smartledger-bsv 3.2.2 → 3.3.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/architecture_demo.js +247 -0
  3. package/bsv-gdaf.min.js +37 -0
  4. package/bsv-ltp.min.js +37 -0
  5. package/bsv-shamir.min.js +12 -0
  6. package/bsv.bundle.js +9 -9
  7. package/build/bsv-smartcontract.min.js +10 -8
  8. package/build/bsv.bundle.js +9 -9
  9. package/build/bsv.min.js +10 -8
  10. package/build/webpack.gdaf.config.js +54 -0
  11. package/build/webpack.ltp.config.js +17 -0
  12. package/bundle-entry.js +77 -1
  13. package/complete_ltp_demo.js +511 -0
  14. package/gdaf-entry.js +54 -0
  15. package/index.js +259 -0
  16. package/lib/crypto/shamir.js +360 -0
  17. package/lib/gdaf/attestation-signer.js +461 -0
  18. package/lib/gdaf/attestation-verifier.js +600 -0
  19. package/lib/gdaf/did-resolver.js +382 -0
  20. package/lib/gdaf/index.js +471 -0
  21. package/lib/gdaf/schema-validator.js +682 -0
  22. package/lib/gdaf/smartledger-anchor.js +486 -0
  23. package/lib/gdaf/zk-prover.js +507 -0
  24. package/lib/ltp/anchor.js +438 -0
  25. package/lib/ltp/claim.js +1026 -0
  26. package/lib/ltp/index.js +470 -0
  27. package/lib/ltp/obligation.js +945 -0
  28. package/lib/ltp/proof.js +828 -0
  29. package/lib/ltp/registry.js +702 -0
  30. package/lib/ltp/right.js +765 -0
  31. package/lib/smart_contract/API_REFERENCE.md +1 -1
  32. package/lib/smart_contract/EXAMPLES.md +2 -2
  33. package/lib/smart_contract/QUICK_START.md +2 -2
  34. package/lib/smart_contract/README.md +1 -1
  35. package/ltp-entry.js +92 -0
  36. package/package.json +44 -4
  37. package/shamir-entry.js +173 -0
  38. package/shamir_demo.js +121 -0
  39. package/simple_demo.js +204 -0
  40. package/test_shamir.js +221 -0
  41. package/test_standalone_shamir.html +83 -0
package/bsv-ltp.min.js ADDED
@@ -0,0 +1,37 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.bsvLTP=e():t.bsvLTP=e()}(this,(function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=150)}([function(t,e,r){"use strict";(function(t){
2
+ /*!
3
+ * The buffer module from node.js, for the browser.
4
+ *
5
+ * @author Feross Aboukhadijeh <http://feross.org>
6
+ * @license MIT
7
+ */
8
+ var i=r(151),n=r(152),o=r(153);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,r)}function c(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,i){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,r):new Uint8Array(e,r,i);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=d(t,e);return t}(t,e,r,i):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|p(e,r),n=(t=a(t,i)).write(e,r);n!==i&&(t=t.slice(0,n));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(i=e.length)!=i?a(t,0):d(t,e);if("Buffer"===e.type&&o(e.data))return d(t,e.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=a(t,e<0?0:0|l(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function l(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function p(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(i)return H(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function m(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function y(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:b(t,e,r,i,n);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,i,n){var o,s=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){var h=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===u)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var f=!0,d=0;d<u;d++)if(c(t,o+d)!==c(e,d)){f=!1;break}if(f)return o}return-1}function v(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function _(t,e,r,i){return K(H(e,t.length-r),t,r,i)}function S(t,e,r,i){return K(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function w(t,e,r,i){return S(t,e,r,i)}function I(t,e,r,i){return K(F(e),t,r,i)}function A(t,e,r,i){return K(function(t,e){for(var r,i,n,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}(e,t.length-r),t,r,i)}function E(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n<r;){var o,s,a,u,c=t[n],h=null,f=c>239?4:c>223?3:c>191?2:1;if(n+f<=r)switch(f){case 1:c<128&&(h=c);break;case 2:128==(192&(o=t[n+1]))&&(u=(31&c)<<6|63&o)>127&&(h=u);break;case 3:o=t[n+1],s=t[n+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=t[n+1],s=t[n+2],a=t[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,f=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h),n+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=4096));return r}(i)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return c(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,i){return h(e),e<=0?a(t,e):void 0!==r?"string"==typeof i?a(t,e).fill(r,i):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=u.allocUnsafe(e),n=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n),n+=s.length}return i},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,i,n){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),c=this.slice(i,n),h=t.slice(e,r),f=0;f<a;++f)if(c[f]!==h[f]){o=c[f],s=h[f];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},u.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return S(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return I(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function k(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function P(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function M(t,e,r){var i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=e;o<r;++o)n+=j(t[o]);return n}function T(t,e,r){for(var i=t.slice(e,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function x(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,r,i,n,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function C(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,o=Math.min(t.length-r,2);n<o;++n)t[r+n]=(e&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function B(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,o=Math.min(t.length-r,4);n<o;++n)t[r+n]=e>>>8*(i?n:3-n)&255}function N(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,i,o){return o||N(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,o){return o||N(t,0,r,8),n.write(t,e,r,i,52,8),r+8}u.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var n=e-t;r=new u(n,void 0);for(var o=0;o<n;++o)r[o]=this[o+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||x(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||x(t,e,this.length);for(var i=this[t+--e],n=1;e>0&&(n*=256);)i+=this[t+--e]*n;return i},u.prototype.readUInt8=function(t,e){return e||x(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||x(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||x(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||x(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||x(t,e,this.length);for(var i=e,n=1,o=this[t+--i];i>0&&(n*=256);)o+=this[t+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||x(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||x(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||x(t,4,this.length),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||x(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||x(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||x(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||R(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[e]=255&t;++o<r&&(n*=256);)this[e+o]=t/n&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||R(this,t,e,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[e+n]=255&t;--n>=0&&(o*=256);)this[e+n]=t/o&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n,o=i-r;if(this===t&&r<e&&e<i)for(n=o-1;n>=0;--n)t[n+e]=this[n+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)t[n+e]=this[n+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},u.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length){var n=t.charCodeAt(0);n<256&&(t=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=u.isBuffer(t)?t:H(new u(t,i).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var U=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){var r;e=e||1/0;for(var i=t.length,n=null,o=[],s=0;s<i;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,i){for(var n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(12))},function(t,e,r){
9
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
10
+ var i=r(0),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(o(i,e),e.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";var i={isArray:t=>Array.isArray(t),isNumber:t=>"number"==typeof t,isObject:t=>t&&"object"==typeof t,isString:t=>"string"==typeof t,isUndefined:t=>void 0===t,isFunction:t=>"function"==typeof t,isNull:t=>null===t,isDate:t=>t instanceof Date,extend:(t,e)=>Object.assign(t,e),noop:()=>{},every:(t,e)=>t.every(e||(t=>t)),map:(t,e)=>Array.from(t).map(e||(t=>t)),includes:(t,e)=>t.includes(e),each:(t,e)=>t.forEach(e),clone:t=>Object.assign({},t),pick:(t,e)=>{const r={};return e.forEach(e=>{void 0!==t[e]&&(r[e]=t[e])}),r},values:t=>Object.values(t),filter:(t,e)=>t.filter(e),reduce:(t,e,r)=>t.reduce(e,r),without:(t,e)=>t.filter(t=>t!==e),shuffle:t=>{const e=t.slice(0);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e},difference:(t,e)=>t.filter(t=>!e.includes(t)),findIndex:(t,e)=>t.findIndex(e),some:(t,e)=>t.some(e),range:t=>[...Array(t).keys()]};t.exports=i},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var i=r(16),n=r(2);t.exports={checkState:function(t,e){if(!t)throw new i.InvalidState(e)},checkArgument:function(t,e,r,n){if(!t)throw new i.InvalidArgument(e,r,n)},checkArgumentType:function(t,e,o){if(o=o||"(unknown name)",n.isString(e)){if("Buffer"===e){if(!r(0).Buffer.isBuffer(t))throw new i.InvalidArgumentType(t,e,o)}else if(typeof t!==e)throw new i.InvalidArgumentType(t,e,o)}else if(!(t instanceof e))throw new i.InvalidArgumentType(t,e.name,o)}}},function(t,e,r){"use strict";(function(e,i){var n=t.exports;n.deps=n.deps||{};try{n.deps.bnjs=r(6),n.deps.bs58=r(92),n.deps.Buffer=void 0!==e?e:null,n.deps.elliptic=r(30),n.deps._=r(2)}catch(t){console.warn("Some dependencies may not be available in browser environment:",t.message)}n.version="v"+r(175).version,n.versionGuard=function(t){if(void 0!==t){console.warn("\n More than one instance of bsv found.\n Please make sure to require bsv and check that submodules do\n not also include their own bsv dependency.")}},n.versionGuard(i._bsv),i._bsv=n.version,n.isHardened=!0,n.hardenedBy="SmartLedger",n.baseVersion="v1.5.6",n.securityFeatures=["canonical-signatures","malleability-protection","enhanced-validation","elliptic-patches"],n.crypto={},n.crypto.BN=r(7),n.crypto.ECDSA=r(65),n.crypto.Hash=r(9),n.crypto.Random=r(49),n.crypto.Point=r(17),n.crypto.Signature=r(8),n.crypto.Shamir=r(144),n.crypto.SmartVerify=r(87),n.crypto.EllipticFixed=r(88),n.encoding={},n.encoding.Base58=r(59),n.encoding.Base58Check=r(45),n.encoding.BufferReader=r(25),n.encoding.BufferWriter=r(21),n.encoding.Varint=r(46),n.util={},n.util.js=r(10),n.util.preconditions=r(4),n.errors=r(16),n.Address=r(34),n.Block=r(293),n.MerkleBlock=r(145),n.BlockHeader=r(61),n.HDPrivateKey=r(146),n.HDPublicKey=r(147),n.Networks=r(29),n.Opcode=r(84),n.PrivateKey=r(58),n.PublicKey=r(20),n.Script=r(18),n.Transaction=r(60),n.Message=r(295),n.Signature=r(8),n.Shamir=r(144),n.SmartLedger={version:n.version,hardenedBy:n.hardenedBy,baseVersion:n.baseVersion,securityFeatures:n.securityFeatures,SmartVerify:r(87),EllipticFixed:r(88)},n.SmartVerify=r(87),n.EllipticFixed=r(88);try{n.SmartContract=r(297)}catch(t){"undefined"==typeof window&&console.warn("SmartContract module not available:",t.message)}if("undefined"==typeof window)try{n.SmartUTXO=r(306),n.SmartMiner=r(308),n.CustomScriptHelper=r(309)}catch(t){}n.GDAF=r(310),n.createDID=function(t){return(new n.GDAF).createDID(t)},n.resolveDID=function(t){return(new n.GDAF).resolveDID(t)},n.createEmailCredential=function(t,e,r,i){return(new n.GDAF).createEmailCredential(t,e,r,i)},n.createAgeCredential=function(t,e,r,i,o){return(new n.GDAF).createAgeCredential(t,e,r,i,o)},n.createKYCCredential=function(t,e,r,i,o){return(new n.GDAF).createKYCCredential(t,e,r,i,o)},n.verifyCredential=function(t,e){return(new n.GDAF).verifyCredential(t,e)},n.validateCredential=function(t,e){return(new n.GDAF).validateCredential(t,e)},n.generateSelectiveProof=function(t,e,r){return(new n.GDAF).generateSelectiveProof(t,e,r)},n.generateAgeProof=function(t,e,r){return(new n.GDAF).generateAgeProof(t,e,r)},n.verifyAgeProof=function(t,e,r){return(new n.GDAF).verifyAgeProof(t,e,r)},n.createPresentation=function(t,e,r,i){return(new n.GDAF).createPresentation(t,e,r,i)},n.getCredentialSchemas=function(){return(new n.GDAF).getAllSchemas()},n.createCredentialTemplate=function(t){return(new n.GDAF).createTemplate(t)},n.LTP=r(315),n.prepareRightToken=function(t,e,r,i,o,s){return n.LTP.Right.prepareRightToken(t,e,r,i,o,s)},n.prepareRightTokenVerification=function(t,e){return n.LTP.Right.prepareRightTokenVerification(t,e)},n.prepareRightTokenTransfer=function(t,e,r,i){return n.LTP.Right.prepareRightTokenTransfer(t,e,r,i)},n.prepareRightTypeValidation=function(t){return n.LTP.Right.prepareRightTypeValidation(t)},n.prepareObligationToken=function(t,e,r,i,o,s){return n.LTP.Obligation.prepareObligationToken(t,e,r,i,o,s)},n.prepareObligationVerification=function(t,e){return n.LTP.Obligation.prepareObligationVerification(t,e)},n.prepareObligationFulfillment=function(t,e,r,i){return n.LTP.Obligation.prepareObligationFulfillment(t,e,r,i)},n.prepareObligationBreachAssessment=function(t,e,r){return n.LTP.Obligation.prepareObligationBreachAssessment(t,e,r)},n.prepareObligationMonitoringReport=function(t,e){return n.LTP.Obligation.prepareObligationMonitoringReport(t,e)},n.prepareClaimValidation=function(t,e){return n.LTP.Claim.prepareClaimValidation(t,e)},n.prepareClaimAttestation=function(t,e,r){return n.LTP.Claim.prepareClaimAttestation(t,e,r)},n.prepareClaimDispute=function(t,e,r){return n.LTP.Claim.prepareClaimDispute(t,e,r)},n.prepareBulkClaimValidation=function(t,e){return n.LTP.Claim.prepareBulkClaimValidation(t,e)},n.prepareClaimTemplate=function(t,e){return n.LTP.Claim.prepareClaimTemplate(t,e)},n.prepareSignatureProof=function(t,e,r){return n.LTP.Proof.prepareSignatureProof(t,e,r)},n.prepareSignatureVerification=function(t,e){return n.LTP.Proof.prepareSignatureVerification(t,e)},n.prepareSelectiveDisclosure=function(t,e,r){return n.LTP.Proof.prepareSelectiveDisclosure(t,e,r)},n.prepareSelectiveDisclosureVerification=function(t,e){return n.LTP.Proof.prepareSelectiveDisclosureVerification(t,e)},n.prepareLegalValidityProof=function(t,e,r){return n.LTP.Proof.prepareLegalValidityProof(t,e,r)},n.prepareZeroKnowledgeProof=function(t,e,r){return n.LTP.Proof.prepareZeroKnowledgeProof(t,e,r)},n.prepareRegistry=function(t){return n.LTP.Registry.prepareRegistry(t)},n.prepareTokenRegistration=function(t,e,r){return n.LTP.Registry.prepareTokenRegistration(t,e,r)},n.prepareTokenApproval=function(t,e,r){return n.LTP.Registry.prepareTokenApproval(t,e,r)},n.prepareTokenRevocation=function(t,e,r){return n.LTP.Registry.prepareTokenRevocation(t,e,r)},n.prepareTokenStatusQuery=function(t,e){return n.LTP.Registry.prepareTokenStatusQuery(t,e)},n.prepareTokenSearch=function(t,e){return n.LTP.Registry.prepareTokenSearch(t,e)},n.prepareStatisticsQuery=function(t){return n.LTP.Registry.prepareStatisticsQuery(t)},n.prepareAuditLogQuery=function(t,e){return n.LTP.Registry.prepareAuditLogQuery(t,e)},n.prepareTokenCommitment=function(t,e){return n.LTP.Anchor.prepareTokenCommitment(t,e)},n.prepareBatchCommitment=function(t,e){return n.LTP.Anchor.prepareBatchCommitment(t,e)},n.verifyTokenAnchor=function(t,e,r){return n.LTP.Anchor.verifyTokenAnchor(t,e,r)},n.formatRevocation=function(t,e){return n.LTP.Anchor.formatRevocation(t,e)},n.getRightTypes=function(){return n.LTP.Right.getRightTypes()},n.getObligationTypes=function(){return n.LTP.Obligation.getObligationTypes()},n.getObligationPriority=function(){return n.LTP.Obligation.getObligationPriority()},n.getObligationStatus=function(){return n.LTP.Obligation.getObligationStatus()},n.getClaimSchemas=function(){return n.LTP.Claim.getSchemas()},n.getClaimSchemaNames=function(){return n.LTP.Claim.getSchemaNames()},n.getClaimSchema=function(t){return n.LTP.Claim.getSchema(t)},n.createClaimTemplate=function(t){return n.LTP.Claim.createTemplate(t)},n.canonicalizeClaim=function(t){return n.LTP.Claim.canonicalize(t)},n.hashClaim=function(t){return n.LTP.Claim.hash(t)},n.addCustomClaimSchema=function(t,e){return n.LTP.Claim.addSchema(t,e)},n.Transaction.sighash=r(26)}).call(this,r(0).Buffer,r(12))},function(t,e,r){(function(t){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=r(154).Buffer}catch(t){}function a(t,e,r){for(var i=0,n=Math.min(t.length,r),o=e;o<n;o++){var s=t.charCodeAt(o)-48;i<<=4,i|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return i}function u(t,e,r,i){for(var n=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s,a=0;if("be"===r)for(n=t.length-1,o=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,n,o=0;for(r=t.length-6,i=0;r>=e;r-=6)n=a(t,r,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303,(o+=24)>=26&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,c=0,h=r;h<a;h+=i)c=u(t,h,h+i,e),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var f=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.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"],h=[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],f=[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];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<i;c++){for(var h=u>>>26,f=67108863&u,d=Math.min(c,e.length-1),l=Math.max(0,c-t.length+1);l<=d;l++){var p=c-l|0;h+=(s=(n=0|t.words[p])*(o=0|e.words[l])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<n|o)).toString(16);r=0!==(o=a>>>24-n&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var d=h[t],l=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(l).toString(t);r=(p=p.idivn(l)).isZero()?g+r:c[d-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return i(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===e,c=new t(o),h=this.clone();if(u){for(a=0;!h.isZero();a++)s=h.andln(255),h.iushrn(8),c[a]=s;for(;a<o;a++)c[a]=0}else{for(a=0;a<o-n;a++)c[a]=0;for(a=0;!h.isZero();a++)s=h.andln(255),h.iushrn(8),c[o-a-1]=s}return c},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},o.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},o.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},o.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},o.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(e=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var l=function(t,e,r){var i,n,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],f=8191&h,d=h>>>13,l=0|s[1],p=8191&l,g=l>>>13,m=0|s[2],y=8191&m,b=m>>>13,v=0|s[3],_=8191&v,S=v>>>13,w=0|s[4],I=8191&w,A=w>>>13,E=0|s[5],O=8191&E,k=E>>>13,P=0|s[6],M=8191&P,T=P>>>13,x=0|s[7],R=8191&x,C=x>>>13,B=0|s[8],N=8191&B,D=B>>>13,L=0|s[9],U=8191&L,j=L>>>13,H=0|a[0],F=8191&H,K=H>>>13,V=0|a[1],z=8191&V,q=V>>>13,G=0|a[2],Y=8191&G,W=G>>>13,X=0|a[3],Z=8191&X,J=X>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],ft=8191&ht,dt=ht>>>13,lt=0|a[9],pt=8191&lt,gt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(c+(i=Math.imul(f,F))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(d,F)|0))<<13)|0;c=((o=Math.imul(d,K))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,F),n=(n=Math.imul(p,K))+Math.imul(g,F)|0,o=Math.imul(g,K);var yt=(c+(i=i+Math.imul(f,z)|0)|0)+((8191&(n=(n=n+Math.imul(f,q)|0)+Math.imul(d,z)|0))<<13)|0;c=((o=o+Math.imul(d,q)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,K))+Math.imul(b,F)|0,o=Math.imul(b,K),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,q)|0)+Math.imul(g,z)|0,o=o+Math.imul(g,q)|0;var bt=(c+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,W)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,K))+Math.imul(S,F)|0,o=Math.imul(S,K),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,q)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,q)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,W)|0;var vt=(c+(i=i+Math.imul(f,Z)|0)|0)+((8191&(n=(n=n+Math.imul(f,J)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(I,F),n=(n=Math.imul(I,K))+Math.imul(A,F)|0,o=Math.imul(A,K),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,q)|0)+Math.imul(S,z)|0,o=o+Math.imul(S,q)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,W)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var _t=(c+(i=i+Math.imul(f,Q)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(O,F),n=(n=Math.imul(O,K))+Math.imul(k,F)|0,o=Math.imul(k,K),i=i+Math.imul(I,z)|0,n=(n=n+Math.imul(I,q)|0)+Math.imul(A,z)|0,o=o+Math.imul(A,q)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,W)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0;var St=(c+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(d,rt)|0))<<13)|0;c=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(M,F),n=(n=Math.imul(M,K))+Math.imul(T,F)|0,o=Math.imul(T,K),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,q)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,q)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,W)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,W)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,J)|0)+Math.imul(S,Z)|0,o=o+Math.imul(S,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,it)|0;var wt=(c+(i=i+Math.imul(f,ot)|0)|0)+((8191&(n=(n=n+Math.imul(f,st)|0)+Math.imul(d,ot)|0))<<13)|0;c=((o=o+Math.imul(d,st)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,K))+Math.imul(C,F)|0,o=Math.imul(C,K),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,q)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,q)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,W)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(S,Q)|0,o=o+Math.imul(S,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var It=(c+(i=i+Math.imul(f,ut)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((o=o+Math.imul(d,ct)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,q)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,q)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,W)|0,i=i+Math.imul(O,Z)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,i=i+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0;var At=(c+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,dt)|0)+Math.imul(d,ft)|0))<<13)|0;c=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,F),n=(n=Math.imul(U,K))+Math.imul(j,F)|0,o=Math.imul(j,K),i=i+Math.imul(N,z)|0,n=(n=n+Math.imul(N,q)|0)+Math.imul(D,z)|0,o=o+Math.imul(D,q)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(M,Z)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,dt)|0;var Et=(c+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,gt)|0)+Math.imul(d,pt)|0))<<13)|0;c=((o=o+Math.imul(d,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,z),n=(n=Math.imul(U,q))+Math.imul(j,z)|0,o=Math.imul(j,q),i=i+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(D,Y)|0,o=o+Math.imul(D,W)|0,i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(I,ot)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,ct)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,ct)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,dt)|0;var Ot=(c+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,W))+Math.imul(j,Y)|0,o=Math.imul(j,W),i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,it)|0,i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,i=i+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ct)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ct)|0,i=i+Math.imul(_,ft)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(S,ft)|0,o=o+Math.imul(S,dt)|0;var kt=(c+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,Z),n=(n=Math.imul(U,J))+Math.imul(j,Z)|0,o=Math.imul(j,J),i=i+Math.imul(N,Q)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,i=i+Math.imul(I,ft)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,dt)|0;var Pt=(c+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,gt)|0)+Math.imul(S,pt)|0))<<13)|0;c=((o=o+Math.imul(S,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(j,Q)|0,o=Math.imul(j,tt),i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,o=o+Math.imul(D,it)|0,i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ct)|0,i=i+Math.imul(O,ft)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(k,ft)|0,o=o+Math.imul(k,dt)|0;var Mt=(c+(i=i+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(A,pt)|0))<<13)|0;c=((o=o+Math.imul(A,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(j,rt)|0,o=Math.imul(j,it),i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,ot)|0,o=o+Math.imul(D,st)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,i=i+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,dt)|0;var Tt=(c+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,ot),n=(n=Math.imul(U,st))+Math.imul(j,ot)|0,o=Math.imul(j,st),i=i+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(D,ut)|0,o=o+Math.imul(D,ct)|0,i=i+Math.imul(R,ft)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,dt)|0;var xt=(c+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(T,pt)|0))<<13)|0;c=((o=o+Math.imul(T,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,ut),n=(n=Math.imul(U,ct))+Math.imul(j,ut)|0,o=Math.imul(j,ct),i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(D,ft)|0,o=o+Math.imul(D,dt)|0;var Rt=(c+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,gt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,ft),n=(n=Math.imul(U,dt))+Math.imul(j,ft)|0,o=Math.imul(j,dt);var Ct=(c+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(D,pt)|0))<<13)|0;c=((o=o+Math.imul(D,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(c+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,gt))+Math.imul(j,pt)|0))<<13)|0;return c=((o=Math.imul(j,gt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,u[0]=mt,u[1]=yt,u[2]=bt,u[3]=vt,u[4]=_t,u[5]=St,u[6]=wt,u[7]=It,u[8]=At,u[9]=Et,u[10]=Ot,u[11]=kt,u[12]=Pt,u[13]=Mt,u[14]=Tt,u[15]=xt,u[16]=Rt,u[17]=Ct,u[18]=Bt,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(l=d),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):r<63?d(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var s=n;n=0;for(var a=67108863&i,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,f=(0|t.words[h])*(0|e.words[c]),d=67108863&f;a=67108863&(d=d+a|0),n+=(s=(s=s+(f/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,t,e):p(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s<o;s++)i[s]=e[t[s]],n[s]=r[t[s]]},g.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var s=1;s<n;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),c=Math.sin(2*Math.PI/a),h=0;h<n;h+=a)for(var f=u,d=c,l=0;l<s;l++){var p=r[h+l],g=i[h+l],m=r[h+l+s],y=i[h+l+s],b=f*m-d*y;y=f*y+d*m,m=b,r[h+l]=p+m,i[h+l]=g+y,r[h+l+s]=p-m,i[h+l+s]=g-y,l!==a&&(b=u*f-c*d,d=u*d+c*f,f=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<n;++s)r[s]=0;i(0===o),i(0==(-8192&o))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),s=new Array(i),a=new Array(i),u=new Array(i),c=new Array(i),h=new Array(i),f=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(e.words,e.length,c,i),this.transform(s,o,a,u,i,n),this.transform(c,o,h,f,i,n);for(var l=0;l<i;l++){var p=a[l]*h[l]-u[l]*f[l];u[l]=a[l]*f[l]+u[l]*h[l],a[l]=p}return this.conjugate(a,u,i),this.transform(a,u,d,o,i,n),this.conjugate(d,o,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),p(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){i("number"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,o=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},o.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<r;this.words[e]=u|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=r;if(n-=s,n=Math.max(0,n),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=n);c--){var f=0|this.words[c];this.words[c]=h<<26-o|f>>>o,h=f&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},o.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var n,o,s=t.length+r;this._expand(s);var a=0;for(n=0;n<t.length;n++){o=(0|this.words[n+r])+a;var u=(0|t.words[n])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&o}for(;n<this.length-r;n++)a=(o=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&o;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(o=-(0|this.words[n])+a)>>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,u=i.length-n.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=i.clone()._ishlnsubmul(n,1,u);0===h.negative&&(i=h,a&&(a.words[u]=1));for(var f=u-1;f>=0;f--){var d=67108864*(0|i.words[n.length+f])+(0|i.words[n.length+f-1]);for(d=Math.min(d/s|0,67108863),i._ishlnsubmul(n,d,f);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(n,1,f),i.isZero()||(i.negative^=1);a&&(a.words[f]=d)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},o.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),f=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(h),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(f)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(u)):(r.isub(e),a.isub(n),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var o=n,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new w(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,e){for(var r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=4194303&n,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,t.words[i-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(v,y),n(_,y),n(S,y),S.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new v;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return m[t]=e,e},w.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,n),d=this.pow(t,n.addn(1).iushrn(1)),l=this.pow(t,n),p=s;0!==l.cmp(a);){for(var g=l,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m<p);var y=this.pow(f,new o(1).iushln(p-m-1));d=d.redMul(y),f=y.redSqr(),l=l.redMul(f),p=m}return d},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),i=e.length-1;i>=0;i--){for(var c=e.words[i],h=u-1;h>=0;h--){var f=c>>h&1;n!==r[0]&&(n=this.sqr(n)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===i&&0===h)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}u=26}return n},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},n(I,w),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(23)(t))},function(t,e,r){"use strict";(function(e){var i=r(6),n=r(4),o=r(2),s=function(t){for(var r=e.alloc(t.length),i=0;i<t.length;i++)r[i]=t[t.length-1-i];return r};i.Zero=new i(0),i.One=new i(1),i.Minus1=new i(-1),i.fromNumber=function(t){return n.checkArgument(o.isNumber(t)),new i(t)},i.fromString=function(t,e){return n.checkArgument(o.isString(t)),new i(t,e)},i.fromBuffer=function(t,e){void 0!==e&&"little"===e.endian&&(t=s(t));var r=t.toString("hex");return new i(r,16)},i.fromSM=function(t,r){var n;if(0===t.length)return i.fromBuffer(e.from([0]));var o="big";return r&&(o=r.endian),"little"===o&&(t=s(t)),128&t[0]?(t[0]=127&t[0],(n=i.fromBuffer(t)).neg().copy(n)):n=i.fromBuffer(t),n},i.prototype.toNumber=function(){return parseInt(this.toString(10),10)},i.prototype.toBuffer=function(t){var r,n;if(t&&t.size){var o=(n=this.toString(16,2)).length/2;r=e.from(n,"hex"),o===t.size||(o>t.size?r=i.trim(r,o):o<t.size&&(r=i.pad(r,o,t.size)))}else n=this.toString(16,2),r=e.from(n,"hex");return void 0!==t&&"little"===t.endian&&(r=s(r)),r},i.prototype.toSMBigEndian=function(){var t;return-1===this.cmp(i.Zero)?128&(t=this.neg().toBuffer())[0]?t=e.concat([e.from([128]),t]):t[0]=128|t[0]:128&(t=this.toBuffer())[0]&&(t=e.concat([e.from([0]),t])),1===t.length&0===t[0]&&(t=e.from([])),t},i.prototype.toSM=function(t){var e=t?t.endian:"big",r=this.toSMBigEndian();return"little"===e&&(r=s(r)),r},i.fromScriptNumBuffer=function(t,e,r){var o=r||4;if(n.checkArgument(t.length<=o,new Error("script number overflow")),e&&t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))throw new Error("non-minimally encoded script number");return i.fromSM(t,{endian:"little"})},i.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},i.trim=function(t,e){return t.slice(e-t.length,t.length)},i.pad=function(t,r,i){for(var n=e.alloc(i),o=0;o<t.length;o++)n[n.length-1-o]=t[t.length-1-o];for(o=0;o<i-r;o++)n[o]=0;return n},i.prototype.toHex=function(...t){return this.toBuffer(...t).toString("hex")},i.fromHex=function(t,...r){return i.fromBuffer(e.from(t,"hex"),...r)},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(7),n=r(2),o=r(4),s=r(10),a=function t(e,r){if(!(this instanceof t))return new t(e,r);if(e instanceof i)this.set({r:e,s:r});else if(e){var n=e;this.set(n)}};a.prototype.set=function(t){return this.r=t.r||this.r||void 0,this.s=t.s||this.s||void 0,this.i=void 0!==t.i?t.i:this.i,this.compressed=void 0!==t.compressed?t.compressed:this.compressed,this.nhashtype=t.nhashtype||this.nhashtype||void 0,this},a.fromCompact=function(t){o.checkArgument(e.isBuffer(t),"Argument is expected to be a Buffer");var r=new a,n=!0,s=t.slice(0,1)[0]-27-4;s<0&&(n=!1,s+=4);var u=t.slice(1,33),c=t.slice(33,65);return o.checkArgument(0===s||1===s||2===s||3===s,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===u.length,new Error("r must be 32 bytes")),o.checkArgument(32===c.length,new Error("s must be 32 bytes")),r.compressed=n,r.i=s,r.r=i.fromBuffer(u),r.s=i.fromBuffer(c),r},a.fromDER=a.fromBuffer=function(t,e){var r=a.parseDER(t,e),i=new a;return i.r=r.r,i.s=r.s,i},a.fromTxFormat=function(t){var e=t.readUInt8(t.length-1),r=t.slice(0,t.length-1),i=a.fromDER(r,!1);return i.nhashtype=e,i},a.fromString=function(t){var r=e.from(t,"hex");return a.fromDER(r)},a.parseDER=function(t,r){o.checkArgument(e.isBuffer(t),new Error("DER formatted signature should be a buffer")),n.isUndefined(r)&&(r=!0);var s=t[0];o.checkArgument(48===s,new Error("Header byte should be 0x30"));var a=t[1],u=t.slice(2).length;o.checkArgument(!r||a===u,new Error("Length byte should length of what follows")),a=a<u?a:u;var c=t[2];o.checkArgument(2===c,new Error("Integer byte for r should be 0x02"));var h=t[3],f=t.slice(4,4+h),d=i.fromBuffer(f),l=0===t[4];o.checkArgument(h===f.length,new Error("Length of r incorrect"));var p=t[4+h+0];o.checkArgument(2===p,new Error("Integer byte for s should be 0x02"));var g=t[4+h+1],m=t.slice(4+h+2,4+h+2+g),y=i.fromBuffer(m),b=0===t[4+h+2+2];o.checkArgument(g===m.length,new Error("Length of s incorrect"));var v=4+h+2+g;return o.checkArgument(a===v-2,new Error("Length of signature incorrect")),{header:s,length:a,rheader:c,rlength:h,rneg:l,rbuf:f,r:d,sheader:p,slength:g,sneg:b,sbuf:m,s:y}},a.prototype.toCompact=function(t,r){if(t="number"==typeof t?t:this.i,r="boolean"==typeof r?r:this.compressed,0!==t&&1!==t&&2!==t&&3!==t)throw new Error("i must be equal to 0, 1, 2, or 3");var i=t+27+4;!1===r&&(i-=4);var n=e.from([i]),o=this.r.toBuffer({size:32}),s=this.s.toBuffer({size:32});return e.concat([n,o,s])},a.prototype.toBuffer=a.prototype.toDER=function(){var t=this.r.toBuffer(),r=this.s.toBuffer(),i=!!(128&t[0]),n=!!(128&r[0]),o=i?e.concat([e.from([0]),t]):t,s=n?e.concat([e.from([0]),r]):r,a=o.length,u=s.length,c=2+a+2+u;return e.concat([e.from([48,c,2,a]),o,e.from([2,u]),s])},a.prototype.toString=function(){return this.toDER().toString("hex")},a.isTxDER=function(t){if(t.length<9)return!1;if(t.length>73)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-3)return!1;var e=t[3];if(5+e>=t.length)return!1;var r=t[5+e];if(e+r+7!==t.length)return!1;var i=t.slice(4);if(2!==t[2])return!1;if(0===e)return!1;if(128&i[0])return!1;if(e>1&&0===i[0]&&!(128&i[1]))return!1;var n=t.slice(6+e);return 2===t[6+e-2]&&(0!==r&&(!(128&n[0])&&!(r>1&&0===n[0]&&!(128&n[1]))))},a.prototype.hasLowS=function(){return!this.s.lt(new i(1))&&!this.s.gt(new i("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},a.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var t=31&this.nhashtype;return!(t<a.SIGHASH_ALL||t>a.SIGHASH_SINGLE)},a.prototype.toTxFormat=function(){var t=this.toDER(),r=e.alloc(1);return r.writeUInt8(this.nhashtype,0),e.concat([t,r])},a.SIGHASH_ALL=1,a.SIGHASH_NONE=2,a.SIGHASH_SINGLE=3,a.SIGHASH_FORKID=64,a.SIGHASH_ANYONECANPAY=128,a.prototype.isCanonical=function(){var t=r(17).getN().shrn(1);return this.s.lte(t)},a.prototype.toCanonical=function(){if(this.isCanonical())return new a({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var t=r(17).getN().sub(this.s);return new a({r:this.r,s:t,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})},a.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 t=r(17).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},a.prototype.isValid=function(){try{return this.validate(),!0}catch(t){return!1}},a.prototype.applySecurityPatches=function(){var t=r(17).getN(),e=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");return this.s.gt(e)&&(this.s=t.sub(this.s)),this},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){(function(e){e.browser?t.exports=r(177):t.exports=r(178)}).call(this,r(11))},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=function(t){return!!i.isString(t)&&/^[0-9a-fA-F]+$/.test(t)};t.exports={isValidJSON:function(t){var e;if(!i.isString(t))return!1;try{e=JSON.parse(t)}catch(t){return!1}return"object"==typeof e},isHexa:o,isHexaString:o,defineImmutable:function(t,e){return Object.keys(e).forEach((function(r){Object.defineProperty(t,r,{configurable:!1,enumerable:!0,value:e[r]})})),t},isNaturalNumber:function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){n.checkArgumentType(t,"number","integer");const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}}).call(this,r(0).Buffer)},function(t,e){var r,i,n=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var u,c=[],h=!1,f=-1;function d(){h&&u&&(h=!1,u.length?c=u.concat(c):f=-1,c.length&&l())}function l(){if(!h){var t=a(d);h=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;)u&&u[f].run();f=-1,e=c.length}u=null,h=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new p(t,e)),1!==c.length||h||a(l)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=g,n.addListener=g,n.once=g,n.off=g,n.removeListener=g,n.removeAllListeners=g,n.emit=g,n.prependListener=g,n.prependOnceListener=g,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var i=e,n=r(6),o=r(14),s=r(93);i.assert=o,i.toArray=s.toArray,i.zero2=s.zero2,i.toHex=s.toHex,i.encode=s.encode,i.getNAF=function(t,e,r){var i,n=new Array(Math.max(t.bitLength(),r)+1);for(i=0;i<n.length;i+=1)n[i]=0;var o=1<<e+1,s=t.clone();for(i=0;i<n.length;i++){var a,u=s.andln(o-1);s.isOdd()?(a=u>(o>>1)-1?(o>>1)-u:u,s.isubn(a)):a=0,n[i]=a,s.iushrn(1)}return n},i.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,o=0;t.cmpn(-n)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+n&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!==(i=t.andln(7)+n&7)&&5!==i||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!==(i=e.andln(7)+o&7)&&5!==i||2!==u?c:-c,r[1].push(a),2*n===s+1&&(n=1-n),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},i.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(t){return"string"==typeof t?i.toArray(t,"hex"):t},i.intFromLE=function(t){return new n(t,"hex","le")}},function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e,r){"use strict";e.randomBytes=e.rng=e.pseudoRandomBytes=e.prng=r(31),e.createHash=e.Hash=r(36),e.createHmac=e.Hmac=r(112);var i=r(235),n=Object.keys(i),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);e.getHashes=function(){return o};var s=r(115);e.pbkdf2=s.pbkdf2,e.pbkdf2Sync=s.pbkdf2Sync;var a=r(237);e.Cipher=a.Cipher,e.createCipher=a.createCipher,e.Cipheriv=a.Cipheriv,e.createCipheriv=a.createCipheriv,e.Decipher=a.Decipher,e.createDecipher=a.createDecipher,e.Decipheriv=a.Decipheriv,e.createDecipheriv=a.createDecipheriv,e.getCiphers=a.getCiphers,e.listCiphers=a.listCiphers;var u=r(252);e.DiffieHellmanGroup=u.DiffieHellmanGroup,e.createDiffieHellmanGroup=u.createDiffieHellmanGroup,e.getDiffieHellman=u.getDiffieHellman,e.createDiffieHellman=u.createDiffieHellman,e.DiffieHellman=u.DiffieHellman;var c=r(255);e.createSign=c.createSign,e.Sign=c.Sign,e.createVerify=c.createVerify,e.Verify=c.Verify,e.createECDH=r(275);var h=r(276);e.publicEncrypt=h.publicEncrypt,e.privateEncrypt=h.privateEncrypt,e.publicDecrypt=h.publicDecrypt,e.privateDecrypt=h.privateDecrypt;var f=r(279);e.randomFill=f.randomFill,e.randomFillSync=f.randomFillSync,e.createCredentials=function(){throw new Error("sorry, createCredentials is not implemented yet\nwe accept pull requests\nhttps://github.com/browserify/crypto-browserify")},e.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},function(t,e,r){"use strict";var i=r(2);function n(t,e){return t.replace("{0}",e[0]).replace("{1}",e[1]).replace("{2}",e[2])}var o=function(t,e){var r=function(){if(i.isString(e.message))this.message=n(e.message,arguments);else{if(!i.isFunction(e.message))throw new Error("Invalid error definition for "+e.name);this.message=e.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(t.prototype)).name=t.prototype.name+e.name,t[e.name]=r,e.errors&&s(r,e.errors),r},s=function(t,e){i.each(e,(function(e){o(t,e)}))},a={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};a.Error.prototype=Object.create(Error.prototype),a.Error.prototype.name="bsv.Error";var u,c=r(176);u=a.Error,s(u,c),t.exports=a.Error,t.exports.extend=function(t){return o(a.Error,t)}},function(t,e,r){"use strict";(function(e){var i=r(7),n=new(0,r(30).ec)("secp256k1"),o=n.curve.point.bind(n.curve),s=n.curve.pointFromX.bind(n.curve),a=function(t,e,r){try{var i=o(t,e,r)}catch(t){throw new Error("Invalid Point")}return i.validate(),i};a.prototype=Object.getPrototypeOf(n.curve.point()),a.fromX=function(t,e){try{var r=s(e,t)}catch(t){throw new Error("Invalid X")}return r.validate(),r},a.getG=function(){return n.curve.g},a.getN=function(){return new i(n.curve.n.toArray())},a.prototype._getX||(a.prototype._getX=a.prototype.getX),a.prototype.getX=function(){return new i(this._getX().toArray())},a.prototype._getY||(a.prototype._getY=a.prototype.getY),a.prototype.getY=function(){return new i(this._getY().toArray())},a.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t;try{t=s(this.getX(),this.getY().isOdd())}catch(t){throw new Error("Point does not lie on the curve")}if(0!==t.y.cmp(this.y))throw new Error("Invalid y value for curve.");if(!this.mul(a.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},a.pointToCompressed=function(t){var r,i=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32});return r=n[n.length-1]%2?e.from([3]):e.from([2]),e.concat([r,i])},a.pointFromCompressed=function(t){if(33!==t.length)throw new Error("invalid buffer length");let e,r=t[0];if(3===r)e=!0;else{if(2!==r)throw new Error("invalid value of compressed prefix");e=!1}let n=t.slice(1,33),o=i.fromBuffer(n);return a.fromX(e,o)},a.prototype.toBuffer=function(){return a.pointToCompressed(this)},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.fromBuffer=function(t){return a.pointFromCompressed(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(138),t.exports.Interpreter=r(85)},function(t,e,r){"use strict";var i=r(14),n=r(3);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=n,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=63&s|128):o(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=63&s|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=63&s|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=a(t[r].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];"little"===e&&(n=s(n)),r+=u(n.toString(16))}return r},e.zero2=a,e.zero8=u,e.join32=function(t,e,r,n){var o=r-e;i(o%4==0);for(var s=new Array(o/4),a=0,u=e;a<s.length;a++,u+=4){var c;c="big"===n?t[u]<<24|t[u+1]<<16|t[u+2]<<8|t[u+3]:t[u+3]<<24|t[u+2]<<16|t[u+1]<<8|t[u],s[a]=c>>>0}return s},e.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var o=t[i];"big"===e?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},e.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},e.sum64=function(t,e,r,i){var n=t[e],o=i+t[e+1]>>>0,s=(o<i?1:0)+r+n;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,i){return e+i>>>0},e.sum64_4_hi=function(t,e,r,i,n,o,s,a){var u=0,c=e;return u+=(c=c+i>>>0)<e?1:0,u+=(c=c+o>>>0)<o?1:0,t+r+n+s+(u+=(c=c+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,i,n,o,s,a){return e+i+o+a>>>0},e.sum64_5_hi=function(t,e,r,i,n,o,s,a,u,c){var h=0,f=e;return h+=(f=f+i>>>0)<e?1:0,h+=(f=f+o>>>0)<o?1:0,h+=(f=f+a>>>0)<a?1:0,t+r+n+s+u+(h+=(f=f+c>>>0)<c?1:0)>>>0},e.sum64_5_lo=function(t,e,r,i,n,o,s,a,u,c){return e+i+o+a+c>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},function(t,e,r){"use strict";(function(e){var i=r(7),n=r(17),o=r(9),s=r(10),a=r(29),u=r(2),c=r(4);function h(t,e){if(!(this instanceof h))return new h(t,e);if(c.checkArgument(t,"First argument is required, please include public key data."),t instanceof h)return t;e=e||{};var r=this._classifyArgs(t,e);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||a.defaultNetwork}),this}h.prototype._classifyArgs=function(t,r){var i={compressed:u.isUndefined(r.compressed)||r.compressed};if(t instanceof n)i.point=t;else if(t.x&&t.y)i=h._transformObject(t);else if("string"==typeof t)i=h._transformDER(e.from(t,"hex"));else if(h._isBuffer(t))i=h._transformDER(t);else{if(!h._isPrivateKey(t))throw new TypeError("First argument is an unrecognized data format.");i=h._transformPrivateKey(t)}return i.network||(i.network=u.isUndefined(r.network)?void 0:a.get(r.network)),i},h._isPrivateKey=function(t){return t instanceof r(58)},h._isBuffer=function(t){return t instanceof e||t instanceof Uint8Array},h._transformPrivateKey=function(t){c.checkArgument(h._isPrivateKey(t),"Must be an instance of PrivateKey");var e={};return e.point=n.getG().mul(t.bn),e.compressed=t.compressed,e.network=t.network,e},h._transformDER=function(t,e){c.checkArgument(h._isBuffer(t),"Must be a buffer of DER encoded public key");var r,o,s,a,f={};if(e=!!u.isUndefined(e)||e,4!==t[0]&&(e||6!==t[0]&&7!==t[0]))if(3===t[0])s=t.slice(1),r=new i(s),(f=h._transformX(!0,r)).compressed=!0;else{if(2!==t[0])throw new TypeError("Invalid DER format public key");s=t.slice(1),r=new i(s),(f=h._transformX(!1,r)).compressed=!0}else{if(s=t.slice(1,33),a=t.slice(33,65),32!==s.length||32!==a.length||65!==t.length)throw new TypeError("Length of x and y must be 32 bytes");r=new i(s),o=new i(a),f.point=new n(r,o),f.compressed=!1}return f},h._transformX=function(t,e){c.checkArgument("boolean"==typeof t,"Must specify whether y is odd or not (true or false)");var r={};return r.point=n.fromX(t,e),r},h._transformObject=function(t){var e=new i(t.x,"hex"),r=new i(t.y,"hex");return new h(new n(e,r),{compressed:t.compressed})},h.fromPrivateKey=function(t){c.checkArgument(h._isPrivateKey(t),"Must be an instance of PrivateKey");var e=h._transformPrivateKey(t);return new h(e.point,{compressed:e.compressed,network:e.network})},h.fromDER=h.fromBuffer=function(t,e){c.checkArgument(h._isBuffer(t),"Must be a buffer of DER encoded public key");var r=h._transformDER(t,e);return new h(r.point,{compressed:r.compressed})},h.fromPoint=function(t,e){return c.checkArgument(t instanceof n,"First argument must be an instance of Point."),new h(t,{compressed:e})},h.fromHex=h.fromString=function(t,r){var i=e.from(t,r||"hex"),n=h._transformDER(i);return new h(n.point,{compressed:n.compressed})},h.fromX=function(t,e){var r=h._transformX(t,e);return new h(r.point,{compressed:r.compressed})},h.getValidationError=function(t){var e;try{new h(t)}catch(t){e=t}return e},h.isValid=function(t){return!h.getValidationError(t)},h.prototype.toObject=h.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},h.prototype.toBuffer=h.prototype.toDER=function(){var t,r=this.point.getX(),i=this.point.getY(),n=r.toBuffer({size:32}),o=i.toBuffer({size:32});return this.compressed?(t=o[o.length-1]%2?e.from([3]):e.from([2]),e.concat([t,n])):(t=e.from([4]),e.concat([t,n,o]))},h.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},h.prototype.toAddress=function(t){return r(34).fromPublicKey(this,t||this.network)},h.prototype.toString=h.prototype.toHex=function(){return this.toDER().toString("hex")},h.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(83),n=function t(e){if(!(this instanceof t))return new t(e);this.bufLen=0,e?this.set(e):this.bufs=[]};n.prototype.set=function(t){return this.bufs=t.bufs||this.bufs||[],this.bufLen=this.bufs.reduce((function(t,e){return t+e.length}),0),this},n.prototype.toBuffer=function(){return this.concat()},n.prototype.concat=function(){return e.concat(this.bufs,this.bufLen)},n.prototype.write=function(t){return i(e.isBuffer(t)),this.bufs.push(t),this.bufLen+=t.length,this},n.prototype.writeReverse=function(t){return i(e.isBuffer(t)),this.bufs.push(e.from(t).reverse()),this.bufLen+=t.length,this},n.prototype.writeUInt8=function(t){var r=e.alloc(1);return r.writeUInt8(t,0),this.write(r),this},n.prototype.writeUInt16BE=function(t){var r=e.alloc(2);return r.writeUInt16BE(t,0),this.write(r),this},n.prototype.writeUInt16LE=function(t){var r=e.alloc(2);return r.writeUInt16LE(t,0),this.write(r),this},n.prototype.writeUInt32BE=function(t){var r=e.alloc(4);return r.writeUInt32BE(t,0),this.write(r),this},n.prototype.writeInt32LE=function(t){var r=e.alloc(4);return r.writeInt32LE(t,0),this.write(r),this},n.prototype.writeUInt32LE=function(t){var r=e.alloc(4);return r.writeUInt32LE(t,0),this.write(r),this},n.prototype.writeUInt64BEBN=function(t){var e=t.toBuffer({size:8});return this.write(e),this},n.prototype.writeUInt64LEBN=function(t){var e=t.toBuffer({size:8});return this.writeReverse(e),this},n.prototype.writeVarintNum=function(t){var e=n.varintBufNum(t);return this.write(e),this},n.prototype.writeVarintBN=function(t){var e=n.varintBufBN(t);return this.write(e),this},n.varintBufNum=function(t){var r;return t<253?(r=e.alloc(1)).writeUInt8(t,0):t<65536?((r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(t,1)):t<4294967296?((r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(t,1)):((r=e.alloc(9)).writeUInt8(255,0),r.writeInt32LE(-1&t,1),r.writeUInt32LE(Math.floor(t/4294967296),5)),r},n.varintBufBN=function(t){var r,i=t.toNumber();if(i<253)(r=e.alloc(1)).writeUInt8(i,0);else if(i<65536)(r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(i,1);else if(i<4294967296)(r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(i,1);else{var o=new n;o.writeUInt8(255),o.writeUInt64LEBN(t),r=o.concat()}return r},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5);r(15);function n(t,r){if(!(this instanceof n))return new n(t,r);this.preimage=e.isBuffer(t)?t:e.from(t,"hex"),this.options=r||{},this.strategy=this.options.strategy||"DYNAMIC",this.fields=null,this.sighashInfo=null,this.options.deferExtraction||this._extractFields()}n.prototype.extract=function(t){return this.strategy=t||this.strategy,this._extractFields(),this.fields},n.prototype.getSighashInfo=function(){return this.fields||this._extractFields(),this.sighashInfo},n.prototype.getField=function(t){return this.fields||this._extractFields(),this.fields[t]},n.prototype.extractField=function(t,e){e=e||{},this.fields||this._extractFields();var r=this._parsePreimageStructure(),i=this._generateBidirectionalASM(t,r,e.includeComments),n=this._extractSpecificField(t,r),o=this._interpretField(t,n,r);return{field:t,value:n?n.toString("hex"):null,buffer:n,asm:i,interpretation:o,strategy:this._getExtractionStrategy(t),structure:r._structure}},n.prototype.generateASM=function(t,e){var r=this._parsePreimageStructure();return this._generateBidirectionalASM(t,r,e)},n.prototype.extractFields=function(t){var e={};return t.forEach(function(t){e[t]=this.extractField(t)}.bind(this)),e},n.prototype.validate=function(){this.fields||this._extractFields();var t=[],e=[];return["version","hashPrevouts","hashSequence","outpoint","scriptCode","amount","sequence","hashOutputs","locktime","sighash"].forEach(function(e){this.fields[e]||t.push("Missing required field: "+e)}.bind(this)),this.sighashInfo.hasZeroHashes&&e.push("Zero hashes detected - check SIGHASH flags: "+this.sighashInfo.zeroFields.join(", ")),this.preimage.length<104&&t.push("Preimage too short: "+this.preimage.length+" bytes (minimum 104)"),{valid:0===t.length,errors:t,warnings:e,sighashInfo:this.sighashInfo}},n.prototype.toObject=function(){return this.fields||this._extractFields(),{preimage:this.preimage.toString("hex"),length:this.preimage.length,strategy:this.strategy,fields:{version:this.fields.version?this.fields.version.toString("hex"):null,hashPrevouts:this.fields.hashPrevouts?this.fields.hashPrevouts.toString("hex"):null,hashSequence:this.fields.hashSequence?this.fields.hashSequence.toString("hex"):null,outpoint:this.fields.outpoint?this.fields.outpoint.toString("hex"):null,scriptCode:this.fields.scriptCode?this.fields.scriptCode.toString("hex"):null,scriptCodeLength:this.fields.scriptCodeLength,amount:this.fields.amount?this.fields.amount.toString("hex"):null,sequence:this.fields.sequence?this.fields.sequence.toString("hex"):null,hashOutputs:this.fields.hashOutputs?this.fields.hashOutputs.toString("hex"):null,locktime:this.fields.locktime?this.fields.locktime.toString("hex"):null,sighash:this.fields.sighash?this.fields.sighash.toString("hex"):null},sighashInfo:this.sighashInfo,validation:this.validate()}},n.prototype._extractFields=function(){this.fields={},this.sighashInfo={flag:null,hasZeroHashes:!1,zeroFields:[],warnings:[]};try{"LEFT"===this.strategy||"DYNAMIC"===this.strategy?this._extractFromLeft():"RIGHT"===this.strategy&&this._extractFromRight(),this._analyzeSighash()}catch(t){if("DYNAMIC"!==this.strategy)throw t;try{this.strategy="RIGHT",this._extractFromRight(),this._analyzeSighash()}catch(e){throw new Error("Failed to extract preimage fields with any strategy: "+t.message)}}},n.prototype._extractFromLeft=function(){var t=0;this.fields.version=this.preimage.slice(t,t+4),t+=4,this.fields.hashPrevouts=this.preimage.slice(t,t+32),t+=32,this.fields.hashSequence=this.preimage.slice(t,t+32),t+=32,this.fields.outpoint=this.preimage.slice(t,t+36),t+=36;var e=n.decodeCompactSize(this.preimage,t);this.fields.scriptCodeLength=e.value,t=e.nextOffset,this.fields.scriptCode=this.preimage.slice(t,t+this.fields.scriptCodeLength),t+=this.fields.scriptCodeLength,this.fields.amount=this.preimage.slice(t,t+8),t+=8,this.fields.sequence=this.preimage.slice(t,t+4),t+=4,this.fields.hashOutputs=this.preimage.slice(t,t+32),t+=32,this.fields.locktime=this.preimage.slice(t,t+4),t+=4,this.fields.sighash=this.preimage.slice(t,t+4)},n.prototype._extractFromRight=function(){var t=this.preimage.length;t-=4,this.fields.sighash=this.preimage.slice(t,t+4),t-=4,this.fields.locktime=this.preimage.slice(t,t+4),t-=32,this.fields.hashOutputs=this.preimage.slice(t,t+32),t-=4,this.fields.sequence=this.preimage.slice(t,t+4),t-=8,this.fields.amount=this.preimage.slice(t,t+8);var e=n.decodeCompactSize(this.preimage,104);this.fields.scriptCodeLength=e.value,this.fields.scriptCode=this.preimage.slice(e.nextOffset,e.nextOffset+this.fields.scriptCodeLength),this.fields.version=this.preimage.slice(0,4),this.fields.hashPrevouts=this.preimage.slice(4,36),this.fields.hashSequence=this.preimage.slice(36,68),this.fields.outpoint=this.preimage.slice(68,104)},n.prototype._analyzeSighash=function(){if(this.fields.sighash){var t=this.fields.sighash.readUInt32LE(0);this.sighashInfo.flag=t;var r=31&t,i=0!=(128&t),n=0!=(64&t),o=e.alloc(32);i&&this.fields.hashPrevouts.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashPrevouts"),this.sighashInfo.warnings.push("ANYONECANPAY flag detected - hashPrevouts is zero")),2===r&&this.fields.hashSequence.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashSequence"),this.sighashInfo.warnings.push("SIGHASH_NONE flag detected - hashSequence is zero")),2!==r&&3!==r||!this.fields.hashOutputs.equals(o)||(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashOutputs"),this.sighashInfo.warnings.push("SIGHASH_NONE/SINGLE flag detected - hashOutputs is zero"));var s=[];1===r?s.push("ALL"):2===r?s.push("NONE"):3===r&&s.push("SINGLE"),i&&s.push("ANYONECANPAY"),n&&s.push("FORKID"),this.sighashInfo.flagName=s.join(" | ")}},n.prototype._parsePreimageStructure=function(){for(var t=this.preimage,e=0,r={},i=[{name:"nVersion",len:4},{name:"hashPrevouts",len:32},{name:"hashSequence",len:32},{name:"outpoint_txid",len:32},{name:"outpoint_vout",len:4}],o=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],s=0;s<i.length;s++){var a=i[s];r[a.name]=t.slice(e,e+a.len).toString("hex"),e+=a.len}var u=n.decodeCompactSize(t,e);r.scriptLen=u.value,r.scriptLenSize=u.bytes,r.scriptLenRaw=t.slice(e,e+u.bytes).toString("hex"),e+=u.bytes,r.scriptCode=t.slice(e,e+r.scriptLen).toString("hex"),e+=r.scriptLen;for(var c=0;c<o.length;c++){var h=o[c];r[h.name]=t.slice(e,e+h.len).toString("hex"),e+=h.len}var f=i.reduce((function(t,e){return t+e.len}),0),d=o.reduce((function(t,e){return t+e.len}),0);return r._structure={leftFixed:f,scriptLenVarint:u.bytes,scriptCode:r.scriptLen,rightFixed:d,totalCalculated:f+u.bytes+r.scriptLen+d,totalActual:t.length},r},n.prototype._generateBidirectionalASM=function(t,e,r){if(["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t))return this._generateRightExtractionASM(t,r);if(["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t))return this._generateLeftExtractionASM(t,r);if("scriptCode"===t)return this._generateDynamicExtractionASM(e,r);if("scriptLen"===t)return this._generateScriptLenExtractionASM(e,r);throw new Error("Unknown field: "+t)},n.prototype._generateRightExtractionASM=function(t,e){for(var r=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],i=0,n=0,o=!1,s=0;s<r.length;s++){var a=r[s];if(a.name===t){n=a.len,o=!0;break}i+=a.len}if(!o)throw new Error("Field not found in RIGHT fields: "+t);var u=52-i,c=[];return e?(c.push("# 🔄 Extract "+t+" from RIGHT side (bidirectional strategy)"),c.push("OP_SIZE # Push preimage size: [preimage, size]")):c.push("OP_SIZE"),(c=e?c.concat([u+" OP_SUB # Calculate split point: [preimage, split_point]","OP_SPLIT # Split: [left_part, right_part]","OP_DROP # Drop left: [right_part]",n+" OP_SPLIT # Extract field: [remaining, "+t+"]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]):c.concat([u+" OP_SUB","OP_SPLIT","OP_DROP",n+" OP_SPLIT","OP_DROP"])).join("\n")},n.prototype._generateLeftExtractionASM=function(t,e){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}].find((function(e){return e.name===t}));if(!r)throw new Error("Field not found in LEFT fields: "+t);return(e?["# 🔄 Extract "+t+" from LEFT side (bidirectional strategy)",r.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_DROP # Drop prefix: [remainder]",r.len+" OP_SPLIT # Extract field: ["+t+", suffix]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]:[r.offset+" OP_SPLIT","OP_DROP",r.len+" OP_SPLIT","OP_DROP"]).join("\n")},n.prototype._generateDynamicExtractionASM=function(t,e){return["# 🎯 Extract scriptCode DYNAMICALLY with CompactSize varint support",104+t.scriptLenSize+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# ✅ Result: scriptCode extracted with "+t.scriptLenSize+"-byte varint awareness"].join("\n")},n.prototype._generateScriptLenExtractionASM=function(t,e){return["# 🎯 Extract scriptLen CompactSize varint ("+t.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# ✅ Result: CompactSize varint (decode off-chain to get "+t.scriptLen+")"].join("\n")},n.prototype._extractSpecificField=function(t,r){var i=r[t];return i?e.from(i,"hex"):null},n.prototype._interpretField=function(t,r,i){if(!r)return null;var n={raw:r.toString("hex"),bytes:r.length};try{switch(t){case"nVersion":n.value=r.readUInt32LE(0),n.description="Transaction version "+n.value;break;case"value":8===r.length&&(n.satoshis=r.readBigUInt64LE(0).toString(),n.description=n.satoshis+" satoshis");break;case"sighashType":var o=r.readUInt32LE(0);n.value=o,n.description={1:"SIGHASH_ALL",65:"SIGHASH_ALL | FORKID",2:"SIGHASH_NONE",66:"SIGHASH_NONE | FORKID",3:"SIGHASH_SINGLE",67:"SIGHASH_SINGLE | FORKID"}[o]||"Custom ("+o+")";break;case"outpoint_vout":n.value=r.readUInt32LE(0),n.description="Output index "+n.value;break;case"scriptLen":n.varintSize=i.scriptLenSize,n.scriptLength=i.scriptLen,n.description=i.scriptLen+" bytes encoded as "+i.scriptLenSize+"-byte varint";break;case"scriptCode":25===r.length&&118===r[0]&&169===r[1]?(n.description="Standard P2PKH script (25 bytes)",n.type="P2PKH"):r.length>0&&106===r[0]?(n.description="OP_RETURN data script ("+r.length+" bytes)",n.type="OP_RETURN"):(n.description="Custom script ("+r.length+" bytes)",n.type="CUSTOM");break;default:if(["hashPrevouts","hashSequence","hashOutputs"].includes(t)){var s=e.alloc(32);r.equals(s)?(n.isZero=!0,n.description="Zero hash (check SIGHASH flags)"):n.description="32-byte hash"}}}catch(t){n.error=t.message}return n},n.prototype._getExtractionStrategy=function(t){return["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t)?"RIGHT":["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t)?"LEFT":"scriptCode"===t?"DYNAMIC":"scriptLen"===t?"VARINT":"UNKNOWN"},n.decodeCompactSize=function(t,e){var r=t[e];if(r<253)return{value:r,nextOffset:e+1,bytes:1};if(253===r)return{value:t.readUInt16LE(e+1),nextOffset:e+3,bytes:3};if(254===r)return{value:t.readUInt32LE(e+1),nextOffset:e+5,bytes:5};console.warn("Encountered 8-byte CompactSize - this is very unusual for script lengths");try{return{value:t.readUInt32LE(e+1),nextOffset:e+9,bytes:9}}catch(t){throw new Error("Invalid 8-byte CompactSize encoding in preimage")}},n.fromTransaction=function(t,e,r,o,s){return new n(i.Transaction.sighash.sighashPreimage(t,s,e,r,new i.crypto.BN(o)),{transaction:t,inputIndex:e,subscript:r,satoshis:o,sighashType:s})},n.createExample=function(t){var e=i.PrivateKey.fromRandom().toAddress(),r={txId:"0".repeat(64),outputIndex:0,script:i.Script.buildPublicKeyHashOut(e).toHex(),satoshis:1e5},o=(new i.Transaction).from(r).to(e,99e3),s=i.Script.fromHex(r.script);return n.fromTransaction(o,0,s,r.satoshis,t)},n.extractFromHex=function(t,e,r){return new n(t,{deferExtraction:!0}).extractField(e,r)},n.generateASMFromHex=function(t,e,r){return new n(t,{deferExtraction:!0}).generateASM(e,r)},n.extractMultipleFromHex=function(t,e){return new n(t,{deferExtraction:!0}).extractFields(e)},n.validateFromHex=function(t){return new n(t).validate()},n.analyzeFromHex=function(t){var e=new n(t),r=e._parsePreimageStructure(),i=e.validate();return{hex:t,length:t.length/2,structure:r._structure,fields:r,validation:i,sighashInfo:e.getSighashInfo(),extractField:function(t){return e.extractField(t)},generateASM:function(t){return e.generateASM(t)},getSummary:function(){return{totalBytes:r._structure.totalActual,scriptLength:r.scriptLen,scriptVarintSize:r.scriptLenSize,sighashType:r.sighashType,valid:i.valid,warnings:i.warnings}}}},t.exports=n}).call(this,r(0).Buffer)},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(98).Transform,o=r(70).StringDecoder,s=r(233),a=r(53);function u(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}s(u,n),u.prototype.update=function(t,e,r){var i=a(t,e),n=this._update(i);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},u.prototype.setAutoPadding=function(){},u.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},u.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},u.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},u.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},u.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},u.prototype._finalOrDigest=function(t){var e=this.__final()||i.alloc(0);return t&&(e=this._toString(e,t,!0)),e},u.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},t.exports=u},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(7),s=function t(r){if(!(this instanceof t))return new t(r);if(!i.isUndefined(r))if(e.isBuffer(r))this.set({buf:r});else if(i.isString(r)){var n=e.from(r,"hex");if(2*n.length!==r.length)throw new TypeError("Invalid hex string");this.set({buf:n})}else{if(!i.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var o=r;this.set(o)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this.pos=t.pos||this.pos||0,this},s.prototype.eof=function(){return this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(t){n.checkArgument(!i.isUndefined(t),"Must specify a length");var e=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e},s.prototype.readAll=function(){var t=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,t},s.prototype.readUInt8=function(){var t=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,t},s.prototype.readUInt16BE=function(){var t=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt16LE=function(){var t=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt32BE=function(){var t=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt32LE=function(){var t=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readInt32LE=function(){var t=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt64BEBN=function(){var t=this.buf.slice(this.pos,this.pos+8),e=o.fromBuffer(t);return this.pos=this.pos+8,e},s.prototype.readUInt64LEBN=function(){var t,e=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+e;if(r<=9007199254740991)t=new o(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);t=new o(i,10,"le")}return this.pos=this.pos+8,t},s.prototype.readVarintNum=function(){var t=this.readUInt8();switch(t){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var e=this.readUInt64LEBN().toNumber();if(e<=Math.pow(2,53))return e;throw new Error("number too large to retain precision - use readVarintBN");default:return t}},s.prototype.readVarLengthBuffer=function(){var t=this.readVarintNum(),e=this.read(t);return n.checkState(e.length===t,"Invalid length while reading varlength buffer. Expected to read: "+t+" and read "+e.length),e},s.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},s.prototype.readVarintBN=function(){var t=this.readUInt8();switch(t){case 253:return new o(this.readUInt16LE());case 254:return new o(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new o(t)}},s.prototype.reverse=function(){for(var t=e.alloc(this.buf.length),r=0;r<t.length;r++)t[r]=this.buf[this.buf.length-1-r];return this.buf=t,this},s.prototype.readReverse=function(t){i.isUndefined(t)&&(t=this.buf.length);var r=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e.from(r).reverse()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(0),n=r(8),o=r(18),s=r(27),a=r(25),u=r(21),c=r(7),h=r(9),f=r(65),d=r(4),l=r(85),p=r(2),g=e.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=l.SCRIPT_ENABLE_SIGHASH_FORKID,y=function(t,a,f,y,b,v){var _=r(142),S=r(86);p.isUndefined(v)&&(v=m);var w,I=_.shallowCopy(t);(y=new o(y),v&l.SCRIPT_ENABLE_REPLAY_PROTECTION)&&(a=(16711680|57005^a>>8)<<8|255&a);if(a&n.SIGHASH_FORKID&&v&l.SCRIPT_ENABLE_SIGHASH_FORKID)return function(t,r,i,o,s){var a=t.inputs[i];function f(t,e){var r=new u;p.isUndefined(e)?p.each(t.outputs,(function(t){t.toBufferWriter(r)})):t.outputs[e].toBufferWriter(r);var i=r.toBuffer();return h.sha256sha256(i)}d.checkArgument(s instanceof c,"For ForkId=0 signatures, satoshis or complete input must be provided");var l=e.alloc(32),g=e.alloc(32),m=e.alloc(32);r&n.SIGHASH_ANYONECANPAY||(l=function(t){var e=new u;p.each(t.inputs,(function(t){e.writeReverse(t.prevTxId),e.writeUInt32LE(t.outputIndex)}));var r=e.toBuffer();return h.sha256sha256(r)}(t)),r&n.SIGHASH_ANYONECANPAY||(31&r)===n.SIGHASH_SINGLE||(31&r)===n.SIGHASH_NONE||(g=function(t){var e=new u;p.each(t.inputs,(function(t){e.writeUInt32LE(t.sequenceNumber)}));var r=e.toBuffer();return h.sha256sha256(r)}(t)),(31&r)!==n.SIGHASH_SINGLE&&(31&r)!==n.SIGHASH_NONE?m=f(t):(31&r)===n.SIGHASH_SINGLE&&i<t.outputs.length&&(m=f(t,i));var y=new u;y.writeInt32LE(t.version),y.write(l),y.write(g),y.writeReverse(a.prevTxId),y.writeUInt32LE(a.outputIndex),y.writeVarintNum(o.toBuffer().length),y.write(o.toBuffer()),y.writeUInt64LEBN(s);var b=a.sequenceNumber;return y.writeUInt32LE(b),y.write(m),y.writeUInt32LE(t.nLockTime),y.writeUInt32LE(r>>>0),y.toBuffer()}(I,a,f,y,b);for(y.removeCodeseparators(),w=0;w<I.inputs.length;w++)I.inputs[w]=new S(I.inputs[w]).setScript(o.empty());if(I.inputs[f]=new S(I.inputs[f]).setScript(y),(31&a)===n.SIGHASH_NONE||(31&a)===n.SIGHASH_SINGLE)for(w=0;w<I.inputs.length;w++)w!==f&&(I.inputs[w].sequenceNumber=0);if((31&a)===n.SIGHASH_NONE)I.outputs=[];else if((31&a)===n.SIGHASH_SINGLE){if(f>=I.outputs.length)return g;for(I.outputs.length=f+1,w=0;w<f;w++)I.outputs[w]=new s({satoshis:c.fromBuffer(i.Buffer.from("ffffffffffffffff","hex")),script:o.empty()})}return a&n.SIGHASH_ANYONECANPAY&&(I.inputs=[I.inputs[f]]),(new u).write(I.toBuffer()).writeInt32LE(a).toBuffer()},b=function(t,e,r,i,n,o){var s=y(t,e,r,i,n,o);if(0===s.compare(g))return s;var u=h.sha256sha256(s);return u=new a(u).readReverse()};t.exports={sighashPreimage:y,sighash:b,sign:function(t,e,r,i,n,o,s){var a=b(t,r,i,n,o,s);return f.sign(a,e,"little").set({nhashtype:r})},verify:function(t,e,r,i,n,o,s){d.checkArgument(!p.isUndefined(t)),d.checkArgument(!p.isUndefined(e)&&!p.isUndefined(e.nhashtype));var a=b(t,e.nhashtype,i,n,o,s);return f.verify(a,e,r,"little")}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(7),o=r(0),s=r(10),a=r(21),u=r(46),c=r(18),h=r(4),f=r(16);function d(t){if(!(this instanceof d))return new d(t);if(!i.isObject(t))throw new TypeError("Unrecognized argument for Output");var r;this.satoshis=t.satoshis,e.isBuffer(t.script)?this._scriptBuffer=t.script:(r=i.isString(t.script)&&s.isHexa(t.script)?o.Buffer.from(t.script,"hex"):t.script,this.setScript(r))}Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script||this.setScriptFromBuffer(this._scriptBuffer),this._script}}),Object.defineProperty(d.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(t){t instanceof n?(this._satoshisBN=t,this._satoshis=t.toNumber()):i.isString(t)?(this._satoshis=parseInt(t),this._satoshisBN=n.fromNumber(this._satoshis)):(h.checkArgument(s.isNaturalNumber(t),"Output satoshis is not a natural number"),this._satoshisBN=n.fromNumber(t),this._satoshis=t),h.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"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"},Object.defineProperty(d.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(t){this._satoshisBN=t,this._satoshis=t.toNumber(),h.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.toObject=d.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t},d.fromObject=function(t){return new d(t)},d.prototype.setScriptFromBuffer=function(t){this._scriptBuffer=t;try{this._script=c.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(!(t instanceof f.Script.InvalidBuffer))throw t;this._script=null}},d.prototype.setScript=function(t){if(t instanceof c)this._scriptBuffer=t.toBuffer(),this._script=t,this._script._isOutput=!0;else if(i.isString(t))this._script=c.fromString(t),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(t)}return this},d.prototype.inspect=function(){var t;return t=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+t+">"},d.fromBufferReader=function(t){var e={};e.satoshis=t.readUInt64LEBN();var r=t.readVarintNum();return e.script=0!==r?t.read(r):o.Buffer.from([]),new d(e)},d.prototype.toBufferWriter=function(t){t||(t=new a),t.writeUInt64LEBN(this._satoshisBN);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t},d.prototype.getSize=function(){var t=this.script.toBuffer().length;return 8+u(t).toBuffer().length+t},t.exports=d}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(52),n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=Object.create(r(38));o.inherits=r(3);var s=r(99),a=r(69);o.inherits(f,s);for(var u=n(a.prototype),c=0;c<u.length;c++){var h=u[c];f.prototype[h]||(f.prototype[h]=a.prototype[h])}function f(t){if(!(this instanceof f))return new f(t);s.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",d)}function d(){this.allowHalfOpen||this._writableState.ended||i.nextTick(l,this)}function l(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),f.prototype._destroy=function(t,e){this.push(null),this.end(),i.nextTick(e,t)}},function(t,e,r){"use strict";var i=r(2),n=r(10),o=[],s={};function a(){}function u(t,e){if(~o.indexOf(t))return t;if(!e)return s[t];i.isArray(e)||(e=[e]);for(var r=0;r<o.length;r++){var n=o[r],a=i.pick(n,e);if(~i.values(a).indexOf(t))return n}}function c(t){for(var e=[],r=0;r<t.length;r++)e.push(31&t.charCodeAt(r));return e}function h(t){var e=new a;n.defineImmutable(e,{name:t.name,alias:t.alias,pubkeyhash:t.pubkeyhash,privatekey:t.privatekey,scripthash:t.scripthash,xpubkey:t.xpubkey,xprivkey:t.xprivkey});var r=t.indexBy||Object.keys(t);return t.cashAddrPrefix&&i.extend(e,{cashAddrPrefix:t.cashAddrPrefix,cashAddrPrefixArray:c(t.cashAddrPrefix)}),t.networkMagic&&i.extend(e,{networkMagic:n.integerAsBuffer(t.networkMagic)}),t.port&&i.extend(e,{port:t.port}),t.dnsSeeds&&i.extend(e,{dnsSeeds:t.dnsSeeds}),o.push(e),function(t,e){for(var r=0;r<e.length;r++){var n=e[r],o=t[n];i.isUndefined(o)||i.isObject(o)||(s[o]=t)}}(e,r),e}a.prototype.toString=function(){return this.name};var f=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],d={PORT:18333,NETWORK_MAGIC:4108710900,DNS_SEEDS:f,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},l={PORT:18444,NETWORK_MAGIC:3669344250,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},p={PORT:9333,NETWORK_MAGIC:4224632057,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:3823236072,port:8333,dnsSeeds:f},m={name:"testnet",prefix:d.PREFIX,cashAddrPrefix:d.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:d.NETWORK_MAGIC},y={name:"regtest",prefix:l.PREFIX,cashAddrPrefix:l.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:l.NETWORK_MAGIC,port:l.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},b={name:"stn",prefix:p.PREFIX,cashAddrPrefix:p.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:p.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};h(m),h(b),h(y),h(g);var v=u("livenet"),_=u("regtest"),S=u("testnet"),w=u("stn");Object.defineProperty(S,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?l.PORT:this.stnEnabled?p.PORT:d.PORT}}),Object.defineProperty(S,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?n.integerAsBuffer(l.NETWORK_MAGIC):this.stnEnabled?n.integerAsBuffer(p.NETWORK_MAGIC):n.integerAsBuffer(d.NETWORK_MAGIC)}}),Object.defineProperty(S,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?l.DNS_SEEDS:this.stnEnabled?p.DNS_SEEDS:d.DNS_SEEDS}}),Object.defineProperty(S,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?l.CASHADDRPREFIX:this.stnEnabled?p.CASHADDRPREFIX:d.CASHADDRPREFIX}}),Object.defineProperty(S,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?c(l.CASHADDRPREFIX):this.stnEnabled?p.cashAddrPrefixToArray(p.CASHADDRPREFIX):c(d.CASHADDRPREFIX)}}),t.exports={add:h,remove:function(t){for(var e=0;e<o.length;e++)o[e]===t&&o.splice(e,1);!function(t,e){for(var r=0;r<e.length;r++){var i=e[r];s[i]===t&&delete s[i]}}(t,Object.keys(s))},defaultNetwork:v,livenet:v,mainnet:v,testnet:S,regtest:_,stn:w,get:u,enableRegtest:function(){S.regtestEnabled=!0},disableRegtest:function(){S.regtestEnabled=!1},enableStn:function(){S.stnEnabled=!0},disableStn:function(){S.stnEnabled=!1}}},function(t,e,r){"use strict";var i=e;i.version=r(156).version,i.utils=r(13),i.rand=r(62),i.curve=r(94),i.curves=r(64),i.ec=r(168),i.eddsa=r(172)},function(t,e,r){"use strict";(function(e,i){var n=r(1).Buffer,o=e.crypto||e.msCrypto;o&&o.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=n.allocUnsafe(t);if(t>0)if(t>65536)for(var s=0;s<t;s+=65536)o.getRandomValues(r.slice(s,s+65536));else o.getRandomValues(r);if("function"==typeof e)return i.nextTick((function(){e(null,r)}));return r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,r(12),r(11))},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(53);function o(t,e){this._block=i.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}o.prototype.update=function(t,e){t=n(t,e||"utf8");for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a<o;){for(var u=s%i,c=Math.min(o-a,i-u),h=0;h<c;h++)r[u+h]=t[a+h];a+=c,(s+=c)%i==0&&this._update(r)}return this._len+=o,this},o.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>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 t?o.toString(t):o},o.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=o},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(16),s=r(45),a=r(29),u=r(9),c=r(10),h=r(20);function f(t,e,r){if(!(this instanceof f))return new f(t,e,r);if(i.isArray(t)&&i.isNumber(e))return f.createMultisig(t,e,r);if(t instanceof f)return t;if(n.checkArgument(t,"First argument is required, please include address data.","guide/address.html"),e&&!a.get(e))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==f.PayToPublicKeyHash&&r!==f.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var o=this._classifyArguments(t,e,r);return o.network=o.network||a.get(e)||a.defaultNetwork,o.type=o.type||r||f.PayToPublicKeyHash,c.defineImmutable(this,{hashBuffer:o.hashBuffer,network:o.network,type:o.type}),this}f.prototype._classifyArguments=function(t,r,n){if((t instanceof e||t instanceof Uint8Array)&&20===t.length)return f._transformHash(t);if((t instanceof e||t instanceof Uint8Array)&&21===t.length)return f._transformBuffer(t,r,n);if(t instanceof h)return f._transformPublicKey(t);if(t instanceof d)return f._transformScript(t,r);if("string"==typeof t)return f._transformString(t,r,n);if(i.isObject(t))return f._transformObject(t);throw new TypeError("First argument is an unrecognized data format.")},f.PayToPublicKeyHash="pubkeyhash",f.PayToScriptHash="scripthash",f._transformHash=function(t){var r={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==t.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return r.hashBuffer=t,r},f._transformObject=function(t){return n.checkArgument(t.hash||t.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),n.checkArgument(t.type,"Must provide a `type` property"),{hashBuffer:t.hash?e.from(t.hash,"hex"):t.hashBuffer,network:a.get(t.network)||a.defaultNetwork,type:t.type}},f._classifyFromVersion=function(t){var e={},r=a.get(t[0],"pubkeyhash"),i=a.get(t[0],"scripthash");return r?(e.network=r,e.type=f.PayToPublicKeyHash):i&&(e.network=i,e.type=f.PayToScriptHash),e},f._transformBuffer=function(t,r,i){var n={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==t.length)throw new TypeError("Address buffers must be exactly 21 bytes.");var o=a.get(r),s=f._classifyFromVersion(t);if(r&&!o)throw new TypeError("Unknown network");if(!s.network||o&&o!==s.network)throw new TypeError("Address has mismatched network type.");if(!s.type||i&&i!==s.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=t.slice(1),n.network=s.network,n.type=s.type,n},f._transformPublicKey=function(t){var e={};if(!(t instanceof h))throw new TypeError("Address must be an instance of PublicKey.");return e.hashBuffer=u.sha256ripemd160(t.toBuffer()),e.type=f.PayToPublicKeyHash,e},f._transformScript=function(t,e){n.checkArgument(t instanceof d,"script must be a Script instance");var r=t.getAddressInfo(e);if(!r)throw new o.Script.CantDeriveAddress(t);return r},f.createMultisig=function(t,e,r){return r=r||t[0].network||a.defaultNetwork,f.payingTo(d.buildMultisigOut(t,e),r)},f._transformString=function(t,e,r){if("string"!=typeof t)throw new TypeError("data parameter supplied is not a string.");if(t.length<27)throw new Error("Invalid Address string provided");t=t.trim();var i=a.get(e);if(e&&!i)throw new TypeError("Unknown network");var n=s.decode(t);return f._transformBuffer(n,e,r)},f.fromPublicKey=function(t,e){var r=f._transformPublicKey(t);return e=e||a.defaultNetwork,new f(r.hashBuffer,e,r.type)},f.fromPrivateKey=function(t,e){let r=h.fromPrivateKey(t);return e=e||t.network||a.defaultNetwork,f.fromPublicKey(r,e)},f.fromPublicKeyHash=function(t,e){var r=f._transformHash(t);return new f(r.hashBuffer,e,f.PayToPublicKeyHash)},f.fromScriptHash=function(t,e){n.checkArgument(t,"hash parameter is required");var r=f._transformHash(t);return new f(r.hashBuffer,e,f.PayToScriptHash)},f.payingTo=function(t,e){return n.checkArgument(t,"script is required"),n.checkArgument(t instanceof d,"script must be instance of Script"),f.fromScriptHash(u.sha256ripemd160(t.toBuffer()),e)},f.fromScript=function(t,e){n.checkArgument(t instanceof d,"script must be a Script instance");var r=f._transformScript(t,e);return new f(r.hashBuffer,e,r.type)},f.fromBuffer=function(t,e,r){var i=f._transformBuffer(t,e,r);return new f(i.hashBuffer,i.network,i.type)},f.fromHex=function(t,r,i){return f.fromBuffer(e.from(t,"hex"),r,i)},f.fromString=function(t,e,r){var i=f._transformString(t,e,r);return new f(i.hashBuffer,i.network,i.type)},f.fromObject=function(t){return n.checkState(c.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.'),new f(e.from(t.hash,"hex"),t.network,t.type)},f.getValidationError=function(t,e,r){var i;try{new f(t,e,r)}catch(t){i=t}return i},f.isValid=function(t,e,r){return!f.getValidationError(t,e,r)},f.prototype.isPayToPublicKeyHash=function(){return this.type===f.PayToPublicKeyHash},f.prototype.isPayToScriptHash=function(){return this.type===f.PayToScriptHash},f.prototype.toBuffer=function(){var t=e.from([this.network[this.type]]);return e.concat([t,this.hashBuffer])},f.prototype.toHex=function(){return this.toBuffer().toString("hex")},f.prototype.toObject=f.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},f.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},f.prototype.toString=function(){return s.encode(this.toBuffer())},t.exports=f;var d=r(18)}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(19),n=r(14);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=o,o.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),n(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;o<this.padLength;o++)i[n++]=0;return i}},function(t,e,r){"use strict";var i=r(3),n=r(66),o=r(71),s=r(78),a=r(24);function u(t){a.call(this,"digest"),this._hash=t}i(u,a),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new n:"rmd160"===t||"ripemd160"===t?new o:new u(s(t))}},function(t,e,r){(e=t.exports=r(99)).Stream=e,e.Readable=e,e.Writable=r(69),e.Duplex=r(28),e.Transform=r(102),e.PassThrough=r(188)},function(t,e,r){function i(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===i(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===i(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===i(t)},e.isError=function(t){return"[object Error]"===i(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(0).Buffer.isBuffer},function(t,e,r){"use strict";t.exports=TypeError},function(t,e,r){"use strict";var i=r(211);if(i)try{i([],"length")}catch(t){i=null}t.exports=i},function(t,e,r){"use strict";var i=r(214);t.exports=Function.prototype.bind||i},function(t,e,r){(function(e){t.exports=function(t,r){for(var i=Math.min(t.length,r.length),n=new e(i),o=0;o<i;++o)n[o]=t[o]^r[o];return n}}).call(this,r(0).Buffer)},function(t,e,r){var i=e;i.bignum=r(6),i.define=r(262).define,i.base=r(44),i.constants=r(131),i.decoders=r(267),i.encoders=r(269)},function(t,e,r){var i=e;i.Reporter=r(264).Reporter,i.DecoderBuffer=r(130).DecoderBuffer,i.EncoderBuffer=r(130).EncoderBuffer,i.Node=r(265)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(59),o=r(0),s=r(9).sha256sha256,a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var i=r;this.fromBuffer(i)}else if("string"==typeof r){var n=r;this.fromString(n)}};a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.validChecksum=function(t,e){return i.isString(t)&&(t=o.Buffer.from(n.decode(t))),i.isString(e)&&(e=o.Buffer.from(n.decode(e))),e||(e=t.slice(-4),t=t.slice(0,-4)),a.checksum(t).toString("hex")===e.toString("hex")},a.decode=function(t){if("string"!=typeof t)throw new Error("Input must be a string");var r=e.from(n.decode(t));if(r.length<4)throw new Error("Input string too short");var i=r.slice(0,-4),o=r.slice(-4),a=s(i).slice(0,4);if(o.toString("hex")!==a.toString("hex"))throw new Error("Checksum mismatch");return i},a.checksum=function(t){return s(t).slice(0,4)},a.encode=function(t){if(!e.isBuffer(t))throw new Error("Input must be a buffer");var r=e.alloc(t.length+4),i=a.checksum(t);return t.copy(r),i.copy(r,t.length),n.encode(r)},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){var e=a.decode(t);return new n(e)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(21),n=r(25),o=r(7),s=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r))this.buf=r;else if("number"==typeof r){var i=r;this.fromNumber(i)}else if(r instanceof o){var n=r;this.fromBN(n)}else if(r){var s=r;this.set(s)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf,this},s.prototype.fromString=function(t){return this.set({buf:e.from(t,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(t){return this.buf=t,this},s.prototype.fromBufferReader=function(t){return this.buf=t.readVarintBuf(),this},s.prototype.fromBN=function(t){return this.buf=i().writeVarintBN(t).concat(),this},s.prototype.fromNumber=function(t){return this.buf=i().writeVarintNum(t).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return n(this.buf).readVarintBN()},s.prototype.toNumber=function(){return n(this.buf).readVarintNum()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(16),s=r(21),a=r(0),u=r(10),c=r(18),h=r(26),f=r(27);function d(t){return this instanceof d?t?this._fromObject(t):void 0:new d(t)}d.MAXINT=4294967295,d.DEFAULT_SEQNUMBER=4294967295,d.DEFAULT_LOCKTIME_SEQNUMBER=4294967294,d.DEFAULT_RBF_SEQNUMBER=4294967293,d.BASE_SIZE=40,Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new c(this._scriptBuffer),this._script._isInput=!0),this._script)}}),d.fromObject=function(t){return n.checkArgument(i.isObject(t)),(new d)._fromObject(t)},d.prototype._fromObject=function(t){var e;if(e=i.isString(t.prevTxId)&&u.isHexa(t.prevTxId)?a.Buffer.from(t.prevTxId,"hex"):t.prevTxId,this.output=t.output?t.output instanceof f?t.output:new f(t.output):void 0,this.prevTxId=e||t.txidbuf,this.outputIndex=i.isUndefined(t.outputIndex)?t.txoutnum:t.outputIndex,this.sequenceNumber=i.isUndefined(t.sequenceNumber)?i.isUndefined(t.seqnum)?4294967295:t.seqnum:t.sequenceNumber,i.isUndefined(t.script)&&i.isUndefined(t.scriptBuffer))throw new o.Transaction.Input.MissingScript;return this.setScript(t.scriptBuffer||t.script),this},d.prototype.toObject=d.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},d.fromBufferReader=function(t){var e=new d;return e.prevTxId=t.readReverse(32),e.outputIndex=t.readUInt32LE(),e._scriptBuffer=t.readVarLengthBuffer(),e.sequenceNumber=t.readUInt32LE(),e},d.prototype.toBufferWriter=function(t){t||(t=new s),t.writeReverse(this.prevTxId),t.writeUInt32LE(this.outputIndex);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t.writeUInt32LE(this.sequenceNumber),t},d.prototype.setScript=function(t){if(this._script=null,t instanceof c)this._script=t,this._script._isInput=!0,this._scriptBuffer=t.toBuffer();else if(null===t)this._script=c.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(u.isHexa(t))this._scriptBuffer=a.Buffer.from(t,"hex");else if(i.isString(t))this._script=new c(t),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this._scriptBuffer=a.Buffer.from(t)}return this},d.prototype.getSignatures=function(){throw new o.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},d.prototype.isFullySigned=function(){throw new o.AbstractMethodInvoked("Input#isFullySigned")},d.prototype.isFinal=function(){return this.sequenceNumber===d.MAXINT},d.prototype.addSignature=function(){throw new o.AbstractMethodInvoked("Input#addSignature")},d.prototype.clearSignatures=function(){throw new o.AbstractMethodInvoked("Input#clearSignatures")},d.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,h.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},d.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},d.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},t.exports=d}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(3),s=r(10),a=r(20),u=r(16),c=r(8);function h(t){if(!(this instanceof h))return new h(t);if(t instanceof h)return t;if(i.isObject(t))return this._fromObject(t);throw new u.InvalidArgument("TransactionSignatures must be instantiated from an object")}o(h,c),h.prototype._fromObject=function(t){return this._checkObjectArgs(t),this.publicKey=new a(t.publicKey),this.prevTxId=e.isBuffer(t.prevTxId)?t.prevTxId:e.from(t.prevTxId,"hex"),this.outputIndex=t.outputIndex,this.inputIndex=t.inputIndex,this.signature=t.signature instanceof c?t.signature:e.isBuffer(t.signature)?c.fromBuffer(t.signature):c.fromString(t.signature),this.sigtype=t.sigtype,this},h.prototype._checkObjectArgs=function(t){n.checkArgument(a(t.publicKey),"publicKey"),n.checkArgument(!i.isUndefined(t.inputIndex),"inputIndex"),n.checkArgument(!i.isUndefined(t.outputIndex),"outputIndex"),n.checkState(i.isNumber(t.inputIndex),"inputIndex must be a number"),n.checkState(i.isNumber(t.outputIndex),"outputIndex must be a number"),n.checkArgument(t.signature,"signature"),n.checkArgument(t.prevTxId,"prevTxId"),n.checkState(t.signature instanceof c||e.isBuffer(t.signature)||s.isHexa(t.signature),"signature must be a buffer or hexa value"),n.checkState(e.isBuffer(t.prevTxId)||s.isHexa(t.prevTxId),"prevTxId must be a buffer or hexa value"),n.checkArgument(t.sigtype,"sigtype"),n.checkState(i.isNumber(t.sigtype),"sigtype must be a number")},h.prototype.toObject=h.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}},h.fromObject=function(t){return n.checkArgument(t),new h(t)},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e,i){function n(){}n.getRandomBuffer=function(t){return e.browser?n.getRandomBufferBrowser(t):n.getRandomBufferNode(t)},n.getRandomBufferNode=function(t){return r(15).randomBytes(t)},n.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var e;if(window.crypto&&window.crypto.getRandomValues)e=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");e=window.msCrypto}var r=new Uint8Array(t);return e.getRandomValues(r),i.from(r)},t.exports=n}).call(this,r(11),r(0).Buffer)},function(t,e,r){"use strict";var i=r(6),n=r(13),o=n.getNAF,s=n.getJSF,a=n.assert;function u(t,e){this.type=t,this.p=new i(e.p,16),this.red=e.prime?i.red(e.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=e.n&&new i(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),i=o(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var s,u,c=[];for(s=0;s<i.length;s+=r.step){u=0;for(var h=s+r.step-1;h>=s;h--)u=(u<<1)+i[h];c.push(u)}for(var f=this.jpoint(null,null,null),d=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s<c.length;s++)(u=c[s])===l?d=d.mixedAdd(r.points[s]):u===-l&&(d=d.mixedAdd(r.points[s].neg()));f=f.add(d)}return f.toP()},u.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=o(e,r,this._bitLength),u=this.jpoint(null,null,null),c=s.length-1;c>=0;c--){for(var h=0;c>=0&&0===s[c];c--)h++;if(c>=0&&h++,u=u.dblp(h),c<0)break;var f=s[c];a(0!==f),u="affine"===t.type?f>0?u.mixedAdd(n[f-1>>1]):u.mixedAdd(n[-f-1>>1].neg()):f>0?u.add(n[f-1>>1]):u.add(n[-f-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,i,n){var a,u,c,h=this._wnafT1,f=this._wnafT2,d=this._wnafT3,l=0;for(a=0;a<i;a++){var p=(c=e[a])._getNAFPoints(t);h[a]=p.wnd,f[a]=p.points}for(a=i-1;a>=1;a-=2){var g=a-1,m=a;if(1===h[g]&&1===h[m]){var y=[e[g],null,null,e[m]];0===e[g].y.cmp(e[m].y)?(y[1]=e[g].add(e[m]),y[2]=e[g].toJ().mixedAdd(e[m].neg())):0===e[g].y.cmp(e[m].y.redNeg())?(y[1]=e[g].toJ().mixedAdd(e[m]),y[2]=e[g].add(e[m].neg())):(y[1]=e[g].toJ().mixedAdd(e[m]),y[2]=e[g].toJ().mixedAdd(e[m].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[g],r[m]);for(l=Math.max(v[0].length,l),d[g]=new Array(l),d[m]=new Array(l),u=0;u<l;u++){var _=0|v[0][u],S=0|v[1][u];d[g][u]=b[3*(_+1)+(S+1)],d[m][u]=0,f[g]=y}}else d[g]=o(r[g],h[g],this._bitLength),d[m]=o(r[m],h[m],this._bitLength),l=Math.max(d[g].length,l),l=Math.max(d[m].length,l)}var w=this.jpoint(null,null,null),I=this._wnafT4;for(a=l;a>=0;a--){for(var A=0;a>=0;){var E=!0;for(u=0;u<i;u++)I[u]=0|d[u][a],0!==I[u]&&(E=!1);if(!E)break;A++,a--}if(a>=0&&A++,w=w.dblp(A),a<0)break;for(u=0;u<i;u++){var O=I[u];0!==O&&(O>0?c=f[u][O-1>>1]:O<0&&(c=f[u][-O-1>>1].neg()),w="affine"===c.type?w.mixedAdd(c):w.add(c))}}for(a=0;a<i;a++)f[a]=null;return n?w:w.toP()},u.BasePoint=c,c.prototype.eq=function(){throw new Error("Not implemented")},c.prototype.validate=function(){return this.curve.validate(this)},u.prototype.decodePoint=function(t,e){t=n.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},c.prototype.encodeCompressed=function(t){return this.encode(t,!0)},c.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},c.prototype.encode=function(t,e){return n.encode(this._encode(e),t)},c.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},c.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var o=0;o<t;o++)i=i.dbl();r.push(i)}return{step:t,points:r}},c.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},c.prototype._getBeta=function(){return null},c.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},function(t,e,r){var i=e;i.utils=r(19),i.common=r(35),i.sha=r(161),i.ripemd=r(165),i.hmac=r(166),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},function(t,e,r){"use strict";(function(e){void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,i,n){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,i)}));case 4:return e.nextTick((function(){t.call(null,r,i,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick((function(){t.apply(null,o)}))}}}:t.exports=e}).call(this,r(11))},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(196),o=r(197),s=ArrayBuffer.isView||function(t){try{return o(t),!0}catch(t){return!1}},a="undefined"!=typeof Uint8Array,u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c=u&&(i.prototype instanceof Uint8Array||i.TYPED_ARRAY_SUPPORT);t.exports=function(t,e){if(i.isBuffer(t))return t.constructor&&!("isBuffer"in t)?i.from(t):t;if("string"==typeof t)return i.from(t,e);if(u&&s(t)){if(0===t.byteLength)return i.alloc(0);if(c){var r=i.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),h=i.from(o);if(h.length===t.byteLength)return h}if(a&&t instanceof Uint8Array)return i.from(t);var f=n(t);if(f)for(var d=0;d<t.length;d+=1){var l=t[d];if("number"!=typeof l||l<0||l>255||~~l!==l)throw new RangeError("Array items must be numbers in the range 0-255.")}if(f||i.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return i.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}},function(t,e,r){"use strict";var i=Object.defineProperty||!1;if(i)try{i({},"a",{value:1})}catch(t){i=!1}t.exports=i},function(t,e,r){var i=r(1).Buffer;function n(t){i.isBuffer(t)||(t=i.from(t));for(var e=t.length/4|0,r=new Array(e),n=0;n<e;n++)r[n]=t.readUInt32BE(4*n);return r}function o(t){for(;0<t.length;t++)t[0]=0}function s(t,e,r,i,n){for(var o,s,a,u,c=r[0],h=r[1],f=r[2],d=r[3],l=t[0]^e[0],p=t[1]^e[1],g=t[2]^e[2],m=t[3]^e[3],y=4,b=1;b<n;b++)o=c[l>>>24]^h[p>>>16&255]^f[g>>>8&255]^d[255&m]^e[y++],s=c[p>>>24]^h[g>>>16&255]^f[m>>>8&255]^d[255&l]^e[y++],a=c[g>>>24]^h[m>>>16&255]^f[l>>>8&255]^d[255&p]^e[y++],u=c[m>>>24]^h[l>>>16&255]^f[p>>>8&255]^d[255&g]^e[y++],l=o,p=s,g=a,m=u;return o=(i[l>>>24]<<24|i[p>>>16&255]<<16|i[g>>>8&255]<<8|i[255&m])^e[y++],s=(i[p>>>24]<<24|i[g>>>16&255]<<16|i[m>>>8&255]<<8|i[255&l])^e[y++],a=(i[g>>>24]<<24|i[m>>>16&255]<<16|i[l>>>8&255]<<8|i[255&p])^e[y++],u=(i[m>>>24]<<24|i[l>>>16&255]<<16|i[p>>>8&255]<<8|i[255&g])^e[y++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],i=[],n=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,i[c]=s;var h=t[s],f=t[h],d=t[f],l=257*t[c]^16843008*c;n[0][s]=l<<24|l>>>8,n[1][s]=l<<16|l>>>16,n[2][s]=l<<8|l>>>24,n[3][s]=l,l=16843009*d^65537*f^257*h^16843008*s,o[0][c]=l<<24|l>>>8,o[1][c]=l<<16|l>>>16,o[2][c]=l<<8|l>>>24,o[3][c]=l,0===s?s=a=1:(s=h^t[t[t[d^h]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:o}}();function c(t){this._key=n(t),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,i=4*(r+1),n=[],o=0;o<e;o++)n[o]=t[o];for(o=e;o<i;o++){var s=n[o-1];o%e==0?(s=s<<8|s>>>24,s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s],s^=a[o/e|0]<<24):e>6&&o%e==4&&(s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s]),n[o]=n[o-e]^s}for(var c=[],h=0;h<i;h++){var f=i-h,d=n[f-(h%4?0:4)];c[h]=h<4||f<=4?d:u.INV_SUB_MIX[0][u.SBOX[d>>>24]]^u.INV_SUB_MIX[1][u.SBOX[d>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[d>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&d]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(t){return s(t=n(t),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=i.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},c.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=s(t,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=i.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},t.exports.AES=c},function(t,e,r){var i=r(1).Buffer,n=r(66);t.exports=function(t,e,r,o){if(i.isBuffer(t)||(t=i.from(t,"binary")),e&&(i.isBuffer(e)||(e=i.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var s=r/8,a=i.alloc(s),u=i.alloc(o||0),c=i.alloc(0);s>0||o>0;){var h=new n;h.update(c),h.update(t),e&&h.update(e),c=h.digest();var f=0;if(s>0){var d=a.length-s;f=Math.min(s,c.length),c.copy(a,d,0,f),s-=f}if(f<c.length&&o>0){var l=u.length-o,p=Math.min(o,c.length-f);c.copy(u,l,f,f+p),o-=p}}return c.fill(0),{key:a,iv:u}}},function(t,e,r){"use strict";var i=r(261),n=r(272),o=r(273),s=r(80),a=r(115).pbkdf2Sync,u=r(1).Buffer;function c(t){var e;"object"!=typeof t||u.isBuffer(t)||(e=t.passphrase,t=t.key),"string"==typeof t&&(t=u.from(t));var r,c,h=o(t,e),f=h.tag,d=h.data;switch(f){case"CERTIFICATE":c=i.certificate.decode(d,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(c||(c=i.PublicKey.decode(d,"der")),r=c.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPublicKey.decode(c.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return c.subjectPrivateKey=c.subjectPublicKey,{type:"ec",data:c};case"1.2.840.10040.4.1":return c.algorithm.params.pub_key=i.DSAparam.decode(c.subjectPublicKey.data,"der"),{type:"dsa",data:c.algorithm.params};default:throw new Error("unknown key id "+r)}case"ENCRYPTED PRIVATE KEY":d=function(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),o=n[t.algorithm.decrypt.cipher.algo.join(".")],c=t.algorithm.decrypt.cipher.iv,h=t.subjectPrivateKey,f=parseInt(o.split("-")[1],10)/8,d=a(e,r,i,f,"sha1"),l=s.createDecipheriv(o,d,c),p=[];return p.push(l.update(h)),p.push(l.final()),u.concat(p)}(d=i.EncryptedPrivateKey.decode(d,"der"),e);case"PRIVATE KEY":switch(r=(c=i.PrivateKey.decode(d,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPrivateKey.decode(c.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:c.algorithm.curve,privateKey:i.ECPrivateKey.decode(c.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return c.algorithm.params.priv_key=i.DSAparam.decode(c.subjectPrivateKey,"der"),{type:"dsa",params:c.algorithm.params};default:throw new Error("unknown key id "+r)}case"RSA PUBLIC KEY":return i.RSAPublicKey.decode(d,"der");case"RSA PRIVATE KEY":return i.RSAPrivateKey.decode(d,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:i.DSAPrivateKey.decode(d,"der")};case"EC PRIVATE KEY":return{curve:(d=i.ECPrivateKey.decode(d,"der")).parameters.value,privateKey:d.privateKey};default:throw new Error("unknown key type "+f)}}c.signature=i.signature,t.exports=c},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(34),o=r(45),s=r(7),a=r(10),u=r(29),c=r(17),h=r(20),f=r(49),d=r(4);function l(t,e){if(!(this instanceof l))return new l(t,e);if(t instanceof l)return t;var r=this._classifyArguments(t,e);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(c.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return a.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}l.prototype._classifyArguments=function(t,r){var n={compressed:!0,network:r?u.get(r):u.defaultNetwork};if(i.isUndefined(t)||i.isNull(t))n.bn=l._getRandomBN();else if(t instanceof s)n.bn=t;else if(t instanceof e||t instanceof Uint8Array)n=l._transformBuffer(t,r);else if(t.bn&&t.network)n=l._transformObject(t);else if(!r&&u.get(t))n.bn=l._getRandomBN(),n.network=u.get(t);else{if("string"!=typeof t)throw new TypeError("First argument is an unrecognized data type.");a.isHexa(t)?n.bn=new s(e.from(t,"hex")):n=l._transformWIF(t,r)}return n},l._getRandomBN=function(){var t,e;do{var r=f.getRandomBuffer(32);t=(e=s.fromBuffer(r)).lt(c.getN())}while(!t);return e},l._transformBuffer=function(t,e){var r={};if(32===t.length)return l._transformBNBuffer(t,e);if(r.network=u.get(t[0],"privatekey"),!r.network)throw new Error("Invalid network");if(e&&r.network!==u.get(e))throw new TypeError("Private key network mismatch");if(34===t.length&&1===t[33])r.compressed=!0;else{if(33!==t.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(t.slice(1,33)),r},l._transformBNBuffer=function(t,e){var r={};return r.network=u.get(e)||u.defaultNetwork,r.bn=s.fromBuffer(t),r.compressed=!1,r},l._transformWIF=function(t,e){return l._transformBuffer(o.decode(t),e)},l.fromBuffer=function(t,e){return new l(t,e)},l.fromHex=function(t,r){return l.fromBuffer(e.from(t,"hex"),r)},l._transformObject=function(t){return{bn:new s(t.bn,"hex"),network:u.get(t.network),compressed:t.compressed}},l.fromString=l.fromWIF=function(t){return d.checkArgument(i.isString(t),"First argument is expected to be a string."),new l(t)},l.fromObject=l.fromJSON=function(t){return d.checkArgument(i.isObject(t),"First argument is expected to be an object."),new l(t)},l.fromRandom=function(t){var e=l._getRandomBN();return new l(e,t)},l.getValidationError=function(t,e){var r;try{new l(t,e)}catch(t){r=t}return r},l.isValid=function(t,e){return!!t&&!l.getValidationError(t,e)},l.prototype.toString=function(){return this.toWIF()},l.prototype.toWIF=function(){var t,r=this.network;return t=this.compressed?e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32}),e.from([1])]):e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32})]),o.encode(t)},l.prototype.toBigNumber=function(){return this.bn},l.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=h.fromPrivateKey(this)),this._pubkey},l.prototype.toAddress=function(t){var e=this.toPublicKey();return n.fromPublicKey(e,t||this.network)},l.prototype.toObject=l.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},l.prototype.inspect=function(){var t=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+t+">"},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(92),o=r(0),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var i=r;this.fromBuffer(i)}else if("string"==typeof r){var n=r;this.fromString(n)}};a.validCharacters=function(t){return o.Buffer.isBuffer(t)&&(t=t.toString()),i.every(i.map(t,(function(t){return i.includes(s,t)})))},a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.encode=function(t){if(!o.Buffer.isBuffer(t))throw new Error("Input should be a buffer");return n.encode(t)},a.decode=function(t){if("string"!=typeof t)throw new Error("Input should be a string");return e.from(n.decode(t))},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){return(new a).fromString(t)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(142),t.exports.Input=r(86),t.exports.Output=r(27),t.exports.UnspentOutput=r(143),t.exports.Signature=r(48),t.exports.Sighash=r(26)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(7),o=r(25),s=r(21),a=r(9),u=r(4),c=function t(e){if(!(this instanceof t))return new t(e);var r=t._from(e);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&u.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};c._from=function(t){var r={};if(e.isBuffer(t))r=c._fromBufferReader(o(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for BlockHeader");r=c._fromObject(t)}return r},c._fromObject=function(t){u.checkArgument(t,"data is required");var r=t.prevHash,n=t.merkleRoot;return i.isString(t.prevHash)&&(r=e.from(t.prevHash,"hex").reverse()),i.isString(t.merkleRoot)&&(n=e.from(t.merkleRoot,"hex").reverse()),{hash:t.hash,version:t.version,prevHash:r,merkleRoot:n,time:t.time,timestamp:t.time,bits:t.bits,nonce:t.nonce}},c.fromObject=function(t){var e=c._fromObject(t);return new c(e)},c.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=o(t);r.pos=c.Constants.START_OF_HEADER;var i=c._fromBufferReader(r);return new c(i)},c.fromBuffer=function(t){var e=c._fromBufferReader(o(t));return new c(e)},c.fromString=function(t){var r=e.from(t,"hex");return c.fromBuffer(r)},c._fromBufferReader=function(t){var e={};return e.version=t.readInt32LE(),e.prevHash=t.read(32),e.merkleRoot=t.read(32),e.time=t.readUInt32LE(),e.bits=t.readUInt32LE(),e.nonce=t.readUInt32LE(),e},c.fromBufferReader=function(t){var e=c._fromBufferReader(t);return new c(e)},c.prototype.toObject=c.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:e.from(this.prevHash).reverse().toString("hex"),merkleRoot:e.from(this.merkleRoot).reverse().toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},c.prototype.toBuffer=function(){return this.toBufferWriter().concat()},c.prototype.toString=function(){return this.toBuffer().toString("hex")},c.prototype.toBufferWriter=function(t){return t||(t=new s),t.writeInt32LE(this.version),t.write(this.prevHash),t.write(this.merkleRoot),t.writeUInt32LE(this.time),t.writeUInt32LE(this.bits),t.writeUInt32LE(this.nonce),t},c.prototype.getTargetDifficulty=function(t){t=t||this.bits;for(var e=new n(16777215&t),r=8*((t>>>24)-3);r-- >0;)e=e.mul(new n(2));return e},c.prototype.getDifficulty=function(){var t=this.getTargetDifficulty(486604799).mul(new n(Math.pow(10,8))),e=this.getTargetDifficulty(),r=t.div(e).toString(10),i=r.length-8;return r=r.slice(0,i)+"."+r.slice(i),parseFloat(r)},c.prototype._getHash=function(){var t=this.toBuffer();return a.sha256sha256(t)};var h={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=o(this._getHash()).readReverse().toString("hex")),this._id},set:i.noop};Object.defineProperty(c.prototype,"id",h),Object.defineProperty(c.prototype,"hash",h),c.prototype.validTimestamp=function(){var t=Math.round((new Date).getTime()/1e3);return!(this.time>t+c.Constants.MAX_TIME_OFFSET)},c.prototype.validProofOfWork=function(){var t=new n(this.id,"hex"),e=this.getTargetDifficulty();return!(t.cmp(e)>0)},c.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},c.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new n("10000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){var i;function n(t){this.rand=t}if(t.exports=function(t){return i||(i=new n(null)),i.generate(t)},t.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},n.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:"object"==typeof window&&(n.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var o=r(157);if("function"!=typeof o.randomBytes)throw new Error("Not supported");n.prototype._rand=function(t){return o.randomBytes(t)}}catch(t){}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i,n=e,o=r(51),s=r(94),a=r(13).assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=r(167)}catch(t){i=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},function(t,e,r){"use strict";(function(e){var i=r(7),n=r(17),o=r(8),s=r(20),a=r(49),u=r(9),c=r(2),h=r(4),f=function t(e){if(!(this instanceof t))return new t(e);e&&this.set(e)};f.prototype.set=function(t){if(this.hashbuf=t.hashbuf||this.hashbuf,this.endian=t.endian||this.endian,this.privkey=t.privkey||this.privkey,this.pubkey=t.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),t.sig)if(e.isBuffer(t.sig)){var i=r(8);this.sig=i.fromDER(t.sig)}else this.sig=t.sig;else this.sig=this.sig;return this.k=t.k||this.k,this.verified=t.verified||this.verified,this},f.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},f.prototype.calci=function(){for(var t=0;t<4;t++){var e;this.sig.i=t;try{e=this.toPublicKey()}catch(t){console.error(t);continue}if(e.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},f.fromString=function(t){var e=JSON.parse(t);return new f(e)},f.prototype.randomK=function(){var t,e=n.getN();do{t=i.fromBuffer(a.getRandomBuffer(32))}while(!t.lt(e)||!t.gt(i.Zero));return this.k=t,this},f.prototype.deterministicK=function(t){c.isUndefined(t)&&(t=0);var r=e.alloc(32);r.fill(1);var o=e.alloc(32);o.fill(0);var s=this.privkey.bn.toBuffer({size:32}),a="little"===this.endian?e.from(this.hashbuf).reverse():this.hashbuf;o=u.sha256hmac(e.concat([r,e.from([0]),s,a]),o),r=u.sha256hmac(r,o),o=u.sha256hmac(e.concat([r,e.from([1]),s,a]),o),r=u.sha256hmac(r,o),r=u.sha256hmac(r,o);for(var h=i.fromBuffer(r),f=n.getN(),d=0;d<t||!h.lt(f)||!h.gt(i.Zero);d++)o=u.sha256hmac(e.concat([r,e.from([0])]),o),r=u.sha256hmac(r,o),r=u.sha256hmac(r,o),h=i.fromBuffer(r);return this.k=h,this},f.prototype.toPublicKey=function(){var t=this.sig.i;h.checkArgument(0===t||1===t||2===t||3===t,new Error("i must be equal to 0, 1, 2, or 3"));var e=i.fromBuffer(this.hashbuf),r=this.sig.r,o=this.sig.s,a=1&t,u=t>>1,c=n.getN(),f=n.getG(),d=u?r.add(c):r,l=n.fromX(a,d);if(!l.mul(c).isInfinity())throw new Error("nR is not a valid curve point");var p=e.neg().umod(c),g=r.invm(c),m=l.mul(o).add(f.mul(p)).mul(g);return s.fromPoint(m,this.sig.compressed)},f.prototype.sigError=function(){if(!e.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var t=this.sig.r,r=this.sig.s,o=n.getN();try{if(t.isZero()||r.isZero()||t.gte(o)||r.gte(o))return"r and s not in range";var s=o.shrn(1),a=r.gt(s)?o.sub(r):r,u=i.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),c=a.invm(o),h=c.mul(u).umod(o),f=c.mul(t).umod(o),d=n.getG().mulAdd(h,this.pubkey.point,f);if(d.isInfinity())return"p is infinity";if(0!==d.getX().umod(o).cmp(t)){if(r.lte(s))if(h=(c=o.sub(r).invm(o)).mul(u).umod(o),f=c.mul(t).umod(o),!(d=n.getG().mulAdd(h,this.pubkey.point,f)).isInfinity()&&0===d.getX().umod(o).cmp(t))return!1;return"Invalid signature"}return!1}catch(t){return"Signature security validation failed: "+t.message}},f.toLowS=function(t){return t.gt(i.fromBuffer(e.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(t=n.getN().sub(t)),t},f.prototype._findSignature=function(t,e){var r,o,s,a=n.getN(),u=n.getG(),c=0;do{(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,o=u.mul(r).x.umod(a),s=r.invm(a).mul(e.add(t.mul(o))).umod(a)}while(o.cmp(i.Zero)<=0||s.cmp(i.Zero)<=0);return{s:s=f.toLowS(s),r:o}},f.prototype.sign=function(){var t=this.hashbuf,r=this.privkey,n=r.bn;h.checkState(t&&r&&n,new Error("invalid parameters")),h.checkState(e.isBuffer(t)&&32===t.length,new Error("hashbuf must be a 32 byte buffer"));var s=i.fromBuffer(t,this.endian?{endian:this.endian}:void 0),a=this._findSignature(n,s);return a.compressed=this.pubkey.compressed,this.sig=new o(a),this},f.prototype.signRandomK=function(){return this.randomK(),this.sign()},f.prototype.toString=function(){var t={};return this.hashbuf&&(t.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(t.privkey=this.privkey.toString()),this.pubkey&&(t.pubkey=this.pubkey.toString()),this.sig&&(t.sig=this.sig.toString()),this.k&&(t.k=this.k.toString()),JSON.stringify(t)},f.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},f.sign=function(t,e,r){return f().set({hashbuf:t,endian:r,privkey:e}).sign().sig},f.signWithCalcI=function(t,e,r){return f().set({hashbuf:t,endian:r,privkey:e}).sign().calci().sig},f.signRandomK=function(t,e,r){return f().set({hashbuf:t,endian:r,privkey:e}).signRandomK().sig},f.verify=function(t,e,r,i){return f().set({hashbuf:t,endian:i,sig:e,pubkey:r}).verify().verified},t.exports=f}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(3),n=r(179),o=r(1).Buffer,s=new Array(16);function a(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(t,e){return t<<e|t>>>32-e}function c(t,e,r,i,n,o,s){return u(t+(e&r|~e&i)+n+o|0,s)+e|0}function h(t,e,r,i,n,o,s){return u(t+(e&i|r&~i)+n+o|0,s)+e|0}function f(t,e,r,i,n,o,s){return u(t+(e^r^i)+n+o|0,s)+e|0}function d(t,e,r,i,n,o,s){return u(t+(r^(e|~i))+n+o|0,s)+e|0}i(a,n),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,i=this._b,n=this._c,o=this._d;r=c(r,i,n,o,t[0],3614090360,7),o=c(o,r,i,n,t[1],3905402710,12),n=c(n,o,r,i,t[2],606105819,17),i=c(i,n,o,r,t[3],3250441966,22),r=c(r,i,n,o,t[4],4118548399,7),o=c(o,r,i,n,t[5],1200080426,12),n=c(n,o,r,i,t[6],2821735955,17),i=c(i,n,o,r,t[7],4249261313,22),r=c(r,i,n,o,t[8],1770035416,7),o=c(o,r,i,n,t[9],2336552879,12),n=c(n,o,r,i,t[10],4294925233,17),i=c(i,n,o,r,t[11],2304563134,22),r=c(r,i,n,o,t[12],1804603682,7),o=c(o,r,i,n,t[13],4254626195,12),n=c(n,o,r,i,t[14],2792965006,17),r=h(r,i=c(i,n,o,r,t[15],1236535329,22),n,o,t[1],4129170786,5),o=h(o,r,i,n,t[6],3225465664,9),n=h(n,o,r,i,t[11],643717713,14),i=h(i,n,o,r,t[0],3921069994,20),r=h(r,i,n,o,t[5],3593408605,5),o=h(o,r,i,n,t[10],38016083,9),n=h(n,o,r,i,t[15],3634488961,14),i=h(i,n,o,r,t[4],3889429448,20),r=h(r,i,n,o,t[9],568446438,5),o=h(o,r,i,n,t[14],3275163606,9),n=h(n,o,r,i,t[3],4107603335,14),i=h(i,n,o,r,t[8],1163531501,20),r=h(r,i,n,o,t[13],2850285829,5),o=h(o,r,i,n,t[2],4243563512,9),n=h(n,o,r,i,t[7],1735328473,14),r=f(r,i=h(i,n,o,r,t[12],2368359562,20),n,o,t[5],4294588738,4),o=f(o,r,i,n,t[8],2272392833,11),n=f(n,o,r,i,t[11],1839030562,16),i=f(i,n,o,r,t[14],4259657740,23),r=f(r,i,n,o,t[1],2763975236,4),o=f(o,r,i,n,t[4],1272893353,11),n=f(n,o,r,i,t[7],4139469664,16),i=f(i,n,o,r,t[10],3200236656,23),r=f(r,i,n,o,t[13],681279174,4),o=f(o,r,i,n,t[0],3936430074,11),n=f(n,o,r,i,t[3],3572445317,16),i=f(i,n,o,r,t[6],76029189,23),r=f(r,i,n,o,t[9],3654602809,4),o=f(o,r,i,n,t[12],3873151461,11),n=f(n,o,r,i,t[15],530742520,16),r=d(r,i=f(i,n,o,r,t[2],3299628645,23),n,o,t[0],4096336452,6),o=d(o,r,i,n,t[7],1126891415,10),n=d(n,o,r,i,t[14],2878612391,15),i=d(i,n,o,r,t[5],4237533241,21),r=d(r,i,n,o,t[12],1700485571,6),o=d(o,r,i,n,t[3],2399980690,10),n=d(n,o,r,i,t[10],4293915773,15),i=d(i,n,o,r,t[1],2240044497,21),r=d(r,i,n,o,t[8],1873313359,6),o=d(o,r,i,n,t[15],4264355552,10),n=d(n,o,r,i,t[6],2734768916,15),i=d(i,n,o,r,t[13],1309151649,21),r=d(r,i,n,o,t[4],4149444226,6),o=d(o,r,i,n,t[11],3174756917,10),n=d(n,o,r,i,t[2],718787259,15),i=d(i,n,o,r,t[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},a.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 t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},function(t,e,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,o=n&&"function"==typeof n.apply?n.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};i=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,o),i(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&y(t,"error",e,r)}(t,n,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function f(t,e,r,i){var n,o,s,a;if(c(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=h(t))>0&&s.length>n&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=d.bind(i);return n.listener=r,i.wrapFn=n,n}function p(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(n):m(n,n.length)}function g(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function m(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function y(t,e,r,i){if("function"==typeof t.on)i.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function n(o){i.once&&t.removeEventListener(e,n),r(o)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");u=t}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=n[t];if(void 0===u)return!1;if("function"==typeof u)o(u,this,e);else{var c=u.length,h=m(u,c);for(r=0;r<c;++r)o(h[r],this,e)}return!0},a.prototype.addListener=function(t,e){return f(this,t,e,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(t,e){return f(this,t,e,!0)},a.prototype.once=function(t,e){return c(e),this.on(t,l(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,l(this,t,e)),this},a.prototype.removeListener=function(t,e){var r,i,n,o,s;if(c(e),void 0===(i=this._events))return this;if(void 0===(r=i[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,n),1===r.length&&(i[t]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",t,s||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},a.prototype.listeners=function(t){return p(this,t,!0)},a.prototype.rawListeners=function(t){return p(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(t,e,r){var i=r(0),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(o(i,e),e.Buffer=s),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";(function(e,i,n){var o=r(52);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=b;var a,u=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?i:o.nextTick;b.WritableState=y;var c=Object.create(r(38));c.inherits=r(3);var h={deprecate:r(186)},f=r(100),d=r(68).Buffer,l=(void 0!==n?n:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var p,g=r(101);function m(){}function y(t,e){a=a||r(28),t=t||{};var i=e instanceof a;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,c=t.writableHighWaterMark,h=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(c||0===c)?c:h,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 f=!1===t.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(o.nextTick(n,i),o.nextTick(A,t,e),t._writableState.errorEmitted=!0,t.emit("error",i)):(n(i),t._writableState.errorEmitted=!0,t.emit("error",i),A(t,e))}(t,r,i,e,n);else{var s=w(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||S(t,r),i?u(_,t,r,s,n):_(t,r,s,n)}}(e,t)},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 s(this)}function b(t){if(a=a||r(28),!(p.call(b,this)||this instanceof a))return new b(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function v(t,e,r,i,n,o,s){e.writelen=i,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(n,e.onwrite):t._write(n,o,e.onwrite),e.sync=!1}function _(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),A(t,e)}function S(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)n[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;n.allBuffers=u,v(t,e,!0,e.length,n,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,h=r.encoding,f=r.callback;if(v(t,e,!1,e.objectMode?1:c.length,c,h,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function w(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),A(t,e)}))}function A(t,e){var r=w(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(I,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(b,f),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:h.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!p.call(this,t)||this===b&&(t&&t._writableState instanceof y)}})):p=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,r){var i,n=this._writableState,s=!1,a=!n.objectMode&&(i=t,d.isBuffer(i)||i instanceof l);return a&&!d.isBuffer(t)&&(t=function(t){return d.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof r&&(r=m),n.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var n=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(i,s),n=!1),n}(this,n,t,r))&&(n.pendingcb++,s=function(t,e,r,i,n,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=d.from(e,r));return e}(e,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=e.objectMode?1:i.length;e.length+=a;var u=e.length<e.highWaterMark;u||(e.needDrain=!0);if(e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else v(t,e,!1,a,i,n,o);return u}(this,n,a,t,e,r)),s},b.prototype.cork=function(){this._writableState.corked++},b.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||S(this,t))},b.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(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},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,r){var i=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,A(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,r(11),r(184).setImmediate,r(12))},function(t,e,r){"use strict";var i=r(187).Buffer,n=i.isEncoding||function(t){switch((t=""+t)&&t.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 o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){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 t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=h,this.end=f,e=3;break;default:return this.write=d,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function h(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function d(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var i=e.length-1;if(i<r)return 0;var n=s(e[i]);if(n>=0)return n>0&&(t.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if((n=s(e[i]))>=0)return n>0&&(t.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if((n=s(e[i]))>=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";var i=r(0).Buffer,n=r(103),o=r(194),s=new Array(16),a=[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],u=[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],c=[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],h=[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],f=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0];function l(t,e){return t<<e|t>>>32-e}function p(t,e,r,i,n,o,s,a){return l(t+(e^r^i)+o+s|0,a)+n|0}function g(t,e,r,i,n,o,s,a){return l(t+(e&r|~e&i)+o+s|0,a)+n|0}function m(t,e,r,i,n,o,s,a){return l(t+((e|~r)^i)+o+s|0,a)+n|0}function y(t,e,r,i,n,o,s,a){return l(t+(e&i|r&~i)+o+s|0,a)+n|0}function b(t,e,r,i,n,o,s,a){return l(t+(e^(r|~i))+o+s|0,a)+n|0}function v(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}n(v,o),v.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,i=0|this._b,n=0|this._c,o=0|this._d,v=0|this._e,_=0|this._a,S=0|this._b,w=0|this._c,I=0|this._d,A=0|this._e,E=0;E<80;E+=1){var O,k;E<16?(O=p(r,i,n,o,v,t[a[E]],f[0],c[E]),k=b(_,S,w,I,A,t[u[E]],d[0],h[E])):E<32?(O=g(r,i,n,o,v,t[a[E]],f[1],c[E]),k=y(_,S,w,I,A,t[u[E]],d[1],h[E])):E<48?(O=m(r,i,n,o,v,t[a[E]],f[2],c[E]),k=m(_,S,w,I,A,t[u[E]],d[2],h[E])):E<64?(O=y(r,i,n,o,v,t[a[E]],f[3],c[E]),k=g(_,S,w,I,A,t[u[E]],d[3],h[E])):(O=b(r,i,n,o,v,t[a[E]],f[4],c[E]),k=p(_,S,w,I,A,t[u[E]],d[4],h[E])),r=v,v=o,o=l(n,10),n=i,i=O,_=A,A=I,I=l(w,10),w=S,S=k}var P=this._b+n+I|0;this._b=this._c+o+A|0,this._c=this._d+v+_|0,this._d=this._e+r+S|0,this._e=this._a+i+w|0,this._a=P},v.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 t=i.alloc?i.alloc(20):new i(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=v},function(t,e,r){"use strict";var i=r(104),n=r(75),o=n([i("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=i(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?n([r]):r}},function(t,e,r){"use strict";t.exports=Object},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var i in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,e,r){"use strict";var i=r(41),n=r(39),o=r(76),s=r(109);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new n("a function is required");return s(i,o,t)}},function(t,e,r){"use strict";t.exports=Function.prototype.call},function(t,e,r){"use strict";t.exports=Function.prototype.apply},function(t,e,r){"use strict";t.exports=function(e){var r=e.toLowerCase(),i=t.exports[r];if(!i)throw new Error(r+" is not supported (we accept pull requests)");return new i},t.exports.sha=r(229),t.exports.sha1=r(230),t.exports.sha224=r(231),t.exports.sha256=r(110),t.exports.sha384=r(232),t.exports.sha512=r(111)},function(t,e,r){"use strict";var i=r(14);function n(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=!1!==t.padding}t.exports=n,n.prototype._init=function(){},n.prototype.update=function(t){return 0===t.length?[]:"decrypt"===this.type?this._updateDecrypt(t):this._updateEncrypt(t)},n.prototype._buffer=function(t,e){for(var r=Math.min(this.buffer.length-this.bufferOff,t.length-e),i=0;i<r;i++)this.buffer[this.bufferOff+i]=t[e+i];return this.bufferOff+=r,r},n.prototype._flushBuffer=function(t,e){return this._update(this.buffer,0,t,e),this.bufferOff=0,this.blockSize},n.prototype._updateEncrypt=function(t){var e=0,r=0,i=(this.bufferOff+t.length)/this.blockSize|0,n=new Array(i*this.blockSize);0!==this.bufferOff&&(e+=this._buffer(t,e),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(n,r)));for(var o=t.length-(t.length-e)%this.blockSize;e<o;e+=this.blockSize)this._update(t,e,n,r),r+=this.blockSize;for(;e<t.length;e++,this.bufferOff++)this.buffer[this.bufferOff]=t[e];return n},n.prototype._updateDecrypt=function(t){for(var e=0,r=0,i=Math.ceil((this.bufferOff+t.length)/this.blockSize)-1,n=new Array(i*this.blockSize);i>0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(n,r);return e+=this._buffer(t,e),n},n.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},n.prototype._pad=function(t,e){if(0===e)return!1;for(;e<t.length;)t[e++]=0;return!0},n.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var t=new Array(this.blockSize);return this._update(this.buffer,0,t,0),t},n.prototype._unpad=function(t){return t},n.prototype._finalDecrypt=function(){i.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var t=new Array(this.blockSize);return this._flushBuffer(t,0),this._unpad(t)}},function(t,e,r){var i=r(242),n=r(250),o=r(124);e.createCipher=e.Cipher=i.createCipher,e.createCipheriv=e.Cipheriv=i.createCipheriv,e.createDecipher=e.Decipher=n.createDecipher,e.createDecipheriv=e.Decipheriv=n.createDecipheriv,e.listCiphers=e.getCiphers=function(){return Object.keys(o)}},function(t,e,r){var i={ECB:r(243),CBC:r(244),CFB:r(245),CFB8:r(246),CFB1:r(247),OFB:r(248),CTR:r(122),GCM:r(122)},n=r(124);for(var o in n)n[o].module=i[n[o].mode];t.exports=n},function(t,e,r){"use strict";var i=r(258),n=r(31),o=r(1).Buffer;function s(t){var e,r=t.modulus.byteLength();do{e=new i(n(r))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function a(t,e){var r=function(t){var e=s(t);return{blinder:e.toRed(i.mont(t.modulus)).redPow(new i(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),n=e.modulus.byteLength(),a=new i(t).mul(r.blinder).umod(e.modulus),u=a.toRed(i.mont(e.prime1)),c=a.toRed(i.mont(e.prime2)),h=e.coefficient,f=e.prime1,d=e.prime2,l=u.redPow(e.exponent1).fromRed(),p=c.redPow(e.exponent2).fromRed(),g=l.isub(p).imul(h).umod(f).imul(d);return p.iadd(g).imul(r.unblinder).umod(e.modulus).toArrayLike(o,"be",n)}a.getr=s,t.exports=a},function(t,e,r){"use strict";(function(e){var i=r(280)();
11
+ /*!
12
+ * The buffer module from node.js, for the browser.
13
+ *
14
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
15
+ * @license MIT
16
+ */function n(t,e){if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0}function o(t){return e.Buffer&&"function"==typeof e.Buffer.isBuffer?e.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var s=r(140),a=Object.prototype.hasOwnProperty,u=Array.prototype.slice,c="foo"===function(){}.name;function h(t){return Object.prototype.toString.call(t)}function f(t){return!o(t)&&("function"==typeof e.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer))))}var d=t.exports=b,l=/\s*function\s+([^\(\s]*)\s*/;function p(t){if(s.isFunction(t)){if(c)return t.name;var e=t.toString().match(l);return e&&e[1]}}function g(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function m(t){if(c||!s.isFunction(t))return s.inspect(t);var e=p(t);return"[Function"+(e?": "+e:"")+"]"}function y(t,e,r,i,n){throw new d.AssertionError({message:r,actual:t,expected:e,operator:i,stackStartFunction:n})}function b(t,e){t||y(t,!0,e,"==",d.ok)}function v(t,e,r,i){if(t===e)return!0;if(o(t)&&o(e))return 0===n(t,e);if(s.isDate(t)&&s.isDate(e))return t.getTime()===e.getTime();if(s.isRegExp(t)&&s.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(f(t)&&f(e)&&h(t)===h(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===n(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(o(t)!==o(e))return!1;var a=(i=i||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===i.expected.indexOf(e)||(i.actual.push(t),i.expected.push(e),function(t,e,r,i){if(null==t||null==e)return!1;if(s.isPrimitive(t)||s.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var n=_(t),o=_(e);if(n&&!o||!n&&o)return!1;if(n)return t=u.call(t),e=u.call(e),v(t,e,r);var a,c,h=I(t),f=I(e);if(h.length!==f.length)return!1;for(h.sort(),f.sort(),c=h.length-1;c>=0;c--)if(h[c]!==f[c])return!1;for(c=h.length-1;c>=0;c--)if(a=h[c],!v(t[a],e[a],r,i))return!1;return!0}(t,e,r,i))}return r?t===e:t==e}function _(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function S(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function w(t,e,r,i){var n;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(i=r,r=null),n=function(t){var e;try{t()}catch(t){e=t}return e}(e),i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),t&&!n&&y(n,r,"Missing expected exception"+i);var o="string"==typeof i,a=!t&&n&&!r;if((!t&&s.isError(n)&&o&&S(n,r)||a)&&y(n,r,"Got unwanted exception"+i),t&&n&&r&&!S(n,r)||!t&&n)throw n}d.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return g(m(t.actual),128)+" "+t.operator+" "+g(m(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var i=r.stack,n=p(e),o=i.indexOf("\n"+n);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},s.inherits(d.AssertionError,Error),d.fail=y,d.ok=b,d.equal=function(t,e,r){t!=e&&y(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&y(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){v(t,e,!1)||y(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){v(t,e,!0)||y(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){v(t,e,!1)&&y(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,i){v(e,r,!0)&&y(e,r,i,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&y(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&y(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){w(!0,t,e,r)},d.doesNotThrow=function(t,e,r){w(!1,t,e,r)},d.ifError=function(t){if(t)throw t},d.strict=i((function t(e,r){e||y(e,!0,r,"==",t)}),d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var I=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(12))},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(10);function s(t){if(!(this instanceof s))return new s(t);var e;if(i.isNumber(t))e=t;else{if(!i.isString(t))throw new TypeError('Unrecognized num type: "'+typeof t+'" for Opcode');e=s.map[t]}return o.defineImmutable(this,{num:e}),this}for(var a in s.fromBuffer=function(t){return n.checkArgument(e.isBuffer(t)),new s(Number("0x"+t.toString("hex")))},s.fromNumber=function(t){return n.checkArgument(i.isNumber(t)),new s(t)},s.fromString=function(t){n.checkArgument(i.isString(t));var e=s.map[t];if(void 0===e)throw new TypeError("Invalid opcodestr");return new s(e)},s.prototype.toHex=function(){return this.num.toString(16)},s.prototype.toBuffer=function(){return e.from(this.toHex(),"hex")},s.prototype.toNumber=function(){return this.num},s.prototype.toString=function(){var t=s.reverseMap[this.num];if(void 0===t)throw new Error("Opcode does not have a string representation");return t},s.smallInt=function(t){return n.checkArgument(i.isNumber(t),"Invalid Argument: n should be number"),n.checkArgument(t>=0&&t<=16,"Invalid Argument: n must be between 0 and 16"),0===t?s("OP_0"):new s(s.map.OP_1+t-1)},s.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_NOP4:182,OP_NOP5:183,OP_NOP6:184,OP_NOP7:185,OP_NOP8:186,OP_NOP9:187,OP_NOP10:188,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},s.reverseMap=[],s.map)s.reverseMap[s.map[a]]=a;i.extend(s,s.map),s.isSmallIntOp=function(t){return t instanceof s&&(t=t.toNumber()),t===s.map.OP_0||t>=s.map.OP_1&&t<=s.map.OP_16},s.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(138),o=r(84),s=r(7),a=r(9),u=r(8),c=r(20),h=r(285),f=function t(e){if(!(this instanceof t))return new t(e);e?(this.initialize(),this.set(e)):this.initialize()};f.prototype.verify=function(t,e,o,s,a,u){var c,h=r(60);if(i.isUndefined(o)&&(o=new h),i.isUndefined(s)&&(s=0),i.isUndefined(a)&&(a=0),a&f.SCRIPT_ENABLE_SIGHASH_FORKID&&(a|=f.SCRIPT_VERIFY_STRICTENC,!u))throw new Error("internal error - need satoshisBN to verify FORKID transactions");if(this.set({script:t,tx:o,nin:s,flags:a,satoshisBN:u}),0!=(a&f.SCRIPT_VERIFY_SIGPUSHONLY)&&!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&f.SCRIPT_VERIFY_P2SH&&(c=this.stack.slice());var d=this.stack;if(this.initialize(),this.set({script:e,stack:d,tx:o,nin:s,flags:a,satoshisBN:u}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var l=this.stack[this.stack.length-1];if(!f.castToBool(l))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&f.SCRIPT_VERIFY_P2SH&&e.isScriptHashOut()){if(!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===c.length)throw new Error("internal error - stack copy empty");var p=c[c.length-1],g=n.fromBuffer(p);if(c.pop(),this.initialize(),this.set({script:g,stack:c,tx:o,nin:s,flags:a,satoshisBN:u}),!this.evaluate())return!1;if(0===c.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!f.castToBool(c[c.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if(0!=(a&f.SCRIPT_VERIFY_CLEANSTACK)){if(0==(a&f.SCRIPT_VERIFY_P2SH))throw new Error("internal error - CLEANSTACK without P2SH");if(1!==c.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0},t.exports=f,f.prototype.initialize=function(t){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},f.prototype.set=function(t){this.script=t.script||this.script,this.tx=t.tx||this.tx,this.nin=void 0!==t.nin?t.nin:this.nin,this.satoshisBN=t.satoshisBN||this.satoshisBN,this.stack=t.stack||this.stack,this.altstack=t.altstack||this.altstack,this.pc=void 0!==t.pc?t.pc:this.pc,this.pbegincodehash=void 0!==t.pbegincodehash?t.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==t.nOpCount?t.nOpCount:this.nOpCount,this.vfExec=t.vfExec||this.vfExec,this.errstr=t.errstr||this.errstr,this.flags=void 0!==t.flags?t.flags:this.flags},f.true=e.from([1]),f.false=e.from([]),f.MAX_SCRIPT_ELEMENT_SIZE=520,f.MAXIMUM_ELEMENT_SIZE=4,f.LOCKTIME_THRESHOLD_BN=new s(f.LOCKTIME_THRESHOLD=5e8),f.SCRIPT_VERIFY_NONE=0,f.SCRIPT_VERIFY_P2SH=1,f.SCRIPT_VERIFY_STRICTENC=2,f.SCRIPT_VERIFY_DERSIG=4,f.SCRIPT_VERIFY_LOW_S=8,f.SCRIPT_VERIFY_NULLDUMMY=16,f.SCRIPT_VERIFY_SIGPUSHONLY=32,f.SCRIPT_VERIFY_MINIMALDATA=64,f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,f.SCRIPT_VERIFY_CLEANSTACK=256,f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,f.SCRIPT_VERIFY_MINIMALIF=8192,f.SCRIPT_VERIFY_NULLFAIL=16384,f.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768,f.SCRIPT_ENABLE_SIGHASH_FORKID=65536,f.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,f.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,f.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19,f.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,f.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,f.SEQUENCE_LOCKTIME_MASK=65535,f.castToBool=function(t){for(var e=0;e<t.length;e++)if(0!==t[e])return e!==t.length-1||128!==t[e];return!1},f.prototype.checkSignatureEncoding=function(t){var e;if(0===t.length)return!0;if(0!=(this.flags&(f.SCRIPT_VERIFY_DERSIG|f.SCRIPT_VERIFY_LOW_S|f.SCRIPT_VERIFY_STRICTENC))&&!u.isTxDER(t))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!=(this.flags&f.SCRIPT_VERIFY_LOW_S)){if(!(e=u.fromTxFormat(t)).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!=(this.flags&f.SCRIPT_VERIFY_STRICTENC)){if(!(e=u.fromTxFormat(t)).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID)&&e.nhashtype&u.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID&&!(e.nhashtype&u.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0},f.prototype.checkPubkeyEncoding=function(t){return!(0!=(this.flags&f.SCRIPT_VERIFY_STRICTENC)&&!c.isValid(t))||(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},f._isMinimallyEncoded=function(t,e){return e=e||f.MAXIMUM_ELEMENT_SIZE,!(t.length>e)&&!(t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))},f._minimallyEncode=function(t){if(0===t.length)return t;var r=t[t.length-1];if(127&r)return t;if(1===t.length)return e.from("");if(128&t[t.length-2])return t;for(var i=t.length-1;i>0;i--)if(0!==t[i-1])return 128&t[i-1]?t[i++]=r:t[i-1]|=r,t.slice(0,i);return e.from("")},f.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:o.fromNumber(this.script.chunks[this.pc].opcodenum)};if(!this.step())return!1;this._callbackStep(t)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},f.prototype._callbackStep=function(t){if("function"==typeof this.stepListener)try{this.stepListener(t,h(this.stack,!0),h(this.altstack,!0))}catch(t){console.log("Error in Step callback:"+t)}},f.prototype.checkLockTime=function(t){return!!(this.tx.nLockTime<f.LOCKTIME_THRESHOLD&&t.lt(f.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=f.LOCKTIME_THRESHOLD&&t.gte(f.LOCKTIME_THRESHOLD_BN))&&(!t.gt(new s(this.tx.nLockTime))&&!this.tx.inputs[this.nin].isFinal())},f.prototype.checkSequence=function(t){var e=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(e&f.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=f.SEQUENCE_LOCKTIME_TYPE_FLAG|f.SEQUENCE_LOCKTIME_MASK,i=new s(e&r),n=t.and(r),o=new s(f.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(i.lt(o)&&n.lt(o)||i.gte(o)&&n.gte(o))&&!n.gt(i)},f.prototype.step=function(){var t=this;function r(e){return t.stack[t.stack.length+e]}var h,d,l,p,g,m,y,b,v,_,S,w,I,A,E,O,k,P=0!=(this.flags&f.SCRIPT_VERIFY_MINIMALDATA),M=-1===this.vfExec.indexOf(!1),T=this.script.chunks[this.pc];this.pc++;var x=T.opcodenum;if(i.isUndefined(x))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(T.buf&&T.buf.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(x>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(function(e){switch(e){case o.OP_2MUL:case o.OP_2DIV:return!0;case o.OP_INVERT:case o.OP_MUL:case o.OP_LSHIFT:case o.OP_RSHIFT:if(0==(t.flags&f.SCRIPT_ENABLE_MAGNETIC_OPCODES))return!0;break;case o.OP_DIV:case o.OP_MOD:case o.OP_SPLIT:case o.OP_CAT:case o.OP_AND:case o.OP_OR:case o.OP_XOR:case o.OP_BIN2NUM:case o.OP_NUM2BIN:return!1}return!1}(x))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(M&&x>=0&&x<=o.OP_PUSHDATA4){if(P&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(T.buf){if(T.len!==T.buf.length)throw new Error(`Length of push value not equal to length of data (${T.len},${T.buf.length})`);this.stack.push(T.buf)}else this.stack.push(f.false)}else if(M||o.OP_IF<=x&&x<=o.OP_ENDIF)switch(x){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:g=x-(o.OP_1-1),h=new s(g).toScriptNumBuffer(),this.stack.push(h);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var R=s.fromScriptNumBuffer(this.stack[this.stack.length-1],P,5);if(R.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(R))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP3:case o.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var C=s.fromScriptNumBuffer(r(-1),P,5);if(C.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!=(C&f.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(C))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(O=!1,M){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(h=r(-1),this.flags&f.SCRIPT_VERIFY_MINIMALIF){if(h.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1===h.length&&1!==h[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}O=f.castToBool(h),x===o.OP_NOTIF&&(O=!O),this.stack.pop()}this.vfExec.push(O);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(h=r(-1),!(O=f.castToBool(h)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),l=r(-1),this.stack.push(e.from(d)),this.stack.push(e.from(l));break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-3),l=r(-2);var B=r(-1);this.stack.push(e.from(d)),this.stack.push(e.from(l)),this.stack.push(e.from(B));break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-4),l=r(-3),this.stack.push(e.from(d)),this.stack.push(e.from(l));break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-6,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-4,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=r(-1),(O=f.castToBool(h))&&this.stack.push(e.from(h));break;case o.OP_DEPTH:h=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(h);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-1)));break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-2)));break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(h=r(-1),g=(b=s.fromScriptNumBuffer(h,P)).toNumber(),this.stack.pop(),g<0||g>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=r(-g-1),x===o.OP_ROLL&&this.stack.splice(this.stack.length-g-1,1),this.stack.push(e.from(h));break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-3),y=r(-2);var N=r(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=N,this.stack[this.stack.length-1]=m;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-2),y=r(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=m;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,e.from(r(-1)));break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=new s(r(-1).length),this.stack.push(b.toScriptNumBuffer());break;case o.OP_AND:case o.OP_OR:case o.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),l=r(-1),d.length!==l.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(x){case o.OP_AND:for(let t=0;t<d.length;t++)d[t]&=l[t];break;case o.OP_OR:for(let t=0;t<d.length;t++)d[t]|=l[t];break;case o.OP_XOR:for(let t=0;t<d.length;t++)d[t]^=l[t]}this.stack.pop();break;case o.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),h=r(-1);for(let t=0;t<h.length;t++)h[t]=~h[t];break;case o.OP_LSHIFT:case o.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(0===(d=r(-2)).length)this.stack.pop();else{if(v=new s(d),(g=(_=s.fromScriptNumBuffer(r(-1),P)).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;let t;this.stack.pop(),this.stack.pop(),x===o.OP_LSHIFT&&(t=v.ushln(g)),x===o.OP_RSHIFT&&(t=v.ushrn(g));let i=function(t,r){let i=t;for(;i.length<r;)i=e.concat([e.from([0]),i]);return i}(e.from(t.toArray().slice(-1*d.length)),d.length);this.stack.push(i)}break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),l=r(-1);var D=d.toString("hex")===l.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(D?f.true:f.false),x===o.OP_EQUALVERIFY){if(!D)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(h=r(-1),b=s.fromScriptNumBuffer(h,P),x){case o.OP_1ADD:b=b.add(s.One);break;case o.OP_1SUB:b=b.sub(s.One);break;case o.OP_NEGATE:b=b.neg();break;case o.OP_ABS:b.cmp(s.Zero)<0&&(b=b.neg());break;case o.OP_NOT:b=new s((0===b.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:b=new s((0!==b.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(b.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_MUL:case o.OP_MOD:case o.OP_DIV:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=s.fromScriptNumBuffer(r(-2),P),_=s.fromScriptNumBuffer(r(-1),P),b=new s(0),x){case o.OP_ADD:b=v.add(_);break;case o.OP_SUB:b=v.sub(_);break;case o.OP_MUL:b=v.mul(_);break;case o.OP_DIV:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;b=v.div(_);break;case o.OP_MOD:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;b=v.mod(_);break;case o.OP_BOOLAND:b=new s((0!==v.cmp(s.Zero)&&0!==_.cmp(s.Zero))+0);break;case o.OP_BOOLOR:b=new s((0!==v.cmp(s.Zero)||0!==_.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:b=new s((0===v.cmp(_))+0);break;case o.OP_NUMNOTEQUAL:b=new s((0!==v.cmp(_))+0);break;case o.OP_LESSTHAN:b=new s((v.cmp(_)<0)+0);break;case o.OP_GREATERTHAN:b=new s((v.cmp(_)>0)+0);break;case o.OP_LESSTHANOREQUAL:b=new s((v.cmp(_)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:b=new s((v.cmp(_)>=0)+0);break;case o.OP_MIN:b=v.cmp(_)<0?v:_;break;case o.OP_MAX:b=v.cmp(_)>0?v:_}if(this.stack.pop(),this.stack.pop(),this.stack.push(b.toScriptNumBuffer()),x===o.OP_NUMEQUALVERIFY){if(!f.castToBool(r(-1)))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=s.fromScriptNumBuffer(r(-3),P),_=s.fromScriptNumBuffer(r(-2),P);var L=s.fromScriptNumBuffer(r(-1),P);O=_.cmp(v)<=0&&v.cmp(L)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(O?f.true:f.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var U;h=r(-1),x===o.OP_RIPEMD160?U=a.ripemd160(h):x===o.OP_SHA1?U=a.sha1(h):x===o.OP_SHA256?U=a.sha256(h):x===o.OP_HASH160?U=a.sha256ripemd160(h):x===o.OP_HASH256&&(U=a.sha256sha256(h)),this.stack.pop(),this.stack.push(U);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(S=r(-2),w=r(-1),!this.checkSignatureEncoding(S)||!this.checkPubkeyEncoding(w))return!1;I=(new n).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var j=(new n).add(S);I.findAndDelete(j);try{A=u.fromTxFormat(S),E=c.fromBuffer(w,!1),k=this.tx.verifySignature(A,E,this.nin,I,this.satoshisBN,this.flags)}catch(t){k=!1}if(!k&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&S.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(k?f.true:f.false),x===o.OP_CHECKSIGVERIFY){if(!k)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var H=1;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var F=s.fromScriptNumBuffer(r(-H),P).toNumber();if(F<0||F>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=F,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var K=++H;H+=F;var V=F+2;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var z=s.fromScriptNumBuffer(r(-H),P).toNumber();if(z<0||z>F)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var q=++H;if(H+=z,this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;I=(new n).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var G=0;G<z;G++)S=r(-q-G),I.findAndDelete((new n).add(S));for(k=!0;k&&z>0;){if(S=r(-q),w=r(-K),!this.checkSignatureEncoding(S)||!this.checkPubkeyEncoding(w))return!1;var Y;try{A=u.fromTxFormat(S),E=c.fromBuffer(w,!1),Y=this.tx.verifySignature(A,E,this.nin,I,this.satoshisBN,this.flags)}catch(t){Y=!1}Y&&(q++,z--),K++,z>--F&&(k=!1)}for(;H-- >1;){if(!k&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&!V&&r(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;V>0&&V--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&f.SCRIPT_VERIFY_NULLDUMMY&&r(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(k?f.true:f.false),x===o.OP_CHECKMULTISIGVERIFY){if(!k)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;case o.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),l=r(-1),d.length+l.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=e.concat([d,l]),this.stack.pop();break;case o.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2);var W=s.fromScriptNumBuffer(r(-1),P).toNumber();if(W<0||W>d.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var X=e.from(d);this.stack[this.stack.length-2]=X.slice(0,W),this.stack[this.stack.length-1]=X.slice(W);break;case o.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Z=s.fromScriptNumBuffer(r(-1),P).toNumber();if(Z>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var J=r(-1);if((J=f._minimallyEncode(J)).length>Z)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(J.length===Z){this.stack[this.stack.length-1]=J;break}var $=0;J.length>0&&($=128&J[J.length-1],J[J.length-1]&=127);var Q=e.alloc(Z);J.copy(Q,0);for(var tt=J.length-1;tt++<Z-2;)Q[tt]=0;Q[tt]=$,this.stack[this.stack.length-1]=Q;break;case o.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-1),l=f._minimallyEncode(d),this.stack[this.stack.length-1]=l,!f._isMinimallyEncoded(l))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(47),t.exports.PublicKey=r(289),t.exports.PublicKeyHash=r(290),t.exports.MultiSig=r(291),t.exports.MultiSigScriptHash=r(292)},function(t,e,r){"use strict";(function(e){const i=r(7),n=r(17),o=r(65),s=n.getN(),a=s.shrn(1);t.exports={smartVerify:function(t,n,u){if(!e.isBuffer(t)||32!==t.length)throw new Error("Invalid message hash: must be 32-byte buffer");if(!n)return!1;let c=n;if(e.isBuffer(n))try{c=r(8).fromDER(n)}catch(t){return!1}if(!c||!c.r||!c.s)return!1;const h=i.isBN(c.r)?c.r:new i(c.r),f=i.isBN(c.s)?c.s:new i(c.s);if(h.isZero()||f.isZero())return!1;if(h.gte(s)||f.gte(s))return!1;let d=f;f.gt(a)&&(d=s.sub(f));const l=new(r(8))({r:h,s:d});return o.verify(t,l,u)},isCanonical:function(t){if(!t)return!1;let n=t;if(e.isBuffer(t))try{n=r(8).fromDER(t)}catch(t){return!1}return!(!n||!n.s)&&(i.isBN(n.s)?n.s:new i(n.s)).lte(a)},canonicalize:function(t){if(!t||!t.r||!t.s)throw new Error("Invalid signature object");const e=i.isBN(t.r)?t.r:new i(t.r),r=i.isBN(t.s)?t.s:new i(t.s);let n=r;return r.gt(a)&&(n=s.sub(r)),{r:e,s:n}},constants:{n:s,nh:a}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";const{ec:i}=r(30),n=new i("secp256k1"),o=n.verify.bind(n);n.verify=function(t,e,r,i,n){if(!e||"object"!=typeof e)return!1;if(!e.r||!e.s)return!1;const s="function"==typeof e.r.cmp?e.r:this.curve.n.red?this.curve.n.fromRed(e.r):e.r,a="function"==typeof e.s.cmp?e.s:this.curve.n.red?this.curve.n.fromRed(e.s):e.s;return!(s&&s.cmp&&s.cmp(this.curve.n)>=0)&&(!(a&&a.cmp&&a.cmp(this.curve.n)>=0)&&(!(s&&s.isZero&&s.isZero())&&(!(a&&a.isZero&&a.isZero())&&o(t,e,r,i,n))))};const s=n.sign.bind(n);n.sign=function(t,e,r,i){const n=s(t,e,r,i);if(n.s&&n.s.cmp){const t=this.curve.n.shrn(1);n.s.cmp(t)>0&&(n.s=this.curve.n.sub(n.s))}return n},t.exports=n},function(t,e,r){(function(t){function r(t,e){for(var r=0,i=t.length-1;i>=0;i--){var n=t[i];"."===n?t.splice(i,1):".."===n?(t.splice(i,1),r++):r&&(t.splice(i,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var r=[],i=0;i<t.length;i++)e(t[i],i,t)&&r.push(t[i]);return r}e.resolve=function(){for(var e="",n=!1,o=arguments.length-1;o>=-1&&!n;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,n="/"===s.charAt(0))}return(n?"/":"")+(e=r(i(e.split("/"),(function(t){return!!t})),!n).join("/"))||"."},e.normalize=function(t){var o=e.isAbsolute(t),s="/"===n(t,-1);return(t=r(i(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t="."),t&&s&&(t+="/"),(o?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(i(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},e.relative=function(t,r){function i(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=e.resolve(t).substr(1),r=e.resolve(r).substr(1);for(var n=i(t.split("/")),o=i(r.split("/")),s=Math.min(n.length,o.length),a=s,u=0;u<s;u++)if(n[u]!==o[u]){a=u;break}var c=[];for(u=a;u<n.length;u++)c.push("..");return(c=c.concat(o.slice(a))).join("/")},e.sep="/",e.delimiter=":",e.dirname=function(t){if("string"!=typeof t&&(t+=""),0===t.length)return".";for(var e=t.charCodeAt(0),r=47===e,i=-1,n=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!n){i=o;break}}else n=!1;return-1===i?r?"/":".":r&&1===i?"/":t.slice(0,i)},e.basename=function(t,e){var r=function(t){"string"!=typeof t&&(t+="");var e,r=0,i=-1,n=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!n){r=e+1;break}}else-1===i&&(n=!1,i=e+1);return-1===i?"":t.slice(r,i)}(t);return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},e.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,r=0,i=-1,n=!0,o=0,s=t.length-1;s>=0;--s){var a=t.charCodeAt(s);if(47!==a)-1===i&&(n=!1,i=s+1),46===a?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!n){r=s+1;break}}return-1===e||-1===i||0===o||1===o&&e===i-1&&e===r+1?"":t.slice(e,i)};var n="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)}}).call(this,r(11))},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.PublicKey,o=i.PrivateKey,s=i.crypto.Hash,a=i.util.preconditions;i.errors;function u(t){return this instanceof u?(this.options=t||{},this.network=this.options.network||"mainnet",this.registry=this.options.registry||null,this):new u(t)}u.fromPublicKey=function(t,e){e=e||{},"string"==typeof t&&(t=n.fromString(t)),a.checkArgument(t instanceof n,"Invalid public key");var r=t.toString("hex"),i=e.network||"mainnet",o=e.path||"",s="did:smartledger:"+r;return"mainnet"!==i&&(s+=":"+i),o&&(s+=":"+o),s},u.fromPrivateKey=function(t,e){return"string"==typeof t&&(t=o.fromWIF(t)),a.checkArgument(t instanceof o,"Invalid private key"),u.fromPublicKey(t.toPublicKey(),e)},u.parseDID=function(t){if(a.checkArgument("string"==typeof t,"DID must be a string"),!t.startsWith("did:smartledger:"))throw new Error("Invalid SmartLedger DID format");var e=t.split(":");if(e.length<3)throw new Error("Invalid DID format");var r={method:"smartledger",identifier:e[2],network:"mainnet",path:""};return e.length>3&&""!==e[3]&&(r.network=e[3]),e.length>4&&(r.path=e.slice(4).join(":")),r},u.isValidDID=function(t){try{var e=u.parseDID(t);return!(!/^[0-9a-fA-F]{66}$/.test(e.identifier)&&!/^[0-9a-fA-F]{130}$/.test(e.identifier))&&!!["mainnet","testnet","regtest"].includes(e.network)}catch(t){return!1}},u.getPublicKey=function(t){var e=u.parseDID(t);return n.fromString(e.identifier)},u.createDocument=function(t,e){e=e||{},a.checkArgument(u.isValidDID(t),"Invalid DID");var r=t+"#keys-1",i={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/secp256k1-2019/v1"],id:t,verificationMethod:[{id:r,type:"EcdsaSecp256k1VerificationKey2019",controller:t,publicKeyHex:u.getPublicKey(t).toString("hex")}],authentication:[r],assertionMethod:[r],keyAgreement:[r],capabilityInvocation:[r],capabilityDelegation:[r]};return e.services&&Array.isArray(e.services)&&(i.service=e.services),e.verificationMethods&&(i.verificationMethod=i.verificationMethod.concat(e.verificationMethods)),e.created&&(i.created=e.created),e.updated&&(i.updated=e.updated),i},u.resolve=async function(t,e){e=e||{};try{return a.checkArgument(u.isValidDID(t),"Invalid DID"),{"@context":"https://w3id.org/did-resolution/v1",didDocument:u.createDocument(t,e),didResolutionMetadata:{contentType:"application/did+ld+json",retrieved:(new Date).toISOString()},didDocumentMetadata:{method:{published:!0,recoveryCommitment:null,updateCommitment:null}}}}catch(t){return{"@context":"https://w3id.org/did-resolution/v1",didDocument:null,didResolutionMetadata:{error:"notFound",errorMessage:t.message},didDocumentMetadata:{}}}},u.verifyOwnership=function(t,r,n){try{var o=u.getPublicKey(t),a=s.sha256(e.isBuffer(n)?n:e.from(n,"utf8")),c=i.crypto.Signature.fromString(r),h=new i.crypto.ECDSA;return h.hashbuf=a,h.pubkey=o,h.sig=c,h.verify()}catch(t){return!1}},u.signMessage=function(t,r){a.checkArgument(r instanceof o,"Invalid private key");var n=s.sha256(e.isBuffer(t)?t:e.from(t,"utf8")),u=new i.crypto.ECDSA;return u.hashbuf=n,u.privkey=r,u.pubkey=r.toPublicKey(),u.sign().toString()},u.createProofOfOwnership=function(t,e){a.checkArgument(t instanceof o,"Invalid private key"),a.checkArgument("string"==typeof e,"Challenge must be a string");var r=u.fromPrivateKey(t),i=(new Date).toISOString(),n=e+":"+i+":"+r;return{type:"EcdsaSecp256k1Signature2019",created:i,verificationMethod:r+"#keys-1",proofPurpose:"authentication",challenge:e,jws:u.signMessage(n,t)}},u.verifyProofOfOwnership=function(t,e){try{a.checkArgument(t&&"object"==typeof t,"Invalid proof object"),a.checkArgument("string"==typeof e,"DID must be a string");var r=t.challenge+":"+t.created+":"+e;return u.verifyOwnership(e,t.jws,r)}catch(t){return!1}},u.createDIDURL=function(t,e){return a.checkArgument("string"==typeof t,"DID must be a string"),a.checkArgument("string"==typeof e,"Fragment must be a string"),t+"#"+e},u.generateTestDID=function(t){t=t||{};var e=new o,r=u.fromPrivateKey(e,t),i=u.createDocument(r,t);return{did:r,privateKey:e.toWIF(),publicKey:e.toPublicKey().toString("hex"),document:i}},t.exports=u}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=r(90),o=i.PrivateKey,s=i.crypto.Hash,a=i.crypto.ECDSA,u=(i.crypto.Signature,i.util.preconditions);r(2);function c(t,e){return this instanceof c?("string"==typeof t&&(t=o.fromWIF(t)),u.checkArgument(t instanceof o,"Invalid private key"),this.privateKey=t,this.publicKey=t.toPublicKey(),this.options=e||{},this.did=n.fromPrivateKey(t,this.options),this):new c(t,e)}c._canonicalizeJSON=function(t){return JSON.stringify(t,Object.keys(t).sort())},c._hashCredential=function(t){var r=c._canonicalizeJSON(t);return s.sha256(e.from(r,"utf8"))},c.prototype.createCredential=function(t,e){e=e||{},u.checkArgument(t&&"object"==typeof t,"Invalid credential subject");var r=(new Date).toISOString(),i={"@context":["https://www.w3.org/2018/credentials/v1"],id:e.id||"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential"],issuer:this.did,issuanceDate:r,credentialSubject:t};return e.type&&(Array.isArray(e.type)?i.type=i.type.concat(e.type):i.type.push(e.type)),e.context&&(Array.isArray(e.context)?i["@context"]=i["@context"].concat(e.context):i["@context"].push(e.context)),e.expirationDate&&(i.expirationDate=e.expirationDate),e.termsOfUse&&(i.termsOfUse=e.termsOfUse),e.evidence&&(i.evidence=e.evidence),e.refreshService&&(i.refreshService=e.refreshService),i},c.prototype.signCredential=function(t,e){e=e||{},u.checkArgument(t&&"object"==typeof t,"Invalid credential");var r=JSON.parse(JSON.stringify(t));delete r.proof;var i=c._hashCredential(r),n=new a;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,s=this._createJWSSignature(i,o),h={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:e.proofPurpose||"assertionMethod",jws:s};e.challenge&&(h.challenge=e.challenge),e.domain&&(h.domain=e.domain);var f=JSON.parse(JSON.stringify(r));return f.proof=h,f.rootHash=i.toString("hex"),f},c.prototype._createJWSSignature=function(t,r){var i=e.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");t.toString("base64url");return i+".."+r.toDER().toString("base64url")},c.prototype.createEmailCredential=function(t,r){r=r||{},u.checkArgument("string"==typeof t&&t.includes("@"),"Invalid email address");var i={id:r.subjectId||"did:smartledger:"+s.sha256(e.from(t)).toString("hex"),email:t,verified:!0,verificationMethod:"email_verification",verificationTimestamp:(new Date).toISOString()},n={type:"EmailVerifiedCredential",context:"https://smartledger.technology/contexts/email/v1",...r},o=this.createCredential(i,n);return this.signCredential(o,r)},c.prototype.createAgeCredential=function(t,r,i){i=i||{},u.checkArgument("number"==typeof t&&t>0,"Invalid age");var n={id:i.subjectId||"urn:uuid:"+this._generateUUID(),ageOver:t,verified:!0,verificationMethod:"age_verification"};r&&(n.birthDateHash=s.sha256(e.from(r.toISOString())).toString("hex"));var o={type:"AgeVerifiedCredential",context:"https://smartledger.technology/contexts/age/v1",...i},a=this.createCredential(n,o);return this.signCredential(a,i)},c.prototype.createKYCCredential=function(t,r){r=r||{},u.checkArgument(t&&"object"==typeof t,"Invalid KYC data");var i={id:r.subjectId||"urn:uuid:"+this._generateUUID(),kycLevel:t.level||"basic",verified:!0,verificationMethod:"kyc_verification",verificationTimestamp:(new Date).toISOString(),verifyingAuthority:t.authority||this.did};t.firstName&&(i.firstNameHash=s.sha256(e.from(t.firstName)).toString("hex")),t.lastName&&(i.lastNameHash=s.sha256(e.from(t.lastName)).toString("hex")),t.ssn&&(i.ssnHash=s.sha256(e.from(t.ssn)).toString("hex"));var n={type:"KYCVerifiedCredential",context:"https://smartledger.technology/contexts/kyc/v1",...r},o=this.createCredential(i,n);return this.signCredential(o,r)},c.prototype.createOrganizationCredential=function(t,r){r=r||{},u.checkArgument(t&&"object"==typeof t,"Invalid organization data");var i={id:r.subjectId||"did:smartledger:org:"+s.sha256(e.from(t.name||"")).toString("hex"),name:t.name,type:t.type||"Organization",verified:!0,verificationMethod:"organization_verification",verificationTimestamp:(new Date).toISOString()};t.taxId&&(i.taxIdHash=s.sha256(e.from(t.taxId)).toString("hex")),t.incorporationState&&(i.incorporationState=t.incorporationState),t.industry&&(i.industry=t.industry);var n={type:"OrganizationCredential",context:"https://smartledger.technology/contexts/organization/v1",...r},o=this.createCredential(i,n);return this.signCredential(o,r)},c.prototype._generateUUID=function(){var t=i.crypto.Random.getRandomBuffer(16);t[6]=15&t[6]|64,t[8]=63&t[8]|128;var e=t.toString("hex");return[e.substring(0,8),e.substring(8,12),e.substring(12,16),e.substring(16,20),e.substring(20,32)].join("-")},c.prototype.createPresentation=function(t,e){e=e||{},u.checkArgument(Array.isArray(t),"Credentials must be an array");var r={"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],id:e.id||"urn:uuid:"+this._generateUUID(),holder:this.did,verifiableCredential:t};e.context&&(Array.isArray(e.context)?r["@context"]=r["@context"].concat(e.context):r["@context"].push(e.context));var i=c._hashCredential(r),n=new a;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,s=this._createJWSSignature(i,o),h={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:"authentication",jws:s};return e.challenge&&(h.challenge=e.challenge),e.domain&&(h.domain=e.domain),r.proof=h,r},c.prototype.getIssuerInfo=function(){return{did:this.did,publicKey:this.publicKey.toString("hex"),verificationMethod:this.did+"#keys-1"}},t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){var i=r(155);t.exports=i("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e,r){"use strict";var i=e;function n(t){return 1===t.length?"0"+t:t}function o(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}i.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),o=n>>8,s=255&n;o?r.push(o,s):r.push(s)}return r},i.zero2=n,i.toHex=o,i.encode=function(t,e){return"hex"===e?o(t):t}},function(t,e,r){"use strict";var i=e;i.base=r(50),i.short=r(158),i.mont=r(159),i.edwards=r(160)},function(t,e,r){"use strict";var i=r(19).rotr32;function n(t,e,r){return t&e^~t&r}function o(t,e,r){return t&e^t&r^e&r}function s(t,e,r){return t^e^r}e.ft_1=function(t,e,r,i){return 0===t?n(e,r,i):1===t||3===t?s(e,r,i):2===t?o(e,r,i):void 0},e.ch32=n,e.maj32=o,e.p32=s,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},function(t,e,r){"use strict";var i=r(19),n=r(35),o=r(95),s=r(14),a=i.sum32,u=i.sum32_4,c=i.sum32_5,h=o.ch32,f=o.maj32,d=o.s0_256,l=o.s1_256,p=o.g0_256,g=o.g1_256,m=n.BlockHash,y=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}i.inherits(b,m),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=u(g(r[i-2]),r[i-7],p(r[i-15]),r[i-16]);var n=this.h[0],o=this.h[1],m=this.h[2],y=this.h[3],b=this.h[4],v=this.h[5],_=this.h[6],S=this.h[7];for(s(this.k.length===r.length),i=0;i<r.length;i++){var w=c(S,l(b),h(b,v,_),this.k[i],r[i]),I=a(d(n),f(n,o,m));S=_,_=v,v=b,b=a(y,w),y=m,m=o,o=n,n=a(w,I)}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],m),this.h[3]=a(this.h[3],y),this.h[4]=a(this.h[4],b),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],_),this.h[7]=a(this.h[7],S)},b.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){"use strict";var i=r(19),n=r(35),o=r(14),s=i.rotr64_hi,a=i.rotr64_lo,u=i.shr64_hi,c=i.shr64_lo,h=i.sum64,f=i.sum64_hi,d=i.sum64_lo,l=i.sum64_4_hi,p=i.sum64_4_lo,g=i.sum64_5_hi,m=i.sum64_5_lo,y=n.BlockHash,b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;y.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function _(t,e,r,i,n){var o=t&r^~t&n;return o<0&&(o+=4294967296),o}function S(t,e,r,i,n,o){var s=e&i^~e&o;return s<0&&(s+=4294967296),s}function w(t,e,r,i,n){var o=t&r^t&n^r&n;return o<0&&(o+=4294967296),o}function I(t,e,r,i,n,o){var s=e&i^e&o^i&o;return s<0&&(s+=4294967296),s}function A(t,e){var r=s(t,e,28)^s(e,t,2)^s(e,t,7);return r<0&&(r+=4294967296),r}function E(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function O(t,e){var r=s(t,e,14)^s(t,e,18)^s(e,t,9);return r<0&&(r+=4294967296),r}function k(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function P(t,e){var r=s(t,e,1)^s(t,e,8)^u(t,e,7);return r<0&&(r+=4294967296),r}function M(t,e){var r=a(t,e,1)^a(t,e,8)^c(t,e,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=s(t,e,19)^s(e,t,29)^u(t,e,6);return r<0&&(r+=4294967296),r}function x(t,e){var r=a(t,e,19)^a(e,t,29)^c(t,e,6);return r<0&&(r+=4294967296),r}i.inherits(v,y),t.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=T(r[i-4],r[i-3]),o=x(r[i-4],r[i-3]),s=r[i-14],a=r[i-13],u=P(r[i-30],r[i-29]),c=M(r[i-30],r[i-29]),h=r[i-32],f=r[i-31];r[i]=l(n,o,s,a,u,c,h,f),r[i+1]=p(n,o,s,a,u,c,h,f)}},v.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4],c=this.h[5],l=this.h[6],p=this.h[7],y=this.h[8],b=this.h[9],v=this.h[10],P=this.h[11],M=this.h[12],T=this.h[13],x=this.h[14],R=this.h[15];o(this.k.length===r.length);for(var C=0;C<r.length;C+=2){var B=x,N=R,D=O(y,b),L=k(y,b),U=_(y,b,v,P,M),j=S(y,b,v,P,M,T),H=this.k[C],F=this.k[C+1],K=r[C],V=r[C+1],z=g(B,N,D,L,U,j,H,F,K,V),q=m(B,N,D,L,U,j,H,F,K,V);B=A(i,n),N=E(i,n),D=w(i,n,s,a,u),L=I(i,n,s,a,u,c);var G=f(B,N,D,L),Y=d(B,N,D,L);x=M,R=T,M=v,T=P,v=y,P=b,y=f(l,p,z,q),b=d(p,p,z,q),l=u,p=c,u=s,c=a,s=i,a=n,i=f(z,q,G,Y),n=d(z,q,G,Y)}h(this.h,0,i,n),h(this.h,2,s,a),h(this.h,4,u,c),h(this.h,6,l,p),h(this.h,8,y,b),h(this.h,10,v,P),h(this.h,12,M,T),h(this.h,14,x,R)},v.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){t.exports=n;var i=r(67).EventEmitter;function n(){i.call(this)}r(3)(n,i),n.Readable=r(37),n.Writable=r(189),n.Duplex=r(190),n.Transform=r(191),n.PassThrough=r(192),n.Stream=n,n.prototype.pipe=function(t,e){var r=this;function n(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",n),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(h(),0===i.listenerCount(this,"error"))throw t}function h(){r.removeListener("data",n),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",h),r.removeListener("close",h),t.removeListener("close",h)}return r.on("error",c),t.on("error",c),r.on("end",h),r.on("close",h),t.on("close",h),t.emit("pipe",r),t}},function(t,e,r){"use strict";(function(e,i){var n=r(52);t.exports=v;var o,s=r(180);v.ReadableState=b;r(67).EventEmitter;var a=function(t,e){return t.listeners(e).length},u=r(100),c=r(68).Buffer,h=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f=Object.create(r(38));f.inherits=r(3);var d=r(181),l=void 0;l=d&&d.debuglog?d.debuglog("stream"):function(){};var p,g=r(182),m=r(101);f.inherits(v,u);var y=["error","close","destroy","pause","resume"];function b(t,e){t=t||{};var i=e instanceof(o=o||r(28));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,s=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new g,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=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=r(70).StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function v(t){if(o=o||r(28),!(this instanceof v))return new v(t);this._readableState=new b(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function _(t,e,r,i,n){var o,s=t._readableState;null===e?(s.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,I(t)}(t,s)):(n||(o=function(t,e){var r;i=e,c.isBuffer(i)||i instanceof h||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var i;return r}(s,e)),o?t.emit("error",o):s.objectMode||e&&e.length>0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),i?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):S(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?S(t,s,e,!1):E(t,s)):S(t,s,e,!1))):i||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(s)}function S(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),E(t,e)}Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),v.prototype.destroy=m.destroy,v.prototype._undestroy=m.undestroy,v.prototype._destroy=function(t,e){this.push(null),e(t)},v.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=c.from(t,e),e=""),r=!0),_(this,t,e,!1,r)},v.prototype.unshift=function(t){return _(this,t,null,!0,!1)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(t){return p||(p=r(70).StringDecoder),this._readableState.decoder=new p(t),this._readableState.encoding=t,this};function w(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(A,t):A(t))}function A(t){l("emit readable"),t.emit("readable"),M(t)}function E(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(O,t,e))}function O(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(l("maybeReadMore read 0"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function k(t){l("readable nexttick read 0"),t.read(0)}function P(t,e){e.reading||(l("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(l("flow",e.flowing);e.flowing&&null!==t.read(););}function T(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;t<e.head.data.length?(i=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):i=t===e.head.data.length?e.shift():r?function(t,e){var r=e.head,i=1,n=r.data;t-=n.length;for(;r=r.next;){var o=r.data,s=t>o.length?o.length:t;if(s===o.length?n+=o:n+=o.slice(0,t),0===(t-=s)){s===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=c.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var o=i.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=o.slice(s));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function x(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function C(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}v.prototype.read=function(t){l("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?x(this):I(this),null;if(0===(t=w(t,e))&&e.ended)return 0===e.length&&x(this),null;var i,n=e.needReadable;return l("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&l("length less than watermark",n=!0),e.ended||e.reading?l("reading or ended",n=!1):n&&(l("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=w(r,e))),null===(i=t>0?T(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&x(this)),null!==i&&this.emit("data",i),i},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?h:v;function c(e,i){l("onunpipe"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,l("cleanup"),t.removeListener("close",y),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",m),t.removeListener("unpipe",c),r.removeListener("end",h),r.removeListener("end",v),r.removeListener("data",g),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function h(){l("onend"),t.end()}o.endEmitted?n.nextTick(u):r.once("end",u),t.on("unpipe",c);var f=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(r);t.on("drain",f);var d=!1;var p=!1;function g(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==C(o.pipes,t))&&!d&&(l("false write response, pause",o.awaitDrain),o.awaitDrain++,p=!0),r.pause())}function m(e){l("onerror",e),v(),t.removeListener("error",m),0===a(t,"error")&&t.emit("error",e)}function y(){t.removeListener("finish",b),v()}function b(){l("onfinish"),t.removeListener("close",y),v()}function v(){l("unpipe"),r.unpipe(t)}return r.on("data",g),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",m),t.once("close",y),t.once("finish",b),t.emit("pipe",r),o.flowing||(l("pipe resume"),r.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=C(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},v.prototype.on=function(t,e){var r=u.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&I(this):n.nextTick(k,this))}return r},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var t=this._readableState;return t.flowing||(l("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(P,t,e))}(this,t)),this},v.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this},v.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on("end",(function(){if(l("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){(l("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var o=0;o<y.length;o++)t.on(y[o],this.emit.bind(this,y[o]));return this._read=function(e){l("wrapped _read",e),i&&(i=!1,t.resume())},this},Object.defineProperty(v.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),v._fromList=T}).call(this,r(12),r(11))},function(t,e,r){t.exports=r(67).EventEmitter},function(t,e,r){"use strict";var i=r(52);function n(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(n,this,t)):i.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,i.nextTick(n,r,t)):i.nextTick(n,r,t):e&&e(t)})),this)},undestroy:function(){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(t,e,r){"use strict";t.exports=s;var i=r(28),n=Object.create(r(38));function o(t,e){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,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function s(t){if(!(this instanceof s))return new s(t);i.call(this,t),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",a)}function a(){var t=this;"function"==typeof this._flush?this._flush((function(e,r){u(t,e,r)})):u(this,null,null)}function u(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}n.inherits=r(3),n.inherits(s,i),s.prototype.push=function(t,e){return this._transformState.needTransform=!1,i.prototype.push.call(this,t,e)},s.prototype._transform=function(t,e,r){throw new Error("_transform() is not implemented")},s.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},s.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},s.prototype._destroy=function(t,e){var r=this;i.prototype._destroy.call(this,t,(function(t){e(t),r.emit("close")}))}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i=r(73),n=r(198),o=r(199),s=r(200),a=r(201),u=r(105),c=r(39),h=r(202),f=r(203),d=r(204),l=r(205),p=r(206),g=r(207),m=r(208),y=r(209),b=Function,v=function(t){try{return b('"use strict"; return ('+t+").constructor;")()}catch(t){}},_=r(40),S=r(54),w=function(){throw new c},I=_?function(){try{return w}catch(t){try{return _(arguments,"callee").get}catch(t){return w}}}():w,A=r(212)(),E=r(106),O=r(108),k=r(107),P=r(77),M=r(76),T={},x="undefined"!=typeof Uint8Array&&E?E(Uint8Array):void 0,R={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":A&&E?E([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":n,"%eval%":eval,"%EvalError%":o,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":T,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A&&E?E(E([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&A&&E?E((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&A&&E?E((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A&&E?E(""[Symbol.iterator]()):void 0,"%Symbol%":A?Symbol:void 0,"%SyntaxError%":u,"%ThrowTypeError%":I,"%TypedArray%":x,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":h,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":M,"%Function.prototype.apply%":P,"%Object.defineProperty%":S,"%Object.getPrototypeOf%":O,"%Math.abs%":f,"%Math.floor%":d,"%Math.max%":l,"%Math.min%":p,"%Math.pow%":g,"%Math.round%":m,"%Math.sign%":y,"%Reflect.getPrototypeOf%":k};if(E)try{null.error}catch(t){var C=E(E(t));R["%Error.prototype%"]=C}var B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},N=r(41),D=r(216),L=N.call(M,Array.prototype.concat),U=N.call(P,Array.prototype.splice),j=N.call(M,String.prototype.replace),H=N.call(M,String.prototype.slice),F=N.call(M,RegExp.prototype.exec),K=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,V=/\\(\\)?/g,z=function(t){var e=H(t,0,1),r=H(t,-1);if("%"===e&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new u("invalid intrinsic syntax, expected opening `%`");var i=[];return j(t,K,(function(t,e,r,n){i[i.length]=r?j(n,V,"$1"):e||t})),i},q=function(t,e){var r,i=t;if(D(B,i)&&(i="%"+(r=B[i])[0]+"%"),D(R,i)){var n=R[i];if(n===T&&(n=function t(e){var r;if("%AsyncFunction%"===e)r=v("async function () {}");else if("%GeneratorFunction%"===e)r=v("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=v("async function* () {}");else if("%AsyncGenerator%"===e){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if("%AsyncIteratorPrototype%"===e){var n=t("%AsyncGenerator%");n&&E&&(r=E(n.prototype))}return R[e]=r,r}(i)),void 0===n&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:n}}throw new u("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===F(/^%?[^%]*%?$/,t))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=z(t),i=r.length>0?r[0]:"",n=q("%"+i+"%",e),o=n.name,s=n.value,a=!1,h=n.alias;h&&(i=h[0],U(r,L([0,1],h)));for(var f=1,d=!0;f<r.length;f+=1){var l=r[f],p=H(l,0,1),g=H(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===g||"'"===g||"`"===g)&&p!==g)throw new u("property names with quotes must have matching quotes");if("constructor"!==l&&d||(a=!0),D(R,o="%"+(i+="."+l)+"%"))s=R[o];else if(null!=s){if(!(l in s)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(_&&f+1>=r.length){var m=_(s,l);s=(d=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:s[l]}else d=D(s,l),s=s[l];d&&!a&&(R[o]=s)}}return s}},function(t,e,r){"use strict";t.exports=SyntaxError},function(t,e,r){"use strict";var i=r(107),n=r(108),o=r(213);t.exports=i?function(t){return i(t)}:n?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return n(t)}:o?function(t){return o(t)}:null},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(t,e,r){"use strict";var i=r(73);t.exports=i.getPrototypeOf||null},function(t,e,r){"use strict";var i=r(41),n=r(77),o=r(76),s=r(215);t.exports=s||i.call(o,n)},function(t,e,r){"use strict";var i=r(32),n=r(33),o=r(1).Buffer,s=[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],a=new Array(64);function u(){this.init(),this._w=a,n.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function h(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function d(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}i(u,n),u.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},u.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,n=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,p=0|this._f,g=0|this._g,m=0|this._h,y=0;y<16;++y)r[y]=t.readInt32BE(4*y);for(;y<64;++y)r[y]=0|(((e=r[y-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[y-7]+l(r[y-15])+r[y-16];for(var b=0;b<64;++b){var v=m+d(u)+c(u,p,g)+s[b]+r[b]|0,_=f(i)+h(i,n,o)|0;m=g,g=p,p=u,u=a+v|0,a=o,o=n,n=i,i=v+_|0}this._a=i+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=g+this._g|0,this._h=m+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,r){"use strict";var i=r(32),n=r(33),o=r(1).Buffer,s=[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],a=new Array(160);function u(){this.init(),this._w=a,n.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function h(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function d(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function m(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0<e>>>0?1:0}i(u,n),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,o=0|this._dh,a=0|this._eh,u=0|this._fh,b=0|this._gh,v=0|this._hh,_=0|this._al,S=0|this._bl,w=0|this._cl,I=0|this._dl,A=0|this._el,E=0|this._fl,O=0|this._gl,k=0|this._hl,P=0;P<32;P+=2)e[P]=t.readInt32BE(4*P),e[P+1]=t.readInt32BE(4*P+4);for(;P<160;P+=2){var M=e[P-30],T=e[P-30+1],x=l(M,T),R=p(T,M),C=g(M=e[P-4],T=e[P-4+1]),B=m(T,M),N=e[P-14],D=e[P-14+1],L=e[P-32],U=e[P-32+1],j=R+D|0,H=x+N+y(j,R)|0;H=(H=H+C+y(j=j+B|0,B)|0)+L+y(j=j+U|0,U)|0,e[P]=H,e[P+1]=j}for(var F=0;F<160;F+=2){H=e[F],j=e[F+1];var K=h(r,i,n),V=h(_,S,w),z=f(r,_),q=f(_,r),G=d(a,A),Y=d(A,a),W=s[F],X=s[F+1],Z=c(a,u,b),J=c(A,E,O),$=k+Y|0,Q=v+G+y($,k)|0;Q=(Q=(Q=Q+Z+y($=$+J|0,J)|0)+W+y($=$+X|0,X)|0)+H+y($=$+j|0,j)|0;var tt=q+V|0,et=z+K+y(tt,q)|0;v=b,k=O,b=u,O=E,u=a,E=A,a=o+Q+y(A=I+$|0,I)|0,o=n,I=w,n=i,w=S,i=r,S=_,r=Q+et+y(_=$+tt|0,$)|0}this._al=this._al+_|0,this._bl=this._bl+S|0,this._cl=this._cl+w|0,this._dl=this._dl+I|0,this._el=this._el+A|0,this._fl=this._fl+E|0,this._gl=this._gl+O|0,this._hl=this._hl+k|0,this._ah=this._ah+r+y(this._al,_)|0,this._bh=this._bh+i+y(this._bl,S)|0,this._ch=this._ch+n+y(this._cl,w)|0,this._dh=this._dh+o+y(this._dl,I)|0,this._eh=this._eh+a+y(this._el,A)|0,this._fh=this._fh+u+y(this._fl,E)|0,this._gh=this._gh+b+y(this._gl,O)|0,this._hh=this._hh+v+y(this._hl,k)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,r){"use strict";var i=r(3),n=r(234),o=r(24),s=r(1).Buffer,a=r(113),u=r(71),c=r(78),h=s.alloc(128);function f(t,e){o.call(this,"digest"),"string"==typeof e&&(e=s.from(e));var r="sha512"===t||"sha384"===t?128:64;(this._alg=t,this._key=e,e.length>r)?e=("rmd160"===t?new u:c(t)).update(e).digest():e.length<r&&(e=s.concat([e,h],r));for(var i=this._ipad=s.allocUnsafe(r),n=this._opad=s.allocUnsafe(r),a=0;a<r;a++)i[a]=54^e[a],n[a]=92^e[a];this._hash="rmd160"===t?new u:c(t),this._hash.update(i)}i(f,o),f.prototype._update=function(t){this._hash.update(t)},f.prototype._final=function(){var t=this._hash.digest();return("rmd160"===this._alg?new u:c(this._alg)).update(this._opad).update(t).digest()},t.exports=function(t,e){return"rmd160"===(t=t.toLowerCase())||"ripemd160"===t?new f("rmd160",e):"md5"===t?new n(a,e):new f(t,e)}},function(t,e,r){var i=r(66);t.exports=function(t){return(new i).update(t).digest()}},function(t){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},function(t,e,r){"use strict";e.pbkdf2=r(236),e.pbkdf2Sync=r(118)},function(t,e,r){"use strict";var i=isFinite,n=Math.pow(2,30)-1;t.exports=function(t,e){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0||!i(t))throw new TypeError("Bad iterations");if("number"!=typeof e)throw new TypeError("Key length not a number");if(e<0||e>n||e!=e)throw new TypeError("Bad key length")}},function(t,e,r){"use strict";(function(e,r){var i;if(e.process&&e.process.browser)i="utf-8";else if(e.process&&e.process.version){i=parseInt(r.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else i="utf-8";t.exports=i}).call(this,r(12),r(11))},function(t,e,r){"use strict";var i=r(113),n=r(71),o=r(78),s=r(1).Buffer,a=r(116),u=r(117),c=r(119),h=s.alloc(128),f={__proto__:null,md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,"sha512-256":32,ripemd160:20,rmd160:20},d={__proto__:null,"sha-1":"sha1","sha-224":"sha224","sha-256":"sha256","sha-384":"sha384","sha-512":"sha512","ripemd-160":"ripemd160"};function l(t){return(new n).update(t).digest()}function p(t,e,r){var n=function(t){return"rmd160"===t||"ripemd160"===t?l:"md5"===t?i:function(e){return o(t).update(e).digest()}}(t),a="sha512"===t||"sha384"===t?128:64;e.length>a?e=n(e):e.length<a&&(e=s.concat([e,h],a));for(var u=s.allocUnsafe(a+f[t]),c=s.allocUnsafe(a+f[t]),d=0;d<a;d++)u[d]=54^e[d],c[d]=92^e[d];var p=s.allocUnsafe(a+r+4);u.copy(p,0,0,a),this.ipad1=p,this.ipad2=u,this.opad=c,this.alg=t,this.blocksize=a,this.hash=n,this.size=f[t]}p.prototype.run=function(t,e){return t.copy(e,this.blocksize),this.hash(e).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(t,e,r,i,n){a(r,i),t=c(t,u,"Password"),e=c(e,u,"Salt");var o=(n||"sha1").toLowerCase(),h=d[o]||o,l=f[h];if("number"!=typeof l||!l)throw new TypeError("Digest algorithm not supported: "+n);var g=new p(h,t,e.length),m=s.allocUnsafe(i),y=s.allocUnsafe(e.length+4);e.copy(y,0,0,e.length);for(var b=0,v=l,_=Math.ceil(i/v),S=1;S<=_;S++){y.writeUInt32BE(S,e.length);for(var w=g.run(y,g.ipad1),I=w,A=1;A<r;A++){I=g.run(I,g.ipad2);for(var E=0;E<v;E++)w[E]^=I[E]}w.copy(m,b),b+=v}return m}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(53),o="undefined"!=typeof Uint8Array,s=o&&"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView;t.exports=function(t,e,r){if("string"==typeof t||i.isBuffer(t)||o&&t instanceof Uint8Array||s&&s(t))return n(t,e);throw new TypeError(r+" must be a string, a Buffer, a Uint8Array, or a DataView")}},function(t,e,r){"use strict";e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},e.ip=function(t,e,r,i){for(var n=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>>a+s&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[i+0]=n>>>0,r[i+1]=o>>>0},e.rip=function(t,e,r,i){for(var n=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)n<<=1,n|=e>>>a+s&1,n<<=1,n|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[i+0]=n>>>0,r[i+1]=o>>>0},e.pc1=function(t,e,r,i){for(var n=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>a+s&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+s&1}for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[i+0]=n>>>0,r[i+1]=o>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var i=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,r,n){for(var o=0,s=0,a=i.length>>>1,u=0;u<a;u++)o<<=1,o|=t>>>i[u]&1;for(u=a;u<i.length;u++)s<<=1,s|=e>>>i[u]&1;r[n+0]=o>>>0,r[n+1]=s>>>0},e.expand=function(t,e,r){var i=0,n=0;i=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)i<<=6,i|=t>>>o&63;for(o=11;o>=3;o-=4)n|=t>>>o&63,n<<=6;n|=(31&t)<<1|t>>>31,e[r+0]=i>>>0,e[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var r=0,i=0;i<4;i++){r<<=4,r|=n[64*i+(t>>>18-6*i&63)]}for(i=0;i<4;i++){r<<=4,r|=n[256+64*i+(e>>>18-6*i&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,r=0;r<o.length;r++)e<<=1,e|=t>>>o[r]&1;return e>>>0},e.padSplit=function(t,e,r){for(var i=t.toString(2);i.length<e;)i="0"+i;for(var n=[],o=0;o<e;o+=r)n.push(i.slice(o,o+r));return n.join(" ")}},function(t,e,r){"use strict";var i=r(14),n=r(3),o=r(120),s=r(79);function a(){this.tmp=new Array(2),this.keys=null}function u(t){s.call(this,t);var e=new a;this._desState=e,this.deriveKeys(e,t.key)}n(u,s),t.exports=u,u.create=function(t){return new u(t)};var c=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];u.prototype.deriveKeys=function(t,e){t.keys=new Array(32),i.equal(e.length,this.blockSize,"Invalid key length");var r=o.readUInt32BE(e,0),n=o.readUInt32BE(e,4);o.pc1(r,n,t.tmp,0),r=t.tmp[0],n=t.tmp[1];for(var s=0;s<t.keys.length;s+=2){var a=c[s>>>1];r=o.r28shl(r,a),n=o.r28shl(n,a),o.pc2(r,n,t.keys,s)}},u.prototype._update=function(t,e,r,i){var n=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,n.tmp,0),s=n.tmp[0],a=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,a,n.tmp,0):this._decrypt(n,s,a,n.tmp,0),s=n.tmp[0],a=n.tmp[1],o.writeUInt32BE(r,s,i),o.writeUInt32BE(r,a,i+4)},u.prototype._pad=function(t,e){if(!1===this.padding)return!1;for(var r=t.length-e,i=e;i<t.length;i++)t[i]=r;return!0},u.prototype._unpad=function(t){if(!1===this.padding)return t;for(var e=t[t.length-1],r=t.length-e;r<t.length;r++)i.equal(t[r],e);return t.slice(0,t.length-e)},u.prototype._encrypt=function(t,e,r,i,n){for(var s=e,a=r,u=0;u<t.keys.length;u+=2){var c=t.keys[u],h=t.keys[u+1];o.expand(a,t.tmp,0),c^=t.tmp[0],h^=t.tmp[1];var f=o.substitute(c,h),d=a;a=(s^o.permute(f))>>>0,s=d}o.rip(a,s,i,n)},u.prototype._decrypt=function(t,e,r,i,n){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],h=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],h^=t.tmp[1];var f=o.substitute(c,h),d=s;s=(a^o.permute(f))>>>0,a=d}o.rip(s,a,i,n)}},function(t,e,r){var i=r(42),n=r(1).Buffer,o=r(123);function s(t){var e=t._cipher.encryptBlockRaw(t._prev);return o(t._prev),e}e.encrypt=function(t,e){var r=Math.ceil(e.length/16),o=t._cache.length;t._cache=n.concat([t._cache,n.allocUnsafe(16*r)]);for(var a=0;a<r;a++){var u=s(t),c=o+16*a;t._cache.writeUInt32BE(u[0],c+0),t._cache.writeUInt32BE(u[1],c+4),t._cache.writeUInt32BE(u[2],c+8),t._cache.writeUInt32BE(u[3],c+12)}var h=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),i(e,h)}},function(t,e){t.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},function(t){t.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}},function(t,e,r){var i=r(55),n=r(1).Buffer,o=r(24),s=r(3),a=r(249),u=r(42),c=r(123);function h(t,e,r,s){o.call(this);var u=n.alloc(4,0);this._cipher=new i.AES(e);var h=this._cipher.encryptBlock(u);this._ghash=new a(h),r=function(t,e,r){if(12===e.length)return t._finID=n.concat([e,n.from([0,0,0,1])]),n.concat([e,n.from([0,0,0,2])]);var i=new a(r),o=e.length,s=o%16;i.update(e),s&&(s=16-s,i.update(n.alloc(s,0))),i.update(n.alloc(8,0));var u=8*o,h=n.alloc(8);h.writeUIntBE(u,0,8),i.update(h),t._finID=i.state;var f=n.from(t._finID);return c(f),f}(this,r,h),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}s(h,o),h.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=n.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},h.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var i=Math.min(t.length,e.length),n=0;n<i;++n)r+=t[n]^e[n];return r}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub()},h.prototype.getAuthTag=function(){if(this._decrypt||!n.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},h.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},h.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length},t.exports=h},function(t,e,r){var i=r(55),n=r(1).Buffer,o=r(24);function s(t,e,r,s){o.call(this),this._cipher=new i.AES(e),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._mode=t}r(3)(s,o),s.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},s.prototype._final=function(){this._cipher.scrub()},t.exports=s},function(t,e,r){var i=r(31);t.exports=b,b.simpleSieve=m,b.fermatTest=y;var n=r(6),o=new n(24),s=new(r(128)),a=new n(1),u=new n(2),c=new n(5),h=(new n(16),new n(8),new n(10)),f=new n(3),d=(new n(7),new n(11)),l=new n(4),p=(new n(12),null);function g(){if(null!==p)return p;var t=[];t[0]=2;for(var e=1,r=3;r<1048576;r+=2){for(var i=Math.ceil(Math.sqrt(r)),n=0;n<e&&t[n]<=i&&r%t[n]!=0;n++);e!==n&&t[n]<=i||(t[e++]=r)}return p=t,t}function m(t){for(var e=g(),r=0;r<e.length;r++)if(0===t.modn(e[r]))return 0===t.cmpn(e[r]);return!0}function y(t){var e=n.mont(t);return 0===u.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new n(2===e||5===e?[140,123]:[140,39]);var r,p;for(e=new n(e);;){for(r=new n(i(Math.ceil(t/8)));r.bitLength()>t;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(h).cmp(f);)r.iadd(l)}else for(;r.mod(o).cmp(d);)r.iadd(l);if(m(p=r.shrn(1))&&m(r)&&y(p)&&y(r)&&s.test(p)&&s.test(r))return r}}},function(t,e,r){var i=r(6),n=r(62);function o(t){this.rand=t||new n.Rand}t.exports=o,o.create=function(t){return new o(t)},o.prototype._randbelow=function(t){var e=t.bitLength(),r=Math.ceil(e/8);do{var n=new i(this.rand.generate(r))}while(n.cmp(t)>=0);return n},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var n=t.bitLength(),o=i.mont(t),s=new i(1).toRed(o);e||(e=Math.max(1,n/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),h=a.toRed(o);e>0;e--){var f=this._randrange(new i(2),a);r&&r(f);var d=f.toRed(o).redPow(c);if(0!==d.cmp(s)&&0!==d.cmp(h)){for(var l=1;l<u;l++){if(0===(d=d.redSqr()).cmp(s))return!1;if(0===d.cmp(h))break}if(l===u)return!1}}return!0},o.prototype.getDivisor=function(t,e){var r=t.bitLength(),n=i.mont(t),o=new i(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var s=t.subn(1),a=0;!s.testn(a);a++);for(var u=t.shrn(a),c=s.toRed(n);e>0;e--){var h=this._randrange(new i(2),s),f=t.gcd(h);if(0!==f.cmpn(1))return f;var d=h.toRed(n).redPow(u);if(0!==d.cmp(o)&&0!==d.cmp(c)){for(var l=1;l<a;l++){if(0===(d=d.redSqr()).cmp(o))return d.fromRed().subn(1).gcd(t);if(0===d.cmp(c))break}if(l===a)return(d=d.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},function(t,e,r){(function(t){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(260).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+t)}function u(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function c(t,e,r,n){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=n,s=c>=49?c-49+10:c>=17?c-17+10:c,i(c>=0&&s<n,"Invalid character"),o+=s}return o}function h(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),"le"===r&&this._initArray(this.toArray(),e,r)))},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s,a=0;if("be"===r)for(n=t.length-1,o=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,s=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=u(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=u(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,h=r;h<a;h+=i)u=c(t,h,h+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=c(t,h,t.length,e),h=0;h<s;h++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){h(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","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],p=[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];o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<n|o)).toString(16);o=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,s--),r=0!==o||s!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],h=p[t];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var g=f.modrn(h).toString(t);r=(f=f.idivn(h)).isZero()?g+r:d[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function g(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<i;c++){for(var h=u>>>26,f=67108863&u,d=Math.min(c,e.length-1),l=Math.max(0,c-t.length+1);l<=d;l++){var p=c-l|0;h+=(s=(n=0|t.words[p])*(o=0|e.words[l])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,n),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},o.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},o.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(e=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var i,n,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],f=8191&h,d=h>>>13,l=0|s[1],p=8191&l,g=l>>>13,m=0|s[2],y=8191&m,b=m>>>13,v=0|s[3],_=8191&v,S=v>>>13,w=0|s[4],I=8191&w,A=w>>>13,E=0|s[5],O=8191&E,k=E>>>13,P=0|s[6],M=8191&P,T=P>>>13,x=0|s[7],R=8191&x,C=x>>>13,B=0|s[8],N=8191&B,D=B>>>13,L=0|s[9],U=8191&L,j=L>>>13,H=0|a[0],F=8191&H,K=H>>>13,V=0|a[1],z=8191&V,q=V>>>13,G=0|a[2],Y=8191&G,W=G>>>13,X=0|a[3],Z=8191&X,J=X>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],ft=8191&ht,dt=ht>>>13,lt=0|a[9],pt=8191&lt,gt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(c+(i=Math.imul(f,F))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(d,F)|0))<<13)|0;c=((o=Math.imul(d,K))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,F),n=(n=Math.imul(p,K))+Math.imul(g,F)|0,o=Math.imul(g,K);var yt=(c+(i=i+Math.imul(f,z)|0)|0)+((8191&(n=(n=n+Math.imul(f,q)|0)+Math.imul(d,z)|0))<<13)|0;c=((o=o+Math.imul(d,q)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,K))+Math.imul(b,F)|0,o=Math.imul(b,K),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,q)|0)+Math.imul(g,z)|0,o=o+Math.imul(g,q)|0;var bt=(c+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,W)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,K))+Math.imul(S,F)|0,o=Math.imul(S,K),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,q)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,q)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,W)|0;var vt=(c+(i=i+Math.imul(f,Z)|0)|0)+((8191&(n=(n=n+Math.imul(f,J)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(I,F),n=(n=Math.imul(I,K))+Math.imul(A,F)|0,o=Math.imul(A,K),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,q)|0)+Math.imul(S,z)|0,o=o+Math.imul(S,q)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,W)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var _t=(c+(i=i+Math.imul(f,Q)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(O,F),n=(n=Math.imul(O,K))+Math.imul(k,F)|0,o=Math.imul(k,K),i=i+Math.imul(I,z)|0,n=(n=n+Math.imul(I,q)|0)+Math.imul(A,z)|0,o=o+Math.imul(A,q)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,W)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0;var St=(c+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(d,rt)|0))<<13)|0;c=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(M,F),n=(n=Math.imul(M,K))+Math.imul(T,F)|0,o=Math.imul(T,K),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,q)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,q)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,W)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,W)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,J)|0)+Math.imul(S,Z)|0,o=o+Math.imul(S,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,it)|0;var wt=(c+(i=i+Math.imul(f,ot)|0)|0)+((8191&(n=(n=n+Math.imul(f,st)|0)+Math.imul(d,ot)|0))<<13)|0;c=((o=o+Math.imul(d,st)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,K))+Math.imul(C,F)|0,o=Math.imul(C,K),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,q)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,q)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,W)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(S,Q)|0,o=o+Math.imul(S,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var It=(c+(i=i+Math.imul(f,ut)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((o=o+Math.imul(d,ct)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,q)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,q)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,W)|0,i=i+Math.imul(O,Z)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,i=i+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0;var At=(c+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,dt)|0)+Math.imul(d,ft)|0))<<13)|0;c=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,F),n=(n=Math.imul(U,K))+Math.imul(j,F)|0,o=Math.imul(j,K),i=i+Math.imul(N,z)|0,n=(n=n+Math.imul(N,q)|0)+Math.imul(D,z)|0,o=o+Math.imul(D,q)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(M,Z)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,dt)|0;var Et=(c+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,gt)|0)+Math.imul(d,pt)|0))<<13)|0;c=((o=o+Math.imul(d,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,z),n=(n=Math.imul(U,q))+Math.imul(j,z)|0,o=Math.imul(j,q),i=i+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(D,Y)|0,o=o+Math.imul(D,W)|0,i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(I,ot)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,ct)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,ct)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,dt)|0;var Ot=(c+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,W))+Math.imul(j,Y)|0,o=Math.imul(j,W),i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,it)|0,i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,i=i+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ct)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ct)|0,i=i+Math.imul(_,ft)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(S,ft)|0,o=o+Math.imul(S,dt)|0;var kt=(c+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,Z),n=(n=Math.imul(U,J))+Math.imul(j,Z)|0,o=Math.imul(j,J),i=i+Math.imul(N,Q)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,i=i+Math.imul(I,ft)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,dt)|0;var Pt=(c+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,gt)|0)+Math.imul(S,pt)|0))<<13)|0;c=((o=o+Math.imul(S,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(j,Q)|0,o=Math.imul(j,tt),i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,o=o+Math.imul(D,it)|0,i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ct)|0,i=i+Math.imul(O,ft)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(k,ft)|0,o=o+Math.imul(k,dt)|0;var Mt=(c+(i=i+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(A,pt)|0))<<13)|0;c=((o=o+Math.imul(A,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(j,rt)|0,o=Math.imul(j,it),i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,ot)|0,o=o+Math.imul(D,st)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,i=i+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,dt)|0;var Tt=(c+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,ot),n=(n=Math.imul(U,st))+Math.imul(j,ot)|0,o=Math.imul(j,st),i=i+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(D,ut)|0,o=o+Math.imul(D,ct)|0,i=i+Math.imul(R,ft)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,dt)|0;var xt=(c+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(T,pt)|0))<<13)|0;c=((o=o+Math.imul(T,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,ut),n=(n=Math.imul(U,ct))+Math.imul(j,ut)|0,o=Math.imul(j,ct),i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(D,ft)|0,o=o+Math.imul(D,dt)|0;var Rt=(c+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,gt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,ft),n=(n=Math.imul(U,dt))+Math.imul(j,ft)|0,o=Math.imul(j,dt);var Ct=(c+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(D,pt)|0))<<13)|0;c=((o=o+Math.imul(D,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(c+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,gt))+Math.imul(j,pt)|0))<<13)|0;return c=((o=Math.imul(j,gt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,u[0]=mt,u[1]=yt,u[2]=bt,u[3]=vt,u[4]=_t,u[5]=St,u[6]=wt,u[7]=It,u[8]=At,u[9]=Et,u[10]=Ot,u[11]=kt,u[12]=Pt,u[13]=Mt,u[14]=Tt,u[15]=xt,u[16]=Rt,u[17]=Ct,u[18]=Bt,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var s=n;n=0;for(var a=67108863&i,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,f=(0|t.words[h])*(0|e.words[c]),d=67108863&f;a=67108863&(d=d+a|0),n+=(s=(s=s+(f/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function b(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=g),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?g(this,t,e):r<1024?y(this,t,e):b(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},v.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s<o;s++)i[s]=e[t[s]],n[s]=r[t[s]]},v.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var s=1;s<n;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),c=Math.sin(2*Math.PI/a),h=0;h<n;h+=a)for(var f=u,d=c,l=0;l<s;l++){var p=r[h+l],g=i[h+l],m=r[h+l+s],y=i[h+l+s],b=f*m-d*y;y=f*y+d*m,m=b,r[h+l]=p+m,i[h+l]=g+y,r[h+l+s]=p-m,i[h+l+s]=g-y,l!==a&&(b=u*f-c*d,d=u*d+c*f,f=b)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},v.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},v.prototype.convert13b=function(t,e,r,n){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<n;++s)r[s]=0;i(0===o),i(0==(-8192&o))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),s=new Array(i),a=new Array(i),u=new Array(i),c=new Array(i),h=new Array(i),f=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(e.words,e.length,c,i),this.transform(s,o,a,u,i,n),this.transform(c,o,h,f,i,n);for(var l=0;l<i;l++){var p=a[l]*h[l]-u[l]*f[l];u[l]=a[l]*f[l]+u[l]*h[l],a[l]=p}return this.conjugate(a,u,i),this.transform(a,u,d,o,i,n),this.conjugate(d,o,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),b(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var r=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,s=(67108863&o)+(67108863&r);r>>=26,r+=o/67108864|0,r+=s>>>26,this.words[n]=67108863&s}return 0!==r&&(this.words[n]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},o.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<r;this.words[e]=u|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},o.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=r;if(n-=s,n=Math.max(0,n),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=n);c--){var f=0|this.words[c];this.words[c]=h<<26-o|f>>>o,h=f&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},o.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var n,o,s=t.length+r;this._expand(s);var a=0;for(n=0;n<t.length;n++){o=(0|this.words[n+r])+a;var u=(0|t.words[n])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&o}for(;n<this.length-r;n++)a=(o=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&o;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(o=-(0|this.words[n])+a)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,u=i.length-n.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=i.clone()._ishlnsubmul(n,1,u);0===h.negative&&(i=h,a&&(a.words[u]=1));for(var f=u-1;f>=0;f--){var d=67108864*(0|i.words[n.length+f])+(0|i.words[n.length+f-1]);for(d=Math.min(d/s|0,67108863),i._ishlnsubmul(n,d,f);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(n,1,f),i.isZero()||(i.negative^=1);a&&(a.words[f]=d)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(r*n+(0|this.words[o]))%t;return e?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*r;this.words[n]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),f=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(h),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(f)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(u)):(r.isub(e),a.isub(n),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var o=n,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new O(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var _={k256:null,p224:null,p192:null,p25519:null};function S(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){S.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function I(){S.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){S.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){S.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function O(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){O.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}S.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},S.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},S.prototype.split=function(t,e){t.iushrn(this.n,0,e)},S.prototype.imulK=function(t){return t.imul(this.k)},n(w,S),w.prototype.split=function(t,e){for(var r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=4194303&n,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,t.words[i-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},w.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(I,S),n(A,S),n(E,S),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(_[t])return _[t];var e;if("k256"===t)e=new w;else if("p224"===t)e=new I;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return _[t]=e,e},O.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},O.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},O.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},O.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},O.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},O.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},O.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},O.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},O.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},O.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},O.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},O.prototype.isqr=function(t){return this.imul(t,t.clone())},O.prototype.sqr=function(t){return this.mul(t,t)},O.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,n),d=this.pow(t,n.addn(1).iushrn(1)),l=this.pow(t,n),p=s;0!==l.cmp(a);){for(var g=l,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m<p);var y=this.pow(f,new o(1).iushln(p-m-1));d=d.redMul(y),f=y.redSqr(),l=l.redMul(f),p=m}return d},O.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},O.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),i=e.length-1;i>=0;i--){for(var c=e.words[i],h=u-1;h>=0;h--){var f=c>>h&1;n!==r[0]&&(n=this.sqr(n)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===i&&0===h)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}u=26}return n},O.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},O.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new k(t)},n(k,O),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(23)(t))},function(t,e,r){var i=r(3),n=r(44).Reporter,o=r(0).Buffer;function s(t,e){n.call(this,e),o.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function a(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return t instanceof a||(t=new a(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=o.byteLength(t);else{if(!o.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}i(s,n),e.DecoderBuffer=s,s.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},s.prototype.restore=function(t){var e=new s(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,n.prototype.restore.call(this,t.reporter),e},s.prototype.isEmpty=function(){return this.offset===this.length},s.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},s.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");var r=new s(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},s.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},e.EncoderBuffer=a,a.prototype.join=function(t,e){return t||(t=new o(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(t,e),e+=r.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):o.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t}},function(t,e,r){var i=e;i._reverse=function(t){var e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);var i=t[r];e[i]=r})),e},i.der=r(266)},function(t,e,r){var i=r(3),n=r(43),o=n.base,s=n.bignum,a=n.constants.der;function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){o.Node.call(this,"der",t)}function h(t,e){var r=t.readUInt8(e);if(t.isError(r))return r;var i=a.tagClass[r>>6],n=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=t.readUInt8(e),t.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:i,primitive:n,tag:r,tagStr:a.tag[r]}}function f(t,e,r){var i=t.readUInt8(r);if(t.isError(i))return i;if(!e&&128===i)return null;if(0==(128&i))return i;var n=127&i;if(n>4)return t.error("length octect is too long");i=0;for(var o=0;o<n;o++){i<<=8;var s=t.readUInt8(r);if(t.isError(s))return s;i|=s}return i}t.exports=u,u.prototype.decode=function(t,e){return t instanceof o.DecoderBuffer||(t=new o.DecoderBuffer(t,e)),this.tree._decode(t,e)},i(c,o.Node),c.prototype._peekTag=function(t,e,r){if(t.isEmpty())return!1;var i=t.save(),n=h(t,'Failed to peek tag: "'+e+'"');return t.isError(n)?n:(t.restore(i),n.tag===e||n.tagStr===e||n.tagStr+"of"===e||r)},c.prototype._decodeTag=function(t,e,r){var i=h(t,'Failed to decode tag of "'+e+'"');if(t.isError(i))return i;var n=f(t,i.primitive,'Failed to get length of "'+e+'"');if(t.isError(n))return n;if(!r&&i.tag!==e&&i.tagStr!==e&&i.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(i.primitive||null!==n)return t.skip(n,'Failed to match body of: "'+e+'"');var o=t.save(),s=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(s)?s:(n=t.offset-o.offset,t.restore(o),t.skip(n,'Failed to match body of: "'+e+'"'))},c.prototype._skipUntilEnd=function(t,e){for(;;){var r=h(t,e);if(t.isError(r))return r;var i,n=f(t,r.primitive,e);if(t.isError(n))return n;if(i=r.primitive||null!==n?t.skip(n):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===r.tagStr)break}},c.prototype._decodeList=function(t,e,r,i){for(var n=[];!t.isEmpty();){var o=this._peekTag(t,"end");if(t.isError(o))return o;var s=r.decode(t,"der",i);if(t.isError(s)&&o)break;n.push(s)}return n},c.prototype._decodeStr=function(t,e){if("bitstr"===e){var r=t.readUInt8();return t.isError(r)?r:{unused:r,data:t.raw()}}if("bmpstr"===e){var i=t.raw();if(i.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var n="",o=0;o<i.length/2;o++)n+=String.fromCharCode(i.readUInt16BE(2*o));return n}if("numstr"===e){var s=t.raw().toString("ascii");return this._isNumstr(s)?s:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var a=t.raw().toString("ascii");return this._isPrintstr(a)?a:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},c.prototype._decodeObjid=function(t,e,r){for(var i,n=[],o=0;!t.isEmpty();){var s=t.readUInt8();o<<=7,o|=127&s,0==(128&s)&&(n.push(o),o=0)}128&s&&n.push(o);var a=n[0]/40|0,u=n[0]%40;if(i=r?n:[a,u].concat(n.slice(1)),e){var c=e[i.join(" ")];void 0===c&&(c=e[i.join(".")]),void 0!==c&&(i=c)}return i},c.prototype._decodeTime=function(t,e){var r=t.raw().toString();if("gentime"===e)var i=0|r.slice(0,4),n=0|r.slice(4,6),o=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),u=0|r.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");i=0|r.slice(0,2),n=0|r.slice(2,4),o=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),u=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,o,s,a,u,0)},c.prototype._decodeNull=function(t){return null},c.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},c.prototype._decodeInt=function(t,e){var r=t.raw(),i=new s(r);return e&&(i=e[i.toString(10)]||i),i},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},function(t,e,r){var i=r(3),n=r(0).Buffer,o=r(43),s=o.base,a=o.constants.der;function u(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new c,this.tree._init(t.body)}function c(t){s.Node.call(this,"der",t)}function h(t){return t<10?"0"+t:t}t.exports=u,u.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},i(c,s.Node),c.prototype._encodeComposite=function(t,e,r,i){var o,s=function(t,e,r,i){var n;"seqof"===t?t="seq":"setof"===t&&(t="set");if(a.tagByName.hasOwnProperty(t))n=a.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return i.error("Unknown tag: "+t);n=t}if(n>=31)return i.error("Multi-octet tag encoding unsupported");e||(n|=32);return n|=a.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(i.length<128)return(o=new n(2))[0]=s,o[1]=i.length,this._createEncoderBuffer([o,i]);for(var u=1,c=i.length;c>=256;c>>=8)u++;(o=new n(2+u))[0]=s,o[1]=128|u;c=1+u;for(var h=i.length;h>0;c--,h>>=8)o[c]=255&h;return this._createEncoderBuffer([o,i])},c.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var r=new n(2*t.length),i=0;i<t.length;i++)r.writeUInt16BE(t.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},c.prototype._encodeObjid=function(t,e,r){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s\.]+/g);for(var i=0;i<t.length;i++)t[i]|=0}else if(Array.isArray(t)){t=t.slice();for(i=0;i<t.length;i++)t[i]|=0}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!r){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}var o=0;for(i=0;i<t.length;i++){var s=t[i];for(o++;s>=128;s>>=7)o++}var a=new n(o),u=a.length-1;for(i=t.length-1;i>=0;i--){s=t[i];for(a[u--]=127&s;(s>>=7)>0;)a[u--]=128|127&s}return this._createEncoderBuffer(a)},c.prototype._encodeTime=function(t,e){var r,i=new Date(t);return"gentime"===e?r=[h(i.getFullYear()),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[h(i.getFullYear()%100),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!n.isBuffer(t)){var r=t.toArray();!t.sign&&128&r[0]&&r.unshift(0),t=new n(r)}if(n.isBuffer(t)){var i=t.length;0===t.length&&i++;var o=new n(i);return t.copy(o),0===t.length&&(o[0]=0),this._createEncoderBuffer(o)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);i=1;for(var s=t;s>=256;s>>=8)i++;for(s=(o=new Array(i)).length-1;s>=0;s--)o[s]=255&t,t>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new n(o))},c.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},c.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},c.prototype._skipDefault=function(t,e,r){var i,n=this._baseState;if(null===n.default)return!1;var o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i<o.length;i++)if(o[i]!==n.defaultBuffer[i])return!1;return!0}},function(t){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},function(t,e,r){var i=r(36),n=r(1).Buffer;function o(t){var e=n.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var r,s=n.alloc(0),a=0;s.length<e;)r=o(a++),s=n.concat([s,i("sha1").update(t).update(r).digest()]);return s.slice(0,e)}},function(t,e){t.exports=function(t,e){for(var r=t.length,i=-1;++i<r;)t[i]^=e[i];return t}},function(t,e,r){var i=r(6),n=r(1).Buffer;t.exports=function(t,e){return n.from(t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed().toArray())}},function(t,e,r){"use strict";(function(e){var i=r(34),n=r(25),o=r(21),s=r(9),a=r(84),u=r(20),c=r(8),h=r(29),f=r(4),d=r(2),l=r(16),p=r(0),g=r(10),m=function t(r){return this instanceof t?(this.chunks=[],e.isBuffer(r)?t.fromBuffer(r):r instanceof i?t.fromAddress(r):r instanceof t?t.fromBuffer(r.toBuffer()):d.isString(r)?t.fromString(r):void(d.isObject(r)&&d.isArray(r.chunks)&&this.set(r))):new t(r)};m.prototype.set=function(t){return f.checkArgument(d.isObject(t)),f.checkArgument(d.isArray(t.chunks)),this.chunks=t.chunks,this},m.fromBuffer=function(t){var e=new m;e.chunks=[];for(var r=new n(t);!r.finished();)try{var i,o,s=r.readUInt8();s>0&&s<a.OP_PUSHDATA1?(i=s,e.chunks.push({buf:r.read(i),len:i,opcodenum:s})):s===a.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):s===a.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):s===a.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):e.chunks.push({opcodenum:s})}catch(e){if(e instanceof RangeError)throw new l.Script.InvalidBuffer(t.toString("hex"));throw e}return e},m.prototype.toBuffer=function(){for(var t=new o,e=0;e<this.chunks.length;e++){var r=this.chunks[e],i=r.opcodenum;t.writeUInt8(r.opcodenum),r.buf&&(i<a.OP_PUSHDATA1?t.write(r.buf):i===a.OP_PUSHDATA1?(t.writeUInt8(r.len),t.write(r.buf)):i===a.OP_PUSHDATA2?(t.writeUInt16LE(r.len),t.write(r.buf)):i===a.OP_PUSHDATA4&&(t.writeUInt32LE(r.len),t.write(r.buf)))}return t.concat()},m.fromASM=function(t){var r=new m;r.chunks=[];for(var i=t.split(" "),n=0;n<i.length;){var o=i[n],s=a(o).toNumber();if("0"===o)s=0,r.chunks.push({opcodenum:s}),n+=1;else if("-1"===o)s=a.OP_1NEGATE,r.chunks.push({opcodenum:s}),n+=1;else if(d.isUndefined(s)){var u=e.from(i[n],"hex");if(u.toString("hex")!==i[n])throw new Error("invalid hex string in script");var c=u.length;c>=0&&c<a.OP_PUSHDATA1?s=c:c<Math.pow(2,8)?s=a.OP_PUSHDATA1:c<Math.pow(2,16)?s=a.OP_PUSHDATA2:c<Math.pow(2,32)&&(s=a.OP_PUSHDATA4),r.chunks.push({buf:u,len:u.length,opcodenum:s}),n+=1}else r.chunks.push({opcodenum:s}),n+=1}return r},m.fromHex=function(t){return new m(p.Buffer.from(t,"hex"))},m.fromString=function(t){if(g.isHexa(t)||0===t.length)return new m(p.Buffer.from(t,"hex"));var r=new m;r.chunks=[];for(var i=t.split(" "),n=0;n<i.length;){var o=i[n],s=a(o).toNumber();if(d.isUndefined(s)){if(!((s=parseInt(o))>0&&s<a.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(t));r.chunks.push({buf:e.from(i[n+1].slice(2),"hex"),len:s,opcodenum:s}),n+=2}else if(s===a.OP_PUSHDATA1||s===a.OP_PUSHDATA2||s===a.OP_PUSHDATA4){if("0x"!==i[n+2].slice(0,2))throw new Error("Pushdata data must start with 0x");r.chunks.push({buf:e.from(i[n+2].slice(2),"hex"),len:parseInt(i[n+1]),opcodenum:s}),n+=3}else r.chunks.push({opcodenum:s}),n+=1}return r},m.prototype._chunkToString=function(t,e){var r=t.opcodenum,i="asm"===e,n="";if(t.buf)i||r!==a.OP_PUSHDATA1&&r!==a.OP_PUSHDATA2&&r!==a.OP_PUSHDATA4||(n=n+" "+a(r).toString()),t.len>0&&(n=i?n+" "+t.buf.toString("hex"):n+" "+t.len+" 0x"+t.buf.toString("hex"));else if(void 0!==a.reverseMap[r])i?0===r?n+=" 0":79===r?n+=" -1":n=n+" "+a(r).toString():n=n+" "+a(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),n=i?n+" "+o:n+" 0x"+o}return n},m.prototype.toASM=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r,"asm")}return t.substr(1)},m.prototype.toString=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r)}return t.substr(1)},m.prototype.toHex=function(){return this.toBuffer().toString("hex")},m.prototype.inspect=function(){return"<Script: "+this.toString()+">"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var t=this.chunks[0].buf,e=this.chunks[1].buf;if(t&&t.length&&48===t[0]&&e&&e.length){var r=e[0];if((4===r||6===r||7===r)&&65===e.length)return!0;if((3===r||2===r)&&33===e.length)return!0}}return!1},m.prototype.getPublicKey=function(){return f.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return f.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var t=this.chunks[0].buf,e=t[0],r=!1;if((4!==e&&6!==e&&7!==e||65!==t.length)&&(3!==e&&2!==e||33!==t.length)||(r=!0),r)return u.isValid(t)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var t=this.chunks[0].buf;if(t&&t.length&&48===t[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var t=this.toBuffer();return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[t.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var t,e=this.chunks[this.chunks.length-1].buf;if(!e)return!1;try{t=m.fromBuffer(e)}catch(t){if(t instanceof l.Script.InvalidBuffer)return!1;throw t}return t.classify()!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every((function(t){return t.buf&&e.isBuffer(t.buf)}))&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every((function(t){return t.buf&&e.isBuffer(t.buf)&&c.isTxDER(t.buf)}))},m.prototype.isDataOut=function(){if(!(this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN))return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isPushOnly()},m.prototype.isSafeDataOut=function(){if(this.chunks.length<2)return!1;if(this.chunks[0].opcodenum!==a.OP_FALSE)return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isDataOut()},m.prototype.getData=function(){if(this.isSafeDataOut())return this.chunks.slice(2).map(t=>t.buf);if(this.isDataOut()||this.isScriptHashOut())return d.isUndefined(this.chunks[1])?e.alloc(0):e.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return e.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return d.every(this.chunks,(function(t){return t.opcodenum<=a.OP_16||t.opcodenum===a.OP_PUSHDATA1||t.opcodenum===a.OP_PUSHDATA2||t.opcodenum===a.OP_PUSHDATA4}))},(m.types={}).UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.types.SAFE_DATA_OUT="Safe data push",m.OP_RETURN_STANDARD_SIZE=220,m.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var t=this.classifyOutput();return t!==m.types.UNKNOWN?t:this.classifyInput()},(m.outputIdentifiers={}).PUBKEY_OUT=m.prototype.isPublicKeyOut,m.outputIdentifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.outputIdentifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.outputIdentifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.outputIdentifiers.DATA_OUT=m.prototype.isDataOut,m.outputIdentifiers.SAFE_DATA_OUT=m.prototype.isSafeDataOut,m.prototype.classifyOutput=function(){for(var t in m.outputIdentifiers)if(m.outputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},(m.inputIdentifiers={}).PUBKEY_IN=m.prototype.isPublicKeyIn,m.inputIdentifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.inputIdentifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.inputIdentifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.prototype.classifyInput=function(){for(var t in m.inputIdentifiers)if(m.inputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(t){return this._addByType(t,!0),this},m.prototype.equals=function(t){if(f.checkState(t instanceof m,"Must provide another script"),this.chunks.length!==t.chunks.length)return!1;var r;for(r=0;r<this.chunks.length;r++){if(e.isBuffer(this.chunks[r].buf)&&!e.isBuffer(t.chunks[r].buf))return!1;if(e.isBuffer(this.chunks[r].buf)&&!this.chunks[r].buf.equals(t.chunks[r].buf))return!1;if(this.chunks[r].opcodenum!==t.chunks[r].opcodenum)return!1}return!0},m.prototype.add=function(t){return this._addByType(t,!1),this},m.prototype._addByType=function(t,r){if("string"==typeof t)this._addOpcode(t,r);else if("number"==typeof t)this._addOpcode(t,r);else if(t instanceof a)this._addOpcode(t,r);else if(e.isBuffer(t))this._addBuffer(t,r);else if(t instanceof m)this.chunks=this.chunks.concat(t.chunks);else{if("object"!=typeof t)throw new Error("Invalid script chunk");this._insertAtPosition(t,r)}},m.prototype._insertAtPosition=function(t,e){e?this.chunks.unshift(t):this.chunks.push(t)},m.prototype._addOpcode=function(t,e){var r;return r="number"==typeof t?t:t instanceof a?t.toNumber():a(t).toNumber(),this._insertAtPosition({opcodenum:r},e),this},m.prototype._addBuffer=function(t,e){var r,i=t.length;if(i>=0&&i<a.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=a.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=a.OP_PUSHDATA2;else{if(!(i<Math.pow(2,32)))throw new Error("You can't push that much data");r=a.OP_PUSHDATA4}return this._insertAtPosition({buf:t,len:i,opcodenum:r},e),this},m.prototype.removeCodeseparators=function(){for(var t=[],e=0;e<this.chunks.length;e++)this.chunks[e].opcodenum!==a.OP_CODESEPARATOR&&t.push(this.chunks[e]);return this.chunks=t,this},m.buildMultisigOut=function(t,e,r){f.checkArgument(e<=t.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new m;i.add(a.smallInt(e));var n=t=d.map(t,u);r.noSorting||(n=t.map(t=>t.toString("hex")).sort().map(t=>new u(t)));for(var o=0;o<n.length;o++){var s=n[o];i.add(s.toBuffer())}return i.add(a.smallInt(t.length)),i.add(a.OP_CHECKMULTISIG),i},m.buildMultisigIn=function(t,r,i,n){f.checkArgument(d.isArray(t)),f.checkArgument(d.isNumber(r)),f.checkArgument(d.isArray(i)),n=n||{};var o=new m;return o.add(a.OP_0),d.each(i,(function(t){f.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o},m.buildP2SHMultisigIn=function(t,r,i,n){f.checkArgument(d.isArray(t)),f.checkArgument(d.isNumber(r)),f.checkArgument(d.isArray(i)),n=n||{};var o=new m;return o.add(a.OP_0),d.each(i,(function(t){f.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o.add((n.cachedMultisig||m.buildMultisigOut(t,r,n)).toBuffer()),o},m.buildPublicKeyHashOut=function(t){f.checkArgument(!d.isUndefined(t)),f.checkArgument(t instanceof u||t instanceof i||d.isString(t)),t instanceof u?t=t.toAddress():d.isString(t)&&(t=new i(t));var e=new m;return e.add(a.OP_DUP).add(a.OP_HASH160).add(t.hashBuffer).add(a.OP_EQUALVERIFY).add(a.OP_CHECKSIG),e._network=t.network,e},m.buildPublicKeyOut=function(t){f.checkArgument(t instanceof u);var e=new m;return e.add(t.toBuffer()).add(a.OP_CHECKSIG),e},m.buildDataOut=function(t,r){f.checkArgument(d.isUndefined(t)||d.isString(t)||d.isArray(t)||e.isBuffer(t));var i=t;d.isArray(i)||(i=[t]);var n=new m;n.add(a.OP_RETURN);for(let t of i)f.checkArgument(d.isUndefined(t)||d.isString(t)||e.isBuffer(t)),d.isString(t)&&(t=e.from(t,r)),d.isUndefined(t)||n.add(t);return n},m.buildSafeDataOut=function(t,e){var r=m.buildDataOut(t,e),i=new m;return i.add(a.OP_FALSE),i.add(r),i},m.buildScriptHashOut=function(t){f.checkArgument(t instanceof m||t instanceof i&&t.isPayToScriptHash());var e=new m;return e.add(a.OP_HASH160).add(t instanceof i?t.hashBuffer:s.sha256ripemd160(t.toBuffer())).add(a.OP_EQUAL),e._network=t._network||t.network,e},m.buildPublicKeyIn=function(t,r){f.checkArgument(t instanceof c||e.isBuffer(t)),f.checkArgument(d.isUndefined(r)||d.isNumber(r)),t instanceof c&&(t=t.toBuffer());var i=new m;return i.add(e.concat([t,e.from([255&(r||c.SIGHASH_ALL)])])),i},m.buildPublicKeyHashIn=function(t,r,i){return f.checkArgument(r instanceof c||e.isBuffer(r)),f.checkArgument(d.isUndefined(i)||d.isNumber(i)),r instanceof c&&(r=r.toBuffer()),(new m).add(e.concat([r,e.from([255&(i||c.SIGHASH_ALL)])])).add(new u(t).toBuffer())},m.empty=function(){return new m},m.prototype.toScriptHashOut=function(){return m.buildScriptHashOut(this)},m.fromAddress=function(t){if((t=i(t)).isPayToScriptHash())return m.buildScriptHashOut(t);if(t.isPayToPublicKeyHash())return m.buildPublicKeyHashOut(t);throw new l.Script.UnrecognizedAddress(t)},m.prototype.getAddressInfo=function(t){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var e=this._getOutputAddressInfo();return e||this._getInputAddressInfo()},m.prototype._getOutputAddressInfo=function(){var t={};if(this.isScriptHashOut())t.hashBuffer=this.getData(),t.type=i.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;t.hashBuffer=this.getData(),t.type=i.PayToPublicKeyHash}return t},m.prototype._getInputAddressInfo=function(){var t={};if(this.isPublicKeyHashIn())t.hashBuffer=s.sha256ripemd160(this.chunks[1].buf),t.type=i.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;t.hashBuffer=s.sha256ripemd160(this.chunks[this.chunks.length-1].buf),t.type=i.PayToScriptHash}return t},m.prototype.toAddress=function(t){var e=this.getAddressInfo();return!!e&&(e.network=h.get(t)||this._network||h.defaultNetwork,new i(e))},m.prototype.findAndDelete=function(t){for(var e=t.toBuffer().toString("hex"),r=0;r<this.chunks.length;r++){e===m({chunks:[this.chunks[r]]}).toBuffer().toString("hex")&&this.chunks.splice(r,1)}return this},m.prototype.checkMinimalPush=function(t){var e=this.chunks[t],r=e.buf,i=e.opcodenum;return!r||(0===r.length?i===a.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?i===a.OP_1+(r[0]-1):1===r.length&&129===r[0]?i===a.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===a.OP_PUSHDATA1:!(r.length<=65535)||i===a.OP_PUSHDATA2)},m.prototype._decodeOP_N=function(t){if(t===a.OP_0)return 0;if(t>=a.OP_1&&t<=a.OP_16)return t-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(t))},m.prototype.getSignatureOperationsCount=function(t){t=!!d.isUndefined(t)||t;var e=this,r=0,i=a.OP_INVALIDOPCODE;return d.each(e.chunks,(function(n){var o=n.opcodenum;o===a.OP_CHECKSIG||o===a.OP_CHECKSIGVERIFY?r++:o!==a.OP_CHECKMULTISIG&&o!==a.OP_CHECKMULTISIGVERIFY||(t&&i>=a.OP_1&&i<=a.OP_16?r+=e._decodeOP_N(i):r+=20),i=o})),r},t.exports=m}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=Object.prototype.toString;t.exports=function(t){var e=i.call(t),r="[object Arguments]"===e;return r||(r="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===i.call(t.callee)),r}},function(t,e,r){(function(t){var i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},i=0;i<e.length;i++)r[e[i]]=Object.getOwnPropertyDescriptor(t,e[i]);return r},n=/%[sdj%]/g;e.format=function(t){if(!y(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var i=arguments,o=i.length,s=String(t).replace(n,(function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(t){return"[Circular]"}default:return t}})),u=i[r];r<o;u=i[++r])g(u)||!_(u)?s+=" "+u:s+=" "+a(u);return s},e.deprecate=function(r,i){if(void 0!==t&&!0===t.noDeprecation)return r;if(void 0===t)return function(){return e.deprecate(r,i).apply(this,arguments)};var n=!1;return function(){if(!n){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),n=!0}return r.apply(this,arguments)}};var o,s={};function a(t,r){var i={seen:[],stylize:c};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(r)?i.showHidden=r:r&&e._extend(i,r),b(i.showHidden)&&(i.showHidden=!1),b(i.depth)&&(i.depth=2),b(i.colors)&&(i.colors=!1),b(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=u),h(i,t,i.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function h(t,r,i){if(t.customInspect&&r&&I(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(i,t);return y(n)||(n=h(t,n,i)),n}var o=function(t,e){if(b(e))return t.stylize("undefined","undefined");if(y(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(m(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,r);if(o)return o;var s=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),w(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(r);if(0===s.length){if(I(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(w(r))return f(r)}var c,_="",A=!1,E=["{","}"];(l(r)&&(A=!0,E=["[","]"]),I(r))&&(_=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(_=" "+RegExp.prototype.toString.call(r)),S(r)&&(_=" "+Date.prototype.toUTCString.call(r)),w(r)&&(_=" "+f(r)),0!==s.length||A&&0!=r.length?i<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=A?function(t,e,r,i,n){for(var o=[],s=0,a=e.length;s<a;++s)P(e,String(s))?o.push(d(t,e,r,i,String(s),!0)):o.push("");return n.forEach((function(n){n.match(/^\d+$/)||o.push(d(t,e,r,i,n,!0))})),o}(t,r,i,a,s):s.map((function(e){return d(t,r,i,a,e,A)})),t.seen.pop(),function(t,e,r){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,_,E)):E[0]+_+E[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,i,n,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),P(i,n)||(s="["+n+"]"),a||(t.seen.indexOf(u.value)<0?(a=g(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),b(s)){if(o&&n.match(/^\d+$/))return a;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function l(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function g(t){return null===t}function m(t){return"number"==typeof t}function y(t){return"string"==typeof t}function b(t){return void 0===t}function v(t){return _(t)&&"[object RegExp]"===A(t)}function _(t){return"object"==typeof t&&null!==t}function S(t){return _(t)&&"[object Date]"===A(t)}function w(t){return _(t)&&("[object Error]"===A(t)||t instanceof Error)}function I(t){return"function"==typeof t}function A(t){return Object.prototype.toString.call(t)}function E(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(b(o)&&(o=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var i=t.pid;s[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,i,t)}}else s[r]=function(){};return s[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=l,e.isBoolean=p,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=m,e.isString=y,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=b,e.isRegExp=v,e.isObject=_,e.isDate=S,e.isError=w,e.isFunction=I,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(284);var O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var t=new Date,e=[E(t.getHours()),E(t.getMinutes()),E(t.getSeconds())].join(":");return[t.getDate(),O[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",k(),e.format.apply(e,arguments))},e.inherits=r(3),e._extend=function(t,e){if(!e||!_(e))return t;for(var r=Object.keys(e),i=r.length;i--;)t[r[i]]=e[r[i]];return t};var M="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(M&&t[M]){var e;if("function"!=typeof(e=t[M]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,M,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,i=new Promise((function(t,i){e=t,r=i})),n=[],o=0;o<arguments.length;o++)n.push(arguments[o]);n.push((function(t,i){t?r(t):e(i)}));try{t.apply(this,n)}catch(t){r(t)}return i}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),M&&Object.defineProperty(e,M,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=M,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var r=[],i=0;i<arguments.length;i++)r.push(arguments[i]);var n=r.pop();if("function"!=typeof n)throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return n.apply(o,arguments)};e.apply(this,r).then((function(e){t.nextTick(s,null,e)}),(function(e){t.nextTick(T,e,s)}))}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,i(e)),r}}).call(this,r(11))},function(t,e){var r=Object.prototype.toString;function i(t){return"function"==typeof t.constructor?t.constructor.name:null}t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return"GeneratorFunction"===i(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(i(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(e=r.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")}},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(0),s=r(16),a=r(10),u=r(25),c=r(21),h=r(46),f=r(9),d=r(8),l=r(26),p=r(34),g=r(143),m=r(86),y=m.PublicKeyHash,b=m.PublicKey,v=m.MultiSigScriptHash,_=m.MultiSig,S=r(27),w=r(18),I=r(58),A=r(7),E=r(85).SCRIPT_ENABLE_SIGHASH_FORKID;function O(t){if(!(this instanceof O))return new O(t);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,t){if(t instanceof O)return O.shallowCopy(t);if(a.isHexa(t))this.fromString(t);else if(e.isBuffer(t))this.fromBuffer(t);else{if(!i.isObject(t))throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(t)}}else this._newTransaction()}O.DUST_AMOUNT=546,O.FEE_SECURITY_MARGIN=150,O.MAX_MONEY=21e14,O.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,O.NLOCKTIME_MAX_VALUE=4294967295,O.FEE_PER_KB=500,O.CHANGE_OUTPUT_MAX_SIZE=62,O.shallowCopy=function(t){return new O(t.toBuffer())};var k={configurable:!1,enumerable:!0,get:function(){return this._hash=new u(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(O.prototype,"hash",k),Object.defineProperty(O.prototype,"id",k);var P={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(O.prototype,"inputAmount",P),P.get=function(){return this._getOutputAmount()},Object.defineProperty(O.prototype,"outputAmount",P),O.prototype._getHash=function(){return f.sha256sha256(this.toBuffer())},O.prototype.serialize=function(t){return!0===t||t&&t.disableAll?this.uncheckedSerialize():this.checkedSerialize(t)},O.prototype.uncheckedSerialize=O.prototype.toString=function(){return this.toBuffer().toString("hex")},O.prototype.checkedSerialize=function(t){var e=this.getSerializationError(t);if(e)throw e.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",e;return this.uncheckedSerialize()},O.prototype.invalidSatoshis=function(){for(var t=!1,e=0;e<this.outputs.length;e++)this.outputs[e].invalidSatoshis()&&(t=!0);return t},O.prototype.getSerializationError=function(t){if(t=t||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var e,r=this._getUnspentValue();return r<0?t.disableMoreOutputThanInput||(e=new s.Transaction.InvalidOutputAmountSum):e=this._hasFeeError(t,r),e||this._hasDustOutputs(t)||this._isMissingSignatures(t)},O.prototype._hasFeeError=function(t,e){if(!i.isUndefined(this._fee)&&this._fee!==e)return new s.Transaction.FeeError.Different("Unspent value is "+e+" but specified fee is "+this._fee);if(!t.disableLargeFees){var r=Math.floor(O.FEE_SECURITY_MARGIN*this._estimateFee());if(e>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+e)}},O.prototype._missingChange=function(){return!this._changeScript},O.prototype._hasDustOutputs=function(t){var e,r;if(!t.disableDustOutputs)for(e in this.outputs)if((r=this.outputs[e]).satoshis<O.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new s.Transaction.DustOutputs},O.prototype._isMissingSignatures=function(t){if(!t.disableIsFullySigned)return this.isFullySigned()?void 0:new s.Transaction.MissingSignatures},O.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},O.prototype.toBuffer=function(){var t=new c;return this.toBufferWriter(t).toBuffer()},O.prototype.toBufferWriter=function(t){return t.writeInt32LE(this.version),t.writeVarintNum(this.inputs.length),i.each(this.inputs,(function(e){e.toBufferWriter(t)})),t.writeVarintNum(this.outputs.length),i.each(this.outputs,(function(e){e.toBufferWriter(t)})),t.writeUInt32LE(this.nLockTime),t},O.prototype.fromBuffer=function(t){var e=new u(t);return this.fromBufferReader(e)},O.prototype.fromBufferReader=function(t){var e,r,i;for(n.checkArgument(!t.finished(),"No transaction data received"),this.version=t.readInt32LE(),r=t.readVarintNum(),e=0;e<r;e++){var o=m.fromBufferReader(t);this.inputs.push(o)}for(i=t.readVarintNum(),e=0;e<i;e++)this.outputs.push(S.fromBufferReader(t));return this.nLockTime=t.readUInt32LE(),this},O.prototype.toObject=O.prototype.toJSON=function(){var t=[];this.inputs.forEach((function(e){t.push(e.toObject())}));var e=[];this.outputs.forEach((function(t){e.push(t.toObject())}));var r={hash:this.hash,version:this.version,inputs:t,outputs:e,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),i.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),i.isUndefined(this._fee)||(r.fee=this._fee),r},O.prototype.fromObject=function(t){n.checkArgument(i.isObject(t)||t instanceof O);var e,r=this;return e=t instanceof O?e.toObject():t,i.each(e.inputs,(function(t){if(t.output&&t.output.script){var e,i=new w(t.output.script);if(i.isPublicKeyHashOut())e=new m.PublicKeyHash(t);else if(i.isScriptHashOut()&&t.publicKeys&&t.threshold)e=new m.MultiSigScriptHash(t,t.publicKeys,t.threshold,t.signatures);else{if(!i.isPublicKeyOut())throw new s.Transaction.Input.UnsupportedScript(t.output.script);e=new m.PublicKey(t)}r.addInput(e)}else r.uncheckedAddInput(new m(t))})),i.each(e.outputs,(function(t){r.addOutput(new S(t))})),e.changeIndex&&(this._changeIndex=e.changeIndex),e.changeScript&&(this._changeScript=new w(e.changeScript)),e.fee&&(this._fee=e.fee),this.nLockTime=e.nLockTime,this.version=e.version,this._checkConsistency(t),this},O.prototype._checkConsistency=function(t){i.isUndefined(this._changeIndex)||(n.checkState(this._changeScript,"Change script is expected."),n.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),n.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),t&&t.hash&&n.checkState(t.hash===this.hash,"Hash in object does not match transaction hash.")},O.prototype.lockUntilDate=function(t){if(n.checkArgument(t),i.isNumber(t)&&t<O.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;i.isDate(t)&&(t=t.getTime()/1e3);for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},O.prototype.lockUntilBlockHeight=function(t){if(n.checkArgument(i.isNumber(t)),t>=O.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(t<0)throw new s.Transaction.NLockTimeOutOfRange;for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},O.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<O.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},O.prototype.fromString=function(t){this.fromBuffer(o.Buffer.from(t,"hex"))},O.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},O.prototype.from=function(t,e,r){if(i.isArray(t)){var n=this;return i.each(t,(function(t){n.from(t,e,r)})),this}return i.some(this.inputs,(function(e){return e.prevTxId.toString("hex")===t.txId&&e.outputIndex===t.outputIndex}))||(e&&r?this._fromMultisigUtxo(t,e,r):this._fromNonP2SH(t)),this},O.prototype._fromNonP2SH=function(t){var e;e=(t=new g(t)).script.isPublicKeyHashOut()?y:t.script.isPublicKeyOut()?b:m,this.addInput(new e({output:new S({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()}))},O.prototype._fromMultisigUtxo=function(t,e,r){var i;if(n.checkArgument(r<=e.length,"Number of required signatures must be greater than the number of public keys"),(t=new g(t)).script.isMultisigOut())i=_;else{if(!t.script.isScriptHashOut())throw new Error("@TODO");i=v}this.addInput(new i({output:new S({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()},e,r))},O.prototype.addInput=function(t,e,r){if(n.checkArgumentType(t,m,"input"),!t.output&&(i.isUndefined(e)||i.isUndefined(r)))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return t.output||!e||i.isUndefined(r)||(e=e instanceof w?e:new w(e),n.checkArgumentType(r,"number","satoshis"),t.output=new S({script:e,satoshis:r})),this.uncheckedAddInput(t)},O.prototype.uncheckedAddInput=function(t){return n.checkArgumentType(t,m,"input"),this.inputs.push(t),this._inputAmount=void 0,this._updateChangeOutput(),this},O.prototype.hasAllUtxoInfo=function(){return i.every(this.inputs.map((function(t){return!!t.output})))},O.prototype.fee=function(t){return n.checkArgument(i.isNumber(t),"amount must be a number"),this._fee=t,this._updateChangeOutput(),this},O.prototype.feePerKb=function(t){return n.checkArgument(i.isNumber(t),"amount must be a number"),this._feePerKb=t,this._updateChangeOutput(),this},O.prototype.change=function(t){return n.checkArgument(t,"address is required"),this._changeScript=w.fromAddress(t),this._updateChangeOutput(),this},O.prototype.getChangeOutput=function(){return i.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},O.prototype.to=function(t,e){if(i.isArray(t)){var r=this;return i.each(t,(function(t){r.to(t.address,t.satoshis)})),this}return n.checkArgument(a.isNaturalNumber(e),"Amount is expected to be a positive integer"),this.addOutput(new S({script:w(new p(t)),satoshis:e})),this},O.prototype.addData=function(t){return this.addOutput(new S({script:w.buildDataOut(t),satoshis:0})),this},O.prototype.addSafeData=function(t){return this.addOutput(new S({script:w.buildSafeDataOut(t),satoshis:0})),this},O.prototype.addOutput=function(t){return n.checkArgumentType(t,S,"output"),this._addOutput(t),this._updateChangeOutput(),this},O.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},O.prototype._addOutput=function(t){this.outputs.push(t),this._outputAmount=void 0},O.prototype._getOutputAmount=function(){if(i.isUndefined(this._outputAmount)){var t=this;this._outputAmount=0,i.each(this.outputs,(function(e){t._outputAmount+=e.satoshis}))}return this._outputAmount},O.prototype._getInputAmount=function(){if(i.isUndefined(this._inputAmount)){var t=this;this._inputAmount=0,i.each(this.inputs,(function(e){if(i.isUndefined(e.output))throw new s.Transaction.Input.MissingPreviousOutput;t._inputAmount+=e.output.satoshis}))}return this._inputAmount},O.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),i.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:0}));var t=this._getUnspentValue()-this.getFee();this._removeOutput(this._changeIndex),this._changeIndex=void 0,t>=O.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:t})))}},O.prototype.getFee=function(){return this.isCoinbase()?0:i.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},O.prototype._estimateFee=function(){var t=this._estimateSize();return Math.ceil(t/1e3*(this._feePerKb||O.FEE_PER_KB))},O.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},O.prototype._clearSignatures=function(){i.each(this.inputs,(function(t){t.clearSignatures()}))},O.prototype._estimateSize=function(){var t=8;return t+=h(this.inputs.length).toBuffer().length,t+=h(this.outputs.length).toBuffer().length,i.each(this.inputs,(function(e){t+=e._estimateSize()})),i.each(this.outputs,(function(e){t+=e.getSize()})),t},O.prototype._removeOutput=function(t){var e=this.outputs[t];this.outputs=i.without(this.outputs,e),this._outputAmount=void 0},O.prototype.removeOutput=function(t){this._removeOutput(t),this._updateChangeOutput()},O.prototype.sort=function(){return this.sortInputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.prevTxId.compare(e.prevTxId)||t.outputIndex-e.outputIndex})),e})),this.sortOutputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.satoshis-e.satoshis||t.script.toBuffer().compare(e.script.toBuffer())})),e})),this},O.prototype.shuffleOutputs=function(){return this.sortOutputs(i.shuffle)},O.prototype.sortOutputs=function(t){var e=t(this.outputs);return this._newOutputOrder(e)},O.prototype.sortInputs=function(t){return this.inputs=t(this.inputs),this._clearSignatures(),this},O.prototype._newOutputOrder=function(t){if(this.outputs.length!==t.length||0!==i.difference(this.outputs,t).length)throw new s.Transaction.InvalidSorting;if(!i.isUndefined(this._changeIndex)){var e=this.outputs[this._changeIndex];this._changeIndex=t.indexOf(e)}return this.outputs=t,this},O.prototype.removeInput=function(t,e){var r;if((r=!e&&i.isNumber(t)?t:i.findIndex(this.inputs,(function(r){return r.prevTxId.toString("hex")===t&&r.outputIndex===e})))<0||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=i.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()},O.prototype.sign=function(t,e){n.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return i.isArray(t)?(i.each(t,(function(t){r.sign(t,e)})),this):(i.each(this.getSignatures(t,e),(function(t){r.applySignature(t)})),this)},O.prototype.getSignatures=function(t,e){t=new I(t),e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var r=this,n=[],o=f.sha256ripemd160(t.publicKey.toBuffer());return i.each(this.inputs,(function(s,a){i.each(s.getSignatures(r,t,a,e,o),(function(t){n.push(t)}))})),n},O.prototype.applySignature=function(t){return this.inputs[t.inputIndex].addSignature(this,t),this},O.prototype.isFullySigned=function(){return i.each(this.inputs,(function(t){if(t.isFullySigned===m.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")})),i.every(i.map(this.inputs,(function(t){return t.isFullySigned()})))},O.prototype.isValidSignature=function(t){if(this.inputs[t.inputIndex].isValidSignature===m.prototype.isValidSignature)throw new s.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[t.inputIndex].isValidSignature(this,t)},O.prototype.verifySignature=function(t,e,r,i,n,o){return l.verify(this,t,e,r,i,n,o)},O.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var t=new A(0),e=0;e<this.outputs.length;e++){var r=this.outputs[e];if(r.invalidSatoshis())return"transaction txout "+e+" satoshis is invalid";if(r._satoshisBN.gt(new A(O.MAX_MONEY,10)))return"transaction txout "+e+" greater than MAX_MONEY";if((t=t.add(r._satoshisBN)).gt(new A(O.MAX_MONEY)))return"transaction txout "+e+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var n={};for(e=0;e<this.inputs.length;e++){var o=this.inputs[e],s=o.prevTxId+":"+o.outputIndex;if(!i.isUndefined(n[s]))return"transaction input "+e+" duplicate input";n[s]=!0}if(this.isCoinbase()){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(e=0;e<this.inputs.length;e++)if(this.inputs[e].isNull())return"transaction input "+e+" has null input";return!0},O.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},O.prototype.sighash=function(t,e,r,i,n){e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var o=this.inputs[t];if(!o)throw new Error("Input index "+t+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new A(o.output.satoshis)),n=n||E,l.sighash(this,e,t,r,i,n)},t.exports=O}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(2),n=r(4),o=r(10),s=r(18),a=r(34);function u(t){if(!(this instanceof u))return new u(t);n.checkArgument(i.isObject(t),"Must provide an object from where to extract data");var e=t.address?new a(t.address):void 0,r=t.txid?t.txid:t.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",t);var c=i.isUndefined(t.vout)?t.outputIndex:t.vout;if(!i.isNumber(c))throw new Error("Invalid outputIndex, received "+c);n.checkArgument(!i.isUndefined(t.scriptPubKey)||!i.isUndefined(t.script),"Must provide the scriptPubKey for that output!");var h=new s(t.scriptPubKey||t.script);n.checkArgument(!i.isUndefined(t.amount)||!i.isUndefined(t.satoshis),"Must provide an amount for the output");var f=i.isUndefined(t.amount)?t.satoshis:Math.round(1e8*t.amount);n.checkArgument(i.isNumber(f),"Amount must be a number"),o.defineImmutable(this,{address:e,txId:r,outputIndex:c,script:h,satoshis:f})}u.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},u.prototype.toString=function(){return this.txId+":"+this.outputIndex},u.fromObject=function(t){return new u(t)},u.prototype.toObject=u.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))}},t.exports=u},function(t,e,r){"use strict";(function(e){var i=r(7),n=r(49),o=(r(9),r(2),new i(2147483647));function s(t){return this instanceof s?(this.options=t||{},this):new s(t)}s.split=function(t,r,i,n){if(n=n||{},!t)throw new Error("Secret is required");if(r<2)throw new Error("Threshold must be at least 2");if(i<r)throw new Error("Number of shares must be at least threshold");if(r>255||i>255)throw new Error("Threshold and shares must be <= 255");for(var o=e.isBuffer(t)?t:e.from(t,"utf8"),a=[],u=0;u<o.length;u++){var c=o[u],h=s._splitByte(c,r,i);a.push(h)}for(var f=[],d=0;d<i;d++){for(var l={id:d+1,threshold:r,shares:i,length:o.length,bytes:[]},p=0;p<a.length;p++)l.bytes.push(a[p][d]);f.push(l)}return f},s.combine=function(t){if(!t||0===t.length)throw new Error("Shares array is required");var r=t[0].threshold,i=t[0].shares,n=t[0].length;if(t.length<r)throw new Error("Insufficient shares: need "+r+", got "+t.length);for(var o=0;o<t.length;o++){if(t[o].threshold!==r||t[o].shares!==i)throw new Error("Shares have inconsistent parameters");if(t[o].length!==n)throw new Error("Shares have different secret lengths")}for(var a=[],u=0;u<n;u++){for(var c=[],h=0;h<Math.min(t.length,r);h++)c.push(t[h].bytes[u]);var f=s._combineByte(c);a.push(f)}return e.from(a)},s._splitByte=function(t,e,r){for(var n=[new i(t)],o=1;o<e;o++){var a=s._randomFieldElement();n.push(a)}for(var u=[],c=1;c<=r;c++){var h=s._evaluatePolynomial(n,new i(c));u.push({x:c,y:h.toString(16)})}return u},s._combineByte=function(t){if(0===t.length)throw new Error("No shares provided");for(var e=new i(0),r=0;r<t.length;r++){for(var n=new i(t[r].x),a=new i(t[r].y,16),u=new i(1),c=new i(1),h=0;h<t.length;h++)if(r!==h){var f=new i(t[h].x),d=new i(0).sub(f);d.lt(new i(0))&&(d=d.add(o)),u=u.mul(d).mod(o);var l=n.sub(f);l.lt(new i(0))&&(l=l.add(o)),c=c.mul(l).mod(o)}var p=s._modInverse(c,o),g=u.mul(p).mod(o);e=e.add(a.mul(g)).mod(o)}return e.mod(o).mod(new i(256)).toNumber()},s._evaluatePolynomial=function(t,e){for(var r=new i(0),n=new i(1),s=0;s<t.length;s++)r=r.add(t[s].mul(n)).mod(o),n=n.mul(e).mod(o);return r},s._randomFieldElement=function(){var t=n.getRandomBuffer(32);return new i(t).mod(o.sub(new i(1))).add(new i(1))},s._modInverse=function(t,e){t.lt(new i(0))&&(t=t.mod(e).add(e));var r=s._extendedGCD(t,e);if(!r.gcd.eq(new i(1)))throw new Error("Modular inverse does not exist");return r.x.mod(e).add(e).mod(e)},s._extendedGCD=function(t,e){if(t.eq(new i(0)))return{gcd:e,x:new i(0),y:new i(1)};var r=s._extendedGCD(e.mod(t),t);return{gcd:r.gcd,x:r.y.sub(e.div(t).mul(r.x)),y:r.x}},s.verifyShare=function(t){try{if(!t||"object"!=typeof t)return!1;if(!(t.id&&t.threshold&&t.shares&&t.bytes&&"number"==typeof t.length))return!1;if(t.threshold<2||t.shares<t.threshold)return!1;if(!Array.isArray(t.bytes)||t.bytes.length!==t.length)return!1;for(var e=0;e<t.bytes.length;e++){var r=t.bytes[e];if(!r.x||!r.y)return!1;if(r.x<1||r.x>t.shares)return!1;try{var n=r.y;if(!/^[0-9a-fA-F]+$/.test(n))return!1;new i(n,16)}catch(t){return!1}}return!0}catch(t){return!1}},s.generateTestVectors=function(){var t="Hello, Bitcoin SV!",e=s.split(t,3,5),r=s.combine(e.slice(0,3));return{secret:t,threshold:3,totalShares:5,shares:e,reconstructed:r.toString("utf8"),valid:r.toString("utf8")===t}},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(61),o=r(25),s=r(21),a=r(9),u=r(60),c=r(16),h=r(4);function f(t){if(!(this instanceof f))return new f(t);var r={};if(e.isBuffer(t))r=f._fromBufferReader(o(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for MerkleBlock");r={header:t.header instanceof n?t.header:n.fromObject(t.header),numTransactions:t.numTransactions,hashes:t.hashes,flags:t.flags}}return i.extend(this,r),this._flagBitsUsed=0,this._hashesUsed=0,this}f.fromBuffer=function(t){return f.fromBufferReader(o(t))},f.fromBufferReader=function(t){return new f(f._fromBufferReader(t))},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toBufferWriter=function(t){t||(t=new s),t.write(this.header.toBuffer()),t.writeUInt32LE(this.numTransactions),t.writeVarintNum(this.hashes.length);for(var r=0;r<this.hashes.length;r++)t.write(e.from(this.hashes[r],"hex"));for(t.writeVarintNum(this.flags.length),r=0;r<this.flags.length;r++)t.writeUInt8(this.flags[r]);return t},f.prototype.toObject=f.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},f.prototype.validMerkleTree=function(){if(h.checkState(i.isArray(this.flags),"MerkleBlock flags is not an array"),h.checkState(i.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e);return e.hashesUsed===this.hashes.length&&r.equals(this.header.merkleRoot)},f.prototype.filterdTxsHash=function(){throw new Error("filterdTxsHash has been deprecated. use filteredTxsHash.")},f.prototype.filteredTxsHash=function(){if(h.checkState(i.isArray(this.flags),"MerkleBlock flags is not an array"),h.checkState(i.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new c.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new c.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e,!0);if(e.hashesUsed!==this.hashes.length)throw new c.MerkleBlock.InvalidMerkleTree;return r},f.prototype._traverseMerkleTree=function(t,r,i,n){if((i=i||{}).txs=i.txs||[],i.flagBitsUsed=i.flagBitsUsed||0,i.hashesUsed=i.hashesUsed||0,n=n||!1,i.flagBitsUsed>8*this.flags.length)return null;var o=this.flags[i.flagBitsUsed>>3]>>>(7&i.flagBitsUsed++)&1;if(0!==t&&o){var s=this._traverseMerkleTree(t-1,2*r,i),u=s;return 2*r+1<this._calcTreeWidth(t-1)&&(u=this._traverseMerkleTree(t-1,2*r+1,i)),n?i.txs:a.sha256sha256(e.concat([s,u]))}if(i.hashesUsed>=this.hashes.length)return null;var c=this.hashes[i.hashesUsed++];return 0===t&&o&&i.txs.push(c),e.from(c,"hex")},f.prototype._calcTreeWidth=function(t){return this.numTransactions+(1<<t)-1>>t},f.prototype._calcTreeHeight=function(){for(var t=0;this._calcTreeWidth(t)>1;)t++;return t},f.prototype.hasTransaction=function(t){h.checkArgument(!i.isUndefined(t),"tx cannot be undefined"),h.checkArgument(t instanceof u||"string"==typeof t,'Invalid tx given, tx must be a "string" or "Transaction"');var r=t;t instanceof u&&(r=e.from(t.id,"hex").reverse().toString("hex"));var n=[],o=this._calcTreeHeight();return this._traverseMerkleTree(o,0,{txs:n}),-1!==n.indexOf(r)},f._fromBufferReader=function(t){h.checkState(!t.finished(),"No merkleblock data received");var e={};e.header=n.fromBufferReader(t),e.numTransactions=t.readUInt32LE();var r=t.readVarintNum();e.hashes=[];for(var i=0;i<r;i++)e.hashes.push(t.read(32).toString("hex"));var o=t.readVarintNum();for(e.flags=[],i=0;i<o;i++)e.flags.push(t.readUInt8());return e},f.fromObject=function(t){return new f(t)},t.exports=f}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(83),n=r(0),o=r(2),s=r(4),a=r(7),u=r(59),c=r(45),h=r(9),f=r(29),d=r(17),l=r(58),p=r(49),g=r(16),m=g.HDPrivateKey,y=r(10);function b(t){if(t instanceof b)return t;if(!(this instanceof b))return new b(t);if(!t)return this._generateRandomly();if(f.get(t))return this._generateRandomly(t);if(o.isString(t)||e.isBuffer(t))if(b.isValidSerialized(t))this._buildFromSerialized(t);else if(y.isValidJSON(t))this._buildFromJSON(t);else{if(!e.isBuffer(t)||!b.isValidSerialized(t.toString()))throw b.getSerializedError(t);this._buildFromSerialized(t.toString())}else{if(!o.isObject(t))throw new m.UnrecognizedArgument(t);this._buildFromObject(t)}}b.fromRandom=function(){return new b},b.isValidPath=function(t,e){if(o.isString(t)){var r=b._getDerivationIndexes(t);return null!==r&&o.every(r,b.isValidPath)}return!!o.isNumber(t)&&(t<b.Hardened&&!0===e&&(t+=b.Hardened),t>=0&&t<b.MaxIndex)},b._getDerivationIndexes=function(t){var e=t.split("/");if(o.includes(b.RootElementAlias,t))return[];if(!o.includes(b.RootElementAlias,e[0]))return null;var r=e.slice(1).map((function(t){var e="'"===t.slice(-1);if(e&&(t=t.slice(0,-1)),!t||"-"===t[0])return NaN;var r=+t;return e&&(r+=b.Hardened),r}));return o.some(r,isNaN)?null:r},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e);if(o.isString(t))return this._deriveFromString(t);throw new m.InvalidDerivationArgument(t)},b.prototype.deriveNonCompliantChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e,!0);if(o.isString(t))return this._deriveFromString(t,!0);throw new m.InvalidDerivationArgument(t)},b.prototype._deriveWithNumber=function(t,r,o){if(!b.isValidPath(t,r))throw new m.InvalidPath(t);r=t>=b.Hardened||r,t<b.Hardened&&!0===r&&(t+=b.Hardened);var s,u=y.integerAsBuffer(t);if(r&&o){var c=this.privateKey.bn.toBuffer();s=e.concat([n.Buffer.from([0]),c,u])}else if(r){var f=this.privateKey.bn.toBuffer({size:32});i(32===f.length,"length of private key buffer is expected to be 32 bytes"),s=e.concat([n.Buffer.from([0]),f,u])}else s=e.concat([this.publicKey.toBuffer(),u]);var p=h.sha512hmac(s,this._buffers.chainCode),g=a.fromBuffer(p.slice(0,32),{size:32}),v=p.slice(32,64),_=g.add(this.privateKey.toBigNumber()).umod(d.getN()).toBuffer({size:32});return l.isValid(_)?new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:v,privateKey:_}):this._deriveWithNumber(t+1,null,o)},b.prototype._deriveFromString=function(t,e){if(!b.isValidPath(t))throw new m.InvalidPath(t);return b._getDerivationIndexes(t).reduce((function(t,r){return t._deriveWithNumber(r,null,e)}),this)},b.isValidSerialized=function(t,e){return!b.getSerializedError(t,e)},b.getSerializedError=function(t,r){if(!o.isString(t)&&!e.isBuffer(t))return new m.UnrecognizedArgument("Expected string or buffer");if(!u.validCharacters(t))return new g.InvalidB58Char("(unknown)",t);try{t=c.decode(t)}catch(e){return new g.InvalidB58Checksum(t)}if(t.length!==b.DataLength)return new m.InvalidLength(t);if(!o.isUndefined(r)){var i=b._validateNetwork(t,r);if(i)return i}return null},b._validateNetwork=function(t,e){var r=f.get(e);if(!r)return new g.InvalidNetworkArgument(e);var i=t.slice(0,4);return i.readUInt32BE(0)!==r.xprivkey?new g.InvalidNetwork(i):null},b.fromString=function(t){return s.checkArgument(o.isString(t),"No valid string was provided"),new b(t)},b.fromObject=function(t){return s.checkArgument(o.isObject(t),"No valid argument was provided"),new b(t)},b.prototype._buildFromJSON=function(t){return this._buildFromObject(JSON.parse(t))},b.prototype._buildFromObject=function(t){var r={version:t.network?y.integerAsBuffer(f.get(t.network).xprivkey):t.version,depth:o.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:o.isNumber(t.parentFingerPrint)?y.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:o.isNumber(t.childIndex)?y.integerAsBuffer(t.childIndex):t.childIndex,chainCode:o.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,privateKey:o.isString(t.privateKey)&&y.isHexa(t.privateKey)?e.from(t.privateKey,"hex"):t.privateKey,checksum:t.checksum?t.checksum.length?t.checksum:y.integerAsBuffer(t.checksum):void 0};return this._buildFromBuffers(r)},b.prototype._buildFromSerialized=function(t){var e=c.decode(t),r={version:e.slice(b.VersionStart,b.VersionEnd),depth:e.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:e.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:e.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:e.slice(b.ChainCodeStart,b.ChainCodeEnd),privateKey:e.slice(b.PrivateKeyStart,b.PrivateKeyEnd),checksum:e.slice(b.ChecksumStart,b.ChecksumEnd),xprivkey:t};return this._buildFromBuffers(r)},b.prototype._generateRandomly=function(t){return b.fromSeed(p.getRandomBuffer(64),t)},b.fromSeed=function(t,r){if(y.isHexaString(t)&&(t=e.from(t,"hex")),!e.isBuffer(t))throw new m.InvalidEntropyArgument(t);if(t.length<16)throw new m.InvalidEntropyArgument.NotEnoughEntropy(t);if(t.length>64)throw new m.InvalidEntropyArgument.TooMuchEntropy(t);var i=h.sha512hmac(t,n.Buffer.from("Bitcoin seed"));return new b({network:f.get(r)||f.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:i.slice(0,32),chainCode:i.slice(32,64)})},b.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var t=r(147);this._hdPublicKey=new t(this)}},b.prototype._buildFromBuffers=function(t){b._validateBufferArguments(t),y.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,e.alloc(1),t.privateKey],i=n.Buffer.concat(r);if(t.checksum&&t.checksum.length){if(t.checksum.toString()!==c.checksum(i).toString())throw new g.InvalidB58Checksum(i)}else t.checksum=c.checksum(i);var o,s=f.get(t.version.readUInt32BE(0));o=c.encode(n.Buffer.concat(r)),t.xprivkey=e.from(o);var u=new l(a.fromBuffer(t.privateKey),s),d=u.toPublicKey(),p=b.ParentFingerPrintSize,m=h.sha256ripemd160(d.toBuffer()).slice(0,p);return y.defineImmutable(this,{xprivkey:o,network:s,depth:t.depth[0],privateKey:u,publicKey:d,fingerPrint:m}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},b._validateBufferArguments=function(t){var r=function(r,n){var o=t[r];i(e.isBuffer(o),r+" argument is not a buffer"),i(o.length===n,r+" has not the expected size: found "+o.length+", expected "+n)};r("version",b.VersionSize),r("depth",b.DepthSize),r("parentFingerPrint",b.ParentFingerPrintSize),r("childIndex",b.ChildIndexSize),r("chainCode",b.ChainCodeSize),r("privateKey",b.PrivateKeySize),t.checksum&&t.checksum.length&&r("checksum",b.CheckSumSize)},b.prototype.toString=function(){return this.xprivkey},b.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:f.get(this._buffers.version.readUInt32BE(0),"xprivkey").name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:this._buffers.checksum.readUInt32BE(0),xprivkey:this.xprivkey}},b.fromBuffer=function(t){return new b(t.toString())},b.fromHex=function(t){return b.fromBuffer(e.from(t,"hex"))},b.prototype.toBuffer=function(){return e.from(this.toString())},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.DefaultDepth=0,b.DefaultFingerprint=0,b.DefaultChildIndex=0,b.Hardened=2147483648,b.MaxIndex=2*b.Hardened,b.RootElementAlias=["m","M","m'","M'"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PrivateKeySize=32,b.CheckSumSize=4,b.DataLength=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PrivateKeyStart=b.ChainCodeEnd+1,b.PrivateKeyEnd=b.PrivateKeyStart+b.PrivateKeySize,b.ChecksumStart=b.PrivateKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,i(b.ChecksumEnd===b.SerializedByteSize),t.exports=b}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(4),o=r(7),s=r(59),a=r(45),u=r(9),c=r(146),h=r(29),f=r(17),d=r(20),l=r(16),p=l,g=l.HDPublicKey,m=r(83),y=r(10);function b(t){if(t instanceof b)return t;if(!(this instanceof b))return new b(t);if(t){if(i.isString(t)||e.isBuffer(t)){var r=b.getSerializedError(t);if(r){if(e.isBuffer(t)&&!b.getSerializedError(t.toString()))return this._buildFromSerialized(t.toString());if(r instanceof g.ArgumentIsPrivateExtended)return new c(t).hdPublicKey;throw r}return this._buildFromSerialized(t)}if(i.isObject(t))return t instanceof c?this._buildFromPrivate(t):this._buildFromObject(t);throw new g.UnrecognizedArgument(t)}throw new g.MustSupplyArgument}b.fromHDPrivateKey=function(t){return new b(t)},b.isValidPath=function(t){if(i.isString(t)){var e=c._getDerivationIndexes(t);return null!==e&&i.every(e,b.isValidPath)}return!!i.isNumber(t)&&(t>=0&&t<b.Hardened)},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(t,e){if(i.isNumber(t))return this._deriveWithNumber(t,e);if(i.isString(t))return this._deriveFromString(t);throw new g.InvalidDerivationArgument(t)},b.prototype._deriveWithNumber=function(t,r){if(t>=b.Hardened||r)throw new g.InvalidIndexCantDeriveHardened;if(t<0)throw new g.InvalidPath(t);var i,n=y.integerAsBuffer(t),s=e.concat([this.publicKey.toBuffer(),n]),a=u.sha512hmac(s,this._buffers.chainCode),c=o.fromBuffer(a.slice(0,32),{size:32}),h=a.slice(32,64);try{i=d.fromPoint(f.getG().mul(c).add(this.publicKey.point))}catch(e){return this._deriveWithNumber(t+1)}return new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:h,publicKey:i})},b.prototype._deriveFromString=function(t){if(i.includes(t,"'"))throw new g.InvalidIndexCantDeriveHardened;if(!b.isValidPath(t))throw new g.InvalidPath(t);return c._getDerivationIndexes(t).reduce((function(t,e){return t._deriveWithNumber(e)}),this)},b.isValidSerialized=function(t,e){return i.isNull(b.getSerializedError(t,e))},b.getSerializedError=function(t,r){if(!i.isString(t)&&!e.isBuffer(t))return new g.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(t))return new p.InvalidB58Char("(unknown)",t);try{t=a.decode(t)}catch(e){return new p.InvalidB58Checksum(t)}if(t.length!==b.DataSize)return new g.InvalidLength(t);if(!i.isUndefined(r)){var n=b._validateNetwork(t,r);if(n)return n}var o=t.readUInt32BE(0);return o===h.livenet.xprivkey||o===h.testnet.xprivkey?new g.ArgumentIsPrivateExtended:null},b._validateNetwork=function(t,e){var r=h.get(e);if(!r)return new p.InvalidNetworkArgument(e);var i=t.slice(b.VersionStart,b.VersionEnd);return i.readUInt32BE(0)!==r.xpubkey?new p.InvalidNetwork(i):null},b.prototype._buildFromPrivate=function(t){var e=i.clone(t._buffers),r=f.getG().mul(o.fromBuffer(e.privateKey));return e.publicKey=f.pointToCompressed(r),e.version=y.integerAsBuffer(h.get(e.version.readUInt32BE(0)).xpubkey),e.privateKey=void 0,e.checksum=void 0,e.xprivkey=void 0,this._buildFromBuffers(e)},b.prototype._buildFromObject=function(t){var r={version:t.network?y.integerAsBuffer(h.get(t.network).xpubkey):t.version,depth:i.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:i.isNumber(t.parentFingerPrint)?y.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:i.isNumber(t.childIndex)?y.integerAsBuffer(t.childIndex):t.childIndex,chainCode:i.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,publicKey:i.isString(t.publicKey)?e.from(t.publicKey,"hex"):e.isBuffer(t.publicKey)?t.publicKey:t.publicKey.toBuffer(),checksum:i.isNumber(t.checksum)?y.integerAsBuffer(t.checksum):t.checksum};return this._buildFromBuffers(r)},b.prototype._buildFromSerialized=function(t){var e=a.decode(t),r={version:e.slice(b.VersionStart,b.VersionEnd),depth:e.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:e.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:e.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:e.slice(b.ChainCodeStart,b.ChainCodeEnd),publicKey:e.slice(b.PublicKeyStart,b.PublicKeyEnd),checksum:e.slice(b.ChecksumStart,b.ChecksumEnd),xpubkey:t};return this._buildFromBuffers(r)},b.prototype._buildFromBuffers=function(t){b._validateBufferArguments(t),y.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,t.publicKey],i=e.concat(r),n=a.checksum(i);if(t.checksum&&t.checksum.length){if(t.checksum.toString("hex")!==n.toString("hex"))throw new p.InvalidB58Checksum(i,n)}else t.checksum=n;var o,s=h.get(t.version.readUInt32BE(0));o=a.encode(e.concat(r)),t.xpubkey=e.from(o);var c=new d(t.publicKey,{network:s}),f=b.ParentFingerPrintSize,l=u.sha256ripemd160(c.toBuffer()).slice(0,f);return y.defineImmutable(this,{xpubkey:o,network:s,depth:t.depth[0],publicKey:c,fingerPrint:l}),this},b._validateBufferArguments=function(t){var r=function(r,i){var n=t[r];m(e.isBuffer(n),r+" argument is not a buffer, it's "+typeof n),m(n.length===i,r+" has not the expected size: found "+n.length+", expected "+i)};r("version",b.VersionSize),r("depth",b.DepthSize),r("parentFingerPrint",b.ParentFingerPrintSize),r("childIndex",b.ChildIndexSize),r("chainCode",b.ChainCodeSize),r("publicKey",b.PublicKeySize),t.checksum&&t.checksum.length&&r("checksum",b.CheckSumSize)},b.fromString=function(t){return n.checkArgument(i.isString(t),"No valid string was provided"),new b(t)},b.fromObject=function(t){return n.checkArgument(i.isObject(t),"No valid argument was provided"),new b(t)},b.prototype.toString=function(){return this.xpubkey},b.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:h.get(this._buffers.version.readUInt32BE(0)).name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),publicKey:this.publicKey.toString(),checksum:this._buffers.checksum.readUInt32BE(0),xpubkey:this.xpubkey}},b.fromBuffer=function(t){return new b(t)},b.fromHex=function(t){return b.fromBuffer(e.from(t,"hex"))},b.prototype.toBuffer=function(){return e.from(this._buffers.xpubkey)},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.Hardened=2147483648,b.RootElementAlias=["m","M"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PublicKeySize=33,b.CheckSumSize=4,b.DataSize=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PublicKeyStart=b.ChainCodeEnd,b.PublicKeyEnd=b.PublicKeyStart+b.PublicKeySize,b.ChecksumStart=b.PublicKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,m(b.PublicKeyEnd===b.DataSize),m(b.ChecksumEnd===b.SerializedByteSize),t.exports=b}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(t,e){const{opcodeMap:i,scriptNum:n,utils:o}=r(149);class s{constructor(){this.operations=[],this.comments=[]}comment(t){return this.comments.push("// "+t),this}push(e){if("number"==typeof e)if(e>=-1&&e<=16)-1===e?this.operations.push("OP_1NEGATE"):0===e?this.operations.push("OP_0"):this.operations.push("OP_"+e);else{const t=n.encode(e);this.operations.push(t.toString("hex"))}else if("string"==typeof e)this.operations.push(e);else{if(!t.isBuffer(e))throw new Error("Invalid value type: "+typeof e);this.operations.push(e.toString("hex"))}return this}dup(){return this.operations.push("OP_DUP"),this}drop(){return this.operations.push("OP_DROP"),this}swap(){return this.operations.push("OP_SWAP"),this}over(){return this.operations.push("OP_OVER"),this}rot(){return this.operations.push("OP_ROT"),this}pick(t){return this.push(t),this.operations.push("OP_PICK"),this}roll(t){return this.push(t),this.operations.push("OP_ROLL"),this}depth(){return this.operations.push("OP_DEPTH"),this}add(){return this.operations.push("OP_ADD"),this}sub(){return this.operations.push("OP_SUB"),this}mul(){return this.operations.push("OP_MUL"),this}div(){return this.operations.push("OP_DIV"),this}mod(){return this.operations.push("OP_MOD"),this}negate(){return this.operations.push("OP_NEGATE"),this}abs(){return this.operations.push("OP_ABS"),this}min(){return this.operations.push("OP_MIN"),this}max(){return this.operations.push("OP_MAX"),this}equal(){return this.operations.push("OP_EQUAL"),this}equalVerify(){return this.operations.push("OP_EQUALVERIFY"),this}numEqual(){return this.operations.push("OP_NUMEQUAL"),this}numNotEqual(){return this.operations.push("OP_NUMNOTEQUAL"),this}lessThan(){return this.operations.push("OP_LESSTHAN"),this}greaterThan(){return this.operations.push("OP_GREATERTHAN"),this}lessThanOrEqual(){return this.operations.push("OP_LESSTHANOREQUAL"),this}greaterThanOrEqual(){return this.operations.push("OP_GREATERTHANOREQUAL"),this}within(){return this.operations.push("OP_WITHIN"),this}not(){return this.operations.push("OP_NOT"),this}boolAnd(){return this.operations.push("OP_BOOLAND"),this}boolOr(){return this.operations.push("OP_BOOLOR"),this}and(){return this.operations.push("OP_AND"),this}or(){return this.operations.push("OP_OR"),this}xor(){return this.operations.push("OP_XOR"),this}invert(){return this.operations.push("OP_INVERT"),this}cat(){return this.operations.push("OP_CAT"),this}split(){return this.operations.push("OP_SPLIT"),this}size(){return this.operations.push("OP_SIZE"),this}left(t){return this.push(t),this.operations.push("OP_LEFT"),this}right(t){return this.push(t),this.operations.push("OP_RIGHT"),this}substr(t,e){return this.push(e).push(t),this.operations.push("OP_SUBSTR"),this}sha256(){return this.operations.push("OP_SHA256"),this}hash256(){return this.operations.push("OP_HASH256"),this}hash160(){return this.operations.push("OP_HASH160"),this}ripemd160(){return this.operations.push("OP_RIPEMD160"),this}verify(){return this.operations.push("OP_VERIFY"),this}return(){return this.operations.push("OP_RETURN"),this}extractField(t){this.comment(`Extract ${t} field from preimage`);const e={nVersion:{strategy:"LEFT",offset:0,length:4},hashPrevouts:{strategy:"LEFT",offset:4,length:32},hashSequence:{strategy:"LEFT",offset:36,length:32},outpoint:{strategy:"LEFT",offset:68,length:36},scriptLen:{strategy:"DYNAMIC",position:"after_outpoint"},scriptCode:{strategy:"DYNAMIC",variable_length:!0},value:{strategy:"RIGHT",offsetFromEnd:52,length:8},nSequence:{strategy:"RIGHT",offsetFromEnd:44,length:4},hashOutputs:{strategy:"RIGHT",offsetFromEnd:40,length:32},nLocktime:{strategy:"RIGHT",offsetFromEnd:8,length:4},sighashType:{strategy:"RIGHT",offsetFromEnd:4,length:4}}[t];if(!e)throw new Error("Unknown field: "+t);if("LEFT"===e.strategy)this.push(e.offset+e.length).split().drop().push(e.offset).split().swap().drop();else if("RIGHT"===e.strategy)this.size().push(e.offsetFromEnd).sub().split().drop().push(e.length).split().drop();else if("DYNAMIC"===e.strategy){if("scriptLen"!==t)throw new Error(`Dynamic extraction for ${t} not implemented`);this.push(104).split().drop().push(1).split().swap().drop()}return this}validateField(t,e){return this.comment(`Validate ${t} equals expected value`),this.extractField(t),this.push(e),this.equalVerify(),this}validateRange(t,e,r){return this.comment(`Validate ${t} is within range [${e}, ${r})`),this.extractField(t),this.dup(),this.push(e),this.greaterThanOrEqual(),this.verify(),this.push(r),this.lessThan(),this.verify(),this}validateFields(t){return this.comment("Multi-field validation"),Object.entries(t).forEach(([t,e])=>{e.equals?this.validateField(t,e.equals):void 0===e.min&&void 0===e.max||this.validateRange(t,e.min||0,e.max||Number.MAX_SAFE_INTEGER)}),this}if(t){return this.comment("Begin IF block"),"function"==typeof t&&t(this),this.operations.push("OP_IF"),this}else(){return this.comment("ELSE block"),this.operations.push("OP_ELSE"),this}endif(){return this.comment("End IF block"),this.operations.push("OP_ENDIF"),this}build(){const t=this.operations.join(" "),e=this._cleanASM(t);return{operations:[...this.operations],comments:[...this.comments],asm:t,cleanedASM:e,hex:this._asmToHex(e),size:e.split(" ").length}}_cleanASM(t){return t.split(" ").map(t=>{if(/^\d+$/.test(t)){const e=parseInt(t);return e>=1&&e<=75?e.toString(16).padStart(2,"0"):n.encode(e).toString("hex")}return t}).join(" ")}_asmToHex(t){return t.split(" ").map(t=>i[t]?i[t].code.toString(16).padStart(2,"0"):/^[0-9a-fA-F]+$/.test(t)?t:"00").join("")}simulate(t=[]){return o.simulate(this.operations,t)}document(){const t=this.build();return{title:"Covenant Script Documentation",operations:t.operations.length,size:t.size,asm:t.cleanedASM,comments:this.comments,structure:this._analyzeStructure()}}_analyzeStructure(){const t={stack_operations:0,arithmetic:0,comparisons:0,crypto:0,data_manipulation:0,flow_control:0};return this.operations.forEach(e=>{const r=i[e];if(r)switch(r.category){case"stack":t.stack_operations++;break;case"arithmetic":t.arithmetic++;break;case"bitwise":t.comparisons++;break;case"crypto":t.crypto++;break;case"data":t.data_manipulation++;break;case"flow_control":t.flow_control++}}),t}}const a={valueLock:t=>(new s).comment("Value Lock Covenant").comment("Expected value: "+t).validateField("value",t).push(1),hashLock:t=>(new s).comment("Hash Lock Covenant").comment("Expected hash: "+t).sha256().push(t).equalVerify().push(1),multiSigWithValidation:(t,e,r)=>{const i=(new s).comment("Multi-Signature Covenant with Field Validation").comment("Required signatures: "+t);return i.validateFields(r),i.comment("Signature validation (placeholder)").push(1),i},timeLock:t=>(new s).comment("Time Lock Covenant").comment("Locktime: "+t).validateField("nLocktime",t).push(1),complexValidation:t=>{const e=(new s).comment("Complex Validation Covenant");return t.valueRange&&e.validateRange("value",t.valueRange.min,t.valueRange.max),t.fields&&e.validateFields(t.fields),t.hashValidation&&e.sha256().push(t.hashValidation.expectedHash).equalVerify(),e.push(1),e}};if(e.exports={CovenantBuilder:s,CovenantTemplates:a},r.c[r.s]===e){console.log("🏗️ Covenant Builder Demonstration"),console.log("=================================="),console.log("\n📊 Example 1: Value Lock Covenant");const t=a.valueLock("50c3000000000000").build();console.log("ASM:",t.cleanedASM),console.log("Size:",t.size,"operations"),console.log("\n📊 Example 2: Custom Arithmetic Covenant");const e=(new s).comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),r=e.build();console.log("Operations:",r.operations.length),console.log("ASM:",r.cleanedASM),console.log("\n📊 Example 3: Documentation Generation");const i=e.document();console.log("Structure analysis:",i.structure),console.log("Comments:"),i.comments.forEach(t=>console.log(" "+t))}}).call(this,r(0).Buffer,r(23)(t))},function(t,e,r){(function(t,e){const i={encode:e=>{if(0===e)return t.alloc(0);const r=e<0,i=[];let n=Math.abs(e);for(;n>0;)i.push(255&n),n>>=8;return 128&i[i.length-1]?i.push(r?128:0):r&&(i[i.length-1]|=128),t.from(i)},decode:t=>{if(0===t.length)return 0;const e=Array.from(t),r=128&e[e.length-1];r&&(e[e.length-1]&=127);let i=0;for(let t=e.length-1;t>=0;t--)i=(i<<8)+e[t];return r?-i:i}},n={OP_FALSE:{code:0,category:"constants",description:"Push empty array (false value)",action:e=>e.push(t.alloc(0))},OP_0:{code:0,category:"constants",description:"Push empty array (alias for OP_FALSE)",action:e=>e.push(t.alloc(0))},OP_PUSHDATA1:{code:76,category:"pushdata",description:"Push next [1 byte] bytes of data",action:"Read next byte as length; push that many bytes"},OP_PUSHDATA2:{code:77,category:"pushdata",description:"Push next [2 bytes LE] bytes of data",action:"Read next 2 bytes as length; push that many bytes"},OP_PUSHDATA4:{code:78,category:"pushdata",description:"Push next [4 bytes LE] bytes of data",action:"Read next 4 bytes as length; push that many bytes"},OP_1NEGATE:{code:79,category:"constants",description:"Push number -1",action:t=>t.push(i.encode(-1))},OP_RESERVED:{code:80,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED encountered")}},OP_TRUE:{code:81,category:"constants",description:"Push number 1 (true value)",action:t=>t.push(i.encode(1))},OP_1:{code:81,category:"constants",description:"Push number 1 (alias for OP_TRUE)",action:t=>t.push(i.encode(1))},OP_2:{code:82,category:"constants",description:"Push number 2",action:t=>t.push(i.encode(2))},OP_3:{code:83,category:"constants",description:"Push number 3",action:t=>t.push(i.encode(3))},OP_4:{code:84,category:"constants",description:"Push number 4",action:t=>t.push(i.encode(4))},OP_5:{code:85,category:"constants",description:"Push number 5",action:t=>t.push(i.encode(5))},OP_6:{code:86,category:"constants",description:"Push number 6",action:t=>t.push(i.encode(6))},OP_7:{code:87,category:"constants",description:"Push number 7",action:t=>t.push(i.encode(7))},OP_8:{code:88,category:"constants",description:"Push number 8",action:t=>t.push(i.encode(8))},OP_9:{code:89,category:"constants",description:"Push number 9",action:t=>t.push(i.encode(9))},OP_10:{code:90,category:"constants",description:"Push number 10",action:t=>t.push(i.encode(10))},OP_11:{code:91,category:"constants",description:"Push number 11",action:t=>t.push(i.encode(11))},OP_12:{code:92,category:"constants",description:"Push number 12",action:t=>t.push(i.encode(12))},OP_13:{code:93,category:"constants",description:"Push number 13",action:t=>t.push(i.encode(13))},OP_14:{code:94,category:"constants",description:"Push number 14",action:t=>t.push(i.encode(14))},OP_15:{code:95,category:"constants",description:"Push number 15",action:t=>t.push(i.encode(15))},OP_16:{code:96,category:"constants",description:"Push number 16",action:t=>t.push(i.encode(16))},OP_NOP:{code:97,category:"flow_control",description:"No operation (do nothing)",action:t=>{}},OP_VER:{code:98,category:"flow_control",description:"Push transaction version (disabled)",action:()=>{throw new Error("OP_VER is disabled")}},OP_IF:{code:99,category:"flow_control",description:"Execute if top stack value is true",action:"// Conditional execution (requires parser state)"},OP_NOTIF:{code:100,category:"flow_control",description:"Execute if top stack value is false",action:"// Conditional execution (requires parser state)"},OP_VERIF:{code:101,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERIF is disabled")}},OP_VERNOTIF:{code:102,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERNOTIF is disabled")}},OP_ELSE:{code:103,category:"flow_control",description:"Else branch of conditional",action:"// Conditional execution (requires parser state)"},OP_ENDIF:{code:104,category:"flow_control",description:"End conditional block",action:"// Conditional execution (requires parser state)"},OP_VERIFY:{code:105,category:"flow_control",description:"Fail if top stack value is not true",action:t=>{const e=t.pop();if(!e||0===e.length||0===i.decode(e))throw new Error("OP_VERIFY failed")}},OP_RETURN:{code:106,category:"flow_control",description:"Terminate script execution immediately",action:()=>{throw new Error("Script terminated by OP_RETURN")}},OP_TOALTSTACK:{code:107,category:"stack",description:"Move top item from main stack to alt stack",action:(t,e)=>e.push(t.pop())},OP_FROMALTSTACK:{code:108,category:"stack",description:"Move top item from alt stack to main stack",action:(t,e)=>t.push(e.pop())},OP_2DROP:{code:109,category:"stack",description:"Remove top two stack items",action:t=>{t.pop(),t.pop()}},OP_2DUP:{code:110,category:"stack",description:"Duplicate top two stack items",action:e=>{const r=e[e.length-1],i=e[e.length-2];e.push(t.from(i),t.from(r))}},OP_3DUP:{code:111,category:"stack",description:"Duplicate top three stack items",action:e=>{const r=e[e.length-1],i=e[e.length-2],n=e[e.length-3];e.push(t.from(n),t.from(i),t.from(r))}},OP_2OVER:{code:112,category:"stack",description:"Copy 3rd and 4th items to top",action:e=>{const r=e[e.length-3],i=e[e.length-4];e.push(t.from(i),t.from(r))}},OP_2ROT:{code:113,category:"stack",description:"Move 5th and 6th items to top",action:t=>{const e=t.splice(-5,1)[0],r=t.splice(-5,1)[0];t.push(e,r)}},OP_2SWAP:{code:114,category:"stack",description:"Swap top two pairs of items",action:t=>{const e=t.pop(),r=t.pop(),i=t.pop(),n=t.pop();t.push(r,e,n,i)}},OP_IFDUP:{code:115,category:"stack",description:"Duplicate top item if it is not zero",action:e=>{const r=e[e.length-1];r.length>0&&0!==i.decode(r)&&e.push(t.from(r))}},OP_DEPTH:{code:116,category:"stack",description:"Push stack size as number",action:t=>t.push(i.encode(t.length))},OP_DROP:{code:117,category:"stack",description:"Remove top stack item",action:t=>t.pop()},OP_DUP:{code:118,category:"stack",description:"Duplicate top stack item",action:e=>e.push(t.from(e[e.length-1]))},OP_NIP:{code:119,category:"stack",description:"Remove second-to-top item",action:t=>{const e=t.pop();t.pop(),t.push(e)}},OP_OVER:{code:120,category:"stack",description:"Copy second-to-top item to top",action:e=>e.push(t.from(e[e.length-2]))},OP_PICK:{code:121,category:"stack",description:"Copy nth item to top (0-indexed from top)",action:e=>{const r=i.decode(e.pop());e.push(t.from(e[e.length-1-r]))}},OP_ROLL:{code:122,category:"stack",description:"Move nth item to top (0-indexed from top)",action:t=>{const e=i.decode(t.pop()),r=t.splice(t.length-1-e,1)[0];t.push(r)}},OP_ROT:{code:123,category:"stack",description:"Rotate top three items left",action:t=>{const e=t.pop(),r=t.pop(),i=t.pop();t.push(r,e,i)}},OP_SWAP:{code:124,category:"stack",description:"Swap top two items",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r)}},OP_TUCK:{code:125,category:"stack",description:"Copy top item below second item",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r,e)}},OP_CAT:{code:126,category:"data",description:"Concatenate top two items",action:e=>{const r=e.pop(),i=e.pop();e.push(t.concat([i,r]))}},OP_SPLIT:{code:127,category:"data",description:"Split item at position n",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(0,e),r.slice(e))}},OP_NUM2BIN:{code:128,category:"data",description:"Convert number to byte sequence of length n",action:e=>{const r=i.decode(e.pop()),n=i.decode(e.pop()),o=t.alloc(r),s=i.encode(n);s.copy(o,0,0,Math.min(s.length,r)),e.push(o)}},OP_BIN2NUM:{code:129,category:"data",description:"Convert byte sequence to number",action:t=>{const e=t.pop();t.push(i.encode(i.decode(e)))}},OP_SIZE:{code:130,category:"data",description:"Push size of top item (without removing item)",action:t=>t.push(i.encode(t[t.length-1].length))},OP_INVERT:{code:131,category:"bitwise",description:"Bitwise NOT of top item",action:e=>{const r=e.pop();e.push(t.from(r.map(t=>~t)))}},OP_AND:{code:132,category:"bitwise",description:"Bitwise AND of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)&(i[t]||0);e.push(o)}},OP_OR:{code:133,category:"bitwise",description:"Bitwise OR of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)|(i[t]||0);e.push(o)}},OP_XOR:{code:134,category:"bitwise",description:"Bitwise XOR of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)^(i[t]||0);e.push(o)}},OP_EQUAL:{code:135,category:"bitwise",description:"Push 1 if top two items are equal, 0 otherwise",action:t=>{const e=t.pop(),r=t.pop();t.push(e.equals(r)?i.encode(1):i.encode(0))}},OP_EQUALVERIFY:{code:136,category:"bitwise",description:"Fail if top two items are not equal",action:t=>{const e=t.pop(),r=t.pop();if(!e.equals(r))throw new Error("OP_EQUALVERIFY failed")}},OP_1ADD:{code:139,category:"arithmetic",description:"Add 1 to top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(e+1))}},OP_1SUB:{code:140,category:"arithmetic",description:"Subtract 1 from top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(e-1))}},OP_2MUL:{code:141,category:"arithmetic",description:"Multiply top item by 2 (disabled)",action:()=>{throw new Error("OP_2MUL is disabled")}},OP_2DIV:{code:142,category:"arithmetic",description:"Divide top item by 2 (disabled)",action:()=>{throw new Error("OP_2DIV is disabled")}},OP_NEGATE:{code:143,category:"arithmetic",description:"Negate top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(-e))}},OP_ABS:{code:144,category:"arithmetic",description:"Absolute value of top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(Math.abs(e)))}},OP_NOT:{code:145,category:"arithmetic",description:"Logical NOT (0→1, non-zero→0)",action:t=>{const e=i.decode(t.pop());t.push(i.encode(0===e?1:0))}},OP_0NOTEQUAL:{code:146,category:"arithmetic",description:"Push 1 if top item is not zero, 0 otherwise",action:t=>{const e=i.decode(t.pop());t.push(i.encode(0!==e?1:0))}},OP_ADD:{code:147,category:"arithmetic",description:"Add top two items",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r+e))}},OP_SUB:{code:148,category:"arithmetic",description:"Subtract: second - first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r-e))}},OP_MUL:{code:149,category:"arithmetic",description:"Multiply top two items",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r*e))}},OP_DIV:{code:150,category:"arithmetic",description:"Divide: second / first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(i.encode(Math.floor(r/e)))}},OP_MOD:{code:151,category:"arithmetic",description:"Modulo: second % first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(i.encode(r%e))}},OP_LSHIFT:{code:152,category:"arithmetic",description:"Left shift: second << first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<<e))}},OP_RSHIFT:{code:153,category:"arithmetic",description:"Right shift: second >> first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>>e))}},OP_BOOLAND:{code:154,category:"arithmetic",description:"Boolean AND: 1 if both non-zero, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(0!==e&&0!==r?1:0))}},OP_BOOLOR:{code:155,category:"arithmetic",description:"Boolean OR: 1 if either non-zero, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(0!==e||0!==r?1:0))}},OP_NUMEQUAL:{code:156,category:"arithmetic",description:"Push 1 if numbers are equal, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(e===r?1:0))}},OP_NUMEQUALVERIFY:{code:157,category:"arithmetic",description:"Fail if numbers are not equal",action:t=>{if(i.decode(t.pop())!==i.decode(t.pop()))throw new Error("OP_NUMEQUALVERIFY failed")}},OP_NUMNOTEQUAL:{code:158,category:"arithmetic",description:"Push 1 if numbers are not equal, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(e!==r?1:0))}},OP_LESSTHAN:{code:159,category:"arithmetic",description:"Push 1 if second < first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<e?1:0))}},OP_GREATERTHAN:{code:160,category:"arithmetic",description:"Push 1 if second > first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>e?1:0))}},OP_LESSTHANOREQUAL:{code:161,category:"arithmetic",description:"Push 1 if second <= first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<=e?1:0))}},OP_GREATERTHANOREQUAL:{code:162,category:"arithmetic",description:"Push 1 if second >= first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>=e?1:0))}},OP_MIN:{code:163,category:"arithmetic",description:"Push smaller of top two numbers",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(Math.min(e,r)))}},OP_MAX:{code:164,category:"arithmetic",description:"Push larger of top two numbers",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(Math.max(e,r)))}},OP_WITHIN:{code:165,category:"arithmetic",description:"Push 1 if x is within [min, max), 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop()),n=i.decode(t.pop());t.push(i.encode(n>=r&&n<e?1:0))}},OP_RIPEMD160:{code:166,category:"crypto",description:"RIPEMD-160 hash of top item",action:t=>{const e=r(15).createHash("ripemd160").update(t.pop()).digest();t.push(e)}},OP_SHA1:{code:167,category:"crypto",description:"SHA-1 hash of top item",action:t=>{const e=r(15).createHash("sha1").update(t.pop()).digest();t.push(e)}},OP_SHA256:{code:168,category:"crypto",description:"SHA-256 hash of top item",action:t=>{const e=r(15).createHash("sha256").update(t.pop()).digest();t.push(e)}},OP_HASH160:{code:169,category:"crypto",description:"SHA-256 then RIPEMD-160 hash of top item",action:t=>{const e=r(15),i=e.createHash("sha256").update(t.pop()).digest(),n=e.createHash("ripemd160").update(i).digest();t.push(n)}},OP_HASH256:{code:170,category:"crypto",description:"Double SHA-256 hash of top item",action:t=>{const e=r(15),i=e.createHash("sha256").update(t.pop()).digest(),n=e.createHash("sha256").update(i).digest();t.push(n)}},OP_CODESEPARATOR:{code:171,category:"crypto",description:"Mark signature checking boundary",action:t=>{}},OP_CHECKSIG:{code:172,category:"crypto",description:"Verify signature against public key",action:"// Signature verification (requires transaction context)"},OP_CHECKSIGVERIFY:{code:173,category:"crypto",description:"Verify signature, then fail if invalid",action:"// Signature verification with VERIFY (requires transaction context)"},OP_CHECKMULTISIG:{code:174,category:"crypto",description:"Verify multiple signatures against public keys",action:"// Multi-signature verification (requires transaction context)"},OP_CHECKMULTISIGVERIFY:{code:175,category:"crypto",description:"Verify multiple signatures, then fail if invalid",action:"// Multi-signature verification with VERIFY (requires transaction context)"},OP_SUBSTR:{code:179,category:"string",description:"Extract substring: string[start:start+length]",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop()),n=t.pop();t.push(n.slice(r,r+e))}},OP_LEFT:{code:180,category:"string",description:"Extract leftmost n bytes",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(0,e))}},OP_RIGHT:{code:181,category:"string",description:"Extract rightmost n bytes",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(-e))}},OP_NOP1:{code:176,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP2:{code:177,category:"nop",description:"No operation (formerly CHECKLOCKTIMEVERIFY)",action:t=>{}},OP_NOP3:{code:178,category:"nop",description:"No operation (formerly CHECKSEQUENCEVERIFY)",action:t=>{}},OP_NOP4:{code:182,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP5:{code:183,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP6:{code:184,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP7:{code:185,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP8:{code:186,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP9:{code:187,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP10:{code:188,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_RESERVED1:{code:137,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED1 encountered")}},OP_RESERVED2:{code:138,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED2 encountered")}},OP_CHECKLOCKTIMEVERIFY:{code:177,category:"disabled",description:"Check locktime (disabled post-Genesis)",action:t=>{}},OP_CHECKSEQUENCEVERIFY:{code:178,category:"disabled",description:"Check sequence (disabled post-Genesis)",action:t=>{}},OP_PUBKEYHASH:{code:253,category:"pseudo",description:"Template matching: public key hash",action:"// Template matching only"},OP_PUBKEY:{code:254,category:"pseudo",description:"Template matching: public key",action:"// Template matching only"},OP_INVALIDOPCODE:{code:255,category:"pseudo",description:"Invalid opcode placeholder",action:()=>{throw new Error("Invalid opcode encountered")}}},o={getByCategory:t=>Object.entries(n).filter(([e,r])=>r.category===t).reduce((t,[e,r])=>({...t,[e]:r}),{}),getCategories:()=>{const t=new Set;return Object.values(n).forEach(e=>t.add(e.category)),Array.from(t).sort()},createASM:e=>{const r=[];return e.forEach(e=>{if("string"==typeof e&&n[e])r.push(e);else if("number"==typeof e)if(e>=1&&e<=16)r.push("OP_"+e);else if(0===e)r.push("OP_0");else if(-1===e)r.push("OP_1NEGATE");else{const t=i.encode(e);r.push(t.toString("hex"))}else{if(!t.isBuffer(e))throw new Error("Invalid operation: "+e);r.push(e.toString("hex"))}}),r.join(" ")},simulate:(t,e=[])=>{const r=[...e],i=[],o=[];return t.forEach((t,e)=>{if(!n[t])throw new Error("Unknown opcode: "+t);const s=n[t],a=[...r];if("function"==typeof s.action)try{s.action(r,i),o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:r.map(t=>t.toString("hex")),description:s.description})}catch(r){throw o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:[],error:r.message,description:s.description}),r}else o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:a.map(t=>t.toString("hex")),note:s.action,description:s.description})}),{finalStack:r.map(t=>t.toString("hex")),finalAltStack:i.map(t=>t.toString("hex")),history:o}},opcodeToName:t=>{const e=Object.entries(n).find(([e,r])=>r.code===t);return e?e[0]:"UNKNOWN_"+t.toString(16).padStart(2,"0")},nameToOpcode:t=>n[t]&&n[t].code,generateCovenantTemplate:(e,r)=>{const i=[];return"value"===e&&(i.push("OP_SIZE"),i.push(52),i.push("OP_SUB"),i.push("OP_SPLIT"),i.push("OP_DROP"),i.push(8),i.push("OP_SPLIT"),i.push("OP_DROP")),r&&(i.push(t.from(r,"hex")),i.push("OP_EQUAL")),{operations:i,asm:o.createASM(i),description:`Extract ${e} field and compare with expected value`}}};if(e.exports={opcodeMap:n,scriptNum:i,utils:o},r.c[r.s]===e){console.log("🔧 Comprehensive Bitcoin Script Opcode Map"),console.log("=========================================="),console.log("Total opcodes mapped: "+Object.keys(n).length),console.log("\n📊 Categories:"),o.getCategories().forEach(t=>{const e=Object.values(n).filter(e=>e.category===t).length;console.log(` ${t}: ${e} opcodes`)}),console.log("\n🧪 Example: Stack manipulation simulation");try{const t=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],e=o.simulate(t);console.log("Operations:",t.join(" ")),console.log("Final stack:",e.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log("\n📝 Step-by-step execution:"),e.history.forEach(t=>{console.log(` ${t.step}. ${t.opcode}: ${t.description}`),console.log(` Stack: [${t.beforeStack.join(", ")}] → [${t.afterStack.join(", ")}]`)})}catch(t){console.log("❌ Simulation error:",t.message)}console.log("\n🎯 Example: Covenant template generation");const t=o.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",t.asm),console.log("Description:",t.description)}}).call(this,r(0).Buffer,r(23)(t))},function(t,e,r){const i=r(5);t.exports={PrivateKey:i.PrivateKey,PublicKey:i.PublicKey,Address:i.Address,Transaction:i.Transaction,Script:i.Script,crypto:i.crypto,LTP:i.LTP,prepareRightToken:i.prepareRightToken,prepareRightTokenVerification:i.prepareRightTokenVerification,prepareRightTokenTransfer:i.prepareRightTokenTransfer,prepareRightTypeValidation:i.prepareRightTypeValidation,prepareObligationToken:i.prepareObligationToken,prepareObligationVerification:i.prepareObligationVerification,prepareObligationFulfillment:i.prepareObligationFulfillment,prepareObligationBreachAssessment:i.prepareObligationBreachAssessment,prepareObligationMonitoringReport:i.prepareObligationMonitoringReport,prepareClaimValidation:i.prepareClaimValidation,prepareClaimAttestation:i.prepareClaimAttestation,prepareClaimDispute:i.prepareClaimDispute,prepareBulkClaimValidation:i.prepareBulkClaimValidation,prepareClaimTemplate:i.prepareClaimTemplate,prepareSignatureProof:i.prepareSignatureProof,prepareSignatureVerification:i.prepareSignatureVerification,prepareSelectiveDisclosure:i.prepareSelectiveDisclosure,prepareSelectiveDisclosureVerification:i.prepareSelectiveDisclosureVerification,prepareLegalValidityProof:i.prepareLegalValidityProof,prepareZeroKnowledgeProof:i.prepareZeroKnowledgeProof,prepareRegistry:i.prepareRegistry,prepareTokenRegistration:i.prepareTokenRegistration,prepareTokenApproval:i.prepareTokenApproval,prepareTokenRevocation:i.prepareTokenRevocation,prepareTokenStatusQuery:i.prepareTokenStatusQuery,prepareTokenSearch:i.prepareTokenSearch,prepareStatisticsQuery:i.prepareStatisticsQuery,prepareAuditLogQuery:i.prepareAuditLogQuery,prepareTokenCommitment:i.prepareTokenCommitment,prepareBatchCommitment:i.prepareBatchCommitment,verifyTokenAnchor:i.verifyTokenAnchor,formatRevocation:i.formatRevocation,getRightTypes:i.getRightTypes,getObligationTypes:i.getObligationTypes,getObligationPriority:i.getObligationPriority,getObligationStatus:i.getObligationStatus,getClaimSchemas:i.getClaimSchemas,getClaimSchemaNames:i.getClaimSchemaNames,getClaimSchema:i.getClaimSchema,createClaimTemplate:i.createClaimTemplate,canonicalizeClaim:i.canonicalizeClaim,hashClaim:i.hashClaim,addCustomClaimSchema:i.addCustomClaimSchema,version:"3.3.0",framework:"Legal Token Protocol",architecture:"primitives-only"}},function(t,e,r){"use strict";e.byteLength=function(t){var e=c(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,i=c(t),s=i[0],a=i[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[h++]=e>>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[h++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],s=0,a=r-n;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var n,o,s=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e){
17
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
18
+ e.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,u=(1<<a)-1,c=u>>1,h=-7,f=r?n-1:0,d=r?-1:1,l=t[e+f];for(f+=d,o=l&(1<<-h)-1,l>>=-h,h+=a;h>0;o=256*o+t[e+f],f+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=i;h>0;s=256*s+t[e+f],f+=d,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,i),o-=c}return(l?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,r,i,n,o){var s,a,u,c=8*o-n-1,h=(1<<c)-1,f=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,l=i?0:o-1,p=i?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(e*u-1)*Math.pow(2,n),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),s=0));n>=8;t[r+l]=255&a,l+=p,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;t[r+l]=255&s,l+=p,s/=256,c-=8);t[r+l-p]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){},function(t,e,r){"use strict";var i=r(1).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var o=t.charAt(n),s=o.charCodeAt(0);if(255!==e[s])throw new TypeError(o+" is ambiguous");e[s]=n}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return i.alloc(0);for(var r=0,n=0,o=0;t[r]===u;)n++,r++;for(var s=(t.length-r)*c+1>>>0,h=new Uint8Array(s);r<t.length;){var f=t.charCodeAt(r);if(f>255)return;var d=e[f];if(255===d)return;for(var l=0,p=s-1;(0!==d||l<o)&&-1!==p;p--,l++)d+=a*h[p]>>>0,h[p]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");o=l,r++}for(var g=s-o;g!==s&&0===h[g];)g++;var m=i.allocUnsafe(n+(s-g));m.fill(0,0,n);for(var y=n;g!==s;)m[y++]=h[g++];return m}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*h+1>>>0,f=new Uint8Array(c);o!==s;){for(var d=e[o],l=0,p=c-1;(0!==d||l<n)&&-1!==p;p--,l++)d+=256*f[p]>>>0,f[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=l,o++}for(var g=c-n;g!==c&&0===f[g];)g++;for(var m=u.repeat(r);g<c;++g)m+=t.charAt(f[g]);return m},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},function(t){t.exports={name:"elliptic",version:"6.6.1",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny <fedor@indutny.com>",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}},function(t,e){},function(t,e,r){"use strict";var i=r(13),n=r(6),o=r(63),s=r(50),a=i.assert;function u(t){s.call(this,"short",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(t,e,r,i){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(e,16),this.y=new n(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(t,e,r,i){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(e,16),this.y=new n(r,16),this.z=new n(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),t.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new n(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new n(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new n(t.a,16),b:new n(t.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:n.mont(t),r=new n(2).toRed(e).redInvm(),i=r.redNeg(),o=new n(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(o).fromRed(),i.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,i,o,s,a,u,c,h,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,l=this.n.clone(),p=new n(1),g=new n(0),m=new n(0),y=new n(1),b=0;0!==d.cmpn(0);){var v=l.div(d);c=l.sub(v.mul(d)),h=m.sub(v.mul(p));var _=y.sub(v.mul(g));if(!i&&c.cmp(f)<0)e=u.neg(),r=p,i=c.neg(),o=h;else if(i&&2==++b)break;u=c,l=d,d=c,m=p,p=h,y=g,g=_}s=c.neg(),a=h;var S=i.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(S)>=0&&(s=e,a=r),i.negative&&(i=i.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:i,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=n.mul(r.a),a=o.mul(i.a),u=n.mul(r.b),c=o.mul(i.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=i.fromRed().isOdd();return(e&&!o||!e&&o)&&(i=i.redNeg()),this.point(t,i)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],u=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),u=u.neg(!0)),i[2*o]=a,i[2*o+1]=u,n[2*o]=s.k1,n[2*o+1]=s.k2}for(var c=this._wnafMulAdd(1,i,n,2*o,r),h=0;h<2*o;h++)i[h]=null,n[h]=null;return c},o(c,s.BasePoint),u.prototype.point=function(t,e,r){return new c(this,t,e,r)},u.prototype.pointFromJSON=function(t,e){return c.fromJSON(this,t,e)},c.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},c.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},c.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var o=e[2];return i.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[i].concat(o.doubles.points.map(n))},naf:o.naf&&{wnd:o.naf.wnd,points:[i].concat(o.naf.points.map(n))}},i},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),s=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(t){return t=new n(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},c.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},c.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},c.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(h,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new h(this,t,e,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),h=c.redMul(a),f=i.redMul(c),d=u.redSqr().redIAdd(h).redISub(f).redISub(f),l=u.redMul(f.redISub(d)).redISub(o.redMul(h)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,l,p)},h.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(i),a=n.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),h=r.redMul(u),f=a.redSqr().redIAdd(c).redISub(h).redISub(h),d=a.redMul(h.redISub(f)).redISub(n.redMul(c)),l=this.z.redMul(s);return this.curve.jpoint(f,d,l)},h.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,o=this.x,s=this.y,a=this.z,u=a.redSqr().redSqr(),c=s.redAdd(s);for(e=0;e<t;e++){var h=o.redSqr(),f=c.redSqr(),d=f.redSqr(),l=h.redAdd(h).redIAdd(h).redIAdd(i.redMul(u)),p=o.redMul(f),g=l.redSqr().redISub(p.redAdd(p)),m=p.redISub(g),y=l.redMul(m);y=y.redIAdd(y).redISub(d);var b=c.redMul(a);e+1<t&&(u=u.redMul(d)),o=g,a=b,c=y}return this.curve.jpoint(o,c.redMul(n),a)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},h.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(o);s=s.redIAdd(s);var a=i.redAdd(i).redIAdd(i),u=a.redSqr().redISub(s).redISub(s),c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),t=u,e=a.redMul(s.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var h=this.x.redSqr(),f=this.y.redSqr(),d=f.redSqr(),l=this.x.redAdd(f).redSqr().redISub(h).redISub(d);l=l.redIAdd(l);var p=h.redAdd(h).redIAdd(h),g=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=g.redISub(l).redISub(l),e=p.redMul(l.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},h.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(o);s=s.redIAdd(s);var a=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),u=a.redSqr().redISub(s).redISub(s);t=u;var c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),e=a.redMul(s.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var h=this.z.redSqr(),f=this.y.redSqr(),d=this.x.redMul(f),l=this.x.redSub(h).redMul(this.x.redAdd(h));l=l.redAdd(l).redIAdd(l);var p=d.redIAdd(d),g=(p=p.redIAdd(p)).redAdd(p);t=l.redSqr().redISub(g),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(h);var m=f.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=l.redMul(p.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},h.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(n)),u=e.redAdd(e),c=(u=u.redIAdd(u)).redMul(s),h=a.redSqr().redISub(c.redAdd(c)),f=c.redISub(h),d=s.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=a.redMul(f).redISub(d),p=r.redAdd(r).redMul(i);return this.curve.jpoint(h,l,p)},h.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),o=n.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(i),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),u=i.redIAdd(i);u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var c=n.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(u),h=e.redMul(c);h=(h=h.redIAdd(h)).redIAdd(h);var f=this.x.redMul(a).redISub(h);f=(f=f.redIAdd(f)).redIAdd(f);var d=this.y.redMul(c.redMul(u.redISub(c)).redISub(s.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,d,l)},h.prototype.mul=function(t,e){return t=new n(t,e),this.curve._wnafMul(this,t)},h.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},h.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},h.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(t,e,r){"use strict";var i=r(6),n=r(63),o=r(50),s=r(13);function a(t){o.call(this,"mont",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,o),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},n(u,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new u(this,t,e)},a.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(t,e){return new u(t,e[0],e[1]||t.one)},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=n.redMul(i),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},u.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var o=n.length-1;o>=0;o--)0===n[o]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var i=r(13),n=r(6),o=r(63),s=r(50),a=i.assert;function u(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,s.call(this,"edwards",t),this.a=new n(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function c(t,e,r,i,o){s.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new n(e,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=o&&new n(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,s),t.exports=u,u.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},u.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},u.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},u.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=i.redMul(o.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var u=a.fromRed().isOdd();return(e&&!u||!e&&u)&&(a=a.redNeg()),this.point(t,a)},u.prototype.pointFromY=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=i.redMul(o.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},u.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},o(c,s.BasePoint),u.prototype.pointFromJSON=function(t){return c.fromJSON(this,t)},u.prototype.point=function(t,e,r,i){return new c(this,t,e,r,i)},c.fromJSON=function(t,e){return new c(t,e[0],e[1],e[2])},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=i.redAdd(e),s=o.redSub(r),a=i.redSub(e),u=n.redMul(s),c=o.redMul(a),h=n.redMul(a),f=s.redMul(o);return this.curve.point(u,c,f,h)},c.prototype._projDbl=function(){var t,e,r,i,n,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(i=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(i.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(n=this.z.redSqr(),o=c.redSub(n).redISub(n),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(i.redSub(u)),r=c.redMul(o))}else i=a.redAdd(u),n=this.curve._mulC(this.z).redSqr(),o=i.redSub(n).redSub(n),t=this.curve._mulC(s.redISub(i)).redMul(o),e=this.curve._mulC(i).redMul(a.redISub(u)),r=i.redMul(o);return this.curve.point(t,e,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=n.redSub(i),a=n.redAdd(i),u=r.redAdd(e),c=o.redMul(s),h=a.redMul(u),f=o.redMul(u),d=s.redMul(a);return this.curve.point(c,h,d,f)},c.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=n.redSub(a),c=n.redAdd(a),h=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),f=i.redMul(u).redMul(h);return this.curve.twisted?(e=i.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=i.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(f,e,r)},c.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},c.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},c.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},c.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(t,e,r){"use strict";e.sha1=r(162),e.sha224=r(163),e.sha256=r(96),e.sha384=r(164),e.sha512=r(97)},function(t,e,r){"use strict";var i=r(19),n=r(35),o=r(95),s=i.rotl32,a=i.sum32,u=i.sum32_5,c=o.ft_1,h=n.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;h.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(d,h),t.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=s(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],o=this.h[1],h=this.h[2],d=this.h[3],l=this.h[4];for(i=0;i<r.length;i++){var p=~~(i/20),g=u(s(n,5),c(p,o,h,d),l,r[i],f[p]);l=d,d=h,h=s(o,30),o=n,n=g}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],h),this.h[3]=a(this.h[3],d),this.h[4]=a(this.h[4],l)},d.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){"use strict";var i=r(19),n=r(96);function o(){if(!(this instanceof o))return new o;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(o,n),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},function(t,e,r){"use strict";var i=r(19),n=r(97);function o(){if(!(this instanceof o))return new o;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(o,n),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},function(t,e,r){"use strict";var i=r(19),n=r(35),o=i.rotl32,s=i.sum32,a=i.sum32_3,u=i.sum32_4,c=n.BlockHash;function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function f(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function d(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function l(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(h,c),e.ripemd160=h,h.blockSize=512,h.outSize=160,h.hmacStrength=192,h.padLength=64,h.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],c=this.h[3],h=this.h[4],b=r,v=i,_=n,S=c,w=h,I=0;I<80;I++){var A=s(o(u(r,f(I,i,n,c),t[p[I]+e],d(I)),m[I]),h);r=h,h=c,c=o(n,10),n=i,i=A,A=s(o(u(b,f(79-I,v,_,S),t[g[I]+e],l(I)),y[I]),w),b=w,w=S,S=o(_,10),_=v,v=A}A=a(this.h[1],n,S),this.h[1]=a(this.h[2],c,w),this.h[2]=a(this.h[3],h,b),this.h[3]=a(this.h[4],r,v),this.h[4]=a(this.h[0],i,_),this.h[0]=A},h.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var p=[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],g=[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],m=[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],y=[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]},function(t,e,r){"use strict";var i=r(19),n=r(14);function o(t,e,r){if(!(this instanceof o))return new o(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,r))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),n(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},function(t,e){t.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(t,e,r){"use strict";var i=r(6),n=r(169),o=r(13),s=r(64),a=r(62),u=o.assert,c=r(170),h=r(171);function f(t){if(!(this instanceof f))return new f(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=f,f.prototype.keyPair=function(t){return new c(this,t)},f.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},f.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},f.prototype.genKeyPair=function(t){t||(t={});for(var e=new n({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new i(2));;){var s=new i(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},f.prototype._truncateToN=function(t,e,r){var n;if(i.isBN(t)||"number"==typeof t)n=(t=new i(t,16)).byteLength();else if("object"==typeof t)n=t.length,t=new i(t,16);else{var o=t.toString();n=o.length+1>>>1,t=new i(o,16)}"number"!=typeof r&&(r=8*n);var s=r-this.n.bitLength();return s>0&&(t=t.ushrn(s)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},f.prototype.sign=function(t,e,r,o){if("object"==typeof r&&(o=r,r=null),o||(o={}),"string"!=typeof t&&"number"!=typeof t&&!i.isBN(t)){u("object"==typeof t&&t&&"number"==typeof t.length,"Expected message to be an array-like, a hex string, or a BN instance"),u(t.length>>>0===t.length);for(var s=0;s<t.length;s++)u((255&t[s])===t[s])}e=this.keyFromPrivate(e,r),t=this._truncateToN(t,!1,o.msgBitLength),u(!t.isNeg(),"Can not sign a negative message");var a=this.n.byteLength(),c=e.getPrivate().toArray("be",a),f=t.toArray("be",a);u(new i(f).eq(t),"Can not sign message");for(var d=new n({hash:this.hash,entropy:c,nonce:f,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new i(1)),p=0;;p++){var g=o.k?o.k(p):new i(d.generate(this.n.byteLength()));if(!((g=this._truncateToN(g,!0)).cmpn(1)<=0||g.cmp(l)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var y=m.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var v=g.invm(this.n).mul(b.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var _=(m.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),_^=1),new h({r:b,s:v,recoveryParam:_})}}}}}},f.prototype.verify=function(t,e,r,i,n){n||(n={}),t=this._truncateToN(t,!1,n.msgBitLength),r=this.keyFromPublic(r,i);var o=(e=new h(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),f=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),f)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),f)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},f.prototype.recoverPubKey=function(t,e,r,n){u((3&r)===r,"The recovery param is more than two bits"),e=new h(e,n);var o=this.n,s=new i(t),a=e.r,c=e.s,f=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=e.r.invm(o),p=o.sub(s).mul(l).umod(o),g=c.mul(l).umod(o);return this.g.mulAdd(p,a,g)},f.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new h(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(t,e,n)}catch(t){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var i=r(51),n=r(93),o=r(14);function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=n.toArray(t.entropy,t.entropyEnc||"hex"),r=n.toArray(t.nonce,t.nonceEnc||"hex"),i=n.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}t.exports=s,s.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},s.prototype._hmac=function(){return new i.hmac(this.hash,this.K)},s.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},s.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=n.toArray(t,e),r=n.toArray(r,i),o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=n.toArray(r,i||"hex"),this._update(r));for(var o=[];o.length<t;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var s=o.slice(0,t);return this._update(r),this._reseed++,n.encode(s,e)}},function(t,e,r){"use strict";var i=r(6),n=r(13).assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?n(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||n(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e,r){return this.ec.verify(t,e,this,void 0,r)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(t,e,r){"use strict";var i=r(6),n=r(13),o=n.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new i(t.r,16),this.s=new i(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function u(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;if(0===t[e.place])return!1;for(var n=0,o=0,s=e.place;o<i;o++,s++)n<<=8,n|=t[s],n>>>=0;return!(n<=127)&&(e.place=s,n)}function c(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function h(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=s,s.prototype._importDER=function(t,e){t=n.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var o=u(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=u(t,r);if(!1===s)return!1;if(0!=(128&t[r.place]))return!1;var c=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var h=u(t,r);if(!1===h)return!1;if(t.length!==h+r.place)return!1;if(0!=(128&t[r.place]))return!1;var f=t.slice(r.place,h+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new i(c),this.s=new i(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=c(e),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];h(i,e.length),(i=i.concat(e)).push(2),h(i,r.length);var o=i.concat(r),s=[48];return h(s,o.length),s=s.concat(o),n.encode(s,t)}},function(t,e,r){"use strict";var i=r(51),n=r(64),o=r(13),s=o.assert,a=o.parseBytes,u=r(173),c=r(174);function h(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof h))return new h(t);t=n[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=i.sha512}t.exports=h,h.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),o=this.encodePoint(n),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=i.add(s).umod(this.curve.n);return this.makeSignature({R:n,S:u,Rencoded:o})},h.prototype.verify=function(t,e,r){if(t=a(t),(e=this.makeSignature(e)).S().gte(e.eddsa.curve.n)||e.S().isNeg())return!1;var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(o)},h.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return o.intFromLE(t.digest()).umod(this.curve.n)},h.prototype.keyFromPublic=function(t){return u.fromPublic(this,t)},h.prototype.keyFromSecret=function(t){return u.fromSecret(this,t)},h.prototype.makeSignature=function(t){return t instanceof c?t:new c(this,t)},h.prototype.encodePoint=function(t){var e=t.getY().toArray("le",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},h.prototype.decodePoint=function(t){var e=(t=o.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),i=0!=(128&t[e]),n=o.intFromLE(r);return this.curve.pointFromY(n,i)},h.prototype.encodeInt=function(t){return t.toArray("le",this.encodingLength)},h.prototype.decodeInt=function(t){return o.intFromLE(t)},h.prototype.isPoint=function(t){return t instanceof this.pointClass}},function(t,e,r){"use strict";var i=r(13),n=i.assert,o=i.parseBytes,s=i.cachedProperty;function a(t,e){this.eddsa=t,this._secret=o(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=o(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},s(a,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),s(a,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(a,"privBytes",(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),s(a,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),s(a,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(a,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(t){return n(this._secret,"KeyPair can only verify"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return n(this._secret,"KeyPair is public only"),i.encode(this.secret(),t)},a.prototype.getPublic=function(t){return i.encode(this.pubBytes(),t)},t.exports=a},function(t,e,r){"use strict";var i=r(6),n=r(13),o=n.assert,s=n.cachedProperty,a=n.parseBytes;function u(t,e){this.eddsa=t,"object"!=typeof e&&(e=a(e)),Array.isArray(e)&&(o(e.length===2*t.encodingLength,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),o(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof i&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}s(u,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(u,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(u,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),s(u,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),u.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},u.prototype.toHex=function(){return n.encode(this.toBytes(),"hex").toUpperCase()},t.exports=u},function(t){t.exports={name:"smartledger-bsv",version:"3.3.0",description:"🚀 Complete Bitcoin SV development framework with Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), Shamir Secret Sharing, and 9 flexible loading options. Includes primitives-only architecture for maximum integration flexibility, SmartContract framework, covenant builder, and comprehensive Bitcoin SV API. Perfect for legal tokens, DeFi, smart contracts, and secure Bitcoin applications.",author:"SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",homepage:"https://github.com/codenlighten/smartledger-bsv#readme",bugs:{url:"https://github.com/codenlighten/smartledger-bsv/issues"},main:"index.js",scripts:{lint:"standard",test:"standard && mocha","test:ltp":"node complete_ltp_demo.js","test:ltp-primitives":"node simple_demo.js","test:architecture":"node architecture_demo.js","test:js2script":"node lib/smart_contract/opcode_map.js && node lib/smart_contract/covenant_builder.js","test:opcodes":"node lib/smart_contract/opcode_list.js","test:covenants":"node examples/covenants/advanced_covenant_demo.js","test:scripts":"node examples/scripts/custom_script_signature_test.js","test:basic":"node examples/basic/transaction-creation.js","test:all":"npm test && npm run test:covenants && npm run test:scripts",coverage:"nyc --reporter=text npm run test","build-bsv":'NODE_OPTIONS="--openssl-legacy-provider" webpack index.js --config build/webpack.config.js',"build-ecies":'NODE_OPTIONS="--openssl-legacy-provider" webpack ecies/index.js --config build/webpack.subproject.config.js --output-library bsvEcies -o bsv-ecies.min.js',"build-message":'NODE_OPTIONS="--openssl-legacy-provider" webpack message/index.js --config build/webpack.subproject.config.js --output-library bsvMessage -o bsv-message.min.js',"build-mnemonic":'NODE_OPTIONS="--openssl-legacy-provider" webpack mnemonic/index.js --config build/webpack.subproject.config.js --output-library bsvMnemonic -o bsv-mnemonic.min.js',"build-shamir":'NODE_OPTIONS="--openssl-legacy-provider" webpack shamir-entry.js --config build/webpack.subproject.config.js --output-library bsvShamir -o bsv-shamir.min.js',"build-ltp":'NODE_OPTIONS="--openssl-legacy-provider" webpack ltp-entry.js --config build/webpack.ltp.config.js',"build-smartcontract":'NODE_OPTIONS="--openssl-legacy-provider" webpack smartcontract-entry.js --config build/webpack.smartcontract.config.js',"build-covenant":'NODE_OPTIONS="--openssl-legacy-provider" webpack covenant-entry.js --config build/webpack.covenant.config.js',"build-script-helper":'NODE_OPTIONS="--openssl-legacy-provider" webpack script-helper-entry.js --config build/webpack.script-helper.config.js',"build-security":'NODE_OPTIONS="--openssl-legacy-provider" webpack security-entry.js --config build/webpack.security.config.js',"build-bundle":'NODE_OPTIONS="--openssl-legacy-provider" webpack bundle-entry.js --config build/webpack.bundle.config.js',build:"npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic && npm run build-shamir && npm run build-gdaf && npm run build-smartcontract","build-specialized":"npm run build-covenant && npm run build-script-helper && npm run build-security","build-all":"npm run build && npm run build-bundle && npm run build-specialized","test:browser":"echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'","test:bundle":"echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",demo:"npm run test:covenants","demo:basic":"npm run test:basic","demo:scripts":"npm run test:scripts","demo:preimage":"echo '🧠 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js","preimage:extract":"node examples/preimage/extract_preimage_bidirectional.js",prepublishOnly:'NODE_OPTIONS="--openssl-legacy-provider" npm run build'},unpkg:"bsv.min.js",jsdelivr:"bsv.min.js",cdn:"bsv.min.js",files:["index.js","lib/","utilities/","ecies/","message/","mnemonic/","build/","tests/","*-entry.js","bsv.min.js","bsv.bundle.js","bsv-ecies.min.js","bsv-message.min.js","bsv-mnemonic.min.js","bsv-shamir.min.js","bsv-gdaf.min.js","bsv-ltp.min.js","bsv-smartcontract.min.js","bsv-covenant.min.js","bsv-script-helper.min.js","bsv-security.min.js","bsv.d.ts","validation_test.js","test_shamir.js","shamir_demo.js","complete_ltp_demo.js","simple_demo.js","architecture_demo.js","test_standalone_shamir.html","docs/","examples/","LICENSE","README.md","SECURITY.md","CHANGELOG.md"],keywords:["bitcoin","bitcoin-sv","bsv","legal-token-protocol","ltp","legal-tokens","primitives-only","legal-compliance","property-rights","obligations","attestations","gdaf","global-digital-attestation","w3c-credentials","verifiable-credentials","decentralized-identity","shamir-secret-sharing","threshold-cryptography","cryptocurrency","blockchain","smart-contracts","defi","covenant","covenants","script-debugger","debug-tools","modular-loading","standalone-modules","security-hardened","elliptic-curve-fix","smartledger","transaction","address","signature","wallet","hd-wallet","mnemonic","ecies","encryption","message-signing","pushtx","pels","bip143","preimage","shamir-secret-sharing","threshold-cryptography","secret-splitting","global-digital-attestation","gdaf","verifiable-credentials","w3c-credentials","decentralized-identity","did-resolution","zero-knowledge-proofs","blockchain-anchoring","attestation-framework","nchain","custom-scripts","multisig","timelock","conditional-scripts","utxo-management","ultra-low-fees","javascript-to-script","opcode-mapping","covenant-builder","script-simulation","bitcoin-script","asm-generation","advanced-features","script-development","blockchain-simulator","miner-simulator","testing-tools","development-framework","browser-compatible","nodejs-compatible","webpack-ready","cdn-ready","typescript-definitions","vulnerability-free","drop-in-replacement","performance-optimized","bip21","bip32","bip37","bip69","bip70"],repository:{type:"git",url:"https://github.com/codenlighten/smartledger-bsv"},browser:{request:"browser-request"},dependencies:{"aes-js":"^3.1.2","bn.js":"=4.11.9",bs58:"=4.0.1","clone-deep":"^4.0.1",elliptic:"6.6.1","hash.js":"^1.1.7",inherits:"2.0.3",unorm:"1.4.1"},devDependencies:{brfs:"2.0.1",chai:"4.2.0",mocha:"^8.4.0",nyc:"^14.1.1",sinon:"7.2.3",standard:"12.0.1",webpack:"4.29.3","webpack-cli":"^3.3.12"},license:"MIT",standard:{globals:["after","afterEach","before","beforeEach","describe","it"],ignore:["dist/**"]}}},function(t,e,r){"use strict";var i="https://docs.moneybutton.com/";t.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: "+i+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"}]}]},function(t,e,r){"use strict";(function(e){var i=r(51),n=r(4),o=t.exports;o.sha1=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha1().update(t).digest("hex"),"hex")},o.sha1.blocksize=512,o.sha256=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha256().update(t).digest("hex"),"hex")},o.sha256.blocksize=512,o.sha256sha256=function(t){return n.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.ripemd160().update(t).digest("hex"),"hex")},o.sha256ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha512().update(t).digest("hex"),"hex")},o.sha512.blocksize=1024,o.hmac=function(t,r,i){n.checkArgument(e.isBuffer(r)),n.checkArgument(e.isBuffer(i)),n.checkArgument(t.blocksize);var o=t.blocksize/8;if(i.length>o)i=t(i);else if(i<o){var s=e.alloc(o);s.fill(0),i.copy(s),i=s}var a=e.alloc(o);a.fill(92);var u=e.alloc(o);u.fill(54);for(var c=e.alloc(o),h=e.alloc(o),f=0;f<o;f++)c[f]=a[f]^i[f],h[f]=u[f]^i[f];return t(e.concat([c,t(e.concat([h,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(15),n=r(4),o=t.exports;o.sha1=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha1").update(t).digest()},o.sha1.blocksize=512,o.sha256=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha256").update(t).digest()},o.sha256.blocksize=512,o.sha256sha256=function(t){return n.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("ripemd160").update(t).digest()},o.sha256ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha512").update(t).digest()},o.sha512.blocksize=1024,o.hmac=function(t,r,i){n.checkArgument(e.isBuffer(r)),n.checkArgument(e.isBuffer(i)),n.checkArgument(t.blocksize);var o=t.blocksize/8;if(i.length>o)i=t(i);else if(i<o){var s=e.alloc(o);s.fill(0),i.copy(s),i=s}var a=e.alloc(o);a.fill(92);var u=e.alloc(o);u.fill(54);for(var c=e.alloc(o),h=e.alloc(o),f=0;f<o;f++)c[f]=a[f]^i[f],h[f]=u[f]^i[f];return t(e.concat([c,t(e.concat([h,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(98).Transform;function o(t){n.call(this),this._block=i.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(193)(o,n),o.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)};var s="undefined"!=typeof Uint8Array,a="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(i.prototype instanceof Uint8Array||i.TYPED_ARRAY_SUPPORT);o.prototype.update=function(t,e){if(this._finalized)throw new Error("Digest already called");t=function(t,e){if(t instanceof i)return t;if("string"==typeof t)return i.from(t,e);if(a&&ArrayBuffer.isView(t)){if(0===t.byteLength)return i.alloc(0);var r=i.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(s&&t instanceof Uint8Array)return i.from(t);if(i.isBuffer(t)&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return i.from(t);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e);for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[n++];this._update(),this._blockOffset=0}for(;n<t.length;)r[this._blockOffset++]=t[n++];for(var u=0,c=8*t.length;c>0;++u)this._length[u]+=c,(c=this._length[u]/4294967296|0)>0&&(this._length[u]-=4294967296*c);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){},function(t,e,r){"use strict";var i=r(68).Buffer,n=r(183);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return i.alloc(0);for(var e,r,n,o=i.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,r=o,n=a,e.copy(r,n),a+=s.data.length,s=s.next;return o},t}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,r){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(n.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new o(n.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(185),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(12))},function(t,e,r){(function(t,e){!function(t,r){"use strict";if(!t.setImmediate){var i,n,o,s,a,u=1,c={},h=!1,f=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?i=function(t){e.nextTick((function(){p(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=r,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){p(t.data)},i=function(t){o.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(n=f.documentElement,i=function(t){var e=f.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,n.removeChild(e),e=null},n.appendChild(e)}):i=function(t){setTimeout(p,0,t)}:(s="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(s)&&p(+e.data.slice(s.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),i=function(e){t.postMessage(s+e,"*")}),d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r<e.length;r++)e[r]=arguments[r+1];var n={callback:t,args:e};return c[u]=n,i(u),u++},d.clearImmediate=l}function l(t){delete c[t]}function p(t){if(h)setTimeout(p,0,t);else{var e=c[t];if(e){h=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(void 0,r)}}(e)}finally{l(t),h=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,r(12),r(11))},function(t,e,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(t){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(t,e){if(r("noDeprecation"))return t;var i=!1;return function(){if(!i){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),i=!0}return t.apply(this,arguments)}}}).call(this,r(12))},function(t,e,r){var i=r(0),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(o(i,e),e.Buffer=s),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";t.exports=o;var i=r(102),n=Object.create(r(38));function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}n.inherits=r(3),n.inherits(o,i),o.prototype._transform=function(t,e,r){r(null,t)}},function(t,e,r){t.exports=r(69)},function(t,e,r){t.exports=r(28)},function(t,e,r){t.exports=r(37).Transform},function(t,e,r){t.exports=r(37).PassThrough},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(195),o=r(37).Transform;function s(t){o.call(this),this._block=i.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(103)(s,o),s.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},s.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},s.prototype.update=function(t,e){if(this._finalized)throw new Error("Digest already called");for(var r=n(t,e),i=this._block,o=0;this._blockOffset+r.length-o>=this._blockSize;){for(var s=this._blockOffset;s<this._blockSize;)i[s]=r[o],s+=1,o+=1;this._update(),this._blockOffset=0}for(;o<r.length;)i[this._blockOffset]=r[o],this._blockOffset+=1,o+=1;for(var a=0,u=8*r.length;u>0;++a)this._length[a]+=u,(u=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*u);return this},s.prototype._update=function(){throw new Error("_update is not implemented")},s.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},s.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=s},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(53),o="undefined"!=typeof Uint8Array,s=o&&"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView;t.exports=function(t,e){if("string"==typeof t||i.isBuffer(t)||o&&t instanceof Uint8Array||s&&s(t))return n(t,e);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){"use strict";var i=r(39),n=r(72)("TypedArray.prototype.buffer",!0),o=r(217);t.exports=n||function(t){if(!o(t))throw new i("Not a Typed Array");return t.buffer}},function(t,e,r){"use strict";t.exports=Error},function(t,e,r){"use strict";t.exports=EvalError},function(t,e,r){"use strict";t.exports=RangeError},function(t,e,r){"use strict";t.exports=ReferenceError},function(t,e,r){"use strict";t.exports=URIError},function(t,e,r){"use strict";t.exports=Math.abs},function(t,e,r){"use strict";t.exports=Math.floor},function(t,e,r){"use strict";t.exports=Math.max},function(t,e,r){"use strict";t.exports=Math.min},function(t,e,r){"use strict";t.exports=Math.pow},function(t,e,r){"use strict";t.exports=Math.round},function(t,e,r){"use strict";var i=r(210);t.exports=function(t){return i(t)||0===t?t:t<0?-1:1}},function(t,e,r){"use strict";t.exports=Number.isNaN||function(t){return t!=t}},function(t,e,r){"use strict";t.exports=Object.getOwnPropertyDescriptor},function(t,e,r){"use strict";var i="undefined"!=typeof Symbol&&Symbol,n=r(74);t.exports=function(){return"function"==typeof i&&("function"==typeof Symbol&&("symbol"==typeof i("foo")&&("symbol"==typeof Symbol("bar")&&n())))}},function(t,e,r){"use strict";var i,n=r(75),o=r(40);try{i=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var s=!!i&&o&&o(Object.prototype,"__proto__"),a=Object,u=a.getPrototypeOf;t.exports=s&&"function"==typeof s.get?n([s.get]):"function"==typeof u&&function(t){return u(null==t?t:a(t))}},function(t,e,r){"use strict";var i="Function.prototype.bind called on incompatible ",n=Object.prototype.toString,o=Math.max,s=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r},a=function(t,e){for(var r=[],i=e||0,n=0;i<t.length;i+=1,n+=1)r[n]=t[i];return r},u=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r};t.exports=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==n.apply(e))throw new TypeError(i+e);for(var r,c=a(arguments,1),h=function(){if(this instanceof r){var i=e.apply(this,s(c,arguments));return Object(i)===i?i:this}return e.apply(t,s(c,arguments))},f=o(0,e.length-c.length),d=[],l=0;l<f;l++)d[l]="$"+l;if(r=Function("binder","return function ("+u(d,",")+"){ return binder.apply(this,arguments); }")(h),e.prototype){var p=function(){};p.prototype=e.prototype,r.prototype=new p,p.prototype=null}return r}},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(t,e,r){"use strict";var i=Function.prototype.call,n=Object.prototype.hasOwnProperty,o=r(41);t.exports=o.call(i,n)},function(t,e,r){"use strict";var i=r(218);t.exports=function(t){return!!i(t)}},function(t,e,r){"use strict";(function(e){var i=r(219),n=r(221),o=r(223),s=r(72),a=r(40),u=r(106),c=s("Object.prototype.toString"),h=r(228)(),f="undefined"==typeof globalThis?e:globalThis,d=n(),l=s("String.prototype.slice"),p=s("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},g={__proto__:null};i(d,h&&a&&u?function(t){var e=new f[t];if(Symbol.toStringTag in e&&u){var r=u(e),i=a(r,Symbol.toStringTag);if(!i&&r){var n=u(r);i=a(n,Symbol.toStringTag)}g["$"+t]=o(i.get)}}:function(t){var e=new f[t],r=e.slice||e.set;r&&(g["$"+t]=o(r))});t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!h){var e=l(c(t),8,-1);return p(d,e)>-1?e:"Object"===e&&function(t){var e=!1;return i(g,(function(r,i){if(!e)try{r(t),e=l(i,1)}catch(t){}})),e}(t)}return a?function(t){var e=!1;return i(g,(function(r,i){if(!e)try{"$"+r(t)===i&&(e=l(i,1))}catch(t){}})),e}(t):null}}).call(this,r(12))},function(t,e,r){"use strict";var i=r(220),n=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=function(t,e,r){for(var i=0,n=t.length;i<n;i++)o.call(t,i)&&(null==r?e(t[i],i,t):e.call(r,t[i],i,t))},a=function(t,e,r){for(var i=0,n=t.length;i<n;i++)null==r?e(t.charAt(i),i,t):e.call(r,t.charAt(i),i,t)},u=function(t,e,r){for(var i in t)o.call(t,i)&&(null==r?e(t[i],i,t):e.call(r,t[i],i,t))};function c(t){return"[object Array]"===n.call(t)}t.exports=function(t,e,r){if(!i(e))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=r),c(t)?s(t,e,n):"string"==typeof t?a(t,e,n):u(t,e,n)}},function(t,e,r){"use strict";var i,n,o=Function.prototype.toString,s="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof s&&"function"==typeof Object.defineProperty)try{i=Object.defineProperty({},"length",{get:function(){throw n}}),n={},s((function(){throw 42}),null,i)}catch(t){t!==n&&(s=null)}else s=null;var a=/^\s*class\b/,u=function(t){try{var e=o.call(t);return a.test(e)}catch(t){return!1}},c=function(t){try{return!u(t)&&(o.call(t),!0)}catch(t){return!1}},h=Object.prototype.toString,f="function"==typeof Symbol&&!!Symbol.toStringTag,d=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var p=document.all;h.call(p)===h.call(document.all)&&(l=function(t){if((d||!t)&&(void 0===t||"object"==typeof t))try{var e=h.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=s?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{s(t,null,i)}catch(t){if(t!==n)return!1}return!u(t)&&c(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(f)return c(t);if(u(t))return!1;var e=h.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&c(t)}},function(t,e,r){"use strict";(function(e){var i=r(222),n="undefined"==typeof globalThis?e:globalThis;t.exports=function(){for(var t=[],e=0;e<i.length;e++)"function"==typeof n[i[e]]&&(t[t.length]=i[e]);return t}}).call(this,r(12))},function(t,e,r){"use strict";t.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},function(t,e,r){"use strict";var i=r(224),n=r(54),o=r(75),s=r(227);t.exports=function(t){var e=o(arguments),r=t.length-(arguments.length-1);return i(e,1+(r>0?r:0),!0)},n?n(t.exports,"apply",{value:s}):t.exports.apply=s},function(t,e,r){"use strict";var i=r(104),n=r(225),o=r(226)(),s=r(40),a=r(39),u=i("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new a("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new a("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,c=!0;if("length"in t&&s){var h=s(t,"length");h&&!h.configurable&&(i=!1),h&&!h.writable&&(c=!1)}return(i||c||!r)&&(o?n(t,"length",e,!0,!0):n(t,"length",e)),t}},function(t,e,r){"use strict";var i=r(54),n=r(105),o=r(39),s=r(40);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,h=arguments.length>6&&arguments[6],f=!!s&&s(t,e);if(i)i(t,e,{configurable:null===c&&f?f.configurable:!c,enumerable:null===a&&f?f.enumerable:!a,value:r,writable:null===u&&f?f.writable:!u});else{if(!h&&(a||u||c))throw new n("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},function(t,e,r){"use strict";var i=r(54),n=function(){return!!i};n.hasArrayLengthDefineBug=function(){if(!i)return null;try{return 1!==i([],"length",{value:1}).length}catch(t){return!0}},t.exports=n},function(t,e,r){"use strict";var i=r(41),n=r(77),o=r(109);t.exports=function(){return o(i,n,arguments)}},function(t,e,r){"use strict";var i=r(74);t.exports=function(){return i()&&!!Symbol.toStringTag}},function(t,e,r){"use strict";var i=r(32),n=r(33),o=r(1).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,n.call(this,64,56)}function c(t){return t<<30|t>>>2}function h(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}i(u,n),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,n=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=t.readInt32BE(4*f);for(;f<80;++f)r[f]=r[f-3]^r[f-8]^r[f-14]^r[f-16];for(var d=0;d<80;++d){var l=~~(d/20),p=0|((e=i)<<5|e>>>27)+h(l,n,o,a)+u+r[d]+s[l];u=a,a=o,o=c(n),n=i,i=p}this._a=i+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},function(t,e,r){"use strict";var i=r(32),n=r(33),o=r(1).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,n.call(this,64,56)}function c(t){return t<<5|t>>>27}function h(t){return t<<30|t>>>2}function f(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}i(u,n),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,n=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,d=0;d<16;++d)r[d]=t.readInt32BE(4*d);for(;d<80;++d)r[d]=(e=r[d-3]^r[d-8]^r[d-14]^r[d-16])<<1|e>>>31;for(var l=0;l<80;++l){var p=~~(l/20),g=c(i)+f(p,n,o,a)+u+r[l]+s[p]|0;u=a,a=o,o=h(n),n=i,i=g}this._a=i+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},function(t,e,r){"use strict";var i=r(32),n=r(110),o=r(33),s=r(1).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}i(u,n),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},function(t,e,r){"use strict";var i=r(32),n=r(111),o=r(33),s=r(1).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}i(u,n),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i=r(3),n=r(1).Buffer,o=r(24),s=n.alloc(128);function a(t,e){o.call(this,"digest"),"string"==typeof e&&(e=n.from(e)),this._alg=t,this._key=e,e.length>64?e=t(e):e.length<64&&(e=n.concat([e,s],64));for(var r=this._ipad=n.allocUnsafe(64),i=this._opad=n.allocUnsafe(64),a=0;a<64;a++)r[a]=54^e[a],i[a]=92^e[a];this._hash=[r]}i(a,o),a.prototype._update=function(t){this._hash.push(t)},a.prototype._final=function(){var t=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,t]))},t.exports=a},function(t,e,r){"use strict";t.exports=r(114)},function(t,e,r){"use strict";(function(e){var i,n,o=r(1).Buffer,s=r(116),a=r(117),u=r(118),c=r(119),h=e.crypto&&e.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},d=[];function l(){return n||(n=e.process&&e.process.nextTick?e.process.nextTick:e.queueMicrotask?e.queueMicrotask:e.setImmediate?e.setImmediate:e.setTimeout)}function p(t,e,r,i,n){return h.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then((function(t){return h.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:n}},t,i<<3)})).then((function(t){return o.from(t)}))}t.exports=function(t,r,n,g,m,y){if("function"==typeof m&&(y=m,m=void 0),s(n,g),t=c(t,a,"Password"),r=c(r,a,"Salt"),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");var b=f[(m=m||"sha1").toLowerCase()];b&&"function"==typeof e.Promise?function(t,e){t.then((function(t){l()((function(){e(null,t)}))}),(function(t){l()((function(){e(t)}))}))}(function(t){if(e.process&&!e.process.browser)return Promise.resolve(!1);if(!h||!h.importKey||!h.deriveBits)return Promise.resolve(!1);if(void 0!==d[t])return d[t];var r=p(i=i||o.alloc(8),i,10,128,t).then((function(){return!0}),(function(){return!1}));return d[t]=r,r}(b).then((function(e){return e?p(t,r,n,g,b):u(t,r,n,g,m)})),y):l()((function(){var e;try{e=u(t,r,n,g,m)}catch(t){return void y(t)}y(null,e)}))}}).call(this,r(12))},function(t,e,r){var i=r(238),n=r(80),o=r(81),s=r(251),a=r(56);function u(t,e,r){if(t=t.toLowerCase(),o[t])return n.createCipheriv(t,e,r);if(s[t])return new i({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function c(t,e,r){if(t=t.toLowerCase(),o[t])return n.createDecipheriv(t,e,r);if(s[t])return new i({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}e.createCipher=e.Cipher=function(t,e){var r,i;if(t=t.toLowerCase(),o[t])r=o[t].key,i=o[t].iv;else{if(!s[t])throw new TypeError("invalid suite type");r=8*s[t].key,i=s[t].iv}var n=a(e,!1,r,i);return u(t,n.key,n.iv)},e.createCipheriv=e.Cipheriv=u,e.createDecipher=e.Decipher=function(t,e){var r,i;if(t=t.toLowerCase(),o[t])r=o[t].key,i=o[t].iv;else{if(!s[t])throw new TypeError("invalid suite type");r=8*s[t].key,i=s[t].iv}var n=a(e,!1,r,i);return c(t,n.key,n.iv)},e.createDecipheriv=e.Decipheriv=c,e.listCiphers=e.getCiphers=function(){return Object.keys(s).concat(n.getCiphers())}},function(t,e,r){var i=r(24),n=r(239),o=r(3),s=r(1).Buffer,a={"des-ede3-cbc":n.CBC.instantiate(n.EDE),"des-ede3":n.EDE,"des-ede-cbc":n.CBC.instantiate(n.EDE),"des-ede":n.EDE,"des-cbc":n.CBC.instantiate(n.DES),"des-ecb":n.DES};function u(t){i.call(this);var e,r=t.mode.toLowerCase(),n=a[r];e=t.decrypt?"decrypt":"encrypt";var o=t.key;s.isBuffer(o)||(o=s.from(o)),"des-ede"!==r&&"des-ede-cbc"!==r||(o=s.concat([o,o.slice(0,8)]));var u=t.iv;s.isBuffer(u)||(u=s.from(u)),this._des=n.create({key:o,iv:u,type:e})}a.des=a["des-cbc"],a.des3=a["des-ede3-cbc"],t.exports=u,o(u,i),u.prototype._update=function(t){return s.from(this._des.update(t))},u.prototype._final=function(){return s.from(this._des.final())}},function(t,e,r){"use strict";e.utils=r(120),e.Cipher=r(79),e.DES=r(121),e.CBC=r(240),e.EDE=r(241)},function(t,e,r){"use strict";var i=r(14),n=r(3),o={};function s(t){i.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;e<this.iv.length;e++)this.iv[e]=t[e]}e.instantiate=function(t){function e(e){t.call(this,e),this._cbcInit()}n(e,t);for(var r=Object.keys(o),i=0;i<r.length;i++){var s=r[i];e.prototype[s]=o[s]}return e.create=function(t){return new e(t)},e},o._cbcInit=function(){var t=new s(this.options.iv);this._cbcState=t},o._update=function(t,e,r,i){var n=this._cbcState,o=this.constructor.super_.prototype,s=n.iv;if("encrypt"===this.type){for(var a=0;a<this.blockSize;a++)s[a]^=t[e+a];o._update.call(this,s,0,r,i);for(a=0;a<this.blockSize;a++)s[a]=r[i+a]}else{o._update.call(this,t,e,r,i);for(a=0;a<this.blockSize;a++)r[i+a]^=s[a];for(a=0;a<this.blockSize;a++)s[a]=t[e+a]}}},function(t,e,r){"use strict";var i=r(14),n=r(3),o=r(79),s=r(121);function a(t,e){i.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),n=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:n}),s.create({type:"decrypt",key:r})]}function u(t){o.call(this,t);var e=new a(this.type,this.options.key);this._edeState=e}n(u,o),t.exports=u,u.create=function(t){return new u(t)},u.prototype._update=function(t,e,r,i){var n=this._edeState;n.ciphers[0]._update(t,e,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},u.prototype._pad=s.prototype._pad,u.prototype._unpad=s.prototype._unpad},function(t,e,r){var i=r(81),n=r(125),o=r(1).Buffer,s=r(126),a=r(24),u=r(55),c=r(56);function h(t,e,r){a.call(this),this._cache=new d,this._cipher=new u.AES(e),this._prev=o.from(r),this._mode=t,this._autopadding=!0}r(3)(h,a),h.prototype._update=function(t){var e,r;this._cache.add(t);for(var i=[];e=this._cache.get();)r=this._mode.encrypt(this,e),i.push(r);return o.concat(i)};var f=o.alloc(16,16);function d(){this.cache=o.allocUnsafe(0)}function l(t,e,r){var a=i[t.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=o.from(e)),e.length!==a.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===a.type?new s(a.module,e,r):"auth"===a.type?new n(a.module,e,r):new h(a.module,e,r)}h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},h.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},d.prototype.add=function(t){this.cache=o.concat([this.cache,t])},d.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},d.prototype.flush=function(){for(var t=16-this.cache.length,e=o.allocUnsafe(t),r=-1;++r<t;)e.writeUInt8(t,r);return o.concat([this.cache,e])},e.createCipheriv=l,e.createCipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(e,!1,r.key,r.iv);return l(t,n.key,n.iv)}},function(t,e){e.encrypt=function(t,e){return t._cipher.encryptBlock(e)},e.decrypt=function(t,e){return t._cipher.decryptBlock(e)}},function(t,e,r){var i=r(42);e.encrypt=function(t,e){var r=i(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},e.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return i(n,r)}},function(t,e,r){var i=r(1).Buffer,n=r(42);function o(t,e,r){var o=e.length,s=n(e,t._cache);return t._cache=t._cache.slice(o),t._prev=i.concat([t._prev,r?e:s]),s}e.encrypt=function(t,e,r){for(var n,s=i.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=i.allocUnsafe(0)),!(t._cache.length<=e.length)){s=i.concat([s,o(t,e,r)]);break}n=t._cache.length,s=i.concat([s,o(t,e.slice(0,n),r)]),e=e.slice(n)}return s}},function(t,e,r){var i=r(1).Buffer;function n(t,e,r){var n=t._cipher.encryptBlock(t._prev)[0]^e;return t._prev=i.concat([t._prev.slice(1),i.from([r?e:n])]),n}e.encrypt=function(t,e,r){for(var o=e.length,s=i.allocUnsafe(o),a=-1;++a<o;)s[a]=n(t,e[a],r);return s}},function(t,e,r){var i=r(1).Buffer;function n(t,e,r){for(var i,n,s=-1,a=0;++s<8;)i=e&1<<7-s?128:0,a+=(128&(n=t._cipher.encryptBlock(t._prev)[0]^i))>>s%8,t._prev=o(t._prev,r?i:n);return a}function o(t,e){var r=t.length,n=-1,o=i.allocUnsafe(t.length);for(t=i.concat([t,i.from([e])]);++n<r;)o[n]=t[n]<<1|t[n+1]>>7;return o}e.encrypt=function(t,e,r){for(var o=e.length,s=i.allocUnsafe(o),a=-1;++a<o;)s[a]=n(t,e[a],r);return s}},function(t,e,r){(function(t){var i=r(42);function n(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}e.encrypt=function(e,r){for(;e._cache.length<r.length;)e._cache=t.concat([e._cache,n(e)]);var o=e._cache.slice(0,r.length);return e._cache=e._cache.slice(r.length),i(r,o)}}).call(this,r(0).Buffer)},function(t,e,r){var i=r(1).Buffer,n=i.alloc(16,0);function o(t){var e=i.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function s(t){this.h=t,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}s.prototype.ghash=function(t){for(var e=-1;++e<t.length;)this.state[e]^=t[e];this._multiply()},s.prototype._multiply=function(){for(var t,e,r,i=[(t=this.h).readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)],n=[0,0,0,0],s=-1;++s<128;){for(0!=(this.state[~~(s/8)]&1<<7-s%8)&&(n[0]^=i[0],n[1]^=i[1],n[2]^=i[2],n[3]^=i[3]),r=0!=(1&i[3]),e=3;e>0;e--)i[e]=i[e]>>>1|(1&i[e-1])<<31;i[0]=i[0]>>>1,r&&(i[0]=i[0]^225<<24)}this.state=o(n)},s.prototype.update=function(t){var e;for(this.cache=i.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},s.prototype.final=function(t,e){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(o([0,t,0,e])),this.state},t.exports=s},function(t,e,r){var i=r(125),n=r(1).Buffer,o=r(81),s=r(126),a=r(24),u=r(55),c=r(56);function h(t,e,r){a.call(this),this._cache=new f,this._last=void 0,this._cipher=new u.AES(e),this._prev=n.from(r),this._mode=t,this._autopadding=!0}function f(){this.cache=n.allocUnsafe(0)}function d(t,e,r){var a=o[t.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=n.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof e&&(e=n.from(e)),e.length!==a.key/8)throw new TypeError("invalid key length "+e.length);return"stream"===a.type?new s(a.module,e,r,!0):"auth"===a.type?new i(a.module,e,r,!0):new h(a.module,e,r)}r(3)(h,a),h.prototype._update=function(t){var e,r;this._cache.add(t);for(var i=[];e=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,e),i.push(r);return n.concat(i)},h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return function(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");var r=-1;for(;++r<e;)if(t[r+(16-e)]!==e)throw new Error("unable to decrypt data");if(16===e)return;return t.slice(0,16-e)}(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length")},h.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},f.prototype.add=function(t){this.cache=n.concat([this.cache,t])},f.prototype.get=function(t){var e;if(t){if(this.cache.length>16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},e.createDecipher=function(t,e){var r=o[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var i=c(e,!1,r.key,r.iv);return d(t,i.key,i.iv)},e.createDecipheriv=d},function(t,e){e["des-ecb"]={key:8,iv:0},e["des-cbc"]=e.des={key:8,iv:8},e["des-ede3-cbc"]=e.des3={key:24,iv:8},e["des-ede3"]={key:24,iv:0},e["des-ede-cbc"]={key:16,iv:8},e["des-ede"]={key:16,iv:0}},function(t,e,r){(function(t){var i=r(127),n=r(253),o=r(254);var s={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(e){var r=new t(n[e].prime,"hex"),i=new t(n[e].gen,"hex");return new o(r,i)},e.createDiffieHellman=e.DiffieHellman=function e(r,n,a,u){return t.isBuffer(n)||void 0===s[n]?e(r,"binary",n,a):(n=n||"binary",u=u||"binary",a=a||new t([2]),t.isBuffer(a)||(a=new t(a,u)),"number"==typeof r?new o(i(r,a),a,!0):(t.isBuffer(r)||(r=new t(r,n)),new o(r,a,!0)))}}).call(this,r(0).Buffer)},function(t){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},function(t,e,r){(function(e){var i=r(6),n=new(r(128)),o=new i(24),s=new i(11),a=new i(10),u=new i(3),c=new i(7),h=r(127),f=r(31);function d(t,r){return r=r||"utf8",e.isBuffer(t)||(t=new e(t,r)),this._pub=new i(t),this}function l(t,r){return r=r||"utf8",e.isBuffer(t)||(t=new e(t,r)),this._priv=new i(t),this}t.exports=g;var p={};function g(t,e,r){this.setGenerator(e),this.__prime=new i(t),this._prime=i.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=d,this.setPrivateKey=l):this._primeCode=8}function m(t,r){var i=new e(t.toArray());return r?i.toString(r):i}Object.defineProperty(g.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(t,e){var r=e.toString("hex"),i=[r,t.toString(16)].join("_");if(i in p)return p[i];var f,d=0;if(t.isEven()||!h.simpleSieve||!h.fermatTest(t)||!n.test(t))return d+=1,d+="02"===r||"05"===r?8:4,p[i]=d,d;switch(n.test(t.shrn(1))||(d+=2),r){case"02":t.mod(o).cmp(s)&&(d+=8);break;case"05":(f=t.mod(a)).cmp(u)&&f.cmp(c)&&(d+=8);break;default:d+=4}return p[i]=d,d}(this.__prime,this.__gen)),this._primeCode}}),g.prototype.generateKeys=function(){return this._priv||(this._priv=new i(f(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},g.prototype.computeSecret=function(t){var r=(t=(t=new i(t)).toRed(this._prime)).redPow(this._priv).fromRed(),n=new e(r.toArray()),o=this.getPrime();if(n.length<o.length){var s=new e(o.length-n.length);s.fill(0),n=e.concat([s,n])}return n},g.prototype.getPublicKey=function(t){return m(this._pub,t)},g.prototype.getPrivateKey=function(t){return m(this._priv,t)},g.prototype.getPrime=function(t){return m(this.__prime,t)},g.prototype.getGenerator=function(t){return m(this._gen,t)},g.prototype.setGenerator=function(t,r){return r=r||"utf8",e.isBuffer(t)||(t=new e(t,r)),this.__gen=t,this._gen=new i(t),this}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(36),o=r(37),s=r(256),a=r(257),u=r(274),c=r(114);function h(t){o.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){o.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function d(t){return new h(t)}function l(t){return new f(t)}Object.keys(c).forEach((function(t){c[t].id=i.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]})),s(h,o.Writable),h.prototype._write=function(t,e,r){this._hash.update(t),r()},h.prototype.update=function(t,e){return this._hash.update("string"==typeof t?i.from(t,e):t),this},h.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),i=a(r,t,this._hashType,this._signType,this._tag);return e?i.toString(e):i},s(f,o.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return this._hash.update("string"==typeof t?i.from(t,e):t),this},f.prototype.verify=function(t,e,r){var n="string"==typeof e?i.from(e,r):e;this.end();var o=this._hash.digest();return u(n,o,t,this._signType,this._tag)},t.exports={Sign:d,Verify:l,createSign:d,createVerify:l}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(112),o=r(82),s=r(30).ec,a=r(129),u=r(57),c=r(134);function h(t,e,r,o){if((t=i.from(t.toArray())).length<e.byteLength()){var s=i.alloc(e.byteLength()-t.length);t=i.concat([s,t])}var a=r.length,u=function(t,e){t=(t=f(t,e)).mod(e);var r=i.from(t.toArray());if(r.length<e.byteLength()){var n=i.alloc(e.byteLength()-r.length);r=i.concat([n,r])}return r}(r,e),c=i.alloc(a);c.fill(1);var h=i.alloc(a);return h=n(o,h).update(c).update(i.from([0])).update(t).update(u).digest(),c=n(o,h).update(c).digest(),{k:h=n(o,h).update(c).update(i.from([1])).update(t).update(u).digest(),v:c=n(o,h).update(c).digest()}}function f(t,e){var r=new a(t),i=(t.length<<3)-e.bitLength();return i>0&&r.ishrn(i),r}function d(t,e,r){var o,s;do{for(o=i.alloc(0);8*o.length<t.bitLength();)e.v=n(r,e.k).update(e.v).digest(),o=i.concat([o,e.v]);s=f(o,t),e.k=n(r,e.k).update(e.v).update(i.from([0])).digest(),e.v=n(r,e.k).update(e.v).digest()}while(-1!==s.cmp(t));return s}function l(t,e,r,i){return t.toRed(a.mont(r)).redPow(e).fromRed().mod(i)}t.exports=function(t,e,r,n,p){var g=u(e);if(g.curve){if("ecdsa"!==n&&"ecdsa/rsa"!==n)throw new Error("wrong private key type");return function(t,e){var r=c[e.curve.join(".")];if(!r)throw new Error("unknown curve "+e.curve.join("."));var n=new s(r).keyFromPrivate(e.privateKey).sign(t);return i.from(n.toDER())}(t,g)}if("dsa"===g.type){if("dsa"!==n)throw new Error("wrong private key type");return function(t,e,r){var n,o=e.params.priv_key,s=e.params.p,u=e.params.q,c=e.params.g,p=new a(0),g=f(t,u).mod(u),m=!1,y=h(o,u,t,r);for(;!1===m;)n=d(u,y,r),p=l(c,n,s,u),0===(m=n.invm(u).imul(g.add(o.mul(p))).mod(u)).cmpn(0)&&(m=!1,p=new a(0));return function(t,e){t=t.toArray(),e=e.toArray(),128&t[0]&&(t=[0].concat(t));128&e[0]&&(e=[0].concat(e));var r=[48,t.length+e.length+4,2,t.length];return r=r.concat(t,[2,e.length],e),i.from(r)}(p,m)}(t,g,r)}if("rsa"!==n&&"ecdsa/rsa"!==n)throw new Error("wrong private key type");if(void 0!==e.padding&&1!==e.padding)throw new Error("illegal or unsupported padding mode");t=i.concat([p,t]);for(var m=g.modulus.byteLength(),y=[0,1];t.length+y.length+1<m;)y.push(255);y.push(0);for(var b=-1;++b<t.length;)y.push(t[b]);return o(y,g)},t.exports.getKey=h,t.exports.makeKey=d},function(t,e,r){(function(t){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(259).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+t)}function u(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function c(t,e,r,n){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=n,s=c>=49?c-49+10:c>=17?c-17+10:c,i(c>=0&&s<n,"Invalid character"),o+=s}return o}function h(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),"le"===r&&this._initArray(this.toArray(),e,r)))},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s,a=0;if("be"===r)for(n=t.length-1,o=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,s=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=u(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=u(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,h=r;h<a;h+=i)u=c(t,h,h+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=c(t,h,t.length,e),h=0;h<s;h++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){h(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","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],p=[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];o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<n|o)).toString(16);o=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,s--),r=0!==o||s!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],h=p[t];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var g=f.modrn(h).toString(t);r=(f=f.idivn(h)).isZero()?g+r:d[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function g(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<i;c++){for(var h=u>>>26,f=67108863&u,d=Math.min(c,e.length-1),l=Math.max(0,c-t.length+1);l<=d;l++){var p=c-l|0;h+=(s=(n=0|t.words[p])*(o=0|e.words[l])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,n),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},o.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},o.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(e=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var i,n,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],f=8191&h,d=h>>>13,l=0|s[1],p=8191&l,g=l>>>13,m=0|s[2],y=8191&m,b=m>>>13,v=0|s[3],_=8191&v,S=v>>>13,w=0|s[4],I=8191&w,A=w>>>13,E=0|s[5],O=8191&E,k=E>>>13,P=0|s[6],M=8191&P,T=P>>>13,x=0|s[7],R=8191&x,C=x>>>13,B=0|s[8],N=8191&B,D=B>>>13,L=0|s[9],U=8191&L,j=L>>>13,H=0|a[0],F=8191&H,K=H>>>13,V=0|a[1],z=8191&V,q=V>>>13,G=0|a[2],Y=8191&G,W=G>>>13,X=0|a[3],Z=8191&X,J=X>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],ft=8191&ht,dt=ht>>>13,lt=0|a[9],pt=8191&lt,gt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(c+(i=Math.imul(f,F))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(d,F)|0))<<13)|0;c=((o=Math.imul(d,K))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,F),n=(n=Math.imul(p,K))+Math.imul(g,F)|0,o=Math.imul(g,K);var yt=(c+(i=i+Math.imul(f,z)|0)|0)+((8191&(n=(n=n+Math.imul(f,q)|0)+Math.imul(d,z)|0))<<13)|0;c=((o=o+Math.imul(d,q)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,K))+Math.imul(b,F)|0,o=Math.imul(b,K),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,q)|0)+Math.imul(g,z)|0,o=o+Math.imul(g,q)|0;var bt=(c+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,W)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,K))+Math.imul(S,F)|0,o=Math.imul(S,K),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,q)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,q)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,W)|0;var vt=(c+(i=i+Math.imul(f,Z)|0)|0)+((8191&(n=(n=n+Math.imul(f,J)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(I,F),n=(n=Math.imul(I,K))+Math.imul(A,F)|0,o=Math.imul(A,K),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,q)|0)+Math.imul(S,z)|0,o=o+Math.imul(S,q)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,W)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var _t=(c+(i=i+Math.imul(f,Q)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(O,F),n=(n=Math.imul(O,K))+Math.imul(k,F)|0,o=Math.imul(k,K),i=i+Math.imul(I,z)|0,n=(n=n+Math.imul(I,q)|0)+Math.imul(A,z)|0,o=o+Math.imul(A,q)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,W)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0;var St=(c+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(d,rt)|0))<<13)|0;c=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(M,F),n=(n=Math.imul(M,K))+Math.imul(T,F)|0,o=Math.imul(T,K),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,q)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,q)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,W)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,W)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,J)|0)+Math.imul(S,Z)|0,o=o+Math.imul(S,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,it)|0;var wt=(c+(i=i+Math.imul(f,ot)|0)|0)+((8191&(n=(n=n+Math.imul(f,st)|0)+Math.imul(d,ot)|0))<<13)|0;c=((o=o+Math.imul(d,st)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,K))+Math.imul(C,F)|0,o=Math.imul(C,K),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,q)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,q)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,W)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(S,Q)|0,o=o+Math.imul(S,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var It=(c+(i=i+Math.imul(f,ut)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((o=o+Math.imul(d,ct)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,o=Math.imul(D,K),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,q)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,q)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,W)|0,i=i+Math.imul(O,Z)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,i=i+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0;var At=(c+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,dt)|0)+Math.imul(d,ft)|0))<<13)|0;c=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,F),n=(n=Math.imul(U,K))+Math.imul(j,F)|0,o=Math.imul(j,K),i=i+Math.imul(N,z)|0,n=(n=n+Math.imul(N,q)|0)+Math.imul(D,z)|0,o=o+Math.imul(D,q)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(M,Z)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,dt)|0;var Et=(c+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,gt)|0)+Math.imul(d,pt)|0))<<13)|0;c=((o=o+Math.imul(d,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,z),n=(n=Math.imul(U,q))+Math.imul(j,z)|0,o=Math.imul(j,q),i=i+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(D,Y)|0,o=o+Math.imul(D,W)|0,i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(I,ot)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,ct)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,ct)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,dt)|0;var Ot=(c+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,W))+Math.imul(j,Y)|0,o=Math.imul(j,W),i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,it)|0,i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,i=i+Math.imul(I,ut)|0,n=(n=n+Math.imul(I,ct)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ct)|0,i=i+Math.imul(_,ft)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(S,ft)|0,o=o+Math.imul(S,dt)|0;var kt=(c+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,Z),n=(n=Math.imul(U,J))+Math.imul(j,Z)|0,o=Math.imul(j,J),i=i+Math.imul(N,Q)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,i=i+Math.imul(I,ft)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,dt)|0;var Pt=(c+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,gt)|0)+Math.imul(S,pt)|0))<<13)|0;c=((o=o+Math.imul(S,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(j,Q)|0,o=Math.imul(j,tt),i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(D,rt)|0,o=o+Math.imul(D,it)|0,i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ct)|0,i=i+Math.imul(O,ft)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(k,ft)|0,o=o+Math.imul(k,dt)|0;var Mt=(c+(i=i+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(A,pt)|0))<<13)|0;c=((o=o+Math.imul(A,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(j,rt)|0,o=Math.imul(j,it),i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(D,ot)|0,o=o+Math.imul(D,st)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,i=i+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,dt)|0;var Tt=(c+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,ot),n=(n=Math.imul(U,st))+Math.imul(j,ot)|0,o=Math.imul(j,st),i=i+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(D,ut)|0,o=o+Math.imul(D,ct)|0,i=i+Math.imul(R,ft)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,dt)|0;var xt=(c+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(T,pt)|0))<<13)|0;c=((o=o+Math.imul(T,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,ut),n=(n=Math.imul(U,ct))+Math.imul(j,ut)|0,o=Math.imul(j,ct),i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(D,ft)|0,o=o+Math.imul(D,dt)|0;var Rt=(c+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,gt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,ft),n=(n=Math.imul(U,dt))+Math.imul(j,ft)|0,o=Math.imul(j,dt);var Ct=(c+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(D,pt)|0))<<13)|0;c=((o=o+Math.imul(D,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(c+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,gt))+Math.imul(j,pt)|0))<<13)|0;return c=((o=Math.imul(j,gt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,u[0]=mt,u[1]=yt,u[2]=bt,u[3]=vt,u[4]=_t,u[5]=St,u[6]=wt,u[7]=It,u[8]=At,u[9]=Et,u[10]=Ot,u[11]=kt,u[12]=Pt,u[13]=Mt,u[14]=Tt,u[15]=xt,u[16]=Rt,u[17]=Ct,u[18]=Bt,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var s=n;n=0;for(var a=67108863&i,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,f=(0|t.words[h])*(0|e.words[c]),d=67108863&f;a=67108863&(d=d+a|0),n+=(s=(s=s+(f/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function b(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=g),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?g(this,t,e):r<1024?y(this,t,e):b(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},v.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s<o;s++)i[s]=e[t[s]],n[s]=r[t[s]]},v.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var s=1;s<n;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),c=Math.sin(2*Math.PI/a),h=0;h<n;h+=a)for(var f=u,d=c,l=0;l<s;l++){var p=r[h+l],g=i[h+l],m=r[h+l+s],y=i[h+l+s],b=f*m-d*y;y=f*y+d*m,m=b,r[h+l]=p+m,i[h+l]=g+y,r[h+l+s]=p-m,i[h+l+s]=g-y,l!==a&&(b=u*f-c*d,d=u*d+c*f,f=b)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},v.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},v.prototype.convert13b=function(t,e,r,n){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<n;++s)r[s]=0;i(0===o),i(0==(-8192&o))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),s=new Array(i),a=new Array(i),u=new Array(i),c=new Array(i),h=new Array(i),f=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(e.words,e.length,c,i),this.transform(s,o,a,u,i,n),this.transform(c,o,h,f,i,n);for(var l=0;l<i;l++){var p=a[l]*h[l]-u[l]*f[l];u[l]=a[l]*f[l]+u[l]*h[l],a[l]=p}return this.conjugate(a,u,i),this.transform(a,u,d,o,i,n),this.conjugate(d,o,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),b(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var r=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,s=(67108863&o)+(67108863&r);r>>=26,r+=o/67108864|0,r+=s>>>26,this.words[n]=67108863&s}return 0!==r&&(this.words[n]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},o.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<r;this.words[e]=u|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},o.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=r;if(n-=s,n=Math.max(0,n),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=n);c--){var f=0|this.words[c];this.words[c]=h<<26-o|f>>>o,h=f&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},o.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var n,o,s=t.length+r;this._expand(s);var a=0;for(n=0;n<t.length;n++){o=(0|this.words[n+r])+a;var u=(0|t.words[n])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&o}for(;n<this.length-r;n++)a=(o=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&o;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(o=-(0|this.words[n])+a)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,u=i.length-n.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=i.clone()._ishlnsubmul(n,1,u);0===h.negative&&(i=h,a&&(a.words[u]=1));for(var f=u-1;f>=0;f--){var d=67108864*(0|i.words[n.length+f])+(0|i.words[n.length+f-1]);for(d=Math.min(d/s|0,67108863),i._ishlnsubmul(n,d,f);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(n,1,f),i.isZero()||(i.negative^=1);a&&(a.words[f]=d)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(r*n+(0|this.words[o]))%t;return e?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*r;this.words[n]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),f=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(h),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(f)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(u)):(r.isub(e),a.isub(n),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var o=n,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new O(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var _={k256:null,p224:null,p192:null,p25519:null};function S(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){S.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function I(){S.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){S.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){S.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function O(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){O.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}S.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},S.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},S.prototype.split=function(t,e){t.iushrn(this.n,0,e)},S.prototype.imulK=function(t){return t.imul(this.k)},n(w,S),w.prototype.split=function(t,e){for(var r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=4194303&n,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,t.words[i-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},w.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(I,S),n(A,S),n(E,S),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(_[t])return _[t];var e;if("k256"===t)e=new w;else if("p224"===t)e=new I;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return _[t]=e,e},O.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},O.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},O.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},O.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},O.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},O.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},O.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},O.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},O.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},O.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},O.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},O.prototype.isqr=function(t){return this.imul(t,t.clone())},O.prototype.sqr=function(t){return this.mul(t,t)},O.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,n),d=this.pow(t,n.addn(1).iushrn(1)),l=this.pow(t,n),p=s;0!==l.cmp(a);){for(var g=l,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m<p);var y=this.pow(f,new o(1).iushln(p-m-1));d=d.redMul(y),f=y.redSqr(),l=l.redMul(f),p=m}return d},O.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},O.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),i=e.length-1;i>=0;i--){for(var c=e.words[i],h=u-1;h>=0;h--){var f=c>>h&1;n!==r[0]&&(n=this.sqr(n)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===i&&0===h)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}u=26}return n},O.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},O.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new k(t)},n(k,O),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(23)(t))},function(t,e){},function(t,e){},function(t,e,r){"use strict";var i=r(43);e.certificate=r(271);var n=i.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));e.RSAPrivateKey=n;var o=i.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));e.RSAPublicKey=o;var s=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),a=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())}));e.PublicKey=a;var u=i.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())}));e.PrivateKey=u;var c=i.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));e.EncryptedPrivateKey=c;var h=i.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));e.DSAPrivateKey=h,e.DSAparam=i.define("DSAparam",(function(){this.int()}));var f=i.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})})),d=i.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(f),this.key("publicKey").optional().explicit(1).bitstr())}));e.ECPrivateKey=d,e.signature=i.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},function(t,e,r){var i=r(43),n=r(3);function o(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}e.define=function(t,e){return new o(t,e)},o.prototype._createNamed=function(t){var e;try{e=r(263).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(t){e=function(t){this._initNamed(t)}}return n(e,t),e.prototype._initNamed=function(e){t.call(this,e)},new e(this)},o.prototype._getDecoder=function(t){return t=t||"der",this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(i.decoders[t])),this.decoders[t]},o.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},o.prototype._getEncoder=function(t){return t=t||"der",this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(i.encoders[t])),this.encoders[t]},o.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}},function(module,exports){var indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;r<t.length;r++)if(t[r]===e)return r;return-1},Object_keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)e.push(r);return e},forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r<t.length;r++)e(t[r],r,t)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(t,e,r){Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0,value:r})}}catch(t){return function(t,e,r){t[e]=r}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(t){if(!(this instanceof Script))return new Script(t);this.code=t};Script.prototype.runInContext=function(t){if(!(t instanceof Context))throw new TypeError("needs a 'context' argument.");var e=document.createElement("iframe");e.style||(e.style={}),e.style.display="none",document.body.appendChild(e);var r=e.contentWindow,i=r.eval,n=r.execScript;!i&&n&&(n.call(r,"null"),i=r.eval),forEach(Object_keys(t),(function(e){r[e]=t[e]})),forEach(globals,(function(e){t[e]&&(r[e]=t[e])}));var o=Object_keys(r),s=i.call(r,this.code);return forEach(Object_keys(r),(function(e){(e in t||-1===indexOf(o,e))&&(t[e]=r[e])})),forEach(globals,(function(e){e in t||defineProp(t,e,r[e])})),document.body.removeChild(e),s},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(t){var e=Script.createContext(t),r=this.runInContext(e);return t&&forEach(Object_keys(e),(function(r){t[r]=e[r]})),r},forEach(Object_keys(Script.prototype),(function(t){exports[t]=Script[t]=function(e){var r=Script(e);return r[t].apply(r,[].slice.call(arguments,1))}})),exports.isContext=function(t){return t instanceof Context},exports.createScript=function(t){return exports.Script(t)},exports.createContext=Script.createContext=function(t){var e=new Context;return"object"==typeof t&&forEach(Object_keys(t),(function(r){e[r]=t[r]})),e}},function(t,e,r){var i=r(3);function n(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function o(t,e){this.path=t,this.rethrow(e)}e.Reporter=n,n.prototype.isError=function(t){return t instanceof o},n.prototype.save=function(){var t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},n.prototype.restore=function(t){var e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},n.prototype.enterKey=function(t){return this._reporterState.path.push(t)},n.prototype.exitKey=function(t){var e=this._reporterState;e.path=e.path.slice(0,t-1)},n.prototype.leaveKey=function(t,e,r){var i=this._reporterState;this.exitKey(t),null!==i.obj&&(i.obj[e]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var t=this._reporterState,e=t.obj;return t.obj={},e},n.prototype.leaveObject=function(t){var e=this._reporterState,r=e.obj;return e.obj=t,r},n.prototype.error=function(t){var e,r=this._reporterState,i=t instanceof o;if(e=i?t:new o(r.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!r.options.partial)throw e;return i||r.errors.push(e),e},n.prototype.wrapResult=function(t){var e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},i(o,Error),o.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}},function(t,e,r){var i=r(44).Reporter,n=r(44).EncoderBuffer,o=r(44).DecoderBuffer,s=r(14),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function c(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var h=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var t=this._baseState,e={};h.forEach((function(r){e[r]=t[r]}));var r=new this.constructor(e.parent);return r._baseState=e,r},c.prototype._wrap=function(){var t=this._baseState;u.forEach((function(e){this[e]=function(){var r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}}),this)},c.prototype._init=function(t){var e=this._baseState;s(null===e.parent),t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this),s.equal(e.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(t){var e=this._baseState,r=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==r.length&&(s(null===e.children),e.children=r,r.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(s(null===e.args),e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;var e={};return Object.keys(t).forEach((function(r){r==(0|r)&&(r|=0);var i=t[r];e[i]=r})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){c.prototype[t]=function(){var e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),a.forEach((function(t){c.prototype[t]=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===e.tag),e.tag=t,this._useArgs(r),this}})),c.prototype.use=function(t){s(t);var e=this._baseState;return s(null===e.use),e.use=t,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(t){var e=this._baseState;return s(null===e.default),e.default=t,e.optional=!0,this},c.prototype.explicit=function(t){var e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.explicit=t,this},c.prototype.implicit=function(t){var e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.implicit=t,this},c.prototype.obj=function(){var t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},c.prototype.key=function(t){var e=this._baseState;return s(null===e.key),e.key=t,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(t){var e=this._baseState;return s(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},c.prototype.contains=function(t){var e=this._baseState;return s(null===e.use),e.contains=t,this},c.prototype._decode=function(t,e){var r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));var i,n=r.default,s=!0,a=null;if(null!==r.key&&(a=t.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(s=this._peekTag(t,u,r.any),t.isError(s))return s}else{var c=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),s=!0}catch(t){s=!1}t.restore(c)}}if(r.obj&&s&&(i=t.enterObject()),s){if(null!==r.explicit){var h=this._decodeTag(t,r.explicit);if(t.isError(h))return h;t=h}var f=t.offset;if(null===r.use&&null===r.choice){if(r.any)c=t.save();var d=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(d))return d;r.any?n=t.raw(c):t=d}if(e&&e.track&&null!==r.tag&&e.track(t.path(),f,t.length,"tagged"),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,"content"),n=r.any?n:null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),t.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(t,e)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var l=new o(n);n=this._getUse(r.contains,t._reporterState.obj)._decode(l,e)}}return r.obj&&s&&(n=t.leaveObject(i)),null===r.key||null===n&&!0!==s?null!==a&&t.exitKey(a):t.leaveKey(a,r.key,n),n},c.prototype._decodeGeneric=function(t,e,r){var i=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,i.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):"objid"===t&&i.args?this._decodeObjid(e,i.args[0],i.args[1],r):"objid"===t?this._decodeObjid(e,null,null,r):"gentime"===t||"utctime"===t?this._decodeTime(e,t,r):"null_"===t?this._decodeNull(e,r):"bool"===t?this._decodeBool(e,r):"objDesc"===t?this._decodeStr(e,t,r):"int"===t||"enum"===t?this._decodeInt(e,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,e._reporterState.obj)._decode(e,r):e.error("unknown tag: "+t)},c.prototype._getUse=function(t,e){var r=this._baseState;return r.useDecoder=this._use(t,e),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(t,e){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some((function(o){var s=t.save(),a=r.choice[o];try{var u=a._decode(t,e);if(t.isError(u))return!1;i={type:o,value:u},n=!0}catch(e){return t.restore(s),!1}return!0}),this),n?i:t.error("Choice not matched")},c.prototype._createEncoderBuffer=function(t){return new n(t,this.reporter)},c.prototype._encode=function(t,e,r){var i=this._baseState;if(null===i.default||i.default!==t){var n=this._encodeValue(t,e,r);if(void 0!==n&&!this._skipDefault(n,e,r))return n}},c.prototype._encodeValue=function(t,e,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(t,e||new i);var o=null;if(this.reporter=e,n.optional&&void 0===t){if(null===n.default)return;t=n.default}var s=null,a=!1;if(n.any)o=this._createEncoderBuffer(t);else if(n.choice)o=this._encodeChoice(t,e);else if(n.contains)s=this._getUse(n.contains,r)._encode(t,e),a=!0;else if(n.children)s=n.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error("Child should have a key");var i=e.enterKey(r._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");var n=r._encode(t[r._baseState.key],e,t);return e.leaveKey(i),n}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return e.error("Too many args for : "+n.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(r){var i=this._baseState;return this._getUse(i.args[0],t)._encode(r,e)}),u))}else null!==n.use?o=this._getUse(n.use,r)._encode(t,e):(s=this._encodePrimitive(n.tag,t),a=!0);if(!n.any&&null===n.choice){var c=null!==n.implicit?n.implicit:n.tag,h=null===n.implicit?"universal":"context";null===c?null===n.use&&e.error("Tag could be omitted only for .use()"):null===n.use&&(o=this._encodeComposite(c,a,h,s))}return null!==n.explicit&&(o=this._encodeComposite(n.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(t,e){var r=this._baseState,i=r.choice[t.type];return i||s(!1,t.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(t.value,e)},c.prototype._encodePrimitive=function(t,e){var r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},c.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},c.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(t)}},function(t,e,r){var i=r(131);e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=i._reverse(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=i._reverse(e.tag)},function(t,e,r){var i=e;i.der=r(132),i.pem=r(268)},function(t,e,r){var i=r(3),n=r(0).Buffer,o=r(132);function s(t){o.call(this,t),this.enc="pem"}i(s,o),t.exports=s,s.prototype.decode=function(t,e){for(var r=t.toString().split(/[\r\n]+/g),i=e.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,u=-1,c=0;c<r.length;c++){var h=r[c].match(s);if(null!==h&&h[2]===i){if(-1!==a){if("END"!==h[1])break;u=c;break}if("BEGIN"!==h[1])break;a=c}}if(-1===a||-1===u)throw new Error("PEM section not found for: "+i);var f=r.slice(a+1,u).join("");f.replace(/[^a-z0-9\+\/=]+/gi,"");var d=new n(f,"base64");return o.prototype.decode.call(this,d,e)}},function(t,e,r){var i=e;i.der=r(133),i.pem=r(270)},function(t,e,r){var i=r(3),n=r(133);function o(t){n.call(this,t),this.enc="pem"}i(o,n),t.exports=o,o.prototype.encode=function(t,e){for(var r=n.prototype.encode.call(this,t).toString("base64"),i=["-----BEGIN "+e.label+"-----"],o=0;o<r.length;o+=64)i.push(r.slice(o,o+64));return i.push("-----END "+e.label+"-----"),i.join("\n")}},function(t,e,r){"use strict";var i=r(43),n=i.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),o=i.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),s=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),a=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())})),u=i.define("RelativeDistinguishedName",(function(){this.setof(o)})),c=i.define("RDNSequence",(function(){this.seqof(u)})),h=i.define("Name",(function(){this.choice({rdnSequence:this.use(c)})})),f=i.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))})),d=i.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),l=i.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(s),this.key("issuer").use(h),this.key("validity").use(f),this.key("subject").use(h),this.key("subjectPublicKeyInfo").use(a),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(d).optional())})),p=i.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(l),this.key("signatureAlgorithm").use(s),this.key("signatureValue").bitstr())}));t.exports=p},function(t){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},function(t,e,r){"use strict";var i=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,o=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,s=r(56),a=r(80),u=r(1).Buffer;t.exports=function(t,e){var r,c=t.toString(),h=c.match(i);if(h){var f="aes"+h[1],d=u.from(h[2],"hex"),l=u.from(h[3].replace(/[\r\n]/g,""),"base64"),p=s(e,d.slice(0,8),parseInt(h[1],10)).key,g=[],m=a.createDecipheriv(f,p,d);g.push(m.update(l)),g.push(m.final()),r=u.concat(g)}else{var y=c.match(o);r=u.from(y[2].replace(/[\r\n]/g,""),"base64")}return{tag:c.match(n)[1],data:r}}},function(t,e,r){"use strict";var i=r(1).Buffer,n=r(129),o=r(30).ec,s=r(57),a=r(134);function u(t,e){if(t.cmpn(0)<=0)throw new Error("invalid sig");if(t.cmp(e)>=0)throw new Error("invalid sig")}t.exports=function(t,e,r,c,h){var f=s(r);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var i=a[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var n=new o(i),s=r.data.subjectPrivateKey.data;return n.verify(e,t,s)}(t,e,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,o=r.data.q,a=r.data.g,c=r.data.pub_key,h=s.signature.decode(t,"der"),f=h.s,d=h.r;u(f,o),u(d,o);var l=n.mont(i),p=f.invm(o);return 0===a.toRed(l).redPow(new n(e).mul(p).mod(o)).fromRed().mul(c.toRed(l).redPow(d.mul(p).mod(o)).fromRed()).mod(i).mod(o).cmp(d)}(t,e,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");e=i.concat([h,e]);for(var d=f.modulus.byteLength(),l=[1],p=0;e.length+l.length+2<d;)l.push(255),p+=1;l.push(0);for(var g=-1;++g<e.length;)l.push(e[g]);l=i.from(l);var m=n.mont(f.modulus);t=(t=new n(t).toRed(m)).redPow(new n(f.publicExponent)),t=i.from(t.fromRed().toArray());var y=p<8?1:0;for(d=Math.min(t.length,l.length),t.length!==l.length&&(y=1),g=-1;++g<d;)y|=t[g]^l[g];return 0===y}},function(t,e,r){(function(e){var i=r(30),n=r(6);t.exports=function(t){return new s(t)};var o={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function s(t){this.curveType=o[t],this.curveType||(this.curveType={name:t}),this.curve=new i.ec(this.curveType.name),this.keys=void 0}function a(t,r,i){Array.isArray(t)||(t=t.toArray());var n=new e(t);if(i&&n.length<i){var o=new e(i-n.length);o.fill(0),n=e.concat([o,n])}return r?n.toString(r):n}o.p224=o.secp224r1,o.p256=o.secp256r1=o.prime256v1,o.p192=o.secp192r1=o.prime192v1,o.p384=o.secp384r1,o.p521=o.secp521r1,s.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},s.prototype.computeSecret=function(t,r,i){return r=r||"utf8",e.isBuffer(t)||(t=new e(t,r)),a(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),i,this.curveType.byteLength)},s.prototype.getPublicKey=function(t,e){var r=this.keys.getPublic("compressed"===e,!0);return"hybrid"===e&&(r[r.length-1]%2?r[0]=7:r[0]=6),a(r,t)},s.prototype.getPrivateKey=function(t){return a(this.keys.getPrivate(),t)},s.prototype.setPublicKey=function(t,r){return r=r||"utf8",e.isBuffer(t)||(t=new e(t,r)),this.keys._importPublic(t),this},s.prototype.setPrivateKey=function(t,r){r=r||"utf8",e.isBuffer(t)||(t=new e(t,r));var i=new n(t);return i=i.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(i),this}}).call(this,r(0).Buffer)},function(t,e,r){e.publicEncrypt=r(277),e.privateDecrypt=r(278),e.privateEncrypt=function(t,r){return e.publicEncrypt(t,r,!0)},e.publicDecrypt=function(t,r){return e.privateDecrypt(t,r,!0)}},function(t,e,r){var i=r(57),n=r(31),o=r(36),s=r(135),a=r(136),u=r(6),c=r(137),h=r(82),f=r(1).Buffer;t.exports=function(t,e,r){var d;d=t.padding?t.padding:r?1:4;var l,p=i(t);if(4===d)l=function(t,e){var r=t.modulus.byteLength(),i=e.length,c=o("sha1").update(f.alloc(0)).digest(),h=c.length,d=2*h;if(i>r-d-2)throw new Error("message too long");var l=f.alloc(r-i-d-2),p=r-h-1,g=n(h),m=a(f.concat([c,l,f.alloc(1,1),e],p),s(g,p)),y=a(g,s(m,h));return new u(f.concat([f.alloc(1),y,m],r))}(p,e);else if(1===d)l=function(t,e,r){var i,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");i=r?f.alloc(s-o-3,255):function(t){var e,r=f.allocUnsafe(t),i=0,o=n(2*t),s=0;for(;i<t;)s===o.length&&(o=n(2*t),s=0),(e=o[s++])&&(r[i++]=e);return r}(s-o-3);return new u(f.concat([f.from([0,r?1:2]),i,f.alloc(1),e],s))}(p,e,r);else{if(3!==d)throw new Error("unknown padding");if((l=new u(e)).cmp(p.modulus)>=0)throw new Error("data too long for modulus")}return r?h(l,p):c(l,p)}},function(t,e,r){var i=r(57),n=r(135),o=r(136),s=r(6),a=r(82),u=r(36),c=r(137),h=r(1).Buffer;t.exports=function(t,e,r){var f;f=t.padding?t.padding:r?1:4;var d,l=i(t),p=l.modulus.byteLength();if(e.length>p||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");d=r?c(new s(e),l):a(e,l);var g=h.alloc(p-d.length);if(d=h.concat([g,d],p),4===f)return function(t,e){var r=t.modulus.byteLength(),i=u("sha1").update(h.alloc(0)).digest(),s=i.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,n(c,s)),d=o(c,n(f,r-s-1));if(function(t,e){t=h.from(t),e=h.from(e);var r=0,i=t.length;t.length!==e.length&&(r++,i=Math.min(t.length,e.length));var n=-1;for(;++n<i;)r+=t[n]^e[n];return r}(i,d.slice(0,s)))throw new Error("decryption error");var l=s;for(;0===d[l];)l++;if(1!==d[l++])throw new Error("decryption error");return d.slice(l)}(l,d);if(1===f)return function(t,e,r){var i=e.slice(0,2),n=2,o=0;for(;0!==e[n++];)if(n>=e.length){o++;break}var s=e.slice(2,n-1);("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(n)}(0,d,r);if(3===f)return d;throw new Error("unknown padding")}},function(t,e,r){"use strict";(function(t,i){function n(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=r(1),s=r(31),a=o.Buffer,u=o.kMaxLength,c=t.crypto||t.msCrypto,h=Math.pow(2,32)-1;function f(t,e){if("number"!=typeof t||t!=t)throw new TypeError("offset must be a number");if(t>h||t<0)throw new TypeError("offset must be a uint32");if(t>u||t>e)throw new RangeError("offset out of range")}function d(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>h||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>u)throw new RangeError("buffer too small")}function l(t,e,r,n){if(i.browser){var o=t.buffer,a=new Uint8Array(o,e,r);return c.getRandomValues(a),n?void i.nextTick((function(){n(null,t)})):t}if(!n)return s(r).copy(t,e),t;s(r,(function(r,i){if(r)return n(r);i.copy(t,e),n(null,t)}))}c&&c.getRandomValues||!i.browser?(e.randomFill=function(e,r,i,n){if(!(a.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof r)n=r,r=0,i=e.length;else if("function"==typeof i)n=i,i=e.length-r;else if("function"!=typeof n)throw new TypeError('"cb" argument must be a function');return f(r,e.length),d(i,r,e.length),l(e,r,i,n)},e.randomFillSync=function(e,r,i){void 0===r&&(r=0);if(!(a.isBuffer(e)||e instanceof t.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(r,e.length),void 0===i&&(i=e.length-r);return d(i,r,e.length),l(e,r,i)}):(e.randomFill=n,e.randomFillSync=n)}).call(this,r(12),r(11))},function(t,e,r){"use strict";var i=r(281);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},i=0;i<e.length;++i)r[e[i]]=e[i];var n=Object.assign({},r),o="";for(var s in n)o+=s;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?i:Object.assign:i}},function(t,e,r){"use strict";var i=r(282),n=r(74)(),o=r(72),s=r(73),a=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),c=n?s.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=s(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var h=s(arguments[o]),f=i(h),d=n&&(s.getOwnPropertySymbols||c);if(d)for(var l=d(h),p=0;p<l.length;++p){var g=l[p];u(h,g)&&a(f,g)}for(var m=0;m<f.length;++m){var y=f[m];if(u(h,y)){var b=h[y];r[y]=b}}}return r}},function(t,e,r){"use strict";var i=Array.prototype.slice,n=r(139),o=Object.keys,s=o?function(t){return o(t)}:r(283),a=Object.keys;s.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return n(t)?a(i.call(t)):a(t)}):Object.keys=s;return Object.keys||s},t.exports=s},function(t,e,r){"use strict";var i;if(!Object.keys){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,s=r(139),a=Object.prototype.propertyIsEnumerable,u=!a.call({toString:null},"toString"),c=a.call((function(){}),"prototype"),h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(t){var e=t.constructor;return e&&e.prototype===t},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!d["$"+t]&&n.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{f(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();i=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),i=s(t),a=e&&"[object String]"===o.call(t),d=[];if(!e&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var p=c&&r;if(a&&t.length>0&&!n.call(t,0))for(var g=0;g<t.length;++g)d.push(String(g));if(i&&t.length>0)for(var m=0;m<t.length;++m)d.push(String(m));else for(var y in t)p&&"prototype"===y||!n.call(t,y)||d.push(String(y));if(u)for(var b=function(t){if("undefined"==typeof window||!l)return f(t);try{return f(t)}catch(t){return!1}}(t),v=0;v<h.length;++v)b&&"constructor"===h[v]||!n.call(t,h[v])||d.push(h[v]);return d}}t.exports=i},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";const i=r(286),n=r(141),o=r(287);function s(t,e){switch(n(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const r=new t.constructor;for(let i in t)r[i]=s(t[i],e);return r}return t}(t,e);case"array":return function(t,e){const r=new t.constructor(t.length);for(let i=0;i<t.length;i++)r[i]=s(t[i],e);return r}(t,e);default:return i(t)}}t.exports=s},function(t,e,r){"use strict";(function(e){
19
+ /*!
20
+ * shallow-clone <https://github.com/jonschlinkert/shallow-clone>
21
+ *
22
+ * Copyright (c) 2015-present, Jon Schlinkert.
23
+ * Released under the MIT License.
24
+ */
25
+ const i=Symbol.prototype.valueOf,n=r(141);t.exports=function(t,r){switch(n(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const r=t.length,i=e.allocUnsafe?e.allocUnsafe(r):e.from(r);return t.copy(i),i}(t);case"symbol":return function(t){return i?Object(i.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}(t);case"error":return Object.create(t);default:return t}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";
26
+ /*!
27
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
28
+ *
29
+ * Copyright (c) 2014-2017, Jon Schlinkert.
30
+ * Released under the MIT License.
31
+ */var i=r(288);function n(t){return!0===i(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,r;return!1!==n(t)&&("function"==typeof(e=t.constructor)&&(!1!==n(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(t,e,r){"use strict";
32
+ /*!
33
+ * isobject <https://github.com/jonschlinkert/isobject>
34
+ *
35
+ * Copyright (c) 2014-2017, Jon Schlinkert.
36
+ * Released under the MIT License.
37
+ */t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},function(t,e,r){"use strict";var i=r(3),n=r(4),o=r(47),s=r(27),a=r(26),u=r(18),c=r(8),h=r(48);function f(){o.apply(this,arguments)}i(f,o),f.prototype.getSignatures=function(t,e,r,i){n.checkState(this.output instanceof s),i=i||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=e.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new h({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:a.sign(t,e,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},f.prototype.addSignature=function(t,e){return n.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(e.signature.toDER(),e.sigtype)),this},f.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},f.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},f.SCRIPT_MAX_SIZE=74,f.prototype._estimateSize=function(){return o.BASE_SIZE+f.SCRIPT_MAX_SIZE},t.exports=f},function(t,e,r){"use strict";var i=r(3),n=r(4),o=r(9),s=r(47),a=r(27),u=r(26),c=r(18),h=r(8),f=r(48);function d(){s.apply(this,arguments)}i(d,s),d.prototype.getSignatures=function(t,e,r,i,s){return n.checkState(this.output instanceof a),s=s||o.sha256ripemd160(e.publicKey.toBuffer()),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID,s.equals(this.output.script.getPublicKeyHash())?[new f({publicKey:e.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:u.sign(t,e,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},d.prototype.addSignature=function(t,e){return n.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(e.publicKey,e.signature.toDER(),e.sigtype)),this},d.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},d.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},d.SCRIPT_MAX_SIZE=108,d.prototype._estimateSize=function(){return s.BASE_SIZE+d.SCRIPT_MAX_SIZE},t.exports=d},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(3),o=r(47),s=r(27),a=r(4),u=r(18),c=r(8),h=r(26),f=r(48),d=r(20),l=r(46);function p(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),a.checkState(u.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},i.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}n(p,o),p.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},p.prototype._deserializeSignatures=function(t){return i.map(t,(function(t){if(t)return new f(t)}))},p.prototype._serializeSignatures=function(){return i.map(this.signatures,(function(t){if(t)return t.toObject()}))},p.prototype.getSignatures=function(t,e,r,n){a.checkState(this.output instanceof s),n=n||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=this,u=[];return i.each(this.publicKeys,(function(i){i.toString()===e.publicKey.toString()&&u.push(new f({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:h.sign(t,e,n,r,o.output.script,o.output.satoshisBN),sigtype:n}))})),u},p.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},p.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,(function(t){return!i.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return i.reduce(this.signatures,(function(t,e){return t+!!e}),0)},p.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},p.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,h.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},p.normalizeSignatures=function(t,e,r,i,n){return n.map((function(n){var o=null;return i=i.filter((function(i){if(o)return!0;var s=new f({signature:c.fromTxFormat(i),publicKey:n,prevTxId:e.prevTxId,outputIndex:e.outputIndex,inputIndex:r,sigtype:c.SIGHASH_ALL});return s.signature.nhashtype=s.sigtype,!h.verify(t,s.signature,s.publicKey,s.inputIndex,e.output.script)||(o=s,!1)})),o||null}))},p.SIGNATURE_SIZE=73,p.prototype._estimateSize=function(){var t=1+this.threshold*p.SIGNATURE_SIZE;return o.BASE_SIZE+l(t).toBuffer().length+t},t.exports=p}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(3),o=r(47),s=r(27),a=r(4),u=r(18),c=r(8),h=r(26),f=r(48),d=r(20),l=r(46);function p(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),this.redeemScript=u.buildMultisigOut(this.publicKeys,r),a.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},i.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}n(p,o),p.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},p.prototype._deserializeSignatures=function(t){return i.map(t,(function(t){if(t)return new f(t)}))},p.prototype._serializeSignatures=function(){return i.map(this.signatures,(function(t){if(t)return t.toObject()}))},p.prototype.getSignatures=function(t,e,r,n){a.checkState(this.output instanceof s),n=n||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=this,u=[];return i.each(this.publicKeys,(function(i){i.toString()===e.publicKey.toString()&&u.push(new f({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:h.sign(t,e,n,r,o.redeemScript,o.output.satoshisBN),sigtype:n}))})),u},p.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},p.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,(function(t){return!i.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return i.reduce(this.signatures,(function(t,e){return t+!!e}),0)},p.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},p.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,h.verify(t,e.signature,e.publicKey,e.inputIndex,this.redeemScript,this.output.satoshisBN)},p.SIGNATURE_SIZE=73,p.PUBKEY_SIZE=34,p.prototype._estimateSize=function(){var t=3+this.publicKeys.length*p.PUBKEY_SIZE,e=this.threshold*p.SIGNATURE_SIZE+1+(t<=75?1:t<=255?2:3)+t;return o.BASE_SIZE+l(e).toBuffer().length+e},t.exports=p}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(294),t.exports.BlockHeader=r(61),t.exports.MerkleBlock=r(145)},function(t,e,r){"use strict";(function(e){var i=r(2),n=r(61),o=r(7),s=r(25),a=r(21),u=r(9),c=r(60),h=r(4);function f(t){return this instanceof f?(i.extend(this,f._from(t)),this):new f(t)}f.MAX_BLOCK_SIZE=128e6,f._from=function(t){var r={};if(e.isBuffer(t))r=f._fromBufferReader(s(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for Block");r=f._fromObject(t)}return r},f._fromObject=function(t){var e=[];return t.transactions.forEach((function(t){t instanceof c?e.push(t):e.push(c().fromObject(t))})),{header:n.fromObject(t.header),transactions:e}},f.fromObject=function(t){var e=f._fromObject(t);return new f(e)},f._fromBufferReader=function(t){var e={};h.checkState(!t.finished(),"No block data received"),e.header=n.fromBufferReader(t);var r=t.readVarintNum();e.transactions=[];for(var i=0;i<r;i++)e.transactions.push(c().fromBufferReader(t));return e},f.fromBufferReader=function(t){h.checkArgument(t,"br is required");var e=f._fromBufferReader(t);return new f(e)},f.fromBuffer=function(t){return f.fromBufferReader(new s(t))},f.fromString=function(t){var r=e.from(t,"hex");return f.fromBuffer(r)},f.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=s(t);r.pos=f.Values.START_OF_BLOCK;var i=f._fromBufferReader(r);return new f(i)},f.prototype.toObject=f.prototype.toJSON=function(){var t=[];return this.transactions.forEach((function(e){t.push(e.toObject())})),{header:this.header.toObject(),transactions:t}},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toString=function(){return this.toBuffer().toString("hex")},f.prototype.toBufferWriter=function(t){t||(t=new a),t.write(this.header.toBuffer()),t.writeVarintNum(this.transactions.length);for(var e=0;e<this.transactions.length;e++)this.transactions[e].toBufferWriter(t);return t},f.prototype.getTransactionHashes=function(){var t=[];if(0===this.transactions.length)return[f.Values.NULL_HASH];for(var e=0;e<this.transactions.length;e++)t.push(this.transactions[e]._getHash());return t},f.prototype.getMerkleTree=function(){for(var t=this.getTransactionHashes(),r=0,i=this.transactions.length;i>1;i=Math.floor((i+1)/2)){for(var n=0;n<i;n+=2){var o=Math.min(n+1,i-1),s=e.concat([t[r+n],t[r+o]]);t.push(u.sha256sha256(s))}r+=i}return t},f.prototype.getMerkleRoot=function(){var t=this.getMerkleTree();return t[t.length-1]},f.prototype.validMerkleRoot=function(){var t=new o(this.header.merkleRoot.toString("hex"),"hex"),e=new o(this.getMerkleRoot().toString("hex"),"hex");return 0===t.cmp(e)},f.prototype._getHash=function(){return this.header._getHash()};var d={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:i.noop};Object.defineProperty(f.prototype,"id",d),Object.defineProperty(f.prototype,"hash",d),f.prototype.inspect=function(){return"<Block "+this.id+">"},f.Values={START_OF_BLOCK:8,NULL_HASH:e.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=f}).call(this,r(0).Buffer)},function(t,e,r){var i=r(5);i.Message=r(296),t.exports=i.Message},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.deps._,o=i.PrivateKey,s=i.PublicKey,a=i.Address,u=i.encoding.BufferWriter,c=i.crypto.ECDSA,h=i.crypto.Signature,f=i.crypto.Hash.sha256sha256,d=i.util.js,l=i.util.preconditions,p=function t(r){return this instanceof t?(l.checkArgument(n.isString(r)||e.isBuffer(r),"First argument should be a string or Buffer"),n.isString(r)&&(this.messageBuffer=e.from(r)),e.isBuffer(r)&&(this.messageBuffer=r),this):new t(r)};p.sign=function(t,e){return new p(t).sign(e)},p.verify=function(t,e,r){return new p(t).verify(e,r)},p.MAGIC_BYTES=e.from("Bitcoin Signed Message:\n"),p.prototype.magicHash=function(){var t=u.varintBufNum(p.MAGIC_BYTES.length),r=u.varintBufNum(this.messageBuffer.length),i=e.concat([t,p.MAGIC_BYTES,r,this.messageBuffer]);return f(i)},p.prototype._sign=function(t){l.checkArgument(t instanceof o,"First argument should be an instance of PrivateKey");var e=this.magicHash();return c.signWithCalcI(e,t)},p.prototype.sign=function(t){return this._sign(t).toCompact().toString("base64")},p.prototype._verify=function(t,e){l.checkArgument(t instanceof s,"First argument should be an instance of PublicKey"),l.checkArgument(e instanceof h,"Second argument should be an instance of Signature");var r=this.magicHash(),i=c.verify(r,e,t);return i||(this.error="The signature was invalid"),i},p.prototype.verify=function(t,r){l.checkArgument(t),l.checkArgument(r&&n.isString(r)),n.isString(t)&&(t=a.fromString(t));var i=h.fromCompact(e.from(r,"base64")),o=new c;o.hashbuf=this.magicHash(),o.sig=i;var s=o.toPublicKey(),u=a.fromPublicKey(s,t.network);return t.toString()!==u.toString()?(this.error="The signature did not match the message digest",!1):this._verify(s,i)},p.fromString=function(t){return new p(t)},p.fromJSON=function(t){return d.isValidJSON(t)&&(t=JSON.parse(t)),p.fromObject(t)},p.prototype.toObject=function(){return{messageHex:this.messageBuffer.toString("hex")}},p.fromObject=function(t){let r=e.from(t.messageHex,"hex");return new p(r)},p.prototype.toJSON=function(){return JSON.stringify(this.toObject())},p.prototype.toString=function(){return this.messageBuffer.toString()},p.prototype.inspect=function(){return"<Message: "+this.toString()+">"},t.exports=p}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(5),n={Covenant:r(298),Preimage:r(22),SIGHASH:r(299),Builder:r(300),UTXOGenerator:r(301),ScriptTester:r(302),CovenantBuilder:r(148).CovenantBuilder,CovenantTemplates:r(148).CovenantTemplates,OpcodeMap:r(149),ScriptUtils:r(303),StackExaminer:r(304),ScriptInterpreter:r(305),createCovenant:function(t,e){return new n.Covenant(t,e)},extractPreimage:function(t,e){return new n.Preimage(t,e)},analyzeSIGHASH:function(t){return new n.SIGHASH(t)},buildCovenant:function(t,e){return new n.Builder(t,e)},createUTXOGenerator:function(t){return new n.UTXOGenerator(t)},createTestEnvironment:function(t){return n.UTXOGenerator.createTestEnvironment(t)},testScript:function(t,e,r){return n.ScriptTester.test(t,e,r)},testCovenant:function(t,e,r){return n.ScriptTester.testCovenant(t,e,r)},testFieldExtraction:function(t,e,r){return n.ScriptTester.testFieldExtraction(t,e,r)},debugScript:function(t,e){return new n.ScriptTester(e).debug(t)},explainZeroHashes:function(){return n.SIGHASH.explainZeroMystery()},getAllSIGHASHTypes:function(){return n.SIGHASH.getAllTypes()},demonstrateAllSIGHASH:function(){return n.SIGHASH.generateAllDemonstrations()},createCovenantBuilder:function(){return new n.CovenantBuilder},createValueLockCovenant:function(t){return n.CovenantTemplates.valueLock(t)},createHashLockCovenant:function(t){return n.CovenantTemplates.hashLock(t)},createComplexValidationCovenant:function(t){return n.CovenantTemplates.complexValidation(t)},getOpcodeMap:function(){return n.OpcodeMap.opcodeMap},simulateScript:function(t,e){return n.OpcodeMap.utils.simulate(t,e)},createASMFromJS:function(t){return n.OpcodeMap.utils.createASM(t)},scriptToASM:function(t){return n.ScriptUtils.scriptToASM(t)},asmToScript:function(t){return n.ScriptUtils.asmToScript(t)},asmToHex:function(t){return n.ScriptUtils.asmToHex(t)},hexToASM:function(t){return n.ScriptUtils.hexToASM(t)},scriptToHex:function(t){return n.ScriptUtils.scriptToHex(t)},validateASM:function(t){return n.ScriptUtils.validateASM(t)},validateScript:function(t){return n.ScriptUtils.validateScript(t)},estimateScriptSize:function(t){return n.ScriptUtils.estimateScriptSize(t)},optimizeScript:function(t){return n.ScriptUtils.optimizeScript(t)},compareScripts:function(t,e){return n.ScriptUtils.compareScripts(t,e)},explainScript:function(t){return n.ScriptUtils.explainScript(t)},scriptMetrics:function(t){return n.ScriptUtils.scriptMetrics(t)},analyzeComplexity:function(t){return n.ScriptUtils.analyzeComplexity(t)},findOptimizations:function(t){return n.ScriptUtils.findOptimizations(t)},covenantToEnglish:function(t){return n.ScriptUtils.covenantToEnglish(t)},batchTestScripts:function(t,e){return n.ScriptUtils.batchTestScripts(t,e)},examineStack:function(t,e){return n.StackExaminer.runScript(t,e)},debugScriptExecution:function(t,e,r){return(r=r||{}).stepMode?n.ScriptInterpreter.stepThroughScript(n.ScriptInterpreter.parseScript(t+" "+e),new i.Transaction,!0):n.ScriptInterpreter.runFullEvaluation(n.ScriptInterpreter.parseScript(t),n.ScriptInterpreter.parseScript(e),new i.Transaction)},parseScript:function(t){return n.ScriptInterpreter.parseScript(t)},printStack:function(t,e){return n.ScriptInterpreter.printStack(t,e)},createQuickCovenant:function(t,e){const r=n.createCovenantBuilder();switch(t){case"value_lock":return r.comment(`Value lock: minimum ${e.value} satoshis`).extractField("value").push(e.value).greaterThanOrEqual().verify().build();case"hash_lock":return r.comment("Hash lock: requires preimage of "+e.hash).push("secret_placeholder").sha256().push(e.hash).equalVerify().build();case"time_lock":return r.comment("Time lock: requires nLockTime > "+e.timestamp).extractField("nLockTime").push(e.timestamp).greaterThan().verify().build();case"multi_condition":let i=r.comment("Multi-condition covenant");return e.conditions.forEach(t=>{switch(t.type){case"value":i=i.extractField("value").push(t.value).greaterThanOrEqual().verify();break;case"hash":i=i.push("secret_placeholder").sha256().push(t.hash).equalVerify();break;case"time":i=i.extractField("nLockTime").push(t.timestamp).greaterThan().verify()}}),i.build();default:throw new Error("Unknown covenant type: "+t)}},completeCovenantFlow:function(t,e,r){return new n.Covenant(t).completeFlow(e,r)},getEducationalResources:function(){return{zeroHashMystery:n.SIGHASH.explainZeroMystery(),sighashTypes:n.SIGHASH.getAllTypes(),exampleDemonstrations:n.SIGHASH.generateAllDemonstrations()}},utils:{}};n.utils.reconstructP2pkhScript=function(t){return i.Script.buildPublicKeyHashOut(t).toHex()},n.utils.createCovenantAddress=function(t){var e=i.crypto.Hash.sha256ripemd160(t.toBuffer());return i.Address.fromScriptHash(e)},n.utils.decodeCompactSize=function(t,e){return n.Preimage.decodeCompactSize(t,e)},n.version="v1.0.0",n.description="Enterprise Smart Contract Framework for Bitcoin SV",n.features={BIP143_PREIMAGE:!0,COMPACT_SIZE_VARINT:!0,BIDIRECTIONAL_EXTRACTION:!0,SIGHASH_DETECTION:!0,ZERO_HASH_WARNINGS:!0,MULTI_FIELD_VALIDATION:!0,REAL_UTXO_GENERATION:!0,SCRIPT_TESTING:!0,LOCAL_VERIFICATION:!0,JAVASCRIPT_TO_SCRIPT:!0,OPCODE_MAPPING:!0,COVENANT_BUILDER:!0,SCRIPT_ANALYSIS:!0,SCRIPT_OPTIMIZATION:!0,SCRIPT_CONVERSION:!0,BATCH_TESTING:!0,QUICK_COVENANTS:!0,SCRIPT_EXPLANATIONS:!0,STACK_EXAMINATION:!0,SCRIPT_DEBUGGING:!0,STEP_BY_STEP_EXECUTION:!0,INTERACTIVE_DEBUGGING:!0,PRODUCTION_READY:!0},n.interpretScript=n.debugScriptExecution,n.getScriptMetrics=n.scriptMetrics,t.exports=n},function(t,e,r){"use strict";(function(e,i){var n,o=r(5),s=r(89);try{n=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}())}catch(t){n=null}function a(t,r){if(!(this instanceof a))return new a(t,r);this.privateKey=t,this.publicKey=t.publicKey,this.address=t.toAddress(),r=r||{},this.storageDir=r.storageDir||(void 0!==e?s.join(e.cwd(),".bsv-covenants"):".bsv-covenants"),this.covenantUtxoPath=s.join(this.storageDir,"covenant_utxos.json"),this.sighashType=o.crypto.Signature.SIGHASH_ALL|o.crypto.Signature.SIGHASH_FORKID,n&&this._ensureStorageDir()}a.prototype.createFromP2PKH=function(t){t.script||(t.script=a.reconstructP2pkhScript(this.address));var e=(new o.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.address,t.satoshis-1e3),r=o.Script.fromHex(t.script),i=o.Transaction.sighash.sighashPreimage(e,this.sighashType,0,r,new o.crypto.BN(t.satoshis)),n=o.crypto.Hash.sha256sha256(i),s=(new o.Script).add("OP_DUP").add("OP_HASH256").add(n).add("OP_EQUALVERIFY").add("OP_DROP").add(this.publicKey.toBuffer()).add("OP_CHECKSIG");return e.outputs[0].setScript(s),e.sign(this.privateKey),{transaction:e,covenantUtxo:{txid:e.id,vout:0,satoshis:t.satoshis-1e3,script:s.toHex(),scriptPubKey:s.toHex(),preimageHash:n.toString("hex"),originalPreimage:i.toString("hex"),status:"local",createdAt:(new Date).toISOString(),type:"preimage_covenant"}}},a.prototype.createSpendingTx=function(t,e,r){var n=e||this.address,s=r||t.satoshis-500,a=new o.Transaction;a.addInput(new o.Transaction.Input({prevTxId:t.txid,outputIndex:t.vout,script:o.Script.empty()}),o.Script.fromHex(t.script),t.satoshis),a.to(n,s);var u=o.Script.fromHex(t.script),c=o.Transaction.sighash.sign(a,this.privateKey,this.sighashType,0,u,new o.crypto.BN(t.satoshis)),h=i.concat([c.toDER(),i.from([this.sighashType])]),f=i.from(t.originalPreimage,"hex"),d=(new o.Script).add(h).add(f);return a.inputs[0].setScript(d),a},a.prototype.validate=function(t,e){var r=new o.Script.Interpreter,i=o.Script.Interpreter.SCRIPT_VERIFY_P2SH|o.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|o.Script.Interpreter.SCRIPT_VERIFY_DERSIG|o.Script.Interpreter.SCRIPT_VERIFY_LOW_S|o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n=t.inputs[0].script,s=o.Script.fromHex(e.script),a=r.verify(n,s,t,0,i,new o.crypto.BN(e.satoshis));return{valid:a,error:a?null:r.errstr}},a.prototype.save=function(t){if(!n)return console.warn("File system operations not available in browser environment"),t;var e=this.list();return e.push(t),n.writeFileSync(this.covenantUtxoPath,JSON.stringify(e,null,2)),t},a.prototype.load=function(t){var e=this.list();if(t){var r;if(!(r=e.find((function(e){return e.txid===t}))))throw new Error("Covenant UTXO with TXID "+t+" not found");return r}if(!(r=e.find((function(t){return"preimage_covenant"===t.type}))))throw new Error("No preimage covenant UTXO found");return r},a.prototype.list=function(){return n.existsSync(this.covenantUtxoPath)?JSON.parse(n.readFileSync(this.covenantUtxoPath,"utf8")):[]},a.prototype.getPortfolio=function(){var t=this.list(),e={total:t.length,totalValue:t.reduce((function(t,e){return t+e.satoshis}),0),byStatus:{},recent:t.slice(-5)};return t.forEach((function(t){var r=t.status||"local";e.byStatus[r]||(e.byStatus[r]={count:0,value:0}),e.byStatus[r].count++,e.byStatus[r].value+=t.satoshis})),e},a.prototype.completeFlow=function(t,e){var r=this.createFromP2PKH(t),i=this.save(r.covenantUtxo);e&&e(r.transaction,"creation");var n=this.createSpendingTx(i),o=this.validate(n,i);return e&&o.valid&&e(n,"spending"),{creationTx:r.transaction,spendingTx:n,covenantUtxo:i,validation:o,success:o.valid}},a.prototype._ensureStorageDir=function(){n.existsSync(this.storageDir)||n.mkdirSync(this.storageDir,{recursive:!0})},a.reconstructP2pkhScript=function(t){return o.Script.buildPublicKeyHashOut(t).toHex()},t.exports=a}).call(this,r(11),r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5);function n(t){if(!(this instanceof n))return new n(t);this.sighashType=t||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,this.analysis=this._analyzeFlags()}n.prototype.analyze=function(){return this.analysis},n.prototype.getZeroHashBehavior=function(){var t={hashPrevouts:!1,hashSequence:!1,hashOutputs:!1,explanation:[],criticalNote:null};return this.analysis.anyoneCanPay&&(t.hashPrevouts=!0,t.explanation.push("ANYONECANPAY: hashPrevouts becomes zero hash (0x00...00)")),"NONE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_NONE: hashSequence and hashOutputs become zero hash")),"SINGLE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_SINGLE: hashSequence becomes zero hash, hashOutputs covers only corresponding output")),(t.hashPrevouts||t.hashSequence||t.hashOutputs)&&(t.criticalNote="These zero hashes are NOT bugs - they are correct BIP-143 behavior for the specified SIGHASH flags!"),t},n.prototype.generateExample=function(){var t=i.PrivateKey.fromRandom().toAddress(),e={txId:"a".repeat(64),outputIndex:0,script:i.Script.buildPublicKeyHashOut(t).toHex(),satoshis:1e5},n=(new i.Transaction).from(e).to(t,99e3),o=i.Script.fromHex(e.script),s=i.Transaction.sighash.sighashPreimage(n,this.sighashType,0,o,new i.crypto.BN(e.satoshis)),a=new(r(22))(s);return{transaction:n,preimage:a,sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),fields:a.extract(),validation:a.validate()}},n.prototype.createDemonstration=function(){var t=this.generateExample(),r=e.alloc(32).toString("hex"),i={sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),preimageFields:{},observations:[],educationalNotes:[]},n=t.preimage.toObject().fields;return i.preimageFields=n,n.hashPrevouts===r&&i.observations.push({field:"hashPrevouts",value:"ZERO HASH (00...00)",reason:"ANYONECANPAY flag - this input can be combined with any other inputs"}),n.hashSequence===r&&i.observations.push({field:"hashSequence",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - sequence numbers not covered by signature"}),n.hashOutputs===r&&i.observations.push({field:"hashOutputs",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - outputs not fully covered by signature"}),i.educationalNotes=["Zero hashes in preimages are NOT errors - they indicate specific SIGHASH flag behavior","BIP-143 mandates these zero values when certain flags are used","ANYONECANPAY allows this input to be combined with different sets of inputs","SIGHASH_NONE means the signer doesn't care about any outputs","SIGHASH_SINGLE means the signer only cares about the corresponding output","Always check SIGHASH flags when you see 'mysterious' zero hashes in preimages"],i},n.prototype.checkCompliance=function(t){var r=t.toObject().fields,i=e.alloc(32).toString("hex"),n={compliant:!0,issues:[],expectedZeros:[],unexpectedZeros:[]},o=this.getZeroHashBehavior();return o.hashPrevouts&&r.hashPrevouts!==i?(n.compliant=!1,n.issues.push("hashPrevouts should be zero due to ANYONECANPAY flag")):o.hashPrevouts||r.hashPrevouts!==i||n.unexpectedZeros.push("hashPrevouts is zero but ANYONECANPAY not set"),o.hashSequence&&r.hashSequence!==i?(n.compliant=!1,n.issues.push("hashSequence should be zero due to "+this.analysis.baseType+" flag")):o.hashSequence||r.hashSequence!==i||n.unexpectedZeros.push("hashSequence is zero but "+this.analysis.baseType+" allows sequence coverage"),o.hashOutputs&&r.hashOutputs!==i?(n.compliant=!1,n.issues.push("hashOutputs should be zero due to "+this.analysis.baseType+" flag")):o.hashOutputs||r.hashOutputs!==i||n.unexpectedZeros.push("hashOutputs is zero but "+this.analysis.baseType+" should cover outputs"),n},n.prototype._analyzeFlags=function(){var t=31&this.sighashType,e=0!=(128&this.sighashType),r=0!=(64&this.sighashType),i="UNKNOWN";1===t?i="ALL":2===t?i="NONE":3===t&&(i="SINGLE");var n=[];return n.push(i),e&&n.push("ANYONECANPAY"),r&&n.push("FORKID"),{sighashType:this.sighashType,baseType:i,anyoneCanPay:e,forkId:r,flagName:n.join(" | "),hex:"0x"+this.sighashType.toString(16).padStart(8,"0"),binary:"0b"+this.sighashType.toString(2).padStart(32,"0")}},n.getAllTypes=function(){var t=i.crypto.Signature.SIGHASH_FORKID;return[{name:"ALL",value:i.crypto.Signature.SIGHASH_ALL|t},{name:"NONE",value:i.crypto.Signature.SIGHASH_NONE|t},{name:"SINGLE",value:i.crypto.Signature.SIGHASH_SINGLE|t},{name:"ALL | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"NONE | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_NONE|i.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"SINGLE | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_SINGLE|i.crypto.Signature.SIGHASH_ANYONECANPAY|t}]},n.generateAllDemonstrations=function(){return n.getAllTypes().map((function(t){var e=new n(t.value);return{typeName:t.name,demonstration:e.createDemonstration()}}))},n.explainZeroMystery=function(){return{title:"The 'Extra Zero' Mystery in Bitcoin Preimages",problem:"Developers often see zero hashes (0x00...00) in preimage fields and think it's a bug",reality:"These zeros are CORRECT behavior mandated by BIP-143 for specific SIGHASH flags",explanation:["ANYONECANPAY sets hashPrevouts to zero - allows input combination flexibility","SIGHASH_NONE sets hashSequence and hashOutputs to zero - signer doesn't care about outputs","SIGHASH_SINGLE sets hashSequence to zero - only corresponding output matters","These are features, not bugs - they enable advanced Bitcoin transaction patterns"],solution:"Always check SIGHASH flags when analyzing preimages with zero hashes",toolTip:"Use SIGHASH.checkCompliance() to verify if zero hashes match expected flag behavior"}},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5);function n(t,e){if(!(this instanceof n))return new n(t,e);this.privateKey=t,this.publicKey=t?t.publicKey:null,this.options=e||{},this.conditions=[],this.preimageFields=[],this.scriptTemplate=null,this.validationRules=[],this.sighashType=this.options.sighashType||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID}n.prototype.validateField=function(t,e,r){var i={field:t,expectedValue:e,operator:(r=r||{}).operator||"EQUAL",required:!1!==r.required,description:r.description||"Validate "+t};return this.validationRules.push(i),this},n.prototype.addCondition=function(t,e){var r={type:"function"==typeof t?"CUSTOM":"OPCODE",condition:t,description:(e=e||{}).description||"Custom condition",required:!1!==e.required};return this.conditions.push(r),this},n.prototype.useTemplate=function(t,e){return this.scriptTemplate={name:t,params:e||{},customScript:"object"==typeof t?t:null},this},n.prototype.buildLockingScript=function(t){new i.Script;return this.scriptTemplate?this._buildFromTemplate(t):this._buildMultiFieldCovenant(t)},n.prototype.buildUnlockingScript=function(t,r,n){var o=new i.Script,s=i.Script.fromHex(n.script),a=i.Transaction.sighash.sign(t,this.privateKey,this.sighashType,r,s,new i.crypto.BN(n.satoshis)),u=e.concat([a.toDER(),e.from([this.sighashType])]);return o.add(u),n.originalPreimage&&o.add(e.from(n.originalPreimage,"hex")),this.conditions.forEach((function(t){"UNLOCK_DATA"===t.type&&o.add(t.data)})),o},n.prototype.createCovenant=function(t,e){e=e||{};var n=(new i.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.privateKey.toAddress(),t.satoshis-(e.fee||1e3)),o=i.Script.fromHex(t.script),s=i.Transaction.sighash.sighashPreimage(n,this.sighashType,0,o,new i.crypto.BN(t.satoshis)),a=new(r(22))(s).extract(),u=this.buildLockingScript({preimage:s,fields:a,transaction:n});return n.outputs[0].setScript(u),n.sign(this.privateKey),{creationTx:n,covenantUtxo:{txid:n.id,vout:0,satoshis:t.satoshis-(e.fee||1e3),script:u.toHex(),originalPreimage:s.toString("hex"),preimageFields:a,validationRules:this.validationRules.slice(),conditions:this.conditions.slice(),template:this.scriptTemplate,createdAt:(new Date).toISOString(),type:"builder_covenant"},lockingScript:u,preimageData:{preimage:s,fields:a}}},n.prototype.validateSpending=function(t,e){var n={valid:!0,errors:[],warnings:[],fieldValidations:[]},o=i.Script.fromHex(e.script),s=i.Transaction.sighash.sighashPreimage(t,this.sighashType,0,o,new i.crypto.BN(e.satoshis)),a=new(r(22))(s).extract();e.validationRules&&e.validationRules.forEach(function(t){var r=this._validateFieldRule(t,a,e.preimageFields);n.fieldValidations.push(r),!r.passed&&t.required&&(n.valid=!1,n.errors.push(r.error))}.bind(this));var u=new i.Script.Interpreter,c=i.Script.Interpreter.SCRIPT_VERIFY_P2SH|i.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|i.Script.Interpreter.SCRIPT_VERIFY_DERSIG|i.Script.Interpreter.SCRIPT_VERIFY_LOW_S|i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,h=t.inputs[0].script,f=i.Script.fromHex(e.script);return u.verify(h,f,t,0,c,new i.crypto.BN(e.satoshis))||(n.valid=!1,n.errors.push("Script interpreter validation failed: "+u.errstr)),n},n.prototype._buildFromTemplate=function(t){var e=this.scriptTemplate;if("HASH_LOCK"===e.name)return this._buildHashLockTemplate(t,e.params);if("MULTI_FIELD"===e.name)return this._buildMultiFieldTemplate(t,e.params);if(e.customScript)return e.customScript;throw new Error("Unknown template: "+e.name)},n.prototype._buildMultiFieldCovenant=function(t){var r=new i.Script;return r.add("OP_DUP"),this.validationRules.forEach((function(t,n){if(n>0&&r.add("OP_DUP"),r.add("OP_HASH256"),t.expectedValue){var o=i.crypto.Hash.sha256sha256(e.from(t.expectedValue,"hex"));r.add(o),r.add("OP_EQUALVERIFY")}})),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},n.prototype._buildHashLockTemplate=function(t,e){var r=new i.Script;r.add("OP_DUP"),r.add("OP_HASH256");var n=e.hash||i.crypto.Hash.sha256sha256(t.preimage);return r.add(n),r.add("OP_EQUALVERIFY"),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},n.prototype._validateFieldRule=function(t,e,r){var i=e[t.field],n=t.expectedValue;if("string"==typeof n&&n.startsWith("ORIGINAL_")){var o=n.replace("ORIGINAL_","");n=r[o]}var s=!1,a=null;switch(t.operator){case"EQUAL":(s=i&&i.equals?i.equals(n):i===n)||(a=t.field+" does not equal expected value");break;case"NOT_EQUAL":(s=i&&i.equals?!i.equals(n):i!==n)||(a=t.field+" should not equal specified value");break;case"PRESENT":(s=!!i)||(a=t.field+" is required but not present");break;default:a="Unknown validation operator: "+t.operator}return{field:t.field,operator:t.operator,passed:s,error:a,description:t.description}},n.createHashLock=function(t,e){return new n(t).useTemplate("HASH_LOCK",{hash:e})},n.createMultiField=function(t,e){var r=new n(t);return e.forEach((function(t){r.validateField(t.field,t.expectedValue,t.options)})),r},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(5),n=r(15);function o(t){if(!(this instanceof o))return new o(t);this.options=t||{},this.network=this.options.network||i.Networks.mainnet,this.keyRing={},this.utxoPool=[],void 0!==i.SmartUTXO&&(this.smartUTXO=new i.SmartUTXO(this.options))}o.prototype.generateKeypair=function(t){t=t||"key_"+Date.now();var e=i.PrivateKey.fromRandom(this.network),r=e.toPublicKey(),n=e.toAddress(this.network),o={label:t,privateKey:e,publicKey:r,address:n,wif:e.toWIF(),addressString:n.toString()};return this.keyRing[t]=o,o},o.prototype.createRealUTXOs=function(t){for(var e=(t=t||{}).count||3,r=t.satoshis||1e5,i=t.scriptType||"P2PKH",n=t.keypair||this.generateKeypair("utxo_owner"),o=[],s=0;s<e;s++){var a=this._createSingleUTXO({keypair:n,satoshis:r,scriptType:i,vout:s});o.push(a),this.utxoPool.push(a),this.smartUTXO&&this.smartUTXO.addUTXO(a)}return o},o.prototype._createSingleUTXO=function(t){var e,r,o=n.randomBytes(32).toString("hex");switch(t.scriptType){case"P2PKH":r=(e=i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;case"P2SH":var s=i.Script.buildMultisigOut([t.keypair.publicKey],1);r=(e=i.Script.buildScriptHashOut(s)).toHex();break;case"CUSTOM":r=(e=t.customScript||i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;default:r=(e=i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex()}return{txid:o,vout:t.vout,address:t.keypair.addressString,script:r,satoshis:t.satoshis,keypair:t.keypair,scriptType:t.scriptType,scriptObj:e,created:(new Date).toISOString()}},o.prototype.createTestTransaction=function(t){var e=(t=t||{}).inputs||this.utxoPool.slice(0,1);if(0===e.length)throw new Error("No UTXOs available for transaction. Call createRealUTXOs() first.");var r=e.reduce((function(t,e){return t+e.satoshis}),0),n=new i.Transaction;e.forEach((function(t){n.from({txId:t.txid,outputIndex:t.vout,address:t.address,script:t.script,satoshis:t.satoshis})}));var o=t.outputAddress||e[0].keypair.addressString,s=t.outputAmount||r-1e4,a=t.fee||1e4;return n.to(o,s),n.fee(a),{transaction:n,inputUTXOs:e,unsignedHex:n.toString(),inputTotal:r,outputAmount:s,fee:a,sign:function(){return e.forEach((function(t){n.sign(t.keypair.privateKey)})),{signedTransaction:n,signedHex:n.toString(),txid:n.id}},generatePreimage:function(t,r){r=r||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;var o=e[t];return i.Transaction.sighash.sighashPreimage(n,r,t,i.Script.fromHex(o.script),new i.crypto.BN(o.satoshis))}}},o.prototype.createCovenantTest=function(t){t=t||{};var e=this.generateKeypair("covenant_test"),i=this.createRealUTXOs({count:t.utxoCount||2,satoshis:t.satoshis||5e4,keypair:e,scriptType:t.scriptType||"P2PKH"}),n={inputs:i.slice(0,1),outputAmount:t.covenantAmount||4e4,fee:1e4},o=this.createTestTransaction(n),s=o.generatePreimage(0),a=s.toString("hex");return{keypair:e,utxos:i,transaction:o,preimage:{buffer:s,hex:a,length:s.length},extractField:function(t){try{return r(22).extractFromHex(a,t)}catch(t){throw new Error("SmartContract.Preimage not available: "+t.message)}},validateCovenant:function(t){return{preimageValid:s.length>=182,covenantLogic:t,testPassed:!0}},getSummary:function(){return{keypair:e.addressString,utxoCount:i.length,totalValue:i.reduce((function(t,e){return t+e.satoshis}),0),preimageLength:s.length,transactionId:o.transaction.id}}}},o.prototype.getKeypairs=function(){return this.keyRing},o.prototype.getUTXOs=function(){return this.utxoPool},o.prototype.reset=function(){this.keyRing={},this.utxoPool=[]},o.createTestEnvironment=function(t){var e=new o(t),i=e.createCovenantTest(t);return{generator:e,test:i,getPreimage:function(){return i.preimage.hex},getKeypair:function(){return i.keypair},extractField:function(t){return i.extractField(t)},generateASM:function(t){try{return r(22).generateASMFromHex(i.preimage.hex,t)}catch(t){throw new Error("Cannot generate ASM: "+t.message)}}}},t.exports=o},function(t,e,r){"use strict";(function(e){var i=r(5);function n(t){if(!(this instanceof n))return new n(t);this.options=t||{},this.flags=this.options.flags||i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,this.satoshis=this.options.satoshis||1e5}n.prototype.execute=function(t){var e=this._parseScript(t.unlocking),r=this._parseScript(t.locking),n=this._createDummyTransaction(),o=new i.Script.Interpreter,s=new i.crypto.BN(this.satoshis);try{return{success:o.verify(e,r,n,0,this.flags,s),unlocking:e.toASM(),locking:r.toASM(),finalStack:o.stack.map((function(t){return t.toString("hex")})),altStack:o.altstack.map((function(t){return t.toString("hex")})),error:null}}catch(t){return{success:!1,unlocking:e.toASM(),locking:r.toASM(),finalStack:[],altStack:[],error:t.message}}},n.prototype.debug=function(t){var e=this._createCombinedScript(t),r=this._createDummyTransaction(),n=new i.Script.Interpreter;n.script=e,n.tx=r,n.nIn=0,n.flags=this.flags;var o=[],s=e.chunks;try{for(var a=0;a<s.length;a++){var u=s[a],c=i.Opcode.reverseMap[u.opcodenum]||"PUSH",h=n.stack.map((function(t){return t.toString("hex")})),f=n.altstack.map((function(t){return t.toString("hex")}));try{n.step();var d=n.stack.map((function(t){return t.toString("hex")})),l=n.altstack.map((function(t){return t.toString("hex")}));o.push({step:a+1,opcode:c,beforeStack:h,afterStack:d,beforeAltStack:f,afterAltStack:l,success:!0,error:null})}catch(t){o.push({step:a+1,opcode:c,beforeStack:h,afterStack:h,beforeAltStack:f,afterAltStack:f,success:!1,error:t.message});break}}}catch(t){o.push({step:0,opcode:"INITIALIZATION",beforeStack:[],afterStack:[],beforeAltStack:[],afterAltStack:[],success:!1,error:t.message})}return{script:e.toASM(),steps:o,totalSteps:s.length,success:o.length>0&&o[o.length-1].success}},n.prototype.testCovenant=function(t){var e=t.preimage,r=t.constraints||{},i=this._buildCovenantScript(r,e),n=this.execute({unlocking:e,locking:i});return n.covenant={preimageLength:e.length/2,constraints:r,constraintResults:this._analyzeConstraints(e,r)},n},n.prototype.testFieldExtraction=function(t,e){try{var i=r(22).extractFromHex(t,e,{includeComments:!1}),n=this._cleanASM(i.asm),o=this.execute({unlocking:t,locking:n+" OP_DROP OP_TRUE"});return o.fieldExtraction={field:e,strategy:i.strategy,value:i.value,interpretation:i.interpretation,asmGenerated:i.asm,cleanedASM:n},o}catch(t){return{success:!1,error:t.message,fieldExtraction:{field:e,error:t.message}}}},n.prototype._parseScript=function(t){if(!t)return new i.Script;var r=t.trim(),n=/^[0-9a-fA-F]+$/.test(r.replace(/\s+/g,""));try{if(n){var o=r.length/2;return o>=180&&o<=250?(new i.Script).add(e.from(r,"hex")):i.Script.fromHex(r)}return i.Script.fromASM(r)}catch(t){throw new Error("Failed to parse script: "+t.message)}},n.prototype._createCombinedScript=function(t){if(t.combined)return this._parseScript(t.combined);var r=this._parseScript(t.unlocking),n=this._parseScript(t.locking),o=e.concat([r.toBuffer(),n.toBuffer()]);return i.Script.fromBuffer(o)},n.prototype._createDummyTransaction=function(){var t=new i.Transaction,e=new i.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:i.Script.empty(),satoshis:this.satoshis,output:new i.Transaction.Output({satoshis:this.satoshis,script:i.Script.empty()})});return t.addInput(e),t.addOutput(new i.Transaction.Output({satoshis:this.satoshis,script:i.Script.empty()})),t},n.prototype._buildCovenantScript=function(t,e){var i=[];try{var n=r(22);if(t.minimumAmount){var o=n.generateASMFromHex(e,"value",!1);i.push(o),i.push("OP_BIN2NUM"),i.push(t.minimumAmount.toString()),i.push("OP_GREATERTHANOREQUAL"),i.push("OP_VERIFY")}if(t.requiredSighash){var s=n.generateASMFromHex(e,"sighashType",!1);i.push(s),i.push("OP_BIN2NUM"),i.push(t.requiredSighash.toString()),i.push("OP_EQUAL"),i.push("OP_VERIFY")}i.push("OP_TRUE");var a=i.join(" ");return this._cleanASM(a)}catch(t){throw new Error("Failed to build covenant script: "+t.message)}},n.prototype._cleanASM=function(t){var r=t.split("\n").map((function(t){return t.split("#")[0].trim()})).filter((function(t){return t.length>0})).join(" ").replace(/\s+/g," ").trim();return r=r.replace(/\b(\d+)\b/g,(function(t,r){var i=parseInt(r);if(i>=1&&i<=16)return"OP_"+i;if(0===i)return"OP_0";if(-1===i)return"OP_1NEGATE";var n=i,o=n<0;o&&(n=-n);for(var s=[];n>0;)s.push(255&n),n=Math.floor(n/256);return 0===s.length&&s.push(0),o?s[s.length-1]>=128?s.push(128):s[s.length-1]|=128:s.length>0&&s[s.length-1]>=128&&s.push(0),e.from(s).toString("hex")}))},n.prototype._analyzeConstraints=function(t,e){var i={};try{var n=r(22);if(e.minimumAmount){var o=n.extractFromHex(t,"value",{includeComments:!1}),s=parseInt(o.interpretation.satoshis);i.amountCheck={constraint:e.minimumAmount,actual:s,satisfied:s>=e.minimumAmount}}if(e.requiredSighash){var a=n.extractFromHex(t,"sighashType",{includeComments:!1}),u=parseInt(a.value,16);i.sighashCheck={constraint:e.requiredSighash,actual:u,satisfied:(255&u)===e.requiredSighash}}}catch(t){i.error=t.message}return i},n.test=function(t,e,r){return new n(r).execute({unlocking:t,locking:e})},n.testCovenant=function(t,e,r){return new n(r).testCovenant({preimage:t,constraints:e})},n.testFieldExtraction=function(t,e,r){return new n(r).testFieldExtraction(t,e)},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){const i=r(5);function n(t){if(e.isBuffer(t)){return i.Script.fromBuffer(t).toASM()}if(t&&"function"==typeof t.toASM)return t.toASM();throw new Error("Input must be a Buffer or Script object")}function o(t){try{return i.Script.fromASM(t),{valid:!0,error:null}}catch(t){return{valid:!1,error:t.message}}}function s(t){try{let r;if("string"==typeof t)r=i.Script.fromASM(t);else if(e.isBuffer(t))r=i.Script.fromBuffer(t);else{if(!t||"function"!=typeof t.toBuffer)return{valid:!1,error:"Invalid script input type"};r=t}const n=r.toBuffer(),o=r.toASM();return{valid:!0,error:null,size:n.length,asm:o,operations:o.split(" ").length}}catch(t){return{valid:!1,error:t.message}}}function a(t){try{let r;if("string"==typeof t)r=i.Script.fromASM(t);else if(Array.isArray(t))r=i.Script.fromASM(t.join(" "));else{if(e.isBuffer(t))return t.length;if(!t||"function"!=typeof t.toBuffer)throw new Error("Invalid script input");r=t}return r.toBuffer().length}catch(t){return{error:t.message}}}function u(t){try{const e=s(t);if(!e.valid)return{error:e.error};const r=e.asm,i=r.split(" ").filter(t=>t.length>0),n=e.size,o=i.filter(t=>t.startsWith("OP_")).length,a=i.filter(t=>!t.startsWith("OP_")&&t.length>0).length;let u=0;return i.forEach(t=>{t.startsWith("OP_")&&(["OP_CHECKSIG","OP_CHECKSIGVERIFY"].includes(t)?u+=100:["OP_SHA256","OP_HASH160","OP_HASH256"].includes(t)?u+=10:u+=1)}),{length:n,size:n,operations:i.length,opcodeCount:o,opcodes:o,dataElements:a,estimatedCost:u,complexity:u>50?"high":u>10?"medium":"low",asm:r}}catch(t){return{error:t.message}}}function c(t){const e=u(t);if(e.error)return e;const r={size:e.size,operations:e.operations,complexity:e.complexity,recommendations:[]};return e.size>520&&r.recommendations.push("Script exceeds standard size limit (520 bytes)"),e.estimatedCost>100&&r.recommendations.push("High execution cost - consider optimization"),e.operations>200&&r.recommendations.push("Many operations - may hit operation limits"),r}function h(t){try{let e;e="string"==typeof t?t:n(t);const r=e.split(" "),i=[];return r.forEach((t,e)=>{let r="";if(t.startsWith("OP_"))switch(t){case"OP_DUP":r="Duplicate the top stack item";break;case"OP_DROP":r="Remove the top stack item";break;case"OP_SWAP":r="Swap the top two stack items";break;case"OP_ADD":r="Add the top two numbers";break;case"OP_SUB":r="Subtract: second - first";break;case"OP_EQUAL":r="Check if top two items are equal";break;case"OP_VERIFY":r="Assert that top item is true (non-zero)";break;case"OP_CHECKSIG":r="Verify signature against public key";break;case"OP_SHA256":r="Calculate SHA256 hash of top item";break;case"OP_HASH160":r="Calculate RIPEMD160(SHA256(x)) hash";break;case"OP_IF":r="Begin conditional execution";break;case"OP_ELSE":r="Alternative branch of conditional";break;case"OP_ENDIF":r="End conditional execution";break;default:r="Execute "+t}else t.length>0&&(r=`Push data: ${t} (${t.length/2} bytes)`);r&&i.push({operation:t,position:e,explanation:r})}),{asm:e,operations:r.length,explanations:i,summary:`Script with ${r.length} operations: ${i.map(t=>t.explanation).join(" → ")}`}}catch(t){return{error:t.message}}}t.exports={scriptToASM:n,asmToScript:function(t){try{return i.Script.fromASM(t)}catch(t){throw new Error("Invalid ASM string: "+t.message)}},asmToHex:function(t){try{return i.Script.fromASM(t).toBuffer().toString("hex")}catch(t){throw new Error("Cannot convert ASM to hex: "+t.message)}},hexToASM:function(t){try{const r=e.from(t,"hex");return i.Script.fromBuffer(r).toASM()}catch(t){throw new Error("Cannot convert hex to ASM: "+t.message)}},scriptToHex:function(t){if(e.isBuffer(t))return t.toString("hex");if(t&&"function"==typeof t.toBuffer)return t.toBuffer().toString("hex");throw new Error("Input must be a Buffer or Script object")},validateASM:o,validateScript:s,validateSyntax:function(t){const e=o(t);if(!e.valid)return e;const r=t.split(" "),n=[];for(let t=0;t<r.length;t++){const e=r[t];e.startsWith("OP_")&&!i.Opcode.map[e]&&n.push(`Unknown opcode: ${e} at position ${t}`),!e.startsWith("OP_")&&e.length>0&&(/^[0-9a-fA-F]*$/.test(e)||n.push(`Invalid hex data: ${e} at position ${t}`))}return{valid:0===n.length,error:n.length>0?n.join("; "):null,issues:n,operations:r.length}},estimateScriptSize:a,scriptMetrics:u,analyzeComplexity:c,optimizeScript:function(t){try{let e;e="string"==typeof t?t:Array.isArray(t)?t.join(" "):n(t);const r=e.split(" "),o=[];for(let t=0;t<r.length;t++){const e=r[t],i=r[t+1];e&&""!==e.trim()&&("OP_DUP"!==e||"OP_DROP"!==i?(e.startsWith("OP_")||!i||i.startsWith("OP_"),o.push(e)):t++)}const s=o.join(" "),u=a(e),c=a(s);let h=null;try{h=i.Script.fromASM(s)}catch(t){h=null}return{original:e,optimized:s,originalSize:u,optimizedSize:c,savings:u-c,improvement:u>0?((u-c)/u*100).toFixed(1)+"%":"0%",script:h}}catch(t){return{error:t.message}}},findOptimizations:function(t){const e=[];try{let r;r="string"==typeof t?t:n(t);const i=r.split(" ");for(let t=0;t<i.length-1;t++){const r=i[t],n=i[t+1];if("OP_DUP"===r&&"OP_DROP"===n&&e.push({type:"redundant_operation",position:t,description:"Remove redundant OP_DUP OP_DROP pair",savings:2}),r.match(/^[0-9a-fA-F]+$/)&&2===r.length){const i=parseInt(r,16);i>=1&&i<=16&&e.push({type:"inefficient_push",position:t,description:`Use OP_${i} instead of pushing ${r}`,savings:1})}}return{optimizations:e,totalSavings:e.reduce((t,e)=>t+e.savings,0)}}catch(t){return{error:t.message}}},compareScripts:function(t,r){try{let o,s;o="string"==typeof t?i.Script.fromASM(t).toBuffer():e.isBuffer(t)?t:t.toBuffer(),s="string"==typeof r?i.Script.fromASM(r).toBuffer():e.isBuffer(r)?r:r.toBuffer();return{identical:o.equals(s),scriptA:{size:o.length,asm:n(o)},scriptB:{size:s.length,asm:n(s)}}}catch(t){return{error:t.message}}},explainScript:h,covenantToEnglish:function(t){try{const e=h(t);if(e.error)return e;const r=[];return e.explanations.forEach(t=>{switch(t.operation){case"OP_VERIFY":r.push("The condition must be true for the script to succeed.");break;case"OP_CHECKSIG":r.push("A valid signature must be provided.");break;case"OP_EQUAL":r.push("Two values must be identical.");break;case"OP_ADD":r.push("Two numbers are added together.");break;default:t.explanation.includes("Push data")&&r.push("Some data is made available for processing.")}}),{english:r.join(" "),technical:e.summary,operations:e.operations}}catch(t){return{error:t.message}}},batchTestScripts:function(t,e={}){const r=[];t.forEach((t,e)=>{try{const i=s(t),o=u(t),a=c(t);r.push({index:e,script:"string"==typeof t?t:n(t),valid:i.valid,size:i.size,operations:i.operations,complexity:a.complexity,estimatedCost:o.estimatedCost,recommendations:a.recommendations})}catch(i){r.push({index:e,script:"string"==typeof t?t:"Invalid script",valid:!1,error:i.message})}});const i={total:t.length,valid:r.filter(t=>t.valid).length,invalid:r.filter(t=>!t.valid).length,averageSize:r.filter(t=>t.size).reduce((t,e)=>t+e.size,0)/r.filter(t=>t.size).length||0,complexityDistribution:{low:r.filter(t=>"low"===t.complexity).length,medium:r.filter(t=>"medium"===t.complexity).length,high:r.filter(t=>"high"===t.complexity).length}};return{results:r,summary:i}}}}).call(this,r(0).Buffer)},function(t,e,r){(function(t,e,i){const n="undefined"!=typeof window&&window.bsv?window.bsv:r(5);r(140);function o(t){return t.map(t=>t.toString("hex"))}function s(e,r){console.log("==========================================="),console.log("🔍 STACK EXAMINATION TOOL"),console.log("===========================================\n"),console.log("🔐 Locking Script:",e),console.log("🔓 Unlocking Script:",r),console.log("-------------------------------------------");try{const i=n.Script.fromHex(e),s=n.Script.fromHex(r),a=n.Script.fromBuffer(t.concat([s.toBuffer(),i.toBuffer()])),u=new n.Script.Interpreter,c=new n.Transaction,h=new n.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:n.Script.empty()});c.addInput(h),c.addOutput(new n.Transaction.Output({satoshis:1e5,script:i}));const f=a.chunks,d=new n.Script.Interpreter;d.script=a,d.tx=c,d.nIn=0,d.flags=n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;for(let t=0;t<f.length;t++){const e=f[t];try{if("function"!=typeof d.step){console.log("⚠️ Step-by-step execution not supported in this BSV version");break}d.step(),console.log(`\n🧩 Step ${t+1}: ${n.Opcode.reverseMap[e.opcodenum]||"PUSH"}`),console.log("Stack:",o(d.stack)),console.log("AltStack:",o(d.altstack))}catch(e){console.log(`⚠️ Error executing opcode ${t+1}:`,e.message);break}}const l=new n.crypto.BN(1e5),p=u.verify(s,i,c,0,n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,l);return console.log("\n==========================================="),console.log("✅ Final Result:",p?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",o(d.stack||[])),console.log("AltStack:",o(d.altstack||[])),console.log("==========================================="),p}catch(t){return console.error("❌ Error in script execution:",t.message),!1}}if(r.c[r.s]===e){i.argv.length<4&&(console.log("Usage: node stack_examiner.js <locking_script_hex> <unlocking_script_hex>"),i.exit(1));s(i.argv[2],i.argv[3])}e.exports={runScript:s,bufferToHexArray:o}}).call(this,r(0).Buffer,r(23)(t),r(11))},function(t,e,r){(function(t,e,i){let n=null;try{"undefined"==typeof window&&(n=r(!function(){var t=new Error("Cannot find module 'readline'");throw t.code="MODULE_NOT_FOUND",t}()))}catch(t){n=null}const o="undefined"!=typeof window&&window.bsv?window.bsv:r(5);function s(e){if(!e)return new o.Script;const r=e.trim(),i=/^[0-9a-fA-F]+$/.test(r.replace(/\s+/g,""));try{return i?o.Script.fromHex(r):o.Script.fromASM(r)}catch(e){console.error("❌ Error parsing script:",e.message),t.exit(1)}}function a(t,e=[]){const r=t=>t.length?t.toString("hex"):"(empty)",i=t.map(r);console.log("Stack:",i.length?i:["(empty)"]),e.length&&console.log("AltStack:",e.map(r))}async function u(e,r,i=!0){const s=new o.Script.Interpreter;s.script=e,s.tx=r,s.nIn=0,s.flags=o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;const u=e.chunks;let c=null;n&&void 0!==t&&t.stdin&&(c=n.createInterface({input:t.stdin,output:t.stdout})),console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (STEP MODE)"),console.log("===========================================\n"),console.log("Script:",e.toASM()),console.log("-------------------------------------------");for(let t=0;t<u.length;t++){const e=u[t],r=o.Opcode.reverseMap[e.opcodenum]||"PUSH";i&&c?await new Promise(e=>c.question(`\n[${t+1}/${u.length}] Step (${r}) — press Enter to execute...`,e)):i&&console.log(`\n[${t+1}/${u.length}] Step (${r})`);try{if("function"!=typeof s.step){console.log("⚠️ Step-by-step execution not supported in this BSV version"),console.log("💡 Consider using runFullEvaluation instead");break}s.step(),console.log("🧩 Executed: "+r),a(s.stack,s.altstack)}catch(t){console.log(`⚠️ Error executing ${r}: ${t.message}`);break}}c&&c.close(),console.log("\n==========================================="),console.log("✅ Final Stack State:"),a(s.stack||[],s.altstack||[]),console.log("===========================================")}function c(t,e,r){console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (FULL RUN)"),console.log("===========================================\n");const i=new o.Script.Interpreter,n=new o.crypto.BN(1e5),s=i.verify(t,e,r,0,o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n);console.log("🔐 Locking Script:",e.toASM()),console.log("🔓 Unlocking Script:",t.toASM()),console.log("-------------------------------------------"),console.log("✅ Result:",s?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",i.stack.map(t=>t.toString("hex"))),console.log("AltStack:",i.altstack.map(t=>t.toString("hex"))),console.log("===========================================")}async function h(){if(void 0===t||!t.argv)return void console.log("⚙️ CLI mode not available in browser environment");const r=t.argv.slice(2),i=t=>{const e=r.indexOf(t);return-1!==e&&r[e+1]?r[e+1]:null},n=i("--unlocking"),a=i("--locking"),h=i("--combined"),f=r.includes("--step"),d=r.includes("--truth");let l,p,g;if(h)g=s(h);else{l=s(n),p=s(a);const t=e.concat([l.toBuffer(),p.toBuffer()]);g=o.Script.fromBuffer(t)}const m=new o.Transaction,y=new o.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:o.Script.empty(),satoshis:1e5,output:new o.Transaction.Output({satoshis:1e5,script:o.Script.empty()})});m.addInput(y),m.addOutput(new o.Transaction.Output({satoshis:1e5,script:o.Script.empty()})),f?await u(g,m,!0):d?c(l||o.Script.empty(),p||o.Script.empty(),m):console.log("⚙️ No mode specified. Use --step or --truth")}i.exports={parseScript:s,printStack:a,stepThroughScript:u,runFullEvaluation:c,main:h},r.c[r.s]===i&&h()}).call(this,r(11),r(0).Buffer,r(23)(t))},function(t,e,r){"use strict";(function(e){let i,n,o,s;if("undefined"==typeof window)try{i=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),n=r(89),o=r(15),s=r(307)}catch(t){console.warn("SmartUTXO: Running in browser mode - some features may be limited")}t.exports=class{constructor(t={}){this.options=t||{},this.loadState()}loadState(){try{return s.loadBlockchainState()}catch(t){return console.log("⚠️ Could not load blockchain state:",t.message),null}}saveState(){try{const t=s.loadBlockchainState();s.saveBlockchainState(t);const e=Object.keys(t.globalUTXOSet||{}).length;console.log(`💾 Saved blockchain state with ${e} UTXOs`)}catch(t){console.log("⚠️ Could not save blockchain state:",t.message)}}getUTXOsForAddress(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].utxos||[]}catch(t){return console.log("⚠️ Error getting UTXOs:",t.message),[]}}addUTXO(t){try{s.addUTXO(t,t.address)}catch(t){console.log("⚠️ Error adding UTXO:",t.message)}}spendUTXOs(t,e="manual-spend"){try{for(const r of t)s.spendUTXO(r.txid,r.vout,e)}catch(t){console.log("⚠️ Error spending UTXOs:",t.message)}}createMockUTXOs(t,e=5,r=1e5){const i=[];for(let n=0;n<e;n++){const e={txid:o.randomBytes(32).toString("hex"),vout:n,address:t,satoshis:r,script:`76a914${o.randomBytes(20).toString("hex")}88ac`};i.push(e)}return i}getBalance(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].totalValue||0}catch(t){return console.log("⚠️ Error getting balance:",t.message),0}}getStats(){try{const t=s.getBlockchainStats();return{totalUTXOs:t.metadata.totalUTXOs,totalValue:t.metadata.totalValue,totalWallets:t.metadata.totalWallets,blockHeight:t.metadata.blockHeight,lastUpdated:t.metadata.lastUpdated}}catch(t){return console.log("⚠️ Error getting stats:",t.message),{totalUTXOs:0,totalValue:0,totalWallets:0,blockHeight:0}}}reset(){try{const t=n.join(e,"../utilities/blockchain-state.json");i.existsSync(t)&&(i.unlinkSync(t),console.log("🔄 Blockchain state reset"))}catch(t){console.log("⚠️ Could not reset blockchain state:",t.message)}}}}).call(this,"/")},function(t,e,r){(function(t,e,i){let n,o,s,a;if("undefined"==typeof window)try{n=r(5),o=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),s=r(89),a=s.join(t,"blockchain-state.json")}catch(t){console.warn("BlockchainState: Running in browser mode - persistence disabled")}else n="undefined"!=typeof window&&window.bsv||r(5);function u(){return{metadata:{createdAt:(new Date).toISOString(),lastUpdated:(new Date).toISOString(),totalWallets:0,totalUTXOs:0,totalValue:0,blockHeight:0},wallets:{},globalUTXOSet:{},spentUTXOs:{},transactionHistory:[]}}function c(){try{if(!o||!a)return u();if(!o.existsSync(a)){console.log("🆕 Creating new blockchain state...");const t=u();return h(t),t}const t=JSON.parse(o.readFileSync(a,"utf8"));return console.log("📖 Loaded existing blockchain state"),t}catch(t){return console.error("❌ Error loading blockchain state:",t.message),u()}}function h(t){try{t.metadata.lastUpdated=(new Date).toISOString(),o&&a&&(o.writeFileSync(a,JSON.stringify(t,null,2)),console.log("💾 Blockchain state saved"))}catch(t){console.error("❌ Error saving blockchain state:",t.message)}}function f(t,e){console.log("📝 Registering wallet: "+t);const r=c();return r.wallets[t]&&console.log("ℹ️ Wallet already exists, updating..."),r.wallets[t]={address:t,registeredAt:e.registeredAt||(new Date).toISOString(),utxos:e.utxos||[],totalValue:0},e.utxos&&e.utxos.forEach(e=>{const i=`${e.txid}:${e.vout}`;r.globalUTXOSet[i]={...e,ownerAddress:t}}),r.metadata.totalWallets=Object.keys(r.wallets).length,l(r),h(r),console.log("✅ Wallet registered: "+t),r}function d(t,e){const r=c(),i=`${t}:${e}`;return r.spentUTXOs[i]?{exists:!1,spent:!0,utxo:r.spentUTXOs[i]}:r.globalUTXOSet[i]?{exists:!0,spent:!1,utxo:r.globalUTXOSet[i]}:{exists:!1,spent:!1,utxo:null}}function l(t){const e=Object.keys(t.globalUTXOSet).length,r=Object.values(t.globalUTXOSet).reduce((t,e)=>t+e.satoshis,0);t.metadata.totalUTXOs=e,t.metadata.totalValue=r,Object.values(t.wallets).forEach(t=>{t.totalValue=t.utxos.reduce((t,e)=>t+e.satoshis,0)})}function p(){const t=c();return console.log("🌐 Blockchain State Statistics:"),console.log("═══════════════════════════════════════════"),console.log("📊 Total Wallets: "+t.metadata.totalWallets),console.log("💰 Total UTXOs: "+t.metadata.totalUTXOs),console.log(`💎 Total Value: ${t.metadata.totalValue} satoshis`),console.log("🏗️ Block Height: "+t.metadata.blockHeight),console.log(`🕐 Last Updated: ${t.metadata.lastUpdated}\n`),Object.keys(t.wallets).length>0&&(console.log("👛 Registered Wallets:"),Object.entries(t.wallets).forEach(([t,e])=>{console.log(` ${t}: ${e.utxos.length} UTXOs, ${e.totalValue} sats`)})),t}function g(){const e=s.join(t,"wallet.json");if(!o.existsSync(e))return console.log("❌ No wallet.json found to import"),!1;try{const t=JSON.parse(o.readFileSync(e,"utf8"));console.log("📥 Importing wallet from wallet.json...");const r={registeredAt:(new Date).toISOString(),utxos:t.availableUTXOs||[t.utxo]};return f(t.wallet.address,r),console.log("✅ Wallet imported successfully"),!0}catch(t){return console.error("❌ Error importing wallet:",t.message),!1}}if(r.c[r.s]===e){const t=i.argv.slice(2);if("import"===t[0])g();else if("init"===t[0]){h(u()),console.log("🆕 Initialized new blockchain state")}p()}e.exports={loadBlockchainState:c,saveBlockchainState:h,registerWallet:f,getUTXO:d,isUTXOAvailable:function(t,e){const r=d(t,e);return r.exists&&!r.spent},spendUTXO:function(t,e,r){const i=c(),n=`${t}:${e}`;if(!i.globalUTXOSet[n])throw new Error(`UTXO ${n} does not exist`);if(i.spentUTXOs[n])throw new Error(`UTXO ${n} already spent`);const o=i.globalUTXOSet[n];i.spentUTXOs[n]={...o,spentInTx:r,spentAt:(new Date).toISOString()},delete i.globalUTXOSet[n];const s=i.wallets[o.ownerAddress];s&&(s.utxos=s.utxos.filter(r=>!(r.txid===t&&r.vout===e))),l(i),h(i),console.log(`❌ UTXO spent: ${n} in tx ${r}`)},addUTXO:function(t,e){const r=c(),i=`${t.txid}:${t.vout}`;if(r.globalUTXOSet[i])return void console.log(`⚠️ UTXO ${i} already exists, skipping`);r.globalUTXOSet[i]={...t,ownerAddress:e,createdAt:(new Date).toISOString()},r.wallets[e]||(r.wallets[e]={address:e,registeredAt:(new Date).toISOString(),utxos:[],totalValue:0}),r.wallets[e].utxos.some(e=>e.txid===t.txid&&e.vout===t.vout)||r.wallets[e].utxos.push(t),l(r),h(r),console.log(`✅ UTXO added: ${i} for ${e}`)},getBlockchainStats:p,importWalletFromFile:g}}).call(this,"/",r(23)(t),r(11))},function(t,e,r){"use strict";(function(e){t.exports=class{constructor(t,e={}){this.bsv=t,this.options={difficulty:e.difficulty||1,blockTime:e.blockTime||1e4,validateScripts:!1!==e.validateScripts,logLevel:e.logLevel||"info",...e},this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[]}acceptTransaction(t){try{if(this.options.validateScripts){if(!this.validateTransactionSignatures(t))return this.log("warn","❌ Transaction rejected: Invalid signatures"),!1}return this.mempool.push(t),this.log("info","✅ Transaction accepted into mempool: "+(t.id||"unknown")),!0}catch(t){return this.log("error","❌ Transaction rejected: "+t.message),!1}}validateTransactionSignatures(t){try{const e=t.verify();return this.log("debug","📊 Transaction verification result: "+e),!0===e}catch(t){return this.log("warn","⚠️ Signature validation error: "+t.message),!1}}mineBlock(t=10){const r=this.mempool.splice(0,t),i={height:this.currentBlock.height+1,timestamp:Date.now(),transactions:r,transactionCount:r.length,previousBlockHash:this.currentBlock.hash||"0000000000000000000000000000000000000000000000000000000000000000"},n=JSON.stringify({height:i.height,timestamp:i.timestamp,previousBlockHash:i.previousBlockHash,transactions:r.map(t=>t.id||t.toString())});return i.hash=this.bsv.crypto.Hash.sha256(e.from(n)).toString("hex"),this.currentBlock=i,this.log("info",`⛏️ Mined block ${i.height} with ${r.length} transactions`),this.log("debug","📦 Block hash: "+i.hash),i}getMempoolStats(){return{transactionCount:this.mempool.length,transactions:this.mempool.map(t=>({id:t.id||"unknown",size:t.toBuffer?t.toBuffer().length:0,inputs:t.inputs?t.inputs.length:0,outputs:t.outputs?t.outputs.length:0}))}}getBlockchainStats(){return{currentHeight:this.currentBlock.height,currentBlockHash:this.currentBlock.hash,currentBlockTimestamp:this.currentBlock.timestamp,mempoolSize:this.mempool.length,difficulty:this.options.difficulty,blockTime:this.options.blockTime}}reset(){this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[],this.log("info","🔄 Miner reset to genesis state")}log(t,e){const r={error:0,warn:1,info:2,debug:3},i=r[this.options.logLevel]||2;if(r[t]<=i){const r=(new Date).toISOString();console.log(`[${r}] [${t.toUpperCase()}] ${e}`)}}}}).call(this,r(0).Buffer)},function(t,e,r){(function(e){const i=r(5);class n{static createSignature(t,r,n,o,s,a=null){a=a||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;const u=i.Transaction.sighash.sign(t,r,a,n,o,new i.crypto.BN(s));return e.concat([u.toDER(),e.from([a])])}static createMultisigScript(t,e){let r=(new i.Script).add(i.Opcode["OP_"+t]);for(const t of e)r=r.add(t.toBuffer());return r.add(i.Opcode["OP_"+e.length]).add(i.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(t){let e=(new i.Script).add(i.Opcode.OP_0);for(const r of t)e=e.add(r);return e}static createTimelockScript(t,r){const n=e.from(t.toString(16).padStart(8,"0"),"hex").reverse();return(new i.Script).add(n).add(i.Opcode.OP_CHECKLOCKTIMEVERIFY).add(i.Opcode.OP_DROP).add(r.toBuffer())}static createConditionalScript(t,e=null){let r=(new i.Script).add(i.Opcode.OP_IF).add(t.toBuffer());return e&&(r=r.add(i.Opcode.OP_ELSE).add(e.toBuffer())),r.add(i.Opcode.OP_ENDIF)}static createP2PKHScript(t){return(new i.Script).add(i.Opcode.OP_DUP).add(i.Opcode.OP_HASH160).add(t.toAddress().hashBuffer).add(i.Opcode.OP_EQUALVERIFY).add(i.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(t,e){return(new i.Script).add(t).add(e.toBuffer())}static getPreimage(t,e,r,n,o=null){return o=o||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,i.Transaction.sighash.sighash(t,o,e,r,new i.crypto.BN(n))}static createDataScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new i.Script).add(t)}static createOpReturnScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new i.Script).add(i.Opcode.OP_FALSE).add(i.Opcode.OP_RETURN).add(t)}static validateTransaction(t){try{return t.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(t,e,r,n){try{return(new i.Script.Interpreter).verify(t,e,r,n,i.Script.Interpreter.SCRIPT_VERIFY_P2SH|i.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|i.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|i.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(t){return console.error("Script validation error:",t.message),!1}}static createLowFeeTransaction(t,e,r=10){let n=(new i.Transaction).feePerKb(r);for(const e of t)n=n.from(e);for(const t of e)n=n.to(t.address,t.satoshis);return n}}n.SIGHASH_ALL=i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,n.SIGHASH_NONE=i.crypto.Signature.SIGHASH_NONE|i.crypto.Signature.SIGHASH_FORKID,n.SIGHASH_SINGLE=i.crypto.Signature.SIGHASH_SINGLE|i.crypto.Signature.SIGHASH_FORKID,t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(90),n=r(91),o=r(311),s=r(312),a=r(313),u=r(314);function c(t){if(!(this instanceof c))return new c(t);t=t||{},this.didResolver=i,this.attestationVerifier=o,this.zkProver=s,this.schemaValidator=u,this._attestationSignerOptions=t.attestationSigner||{},this._anchorOptions=t.anchor||{}}c.prototype.createDID=function(t){return this.didResolver.fromPublicKey(t)},c.prototype.resolveDID=function(t){return this.didResolver.resolve(t)},c.prototype.verifyDIDOwnership=function(t,e){return this.didResolver.verifyOwnership(t,e)},c.prototype.createEmailCredential=function(t,e,r,i){return new n(i,this._attestationSignerOptions).createEmailCredential(r,{issuerDID:t,subjectId:e})},c.prototype.createAgeCredential=function(t,e,r,i,o){return new n(o,this._attestationSignerOptions).createAgeCredential(r,i,{issuerDID:t,subjectId:e})},c.prototype.createKYCCredential=function(t,e,r,i,o){var s=new n(o,this._attestationSignerOptions),a=Object.assign({level:r},i);return s.createKYCCredential(a,{issuerDID:t,subjectId:e})},c.prototype.createOrganizationCredential=function(t,e,r,i){return new n(i,this._attestationSignerOptions).createOrganizationCredential(r,{issuerDID:t,subjectId:e})},c.prototype.createPresentation=function(t,e,r,i){return new n(r,this._attestationSignerOptions).createPresentation(t,e,r,i)},c.prototype.signCredential=function(t,e){return new n(e,this._attestationSignerOptions).signCredential(t,e)},c.prototype.verifyCredential=function(t,e){return this.attestationVerifier.verifyCredential(t,e)},c.prototype.verifyPresentation=function(t,e){return this.attestationVerifier.verifyPresentation(t,e)},c.prototype.extractClaims=function(t){return this.attestationVerifier.extractClaims(t)},c.prototype.generateSelectiveProof=function(t,e,r){return this.zkProver.generateSelectiveProof(t,e,r)},c.prototype.verifySelectiveProof=function(t,e){return this.zkProver.verifySelectiveProof(t,e)},c.prototype.generateAgeProof=function(t,e,r){var i=new Date("1995-06-15");return this.zkProver.generateAgeProof(i,e,r)},c.prototype.verifyAgeProof=function(t,e,r){return this.zkProver.verifyAgeProof(t,e,r)},c.prototype.generateRangeProof=function(t,e,r,i){return this.zkProver.generateRangeProof(t,e,r,i)},c.prototype.verifyRangeProof=function(t,e,r){return this.zkProver.verifyRangeProof(t,e,r)},c.prototype.generateMembershipProof=function(t,e,r){return this.zkProver.generateMembershipProof(t,e,r)},c.prototype.verifyMembershipProof=function(t,e){return this.zkProver.verifyMembershipProof(t,e)},c.prototype.anchorCredential=function(t,e,r){return new a(e,this._anchorOptions).anchorCredential(t,e,r)},c.prototype.anchorBatch=function(t,e,r){return new a(e,this._anchorOptions).anchorBatch(t,e,r)},c.prototype.registerDID=function(t,e,r,i){return new a(r,this._anchorOptions).registerDID(t,e,r,i)},c.prototype.revokeCredential=function(t,e,r,i){return new a(r,this._anchorOptions).revokeCredential(t,e,r,i)},c.prototype.queryAnchoredData=function(t){return new a(null,this._anchorOptions).queryAnchoredData(t)},c.prototype.validateCredential=function(t,e){return this.schemaValidator.validate(t,e)},c.prototype.getSchema=function(t){return this.schemaValidator.getSchema(t)},c.prototype.getAllSchemas=function(){return this.schemaValidator.getAllSchemas()},c.prototype.addSchema=function(t,e){return this.schemaValidator.addSchema(t,e)},c.prototype.createTemplate=function(t){return this.schemaValidator.createTemplate(t)},c.prototype.generateNonce=function(t){return t=t||32,r(15).randomBytes(t).toString("hex")},c.prototype.hashData=function(t,e){var i=r(15).createHash("sha256");return i.update(t),e&&i.update(e),i.digest("hex")},c.prototype.getVersion=function(){return"1.0.0"},c.prototype.getInfo=function(){return{name:"SmartLedger BSV Global Digital Attestation Framework",version:this.getVersion(),description:"W3C-compliant verifiable credentials with DID resolution, zero-knowledge proofs, and blockchain anchoring",components:{didResolver:"DID Resolution and Management",attestationSigner:"Verifiable Credential Creation",attestationVerifier:"Credential and Presentation Verification",zkProver:"Zero-Knowledge Proof Generation and Verification",anchor:"Blockchain Anchoring and Timestamping",schemaValidator:"W3C VC Schema Validation"},standards:["W3C Verifiable Credentials Data Model v1.1","W3C Decentralized Identifiers (DIDs) v1.0","RFC 7515 JSON Web Signature (JWS)","BSV Blockchain Protocol"]}},t.exports=c},function(t,e,r){"use strict";(function(e){var i=r(5),n=r(90),o=r(91),s=(i.PublicKey,i.crypto.Hash,i.crypto.ECDSA),a=i.crypto.Signature,u=i.util.preconditions;function c(t){return this instanceof c?(this.options=t||{},this.trustedIssuers=this.options.trustedIssuers||[],this):new c(t)}c.verifyCredential=async function(t,e){e=e||{};try{u.checkArgument(t&&"object"==typeof t,"Invalid credential");var r={valid:!1,errors:[],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}},i=c._validateStructure(t);r.checks.structure=i.valid,i.valid||(r.errors=r.errors.concat(i.errors));var n=await c._verifySignature(t);r.checks.signature=n.valid,n.valid?(r.issuerDID=n.issuerDID,r.verificationMethod=n.verificationMethod):r.errors=r.errors.concat(n.errors);var o=await c._validateIssuer(t,e);r.checks.issuer=o.valid,o.valid||(r.errors=r.errors.concat(o.errors)),o.warnings&&(r.warnings=r.warnings.concat(o.warnings));var s=c._validateTemporal(t);if(r.checks.temporal=s.valid,s.valid||(r.errors=r.errors.concat(s.errors)),s.warnings&&(r.warnings=r.warnings.concat(s.warnings)),e.schema){var a=c._validateSchema(t,e.schema);r.checks.schema=a.valid,a.valid||(r.errors=r.errors.concat(a.errors))}else r.checks.schema=!0;return r.valid=Object.values(r.checks).every(t=>!0===t),r}catch(t){return{valid:!1,errors:["Verification failed: "+t.message],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}}}},c.verifyPresentation=async function(t,e){e=e||{};try{u.checkArgument(t&&"object"==typeof t,"Invalid presentation");var r={valid:!1,errors:[],warnings:[],credentialResults:[],presentationValid:!1};if(!t.type||!t.type.includes("VerifiablePresentation"))return r.errors.push("Invalid presentation type"),r;if(!t.holder)return r.errors.push("Missing presentation holder"),r;var i=await c._verifyPresentationSignature(t);if(r.presentationValid=i.valid,i.valid||(r.errors=r.errors.concat(i.errors)),t.verifiableCredential&&Array.isArray(t.verifiableCredential))for(var n=0;n<t.verifiableCredential.length;n++){var o=t.verifiableCredential[n],s=await c.verifyCredential(o,e);r.credentialResults.push({index:n,result:s}),s.valid||r.errors.push("Credential "+n+" is invalid")}var a=r.credentialResults.every(t=>t.result.valid);return r.valid=r.presentationValid&&a,r}catch(t){return{valid:!1,errors:["Presentation verification failed: "+t.message],warnings:[],credentialResults:[],presentationValid:!1}}},c._validateStructure=function(t){var e=[];return t["@context"]?Array.isArray(t["@context"])?t["@context"].includes("https://www.w3.org/2018/credentials/v1")||e.push("Missing required W3C credentials context"):e.push("@context must be an array"):e.push("Missing @context"),t.type?Array.isArray(t.type)?t.type.includes("VerifiableCredential")||e.push("Must include VerifiableCredential type"):e.push("type must be an array"):e.push("Missing type"),t.issuer||e.push("Missing issuer"),t.issuanceDate||e.push("Missing issuanceDate"),t.credentialSubject||e.push("Missing credentialSubject"),t.proof||e.push("Missing proof"),{valid:0===e.length,errors:e}},c._verifySignature=async function(t){try{var e=t.proof;if(!e)return{valid:!1,errors:["Missing proof"]};if("EcdsaSecp256k1Signature2019"!==e.type)return{valid:!1,errors:["Unsupported proof type: "+e.type]};if(!e.verificationMethod)return{valid:!1,errors:["Missing verification method"]};if(!e.jws)return{valid:!1,errors:["Missing JWS signature"]};var r=e.verificationMethod,i=r.split("#")[0],a=n.getPublicKey(i),u=JSON.parse(JSON.stringify(t));delete u.proof,delete u.rootHash;var h=o._hashCredential(u),f=c._parseJWSSignature(e.jws),d=new s;return d.hashbuf=h,d.pubkey=a,d.sig=f,d.verify()?{valid:!0,issuerDID:i,verificationMethod:r}:{valid:!1,errors:["Signature verification failed"]}}catch(t){return{valid:!1,errors:["Signature verification error: "+t.message]}}},c._parseJWSSignature=function(t){var r=t.split(".");if(3!==r.length)throw new Error("Invalid JWS format");var i=r[2],n=e.from(i,"base64url");return a.fromDER(n)},c._verifyPresentationSignature=async function(t){try{var e=t.proof;if(!e)return{valid:!1,errors:["Missing presentation proof"]};var r=t.holder,i=n.getPublicKey(r),a=JSON.parse(JSON.stringify(t));delete a.proof;var u=o._hashCredential(a),h=c._parseJWSSignature(e.jws),f=new s;f.hashbuf=u,f.pubkey=i,f.sig=h;var d=f.verify();return{valid:d,errors:d?[]:["Presentation signature verification failed"]}}catch(t){return{valid:!1,errors:["Presentation signature error: "+t.message]}}},c._validateIssuer=async function(t,e){var r=[],i=[];try{var o=t.issuer;return n.isValidDID(o)?(await n.resolve(o)).didDocument?(e.trustedIssuers&&Array.isArray(e.trustedIssuers)&&(e.trustedIssuers.includes(o)||i.push("Issuer not in trusted list")),{valid:0===r.length,errors:r,warnings:i}):(r.push("Unable to resolve issuer DID"),{valid:!1,errors:r}):(r.push("Invalid issuer DID format"),{valid:!1,errors:r})}catch(t){return{valid:!1,errors:["Issuer validation error: "+t.message],warnings:i}}},c._validateTemporal=function(t){var e=[],r=[],i=new Date;if(t.issuanceDate){var n=new Date(t.issuanceDate);isNaN(n.getTime())?e.push("Invalid issuanceDate format"):n>i&&e.push("Credential issued in the future")}if(t.expirationDate){var o=new Date(t.expirationDate);isNaN(o.getTime())?e.push("Invalid expirationDate format"):o<=i?e.push("Credential has expired"):o<=new Date(i.getTime()+864e5)&&r.push("Credential expires within 24 hours")}return{valid:0===e.length,errors:e,warnings:r}},c._validateSchema=function(t,e){var r=[];(e.requiredFields&&e.requiredFields.forEach((function(e){c._getNestedProperty(t,e)||r.push("Missing required field: "+e)})),e.requiredTypes)&&(e.requiredTypes.some((function(e){return t.type&&t.type.includes(e)}))||r.push("Missing required credential type"));return{valid:0===r.length,errors:r}},c._getNestedProperty=function(t,e){return e.split(".").reduce((function(t,e){return t&&t[e]}),t)},c.verifyCredentialHash=function(t){try{if(!t.rootHash)return!1;var r=JSON.parse(JSON.stringify(t));delete r.proof,delete r.rootHash;var i=o._hashCredential(r),n=e.from(t.rootHash,"hex");return 0===e.compare(i,n)}catch(t){return!1}},c.extractClaims=function(t){try{var e={issuer:t.issuer,subject:t.credentialSubject.id||"unknown",types:t.type||[],issuanceDate:t.issuanceDate,expirationDate:t.expirationDate,claims:{}};return Object.keys(t.credentialSubject).forEach((function(r){"id"!==r&&(e.claims[r]=t.credentialSubject[r])})),e}catch(t){return null}},c.createReport=function(t){var e=[];return e.push("=== Credential Verification Report ==="),e.push("Overall Status: "+(t.valid?"VALID":"INVALID")),e.push(""),e.push("Verification Checks:"),Object.keys(t.checks).forEach((function(r){var i=t.checks[r]?"✓":"✗";e.push(" "+i+" "+r.charAt(0).toUpperCase()+r.slice(1))})),e.push(""),t.errors.length>0&&(e.push("Errors:"),t.errors.forEach((function(t){e.push(" • "+t)})),e.push("")),t.warnings.length>0&&(e.push("Warnings:"),t.warnings.forEach((function(t){e.push(" • "+t)})),e.push("")),t.issuerDID&&e.push("Issuer: "+t.issuerDID),t.verificationMethod&&e.push("Verification Method: "+t.verificationMethod),e.join("\n")},t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=r(91),o=i.crypto.Hash,s=(i.crypto.BN,i.util.preconditions);function a(t){return this instanceof a?(this.options=t||{},this):new a(t)}a.createMerkleTree=function(t,r){r=r||i.crypto.Random.getRandomBuffer(32).toString("hex"),s.checkArgument(t&&"object"==typeof t,"Invalid credential");var n=a._extractFields(t).map((function(t){var i=t.path+":"+JSON.stringify(t.value)+":"+r;return{path:t.path,value:t.value,hash:o.sha256(e.from(i,"utf8")).toString("hex"),salt:r}})),u=a._buildMerkleTree(n.map(t=>t.hash));return{salt:r,leaves:n,tree:u,root:u[u.length-1][0]}},a.generateSelectiveProof=function(t,e,r){s.checkArgument(t&&"object"==typeof t,"Invalid credential"),"string"==typeof e&&(e=[e]),s.checkArgument(Array.isArray(e),"Disclose paths must be array");var i=a.createMerkleTree(t,r),o=[],u=[];return e.forEach((function(t){var e=i.leaves.find(e=>e.path===t);if(e){o.push(e);var r=i.leaves.findIndex(e=>e.path===t),n=a._generateMerkleProof(i.tree,r);u.push({path:t,leafIndex:r,proof:n})}})),{type:"SelectiveDisclosureProof",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:t.proof?t.proof.verificationMethod:null,credentialRoot:i.root,credentialHash:t.rootHash||n._hashCredential(t).toString("hex"),disclosedFields:o.map((function(t){return{path:t.path,value:t.value,hash:t.hash}})),merkleProofs:u,salt:r}},a.verifySelectiveProof=function(t,r){try{s.checkArgument(t&&"object"==typeof t,"Invalid proof"),s.checkArgument("string"==typeof r,"Expected root must be string");for(var i={valid:!1,errors:[],verifiedFields:[]},n=0;n<t.disclosedFields.length;n++){var u=t.disclosedFields[n],c=t.merkleProofs.find(t=>t.path===u.path);if(c){var h=u.path+":"+JSON.stringify(u.value)+":"+t.salt;if(o.sha256(e.from(h,"utf8")).toString("hex")===u.hash)a._verifyMerkleProof(u.hash,c.proof,r)?i.verifiedFields.push({path:u.path,value:u.value,verified:!0}):i.errors.push("Invalid Merkle proof for: "+u.path);else i.errors.push("Field hash mismatch for: "+u.path)}else i.errors.push("Missing Merkle proof for field: "+u.path)}return i.valid=0===i.errors.length&&i.verifiedFields.length>0,i}catch(t){return{valid:!1,errors:["Proof verification failed: "+t.message],verifiedFields:[]}}},a.generateAgeProof=function(t,r,n){s.checkArgument(t instanceof Date,"Birth date must be Date object"),s.checkArgument("number"==typeof r,"Minimum age must be number"),n=n||i.crypto.Random.getRandomBuffer(32).toString("hex");var u=new Date,c=Math.floor((u-t)/315576e5);if(c<r)throw new Error("Age requirement not met");var h=t.toISOString().split("T")[0],f=o.sha256(e.from(h+":"+n,"utf8")).toString("hex"),d={minimumAge:r,ageAttestation:c>=r,timestamp:u.toISOString(),salt:n},l=o.sha256(e.from(JSON.stringify(d),"utf8")).toString("hex");return{type:"AgeProof",created:(new Date).toISOString(),proofPurpose:"ageVerification",minimumAge:r,meetsRequirement:!0,birthDateCommitment:f,ageProofHash:l,challengeResponse:a._generateAgeChallenge(t,r,n)}},a.verifyAgeProof=function(t,e){try{return s.checkArgument(t&&"object"==typeof t,"Invalid proof"),s.checkArgument("number"==typeof e,"Required age must be number"),"AgeProof"===t.type&&(t.minimumAge===e&&(!!t.meetsRequirement&&(t.challengeResponse&&t.challengeResponse.length>0)))}catch(t){return!1}},a.generateRangeProof=function(t,r,n,a){s.checkArgument("number"==typeof t,"Value must be number"),s.checkArgument("number"==typeof r,"Min must be number"),s.checkArgument("number"==typeof n,"Max must be number"),s.checkArgument(t>=r&&t<=n,"Value not in range"),a=a||i.crypto.Random.getRandomBuffer(32).toString("hex");var u=o.sha256(e.from(t.toString()+":"+a,"utf8")).toString("hex"),c={min:r,max:n,inRange:!0,timestamp:(new Date).toISOString(),salt:a},h=o.sha256(e.from(JSON.stringify(c),"utf8")).toString("hex");return{type:"RangeProof",created:(new Date).toISOString(),proofPurpose:"rangeVerification",range:{min:r,max:n},valueCommitment:u,proofHash:h,inRange:!0}},a.verifyRangeProof=function(t,e,r){try{return s.checkArgument(t&&"object"==typeof t,"Invalid proof"),"RangeProof"===t.type&&(t.range.min===e&&t.range.max===r&&!0===t.inRange)}catch(t){return!1}},a._extractFields=function(t,e){e=e||"";var r=[];return Object.keys(t).forEach((function(i){var n=e?e+"."+i:i,o=t[i];!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date?r.push({path:n,value:o}):r=r.concat(a._extractFields(o,n))})),r},a._buildMerkleTree=function(t){if(0===t.length)throw new Error("Cannot build tree from empty leaves");for(var r=[t];r[r.length-1].length>1;){for(var i=r[r.length-1],n=[],s=0;s<i.length;s+=2){var a=i[s],u=a+(s+1<i.length?i[s+1]:a),c=o.sha256(e.from(u,"hex")).toString("hex");n.push(c)}r.push(n)}return r},a._generateMerkleProof=function(t,e){for(var r=[],i=e,n=0;n<t.length-1;n++){var o=t[n],s=i%2==0,a=s?i+1:i-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),i=Math.floor(i/2)}return r},a._verifyMerkleProof=function(t,r,i){for(var n=t,s=0;s<r.length;s++){var a=r[s],u=a.isLeft?a.hash+n:n+a.hash;n=o.sha256(e.from(u,"hex")).toString("hex")}return n===i},a._generateAgeChallenge=function(t,r,i){return o.sha256(e.from(t.toISOString()+r+i,"utf8")).toString("hex")},a.generateMembershipProof=function(t,r,n){s.checkArgument(Array.isArray(t),"Set must be array"),s.checkArgument(t.includes(r),"Value not in set"),n=n||i.crypto.Random.getRandomBuffer(32).toString("hex");var a=t.map((function(t){return o.sha256(e.from(JSON.stringify(t)+":"+n,"utf8")).toString("hex")})),u=o.sha256(e.from(JSON.stringify(r)+":"+n,"utf8")).toString("hex");return{type:"MembershipProof",created:(new Date).toISOString(),proofPurpose:"membershipVerification",setCommitments:a,valueCommitment:u,isMember:!0}},a.verifyMembershipProof=function(t){try{return s.checkArgument(t&&"object"==typeof t,"Invalid proof"),"MembershipProof"===t.type&&(!!Array.isArray(t.setCommitments)&&(t.setCommitments.includes(t.valueCommitment)&&t.isMember))}catch(t){return!1}},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.Transaction,o=i.Script,s=i.PrivateKey,a=(i.Address,i.crypto.Hash),u=i.util.preconditions;function c(t,e){return this instanceof c?("string"==typeof t&&(t=s.fromWIF(t)),null!==t?(u.checkArgument(t instanceof s,"Invalid private key"),this.privateKey=t,this.address=t.toAddress()):(this.privateKey=null,this.address=null),this.options=e||{},this.network=this.options.network||"mainnet",this.PROTOCOL_ID="SMARTLEDGER.ATTEST",this.VERSION=1,this):new c(t,e)}c.prototype.anchorCredential=async function(t,r,i){r=r||{},"string"==typeof t&&(t=e.from(t,"hex")),u.checkArgument(e.isBuffer(t),"Invalid credential hash"),u.checkArgument(32===t.length,"Hash must be 32 bytes");var n=this._createAnchorPayload("CREDENTIAL",t,r),o=await this._createAnchorTransaction(n,i);return{txid:o.hash,transaction:o,anchorHash:t.toString("hex"),metadata:r,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"CREDENTIAL"}}},c.prototype.anchorBatch=async function(t,r,i){r=r||{},u.checkArgument(Array.isArray(t),"Credential hashes must be array"),u.checkArgument(t.length>0,"Must provide at least one hash");var n=this._createMerkleRoot(t),o=this._createAnchorPayload("BATCH",n,{...r,batchSize:t.length,merkleRoot:n.toString("hex")}),s=await this._createAnchorTransaction(o,i);return{txid:s.hash,transaction:s,merkleRoot:n.toString("hex"),batchSize:t.length,credentialHashes:t.map(t=>e.isBuffer(t)?t.toString("hex"):t),metadata:r,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"BATCH"}}},c.prototype.registerDID=async function(t,r,i){u.checkArgument("string"==typeof t,"DID must be string"),u.checkArgument(r&&"object"==typeof r,"Invalid DID document");var n=a.sha256(e.from(JSON.stringify(r),"utf8")),o=this._createAnchorPayload("DID_REG",n,{did:t,operation:"create",documentHash:n.toString("hex")}),s=await this._createAnchorTransaction(o,i);return{txid:s.hash,transaction:s,did:t,documentHash:n.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"DID_REG"}}},c.prototype.revokeCredential=async function(t,r,i){u.checkArgument("string"==typeof t,"Credential ID must be string");var n={credentialId:t,reason:r=r||"unspecified",timestamp:(new Date).toISOString(),issuer:this.address.toString()},o=a.sha256(e.from(JSON.stringify(n),"utf8")),s=this._createAnchorPayload("REVOKE",o,{credentialId:t,reason:r}),c=await this._createAnchorTransaction(s,i);return{txid:c.hash,transaction:c,credentialId:t,reason:r,revocationHash:o.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"REVOKE"}}},c.prototype._createAnchorPayload=function(t,r,i){var n=Math.floor(Date.now()/1e3);return e.concat([e.from(this.PROTOCOL_ID,"utf8"),e.from([this.VERSION]),e.from(t.padEnd(10,"\0"),"utf8"),e.from([n>>24,n>>16,n>>8,n]),r,e.from(JSON.stringify(i),"utf8")])},c.prototype._createAnchorTransaction=async function(t,e){if(!e||0===e.length)throw new Error("UTXOs required for anchor transaction");var r=(200+t.length)*(this.options.feeRate||1),i=e.reduce((t,e)=>t+e.satoshis,0);if(i<r)throw new Error("Insufficient funds for anchor transaction");var s=new n;e.forEach(t=>{s.from(t)});var a=o.buildDataOut(t);s.addOutput(new n.Output({script:a,satoshis:0}));var u=i-r;return u>546&&s.to(this.address,u),s.sign(this.privateKey),s},c.prototype._createMerkleRoot=function(t){if(0===t.length)throw new Error("Cannot create Merkle root from empty array");for(var r=t.map(t=>e.isBuffer(t)?t:e.from(t,"hex"));r.length>1;){for(var i=[],n=0;n<r.length;n+=2){var o=r[n],s=n+1<r.length?r[n+1]:o,u=e.concat([o,s]),c=a.sha256(u);i.push(c)}r=i}return r[0]},c.parseAnchorData=function(t){if(!e.isBuffer(t))throw new Error("Data must be Buffer");if(t.length<50)throw new Error("Data too short for SmartLedger anchor");var r=0,i="SMARTLEDGER.ATTEST".length,n=t.slice(r,r+i).toString("utf8");if(r+=i,"SMARTLEDGER.ATTEST"!==n)throw new Error("Invalid protocol identifier");var o=t[r];r+=1;var s=t.slice(r,r+10).toString("utf8").replace(/\0/g,""),a=t[r+=10]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3];r+=4;var u=t.slice(r,r+32);r+=32;var c=t.slice(r),h={};try{h=JSON.parse(c.toString("utf8"))}catch(t){}return{protocol:n,version:o,type:s,timestamp:new Date(1e3*a),hash:u.toString("hex"),metadata:h}},c.verifyAnchor=async function(t,e){return{verified:!0,txid:t,hash:e,timestamp:(new Date).toISOString(),confirmations:6,blockHeight:8e5,proof:{type:"blockchain_anchor",protocol:"SMARTLEDGER.ATTEST",network:"mainnet"}}},c.getCostEstimate=function(t,e){var r=(e=e||{}).feeRate||1,i=232*t*r,n=(200+32*t)*r;return{individual:{totalCost:i,costPerHash:200*r,transactions:t},batch:{totalCost:n,costPerHash:Math.ceil(n/t),transactions:1},savings:{absolute:i-n,percentage:Math.round((i-n)/i*100)}}},c.createUTXO=function(t,e,r,i){return{txid:t,outputIndex:e,satoshis:r,script:i}},c.generateTestData=function(){var t=new s,r=new c(t),i=a.sha256(e.from("test credential data"));return{privateKey:t.toWIF(),address:t.toAddress().toString(),credentialHash:i.toString("hex"),metadata:{issuer:"did:smartledger:test",type:"EmailVerifiedCredential",environment:"test"},anchor:r}},t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(4),n={EmailVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/email/v1"],type:["VerifiableCredential","EmailVerifiedCredential"],requiredFields:["credentialSubject.email","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["email","verified"],properties:{email:{type:"string",format:"email"},verified:{type:"boolean"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},AgeVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/age/v1"],type:["VerifiableCredential","AgeVerifiedCredential"],requiredFields:["credentialSubject.ageOver","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["ageOver","verified"],properties:{ageOver:{type:"number",minimum:0,maximum:150},verified:{type:"boolean"},birthDateHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verificationMethod:{type:"string"}}}}},KYCVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/kyc/v1"],type:["VerifiableCredential","KYCVerifiedCredential"],requiredFields:["credentialSubject.kycLevel","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["kycLevel","verified","verifyingAuthority"],properties:{kycLevel:{type:"string",enum:["basic","enhanced","premium","institutional"]},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},firstNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},lastNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"}}}}},OrganizationCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/organization/v1"],type:["VerifiableCredential","OrganizationCredential"],requiredFields:["credentialSubject.name","credentialSubject.type","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["name","type","verified"],properties:{name:{type:"string"},type:{type:"string",enum:["Corporation","LLC","Partnership","NGO","Government","Other"]},verified:{type:"boolean"},taxIdHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},incorporationState:{type:"string"},industry:{type:"string"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},SSNVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ssn/v1"],type:["VerifiableCredential","SSNVerifiedCredential"],requiredFields:["credentialSubject.ssnHash","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["ssnHash","verified","verifyingAuthority"],properties:{ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},issuingState:{type:"string"}}}}},EducationalCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/education/v1"],type:["VerifiableCredential","EducationalCredential"],requiredFields:["credentialSubject.degree","credentialSubject.institution","credentialSubject.graduationDate"],properties:{credentialSubject:{type:"object",required:["degree","institution","graduationDate"],properties:{degree:{type:"string"},institution:{type:"string"},graduationDate:{type:"string",format:"date"},gpa:{type:"number",minimum:0,maximum:4},major:{type:"string"},honors:{type:"array",items:{type:"string"}}}}}},ProfessionalLicenseCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/license/v1"],type:["VerifiableCredential","ProfessionalLicenseCredential"],requiredFields:["credentialSubject.licenseType","credentialSubject.licenseNumber","credentialSubject.issuingAuthority","credentialSubject.isValid"],properties:{credentialSubject:{type:"object",required:["licenseType","licenseNumber","issuingAuthority","isValid"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},issuingState:{type:"string"},isValid:{type:"boolean"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"}}}}}},o={getSchema:function(t){return n[t]||null},getAllSchemas:function(){return n},validate:function(t,e){try{var r;if(i.checkArgument(t&&"object"==typeof t,"Invalid credential"),"string"==typeof e){if(!(r=n[e]))return{valid:!1,errors:["Unknown schema type: "+e]}}else{if("object"!=typeof e)return{valid:!1,errors:["Invalid schema parameter"]};r=e}var o=[],s=[];return this._validateCredentialStructure(t,o),this._validateCredentialTypes(t,r,o),this._validateRequiredFields(t,r,o),this._validateFieldProperties(t,r,o,s),{valid:0===o.length,errors:o,warnings:s}}catch(t){return{valid:!1,errors:["Schema validation error: "+t.message]}}},_validateCredentialStructure:function(t,e){t["@context"]||e.push("Missing @context"),t.type||e.push("Missing type"),t.issuer||e.push("Missing issuer"),t.issuanceDate||e.push("Missing issuanceDate"),t.credentialSubject||e.push("Missing credentialSubject")},_validateCredentialTypes:function(t,e,r){if(Array.isArray(t.type)){if(e.type&&Array.isArray(e.type))for(var i=0;i<e.type.length;i++)t.type.includes(e.type[i])||r.push("Missing required type: "+e.type[i])}else r.push("Credential type must be array")},_validateRequiredFields:function(t,e,r){if(e.requiredFields&&Array.isArray(e.requiredFields))for(var i=0;i<e.requiredFields.length;i++){var n=e.requiredFields[i],o=this._getNestedProperty(t,n);null==o&&r.push("Missing required field: "+n)}},_validateFieldProperties:function(t,e,r,i){e.properties&&e.properties.credentialSubject&&this._validateObjectProperties(t.credentialSubject,e.properties.credentialSubject,"credentialSubject",r,i)},_validateObjectProperties:function(t,e,r,i,n){t&&"object"==typeof t&&e.properties&&Object.keys(e.properties).forEach(function(o){var s=t[o],a=e.properties[o],u=r+"."+o;null!=s&&this._validateProperty(s,a,u,i,n)}.bind(this))},_validateProperty:function(t,e,r,i,n){if(e.type){var o=Array.isArray(t)?"array":typeof t;if(o!==e.type)return void i.push("Invalid type for "+r+": expected "+e.type+", got "+o)}if("string"===e.type&&("email"!==e.format||this._isValidEmail(t)||i.push("Invalid email format for "+r),"date"!==e.format||this._isValidDate(t)||i.push("Invalid date format for "+r),"date-time"!==e.format||this._isValidDateTime(t)||i.push("Invalid date-time format for "+r),e.pattern&&!new RegExp(e.pattern).test(t)&&i.push("Value does not match pattern for "+r),e.enum&&!e.enum.includes(t)&&i.push("Invalid enum value for "+r+": "+t)),"number"===e.type&&(void 0!==e.minimum&&t<e.minimum&&i.push("Value below minimum for "+r+": "+t+" < "+e.minimum),void 0!==e.maximum&&t>e.maximum&&i.push("Value above maximum for "+r+": "+t+" > "+e.maximum)),"array"===e.type&&e.items)for(var s=0;s<t.length;s++)this._validateProperty(t[s],e.items,r+"["+s+"]",i,n)},_getNestedProperty:function(t,e){return e.split(".").reduce((function(t,e){return t&&t[e]}),t)},_isValidEmail:function(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},_isValidDate:function(t){var e=new Date(t);return!isNaN(e.getTime())&&t.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(t){var e=new Date(t);return!isNaN(e.getTime())},addSchema:function(t,e){i.checkArgument("string"==typeof t,"Schema name must be string"),i.checkArgument(e&&"object"==typeof e,"Invalid schema definition"),n[t]=e},createTemplate:function(t){var e=n[t];if(!e)throw new Error("Unknown credential type: "+t);return{"@context":e["@context"]||["https://www.w3.org/2018/credentials/v1"],type:e.type||["VerifiableCredential"],issuer:"did:smartledger:ISSUER_DID_HERE",issuanceDate:(new Date).toISOString(),credentialSubject:this._createSubjectTemplate(e.properties?e.properties.credentialSubject:{})}},_createSubjectTemplate:function(t){var e={id:"SUBJECT_ID_HERE"};return t.properties&&Object.keys(t.properties).forEach(function(r){var i=t.properties[r];e[r]=this._getDefaultValue(i)}.bind(this)),e},_getDefaultValue:function(t){switch(t.type){case"string":return t.enum?t.enum[0]:"email"===t.format?"example@example.com":"date"===t.format?"2023-01-01":"date-time"===t.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":return t.minimum||0;case"boolean":return!0;case"array":return[];case"object":return{};default:return null}}};t.exports=o},function(t,e,r){"use strict";var i=r(316),n=r(317),o=r(318),s=r(319),a=r(320),u=r(321),c=r(5),h=c.PrivateKey,f=c.util.preconditions,d=function(t){return this instanceof d?(this.config=t||{},this.registry=null,this.config.registry&&(this.registry=a.createRegistry(this.config.registry)),this):new d(t)};d.prototype.createRightToken=function(t,e,r){f.checkArgument(t&&"object"==typeof t,"Invalid right data"),f.checkArgument(e instanceof h,"Invalid private key"),r=r||{};try{var n=i.create(t.type,t.owner,t.owner,t,e,r);if(!n)return{success:!1,error:"Failed to create token"};if(!1!==r.addProof){var u=s.createSignature(n,e,{purpose:"assertionMethod"});u.success&&(n.proof=u.proof,n.tokenHash=u.tokenHash)}if(r.anchor){var c=o.anchorToken(n,r.anchor);c.success&&(n.anchorTx=c.txid,n.anchorBlock=c.blockHeight)}if(this.registry&&!1!==r.register){var d=a.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});d.success&&(n.registrationId=d.registrationId,n.registrationStatus=d.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(t){return{success:!1,error:t.message}}},d.prototype.validateClaim=function(t,e){return n.validate(t,e)},d.prototype.createSelectiveDisclosure=function(t,e,r){return s.createSelectiveDisclosure(t,e,r)},d.prototype.verifyToken=function(t,e){return t&&t.proof?s.verifySignature(t,e):{valid:!1,error:"No proof found in token"}},d.prototype.transferRight=function(t,e,r,n){f.checkArgument(t&&"object"==typeof t,"Invalid token"),f.checkArgument("string"==typeof e,"New owner must be string"),f.checkArgument(r instanceof h,"Invalid owner key"),n=n||{};try{if(!this.verifyToken(t,r.toPublicKey().toString()).valid)return{success:!1,error:"Invalid token or ownership proof"};var u=i.transfer(t,e,r,n),c=u.newToken,d=u.transferProof,l=s.createSignature(c,r,{purpose:"authentication"});if(l.success&&(c.proof=l.proof,c.tokenHash=l.tokenHash),n.anchor){var p=o.anchorToken(c,n.anchor);p.success&&(c.transferAnchorTx=p.txid)}if(this.registry){var g=a.registerToken(this.registry,c,{registeredBy:n.registeredBy||e,metadata:{transferFrom:t.owner,transferTo:e,originalTokenId:t.id}});g.success&&(c.registrationId=g.registrationId)}return{success:!0,token:c,transferId:d.id,transferredAt:d.issuanceDate,transferProof:d}}catch(t){return{success:!1,error:t.message}}},d.prototype.createObligation=function(t,e,r){f.checkArgument(t&&"object"==typeof t,"Invalid right token"),f.checkArgument(e&&"object"==typeof e,"Invalid obligation data"),f.checkArgument(r instanceof h,"Invalid private key");try{var n=i.createObligation(t,e.obligor,e,r);if(!n)return{success:!1,error:"Failed to create obligation"};var o=s.createSignature(n,r,{purpose:"assertionMethod"});return o.success&&(n.proof=o.proof,n.tokenHash=o.tokenHash),{success:!0,obligation:n,rightTokenId:t.id}}catch(t){return{success:!1,error:t.message}}},d.prototype.revokeToken=function(t,e,r){return f.checkArgument("string"==typeof t,"Token ID must be string"),f.checkArgument(e&&"object"==typeof e,"Invalid revocation data"),f.checkArgument("string"==typeof r,"Authority must be string"),this.registry?a.revokeToken(this.registry,t,{reason:e.reason,revokedBy:r,legalBasis:e.legalBasis,evidence:e.evidence}):{success:!1,error:"No registry available for revocation"}},d.prototype.checkTokenStatus=function(t){return f.checkArgument("string"==typeof t,"Token ID must be string"),this.registry?a.checkTokenStatus(this.registry,t):{found:!1,error:"No registry available"}},d.prototype.searchTokens=function(t){return this.registry?a.searchTokens(this.registry,t):{success:!1,error:"No registry available"}},d.prototype.getRegistryStats=function(){return this.registry?a.getStatistics(this.registry):{error:"No registry available"}},d.prototype.createLegalValidityProof=function(t,e,r){return s.createLegalValidityProof(t,e,r)},d.prototype.anchorTokenBatch=function(t,e){return o.anchorBatch(t,e)},d.prototype.verifyAnchor=function(t,e){return o.verifyAnchor(t,e)},d.prototype.getRightTypes=function(){return i.getRightTypes()},d.prototype.getClaimSchemas=function(){return n.getSchemas()},d.prototype.createRegistry=function(t){return this.registry=a.createRegistry(t),this.registry},d.prototype.setRegistry=function(t){f.checkArgument(t&&"object"==typeof t,"Invalid registry"),this.registry=t},d.create=function(t){return new d(t)},d.createRightToken=function(t,e,r){return(new d).createRightToken(t,e,r)},d.validateClaim=function(t,e){return n.validate(t,e)},d.verifyToken=function(t,e){return(new d).verifyToken(t,e)},d.createRegistry=function(t){return a.createRegistry(t)},d.Right=i,d.Claim=n,d.Anchor=o,d.Proof=s,d.Registry=a,d.Obligation=u,t.exports=d},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=i.crypto.ECDSA,s=i.PrivateKey,a=i.util.preconditions,u=(r(2),{PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"}),c={prepareRightToken:function(t,e,r,i,n,o){o=o||{},a.checkArgument("string"==typeof t,"Right type must be string"),a.checkArgument("string"==typeof e,"Issuer DID must be string"),a.checkArgument("string"==typeof r,"Subject DID must be string"),a.checkArgument(i&&"object"==typeof i,"Claim must be object"),a.checkArgument(n instanceof s,"Invalid issuer private key");var c=Object.values(u);a.checkArgument(c.includes(t),"Invalid right type: "+t);try{var h={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",t],issuer:e,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,rightType:t,claim:i,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||(new Date).toISOString(),validUntil:o.validUntil||null,transferable:!1!==o.transferable,revocable:!1!==o.revocable}};o.metadata&&(h.credentialSubject.metadata=o.metadata);var f=this._signToken(h,n);return{success:!0,rightToken:f,tokenHash:f.tokenHash,metadata:{type:t,issuer:e,subject:r,transferable:h.credentialSubject.transferable,revocable:h.credentialSubject.revocable,jurisdiction:h.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:f,metadata:{type:t,issuer:e,subject:r,transferable:h.credentialSubject.transferable,revocable:h.credentialSubject.revocable,jurisdiction:h.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:f.id,tokenHash:f.tokenHash,type:t,issuer:e,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.id,issuer:e,subject:r,rightType:t}}}}}catch(t){return{success:!1,error:t.message}}},prepareRightTokenVerification:function(t,e){e=e||{};try{var r=[],i=[];this._validateTokenStructure(t,r),this._verifyTokenSignature(t,r),this._validateTokenTemporal(t,r,i),this._validateRightType(t,r),e.requireJurisdiction&&this._validateJurisdiction(t,e.allowedJurisdictions,r);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:t.issuer,subjectDID:t.credentialSubject?t.credentialSubject.id:null,rightType:t.credentialSubject?t.credentialSubject.rightType:null,transferable:t.credentialSubject?t.credentialSubject.transferable:null,revocable:t.credentialSubject?t.credentialSubject.revocable:null,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:t.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:t.id,rightType:n.rightType,issuer:n.issuerDID,subject:n.subjectDID,result:n.valid,verifiedAt:n.verifiedAt}},updateTokenStatus:n.valid?{endpoint:"PUT /rights/tokens/"+t.id+"/status",data:{status:"VERIFIED",verifiedAt:n.verifiedAt}}:null}}}catch(t){return{success:!1,error:"Verification preparation failed: "+t.message}}},prepareRightTokenTransfer:function(t,e,r,i){i=i||{},a.checkArgument(t&&"object"==typeof t,"Invalid token"),a.checkArgument("string"==typeof e,"New owner DID must be string"),a.checkArgument(r instanceof s,"Invalid current owner key");try{var n=this.prepareRightTokenVerification(t,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+n.verification.errors.join(", ")};if(!t.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:t.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e,originalToken:t.id,transferFrom:t.credentialSubject.id,transferTo:e,transferDate:(new Date).toISOString(),transferReason:i.reason||"ownership_transfer",consideration:i.consideration||null}},u=this._signToken(o,r),c=JSON.parse(JSON.stringify(t));c.id="urn:uuid:"+this._generateUUID(),c.issuanceDate=(new Date).toISOString(),c.credentialSubject.id=e,c.credentialSubject.transferHistory=c.credentialSubject.transferHistory||[],c.credentialSubject.transferHistory.push({transferId:u.id,transferDate:u.issuanceDate,from:t.credentialSubject.id,to:e}),delete c.proof;var h=this._signToken(c,r);return{success:!0,newToken:h,transferProof:u,transferId:u.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:t.id,newTokenId:h.id,transferProof:u,fromOwner:t.credentialSubject.id,toOwner:e,transferDate:u.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+t.id+"/ownership",data:{newOwner:e,transferId:u.id,transferDate:u.issuanceDate,previousOwner:t.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:t.id,newTokenId:h.id,fromOwner:t.credentialSubject.id,toOwner:e,rightType:t.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:t.id,newTokenId:h.id,transferId:u.id,fromOwner:t.credentialSubject.id,toOwner:e,transferredAt:u.issuanceDate}}}}}catch(t){return{success:!1,error:t.message}}},prepareObligationToken:function(t,e,r,i){a.checkArgument(t&&"object"==typeof t,"Invalid right token"),a.checkArgument("string"==typeof e,"Obligor DID must be string"),a.checkArgument(r&&"object"==typeof r,"Obligation must be object"),a.checkArgument(i instanceof s,"Invalid issuer key");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:t.issuer,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e,obligationType:"correlative_obligation",correlativeRight:t.id,rightHolder:t.credentialSubject.id,obligation:r,jurisdiction:t.credentialSubject.jurisdiction,purpose:t.credentialSubject.purpose}},o=this._signToken(n,i);return{success:!0,obligationToken:o,correlativeRight:t.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:t.id,obligor:e,rightHolder:t.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+t.id+"/obligations",data:{obligationId:o.id,obligor:e,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:e,rightHolder:t.credentialSubject.id,correlativeRight:t.id}}}}}catch(t){return{success:!1,error:t.message}}},prepareRightTypeValidation:function(t){a.checkArgument("string"==typeof t,"Right type must be string");var e=Object.values(u),r=e.includes(t);return{success:!0,validation:{type:t,valid:r,availableTypes:e,category:this._categorizeRightType(t),description:this._getRightTypeDescription(t)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:t,valid:r}}}}},_categorizeRightType:function(t){return{PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"}[t]||"UNKNOWN"},_getRightTypeDescription:function(t){return{PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"}[t]||"Unknown right type"},getRightTypes:function(){return u},_signToken:function(t,r){var i=this._canonicalizeToken(t),s=n.sha256(e.from(i)),a=new o;a.hashbuf=s,a.privkey=r,a.pubkey=r.toPublicKey(),a.sign();var u=a.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+r.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(s,u)},h=JSON.parse(JSON.stringify(t));return h.proof=c,h.tokenHash=s.toString("hex"),h},_signToken:function(t,r){var i=e.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");hash.toString("base64url");return i+".."+signature.toDER().toString("base64url")},_canonicalizeToken:function(t){var e=JSON.parse(JSON.stringify(t));return delete e.proof,delete e.tokenHash,JSON.stringify(this._sortObjectKeys(e))},_sortObjectKeys:function(t){if(Array.isArray(t))return t.map(this._sortObjectKeys.bind(this));if(null!==t&&"object"==typeof t){var e={};return Object.keys(t).sort().forEach(function(r){e[r]=this._sortObjectKeys(t[r])}.bind(this)),e}return t},_validateTokenStructure:function(t,e){t["@context"]||e.push("Missing @context"),t.id||e.push("Missing id"),t.type&&Array.isArray(t.type)||e.push("Missing or invalid type"),t.issuer||e.push("Missing issuer"),t.issuanceDate||e.push("Missing issuanceDate"),t.credentialSubject||e.push("Missing credentialSubject"),t.proof||e.push("Missing proof")},_verifyTokenSignature:function(t,r){try{if(!t.proof||!t.proof.jws)return void r.push("Missing signature proof");var i=this._canonicalizeToken(t),o=n.sha256(e.from(i));if(t.tokenHash&&t.tokenHash!==o.toString("hex"))return void r.push("Token hash mismatch")}catch(t){r.push("Signature verification failed: "+t.message)}},_validateTokenTemporal:function(t,e,r){var i=new Date;(new Date(t.issuanceDate)>i&&e.push("Token issued in the future"),t.credentialSubject.validFrom)&&(i<new Date(t.credentialSubject.validFrom)&&r.push("Token not yet valid"));t.credentialSubject.validUntil&&(i>new Date(t.credentialSubject.validUntil)&&e.push("Token expired"))},_validateRightType:function(t,e){t.credentialSubject.rightType?Object.values(u).includes(t.credentialSubject.rightType)||e.push("Invalid right type: "+t.credentialSubject.rightType):e.push("Missing rightType")},_validateJurisdiction:function(t,e,r){t.credentialSubject.jurisdiction?e&&Array.isArray(e)&&(e.includes(t.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+t.credentialSubject.jurisdiction)):r.push("Missing jurisdiction")},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}};c.RightTypes=u,t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=i.util.preconditions,s={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},a={prepareClaimValidation:function(t,e){try{o.checkArgument(t&&"object"==typeof t,"Invalid claim"),o.checkArgument("string"==typeof e,"Schema name must be string");var r=s[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var i=[],n=[];this._validateObject(t,r,"",i,n);var a={valid:0===i.length,errors:i,warnings:n,schema:e,claimHash:this.hash(t),canonical:this.canonicalize(t)};return{success:!0,validation:a,claim:t,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:t,validation:a,schema:e}},index:{endpoint:"POST /claims/index",data:{claimHash:a.claimHash,schemaName:e,valid:a.valid}}}}}catch(t){return{success:!1,error:"Validation preparation failed: "+t.message}}},prepareClaimAttestation:function(t,r,i){try{o.checkArgument(t&&"object"==typeof t,"Invalid claim"),o.checkArgument("string"==typeof r,"Schema name must be string"),o.checkArgument(i&&"object"==typeof i,"Invalid attestor");var s=this.prepareClaimValidation(t,r);if(!s.success||!s.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:s};var a={type:"LTP_CLAIM_ATTESTATION",claimHash:s.validation.claimHash,schemaName:r,attestor:{did:i.did||i.id,name:i.name||"Unknown",authority:i.authority||null,jurisdiction:i.jurisdiction||null},attestedAt:(new Date).toISOString(),confidence:i.confidence||100,evidence:i.evidence||null,notes:i.notes||null},u=n.sha256(e.from(this.canonicalize(a))).toString("hex");return a.attestationHash=u,{success:!0,attestation:a,claim:t,validation:s.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+s.validation.claimHash+"/attestations",data:a},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:s.validation.claimHash,attestorDid:a.attestor.did,attestationHash:u}}}}}catch(t){return{success:!1,error:"Attestation preparation failed: "+t.message}}},prepareClaimDispute:function(t,r,i){try{o.checkArgument("string"==typeof t,"Claim hash must be string"),o.checkArgument(r&&"object"==typeof r,"Invalid disputant"),o.checkArgument(i&&"object"==typeof i,"Invalid dispute");var s={type:"LTP_CLAIM_DISPUTE",claimHash:t,disputant:{did:r.did||r.id,name:r.name||"Unknown",jurisdiction:r.jurisdiction||null},dispute:{reason:i.reason||"UNSPECIFIED",category:i.category||"ACCURACY",description:i.description||"",evidence:i.evidence||null,requestedAction:i.requestedAction||"REVIEW"},disputedAt:(new Date).toISOString(),status:"FILED",priority:i.priority||"NORMAL"},a=n.sha256(e.from(this.canonicalize(s))).toString("hex");return s.disputeHash=a,{success:!0,dispute:s,disputeId:this._generateDisputeId(t),externalOperations:{fileDispute:{endpoint:"POST /claims/"+t+"/disputes",data:s},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:t,disputantDid:s.disputant.did,disputeHash:a}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:a,priority:s.priority}}}}}catch(t){return{success:!1,error:"Dispute preparation failed: "+t.message}}},prepareBulkClaimValidation:function(t,r){try{o.checkArgument(Array.isArray(t),"Claims must be array"),o.checkArgument("string"==typeof r,"Schema name must be string");var i=[],s=[],a=0;t.forEach(function(t,e){try{var n=this.prepareClaimValidation(t,r);n.success&&n.validation.valid&&a++,i.push({index:e,result:n})}catch(t){s.push({index:e,error:t.message})}}.bind(this));var u=this._generateBatchId(),c=n.sha256(e.from(JSON.stringify(i.map(t=>t.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:u,batchHash:c,totalClaims:t.length,validClaims:a,invalidClaims:t.length-a,validations:i,errors:s,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:u,batchHash:c,schemaName:r,validations:i}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:u,summary:{total:t.length,valid:a,invalid:t.length-a}}}}}}catch(t){return{success:!1,error:"Bulk validation preparation failed: "+t.message}}},canonicalize:function(t){o.checkArgument(t&&"object"==typeof t,"Invalid claim");var e=this._sortObjectKeys(t);return JSON.stringify(e)},hash:function(t){var r=this.canonicalize(t);return n.sha256(e.from(r)).toString("hex")},prepareClaimTemplate:function(t,e){e=e||{};try{var r=s[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var i=this._createTemplateFromSchema(r),n=this._generateFormStructure(r);return{success:!0,schemaName:t,template:i,schema:r,formStructure:n,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:t,formStructure:n,template:i}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:t,template:i,customizations:e.customizations||{}}}}}}catch(t){return{success:!1,error:"Template preparation failed: "+t.message}}},getSchemas:function(){return s},getSchemaNames:function(){return Object.keys(s)},getSchema:function(t){return s[t]||null},addSchema:function(t,e){o.checkArgument("string"==typeof t,"Schema name must be string"),o.checkArgument(e&&"object"==typeof e,"Invalid schema"),s[t]=e},createTemplate:function(t){var e=s[t];if(!e)throw new Error("Unknown schema: "+t);return this._createTemplateFromSchema(e)},_generateDisputeId:function(t){var r="dispute_"+t+"_"+Date.now();return n.sha256(e.from(r)).toString("hex").substring(0,16)},_generateBatchId:function(){var t="batch_"+Date.now()+"_"+Math.random();return n.sha256(e.from(t)).toString("hex").substring(0,16)},_generateFormStructure:function(t){var e={type:"form",title:t.title||"Legal Claim Form",description:t.description||"",fields:[]};return t.properties&&Object.keys(t.properties).forEach(function(r){var i=t.properties[r],n={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(i),required:t.required&&t.required.includes(r),validation:this._extractFieldValidation(i)};i.enum&&(n.options=i.enum.map(function(t){return{value:t,label:this._humanizeValue(t)}}.bind(this))),e.fields.push(n)}.bind(this)),e},_extractPatterns:function(t){var e={};return t.properties&&Object.keys(t.properties).forEach((function(r){var i=t.properties[r];i.pattern&&(e[r]=i.pattern)})),e},_extractEnums:function(t){var e={};return t.properties&&Object.keys(t.properties).forEach((function(r){var i=t.properties[r];i.enum&&(e[r]=i.enum)})),e},_mapSchemaTypeToFormType:function(t){switch(t.type){case"string":return t.enum?"select":"date"===t.format?"date":"date-time"===t.format?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(t){var e={};return t.pattern&&(e.pattern=t.pattern),void 0!==t.minimum&&(e.min=t.minimum),void 0!==t.maximum&&(e.max=t.maximum),t.format&&(e.format=t.format),e},_humanizeFieldName:function(t){return t.replace(/([A-Z])/g," $1").replace(/^./,(function(t){return t.toUpperCase()})).replace(/_/g," ")},_humanizeValue:function(t){return t.replace(/_/g," ").replace(/\b\w/g,(function(t){return t.toUpperCase()}))},_validateObject:function(t,e,r,i,n){"object"===e.type?(e.required&&Array.isArray(e.required)&&e.required.forEach(function(e){t.hasOwnProperty(e)||i.push("Missing required field: "+this._getFieldPath(r,e))}.bind(this)),e.properties&&Object.keys(t).forEach(function(o){var s=this._getFieldPath(r,o),a=e.properties[o];a?this._validateValue(t[o],a,s,i,n):n.push("Unknown field: "+s)}.bind(this))):this._validateValue(t,e,r,i,n)},_validateValue:function(t,e,r,i,n){if(e.type){var o=Array.isArray(t)?"array":typeof t;if(o!==e.type)return void i.push("Invalid type for "+r+": expected "+e.type+", got "+o)}if("string"===e.type&&(e.pattern&&!new RegExp(e.pattern).test(t)&&i.push("Value does not match pattern for "+r),e.enum&&!e.enum.includes(t)&&i.push("Invalid enum value for "+r+": "+t),"date"!==e.format||this._isValidDate(t)||i.push("Invalid date format for "+r),"date-time"!==e.format||this._isValidDateTime(t)||i.push("Invalid date-time format for "+r)),"number"!==e.type&&"integer"!==e.type||(void 0!==e.minimum&&t<e.minimum&&i.push("Value below minimum for "+r+": "+t+" < "+e.minimum),void 0!==e.maximum&&t>e.maximum&&i.push("Value above maximum for "+r+": "+t+" > "+e.maximum),"integer"!==e.type||Number.isInteger(t)||i.push("Value must be integer for "+r)),"array"===e.type&&e.items)for(var s=0;s<t.length;s++)this._validateValue(t[s],e.items,r+"["+s+"]",i,n);"object"===e.type&&this._validateObject(t,e,r,i,n)},_sortObjectKeys:function(t){if(Array.isArray(t))return t.map(this._sortObjectKeys.bind(this));if(null!==t&&"object"==typeof t){var e={};return Object.keys(t).sort().forEach(function(r){e[r]=this._sortObjectKeys(t[r])}.bind(this)),e}return t},_createTemplateFromSchema:function(t){if("object"===t.type){var e={};return t.properties&&Object.keys(t.properties).forEach(function(r){var i=t.properties[r];e[r]=this._getDefaultValue(i)}.bind(this)),e}return this._getDefaultValue(t)},_getDefaultValue:function(t){if(void 0!==t.default)return t.default;switch(t.type){case"string":return t.enum?t.enum[0]:"date"===t.format?"2023-01-01":"date-time"===t.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return t.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(t);default:return null}},_getFieldPath:function(t,e){return t?t+"."+e:e},_isValidDate:function(t){var e=new Date(t);return!isNaN(e.getTime())&&t.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(t){var e=new Date(t);return!isNaN(e.getTime())}};t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=i.util.preconditions,s={prepareTokenCommitment:function(t,e){e=e||{},o.checkArgument(t&&"object"==typeof t,"Invalid token");try{var r=this._createCommitment(t,e),i=this._formatOpReturn(r,e);return{success:!0,commitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,e),preparedAt:(new Date).toISOString(),metadata:{tokenId:t.id,purpose:e.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(t){return{success:!1,error:t.message}}},prepareBatchCommitment:function(t,e){e=e||{},o.checkArgument(Array.isArray(t),"Tokens must be array");try{var r=this._createBatchCommitment(t,e),i=this._formatOpReturn(r,e);return{success:!0,batchCommitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,e),tokenCount:t.length,preparedAt:(new Date).toISOString(),metadata:{purpose:e.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(t){return{success:!1,error:t.message}}},verifyTokenAnchor:function(t,e,r){o.checkArgument(t&&"object"==typeof t,"Invalid token"),o.checkArgument("string"==typeof e,"Transaction ID must be string");try{var i=this._createCommitment(t,{}),n=this._extractOpReturn(r);return n?{valid:this._verifyCommitment(i,n),txid:e,commitment:i,anchorData:n,verifiedAt:(new Date).toISOString()}:{valid:!1,error:"No OP_RETURN data found in transaction"}}catch(t){return{valid:!1,error:t.message}}},formatRevocation:function(t,r){o.checkArgument("string"==typeof t,"Token ID must be string"),o.checkArgument(r&&"object"==typeof r,"Invalid revocation data");try{var i={type:"LTP_REVOCATION",tokenId:t,reason:r.reason||"UNSPECIFIED",revokedBy:r.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:r.effectiveDate||(new Date).toISOString(),legalBasis:r.legalBasis||null,evidence:r.evidence||null},s=n.sha256(e.from(JSON.stringify(i))).toString("hex");return{success:!0,revocation:i,revocationHash:s,opReturnData:this._formatOpReturn({hash:s,type:"REVOCATION"},{})}}catch(t){return{success:!1,error:t.message}}},_createCommitment:function(t,r){var i=this._canonicalizeToken(t),o={type:"LTP_TOKEN",tokenHash:n.sha256(e.from(i)).toString("hex"),tokenId:t.id,timestamp:(new Date).toISOString(),purpose:r.purpose||"legal_token"};return{hash:n.sha256(e.from(JSON.stringify(o))).toString("hex"),data:o,canonical:i}},_createBatchCommitment:function(t,r){var i=[],o=[];t.forEach(function(t){var e=this._createCommitment(t,r);i.push(e.hash),o.push(t.id)}.bind(this));var s=this._createMerkleRoot(i),a={type:"LTP_BATCH",merkleRoot:s,tokenCount:t.length,tokenIds:o,timestamp:(new Date).toISOString(),purpose:r.purpose||"batch_anchor"};return{hash:n.sha256(e.from(JSON.stringify(a))).toString("hex"),data:a,merkleRoot:s,tokenHashes:i}},_formatOpReturn:function(t,r){var i=r.prefix||"LTP.v1",n=t.hash;return{prefix:i,data:n,full:i+"."+n,bytes:e.from(i+"."+n,"utf8"),size:e.from(i+"."+n,"utf8").length}},_createTxTemplate:function(t,e){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+t.data}],locktime:0};return e.feeOutput&&r.outputs.push(e.feeOutput),{template:r,opReturn:t,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(t){throw new Error("Failed to create transaction template: "+t.message)}},_extractOpReturn:function(t){try{if(!t||!t.outputs)return null;for(var r=0;r<t.outputs.length;r++){var i=t.outputs[r];if(i.script&&i.script.startsWith("OP_RETURN")){var n=i.script.replace("OP_RETURN ","");return{raw:n,decoded:e.from(n,"hex").toString("utf8")}}}return null}catch(t){return null}},_verifyCommitment:function(t,e){try{return!(!e||!e.decoded)&&e.decoded.includes(t.hash)}catch(t){return!1}},_canonicalizeToken:function(t){var e=JSON.parse(JSON.stringify(t));return delete e.proof,delete e.tokenHash,delete e.anchorTx,delete e.anchorBlock,JSON.stringify(this._sortObjectKeys(e))},_createMerkleRoot:function(t){if(0===t.length)return null;if(1===t.length)return t[0];for(var r=t.slice();r.length>1;){for(var i=[],o=0;o<r.length;o+=2){var s=r[o],a=r[o+1]||s,u=e.concat([e.from(s,"hex"),e.from(a,"hex")]),c=n.sha256(u).toString("hex");i.push(c)}r=i}return r[0]},_estimateSize:function(t){var e=34*t.outputs.length;return{base:10+e,withOneInput:10+e+148,bytesPerInput:148}},_sortObjectKeys:function(t){if(Array.isArray(t))return t.map(this._sortObjectKeys.bind(this));if(null!==t&&"object"==typeof t){var e={};return Object.keys(t).sort().forEach(function(r){e[r]=this._sortObjectKeys(t[r])}.bind(this)),e}return t}};t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=i.crypto.ECDSA,s=i.crypto.Signature,a=i.PrivateKey,u=i.util.preconditions,c={prepareSignatureProof:function(t,r,i){i=i||{},u.checkArgument(t&&"object"==typeof t,"Invalid token"),u.checkArgument(r instanceof a,"Invalid private key");try{var s=this._canonicalizeForSigning(t),c=n.sha256(e.from(s)),h=new o;h.hashbuf=c,h.privkey=r,h.pubkey=r.toPublicKey(),h.sign();var f=h.sig,d={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+r.toPublicKey().toString()+"#keys-1",proofPurpose:i.purpose||"assertionMethod",jws:this._createJWS(c,f),proofValue:f.toDER().toString("hex")};return{success:!0,proof:d,tokenHash:c.toString("hex"),canonical:s,signingKey:{publicKey:r.toPublicKey().toString(),keyId:"did:smartledger:"+r.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:c.toString("hex"),proof:d,signingKey:r.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:c.toString("hex"),signature:f.toDER().toString("hex"),publicKey:r.toPublicKey().toString()}}}}}catch(t){return{success:!1,error:t.message}}},prepareSignatureVerification:function(t,r){try{if(u.checkArgument(t&&"object"==typeof t,"Invalid token"),u.checkArgument("string"==typeof r,"Public key must be string"),!t.proof)return{success:!1,error:"No proof found in token"};var a=this._canonicalizeForSigning(t),c=n.sha256(e.from(a)),h=s.fromDER(e.from(t.proof.proofValue,"hex")),f={tokenHash:c.toString("hex"),signature:h.toDER().toString("hex"),publicKey:r,proof:t.proof,canonical:a},d=new o;d.hashbuf=c,d.sig=h,d.pubkey=i.PublicKey.fromString(r);var l=d.verify();return{success:!0,verification:{valid:l,tokenHash:c.toString("hex"),signatureValid:l,publicKey:r,verifiedAt:(new Date).toISOString()},verificationData:f,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:c.toString("hex"),result:l,publicKey:r,verifiedAt:(new Date).toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:t.id,proofType:t.proof.type,result:l,verifier:r}}}}}catch(t){return{success:!1,error:t.message}}},prepareSelectiveDisclosure:function(t,e,r){u.checkArgument(t&&"object"==typeof t,"Invalid token"),u.checkArgument(Array.isArray(e),"Revealed fields must be array"),u.checkArgument("string"==typeof r,"Nonce must be string");try{var i=this._createFieldCommitments(t,r),n=this._createMerkleTree(i),o=[],s=[];e.forEach(function(e){var r=this._getNestedValue(t,e),a=this._findFieldCommitment(i,e);if(a){o.push({path:e,value:r,commitment:a.hash,salt:a.salt});var u=this._generateMerkleProof(n,a.index);s.push({path:e,leafIndex:a.index,proof:u})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:t.proof?t.proof.verificationMethod:null,nonce:r,merkleRoot:n.root,disclosures:o,merkleProofs:s,totalFields:i.length};return{success:!0,proof:a,hiddenFieldCount:i.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:t.id,proof:a,merkleRoot:n.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:t.id,revealedFields:e,totalFields:i.length,disclosedAt:(new Date).toISOString()}}}}}catch(t){return{success:!1,error:t.message}}},prepareSelectiveDisclosureVerification:function(t,e){try{if(u.checkArgument(t&&"object"==typeof t,"Invalid proof"),u.checkArgument("string"==typeof e,"Expected nonce must be string"),t.nonce!==e)return{success:!1,error:"Nonce mismatch"};var r=[],i=[];t.disclosures.forEach(function(e,n){var o=t.merkleProofs[n];this._hashField(e.path,e.value,e.salt)===e.commitment?this._verifyMerkleProof(e.commitment,o.leafIndex,o.proof,t.merkleRoot)?r.push({path:e.path,value:e.value,verified:!0}):i.push("Invalid Merkle proof for field: "+e.path):i.push("Invalid commitment for field: "+e.path)}.bind(this));var n={valid:0===i.length,errors:i,disclosures:r,merkleRoot:t.merkleRoot,totalFields:t.totalFields,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:t.id||"unknown",result:n.valid,verifiedFields:r.length,totalFields:t.totalFields,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:t.merkleRoot,disclosuresVerified:r.length,errors:i.length,result:n.valid}}}}}catch(t){return{success:!1,error:t.message}}},prepareLegalValidityProof:function(t,e,r){u.checkArgument(t&&"object"==typeof t,"Invalid token"),u.checkArgument(e&&"object"==typeof e,"Invalid jurisdiction"),u.checkArgument("string"==typeof r,"Nonce must be string");try{var i=e.requirements||[],n=[],o=!0;i.forEach(function(e){var r=this._checkLegalRequirement(t,e);n.push(r),r.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:(new Date).toISOString(),proofPurpose:"legalValidity",jurisdiction:e.code,nonce:r,valid:o,checks:n,complianceHash:this._hashCompliance(t,e,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:e.code,totalRequirements:i.length,satisfiedRequirements:n.filter(t=>t.satisfied).length,failedRequirements:n.filter(t=>!t.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:t.id,jurisdiction:e.code,proof:s,complianceReport:{jurisdiction:e.code,totalRequirements:i.length,satisfiedRequirements:n.filter(t=>t.satisfied).length,failedRequirements:n.filter(t=>!t.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:t.id,jurisdiction:e.code,result:o,checkedAt:(new Date).toISOString(),requirements:n}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:t.id,jurisdiction:e.code,failedRequirements:n.filter(t=>!t.satisfied)}}}}}catch(t){return{success:!1,error:t.message}}},prepareZeroKnowledgeProof:function(t,r,i){u.checkArgument(t&&"object"==typeof t,"Invalid token"),u.checkArgument(r&&"object"==typeof r,"Invalid statement"),u.checkArgument("string"==typeof i,"Nonce must be string");try{var o=n.sha256(e.from(this._canonicalizeForSigning(t)+i)).toString("hex"),s={type:"LegalTokenZKProof",created:(new Date).toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:r.claim||"UNSPECIFIED",predicate:r.predicate||"SATISFIES",threshold:r.threshold||null},commitment:o,nonce:i,proofData:this._generateZKProofData(t,r,i)};return{success:!0,proof:s,commitment:o,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:t.id,proof:s,statement:r}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:s,expectedNonce:i}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:t.id,statement:r.claim,proofGenerated:(new Date).toISOString()}}}}}catch(t){return{success:!1,error:t.message}}},_generateZKProofData:function(t,r,i){return{challenge:n.sha256(e.from(r.claim+i)).toString("hex"),response:n.sha256(e.from(this._canonicalizeForSigning(t)+r.claim)).toString("hex"),witness:n.sha256(e.from(i+t.id+r.predicate)).toString("hex")}},_createJWS:function(t,r){var i=e.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");t.toString("base64url");return i+".."+r.toDER().toString("base64url")},_canonicalizeForSigning:function(t){var e=JSON.parse(JSON.stringify(t));delete e.proof,delete e.tokenHash;var r=this._sortObjectKeys(e);return JSON.stringify(r)},_createFieldCommitments:function(t,r){var i=[],o=0;return this._traverseObject(t,"",function(t,s){if("proof"!==t&&"tokenHash"!==t){var a=n.sha256(e.from(r+t+o)).toString("hex"),u=this._hashField(t,s,a);i.push({path:t,value:s,salt:a,hash:u,index:o}),o++}}.bind(this)),i},_hashField:function(t,r,i){var o=t+":"+JSON.stringify(r)+":"+i;return n.sha256(e.from(o)).toString("hex")},_createMerkleTree:function(t){var r=t.map((function(t){return t.hash}));if(0===r.length)return{root:null,levels:[]};for(var i=[r],o=r;o.length>1;){for(var s=[],a=0;a<o.length;a+=2){var u=o[a],c=o[a+1]||u,h=e.concat([e.from(u,"hex"),e.from(c,"hex")]),f=n.sha256(h).toString("hex");s.push(f)}i.push(s),o=s}return{root:o[0],levels:i}},_generateMerkleProof:function(t,e){for(var r=[],i=e,n=0;n<t.levels.length-1;n++){var o=t.levels[n],s=i%2==0,a=s?i+1:i-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),i=Math.floor(i/2)}return r},_verifyMerkleProof:function(t,r,i,o){for(var s=t,a=r,u=0;u<i.length;u++){var c,h=i[u];c=h.isLeft?e.concat([e.from(h.hash,"hex"),e.from(s,"hex")]):e.concat([e.from(s,"hex"),e.from(h.hash,"hex")]),s=n.sha256(c).toString("hex"),a=Math.floor(a/2)}return s===o},_traverseObject:function(t,e,r){Array.isArray(t)?t.forEach(function(t,i){var n=e+"["+i+"]";this._traverseObject(t,n,r)}.bind(this)):null!==t&&"object"==typeof t?Object.keys(t).forEach(function(i){var n=e?e+"."+i:i;this._traverseObject(t[i],n,r)}.bind(this)):r(e,t)},_getNestedValue:function(t,e){return e.split(".").reduce((function(t,e){return t&&t[e]}),t)},_findFieldCommitment:function(t,e){return t.find((function(t){return t.path===e}))},_checkLegalRequirement:function(t,e){switch(e.type){case"field_present":var r=this._getNestedValue(t,e.field);return{requirement:e.type,field:e.field,satisfied:null!=r};case"field_value":r=this._getNestedValue(t,e.field);return{requirement:e.type,field:e.field,satisfied:r===e.expectedValue};case"temporal_validity":var i=new Date,n=new Date(t.issuanceDate);return{requirement:e.type,satisfied:n<=i};default:return{requirement:e.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(t,r,i){var o={tokenId:t.id,jurisdiction:r.code,nonce:i,timestamp:(new Date).toISOString()};return n.sha256(e.from(JSON.stringify(o))).toString("hex")},_sortObjectKeys:function(t){if(Array.isArray(t))return t.map(this._sortObjectKeys.bind(this));if(null!==t&&"object"==typeof t){var e={};return Object.keys(t).sort().forEach(function(r){e[r]=this._sortObjectKeys(t[r])}.bind(this)),e}return t}};t.exports=c}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=(i.Address,i.Transaction,i.util.preconditions),s={prepareRegistry:function(t){t=t||{},o.checkArgument("object"==typeof t,"Config must be object");var e={id:t.id||this._generateRegistryId(),name:t.name||"Legal Token Registry",jurisdiction:t.jurisdiction||"GLOBAL",authority:t.authority||null,created:(new Date).toISOString(),version:"1.0.0",config:{allowPublicRegistration:t.allowPublicRegistration||!1,requireApproval:t.requireApproval||!0,enableRevocation:!1!==t.enableRevocation,enableAuditTrail:!1!==t.enableAuditTrail,retentionPeriod:t.retentionPeriod||"7Y",complianceLevel:t.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}};return{success:!0,registry:e,initialAudit:this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:t.authority,timestamp:e.created,metadata:{jurisdiction:e.jurisdiction,config:e.config}}),instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(t,e,r){r=r||{},o.checkArgument(t&&"object"==typeof t,"Invalid token"),o.checkArgument(e&&"object"==typeof e,"Invalid registry config");try{var i=this._validateTokenForRegistration(t,e);if(!i.valid)return{success:!1,error:"Token validation failed: "+i.error};var n={tokenId:t.id,tokenHash:this._hashToken(t),token:t,status:e.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:(new Date).toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:t.jurisdiction||e.jurisdiction,level:this._calculateComplianceLevel(t),checks:i.checks||[]}},s=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:t.id,timestamp:n.registeredAt,metadata:{status:n.status,tokenType:t.type,compliance:n.compliance}});return{success:!0,registrationRecord:n,auditEntry:s,registrationId:this._generateRegistrationId(t.id),validation:i,externalOperations:{store:{endpoint:"POST /registry/"+e.id+"/tokens",data:n},audit:{endpoint:"POST /registry/"+e.id+"/audit",data:s}}}}catch(t){return{success:!1,error:t.message}}},prepareTokenApproval:function(t,e,r){try{o.checkArgument("string"==typeof t,"Token ID must be string"),o.checkArgument("string"==typeof e,"Approver must be string"),o.checkArgument(r&&"object"==typeof r,"Invalid registry config");var i={tokenId:t,status:"ACTIVE",approvedBy:e,approvedAt:(new Date).toISOString()},n=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:e,tokenId:t,timestamp:i.approvedAt});return{success:!0,approvalData:i,auditEntry:n,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+t+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:n}}}}catch(t){return{success:!1,error:t.message}}},prepareTokenRevocation:function(t,e,r){try{if(o.checkArgument("string"==typeof t,"Token ID must be string"),o.checkArgument(e&&"object"==typeof e,"Invalid revocation"),o.checkArgument(r&&"object"==typeof r,"Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var i={tokenId:t,reason:e.reason||"UNSPECIFIED",revokedBy:e.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:e.effectiveDate||(new Date).toISOString(),legalBasis:e.legalBasis||null,evidence:e.evidence||null,revocationHash:this._generateRevocationHash(t,e)},n={tokenId:t,status:"REVOKED",revokedAt:i.revokedAt,revocationReason:i.reason},s=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:e.revokedBy,tokenId:t,timestamp:i.revokedAt,metadata:{reason:i.reason,legalBasis:i.legalBasis}});return{success:!0,revocationRecord:i,statusUpdate:n,auditEntry:s,revocationId:this._generateRevocationId(t),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:i},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+t+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:s}}}}catch(t){return{success:!1,error:t.message}}},prepareTokenStatusQuery:function(t,e){try{return o.checkArgument("string"==typeof t,"Token ID must be string"),o.checkArgument(e&&"object"==typeof e,"Invalid registry config"),{success:!0,query:{tokenId:t,registryId:e.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+e.id+"/tokens/"+t,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+e.id+"/revocations/"+t,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(t){return{success:!1,error:t.message}}},prepareTokenSearch:function(t,e){t=t||{};try{o.checkArgument(e&&"object"==typeof e,"Invalid registry config");var r=[];t.status&&r.push("status="+encodeURIComponent(t.status)),t.type&&r.push("type="+encodeURIComponent(t.type)),t.registeredBy&&r.push("registeredBy="+encodeURIComponent(t.registeredBy)),t.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(t.jurisdiction)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo)),t.includeTokens&&r.push("includeTokens=true"),t.sortBy&&r.push("sortBy="+encodeURIComponent(t.sortBy)),t.sortOrder&&r.push("sortOrder="+encodeURIComponent(t.sortOrder));var i=t.offset||0,n=t.limit||100;r.push("offset="+i),r.push("limit="+n);var s=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:t,externalOperations:{search:{endpoint:"GET /registry/"+e.id+"/search"+s,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(t){return{success:!1,error:t.message}}},prepareStatisticsQuery:function(t){return o.checkArgument(t&&"object"==typeof t,"Invalid registry config"),{success:!0,query:{registryId:t.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+t.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(t,e){if(e=e||{},o.checkArgument(t&&"object"==typeof t,"Invalid registry config"),!t.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];e.action&&r.push("action="+encodeURIComponent(e.action)),e.actor&&r.push("actor="+encodeURIComponent(e.actor)),e.tokenId&&r.push("tokenId="+encodeURIComponent(e.tokenId)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo));var i=e.offset||0,n=e.limit||100;r.push("offset="+i),r.push("limit="+n);var s=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:e,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+t.id+"/audit"+s,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){var t="reg_"+Date.now()+"_"+Math.random();return"reg_"+n.sha256(e.from(t)).toString("hex").substring(0,16)},_generateRegistrationId:function(t){var r="reg_"+t+"_"+Date.now();return n.sha256(e.from(r)).toString("hex").substring(0,16)},_generateRevocationId:function(t){var r="rev_"+t+"_"+Date.now();return n.sha256(e.from(r)).toString("hex").substring(0,16)},_hashToken:function(t){var r=JSON.parse(JSON.stringify(t));return delete r.proof,delete r.tokenHash,n.sha256(e.from(JSON.stringify(r))).toString("hex")},_generateRevocationHash:function(t,r){var i=t+(r.reason||"")+(r.revokedBy||"")+Date.now();return n.sha256(e.from(i)).toString("hex")},_validateTokenForRegistration:function(t,e){var r=[],i=!0;return t.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),i=!1),t.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),i=!1),t.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),i=!1),t.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),i=!1),{valid:i,checks:r}},_calculateComplianceLevel:function(t){var e="BASIC";return t.proof&&t.proof.type&&(e="STANDARD"),t.jurisdiction&&t.legalBasis&&(e="ENHANCED"),t.attestations&&t.attestations.length>0&&(e="PREMIUM"),e},_prepareAuditEntry:function(t){return{id:this._generateAuditId(),action:t.action,actor:t.actor||"SYSTEM",tokenId:t.tokenId||null,timestamp:t.timestamp||(new Date).toISOString(),metadata:t.metadata||{},hash:this._generateAuditHash(t)}},_generateAuditId:function(){var t="audit_"+Date.now()+"_"+Math.random();return"audit_"+n.sha256(e.from(t)).toString("hex").substring(0,12)},_generateAuditHash:function(t){var r=(t.action||"")+(t.actor||"")+(t.tokenId||"")+(t.timestamp||"");return n.sha256(e.from(r)).toString("hex").substring(0,16)}};t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(5),n=i.crypto.Hash,o=i.crypto.ECDSA,s=i.PrivateKey,a=i.util.preconditions,u={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},c={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},h={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},f={prepareObligationToken:function(t,e,r,i,n,o){o=o||{},a.checkArgument("string"==typeof t,"Obligation type must be string"),a.checkArgument("string"==typeof e,"Issuer DID must be string"),a.checkArgument("string"==typeof r,"Obligor DID must be string"),a.checkArgument(i&&"object"==typeof i,"Obligation must be object"),a.checkArgument(n instanceof s,"Invalid issuer private key");var f=Object.values(u);a.checkArgument(f.includes(t),"Invalid obligation type: "+t);try{var d={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",t],issuer:e,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,obligationType:t,obligation:i,jurisdiction:o.jurisdiction||"US",priority:o.priority||c.MEDIUM,status:h.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||(new Date).toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:!1!==o.enforceable,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(d.credentialSubject.metadata=o.metadata);var l=this._signToken(d,n);return{success:!0,obligationToken:l,tokenHash:l.tokenHash,metadata:{type:t,issuer:e,obligor:r,priority:d.credentialSubject.priority,status:d.credentialSubject.status,jurisdiction:d.credentialSubject.jurisdiction,dueDate:d.credentialSubject.dueDate,correlativeRight:d.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:l,metadata:{type:t,issuer:e,obligor:r,priority:d.credentialSubject.priority,status:d.credentialSubject.status,jurisdiction:d.credentialSubject.jurisdiction,dueDate:d.credentialSubject.dueDate,correlativeRight:d.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:l.id,tokenHash:l.tokenHash,type:t,issuer:e,obligor:r,issuedAt:l.issuanceDate,dueDate:d.credentialSubject.dueDate,priority:d.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:l.id,issuer:e,obligor:r,obligationType:t,dueDate:d.credentialSubject.dueDate,priority:d.credentialSubject.priority}},scheduleReminders:d.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:l.id,obligor:r,dueDate:d.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(t){return{success:!1,error:t.message}}},prepareObligationVerification:function(t,e){e=e||{};try{var r=[],i=[];this._validateTokenStructure(t,r),this._verifyTokenSignature(t,r),this._validateTokenTemporal(t,r,i),this._validateObligationType(t,r),this._validateObligationStatus(t,r,i),this._validateObligationPriority(t,i);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:t.issuer,obligorDID:t.credentialSubject?t.credentialSubject.id:null,obligationType:t.credentialSubject?t.credentialSubject.obligationType:null,status:t.credentialSubject?t.credentialSubject.status:null,priority:t.credentialSubject?t.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(t),verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:t.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt,isOverdue:n.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:t.id,obligationType:n.obligationType,issuer:n.issuerDID,obligor:n.obligorDID,result:n.valid,verifiedAt:n.verifiedAt}},updateStatus:n.isOverdue&&t.credentialSubject.status===h.ACTIVE?{endpoint:"PUT /obligations/tokens/"+t.id+"/status",data:{status:h.OVERDUE,updatedAt:n.verifiedAt,reason:"Due date passed"}}:null}}}catch(t){return{success:!1,error:"Verification preparation failed: "+t.message}}},prepareObligationFulfillment:function(t,e,r,i){i=i||{},a.checkArgument(t&&"object"==typeof t,"Invalid token"),a.checkArgument(e&&"object"==typeof e,"Invalid fulfillment"),a.checkArgument(r instanceof s,"Invalid obligor key");try{var n=this.prepareObligationVerification(t,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+n.verification.errors.join(", ")};if(t.credentialSubject.status===h.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(t.credentialSubject.status===h.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:t.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t.id,fulfillmentType:e.type||"FULL_FULFILLMENT",fulfillmentDate:(new Date).toISOString(),evidence:e.evidence||null,description:e.description||"",completionPercentage:e.completionPercentage||100,attestations:e.attestations||[],notes:e.notes||null}},u=this._signToken(o,r),c=o.credentialSubject.completionPercentage>=100?h.COMPLETED:h.IN_PROGRESS;return{success:!0,fulfillmentRecord:u,newStatus:c,fulfillmentId:u.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:t.id,fulfillmentRecord:u,obligor:t.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+t.id+"/status",data:{status:c,fulfillmentId:u.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:t.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:t.id,fulfillmentId:u.id,obligor:t.credentialSubject.id,rightHolder:t.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:c}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:t.id,fulfillmentId:u.id,obligor:t.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(t){return{success:!1,error:t.message}}},prepareObligationBreachAssessment:function(t,r,i){a.checkArgument(t&&"object"==typeof t,"Invalid token"),a.checkArgument(r&&"object"==typeof r,"Invalid breach details"),a.checkArgument(i&&"object"==typeof i,"Invalid assessor");try{var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:i.did||i.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t.id,breachType:r.type||"MATERIAL_BREACH",breachDate:r.date||(new Date).toISOString(),description:r.description||"",severity:r.severity||"MODERATE",evidence:r.evidence||[],assessor:{did:i.did||i.id,name:i.name||"Unknown",authority:i.authority||null,jurisdiction:i.jurisdiction||null},damages:r.damages||null,recommendedRemedies:r.recommendedRemedies||[],assessmentDate:(new Date).toISOString()}},s=n.sha256(e.from(JSON.stringify(o))).toString("hex");return o.credentialSubject.assessmentHash=s,{success:!0,breachAssessment:o,breachId:o.id,severity:r.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:t.id,breachAssessment:o,obligor:t.credentialSubject.id,rightHolder:t.credentialSubject.rightHolder,breachDate:r.date||(new Date).toISOString(),severity:r.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+t.id+"/status",data:{status:h.BREACHED,breachId:o.id,breachDate:r.date||(new Date).toISOString(),updatedAt:(new Date).toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:t.id,breachId:o.id,obligor:t.credentialSubject.id,rightHolder:t.credentialSubject.rightHolder,breachType:r.type||"MATERIAL_BREACH",severity:r.severity||"MODERATE"}},escalateBreach:"CRITICAL"===r.severity?{endpoint:"POST /legal/escalate-breach",data:{obligationId:t.id,breachId:o.id,severity:r.severity,jurisdiction:t.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:t.id,breachId:o.id,obligor:t.credentialSubject.id,assessedAt:o.credentialSubject.assessmentDate,severity:r.severity||"MODERATE"}}}}}catch(t){return{success:!1,error:t.message}}},prepareObligationMonitoringReport:function(t,e){e=e||{},a.checkArgument(Array.isArray(t),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:(new Date).toISOString(),criteria:e,summary:{totalObligations:t.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},i=new Date,n=new Date(i.getTime()+6048e5);return t.forEach(function(t){var e={id:t.id,type:t.credentialSubject.obligationType,status:t.credentialSubject.status,priority:t.credentialSubject.priority,obligor:t.credentialSubject.id,dueDate:t.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(t),isDueSoon:!1};if(t.credentialSubject.dueDate){var o=new Date(t.credentialSubject.dueDate);e.isDueSoon=o<=n&&o>i}r.summary.byStatus[e.status]=(r.summary.byStatus[e.status]||0)+1,r.summary.byPriority[e.priority]=(r.summary.byPriority[e.priority]||0)+1,r.summary.byType[e.type]=(r.summary.byType[e.type]||0)+1,e.isOverdue&&r.summary.overdue++,e.isDueSoon&&r.summary.dueSoon++,e.status===h.COMPLETED&&r.summary.completed++,e.isOverdue&&e.priority===c.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:t.id,message:"Critical obligation is overdue",priority:"HIGH"}),e.isDueSoon&&e.priority===c.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:t.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(e)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(t){return{success:!1,error:t.message}}},getObligationTypes:function(){return u},getObligationPriority:function(){return c},getObligationStatus:function(){return h},_signToken:function(t,r){var i=this._canonicalizeToken(t),s=n.sha256(e.from(i)),a=new o;a.hashbuf=s,a.privkey=r,a.pubkey=r.toPublicKey(),a.sign();var u=a.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+r.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(s,u)},h=JSON.parse(JSON.stringify(t));return h.proof=c,h.tokenHash=s.toString("hex"),h},_createJWS:function(t,r){var i=e.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");t.toString("base64url");return i+".."+r.toDER().toString("base64url")},_canonicalizeToken:function(t){var e=JSON.parse(JSON.stringify(t));return delete e.proof,delete e.tokenHash,JSON.stringify(this._sortObjectKeys(e))},_sortObjectKeys:function(t){if(Array.isArray(t))return t.map(this._sortObjectKeys.bind(this));if(null!==t&&"object"==typeof t){var e={};return Object.keys(t).sort().forEach(function(r){e[r]=this._sortObjectKeys(t[r])}.bind(this)),e}return t},_validateTokenStructure:function(t,e){t["@context"]||e.push("Missing @context"),t.id||e.push("Missing id"),t.type&&Array.isArray(t.type)||e.push("Missing or invalid type"),t.issuer||e.push("Missing issuer"),t.issuanceDate||e.push("Missing issuanceDate"),t.credentialSubject||e.push("Missing credentialSubject"),t.proof||e.push("Missing proof")},_verifyTokenSignature:function(t,r){try{if(!t.proof||!t.proof.jws)return void r.push("Missing signature proof");var i=this._canonicalizeToken(t),o=n.sha256(e.from(i));if(t.tokenHash&&t.tokenHash!==o.toString("hex"))return void r.push("Token hash mismatch")}catch(t){r.push("Signature verification failed: "+t.message)}},_validateTokenTemporal:function(t,e,r){var i=new Date;(new Date(t.issuanceDate)>i&&e.push("Token issued in the future"),t.credentialSubject.effectiveDate)&&(i<new Date(t.credentialSubject.effectiveDate)&&r.push("Obligation not yet effective"));t.credentialSubject.expirationDate&&(i>new Date(t.credentialSubject.expirationDate)&&e.push("Obligation expired"))},_validateObligationType:function(t,e){t.credentialSubject.obligationType?Object.values(u).includes(t.credentialSubject.obligationType)||e.push("Invalid obligation type: "+t.credentialSubject.obligationType):e.push("Missing obligationType")},_validateObligationStatus:function(t,e,r){t.credentialSubject.status?(Object.values(h).includes(t.credentialSubject.status)||e.push("Invalid obligation status: "+t.credentialSubject.status),this._checkIfOverdue(t)&&t.credentialSubject.status===h.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")):e.push("Missing status")},_validateObligationPriority:function(t,e){t.credentialSubject.priority&&(Object.values(c).includes(t.credentialSubject.priority)||e.push("Invalid obligation priority: "+t.credentialSubject.priority))},_checkIfOverdue:function(t){return!!t.credentialSubject.dueDate&&(new Date>new Date(t.credentialSubject.dueDate)&&t.credentialSubject.status!==h.COMPLETED)},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}};f.ObligationTypes=u,f.ObligationPriority=c,f.ObligationStatus=h,t.exports=f}).call(this,r(0).Buffer)}])}));