@blockcerts/blockcerts-verifier 1.70.0 → 1.70.1
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/__mocks__/@polymer/lit-element.ts +1 -1
- package/bundle-stats.html +1 -1
- package/dist/EcdsaSd2023-BDSl7Ei2-BKyD2rP9.js +35 -0
- package/dist/EcdsaSecp256k1Signature2019-Bk8_LQ8c-BqdRm-Jv.js +1 -0
- package/dist/Ed25519Signature2020-fyWut63D-R9eZ2oN0.js +58 -0
- package/dist/HashlinkVerifier-mEn5oMxx-0x0OtiE4.js +8 -0
- package/dist/{MerkleProof2017-DqA3Y12J-D6qS7nCf.js → MerkleProof2017-Cgbk--lC-CKvOfXrT.js} +1 -1
- package/dist/{MerkleProof2017-MZJbBTpc-CeZmtqCh.js → MerkleProof2017-MZJbBTpc-Cwfnte6F.js} +6 -6
- package/dist/MerkleProof2019-Dhsn349H-DFyc-5gT.js +3 -0
- package/dist/checkCredentialSchemaConformity-CuuMYTl6-DqE6I7JD.js +1 -0
- package/dist/{checkRevocationStatusList2021-CPFaTtUR-XCu3zkCJ.js → checkRevocationStatusList2021-UjTyRcl_-BEBD8TO8.js} +1 -1
- package/dist/{controlVerificationMethod-qY02GU_H-B-4U8WJQ.js → controlVerificationMethod-C87jwGUr-CpVyq-8H.js} +1 -1
- package/dist/{did-key-common.esm-nDfdwcKN-BTWid9-w.js → did-key-common.esm-D1RQn0yL-kJBnihy7.js} +3 -3
- package/dist/{did-key-ed25519.esm-DNra0jwE-CTwAEzy6.js → did-key-ed25519.esm-0v03exJh-COIOTeQ5.js} +1 -1
- package/dist/did-key-secp256k1.esm-Cs0ZCHjg-B35GrJww.js +1 -0
- package/dist/{downloadPDF-DQVfeIBI.js → downloadPDF-CWa3ZYVl.js} +19 -19
- package/dist/elliptic-CRAl7yyq-DbLzV4aB.js +1 -0
- package/dist/elliptic-HXNc7riQ-DrFZxkx3.js +1 -0
- package/dist/{ensureNotRevoked-gui-UMnE-DnVNmhNy.js → ensureNotRevoked-gui-UMnE-o08xNOvL.js} +1 -1
- package/dist/{ensureValidIssuingKey-Cz0isOdi-wu9SdYxL.js → ensureValidIssuingKey-n3jD_OlE-BdV46XBb.js} +1 -1
- package/dist/{index-Bi-O7G4n-Bgz40JYf.js → index-BJkS6Wwm-C8oVP6LM.js} +7 -7
- package/dist/index-CEj3k9G6.js +2 -0
- package/dist/index-DZLKRa_V-D_IQzjvG.js +5 -0
- package/dist/index.es-kH7iskh8.js +56 -0
- package/dist/{jsonld-CQCA9cVk-CQeQQNYP.js → jsonld-CMQE_cGn-899pOqB6.js} +3 -3
- package/dist/{index-BM3knvQR-D4vxi3Vi.js → jsonld-signatures-ZtLxJmqT-B0W14Jb0.js} +16 -20
- package/dist/main.js +125 -125
- package/dist/pako.esm-BGRKTPxS-UdHShO7y.js +2 -0
- package/dist/purify.es-CkKsfeyH.js +2 -0
- package/dist/{retrieveVerificationMethodPublicKey-6-rH9LB2-DvFOhdlW.js → retrieveVerificationMethodPublicKey-nmb3CCVx-DA6ovQri.js} +1 -1
- package/dist/verifyIssuerProfile-CYqfuwV1-DeQqsjiM.js +1 -0
- package/dist/webcrypto.es-hNUMWa8--BnVhHKeM.js +40 -0
- package/eslint.config.mjs +21 -0
- package/package.json +34 -45
- package/vitest.config.ts +11 -0
- package/web-test-runner.config.mjs +7 -0
- package/.eslintrc.js +0 -29
- package/dist/EcdsaSd2023-DcsELLJj-DreWzXlX.js +0 -36
- package/dist/EcdsaSecp256k1Signature2019-Cy1mIkjt-DJmj4ZAc.js +0 -1
- package/dist/Ed25519Signature2020-B-CFC9WC-DJkVVmwk.js +0 -52
- package/dist/HashlinkVerifier-hQgVXluZ-dg5WNZnc.js +0 -11
- package/dist/MerkleProof2019-B4HSvmJo-Cwc-hu-Y.js +0 -3
- package/dist/checkCredentialSchemaConformity-ChaCRIqw-7U54o8BA.js +0 -1
- package/dist/did-key-secp256k1.esm-Dv1NXpDw-_M-qRy-N.js +0 -1
- package/dist/elliptic-D-ZnlFdt-DQmYEk-8.js +0 -1
- package/dist/index-ButIU7pZ-Djl5IfSw.js +0 -1
- package/dist/index-C-APorIs.js +0 -2
- package/dist/index.es-BqQdvz5C.js +0 -56
- package/dist/pako.esm-DnD5dZGi-Bw1vqMku.js +0 -2
- package/dist/purify.es-DJj7iNgQ.js +0 -2
- package/dist/verifyIssuerProfile-DnjbDuXe-BVFzyjSL.js +0 -1
- package/dist/webcrypto.es-BxABHF-B-TCzLuarM.js +0 -40
- package/karma.conf.js +0 -27
- /package/dist/{Suite-B7Vy9AuU-D1ucdMDB.js → Suite-BmP2Qu19-D1ucdMDB.js} +0 -0
- /package/dist/{ensureNotRevoked-D9FFjDJd-DvMIgM4L.js → ensureNotRevoked-CdrYFvh7-DvMIgM4L.js} +0 -0
- /package/dist/{index-ZJb8DPW9-Dgus2xdV.js → index-BcfLkJHS-Dgus2xdV.js} +0 -0
- /package/dist/{index-0q2-1l6i-C0eXpZGn.js → index-DYND9Svl-C0eXpZGn.js} +0 -0
- /package/dist/{sha256-BIUNvBZY-C1PUWFZm.js → sha256-CN3v2fAD-C1PUWFZm.js} +0 -0
- /package/dist/{x25519-CEFq6uo8-NSl6svWQ.js → x25519-CbZcE2Ac-NSl6svWQ.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{d as e,h as t,r,j as n,l as i,k as o,S as s,f as a,B as u,m as c,p as f,i as h,n as p}from"./main.js";import{r as l}from"./index-DYND9Svl-C0eXpZGn.js";import{k as d,s as y,r as g,a as w,b as m}from"./elliptic-CRAl7yyq-DbLzV4aB.js";import{a as b}from"./elliptic-HXNc7riQ-DrFZxkx3.js";import{j as E}from"./jsonld-signatures-ZtLxJmqT-B0W14Jb0.js";import{j as _,r as v}from"./jsonld-CMQE_cGn-899pOqB6.js";import{s as S}from"./sha256-CN3v2fAD-C1PUWFZm.js";import{t as I,e as T}from"./index-BJkS6Wwm-C8oVP6LM.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import{e as P}from"./ensureValidIssuingKey-n3jD_OlE-BdV46XBb.js";import"./index-BcfLkJHS-Dgus2xdV.js";import{r as k}from"./retrieveVerificationMethodPublicKey-nmb3CCVx-DA6ovQri.js";import{S as A}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./index-DZLKRa_V-D_IQzjvG.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";var O,N,x,U,B,M,R={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 L(){if(U)return x;U=1;const e=function(){if(N)return O;N=1;const e=R,{validator:t}=l(),r=t(e);return O=r}();return x={validate:e}}function C(){if(M)return B;M=1;return B={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 H,D={},V={exports:{}},F=V.exports;function j(){return H||(H=1,e=V,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,P,k,A,O,N=G.prototype={constructor:G,toString:null,valueOf:null},x=new G(1),U=20,B=4,M=-7,R=21,L=-1e7,C=1e7,H=!1,D=1,V=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},j="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,j.length,"Base"),10==t&&K)return $(y=new G(e),U+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=j.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<=M||s>=R)?b(u,s):E(u,s,"0");else if(o=(e=$(new G(e),t,r)).e,a=(u=y(e.c)).length,1==n||2==n&&(t<=o||o<=M)){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 q(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 X(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 $(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 z(e){var t,r=e.e;return null===r?e.toString():(t=y(e.c),t=r<=M||r>=R?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),U=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],-1e9,0,t),w(r[1],0,l,t),M=r[0],R=r[1]):(w(r,-1e9,l,t),M=-(R=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)w(r[0],-1e9,-1,t),w(r[1],1,l,t),L=r[0],C=r[1];else{if(w(r,-1e9,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),V=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(s+t+" not an object: "+r);F=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),j=r}}return{DECIMAL_PLACES:U,ROUNDING_MODE:B,EXPONENTIAL_AT:[M,R],RANGE:[L,C],CRYPTO:H,MODULO_MODE:D,POW_PRECISION:V,FORMAT:F,ALPHABET:j}},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>=-1e9&&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 q(arguments,-1)},G.minimum=G.min=function(){return q(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(x);if(null==e?e=U: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=U,b=B;for(w>=0&&(h=V,V=0,n=n.replace(".",""),l=(g=new G(i)).pow(n.length-w),V=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=j,e):(u=e,j))).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,P,k,A,O=n.s==i.s?1:-1,N=n.c,x=i.c;if(!(N&&N[0]&&x&&x[0]))return new G(n.s&&i.s&&(N?!x||N[0]!=x[0]:x)?N&&0==N[0]||!x?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;x[l]==(N[l]||0);l++);if(x[l]>(N[l]||0)&&p--,O<0)E.push(1),y=!0;else{for(T=N.length,k=x.length,l=0,O+=2,(g=o(f/(x[0]+1)))>1&&(x=e(x,g,f),N=e(N,g,f),k=x.length,T=N.length),I=k,v=(_=N.slice(0,k)).length;v<k;_[v++]=0);A=x.slice(),A=[0].concat(A),P=x[0],x[1]>=f/2&&P++;do{if(g=0,(h=t(x,_,k,v))<0){if(S=_[0],k!=v&&(S=S*f+(_[1]||0)),(g=o(S/P))>1)for(g>=f&&(g=f-1),m=(w=e(x,g,f)).length,v=_.length;1==t(w,_,m,v);)g--,r(w,k<m?A:x,m,f),m=w.length,h=1;else 0==g&&(h=g=1),m=(w=x.slice()).length;if(m<v&&(w=[0].concat(w)),r(_,w,v,f),v=_.length,-1==h)for(;t(x,_,k,v)<1;)g++,r(_,k<v?A:x,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++);$(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,P=/^([^.]+)\.$/,k=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,t,r,n){var i,o=r?t:t.replace(O,"");if(A.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(P,"$1").replace(k,"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),$(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),U,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: "+z(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(+z(d),f?e.s*(2-m(e)):+z(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);V&&(u=i(V/c+2))}for(f?(r=new G(.5),h&&(e.s=1),p=m(e)):p=(a=Math.abs(+z(e)))%2,l=new G(x);;){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($(e=e.times(r),e.e+1,1),e.e>14)p=m(e);else{if(0==(a=+z(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=x.div(l)),t?l.mod(t):u?$(l,V,B,void 0):l)},N.integerValue=function(e){var t=new G(this);return null==e?e=B:w(e,0,8),$(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]?X(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),X(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),X(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),$(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=U+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(+z(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))||($(n,n.e+U+2,1),e=!n.times(n).eq(s));break}if(!i&&($(o,o.e+U+2,0),o.times(o).eq(s))){n=o;break}f+=4,u+=4,i=1}return $(n,n.e+U+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=F;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(x)))throw Error(s+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+z(f));if(!b)return new G(m);for(t=new G(x),l=n=new G(x),i=p=new G(x),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+z(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<=M||i>=R?b(y(r.c),i):E(y(r.c),i,"0"):10===e&&K?t=E(y((r=$(new G(r),U+i+1,B)).c),r.e,"0"):(w(e,2,j.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 z(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)}(F)),V.exports;var e}var K,G,W,q,X,$,z,Y,J,Q,Z,ee,te,re,ne,ie,oe,se,ae,ue,ce,fe={},he={};function pe(){return K||(K=1,function(e){const t=j().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)}}(he)),he}function le(){return G||(G=1,function(e){const t=w,r=j().BigNumber,n=pe(),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")}}(fe)),fe}function de(){if(q)return W;q=1;const e=w,t=pe(),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 W=o}function ye(){if($)return X;$=1;const e=g,t=w;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)}),X=r}function ge(){if(Q)return J;Q=1;const e=j().BigNumber,t=le(),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 J=o}function we(){if(ee)return Z;ee=1;const e=g,t=function(){if(Y)return z;Y=1;const e=g,t=ye(),r=e.Transform;return z=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=ge(),n=de(),i=le(),o=j().BigNumber,s=ye(),a=pe(),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"),w=Symbol("error"),m=Symbol("not found");function b(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 m: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=m;const c=new Promise(((e,t)=>{a.on("data",(e=>{u=S.nullcheck(e),a.close()})),a.once("error",(e=>(u!==m&&(e.value=u),u=w,a.close(),t(e)))),a.once("end",(()=>{switch(u){case m:return o?t(new Error("No CBOR found")):e(u);case w: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,m=null!=e?e[y]:void 0,_=null!=e?e.length:void 0;switch(w){case f.ONE:this.emit("more-bytes",g,1,m,_),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,m,_);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,m,_),a=g===c.BYTE_STRING?u.allocUnsafe(0):"";break;case-1:this.emit("start",g,h.STREAM,m,_),e=E(e,g),t++;continue;default:this.emit("start-string",g,a,m,_),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,m,_),e=b(e,g,-1),t++;continue;default:this.emit("start",g,a,m,_),e=b(e,g,a*(g-3)),t++;continue}break;case c.TAG:this.emit("start",g,a,m,_),e=b(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,m,_,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=m,Z=S}function me(){if(se)return oe;se=1;const e=g,t=p;j().BigNumber;const r=ye();ge(),de();const n=le(),i=pe(),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,w=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.TRUE,m=i.MT.SIMPLE_FLOAT<<5|i.SIMPLE.FALSE,b=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"),P=u.from("f97c00","hex"),k=u.from("f98000","hex"),A=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:P;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(k):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?w:m)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(b);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[A];if(!r)return!1;if(null==t)t=r;else if(t!==r)return!1;if(delete e[A],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[A]===this.detectLoops)throw new Error("Loop detected while CBOR encoding");e[A]=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 oe=O}function be(){return ce||(ce=1,(e=D).BigNumber=j().BigNumber,e.Commented=function(){if(re)return te;re=1;const e=g,t=w;le(),de();const r=we(),n=pe(),i=j().BigNumber,o=ye(),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 te=f}(),e.Diagnose=function(){if(ie)return ne;ie=1;const e=g,t=w,r=we();de();const n=le(),i=pe(),o=j().BigNumber,s=ye(),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 ne=c}(),e.Decoder=we(),e.Encoder=me(),e.Simple=de(),e.Tagged=ge(),e.Map=function(){if(ue)return ae;ue=1;const e=me(),t=we(),r=pe().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 ae=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=le().hasBigInt),D;var e}var Ee,_e,ve,Se,Ie,Te,Pe,ke,Ae,Oe,Ne,xe,Ue,Be,Me,Re,Le,Ce,He,De={exports:{}};function Ve(){if(Te)return Ie;Te=1;const{Buffer:e}=b;return Ie=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 Fe(){if(ke)return Pe;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 ke=1,Pe=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 je(){if(Oe)return Ae;Oe=1;const{Buffer:e}=b;return Ae=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 Ke(){if(xe)return Ne;xe=1;const e=_e?Ee:(_e=1,Ee=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(Se)return ve;Se=1;var e=m().Buffer;return ve=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);n<t.length;){var h=t.charCodeAt(n);if(h>255)return;var p=r[h];if(255===p)return;for(var l=0,d=s-1;(0!==p||l<o)&&-1!==d;d--,l++)p+=a*f[d]>>>0,f[d]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");o=l,n++}for(var y=s-o;y!==s&&0===f[y];)y++;var g=e.allocUnsafe(i+(s-y));g.fill(0,0,i);for(var w=i;y!==s;)g[w++]=f[y++];return g}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")}}},ve}(),r=Ve(),n=Fe(),i=je(),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 Ne={names:s,codes:a}}function Ge(){return Ue||(Ue=1,function(e,t){const{Buffer:r}=b,n=Ke();(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}}(De,De.exports)),De.exports}function We(){if(Me)return Be;Me=1;var e=9007199254740991,t="[object Arguments]",r="[object Function]",n="[object GeneratorFunction]",i="object"==typeof c&&c&&c.Object===Object&&c,o="object"==typeof self&&self&&self.Object===Object&&self,s=i||o||Function("return this")();function a(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var u=Object.prototype,f=u.hasOwnProperty,h=u.toString,p=s.Symbol,l=u.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 Be=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 u=e[o];r(u)?a(i,u):i[i.length]=u}return i}(e):[]}}function qe(){if(He)return Ce;He=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 Ce=v}var Xe,$e,ze,Ye,Je,Qe={exports:{}};function Ze(){return Xe||(Xe=1,function(e,t){var r="__lodash_hash_undefined__",n=9007199254740991,i="[object Arguments]",o="[object Array]",s="[object Boolean]",a="[object Date]",u="[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,P=/\\(\\)?/g,k=/^\[object .+?Constructor\]$/,A=/^(?: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[s]=O[_]=O[a]=O[u]=O[f]=O[h]=O[p]=O[l]=O[y]=O[g]=O[w]=O[b]=!1;var N="object"==typeof c&&c&&c.Object===Object&&c,x="object"==typeof self&&self&&self.Object===Object&&self,U=N||x||Function("return this")(),B=t&&!t.nodeType&&t,M=B&&e&&!e.nodeType&&e,R=M&&M.exports===B&&N.process,L=function(){try{return R&&R.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 V(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function F(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var j,K,G,W=Array.prototype,q=Function.prototype,X=Object.prototype,$=U["__core-js_shared__"],z=(j=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",Y=q.toString,J=X.hasOwnProperty,Q=X.toString,Z=RegExp("^"+Y.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=U.Symbol,te=U.Uint8Array,re=X.propertyIsEnumerable,ne=W.splice,ie=(K=Object.keys,G=Object,function(e){return K(G(e))}),oe=Le(U,"DataView"),se=Le(U,"Map"),ae=Le(U,"Promise"),ue=Le(U,"Set"),ce=Le(U,"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=$e(e)||Xe(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(qe(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 Re(this,e).delete(e)},_e.prototype.get=function(e){return Re(this,e).get(e)},_e.prototype.has=function(e){return Re(this,e).has(e)},_e.prototype.set=function(e,t){return Re(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 Pe=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 ke(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 Ae(e,t){return null!=e&&t in Object(e)}function Oe(e,t,r,n){return function(e,t){e&&Pe(e,t,ot)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Ne(e,t,r,n,c){return e===t||(null==e||null==t||!Qe(e)&&!Ze(t)?e!=e&&t!=t:function(e,t,r,n,c,f){var d=$e(e),b=$e(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),P=v==S;if(P&&!I)return f||(f=new Se),d||tt(e)?Me(e,t,r,n,c,f):function(e,t,r,n,i,o,c){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 s:case a:case p:return qe(+e,+t);case u:return e.name==t.name&&e.message==t.message;case y:case w:return e==t+"";case h:var f=V;case g:var l=2&o;if(f||(f=F),e.size!=t.size&&!l)return!1;var d=c.get(e);if(d)return d==t;o|=1,c.set(e,t);var b=Me(f(e),f(t),n,i,o,c);return c.delete(e),b;case m:if(we)return we.call(e)==we.call(t)}return!1}(e,t,v,r,n,c,f);if(!(2&c)){var k=I&&J.call(e,"__wrapped__"),A=T&&J.call(t,"__wrapped__");if(k||A){var O=k?e.value():e,N=A?t.value():t;return f||(f=new Se),r(O,N,n,c,f)}}if(!P)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,c,f)}(e,t,Ne,r,n,c))}function xe(e){return!(!Qe(e)||function(e){return!!z&&z in e}(e))&&(Ye(e)||D(e)?Z:k).test(Ge(e))}function Ue(e){if(r=(t=e)&&t.constructor,n="function"==typeof r&&r.prototype||X,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 $e(e)?e:je(e)}function Me(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 Re(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 xe(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||A.test(e))&&e>-1&&e%1==0&&e<t}function De(e,t){if($e(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 Ve(e){return e==e&&!Qe(e)}function Fe(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 je=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(P,"$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 qe(e,t){return e===t||e!=e&&t!=t}function Xe(e){return function(e){return Ze(e)&&ze(e)}(e)&&J.call(e,"callee")&&(!re.call(e,"callee")||Q.call(e)==i)}We.Cache=_e;var $e=Array.isArray;function ze(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?$e(e)?function(e,t){return De(e)&&Ve(t)?Fe(Ke(e),t):function(r){var n=function(e,t,r){var n=null==e?void 0:ke(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)&&($e(e)||Xe(e))}(e,t,Ae)}(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,Ve(i)]}return t}(t=e),1==r.length&&r[0][2]?Fe(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 ke(t,e)}}(n);var t,r,n,i},function(e,t){return Oe(e,rt,nt(t),{})});function ot(e){return ze(e)?Ie(e):Ue(e)}function st(e){return e}e.exports=it}(Qe,Qe.exports)),Qe.exports}var et=function(){if(Je)return Ye;Je=1;const e=function(){if(Le)return Re;Le=1;const{validate:e}=L(),t=C(),r=be(),n=Ge(),i=We();return Re=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)}},Re}(),t=function(){if(ze)return $e;ze=1;const e=C(),t=be(),r=Ge(),n=qe(),i=Ze();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=C();return Ye={Encoder:e,Decoder:t,Keymap:r}}();function tt(e){return Object.keys(o).map((e=>o[e])).find((t=>t.signatureValue===e))}function rt(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 o.mocknet.blinkCode:return tt(o.mocknet.signatureValue);case o.bitcoin.blinkCode:r=o.bitcoin.name;break;case o.ethmain.blinkCode:r=o.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}const n=t[2];return tt(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 nt(e,t){const r=e.findIndex((e=>e===t));r>-1&&e.splice(r,1)}class it extends Error{constructor(e,t){super(t),this.stepCode=e}}var ot="en-US",st={"en-US":{errors:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Objectif de la signature invalide. Attendu: ${expectedProofPurpose} mais la signature a un objectif de ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"La méthode de vérification ${proof.verificationMethod} n'est pas autorisée pour l'objectif de verification: ${expectedProofPurpose}",assertProofValidityDomainVerifier:"La signature n'est pas autorisée pour ce domaine",assertProofValidityInvalidChallenge:"Le challenge de la signature ne correspond pas au challenge de vérification",assertProofValidityNoProofPurpose:"La propriété `proofPurpose` est manquante dans la signature",assertProofValidityNoCreated:"La propriété `created` est manquante dans la signature",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:{assertProofValidityPurposeVerifier:"Objectivo de verificación invalido. Se esperaba ${expectedProofPurpose} pero recibió ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"El método de verificación ${proof.verificationMethod} no está permitido para el objectivo de verificación ${expectedProofPurpose}",assertProofValidityDomainVerifier:"La prueba no está autorizada para este dominio",assertProofValidityInvalidChallenge:"El reto de la prueba no coincide con el reto de verificación",assertProofValidityNoProofPurpose:"Falta propiedad `proofPurpose` en la prueba",assertProofValidityNoCreated:"Falta propiedad `created` en la prueba",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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 at(e,t){return t?st[ot]?st[ot][e]?st[ot][e][t]?st[ot][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}function ut({expectedProofPurpose:e,expectedDomain:t,expectedChallenge:r,proof:n,issuer:i}){if(!n.proofPurpose)throw new it("assertProofValidity",at("errors","assertProofValidityNoProofPurpose"));if(!n.created)throw new it("assertProofValidity",at("errors","assertProofValidityNoCreated"));return n.proofPurpose&&function({expectedProofPurpose:e,proof:t,issuer:r}){var n;if(t.proofPurpose!==e)throw new it("assertProofValidity",at("errors","assertProofValidityPurposeVerifier").replace("${expectedProofPurpose}",e).replace("${proof.proofPurpose}",t.proofPurpose));if(r&&!(null===(n=r[e])||void 0===n?void 0:n.includes(t.verificationMethod)))throw new it("assertProofValidity",at("errors","assertProofValidityPurposeIssuerKey").replace("${proof.verificationMethod}",t.verificationMethod).replace("${expectedProofPurpose}",e));"authentication"!==e||t.domain||console.warn("No domain found in proof, but it is recommended for authentication purposes")}({expectedProofPurpose:e,proof:n,issuer:i}),n.domain&&function({expectedDomain:e,proof:t,expectedChallenge:r}){if(!e.includes(t.domain))throw new it("assertProofValidity",at("errors","assertProofValidityDomainVerifier").replace("${expectedDomain}",e.join(", ")).replace("${proof.domain}",t.domain));if(t.domain&&!t.challenge&&console.warn("No challenge found in proof, but it is recommended for domain verification"),t.challenge&&t.challenge!==r)throw new it("assertProofValidity",at("errors","assertProofValidityInvalidChallenge"))}({expectedDomain:t,proof:n,expectedChallenge:r}),!0}var ct={"@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"}]},ft={"@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"}}},ht={"@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"}}},pt={"@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 lt(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}a["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=ct,a["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=ct,a["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=ft,a["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=ft,a["https://w3id.org/blockcerts/v3.0-alpha"]=ft,a["https://www.blockcerts.org/schema/3.0-beta/context.json"]=ht,a["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=ht,a["https://w3id.org/blockcerts/v3.0-beta"]=ht,a["https://w3id.org/security/suites/ed25519-2020/v1"]=pt;var dt=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 yt(e){return dt(this,arguments,void 0,(function*(e,t=null,r=e=>dt(this,void 0,void 0,(function*(){return Promise}))){e["@context"].find((e=>{return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"});const n=JSON.parse(JSON.stringify(e));if(Array.isArray(n.proof)){if(!t)throw new it("computeLocalHash",at("errors","noProofSpecified"));const e=n.proof.findIndex((e=>e.proofValue===t.proofValue));n.proof=n.proof.slice(0,e)}else delete n.proof;const i={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return dt(this,void 0,void 0,(function*(){return null!=r&&(yield r(e)),e in a?{contextUrl:null,document:a[e],documentUrl:e}:_.documentLoader(e)}))},safe:!1};let o;try{o=yield _.normalize(n,i)}catch(e){throw console.error(e),new it("computeLocalHash",at("errors","failedJsonLdNormalization"))}const s=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}(o);if(s)throw new it("computeLocalHash",`${at("errors","foundUnmappedFields")}: ${s.join(", ")}`);return S(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}(o))}))}v();var gt=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 wt=u,mt=e=>{const t=(e=>{const t=d.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),r=y.publicKeyConvert(wt.from(t,"hex"),!0);return wt.from(r).toString("hex")})(e);let r=wt.from(t,"hex"),n=32-r.length;for(;n>0;)r=wt.concat([wt.from("00","hex"),r]),n--;return r};var bt,Et={},_t={},vt={};function St(){return bt||(bt=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.testnet=vt.regtest=vt.bitcoin=void 0,vt.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},vt.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},vt.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}),vt}var It,Tt={},Pt={},kt={},At={};function Ot(){if(It)return At;return It=1,Object.defineProperty(At,"__esModule",{value:!0}),At.encode=At.decode=At.check=void 0,At.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]))))))},At.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)}},At.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},At}var Nt,xt={};function Ut(){if(Nt)return xt;Nt=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.REVERSE_OPS=xt.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};xt.OPS=e;const t={};xt.REVERSE_OPS=t;for(const r of Object.keys(e)){t[e[r]]=r}return xt}var Bt,Mt={};var Rt,Lt={};var Ct,Ht,Dt,Vt,Ft,jt,Kt,Gt,Wt,qt,Xt,$t={},zt={};function Yt(){if(Ht)return Ct;Ht=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 Ct=e}function Jt(){if(Vt)return Dt;Vt=1;var e=Yt();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,Dt={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 Qt(){if(Gt)return Kt;Gt=1;var e=Jt(),t=Yt(),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(jt)return Ft;jt=1;var e=Yt(),t=Jt();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 Ft=f}();for(f in p)c[f]=p[f];return c.compile=u,c.TfTypeError=n,c.TfPropertyTypeError=i,Kt=c}function Zt(){return Wt||(Wt=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.Satoshi=e.isPoint=e.stacksEqual=e.typeforce=void 0;const t=b;e.typeforce=Qt();const r=t.Buffer.alloc(32,0),n=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.stacksEqual=function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))},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))};function i(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.TAPLEAF_VERSION_MASK=254,e.isTapleaf=i,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):i(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 er(){return Xt||(Xt=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=Ot(),r=Ut();Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return r.OPS}});const n=function(){if(Bt)return Mt;Bt=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.decode=Mt.encode=Mt.encodingLength=void 0;const e=Ut();function t(t){return t<e.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}return Mt.encodingLength=t,Mt.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},Mt.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}},Mt}(),i=(Rt||(Rt=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.encode=Lt.decode=void 0,Lt.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},Lt.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}),Lt),o=function(){if(qt)return $t;qt=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.encode=$t.decode=void 0;const e=Ot(),t=er(),r=Zt(),{typeforce:n}=r,i=u.alloc(1,0);function o(e){let t=0;for(;0===e[t];)++t;return t===e.length?i:128&(e=e.slice(t))[0]?u.concat([i,e],1+e.length):e}function s(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 $t.decode=function(r){const n=r.readUInt8(r.length-1);if(!(0,t.isDefinedHashType)(n))throw new Error("Invalid hashType "+n);const i=e.decode(r.slice(0,-1)),o=s(i.r),a=s(i.s);return{signature:u.concat([o,a],64),hashType:n}},$t.encode=function(i,s){if(n({signature:r.BufferN(64),hashType:r.UInt8},{signature:i,hashType:s}),!(0,t.isDefinedHashType)(s))throw new Error("Invalid hashType "+s);const a=u.allocUnsafe(1);a.writeUInt8(s,0);const c=o(i.slice(0,32)),f=o(i.slice(32,64));return u.concat([e.encode(c,f),a])},$t}(),s=Zt(),{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){if(d(e)&&(e=w(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return 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}(kt)),kt}var tr,rr,nr={};function ir(){if(tr)return nr;return tr=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.value=nr.prop=void 0,nr.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})}})},nr.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)},nr}var or,sr={};var ar,ur={};var cr,fr={},hr={},pr={},lr={},dr={};function yr(){if(cr)return dr;function e(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function t(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}return cr=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.anumber=e,dr.abytes=t,dr.ahash=function(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)},dr.aexists=function(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")},dr.aoutput=function(e,r){t(e);const n=r.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)},dr}var gr,wr,mr,br,Er={},_r={};function vr(){return wr||(wr=1,function(e){
|
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
+
Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.isLE=void 0,e.isBytes=function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name},e.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},e.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},e.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},e.rotr=function(e,t){return e<<32-t|e>>>t},e.rotl=function(e,t){return e<<t|e>>>32-t>>>0},e.byteSwap=n,e.byteSwap32=function(e){for(let t=0;t<e.length;t++)e[t]=n(e[t])},e.bytesToHex=function(e){(0,r.abytes)(e);let t="";for(let r=0;r<e.length;r++)t+=i[e[r]];return t},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("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=s(e.charCodeAt(i)),o=s(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},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=a,e.toBytes=u,e.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];(0,r.abytes)(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.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.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(u(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(u(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(u(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));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=(gr||(gr=1,Object.defineProperty(_r,"__esModule",{value:!0}),_r.crypto=void 0,_r.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0),_r),r=yr();function n(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwapIfBE=e.isLE?e=>e:e=>n(e);const i=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));const o={_0:48,_9:57,A:65,F:70,a:97,f:102};function s(e){return e>=o._0&&e<=o._9?e-o._0:e>=o.A&&e<=o.F?e-(o.A-10):e>=o.a&&e<=o.f?e-(o.a-10):void 0}function a(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function u(e){return"string"==typeof e&&(e=a(e)),(0,r.abytes)(e),e}e.nextTick=async()=>{};e.Hash=class{clone(){return this._cloneInto()}}}(Er)),Er}function Sr(){if(mr)return lr;mr=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.HashMD=void 0,lr.setBigUint64=r,lr.Chi=function(e,t,r){return e&t^~e&r},lr.Maj=function(e,t,r){return e&t^e&r^t&r};const e=yr(),t=vr();function r(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)}class n 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.aexists)(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(n){(0,e.aexists)(this),(0,e.aoutput)(n,this),this.finished=!0;const{buffer:i,view:o,blockLen:s,isLE:a}=this;let{pos:u}=this;i[u++]=128,this.buffer.subarray(u).fill(0),this.padOffset>s-u&&(this.process(o,0),u=0);for(let e=u;e<s;e++)i[e]=0;r(o,s-8,BigInt(8*this.length),a),this.process(o,0);const c=(0,t.createView)(n),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,p=this.get();if(h>p.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<h;e++)c.setUint32(4*e,p[e],a)}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 lr.HashMD=n,lr}function Ir(){if(br)return pr;br=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.ripemd160=pr.RIPEMD160=void 0;const e=Sr(),t=vr(),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],P=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,P[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 pr.RIPEMD160=l,pr.ripemd160=(0,t.wrapConstructor)((()=>new l)),pr}var Tr,Pr={};function kr(){if(Tr)return Pr;Tr=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.sha1=Pr.SHA1=void 0;const e=Sr(),t=vr(),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 Pr.SHA1=i,Pr.sha1=(0,t.wrapConstructor)((()=>new i)),Pr}var Ar,Or,Nr,xr,Ur,Br,Mr,Rr,Lr,Cr,Hr,Dr={};function Vr(){if(Ar)return Dr;Ar=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.sha224=Dr.sha256=Dr.SHA256=void 0;const e=Sr(),t=vr(),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)}}Dr.SHA256=o;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 Fr(){return Or||(Or=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=Ir(),r=kr(),n=Vr();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]))}}(hr)),hr}function jr(){if(Br)return Ur;Br=1;const e=(xr||(xr=1,Nr=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,a=e.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function f(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,i=0;e[r]===a;)n++,r++;for(var o=(e.length-r)*u+1>>>0,c=new Uint8Array(o);e[r];){var f=e.charCodeAt(r);if(f>255)return;var h=t[f];if(255===h)return;for(var p=0,l=o-1;(0!==h||p<i)&&-1!==l;l--,p++)h+=s*c[l]>>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,r++}for(var d=o-i;d!==o&&0===c[d];)d++;for(var y=new Uint8Array(n+(o-d)),g=n;d!==o;)y[g++]=c[d++];return y}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*c+1>>>0,f=new Uint8Array(u);i!==o;){for(var h=t[i],p=0,l=u-1;(0!==h||p<n)&&-1!==l;l--,p++)h+=256*f[l]>>>0,f[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=p,i++}for(var d=u-n;d!==u&&0===f[d];)d++;for(var y=a.repeat(r);d<u;++d)y+=e.charAt(f[d]);return y},decodeUnsafe:f,decode:function(e){var t=f(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),Nr);return Ur=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}function Kr(){if(Cr)return Lr;Cr=1;var{sha256:e}=Vr(),t=function(){if(Rr)return Mr;Rr=1;var e=jr();return Mr=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)}}},Mr}();return Lr=t((function(t){return e(e(t))})),Lr}var Gr,Wr={};var qr,Xr,$r={},zr={};function Yr(){if(qr)return zr;qr=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 Jr,Qr={};var Zr,en={},tn={};function rn(){if(Zr)return tn;Zr=1,Object.defineProperty(tn,"__esModule",{value:!0}),tn.getEccLib=tn.initEccLib=void 0;const e={};tn.initEccLib=function(i,o){var s;i?i!==e.eccLib&&(o?.DANGER_DO_NOT_VERIFY_ECCLIB||(r("function"==typeof(s=i).isXOnlyPoint),r(s.isXOnlyPoint(t("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),r(s.isXOnlyPoint(t("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),r(s.isXOnlyPoint(t("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),r(s.isXOnlyPoint(t("0000000000000000000000000000000000000000000000000000000000000001"))),r(!s.isXOnlyPoint(t("0000000000000000000000000000000000000000000000000000000000000000"))),r(!s.isXOnlyPoint(t("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),r("function"==typeof s.xOnlyPointAddTweak),n.forEach((e=>{const n=s.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},tn.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 tn}var nn,on,sn,an,un,cn,fn,hn={},pn={};function ln(){if(sn)return pn;sn=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.BufferReader=pn.BufferWriter=pn.cloneBuffer=pn.reverseBuffer=pn.writeUInt64LE=pn.readUInt64LE=pn.varuint=void 0;const e=Zt(),{typeforce:t}=e,r=function(){if(on)return nn;on=1;var e=m().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 nn={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},nn}();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}pn.varuint=r,pn.readUInt64LE=i,pn.writeUInt64LE=o,pn.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},pn.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}`)}}pn.BufferWriter=s;return pn.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}},pn}function dn(){return an||(an=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=b,r=rn(),n=Fr(),i=ln(),o=Zt();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}}(hn)),hn}function yn(){return cn||(cn=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(rr)return Pt;rr=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.p2data=void 0;const e=St(),t=er(),r=Zt(),n=ir(),i=t.OPS;return Pt.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&&!(0,r.stacksEqual)(o.data,a.data))throw new TypeError("Data mismatch")}return Object.assign(a,o)},Pt}();Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});const r=function(){if(or)return sr;or=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.p2ms=void 0;const e=St(),t=er(),r=Zt(),n=ir(),i=t.OPS,o=i.OP_RESERVED;return sr.p2ms=function(s,a){if(!(s.input||s.output||s.pubkeys&&void 0!==s.m||s.signatures))throw new TypeError("Not enough data");function u(e){return t.isCanonicalScriptSignature(e)||void 0!==(a.allowIncomplete&&e===i.OP_0)}a=Object.assign({validate:!0},a||{}),(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(u)),input:r.typeforce.maybe(r.typeforce.Buffer)},s);const c={network:s.network||e.bitcoin};let f=[],h=!1;function p(e){h||(h=!0,f=t.decompile(e),c.m=f[0]-o,c.n=f[f.length-2]-o,c.pubkeys=f.slice(1,-2))}if(n.prop(c,"output",(()=>{if(s.m&&c.n&&s.pubkeys)return t.compile([].concat(o+s.m,s.pubkeys,o+c.n,i.OP_CHECKMULTISIG))})),n.prop(c,"m",(()=>{if(c.output)return p(c.output),c.m})),n.prop(c,"n",(()=>{if(c.pubkeys)return c.pubkeys.length})),n.prop(c,"pubkeys",(()=>{if(s.output)return p(s.output),c.pubkeys})),n.prop(c,"signatures",(()=>{if(s.input)return t.decompile(s.input).slice(1)})),n.prop(c,"input",(()=>{if(s.signatures)return t.compile([i.OP_0].concat(s.signatures))})),n.prop(c,"witness",(()=>{if(c.input)return[]})),n.prop(c,"name",(()=>{if(c.m&&c.n)return`p2ms(${c.m} of ${c.n})`})),a.validate){if(s.output){if(p(s.output),!r.typeforce.Number(f[0]))throw new TypeError("Output is invalid");if(!r.typeforce.Number(f[f.length-2]))throw new TypeError("Output is invalid");if(f[f.length-1]!==i.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(c.m<=0||c.n>16||c.m>c.n||c.n!==f.length-3)throw new TypeError("Output is invalid");if(!c.pubkeys.every((e=>(0,r.isPoint)(e))))throw new TypeError("Output is invalid");if(void 0!==s.m&&s.m!==c.m)throw new TypeError("m mismatch");if(void 0!==s.n&&s.n!==c.n)throw new TypeError("n mismatch");if(s.pubkeys&&!(0,r.stacksEqual)(s.pubkeys,c.pubkeys))throw new TypeError("Pubkeys mismatch")}if(s.pubkeys){if(void 0!==s.n&&s.n!==s.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(c.n=s.pubkeys.length,c.n<c.m)throw new TypeError("Pubkey count cannot be less than m")}if(s.signatures){if(s.signatures.length<c.m)throw new TypeError("Not enough signatures provided");if(s.signatures.length>c.m)throw new TypeError("Too many signatures provided")}if(s.input){if(s.input[0]!==i.OP_0)throw new TypeError("Input is invalid");if(0===c.signatures.length||!c.signatures.every(u))throw new TypeError("Input has invalid signature(s)");if(s.signatures&&!(0,r.stacksEqual)(s.signatures,c.signatures))throw new TypeError("Signature mismatch");if(void 0!==s.m&&s.m!==s.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(c,s)},sr}();Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return r.p2ms}});const n=function(){if(ar)return ur;ar=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.p2pk=void 0;const e=St(),t=er(),r=Zt(),n=ir(),i=t.OPS;return ur.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)},ur}();Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return n.p2pk}});const i=function(){if(Hr)return fr;Hr=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.p2pkh=void 0;const e=Fr(),t=St(),r=er(),n=Zt(),i=ir(),o=Kr(),s=r.OPS;return fr.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)},fr}();Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return i.p2pkh}});const o=function(){if(Gr)return Wr;Gr=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.p2sh=void 0;const e=Fr(),t=St(),r=er(),n=Zt(),i=ir(),o=Kr(),s=r.OPS;return Wr.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 i=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");i(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")}i(a.redeem)}if(a.witness&&a.redeem&&a.redeem.witness&&!(0,n.stacksEqual)(a.redeem.witness,a.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(p,a)},Wr}();Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});const s=function(){if(Xr)return $r;Xr=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.p2wpkh=void 0;const e=Fr(),t=St(),r=er(),n=Zt(),i=ir(),o=Yr(),s=r.OPS,a=u.alloc(0);return $r.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)},$r}();Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return s.p2wpkh}});const a=function(){if(Jr)return Qr;Jr=1,Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.p2wsh=void 0;const e=Fr(),t=St(),r=er(),n=Zt(),i=ir(),o=Yr(),s=r.OPS,a=u.alloc(0);function c(e){return!(!h(e)||65!==e.length||4!==e[0]||!(0,n.isPoint)(e))}return Qr.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&&!(0,n.stacksEqual)(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)},Qr}();Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const c=function(){if(un)return en;un=1,Object.defineProperty(en,"__esModule",{value:!0}),en.p2tr=void 0;const e=b,t=St(),r=er(),n=Zt(),i=rn(),o=dn(),s=ir(),a=Yr(),u=gn(),c=r.OPS;return en.p2tr=function(f,h){if(!(f.address||f.output||f.pubkey||f.internalPubkey||f.witness&&f.witness.length>1))throw new TypeError("Not enough data");h=Object.assign({validate:!0},h||{}),(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)},f);const p=s.value((()=>(0,u.fromBech32)(f.address))),l=s.value((()=>{if(f.witness&&f.witness.length)return f.witness.length>=2&&80===f.witness[f.witness.length-1][0]?f.witness.slice(0,-1):f.witness.slice()})),d=s.value((()=>f.scriptTree?(0,o.toHashTree)(f.scriptTree):f.hash?{hash:f.hash}:void 0)),y=f.network||t.bitcoin,g={name:"p2tr",network:y};if(s.prop(g,"address",(()=>{if(!g.pubkey)return;const e=a.bech32m.toWords(g.pubkey);return e.unshift(1),a.bech32m.encode(y.bech32,e)})),s.prop(g,"hash",(()=>{const e=d();if(e)return e.hash;const t=l();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(g,"output",(()=>{if(g.pubkey)return r.compile([c.OP_1,g.pubkey])})),s.prop(g,"redeemVersion",(()=>f.redeemVersion?f.redeemVersion:f.redeem&&void 0!==f.redeem.redeemVersion&&null!==f.redeem.redeemVersion?f.redeem.redeemVersion:o.LEAF_VERSION_TAPSCRIPT)),s.prop(g,"redeem",(()=>{const e=l();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(g,"pubkey",(()=>{if(f.pubkey)return f.pubkey;if(f.output)return f.output.slice(2);if(f.address)return p().data;if(g.internalPubkey){const e=(0,o.tweakKey)(g.internalPubkey,g.hash);if(e)return e.x}})),s.prop(g,"internalPubkey",(()=>{if(f.internalPubkey)return f.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),s.prop(g,"signature",(()=>{if(f.signature)return f.signature;const e=l();return e&&1===e.length?e[0]:void 0})),s.prop(g,"witness",(()=>{if(f.witness)return f.witness;const t=d();if(t&&f.redeem&&f.redeem.output&&f.internalPubkey){const r=(0,o.tapleafHash)({output:f.redeem.output,version:g.redeemVersion}),n=(0,o.findScriptPath)(t,r);if(!n)return;const i=(0,o.tweakKey)(f.internalPubkey,t.hash);if(!i)return;const s=e.Buffer.concat([e.Buffer.from([g.redeemVersion|i.parity]),f.internalPubkey].concat(n));return[f.redeem.output,s]}return f.signature?[f.signature]:void 0})),h.validate){let t=e.Buffer.from([]);if(f.address){if(y&&y.bech32!==p().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==p().version)throw new TypeError("Invalid address version");if(32!==p().data.length)throw new TypeError("Invalid address data");t=p().data}if(f.pubkey){if(t.length>0&&!t.equals(f.pubkey))throw new TypeError("Pubkey mismatch");t=f.pubkey}if(f.output){if(34!==f.output.length||f.output[0]!==c.OP_1||32!==f.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(f.output.slice(2)))throw new TypeError("Pubkey mismatch");t=f.output.slice(2)}if(f.internalPubkey){const e=(0,o.tweakKey)(f.internalPubkey,g.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=d();if(f.hash&&s&&!f.hash.equals(s.hash))throw new TypeError("Hash mismatch");if(f.redeem&&f.redeem.output&&s){const e=(0,o.tapleafHash)({output:f.redeem.output,version:g.redeemVersion});if(!(0,o.findScriptPath)(s,e))throw new TypeError("Redeem script not in tree")}const a=l();if(f.redeem&&g.redeem){if(f.redeem.redeemVersion&&f.redeem.redeemVersion!==g.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(f.redeem.output){if(0===r.decompile(f.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(g.redeem.output&&!f.redeem.output.equals(g.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(f.redeem.witness&&g.redeem.witness&&!(0,n.stacksEqual)(f.redeem.witness,g.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(a&&a.length)if(1===a.length){if(f.signature&&!f.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(f.internalPubkey&&!f.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,c=a[a.length-2],h=(0,o.tapleafHash)({output:c,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(g,f)},en}();Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})}(Tt)),Tt}function gn(){if(fn)return _t;fn=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.toOutputScript=_t.fromOutputScript=_t.toBech32=_t.toBase58Check=_t.fromBech32=_t.fromBase58Check=void 0;const e=St(),t=yn(),r=er(),n=Zt(),i=Yr(),o=Kr(),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 _t.fromBase58Check=a,_t.fromBech32=c,_t.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)},_t.toBech32=f,_t.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")},_t.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")},_t}var wn,mn={},bn={};var En,_n,vn={};function Sn(){if(En)return vn;En=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.Transaction=void 0;const e=ln(),t=Fr(),r=er(),n=er(),i=Zt(),{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))}stripWitnesses(){this.ins.forEach((e=>{e.witness=c}))}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 vn.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,vn}function In(){if(_n)return mn;_n=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.Block=void 0;const e=ln(),t=Fr(),r=(wn||(wn=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.fastMerkleRoot=void 0,bn.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]}),bn),n=Sn(),i=Zt(),{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 mn.Block=c,mn}var Tn,Pn={},kn={},An={},On={},Nn={},xn={},Un={};function Bn(){return Tn||(Tn=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 Mn,Rn={};function Ln(){if(Mn)return Rn;Mn=1,Object.defineProperty(Rn,"__esModule",{value:!0});const e=Bn();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 Cn,Hn={};function Dn(){if(Cn)return Hn;Cn=1,Object.defineProperty(Hn,"__esModule",{value:!0});const e=Bn();return Hn.encode=function(t){return{key:u.from([e.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}},Hn}var Vn,Fn={};function jn(){if(Vn)return Fn;Vn=1,Object.defineProperty(Fn,"__esModule",{value:!0});const e=Bn();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 Kn,Gn={};function Wn(){if(Kn)return Gn;Kn=1,Object.defineProperty(Gn,"__esModule",{value:!0});const e=Bn();return Gn.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},Gn.encode=function(t){return{key:u.from([e.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},Gn.expected="Buffer",Gn.check=function(e){return h(e)},Gn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness},Gn}var qn,Xn={};function $n(){if(qn)return Xn;qn=1,Object.defineProperty(Xn,"__esModule",{value:!0});const e=Bn();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,Yn={};function Jn(){if(zn)return Yn;zn=1,Object.defineProperty(Yn,"__esModule",{value:!0});const e=Bn();return Yn.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}},Yn.encode=function(t){const r=u.from([e.InputTypes.PARTIAL_SIG]);return{key:u.concat([r,t.pubkey]),value:t.signature}},Yn.expected="{ pubkey: Buffer; signature: Buffer; }",Yn.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)},Yn.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)},Yn}var Qn,Zn={};function ei(){if(Qn)return Zn;Qn=1,Object.defineProperty(Zn,"__esModule",{value:!0});const e=Bn();return Zn.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")},Zn.encode=function(t){return{key:u.from([e.InputTypes.POR_COMMITMENT]),value:u.from(t,"utf8")}},Zn.expected="string",Zn.check=function(e){return"string"==typeof e},Zn.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment},Zn}var ti,ri={};function ni(){if(ti)return ri;ti=1,Object.defineProperty(ri,"__esModule",{value:!0});const e=Bn();return ri.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)},ri.encode=function(t){const r=u.from([e.InputTypes.SIGHASH_TYPE]),n=u.allocUnsafe(4);return n.writeUInt32LE(t,0),{key:r,value:n}},ri.expected="number",ri.check=function(e){return"number"==typeof e},ri.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType},ri}var ii,oi={};function si(){if(ii)return oi;ii=1,Object.defineProperty(oi,"__esModule",{value:!0});const e=Bn();function t(e){return h(e)&&(64===e.length||65===e.length)}return oi.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},oi.encode=function(t){return{key:u.from([e.InputTypes.TAP_KEY_SIG]),value:t}},oi.expected="Buffer",oi.check=t,oi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig},oi}var ai,ui={};function ci(){if(ai)return ui;ai=1,Object.defineProperty(ui,"__esModule",{value:!0});const e=Bn();return ui.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}},ui.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])}},ui.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",ui.check=function(e){return h(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&h(e.script)},ui.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)},ui}var fi,hi={};function pi(){if(fi)return hi;fi=1,Object.defineProperty(hi,"__esModule",{value:!0});const e=Bn();function t(e){return h(e)&&32===e.length}return hi.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},hi.encode=function(t){return{key:u.from([e.InputTypes.TAP_MERKLE_ROOT]),value:t}},hi.expected="Buffer",hi.check=t,hi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot},hi}var li,di={};function yi(){if(li)return di;li=1,Object.defineProperty(di,"__esModule",{value:!0});const e=Bn();return di.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}},di.encode=function(t){const r=u.from([e.InputTypes.TAP_SCRIPT_SIG]);return{key:u.concat([r,t.pubkey,t.leafHash]),value:t.signature}},di.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",di.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)},di.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)},di}var gi,wi,mi,bi={},Ei={},_i={};function vi(){if(gi)return _i;gi=1,Object.defineProperty(_i,"__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 _i.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},_i.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}},_i.encodingLength=t,_i}function Si(){if(wi)return Ei;wi=1,Object.defineProperty(Ei,"__esModule",{value:!0});const e=vi();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 Ei.range=e=>[...Array(e).keys()],Ei.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},Ei.keyValsToBuffer=function(e){const r=e.map(t);return r.push(u.from([0])),u.concat(r)},Ei.keyValToBuffer=t,Ei.readUInt64LE=function(e,t){const n=e.readUInt32LE(t);let i=e.readUInt32LE(t+4);return i*=4294967296,r(i+n,9007199254740991),i+n},Ei.writeUInt64LE=function(e,t,n){return r(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8},Ei}function Ii(){if(mi)return bi;mi=1,Object.defineProperty(bi,"__esModule",{value:!0});const e=Bn(),t=Si(),r=vi();return bi.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}},bi.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}},bi.expected="{ script: Buffer; value: number; }",bi.check=function(e){return h(e.script)&&"number"==typeof e.value},bi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo},bi}var Ti,Pi={};function ki(){if(Ti)return Pi;Ti=1,Object.defineProperty(Pi,"__esModule",{value:!0});const e=Bn(),t=vi();return Pi.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}},Pi.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)}},Pi.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",Pi.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)))},Pi.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree},Pi}var Ai,Oi={};function Ni(){if(Ai)return Oi;Ai=1,Object.defineProperty(Oi,"__esModule",{value:!0});const e=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];return Oi.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)}}},Oi}var xi,Ui={};function Bi(){if(xi)return Ui;return xi=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 Mi,Ri={};function Li(){if(Mi)return Ri;return Mi=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 Ci,Hi={};function Di(){if(Ci)return Hi;Ci=1,Object.defineProperty(Hi,"__esModule",{value:!0});const e=vi(),t=Ni(),r=e=>32===e.length;return Hi.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}},Hi}var Vi,Fi={};function ji(){if(Vi)return Fi;return Vi=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 Ki,Gi,Wi,qi={};function Xi(){if(Ki)return qi;return Ki=1,Object.defineProperty(qi,"__esModule",{value:!0}),qi.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}}},qi}function $i(){if(Gi)return xn;Gi=1,Object.defineProperty(xn,"__esModule",{value:!0});const e=Bn(),t=Ln(),r=Dn(),n=jn(),i=Wn(),o=$n(),s=Jn(),a=ei(),u=ni(),c=si(),f=ci(),h=pi(),p=yi(),l=Ii(),d=ki(),y=Ni(),g=Bi(),w=Li(),m=Di(),b=ji(),E=Xi(),_={unsignedTx:r,globalXpub:t,checkPubkey:g.makeChecker([])};xn.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};xn.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 xn.outputs=S,xn}var zi,Yi,Ji,Qi={};function Zi(){return Yi||(Yi=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(Wi)return Nn;Wi=1,Object.defineProperty(Nn,"__esModule",{value:!0});const e=$i(),t=Si(),r=vi(),n=Bn();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 Nn.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})},Nn.checkKeyBuffer=i,Nn.psbtFromKeyVals=o,Nn}()),t(function(){if(zi)return Qi;zi=1,Object.defineProperty(Qi,"__esModule",{value:!0});const e=$i(),t=Si();Qi.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 Qi.psbtToKeyVals=i,Qi}())}(On)),On}var eo,to,ro={};function no(){return eo||(eo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=$i();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}}(ro)),ro}function io(){if(to)return kn;to=1,Object.defineProperty(kn,"__esModule",{value:!0});const e=function(){if(Ji)return An;Ji=1,Object.defineProperty(An,"__esModule",{value:!0});const e=Zi();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=Zi(),r=Bn(),n=no();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 oo,so,ao,uo,co={},fo={};function ho(){if(oo)return fo;oo=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.signatureBlocksAction=fo.checkInputForSig=fo.pubkeyInScript=fo.pubkeyPositionInScript=fo.witnessStackToScriptWitness=fo.isP2TR=fo.isP2SHScript=fo.isP2WSHScript=fo.isP2WPKH=fo.isP2PKH=fo.isP2PK=fo.isP2MS=void 0;const e=vi(),t=er(),r=Sn(),n=Fr(),i=yn();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 fo.isP2MS=o(i.p2ms),fo.isP2PK=o(i.p2pk),fo.isP2PKH=o(i.p2pkh),fo.isP2WPKH=o(i.p2wpkh),fo.isP2WSHScript=o(i.p2wsh),fo.isP2SHScript=o(i.p2sh),fo.isP2TR=o(i.p2tr),fo.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},fo.pubkeyPositionInScript=s,fo.pubkeyInScript=function(e,t){return-1!==s(e,t)},fo.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)))},fo.signatureBlocksAction=a,fo}function po(){if(so)return co;so=1,Object.defineProperty(co,"__esModule",{value:!0}),co.checkTaprootInputForSigs=co.tapTreeFromList=co.tapTreeToList=co.tweakInternalPubKey=co.checkTaprootOutputFields=co.checkTaprootInputFields=co.isTaprootOutput=co.isTaprootInput=co.serializeTaprootSignature=co.tapScriptFinalizer=co.toXOnly=void 0;const e=Zt(),t=Sn(),r=ho(),n=dn(),i=yn(),o=ho();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 co.toXOnly=e=>32===e.length?e:e.slice(1,33),co.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}`)}},co.serializeTaprootSignature=function(e,t){const r=t?u.from([t]):u.from([]);return u.concat([e,r])},co.isTaprootInput=s,co.isTaprootOutput=a,co.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)},co.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)},co.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},co.tapTreeToList=function(t){if(!(0,e.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return h(t)},co.tapTreeFromList=c,co.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)))},co}function lo(){if(ao)return Pn;ao=1,Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.Psbt=void 0;const e=io(),t=vi(),r=no(),n=gn(),i=ln(),o=St(),s=yn(),a=dn(),c=er(),f=Sn(),p=po(),l=ho(),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&&q(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 V(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),$(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=F(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(j(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+"-")+X(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=j(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 $(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?U(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))?R(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=>R(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,M(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,M(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 $(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 $(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 $(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}=x(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}=x(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=R(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&&q(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}}Pn.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 P(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 k=P(s.p2sh,"Redeem script"),A=P(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(),V(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=X(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 x(e,t,n,i,o){const s=(0,r.checkForInput)(e,t),{hash:a,sighashType:u,script:c}=U(t,s,i,!1,o);return I(n,c,"sign"),{hash:a,sighashType:u}}function U(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=F(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 predecessor (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 M(e){return 64===e.length?e:e.subarray(0,64)}function R(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,h,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 V(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=F(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 F(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(e,t,r),n[r]}function j(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=F(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,k(t,e,n,r),A(t,n,i,r),q(u)):a?(u=i,A(t,e,i,r),q(u)):o?(u=n,k(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function q(e){if((0,l.isP2WPKH)(e)||(0,l.isP2SHScript)(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function X(e){return(0,l.isP2WPKH)(e)?"witnesspubkeyhash":(0,l.isP2PKH)(e)?"pubkeyhash":(0,l.isP2MS)(e)?"multisig":(0,l.isP2PK)(e)?"pubkey":"nonstandard"}function $(e){return[...Array(e).keys()]}return Pn}var yo,go=(uo||(uo=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=gn();e.address=t;const r=Fr();e.crypto=r;const n=St();e.networks=n;const i=yn();e.payments=i;const o=er();e.script=o;var s=In();Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return s.Block}});var a=lo();Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return a.Psbt}});var u=Ut();Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return u.OPS}});var c=Sn();Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return c.Transaction}});var f=rn();Object.defineProperty(e,"initEccLib",{enumerable:!0,get:function(){return f.initEccLib}})}(Et)),Et),wo={exports:{}};var mo,bo=(yo||(yo=1,mo=wo,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 f&&f.versions&&f.versions.node?r=c:n&&(r=self);for(var i=!r.JS_SHA3_NO_COMMON_JS&&mo.exports,o=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),a=[4,1024,262144,67108864],u=[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},g=r.JS_SHA3_NO_NODE_JS||!Array.isArray?function(e){return"[object Array]"===Object.prototype.toString.call(e)}:Array.isArray,w=!o||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer},m=function(t){var r=typeof t;if("string"===r)return[t,!0];if("object"!==r||null===t)throw new Error(e);if(o&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!g(t)&&!w(t))throw new Error(e);return[t,!1]},b=function(e){return 0===m(e)[0].length},E=function(e){for(var t=[],r=0;r<e.length;++r)t[r]=e[r];return t},_=function(e,t,r){return function(n){return new L(e,t,e).update(n)[r]()}},v=function(e,t,r){return function(n,i){return new L(e,t,i).update(n)[r]()}},S=function(e,t,r){return function(t,n,i,o){return A["cshake"+e].update(t,n,i,o)[r]()}},I=function(e,t,r){return function(t,n,i,o){return A["kmac"+e].update(t,n,i,o)[r]()}},T=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},P=function(e,t){var r=_(e,t,"hex");return r.create=function(){return new L(e,t,e)},r.update=function(e){return r.create().update(e)},T(r,_,e,t)},k=[{name:"keccak",padding:[1,256,65536,16777216],bits:p,createMethod:P},{name:"sha3",padding:[6,1536,393216,100663296],bits:p,createMethod:P},{name:"shake",padding:[31,7936,2031616,520093696],bits:l,createMethod:function(e,t){var r=v(e,t,"hex");return r.create=function(r){return new L(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},T(r,v,e,t)}},{name:"cshake",padding:a,bits:l,createMethod:function(e,t){var r=y[e],n=S(e,0,"hex");return n.create=function(n,i,o){return b(i)&&b(o)?A["shake"+e].create(n):new L(e,t,n).bytepad([i,o],r)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},T(n,S,e,t)}},{name:"kmac",padding:a,bits:l,createMethod:function(e,t){var r=y[e],n=I(e,0,"hex");return n.create=function(n,i,o){return new C(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)},T(n,I,e,t)}}],A={},O=[],N=0;N<k.length;++N)for(var x=k[N],U=x.bits,B=0;B<U.length;++B){var M=x.name+"_"+U[B];if(O.push(M),A[M]=x.createMethod(U[B],x.padding),"sha3"!==x.name){var R=x.name+U[B];O.push(R),A[R]=A[M]}}function L(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 C(e,t,r){L.call(this,e,t,r)}L.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t=m(e);e=t[0];for(var r,n,i=t[1],o=this.blocks,s=this.byteCount,a=e.length,c=this.blockCount,f=0,h=this.s;f<a;){if(this.reset)for(this.reset=!1,o[0]=this.block,r=1;r<c+1;++r)o[r]=0;if(i)for(r=this.start;f<a&&r<s;++f)(n=e.charCodeAt(f))<128?o[r>>2]|=n<<u[3&r++]:n<2048?(o[r>>2]|=(192|n>>6)<<u[3&r++],o[r>>2]|=(128|63&n)<<u[3&r++]):n<55296||n>=57344?(o[r>>2]|=(224|n>>12)<<u[3&r++],o[r>>2]|=(128|n>>6&63)<<u[3&r++],o[r>>2]|=(128|63&n)<<u[3&r++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++f)),o[r>>2]|=(240|n>>18)<<u[3&r++],o[r>>2]|=(128|n>>12&63)<<u[3&r++],o[r>>2]|=(128|n>>6&63)<<u[3&r++],o[r>>2]|=(128|63&n)<<u[3&r++]);else for(r=this.start;f<a&&r<s;++f)o[r>>2]|=e[f]<<u[3&r++];if(this.lastByteIndex=r,r>=s){for(this.start=r-s,this.block=o[c],r=0;r<c;++r)h[r]^=o[r];H(h),this.reset=!0}else this.start=r}return this},L.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},L.prototype.encodeString=function(e){var t=m(e);e=t[0];var r=t[1],n=0,i=e.length;if(r)for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);s<128?n+=1:s<2048?n+=2:s<55296||s>=57344?n+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++o)),n+=4)}else n=i;return n+=this.encode(8*n),this.update(e),n},L.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)%t,o=[];return o.length=i,this.update(o),this},L.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];H(n)}},L.prototype.toString=L.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,u="";a<n;){for(o=0;o<t&&a<n;++o,++a)e=r[o],u+=s[e>>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];a%t==0&&(r=E(r),H(r),o=0)}return i&&(e=r[o],u+=s[e>>4&15]+s[15&e],i>1&&(u+=s[e>>12&15]+s[e>>8&15]),i>2&&(u+=s[e>>20&15]+s[e>>16&15])),u},L.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&&(r=E(r),H(r))}return i&&(u[s]=r[o],e=e.slice(0,a)),e},L.prototype.buffer=L.prototype.arrayBuffer,L.prototype.digest=L.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&&(n=E(n),H(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},C.prototype=new L,C.prototype.finalize=function(){return this.encode(this.outputBits,!0),L.prototype.finalize.call(this)};var H=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,P,k,A,O,N,x,U,B,M,R,L,C,H,D,V,F,j,K,G,W,q,X,$,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],X=e[11]<<4|e[10]>>>28,$=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,R=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,z=e[22]<<10|e[23]>>>22,Y=e[23]<<10|e[22]>>>22,x=e[33]<<13|e[32]>>>19,U=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,M=e[44]<<29|e[45]>>>3,T=e[6]<<28|e[7]>>>4,P=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,V=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,q=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,A=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,j=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^~k&O,e[11]=P^~A&N,e[20]=R^~C&D,e[21]=L^~H&V,e[30]=W^~X&z,e[31]=q^~$&Y,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=w^~b&_,e[3]=m^~E&v,e[12]=k^~O&x,e[13]=A^~N&U,e[22]=C^~D&F,e[23]=H^~V&j,e[32]=X^~z&J,e[33]=$^~Y&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=b^~_&S,e[5]=E^~v&I,e[14]=O^~x&B,e[15]=N^~U&M,e[24]=D^~F&K,e[25]=V^~j&G,e[34]=z^~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]=x^~B&T,e[17]=U^~M&P,e[26]=F^~K&R,e[27]=j^~G&L,e[36]=J^~Z&W,e[37]=Q^~ee&q,e[46]=ae^~ce&te,e[47]=ue^~fe&re,e[8]=S^~y&w,e[9]=I^~g&m,e[18]=B^~T&k,e[19]=M^~P&A,e[28]=K^~R&C,e[29]=G^~L&H,e[38]=Z^~W&X,e[39]=ee^~q&$,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=h[n],e[1]^=h[n+1]};if(i)mo.exports=A;else for(N=0;N<O.length;++N)r[O[N]]=A[O[N]]}()),wo.exports);var Eo=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 _o(e,t){return Eo(this,void 0,void 0,(function*(){let r;var n;"publicKeyJwk"in e?r=mt(e.publicKeyJwk):"publicKeyMultibase"in e&&(r=yield(n=e,gt(void 0,void 0,void 0,(function*(){const e=yield I({keyPair:n});return mt(e)}))));const i=at("errors","identityErrorBaseMessage");let o="";switch(t.code){case s.Bitcoin:case s.Mocknet:case s.Testnet:o=function(e,t){return go.payments.p2pkh({pubkey:e,network:go.networks[t.code]}).address}(r,t);break;case s.Ethmain:case s.Ethropst:case s.Ethrinkeby:case s.Ethgoerli:case s.Ethsepolia:o=function(e){const t=e.toString("hex"),r=new T.ec("secp256k1").keyFromPublic(t,"hex").getPublic().encode("hex").slice(2),n=u;return`0x${bo.keccak256(n.from(r,"hex")).slice(24).toString()}`}(r);break;default:throw new it("deriveIssuingAddressFromPublicKey",`${i} - ${at("errors","deriveIssuingAddressFromPublicKey")}`)}return o}))}function vo(e){if(e){const t="string"==typeof e?e:e.code;return!!Object.keys(o).some((e=>e===t))&&!!o[t].test}return!1}var So=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:Io}=E.suites;class To extends Io{constructor({issuer:e=null,verificationMethod:t=null,document:r=null,proof:n=null,options:i={},proofPurpose:o="assertionMethod",domain:s=[],challenge:a=""}){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=["assertProofValidity","getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"],this.identityVerificationProcess=["deriveIssuingAddressFromPublicKey","ensureVerificationMethodValidity","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.proofPurpose=o,this.domain=Array.isArray(s)?s:[s],this.challenge=a,this.setProof(n),this.setOptions(i),this.getChain(),vo(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet())}static decodeMerkleProof2019(e){return new et.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=To.decodeMerkleProof2019(this.proof)}verifyProof(){return So(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 So(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 vo(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=rt(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(){nt(this.proofVerificationProcess,"getTransactionId"),nt(this.proofVerificationProcess,"fetchRemoteHash"),nt(this.proofVerificationProcess,"checkMerkleRoot")}adaptIdentityVerificationProcessToMocknet(){this.identityVerificationProcess=["ensureVerificationMethodValidity"]}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 So(this,arguments,void 0,(function*(e,t,r=""){return yield t()}))}verifyProcess(e){return So(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]()}}))}assertProofValidity(){return So(this,void 0,void 0,(function*(){yield this.executeStep("assertProofValidity",(()=>ut({expectedProofPurpose:this.proofPurpose,expectedDomain:this.domain,expectedChallenge:this.challenge,proof:this.proof,issuer:this.issuer})),this.type)}))}checkMerkleRoot(){return So(this,void 0,void 0,(function*(){yield this.executeStep("checkMerkleRoot",(()=>function(e,t){if(e!==t)throw new it("checkMerkleRoot",at("errors","ensureMerkleRootEqual"));return!0}(this.proofValue.merkleRoot,this.txData.remoteHash)),this.type)}))}compareHashes(){return So(this,void 0,void 0,(function*(){yield this.executeStep("compareHashes",(()=>function(e,t){if(e!==t)throw new it("compareHashes",at("errors","ensureHashesEqual"));return!0}(this.localDocumentHash,this.proofValue.targetHash)),this.type)}))}computeLocalHash(){return So(this,void 0,void 0,(function*(){this.localDocumentHash=yield this.executeStep("computeLocalHash",(()=>So(this,void 0,void 0,(function*(){return yield yt(this.document,this.proof,this.documentLoader)}))),this.type)}))}checkReceipt(){return So(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=lt(`${n.left}${t}`),t=S(i);else{if(void 0===n.right)throw new it("checkReceipt","Trigger catch error.");i=lt(`${t}${n.right}`),t=S(i)}}}catch(e){throw new it("checkReceipt",at("errors","ensureValidReceipt"))}if(t!==r)throw new it("checkReceipt",at("errors","invalidMerkleReceipt"))}(this.proofValue)}),this.type)}))}getTransactionId(){return So(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 it("getTransactionId",at("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}))}fetchRemoteHash(){return So(this,void 0,void 0,(function*(){this.txData=yield this.executeStep("fetchRemoteHash",(()=>So(this,void 0,void 0,(function*(){var e;return yield i({transactionId:this.transactionId,chain:null===(e=this.chain)||void 0===e?void 0:e.code,explorerAPIs:this.explorerAPIs})}))),this.type)}))}deriveIssuingAddressFromPublicKey(){return So(this,void 0,void 0,(function*(){this.derivedIssuingAddress=yield this.executeStep("deriveIssuingAddressFromPublicKey",(()=>So(this,void 0,void 0,(function*(){return yield _o(this.verificationMethod,this.chain)}))),this.type)}))}ensureVerificationMethodValidity(){return So(this,void 0,void 0,(function*(){yield this.executeStep("ensureVerificationMethodValidity",(()=>So(this,void 0,void 0,(function*(){if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new it("ensureVerificationMethodValidity","The verification key has expired")}if(this.verificationMethod.revoked)throw new it("ensureVerificationMethodValidity","The verification key has been revoked")}))),this.type)}))}compareIssuingAddress(){return So(this,void 0,void 0,(function*(){yield this.executeStep("compareIssuingAddress",(()=>{!function(e,t){const r=at("errors","identityErrorBaseMessage");if(e.toLowerCase()!==t.toLowerCase())throw new it("compareIssuingAddress",`${r} - ${at("errors","compareIssuingAddress")}`)}(this.getIssuerPublicKey(),this.derivedIssuingAddress)}),this.type)}))}}var Po;function ko(e){return To.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.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.deriveIssuingAddressFromPublicKey="deriveIssuingAddressFromPublicKey",e.compareIssuingAddress="compareIssuingAddress",e.checkAuthenticity="checkAuthenticity"}(Po||(Po={}));class Ao extends A{proofVerificationProcess=[Po.parseIssuerKeys,Po.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;verificationMethod;derivedIssuingAddress;hasDid;proof;type="MerkleProof2019";cryptosuite="merkle-proof-2019";suite;proofPurpose;proofDomain;proofChallenge;constructor(t){super(t),this.executeStep=t.executeStep,this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.proof=t.proof,this.issuer=t.issuer,this.proofPurpose=t.proofPurpose,this.proofDomain=t.proofDomain,this.proofChallenge=t.proofChallenge,this.validateProofType(),this.receipt=ko(this.proof),this.transactionId=e.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(t){return[...this.suite.getProofVerificationProcess(),...this.proofVerificationProcess].map((r=>e.verifier.convertToVerificationSubsteps(t,r)))}getIdentityVerificationSteps(t){return this.hasDid?this.suite.getIdentityVerificationProcess().map((r=>e.verifier.convertToVerificationSubsteps(t,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 e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.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.verificationMethod=k(this.getTargetVerificationMethodContainer(),t(this.proof)),this.suite=new To({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethod,proofPurpose:this.proofPurpose,domain:this.proofDomain,challenge:this.proofChallenge,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}})}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(r(this.proofVerificationProcess,Po.parseIssuerKeys),r(this.proofVerificationProcess,Po.checkAuthenticity))}getTargetVerificationMethodContainer(){if(this.issuer.didDocument)return this.issuer.didDocument;const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e?.find((e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod))??null}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 t=this.proof.verificationMethod.split("#")[0];this.issuer=await e.verifier.getIssuerProfile(t)}}setHasDid(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.hasDid=n(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(Po.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(Po.checkAuthenticity,(()=>{P(this.issuerPublicKeyList,this.getIssuerPublicKey(),this.getIssuanceTime())}),this.type)}}export{Ao as default,ko as parseReceipt};
|