@blockcerts/blockcerts-verifier 1.62.2 → 1.63.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/bundle-stats.html +1 -1
- package/dist/{EcdsaSd2023-jnIXPui8-Ecil79Z6.js → EcdsaSd2023-DZGap3SM-mPG0cLDm.js} +7 -7
- package/dist/EcdsaSecp256k1Signature2019-n7E_p_GN-CK56BVKZ.js +1 -0
- package/dist/Ed25519Signature2020-_cT8vvaO-DsdBcpgb.js +52 -0
- package/dist/HashlinkVerifier-DgB7rgX8-dg5WNZnc.js +11 -0
- package/dist/{MerkleProof2017-Cy_nkz4C-gnoFFWMW.js → MerkleProof2017-C7joZBSg-D3Ose_hz.js} +1 -1
- package/dist/MerkleProof2019-B6RcT8nL-CW7PatZk.js +3 -0
- package/dist/checkCredentialSchemaConformity-BFdwoe1d-SeiEjHaf.js +1 -0
- package/dist/{controlVerificationMethod-BxseSDWK-Ghg2o_Hj.js → controlVerificationMethod-DZMPBpH4-DAL92l4K.js} +1 -1
- package/dist/did-key-common.esm-Dpr3yDzE-TRogf7i4.js +9 -0
- package/dist/did-key-ed25519.esm-Cds5njOI-zlZoO68S.js +1 -0
- package/dist/did-key-secp256k1.esm-D1IImaHL-CTenolkL.js +1 -0
- package/dist/elliptic-Bf4jfo3V-BRLTdj5Y.js +1 -0
- package/dist/{ensureValidIssuingKey-C7MTkDyV-frafTbMl.js → ensureValidIssuingKey-DVA5iNXJ-wu9SdYxL.js} +1 -1
- package/dist/index-ByRXJxEU-CtZ_5kyD.js +22 -0
- package/dist/index-CAl7T2GU-LqbKlBZ6.js +1 -0
- package/dist/index-Chj6rFU_-DwRdQV-L.js +60 -0
- package/dist/index-DsWS3N1O-C0eXpZGn.js +1 -0
- package/dist/jsonld-CkyvX_Vg-C61cS9xX.js +33 -0
- package/dist/main.js +110 -111
- package/dist/{retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js → retrieveVerificationMethodPublicKey-Dz3Z2B9t-C2YmGxIc.js} +1 -1
- package/dist/sha256-Dr-8c5iF-C1PUWFZm.js +1 -0
- package/dist/webcrypto.es-InUVnvpc-B87Lqr9a.js +40 -0
- package/dist/x25519-KEey2Qx1-NSl6svWQ.js +1 -0
- package/package.json +2 -2
- package/dist/EcdsaSecp256k1Signature2019-CBV4BwnM-C2qGlq2W.js +0 -4
- package/dist/Ed25519Signature2020-MQoWd113-PNuci9U2.js +0 -52
- package/dist/HashlinkVerifier-DykIKn5i-CYewU55u.js +0 -11
- package/dist/MerkleProof2019-DpwH-snR-ClzVR6uC.js +0 -3
- package/dist/checkCredentialSchemaConformity-DOGmtCq0-CnEpCN-s.js +0 -1
- package/dist/did-key-common.esm-C42sQiXe-DN5hgDGM.js +0 -9
- package/dist/did-key-ed25519.esm-CO7qImeZ-BR5JRBUU.js +0 -1
- package/dist/did-key-secp256k1.esm-BblZ1xRe-4Ak_uTKC.js +0 -1
- package/dist/elliptic-6eMlPaPZ-CGOSt2J1.js +0 -1
- package/dist/index-BZds3Ljo-CHN5LgUq.js +0 -1
- package/dist/index-Dzjg2qbR-DK7tzt5T.js +0 -22
- package/dist/index-VOqA2-xz-CKqwdkuf.js +0 -70
- package/dist/index-WN144sZ6-DKm58evR.js +0 -3
- package/dist/jsonld-BpvX3DRL-qZrjsUmJ.js +0 -75
- package/dist/sha256-D_qJpPFT-BYFBxJ7m.js +0 -1
- package/dist/webcrypto.es-DQnPRx8R-BJSH271h.js +0 -41
- package/dist/x25519-Dm-l65ld-DcUk09rC.js +0 -1
- /package/dist/{checkRevocationStatusList2021-CNtaPjVp-XCu3zkCJ.js → checkRevocationStatusList2021-BEXdT3FD-XCu3zkCJ.js} +0 -0
- /package/dist/{ensureNotRevoked-D9_PlMpD-DvMIgM4L.js → ensureNotRevoked-zJYOGU17-DvMIgM4L.js} +0 -0
- /package/dist/{index-CWugL4dz-Dgus2xdV.js → index-CgNQmXGo-Dgus2xdV.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{f as e,d as t,h as r,r as n,j as i,p as o,k as s,l as a,B as u,S as c,m as f,i as h,n as p}from"./main.js";import{r as l}from"./index-DsWS3N1O-C0eXpZGn.js";import{r as d,k as y,s as g,a as w,b as m,c as b}from"./index-CAl7T2GU-LqbKlBZ6.js";import{a as E}from"./elliptic-Bf4jfo3V-BRLTdj5Y.js";import{j as _}from"./index-Chj6rFU_-DwRdQV-L.js";import{j as v,r as S}from"./jsonld-CkyvX_Vg-C61cS9xX.js";import{s as I}from"./sha256-Dr-8c5iF-C1PUWFZm.js";import{t as T,e as k}from"./index-ByRXJxEU-CtZ_5kyD.js";import"./pako.esm-DnD5dZGi-Bw1vqMku.js";import{e as A}from"./ensureValidIssuingKey-DVA5iNXJ-wu9SdYxL.js";import"./index-CgNQmXGo-Dgus2xdV.js";import{r as P}from"./retrieveVerificationMethodPublicKey-Dz3Z2B9t-C2YmGxIc.js";import{S as O}from"./Suite-B7Vy9AuU-D1ucdMDB.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";var N,U,x,B,R,M,L={type:"object",required:["merkleRoot","targetHash","anchors"],properties:{merkleRoot:{type:"string",minLength:64,maxLength:64},targetHash:{type:"string",minLength:64,maxLength:64},anchors:{type:"array",minItems:1,contains:{type:"string"}}}};function C(){if(B)return x;B=1;const e=function(){if(U)return N;U=1;const e=L,{validator:t}=l(),r=t(e);return N=r}();return x={validate:e}}function H(){if(M)return R;M=1;return R={root:{merkleRoot:0,targetHash:1,anchors:2,path:3},path:{left:0,right:1},chain:{btc:{id:0,networks:{mainnet:1,testnet:3}},eth:{id:1,networks:{mainnet:1,ropsten:3,rinkeby:4,goerli:5,sepolia:11155111}},mtc:{id:2,networks:{mainnet:137,mumbai:80001}},mocknet:{id:-1,networks:{mocknet:-1}}}}}var D,F={},j={exports:{}},V=j.exports;function K(){return D||(D=1,e=j,function(t){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,o=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",u=1e14,c=14,f=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,l=1e9;function d(e){var t=0|e;return e>0||e===t?t:t-1}function y(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=c-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function g(e,t){var r,n,i=e.c,o=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function w(e,t,r,n){if(e<t||e>r||e!==o(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function m(e){var t=e.c.length-1;return d(e.e/c)==t&&e.c[t]%2!=0}function b(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,_,v,S,I,T,k,A,P,O,N=G.prototype={constructor:G,toString:null,valueOf:null},U=new G(1),x=20,B=4,R=-7,M=21,L=-1e7,C=1e7,H=!1,D=1,F=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},V="0123456789abcdefghijklmnopqrstuvwxyz",K=!0;function G(e,t){var r,i,s,u,h,p,l,d,y=this;if(!(y instanceof G))return new G(e,t);if(null==t){if(e&&!0===e._isBigNumber)return y.s=e.s,void(!e.c||e.e>C?y.c=y.e=null:e.e<L?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(u=0,h=e;h>=10;h/=10,u++);return void(u>C?y.c=y.e=null:(y.e=u,y.c=[e]))}d=String(e)}else{if(!n.test(d=String(e)))return v(y,d,p);y.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(u=d.indexOf("."))>-1&&(d=d.replace(".","")),(h=d.search(/e/i))>0?(u<0&&(u=h),u+=+d.slice(h+1),d=d.substring(0,h)):u<0&&(u=d.length)}else{if(w(t,2,V.length,"Base"),10==t&&K)return z(y=new G(e),x+y.e+1,B);if(d=String(e),p="number"==typeof e){if(0*e!=0)return v(y,d,p,t);if(y.s=1/e<0?(d=d.slice(1),-1):1,G.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(a+e)}else y.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(r=V.slice(0,t),u=h=0,l=d.length;h<l;h++)if(r.indexOf(i=d.charAt(h))<0){if("."==i){if(h>u){u=l;continue}}else if(!s&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){s=!0,h=-1,u=0;continue}return v(y,String(e),p,t)}p=!1,(u=(d=_(d,t,10,y.s)).indexOf("."))>-1?d=d.replace(".",""):u=d.length}for(h=0;48===d.charCodeAt(h);h++);for(l=d.length;48===d.charCodeAt(--l););if(d=d.slice(h,++l)){if(l-=h,p&&G.DEBUG&&l>15&&(e>f||e!==o(e)))throw Error(a+y.s*e);if((u=u-h-1)>C)y.c=y.e=null;else if(u<L)y.c=[y.e=0];else{if(y.e=u,y.c=[],h=(u+1)%c,u<0&&(h+=c),h<l){for(h&&y.c.push(+d.slice(0,h)),l-=c;h<l;)y.c.push(+d.slice(h,h+=c));h=c-(d=d.slice(h)).length}else h-=l;for(;h--;d+="0");y.c.push(+d)}}else y.c=[y.e=0]}function W(e,t,r,n){var i,o,s,a,u;if(null==r?r=B:w(r,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)u=y(e.c),u=1==n||2==n&&(s<=R||s>=M)?b(u,s):E(u,s,"0");else if(o=(e=z(new G(e),t,r)).e,a=(u=y(e.c)).length,1==n||2==n&&(t<=o||o<=R)){for(;a<t;u+="0",a++);u=b(u,o)}else if(t-=s,u=E(u,o,"0"),o+1>a){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-a)>0)for(o+1==a&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function X(e,t){for(var r,n,i=1,o=new G(e[0]);i<e.length;i++)(!(n=new G(e[i])).s||(r=g(o,n))===t||0===r&&o.s===t)&&(o=n);return o}function q(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*c-1)>C?e.c=e.e=null:r<L?e.c=[e.e=0]:(e.e=r,e.c=t),e}function z(e,t,r,n){var s,a,f,p,l,d,y,g=e.c,w=h;if(g){e:{for(s=1,p=g[0];p>=10;p/=10,s++);if((a=t-s)<0)a+=c,f=t,l=g[d=0],y=o(l/w[s-f-1]%10);else if((d=i((a+1)/c))>=g.length){if(!n)break e;for(;g.length<=d;g.push(0));l=y=0,s=1,f=(a%=c)-c+1}else{for(l=p=g[d],s=1;p>=10;p/=10,s++);y=(f=(a%=c)-c+s)<0?0:o(l/w[s-f-1]%10)}if(n=n||t<0||null!=g[d+1]||(f<0?l:l%w[s-f-1]),n=r<4?(y||n)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||n||6==r&&(a>0?f>0?l/w[s-f]:0:g[d-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=w[(c-t%c)%c],e.e=-t||0):g[0]=e.e=0,e;if(0==a?(g.length=d,p=1,d--):(g.length=d+1,p=w[c-a],g[d]=f>0?o(l/w[s-f]%w[f])*p:0),n)for(;;){if(0==d){for(a=1,f=g[0];f>=10;f/=10,a++);for(f=g[0]+=p,p=1;f>=10;f/=10,p++);a!=p&&(e.e++,g[0]==u&&(g[0]=1));break}if(g[d]+=p,g[d]!=u)break;g[d--]=0,p=1}for(a=g.length;0===g[--a];g.pop());}e.e>C?e.c=e.e=null:e.e<L&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=y(e.c),t=r<=R||r>=M?b(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return G.clone=e,G.ROUND_UP=0,G.ROUND_DOWN=1,G.ROUND_CEIL=2,G.ROUND_FLOOR=3,G.ROUND_HALF_UP=4,G.ROUND_HALF_DOWN=5,G.ROUND_HALF_EVEN=6,G.ROUND_HALF_CEIL=7,G.ROUND_HALF_FLOOR=8,G.EUCLID=9,G.config=G.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(s+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(w(r=e[t],0,l,t),x=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(w(r=e[t],0,8,t),B=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(w(r[0],-l,0,t),w(r[1],0,l,t),R=r[0],M=r[1]):(w(r,-l,l,t),R=-(M=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)w(r[0],-l,-1,t),w(r[1],1,l,t),L=r[0],C=r[1];else{if(w(r,-l,l,t),!r)throw Error(s+t+" cannot be zero: "+r);L=-(C=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(s+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw H=!r,Error(s+"crypto unavailable");H=r}else H=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(w(r=e[t],0,9,t),D=r),e.hasOwnProperty(t="POW_PRECISION")&&(w(r=e[t],0,l,t),F=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(s+t+" not an object: "+r);j=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(s+t+" invalid: "+r);K="0123456789"==r.slice(0,10),V=r}}return{DECIMAL_PLACES:x,ROUNDING_MODE:B,EXPONENTIAL_AT:[R,M],RANGE:[L,C],CRYPTO:H,MODULO_MODE:D,POW_PRECISION:F,FORMAT:j,ALPHABET:V}},G.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!G.DEBUG)return!0;var t,r,n=e.c,i=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&i>=-l&&i<=l&&i===o(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%c)<1&&(t+=c),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=u||r!==o(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===a||1===a||-1===a))return!0;throw Error(s+"Invalid BigNumber: "+e)},G.maximum=G.max=function(){return X(arguments,-1)},G.minimum=G.min=function(){return X(arguments,1)},G.random=(S=9007199254740992,I=Math.random()*S&2097151?function(){return o(Math.random()*S)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,a,u,f=0,p=[],d=new G(U);if(null==e?e=x:w(e,0,l),a=i(e/c),H)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));f<a;)(u=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(p.push(u%1e14),f+=2);f=a/2}else{if(!crypto.randomBytes)throw H=!1,Error(s+"crypto unavailable");for(t=crypto.randomBytes(a*=7);f<a;)(u=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(p.push(u%1e14),f+=7);f=a/7}if(!H)for(;f<a;)(u=I())<9e15&&(p[f++]=u%1e14);for(a=p[--f],e%=c,a&&e&&(u=h[c-e],p[f]=o(a/u)*u);0===p[f];p.pop(),f--);if(f<0)p=[n=0];else{for(n=-1;0===p[0];p.splice(0,1),n-=c);for(f=1,u=p[0];u>=10;u/=10,f++);f<c&&(n-=c-f)}return d.e=n,d.c=p,d}),G.sum=function(){for(var e=1,t=arguments,r=new G(t[0]);e<t.length;)r=r.plus(t[e++]);return r},_=function(){var e="0123456789";function t(e,t,r,n){for(var i,o,s=[0],a=0,u=e.length;a<u;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var u,c,f,h,p,l,d,g,w=n.indexOf("."),m=x,b=B;for(w>=0&&(h=F,F=0,n=n.replace(".",""),l=(g=new G(i)).pow(n.length-w),F=h,g.c=t(E(y(l.c),l.e,"0"),10,o,e),g.e=g.c.length),f=h=(d=t(n,i,o,a?(u=V,e):(u=e,V))).length;0==d[--h];d.pop());if(!d[0])return u.charAt(0);if(w<0?--f:(l.c=d,l.e=f,l.s=s,d=(l=r(l,g,m,b,o)).c,p=l.r,f=l.e),w=d[c=f+m+1],h=o/2,p=p||c<0||null!=d[c+1],p=b<4?(null!=w||p)&&(0==b||b==(l.s<0?3:2)):w>h||w==h&&(4==b||p||6==b&&1&d[c-1]||b==(l.s<0?8:7)),c<1||!d[0])n=p?E(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(d.length=c,p)for(--o;++d[--c]>o;)d[c]=0,c||(++f,d=[1].concat(d));for(h=d.length;!d[--h];);for(w=0,n="";w<=h;n+=u.charAt(d[w++]));n=E(n,f,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,o,s,a=0,u=e.length,c=t%p,f=t/p|0;for(e=e.slice();u--;)a=((i=c*(o=e[u]%p)+(n=f*o+(s=e[u]/p|0)*c)%p*p+a)/r|0)+(n/p|0)+f*s,e[u]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,s,a,f){var h,p,l,y,g,w,m,b,E,_,v,S,I,T,k,A,P,O=n.s==i.s?1:-1,N=n.c,U=i.c;if(!(N&&N[0]&&U&&U[0]))return new G(n.s&&i.s&&(N?!U||N[0]!=U[0]:U)?N&&0==N[0]||!U?0*O:O/0:NaN);for(E=(b=new G(O)).c=[],O=s+(p=n.e-i.e)+1,f||(f=u,p=d(n.e/c)-d(i.e/c),O=O/c|0),l=0;U[l]==(N[l]||0);l++);if(U[l]>(N[l]||0)&&p--,O<0)E.push(1),y=!0;else{for(T=N.length,A=U.length,l=0,O+=2,(g=o(f/(U[0]+1)))>1&&(U=e(U,g,f),N=e(N,g,f),A=U.length,T=N.length),I=A,v=(_=N.slice(0,A)).length;v<A;_[v++]=0);P=U.slice(),P=[0].concat(P),k=U[0],U[1]>=f/2&&k++;do{if(g=0,(h=t(U,_,A,v))<0){if(S=_[0],A!=v&&(S=S*f+(_[1]||0)),(g=o(S/k))>1)for(g>=f&&(g=f-1),m=(w=e(U,g,f)).length,v=_.length;1==t(w,_,m,v);)g--,r(w,A<m?P:U,m,f),m=w.length,h=1;else 0==g&&(h=g=1),m=(w=U.slice()).length;if(m<v&&(w=[0].concat(w)),r(_,w,v,f),v=_.length,-1==h)for(;t(U,_,A,v)<1;)g++,r(_,A<v?P:U,v,f),v=_.length}else 0===h&&(g++,_=[0]);E[l++]=g,_[0]?_[v++]=N[I]||0:(_=[N[I]],v=1)}while((I++<T||null!=_[0])&&O--);y=null!=_[0],E[0]||E.splice(0,1)}if(f==u){for(l=1,O=E[0];O>=10;O/=10,l++);z(b,s+(b.e=l+p*c-1)+1,a,y)}else b.e=p,b.r=+y;return b}}(),T=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,A=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,t,r,n){var i,o=r?t:t.replace(O,"");if(P.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(T,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,o=o.replace(k,"$1").replace(A,"0.$1")),t!=o))return new G(o,i);if(G.DEBUG)throw Error(s+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},N.absoluteValue=N.abs=function(){var e=new G(this);return e.s<0&&(e.s=1),e},N.comparedTo=function(e,t){return g(this,new G(e,t))},N.decimalPlaces=N.dp=function(e,t){var r,n,i,o=this;if(null!=e)return w(e,0,l),null==t?t=B:w(t,0,8),z(new G(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-d(this.e/c))*c,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},N.dividedBy=N.div=function(e,t){return r(this,new G(e,t),x,B)},N.dividedToIntegerBy=N.idiv=function(e,t){return r(this,new G(e,t),0,1)},N.exponentiatedBy=N.pow=function(e,t){var r,n,a,u,f,h,p,l,d=this;if((e=new G(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+$(e));if(null!=t&&(t=new G(t)),f=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return l=new G(Math.pow(+$(d),f?e.s*(2-m(e)):+$(e))),t?l.mod(t):l;if(h=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new G(NaN);(n=!h&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||f&&d.c[1]>=24e7:d.c[0]<8e13||f&&d.c[0]<=9999975e7)))return u=d.s<0&&m(e)?-0:0,d.e>-1&&(u=1/u),new G(h?1/u:u);F&&(u=i(F/c+2))}for(f?(r=new G(.5),h&&(e.s=1),p=m(e)):p=(a=Math.abs(+$(e)))%2,l=new G(U);;){if(p){if(!(l=l.times(d)).c)break;u?l.c.length>u&&(l.c.length=u):n&&(l=l.mod(t))}if(a){if(0===(a=o(a/2)))break;p=a%2}else if(z(e=e.times(r),e.e+1,1),e.e>14)p=m(e);else{if(0==(a=+$(e)))break;p=a%2}d=d.times(d),u?d.c&&d.c.length>u&&(d.c.length=u):n&&(d=d.mod(t))}return n?l:(h&&(l=U.div(l)),t?l.mod(t):u?z(l,F,B,void 0):l)},N.integerValue=function(e){var t=new G(this);return null==e?e=B:w(e,0,8),z(t,t.e+1,e)},N.isEqualTo=N.eq=function(e,t){return 0===g(this,new G(e,t))},N.isFinite=function(){return!!this.c},N.isGreaterThan=N.gt=function(e,t){return g(this,new G(e,t))>0},N.isGreaterThanOrEqualTo=N.gte=function(e,t){return 1===(t=g(this,new G(e,t)))||0===t},N.isInteger=function(){return!!this.c&&d(this.e/c)>this.c.length-2},N.isLessThan=N.lt=function(e,t){return g(this,new G(e,t))<0},N.isLessThanOrEqualTo=N.lte=function(e,t){return-1===(t=g(this,new G(e,t)))||0===t},N.isNaN=function(){return!this.s},N.isNegative=function(){return this.s<0},N.isPositive=function(){return this.s>0},N.isZero=function(){return!!this.c&&0==this.c[0]},N.minus=function(e,t){var r,n,i,o,s=this,a=s.s;if(t=(e=new G(e,t)).s,!a||!t)return new G(NaN);if(a!=t)return e.s=-t,s.plus(e);var f=s.e/c,h=e.e/c,p=s.c,l=e.c;if(!f||!h){if(!p||!l)return p?(e.s=-t,e):new G(l?s:NaN);if(!p[0]||!l[0])return l[0]?(e.s=-t,e):new G(p[0]?s:3==B?-0:0)}if(f=d(f),h=d(h),p=p.slice(),a=f-h){for((o=a<0)?(a=-a,i=p):(h=f,i=l),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(o=(a=p.length)<(t=l.length))?a:t,a=t=0;t<n;t++)if(p[t]!=l[t]){o=p[t]<l[t];break}if(o&&(i=p,p=l,l=i,e.s=-e.s),(t=(n=l.length)-(r=p.length))>0)for(;t--;p[r++]=0);for(t=u-1;n>a;){if(p[--n]<l[n]){for(r=n;r&&!p[--r];p[r]=t);--p[r],p[n]+=u}p[n]-=l[n]}for(;0==p[0];p.splice(0,1),--h);return p[0]?q(e,p,h):(e.s=3==B?-1:1,e.c=[e.e=0],e)},N.modulo=N.mod=function(e,t){var n,i,o=this;return e=new G(e,t),!o.c||!e.s||e.c&&!e.c[0]?new G(NaN):!e.c||o.c&&!o.c[0]?new G(o):(9==D?(i=e.s,e.s=1,n=r(o,e,0,3),e.s=i,n.s*=i):n=r(o,e,0,D),(e=o.minus(n.times(e))).c[0]||1!=D||(e.s=o.s),e)},N.multipliedBy=N.times=function(e,t){var r,n,i,o,s,a,f,h,l,y,g,w,m,b,E,_=this,v=_.c,S=(e=new G(e,t)).c;if(!(v&&S&&v[0]&&S[0]))return!_.s||!e.s||v&&!v[0]&&!S||S&&!S[0]&&!v?e.c=e.e=e.s=null:(e.s*=_.s,v&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=d(_.e/c)+d(e.e/c),e.s*=_.s,(f=v.length)<(y=S.length)&&(m=v,v=S,S=m,i=f,f=y,y=i),i=f+y,m=[];i--;m.push(0));for(b=u,E=p,i=y;--i>=0;){for(r=0,g=S[i]%E,w=S[i]/E|0,o=i+(s=f);o>i;)r=((h=g*(h=v[--s]%E)+(a=w*h+(l=v[s]/E|0)*g)%E*E+m[o]+r)/b|0)+(a/E|0)+w*l,m[o--]=h%b;m[o]=r}return r?++n:m.splice(0,1),q(e,m,n)},N.negated=function(){var e=new G(this);return e.s=-e.s||null,e},N.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new G(e,t)).s,!i||!t)return new G(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/c,s=e.e/c,a=n.c,f=e.c;if(!o||!s){if(!a||!f)return new G(i/0);if(!a[0]||!f[0])return f[0]?e:new G(a[0]?n:0*i)}if(o=d(o),s=d(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=f):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=f.length)<0&&(r=f,f=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+f[t]+i)/u|0,a[t]=u===a[t]?0:a[t]%u;return i&&(a=[i].concat(a),++s),q(e,a,s)},N.precision=N.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return w(e,1,l),null==t?t=B:w(t,0,8),z(new G(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*c+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},N.shiftedBy=function(e){return w(e,-9007199254740991,f),this.times("1e"+e)},N.squareRoot=N.sqrt=function(){var e,t,n,i,o,s=this,a=s.c,u=s.s,c=s.e,f=x+4,h=new G("0.5");if(1!==u||!a||!a[0])return new G(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+$(s)))||u==1/0?(((t=y(a)).length+c)%2==0&&(t+="0"),u=Math.sqrt(+t),c=d((c+1)/2)-(c<0||c%2),n=new G(t=u==1/0?"5e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new G(u+""),n.c[0])for((u=(c=n.e)+f)<3&&(u=0);;)if(o=n,n=h.times(o.plus(r(s,o,f,1))),y(o.c).slice(0,u)===(t=y(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(n,n.e+x+2,1),e=!n.times(n).eq(s));break}if(!i&&(z(o,o.e+x+2,0),o.times(o).eq(s))){n=o;break}f+=4,u+=4,i=1}return z(n,n.e+x+1,B,e)},N.toExponential=function(e,t){return null!=e&&(w(e,0,l),e++),W(this,e,t,1)},N.toFixed=function(e,t){return null!=e&&(w(e,0,l),e=e+this.e+1),W(this,e,t)},N.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=j;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var o,a=n.split("."),u=+r.groupSize,c=+r.secondaryGroupSize,f=r.groupSeparator||"",h=a[0],p=a[1],l=i.s<0,d=l?h.slice(1):h,y=d.length;if(c&&(o=u,u=c,c=o,y-=o),u>0&&y>0){for(o=y%u||u,h=d.substr(0,o);o<y;o+=u)h+=f+d.substr(o,u);c>0&&(h+=f+d.slice(o)),l&&(h="-"+h)}n=p?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?p.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):p):h}return(r.prefix||"")+n+(r.suffix||"")},N.toFraction=function(e){var t,n,i,o,a,u,f,p,l,d,g,w,m=this,b=m.c;if(null!=e&&(!(f=new G(e)).isInteger()&&(f.c||1!==f.s)||f.lt(U)))throw Error(s+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+$(f));if(!b)return new G(m);for(t=new G(U),l=n=new G(U),i=p=new G(U),w=y(b),a=t.e=w.length-m.e-1,t.c[0]=h[(u=a%c)<0?c+u:u],e=!e||f.comparedTo(t)>0?a>0?t:l:f,u=C,C=1/0,f=new G(w),p.c[0]=0;d=r(f,t,0,1),1!=(o=n.plus(d.times(i))).comparedTo(e);)n=i,i=o,l=p.plus(d.times(o=l)),p=o,t=f.minus(d.times(o=t)),f=o;return o=r(e.minus(n),i,0,1),p=p.plus(o.times(l)),n=n.plus(o.times(i)),p.s=l.s=m.s,g=r(l,i,a*=2,B).minus(m).abs().comparedTo(r(p,n,a,B).minus(m).abs())<1?[l,i]:[p,n],C=u,g},N.toNumber=function(){return+$(this)},N.toPrecision=function(e,t){return null!=e&&w(e,1,l),W(this,e,t,2)},N.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=R||i>=M?b(y(r.c),i):E(y(r.c),i,"0"):10===e&&K?t=E(y((r=z(new G(r),x+i+1,B)).c),r.e,"0"):(w(e,2,V.length,"Base"),t=_(E(y(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},N.valueOf=N.toJSON=function(){return $(this)},N._isBigNumber=!0,null!=t&&G.set(t),G}(),r.default=r.BigNumber=r,e.exports?e.exports=r:(t||(t="undefined"!=typeof self&&self?self:window),t.BigNumber=r)}(V)),j.exports;var e}var G,W,X,q,z,$,Y,J,Q,Z,ee,te,re,ne,ie,oe,se,ae,ue,ce,fe,he={},pe={};function le(){return G||(G=1,function(e){const t=K().BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=4294967296,e.BI={MINUS_ONE:-1,MAXINT32:4294967295,MAXINT64:"0xffffffffffffffff",SHIFT32:e.SHIFT32};const r=new t(-1);e.BN={MINUS_ONE:r,NEG_MAX:r.minus(new t(Number.MAX_SAFE_INTEGER.toString(16),16)),MAXINT:new t("0x20000000000000"),MAXINT32:new t(4294967295),MAXINT64:new t("0xffffffffffffffff"),SHIFT32:new t(e.SHIFT32)}}(pe)),pe}function de(){return W||(W=1,function(e){const t=m,r=K().BigNumber,n=le(),i=n.NUMBYTES,o=n.SHIFT32;e.hasBigInt="function"==typeof BigInt;const s="function"==typeof TextDecoder?TextDecoder:t.TextDecoder;if(s){const t=new s("utf8",{fatal:!0,ignoreBOM:!0});e.utf8=e=>t.decode(e),e.utf8.checksUTF8=!0}else e.utf8=e=>e.toString("utf8"),e.utf8.checksUTF8=!1;e.parseCBORint=function(e,t){switch(e){case i.ONE:return t.readUInt8(0);case i.TWO:return t.readUInt16BE(0);case i.FOUR:return t.readUInt32BE(0);case i.EIGHT:const n=t.readUInt32BE(0),s=t.readUInt32BE(4);return n>2097151?new r(n).times(o).plus(s):n*o+s;default:throw new Error("Invalid additional info for int: "+e)}},e.writeHalf=function(e,t){const r=u.allocUnsafe(4);r.writeFloatBE(t,0);const n=r.readUInt32BE(0);if(8191&n)return!1;let i=n>>16&32768;const o=n>>23&255,s=8388607&n;if(o>=113&&o<=142)i+=(o-112<<10)+(s>>13);else{if(!(o>=103&&o<113))return!1;if(s&(1<<126-o)-1)return!1;i+=s+8388608>>126-o}return e.writeUInt16BE(i),!0},e.parseHalf=function(e){const t=128&e[0]?-1:1,r=(124&e[0])>>2,n=(3&e[0])<<8|e[1];return r?31===r?t*(n?NaN:Infinity):t*Math.pow(2,r-25)*(1024+n):5.960464477539063e-8*t*n},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error("Invalid float size: "+t.length)}},e.hex=function(e){return u.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let t=0,r=(e=e.replace(/\s/g,"")).length%8||8;const n=[];for(;r<=e.length;)n.push(parseInt(e.slice(t,r),2)),t=r,r+=8;return u.from(n)},e.extend=function(e={},...t){const r=t.length;for(let n=0;n<r;n++){const r=t[n];for(const t in r){const n=r[t];e[t]=n}}return e},e.arrayEqual=function(e,t){return null==e&&null==t||null!=e&&null!=t&&(e.length===t.length&&e.every(((e,r)=>e===t[r])))},e.bufferEqual=function(e,t){if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(!h(e)||!h(t)||e.length!==t.length)return!1;const r=e.length;let n,i,o=!0;for(n=i=0;i<r;n=++i){const r=e[n];o=o&&t[n]===r}return!!o},e.bufferToBignumber=function(e){return new r(e.toString("hex"),16)},e.toBigInt=function(t){return e.hasBigInt?BigInt(t):Number(t)},e.bigIntize=function(t){const r={};for(const n in t)r[n]=e.toBigInt(t[n]);return r},e.bufferToBigInt=function(t){return e.toBigInt("0x"+t.toString("hex"))},e.guessEncoding=function(e){if("string"==typeof e)return"hex";if(!h(e))throw new Error("Unknown input type")}}(he)),he}function ye(){if(q)return X;q=1;const e=m,t=le(),r=t.MT,n=t.SIMPLE,i=t.SYMS;class o{constructor(e){if("number"!=typeof e)throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(0|e)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}[e.inspect.custom](e,t){return"simple("+this.value+")"}inspect(e,t){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,r.SIMPLE_FLOAT)}static isSimple(e){return e instanceof o}static decode(e,t=!0,r=!1){switch(e){case n.FALSE:return!1;case n.TRUE:return!0;case n.NULL:return t?null:i.NULL;case n.UNDEFINED:return t?void 0:i.UNDEFINED;case-1:if(!t||!r)throw new Error("Invalid BREAK");return i.BREAK;default:return new o(e)}}}return X=o}function ge(){if($)return z;$=1;const e=b,t=m;class r extends e.Transform{constructor(e,t,r){let n,i;switch(null==r&&(r={}),typeof e){case"object":h(e)?(n=e,null!=t&&"object"==typeof t&&(r=t)):r=e;break;case"string":n=e,null!=t&&"object"==typeof t?r=t:i=t}null==r&&(r={}),null==n&&(n=r.input),null==i&&(i=r.inputEncoding),delete r.input,delete r.inputEncoding;const o=null==r.watchPipe||r.watchPipe;delete r.watchPipe;const s=!!r.readError;delete r.readError,super(r),this.readError=s,o&&this.on("pipe",(e=>{const t=e._readableState.objectMode;if(this.length>0&&t!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");return this._readableState.objectMode=t,this._writableState.objectMode=t})),null!=n&&this.end(n,i)}static isNoFilter(e){return e instanceof this}static compare(e,t){if(!(e instanceof this))throw new TypeError("Arguments must be NoFilters");return e===t?0:e.compare(t)}static concat(e,t){if(!Array.isArray(e))throw new TypeError("list argument must be an Array of NoFilters");if(0===e.length||0===t)return u.alloc(0);null==t&&(t=e.reduce(((e,t)=>{if(!(t instanceof r))throw new TypeError("list argument must be an Array of NoFilters");return e+t.length}),0));let n=!0,i=!0;const o=e.map((e=>{if(!(e instanceof r))throw new TypeError("list argument must be an Array of NoFilters");const t=e.slice();return h(t)?i=!1:n=!1,t}));if(n)return u.concat(o,t);if(i)return[].concat(...o).slice(0,t);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(e,t,r){this._readableState.objectMode||h(e)||(e=u.from(e,t)),this.push(e),r()}_bufArray(){let e=this._readableState.buffer;if(!Array.isArray(e)){let t=e.head;for(e=[];null!=t;)e.push(t.data),t=t.next}return e}read(e){const t=super.read(e);if(null!=t){if(this.emit("read",t),this.readError&&t.length<e)throw new Error(`Read ${t.length}, wanted ${e}`)}else if(this.readError)throw new Error(`No data available, wanted ${e}`);return t}promise(e){let t=!1;return new Promise(((r,n)=>{this.on("finish",(()=>{const n=this.read();null==e||t||(t=!0,e(null,n)),r(n)})),this.on("error",(r=>{null==e||t||(t=!0,e(r)),n(r)}))}))}compare(e){if(!(e instanceof r))throw new TypeError("Arguments must be NoFilters");if(this===e)return 0;{const t=this.slice(),r=e.slice();if(h(t)&&h(r))return t.compare(r);throw new Error("Cannot compare streams in object mode")}}equals(e){return 0===this.compare(e)}slice(e,t){if(this._readableState.objectMode)return this._bufArray().slice(e,t);const r=this._bufArray();switch(r.length){case 0:return u.alloc(0);case 1:return r[0].slice(e,t);default:return u.concat(r).slice(e,t)}}get(e){return this.slice()[e]}toJSON(){const e=this.slice();return h(e)?e.toJSON():e}toString(e,r,n){const i=this.slice(r,n);if(!h(i))return JSON.stringify(i);if((!e||"utf8"===e)&&t.TextDecoder){return new t.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(i)}return i.toString(e,r,n)}inspect(e,r){return this[t.inspect.custom](e,r)}[t.inspect.custom](e,r){const n=this._bufArray().map((e=>h(e)?(null!=r?r.stylize:void 0)?r.stylize(e.toString("hex"),"string"):e.toString("hex"):t.inspect(e,r))).join(", ");return`${this.constructor.name} [${n}]`}get length(){return this._readableState.length}writeBigInt(e){let t=e.toString(16);if(e<0){const r=BigInt(Math.floor(t.length/2));t=(e=(BigInt(1)<<r*BigInt(8))+e).toString(16)}return t.length%2&&(t="0"+t),this.push(u.from(t,"hex"))}readUBigInt(e){const t=this.read(e);return h(t)?BigInt("0x"+t.toString("hex")):null}readBigInt(e){const t=this.read(e);if(!h(t))return null;let r=BigInt("0x"+t.toString("hex"));if(128&t[0]){r-=BigInt(1)<<BigInt(t.length)*BigInt(8)}return r}}function n(e,t){return function(r){const n=this.read(t);return h(n)?n[e].call(n,0,!0):null}}function i(e,t){return function(r){const n=u.alloc(t);return n[e].call(n,r,0,!0),this.push(n)}}return Object.assign(r.prototype,{writeUInt8:i("writeUInt8",1),writeUInt16LE:i("writeUInt16LE",2),writeUInt16BE:i("writeUInt16BE",2),writeUInt32LE:i("writeUInt32LE",4),writeUInt32BE:i("writeUInt32BE",4),writeInt8:i("writeInt8",1),writeInt16LE:i("writeInt16LE",2),writeInt16BE:i("writeInt16BE",2),writeInt32LE:i("writeInt32LE",4),writeInt32BE:i("writeInt32BE",4),writeFloatLE:i("writeFloatLE",4),writeFloatBE:i("writeFloatBE",4),writeDoubleLE:i("writeDoubleLE",8),writeDoubleBE:i("writeDoubleBE",8),readUInt8:n("readUInt8",1),readUInt16LE:n("readUInt16LE",2),readUInt16BE:n("readUInt16BE",2),readUInt32LE:n("readUInt32LE",4),readUInt32BE:n("readUInt32BE",4),readInt8:n("readInt8",1),readInt16LE:n("readInt16LE",2),readInt16BE:n("readInt16BE",2),readInt32LE:n("readInt32LE",4),readInt32BE:n("readInt32BE",4),readFloatLE:n("readFloatLE",4),readFloatBE:n("readFloatBE",4),readDoubleLE:n("readDoubleLE",8),readDoubleBE:n("readDoubleBE",8)}),z=r}function we(){if(Z)return Q;Z=1;const e=K().BigNumber,t=de(),r=p,n=new e(-1),i=new e(2);class o{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){let t=null!=e?e[this.tag]:void 0;if("function"!=typeof t&&(t=o["_tag_"+this.tag],"function"!=typeof t))return this;try{return t.call(o,this.value)}catch(e){return this.err=e,this}}static _tag_0(e){return new Date(e)}static _tag_1(e){return new Date(1e3*e)}static _tag_2(e){return t.bufferToBignumber(e)}static _tag_3(e){return n.minus(t.bufferToBignumber(e))}static _tag_4(t){return e(t[1]).shiftedBy(t[0])}static _tag_5(e){return i.pow(e[0]).times(e[1])}static _tag_32(e){return r.parse(e)}static _tag_35(e){return new RegExp(e)}}return Q=o}function me(){if(te)return ee;te=1;const e=b,t=function(){if(J)return Y;J=1;const e=b,t=ge(),r=e.Transform;return Y=class extends r{constructor(e){super(e),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new t,this.__restart()}_transform(e,t,r){for(this.bs.write(e);this.bs.length>=this.__needed;){let e;const t=null===this.__needed?void 0:this.bs.read(this.__needed);try{e=this.__parser.next(t)}catch(e){return r(e)}this.__needed&&(this.__fresh=!1),e.done?(this.push(e.value),this.__restart()):this.__needed=e.value||0}return r()}*_parse(){throw new Error("Must be implemented in subclass")}__restart(){this.__needed=null,this.__parser=this._parse(),this.__fresh=!0}_flush(e){e(this.__fresh?null:new Error("unexpected end of input"))}}}(),r=we(),n=ye(),i=de(),o=K().BigNumber,s=ge(),a=le(),c=a.MT,f=a.NUMBYTES;a.SIMPLE;const h=a.SYMS,p=i.bigIntize(a.BI),l=a.BN,d=Symbol("count"),y=Symbol("major type"),g=Symbol("error"),w=Symbol("not found");function m(e,t,r){const n=[];return n[d]=r,n[h.PARENT]=e,n[y]=t,n}function E(e,t){const r=new s;return r[d]=-1,r[h.PARENT]=e,r[y]=t,r}function _(e){return i.bufferToBigInt(e)}function v(e){return p.MINUS_ONE-i.bufferToBigInt(e)}class S extends t{constructor(e){const t=(e=e||{}).tags;delete e.tags;const r=null!=e.max_depth?e.max_depth:-1;delete e.max_depth;const n=!!i.hasBigInt&&!!e.bigint;delete e.bigint,super(e),this.running=!0,this.max_depth=r,this.tags=t,n&&(null==this.tags&&(this.tags={}),null==this.tags[2]&&(this.tags[2]=_),null==this.tags[3]&&(this.tags[3]=v))}static nullcheck(e){switch(e){case h.NULL:return null;case h.UNDEFINED:return;case w:throw new Error("Value not found");default:return e}}static decodeFirstSync(t,r){let n,o={};switch(typeof(r=r||{encoding:"hex"})){case"string":n=r;break;case"object":o=i.extend({},r),n=o.encoding,delete o.encoding}const a=new S(o),u=t instanceof e.Readable?t:new s(t,null!=n?n:i.guessEncoding(t)),c=a._parse();let f=c.next();for(;!f.done;){const e=u.read(f.value);if(null==e||e.length!==f.value)throw new Error("Insufficient data");f=c.next(e)}const h=S.nullcheck(f.value);if(u.length>0){const e=u.read(1);u.unshift(e);const t=new Error("Unexpected data: 0x"+e[0].toString(16));throw t.value=h,t}return h}static decodeAllSync(t,r){let n,o={};switch(typeof(r=r||{encoding:"hex"})){case"string":n=r;break;case"object":o=i.extend({},r),n=o.encoding,delete o.encoding}const a=new S(o),u=t instanceof e.Readable?t:new s(t,null!=n?n:i.guessEncoding(t)),c=[];for(;u.length>0;){const e=a._parse();let t=e.next();for(;!t.done;){const r=u.read(t.value);if(null==r||r.length!==t.value)throw new Error("Insufficient data");t=e.next(r)}c.push(S.nullcheck(t.value))}return c}static decodeFirst(e,t,r){let n={},o=!1,s="hex";switch(typeof t){case"function":r=t,s=i.guessEncoding(e);break;case"string":s=t;break;case"object":n=i.extend({},t),s=null!=n.encoding?n.encoding:i.guessEncoding(e),delete n.encoding,o=null!=n.required&&n.required,delete n.required}const a=new S(n);let u=w;const c=new Promise(((e,t)=>{a.on("data",(e=>{u=S.nullcheck(e),a.close()})),a.once("error",(e=>(u!==w&&(e.value=u),u=g,a.close(),t(e)))),a.once("end",(()=>{switch(u){case w:return o?t(new Error("No CBOR found")):e(u);case g:return;default:return e(u)}}))}));return"function"==typeof r&&c.then((e=>r(null,e)),r),a.end(e,s),c}static decodeAll(e,t,r){let n={},o="hex";switch(typeof t){case"function":r=t,o=i.guessEncoding(e);break;case"string":o=t;break;case"object":n=i.extend({},t),o=null!=n.encoding?n.encoding:i.guessEncoding(e),delete n.encoding}const s=new S(n),a=[];s.on("data",(e=>a.push(S.nullcheck(e))));const u=new Promise(((e,t)=>{s.on("error",t),s.on("end",(()=>e(a)))}));return"function"==typeof r&&u.then((e=>r(null,e)),r),s.end(e,o),u}close(){this.running=!1,this.__fresh=!0}*_parse(){let e=null,t=0,a=null;for(;;){if(this.max_depth>=0&&t>this.max_depth)throw new Error("Maximum depth "+this.max_depth+" exceeded");const p=(yield 1)[0];if(!this.running)throw new Error("Unexpected data: 0x"+p.toString(16));const g=p>>5,w=31&p,b=null!=e?e[y]:void 0,_=null!=e?e.length:void 0;switch(w){case f.ONE:this.emit("more-bytes",g,1,b,_),a=(yield 1)[0];break;case f.TWO:case f.FOUR:case f.EIGHT:const e=1<<w-24;this.emit("more-bytes",g,e,b,_);const t=yield e;a=g===c.SIMPLE_FLOAT?t:i.parseCBORint(w,t);break;case 28:case 29:case 30:throw this.running=!1,new Error("Additional info not implemented: "+w);case f.INDEFINITE:switch(g){case c.POS_INT:case c.NEG_INT:case c.TAG:throw new Error(`Invalid indefinite encoding for MT ${g}`)}a=-1;break;default:a=w}switch(g){case c.POS_INT:break;case c.NEG_INT:a=a===Number.MAX_SAFE_INTEGER?l.NEG_MAX:a instanceof o?l.MINUS_ONE.minus(a):-1-a;break;case c.BYTE_STRING:case c.UTF8_STRING:switch(a){case 0:this.emit("start-string",g,a,b,_),a=g===c.BYTE_STRING?u.allocUnsafe(0):"";break;case-1:this.emit("start",g,h.STREAM,b,_),e=E(e,g),t++;continue;default:this.emit("start-string",g,a,b,_),a=yield a,g===c.UTF8_STRING&&(a=i.utf8(a))}break;case c.ARRAY:case c.MAP:switch(a){case 0:a=g===c.MAP?{}:[];break;case-1:this.emit("start",g,h.STREAM,b,_),e=m(e,g,-1),t++;continue;default:this.emit("start",g,a,b,_),e=m(e,g,a*(g-3)),t++;continue}break;case c.TAG:this.emit("start",g,a,b,_),e=m(e,g,1),e.push(a),t++;continue;case c.SIMPLE_FLOAT:if("number"==typeof a){if(w===f.ONE&&a<32)throw new Error(`Invalid two-byte encoding of simple value ${a}`);const t=null!=e;a=n.decode(a,t,t&&e[d]<0)}else a=i.parseCBORfloat(a)}this.emit("value",a,b,_,w);let v=!1;for(;null!=e;){switch(!1){case a!==h.BREAK:e[d]=1;break;case!Array.isArray(e):e.push(a);break;case!(e instanceof s):const t=e[y];if(null!=t&&t!==g)throw this.running=!1,new Error("Invalid major type in indefinite encoding");e.write(a)}if(0!=--e[d]){v=!0;break}if(--t,delete e[d],Array.isArray(e))switch(e[y]){case c.ARRAY:a=e;break;case c.MAP:let t=!0;if(e.length%2!=0)throw new Error("Invalid map length: "+e.length);for(let r=0,n=e.length;r<n;r+=2)if("string"!=typeof e[r]){t=!1;break}if(t){a={};for(let t=0,r=e.length;t<r;t+=2)a[e[t]]=e[t+1]}else{a=new Map;for(let t=0,r=e.length;t<r;t+=2)a.set(e[t],e[t+1])}break;case c.TAG:a=new r(e[0],e[1]).convert(this.tags)}else if(e instanceof s)switch(e[y]){case c.BYTE_STRING:a=e.slice();break;case c.UTF8_STRING:a=e.toString("utf-8")}this.emit("stop",e[y]);const n=e;e=e[h.PARENT],delete n[h.PARENT],delete n[y]}if(!v)return a}}}return S.NOT_FOUND=w,ee=S}function be(){if(ae)return se;ae=1;const e=b,t=p;K().BigNumber;const r=ge();we(),ye();const n=de(),i=le(),o=i.MT,s=i.NUMBYTES,a=i.SHIFT32,c=i.SYMS,f=i.TAG,l=i.MT.SIMPLE_FLOAT<<5|i.NUMBYTES.TWO,d=i.MT.SIMPLE_FLOAT<<5|i.NUMBYTES.FOUR,y=i.MT.SIMPLE_FLOAT<<5|i.NUMBYTES.EIGHT,g=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.TRUE,w=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.FALSE,m=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.UNDEFINED,E=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.NULL,_=u.from([255]),v=n.bigIntize(i.BI),S=i.BN,I=u.from("f97e00","hex"),T=u.from("f9fc00","hex"),k=u.from("f97c00","hex"),A=u.from("f98000","hex"),P=Symbol("CBOR_LOOP_DETECT");class O extends e.Transform{constructor(e){const r=Object.assign({},e,{readableObjectMode:!1,writableObjectMode:!0});super(r),this.canonical=r.canonical,this.encodeUndefined=r.encodeUndefined,this.disallowUndefinedKeys=!!r.disallowUndefinedKeys,this.dateType=null!=r.dateType?r.dateType.toLowerCase():"number",this.collapseBigIntegers=!!r.collapseBigIntegers,"symbol"==typeof r.detectLoops?this.detectLoops=r.detectLoops:this.detectLoops=r.detectLoops?Symbol("CBOR_DETECT"):null,this.semanticTypes={Array:this._pushArray,Date:this._pushDate,Buffer:this._pushBuffer,Map:this._pushMap,NoFilter:this._pushNoFilter,RegExp:this._pushRegexp,Set:this._pushSet,BigNumber:this._pushBigNumber,ArrayBuffer:this._pushUint8Array,Uint8ClampedArray:this._pushUint8Array,Uint8Array:this._pushUint8Array,Uint16Array:this._pushArray,Uint32Array:this._pushArray,Int8Array:this._pushArray,Int16Array:this._pushArray,Int32Array:this._pushArray,Float32Array:this._pushFloat32Array,Float64Array:this._pushFloat64Array},t.Url&&this.addSemanticType("Url",this._pushUrl),t.URL&&this.addSemanticType("URL",this._pushURL);const n=r.genTypes||[];for(let e=0,t=n.length;e<t;e+=2)this.addSemanticType(n[e],n[e+1])}_transform(e,t,r){return r(!1===this.pushAny(e)?new Error("Push Error"):void 0)}_flush(e){return e()}addSemanticType(e,t){if("function"!=typeof t)throw new TypeError("fun must be of type function");const r="string"==typeof e?e:e.name,n=this.semanticTypes[r];return this.semanticTypes[r]=t,n}_pushUInt8(e){const t=u.allocUnsafe(1);return t.writeUInt8(e,0),this.push(t)}_pushUInt16BE(e){const t=u.allocUnsafe(2);return t.writeUInt16BE(e,0),this.push(t)}_pushUInt32BE(e){const t=u.allocUnsafe(4);return t.writeUInt32BE(e,0),this.push(t)}_pushFloatBE(e){const t=u.allocUnsafe(4);return t.writeFloatBE(e,0),this.push(t)}_pushDoubleBE(e){const t=u.allocUnsafe(8);return t.writeDoubleBE(e,0),this.push(t)}_pushNaN(){return this.push(I)}_pushInfinity(e){const t=e<0?T:k;return this.push(t)}_pushFloat(e){if(this.canonical){const t=u.allocUnsafe(2);if(n.writeHalf(t,e))return this._pushUInt8(l)&&this.push(t)}return Math.fround(e)===e?this._pushUInt8(d)&&this._pushFloatBE(e):this._pushUInt8(y)&&this._pushDoubleBE(e)}_pushInt(e,t,r){const n=t<<5;switch(!1){case!(e<24):return this._pushUInt8(n|e);case!(e<=255):return this._pushUInt8(n|s.ONE)&&this._pushUInt8(e);case!(e<=65535):return this._pushUInt8(n|s.TWO)&&this._pushUInt16BE(e);case!(e<=4294967295):return this._pushUInt8(n|s.FOUR)&&this._pushUInt32BE(e);case!(e<=Number.MAX_SAFE_INTEGER):return this._pushUInt8(n|s.EIGHT)&&this._pushUInt32BE(Math.floor(e/a))&&this._pushUInt32BE(e%a);default:return t===o.NEG_INT?this._pushFloat(r):this._pushFloat(e)}}_pushIntNum(e){return Object.is(e,-0)?this.push(A):e<0?this._pushInt(-e-1,o.NEG_INT,e):this._pushInt(e,o.POS_INT)}_pushNumber(e){switch(!1){case!isNaN(e):return this._pushNaN();case isFinite(e):return this._pushInfinity(e);case Math.round(e)!==e:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){const t=u.byteLength(e,"utf8");return this._pushInt(t,o.UTF8_STRING)&&this.push(e,"utf8")}_pushBoolean(e){return this._pushUInt8(e?g:w)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(m);case"function":return this.pushAny(this.encodeUndefined.call(this,e));case"object":if(h(this.encodeUndefined))return this.push(this.encodeUndefined)}return this.pushAny(this.encodeUndefined)}_pushNull(e){return this._pushUInt8(E)}_pushArray(e,t,r){r=Object.assign({indefinite:!1},r);const n=t.length;if(r.indefinite){if(!e._pushUInt8(o.ARRAY<<5|s.INDEFINITE))return!1}else if(!e._pushInt(n,o.ARRAY))return!1;for(let r=0;r<n;r++)if(!e.pushAny(t[r]))return!1;return!(r.indefinite&&!e.push(_))}_pushTag(e){return this._pushInt(e,o.TAG)}_pushDate(e,t){switch(e.dateType){case"string":return e._pushTag(f.DATE_STRING)&&e._pushString(t.toISOString());case"int":case"integer":return e._pushTag(f.DATE_EPOCH)&&e._pushIntNum(Math.round(t/1e3));case"float":return e._pushTag(f.DATE_EPOCH)&&e._pushFloat(t/1e3);default:return e._pushTag(f.DATE_EPOCH)&&e.pushAny(t/1e3)}}_pushBuffer(e,t){return e._pushInt(t.length,o.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(f.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,o.ARRAY))return!1;for(const r of t)if(!e.pushAny(r))return!1;return!0}_pushUrl(e,t){return e._pushTag(f.URI)&&e.pushAny(t.format())}_pushURL(e,t){return e._pushTag(f.URI)&&e.pushAny(t.toString())}_pushBigint(e){let t=o.POS_INT,r=f.POS_BIGINT;if(e.isNegative()&&(e=e.negated().minus(1),t=o.NEG_INT,r=f.NEG_BIGINT),this.collapseBigIntegers&&e.lte(S.MAXINT64))return e.lte(S.MAXINT32)?this._pushInt(e.toNumber(),t):this._pushUInt8(t<<5|s.EIGHT)&&this._pushUInt32BE(e.dividedToIntegerBy(S.SHIFT32).toNumber())&&this._pushUInt32BE(e.mod(S.SHIFT32).toNumber());let n=e.toString(16);n.length%2&&(n="0"+n);const i=u.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushJSBigint(e){let t=o.POS_INT,r=f.POS_BIGINT;if(e<0&&(e=-e+v.MINUS_ONE,t=o.NEG_INT,r=f.NEG_BIGINT),this.collapseBigIntegers&&e<=v.MAXINT64)return e<=4294967295?this._pushInt(Number(e),t):this._pushUInt8(t<<5|s.EIGHT)&&this._pushUInt32BE(Number(e/v.SHIFT32))&&this._pushUInt32BE(Number(e%v.SHIFT32));let n=e.toString(16);n.length%2&&(n="0"+n);const i=u.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushBigint(t);if(!e._pushTag(f.DECIMAL_FRAC)||!e._pushInt(2,o.ARRAY))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(S.MAXINT)?e._pushIntNum(n.toNumber()):e._pushBigint(n))}_pushMap(e,t,n){if((n=Object.assign({indefinite:!1},n)).indefinite){if(!e._pushUInt8(o.MAP<<5|s.INDEFINITE))return!1}else if(!e._pushInt(t.size,o.MAP))return!1;if(e.canonical){const n=[...t.entries()],i=new O(this),o=new r({highWaterMark:this.readableHighWaterMark});i.pipe(o),n.sort((([e],[t])=>{i.pushAny(e);const r=o.read();i.pushAny(t);const n=o.read();return r.compare(n)}));for(const[t,r]of n){if(e.disallowUndefinedKeys&&void 0===t)throw new Error("Invalid Map key: undefined");if(!e.pushAny(t)||!e.pushAny(r))return!1}}else for(const[r,n]of t){if(e.disallowUndefinedKeys&&void 0===r)throw new Error("Invalid Map key: undefined");if(!e.pushAny(r)||!e.pushAny(n))return!1}return!(n.indefinite&&!e.push(_))}_pushUint8Array(e,t){return e._pushBuffer(e,u.from(t))}_pushFloat32Array(e,t){const r=t.length;if(!e._pushInt(r,o.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(d)||!e._pushFloatBE(t[n]))return!1;return!0}_pushFloat64Array(e,t){const r=t.length;if(!e._pushInt(r,o.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(y)||!e._pushDoubleBE(t[n]))return!1;return!0}removeLoopDetectors(e){return!!this.detectLoops&&O.removeLoopDetectors(e,this.detectLoops)}static removeLoopDetectors(e,t=null){if("object"!=typeof e||!e)return!1;const r=e[P];if(!r)return!1;if(null==t)t=r;else if(t!==r)return!1;if(delete e[P],Array.isArray(e))for(const r of e)this.removeLoopDetectors(r,t);else for(const r in e)this.removeLoopDetectors(e[r],t);return!0}_pushObject(e,t){if(!e)return this._pushNull(e);if(!(t=Object.assign({indefinite:!1,skipTypes:!1},t)).indefinite&&this.detectLoops){if(e[P]===this.detectLoops)throw new Error("Loop detected while CBOR encoding");e[P]=this.detectLoops}if(!t.skipTypes){const t=e.encodeCBOR;if("function"==typeof t)return t.call(e,this);const r=this.semanticTypes[e.constructor.name];if(r)return r.call(e,this,e)}const r=Object.keys(e).filter((t=>"function"!=typeof e[t])),n={};if(this.canonical&&r.sort(((e,t)=>{const r=n[e]||(n[e]=O.encode(e)),i=n[t]||(n[t]=O.encode(t));return r.compare(i)})),t.indefinite){if(!this._pushUInt8(o.MAP<<5|s.INDEFINITE))return!1}else if(!this._pushInt(r.length,o.MAP))return!1;let i;for(let t=0,o=r.length;t<o;t++){const o=r[t];if(this.canonical&&(i=n[o])){if(!this.push(i))return!1}else if(!this._pushString(o))return!1;if(!this.pushAny(e[o]))return!1}return!(t.indefinite&&!this.push(_))}pushAny(e){switch(typeof e){case"number":return this._pushNumber(e);case"bigint":return this._pushJSBigint(e);case"string":return this._pushString(e);case"boolean":return this._pushBoolean(e);case"undefined":return this._pushUndefined(e);case"object":return this._pushObject(e);case"symbol":switch(e){case c.NULL:return this._pushNull(null);case c.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e.toString?e.toString():""))}}_pushAny(e){return this.pushAny(e)}_encodeAll(e){const t=new r({highWaterMark:this.readableHighWaterMark});this.pipe(t);for(const t of e)this.pushAny(t);return this.end(),t.read()}static encodeIndefinite(e,t,r){if(null==t){if(null==this)throw new Error("No object to encode");t=this}r=Object.assign({chunkSize:4096},r);let n=!0;const i=typeof t;if("string"===i){n=n&&e._pushUInt8(o.UTF8_STRING<<5|s.INDEFINITE);let i=0;for(;i<t.length;){const o=i+r.chunkSize;n=n&&e._pushString(t.slice(i,o)),i=o}n=n&&e.push(_)}else if(h(t)){n=n&&e._pushUInt8(o.BYTE_STRING<<5|s.INDEFINITE);let i=0;for(;i<t.length;){const o=i+r.chunkSize;n=n&&e._pushBuffer(e,t.slice(i,o)),i=o}n=n&&e.push(_)}else if(Array.isArray(t))n=n&&e._pushArray(e,t,{indefinite:!0});else if(t instanceof Map)n=n&&e._pushMap(e,t,{indefinite:!0});else{if("object"!==i)throw new Error("Invalid indefinite encoding");n=n&&e._pushObject(t,{indefinite:!0,skipTypes:!0})}return n}static encode(...e){return(new O)._encodeAll(e)}static encodeCanonical(...e){return new O({canonical:!0})._encodeAll(e)}static encodeOne(e,t){return new O(t)._encodeAll([e])}static encodeAsync(e,t){return new Promise(((r,n)=>{const i=[],o=new O(t);o.on("data",(e=>i.push(e))),o.on("error",n),o.on("finish",(()=>r(u.concat(i)))),o.pushAny(e),o.end()}))}}return se=O}function Ee(){return fe||(fe=1,(e=F).BigNumber=K().BigNumber,e.Commented=function(){if(ne)return re;ne=1;const e=b,t=m;de(),ye();const r=me(),n=le(),i=K().BigNumber,o=ge(),s=n.MT,a=n.NUMBYTES,u=n.SYMS;function c(e){return e>1?"s":""}class f extends e.Transform{constructor(e){const t=Object.assign({depth:1,max_depth:10,no_summary:!1},e,{readableObjectMode:!1,writableObjectMode:!1}),n=t.max_depth;delete t.max_depth;const i=t.depth;delete t.depth,super(t),this.depth=i,this.max_depth=n,this.all=new o,t.tags={24:this._tag_24.bind(this)},this.parser=new r(t),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("start-string",this._on_start_string.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("error",this._on_error.bind(this)),t.no_summary||this.parser.on("data",this._on_data.bind(this)),this.parser.bs.on("read",this._on_read.bind(this))}_tag_24(e){const t=new f({depth:this.depth+1,no_summary:!0});t.on("data",(e=>this.push(e))),t.on("error",(e=>this.emit("error",e))),t.end(e)}_transform(e,t,r){this.parser.write(e,t,r)}_flush(e){return this.parser._flush(e)}static comment(e,t,r){if(null==e)throw new Error("input required");let n="string"==typeof e?"hex":void 0,i=10;switch(typeof t){case"function":r=t;break;case"string":n=t;break;case"number":i=t;break;case"object":const e=t.encoding,o=t.max_depth;n=null!=e?e:n,i=null!=o?o:i;break;case"undefined":break;default:throw new Error("Unknown option type")}const s=new o,a=new f({max_depth:i});let u=null;return"function"==typeof r?(a.on("end",(()=>{r(null,s.toString("utf8"))})),a.on("error",r)):u=new Promise(((e,t)=>(a.on("end",(()=>{e(s.toString("utf8"))})),a.on("error",t)))),a.pipe(s),a.end(e,n),u}_on_error(e){this.push("ERROR: "),this.push(e.toString()),this.push("\n")}_on_read(e){this.all.write(e);const t=e.toString("hex");this.push(new Array(this.depth+1).join(" ")),this.push(t);let r=2*(this.max_depth-this.depth);return r-=t.length,r<1&&(r=1),this.push(new Array(r+1).join(" ")),this.push("-- ")}_on_more(e,t,r,n){this.depth++;let i="";switch(e){case s.POS_INT:i="Positive number,";break;case s.NEG_INT:i="Negative number,";break;case s.ARRAY:i="Array, length";break;case s.MAP:i="Map, count";break;case s.BYTE_STRING:i="Bytes, length";break;case s.UTF8_STRING:i="String, length";break;case s.SIMPLE_FLOAT:i=1===t?"Simple value,":"Float,"}return this.push(i+" next "+t+" byte"+c(t)+"\n")}_on_start_string(e,t,r,n){this.depth++;let i="";switch(e){case s.BYTE_STRING:i="Bytes, length: "+t;break;case s.UTF8_STRING:i="String, length: "+t.toString()}return this.push(i+"\n")}_on_start(e,t,r,n){if(this.depth++,t!==u.BREAK)switch(r){case s.ARRAY:this.push(`[${n}], `);break;case s.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e){case s.TAG:this.push(`Tag #${t}`),24==t&&this.push(" Encoded CBOR data item");break;case s.ARRAY:t===u.STREAM?this.push("Array (streaming)"):this.push(`Array, ${t} item${c(t)}`);break;case s.MAP:t===u.STREAM?this.push("Map (streaming)"):this.push(`Map, ${t} pair${c(t)}`);break;case s.BYTE_STRING:this.push("Bytes (streaming)");break;case s.UTF8_STRING:this.push("String (streaming)")}return this.push("\n")}_on_stop(e){return this.depth--}_on_value(e,r,n,o){if(e!==u.BREAK)switch(r){case s.ARRAY:this.push(`[${n}], `);break;case s.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e===u.BREAK?this.push("BREAK\n"):e===u.NULL?this.push("null\n"):e===u.UNDEFINED?this.push("undefined\n"):"string"==typeof e?(this.depth--,e.length>0&&(this.push(JSON.stringify(e)),this.push("\n"))):h(e)?(this.depth--,e.length>0&&(this.push(e.toString("hex")),this.push("\n"))):e instanceof i?(this.push(e.toString()),this.push("\n")):(this.push(t.inspect(e)),this.push("\n")),o){case a.ONE:case a.TWO:case a.FOUR:case a.EIGHT:this.depth--}}_on_data(){return this.push("0x"),this.push(this.all.read().toString("hex")),this.push("\n")}}return re=f}(),e.Diagnose=function(){if(oe)return ie;oe=1;const e=b,t=m,r=me();ye();const n=de(),i=le(),o=K().BigNumber,s=ge(),a=i.MT,u=i.SYMS;class c extends e.Transform{constructor(e){const t=Object.assign({separator:"\n",stream_errors:!1},e,{readableObjectMode:!1,writableObjectMode:!1}),n=t.separator;delete t.separator;const i=t.stream_errors;delete t.stream_errors,super(t),this.float_bytes=-1,this.separator=n,this.stream_errors=i,this.parser=new r(t),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("data",this._on_data.bind(this)),this.parser.on("error",this._on_error.bind(this))}_transform(e,t,r){return this.parser.write(e,t,r)}_flush(e){return this.parser._flush((t=>this.stream_errors?(t&&this._on_error(t),e()):e(t)))}static diagnose(e,t,r){if(null==e)throw new Error("input required");let i={},o="hex";switch(typeof t){case"function":r=t,o=n.guessEncoding(e);break;case"object":i=n.extend({},t),o=null!=i.encoding?i.encoding:n.guessEncoding(e),delete i.encoding;break;default:o=null!=t?t:"hex"}const a=new s,u=new c(i);let f=null;return"function"==typeof r?(u.on("end",(()=>r(null,a.toString("utf8")))),u.on("error",r)):f=new Promise(((e,t)=>(u.on("end",(()=>e(a.toString("utf8")))),u.on("error",t)))),u.pipe(a),u.end(e,o),f}_on_error(e){return this.stream_errors?this.push(e.toString()):this.emit("error",e)}_on_more(e,t,r,n){if(e===a.SIMPLE_FLOAT)return this.float_bytes={2:1,4:2,8:3}[t]}_fore(e,t){switch(e){case a.BYTE_STRING:case a.UTF8_STRING:case a.ARRAY:if(t>0)return this.push(", ");break;case a.MAP:if(t>0)return t%2?this.push(": "):this.push(", ")}}_on_value(e,r,n){if(e!==u.BREAK)return this._fore(r,n),this.push((()=>{switch(!1){case e!==u.NULL:return"null";case e!==u.UNDEFINED:return"undefined";case"string"!=typeof e:return JSON.stringify(e);case!(this.float_bytes>0):const r=this.float_bytes;return this.float_bytes=-1,t.inspect(e)+"_"+r;case!h(e):return"h'"+e.toString("hex")+"'";case!(e instanceof o):return e.toString();default:return t.inspect(e)}})())}_on_start(e,t,r,n){switch(this._fore(r,n),e){case a.TAG:this.push(`${t}(`);break;case a.ARRAY:this.push("[");break;case a.MAP:this.push("{");break;case a.BYTE_STRING:case a.UTF8_STRING:this.push("(")}if(t===u.STREAM)return this.push("_ ")}_on_stop(e){switch(e){case a.TAG:return this.push(")");case a.ARRAY:return this.push("]");case a.MAP:return this.push("}");case a.BYTE_STRING:case a.UTF8_STRING:return this.push(")")}}_on_data(){return this.push(this.separator)}}return ie=c}(),e.Decoder=me(),e.Encoder=be(),e.Simple=ye(),e.Tagged=we(),e.Map=function(){if(ce)return ue;ce=1;const e=be(),t=me(),r=le().MT;class n extends Map{constructor(e){super(e)}static _encode(t){return e.encodeCanonical(t).toString("base64")}static _decode(e){return t.decodeFirstSync(e,"base64")}get(e){return super.get(n._encode(e))}set(e,t){return super.set(n._encode(e),t)}delete(e){return super.delete(n._encode(e))}has(e){return super.has(n._encode(e))}*keys(){for(const e of super.keys())yield n._decode(e)}*entries(){for(const e of super.entries())yield[n._decode(e[0]),e[1]]}[Symbol.iterator](){return this.entries()}forEach(e,t){if("function"!=typeof e)throw new TypeError("Must be function");for(const t of super.entries())e.call(this,t[1],n._decode(t[0]),this)}encodeCBOR(e){if(!e._pushInt(this.size,r.MAP))return!1;if(e.canonical){const t=Array.from(super.entries()).map((e=>[u.from(e[0],"base64"),e[1]]));t.sort(((e,t)=>e[0].compare(t[0])));for(const r of t)if(!e.push(r[0])||!e.pushAny(r[1]))return!1}else for(const t of super.entries())if(!e.push(u.from(t[0],"base64"))||!e.pushAny(t[1]))return!1;return!0}}return ue=n}(),e.comment=e.Commented.comment,e.decodeAll=e.Decoder.decodeAll,e.decodeFirst=e.Decoder.decodeFirst,e.decodeAllSync=e.Decoder.decodeAllSync,e.decodeFirstSync=e.Decoder.decodeFirstSync,e.diagnose=e.Diagnose.diagnose,e.encode=e.Encoder.encode,e.encodeCanonical=e.Encoder.encodeCanonical,e.encodeOne=e.Encoder.encodeOne,e.encodeAsync=e.Encoder.encodeAsync,e.decode=e.Decoder.decodeFirstSync,e.leveldb={decode:e.Decoder.decodeAllSync,encode:e.Encoder.encode,buffer:!0,name:"cbor"},e.hasBigInt=de().hasBigInt),F;var e}var _e,ve,Se,Ie,Te,ke,Ae,Pe,Oe,Ne,Ue,xe,Be,Re,Me,Le,Ce,He,De,Fe={exports:{}};function je(){if(ke)return Te;ke=1;const{Buffer:e}=E;return Te=function(t){return{encode:t=>"string"==typeof t?e.from(t).toString("hex"):t.toString("hex"),decode(r){for(const e of r)if(t.indexOf(e)<0)throw new Error("invalid base16 character");return e.from(r,"hex")}}}}function Ve(){if(Pe)return Ae;function e(e,t){const r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-1));let o=0,s=0,a="";for(let e=0;e<r;e++)for(s=s<<8|n[e],o+=8;o>=5;)a+=t[s>>>o-5&31],o-=5;if(o>0&&(a+=t[s<<5-o&31]),i)for(;a.length%8!=0;)a+="=";return a}return Pe=1,Ae=function(t){return{encode:r=>e("string"==typeof r?Uint8Array.from(r):r,t),decode(e){for(const r of e)if(t.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){const r=(e=e.replace(new RegExp("=","g"),"")).length;let n=0,i=0,o=0;const s=new Uint8Array(5*r/8|0);for(let a=0;a<r;a++)i=i<<5|t.indexOf(e[a]),n+=5,n>=8&&(s[o++]=i>>>n-8&255,n-=8);return s.buffer}(e,t)}}}}function Ke(){if(Ne)return Oe;Ne=1;const{Buffer:e}=E;return Oe=function(t){const r=t.indexOf("=")>-1,n=t.indexOf("-")>-1&&t.indexOf("_")>-1;return{encode(t){let i="";i="string"==typeof t?e.from(t).toString("base64"):t.toString("base64"),n&&(i=i.replace(/\+/g,"-").replace(/\//g,"_"));const o=i.indexOf("=");return o>0&&!r&&(i=i.substring(0,o)),i},decode(r){for(const e of r)if(t.indexOf(e)<0)throw new Error("invalid base64 character");return e.from(r,"base64")}}}}function Ge(){if(xe)return Ue;xe=1;const e=ve?_e:(ve=1,_e=class{constructor(e,t,r,n){this.name=e,this.code=t,this.alphabet=n,r&&n&&(this.engine=r(n))}encode(e){return this.engine.encode(e)}decode(e){return this.engine.decode(e)}isImplemented(){return this.engine}}),t=function(){if(Ie)return Se;Ie=1;var e=d().Buffer;return Se=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return e.alloc(0);for(var n=0,i=0,o=0;t[n]===u;)i++,n++;for(var s=(t.length-n)*c+1>>>0,f=new Uint8Array(s);t[n];){var h=r[t.charCodeAt(n)];if(255===h)return;for(var p=0,l=s-1;(0!==h||p<o)&&-1!==l;l--,p++)h+=a*f[l]>>>0,f[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,n++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=e.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(r){if((Array.isArray(r)||r instanceof Uint8Array)&&(r=e.from(r)),!e.isBuffer(r))throw new TypeError("Expected Buffer");if(0===r.length)return"";for(var n=0,i=0,o=0,s=r.length;o!==s&&0===r[o];)o++,n++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var p=r[o],l=0,d=c-1;(0!==p||l<i)&&-1!==d;d--,l++)p+=256*h[d]>>>0,h[d]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,o++}for(var y=c-i;y!==c&&0===h[y];)y++;for(var g=u.repeat(n);y<c;++y)g+=t.charAt(h[y]);return g},decodeUnsafe:h,decode:function(e){var t=h(e);if(t)return t;throw new Error("Non-base"+a+" character")}}},Se}(),r=je(),n=Ve(),i=Ke(),o=[["base1","1","","1"],["base2","0",t,"01"],["base8","7",t,"01234567"],["base10","9",t,"0123456789"],["base16","f",r,"0123456789abcdef"],["base32","b",n,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",n,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",n,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",n,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",n,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",t,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",t,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",i,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",i,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",i,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",i,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],s=o.reduce(((t,r)=>(t[r[0]]=new e(r[0],r[1],r[2],r[3]),t)),{}),a=o.reduce(((e,t)=>(e[t[1]]=s[t[0]],e)),{});return Ue={names:s,codes:a}}function We(){return Be||(Be=1,function(e,t){const{Buffer:r}=E,n=Ge();(t=e.exports=o).encode=function(e,t){const n=s(e),i=n.name;return o(i,r.from(n.encode(t)))},t.decode=function(e){r.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);"string"==typeof(e=e.substring(1,e.length))&&(e=r.from(e));const n=s(t);return r.from(n.decode(e.toString()))},t.isEncoded=function(e){r.isBuffer(e)&&(e=e.toString());if("[object String]"!==Object.prototype.toString.call(e))return!1;const t=e.substring(0,1);try{return s(t).name}catch(e){return!1}},t.names=Object.freeze(Object.keys(n.names)),t.codes=Object.freeze(Object.keys(n.codes));const i=new Error("Unsupported encoding");function o(e,t){if(!t)throw new Error("requires an encoded buffer");const n=s(e),i=r.from(n.code);return function(e,t){const r=s(e);r.decode(t.toString())}(n.name,t),r.concat([i,t])}function s(e){let t;if(n.names[e])t=n.names[e];else{if(!n.codes[e])throw i;t=n.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}}(Fe,Fe.exports)),Fe.exports}function Xe(){if(Me)return Re;Me=1;var e=9007199254740991,t="[object Arguments]",r="[object Function]",n="[object GeneratorFunction]",i="object"==typeof s&&s&&s.Object===Object&&s,o="object"==typeof self&&self&&self.Object===Object&&self,a=i||o||Function("return this")();function u(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var c=Object.prototype,f=c.hasOwnProperty,h=c.toString,p=a.Symbol,l=c.propertyIsEnumerable,d=p?p.isConcatSpreadable:void 0;function y(i){return g(i)||function(i){return function(t){return function(e){return!!e&&"object"==typeof e}(t)&&function(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=e}(t.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?h.call(e):"";return t==r||t==n}(t)}(t)}(i)&&f.call(i,"callee")&&(!l.call(i,"callee")||h.call(i)==t)}(i)||!!(d&&i&&i[d])}var g=Array.isArray;return Re=function(e){return(e?e.length:0)?function(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=y),i||(i=[]);++o<s;){var a=e[o];r(a)?u(i,a):i[i.length]=a}return i}(e):[]}}function qe(){if(De)return He;De=1;var e=9007199254740991,t="[object Arguments]",r="[object Function]",n="[object GeneratorFunction]",i=/^(?:0|[1-9]\d*)$/;var o,s,a=Object.prototype,u=a.hasOwnProperty,c=a.toString,f=a.propertyIsEnumerable,h=(o=Object.keys,s=Object,function(e){return o(s(e))});function p(e,r){var n=w(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&m(e)}(e)&&u.call(e,"callee")&&(!f.call(e,"callee")||c.call(e)==t)}(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],i=n.length,o=!!i;for(var s in e)!u.call(e,s)||o&&("length"==s||g(s,i))||n.push(s);return n}var l=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[++n];if(!1===t(i[a],a,i))break}return e};function d(e,t,r,n){return function(e,t){e&&l(e,t,S)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function y(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||a,t!==n)return h(e);var t,r,n,i=[];for(var o in Object(e))u.call(e,o)&&"constructor"!=o&&i.push(o);return i}function g(t,r){return!!(r=null==r?e:r)&&("number"==typeof t||i.test(t))&&t>-1&&t%1==0&&t<r}var w=Array.isArray;function m(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=e}(t.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?c.call(e):"";return t==r||t==n}(t)}var b,E,_,v=(b=function(e,t,r){e[t]=r},_=function(e){return e},E=function(){return _},function(e,t){return d(e,b,E(t),{})});function S(e){return m(e)?p(e):y(e)}return He=v}var ze,$e,Ye,Je,Qe,Ze={exports:{}};function et(){return ze||(ze=1,function(e,t){var r="__lodash_hash_undefined__",n=9007199254740991,i="[object Arguments]",o="[object Array]",a="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",l="[object Object]",d="[object Promise]",y="[object RegExp]",g="[object Set]",w="[object String]",m="[object Symbol]",b="[object WeakMap]",E="[object ArrayBuffer]",_="[object DataView]",v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,I=/^\./,T=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,k=/\\(\\)?/g,A=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[i]=O[o]=O[E]=O[a]=O[_]=O[u]=O[c]=O[f]=O[h]=O[p]=O[l]=O[y]=O[g]=O[w]=O[b]=!1;var N="object"==typeof s&&s&&s.Object===Object&&s,U="object"==typeof self&&self&&self.Object===Object&&self,x=N||U||Function("return this")(),B=t&&!t.nodeType&&t,R=B&&e&&!e.nodeType&&e,M=R&&R.exports===B&&N.process,L=function(){try{return M&&M.binding("util")}catch(e){}}(),C=L&&L.isTypedArray;function H(e,t){for(var r=-1,n=e?e.length:0;++r<n;)if(t(e[r],r,e))return!0;return!1}function D(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function F(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function j(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var V,K,G,W=Array.prototype,X=Function.prototype,q=Object.prototype,z=x["__core-js_shared__"],$=(V=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Y=X.toString,J=q.hasOwnProperty,Q=q.toString,Z=RegExp("^"+Y.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=x.Symbol,te=x.Uint8Array,re=q.propertyIsEnumerable,ne=W.splice,ie=(K=Object.keys,G=Object,function(e){return K(G(e))}),oe=Le(x,"DataView"),se=Le(x,"Map"),ae=Le(x,"Promise"),ue=Le(x,"Set"),ce=Le(x,"WeakMap"),fe=Le(Object,"create"),he=Ge(oe),pe=Ge(se),le=Ge(ae),de=Ge(ue),ye=Ge(ce),ge=ee?ee.prototype:void 0,we=ge?ge.valueOf:void 0,me=ge?ge.toString:void 0;function be(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ee(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function _e(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ve(e){var t=-1,r=e?e.length:0;for(this.__data__=new _e;++t<r;)this.add(e[t])}function Se(e){this.__data__=new Ee(e)}function Ie(e,t){var r=ze(e)||qe(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,i=!!n;for(var o in e)!J.call(e,o)||i&&("length"==o||He(o,n))||r.push(o);return r}function Te(e,t){for(var r=e.length;r--;)if(Xe(e[r][0],t))return r;return-1}be.prototype.clear=function(){this.__data__=fe?fe(null):{}},be.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},be.prototype.get=function(e){var t=this.__data__;if(fe){var n=t[e];return n===r?void 0:n}return J.call(t,e)?t[e]:void 0},be.prototype.has=function(e){var t=this.__data__;return fe?void 0!==t[e]:J.call(t,e)},be.prototype.set=function(e,t){return this.__data__[e]=fe&&void 0===t?r:t,this},Ee.prototype.clear=function(){this.__data__=[]},Ee.prototype.delete=function(e){var t=this.__data__,r=Te(t,e);return!(r<0)&&(r==t.length-1?t.pop():ne.call(t,r,1),!0)},Ee.prototype.get=function(e){var t=this.__data__,r=Te(t,e);return r<0?void 0:t[r][1]},Ee.prototype.has=function(e){return Te(this.__data__,e)>-1},Ee.prototype.set=function(e,t){var r=this.__data__,n=Te(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},_e.prototype.clear=function(){this.__data__={hash:new be,map:new(se||Ee),string:new be}},_e.prototype.delete=function(e){return Me(this,e).delete(e)},_e.prototype.get=function(e){return Me(this,e).get(e)},_e.prototype.has=function(e){return Me(this,e).has(e)},_e.prototype.set=function(e,t){return Me(this,e).set(e,t),this},ve.prototype.add=ve.prototype.push=function(e){return this.__data__.set(e,r),this},ve.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.clear=function(){this.__data__=new Ee},Se.prototype.delete=function(e){return this.__data__.delete(e)},Se.prototype.get=function(e){return this.__data__.get(e)},Se.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!se||n.length<199)return n.push([e,t]),this;r=this.__data__=new _e(n)}return r.set(e,t),this};var ke=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[++n];if(!1===t(i[a],a,i))break}return e};function Ae(e,t){for(var r=0,n=(t=De(t,e)?[t]:Be(t)).length;null!=e&&r<n;)e=e[Ke(t[r++])];return r&&r==n?e:void 0}function Pe(e,t){return null!=e&&t in Object(e)}function Oe(e,t,r,n){return function(e,t){e&&ke(e,t,ot)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Ne(e,t,r,n,s){return e===t||(null==e||null==t||!Qe(e)&&!Ze(t)?e!=e&&t!=t:function(e,t,r,n,s,f){var d=ze(e),b=ze(t),v=o,S=o;d||(v=(v=Ce(e))==i?l:v);b||(S=(S=Ce(t))==i?l:S);var I=v==l&&!D(e),T=S==l&&!D(t),k=v==S;if(k&&!I)return f||(f=new Se),d||tt(e)?Re(e,t,r,n,s,f):function(e,t,r,n,i,o,s){switch(r){case _:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case E:return!(e.byteLength!=t.byteLength||!n(new te(e),new te(t)));case a:case u:case p:return Xe(+e,+t);case c:return e.name==t.name&&e.message==t.message;case y:case w:return e==t+"";case h:var f=F;case g:var l=2&o;if(f||(f=j),e.size!=t.size&&!l)return!1;var d=s.get(e);if(d)return d==t;o|=1,s.set(e,t);var b=Re(f(e),f(t),n,i,o,s);return s.delete(e),b;case m:if(we)return we.call(e)==we.call(t)}return!1}(e,t,v,r,n,s,f);if(!(2&s)){var A=I&&J.call(e,"__wrapped__"),P=T&&J.call(t,"__wrapped__");if(A||P){var O=A?e.value():e,N=P?t.value():t;return f||(f=new Se),r(O,N,n,s,f)}}if(!k)return!1;return f||(f=new Se),function(e,t,r,n,i,o){var s=2&i,a=ot(e),u=a.length,c=ot(t),f=c.length;if(u!=f&&!s)return!1;var h=u;for(;h--;){var p=a[h];if(!(s?p in t:J.call(t,p)))return!1}var l=o.get(e);if(l&&o.get(t))return l==t;var d=!0;o.set(e,t),o.set(t,e);var y=s;for(;++h<u;){var g=e[p=a[h]],w=t[p];if(n)var m=s?n(w,g,p,t,e,o):n(g,w,p,e,t,o);if(!(void 0===m?g===w||r(g,w,n,i,o):m)){d=!1;break}y||(y="constructor"==p)}if(d&&!y){var b=e.constructor,E=t.constructor;b==E||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E||(d=!1)}return o.delete(e),o.delete(t),d}(e,t,r,n,s,f)}(e,t,Ne,r,n,s))}function Ue(e){return!(!Qe(e)||function(e){return!!$&&$ in e}(e))&&(Ye(e)||D(e)?Z:A).test(Ge(e))}function xe(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||q,t!==n)return ie(e);var t,r,n,i=[];for(var o in Object(e))J.call(e,o)&&"constructor"!=o&&i.push(o);return i}function Be(e){return ze(e)?e:Ve(e)}function Re(e,t,r,n,i,o){var s=2&i,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var f=-1,h=!0,p=1&i?new ve:void 0;for(o.set(e,t),o.set(t,e);++f<a;){var l=e[f],d=t[f];if(n)var y=s?n(d,l,f,t,e,o):n(l,d,f,e,t,o);if(void 0!==y){if(y)continue;h=!1;break}if(p){if(!H(t,(function(e,t){if(!p.has(t)&&(l===e||r(l,e,n,i,o)))return p.add(t)}))){h=!1;break}}else if(l!==d&&!r(l,d,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function Me(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function Le(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Ue(r)?r:void 0}var Ce=function(e){return Q.call(e)};function He(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||P.test(e))&&e>-1&&e%1==0&&e<t}function De(e,t){if(ze(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!et(e))||(S.test(e)||!v.test(e)||null!=t&&e in Object(t))}function Fe(e){return e==e&&!Qe(e)}function je(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}(oe&&Ce(new oe(new ArrayBuffer(1)))!=_||se&&Ce(new se)!=h||ae&&Ce(ae.resolve())!=d||ue&&Ce(new ue)!=g||ce&&Ce(new ce)!=b)&&(Ce=function(e){var t=Q.call(e),r=t==l?e.constructor:void 0,n=r?Ge(r):void 0;if(n)switch(n){case he:return _;case pe:return h;case le:return d;case de:return g;case ye:return b}return t});var Ve=We((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(et(e))return me?me.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var r=[];return I.test(e)&&r.push(""),e.replace(T,(function(e,t,n,i){r.push(n?i.replace(k,"$1"):t||e)})),r}));function Ke(e){if("string"==typeof e||et(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Ge(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function We(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(We.Cache||_e),r}function Xe(e,t){return e===t||e!=e&&t!=t}function qe(e){return function(e){return Ze(e)&&$e(e)}(e)&&J.call(e,"callee")&&(!re.call(e,"callee")||Q.call(e)==i)}We.Cache=_e;var ze=Array.isArray;function $e(e){return null!=e&&Je(e.length)&&!Ye(e)}function Ye(e){var t=Qe(e)?Q.call(e):"";return t==f||"[object GeneratorFunction]"==t}function Je(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}function Qe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return!!e&&"object"==typeof e}function et(e){return"symbol"==typeof e||Ze(e)&&Q.call(e)==m}var tt=C?function(e){return function(t){return e(t)}}(C):function(e){return Ze(e)&&Je(e.length)&&!!O[Q.call(e)]};var rt,nt,it=(rt=function(e,t,r){J.call(e,t)?e[t].push(r):e[t]=[r]},nt=function(e){return"function"==typeof e?e:null==e?st:"object"==typeof e?ze(e)?function(e,t){return De(e)&&Fe(t)?je(Ke(e),t):function(r){var n=function(e,t,r){var n=null==e?void 0:Ae(e,t);return void 0===n?r:n}(r,e);return void 0===n&&n===t?function(e,t){return null!=e&&function(e,t,r){t=De(t,e)?[t]:Be(t);for(var n,i=-1,o=t.length;++i<o;){var s=Ke(t[i]);if(!(n=null!=e&&r(e,s)))break;e=e[s]}return n||!!(o=e?e.length:0)&&Je(o)&&He(s,o)&&(ze(e)||qe(e))}(e,t,Pe)}(r,e):Ne(t,n,void 0,3)}}(e[0],e[1]):(r=function(e){for(var t=ot(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Fe(i)]}return t}(t=e),1==r.length&&r[0][2]?je(r[0][0],r[0][1]):function(e){return e===t||function(e,t,r,n){var i=r.length,o=i;if(null==e)return!o;for(e=Object(e);i--;){var s=r[i];if(s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){var a=(s=r[i])[0],u=e[a],c=s[1];if(s[2]){if(void 0===u&&!(a in e))return!1}else if(!Ne(c,u,n,3,new Se))return!1}return!0}(e,0,r)}):De(n=e)?(i=Ke(n),function(e){return null==e?void 0:e[i]}):function(e){return function(t){return Ae(t,e)}}(n);var t,r,n,i},function(e,t){return Oe(e,rt,nt(t),{})});function ot(e){return $e(e)?Ie(e):xe(e)}function st(e){return e}e.exports=it}(Ze,Ze.exports)),Ze.exports}var tt=function(){if(Qe)return Je;Qe=1;const e=function(){if(Ce)return Le;Ce=1;const{validate:e}=C(),t=H(),r=Ee(),n=We(),i=Xe();return Le=class{constructor(t){if(!e(t))throw new Error("JSON is invalid. Cannot construct Encoder.");this.json=t}constructRootMap(){return Object.keys(this.json).map((e=>{let n=this.json[e];return"string"==typeof n&&(n=r.encode(u.from(n,"hex"))),n instanceof Array&&("anchors"===e&&(n=this.constructAnchorsMap(n)),"path"===e&&(n=this.constructPathMap(n))),[t.root[e],n]}))}constructAnchorsMap(e){return e.map((e=>{let n=e.split(":");return n.shift(),n.map(((e,i)=>0===i?[i,t.chain[e].id]:1===i?[i,t.chain[n[i-1]].networks[e]]:[i,r.encode(u.from(e,"hex"))]))}))}constructPathMap(e){return i(e.map((e=>Object.keys(e).map((n=>[t.path[n],r.encode(u.from(e[n],"hex"))])))))}encode(){const e=this.constructRootMap(),t=r.encode(e);return n.encode("base58btc",t)}},Le}(),t=function(){if(Ye)return $e;Ye=1;const e=H(),t=Ee(),r=We(),n=qe(),i=et();return $e=class{constructor(e){if(!r.isEncoded(e))throw new Error("Base58 string is invalid. Cannot construct Decoder.");this.base58=e}constructRootJSON(r){const i=n(e.root);return r.reduce(((e,r)=>{const n=i[r[0]];let o=r[1];return o instanceof Array&&("anchors"===n&&(o=this.constructAnchorsJSON(o)),"path"===n&&(o=this.constructPathJSON(o))),o instanceof u&&(o=t.decode(o).toString("hex")),e[n]=o,e}),{})}constructAnchorsJSON(r){const o=i(e.chain,(e=>e.id));return r.map((r=>r.reduce(((r,i)=>{if(0===i[0])return`${r}:${o[i[1]]}`;if(1===i[0]){const t=r.split(":").pop();return`${r}:${n(e.chain[t].networks)[i[1]]}`}return`${r}:${t.decode(i[1]).toString("hex")}`}),"blink")))}constructPathJSON(r){const i=n(e.path);return r.map((e=>({[i[e[0]]]:t.decode(e[1]).toString("hex")})))}decode(){const e=r.decode(this.base58),n=t.decode(e);return this.constructRootJSON(n)}},$e}(),r=H();return Je={Encoder:e,Decoder:t,Keymap:r}}();function rt(e){return Object.keys(f).map((e=>f[e])).find((t=>t.signatureValue===e))}function nt(e=null){if(null==e?void 0:e.anchors){const{anchors:t}=e,r=t[0];if("string"==typeof r)return function(e){const t=e.split(":");let r;switch(t[1]){case f.mocknet.blinkCode:return rt(f.mocknet.signatureValue);case f.bitcoin.blinkCode:r=f.bitcoin.name;break;case f.ethmain.blinkCode:r=f.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}const n=t[2];return rt(r.toLowerCase()+function(e){const t=e.substr(0,1),r=e.substr(1,e.length-1);return t.toUpperCase()+r.toLowerCase()}(n))}(r)}return null}function it(e,t){const r=e.findIndex((e=>e===t));r>-1&&e.splice(r,1)}var ot={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",obi:"https://w3id.org/openbadges#",cp:"https://w3id.org/chainpoint#",schema:"http://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2017:"sec:MerkleProof2017",RecipientProfile:"bc:RecipientProfile",SignatureLine:"bc:SignatureLine",MerkleProofVerification2017:"bc:MerkleProofVerification2017",recipientProfile:"bc:recipientProfile",signatureLines:"bc:signatureLines",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},subtitle:"bc:subtitle",jobTitle:"schema:jobTitle",creator:{"@id":"dc:creator","@type":"@id"},expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},revoked:{"@id":"sec:expiration","@type":"xsd:dateTime"},CryptographicKey:"sec:Key",signature:"sec:signature",verification:"bc:verification",publicKeys:"bc:publicKeys",ChainpointSHA256v2:"cp:ChainpointSHA256v2",BTCOpReturn:"cp:BTCOpReturn",targetHash:"cp:targetHash",merkleRoot:"cp:merkleRoot",proof:"cp:proof",anchors:"cp:anchors",sourceId:"cp:sourceId",right:"cp:right",left:"cp:left"},"obi:validation":[{"obi:validatesType":"RecipientProfile","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/recipientSchema.json"},{"obi:validatesType":"SignatureLine","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/signatureLineSchema.json"},{"obi:validatesType":"MerkleProof2017","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/merkleProof2017Schema.json"}]},st={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",cp:"https://w3id.org/chainpoint#",schema:"http://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2019:"sec:MerkleProof2019",BlockcertsCredential:"bc:BlockcertsCredential",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},CryptographicKey:"sec:Key",domain:"sec:domain",nonce:"sec:nonce",proofValue:"sec:proofValue",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},created:{"@id":"bc:created","@type":"xsd:dateTime"},name:{"@id":"schema:name"}}},at={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",cp:"https://w3id.org/chainpoint#",vc:"https://www.w3.org/2018/credentials/v1",schema:"https://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2019:"sec:MerkleProof2019",BlockcertsCredential:"bc:BlockcertsCredential",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},metadata:"bc:metadata",display:{"@id":"bc:display","@context":{id:"@id",type:"@type",contentMediaType:{"@id":"bc:contentMediaType","@type":"@id"},contentEncoding:{"@id":"bc:contentEncoding","@type":"@id"},content:{"@id":"bc:content","@type":"@id"}}},CryptographicKey:"sec:Key",domain:"sec:domain",nonce:"sec:nonce",proofValue:"sec:proofValue",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},created:{"@id":"https://purl.org/dc/terms/created","@type":"xsd:dateTime"},challenge:"sec:challenge",expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},name:{"@id":"schema:name"},description:{"@id":"schema:description"},email:{"@id":"schema:email"},publicKey:{"@id":"sec:publicKey","@type":"@id"},url:{"@id":"schema:url","@type":"@id"},image:{"@id":"schema:image","@type":"@id"}}},ut={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2020:{"@id":"https://w3id.org/security#Ed25519VerificationKey2020","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},Ed25519Signature2020:{"@id":"https://w3id.org/security#Ed25519Signature2020","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},proofValue:{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};function ct(e){e=e.trim();const t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substring(r,r+2),16));return t}e["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=ot,e["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=ot,e["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=st,e["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=st,e["https://w3id.org/blockcerts/v3.0-alpha"]=st,e["https://www.blockcerts.org/schema/3.0-beta/context.json"]=at,e["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=at,e["https://w3id.org/blockcerts/v3.0-beta"]=at,e["https://w3id.org/security/suites/ed25519-2020/v1"]=ut;class ft extends Error{constructor(e,t){super(t),this.stepCode=e}}var ht="en-US",pt={"en-US":{errors:{ensureHashesEqual:"Computed hash does not match remote hash",ensureMerkleRootEqual:"Merkle root does not match remote hash.",ensureValidReceipt:"The receipt is malformed. There was a problem navigating the merkle tree in the receipt.",failedJsonLdNormalization:"Failed JSON-LD normalization",foundUnmappedFields:"Found unmapped fields during JSON-LD normalization",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Cannot verify this certificate without a transaction ID to compare against.",invalidMerkleReceipt:"Invalid Merkle Receipt. Proof hash did not match Merkle root",isTransactionIdValid:"Cannot verify this certificate without a transaction ID to compare against.",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},fr:{errors:{ensureHashesEqual:"Calcul du hash local différent du hash distant",ensureMerkleRootEqual:"Le Merkle root ne correspond pas au hash distant",ensureValidReceipt:"Erreur d'écriture du reçu. Un problème est survenu lors de la navigation de l'arbre Merkle du reçu.",failedJsonLdNormalization:"Erreur de normalisation JSON-LD",foundUnmappedFields:"Champs non liés découverts durant la normalisation JSON-LD",identityErrorBaseMessage:"Identité de l'émetteur invalide",deriveIssuingAddressFromPublicKey:"Cette blockchain n'est pas supportée pour la vérification de l'identité décentralisée.",compareIssuingAddress:"La méthode de vérification n'a pas permis d'établir l'identité de l'émetteur.",getTransactionId:"Impossible de vérifier ce certificat sans un identifiant de transaction valide",invalidMerkleReceipt:"Reçu Merkle invalide. Hash de preuve différent du Merkle root",isTransactionIdValid:"Impossible de vérifier ce certificat sans un identifiant de transaction valide",noProofSpecified:"La propriété 'proof' du document est un tableau mais aucune preuve n'a été passée pour savoir ce qu'il faut vérifier"}},es:{errors:{ensureHashesEqual:"La cadena binaria calculada no corresponde con la cadena binaria remota",ensureMerkleRootEqual:"La raíz Merkle no corresponde con la cadena binaria remota",ensureValidReceipt:"El recibo está malformado. Hubo un problema navegando el árbol Merkle en el recibo",failedJsonLdNormalization:"La normalización del JSON-LD ha fallado",foundUnmappedFields:"Se han encontrado campos no mapeados durante la normalización de JSON-LD",identityErrorBaseMessage:"Identitad del emisor inválida",deriveIssuingAddressFromPublicKey:"No se puede validar la identitad decentalisada con esta cadena binaria.",compareIssuingAddress:"El metodo de verificación no corresponde a la identitad del emisor.",getTransactionId:"No se puede verificar este certificado sin una identificación de transacción que sirva como comparación",invalidMerkleReceipt:"Recibo Merkle inválido. La cadena binaria de prueba no corresponde con la raíz Merkle",isTransactionIdValid:"No se puede verificar este certificado sin una identificación de transacción que sirva como comparación",noProofSpecified:"La propiedad 'proof' del documento es una lista, pero no prueba especifica ha sido declarada para conocer el punto de verificación"}},mt:{errors:{ensureHashesEqual:"Il-hash ikkalkulat ma jikkorrispondix mar-remote hash",ensureMerkleRootEqual:"Merkle root ma taqbilx mar-remote hash",ensureValidReceipt:"L-irċevuta hija malformata. Kien hemm problema fin-navigazzjoni tal-merkle tree fl-irċevuta",failedJsonLdNormalization:"In-normalizzazzjoni ta' JSON-LD ma rnexxietx",foundUnmappedFields:"Instabu unmapped fields matul in-normalizzazzjoni JSON-LD",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Dan iċ-ċertifikat ma jistax jiġi vverifikat mingħajr ID ta' tranżazzjoni mqabbla miegħu",invalidMerkleReceipt:"Irċevuta Merkle invalida. Il-proof hash ma kienx jaqbel mal-Merkle root",isTransactionIdValid:"Dan iċ-ċertifikat ma jistax jiġi vverifikat mingħajr ID ta' tranżazzjoni mqabbla miegħu",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},"it-IT":{errors:{ensureHashesEqual:"L'hash calcolato non corrisponde all'hash remoto",ensureMerkleRootEqual:"La radice di Merkle non corrisponde all'hash remoto.",ensureValidReceipt:"La ricevuta è malformata. C'è stato un problema nella navigazione dell'albero di Merkle nella ricevuta.",failedJsonLdNormalization:"Normalizzazione JSON-LD fallita",foundUnmappedFields:"Campi non mappati trovati durante la normalizzazione JSON-LD",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Impossibile verificare questo certificato senza un ID transazione da confrontare.",invalidMerkleReceipt:"Ricevuta Merkle non valida. L'hash di prova non corrisponde alla radice di Merkle",isTransactionIdValid:"Impossibile verificare questo certificato senza un ID transazione da confrontare.",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},ja:{errors:{ensureHashesEqual:"算出されたハッシュがリモートハッシュと一致しませんでした",ensureMerkleRootEqual:"Merkle rootがリモートハッシュと一致しませんでした",ensureValidReceipt:"レシートが異常です。レシート内のMerkle treeを辿る際に問題が発生しました。",failedJsonLdNormalization:"JSON-LDの正規化に失敗しました",foundUnmappedFields:"JSON-LDの正規化時にマップされていないフィールドを検出しました",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"照合のための取引IDがないため、この証明書を認証できません。",invalidMerkleReceipt:"Merkleレシートが無効です。証明ハッシュがMerkle rootと一致しませんでした。",isTransactionIdValid:"照合するための取引IDがないため、この証明書を認証できません。",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}}};function lt(e,t){return e&&t?pt[ht]?pt[ht][e]?pt[ht][e][t]?pt[ht][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var dt,yt,gt,wt,mt=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};function bt(t){return mt(this,arguments,void 0,(function*(t,r=null,n=e=>mt(this,void 0,void 0,(function*(){return Promise}))){t["@context"].find((e=>{return(t=e)===Object(t)&&"@vocab"in e;var t}))||t["@context"].push({"@vocab":"http://fallback.org/"});const i=JSON.parse(JSON.stringify(t));if(Array.isArray(i.proof)){if(!r)throw new ft("computeLocalHash",lt("errors","noProofSpecified"));const e=i.proof.findIndex((e=>e.proofValue===r.proofValue));i.proof=i.proof.slice(0,e)}else delete i.proof;const o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(t){return mt(this,void 0,void 0,(function*(){return null!=n&&(yield n(t)),t in e?{contextUrl:null,document:e[t],documentUrl:t}:v.documentLoader(t)}))},safe:!1};let s;try{s=yield v.normalize(i,o)}catch(e){throw console.error(e),new ft("computeLocalHash",lt("errors","failedJsonLdNormalization"))}const a=function(e){const t=e.split("\n"),r=/<http:\/\/fallback\.org\/(.*)>/,n=t.map((e=>r.exec(e))).filter((e=>null!=e));if(n.length>0){const e=n.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(s);if(a)throw new ft("computeLocalHash",`${lt("errors","foundUnmappedFields")}: ${a.join(", ")}`);return I(function(e){const t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}(s))}))}!function(){if(wt)return gt;wt=1;var e=function(){if(yt)return dt;yt=1;var e=d().Buffer;return dt=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(255!==r[s])throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return e.alloc(0);for(var n=0,i=0,o=0;t[n]===u;)i++,n++;for(var s=(t.length-n)*c+1>>>0,f=new Uint8Array(s);t[n];){var h=r[t.charCodeAt(n)];if(255===h)return;for(var p=0,l=s-1;(0!==h||p<o)&&-1!==l;l--,p++)h+=a*f[l]>>>0,f[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,n++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=e.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(r){if((Array.isArray(r)||r instanceof Uint8Array)&&(r=e.from(r)),!e.isBuffer(r))throw new TypeError("Expected Buffer");if(0===r.length)return"";for(var n=0,i=0,o=0,s=r.length;o!==s&&0===r[o];)o++,n++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var p=r[o],l=0,d=c-1;(0!==p||l<i)&&-1!==d;d--,l++)p+=256*h[d]>>>0,h[d]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,o++}for(var y=c-i;y!==c&&0===h[y];)y++;for(var g=u.repeat(n);y<c;++y)g+=t.charAt(h[y]);return g},decodeUnsafe:h,decode:function(e){var t=h(e);if(t)return t;throw new Error("Non-base"+a+" character")}}},dt}();gt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}(),S();var Et=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};const _t=u,vt=e=>{const t=(e=>{const t=y.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),r=g.publicKeyConvert(_t.from(t,"hex"),!0);return _t.from(r).toString("hex")})(e);let r=_t.from(t,"hex"),n=32-r.length;for(;n>0;)r=_t.concat([_t.from("00","hex"),r]),n--;return r};var St,It={},Tt={},kt={};function At(){return St||(St=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.testnet=kt.regtest=kt.bitcoin=void 0,kt.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},kt.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},kt.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}),kt}var Pt,Ot={},Nt={},Ut={},xt={};function Bt(){if(Pt)return xt;return Pt=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.encode=xt.decode=xt.check=void 0,xt.check=function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return 0!==r&&(6+t+r===e.length&&(!(128&e[4])&&(!(t>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[t+6])&&!(r>1&&0===e[t+6]&&!(128&e[t+7]))))))},xt.decode=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},xt.encode=function(e,t){const r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");const i=u.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i},xt}var Rt,Mt={};function Lt(){if(Rt)return Mt;Rt=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.REVERSE_OPS=Mt.OPS=void 0;const e={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Mt.OPS=e;const t={};Mt.REVERSE_OPS=t;for(const r of Object.keys(e)){t[e[r]]=r}return Mt}var Ct,Ht={};var Dt,Ft={};var jt,Vt,Kt,Gt,Wt,Xt,qt,zt,$t,Yt,Jt,Qt={},Zt={};function er(){if(Vt)return jt;Vt=1;var e={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var t in e.Null=e.Nil,e)e[t].toJSON=function(e){return e}.bind(null,t);return jt=e}function tr(){if(Gt)return Kt;Gt=1;var e=er();function t(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function r(r){return e.Nil(r)?"":t(r.constructor)}function n(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function i(r){return e.Function(r)?r.toJSON?r.toJSON():t(r):e.Array(r)?"Array":r&&e.Object(r)?"Object":void 0!==r?r:""}function o(t,r,n){var o=function(t){return e.Function(t)?"":e.String(t)?JSON.stringify(t):t&&e.Object(t)?"":t}(r);return"Expected "+i(t)+", got"+(""!==n?" "+n:"")+(""!==o?" "+o:"")}function s(e,t,i){i=i||r(t),this.message=o(e,t,i),n(this,s),this.__type=e,this.__value=t,this.__valueTypeName=i}function a(e,t,a,u,c){e?(c=c||r(u),this.message=function(e,t,r,n,s){var a='" of type ';return"key"===t&&(a='" with key type '),o('property "'+i(r)+a+i(e),n,s)}(e,a,t,u,c)):this.message='Unexpected property "'+t+'"',n(this,s),this.__label=a,this.__property=t,this.__type=e,this.__value=u,this.__valueTypeName=c}return s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,a.prototype=Object.create(Error.prototype),a.prototype.constructor=s,Kt={TfTypeError:s,TfPropertyTypeError:a,tfCustomError:function(e,t){return new s(e,{},t)},tfSubError:function(e,t,r){return e instanceof a?(t=t+"."+e.__property,e=new a(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof s&&(e=new a(e.__type,t,r,e.__value,e.__valueTypeName)),n(e),e},tfJSON:i,getValueTypeName:r}}function rr(){if(zt)return qt;zt=1;var e=tr(),t=er(),r=e.tfJSON,n=e.TfTypeError,i=e.TfPropertyTypeError,o=e.tfSubError,s=e.getValueTypeName,a={arrayOf:function(e,n){function i(r,i){return!!t.Array(r)&&(!t.Nil(r)&&(!(void 0!==n.minLength&&r.length<n.minLength)&&(!(void 0!==n.maxLength&&r.length>n.maxLength)&&((void 0===n.length||r.length===n.length)&&r.every((function(t,r){try{return c(e,t,i)}catch(e){throw o(e,r)}}))))))}return e=u(e),n=n||{},i.toJSON=function(){var t="["+r(e)+"]";return void 0!==n.length?t+="{"+n.length+"}":void 0===n.minLength&&void 0===n.maxLength||(t+="{"+(void 0===n.minLength?0:n.minLength)+","+(void 0===n.maxLength?1/0:n.maxLength)+"}"),t},i},maybe:function e(n){function i(r,i){return t.Nil(r)||n(r,i,e)}return n=u(n),i.toJSON=function(){return"?"+r(n)},i},map:function(e,n){function i(r,i){if(!t.Object(r))return!1;if(t.Nil(r))return!1;for(var s in r){try{n&&c(n,s,i)}catch(e){throw o(e,s,"key")}try{var a=r[s];c(e,a,i)}catch(e){throw o(e,s)}}return!0}return e=u(e),n&&(n=u(n)),i.toJSON=n?function(){return"{"+r(n)+": "+r(e)+"}"}:function(){return"{"+r(e)+"}"},i},object:function(e){var n={};for(var s in e)n[s]=u(e[s]);function a(e,r){if(!t.Object(e))return!1;if(t.Nil(e))return!1;var s;try{for(s in n){c(n[s],e[s],r)}}catch(e){throw o(e,s)}if(r)for(s in e)if(!n[s])throw new i(void 0,s);return!0}return a.toJSON=function(){return r(n)},a},anyOf:function(){var e=[].slice.call(arguments).map(u);function t(t,r){return e.some((function(e){try{return c(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(r).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(u);function t(t,r){return e.every((function(e){try{return c(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(r).join(" & ")},t},quacksLike:function(e){function t(t){return e===s(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(u);function n(r,n){return!t.Nil(r)&&(!t.Nil(r.length)&&((!n||r.length===e.length)&&e.every((function(e,t){try{return c(e,r[t],n)}catch(e){throw o(e,t)}}))))}return n.toJSON=function(){return"("+e.map(r).join(", ")+")"},n},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function u(e){if(t.String(e))return"?"===e[0]?a.maybe(e.slice(1)):t[e]||a.quacksLike(e);if(e&&t.Object(e)){if(t.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return a.arrayOf(e[0])}return a.object(e)}return t.Function(e)?e:a.value(e)}function c(e,r,i,o){if(t.Function(e)){if(e(r,i))return!0;throw new n(o||e,r)}return c(u(e),r,i)}for(var f in a.oneOf=a.anyOf,t)c[f]=t[f];for(f in a)c[f]=a[f];var p=function(){if(Xt)return Wt;Xt=1;var e=er(),t=tr();function r(e){return h(e)}function n(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function i(e,r){var n=e.toJSON();function i(i){if(!e(i))return!1;if(i.length===r)return!0;throw t.tfCustomError(n+"(Length: "+r+")",n+"(Length: "+i.length+")")}return i.toJSON=function(){return n},i}var o=i.bind(null,e.Array),s=i.bind(null,r),a=i.bind(null,n),u=i.bind(null,e.String),c=Math.pow(2,53)-1,f={ArrayN:o,Buffer:r,BufferN:s,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:n,HexN:a,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-c&&e<=c&&Math.floor(e)===e},Range:function(t,r,n){function i(e,i){return n(e,i)&&e>t&&e<r}return n=n||e.Number,i.toJSON=function(){return`${n.toJSON()} between [${t}, ${r}]`},i},StringN:u,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=c&&Math.floor(e)===e}};for(var p in f)f[p].toJSON=function(e){return e}.bind(null,p);return Wt=f}();for(f in p)c[f]=p[f];return c.compile=u,c.TfTypeError=n,c.TfPropertyTypeError=i,qt=c}function nr(){return $t||($t=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const t=E;e.typeforce=rr();const r=t.Buffer.alloc(32,0),n=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(e){if(!t.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;const i=e[0],o=e.slice(1,33);if(0===o.compare(r))return!1;if(o.compare(n)>=0)return!1;if((2===i||3===i)&&33===e.length)return!0;const s=e.slice(33);return 0!==s.compare(r)&&(!(s.compare(n)>=0)&&(4===i&&65===e.length))};const i=Math.pow(2,31)-1;function o(t){return e.typeforce.String(t)&&!!t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=i},e.BIP32Path=o,o.toJSON=()=>"BIP32 derivation path",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign};function s(r){return!(!r||!("output"in r))&&(!!t.Buffer.isBuffer(r.output)&&(void 0===r.version||(r.version&e.TAPLEAF_VERSION_MASK)===r.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike("Point"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=s,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):s(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf}(Zt)),Zt}function ir(){return Jt||(Jt=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const t=Bt(),r=Lt();Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return r.OPS}});const n=function(){if(Ct)return Ht;Ct=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.decode=Ht.encode=Ht.encodingLength=void 0;const e=Lt();function t(t){return t<e.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}return Ht.encodingLength=t,Ht.encode=function(r,n,i){const o=t(n);return 1===o?r.writeUInt8(n,i):2===o?(r.writeUInt8(e.OPS.OP_PUSHDATA1,i),r.writeUInt8(n,i+1)):3===o?(r.writeUInt8(e.OPS.OP_PUSHDATA2,i),r.writeUInt16LE(n,i+1)):(r.writeUInt8(e.OPS.OP_PUSHDATA4,i),r.writeUInt32LE(n,i+1)),o},Ht.decode=function(t,r){const n=t.readUInt8(r);let i,o;if(n<e.OPS.OP_PUSHDATA1)i=n,o=1;else if(n===e.OPS.OP_PUSHDATA1){if(r+2>t.length)return null;i=t.readUInt8(r+1),o=2}else if(n===e.OPS.OP_PUSHDATA2){if(r+3>t.length)return null;i=t.readUInt16LE(r+1),o=3}else{if(r+5>t.length)return null;if(n!==e.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=t.readUInt32LE(r+1),o=5}return{opcode:n,number:i,size:o}},Ht}(),i=(Dt||(Dt=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.encode=Ft.decode=void 0,Ft.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(127&e[n-1]||!(n<=1)&&128&e[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},Ft.encode=function(e){let t=Math.abs(e);const r=(n=t)>2147483647?5:n>8388607?4:n>32767?3:n>127?2:n>0?1:0;var n;const i=u.allocUnsafe(r),o=e<0;for(let e=0;e<r;++e)i.writeUInt8(255&t,e),t>>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}),Ft),o=function(){if(Yt)return Qt;Yt=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.encode=Qt.decode=void 0;const e=Bt(),t=nr(),{typeforce:r}=t,n=u.alloc(1,0);function i(e){let t=0;for(;0===e[t];)++t;return t===e.length?n:128&(e=e.slice(t))[0]?u.concat([n,e],1+e.length):e}function o(e){0===e[0]&&(e=e.slice(1));const t=u.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}return Qt.decode=function(t){const r=t.readUInt8(t.length-1),n=-129&r;if(n<=0||n>=4)throw new Error("Invalid hashType "+r);const i=e.decode(t.slice(0,-1)),s=o(i.r),a=o(i.s);return{signature:u.concat([s,a],64),hashType:r}},Qt.encode=function(n,o){r({signature:t.BufferN(64),hashType:t.UInt8},{signature:n,hashType:o});const s=-129&o;if(s<=0||s>=4)throw new Error("Invalid hashType "+o);const a=u.allocUnsafe(1);a.writeUInt8(o,0);const c=i(n.slice(0,32)),f=i(n.slice(32,64));return u.concat([e.encode(c,f),a])},Qt}(),s=nr(),{typeforce:a}=s,c=r.OPS.OP_RESERVED;function f(e){return s.Buffer(e)||function(e){return s.Number(e)&&(e===r.OPS.OP_0||e>=r.OPS.OP_1&&e<=r.OPS.OP_16||e===r.OPS.OP_1NEGATE)}(e)}function p(e){return s.Array(e)&&e.every(f)}function l(e){return 0===e.length?r.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?c+e[0]:129===e[0]?r.OPS.OP_1NEGATE:void 0:void 0}function d(e){return h(e)}function y(e){return h(e)}function g(e){if(d(e))return e;a(s.Array,e);const t=e.reduce(((e,t)=>y(t)?1===t.length&&void 0!==l(t)?e+1:e+n.encodingLength(t.length)+t.length:e+1),0),r=u.allocUnsafe(t);let i=0;if(e.forEach((e=>{if(y(e)){const t=l(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=n.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function w(e){if(t=e,s.Array(t))return e;var t;a(s.Buffer,e);const i=[];let o=0;for(;o<e.length;){const t=e[o];if(t>r.OPS.OP_0&&t<=r.OPS.OP_PUSHDATA4){const t=n.decode(e,o);if(null===t)return null;if(o+=t.size,o+t.number>e.length)return null;const r=e.slice(o,o+t.number);o+=t.number;const s=l(r);void 0!==s?i.push(s):i.push(r)}else i.push(t),o+=1}return i}function m(e){const t=-129&e;return t>0&&t<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(e){return e.length-e.filter(f).length},e.compile=g,e.decompile=w,e.toASM=function(e){return d(e)&&(e=w(e)),e.map((e=>{if(y(e)){const t=l(e);if(void 0===t)return e.toString("hex");e=t}return r.REVERSE_OPS[e]})).join(" ")},e.fromASM=function(e){return a(s.String,e),g(e.split(" ").map((e=>void 0!==r.OPS[e]?r.OPS[e]:(a(s.Hex,e),u.from(e,"hex")))))},e.toStack=function(e){return e=w(e),a(p,e),e.map((e=>y(e)?e:e===r.OPS.OP_0?u.allocUnsafe(0):i.encode(e-c)))},e.isCanonicalPubKey=function(e){return s.isPoint(e)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(e){return!!h(e)&&(!!m(e[e.length-1])&&t.check(e.slice(0,-1)))},e.number=i,e.signature=o}(Ut)),Ut}var or,sr,ar={};function ur(){if(or)return ar;return or=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.value=ar.prop=void 0,ar.prop=function(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},ar.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)},ar}var cr,fr={};var hr,pr={};var lr,dr={},yr={},gr={},wr={},mr={};function br(){if(lr)return mr;function e(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function t(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function n(e,...t){if(!r(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function i(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");e(t.outputLen),e(t.blockLen)}function o(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function s(e,t){n(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}lr=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.output=mr.exists=mr.hash=mr.bytes=mr.bool=mr.number=mr.isBytes=void 0,mr.number=e,mr.bool=t,mr.isBytes=r,mr.bytes=n,mr.hash=i,mr.exists=o,mr.output=s;const a={number:e,bool:t,bytes:n,hash:i,exists:o,output:s};return mr.default=a,mr}var Er,_r,vr,Sr,Ir={},Tr={};function kr(){return _r||(_r=1,function(e){
|
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
+
Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=(Er||(Er=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.crypto=void 0,Tr.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0),Tr),r=br();e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name};e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);e.rotr=(e,t)=>e<<32-t|e>>>t;e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])};const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){(0,r.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=n[e[r]];return t};const i=48,o=57,s=65,a=70,u=97,c=102;function f(e){return e>=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=u&&e<=c?e-(u-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=f(e.charCodeAt(i)),o=f(e.charCodeAt(i+1));if(void 0===r||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}n[t]=16*r+o}return n};function h(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function p(e){return"string"==typeof e&&(e=h(e)),(0,r.bytes)(e),e}e.nextTick=async()=>{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=h,e.toBytes=p,e.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];(0,r.bytes)(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n};e.Hash=class{clone(){return this._cloneInto()}};const l={}.toString;e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==l.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(p(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(p(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(p(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Ir)),Ir}function Ar(){if(vr)return wr;vr=1,Object.defineProperty(wr,"__esModule",{value:!0}),wr.HashMD=wr.Maj=wr.Chi=void 0;const e=br(),t=kr();wr.Chi=(e,t,r)=>e&t^~e&r;wr.Maj=(e,t,r)=>e&t^e&r^t&r;class r extends t.Hash{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,t.createView)(this.buffer)}update(r){(0,e.exists)(this);const{view:n,buffer:i,blockLen:o}=this,s=(r=(0,t.toBytes)(r)).length;for(let e=0;e<s;){const a=Math.min(o-this.pos,s-e);if(a!==o)i.set(r.subarray(e,e+a),this.pos),this.pos+=a,e+=a,this.pos===o&&(this.process(n,0),this.pos=0);else{const n=(0,t.createView)(r);for(;o<=s-e;e+=o)this.process(n,e)}}return this.length+=r.length,this.roundClean(),this}digestInto(r){(0,e.exists)(this),(0,e.output)(r,this),this.finished=!0;const{buffer:n,view:i,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(i,0),a=0);for(let e=a;e<o;e++)n[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+c,a,n)}(i,o-8,BigInt(8*this.length),s),this.process(i,0);const u=(0,t.createView)(r),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<f;e++)u.setUint32(4*e,h[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}}return wr.HashMD=r,wr}function Pr(){if(Sr)return gr;Sr=1,Object.defineProperty(gr,"__esModule",{value:!0}),gr.ripemd160=gr.RIPEMD160=void 0;const e=Ar(),t=kr(),r=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),n=new Uint8Array(new Array(16).fill(0).map(((e,t)=>t)));let i=[n],o=[n.map((e=>(9*e+5)%16))];for(let e=0;e<4;e++)for(let t of[i,o])t.push(t[e].map((e=>r[e])));const s=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),a=i.map(((e,t)=>e.map((e=>s[t][e])))),u=o.map(((e,t)=>e.map((e=>s[t][e])))),c=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),f=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function h(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const p=new Uint32Array(16);class l extends e.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(e,r){for(let t=0;t<16;t++,r+=4)p[t]=e.getUint32(r,!0);let n=0|this.h0,s=n,l=0|this.h1,d=l,y=0|this.h2,g=y,w=0|this.h3,m=w,b=0|this.h4,E=b;for(let e=0;e<5;e++){const r=4-e,_=c[e],v=f[e],S=i[e],I=o[e],T=a[e],k=u[e];for(let r=0;r<16;r++){const i=(0,t.rotl)(n+h(e,l,y,w)+p[S[r]]+_,T[r])+b|0;n=b,b=w,w=0|(0,t.rotl)(y,10),y=l,l=i}for(let e=0;e<16;e++){const n=(0,t.rotl)(s+h(r,d,g,m)+p[I[e]]+v,k[e])+E|0;s=E,E=m,m=0|(0,t.rotl)(g,10),g=d,d=n}}this.set(this.h1+y+m|0,this.h2+w+E|0,this.h3+b+s|0,this.h4+n+d|0,this.h0+l+g|0)}roundClean(){p.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}return gr.RIPEMD160=l,gr.ripemd160=(0,t.wrapConstructor)((()=>new l)),gr}var Or,Nr={};function Ur(){if(Or)return Nr;Or=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.sha1=void 0;const e=Ar(),t=kr(),r=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),n=new Uint32Array(80);class i extends e.HashMD{constructor(){super(64,20,8,!1),this.A=0|r[0],this.B=0|r[1],this.C=0|r[2],this.D=0|r[3],this.E=0|r[4]}get(){const{A:e,B:t,C:r,D:n,E:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i}process(r,i){for(let e=0;e<16;e++,i+=4)n[e]=r.getUint32(i,!1);for(let e=16;e<80;e++)n[e]=(0,t.rotl)(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let{A:o,B:s,C:a,D:u,E:c}=this;for(let r=0;r<80;r++){let i,f;r<20?(i=(0,e.Chi)(s,a,u),f=1518500249):r<40?(i=s^a^u,f=1859775393):r<60?(i=(0,e.Maj)(s,a,u),f=2400959708):(i=s^a^u,f=3395469782);const h=(0,t.rotl)(o,5)+i+c+f+n[r]|0;c=u,u=a,a=(0,t.rotl)(s,30),s=o,o=h}o=o+this.A|0,s=s+this.B|0,a=a+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(o,s,a,u,c)}roundClean(){n.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}return Nr.sha1=(0,t.wrapConstructor)((()=>new i)),Nr}var xr,Br,Rr,Mr,Lr,Cr,Hr,Dr={};function Fr(){if(xr)return Dr;xr=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.sha224=Dr.sha256=void 0;const e=Ar(),t=kr(),r=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]),n=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),i=new Uint32Array(64);class o extends e.HashMD{constructor(){super(64,32,8,!1),this.A=0|n[0],this.B=0|n[1],this.C=0|n[2],this.D=0|n[3],this.E=0|n[4],this.F=0|n[5],this.G=0|n[6],this.H=0|n[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(n,o){for(let e=0;e<16;e++,o+=4)i[e]=n.getUint32(o,!1);for(let e=16;e<64;e++){const r=i[e-15],n=i[e-2],o=(0,t.rotr)(r,7)^(0,t.rotr)(r,18)^r>>>3,s=(0,t.rotr)(n,17)^(0,t.rotr)(n,19)^n>>>10;i[e]=s+i[e-7]+o+i[e-16]|0}let{A:s,B:a,C:u,D:c,E:f,F:h,G:p,H:l}=this;for(let n=0;n<64;n++){const o=l+((0,t.rotr)(f,6)^(0,t.rotr)(f,11)^(0,t.rotr)(f,25))+(0,e.Chi)(f,h,p)+r[n]+i[n]|0,d=((0,t.rotr)(s,2)^(0,t.rotr)(s,13)^(0,t.rotr)(s,22))+(0,e.Maj)(s,a,u)|0;l=p,p=h,h=f,f=c+o|0,c=u,u=a,a=s,s=o+d|0}s=s+this.A|0,a=a+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,h=h+this.F|0,p=p+this.G|0,l=l+this.H|0,this.set(s,a,u,c,f,h,p,l)}roundClean(){i.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class s extends o{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}}return Dr.sha256=(0,t.wrapConstructor)((()=>new o)),Dr.sha224=(0,t.wrapConstructor)((()=>new s)),Dr}function jr(){return Br||(Br=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const t=Pr(),r=Ur(),n=Fr();function i(e){return u.from((0,n.sha256)(Uint8Array.from(e)))}e.ripemd160=function(e){return u.from((0,t.ripemd160)(Uint8Array.from(e)))},e.sha1=function(e){return u.from((0,r.sha1)(Uint8Array.from(e)))},e.sha256=i,e.hash160=function(e){return u.from((0,t.ripemd160)((0,n.sha256)(Uint8Array.from(e))))},e.hash256=function(e){return u.from((0,n.sha256)((0,n.sha256)(Uint8Array.from(e))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":u.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":u.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":u.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:u.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:u.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:u.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:u.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":u.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":u.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return i(u.concat([e.TAGGED_HASH_PREFIXES[t],r]))}}(yr)),yr}function Vr(){if(Cr)return Lr;Cr=1;var{sha256:e}=Fr(),t=function(){if(Mr)return Rr;Mr=1;var e=w();return Rr=function(t){function r(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(r){var n=Uint8Array.from(r),i=t(n),o=n.length+4,s=new Uint8Array(o);return s.set(n,0),s.set(i.subarray(0,4),n.length),e.encode(s,o)},decode:function(t){var n=r(e.decode(t));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:function(t){var n=e.decodeUnsafe(t);if(n)return r(n)}}},Rr}();return Lr=t((function(t){return e(e(t))})),Lr}var Kr,Gr={};var Wr,Xr,qr={},zr={};function $r(){if(Wr)return zr;Wr=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.bech32m=zr.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",t={};for(let r=0;r<32;r++){const n=e.charAt(r);t[n]=r}function r(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let n=0;n<e.length;++n){const i=e.charCodeAt(n);if(i<33||i>126)return"Invalid prefix ("+e+")";t=r(t)^i>>5}t=r(t);for(let n=0;n<e.length;++n){const i=e.charCodeAt(n);t=r(t)^31&i}return t}function i(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let n=0;n<e.length;++n)for(i=i<<t|e[n],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function o(e){return i(e,8,5,!0)}function s(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t}function a(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function u(i){let u;function c(e,i){if(i=i||90,e.length<8)return e+" too short";if(e.length>i)return"Exceeds length limit";const o=e.toLowerCase(),s=e.toUpperCase();if(e!==o&&e!==s)return"Mixed-case string "+e;const a=(e=o).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;const c=e.slice(0,a),f=e.slice(a+1);if(f.length<6)return"Data too short";let h=n(c);if("string"==typeof h)return h;const p=[];for(let e=0;e<f.length;++e){const n=f.charAt(e),i=t[n];if(void 0===i)return"Unknown character "+n;h=r(h)^i,e+6>=f.length||p.push(i)}return h!==u?"Invalid checksum for "+e:{prefix:c,words:p}}return u="bech32"===i?1:734539939,{decodeUnsafe:function(e,t){const r=c(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=c(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,i,o){if(o=o||90,t.length+7+i.length>o)throw new TypeError("Exceeds length limit");let s=n(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let a=t+"1";for(let t=0;t<i.length;++t){const n=i[t];if(n>>5)throw new Error("Non 5-bit word");s=r(s)^n,a+=e.charAt(n)}for(let e=0;e<6;++e)s=r(s);s^=u;for(let t=0;t<6;++t){a+=e.charAt(s>>5*(5-t)&31)}return a},toWords:o,fromWordsUnsafe:s,fromWords:a}}return zr.bech32=u("bech32"),zr.bech32m=u("bech32m"),zr}var Yr,Jr={};var Qr,Zr={},en={};function tn(){if(Qr)return en;Qr=1,Object.defineProperty(en,"__esModule",{value:!0}),en.getEccLib=en.initEccLib=void 0;const e={};en.initEccLib=function(i){var o;i?i!==e.eccLib&&(r("function"==typeof(o=i).isXOnlyPoint),r(o.isXOnlyPoint(t("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),r(o.isXOnlyPoint(t("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),r(o.isXOnlyPoint(t("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),r(o.isXOnlyPoint(t("0000000000000000000000000000000000000000000000000000000000000001"))),r(!o.isXOnlyPoint(t("0000000000000000000000000000000000000000000000000000000000000000"))),r(!o.isXOnlyPoint(t("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),r("function"==typeof o.xOnlyPointAddTweak),n.forEach((e=>{const n=o.xOnlyPointAddTweak(t(e.pubkey),t(e.tweak));null===e.result?r(null===n):(r(null!==n),r(n.parity===e.parity),r(u.from(n.xOnlyPubkey).equals(t(e.result))))})),e.eccLib=i):e.eccLib=i},en.getEccLib=function(){if(!e.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return e.eccLib};const t=e=>u.from(e,"hex");function r(e){if(!e)throw new Error("ecc library invalid")}const n=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}];return en}var rn,nn,on,sn,an,un,cn,fn={},hn={};function pn(){if(on)return hn;on=1,Object.defineProperty(hn,"__esModule",{value:!0}),hn.BufferReader=hn.BufferWriter=hn.cloneBuffer=hn.reverseBuffer=hn.writeUInt64LE=hn.readUInt64LE=hn.varuint=void 0;const e=nr(),{typeforce:t}=e,r=function(){if(nn)return rn;nn=1;var e=d().Buffer;function t(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function r(e){return t(e),e<253?1:e<=65535?3:e<=4294967295?5:9}return rn={encode:function n(i,o,s){if(t(i),o||(o=e.allocUnsafe(r(i))),!e.isBuffer(o))throw new TypeError("buffer must be a Buffer instance");return s||(s=0),i<253?(o.writeUInt8(i,s),n.bytes=1):i<=65535?(o.writeUInt8(253,s),o.writeUInt16LE(i,s+1),n.bytes=3):i<=4294967295?(o.writeUInt8(254,s),o.writeUInt32LE(i,s+1),n.bytes=5):(o.writeUInt8(255,s),o.writeUInt32LE(i>>>0,s+1),o.writeUInt32LE(i/4294967296|0,s+5),n.bytes=9),o},decode:function r(n,i){if(!e.isBuffer(n))throw new TypeError("buffer must be a Buffer instance");i||(i=0);var o=n.readUInt8(i);if(o<253)return r.bytes=1,o;if(253===o)return r.bytes=3,n.readUInt16LE(i+1);if(254===o)return r.bytes=5,n.readUInt32LE(i+1);r.bytes=9;var s=n.readUInt32LE(i+1),a=4294967296*n.readUInt32LE(i+5)+s;return t(a),a},encodingLength:r},rn}();function n(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function i(e,t){const r=e.readUInt32LE(t);let i=e.readUInt32LE(t+4);return i*=4294967296,n(i+r,9007199254740991),i+r}function o(e,t,r){return n(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}hn.varuint=r,hn.readUInt64LE=i,hn.writeUInt64LE=o,hn.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},hn.cloneBuffer=function(e){const t=u.allocUnsafe(e.length);return e.copy(t),t};class s{static withCapacity(e){return new s(u.alloc(e))}constructor(r,n=0){this.buffer=r,this.offset=n,t(e.tuple(e.Buffer,e.UInt32),[r,n])}writeUInt8(e){this.offset=this.buffer.writeUInt8(e,this.offset)}writeInt32(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}writeUInt32(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}writeUInt64(e){this.offset=o(this.buffer,e,this.offset)}writeVarInt(e){r.encode(e,this.buffer,this.offset),this.offset+=r.encode.bytes}writeSlice(e){if(this.buffer.length<this.offset+e.length)throw new Error("Cannot write slice out of bounds");this.offset+=e.copy(this.buffer,this.offset)}writeVarSlice(e){this.writeVarInt(e.length),this.writeSlice(e)}writeVector(e){this.writeVarInt(e.length),e.forEach((e=>this.writeVarSlice(e)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}hn.BufferWriter=s;return hn.BufferReader=class{constructor(r,n=0){this.buffer=r,this.offset=n,t(e.tuple(e.Buffer,e.UInt32),[r,n])}readUInt8(){const e=this.buffer.readUInt8(this.offset);return this.offset++,e}readInt32(){const e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}readUInt32(){const e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}readUInt64(){const e=i(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=r.decode(this.buffer,this.offset);return this.offset+=r.decode.bytes,e}readSlice(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");const t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const e=this.readVarInt(),t=[];for(let r=0;r<e;r++)t.push(this.readVarSlice());return t}},hn}function ln(){return sn||(sn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const t=E,r=tn(),n=jr(),i=pn(),o=nr();e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function s(r){const i=r.version||e.LEAF_VERSION_TAPSCRIPT;return n.taggedHash("TapLeaf",t.Buffer.concat([t.Buffer.from([i]),c(r.output)]))}function a(e,r){return n.taggedHash("TapTweak",t.Buffer.concat(r?[e,r]:[e]))}function u(e,r){return n.taggedHash("TapBranch",t.Buffer.concat([e,r]))}function c(e){const r=i.varuint.encodingLength(e.length),n=t.Buffer.allocUnsafe(r);return i.varuint.encode(e.length,n),t.Buffer.concat([n,e])}e.rootHashFromPath=function(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let t=0;t<r;t++){const r=e.slice(33+32*t,65+32*t);n=n.compare(r)<0?u(n,r):u(r,n)}return n},e.toHashTree=function e(t){if((0,o.isTapleaf)(t))return{hash:s(t)};const r=[e(t[0]),e(t[1])];r.sort(((e,t)=>e.hash.compare(t.hash)));const[n,i]=r;return{hash:u(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function e(t,r){if("left"in(n=t)&&"right"in n){const n=e(t.left,r);if(void 0!==n)return[...n,t.right.hash];const i=e(t.right,r);if(void 0!==i)return[...i,t.left.hash]}else if(t.hash.equals(r))return[];var n},e.tapleafHash=s,e.tapTweakHash=a,e.tweakKey=function(e,n){if(!t.Buffer.isBuffer(e))return null;if(32!==e.length)return null;if(n&&32!==n.length)return null;const i=a(e,n),o=(0,r.getEccLib)().xOnlyPointAddTweak(e,i);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:t.Buffer.from(o.xOnlyPubkey)}:null}}(fn)),fn}function dn(){return un||(un=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const t=function(){if(sr)return Nt;sr=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.p2data=void 0;const e=At(),t=ir(),r=nr(),n=ur(),i=t.OPS;return Nt.p2data=function(o,s){if(!o.data&&!o.output)throw new TypeError("Not enough data");s=Object.assign({validate:!0},s||{}),(0,r.typeforce)({network:r.typeforce.maybe(r.typeforce.Object),output:r.typeforce.maybe(r.typeforce.Buffer),data:r.typeforce.maybe(r.typeforce.arrayOf(r.typeforce.Buffer))},o);const a={name:"embed",network:o.network||e.bitcoin};if(n.prop(a,"output",(()=>{if(o.data)return t.compile([i.OP_RETURN].concat(o.data))})),n.prop(a,"data",(()=>{if(o.output)return t.decompile(o.output).slice(1)})),s.validate&&o.output){const e=t.decompile(o.output);if(e[0]!==i.OP_RETURN)throw new TypeError("Output is invalid");if(!e.slice(1).every(r.typeforce.Buffer))throw new TypeError("Output is invalid");if(o.data&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(o.data,a.data))throw new TypeError("Data mismatch")}return Object.assign(a,o)},Nt}();Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});const r=function(){if(cr)return fr;cr=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.p2ms=void 0;const e=At(),t=ir(),r=nr(),n=ur(),i=t.OPS,o=i.OP_RESERVED;function s(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}return fr.p2ms=function(a,u){if(!(a.input||a.output||a.pubkeys&&void 0!==a.m||a.signatures))throw new TypeError("Not enough data");function c(e){return t.isCanonicalScriptSignature(e)||void 0!==(u.allowIncomplete&&e===i.OP_0)}u=Object.assign({validate:!0},u||{}),(0,r.typeforce)({network:r.typeforce.maybe(r.typeforce.Object),m:r.typeforce.maybe(r.typeforce.Number),n:r.typeforce.maybe(r.typeforce.Number),output:r.typeforce.maybe(r.typeforce.Buffer),pubkeys:r.typeforce.maybe(r.typeforce.arrayOf(r.isPoint)),signatures:r.typeforce.maybe(r.typeforce.arrayOf(c)),input:r.typeforce.maybe(r.typeforce.Buffer)},a);const f={network:a.network||e.bitcoin};let h=[],p=!1;function l(e){p||(p=!0,h=t.decompile(e),f.m=h[0]-o,f.n=h[h.length-2]-o,f.pubkeys=h.slice(1,-2))}if(n.prop(f,"output",(()=>{if(a.m&&f.n&&a.pubkeys)return t.compile([].concat(o+a.m,a.pubkeys,o+f.n,i.OP_CHECKMULTISIG))})),n.prop(f,"m",(()=>{if(f.output)return l(f.output),f.m})),n.prop(f,"n",(()=>{if(f.pubkeys)return f.pubkeys.length})),n.prop(f,"pubkeys",(()=>{if(a.output)return l(a.output),f.pubkeys})),n.prop(f,"signatures",(()=>{if(a.input)return t.decompile(a.input).slice(1)})),n.prop(f,"input",(()=>{if(a.signatures)return t.compile([i.OP_0].concat(a.signatures))})),n.prop(f,"witness",(()=>{if(f.input)return[]})),n.prop(f,"name",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),u.validate){if(a.output){if(l(a.output),!r.typeforce.Number(h[0]))throw new TypeError("Output is invalid");if(!r.typeforce.Number(h[h.length-2]))throw new TypeError("Output is invalid");if(h[h.length-1]!==i.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(f.m<=0||f.n>16||f.m>f.n||f.n!==h.length-3)throw new TypeError("Output is invalid");if(!f.pubkeys.every((e=>(0,r.isPoint)(e))))throw new TypeError("Output is invalid");if(void 0!==a.m&&a.m!==f.m)throw new TypeError("m mismatch");if(void 0!==a.n&&a.n!==f.n)throw new TypeError("n mismatch");if(a.pubkeys&&!s(a.pubkeys,f.pubkeys))throw new TypeError("Pubkeys mismatch")}if(a.pubkeys){if(void 0!==a.n&&a.n!==a.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(f.n=a.pubkeys.length,f.n<f.m)throw new TypeError("Pubkey count cannot be less than m")}if(a.signatures){if(a.signatures.length<f.m)throw new TypeError("Not enough signatures provided");if(a.signatures.length>f.m)throw new TypeError("Too many signatures provided")}if(a.input){if(a.input[0]!==i.OP_0)throw new TypeError("Input is invalid");if(0===f.signatures.length||!f.signatures.every(c))throw new TypeError("Input has invalid signature(s)");if(a.signatures&&!s(a.signatures,f.signatures))throw new TypeError("Signature mismatch");if(void 0!==a.m&&a.m!==a.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(f,a)},fr}();Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return r.p2ms}});const n=function(){if(hr)return pr;hr=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.p2pk=void 0;const e=At(),t=ir(),r=nr(),n=ur(),i=t.OPS;return pr.p2pk=function(o,s){if(!(o.input||o.output||o.pubkey||o.input||o.signature))throw new TypeError("Not enough data");s=Object.assign({validate:!0},s||{}),(0,r.typeforce)({network:r.typeforce.maybe(r.typeforce.Object),output:r.typeforce.maybe(r.typeforce.Buffer),pubkey:r.typeforce.maybe(r.isPoint),signature:r.typeforce.maybe(t.isCanonicalScriptSignature),input:r.typeforce.maybe(r.typeforce.Buffer)},o);const a=n.value((()=>t.decompile(o.input))),u={name:"p2pk",network:o.network||e.bitcoin};if(n.prop(u,"output",(()=>{if(o.pubkey)return t.compile([o.pubkey,i.OP_CHECKSIG])})),n.prop(u,"pubkey",(()=>{if(o.output)return o.output.slice(1,-1)})),n.prop(u,"signature",(()=>{if(o.input)return a()[0]})),n.prop(u,"input",(()=>{if(o.signature)return t.compile([o.signature])})),n.prop(u,"witness",(()=>{if(u.input)return[]})),s.validate){if(o.output){if(o.output[o.output.length-1]!==i.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,r.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(o.pubkey&&!o.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(o.signature&&o.input&&!o.input.equals(u.input))throw new TypeError("Signature mismatch");if(o.input){if(1!==a().length)throw new TypeError("Input is invalid");if(!t.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,o)},pr}();Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return n.p2pk}});const i=function(){if(Hr)return dr;Hr=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.p2pkh=void 0;const e=jr(),t=At(),r=ir(),n=nr(),i=ur(),o=Vr(),s=r.OPS;return dr.p2pkh=function(a,c){if(!(a.address||a.hash||a.output||a.pubkey||a.input))throw new TypeError("Not enough data");c=Object.assign({validate:!0},c||{}),(0,n.typeforce)({network:n.typeforce.maybe(n.typeforce.Object),address:n.typeforce.maybe(n.typeforce.String),hash:n.typeforce.maybe(n.typeforce.BufferN(20)),output:n.typeforce.maybe(n.typeforce.BufferN(25)),pubkey:n.typeforce.maybe(n.isPoint),signature:n.typeforce.maybe(r.isCanonicalScriptSignature),input:n.typeforce.maybe(n.typeforce.Buffer)},a);const f=i.value((()=>{const e=u.from(o.decode(a.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=i.value((()=>r.decompile(a.input))),p=a.network||t.bitcoin,l={name:"p2pkh",network:p};if(i.prop(l,"address",(()=>{if(!l.hash)return;const e=u.allocUnsafe(21);return e.writeUInt8(p.pubKeyHash,0),l.hash.copy(e,1),o.encode(e)})),i.prop(l,"hash",(()=>a.output?a.output.slice(3,23):a.address?f().hash:a.pubkey||l.pubkey?e.hash160(a.pubkey||l.pubkey):void 0)),i.prop(l,"output",(()=>{if(l.hash)return r.compile([s.OP_DUP,s.OP_HASH160,l.hash,s.OP_EQUALVERIFY,s.OP_CHECKSIG])})),i.prop(l,"pubkey",(()=>{if(a.input)return h()[1]})),i.prop(l,"signature",(()=>{if(a.input)return h()[0]})),i.prop(l,"input",(()=>{if(a.pubkey&&a.signature)return r.compile([a.signature,a.pubkey])})),i.prop(l,"witness",(()=>{if(l.input)return[]})),c.validate){let t=u.from([]);if(a.address){if(f().version!==p.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==f().hash.length)throw new TypeError("Invalid address");t=f().hash}if(a.hash){if(t.length>0&&!t.equals(a.hash))throw new TypeError("Hash mismatch");t=a.hash}if(a.output){if(25!==a.output.length||a.output[0]!==s.OP_DUP||a.output[1]!==s.OP_HASH160||20!==a.output[2]||a.output[23]!==s.OP_EQUALVERIFY||a.output[24]!==s.OP_CHECKSIG)throw new TypeError("Output is invalid");const e=a.output.slice(3,23);if(t.length>0&&!t.equals(e))throw new TypeError("Hash mismatch");t=e}if(a.pubkey){const r=e.hash160(a.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(a.input){const i=h();if(2!==i.length)throw new TypeError("Input is invalid");if(!r.isCanonicalScriptSignature(i[0]))throw new TypeError("Input has invalid signature");if(!(0,n.isPoint)(i[1]))throw new TypeError("Input has invalid pubkey");if(a.signature&&!a.signature.equals(i[0]))throw new TypeError("Signature mismatch");if(a.pubkey&&!a.pubkey.equals(i[1]))throw new TypeError("Pubkey mismatch");const o=e.hash160(i[1]);if(t.length>0&&!t.equals(o))throw new TypeError("Hash mismatch")}}return Object.assign(l,a)},dr}();Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return i.p2pkh}});const o=function(){if(Kr)return Gr;Kr=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.p2sh=void 0;const e=jr(),t=At(),r=ir(),n=nr(),i=ur(),o=Vr(),s=r.OPS;return Gr.p2sh=function(a,c){if(!(a.address||a.hash||a.output||a.redeem||a.input))throw new TypeError("Not enough data");c=Object.assign({validate:!0},c||{}),(0,n.typeforce)({network:n.typeforce.maybe(n.typeforce.Object),address:n.typeforce.maybe(n.typeforce.String),hash:n.typeforce.maybe(n.typeforce.BufferN(20)),output:n.typeforce.maybe(n.typeforce.BufferN(23)),redeem:n.typeforce.maybe({network:n.typeforce.maybe(n.typeforce.Object),output:n.typeforce.maybe(n.typeforce.Buffer),input:n.typeforce.maybe(n.typeforce.Buffer),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))}),input:n.typeforce.maybe(n.typeforce.Buffer),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))},a);let f=a.network;f||(f=a.redeem&&a.redeem.network||t.bitcoin);const p={network:f},l=i.value((()=>{const e=u.from(o.decode(a.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),d=i.value((()=>r.decompile(a.input))),y=i.value((()=>{const e=d(),t=e[e.length-1];return{network:f,output:t===s.OP_FALSE?u.from([]):t,input:r.compile(e.slice(0,-1)),witness:a.witness||[]}}));if(i.prop(p,"address",(()=>{if(!p.hash)return;const e=u.allocUnsafe(21);return e.writeUInt8(p.network.scriptHash,0),p.hash.copy(e,1),o.encode(e)})),i.prop(p,"hash",(()=>a.output?a.output.slice(2,22):a.address?l().hash:p.redeem&&p.redeem.output?e.hash160(p.redeem.output):void 0)),i.prop(p,"output",(()=>{if(p.hash)return r.compile([s.OP_HASH160,p.hash,s.OP_EQUAL])})),i.prop(p,"redeem",(()=>{if(a.input)return y()})),i.prop(p,"input",(()=>{if(a.redeem&&a.redeem.input&&a.redeem.output)return r.compile([].concat(r.decompile(a.redeem.input),a.redeem.output))})),i.prop(p,"witness",(()=>p.redeem&&p.redeem.witness?p.redeem.witness:p.input?[]:void 0)),i.prop(p,"name",(()=>{const e=["p2sh"];return void 0!==p.redeem&&void 0!==p.redeem.name&&e.push(p.redeem.name),e.join("-")})),c.validate){let t=u.from([]);if(a.address){if(l().version!==f.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==l().hash.length)throw new TypeError("Invalid address");t=l().hash}if(a.hash){if(t.length>0&&!t.equals(a.hash))throw new TypeError("Hash mismatch");t=a.hash}if(a.output){if(23!==a.output.length||a.output[0]!==s.OP_HASH160||20!==a.output[1]||a.output[22]!==s.OP_EQUAL)throw new TypeError("Output is invalid");const e=a.output.slice(2,22);if(t.length>0&&!t.equals(e))throw new TypeError("Hash mismatch");t=e}const n=n=>{if(n.output){const i=r.decompile(n.output);if(!i||i.length<1)throw new TypeError("Redeem.output too short");if(n.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(r.countNonPushOnlyOPs(i)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const o=e.hash160(n.output);if(t.length>0&&!t.equals(o))throw new TypeError("Hash mismatch");t=o}if(n.input){const e=n.input.length>0,t=n.witness&&n.witness.length>0;if(!e&&!t)throw new TypeError("Empty input");if(e&&t)throw new TypeError("Input and witness provided");if(e){const e=r.decompile(n.input);if(!r.isPushOnly(e))throw new TypeError("Non push-only scriptSig")}}};if(a.input){const e=d();if(!e||e.length<1)throw new TypeError("Input too short");if(!h(y().output))throw new TypeError("Input is invalid");n(y())}if(a.redeem){if(a.redeem.network&&a.redeem.network!==f)throw new TypeError("Network mismatch");if(a.input){const e=y();if(a.redeem.output&&!a.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(a.redeem.input&&!a.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}n(a.redeem)}if(a.witness&&a.redeem&&a.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(a.redeem.witness,a.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(p,a)},Gr}();Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});const s=function(){if(Xr)return qr;Xr=1,Object.defineProperty(qr,"__esModule",{value:!0}),qr.p2wpkh=void 0;const e=jr(),t=At(),r=ir(),n=nr(),i=ur(),o=$r(),s=r.OPS,a=u.alloc(0);return qr.p2wpkh=function(c,f){if(!(c.address||c.hash||c.output||c.pubkey||c.witness))throw new TypeError("Not enough data");f=Object.assign({validate:!0},f||{}),(0,n.typeforce)({address:n.typeforce.maybe(n.typeforce.String),hash:n.typeforce.maybe(n.typeforce.BufferN(20)),input:n.typeforce.maybe(n.typeforce.BufferN(0)),network:n.typeforce.maybe(n.typeforce.Object),output:n.typeforce.maybe(n.typeforce.BufferN(22)),pubkey:n.typeforce.maybe(n.isPoint),signature:n.typeforce.maybe(r.isCanonicalScriptSignature),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))},c);const h=i.value((()=>{const e=o.bech32.decode(c.address),t=e.words.shift(),r=o.bech32.fromWords(e.words);return{version:t,prefix:e.prefix,data:u.from(r)}})),p=c.network||t.bitcoin,l={name:"p2wpkh",network:p};if(i.prop(l,"address",(()=>{if(!l.hash)return;const e=o.bech32.toWords(l.hash);return e.unshift(0),o.bech32.encode(p.bech32,e)})),i.prop(l,"hash",(()=>c.output?c.output.slice(2,22):c.address?h().data:c.pubkey||l.pubkey?e.hash160(c.pubkey||l.pubkey):void 0)),i.prop(l,"output",(()=>{if(l.hash)return r.compile([s.OP_0,l.hash])})),i.prop(l,"pubkey",(()=>c.pubkey?c.pubkey:c.witness?c.witness[1]:void 0)),i.prop(l,"signature",(()=>{if(c.witness)return c.witness[0]})),i.prop(l,"input",(()=>{if(l.witness)return a})),i.prop(l,"witness",(()=>{if(c.pubkey&&c.signature)return[c.signature,c.pubkey]})),f.validate){let t=u.from([]);if(c.address){if(p&&p.bech32!==h().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==h().version)throw new TypeError("Invalid address version");if(20!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(c.hash){if(t.length>0&&!t.equals(c.hash))throw new TypeError("Hash mismatch");t=c.hash}if(c.output){if(22!==c.output.length||c.output[0]!==s.OP_0||20!==c.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(c.output.slice(2)))throw new TypeError("Hash mismatch");t=c.output.slice(2)}if(c.pubkey){const r=e.hash160(c.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");if(t=r,!(0,n.isPoint)(c.pubkey)||33!==c.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(c.witness){if(2!==c.witness.length)throw new TypeError("Witness is invalid");if(!r.isCanonicalScriptSignature(c.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,n.isPoint)(c.witness[1])||33!==c.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(c.signature&&!c.signature.equals(c.witness[0]))throw new TypeError("Signature mismatch");if(c.pubkey&&!c.pubkey.equals(c.witness[1]))throw new TypeError("Pubkey mismatch");const i=e.hash160(c.witness[1]);if(t.length>0&&!t.equals(i))throw new TypeError("Hash mismatch")}}return Object.assign(l,c)},qr}();Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return s.p2wpkh}});const a=function(){if(Yr)return Jr;Yr=1,Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.p2wsh=void 0;const e=jr(),t=At(),r=ir(),n=nr(),i=ur(),o=$r(),s=r.OPS,a=u.alloc(0);function c(e){return!(!h(e)||65!==e.length||4!==e[0]||!(0,n.isPoint)(e))}return Jr.p2wsh=function(f,h){if(!(f.address||f.hash||f.output||f.redeem||f.witness))throw new TypeError("Not enough data");h=Object.assign({validate:!0},h||{}),(0,n.typeforce)({network:n.typeforce.maybe(n.typeforce.Object),address:n.typeforce.maybe(n.typeforce.String),hash:n.typeforce.maybe(n.typeforce.BufferN(32)),output:n.typeforce.maybe(n.typeforce.BufferN(34)),redeem:n.typeforce.maybe({input:n.typeforce.maybe(n.typeforce.Buffer),network:n.typeforce.maybe(n.typeforce.Object),output:n.typeforce.maybe(n.typeforce.Buffer),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))}),input:n.typeforce.maybe(n.typeforce.BufferN(0)),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))},f);const p=i.value((()=>{const e=o.bech32.decode(f.address),t=e.words.shift(),r=o.bech32.fromWords(e.words);return{version:t,prefix:e.prefix,data:u.from(r)}})),l=i.value((()=>r.decompile(f.redeem.input)));let d=f.network;d||(d=f.redeem&&f.redeem.network||t.bitcoin);const y={network:d};if(i.prop(y,"address",(()=>{if(!y.hash)return;const e=o.bech32.toWords(y.hash);return e.unshift(0),o.bech32.encode(d.bech32,e)})),i.prop(y,"hash",(()=>f.output?f.output.slice(2):f.address?p().data:y.redeem&&y.redeem.output?e.sha256(y.redeem.output):void 0)),i.prop(y,"output",(()=>{if(y.hash)return r.compile([s.OP_0,y.hash])})),i.prop(y,"redeem",(()=>{if(f.witness)return{output:f.witness[f.witness.length-1],input:a,witness:f.witness.slice(0,-1)}})),i.prop(y,"input",(()=>{if(y.witness)return a})),i.prop(y,"witness",(()=>{if(f.redeem&&f.redeem.input&&f.redeem.input.length>0&&f.redeem.output&&f.redeem.output.length>0){const e=r.toStack(l());return y.redeem=Object.assign({witness:e},f.redeem),y.redeem.input=a,[].concat(e,f.redeem.output)}if(f.redeem&&f.redeem.output&&f.redeem.witness)return[].concat(f.redeem.witness,f.redeem.output)})),i.prop(y,"name",(()=>{const e=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&e.push(y.redeem.name),e.join("-")})),h.validate){let t=u.from([]);if(f.address){if(p().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==p().version)throw new TypeError("Invalid address version");if(32!==p().data.length)throw new TypeError("Invalid address data");t=p().data}if(f.hash){if(t.length>0&&!t.equals(f.hash))throw new TypeError("Hash mismatch");t=f.hash}if(f.output){if(34!==f.output.length||f.output[0]!==s.OP_0||32!==f.output[1])throw new TypeError("Output is invalid");const e=f.output.slice(2);if(t.length>0&&!t.equals(e))throw new TypeError("Hash mismatch");t=e}if(f.redeem){if(f.redeem.network&&f.redeem.network!==d)throw new TypeError("Network mismatch");if(f.redeem.input&&f.redeem.input.length>0&&f.redeem.witness&&f.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(f.redeem.output){const n=r.decompile(f.redeem.output);if(!n||n.length<1)throw new TypeError("Redeem.output is invalid");if(f.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(r.countNonPushOnlyOPs(n)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const i=e.sha256(f.redeem.output);if(t.length>0&&!t.equals(i))throw new TypeError("Hash mismatch");t=i}if(f.redeem.input&&!r.isPushOnly(l()))throw new TypeError("Non push-only scriptSig");if(f.witness&&f.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(f.witness,f.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(f.redeem.input&&l().some(c)||f.redeem.output&&(r.decompile(f.redeem.output)||[]).some(c))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(f.witness&&f.witness.length>0){const e=f.witness[f.witness.length-1];if(f.redeem&&f.redeem.output&&!f.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(f.witness.some(c)||(r.decompile(e)||[]).some(c))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,f)},Jr}();Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const c=function(){if(an)return Zr;an=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.p2tr=void 0;const e=E,t=At(),r=ir(),n=nr(),i=tn(),o=ln(),s=ur(),a=$r(),u=r.OPS;return Zr.p2tr=function(c,f){if(!(c.address||c.output||c.pubkey||c.internalPubkey||c.witness&&c.witness.length>1))throw new TypeError("Not enough data");f=Object.assign({validate:!0},f||{}),(0,n.typeforce)({address:n.typeforce.maybe(n.typeforce.String),input:n.typeforce.maybe(n.typeforce.BufferN(0)),network:n.typeforce.maybe(n.typeforce.Object),output:n.typeforce.maybe(n.typeforce.BufferN(34)),internalPubkey:n.typeforce.maybe(n.typeforce.BufferN(32)),hash:n.typeforce.maybe(n.typeforce.BufferN(32)),pubkey:n.typeforce.maybe(n.typeforce.BufferN(32)),signature:n.typeforce.maybe(n.typeforce.anyOf(n.typeforce.BufferN(64),n.typeforce.BufferN(65))),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer)),scriptTree:n.typeforce.maybe(n.isTaptree),redeem:n.typeforce.maybe({output:n.typeforce.maybe(n.typeforce.Buffer),redeemVersion:n.typeforce.maybe(n.typeforce.Number),witness:n.typeforce.maybe(n.typeforce.arrayOf(n.typeforce.Buffer))}),redeemVersion:n.typeforce.maybe(n.typeforce.Number)},c);const h=s.value((()=>{const t=a.bech32m.decode(c.address),r=t.words.shift(),n=a.bech32m.fromWords(t.words);return{version:r,prefix:t.prefix,data:e.Buffer.from(n)}})),p=s.value((()=>{if(c.witness&&c.witness.length)return c.witness.length>=2&&80===c.witness[c.witness.length-1][0]?c.witness.slice(0,-1):c.witness.slice()})),l=s.value((()=>c.scriptTree?(0,o.toHashTree)(c.scriptTree):c.hash?{hash:c.hash}:void 0)),d=c.network||t.bitcoin,y={name:"p2tr",network:d};if(s.prop(y,"address",(()=>{if(!y.pubkey)return;const e=a.bech32m.toWords(y.pubkey);return e.unshift(1),a.bech32m.encode(d.bech32,e)})),s.prop(y,"hash",(()=>{const e=l();if(e)return e.hash;const t=p();if(t&&t.length>1){const e=t[t.length-1],r=e[0]&n.TAPLEAF_VERSION_MASK,i=t[t.length-2],s=(0,o.tapleafHash)({output:i,version:r});return(0,o.rootHashFromPath)(e,s)}return null})),s.prop(y,"output",(()=>{if(y.pubkey)return r.compile([u.OP_1,y.pubkey])})),s.prop(y,"redeemVersion",(()=>c.redeemVersion?c.redeemVersion:c.redeem&&void 0!==c.redeem.redeemVersion&&null!==c.redeem.redeemVersion?c.redeem.redeemVersion:o.LEAF_VERSION_TAPSCRIPT)),s.prop(y,"redeem",(()=>{const e=p();if(e&&!(e.length<2))return{output:e[e.length-2],witness:e.slice(0,-2),redeemVersion:e[e.length-1][0]&n.TAPLEAF_VERSION_MASK}})),s.prop(y,"pubkey",(()=>{if(c.pubkey)return c.pubkey;if(c.output)return c.output.slice(2);if(c.address)return h().data;if(y.internalPubkey){const e=(0,o.tweakKey)(y.internalPubkey,y.hash);if(e)return e.x}})),s.prop(y,"internalPubkey",(()=>{if(c.internalPubkey)return c.internalPubkey;const e=p();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),s.prop(y,"signature",(()=>{if(c.signature)return c.signature;const e=p();return e&&1===e.length?e[0]:void 0})),s.prop(y,"witness",(()=>{if(c.witness)return c.witness;const t=l();if(t&&c.redeem&&c.redeem.output&&c.internalPubkey){const r=(0,o.tapleafHash)({output:c.redeem.output,version:y.redeemVersion}),n=(0,o.findScriptPath)(t,r);if(!n)return;const i=(0,o.tweakKey)(c.internalPubkey,t.hash);if(!i)return;const s=e.Buffer.concat([e.Buffer.from([y.redeemVersion|i.parity]),c.internalPubkey].concat(n));return[c.redeem.output,s]}return c.signature?[c.signature]:void 0})),f.validate){let t=e.Buffer.from([]);if(c.address){if(d&&d.bech32!==h().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==h().version)throw new TypeError("Invalid address version");if(32!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(c.pubkey){if(t.length>0&&!t.equals(c.pubkey))throw new TypeError("Pubkey mismatch");t=c.pubkey}if(c.output){if(34!==c.output.length||c.output[0]!==u.OP_1||32!==c.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(c.output.slice(2)))throw new TypeError("Pubkey mismatch");t=c.output.slice(2)}if(c.internalPubkey){const e=(0,o.tweakKey)(c.internalPubkey,y.hash);if(t.length>0&&!t.equals(e.x))throw new TypeError("Pubkey mismatch");t=e.x}if(t&&t.length&&!(0,i.getEccLib)().isXOnlyPoint(t))throw new TypeError("Invalid pubkey for p2tr");const s=l();if(c.hash&&s&&!c.hash.equals(s.hash))throw new TypeError("Hash mismatch");if(c.redeem&&c.redeem.output&&s){const e=(0,o.tapleafHash)({output:c.redeem.output,version:y.redeemVersion});if(!(0,o.findScriptPath)(s,e))throw new TypeError("Redeem script not in tree")}const a=p();if(c.redeem&&y.redeem){if(c.redeem.redeemVersion&&c.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(c.redeem.output){if(0===r.decompile(c.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(y.redeem.output&&!c.redeem.output.equals(y.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(c.redeem.witness&&y.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(c.redeem.witness,y.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(a&&a.length)if(1===a.length){if(c.signature&&!c.signature.equals(a[0]))throw new TypeError("Signature mismatch")}else{const e=a[a.length-1];if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);if((e.length-33)%32!=0)throw new TypeError(`The control-block length of ${e.length} is incorrect!`);const r=(e.length-33)/32;if(r>128)throw new TypeError(`The script path is too long. Got ${r}, expected max 128.`);const s=e.slice(1,33);if(c.internalPubkey&&!c.internalPubkey.equals(s))throw new TypeError("Internal pubkey mismatch");if(!(0,i.getEccLib)().isXOnlyPoint(s))throw new TypeError("Invalid internalPubkey for p2tr witness");const u=e[0]&n.TAPLEAF_VERSION_MASK,f=a[a.length-2],h=(0,o.tapleafHash)({output:f,version:u}),p=(0,o.rootHashFromPath)(e,h),l=(0,o.tweakKey)(s,p);if(!l)throw new TypeError("Invalid outputKey for p2tr witness");if(t.length&&!t.equals(l.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(l.parity!==(1&e[0]))throw new Error("Incorrect parity")}}return Object.assign(y,c)},Zr}();Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})}(Ot)),Ot}function yn(){if(cn)return Tt;cn=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.toOutputScript=Tt.fromOutputScript=Tt.toBech32=Tt.toBase58Check=Tt.fromBech32=Tt.fromBase58Check=void 0;const e=At(),t=dn(),r=ir(),n=nr(),i=$r(),o=Vr(),s="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function a(e){const t=u.from(o.decode(e));if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function c(e){let t,r;try{t=i.bech32.decode(e)}catch(e){}if(t){if(r=t.words[0],0!==r)throw new TypeError(e+" uses wrong encoding")}else if(t=i.bech32m.decode(e),r=t.words[0],0===r)throw new TypeError(e+" uses wrong encoding");const n=i.bech32.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:u.from(n)}}function f(e,t,r){const n=i.bech32.toWords(e);return n.unshift(t),0===t?i.bech32.encode(r,n):i.bech32m.encode(r,n)}return Tt.fromBase58Check=a,Tt.fromBech32=c,Tt.toBase58Check=function(e,t){(0,n.typeforce)((0,n.tuple)(n.Hash160bit,n.UInt8),arguments);const r=u.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)},Tt.toBech32=f,Tt.fromOutputScript=function(n,i){i=i||e.bitcoin;try{return t.p2pkh({output:n,network:i}).address}catch(e){}try{return t.p2sh({output:n,network:i}).address}catch(e){}try{return t.p2wpkh({output:n,network:i}).address}catch(e){}try{return t.p2wsh({output:n,network:i}).address}catch(e){}try{return t.p2tr({output:n,network:i}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=e[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(s),f(r,n,t.bech32)}(n,i)}catch(e){}throw new Error(r.toASM(n)+" has no matching Address")},Tt.toOutputScript=function(n,i){let o,u;i=i||e.bitcoin;try{o=a(n)}catch(e){}if(o){if(o.version===i.pubKeyHash)return t.p2pkh({hash:o.hash}).output;if(o.version===i.scriptHash)return t.p2sh({hash:o.hash}).output}else{try{u=c(n)}catch(e){}if(u){if(u.prefix!==i.bech32)throw new Error(n+" has an invalid prefix");if(0===u.version){if(20===u.data.length)return t.p2wpkh({hash:u.data}).output;if(32===u.data.length)return t.p2wsh({hash:u.data}).output}else if(1===u.version){if(32===u.data.length)return t.p2tr({pubkey:u.data}).output}else if(u.version>=2&&u.version<=16&&u.data.length>=2&&u.data.length<=40)return console.warn(s),r.compile([u.version+80,u.data])}}throw new Error(n+" has no matching Script")},Tt}var gn,wn={},mn={};var bn,En,_n={};function vn(){if(bn)return _n;bn=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.Transaction=void 0;const e=pn(),t=jr(),r=ir(),n=ir(),i=nr(),{typeforce:o}=i;function s(t){const r=t.length;return e.varuint.encodingLength(r)+r}const a=u.allocUnsafe(0),c=[],f=u.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),h=u.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),p=u.from("ffffffffffffffff","hex"),l={script:a,valueBuffer:p};class d{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,r){const n=new e.BufferReader(t),i=new d;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===d.ADVANCED_TRANSACTION_MARKER&&s===d.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let e=0;e<u;++e)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:c});const f=n.readVarInt();for(let e=0;e<f;++e)i.outs.push({value:n.readUInt64(),script:n.readVarSlice()});if(a){for(let e=0;e<u;++e)i.ins[e].witness=n.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=n.readUInt32(),r)return i;if(n.offset!==t.length)throw new Error("Transaction has unexpected data");return i}static fromHex(e){return d.fromBuffer(u.from(e,"hex"),!1)}static isCoinbaseHash(e){o(i.Hash256bit,e);for(let t=0;t<32;++t)if(0!==e[t])return!1;return!0}isCoinbase(){return 1===this.ins.length&&d.isCoinbaseHash(this.ins[0].hash)}addInput(e,t,r,n){return o(i.tuple(i.Hash256bit,i.UInt32,i.maybe(i.UInt32),i.maybe(i.Buffer)),arguments),i.Null(r)&&(r=d.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||a,sequence:r,witness:c})-1}addOutput(e,t){return o(i.tuple(i.Buffer,i.Satoshi),arguments),this.outs.push({script:e,value:t})-1}hasWitnesses(){return this.ins.some((e=>0!==e.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+e.varuint.encodingLength(this.ins.length)+e.varuint.encodingLength(this.outs.length)+this.ins.reduce(((e,t)=>e+40+s(t.script)),0)+this.outs.reduce(((e,t)=>e+8+s(t.script)),0)+(r?this.ins.reduce(((t,r)=>t+function(t){const r=t.length;return e.varuint.encodingLength(r)+t.reduce(((e,t)=>e+s(t)),0)}(r.witness)),0):0)}clone(){const e=new d;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map((e=>({hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}))),e.outs=this.outs.map((e=>({script:e.script,value:e.value}))),e}hashForSignature(e,s,c){if(o(i.tuple(i.UInt32,i.Buffer,i.Number),arguments),e>=this.ins.length)return h;const f=r.compile(r.decompile(s).filter((e=>e!==n.OPS.OP_CODESEPARATOR))),p=this.clone();if((31&c)===d.SIGHASH_NONE)p.outs=[],p.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}));else if((31&c)===d.SIGHASH_SINGLE){if(e>=this.outs.length)return h;p.outs.length=e+1;for(let t=0;t<e;t++)p.outs[t]=l;p.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}))}c&d.SIGHASH_ANYONECANPAY?(p.ins=[p.ins[e]],p.ins[0].script=f):(p.ins.forEach((e=>{e.script=a})),p.ins[e].script=f);const y=u.allocUnsafe(p.byteLength(!1)+4);return y.writeInt32LE(c,y.length-4),p.__toBuffer(y,0,!1),t.hash256(y)}hashForWitnessV1(r,n,c,f,h,p){if(o(i.tuple(i.UInt32,o.arrayOf(i.Buffer),o.arrayOf(i.Satoshi),i.UInt32),arguments),c.length!==this.ins.length||n.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=f===d.SIGHASH_DEFAULT?d.SIGHASH_ALL:f&d.SIGHASH_OUTPUT_MASK,y=(f&d.SIGHASH_INPUT_MASK)===d.SIGHASH_ANYONECANPAY,g=l===d.SIGHASH_NONE,w=l===d.SIGHASH_SINGLE;let m=a,b=a,E=a,_=a,v=a;if(!y){let r=e.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{r.writeSlice(e.hash),r.writeUInt32(e.index)})),m=t.sha256(r.end()),r=e.BufferWriter.withCapacity(8*this.ins.length),c.forEach((e=>r.writeUInt64(e))),b=t.sha256(r.end()),r=e.BufferWriter.withCapacity(n.map(s).reduce(((e,t)=>e+t))),n.forEach((e=>r.writeVarSlice(e))),E=t.sha256(r.end()),r=e.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>r.writeUInt32(e.sequence))),_=t.sha256(r.end())}if(g||w){if(w&&r<this.outs.length){const n=this.outs[r],i=e.BufferWriter.withCapacity(8+s(n.script));i.writeUInt64(n.value),i.writeVarSlice(n.script),v=t.sha256(i.end())}}else{const r=this.outs.map((e=>8+s(e.script))).reduce(((e,t)=>e+t)),n=e.BufferWriter.withCapacity(r);this.outs.forEach((e=>{n.writeUInt64(e.value),n.writeVarSlice(e.script)})),v=t.sha256(n.end())}const S=(h?2:0)+(p?1:0),I=174-(y?49:0)-(g?32:0)+(p?32:0)+(h?37:0),T=e.BufferWriter.withCapacity(I);if(T.writeUInt8(f),T.writeInt32(this.version),T.writeUInt32(this.locktime),T.writeSlice(m),T.writeSlice(b),T.writeSlice(E),T.writeSlice(_),g||w||T.writeSlice(v),T.writeUInt8(S),y){const e=this.ins[r];T.writeSlice(e.hash),T.writeUInt32(e.index),T.writeUInt64(c[r]),T.writeVarSlice(n[r]),T.writeUInt32(e.sequence)}else T.writeUInt32(r);if(p){const r=e.BufferWriter.withCapacity(s(p));r.writeVarSlice(p),T.writeSlice(t.sha256(r.end()))}return w&&T.writeSlice(v),h&&(T.writeSlice(h),T.writeUInt8(0),T.writeUInt32(4294967295)),t.taggedHash("TapSighash",u.concat([u.from([0]),T.end()]))}hashForWitnessV0(r,n,a,c){o(i.tuple(i.UInt32,i.Buffer,i.Satoshi,i.UInt32),arguments);let h,p=u.from([]),l=f,y=f,g=f;if(c&d.SIGHASH_ANYONECANPAY||(p=u.allocUnsafe(36*this.ins.length),h=new e.BufferWriter(p,0),this.ins.forEach((e=>{h.writeSlice(e.hash),h.writeUInt32(e.index)})),y=t.hash256(p)),c&d.SIGHASH_ANYONECANPAY||(31&c)===d.SIGHASH_SINGLE||(31&c)===d.SIGHASH_NONE||(p=u.allocUnsafe(4*this.ins.length),h=new e.BufferWriter(p,0),this.ins.forEach((e=>{h.writeUInt32(e.sequence)})),g=t.hash256(p)),(31&c)!==d.SIGHASH_SINGLE&&(31&c)!==d.SIGHASH_NONE){const r=this.outs.reduce(((e,t)=>e+8+s(t.script)),0);p=u.allocUnsafe(r),h=new e.BufferWriter(p,0),this.outs.forEach((e=>{h.writeUInt64(e.value),h.writeVarSlice(e.script)})),l=t.hash256(p)}else if((31&c)===d.SIGHASH_SINGLE&&r<this.outs.length){const n=this.outs[r];p=u.allocUnsafe(8+s(n.script)),h=new e.BufferWriter(p,0),h.writeUInt64(n.value),h.writeVarSlice(n.script),l=t.hash256(p)}p=u.allocUnsafe(156+s(n)),h=new e.BufferWriter(p,0);const w=this.ins[r];return h.writeInt32(this.version),h.writeSlice(y),h.writeSlice(g),h.writeSlice(w.hash),h.writeUInt32(w.index),h.writeVarSlice(n),h.writeUInt64(a),h.writeUInt32(w.sequence),h.writeSlice(l),h.writeUInt32(this.locktime),h.writeUInt32(c),t.hash256(p)}getHash(e){return e&&this.isCoinbase()?u.alloc(32,0):t.hash256(this.__toBuffer(void 0,void 0,e))}getId(){return(0,e.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(e,t){return this.__toBuffer(e,t,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(e,t){o(i.tuple(i.Number,i.Buffer),arguments),this.ins[e].script=t}setWitness(e,t){o(i.tuple(i.Number,[i.Buffer]),arguments),this.ins[e].witness=t}__toBuffer(t,r,n=!1){t||(t=u.allocUnsafe(this.byteLength(n)));const i=new e.BufferWriter(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(d.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(d.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((e=>{i.writeSlice(e.hash),i.writeUInt32(e.index),i.writeVarSlice(e.script),i.writeUInt32(e.sequence)})),i.writeVarInt(this.outs.length),this.outs.forEach((e=>{void 0!==e.value?i.writeUInt64(e.value):i.writeSlice(e.valueBuffer),i.writeVarSlice(e.script)})),o&&this.ins.forEach((e=>{i.writeVector(e.witness)})),i.writeUInt32(this.locktime),void 0!==r?t.slice(r,i.offset):t}}return _n.Transaction=d,d.DEFAULT_SEQUENCE=4294967295,d.SIGHASH_DEFAULT=0,d.SIGHASH_ALL=1,d.SIGHASH_NONE=2,d.SIGHASH_SINGLE=3,d.SIGHASH_ANYONECANPAY=128,d.SIGHASH_OUTPUT_MASK=3,d.SIGHASH_INPUT_MASK=128,d.ADVANCED_TRANSACTION_MARKER=0,d.ADVANCED_TRANSACTION_FLAG=1,_n}function Sn(){if(En)return wn;En=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.Block=void 0;const e=pn(),t=jr(),r=(gn||(gn=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.fastMerkleRoot=void 0,mn.fastMerkleRoot=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");let r=e.length;const n=e.concat();for(;r>1;){let e=0;for(let i=0;i<r;i+=2,++e){const o=n[i],s=i+1===r?o:n[i+1],a=u.concat([o,s]);n[e]=t(a)}r=e}return n[0]}),mn),n=vn(),i=nr(),{typeforce:o}=i,s=new TypeError("Cannot compute merkle root for zero transactions"),a=new TypeError("Cannot compute witness commit for non-segwit block");class c{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");const r=new e.BufferReader(t),i=new c;if(i.version=r.readInt32(),i.prevHash=r.readSlice(32),i.merkleRoot=r.readSlice(32),i.timestamp=r.readUInt32(),i.bits=r.readUInt32(),i.nonce=r.readUInt32(),80===t.length)return i;const o=()=>{const e=n.Transaction.fromBuffer(r.buffer.slice(r.offset),!0);return r.offset+=e.byteLength(),e},s=r.readVarInt();i.transactions=[];for(let e=0;e<s;++e){const e=o();i.transactions.push(e)}const a=i.getWitnessCommit();return a&&(i.witnessCommit=a),i}static fromHex(e){return c.fromBuffer(u.from(e,"hex"))}static calculateTarget(e){const t=((4278190080&e)>>24)-3,r=8388607&e,n=u.alloc(32,0);return n.writeUIntBE(r,29-t,3),n}static calculateMerkleRoot(e,n){if(o([{getHash:i.Function}],e),0===e.length)throw s;if(n&&!f(e))throw a;const c=e.map((e=>e.getHash(n))),h=(0,r.fastMerkleRoot)(c,t.hash256);return n?t.hash256(u.concat([h,e[0].ins[0].witness[0]])):h}getWitnessCommit(){if(!f(this.transactions))return null;const e=this.transactions[0].outs.filter((e=>e.script.slice(0,6).equals(u.from("6a24aa21a9ed","hex")))).map((e=>e.script.slice(6,38)));if(0===e.length)return null;const t=e[e.length-1];return t instanceof u&&32===t.length?t:null}hasWitnessCommit(){return this.witnessCommit instanceof u&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(e=this.transactions)instanceof Array&&e.some((e=>"object"==typeof e&&e.ins instanceof Array&&e.ins.some((e=>"object"==typeof e&&e.witness instanceof Array&&e.witness.length>0))));var e}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,r=!0){return t||!this.transactions?80:80+e.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((e,t)=>e+t.byteLength(r)),0)}getHash(){return t.hash256(this.toBuffer(!0))}getId(){return(0,e.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const e=new Date(0);return e.setUTCSeconds(this.timestamp),e}toBuffer(t){const r=u.allocUnsafe(this.byteLength(t)),n=new e.BufferWriter(r);return n.writeInt32(this.version),n.writeSlice(this.prevHash),n.writeSlice(this.merkleRoot),n.writeUInt32(this.timestamp),n.writeUInt32(this.bits),n.writeUInt32(this.nonce),t||!this.transactions||(e.varuint.encode(this.transactions.length,r,n.offset),n.offset+=e.varuint.encode.bytes,this.transactions.forEach((e=>{const t=e.byteLength();e.toBuffer(r,n.offset),n.offset+=t}))),r}toHex(e){return this.toBuffer(e).toString("hex")}checkTxRoots(){const e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit()))}checkProofOfWork(){const t=(0,e.reverseBuffer)(this.getHash()),r=c.calculateTarget(this.bits);return t.compare(r)<=0}__checkMerkleRoot(){if(!this.transactions)throw s;const e=c.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw s;if(!this.hasWitnessCommit())throw a;const e=c.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function f(e){return e instanceof Array&&e[0]&&e[0].ins&&e[0].ins instanceof Array&&e[0].ins[0]&&e[0].ins[0].witness&&e[0].ins[0].witness instanceof Array&&e[0].ins[0].witness.length>0}return wn.Block=c,wn}var In,Tn={},kn={},An={},Pn={},On={},Nn={},Un={};function xn(){return In||(In=1,e=Un,Object.defineProperty(e,"__esModule",{value:!0}),(t=e.GlobalTypes||(e.GlobalTypes={}))[t.UNSIGNED_TX=0]="UNSIGNED_TX",t[t.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(r=e.InputTypes||(e.InputTypes={}))[r.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",r[r.WITNESS_UTXO=1]="WITNESS_UTXO",r[r.PARTIAL_SIG=2]="PARTIAL_SIG",r[r.SIGHASH_TYPE=3]="SIGHASH_TYPE",r[r.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=6]="BIP32_DERIVATION",r[r.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",r[r.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",r[r.POR_COMMITMENT=9]="POR_COMMITMENT",r[r.TAP_KEY_SIG=19]="TAP_KEY_SIG",r[r.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",r[r.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",r[r.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",r[r.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(n=e.OutputTypes||(e.OutputTypes={}))[n.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=2]="BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",n[n.TAP_TREE=6]="TAP_TREE",n[n.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]),Un;var e,t,r,n}var Bn,Rn={};function Mn(){if(Bn)return Rn;Bn=1,Object.defineProperty(Rn,"__esModule",{value:!0});const e=xn();return Rn.decode=function(t){if(t.key[0]!==e.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const r=t.key.slice(1),n={masterFingerprint:t.value.slice(0,4),extendedPubkey:r,path:"m"};for(const e of(i=t.value.length/4-1,[...Array(i).keys()])){const r=t.value.readUInt32LE(4*e+4),i=!!(2147483648&r),o=2147483647&r;n.path+="/"+o.toString(10)+(i?"'":"")}var i;return n},Rn.encode=function(t){const r=u.from([e.GlobalTypes.GLOBAL_XPUB]),n=u.concat([r,t.extendedPubkey]),i=t.path.split("/"),o=u.allocUnsafe(4*i.length);t.masterFingerprint.copy(o,0);let s=4;return i.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),o.writeUInt32LE(r,s),s+=4})),{key:n,value:o}},Rn.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",Rn.check=function(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return h(t)&&78===t.length&&[2,3].indexOf(t[45])>-1&&h(r)&&4===r.length&&"string"==typeof n&&!!n.match(/^m(\/\d+'?)*$/)},Rn.canAddToArray=function(e,t,r){const n=t.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.extendedPubkey.equals(t.extendedPubkey))).length)},Rn}var Ln,Cn={};function Hn(){if(Ln)return Cn;Ln=1,Object.defineProperty(Cn,"__esModule",{value:!0});const e=xn();return Cn.encode=function(t){return{key:u.from([e.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}},Cn}var Dn,Fn={};function jn(){if(Dn)return Fn;Dn=1,Object.defineProperty(Fn,"__esModule",{value:!0});const e=xn();return Fn.decode=function(t){if(t.key[0]!==e.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},Fn.encode=function(t){return{key:u.from([e.InputTypes.FINAL_SCRIPTSIG]),value:t}},Fn.expected="Buffer",Fn.check=function(e){return h(e)},Fn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig},Fn}var Vn,Kn={};function Gn(){if(Vn)return Kn;Vn=1,Object.defineProperty(Kn,"__esModule",{value:!0});const e=xn();return Kn.decode=function(t){if(t.key[0]!==e.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},Kn.encode=function(t){return{key:u.from([e.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},Kn.expected="Buffer",Kn.check=function(e){return h(e)},Kn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness},Kn}var Wn,Xn={};function qn(){if(Wn)return Xn;Wn=1,Object.defineProperty(Xn,"__esModule",{value:!0});const e=xn();return Xn.decode=function(t){if(t.key[0]!==e.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},Xn.encode=function(t){return{key:u.from([e.InputTypes.NON_WITNESS_UTXO]),value:t}},Xn.expected="Buffer",Xn.check=function(e){return h(e)},Xn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo},Xn}var zn,$n={};function Yn(){if(zn)return $n;zn=1,Object.defineProperty($n,"__esModule",{value:!0});const e=xn();return $n.decode=function(t){if(t.key[0]!==e.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},$n.encode=function(t){const r=u.from([e.InputTypes.PARTIAL_SIG]);return{key:u.concat([r,t.pubkey]),value:t.signature}},$n.expected="{ pubkey: Buffer; signature: Buffer; }",$n.check=function(e){return h(e.pubkey)&&h(e.signature)&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&function(e){if(!h(e)||e.length<9)return!1;if(48!==e[0])return!1;if(e.length!==e[1]+3)return!1;if(2!==e[2])return!1;const t=e[3];if(t>33||t<1)return!1;if(2!==e[3+t+1])return!1;const r=e[3+t+2];return!(r>33||r<1)&&e.length===3+t+2+r+2}(e.signature)},$n.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)},$n}var Jn,Qn={};function Zn(){if(Jn)return Qn;Jn=1,Object.defineProperty(Qn,"__esModule",{value:!0});const e=xn();return Qn.decode=function(t){if(t.key[0]!==e.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},Qn.encode=function(t){return{key:u.from([e.InputTypes.POR_COMMITMENT]),value:u.from(t,"utf8")}},Qn.expected="string",Qn.check=function(e){return"string"==typeof e},Qn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment},Qn}var ei,ti={};function ri(){if(ei)return ti;ei=1,Object.defineProperty(ti,"__esModule",{value:!0});const e=xn();return ti.decode=function(t){if(t.key[0]!==e.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},ti.encode=function(t){const r=u.from([e.InputTypes.SIGHASH_TYPE]),n=u.allocUnsafe(4);return n.writeUInt32LE(t,0),{key:r,value:n}},ti.expected="number",ti.check=function(e){return"number"==typeof e},ti.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType},ti}var ni,ii={};function oi(){if(ni)return ii;ni=1,Object.defineProperty(ii,"__esModule",{value:!0});const e=xn();function t(e){return h(e)&&(64===e.length||65===e.length)}return ii.decode=function(r){if(r.key[0]!==e.InputTypes.TAP_KEY_SIG||1!==r.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+r.key.toString("hex"));if(!t(r.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return r.value},ii.encode=function(t){return{key:u.from([e.InputTypes.TAP_KEY_SIG]),value:t}},ii.expected="Buffer",ii.check=t,ii.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig},ii}var si,ai={};function ui(){if(si)return ai;si=1,Object.defineProperty(ai,"__esModule",{value:!0});const e=xn();return ai.decode=function(t){if(t.key[0]!==e.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const r=t.value[t.value.length-1];if((254&t.key[1])!==r)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const n=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:n,leafVersion:r}},ai.encode=function(t){const r=u.from([e.InputTypes.TAP_LEAF_SCRIPT]),n=u.from([t.leafVersion]);return{key:u.concat([r,t.controlBlock]),value:u.concat([t.script,n])}},ai.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",ai.check=function(e){return h(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&h(e.script)},ai.canAddToArray=function(e,t,r){const n=t.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.controlBlock.equals(t.controlBlock))).length)},ai}var ci,fi={};function hi(){if(ci)return fi;ci=1,Object.defineProperty(fi,"__esModule",{value:!0});const e=xn();function t(e){return h(e)&&32===e.length}return fi.decode=function(r){if(r.key[0]!==e.InputTypes.TAP_MERKLE_ROOT||1!==r.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+r.key.toString("hex"));if(!t(r.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return r.value},fi.encode=function(t){return{key:u.from([e.InputTypes.TAP_MERKLE_ROOT]),value:t}},fi.expected="Buffer",fi.check=t,fi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot},fi}var pi,li={};function di(){if(pi)return li;pi=1,Object.defineProperty(li,"__esModule",{value:!0});const e=xn();return li.decode=function(t){if(t.key[0]!==e.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},li.encode=function(t){const r=u.from([e.InputTypes.TAP_SCRIPT_SIG]);return{key:u.concat([r,t.pubkey,t.leafHash]),value:t.signature}},li.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",li.check=function(e){return h(e.pubkey)&&h(e.leafHash)&&h(e.signature)&&32===e.pubkey.length&&32===e.leafHash.length&&(64===e.signature.length||65===e.signature.length)},li.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex")+t.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey)&&e.leafHash.equals(t.leafHash))).length)},li}var yi,gi,wi,mi={},bi={},Ei={};function _i(){if(yi)return Ei;yi=1,Object.defineProperty(Ei,"__esModule",{value:!0});function e(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function t(t){return e(t),t<253?1:t<=65535?3:t<=4294967295?5:9}return Ei.encode=function r(n,i,o){if(e(n),i||(i=u.allocUnsafe(t(n))),!h(i))throw new TypeError("buffer must be a Buffer instance");return o||(o=0),n<253?(i.writeUInt8(n,o),Object.assign(r,{bytes:1})):n<=65535?(i.writeUInt8(253,o),i.writeUInt16LE(n,o+1),Object.assign(r,{bytes:3})):n<=4294967295?(i.writeUInt8(254,o),i.writeUInt32LE(n,o+1),Object.assign(r,{bytes:5})):(i.writeUInt8(255,o),i.writeUInt32LE(n>>>0,o+1),i.writeUInt32LE(n/4294967296|0,o+5),Object.assign(r,{bytes:9})),i},Ei.decode=function t(r,n){if(!h(r))throw new TypeError("buffer must be a Buffer instance");n||(n=0);const i=r.readUInt8(n);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),r.readUInt16LE(n+1);if(254===i)return Object.assign(t,{bytes:5}),r.readUInt32LE(n+1);{Object.assign(t,{bytes:9});const i=r.readUInt32LE(n+1),o=4294967296*r.readUInt32LE(n+5)+i;return e(o),o}},Ei.encodingLength=t,Ei}function vi(){if(gi)return bi;gi=1,Object.defineProperty(bi,"__esModule",{value:!0});const e=_i();function t(t){const r=t.key.length,n=t.value.length,i=e.encodingLength(r),o=e.encodingLength(n),s=u.allocUnsafe(i+r+o+n);return e.encode(r,s,0),t.key.copy(s,i),e.encode(n,s,i+r),t.value.copy(s,i+r+o),s}function r(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}return bi.range=e=>[...Array(e).keys()],bi.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},bi.keyValsToBuffer=function(e){const r=e.map(t);return r.push(u.from([0])),u.concat(r)},bi.keyValToBuffer=t,bi.readUInt64LE=function(e,t){const n=e.readUInt32LE(t);let i=e.readUInt32LE(t+4);return i*=4294967296,r(i+n,9007199254740991),i+n},bi.writeUInt64LE=function(e,t,n){return r(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8},bi}function Si(){if(wi)return mi;wi=1,Object.defineProperty(mi,"__esModule",{value:!0});const e=xn(),t=vi(),r=_i();return mi.decode=function(n){if(n.key[0]!==e.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+n.key.toString("hex"));const i=t.readUInt64LE(n.value,0);let o=8;const s=r.decode(n.value,o);o+=r.encodingLength(s);const a=n.value.slice(o);if(a.length!==s)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:i}},mi.encode=function(n){const{script:i,value:o}=n,s=r.encodingLength(i.length),a=u.allocUnsafe(8+s+i.length);return t.writeUInt64LE(a,o,0),r.encode(i.length,a,8),i.copy(a,8+s),{key:u.from([e.InputTypes.WITNESS_UTXO]),value:a}},mi.expected="{ script: Buffer; value: number; }",mi.check=function(e){return h(e.script)&&"number"==typeof e.value},mi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo},mi}var Ii,Ti={};function ki(){if(Ii)return Ti;Ii=1,Object.defineProperty(Ti,"__esModule",{value:!0});const e=xn(),t=_i();return Ti.decode=function(r){if(r.key[0]!==e.OutputTypes.TAP_TREE||1!==r.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+r.key.toString("hex"));let n=0;const i=[];for(;n<r.value.length;){const e=r.value[n++],o=r.value[n++],s=t.decode(r.value,n);n+=t.encodingLength(s),i.push({depth:e,leafVersion:o,script:r.value.slice(n,n+s)}),n+=s}return{leaves:i}},Ti.encode=function(r){const n=u.from([e.OutputTypes.TAP_TREE]),i=[].concat(...r.leaves.map((e=>[u.of(e.depth,e.leafVersion),t.encode(e.script.length),e.script])));return{key:n,value:u.concat(i)}},Ti.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",Ti.check=function(e){return Array.isArray(e.leaves)&&e.leaves.every((e=>e.depth>=0&&e.depth<=128&&(254&e.leafVersion)===e.leafVersion&&h(e.script)))},Ti.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree},Ti}var Ai,Pi={};function Oi(){if(Ai)return Pi;Ai=1,Object.defineProperty(Pi,"__esModule",{value:!0});const e=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];return Pi.makeConverter=function(t,r=e){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+e.key.toString("hex"));const n=e.key.slice(1);if(!r(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+e.key.toString("hex"));if(e.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:e.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=e.value.length/4-1,[...Array(o).keys()])){const r=e.value.readUInt32LE(4*t+4),n=!!(2147483648&r),o=2147483647&r;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=u.from([t]),n=u.concat([r,e.pubkey]),i=e.path.split("/"),o=u.allocUnsafe(4*i.length);e.masterFingerprint.copy(o,0);let s=4;return i.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),o.writeUInt32LE(r,s),s+=4})),{key:n,value:o}},check:function(e){return h(e.pubkey)&&h(e.masterFingerprint)&&"string"==typeof e.path&&r(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)}}},Pi}var Ni,Ui={};function xi(){if(Ni)return Ui;return Ni=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.makeChecker=function(e){return function(t){let r;if(e.includes(t.key[0])&&(r=t.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+t.key.toString("hex"));return r}},Ui}var Bi,Ri={};function Mi(){if(Bi)return Ri;return Bi=1,Object.defineProperty(Ri,"__esModule",{value:!0}),Ri.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(t){return{key:u.from([e]),value:t}},check:function(e){return h(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}},Ri}var Li,Ci={};function Hi(){if(Li)return Ci;Li=1,Object.defineProperty(Ci,"__esModule",{value:!0});const e=_i(),t=Oi(),r=e=>32===e.length;return Ci.makeConverter=function(n){const i=t.makeConverter(n,r);return{decode:function(t){const r=e.decode(t.value),n=e.encodingLength(r),o=i.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)s[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:s})},encode:function(t){const r=i.encode(t),n=e.encodingLength(t.leafHashes.length),o=u.allocUnsafe(n);e.encode(t.leafHashes.length,o);const s=u.concat([o,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},check:function(e){return Array.isArray(e.leafHashes)&&e.leafHashes.every((e=>h(e)&&32===e.length))&&i.check(e)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:i.canAddToArray}},Ci}var Di,Fi={};function ji(){if(Di)return Fi;return Di=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e||1!==t.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+t.key.toString("hex"));if(32!==t.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return t.value},encode:function(t){return{key:u.from([e]),value:t}},check:function(e){return h(e)&&32===e.length},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}},Fi}var Vi,Ki,Gi,Wi={};function Xi(){if(Vi)return Wi;return Vi=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(t){return{key:u.from([e]),value:t}},check:function(e){return h(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}},Wi}function qi(){if(Ki)return Nn;Ki=1,Object.defineProperty(Nn,"__esModule",{value:!0});const e=xn(),t=Mn(),r=Hn(),n=jn(),i=Gn(),o=qn(),s=Yn(),a=Zn(),u=ri(),c=oi(),f=ui(),h=hi(),p=di(),l=Si(),d=ki(),y=Oi(),g=xi(),w=Mi(),m=Hi(),b=ji(),E=Xi(),_={unsignedTx:r,globalXpub:t,checkPubkey:g.makeChecker([])};Nn.globals=_;const v={nonWitnessUtxo:o,partialSig:s,sighashType:u,finalScriptSig:n,finalScriptWitness:i,porCommitment:a,witnessUtxo:l,bip32Derivation:y.makeConverter(e.InputTypes.BIP32_DERIVATION),redeemScript:w.makeConverter(e.InputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(e.InputTypes.WITNESS_SCRIPT),checkPubkey:g.makeChecker([e.InputTypes.PARTIAL_SIG,e.InputTypes.BIP32_DERIVATION]),tapKeySig:c,tapScriptSig:p,tapLeafScript:f,tapBip32Derivation:m.makeConverter(e.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:b.makeConverter(e.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:h};Nn.inputs=v;const S={bip32Derivation:y.makeConverter(e.OutputTypes.BIP32_DERIVATION),redeemScript:w.makeConverter(e.OutputTypes.REDEEM_SCRIPT),witnessScript:E.makeConverter(e.OutputTypes.WITNESS_SCRIPT),checkPubkey:g.makeChecker([e.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:m.makeConverter(e.OutputTypes.TAP_BIP32_DERIVATION),tapTree:d,tapInternalKey:b.makeConverter(e.OutputTypes.TAP_INTERNAL_KEY)};return Nn.outputs=S,Nn}var zi,$i,Yi,Ji={};function Qi(){return $i||($i=1,function(e){function t(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),t(function(){if(Gi)return On;Gi=1,Object.defineProperty(On,"__esModule",{value:!0});const e=qi(),t=vi(),r=_i(),n=xn();function i(e,t,r){if(!t.equals(u.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${t.toString("hex")}`)}function o(r,{globalMapKeyVals:o,inputKeyVals:s,outputKeyVals:a}){const u={unsignedTx:r};let c=0;for(const t of o)switch(t.key[0]){case n.GlobalTypes.UNSIGNED_TX:if(i("global",t.key,n.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case n.GlobalTypes.GLOBAL_XPUB:void 0===u.globalXpub&&(u.globalXpub=[]),u.globalXpub.push(e.globals.globalXpub.decode(t));break;default:u.unknownKeyVals||(u.unknownKeyVals=[]),u.unknownKeyVals.push(t)}const f=s.length,h=a.length,p=[],l=[];for(const r of t.range(f)){const t={};for(const o of s[r])switch(e.inputs.checkPubkey(o),o.key[0]){case n.InputTypes.NON_WITNESS_UTXO:if(i("input",o.key,n.InputTypes.NON_WITNESS_UTXO),void 0!==t.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");t.nonWitnessUtxo=e.inputs.nonWitnessUtxo.decode(o);break;case n.InputTypes.WITNESS_UTXO:if(i("input",o.key,n.InputTypes.WITNESS_UTXO),void 0!==t.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");t.witnessUtxo=e.inputs.witnessUtxo.decode(o);break;case n.InputTypes.PARTIAL_SIG:void 0===t.partialSig&&(t.partialSig=[]),t.partialSig.push(e.inputs.partialSig.decode(o));break;case n.InputTypes.SIGHASH_TYPE:if(i("input",o.key,n.InputTypes.SIGHASH_TYPE),void 0!==t.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");t.sighashType=e.inputs.sighashType.decode(o);break;case n.InputTypes.REDEEM_SCRIPT:if(i("input",o.key,n.InputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");t.redeemScript=e.inputs.redeemScript.decode(o);break;case n.InputTypes.WITNESS_SCRIPT:if(i("input",o.key,n.InputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");t.witnessScript=e.inputs.witnessScript.decode(o);break;case n.InputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(e.inputs.bip32Derivation.decode(o));break;case n.InputTypes.FINAL_SCRIPTSIG:i("input",o.key,n.InputTypes.FINAL_SCRIPTSIG),t.finalScriptSig=e.inputs.finalScriptSig.decode(o);break;case n.InputTypes.FINAL_SCRIPTWITNESS:i("input",o.key,n.InputTypes.FINAL_SCRIPTWITNESS),t.finalScriptWitness=e.inputs.finalScriptWitness.decode(o);break;case n.InputTypes.POR_COMMITMENT:i("input",o.key,n.InputTypes.POR_COMMITMENT),t.porCommitment=e.inputs.porCommitment.decode(o);break;case n.InputTypes.TAP_KEY_SIG:i("input",o.key,n.InputTypes.TAP_KEY_SIG),t.tapKeySig=e.inputs.tapKeySig.decode(o);break;case n.InputTypes.TAP_SCRIPT_SIG:void 0===t.tapScriptSig&&(t.tapScriptSig=[]),t.tapScriptSig.push(e.inputs.tapScriptSig.decode(o));break;case n.InputTypes.TAP_LEAF_SCRIPT:void 0===t.tapLeafScript&&(t.tapLeafScript=[]),t.tapLeafScript.push(e.inputs.tapLeafScript.decode(o));break;case n.InputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(e.inputs.tapBip32Derivation.decode(o));break;case n.InputTypes.TAP_INTERNAL_KEY:i("input",o.key,n.InputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=e.inputs.tapInternalKey.decode(o);break;case n.InputTypes.TAP_MERKLE_ROOT:i("input",o.key,n.InputTypes.TAP_MERKLE_ROOT),t.tapMerkleRoot=e.inputs.tapMerkleRoot.decode(o);break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(o)}p.push(t)}for(const r of t.range(h)){const t={};for(const o of a[r])switch(e.outputs.checkPubkey(o),o.key[0]){case n.OutputTypes.REDEEM_SCRIPT:if(i("output",o.key,n.OutputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");t.redeemScript=e.outputs.redeemScript.decode(o);break;case n.OutputTypes.WITNESS_SCRIPT:if(i("output",o.key,n.OutputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");t.witnessScript=e.outputs.witnessScript.decode(o);break;case n.OutputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(e.outputs.bip32Derivation.decode(o));break;case n.OutputTypes.TAP_INTERNAL_KEY:i("output",o.key,n.OutputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=e.outputs.tapInternalKey.decode(o);break;case n.OutputTypes.TAP_TREE:i("output",o.key,n.OutputTypes.TAP_TREE),t.tapTree=e.outputs.tapTree.decode(o);break;case n.OutputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(e.outputs.tapBip32Derivation.decode(o));break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(o)}l.push(t)}return{globalMap:u,inputs:p,outputs:l}}return On.psbtFromBuffer=function(e,i){let s=0;function a(){const t=r.decode(e,s);s+=r.encodingLength(t);const n=e.slice(s,s+t);return s+=t,n}function u(){return{key:a(),value:a()}}function c(){if(s>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const t=0===e.readUInt8(s);return t&&s++,t}if(1886610036!==function(){const t=e.readUInt32BE(s);return s+=4,t}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const t=e.readUInt8(s);return s+=1,t}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const f=[],h={};for(;!c();){const e=u(),t=e.key.toString("hex");if(h[t])throw new Error("Format Error: Keys must be unique for global keymap: key "+t);h[t]=1,f.push(e)}const p=f.filter((e=>e.key[0]===n.GlobalTypes.UNSIGNED_TX));if(1!==p.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const l=i(p[0].value),{inputCount:d,outputCount:y}=l.getInputOutputCounts(),g=[],w=[];for(const e of t.range(d)){const t={},r=[];for(;!c();){const n=u(),i=n.key.toString("hex");if(t[i])throw new Error("Format Error: Keys must be unique for each input: input index "+e+" key "+i);t[i]=1,r.push(n)}g.push(r)}for(const e of t.range(y)){const t={},r=[];for(;!c();){const n=u(),i=n.key.toString("hex");if(t[i])throw new Error("Format Error: Keys must be unique for each output: output index "+e+" key "+i);t[i]=1,r.push(n)}w.push(r)}return o(l,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:w})},On.checkKeyBuffer=i,On.psbtFromKeyVals=o,On}()),t(function(){if(zi)return Ji;zi=1,Object.defineProperty(Ji,"__esModule",{value:!0});const e=qi(),t=vi();Ji.psbtToBuffer=function({globalMap:e,inputs:r,outputs:n}){const{globalKeyVals:o,inputKeyVals:s,outputKeyVals:a}=i({globalMap:e,inputs:r,outputs:n}),c=t.keyValsToBuffer(o),f=e=>0===e.length?[u.from([0])]:e.map(t.keyValsToBuffer),h=f(s),p=f(a),l=u.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),u.concat([l,c].concat(h,p))};const r=(e,t)=>e.key.compare(t.key);function n(e,t){const n=new Set,i=Object.entries(e).reduce(((e,[r,i])=>{if("unknownKeyVals"===r)return e;const o=t[r];if(void 0===o)return e;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((e=>e.key.toString("hex"))).forEach((e=>{if(n.has(e))throw new Error("Serialize Error: Duplicate key: "+e);n.add(e)})),e.concat(s)}),[]),o=e.unknownKeyVals?e.unknownKeyVals.filter((e=>!n.has(e.key.toString("hex")))):[];return i.concat(o).sort(r)}function i({globalMap:t,inputs:r,outputs:i}){return{globalKeyVals:n(t,e.globals),inputKeyVals:r.map((t=>n(t,e.inputs))),outputKeyVals:i.map((t=>n(t,e.outputs)))}}return Ji.psbtToKeyVals=i,Ji}())}(Pn)),Pn}var Zi,eo,to={};function ro(){return Zi||(Zi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=qi();function r(e,t){const r=e[t];if(void 0===r)throw new Error(`No input #${t}`);return r}function n(e,t){const r=e[t];if(void 0===r)throw new Error(`No output #${t}`);return r}function i(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function o(e){return(r,n)=>{for(const o of Object.keys(r)){const s=r[o],{canAdd:a,canAddToArray:u,check:c,expected:f}=t[e+"s"][o]||{};if(c)if(!!u){if(!Array.isArray(s)||n[o]&&!Array.isArray(n[o]))throw new Error(`Key type ${o} must be an array`);s.every(c)||i(e,o,f,s);const t=n[o]||[],r=new Set;if(!s.every((e=>u(t,e,r))))throw new Error("Can not add duplicate data to array");n[o]=t.concat(s)}else{if(c(s)||i(e,o,f,s),!a(n,s))throw new Error(`Can not add duplicate data to ${e}`);n[o]=s}}}}e.checkForInput=r,e.checkForOutput=n,e.checkHasKey=function(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&0!==t.filter((t=>t.key.equals(e.key))).length)throw new Error(`Duplicate Key: ${e.key.toString("hex")}`)},e.getEnumLength=function(e){let t=0;return Object.keys(e).forEach((e=>{Number(isNaN(Number(e)))&&t++})),t},e.inputCheckUncleanFinalized=function(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const e=!!t.redeemScript,n=!!t.witnessScript,i=!e||!!t.finalScriptSig,o=!n||!!t.finalScriptWitness,s=!!t.finalScriptSig||!!t.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${e} has too much or too little data to clean`)},e.updateGlobal=o("global"),e.updateInput=o("input"),e.updateOutput=o("output"),e.addInputAttributes=function(t,n){const i=r(t,t.length-1);e.updateInput(n,i)},e.addOutputAttributes=function(t,r){const i=n(t,t.length-1);e.updateOutput(r,i)},e.defaultVersionSetter=function(e,t){if(!h(t)||t.length<4)throw new Error("Set Version: Invalid Transaction");return t.writeUInt32LE(e,0),t},e.defaultLocktimeSetter=function(e,t){if(!h(t)||t.length<4)throw new Error("Set Locktime: Invalid Transaction");return t.writeUInt32LE(e,t.length-4),t}}(to)),to}function no(){if(eo)return kn;eo=1,Object.defineProperty(kn,"__esModule",{value:!0});const e=function(){if(Yi)return An;Yi=1,Object.defineProperty(An,"__esModule",{value:!0});const e=Qi();function t(e,t,r){return n=>{if(e.has(n))return;const i=r.filter((e=>e.key.toString("hex")===n))[0];t.push(i),e.add(n)}}function r(e){return e.globalMap.unsignedTx}function n(e){const t=new Set;return e.forEach((e=>{const r=e.key.toString("hex");if(t.has(r))throw new Error("Combine: KeyValue Map keys should be unique");t.add(r)})),t}return An.combine=function(i){const o=i[0],s=e.psbtToKeyVals(o),a=i.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const u=r(o);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=n(s.globalKeyVals),f=s.inputKeyVals.map(n),h=s.outputKeyVals.map(n);for(const i of a){const o=r(i);if(void 0===o||!o.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const a=e.psbtToKeyVals(i);n(a.globalKeyVals).forEach(t(c,s.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(n).forEach(((e,r)=>e.forEach(t(f[r],s.inputKeyVals[r],a.inputKeyVals[r])))),a.outputKeyVals.map(n).forEach(((e,r)=>e.forEach(t(h[r],s.outputKeyVals[r],a.outputKeyVals[r]))))}return e.psbtFromKeyVals(u,{globalMapKeyVals:s.globalKeyVals,inputKeyVals:s.inputKeyVals,outputKeyVals:s.outputKeyVals})},An}(),t=Qi(),r=xn(),n=ro();return kn.Psbt=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=u.from(e,"base64");return this.fromBuffer(r,t)}static fromHex(e,t){const r=u.from(e,"hex");return this.fromBuffer(r,t)}static fromBuffer(e,r){const n=t.psbtFromBuffer(e,r),i=new this(n.globalMap.unsignedTx);return Object.assign(i,n),i}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return t.psbtToBuffer(this)}updateGlobal(e){return n.updateGlobal(e,this.globalMap),this}updateInput(e,t){const r=n.checkForInput(this.inputs,e);return n.updateInput(t,r),this}updateOutput(e,t){const r=n.checkForOutput(this.outputs,e);return n.updateOutput(t,r),this}addUnknownKeyValToGlobal(e){return n.checkHasKey(e,this.globalMap.unknownKeyVals,n.getEnumLength(r.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const i=n.checkForInput(this.inputs,e);return n.checkHasKey(t,i.unknownKeyVals,n.getEnumLength(r.InputTypes)),i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const i=n.checkForOutput(this.outputs,e);return n.checkHasKey(t,i.unknownKeyVals,n.getEnumLength(r.OutputTypes)),i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(t),this}addInput(e){this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToInput(r,e))),n.addInputAttributes(this.inputs,e),this}addOutput(e){this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToOutput(r,e))),n.addOutputAttributes(this.outputs,e),this}clearFinalizedInput(e){const t=n.checkForInput(this.inputs,e);n.inputCheckUncleanFinalized(e,t);for(const e of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(e)||delete t[e];return this}combine(...t){const r=e.combine([this].concat(t));return Object.assign(this,r),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}},kn}var io,oo,so,ao,uo={},co={};function fo(){if(io)return co;io=1,Object.defineProperty(co,"__esModule",{value:!0}),co.signatureBlocksAction=co.checkInputForSig=co.pubkeyInScript=co.pubkeyPositionInScript=co.witnessStackToScriptWitness=co.isP2TR=co.isP2SHScript=co.isP2WSHScript=co.isP2WPKH=co.isP2PKH=co.isP2PK=co.isP2MS=void 0;const e=_i(),t=ir(),r=vn(),n=jr(),i=dn();function o(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function s(e,r){const i=(0,n.hash160)(e),o=e.slice(1,33),s=t.decompile(r);if(null===s)throw new Error("Unknown script error");return s.findIndex((t=>"number"!=typeof t&&(t.equals(e)||t.equals(i)||t.equals(o))))}function a(e,t,n){const{hashType:i}=t(e),o=[];i&r.Transaction.SIGHASH_ANYONECANPAY&&o.push("addInput");switch(31&i){case r.Transaction.SIGHASH_ALL:break;case r.Transaction.SIGHASH_SINGLE:case r.Transaction.SIGHASH_NONE:o.push("addOutput"),o.push("setInputSequence")}return-1===o.indexOf(n)}return co.isP2MS=o(i.p2ms),co.isP2PK=o(i.p2pk),co.isP2PKH=o(i.p2pkh),co.isP2WPKH=o(i.p2wpkh),co.isP2WSHScript=o(i.p2wsh),co.isP2SHScript=o(i.p2sh),co.isP2TR=o(i.p2tr),co.witnessStackToScriptWitness=function(t){let r=u.allocUnsafe(0);function n(t){const n=r.length,i=e.encodingLength(t);r=u.concat([r,u.allocUnsafe(i)]),e.encode(t,r,n)}function i(e){n(e.length),function(e){r=u.concat([r,u.from(e)])}(e)}var o;return n((o=t).length),o.forEach(i),r},co.pubkeyPositionInScript=s,co.pubkeyInScript=function(e,t){return-1!==s(e,t)},co.checkInputForSig=function(e,r){return function(e){let r=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];r=function(e){const r=e.finalScriptSig&&t.decompile(e.finalScriptSig)||[],n=e.finalScriptWitness&&t.decompile(e.finalScriptWitness)||[];return r.concat(n).filter((e=>h(e)&&t.isCanonicalScriptSignature(e))).map((e=>({signature:e})))}(e)}else r=e.partialSig;return r.map((e=>e.signature))}(e).some((e=>a(e,t.signature.decode,r)))},co.signatureBlocksAction=a,co}function ho(){if(oo)return uo;oo=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.checkTaprootInputForSigs=uo.tapTreeFromList=uo.tapTreeToList=uo.tweakInternalPubKey=uo.checkTaprootOutputFields=uo.checkTaprootInputFields=uo.isTaprootOutput=uo.isTaprootInput=uo.serializeTaprootSignature=uo.tapScriptFinalizer=uo.toXOnly=void 0;const e=nr(),t=vn(),r=fo(),n=ln(),i=dn(),o=fo();function s(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,r.isP2TR)(e.witnessUtxo.script))}function a(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,r.isP2TR)(t))}function c(e=[]){return 1===e.length&&0===e[0].depth?{output:e[0].script,version:e[0].leafVersion}:function(e){let t;for(const r of e)if(t=p(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}(e)}function f(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||t.Transaction.SIGHASH_DEFAULT}}function h(t,r=[],i=0){if(i>n.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,e.isTapleaf)(t)?(r.push({depth:i,leafVersion:t.version||n.LEAF_VERSION_TAPSCRIPT,script:t.output}),r):(t[0]&&h(t[0],r,i+1),t[1]&&h(t[1],r,i+1),r):[]}function p(t,r,i=0){if(i>n.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(t.depth===i)return r?void 0:{output:t.script,version:t.leafVersion};if((0,e.isTapleaf)(r))return;const o=p(t,r&&r[0],i+1);if(o)return[o,r&&r[1]];const s=p(t,r&&r[1],i+1);return s?[r&&r[0],s]:void 0}function l(e,t){if(!t)return!0;const r=(0,n.tapleafHash)({output:e.script,version:e.leafVersion});return(0,n.rootHashFromPath)(e.controlBlock,r).equals(t)}function d(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}return uo.toXOnly=e=>32===e.length?e:e.slice(1,33),uo.tapScriptFinalizer=function(e,t,i){const o=function(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const i=(e.tapLeafScript||[]).sort(((e,t)=>e.controlBlock.length-t.controlBlock.length)).find((t=>function(e,t,r){const i=(0,n.tapleafHash)({output:e.script,version:e.leafVersion});return(!r||r.equals(i))&&void 0!==t.find((e=>e.leafHash.equals(i)))}(t,e.tapScriptSig,r)));if(!i)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return i}(t,e,i);try{const e=function(e,t){const i=(0,n.tapleafHash)({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter((e=>e.leafHash.equals(i))).map((e=>function(e,t){return Object.assign({positionInScript:(0,r.pubkeyPositionInScript)(t.pubkey,e)},t)}(t.script,e))).sort(((e,t)=>t.positionInScript-e.positionInScript)).map((e=>e.signature))}(t,o),i=e.concat(o.script).concat(o.controlBlock);return{finalScriptWitness:(0,r.witnessStackToScriptWitness)(i)}}catch(t){throw new Error(`Can not finalize taproot input #${e}: ${t}`)}},uo.serializeTaprootSignature=function(e,t){const r=t?u.from([t]):u.from([]);return u.concat([e,r])},uo.isTaprootInput=s,uo.isTaprootOutput=a,uo.checkTaprootInputFields=function(e,t,r){!function(e,t,r){const n=s(e)&&d(t),i=d(e)&&s(t),o=e===t&&s(t)&&d(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every((e=>l(e,t.tapMerkleRoot))),i=(e.tapLeafScript||[]).every((e=>l(e,t.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot){if(!(t.tapLeafScript||[]).every((t=>l(t,e.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(e,t,r)},uo.checkTaprootOutputFields=function(e,t,r){!function(e,t,r){const n=a(e)&&d(t),i=d(e)&&a(t),o=e===t&&a(t)&&d(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:t}=e,o=function(e,t){const r=t&&c(t.leaves),{output:n}=(0,i.p2tr)({internalPubkey:e,scriptTree:r});return n}(r,n);if(t&&!t.equals(o))throw new Error("Error adding output. Script or address missmatch.")}}(e,t)},uo.tweakInternalPubKey=function(e,t){const r=t.tapInternalKey,i=r&&(0,n.tweakKey)(r,t.tapMerkleRoot);if(!i)throw new Error(`Cannot tweak tap internal key for input #${e}. Public key: ${r&&r.toString("hex")}`);return i.x},uo.tapTreeToList=function(t){if(!(0,e.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return h(t)},uo.tapTreeFromList=c,uo.checkTaprootInputForSigs=function(e,t){const r=function(e){const t=[];e.tapKeySig&&t.push(e.tapKeySig);e.tapScriptSig&&t.push(...e.tapScriptSig.map((e=>e.signature)));if(!t.length){const r=function(e){if(!e)return;const t=e.slice(2);if(64===t.length||65===t.length)return t}(e.finalScriptWitness);r&&t.push(r)}return t}(e);return r.some((e=>(0,o.signatureBlocksAction)(e,f,t)))},uo}function po(){if(so)return Tn;so=1,Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.Psbt=void 0;const e=no(),t=_i(),r=ro(),n=yn(),i=pn(),o=At(),s=dn(),a=ln(),c=ir(),f=vn(),p=ho(),l=fo(),d={network:o.bitcoin,maximumFeeRate:5e3};class y{static fromBase64(e,t={}){const r=u.from(e,"base64");return this.fromBuffer(r,t)}static fromHex(e,t={}){const r=u.from(e,"hex");return this.fromBuffer(r,t)}static fromBuffer(t,r={}){const n=e.Psbt.fromBuffer(t,g),i=new y(r,n);var o,s;return o=i.__CACHE.__TX,s=i.__CACHE,o.ins.forEach((e=>{T(s,e)})),i}constructor(t={},r=new e.Psbt(new w)){this.data=r,this.opts=Object.assign({},d,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const n=(e,t,r,n)=>Object.defineProperty(e,t,{enumerable:r,writable:n});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(e){this.setVersion(e)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(e){this.setLocktime(e)}get txInputs(){return this.__CACHE.__TX.ins.map((e=>({hash:(0,i.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((e=>{let t;try{t=(0,n.fromOutputScript)(e.script,this.opts.network)}catch(e){}return{script:(0,i.cloneBuffer)(e.script),value:e.value,address:t}}))}combine(...e){return this.data.combine(...e.map((e=>e.data))),this}clone(){const e=y.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){v(e),this.opts.maximumFeeRate=e}setVersion(e){v(e),S(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){v(e),S(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){v(t),S(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=e)throw new Error("Input index too high");return r.__TX.ins[e].sequence=t,r.__EXTRACTED_TX=void 0,this}addInputs(e){return e.forEach((e=>this.addInput(e))),this}addInput(e){if(arguments.length>1||!e||void 0===e.hash||void 0===e.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,p.checkTaprootInputFields)(e,e,"addInput"),S(this.data.inputs,"addInput"),e.witnessScript&&X(e.witnessScript);const t=this.__CACHE;this.data.addInput(e);T(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&D(this.__CACHE,n,r),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}addOutputs(e){return e.forEach((e=>this.addOutput(e))),this}addOutput(e){if(arguments.length>1||!e||void 0===e.value||void 0===e.address&&void 0===e.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");S(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,i=(0,n.toOutputScript)(t,r);e=Object.assign(e,{script:i})}(0,p.checkTaprootOutputFields)(e,e,"addOutput");const r=this.__CACHE;return this.data.addOutput(e),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(e){if(!this.data.inputs.every(E))throw new Error("Not finalized");const t=this.__CACHE;if(e||function(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,t,this.opts),t.__EXTRACTED_TX)return t.__EXTRACTED_TX;const r=t.__TX.clone();return F(this.data.inputs,r,t,!0),r}getFeeRate(){return O("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return O("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,r.checkForInput)(this.data.inputs,0),z(this.data.inputs.length).forEach((e=>this.finalizeInput(e))),this}finalizeInput(e,t){const n=(0,r.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(n)?this._finalizeTaprootInput(e,n,void 0,t):this._finalizeInput(e,n,t)}finalizeTaprootInput(e,t,n=p.tapScriptFinalizer){const i=(0,r.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(i))return this._finalizeTaprootInput(e,i,t,n);throw new Error(`Cannot finalize input #${e}. Not Taproot.`)}_finalizeInput(e,t,r=N){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=j(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);(t.witnessScript||(0,l.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(e,t,this.__CACHE);if(!n)throw new Error(`No script found for input #${e}`);!function(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach((e=>{const{hashType:t}=c.signature.decode(e.signature);if(r!==t)throw new Error("Signature sighash does not match input sighash type")}))}(t);const{finalScriptSig:a,finalScriptWitness:u}=r(e,t,n,s,i,o);if(a&&this.data.updateInput(e,{finalScriptSig:a}),u&&this.data.updateInput(e,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${e}`);return this.data.clearFinalizedInput(e),this}_finalizeTaprootInput(e,t,r,n=p.tapScriptFinalizer){if(!t.witnessUtxo)throw new Error(`Cannot finalize input #${e}. Missing withness utxo.`);if(t.tapKeySig){const r=s.p2tr({output:t.witnessUtxo.script,signature:t.tapKeySig}),n=(0,l.witnessStackToScriptWitness)(r.witness);this.data.updateInput(e,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(e,t,r);this.data.updateInput(e,{finalScriptWitness:i})}return this.data.clearFinalizedInput(e),this}getInputType(e){const t=(0,r.checkForInput)(this.data.inputs,e),n=W(V(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(!e)return;const t=c.decompile(e);if(!t)return;const r=t[t.length-1];if(!h(r)||G(r)||(n=r,c.isCanonicalScriptSignature(n)))return;var n;if(!c.decompile(r))return;return r}(t.finalScriptSig),t.witnessScript||function(e){if(!e)return;const t=H(e),r=t[t.length-1];if(G(r))return;if(!c.decompile(r))return;return r}(t.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+q(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=V(r,t,n),{meaningfulScript:o}=W(i,r,"input",t.redeemScript,t.witnessScript);return(0,l.pubkeyInScript)(e,o)}(t,(0,r.checkForInput)(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const n=(0,r.checkForInput)(this.data.inputs,e),i=_(t);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(e,t){return function(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=W(i,r,"output",t.redeemScript,t.witnessScript);return(0,l.pubkeyInScript)(e,o)}(t,(0,r.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const n=(0,r.checkForOutput)(this.data.outputs,e),i=_(t);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(e){(0,r.checkForInput)(this.data.inputs,0);return z(this.data.inputs.length).map((t=>this.validateSignaturesOfInput(t,e))).reduce(((e,t)=>!0===t&&e),!0)}validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e];return(0,p.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(e,t,r):this._validateSignaturesOfInput(e,t,r)}_validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const o=r?i.filter((e=>e.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,u,f;for(const r of o){const i=c.signature.decode(r.signature),{hash:o,script:h}=f!==i.hashType?x(e,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};f=i.hashType,a=o,u=h,I(r.pubkey,h,"verify"),s.push(t(r.pubkey,o,i.signature))}return s.every((e=>!0===e))}validateSignaturesOfTaprootInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,p.toXOnly)(r))?M(e,n,this.data.inputs,r,this.__CACHE):function(e,t,r,n){const i=[];if(t.tapInternalKey){const r=B(e,t,n);r&&i.push(r)}if(t.tapScriptSig){const e=t.tapScriptSig.map((e=>e.pubkey));i.push(...e)}const o=i.map((i=>M(e,t,r,i,n)));return o.flat()}(e,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((e=>!e.leafHash));let u=0;if(i&&a){if(!t(a.pubkey,a.hash,R(i)))return!1;u++}if(o)for(const e of o){const r=s.find((t=>e.pubkey.equals(t.pubkey)));if(r){if(!t(e.pubkey,r.hash,R(e.signature)))return!1;u++}}return u>0}signAllInputsHD(e,t=[f.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of z(this.data.inputs.length))try{this.signInputHD(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(e,t=[f.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!e||!e.publicKey||!e.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of z(this.data.inputs.length))o.push(this.signInputHDAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(e,t,r=[f.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return C(e,this.data.inputs,t).forEach((t=>this.signInput(e,t,r))),this}signInputHDAsync(e,t,r=[f.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=C(e,this.data.inputs,t).map((t=>this.signInputAsync(e,t,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(e,t){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of z(this.data.inputs.length))try{this.signInput(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsAsync(e,t){return new Promise(((r,n)=>{if(!e||!e.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInput(e,t,n){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,r.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(i)?this._signTaprootInput(e,i,t,void 0,n):this._signInput(e,t,n)}signTaprootInput(e,t,n,i){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const o=(0,r.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(o))return this._signTaprootInput(e,o,t,n,i);throw new Error(`Input #${e} is not of type Taproot.`)}_signInput(e,t,r=[f.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=U(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:c.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}_signTaprootInput(e,t,r,n,i=[f.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=o.filter((e=>!e.leafHash)).map((e=>(0,p.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType)))[0],a=o.filter((e=>!!e.leafHash)).map((e=>({pubkey:(0,p.toXOnly)(r.publicKey),signature:(0,p.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType),leafHash:e.leafHash})));return s&&this.data.updateInput(e,{tapKeySig:s}),a.length&&this.data.updateInput(e,{tapScriptSig:a}),this}signInputAsync(e,t,n){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,r.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(i)?this._signTaprootInputAsync(e,i,t,void 0,n):this._signInputAsync(e,t,n)}))}signTaprootInputAsync(e,t,n,i){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const o=(0,r.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(o))return this._signTaprootInputAsync(e,o,t,n,i);throw new Error(`Input #${e} is not of type Taproot.`)}))}_signInputAsync(e,t,r=[f.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=U(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then((r=>{const n=[{pubkey:t.publicKey,signature:c.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})}))}async _signTaprootInputAsync(e,t,r,n,i=[f.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=[],a=o.filter((e=>!e.leafHash))[0];if(a){const e=Promise.resolve(r.signSchnorr(a.hash)).then((e=>({tapKeySig:(0,p.serializeTaprootSignature)(e,t.sighashType)})));s.push(e)}const u=o.filter((e=>!!e.leafHash));if(u.length){const e=u.map((e=>Promise.resolve(r.signSchnorr(e.hash)).then((n=>({tapScriptSig:[{pubkey:(0,p.toXOnly)(r.publicKey),signature:(0,p.serializeTaprootSignature)(n,t.sighashType),leafHash:e.leafHash}]})))));s.push(...e)}return Promise.all(s).then((t=>{t.forEach((t=>this.data.updateInput(e,t)))}))}checkTaprootHashesForSig(e,t,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${e}.`);const o=M(e,t,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${e} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return m(this.__CACHE),this.data.toBuffer()}toHex(){return m(this.__CACHE),this.data.toHex()}toBase64(){return m(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&X(t.witnessScript),(0,p.checkTaprootInputFields)(this.data.inputs[e],t,"updateInput"),this.data.updateInput(e,t),t.nonWitnessUtxo&&D(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){const r=this.data.outputs[e];return(0,p.checkTaprootOutputFields)(r,t,"updateOutput"),this.data.updateOutput(e,t),this}addUnknownKeyValToGlobal(e){return this.data.addUnknownKeyValToGlobal(e),this}addUnknownKeyValToInput(e,t){return this.data.addUnknownKeyValToInput(e,t),this}addUnknownKeyValToOutput(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}clearFinalizedInput(e){return this.data.clearFinalizedInput(e),this}}Tn.Psbt=y;const g=e=>new w(e);class w{constructor(e=u.from([2,0,0,0,0,0,0,0,0,0])){this.tx=f.Transaction.fromBuffer(e),function(e){if(!e.ins.every((e=>e.script&&0===e.script.length&&e.witness&&0===e.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(e){if(void 0===e.hash||void 0===e.index||!h(e.hash)&&"string"!=typeof e.hash||"number"!=typeof e.index)throw new Error("Error adding input.");const t="string"==typeof e.hash?(0,i.reverseBuffer)(u.from(e.hash,"hex")):e.hash;this.tx.addInput(t,e.index,e.sequence)}addOutput(e){if(void 0===e.script||void 0===e.value||!h(e.script)||"number"!=typeof e.value)throw new Error("Error adding output.");this.tx.addOutput(e.script,e.value)}toBuffer(){return this.tx.toBuffer()}}function m(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function b(e,t,r){if(!t)return!1;let n;if(n=r?r.map((e=>{const r=function(e){if(65===e.length){const t=1&e[64],r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}(e);return t.find((e=>e.pubkey.equals(r)))})).filter((e=>!!e)):t,n.length>e)throw new Error("Too many signatures");return n.length===e}function E(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function _(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function v(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function S(e,t){e.forEach((e=>{if((0,p.isTaprootInput)(e)?(0,p.checkTaprootInputForSigs)(e,t):(0,l.checkInputForSig)(e,t))throw new Error("Can not modify transaction, signatures exist.")}))}function I(e,t,r){if(!(0,l.pubkeyInScript)(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function T(e,t){const r=(0,i.reverseBuffer)(u.from(t.hash)).toString("hex")+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function k(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const A=k(s.p2sh,"Redeem script"),P=k(s.p2wsh,"Witness script");function O(e,t,r,n){if(!r.every(E))throw new Error(`PSBT must be finalized to calculate ${t}`);if("__FEE_RATE"===e&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===e&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),F(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function N(e,t,r,n,i,o){const a=q(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return b(1,e.partialSig);case"multisig":const r=s.p2ms({output:t});return b(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,r,a))throw new Error(`Can not finalize input #${e}`);return function(e,t,r,n,i,o){let a,u;const c=function(e,t,r){let n;switch(t){case"multisig":const t=function(e,t){const r=s.p2ms({output:e});return r.pubkeys.map((e=>(t.filter((t=>t.pubkey.equals(e)))[0]||{}).signature)).filter((e=>!!e))}(e,r);n=s.p2ms({output:e,signatures:t});break;case"pubkey":n=s.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=s.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=s.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),f=o?s.p2wsh({redeem:c}):null,h=i?s.p2sh({redeem:f||c}):null;n?(u=f?(0,l.witnessStackToScriptWitness)(f.witness):(0,l.witnessStackToScriptWitness)(c.witness),h&&(a=h.input)):a=h?h.input:c.input;return{finalScriptSig:a,finalScriptWitness:u}}(r,a,t.partialSig,n,i,o)}function U(e,t,n,i,o){const s=(0,r.checkForInput)(e,t),{hash:a,sighashType:u,script:c}=x(t,s,i,!1,o);return I(n,c,"sign"),{hash:a,sighashType:u}}function x(e,t,r,n,i){const o=r.__TX,a=t.sighashType||f.Transaction.SIGHASH_ALL;let u,c;if(L(a,i),t.nonWitnessUtxo){const n=j(r,t,e),i=o.ins[e].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const a=o.ins[e].index;c=n.outs[a]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");c=t.witnessUtxo}const{meaningfulScript:h,type:p}=W(c.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(p)>=0)u=o.hashForWitnessV0(e,h,c.value,a);else if((0,l.isP2WPKH)(h)){const t=s.p2pkh({hash:h.slice(2)}).output;u=o.hashForWitnessV0(e,t,c.value,a)}else{if(void 0===t.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${h.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),u=o.hashForSignature(e,h,a)}return{script:h,sighashType:a,hash:u}}function B(e,t,r){const{script:n}=K(e,t,r);return(0,l.isP2TR)(n)?n.subarray(2,34):null}function R(e){return 64===e.length?e:e.subarray(0,64)}function M(e,t,r,n,i,o,s){const c=i.__TX,h=t.sighashType||f.Transaction.SIGHASH_DEFAULT;L(h,s);const d=r.map(((e,t)=>K(t,e,i))),y=d.map((e=>e.script)),g=d.map((e=>e.value)),w=[];if(t.tapInternalKey&&!o){const r=B(e,t,i)||u.from([]);if((0,p.toXOnly)(n).equals(r)){const t=c.hashForWitnessV1(e,y,g,h);w.push({pubkey:n,hash:t})}}const m=(t.tapLeafScript||[]).filter((e=>(0,l.pubkeyInScript)(n,e.script))).map((e=>{const t=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return Object.assign({hash:t},e)})).filter((e=>!o||o.equals(e.hash))).map((t=>{const r=c.hashForWitnessV1(e,y,g,f.Transaction.SIGHASH_DEFAULT,t.hash);return{pubkey:n,hash:r,leafHash:t.hash}}));return w.concat(m)}function L(e,t){if(t&&t.indexOf(e)<0){const t=function(e){let t=e&f.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case f.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case f.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case f.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${t}`)}}function C(e,t,n){const i=(0,r.checkForInput)(t,e);if(!i.bip32Derivation||0===i.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const o=i.bip32Derivation.map((e=>e.masterFingerprint.equals(n.fingerprint)?e:void 0)).filter((e=>!!e));if(0===o.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return o.map((e=>{const t=n.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t}))}function H(e){let r=0;function n(){const n=t.decode(e,r);return r+=t.decode.bytes,n}function i(){return t=n(),r+=t,e.slice(r-t,r);var t}return function(){const e=n(),t=[];for(let r=0;r<e;r++)t.push(i());return t}()}function D(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=f.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;{const e=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e,e}},set(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function F(e,t,r,n){let i=0;e.forEach(((e,o)=>{if(n&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),n&&e.finalScriptWitness&&(t.ins[o].witness=H(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=j(r,e,o),s=t.ins[o].index,a=n.outs[s];i+=a.value}}));const o=t.outs.reduce(((e,t)=>e+t.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function j(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(e,t,r),n[r]}function V(e,t,r){const{script:n}=K(e,t,r);return n}function K(e,t,r){if(void 0!==t.witnessUtxo)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(void 0!==t.nonWitnessUtxo){const n=j(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function G(e){return 33===e.length&&c.isCanonicalPubKey(e)}function W(e,t,r,n,i){const o=(0,l.isP2SHScript)(e),s=o&&n&&(0,l.isP2WSHScript)(n),a=(0,l.isP2WSHScript)(e);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,A(t,e,n,r),P(t,n,i,r),X(u)):a?(u=i,P(t,e,i,r),X(u)):o?(u=n,A(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function X(e){if((0,l.isP2WPKH)(e)||(0,l.isP2SHScript)(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function q(e){return(0,l.isP2WPKH)(e)?"witnesspubkeyhash":(0,l.isP2PKH)(e)?"pubkeyhash":(0,l.isP2MS)(e)?"multisig":(0,l.isP2PK)(e)?"pubkey":"nonstandard"}function z(e){return[...Array(e).keys()]}return Tn}var lo,yo=(ao||(ao=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.initEccLib=e.Transaction=e.opcodes=e.Psbt=e.Block=e.script=e.payments=e.networks=e.crypto=e.address=void 0;const t=yn();e.address=t;const r=jr();e.crypto=r;const n=At();e.networks=n;const i=dn();e.payments=i;const o=ir();e.script=o;var s=Sn();Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return s.Block}});var a=po();Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return a.Psbt}});var u=Lt();Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return u.OPS}});var c=vn();Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return c.Transaction}});var f=tn();Object.defineProperty(e,"initEccLib",{enumerable:!0,get:function(){return f.initEccLib}})}(It)),It),go={exports:{}};var wo,mo=(lo||(lo=1,wo=go,function(){var e="input is invalid type",t="object"==typeof window,r=t?window:{};r.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof o&&o.versions&&o.versions.node?r=s:n&&(r=self);var i=!r.JS_SHA3_NO_COMMON_JS&&wo.exports,a=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),c=[4,1024,262144,67108864],f=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],p=[224,256,384,512],l=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],y={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var g=function(e,t,r){return function(n){return new U(e,t,e).update(n)[r]()}},w=function(e,t,r){return function(n,i){return new U(e,t,i).update(n)[r]()}},m=function(e,t,r){return function(t,n,i,o){return S["cshake"+e].update(t,n,i,o)[r]()}},b=function(e,t,r){return function(t,n,i,o){return S["kmac"+e].update(t,n,i,o)[r]()}},E=function(e,t,r,n){for(var i=0;i<d.length;++i){var o=d[i];e[o]=t(r,n,o)}return e},_=function(e,t){var r=g(e,t,"hex");return r.create=function(){return new U(e,t,e)},r.update=function(e){return r.create().update(e)},E(r,g,e,t)},v=[{name:"keccak",padding:[1,256,65536,16777216],bits:p,createMethod:_},{name:"sha3",padding:[6,1536,393216,100663296],bits:p,createMethod:_},{name:"shake",padding:[31,7936,2031616,520093696],bits:l,createMethod:function(e,t){var r=w(e,t,"hex");return r.create=function(r){return new U(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},E(r,w,e,t)}},{name:"cshake",padding:c,bits:l,createMethod:function(e,t){var r=y[e],n=m(e,0,"hex");return n.create=function(n,i,o){return i||o?new U(e,t,n).bytepad([i,o],r):S["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},E(n,m,e,t)}},{name:"kmac",padding:c,bits:l,createMethod:function(e,t){var r=y[e],n=b(e,0,"hex");return n.create=function(n,i,o){return new x(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},E(n,b,e,t)}}],S={},I=[],T=0;T<v.length;++T)for(var k=v[T],A=k.bits,P=0;P<A.length;++P){var O=k.name+"_"+A[P];if(I.push(O),S[O]=k.createMethod(A[P],k.padding),"sha3"!==k.name){var N=k.name+A[P];I.push(N),S[N]=S[O]}}function U(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function x(e,t,r){U.call(this,e,t,r)}U.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,o,s=this.blocks,u=this.byteCount,c=t.length,h=this.blockCount,p=0,l=this.s;p<c;){if(this.reset)for(this.reset=!1,s[0]=this.block,i=1;i<h+1;++i)s[i]=0;if(r)for(i=this.start;p<c&&i<u;++p)s[i>>2]|=t[p]<<f[3&i++];else for(i=this.start;p<c&&i<u;++p)(o=t.charCodeAt(p))<128?s[i>>2]|=o<<f[3&i++]:o<2048?(s[i>>2]|=(192|o>>6)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]):o<55296||o>=57344?(s[i>>2]|=(224|o>>12)<<f[3&i++],s[i>>2]|=(128|o>>6&63)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++p)),s[i>>2]|=(240|o>>18)<<f[3&i++],s[i>>2]|=(128|o>>12&63)<<f[3&i++],s[i>>2]|=(128|o>>6&63)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]);if(this.lastByteIndex=i,i>=u){for(this.start=i-u,this.block=s[h],i=0;i<h;++i)l[i]^=s[i];B(l),this.reset=!0}else this.start=i}return this},U.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},U.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,o=t.length;if(r)i=o;else for(var s=0;s<t.length;++s){var u=t.charCodeAt(s);u<128?i+=1:u<2048?i+=2:u<55296||u>=57344?i+=3:(u=65536+((1023&u)<<10|1023&t.charCodeAt(++s)),i+=4)}return i+=this.encode(8*i),this.update(t),i},U.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,o=[];return o.length=i,this.update(o),this},U.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];B(n)}},U.prototype.toString=U.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],a+=u[e>>4&15]+u[15&e]+u[e>>12&15]+u[e>>8&15]+u[e>>20&15]+u[e>>16&15]+u[e>>28&15]+u[e>>24&15];s%t==0&&(B(r),o=0)}return i&&(e=r[o],a+=u[e>>4&15]+u[15&e],i>1&&(a+=u[e>>12&15]+u[e>>8&15]),i>2&&(a+=u[e>>20&15]+u[e>>16&15])),a},U.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(e);s<n;){for(o=0;o<t&&s<n;++o,++s)u[s]=r[o];s%t==0&&B(r)}return i&&(u[o]=r[o],e=e.slice(0,a)),e},U.prototype.buffer=U.prototype.arrayBuffer,U.prototype.digest=U.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,u=[];a<i;){for(s=0;s<r&&a<i;++s,++a)e=a<<2,t=n[s],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&B(n)}return o&&(e=a<<2,t=n[s],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},x.prototype=new U,x.prototype.finalize=function(){return this.encode(this.outputBits,!0),U.prototype.finalize.call(this)};var B=function(e){var t,r,n,i,o,s,a,u,c,f,p,l,d,y,g,w,m,b,E,_,v,S,I,T,k,A,P,O,N,U,x,B,R,M,L,C,H,D,F,j,V,K,G,W,X,q,z,$,Y,J,Q,Z,ee,te,re,ne,ie,oe,se,ae,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],p=e[7]^e[17]^e[27]^e[37]^e[47],t=(l=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(u<<1|c>>>31),r=o^(c<<1|u>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|p>>>31),r=a^(p<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=u^(l<<1|d>>>31),r=c^(d<<1|l>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=p^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,y=e[0],g=e[1],q=e[11]<<4|e[10]>>>28,z=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,G=e[41]<<18|e[40]>>>14,M=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,w=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,$=e[22]<<10|e[23]>>>22,Y=e[23]<<10|e[22]>>>22,U=e[33]<<13|e[32]>>>19,x=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,C=e[14]<<6|e[15]>>>26,H=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,E=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,B=e[45]<<29|e[44]>>>3,R=e[44]<<29|e[45]>>>3,T=e[6]<<28|e[7]>>>4,k=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,v=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,X=e[9]<<27|e[8]>>>5,A=e[18]<<20|e[19]>>>12,P=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,j=e[38]<<8|e[39]>>>24,V=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,I=e[49]<<14|e[48]>>>18,e[0]=y^~w&b,e[1]=g^~m&E,e[10]=T^~A&O,e[11]=k^~P&N,e[20]=M^~C&D,e[21]=L^~H&F,e[30]=W^~q&$,e[31]=X^~z&Y,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=w^~b&_,e[3]=m^~E&v,e[12]=A^~O&U,e[13]=P^~N&x,e[22]=C^~D&j,e[23]=H^~F&V,e[32]=q^~$&J,e[33]=z^~Y&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=b^~_&S,e[5]=E^~v&I,e[14]=O^~U&B,e[15]=N^~x&R,e[24]=D^~j&K,e[25]=F^~V&G,e[34]=$^~J&Z,e[35]=Y^~Q&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&fe,e[6]=_^~S&y,e[7]=v^~I&g,e[16]=U^~B&T,e[17]=x^~R&k,e[26]=j^~K&M,e[27]=V^~G&L,e[36]=J^~Z&W,e[37]=Q^~ee&X,e[46]=ae^~ce&te,e[47]=ue^~fe&re,e[8]=S^~y&w,e[9]=I^~g&m,e[18]=B^~T&A,e[19]=R^~k&P,e[28]=K^~M&C,e[29]=G^~L&H,e[38]=Z^~W&q,e[39]=ee^~X&z,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=h[n],e[1]^=h[n+1]};if(i)wo.exports=S;else for(T=0;T<I.length;++T)r[I[T]]=S[I[T]]}()),go.exports);var bo=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};function Eo(e,t){return bo(this,void 0,void 0,(function*(){let r;var n;"publicKeyJwk"in e?r=vt(e.publicKeyJwk):"publicKeyMultibase"in e&&(r=yield(n=e,Et(void 0,void 0,void 0,(function*(){const e=yield T({keyPair:n});return vt(e)}))));const i=lt("errors","identityErrorBaseMessage");let o="";switch(t.code){case c.Bitcoin:case c.Mocknet:case c.Testnet:o=function(e,t){return yo.payments.p2pkh({pubkey:e,network:yo.networks[t.code]}).address}(r,t);break;case c.Ethmain:case c.Ethropst:case c.Ethrinkeby:case c.Ethgoerli:case c.Ethsepolia:o=function(e){const t=e.toString("hex"),r=new k.ec("secp256k1").keyFromPublic(t,"hex").getPublic().encode("hex").slice(2),n=u;return`0x${mo.keccak256(n.from(r,"hex")).slice(24).toString()}`}(r);break;default:throw new ft("deriveIssuingAddressFromPublicKey",`${i} - ${lt("errors","deriveIssuingAddressFromPublicKey")}`)}return o}))}function _o(e){if(e){const t="string"==typeof e?e:e.code;return!!Object.keys(f).some((e=>e===t))&&!!f[t].test}return!1}var vo=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))};const{LinkedDataProof:So}=_.suites;class Io extends So{constructor({issuer:e=null,verificationMethod:t=null,document:r=null,proof:n=null,options:i={}}){if(super({type:"MerkleProof2019"}),this.type="MerkleProof2019",this.issuer=null,this.verificationMethod=null,this.proof=null,this.proofValue=null,this.document=null,this.explorerAPIs=[],this.documentLoader=null,this.proofVerificationProcess=["getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"],this.identityVerificationProcess=["deriveIssuingAddressFromPublicKey","compareIssuingAddress"],this.transactionId="",!r)throw new Error("A document signed by MerkleProof2019 is required for the verification process.");this.issuer=e,this.verificationMethod=t,this.document=r,this.setProof(n),this.setOptions(i),this.getChain(),_o(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet())}static decodeMerkleProof2019(e){return new tt.Decoder(e.proofValue).decode()}setProof(e=null){const t=null!=e?e:this.document.proof;if(!t)throw new Error("The passed document is not signed.");this.proof=t,this.proofValue=Io.decodeMerkleProof2019(this.proof)}verifyProof(){return vo(this,arguments,void 0,(function*({documentLoader:e,verifyIdentity:t}={documentLoader:e=>{},verifyIdentity:!0}){let r;this.documentLoader=e;let n="";try{yield this.verifyProcess(this.proofVerificationProcess),t&&(yield this.verifyIdentity()),r=!0}catch(e){console.error(e),r=!1,n=e.message}return{verificationMethod:this.verificationMethod,verified:r,error:n}}))}verifyIdentity(){return vo(this,void 0,void 0,(function*(){if(null!=this.verificationMethod)try{yield this.verifyProcess(this.identityVerificationProcess)}catch(e){throw new Error(e)}}))}getProofVerificationProcess(){return this.proofVerificationProcess}getIdentityVerificationProcess(){return this.identityVerificationProcess}getIssuerPublicKey(){var e,t;return _o(this.chain)?"This mock chain does not support issuing addresses":null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.issuingAddress)&&void 0!==t?t:""}getIssuanceTime(){var e,t;return null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.time)&&void 0!==t?t:""}getChain(){return this.chain||(this.chain=nt(this.proofValue)),this.chain}getTxData(){return this.txData?this.txData:(console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?"),null)}adaptProofVerificationProcessToMocknet(){it(this.proofVerificationProcess,"getTransactionId"),it(this.proofVerificationProcess,"fetchRemoteHash"),it(this.proofVerificationProcess,"checkMerkleRoot")}adaptIdentityVerificationProcessToMocknet(){this.identityVerificationProcess=[]}setOptions(e){var t;this.explorerAPIs=null!==(t=e.explorerAPIs)&&void 0!==t?t:[],e.executeStepMethod&&"function"==typeof e.executeStepMethod&&(this.executeStep=e.executeStepMethod)}executeStep(e,t){return vo(this,arguments,void 0,(function*(e,t,r=""){return yield t()}))}verifyProcess(e){return vo(this,void 0,void 0,(function*(){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");yield this[t]()}}))}checkMerkleRoot(){return vo(this,void 0,void 0,(function*(){yield this.executeStep("checkMerkleRoot",(()=>function(e,t){if(e!==t)throw new ft("checkMerkleRoot",lt("errors","ensureMerkleRootEqual"));return!0}(this.proofValue.merkleRoot,this.txData.remoteHash)),this.type)}))}compareHashes(){return vo(this,void 0,void 0,(function*(){yield this.executeStep("compareHashes",(()=>function(e,t){if(e!==t)throw new ft("compareHashes",lt("errors","ensureHashesEqual"));return!0}(this.localDocumentHash,this.proofValue.targetHash)),this.type)}))}computeLocalHash(){return vo(this,void 0,void 0,(function*(){this.localDocumentHash=yield this.executeStep("computeLocalHash",(()=>vo(this,void 0,void 0,(function*(){return yield bt(this.document,this.proof,this.documentLoader)}))),this.type)}))}checkReceipt(){return vo(this,void 0,void 0,(function*(){yield this.executeStep("checkReceipt",(()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const r=e.path;if(r&&t)for(const e in r){const n=r[e];let i;if(void 0!==n.left)i=ct(`${n.left}${t}`),t=I(i);else{if(void 0===n.right)throw new ft("checkReceipt","Trigger catch error.");i=ct(`${t}${n.right}`),t=I(i)}}}catch(e){throw new ft("checkReceipt",lt("errors","ensureValidReceipt"))}if(t!==r)throw new ft("checkReceipt",lt("errors","invalidMerkleReceipt"))}(this.proofValue)}),this.type)}))}getTransactionId(){return vo(this,void 0,void 0,(function*(){this.transactionId=function(e=null){if(!e)throw new Error("DecodedProof is not set");const{anchors:t}=e,r=t[0];if("string"==typeof r)return r.split(":").pop();throw new Error("Could not retrieve transaction id as was provided an unexpected format")}(this.proofValue);return yield this.executeStep("getTransactionId",(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new ft("getTransactionId",lt("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}))}fetchRemoteHash(){return vo(this,void 0,void 0,(function*(){this.txData=yield this.executeStep("fetchRemoteHash",(()=>vo(this,void 0,void 0,(function*(){var e;return yield a({transactionId:this.transactionId,chain:null===(e=this.chain)||void 0===e?void 0:e.code,explorerAPIs:this.explorerAPIs})}))),this.type)}))}deriveIssuingAddressFromPublicKey(){return vo(this,void 0,void 0,(function*(){this.derivedIssuingAddress=yield this.executeStep("deriveIssuingAddressFromPublicKey",(()=>vo(this,void 0,void 0,(function*(){return yield Eo(this.verificationMethod,this.chain)}))),this.type)}))}compareIssuingAddress(){return vo(this,void 0,void 0,(function*(){yield this.executeStep("compareIssuingAddress",(()=>{!function(e,t){const r=lt("errors","identityErrorBaseMessage");if(e.toLowerCase()!==t.toLowerCase())throw new ft("compareIssuingAddress",`${r} - ${lt("errors","compareIssuingAddress")}`)}(this.getIssuerPublicKey(),this.derivedIssuingAddress)}),this.type)}))}}var To;function ko(e){return Io.decodeMerkleProof2019(e)}!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkImagesIntegrity="checkImagesIntegrity",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.deriveIssuingAddressFromPublicKey="deriveIssuingAddressFromPublicKey",e.compareIssuingAddress="compareIssuingAddress",e.checkAuthenticity="checkAuthenticity"}(To||(To={}));class Ao extends O{proofVerificationProcess=[To.parseIssuerKeys,To.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;verificationMethodPublicKey;derivedIssuingAddress;hasDid;proof;type="MerkleProof2019";cryptosuite="merkle-proof-2019";suite;constructor(e){super(e),this.executeStep=e.executeStep,this.documentToVerify=e.document,this.explorerAPIs=e.explorerAPIs,this.proof=e.proof,this.issuer=e.issuer,this.validateProofType(),this.receipt=ko(this.proof),this.transactionId=t.certificates.getTransactionId(this.receipt),this.setHasDid()}async init(){await this.setVerificationSuite(),this.chain=this.suite.getChain(),this.adaptVerificationProcessToChain()}async verifyProof(){await this.suite.verifyProof({verifyIdentity:!1}),await this.verifyProcess(this.proofVerificationProcess)}async verifyIdentity(){await this.suite.verifyIdentity()}getProofVerificationSteps(e){return[...this.suite.getProofVerificationProcess(),...this.proofVerificationProcess].map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map((r=>t.verifier.convertToVerificationSubsteps(e,r))):[]}getIssuerPublicKey(){return this.suite.getIssuerPublicKey()}getIssuanceTime(){return this.suite.getIssuanceTime()}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.proof.created}getChain(){return this.suite.getChain()}getReceipt(){return this.receipt}getTransactionIdString(){return t.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}async executeStep(e,t,r){throw new Error("executeStep method needs to be overwritten by injecting from Verifier")}async setVerificationSuite(){await this.setIssuerFromProofVerificationMethod(),this.verificationMethodPublicKey=P(this.getTargetVerificationMethodContainer(),r(this.proof)),this.suite=new Io({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethodPublicKey,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}})}adaptVerificationProcessToChain(){t.chains.isMockChain(this.chain)&&(n(this.proofVerificationProcess,To.parseIssuerKeys),n(this.proofVerificationProcess,To.checkAuthenticity))}getTargetVerificationMethodContainer(){return this.issuer.didDocument??this.issuer}isProofChain(){return"ChainedProof2021"===this.proof.type}isMultipleProof(){return Array.isArray(this.documentToVerify.proof)}getProofIndex(){return this.isMultipleProof()?this.documentToVerify.proof.findIndex((e=>e.proofValue===this.proof.proofValue)):-1}async setIssuerFromProofVerificationMethod(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.issuer=await t.verifier.getIssuerProfile(e)}}setHasDid(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.hasDid=i(e)}else this.hasDid=!!this.issuer.didDocument}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}async verifyProcess(e){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(To.parseIssuerKeys,(()=>t.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(To.checkAuthenticity,(()=>{A(this.issuerPublicKeyList,this.getIssuerPublicKey(),this.getIssuanceTime())}),this.type)}}export{Ao as default,ko as parseReceipt};
|