!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).bcur=t()}}((function(){for(var t=function(t){var r;return function(e){return r||t(r={exports:{},parent:e},r.exports),r.exports}},r=t((function(t,r){(function(t){(function(){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.decodeBc32Data=r.encodeBc32Data=r.Bech32Version=void 0;var i,o=n(e({}));!function(t){t[t.Origin=1]="Origin",t[t.bis=2]="bis"}(i=r.Bech32Version||(r.Bech32Version={}));var h=function(t,r,e,n){for(var i=0,o=0,h=[],s=(1<>r!=0)return null;for(i=i<=e;)o-=e,h.push(i>>o&s)}if(n)o>0&&h.push(i<=r||i<>25;r=(33554431&r)<<5^t[e];for(var i=0;i<6;++i)n>>i&1&&(r^=o[i])}return r},s=function(t){var r,e=[];for(r=0;r>5);for(e.push(0),r=0;r>5*(5-a)&31);return f}(t,r,e));o=t?t+"1":"";for(var f=0;f126)return null;t.charCodeAt(r)>=97&&t.charCodeAt(r)<=122&&(e=!0),t.charCodeAt(r)>=65&&t.charCodeAt(r)<=90&&(o=!0)}if(e&&o)return null;var h=(t=t.toLowerCase()).lastIndexOf("1");if(-1===h)return function(t){for(var r=[],e=0;et.length||t.length>90)return null;var s=t.substring(0,h),f=[];for(r=h+1;r2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,r,e){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return n(t,r,e)}function n(r,n,i){if("string"==typeof r)return function(r,n){if("string"==typeof n&&""!==n||(n="utf8"),!e.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var i=0|f(r,n),o=t(i),h=o.write(r,n);return h!==i&&(o=o.slice(0,h)),o}(r,n);if(ArrayBuffer.isView(r))return s(r);if(null==r)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(P(r,ArrayBuffer)||r&&P(r.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function f(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return T(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return M(t).length;default:if(o)return i?-1:T(t).length;r=(""+r).toLowerCase(),o=!0}}function a(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function c(t,r,n,i,o){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),j(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:l(t,r,n,i,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):l(t,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function l(t,r,e,n,i){var o,h=1,s=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;h=2,s/=2,u/=2,e/=2}function f(t,r){return 1===h?t[r]:t.readUInt16BE(r*h)}if(i){var a=-1;for(o=e;os&&(e=s-u),o=e;o>=0;o--){for(var c=!0,l=0;li&&(n=i):n=i;var o=r.length;n>o/2&&(n=o/2);for(var h=0;h>8,i=e%256,o.push(i),o.push(n);return o}(r,t.length-e),t,e,n)}function b(t,r,e){return 0===r&&e===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(r,e))}function m(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i239?4:f>223?3:f>191?2:1;if(i+c<=e)switch(c){case 1:f<128&&(a=f);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&f)<<6|63&o)>127&&(a=u);break;case 3:o=t[i+1],h=t[i+2],128==(192&o)&&128==(192&h)&&(u=(15&f)<<12|(63&o)<<6|63&h)>2047&&(u<55296||u>57343)&&(a=u);break;case 4:o=t[i+1],h=t[i+2],s=t[i+3],128==(192&o)&&128==(192&h)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&h)<<6|63&s)>65535&&u<1114112&&(a=u)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return function(t){var r=t.length;if(r<=E)return String.fromCharCode.apply(String,t);for(var e="",n=0;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,r,e);case"utf8":case"utf-8":return m(this,r,e);case"ascii":return B(this,r,e);case"latin1":case"binary":return A(this,r,e);case"base64":return b(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},e.prototype.compare=function(t,r,n,i,o){if(P(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(this===t)return 0;for(var h=(o>>>=0)-(i>>>=0),s=(n>>>=0)-(r>>>=0),u=Math.min(h,s),f=this.slice(i,o),a=t.slice(r,n),c=0;c>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return d(this,t,r,e);case"utf8":case"utf-8":return _(this,t,r,e);case"ascii":return g(this,t,r,e);case"latin1":case"binary":return y(this,t,r,e);case"base64":return w(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function B(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;ii)&&(e=i);for(var o="",h=r;he)throw new RangeError("Trying to access beyond buffer length")}function x(t,r,n,i,o,h){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function C(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function R(t,r,e,n,i){return r=+r,e>>>=0,i||C(t,0,e,4),p.write(t,r,e,n,23,4),e+4}function k(t,r,e,n,i){return r=+r,e>>>=0,i||C(t,0,e,8),p.write(t,r,e,n,52,8),e+8}e.prototype.slice=function(t,r){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t],i=1,o=0;++o>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},e.prototype.readUInt8=function(t,r){return t>>>=0,r||S(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,r){return t>>>=0,r||S(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,r){return t>>>=0,r||S(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,r){return t>>>=0,r||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,r){return t>>>=0,r||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*r)),n},e.prototype.readIntBE=function(t,r,e){t>>>=0,r>>>=0,e||S(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},e.prototype.readInt8=function(t,r){return t>>>=0,r||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,r){t>>>=0,r||S(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},e.prototype.readInt16BE=function(t,r){t>>>=0,r||S(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},e.prototype.readInt32LE=function(t,r){return t>>>=0,r||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,r){return t>>>=0,r||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,r){return t>>>=0,r||S(t,4,this.length),p.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,r){return t>>>=0,r||S(t,4,this.length),p.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,r){return t>>>=0,r||S(t,8,this.length),p.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,r){return t>>>=0,r||S(t,8,this.length),p.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,r,e,n){t=+t,r>>>=0,e>>>=0,n||x(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o>>=0,e>>>=0,n||x(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},e.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,255,0),this[r]=255&t,r+1},e.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},e.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},e.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},e.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},e.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);x(this,t,r,e,i-1,-i)}var o=0,h=1,s=0;for(this[r]=255&t;++o>0)-s&255;return r+e},e.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var i=Math.pow(2,8*e-1);x(this,t,r,e,i-1,-i)}var o=e-1,h=1,s=0;for(this[r+o]=255&t;--o>=0&&(h*=256);)t<0&&0===s&&0!==this[r+o+1]&&(s=1),this[r+o]=(t/h>>0)-s&255;return r+e},e.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},e.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},e.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},e.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},e.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},e.prototype.writeFloatLE=function(t,r,e){return R(this,t,r,!0,e)},e.prototype.writeFloatBE=function(t,r,e){return R(this,t,r,!1,e)},e.prototype.writeDoubleLE=function(t,r,e){return k(this,t,r,!0,e)},e.prototype.writeDoubleBE=function(t,r,e){return k(this,t,r,!1,e)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--h)t[h+r]=this[h+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return o},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var o=t.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(t=o)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(h=r;h55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(h+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function M(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,r,e,n){for(var i=0;i=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function P(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function j(t){return t!=t}}).call(this)}).call(this,n({}).Buffer)})),i={toByteArray:function(t){var r,e,n=c(t),i=n[0],o=n[1],u=new s(function(t,r,e){return 3*(r+e)/4-e}(0,i,o)),f=0,a=o>0?i-4:i;for(e=0;e>16&255,u[f++]=r>>8&255,u[f++]=255&r;return 2===o&&(r=h[t.charCodeAt(e)]<<2|h[t.charCodeAt(e+1)]>>4,u[f++]=255&r),1===o&&(r=h[t.charCodeAt(e)]<<10|h[t.charCodeAt(e+1)]<<4|h[t.charCodeAt(e+2)]>>2,u[f++]=r>>8&255,u[f++]=255&r),u},fromByteArray:function(t){for(var r,e=t.length,n=e%3,i=[],h=0,s=e-n;hs?s:h+16383));return 1===n?(r=t[e-1],i.push(o[r>>2]+o[r<<4&63]+"==")):2===n&&(r=(t[e-2]<<8)+t[e-1],i.push(o[r>>10]+o[r>>4&63]+o[r<<2&63]+"=")),i.join("")}},o=[],h=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,a=u.length;f0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function l(t,r,e){for(var n,i,h=[],s=r;s>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return h.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var p={read:function(t,r,e,n,i){var o,h,s=8*i-n-1,u=(1<>1,a=-7,c=e?i-1:0,l=e?-1:1,p=t[r+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[r+c],c+=l,a-=8);for(h=o&(1<<-a)-1,o>>=-a,a+=n;a>0;h=256*h+t[r+c],c+=l,a-=8);if(0===o)o=1-f;else{if(o===u)return h?NaN:1/0*(p?-1:1);h+=Math.pow(2,n),o-=f}return(p?-1:1)*h*Math.pow(2,o-n)},write:function(t,r,e,n,i,o){var h,s,u,f=8*o-i-1,a=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,h=a):(h=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-h))<1&&(h--,u*=2),(r+=h+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(h++,u/=2),h+c>=a?(s=0,h=a):h+c>=1?(s=(r*u-1)*Math.pow(2,i),h+=c):(s=r*Math.pow(2,c-1)*Math.pow(2,i),h=0));i>=8;t[e+p]=255&s,p+=d,s/=256,i-=8);for(h=h<0;t[e+p]=255&h,p+=d,h/=256,f-=8);t[e+p-d]|=128*_}},d={};(function(t){(function(){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.decodeSimpleCBOR=d.encodeSimpleCBOR=d.composeHeader=void 0,d.composeHeader=function(r){var e;if(r>0&&r<=23)e=t.from([64+r]);else if(r>=24&&r<=255)(n=t.alloc(1)).writeUInt8(r,0),e=t.concat([t.from([88]),n]);else if(r>=256&&r<=65535)(n=t.alloc(2)).writeUInt16BE(r,0),e=t.concat([t.from([89]),n]);else{if(!(r>=65536&&r<=Math.pow(2,32)-1))throw new Error("length exceeded");var n;(n=t.alloc(4)).writeUInt32BE(r,0),e=t.concat([t.from([96]),n])}return e},d.encodeSimpleCBOR=function(r){var e=t.from(r,"hex");if(e.length<=0||e.length>=Math.pow(2,32))throw new Error("data is too large");var n=d.composeHeader(e.length);return t.concat([n,e]).toString("hex")},d.decodeSimpleCBOR=function(r){var e=t.from(r,"hex");if(e.length<=0)throw new Error("invalid input");var n=e[0];if(n<88){var i=n-64;return e.slice(1,1+i).toString("hex")}if(88==n)return i=e.slice(1,2).readUInt8(0),e.slice(2,2+i).toString("hex");if(89==n)return i=e.slice(1,3).readUInt16BE(0),e.slice(3,3+i).toString("hex");if(96==n)return i=e.slice(1,5).readUInt32BE(0),e.slice(5,5+i).toString("hex");throw new Error("invalid input")}}).call(this)}).call(this,n({}).Buffer);var _={};_="function"==typeof Object.create?function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:function(t,r){if(r){t.super_=r;var e=function(){};e.prototype=r.prototype,t.prototype=new e,t.prototype.constructor=t}};var g={},y=n({}),w=y.Buffer;function v(t,r){for(var e in t)r[e]=t[e]}function b(t,r,e){return w(t,r,e)}w.from&&w.alloc&&w.allocUnsafe&&w.allocUnsafeSlow?g=y:(v(y,g),g.Buffer=b),b.prototype=Object.create(w.prototype),v(w,b),b.from=function(t,r,e){if("number"==typeof t)throw new TypeError("Argument must not be a number");return w(t,r,e)},b.alloc=function(t,r,e){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=w(t);return void 0!==r?"string"==typeof e?n.fill(r,e):n.fill(r):n.fill(0),n},b.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return w(t)},b.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return y.SlowBuffer(t)};var m={},E=g.Buffer;function B(t,r){this._block=E.alloc(t),this._finalSize=r,this._blockSize=t,this._len=0}B.prototype.update=function(t,r){"string"==typeof t&&(r=r||"utf8",t=E.from(t,r));for(var e=this._block,n=this._blockSize,i=t.length,o=this._len,h=0;h=this._finalSize&&(this._update(this._block),this._block.fill(0));var e=8*this._len;if(e<=4294967295)this._block.writeUInt32BE(e,this._blockSize-4);else{var n=(4294967295&e)>>>0,i=(e-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},B.prototype._update=function(){throw new Error("_update must be implemented by subclass")},m=B;var A,I=g.Buffer,U=[1518500249,1859775393,-1894007588,-899497514],S=new Array(80);function x(){this.init(),this._w=S,m.call(this,64,56)}function C(t){return t<<30|t>>>2}function R(t,r,e,n){return 0===t?r&e|~r&n:2===t?r&e|r&n|e&n:r^e^n}_(x,m),x.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},x.prototype._update=function(t){for(var r,e=this._w,n=0|this._a,i=0|this._b,o=0|this._c,h=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=e[u-3]^e[u-8]^e[u-14]^e[u-16];for(var f=0;f<80;++f){var a=~~(f/20),c=0|((r=n)<<5|r>>>27)+R(a,i,o,h)+s+e[f]+U[a];s=h,h=o,o=C(i),i=n,n=c}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=h+this._d|0,this._e=s+this._e|0},x.prototype._hash=function(){var t=I.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},A=x;var k,O=g.Buffer,T=[1518500249,1859775393,-1894007588,-899497514],M=new Array(80);function L(){this.init(),this._w=M,m.call(this,64,56)}function P(t){return t<<5|t>>>27}function j(t){return t<<30|t>>>2}function z(t,r,e,n){return 0===t?r&e|~r&n:2===t?r&e|r&n|e&n:r^e^n}_(L,m),L.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},L.prototype._update=function(t){for(var r,e=this._w,n=0|this._a,i=0|this._b,o=0|this._c,h=0|this._d,s=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=(r=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|r>>>31;for(var f=0;f<80;++f){var a=~~(f/20),c=P(n)+z(a,i,o,h)+s+e[f]+T[a]|0;s=h,h=o,o=j(i),i=n,n=c}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=h+this._d|0,this._e=s+this._e|0},L.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},k=L;var D,N=g.Buffer,V=[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],q=new Array(64);function F(){this.init(),this._w=q,m.call(this,64,56)}function H(t,r,e){return e^t&(r^e)}function W(t,r,e){return t&r|e&(t|r)}function Y(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function X(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function J(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}_(F,m),F.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},F.prototype._update=function(t){for(var r,e=this._w,n=0|this._a,i=0|this._b,o=0|this._c,h=0|this._d,s=0|this._e,u=0|this._f,f=0|this._g,a=0|this._h,c=0;c<16;++c)e[c]=t.readInt32BE(4*c);for(;c<64;++c)e[c]=0|(((r=e[c-2])>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)+e[c-7]+J(e[c-15])+e[c-16];for(var l=0;l<64;++l){var p=a+X(s)+H(s,u,f)+V[l]+e[l]|0,d=Y(n)+W(n,i,o)|0;a=f,f=u,u=s,s=h+p|0,h=o,o=i,i=n,n=p+d|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=h+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=f+this._g|0,this._h=a+this._h|0},F.prototype._hash=function(){var t=N.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},D=F;var Z,G=g.Buffer,K=new Array(64);function Q(){this.init(),this._w=K,m.call(this,64,56)}_(Q,D),Q.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},Q.prototype._hash=function(){var t=G.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},Z=Q;var $,tt=g.Buffer,rt=[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],et=new Array(160);function nt(){this.init(),this._w=et,m.call(this,128,112)}function it(t,r,e){return e^t&(r^e)}function ot(t,r,e){return t&r|e&(t|r)}function ht(t,r){return(t>>>28|r<<4)^(r>>>2|t<<30)^(r>>>7|t<<25)}function st(t,r){return(t>>>14|r<<18)^(t>>>18|r<<14)^(r>>>9|t<<23)}function ut(t,r){return(t>>>1|r<<31)^(t>>>8|r<<24)^t>>>7}function ft(t,r){return(t>>>1|r<<31)^(t>>>8|r<<24)^(t>>>7|r<<25)}function at(t,r){return(t>>>19|r<<13)^(r>>>29|t<<3)^t>>>6}function ct(t,r){return(t>>>19|r<<13)^(r>>>29|t<<3)^(t>>>6|r<<26)}function lt(t,r){return t>>>0>>0?1:0}_(nt,m),nt.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},nt.prototype._update=function(t){for(var r=this._w,e=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,h=0|this._eh,s=0|this._fh,u=0|this._gh,f=0|this._hh,a=0|this._al,c=0|this._bl,l=0|this._cl,p=0|this._dl,d=0|this._el,_=0|this._fl,g=0|this._gl,y=0|this._hl,w=0;w<32;w+=2)r[w]=t.readInt32BE(4*w),r[w+1]=t.readInt32BE(4*w+4);for(;w<160;w+=2){var v=r[w-30],b=r[w-30+1],m=ut(v,b),E=ft(b,v),B=at(v=r[w-4],b=r[w-4+1]),A=ct(b,v),I=r[w-14],U=r[w-14+1],S=r[w-32],x=r[w-32+1],C=E+U|0,R=m+I+lt(C,E)|0;R=(R=R+B+lt(C=C+A|0,A)|0)+S+lt(C=C+x|0,x)|0,r[w]=R,r[w+1]=C}for(var k=0;k<160;k+=2){R=r[k],C=r[k+1];var O=ot(e,n,i),T=ot(a,c,l),M=ht(e,a),L=ht(a,e),P=st(h,d),j=st(d,h),z=rt[k],D=rt[k+1],N=it(h,s,u),V=it(d,_,g),q=y+j|0,F=f+P+lt(q,y)|0;F=(F=(F=F+N+lt(q=q+V|0,V)|0)+z+lt(q=q+D|0,D)|0)+R+lt(q=q+C|0,C)|0;var H=L+T|0,W=M+O+lt(H,L)|0;f=u,y=g,u=s,g=_,s=h,_=d,h=o+F+lt(d=p+q|0,p)|0,o=i,p=l,i=n,l=c,n=e,c=a,e=F+W+lt(a=q+H|0,q)|0}this._al=this._al+a|0,this._bl=this._bl+c|0,this._cl=this._cl+l|0,this._dl=this._dl+p|0,this._el=this._el+d|0,this._fl=this._fl+_|0,this._gl=this._gl+g|0,this._hl=this._hl+y|0,this._ah=this._ah+e+lt(this._al,a)|0,this._bh=this._bh+n+lt(this._bl,c)|0,this._ch=this._ch+i+lt(this._cl,l)|0,this._dh=this._dh+o+lt(this._dl,p)|0,this._eh=this._eh+h+lt(this._el,d)|0,this._fh=this._fh+s+lt(this._fl,_)|0,this._gh=this._gh+u+lt(this._gl,g)|0,this._hh=this._hh+f+lt(this._hl,y)|0},nt.prototype._hash=function(){var t=tt.allocUnsafe(64);function r(r,e,n){t.writeInt32BE(r,n),t.writeInt32BE(e,n+4)}return r(this._ah,this._al,0),r(this._bh,this._bl,8),r(this._ch,this._cl,16),r(this._dh,this._dl,24),r(this._eh,this._el,32),r(this._fh,this._fl,40),r(this._gh,this._gl,48),r(this._hh,this._hl,56),t},$=nt;var pt,dt=g.Buffer,_t=new Array(160);function gt(){this.init(),this._w=_t,m.call(this,128,112)}_(gt,$),gt.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},gt.prototype._hash=function(){var t=dt.allocUnsafe(48);function r(r,e,n){t.writeInt32BE(r,n),t.writeInt32BE(e,n+4)}return r(this._ah,this._al,0),r(this._bh,this._bl,8),r(this._ch,this._cl,16),r(this._dh,this._dl,24),r(this._eh,this._el,32),r(this._fh,this._fl,40),t},pt=gt;var yt,wt;(wt=yt=function(t){t=t.toLowerCase();var r=wt[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r}).sha=A,wt.sha1=k,wt.sha224=Z,wt.sha256=D,wt.sha384=pt,wt.sha512=$;var vt={},bt=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(vt,"__esModule",{value:!0}),vt.compose3=vt.sha256Hash=void 0;var mt=bt(yt);vt.sha256Hash=function(t){return mt.default("sha256").update(t).digest()},vt.compose3=function(t,r,e){return function(n){return t(r(e(n)))}};var Et={};(function(t){(function(){"use strict";Object.defineProperty(Et,"__esModule",{value:!0}),Et.encodeUR=void 0;var e=r({}),n=function(t,r){return void 0===r&&(r="bytes"),"ur:"+r+"/"+t};Et.encodeUR=function(r,i){void 0===i&&(i=200);var o=d.encodeSimpleCBOR(r),h=e.encodeBc32Data(o),s=vt.sha256Hash(t.from(o,"hex")).toString("hex"),u=e.encodeBc32Data(s),f=h.match(new RegExp(".{1,"+i+"}","g"));if(!f)throw new Error("Unexpected error when encoding");return function(t,r,e){return void 0===e&&(e="bytes"),1===t.length?[n(t[0])]:t.map((function(i,o){return vt.compose3((function(t){return n(t,e)}),(function(r){return function(t,r,e){return r+1+"of"+e+"/"+t}(r,o,t.length)}),(function(t){return function(t,r){return r+"/"+t}(t,r)}))(i)}))}(f,u,"bytes").map((function(t){return t.toUpperCase()}))}}).call(this)}).call(this,n({}).Buffer);var Bt={};(function(t){(function(){"use strict";Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.extractSingleWorkload=Bt.decodeUR=void 0;var e=r({}),n=function(t){var r=t.toUpperCase().split("OF");if(2!==r.length)throw new Error("invalid sequence: "+t);return[+r[0],+r[1]]},i=function(r,n){var i=e.decodeBc32Data(n);if(!i)throw new Error("can not decode payload: "+n);if(e.decodeBc32Data(r)!==vt.sha256Hash(t.from(i,"hex")).toString("hex"))throw new Error("invalid digest: \n digest:"+r+" \n payload:"+n)},o=function(t,r){if(void 0===r&&(r="bytes"),t.toUpperCase()!==("ur:"+r).toUpperCase())throw new Error("invalid UR header: "+t)};Bt.decodeUR=function(t,r){void 0===r&&(r="bytes");var h=function(t,r){void 0===r&&(r="bytes");try{return 1===t.length?function(t,r){void 0===r&&(r="bytes");var e=t.split("/");switch(e.length){case 2:return o(e[0],r),e[1];case 3:o(e[0],r);var h=e[1],s=e[2];return i(h,s),s;case 4:return o(e[0],r),n(e[1]),h=e[2],s=e[3],i(h,s),s;default:throw new Error("invalid workload pieces length: expect 2 / 3 / 4 bug got "+e.length)}}(t[0],r):function(t,r){void 0===r&&(r="bytes");var e=t.length,h=new Array(e).fill(""),s="";t.forEach((function(t){var i=t.split("/");o(i[0],r);var u=n(i[1]),f=u[0],a=u[1];if(a!==e)throw new Error("invalid workload: "+t+", total "+a+" not equal workloads length "+e);if(s&&s!==i[2])throw new Error("invalid workload: "+t+", checksum changed "+s+", "+i[2]);if(s=i[2],h[f-1])throw new Error("invalid workload: "+t+", index "+f+" has already been set");h[f-1]=i[3]}));var u=h.join("");return i(s,u),u}(t,r)}catch(e){throw new Error("invalid workloads: "+t+"\n "+e)}}(t,r),s=e.decodeBc32Data(h);if(!s)throw new Error("invalid data");return d.decodeSimpleCBOR(s)};Bt.extractSingleWorkload=function(t){var r=t.toUpperCase().split("/");switch(r.length){case 2:case 3:return[1,1];case 4:return n(r[1]);default:throw new Error("invalid workload pieces length: expect 2 / 3 / 4 bug got "+r.length)}}}).call(this)}).call(this,n({}).Buffer);var At={};return Object.defineProperty(At,"__esModule",{value:!0}),At.extractSingleWorkload=At.decodeUR=At.encodeUR=void 0,Object.defineProperty(At,"encodeUR",{enumerable:!0,get:function(){return Et.encodeUR}}),Object.defineProperty(At,"decodeUR",{enumerable:!0,get:function(){return Bt.decodeUR}}),Object.defineProperty(At,"extractSingleWorkload",{enumerable:!0,get:function(){return Bt.extractSingleWorkload}}),At}));