@stacks/bns 7.2.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/dist/utils.js.map +1 -1
- package/package.json +6 -7
- package/LICENSE +0 -20
package/dist/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StacksBns=e():t.StacksBns=e()}(this,(()=>(()=>{var t,e,n={525:(t,e)=>{"use strict";function n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function r(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(t.outputLen),n(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){i(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=void 0,e.number=n,e.bool=r,e.bytes=i,e.hash=o,e.exists=s,e.output=a;const c={number:n,bool:r,bytes:i,hash:o,exists:s,output:a};e.default=c},350:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const r=n(525),i=n(64);class o extends i.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){r.default.exists(this);const{view:e,buffer:n,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let r=0;r<s;){const a=Math.min(o-this.pos,s-r);if(a!==o)n.set(t.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=s-r;r+=o)this.process(e,r)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){r.default.exists(this),r.default.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,o-8,BigInt(8*this.length),s),this.process(n,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)c.setUint32(4*t,h[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}e.SHA2=o},661:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto={node:void 0,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0}},53:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const r=n(350),i=n(64),o=(t,e,n)=>t&e^t&n^e&n,s=new Uint32Array([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 Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint32Array(64);class u extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)c[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=c[t-15],n=c[t-2],r=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(n,17)^(0,i.rotr)(n,19)^n>>>10;c[t]=o+c[t-7]+r+c[t-16]|0}let{A:n,B:r,C:a,D:u,E:f,F:h,G:l,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+((p=f)&h^~p&l)+s[t]+c[t]|0,y=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+o(n,r,a)|0;d=l,l=h,h=f,f=u+e|0,u=a,a=r,r=n,n=e+y|0}var p;n=n+this.A|0,r=r+this.B|0,a=a+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,r,a,u,f,h,l,d)}roundClean(){c.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class f extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new f))},64:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const r=n(661);if(e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function o(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}function s(t){if("string"==typeof t&&(t=o(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}e.bytesToHex=function(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=i[t[n]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e},e.nextTick=async()=>{},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=o,e.toBytes=s,e.concatBytes=function(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n},e.Hash=class{clone(){return this._cloneInto()}},e.checkOpts=function(t,e){if(void 0!==e&&("object"!=typeof e||(n=e,"[object Object]"!==Object.prototype.toString.call(n)||n.constructor!==Object)))throw new TypeError("Options should be object or undefined");var n;return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(s(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(s(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto.web)return r.crypto.web.getRandomValues(new Uint8Array(t));if(r.crypto.node)return new Uint8Array(r.crypto.node.randomBytes(t).buffer);throw new Error("The environment doesn't have randomBytes function")}},166:t=>{"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var f=e[t.charCodeAt(n)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h<i)&&-1!==l;l--,h++)f+=s*u[l]>>>0,u[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,n++}for(var d=o-i;d!==o&&0===u[d];)d++;for(var p=new Uint8Array(r+(o-d)),y=r;d!==o;)p[y++]=u[d++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,d=c-1;(0!==h||l<r)&&-1!==d;d--,l++)h+=256*f[d]>>>0,f[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=l,i++}for(var p=c-r;p!==c&&0===f[p];)p++;for(var y=a.repeat(n);p<c;++p)y+=t.charAt(f[p]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},98:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32ToB58=e.b58ToC32=e.c32addressDecode=e.c32address=e.versions=void 0;const r=n(392),i=n(716),o=n(64);e.versions={mainnet:{p2pkh:22,p2sh:20},testnet:{p2pkh:26,p2sh:21}};const s={};s[0]=e.versions.mainnet.p2pkh,s[5]=e.versions.mainnet.p2sh,s[111]=e.versions.testnet.p2pkh,s[196]=e.versions.testnet.p2sh;const a={};function c(t,e){if(!e.match(/^[0-9a-fA-F]{40}$/))throw new Error("Invalid argument: not a hash160 hex string");return`S${(0,r.c32checkEncode)(t,e)}`}function u(t){if(t.length<=5)throw new Error("Invalid c32 address: invalid length");if("S"!=t[0])throw new Error('Invalid c32 address: must start with "S"');return(0,r.c32checkDecode)(t.slice(1))}a[e.versions.mainnet.p2pkh]=0,a[e.versions.mainnet.p2sh]=5,a[e.versions.testnet.p2pkh]=111,a[e.versions.testnet.p2sh]=196,e.c32address=c,e.c32addressDecode=u,e.b58ToC32=function(t,e=-1){const n=i.decode(t),r=(0,o.bytesToHex)(n.data),a=parseInt((0,o.bytesToHex)(n.prefix),16);let u;return e<0?(u=a,void 0!==s[a]&&(u=s[a])):u=e,c(u,r)},e.c32ToB58=function(t,e=-1){const n=u(t),r=n[0],o=n[1];let s;e<0?(s=r,void 0!==a[r]&&(s=a[r])):s=e;let c=s.toString(16);return 1===c.length&&(c=`0${c}`),i.encode(o,c)}},716:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=void 0;const r=n(53),i=n(64),o=n(166),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";e.encode=function(t,e="00"){const n="string"==typeof t?(0,i.hexToBytes)(t):t,a="string"==typeof e?(0,i.hexToBytes)(e):t;if(!(n instanceof Uint8Array&&a instanceof Uint8Array))throw new TypeError("Argument must be of type Uint8Array or string");const c=(0,r.sha256)((0,r.sha256)(new Uint8Array([...a,...n])));return o(s).encode([...a,...n,...c.slice(0,4)])},e.decode=function(t){const e=o(s).decode(t),n=e.slice(0,1),i=e.slice(1,-4),a=(0,r.sha256)((0,r.sha256)(new Uint8Array([...n,...i])));return e.slice(-4).forEach(((t,e)=>{if(t!==a[e])throw new Error("Invalid checksum")})),{prefix:n,data:i}}},392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32checkDecode=e.c32checkEncode=void 0;const r=n(53),i=n(64),o=n(103);function s(t){const e=(0,r.sha256)((0,r.sha256)((0,i.hexToBytes)(t)));return(0,i.bytesToHex)(e.slice(0,4))}e.c32checkEncode=function(t,e){if(t<0||t>=32)throw new Error("Invalid version (must be between 0 and 31)");if(!e.match(/^[0-9a-fA-F]*$/))throw new Error("Invalid data (not a hex string)");(e=e.toLowerCase()).length%2!=0&&(e=`0${e}`);let n=t.toString(16);1===n.length&&(n=`0${n}`);const r=s(`${n}${e}`),i=(0,o.c32encode)(`${e}${r}`);return`${o.c32[t]}${i}`},e.c32checkDecode=function(t){t=(0,o.c32normalize)(t);const e=(0,o.c32decode)(t.slice(1)),n=t[0],r=o.c32.indexOf(n),i=e.slice(-8);let a=r.toString(16);if(1===a.length&&(a=`0${a}`),s(`${a}${e.substring(0,e.length-8)}`)!==i)throw new Error("Invalid c32check string: checksum mismatch");return[r,e.substring(0,e.length-8)]}},103:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32decode=e.c32normalize=e.c32encode=e.c32=void 0;const r=n(64);e.c32="0123456789ABCDEFGHJKMNPQRSTVWXYZ";const i="0123456789abcdef";function o(t){return t.toUpperCase().replace(/O/g,"0").replace(/L|I/g,"1")}e.c32encode=function(t,n){if(!t.match(/^[0-9a-fA-F]*$/))throw new Error("Not a hex-encoded string");t.length%2!=0&&(t=`0${t}`);let o=[],s=0;for(let n=(t=t.toLowerCase()).length-1;n>=0;n--)if(s<4){const r=i.indexOf(t[n])>>s;let a=0;0!==n&&(a=i.indexOf(t[n-1]));const c=1+s,u=a%(1<<c)<<5-c,f=e.c32[r+u];s=c,o.unshift(f)}else s=0;let a=0;for(let t=0;t<o.length&&"0"===o[t];t++)a++;o=o.slice(a);const c=(new TextDecoder).decode((0,r.hexToBytes)(t)).match(/^\u0000*/),u=c?c[0].length:0;for(let t=0;t<u;t++)o.unshift(e.c32[0]);if(n){const t=n-o.length;for(let n=0;n<t;n++)o.unshift(e.c32[0])}return o.join("")},e.c32normalize=o,e.c32decode=function(t,n){if(!(t=o(t)).match(`^[${e.c32}]*$`))throw new Error("Not a c32-encoded string");const r=t.match(`^${e.c32[0]}*`),s=r?r[0].length:0;let a=[],c=0,u=0;for(let n=t.length-1;n>=0;n--){4===u&&(a.unshift(i[c]),u=0,c=0);const r=(e.c32.indexOf(t[n])<<u)+c,o=i[r%16];if(u+=1,c=r>>4,c>1<<u)throw new Error("Panic error in decoding.");a.unshift(o)}a.unshift(i[c]),a.length%2==1&&a.unshift("0");let f=0;for(let t=0;t<a.length&&"0"===a[t];t++)f++;a=a.slice(f-f%2);let h=a.join("");for(let t=0;t<s;t++)h=`00${h}`;if(n){const t=2*n-h.length;for(let e=0;e<t;e+=2)h=`00${h}`}return h}},870:(t,e,n)=>{"use strict";e.yI=e.H4=void 0;n(103),n(392);const r=n(98);Object.defineProperty(e,"H4",{enumerable:!0,get:function(){return r.c32address}}),Object.defineProperty(e,"yI",{enumerable:!0,get:function(){return r.c32addressDecode}})},907:(t,e,n)=>{t=n.nmd(t);var r="__lodash_hash_undefined__",i=9007199254740991,o="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",h="[object Number]",l="[object Object]",d="[object Promise]",p="[object RegExp]",y="[object Set]",g="[object String]",b="[object Symbol]",w="[object WeakMap]",m="[object ArrayBuffer]",v="[object DataView]",A="[object Float32Array]",x="[object Float64Array]",S="[object Int8Array]",E="[object Int16Array]",C="[object Int32Array]",B="[object Uint8Array]",T="[object Uint8ClampedArray]",I="[object Uint16Array]",U="[object Uint32Array]",k=/\w*$/,P=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,$={};$[o]=$["[object Array]"]=$[m]=$[v]=$[s]=$[a]=$[A]=$[x]=$[S]=$[E]=$[C]=$[f]=$[h]=$[l]=$[p]=$[y]=$[g]=$[b]=$[B]=$[T]=$[I]=$[U]=!0,$["[object Error]"]=$[c]=$[w]=!1;var O="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,H="object"==typeof self&&self&&self.Object===Object&&self,_=O||H||Function("return this")(),L=e&&!e.nodeType&&e,j=L&&t&&!t.nodeType&&t,M=j&&j.exports===L;function F(t,e){return t.set(e[0],e[1]),t}function R(t,e){return t.add(e),t}function D(t,e,n,r){var i=-1,o=t?t.length:0;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function K(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function V(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function z(t,e){return function(n){return t(e(n))}}function q(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var W,G=Array.prototype,Z=Function.prototype,X=Object.prototype,J=_["__core-js_shared__"],Q=(W=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+W:"",Y=Z.toString,tt=X.hasOwnProperty,et=X.toString,nt=RegExp("^"+Y.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=M?_.Buffer:void 0,it=_.Symbol,ot=_.Uint8Array,st=z(Object.getPrototypeOf,Object),at=Object.create,ct=X.propertyIsEnumerable,ut=G.splice,ft=Object.getOwnPropertySymbols,ht=rt?rt.isBuffer:void 0,lt=z(Object.keys,Object),dt=_t(_,"DataView"),pt=_t(_,"Map"),yt=_t(_,"Promise"),gt=_t(_,"Set"),bt=_t(_,"WeakMap"),wt=_t(Object,"create"),mt=Rt(dt),vt=Rt(pt),At=Rt(yt),xt=Rt(gt),St=Rt(bt),Et=it?it.prototype:void 0,Ct=Et?Et.valueOf:void 0;function Bt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function It(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Ut(t){this.__data__=new Tt(t)}function kt(t,e,n){var r=t[e];tt.call(t,e)&&Dt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function Pt(t,e){for(var n=t.length;n--;)if(Dt(t[n][0],e))return n;return-1}function Nt(t,e,n,r,i,d,w){var P;if(r&&(P=d?r(t,i,d,w):r(t)),void 0!==P)return P;if(!Wt(t))return t;var N=Kt(t);if(N){if(P=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,P)}else{var O=jt(t),H=O==c||O==u;if(zt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(O==l||O==o||H&&!d){if(K(t))return d?t:{};if(P=function(t){return"function"!=typeof t.constructor||Ft(t)?{}:Wt(e=st(t))?at(e):{};var e}(H?{}:t),!e)return function(t,e){return Ot(t,Lt(t),e)}(t,function(t,e){return t&&Ot(e,Gt(e),t)}(P,t))}else{if(!$[O])return d?t:{};P=function(t,e,n,r){var i,o=t.constructor;switch(e){case m:return $t(t);case s:case a:return new o(+t);case v:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case A:case x:case S:case E:case C:case B:case T:case I:case U:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return D(e?n(V(t),!0):V(t),F,new t.constructor)}(t,r,n);case h:case g:return new o(t);case p:return function(t){var e=new t.constructor(t.source,k.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,n){return D(e?n(q(t),!0):q(t),R,new t.constructor)}(t,r,n);case b:return i=t,Ct?Object(Ct.call(i)):{}}}(t,O,Nt,e)}}w||(w=new Ut);var _=w.get(t);if(_)return _;if(w.set(t,P),!N)var L=n?function(t){return function(t,e,n){var r=e(t);return Kt(t)?r:function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}(r,n(t))}(t,Gt,Lt)}(t):Gt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(L||t,(function(i,o){L&&(i=t[o=i]),kt(P,o,Nt(i,e,n,r,o,t,w))})),P}function $t(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Ot(t,e,n,r){n||(n={});for(var i=-1,o=e.length;++i<o;){var s=e[i],a=r?r(n[s],t[s],s,n,t):void 0;kt(n,s,void 0===a?t[s]:a)}return n}function Ht(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function _t(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!Wt(t)||(e=t,Q&&Q in e))&&(qt(t)||K(t)?nt:P).test(Rt(t));var e}(n)?n:void 0}Bt.prototype.clear=function(){this.__data__=wt?wt(null):{}},Bt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Bt.prototype.get=function(t){var e=this.__data__;if(wt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},Bt.prototype.has=function(t){var e=this.__data__;return wt?void 0!==e[t]:tt.call(e,t)},Bt.prototype.set=function(t,e){return this.__data__[t]=wt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=Pt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=Pt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return Pt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=Pt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},It.prototype.clear=function(){this.__data__={hash:new Bt,map:new(pt||Tt),string:new Bt}},It.prototype.delete=function(t){return Ht(this,t).delete(t)},It.prototype.get=function(t){return Ht(this,t).get(t)},It.prototype.has=function(t){return Ht(this,t).has(t)},It.prototype.set=function(t,e){return Ht(this,t).set(t,e),this},Ut.prototype.clear=function(){this.__data__=new Tt},Ut.prototype.delete=function(t){return this.__data__.delete(t)},Ut.prototype.get=function(t){return this.__data__.get(t)},Ut.prototype.has=function(t){return this.__data__.has(t)},Ut.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!pt||r.length<199)return r.push([t,e]),this;n=this.__data__=new It(r)}return n.set(t,e),this};var Lt=ft?z(ft,Object):function(){return[]},jt=function(t){return et.call(t)};function Mt(t,e){return!!(e=null==e?i:e)&&("number"==typeof t||N.test(t))&&t>-1&&t%1==0&&t<e}function Ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||X)}function Rt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Dt(t,e){return t===e||t!=t&&e!=e}(dt&&jt(new dt(new ArrayBuffer(1)))!=v||pt&&jt(new pt)!=f||yt&&jt(yt.resolve())!=d||gt&&jt(new gt)!=y||bt&&jt(new bt)!=w)&&(jt=function(t){var e=et.call(t),n=e==l?t.constructor:void 0,r=n?Rt(n):void 0;if(r)switch(r){case mt:return v;case vt:return f;case At:return d;case xt:return y;case St:return w}return e});var Kt=Array.isArray;function Vt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}(t.length)&&!qt(t)}var zt=ht||function(){return!1};function qt(t){var e=Wt(t)?et.call(t):"";return e==c||e==u}function Wt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Gt(t){return Vt(t)?function(t,e){var n=Kt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Vt(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==o)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,i=!!r;for(var s in t)!e&&!tt.call(t,s)||i&&("length"==s||Mt(s,r))||n.push(s);return n}(t):function(t){if(!Ft(t))return lt(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Nt(t,!0,!0)}},314:()=>{}},r={};function i(t){var e=r[t];if(void 0!==e)return e.exports;var o=r[t]={id:t,loaded:!1,exports:{}};return n[t](o,o.exports,i),o.loaded=!0,o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var o=Object.create(null);i.r(o);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((t=>s[t]=()=>n[t]));return s.default=()=>n,i.d(o,s),o},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var o={};return(()=>{"use strict";function t(t,n){return a(e(t),n)}function e(t){if("bigint"==typeof t)return t;if("string"==typeof t)return BigInt(t);if("number"==typeof t){if(!Number.isInteger(t))throw new RangeError("Invalid value. Values of type 'number' must be an integer.");if(t>Number.MAX_SAFE_INTEGER)throw new RangeError(`Invalid value. Values of type 'number' must be less than or equal to ${Number.MAX_SAFE_INTEGER}. For larger values, try using a BigInt instead.`);return BigInt(t)}if(v(t,Uint8Array))return BigInt(`0x${f(t)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function n(t){if("string"!=typeof t)throw new TypeError("hexToBigInt: expected string, got "+typeof t);return BigInt(`0x${t}`)}function r(t,n=8){return("bigint"==typeof t?t:e(t)).toString(16).padStart(2*n,"0")}function s(t){return parseInt(t,16)}function a(t,e=16){return h(r(t,e))}function c(t){return e=BigInt(`0x${f(t)}`),n=BigInt(8*t.byteLength),function(t,e){return t&BigInt(1)<<e}(e,n-BigInt(1))?e-(BigInt(1)<<n):e;var e,n}i.r(o),i.d(o,{BNS_CONTRACT_NAME:()=>Di,buildImportNameTx:()=>Xi,buildPreorderNameTx:()=>Qi,buildPreorderNamespaceTx:()=>Gi,buildReadyNamespaceTx:()=>Ji,buildRegisterNameTx:()=>Yi,buildRenewNameTx:()=>ro,buildRevealNamespaceTx:()=>Zi,buildRevokeNameTx:()=>no,buildTransferNameTx:()=>eo,buildUpdateNameTx:()=>to,canRegisterName:()=>zi,getNamePrice:()=>Wi,getNamespacePrice:()=>qi});const u=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function f(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(const n of t)e+=u[n];return e}function h(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);var e;t=(e=t,t=/^0x/i.test(e)?e.slice(2):e).length%2?`0${t}`:t;const n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++){const r=2*e,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[e]=o}return n}function l(t){return(new TextEncoder).encode(t)}function d(t){return(new TextDecoder).decode(t)}function p(t){const e=[];for(let n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return new Uint8Array(e)}function y(t){return String.fromCharCode.apply(null,t)}function g(t){return!Number.isInteger(t)||t<0||t>255}function b(t){if(t.some(g))throw new Error("Some values are invalid bytes.");return new Uint8Array(t)}function w(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}function m(t){return w(...t.map((t=>"number"==typeof t?b([t]):t instanceof Array?b(t):t)))}function v(t,e){return t instanceof e||t?.constructor?.name?.toLowerCase()===e.name}const A=33,x={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}};async function S(t,e){const n={};return Object.assign(n,x,e),await fetch(t,n)}function E(...t){const{fetchLib:e,middlewares:n}=function(t){let e=S,n=[];return t.length>0&&"function"==typeof t[0]&&(e=t.shift()),t.length>0&&(n=t),{fetchLib:e,middlewares:n}}(t);return async(t,r)=>{let i={url:t,init:r??{}};for(const t of n)"function"==typeof t.pre&&(i=await Promise.resolve(t.pre({fetch:e,...i}))??i);let o=await e(i.url,i.init);for(const t of n)if("function"==typeof t.post){const n=await Promise.resolve(t.post({fetch:e,url:i.url,init:i.init,response:o?.clone()??o}));o=n??o}return o}}var C,B,T,I,U;!function(t){t[t.Mainnet=1]="Mainnet",t[t.Testnet=2147483648]="Testnet"}(C||(C={})),function(t){t[t.Mainnet=385875968]="Mainnet",t[t.Testnet=4278190080]="Testnet"}(B||(B={})),C.Mainnet,(U=T||(T={}))[U.Mainnet=0]="Mainnet",U[U.Testnet=128]="Testnet",function(t){t[t.MainnetSingleSig=22]="MainnetSingleSig",t[t.MainnetMultiSig=20]="MainnetMultiSig",t[t.TestnetSingleSig=26]="TestnetSingleSig",t[t.TestnetMultiSig=21]="TestnetMultiSig"}(I||(I={})),T.Mainnet;const k={chainId:C.Mainnet,transactionVersion:T.Mainnet,peerNetworkId:B.Mainnet,magicBytes:"X2",bootAddress:"SP000000000000000000002Q6VF78",addressVersion:{singleSig:I.MainnetSingleSig,multiSig:I.MainnetMultiSig},client:{baseUrl:"https://api.mainnet.hiro.so"}},P={chainId:C.Testnet,transactionVersion:T.Testnet,peerNetworkId:B.Testnet,magicBytes:"T2",bootAddress:"ST000000000000000000002AMW42H",addressVersion:{singleSig:I.TestnetSingleSig,multiSig:I.TestnetMultiSig},client:{baseUrl:"https://api.testnet.hiro.so"}},N={...P,addressVersion:{...P.addressVersion},magicBytes:"id",client:{baseUrl:"http://localhost:3999"}},$={...N,addressVersion:{...N.addressVersion},client:{...N.client}};function O(t){return"string"==typeof t?function(t){switch(t){case"mainnet":return k;case"testnet":return P;case"devnet":return N;case"mocknet":return $;default:throw new Error(`Unknown network name: ${t}`)}}(t):t}function H(t){return t.client.fetch?t.client:{...t.client,fetch:E()}}var _=i(870);function L(t,e,n=0){return t[n+3]=e,e>>>=8,t[n+2]=e,e>>>=8,t[n+1]=e,e>>>=8,t[n]=e,t}const j=128,M=128,F=16,R=65,D=34;var K,V,z,q,W,G;(G=K||(K={}))[G.TokenTransfer=0]="TokenTransfer",G[G.SmartContract=1]="SmartContract",G[G.VersionedSmartContract=6]="VersionedSmartContract",G[G.ContractCall=2]="ContractCall",G[G.PoisonMicroblock=3]="PoisonMicroblock",G[G.Coinbase=4]="Coinbase",G[G.CoinbaseToAltRecipient=5]="CoinbaseToAltRecipient",G[G.TenureChange=7]="TenureChange",G[G.NakamotoCoinbase=8]="NakamotoCoinbase",(W=V||(V={}))[W.Clarity1=1]="Clarity1",W[W.Clarity2=2]="Clarity2",W[W.Clarity3=3]="Clarity3",(q=z||(z={}))[q.OnChainOnly=1]="OnChainOnly",q[q.OffChainOnly=2]="OffChainOnly",q[q.Any=3]="Any";var Z,X,J,Q,Y,tt,et,nt,rt,it,ot,st,at,ct,ut,ft,ht,lt,dt,pt;z.OnChainOnly,z.OffChainOnly,z.Any,z.OnChainOnly,z.OnChainOnly,z.OffChainOnly,z.OffChainOnly,z.Any,z.Any,(pt=Z||(Z={}))[pt.Allow=1]="Allow",pt[pt.Deny=2]="Deny",(dt=X||(X={}))[dt.STX=0]="STX",dt[dt.Fungible=1]="Fungible",dt[dt.NonFungible=2]="NonFungible",(lt=J||(J={}))[lt.Standard=4]="Standard",lt[lt.Sponsored=5]="Sponsored",(ht=Q||(Q={}))[ht.P2PKH=0]="P2PKH",ht[ht.P2SH=1]="P2SH",ht[ht.P2WPKH=2]="P2WPKH",ht[ht.P2WSH=3]="P2WSH",ht[ht.P2SHNonSequential=5]="P2SHNonSequential",ht[ht.P2WSHNonSequential=7]="P2WSHNonSequential",(ft=Y||(Y={}))[ft.Compressed=0]="Compressed",ft[ft.Uncompressed=1]="Uncompressed",function(t){t[t.Equal=1]="Equal",t[t.Greater=2]="Greater",t[t.GreaterEqual=3]="GreaterEqual",t[t.Less=4]="Less",t[t.LessEqual=5]="LessEqual"}(tt||(tt={})),function(t){t[t.Sends=16]="Sends",t[t.DoesNotSend=17]="DoesNotSend"}(et||(et={})),(ut=nt||(nt={}))[ut.Origin=1]="Origin",ut[ut.Standard=2]="Standard",ut[ut.Contract=3]="Contract",function(t){t[t.STX=0]="STX",t[t.Fungible=1]="Fungible",t[t.NonFungible=2]="NonFungible"}(rt||(rt={})),(ct=it||(it={}))[ct.BlockFound=0]="BlockFound",ct[ct.Extended=1]="Extended",(at=ot||(ot={}))[at.PublicKeyCompressed=0]="PublicKeyCompressed",at[at.PublicKeyUncompressed=1]="PublicKeyUncompressed",at[at.SignatureCompressed=2]="SignatureCompressed",at[at.SignatureUncompressed=3]="SignatureUncompressed",function(t){t.Serialization="Serialization",t.Deserialization="Deserialization",t.SignatureValidation="SignatureValidation",t.FeeTooLow="FeeTooLow",t.BadNonce="BadNonce",t.NotEnoughFunds="NotEnoughFunds",t.NoSuchContract="NoSuchContract",t.NoSuchPublicFunction="NoSuchPublicFunction",t.BadFunctionArgument="BadFunctionArgument",t.ContractAlreadyExists="ContractAlreadyExists",t.PoisonMicroblocksDoNotConflict="PoisonMicroblocksDoNotConflict",t.PoisonMicroblockHasUnknownPubKeyHash="PoisonMicroblockHasUnknownPubKeyHash",t.PoisonMicroblockIsInvalid="PoisonMicroblockIsInvalid",t.BadAddressVersionByte="BadAddressVersionByte",t.NoCoinbaseViaMempool="NoCoinbaseViaMempool",t.ServerFailureNoSuchChainTip="ServerFailureNoSuchChainTip",t.ServerFailureDatabase="ServerFailureDatabase",t.ServerFailureOther="ServerFailureOther"}(st||(st={}));class yt extends Error{constructor(t){super(t),this.message=t,this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class gt extends yt{constructor(t){super(t)}}class bt extends yt{constructor(t){super(t)}}class wt extends yt{constructor(t){super(t)}}class mt extends yt{constructor(t){super(t)}}class vt extends yt{constructor(t){super(t)}}function At(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function xt(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}const St={number:At,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:xt,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");At(t.outputLen),At(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){xt(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},Et=("object"==typeof self&&"crypto"in self&&self.crypto,t=>new DataView(t.buffer,t.byteOffset,t.byteLength)),Ct=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Bt(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));class Tt{clone(){return this._cloneInto()}}function It(t){const e=e=>t().update(Bt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}class Ut extends Tt{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,St.hash(t);const n=Bt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return St.exists(this),this.iHash.update(t),this}digestInto(t){St.exists(this),St.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kt=(t,e,n)=>new Ut(t,e).update(n).digest();kt.create=(t,e)=>new Ut(t,e);class Pt extends Tt{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Et(this.buffer)}update(t){St.exists(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Bt(t)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=Et(t);for(;r<=i-o;o+=r)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){St.exists(this),St.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Et(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}const Nt=(t,e,n)=>t&e^t&n^e&n,$t=new Uint32Array([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]),Ot=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64);class _t extends Pt{constructor(){super(64,32,8,!1),this.A=0|Ot[0],this.B=0|Ot[1],this.C=0|Ot[2],this.D=0|Ot[3],this.E=0|Ot[4],this.F=0|Ot[5],this.G=0|Ot[6],this.H=0|Ot[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)Ht[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Ht[t-15],n=Ht[t-2],r=Ct(e,7)^Ct(e,18)^e>>>3,i=Ct(n,17)^Ct(n,19)^n>>>10;Ht[t]=i+Ht[t-7]+r+Ht[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(Ct(s,6)^Ct(s,11)^Ct(s,25))+((f=s)&a^~f&c)+$t[t]+Ht[t]|0,h=(Ct(n,2)^Ct(n,13)^Ct(n,22))+Nt(n,r,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+h|0}var f;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,i,o,s,a,c,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Lt extends _t{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const jt=It((()=>new _t));It((()=>new Lt));var Mt=i(314),Ft=i.t(Mt,2);const Rt=BigInt(0),Dt=BigInt(1),Kt=BigInt(2),Vt=BigInt(3),zt=BigInt(8),qt=Object.freeze({a:Rt,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Dt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Wt=(t,e)=>(t+e/Kt)/e,Gt={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=qt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Dt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Wt(o*t,e),c=Wt(-r*t,e);let u=xe(t-a*n-c*i,e),f=xe(-a*r-c*o,e);const h=u>s,l=f>s;if(h&&(u=e-u),l&&(f=e-f),u>s||f>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:h,k1:u,k2neg:l,k2:f}}},Zt=32,Xt=32,Jt=Zt+1,Qt=2*Zt+1;function Yt(t){const{a:e,b:n}=qt,r=xe(t*t),i=xe(r*t);return xe(i+e*t+n)}const te=qt.a===Rt;class ee extends Error{constructor(t){super(t)}}function ne(t){if(!(t instanceof re))throw new TypeError("JacobianPoint expected")}class re{constructor(t,e,n){this.x=t,this.y=e,this.z=n}static fromAffine(t){if(!(t instanceof se))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(se.ZERO)?re.ZERO:new re(t.x,t.y,Dt)}static toAffineBatch(t){const e=function(t,e=qt.P){const n=new Array(t.length),r=Ee(t.reduce(((t,r,i)=>r===Rt?t:(n[i]=t,xe(t*r,e))),Dt),e);return t.reduceRight(((t,r,i)=>r===Rt?t:(n[i]=xe(t*n[i],e),xe(t*r,e))),r),n}(t.map((t=>t.z)));return t.map(((t,n)=>t.toAffine(e[n])))}static normalizeZ(t){return re.toAffineBatch(t).map(re.fromAffine)}equals(t){ne(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t,a=xe(r*r),c=xe(s*s),u=xe(e*c),f=xe(i*a),h=xe(xe(n*s)*c),l=xe(xe(o*r)*a);return u===f&&h===l}negate(){return new re(this.x,xe(-this.y),this.z)}double(){const{x:t,y:e,z:n}=this,r=xe(t*t),i=xe(e*e),o=xe(i*i),s=t+i,a=xe(Kt*(xe(s*s)-r-o)),c=xe(Vt*r),u=xe(c*c),f=xe(u-Kt*a),h=xe(c*(a-f)-zt*o),l=xe(Kt*e*n);return new re(f,h,l)}add(t){ne(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t;if(i===Rt||o===Rt)return this;if(e===Rt||n===Rt)return t;const a=xe(r*r),c=xe(s*s),u=xe(e*c),f=xe(i*a),h=xe(xe(n*s)*c),l=xe(xe(o*r)*a),d=xe(f-u),p=xe(l-h);if(d===Rt)return p===Rt?this.double():re.ZERO;const y=xe(d*d),g=xe(d*y),b=xe(u*y),w=xe(p*p-g-Kt*b),m=xe(p*(b-w)-h*g),v=xe(r*s*d);return new re(w,m,v)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=re.ZERO;if("bigint"==typeof t&&t===Rt)return e;let n=Ae(t);if(n===Dt)return this;if(!te){let t=e,r=this;for(;n>Rt;)n&Dt&&(t=t.add(r)),r=r.double(),n>>=Dt;return t}let{k1neg:r,k1:i,k2neg:o,k2:s}=Gt.splitScalar(n),a=e,c=e,u=this;for(;i>Rt||s>Rt;)i&Dt&&(a=a.add(u)),s&Dt&&(c=c.add(u)),u=u.double(),i>>=Dt,s>>=Dt;return r&&(a=a.negate()),o&&(c=c.negate()),c=new re(xe(c.x*Gt.beta),c.y,c.z),a.add(c)}precomputeWindow(t){const e=te?128/t+1:256/t+1,n=[];let r=this,i=r;for(let o=0;o<e;o++){i=r,n.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(r),n.push(i);r=i.double()}return n}wNAF(t,e){!e&&this.equals(re.BASE)&&(e=se.BASE);const n=e&&e._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let r=e&&oe.get(e);r||(r=this.precomputeWindow(n),e&&1!==n&&(r=re.normalizeZ(r),oe.set(e,r)));let i=re.ZERO,o=re.BASE;const s=1+(te?128/n:256/n),a=2**(n-1),c=BigInt(2**n-1),u=2**n,f=BigInt(n);for(let e=0;e<s;e++){const n=e*a;let s=Number(t&c);t>>=f,s>a&&(s-=u,t+=Dt);const h=n,l=n+Math.abs(s)-1,d=e%2!=0,p=s<0;0===s?o=o.add(ie(d,r[h])):i=i.add(ie(p,r[l]))}return{p:i,f:o}}multiply(t,e){let n,r,i=Ae(t);if(te){const{k1neg:t,k1:o,k2neg:s,k2:a}=Gt.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:h}=this.wNAF(a,e);c=ie(t,c),f=ie(s,f),f=new re(xe(f.x*Gt.beta),f.y,f.z),n=c.add(f),r=u.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);n=t,r=o}return re.normalizeZ([n,r])[0]}toAffine(t){const{x:e,y:n,z:r}=this,i=this.equals(re.ZERO);null==t&&(t=i?zt:Ee(r));const o=t,s=xe(o*o),a=xe(s*o),c=xe(e*s),u=xe(n*a),f=xe(r*o);if(i)return se.ZERO;if(f!==Dt)throw new Error("invZ was invalid");return new se(c,u)}}function ie(t,e){const n=e.negate();return t?n:e}re.BASE=new re(qt.Gx,qt.Gy,Dt),re.ZERO=new re(Rt,Dt,Rt);const oe=new WeakMap;class se{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,oe.delete(this)}hasEvenY(){return this.y%Kt===Rt}static fromCompressedHex(t){const e=32===t.length,n=me(e?t:t.subarray(1));if(!ke(n))throw new Error("Point is not on curve");let r=function(t){const{P:e}=qt,n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,f=Se(u,Vt)*u%e,h=Se(f,Vt)*u%e,l=Se(h,Kt)*c%e,d=Se(l,r)*l%e,p=Se(d,i)*d%e,y=Se(p,s)*p%e,g=Se(y,a)*y%e,b=Se(g,s)*p%e,w=Se(b,Vt)*u%e,m=Se(w,o)*d%e,v=Se(m,n)*c%e,A=Se(v,Kt);if(A*A%e!==t)throw new Error("Cannot find square root");return A}(Yt(n));const i=(r&Dt)===Dt;e?i&&(r=xe(-r)):1==(1&t[0])!==i&&(r=xe(-r));const o=new se(n,r);return o.assertValidity(),o}static fromUncompressedHex(t){const e=me(t.subarray(1,Zt+1)),n=me(t.subarray(Zt+1,2*Zt+1)),r=new se(e,n);return r.assertValidity(),r}static fromHex(t){const e=ve(t),n=e.length,r=e[0];if(n===Zt)return this.fromCompressedHex(e);if(n===Jt&&(2===r||3===r))return this.fromCompressedHex(e);if(n===Qt&&4===r)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${Jt} compressed bytes or ${Qt} uncompressed bytes, not ${n}`)}static fromPrivateKey(t){return se.BASE.multiply(Ne(t))}static fromSignature(t,e,n){const{r,s:i}=function(t){if(t instanceof ue)return t.assertValidity(),t;try{return ue.fromDER(t)}catch(e){return ue.fromCompact(t)}}(e);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const o=Ce(ve(t)),{n:s}=qt,a=2===n||3===n?r+s:r,c=Ee(a,s),u=xe(-o*c,s),f=xe(i*c,s),h=1&n?"03":"02",l=se.fromHex(h+pe(a)),d=se.BASE.multiplyAndAddUnsafe(l,u,f);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return we(this.toHex(t))}toHex(t=!1){const e=pe(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${pe(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:n}=this;if(!ke(e)||!ke(n))throw new Error(t);const r=xe(n*n);if(xe(r-Yt(e))!==Rt)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new se(this.x,xe(-this.y))}double(){return re.fromAffine(this).double().toAffine()}add(t){return re.fromAffine(this).add(re.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return re.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,n){const r=re.fromAffine(this),i=e===Rt||e===Dt||this!==se.BASE?r.multiplyUnsafe(e):r.multiply(e),o=re.fromAffine(t).multiplyUnsafe(n),s=i.add(o);return s.equals(re.ZERO)?void 0:s.toAffine()}}function ae(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function ce(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${le(t)}`);const e=t[1],n=t.subarray(2,e+2);if(!e||n.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:me(n),left:t.subarray(e+2)}}se.BASE=new se(qt.Gx,qt.Gy),se.ZERO=new se(Rt,Rt);class ue{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,n="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=e?le(t):t;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new ue(be(r.slice(0,64)),be(r.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${le(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:n}=ce(t.subarray(2)),{data:r,left:i}=ce(n);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${le(i)}`);return{r:e,s:r}}(e?t:we(t));return new ue(n,r)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!Ue(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ue(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=qt.n>>Dt;return this.s>t}normalizeS(){return this.hasHighS()?new ue(this.r,xe(-this.s,qt.n)):this}toDERRawBytes(){return we(this.toDERHex())}toDERHex(){const t=ae(ge(this.s)),e=ae(ge(this.r)),n=t.length/2,r=e.length/2,i=ge(n),o=ge(r);return`30${ge(r+n+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return we(this.toCompactHex())}toCompactHex(){return pe(this.r)+pe(this.s)}}function fe(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}const he=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function le(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let n=0;n<t.length;n++)e+=he[t[n]];return e}const de=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function pe(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(Rt<=t&&t<de))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function ye(t){const e=we(pe(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function ge(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function be(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function we(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e}function me(t){return be(le(t))}function ve(t){return t instanceof Uint8Array?Uint8Array.from(t):we(t)}function Ae(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&Ue(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function xe(t,e=qt.P){const n=t%e;return n>=Rt?n:e+n}function Se(t,e){const{P:n}=qt;let r=t;for(;e-- >Rt;)r*=r,r%=n;return r}function Ee(t,e=qt.P){if(t===Rt||e<=Rt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=xe(t,e),r=e,i=Rt,o=Dt,s=Dt,a=Rt;for(;n!==Rt;){const t=r/n,e=r%n,c=i-s*t,u=o-a*t;r=n,n=e,i=s,o=a,s=c,a=u}if(r!==Dt)throw new Error("invert: does not exist");return xe(i,e)}function Ce(t,e=!1){const n=function(t){const e=8*t.length-8*Xt,n=me(t);return e>0?n>>BigInt(e):n}(t);if(e)return n;const{n:r}=qt;return n>=r?n-r:n}let Be,Te;class Ie{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,"number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return je.hmacSha256(this.k,...t)}hmacSync(...t){return Te(this.k,...t)}checkSync(){if("function"!=typeof Te)throw new ee("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=await this.hmac(this.v);const n=this.v.slice();e.push(n),t+=this.v.length}return fe(...e)}generateSync(){this.checkSync(),this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=this.hmacSync(this.v);const n=this.v.slice();e.push(n),t+=this.v.length}return fe(...e)}}function Ue(t){return Rt<t&&t<qt.n}function ke(t){return Rt<t&&t<qt.P}function Pe(t,e,n,r=!0){const{n:i}=qt,o=Ce(t,!0);if(!Ue(o))return;const s=Ee(o,i),a=se.BASE.multiply(o),c=xe(a.x,i);if(c===Rt)return;const u=xe(s*xe(e+n*c,i),i);if(u===Rt)return;let f=new ue(c,u),h=(a.x===f.r?0:2)|Number(a.y&Dt);return r&&f.hasHighS()&&(f=f.normalizeS(),h^=1),{sig:f,recovery:h}}function Ne(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if("string"==typeof t){if(t.length!==2*Xt)throw new Error("Expected 32 bytes of private key");e=be(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(t.length!==Xt)throw new Error("Expected 32 bytes of private key");e=me(t)}if(!Ue(e))throw new Error("Expected private key: 0 < key < n");return e}function $e(t){return me(t.length>Zt?t.slice(0,Zt):t)}function Oe(t){const e=$e(t),n=xe(e,qt.n);return He(n<Rt?e:n)}function He(t){return ye(t)}se.BASE._setWindowSize(8);const _e={node:Ft,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},Le={},je={bytesToHex:le,hexToBytes:we,concatBytes:fe,mod:xe,invert:Ee,isValidPrivateKey(t){try{return Ne(t),!0}catch(t){return!1}},_bigintTo32Bytes:ye,_normalizePrivateKey:Ne,hashToPrivateKey:t=>{t=ve(t);const e=Xt+8;if(t.length<e||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return ye(xe(me(t),qt.n-Dt)+Dt)},randomBytes:(t=32)=>{if(_e.web)return _e.web.getRandomValues(new Uint8Array(t));if(_e.node){const{randomBytes:e}=_e.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>je.hashToPrivateKey(je.randomBytes(Xt+8)),precompute(t=8,e=se.BASE){const n=e===se.BASE?e:new se(e.x,e.y);return n._setWindowSize(t),n.multiply(Vt),n},sha256:async(...t)=>{if(_e.web){const e=await _e.web.subtle.digest("SHA-256",fe(...t));return new Uint8Array(e)}if(_e.node){const{createHash:e}=_e.node,n=e("sha256");return t.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(_e.web){const n=await _e.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),r=fe(...e),i=await _e.web.subtle.sign("HMAC",n,r);return new Uint8Array(i)}if(_e.node){const{createHmac:n}=_e.node,r=n("sha256",t);return e.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...e)=>{let n=Le[t];if(void 0===n){const e=await je.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=fe(e,e),Le[t]=n}return je.sha256(n,...e)},taggedHashSync:(t,...e)=>{if("function"!=typeof Be)throw new ee("sha256Sync is undefined, you need to set it");let n=Le[t];if(void 0===n){const e=Be(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=fe(e,e),Le[t]=n}return Be(n,...e)},_JacobianPoint:re};Object.defineProperties(je,{sha256Sync:{configurable:!1,get:()=>Be,set(t){Be||(Be=t)}},hmacSha256Sync:{configurable:!1,get:()=>Te,set(t){Te||(Te=t)}}});const Me=32;function Fe(t){const e="string"==typeof t?h(t):t;if(32!=e.length&&33!=e.length)throw new Error(`Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${e.length}`);if(33==e.length&&1!==e[32])throw new Error("Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01");return e}const Re=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),De=Uint8Array.from({length:16},((t,e)=>e)),Ke=De.map((t=>(9*t+5)%16));let Ve=[De],ze=[Ke];for(let t=0;t<4;t++)for(let e of[Ve,ze])e.push(e[t].map((t=>Re[t])));const qe=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),We=Ve.map(((t,e)=>t.map((t=>qe[e][t])))),Ge=ze.map(((t,e)=>t.map((t=>qe[e][t])))),Ze=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Xe=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),Je=(t,e)=>t<<e|t>>>32-e;function Qe(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const Ye=new Uint32Array(16);class tn extends Pt{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:n,h3:r,h4:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.h0=0|t,this.h1=0|e,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)Ye[n]=t.getUint32(e,!0);let n=0|this.h0,r=n,i=0|this.h1,o=i,s=0|this.h2,a=s,c=0|this.h3,u=c,f=0|this.h4,h=f;for(let t=0;t<5;t++){const e=4-t,l=Ze[t],d=Xe[t],p=Ve[t],y=ze[t],g=We[t],b=Ge[t];for(let e=0;e<16;e++){const r=Je(n+Qe(t,i,s,c)+Ye[p[e]]+l,g[e])+f|0;n=f,f=c,c=0|Je(s,10),s=i,i=r}for(let t=0;t<16;t++){const n=Je(r+Qe(e,o,a,u)+Ye[y[t]]+d,b[t])+h|0;r=h,h=u,u=0|Je(a,10),a=o,o=n}}this.set(this.h1+s+u|0,this.h2+c+h|0,this.h3+f+r|0,this.h4+n+o|0,this.h0+i+a|0)}roundClean(){Ye.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const en=It((()=>new tn)),nn=BigInt(2**32-1),rn=BigInt(32);function on(t,e=!1){return e?{h:Number(t&nn),l:Number(t>>rn&nn)}:{h:0|Number(t>>rn&nn),l:0|Number(t&nn)}}const sn=function(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=on(t[i],e);[n[i],r[i]]=[o,s]}return[n,r]},an=(t,e,n)=>t>>>n,cn=(t,e,n)=>t<<32-n|e>>>n,un=(t,e,n)=>t>>>n|e<<32-n,fn=(t,e,n)=>t<<32-n|e>>>n,hn=(t,e,n)=>t<<64-n|e>>>n-32,ln=(t,e,n)=>t>>>n-32|e<<64-n,dn=function(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}},pn=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),yn=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,gn=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),bn=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,wn=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,mn=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),[vn,An]=sn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))),xn=new Uint32Array(80),Sn=new Uint32Array(80);class En extends Pt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:d,Hh:p,Hl:y}=this;return[t,e,n,r,i,o,s,a,c,u,f,h,l,d,p,y]}set(t,e,n,r,i,o,s,a,c,u,f,h,l,d,p,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)xn[n]=t.getUint32(e),Sn[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|xn[t-15],n=0|Sn[t-15],r=un(e,n,1)^un(e,n,8)^an(e,n,7),i=fn(e,n,1)^fn(e,n,8)^cn(e,n,7),o=0|xn[t-2],s=0|Sn[t-2],a=un(o,s,19)^hn(o,s,61)^an(o,s,6),c=fn(o,s,19)^ln(o,s,61)^cn(o,s,6),u=gn(i,c,Sn[t-7],Sn[t-16]),f=bn(u,r,a,xn[t-7],xn[t-16]);xn[t]=0|f,Sn[t]=0|u}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:f,El:h,Fh:l,Fl:d,Gh:p,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=un(f,h,14)^un(f,h,18)^hn(f,h,41),w=fn(f,h,14)^fn(f,h,18)^ln(f,h,41),m=f&l^~f&p,v=mn(b,w,h&d^~h&y,An[t],Sn[t]),A=wn(v,g,e,m,vn[t],xn[t]),x=0|v,S=un(n,r,28)^hn(n,r,34)^hn(n,r,39),E=fn(n,r,28)^ln(n,r,34)^ln(n,r,39),C=n&i^n&s^i&s,B=r&o^r&a^o&a;g=0|p,b=0|y,p=0|l,y=0|d,l=0|f,d=0|h,({h:f,l:h}=dn(0|c,0|u,0|A,0|x)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const T=pn(x,E,B);n=yn(T,A,S,C),r=0|T}({h:n,l:r}=dn(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=dn(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=dn(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=dn(0|this.Dh,0|this.Dl,0|c,0|u)),({h:f,l:h}=dn(0|this.Eh,0|this.El,0|f,0|h)),({h:l,l:d}=dn(0|this.Fh,0|this.Fl,0|l,0|d)),({h:p,l:y}=dn(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:b}=dn(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(n,r,i,o,s,a,c,u,f,h,l,d,p,y,g,b)}roundClean(){xn.fill(0),Sn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Cn extends En{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Bn extends En{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Tn extends En{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}It((()=>new En)),It((()=>new Cn));const In=It((()=>new Bn));It((()=>new Tn));var Un=i(907),kn=i.n(Un);const Pn=new Map;function Nn(t,e){const n=Pn.get(t);if(void 0!==n)return n(e);const r=function(t){const e=Object.values(t).filter((t=>"number"==typeof t)),n=new Set(e);return t=>n.has(t)}(t);return Pn.set(t,r),Nn(t,e)}class $n{constructor(t){this.consumed=0,this.source="string"==typeof t?h(t):t}readBytes(t){const e=this.source.subarray(this.consumed,this.consumed+t);return this.consumed+=t,e}readUInt32BE(){return(t=this.readBytes(4))[0]*2**24+65536*t[1]+256*t[2]+t[3];var t}readUInt8(){return this.readBytes(1)[0]}readUInt16BE(){return((t=this.readBytes(2))[0+0]<<8|t[1])>>>0;var t}readBigUIntLE(t){const e=f(this.readBytes(t).slice().reverse());return BigInt(`0x${e}`)}readBigUIntBE(t){const e=f(this.readBytes(t));return BigInt(`0x${e}`)}get readOffset(){return this.consumed}set readOffset(t){this.consumed=t}get internalBytes(){return this.source}readUInt8Enum(t,e){const n=this.readUInt8();if(Nn(t,n))return n;throw e(n)}}var On,Hn,_n;function Ln(t){return Hn[t]}(_n=On||(On={})).Int="int",_n.UInt="uint",_n.Buffer="buffer",_n.BoolTrue="true",_n.BoolFalse="false",_n.PrincipalStandard="address",_n.PrincipalContract="contract",_n.ResponseOk="ok",_n.ResponseErr="err",_n.OptionalNone="none",_n.OptionalSome="some",_n.List="list",_n.Tuple="tuple",_n.StringASCII="ascii",_n.StringUTF8="utf8",function(t){t[t.int=0]="int",t[t.uint=1]="uint",t[t.buffer=2]="buffer",t[t.true=3]="true",t[t.false=4]="false",t[t.address=5]="address",t[t.contract=6]="contract",t[t.ok=7]="ok",t[t.err=8]="err",t[t.none=9]="none",t[t.some=10]="some",t[t.list=11]="list",t[t.tuple=12]="tuple",t[t.ascii=13]="ascii",t[t.utf8=14]="utf8"}(Hn||(Hn={}));const jn=BigInt("0xffffffffffffffffffffffffffffffff"),Mn=BigInt(0),Fn=BigInt("0x7fffffffffffffffffffffffffffffff"),Rn=BigInt("-170141183460469231731687303715884105728"),Dn=t=>{"string"==typeof t&&t.toLowerCase().startsWith("0x")&&(t=c(h(t))),v(t,Uint8Array)&&(t=c(t));const n=e(t);if(n>Fn)throw new RangeError(`Cannot construct clarity integer from value greater than ${Fn}`);if(n<Rn)throw new RangeError(`Cannot construct clarity integer form value less than ${Rn}`);return{type:On.Int,value:n}},Kn=t=>{const n=e(t);if(n<Mn)throw new RangeError("Cannot construct unsigned clarity integer from negative value");if(n>jn)throw new RangeError(`Cannot construct unsigned clarity integer greater than ${jn}`);return{type:On.UInt,value:n}},Vn=t=>{if(t.byteLength>1048576)throw new Error("Cannot construct clarity buffer that is greater than 1MB");return{type:On.Buffer,value:f(t)}},zn=t=>Vn(l(t)),qn=()=>({type:On.BoolTrue}),Wn=()=>({type:On.BoolFalse});var Gn,Zn;function Xn(t,e){return{type:Gn.LengthPrefixedList,lengthPrefixBytes:e||4,values:t}}function Jn(t){if(h(t).byteLength!=R)throw Error("Invalid signature");return{type:Gn.MessageSignature,data:t}}function Qn(t,e,n){const r=e||1,i=n||j;if(Pr(t,i))throw new Error(`String length exceeds maximum bytes ${i}`);return{type:Gn.LengthPrefixedString,content:t,lengthPrefixBytes:r,maxLengthBytes:i}}function Yn(t){const e=(0,_.yI)(t);return{type:Gn.Address,version:e[0],hash160:e[1]}}function tr(t,e){return{pubKeyEncoding:t,type:Gn.TransactionAuthField,contents:e}}function er(t,e,n,r){if(0===r.length)throw Error("Invalid number of public keys");if(!(e!==Q.P2PKH&&e!==Q.P2WPKH||1===r.length&&1===n))throw Error("Invalid number of public keys or signatures");if((e===Q.P2WPKH||e===Q.P2WSH||e===Q.P2WSHNonSequential)&&!r.map((t=>t.data)).every(zr))throw Error("Public keys must be compressed for segwit");switch(e){case Q.P2PKH:return nr(t,Hr(r[0].data));case Q.P2WPKH:return nr(t,_r(r[0].data));case Q.P2SH:case Q.P2SHNonSequential:return nr(t,Lr(n,r.map(Cr)));case Q.P2WSH:case Q.P2WSHNonSequential:return nr(t,jr(n,r.map(Cr)))}}function nr(t,e){return{type:Gn.Address,version:t,hash160:e}}function rr(t){return(0,_.H4)(t.version,t.hash160)}function ir(t){const[e,n,r]=t.split(/\.|::/);var i,o,s;return i=e,o=n,s=r,{type:Gn.Asset,address:Yn(i),contractName:Qn(o),assetName:Qn(s)}}function or(t){if(t.includes(".")){const[e,n]=t.split(".");return function(t,e){const n=Yn(t),r=Qn(e);return{type:Gn.Principal,prefix:nt.Contract,address:n,contractName:r}}(e,n)}return function(t){const e=Yn(t);return{type:Gn.Principal,prefix:nt.Standard,address:e}}(t)}function sr(t){const e=Yn(t);return{type:On.PrincipalStandard,value:rr(e)}}function ar(){return{type:On.OptionalNone}}function cr(t){return{type:On.OptionalSome,value:t}}function ur(t){for(const n in t)if(!(/^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$/.test(e=n)&&e.length<128))throw new Error(`"${n}" is not a valid Clarity name`);var e;return{type:On.Tuple,value:t}}(Zn=Gn||(Gn={}))[Zn.Address=0]="Address",Zn[Zn.Principal=1]="Principal",Zn[Zn.LengthPrefixedString=2]="LengthPrefixedString",Zn[Zn.MemoString=3]="MemoString",Zn[Zn.Asset=4]="Asset",Zn[Zn.PostCondition=5]="PostCondition",Zn[Zn.PublicKey=6]="PublicKey",Zn[Zn.LengthPrefixedList=7]="LengthPrefixedList",Zn[Zn.Payload=8]="Payload",Zn[Zn.MessageSignature=9]="MessageSignature",Zn[Zn.StructuredDataSignature=10]="StructuredDataSignature",Zn[Zn.TransactionAuthField=11]="TransactionAuthField";const fr=t=>({type:On.StringASCII,value:t}),hr=t=>({type:On.StringUTF8,value:t});function lr(t){let e;if("string"==typeof t){const n="0x"===t.slice(0,2).toLowerCase();e=new $n(h(n?t.slice(2):t))}else e=t instanceof Uint8Array?new $n(t):t;switch(e.readUInt8Enum(Hn,(t=>{throw new bt(`Cannot recognize Clarity Type: ${t}`)}))){case Hn.int:return Dn(c(e.readBytes(16)));case Hn.uint:return Kn(e.readBytes(16));case Hn.buffer:const t=e.readUInt32BE();return Vn(e.readBytes(t));case Hn.true:return qn();case Hn.false:return Wn();case Hn.address:return i=yr(e),{type:On.PrincipalStandard,value:rr(i)};case Hn.contract:return function(t,e){if(l(e.content).byteLength>=128)throw new Error("Contract name must be less than 128 bytes");return{type:On.PrincipalContract,value:`${rr(t)}.${e.content}`}}(yr(e),wr(e));case Hn.ok:return r=lr(e),{type:On.ResponseOk,value:r};case Hn.err:return function(t){return{type:On.ResponseErr,value:t}}(lr(e));case Hn.none:return ar();case Hn.some:return cr(lr(e));case Hn.list:const o=e.readUInt32BE(),s=[];for(let t=0;t<o;t++)s.push(lr(e));return n=s,{type:On.List,value:n};case Hn.tuple:const a=e.readUInt32BE(),u={};for(let t=0;t<a;t++){const t=wr(e).content;if(void 0===t)throw new bt('"content" is undefined');u[t]=lr(e)}return ur(u);case Hn.ascii:const f=e.readUInt32BE(),h=y(e.readBytes(f));return fr(h);case Hn.utf8:const p=e.readUInt32BE(),g=d(e.readBytes(p));return hr(g);default:throw new bt("Unable to deserialize Clarity Value from Uint8Array. Could not find valid Clarity Type.")}var n,r,i}function dr(e){switch(e.type){case Gn.Address:return pr(e);case Gn.Principal:return gr(e);case Gn.LengthPrefixedString:return br(e);case Gn.MemoString:return function(t){const e=[],n=l(t.content),r=kr(f(n),2*D);return e.push(h(r)),m(e)}(e);case Gn.Asset:return mr(e);case Gn.PostCondition:return function(e){const n=[];if(n.push(e.conditionType),n.push(gr(e.principal)),e.conditionType!==X.Fungible&&e.conditionType!==X.NonFungible||n.push(mr(e.asset)),e.conditionType===X.NonFungible&&n.push(Ir(e.assetName)),n.push(e.conditionCode),e.conditionType===X.STX||e.conditionType===X.Fungible){if(e.amount>BigInt("0xffffffffffffffff"))throw new gt("The post-condition amount may not be larger than 8 bytes");n.push(t(e.amount,8))}return m(n)}(e);case Gn.PublicKey:return Cr(e);case Gn.LengthPrefixedList:return Ar(e);case Gn.Payload:return Sr(e);case Gn.TransactionAuthField:return function(t){const e=[];switch(t.contents.type){case Gn.PublicKey:e.push(t.pubKeyEncoding===Y.Compressed?ot.PublicKeyCompressed:ot.PublicKeyUncompressed),e.push(h((n=t.contents.data,se.fromHex(Kr(n)).toHex(!0))));break;case Gn.MessageSignature:e.push(t.pubKeyEncoding===Y.Compressed?ot.SignatureCompressed:ot.SignatureUncompressed),e.push(Er(t.contents))}var n;return m(e)}(e);case Gn.MessageSignature:return Er(e)}}function pr(t){const e=[];return e.push(h(r(t.version,1))),e.push(h(t.hash160)),m(e)}function yr(t){const e=v(t,$n)?t:new $n(t),n=s(f(e.readBytes(1))),r=f(e.readBytes(20));return{type:Gn.Address,version:n,hash160:r}}function gr(t){const e=[];return e.push(t.prefix),t.prefix!==nt.Standard&&t.prefix!==nt.Contract||e.push(pr(t.address)),t.prefix===nt.Contract&&e.push(br(t.contractName)),m(e)}function br(t){const e=[],n=l(t.content),i=n.byteLength;return e.push(h(r(i,t.lengthPrefixBytes))),e.push(n),m(e)}function wr(t,e,n){e=e||1;const r=v(t,$n)?t:new $n(t),i=s(f(r.readBytes(e)));return Qn(d(r.readBytes(i)),e,n??128)}function mr(t){const e=[];return e.push(pr(t.address)),e.push(br(t.contractName)),e.push(br(t.assetName)),m(e)}function vr(t){const e=v(t,$n)?t:new $n(t);return{type:Gn.Asset,address:yr(e),contractName:wr(e),assetName:wr(e)}}function Ar(t){const e=t.values,n=[];n.push(h(r(e.length,t.lengthPrefixBytes)));for(const t of e)n.push(dr(t));return m(n)}function xr(t){const e=v(t,$n)?t:new $n(t),n=e.readUInt8Enum(X,(t=>{throw new bt(`Could not read ${t} as PostConditionType`)})),r=function(t){const e=v(t,$n)?t:new $n(t),n=e.readUInt8Enum(nt,(t=>{throw new bt(`Unexpected Principal payload type: ${t}`)}));if(n===nt.Origin)return{type:Gn.Principal,prefix:n};const r=yr(e);if(n===nt.Standard)return{type:Gn.Principal,prefix:n,address:r};const i=wr(e);return{type:Gn.Principal,prefix:n,address:r,contractName:i}}(e);let i,o,s;switch(n){case X.STX:return i=e.readUInt8Enum(tt,(t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)})),s=BigInt(`0x${f(e.readBytes(8))}`),{type:Gn.PostCondition,conditionType:X.STX,principal:r,conditionCode:i,amount:s};case X.Fungible:return o=vr(e),i=e.readUInt8Enum(tt,(t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)})),s=BigInt(`0x${f(e.readBytes(8))}`),{type:Gn.PostCondition,conditionType:X.Fungible,principal:r,conditionCode:i,amount:s,asset:o};case X.NonFungible:o=vr(e);const t=lr(e);return i=e.readUInt8Enum(et,(t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)})),{type:Gn.PostCondition,conditionType:X.NonFungible,principal:r,conditionCode:i,asset:o,assetName:t}}}function Sr(e){const n=[];switch(n.push(e.payloadType),e.payloadType){case K.TokenTransfer:n.push(Ir(e.recipient)),n.push(t(e.amount,8)),n.push(dr(e.memo));break;case K.ContractCall:n.push(dr(e.contractAddress)),n.push(dr(e.contractName)),n.push(dr(e.functionName));const r=new Uint8Array(4);L(r,e.functionArgs.length,0),n.push(r),e.functionArgs.forEach((t=>{n.push(Ir(t))}));break;case K.SmartContract:n.push(dr(e.contractName)),n.push(dr(e.codeBody));break;case K.VersionedSmartContract:n.push(e.clarityVersion),n.push(dr(e.contractName)),n.push(dr(e.codeBody));break;case K.PoisonMicroblock:break;case K.Coinbase:n.push(e.coinbaseBytes);break;case K.CoinbaseToAltRecipient:n.push(e.coinbaseBytes),n.push(Ir(e.recipient));break;case K.NakamotoCoinbase:n.push(e.coinbaseBytes),n.push(Ir(e.recipient?cr(e.recipient):ar())),n.push(e.vrfProof);break;case K.TenureChange:n.push(h(e.tenureHash)),n.push(h(e.previousTenureHash)),n.push(h(e.burnViewHash)),n.push(h(e.previousTenureEnd)),n.push(L(new Uint8Array(4),e.previousTenureBlocks)),n.push(function(t,e,n=0){return t[n]=e,t}(new Uint8Array(1),e.cause)),n.push(h(e.publicKeyHash))}return m(n)}function Er(t){return h(t.data)}function Cr(t){return t.data.slice()}function Br(t,e){return m([Ln(t),e])}function Tr(t,e){const n=[],r="ascii"==e?p(t.value):l(t.value),i=new Uint8Array(4);return L(i,r.length,0),n.push(i),n.push(r),Br(t.type,m(n))}function Ir(t){switch(t.type){case On.BoolTrue:case On.BoolFalse:return function(t){return new Uint8Array([Ln(t.type)])}(t);case On.OptionalNone:case On.OptionalSome:return(e=t).type===On.OptionalNone?new Uint8Array([Ln(e.type)]):Br(e.type,Ir(e.value));case On.Buffer:return function(t){const e=new Uint8Array(4);return L(e,Math.ceil(t.value.length/2),0),Br(t.type,w(e,h(t.value)))}(t);case On.UInt:return function(t){const e=a(BigInt(t.value),F);return Br(t.type,e)}(t);case On.Int:return function(t){const e=a(function(t,e){if(t<-(BigInt(1)<<e-BigInt(1))||(BigInt(1)<<e-BigInt(1))-BigInt(1)<t)throw`Unable to represent integer in width: ${e}`;return t>=BigInt(0)?BigInt(t):t+(BigInt(1)<<e)}(BigInt(t.value),BigInt(M)),F);return Br(t.type,e)}(t);case On.PrincipalStandard:return function(t){return Br(t.type,pr(Yn(t.value)))}(t);case On.PrincipalContract:return function(t){const[e,n]=function(t){const[e,n]=t.split(".");if(!e||!n)throw new Error(`Invalid contract identifier: ${t}`);return[e,n]}(t.value);return Br(t.type,w(pr(Yn(e)),br(Qn(n))))}(t);case On.ResponseOk:case On.ResponseErr:return function(t){return Br(t.type,Ir(t.value))}(t);case On.List:return function(t){const e=[],n=new Uint8Array(4);L(n,t.value.length,0),e.push(n);for(const n of t.value){const t=Ir(n);e.push(t)}return Br(t.type,m(e))}(t);case On.Tuple:return function(t){const e=[],n=new Uint8Array(4);L(n,Object.keys(t.value).length,0),e.push(n);const r=Object.keys(t.value).sort(((t,e)=>t.localeCompare(e)));for(const n of r){const r=Qn(n);e.push(br(r));const i=Ir(t.value[n]);e.push(i)}return Br(t.type,m(e))}(t);case On.StringASCII:return function(t){return Tr(t,"ascii")}(t);case On.StringUTF8:return function(t){return Tr(t,"utf8")}(t);default:throw new gt("Unable to serialize. Invalid Clarity Value.")}var e}const Ur=t=>t.length%2?`0${t}`:t,kr=(t,e)=>t.padEnd(e,"0"),Pr=(t,e)=>!!t&&l(t).length>e;function Nr(t){return kn()(t)}const $r=t=>en(jt(t)),Or=t=>f(In(t)),Hr=t=>f($r(t)),_r=t=>{const e=$r(t),n=w(new Uint8Array([0]),new Uint8Array([e.length]),e);return f($r(n))},Lr=(t,e)=>{if(t>15||e.length>15)throw Error("P2SH multisig address can only contain up to 15 public keys");const n=[];n.push(80+t),e.forEach((t=>{n.push(t.length),n.push(t)})),n.push(80+e.length),n.push(174);const r=m(n);return f($r(r))},jr=(t,e)=>{if(t>15||e.length>15)throw Error("P2WSH multisig address can only contain up to 15 public keys");const n=[];n.push(80+t),e.forEach((t=>{n.push(t.length),n.push(t)})),n.push(80+e.length),n.push(174);const r=m(n),i=jt(r),o=[];o.push(0),o.push(i.length),o.push(i);const s=m(o);return f($r(s))};const Mr=t=>{if(t.okay)return lr(t.result);throw new Error(t.cause)};function Fr(t,e="mainnet"){return e=O(e),function(t,e="mainnet"){e=O(e),t="string"==typeof t?h(t):t;const n=function(t,e){switch(e=O(e??k),t){case Q.P2PKH:switch(e.transactionVersion){case T.Mainnet:return I.MainnetSingleSig;case T.Testnet:return I.TestnetSingleSig;default:throw new Error(`Unexpected transactionVersion ${e.transactionVersion} for hashMode ${t}`)}case Q.P2SH:case Q.P2SHNonSequential:case Q.P2WPKH:case Q.P2WSH:case Q.P2WSHNonSequential:switch(e.transactionVersion){case T.Mainnet:return I.MainnetMultiSig;case T.Testnet:return I.TestnetMultiSig;default:throw new Error(`Unexpected transactionVersion ${e.transactionVersion} for hashMode ${t}`)}default:throw new Error(`Unexpected hashMode ${t}`)}}(Q.P2PKH,e);return rr(nr(n,Hr(t)))}(qr(t),e)}function Rr(t){return t="string"==typeof t?h(t):t,{type:Gn.PublicKey,data:t}}function Dr(t){return"string"==typeof t?t:f(t)}je.hmacSha256Sync=(t,...e)=>{const n=kt.create(jt,t);return e.forEach((t=>n.update(t))),n.digest()};const Kr=Dr;function Vr(t){return("string"==typeof t?t.length/2:t.byteLength)===A}function zr(t){return!Kr(t).startsWith("04")}function qr(t){const e=Vr(t=Fe(t));return f(function(t,e=!1){return se.fromPrivateKey(t).toRawBytes(e)}(t.slice(0,32),e))}const Wr=function(){return(t=Dr(t=je.randomPrivateKey())).length==2*A?t:`${t}01`;var t};function Gr(t,e){t=Fe(t);const[n,i]=function(t,e,n={}){const{seed:r,m:i,d:o}=function(t,e,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const r=ve(t),i=Ne(e),o=[He(i),Oe(r)];if(null!=n){!0===n&&(n=je.randomBytes(Zt));const t=ve(n);if(t.length!==Zt)throw new Error(`sign: Expected ${Zt} bytes of extra data`);o.push(t)}return{seed:fe(...o),m:$e(r),d:i}}(t,e,n.extraEntropy),s=new Ie(32,Xt);let a;for(s.reseedSync(r);!(a=Pe(s.generateSync(),i,o,n.canonical));)s.reseedSync();return function(t,e){const{sig:n,recovery:r}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),s=i?n.toDERRawBytes():n.toCompactRawBytes();return o?[s,r]:s}(a,n)}(e,t.slice(0,32),{canonical:!0,recovered:!0});if(null==i)throw new Error("No signature recoveryId received");return r(i,1)+ue.fromHex(n).toCompactHex()}function Zr(...t){return"number"==typeof t[0]?function(t,e){return e="string"==typeof e?h(e):e,(0,_.H4)(t,f($r(e)))}(...t):function(t,e){return e=e?O(e):k,t="string"==typeof t?h(t):t,(0,_.H4)(e.addressVersion.singleSig,f($r(t)))}(...t)}function Xr(){return{type:Gn.MessageSignature,data:f(new Uint8Array(R))}}function Jr(t,n,r,i){const o=er(0,t,1,[Rr(n)]).hash160,s=zr(n)?Y.Compressed:Y.Uncompressed;return{hashMode:t,signer:o,nonce:e(r),fee:e(i),keyEncoding:s,signature:Xr()}}function Qr(t){return"signature"in t}function Yr(t){return t===Q.P2SH||t===Q.P2WSH}function ti(t){const e=Nr(t);return e.nonce=0,e.fee=0,Qr(e)?e.signature=Xr():e.fields=[],{...e,nonce:BigInt(0),fee:BigInt(0)}}function ei(e){return Qr(e)?function(e){return m([e.hashMode,h(e.signer),t(e.nonce,8),t(e.fee,8),e.keyEncoding,Er(e.signature)])}(e):function(e){const n=[e.hashMode,h(e.signer),t(e.nonce,8),t(e.fee,8)],r=Xn(e.fields);n.push(Ar(r));const i=new Uint8Array(2);return function(t,e,n=0){t[n+0]=e>>>8,t[n+1]=e>>>0}(i,e.signaturesRequired,0),n.push(i),m(n)}(e)}function ni(e,n,r,i){const o=e+f(new Uint8Array([n]))+f(t(r,8))+f(t(i,8));if(49!==h(o).byteLength)throw Error("Invalid signature hash length");return Or(h(o))}function ri(t,e,n){const r=33+R,i=zr(e.data)?Y.Compressed:Y.Uncompressed,o=h(t+Ur(i.toString(16))+n);if(o.byteLength>r)throw Error("Invalid signature hash length");return Or(o)}function ii(t,e,r,i,o,a){const c=ni(t,e,r,i),u=Rr(function(t,e,r=Y.Compressed){const i=function(t){if(t.length<2*Me*2+1)throw new Error("Invalid signature");const e=t.slice(0,2),n=t.slice(2,2+2*Me),r=t.slice(2+2*Me);return{recoveryId:s(e),r:n,s:r}}(e),o=new ue(n(i.r),n(i.s)),a=se.fromSignature(t,o,i.recoveryId),c=r===Y.Compressed;return a.toHex(c)}(c,a,o));return{pubKey:u,nextSigHash:ri(c,u,a)}}function oi(t){return{authType:J.Standard,spendingCondition:t}}function si(t,e){return{authType:J.Sponsored,spendingCondition:t,sponsorSpendingCondition:e||Jr(Q.P2PKH,"0".repeat(66),0,0)}}function ai(t){if(t.spendingCondition)switch(t.authType){case J.Standard:return oi(ti(t.spendingCondition));case J.Sponsored:return si(ti(t.spendingCondition),function(){const t=Jr(Q.P2PKH,"",0,0);return t.signer=(Gn.Address,I.MainnetSingleSig,"0".repeat(40)),t.keyEncoding=Y.Compressed,t.signature=Xr(),t}());default:throw new mt("Unexpected authorization type for signing")}throw new Error("Authorization missing SpendingCondition")}function ci(t,e="hex"){switch(t.type){case On.BoolTrue:return"true";case On.BoolFalse:return"false";case On.Int:return t.value.toString();case On.UInt:return`u${t.value.toString()}`;case On.Buffer:if("tryAscii"===e){const e=y(h(t.value));if(/[ -~]/.test(e))return JSON.stringify(e)}return`0x${t.value}`;case On.OptionalNone:return"none";case On.OptionalSome:return`(some ${ci(t.value,e)})`;case On.ResponseErr:return`(err ${ci(t.value,e)})`;case On.ResponseOk:return`(ok ${ci(t.value,e)})`;case On.PrincipalStandard:case On.PrincipalContract:return t.value;case On.List:return`(list ${t.value.map((t=>ci(t,e))).join(" ")})`;case On.Tuple:return`(tuple ${Object.keys(t.value).map((n=>`(${n} ${ci(t.value[n],e)})`)).join(" ")})`;case On.StringASCII:return`"${t.value}"`;case On.StringUTF8:return`u"${t.value}"`}}function ui(t){switch(t.type){case On.BoolTrue:case On.BoolFalse:return"bool";case On.Int:return"int";case On.UInt:return"uint";case On.Buffer:return`(buff ${Math.ceil(t.value.length/2)})`;case On.OptionalNone:return"(optional none)";case On.OptionalSome:return`(optional ${ui(t.value)})`;case On.ResponseErr:return`(response UnknownType ${ui(t.value)})`;case On.ResponseOk:return`(response ${ui(t.value)} UnknownType)`;case On.PrincipalStandard:case On.PrincipalContract:return"principal";case On.List:return`(list ${t.value.length} ${t.value.length?ui(t.value[0]):"UnknownType"})`;case On.Tuple:return`(tuple ${Object.keys(t.value).map((e=>`(${e} ${ui(t.value[e])})`)).join(" ")})`;case On.StringASCII:return`(string-ascii ${p(t.value).length})`;case On.StringUTF8:return`(string-utf8 ${l(t.value).length})`}}var fi;!function(t){t[t.ClarityAbiTypeUInt128=1]="ClarityAbiTypeUInt128",t[t.ClarityAbiTypeInt128=2]="ClarityAbiTypeInt128",t[t.ClarityAbiTypeBool=3]="ClarityAbiTypeBool",t[t.ClarityAbiTypePrincipal=4]="ClarityAbiTypePrincipal",t[t.ClarityAbiTypeNone=5]="ClarityAbiTypeNone",t[t.ClarityAbiTypeBuffer=6]="ClarityAbiTypeBuffer",t[t.ClarityAbiTypeResponse=7]="ClarityAbiTypeResponse",t[t.ClarityAbiTypeOptional=8]="ClarityAbiTypeOptional",t[t.ClarityAbiTypeTuple=9]="ClarityAbiTypeTuple",t[t.ClarityAbiTypeList=10]="ClarityAbiTypeList",t[t.ClarityAbiTypeStringAscii=11]="ClarityAbiTypeStringAscii",t[t.ClarityAbiTypeStringUtf8=12]="ClarityAbiTypeStringUtf8",t[t.ClarityAbiTypeTraitReference=13]="ClarityAbiTypeTraitReference"}(fi||(fi={}));const hi=t=>"string"==typeof t,li=t=>void 0!==t.buffer,di=t=>void 0!==t["string-ascii"],pi=t=>void 0!==t["string-utf8"],yi=t=>void 0!==t.response,gi=t=>void 0!==t.optional,bi=t=>void 0!==t.tuple,wi=t=>void 0!==t.list;function mi(t){if(hi(t))return"int128"===t?"int":"uint128"===t?"uint":t;if(li(t))return`(buff ${t.buffer.length})`;if(di(t))return`(string-ascii ${t["string-ascii"].length})`;if(pi(t))return`(string-utf8 ${t["string-utf8"].length})`;if(yi(t))return`(response ${mi(t.response.ok)} ${mi(t.response.error)})`;if(gi(t))return`(optional ${mi(t.optional)})`;if(bi(t))return`(tuple ${t.tuple.map((t=>`(${t.name} ${mi(t.type)})`)).join(" ")})`;if(wi(t))return`(list ${t.list.length} ${mi(t.list.type)})`;throw new Error(`Type string unsupported for Clarity type: ${JSON.stringify(t)}`)}function vi(t,e){const n=function(t){if(hi(t)){if("uint128"===t)return{id:fi.ClarityAbiTypeUInt128,type:t};if("int128"===t)return{id:fi.ClarityAbiTypeInt128,type:t};if("bool"===t)return{id:fi.ClarityAbiTypeBool,type:t};if("principal"===t)return{id:fi.ClarityAbiTypePrincipal,type:t};if("trait_reference"===t)return{id:fi.ClarityAbiTypeTraitReference,type:t};if("none"===t)return{id:fi.ClarityAbiTypeNone,type:t};throw new Error(`Unexpected Clarity ABI type primitive: ${JSON.stringify(t)}`)}if(li(t))return{id:fi.ClarityAbiTypeBuffer,type:t};if(yi(t))return{id:fi.ClarityAbiTypeResponse,type:t};if(gi(t))return{id:fi.ClarityAbiTypeOptional,type:t};if(bi(t))return{id:fi.ClarityAbiTypeTuple,type:t};if(wi(t))return{id:fi.ClarityAbiTypeList,type:t};if(di(t))return{id:fi.ClarityAbiTypeStringAscii,type:t};if(pi(t))return{id:fi.ClarityAbiTypeStringUtf8,type:t};throw new Error(`Unexpected Clarity ABI type: ${JSON.stringify(t)}`)}(e);switch(t.type){case On.BoolTrue:case On.BoolFalse:return n.id===fi.ClarityAbiTypeBool;case On.Int:return n.id===fi.ClarityAbiTypeInt128;case On.UInt:return n.id===fi.ClarityAbiTypeUInt128;case On.Buffer:return n.id===fi.ClarityAbiTypeBuffer&&n.type.buffer.length>=Math.ceil(t.value.length/2);case On.StringASCII:return n.id===fi.ClarityAbiTypeStringAscii&&n.type["string-ascii"].length>=t.value.length;case On.StringUTF8:return n.id===fi.ClarityAbiTypeStringUtf8&&n.type["string-utf8"].length>=t.value.length;case On.OptionalNone:return n.id===fi.ClarityAbiTypeNone||n.id===fi.ClarityAbiTypeOptional;case On.OptionalSome:return n.id===fi.ClarityAbiTypeOptional&&vi(t.value,n.type.optional);case On.ResponseErr:return n.id===fi.ClarityAbiTypeResponse&&vi(t.value,n.type.response.error);case On.ResponseOk:return n.id===fi.ClarityAbiTypeResponse&&vi(t.value,n.type.response.ok);case On.PrincipalContract:return n.id===fi.ClarityAbiTypePrincipal||n.id===fi.ClarityAbiTypeTraitReference;case On.PrincipalStandard:return n.id===fi.ClarityAbiTypePrincipal;case On.List:return n.id==fi.ClarityAbiTypeList&&n.type.list.length>=t.value.length&&t.value.every((t=>vi(t,n.type.list.type)));case On.Tuple:if(n.id==fi.ClarityAbiTypeTuple){const e=Nr(t.value);for(let t=0;t<n.type.tuple.length;t++){const r=n.type.tuple[t],i=r.name,o=e[i];if(!o)return!1;if(!vi(o,r.type))return!1;delete e[i]}return!0}return!1;default:return!1}}class Ai{constructor({auth:t,payload:n,postConditions:r=Xn([]),postConditionMode:i=Z.Deny,transactionVersion:o,chainId:s,network:a="mainnet"}){a=O(a),this.transactionVersion=o??a.transactionVersion,this.chainId=s??a.chainId,this.auth=t,this.payload="amount"in n?{...n,amount:e(n.amount)}:n,this.postConditionMode=i,this.postConditions=r,this.anchorMode=z.Any}signBegin(){const t=Nr(this);return t.auth=ai(t.auth),t.txid()}verifyBegin(){const t=Nr(this);return t.auth=ai(t.auth),t.txid()}verifyOrigin(){return function(t,e){switch(t.authType){case J.Standard:case J.Sponsored:return function(t,e,n){return Qr(t)?function(t,e,n){const{pubKey:r,nextSigHash:i}=ii(e,n,t.fee,t.nonce,t.keyEncoding,t.signature.data),o=er(0,t.hashMode,1,[r]).hash160;if(o!==t.signer)throw new vt(`Signer hash does not equal hash of public key(s): ${o} != ${t.signer}`);return i}(t,e,n):function(t,e,n){const r=[];let i=e,o=!1,s=0;for(const e of t.fields)switch(e.contents.type){case Gn.PublicKey:zr(e.contents.data)||(o=!0),r.push(e.contents);break;case Gn.MessageSignature:e.pubKeyEncoding===Y.Uncompressed&&(o=!0);const{pubKey:a,nextSigHash:c}=ii(i,n,t.fee,t.nonce,e.pubKeyEncoding,e.contents.data);if(Yr(t.hashMode)&&(i=c),r.push(a),s+=1,65536===s)throw new vt("Too many signatures")}if(Yr(t.hashMode)&&s!==t.signaturesRequired||((a=t.hashMode)===Q.P2SHNonSequential||a===Q.P2WSHNonSequential)&&s<t.signaturesRequired)throw new vt("Incorrect number of signatures");var a;if(o&&(t.hashMode===Q.P2WSH||t.hashMode===Q.P2WSHNonSequential))throw new vt("Uncompressed keys are not allowed in this hash mode");const c=er(0,t.hashMode,t.signaturesRequired,r).hash160;if(c!==t.signer)throw new vt(`Signer hash does not equal hash of public key(s): ${c} != ${t.signer}`);return i}(t,e,n)}(t.spendingCondition,e,J.Standard);default:throw new mt("Invalid origin auth type")}}(this.auth,this.verifyBegin())}signNextOrigin(t,e){if(void 0===this.auth.spendingCondition)throw new Error('"auth.spendingCondition" is undefined');if(void 0===this.auth.authType)throw new Error('"auth.authType" is undefined');return this.signAndAppend(this.auth.spendingCondition,t,J.Standard,e)}signNextSponsor(t,e){if(this.auth.authType===J.Sponsored)return this.signAndAppend(this.auth.sponsorSpendingCondition,t,J.Sponsored,e);throw new Error('"auth.sponsorSpendingCondition" is undefined')}appendPubkey(t){const e="object"==typeof t&&"type"in t?t:Rr(t),n=this.auth.spendingCondition;if(!n||Qr(n))throw new Error("Can't append public key to a singlesig condition");{const t=zr(e.data);n.fields.push(tr(t?Y.Compressed:Y.Uncompressed,e))}}signAndAppend(t,e,n,r){const{nextSig:i,nextSigHash:o}=function(t,e,n,r,i){const o=ni(t,e,n,r),s=Gr(i,o);return{nextSig:s,nextSigHash:ri(o,Rr(qr(i)),s)}}(e,n,t.fee,t.nonce,r);if(Qr(t))t.signature=Jn(i);else{const e=Vr(r);t.fields.push(tr(e?Y.Compressed:Y.Uncompressed,Jn(i)))}return o}txid(){const t=this.serializeBytes();return Or(t)}setSponsor(t){if(this.auth.authType!=J.Sponsored)throw new mt("Cannot sponsor sign a non-sponsored transaction");this.auth=function(t,n){return{...t,sponsorSpendingCondition:{...n,nonce:e(n.nonce),fee:e(n.fee)}}}(this.auth,t)}setFee(t){this.auth=function(t,n){switch(t.authType){case J.Standard:const r={...t.spendingCondition,fee:e(n)};return{...t,spendingCondition:r};case J.Sponsored:const i={...t.sponsorSpendingCondition,fee:e(n)};return{...t,sponsorSpendingCondition:i}}}(this.auth,t)}setNonce(t){this.auth=function(t,n){const r={...t.spendingCondition,nonce:e(n)};return{...t,spendingCondition:r}}(this.auth,t)}setSponsorNonce(t){if(this.auth.authType!=J.Sponsored)throw new mt("Cannot sponsor sign a non-sponsored transaction");this.auth=function(t,n){const r={...t.sponsorSpendingCondition,nonce:e(n)};return{...t,sponsorSpendingCondition:r}}(this.auth,t)}serialize(){return f(this.serializeBytes())}serializeBytes(){if(void 0===this.transactionVersion)throw new gt('"transactionVersion" is undefined');if(void 0===this.chainId)throw new gt('"chainId" is undefined');if(void 0===this.auth)throw new gt('"auth" is undefined');if(void 0===this.payload)throw new gt('"payload" is undefined');const t=[];t.push(this.transactionVersion);const e=new Uint8Array(4);return L(e,this.chainId,0),t.push(e),t.push(function(t){const e=[];switch(e.push(t.authType),t.authType){case J.Standard:e.push(ei(t.spendingCondition));break;case J.Sponsored:e.push(ei(t.spendingCondition)),e.push(ei(t.sponsorSpendingCondition))}return m(e)}(this.auth)),t.push(this.anchorMode),t.push(this.postConditionMode),t.push(Ar(this.postConditions)),t.push(Sr(this.payload)),m(t)}}function xi(t){return(e=t.transactionVersion,t=>t[e])({[T.Mainnet]:k,[T.Testnet]:P});var e}const Si="/v2/fees/transfer",Ei="/v2/fees/transaction",Ci="/v2/accounts",Bi="/v2/contracts/interface",Ti="/v2/contracts/call-read";var Ii;function Ui(t){return Ii[t]}async function ki(t){const n={fee:BigInt(0),nonce:BigInt(0),network:k,postConditionMode:Z.Deny,sponsored:!1},r=Object.assign(n,t);r.network=O(r.network),r.client=Object.assign({},H(r.network),r.client),r.postConditionMode=function(t){if("number"==typeof t)return t;if("allow"===t)return Z.Allow;if("deny"===t)return Z.Deny;throw new Error(`Invalid post condition mode: ${t}`)}(r.postConditionMode);const i=(o=r.contractAddress,s=r.contractName,a=r.functionName,c=r.functionArgs,"string"==typeof s&&(s=Qn(s)),"string"==typeof a&&(a=Qn(a)),{type:Gn.Payload,payloadType:K.ContractCall,contractAddress:"string"==typeof o?Yn(o):o,contractName:s,functionName:a,functionArgs:c});var o,s,a,c;if(r?.validateWithAbi){let t;if("boolean"==typeof r.validateWithAbi){if(!r?.network)throw new Error("Network option must be provided in order to validate with ABI");t=await async function({contractAddress:t,contractName:e,network:n="mainnet",client:r}){const i=Object.assign({},H(O(n)),r),o=`${i.baseUrl}${Bi}/${t}/${e}`,s=await i.fetch(o);if(!s.ok){const n=await s.text().catch((()=>""));throw new Error(`Error fetching contract ABI for contract "${e}" at address ${t}. Response ${s.status}: ${s.statusText}. Attempted to fetch ${o} and failed with the message: "${n}"`)}return JSON.parse(await s.text())}({...r})}else t=r.validateWithAbi;!function(t,e){const n=e.functions.filter((e=>e.name===t.functionName.content));if(1===n.length){const e=n[0].args;if(t.functionArgs.length!==e.length)throw new Error(`Clarity function expects ${e.length} argument(s) but received ${t.functionArgs.length}`);for(let n=0;n<t.functionArgs.length;n++){const r=t.functionArgs[n],i=e[n];if(!vi(r,i.type)){const e=n+1;throw new Error(`Clarity function \`${t.functionName.content}\` expects argument ${e} to be of type ${mi(i.type)}, not ${ui(r)}`)}}return!0}throw 0===n.length?new Error(`ABI doesn't contain a function with the name ${t.functionName.content}`):new Error(`Malformed ABI. Contains multiple functions with the name ${t.functionName.content}`)}(i,t)}let u=null;if("publicKey"in r)u=Jr(Q.P2PKH,r.publicKey,r.nonce,r.fee);else{const t=r.useNonSequentialMultiSig?Q.P2SHNonSequential:Q.P2SH,n=r.address?function(t,e,n,r){if(er(0,n,e,t.map(Rr)).hash160===r)return t;const i=t.slice().sort();if(er(0,n,e,i.map(Rr)).hash160===r)return i;throw new Error("Failed to find matching multi-sig address given public-keys.")}(r.publicKeys.map(Kr),r.numSignatures,t,Yn(r.address).hash160):r.publicKeys.map(Kr);u=function(t,n,r,i,o){return{hashMode:t,signer:er(0,t,n,r.map(Rr)).hash160,nonce:e(i),fee:e(o),fields:[],signaturesRequired:n}}(t,r.numSignatures,n,r.nonce,r.fee)}const h=r.sponsored?si(u):oi(u),l=Xn((r.postConditions??[]).map((t=>"string"==typeof t?xr(t):"string"==typeof t.type?function(t){switch(t.type){case"stx-postcondition":return{type:Gn.PostCondition,conditionType:X.STX,principal:"origin"===t.address?{type:Gn.Principal,prefix:nt.Origin}:or(t.address),conditionCode:Ui(t.condition),amount:BigInt(t.amount)};case"ft-postcondition":return{type:Gn.PostCondition,conditionType:X.Fungible,principal:"origin"===t.address?{type:Gn.Principal,prefix:nt.Origin}:or(t.address),conditionCode:Ui(t.condition),amount:BigInt(t.amount),asset:ir(t.asset)};case"nft-postcondition":return{type:Gn.PostCondition,conditionType:X.NonFungible,principal:"origin"===t.address?{type:Gn.Principal,prefix:nt.Origin}:or(t.address),conditionCode:Ui(t.condition),asset:ir(t.asset),assetName:t.assetId};default:throw new Error("Invalid post condition type")}}(t):t))),d=new Ai({transactionVersion:r.network.transactionVersion,chainId:r.network.chainId,auth:h,payload:i,postConditions:l,postConditionMode:r.postConditionMode});if(void 0===t.fee||null===t.fee){const t=await async function({transaction:t,network:e,client:n}){const r=e??xi(t),i=Object.assign({},H(O(r)),n);try{const e=function(t){const e=t.auth.spendingCondition.hashMode;if([Q.P2SH,Q.P2WSH].includes(e)){const e=t.auth.spendingCondition,n=e.fields.filter((t=>t.contents.type===Gn.MessageSignature)).length,r=(e.signaturesRequired-n)*(R+1);return t.serializeBytes().byteLength+r}return t.serializeBytes().byteLength}(t);return(await async function({payload:t,estimatedLength:e,network:n="mainnet",client:r}){const i={transaction_payload:t,estimated_len:e},o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},s=Object.assign({},H(O(n)),r),a=`${s.baseUrl}${Ei}`,c=await s.fetch(a,o);if(!c.ok){const t=await c.text().catch((()=>""));if(t.includes("NoEstimateAvailable")){let e={};try{e=JSON.parse(t)}catch(t){}throw new wt(e?.reason_data?.message??"")}throw new Error(`Error estimating transaction fee. Response ${c.status}: ${c.statusText}. Attempted to fetch ${a} and failed with the message: "${t}"`)}return(await c.json()).estimations}({payload:f(Sr(t.payload)),estimatedLength:e,network:r,client:i}))[1].fee}catch(e){if(!(e instanceof wt))throw e;return await async function({transaction:t,network:e,client:n}){const r="number"==typeof t?"mainnet":e??xi(t),i=Object.assign({},H(O(r)),n),o=`${i.baseUrl}${Si}`,s=await i.fetch(o,{headers:{Accept:"application/text"}});if(!s.ok){const t=await s.text().catch((()=>""));throw new Error(`Error estimating transfer fee. Response ${s.status}: ${s.statusText}. Attempted to fetch ${o} and failed with the message: "${t}"`)}const a=await s.text(),c="number"==typeof t?BigInt(t):BigInt(Math.ceil(t.serializeBytes().byteLength));return BigInt(a)*c}({transaction:t,network:r})}}({transaction:d,...r});d.setFee(t)}if(void 0===t.nonce||null===t.nonce){const t=r.network.addressVersion.singleSig,e=(0,_.H4)(t,d.auth.spendingCondition.signer),n=await async function(t){try{return await async function({address:t,network:e="mainnet",client:n}){const r=Object.assign({},H(O(e)),n),i=`${r.baseUrl}/extended/v1/address/${t}/nonces`,o=await r.fetch(i),s=await o.json();return BigInt(s.possible_next_nonce)}(t)}catch(t){}const e=O(t.network??"mainnet"),n=Object.assign({},H(e),t.client),r=`${n.baseUrl}${Ci}/${t.address}?proof=0`,i=await n.fetch(r);if(!i.ok){const t=await i.text().catch((()=>""));throw new Error(`Error fetching nonce. Response ${i.status}: ${i.statusText}. Attempted to fetch ${r} and failed with the message: "${t}"`)}const o=await i.json();return BigInt(o.nonce)}({address:e,...r});d.setNonce(n)}return d}function Pi(t){const e=t.split(".");return e.length>2?{subdomain:e[0],name:e[1],namespace:e[2]}:{name:e[0],namespace:e[1]}}!function(t){t[t.eq=1]="eq",t[t.gt=2]="gt",t[t.lt=4]="lt",t[t.gte=3]="gte",t[t.lte=5]="lte",t[t.sent=16]="sent",t[t["not-sent"]=17]="not-sent"}(Ii||(Ii={}));const Ni=t=>$r(l(t));var $i=Object.defineProperty,Oi=Object.defineProperties,Hi=Object.getOwnPropertyDescriptors,_i=Object.getOwnPropertySymbols,Li=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable,Mi=(t,e,n)=>e in t?$i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Fi=(t,e)=>{for(var n in e||(e={}))Li.call(e,n)&&Mi(t,n,e[n]);if(_i)for(var n of _i(e))ji.call(e,n)&&Mi(t,n,e[n]);return t},Ri=(t,e)=>Oi(t,Hi(e));const Di="bns";async function Ki(t){return ki({contractAddress:t.network.bootAddress,contractName:Di,functionName:t.functionName,functionArgs:t.functionArgs,publicKey:t.publicKey,validateWithAbi:!1,network:t.network,postConditions:t.postConditions})}async function Vi(t){return async function({contractName:t,contractAddress:e,functionName:n,functionArgs:r,senderAddress:i,network:o="mainnet",client:s}){const a={sender:i,arguments:r.map((t=>`0x${f(Ir(t))}`))},c={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)},u=encodeURIComponent(n),h=Object.assign({},H(O(o)),s),l=`${h.baseUrl}${Ti}/${e}/${t}/${u}`,d=await h.fetch(l,c);if(!d.ok){const t=await d.text().catch((()=>""));throw new Error(`Error calling read-only function. Response ${d.status}: ${d.statusText}. Attempted to fetch ${l} and failed with the message: "${t}"`)}return await d.json().then(Mr)}(Ri(Fi({},t),{contractAddress:t.network.bootAddress,contractName:Di}))}async function zi({fullyQualifiedName:t,network:e}){const{subdomain:n,namespace:r,name:i}=Pi(t);if(n)throw new Error("Cannot register a subdomain using registerName");return Vi({functionName:"can-name-be-registered",senderAddress:Fr(Wr()),functionArgs:[zn(r),zn(i)],network:e}).then((t=>t.type===On.ResponseOk&&t.value.type===On.BoolTrue))}async function qi({namespace:t,network:e}){return Vi({functionName:"get-namespace-price",senderAddress:Fr(Wr()),functionArgs:[zn(t)],network:e}).then((t=>{if(t.type===On.ResponseOk){if(t.value.type===On.Int||t.value.type===On.UInt)return BigInt(t.value.value);throw new Error("Response did not contain a number")}throw t.type===On.ResponseErr?new Error(ci(t.value)):new Error(`Unexpected Clarity Value type: ${ui(t)}`)}))}async function Wi({fullyQualifiedName:t,network:e}){const{subdomain:n,namespace:r,name:i}=Pi(t);if(n)throw new Error("Cannot get subdomain name price");return Vi({functionName:"get-name-price",senderAddress:Fr(Wr()),functionArgs:[zn(r),zn(i)],network:e}).then((t=>{if(t.type===On.ResponseOk){if(t.value.type===On.Int||t.value.type===On.UInt)return BigInt(t.value.value);throw new Error("Response did not contain a number")}throw new Error(ci(t.value))}))}async function Gi({namespace:t,salt:n,stxToBurn:r,publicKey:i,network:o}){const s=l(`${t}${n}`),a=$r(s),c={type:"stx-postcondition",address:Zr(o.addressVersion.singleSig,i),condition:"eq",amount:e(r)};return Ki({functionName:"namespace-preorder",functionArgs:[Vn(a),Kn(r)],publicKey:i,network:o,postConditions:[c]})}async function Zi({namespace:t,salt:e,priceFunction:n,lifetime:r,namespaceImportAddress:i,publicKey:o,network:s}){return Ki({functionName:"namespace-reveal",functionArgs:[zn(t),zn(e),Kn(n.base),Kn(n.coefficient),Kn(n.b1),Kn(n.b2),Kn(n.b3),Kn(n.b4),Kn(n.b5),Kn(n.b6),Kn(n.b7),Kn(n.b8),Kn(n.b9),Kn(n.b10),Kn(n.b11),Kn(n.b12),Kn(n.b13),Kn(n.b14),Kn(n.b15),Kn(n.b16),Kn(n.nonAlphaDiscount),Kn(n.noVowelDiscount),Kn(r),sr(i)],publicKey:o,network:s})}async function Xi({namespace:t,name:e,beneficiary:n,zonefile:r,publicKey:i,network:o}){const s=Ni(r);return Ki({functionName:"name-import",functionArgs:[zn(t),zn(e),sr(n),Vn(s)],publicKey:i,network:o})}async function Ji({namespace:t,publicKey:e,network:n}){return Ki({functionName:"namespace-ready",functionArgs:[zn(t)],publicKey:e,network:n})}async function Qi({fullyQualifiedName:t,salt:n,stxToBurn:r,publicKey:i,network:o}){const{subdomain:s}=Pi(t);if(s)throw new Error("Cannot preorder a subdomain using preorderName()");const a=l(`${t}${n}`),c=$r(a),u={type:"stx-postcondition",address:Zr(o.addressVersion.singleSig,i),condition:"eq",amount:e(r)};return Ki({functionName:"name-preorder",functionArgs:[Vn(c),Kn(r)],publicKey:i,network:o,postConditions:[u]})}async function Yi({fullyQualifiedName:t,salt:e,zonefile:n,publicKey:r,network:i}){const{subdomain:o,namespace:s,name:a}=Pi(t);if(o)throw new Error("Cannot register a subdomain using registerName()");const c=Ni(n);return Ki({functionName:"name-register",functionArgs:[zn(s),zn(a),zn(e),Vn(c)],network:i,publicKey:r})}async function to({fullyQualifiedName:t,zonefile:e,publicKey:n,network:r}){const{subdomain:i,namespace:o,name:s}=Pi(t);if(i)throw new Error("Cannot update a subdomain using updateName()");const a=Ni(e);return Ki({functionName:"name-update",functionArgs:[zn(o),zn(s),Vn(a)],publicKey:n,network:r})}async function eo({fullyQualifiedName:t,newOwnerAddress:e,zonefile:n,publicKey:r,network:i}){const{subdomain:o,namespace:s,name:a}=Pi(t);if(o)throw new Error("Cannot transfer a subdomain using transferName()");return Ki({functionName:"name-transfer",functionArgs:[zn(s),zn(a),sr(e),n?cr(Vn(Ni(n))):ar()],publicKey:r,network:i,postConditions:[{type:"nft-postcondition",address:Zr(i.addressVersion.singleSig,r),condition:"sent",asset:`${i.bootAddress}.bns::names`,assetId:ur({name:zn(a),namespace:zn(s)})},{type:"nft-postcondition",address:e,condition:"not-sent",asset:`${i.bootAddress}.bns::names`,assetId:ur({name:zn(a),namespace:zn(s)})}]})}async function no({fullyQualifiedName:t,publicKey:e,network:n}){const{subdomain:r,namespace:i,name:o}=Pi(t);if(r)throw new Error("Cannot revoke a subdomain using revokeName()");return Ki({functionName:"name-revoke",functionArgs:[zn(i),zn(o)],publicKey:e,network:n})}async function ro({fullyQualifiedName:t,stxToBurn:n,newOwnerAddress:r,zonefile:i,publicKey:o,network:s}){const{subdomain:a,namespace:c,name:u}=Pi(t);if(a)throw new Error("Cannot renew a subdomain using renewName()");return Ki({functionName:"name-renewal",functionArgs:[zn(c),zn(u),Kn(n),r?cr(sr(r)):ar(),i?cr(Vn(Ni(i))):ar()],publicKey:o,network:s,postConditions:[{type:"stx-postcondition",address:Zr(s.addressVersion.singleSig,o),condition:"eq",amount:e(n)}]})}})(),o})()));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StacksBns=e():t.StacksBns=e()}(this,()=>(()=>{var t,e,n={74:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const r=n(452);if(e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function o(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}function s(t){if("string"==typeof t&&(t=o(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}e.bytesToHex=function(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=i[t[n]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e},e.nextTick=async()=>{},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=o,e.toBytes=s,e.concatBytes=function(...t){if(!t.every(t=>t instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n},e.Hash=class{clone(){return this._cloneInto()}},e.checkOpts=function(t,e){if(void 0!==e&&("object"!=typeof e||(n=e,"[object Object]"!==Object.prototype.toString.call(n)||n.constructor!==Object)))throw new TypeError("Options should be object or undefined");var n;return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(s(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(s(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto.web)return r.crypto.web.getRandomValues(new Uint8Array(t));if(r.crypto.node)return new Uint8Array(r.crypto.node.randomBytes(t).buffer);throw new Error("The environment doesn't have randomBytes function")}},258:(t,e,n)=>{"use strict";e.ns=e.bJ=void 0;n(669),n(639);const r=n(877);Object.defineProperty(e,"bJ",{enumerable:!0,get:function(){return r.c32address}}),Object.defineProperty(e,"ns",{enumerable:!0,get:function(){return r.c32addressDecode}})},290:(t,e,n)=>{t=n.nmd(t);var r="__lodash_hash_undefined__",i=9007199254740991,o="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",h="[object Number]",l="[object Object]",d="[object Promise]",p="[object RegExp]",y="[object Set]",g="[object String]",b="[object Symbol]",w="[object WeakMap]",m="[object ArrayBuffer]",v="[object DataView]",A="[object Float32Array]",x="[object Float64Array]",E="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",B="[object Uint8Array]",T="[object Uint8ClampedArray]",I="[object Uint16Array]",U="[object Uint32Array]",k=/\w*$/,P=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,$={};$[o]=$["[object Array]"]=$[m]=$[v]=$[s]=$[a]=$[A]=$[x]=$[E]=$[S]=$[C]=$[f]=$[h]=$[l]=$[p]=$[y]=$[g]=$[b]=$[B]=$[T]=$[I]=$[U]=!0,$["[object Error]"]=$[c]=$[w]=!1;var O="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,H="object"==typeof self&&self&&self.Object===Object&&self,_=O||H||Function("return this")(),L=e&&!e.nodeType&&e,j=L&&t&&!t.nodeType&&t,M=j&&j.exports===L;function F(t,e){return t.set(e[0],e[1]),t}function R(t,e){return t.add(e),t}function D(t,e,n,r){var i=-1,o=t?t.length:0;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function K(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function V(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function z(t,e){return function(n){return t(e(n))}}function W(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var q,G=Array.prototype,Z=Function.prototype,J=Object.prototype,X=_["__core-js_shared__"],Q=(q=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Y=Z.toString,tt=J.hasOwnProperty,et=J.toString,nt=RegExp("^"+Y.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=M?_.Buffer:void 0,it=_.Symbol,ot=_.Uint8Array,st=z(Object.getPrototypeOf,Object),at=Object.create,ct=J.propertyIsEnumerable,ut=G.splice,ft=Object.getOwnPropertySymbols,ht=rt?rt.isBuffer:void 0,lt=z(Object.keys,Object),dt=_t(_,"DataView"),pt=_t(_,"Map"),yt=_t(_,"Promise"),gt=_t(_,"Set"),bt=_t(_,"WeakMap"),wt=_t(Object,"create"),mt=Rt(dt),vt=Rt(pt),At=Rt(yt),xt=Rt(gt),Et=Rt(bt),St=it?it.prototype:void 0,Ct=St?St.valueOf:void 0;function Bt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function It(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Ut(t){this.__data__=new Tt(t)}function kt(t,e,n){var r=t[e];tt.call(t,e)&&Dt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function Pt(t,e){for(var n=t.length;n--;)if(Dt(t[n][0],e))return n;return-1}function Nt(t,e,n,r,i,d,w){var P;if(r&&(P=d?r(t,i,d,w):r(t)),void 0!==P)return P;if(!qt(t))return t;var N=Kt(t);if(N){if(P=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,P)}else{var O=jt(t),H=O==c||O==u;if(zt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(O==l||O==o||H&&!d){if(K(t))return d?t:{};if(P=function(t){return"function"!=typeof t.constructor||Ft(t)?{}:qt(e=st(t))?at(e):{};var e}(H?{}:t),!e)return function(t,e){return Ot(t,Lt(t),e)}(t,function(t,e){return t&&Ot(e,Gt(e),t)}(P,t))}else{if(!$[O])return d?t:{};P=function(t,e,n,r){var i,o=t.constructor;switch(e){case m:return $t(t);case s:case a:return new o(+t);case v:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case A:case x:case E:case S:case C:case B:case T:case I:case U:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return D(e?n(V(t),!0):V(t),F,new t.constructor)}(t,r,n);case h:case g:return new o(t);case p:return function(t){var e=new t.constructor(t.source,k.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,n){return D(e?n(W(t),!0):W(t),R,new t.constructor)}(t,r,n);case b:return i=t,Ct?Object(Ct.call(i)):{}}}(t,O,Nt,e)}}w||(w=new Ut);var _=w.get(t);if(_)return _;if(w.set(t,P),!N)var L=n?function(t){return function(t,e,n){var r=e(t);return Kt(t)?r:function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}(r,n(t))}(t,Gt,Lt)}(t):Gt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(L||t,function(i,o){L&&(i=t[o=i]),kt(P,o,Nt(i,e,n,r,o,t,w))}),P}function $t(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Ot(t,e,n,r){n||(n={});for(var i=-1,o=e.length;++i<o;){var s=e[i],a=r?r(n[s],t[s],s,n,t):void 0;kt(n,s,void 0===a?t[s]:a)}return n}function Ht(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function _t(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!qt(t)||(e=t,Q&&Q in e))&&(Wt(t)||K(t)?nt:P).test(Rt(t));var e}(n)?n:void 0}Bt.prototype.clear=function(){this.__data__=wt?wt(null):{}},Bt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Bt.prototype.get=function(t){var e=this.__data__;if(wt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},Bt.prototype.has=function(t){var e=this.__data__;return wt?void 0!==e[t]:tt.call(e,t)},Bt.prototype.set=function(t,e){return this.__data__[t]=wt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=Pt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=Pt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return Pt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=Pt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},It.prototype.clear=function(){this.__data__={hash:new Bt,map:new(pt||Tt),string:new Bt}},It.prototype.delete=function(t){return Ht(this,t).delete(t)},It.prototype.get=function(t){return Ht(this,t).get(t)},It.prototype.has=function(t){return Ht(this,t).has(t)},It.prototype.set=function(t,e){return Ht(this,t).set(t,e),this},Ut.prototype.clear=function(){this.__data__=new Tt},Ut.prototype.delete=function(t){return this.__data__.delete(t)},Ut.prototype.get=function(t){return this.__data__.get(t)},Ut.prototype.has=function(t){return this.__data__.has(t)},Ut.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!pt||r.length<199)return r.push([t,e]),this;n=this.__data__=new It(r)}return n.set(t,e),this};var Lt=ft?z(ft,Object):function(){return[]},jt=function(t){return et.call(t)};function Mt(t,e){return!!(e=null==e?i:e)&&("number"==typeof t||N.test(t))&&t>-1&&t%1==0&&t<e}function Ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||J)}function Rt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Dt(t,e){return t===e||t!=t&&e!=e}(dt&&jt(new dt(new ArrayBuffer(1)))!=v||pt&&jt(new pt)!=f||yt&&jt(yt.resolve())!=d||gt&&jt(new gt)!=y||bt&&jt(new bt)!=w)&&(jt=function(t){var e=et.call(t),n=e==l?t.constructor:void 0,r=n?Rt(n):void 0;if(r)switch(r){case mt:return v;case vt:return f;case At:return d;case xt:return y;case Et:return w}return e});var Kt=Array.isArray;function Vt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}(t.length)&&!Wt(t)}var zt=ht||function(){return!1};function Wt(t){var e=qt(t)?et.call(t):"";return e==c||e==u}function qt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Gt(t){return Vt(t)?function(t,e){var n=Kt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Vt(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==o)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,i=!!r;for(var s in t)!e&&!tt.call(t,s)||i&&("length"==s||Mt(s,r))||n.push(s);return n}(t):function(t){if(!Ft(t))return lt(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Nt(t,!0,!0)}},403:t=>{"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var f=t.charCodeAt(n);if(f>255)return;var h=e[f];if(255===h)return;for(var l=0,d=o-1;(0!==h||l<i)&&-1!==d;d--,l++)h+=s*u[d]>>>0,u[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var y=new Uint8Array(r+(o-p)),g=r;p!==o;)y[g++]=u[p++];return y}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,d=c-1;(0!==h||l<r)&&-1!==d;d--,l++)h+=256*f[d]>>>0,f[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=l,i++}for(var p=c-r;p!==c&&0===f[p];)p++;for(var y=a.repeat(n);p<c;++p)y+=t.charAt(f[p]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},414:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=void 0;const r=n(688),i=n(74),o=n(403),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";e.encode=function(t,e="00"){const n="string"==typeof t?(0,i.hexToBytes)(t):t,a="string"==typeof e?(0,i.hexToBytes)(e):t;if(!(n instanceof Uint8Array&&a instanceof Uint8Array))throw new TypeError("Argument must be of type Uint8Array or string");const c=(0,r.sha256)((0,r.sha256)(new Uint8Array([...a,...n])));return o(s).encode([...a,...n,...c.slice(0,4)])},e.decode=function(t){const e=o(s).decode(t),n=e.slice(0,1),i=e.slice(1,-4),a=(0,r.sha256)((0,r.sha256)(new Uint8Array([...n,...i])));return e.slice(-4).forEach((t,e)=>{if(t!==a[e])throw new Error("Invalid checksum")}),{prefix:n,data:i}}},452:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto={node:void 0,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0}},460:(t,e)=>{"use strict";function n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function r(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(t.outputLen),n(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){i(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=void 0,e.number=n,e.bool=r,e.bytes=i,e.hash=o,e.exists=s,e.output=a;const c={number:n,bool:r,bytes:i,hash:o,exists:s,output:a};e.default=c},546:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const r=n(460),i=n(74);class o extends i.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){r.default.exists(this);const{view:e,buffer:n,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let r=0;r<s;){const a=Math.min(o-this.pos,s-r);if(a===o){const e=(0,i.createView)(t);for(;o<=s-r;r+=o)this.process(e,r);continue}n.set(t.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){r.default.exists(this),r.default.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,o-8,BigInt(8*this.length),s),this.process(n,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)c.setUint32(4*t,h[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}e.SHA2=o},639:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32checkDecode=e.c32checkEncode=void 0;const r=n(688),i=n(74),o=n(669);function s(t){const e=(0,r.sha256)((0,r.sha256)((0,i.hexToBytes)(t)));return(0,i.bytesToHex)(e.slice(0,4))}e.c32checkEncode=function(t,e){if(t<0||t>=32)throw new Error("Invalid version (must be between 0 and 31)");if(!e.match(/^[0-9a-fA-F]*$/))throw new Error("Invalid data (not a hex string)");(e=e.toLowerCase()).length%2!=0&&(e=`0${e}`);let n=t.toString(16);1===n.length&&(n=`0${n}`);const r=s(`${n}${e}`),i=(0,o.c32encode)(`${e}${r}`);return`${o.c32[t]}${i}`},e.c32checkDecode=function(t){t=(0,o.c32normalize)(t);const e=(0,o.c32decode)(t.slice(1)),n=t[0],r=o.c32.indexOf(n),i=e.slice(-8);let a=r.toString(16);if(1===a.length&&(a=`0${a}`),s(`${a}${e.substring(0,e.length-8)}`)!==i)throw new Error("Invalid c32check string: checksum mismatch");return[r,e.substring(0,e.length-8)]}},669:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32decode=e.c32normalize=e.c32encode=e.c32=void 0;const r=n(74);e.c32="0123456789ABCDEFGHJKMNPQRSTVWXYZ";const i="0123456789abcdef";function o(t){return t.toUpperCase().replace(/O/g,"0").replace(/L|I/g,"1")}e.c32encode=function(t,n){if(!t.match(/^[0-9a-fA-F]*$/))throw new Error("Not a hex-encoded string");t.length%2!=0&&(t=`0${t}`);let o=[],s=0;for(let n=(t=t.toLowerCase()).length-1;n>=0;n--)if(s<4){const r=i.indexOf(t[n])>>s;let a=0;0!==n&&(a=i.indexOf(t[n-1]));const c=1+s,u=a%(1<<c)<<5-c,f=e.c32[r+u];s=c,o.unshift(f)}else s=0;let a=0;for(let t=0;t<o.length&&"0"===o[t];t++)a++;o=o.slice(a);const c=(new TextDecoder).decode((0,r.hexToBytes)(t)).match(/^\u0000*/),u=c?c[0].length:0;for(let t=0;t<u;t++)o.unshift(e.c32[0]);if(n){const t=n-o.length;for(let n=0;n<t;n++)o.unshift(e.c32[0])}return o.join("")},e.c32normalize=o,e.c32decode=function(t,n){if(!(t=o(t)).match(`^[${e.c32}]*$`))throw new Error("Not a c32-encoded string");const r=t.match(`^${e.c32[0]}*`),s=r?r[0].length:0;let a=[],c=0,u=0;for(let n=t.length-1;n>=0;n--){4===u&&(a.unshift(i[c]),u=0,c=0);const r=(e.c32.indexOf(t[n])<<u)+c,o=i[r%16];if(u+=1,c=r>>4,c>1<<u)throw new Error("Panic error in decoding.");a.unshift(o)}a.unshift(i[c]),a.length%2==1&&a.unshift("0");let f=0;for(let t=0;t<a.length&&"0"===a[t];t++)f++;a=a.slice(f-f%2);let h=a.join("");for(let t=0;t<s;t++)h=`00${h}`;if(n){const t=2*n-h.length;for(let e=0;e<t;e+=2)h=`00${h}`}return h}},688:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const r=n(546),i=n(74),o=(t,e,n)=>t&e^~t&n,s=(t,e,n)=>t&e^t&n^e&n,a=new Uint32Array([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]),c=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64);class f extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4],this.F=0|c[5],this.G=0|c[6],this.H=0|c[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)u[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=u[t-15],n=u[t-2],r=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(n,17)^(0,i.rotr)(n,19)^n>>>10;u[t]=o+u[t-7]+r+u[t-16]|0}let{A:n,B:r,C:c,D:f,E:h,F:l,G:d,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(h,6)^(0,i.rotr)(h,11)^(0,i.rotr)(h,25))+o(h,l,d)+a[t]+u[t]|0,y=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+s(n,r,c)|0;p=d,d=l,l=h,h=f+e|0,f=c,c=r,r=n,n=e+y|0}n=n+this.A|0,r=r+this.B|0,c=c+this.C|0,f=f+this.D|0,h=h+this.E|0,l=l+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(n,r,c,f,h,l,d,p)}roundClean(){u.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class h extends f{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)(()=>new f),e.sha224=(0,i.wrapConstructor)(()=>new h)},877:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32ToB58=e.b58ToC32=e.c32addressDecode=e.c32address=e.versions=void 0;const r=n(639),i=n(414),o=n(74);e.versions={mainnet:{p2pkh:22,p2sh:20},testnet:{p2pkh:26,p2sh:21}};const s={};s[0]=e.versions.mainnet.p2pkh,s[5]=e.versions.mainnet.p2sh,s[111]=e.versions.testnet.p2pkh,s[196]=e.versions.testnet.p2sh;const a={};function c(t,e){if(!e.match(/^[0-9a-fA-F]{40}$/))throw new Error("Invalid argument: not a hash160 hex string");return`S${(0,r.c32checkEncode)(t,e)}`}function u(t){if(t.length<=5)throw new Error("Invalid c32 address: invalid length");if("S"!=t[0])throw new Error('Invalid c32 address: must start with "S"');return(0,r.c32checkDecode)(t.slice(1))}a[e.versions.mainnet.p2pkh]=0,a[e.versions.mainnet.p2sh]=5,a[e.versions.testnet.p2pkh]=111,a[e.versions.testnet.p2sh]=196,e.c32address=c,e.c32addressDecode=u,e.b58ToC32=function(t,e=-1){const n=i.decode(t),r=(0,o.bytesToHex)(n.data),a=parseInt((0,o.bytesToHex)(n.prefix),16);let u;return e<0?(u=a,void 0!==s[a]&&(u=s[a])):u=e,c(u,r)},e.c32ToB58=function(t,e=-1){const n=u(t),r=n[0],o=n[1];let s;e<0?(s=r,void 0!==a[r]&&(s=a[r])):s=e;let c=s.toString(16);return 1===c.length&&(c=`0${c}`),i.encode(o,c)}},976:()=>{}},r={};function i(t){var e=r[t];if(void 0!==e)return e.exports;var o=r[t]={id:t,loaded:!1,exports:{}};return n[t](o,o.exports,i),o.loaded=!0,o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var o=Object.create(null);i.r(o);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach(t=>s[t]=()=>n[t]);return s.default=()=>n,i.d(o,s),o},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var o={};return(()=>{"use strict";function t(t,n){return a(e(t),n)}function e(t){if("bigint"==typeof t)return t;if("string"==typeof t)return BigInt(t);if("number"==typeof t){if(!Number.isInteger(t))throw new RangeError("Invalid value. Values of type 'number' must be an integer.");if(t>Number.MAX_SAFE_INTEGER)throw new RangeError(`Invalid value. Values of type 'number' must be less than or equal to ${Number.MAX_SAFE_INTEGER}. For larger values, try using a BigInt instead.`);return BigInt(t)}if(v(t,Uint8Array))return BigInt(`0x${f(t)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function n(t){if("string"!=typeof t)throw new TypeError("hexToBigInt: expected string, got "+typeof t);return BigInt(`0x${t}`)}function r(t,n=8){return("bigint"==typeof t?t:e(t)).toString(16).padStart(2*n,"0")}function s(t){return parseInt(t,16)}function a(t,e=16){return h(r(t,e))}function c(t){return e=BigInt(`0x${f(t)}`),n=BigInt(8*t.byteLength),function(t,e){return t&BigInt(1)<<e}(e,n-BigInt(1))?e-(BigInt(1)<<n):e;var e,n}i.r(o),i.d(o,{BNS_CONTRACT_NAME:()=>Fi,buildImportNameTx:()=>Gi,buildPreorderNameTx:()=>Ji,buildPreorderNamespaceTx:()=>Wi,buildReadyNamespaceTx:()=>Zi,buildRegisterNameTx:()=>Xi,buildRenewNameTx:()=>eo,buildRevealNamespaceTx:()=>qi,buildRevokeNameTx:()=>to,buildTransferNameTx:()=>Yi,buildUpdateNameTx:()=>Qi,canRegisterName:()=>Ki,getNamePrice:()=>zi,getNamespacePrice:()=>Vi});const u=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function f(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(const n of t)e+=u[n];return e}function h(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);var e;t=(e=t,t=/^0x/i.test(e)?e.slice(2):e).length%2?`0${t}`:t;const n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++){const r=2*e,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[e]=o}return n}function l(t){return(new TextEncoder).encode(t)}function d(t){return(new TextDecoder).decode(t)}function p(t){const e=[];for(let n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return new Uint8Array(e)}function y(t){return String.fromCharCode.apply(null,t)}function g(t){return!Number.isInteger(t)||t<0||t>255}function b(t){if(t.some(g))throw new Error("Some values are invalid bytes.");return new Uint8Array(t)}function w(...t){if(!t.every(t=>t instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}function m(t){return w(...t.map(t=>"number"==typeof t?b([t]):t instanceof Array?b(t):t))}function v(t,e){return t instanceof e||t?.constructor?.name?.toLowerCase()===e.name}const A=33,x={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}};async function E(t,e){const n={};return Object.assign(n,x,e),await fetch(t,n)}function S(...t){const{fetchLib:e,middlewares:n}=function(t){let e=E,n=[];return t.length>0&&"function"==typeof t[0]&&(e=t.shift()),t.length>0&&(n=t),{fetchLib:e,middlewares:n}}(t);return async(t,r)=>{let i={url:t,init:r??{}};for(const t of n)"function"==typeof t.pre&&(i=await Promise.resolve(t.pre({fetch:e,...i}))??i);let o=await e(i.url,i.init);for(const t of n)if("function"==typeof t.post){const n=await Promise.resolve(t.post({fetch:e,url:i.url,init:i.init,response:o?.clone()??o}));o=n??o}return o}}var C,B,T,I,U;!function(t){t[t.Mainnet=1]="Mainnet",t[t.Testnet=2147483648]="Testnet"}(C||(C={})),function(t){t[t.Mainnet=385875968]="Mainnet",t[t.Testnet=4278190080]="Testnet"}(B||(B={})),C.Mainnet,(U=T||(T={}))[U.Mainnet=0]="Mainnet",U[U.Testnet=128]="Testnet",function(t){t[t.MainnetSingleSig=22]="MainnetSingleSig",t[t.MainnetMultiSig=20]="MainnetMultiSig",t[t.TestnetSingleSig=26]="TestnetSingleSig",t[t.TestnetMultiSig=21]="TestnetMultiSig"}(I||(I={})),T.Mainnet;const k={chainId:C.Mainnet,transactionVersion:T.Mainnet,peerNetworkId:B.Mainnet,magicBytes:"X2",bootAddress:"SP000000000000000000002Q6VF78",addressVersion:{singleSig:I.MainnetSingleSig,multiSig:I.MainnetMultiSig},client:{baseUrl:"https://api.mainnet.hiro.so"}},P={chainId:C.Testnet,transactionVersion:T.Testnet,peerNetworkId:B.Testnet,magicBytes:"T2",bootAddress:"ST000000000000000000002AMW42H",addressVersion:{singleSig:I.TestnetSingleSig,multiSig:I.TestnetMultiSig},client:{baseUrl:"https://api.testnet.hiro.so"}},N={...P,addressVersion:{...P.addressVersion},magicBytes:"id",client:{baseUrl:"http://localhost:3999"}},$={...N,addressVersion:{...N.addressVersion},client:{...N.client}};function O(t){return"string"==typeof t?function(t){switch(t){case"mainnet":return k;case"testnet":return P;case"devnet":return N;case"mocknet":return $;default:throw new Error(`Unknown network name: ${t}`)}}(t):t}function H(t){return t.client.fetch?t.client:{...t.client,fetch:S()}}var _=i(258);function L(t,e,n=0){return t[n+3]=e,e>>>=8,t[n+2]=e,e>>>=8,t[n+1]=e,e>>>=8,t[n]=e,t}const j=128,M=128,F=16,R=65,D=34;var K,V,z,W,q,G;(G=K||(K={}))[G.TokenTransfer=0]="TokenTransfer",G[G.SmartContract=1]="SmartContract",G[G.VersionedSmartContract=6]="VersionedSmartContract",G[G.ContractCall=2]="ContractCall",G[G.PoisonMicroblock=3]="PoisonMicroblock",G[G.Coinbase=4]="Coinbase",G[G.CoinbaseToAltRecipient=5]="CoinbaseToAltRecipient",G[G.TenureChange=7]="TenureChange",G[G.NakamotoCoinbase=8]="NakamotoCoinbase",(q=V||(V={}))[q.Clarity1=1]="Clarity1",q[q.Clarity2=2]="Clarity2",q[q.Clarity3=3]="Clarity3",q[q.Clarity4=4]="Clarity4",q[q.Clarity5=5]="Clarity5",(W=z||(z={}))[W.OnChainOnly=1]="OnChainOnly",W[W.OffChainOnly=2]="OffChainOnly",W[W.Any=3]="Any";var Z,J,X,Q,Y,tt,et,nt,rt,it,ot,st,at,ct,ut,ft,ht,lt,dt,pt;z.OnChainOnly,z.OffChainOnly,z.Any,z.OnChainOnly,z.OnChainOnly,z.OffChainOnly,z.OffChainOnly,z.Any,z.Any,(pt=Z||(Z={}))[pt.Allow=1]="Allow",pt[pt.Deny=2]="Deny",pt[pt.Originator=3]="Originator",(dt=J||(J={}))[dt.STX=0]="STX",dt[dt.Fungible=1]="Fungible",dt[dt.NonFungible=2]="NonFungible",(lt=X||(X={}))[lt.Standard=4]="Standard",lt[lt.Sponsored=5]="Sponsored",(ht=Q||(Q={}))[ht.P2PKH=0]="P2PKH",ht[ht.P2SH=1]="P2SH",ht[ht.P2WPKH=2]="P2WPKH",ht[ht.P2WSH=3]="P2WSH",ht[ht.P2SHNonSequential=5]="P2SHNonSequential",ht[ht.P2WSHNonSequential=7]="P2WSHNonSequential",(ft=Y||(Y={}))[ft.Compressed=0]="Compressed",ft[ft.Uncompressed=1]="Uncompressed",function(t){t[t.Equal=1]="Equal",t[t.Greater=2]="Greater",t[t.GreaterEqual=3]="GreaterEqual",t[t.Less=4]="Less",t[t.LessEqual=5]="LessEqual"}(tt||(tt={})),function(t){t[t.Sends=16]="Sends",t[t.DoesNotSend=17]="DoesNotSend",t[t.MaybeSent=18]="MaybeSent"}(et||(et={})),(ut=nt||(nt={}))[ut.Origin=1]="Origin",ut[ut.Standard=2]="Standard",ut[ut.Contract=3]="Contract",function(t){t[t.STX=0]="STX",t[t.Fungible=1]="Fungible",t[t.NonFungible=2]="NonFungible"}(rt||(rt={})),(ct=it||(it={}))[ct.BlockFound=0]="BlockFound",ct[ct.Extended=1]="Extended",ct[ct.ExtendedRuntime=2]="ExtendedRuntime",ct[ct.ExtendedReadCount=3]="ExtendedReadCount",ct[ct.ExtendedReadLength=4]="ExtendedReadLength",ct[ct.ExtendedWriteCount=5]="ExtendedWriteCount",ct[ct.ExtendedWriteLength=6]="ExtendedWriteLength",(at=ot||(ot={}))[at.PublicKeyCompressed=0]="PublicKeyCompressed",at[at.PublicKeyUncompressed=1]="PublicKeyUncompressed",at[at.SignatureCompressed=2]="SignatureCompressed",at[at.SignatureUncompressed=3]="SignatureUncompressed",function(t){t.Serialization="Serialization",t.Deserialization="Deserialization",t.SignatureValidation="SignatureValidation",t.FeeTooLow="FeeTooLow",t.BadNonce="BadNonce",t.NotEnoughFunds="NotEnoughFunds",t.NoSuchContract="NoSuchContract",t.NoSuchPublicFunction="NoSuchPublicFunction",t.BadFunctionArgument="BadFunctionArgument",t.ContractAlreadyExists="ContractAlreadyExists",t.PoisonMicroblocksDoNotConflict="PoisonMicroblocksDoNotConflict",t.PoisonMicroblockHasUnknownPubKeyHash="PoisonMicroblockHasUnknownPubKeyHash",t.PoisonMicroblockIsInvalid="PoisonMicroblockIsInvalid",t.BadAddressVersionByte="BadAddressVersionByte",t.NoCoinbaseViaMempool="NoCoinbaseViaMempool",t.ServerFailureNoSuchChainTip="ServerFailureNoSuchChainTip",t.ServerFailureDatabase="ServerFailureDatabase",t.ServerFailureOther="ServerFailureOther"}(st||(st={}));class yt extends Error{constructor(t){super(t),this.message=t,this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class gt extends yt{constructor(t){super(t)}}class bt extends yt{constructor(t){super(t)}}class wt extends yt{constructor(t){super(t)}}class mt extends yt{constructor(t){super(t)}}class vt extends yt{constructor(t){super(t)}}function At(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function xt(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}const Et={number:At,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:xt,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");At(t.outputLen),At(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){xt(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},St=("object"==typeof self&&"crypto"in self&&self.crypto,t=>new DataView(t.buffer,t.byteOffset,t.byteLength)),Ct=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Bt(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));class Tt{clone(){return this._cloneInto()}}function It(t){const e=e=>t().update(Bt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}class Ut extends Tt{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Et.hash(t);const n=Bt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return Et.exists(this),this.iHash.update(t),this}digestInto(t){Et.exists(this),Et.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kt=(t,e,n)=>new Ut(t,e).update(n).digest();kt.create=(t,e)=>new Ut(t,e);class Pt extends Tt{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=St(this.buffer)}update(t){Et.exists(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Bt(t)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const e=St(t);for(;r<=i-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Et.exists(this),Et.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=St(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}const Nt=(t,e,n)=>t&e^~t&n,$t=(t,e,n)=>t&e^t&n^e&n,Ot=new Uint32Array([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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_t=new Uint32Array(64);class Lt extends Pt{constructor(){super(64,32,8,!1),this.A=0|Ht[0],this.B=0|Ht[1],this.C=0|Ht[2],this.D=0|Ht[3],this.E=0|Ht[4],this.F=0|Ht[5],this.G=0|Ht[6],this.H=0|Ht[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)_t[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=_t[t-15],n=_t[t-2],r=Ct(e,7)^Ct(e,18)^e>>>3,i=Ct(n,17)^Ct(n,19)^n>>>10;_t[t]=i+_t[t-7]+r+_t[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(Ct(s,6)^Ct(s,11)^Ct(s,25))+Nt(s,a,c)+Ot[t]+_t[t]|0,f=(Ct(n,2)^Ct(n,13)^Ct(n,22))+$t(n,r,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+f|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,i,o,s,a,c,u)}roundClean(){_t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class jt extends Lt{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const Mt=It(()=>new Lt);It(()=>new jt);var Ft=i(976),Rt=i.t(Ft,2);const Dt=BigInt(0),Kt=BigInt(1),Vt=BigInt(2),zt=BigInt(3),Wt=BigInt(8),qt=Object.freeze({a:Dt,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Kt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Gt=(t,e)=>(t+e/Vt)/e,Zt={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=qt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Kt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Gt(o*t,e),c=Gt(-r*t,e);let u=me(t-a*n-c*i,e),f=me(-a*r-c*o,e);const h=u>s,l=f>s;if(h&&(u=e-u),l&&(f=e-f),u>s||f>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:h,k1:u,k2neg:l,k2:f}}};function Jt(t){const{a:e,b:n}=qt,r=me(t*t),i=me(r*t);return me(i+e*t+n)}const Xt=qt.a===Dt;class Qt extends Error{constructor(t){super(t)}}function Yt(t){if(!(t instanceof te))throw new TypeError("JacobianPoint expected")}class te{constructor(t,e,n){this.x=t,this.y=e,this.z=n}static fromAffine(t){if(!(t instanceof re))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(re.ZERO)?te.ZERO:new te(t.x,t.y,Kt)}static toAffineBatch(t){const e=function(t,e=qt.P){const n=new Array(t.length),r=Ae(t.reduce((t,r,i)=>r===Dt?t:(n[i]=t,me(t*r,e)),Kt),e);return t.reduceRight((t,r,i)=>r===Dt?t:(n[i]=me(t*n[i],e),me(t*r,e)),r),n}(t.map(t=>t.z));return t.map((t,n)=>t.toAffine(e[n]))}static normalizeZ(t){return te.toAffineBatch(t).map(te.fromAffine)}equals(t){Yt(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t,a=me(r*r),c=me(s*s),u=me(e*c),f=me(i*a),h=me(me(n*s)*c),l=me(me(o*r)*a);return u===f&&h===l}negate(){return new te(this.x,me(-this.y),this.z)}double(){const{x:t,y:e,z:n}=this,r=me(t*t),i=me(e*e),o=me(i*i),s=t+i,a=me(Vt*(me(s*s)-r-o)),c=me(zt*r),u=me(c*c),f=me(u-Vt*a),h=me(c*(a-f)-Wt*o),l=me(Vt*e*n);return new te(f,h,l)}add(t){Yt(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t;if(i===Dt||o===Dt)return this;if(e===Dt||n===Dt)return t;const a=me(r*r),c=me(s*s),u=me(e*c),f=me(i*a),h=me(me(n*s)*c),l=me(me(o*r)*a),d=me(f-u),p=me(l-h);if(d===Dt)return p===Dt?this.double():te.ZERO;const y=me(d*d),g=me(d*y),b=me(u*y),w=me(p*p-g-Vt*b),m=me(p*(b-w)-h*g),v=me(r*s*d);return new te(w,m,v)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=te.ZERO;if("bigint"==typeof t&&t===Dt)return e;let n=we(t);if(n===Kt)return this;if(!Xt){let t=e,r=this;for(;n>Dt;)n&Kt&&(t=t.add(r)),r=r.double(),n>>=Kt;return t}let{k1neg:r,k1:i,k2neg:o,k2:s}=Zt.splitScalar(n),a=e,c=e,u=this;for(;i>Dt||s>Dt;)i&Kt&&(a=a.add(u)),s&Kt&&(c=c.add(u)),u=u.double(),i>>=Kt,s>>=Kt;return r&&(a=a.negate()),o&&(c=c.negate()),c=new te(me(c.x*Zt.beta),c.y,c.z),a.add(c)}precomputeWindow(t){const e=Xt?128/t+1:256/t+1,n=[];let r=this,i=r;for(let o=0;o<e;o++){i=r,n.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(r),n.push(i);r=i.double()}return n}wNAF(t,e){!e&&this.equals(te.BASE)&&(e=re.BASE);const n=e&&e._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let r=e&&ne.get(e);r||(r=this.precomputeWindow(n),e&&1!==n&&(r=te.normalizeZ(r),ne.set(e,r)));let i=te.ZERO,o=te.BASE;const s=1+(Xt?128/n:256/n),a=2**(n-1),c=BigInt(2**n-1),u=2**n,f=BigInt(n);for(let e=0;e<s;e++){const n=e*a;let s=Number(t&c);t>>=f,s>a&&(s-=u,t+=Kt);const h=n,l=n+Math.abs(s)-1,d=e%2!=0,p=s<0;0===s?o=o.add(ee(d,r[h])):i=i.add(ee(p,r[l]))}return{p:i,f:o}}multiply(t,e){let n,r,i=we(t);if(Xt){const{k1neg:t,k1:o,k2neg:s,k2:a}=Zt.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:h}=this.wNAF(a,e);c=ee(t,c),f=ee(s,f),f=new te(me(f.x*Zt.beta),f.y,f.z),n=c.add(f),r=u.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);n=t,r=o}return te.normalizeZ([n,r])[0]}toAffine(t){const{x:e,y:n,z:r}=this,i=this.equals(te.ZERO);null==t&&(t=i?Wt:Ae(r));const o=t,s=me(o*o),a=me(s*o),c=me(e*s),u=me(n*a),f=me(r*o);if(i)return re.ZERO;if(f!==Kt)throw new Error("invZ was invalid");return new re(c,u)}}function ee(t,e){const n=e.negate();return t?n:e}te.BASE=new te(qt.Gx,qt.Gy,Kt),te.ZERO=new te(Dt,Kt,Dt);const ne=new WeakMap;class re{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,ne.delete(this)}hasEvenY(){return this.y%Vt===Dt}static fromCompressedHex(t){const e=32===t.length,n=ge(e?t:t.subarray(1));if(!Te(n))throw new Error("Point is not on curve");let r=function(t){const{P:e}=qt,n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,f=ve(u,zt)*u%e,h=ve(f,zt)*u%e,l=ve(h,Vt)*c%e,d=ve(l,r)*l%e,p=ve(d,i)*d%e,y=ve(p,s)*p%e,g=ve(y,a)*y%e,b=ve(g,s)*p%e,w=ve(b,zt)*u%e,m=ve(w,o)*d%e,v=ve(m,n)*c%e,A=ve(v,Vt);if(A*A%e!==t)throw new Error("Cannot find square root");return A}(Jt(n));const i=(r&Kt)===Kt;e?i&&(r=me(-r)):!(1&~t[0])!==i&&(r=me(-r));const o=new re(n,r);return o.assertValidity(),o}static fromUncompressedHex(t){const e=ge(t.subarray(1,33)),n=ge(t.subarray(33,65)),r=new re(e,n);return r.assertValidity(),r}static fromHex(t){const e=be(t),n=e.length,r=e[0];if(32===n)return this.fromCompressedHex(e);if(33===n&&(2===r||3===r))return this.fromCompressedHex(e);if(65===n&&4===r)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(t){return re.BASE.multiply(Ue(t))}static fromSignature(t,e,n){const{r,s:i}=function(t){if(t instanceof se)return t.assertValidity(),t;try{return se.fromDER(t)}catch(e){return se.fromCompact(t)}}(e);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const o=xe(be(t)),{n:s}=qt,a=2===n||3===n?r+s:r,c=Ae(a,s),u=me(-o*c,s),f=me(i*c,s),h=1&n?"03":"02",l=re.fromHex(h+he(a)),d=re.BASE.multiplyAndAddUnsafe(l,u,f);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return ye(this.toHex(t))}toHex(t=!1){const e=he(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${he(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:n}=this;if(!Te(e)||!Te(n))throw new Error(t);const r=me(n*n);if(me(r-Jt(e))!==Dt)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new re(this.x,me(-this.y))}double(){return te.fromAffine(this).double().toAffine()}add(t){return te.fromAffine(this).add(te.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return te.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,n){const r=te.fromAffine(this),i=e===Dt||e===Kt||this!==re.BASE?r.multiplyUnsafe(e):r.multiply(e),o=te.fromAffine(t).multiplyUnsafe(n),s=i.add(o);return s.equals(te.ZERO)?void 0:s.toAffine()}}function ie(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function oe(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${ue(t)}`);const e=t[1],n=t.subarray(2,e+2);if(!e||n.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ge(n),left:t.subarray(e+2)}}re.BASE=new re(qt.Gx,qt.Gy),re.ZERO=new re(Dt,Dt);class se{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,n="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=e?ue(t):t;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new se(pe(r.slice(0,64)),pe(r.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${ue(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:n}=oe(t.subarray(2)),{data:r,left:i}=oe(n);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${ue(i)}`);return{r:e,s:r}}(e?t:ye(t));return new se(n,r)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!Be(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Be(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=qt.n>>Kt;return this.s>t}normalizeS(){return this.hasHighS()?new se(this.r,me(-this.s,qt.n)):this}toDERRawBytes(){return ye(this.toDERHex())}toDERHex(){const t=ie(de(this.s)),e=ie(de(this.r)),n=t.length/2,r=e.length/2,i=de(n),o=de(r);return`30${de(r+n+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ye(this.toCompactHex())}toCompactHex(){return he(this.r)+he(this.s)}}function ae(...t){if(!t.every(t=>t instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}const ce=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ue(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let n=0;n<t.length;n++)e+=ce[t[n]];return e}const fe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function he(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(Dt<=t&&t<fe))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function le(t){const e=ye(he(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function de(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function pe(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function ye(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e}function ge(t){return pe(ue(t))}function be(t){return t instanceof Uint8Array?Uint8Array.from(t):ye(t)}function we(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&Be(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function me(t,e=qt.P){const n=t%e;return n>=Dt?n:e+n}function ve(t,e){const{P:n}=qt;let r=t;for(;e-- >Dt;)r*=r,r%=n;return r}function Ae(t,e=qt.P){if(t===Dt||e<=Dt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=me(t,e),r=e,i=Dt,o=Kt,s=Kt,a=Dt;for(;n!==Dt;){const t=r/n,e=r%n,c=i-s*t,u=o-a*t;r=n,n=e,i=s,o=a,s=c,a=u}if(r!==Kt)throw new Error("invert: does not exist");return me(i,e)}function xe(t,e=!1){const n=function(t){const e=8*t.length-256,n=ge(t);return e>0?n>>BigInt(e):n}(t);if(e)return n;const{n:r}=qt;return n>=r?n-r:n}let Ee,Se;class Ce{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,"number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return He.hmacSha256(this.k,...t)}hmacSync(...t){return Se(this.k,...t)}checkSync(){if("function"!=typeof Se)throw new Qt("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=await this.hmac(this.v);const n=this.v.slice();e.push(n),t+=this.v.length}return ae(...e)}generateSync(){this.checkSync(),this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=this.hmacSync(this.v);const n=this.v.slice();e.push(n),t+=this.v.length}return ae(...e)}}function Be(t){return Dt<t&&t<qt.n}function Te(t){return Dt<t&&t<qt.P}function Ie(t,e,n,r=!0){const{n:i}=qt,o=xe(t,!0);if(!Be(o))return;const s=Ae(o,i),a=re.BASE.multiply(o),c=me(a.x,i);if(c===Dt)return;const u=me(s*me(e+n*c,i),i);if(u===Dt)return;let f=new se(c,u),h=(a.x===f.r?0:2)|Number(a.y&Kt);return r&&f.hasHighS()&&(f=f.normalizeS(),h^=1),{sig:f,recovery:h}}function Ue(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private key");e=pe(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==t.length)throw new Error("Expected 32 bytes of private key");e=ge(t)}if(!Be(e))throw new Error("Expected private key: 0 < key < n");return e}function ke(t){return ge(t.length>32?t.slice(0,32):t)}function Pe(t){const e=ke(t),n=me(e,qt.n);return Ne(n<Dt?e:n)}function Ne(t){return le(t)}re.BASE._setWindowSize(8);const $e={node:Rt,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},Oe={},He={bytesToHex:ue,hexToBytes:ye,concatBytes:ae,mod:me,invert:Ae,isValidPrivateKey(t){try{return Ue(t),!0}catch(t){return!1}},_bigintTo32Bytes:le,_normalizePrivateKey:Ue,hashToPrivateKey:t=>{if((t=be(t)).length<40||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return le(me(ge(t),qt.n-Kt)+Kt)},randomBytes:(t=32)=>{if($e.web)return $e.web.getRandomValues(new Uint8Array(t));if($e.node){const{randomBytes:e}=$e.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>He.hashToPrivateKey(He.randomBytes(40)),precompute(t=8,e=re.BASE){const n=e===re.BASE?e:new re(e.x,e.y);return n._setWindowSize(t),n.multiply(zt),n},sha256:async(...t)=>{if($e.web){const e=await $e.web.subtle.digest("SHA-256",ae(...t));return new Uint8Array(e)}if($e.node){const{createHash:e}=$e.node,n=e("sha256");return t.forEach(t=>n.update(t)),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if($e.web){const n=await $e.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),r=ae(...e),i=await $e.web.subtle.sign("HMAC",n,r);return new Uint8Array(i)}if($e.node){const{createHmac:n}=$e.node,r=n("sha256",t);return e.forEach(t=>r.update(t)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...e)=>{let n=Oe[t];if(void 0===n){const e=await He.sha256(Uint8Array.from(t,t=>t.charCodeAt(0)));n=ae(e,e),Oe[t]=n}return He.sha256(n,...e)},taggedHashSync:(t,...e)=>{if("function"!=typeof Ee)throw new Qt("sha256Sync is undefined, you need to set it");let n=Oe[t];if(void 0===n){const e=Ee(Uint8Array.from(t,t=>t.charCodeAt(0)));n=ae(e,e),Oe[t]=n}return Ee(n,...e)},_JacobianPoint:te};function _e(t){const e="string"==typeof t?h(t):t;if(32!=e.length&&33!=e.length)throw new Error(`Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: ${e.length}`);if(33==e.length&&1!==e[32])throw new Error("Improperly formatted private-key. 33 bytes indicate compressed key, but the last byte must be == 01");return e}Object.defineProperties(He,{sha256Sync:{configurable:!1,get:()=>Ee,set(t){Ee||(Ee=t)}},hmacSha256Sync:{configurable:!1,get:()=>Se,set(t){Se||(Se=t)}}});const Le=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),je=Uint8Array.from({length:16},(t,e)=>e),Me=je.map(t=>(9*t+5)%16);let Fe=[je],Re=[Me];for(let t=0;t<4;t++)for(let e of[Fe,Re])e.push(e[t].map(t=>Le[t]));const De=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),Ke=Fe.map((t,e)=>t.map(t=>De[e][t])),Ve=Re.map((t,e)=>t.map(t=>De[e][t])),ze=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),We=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),qe=(t,e)=>t<<e|t>>>32-e;function Ge(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const Ze=new Uint32Array(16);class Je extends Pt{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:n,h3:r,h4:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.h0=0|t,this.h1=0|e,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)Ze[n]=t.getUint32(e,!0);let n=0|this.h0,r=n,i=0|this.h1,o=i,s=0|this.h2,a=s,c=0|this.h3,u=c,f=0|this.h4,h=f;for(let t=0;t<5;t++){const e=4-t,l=ze[t],d=We[t],p=Fe[t],y=Re[t],g=Ke[t],b=Ve[t];for(let e=0;e<16;e++){const r=qe(n+Ge(t,i,s,c)+Ze[p[e]]+l,g[e])+f|0;n=f,f=c,c=0|qe(s,10),s=i,i=r}for(let t=0;t<16;t++){const n=qe(r+Ge(e,o,a,u)+Ze[y[t]]+d,b[t])+h|0;r=h,h=u,u=0|qe(a,10),a=o,o=n}}this.set(this.h1+s+u|0,this.h2+c+h|0,this.h3+f+r|0,this.h4+n+o|0,this.h0+i+a|0)}roundClean(){Ze.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Xe=It(()=>new Je),Qe=BigInt(2**32-1),Ye=BigInt(32);function tn(t,e=!1){return e?{h:Number(t&Qe),l:Number(t>>Ye&Qe)}:{h:0|Number(t>>Ye&Qe),l:0|Number(t&Qe)}}const en=function(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=tn(t[i],e);[n[i],r[i]]=[o,s]}return[n,r]},nn=(t,e,n)=>t>>>n,rn=(t,e,n)=>t<<32-n|e>>>n,on=(t,e,n)=>t>>>n|e<<32-n,sn=(t,e,n)=>t<<32-n|e>>>n,an=(t,e,n)=>t<<64-n|e>>>n-32,cn=(t,e,n)=>t>>>n-32|e<<64-n,un=function(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}},fn=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),hn=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,ln=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),dn=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,pn=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,yn=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),[gn,bn]=en(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),wn=new Uint32Array(80),mn=new Uint32Array(80);class vn extends Pt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:d,Hh:p,Hl:y}=this;return[t,e,n,r,i,o,s,a,c,u,f,h,l,d,p,y]}set(t,e,n,r,i,o,s,a,c,u,f,h,l,d,p,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)wn[n]=t.getUint32(e),mn[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|wn[t-15],n=0|mn[t-15],r=on(e,n,1)^on(e,n,8)^nn(e,n,7),i=sn(e,n,1)^sn(e,n,8)^rn(e,n,7),o=0|wn[t-2],s=0|mn[t-2],a=on(o,s,19)^an(o,s,61)^nn(o,s,6),c=sn(o,s,19)^cn(o,s,61)^rn(o,s,6),u=ln(i,c,mn[t-7],mn[t-16]),f=dn(u,r,a,wn[t-7],wn[t-16]);wn[t]=0|f,mn[t]=0|u}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:f,El:h,Fh:l,Fl:d,Gh:p,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=on(f,h,14)^on(f,h,18)^an(f,h,41),w=sn(f,h,14)^sn(f,h,18)^cn(f,h,41),m=f&l^~f&p,v=yn(b,w,h&d^~h&y,bn[t],mn[t]),A=pn(v,g,e,m,gn[t],wn[t]),x=0|v,E=on(n,r,28)^an(n,r,34)^an(n,r,39),S=sn(n,r,28)^cn(n,r,34)^cn(n,r,39),C=n&i^n&s^i&s,B=r&o^r&a^o&a;g=0|p,b=0|y,p=0|l,y=0|d,l=0|f,d=0|h,({h:f,l:h}=un(0|c,0|u,0|A,0|x)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const T=fn(x,S,B);n=hn(T,A,E,C),r=0|T}({h:n,l:r}=un(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=un(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=un(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=un(0|this.Dh,0|this.Dl,0|c,0|u)),({h:f,l:h}=un(0|this.Eh,0|this.El,0|f,0|h)),({h:l,l:d}=un(0|this.Fh,0|this.Fl,0|l,0|d)),({h:p,l:y}=un(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:b}=un(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(n,r,i,o,s,a,c,u,f,h,l,d,p,y,g,b)}roundClean(){wn.fill(0),mn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class An extends vn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class xn extends vn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class En extends vn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}It(()=>new vn),It(()=>new An);const Sn=It(()=>new xn);It(()=>new En);var Cn=i(290),Bn=i.n(Cn);const Tn=new Map;function In(t,e){const n=Tn.get(t);if(void 0!==n)return n(e);const r=function(t){const e=Object.values(t).filter(t=>"number"==typeof t),n=new Set(e);return t=>n.has(t)}(t);return Tn.set(t,r),In(t,e)}class Un{constructor(t){this.consumed=0,this.source="string"==typeof t?h(t):t}readBytes(t){const e=this.source.subarray(this.consumed,this.consumed+t);return this.consumed+=t,e}readUInt32BE(){return(t=this.readBytes(4))[0]*2**24+65536*t[1]+256*t[2]+t[3];var t}readUInt8(){return this.readBytes(1)[0]}readUInt16BE(){return((t=this.readBytes(2))[0+0]<<8|t[1])>>>0;var t}readBigUIntLE(t){const e=f(this.readBytes(t).slice().reverse());return BigInt(`0x${e}`)}readBigUIntBE(t){const e=f(this.readBytes(t));return BigInt(`0x${e}`)}get readOffset(){return this.consumed}set readOffset(t){this.consumed=t}get internalBytes(){return this.source}readUInt8Enum(t,e){const n=this.readUInt8();if(In(t,n))return n;throw e(n)}}var kn,Pn,Nn;function $n(t){return Pn[t]}(Nn=kn||(kn={})).Int="int",Nn.UInt="uint",Nn.Buffer="buffer",Nn.BoolTrue="true",Nn.BoolFalse="false",Nn.PrincipalStandard="address",Nn.PrincipalContract="contract",Nn.ResponseOk="ok",Nn.ResponseErr="err",Nn.OptionalNone="none",Nn.OptionalSome="some",Nn.List="list",Nn.Tuple="tuple",Nn.StringASCII="ascii",Nn.StringUTF8="utf8",function(t){t[t.int=0]="int",t[t.uint=1]="uint",t[t.buffer=2]="buffer",t[t.true=3]="true",t[t.false=4]="false",t[t.address=5]="address",t[t.contract=6]="contract",t[t.ok=7]="ok",t[t.err=8]="err",t[t.none=9]="none",t[t.some=10]="some",t[t.list=11]="list",t[t.tuple=12]="tuple",t[t.ascii=13]="ascii",t[t.utf8=14]="utf8"}(Pn||(Pn={}));const On=BigInt("0xffffffffffffffffffffffffffffffff"),Hn=BigInt(0),_n=BigInt("0x7fffffffffffffffffffffffffffffff"),Ln=BigInt("-170141183460469231731687303715884105728"),jn=t=>{"string"==typeof t&&t.toLowerCase().startsWith("0x")&&(t=c(h(t))),v(t,Uint8Array)&&(t=c(t));const n=e(t);if(n>_n)throw new RangeError(`Cannot construct clarity integer from value greater than ${_n}`);if(n<Ln)throw new RangeError(`Cannot construct clarity integer form value less than ${Ln}`);return{type:kn.Int,value:n}},Mn=t=>{const n=e(t);if(n<Hn)throw new RangeError("Cannot construct unsigned clarity integer from negative value");if(n>On)throw new RangeError(`Cannot construct unsigned clarity integer greater than ${On}`);return{type:kn.UInt,value:n}},Fn=t=>{if(t.byteLength>1048576)throw new Error("Cannot construct clarity buffer that is greater than 1MB");return{type:kn.Buffer,value:f(t)}},Rn=t=>Fn(l(t)),Dn=()=>({type:kn.BoolTrue}),Kn=()=>({type:kn.BoolFalse});var Vn,zn;function Wn(t,e){return{type:Vn.LengthPrefixedList,lengthPrefixBytes:e||4,values:t}}function qn(t){if(h(t).byteLength!=R)throw Error("Invalid signature");return{type:Vn.MessageSignature,data:t}}function Gn(t,e,n){const r=e||1,i=n||j;if(Br(t,i))throw new Error(`String length exceeds maximum bytes ${i}`);return{type:Vn.LengthPrefixedString,content:t,lengthPrefixBytes:r,maxLengthBytes:i}}function Zn(t){const e=(0,_.ns)(t);return{type:Vn.Address,version:e[0],hash160:e[1]}}function Jn(t,e){return{pubKeyEncoding:t,type:Vn.TransactionAuthField,contents:e}}function Xn(t,e,n,r){if(0===r.length)throw Error("Invalid number of public keys");if(!(e!==Q.P2PKH&&e!==Q.P2WPKH||1===r.length&&1===n))throw Error("Invalid number of public keys or signatures");if((e===Q.P2WPKH||e===Q.P2WSH||e===Q.P2WSHNonSequential)&&!r.map(t=>t.data).every(Rr))throw Error("Public keys must be compressed for segwit");switch(e){case Q.P2PKH:return Qn(t,kr(r[0].data));case Q.P2WPKH:return Qn(t,Pr(r[0].data));case Q.P2SH:case Q.P2SHNonSequential:return Qn(t,Nr(n,r.map(Ar)));case Q.P2WSH:case Q.P2WSHNonSequential:return Qn(t,$r(n,r.map(Ar)))}}function Qn(t,e){return{type:Vn.Address,version:t,hash160:e}}function Yn(t){return(0,_.bJ)(t.version,t.hash160)}function tr(t){const[e,n,r]=t.split(/\.|::/);var i,o,s;return i=e,o=n,s=r,{type:Vn.Asset,address:Zn(i),contractName:Gn(o),assetName:Gn(s)}}function er(t){if(t.includes(".")){const[e,n]=t.split(".");return function(t,e){const n=Zn(t),r=Gn(e);return{type:Vn.Principal,prefix:nt.Contract,address:n,contractName:r}}(e,n)}return function(t){const e=Zn(t);return{type:Vn.Principal,prefix:nt.Standard,address:e}}(t)}function nr(t){const e=Zn(t);return{type:kn.PrincipalStandard,value:Yn(e)}}function rr(){return{type:kn.OptionalNone}}function ir(t){return{type:kn.OptionalSome,value:t}}function or(t){for(const e in t)if(!Or(e))throw new Error(`"${e}" is not a valid Clarity name`);return{type:kn.Tuple,value:t}}(zn=Vn||(Vn={}))[zn.Address=0]="Address",zn[zn.Principal=1]="Principal",zn[zn.LengthPrefixedString=2]="LengthPrefixedString",zn[zn.MemoString=3]="MemoString",zn[zn.Asset=4]="Asset",zn[zn.PostCondition=5]="PostCondition",zn[zn.PublicKey=6]="PublicKey",zn[zn.LengthPrefixedList=7]="LengthPrefixedList",zn[zn.Payload=8]="Payload",zn[zn.MessageSignature=9]="MessageSignature",zn[zn.StructuredDataSignature=10]="StructuredDataSignature",zn[zn.TransactionAuthField=11]="TransactionAuthField";const sr=t=>({type:kn.StringASCII,value:t}),ar=t=>({type:kn.StringUTF8,value:t});function cr(t){let e;if("string"==typeof t){const n="0x"===t.slice(0,2).toLowerCase();e=new Un(h(n?t.slice(2):t))}else e=t instanceof Uint8Array?new Un(t):t;switch(e.readUInt8Enum(Pn,t=>{throw new bt(`Cannot recognize Clarity Type: ${t}`)})){case Pn.int:return jn(c(e.readBytes(16)));case Pn.uint:return Mn(e.readBytes(16));case Pn.buffer:const t=e.readUInt32BE();return Fn(e.readBytes(t));case Pn.true:return Dn();case Pn.false:return Kn();case Pn.address:return i=hr(e),{type:kn.PrincipalStandard,value:Yn(i)};case Pn.contract:return function(t,e){if(l(e.content).byteLength>=128)throw new Error("Contract name must be less than 128 bytes");return{type:kn.PrincipalContract,value:`${Yn(t)}.${e.content}`}}(hr(e),pr(e));case Pn.ok:return r=cr(e),{type:kn.ResponseOk,value:r};case Pn.err:return function(t){return{type:kn.ResponseErr,value:t}}(cr(e));case Pn.none:return rr();case Pn.some:return ir(cr(e));case Pn.list:const o=e.readUInt32BE(),s=[];for(let t=0;t<o;t++)s.push(cr(e));return n=s,{type:kn.List,value:n};case Pn.tuple:const a=e.readUInt32BE(),u={};for(let t=0;t<a;t++){const t=pr(e).content;if(void 0===t)throw new bt('"content" is undefined');u[t]=cr(e)}return or(u);case Pn.ascii:const f=e.readUInt32BE(),h=y(e.readBytes(f));return sr(h);case Pn.utf8:const p=e.readUInt32BE(),g=d(e.readBytes(p));return ar(g);default:throw new bt("Unable to deserialize Clarity Value from Uint8Array. Could not find valid Clarity Type.")}var n,r,i}function ur(e){switch(e.type){case Vn.Address:return fr(e);case Vn.Principal:return lr(e);case Vn.LengthPrefixedString:return dr(e);case Vn.MemoString:return function(t){const e=[],n=l(t.content),r=Cr(f(n),2*D);return e.push(h(r)),m(e)}(e);case Vn.Asset:return yr(e);case Vn.PostCondition:return function(e){const n=[];if(n.push(e.conditionType),n.push(lr(e.principal)),e.conditionType!==J.Fungible&&e.conditionType!==J.NonFungible||n.push(yr(e.asset)),e.conditionType===J.NonFungible&&n.push(Sr(e.assetName)),n.push(e.conditionCode),e.conditionType===J.STX||e.conditionType===J.Fungible){if(e.amount>BigInt("0xffffffffffffffff"))throw new gt("The post-condition amount may not be larger than 8 bytes");n.push(t(e.amount,8))}return m(n)}(e);case Vn.PublicKey:return Ar(e);case Vn.LengthPrefixedList:return br(e);case Vn.Payload:return mr(e);case Vn.TransactionAuthField:return function(t){const e=[];switch(t.contents.type){case Vn.PublicKey:e.push(t.pubKeyEncoding===Y.Compressed?ot.PublicKeyCompressed:ot.PublicKeyUncompressed),e.push(h((n=t.contents.data,re.fromHex(Mr(n)).toHex(!0))));break;case Vn.MessageSignature:e.push(t.pubKeyEncoding===Y.Compressed?ot.SignatureCompressed:ot.SignatureUncompressed),e.push(vr(t.contents))}var n;return m(e)}(e);case Vn.MessageSignature:return vr(e)}}function fr(t){const e=[];return e.push(h(r(t.version,1))),e.push(h(t.hash160)),m(e)}function hr(t){const e=v(t,Un)?t:new Un(t),n=s(f(e.readBytes(1))),r=f(e.readBytes(20));return{type:Vn.Address,version:n,hash160:r}}function lr(t){const e=[];return e.push(t.prefix),t.prefix!==nt.Standard&&t.prefix!==nt.Contract||e.push(fr(t.address)),t.prefix===nt.Contract&&e.push(dr(t.contractName)),m(e)}function dr(t){const e=[],n=l(t.content),i=n.byteLength;return e.push(h(r(i,t.lengthPrefixBytes))),e.push(n),m(e)}function pr(t,e,n){e=e||1;const r=v(t,Un)?t:new Un(t),i=s(f(r.readBytes(e)));return Gn(d(r.readBytes(i)),e,n??128)}function yr(t){const e=[];return e.push(fr(t.address)),e.push(dr(t.contractName)),e.push(dr(t.assetName)),m(e)}function gr(t){const e=v(t,Un)?t:new Un(t);return{type:Vn.Asset,address:hr(e),contractName:pr(e),assetName:pr(e)}}function br(t){const e=t.values,n=[];n.push(h(r(e.length,t.lengthPrefixBytes)));for(const t of e)n.push(ur(t));return m(n)}function wr(t){const e=v(t,Un)?t:new Un(t),n=e.readUInt8Enum(J,t=>{throw new bt(`Could not read ${t} as PostConditionType`)}),r=function(t){const e=v(t,Un)?t:new Un(t),n=e.readUInt8Enum(nt,t=>{throw new bt(`Unexpected Principal payload type: ${t}`)});if(n===nt.Origin)return{type:Vn.Principal,prefix:n};const r=hr(e);if(n===nt.Standard)return{type:Vn.Principal,prefix:n,address:r};const i=pr(e);return{type:Vn.Principal,prefix:n,address:r,contractName:i}}(e);let i,o,s;switch(n){case J.STX:return i=e.readUInt8Enum(tt,t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)}),s=BigInt(`0x${f(e.readBytes(8))}`),{type:Vn.PostCondition,conditionType:J.STX,principal:r,conditionCode:i,amount:s};case J.Fungible:return o=gr(e),i=e.readUInt8Enum(tt,t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)}),s=BigInt(`0x${f(e.readBytes(8))}`),{type:Vn.PostCondition,conditionType:J.Fungible,principal:r,conditionCode:i,amount:s,asset:o};case J.NonFungible:o=gr(e);const t=cr(e);return i=e.readUInt8Enum(et,t=>{throw new bt(`Could not read ${t} as FungibleConditionCode`)}),{type:Vn.PostCondition,conditionType:J.NonFungible,principal:r,conditionCode:i,asset:o,assetName:t}}}function mr(e){const n=[];switch(n.push(e.payloadType),e.payloadType){case K.TokenTransfer:n.push(Sr(e.recipient)),n.push(t(e.amount,8)),n.push(ur(e.memo));break;case K.ContractCall:n.push(ur(e.contractAddress)),n.push(ur(e.contractName)),n.push(ur(e.functionName));const r=new Uint8Array(4);L(r,e.functionArgs.length,0),n.push(r),e.functionArgs.forEach(t=>{n.push(Sr(t))});break;case K.SmartContract:n.push(ur(e.contractName)),n.push(ur(e.codeBody));break;case K.VersionedSmartContract:n.push(e.clarityVersion),n.push(ur(e.contractName)),n.push(ur(e.codeBody));break;case K.PoisonMicroblock:break;case K.Coinbase:n.push(e.coinbaseBytes);break;case K.CoinbaseToAltRecipient:n.push(e.coinbaseBytes),n.push(Sr(e.recipient));break;case K.NakamotoCoinbase:n.push(e.coinbaseBytes),n.push(Sr(e.recipient?ir(e.recipient):rr())),n.push(e.vrfProof);break;case K.TenureChange:n.push(h(e.tenureHash)),n.push(h(e.previousTenureHash)),n.push(h(e.burnViewHash)),n.push(h(e.previousTenureEnd)),n.push(L(new Uint8Array(4),e.previousTenureBlocks)),n.push(function(t,e,n=0){return t[n]=e,t}(new Uint8Array(1),e.cause)),n.push(h(e.publicKeyHash))}return m(n)}function vr(t){return h(t.data)}function Ar(t){return t.data.slice()}function xr(t,e){return m([$n(t),e])}function Er(t,e){const n=[],r="ascii"==e?p(t.value):l(t.value),i=new Uint8Array(4);return L(i,r.length,0),n.push(i),n.push(r),xr(t.type,m(n))}function Sr(t){switch(t.type){case kn.BoolTrue:case kn.BoolFalse:return function(t){return new Uint8Array([$n(t.type)])}(t);case kn.OptionalNone:case kn.OptionalSome:return(e=t).type===kn.OptionalNone?new Uint8Array([$n(e.type)]):xr(e.type,Sr(e.value));case kn.Buffer:return function(t){const e=new Uint8Array(4);return L(e,Math.ceil(t.value.length/2),0),xr(t.type,w(e,h(t.value)))}(t);case kn.UInt:return function(t){const e=a(BigInt(t.value),F);return xr(t.type,e)}(t);case kn.Int:return function(t){const e=a(function(t,e){if(t<-(BigInt(1)<<e-BigInt(1))||(BigInt(1)<<e-BigInt(1))-BigInt(1)<t)throw`Unable to represent integer in width: ${e}`;return t>=BigInt(0)?BigInt(t):t+(BigInt(1)<<e)}(BigInt(t.value),BigInt(M)),F);return xr(t.type,e)}(t);case kn.PrincipalStandard:return function(t){return xr(t.type,fr(Zn(t.value)))}(t);case kn.PrincipalContract:return function(t){const[e,n]=function(t){const[e,n]=t.split(".");if(!e||!n)throw new Error(`Invalid contract identifier: ${t}`);return[e,n]}(t.value);return xr(t.type,w(fr(Zn(e)),dr(Gn(n))))}(t);case kn.ResponseOk:case kn.ResponseErr:return function(t){return xr(t.type,Sr(t.value))}(t);case kn.List:return function(t){const e=[],n=new Uint8Array(4);L(n,t.value.length,0),e.push(n);for(const n of t.value){const t=Sr(n);e.push(t)}return xr(t.type,m(e))}(t);case kn.Tuple:return function(t){const e=[],n=new Uint8Array(4);L(n,Object.keys(t.value).length,0),e.push(n);const r=Object.keys(t.value).sort((t,e)=>t.localeCompare(e));for(const n of r){const r=Gn(n);e.push(dr(r));const i=Sr(t.value[n]);e.push(i)}return xr(t.type,m(e))}(t);case kn.StringASCII:return function(t){return Er(t,"ascii")}(t);case kn.StringUTF8:return function(t){return Er(t,"utf8")}(t);default:throw new gt("Unable to serialize. Invalid Clarity Value.")}var e}const Cr=(t,e)=>t.padEnd(e,"0"),Br=(t,e)=>!!t&&l(t).length>e;function Tr(t){return Bn()(t)}const Ir=t=>Xe(Mt(t)),Ur=t=>f(Sn(t)),kr=t=>f(Ir(t)),Pr=t=>{const e=Ir(t),n=w(new Uint8Array([0]),new Uint8Array([e.length]),e);return f(Ir(n))},Nr=(t,e)=>{if(t>15||e.length>15)throw Error("P2SH multisig address can only contain up to 15 public keys");const n=[];n.push(80+t),e.forEach(t=>{n.push(t.length),n.push(t)}),n.push(80+e.length),n.push(174);const r=m(n);return f(Ir(r))},$r=(t,e)=>{if(t>15||e.length>15)throw Error("P2WSH multisig address can only contain up to 15 public keys");const n=[];n.push(80+t),e.forEach(t=>{n.push(t.length),n.push(t)}),n.push(80+e.length),n.push(174);const r=m(n),i=Mt(r),o=[];o.push(0),o.push(i.length),o.push(i);const s=m(o);return f(Ir(s))};function Or(t){return/^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$/.test(t)&&t.length<128}const Hr=t=>{if(t.okay)return cr(t.result);throw new Error(t.cause)};function _r(t,e="mainnet"){return e=O(e),function(t,e="mainnet"){e=O(e),t="string"==typeof t?h(t):t;const n=function(t,e){switch(e=O(e??k),t){case Q.P2PKH:switch(e.transactionVersion){case T.Mainnet:return I.MainnetSingleSig;case T.Testnet:return I.TestnetSingleSig;default:throw new Error(`Unexpected transactionVersion ${e.transactionVersion} for hashMode ${t}`)}case Q.P2SH:case Q.P2SHNonSequential:case Q.P2WPKH:case Q.P2WSH:case Q.P2WSHNonSequential:switch(e.transactionVersion){case T.Mainnet:return I.MainnetMultiSig;case T.Testnet:return I.TestnetMultiSig;default:throw new Error(`Unexpected transactionVersion ${e.transactionVersion} for hashMode ${t}`)}default:throw new Error(`Unexpected hashMode ${t}`)}}(Q.P2PKH,e);return Yn(Qn(n,kr(t)))}(Dr(t),e)}function Lr(t){return t="string"==typeof t?h(t):t,{type:Vn.PublicKey,data:t}}function jr(t){return"string"==typeof t?t:f(t)}He.hmacSha256Sync=(t,...e)=>{const n=kt.create(Mt,t);return e.forEach(t=>n.update(t)),n.digest()};const Mr=jr;function Fr(t){return("string"==typeof t?t.length/2:t.byteLength)===A}function Rr(t){return!Mr(t).startsWith("04")}function Dr(t){const e=Fr(t=_e(t));return f(function(t,e=!1){return re.fromPrivateKey(t).toRawBytes(e)}(t.slice(0,32),e))}const Kr=function(){return(t=jr(t=He.randomPrivateKey())).length==2*A?t:`${t}01`;var t};function Vr(t,e){t=_e(t);const[n,i]=function(t,e,n={}){const{seed:r,m:i,d:o}=function(t,e,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const r=be(t),i=Ue(e),o=[Ne(i),Pe(r)];if(null!=n){!0===n&&(n=He.randomBytes(32));const t=be(n);if(32!==t.length)throw new Error("sign: Expected 32 bytes of extra data");o.push(t)}return{seed:ae(...o),m:ke(r),d:i}}(t,e,n.extraEntropy),s=new Ce(32,32);let a;for(s.reseedSync(r);!(a=Ie(s.generateSync(),i,o,n.canonical));)s.reseedSync();return function(t,e){const{sig:n,recovery:r}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),s=i?n.toDERRawBytes():n.toCompactRawBytes();return o?[s,r]:s}(a,n)}(e,t.slice(0,32),{canonical:!0,recovered:!0});if(null==i)throw new Error("No signature recoveryId received");return r(i,1)+se.fromHex(n).toCompactHex()}function zr(...t){return"number"==typeof t[0]?function(t,e){return e="string"==typeof e?h(e):e,(0,_.bJ)(t,f(Ir(e)))}(...t):function(t,e){return e=e?O(e):k,t="string"==typeof t?h(t):t,(0,_.bJ)(e.addressVersion.singleSig,f(Ir(t)))}(...t)}function Wr(){return{type:Vn.MessageSignature,data:f(new Uint8Array(R))}}function qr(t,n,r,i){const o=Xn(0,t,1,[Lr(n)]).hash160,s=Rr(n)?Y.Compressed:Y.Uncompressed;return{hashMode:t,signer:o,nonce:e(r),fee:e(i),keyEncoding:s,signature:Wr()}}function Gr(t){return"signature"in t}function Zr(t){return t===Q.P2SH||t===Q.P2WSH}function Jr(t){const e=Tr(t);return e.nonce=0,e.fee=0,Gr(e)?e.signature=Wr():e.fields=[],{...e,nonce:BigInt(0),fee:BigInt(0)}}function Xr(e){return Gr(e)?function(e){return m([e.hashMode,h(e.signer),t(e.nonce,8),t(e.fee,8),e.keyEncoding,vr(e.signature)])}(e):function(e){const n=[e.hashMode,h(e.signer),t(e.nonce,8),t(e.fee,8)],r=Wn(e.fields);n.push(br(r));const i=new Uint8Array(2);return function(t,e,n=0){t[n+0]=e>>>8,t[n+1]=e>>>0}(i,e.signaturesRequired,0),n.push(i),m(n)}(e)}function Qr(e,n,r,i){const o=e+f(new Uint8Array([n]))+f(t(r,8))+f(t(i,8));if(49!==h(o).byteLength)throw Error("Invalid signature hash length");return Ur(h(o))}function Yr(t,e,n){const r=33+R;var i;const o=h(t+((i=(Rr(e.data)?Y.Compressed:Y.Uncompressed).toString(16)).length%2?`0${i}`:i)+n);if(o.byteLength>r)throw Error("Invalid signature hash length");return Ur(o)}function ti(t,e,r,i,o,a){const c=Qr(t,e,r,i),u=Lr(function(t,e,r=Y.Compressed){const i=function(t){if(t.length<129)throw new Error("Invalid signature");const e=t.slice(0,2),n=t.slice(2,66),r=t.slice(66);return{recoveryId:s(e),r:n,s:r}}(e),o=new se(n(i.r),n(i.s)),a=re.fromSignature(t,o,i.recoveryId),c=r===Y.Compressed;return a.toHex(c)}(c,a,o));return{pubKey:u,nextSigHash:Yr(c,u,a)}}function ei(t){return{authType:X.Standard,spendingCondition:t}}function ni(t,e){return{authType:X.Sponsored,spendingCondition:t,sponsorSpendingCondition:e||qr(Q.P2PKH,"0".repeat(66),0,0)}}function ri(t){if(t.spendingCondition)switch(t.authType){case X.Standard:return ei(Jr(t.spendingCondition));case X.Sponsored:return ni(Jr(t.spendingCondition),function(){const t=qr(Q.P2PKH,"",0,0);return t.signer=(Vn.Address,I.MainnetSingleSig,"0".repeat(40)),t.keyEncoding=Y.Compressed,t.signature=Wr(),t}());default:throw new mt("Unexpected authorization type for signing")}throw new Error("Authorization missing SpendingCondition")}function ii(t,e="hex"){switch(t.type){case kn.BoolTrue:return"true";case kn.BoolFalse:return"false";case kn.Int:return t.value.toString();case kn.UInt:return`u${t.value.toString()}`;case kn.Buffer:if("tryAscii"===e){const e=y(h(t.value));if(/[ -~]/.test(e))return JSON.stringify(e)}return`0x${t.value}`;case kn.OptionalNone:return"none";case kn.OptionalSome:return`(some ${ii(t.value,e)})`;case kn.ResponseErr:return`(err ${ii(t.value,e)})`;case kn.ResponseOk:return`(ok ${ii(t.value,e)})`;case kn.PrincipalStandard:case kn.PrincipalContract:return t.value;case kn.List:return`(list ${t.value.map(t=>ii(t,e)).join(" ")})`;case kn.Tuple:return`(tuple ${Object.keys(t.value).map(n=>`(${n} ${ii(t.value[n],e)})`).join(" ")})`;case kn.StringASCII:return`"${t.value}"`;case kn.StringUTF8:return`u"${t.value}"`}}function oi(t){switch(t.type){case kn.BoolTrue:case kn.BoolFalse:return"bool";case kn.Int:return"int";case kn.UInt:return"uint";case kn.Buffer:return`(buff ${Math.ceil(t.value.length/2)})`;case kn.OptionalNone:return"(optional none)";case kn.OptionalSome:return`(optional ${oi(t.value)})`;case kn.ResponseErr:return`(response UnknownType ${oi(t.value)})`;case kn.ResponseOk:return`(response ${oi(t.value)} UnknownType)`;case kn.PrincipalStandard:case kn.PrincipalContract:return"principal";case kn.List:return`(list ${t.value.length} ${t.value.length?oi(t.value[0]):"UnknownType"})`;case kn.Tuple:return`(tuple ${Object.keys(t.value).map(e=>`(${e} ${oi(t.value[e])})`).join(" ")})`;case kn.StringASCII:return`(string-ascii ${p(t.value).length})`;case kn.StringUTF8:return`(string-utf8 ${l(t.value).length})`}}var si;!function(t){t[t.ClarityAbiTypeUInt128=1]="ClarityAbiTypeUInt128",t[t.ClarityAbiTypeInt128=2]="ClarityAbiTypeInt128",t[t.ClarityAbiTypeBool=3]="ClarityAbiTypeBool",t[t.ClarityAbiTypePrincipal=4]="ClarityAbiTypePrincipal",t[t.ClarityAbiTypeNone=5]="ClarityAbiTypeNone",t[t.ClarityAbiTypeBuffer=6]="ClarityAbiTypeBuffer",t[t.ClarityAbiTypeResponse=7]="ClarityAbiTypeResponse",t[t.ClarityAbiTypeOptional=8]="ClarityAbiTypeOptional",t[t.ClarityAbiTypeTuple=9]="ClarityAbiTypeTuple",t[t.ClarityAbiTypeList=10]="ClarityAbiTypeList",t[t.ClarityAbiTypeStringAscii=11]="ClarityAbiTypeStringAscii",t[t.ClarityAbiTypeStringUtf8=12]="ClarityAbiTypeStringUtf8",t[t.ClarityAbiTypeTraitReference=13]="ClarityAbiTypeTraitReference"}(si||(si={}));const ai=t=>"string"==typeof t,ci=t=>void 0!==t.buffer,ui=t=>void 0!==t["string-ascii"],fi=t=>void 0!==t["string-utf8"],hi=t=>void 0!==t.response,li=t=>void 0!==t.optional,di=t=>void 0!==t.tuple,pi=t=>void 0!==t.list;function yi(t){if(ai(t))return"int128"===t?"int":"uint128"===t?"uint":t;if(ci(t))return`(buff ${t.buffer.length})`;if(ui(t))return`(string-ascii ${t["string-ascii"].length})`;if(fi(t))return`(string-utf8 ${t["string-utf8"].length})`;if(hi(t))return`(response ${yi(t.response.ok)} ${yi(t.response.error)})`;if(li(t))return`(optional ${yi(t.optional)})`;if(di(t))return`(tuple ${t.tuple.map(t=>`(${t.name} ${yi(t.type)})`).join(" ")})`;if(pi(t))return`(list ${t.list.length} ${yi(t.list.type)})`;throw new Error(`Type string unsupported for Clarity type: ${JSON.stringify(t)}`)}function gi(t,e){const n=function(t){if(ai(t)){if("uint128"===t)return{id:si.ClarityAbiTypeUInt128,type:t};if("int128"===t)return{id:si.ClarityAbiTypeInt128,type:t};if("bool"===t)return{id:si.ClarityAbiTypeBool,type:t};if("principal"===t)return{id:si.ClarityAbiTypePrincipal,type:t};if("trait_reference"===t)return{id:si.ClarityAbiTypeTraitReference,type:t};if("none"===t)return{id:si.ClarityAbiTypeNone,type:t};throw new Error(`Unexpected Clarity ABI type primitive: ${JSON.stringify(t)}`)}if(ci(t))return{id:si.ClarityAbiTypeBuffer,type:t};if(hi(t))return{id:si.ClarityAbiTypeResponse,type:t};if(li(t))return{id:si.ClarityAbiTypeOptional,type:t};if(di(t))return{id:si.ClarityAbiTypeTuple,type:t};if(pi(t))return{id:si.ClarityAbiTypeList,type:t};if(ui(t))return{id:si.ClarityAbiTypeStringAscii,type:t};if(fi(t))return{id:si.ClarityAbiTypeStringUtf8,type:t};throw new Error(`Unexpected Clarity ABI type: ${JSON.stringify(t)}`)}(e);switch(t.type){case kn.BoolTrue:case kn.BoolFalse:return n.id===si.ClarityAbiTypeBool;case kn.Int:return n.id===si.ClarityAbiTypeInt128;case kn.UInt:return n.id===si.ClarityAbiTypeUInt128;case kn.Buffer:return n.id===si.ClarityAbiTypeBuffer&&n.type.buffer.length>=Math.ceil(t.value.length/2);case kn.StringASCII:return n.id===si.ClarityAbiTypeStringAscii&&n.type["string-ascii"].length>=t.value.length;case kn.StringUTF8:return n.id===si.ClarityAbiTypeStringUtf8&&n.type["string-utf8"].length>=t.value.length;case kn.OptionalNone:return n.id===si.ClarityAbiTypeNone||n.id===si.ClarityAbiTypeOptional;case kn.OptionalSome:return n.id===si.ClarityAbiTypeOptional&&gi(t.value,n.type.optional);case kn.ResponseErr:return n.id===si.ClarityAbiTypeResponse&&gi(t.value,n.type.response.error);case kn.ResponseOk:return n.id===si.ClarityAbiTypeResponse&&gi(t.value,n.type.response.ok);case kn.PrincipalContract:return n.id===si.ClarityAbiTypePrincipal||n.id===si.ClarityAbiTypeTraitReference;case kn.PrincipalStandard:return n.id===si.ClarityAbiTypePrincipal;case kn.List:return n.id==si.ClarityAbiTypeList&&n.type.list.length>=t.value.length&&t.value.every(t=>gi(t,n.type.list.type));case kn.Tuple:if(n.id==si.ClarityAbiTypeTuple){const e=Tr(t.value);for(let t=0;t<n.type.tuple.length;t++){const r=n.type.tuple[t],i=r.name,o=e[i];if(!o)return!1;if(!gi(o,r.type))return!1;delete e[i]}return!0}return!1;default:return!1}}class bi{constructor({auth:t,payload:n,postConditions:r=Wn([]),postConditionMode:i=Z.Deny,transactionVersion:o,chainId:s,network:a="mainnet"}){a=O(a),this.transactionVersion=o??a.transactionVersion,this.chainId=s??a.chainId,this.auth=t,this.payload="amount"in n?{...n,amount:e(n.amount)}:n,this.postConditionMode=i,this.postConditions=r,this.anchorMode=z.Any}signBegin(){const t=Tr(this);return t.auth=ri(t.auth),t.txid()}verifyBegin(){const t=Tr(this);return t.auth=ri(t.auth),t.txid()}verifyOrigin(){return function(t,e){switch(t.authType){case X.Standard:case X.Sponsored:return function(t,e,n){return Gr(t)?function(t,e,n){const{pubKey:r,nextSigHash:i}=ti(e,n,t.fee,t.nonce,t.keyEncoding,t.signature.data),o=Xn(0,t.hashMode,1,[r]).hash160;if(o!==t.signer)throw new vt(`Signer hash does not equal hash of public key(s): ${o} != ${t.signer}`);return i}(t,e,n):function(t,e,n){const r=[];let i=e,o=!1,s=0;for(const e of t.fields)switch(e.contents.type){case Vn.PublicKey:Rr(e.contents.data)||(o=!0),r.push(e.contents);break;case Vn.MessageSignature:e.pubKeyEncoding===Y.Uncompressed&&(o=!0);const{pubKey:a,nextSigHash:c}=ti(i,n,t.fee,t.nonce,e.pubKeyEncoding,e.contents.data);if(Zr(t.hashMode)&&(i=c),r.push(a),s+=1,65536===s)throw new vt("Too many signatures")}if(Zr(t.hashMode)&&s!==t.signaturesRequired||((a=t.hashMode)===Q.P2SHNonSequential||a===Q.P2WSHNonSequential)&&s<t.signaturesRequired)throw new vt("Incorrect number of signatures");var a;if(o&&(t.hashMode===Q.P2WSH||t.hashMode===Q.P2WSHNonSequential))throw new vt("Uncompressed keys are not allowed in this hash mode");const c=Xn(0,t.hashMode,t.signaturesRequired,r).hash160;if(c!==t.signer)throw new vt(`Signer hash does not equal hash of public key(s): ${c} != ${t.signer}`);return i}(t,e,n)}(t.spendingCondition,e,X.Standard);default:throw new mt("Invalid origin auth type")}}(this.auth,this.verifyBegin())}signNextOrigin(t,e){if(void 0===this.auth.spendingCondition)throw new Error('"auth.spendingCondition" is undefined');if(void 0===this.auth.authType)throw new Error('"auth.authType" is undefined');return this.signAndAppend(this.auth.spendingCondition,t,X.Standard,e)}signNextSponsor(t,e){if(this.auth.authType===X.Sponsored)return this.signAndAppend(this.auth.sponsorSpendingCondition,t,X.Sponsored,e);throw new Error('"auth.sponsorSpendingCondition" is undefined')}appendPubkey(t){const e="object"==typeof t&&"type"in t?t:Lr(t),n=this.auth.spendingCondition;if(!n||Gr(n))throw new Error("Can't append public key to a singlesig condition");{const t=Rr(e.data);n.fields.push(Jn(t?Y.Compressed:Y.Uncompressed,e))}}signAndAppend(t,e,n,r){const{nextSig:i,nextSigHash:o}=function(t,e,n,r,i){const o=Qr(t,e,n,r),s=Vr(i,o);return{nextSig:s,nextSigHash:Yr(o,Lr(Dr(i)),s)}}(e,n,t.fee,t.nonce,r);if(Gr(t))t.signature=qn(i);else{const e=Fr(r);t.fields.push(Jn(e?Y.Compressed:Y.Uncompressed,qn(i)))}return o}txid(){const t=this.serializeBytes();return Ur(t)}setSponsor(t){if(this.auth.authType!=X.Sponsored)throw new mt("Cannot sponsor sign a non-sponsored transaction");this.auth=function(t,n){return{...t,sponsorSpendingCondition:{...n,nonce:e(n.nonce),fee:e(n.fee)}}}(this.auth,t)}setFee(t){this.auth=function(t,n){switch(t.authType){case X.Standard:const r={...t.spendingCondition,fee:e(n)};return{...t,spendingCondition:r};case X.Sponsored:const i={...t.sponsorSpendingCondition,fee:e(n)};return{...t,sponsorSpendingCondition:i}}}(this.auth,t)}setNonce(t){this.auth=function(t,n){const r={...t.spendingCondition,nonce:e(n)};return{...t,spendingCondition:r}}(this.auth,t)}setSponsorNonce(t){if(this.auth.authType!=X.Sponsored)throw new mt("Cannot sponsor sign a non-sponsored transaction");this.auth=function(t,n){const r={...t.sponsorSpendingCondition,nonce:e(n)};return{...t,sponsorSpendingCondition:r}}(this.auth,t)}serialize(){return f(this.serializeBytes())}serializeBytes(){if(void 0===this.transactionVersion)throw new gt('"transactionVersion" is undefined');if(void 0===this.chainId)throw new gt('"chainId" is undefined');if(void 0===this.auth)throw new gt('"auth" is undefined');if(void 0===this.payload)throw new gt('"payload" is undefined');const t=[];t.push(this.transactionVersion);const e=new Uint8Array(4);return L(e,this.chainId,0),t.push(e),t.push(function(t){const e=[];switch(e.push(t.authType),t.authType){case X.Standard:e.push(Xr(t.spendingCondition));break;case X.Sponsored:e.push(Xr(t.spendingCondition)),e.push(Xr(t.sponsorSpendingCondition))}return m(e)}(this.auth)),t.push(this.anchorMode),t.push(this.postConditionMode),t.push(br(this.postConditions)),t.push(mr(this.payload)),m(t)}}function wi(t){return(e=t.transactionVersion,t=>t[e])({[T.Mainnet]:k,[T.Testnet]:P});var e}const mi="/v2/fees/transfer",vi="/v2/fees/transaction",Ai="/v2/accounts",xi="/v2/contracts/interface",Ei="/v2/contracts/call-read";const Si=BigInt("18446744073709551615");function Ci(t){const n=e(t);if(n<0n||n>Si)throw new RangeError(`Post-condition amount must be between 0 and ${Si} (u64 max), received: ${n}`);return n}var Bi;function Ti(t){return Bi[t]}async function Ii(t){const n={fee:BigInt(0),nonce:BigInt(0),network:k,postConditionMode:Z.Deny,sponsored:!1},r=Object.assign(n,t);r.network=O(r.network),r.client=Object.assign({},H(r.network),r.client),r.postConditionMode=function(t){if("number"==typeof t)return t;if("allow"===t)return Z.Allow;if("deny"===t)return Z.Deny;if("originator"===t)return Z.Originator;throw new Error(`Invalid post condition mode: ${t}`)}(r.postConditionMode);const i=(o=r.contractAddress,s=r.contractName,a=r.functionName,c=r.functionArgs,"string"==typeof s&&(s=Gn(s)),"string"==typeof a&&(a=Gn(a)),{type:Vn.Payload,payloadType:K.ContractCall,contractAddress:"string"==typeof o?Zn(o):o,contractName:s,functionName:a,functionArgs:c});var o,s,a,c;if(r?.validateWithAbi){let t;if("boolean"==typeof r.validateWithAbi){if(!r?.network)throw new Error("Network option must be provided in order to validate with ABI");t=await async function({contractAddress:t,contractName:e,network:n="mainnet",client:r}){const i=Object.assign({},H(O(n)),r),o=`${i.baseUrl}${xi}/${t}/${e}`,s=await i.fetch(o);if(!s.ok){const n=await s.text().catch(()=>"");throw new Error(`Error fetching contract ABI for contract "${e}" at address ${t}. Response ${s.status}: ${s.statusText}. Attempted to fetch ${o} and failed with the message: "${n}"`)}return JSON.parse(await s.text())}({...r})}else t=r.validateWithAbi;!function(t,e){const n=e.functions.filter(e=>e.name===t.functionName.content);if(1===n.length){const e=n[0].args;if(t.functionArgs.length!==e.length)throw new Error(`Clarity function expects ${e.length} argument(s) but received ${t.functionArgs.length}`);for(let n=0;n<t.functionArgs.length;n++){const r=t.functionArgs[n],i=e[n];if(!gi(r,i.type)){const e=n+1;throw new Error(`Clarity function \`${t.functionName.content}\` expects argument ${e} to be of type ${yi(i.type)}, not ${oi(r)}`)}}return!0}throw 0===n.length?new Error(`ABI doesn't contain a function with the name ${t.functionName.content}`):new Error(`Malformed ABI. Contains multiple functions with the name ${t.functionName.content}`)}(i,t)}let u=null;if("publicKey"in r)u=qr(Q.P2PKH,r.publicKey,r.nonce,r.fee);else{const t=r.useNonSequentialMultiSig?Q.P2SHNonSequential:Q.P2SH,n=r.address?function(t,e,n,r){if(Xn(0,n,e,t.map(Lr)).hash160===r)return t;const i=t.slice().sort();if(Xn(0,n,e,i.map(Lr)).hash160===r)return i;throw new Error("Failed to find matching multi-sig address given public-keys.")}(r.publicKeys.map(Mr),r.numSignatures,t,Zn(r.address).hash160):r.publicKeys.map(Mr);u=function(t,n,r,i,o){return{hashMode:t,signer:Xn(0,t,n,r.map(Lr)).hash160,nonce:e(i),fee:e(o),fields:[],signaturesRequired:n}}(t,r.numSignatures,n,r.nonce,r.fee)}const h=r.sponsored?ni(u):ei(u),l=Wn((r.postConditions??[]).map(t=>"string"==typeof t?wr(t):"string"==typeof t.type?function(t){switch(t.type){case"stx-postcondition":return{type:Vn.PostCondition,conditionType:J.STX,principal:"origin"===t.address?{type:Vn.Principal,prefix:nt.Origin}:er(t.address),conditionCode:Ti(t.condition),amount:Ci(t.amount)};case"ft-postcondition":return{type:Vn.PostCondition,conditionType:J.Fungible,principal:"origin"===t.address?{type:Vn.Principal,prefix:nt.Origin}:er(t.address),conditionCode:Ti(t.condition),amount:Ci(t.amount),asset:tr(t.asset)};case"nft-postcondition":return{type:Vn.PostCondition,conditionType:J.NonFungible,principal:"origin"===t.address?{type:Vn.Principal,prefix:nt.Origin}:er(t.address),conditionCode:Ti(t.condition),asset:tr(t.asset),assetName:t.assetId};default:throw new Error("Invalid post condition type")}}(t):t)),d=new bi({transactionVersion:r.network.transactionVersion,chainId:r.network.chainId,auth:h,payload:i,postConditions:l,postConditionMode:r.postConditionMode});if(void 0===t.fee||null===t.fee){const t=await async function({transaction:t,network:e,client:n}){const r=e??wi(t),i=Object.assign({},H(O(r)),n);try{const e=function(t){const e=t.auth.spendingCondition.hashMode;if([Q.P2SH,Q.P2WSH].includes(e)){const e=t.auth.spendingCondition,n=e.fields.filter(t=>t.contents.type===Vn.MessageSignature).length,r=(e.signaturesRequired-n)*(R+1);return t.serializeBytes().byteLength+r}return t.serializeBytes().byteLength}(t);return(await async function({payload:t,estimatedLength:e,network:n="mainnet",client:r}){const i={transaction_payload:t,estimated_len:e},o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},s=Object.assign({},H(O(n)),r),a=`${s.baseUrl}${vi}`,c=await s.fetch(a,o);if(!c.ok){const t=await c.text().catch(()=>"");if(t.includes("NoEstimateAvailable")){let e={};try{e=JSON.parse(t)}catch(t){}throw new wt(e?.reason_data?.message??"")}throw new Error(`Error estimating transaction fee. Response ${c.status}: ${c.statusText}. Attempted to fetch ${a} and failed with the message: "${t}"`)}return(await c.json()).estimations}({payload:f(mr(t.payload)),estimatedLength:e,network:r,client:i}))[1].fee}catch(e){if(!(e instanceof wt))throw e;return await async function({transaction:t,network:e,client:n}){const r="number"==typeof t?"mainnet":e??wi(t),i=Object.assign({},H(O(r)),n),o=`${i.baseUrl}${mi}`,s=await i.fetch(o,{headers:{Accept:"application/text"}});if(!s.ok){const t=await s.text().catch(()=>"");throw new Error(`Error estimating transfer fee. Response ${s.status}: ${s.statusText}. Attempted to fetch ${o} and failed with the message: "${t}"`)}const a=await s.text(),c="number"==typeof t?BigInt(t):BigInt(Math.ceil(t.serializeBytes().byteLength));return BigInt(a)*c}({transaction:t,network:r})}}({transaction:d,...r});d.setFee(t)}if(void 0===t.nonce||null===t.nonce){const t=r.network.addressVersion.singleSig,e=(0,_.bJ)(t,d.auth.spendingCondition.signer),n=await async function(t){try{return await async function({address:t,network:e="mainnet",client:n}){const r=Object.assign({},H(O(e)),n),i=`${r.baseUrl}/extended/v1/address/${t}/nonces`,o=await r.fetch(i),s=await o.json();return BigInt(s.possible_next_nonce)}(t)}catch(t){}const e=O(t.network??"mainnet"),n=Object.assign({},H(e),t.client),r=`${n.baseUrl}${Ai}/${t.address}?proof=0`,i=await n.fetch(r);if(!i.ok){const t=await i.text().catch(()=>"");throw new Error(`Error fetching nonce. Response ${i.status}: ${i.statusText}. Attempted to fetch ${r} and failed with the message: "${t}"`)}const o=await i.json();return BigInt(o.nonce)}({address:e,...r});d.setNonce(n)}return d}function Ui(t){const e=t.split(".");return e.length>2?{subdomain:e[0],name:e[1],namespace:e[2]}:{name:e[0],namespace:e[1]}}!function(t){t[t.eq=1]="eq",t[t.gt=2]="gt",t[t.lt=4]="lt",t[t.gte=3]="gte",t[t.lte=5]="lte",t[t.sent=16]="sent",t[t["not-sent"]=17]="not-sent",t[t["maybe-sent"]=18]="maybe-sent"}(Bi||(Bi={}));const ki=t=>Ir(l(t));var Pi=Object.defineProperty,Ni=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,Oi=Object.getOwnPropertySymbols,Hi=Object.prototype.hasOwnProperty,_i=Object.prototype.propertyIsEnumerable,Li=(t,e,n)=>e in t?Pi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ji=(t,e)=>{for(var n in e||(e={}))Hi.call(e,n)&&Li(t,n,e[n]);if(Oi)for(var n of Oi(e))_i.call(e,n)&&Li(t,n,e[n]);return t},Mi=(t,e)=>Ni(t,$i(e));const Fi="bns";async function Ri(t){return Ii({contractAddress:t.network.bootAddress,contractName:Fi,functionName:t.functionName,functionArgs:t.functionArgs,publicKey:t.publicKey,validateWithAbi:!1,network:t.network,postConditions:t.postConditions})}async function Di(t){return async function({contractName:t,contractAddress:e,functionName:n,functionArgs:r,senderAddress:i,network:o="mainnet",client:s}){const a={sender:i,arguments:r.map(t=>`0x${f(Sr(t))}`)},c={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)},u=encodeURIComponent(n),h=Object.assign({},H(O(o)),s),l=`${h.baseUrl}${Ei}/${e}/${t}/${u}`,d=await h.fetch(l,c);if(!d.ok){const t=await d.text().catch(()=>"");throw new Error(`Error calling read-only function. Response ${d.status}: ${d.statusText}. Attempted to fetch ${l} and failed with the message: "${t}"`)}return await d.json().then(Hr)}(Mi(ji({},t),{contractAddress:t.network.bootAddress,contractName:Fi}))}async function Ki({fullyQualifiedName:t,network:e}){const{subdomain:n,namespace:r,name:i}=Ui(t);if(n)throw new Error("Cannot register a subdomain using registerName");return Di({functionName:"can-name-be-registered",senderAddress:_r(Kr()),functionArgs:[Rn(r),Rn(i)],network:e}).then(t=>t.type===kn.ResponseOk&&t.value.type===kn.BoolTrue)}async function Vi({namespace:t,network:e}){return Di({functionName:"get-namespace-price",senderAddress:_r(Kr()),functionArgs:[Rn(t)],network:e}).then(t=>{if(t.type===kn.ResponseOk){if(t.value.type===kn.Int||t.value.type===kn.UInt)return BigInt(t.value.value);throw new Error("Response did not contain a number")}throw t.type===kn.ResponseErr?new Error(ii(t.value)):new Error(`Unexpected Clarity Value type: ${oi(t)}`)})}async function zi({fullyQualifiedName:t,network:e}){const{subdomain:n,namespace:r,name:i}=Ui(t);if(n)throw new Error("Cannot get subdomain name price");return Di({functionName:"get-name-price",senderAddress:_r(Kr()),functionArgs:[Rn(r),Rn(i)],network:e}).then(t=>{if(t.type===kn.ResponseOk){if(t.value.type===kn.Int||t.value.type===kn.UInt)return BigInt(t.value.value);throw new Error("Response did not contain a number")}throw new Error(ii(t.value))})}async function Wi({namespace:t,salt:n,stxToBurn:r,publicKey:i,network:o}){const s=l(`${t}${n}`),a=Ir(s),c={type:"stx-postcondition",address:zr(o.addressVersion.singleSig,i),condition:"eq",amount:e(r)};return Ri({functionName:"namespace-preorder",functionArgs:[Fn(a),Mn(r)],publicKey:i,network:o,postConditions:[c]})}async function qi({namespace:t,salt:e,priceFunction:n,lifetime:r,namespaceImportAddress:i,publicKey:o,network:s}){return Ri({functionName:"namespace-reveal",functionArgs:[Rn(t),Rn(e),Mn(n.base),Mn(n.coefficient),Mn(n.b1),Mn(n.b2),Mn(n.b3),Mn(n.b4),Mn(n.b5),Mn(n.b6),Mn(n.b7),Mn(n.b8),Mn(n.b9),Mn(n.b10),Mn(n.b11),Mn(n.b12),Mn(n.b13),Mn(n.b14),Mn(n.b15),Mn(n.b16),Mn(n.nonAlphaDiscount),Mn(n.noVowelDiscount),Mn(r),nr(i)],publicKey:o,network:s})}async function Gi({namespace:t,name:e,beneficiary:n,zonefile:r,publicKey:i,network:o}){const s=ki(r);return Ri({functionName:"name-import",functionArgs:[Rn(t),Rn(e),nr(n),Fn(s)],publicKey:i,network:o})}async function Zi({namespace:t,publicKey:e,network:n}){return Ri({functionName:"namespace-ready",functionArgs:[Rn(t)],publicKey:e,network:n})}async function Ji({fullyQualifiedName:t,salt:n,stxToBurn:r,publicKey:i,network:o}){const{subdomain:s}=Ui(t);if(s)throw new Error("Cannot preorder a subdomain using preorderName()");const a=l(`${t}${n}`),c=Ir(a),u={type:"stx-postcondition",address:zr(o.addressVersion.singleSig,i),condition:"eq",amount:e(r)};return Ri({functionName:"name-preorder",functionArgs:[Fn(c),Mn(r)],publicKey:i,network:o,postConditions:[u]})}async function Xi({fullyQualifiedName:t,salt:e,zonefile:n,publicKey:r,network:i}){const{subdomain:o,namespace:s,name:a}=Ui(t);if(o)throw new Error("Cannot register a subdomain using registerName()");const c=ki(n);return Ri({functionName:"name-register",functionArgs:[Rn(s),Rn(a),Rn(e),Fn(c)],network:i,publicKey:r})}async function Qi({fullyQualifiedName:t,zonefile:e,publicKey:n,network:r}){const{subdomain:i,namespace:o,name:s}=Ui(t);if(i)throw new Error("Cannot update a subdomain using updateName()");const a=ki(e);return Ri({functionName:"name-update",functionArgs:[Rn(o),Rn(s),Fn(a)],publicKey:n,network:r})}async function Yi({fullyQualifiedName:t,newOwnerAddress:e,zonefile:n,publicKey:r,network:i}){const{subdomain:o,namespace:s,name:a}=Ui(t);if(o)throw new Error("Cannot transfer a subdomain using transferName()");return Ri({functionName:"name-transfer",functionArgs:[Rn(s),Rn(a),nr(e),n?ir(Fn(ki(n))):rr()],publicKey:r,network:i,postConditions:[{type:"nft-postcondition",address:zr(i.addressVersion.singleSig,r),condition:"sent",asset:`${i.bootAddress}.bns::names`,assetId:or({name:Rn(a),namespace:Rn(s)})},{type:"nft-postcondition",address:e,condition:"not-sent",asset:`${i.bootAddress}.bns::names`,assetId:or({name:Rn(a),namespace:Rn(s)})}]})}async function to({fullyQualifiedName:t,publicKey:e,network:n}){const{subdomain:r,namespace:i,name:o}=Ui(t);if(r)throw new Error("Cannot revoke a subdomain using revokeName()");return Ri({functionName:"name-revoke",functionArgs:[Rn(i),Rn(o)],publicKey:e,network:n})}async function eo({fullyQualifiedName:t,stxToBurn:n,newOwnerAddress:r,zonefile:i,publicKey:o,network:s}){const{subdomain:a,namespace:c,name:u}=Ui(t);if(a)throw new Error("Cannot renew a subdomain using renewName()");return Ri({functionName:"name-renewal",functionArgs:[Rn(c),Rn(u),Mn(n),r?ir(nr(r)):rr(),i?ir(Fn(ki(i))):rr()],publicKey:o,network:s,postConditions:[{type:"stx-postcondition",address:zr(s.addressVersion.singleSig,o),condition:"eq",amount:e(n)}]})}})(),o})());
|
|
3
3
|
//# sourceMappingURL=index.js.map
|