@omnisat/lasereyes 0.0.96 → 0.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +5770 -6006
  2. package/dist/index.umd.cjs +26 -26
  3. package/package.json +3 -3
@@ -1,19 +1,19 @@
1
- (function(Y,tn){typeof exports=="object"&&typeof module<"u"?tn(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],tn):(Y=typeof globalThis<"u"?globalThis:Y||self,tn(Y.lasereyes={},Y.React))})(this,function(Y,tn){"use strict";"use client";var Yb=Object.defineProperty,Zb=(e,t,r)=>t in e?Yb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,de=(e,t,r)=>Zb(e,typeof t!="symbol"?t+"":t,r);function Qb(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let pl=Symbol("clean"),rn=[],mi=0;const Ra=4;let yl=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=mi+Ra;o<rn.length;)rn[o]===n?rn.splice(o,Ra):o+=Ra;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!rn.length;for(let s of t)rn.push(s,r.value,n,i);if(o){for(mi=0;mi<rn.length;mi+=Ra)rn[mi](rn[mi+1],rn[mi+2],rn[mi+3]);rn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[pl]=()=>{t=[],r.lc=0,r.off()}),r};const em=5,Rs=6,Ba=10;let tm=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Ba]||(e.events[r+Ba]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Ba](),delete e.events[r+Ba])}),rm=1e3,nm=(e,t)=>tm(e,r=>{let n=t(r);n&&e.events[Rs].push(n)},em,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[Rs]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[Rs])o();e.events[Rs]=[]}},rm)},process.env.NODE_ENV!=="production"){let o=e[pl];e[pl]=()=>{for(let s of e.events[Rs])s();e.events[Rs]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function nn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Ud(e,t,r){let n=nn(e,t,r);return r(e.value),n}let Rd=(e={})=>{let t=yl(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const vi="oyl",zn="unisat",In="xverse",Ei="phantom",Ai="leather",Wn="magic-eden",ss="okx",os="wizz",Si="orange",Ti="op_net",Ha="p2tr",im="p2pkh",gl="p2wpkh",sm="p2psh",om="p2wsh",am="p2sh",cm={oyl:{name:vi,icon:"data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E",site:"https://oyl.io/",disabled:!1},unisat:{name:zn,icon:"/wallet-logos/unisat_logo.png",site:"https://unisat.io/",disabled:!1},xverse:{name:In,icon:"/wallet-logos/xverse_logo.png",site:"https://www.xverse.app/",config:()=>{},disabled:!1},leather:{name:Ai,icon:"/wallet-logos/leather_logo.png",site:"https://leather.io/",config:()=>{},disabled:!0}},La="defaultWallet",sn={messagePrefix:`Bitcoin Signed Message:
1
+ (function(Y,tn){typeof exports=="object"&&typeof module<"u"?tn(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],tn):(Y=typeof globalThis<"u"?globalThis:Y||self,tn(Y.lasereyes={},Y.React))})(this,function(Y,tn){"use strict";"use client";var Yb=Object.defineProperty,Zb=(e,t,r)=>t in e?Yb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t,r)=>Zb(e,typeof t!="symbol"?t+"":t,r);function Qb(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let ll=Symbol("clean"),rn=[],wi=0;const $a=4;let hl=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=wi+$a;o<rn.length;)rn[o]===n?rn.splice(o,$a):o+=$a;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!rn.length;for(let s of t)rn.push(s,r.value,n,i);if(o){for(wi=0;wi<rn.length;wi+=$a)rn[wi](rn[wi+1],rn[wi+2],rn[wi+3]);rn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[ll]=()=>{t=[],r.lc=0,r.off()}),r};const em=5,Ns=6,Ca=10;let tm=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Ca]||(e.events[r+Ca]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Ca](),delete e.events[r+Ca])}),rm=1e3,nm=(e,t)=>tm(e,r=>{let n=t(r);n&&e.events[Ns].push(n)},em,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[Ns]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[Ns])o();e.events[Ns]=[]}},rm)},process.env.NODE_ENV!=="production"){let o=e[ll];e[ll]=()=>{for(let s of e.events[Ns])s();e.events[Ns]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function kn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Cd(e,t,r){let n=kn(e,t,r);return r(e.value),n}let Nd=(e={})=>{let t=hl(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const bi="oyl",Vn="unisat",Pn="xverse",mi="phantom",vi="leather",Wn="magic-eden",ns="okx",is="wizz",Ei="orange",Ud="op_net",Na="p2tr",im="p2pkh",fl="p2wpkh",sm="p2psh",om="p2wsh",am="p2sh",cm={oyl:{name:bi,icon:"data:image/svg+xml,%3Csvg%20width%3D%2296%22%20height%3D%2216%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M17.27.318c2.947%200%205.72.26%208.32.78%202.6.507%204.714%201.307%206.34%202.4%201.64%201.094%202.46%202.467%202.46%204.12%200%201.654-.82%203.047-2.46%204.18-1.64%201.12-3.766%201.954-6.38%202.5-2.6.547-5.36.82-8.28.82-2.946%200-5.72-.253-8.32-.76-2.6-.52-4.72-1.326-6.36-2.42C.964%2010.845.15%209.472.15%207.818c0-1.653.82-3.04%202.46-4.16%201.64-1.133%203.76-1.973%206.36-2.52%202.614-.546%205.38-.82%208.3-.82Zm.04%2011.96c1.4%200%202.8-.146%204.2-.44%201.414-.293%202.6-.78%203.56-1.46.96-.68%201.44-1.566%201.44-2.66%200-1.093-.48-1.98-1.44-2.66-.96-.68-2.146-1.166-3.56-1.46-1.4-.293-2.8-.44-4.2-.44h-.08c-1.4%200-2.806.147-4.22.44-1.4.294-2.58.78-3.54%201.46-.96.68-1.44%201.567-1.44%202.66%200%201.094.48%201.98%201.44%202.66.96.68%202.14%201.167%203.54%201.46%201.414.294%202.82.44%204.22.44h.08ZM61.293.758c.08-.026.14-.04.18-.04h8.24c.12%200%20.214.04.28.12.08.08.12.174.12.28%200%20.147-.066.26-.2.34l-14%207.7c-.133.067-.2.18-.2.34v4.82c0%20.107-.04.2-.12.28a.384.384%200%200%201-.28.12h-6.94c-.106%200-.2-.04-.28-.12a.384.384%200%200%201-.12-.28v-4.82c0-.16-.066-.273-.2-.34l-13.98-7.7a.376.376%200%200%201-.2-.34c0-.106.034-.2.1-.28.067-.08.16-.12.28-.12h8.24c.054%200%20.12.014.2.04l9.24%205.1c.08.027.147.04.2.04.04%200%20.1-.013.18-.04l9.26-5.1Zm11.232.36c0-.106.033-.2.1-.28.08-.08.173-.12.28-.12h6.84c.106%200%20.193.04.26.12.08.08.12.174.12.28v10.32c0%20.107.04.2.12.28.08.08.173.12.28.12h14.46c.106%200%20.193.04.26.12.08.08.12.174.12.28v2.08c0%20.107-.04.2-.12.28a.322.322%200%200%201-.26.12h-22.08c-.107%200-.2-.04-.28-.12a.424.424%200%200%201-.1-.28v-13.2Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E",site:"https://oyl.io/",disabled:!1},unisat:{name:Vn,icon:"/wallet-logos/unisat_logo.png",site:"https://unisat.io/",disabled:!1},xverse:{name:Pn,icon:"/wallet-logos/xverse_logo.png",site:"https://www.xverse.app/",config:()=>{},disabled:!1},leather:{name:vi,icon:"/wallet-logos/leather_logo.png",site:"https://leather.io/",config:()=>{},disabled:!0}},Ua="defaultWallet",nn={messagePrefix:`Bitcoin Signed Message:
2
2
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},um={messagePrefix:`Bitcoin Signed Message:
3
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function lm(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function hm(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(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function fm(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)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(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const We={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},Bd={};for(const e of Object.keys(We)){const t=We[e];Bd[t]=e}const Ka="0123456789abcdefABCDEF",ja=Ka.split("").map(e=>e.codePointAt(0)),Da=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Ka.indexOf(r);return n<0?void 0:n<16?n:n-6}),Hd=new TextEncoder,Ld=new TextDecoder;function dm(e){return Ld.decode(e)}function pm(e){return Hd.encode(e)}function ot(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function ve(e){const t=e||new Uint8Array;return t.length>512?gm(t):ym(t)}function ym(e){let t="";for(let r=0;r<e.length;++r)t+=Ka[Da[ja[e[r]>>4]]],t+=Ka[Da[ja[e[r]&15]]];return t}function gm(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=ja[e[r]>>4],t[r*2+1]=ja[e[r]&15];return Ld.decode(t)}function qn(e){const t=Hd.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=Da[t[n*2]],o=Da[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function wm(e){return btoa(String.fromCharCode(...e))}function Kd(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Tr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function bm(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function ko(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function mm(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function Gn(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function vm(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Bs(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function jd(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function Dd(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function Em(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function Md(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function Fd(e){return e<We.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function Am(e,t,r){const n=Fd(t);return n===1?Tr(e,r,t):n===2?(Tr(e,r,We.OP_PUSHDATA1),Tr(e,r+1,t)):n===3?(Tr(e,r,We.OP_PUSHDATA2),bm(e,r+1,t,"LE")):(Tr(e,r,We.OP_PUSHDATA4),ko(e,r+1,t,"LE")),n}function Sm(e,t){const r=Gn(e,t);let n,i;if(r<We.OP_PUSHDATA1)n=r,i=1;else if(r===We.OP_PUSHDATA1){if(t+2>e.length)return null;n=Gn(e,t+1),i=2}else if(r===We.OP_PUSHDATA2){if(t+3>e.length)return null;n=vm(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==We.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=Bs(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function Tm(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function _m(e){let t=Math.abs(e);const r=Tm(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Tr(n,o,t&255),t>>=8;return n[r-1]&128?Tr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function km(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function a9(e){}function c9(e){}function Pm(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Po(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function Ft(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Po(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Pm(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Om(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var Im=class extends Error{constructor(t){super(t[0].message),de(this,"issues"),this.name="ValiError",this.issues=t}};function Vd(e,t){return{kind:"validation",type:"every_item",reference:Vd,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&Ft(this,"item",r,n),r}}}function wl(e){return{kind:"validation",type:"integer",reference:wl,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&Ft(this,"integer",t,r),t}}}function zd(e,t){return{kind:"validation",type:"length",reference:zd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&Ft(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ma(e,t){return{kind:"validation",type:"max_value",reference:Ma,async:!1,expects:`<=${e instanceof Date?e.toJSON():Po(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Po(r.value)}),r}}}function Fa(e,t){return{kind:"validation",type:"min_value",reference:Fa,async:!1,expects:`>=${e instanceof Date?e.toJSON():Po(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Po(r.value)}),r}}}function Wd(e,t){return{kind:"validation",type:"regex",reference:Wd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&Ft(this,"format",r,n),r}}}function bl(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function Va(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function qd(){return{kind:"schema",type:"any",reference:qd,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function or(e,t){return{kind:"schema",type:"array",reference:or,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function Gd(e){return{kind:"schema",type:"bigint",reference:Gd,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:Ft(this,"type",t,r),t}}}function on(e,t){return{kind:"schema",type:"custom",reference:on,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:Ft(this,"type",r,n),r}}}function za(e,t){return{kind:"schema",type:"instance",reference:za,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:Ft(this,"type",r,n),r}}}function ml(e,...t){const r={kind:"schema",type:"nullable",reference:ml,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=bl(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Xd(e,...t){const r={kind:"schema",type:"nullish",reference:Xd,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=bl(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function ar(e){return{kind:"schema",type:"number",reference:ar,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Ft(this,"type",t,r),t}}}function It(e,t){return{kind:"schema",type:"object",reference:It,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else Ft(this,"type",r,n);return r}}}function Wa(e,...t){const r={kind:"schema",type:"optional",reference:Wa,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=bl(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function as(e){return{kind:"schema",type:"string",reference:as,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:Ft(this,"type",t,r),t}}}function xn(e,t){return{kind:"schema",type:"tuple",reference:xn,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function Jd(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function vl(e,t){return{kind:"schema",type:"union",reference:vl,expects:Om(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];Ft(this,"type",r,n,{issues:Jd(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];Ft(this,"type",r,n,{issues:Jd(s)})}return r}}}function at(e,t,r){const n=e._run({typed:!1,value:t},km(r));if(n.issues)throw new Im(n.issues);return n.value}function _i(e,t){const r={};for(const n in e.entries)r[n]=Wa(e.entries[n]);return{...e,entries:r}}function Hs(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const Yd=new Uint8Array(32),Zd=qn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ct=e=>Hs(za(Uint8Array),zd(e));function Oo(e,t){return e.length!==t.length?!1:e.every((r,n)=>Q(r,t[n])===0)}function an(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(Q(Yd,r)===0||Q(r,Zd)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return Q(Yd,n)===0||Q(n,Zd)>=0?!1:t===4&&e.length===65}const qa=254;function El(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&qa)===e.version:!0}function Qd(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>Qd(t)):El(e)}const xm=Ct(32),$m=Ct(20),ep=Ct(32),De=za(Uint8Array);Hs(as(),Wd(/^([0-9a-f]{2})+$/i));const Cm=Hs(ar(),wl(),Fa(0),Ma(255)),Xn=Hs(ar(),wl(),Fa(0),Ma(4294967295)),Al=Hs(Gd(),Fa(0n),Ma(0x7fffffffffffffffn)),tp=e=>It(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Xd(r[1])}),{})),rp=new Uint8Array(1);function np(e){let t=0;for(;e[t]===0;)++t;return t===e.length?rp:(e=e.slice(t),e[0]&128?ot([rp,e]):e)}function ip(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Nm(e){const t=Gn(e,e.length-1);if(!Tl(t))throw new Error("Invalid hashType "+t);const r=hm(e.subarray(0,-1)),n=ip(r.r),i=ip(r.s);return{signature:ot([n,i]),hashType:t}}function Um(e,t){if(at(It({signature:Ct(64),hashType:Cm}),{signature:e,hashType:t}),!Tl(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Tr(r,0,t);const n=np(e.slice(0,32)),i=np(e.slice(32,64));return ot([fm(n,i),r])}const Rm=Object.freeze(Object.defineProperty({__proto__:null,decode:Nm,encode:Um},Symbol.toStringTag,{value:"Module"})),sp=We.OP_RESERVED,op=or(vl([za(Uint8Array),ar()]));function Bm(e){return Va(ar(),e)&&(e===We.OP_0||e>=We.OP_1&&e<=We.OP_16||e===We.OP_1NEGATE)}function ap(e){return Va(De,e)||Bm(e)}function Sl(e){return Va(Hs(qd(),Vd(ap)),e)}function cp(e){return e.length-e.filter(ap).length}function Ga(e){if(e.length===0)return We.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return sp+e[0];if(e[0]===129)return We.OP_1NEGATE}}function up(e){return e instanceof Uint8Array}function Hm(e){return Va(op,e)}function Xa(e){return e instanceof Uint8Array}function cr(e){if(up(e))return e;at(op,e);const t=e.reduce((i,o)=>Xa(o)?o.length===1&&Ga(o)!==void 0?i+1:i+Fd(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(Xa(i)){const o=Ga(i);if(o!==void 0){Tr(r,n,o),n+=1;return}n+=Am(r,i.length,n),r.set(i,n),n+=i.length}else Tr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function bt(e){if(Hm(e))return e;at(De,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>We.OP_0&&n<=We.OP_PUSHDATA4){const i=Sm(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=Ga(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function Lm(e){if(up(e)&&(e=bt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(Xa(t)){const r=Ga(t);if(r===void 0)return ve(t);t=r}return Bd[t]}).join(" ")}function Km(e){return e=bt(e),at(on(Sl),e),e.map(t=>Xa(t)?t:t===We.OP_0?new Uint8Array(0):_m(t-sp))}function jm(e){return an(e)}function Tl(e){const t=e&-129;return t>0&&t<4}function Jn(e){return!(e instanceof Uint8Array)||!Tl(e[e.length-1])?!1:lm(e.slice(0,-1))}const Io=Rm;function pe(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Ur(e){let t;return()=>(t!==void 0||(t=e()),t)}const Ls=We,Ja=Ls.OP_RESERVED;function Ya(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return Jn(a)||(t.allowIncomplete&&a===Ls.OP_0)!==void 0}at(_i(It({network:It({}),m:ar(),n:ar(),output:De,pubkeys:or(on(an),"Received invalid pubkey"),signatures:or(on(r),"Expected signature to be of type isAcceptableSignature"),input:De})),e);const n={network:e.network||sn};let i=[],o=!1;function s(a){o||(o=!0,i=bt(a),n.m=i[0]-Ja,n.n=i[i.length-2]-Ja,n.pubkeys=i.slice(1,-2))}if(pe(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return cr([].concat(Ja+e.m,e.pubkeys,Ja+n.n,Ls.OP_CHECKMULTISIG))}),pe(n,"m",()=>{if(n.output)return s(n.output),n.m}),pe(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),pe(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),pe(n,"signatures",()=>{if(e.input)return bt(e.input).slice(1)}),pe(n,"input",()=>{if(e.signatures)return cr([Ls.OP_0].concat(e.signatures))}),pe(n,"witness",()=>{if(n.input)return[]}),pe(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),at(ar(),i[0],{message:"Output is invalid"}),at(ar(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==Ls.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>an(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!Oo(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==Ls.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!Oo(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const lp=We;function hp(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(_i(It({network:It({}),output:De,pubkey:on(an,"invalid pubkey"),signature:on(Jn,"Expected signature to be of type isCanonicalScriptSignature"),input:De})),e);const r=Ur(()=>bt(e.input)),n={name:"p2pk",network:e.network||sn};if(pe(n,"output",()=>{if(e.pubkey)return cr([e.pubkey,lp.OP_CHECKSIG])}),pe(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),pe(n,"signature",()=>{if(e.input)return r()[0]}),pe(n,"input",()=>{if(e.signature)return cr([e.signature])}),pe(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==lp.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!an(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&Q(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&Q(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!Jn(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function Dm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fp(e,...t){if(!Dm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function dp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mm(e,t){fp(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _l=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),$n=(e,t)=>e<<32-t|e>>>t,Za=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Fm(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function pp(e){return typeof e=="string"&&(e=Fm(e)),fp(e),e}let Vm=class{clone(){return this._cloneInto()}};function yp(e){const t=n=>e().update(pp(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function zm(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const Wm=(e,t,r)=>e&t^~e&r,qm=(e,t,r)=>e&t^e&r^t&r;let gp=class extends Vm{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=_l(this.buffer)}update(t){dp(this);const{view:r,buffer:n,blockLen:i}=this;t=pp(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=_l(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){dp(this),Mm(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;zm(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=_l(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};const Gm=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),wp=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Xm=wp.map(e=>(9*e+5)%16);let kl=[wp],Pl=[Xm];for(let e=0;e<4;e++)for(let t of[kl,Pl])t.push(t[e].map(r=>Gm[r]));const bp=[[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)),Jm=kl.map((e,t)=>e.map(r=>bp[t][r])),Ym=Pl.map((e,t)=>e.map(r=>bp[t][r])),Zm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Qm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function mp(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const Qa=new Uint32Array(16);let ev=class extends gp{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)Qa[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=Zm[v],x=Qm[v],N=kl[v],I=Pl[v],k=Jm[v],B=Ym[v];for(let W=0;W<16;W++){const V=Za(n+mp(v,o,a,f)+Qa[N[W]]+T,k[W])+d|0;n=d,d=f,f=Za(a,10)|0,a=o,o=V}for(let W=0;W<16;W++){const V=Za(i+mp(E,s,u,h)+Qa[I[W]]+x,B[W])+g|0;i=g,g=h,h=Za(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){Qa.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const tv=yp(()=>new ev),rv=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]),ki=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pi=new Uint32Array(64);let nv=class extends gp{constructor(){super(64,32,8,!1),this.A=ki[0]|0,this.B=ki[1]|0,this.C=ki[2]|0,this.D=ki[3]|0,this.E=ki[4]|0,this.F=ki[5]|0,this.G=ki[6]|0,this.H=ki[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Pi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Pi[d-15],v=Pi[d-2],E=$n(g,7)^$n(g,18)^g>>>3,T=$n(v,17)^$n(v,19)^v>>>10;Pi[d]=T+Pi[d-7]+E+Pi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=$n(a,6)^$n(a,11)^$n(a,25),v=h+g+Wm(a,u,f)+rv[d]+Pi[d]|0,E=($n(n,2)^$n(n,13)^$n(n,22))+qm(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Pi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Jt=yp(()=>new nv);function Yn(e){return tv(Jt(e))}function cs(e){return Jt(Jt(e))}const iv={"BIP0340/challenge":Uint8Array.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":Uint8Array.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":Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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":Uint8Array.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":Uint8Array.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])};function ec(e,t){return Jt(ot([iv[e],t]))}function sv(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let I=f[g],k=0;for(let B=E-1;(I!==0||k<d)&&B!==-1;B--,k++)I+=256*T[B]>>>0,T[B]=I%r>>>0,I=I/r>>>0;if(I!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let I=t[f.charCodeAt(h)];if(I===255)return;let k=0;for(let B=v-1;(I!==0||k<g)&&B!==-1;B--,k++)I+=r*E[B]>>>0,E[B]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var ov="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Ol=sv(ov);function av(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),Ol.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=Ol.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=Ol.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function cv(e){return Jt(Jt(e))}const xo=av(cv),Oi=We;function $o(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(_i(It({network:It({}),address:as(),hash:$m,output:Ct(25),pubkey:on(an),signature:on(Jn),input:De})),e);const r=Ur(()=>{const s=xo.decode(e.address),a=Gn(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Ur(()=>bt(e.input)),i=e.network||sn,o={name:"p2pkh",network:i};if(pe(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Tr(s,0,i.pubKeyHash),s.set(o.hash,1),xo.encode(s)}),pe(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return Yn(e.pubkey||o.pubkey)}),pe(o,"output",()=>{if(o.hash)return cr([Oi.OP_DUP,Oi.OP_HASH160,o.hash,Oi.OP_EQUALVERIFY,Oi.OP_CHECKSIG])}),pe(o,"pubkey",()=>{if(e.input)return n()[1]}),pe(o,"signature",()=>{if(e.input)return n()[0]}),pe(o,"input",()=>{if(e.pubkey&&e.signature)return cr([e.signature,e.pubkey])}),pe(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==Oi.OP_DUP||e.output[1]!==Oi.OP_HASH160||e.output[2]!==20||e.output[23]!==Oi.OP_EQUALVERIFY||e.output[24]!==Oi.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=Yn(e.pubkey);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!Jn(a[0]))throw new TypeError("Input has invalid signature");if(!an(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&Q(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=Yn(a[1]);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const Co=We;function Ks(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(_i(It({network:It({}),address:as(),hash:Ct(20),output:Ct(23),redeem:_i(It({network:It({}),output:De,input:De,witness:or(De)})),input:De,witness:or(De)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||sn);const n={network:r},i=Ur(()=>{const a=xo.decode(e.address),u=Gn(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Ur(()=>bt(e.input)),s=Ur(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===Co.OP_FALSE?Uint8Array.from([]):u,input:cr(a.slice(0,-1)),witness:e.witness||[]}});if(pe(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Tr(a,0,n.network.scriptHash),a.set(n.hash,1),xo.encode(a)}),pe(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return Yn(n.redeem.output)}),pe(n,"output",()=>{if(n.hash)return cr([Co.OP_HASH160,n.hash,Co.OP_EQUAL])}),pe(n,"redeem",()=>{if(e.input)return s()}),pe(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return cr([].concat(bt(e.redeem.input),e.redeem.output))}),pe(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),pe(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&Q(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==Co.OP_HASH160||e.output[1]!==20||e.output[22]!==Co.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&Q(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=bt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(cp(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=Yn(f.output);if(a.length>0&&Q(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=bt(f.input);if(!Sl(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&Q(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&Q(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!Oo(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function lv(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var No={};Object.defineProperty(No,"__esModule",{value:!0});var Uo=No.bech32m=_r=No.bech32=void 0;const tc="qpzry9x8gf2tvdw0s3jn54khce6mua7l",vp={};for(let e=0;e<tc.length;e++){const t=tc.charAt(e);vp[t]=e}function js(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ep(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=js(t)^n>>5}t=js(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=js(t)^n&31}return t}function Il(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],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 hv(e){return Il(e,8,5,!0)}function fv(e){const t=Il(e,5,8,!1);if(Array.isArray(t))return t}function dv(e){const t=Il(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Ap(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=Ep(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=js(f)^g,h+=tc.charAt(g)}for(let d=0;d<6;++d)f=js(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=tc.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=Ep(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=vp[x];if(N===void 0)return"Unknown character "+x;v=js(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:hv,fromWordsUnsafe:fv,fromWords:dv}}var _r=No.bech32=Ap("bech32");Uo=No.bech32m=Ap("bech32m");const Sp=We,pv=new Uint8Array(0);function Ro(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(_i(It({address:as(),hash:Ct(20),input:Ct(0),network:It({}),output:Ct(22),pubkey:on(an,"Not a valid pubkey"),signature:on(Jn),witness:or(De)})),e);const r=Ur(()=>{const o=_r.decode(e.address),s=o.words.shift(),a=_r.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||sn,i={name:"p2wpkh",network:n};if(pe(i,"address",()=>{if(!i.hash)return;const o=_r.toWords(i.hash);return o.unshift(0),_r.encode(n.bech32,o)}),pe(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return Yn(e.pubkey||i.pubkey)}),pe(i,"output",()=>{if(i.hash)return cr([Sp.OP_0,i.hash])}),pe(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),pe(i,"signature",()=>{if(e.witness)return e.witness[0]}),pe(i,"input",()=>{if(i.witness)return pv}),pe(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&Q(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==Sp.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&Q(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=Yn(e.pubkey);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!an(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!Jn(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!an(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&Q(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=Yn(e.witness[1]);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const Tp=We,xl=new Uint8Array(0);function rc(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&an(e))}function Bo(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(tp({network:It({}),address:as(),hash:xm,output:Ct(34),redeem:tp({input:De,network:It({}),output:De,witness:or(De)}),input:Ct(0),witness:or(De)}),e);const r=Ur(()=>{const s=_r.decode(e.address),a=s.words.shift(),u=_r.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Ur(()=>bt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||sn);const o={network:i};if(pe(o,"address",()=>{if(!o.hash)return;const s=_r.toWords(o.hash);return s.unshift(0),_r.encode(i.bech32,s)}),pe(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return Jt(o.redeem.output)}),pe(o,"output",()=>{if(o.hash)return cr([Tp.OP_0,o.hash])}),pe(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:xl,witness:e.witness.slice(0,-1)}}),pe(o,"input",()=>{if(o.witness)return xl}),pe(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=Km(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=xl,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),pe(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==Tp.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=bt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(cp(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=Jt(e.redeem.output);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!Sl(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!Oo(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(rc)||e.redeem.output&&(bt(e.redeem.output)||[]).some(rc))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&Q(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(rc)||(bt(a)||[]).some(rc))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const Ho={};function yv(e){e?e!==Ho.eccLib&&(gv(e),Ho.eccLib=e):Ho.eccLib=e}function $l(){if(!Ho.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Ho.eccLib}const Zn=e=>qn(e);function gv(e){Rr(typeof e.isXOnlyPoint=="function"),Rr(e.isXOnlyPoint(Zn("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Rr(e.isXOnlyPoint(Zn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Rr(e.isXOnlyPoint(Zn("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Rr(e.isXOnlyPoint(Zn("0000000000000000000000000000000000000000000000000000000000000001"))),Rr(!e.isXOnlyPoint(Zn("0000000000000000000000000000000000000000000000000000000000000000"))),Rr(!e.isXOnlyPoint(Zn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Rr(typeof e.xOnlyPointAddTweak=="function"),wv.forEach(t=>{const r=e.xOnlyPointAddTweak(Zn(t.pubkey),Zn(t.tweak));t.result===null?Rr(r===null):(Rr(r!==null),Rr(r.parity===t.parity),Rr(Q(r.xOnlyPubkey,Zn(t.result))===0))})}function Rr(e){if(!e)throw new Error("ecc library invalid")}const wv=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],_p="0123456789abcdefABCDEF";_p.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=_p.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function bv(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function mv(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function vv(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function Ev(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Av(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Sv(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const Tv=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function _v(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function kp(e){typeof e=="number"?_v(e):Tv(e)}function Ii(e,t,r){kp(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Br(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),bv(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),mv(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),vv(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function Ds(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=Ev(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=Av(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=Sv(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Br(e){return kp(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const kv=9007199254740991;function Pv(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function Cl(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}function Pp(e){const t=new Uint8Array(e.length);return t.set(e),t}let ur=class Xb{constructor(t,r=0){de(this,"buffer"),de(this,"offset"),this.buffer=t,this.offset=r,at(xn([De,Xn]),[t,r])}static withCapacity(t){return new Xb(new Uint8Array(t))}writeUInt8(t){this.offset=Tr(this.buffer,this.offset,t)}writeInt32(t){this.offset=jd(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=Dd(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=ko(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=mm(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=Ii(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}},Ov=class{constructor(t,r=0){de(this,"buffer"),de(this,"offset"),this.buffer=t,this.offset=r,at(xn([De,Xn]),[t,r])}readUInt8(){const t=Gn(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=Em(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=Bs(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=Md(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=Ds(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){Pv(t,kv);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}};const Op=192,Iv=128,xv=e=>"left"in e&&"right"in e;function Nl(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 i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);Q(n,o)<0?n=Rl(n,o):n=Rl(o,n)}return n}function Ul(e){if(El(e))return{hash:Qn(e)};const t=[Ul(e[0]),Ul(e[1])];t.sort((i,o)=>Q(i.hash,o.hash));const[r,n]=t;return{hash:Rl(r.hash,n.hash),left:r,right:n}}function nc(e,t){if(xv(e)){const r=nc(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=nc(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(Q(e.hash,t)===0)return[]}function Qn(e){const t=e.version||Op;return ec("TapLeaf",ot([Uint8Array.from([t]),Cv(e.output)]))}function $v(e,t){return ec("TapTweak",ot(t?[e,t]:[e]))}function ic(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=$v(e,t),n=$l().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function Rl(e,t){return ec("TapBranch",ot([e,t]))}function Cv(e){const t=Br(e.length),r=new Uint8Array(t);return Ii(e.length,r),ot([r,e])}const Ip=We,xp=1,Nv=80;function Lo(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(_i(It({address:as(),input:Ct(0),network:It({}),output:Ct(34),internalPubkey:Ct(32),hash:Ct(32),pubkey:Ct(32),signature:vl([Ct(64),Ct(65)]),witness:or(De),scriptTree:on(Qd,"Taptree is not of type isTaptree"),redeem:_i(It({output:De,redeemVersion:ar(),witness:or(De)})),redeemVersion:ar()})),e);const r=Ur(()=>Hp(e.address)),n=Ur(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===Nv?e.witness.slice(0,-1):e.witness.slice()}),i=Ur(()=>{if(e.scriptTree)return Ul(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||sn,s={name:"p2tr",network:o};if(pe(s,"address",()=>{if(!s.pubkey)return;const a=Uo.toWords(s.pubkey);return a.unshift(xp),Uo.encode(o.bech32,a)}),pe(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&qa,d=u[u.length-2],g=Qn({output:d,version:h});return Nl(f,g)}return null}),pe(s,"output",()=>{if(s.pubkey)return cr([Ip.OP_1,s.pubkey])}),pe(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:Op),pe(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&qa}}),pe(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=ic(s.internalPubkey,s.hash);if(a)return a.x}}),pe(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),pe(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),pe(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=Qn({output:e.redeem.output,version:s.redeemVersion}),f=nc(a,u);if(!f)return;const h=ic(e.internalPubkey,a.hash);if(!h)return;const d=ot([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==xp)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&Q(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==Ip.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&Q(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=ic(e.internalPubkey,s.hash);if(a.length>0&&Q(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!$l().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&Q(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=Qn({output:e.redeem.output,version:s.redeemVersion});if(!nc(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(bt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&Q(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!Oo(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&Q(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&Q(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!$l().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&qa,E=f[f.length-2],T=Qn({output:E,version:v}),x=Nl(h,T),N=ic(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&Q(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const $p=40,Cp=2,Np=16,Up=2,Rp=80,Bp="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 Uv(e,t){const r=e.slice(2);if(r.length<Cp||r.length>$p)throw new TypeError("Invalid program length for segwit address");const n=e[0]-Rp;if(n<Up||n>Np)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(Bp),Bv(r,n,t.bech32)}function Rv(e){const t=xo.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=Gn(t,0),n=t.slice(1);return{version:r,hash:n}}function Hp(e){let t,r;try{t=_r.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=Uo.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=_r.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function Bv(e,t,r){const n=_r.toWords(e);return n.unshift(t),t===0?_r.encode(r,n):Uo.encode(r,n)}function Ko(e,t){t=t||sn;try{return $o({output:e,network:t}).address}catch{}try{return Ks({output:e,network:t}).address}catch{}try{return Ro({output:e,network:t}).address}catch{}try{return Bo({output:e,network:t}).address}catch{}try{return Lo({output:e,network:t}).address}catch{}try{return Uv(e,t)}catch{}throw new Error(Lm(e)+" has no matching Address")}function Lp(e,t){t=t||sn;let r,n;try{r=Rv(e)}catch{}if(r){if(r.version===t.pubKeyHash)return $o({hash:r.hash}).output;if(r.version===t.scriptHash)return Ks({hash:r.hash}).output}else{try{n=Hp(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return Ro({hash:n.data}).output;if(n.data.length===32)return Bo({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return Lo({pubkey:n.data}).output}else if(n.version>=Up&&n.version<=Np&&n.data.length>=Cp&&n.data.length<=$p)return console.warn(Bp),cr([n.version+Rp,n.data])}}throw new Error(e+" has no matching Script")}function Cn(e){const t=e.length;return Br(t)+t}function Hv(e){const t=e.length;return Br(t)+e.reduce((r,n)=>r+Cn(n),0)}const xi=new Uint8Array(0),Kp=[],Bl=qn("0000000000000000000000000000000000000000000000000000000000000000"),jp=qn("0000000000000000000000000000000000000000000000000000000000000001"),Lv=qn("ffffffffffffffff"),Kv={script:xi,valueBuffer:Lv};function jv(e){return e.value!==void 0}const cn=class Qe{constructor(){de(this,"version",1),de(this,"locktime",0),de(this,"ins",[]),de(this,"outs",[])}static fromBuffer(t,r){const n=new Ov(t),i=new Qe;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===Qe.ADVANCED_TRANSACTION_MARKER&&s===Qe.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:Kp});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].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(t){return Qe.fromBuffer(qn(t),!1)}static isCoinbaseHash(t){at(ep,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&Qe.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return at(xn([ep,Xn,ml(Wa(Xn)),ml(Wa(De))]),[t,r,n,i]),n==null&&(n=Qe.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||xi,sequence:n,witness:Kp})-1}addOutput(t,r){return at(xn([De,Al]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Br(this.ins.length)+Br(this.outs.length)+this.ins.reduce((n,i)=>n+40+Cn(i.script),0)+this.outs.reduce((n,i)=>n+8+Cn(i.script),0)+(r?this.ins.reduce((n,i)=>n+Hv(i.witness),0):0)}clone(){const t=new Qe;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(at(xn([Xn,De,ar()]),[t,r,n]),t>=this.ins.length)return jp;const i=cr(bt(r).filter(a=>a!==We.OP_CODESEPARATOR)),o=this.clone();if((n&31)===Qe.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===Qe.SIGHASH_SINGLE){if(t>=this.outs.length)return jp;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=Kv;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&Qe.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=xi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return jd(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),cs(s)}hashForWitnessV1(t,r,n,i,o,s){if(at(xn([Xn,or(De),or(Al),Xn]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===Qe.SIGHASH_DEFAULT?Qe.SIGHASH_ALL:i&Qe.SIGHASH_OUTPUT_MASK,u=(i&Qe.SIGHASH_INPUT_MASK)===Qe.SIGHASH_ANYONECANPAY,f=a===Qe.SIGHASH_NONE,h=a===Qe.SIGHASH_SINGLE;let d=xi,g=xi,v=xi,E=xi,T=xi;if(!u){let k=ur.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=Jt(k.end()),k=ur.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=Jt(k.end()),k=ur.withCapacity(r.map(Cn).reduce((B,W)=>B+W)),r.forEach(B=>k.writeVarSlice(B)),v=Jt(k.end()),k=ur.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=Jt(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=ur.withCapacity(8+Cn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=Jt(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(W=>8+Cn(W.script)).reduce((W,V)=>W+V),B=ur.withCapacity(k);this.outs.forEach(W=>{B.writeInt64(W.value),B.writeVarSlice(W.script)}),T=Jt(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),I=ur.withCapacity(N);if(I.writeUInt8(i),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(d),I.writeSlice(g),I.writeSlice(v),I.writeSlice(E),f||h||I.writeSlice(T),I.writeUInt8(x),u){const k=this.ins[t];I.writeSlice(k.hash),I.writeUInt32(k.index),I.writeInt64(n[t]),I.writeVarSlice(r[t]),I.writeUInt32(k.sequence)}else I.writeUInt32(t);if(s){const k=ur.withCapacity(Cn(s));k.writeVarSlice(s),I.writeSlice(Jt(k.end()))}return h&&I.writeSlice(T),o&&(I.writeSlice(o),I.writeUInt8(0),I.writeUInt32(4294967295)),ec("TapSighash",ot([Uint8Array.from([0]),I.end()]))}hashForWitnessV0(t,r,n,i){at(xn([Xn,De,Al,Xn]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=Bl,u=Bl,f=Bl;if(i&Qe.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new ur(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=cs(o)),!(i&Qe.SIGHASH_ANYONECANPAY)&&(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new ur(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=cs(o)),(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+Cn(v.script),0);o=new Uint8Array(d),s=new ur(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=cs(o)}else if((i&31)===Qe.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+Cn(d.script)),s=new ur(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=cs(o)}o=new Uint8Array(156+Cn(r)),s=new ur(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),cs(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):cs(this.__toBuffer(void 0,void 0,t))}getId(){return ve(Cl(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return ve(this.toBuffer(void 0,void 0))}setInputScript(t,r){at(xn([ar(),De]),[t,r]),this.ins[t].script=r}setWitness(t,r){at(xn([ar(),or(De)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new ur(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(Qe.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(Qe.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{jv(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};de(cn,"DEFAULT_SEQUENCE",4294967295),de(cn,"SIGHASH_DEFAULT",0),de(cn,"SIGHASH_ALL",1),de(cn,"SIGHASH_NONE",2),de(cn,"SIGHASH_SINGLE",3),de(cn,"SIGHASH_ANYONECANPAY",128),de(cn,"SIGHASH_OUTPUT_MASK",3),de(cn,"SIGHASH_INPUT_MASK",128),de(cn,"ADVANCED_TRANSACTION_MARKER",0),de(cn,"ADVANCED_TRANSACTION_FLAG",1);let St=cn;var Nn;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})(Nn||(Nn={}));var ie;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(ie||(ie={}));var Tt;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(Tt||(Tt={}));const Dv=e=>[...Array(e).keys()];function Mv(e){if(e.key[0]!==Nn.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+ve(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+ve(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of Dv(e.value.length/4-1)){const i=Bs(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function Fv(e){const t=new Uint8Array([Nn.GLOBAL_XPUB]),r=ot([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),ko(i,o,u,"LE"),o+=4}),{key:r,value:i}}const Vv="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function zv(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function Wv(e,t,r){const n=ve(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.extendedPubkey,t.extendedPubkey)).length===0)}const qv=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:Wv,check:zv,decode:Mv,encode:Fv,expected:Vv},Symbol.toStringTag,{value:"Module"}));function Gv(e){return{key:new Uint8Array([Nn.UNSIGNED_TX]),value:e.toBuffer()}}const Xv=Object.freeze(Object.defineProperty({__proto__:null,encode:Gv},Symbol.toStringTag,{value:"Module"}));function Jv(e){if(e.key[0]!==ie.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+ve(e.key));return e.value}function Yv(e){return{key:new Uint8Array([ie.FINAL_SCRIPTSIG]),value:e}}const Zv="Uint8Array";function Qv(e){return e instanceof Uint8Array}function eE(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const tE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:eE,check:Qv,decode:Jv,encode:Yv,expected:Zv},Symbol.toStringTag,{value:"Module"}));function rE(e){if(e.key[0]!==ie.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+ve(e.key));return e.value}function nE(e){return{key:new Uint8Array([ie.FINAL_SCRIPTWITNESS]),value:e}}const iE="Uint8Array";function sE(e){return e instanceof Uint8Array}function oE(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const aE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:oE,check:sE,decode:rE,encode:nE,expected:iE},Symbol.toStringTag,{value:"Module"}));function cE(e){if(e.key[0]!==ie.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+ve(e.key));return e.value}function uE(e){return{key:new Uint8Array([ie.NON_WITNESS_UTXO]),value:e}}const lE="Uint8Array";function hE(e){return e instanceof Uint8Array}function fE(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const dE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fE,check:hE,decode:cE,encode:uE,expected:lE},Symbol.toStringTag,{value:"Module"}));function pE(e){if(e.key[0]!==ie.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+ve(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+ve(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function yE(e){const t=new Uint8Array([ie.PARTIAL_SIG]);return{key:ot([t,e.pubkey]),value:e.signature}}const gE="{ pubkey: Uint8Array; signature: Uint8Array; }";function wE(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&bE(e.signature)}function bE(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function mE(e,t,r){const n=ve(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0).length===0)}const vE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:mE,check:wE,decode:pE,encode:yE,expected:gE},Symbol.toStringTag,{value:"Module"}));function EE(e){if(e.key[0]!==ie.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+ve(e.key));return dm(e.value)}function AE(e){return{key:new Uint8Array([ie.POR_COMMITMENT]),value:pm(e)}}const SE="string";function TE(e){return typeof e=="string"}function _E(e,t){return!!e&&!!t&&e.porCommitment===void 0}const kE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:_E,check:TE,decode:EE,encode:AE,expected:SE},Symbol.toStringTag,{value:"Module"}));function PE(e){if(e.key[0]!==ie.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+ve(e.key));return Number(Bs(e.value,0,"LE"))}function OE(e){const t=Uint8Array.from([ie.SIGHASH_TYPE]),r=new Uint8Array(4);return ko(r,0,e,"LE"),{key:t,value:r}}const IE="number";function xE(e){return typeof e=="number"}function $E(e,t){return!!e&&!!t&&e.sighashType===void 0}const CE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$E,check:xE,decode:PE,encode:OE,expected:IE},Symbol.toStringTag,{value:"Module"}));function NE(e){if(e.key[0]!==ie.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+ve(e.key));if(!Dp(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function UE(e){return{key:Uint8Array.from([ie.TAP_KEY_SIG]),value:e}}const RE="Uint8Array";function Dp(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function BE(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const HE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:BE,check:Dp,decode:NE,encode:UE,expected:RE},Symbol.toStringTag,{value:"Module"}));function LE(e){if(e.key[0]!==ie.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+ve(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+ve(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+ve(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function KE(e){const t=Uint8Array.from([ie.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:ot([t,e.controlBlock]),value:ot([e.script,r])}}const jE="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function DE(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ME(e,t,r){const n=ve(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.controlBlock,t.controlBlock)===0).length===0)}const FE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ME,check:DE,decode:LE,encode:KE,expected:jE},Symbol.toStringTag,{value:"Module"}));function VE(e){if(e.key[0]!==ie.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+ve(e.key));if(!Mp(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function zE(e){return{key:Uint8Array.from([ie.TAP_MERKLE_ROOT]),value:e}}const WE="Uint8Array";function Mp(e){return e instanceof Uint8Array&&e.length===32}function qE(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const GE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:qE,check:Mp,decode:VE,encode:zE,expected:WE},Symbol.toStringTag,{value:"Module"}));function XE(e){if(e.key[0]!==ie.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+ve(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+ve(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+ve(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function JE(e){const t=Uint8Array.from([ie.TAP_SCRIPT_SIG]);return{key:ot([t,e.pubkey,e.leafHash]),value:e.signature}}const YE="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function ZE(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function QE(e,t,r){const n=ve(t.pubkey)+ve(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0&&Q(i.leafHash,t.leafHash)===0).length===0)}const eA=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:QE,check:ZE,decode:XE,encode:JE,expected:YE},Symbol.toStringTag,{value:"Module"}));function tA(e){if(e.key[0]!==ie.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+ve(e.key));const t=Md(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=Ds(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function rA(e){const{script:t,value:r}=e,n=Br(t.length),i=new Uint8Array(8+n+t.length);return Dd(i,0,BigInt(r),"LE"),Ii(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([ie.WITNESS_UTXO]),value:i}}const nA="{ script: Uint8Array; value: bigint; }";function iA(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function sA(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const oA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:sA,check:iA,decode:tA,encode:rA,expected:nA},Symbol.toStringTag,{value:"Module"}));function aA(e){if(e.key[0]!==Tt.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+ve(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=Ds(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function cA(e){const t=Uint8Array.from([Tt.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),Ii(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:ot(r)}}const uA="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function lA(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function hA(e,t){return!!e&&!!t&&e.tapTree===void 0}const fA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:hA,check:lA,decode:aA,encode:cA,expected:uA},Symbol.toStringTag,{value:"Module"})),dA=e=>[...Array(e).keys()],pA=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Hl(e,t=pA){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+ve(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+ve(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of dA(a.value.length/4-1)){const d=Bs(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=ot([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),ko(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=ve(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>Q(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Ll(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+ve(r.key));return n}}function Fp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const yA=e=>e.length===32;function Vp(e){const t=Hl(e,yA);function r(s){const{numberValue:a,bytes:u}=Ds(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Br(s.leafHashes.length),f=new Uint8Array(u);Ii(s.leafHashes.length,f);const h=ot([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function zp(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+ve(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function Wp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Kl={unsignedTx:Xv,globalXpub:qv,checkPubkey:Ll([])},Nt={nonWitnessUtxo:dE,partialSig:vE,sighashType:CE,finalScriptSig:tE,finalScriptWitness:aE,porCommitment:kE,witnessUtxo:oA,bip32Derivation:Hl(ie.BIP32_DERIVATION),redeemScript:Fp(ie.REDEEM_SCRIPT),witnessScript:Wp(ie.WITNESS_SCRIPT),checkPubkey:Ll([ie.PARTIAL_SIG,ie.BIP32_DERIVATION]),tapKeySig:HE,tapScriptSig:eA,tapLeafScript:FE,tapBip32Derivation:Vp(ie.TAP_BIP32_DERIVATION),tapInternalKey:zp(ie.TAP_INTERNAL_KEY),tapMerkleRoot:GE},ei={bip32Derivation:Hl(Tt.BIP32_DERIVATION),redeemScript:Fp(Tt.REDEEM_SCRIPT),witnessScript:Wp(Tt.WITNESS_SCRIPT),checkPubkey:Ll([Tt.BIP32_DERIVATION]),tapBip32Derivation:Vp(Tt.TAP_BIP32_DERIVATION),tapTree:fA,tapInternalKey:zp(Tt.TAP_INTERNAL_KEY)},gA=Object.freeze(Object.defineProperty({__proto__:null,globals:Kl,inputs:Nt,outputs:ei},Symbol.toStringTag,{value:"Module"})),sc=e=>[...Array(e).keys()];function qp(e){const t=e.map(wA);return t.push(Uint8Array.from([0])),ot(t)}function wA(e){const t=e.key.length,r=e.value.length,n=Br(t),i=Br(r),o=new Uint8Array(n+t+i+r);return Ii(t,o,0),o.set(e.key,n),Ii(r,o,n+t),o.set(e.value,n+t+i),o}function bA(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=Ds(e,r);r+=N;const I=e.slice(r,r+Number(x));return r+=Number(x),I}function i(){const x=Bs(e,r,"BE");return r+=4,x}function o(){const x=Gn(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=Gn(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=ve(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===Nn.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of sc(g)){const N={},I=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,I.push(k)}E.push(I)}for(const x of sc(v)){const N={},I=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,I.push(k)}T.push(I)}return Gp(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Vt(e,t,r){if(Q(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${ve(t)}`)}function Gp(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case Nn.UNSIGNED_TX:if(Vt("global",h.key,Nn.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case Nn.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Kl.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of sc(s)){const d={};for(const g of r[h])switch(Nt.checkPubkey(g),g.key[0]){case ie.NON_WITNESS_UTXO:if(Vt("input",g.key,ie.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Nt.nonWitnessUtxo.decode(g);break;case ie.WITNESS_UTXO:if(Vt("input",g.key,ie.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Nt.witnessUtxo.decode(g);break;case ie.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Nt.partialSig.decode(g));break;case ie.SIGHASH_TYPE:if(Vt("input",g.key,ie.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Nt.sighashType.decode(g);break;case ie.REDEEM_SCRIPT:if(Vt("input",g.key,ie.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Nt.redeemScript.decode(g);break;case ie.WITNESS_SCRIPT:if(Vt("input",g.key,ie.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Nt.witnessScript.decode(g);break;case ie.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Nt.bip32Derivation.decode(g));break;case ie.FINAL_SCRIPTSIG:Vt("input",g.key,ie.FINAL_SCRIPTSIG),d.finalScriptSig=Nt.finalScriptSig.decode(g);break;case ie.FINAL_SCRIPTWITNESS:Vt("input",g.key,ie.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Nt.finalScriptWitness.decode(g);break;case ie.POR_COMMITMENT:Vt("input",g.key,ie.POR_COMMITMENT),d.porCommitment=Nt.porCommitment.decode(g);break;case ie.TAP_KEY_SIG:Vt("input",g.key,ie.TAP_KEY_SIG),d.tapKeySig=Nt.tapKeySig.decode(g);break;case ie.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Nt.tapScriptSig.decode(g));break;case ie.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Nt.tapLeafScript.decode(g));break;case ie.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Nt.tapBip32Derivation.decode(g));break;case ie.TAP_INTERNAL_KEY:Vt("input",g.key,ie.TAP_INTERNAL_KEY),d.tapInternalKey=Nt.tapInternalKey.decode(g);break;case ie.TAP_MERKLE_ROOT:Vt("input",g.key,ie.TAP_MERKLE_ROOT),d.tapMerkleRoot=Nt.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of sc(a)){const d={};for(const g of n[h])switch(ei.checkPubkey(g),g.key[0]){case Tt.REDEEM_SCRIPT:if(Vt("output",g.key,Tt.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=ei.redeemScript.decode(g);break;case Tt.WITNESS_SCRIPT:if(Vt("output",g.key,Tt.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=ei.witnessScript.decode(g);break;case Tt.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(ei.bip32Derivation.decode(g));break;case Tt.TAP_INTERNAL_KEY:Vt("output",g.key,Tt.TAP_INTERNAL_KEY),d.tapInternalKey=ei.tapInternalKey.decode(g);break;case Tt.TAP_TREE:Vt("output",g.key,Tt.TAP_TREE),d.tapTree=ei.tapTree.decode(g);break;case Tt.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(ei.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function mA({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=Dl({globalMap:e,inputs:t,outputs:r}),s=qp(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(qp),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),ot([h,s].concat(u,f))}const vA=(e,t)=>Q(e.key,t.key);function jl(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>ve(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(ve(o.key))):[];return n.concat(i).sort(vA)}function Dl({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:jl(e,Kl),inputKeyVals:t.map(n=>jl(n,Nt)),outputKeyVals:r.map(n=>jl(n,ei))}}function EA(e){const t=e[0],r=Dl(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Xp(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=Ms(r.globalKeyVals),s=r.inputKeyVals.map(Ms),a=r.outputKeyVals.map(Ms);for(const u of n){const f=Xp(u);if(f===void 0||Q(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=Dl(u);Ms(h.globalKeyVals).forEach(Ml(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(Ms).forEach((d,g)=>d.forEach(Ml(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(Ms).forEach((d,g)=>d.forEach(Ml(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return Gp(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function Ml(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>ve(o.key)===n)[0];t.push(i),e.add(n)}}function Xp(e){return e.globalMap.unsignedTx}function Ms(e){const t=new Set;return e.forEach(r=>{const n=ve(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function Kt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function jo(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Fl(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>Q(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${ve(e.key)}`)}function Vl(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function AA(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function Jp(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function zl(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=gA[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||Jp(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||Jp(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const SA=zl("global"),Yp=zl("input"),Zp=zl("output");function TA(e,t){const r=e.length-1,n=Kt(e,r);Yp(t,n)}function _A(e,t){const r=e.length-1,n=jo(e,r);Zp(t,n)}let Qp=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,r){const n=Kd(t);return this.fromBuffer(n,r)}static fromHex(t,r){const n=qn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r){const n=bA(t,r),i=new this(n.globalMap.unsignedTx);return Object.assign(i,n),i}toBase64(){const t=this.toBuffer();return wm(t)}toHex(){const t=this.toBuffer();return ve(t)}toBuffer(){return mA(this)}updateGlobal(t){return SA(t,this.globalMap),this}updateInput(t,r){const n=Kt(this.inputs,t);return Yp(r,n),this}updateOutput(t,r){const n=jo(this.outputs,t);return Zp(r,n),this}addUnknownKeyValToGlobal(t){return Fl(t,this.globalMap.unknownKeyVals,Vl(Nn)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,r){const n=Kt(this.inputs,t);return Fl(r,n.unknownKeyVals,Vl(ie)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addUnknownKeyValToOutput(t,r){const n=jo(this.outputs,t);return Fl(r,n.unknownKeyVals,Vl(Tt)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.inputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToInput(n,i)),TA(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.outputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToOutput(n,i)),_A(this.outputs,t),this}clearFinalizedInput(t){const r=Kt(this.inputs,t);AA(t,r);for(const n of Object.keys(r))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(n)||delete r[n];return this}combine(...t){const r=EA([this].concat(t));return Object.assign(this,r),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function us(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const kA=us(Ya),PA=us(hp),OA=us($o),oc=us(Ro),e0=us(Bo),t0=us(Ks),r0=us(Lo);function ac(e){let t=new Uint8Array(0);function r(s){t=ot([t,s])}function n(s){const a=t.length,u=Br(s);t=ot([t,new Uint8Array(u)]),Ii(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function n0(e,t){const r=Yn(e),n=e.slice(1,33),i=bt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:Q(e,o)===0||Q(r,o)===0||Q(n,o)===0)}function cc(e,t){return n0(e,t)!==-1}function IA(e,t){return xA(e).some(r=>i0(r,Io.decode,t))}function i0(e,t,r){const{hashType:n}=t(e),i=[];switch(n&St.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case St.SIGHASH_ALL:break;case St.SIGHASH_SINGLE:case St.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function xA(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=$A(e)}else t=e.partialSig;return t.map(r=>r.signature)}function $A(e){const t=e.finalScriptSig?bt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?bt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&Jn(n)).map(n=>({signature:n}))}const uc=e=>e.length===32?e:e.slice(1,33);function s0(e,t,r){const n=zA(t,e,r);try{const i=FA(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:ac(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function lc(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return ot([e,r])}function un(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&r0(e.witnessUtxo.script))}function Wl(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function o0(e,t,r){jA(e,t,r),MA(e,t,r)}function a0(e,t,r){DA(e,t,r),CA(e,t)}function CA(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=NA(r,n);if(i&&Q(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function NA(e,t){const r=t&&UA(t.leaves),{output:n}=Lo({internalPubkey:e,scriptTree:r});return n}function UA(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:KA(e)}function RA(e,t){return HA(e).some(r=>i0(r,BA,t))}function BA(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||St.SIGHASH_DEFAULT}}function HA(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=LA(e.finalScriptWitness);r&&t.push(r)}return t}function LA(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function KA(e){let t;for(const r of e)if(t=ql(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function ql(e,t,r=0){if(r>Iv)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(El(t))return;const n=ql(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=ql(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function jA(e,t,r){const n=un(e)&&Fs(t),i=Fs(e)&&un(t),o=e===t&&un(t)&&Fs(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function DA(e,t,r){const n=Wl(e)&&Fs(t),i=Fs(e)&&Wl(t),o=e===t&&Wl(t)&&Fs(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function MA(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Gl(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Gl(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Gl(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Gl(e,t){if(!t)return!0;const r=Qn({output:e.script,version:e.leafVersion}),n=Nl(e.controlBlock,r);return Q(n,t)===0}function FA(e,t){const r=Qn({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>Q(n.leafHash,r)===0).map(n=>VA(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function VA(e,t){return Object.assign({positionInScript:n0(t.pubkey,e)},t)}function zA(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>WA(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function WA(e,t,r){const n=Qn({output:e.script,version:e.leafVersion});return(!r||Q(n,r)===0)&&t.find(i=>Q(i.leafHash,n)===0)!==void 0}function Fs(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const qA={network:sn,maximumFeeRate:5e3};class ct{constructor(t={},r=new Qp(new c0)){de(this,"data"),de(this,"__CACHE"),de(this,"opts"),this.data=r,this.opts=Object.assign({},qA,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},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Kd(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=qn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=Qp.fromBuffer(t,GA),i=new ct(r,n);return QA(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:Pp(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=Ko(t.script,this.opts.network)}catch{}return{script:Pp(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=ct.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){hc(t),this.opts.maximumFeeRate=t}setVersion(t){hc(t),Do(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){hc(t),Do(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){hc(r),Do(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");o0(t,t,"addInput"),Do(this.data.inputs,"addInput"),t.witnessScript&&pc(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];d0(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&Yl(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Do(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=Lp(r,i);t=Object.assign({},t,{script:o})}a0(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(l0))throw new Error("Not finalized");const r=this.__CACHE;if(t||JA(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return _0(this.data.inputs,n,r,!0),n}getFeeRate(){return w0("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return w0("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return Kt(this.data.inputs,0),Mo(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=Kt(this.data.inputs,t);return un(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=s0){const i=Kt(this.data.inputs,t);if(un(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=e3){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=i3(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);YA(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=s0){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=Lo({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=ac(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=Kt(this.data.inputs,t),n=k0(t,r,this.__CACHE),i=dc(n,t,"input",r.redeemScript||u3(r.finalScriptSig),r.witnessScript||l3(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=O0(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=Kt(this.data.inputs,t);return a3(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=Kt(this.data.inputs,t),i=h0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=jo(this.data.outputs,t);return c3(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=jo(this.data.outputs,t),i=h0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return Kt(this.data.inputs,0),Mo(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return un(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>Q(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=Io.decode(d.signature),{hash:v,script:E}=h!==g.hashType?m0(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,f0(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&uc(n);const a=n?Jl(t,i,this.data.inputs,n,this.__CACHE):r3(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,E0(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>Q(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,E0(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[St.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of Mo(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[St.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of Mo(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[St.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return S0(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[St.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=S0(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of Mo(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return un(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(un(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[St.SIGHASH_ALL]){const{hash:i,sighashType:o}=b0(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:Io.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[St.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>lc(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:uc(n.publicKey),signature:lc(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return un(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(un(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[St.SIGHASH_ALL]){const{hash:i,sighashType:o}=b0(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:Io.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[St.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:lc(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:uc(n.publicKey),signature:lc(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=Jl(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${ve(n.publicKey)}`);return s}toBuffer(){return Xl(this.__CACHE),this.data.toBuffer()}toHex(){return Xl(this.__CACHE),this.data.toHex()}toBase64(){return Xl(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&pc(r.witnessScript),o0(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&Yl(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return a0(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}const GA=e=>new c0(e);let c0=class{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){de(this,"tx"),this.tx=St.fromBuffer(t),ZA(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?Cl(qn(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}};function XA(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return u0(1,e.partialSig);case"multisig":const n=Ya({output:t});return u0(n.m,e.partialSig,n.pubkeys);default:return!1}}function Xl(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function u0(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=h3(i);return t.find(s=>Q(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function l0(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function h0(e){return t=>!(Q(e.fingerprint,t.masterFingerprint)||Q(e.derivePath(t.path).publicKey,t.pubkey))}function hc(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function JA(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.`)}function Do(e,t){e.forEach(r=>{if(un(r)?RA(r,t):IA(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function YA(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=Io.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function f0(e,t,r){if(!cc(e,t))throw new Error(`Can not ${r} for this input with the key ${ve(e)}`)}function ZA(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function QA(e,t){e.ins.forEach(r=>{d0(t,r)})}function d0(e,t){const r=ve(Cl(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function p0(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(Q(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const y0=p0(Ks,"Redeem script"),g0=p0(Bo,"Witness script");function w0(e,t,r,n){if(!r.every(l0))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),_0(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function e3(e,t,r,n,i,o){const s=O0(r);if(!XA(t,r,s))throw new Error(`Can not finalize input #${e}`);return t3(r,s,t.partialSig,n,i,o)}function t3(e,t,r,n,i,o){let s,a;const u=n3(e,t,r),f=o?Bo({redeem:u}):null,h=i?Ks({redeem:f||u}):null;return n?(f?a=ac(f.witness):a=ac(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function b0(e,t,r,n,i){const o=Kt(e,t),{hash:s,sighashType:a,script:u}=m0(t,o,n,!1,i);return f0(r,u,"sign"),{hash:s,sighashType:a}}function m0(e,t,r,n,i){const o=r.__TX,s=t.sighashType||St.SIGHASH_ALL;A0(s,i);let a,u;if(t.nonWitnessUtxo){const d=fc(r,t,e),g=o.ins[e].hash,v=d.getHash();if(Q(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=dc(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(oc(f)){const d=$o({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${ve(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&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.
3
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function lm(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function hm(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(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function fm(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)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(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const ze={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},Rd={};for(const e of Object.keys(ze)){const t=ze[e];Rd[t]=e}const Ra="0123456789abcdefABCDEF",Ba=Ra.split("").map(e=>e.codePointAt(0)),La=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Ra.indexOf(r);return n<0?void 0:n<16?n:n-6}),Bd=new TextEncoder,Ld=new TextDecoder;function dm(e){return Ld.decode(e)}function pm(e){return Bd.encode(e)}function ot(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function ve(e){const t=e||new Uint8Array;return t.length>512?gm(t):ym(t)}function ym(e){let t="";for(let r=0;r<e.length;++r)t+=Ra[La[Ba[e[r]>>4]]],t+=Ra[La[Ba[e[r]&15]]];return t}function gm(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Ba[e[r]>>4],t[r*2+1]=Ba[e[r]&15];return Ld.decode(t)}function zn(e){const t=Bd.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=La[t[n*2]],o=La[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function wm(e){return btoa(String.fromCharCode(...e))}function Hd(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Tr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function bm(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function So(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function mm(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function qn(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function vm(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Us(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Kd(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function jd(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function Em(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function Dd(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function Md(e){return e<ze.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function Am(e,t,r){const n=Md(t);return n===1?Tr(e,r,t):n===2?(Tr(e,r,ze.OP_PUSHDATA1),Tr(e,r+1,t)):n===3?(Tr(e,r,ze.OP_PUSHDATA2),bm(e,r+1,t,"LE")):(Tr(e,r,ze.OP_PUSHDATA4),So(e,r+1,t,"LE")),n}function Sm(e,t){const r=qn(e,t);let n,i;if(r<ze.OP_PUSHDATA1)n=r,i=1;else if(r===ze.OP_PUSHDATA1){if(t+2>e.length)return null;n=qn(e,t+1),i=2}else if(r===ze.OP_PUSHDATA2){if(t+3>e.length)return null;n=vm(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==ze.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=Us(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function Tm(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function _m(e){let t=Math.abs(e);const r=Tm(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Tr(n,o,t&255),t>>=8;return n[r-1]&128?Tr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function km(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function s9(e){}function o9(e){}function Pm(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function To(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function Ft(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??To(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Pm(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Im(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var Om=class extends Error{constructor(t){super(t[0].message),we(this,"issues"),this.name="ValiError",this.issues=t}};function Fd(e,t){return{kind:"validation",type:"every_item",reference:Fd,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&Ft(this,"item",r,n),r}}}function dl(e){return{kind:"validation",type:"integer",reference:dl,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&Ft(this,"integer",t,r),t}}}function Vd(e,t){return{kind:"validation",type:"length",reference:Vd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&Ft(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Ha(e,t){return{kind:"validation",type:"max_value",reference:Ha,async:!1,expects:`<=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Ka(e,t){return{kind:"validation",type:"min_value",reference:Ka,async:!1,expects:`>=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&Ft(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():To(r.value)}),r}}}function Wd(e,t){return{kind:"validation",type:"regex",reference:Wd,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&Ft(this,"format",r,n),r}}}function pl(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function ja(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function zd(){return{kind:"schema",type:"any",reference:zd,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function ar(e,t){return{kind:"schema",type:"array",reference:ar,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function qd(e){return{kind:"schema",type:"bigint",reference:qd,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:Ft(this,"type",t,r),t}}}function sn(e,t){return{kind:"schema",type:"custom",reference:sn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:Ft(this,"type",r,n),r}}}function Da(e,t){return{kind:"schema",type:"instance",reference:Da,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:Ft(this,"type",r,n),r}}}function yl(e,...t){const r={kind:"schema",type:"nullable",reference:yl,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=pl(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Gd(e,...t){const r={kind:"schema",type:"nullish",reference:Gd,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=pl(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function cr(e){return{kind:"schema",type:"number",reference:cr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Ft(this,"type",t,r),t}}}function It(e,t){return{kind:"schema",type:"object",reference:It,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else Ft(this,"type",r,n);return r}}}function Ma(e,...t){const r={kind:"schema",type:"optional",reference:Ma,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=pl(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function ss(e){return{kind:"schema",type:"string",reference:ss,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:Ft(this,"type",t,r),t}}}function In(e,t){return{kind:"schema",type:"tuple",reference:In,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Ft(this,"type",r,n);return r}}}function Xd(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function gl(e,t){return{kind:"schema",type:"union",reference:gl,expects:Im(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];Ft(this,"type",r,n,{issues:Xd(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];Ft(this,"type",r,n,{issues:Xd(s)})}return r}}}function at(e,t,r){const n=e._run({typed:!1,value:t},km(r));if(n.issues)throw new Om(n.issues);return n.value}function Ai(e,t){const r={};for(const n in e.entries)r[n]=Ma(e.entries[n]);return{...e,entries:r}}function Rs(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const Jd=new Uint8Array(32),Yd=zn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$t=e=>Rs(Da(Uint8Array),Vd(e));function _o(e,t){return e.length!==t.length?!1:e.every((r,n)=>Q(r,t[n])===0)}function on(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(Q(Jd,r)===0||Q(r,Yd)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return Q(Jd,n)===0||Q(n,Yd)>=0?!1:t===4&&e.length===65}const Fa=254;function wl(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&Fa)===e.version:!0}function Zd(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>Zd(t)):wl(e)}const xm=$t(32),$m=$t(20),Qd=$t(32),De=Da(Uint8Array);Rs(ss(),Wd(/^([0-9a-f]{2})+$/i));const Cm=Rs(cr(),dl(),Ka(0),Ha(255)),Gn=Rs(cr(),dl(),Ka(0),Ha(4294967295)),bl=Rs(qd(),Ka(0n),Ha(0x7fffffffffffffffn)),ep=e=>It(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Gd(r[1])}),{})),tp=new Uint8Array(1);function rp(e){let t=0;for(;e[t]===0;)++t;return t===e.length?tp:(e=e.slice(t),e[0]&128?ot([tp,e]):e)}function np(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Nm(e){const t=qn(e,e.length-1);if(!vl(t))throw new Error("Invalid hashType "+t);const r=hm(e.subarray(0,-1)),n=np(r.r),i=np(r.s);return{signature:ot([n,i]),hashType:t}}function Um(e,t){if(at(It({signature:$t(64),hashType:Cm}),{signature:e,hashType:t}),!vl(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Tr(r,0,t);const n=rp(e.slice(0,32)),i=rp(e.slice(32,64));return ot([fm(n,i),r])}const Rm=Object.freeze(Object.defineProperty({__proto__:null,decode:Nm,encode:Um},Symbol.toStringTag,{value:"Module"})),ip=ze.OP_RESERVED,sp=ar(gl([Da(Uint8Array),cr()]));function Bm(e){return ja(cr(),e)&&(e===ze.OP_0||e>=ze.OP_1&&e<=ze.OP_16||e===ze.OP_1NEGATE)}function op(e){return ja(De,e)||Bm(e)}function ml(e){return ja(Rs(zd(),Fd(op)),e)}function ap(e){return e.length-e.filter(op).length}function Va(e){if(e.length===0)return ze.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return ip+e[0];if(e[0]===129)return ze.OP_1NEGATE}}function cp(e){return e instanceof Uint8Array}function Lm(e){return ja(sp,e)}function Wa(e){return e instanceof Uint8Array}function ur(e){if(cp(e))return e;at(sp,e);const t=e.reduce((i,o)=>Wa(o)?o.length===1&&Va(o)!==void 0?i+1:i+Md(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(Wa(i)){const o=Va(i);if(o!==void 0){Tr(r,n,o),n+=1;return}n+=Am(r,i.length,n),r.set(i,n),n+=i.length}else Tr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function gt(e){if(Lm(e))return e;at(De,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>ze.OP_0&&n<=ze.OP_PUSHDATA4){const i=Sm(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=Va(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function Hm(e){if(cp(e)&&(e=gt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(Wa(t)){const r=Va(t);if(r===void 0)return ve(t);t=r}return Rd[t]}).join(" ")}function Km(e){return e=gt(e),at(sn(ml),e),e.map(t=>Wa(t)?t:t===ze.OP_0?new Uint8Array(0):_m(t-ip))}function jm(e){return on(e)}function vl(e){const t=e&-129;return t>0&&t<4}function Xn(e){return!(e instanceof Uint8Array)||!vl(e[e.length-1])?!1:lm(e.slice(0,-1))}const ko=Rm;function de(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Ur(e){let t;return()=>(t!==void 0||(t=e()),t)}const Bs=ze,za=Bs.OP_RESERVED;function qa(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return Xn(a)||(t.allowIncomplete&&a===Bs.OP_0)!==void 0}at(Ai(It({network:It({}),m:cr(),n:cr(),output:De,pubkeys:ar(sn(on),"Received invalid pubkey"),signatures:ar(sn(r),"Expected signature to be of type isAcceptableSignature"),input:De})),e);const n={network:e.network||nn};let i=[],o=!1;function s(a){o||(o=!0,i=gt(a),n.m=i[0]-za,n.n=i[i.length-2]-za,n.pubkeys=i.slice(1,-2))}if(de(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return ur([].concat(za+e.m,e.pubkeys,za+n.n,Bs.OP_CHECKMULTISIG))}),de(n,"m",()=>{if(n.output)return s(n.output),n.m}),de(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),de(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),de(n,"signatures",()=>{if(e.input)return gt(e.input).slice(1)}),de(n,"input",()=>{if(e.signatures)return ur([Bs.OP_0].concat(e.signatures))}),de(n,"witness",()=>{if(n.input)return[]}),de(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),at(cr(),i[0],{message:"Output is invalid"}),at(cr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==Bs.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>on(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!_o(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==Bs.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!_o(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const up=ze;function lp(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),output:De,pubkey:sn(on,"invalid pubkey"),signature:sn(Xn,"Expected signature to be of type isCanonicalScriptSignature"),input:De})),e);const r=Ur(()=>gt(e.input)),n={name:"p2pk",network:e.network||nn};if(de(n,"output",()=>{if(e.pubkey)return ur([e.pubkey,up.OP_CHECKSIG])}),de(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),de(n,"signature",()=>{if(e.input)return r()[0]}),de(n,"input",()=>{if(e.signature)return ur([e.signature])}),de(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==up.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!on(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&Q(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&Q(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!Xn(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function Dm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function hp(e,...t){if(!Dm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function fp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mm(e,t){hp(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const El=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),On=(e,t)=>e<<32-t|e>>>t,Ga=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Fm(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function dp(e){return typeof e=="string"&&(e=Fm(e)),hp(e),e}let Vm=class{clone(){return this._cloneInto()}};function pp(e){const t=n=>e().update(dp(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Wm(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const zm=(e,t,r)=>e&t^~e&r,qm=(e,t,r)=>e&t^e&r^t&r;let yp=class extends Vm{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=El(this.buffer)}update(t){fp(this);const{view:r,buffer:n,blockLen:i}=this;t=dp(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=El(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){fp(this),Mm(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;Wm(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=El(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};const Gm=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),gp=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Xm=gp.map(e=>(9*e+5)%16);let Al=[gp],Sl=[Xm];for(let e=0;e<4;e++)for(let t of[Al,Sl])t.push(t[e].map(r=>Gm[r]));const wp=[[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)),Jm=Al.map((e,t)=>e.map(r=>wp[t][r])),Ym=Sl.map((e,t)=>e.map(r=>wp[t][r])),Zm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Qm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function bp(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const Xa=new Uint32Array(16);let ev=class extends yp{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)Xa[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=Zm[v],x=Qm[v],N=Al[v],O=Sl[v],k=Jm[v],B=Ym[v];for(let z=0;z<16;z++){const V=Ga(n+bp(v,o,a,f)+Xa[N[z]]+T,k[z])+d|0;n=d,d=f,f=Ga(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=Ga(i+bp(E,s,u,h)+Xa[O[z]]+x,B[z])+g|0;i=g,g=h,h=Ga(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){Xa.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const tv=pp(()=>new ev),rv=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]),Si=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ti=new Uint32Array(64);let nv=class extends yp{constructor(){super(64,32,8,!1),this.A=Si[0]|0,this.B=Si[1]|0,this.C=Si[2]|0,this.D=Si[3]|0,this.E=Si[4]|0,this.F=Si[5]|0,this.G=Si[6]|0,this.H=Si[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ti[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ti[d-15],v=Ti[d-2],E=On(g,7)^On(g,18)^g>>>3,T=On(v,17)^On(v,19)^v>>>10;Ti[d]=T+Ti[d-7]+E+Ti[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=On(a,6)^On(a,11)^On(a,25),v=h+g+zm(a,u,f)+rv[d]+Ti[d]|0,E=(On(n,2)^On(n,13)^On(n,22))+qm(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Xt=pp(()=>new nv);function Jn(e){return tv(Xt(e))}function os(e){return Xt(Xt(e))}const iv={"BIP0340/challenge":Uint8Array.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":Uint8Array.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":Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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":Uint8Array.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":Uint8Array.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])};function Ja(e,t){return Xt(ot([iv[e],t]))}function sv(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let O=f[g],k=0;for(let B=E-1;(O!==0||k<d)&&B!==-1;B--,k++)O+=256*T[B]>>>0,T[B]=O%r>>>0,O=O/r>>>0;if(O!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let O=t[f.charCodeAt(h)];if(O===255)return;let k=0;for(let B=v-1;(O!==0||k<g)&&B!==-1;B--,k++)O+=r*E[B]>>>0,E[B]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var ov="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Tl=sv(ov);function av(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),Tl.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=Tl.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=Tl.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function cv(e){return Xt(Xt(e))}const Po=av(cv),_i=ze;function Io(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),address:ss(),hash:$m,output:$t(25),pubkey:sn(on),signature:sn(Xn),input:De})),e);const r=Ur(()=>{const s=Po.decode(e.address),a=qn(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Ur(()=>gt(e.input)),i=e.network||nn,o={name:"p2pkh",network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Tr(s,0,i.pubKeyHash),s.set(o.hash,1),Po.encode(s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return Jn(e.pubkey||o.pubkey)}),de(o,"output",()=>{if(o.hash)return ur([_i.OP_DUP,_i.OP_HASH160,o.hash,_i.OP_EQUALVERIFY,_i.OP_CHECKSIG])}),de(o,"pubkey",()=>{if(e.input)return n()[1]}),de(o,"signature",()=>{if(e.input)return n()[0]}),de(o,"input",()=>{if(e.pubkey&&e.signature)return ur([e.signature,e.pubkey])}),de(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==_i.OP_DUP||e.output[1]!==_i.OP_HASH160||e.output[2]!==20||e.output[23]!==_i.OP_EQUALVERIFY||e.output[24]!==_i.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=Jn(e.pubkey);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!Xn(a[0]))throw new TypeError("Input has invalid signature");if(!on(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&Q(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=Jn(a[1]);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const Oo=ze;function Ls(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({network:It({}),address:ss(),hash:$t(20),output:$t(23),redeem:Ai(It({network:It({}),output:De,input:De,witness:ar(De)})),input:De,witness:ar(De)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||nn);const n={network:r},i=Ur(()=>{const a=Po.decode(e.address),u=qn(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Ur(()=>gt(e.input)),s=Ur(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===Oo.OP_FALSE?Uint8Array.from([]):u,input:ur(a.slice(0,-1)),witness:e.witness||[]}});if(de(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Tr(a,0,n.network.scriptHash),a.set(n.hash,1),Po.encode(a)}),de(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return Jn(n.redeem.output)}),de(n,"output",()=>{if(n.hash)return ur([Oo.OP_HASH160,n.hash,Oo.OP_EQUAL])}),de(n,"redeem",()=>{if(e.input)return s()}),de(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return ur([].concat(gt(e.redeem.input),e.redeem.output))}),de(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),de(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&Q(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==Oo.OP_HASH160||e.output[1]!==20||e.output[22]!==Oo.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&Q(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=gt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(ap(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=Jn(f.output);if(a.length>0&&Q(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=gt(f.input);if(!ml(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&Q(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&Q(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!_o(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function lv(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var xo={};Object.defineProperty(xo,"__esModule",{value:!0});var $o=xo.bech32m=_r=xo.bech32=void 0;const Ya="qpzry9x8gf2tvdw0s3jn54khce6mua7l",mp={};for(let e=0;e<Ya.length;e++){const t=Ya.charAt(e);mp[t]=e}function Hs(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function vp(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=Hs(t)^n>>5}t=Hs(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=Hs(t)^n&31}return t}function _l(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],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 hv(e){return _l(e,8,5,!0)}function fv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t}function dv(e){const t=_l(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Ep(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=vp(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=Hs(f)^g,h+=Ya.charAt(g)}for(let d=0;d<6;++d)f=Hs(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=Ya.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=vp(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=mp[x];if(N===void 0)return"Unknown character "+x;v=Hs(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:hv,fromWordsUnsafe:fv,fromWords:dv}}var _r=xo.bech32=Ep("bech32");$o=xo.bech32m=Ep("bech32m");const Ap=ze,pv=new Uint8Array(0);function Co(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({address:ss(),hash:$t(20),input:$t(0),network:It({}),output:$t(22),pubkey:sn(on,"Not a valid pubkey"),signature:sn(Xn),witness:ar(De)})),e);const r=Ur(()=>{const o=_r.decode(e.address),s=o.words.shift(),a=_r.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||nn,i={name:"p2wpkh",network:n};if(de(i,"address",()=>{if(!i.hash)return;const o=_r.toWords(i.hash);return o.unshift(0),_r.encode(n.bech32,o)}),de(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return Jn(e.pubkey||i.pubkey)}),de(i,"output",()=>{if(i.hash)return ur([Ap.OP_0,i.hash])}),de(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),de(i,"signature",()=>{if(e.witness)return e.witness[0]}),de(i,"input",()=>{if(i.witness)return pv}),de(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&Q(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==Ap.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&Q(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=Jn(e.pubkey);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!on(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!Xn(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!on(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&Q(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&Q(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=Jn(e.witness[1]);if(o.length>0&&Q(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const Sp=ze,kl=new Uint8Array(0);function Za(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&on(e))}function No(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(ep({network:It({}),address:ss(),hash:xm,output:$t(34),redeem:ep({input:De,network:It({}),output:De,witness:ar(De)}),input:$t(0),witness:ar(De)}),e);const r=Ur(()=>{const s=_r.decode(e.address),a=s.words.shift(),u=_r.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Ur(()=>gt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||nn);const o={network:i};if(de(o,"address",()=>{if(!o.hash)return;const s=_r.toWords(o.hash);return s.unshift(0),_r.encode(i.bech32,s)}),de(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return Xt(o.redeem.output)}),de(o,"output",()=>{if(o.hash)return ur([Sp.OP_0,o.hash])}),de(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:kl,witness:e.witness.slice(0,-1)}}),de(o,"input",()=>{if(o.witness)return kl}),de(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=Km(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=kl,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),de(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&Q(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==Sp.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&Q(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=gt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(ap(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=Xt(e.redeem.output);if(s.length>0&&Q(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!ml(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!_o(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(Za)||e.redeem.output&&(gt(e.redeem.output)||[]).some(Za))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&Q(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(Za)||(gt(a)||[]).some(Za))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const Uo={};function yv(e){e?e!==Uo.eccLib&&(gv(e),Uo.eccLib=e):Uo.eccLib=e}function Pl(){if(!Uo.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return Uo.eccLib}const Yn=e=>zn(e);function gv(e){Rr(typeof e.isXOnlyPoint=="function"),Rr(e.isXOnlyPoint(Yn("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Rr(e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Rr(e.isXOnlyPoint(Yn("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Rr(e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000001"))),Rr(!e.isXOnlyPoint(Yn("0000000000000000000000000000000000000000000000000000000000000000"))),Rr(!e.isXOnlyPoint(Yn("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Rr(typeof e.xOnlyPointAddTweak=="function"),wv.forEach(t=>{const r=e.xOnlyPointAddTweak(Yn(t.pubkey),Yn(t.tweak));t.result===null?Rr(r===null):(Rr(r!==null),Rr(r.parity===t.parity),Rr(Q(r.xOnlyPubkey,Yn(t.result))===0))})}function Rr(e){if(!e)throw new Error("ecc library invalid")}const wv=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],Tp="0123456789abcdefABCDEF";Tp.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Tp.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function bv(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function mv(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function vv(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function Ev(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function Av(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Sv(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const Tv=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function _v(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function _p(e){typeof e=="number"?_v(e):Tv(e)}function ki(e,t,r){_p(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Br(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),bv(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),mv(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),vv(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function Ks(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=Ev(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=Av(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=Sv(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Br(e){return _p(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const kv=9007199254740991;function Pv(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function Il(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}function kp(e){const t=new Uint8Array(e.length);return t.set(e),t}class Vt{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(In([De,Gn]),[t,r])}static withCapacity(t){return new Vt(new Uint8Array(t))}writeUInt8(t){this.offset=Tr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Kd(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=jd(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=So(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=mm(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=ki(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}let Iv=class{constructor(t,r=0){we(this,"buffer"),we(this,"offset"),this.buffer=t,this.offset=r,at(In([De,Gn]),[t,r])}readUInt8(){const t=qn(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=Em(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=Us(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=Dd(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=Ks(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){Pv(t,kv);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}};const Pp=192,Ov=128,xv=e=>"left"in e&&"right"in e;function Ol(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 i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);Q(n,o)<0?n=$l(n,o):n=$l(o,n)}return n}function xl(e){if(wl(e))return{hash:Zn(e)};const t=[xl(e[0]),xl(e[1])];t.sort((i,o)=>Q(i.hash,o.hash));const[r,n]=t;return{hash:$l(r.hash,n.hash),left:r,right:n}}function Qa(e,t){if(xv(e)){const r=Qa(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=Qa(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(Q(e.hash,t)===0)return[]}function Zn(e){const t=e.version||Pp;return Ja("TapLeaf",ot([Uint8Array.from([t]),Cv(e.output)]))}function $v(e,t){return Ja("TapTweak",ot(t?[e,t]:[e]))}function ec(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=$v(e,t),n=Pl().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function $l(e,t){return Ja("TapBranch",ot([e,t]))}function Cv(e){const t=Br(e.length),r=new Uint8Array(t);return ki(e.length,r),ot([r,e])}const Ip=ze,Op=1,Nv=80;function Ro(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),at(Ai(It({address:ss(),input:$t(0),network:It({}),output:$t(34),internalPubkey:$t(32),hash:$t(32),pubkey:$t(32),signature:gl([$t(64),$t(65)]),witness:ar(De),scriptTree:sn(Zd,"Taptree is not of type isTaptree"),redeem:Ai(It({output:De,redeemVersion:cr(),witness:ar(De)})),redeemVersion:cr()})),e);const r=Ur(()=>Bp(e.address)),n=Ur(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===Nv?e.witness.slice(0,-1):e.witness.slice()}),i=Ur(()=>{if(e.scriptTree)return xl(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||nn,s={name:"p2tr",network:o};if(de(s,"address",()=>{if(!s.pubkey)return;const a=$o.toWords(s.pubkey);return a.unshift(Op),$o.encode(o.bech32,a)}),de(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&Fa,d=u[u.length-2],g=Zn({output:d,version:h});return Ol(f,g)}return null}),de(s,"output",()=>{if(s.pubkey)return ur([Ip.OP_1,s.pubkey])}),de(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:Pp),de(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&Fa}}),de(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=ec(s.internalPubkey,s.hash);if(a)return a.x}}),de(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),de(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),de(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=Zn({output:e.redeem.output,version:s.redeemVersion}),f=Qa(a,u);if(!f)return;const h=ec(e.internalPubkey,a.hash);if(!h)return;const d=ot([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==Op)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&Q(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==Ip.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&Q(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=ec(e.internalPubkey,s.hash);if(a.length>0&&Q(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!Pl().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&Q(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=Zn({output:e.redeem.output,version:s.redeemVersion});if(!Qa(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(gt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&Q(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!_o(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&Q(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&Q(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!Pl().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&Fa,E=f[f.length-2],T=Zn({output:E,version:v}),x=Ol(h,T),N=ec(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&Q(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const xp=40,$p=2,Cp=16,Np=2,Up=80,Rp="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 Uv(e,t){const r=e.slice(2);if(r.length<$p||r.length>xp)throw new TypeError("Invalid program length for segwit address");const n=e[0]-Up;if(n<Np||n>Cp)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(Rp),Bv(r,n,t.bech32)}function Rv(e){const t=Po.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=qn(t,0),n=t.slice(1);return{version:r,hash:n}}function Bp(e){let t,r;try{t=_r.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=$o.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=_r.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function Bv(e,t,r){const n=_r.toWords(e);return n.unshift(t),t===0?_r.encode(r,n):$o.encode(r,n)}function Bo(e,t){t=t||nn;try{return Io({output:e,network:t}).address}catch{}try{return Ls({output:e,network:t}).address}catch{}try{return Co({output:e,network:t}).address}catch{}try{return No({output:e,network:t}).address}catch{}try{return Ro({output:e,network:t}).address}catch{}try{return Uv(e,t)}catch{}throw new Error(Hm(e)+" has no matching Address")}function Lp(e,t){t=t||nn;let r,n;try{r=Rv(e)}catch{}if(r){if(r.version===t.pubKeyHash)return Io({hash:r.hash}).output;if(r.version===t.scriptHash)return Ls({hash:r.hash}).output}else{try{n=Bp(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return Co({hash:n.data}).output;if(n.data.length===32)return No({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return Ro({pubkey:n.data}).output}else if(n.version>=Np&&n.version<=Cp&&n.data.length>=$p&&n.data.length<=xp)return console.warn(Rp),ur([n.version+Up,n.data])}}throw new Error(e+" has no matching Script")}function xn(e){const t=e.length;return Br(t)+t}function Lv(e){const t=e.length;return Br(t)+e.reduce((r,n)=>r+xn(n),0)}const Pi=new Uint8Array(0),Hp=[],Cl=zn("0000000000000000000000000000000000000000000000000000000000000000"),Kp=zn("0000000000000000000000000000000000000000000000000000000000000001"),Hv=zn("ffffffffffffffff"),Kv={script:Pi,valueBuffer:Hv};function jv(e){return e.value!==void 0}const an=class Qe{constructor(){we(this,"version",1),we(this,"locktime",0),we(this,"ins",[]),we(this,"outs",[])}static fromBuffer(t,r){const n=new Iv(t),i=new Qe;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===Qe.ADVANCED_TRANSACTION_MARKER&&s===Qe.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:Hp});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].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(t){return Qe.fromBuffer(zn(t),!1)}static isCoinbaseHash(t){at(Qd,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&Qe.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return at(In([Qd,Gn,yl(Ma(Gn)),yl(Ma(De))]),[t,r,n,i]),n==null&&(n=Qe.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||Pi,sequence:n,witness:Hp})-1}addOutput(t,r){return at(In([De,bl]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Br(this.ins.length)+Br(this.outs.length)+this.ins.reduce((n,i)=>n+40+xn(i.script),0)+this.outs.reduce((n,i)=>n+8+xn(i.script),0)+(r?this.ins.reduce((n,i)=>n+Lv(i.witness),0):0)}clone(){const t=new Qe;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(at(In([Gn,De,cr()]),[t,r,n]),t>=this.ins.length)return Kp;const i=ur(gt(r).filter(a=>a!==ze.OP_CODESEPARATOR)),o=this.clone();if((n&31)===Qe.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===Qe.SIGHASH_SINGLE){if(t>=this.outs.length)return Kp;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=Kv;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&Qe.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=Pi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Kd(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),os(s)}hashForWitnessV1(t,r,n,i,o,s){if(at(In([Gn,ar(De),ar(bl),Gn]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===Qe.SIGHASH_DEFAULT?Qe.SIGHASH_ALL:i&Qe.SIGHASH_OUTPUT_MASK,u=(i&Qe.SIGHASH_INPUT_MASK)===Qe.SIGHASH_ANYONECANPAY,f=a===Qe.SIGHASH_NONE,h=a===Qe.SIGHASH_SINGLE;let d=Pi,g=Pi,v=Pi,E=Pi,T=Pi;if(!u){let k=Vt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=Xt(k.end()),k=Vt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=Xt(k.end()),k=Vt.withCapacity(r.map(xn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=Xt(k.end()),k=Vt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=Xt(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=Vt.withCapacity(8+xn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=Xt(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+xn(z.script)).reduce((z,V)=>z+V),B=Vt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=Xt(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),O=Vt.withCapacity(N);if(O.writeUInt8(i),O.writeInt32(this.version),O.writeUInt32(this.locktime),O.writeSlice(d),O.writeSlice(g),O.writeSlice(v),O.writeSlice(E),f||h||O.writeSlice(T),O.writeUInt8(x),u){const k=this.ins[t];O.writeSlice(k.hash),O.writeUInt32(k.index),O.writeInt64(n[t]),O.writeVarSlice(r[t]),O.writeUInt32(k.sequence)}else O.writeUInt32(t);if(s){const k=Vt.withCapacity(xn(s));k.writeVarSlice(s),O.writeSlice(Xt(k.end()))}return h&&O.writeSlice(T),o&&(O.writeSlice(o),O.writeUInt8(0),O.writeUInt32(4294967295)),Ja("TapSighash",ot([Uint8Array.from([0]),O.end()]))}hashForWitnessV0(t,r,n,i){at(In([Gn,De,bl,Gn]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=Cl,u=Cl,f=Cl;if(i&Qe.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=os(o)),!(i&Qe.SIGHASH_ANYONECANPAY)&&(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new Vt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=os(o)),(i&31)!==Qe.SIGHASH_SINGLE&&(i&31)!==Qe.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+xn(v.script),0);o=new Uint8Array(d),s=new Vt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=os(o)}else if((i&31)===Qe.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+xn(d.script)),s=new Vt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=os(o)}o=new Uint8Array(156+xn(r)),s=new Vt(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),os(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):os(this.__toBuffer(void 0,void 0,t))}getId(){return ve(Il(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return ve(this.toBuffer(void 0,void 0))}setInputScript(t,r){at(In([cr(),De]),[t,r]),this.ins[t].script=r}setWitness(t,r){at(In([cr(),ar(De)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new Vt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(Qe.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(Qe.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{jv(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};we(an,"DEFAULT_SEQUENCE",4294967295),we(an,"SIGHASH_DEFAULT",0),we(an,"SIGHASH_ALL",1),we(an,"SIGHASH_NONE",2),we(an,"SIGHASH_SINGLE",3),we(an,"SIGHASH_ANYONECANPAY",128),we(an,"SIGHASH_OUTPUT_MASK",3),we(an,"SIGHASH_INPUT_MASK",128),we(an,"ADVANCED_TRANSACTION_MARKER",0),we(an,"ADVANCED_TRANSACTION_FLAG",1);let At=an;var $n;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})($n||($n={}));var ie;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(ie||(ie={}));var St;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(St||(St={}));const Dv=e=>[...Array(e).keys()];function Mv(e){if(e.key[0]!==$n.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+ve(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+ve(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of Dv(e.value.length/4-1)){const i=Us(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function Fv(e){const t=new Uint8Array([$n.GLOBAL_XPUB]),r=ot([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),So(i,o,u,"LE"),o+=4}),{key:r,value:i}}const Vv="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function Wv(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function zv(e,t,r){const n=ve(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.extendedPubkey,t.extendedPubkey)).length===0)}const qv=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:zv,check:Wv,decode:Mv,encode:Fv,expected:Vv},Symbol.toStringTag,{value:"Module"}));function Gv(e){return{key:new Uint8Array([$n.UNSIGNED_TX]),value:e.toBuffer()}}const Xv=Object.freeze(Object.defineProperty({__proto__:null,encode:Gv},Symbol.toStringTag,{value:"Module"}));function Jv(e){if(e.key[0]!==ie.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+ve(e.key));return e.value}function Yv(e){return{key:new Uint8Array([ie.FINAL_SCRIPTSIG]),value:e}}const Zv="Uint8Array";function Qv(e){return e instanceof Uint8Array}function eE(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const tE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:eE,check:Qv,decode:Jv,encode:Yv,expected:Zv},Symbol.toStringTag,{value:"Module"}));function rE(e){if(e.key[0]!==ie.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+ve(e.key));return e.value}function nE(e){return{key:new Uint8Array([ie.FINAL_SCRIPTWITNESS]),value:e}}const iE="Uint8Array";function sE(e){return e instanceof Uint8Array}function oE(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const aE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:oE,check:sE,decode:rE,encode:nE,expected:iE},Symbol.toStringTag,{value:"Module"}));function cE(e){if(e.key[0]!==ie.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+ve(e.key));return e.value}function uE(e){return{key:new Uint8Array([ie.NON_WITNESS_UTXO]),value:e}}const lE="Uint8Array";function hE(e){return e instanceof Uint8Array}function fE(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const dE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fE,check:hE,decode:cE,encode:uE,expected:lE},Symbol.toStringTag,{value:"Module"}));function pE(e){if(e.key[0]!==ie.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+ve(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+ve(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function yE(e){const t=new Uint8Array([ie.PARTIAL_SIG]);return{key:ot([t,e.pubkey]),value:e.signature}}const gE="{ pubkey: Uint8Array; signature: Uint8Array; }";function wE(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&bE(e.signature)}function bE(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function mE(e,t,r){const n=ve(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0).length===0)}const vE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:mE,check:wE,decode:pE,encode:yE,expected:gE},Symbol.toStringTag,{value:"Module"}));function EE(e){if(e.key[0]!==ie.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+ve(e.key));return dm(e.value)}function AE(e){return{key:new Uint8Array([ie.POR_COMMITMENT]),value:pm(e)}}const SE="string";function TE(e){return typeof e=="string"}function _E(e,t){return!!e&&!!t&&e.porCommitment===void 0}const kE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:_E,check:TE,decode:EE,encode:AE,expected:SE},Symbol.toStringTag,{value:"Module"}));function PE(e){if(e.key[0]!==ie.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+ve(e.key));return Number(Us(e.value,0,"LE"))}function IE(e){const t=Uint8Array.from([ie.SIGHASH_TYPE]),r=new Uint8Array(4);return So(r,0,e,"LE"),{key:t,value:r}}const OE="number";function xE(e){return typeof e=="number"}function $E(e,t){return!!e&&!!t&&e.sighashType===void 0}const CE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$E,check:xE,decode:PE,encode:IE,expected:OE},Symbol.toStringTag,{value:"Module"}));function NE(e){if(e.key[0]!==ie.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+ve(e.key));if(!jp(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function UE(e){return{key:Uint8Array.from([ie.TAP_KEY_SIG]),value:e}}const RE="Uint8Array";function jp(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function BE(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const LE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:BE,check:jp,decode:NE,encode:UE,expected:RE},Symbol.toStringTag,{value:"Module"}));function HE(e){if(e.key[0]!==ie.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+ve(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+ve(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+ve(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function KE(e){const t=Uint8Array.from([ie.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:ot([t,e.controlBlock]),value:ot([e.script,r])}}const jE="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function DE(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ME(e,t,r){const n=ve(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.controlBlock,t.controlBlock)===0).length===0)}const FE=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ME,check:DE,decode:HE,encode:KE,expected:jE},Symbol.toStringTag,{value:"Module"}));function VE(e){if(e.key[0]!==ie.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+ve(e.key));if(!Dp(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function WE(e){return{key:Uint8Array.from([ie.TAP_MERKLE_ROOT]),value:e}}const zE="Uint8Array";function Dp(e){return e instanceof Uint8Array&&e.length===32}function qE(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const GE=Object.freeze(Object.defineProperty({__proto__:null,canAdd:qE,check:Dp,decode:VE,encode:WE,expected:zE},Symbol.toStringTag,{value:"Module"}));function XE(e){if(e.key[0]!==ie.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+ve(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+ve(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+ve(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function JE(e){const t=Uint8Array.from([ie.TAP_SCRIPT_SIG]);return{key:ot([t,e.pubkey,e.leafHash]),value:e.signature}}const YE="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function ZE(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function QE(e,t,r){const n=ve(t.pubkey)+ve(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>Q(i.pubkey,t.pubkey)===0&&Q(i.leafHash,t.leafHash)===0).length===0)}const eA=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:QE,check:ZE,decode:XE,encode:JE,expected:YE},Symbol.toStringTag,{value:"Module"}));function tA(e){if(e.key[0]!==ie.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+ve(e.key));const t=Dd(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=Ks(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function rA(e){const{script:t,value:r}=e,n=Br(t.length),i=new Uint8Array(8+n+t.length);return jd(i,0,BigInt(r),"LE"),ki(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([ie.WITNESS_UTXO]),value:i}}const nA="{ script: Uint8Array; value: bigint; }";function iA(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function sA(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const oA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:sA,check:iA,decode:tA,encode:rA,expected:nA},Symbol.toStringTag,{value:"Module"}));function aA(e){if(e.key[0]!==St.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+ve(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=Ks(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function cA(e){const t=Uint8Array.from([St.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),ki(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:ot(r)}}const uA="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function lA(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function hA(e,t){return!!e&&!!t&&e.tapTree===void 0}const fA=Object.freeze(Object.defineProperty({__proto__:null,canAdd:hA,check:lA,decode:aA,encode:cA,expected:uA},Symbol.toStringTag,{value:"Module"})),dA=e=>[...Array(e).keys()],pA=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Nl(e,t=pA){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+ve(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+ve(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of dA(a.value.length/4-1)){const d=Us(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=ot([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),So(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=ve(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>Q(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Ul(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+ve(r.key));return n}}function Mp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const yA=e=>e.length===32;function Fp(e){const t=Nl(e,yA);function r(s){const{numberValue:a,bytes:u}=Ks(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Br(s.leafHashes.length),f=new Uint8Array(u);ki(s.leafHashes.length,f);const h=ot([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function Vp(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+ve(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function Wp(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+ve(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Rl={unsignedTx:Xv,globalXpub:qv,checkPubkey:Ul([])},Ct={nonWitnessUtxo:dE,partialSig:vE,sighashType:CE,finalScriptSig:tE,finalScriptWitness:aE,porCommitment:kE,witnessUtxo:oA,bip32Derivation:Nl(ie.BIP32_DERIVATION),redeemScript:Mp(ie.REDEEM_SCRIPT),witnessScript:Wp(ie.WITNESS_SCRIPT),checkPubkey:Ul([ie.PARTIAL_SIG,ie.BIP32_DERIVATION]),tapKeySig:LE,tapScriptSig:eA,tapLeafScript:FE,tapBip32Derivation:Fp(ie.TAP_BIP32_DERIVATION),tapInternalKey:Vp(ie.TAP_INTERNAL_KEY),tapMerkleRoot:GE},Qn={bip32Derivation:Nl(St.BIP32_DERIVATION),redeemScript:Mp(St.REDEEM_SCRIPT),witnessScript:Wp(St.WITNESS_SCRIPT),checkPubkey:Ul([St.BIP32_DERIVATION]),tapBip32Derivation:Fp(St.TAP_BIP32_DERIVATION),tapTree:fA,tapInternalKey:Vp(St.TAP_INTERNAL_KEY)},gA=Object.freeze(Object.defineProperty({__proto__:null,globals:Rl,inputs:Ct,outputs:Qn},Symbol.toStringTag,{value:"Module"})),tc=e=>[...Array(e).keys()];function zp(e){const t=e.map(wA);return t.push(Uint8Array.from([0])),ot(t)}function wA(e){const t=e.key.length,r=e.value.length,n=Br(t),i=Br(r),o=new Uint8Array(n+t+i+r);return ki(t,o,0),o.set(e.key,n),ki(r,o,n+t),o.set(e.value,n+t+i),o}function bA(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=Ks(e,r);r+=N;const O=e.slice(r,r+Number(x));return r+=Number(x),O}function i(){const x=Us(e,r,"BE");return r+=4,x}function o(){const x=qn(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=qn(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=ve(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===$n.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of tc(g)){const N={},O=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,O.push(k)}E.push(O)}for(const x of tc(v)){const N={},O=[];for(;!a();){const k=s(),B=ve(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,O.push(k)}T.push(O)}return qp(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Wt(e,t,r){if(Q(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${ve(t)}`)}function qp(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case $n.UNSIGNED_TX:if(Wt("global",h.key,$n.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case $n.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Rl.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of tc(s)){const d={};for(const g of r[h])switch(Ct.checkPubkey(g),g.key[0]){case ie.NON_WITNESS_UTXO:if(Wt("input",g.key,ie.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Ct.nonWitnessUtxo.decode(g);break;case ie.WITNESS_UTXO:if(Wt("input",g.key,ie.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Ct.witnessUtxo.decode(g);break;case ie.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Ct.partialSig.decode(g));break;case ie.SIGHASH_TYPE:if(Wt("input",g.key,ie.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Ct.sighashType.decode(g);break;case ie.REDEEM_SCRIPT:if(Wt("input",g.key,ie.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Ct.redeemScript.decode(g);break;case ie.WITNESS_SCRIPT:if(Wt("input",g.key,ie.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Ct.witnessScript.decode(g);break;case ie.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Ct.bip32Derivation.decode(g));break;case ie.FINAL_SCRIPTSIG:Wt("input",g.key,ie.FINAL_SCRIPTSIG),d.finalScriptSig=Ct.finalScriptSig.decode(g);break;case ie.FINAL_SCRIPTWITNESS:Wt("input",g.key,ie.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Ct.finalScriptWitness.decode(g);break;case ie.POR_COMMITMENT:Wt("input",g.key,ie.POR_COMMITMENT),d.porCommitment=Ct.porCommitment.decode(g);break;case ie.TAP_KEY_SIG:Wt("input",g.key,ie.TAP_KEY_SIG),d.tapKeySig=Ct.tapKeySig.decode(g);break;case ie.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Ct.tapScriptSig.decode(g));break;case ie.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Ct.tapLeafScript.decode(g));break;case ie.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Ct.tapBip32Derivation.decode(g));break;case ie.TAP_INTERNAL_KEY:Wt("input",g.key,ie.TAP_INTERNAL_KEY),d.tapInternalKey=Ct.tapInternalKey.decode(g);break;case ie.TAP_MERKLE_ROOT:Wt("input",g.key,ie.TAP_MERKLE_ROOT),d.tapMerkleRoot=Ct.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of tc(a)){const d={};for(const g of n[h])switch(Qn.checkPubkey(g),g.key[0]){case St.REDEEM_SCRIPT:if(Wt("output",g.key,St.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=Qn.redeemScript.decode(g);break;case St.WITNESS_SCRIPT:if(Wt("output",g.key,St.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=Qn.witnessScript.decode(g);break;case St.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Qn.bip32Derivation.decode(g));break;case St.TAP_INTERNAL_KEY:Wt("output",g.key,St.TAP_INTERNAL_KEY),d.tapInternalKey=Qn.tapInternalKey.decode(g);break;case St.TAP_TREE:Wt("output",g.key,St.TAP_TREE),d.tapTree=Qn.tapTree.decode(g);break;case St.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Qn.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function mA({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=Ll({globalMap:e,inputs:t,outputs:r}),s=zp(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(zp),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),ot([h,s].concat(u,f))}const vA=(e,t)=>Q(e.key,t.key);function Bl(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>ve(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(ve(o.key))):[];return n.concat(i).sort(vA)}function Ll({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Bl(e,Rl),inputKeyVals:t.map(n=>Bl(n,Ct)),outputKeyVals:r.map(n=>Bl(n,Qn))}}function EA(e){const t=e[0],r=Ll(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Gp(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=js(r.globalKeyVals),s=r.inputKeyVals.map(js),a=r.outputKeyVals.map(js);for(const u of n){const f=Gp(u);if(f===void 0||Q(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=Ll(u);js(h.globalKeyVals).forEach(Hl(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(js).forEach((d,g)=>d.forEach(Hl(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return qp(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function Hl(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>ve(o.key)===n)[0];t.push(i),e.add(n)}}function Gp(e){return e.globalMap.unsignedTx}function js(e){const t=new Set;return e.forEach(r=>{const n=ve(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function Kt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function Lo(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Kl(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>Q(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${ve(e.key)}`)}function jl(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function AA(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function Xp(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Dl(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=gA[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||Xp(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||Xp(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const SA=Dl("global"),Jp=Dl("input"),Yp=Dl("output");function TA(e,t){const r=e.length-1,n=Kt(e,r);Jp(t,n)}function _A(e,t){const r=e.length-1,n=Lo(e,r);Yp(t,n)}let Zp=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,r){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r){const n=bA(t,r),i=new this(n.globalMap.unsignedTx);return Object.assign(i,n),i}toBase64(){const t=this.toBuffer();return wm(t)}toHex(){const t=this.toBuffer();return ve(t)}toBuffer(){return mA(this)}updateGlobal(t){return SA(t,this.globalMap),this}updateInput(t,r){const n=Kt(this.inputs,t);return Jp(r,n),this}updateOutput(t,r){const n=Lo(this.outputs,t);return Yp(r,n),this}addUnknownKeyValToGlobal(t){return Kl(t,this.globalMap.unknownKeyVals,jl($n)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,r){const n=Kt(this.inputs,t);return Kl(r,n.unknownKeyVals,jl(ie)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addUnknownKeyValToOutput(t,r){const n=Lo(this.outputs,t);return Kl(r,n.unknownKeyVals,jl(St)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(r),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.inputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToInput(n,i)),TA(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const r=t.unknownKeyVals||[],n=this.outputs.length-1;if(!Array.isArray(r))throw new Error("unknownKeyVals must be an Array");return r.forEach(i=>this.addUnknownKeyValToOutput(n,i)),_A(this.outputs,t),this}clearFinalizedInput(t){const r=Kt(this.inputs,t);AA(t,r);for(const n of Object.keys(r))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(n)||delete r[n];return this}combine(...t){const r=EA([this].concat(t));return Object.assign(this,r),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function as(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const kA=as(qa),PA=as(lp),IA=as(Io),rc=as(Co),Qp=as(No),e0=as(Ls),t0=as(Ro);function nc(e){let t=new Uint8Array(0);function r(s){t=ot([t,s])}function n(s){const a=t.length,u=Br(s);t=ot([t,new Uint8Array(u)]),ki(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function r0(e,t){const r=Jn(e),n=e.slice(1,33),i=gt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:Q(e,o)===0||Q(r,o)===0||Q(n,o)===0)}function ic(e,t){return r0(e,t)!==-1}function OA(e,t){return xA(e).some(r=>n0(r,ko.decode,t))}function n0(e,t,r){const{hashType:n}=t(e),i=[];switch(n&At.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case At.SIGHASH_ALL:break;case At.SIGHASH_SINGLE:case At.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function xA(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=$A(e)}else t=e.partialSig;return t.map(r=>r.signature)}function $A(e){const t=e.finalScriptSig?gt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?gt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&Xn(n)).map(n=>({signature:n}))}const sc=e=>e.length===32?e:e.slice(1,33);function i0(e,t,r){const n=WA(t,e,r);try{const i=FA(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:nc(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function oc(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return ot([e,r])}function cn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&t0(e.witnessUtxo.script))}function Ml(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function s0(e,t,r){jA(e,t,r),MA(e,t,r)}function o0(e,t,r){DA(e,t,r),CA(e,t)}function CA(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=NA(r,n);if(i&&Q(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function NA(e,t){const r=t&&UA(t.leaves),{output:n}=Ro({internalPubkey:e,scriptTree:r});return n}function UA(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:KA(e)}function RA(e,t){return LA(e).some(r=>n0(r,BA,t))}function BA(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||At.SIGHASH_DEFAULT}}function LA(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=HA(e.finalScriptWitness);r&&t.push(r)}return t}function HA(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function KA(e){let t;for(const r of e)if(t=Fl(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function Fl(e,t,r=0){if(r>Ov)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(wl(t))return;const n=Fl(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Fl(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function jA(e,t,r){const n=cn(e)&&Ds(t),i=Ds(e)&&cn(t),o=e===t&&cn(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function DA(e,t,r){const n=Ml(e)&&Ds(t),i=Ds(e)&&Ml(t),o=e===t&&Ml(t)&&Ds(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function MA(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Vl(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Vl(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Vl(e,t){if(!t)return!0;const r=Zn({output:e.script,version:e.leafVersion}),n=Ol(e.controlBlock,r);return Q(n,t)===0}function FA(e,t){const r=Zn({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>Q(n.leafHash,r)===0).map(n=>VA(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function VA(e,t){return Object.assign({positionInScript:r0(t.pubkey,e)},t)}function WA(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>zA(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function zA(e,t,r){const n=Zn({output:e.script,version:e.leafVersion});return(!r||Q(n,r)===0)&&t.find(i=>Q(i.leafHash,n)===0)!==void 0}function Ds(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const qA={network:nn,maximumFeeRate:5e3};let Nt=class $d{constructor(t={},r=new Zp(new a0)){we(this,"data"),we(this,"__CACHE"),we(this,"opts"),this.data=r,this.opts=Object.assign({},qA,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},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Hd(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=zn(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=Zp.fromBuffer(t,GA),i=new $d(r,n);return QA(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:kp(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=Bo(t.script,this.opts.network)}catch{}return{script:kp(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=$d.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){ac(t),this.opts.maximumFeeRate=t}setVersion(t){ac(t),Ho(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){ac(t),Ho(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){ac(r),Ho(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");s0(t,t,"addInput"),Ho(this.data.inputs,"addInput"),t.witnessScript&&lc(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];f0(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&ql(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");Ho(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=Lp(r,i);t=Object.assign({},t,{script:o})}o0(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(u0))throw new Error("Not finalized");const r=this.__CACHE;if(t||JA(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return T0(this.data.inputs,n,r,!0),n}getFeeRate(){return g0("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return g0("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=Kt(this.data.inputs,t);return cn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=i0){const i=Kt(this.data.inputs,t);if(cn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=e3){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=i3(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);YA(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=i0){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=Ro({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=nc(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=Kt(this.data.inputs,t),n=_0(t,r,this.__CACHE),i=uc(n,t,"input",r.redeemScript||u3(r.finalScriptSig),r.witnessScript||l3(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=P0(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=Kt(this.data.inputs,t);return a3(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=Kt(this.data.inputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=Lo(this.data.outputs,t);return c3(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=Lo(this.data.outputs,t),i=l0(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return Kt(this.data.inputs,0),Ko(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return cn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>Q(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=ko.decode(d.signature),{hash:v,script:E}=h!==g.hashType?b0(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,h0(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&sc(n);const a=n?zl(t,i,this.data.inputs,n,this.__CACHE):r3(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,v0(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>Q(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,v0(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[At.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[At.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of Ko(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[At.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return A0(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[At.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=A0(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of Ko(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:ko.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>oc(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:sc(n.publicKey),signature:oc(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=Kt(this.data.inputs,t);return cn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=Kt(this.data.inputs,t);if(cn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[At.SIGHASH_ALL]){const{hash:i,sighashType:o}=w0(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:ko.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[At.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:oc(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:sc(n.publicKey),signature:oc(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=zl(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${ve(n.publicKey)}`);return s}toBuffer(){return Wl(this.__CACHE),this.data.toBuffer()}toHex(){return Wl(this.__CACHE),this.data.toHex()}toBase64(){return Wl(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&lc(r.witnessScript),s0(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&ql(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return o0(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}};const GA=e=>new a0(e);let a0=class{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){we(this,"tx"),this.tx=At.fromBuffer(t),ZA(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?Il(zn(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}};function XA(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return c0(1,e.partialSig);case"multisig":const n=qa({output:t});return c0(n.m,e.partialSig,n.pubkeys);default:return!1}}function Wl(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function c0(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=h3(i);return t.find(s=>Q(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function u0(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function l0(e){return t=>!(Q(e.fingerprint,t.masterFingerprint)||Q(e.derivePath(t.path).publicKey,t.pubkey))}function ac(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function JA(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.`)}function Ho(e,t){e.forEach(r=>{if(cn(r)?RA(r,t):OA(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function YA(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=ko.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function h0(e,t,r){if(!ic(e,t))throw new Error(`Can not ${r} for this input with the key ${ve(e)}`)}function ZA(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function QA(e,t){e.ins.forEach(r=>{f0(t,r)})}function f0(e,t){const r=ve(Il(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function d0(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(Q(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const p0=d0(Ls,"Redeem script"),y0=d0(No,"Witness script");function g0(e,t,r,n){if(!r.every(u0))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),T0(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function e3(e,t,r,n,i,o){const s=P0(r);if(!XA(t,r,s))throw new Error(`Can not finalize input #${e}`);return t3(r,s,t.partialSig,n,i,o)}function t3(e,t,r,n,i,o){let s,a;const u=n3(e,t,r),f=o?No({redeem:u}):null,h=i?Ls({redeem:f||u}):null;return n?(f?a=nc(f.witness):a=nc(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function w0(e,t,r,n,i){const o=Kt(e,t),{hash:s,sighashType:a,script:u}=b0(t,o,n,!1,i);return h0(r,u,"sign"),{hash:s,sighashType:a}}function b0(e,t,r,n,i){const o=r.__TX,s=t.sighashType||At.SIGHASH_ALL;E0(s,i);let a,u;if(t.nonWitnessUtxo){const d=cc(r,t,e),g=o.ins[e].hash,v=d.getHash();if(Q(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=uc(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(rc(f)){const d=Io({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${ve(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&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.
4
4
  *********************
5
5
  PROCEED WITH CAUTION!
6
- *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function r3(e,t,r,n){const i=[];if(t.tapInternalKey){const o=v0(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>Jl(e,t,r,o,n)).flat()}function v0(e,t,r){const{script:n}=Zl(e,t,r);return r0(n)?n.subarray(2,34):null}function E0(e){return e.length===64?e:e.subarray(0,64)}function Jl(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||St.SIGHASH_DEFAULT;A0(u,s);const f=r.map((E,T)=>Zl(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=v0(e,t,i)||Uint8Array.from([]);if(Q(uc(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>cc(n,E.script)).map(E=>{const T=Qn({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||Q(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function A0(e,t){if(t&&t.indexOf(e)<0){const r=o3(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function n3(e,t,r){let n;switch(t){case"multisig":const i=s3(e,r);n=Ya({output:e,signatures:i});break;case"pubkey":n=hp({output:e,signature:r[0].signature});break;case"pubkeyhash":n=$o({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Ro({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function i3(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=fc(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||oc(i.script))&&(i.isSegwit=!0),i}function S0(e,t,r){const n=Kt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(Q(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(Q(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function s3(e,t){return Ya({output:e}).pubkeys.map(r=>(t.filter(n=>Q(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function T0(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=Ds(e,t);return t+=Br(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function o3(e){let t=e&St.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case St.SIGHASH_ALL:t+="SIGHASH_ALL";break;case St.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case St.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Yl(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=St.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 s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function _0(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=T0(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=fc(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),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(Number(s/BigInt(a)))}function fc(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Yl(e,t,r),n[r]}function k0(e,t,r){const{script:n}=Zl(e,t,r);return n}function Zl(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=fc(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function a3(e,t,r,n){const i=k0(r,t,n),{meaningfulScript:o}=dc(i,r,"input",t.redeemScript,t.witnessScript);return cc(e,o)}function c3(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=dc(i,r,"output",t.redeemScript,t.witnessScript);return cc(e,o)}function u3(e){if(!e)return;const t=bt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||P0(r)||f3(r)||!bt(r)))return r}function l3(e){if(!e)return;const t=T0(e),r=t[t.length-1];if(!(P0(r)||!bt(r)))return r}function h3(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function P0(e){return e.length===33&&jm(e)}function f3(e){return Jn(e)}function dc(e,t,r,n,i){const o=t0(e),s=o&&n&&e0(n),a=e0(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,y0(t,e,n,r),g0(t,n,i,r),pc(u)):a?(u=i,g0(t,e,i,r),pc(u)):o?(u=n,y0(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function pc(e){if(oc(e)||t0(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function O0(e){return oc(e)?"witnesspubkeyhash":OA(e)?"pubkeyhash":kA(e)?"multisig":PA(e)?"pubkey":"nonstandard"}function Mo(e){return[...Array(e).keys()]}const Hr=new Error("The connected wallet doesn't support this method..."),I0=new Error("Wallet is not installed");let ln=class{constructor(t,r,n){de(this,"$store"),de(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),Hr}};const d3="Mainnet",yc="BITCOIN_MAINNET",Ql="BITCOIN_TESTNET",eh="BITCOIN_TESTNET4",th="BITCOIN_SIGNET",rh="FRACTAL_BITCOIN_MAINNET",nh="FRACTAL_BITCOIN_TESTNET",p3="livenet",y3="testnet",gc="Mainnet",ih="Testnet",x0="Signet",$0="livenet",C0="testnet",Fo="livenet",wc="testnet",sh="testnet4",oh="signet",ah="Mainnet",N0="Testnet",bc="mainnet",ch="testnet",tt="mainnet",Yt="signet",it="testnet",Zt="testnet4",ls="fractal mainnet",Qt="fractal testnet",g3="regtest",Vs=e=>e===tt?gc:e===it?ih:e===Yt?x0:gc,w3=e=>e===tt?bc:e===it?ch:bc,mc=e=>e===tt?yc:e===it?Ql:e===Zt?eh:e===Yt?th:e===ls?rh:e===Qt?nh:yc,b3=e=>e===tt?Fo:e===it?wc:e===Zt?sh:e===Yt?oh:e===Qt?wc:Fo,Vo=e=>e===tt?ah:e===it?N0:ah,zs=e=>e===yc?tt:e===Ql?it:e===eh?Zt:e===th?Yt:e===rh?ls:e===nh?Qt:tt,m3=e=>e===gc?tt:e===ih?it:tt,v3=e=>e===bc?tt:e===ch?it:tt,U0=e=>e===$0?tt:e===C0?it:tt,uh=e=>e===Fo?tt:e===wc?it:e===sh?Zt:e===oh?Yt:e===Qt?it:tt;function R0(e,t){return function(){return e.apply(t,arguments)}}const{toString:E3}=Object.prototype,{getPrototypeOf:lh}=Object,vc=(e=>t=>{const r=E3.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),hn=e=>(e=e.toLowerCase(),t=>vc(t)===e),Ec=e=>t=>typeof t===e,{isArray:Ws}=Array,zo=Ec("undefined");function A3(e){return e!==null&&!zo(e)&&e.constructor!==null&&!zo(e.constructor)&&kr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const B0=hn("ArrayBuffer");function S3(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&B0(e.buffer),t}const T3=Ec("string"),kr=Ec("function"),H0=Ec("number"),Ac=e=>e!==null&&typeof e=="object",_3=e=>e===!0||e===!1,Sc=e=>{if(vc(e)!=="object")return!1;const t=lh(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},k3=hn("Date"),P3=hn("File"),O3=hn("Blob"),I3=hn("FileList"),x3=e=>Ac(e)&&kr(e.pipe),$3=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||kr(e.append)&&((t=vc(e))==="formdata"||t==="object"&&kr(e.toString)&&e.toString()==="[object FormData]"))},C3=hn("URLSearchParams"),[N3,U3,R3,B3]=["ReadableStream","Request","Response","Headers"].map(hn),H3=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Wo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Ws(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function L0(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const hs=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,K0=e=>!zo(e)&&e!==hs;function hh(){const{caseless:e}=K0(this)&&this||{},t={},r=(n,i)=>{const o=e&&L0(t,i)||i;Sc(t[o])&&Sc(n)?t[o]=hh(t[o],n):Sc(n)?t[o]=hh({},n):Ws(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Wo(arguments[n],r);return t}const L3=(e,t,r,{allOwnKeys:n}={})=>(Wo(t,(i,o)=>{r&&kr(i)?e[o]=R0(i,r):e[o]=i},{allOwnKeys:n}),e),K3=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j3=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},D3=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&lh(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},M3=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},F3=e=>{if(!e)return null;if(Ws(e))return e;let t=e.length;if(!H0(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},V3=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&lh(Uint8Array)),z3=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},W3=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},q3=hn("HTMLFormElement"),G3=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),j0=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),X3=hn("RegExp"),D0=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Wo(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},J3=e=>{D0(e,(t,r)=>{if(kr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(kr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Ws(e)?n(e):n(String(e).split(t)),r},Z3=()=>{},Q3=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,fh="abcdefghijklmnopqrstuvwxyz",M0="0123456789",F0={DIGIT:M0,ALPHA:fh,ALPHA_DIGIT:fh+fh.toUpperCase()+M0},e4=(e=16,t=F0.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function t4(e){return!!(e&&kr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const r4=e=>{const t=new Array(10),r=(n,i)=>{if(Ac(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=Ws(n)?[]:{};return Wo(n,(s,a)=>{const u=r(s,i+1);!zo(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},n4=hn("AsyncFunction"),i4=e=>e&&(Ac(e)||kr(e))&&kr(e.then)&&kr(e.catch),V0=((e,t)=>e?setImmediate:t?((r,n)=>(hs.addEventListener("message",({source:i,data:o})=>{i===hs&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),hs.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",kr(hs.postMessage)),s4=typeof queueMicrotask<"u"?queueMicrotask.bind(hs):typeof process<"u"&&process.nextTick||V0,D={isArray:Ws,isArrayBuffer:B0,isBuffer:A3,isFormData:$3,isArrayBufferView:S3,isString:T3,isNumber:H0,isBoolean:_3,isObject:Ac,isPlainObject:Sc,isReadableStream:N3,isRequest:U3,isResponse:R3,isHeaders:B3,isUndefined:zo,isDate:k3,isFile:P3,isBlob:O3,isRegExp:X3,isFunction:kr,isStream:x3,isURLSearchParams:C3,isTypedArray:V3,isFileList:I3,forEach:Wo,merge:hh,extend:L3,trim:H3,stripBOM:K3,inherits:j3,toFlatObject:D3,kindOf:vc,kindOfTest:hn,endsWith:M3,toArray:F3,forEachEntry:z3,matchAll:W3,isHTMLForm:q3,hasOwnProperty:j0,hasOwnProp:j0,reduceDescriptors:D0,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Z3,toFiniteNumber:Q3,findKey:L0,global:hs,isContextDefined:K0,ALPHABET:F0,generateString:e4,isSpecCompliantForm:t4,toJSONObject:r4,isAsyncFn:n4,isThenable:i4,setImmediate:V0,asap:s4};function Ie(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}D.inherits(Ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}});const z0=Ie.prototype,W0={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{W0[e]={value:e}}),Object.defineProperties(Ie,W0),Object.defineProperty(z0,"isAxiosError",{value:!0}),Ie.from=(e,t,r,n,i,o)=>{const s=Object.create(z0);return D.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),Ie.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const o4=null;function dh(e){return D.isPlainObject(e)||D.isArray(e)}function q0(e){return D.endsWith(e,"[]")?e.slice(0,-2):e}function G0(e,t,r){return e?e.concat(t).map(function(n,i){return n=q0(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function a4(e){return D.isArray(e)&&!e.some(dh)}const c4=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function Tc(e,t,r){if(!D.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=D.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!D.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(D.isDate(v))return v.toISOString();if(!a&&D.isBlob(v))throw new Ie("Blob is not supported. Use a Buffer instead.");return D.isArrayBuffer(v)||D.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(D.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(D.isArray(v)&&a4(v)||(D.isFileList(v)||D.endsWith(E,"[]"))&&(x=D.toArray(v)))return E=q0(E),x.forEach(function(N,I){!(D.isUndefined(N)||N===null)&&t.append(s===!0?G0([E],I,o):s===null?E:E+"[]",u(N))}),!1}return dh(v)?!0:(t.append(G0(T,E,o),u(v)),!1)}const h=[],d=Object.assign(c4,{defaultVisitor:f,convertValue:u,isVisitable:dh});function g(v,E){if(!D.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),D.forEach(v,function(T,x){(!(D.isUndefined(T)||T===null)&&i.call(t,T,D.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!D.isObject(e))throw new TypeError("data must be an object");return g(e),t}function X0(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ph(e,t){this._pairs=[],e&&Tc(e,this,t)}const J0=ph.prototype;J0.append=function(e,t){this._pairs.push([e,t])},J0.toString=function(e){const t=e?function(r){return e.call(this,r,X0)}:X0;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function u4(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Y0(e,t,r){if(!t)return e;const n=r&&r.encode||u4,i=r&&r.serialize;let o;if(i?o=i(t,r):o=D.isURLSearchParams(t)?t.toString():new ph(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}let Z0=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){D.forEach(this.handlers,function(r){r!==null&&t(r)})}};const Q0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},l4=typeof URLSearchParams<"u"?URLSearchParams:ph,h4=typeof FormData<"u"?FormData:null,f4=typeof Blob<"u"?Blob:null,d4={isBrowser:!0,classes:{URLSearchParams:l4,FormData:h4,Blob:f4},protocols:["http","https","file","blob","url","data"]},yh=typeof window<"u"&&typeof document<"u",gh=typeof navigator=="object"&&navigator||void 0,p4=yh&&(!gh||["ReactNative","NativeScript","NS"].indexOf(gh.product)<0),y4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",g4=yh&&window.location.href||"http://localhost",w4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yh,hasStandardBrowserEnv:p4,hasStandardBrowserWebWorkerEnv:y4,navigator:gh,origin:g4},Symbol.toStringTag,{value:"Module"})),lr={...w4,...d4};function b4(e,t){return Tc(e,new lr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return lr.isNode&&D.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function m4(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function v4(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function ey(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&D.isArray(i)?i.length:s,u?(D.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!D.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&D.isArray(i[s])&&(i[s]=v4(i[s])),!a)}if(D.isFormData(e)&&D.isFunction(e.entries)){const r={};return D.forEachEntry(e,(n,i)=>{t(m4(n),i,r,0)}),r}return null}function E4(e,t,r){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const qo={transitional:Q0,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return n?JSON.stringify(ey(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return b4(e,this.formSerializer).toString();if((o=D.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Tc(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),E4(e)):e}],transformResponse:[function(e){const t=this.transitional||qo.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Ie.from(o,Ie.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lr.classes.FormData,Blob:lr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};D.forEach(["delete","get","head","post","put","patch"],e=>{qo.headers[e]={}});const A4=D.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),S4=e=>{const t={};let r,n,i;return e&&e.split(`
7
- `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&A4[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},ty=Symbol("internals");function Go(e){return e&&String(e).trim().toLowerCase()}function _c(e){return e===!1||e==null?e:D.isArray(e)?e.map(_c):String(e)}function T4(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const _4=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function wh(e,t,r,n,i){if(D.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!D.isString(t)){if(D.isString(n))return t.indexOf(n)!==-1;if(D.isRegExp(n))return n.test(t)}}function k4(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function P4(e,t){const r=D.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}let hr=class{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=Go(u);if(!h)throw new Error("header name must be a non-empty string");const d=D.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=_c(a))}const s=(a,u)=>D.forEach(a,(f,h)=>o(f,h,u));if(D.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(D.isString(t)&&(t=t.trim())&&!_4(t))s(S4(t),r);else if(D.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Go(t),t){const n=D.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return T4(i);if(D.isFunction(r))return r.call(this,i,n);if(D.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Go(t),t){const n=D.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||wh(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Go(s),s){const a=D.findKey(n,s);a&&(!r||wh(n,n[a],a,r))&&(delete n[a],i=!0)}}return D.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||wh(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return D.forEach(this,(i,o)=>{const s=D.findKey(n,o);if(s){r[s]=_c(i),delete r[o];return}const a=t?k4(o):String(o).trim();a!==o&&delete r[o],r[a]=_c(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return D.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&D.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
8
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[ty]=this[ty]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Go(o);r[s]||(P4(n,o),r[s]=!0)}return D.isArray(t)?t.forEach(i):i(t),this}};hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),D.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),D.freezeMethods(hr);function bh(e,t){const r=this||qo,n=t||r,i=hr.from(n.headers);let o=n.data;return D.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function ry(e){return!!(e&&e.__CANCEL__)}function qs(e,t,r){Ie.call(this,e??"canceled",Ie.ERR_CANCELED,t,r),this.name="CanceledError"}D.inherits(qs,Ie,{__CANCEL__:!0});function ny(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ie("Request failed with status code "+r.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function O4(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function I4(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function x4(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const kc=(e,t,r=3)=>{let n=0;const i=I4(50,250);return x4(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},iy=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},sy=e=>(...t)=>D.asap(()=>e(...t)),$4=lr.hasStandardBrowserEnv?function(){const e=lr.navigator&&/(msie|trident)/i.test(lr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=D.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),C4=lr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];D.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),D.isString(n)&&s.push("path="+n),D.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function N4(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function U4(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function oy(e,t){return e&&!N4(t)?U4(e,t):t}const ay=e=>e instanceof hr?{...e}:e;function fs(e,t){t=t||{};const r={};function n(f,h,d){return D.isPlainObject(f)&&D.isPlainObject(h)?D.merge.call({caseless:d},f,h):D.isPlainObject(h)?D.merge({},h):D.isArray(h)?h.slice():h}function i(f,h,d){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!D.isUndefined(h))return n(void 0,h)}function s(f,h){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(ay(f),ay(h),!0)};return D.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);D.isUndefined(d)&&h!==a||(r[f]=d)}),r}const cy=e=>{const t=fs({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=hr.from(s),t.url=Y0(oy(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(D.isFormData(r)){if(lr.hasStandardBrowserEnv||lr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(lr.hasStandardBrowserEnv&&(n&&D.isFunction(n)&&(n=n(t)),n||n!==!1&&$4(t.url))){const f=i&&o&&C4.read(o);f&&s.set(i,f)}return t},R4=typeof XMLHttpRequest<"u",B4=R4&&function(e){return new Promise(function(t,r){const n=cy(e);let i=n.data;const o=hr.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const I=hr.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:I,config:e,request:T};ny(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new Ie("Request aborted",Ie.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new Ie("Network Error",Ie.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let I=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||Q0;n.timeoutErrorMessage&&(I=n.timeoutErrorMessage),r(new Ie(I,k.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&D.forEach(o.toJSON(),function(I,k){T.setRequestHeader(k,I)}),D.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=kc(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=kc(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=I=>{T&&(r(!I||I.type?new qs(null,e,T):I),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=O4(n.url);if(N&&lr.protocols.indexOf(N)===-1){r(new Ie("Unsupported protocol "+N+":",Ie.ERR_BAD_REQUEST,e));return}T.send(i||null)})},H4=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof Ie?h:new qs(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new Ie(`timeout ${t} of ms exceeded`,Ie.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>D.asap(a),u}},L4=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},K4=async function*(e,t){for await(const r of j4(e))yield*L4(r,t)},j4=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},uy=(e,t,r,n)=>{const i=K4(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Pc=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ly=Pc&&typeof ReadableStream=="function",D4=Pc&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),hy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},M4=ly&&hy(()=>{let e=!1;const t=new Request(lr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),fy=64*1024,mh=ly&&hy(()=>D.isReadableStream(new Response("").body)),Oc={stream:mh&&(e=>e.body)};Pc&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Oc[t]&&(Oc[t]=D.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new Ie(`Response type '${t}' is not supported`,Ie.ERR_NOT_SUPPORT,n)})})})(new Response);const F4=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new Request(lr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e=e+""),D.isString(e))return(await D4(e)).byteLength},V4=async(e,t)=>D.toFiniteNumber(e.getContentLength())??F4(t),z4=Pc&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=cy(e);f=f?(f+"").toLowerCase():"text";let v=H4([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&M4&&r!=="get"&&r!=="head"&&(x=await V4(h,n))!==0){let W=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(D.isFormData(n)&&(V=W.headers.get("content-type"))&&h.setContentType(V),W.body){const[Ue,Le]=iy(x,kc(sy(u)));n=uy(W.body,fy,Ue,Le)}}D.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let I=await fetch(E);const k=mh&&(f==="stream"||f==="response");if(mh&&(a||k&&T)){const W={};["status","statusText","headers"].forEach(Je=>{W[Je]=I[Je]});const V=D.toFiniteNumber(I.headers.get("content-length")),[Ue,Le]=a&&iy(V,kc(sy(a),!0))||[];I=new Response(uy(I.body,fy,Ue,()=>{Le&&Le(),T&&T()}),W)}f=f||"text";let B=await Oc[D.findKey(Oc,f)||"text"](I,e);return!k&&T&&T(),await new Promise((W,V)=>{ny(W,V,{data:B,headers:hr.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,e,E),{cause:N.cause||N}):Ie.from(N,N&&N.code,e,E)}}),vh={http:o4,xhr:B4,fetch:z4};D.forEach(vh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const dy=e=>`- ${e}`,W4=e=>D.isFunction(e)||e===null||e===!1,py={getAdapter:e=>{e=D.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!W4(r)&&(n=vh[(s=String(r)).toLowerCase()],n===void 0))throw new Ie(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
9
- `+o.map(dy).join(`
10
- `):" "+dy(o[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:vh};function Eh(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new qs(null,e)}function yy(e){return Eh(e),e.headers=hr.from(e.headers),e.data=bh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),py.getAdapter(e.adapter||qo.adapter)(e).then(function(t){return Eh(e),t.data=bh.call(e,e.transformResponse,t),t.headers=hr.from(t.headers),t},function(t){return ry(t)||(Eh(e),t&&t.response&&(t.response.data=bh.call(e,e.transformResponse,t.response),t.response.headers=hr.from(t.response.headers))),Promise.reject(t)})}const gy="1.7.7",Ah={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ah[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const wy={};Ah.transitional=function(e,t,r){function n(i,o){return"[Axios v"+gy+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new Ie(n(o," has been removed"+(t?" in "+t:"")),Ie.ERR_DEPRECATED);return t&&!wy[o]&&(wy[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function q4(e,t,r){if(typeof e!="object")throw new Ie("options must be an object",Ie.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new Ie("option "+o+" must be "+u,Ie.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ie("Unknown option "+o,Ie.ERR_BAD_OPTION)}}const Sh={assertOptions:q4,validators:Ah},$i=Sh.validators;let ds=class{constructor(t){this.defaults=t,this.interceptors={request:new Z0,response:new Z0}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
11
- `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=fs(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&Sh.assertOptions(n,{silentJSONParsing:$i.transitional($i.boolean),forcedJSONParsing:$i.transitional($i.boolean),clarifyTimeoutError:$i.transitional($i.boolean)},!1),i!=null&&(D.isFunction(i)?r.paramsSerializer={serialize:i}:Sh.assertOptions(i,{encode:$i.function,serialize:$i.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&D.merge(o.common,o[r.method]);o&&D.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=hr.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[yy.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=yy.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=fs(this.defaults,t);const r=oy(t.baseURL,t.url);return Y0(r,t.params,t.paramsSerializer)}};D.forEach(["delete","get","head","options"],function(e){ds.prototype[e]=function(t,r){return this.request(fs(r||{},{method:e,url:t,data:(r||{}).data}))}}),D.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(fs(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ds.prototype[e]=t(),ds.prototype[e+"Form"]=t(!0)});let G4=class Jb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new qs(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Jb(function(r){t=r}),cancel:t}}};function X4(e){return function(t){return e.apply(null,t)}}function J4(e){return D.isObject(e)&&e.isAxiosError===!0}const Th={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Th).forEach(([e,t])=>{Th[t]=e});function by(e){const t=new ds(e),r=R0(ds.prototype.request,t);return D.extend(r,ds.prototype,t,{allOwnKeys:!0}),D.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return by(fs(e,n))},r}const qe=by(qo);qe.Axios=ds,qe.CanceledError=qs,qe.CancelToken=G4,qe.isCancel=ry,qe.VERSION=gy,qe.toFormData=Tc,qe.AxiosError=Ie,qe.Cancel=qe.CanceledError,qe.all=function(e){return Promise.all(e)},qe.spread=X4,qe.isAxiosError=J4,qe.mergeConfig=fs,qe.AxiosHeaders=hr,qe.formToJSON=e=>ey(D.isHTMLForm(e)?new FormData(e):e),qe.getAdapter=py.getAdapter,qe.HttpStatusCode=Th,qe.default=qe;var my={},Gs={};Gs.byteLength=Q4,Gs.toByteArray=tS,Gs.fromByteArray=iS;for(var Un=[],Lr=[],Y4=typeof Uint8Array<"u"?Uint8Array:Array,_h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xs=0,Z4=_h.length;Xs<Z4;++Xs)Un[Xs]=_h[Xs],Lr[_h.charCodeAt(Xs)]=Xs;Lr[45]=62,Lr[95]=63;function vy(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Q4(e){var t=vy(e),r=t[0],n=t[1];return(r+n)*3/4-n}function eS(e,t,r){return(t+r)*3/4-r}function tS(e){var t,r=vy(e),n=r[0],i=r[1],o=new Y4(eS(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Lr[e.charCodeAt(u)]<<18|Lr[e.charCodeAt(u+1)]<<12|Lr[e.charCodeAt(u+2)]<<6|Lr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Lr[e.charCodeAt(u)]<<2|Lr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Lr[e.charCodeAt(u)]<<10|Lr[e.charCodeAt(u+1)]<<4|Lr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function rS(e){return Un[e>>18&63]+Un[e>>12&63]+Un[e>>6&63]+Un[e&63]}function nS(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(rS(n));return i.join("")}function iS(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(nS(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Un[t>>2]+Un[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Un[t>>10]+Un[t>>4&63]+Un[t<<2&63]+"=")),i.join("")}var kh={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */kh.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},kh.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
6
+ *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function r3(e,t,r,n){const i=[];if(t.tapInternalKey){const o=m0(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>zl(e,t,r,o,n)).flat()}function m0(e,t,r){const{script:n}=Gl(e,t,r);return t0(n)?n.subarray(2,34):null}function v0(e){return e.length===64?e:e.subarray(0,64)}function zl(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||At.SIGHASH_DEFAULT;E0(u,s);const f=r.map((E,T)=>Gl(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=m0(e,t,i)||Uint8Array.from([]);if(Q(sc(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>ic(n,E.script)).map(E=>{const T=Zn({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||Q(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function E0(e,t){if(t&&t.indexOf(e)<0){const r=o3(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function n3(e,t,r){let n;switch(t){case"multisig":const i=s3(e,r);n=qa({output:e,signatures:i});break;case"pubkey":n=lp({output:e,signature:r[0].signature});break;case"pubkeyhash":n=Io({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Co({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function i3(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=cc(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||rc(i.script))&&(i.isSegwit=!0),i}function A0(e,t,r){const n=Kt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(Q(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(Q(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function s3(e,t){return qa({output:e}).pubkeys.map(r=>(t.filter(n=>Q(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function S0(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=Ks(e,t);return t+=Br(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function o3(e){let t=e&At.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case At.SIGHASH_ALL:t+="SIGHASH_ALL";break;case At.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case At.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function ql(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=At.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 s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function T0(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=S0(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=cc(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),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(Number(s/BigInt(a)))}function cc(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||ql(e,t,r),n[r]}function _0(e,t,r){const{script:n}=Gl(e,t,r);return n}function Gl(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=cc(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function a3(e,t,r,n){const i=_0(r,t,n),{meaningfulScript:o}=uc(i,r,"input",t.redeemScript,t.witnessScript);return ic(e,o)}function c3(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=uc(i,r,"output",t.redeemScript,t.witnessScript);return ic(e,o)}function u3(e){if(!e)return;const t=gt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||k0(r)||f3(r)||!gt(r)))return r}function l3(e){if(!e)return;const t=S0(e),r=t[t.length-1];if(!(k0(r)||!gt(r)))return r}function h3(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function k0(e){return e.length===33&&jm(e)}function f3(e){return Xn(e)}function uc(e,t,r,n,i){const o=e0(e),s=o&&n&&Qp(n),a=Qp(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,p0(t,e,n,r),y0(t,n,i,r),lc(u)):a?(u=i,y0(t,e,i,r),lc(u)):o?(u=n,p0(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function lc(e){if(rc(e)||e0(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function P0(e){return rc(e)?"witnesspubkeyhash":IA(e)?"pubkeyhash":kA(e)?"multisig":PA(e)?"pubkey":"nonstandard"}function Ko(e){return[...Array(e).keys()]}const Lr=new Error("The connected wallet doesn't support this method..."),I0=new Error("Wallet is not installed");let Cn=class{constructor(t,r,n){we(this,"$store"),we(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),Lr}};const d3="Mainnet",hc="BITCOIN_MAINNET",Xl="BITCOIN_TESTNET",Jl="BITCOIN_TESTNET4",Yl="BITCOIN_SIGNET",Zl="FRACTAL_BITCOIN_MAINNET",Ql="FRACTAL_BITCOIN_TESTNET",p3="livenet",y3="testnet",fc="Mainnet",eh="Testnet",O0="Signet",x0="livenet",$0="testnet",jo="livenet",dc="testnet",th="testnet4",rh="signet",nh="Mainnet",C0="Testnet",pc="mainnet",ih="testnet",tt="mainnet",Jt="signet",it="testnet",Yt="testnet4",cs="fractal mainnet",Zt="fractal testnet",g3="regtest",Ms=e=>e===tt?fc:e===it?eh:e===Jt?O0:fc,w3=e=>e===tt?pc:e===it?ih:pc,sh=e=>e===tt?hc:e===it?Xl:e===Yt?Jl:e===Jt?Yl:e===cs?Zl:e===Zt?Ql:hc,b3=e=>e===tt?jo:e===it?dc:e===Yt?th:e===Jt?rh:e===Zt?dc:jo,Do=e=>e===tt?nh:e===it?C0:nh,yc=e=>e===hc?tt:e===Xl?it:e===Jl?Yt:e===Yl?Jt:e===Zl?cs:e===Ql?Zt:tt,m3=e=>e===fc?tt:e===eh?it:tt,v3=e=>e===pc?tt:e===ih?it:tt,N0=e=>e===x0?tt:e===$0?it:tt,oh=e=>e===jo?tt:e===dc?it:e===th?Yt:e===rh?Jt:e===Zt?it:tt;function U0(e,t){return function(){return e.apply(t,arguments)}}const{toString:E3}=Object.prototype,{getPrototypeOf:ah}=Object,gc=(e=>t=>{const r=E3.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),un=e=>(e=e.toLowerCase(),t=>gc(t)===e),wc=e=>t=>typeof t===e,{isArray:Fs}=Array,Mo=wc("undefined");function A3(e){return e!==null&&!Mo(e)&&e.constructor!==null&&!Mo(e.constructor)&&kr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const R0=un("ArrayBuffer");function S3(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&R0(e.buffer),t}const T3=wc("string"),kr=wc("function"),B0=wc("number"),bc=e=>e!==null&&typeof e=="object",_3=e=>e===!0||e===!1,mc=e=>{if(gc(e)!=="object")return!1;const t=ah(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},k3=un("Date"),P3=un("File"),I3=un("Blob"),O3=un("FileList"),x3=e=>bc(e)&&kr(e.pipe),$3=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||kr(e.append)&&((t=gc(e))==="formdata"||t==="object"&&kr(e.toString)&&e.toString()==="[object FormData]"))},C3=un("URLSearchParams"),[N3,U3,R3,B3]=["ReadableStream","Request","Response","Headers"].map(un),L3=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Fo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Fs(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function L0(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,H0=e=>!Mo(e)&&e!==us;function ch(){const{caseless:e}=H0(this)&&this||{},t={},r=(n,i)=>{const o=e&&L0(t,i)||i;mc(t[o])&&mc(n)?t[o]=ch(t[o],n):mc(n)?t[o]=ch({},n):Fs(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Fo(arguments[n],r);return t}const H3=(e,t,r,{allOwnKeys:n}={})=>(Fo(t,(i,o)=>{r&&kr(i)?e[o]=U0(i,r):e[o]=i},{allOwnKeys:n}),e),K3=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j3=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},D3=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&ah(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},M3=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},F3=e=>{if(!e)return null;if(Fs(e))return e;let t=e.length;if(!B0(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},V3=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ah(Uint8Array)),W3=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},z3=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},q3=un("HTMLFormElement"),G3=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),K0=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),X3=un("RegExp"),j0=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Fo(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},J3=e=>{j0(e,(t,r)=>{if(kr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(kr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Fs(e)?n(e):n(String(e).split(t)),r},Z3=()=>{},Q3=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,uh="abcdefghijklmnopqrstuvwxyz",D0="0123456789",M0={DIGIT:D0,ALPHA:uh,ALPHA_DIGIT:uh+uh.toUpperCase()+D0},e4=(e=16,t=M0.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function t4(e){return!!(e&&kr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const r4=e=>{const t=new Array(10),r=(n,i)=>{if(bc(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=Fs(n)?[]:{};return Fo(n,(s,a)=>{const u=r(s,i+1);!Mo(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},n4=un("AsyncFunction"),i4=e=>e&&(bc(e)||kr(e))&&kr(e.then)&&kr(e.catch),F0=((e,t)=>e?setImmediate:t?((r,n)=>(us.addEventListener("message",({source:i,data:o})=>{i===us&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),us.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",kr(us.postMessage)),s4=typeof queueMicrotask<"u"?queueMicrotask.bind(us):typeof process<"u"&&process.nextTick||F0,D={isArray:Fs,isArrayBuffer:R0,isBuffer:A3,isFormData:$3,isArrayBufferView:S3,isString:T3,isNumber:B0,isBoolean:_3,isObject:bc,isPlainObject:mc,isReadableStream:N3,isRequest:U3,isResponse:R3,isHeaders:B3,isUndefined:Mo,isDate:k3,isFile:P3,isBlob:I3,isRegExp:X3,isFunction:kr,isStream:x3,isURLSearchParams:C3,isTypedArray:V3,isFileList:O3,forEach:Fo,merge:ch,extend:H3,trim:L3,stripBOM:K3,inherits:j3,toFlatObject:D3,kindOf:gc,kindOfTest:un,endsWith:M3,toArray:F3,forEachEntry:W3,matchAll:z3,isHTMLForm:q3,hasOwnProperty:K0,hasOwnProp:K0,reduceDescriptors:j0,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Z3,toFiniteNumber:Q3,findKey:L0,global:us,isContextDefined:H0,ALPHABET:M0,generateString:e4,isSpecCompliantForm:t4,toJSONObject:r4,isAsyncFn:n4,isThenable:i4,setImmediate:F0,asap:s4};function Oe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}D.inherits(Oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}});const V0=Oe.prototype,W0={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{W0[e]={value:e}}),Object.defineProperties(Oe,W0),Object.defineProperty(V0,"isAxiosError",{value:!0}),Oe.from=(e,t,r,n,i,o)=>{const s=Object.create(V0);return D.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),Oe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const o4=null;function lh(e){return D.isPlainObject(e)||D.isArray(e)}function z0(e){return D.endsWith(e,"[]")?e.slice(0,-2):e}function q0(e,t,r){return e?e.concat(t).map(function(n,i){return n=z0(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function a4(e){return D.isArray(e)&&!e.some(lh)}const c4=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function vc(e,t,r){if(!D.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=D.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!D.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(D.isDate(v))return v.toISOString();if(!a&&D.isBlob(v))throw new Oe("Blob is not supported. Use a Buffer instead.");return D.isArrayBuffer(v)||D.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(D.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(D.isArray(v)&&a4(v)||(D.isFileList(v)||D.endsWith(E,"[]"))&&(x=D.toArray(v)))return E=z0(E),x.forEach(function(N,O){!(D.isUndefined(N)||N===null)&&t.append(s===!0?q0([E],O,o):s===null?E:E+"[]",u(N))}),!1}return lh(v)?!0:(t.append(q0(T,E,o),u(v)),!1)}const h=[],d=Object.assign(c4,{defaultVisitor:f,convertValue:u,isVisitable:lh});function g(v,E){if(!D.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),D.forEach(v,function(T,x){(!(D.isUndefined(T)||T===null)&&i.call(t,T,D.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!D.isObject(e))throw new TypeError("data must be an object");return g(e),t}function G0(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function hh(e,t){this._pairs=[],e&&vc(e,this,t)}const X0=hh.prototype;X0.append=function(e,t){this._pairs.push([e,t])},X0.toString=function(e){const t=e?function(r){return e.call(this,r,G0)}:G0;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function u4(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function J0(e,t,r){if(!t)return e;const n=r&&r.encode||u4,i=r&&r.serialize;let o;if(i?o=i(t,r):o=D.isURLSearchParams(t)?t.toString():new hh(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}let Y0=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){D.forEach(this.handlers,function(r){r!==null&&t(r)})}};const Z0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},l4=typeof URLSearchParams<"u"?URLSearchParams:hh,h4=typeof FormData<"u"?FormData:null,f4=typeof Blob<"u"?Blob:null,d4={isBrowser:!0,classes:{URLSearchParams:l4,FormData:h4,Blob:f4},protocols:["http","https","file","blob","url","data"]},fh=typeof window<"u"&&typeof document<"u",dh=typeof navigator=="object"&&navigator||void 0,p4=fh&&(!dh||["ReactNative","NativeScript","NS"].indexOf(dh.product)<0),y4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",g4=fh&&window.location.href||"http://localhost",w4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:fh,hasStandardBrowserEnv:p4,hasStandardBrowserWebWorkerEnv:y4,navigator:dh,origin:g4},Symbol.toStringTag,{value:"Module"})),lr={...w4,...d4};function b4(e,t){return vc(e,new lr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return lr.isNode&&D.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function m4(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function v4(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function Q0(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&D.isArray(i)?i.length:s,u?(D.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!D.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&D.isArray(i[s])&&(i[s]=v4(i[s])),!a)}if(D.isFormData(e)&&D.isFunction(e.entries)){const r={};return D.forEachEntry(e,(n,i)=>{t(m4(n),i,r,0)}),r}return null}function E4(e,t,r){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const Vo={transitional:Z0,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return n?JSON.stringify(Q0(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return b4(e,this.formSerializer).toString();if((o=D.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return vc(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),E4(e)):e}],transformResponse:[function(e){const t=this.transitional||Vo.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Oe.from(o,Oe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lr.classes.FormData,Blob:lr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};D.forEach(["delete","get","head","post","put","patch"],e=>{Vo.headers[e]={}});const A4=D.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),S4=e=>{const t={};let r,n,i;return e&&e.split(`
7
+ `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&A4[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},ey=Symbol("internals");function Wo(e){return e&&String(e).trim().toLowerCase()}function Ec(e){return e===!1||e==null?e:D.isArray(e)?e.map(Ec):String(e)}function T4(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const _4=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ph(e,t,r,n,i){if(D.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!D.isString(t)){if(D.isString(n))return t.indexOf(n)!==-1;if(D.isRegExp(n))return n.test(t)}}function k4(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function P4(e,t){const r=D.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class hr{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=Wo(u);if(!h)throw new Error("header name must be a non-empty string");const d=D.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=Ec(a))}const s=(a,u)=>D.forEach(a,(f,h)=>o(f,h,u));if(D.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(D.isString(t)&&(t=t.trim())&&!_4(t))s(S4(t),r);else if(D.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return T4(i);if(D.isFunction(r))return r.call(this,i,n);if(D.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Wo(t),t){const n=D.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||ph(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Wo(s),s){const a=D.findKey(n,s);a&&(!r||ph(n,n[a],a,r))&&(delete n[a],i=!0)}}return D.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||ph(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return D.forEach(this,(i,o)=>{const s=D.findKey(n,o);if(s){r[s]=Ec(i),delete r[o];return}const a=t?k4(o):String(o).trim();a!==o&&delete r[o],r[a]=Ec(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return D.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&D.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
8
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[ey]=this[ey]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Wo(o);r[s]||(P4(n,o),r[s]=!0)}return D.isArray(t)?t.forEach(i):i(t),this}}hr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),D.reduceDescriptors(hr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),D.freezeMethods(hr);function yh(e,t){const r=this||Vo,n=t||r,i=hr.from(n.headers);let o=n.data;return D.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function ty(e){return!!(e&&e.__CANCEL__)}function Vs(e,t,r){Oe.call(this,e??"canceled",Oe.ERR_CANCELED,t,r),this.name="CanceledError"}D.inherits(Vs,Oe,{__CANCEL__:!0});function ry(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Oe("Request failed with status code "+r.status,[Oe.ERR_BAD_REQUEST,Oe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function I4(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function O4(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function x4(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Ac=(e,t,r=3)=>{let n=0;const i=O4(50,250);return x4(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},ny=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},iy=e=>(...t)=>D.asap(()=>e(...t)),$4=lr.hasStandardBrowserEnv?function(){const e=lr.navigator&&/(msie|trident)/i.test(lr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=D.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),C4=lr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];D.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),D.isString(n)&&s.push("path="+n),D.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function N4(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function U4(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function sy(e,t){return e&&!N4(t)?U4(e,t):t}const oy=e=>e instanceof hr?{...e}:e;function ls(e,t){t=t||{};const r={};function n(f,h,d){return D.isPlainObject(f)&&D.isPlainObject(h)?D.merge.call({caseless:d},f,h):D.isPlainObject(h)?D.merge({},h):D.isArray(h)?h.slice():h}function i(f,h,d){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!D.isUndefined(h))return n(void 0,h)}function s(f,h){if(D.isUndefined(h)){if(!D.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(oy(f),oy(h),!0)};return D.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);D.isUndefined(d)&&h!==a||(r[f]=d)}),r}const ay=e=>{const t=ls({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=hr.from(s),t.url=J0(sy(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(D.isFormData(r)){if(lr.hasStandardBrowserEnv||lr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(lr.hasStandardBrowserEnv&&(n&&D.isFunction(n)&&(n=n(t)),n||n!==!1&&$4(t.url))){const f=i&&o&&C4.read(o);f&&s.set(i,f)}return t},R4=typeof XMLHttpRequest<"u",B4=R4&&function(e){return new Promise(function(t,r){const n=ay(e);let i=n.data;const o=hr.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const O=hr.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:O,config:e,request:T};ry(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new Oe("Request aborted",Oe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new Oe("Network Error",Oe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let O=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||Z0;n.timeoutErrorMessage&&(O=n.timeoutErrorMessage),r(new Oe(O,k.clarifyTimeoutError?Oe.ETIMEDOUT:Oe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&D.forEach(o.toJSON(),function(O,k){T.setRequestHeader(k,O)}),D.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ac(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=Ac(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=O=>{T&&(r(!O||O.type?new Vs(null,e,T):O),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=I4(n.url);if(N&&lr.protocols.indexOf(N)===-1){r(new Oe("Unsupported protocol "+N+":",Oe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},L4=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof Oe?h:new Vs(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new Oe(`timeout ${t} of ms exceeded`,Oe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>D.asap(a),u}},H4=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},K4=async function*(e,t){for await(const r of j4(e))yield*H4(r,t)},j4=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},cy=(e,t,r,n)=>{const i=K4(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Sc=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",uy=Sc&&typeof ReadableStream=="function",D4=Sc&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),ly=(e,...t)=>{try{return!!e(...t)}catch{return!1}},M4=uy&&ly(()=>{let e=!1;const t=new Request(lr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),hy=64*1024,gh=uy&&ly(()=>D.isReadableStream(new Response("").body)),Tc={stream:gh&&(e=>e.body)};Sc&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Tc[t]&&(Tc[t]=D.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new Oe(`Response type '${t}' is not supported`,Oe.ERR_NOT_SUPPORT,n)})})})(new Response);const F4=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new Request(lr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e=e+""),D.isString(e))return(await D4(e)).byteLength},V4=async(e,t)=>D.toFiniteNumber(e.getContentLength())??F4(t),W4=Sc&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=ay(e);f=f?(f+"").toLowerCase():"text";let v=L4([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&M4&&r!=="get"&&r!=="head"&&(x=await V4(h,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(D.isFormData(n)&&(V=z.headers.get("content-type"))&&h.setContentType(V),z.body){const[Ue,He]=ny(x,Ac(iy(u)));n=cy(z.body,hy,Ue,He)}}D.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let O=await fetch(E);const k=gh&&(f==="stream"||f==="response");if(gh&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=O[Ge]});const V=D.toFiniteNumber(O.headers.get("content-length")),[Ue,He]=a&&ny(V,Ac(iy(a),!0))||[];O=new Response(cy(O.body,hy,Ue,()=>{He&&He(),T&&T()}),z)}f=f||"text";let B=await Tc[D.findKey(Tc,f)||"text"](O,e);return!k&&T&&T(),await new Promise((z,V)=>{ry(z,V,{data:B,headers:hr.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new Oe("Network Error",Oe.ERR_NETWORK,e,E),{cause:N.cause||N}):Oe.from(N,N&&N.code,e,E)}}),wh={http:o4,xhr:B4,fetch:W4};D.forEach(wh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const fy=e=>`- ${e}`,z4=e=>D.isFunction(e)||e===null||e===!1,dy={getAdapter:e=>{e=D.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!z4(r)&&(n=wh[(s=String(r)).toLowerCase()],n===void 0))throw new Oe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
9
+ `+o.map(fy).join(`
10
+ `):" "+fy(o[0]):"as no adapter specified";throw new Oe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:wh};function bh(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vs(null,e)}function py(e){return bh(e),e.headers=hr.from(e.headers),e.data=yh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),dy.getAdapter(e.adapter||Vo.adapter)(e).then(function(t){return bh(e),t.data=yh.call(e,e.transformResponse,t),t.headers=hr.from(t.headers),t},function(t){return ty(t)||(bh(e),t&&t.response&&(t.response.data=yh.call(e,e.transformResponse,t.response),t.response.headers=hr.from(t.response.headers))),Promise.reject(t)})}const yy="1.7.7",mh={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{mh[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const gy={};mh.transitional=function(e,t,r){function n(i,o){return"[Axios v"+yy+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new Oe(n(o," has been removed"+(t?" in "+t:"")),Oe.ERR_DEPRECATED);return t&&!gy[o]&&(gy[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function q4(e,t,r){if(typeof e!="object")throw new Oe("options must be an object",Oe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new Oe("option "+o+" must be "+u,Oe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Oe("Unknown option "+o,Oe.ERR_BAD_OPTION)}}const vh={assertOptions:q4,validators:mh},Ii=vh.validators;let hs=class{constructor(t){this.defaults=t,this.interceptors={request:new Y0,response:new Y0}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
11
+ `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ls(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&vh.assertOptions(n,{silentJSONParsing:Ii.transitional(Ii.boolean),forcedJSONParsing:Ii.transitional(Ii.boolean),clarifyTimeoutError:Ii.transitional(Ii.boolean)},!1),i!=null&&(D.isFunction(i)?r.paramsSerializer={serialize:i}:vh.assertOptions(i,{encode:Ii.function,serialize:Ii.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&D.merge(o.common,o[r.method]);o&&D.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=hr.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[py.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=py.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=ls(this.defaults,t);const r=sy(t.baseURL,t.url);return J0(r,t.params,t.paramsSerializer)}};D.forEach(["delete","get","head","options"],function(e){hs.prototype[e]=function(t,r){return this.request(ls(r||{},{method:e,url:t,data:(r||{}).data}))}}),D.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(ls(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}hs.prototype[e]=t(),hs.prototype[e+"Form"]=t(!0)});let G4=class Jb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new Vs(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Jb(function(r){t=r}),cancel:t}}};function X4(e){return function(t){return e.apply(null,t)}}function J4(e){return D.isObject(e)&&e.isAxiosError===!0}const Eh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Eh).forEach(([e,t])=>{Eh[t]=e});function wy(e){const t=new hs(e),r=U0(hs.prototype.request,t);return D.extend(r,hs.prototype,t,{allOwnKeys:!0}),D.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return wy(ls(e,n))},r}const Xe=wy(Vo);Xe.Axios=hs,Xe.CanceledError=Vs,Xe.CancelToken=G4,Xe.isCancel=ty,Xe.VERSION=yy,Xe.toFormData=vc,Xe.AxiosError=Oe,Xe.Cancel=Xe.CanceledError,Xe.all=function(e){return Promise.all(e)},Xe.spread=X4,Xe.isAxiosError=J4,Xe.mergeConfig=ls,Xe.AxiosHeaders=hr,Xe.formToJSON=e=>Q0(D.isHTMLForm(e)?new FormData(e):e),Xe.getAdapter=dy.getAdapter,Xe.HttpStatusCode=Eh,Xe.default=Xe;var by={},Ws={};Ws.byteLength=Q4,Ws.toByteArray=tS,Ws.fromByteArray=iS;for(var Nn=[],Hr=[],Y4=typeof Uint8Array<"u"?Uint8Array:Array,Ah="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zs=0,Z4=Ah.length;zs<Z4;++zs)Nn[zs]=Ah[zs],Hr[Ah.charCodeAt(zs)]=zs;Hr[45]=62,Hr[95]=63;function my(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Q4(e){var t=my(e),r=t[0],n=t[1];return(r+n)*3/4-n}function eS(e,t,r){return(t+r)*3/4-r}function tS(e){var t,r=my(e),n=r[0],i=r[1],o=new Y4(eS(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Hr[e.charCodeAt(u)]<<18|Hr[e.charCodeAt(u+1)]<<12|Hr[e.charCodeAt(u+2)]<<6|Hr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Hr[e.charCodeAt(u)]<<2|Hr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Hr[e.charCodeAt(u)]<<10|Hr[e.charCodeAt(u+1)]<<4|Hr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function rS(e){return Nn[e>>18&63]+Nn[e>>12&63]+Nn[e>>6&63]+Nn[e&63]}function nS(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(rS(n));return i.join("")}function iS(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(nS(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Nn[t>>2]+Nn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Nn[t>>10]+Nn[t>>4&63]+Nn[t<<2&63]+"=")),i.join("")}var Sh={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Sh.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},Sh.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
12
12
  * The buffer module from node.js, for the browser.
13
13
  *
14
14
  * @author Feross Aboukhadijeh <https://feross.org>
15
15
  * @license MIT
16
- */(function(e){const t=Gs,r=kh,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(my);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",ti=e=>e===it?oS:e===Zt?aS:e===Yt?cS:e===ls?uS:e===Qt?lS:sS;var ut={},Ph={};const hS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),Ey=lv(fS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=Ey,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(Ph);var Oh={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Sy,Kr.number=Ic,Kr.bool=Ay,Kr.bytes=Ih,Kr.hash=Ty,Kr.exists=_y,Kr.output=ky;function Ic(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ay(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Sy(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ih(e,...t){if(!Sy(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ty(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ic(e.outputLen),Ic(e.blockLen)}function _y(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ky(e,t){Ih(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:Ic,bool:Ay,bytes:Ih,hash:Ty,exists:_y,output:ky};Kr.default=dS;var Xo={},xc={};Object.defineProperty(xc,"__esModule",{value:!0}),xc.crypto=void 0,xc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=xc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Xo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=Xo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(Oh);var Rn={},Ci={};Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.HashMD=Ci.Maj=Ci.Chi=void 0;const xh=Kr,Jo=Xo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const yS=(e,t,r)=>e&t^~e&r;Ci.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;Ci.Maj=gS;let wS=class extends Jo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=(0,Jo.createView)(this.buffer)}update(t){(0,xh.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Jo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Jo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,xh.exists)(this),(0,xh.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Jo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};Ci.HashMD=wS,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.sha224=Rn.sha256=Rn.SHA256=void 0;const $h=Ci,jr=Xo,bS=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]),Ni=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ui=new Uint32Array(64);let Ch=class extends $h.HashMD{constructor(){super(64,32,8,!1),this.A=Ni[0]|0,this.B=Ni[1]|0,this.C=Ni[2]|0,this.D=Ni[3]|0,this.E=Ni[4]|0,this.F=Ni[5]|0,this.G=Ni[6]|0,this.H=Ni[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ui[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ui[d-15],v=Ui[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ui[d]=T+Ui[d-7]+E+Ui[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=h+g+(0,$h.Chi)(a,u,f)+bS[d]+Ui[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,$h.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ui.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Rn.SHA256=Ch;let mS=class extends Ch{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}};Rn.sha256=(0,jr.wrapConstructor)(()=>new Ch),Rn.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=Ph,ES=Oh,Py=Rn;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ri="Expected Private",Bi="Expected Point",Yo="Expected Tweak",SS="Expected Hash",$c="Expected Signature",Nh="Expected Extra Data (32 bytes)",Zo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(Py.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>Py.sha256(Re.utils.concatBytes(...e));const Uh=Re.utils._normalizePrivateKey,_S=32,kS=32,Rh=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,OS=new Uint8Array(32),IS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Qo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Oy(e){return Qo(e,OS)===0}function ea(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Qo(e,Rh)>=0)}function Bh(e){return e instanceof Uint8Array&&e.length===64&&Qo(e.subarray(0,32),Rh)<0&&Qo(e.subarray(32,64),Rh)<0}function $S(e){return xS(e)&&e.length===64&&Qo(e.subarray(0,32),IS)<0}function CS(e){return!(Oy(e.subarray(0,32))||Oy(e.subarray(32,64)))}function Js(e){return e instanceof Uint8Array&&e.length===_S}function Hh(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Iy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Iy(Re.utils.bytesToHex(e))}function Lh(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Iy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=Uh(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},xy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Lh(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},HS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Ys(e,t){return e===void 0?t!==void 0?$y(t):!0:!!e}function ps(e){try{return e()}catch{return null}}function Kh(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Hi(e){return Kh(e,!1)}function $y(e){return Kh(e,!1)&&e.length===33}function ri(e){return Re.utils.isValidPrivateKey(e)}function Cc(e){return Kh(e,!0)}function LS(e,t){if(!Cc(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>{const r=xy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function Cy(e){if(!Hi(e))throw new Error(Bi);return e.slice(1,33)}function Ny(e,t){if(!ri(e))throw new Error(Ri);return ps(()=>Re.getPublicKey(e,Ys(t)))}function KS(e){if(!ri(e))throw new Error(Ri);return Cy(Ny(e))}function jS(e,t){if(!Hi(e))throw new Error(Bi);return Re.Point.fromHex(e).toRawBytes(Ys(t,e))}function DS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>HS(e,t,Ys(r,e)))}function MS(e,t,r){if(!Hi(e)||!Hi(t))throw new Error(Bi);return ps(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Ys(r,e))})}function FS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>xy(e,t,Ys(r,e)))}function VS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>US(e,t))}function zS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>RS(e,t))}function WS(e){if(ri(e)===!1)throw new Error(Ri);return BS(e)}function qS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!Js(e))throw new Error(SS);if(!Bh(t)||!CS(t))throw new Error($c);if(r&2&&!$S(t))throw new Error(TS);if(!Cc(t.subarray(0,32)))throw new Error($c);return Re.recoverPublicKey(e,t,r,Ys(n))}function YS(e,t,r,n){if(!Hi(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Cc(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.schnorr.verifySync(r,e,t)}var QS=ut.isPoint=Hi,e8=ut.isPointCompressed=$y,t8=ut.isPrivate=ri,r8=ut.isXOnlyPoint=Cc,n8=ut.pointAdd=MS,i8=ut.pointAddScalar=FS,s8=ut.pointCompress=jS,o8=ut.pointFromScalar=Ny,a8=ut.pointMultiply=DS,c8=ut.privateAdd=VS,u8=ut.privateNegate=WS,l8=ut.privateSub=zS,h8=ut.recover=JS,f8=ut.sign=qS,d8=ut.signRecoverable=GS,p8=ut.signSchnorr=XS,y8=ut.verify=YS,g8=ut.verifySchnorr=ZS,w8=ut.xOnlyPointAddTweak=LS,b8=ut.xOnlyPointFromPoint=Cy,m8=ut.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ut,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:h8,sign:f8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ut]));const er=e=>e===it||e===Zt||e===Yt?um:sn,jh=e=>e.find(({purpose:t})=>t==="ordinals"),Dh=e=>e.find(({purpose:t})=>t==="payment"),zt=async(e,t)=>{try{const r=await Uy(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Uy(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===ls)return[];if(t===Qt)return[]}return await qe.get(`${ti(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Ry(e,t,r,n,i,o,s=7){const a=e===t,u=await Uy(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new ct({network:er(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=Lp(t,er(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=S8(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function S8(e,t){var r;const n=Ro({pubkey:my.Buffer.from(e,"hex"),network:er(t)}),i=Ks({redeem:n,network:er(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[zn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{if(t.provider!==zn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(zn):this.parent.disconnect())}handleNetworkChanged(t){const r=zs(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(zn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",zn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),zt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?zs(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=ct.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=mc(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Rd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[zn]:!1,[In]:!1,[vi]:!1,[Wn]:!1,[Ti]:!1,[ss]:!1,[Ai]:!1,[Ei]:!1,[os]:!1,[Si]:!1}}),$network:yl(tt),$library:yl(void 0)}}function P8({network:e}){return{network:e}}function l9(e){}function h9(e){}function O8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Nc(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function fr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Nc(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??O8(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function I8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function By(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function Hy(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function fn(e,t){return{kind:"schema",type:"array",reference:fn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else fr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:fr(this,"type",t,r),t}}}function ys(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ys,expects:r.map(Nc).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:fr(this,"type",n,i),n}}}function lt(e,t){return{kind:"schema",type:"literal",reference:lt,expects:Nc(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:fr(this,"type",r,n),r}}}function Ky(e,t){return{kind:"schema",type:"loose_object",reference:Ky,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)I8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else fr(this,"type",r,n);return r}}}function Mh(e,t){return{kind:"schema",type:"non_optional",reference:Mh,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(fr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function gs(e){return{kind:"schema",type:"null",reference:gs,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:fr(this,"type",t,r),t}}}function ws(e,...t){const r={kind:"schema",type:"nullish",reference:ws,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=By(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Bn(e){return{kind:"schema",type:"number",reference:Bn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:fr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else fr(this,"type",r,n);return r}}}function dn(e,...t){const r={kind:"schema",type:"optional",reference:dn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=By(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function jy(e,t){return{kind:"schema",type:"picklist",reference:jy,expects:e.map(Nc).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:fr(this,"type",r,n),r}}}function ye(e){return{kind:"schema",type:"string",reference:ye,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:fr(this,"type",t,r),t}}}function Fh(e){return{kind:"schema",type:"undefined",reference:Fh,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:fr(this,"type",t,r),t}}}function Dy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Uc(e,t){return{kind:"schema",type:"union",reference:Uc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];fr(this,"type",r,n,{issues:Dy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];fr(this,"type",r,n,{issues:Dy(s)})}return r}}}function Rc(){return{kind:"schema",type:"unknown",reference:Rc,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Zs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const My=Gs;function Vh(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Vh;function Fy(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=Fy;function Vy(e){return Vh(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Vy;function x8(e){return Fy((0,My.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,My.toByteArray)(Vh(Vy(e))))}tr.decode=$8;var Bc={},Hc={},Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.joseToDer=Qs.derToJose=void 0;const zy=Gs,Wy=tr;function zh(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:zh(256),ES384:zh(384),ES512:zh(521)};function qy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Lc=128,Gy=0,N8=32,U8=16,R8=2,Xy=U8|N8|Gy<<6,Kc=R8|Gy<<6;function Jy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,zy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Jy(e),n=qy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Xy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Lc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Kc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Kc)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Wy.escape)((0,zy.fromByteArray)(E))}Qs.derToJose=B8;function Yy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Lc&&--n,n}function H8(e,t){e=Jy(e);const r=qy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Yy(e,0,r),o=Yy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Lc,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=Xy,f?h[d++]=u:(h[d++]=Lc|1,h[d++]=u&255),h[d++]=Kc,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Kc,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Qs.joseToDer=H8;var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.InvalidTokenError=ni.MissingParametersError=void 0;class L8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ni.MissingParametersError=L8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ni.InvalidTokenError=K8,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.SECP256K1Client=void 0;const j8=Oh,D8=Rn,jc=Ph,Zy=Qs,Qy=ni,eg=Xo;jc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let tg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,eg.bytesToHex)(jc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Qy.MissingParametersError("a signing input hash and private key are all required");const i=jc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,eg.bytesToHex)(i);if(n==="jose")return(0,Zy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Zy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Qy.MissingParametersError("a signing input hash, der signature, and public key are all required");return jc.verify(r,t,n,{strict:!1})}};Hc.SECP256K1Client=tg,tg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Hc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Bc);var bs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(bs,"__esModule",{value:!0}),bs.hashSha256Async=bs.hashSha256=void 0;const F8=Rn;function rg(e){return(0,F8.sha256)(e)}bs.hashSha256=rg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=Ey;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(rg(e))}})}bs.hashSha256Async=V8;var z8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.TokenSigner=Zs.createUnsecuredToken=void 0;const Wh=tr,ng=Bc,W8=ni,ig=bs;function qh(e,t){const r=[],n=Wh.encode(JSON.stringify(t));r.push(n);const i=Wh.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return qh(e,{typ:"JWT",alg:"none"})+"."}Zs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new W8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!ng.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=ng.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=qh(t,i),s=(0,ig.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return z8(this,void 0,void 0,function*(){const i=this.header(n),o=qh(t,i),s=yield(0,ig.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Wh.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Zs.TokenSigner=G8;var Dc={};Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.TokenVerifier=void 0;const X8=tr,sg=Bc,J8=ni,Mc=bs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!sg.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=sg.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Mc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Mc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Mc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Mc.hashSha256)(n);return o(s)}}}Dc.TokenVerifier=Y8;var Fc={};Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.decodeToken=void 0;const Vc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Vc.decode(t[0])),n=JSON.parse(Vc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Vc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Vc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Fc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Zs,e),r(Dc,e),r(Fc,e),r(ni,e),r(Bc,e)}(Dr);/*! *****************************************************************************
16
+ */(function(e){const t=Ws,r=Sh,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=O,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function O(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,I=Math.min(p,m);S<I;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let I=c[p];if(We(I,Uint8Array))S+I.length>m.length?(a.isBuffer(I)||(I=a.from(I)),I.copy(m,S)):Uint8Array.prototype.set.call(m,I,S);else if(a.isBuffer(I))I.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=I.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let I=S-m,U=p-l;const ce=Math.min(I,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){I=ke[ae],U=le[ae];break}return I<U?-1:U<I?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let I=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;I=2,U/=2,ce/=2,p/=2}function ke(ae,me){return I===1?ae[me]:ae.readUInt16BE(me*I)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*I}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const I=l.length;m>I/2&&(m=I/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let I=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const I=c[S];let U=null,ce=I>239?4:I>223?3:I>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:I<128&&(U=I);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(I&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(I&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(I&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let I=l;I<p;++I)S+=yi[c[I]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let I=0;I<m.length-1;I+=2)S+=String.fromCharCode(m[I]+m[I+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,I=this[c+--m];for(;m>0&&(S*=256);)I+=this[c+--m]*S;return S*=128,I>=S&&(I-=Math.pow(2,8*l)),I},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,I){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<I)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,I=0;for(this[l]=c&255;++I<p&&(S*=256);)this[l+I]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,I=1;for(this[l+S]=c&255;--S>=0&&(I*=256);)this[l+S]=c/I&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p+7]=I,I=I>>8,c[p+6]=I,I=I>>8,c[p+5]=I,I=I>>8,c[p+4]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,I=1,U=0;for(this[l]=c&255;++S<p&&(I*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,I=1,U=0;for(this[l+S]=c&255;--S>=0&&(I*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,I){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const I=c.charCodeAt(0);(m==="utf8"&&I<128||m==="latin1")&&(c=I)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const I=a.isBuffer(c)?c:a.from(c,m),U=I.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=I[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,I){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(I+1)*8}${U}`:ce=`>= -(2${U} ** ${(I+1)*8-1}${U}) and < 2 ** ${(I+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,I)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const I=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&I.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&I.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&I.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&I.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;I.push(p)}else if(p<2048){if((l-=2)<0)break;I.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;I.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;I.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return I}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const I=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,I.push(S),I.push(m);return I}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(by);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",Oi=e=>e===it?oS:e===Yt?aS:e===Jt?cS:e===cs?uS:e===Zt?lS:sS;var ct={},Th={};const hS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),vy=lv(fS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=vy,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function O(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Ie=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Ie,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=f.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*f.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Ie=Le(Pe,w)*q%y,Ze=Le(Ie,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function I(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=I(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=I($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(Th);var _h={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Ay,Kr.number=_c,Kr.bool=Ey,Kr.bytes=kh,Kr.hash=Sy,Kr.exists=Ty,Kr.output=_y;function _c(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ey(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Ay(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function kh(e,...t){if(!Ay(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Sy(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_c(e.outputLen),_c(e.blockLen)}function Ty(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _y(e,t){kh(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:_c,bool:Ey,bytes:kh,hash:Sy,exists:Ty,output:_y};Kr.default=dS;var zo={},kc={};Object.defineProperty(kc,"__esModule",{value:!0}),kc.crypto=void 0,kc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=O,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=kc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function O(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=O(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(zo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=zo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(_h);var Un={},xi={};Object.defineProperty(xi,"__esModule",{value:!0}),xi.HashMD=xi.Maj=xi.Chi=void 0;const Ph=Kr,qo=zo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const yS=(e,t,r)=>e&t^~e&r;xi.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;xi.Maj=gS;let wS=class extends qo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=(0,qo.createView)(this.buffer)}update(t){(0,Ph.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,qo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,qo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Ph.exists)(this),(0,Ph.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,qo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};xi.HashMD=wS,Object.defineProperty(Un,"__esModule",{value:!0}),Un.sha224=Un.sha256=Un.SHA256=void 0;const Ih=xi,jr=zo,bS=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]),$i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ci=new Uint32Array(64);let Oh=class extends Ih.HashMD{constructor(){super(64,32,8,!1),this.A=$i[0]|0,this.B=$i[1]|0,this.C=$i[2]|0,this.D=$i[3]|0,this.E=$i[4]|0,this.F=$i[5]|0,this.G=$i[6]|0,this.H=$i[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ci[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ci[d-15],v=Ci[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ci[d]=T+Ci[d-7]+E+Ci[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=h+g+(0,Ih.Chi)(a,u,f)+bS[d]+Ci[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,Ih.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ci.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Un.SHA256=Oh;let mS=class extends Oh{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}};Un.sha256=(0,jr.wrapConstructor)(()=>new Oh),Un.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=Th,ES=_h,ky=Un;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ni="Expected Private",Ui="Expected Point",Go="Expected Tweak",SS="Expected Hash",Pc="Expected Signature",xh="Expected Extra Data (32 bytes)",Xo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(ky.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>ky.sha256(Re.utils.concatBytes(...e));const $h=Re.utils._normalizePrivateKey,_S=32,kS=32,Ch=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,IS=new Uint8Array(32),OS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Jo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Py(e){return Jo(e,IS)===0}function Yo(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Jo(e,Ch)>=0)}function Nh(e){return e instanceof Uint8Array&&e.length===64&&Jo(e.subarray(0,32),Ch)<0&&Jo(e.subarray(32,64),Ch)<0}function $S(e){return xS(e)&&e.length===64&&Jo(e.subarray(0,32),OS)<0}function CS(e){return!(Py(e.subarray(0,32))||Py(e.subarray(32,64)))}function qs(e){return e instanceof Uint8Array&&e.length===_S}function Uh(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Iy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Iy(Re.utils.bytesToHex(e))}function Rh(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Iy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=$h(e),n=Rh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=$h(e),n=Rh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=$h(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},Oy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Rh(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},LS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Gs(e,t){return e===void 0?t!==void 0?xy(t):!0:!!e}function fs(e){try{return e()}catch{return null}}function Bh(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Ri(e){return Bh(e,!1)}function xy(e){return Bh(e,!1)&&e.length===33}function ei(e){return Re.utils.isValidPrivateKey(e)}function Ic(e){return Bh(e,!0)}function HS(e,t){if(!Ic(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>{const r=Oy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function $y(e){if(!Ri(e))throw new Error(Ui);return e.slice(1,33)}function Cy(e,t){if(!ei(e))throw new Error(Ni);return fs(()=>Re.getPublicKey(e,Gs(t)))}function KS(e){if(!ei(e))throw new Error(Ni);return $y(Cy(e))}function jS(e,t){if(!Ri(e))throw new Error(Ui);return Re.Point.fromHex(e).toRawBytes(Gs(t,e))}function DS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>LS(e,t,Gs(r,e)))}function MS(e,t,r){if(!Ri(e)||!Ri(t))throw new Error(Ui);return fs(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Gs(r,e))})}function FS(e,t,r){if(!Ri(e))throw new Error(Ui);if(!Yo(t))throw new Error(Go);return fs(()=>Oy(e,t,Gs(r,e)))}function VS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return fs(()=>US(e,t))}function WS(e,t){if(ei(e)===!1)throw new Error(Ni);if(Yo(t)===!1)throw new Error(Go);return fs(()=>RS(e,t))}function zS(e){if(ei(e)===!1)throw new Error(Ni);return BS(e)}function qS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ei(t))throw new Error(Ni);if(!qs(e))throw new Error(Xo);if(!Uh(r))throw new Error(xh);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!qs(e))throw new Error(SS);if(!Nh(t)||!CS(t))throw new Error(Pc);if(r&2&&!$S(t))throw new Error(TS);if(!Ic(t.subarray(0,32)))throw new Error(Pc);return Re.recoverPublicKey(e,t,r,Gs(n))}function YS(e,t,r,n){if(!Ri(t))throw new Error(Ui);if(!Nh(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Ic(t))throw new Error(Ui);if(!Nh(r))throw new Error(Pc);if(!qs(e))throw new Error(Xo);return Re.schnorr.verifySync(r,e,t)}var QS=ct.isPoint=Ri,e8=ct.isPointCompressed=xy,t8=ct.isPrivate=ei,r8=ct.isXOnlyPoint=Ic,n8=ct.pointAdd=MS,i8=ct.pointAddScalar=FS,s8=ct.pointCompress=jS,o8=ct.pointFromScalar=Cy,a8=ct.pointMultiply=DS,c8=ct.privateAdd=VS,u8=ct.privateNegate=zS,l8=ct.privateSub=WS,h8=ct.recover=JS,f8=ct.sign=qS,d8=ct.signRecoverable=GS,p8=ct.signSchnorr=XS,y8=ct.verify=YS,g8=ct.verifySchnorr=ZS,w8=ct.xOnlyPointAddTweak=HS,b8=ct.xOnlyPointFromPoint=$y,m8=ct.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ct,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:h8,sign:f8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ct]));const Qt=e=>e===it||e===Yt||e===Jt?um:nn,Lh=e=>e.find(({purpose:t})=>t==="ordinals"),Hh=e=>e.find(({purpose:t})=>t==="payment"),er=async(e,t)=>{try{const r=await Ny(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Ny(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===cs)return[];if(t===Zt)return[]}return await Xe.get(`${Oi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Uy(e,t,r,n,i,o,s=7){const a=e===t,u=await Ny(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new Nt({network:Qt(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:O}=T,k=Lp(t,Qt(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(O)}}),!a){const B=S8(i,o);h.updateInput(E,{redeemScript:B})}if(v+=O,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function S8(e,t){var r;const n=Co({pubkey:by.Buffer.from(e,"hex"),network:Qt(t)}),i=Ls({redeem:n,network:Qt(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Vn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==Vn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Vn):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Vn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Vn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),er(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?yc(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=Nt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=sh(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Nd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Vn]:!1,[Pn]:!1,[bi]:!1,[Wn]:!1,[Ud]:!1,[ns]:!1,[vi]:!1,[mi]:!1,[is]:!1,[Ei]:!1}}),$network:hl(tt),$library:hl(void 0)}}function P8({network:e}){return{network:e}}function c9(e){}function u9(e){}function I8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Oc(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function fr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Oc(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??I8(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function O8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Ry(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function By(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function ln(e,t){return{kind:"schema",type:"array",reference:ln,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else fr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:fr(this,"type",t,r),t}}}function ds(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ds,expects:r.map(Oc).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:fr(this,"type",n,i),n}}}function ut(e,t){return{kind:"schema",type:"literal",reference:ut,expects:Oc(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:fr(this,"type",r,n),r}}}function Hy(e,t){return{kind:"schema",type:"loose_object",reference:Hy,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)O8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else fr(this,"type",r,n);return r}}}function Kh(e,t){return{kind:"schema",type:"non_optional",reference:Kh,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(fr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function ps(e){return{kind:"schema",type:"null",reference:ps,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:fr(this,"type",t,r),t}}}function ys(e,...t){const r={kind:"schema",type:"nullish",reference:ys,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=Ry(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Rn(e){return{kind:"schema",type:"number",reference:Rn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:fr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else fr(this,"type",r,n);return r}}}function hn(e,...t){const r={kind:"schema",type:"optional",reference:hn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=Ry(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Ky(e,t){return{kind:"schema",type:"picklist",reference:Ky,expects:e.map(Oc).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:fr(this,"type",r,n),r}}}function pe(e){return{kind:"schema",type:"string",reference:pe,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:fr(this,"type",t,r),t}}}function jh(e){return{kind:"schema",type:"undefined",reference:jh,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:fr(this,"type",t,r),t}}}function jy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function xc(e,t){return{kind:"schema",type:"union",reference:xc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];fr(this,"type",r,n,{issues:jy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];fr(this,"type",r,n,{issues:jy(s)})}return r}}}function $c(){return{kind:"schema",type:"unknown",reference:$c,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Xs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const Dy=Ws;function Dh(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Dh;function My(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=My;function Fy(e){return Dh(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Fy;function x8(e){return My((0,Dy.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,Dy.toByteArray)(Dh(Fy(e))))}tr.decode=$8;var Cc={},Nc={},Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.joseToDer=Js.derToJose=void 0;const Vy=Ws,Wy=tr;function Mh(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:Mh(256),ES384:Mh(384),ES512:Mh(521)};function zy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Uc=128,qy=0,N8=32,U8=16,R8=2,Gy=U8|N8|qy<<6,Rc=R8|qy<<6;function Xy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Vy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Xy(e),n=zy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Gy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Uc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Rc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Rc)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Wy.escape)((0,Vy.fromByteArray)(E))}Js.derToJose=B8;function Jy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Uc&&--n,n}function L8(e,t){e=Xy(e);const r=zy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Jy(e,0,r),o=Jy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Uc,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=Gy,f?h[d++]=u:(h[d++]=Uc|1,h[d++]=u&255),h[d++]=Rc,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Rc,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Js.joseToDer=L8;var ti={};Object.defineProperty(ti,"__esModule",{value:!0}),ti.InvalidTokenError=ti.MissingParametersError=void 0;class H8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ti.MissingParametersError=H8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ti.InvalidTokenError=K8,Object.defineProperty(Nc,"__esModule",{value:!0}),Nc.SECP256K1Client=void 0;const j8=_h,D8=Un,Bc=Th,Yy=Js,Zy=ti,Qy=zo;Bc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let eg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,Qy.bytesToHex)(Bc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Zy.MissingParametersError("a signing input hash and private key are all required");const i=Bc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,Qy.bytesToHex)(i);if(n==="jose")return(0,Yy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Yy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Zy.MissingParametersError("a signing input hash, der signature, and public key are all required");return Bc.verify(r,t,n,{strict:!1})}};Nc.SECP256K1Client=eg,eg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Nc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Cc);var gs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(gs,"__esModule",{value:!0}),gs.hashSha256Async=gs.hashSha256=void 0;const F8=Un;function tg(e){return(0,F8.sha256)(e)}gs.hashSha256=tg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=vy;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(tg(e))}})}gs.hashSha256Async=V8;var W8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.TokenSigner=Xs.createUnsecuredToken=void 0;const Fh=tr,rg=Cc,z8=ti,ng=gs;function Vh(e,t){const r=[],n=Fh.encode(JSON.stringify(t));r.push(n);const i=Fh.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return Vh(e,{typ:"JWT",alg:"none"})+"."}Xs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new z8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!rg.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=rg.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Vh(t,i),s=(0,ng.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return W8(this,void 0,void 0,function*(){const i=this.header(n),o=Vh(t,i),s=yield(0,ng.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Fh.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Xs.TokenSigner=G8;var Lc={};Object.defineProperty(Lc,"__esModule",{value:!0}),Lc.TokenVerifier=void 0;const X8=tr,ig=Cc,J8=ti,Hc=gs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!ig.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=ig.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Hc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Hc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Hc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Hc.hashSha256)(n);return o(s)}}}Lc.TokenVerifier=Y8;var Kc={};Object.defineProperty(Kc,"__esModule",{value:!0}),Kc.decodeToken=void 0;const jc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(jc.decode(t[0])),n=JSON.parse(jc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=jc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(jc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Kc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Xs,e),r(Lc,e),r(Kc,e),r(ti,e),r(Cc,e)}(Dr);/*! *****************************************************************************
17
17
  Copyright (c) Microsoft Corporation.
18
18
 
19
19
  Permission to use, copy, modify, and/or distribute this software for any
@@ -26,22 +26,22 @@ PROCEED WITH CAUTION!
26
26
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
27
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
28
  PERFORMANCE OF THIS SOFTWARE.
29
- ***************************************************************************** */var og="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<og.length;++t)e[og.charCodeAt(t)]=t})();var ag,Gh,zc,Xh=(ag=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,I=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,I.push(T>>x&N);if(E)x>0&&I.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return I}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const I=(E=x).lastIndexOf("1");if(I===-1)return"No separator character for "+E;if(I===0)return"Missing prefix for "+E;const k=E.slice(0,I),B=E.slice(I+1);if(B.length<6)return"Data too short";let W=o(k);if(typeof W=="string")return W;const V=[];for(let Ue=0;Ue<B.length;++Ue){const Le=B.charAt(Ue),Je=n[Le];if(Je===void 0)return"Unknown character "+Le;W=i(W)^Je,Ue+6>=B.length||V.push(Je)}return W!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let I=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,I+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)I+=r.charAt(N>>5*(5-k)&31);return I},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},ag(Gh={exports:{}},Gh.exports),Gh.exports);(zc=Xh)&&zc.__esModule&&Object.prototype.hasOwnProperty.call(zc,"default")&&zc.default,Xh.bech32m,Xh.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var eo,to;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(eo||(eo={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(to||(to={})),to.p2pkh,eo.mainnet,to.p2pkh,eo.testnet,to.p2sh,eo.mainnet,to.p2sh,eo.testnet;var Q8="accountChange";he({type:lt(Q8)});var e6="networkChange";he({type:lt(e6)});var t6="disconnect";he({type:lt(t6)});async function Jh(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var cg=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(cg||{}),Yh=dn(Uc([ye(),Bn(),gs()])),dr=he({jsonrpc:lt("2.0"),method:ye(),params:dn(Uc([fn(Rc()),Ky({}),gs()])),id:Yh}),Wc=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(Wc||{}),ug=he({jsonrpc:lt("2.0"),result:Mh(Rc()),id:Yh}),lg=he({jsonrpc:lt("2.0"),error:Mh(Rc()),id:Yh});Uc([ug,lg]);var qc=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(qc||{}),hg=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(hg||{}),r6=he({address:ye(),publicKey:ye(),purpose:ys(qc),addressType:ys(hg)}),fg=async e=>{var t,r;const n=await Jh(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Dr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},n6="stx_getAddresses",i6=ws(he({message:dn(ye())}));he({...dr.entries,...he({method:lt(n6),params:i6,id:ye()}).entries});var s6="stx_signTransaction",o6=he({transaction:ye(),pubkey:dn(ye()),broadcast:dn(Ly())});he({...dr.entries,...he({method:lt(s6),params:o6,id:ye()}).entries});var a6=["software","ledger"],c6=jy(a6),u6="getInfo",l6=ws(gs());he({version:ye(),methods:dn(fn(ye())),supports:fn(ye())}),he({...dr.entries,...he({method:lt(u6),params:l6,id:ye()}).entries});var h6="getAddresses",f6=he({purposes:fn(ys(qc)),message:dn(ye())});he({...dr.entries,...he({method:lt(h6),params:f6,id:ye()}).entries});var d6="signMessage",Gc=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(Gc||{}),p6=he({address:ye(),message:ye(),protocol:dn(ys(Gc))});he({signature:ye(),messageHash:ye(),address:ye(),protocol:ys(Gc)}),he({...dr.entries,...he({method:lt(d6),params:p6,id:ye()}).entries});var y6="getAccounts",g6=he({purposes:fn(ys(qc)),message:dn(ye())});fn(he({...r6.entries,...he({walletType:c6}).entries})),he({...dr.entries,...he({method:lt(y6),params:g6,id:ye()}).entries});var w6="getBalance";ws(gs()),he({...dr.entries,...he({method:lt(w6),id:ye()}).entries});var b6="wallet_requestPermissions",m6=Fh();lt(!0),he({...dr.entries,...he({method:lt(b6),params:m6,id:ye()}).entries});var v6="wallet_renouncePermissions",E6=Fh();lt(!0),he({...dr.entries,...he({method:lt(v6),params:E6,id:ye()}).entries});var A6="wallet_getWalletType";ws(gs()),he({...dr.entries,...he({method:lt(A6),id:ye()}).entries});var S6="runes_getBalance",T6=ws(gs());he({balances:fn(he({runeName:ye(),amount:ye(),divisibility:Bn(),symbol:ye(),inscriptionId:ws(ye())}))}),he({...dr.entries,...he({method:lt(S6),params:T6,id:ye()}).entries});var _6="runes_transfer",k6=he({recipients:fn(he({runeName:ye(),amount:ye(),address:ye()}))});he({...dr.entries,...he({method:lt(_6),params:k6,id:ye()}).entries});var P6="ord_getInscriptions",O6=he({offset:Bn(),limit:Bn()});he({total:Bn(),limit:Bn(),offset:Bn(),inscriptions:fn(he({inscriptionId:ye(),inscriptionNumber:ye(),address:ye(),collectionName:dn(ye()),postage:ye(),contentLength:ye(),contentType:ye(),timestamp:Bn(),offset:Bn(),genesisTransaction:ye(),output:ye()}))}),he({...dr.entries,...he({method:lt(P6),params:O6,id:ye()}).entries});var I6="ord_sendInscriptions",x6=he({transfers:fn(he({address:ye(),inscriptionId:ye()}))});he({...dr.entries,...he({method:lt(I6),params:x6,id:ye()}).entries});var dg=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return Hy(lg,o)?{status:"error",error:o.error}:Hy(ug,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},$6=async e=>{var t,r;const n=await Jh(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Dr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},C6=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),N6=async e=>{var t,r;const n=await Jh(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=C6(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Dr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let pg=e=>e,ta={},Li={addEventListener(){},removeEventListener(){}};function U6(){try{return typeof localStorage<"u"}catch{return!1}}U6()&&(ta=localStorage),typeof window<"u"&&(Li={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function ro(e,t={},r={}){let n=r.encode||pg,i=r.decode||pg,o=Rd(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&Li.perKey&&Li.removeEventListener(e+d,f,h),delete ta[e+d]):(r.listen!==!1&&Li.perKey&&!(d in o.value)&&Li.addEventListener(e+d,f,h),ta[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in ta)g.startsWith(e)&&(d[g.slice(e.length)]=i(ta[g]));for(let g in d)o.setKey(g,d[g])}return nm(o,()=>{if(h(),r.listen!==!1)return Li.addEventListener(e,f,h),()=>{Li.removeEventListener(e,f,h);for(let d in o.value)Li.removeEventListener(e+d,f,h)}}),o}const yg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R6="XVERSE_CONNECTED_WALLET_STATE";let B6=class extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(R6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of yg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===In&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):yg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){nn(this.$store,["provider"],t=>{t.provider!==In?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[In]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),zt(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Vs(this.network||tt);await fg({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=jh(o.addresses),a=Dh(o.addresses);s&&a&&(this.$store.setKey("provider",In),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),zt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${In} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${In} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Zt,Yt,Qt].includes(this.network)?this.network:tt}getPublicKey(){throw Hr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await zt(t,this.network)}getInscriptions(){throw Hr}async sendBTC(t,r){const n=await dg("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===Wc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await dg("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===Wc.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=ct.fromBase64(String(n),{network:er(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let I of f){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=Ko(k,er(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Vs(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:I=>{if(I.txId)E=I.txId;else if(I.psbtBase64){const k=ct.fromBase64(String(I.psbtBase64),{network:er(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw Hr}},H6=class extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(os)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){nn(this.$store,["provider"],t=>{t.provider===os?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[os]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw I0;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",os),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?uh(r):void 0}async switchNetwork(t){var r;if(t===Qt||t===ls)return await this.library.switchNetwork(Fo);const n=uh(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=ct.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await qe.post(`${ti(this.$network.get())}/api/tx`,t).then(r=>r.data)}};const gg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],L6="OYL_CONNECTED_WALLET_STATE";let K6=class extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(L6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of gg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===vi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):gg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{t.provider!==vi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",vi),zt(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await Ry(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=ct.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw Hr}};const wg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],j6="LEATHER_CONNECTED_WALLET_STATE";let D6=class extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(j6,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of wg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Ai&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):wg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ai]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{t.provider!==Ai?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Ha),a=i.find(u=>u.type===gl);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==it&&this.network!==Zt&&this.network!==Yt)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",Ai),zt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===Wc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Ha:gl;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=ct.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=ct.fromHex(t).extractTransaction();return await qe.post(`${ti(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Ha);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await zt(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw Hr}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw Hr}};var Zh={},bg={},pn={},mg={};Object.defineProperty(mg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(mg,e)}(pn);var vg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(vg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Dr,i=pn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(vg,e)}(bg);var Eg={},Ag={},Sg={};Object.defineProperty(Sg,"__esModule",{value:!0});var Tg={};Object.defineProperty(Tg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Sg,e),r(Tg,e)}(Ag),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=pn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(Ag,e)}(Eg);var _g={},kg={};Object.defineProperty(kg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Se&&Se.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Dr,i=pn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(kg,e)}(_g);var Pg={},Xc={},ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.validateInscriptionPayload=void 0;const M6=4e5,F6=6e4,V6=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?M6:F6))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};ra.validateInscriptionPayload=V6,Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.createInscription=void 0;const z6=Dr,W6=pn,q6=ra,G6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,W6.getProviderOrThrow)(n);(0,q6.validateInscriptionPayload)(e.payload);try{const o=(0,z6.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};Xc.createInscription=G6;var Jc={};Object.defineProperty(Jc,"__esModule",{value:!0}),Jc.createRepeatInscriptions=void 0;const X6=pn,J6=Dr,Y6=ra,Z6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,X6.getProviderOrThrow)(n);(0,Y6.validateInscriptionPayload)(e.payload);try{const o=(0,J6.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};Jc.createRepeatInscriptions=Z6;var Og={};Object.defineProperty(Og,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Xc,e),r(Jc,e),r(Og,e)}(Pg);var Ig={},xg={};Object.defineProperty(xg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Dr,i=pn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(xg,e)}(Ig);var $g={},Yc={};Object.defineProperty(Yc,"__esModule",{value:!0}),Yc.sendBtcTransaction=void 0;const Q6=Dr,e5=pn,t5=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),r5=async e=>{var t,r;const n=await(0,e5.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=t5(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,Q6.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};Yc.sendBtcTransaction=r5;var Zc={};Object.defineProperty(Zc,"__esModule",{value:!0}),Zc.signTransaction=void 0;const n5=Dr,i5=pn,s5=async e=>{var t,r;const n=await(0,i5.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,n5.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};Zc.signTransaction=s5;var Qc={};Object.defineProperty(Qc,"__esModule",{value:!0}),Qc.signMultipleTransactions=void 0;const o5=Dr,a5=pn,c5=async e=>{var t,r;const n=await(0,a5.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,o5.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};Qc.signMultipleTransactions=c5;var Cg={};Object.defineProperty(Cg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Yc,e),r(Zc,e),r(Qc,e),r(Cg,e)}($g);var Ng={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Ng),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(bg,e),r(Eg,e),r(_g,e),r(Pg,e),r(Ig,e),r(pn,e),r($g,e),r(Ng,e)}(Zh);const u5=uv(Zh),Ug=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:l5,sendBtcTransaction:h5,signTransaction:f5}=u5,d5="ORANGE_CONNECTED_WALLET_STATE";let p5=class extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(d5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ug)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Si&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ug.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Si]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],r=>{r.provider!==Si?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),zt(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Vo(this.network||tt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=jh(s.addresses),u=Dh(s.addresses);a&&u&&(this.$store.setKey("publicKey",String(s.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(s.addresses[1].publicKey)),this.$store.setKey("provider",Si),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),zt(u.address,this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Si} wallet`)}};await Zh.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Zt,Yt,Qt].includes(this.network)?this.network:tt}getPublicKey(){throw Hr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await zt(t,this.network)}getInscriptions(){throw Hr}async sendBTC(t,r){let n="";const i={payload:{network:{type:Vo(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{console.log(o),n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await h5(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Vo(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await l5(o),n}async signPsbt(t,r,n,i,o){const s=ct.fromBase64(String(n),{network:er(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let I of f){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=Ko(k,er(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Vo(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:I=>{if(console.log(I),I.txId)E=I.txId;else if(I.psbtBase64){const k=ct.fromBase64(String(I.psbtBase64),{network:er(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await f5(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=ct.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await qe.post(`${ti(this.network)}/api/tx`,r).then(n=>n.data)}};const Rg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],y5="OKX_CONNECTED_WALLET_STATE";class g5 extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(y5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===it||this.network===Zt||this.network===Yt||this.network===Qt?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===tt||this.network===ls)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Rg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ss&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Rg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ss]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],r=>{r.provider!==ss?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ss),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===it||r===Zt||r===Qt?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===it?it:r===Zt?Zt:r===Yt?Yt:r===Qt?Qt:it;const n=await this.library.getNetwork();return U0(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await zt(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=ct.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}}const Bg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],w5="MAGIC_EDEN_CONNECTED_WALLET_STATE";class b5 extends ln{constructor(){super(...arguments),de(this,"observer"),de(this,"$valueStore",ro(w5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),de(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Bg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Wn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Bg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Wn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{t.provider!==Wn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),zt(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Vs(this.network||tt);await fg({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=jh(o.addresses),a=Dh(o.addresses);s&&a&&(this.$store.setKey("provider",Wn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),zt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Wn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Wn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Zt,Yt,Qt].includes(this.network)?this.network:tt}getPublicKey(){throw Hr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await zt(t,this.network)}getInscriptions(){throw Hr}async sendBTC(t,r){let n;if(await N6({getProvider:async()=>this.library,payload:{network:{type:Vs(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await $6({getProvider:async()=>this.library,payload:{network:{type:cg.Mainnet},address:n,message:t,protocol:Gc.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=ct.fromBase64(String(n),{network:er(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,W=Ko(B,er(this.network));W===a?g.signingIndexes.push(Number(v)):W===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=Vs(this.network),I={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=ct.fromBase64(String(k.psbtBase64),{network:er(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(I),o){const k=ct.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}}class m5 extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ei]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{if(t.provider!==Ei){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Ei):this.parent.disconnect())}handleNetworkChanged(t){const r=zs(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Ei)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",Ei),zt(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?it:tt}async sendBTC(t,r){const{psbtHex:n}=await Ry(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=ct.fromHex(String(r),{network:er(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=Ko(x,er(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=ct.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=mc(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class v5 extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){return window.opnet}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ti]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{if(t.provider!==Ti){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Ti):this.parent.disconnect())}handleNetworkChanged(t){const r=zs(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Ti)}async connect(t){if(!this.library)throw new Error("OP_NET isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Ti),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),zt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?zs(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=ct.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=mc(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class E5{constructor(t,r){de(this,"$store"),de(this,"$network"),de(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[Ai]:new D6(t,this,r),[Wn]:new b5(t,this,r),[ss]:new g5(t,this,r),[Ti]:new v5(t,this,r),[Si]:new p5(t,this,r),[vi]:new K6(t,this,r),[Ei]:new m5(t,this,r),[zn]:new T8(t,this,r),[In]:new B6(t,this,r),[os]:new H6(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Ud(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Ud(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),_8()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(La);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(La,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(La)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(E8(t))s=ct.fromHex(t).toBase64(),o=t;else if(v8(t))s=t,o=ct.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}}var A5=Object.defineProperty,S5=(e,t,r)=>t in e?A5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t,r)=>S5(e,typeof t!="symbol"?t+"":t,r);function T5(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let Qh=Symbol("clean"),yn=[],Ki=0;const eu=4;let ef=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=Ki+eu;o<yn.length;)yn[o]===n?yn.splice(o,eu):o+=eu;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!yn.length;for(let s of t)yn.push(s,r.value,n,i);if(o){for(Ki=0;Ki<yn.length;Ki+=eu)yn[Ki](yn[Ki+1],yn[Ki+2],yn[Ki+3]);yn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[Qh]=()=>{t=[],r.lc=0,r.off()}),r};const _5=5,no=6,tu=10;let k5=(e,t,r,n)=>(e.events=e.events||{},e.events[r+tu]||(e.events[r+tu]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+tu](),delete e.events[r+tu])}),P5=1e3,O5=(e,t)=>k5(e,r=>{let n=t(r);n&&e.events[no].push(n)},_5,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[no]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[no])o();e.events[no]=[]}},P5)},process.env.NODE_ENV!=="production"){let o=e[Qh];e[Qh]=()=>{for(let s of e.events[no])s();e.events[no]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function gn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Hg(e,t,r){let n=gn(e,t,r);return r(e.value),n}let Lg=(e={})=>{let t=ef(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const ms="oyl",ji="unisat",ii="xverse",Di="phantom",vs="leather",si="magic-eden",Es="okx",As="wizz",Mi="orange",Fi="op_net",tf="p2tr",Kg="p2wpkh",rf="defaultWallet",wn={messagePrefix:`Bitcoin Signed Message:
29
+ ***************************************************************************** */var sg="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<sg.length;++t)e[sg.charCodeAt(t)]=t})();var og,Wh,Dc,zh=(og=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,O=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,O.push(T>>x&N);if(E)x>0&&O.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return O}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const O=(E=x).lastIndexOf("1");if(O===-1)return"No separator character for "+E;if(O===0)return"Missing prefix for "+E;const k=E.slice(0,O),B=E.slice(O+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let O=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,O+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)O+=r.charAt(N>>5*(5-k)&31);return O},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},og(Wh={exports:{}},Wh.exports),Wh.exports);(Dc=zh)&&Dc.__esModule&&Object.prototype.hasOwnProperty.call(Dc,"default")&&Dc.default,zh.bech32m,zh.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var Ys,Zs;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(Ys||(Ys={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(Zs||(Zs={})),Zs.p2pkh,Ys.mainnet,Zs.p2pkh,Ys.testnet,Zs.p2sh,Ys.mainnet,Zs.p2sh,Ys.testnet;var Q8="accountChange";he({type:ut(Q8)});var e6="networkChange";he({type:ut(e6)});var t6="disconnect";he({type:ut(t6)});async function qh(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var ag=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(ag||{}),Gh=hn(xc([pe(),Rn(),ps()])),dr=he({jsonrpc:ut("2.0"),method:pe(),params:hn(xc([ln($c()),Hy({}),ps()])),id:Gh}),Mc=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(Mc||{}),cg=he({jsonrpc:ut("2.0"),result:Kh($c()),id:Gh}),ug=he({jsonrpc:ut("2.0"),error:Kh($c()),id:Gh});xc([cg,ug]);var Fc=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(Fc||{}),lg=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(lg||{}),r6=he({address:pe(),publicKey:pe(),purpose:ds(Fc),addressType:ds(lg)}),hg=async e=>{var t,r;const n=await qh(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Dr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},n6="stx_getAddresses",i6=ys(he({message:hn(pe())}));he({...dr.entries,...he({method:ut(n6),params:i6,id:pe()}).entries});var s6="stx_signTransaction",o6=he({transaction:pe(),pubkey:hn(pe()),broadcast:hn(Ly())});he({...dr.entries,...he({method:ut(s6),params:o6,id:pe()}).entries});var a6=["software","ledger"],c6=Ky(a6),u6="getInfo",l6=ys(ps());he({version:pe(),methods:hn(ln(pe())),supports:ln(pe())}),he({...dr.entries,...he({method:ut(u6),params:l6,id:pe()}).entries});var h6="getAddresses",f6=he({purposes:ln(ds(Fc)),message:hn(pe())});he({...dr.entries,...he({method:ut(h6),params:f6,id:pe()}).entries});var d6="signMessage",Vc=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(Vc||{}),p6=he({address:pe(),message:pe(),protocol:hn(ds(Vc))});he({signature:pe(),messageHash:pe(),address:pe(),protocol:ds(Vc)}),he({...dr.entries,...he({method:ut(d6),params:p6,id:pe()}).entries});var y6="getAccounts",g6=he({purposes:ln(ds(Fc)),message:hn(pe())});ln(he({...r6.entries,...he({walletType:c6}).entries})),he({...dr.entries,...he({method:ut(y6),params:g6,id:pe()}).entries});var w6="getBalance";ys(ps()),he({...dr.entries,...he({method:ut(w6),id:pe()}).entries});var b6="wallet_requestPermissions",m6=jh();ut(!0),he({...dr.entries,...he({method:ut(b6),params:m6,id:pe()}).entries});var v6="wallet_renouncePermissions",E6=jh();ut(!0),he({...dr.entries,...he({method:ut(v6),params:E6,id:pe()}).entries});var A6="wallet_getWalletType";ys(ps()),he({...dr.entries,...he({method:ut(A6),id:pe()}).entries});var S6="runes_getBalance",T6=ys(ps());he({balances:ln(he({runeName:pe(),amount:pe(),divisibility:Rn(),symbol:pe(),inscriptionId:ys(pe())}))}),he({...dr.entries,...he({method:ut(S6),params:T6,id:pe()}).entries});var _6="runes_transfer",k6=he({recipients:ln(he({runeName:pe(),amount:pe(),address:pe()}))});he({...dr.entries,...he({method:ut(_6),params:k6,id:pe()}).entries});var P6="ord_getInscriptions",I6=he({offset:Rn(),limit:Rn()});he({total:Rn(),limit:Rn(),offset:Rn(),inscriptions:ln(he({inscriptionId:pe(),inscriptionNumber:pe(),address:pe(),collectionName:hn(pe()),postage:pe(),contentLength:pe(),contentType:pe(),timestamp:Rn(),offset:Rn(),genesisTransaction:pe(),output:pe()}))}),he({...dr.entries,...he({method:ut(P6),params:I6,id:pe()}).entries});var O6="ord_sendInscriptions",x6=he({transfers:ln(he({address:pe(),inscriptionId:pe()}))});he({...dr.entries,...he({method:ut(O6),params:x6,id:pe()}).entries});var fg=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return By(ug,o)?{status:"error",error:o.error}:By(cg,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},$6=async e=>{var t,r;const n=await qh(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Dr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},C6=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),N6=async e=>{var t,r;const n=await qh(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=C6(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Dr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let dg=e=>e,Zo={},Bi={addEventListener(){},removeEventListener(){}};function U6(){try{return typeof localStorage<"u"}catch{return!1}}U6()&&(Zo=localStorage),typeof window<"u"&&(Bi={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Qs(e,t={},r={}){let n=r.encode||dg,i=r.decode||dg,o=Nd(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&Bi.perKey&&Bi.removeEventListener(e+d,f,h),delete Zo[e+d]):(r.listen!==!1&&Bi.perKey&&!(d in o.value)&&Bi.addEventListener(e+d,f,h),Zo[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in Zo)g.startsWith(e)&&(d[g.slice(e.length)]=i(Zo[g]));for(let g in d)o.setKey(g,d[g])}return nm(o,()=>{if(h(),r.listen!==!1)return Bi.addEventListener(e,f,h),()=>{Bi.removeEventListener(e,f,h);for(let d in o.value)Bi.removeEventListener(e+d,f,h)}}),o}const pg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R6="XVERSE_CONNECTED_WALLET_STATE";class B6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(R6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of pg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Pn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):pg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){kn(this.$store,["provider"],t=>{t.provider!==Pn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Pn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await hg({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Lh(o.addresses),a=Hh(o.addresses);if(!s||!a)throw new Error("Could not find the addresses");s&&a&&(this.$store.setKey("provider",Pn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Pn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Pn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){const n=await fg("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await fg("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=Bo(k,Qt(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Ms(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=Nt.fromBase64(String(O.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw Lr}}class L6 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(is)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){kn(this.$store,["provider"],t=>{t.provider===is?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[is]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw I0;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",is),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?oh(r):void 0}async switchNetwork(t){var r;if(t===Zt||t===cs)return await this.library.switchNetwork(jo);const n=oh(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=Nt.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await Xe.post(`${Oi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const yg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],H6="OYL_CONNECTED_WALLET_STATE";class K6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(H6,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of yg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):yg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==bi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",bi),er(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=Nt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw Lr}}const gg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],j6="LEATHER_CONNECTED_WALLET_STATE";class D6 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(j6,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of gg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===vi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):gg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==vi?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Na),a=i.find(u=>u.type===fl);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==it&&this.network!==Yt&&this.network!==Jt)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",vi),er(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===Mc.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Na:fl;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=Nt.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=Nt.fromHex(t).extractTransaction();return await Xe.post(`${Oi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Na);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await er(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw Lr}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw Lr}}var Xh={},wg={},fn={},bg={};Object.defineProperty(bg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(bg,e)}(fn);var mg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(mg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Dr,i=fn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(mg,e)}(wg);var vg={},Eg={},Ag={};Object.defineProperty(Ag,"__esModule",{value:!0});var Sg={};Object.defineProperty(Sg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ag,e),r(Sg,e)}(Eg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=fn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(Eg,e)}(vg);var Tg={},_g={};Object.defineProperty(_g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Se&&Se.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Dr,i=fn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(_g,e)}(Tg);var kg={},Wc={},Qo={};Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.validateInscriptionPayload=void 0;const M6=4e5,F6=6e4,V6=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?M6:F6))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Qo.validateInscriptionPayload=V6,Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.createInscription=void 0;const W6=Dr,z6=fn,q6=Qo,G6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,z6.getProviderOrThrow)(n);(0,q6.validateInscriptionPayload)(e.payload);try{const o=(0,W6.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};Wc.createInscription=G6;var zc={};Object.defineProperty(zc,"__esModule",{value:!0}),zc.createRepeatInscriptions=void 0;const X6=fn,J6=Dr,Y6=Qo,Z6=async e=>{var t,r;const{getProvider:n}=e,i=await(0,X6.getProviderOrThrow)(n);(0,Y6.validateInscriptionPayload)(e.payload);try{const o=(0,J6.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};zc.createRepeatInscriptions=Z6;var Pg={};Object.defineProperty(Pg,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Wc,e),r(zc,e),r(Pg,e)}(kg);var Ig={},Og={};Object.defineProperty(Og,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Se&&Se.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Dr,i=fn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Og,e)}(Ig);var xg={},qc={};Object.defineProperty(qc,"__esModule",{value:!0}),qc.sendBtcTransaction=void 0;const Q6=Dr,e5=fn,t5=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),r5=async e=>{var t,r;const n=await(0,e5.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=t5(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,Q6.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};qc.sendBtcTransaction=r5;var Gc={};Object.defineProperty(Gc,"__esModule",{value:!0}),Gc.signTransaction=void 0;const n5=Dr,i5=fn,s5=async e=>{var t,r;const n=await(0,i5.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,n5.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};Gc.signTransaction=s5;var Xc={};Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.signMultipleTransactions=void 0;const o5=Dr,a5=fn,c5=async e=>{var t,r;const n=await(0,a5.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,o5.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};Xc.signMultipleTransactions=c5;var $g={};Object.defineProperty($g,"__esModule",{value:!0}),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(qc,e),r(Gc,e),r(Xc,e),r($g,e)}(xg);var Cg={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Cg),function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wg,e),r(vg,e),r(Tg,e),r(kg,e),r(Ig,e),r(fn,e),r(xg,e),r(Cg,e)}(Xh);const u5=uv(Xh),Ng=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:l5,sendBtcTransaction:h5,signTransaction:f5}=u5,d5="ORANGE_CONNECTED_WALLET_STATE";class p5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(d5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ng)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Ei&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ng.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ei]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==Ei?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Do(this.network||tt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=Lh(s.addresses),u=Hh(s.addresses);if(!a||!(u!=null&&u.address))throw new Error("Could not find addresses");a&&u&&(this.$store.setKey("provider",Ei),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),this.$store.setKey("publicKey",String(a.publicKey)),this.$store.setKey("paymentPublicKey",String(u.publicKey)),er(String(u==null?void 0:u.address),this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Ei} wallet`)}};await Xh.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n="";const i={payload:{network:{type:Do(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await h5(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Do(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await l5(o),n}async signPsbt(t,r,n,i,o){const s=Nt.fromBase64(String(n),{network:Qt(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=Bo(k,Qt(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Do(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=Nt.fromBase64(String(O.psbtBase64),{network:Qt(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await f5(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=Nt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Xe.post(`${Oi(this.network)}/api/tx`,r).then(n=>n.data)}}const Ug=["address","paymentAddress","publicKey","paymentPublicKey","balance"],y5="OKX_CONNECTED_WALLET_STATE";class g5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(y5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===it||this.network===Yt||this.network===Jt||this.network===Zt?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===tt||this.network===cs)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ug)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ns&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ug.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ns]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],r=>{r.provider!==ns?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ns),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===it||r===Yt||r===Zt?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===it?it:r===Yt?Yt:r===Jt?Jt:r===Zt?Zt:it;const n=await this.library.getNetwork();return N0(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=Nt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}}const Rg=["address","paymentAddress","publicKey","paymentPublicKey","balance"],w5="MAGIC_EDEN_CONNECTED_WALLET_STATE";class b5 extends Cn{constructor(){super(...arguments),we(this,"observer"),we(this,"$valueStore",Qs(w5,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),we(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Rg)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Wn&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Rg.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Wn]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{t.provider!==Wn?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),er(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=Ms(this.network||tt);await hg({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=Lh(o.addresses),a=Hh(o.addresses);if(!s||!a)throw new Error("No address found");s&&a&&(this.$store.setKey("provider",Wn),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),er(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Wn} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${Wn} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[it,Yt,Jt,Zt].includes(this.network)?this.network:tt}getPublicKey(){throw Lr}async getBalance(){const{paymentAddress:t}=this.$store.get();return await er(t,this.network)}getInscriptions(){throw Lr}async sendBTC(t,r){let n;if(await N6({getProvider:async()=>this.library,payload:{network:{type:Ms(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await $6({getProvider:async()=>this.library,payload:{network:{type:ag.Mainnet},address:n,message:t,protocol:Vc.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromBase64(String(n),{network:Qt(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,z=Bo(B,Qt(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=Ms(this.network),O={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=Nt.fromBase64(String(k.psbtBase64),{network:Qt(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(O),o){const k=Nt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}}class m5 extends Cn{constructor(){super(...arguments),we(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[mi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),kn(this.$store,["provider"],t=>{if(t.provider!==mi){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(mi):this.parent.disconnect())}handleNetworkChanged(t){const r=yc(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(mi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",mi),er(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?it:tt}async sendBTC(t,r){const{psbtHex:n}=await Uy(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=Nt.fromHex(String(r),{network:Qt(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=Bo(x,Qt(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=Nt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${Oi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=sh(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}let v5=class{constructor(t,r){we(this,"$store"),we(this,"$network"),we(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[vi]:new D6(t,this,r),[Wn]:new b5(t,this,r),[ns]:new g5(t,this,r),[Ei]:new p5(t,this,r),[bi]:new K6(t,this,r),[mi]:new m5(t,this,r),[Vn]:new T8(t,this,r),[Pn]:new B6(t,this,r),[is]:new L6(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Cd(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Cd(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),_8()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(Ua);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(Ua,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(Ua)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(E8(t))s=Nt.fromHex(t).toBase64(),o=t;else if(v8(t))s=t,o=Nt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}};var E5=Object.defineProperty,A5=(e,t,r)=>t in e?E5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t,r)=>A5(e,typeof t!="symbol"?t+"":t,r);function S5(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}let Jh=Symbol("clean"),dn=[],Li=0;const Jc=4;let Yh=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=t.push(n),()=>{for(let o=Li+Jc;o<dn.length;)dn[o]===n?dn.splice(o,Jc):o+=Jc;let i=t.indexOf(n);~i&&(t.splice(i,1),--r.lc||r.off())}},notify(n,i){let o=!dn.length;for(let s of t)dn.push(s,r.value,n,i);if(o){for(Li=0;Li<dn.length;Li+=Jc)dn[Li](dn[Li+1],dn[Li+2],dn[Li+3]);dn.length=0}},off(){},set(n){let i=r.value;i!==n&&(r.value=n,r.notify(i))},subscribe(n){let i=r.listen(n);return n(r.value),i},value:e};return process.env.NODE_ENV!=="production"&&(r[Jh]=()=>{t=[],r.lc=0,r.off()}),r};const T5=5,eo=6,Yc=10;let _5=(e,t,r,n)=>(e.events=e.events||{},e.events[r+Yc]||(e.events[r+Yc]=n(i=>{e.events[r].reduceRight((o,s)=>(s(o),o),{shared:{},...i})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let i=e.events[r],o=i.indexOf(t);i.splice(o,1),i.length||(delete e.events[r],e.events[r+Yc](),delete e.events[r+Yc])}),k5=1e3,P5=(e,t)=>_5(e,r=>{let n=t(r);n&&e.events[eo].push(n)},T5,r=>{let n=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),n(...o));let i=e.off;if(e.events[eo]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[eo])o();e.events[eo]=[]}},k5)},process.env.NODE_ENV!=="production"){let o=e[Jh];e[Jh]=()=>{for(let s of e.events[eo])s();e.events[eo]=[],e.active=!1,o()}}return()=>{e.listen=n,e.off=i}});function Bn(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Bg(e,t,r){let n=Bn(e,t,r);return r(e.value),n}let Lg=(e={})=>{let t=Yh(e);return t.setKey=function(r,n){let i=t.value;typeof n>"u"&&r in t.value?(t.value={...t.value},delete t.value[r],t.notify(i,r)):t.value[r]!==n&&(t.value={...t.value,[r]:n},t.notify(i,r))},t};const ws="oyl",Hi="unisat",ri="xverse",Ki="phantom",bs="leather",ni="magic-eden",ms="okx",vs="wizz",ji="orange",Hg="op_net",Zh="p2tr",Kg="p2wpkh",Qh="defaultWallet",pn={messagePrefix:`Bitcoin Signed Message:
30
30
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},I5={messagePrefix:`Bitcoin Signed Message:
31
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function x5(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function $5(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(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function C5(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)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(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const Ge={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},jg={};for(const e of Object.keys(Ge)){const t=Ge[e];jg[t]=e}const ru="0123456789abcdefABCDEF",nu=ru.split("").map(e=>e.codePointAt(0)),iu=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=ru.indexOf(r);return n<0?void 0:n<16?n:n-6}),Dg=new TextEncoder,Mg=new TextDecoder;function N5(e){return Mg.decode(e)}function U5(e){return Dg.encode(e)}function ht(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Ee(e){const t=e||new Uint8Array;return t.length>512?B5(t):R5(t)}function R5(e){let t="";for(let r=0;r<e.length;++r)t+=ru[iu[nu[e[r]>>4]]],t+=ru[iu[nu[e[r]&15]]];return t}function B5(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=nu[e[r]>>4],t[r*2+1]=nu[e[r]&15];return Mg.decode(t)}function oi(e){const t=Dg.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=iu[t[n*2]],o=iu[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function H5(e){return btoa(String.fromCharCode(...e))}function Fg(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function ee(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Pr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function L5(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function na(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function K5(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function ai(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function j5(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function io(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Vg(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function zg(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function D5(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function Wg(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function qg(e){return e<Ge.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function M5(e,t,r){const n=qg(t);return n===1?Pr(e,r,t):n===2?(Pr(e,r,Ge.OP_PUSHDATA1),Pr(e,r+1,t)):n===3?(Pr(e,r,Ge.OP_PUSHDATA2),L5(e,r+1,t,"LE")):(Pr(e,r,Ge.OP_PUSHDATA4),na(e,r+1,t,"LE")),n}function F5(e,t){const r=ai(e,t);let n,i;if(r<Ge.OP_PUSHDATA1)n=r,i=1;else if(r===Ge.OP_PUSHDATA1){if(t+2>e.length)return null;n=ai(e,t+1),i=2}else if(r===Ge.OP_PUSHDATA2){if(t+3>e.length)return null;n=j5(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==Ge.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=io(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function V5(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function z5(e){let t=Math.abs(e);const r=V5(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Pr(n,o,t&255),t>>=8;return n[r-1]&128?Pr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function W5(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function q5(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function ia(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function Wt(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??ia(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??q5(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function G5(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var X5=class extends Error{constructor(e){super(e[0].message),ge(this,"issues"),this.name="ValiError",this.issues=e}};function Gg(e,t){return{kind:"validation",type:"every_item",reference:Gg,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&Wt(this,"item",r,n),r}}}function nf(e){return{kind:"validation",type:"integer",reference:nf,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&Wt(this,"integer",t,r),t}}}function Xg(e,t){return{kind:"validation",type:"length",reference:Xg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&Wt(this,"length",r,n,{received:`${r.value.length}`}),r}}}function su(e,t){return{kind:"validation",type:"max_value",reference:su,async:!1,expects:`<=${e instanceof Date?e.toJSON():ia(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&Wt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ia(r.value)}),r}}}function ou(e,t){return{kind:"validation",type:"min_value",reference:ou,async:!1,expects:`>=${e instanceof Date?e.toJSON():ia(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&Wt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ia(r.value)}),r}}}function Jg(e,t){return{kind:"validation",type:"regex",reference:Jg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&Wt(this,"format",r,n),r}}}function sf(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function au(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Yg(){return{kind:"schema",type:"any",reference:Yg,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function pr(e,t){return{kind:"schema",type:"array",reference:pr,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Wt(this,"type",r,n);return r}}}function Zg(e){return{kind:"schema",type:"bigint",reference:Zg,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:Wt(this,"type",t,r),t}}}function bn(e,t){return{kind:"schema",type:"custom",reference:bn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:Wt(this,"type",r,n),r}}}function cu(e,t){return{kind:"schema",type:"instance",reference:cu,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:Wt(this,"type",r,n),r}}}function of(e,...t){const r={kind:"schema",type:"nullable",reference:of,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=sf(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Qg(e,...t){const r={kind:"schema",type:"nullish",reference:Qg,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=sf(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function yr(e){return{kind:"schema",type:"number",reference:yr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Wt(this,"type",t,r),t}}}function xt(e,t){return{kind:"schema",type:"object",reference:xt,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else Wt(this,"type",r,n);return r}}}function uu(e,...t){const r={kind:"schema",type:"optional",reference:uu,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=sf(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Ss(e){return{kind:"schema",type:"string",reference:Ss,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:Wt(this,"type",t,r),t}}}function Hn(e,t){return{kind:"schema",type:"tuple",reference:Hn,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else Wt(this,"type",r,n);return r}}}function e1(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function af(e,t){return{kind:"schema",type:"union",reference:af,expects:G5(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];Wt(this,"type",r,n,{issues:e1(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];Wt(this,"type",r,n,{issues:e1(s)})}return r}}}function ft(e,t,r){const n=e._run({typed:!1,value:t},W5(r));if(n.issues)throw new X5(n.issues);return n.value}function Vi(e,t){const r={};for(const n in e.entries)r[n]=uu(e.entries[n]);return{...e,entries:r}}function so(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const t1=new Uint8Array(32),r1=oi("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ut=e=>so(cu(Uint8Array),Xg(e));function sa(e,t){return e.length!==t.length?!1:e.every((r,n)=>ee(r,t[n])===0)}function mn(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(ee(t1,r)===0||ee(r,r1)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return ee(t1,n)===0||ee(n,r1)>=0?!1:t===4&&e.length===65}const lu=254;function cf(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&lu)===e.version:!0}function n1(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>n1(t)):cf(e)}const J5=Ut(32),Y5=Ut(20),i1=Ut(32),Me=cu(Uint8Array);so(Ss(),Jg(/^([0-9a-f]{2})+$/i));const Z5=so(yr(),nf(),ou(0),su(255)),ci=so(yr(),nf(),ou(0),su(4294967295)),uf=so(Zg(),ou(0n),su(0x7fffffffffffffffn)),s1=e=>xt(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Qg(r[1])}),{})),o1=new Uint8Array(1);function a1(e){let t=0;for(;e[t]===0;)++t;return t===e.length?o1:(e=e.slice(t),e[0]&128?ht([o1,e]):e)}function c1(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Q5(e){const t=ai(e,e.length-1);if(!hf(t))throw new Error("Invalid hashType "+t);const r=$5(e.subarray(0,-1)),n=c1(r.r),i=c1(r.s);return{signature:ht([n,i]),hashType:t}}function eT(e,t){if(ft(xt({signature:Ut(64),hashType:Z5}),{signature:e,hashType:t}),!hf(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Pr(r,0,t);const n=a1(e.slice(0,32)),i=a1(e.slice(32,64));return ht([C5(n,i),r])}const tT=Object.freeze(Object.defineProperty({__proto__:null,decode:Q5,encode:eT},Symbol.toStringTag,{value:"Module"})),u1=Ge.OP_RESERVED,l1=pr(af([cu(Uint8Array),yr()]));function rT(e){return au(yr(),e)&&(e===Ge.OP_0||e>=Ge.OP_1&&e<=Ge.OP_16||e===Ge.OP_1NEGATE)}function h1(e){return au(Me,e)||rT(e)}function lf(e){return au(so(Yg(),Gg(h1)),e)}function f1(e){return e.length-e.filter(h1).length}function hu(e){if(e.length===0)return Ge.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return u1+e[0];if(e[0]===129)return Ge.OP_1NEGATE}}function d1(e){return e instanceof Uint8Array}function nT(e){return au(l1,e)}function fu(e){return e instanceof Uint8Array}function gr(e){if(d1(e))return e;ft(l1,e);const t=e.reduce((i,o)=>fu(o)?o.length===1&&hu(o)!==void 0?i+1:i+qg(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(fu(i)){const o=hu(i);if(o!==void 0){Pr(r,n,o),n+=1;return}n+=M5(r,i.length,n),r.set(i,n),n+=i.length}else Pr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function mt(e){if(nT(e))return e;ft(Me,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>Ge.OP_0&&n<=Ge.OP_PUSHDATA4){const i=F5(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=hu(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function iT(e){if(d1(e)&&(e=mt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(fu(t)){const r=hu(t);if(r===void 0)return Ee(t);t=r}return jg[t]}).join(" ")}function sT(e){return e=mt(e),ft(bn(lf),e),e.map(t=>fu(t)?t:t===Ge.OP_0?new Uint8Array(0):z5(t-u1))}function oT(e){return mn(e)}function hf(e){const t=e&-129;return t>0&&t<4}function ui(e){return!(e instanceof Uint8Array)||!hf(e[e.length-1])?!1:x5(e.slice(0,-1))}const oa=tT;function we(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Mr(e){let t;return()=>(t!==void 0||(t=e()),t)}const oo=Ge,du=oo.OP_RESERVED;function pu(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return ui(a)||(t.allowIncomplete&&a===oo.OP_0)!==void 0}ft(Vi(xt({network:xt({}),m:yr(),n:yr(),output:Me,pubkeys:pr(bn(mn),"Received invalid pubkey"),signatures:pr(bn(r),"Expected signature to be of type isAcceptableSignature"),input:Me})),e);const n={network:e.network||wn};let i=[],o=!1;function s(a){o||(o=!0,i=mt(a),n.m=i[0]-du,n.n=i[i.length-2]-du,n.pubkeys=i.slice(1,-2))}if(we(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return gr([].concat(du+e.m,e.pubkeys,du+n.n,oo.OP_CHECKMULTISIG))}),we(n,"m",()=>{if(n.output)return s(n.output),n.m}),we(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),we(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),we(n,"signatures",()=>{if(e.input)return mt(e.input).slice(1)}),we(n,"input",()=>{if(e.signatures)return gr([oo.OP_0].concat(e.signatures))}),we(n,"witness",()=>{if(n.input)return[]}),we(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),ft(yr(),i[0],{message:"Output is invalid"}),ft(yr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==oo.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>mn(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!sa(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==oo.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!sa(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const p1=Ge;function y1(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Vi(xt({network:xt({}),output:Me,pubkey:bn(mn,"invalid pubkey"),signature:bn(ui,"Expected signature to be of type isCanonicalScriptSignature"),input:Me})),e);const r=Mr(()=>mt(e.input)),n={name:"p2pk",network:e.network||wn};if(we(n,"output",()=>{if(e.pubkey)return gr([e.pubkey,p1.OP_CHECKSIG])}),we(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),we(n,"signature",()=>{if(e.input)return r()[0]}),we(n,"input",()=>{if(e.signature)return gr([e.signature])}),we(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==p1.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!mn(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&ee(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&ee(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!ui(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function aT(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function g1(e,...t){if(!aT(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function w1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function cT(e,t){g1(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ff=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ln=(e,t)=>e<<32-t|e>>>t,yu=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function uT(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function b1(e){return typeof e=="string"&&(e=uT(e)),g1(e),e}class lT{clone(){return this._cloneInto()}}function m1(e){const t=n=>e().update(b1(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function hT(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const fT=(e,t,r)=>e&t^~e&r,dT=(e,t,r)=>e&t^e&r^t&r;let v1=class extends lT{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ff(this.buffer)}update(e){w1(this);const{view:t,buffer:r,blockLen:n}=this;e=b1(e);const i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const a=ff(e);for(;n<=i-o;o+=n)this.process(a,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){w1(this),cT(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let h=o;h<n;h++)t[h]=0;hT(r,n-8,BigInt(this.length*8),i),this.process(r,0);const s=ff(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)s.setUint32(4*h,f[h],i)}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}};const pT=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),E1=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),yT=E1.map(e=>(9*e+5)%16);let df=[E1],pf=[yT];for(let e=0;e<4;e++)for(let t of[df,pf])t.push(t[e].map(r=>pT[r]));const A1=[[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)),gT=df.map((e,t)=>e.map(r=>A1[t][r])),wT=pf.map((e,t)=>e.map(r=>A1[t][r])),bT=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),mT=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function S1(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const gu=new Uint32Array(16);class vT extends v1{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)gu[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=bT[v],x=mT[v],N=df[v],I=pf[v],k=gT[v],B=wT[v];for(let W=0;W<16;W++){const V=yu(n+S1(v,o,a,f)+gu[N[W]]+T,k[W])+d|0;n=d,d=f,f=yu(a,10)|0,a=o,o=V}for(let W=0;W<16;W++){const V=yu(i+S1(E,s,u,h)+gu[I[W]]+x,B[W])+g|0;i=g,g=h,h=yu(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){gu.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const ET=m1(()=>new vT),AT=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]),zi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wi=new Uint32Array(64);let ST=class extends v1{constructor(){super(64,32,8,!1),this.A=zi[0]|0,this.B=zi[1]|0,this.C=zi[2]|0,this.D=zi[3]|0,this.E=zi[4]|0,this.F=zi[5]|0,this.G=zi[6]|0,this.H=zi[7]|0}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=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let h=0;h<16;h++,t+=4)Wi[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const d=Wi[h-15],g=Wi[h-2],v=Ln(d,7)^Ln(d,18)^d>>>3,E=Ln(g,17)^Ln(g,19)^g>>>10;Wi[h]=E+Wi[h-7]+v+Wi[h-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:f}=this;for(let h=0;h<64;h++){const d=Ln(s,6)^Ln(s,11)^Ln(s,25),g=f+d+fT(s,a,u)+AT[h]+Wi[h]|0,v=(Ln(r,2)^Ln(r,13)^Ln(r,22))+dT(r,n,i)|0;f=u,u=a,a=s,s=o+g|0,o=i,i=n,n=r,r=g+v|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,n,i,o,s,a,u,f)}roundClean(){Wi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const rr=m1(()=>new ST);function li(e){return ET(rr(e))}function Ts(e){return rr(rr(e))}const TT={"BIP0340/challenge":Uint8Array.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":Uint8Array.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":Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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":Uint8Array.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":Uint8Array.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])};function wu(e,t){return rr(ht([TT[e],t]))}function _T(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let I=f[g],k=0;for(let B=E-1;(I!==0||k<d)&&B!==-1;B--,k++)I+=256*T[B]>>>0,T[B]=I%r>>>0,I=I/r>>>0;if(I!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let I=t[f.charCodeAt(h)];if(I===255)return;let k=0;for(let B=v-1;(I!==0||k<g)&&B!==-1;B--,k++)I+=r*E[B]>>>0,E[B]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var kT="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const yf=_T(kT);function PT(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),yf.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=yf.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=yf.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function OT(e){return rr(rr(e))}const aa=PT(OT),qi=Ge;function ca(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Vi(xt({network:xt({}),address:Ss(),hash:Y5,output:Ut(25),pubkey:bn(mn),signature:bn(ui),input:Me})),e);const r=Mr(()=>{const s=aa.decode(e.address),a=ai(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Mr(()=>mt(e.input)),i=e.network||wn,o={name:"p2pkh",network:i};if(we(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Pr(s,0,i.pubKeyHash),s.set(o.hash,1),aa.encode(s)}),we(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return li(e.pubkey||o.pubkey)}),we(o,"output",()=>{if(o.hash)return gr([qi.OP_DUP,qi.OP_HASH160,o.hash,qi.OP_EQUALVERIFY,qi.OP_CHECKSIG])}),we(o,"pubkey",()=>{if(e.input)return n()[1]}),we(o,"signature",()=>{if(e.input)return n()[0]}),we(o,"input",()=>{if(e.pubkey&&e.signature)return gr([e.signature,e.pubkey])}),we(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==qi.OP_DUP||e.output[1]!==qi.OP_HASH160||e.output[2]!==20||e.output[23]!==qi.OP_EQUALVERIFY||e.output[24]!==qi.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=li(e.pubkey);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!ui(a[0]))throw new TypeError("Input has invalid signature");if(!mn(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&ee(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=li(a[1]);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const ua=Ge;function ao(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Vi(xt({network:xt({}),address:Ss(),hash:Ut(20),output:Ut(23),redeem:Vi(xt({network:xt({}),output:Me,input:Me,witness:pr(Me)})),input:Me,witness:pr(Me)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||wn);const n={network:r},i=Mr(()=>{const a=aa.decode(e.address),u=ai(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Mr(()=>mt(e.input)),s=Mr(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===ua.OP_FALSE?Uint8Array.from([]):u,input:gr(a.slice(0,-1)),witness:e.witness||[]}});if(we(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Pr(a,0,n.network.scriptHash),a.set(n.hash,1),aa.encode(a)}),we(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return li(n.redeem.output)}),we(n,"output",()=>{if(n.hash)return gr([ua.OP_HASH160,n.hash,ua.OP_EQUAL])}),we(n,"redeem",()=>{if(e.input)return s()}),we(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return gr([].concat(mt(e.redeem.input),e.redeem.output))}),we(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),we(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&ee(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==ua.OP_HASH160||e.output[1]!==20||e.output[22]!==ua.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&ee(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=mt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(f1(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=li(f.output);if(a.length>0&&ee(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=mt(f.input);if(!lf(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&ee(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&ee(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!sa(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function IT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function xT(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var la={};Object.defineProperty(la,"__esModule",{value:!0});var ha=la.bech32m=Or=la.bech32=void 0;const bu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",T1={};for(let e=0;e<bu.length;e++){const t=bu.charAt(e);T1[t]=e}function co(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function _1(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=co(t)^n>>5}t=co(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=co(t)^n&31}return t}function gf(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],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 $T(e){return gf(e,8,5,!0)}function CT(e){const t=gf(e,5,8,!1);if(Array.isArray(t))return t}function NT(e){const t=gf(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function k1(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=_1(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=co(f)^g,h+=bu.charAt(g)}for(let d=0;d<6;++d)f=co(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=bu.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=_1(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=T1[x];if(N===void 0)return"Unknown character "+x;v=co(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:$T,fromWordsUnsafe:CT,fromWords:NT}}var Or=la.bech32=k1("bech32");ha=la.bech32m=k1("bech32m");const P1=Ge,UT=new Uint8Array(0);function fa(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Vi(xt({address:Ss(),hash:Ut(20),input:Ut(0),network:xt({}),output:Ut(22),pubkey:bn(mn,"Not a valid pubkey"),signature:bn(ui),witness:pr(Me)})),e);const r=Mr(()=>{const o=Or.decode(e.address),s=o.words.shift(),a=Or.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||wn,i={name:"p2wpkh",network:n};if(we(i,"address",()=>{if(!i.hash)return;const o=Or.toWords(i.hash);return o.unshift(0),Or.encode(n.bech32,o)}),we(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return li(e.pubkey||i.pubkey)}),we(i,"output",()=>{if(i.hash)return gr([P1.OP_0,i.hash])}),we(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),we(i,"signature",()=>{if(e.witness)return e.witness[0]}),we(i,"input",()=>{if(i.witness)return UT}),we(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&ee(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==P1.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&ee(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=li(e.pubkey);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!mn(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!ui(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!mn(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&ee(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=li(e.witness[1]);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const O1=Ge,wf=new Uint8Array(0);function mu(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&mn(e))}function da(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(s1({network:xt({}),address:Ss(),hash:J5,output:Ut(34),redeem:s1({input:Me,network:xt({}),output:Me,witness:pr(Me)}),input:Ut(0),witness:pr(Me)}),e);const r=Mr(()=>{const s=Or.decode(e.address),a=s.words.shift(),u=Or.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Mr(()=>mt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||wn);const o={network:i};if(we(o,"address",()=>{if(!o.hash)return;const s=Or.toWords(o.hash);return s.unshift(0),Or.encode(i.bech32,s)}),we(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return rr(o.redeem.output)}),we(o,"output",()=>{if(o.hash)return gr([O1.OP_0,o.hash])}),we(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:wf,witness:e.witness.slice(0,-1)}}),we(o,"input",()=>{if(o.witness)return wf}),we(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=sT(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=wf,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),we(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==O1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=mt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(f1(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=rr(e.redeem.output);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!lf(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!sa(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(mu)||e.redeem.output&&(mt(e.redeem.output)||[]).some(mu))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&ee(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(mu)||(mt(a)||[]).some(mu))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const pa={};function RT(e){e?e!==pa.eccLib&&(BT(e),pa.eccLib=e):pa.eccLib=e}function bf(){if(!pa.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return pa.eccLib}const hi=e=>oi(e);function BT(e){Fr(typeof e.isXOnlyPoint=="function"),Fr(e.isXOnlyPoint(hi("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Fr(e.isXOnlyPoint(hi("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Fr(e.isXOnlyPoint(hi("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Fr(e.isXOnlyPoint(hi("0000000000000000000000000000000000000000000000000000000000000001"))),Fr(!e.isXOnlyPoint(hi("0000000000000000000000000000000000000000000000000000000000000000"))),Fr(!e.isXOnlyPoint(hi("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Fr(typeof e.xOnlyPointAddTweak=="function"),HT.forEach(t=>{const r=e.xOnlyPointAddTweak(hi(t.pubkey),hi(t.tweak));t.result===null?Fr(r===null):(Fr(r!==null),Fr(r.parity===t.parity),Fr(ee(r.xOnlyPubkey,hi(t.result))===0))})}function Fr(e){if(!e)throw new Error("ecc library invalid")}const HT=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],I1="0123456789abcdefABCDEF";I1.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=I1.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function LT(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function KT(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function jT(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function DT(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function MT(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function FT(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const VT=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function zT(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function x1(e){typeof e=="number"?zT(e):VT(e)}function Gi(e,t,r){x1(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Vr(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),LT(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),KT(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),jT(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function uo(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=DT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=MT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=FT(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Vr(e){return x1(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const WT=9007199254740991;function qT(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function mf(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}function $1(e){const t=new Uint8Array(e.length);return t.set(e),t}class qt{constructor(t,r=0){ge(this,"buffer"),ge(this,"offset"),this.buffer=t,this.offset=r,ft(Hn([Me,ci]),[t,r])}static withCapacity(t){return new qt(new Uint8Array(t))}writeUInt8(t){this.offset=Pr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Vg(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=zg(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=na(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=K5(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=Gi(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}class GT{constructor(t,r=0){ge(this,"buffer"),ge(this,"offset"),this.buffer=t,this.offset=r,ft(Hn([Me,ci]),[t,r])}readUInt8(){const t=ai(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=D5(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=io(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=Wg(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=uo(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){qT(t,WT);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}}const C1=192,XT=128,JT=e=>"left"in e&&"right"in e;function vf(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 i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);ee(n,o)<0?n=Af(n,o):n=Af(o,n)}return n}function Ef(e){if(cf(e))return{hash:fi(e)};const t=[Ef(e[0]),Ef(e[1])];t.sort((i,o)=>ee(i.hash,o.hash));const[r,n]=t;return{hash:Af(r.hash,n.hash),left:r,right:n}}function vu(e,t){if(JT(e)){const r=vu(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=vu(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(ee(e.hash,t)===0)return[]}function fi(e){const t=e.version||C1;return wu("TapLeaf",ht([Uint8Array.from([t]),ZT(e.output)]))}function YT(e,t){return wu("TapTweak",ht(t?[e,t]:[e]))}function Eu(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=YT(e,t),n=bf().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function Af(e,t){return wu("TapBranch",ht([e,t]))}function ZT(e){const t=Vr(e.length),r=new Uint8Array(t);return Gi(e.length,r),ht([r,e])}const N1=Ge,U1=1,QT=80;function ya(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ft(Vi(xt({address:Ss(),input:Ut(0),network:xt({}),output:Ut(34),internalPubkey:Ut(32),hash:Ut(32),pubkey:Ut(32),signature:af([Ut(64),Ut(65)]),witness:pr(Me),scriptTree:bn(n1,"Taptree is not of type isTaptree"),redeem:Vi(xt({output:Me,redeemVersion:yr(),witness:pr(Me)})),redeemVersion:yr()})),e);const r=Mr(()=>D1(e.address)),n=Mr(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===QT?e.witness.slice(0,-1):e.witness.slice()}),i=Mr(()=>{if(e.scriptTree)return Ef(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||wn,s={name:"p2tr",network:o};if(we(s,"address",()=>{if(!s.pubkey)return;const a=ha.toWords(s.pubkey);return a.unshift(U1),ha.encode(o.bech32,a)}),we(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&lu,d=u[u.length-2],g=fi({output:d,version:h});return vf(f,g)}return null}),we(s,"output",()=>{if(s.pubkey)return gr([N1.OP_1,s.pubkey])}),we(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:C1),we(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&lu}}),we(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=Eu(s.internalPubkey,s.hash);if(a)return a.x}}),we(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),we(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),we(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=fi({output:e.redeem.output,version:s.redeemVersion}),f=vu(a,u);if(!f)return;const h=Eu(e.internalPubkey,a.hash);if(!h)return;const d=ht([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==U1)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&ee(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==N1.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&ee(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=Eu(e.internalPubkey,s.hash);if(a.length>0&&ee(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!bf().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&ee(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=fi({output:e.redeem.output,version:s.redeemVersion});if(!vu(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(mt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&ee(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!sa(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&ee(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&ee(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!bf().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&lu,E=f[f.length-2],T=fi({output:E,version:v}),x=vf(h,T),N=Eu(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&ee(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const R1=40,B1=2,H1=16,L1=2,K1=80,j1="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 e_(e,t){const r=e.slice(2);if(r.length<B1||r.length>R1)throw new TypeError("Invalid program length for segwit address");const n=e[0]-K1;if(n<L1||n>H1)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(j1),r_(r,n,t.bech32)}function t_(e){const t=aa.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=ai(t,0),n=t.slice(1);return{version:r,hash:n}}function D1(e){let t,r;try{t=Or.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=ha.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=Or.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function r_(e,t,r){const n=Or.toWords(e);return n.unshift(t),t===0?Or.encode(r,n):ha.encode(r,n)}function ga(e,t){t=t||wn;try{return ca({output:e,network:t}).address}catch{}try{return ao({output:e,network:t}).address}catch{}try{return fa({output:e,network:t}).address}catch{}try{return da({output:e,network:t}).address}catch{}try{return ya({output:e,network:t}).address}catch{}try{return e_(e,t)}catch{}throw new Error(iT(e)+" has no matching Address")}function M1(e,t){t=t||wn;let r,n;try{r=t_(e)}catch{}if(r){if(r.version===t.pubKeyHash)return ca({hash:r.hash}).output;if(r.version===t.scriptHash)return ao({hash:r.hash}).output}else{try{n=D1(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return fa({hash:n.data}).output;if(n.data.length===32)return da({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return ya({pubkey:n.data}).output}else if(n.version>=L1&&n.version<=H1&&n.data.length>=B1&&n.data.length<=R1)return console.warn(j1),gr([n.version+K1,n.data])}}throw new Error(e+" has no matching Script")}function Kn(e){const t=e.length;return Vr(t)+t}function n_(e){const t=e.length;return Vr(t)+e.reduce((r,n)=>r+Kn(n),0)}const Xi=new Uint8Array(0),F1=[],Sf=oi("0000000000000000000000000000000000000000000000000000000000000000"),V1=oi("0000000000000000000000000000000000000000000000000000000000000001"),i_=oi("ffffffffffffffff"),s_={script:Xi,valueBuffer:i_};function o_(e){return e.value!==void 0}const vn=class et{constructor(){ge(this,"version",1),ge(this,"locktime",0),ge(this,"ins",[]),ge(this,"outs",[])}static fromBuffer(t,r){const n=new GT(t),i=new et;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===et.ADVANCED_TRANSACTION_MARKER&&s===et.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:F1});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].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(t){return et.fromBuffer(oi(t),!1)}static isCoinbaseHash(t){ft(i1,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&et.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return ft(Hn([i1,ci,of(uu(ci)),of(uu(Me))]),[t,r,n,i]),n==null&&(n=et.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||Xi,sequence:n,witness:F1})-1}addOutput(t,r){return ft(Hn([Me,uf]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Vr(this.ins.length)+Vr(this.outs.length)+this.ins.reduce((n,i)=>n+40+Kn(i.script),0)+this.outs.reduce((n,i)=>n+8+Kn(i.script),0)+(r?this.ins.reduce((n,i)=>n+n_(i.witness),0):0)}clone(){const t=new et;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(ft(Hn([ci,Me,yr()]),[t,r,n]),t>=this.ins.length)return V1;const i=gr(mt(r).filter(a=>a!==Ge.OP_CODESEPARATOR)),o=this.clone();if((n&31)===et.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===et.SIGHASH_SINGLE){if(t>=this.outs.length)return V1;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=s_;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&et.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=Xi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Vg(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),Ts(s)}hashForWitnessV1(t,r,n,i,o,s){if(ft(Hn([ci,pr(Me),pr(uf),ci]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===et.SIGHASH_DEFAULT?et.SIGHASH_ALL:i&et.SIGHASH_OUTPUT_MASK,u=(i&et.SIGHASH_INPUT_MASK)===et.SIGHASH_ANYONECANPAY,f=a===et.SIGHASH_NONE,h=a===et.SIGHASH_SINGLE;let d=Xi,g=Xi,v=Xi,E=Xi,T=Xi;if(!u){let k=qt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=rr(k.end()),k=qt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=rr(k.end()),k=qt.withCapacity(r.map(Kn).reduce((B,W)=>B+W)),r.forEach(B=>k.writeVarSlice(B)),v=rr(k.end()),k=qt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=rr(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=qt.withCapacity(8+Kn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=rr(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(W=>8+Kn(W.script)).reduce((W,V)=>W+V),B=qt.withCapacity(k);this.outs.forEach(W=>{B.writeInt64(W.value),B.writeVarSlice(W.script)}),T=rr(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),I=qt.withCapacity(N);if(I.writeUInt8(i),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(d),I.writeSlice(g),I.writeSlice(v),I.writeSlice(E),f||h||I.writeSlice(T),I.writeUInt8(x),u){const k=this.ins[t];I.writeSlice(k.hash),I.writeUInt32(k.index),I.writeInt64(n[t]),I.writeVarSlice(r[t]),I.writeUInt32(k.sequence)}else I.writeUInt32(t);if(s){const k=qt.withCapacity(Kn(s));k.writeVarSlice(s),I.writeSlice(rr(k.end()))}return h&&I.writeSlice(T),o&&(I.writeSlice(o),I.writeUInt8(0),I.writeUInt32(4294967295)),wu("TapSighash",ht([Uint8Array.from([0]),I.end()]))}hashForWitnessV0(t,r,n,i){ft(Hn([ci,Me,uf,ci]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=Sf,u=Sf,f=Sf;if(i&et.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=Ts(o)),!(i&et.SIGHASH_ANYONECANPAY)&&(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=Ts(o)),(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+Kn(v.script),0);o=new Uint8Array(d),s=new qt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=Ts(o)}else if((i&31)===et.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+Kn(d.script)),s=new qt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=Ts(o)}o=new Uint8Array(156+Kn(r)),s=new qt(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),Ts(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):Ts(this.__toBuffer(void 0,void 0,t))}getId(){return Ee(mf(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return Ee(this.toBuffer(void 0,void 0))}setInputScript(t,r){ft(Hn([yr(),Me]),[t,r]),this.ins[t].script=r}setWitness(t,r){ft(Hn([yr(),pr(Me)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new qt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(et.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(et.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{o_(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};ge(vn,"DEFAULT_SEQUENCE",4294967295),ge(vn,"SIGHASH_DEFAULT",0),ge(vn,"SIGHASH_ALL",1),ge(vn,"SIGHASH_NONE",2),ge(vn,"SIGHASH_SINGLE",3),ge(vn,"SIGHASH_ANYONECANPAY",128),ge(vn,"SIGHASH_OUTPUT_MASK",3),ge(vn,"SIGHASH_INPUT_MASK",128),ge(vn,"ADVANCED_TRANSACTION_MARKER",0),ge(vn,"ADVANCED_TRANSACTION_FLAG",1);let _t=vn;var jn;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})(jn||(jn={}));var se;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(se||(se={}));var kt;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(kt||(kt={}));const a_=e=>[...Array(e).keys()];function c_(e){if(e.key[0]!==jn.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+Ee(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+Ee(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of a_(e.value.length/4-1)){const i=io(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function u_(e){const t=new Uint8Array([jn.GLOBAL_XPUB]),r=ht([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),na(i,o,u,"LE"),o+=4}),{key:r,value:i}}const l_="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function h_(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function f_(e,t,r){const n=Ee(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.extendedPubkey,t.extendedPubkey)).length===0)}const d_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:f_,check:h_,decode:c_,encode:u_,expected:l_},Symbol.toStringTag,{value:"Module"}));function p_(e){return{key:new Uint8Array([jn.UNSIGNED_TX]),value:e.toBuffer()}}const y_=Object.freeze(Object.defineProperty({__proto__:null,encode:p_},Symbol.toStringTag,{value:"Module"}));function g_(e){if(e.key[0]!==se.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+Ee(e.key));return e.value}function w_(e){return{key:new Uint8Array([se.FINAL_SCRIPTSIG]),value:e}}const b_="Uint8Array";function m_(e){return e instanceof Uint8Array}function v_(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const E_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:v_,check:m_,decode:g_,encode:w_,expected:b_},Symbol.toStringTag,{value:"Module"}));function A_(e){if(e.key[0]!==se.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+Ee(e.key));return e.value}function S_(e){return{key:new Uint8Array([se.FINAL_SCRIPTWITNESS]),value:e}}const T_="Uint8Array";function __(e){return e instanceof Uint8Array}function k_(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const P_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:k_,check:__,decode:A_,encode:S_,expected:T_},Symbol.toStringTag,{value:"Module"}));function O_(e){if(e.key[0]!==se.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+Ee(e.key));return e.value}function I_(e){return{key:new Uint8Array([se.NON_WITNESS_UTXO]),value:e}}const x_="Uint8Array";function $_(e){return e instanceof Uint8Array}function C_(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const N_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:C_,check:$_,decode:O_,encode:I_,expected:x_},Symbol.toStringTag,{value:"Module"}));function U_(e){if(e.key[0]!==se.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+Ee(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+Ee(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function R_(e){const t=new Uint8Array([se.PARTIAL_SIG]);return{key:ht([t,e.pubkey]),value:e.signature}}const B_="{ pubkey: Uint8Array; signature: Uint8Array; }";function H_(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&L_(e.signature)}function L_(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function K_(e,t,r){const n=Ee(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0).length===0)}const j_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:K_,check:H_,decode:U_,encode:R_,expected:B_},Symbol.toStringTag,{value:"Module"}));function D_(e){if(e.key[0]!==se.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+Ee(e.key));return N5(e.value)}function M_(e){return{key:new Uint8Array([se.POR_COMMITMENT]),value:U5(e)}}const F_="string";function V_(e){return typeof e=="string"}function z_(e,t){return!!e&&!!t&&e.porCommitment===void 0}const W_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:z_,check:V_,decode:D_,encode:M_,expected:F_},Symbol.toStringTag,{value:"Module"}));function q_(e){if(e.key[0]!==se.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+Ee(e.key));return Number(io(e.value,0,"LE"))}function G_(e){const t=Uint8Array.from([se.SIGHASH_TYPE]),r=new Uint8Array(4);return na(r,0,e,"LE"),{key:t,value:r}}const X_="number";function J_(e){return typeof e=="number"}function Y_(e,t){return!!e&&!!t&&e.sighashType===void 0}const Z_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:Y_,check:J_,decode:q_,encode:G_,expected:X_},Symbol.toStringTag,{value:"Module"}));function Q_(e){if(e.key[0]!==se.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+Ee(e.key));if(!z1(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function ek(e){return{key:Uint8Array.from([se.TAP_KEY_SIG]),value:e}}const tk="Uint8Array";function z1(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function rk(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const nk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:rk,check:z1,decode:Q_,encode:ek,expected:tk},Symbol.toStringTag,{value:"Module"}));function ik(e){if(e.key[0]!==se.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+Ee(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+Ee(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+Ee(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function sk(e){const t=Uint8Array.from([se.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:ht([t,e.controlBlock]),value:ht([e.script,r])}}const ok="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function ak(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ck(e,t,r){const n=Ee(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.controlBlock,t.controlBlock)===0).length===0)}const uk=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ck,check:ak,decode:ik,encode:sk,expected:ok},Symbol.toStringTag,{value:"Module"}));function lk(e){if(e.key[0]!==se.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+Ee(e.key));if(!W1(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function hk(e){return{key:Uint8Array.from([se.TAP_MERKLE_ROOT]),value:e}}const fk="Uint8Array";function W1(e){return e instanceof Uint8Array&&e.length===32}function dk(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const pk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:dk,check:W1,decode:lk,encode:hk,expected:fk},Symbol.toStringTag,{value:"Module"}));function yk(e){if(e.key[0]!==se.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+Ee(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+Ee(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+Ee(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function gk(e){const t=Uint8Array.from([se.TAP_SCRIPT_SIG]);return{key:ht([t,e.pubkey,e.leafHash]),value:e.signature}}const wk="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function bk(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function mk(e,t,r){const n=Ee(t.pubkey)+Ee(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0&&ee(i.leafHash,t.leafHash)===0).length===0)}const vk=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:mk,check:bk,decode:yk,encode:gk,expected:wk},Symbol.toStringTag,{value:"Module"}));function Ek(e){if(e.key[0]!==se.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+Ee(e.key));const t=Wg(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=uo(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function Ak(e){const{script:t,value:r}=e,n=Vr(t.length),i=new Uint8Array(8+n+t.length);return zg(i,0,BigInt(r),"LE"),Gi(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([se.WITNESS_UTXO]),value:i}}const Sk="{ script: Uint8Array; value: bigint; }";function Tk(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function _k(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const kk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:_k,check:Tk,decode:Ek,encode:Ak,expected:Sk},Symbol.toStringTag,{value:"Module"}));function Pk(e){if(e.key[0]!==kt.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+Ee(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=uo(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function Ok(e){const t=Uint8Array.from([kt.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),Gi(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:ht(r)}}const Ik="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function xk(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function $k(e,t){return!!e&&!!t&&e.tapTree===void 0}const Ck=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$k,check:xk,decode:Pk,encode:Ok,expected:Ik},Symbol.toStringTag,{value:"Module"})),Nk=e=>[...Array(e).keys()],Uk=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Tf(e,t=Uk){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+Ee(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+Ee(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of Nk(a.value.length/4-1)){const d=io(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=ht([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),na(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=Ee(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>ee(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function _f(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+Ee(r.key));return n}}function q1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Rk=e=>e.length===32;function G1(e){const t=Tf(e,Rk);function r(s){const{numberValue:a,bytes:u}=uo(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Vr(s.leafHashes.length),f=new Uint8Array(u);Gi(s.leafHashes.length,f);const h=ht([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function X1(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+Ee(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function J1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const kf={unsignedTx:y_,globalXpub:d_,checkPubkey:_f([])},Rt={nonWitnessUtxo:N_,partialSig:j_,sighashType:Z_,finalScriptSig:E_,finalScriptWitness:P_,porCommitment:W_,witnessUtxo:kk,bip32Derivation:Tf(se.BIP32_DERIVATION),redeemScript:q1(se.REDEEM_SCRIPT),witnessScript:J1(se.WITNESS_SCRIPT),checkPubkey:_f([se.PARTIAL_SIG,se.BIP32_DERIVATION]),tapKeySig:nk,tapScriptSig:vk,tapLeafScript:uk,tapBip32Derivation:G1(se.TAP_BIP32_DERIVATION),tapInternalKey:X1(se.TAP_INTERNAL_KEY),tapMerkleRoot:pk},di={bip32Derivation:Tf(kt.BIP32_DERIVATION),redeemScript:q1(kt.REDEEM_SCRIPT),witnessScript:J1(kt.WITNESS_SCRIPT),checkPubkey:_f([kt.BIP32_DERIVATION]),tapBip32Derivation:G1(kt.TAP_BIP32_DERIVATION),tapTree:Ck,tapInternalKey:X1(kt.TAP_INTERNAL_KEY)},Bk=Object.freeze(Object.defineProperty({__proto__:null,globals:kf,inputs:Rt,outputs:di},Symbol.toStringTag,{value:"Module"})),Au=e=>[...Array(e).keys()];function Y1(e){const t=e.map(Hk);return t.push(Uint8Array.from([0])),ht(t)}function Hk(e){const t=e.key.length,r=e.value.length,n=Vr(t),i=Vr(r),o=new Uint8Array(n+t+i+r);return Gi(t,o,0),o.set(e.key,n),Gi(r,o,n+t),o.set(e.value,n+t+i),o}function Lk(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=uo(e,r);r+=N;const I=e.slice(r,r+Number(x));return r+=Number(x),I}function i(){const x=io(e,r,"BE");return r+=4,x}function o(){const x=ai(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=ai(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=Ee(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===jn.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of Au(g)){const N={},I=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,I.push(k)}E.push(I)}for(const x of Au(v)){const N={},I=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,I.push(k)}T.push(I)}return Z1(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Gt(e,t,r){if(ee(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${Ee(t)}`)}function Z1(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case jn.UNSIGNED_TX:if(Gt("global",h.key,jn.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case jn.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(kf.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of Au(s)){const d={};for(const g of r[h])switch(Rt.checkPubkey(g),g.key[0]){case se.NON_WITNESS_UTXO:if(Gt("input",g.key,se.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Rt.nonWitnessUtxo.decode(g);break;case se.WITNESS_UTXO:if(Gt("input",g.key,se.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Rt.witnessUtxo.decode(g);break;case se.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Rt.partialSig.decode(g));break;case se.SIGHASH_TYPE:if(Gt("input",g.key,se.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Rt.sighashType.decode(g);break;case se.REDEEM_SCRIPT:if(Gt("input",g.key,se.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Rt.redeemScript.decode(g);break;case se.WITNESS_SCRIPT:if(Gt("input",g.key,se.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Rt.witnessScript.decode(g);break;case se.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Rt.bip32Derivation.decode(g));break;case se.FINAL_SCRIPTSIG:Gt("input",g.key,se.FINAL_SCRIPTSIG),d.finalScriptSig=Rt.finalScriptSig.decode(g);break;case se.FINAL_SCRIPTWITNESS:Gt("input",g.key,se.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Rt.finalScriptWitness.decode(g);break;case se.POR_COMMITMENT:Gt("input",g.key,se.POR_COMMITMENT),d.porCommitment=Rt.porCommitment.decode(g);break;case se.TAP_KEY_SIG:Gt("input",g.key,se.TAP_KEY_SIG),d.tapKeySig=Rt.tapKeySig.decode(g);break;case se.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Rt.tapScriptSig.decode(g));break;case se.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Rt.tapLeafScript.decode(g));break;case se.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Rt.tapBip32Derivation.decode(g));break;case se.TAP_INTERNAL_KEY:Gt("input",g.key,se.TAP_INTERNAL_KEY),d.tapInternalKey=Rt.tapInternalKey.decode(g);break;case se.TAP_MERKLE_ROOT:Gt("input",g.key,se.TAP_MERKLE_ROOT),d.tapMerkleRoot=Rt.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of Au(a)){const d={};for(const g of n[h])switch(di.checkPubkey(g),g.key[0]){case kt.REDEEM_SCRIPT:if(Gt("output",g.key,kt.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=di.redeemScript.decode(g);break;case kt.WITNESS_SCRIPT:if(Gt("output",g.key,kt.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=di.witnessScript.decode(g);break;case kt.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(di.bip32Derivation.decode(g));break;case kt.TAP_INTERNAL_KEY:Gt("output",g.key,kt.TAP_INTERNAL_KEY),d.tapInternalKey=di.tapInternalKey.decode(g);break;case kt.TAP_TREE:Gt("output",g.key,kt.TAP_TREE),d.tapTree=di.tapTree.decode(g);break;case kt.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(di.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function Kk({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=Of({globalMap:e,inputs:t,outputs:r}),s=Y1(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(Y1),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),ht([h,s].concat(u,f))}const jk=(e,t)=>ee(e.key,t.key);function Pf(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>Ee(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(Ee(o.key))):[];return n.concat(i).sort(jk)}function Of({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Pf(e,kf),inputKeyVals:t.map(n=>Pf(n,Rt)),outputKeyVals:r.map(n=>Pf(n,di))}}function Dk(e){const t=e[0],r=Of(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Q1(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=lo(r.globalKeyVals),s=r.inputKeyVals.map(lo),a=r.outputKeyVals.map(lo);for(const u of n){const f=Q1(u);if(f===void 0||ee(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=Of(u);lo(h.globalKeyVals).forEach(If(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(lo).forEach((d,g)=>d.forEach(If(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(lo).forEach((d,g)=>d.forEach(If(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return Z1(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function If(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>Ee(o.key)===n)[0];t.push(i),e.add(n)}}function Q1(e){return e.globalMap.unsignedTx}function lo(e){const t=new Set;return e.forEach(r=>{const n=Ee(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function jt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function wa(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function xf(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>ee(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${Ee(e.key)}`)}function $f(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function Mk(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function ew(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Cf(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=Bk[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||ew(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||ew(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const Fk=Cf("global"),tw=Cf("input"),rw=Cf("output");function Vk(e,t){const r=e.length-1,n=jt(e,r);tw(t,n)}function zk(e,t){const r=e.length-1,n=wa(e,r);rw(t,n)}let nw=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=Fg(e);return this.fromBuffer(r,t)}static fromHex(e,t){const r=oi(e);return this.fromBuffer(r,t)}static fromBuffer(e,t){const r=Lk(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){const e=this.toBuffer();return H5(e)}toHex(){const e=this.toBuffer();return Ee(e)}toBuffer(){return Kk(this)}updateGlobal(e){return Fk(e,this.globalMap),this}updateInput(e,t){const r=jt(this.inputs,e);return tw(t,r),this}updateOutput(e,t){const r=wa(this.outputs,e);return rw(t,r),this}addUnknownKeyValToGlobal(e){return xf(e,this.globalMap.unknownKeyVals,$f(jn)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=jt(this.inputs,e);return xf(t,r.unknownKeyVals,$f(se)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=wa(this.outputs,e);return xf(t,r.unknownKeyVals,$f(kt)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.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(n=>this.addUnknownKeyValToInput(r,n)),Vk(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(n=>this.addUnknownKeyValToOutput(r,n)),zk(this.outputs,e),this}clearFinalizedInput(e){const t=jt(this.inputs,e);Mk(e,t);for(const r of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(r)||delete t[r];return this}combine(...e){const t=Dk([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function _s(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const Wk=_s(pu),qk=_s(y1),Gk=_s(ca),Su=_s(fa),iw=_s(da),sw=_s(ao),ow=_s(ya);function Tu(e){let t=new Uint8Array(0);function r(s){t=ht([t,s])}function n(s){const a=t.length,u=Vr(s);t=ht([t,new Uint8Array(u)]),Gi(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function aw(e,t){const r=li(e),n=e.slice(1,33),i=mt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:ee(e,o)===0||ee(r,o)===0||ee(n,o)===0)}function _u(e,t){return aw(e,t)!==-1}function Xk(e,t){return Jk(e).some(r=>cw(r,oa.decode,t))}function cw(e,t,r){const{hashType:n}=t(e),i=[];switch(n&_t.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case _t.SIGHASH_ALL:break;case _t.SIGHASH_SINGLE:case _t.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function Jk(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=Yk(e)}else t=e.partialSig;return t.map(r=>r.signature)}function Yk(e){const t=e.finalScriptSig?mt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?mt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&ui(n)).map(n=>({signature:n}))}const ku=e=>e.length===32?e:e.slice(1,33);function uw(e,t,r){const n=hP(t,e,r);try{const i=uP(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:Tu(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function Pu(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return ht([e,r])}function En(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&ow(e.witnessUtxo.script))}function Nf(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function lw(e,t,r){oP(e,t,r),cP(e,t,r)}function hw(e,t,r){aP(e,t,r),Zk(e,t)}function Zk(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=Qk(r,n);if(i&&ee(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function Qk(e,t){const r=t&&eP(t.leaves),{output:n}=ya({internalPubkey:e,scriptTree:r});return n}function eP(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:sP(e)}function tP(e,t){return nP(e).some(r=>cw(r,rP,t))}function rP(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||_t.SIGHASH_DEFAULT}}function nP(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=iP(e.finalScriptWitness);r&&t.push(r)}return t}function iP(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function sP(e){let t;for(const r of e)if(t=Uf(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function Uf(e,t,r=0){if(r>XT)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(cf(t))return;const n=Uf(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Uf(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function oP(e,t,r){const n=En(e)&&ho(t),i=ho(e)&&En(t),o=e===t&&En(t)&&ho(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function aP(e,t,r){const n=Nf(e)&&ho(t),i=ho(e)&&Nf(t),o=e===t&&Nf(t)&&ho(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function cP(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Rf(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Rf(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Rf(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Rf(e,t){if(!t)return!0;const r=fi({output:e.script,version:e.leafVersion}),n=vf(e.controlBlock,r);return ee(n,t)===0}function uP(e,t){const r=fi({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>ee(n.leafHash,r)===0).map(n=>lP(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function lP(e,t){return Object.assign({positionInScript:aw(t.pubkey,e)},t)}function hP(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>fP(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function fP(e,t,r){const n=fi({output:e.script,version:e.leafVersion});return(!r||ee(n,r)===0)&&t.find(i=>ee(i.leafHash,n)===0)!==void 0}function ho(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const dP={network:wn,maximumFeeRate:5e3};class dt{constructor(t={},r=new nw(new fw)){ge(this,"data"),ge(this,"__CACHE"),ge(this,"opts"),this.data=r,this.opts=Object.assign({},dP,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},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Fg(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=oi(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=nw.fromBuffer(t,pP),i=new dt(r,n);return mP(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:$1(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=ga(t.script,this.opts.network)}catch{}return{script:$1(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=dt.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){Ou(t),this.opts.maximumFeeRate=t}setVersion(t){Ou(t),ba(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){Ou(t),ba(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){Ou(r),ba(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");lw(t,t,"addInput"),ba(this.data.inputs,"addInput"),t.witnessScript&&$u(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];ww(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&Lf(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");ba(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=M1(r,i);t=Object.assign({},t,{script:o})}hw(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(pw))throw new Error("Not finalized");const r=this.__CACHE;if(t||gP(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return Iw(this.data.inputs,n,r,!0),n}getFeeRate(){return Ew("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return Ew("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return jt(this.data.inputs,0),ma(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=jt(this.data.inputs,t);return En(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=uw){const i=jt(this.data.inputs,t);if(En(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=vP){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=TP(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);wP(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=uw){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=ya({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=Tu(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=jt(this.data.inputs,t),n=xw(t,r,this.__CACHE),i=xu(n,t,"input",r.redeemScript||IP(r.finalScriptSig),r.witnessScript||xP(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=Cw(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=jt(this.data.inputs,t);return PP(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=jt(this.data.inputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=wa(this.data.outputs,t);return OP(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=wa(this.data.outputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return jt(this.data.inputs,0),ma(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return En(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>ee(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=oa.decode(d.signature),{hash:v,script:E}=h!==g.hashType?Sw(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,gw(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&ku(n);const a=n?Hf(t,i,this.data.inputs,n,this.__CACHE):AP(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,_w(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>ee(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,_w(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[_t.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of ma(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[_t.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of ma(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[_t.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return Pw(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[_t.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=Pw(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of ma(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return En(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(En(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[_t.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:oa.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[_t.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>Pu(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:ku(n.publicKey),signature:Pu(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return En(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(En(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[_t.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:oa.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[_t.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:Pu(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:ku(n.publicKey),signature:Pu(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=Hf(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${Ee(n.publicKey)}`);return s}toBuffer(){return Bf(this.__CACHE),this.data.toBuffer()}toHex(){return Bf(this.__CACHE),this.data.toHex()}toBase64(){return Bf(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&$u(r.witnessScript),lw(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&Lf(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return hw(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}const pP=e=>new fw(e);class fw{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){ge(this,"tx"),this.tx=_t.fromBuffer(t),bP(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?mf(oi(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function yP(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return dw(1,e.partialSig);case"multisig":const n=pu({output:t});return dw(n.m,e.partialSig,n.pubkeys);default:return!1}}function Bf(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function dw(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=$P(i);return t.find(s=>ee(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function pw(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function yw(e){return t=>!(ee(e.fingerprint,t.masterFingerprint)||ee(e.derivePath(t.path).publicKey,t.pubkey))}function Ou(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function gP(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.`)}function ba(e,t){e.forEach(r=>{if(En(r)?tP(r,t):Xk(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function wP(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=oa.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function gw(e,t,r){if(!_u(e,t))throw new Error(`Can not ${r} for this input with the key ${Ee(e)}`)}function bP(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function mP(e,t){e.ins.forEach(r=>{ww(t,r)})}function ww(e,t){const r=Ee(mf(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function bw(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(ee(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const mw=bw(ao,"Redeem script"),vw=bw(da,"Witness script");function Ew(e,t,r,n){if(!r.every(pw))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),Iw(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function vP(e,t,r,n,i,o){const s=Cw(r);if(!yP(t,r,s))throw new Error(`Can not finalize input #${e}`);return EP(r,s,t.partialSig,n,i,o)}function EP(e,t,r,n,i,o){let s,a;const u=SP(e,t,r),f=o?da({redeem:u}):null,h=i?ao({redeem:f||u}):null;return n?(f?a=Tu(f.witness):a=Tu(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function Aw(e,t,r,n,i){const o=jt(e,t),{hash:s,sighashType:a,script:u}=Sw(t,o,n,!1,i);return gw(r,u,"sign"),{hash:s,sighashType:a}}function Sw(e,t,r,n,i){const o=r.__TX,s=t.sighashType||_t.SIGHASH_ALL;kw(s,i);let a,u;if(t.nonWitnessUtxo){const d=Iu(r,t,e),g=o.ins[e].hash,v=d.getHash();if(ee(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=xu(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(Su(f)){const d=ca({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${Ee(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&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.
31
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};function O5(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}function x5(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(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}function $5(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)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(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=new Uint8Array(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,i.set(e,4),i[4+r]=2,i[5+r]=t.length,i.set(t,6+r),i}const qe={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},jg={};for(const e of Object.keys(qe)){const t=qe[e];jg[t]=e}const Zc="0123456789abcdefABCDEF",Qc=Zc.split("").map(e=>e.codePointAt(0)),eu=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Zc.indexOf(r);return n<0?void 0:n<16?n:n-6}),Dg=new TextEncoder,Mg=new TextDecoder;function C5(e){return Mg.decode(e)}function N5(e){return Dg.encode(e)}function lt(e){const t=e.reduce((i,o)=>i+o.length,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Ee(e){const t=e||new Uint8Array;return t.length>512?R5(t):U5(t)}function U5(e){let t="";for(let r=0;r<e.length;++r)t+=Zc[eu[Qc[e[r]>>4]]],t+=Zc[eu[Qc[e[r]&15]]];return t}function R5(e){const t=new Uint8Array(e.length*2);for(let r=0;r<e.length;++r)t[r*2]=Qc[e[r]>>4],t[r*2+1]=Qc[e[r]&15];return Mg.decode(t)}function ii(e){const t=Dg.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const i=eu[t[n*2]],o=eu[t[n*2+1]];if(i===void 0||o===void 0)break;r[n]=i<<4|o}return n===r.length?r:r.slice(0,n)}function B5(e){return btoa(String.fromCharCode(...e))}function Fg(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function ee(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function Pr(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function L5(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255),t+2}function ea(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);return n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function H5(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);return n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function si(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function K5(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function to(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function Vg(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>2147483647||r<-2147483648)throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255),t+4}function Wg(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>0x7fffffffffffffffn||r<-0x8000000000000000n)throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);return n=n.toUpperCase(),n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn)),t+8}function j5(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){const n=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0);return e[t+3]<=127?n:n-4294967296}else{const n=(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];return e[t]<=127?n:n-4294967296}}function zg(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");r=r.toUpperCase();let n=0n;if(r==="LE")return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),e[t+7]<=127?n:n-0x10000000000000000n;{let i=0n;return i=(i<<8n)+BigInt(e[t]),i=(i<<8n)+BigInt(e[t+1]),i=(i<<8n)+BigInt(e[t+2]),i=(i<<8n)+BigInt(e[t+3]),i=(i<<8n)+BigInt(e[t+4]),i=(i<<8n)+BigInt(e[t+5]),i=(i<<8n)+BigInt(e[t+6]),i=(i<<8n)+BigInt(e[t+7]),e[t]<=127?i:i-0x10000000000000000n}}function qg(e){return e<qe.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function D5(e,t,r){const n=qg(t);return n===1?Pr(e,r,t):n===2?(Pr(e,r,qe.OP_PUSHDATA1),Pr(e,r+1,t)):n===3?(Pr(e,r,qe.OP_PUSHDATA2),L5(e,r+1,t,"LE")):(Pr(e,r,qe.OP_PUSHDATA4),ea(e,r+1,t,"LE")),n}function M5(e,t){const r=si(e,t);let n,i;if(r<qe.OP_PUSHDATA1)n=r,i=1;else if(r===qe.OP_PUSHDATA1){if(t+2>e.length)return null;n=si(e,t+1),i=2}else if(r===qe.OP_PUSHDATA2){if(t+3>e.length)return null;n=K5(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==qe.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=to(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}function F5(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function V5(e){let t=Math.abs(e);const r=F5(t),n=new Uint8Array(r),i=e<0;for(let o=0;o<r;++o)Pr(n,o,t&255),t>>=8;return n[r-1]&128?Pr(n,r-1,i?128:0):i&&(n[r-1]|=128),n}function W5(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function z5(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function ta(e){var t,r;const n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null":n}function zt(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??ta(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??z5(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function q5(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var G5=class extends Error{constructor(e){super(e[0].message),be(this,"issues"),this.name="ValiError",this.issues=e}};function Gg(e,t){return{kind:"validation",type:"every_item",reference:Gg,async:!1,expects:null,requirement:e,message:t,_run(r,n){return r.typed&&!r.value.every(this.requirement)&&zt(this,"item",r,n),r}}}function ef(e){return{kind:"validation",type:"integer",reference:ef,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(t,r){return t.typed&&!this.requirement(t.value)&&zt(this,"integer",t,r),t}}}function Xg(e,t){return{kind:"validation",type:"length",reference:Xg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value.length!==this.requirement&&zt(this,"length",r,n,{received:`${r.value.length}`}),r}}}function tu(e,t){return{kind:"validation",type:"max_value",reference:tu,async:!1,expects:`<=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value>this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function ru(e,t){return{kind:"validation",type:"min_value",reference:ru,async:!1,expects:`>=${e instanceof Date?e.toJSON():ta(e)}`,requirement:e,message:t,_run(r,n){return r.typed&&r.value<this.requirement&&zt(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():ta(r.value)}),r}}}function Jg(e,t){return{kind:"validation",type:"regex",reference:Jg,async:!1,expects:`${e}`,requirement:e,message:t,_run(r,n){return r.typed&&!this.requirement.test(r.value)&&zt(this,"format",r,n),r}}}function tf(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function nu(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Yg(){return{kind:"schema",type:"any",reference:Yg,expects:"any",async:!1,_run(e){return e.typed=!0,e}}}function pr(e,t){return{kind:"schema",type:"array",reference:pr,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function Zg(e){return{kind:"schema",type:"bigint",reference:Zg,expects:"bigint",async:!1,message:e,_run(t,r){return typeof t.value=="bigint"?t.typed=!0:zt(this,"type",t,r),t}}}function yn(e,t){return{kind:"schema",type:"custom",reference:yn,expects:"unknown",async:!1,check:e,message:t,_run(r,n){return this.check(r.value)?r.typed=!0:zt(this,"type",r,n),r}}}function iu(e,t){return{kind:"schema",type:"instance",reference:iu,expects:e.name,async:!1,class:e,message:t,_run(r,n){return r.value instanceof this.class?r.typed=!0:zt(this,"type",r,n),r}}}function rf(e,...t){const r={kind:"schema",type:"nullable",reference:rf,expects:`(${e.expects} | null)`,async:!1,wrapped:e,_run(n,i){return n.value===null&&("default"in this&&(n.value=tf(this,n,i)),n.value===null)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Qg(e,...t){const r={kind:"schema",type:"nullish",reference:Qg,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=tf(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function yr(e){return{kind:"schema",type:"number",reference:yr,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:zt(this,"type",t,r),t}}}function Ot(e,t){return{kind:"schema",type:"object",reference:Ot,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else zt(this,"type",r,n);return r}}}function su(e,...t){const r={kind:"schema",type:"optional",reference:su,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=tf(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Es(e){return{kind:"schema",type:"string",reference:Es,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:zt(this,"type",t,r),t}}}function Ln(e,t){return{kind:"schema",type:"tuple",reference:Ln,expects:"Array",async:!1,items:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const a=o[s],u=this.items[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else zt(this,"type",r,n);return r}}}function e1(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function nf(e,t){return{kind:"schema",type:"union",reference:nf,expects:q5(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];zt(this,"type",r,n,{issues:e1(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];zt(this,"type",r,n,{issues:e1(s)})}return r}}}function ht(e,t,r){const n=e._run({typed:!1,value:t},W5(r));if(n.issues)throw new G5(n.issues);return n.value}function Di(e,t){const r={};for(const n in e.entries)r[n]=su(e.entries[n]);return{...e,entries:r}}function ro(...e){return{...e[0],pipe:e,_run(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n._run(t,r))}return t}}}const t1=new Uint8Array(32),r1=ii("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ut=e=>ro(iu(Uint8Array),Xg(e));function ra(e,t){return e.length!==t.length?!1:e.every((r,n)=>ee(r,t[n])===0)}function gn(e){if(!(e instanceof Uint8Array)||e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(ee(t1,r)===0||ee(r,r1)>=0)return!1;if((t===2||t===3)&&e.length===33)return!0;const n=e.slice(33);return ee(t1,n)===0||ee(n,r1)>=0?!1:t===4&&e.length===65}const ou=254;function sf(e){return!e||!("output"in e)||!(e.output instanceof Uint8Array)?!1:e.version!==void 0?(e.version&ou)===e.version:!0}function n1(e){return Array.isArray(e)?e.length!==2?!1:e.every(t=>n1(t)):sf(e)}const X5=Ut(32),J5=Ut(20),i1=Ut(32),Me=iu(Uint8Array);ro(Es(),Jg(/^([0-9a-f]{2})+$/i));const Y5=ro(yr(),ef(),ru(0),tu(255)),oi=ro(yr(),ef(),ru(0),tu(4294967295)),of=ro(Zg(),ru(0n),tu(0x7fffffffffffffffn)),s1=e=>Ot(Object.entries(e).reduce((t,r)=>({...t,[r[0]]:Qg(r[1])}),{})),o1=new Uint8Array(1);function a1(e){let t=0;for(;e[t]===0;)++t;return t===e.length?o1:(e=e.slice(t),e[0]&128?lt([o1,e]):e)}function c1(e){e[0]===0&&(e=e.slice(1));const t=new Uint8Array(32),r=Math.max(0,32-e.length);return t.set(e,r),t}function Z5(e){const t=si(e,e.length-1);if(!cf(t))throw new Error("Invalid hashType "+t);const r=x5(e.subarray(0,-1)),n=c1(r.r),i=c1(r.s);return{signature:lt([n,i]),hashType:t}}function Q5(e,t){if(ht(Ot({signature:Ut(64),hashType:Y5}),{signature:e,hashType:t}),!cf(t))throw new Error("Invalid hashType "+t);const r=new Uint8Array(1);Pr(r,0,t);const n=a1(e.slice(0,32)),i=a1(e.slice(32,64));return lt([$5(n,i),r])}const eT=Object.freeze(Object.defineProperty({__proto__:null,decode:Z5,encode:Q5},Symbol.toStringTag,{value:"Module"})),u1=qe.OP_RESERVED,l1=pr(nf([iu(Uint8Array),yr()]));function tT(e){return nu(yr(),e)&&(e===qe.OP_0||e>=qe.OP_1&&e<=qe.OP_16||e===qe.OP_1NEGATE)}function h1(e){return nu(Me,e)||tT(e)}function af(e){return nu(ro(Yg(),Gg(h1)),e)}function f1(e){return e.length-e.filter(h1).length}function au(e){if(e.length===0)return qe.OP_0;if(e.length===1){if(e[0]>=1&&e[0]<=16)return u1+e[0];if(e[0]===129)return qe.OP_1NEGATE}}function d1(e){return e instanceof Uint8Array}function rT(e){return nu(l1,e)}function cu(e){return e instanceof Uint8Array}function gr(e){if(d1(e))return e;ht(l1,e);const t=e.reduce((i,o)=>cu(o)?o.length===1&&au(o)!==void 0?i+1:i+qg(o.length)+o.length:i+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(i=>{if(cu(i)){const o=au(i);if(o!==void 0){Pr(r,n,o),n+=1;return}n+=D5(r,i.length,n),r.set(i,n),n+=i.length}else Pr(r,n,i),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function wt(e){if(rT(e))return e;ht(Me,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>qe.OP_0&&n<=qe.OP_PUSHDATA4){const i=M5(e,r);if(i===null||(r+=i.size,r+i.number>e.length))return null;const o=e.slice(r,r+i.number);r+=i.number;const s=au(o);s!==void 0?t.push(s):t.push(o)}else t.push(n),r+=1}return t}function nT(e){if(d1(e)&&(e=wt(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(t=>{if(cu(t)){const r=au(t);if(r===void 0)return Ee(t);t=r}return jg[t]}).join(" ")}function iT(e){return e=wt(e),ht(yn(af),e),e.map(t=>cu(t)?t:t===qe.OP_0?new Uint8Array(0):V5(t-u1))}function sT(e){return gn(e)}function cf(e){const t=e&-129;return t>0&&t<4}function ai(e){return!(e instanceof Uint8Array)||!cf(e[e.length-1])?!1:O5(e.slice(0,-1))}const na=eT;function ye(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const n=r.call(this);return this[t]=n,n},set(n){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}})}function Mr(e){let t;return()=>(t!==void 0||(t=e()),t)}const no=qe,uu=no.OP_RESERVED;function lu(e,t){if(!e.input&&!e.output&&!(e.pubkeys&&e.m!==void 0)&&!e.signatures)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{});function r(a){return ai(a)||(t.allowIncomplete&&a===no.OP_0)!==void 0}ht(Di(Ot({network:Ot({}),m:yr(),n:yr(),output:Me,pubkeys:pr(yn(gn),"Received invalid pubkey"),signatures:pr(yn(r),"Expected signature to be of type isAcceptableSignature"),input:Me})),e);const n={network:e.network||pn};let i=[],o=!1;function s(a){o||(o=!0,i=wt(a),n.m=i[0]-uu,n.n=i[i.length-2]-uu,n.pubkeys=i.slice(1,-2))}if(ye(n,"output",()=>{if(e.m&&n.n&&e.pubkeys)return gr([].concat(uu+e.m,e.pubkeys,uu+n.n,no.OP_CHECKMULTISIG))}),ye(n,"m",()=>{if(n.output)return s(n.output),n.m}),ye(n,"n",()=>{if(n.pubkeys)return n.pubkeys.length}),ye(n,"pubkeys",()=>{if(e.output)return s(e.output),n.pubkeys}),ye(n,"signatures",()=>{if(e.input)return wt(e.input).slice(1)}),ye(n,"input",()=>{if(e.signatures)return gr([no.OP_0].concat(e.signatures))}),ye(n,"witness",()=>{if(n.input)return[]}),ye(n,"name",()=>{if(!(!n.m||!n.n))return`p2ms(${n.m} of ${n.n})`}),t.validate){if(e.output){if(s(e.output),ht(yr(),i[0],{message:"Output is invalid"}),ht(yr(),i[i.length-2],{message:"Output is invalid"}),i[i.length-1]!==no.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every(a=>gn(a)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==n.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!ra(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(e.n!==void 0&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==no.OP_0)throw new TypeError("Input is invalid");if(n.signatures.length===0||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!ra(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(e.m!==void 0&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)}const p1=qe;function y1(e,t){if(!e.input&&!e.output&&!e.pubkey&&!e.input&&!e.signature)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),output:Me,pubkey:yn(gn,"invalid pubkey"),signature:yn(ai,"Expected signature to be of type isCanonicalScriptSignature"),input:Me})),e);const r=Mr(()=>wt(e.input)),n={name:"p2pk",network:e.network||pn};if(ye(n,"output",()=>{if(e.pubkey)return gr([e.pubkey,p1.OP_CHECKSIG])}),ye(n,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),ye(n,"signature",()=>{if(e.input)return r()[0]}),ye(n,"input",()=>{if(e.signature)return gr([e.signature])}),ye(n,"witness",()=>{if(n.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==p1.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!gn(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&ee(e.pubkey,n.pubkey)!==0)throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&ee(e.input,n.input)!==0)throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!ai(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)}function oT(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function g1(e,...t){if(!oT(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function w1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function aT(e,t){g1(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uf=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Hn=(e,t)=>e<<32-t|e>>>t,hu=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function cT(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function b1(e){return typeof e=="string"&&(e=cT(e)),g1(e),e}class uT{clone(){return this._cloneInto()}}function m1(e){const t=n=>e().update(b1(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function lT(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const hT=(e,t,r)=>e&t^~e&r,fT=(e,t,r)=>e&t^e&r^t&r;let v1=class extends uT{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=uf(this.buffer)}update(e){w1(this);const{view:t,buffer:r,blockLen:n}=this;e=b1(e);const i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const a=uf(e);for(;n<=i-o;o+=n)this.process(a,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){w1(this),aT(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let h=o;h<n;h++)t[h]=0;lT(r,n-8,BigInt(this.length*8),i),this.process(r,0);const s=uf(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)s.setUint32(4*h,f[h],i)}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}};const dT=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),E1=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),pT=E1.map(e=>(9*e+5)%16);let lf=[E1],hf=[pT];for(let e=0;e<4;e++)for(let t of[lf,hf])t.push(t[e].map(r=>dT[r]));const A1=[[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)),yT=lf.map((e,t)=>e.map(r=>A1[t][r])),gT=hf.map((e,t)=>e.map(r=>A1[t][r])),wT=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),bT=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function S1(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const fu=new Uint32Array(16);class mT extends v1{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:o}=this;return[t,r,n,i,o]}set(t,r,n,i,o){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=o|0}process(t,r){for(let v=0;v<16;v++,r+=4)fu[v]=t.getUint32(r,!0);let n=this.h0|0,i=n,o=this.h1|0,s=o,a=this.h2|0,u=a,f=this.h3|0,h=f,d=this.h4|0,g=d;for(let v=0;v<5;v++){const E=4-v,T=wT[v],x=bT[v],N=lf[v],O=hf[v],k=yT[v],B=gT[v];for(let z=0;z<16;z++){const V=hu(n+S1(v,o,a,f)+fu[N[z]]+T,k[z])+d|0;n=d,d=f,f=hu(a,10)|0,a=o,o=V}for(let z=0;z<16;z++){const V=hu(i+S1(E,s,u,h)+fu[O[z]]+x,B[z])+g|0;i=g,g=h,h=hu(u,10)|0,u=s,s=V}}this.set(this.h1+a+h|0,this.h2+f+g|0,this.h3+d+i|0,this.h4+n+s|0,this.h0+o+u|0)}roundClean(){fu.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const vT=m1(()=>new mT),ET=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]),Mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fi=new Uint32Array(64);let AT=class extends v1{constructor(){super(64,32,8,!1),this.A=Mi[0]|0,this.B=Mi[1]|0,this.C=Mi[2]|0,this.D=Mi[3]|0,this.E=Mi[4]|0,this.F=Mi[5]|0,this.G=Mi[6]|0,this.H=Mi[7]|0}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=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let h=0;h<16;h++,t+=4)Fi[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const d=Fi[h-15],g=Fi[h-2],v=Hn(d,7)^Hn(d,18)^d>>>3,E=Hn(g,17)^Hn(g,19)^g>>>10;Fi[h]=E+Fi[h-7]+v+Fi[h-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:f}=this;for(let h=0;h<64;h++){const d=Hn(s,6)^Hn(s,11)^Hn(s,25),g=f+d+hT(s,a,u)+ET[h]+Fi[h]|0,v=(Hn(r,2)^Hn(r,13)^Hn(r,22))+fT(r,n,i)|0;f=u,u=a,a=s,s=o+g|0,o=i,i=n,n=r,r=g+v|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,n,i,o,s,a,u,f)}roundClean(){Fi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const rr=m1(()=>new AT);function ci(e){return vT(rr(e))}function As(e){return rr(rr(e))}const ST={"BIP0340/challenge":Uint8Array.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":Uint8Array.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":Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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:Uint8Array.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":Uint8Array.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":Uint8Array.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])};function du(e,t){return rr(lt([ST[e],t]))}function TT(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let f=0;f<t.length;f++)t[f]=255;for(let f=0;f<e.length;f++){const h=e.charAt(f),d=h.charCodeAt(0);if(t[d]!==255)throw new TypeError(h+" is ambiguous");t[d]=f}const r=e.length,n=e.charAt(0),i=Math.log(r)/Math.log(256),o=Math.log(256)/Math.log(r);function s(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let h=0,d=0,g=0;const v=f.length;for(;g!==v&&f[g]===0;)g++,h++;const E=(v-g)*o+1>>>0,T=new Uint8Array(E);for(;g!==v;){let O=f[g],k=0;for(let B=E-1;(O!==0||k<d)&&B!==-1;B--,k++)O+=256*T[B]>>>0,T[B]=O%r>>>0,O=O/r>>>0;if(O!==0)throw new Error("Non-zero carry");d=k,g++}let x=E-d;for(;x!==E&&T[x]===0;)x++;let N=n.repeat(h);for(;x<E;++x)N+=e.charAt(T[x]);return N}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let h=0,d=0,g=0;for(;f[h]===n;)d++,h++;const v=(f.length-h)*i+1>>>0,E=new Uint8Array(v);for(;f[h];){let O=t[f.charCodeAt(h)];if(O===255)return;let k=0;for(let B=v-1;(O!==0||k<g)&&B!==-1;B--,k++)O+=r*E[B]>>>0,E[B]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");g=k,h++}let T=v-g;for(;T!==v&&E[T]===0;)T++;const x=new Uint8Array(d+(v-T));let N=d;for(;T!==v;)x[N++]=E[T++];return x}function u(f){const h=a(f);if(h)return h;throw new Error("Non-base"+r+" character")}return{encode:s,decodeUnsafe:a,decode:u}}var _T="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const ff=TT(_T);function kT(e){function t(o){var s=Uint8Array.from(o),a=e(s),u=s.length+4,f=new Uint8Array(u);return f.set(s,0),f.set(a.subarray(0,4),s.length),ff.encode(f)}function r(o){var s=o.slice(0,-4),a=o.slice(-4),u=e(s);if(!(a[0]^u[0]|a[1]^u[1]|a[2]^u[2]|a[3]^u[3]))return s}function n(o){var s=ff.decodeUnsafe(o);if(s!=null)return r(s)}function i(o){var s=ff.decode(o),a=r(s);if(a==null)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}}function PT(e){return rr(rr(e))}const ia=kT(PT),Vi=qe;function sa(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),address:Es(),hash:J5,output:Ut(25),pubkey:yn(gn),signature:yn(ai),input:Me})),e);const r=Mr(()=>{const s=ia.decode(e.address),a=si(s,0),u=s.slice(1);return{version:a,hash:u}}),n=Mr(()=>wt(e.input)),i=e.network||pn,o={name:"p2pkh",network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=new Uint8Array(21);return Pr(s,0,i.pubKeyHash),s.set(o.hash,1),ia.encode(s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||o.pubkey)return ci(e.pubkey||o.pubkey)}),ye(o,"output",()=>{if(o.hash)return gr([Vi.OP_DUP,Vi.OP_HASH160,o.hash,Vi.OP_EQUALVERIFY,Vi.OP_CHECKSIG])}),ye(o,"pubkey",()=>{if(e.input)return n()[1]}),ye(o,"signature",()=>{if(e.input)return n()[0]}),ye(o,"input",()=>{if(e.pubkey&&e.signature)return gr([e.signature,e.pubkey])}),ye(o,"witness",()=>{if(o.input)return[]}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");s=r().hash}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==Vi.OP_DUP||e.output[1]!==Vi.OP_HASH160||e.output[2]!==20||e.output[23]!==Vi.OP_EQUALVERIFY||e.output[24]!==Vi.OP_CHECKSIG)throw new TypeError("Output is invalid");const a=e.output.slice(3,23);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.pubkey){const a=ci(e.pubkey);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.input){const a=n();if(a.length!==2)throw new TypeError("Input is invalid");if(!ai(a[0]))throw new TypeError("Input has invalid signature");if(!gn(a[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&ee(e.signature,a[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,a[1])!==0)throw new TypeError("Pubkey mismatch");const u=ci(a[1]);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}const oa=qe;function io(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.input)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({network:Ot({}),address:Es(),hash:Ut(20),output:Ut(23),redeem:Di(Ot({network:Ot({}),output:Me,input:Me,witness:pr(Me)})),input:Me,witness:pr(Me)})),e);let r=e.network;r||(r=e.redeem&&e.redeem.network||pn);const n={network:r},i=Mr(()=>{const a=ia.decode(e.address),u=si(a,0),f=a.slice(1);return{version:u,hash:f}}),o=Mr(()=>wt(e.input)),s=Mr(()=>{const a=o(),u=a[a.length-1];return{network:r,output:u===oa.OP_FALSE?Uint8Array.from([]):u,input:gr(a.slice(0,-1)),witness:e.witness||[]}});if(ye(n,"address",()=>{if(!n.hash)return;const a=new Uint8Array(21);return Pr(a,0,n.network.scriptHash),a.set(n.hash,1),ia.encode(a)}),ye(n,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return i().hash;if(n.redeem&&n.redeem.output)return ci(n.redeem.output)}),ye(n,"output",()=>{if(n.hash)return gr([oa.OP_HASH160,n.hash,oa.OP_EQUAL])}),ye(n,"redeem",()=>{if(e.input)return s()}),ye(n,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return gr([].concat(wt(e.redeem.input),e.redeem.output))}),ye(n,"witness",()=>{if(n.redeem&&n.redeem.witness)return n.redeem.witness;if(n.input)return[]}),ye(n,"name",()=>{const a=["p2sh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Uint8Array.from([]);if(e.address){if(i().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(i().hash.length!==20)throw new TypeError("Invalid address");a=i().hash}if(e.hash){if(a.length>0&&ee(a,e.hash)!==0)throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==oa.OP_HASH160||e.output[1]!==20||e.output[22]!==oa.OP_EQUAL)throw new TypeError("Output is invalid");const f=e.output.slice(2,22);if(a.length>0&&ee(a,f)!==0)throw new TypeError("Hash mismatch");a=f}const u=f=>{if(f.output){const h=wt(f.output);if(!h||h.length<1)throw new TypeError("Redeem.output too short");if(f.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(f1(h)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const d=ci(f.output);if(a.length>0&&ee(a,d)!==0)throw new TypeError("Hash mismatch");a=d}if(f.input){const h=f.input.length>0,d=f.witness&&f.witness.length>0;if(!h&&!d)throw new TypeError("Empty input");if(h&&d)throw new TypeError("Input and witness provided");if(h){const g=wt(f.input);if(!af(g))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const f=o();if(!f||f.length<1)throw new TypeError("Input too short");if(!(s().output instanceof Uint8Array))throw new TypeError("Input is invalid");u(s())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const f=s();if(e.redeem.output&&ee(e.redeem.output,f.output)!==0)throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&ee(e.redeem.input,f.input)!==0)throw new TypeError("Redeem.input mismatch")}u(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!ra(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(n,e)}var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function IT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function OT(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var aa={};Object.defineProperty(aa,"__esModule",{value:!0});var ca=aa.bech32m=Ir=aa.bech32=void 0;const pu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",T1={};for(let e=0;e<pu.length;e++){const t=pu.charAt(e);T1[t]=e}function so(e){const t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function _1(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=so(t)^n>>5}t=so(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=so(t)^n&31}return t}function df(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(i=i<<t|e[u],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 xT(e){return df(e,8,5,!0)}function $T(e){const t=df(e,5,8,!1);if(Array.isArray(t))return t}function CT(e){const t=df(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function k1(e){let t;e==="bech32"?t=1:t=734539939;function r(s,a,u){if(u=u||90,s.length+7+a.length>u)throw new TypeError("Exceeds length limit");s=s.toLowerCase();let f=_1(s);if(typeof f=="string")throw new Error(f);let h=s+"1";for(let d=0;d<a.length;++d){const g=a[d];if(g>>5)throw new Error("Non 5-bit word");f=so(f)^g,h+=pu.charAt(g)}for(let d=0;d<6;++d)f=so(f);f^=t;for(let d=0;d<6;++d){const g=f>>(5-d)*5&31;h+=pu.charAt(g)}return h}function n(s,a){if(a=a||90,s.length<8)return s+" too short";if(s.length>a)return"Exceeds length limit";const u=s.toLowerCase(),f=s.toUpperCase();if(s!==u&&s!==f)return"Mixed-case string "+s;s=u;const h=s.lastIndexOf("1");if(h===-1)return"No separator character for "+s;if(h===0)return"Missing prefix for "+s;const d=s.slice(0,h),g=s.slice(h+1);if(g.length<6)return"Data too short";let v=_1(d);if(typeof v=="string")return v;const E=[];for(let T=0;T<g.length;++T){const x=g.charAt(T),N=T1[x];if(N===void 0)return"Unknown character "+x;v=so(v)^N,!(T+6>=g.length)&&E.push(N)}return v!==t?"Invalid checksum for "+s:{prefix:d,words:E}}function i(s,a){const u=n(s,a);if(typeof u=="object")return u}function o(s,a){const u=n(s,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:i,decode:o,encode:r,toWords:xT,fromWordsUnsafe:$T,fromWords:CT}}var Ir=aa.bech32=k1("bech32");ca=aa.bech32m=k1("bech32m");const P1=qe,NT=new Uint8Array(0);function ua(e,t){if(!e.address&&!e.hash&&!e.output&&!e.pubkey&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({address:Es(),hash:Ut(20),input:Ut(0),network:Ot({}),output:Ut(22),pubkey:yn(gn,"Not a valid pubkey"),signature:yn(ai),witness:pr(Me)})),e);const r=Mr(()=>{const o=Ir.decode(e.address),s=o.words.shift(),a=Ir.fromWords(o.words);return{version:s,prefix:o.prefix,data:Uint8Array.from(a)}}),n=e.network||pn,i={name:"p2wpkh",network:n};if(ye(i,"address",()=>{if(!i.hash)return;const o=Ir.toWords(i.hash);return o.unshift(0),Ir.encode(n.bech32,o)}),ye(i,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||i.pubkey)return ci(e.pubkey||i.pubkey)}),ye(i,"output",()=>{if(i.hash)return gr([P1.OP_0,i.hash])}),ye(i,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),ye(i,"signature",()=>{if(e.witness)return e.witness[0]}),ye(i,"input",()=>{if(i.witness)return NT}),ye(i,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let o=Uint8Array.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==20)throw new TypeError("Invalid address data");o=r().data}if(e.hash){if(o.length>0&&ee(o,e.hash)!==0)throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==P1.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(o.length>0&&ee(o,e.output.slice(2))!==0)throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){const s=ci(e.pubkey);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch");if(o=s,!gn(e.pubkey)||e.pubkey.length!==33)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(e.witness.length!==2)throw new TypeError("Witness is invalid");if(!ai(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!gn(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&ee(e.signature,e.witness[0])!==0)throw new TypeError("Signature mismatch");if(e.pubkey&&ee(e.pubkey,e.witness[1])!==0)throw new TypeError("Pubkey mismatch");const s=ci(e.witness[1]);if(o.length>0&&ee(o,s)!==0)throw new TypeError("Hash mismatch")}}return Object.assign(i,e)}const I1=qe,pf=new Uint8Array(0);function yu(e){return!!(e instanceof Uint8Array&&e.length===65&&e[0]===4&&gn(e))}function la(e,t){if(!e.address&&!e.hash&&!e.output&&!e.redeem&&!e.witness)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(s1({network:Ot({}),address:Es(),hash:X5,output:Ut(34),redeem:s1({input:Me,network:Ot({}),output:Me,witness:pr(Me)}),input:Ut(0),witness:pr(Me)}),e);const r=Mr(()=>{const s=Ir.decode(e.address),a=s.words.shift(),u=Ir.fromWords(s.words);return{version:a,prefix:s.prefix,data:Uint8Array.from(u)}}),n=Mr(()=>wt(e.redeem.input));let i=e.network;i||(i=e.redeem&&e.redeem.network||pn);const o={network:i};if(ye(o,"address",()=>{if(!o.hash)return;const s=Ir.toWords(o.hash);return s.unshift(0),Ir.encode(i.bech32,s)}),ye(o,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(o.redeem&&o.redeem.output)return rr(o.redeem.output)}),ye(o,"output",()=>{if(o.hash)return gr([I1.OP_0,o.hash])}),ye(o,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:pf,witness:e.witness.slice(0,-1)}}),ye(o,"input",()=>{if(o.witness)return pf}),ye(o,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const s=iT(n());return o.redeem=Object.assign({witness:s},e.redeem),o.redeem.input=pf,[].concat(s,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),ye(o,"name",()=>{const s=["p2wsh"];return o.redeem!==void 0&&o.redeem.name!==void 0&&s.push(o.redeem.name),s.join("-")}),t.validate){let s=Uint8Array.from([]);if(e.address){if(r().prefix!==i.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==0)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");s=r().data}if(e.hash){if(s.length>0&&ee(s,e.hash)!==0)throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==I1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const a=e.output.slice(2);if(s.length>0&&ee(s,a)!==0)throw new TypeError("Hash mismatch");s=a}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const a=wt(e.redeem.output);if(!a||a.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(f1(a)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const u=rr(e.redeem.output);if(s.length>0&&ee(s,u)!==0)throw new TypeError("Hash mismatch");s=u}if(e.redeem.input&&!af(n()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!ra(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&n().some(yu)||e.redeem.output&&(wt(e.redeem.output)||[]).some(yu))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const a=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&ee(e.redeem.output,a)!==0)throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(yu)||(wt(a)||[]).some(yu))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)}const ha={};function UT(e){e?e!==ha.eccLib&&(RT(e),ha.eccLib=e):ha.eccLib=e}function yf(){if(!ha.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return ha.eccLib}const ui=e=>ii(e);function RT(e){Fr(typeof e.isXOnlyPoint=="function"),Fr(e.isXOnlyPoint(ui("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Fr(e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Fr(e.isXOnlyPoint(ui("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Fr(e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000001"))),Fr(!e.isXOnlyPoint(ui("0000000000000000000000000000000000000000000000000000000000000000"))),Fr(!e.isXOnlyPoint(ui("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Fr(typeof e.xOnlyPointAddTweak=="function"),BT.forEach(t=>{const r=e.xOnlyPointAddTweak(ui(t.pubkey),ui(t.tweak));t.result===null?Fr(r===null):(Fr(r!==null),Fr(r.parity===t.parity),Fr(ee(r.xOnlyPubkey,ui(t.result))===0))})}function Fr(e){if(!e)throw new Error("ecc library invalid")}const BT=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}],O1="0123456789abcdefABCDEF";O1.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=O1.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function LT(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=r&255)}function HT(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);n==="LE"?(e[t]=r&255,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r&255)}function KT(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);n==="LE"?(e[t]=Number(r&0xffn),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(r&0xffn))}function jT(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+1],n=(n<<8)+e[t],n}else{let n=0;return n=(n<<8)+e[t],n=(n<<8)+e[t+1],n}}function DT(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0;return n=(n<<8)+e[t+3]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t]>>>0,n}else{let n=0;return n=(n<<8)+e[t]>>>0,n=(n<<8)+e[t+1]>>>0,n=(n<<8)+e[t+2]>>>0,n=(n<<8)+e[t+3]>>>0,n}}function MT(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r=r.toUpperCase(),r==="LE"){let n=0n;return n=(n<<8n)+BigInt(e[t+7]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t]),n}else{let n=0n;return n=(n<<8n)+BigInt(e[t]),n=(n<<8n)+BigInt(e[t+1]),n=(n<<8n)+BigInt(e[t+2]),n=(n<<8n)+BigInt(e[t+3]),n=(n<<8n)+BigInt(e[t+4]),n=(n<<8n)+BigInt(e[t+5]),n=(n<<8n)+BigInt(e[t+6]),n=(n<<8n)+BigInt(e[t+7]),n}}const FT=e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")};function VT(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function x1(e){typeof e=="number"?VT(e):FT(e)}function Wi(e,t,r){x1(e),r===void 0&&(r=0),t===void 0&&(t=new Uint8Array(Vr(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),LT(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),HT(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),KT(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function oo(e,t){t===void 0&&(t=0);const r=e.at(t);if(r===void 0)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(r===253){const n=jT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:3}}else if(r===254){const n=DT(e,t+1,"LE");return{numberValue:n,bigintValue:BigInt(n),bytes:5}}else{const n=MT(e,t+1,"LE");return{numberValue:n<=Number.MAX_SAFE_INTEGER?Number(n):null,bigintValue:n,bytes:9}}}function Vr(e){return x1(e),e<253?1:e<=65535?3:e<=4294967295?5:9}const WT=9007199254740991;function zT(e,t){if(typeof e!="number"&&typeof e!="bigint")throw new Error("cannot write a non-number as a number");if(e<0&&e<BigInt(0))throw new Error("specified a negative value for writing an unsigned value");if(e>t&&e>BigInt(t))throw new Error("RangeError: value out of range");if(Math.floor(Number(e))!==Number(e))throw new Error("value has a fractional component")}function gf(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}function $1(e){const t=new Uint8Array(e.length);return t.set(e),t}class qt{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ht(Ln([Me,oi]),[t,r])}static withCapacity(t){return new qt(new Uint8Array(t))}writeUInt8(t){this.offset=Pr(this.buffer,this.offset,t)}writeInt32(t){this.offset=Vg(this.buffer,this.offset,t,"LE")}writeInt64(t){this.offset=Wg(this.buffer,this.offset,BigInt(t),"LE")}writeUInt32(t){this.offset=ea(this.buffer,this.offset,t,"LE")}writeUInt64(t){this.offset=H5(this.buffer,this.offset,BigInt(t),"LE")}writeVarInt(t){const{bytes:r}=Wi(t,this.buffer,this.offset);this.offset+=r}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.buffer.set(t,this.offset),this.offset+=t.length}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach(r=>this.writeVarSlice(r))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}class qT{constructor(t,r=0){be(this,"buffer"),be(this,"offset"),this.buffer=t,this.offset=r,ht(Ln([Me,oi]),[t,r])}readUInt8(){const t=si(this.buffer,this.offset);return this.offset++,t}readInt32(){const t=j5(this.buffer,this.offset,"LE");return this.offset+=4,t}readUInt32(){const t=to(this.buffer,this.offset,"LE");return this.offset+=4,t}readInt64(){const t=zg(this.buffer,this.offset,"LE");return this.offset+=8,t}readVarInt(){const{bigintValue:t,bytes:r}=oo(this.buffer,this.offset);return this.offset+=r,t}readSlice(t){zT(t,WT);const r=Number(t);if(this.buffer.length<this.offset+r)throw new Error("Cannot read slice out of bounds");const n=this.buffer.slice(this.offset,this.offset+r);return this.offset+=r,n}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let n=0;n<t;n++)r.push(this.readVarSlice());return r}}const C1=192,GT=128,XT=e=>"left"in e&&"right"in e;function wf(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 i=0;i<r;i++){const o=e.slice(33+32*i,65+32*i);ee(n,o)<0?n=mf(n,o):n=mf(o,n)}return n}function bf(e){if(sf(e))return{hash:li(e)};const t=[bf(e[0]),bf(e[1])];t.sort((i,o)=>ee(i.hash,o.hash));const[r,n]=t;return{hash:mf(r.hash,n.hash),left:r,right:n}}function gu(e,t){if(XT(e)){const r=gu(e.left,t);if(r!==void 0)return[...r,e.right.hash];const n=gu(e.right,t);if(n!==void 0)return[...n,e.left.hash]}else if(ee(e.hash,t)===0)return[]}function li(e){const t=e.version||C1;return du("TapLeaf",lt([Uint8Array.from([t]),YT(e.output)]))}function JT(e,t){return du("TapTweak",lt(t?[e,t]:[e]))}function wu(e,t){if(!(e instanceof Uint8Array)||e.length!==32||t&&t.length!==32)return null;const r=JT(e,t),n=yf().xOnlyPointAddTweak(e,r);return!n||n.xOnlyPubkey===null?null:{parity:n.parity,x:Uint8Array.from(n.xOnlyPubkey)}}function mf(e,t){return du("TapBranch",lt([e,t]))}function YT(e){const t=Vr(e.length),r=new Uint8Array(t);return Wi(e.length,r),lt([r,e])}const N1=qe,U1=1,ZT=80;function fa(e,t){if(!e.address&&!e.output&&!e.pubkey&&!e.internalPubkey&&!(e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),ht(Di(Ot({address:Es(),input:Ut(0),network:Ot({}),output:Ut(34),internalPubkey:Ut(32),hash:Ut(32),pubkey:Ut(32),signature:nf([Ut(64),Ut(65)]),witness:pr(Me),scriptTree:yn(n1,"Taptree is not of type isTaptree"),redeem:Di(Ot({output:Me,redeemVersion:yr(),witness:pr(Me)})),redeemVersion:yr()})),e);const r=Mr(()=>D1(e.address)),n=Mr(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===ZT?e.witness.slice(0,-1):e.witness.slice()}),i=Mr(()=>{if(e.scriptTree)return bf(e.scriptTree);if(e.hash)return{hash:e.hash}}),o=e.network||pn,s={name:"p2tr",network:o};if(ye(s,"address",()=>{if(!s.pubkey)return;const a=ca.toWords(s.pubkey);return a.unshift(U1),ca.encode(o.bech32,a)}),ye(s,"hash",()=>{const a=i();if(a)return a.hash;const u=n();if(u&&u.length>1){const f=u[u.length-1],h=f[0]&ou,d=u[u.length-2],g=li({output:d,version:h});return wf(f,g)}return null}),ye(s,"output",()=>{if(s.pubkey)return gr([N1.OP_1,s.pubkey])}),ye(s,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:C1),ye(s,"redeem",()=>{const a=n();if(!(!a||a.length<2))return{output:a[a.length-2],witness:a.slice(0,-2),redeemVersion:a[a.length-1][0]&ou}}),ye(s,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const a=wu(s.internalPubkey,s.hash);if(a)return a.x}}),ye(s,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const a=n();if(a&&a.length>1)return a[a.length-1].slice(1,33)}),ye(s,"signature",()=>{if(e.signature)return e.signature;const a=n();if(!(!a||a.length!==1))return a[0]}),ye(s,"witness",()=>{if(e.witness)return e.witness;const a=i();if(a&&e.redeem&&e.redeem.output&&e.internalPubkey){const u=li({output:e.redeem.output,version:s.redeemVersion}),f=gu(a,u);if(!f)return;const h=wu(e.internalPubkey,a.hash);if(!h)return;const d=lt([Uint8Array.from([s.redeemVersion|h.parity]),e.internalPubkey].concat(f));return[e.redeem.output,d]}if(e.signature)return[e.signature]}),t.validate){let a=Uint8Array.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==U1)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");a=r().data}if(e.pubkey){if(a.length>0&&ee(a,e.pubkey)!==0)throw new TypeError("Pubkey mismatch");a=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==N1.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(a.length>0&&ee(a,e.output.slice(2))!==0)throw new TypeError("Pubkey mismatch");a=e.output.slice(2)}if(e.internalPubkey){const h=wu(e.internalPubkey,s.hash);if(a.length>0&&ee(a,h.x)!==0)throw new TypeError("Pubkey mismatch");a=h.x}if(a&&a.length&&!yf().isXOnlyPoint(a))throw new TypeError("Invalid pubkey for p2tr");const u=i();if(e.hash&&u&&ee(e.hash,u.hash)!==0)throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&u){const h=li({output:e.redeem.output,version:s.redeemVersion});if(!gu(u,h))throw new TypeError("Redeem script not in tree")}const f=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(wt(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&ee(e.redeem.output,s.redeem.output)!==0)throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!ra(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(f.length===1){if(e.signature&&ee(e.signature,f[0])!==0)throw new TypeError("Signature mismatch")}else{const h=f[f.length-1];if(h.length<33)throw new TypeError(`The control-block length is too small. Got ${h.length}, expected min 33.`);if((h.length-33)%32!==0)throw new TypeError(`The control-block length of ${h.length} is incorrect!`);const d=(h.length-33)/32;if(d>128)throw new TypeError(`The script path is too long. Got ${d}, expected max 128.`);const g=h.slice(1,33);if(e.internalPubkey&&ee(e.internalPubkey,g)!==0)throw new TypeError("Internal pubkey mismatch");if(!yf().isXOnlyPoint(g))throw new TypeError("Invalid internalPubkey for p2tr witness");const v=h[0]&ou,E=f[f.length-2],T=li({output:E,version:v}),x=wf(h,T),N=wu(g,x);if(!N)throw new TypeError("Invalid outputKey for p2tr witness");if(a.length&&ee(a,N.x)!==0)throw new TypeError("Pubkey mismatch for p2tr witness");if(N.parity!==(h[0]&1))throw new Error("Incorrect parity")}}return Object.assign(s,e)}const R1=40,B1=2,L1=16,H1=2,K1=80,j1="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 QT(e,t){const r=e.slice(2);if(r.length<B1||r.length>R1)throw new TypeError("Invalid program length for segwit address");const n=e[0]-K1;if(n<H1||n>L1)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(j1),t_(r,n,t.bech32)}function e_(e){const t=ia.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");const r=si(t,0),n=t.slice(1);return{version:r,hash:n}}function D1(e){let t,r;try{t=Ir.decode(e)}catch{}if(t){if(r=t.words[0],r!==0)throw new TypeError(e+" uses wrong encoding")}else if(t=ca.decode(e),r=t.words[0],r===0)throw new TypeError(e+" uses wrong encoding");const n=Ir.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:Uint8Array.from(n)}}function t_(e,t,r){const n=Ir.toWords(e);return n.unshift(t),t===0?Ir.encode(r,n):ca.encode(r,n)}function da(e,t){t=t||pn;try{return sa({output:e,network:t}).address}catch{}try{return io({output:e,network:t}).address}catch{}try{return ua({output:e,network:t}).address}catch{}try{return la({output:e,network:t}).address}catch{}try{return fa({output:e,network:t}).address}catch{}try{return QT(e,t)}catch{}throw new Error(nT(e)+" has no matching Address")}function M1(e,t){t=t||pn;let r,n;try{r=e_(e)}catch{}if(r){if(r.version===t.pubKeyHash)return sa({hash:r.hash}).output;if(r.version===t.scriptHash)return io({hash:r.hash}).output}else{try{n=D1(e)}catch{}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(n.version===0){if(n.data.length===20)return ua({hash:n.data}).output;if(n.data.length===32)return la({hash:n.data}).output}else if(n.version===1){if(n.data.length===32)return fa({pubkey:n.data}).output}else if(n.version>=H1&&n.version<=L1&&n.data.length>=B1&&n.data.length<=R1)return console.warn(j1),gr([n.version+K1,n.data])}}throw new Error(e+" has no matching Script")}function Kn(e){const t=e.length;return Vr(t)+t}function r_(e){const t=e.length;return Vr(t)+e.reduce((r,n)=>r+Kn(n),0)}const zi=new Uint8Array(0),F1=[],vf=ii("0000000000000000000000000000000000000000000000000000000000000000"),V1=ii("0000000000000000000000000000000000000000000000000000000000000001"),n_=ii("ffffffffffffffff"),i_={script:zi,valueBuffer:n_};function s_(e){return e.value!==void 0}const wn=class et{constructor(){be(this,"version",1),be(this,"locktime",0),be(this,"ins",[]),be(this,"outs",[])}static fromBuffer(t,r){const n=new qT(t),i=new et;i.version=n.readInt32();const o=n.readUInt8(),s=n.readUInt8();let a=!1;o===et.ADVANCED_TRANSACTION_MARKER&&s===et.ADVANCED_TRANSACTION_FLAG?a=!0:n.offset-=2;const u=n.readVarInt();for(let h=0;h<u;++h)i.ins.push({hash:n.readSlice(32),index:n.readUInt32(),script:n.readVarSlice(),sequence:n.readUInt32(),witness:F1});const f=n.readVarInt();for(let h=0;h<f;++h)i.outs.push({value:n.readInt64(),script:n.readVarSlice()});if(a){for(let h=0;h<u;++h)i.ins[h].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(t){return et.fromBuffer(ii(t),!1)}static isCoinbaseHash(t){ht(i1,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&et.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,n,i){return ht(Ln([i1,oi,rf(su(oi)),rf(su(Me))]),[t,r,n,i]),n==null&&(n=et.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:i||zi,sequence:n,witness:F1})-1}addOutput(t,r){return ht(Ln([Me,of]),[t,r]),this.outs.push({script:t,value:r})-1}hasWitnesses(){return this.ins.some(t=>t.witness.length!==0)}weight(){const t=this.byteLength(!1),r=this.byteLength(!0);return t*3+r}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const r=t&&this.hasWitnesses();return(r?10:8)+Vr(this.ins.length)+Vr(this.outs.length)+this.ins.reduce((n,i)=>n+40+Kn(i.script),0)+this.outs.reduce((n,i)=>n+8+Kn(i.script),0)+(r?this.ins.reduce((n,i)=>n+r_(i.witness),0):0)}clone(){const t=new et;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map(r=>({hash:r.hash,index:r.index,script:r.script,sequence:r.sequence,witness:r.witness})),t.outs=this.outs.map(r=>({script:r.script,value:r.value})),t}hashForSignature(t,r,n){if(ht(Ln([oi,Me,yr()]),[t,r,n]),t>=this.ins.length)return V1;const i=gr(wt(r).filter(a=>a!==qe.OP_CODESEPARATOR)),o=this.clone();if((n&31)===et.SIGHASH_NONE)o.outs=[],o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)});else if((n&31)===et.SIGHASH_SINGLE){if(t>=this.outs.length)return V1;o.outs.length=t+1;for(let a=0;a<t;a++)o.outs[a]=i_;o.ins.forEach((a,u)=>{u!==t&&(a.sequence=0)})}n&et.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach(a=>{a.script=zi}),o.ins[t].script=i);const s=new Uint8Array(o.byteLength(!1)+4);return Vg(s,s.length-4,n,"LE"),o.__toBuffer(s,0,!1),As(s)}hashForWitnessV1(t,r,n,i,o,s){if(ht(Ln([oi,pr(Me),pr(of),oi]),[t,r,n,i]),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===et.SIGHASH_DEFAULT?et.SIGHASH_ALL:i&et.SIGHASH_OUTPUT_MASK,u=(i&et.SIGHASH_INPUT_MASK)===et.SIGHASH_ANYONECANPAY,f=a===et.SIGHASH_NONE,h=a===et.SIGHASH_SINGLE;let d=zi,g=zi,v=zi,E=zi,T=zi;if(!u){let k=qt.withCapacity(36*this.ins.length);this.ins.forEach(B=>{k.writeSlice(B.hash),k.writeUInt32(B.index)}),d=rr(k.end()),k=qt.withCapacity(8*this.ins.length),n.forEach(B=>k.writeInt64(B)),g=rr(k.end()),k=qt.withCapacity(r.map(Kn).reduce((B,z)=>B+z)),r.forEach(B=>k.writeVarSlice(B)),v=rr(k.end()),k=qt.withCapacity(4*this.ins.length),this.ins.forEach(B=>k.writeUInt32(B.sequence)),E=rr(k.end())}if(f||h){if(h&&t<this.outs.length){const k=this.outs[t],B=qt.withCapacity(8+Kn(k.script));B.writeInt64(k.value),B.writeVarSlice(k.script),T=rr(B.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const k=this.outs.map(z=>8+Kn(z.script)).reduce((z,V)=>z+V),B=qt.withCapacity(k);this.outs.forEach(z=>{B.writeInt64(z.value),B.writeVarSlice(z.script)}),T=rr(B.end())}const x=(o?2:0)+(s?1:0),N=174-(u?49:0)-(f?32:0)+(s?32:0)+(o?37:0),O=qt.withCapacity(N);if(O.writeUInt8(i),O.writeInt32(this.version),O.writeUInt32(this.locktime),O.writeSlice(d),O.writeSlice(g),O.writeSlice(v),O.writeSlice(E),f||h||O.writeSlice(T),O.writeUInt8(x),u){const k=this.ins[t];O.writeSlice(k.hash),O.writeUInt32(k.index),O.writeInt64(n[t]),O.writeVarSlice(r[t]),O.writeUInt32(k.sequence)}else O.writeUInt32(t);if(s){const k=qt.withCapacity(Kn(s));k.writeVarSlice(s),O.writeSlice(rr(k.end()))}return h&&O.writeSlice(T),o&&(O.writeSlice(o),O.writeUInt8(0),O.writeUInt32(4294967295)),du("TapSighash",lt([Uint8Array.from([0]),O.end()]))}hashForWitnessV0(t,r,n,i){ht(Ln([oi,Me,of,oi]),[t,r,n,i]);let o=Uint8Array.from([]),s,a=vf,u=vf,f=vf;if(i&et.SIGHASH_ANYONECANPAY||(o=new Uint8Array(36*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeSlice(d.hash),s.writeUInt32(d.index)}),u=As(o)),!(i&et.SIGHASH_ANYONECANPAY)&&(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE&&(o=new Uint8Array(4*this.ins.length),s=new qt(o,0),this.ins.forEach(d=>{s.writeUInt32(d.sequence)}),f=As(o)),(i&31)!==et.SIGHASH_SINGLE&&(i&31)!==et.SIGHASH_NONE){const d=this.outs.reduce((g,v)=>g+8+Kn(v.script),0);o=new Uint8Array(d),s=new qt(o,0),this.outs.forEach(g=>{s.writeInt64(g.value),s.writeVarSlice(g.script)}),a=As(o)}else if((i&31)===et.SIGHASH_SINGLE&&t<this.outs.length){const d=this.outs[t];o=new Uint8Array(8+Kn(d.script)),s=new qt(o,0),s.writeInt64(d.value),s.writeVarSlice(d.script),a=As(o)}o=new Uint8Array(156+Kn(r)),s=new qt(o,0);const h=this.ins[t];return s.writeInt32(this.version),s.writeSlice(u),s.writeSlice(f),s.writeSlice(h.hash),s.writeUInt32(h.index),s.writeVarSlice(r),s.writeInt64(n),s.writeUInt32(h.sequence),s.writeSlice(a),s.writeUInt32(this.locktime),s.writeUInt32(i),As(o)}getHash(t){return t&&this.isCoinbase()?new Uint8Array(32):As(this.__toBuffer(void 0,void 0,t))}getId(){return Ee(gf(this.getHash(!1)))}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return Ee(this.toBuffer(void 0,void 0))}setInputScript(t,r){ht(Ln([yr(),Me]),[t,r]),this.ins[t].script=r}setWitness(t,r){ht(Ln([yr(),pr(Me)]),[t,r]),this.ins[t].witness=r}__toBuffer(t,r,n=!1){t||(t=new Uint8Array(this.byteLength(n)));const i=new qt(t,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(et.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(et.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach(s=>{i.writeSlice(s.hash),i.writeUInt32(s.index),i.writeVarSlice(s.script),i.writeUInt32(s.sequence)}),i.writeVarInt(this.outs.length),this.outs.forEach(s=>{s_(s)?i.writeInt64(s.value):i.writeSlice(s.valueBuffer),i.writeVarSlice(s.script)}),o&&this.ins.forEach(s=>{i.writeVector(s.witness)}),i.writeUInt32(this.locktime),r!==void 0?t.slice(r,i.offset):t}};be(wn,"DEFAULT_SEQUENCE",4294967295),be(wn,"SIGHASH_DEFAULT",0),be(wn,"SIGHASH_ALL",1),be(wn,"SIGHASH_NONE",2),be(wn,"SIGHASH_SINGLE",3),be(wn,"SIGHASH_ANYONECANPAY",128),be(wn,"SIGHASH_OUTPUT_MASK",3),be(wn,"SIGHASH_INPUT_MASK",128),be(wn,"ADVANCED_TRANSACTION_MARKER",0),be(wn,"ADVANCED_TRANSACTION_FLAG",1);let Tt=wn;var jn;(function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"})(jn||(jn={}));var se;(function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"})(se||(se={}));var _t;(function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"})(_t||(_t={}));const o_=e=>[...Array(e).keys()];function a_(e){if(e.key[0]!==jn.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+Ee(e.key));if(e.key.length!==79||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+Ee(e.key));if(e.value.length/4%1!==0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const n of o_(e.value.length/4-1)){const i=to(e.value,n*4+4,"LE"),o=!!(i&2147483648),s=i&2147483647;r.path+="/"+s.toString(10)+(o?"'":"")}return r}function c_(e){const t=new Uint8Array([jn.GLOBAL_XPUB]),r=lt([t,e.extendedPubkey]),n=e.path.split("/"),i=new Uint8Array(n.length*4);i.set(e.masterFingerprint,0);let o=4;return n.slice(1).forEach(s=>{const a=s.slice(-1)==="'";let u=2147483647&parseInt(a?s.slice(0,-1):s,10);a&&(u+=2147483648),ea(i,o,u,"LE"),o+=4}),{key:r,value:i}}const u_="{ masterFingerprint: Uint8Array; extendedPubkey: Uint8Array; path: string; }";function l_(e){const t=e.extendedPubkey,r=e.masterFingerprint,n=e.path;return t instanceof Uint8Array&&t.length===78&&[2,3].indexOf(t[45])>-1&&r instanceof Uint8Array&&r.length===4&&typeof n=="string"&&!!n.match(/^m(\/\d+'?)*$/)}function h_(e,t,r){const n=Ee(t.extendedPubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.extendedPubkey,t.extendedPubkey)).length===0)}const f_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:h_,check:l_,decode:a_,encode:c_,expected:u_},Symbol.toStringTag,{value:"Module"}));function d_(e){return{key:new Uint8Array([jn.UNSIGNED_TX]),value:e.toBuffer()}}const p_=Object.freeze(Object.defineProperty({__proto__:null,encode:d_},Symbol.toStringTag,{value:"Module"}));function y_(e){if(e.key[0]!==se.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+Ee(e.key));return e.value}function g_(e){return{key:new Uint8Array([se.FINAL_SCRIPTSIG]),value:e}}const w_="Uint8Array";function b_(e){return e instanceof Uint8Array}function m_(e,t){return!!e&&!!t&&e.finalScriptSig===void 0}const v_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:m_,check:b_,decode:y_,encode:g_,expected:w_},Symbol.toStringTag,{value:"Module"}));function E_(e){if(e.key[0]!==se.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+Ee(e.key));return e.value}function A_(e){return{key:new Uint8Array([se.FINAL_SCRIPTWITNESS]),value:e}}const S_="Uint8Array";function T_(e){return e instanceof Uint8Array}function __(e,t){return!!e&&!!t&&e.finalScriptWitness===void 0}const k_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:__,check:T_,decode:E_,encode:A_,expected:S_},Symbol.toStringTag,{value:"Module"}));function P_(e){if(e.key[0]!==se.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+Ee(e.key));return e.value}function I_(e){return{key:new Uint8Array([se.NON_WITNESS_UTXO]),value:e}}const O_="Uint8Array";function x_(e){return e instanceof Uint8Array}function $_(e,t){return!!e&&!!t&&e.nonWitnessUtxo===void 0}const C_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:$_,check:x_,decode:P_,encode:I_,expected:O_},Symbol.toStringTag,{value:"Module"}));function N_(e){if(e.key[0]!==se.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+Ee(e.key));if(!(e.key.length===34||e.key.length===66)||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+Ee(e.key));return{pubkey:e.key.slice(1),signature:e.value}}function U_(e){const t=new Uint8Array([se.PARTIAL_SIG]);return{key:lt([t,e.pubkey]),value:e.signature}}const R_="{ pubkey: Uint8Array; signature: Uint8Array; }";function B_(e){return e.pubkey instanceof Uint8Array&&e.signature instanceof Uint8Array&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&L_(e.signature)}function L_(e){if(!(e instanceof Uint8Array)||e.length<9||e[0]!==48||e.length!==e[1]+3||e[2]!==2)return!1;const t=e[3];if(t>33||t<1||e[3+t+1]!==2)return!1;const r=e[3+t+2];return!(r>33||r<1||e.length!==3+t+2+r+2)}function H_(e,t,r){const n=Ee(t.pubkey);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0).length===0)}const K_=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:H_,check:B_,decode:N_,encode:U_,expected:R_},Symbol.toStringTag,{value:"Module"}));function j_(e){if(e.key[0]!==se.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+Ee(e.key));return C5(e.value)}function D_(e){return{key:new Uint8Array([se.POR_COMMITMENT]),value:N5(e)}}const M_="string";function F_(e){return typeof e=="string"}function V_(e,t){return!!e&&!!t&&e.porCommitment===void 0}const W_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:V_,check:F_,decode:j_,encode:D_,expected:M_},Symbol.toStringTag,{value:"Module"}));function z_(e){if(e.key[0]!==se.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+Ee(e.key));return Number(to(e.value,0,"LE"))}function q_(e){const t=Uint8Array.from([se.SIGHASH_TYPE]),r=new Uint8Array(4);return ea(r,0,e,"LE"),{key:t,value:r}}const G_="number";function X_(e){return typeof e=="number"}function J_(e,t){return!!e&&!!t&&e.sighashType===void 0}const Y_=Object.freeze(Object.defineProperty({__proto__:null,canAdd:J_,check:X_,decode:z_,encode:q_,expected:G_},Symbol.toStringTag,{value:"Module"}));function Z_(e){if(e.key[0]!==se.TAP_KEY_SIG||e.key.length!==1)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+Ee(e.key));if(!W1(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value}function Q_(e){return{key:Uint8Array.from([se.TAP_KEY_SIG]),value:e}}const ek="Uint8Array";function W1(e){return e instanceof Uint8Array&&(e.length===64||e.length===65)}function tk(e,t){return!!e&&!!t&&e.tapKeySig===void 0}const rk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:tk,check:W1,decode:Z_,encode:Q_,expected:ek},Symbol.toStringTag,{value:"Module"}));function nk(e){if(e.key[0]!==se.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+Ee(e.key));if((e.key.length-2)%32!==0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+Ee(e.key));const t=e.value[e.value.length-1];if((e.key[1]&254)!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+Ee(e.key));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}}function ik(e){const t=Uint8Array.from([se.TAP_LEAF_SCRIPT]),r=Uint8Array.from([e.leafVersion]);return{key:lt([t,e.controlBlock]),value:lt([e.script,r])}}const sk="{ controlBlock: Uint8Array; leafVersion: number, script: Uint8Array; }";function ok(e){return e.controlBlock instanceof Uint8Array&&(e.controlBlock.length-1)%32===0&&(e.controlBlock[0]&254)===e.leafVersion&&e.script instanceof Uint8Array}function ak(e,t,r){const n=Ee(t.controlBlock);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.controlBlock,t.controlBlock)===0).length===0)}const ck=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:ak,check:ok,decode:nk,encode:ik,expected:sk},Symbol.toStringTag,{value:"Module"}));function uk(e){if(e.key[0]!==se.TAP_MERKLE_ROOT||e.key.length!==1)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+Ee(e.key));if(!z1(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value}function lk(e){return{key:Uint8Array.from([se.TAP_MERKLE_ROOT]),value:e}}const hk="Uint8Array";function z1(e){return e instanceof Uint8Array&&e.length===32}function fk(e,t){return!!e&&!!t&&e.tapMerkleRoot===void 0}const dk=Object.freeze(Object.defineProperty({__proto__:null,canAdd:fk,check:z1,decode:uk,encode:lk,expected:hk},Symbol.toStringTag,{value:"Module"}));function pk(e){if(e.key[0]!==se.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+Ee(e.key));if(e.key.length!==65)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+Ee(e.key));if(e.value.length!==64&&e.value.length!==65)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+Ee(e.key));const t=e.key.slice(1,33),r=e.key.slice(33);return{pubkey:t,leafHash:r,signature:e.value}}function yk(e){const t=Uint8Array.from([se.TAP_SCRIPT_SIG]);return{key:lt([t,e.pubkey,e.leafHash]),value:e.signature}}const gk="{ pubkey: Uint8Array; leafHash: Uint8Array; signature: Uint8Array; }";function wk(e){return e.pubkey instanceof Uint8Array&&e.leafHash instanceof Uint8Array&&e.signature instanceof Uint8Array&&e.pubkey.length===32&&e.leafHash.length===32&&(e.signature.length===64||e.signature.length===65)}function bk(e,t,r){const n=Ee(t.pubkey)+Ee(t.leafHash);return r.has(n)?!1:(r.add(n),e.filter(i=>ee(i.pubkey,t.pubkey)===0&&ee(i.leafHash,t.leafHash)===0).length===0)}const mk=Object.freeze(Object.defineProperty({__proto__:null,canAddToArray:bk,check:wk,decode:pk,encode:yk,expected:gk},Symbol.toStringTag,{value:"Module"}));function vk(e){if(e.key[0]!==se.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+Ee(e.key));const t=zg(e.value,0,"LE");let r=8;const{numberValue:n,bytes:i}=oo(e.value,r);r+=i;const o=e.value.slice(r);if(o.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:o,value:t}}function Ek(e){const{script:t,value:r}=e,n=Vr(t.length),i=new Uint8Array(8+n+t.length);return Wg(i,0,BigInt(r),"LE"),Wi(t.length,i,8),i.set(t,8+n),{key:Uint8Array.from([se.WITNESS_UTXO]),value:i}}const Ak="{ script: Uint8Array; value: bigint; }";function Sk(e){return e.script instanceof Uint8Array&&typeof e.value=="bigint"}function Tk(e,t){return!!e&&!!t&&e.witnessUtxo===void 0}const _k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:Tk,check:Sk,decode:vk,encode:Ek,expected:Ak},Symbol.toStringTag,{value:"Module"}));function kk(e){if(e.key[0]!==_t.TAP_TREE||e.key.length!==1)throw new Error("Decode Error: could not decode tapTree with key 0x"+Ee(e.key));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],{numberValue:o,bytes:s}=oo(e.value,t);t+=s,r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}}function Pk(e){const t=Uint8Array.from([_t.TAP_TREE]),r=[].concat(...e.leaves.map(n=>[Uint8Array.of(n.depth,n.leafVersion),Wi(BigInt(n.script.length)).buffer,n.script]));return{key:t,value:lt(r)}}const Ik="{ leaves: [{ depth: number; leafVersion: number, script: Uint8Array; }] }";function Ok(e){return Array.isArray(e.leaves)&&e.leaves.every(t=>t.depth>=0&&t.depth<=128&&(t.leafVersion&254)===t.leafVersion&&t.script instanceof Uint8Array)}function xk(e,t){return!!e&&!!t&&e.tapTree===void 0}const $k=Object.freeze(Object.defineProperty({__proto__:null,canAdd:xk,check:Ok,decode:kk,encode:Pk,expected:Ik},Symbol.toStringTag,{value:"Module"})),Ck=e=>[...Array(e).keys()],Nk=e=>e.length===33&&[2,3].includes(e[0])||e.length===65&&e[0]===4;function Ef(e,t=Nk){function r(a){if(a.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+Ee(a.key));const u=a.key.slice(1);if(!t(u))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+Ee(a.key));if(a.value.length/4%1!==0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const f={masterFingerprint:a.value.slice(0,4),pubkey:u,path:"m"};for(const h of Ck(a.value.length/4-1)){const d=to(a.value,h*4+4,"LE"),g=!!(d&2147483648),v=d&2147483647;f.path+="/"+v.toString(10)+(g?"'":"")}return f}function n(a){const u=Uint8Array.from([e]),f=lt([u,a.pubkey]),h=a.path.split("/"),d=new Uint8Array(h.length*4);d.set(a.masterFingerprint,0);let g=4;return h.slice(1).forEach(v=>{const E=v.slice(-1)==="'";let T=2147483647&parseInt(E?v.slice(0,-1):v,10);E&&(T+=2147483648),ea(d,g,T,"LE"),g+=4}),{key:f,value:d}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }";function o(a){return a.pubkey instanceof Uint8Array&&a.masterFingerprint instanceof Uint8Array&&typeof a.path=="string"&&t(a.pubkey)&&a.masterFingerprint.length===4}function s(a,u,f){const h=Ee(u.pubkey);return f.has(h)?!1:(f.add(h),a.filter(d=>ee(d.pubkey,u.pubkey)===0).length===0)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:s}}function Af(e){return t;function t(r){let n;if(e.includes(r.key[0])&&(n=r.key.slice(1),!(n.length===33||n.length===65)||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+Ee(r.key));return n}}function q1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.redeemScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Uk=e=>e.length===32;function G1(e){const t=Ef(e,Uk);function r(s){const{numberValue:a,bytes:u}=oo(s.value),f=t.decode({key:s.key,value:s.value.slice(u+Number(a)*32)}),h=new Array(Number(a));for(let d=0,g=u;d<a;d++,g+=32)h[d]=s.value.slice(g,g+32);return{...f,leafHashes:h}}function n(s){const a=t.encode(s),u=Vr(s.leafHashes.length),f=new Uint8Array(u);Wi(s.leafHashes.length,f);const h=lt([f,...s.leafHashes,a.value]);return{...a,value:h}}const i="{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }";function o(s){return Array.isArray(s.leafHashes)&&s.leafHashes.every(a=>a instanceof Uint8Array&&a.length===32)&&t.check(s)}return{decode:r,encode:n,check:o,expected:i,canAddToArray:t.canAddToArray}}function X1(e){function t(s){if(s.key[0]!==e||s.key.length!==1)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+Ee(s.key));if(s.value.length!==32)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array&&s.length===32}function o(s,a){return!!s&&!!a&&s.tapInternalKey===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}function J1(e){function t(s){if(s.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+Ee(s.key));return s.value}function r(s){return{key:Uint8Array.from([e]),value:s}}const n="Uint8Array";function i(s){return s instanceof Uint8Array}function o(s,a){return!!s&&!!a&&s.witnessScript===void 0}return{decode:t,encode:r,check:i,expected:n,canAdd:o}}const Sf={unsignedTx:p_,globalXpub:f_,checkPubkey:Af([])},Rt={nonWitnessUtxo:C_,partialSig:K_,sighashType:Y_,finalScriptSig:v_,finalScriptWitness:k_,porCommitment:W_,witnessUtxo:_k,bip32Derivation:Ef(se.BIP32_DERIVATION),redeemScript:q1(se.REDEEM_SCRIPT),witnessScript:J1(se.WITNESS_SCRIPT),checkPubkey:Af([se.PARTIAL_SIG,se.BIP32_DERIVATION]),tapKeySig:rk,tapScriptSig:mk,tapLeafScript:ck,tapBip32Derivation:G1(se.TAP_BIP32_DERIVATION),tapInternalKey:X1(se.TAP_INTERNAL_KEY),tapMerkleRoot:dk},hi={bip32Derivation:Ef(_t.BIP32_DERIVATION),redeemScript:q1(_t.REDEEM_SCRIPT),witnessScript:J1(_t.WITNESS_SCRIPT),checkPubkey:Af([_t.BIP32_DERIVATION]),tapBip32Derivation:G1(_t.TAP_BIP32_DERIVATION),tapTree:$k,tapInternalKey:X1(_t.TAP_INTERNAL_KEY)},Rk=Object.freeze(Object.defineProperty({__proto__:null,globals:Sf,inputs:Rt,outputs:hi},Symbol.toStringTag,{value:"Module"})),bu=e=>[...Array(e).keys()];function Y1(e){const t=e.map(Bk);return t.push(Uint8Array.from([0])),lt(t)}function Bk(e){const t=e.key.length,r=e.value.length,n=Vr(t),i=Vr(r),o=new Uint8Array(n+t+i+r);return Wi(t,o,0),o.set(e.key,n),Wi(r,o,n+t),o.set(e.value,n+t+i),o}function Lk(e,t){let r=0;function n(){const{numberValue:x,bytes:N}=oo(e,r);r+=N;const O=e.slice(r,r+Number(x));return r+=Number(x),O}function i(){const x=to(e,r,"BE");return r+=4,x}function o(){const x=si(e,r);return r+=1,x}function s(){const x=n(),N=n();return{key:x,value:N}}function a(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const x=si(e,r)===0;return x&&r++,x}if(i()!==1886610036)throw new Error("Format Error: Invalid Magic Number");if(o()!==255)throw new Error("Format Error: Magic Number must be followed by 0xff separator");const u=[],f={};for(;!a();){const x=s(),N=Ee(x.key);if(f[N])throw new Error("Format Error: Keys must be unique for global keymap: key "+N);f[N]=1,u.push(x)}const h=u.filter(x=>x.key[0]===jn.UNSIGNED_TX);if(h.length!==1)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const d=t(h[0].value),{inputCount:g,outputCount:v}=d.getInputOutputCounts(),E=[],T=[];for(const x of bu(g)){const N={},O=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each input: input index "+x+" key "+B);N[B]=1,O.push(k)}E.push(O)}for(const x of bu(v)){const N={},O=[];for(;!a();){const k=s(),B=Ee(k.key);if(N[B])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+B);N[B]=1,O.push(k)}T.push(O)}return Z1(d,{globalMapKeyVals:u,inputKeyVals:E,outputKeyVals:T})}function Gt(e,t,r){if(ee(t,Uint8Array.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${Ee(t)}`)}function Z1(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const h of t)switch(h.key[0]){case jn.UNSIGNED_TX:if(Gt("global",h.key,jn.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case jn.GLOBAL_XPUB:i.globalXpub===void 0&&(i.globalXpub=[]),i.globalXpub.push(Sf.globalXpub.decode(h));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(h)}const s=r.length,a=n.length,u=[],f=[];for(const h of bu(s)){const d={};for(const g of r[h])switch(Rt.checkPubkey(g),g.key[0]){case se.NON_WITNESS_UTXO:if(Gt("input",g.key,se.NON_WITNESS_UTXO),d.nonWitnessUtxo!==void 0)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");d.nonWitnessUtxo=Rt.nonWitnessUtxo.decode(g);break;case se.WITNESS_UTXO:if(Gt("input",g.key,se.WITNESS_UTXO),d.witnessUtxo!==void 0)throw new Error("Format Error: Input has multiple WITNESS_UTXO");d.witnessUtxo=Rt.witnessUtxo.decode(g);break;case se.PARTIAL_SIG:d.partialSig===void 0&&(d.partialSig=[]),d.partialSig.push(Rt.partialSig.decode(g));break;case se.SIGHASH_TYPE:if(Gt("input",g.key,se.SIGHASH_TYPE),d.sighashType!==void 0)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");d.sighashType=Rt.sighashType.decode(g);break;case se.REDEEM_SCRIPT:if(Gt("input",g.key,se.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");d.redeemScript=Rt.redeemScript.decode(g);break;case se.WITNESS_SCRIPT:if(Gt("input",g.key,se.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");d.witnessScript=Rt.witnessScript.decode(g);break;case se.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(Rt.bip32Derivation.decode(g));break;case se.FINAL_SCRIPTSIG:Gt("input",g.key,se.FINAL_SCRIPTSIG),d.finalScriptSig=Rt.finalScriptSig.decode(g);break;case se.FINAL_SCRIPTWITNESS:Gt("input",g.key,se.FINAL_SCRIPTWITNESS),d.finalScriptWitness=Rt.finalScriptWitness.decode(g);break;case se.POR_COMMITMENT:Gt("input",g.key,se.POR_COMMITMENT),d.porCommitment=Rt.porCommitment.decode(g);break;case se.TAP_KEY_SIG:Gt("input",g.key,se.TAP_KEY_SIG),d.tapKeySig=Rt.tapKeySig.decode(g);break;case se.TAP_SCRIPT_SIG:d.tapScriptSig===void 0&&(d.tapScriptSig=[]),d.tapScriptSig.push(Rt.tapScriptSig.decode(g));break;case se.TAP_LEAF_SCRIPT:d.tapLeafScript===void 0&&(d.tapLeafScript=[]),d.tapLeafScript.push(Rt.tapLeafScript.decode(g));break;case se.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(Rt.tapBip32Derivation.decode(g));break;case se.TAP_INTERNAL_KEY:Gt("input",g.key,se.TAP_INTERNAL_KEY),d.tapInternalKey=Rt.tapInternalKey.decode(g);break;case se.TAP_MERKLE_ROOT:Gt("input",g.key,se.TAP_MERKLE_ROOT),d.tapMerkleRoot=Rt.tapMerkleRoot.decode(g);break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}u.push(d)}for(const h of bu(a)){const d={};for(const g of n[h])switch(hi.checkPubkey(g),g.key[0]){case _t.REDEEM_SCRIPT:if(Gt("output",g.key,_t.REDEEM_SCRIPT),d.redeemScript!==void 0)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");d.redeemScript=hi.redeemScript.decode(g);break;case _t.WITNESS_SCRIPT:if(Gt("output",g.key,_t.WITNESS_SCRIPT),d.witnessScript!==void 0)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");d.witnessScript=hi.witnessScript.decode(g);break;case _t.BIP32_DERIVATION:d.bip32Derivation===void 0&&(d.bip32Derivation=[]),d.bip32Derivation.push(hi.bip32Derivation.decode(g));break;case _t.TAP_INTERNAL_KEY:Gt("output",g.key,_t.TAP_INTERNAL_KEY),d.tapInternalKey=hi.tapInternalKey.decode(g);break;case _t.TAP_TREE:Gt("output",g.key,_t.TAP_TREE),d.tapTree=hi.tapTree.decode(g);break;case _t.TAP_BIP32_DERIVATION:d.tapBip32Derivation===void 0&&(d.tapBip32Derivation=[]),d.tapBip32Derivation.push(hi.tapBip32Derivation.decode(g));break;default:d.unknownKeyVals||(d.unknownKeyVals=[]),d.unknownKeyVals.push(g)}f.push(d)}return{globalMap:i,inputs:u,outputs:f}}function Hk({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:n,inputKeyVals:i,outputKeyVals:o}=_f({globalMap:e,inputs:t,outputs:r}),s=Y1(n),a=d=>d.length===0?[Uint8Array.from([0])]:d.map(Y1),u=a(i),f=a(o),h=new Uint8Array(5);return h.set([112,115,98,116,255],0),lt([h,s].concat(u,f))}const Kk=(e,t)=>ee(e.key,t.key);function Tf(e,t){const r=new Set,n=Object.entries(e).reduce((o,[s,a])=>{if(s==="unknownKeyVals")return o;const u=t[s];if(u===void 0)return o;const f=(Array.isArray(a)?a:[a]).map(u.encode);return f.map(h=>Ee(h.key)).forEach(h=>{if(r.has(h))throw new Error("Serialize Error: Duplicate key: "+h);r.add(h)}),o.concat(f)},[]),i=e.unknownKeyVals?e.unknownKeyVals.filter(o=>!r.has(Ee(o.key))):[];return n.concat(i).sort(Kk)}function _f({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:Tf(e,Sf),inputKeyVals:t.map(n=>Tf(n,Rt)),outputKeyVals:r.map(n=>Tf(n,hi))}}function jk(e){const t=e[0],r=_f(t),n=e.slice(1);if(n.length===0)throw new Error("Combine: Nothing to combine");const i=Q1(t);if(i===void 0)throw new Error("Combine: Self missing transaction");const o=ao(r.globalKeyVals),s=r.inputKeyVals.map(ao),a=r.outputKeyVals.map(ao);for(const u of n){const f=Q1(u);if(f===void 0||ee(f.toBuffer(),i.toBuffer())!==0)throw new Error("Combine: One of the Psbts does not have the same transaction.");const h=_f(u);ao(h.globalKeyVals).forEach(kf(o,r.globalKeyVals,h.globalKeyVals)),h.inputKeyVals.map(ao).forEach((d,g)=>d.forEach(kf(s[g],r.inputKeyVals[g],h.inputKeyVals[g]))),h.outputKeyVals.map(ao).forEach((d,g)=>d.forEach(kf(a[g],r.outputKeyVals[g],h.outputKeyVals[g])))}return Z1(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}function kf(e,t,r){return n=>{if(e.has(n))return;const i=r.filter(o=>Ee(o.key)===n)[0];t.push(i),e.add(n)}}function Q1(e){return e.globalMap.unsignedTx}function ao(e){const t=new Set;return e.forEach(r=>{const n=Ee(r.key);if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)}),t}function jt(e,t){const r=e[t];if(r===void 0)throw new Error(`No input #${t}`);return r}function pa(e,t){const r=e[t];if(r===void 0)throw new Error(`No output #${t}`);return r}function Pf(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&t.filter(n=>ee(n.key,e.key)===0).length!==0)throw new Error(`Duplicate Key: ${Ee(e.key)}`)}function If(e){let t=0;return Object.keys(e).forEach(r=>{Number(isNaN(Number(r)))&&t++}),t}function Dk(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const n=!!t.redeemScript,i=!!t.witnessScript,o=!n||!!t.finalScriptSig,s=!i||!!t.finalScriptWitness,a=!!t.finalScriptSig||!!t.finalScriptWitness;r=o&&s&&a}if(r===!1)throw new Error(`Input #${e} has too much or too little data to clean`)}function ew(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function Of(e){return(t,r)=>{for(const n of Object.keys(t)){const i=t[n],{canAdd:o,canAddToArray:s,check:a,expected:u}=Rk[e+"s"][n]||{},f=!!s;if(a)if(f){if(!Array.isArray(i)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);i.every(a)||ew(e,n,u,i);const h=r[n]||[],d=new Set;if(!i.every(g=>s(h,g,d)))throw new Error("Can not add duplicate data to array");r[n]=h.concat(i)}else{if(a(i)||ew(e,n,u,i),!o(r,i))throw new Error(`Can not add duplicate data to ${e}`);r[n]=i}}}}const Mk=Of("global"),tw=Of("input"),rw=Of("output");function Fk(e,t){const r=e.length-1,n=jt(e,r);tw(t,n)}function Vk(e,t){const r=e.length-1,n=pa(e,r);rw(t,n)}let nw=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=Fg(e);return this.fromBuffer(r,t)}static fromHex(e,t){const r=ii(e);return this.fromBuffer(r,t)}static fromBuffer(e,t){const r=Lk(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){const e=this.toBuffer();return B5(e)}toHex(){const e=this.toBuffer();return Ee(e)}toBuffer(){return Hk(this)}updateGlobal(e){return Mk(e,this.globalMap),this}updateInput(e,t){const r=jt(this.inputs,e);return tw(t,r),this}updateOutput(e,t){const r=pa(this.outputs,e);return rw(t,r),this}addUnknownKeyValToGlobal(e){return Pf(e,this.globalMap.unknownKeyVals,If(jn)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=jt(this.inputs,e);return Pf(t,r.unknownKeyVals,If(se)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=pa(this.outputs,e);return Pf(t,r.unknownKeyVals,If(_t)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.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(n=>this.addUnknownKeyValToInput(r,n)),Fk(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(n=>this.addUnknownKeyValToOutput(r,n)),Vk(this.outputs,e),this}clearFinalizedInput(e){const t=jt(this.inputs,e);Dk(e,t);for(const r of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(r)||delete t[r];return this}combine(...e){const t=jk([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};function Ss(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}const Wk=Ss(lu),zk=Ss(y1),qk=Ss(sa),mu=Ss(ua),iw=Ss(la),sw=Ss(io),ow=Ss(fa);function vu(e){let t=new Uint8Array(0);function r(s){t=lt([t,s])}function n(s){const a=t.length,u=Vr(s);t=lt([t,new Uint8Array(u)]),Wi(s,t,a)}function i(s){n(s.length),r(s)}function o(s){n(s.length),s.forEach(i)}return o(e),t}function aw(e,t){const r=ci(e),n=e.slice(1,33),i=wt(t);if(i===null)throw new Error("Unknown script error");return i.findIndex(o=>typeof o=="number"?!1:ee(e,o)===0||ee(r,o)===0||ee(n,o)===0)}function Eu(e,t){return aw(e,t)!==-1}function Gk(e,t){return Xk(e).some(r=>cw(r,na.decode,t))}function cw(e,t,r){const{hashType:n}=t(e),i=[];switch(n&Tt.SIGHASH_ANYONECANPAY&&i.push("addInput"),n&31){case Tt.SIGHASH_ALL:break;case Tt.SIGHASH_SINGLE:case Tt.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence");break}return i.indexOf(r)===-1}function Xk(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=Jk(e)}else t=e.partialSig;return t.map(r=>r.signature)}function Jk(e){const t=e.finalScriptSig?wt(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?wt(e.finalScriptWitness)||[]:[];return t.concat(r).filter(n=>n instanceof Uint8Array&&ai(n)).map(n=>({signature:n}))}const Au=e=>e.length===32?e:e.slice(1,33);function uw(e,t,r){const n=lP(t,e,r);try{const i=cP(t,n).concat(n.script).concat(n.controlBlock);return{finalScriptWitness:vu(i)}}catch(i){throw new Error(`Can not finalize taproot input #${e}: ${i}`)}}function Su(e,t){const r=t?Uint8Array.from([t]):Uint8Array.from([]);return lt([e,r])}function bn(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&ow(e.witnessUtxo.script))}function xf(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t)}function lw(e,t,r){sP(e,t,r),aP(e,t,r)}function hw(e,t,r){oP(e,t,r),Yk(e,t)}function Yk(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:i}=e,o=Zk(r,n);if(i&&ee(o,i)!==0)throw new Error("Error adding output. Script or address mismatch.")}}function Zk(e,t){const r=t&&Qk(t.leaves),{output:n}=fa({internalPubkey:e,scriptTree:r});return n}function Qk(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:iP(e)}function eP(e,t){return rP(e).some(r=>cw(r,tP,t))}function tP(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||Tt.SIGHASH_DEFAULT}}function rP(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=nP(e.finalScriptWitness);r&&t.push(r)}return t}function nP(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function iP(e){let t;for(const r of e)if(t=$f(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function $f(e,t,r=0){if(r>GT)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if(sf(t))return;const n=$f(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=$f(e,t&&t[1],r+1);if(i)return[t&&t[0],i]}function sP(e,t,r){const n=bn(e)&&co(t),i=co(e)&&bn(t),o=e===t&&bn(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function oP(e,t,r){const n=xf(e)&&co(t),i=co(e)&&xf(t),o=e===t&&xf(t)&&co(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function aP(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every(o=>Cf(o,t.tapMerkleRoot)),i=(e.tapLeafScript||[]).every(o=>Cf(o,t.tapMerkleRoot));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(n=>Cf(n,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function Cf(e,t){if(!t)return!0;const r=li({output:e.script,version:e.leafVersion}),n=wf(e.controlBlock,r);return ee(n,t)===0}function cP(e,t){const r=li({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(n=>ee(n.leafHash,r)===0).map(n=>uP(t.script,n)).sort((n,i)=>i.positionInScript-n.positionInScript).map(n=>n.signature)}function uP(e,t){return Object.assign({positionInScript:aw(t.pubkey,e)},t)}function lP(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort((i,o)=>i.controlBlock.length-o.controlBlock.length).find(i=>hP(i,e.tapScriptSig,r));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}function hP(e,t,r){const n=li({output:e.script,version:e.leafVersion});return(!r||ee(n,r)===0)&&t.find(i=>ee(i.leafHash,n)===0)!==void 0}function co(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const fP={network:pn,maximumFeeRate:5e3};class bt{constructor(t={},r=new nw(new fw)){be(this,"data"),be(this,"__CACHE"),be(this,"opts"),this.data=r,this.opts=Object.assign({},fP,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},this.data.inputs.length===0&&this.setVersion(2);const n=(i,o,s,a)=>Object.defineProperty(i,o,{enumerable:s,writable:a});n(this,"__CACHE",!1,!0),n(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=Fg(t);return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=ii(t);return this.fromBuffer(n,r)}static fromBuffer(t,r={}){const n=nw.fromBuffer(t,dP),i=new bt(r,n);return bP(i.__CACHE.__TX,i.__CACHE),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map(t=>({hash:$1(t.hash),index:t.index,sequence:t.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(t=>{let r;try{r=da(t.script,this.opts.network)}catch{}return{script:$1(t.script),value:t.value,address:r}})}combine(...t){return this.data.combine(...t.map(r=>r.data)),this}clone(){const t=bt.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){Tu(t),this.opts.maximumFeeRate=t}setVersion(t){Tu(t),ya(this.data.inputs,"setVersion");const r=this.__CACHE;return r.__TX.version=t,r.__EXTRACTED_TX=void 0,this}setLocktime(t){Tu(t),ya(this.data.inputs,"setLocktime");const r=this.__CACHE;return r.__TX.locktime=t,r.__EXTRACTED_TX=void 0,this}setInputSequence(t,r){Tu(r),ya(this.data.inputs,"setInputSequence");const n=this.__CACHE;if(n.__TX.ins.length<=t)throw new Error("Input index too high");return n.__TX.ins[t].sequence=r,n.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach(r=>this.addInput(r)),this}addInput(t){if(arguments.length>1||!t||t.hash===void 0||t.index===void 0)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");lw(t,t,"addInput"),ya(this.data.inputs,"addInput"),t.witnessScript&&Pu(t.witnessScript);const r=this.__CACHE;this.data.addInput(t);const n=r.__TX.ins[r.__TX.ins.length-1];ww(r,n);const i=this.data.inputs.length-1,o=this.data.inputs[i];return o.nonWitnessUtxo&&Rf(this.__CACHE,o,i),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach(r=>this.addOutput(r)),this}addOutput(t){if(arguments.length>1||!t||t.value===void 0||t.address===void 0&&t.script===void 0)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");ya(this.data.inputs,"addOutput");const{address:r}=t;if(typeof r=="string"){const{network:i}=this.opts,o=M1(r,i);t=Object.assign({},t,{script:o})}hw(t,t,"addOutput");const n=this.__CACHE;return this.data.addOutput(t),n.__FEE=void 0,n.__FEE_RATE=void 0,n.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(pw))throw new Error("Not finalized");const r=this.__CACHE;if(t||yP(this,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return Ow(this.data.inputs,n,r,!0),n}getFeeRate(){return Ew("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return Ew("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return jt(this.data.inputs,0),ga(this.data.inputs.length).forEach(t=>this.finalizeInput(t)),this}finalizeInput(t,r){const n=jt(this.data.inputs,t);return bn(n)?this._finalizeTaprootInput(t,n,void 0,r):this._finalizeInput(t,n,r)}finalizeTaprootInput(t,r,n=uw){const i=jt(this.data.inputs,t);if(bn(i))return this._finalizeTaprootInput(t,i,r,n);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,r,n=mP){const{script:i,isP2SH:o,isP2WSH:s,isSegwit:a}=SP(t,r,this.__CACHE);if(!i)throw new Error(`No script found for input #${t}`);gP(r);const{finalScriptSig:u,finalScriptWitness:f}=n(t,r,i,a,o,s);if(u&&this.data.updateInput(t,{finalScriptSig:u}),f&&this.data.updateInput(t,{finalScriptWitness:f}),!u&&!f)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,r,n,i=uw){if(!r.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(r.tapKeySig){const o=fa({output:r.witnessUtxo.script,signature:r.tapKeySig}),s=vu(o.witness);this.data.updateInput(t,{finalScriptWitness:s})}else{const{finalScriptWitness:o}=i(t,r,n);this.data.updateInput(t,{finalScriptWitness:o})}return this.data.clearFinalizedInput(t),this}getInputType(t){const r=jt(this.data.inputs,t),n=xw(t,r,this.__CACHE),i=ku(n,t,"input",r.redeemScript||IP(r.finalScriptSig),r.witnessScript||OP(r.finalScriptWitness)),o=i.type==="raw"?"":i.type+"-",s=Cw(i.meaningfulScript);return o+s}inputHasPubkey(t,r){const n=jt(this.data.inputs,t);return kP(r,n,t,this.__CACHE)}inputHasHDKey(t,r){const n=jt(this.data.inputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}outputHasPubkey(t,r){const n=pa(this.data.outputs,t);return PP(r,n,t,this.__CACHE)}outputHasHDKey(t,r){const n=pa(this.data.outputs,t),i=yw(r);return!!n.bip32Derivation&&n.bip32Derivation.some(i)}validateSignaturesOfAllInputs(t){return jt(this.data.inputs,0),ga(this.data.inputs.length).map(r=>this.validateSignaturesOfInput(r,t)).reduce((r,n)=>n===!0&&r,!0)}validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t];return bn(i)?this.validateSignaturesOfTaprootInput(t,r,n):this._validateSignaturesOfInput(t,r,n)}_validateSignaturesOfInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).partialSig;if(!i||!o||o.length<1)throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");const s=n?o.filter(d=>ee(d.pubkey,n)===0):o;if(s.length<1)throw new Error("No signatures for this pubkey");const a=[];let u,f,h;for(const d of s){const g=na.decode(d.signature),{hash:v,script:E}=h!==g.hashType?Sw(t,Object.assign({},i,{sighashType:g.hashType}),this.__CACHE,!0):{hash:u,script:f};h=g.hashType,u=v,f=E,gw(d.pubkey,E,"verify"),a.push(r(d.pubkey,v,g.signature))}return a.every(d=>d===!0)}validateSignaturesOfTaprootInput(t,r,n){const i=this.data.inputs[t],o=(i||{}).tapKeySig,s=(i||{}).tapScriptSig;if(!i&&!o&&!(s&&!s.length))throw new Error("No signatures to validate");if(typeof r!="function")throw new Error("Need validator function to validate signatures");n=n&&Au(n);const a=n?Uf(t,i,this.data.inputs,n,this.__CACHE):EP(t,i,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const u=a.find(h=>!h.leafHash);let f=0;if(o&&u){if(!r(u.pubkey,u.hash,_w(o)))return!1;f++}if(s)for(const h of s){const d=a.find(g=>ee(g.pubkey,h.pubkey)===0);if(d){if(!r(h.pubkey,d.hash,_w(h.signature)))return!1;f++}}return f>0}signAllInputsHD(t,r=[Tt.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInputHD(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,r=[Tt.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=[],s=[];for(const a of ga(this.data.inputs.length))s.push(this.signInputHDAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInputHD(t,r,n=[Tt.SIGHASH_ALL]){if(!r||!r.publicKey||!r.fingerprint)throw new Error("Need HDSigner to sign input");return Pw(t,this.data.inputs,r).forEach(i=>this.signInput(t,i,n)),this}signInputHDAsync(t,r,n=[Tt.SIGHASH_ALL]){return new Promise((i,o)=>{if(!r||!r.publicKey||!r.fingerprint)return o(new Error("Need HDSigner to sign input"));const s=Pw(t,this.data.inputs,r).map(a=>this.signInputAsync(t,a,n));return Promise.all(s).then(()=>{i()}).catch(o)})}signAllInputs(t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=[];for(const i of ga(this.data.inputs.length))try{this.signInput(i,t,r),n.push(!0)}catch{n.push(!1)}if(n.every(i=>i===!1))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,r){return new Promise((n,i)=>{if(!t||!t.publicKey)return i(new Error("Need Signer to sign input"));const o=[],s=[];for(const[a]of this.data.inputs.entries())s.push(this.signInputAsync(a,t,r).then(()=>{o.push(!0)},()=>{o.push(!1)}));return Promise.all(s).then(()=>{if(o.every(a=>a===!1))return i(new Error("No inputs were signed"));n()})})}signInput(t,r,n){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInput(t,i,r,void 0,n):this._signInput(t,r,n)}signTaprootInput(t,r,n,i){if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInput(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n),s=[{pubkey:r.publicKey,signature:na.encode(r.sign(i),o)}];return this.data.updateInput(t,{partialSig:s}),this}_signTaprootInput(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=s.filter(f=>!f.leafHash).map(f=>Su(n.signSchnorr(f.hash),r.sighashType))[0],u=s.filter(f=>!!f.leafHash).map(f=>({pubkey:Au(n.publicKey),signature:Su(n.signSchnorr(f.hash),r.sighashType),leafHash:f.leafHash}));return a&&this.data.updateInput(t,{tapKeySig:a}),u.length&&this.data.updateInput(t,{tapScriptSig:u}),this}signInputAsync(t,r,n){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const i=jt(this.data.inputs,t);return bn(i)?this._signTaprootInputAsync(t,i,r,void 0,n):this._signInputAsync(t,r,n)})}signTaprootInputAsync(t,r,n,i){return Promise.resolve().then(()=>{if(!r||!r.publicKey)throw new Error("Need Signer to sign input");const o=jt(this.data.inputs,t);if(bn(o))return this._signTaprootInputAsync(t,o,r,n,i);throw new Error(`Input #${t} is not of type Taproot.`)})}_signInputAsync(t,r,n=[Tt.SIGHASH_ALL]){const{hash:i,sighashType:o}=Aw(this.data.inputs,t,r.publicKey,this.__CACHE,n);return Promise.resolve(r.sign(i)).then(s=>{const a=[{pubkey:r.publicKey,signature:na.encode(s,o)}];this.data.updateInput(t,{partialSig:a})})}async _signTaprootInputAsync(t,r,n,i,o=[Tt.SIGHASH_DEFAULT]){const s=this.checkTaprootHashesForSig(t,r,n,i,o),a=[],u=s.filter(h=>!h.leafHash)[0];if(u){const h=Promise.resolve(n.signSchnorr(u.hash)).then(d=>({tapKeySig:Su(d,r.sighashType)}));a.push(h)}const f=s.filter(h=>!!h.leafHash);if(f.length){const h=f.map(d=>Promise.resolve(n.signSchnorr(d.hash)).then(g=>({tapScriptSig:[{pubkey:Au(n.publicKey),signature:Su(g,r.sighashType),leafHash:d.leafHash}]})));a.push(...h)}return Promise.all(a).then(h=>{h.forEach(d=>this.data.updateInput(t,d))})}checkTaprootHashesForSig(t,r,n,i,o){if(typeof n.signSchnorr!="function")throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const s=Uf(t,r,this.data.inputs,n.publicKey,this.__CACHE,i,o);if(!s||!s.length)throw new Error(`Can not sign for input #${t} with the key ${Ee(n.publicKey)}`);return s}toBuffer(){return Nf(this.__CACHE),this.data.toBuffer()}toHex(){return Nf(this.__CACHE),this.data.toHex()}toBase64(){return Nf(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,r){return r.witnessScript&&Pu(r.witnessScript),lw(this.data.inputs[t],r,"updateInput"),this.data.updateInput(t,r),r.nonWitnessUtxo&&Rf(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,r){const n=this.data.outputs[t];return hw(n,r,"updateOutput"),this.data.updateOutput(t,r),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,r){return this.data.addUnknownKeyValToInput(t,r),this}addUnknownKeyValToOutput(t,r){return this.data.addUnknownKeyValToOutput(t,r),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}const dP=e=>new fw(e);class fw{constructor(t=Uint8Array.from([2,0,0,0,0,0,0,0,0,0])){be(this,"tx"),this.tx=Tt.fromBuffer(t),wP(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(t.hash===void 0||t.index===void 0||!(t.hash instanceof Uint8Array)&&typeof t.hash!="string"||typeof t.index!="number")throw new Error("Error adding input.");const r=typeof t.hash=="string"?gf(ii(t.hash)):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(t.script===void 0||t.value===void 0||!(t.script instanceof Uint8Array)||typeof t.value!="bigint")throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function pP(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return dw(1,e.partialSig);case"multisig":const n=lu({output:t});return dw(n.m,e.partialSig,n.pubkeys);default:return!1}}function Nf(e){if(e.__UNSAFE_SIGN_NONSEGWIT!==!1)throw new Error("Not BIP174 compliant, can not export")}function dw(e,t,r){if(!t)return!1;let n;if(r?n=r.map(i=>{const o=xP(i);return t.find(s=>ee(s.pubkey,o)===0)}).filter(i=>!!i):n=t,n.length>e)throw new Error("Too many signatures");return n.length===e}function pw(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function yw(e){return t=>!(ee(e.fingerprint,t.masterFingerprint)||ee(e.derivePath(t.path).publicKey,t.pubkey))}function Tu(e){if(typeof e!="number"||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function yP(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.`)}function ya(e,t){e.forEach(r=>{if(bn(r)?eP(r,t):Gk(r,t))throw new Error("Can not modify transaction, signatures exist.")})}function gP(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(n=>{const{hashType:i}=na.decode(n.signature);if(r!==i)throw new Error("Signature sighash does not match input sighash type")})}function gw(e,t,r){if(!Eu(e,t))throw new Error(`Can not ${r} for this input with the key ${Ee(e)}`)}function wP(e){if(!e.ins.every(t=>t.script&&t.script.length===0&&t.witness&&t.witness.length===0))throw new Error("Format Error: Transaction ScriptSigs are not empty")}function bP(e,t){e.ins.forEach(r=>{ww(t,r)})}function ww(e,t){const r=Ee(gf(Uint8Array.from(t.hash)))+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function bw(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(ee(n,s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const mw=bw(io,"Redeem script"),vw=bw(la,"Witness script");function Ew(e,t,r,n){if(!r.every(pw))throw new Error(`PSBT must be finalized to calculate ${t}`);if(e==="__FEE_RATE"&&n.__FEE_RATE)return n.__FEE_RATE;if(e==="__FEE"&&n.__FEE)return n.__FEE;let i,o=!0;if(n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),Ow(r,i,n,o),e==="__FEE_RATE")return n.__FEE_RATE;if(e==="__FEE")return n.__FEE}function mP(e,t,r,n,i,o){const s=Cw(r);if(!pP(t,r,s))throw new Error(`Can not finalize input #${e}`);return vP(r,s,t.partialSig,n,i,o)}function vP(e,t,r,n,i,o){let s,a;const u=AP(e,t,r),f=o?la({redeem:u}):null,h=i?io({redeem:f||u}):null;return n?(f?a=vu(f.witness):a=vu(u.witness),h&&(s=h.input)):h?s=h.input:s=u.input,{finalScriptSig:s,finalScriptWitness:a}}function Aw(e,t,r,n,i){const o=jt(e,t),{hash:s,sighashType:a,script:u}=Sw(t,o,n,!1,i);return gw(r,u,"sign"),{hash:s,sighashType:a}}function Sw(e,t,r,n,i){const o=r.__TX,s=t.sighashType||Tt.SIGHASH_ALL;kw(s,i);let a,u;if(t.nonWitnessUtxo){const d=_u(r,t,e),g=o.ins[e].hash,v=d.getHash();if(ee(g,v)!==0)throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const E=o.ins[e].index;u=d.outs[E]}else if(t.witnessUtxo)u=t.witnessUtxo;else throw new Error("Need a Utxo input item for signing");const{meaningfulScript:f,type:h}=ku(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,f,u.value,s);else if(mu(f)){const d=sa({hash:f.slice(2)}).output;a=o.hashForWitnessV0(e,d,u.value,s)}else{if(t.nonWitnessUtxo===void 0&&r.__UNSAFE_SIGN_NONSEGWIT===!1)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${Ee(f)}`);!n&&r.__UNSAFE_SIGN_NONSEGWIT!==!1&&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.
32
32
  *********************
33
33
  PROCEED WITH CAUTION!
34
- *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function AP(e,t,r,n){const i=[];if(t.tapInternalKey){const o=Tw(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>Hf(e,t,r,o,n)).flat()}function Tw(e,t,r){const{script:n}=Kf(e,t,r);return ow(n)?n.subarray(2,34):null}function _w(e){return e.length===64?e:e.subarray(0,64)}function Hf(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||_t.SIGHASH_DEFAULT;kw(u,s);const f=r.map((E,T)=>Kf(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=Tw(e,t,i)||Uint8Array.from([]);if(ee(ku(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>_u(n,E.script)).map(E=>{const T=fi({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||ee(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function kw(e,t){if(t&&t.indexOf(e)<0){const r=kP(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function SP(e,t,r){let n;switch(t){case"multisig":const i=_P(e,r);n=pu({output:e,signatures:i});break;case"pubkey":n=y1({output:e,signature:r[0].signature});break;case"pubkeyhash":n=ca({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=fa({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function TP(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=Iu(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||Su(i.script))&&(i.isSegwit=!0),i}function Pw(e,t,r){const n=jt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(ee(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(ee(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function _P(e,t){return pu({output:e}).pubkeys.map(r=>(t.filter(n=>ee(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function Ow(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=uo(e,t);return t+=Vr(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function kP(e){let t=e&_t.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case _t.SIGHASH_ALL:t+="SIGHASH_ALL";break;case _t.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case _t.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Lf(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=_t.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 s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function Iw(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=Ow(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=Iu(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),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(Number(s/BigInt(a)))}function Iu(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Lf(e,t,r),n[r]}function xw(e,t,r){const{script:n}=Kf(e,t,r);return n}function Kf(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=Iu(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function PP(e,t,r,n){const i=xw(r,t,n),{meaningfulScript:o}=xu(i,r,"input",t.redeemScript,t.witnessScript);return _u(e,o)}function OP(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=xu(i,r,"output",t.redeemScript,t.witnessScript);return _u(e,o)}function IP(e){if(!e)return;const t=mt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||$w(r)||CP(r)||!mt(r)))return r}function xP(e){if(!e)return;const t=Ow(e),r=t[t.length-1];if(!($w(r)||!mt(r)))return r}function $P(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function $w(e){return e.length===33&&oT(e)}function CP(e){return ui(e)}function xu(e,t,r,n,i){const o=sw(e),s=o&&n&&iw(n),a=iw(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,mw(t,e,n,r),vw(t,n,i,r),$u(u)):a?(u=i,vw(t,e,i,r),$u(u)):o?(u=n,mw(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function $u(e){if(Su(e)||sw(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Cw(e){return Su(e)?"witnesspubkeyhash":Gk(e)?"pubkeyhash":Wk(e)?"multisig":qk(e)?"pubkey":"nonstandard"}function ma(e){return[...Array(e).keys()]}const An=new Error("The connected wallet doesn't support this method..."),NP=new Error("Wallet is not installed");class Dn{constructor(t,r,n){ge(this,"$store"),ge(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),An}}const jf="BITCOIN_MAINNET",Nw="BITCOIN_TESTNET",Uw="BITCOIN_TESTNET4",Rw="BITCOIN_SIGNET",Bw="FRACTAL_BITCOIN_MAINNET",Hw="FRACTAL_BITCOIN_TESTNET",Lw="Mainnet",UP="Testnet",RP="Signet",BP="livenet",HP="testnet",Kw="livenet",LP="testnet",KP="testnet4",jP="signet",jw="Mainnet",DP="Testnet",vt="mainnet",Ir="signet",Bt="testnet",xr="testnet4",fo="fractal mainnet",$r="fractal testnet",va=e=>e===vt?Lw:e===Bt?UP:e===Ir?RP:Lw,Df=e=>e===vt?jf:e===Bt?Nw:e===xr?Uw:e===Ir?Rw:e===fo?Bw:e===$r?Hw:jf,Cu=e=>e===vt?jw:e===Bt?DP:jw,Ea=e=>e===jf?vt:e===Nw?Bt:e===Uw?xr:e===Rw?Ir:e===Bw?fo:e===Hw?$r:vt,MP=e=>e===BP?vt:e===HP?Bt:vt,Dw=e=>e===Kw?vt:e===LP?Bt:e===KP?xr:e===jP?Ir:e===$r?Bt:vt;function Mw(e,t){return function(){return e.apply(t,arguments)}}const{toString:FP}=Object.prototype,{getPrototypeOf:Mf}=Object,Nu=(e=>t=>{const r=FP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Sn=e=>(e=e.toLowerCase(),t=>Nu(t)===e),Uu=e=>t=>typeof t===e,{isArray:po}=Array,Aa=Uu("undefined");function VP(e){return e!==null&&!Aa(e)&&e.constructor!==null&&!Aa(e.constructor)&&Cr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Fw=Sn("ArrayBuffer");function zP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fw(e.buffer),t}const WP=Uu("string"),Cr=Uu("function"),Vw=Uu("number"),Ru=e=>e!==null&&typeof e=="object",qP=e=>e===!0||e===!1,Bu=e=>{if(Nu(e)!=="object")return!1;const t=Mf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},GP=Sn("Date"),XP=Sn("File"),JP=Sn("Blob"),YP=Sn("FileList"),ZP=e=>Ru(e)&&Cr(e.pipe),QP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cr(e.append)&&((t=Nu(e))==="formdata"||t==="object"&&Cr(e.toString)&&e.toString()==="[object FormData]"))},eO=Sn("URLSearchParams"),[tO,rO,nO,iO]=["ReadableStream","Request","Response","Headers"].map(Sn),sO=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Sa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),po(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function zw(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const ks=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ww=e=>!Aa(e)&&e!==ks;function Ff(){const{caseless:e}=Ww(this)&&this||{},t={},r=(n,i)=>{const o=e&&zw(t,i)||i;Bu(t[o])&&Bu(n)?t[o]=Ff(t[o],n):Bu(n)?t[o]=Ff({},n):po(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Sa(arguments[n],r);return t}const oO=(e,t,r,{allOwnKeys:n}={})=>(Sa(t,(i,o)=>{r&&Cr(i)?e[o]=Mw(i,r):e[o]=i},{allOwnKeys:n}),e),aO=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cO=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},uO=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&Mf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},lO=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},hO=e=>{if(!e)return null;if(po(e))return e;let t=e.length;if(!Vw(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},fO=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Mf(Uint8Array)),dO=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},pO=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},yO=Sn("HTMLFormElement"),gO=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),qw=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),wO=Sn("RegExp"),Gw=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Sa(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},bO=e=>{Gw(e,(t,r)=>{if(Cr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(Cr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},mO=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return po(e)?n(e):n(String(e).split(t)),r},vO=()=>{},EO=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Vf="abcdefghijklmnopqrstuvwxyz",Xw="0123456789",Jw={DIGIT:Xw,ALPHA:Vf,ALPHA_DIGIT:Vf+Vf.toUpperCase()+Xw},AO=(e=16,t=Jw.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function SO(e){return!!(e&&Cr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const TO=e=>{const t=new Array(10),r=(n,i)=>{if(Ru(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=po(n)?[]:{};return Sa(n,(s,a)=>{const u=r(s,i+1);!Aa(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},_O=Sn("AsyncFunction"),kO=e=>e&&(Ru(e)||Cr(e))&&Cr(e.then)&&Cr(e.catch),Yw=((e,t)=>e?setImmediate:t?((r,n)=>(ks.addEventListener("message",({source:i,data:o})=>{i===ks&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),ks.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cr(ks.postMessage)),PO=typeof queueMicrotask<"u"?queueMicrotask.bind(ks):typeof process<"u"&&process.nextTick||Yw,M={isArray:po,isArrayBuffer:Fw,isBuffer:VP,isFormData:QP,isArrayBufferView:zP,isString:WP,isNumber:Vw,isBoolean:qP,isObject:Ru,isPlainObject:Bu,isReadableStream:tO,isRequest:rO,isResponse:nO,isHeaders:iO,isUndefined:Aa,isDate:GP,isFile:XP,isBlob:JP,isRegExp:wO,isFunction:Cr,isStream:ZP,isURLSearchParams:eO,isTypedArray:fO,isFileList:YP,forEach:Sa,merge:Ff,extend:oO,trim:sO,stripBOM:aO,inherits:cO,toFlatObject:uO,kindOf:Nu,kindOfTest:Sn,endsWith:lO,toArray:hO,forEachEntry:dO,matchAll:pO,isHTMLForm:yO,hasOwnProperty:qw,hasOwnProp:qw,reduceDescriptors:Gw,freezeMethods:bO,toObjectSet:mO,toCamelCase:gO,noop:vO,toFiniteNumber:EO,findKey:zw,global:ks,isContextDefined:Ww,ALPHABET:Jw,generateString:AO,isSpecCompliantForm:SO,toJSONObject:TO,isAsyncFn:_O,isThenable:kO,setImmediate:Yw,asap:PO};function xe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}M.inherits(xe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:M.toJSONObject(this.config),code:this.code,status:this.status}}});const Zw=xe.prototype,Qw={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Qw[e]={value:e}}),Object.defineProperties(xe,Qw),Object.defineProperty(Zw,"isAxiosError",{value:!0}),xe.from=(e,t,r,n,i,o)=>{const s=Object.create(Zw);return M.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),xe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const OO=null;function zf(e){return M.isPlainObject(e)||M.isArray(e)}function e2(e){return M.endsWith(e,"[]")?e.slice(0,-2):e}function t2(e,t,r){return e?e.concat(t).map(function(n,i){return n=e2(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function IO(e){return M.isArray(e)&&!e.some(zf)}const xO=M.toFlatObject(M,{},null,function(e){return/^is[A-Z]/.test(e)});function Hu(e,t,r){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=M.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!M.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(M.isDate(v))return v.toISOString();if(!a&&M.isBlob(v))throw new xe("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(v)||M.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(M.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(M.isArray(v)&&IO(v)||(M.isFileList(v)||M.endsWith(E,"[]"))&&(x=M.toArray(v)))return E=e2(E),x.forEach(function(N,I){!(M.isUndefined(N)||N===null)&&t.append(s===!0?t2([E],I,o):s===null?E:E+"[]",u(N))}),!1}return zf(v)?!0:(t.append(t2(T,E,o),u(v)),!1)}const h=[],d=Object.assign(xO,{defaultVisitor:f,convertValue:u,isVisitable:zf});function g(v,E){if(!M.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),M.forEach(v,function(T,x){(!(M.isUndefined(T)||T===null)&&i.call(t,T,M.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!M.isObject(e))throw new TypeError("data must be an object");return g(e),t}function r2(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Wf(e,t){this._pairs=[],e&&Hu(e,this,t)}const n2=Wf.prototype;n2.append=function(e,t){this._pairs.push([e,t])},n2.toString=function(e){const t=e?function(r){return e.call(this,r,r2)}:r2;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function $O(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function i2(e,t,r){if(!t)return e;const n=r&&r.encode||$O,i=r&&r.serialize;let o;if(i?o=i(t,r):o=M.isURLSearchParams(t)?t.toString():new Wf(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class s2{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){M.forEach(this.handlers,function(r){r!==null&&t(r)})}}const o2={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},CO=typeof URLSearchParams<"u"?URLSearchParams:Wf,NO=typeof FormData<"u"?FormData:null,UO=typeof Blob<"u"?Blob:null,RO={isBrowser:!0,classes:{URLSearchParams:CO,FormData:NO,Blob:UO},protocols:["http","https","file","blob","url","data"]},qf=typeof window<"u"&&typeof document<"u",Gf=typeof navigator=="object"&&navigator||void 0,BO=qf&&(!Gf||["ReactNative","NativeScript","NS"].indexOf(Gf.product)<0),HO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LO=qf&&window.location.href||"http://localhost",KO=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:qf,hasStandardBrowserEnv:BO,hasStandardBrowserWebWorkerEnv:HO,navigator:Gf,origin:LO},Symbol.toStringTag,{value:"Module"})),wr={...KO,...RO};function jO(e,t){return Hu(e,new wr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return wr.isNode&&M.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function DO(e){return M.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function MO(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function a2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&M.isArray(i)?i.length:s,u?(M.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!M.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&M.isArray(i[s])&&(i[s]=MO(i[s])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const r={};return M.forEachEntry(e,(n,i)=>{t(DO(n),i,r,0)}),r}return null}function FO(e,t,r){if(M.isString(e))try{return(t||JSON.parse)(e),M.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const Ta={transitional:o2,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=M.isObject(e);if(i&&M.isHTMLForm(e)&&(e=new FormData(e)),M.isFormData(e))return n?JSON.stringify(a2(e)):e;if(M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)||M.isReadableStream(e))return e;if(M.isArrayBufferView(e))return e.buffer;if(M.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return jO(e,this.formSerializer).toString();if((o=M.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Hu(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),FO(e)):e}],transformResponse:[function(e){const t=this.transitional||Ta.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(M.isResponse(e)||M.isReadableStream(e))return e;if(e&&M.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?xe.from(o,xe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wr.classes.FormData,Blob:wr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{Ta.headers[e]={}});const VO=M.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),zO=e=>{const t={};let r,n,i;return e&&e.split(`
35
- `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&VO[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},c2=Symbol("internals");function _a(e){return e&&String(e).trim().toLowerCase()}function Lu(e){return e===!1||e==null?e:M.isArray(e)?e.map(Lu):String(e)}function WO(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const qO=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Xf(e,t,r,n,i){if(M.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!M.isString(t)){if(M.isString(n))return t.indexOf(n)!==-1;if(M.isRegExp(n))return n.test(t)}}function GO(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function XO(e,t){const r=M.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class br{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=_a(u);if(!h)throw new Error("header name must be a non-empty string");const d=M.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=Lu(a))}const s=(a,u)=>M.forEach(a,(f,h)=>o(f,h,u));if(M.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(M.isString(t)&&(t=t.trim())&&!qO(t))s(zO(t),r);else if(M.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=_a(t),t){const n=M.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return WO(i);if(M.isFunction(r))return r.call(this,i,n);if(M.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=_a(t),t){const n=M.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Xf(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=_a(s),s){const a=M.findKey(n,s);a&&(!r||Xf(n,n[a],a,r))&&(delete n[a],i=!0)}}return M.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||Xf(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return M.forEach(this,(i,o)=>{const s=M.findKey(n,o);if(s){r[s]=Lu(i),delete r[o];return}const a=t?GO(o):String(o).trim();a!==o&&delete r[o],r[a]=Lu(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return M.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&M.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
36
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[c2]=this[c2]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=_a(o);r[s]||(XO(n,o),r[s]=!0)}return M.isArray(t)?t.forEach(i):i(t),this}}br.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(br.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),M.freezeMethods(br);function Jf(e,t){const r=this||Ta,n=t||r,i=br.from(n.headers);let o=n.data;return M.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function u2(e){return!!(e&&e.__CANCEL__)}function yo(e,t,r){xe.call(this,e??"canceled",xe.ERR_CANCELED,t,r),this.name="CanceledError"}M.inherits(yo,xe,{__CANCEL__:!0});function l2(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xe("Request failed with status code "+r.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function JO(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function YO(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function ZO(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Ku=(e,t,r=3)=>{let n=0;const i=YO(50,250);return ZO(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},h2=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},f2=e=>(...t)=>M.asap(()=>e(...t)),QO=wr.hasStandardBrowserEnv?function(){const e=wr.navigator&&/(msie|trident)/i.test(wr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=M.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),eI=wr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];M.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),M.isString(n)&&s.push("path="+n),M.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function tI(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function rI(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function d2(e,t){return e&&!tI(t)?rI(e,t):t}const p2=e=>e instanceof br?{...e}:e;function Ps(e,t){t=t||{};const r={};function n(f,h,d){return M.isPlainObject(f)&&M.isPlainObject(h)?M.merge.call({caseless:d},f,h):M.isPlainObject(h)?M.merge({},h):M.isArray(h)?h.slice():h}function i(f,h,d){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!M.isUndefined(h))return n(void 0,h)}function s(f,h){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(p2(f),p2(h),!0)};return M.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);M.isUndefined(d)&&h!==a||(r[f]=d)}),r}const y2=e=>{const t=Ps({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=br.from(s),t.url=i2(d2(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(M.isFormData(r)){if(wr.hasStandardBrowserEnv||wr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(wr.hasStandardBrowserEnv&&(n&&M.isFunction(n)&&(n=n(t)),n||n!==!1&&QO(t.url))){const f=i&&o&&eI.read(o);f&&s.set(i,f)}return t},nI=typeof XMLHttpRequest<"u",iI=nI&&function(e){return new Promise(function(t,r){const n=y2(e);let i=n.data;const o=br.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const I=br.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:I,config:e,request:T};l2(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new xe("Request aborted",xe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new xe("Network Error",xe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let I=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||o2;n.timeoutErrorMessage&&(I=n.timeoutErrorMessage),r(new xe(I,k.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&M.forEach(o.toJSON(),function(I,k){T.setRequestHeader(k,I)}),M.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ku(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=Ku(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=I=>{T&&(r(!I||I.type?new yo(null,e,T):I),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=JO(n.url);if(N&&wr.protocols.indexOf(N)===-1){r(new xe("Unsupported protocol "+N+":",xe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},sI=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof xe?h:new yo(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new xe(`timeout ${t} of ms exceeded`,xe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>M.asap(a),u}},oI=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},aI=async function*(e,t){for await(const r of cI(e))yield*oI(r,t)},cI=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},g2=(e,t,r,n)=>{const i=aI(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},ju=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",w2=ju&&typeof ReadableStream=="function",uI=ju&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),b2=(e,...t)=>{try{return!!e(...t)}catch{return!1}},lI=w2&&b2(()=>{let e=!1;const t=new Request(wr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),m2=64*1024,Yf=w2&&b2(()=>M.isReadableStream(new Response("").body)),Du={stream:Yf&&(e=>e.body)};ju&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Du[t]&&(Du[t]=M.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new xe(`Response type '${t}' is not supported`,xe.ERR_NOT_SUPPORT,n)})})})(new Response);const hI=async e=>{if(e==null)return 0;if(M.isBlob(e))return e.size;if(M.isSpecCompliantForm(e))return(await new Request(wr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(M.isArrayBufferView(e)||M.isArrayBuffer(e))return e.byteLength;if(M.isURLSearchParams(e)&&(e=e+""),M.isString(e))return(await uI(e)).byteLength},fI=async(e,t)=>M.toFiniteNumber(e.getContentLength())??hI(t),dI=ju&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=y2(e);f=f?(f+"").toLowerCase():"text";let v=sI([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&lI&&r!=="get"&&r!=="head"&&(x=await fI(h,n))!==0){let W=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(M.isFormData(n)&&(V=W.headers.get("content-type"))&&h.setContentType(V),W.body){const[Ue,Le]=h2(x,Ku(f2(u)));n=g2(W.body,m2,Ue,Le)}}M.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let I=await fetch(E);const k=Yf&&(f==="stream"||f==="response");if(Yf&&(a||k&&T)){const W={};["status","statusText","headers"].forEach(Je=>{W[Je]=I[Je]});const V=M.toFiniteNumber(I.headers.get("content-length")),[Ue,Le]=a&&h2(V,Ku(f2(a),!0))||[];I=new Response(g2(I.body,m2,Ue,()=>{Le&&Le(),T&&T()}),W)}f=f||"text";let B=await Du[M.findKey(Du,f)||"text"](I,e);return!k&&T&&T(),await new Promise((W,V)=>{l2(W,V,{data:B,headers:br.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new xe("Network Error",xe.ERR_NETWORK,e,E),{cause:N.cause||N}):xe.from(N,N&&N.code,e,E)}}),Zf={http:OO,xhr:iI,fetch:dI};M.forEach(Zf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const v2=e=>`- ${e}`,pI=e=>M.isFunction(e)||e===null||e===!1,E2={getAdapter:e=>{e=M.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!pI(r)&&(n=Zf[(s=String(r)).toLowerCase()],n===void 0))throw new xe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
37
- `+o.map(v2).join(`
38
- `):" "+v2(o[0]):"as no adapter specified";throw new xe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Zf};function Qf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new yo(null,e)}function A2(e){return Qf(e),e.headers=br.from(e.headers),e.data=Jf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),E2.getAdapter(e.adapter||Ta.adapter)(e).then(function(t){return Qf(e),t.data=Jf.call(e,e.transformResponse,t),t.headers=br.from(t.headers),t},function(t){return u2(t)||(Qf(e),t&&t.response&&(t.response.data=Jf.call(e,e.transformResponse,t.response),t.response.headers=br.from(t.response.headers))),Promise.reject(t)})}const S2="1.7.7",ed={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ed[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const T2={};ed.transitional=function(e,t,r){function n(i,o){return"[Axios v"+S2+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new xe(n(o," has been removed"+(t?" in "+t:"")),xe.ERR_DEPRECATED);return t&&!T2[o]&&(T2[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function yI(e,t,r){if(typeof e!="object")throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new xe("option "+o+" must be "+u,xe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new xe("Unknown option "+o,xe.ERR_BAD_OPTION)}}const td={assertOptions:yI,validators:ed},Ji=td.validators;class Os{constructor(t){this.defaults=t,this.interceptors={request:new s2,response:new s2}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
39
- `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ps(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&td.assertOptions(n,{silentJSONParsing:Ji.transitional(Ji.boolean),forcedJSONParsing:Ji.transitional(Ji.boolean),clarifyTimeoutError:Ji.transitional(Ji.boolean)},!1),i!=null&&(M.isFunction(i)?r.paramsSerializer={serialize:i}:td.assertOptions(i,{encode:Ji.function,serialize:Ji.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&M.merge(o.common,o[r.method]);o&&M.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=br.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[A2.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=A2.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=Ps(this.defaults,t);const r=d2(t.baseURL,t.url);return i2(r,t.params,t.paramsSerializer)}}M.forEach(["delete","get","head","options"],function(e){Os.prototype[e]=function(t,r){return this.request(Ps(r||{},{method:e,url:t,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(Ps(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}Os.prototype[e]=t(),Os.prototype[e+"Form"]=t(!0)});class rd{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new yo(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new rd(function(r){t=r}),cancel:t}}}function gI(e){return function(t){return e.apply(null,t)}}function wI(e){return M.isObject(e)&&e.isAxiosError===!0}const nd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nd).forEach(([e,t])=>{nd[t]=e});function _2(e){const t=new Os(e),r=Mw(Os.prototype.request,t);return M.extend(r,Os.prototype,t,{allOwnKeys:!0}),M.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return _2(Ps(e,n))},r}const Xe=_2(Ta);Xe.Axios=Os,Xe.CanceledError=yo,Xe.CancelToken=rd,Xe.isCancel=u2,Xe.VERSION=S2,Xe.toFormData=Hu,Xe.AxiosError=xe,Xe.Cancel=Xe.CanceledError,Xe.all=function(e){return Promise.all(e)},Xe.spread=gI,Xe.isAxiosError=wI,Xe.mergeConfig=Ps,Xe.AxiosHeaders=br,Xe.formToJSON=e=>a2(M.isHTMLForm(e)?new FormData(e):e),Xe.getAdapter=E2.getAdapter,Xe.HttpStatusCode=nd,Xe.default=Xe;var k2={},go={};go.byteLength=vI,go.toByteArray=AI,go.fromByteArray=_I;for(var Mn=[],zr=[],bI=typeof Uint8Array<"u"?Uint8Array:Array,id="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wo=0,mI=id.length;wo<mI;++wo)Mn[wo]=id[wo],zr[id.charCodeAt(wo)]=wo;zr[45]=62,zr[95]=63;function P2(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function vI(e){var t=P2(e),r=t[0],n=t[1];return(r+n)*3/4-n}function EI(e,t,r){return(t+r)*3/4-r}function AI(e){var t,r=P2(e),n=r[0],i=r[1],o=new bI(EI(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=zr[e.charCodeAt(u)]<<18|zr[e.charCodeAt(u+1)]<<12|zr[e.charCodeAt(u+2)]<<6|zr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=zr[e.charCodeAt(u)]<<2|zr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=zr[e.charCodeAt(u)]<<10|zr[e.charCodeAt(u+1)]<<4|zr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function SI(e){return Mn[e>>18&63]+Mn[e>>12&63]+Mn[e>>6&63]+Mn[e&63]}function TI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(SI(n));return i.join("")}function _I(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(TI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Mn[t>>2]+Mn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Mn[t>>10]+Mn[t>>4&63]+Mn[t<<2&63]+"=")),i.join("")}var sd={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */sd.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},sd.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
34
+ *********************`),a=o.hashForSignature(e,f,s)}return{script:f,sighashType:s,hash:a}}function EP(e,t,r,n){const i=[];if(t.tapInternalKey){const o=Tw(e,t,n);o&&i.push(o)}if(t.tapScriptSig){const o=t.tapScriptSig.map(s=>s.pubkey);i.push(...o)}return i.map(o=>Uf(e,t,r,o,n)).flat()}function Tw(e,t,r){const{script:n}=Bf(e,t,r);return ow(n)?n.subarray(2,34):null}function _w(e){return e.length===64?e:e.subarray(0,64)}function Uf(e,t,r,n,i,o,s){const a=i.__TX,u=t.sighashType||Tt.SIGHASH_DEFAULT;kw(u,s);const f=r.map((E,T)=>Bf(T,E,i)),h=f.map(E=>E.script),d=f.map(E=>E.value),g=[];if(t.tapInternalKey&&!o){const E=Tw(e,t,i)||Uint8Array.from([]);if(ee(Au(n),E)===0){const T=a.hashForWitnessV1(e,h,d,u);g.push({pubkey:n,hash:T})}}const v=(t.tapLeafScript||[]).filter(E=>Eu(n,E.script)).map(E=>{const T=li({output:E.script,version:E.leafVersion});return Object.assign({hash:T},E)}).filter(E=>!o||ee(o,E.hash)===0).map(E=>{const T=a.hashForWitnessV1(e,h,d,u,E.hash);return{pubkey:n,hash:T,leafHash:E.hash}});return g.concat(v)}function kw(e,t){if(t&&t.indexOf(e)<0){const r=_P(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function AP(e,t,r){let n;switch(t){case"multisig":const i=TP(e,r);n=lu({output:e,signatures:i});break;case"pubkey":n=y1({output:e,signature:r[0].signature});break;case"pubkeyhash":n=sa({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ua({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function SP(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=_u(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||mu(i.script))&&(i.isSegwit=!0),i}function Pw(e,t,r){const n=jt(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(o=>{if(ee(o.masterFingerprint,r.fingerprint)===0)return o}).filter(o=>!!o);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(o=>{const s=r.derivePath(o.path);if(ee(o.pubkey,s.publicKey)!==0)throw new Error("pubkey did not match bip32Derivation");return s})}function TP(e,t){return lu({output:e}).pubkeys.map(r=>(t.filter(n=>ee(n.pubkey,r)===0)[0]||{}).signature).filter(r=>!!r)}function Iw(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=oo(e,t);return t+=Vr(s.bigintValue),s.numberValue}function i(){return r(n())}function o(){const s=n(),a=[];for(let u=0;u<s;u++)a.push(i());return a}return o()}function _P(e){let t=e&Tt.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case Tt.SIGHASH_ALL:t+="SIGHASH_ALL";break;case Tt.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case Tt.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Rf(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=Tt.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 s=i.__NON_WITNESS_UTXO_BUF_CACHE[o],a=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(s!==void 0)return s;{const u=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=u,u}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=s}})}function Ow(e,t,r,n){let i=0n;e.forEach((u,f)=>{if(n&&u.finalScriptSig&&(t.ins[f].script=u.finalScriptSig),n&&u.finalScriptWitness&&(t.ins[f].witness=Iw(u.finalScriptWitness)),u.witnessUtxo)i+=u.witnessUtxo.value;else if(u.nonWitnessUtxo){const h=_u(r,u,f),d=t.ins[f].index,g=h.outs[d];i+=g.value}});const o=t.outs.reduce((u,f)=>u+f.value,0n),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(Number(s/BigInt(a)))}function _u(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Rf(e,t,r),n[r]}function xw(e,t,r){const{script:n}=Bf(e,t,r);return n}function Bf(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const n=_u(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function kP(e,t,r,n){const i=xw(r,t,n),{meaningfulScript:o}=ku(i,r,"input",t.redeemScript,t.witnessScript);return Eu(e,o)}function PP(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=ku(i,r,"output",t.redeemScript,t.witnessScript);return Eu(e,o)}function IP(e){if(!e)return;const t=wt(e);if(!t)return;const r=t[t.length-1];if(!(!(r instanceof Uint8Array)||$w(r)||$P(r)||!wt(r)))return r}function OP(e){if(!e)return;const t=Iw(e),r=t[t.length-1];if(!($w(r)||!wt(r)))return r}function xP(e){if(e.length===65){const t=e[64]&1,r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}function $w(e){return e.length===33&&sT(e)}function $P(e){return ai(e)}function ku(e,t,r,n,i){const o=sw(e),s=o&&n&&iw(n),a=iw(e);if(o&&n===void 0)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&i===void 0)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,mw(t,e,n,r),vw(t,n,i,r),Pu(u)):a?(u=i,vw(t,e,i,r),Pu(u)):o?(u=n,mw(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Pu(e){if(mu(e)||sw(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Cw(e){return mu(e)?"witnesspubkeyhash":qk(e)?"pubkeyhash":Wk(e)?"multisig":zk(e)?"pubkey":"nonstandard"}function ga(e){return[...Array(e).keys()]}const mn=new Error("The connected wallet doesn't support this method..."),CP=new Error("Wallet is not installed");class fi{constructor(t,r,n){be(this,"$store"),be(this,"$network"),this.parent=r,this.config=n,this.$store=t.$store,this.$network=t.$network,this.initialize()}disconnect(){}switchNetwork(t){throw this.parent.disconnect(),mn}}const Lf="BITCOIN_MAINNET",Nw="BITCOIN_TESTNET",Uw="BITCOIN_TESTNET4",Rw="BITCOIN_SIGNET",Bw="FRACTAL_BITCOIN_MAINNET",Lw="FRACTAL_BITCOIN_TESTNET",Hw="Mainnet",NP="Testnet",UP="Signet",RP="livenet",BP="testnet",Kw="livenet",LP="testnet",HP="testnet4",KP="signet",jw="Mainnet",jP="Testnet",mt="mainnet",Or="signet",Bt="testnet",xr="testnet4",uo="fractal mainnet",$r="fractal testnet",wa=e=>e===mt?Hw:e===Bt?NP:e===Or?UP:Hw,Dw=e=>e===mt?Lf:e===Bt?Nw:e===xr?Uw:e===Or?Rw:e===uo?Bw:e===$r?Lw:Lf,Iu=e=>e===mt?jw:e===Bt?jP:jw,Hf=e=>e===Lf?mt:e===Nw?Bt:e===Uw?xr:e===Rw?Or:e===Bw?uo:e===Lw?$r:mt,DP=e=>e===RP?mt:e===BP?Bt:mt,Mw=e=>e===Kw?mt:e===LP?Bt:e===HP?xr:e===KP?Or:e===$r?Bt:mt;function Fw(e,t){return function(){return e.apply(t,arguments)}}const{toString:MP}=Object.prototype,{getPrototypeOf:Kf}=Object,Ou=(e=>t=>{const r=MP.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),vn=e=>(e=e.toLowerCase(),t=>Ou(t)===e),xu=e=>t=>typeof t===e,{isArray:lo}=Array,ba=xu("undefined");function FP(e){return e!==null&&!ba(e)&&e.constructor!==null&&!ba(e.constructor)&&Cr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Vw=vn("ArrayBuffer");function VP(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Vw(e.buffer),t}const WP=xu("string"),Cr=xu("function"),Ww=xu("number"),$u=e=>e!==null&&typeof e=="object",zP=e=>e===!0||e===!1,Cu=e=>{if(Ou(e)!=="object")return!1;const t=Kf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},qP=vn("Date"),GP=vn("File"),XP=vn("Blob"),JP=vn("FileList"),YP=e=>$u(e)&&Cr(e.pipe),ZP=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cr(e.append)&&((t=Ou(e))==="formdata"||t==="object"&&Cr(e.toString)&&e.toString()==="[object FormData]"))},QP=vn("URLSearchParams"),[eI,tI,rI,nI]=["ReadableStream","Request","Response","Headers"].map(vn),iI=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ma(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),lo(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let a;for(n=0;n<s;n++)a=o[n],t.call(null,e[a],a,e)}}function zw(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const Ts=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qw=e=>!ba(e)&&e!==Ts;function jf(){const{caseless:e}=qw(this)&&this||{},t={},r=(n,i)=>{const o=e&&zw(t,i)||i;Cu(t[o])&&Cu(n)?t[o]=jf(t[o],n):Cu(n)?t[o]=jf({},n):lo(n)?t[o]=n.slice():t[o]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&ma(arguments[n],r);return t}const sI=(e,t,r,{allOwnKeys:n}={})=>(ma(t,(i,o)=>{r&&Cr(i)?e[o]=Fw(i,r):e[o]=i},{allOwnKeys:n}),e),oI=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),aI=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},cI=(e,t,r,n)=>{let i,o,s;const a={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=r!==!1&&Kf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},uI=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},lI=e=>{if(!e)return null;if(lo(e))return e;let t=e.length;if(!Ww(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},hI=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Kf(Uint8Array)),fI=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},dI=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},pI=vn("HTMLFormElement"),yI=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),Gw=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gI=vn("RegExp"),Xw=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ma(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},wI=e=>{Xw(e,(t,r)=>{if(Cr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(Cr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},bI=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return lo(e)?n(e):n(String(e).split(t)),r},mI=()=>{},vI=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,Df="abcdefghijklmnopqrstuvwxyz",Jw="0123456789",Yw={DIGIT:Jw,ALPHA:Df,ALPHA_DIGIT:Df+Df.toUpperCase()+Jw},EI=(e=16,t=Yw.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function AI(e){return!!(e&&Cr(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const SI=e=>{const t=new Array(10),r=(n,i)=>{if($u(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;const o=lo(n)?[]:{};return ma(n,(s,a)=>{const u=r(s,i+1);!ba(u)&&(o[a]=u)}),t[i]=void 0,o}}return n};return r(e,0)},TI=vn("AsyncFunction"),_I=e=>e&&($u(e)||Cr(e))&&Cr(e.then)&&Cr(e.catch),Zw=((e,t)=>e?setImmediate:t?((r,n)=>(Ts.addEventListener("message",({source:i,data:o})=>{i===Ts&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ts.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cr(Ts.postMessage)),kI=typeof queueMicrotask<"u"?queueMicrotask.bind(Ts):typeof process<"u"&&process.nextTick||Zw,M={isArray:lo,isArrayBuffer:Vw,isBuffer:FP,isFormData:ZP,isArrayBufferView:VP,isString:WP,isNumber:Ww,isBoolean:zP,isObject:$u,isPlainObject:Cu,isReadableStream:eI,isRequest:tI,isResponse:rI,isHeaders:nI,isUndefined:ba,isDate:qP,isFile:GP,isBlob:XP,isRegExp:gI,isFunction:Cr,isStream:YP,isURLSearchParams:QP,isTypedArray:hI,isFileList:JP,forEach:ma,merge:jf,extend:sI,trim:iI,stripBOM:oI,inherits:aI,toFlatObject:cI,kindOf:Ou,kindOfTest:vn,endsWith:uI,toArray:lI,forEachEntry:fI,matchAll:dI,isHTMLForm:pI,hasOwnProperty:Gw,hasOwnProp:Gw,reduceDescriptors:Xw,freezeMethods:wI,toObjectSet:bI,toCamelCase:yI,noop:mI,toFiniteNumber:vI,findKey:zw,global:Ts,isContextDefined:qw,ALPHABET:Yw,generateString:EI,isSpecCompliantForm:AI,toJSONObject:SI,isAsyncFn:TI,isThenable:_I,setImmediate:Zw,asap:kI};function xe(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}M.inherits(xe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:M.toJSONObject(this.config),code:this.code,status:this.status}}});const Qw=xe.prototype,e2={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{e2[e]={value:e}}),Object.defineProperties(xe,e2),Object.defineProperty(Qw,"isAxiosError",{value:!0}),xe.from=(e,t,r,n,i,o)=>{const s=Object.create(Qw);return M.toFlatObject(e,s,function(a){return a!==Error.prototype},a=>a!=="isAxiosError"),xe.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const PI=null;function Mf(e){return M.isPlainObject(e)||M.isArray(e)}function t2(e){return M.endsWith(e,"[]")?e.slice(0,-2):e}function r2(e,t,r){return e?e.concat(t).map(function(n,i){return n=t2(n),!r&&i?"["+n+"]":n}).join(r?".":""):t}function II(e){return M.isArray(e)&&!e.some(Mf)}const OI=M.toFlatObject(M,{},null,function(e){return/^is[A-Z]/.test(e)});function Nu(e,t,r){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=M.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,E){return!M.isUndefined(E[v])});const n=r.metaTokens,i=r.visitor||f,o=r.dots,s=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(i))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(M.isDate(v))return v.toISOString();if(!a&&M.isBlob(v))throw new xe("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(v)||M.isTypedArray(v)?a&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function f(v,E,T){let x=v;if(v&&!T&&typeof v=="object"){if(M.endsWith(E,"{}"))E=n?E:E.slice(0,-2),v=JSON.stringify(v);else if(M.isArray(v)&&II(v)||(M.isFileList(v)||M.endsWith(E,"[]"))&&(x=M.toArray(v)))return E=t2(E),x.forEach(function(N,O){!(M.isUndefined(N)||N===null)&&t.append(s===!0?r2([E],O,o):s===null?E:E+"[]",u(N))}),!1}return Mf(v)?!0:(t.append(r2(T,E,o),u(v)),!1)}const h=[],d=Object.assign(OI,{defaultVisitor:f,convertValue:u,isVisitable:Mf});function g(v,E){if(!M.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+E.join("."));h.push(v),M.forEach(v,function(T,x){(!(M.isUndefined(T)||T===null)&&i.call(t,T,M.isString(x)?x.trim():x,E,d))===!0&&g(T,E?E.concat(x):[x])}),h.pop()}}if(!M.isObject(e))throw new TypeError("data must be an object");return g(e),t}function n2(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ff(e,t){this._pairs=[],e&&Nu(e,this,t)}const i2=Ff.prototype;i2.append=function(e,t){this._pairs.push([e,t])},i2.toString=function(e){const t=e?function(r){return e.call(this,r,n2)}:n2;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function xI(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function s2(e,t,r){if(!t)return e;const n=r&&r.encode||xI,i=r&&r.serialize;let o;if(i?o=i(t,r):o=M.isURLSearchParams(t)?t.toString():new Ff(t,r).toString(n),o){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class o2{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){M.forEach(this.handlers,function(r){r!==null&&t(r)})}}const a2={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$I=typeof URLSearchParams<"u"?URLSearchParams:Ff,CI=typeof FormData<"u"?FormData:null,NI=typeof Blob<"u"?Blob:null,UI={isBrowser:!0,classes:{URLSearchParams:$I,FormData:CI,Blob:NI},protocols:["http","https","file","blob","url","data"]},Vf=typeof window<"u"&&typeof document<"u",Wf=typeof navigator=="object"&&navigator||void 0,RI=Vf&&(!Wf||["ReactNative","NativeScript","NS"].indexOf(Wf.product)<0),BI=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LI=Vf&&window.location.href||"http://localhost",HI=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Vf,hasStandardBrowserEnv:RI,hasStandardBrowserWebWorkerEnv:BI,navigator:Wf,origin:LI},Symbol.toStringTag,{value:"Module"})),wr={...HI,...UI};function KI(e,t){return Nu(e,new wr.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,o){return wr.isNode&&M.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function jI(e){return M.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DI(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function c2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),u=o>=r.length;return s=!s&&M.isArray(i)?i.length:s,u?(M.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!M.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&M.isArray(i[s])&&(i[s]=DI(i[s])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const r={};return M.forEachEntry(e,(n,i)=>{t(jI(n),i,r,0)}),r}return null}function MI(e,t,r){if(M.isString(e))try{return(t||JSON.parse)(e),M.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const va={transitional:a2,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=M.isObject(e);if(i&&M.isHTMLForm(e)&&(e=new FormData(e)),M.isFormData(e))return n?JSON.stringify(c2(e)):e;if(M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)||M.isReadableStream(e))return e;if(M.isArrayBufferView(e))return e.buffer;if(M.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return KI(e,this.formSerializer).toString();if((o=M.isFileList(e))||r.indexOf("multipart/form-data")>-1){const s=this.env&&this.env.FormData;return Nu(o?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),MI(e)):e}],transformResponse:[function(e){const t=this.transitional||va.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(M.isResponse(e)||M.isReadableStream(e))return e;if(e&&M.isString(e)&&(r&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?xe.from(o,xe.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wr.classes.FormData,Blob:wr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{va.headers[e]={}});const FI=M.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),VI=e=>{const t={};let r,n,i;return e&&e.split(`
35
+ `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&FI[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},u2=Symbol("internals");function Ea(e){return e&&String(e).trim().toLowerCase()}function Uu(e){return e===!1||e==null?e:M.isArray(e)?e.map(Uu):String(e)}function WI(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const zI=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zf(e,t,r,n,i){if(M.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!M.isString(t)){if(M.isString(n))return t.indexOf(n)!==-1;if(M.isRegExp(n))return n.test(t)}}function qI(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function GI(e,t){const r=M.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}class br{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(a,u,f){const h=Ea(u);if(!h)throw new Error("header name must be a non-empty string");const d=M.findKey(i,h);(!d||i[d]===void 0||f===!0||f===void 0&&i[d]!==!1)&&(i[d||u]=Uu(a))}const s=(a,u)=>M.forEach(a,(f,h)=>o(f,h,u));if(M.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(M.isString(t)&&(t=t.trim())&&!zI(t))s(VI(t),r);else if(M.isHeaders(t))for(const[a,u]of t.entries())o(u,a,n);else t!=null&&o(r,t,n);return this}get(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return WI(i);if(M.isFunction(r))return r.call(this,i,n);if(M.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Ea(t),t){const n=M.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||zf(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Ea(s),s){const a=M.findKey(n,s);a&&(!r||zf(n,n[a],a,r))&&(delete n[a],i=!0)}}return M.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||zf(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return M.forEach(this,(i,o)=>{const s=M.findKey(n,o);if(s){r[s]=Uu(i),delete r[o];return}const a=t?qI(o):String(o).trim();a!==o&&delete r[o],r[a]=Uu(i),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return M.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&M.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
36
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const r=(this[u2]=this[u2]={accessors:{}}).accessors,n=this.prototype;function i(o){const s=Ea(o);r[s]||(GI(n,o),r[s]=!0)}return M.isArray(t)?t.forEach(i):i(t),this}}br.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(br.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),M.freezeMethods(br);function qf(e,t){const r=this||va,n=t||r,i=br.from(n.headers);let o=n.data;return M.forEach(e,function(s){o=s.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function l2(e){return!!(e&&e.__CANCEL__)}function ho(e,t,r){xe.call(this,e??"canceled",xe.ERR_CANCELED,t,r),this.name="CanceledError"}M.inherits(ho,xe,{__CANCEL__:!0});function h2(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xe("Request failed with status code "+r.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function XI(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function JI(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),f=n[o];s||(s=u),r[i]=a,n[i]=u;let h=o,d=0;for(;h!==i;)d+=r[h++],h=h%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(d*1e3/g):void 0}}function YI(e,t){let r=0,n=1e3/t,i,o;const s=(a,u=Date.now())=>{r=u,i=null,o&&(clearTimeout(o),o=null),e.apply(null,a)};return[(...a)=>{const u=Date.now(),f=u-r;f>=n?s(a,u):(i=a,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Ru=(e,t,r=3)=>{let n=0;const i=JI(50,250);return YI(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,u=s-n,f=i(u),h=s<=a;n=s;const d={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:f||void 0,estimated:f&&a&&h?(a-s)/f:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},f2=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},d2=e=>(...t)=>M.asap(()=>e(...t)),ZI=wr.hasStandardBrowserEnv?function(){const e=wr.navigator&&/(msie|trident)/i.test(wr.navigator.userAgent),t=document.createElement("a");let r;function n(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(i){const o=M.isString(i)?n(i):i;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),QI=wr.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];M.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),M.isString(n)&&s.push("path="+n),M.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function eO(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function tO(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function p2(e,t){return e&&!eO(t)?tO(e,t):t}const y2=e=>e instanceof br?{...e}:e;function _s(e,t){t=t||{};const r={};function n(f,h,d){return M.isPlainObject(f)&&M.isPlainObject(h)?M.merge.call({caseless:d},f,h):M.isPlainObject(h)?M.merge({},h):M.isArray(h)?h.slice():h}function i(f,h,d){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f,d)}else return n(f,h,d)}function o(f,h){if(!M.isUndefined(h))return n(void 0,h)}function s(f,h){if(M.isUndefined(h)){if(!M.isUndefined(f))return n(void 0,f)}else return n(void 0,h)}function a(f,h,d){if(d in t)return n(f,h);if(d in e)return n(void 0,f)}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(f,h)=>i(y2(f),y2(h),!0)};return M.forEach(Object.keys(Object.assign({},e,t)),function(f){const h=u[f]||i,d=h(e[f],t[f],f);M.isUndefined(d)&&h!==a||(r[f]=d)}),r}const g2=e=>{const t=_s({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=br.from(s),t.url=s2(p2(t.baseURL,t.url),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(M.isFormData(r)){if(wr.hasStandardBrowserEnv||wr.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[f,...h]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(wr.hasStandardBrowserEnv&&(n&&M.isFunction(n)&&(n=n(t)),n||n!==!1&&ZI(t.url))){const f=i&&o&&QI.read(o);f&&s.set(i,f)}return t},rO=typeof XMLHttpRequest<"u",nO=rO&&function(e){return new Promise(function(t,r){const n=g2(e);let i=n.data;const o=br.from(n.headers).normalize();let{responseType:s,onUploadProgress:a,onDownloadProgress:u}=n,f,h,d,g,v;function E(){g&&g(),v&&v(),n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let T=new XMLHttpRequest;T.open(n.method.toUpperCase(),n.url,!0),T.timeout=n.timeout;function x(){if(!T)return;const O=br.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),k={data:!s||s==="text"||s==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:O,config:e,request:T};h2(function(B){t(B),E()},function(B){r(B),E()},k),T=null}"onloadend"in T?T.onloadend=x:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(x)},T.onabort=function(){T&&(r(new xe("Request aborted",xe.ECONNABORTED,e,T)),T=null)},T.onerror=function(){r(new xe("Network Error",xe.ERR_NETWORK,e,T)),T=null},T.ontimeout=function(){let O=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const k=n.transitional||a2;n.timeoutErrorMessage&&(O=n.timeoutErrorMessage),r(new xe(O,k.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,T)),T=null},i===void 0&&o.setContentType(null),"setRequestHeader"in T&&M.forEach(o.toJSON(),function(O,k){T.setRequestHeader(k,O)}),M.isUndefined(n.withCredentials)||(T.withCredentials=!!n.withCredentials),s&&s!=="json"&&(T.responseType=n.responseType),u&&([d,v]=Ru(u,!0),T.addEventListener("progress",d)),a&&T.upload&&([h,g]=Ru(a),T.upload.addEventListener("progress",h),T.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(f=O=>{T&&(r(!O||O.type?new ho(null,e,T):O),T.abort(),T=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const N=XI(n.url);if(N&&wr.protocols.indexOf(N)===-1){r(new xe("Unsupported protocol "+N+":",xe.ERR_BAD_REQUEST,e));return}T.send(i||null)})},iO=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,a();const h=f instanceof Error?f:this.reason;n.abort(h instanceof xe?h:new ho(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,o(new xe(`timeout ${t} of ms exceeded`,xe.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:u}=n;return u.unsubscribe=()=>M.asap(a),u}},sO=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},oO=async function*(e,t){for await(const r of aO(e))yield*sO(r,t)},aO=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},w2=(e,t,r,n)=>{const i=oO(e,t);let o=0,s,a=u=>{s||(s=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:f,value:h}=await i.next();if(f){a(),u.close();return}let d=h.byteLength;if(r){let g=o+=d;r(g)}u.enqueue(new Uint8Array(h))}catch(f){throw a(f),f}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},Bu=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",b2=Bu&&typeof ReadableStream=="function",cO=Bu&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),m2=(e,...t)=>{try{return!!e(...t)}catch{return!1}},uO=b2&&m2(()=>{let e=!1;const t=new Request(wr.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),v2=64*1024,Gf=b2&&m2(()=>M.isReadableStream(new Response("").body)),Lu={stream:Gf&&(e=>e.body)};Bu&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Lu[t]&&(Lu[t]=M.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new xe(`Response type '${t}' is not supported`,xe.ERR_NOT_SUPPORT,n)})})})(new Response);const lO=async e=>{if(e==null)return 0;if(M.isBlob(e))return e.size;if(M.isSpecCompliantForm(e))return(await new Request(wr.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(M.isArrayBufferView(e)||M.isArrayBuffer(e))return e.byteLength;if(M.isURLSearchParams(e)&&(e=e+""),M.isString(e))return(await cO(e)).byteLength},hO=async(e,t)=>M.toFiniteNumber(e.getContentLength())??lO(t),fO=Bu&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:f,headers:h,withCredentials:d="same-origin",fetchOptions:g}=g2(e);f=f?(f+"").toLowerCase():"text";let v=iO([i,o&&o.toAbortSignal()],s),E;const T=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let x;try{if(u&&uO&&r!=="get"&&r!=="head"&&(x=await hO(h,n))!==0){let z=new Request(t,{method:"POST",body:n,duplex:"half"}),V;if(M.isFormData(n)&&(V=z.headers.get("content-type"))&&h.setContentType(V),z.body){const[Ue,He]=f2(x,Ru(d2(u)));n=w2(z.body,v2,Ue,He)}}M.isString(d)||(d=d?"include":"omit");const N="credentials"in Request.prototype;E=new Request(t,{...g,signal:v,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:N?d:void 0});let O=await fetch(E);const k=Gf&&(f==="stream"||f==="response");if(Gf&&(a||k&&T)){const z={};["status","statusText","headers"].forEach(Ge=>{z[Ge]=O[Ge]});const V=M.toFiniteNumber(O.headers.get("content-length")),[Ue,He]=a&&f2(V,Ru(d2(a),!0))||[];O=new Response(w2(O.body,v2,Ue,()=>{He&&He(),T&&T()}),z)}f=f||"text";let B=await Lu[M.findKey(Lu,f)||"text"](O,e);return!k&&T&&T(),await new Promise((z,V)=>{h2(z,V,{data:B,headers:br.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:E})})}catch(N){throw T&&T(),N&&N.name==="TypeError"&&/fetch/i.test(N.message)?Object.assign(new xe("Network Error",xe.ERR_NETWORK,e,E),{cause:N.cause||N}):xe.from(N,N&&N.code,e,E)}}),Xf={http:PI,xhr:nO,fetch:fO};M.forEach(Xf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const E2=e=>`- ${e}`,dO=e=>M.isFunction(e)||e===null||e===!1,A2={getAdapter:e=>{e=M.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!dO(r)&&(n=Xf[(s=String(r)).toLowerCase()],n===void 0))throw new xe(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){const o=Object.entries(i).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?o.length>1?`since :
37
+ `+o.map(E2).join(`
38
+ `):" "+E2(o[0]):"as no adapter specified";throw new xe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Xf};function Jf(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ho(null,e)}function S2(e){return Jf(e),e.headers=br.from(e.headers),e.data=qf.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),A2.getAdapter(e.adapter||va.adapter)(e).then(function(t){return Jf(e),t.data=qf.call(e,e.transformResponse,t),t.headers=br.from(t.headers),t},function(t){return l2(t)||(Jf(e),t&&t.response&&(t.response.data=qf.call(e,e.transformResponse,t.response),t.response.headers=br.from(t.response.headers))),Promise.reject(t)})}const T2="1.7.7",Yf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Yf[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const _2={};Yf.transitional=function(e,t,r){function n(i,o){return"[Axios v"+T2+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,s)=>{if(e===!1)throw new xe(n(o," has been removed"+(t?" in "+t:"")),xe.ERR_DEPRECATED);return t&&!_2[o]&&(_2[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,s):!0}};function pO(e,t,r){if(typeof e!="object")throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const a=e[o],u=a===void 0||s(a,o,e);if(u!==!0)throw new xe("option "+o+" must be "+u,xe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new xe("Unknown option "+o,xe.ERR_BAD_OPTION)}}const Zf={assertOptions:pO,validators:Yf},qi=Zf.validators;class ks{constructor(t){this.defaults=t,this.interceptors={request:new o2,response:new o2}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
39
+ `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=_s(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&Zf.assertOptions(n,{silentJSONParsing:qi.transitional(qi.boolean),forcedJSONParsing:qi.transitional(qi.boolean),clarifyTimeoutError:qi.transitional(qi.boolean)},!1),i!=null&&(M.isFunction(i)?r.paramsSerializer={serialize:i}:Zf.assertOptions(i,{encode:qi.function,serialize:qi.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&M.merge(o.common,o[r.method]);o&&M.forEach(["delete","get","head","post","put","patch","common"],E=>{delete o[E]}),r.headers=br.concat(s,o);const a=[];let u=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(u=u&&E.synchronous,a.unshift(E.fulfilled,E.rejected))});const f=[];this.interceptors.response.forEach(function(E){f.push(E.fulfilled,E.rejected)});let h,d=0,g;if(!u){const E=[S2.bind(this),void 0];for(E.unshift.apply(E,a),E.push.apply(E,f),g=E.length,h=Promise.resolve(r);d<g;)h=h.then(E[d++],E[d++]);return h}g=a.length;let v=r;for(d=0;d<g;){const E=a[d++],T=a[d++];try{v=E(v)}catch(x){T.call(this,x);break}}try{h=S2.call(this,v)}catch(E){return Promise.reject(E)}for(d=0,g=f.length;d<g;)h=h.then(f[d++],f[d++]);return h}getUri(t){t=_s(this.defaults,t);const r=p2(t.baseURL,t.url);return s2(r,t.params,t.paramsSerializer)}}M.forEach(["delete","get","head","options"],function(e){ks.prototype[e]=function(t,r){return this.request(_s(r||{},{method:e,url:t,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(e){function t(r){return function(n,i,o){return this.request(_s(o||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:i}))}}ks.prototype[e]=t(),ks.prototype[e+"Form"]=t(!0)});class Qf{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(i,o,s){n.reason||(n.reason=new ho(i,o,s),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Qf(function(r){t=r}),cancel:t}}}function yO(e){return function(t){return e.apply(null,t)}}function gO(e){return M.isObject(e)&&e.isAxiosError===!0}const ed={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ed).forEach(([e,t])=>{ed[t]=e});function k2(e){const t=new ks(e),r=Fw(ks.prototype.request,t);return M.extend(r,ks.prototype,t,{allOwnKeys:!0}),M.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return k2(_s(e,n))},r}const Je=k2(va);Je.Axios=ks,Je.CanceledError=ho,Je.CancelToken=Qf,Je.isCancel=l2,Je.VERSION=T2,Je.toFormData=Nu,Je.AxiosError=xe,Je.Cancel=Je.CanceledError,Je.all=function(e){return Promise.all(e)},Je.spread=yO,Je.isAxiosError=gO,Je.mergeConfig=_s,Je.AxiosHeaders=br,Je.formToJSON=e=>c2(M.isHTMLForm(e)?new FormData(e):e),Je.getAdapter=A2.getAdapter,Je.HttpStatusCode=ed,Je.default=Je;var P2={},fo={};fo.byteLength=mO,fo.toByteArray=EO,fo.fromByteArray=TO;for(var Dn=[],Wr=[],wO=typeof Uint8Array<"u"?Uint8Array:Array,td="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",po=0,bO=td.length;po<bO;++po)Dn[po]=td[po],Wr[td.charCodeAt(po)]=po;Wr[45]=62,Wr[95]=63;function I2(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function mO(e){var t=I2(e),r=t[0],n=t[1];return(r+n)*3/4-n}function vO(e,t,r){return(t+r)*3/4-r}function EO(e){var t,r=I2(e),n=r[0],i=r[1],o=new wO(vO(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Wr[e.charCodeAt(u)]<<18|Wr[e.charCodeAt(u+1)]<<12|Wr[e.charCodeAt(u+2)]<<6|Wr[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=Wr[e.charCodeAt(u)]<<2|Wr[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=Wr[e.charCodeAt(u)]<<10|Wr[e.charCodeAt(u+1)]<<4|Wr[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function AO(e){return Dn[e>>18&63]+Dn[e>>12&63]+Dn[e>>6&63]+Dn[e&63]}function SO(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(AO(n));return i.join("")}function TO(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(SO(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Dn[t>>2]+Dn[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Dn[t>>10]+Dn[t>>4&63]+Dn[t<<2&63]+"=")),i.join("")}var rd={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */rd.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,f=u>>1,h=-7,d=r?i-1:0,g=r?-1:1,v=e[t+d];for(d+=g,o=v&(1<<-h)-1,v>>=-h,h+=a;h>0;o=o*256+e[t+d],d+=g,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=s*256+e[t+d],d+=g,h-=8);if(o===0)o=1-f;else{if(o===u)return s?NaN:(v?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(v?-1:1)*s*Math.pow(2,o-n)},rd.write=function(e,t,r,n,i,o){var s,a,u,f=o*8-i-1,h=(1<<f)-1,d=h>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:o-1,E=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+d>=1?t+=g/u:t+=g*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=h?(a=0,s=h):s+d>=1?(a=(t*u-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+v]=a&255,v+=E,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+v]=s&255,v+=E,s/=256,f-=8);e[r+v-E]|=T*128};/*!
40
40
  * The buffer module from node.js, for the browser.
41
41
  *
42
42
  * @author Feross Aboukhadijeh <https://feross.org>
43
43
  * @license MIT
44
- */(function(e){const t=go,r=sd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(k2);const kI="https://mempool.space",PI="https://mempool.space/testnet",OI="https://mempool.space/testnet4",II="https://mempool.space/signet",xI="https://mempool.fractalbitcoin.io",$I="https://mempool-testnet.fractalbitcoin.io",pi=e=>e===Bt?PI:e===xr?OI:e===Ir?II:e===fo?xI:e===$r?$I:kI;var pt={},od={};const CI={},NI=Object.freeze(Object.defineProperty({__proto__:null,default:CI},Symbol.toStringTag,{value:"Module"})),O2=xT(NI);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=O2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(od);var ad={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.isBytes=x2,Wr.number=Mu,Wr.bool=I2,Wr.bytes=cd,Wr.hash=$2,Wr.exists=C2,Wr.output=N2;function Mu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function I2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function x2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function cd(e,...t){if(!x2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function $2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mu(e.outputLen),Mu(e.blockLen)}function C2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function N2(e,t){cd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const UI={number:Mu,bool:I2,bytes:cd,hash:$2,exists:C2,output:N2};Wr.default=UI;var ka={},Fu={};Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.crypto=void 0,Fu.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Fu,r=Wr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(ka),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Wr,r=ka;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(ad);var Fn={},Yi={};Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.HashMD=Yi.Maj=Yi.Chi=void 0;const ud=Wr,Pa=ka;function RI(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const BI=(e,t,r)=>e&t^~e&r;Yi.Chi=BI;const HI=(e,t,r)=>e&t^e&r^t&r;Yi.Maj=HI;class LI extends Pa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=(0,Pa.createView)(this.buffer)}update(t){(0,ud.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Pa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Pa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,ud.exists)(this),(0,ud.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;RI(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Pa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Yi.HashMD=LI,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.sha224=Fn.sha256=Fn.SHA256=void 0;const ld=Yi,qr=ka,KI=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]),Zi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qi=new Uint32Array(64);class hd extends ld.HashMD{constructor(){super(64,32,8,!1),this.A=Zi[0]|0,this.B=Zi[1]|0,this.C=Zi[2]|0,this.D=Zi[3]|0,this.E=Zi[4]|0,this.F=Zi[5]|0,this.G=Zi[6]|0,this.H=Zi[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Qi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Qi[d-15],v=Qi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Qi[d]=T+Qi[d-7]+E+Qi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=h+g+(0,ld.Chi)(a,u,f)+KI[d]+Qi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ld.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Qi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Fn.SHA256=hd;class jI extends hd{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}}Fn.sha256=(0,qr.wrapConstructor)(()=>new hd),Fn.sha224=(0,qr.wrapConstructor)(()=>new jI);var DI=od,MI=ad,U2=Fn;function FI(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=FI(DI);const es="Expected Private",ts="Expected Point",Oa="Expected Tweak",VI="Expected Hash",Vu="Expected Signature",fd="Expected Extra Data (32 bytes)",Ia="Expected Scalar",zI="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>MI.hmac(U2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>U2.sha256(Be.utils.concatBytes(...e));const dd=Be.utils._normalizePrivateKey,WI=32,qI=32,pd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),GI=32,XI=new Uint8Array(32),JI=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function YI(e){return e instanceof Uint8Array}function xa(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function R2(e){return xa(e,XI)===0}function $a(e){return!(!(e instanceof Uint8Array)||e.length!==qI||xa(e,pd)>=0)}function yd(e){return e instanceof Uint8Array&&e.length===64&&xa(e.subarray(0,32),pd)<0&&xa(e.subarray(32,64),pd)<0}function ZI(e){return YI(e)&&e.length===64&&xa(e.subarray(0,32),JI)<0}function QI(e){return!(R2(e.subarray(0,32))||R2(e.subarray(32,64)))}function bo(e){return e instanceof Uint8Array&&e.length===WI}function gd(e){return e===void 0||e instanceof Uint8Array&&e.length===GI}function B2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function ex(e){return B2(Be.utils.bytesToHex(e))}function wd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=B2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=ex(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const tx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},nx=e=>{const t=dd(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=wd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},ix=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function mo(e,t){return e===void 0?t!==void 0?L2(t):!0:!!e}function Is(e){try{return e()}catch{return null}}function bd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function rs(e){return bd(e,!1)}function L2(e){return bd(e,!1)&&e.length===33}function yi(e){return Be.utils.isValidPrivateKey(e)}function zu(e){return bd(e,!0)}function sx(e,t){if(!zu(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function K2(e){if(!rs(e))throw new Error(ts);return e.slice(1,33)}function j2(e,t){if(!yi(e))throw new Error(es);return Is(()=>Be.getPublicKey(e,mo(t)))}function ox(e){if(!yi(e))throw new Error(es);return K2(j2(e))}function ax(e,t){if(!rs(e))throw new Error(ts);return Be.Point.fromHex(e).toRawBytes(mo(t,e))}function cx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>ix(e,t,mo(r,e)))}function ux(e,t,r){if(!rs(e)||!rs(t))throw new Error(ts);return Is(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(mo(r,e))})}function lx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>H2(e,t,mo(r,e)))}function hx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>tx(e,t))}function fx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>rx(e,t))}function dx(e){if(yi(e)===!1)throw new Error(es);return nx(e)}function px(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function yx(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function gx(e,t,r=Buffer.alloc(32,0)){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.schnorr.signSync(e,t,r)}function wx(e,t,r,n){if(!bo(e))throw new Error(VI);if(!yd(t)||!QI(t))throw new Error(Vu);if(r&2&&!ZI(t))throw new Error(zI);if(!zu(t.subarray(0,32)))throw new Error(Vu);return Be.recoverPublicKey(e,t,r,mo(n))}function bx(e,t,r,n){if(!rs(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.verify(r,e,t,{strict:n})}function mx(e,t,r){if(!zu(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.schnorr.verifySync(r,e,t)}var vx=pt.isPoint=rs,Ex=pt.isPointCompressed=L2,Ax=pt.isPrivate=yi,Sx=pt.isXOnlyPoint=zu,Tx=pt.pointAdd=ux,_x=pt.pointAddScalar=lx,kx=pt.pointCompress=ax,Px=pt.pointFromScalar=j2,Ox=pt.pointMultiply=cx,Ix=pt.privateAdd=hx,xx=pt.privateNegate=dx,$x=pt.privateSub=fx,Cx=pt.recover=wx,Nx=pt.sign=px,Ux=pt.signRecoverable=yx,Rx=pt.signSchnorr=gx,Bx=pt.verify=bx,Hx=pt.verifySchnorr=mx,Lx=pt.xOnlyPointAddTweak=sx,Kx=pt.xOnlyPointFromPoint=K2,jx=pt.xOnlyPointFromScalar=ox;RT(T5({__proto__:null,default:pt,isPoint:vx,isPointCompressed:Ex,isPrivate:Ax,isXOnlyPoint:Sx,pointAdd:Tx,pointAddScalar:_x,pointCompress:kx,pointFromScalar:Px,pointMultiply:Ox,privateAdd:Ix,privateNegate:xx,privateSub:$x,recover:Cx,sign:Nx,signRecoverable:Ux,signSchnorr:Rx,verify:Bx,verifySchnorr:Hx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Kx,xOnlyPointFromScalar:jx},[pt]));const nr=e=>e===Bt||e===xr||e===Ir?I5:wn,md=e=>e.find(({purpose:t})=>t==="ordinals"),vd=e=>e.find(({purpose:t})=>t==="payment"),Xt=async(e,t)=>{try{const r=await D2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},Dx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Mx=e=>/^[a-fA-F0-9]+$/.test(e);function Fx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function D2(e,t){if(e.startsWith("t")){if(t===vt)return[];if(t===fo)return[];if(t===$r)return[]}return await Xe.get(`${pi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function M2(e,t,r,n,i,o,s=7){const a=e===t,u=await D2(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new dt({network:nr(o)}),d=Fx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=M1(t,nr(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=Vx(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function Vx(e,t){var r;const n=fa({pubkey:k2.Buffer.from(e,"hex"),network:nr(t)}),i=ao({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class zx extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{if(t.provider!==ji){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(ji):this.parent.disconnect())}handleNetworkChanged(t){const r=Ea(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(ji)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",ji),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),Xt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Ea(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=dt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Df(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function qx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[ji]:!1,[ii]:!1,[ms]:!1,[si]:!1,[Fi]:!1,[Es]:!1,[vs]:!1,[Di]:!1,[As]:!1,[Mi]:!1}}),$network:ef(vt),$library:ef(void 0)}}function Gx({network:e}){return{network:e}}function Xx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Wu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Wu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Xx(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Jx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function F2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function V2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:xs,expects:r.map(Wu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function yt(e,t){return{kind:"schema",type:"literal",reference:yt,expects:Wu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function W2(e,t){return{kind:"schema",type:"loose_object",reference:W2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Jx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function Ed(e,t){return{kind:"schema",type:"non_optional",reference:Ed,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function $s(e){return{kind:"schema",type:"null",reference:$s,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function Cs(e,...t){const r={kind:"schema",type:"nullish",reference:Cs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=F2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Vn(e){return{kind:"schema",type:"number",reference:Vn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function _n(e,...t){const r={kind:"schema",type:"optional",reference:_n,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=F2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function q2(e,t){return{kind:"schema",type:"picklist",reference:q2,expects:e.map(Wu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function be(e){return{kind:"schema",type:"string",reference:be,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function Ad(e){return{kind:"schema",type:"undefined",reference:Ad,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function G2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function qu(e,t){return{kind:"schema",type:"union",reference:qu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:G2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:G2(s)})}return r}}}function Gu(){return{kind:"schema",type:"unknown",reference:Gu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},vo={},ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.decode=ir.encode=ir.unescape=ir.escape=ir.pad=void 0;const X2=go;function Sd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}ir.pad=Sd;function J2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}ir.escape=J2;function Y2(e){return Sd(e).replace(/-/g,"+").replace(/_/g,"/")}ir.unescape=Y2;function Yx(e){return J2((0,X2.fromByteArray)(new TextEncoder().encode(e)))}ir.encode=Yx;function Zx(e){return new TextDecoder().decode((0,X2.toByteArray)(Sd(Y2(e))))}ir.decode=Zx;var Xu={},Ju={},Eo={};Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.joseToDer=Eo.derToJose=void 0;const Z2=go,Q2=ir;function Td(e){return(e/8|0)+(e%8===0?0:1)}const Qx={ES256:Td(256),ES384:Td(384),ES512:Td(521)};function eb(e){const t=Qx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Yu=128,tb=0,e$=32,t$=16,r$=2,rb=t$|e$|tb<<6,Zu=r$|tb<<6;function nb(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Z2.toByteArray)((0,Q2.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function n$(e,t){const r=nb(e),n=eb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==rb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Yu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Zu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Zu)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Q2.escape)((0,Z2.fromByteArray)(E))}Eo.derToJose=n$;function ib(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Yu&&--n,n}function i$(e,t){e=nb(e);const r=eb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=ib(e,0,r),o=ib(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Yu,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=rb,f?h[d++]=u:(h[d++]=Yu|1,h[d++]=u&255),h[d++]=Zu,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Zu,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Eo.joseToDer=i$;var gi={};Object.defineProperty(gi,"__esModule",{value:!0}),gi.InvalidTokenError=gi.MissingParametersError=void 0;class s$ extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}gi.MissingParametersError=s$;class o$ extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}gi.InvalidTokenError=o$,Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.SECP256K1Client=void 0;const a$=ad,c$=Fn,Qu=od,sb=Eo,ob=gi,ab=ka;Qu.utils.hmacSha256Sync=(e,...t)=>{const r=a$.hmac.create(c$.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class cb{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,ab.bytesToHex)(Qu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ob.MissingParametersError("a signing input hash and private key are all required");const i=Qu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,ab.bytesToHex)(i);if(n==="jose")return(0,sb.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,sb.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ob.MissingParametersError("a signing input hash, der signature, and public key are all required");return Qu.verify(r,t,n,{strict:!1})}}Ju.SECP256K1Client=cb,cb.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Ju;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Xu);var Ns={},u$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.hashSha256Async=Ns.hashSha256=void 0;const l$=Fn;function ub(e){return(0,l$.sha256)(e)}Ns.hashSha256=ub;function h$(e){return u$(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=O2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(ub(e))}})}Ns.hashSha256Async=h$;var f$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(vo,"__esModule",{value:!0}),vo.TokenSigner=vo.createUnsecuredToken=void 0;const _d=ir,lb=Xu,d$=gi,hb=Ns;function kd(e,t){const r=[],n=_d.encode(JSON.stringify(t));r.push(n);const i=_d.encode(JSON.stringify(e));return r.push(i),r.join(".")}function p$(e){return kd(e,{typ:"JWT",alg:"none"})+"."}vo.createUnsecuredToken=p$;class y${constructor(t,r){if(!(t&&r))throw new d$.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!lb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=lb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=kd(t,i),s=(0,hb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return f$(this,void 0,void 0,function*(){const i=this.header(n),o=kd(t,i),s=yield(0,hb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[_d.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}vo.TokenSigner=y$;var el={};Object.defineProperty(el,"__esModule",{value:!0}),el.TokenVerifier=void 0;const g$=ir,fb=Xu,w$=gi,tl=Ns;class b${constructor(t,r){if(!(t&&r))throw new w$.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!fb.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=fb.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,tl.hashSha256Async)(i).then(s=>o(s));{const s=(0,tl.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),g$.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,tl.hashSha256Async)(n).then(s=>o(s));{const s=(0,tl.hashSha256)(n);return o(s)}}}el.TokenVerifier=b$;var rl={};Object.defineProperty(rl,"__esModule",{value:!0}),rl.decodeToken=void 0;const nl=ir;function m$(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(nl.decode(t[0])),n=JSON.parse(nl.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=nl.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(nl.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}rl.decodeToken=m$,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(vo,e),r(el,e),r(rl,e),r(gi,e),r(Xu,e)}(Gr);/*! *****************************************************************************
44
+ */(function(e){const t=fo,r=rd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=O,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(We(c,ArrayBuffer)||c&&We(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(We(c,SharedArrayBuffer)||c&&We(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(We(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||or(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function O(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),We(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,I=Math.min(p,m);S<I;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let I=c[p];if(We(I,Uint8Array))S+I.length>m.length?(a.isBuffer(I)||(I=a.from(I)),I.copy(m,S)):Uint8Array.prototype.set.call(m,I,S);else if(a.isBuffer(I))I.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=I.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||We(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ht(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return _n(c).length;default:if(S)return m?-1:Ht(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return vt(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function z(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)z(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)z(this,l,l+3),z(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)z(this,l,l+7),z(this,l+1,l+6),z(this,l+2,l+5),z(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(We(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let I=S-m,U=p-l;const ce=Math.min(I,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){I=ke[ae],U=le[ae];break}return I<U?-1:U<I?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,or(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let I=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;I=2,U/=2,ce/=2,p/=2}function ke(ae,me){return I===1?ae[me]:ae.readUInt16BE(me*I)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*I}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function He(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const I=l.length;m>I/2&&(m=I/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(or(ce))return U;c[p+U]=ce}return U}function Ge(c,l,p,m){return Mt(Ht(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(_n(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let I=!1;for(;;)switch(m){case"hex":return He(this,c,l,p);case"utf8":case"utf-8":return Ge(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),I=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const I=c[S];let U=null,ce=I>239?4:I>223?3:I>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:I<128&&(U=I);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(I&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(I&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(I&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function vt(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let I=l;I<p;++I)S+=yi[c[I]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let I=0;I<m.length-1;I+=2)S+=String.fromCharCode(m[I]+m[I+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,I=0;for(;++I<l&&(S*=256);)m+=this[c+I]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,I=this[c+--m];for(;m>0&&(S*=256);)I+=this[c+--m]*S;return S*=128,I>=S&&(I-=Math.pow(2,8*l)),I},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&yt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,I){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<I)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,I=0;for(this[l]=c&255;++I<p&&(S*=256);)this[l+I]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,I=1;for(this[l+S]=c&255;--S>=0&&(I*=256);)this[l+S]=c/I&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function H(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I,I=I>>8,c[p++]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function Le(c,l,p,m,S){Er(l,m,S,c,p,7);let I=Number(l&BigInt(4294967295));c[p+7]=I,I=I>>8,c[p+6]=I,I=I>>8,c[p+5]=I,I=I>>8,c[p+4]=I;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return H(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return Le(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,I=1,U=0;for(this[l]=c&255;++S<p&&(I*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,I=1,U=0;for(this[l+S]=c&255;--S>=0&&(I*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/I>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return H(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return Le(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tn(c,l,p,m,S,I){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function pt(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return pt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return pt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Tn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const I=c.charCodeAt(0);(m==="utf8"&&I<128||m==="latin1")&&(c=I)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const I=a.isBuffer(c)?c:a.from(c,m),U=I.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=I[S%U]}return this};const Et={};function Lt(c,l,p){Et[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Lt("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Lt("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Lt("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&yt(l,c.length-(p+1))}function Er(c,l,p,m,S,I){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(I+1)*8}${U}`:ce=`>= -(2${U} ** ${(I+1)*8-1}${U}) and < 2 ** ${(I+1)*8-1}${U}`,new Et.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,I)}function Ve(c,l){if(typeof c!="number")throw new Et.ERR_INVALID_ARG_TYPE(l,"number",c)}function yt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new Et.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new Et.ERR_BUFFER_OUT_OF_BOUNDS:new Et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Ht(c,l){l=l||1/0;let p;const m=c.length;let S=null;const I=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&I.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&I.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&I.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&I.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;I.push(p)}else if(p<2048){if((l-=2)<0)break;I.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;I.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;I.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return I}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const I=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,I.push(S),I.push(m);return I}function _n(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function We(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function or(c){return c!==c}const yi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(P2);const _O="https://mempool.space",kO="https://mempool.space/testnet",PO="https://mempool.space/testnet4",IO="https://mempool.space/signet",OO="https://mempool.fractalbitcoin.io",xO="https://mempool-testnet.fractalbitcoin.io",Gi=e=>e===Bt?kO:e===xr?PO:e===Or?IO:e===uo?OO:e===$r?xO:_O;var ft={},nd={};const $O={},CO=Object.freeze(Object.defineProperty({__proto__:null,default:$O},Symbol.toStringTag,{value:"Module"})),O2=OT(CO);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=O2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,L=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let W=H(b-K*w-q*_,y),X=H(-K*A-q*$,y);const Z=W>L,te=X>L;if(Z&&(W=y-W),te&&(X=y-X),W>L||X>L)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:W,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=H(b*b),_=H(A*b);return H(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function O(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y,q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q);return X===Z&&te===P}negate(){return new k(this.x,H(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=H(y*y),$=H(w*w),L=H($*$),K=y+$,q=H(i*(H(K*K)-_-L)),W=H(o*_),X=H(W*W),Z=H(X-i*q),te=H(W*(q-Z)-s*L),P=H(i*w*A);return new k(Z,te,P)}add(y){O(y);const{x:w,y:A,z:_}=this,{x:$,y:L,z:K}=y;if($===r||L===r)return this;if(w===r||A===r)return y;const q=H(_*_),W=H(K*K),X=H(w*W),Z=H($*q),te=H(H(A*K)*W),P=H(H(L*_)*q),j=H(Z-X),G=H(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=H(j*j),_e=H(j*ne),$e=H(X*ne),Pe=H(G*G-_e-i*$e),Ie=H(G*($e-Pe)-te*_e),Ze=H(_*K*j);return new k(Pe,Ie,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:L,k2:K}=f.splitScalar(A),q=w,W=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(W=W.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),L&&(W=W.negate()),W=new k(H(W.x*f.beta),W.y,W.z),q.add(W)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let L=0;L<w;L++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&z.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),z.set(w,_)));let $=k.ZERO,L=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),W=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&W);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?L=L.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:L}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:L,k1:K,k2neg:q,k2:W}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(W,w);X=B(L,X),te=B(q,te),te=new k(H(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:L,f:K}=this.wNAF(A,w);_=L,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:pt(_));const L=y,K=H(L*L),q=H(K*L),W=H(w*K),X=H(A*q),Z=H(_*L);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(W,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const z=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,z.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!yt(A))throw new Error("Point is not on curve");const _=T(A);let $=Tn(_);const L=($&n)===n;w?L&&($=H(-$)):(y[0]&1)===1!==L&&($=H(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const L=Lt(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,W=pt(q,K),X=H(-L*W,K),Z=H($*W,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!yt(w)||!yt(A))throw new Error(y);const _=H(A*A),$=T(w);if(H(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,H(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),L=k.fromAffine(y).multiplyUnsafe(A),K=$.add(L);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function He(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Ge(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=He(b.subarray(2)),{data:A,left:_}=He(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(vt(_.slice(0,64)),vt(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Ge(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,H(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),L=Ae(_);return`30${Ae(_+A+4)}02${L}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function vt(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return vt(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function H(b,y=a.P){const w=b%y;return w>=r?w:y+w}function Le(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Tn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),L=BigInt(44),K=BigInt(88),q=b*b*b%y,W=q*q*b%y,X=Le(W,o)*W%y,Z=Le(X,o)*W%y,te=Le(Z,i)*q%y,P=Le(te,A)*te%y,j=Le(P,_)*P%y,G=Le(j,L)*j%y,ne=Le(G,K)*G%y,_e=Le(ne,L)*j%y,$e=Le(_e,o)*W%y,Pe=Le($e,$)*P%y,Ie=Le(Pe,w)*q%y,Ze=Le(Ie,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function pt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=H(b,y),A=y,_=r,$=n;for(;w!==r;){const L=A/w,K=A%w,q=_-$*L;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return H(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,L,K)=>L===r?$:(w[K]=$,H($*L,y)),n),_=pt(A,y);return b.reduceRight(($,L,K)=>L===r?$:(w[K]=H($*w[K],y),H($*L,y)),_),w}function Et(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Lt(b,y=!1){const w=Et(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function yt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Lt(b,!0);if(!Ve($))return;const L=pt($,_),K=V.BASE.multiply($),q=H(K.x,_);if(q===r)return;const W=H(L*H(y+w*q,_),_);if(W===r)return;let X=new Fe(q,W),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=vt(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Ht(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function _n(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=_n;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function We(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Ht(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=We;function or(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function yi(b){const y=or(b),w=H(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),yi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const L=Ye(...$),K=or(A);return{seed:L,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),L=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[L,A]:L}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);await L.reseed(A);let K;for(;!(K=Ar(await L.generate(),_,$,w.canonical));)await L.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),L=new Er(g,d);L.reseedSync(A);let K;for(;!(K=Ar(L.generateSync(),_,$,w.canonical));)L.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:L}=_;if(A.strict&&_.hasHighS())return!1;const K=Lt(y);let q;try{q=Ht(w)}catch{return!1}const{n:W}=a,X=pt(L,W),Z=H(K*X,W),te=H($*X,W),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?H(P.x,W)===$:!1}e.verify=S;function I(b){return H(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!yt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=H(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,H(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,L=this.initNonce(w,await $(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce(await $(kt.nonce,L,A,y)),X=I(await $(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return await rs(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,L=this.initNonce(w,$(kt.aux,_)),{R:K,rx:q,k:W}=this.finalizeNonce($(kt.nonce,L,A,y)),X=I($(kt.challenge,q,A,y)),Z=this.finalizeSig(K,W,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Ht(w)}}function gi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),H(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function rs(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(await e.utils.taggedHash(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:L}=me(b,y,w),K=I(e.utils.taggedHashSync(kt.challenge,ue(A),L.toRawX(),$));return gi(A,L,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:rs,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},kt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:H,invert:pt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=H(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(nd);var id={},zr={};Object.defineProperty(zr,"__esModule",{value:!0}),zr.isBytes=$2,zr.number=Hu,zr.bool=x2,zr.bytes=sd,zr.hash=C2,zr.exists=N2,zr.output=U2;function Hu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function x2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function $2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function sd(e,...t){if(!$2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function C2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Hu(e.outputLen),Hu(e.blockLen)}function N2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function U2(e,t){sd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const NO={number:Hu,bool:x2,bytes:sd,hash:C2,exists:N2,output:U2};zr.default=NO;var Aa={},Ku={};Object.defineProperty(Ku,"__esModule",{value:!0}),Ku.crypto=void 0,Ku.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=O,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=He,e.wrapConstructorWithOpts=Ge,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Ku,r=zr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const vt=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(vt===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=vt*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function O(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=O(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class z{clone(){return this._cloneInto()}}e.Hash=z;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function He(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Ge(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Aa),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=zr,r=Aa;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(id);var Mn={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.HashMD=Xi.Maj=Xi.Chi=void 0;const od=zr,Sa=Aa;function UO(e,t,r,n){if(typeof e.setBigUint64=="function")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,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const RO=(e,t,r)=>e&t^~e&r;Xi.Chi=RO;const BO=(e,t,r)=>e&t^e&r^t&r;Xi.Maj=BO;class LO extends Sa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=(0,Sa.createView)(this.buffer)}update(t){(0,od.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Sa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Sa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,od.exists)(this),(0,od.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;UO(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Sa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Xi.HashMD=LO,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.sha224=Mn.sha256=Mn.SHA256=void 0;const ad=Xi,qr=Aa,HO=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]),Ji=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yi=new Uint32Array(64);class cd extends ad.HashMD{constructor(){super(64,32,8,!1),this.A=Ji[0]|0,this.B=Ji[1]|0,this.C=Ji[2]|0,this.D=Ji[3]|0,this.E=Ji[4]|0,this.F=Ji[5]|0,this.G=Ji[6]|0,this.H=Ji[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Yi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Yi[d-15],v=Yi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Yi[d]=T+Yi[d-7]+E+Yi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=h+g+(0,ad.Chi)(a,u,f)+HO[d]+Yi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ad.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Yi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Mn.SHA256=cd;class KO extends cd{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}}Mn.sha256=(0,qr.wrapConstructor)(()=>new cd),Mn.sha224=(0,qr.wrapConstructor)(()=>new KO);var jO=nd,DO=id,R2=Mn;function MO(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=MO(jO);const Zi="Expected Private",Qi="Expected Point",Ta="Expected Tweak",FO="Expected Hash",ju="Expected Signature",ud="Expected Extra Data (32 bytes)",_a="Expected Scalar",VO="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>DO.hmac(R2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>R2.sha256(Be.utils.concatBytes(...e));const ld=Be.utils._normalizePrivateKey,WO=32,zO=32,hd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),qO=32,GO=new Uint8Array(32),XO=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function JO(e){return e instanceof Uint8Array}function ka(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function B2(e){return ka(e,GO)===0}function Pa(e){return!(!(e instanceof Uint8Array)||e.length!==zO||ka(e,hd)>=0)}function fd(e){return e instanceof Uint8Array&&e.length===64&&ka(e.subarray(0,32),hd)<0&&ka(e.subarray(32,64),hd)<0}function YO(e){return JO(e)&&e.length===64&&ka(e.subarray(0,32),XO)<0}function ZO(e){return!(B2(e.subarray(0,32))||B2(e.subarray(32,64)))}function yo(e){return e instanceof Uint8Array&&e.length===WO}function dd(e){return e===void 0||e instanceof Uint8Array&&e.length===qO}function L2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function QO(e){return L2(Be.utils.bytesToHex(e))}function pd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=L2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=QO(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const ex=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},tx=(e,t)=>{const r=ld(e),n=pd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=e=>{const t=ld(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=pd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},nx=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function go(e,t){return e===void 0?t!==void 0?K2(t):!0:!!e}function Ps(e){try{return e()}catch{return null}}function yd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function es(e){return yd(e,!1)}function K2(e){return yd(e,!1)&&e.length===33}function di(e){return Be.utils.isValidPrivateKey(e)}function Du(e){return yd(e,!0)}function ix(e,t){if(!Du(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function j2(e){if(!es(e))throw new Error(Qi);return e.slice(1,33)}function D2(e,t){if(!di(e))throw new Error(Zi);return Ps(()=>Be.getPublicKey(e,go(t)))}function sx(e){if(!di(e))throw new Error(Zi);return j2(D2(e))}function ox(e,t){if(!es(e))throw new Error(Qi);return Be.Point.fromHex(e).toRawBytes(go(t,e))}function ax(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>nx(e,t,go(r,e)))}function cx(e,t,r){if(!es(e)||!es(t))throw new Error(Qi);return Ps(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(go(r,e))})}function ux(e,t,r){if(!es(e))throw new Error(Qi);if(!Pa(t))throw new Error(Ta);return Ps(()=>H2(e,t,go(r,e)))}function lx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>ex(e,t))}function hx(e,t){if(di(e)===!1)throw new Error(Zi);if(Pa(t)===!1)throw new Error(Ta);return Ps(()=>tx(e,t))}function fx(e){if(di(e)===!1)throw new Error(Zi);return rx(e)}function dx(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function px(e,t,r){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function yx(e,t,r=Buffer.alloc(32,0)){if(!di(t))throw new Error(Zi);if(!yo(e))throw new Error(_a);if(!dd(r))throw new Error(ud);return Be.schnorr.signSync(e,t,r)}function gx(e,t,r,n){if(!yo(e))throw new Error(FO);if(!fd(t)||!ZO(t))throw new Error(ju);if(r&2&&!YO(t))throw new Error(VO);if(!Du(t.subarray(0,32)))throw new Error(ju);return Be.recoverPublicKey(e,t,r,go(n))}function wx(e,t,r,n){if(!es(t))throw new Error(Qi);if(!fd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.verify(r,e,t,{strict:n})}function bx(e,t,r){if(!Du(t))throw new Error(Qi);if(!fd(r))throw new Error(ju);if(!yo(e))throw new Error(_a);return Be.schnorr.verifySync(r,e,t)}var mx=ft.isPoint=es,vx=ft.isPointCompressed=K2,Ex=ft.isPrivate=di,Ax=ft.isXOnlyPoint=Du,Sx=ft.pointAdd=cx,Tx=ft.pointAddScalar=ux,_x=ft.pointCompress=ox,kx=ft.pointFromScalar=D2,Px=ft.pointMultiply=ax,Ix=ft.privateAdd=lx,Ox=ft.privateNegate=fx,xx=ft.privateSub=hx,$x=ft.recover=gx,Cx=ft.sign=dx,Nx=ft.signRecoverable=px,Ux=ft.signSchnorr=yx,Rx=ft.verify=wx,Bx=ft.verifySchnorr=bx,Lx=ft.xOnlyPointAddTweak=ix,Hx=ft.xOnlyPointFromPoint=j2,Kx=ft.xOnlyPointFromScalar=sx;UT(S5({__proto__:null,default:ft,isPoint:mx,isPointCompressed:vx,isPrivate:Ex,isXOnlyPoint:Ax,pointAdd:Sx,pointAddScalar:Tx,pointCompress:_x,pointFromScalar:kx,pointMultiply:Px,privateAdd:Ix,privateNegate:Ox,privateSub:xx,recover:$x,sign:Cx,signRecoverable:Nx,signSchnorr:Ux,verify:Rx,verifySchnorr:Bx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Hx,xOnlyPointFromScalar:Kx},[ft]));const nr=e=>e===Bt||e===xr||e===Or?I5:pn,gd=e=>e.find(({purpose:t})=>t==="ordinals"),wd=e=>e.find(({purpose:t})=>t==="payment"),ir=async(e,t)=>{try{const r=await M2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},jx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Dx=e=>/^[a-fA-F0-9]+$/.test(e);function Mx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function M2(e,t){if(e.startsWith("t")){if(t===mt)return[];if(t===uo)return[];if(t===$r)return[]}return await Je.get(`${Gi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function F2(e,t,r,n,i,o,s=7){const a=e===t,u=await M2(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new bt({network:nr(o)}),d=Mx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:O}=T,k=M1(t,nr(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(O)}}),!a){const B=Fx(i,o);h.updateInput(E,{redeemScript:B})}if(v+=O,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function Fx(e,t){var r;const n=ua({pubkey:P2.Buffer.from(e,"hex"),network:nr(t)}),i=io({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class Vx extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Hi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Hi){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Hi):this.parent.disconnect())}handleNetworkChanged(t){const r=Hf(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Hi)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Hi),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),ir(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Hf(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=bt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function zx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[Hi]:!1,[ri]:!1,[ws]:!1,[ni]:!1,[Hg]:!1,[ms]:!1,[bs]:!1,[Ki]:!1,[vs]:!1,[ji]:!1}}),$network:Yh(mt),$library:Yh(void 0)}}function qx({network:e}){return{network:e}}function Gx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Mu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Mu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Gx(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Xx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function V2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function W2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function En(e,t){return{kind:"schema",type:"array",reference:En,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function Is(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:Is,expects:r.map(Mu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function dt(e,t){return{kind:"schema",type:"literal",reference:dt,expects:Mu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function q2(e,t){return{kind:"schema",type:"loose_object",reference:q2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Xx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function bd(e,t){return{kind:"schema",type:"non_optional",reference:bd,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function Os(e){return{kind:"schema",type:"null",reference:Os,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,...t){const r={kind:"schema",type:"nullish",reference:xs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=V2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Fn(e){return{kind:"schema",type:"number",reference:Fn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function An(e,...t){const r={kind:"schema",type:"optional",reference:An,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=V2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function G2(e,t){return{kind:"schema",type:"picklist",reference:G2,expects:e.map(Mu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function ge(e){return{kind:"schema",type:"string",reference:ge,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function md(e){return{kind:"schema",type:"undefined",reference:md,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function X2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Fu(e,t){return{kind:"schema",type:"union",reference:Fu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:X2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:X2(s)})}return r}}}function Vu(){return{kind:"schema",type:"unknown",reference:Vu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},wo={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.decode=sr.encode=sr.unescape=sr.escape=sr.pad=void 0;const J2=fo;function vd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}sr.pad=vd;function Y2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}sr.escape=Y2;function Z2(e){return vd(e).replace(/-/g,"+").replace(/_/g,"/")}sr.unescape=Z2;function Jx(e){return Y2((0,J2.fromByteArray)(new TextEncoder().encode(e)))}sr.encode=Jx;function Yx(e){return new TextDecoder().decode((0,J2.toByteArray)(vd(Z2(e))))}sr.decode=Yx;var Wu={},zu={},bo={};Object.defineProperty(bo,"__esModule",{value:!0}),bo.joseToDer=bo.derToJose=void 0;const Q2=fo,eb=sr;function Ed(e){return(e/8|0)+(e%8===0?0:1)}const Zx={ES256:Ed(256),ES384:Ed(384),ES512:Ed(521)};function tb(e){const t=Zx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const qu=128,rb=0,Qx=32,e7=16,t7=2,nb=e7|Qx|rb<<6,Gu=t7|rb<<6;function ib(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Q2.toByteArray)((0,eb.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function r7(e,t){const r=ib(e),n=tb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==nb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(qu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Gu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Gu)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,eb.escape)((0,Q2.fromByteArray)(E))}bo.derToJose=r7;function sb(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=qu&&--n,n}function n7(e,t){e=ib(e);const r=tb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=sb(e,0,r),o=sb(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<qu,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=nb,f?h[d++]=u:(h[d++]=qu|1,h[d++]=u&255),h[d++]=Gu,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Gu,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}bo.joseToDer=n7;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.InvalidTokenError=pi.MissingParametersError=void 0;class i7 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}pi.MissingParametersError=i7;class s7 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}pi.InvalidTokenError=s7,Object.defineProperty(zu,"__esModule",{value:!0}),zu.SECP256K1Client=void 0;const o7=id,a7=Mn,Xu=nd,ob=bo,ab=pi,cb=Aa;Xu.utils.hmacSha256Sync=(e,...t)=>{const r=o7.hmac.create(a7.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class ub{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,cb.bytesToHex)(Xu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ab.MissingParametersError("a signing input hash and private key are all required");const i=Xu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,cb.bytesToHex)(i);if(n==="jose")return(0,ob.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,ob.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ab.MissingParametersError("a signing input hash, der signature, and public key are all required");return Xu.verify(r,t,n,{strict:!1})}}zu.SECP256K1Client=ub,ub.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=zu;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Wu);var $s={},c7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty($s,"__esModule",{value:!0}),$s.hashSha256Async=$s.hashSha256=void 0;const u7=Mn;function lb(e){return(0,u7.sha256)(e)}$s.hashSha256=lb;function l7(e){return c7(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=O2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(lb(e))}})}$s.hashSha256Async=l7;var h7=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(wo,"__esModule",{value:!0}),wo.TokenSigner=wo.createUnsecuredToken=void 0;const Ad=sr,hb=Wu,f7=pi,fb=$s;function Sd(e,t){const r=[],n=Ad.encode(JSON.stringify(t));r.push(n);const i=Ad.encode(JSON.stringify(e));return r.push(i),r.join(".")}function d7(e){return Sd(e,{typ:"JWT",alg:"none"})+"."}wo.createUnsecuredToken=d7;class p7{constructor(t,r){if(!(t&&r))throw new f7.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!hb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=hb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=Sd(t,i),s=(0,fb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return h7(this,void 0,void 0,function*(){const i=this.header(n),o=Sd(t,i),s=yield(0,fb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Ad.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}wo.TokenSigner=p7;var Ju={};Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.TokenVerifier=void 0;const y7=sr,db=Wu,g7=pi,Yu=$s;class w7{constructor(t,r){if(!(t&&r))throw new g7.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!db.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=db.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Yu.hashSha256Async)(i).then(s=>o(s));{const s=(0,Yu.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),y7.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Yu.hashSha256Async)(n).then(s=>o(s));{const s=(0,Yu.hashSha256)(n);return o(s)}}}Ju.TokenVerifier=w7;var Zu={};Object.defineProperty(Zu,"__esModule",{value:!0}),Zu.decodeToken=void 0;const Qu=sr;function b7(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Qu.decode(t[0])),n=JSON.parse(Qu.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Qu.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Qu.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Zu.decodeToken=b7,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(wo,e),r(Ju,e),r(Zu,e),r(pi,e),r(Wu,e)}(Gr);/*! *****************************************************************************
45
45
  Copyright (c) Microsoft Corporation.
46
46
 
47
47
  Permission to use, copy, modify, and/or distribute this software for any
@@ -54,7 +54,7 @@ PROCEED WITH CAUTION!
54
54
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55
55
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56
56
  PERFORMANCE OF THIS SOFTWARE.
57
- ***************************************************************************** */var db="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<db.length;++t)e[db.charCodeAt(t)]=t})();var pb,Pd,il,Od=(pb=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,I=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,I.push(T>>x&N);if(E)x>0&&I.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return I}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const I=(E=x).lastIndexOf("1");if(I===-1)return"No separator character for "+E;if(I===0)return"Missing prefix for "+E;const k=E.slice(0,I),B=E.slice(I+1);if(B.length<6)return"Data too short";let W=o(k);if(typeof W=="string")return W;const V=[];for(let Ue=0;Ue<B.length;++Ue){const Le=B.charAt(Ue),Je=n[Le];if(Je===void 0)return"Unknown character "+Le;W=i(W)^Je,Ue+6>=B.length||V.push(Je)}return W!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let I=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,I+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)I+=r.charAt(N>>5*(5-k)&31);return I},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},pb(Pd={exports:{}},Pd.exports),Pd.exports);(il=Od)&&il.__esModule&&Object.prototype.hasOwnProperty.call(il,"default")&&il.default,Od.bech32m,Od.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var Ao,So;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(Ao||(Ao={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(So||(So={})),So.p2pkh,Ao.mainnet,So.p2pkh,Ao.testnet,So.p2sh,Ao.mainnet,So.p2sh,Ao.testnet;var v$="accountChange";fe({type:yt(v$)});var E$="networkChange";fe({type:yt(E$)});var A$="disconnect";fe({type:yt(A$)});async function Id(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var yb=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(yb||{}),xd=_n(qu([be(),Vn(),$s()])),vr=fe({jsonrpc:yt("2.0"),method:be(),params:_n(qu([Tn(Gu()),W2({}),$s()])),id:xd}),sl=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(sl||{}),gb=fe({jsonrpc:yt("2.0"),result:Ed(Gu()),id:xd}),wb=fe({jsonrpc:yt("2.0"),error:Ed(Gu()),id:xd});qu([gb,wb]);var ol=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(ol||{}),bb=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(bb||{}),S$=fe({address:be(),publicKey:be(),purpose:xs(ol),addressType:xs(bb)}),mb=async e=>{var t,r;const n=await Id(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Gr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},T$="stx_getAddresses",_$=Cs(fe({message:_n(be())}));fe({...vr.entries,...fe({method:yt(T$),params:_$,id:be()}).entries});var k$="stx_signTransaction",P$=fe({transaction:be(),pubkey:_n(be()),broadcast:_n(z2())});fe({...vr.entries,...fe({method:yt(k$),params:P$,id:be()}).entries});var O$=["software","ledger"],I$=q2(O$),x$="getInfo",$$=Cs($s());fe({version:be(),methods:_n(Tn(be())),supports:Tn(be())}),fe({...vr.entries,...fe({method:yt(x$),params:$$,id:be()}).entries});var C$="getAddresses",N$=fe({purposes:Tn(xs(ol)),message:_n(be())});fe({...vr.entries,...fe({method:yt(C$),params:N$,id:be()}).entries});var U$="signMessage",al=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(al||{}),R$=fe({address:be(),message:be(),protocol:_n(xs(al))});fe({signature:be(),messageHash:be(),address:be(),protocol:xs(al)}),fe({...vr.entries,...fe({method:yt(U$),params:R$,id:be()}).entries});var B$="getAccounts",H$=fe({purposes:Tn(xs(ol)),message:_n(be())});Tn(fe({...S$.entries,...fe({walletType:I$}).entries})),fe({...vr.entries,...fe({method:yt(B$),params:H$,id:be()}).entries});var L$="getBalance";Cs($s()),fe({...vr.entries,...fe({method:yt(L$),id:be()}).entries});var K$="wallet_requestPermissions",j$=Ad();yt(!0),fe({...vr.entries,...fe({method:yt(K$),params:j$,id:be()}).entries});var D$="wallet_renouncePermissions",M$=Ad();yt(!0),fe({...vr.entries,...fe({method:yt(D$),params:M$,id:be()}).entries});var F$="wallet_getWalletType";Cs($s()),fe({...vr.entries,...fe({method:yt(F$),id:be()}).entries});var V$="runes_getBalance",z$=Cs($s());fe({balances:Tn(fe({runeName:be(),amount:be(),divisibility:Vn(),symbol:be(),inscriptionId:Cs(be())}))}),fe({...vr.entries,...fe({method:yt(V$),params:z$,id:be()}).entries});var W$="runes_transfer",q$=fe({recipients:Tn(fe({runeName:be(),amount:be(),address:be()}))});fe({...vr.entries,...fe({method:yt(W$),params:q$,id:be()}).entries});var G$="ord_getInscriptions",X$=fe({offset:Vn(),limit:Vn()});fe({total:Vn(),limit:Vn(),offset:Vn(),inscriptions:Tn(fe({inscriptionId:be(),inscriptionNumber:be(),address:be(),collectionName:_n(be()),postage:be(),contentLength:be(),contentType:be(),timestamp:Vn(),offset:Vn(),genesisTransaction:be(),output:be()}))}),fe({...vr.entries,...fe({method:yt(G$),params:X$,id:be()}).entries});var J$="ord_sendInscriptions",Y$=fe({transfers:Tn(fe({address:be(),inscriptionId:be()}))});fe({...vr.entries,...fe({method:yt(J$),params:Y$,id:be()}).entries});var vb=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return V2(wb,o)?{status:"error",error:o.error}:V2(gb,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},Z$=async e=>{var t,r;const n=await Id(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Gr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},Q$=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),e7=async e=>{var t,r;const n=await Id(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=Q$(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Gr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let Eb=e=>e,Ca={},ns={addEventListener(){},removeEventListener(){}};function t7(){try{return typeof localStorage<"u"}catch{return!1}}t7()&&(Ca=localStorage),typeof window<"u"&&(ns={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function To(e,t={},r={}){let n=r.encode||Eb,i=r.decode||Eb,o=Lg(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&ns.perKey&&ns.removeEventListener(e+d,f,h),delete Ca[e+d]):(r.listen!==!1&&ns.perKey&&!(d in o.value)&&ns.addEventListener(e+d,f,h),Ca[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in Ca)g.startsWith(e)&&(d[g.slice(e.length)]=i(Ca[g]));for(let g in d)o.setKey(g,d[g])}return O5(o,()=>{if(h(),r.listen!==!1)return ns.addEventListener(e,f,h),()=>{ns.removeEventListener(e,f,h);for(let d in o.value)ns.removeEventListener(e+d,f,h)}}),o}const Ab=["address","paymentAddress","publicKey","paymentPublicKey","balance"],r7="XVERSE_CONNECTED_WALLET_STATE";class n7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(r7,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Ab)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ii&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Ab.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){gn(this.$store,["provider"],t=>{t.provider!==ii?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ii]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),Xt(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=va(this.network||vt);await mb({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=md(o.addresses),a=vd(o.addresses);s&&a&&(this.$store.setKey("provider",ii),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),Xt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ii} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ii} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:vt}getPublicKey(){throw An}async getBalance(){const{paymentAddress:t}=this.$store.get();return await Xt(t,this.network)}getInscriptions(){throw An}async sendBTC(t,r){const n=await vb("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===sl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await vb("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===sl.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=dt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let I of f){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=ga(k,nr(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:va(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:I=>{if(I.txId)E=I.txId;else if(I.psbtBase64){const k=dt.fromBase64(String(I.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw An}}class i7 extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(As)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){gn(this.$store,["provider"],t=>{t.provider===As?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[As]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw NP;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",As),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?Dw(r):void 0}async switchNetwork(t){var r;if(t===$r||t===fo)return await this.library.switchNetwork(Kw);const n=Dw(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=dt.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await Xe.post(`${pi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const Sb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],s7="OYL_CONNECTED_WALLET_STATE";class o7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(s7,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Sb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ms&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Sb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ms]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{t.provider!==ms?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",ms),Xt(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await M2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=dt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw An}}const Tb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],a7="LEATHER_CONNECTED_WALLET_STATE";class c7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(a7,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Tb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===vs&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Tb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{t.provider!==vs?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===tf),a=i.find(u=>u.type===Kg);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==Bt&&this.network!==xr&&this.network!==Ir)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",vs),Xt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===sl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?tf:Kg;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=dt.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=dt.fromHex(t).extractTransaction();return await Xe.post(`${pi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===tf);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await Xt(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw An}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw An}}var $d={},_b={},kn={},kb={};Object.defineProperty(kb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(kb,e)}(kn);var Pb={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(Pb),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Gr,i=kn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(Pb,e)}(_b);var Ob={},Ib={},xb={};Object.defineProperty(xb,"__esModule",{value:!0});var $b={};Object.defineProperty($b,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(xb,e),r($b,e)}(Ib),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=kn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(Ib,e)}(Ob);var Cb={},Nb={};Object.defineProperty(Nb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Te&&Te.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Gr,i=kn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(Nb,e)}(Cb);var Ub={},cl={},Na={};Object.defineProperty(Na,"__esModule",{value:!0}),Na.validateInscriptionPayload=void 0;const u7=4e5,l7=6e4,h7=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?u7:l7))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Na.validateInscriptionPayload=h7,Object.defineProperty(cl,"__esModule",{value:!0}),cl.createInscription=void 0;const f7=Gr,d7=kn,p7=Na,y7=async e=>{var t,r;const{getProvider:n}=e,i=await(0,d7.getProviderOrThrow)(n);(0,p7.validateInscriptionPayload)(e.payload);try{const o=(0,f7.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};cl.createInscription=y7;var ul={};Object.defineProperty(ul,"__esModule",{value:!0}),ul.createRepeatInscriptions=void 0;const g7=kn,w7=Gr,b7=Na,m7=async e=>{var t,r;const{getProvider:n}=e,i=await(0,g7.getProviderOrThrow)(n);(0,b7.validateInscriptionPayload)(e.payload);try{const o=(0,w7.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};ul.createRepeatInscriptions=m7;var Rb={};Object.defineProperty(Rb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(cl,e),r(ul,e),r(Rb,e)}(Ub);var Bb={},Hb={};Object.defineProperty(Hb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Gr,i=kn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Hb,e)}(Bb);var Lb={},ll={};Object.defineProperty(ll,"__esModule",{value:!0}),ll.sendBtcTransaction=void 0;const v7=Gr,E7=kn,A7=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),S7=async e=>{var t,r;const n=await(0,E7.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=A7(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,v7.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};ll.sendBtcTransaction=S7;var hl={};Object.defineProperty(hl,"__esModule",{value:!0}),hl.signTransaction=void 0;const T7=Gr,_7=kn,k7=async e=>{var t,r;const n=await(0,_7.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,T7.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};hl.signTransaction=k7;var fl={};Object.defineProperty(fl,"__esModule",{value:!0}),fl.signMultipleTransactions=void 0;const P7=Gr,O7=kn,I7=async e=>{var t,r;const n=await(0,O7.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,P7.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};fl.signMultipleTransactions=I7;var Kb={};Object.defineProperty(Kb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(ll,e),r(hl,e),r(fl,e),r(Kb,e)}(Lb);var jb={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(jb),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(_b,e),r(Ob,e),r(Cb,e),r(Ub,e),r(Bb,e),r(kn,e),r(Lb,e),r(jb,e)}($d);const x7=IT($d),Db=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:$7,sendBtcTransaction:C7,signTransaction:N7}=x7,U7="ORANGE_CONNECTED_WALLET_STATE";class R7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(U7,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Db)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Mi&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Db.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Mi]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],r=>{r.provider!==Mi?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),Xt(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Cu(this.network||vt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=md(s.addresses),u=vd(s.addresses);a&&u&&(this.$store.setKey("publicKey",String(s.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(s.addresses[1].publicKey)),this.$store.setKey("provider",Mi),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),Xt(u.address,this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${Mi} wallet`)}};await $d.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:vt}getPublicKey(){throw An}async getBalance(){const{paymentAddress:t}=this.$store.get();return await Xt(t,this.network)}getInscriptions(){throw An}async sendBTC(t,r){let n="";const i={payload:{network:{type:Cu(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{console.log(o),n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await C7(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Cu(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await $7(o),n}async signPsbt(t,r,n,i,o){const s=dt.fromBase64(String(n),{network:nr(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let I of f){if(I.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=I.witnessUtxo,B=ga(k,nr(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Cu(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:I=>{if(console.log(I),I.txId)E=I.txId;else if(I.psbtBase64){const k=dt.fromBase64(String(I.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await N7(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=dt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Xe.post(`${pi(this.network)}/api/tx`,r).then(n=>n.data)}}const Mb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],B7="OKX_CONNECTED_WALLET_STATE";class H7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(B7,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===Bt||this.network===xr||this.network===Ir||this.network===$r?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===vt||this.network===fo)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Mb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===Es&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Mb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Es]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],r=>{r.provider!==Es?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",Es),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===Bt||r===xr||r===$r?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===Bt?Bt:r===xr?xr:r===Ir?Ir:r===$r?$r:Bt;const n=await this.library.getNetwork();return MP(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await Xt(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=dt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}}const Fb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],L7="MAGIC_EDEN_CONNECTED_WALLET_STATE";class K7 extends Dn{constructor(){super(...arguments),ge(this,"observer"),ge(this,"$valueStore",To(L7,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),ge(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Fb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===si&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Fb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[si]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{t.provider!==si?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),Xt(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=va(this.network||vt);await mb({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=md(o.addresses),a=vd(o.addresses);s&&a&&(this.$store.setKey("provider",si),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),Xt(a.address,this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${si} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${si} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Ir,$r].includes(this.network)?this.network:vt}getPublicKey(){throw An}async getBalance(){const{paymentAddress:t}=this.$store.get();return await Xt(t,this.network)}getInscriptions(){throw An}async sendBTC(t,r){let n;if(await e7({getProvider:async()=>this.library,payload:{network:{type:va(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await Z$({getProvider:async()=>this.library,payload:{network:{type:yb.Mainnet},address:n,message:t,protocol:al.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=dt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,W=ga(B,nr(this.network));W===a?g.signingIndexes.push(Number(v)):W===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=va(this.network),I={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=dt.fromBase64(String(k.psbtBase64),{network:nr(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(I),o){const k=dt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}}class j7 extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Di]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{if(t.provider!==Di){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Di):this.parent.disconnect())}handleNetworkChanged(t){const r=Ea(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Di)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",Di),Xt(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?Bt:vt}async sendBTC(t,r){const{psbtHex:n}=await M2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=dt.fromHex(String(r),{network:nr(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=ga(x,nr(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=dt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Df(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class D7 extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){return window.opnet}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Fi]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{if(t.provider!==Fi){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Fi):this.parent.disconnect())}handleNetworkChanged(t){const r=Ea(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Fi)}async connect(t){if(!this.library)throw new Error("OP_NET isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",Fi),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),Xt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Ea(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=dt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Df(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class M7{constructor(t,r){ge(this,"$store"),ge(this,"$network"),ge(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[vs]:new c7(t,this,r),[si]:new K7(t,this,r),[Es]:new H7(t,this,r),[Fi]:new D7(t,this,r),[Mi]:new R7(t,this,r),[ms]:new o7(t,this,r),[Di]:new j7(t,this,r),[ji]:new zx(t,this,r),[ii]:new n7(t,this,r),[As]:new i7(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Hg(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Hg(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),Wx()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(rf);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(rf,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(rf)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(Mx(t))s=dt.fromHex(t).toBase64(),o=t;else if(Dx(t))s=t,o=dt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}}const F7={hasUnisat:!1,hasXverse:!1,hasOyl:!1,hasMagicEden:!1,hasOkx:!1,hasOrange:!1,hasOpNet:!1,hasLeather:!1,hasPhantom:!1,hasWizz:!1,isInitializing:!0,connected:!1,isConnecting:!1,publicKey:"",address:"",paymentAddress:"",paymentPublicKey:"",balance:void 0,network:vt,library:null,provider:null,accounts:[],connect:async e=>{},disconnect:()=>{},requestAccounts:async()=>[],getNetwork:async()=>vt,switchNetwork:async e=>{},getPublicKey:async()=>"",getBalance:async()=>"",getInscriptions:async()=>[],sendBTC:async(e,t)=>"",signMessage:async e=>"",signPsbt:async e=>({signedPsbtHex:"",signedPsbtBase64:"",txId:""}),pushPsbt:async e=>"",inscribe:async e=>"",isCreatingCommit:!1,isInscribing:!1},Vb=tn.createContext(F7),V7=()=>tn.useContext(Vb);var Cd={exports:{}},Ua={};/**
57
+ ***************************************************************************** */var pb="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";(()=>{const e=Array(256).fill(-1);for(let t=0;t<pb.length;++t)e[pb.charCodeAt(t)]=t})();var yb,Td,el,_d=(yb=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let d=0;d<32;d++){const g=r.charAt(d);n[g]=d}function i(d){const g=d>>25;return(33554431&d)<<5^996825010&-(g>>0&1)^642813549&-(g>>1&1)^513874426&-(g>>2&1)^1027748829&-(g>>3&1)^705979059&-(g>>4&1)}function o(d){let g=1;for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);if(E<33||E>126)return"Invalid prefix ("+d+")";g=i(g)^E>>5}g=i(g);for(let v=0;v<d.length;++v){const E=d.charCodeAt(v);g=i(g)^31&E}return g}function s(d,g,v,E){let T=0,x=0;const N=(1<<v)-1,O=[];for(let k=0;k<d.length;++k)for(T=T<<g|d[k],x+=g;x>=v;)x-=v,O.push(T>>x&N);if(E)x>0&&O.push(T<<v-x&N);else{if(x>=g)return"Excess padding";if(T<<v-x&N)return"Non-zero padding"}return O}function a(d){return s(d,8,5,!0)}function u(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g}function f(d){const g=s(d,5,8,!1);if(Array.isArray(g))return g;throw new Error(g)}function h(d){let g;function v(E,T){if(T=T||90,E.length<8)return E+" too short";if(E.length>T)return"Exceeds length limit";const x=E.toLowerCase(),N=E.toUpperCase();if(E!==x&&E!==N)return"Mixed-case string "+E;const O=(E=x).lastIndexOf("1");if(O===-1)return"No separator character for "+E;if(O===0)return"Missing prefix for "+E;const k=E.slice(0,O),B=E.slice(O+1);if(B.length<6)return"Data too short";let z=o(k);if(typeof z=="string")return z;const V=[];for(let Ue=0;Ue<B.length;++Ue){const He=B.charAt(Ue),Ge=n[He];if(Ge===void 0)return"Unknown character "+He;z=i(z)^Ge,Ue+6>=B.length||V.push(Ge)}return z!==g?"Invalid checksum for "+E:{prefix:k,words:V}}return g=d==="bech32"?1:734539939,{decodeUnsafe:function(E,T){const x=v(E,T);if(typeof x=="object")return x},decode:function(E,T){const x=v(E,T);if(typeof x=="object")return x;throw new Error(x)},encode:function(E,T,x){if(x=x||90,E.length+7+T.length>x)throw new TypeError("Exceeds length limit");let N=o(E=E.toLowerCase());if(typeof N=="string")throw new Error(N);let O=E+"1";for(let k=0;k<T.length;++k){const B=T[k];if(B>>5)throw new Error("Non 5-bit word");N=i(N)^B,O+=r.charAt(B)}for(let k=0;k<6;++k)N=i(N);N^=g;for(let k=0;k<6;++k)O+=r.charAt(N>>5*(5-k)&31);return O},toWords:a,fromWordsUnsafe:u,fromWords:f}}t.bech32=h("bech32"),t.bech32m=h("bech32m")},yb(Td={exports:{}},Td.exports),Td.exports);(el=_d)&&el.__esModule&&Object.prototype.hasOwnProperty.call(el,"default")&&el.default,_d.bech32m,_d.bech32,new Uint8Array(new Uint16Array([65279]).buffer)[0];var mo,vo;(function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"})(mo||(mo={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(vo||(vo={})),vo.p2pkh,mo.mainnet,vo.p2pkh,mo.testnet,vo.p2sh,mo.mainnet,vo.p2sh,mo.testnet;var m7="accountChange";fe({type:dt(m7)});var v7="networkChange";fe({type:dt(v7)});var E7="disconnect";fe({type:dt(E7)});async function kd(e){var t;const r=await(e==null?void 0:e())||((t=window.XverseProviders)==null?void 0:t.BitcoinProvider)||window.BitcoinProvider;if(!r)throw new Error("No Bitcoin wallet installed");return r}var gb=(e=>(e.Mainnet="Mainnet",e.Testnet="Testnet",e.Signet="Signet",e))(gb||{}),Pd=An(Fu([ge(),Fn(),Os()])),vr=fe({jsonrpc:dt("2.0"),method:ge(),params:An(Fu([En(Vu()),q2({}),Os()])),id:Pd}),tl=(e=>(e[e.PARSE_ERROR=-32700]="PARSE_ERROR",e[e.INVALID_REQUEST=-32600]="INVALID_REQUEST",e[e.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",e[e.INVALID_PARAMS=-32602]="INVALID_PARAMS",e[e.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",e[e.USER_REJECTION=-32e3]="USER_REJECTION",e[e.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED",e[e.ACCESS_DENIED=-32002]="ACCESS_DENIED",e))(tl||{}),wb=fe({jsonrpc:dt("2.0"),result:bd(Vu()),id:Pd}),bb=fe({jsonrpc:dt("2.0"),error:bd(Vu()),id:Pd});Fu([wb,bb]);var rl=(e=>(e.Ordinals="ordinals",e.Payment="payment",e.Stacks="stacks",e))(rl||{}),mb=(e=>(e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr",e.stacks="stacks",e))(mb||{}),A7=fe({address:ge(),publicKey:ge(),purpose:Is(rl),addressType:Is(mb)}),vb=async e=>{var t,r;const n=await kd(e.getProvider),{purposes:i}=e.payload;if(!i)throw new Error("Address purposes are required");try{const o=Gr.createUnsecuredToken(e.payload),s=await n.connect(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during address request",o),(r=e.onCancel)==null||r.call(e)}},S7="stx_getAddresses",T7=xs(fe({message:An(ge())}));fe({...vr.entries,...fe({method:dt(S7),params:T7,id:ge()}).entries});var _7="stx_signTransaction",k7=fe({transaction:ge(),pubkey:An(ge()),broadcast:An(z2())});fe({...vr.entries,...fe({method:dt(_7),params:k7,id:ge()}).entries});var P7=["software","ledger"],I7=G2(P7),O7="getInfo",x7=xs(Os());fe({version:ge(),methods:An(En(ge())),supports:En(ge())}),fe({...vr.entries,...fe({method:dt(O7),params:x7,id:ge()}).entries});var $7="getAddresses",C7=fe({purposes:En(Is(rl)),message:An(ge())});fe({...vr.entries,...fe({method:dt($7),params:C7,id:ge()}).entries});var N7="signMessage",nl=(e=>(e.ECDSA="ECDSA",e.BIP322="BIP322",e))(nl||{}),U7=fe({address:ge(),message:ge(),protocol:An(Is(nl))});fe({signature:ge(),messageHash:ge(),address:ge(),protocol:Is(nl)}),fe({...vr.entries,...fe({method:dt(N7),params:U7,id:ge()}).entries});var R7="getAccounts",B7=fe({purposes:En(Is(rl)),message:An(ge())});En(fe({...A7.entries,...fe({walletType:I7}).entries})),fe({...vr.entries,...fe({method:dt(R7),params:B7,id:ge()}).entries});var L7="getBalance";xs(Os()),fe({...vr.entries,...fe({method:dt(L7),id:ge()}).entries});var H7="wallet_requestPermissions",K7=md();dt(!0),fe({...vr.entries,...fe({method:dt(H7),params:K7,id:ge()}).entries});var j7="wallet_renouncePermissions",D7=md();dt(!0),fe({...vr.entries,...fe({method:dt(j7),params:D7,id:ge()}).entries});var M7="wallet_getWalletType";xs(Os()),fe({...vr.entries,...fe({method:dt(M7),id:ge()}).entries});var F7="runes_getBalance",V7=xs(Os());fe({balances:En(fe({runeName:ge(),amount:ge(),divisibility:Fn(),symbol:ge(),inscriptionId:xs(ge())}))}),fe({...vr.entries,...fe({method:dt(F7),params:V7,id:ge()}).entries});var W7="runes_transfer",z7=fe({recipients:En(fe({runeName:ge(),amount:ge(),address:ge()}))});fe({...vr.entries,...fe({method:dt(W7),params:z7,id:ge()}).entries});var q7="ord_getInscriptions",G7=fe({offset:Fn(),limit:Fn()});fe({total:Fn(),limit:Fn(),offset:Fn(),inscriptions:En(fe({inscriptionId:ge(),inscriptionNumber:ge(),address:ge(),collectionName:An(ge()),postage:ge(),contentLength:ge(),contentType:ge(),timestamp:Fn(),offset:Fn(),genesisTransaction:ge(),output:ge()}))}),fe({...vr.entries,...fe({method:dt(q7),params:G7,id:ge()}).entries});var X7="ord_sendInscriptions",J7=fe({transfers:En(fe({address:ge(),inscriptionId:ge()}))});fe({...vr.entries,...fe({method:dt(X7),params:J7,id:ge()}).entries});var Eb=async(e,t,r)=>{var n;let i=((n=window.XverseProviders)==null?void 0:n.BitcoinProvider)||window.BitcoinProvider;if(!i)throw new Error("no wallet provider was found");if(!e)throw new Error("A wallet method is required");const o=await i.request(e,t);return W2(bb,o)?{status:"error",error:o.error}:W2(wb,o)?{status:"success",result:o.result}:{status:"error",error:{code:-32603,message:"Received unknown response from provider.",data:o}}},Y7=async e=>{var t,r;const n=await kd(e.getProvider),{address:i,message:o}=e.payload;if(!i)throw new Error("An address is required to sign a message");if(!o)throw new Error("A message to be signed is required");try{const s=Gr.createUnsecuredToken(e.payload),a=await n.signMessage(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign message request",s),(r=e.onCancel)==null||r.call(e)}},Z7=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),Q7=async e=>{var t,r;const n=await kd(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=Z7(i),f={network:s,senderAddress:o,message:a,recipients:u},h=Gr.createUnsecuredToken(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};let Ab=e=>e,Ia={},ts={addEventListener(){},removeEventListener(){}};function e$(){try{return typeof localStorage<"u"}catch{return!1}}e$()&&(Ia=localStorage),typeof window<"u"&&(ts={addEventListener(e,t,r){window.addEventListener("storage",t),window.addEventListener("pageshow",r)},removeEventListener(e,t,r){window.removeEventListener("storage",t),window.removeEventListener("pageshow",r)}});function Eo(e,t={},r={}){let n=r.encode||Ab,i=r.decode||Ab,o=Lg(),s=o.setKey,a=(d,g)=>{typeof g>"u"?(r.listen!==!1&&ts.perKey&&ts.removeEventListener(e+d,f,h),delete Ia[e+d]):(r.listen!==!1&&ts.perKey&&!(d in o.value)&&ts.addEventListener(e+d,f,h),Ia[e+d]=n(g))};o.setKey=(d,g)=>{a(d,g),s(d,g)};let u=o.set;o.set=function(d){for(let g in d)a(g,d[g]);for(let g in o.value)g in d||a(g,void 0);u(d)};function f(d){d.key?d.key.startsWith(e)&&(d.newValue===null?s(d.key.slice(e.length),void 0):s(d.key.slice(e.length),i(d.newValue))):u({})}function h(){let d={...t};for(let g in Ia)g.startsWith(e)&&(d[g.slice(e.length)]=i(Ia[g]));for(let g in d)o.setKey(g,d[g])}return P5(o,()=>{if(h(),r.listen!==!1)return ts.addEventListener(e,f,h),()=>{ts.removeEventListener(e,f,h);for(let d in o.value)ts.removeEventListener(e+d,f,h)}}),o}const Sb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],t$="XVERSE_CONNECTED_WALLET_STATE";class r$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(t$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window==null?void 0:window.BitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Sb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ri&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Sb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){Bn(this.$store,["provider"],t=>{t.provider!==ri?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.XverseProviders)!=null&&t.BitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ri]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);if(!s||!a)throw new Error("Could not find the addresses");s&&a&&(this.$store.setKey("provider",ri),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ri} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ri} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){const n=await Eb("sendTransfer",{recipients:[{address:t,amount:r}]});if(n.status==="success")return n.result.txid;throw n.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+n.error.message)}async signMessage(t,r){const n=r||this.$store.get().paymentAddress,i=await Eb("signMessage",{address:n,message:t});if(i.status==="success")return i.result.signature;throw i.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error signing message: "+i.error.message)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=da(k,nr(this.network));B===a?g.signingIndexes.push(Number(v)):B===s&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:wa(this.network)},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=bt.fromBase64(String(O.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await signTransaction(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}pushPsbt(t){throw mn}}class n$ extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){return window.wizz}get network(){return this.$network.get()}handleNetworkChanged(t){this.parent.connect(vs)}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&this.$store.setKey("accounts",t)}initialize(){Bn(this.$store,["provider"],t=>{t.provider===vs?this.addLibraryListeners():this.removeLibraryListeners()}),typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[vs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0}))}removeLibraryListeners(){var t,r;(t=this.library)==null||t.removeListener("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.removeListener("accountsChanged",this.handleAccountsChanged.bind(this))}addLibraryListeners(){var t,r;(t=this.library)==null||t.on("networkChanged",this.handleNetworkChanged.bind(this)),(r=this.library)==null||r.on("accountsChanged",this.handleAccountsChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeLibraryListeners()}async connect(){if(!this.library)throw CP;const t=await this.library.requestAccounts();if(!t)throw new Error("No accounts found");const r=await this.library.getPublicKey();if(!r)throw new Error("No public key found");this.$store.setKey("accounts",t),this.$store.setKey("address",t[0]),this.$store.setKey("paymentAddress",t[0]),this.$store.setKey("publicKey",r),this.$store.setKey("paymentPublicKey",r),this.$store.setKey("provider",vs),await this.getNetwork().then(n=>{var i;n&&((i=this.config)==null?void 0:i.network)!==n&&this.parent.switchNetwork(n)}),await this.parent.getBalance(),this.$store.setKey("connected",!0)}async requestAccounts(){return await this.library.requestAccounts()}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getNetwork());return r?Mw(r):void 0}async switchNetwork(t){var r;if(t===$r||t===uo)return await this.library.switchNetwork(Kw);const n=Mw(t);await((r=this.library)==null?void 0:r.switchNetwork(n)),this.$network.set(t),await this.parent.getBalance()}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(i)return i;throw new Error("Error sending BTC")}async signMessage(t){var r;return await((r=this.library)==null?void 0:r.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i,broadcast:!1})),u=bt.fromHex(a);let f;return i&&o&&(f=await this.pushPsbt(a)),{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}async pushPsbt(t){return await Je.post(`${Gi(this.$network.get())}/api/tx`,t).then(r=>r.data)}}const Tb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],i$="OYL_CONNECTED_WALLET_STATE";class s$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(i$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.oyl}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Tb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ws&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Tb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.oyl&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ws]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ws?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){if(!this.library)throw new Error("Oyl isn't installed");const{nativeSegwit:r,taproot:n}=await this.library.getAddresses();if(!r||!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",r.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",r.publicKey),this.$store.setKey("provider",ws),ir(r.address,this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0);const i=await this.getBalance();i&&this.$store.setKey("balance",i)}async getNetwork(){return this.network}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){const n=r||this.$store.get().paymentAddress;return(await this.library.signMessage({address:n,message:t})).signature}async signPsbt(t,r,n,i,o){const{psbt:s,txid:a}=await this.library.signPsbt({psbt:r,finalize:i,broadcast:o}),u=bt.fromHex(s);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:a}}async pushPsbt(t){return(await this.library.pushPsbt({psbt:t})).txid}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){const{total:t}=await this.library.getBalance();return this.$store.setKey("balance",t),t}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(){throw mn}}const _b=["address","paymentAddress","publicKey","paymentPublicKey","balance"],o$="LEATHER_CONNECTED_WALLET_STATE";class a$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(o$,{address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){return window.LeatherProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of _b)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===bs&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):_b.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;window!=null&&window.LeatherProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[bs]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==bs?this.removeSubscriber&&(this.$valueStore.set({address:"",publicKey:"",paymentAddress:"",paymentPublicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;if(!this.library)throw new Error("Leather isn't installed");const n=await this.library.request("getAddresses");if(!n)throw new Error("No accounts found");const i=n.result.addresses,o=i.map(u=>u.address),s=i.find(u=>u.type===Zh),a=i.find(u=>u.type===Kg);if(!(s!=null&&s.publicKey)||!(a!=null&&a.publicKey))throw new Error("No accounts found");if((r=String(s==null?void 0:s.address))!=null&&r.startsWith("tb")&&this.network!==Bt&&this.network!==xr&&this.network!==Or)throw new Error(`Please switch networks to ${this.network} in the wallet settings.`);this.$store.setKey("accounts",o),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address),this.$store.setKey("publicKey",s.publicKey),this.$store.setKey("paymentPublicKey",a.publicKey),this.$store.setKey("provider",bs),ir(a.address,this.network).then(u=>{this.$store.setKey("balance",u)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.network}async sendBTC(t,r){var n,i;const o=await((n=this.library)==null?void 0:n.request("sendTransfer",{recipients:[{address:t,amount:r}]}));if((i=o==null?void 0:o.result)!=null&&i.txid)return o.result.txid;throw o.error.code===tl.USER_REJECTION?new Error("User rejected the request"):new Error("Error sending BTC: "+o.error.message)}async signMessage(t,r){var n;const i=r===this.$store.get().address?Zh:Kg;if(r!==this.$store.get().address&&r!==this.$store.get().paymentAddress)throw new Error("Invalid address to sign message");const o=await this.library.request("signMessage",{message:t,paymentType:i});return(n=o==null?void 0:o.result)==null?void 0:n.signature}async signPsbt(t,r,n,i,o){const s={hex:r,broadcast:!1,network:this.network},a=(await this.library.request("signPsbt",s)).result.hex,u=bt.fromHex(String(a));if(i&&o){const f=u.finalizeAllInputs(),h=await this.pushPsbt(f.toHex());return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:h}}else if(i){const f=u.finalizeAllInputs();return{signedPsbtHex:f.toHex(),signedPsbtBase64:f.toBase64(),txId:void 0}}else return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){const r=bt.fromHex(t).extractTransaction();return await Je.post(`${Gi(this.network)}/api/tx`,r.toHex()).then(n=>n.data)}async getPublicKey(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.find(n=>n.type===Zh);if(!(r!=null&&r.publicKey))throw new Error("No accounts found");return r.publicKey}async getBalance(){const t=await ir(this.$store.get().paymentAddress,this.network);return this.$store.setKey("balance",t),t.toString()}async getInscriptions(){throw mn}async requestAccounts(){const{result:t}=await this.library.request("getAddresses"),r=t.addresses.map(n=>n.address);return this.$store.setKey("accounts",r),r}async switchNetwork(){throw mn}}var Id={},kb={},Sn={},Pb={};Object.defineProperty(Pb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getProviderById=e.getProviders=e.getProviderOrThrow=void 0;async function n(s){var a,u;if(s){const h=await s();if(h)return h}const f=window.OrangeBitcoinProvider||((a=window.OrangecryptoProviders)==null?void 0:a.BitcoinProvider)||((u=window.OrangeWalletProviders)==null?void 0:u.OrangeBitcoinProvider);if(!f)throw new Error("No Orange Bitcoin wallet installed");return f}e.getProviderOrThrow=n;function i(){return window.btc_providers||(window.btc_providers=[]),window.btc_providers}e.getProviders=i;function o(s){var a;if(Array.isArray(window.btc_providers)){const u=window.btc_providers.find(f=>f.id===s);return(a=u==null?void 0:u.id)==null?void 0:a.split(".").reduce((f,h)=>f==null?void 0:f[h],window)}else{console.log("window.btc_providers is not defined or not an array");return}}e.getProviderById=o,r(Pb,e)}(Sn);var Ib={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AddressType=e.AddressPurpose=void 0,function(t){t.Ordinals="ordinals",t.Payment="payment",t.Stacks="stacks"}(e.AddressPurpose||(e.AddressPurpose={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr",t.stacks="stacks"}(e.AddressType||(e.AddressType={}))})(Ib),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.getAddress=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{purposes:h}=s.payload;if(!h)throw new Error("Address purposes are required");try{const d=(0,n.createUnsecuredToken)(s.payload),g=await f.connect(d);(a=s.onFinish)==null||a.call(s,g)}catch(d){console.error("[Connect] Error during address request",d),(u=s.onCancel)==null||u.call(s)}};e.getAddress=o,r(Ib,e)}(kb);var Ob={},xb={},$b={};Object.defineProperty($b,"__esModule",{value:!0});var Cb={};Object.defineProperty(Cb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r($b,e),r(Cb,e)}(xb),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.request=void 0;const n=Sn,i=async(s,a,u)=>{var f;let h=((f=window.OrangecryptoProviders)==null?void 0:f.BitcoinProvider)||window.OrangeBitcoinProvider;if(u&&(h=await(0,n.getProviderById)(u)),!h)throw new Error("no wallet provider was found");if(!s)throw new Error("A wallet method is required");const d=await h.request(s,a);return o(d)?{status:"success",result:d.result}:{status:"error",error:d.error}};e.request=i;const o=s=>Object.hasOwn(s,"result")&&!!s.result;r(xb,e)}(Ob);var Nb={},Ub={};Object.defineProperty(Ub,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(a,u,f,h){h===void 0&&(h=f);var d=Object.getOwnPropertyDescriptor(u,f);(!d||("get"in d?!u.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return u[f]}}),Object.defineProperty(a,h,d)}:function(a,u,f,h){h===void 0&&(h=f),a[h]=u[f]}),r=Te&&Te.__exportStar||function(a,u){for(var f in a)f!=="default"&&!Object.prototype.hasOwnProperty.call(u,f)&&t(u,a,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCapabilities=void 0;const n=Gr,i=Sn,o=(a,u)=>{const f=d=>!(!a[d]||u&&!u.has(d)),h={request:f("request"),connect:f("connect"),signMessage:f("signMessage"),signTransaction:f("signTransaction"),sendBtcTransaction:f("sendBtcTransaction"),createInscription:f("createInscription"),createRepeatInscriptions:f("createRepeatInscriptions"),signMultipleTransactions:f("signMultipleTransactions")};return Object.entries(h).reduce((d,[g,v])=>v?[...d,g]:d,[])},s=async a=>{var u,f,h;const d=await(0,i.getProviderOrThrow)(a.getProvider),g=(0,n.createUnsecuredToken)(a.payload);if(d.getCapabilities)try{const v=await d.getCapabilities(g);(u=a.onFinish)==null||u.call(a,o(d,new Set(v)))}catch(v){console.error("[Connect] Error during capabilities request",v)}try{const v=o(d);(f=a.onFinish)==null||f.call(a,v)}catch(v){console.error("[Connect] Error during capabilities request",v),(h=a.onCancel)==null||h.call(a)}};e.getCapabilities=s,r(Ub,e)}(Nb);var Rb={},il={},Oa={};Object.defineProperty(Oa,"__esModule",{value:!0}),Oa.validateInscriptionPayload=void 0;const c$=4e5,u$=6e4,l$=e=>{const{contentType:t,content:r,payloadType:n,network:i,appFeeAddress:o,appFee:s}=e;if(!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(t))throw new Error("Invalid content type detected");if(!r||r.length===0)throw new Error("Empty content not allowed");if(!n||n!=="BASE_64"&&n!=="PLAIN_TEXT")throw new Error("Empty invalid payloadType specified");if(r.length>(i.type==="Mainnet"?c$:u$))throw new Error("Content too large");if(((o==null?void 0:o.length)??0)>0&&(s??0)<=0)throw new Error("Invalid combination of app fee address and fee provided")};Oa.validateInscriptionPayload=l$,Object.defineProperty(il,"__esModule",{value:!0}),il.createInscription=void 0;const h$=Gr,f$=Sn,d$=Oa,p$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,f$.getProviderOrThrow)(n);(0,d$.validateInscriptionPayload)(e.payload);try{const o=(0,h$.createUnsecuredToken)(e.payload),s=await i.createInscription(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create inscription",o),(r=e.onCancel)==null||r.call(e)}};il.createInscription=p$;var sl={};Object.defineProperty(sl,"__esModule",{value:!0}),sl.createRepeatInscriptions=void 0;const y$=Sn,g$=Gr,w$=Oa,b$=async e=>{var t,r;const{getProvider:n}=e,i=await(0,y$.getProviderOrThrow)(n);(0,w$.validateInscriptionPayload)(e.payload);try{const o=(0,g$.createUnsecuredToken)(e.payload),s=await i.createRepeatInscriptions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during create repeat inscriptions",o),(r=e.onCancel)==null||r.call(e)}};sl.createRepeatInscriptions=b$;var Bb={};Object.defineProperty(Bb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(il,e),r(sl,e),r(Bb,e)}(Rb);var Lb={},Hb={};Object.defineProperty(Hb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(s,a,u,f){f===void 0&&(f=u);var h=Object.getOwnPropertyDescriptor(a,u);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(s,f,h)}:function(s,a,u,f){f===void 0&&(f=u),s[f]=a[u]}),r=Te&&Te.__exportStar||function(s,a){for(var u in s)u!=="default"&&!Object.prototype.hasOwnProperty.call(a,u)&&t(a,s,u)};Object.defineProperty(e,"__esModule",{value:!0}),e.signMessage=void 0;const n=Gr,i=Sn,o=async s=>{var a,u;const f=await(0,i.getProviderOrThrow)(s.getProvider),{address:h,message:d}=s.payload;if(!h)throw new Error("An address is required to sign a message");if(!d)throw new Error("A message to be signed is required");try{const g=(0,n.createUnsecuredToken)(s.payload),v=await f.signMessage(g);(a=s.onFinish)==null||a.call(s,v)}catch(g){console.error("[Connect] Error during sign message request",g),(u=s.onCancel)==null||u.call(s)}};e.signMessage=o,r(Hb,e)}(Lb);var Kb={},ol={};Object.defineProperty(ol,"__esModule",{value:!0}),ol.sendBtcTransaction=void 0;const m$=Gr,v$=Sn,E$=e=>e.map(t=>{const{address:r,amountSats:n}=t;return{address:r,amountSats:n.toString()}}),A$=async e=>{var t,r;const n=await(0,v$.getProviderOrThrow)(e.getProvider),{recipients:i,senderAddress:o,network:s,message:a}=e.payload;if(!i||i.length===0)throw new Error("At least one recipient is required");if(i.some(u=>typeof u.address!="string"||typeof u.amountSats!="bigint"))throw new Error("Incorrect recipient format");if(!o)throw new Error("The sender address is required");try{const u=E$(i),f={network:s,senderAddress:o,message:a,recipients:u},h=(0,m$.createUnsecuredToken)(f),d=await n.sendBtcTransaction(h);(t=e.onFinish)==null||t.call(e,d)}catch(u){console.error("[Connect] Error during send BTC transaction request",u),(r=e.onCancel)==null||r.call(e)}};ol.sendBtcTransaction=A$;var al={};Object.defineProperty(al,"__esModule",{value:!0}),al.signTransaction=void 0;const S$=Gr,T$=Sn,_$=async e=>{var t,r;const n=await(0,T$.getProviderOrThrow)(e.getProvider),{psbtBase64:i,inputsToSign:o}=e.payload;if(!i)throw new Error("A value for psbtBase64 representing the tx hash is required");if(!o)throw new Error("An array specifying the inputs to be signed by the wallet is required");try{const s=(0,S$.createUnsecuredToken)(e.payload),a=await n.signTransaction(s);(t=e.onFinish)==null||t.call(e,a)}catch(s){console.error("[Connect] Error during sign transaction request",s),(r=e.onCancel)==null||r.call(e)}};al.signTransaction=_$;var cl={};Object.defineProperty(cl,"__esModule",{value:!0}),cl.signMultipleTransactions=void 0;const k$=Gr,P$=Sn,I$=async e=>{var t,r;const n=await(0,P$.getProviderOrThrow)(e.getProvider),{psbts:i}=e.payload;if(!i||!i.length)throw new Error("psbts array is required");if(i.length>100)throw new Error("psbts array must contain less than 100 psbts");try{const o=(0,k$.createUnsecuredToken)(e.payload),s=await n.signMultipleTransactions(o);(t=e.onFinish)==null||t.call(e,s)}catch(o){console.error("[Connect] Error during sign Multiple transactions request",o),(r=e.onCancel)==null||r.call(e)}};cl.signMultipleTransactions=I$;var jb={};Object.defineProperty(jb,"__esModule",{value:!0}),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(ol,e),r(al,e),r(cl,e),r(jb,e)}(Kb);var Db={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.RpcErrorCode=e.BitcoinNetworkType=void 0,function(t){t.Mainnet="Mainnet",t.Testnet="Testnet"}(e.BitcoinNetworkType||(e.BitcoinNetworkType={})),function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.USER_REJECTION=-32e3]="USER_REJECTION",t[t.METHOD_NOT_SUPPORTED=-32001]="METHOD_NOT_SUPPORTED"}(e.RpcErrorCode||(e.RpcErrorCode={}))})(Db),function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(kb,e),r(Ob,e),r(Nb,e),r(Rb,e),r(Lb,e),r(Sn,e),r(Kb,e),r(Db,e)}(Id);const O$=IT(Id),Mb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],{signMessage:x$,sendBtcTransaction:$$,signTransaction:C$}=O$,N$="ORANGE_CONNECTED_WALLET_STATE";class U$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(N$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.OrangeWalletProviders)==null?void 0:t.OrangeBitcoinProvider}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Mb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ji&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Mb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r,n;(r=window==null?void 0:window.OrangeWalletProviders)!=null&&r.OrangeBitcoinProvider&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(n=this.observer)==null||n.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ji?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(s=>{this.$store.setKey("balance",s)});return}let i=Iu(this.network||mt);const o={payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:s=>{const a=gd(s.addresses),u=wd(s.addresses);if(!a||!(u!=null&&u.address))throw new Error("Could not find addresses");a&&u&&(this.$store.setKey("provider",ji),this.$store.setKey("address",a.address),this.$store.setKey("paymentAddress",u.address)),this.$store.setKey("publicKey",String(a.publicKey)),this.$store.setKey("paymentPublicKey",String(u.publicKey)),ir(String(u==null?void 0:u.address),this.network).then(f=>{this.$store.setKey("balance",f)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ji} wallet`)}};await Id.getAddress(o),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n="";const i={payload:{network:{type:Iu(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:o=>{n=o},onCancel:()=>{throw new Error("User canceled the request")}};return await $$(i),n}async signMessage(t,r){let n="";const i=r||this.$store.get().paymentAddress,o={payload:{network:{type:Iu(this.network)},address:i,message:t},onFinish:s=>{n=s},onCancel:()=>{throw new Error("User canceled the request")}};return await x$(o),n}async signPsbt(t,r,n,i,o){const s=bt.fromBase64(String(n),{network:nr(this.network)}),a=this.$store.get().address,u=this.$store.get().paymentAddress,f=s.data.inputs,h=[],d={address:a,signingIndexes:[]},g={address:u,signingIndexes:[]};let v=0;for await(let O of f){if(O.witnessUtxo===void 0)g.signingIndexes.push(Number(v));else{const{script:k}=O.witnessUtxo,B=da(k,nr(this.network));B===u?g.signingIndexes.push(Number(v)):B===a&&d.signingIndexes.push(Number(v))}v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N={payload:{network:{type:Iu(this.network)},psbtBase64:s.toBase64(),message:s.toBase64(),broadcast:o,inputsToSign:h},onFinish:O=>{if(O.txId)E=O.txId;else if(O.psbtBase64){const k=bt.fromBase64(String(O.psbtBase64),{network:nr(this.network)});T=k.toHex(),x=k.toBase64()}},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}};return await C$(N),{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){let r=t;if(!r.startsWith("02")){const n=bt.fromHex(r);n.finalizeAllInputs(),r=n.extractTransaction().toHex()}return await Je.post(`${Gi(this.network)}/api/tx`,r).then(n=>n.data)}}const Fb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],R$="OKX_CONNECTED_WALLET_STATE";class B$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(R$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t,r;let n;return this.network===Bt||this.network===xr||this.network===Or||this.network===$r?n=(t=window==null?void 0:window.okxwallet)==null?void 0:t.bitcoinTestnet:(this.network===mt||this.network===uo)&&(n=(r=window==null?void 0:window.okxwallet)==null?void 0:r.bitcoin),n}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Fb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ms&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Fb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){var t;typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var r;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ms]:!0}),(r=this.observer)==null||r.disconnect())}),(t=this.observer)==null||t.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],r=>{r.provider!==ms?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){var r;try{const n=await this.library.connect();if(!n)throw new Error("No accounts found");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",n.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",n.publicKey),this.$store.setKey("accounts",[n]);const i=await((r=this.library)==null?void 0:r.getBalance());this.$store.setKey("balance",i.total),this.$store.setKey("provider",ms),this.$store.setKey("connected",!0)}catch(n){throw n}}async requestAccounts(){const t=this.library,r=this.network;return r===Bt||r===xr||r===$r?await t.connect():await t.requestAccounts()}async getNetwork(){const{address:t}=this.$store.get(),r=this.network;if(t.slice(0,1)==="t")return r===Bt?Bt:r===xr?xr:r===Or?Or:r===$r?$r:Bt;const n=await this.library.getNetwork();return DP(n)}async getPublicKey(){const t=this.library;return await(t==null?void 0:t.getPublicKey())}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}async getInscriptions(){return await this.library.getInscriptions(0,10)}async sendBTC(t,r){const n=await this.library.sendBitcoin(t,r);if(!n)throw new Error("Transaction failed");return n}async signMessage(t,r){const n=this.library;return await(n==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){const s=await this.library.signPsbt(r,{autoFinalized:i}),a=bt.fromHex(s);if(i&&o){const u=await this.pushPsbt(s);return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:u}}return{signedPsbtHex:a.toHex(),signedPsbtBase64:a.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}const Vb=["address","paymentAddress","publicKey","paymentPublicKey","balance"],L$="MAGIC_EDEN_CONNECTED_WALLET_STATE";class H$ extends fi{constructor(){super(...arguments),be(this,"observer"),be(this,"$valueStore",Eo(L$,{address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""})),be(this,"removeSubscriber")}get library(){var t;return(t=window==null?void 0:window.magicEden)==null?void 0:t.bitcoin}get network(){return this.$network.get()}restorePersistedValues(){const t=this.$valueStore.get();for(const r of Vb)this.$store.setKey(r,t[r])}watchStateChange(t,r,n){var i,o;n&&t.provider===ni&&(n==="balance"?this.$valueStore.setKey("balance",((i=t.balance)==null?void 0:i.toString())??""):Vb.includes(n)&&this.$valueStore.setKey(n,((o=t[n])==null?void 0:o.toString())??""))}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t,r;(t=window==null?void 0:window.magicEden)!=null&&t.bitcoin&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ni]:!0}),(r=this.observer)==null||r.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{t.provider!==ni?this.removeSubscriber&&(this.$valueStore.set({address:"",paymentAddress:"",paymentPublicKey:"",publicKey:"",balance:""}),this.removeSubscriber(),this.removeSubscriber=void 0):this.removeSubscriber=this.$store.subscribe(this.watchStateChange.bind(this))})}dispose(){var t;(t=this.observer)==null||t.disconnect()}async connect(t){const{address:r,paymentAddress:n}=this.$valueStore.get();try{if(r){this.restorePersistedValues(),ir(n,this.network).then(o=>{this.$store.setKey("balance",o)});return}let i=wa(this.network||mt);await vb({getProvider:async()=>this.library,payload:{purposes:["ordinals","payment"],message:"Address for receiving Ordinals and payments",network:{type:i}},onFinish:o=>{const s=gd(o.addresses),a=wd(o.addresses);if(!s||!a)throw new Error("No address found");s&&a&&(this.$store.setKey("provider",ni),this.$store.setKey("address",s.address),this.$store.setKey("paymentAddress",a.address)),this.$store.setKey("publicKey",String(o.addresses[0].publicKey)),this.$store.setKey("paymentPublicKey",String(o.addresses[1].publicKey)),ir(String(a.address),this.network).then(u=>{this.$store.setKey("balance",u)})},onCancel:()=>{throw new Error(`User canceled lasereyes to ${ni} wallet`)},onError:o=>{throw new Error(`Can't lasereyes to ${ni} wallet`)}}),this.$store.setKey("connected",!0)}catch(i){throw i}}async requestAccounts(){return[this.$store.get().address,this.$store.get().paymentAddress]}async getNetwork(){const{address:t}=this.$store.get();return t.slice(0,1)==="t"&&[Bt,xr,Or,$r].includes(this.network)?this.network:mt}getPublicKey(){throw mn}async getBalance(){const{paymentAddress:t}=this.$store.get();return await ir(t,this.network)}getInscriptions(){throw mn}async sendBTC(t,r){let n;if(await Q7({getProvider:async()=>this.library,payload:{network:{type:wa(this.network)},recipients:[{address:t,amountSats:BigInt(r)}],senderAddress:this.$store.get().paymentAddress},onFinish:i=>{n=i},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),!n)throw new Error("Error sending BTC");return n.txid}async signMessage(t,r){try{const n=r||this.$store.get().paymentAddress;let i="";return await Y7({getProvider:async()=>this.library,payload:{network:{type:gb.Mainnet},address:n,message:t,protocol:nl.BIP322},onFinish:o=>{i=o},onCancel:()=>{throw console.error("Request canceled"),new Error("User canceled the request")}}),i}catch(n){throw n}}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromBase64(String(n),{network:nr(this.network)}),f=u.data.inputs,h=[],d={address:s,signingIndexes:[]},g={address:a,signingIndexes:[]};let v=0;for await(let k of f){const{script:B}=k.witnessUtxo,z=da(B,nr(this.network));z===a?g.signingIndexes.push(Number(v)):z===s&&d.signingIndexes.push(Number(v)),v++}d.signingIndexes.length>0&&h.push(d),g.signingIndexes.length>0&&h.push(g);let E,T,x;const N=wa(this.network),O={getProvider:async()=>this.library,payload:{network:{type:N},message:"Sign Transaction",psbtBase64:u.toBase64(),broadcast:o,inputsToSign:h},onFinish:k=>{if(k.psbtBase64){const B=bt.fromBase64(String(k.psbtBase64),{network:nr(this.network)});T=B.toHex(),x=B.toBase64()}},onCancel:()=>{throw console.log("Canceled"),new Error("User canceled the request")},onError:k=>{throw console.log("error",k),k}};if(await signTransaction(O),o){const k=bt.fromBase64(String(x)).finalizeAllInputs().extractTransaction(),B=await this.pushPsbt(k.toHex());return{signedPsbtHex:k.toHex(),signedPsbtBase64:"test",txId:B}}else return{signedPsbtHex:T,signedPsbtBase64:x,txId:E}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}}class K$ extends fi{constructor(){super(...arguments),be(this,"observer")}get library(){var t;return(t=window==null?void 0:window.phantom)==null?void 0:t.bitcoin}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[Ki]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),Bn(this.$store,["provider"],t=>{if(t.provider!==Ki){this.removeListeners();return}this.library.requestAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(Ki):this.parent.disconnect())}handleNetworkChanged(t){const r=Hf(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(Ki)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(console.log("phantomAccounts",r),!r)throw new Error("No accounts found");this.$store.setKey("accounts",r);const n=r.find(o=>o.purpose==="ordinals"),i=r.find(o=>o.purpose==="payment");this.$store.setKey("address",n.address),this.$store.setKey("paymentAddress",i.address),this.$store.setKey("publicKey",n.publicKey),this.$store.setKey("paymentPublicKey",i.publicKey),this.$store.setKey("provider",Ki),ir(r[0],this.network).then(o=>{this.$store.setKey("balance",o)}),this.$store.setKey("connected",!0)}async getNetwork(){return this.$store.get().address.slice(0,1)==="t"?Bt:mt}async sendBTC(t,r){const{psbtHex:n}=await F2(this.$store.get().address,this.$store.get().paymentAddress,t,r,this.$store.get().paymentPublicKey,this.network,7),i=await this.signPsbt("",n,"",!0,!0);if(!i)throw new Error("Error sending BTC");return i.txId}async signMessage(t,r){var n;const i=new TextEncoder().encode(t),o=new Uint8Array(i),s=r||this.$store.get().paymentAddress,a=await((n=this.library)==null?void 0:n.signMessage(s,o)),u=String.fromCharCode(...a.signature);return btoa(u)}async signPsbt(t,r,n,i,o){const{address:s,paymentAddress:a}=this.$store.get(),u=bt.fromHex(String(r),{network:nr(this.network)}).data.inputs,f=[],h={address:s,signingIndexes:[]},d={address:a,signingIndexes:[]};let g=0;for await(let T of u){const{script:x}=T.witnessUtxo,N=da(x,nr(this.network));N===a?d.signingIndexes.push(Number(g)):N===s&&h.signingIndexes.push(Number(g)),g++}h.signingIndexes.length>0&&f.push(h),d.signingIndexes.length>0&&f.push(d);const v=await this.library.signPsbt(r,{inputsToSign:f}),E=bt.fromHex(v);if(i&&o){const T=await this.pushPsbt(v);return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:T}}return{signedPsbtHex:E.toHex(),signedPsbtBase64:E.toBase64(),txId:void 0}}async pushPsbt(t){return await Je.post(`${Gi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){return this.$store.get().publicKey}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Dw(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}class j${constructor(t,r){be(this,"$store"),be(this,"$network"),be(this,"$providerMap"),this.config=r,this.$store=t.$store,this.$network=t.$network,this.$providerMap={[bs]:new a$(t,this,r),[ni]:new H$(t,this,r),[ms]:new B$(t,this,r),[ji]:new U$(t,this,r),[ws]:new s$(t,this,r),[Ki]:new K$(t,this,r),[Hi]:new Vx(t,this,r),[ri]:new r$(t,this,r),[vs]:new n$(t,this,r)},this.$network.subscribe(this.watchNetworkChange.bind(this)),Bg(this.$store,["isInitializing"],n=>this.handleIsInitializingChanged(n.isInitializing)),r&&r.network&&(this.$network.set(r.network),this.getNetwork().then(n=>{try{r.network!==n&&this.switchNetwork(r.network)}catch{this.disconnect()}})),Bg(this.$store,["hasProvider"],this.checkInitializationComplete.bind(this)),Wx()}dispose(){Object.values(this.$providerMap).forEach(t=>t==null?void 0:t.dispose())}handleIsInitializingChanged(t){if(typeof window<"u"&&typeof localStorage<"u"&&!t){const r=localStorage==null?void 0:localStorage.getItem(Qh);r&&(this.$store.setKey("provider",r),this.connect(r))}}async connect(t){this.$store.setKey("isConnecting",!0);try{if(localStorage==null||localStorage.setItem(Qh,t),!this.$providerMap[t])throw new Error("Unsupported wallet provider");const r=this.$providerMap[t];await(r==null?void 0:r.connect(t)),this.$store.setKey("connected",!0)}catch(r){throw console.error(r),this.$store.setKey("isConnecting",!1),this.disconnect(),r}finally{this.$store.setKey("isConnecting",!1)}}async requestAccounts(){var t;if(!this.$store.get().provider)throw new Error("No wallet provider connected");if(!this.$providerMap[this.$store.get().provider])throw new Error("The connected wallet doesn't support this method");try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.requestAccounts())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}disconnect(){this.$store.setKey("connected",!1),this.$store.setKey("provider",void 0),this.$store.setKey("address",""),this.$store.setKey("paymentAddress",""),this.$store.setKey("publicKey",""),this.$store.setKey("paymentPublicKey",""),this.$store.setKey("balance",void 0),this.$store.setKey("accounts",[]),localStorage==null||localStorage.removeItem(Qh)}switchNetwork(t){var r;try{this.$store.get().provider&&((r=this.$providerMap[this.$store.get().provider])==null||r.switchNetwork(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?(this.disconnect(),new Error("The connected wallet doesn't support programmatic network changes..")):n}}checkInitializationComplete(){Object.values(this.$store.get().hasProvider).every(t=>t!==void 0)&&this.$store.setKey("isInitializing",!1)}watchNetworkChange(){this.$store.setKey("balance",void 0)}async getNetwork(){var t;return this.$store.get().provider&&this.$providerMap[this.$store.get().provider]?await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getNetwork()):this.$network.get()}async sendBTC(t,r){var n;if(r<=0)throw new Error("Amount must be greater than 0");if(!Number.isInteger(r))throw new Error("Amount must be an integer");if(!this.$store.get().provider)throw new Error("No wallet connected");if(this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.sendBTC(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support sending BTC..."):i}}async signMessage(t,r){var n;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((n=this.$providerMap[this.$store.get().provider])==null?void 0:n.signMessage(t,r))}catch(i){throw i instanceof Error&&i.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support message signing..."):i}}async signPsbt(t,r=!1,n=!1){var i;let o,s;if(!t)throw new Error("No PSBT provided");if(Dx(t))s=bt.fromHex(t).toBase64(),o=t;else if(jx(t))s=t,o=bt.fromBase64(t).toHex();else throw new Error("Invalid PSBT format");if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((i=this.$providerMap[this.$store.get().provider])==null?void 0:i.signPsbt(t,o,s,r,n))}catch(a){throw a instanceof Error&&a.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):a}else throw new Error("No wallet provider connected")}async pushPsbt(t){var r;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((r=this.$providerMap[this.$store.get().provider])==null?void 0:r.pushPsbt(t))}catch(n){throw n instanceof Error&&n.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support PSBT signing..."):n}}async getPublicKey(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getPublicKey())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}async getBalance(){if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{const t=await this.$providerMap[this.$store.get().provider].getBalance();return this.$store.setKey("balance",BigInt(t)),t}catch(t){throw t instanceof Error&&t.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):t}}async getInscriptions(){var t;if(this.$store.get().provider&&this.$providerMap[this.$store.get().provider])try{return await((t=this.$providerMap[this.$store.get().provider])==null?void 0:t.getInscriptions())}catch(r){throw r instanceof Error&&r.message.toLowerCase().includes("not implemented")?new Error("The connected wallet doesn't support this method"):r}}}const D$={hasUnisat:!1,hasXverse:!1,hasOyl:!1,hasMagicEden:!1,hasOkx:!1,hasOrange:!1,hasOpNet:!1,hasLeather:!1,hasPhantom:!1,hasWizz:!1,isInitializing:!0,connected:!1,isConnecting:!1,publicKey:"",address:"",paymentAddress:"",paymentPublicKey:"",balance:void 0,network:mt,library:null,provider:null,accounts:[],connect:async e=>{},disconnect:()=>{},requestAccounts:async()=>[],getNetwork:async()=>mt,switchNetwork:async e=>{},getPublicKey:async()=>"",getBalance:async()=>"",getInscriptions:async()=>[],sendBTC:async(e,t)=>"",signMessage:async e=>"",signPsbt:async e=>({signedPsbtHex:"",signedPsbtBase64:"",txId:""}),pushPsbt:async e=>"",inscribe:async e=>"",isCreatingCommit:!1,isInscribing:!1},Wb=tn.createContext(D$),M$=()=>tn.useContext(Wb);var Od={exports:{}},xa={};/**
58
58
  * @license React
59
59
  * react-jsx-runtime.production.min.js
60
60
  *
@@ -62,7 +62,7 @@ PROCEED WITH CAUTION!
62
62
  *
63
63
  * This source code is licensed under the MIT license found in the
64
64
  * LICENSE file in the root directory of this source tree.
65
- */var zb;function z7(){if(zb)return Ua;zb=1;var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(a,u,f){var h,d={},g=null,v=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(v=u.ref);for(h in u)n.call(u,h)&&!o.hasOwnProperty(h)&&(d[h]=u[h]);if(a&&a.defaultProps)for(h in u=a.defaultProps,u)d[h]===void 0&&(d[h]=u[h]);return{$$typeof:t,type:a,key:g,ref:v,props:d,_owner:i.current}}return Ua.Fragment=r,Ua.jsx=s,Ua.jsxs=s,Ua}var dl={};/**
65
+ */var zb;function F$(){if(zb)return xa;zb=1;var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(a,u,f){var h,d={},g=null,v=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(v=u.ref);for(h in u)n.call(u,h)&&!o.hasOwnProperty(h)&&(d[h]=u[h]);if(a&&a.defaultProps)for(h in u=a.defaultProps,u)d[h]===void 0&&(d[h]=u[h]);return{$$typeof:t,type:a,key:g,ref:v,props:d,_owner:i.current}}return xa.Fragment=r,xa.jsx=s,xa.jsxs=s,xa}var ul={};/**
66
66
  * @license React
67
67
  * react-jsx-runtime.development.js
68
68
  *
@@ -70,17 +70,17 @@ PROCEED WITH CAUTION!
70
70
  *
71
71
  * This source code is licensed under the MIT license found in the
72
72
  * LICENSE file in the root directory of this source tree.
73
- */var Wb;function W7(){return Wb||(Wb=1,process.env.NODE_ENV!=="production"&&function(){var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),E=Symbol.iterator,T="@@iterator";function x(P){if(P===null||typeof P!="object")return null;var j=E&&P[E]||P[T];return typeof j=="function"?j:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function I(P){{for(var j=arguments.length,G=new Array(j>1?j-1:0),ne=1;ne<j;ne++)G[ne-1]=arguments[ne];k("error",P,G)}}function k(P,j,G){{var ne=N.ReactDebugCurrentFrame,_e=ne.getStackAddendum();_e!==""&&(j+="%s",G=G.concat([_e]));var $e=G.map(function(Pe){return String(Pe)});$e.unshift("Warning: "+j),Function.prototype.apply.call(console[P],console,$e)}}var B=!1,W=!1,V=!1,Ue=!1,Le=!1,Je;Je=Symbol.for("react.module.reference");function Fe(P){return!!(typeof P=="string"||typeof P=="function"||P===n||P===o||Le||P===i||P===f||P===h||Ue||P===v||B||W||V||typeof P=="object"&&P!==null&&(P.$$typeof===g||P.$$typeof===d||P.$$typeof===s||P.$$typeof===a||P.$$typeof===u||P.$$typeof===Je||P.getModuleId!==void 0))}function Ye(P,j,G){var ne=P.displayName;if(ne)return ne;var _e=j.displayName||j.name||"";return _e!==""?G+"("+_e+")":G}function C(P){return P.displayName||"Context"}function F(P){if(P==null)return null;if(typeof P.tag=="number"&&I("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof P=="function")return P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case n:return"Fragment";case r:return"Portal";case o:return"Profiler";case i:return"StrictMode";case f:return"Suspense";case h:return"SuspenseList"}if(typeof P=="object")switch(P.$$typeof){case a:var j=P;return C(j)+".Consumer";case s:var G=P;return C(G._context)+".Provider";case u:return Ye(P,P.render,"ForwardRef");case d:var ne=P.displayName||null;return ne!==null?ne:F(P.type)||"Memo";case g:{var _e=P,$e=_e._payload,Pe=_e._init;try{return F(Pe($e))}catch{return null}}}return null}var oe=Object.assign,J=0,ue,Ae,Et,je,Ce,re,Ne;function L(){}L.__reactDisabledLog=!0;function He(){{if(J===0){ue=console.log,Ae=console.info,Et=console.warn,je=console.error,Ce=console.group,re=console.groupCollapsed,Ne=console.groupEnd;var P={configurable:!0,enumerable:!0,value:L,writable:!0};Object.defineProperties(console,{info:P,log:P,warn:P,error:P,group:P,groupCollapsed:P,groupEnd:P})}J++}}function Pn(){{if(J--,J===0){var P={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:oe({},P,{value:ue}),info:oe({},P,{value:Ae}),warn:oe({},P,{value:Et}),error:oe({},P,{value:je}),group:oe({},P,{value:Ce}),groupCollapsed:oe({},P,{value:re}),groupEnd:oe({},P,{value:Ne})})}J<0&&I("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var gt=N.ReactCurrentDispatcher,Nr;function At(P,j,G){{if(Nr===void 0)try{throw Error()}catch(_e){var ne=_e.stack.trim().match(/\n( *(at )?)/);Nr=ne&&ne[1]||""}return`
74
- `+Nr+P}}var Ht=!1,st;{var Dt=typeof WeakMap=="function"?WeakMap:Map;st=new Dt}function Er(P,j){if(!P||Ht)return"";{var G=st.get(P);if(G!==void 0)return G}var ne;Ht=!0;var _e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=gt.current,gt.current=null,He();try{if(j){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(Sr){ne=Sr}Reflect.construct(P,[],Pe)}else{try{Pe.call()}catch(Sr){ne=Sr}P.call(Pe.prototype)}}else{try{throw Error()}catch(Sr){ne=Sr}P()}}catch(Sr){if(Sr&&ne&&typeof Sr.stack=="string"){for(var Oe=Sr.stack.split(`
73
+ */var qb;function V$(){return qb||(qb=1,process.env.NODE_ENV!=="production"&&function(){var e=tn,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),E=Symbol.iterator,T="@@iterator";function x(P){if(P===null||typeof P!="object")return null;var j=E&&P[E]||P[T];return typeof j=="function"?j:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(P){{for(var j=arguments.length,G=new Array(j>1?j-1:0),ne=1;ne<j;ne++)G[ne-1]=arguments[ne];k("error",P,G)}}function k(P,j,G){{var ne=N.ReactDebugCurrentFrame,_e=ne.getStackAddendum();_e!==""&&(j+="%s",G=G.concat([_e]));var $e=G.map(function(Pe){return String(Pe)});$e.unshift("Warning: "+j),Function.prototype.apply.call(console[P],console,$e)}}var B=!1,z=!1,V=!1,Ue=!1,He=!1,Ge;Ge=Symbol.for("react.module.reference");function Fe(P){return!!(typeof P=="string"||typeof P=="function"||P===n||P===o||He||P===i||P===f||P===h||Ue||P===v||B||z||V||typeof P=="object"&&P!==null&&(P.$$typeof===g||P.$$typeof===d||P.$$typeof===s||P.$$typeof===a||P.$$typeof===u||P.$$typeof===Ge||P.getModuleId!==void 0))}function Ye(P,j,G){var ne=P.displayName;if(ne)return ne;var _e=j.displayName||j.name||"";return _e!==""?G+"("+_e+")":G}function C(P){return P.displayName||"Context"}function F(P){if(P==null)return null;if(typeof P.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof P=="function")return P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case n:return"Fragment";case r:return"Portal";case o:return"Profiler";case i:return"StrictMode";case f:return"Suspense";case h:return"SuspenseList"}if(typeof P=="object")switch(P.$$typeof){case a:var j=P;return C(j)+".Consumer";case s:var G=P;return C(G._context)+".Provider";case u:return Ye(P,P.render,"ForwardRef");case d:var ne=P.displayName||null;return ne!==null?ne:F(P.type)||"Memo";case g:{var _e=P,$e=_e._payload,Pe=_e._init;try{return F(Pe($e))}catch{return null}}}return null}var oe=Object.assign,J=0,ue,Ae,vt,je,Ce,re,Ne;function H(){}H.__reactDisabledLog=!0;function Le(){{if(J===0){ue=console.log,Ae=console.info,vt=console.warn,je=console.error,Ce=console.group,re=console.groupCollapsed,Ne=console.groupEnd;var P={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:P,log:P,warn:P,error:P,group:P,groupCollapsed:P,groupEnd:P})}J++}}function Tn(){{if(J--,J===0){var P={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:oe({},P,{value:ue}),info:oe({},P,{value:Ae}),warn:oe({},P,{value:vt}),error:oe({},P,{value:je}),group:oe({},P,{value:Ce}),groupCollapsed:oe({},P,{value:re}),groupEnd:oe({},P,{value:Ne})})}J<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pt=N.ReactCurrentDispatcher,Nr;function Et(P,j,G){{if(Nr===void 0)try{throw Error()}catch(_e){var ne=_e.stack.trim().match(/\n( *(at )?)/);Nr=ne&&ne[1]||""}return`
74
+ `+Nr+P}}var Lt=!1,st;{var Dt=typeof WeakMap=="function"?WeakMap:Map;st=new Dt}function Er(P,j){if(!P||Lt)return"";{var G=st.get(P);if(G!==void 0)return G}var ne;Lt=!0;var _e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=pt.current,pt.current=null,Le();try{if(j){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(Sr){ne=Sr}Reflect.construct(P,[],Pe)}else{try{Pe.call()}catch(Sr){ne=Sr}P.call(Pe.prototype)}}else{try{throw Error()}catch(Sr){ne=Sr}P()}}catch(Sr){if(Sr&&ne&&typeof Sr.stack=="string"){for(var Ie=Sr.stack.split(`
75
75
  `),Ze=ne.stack.split(`
76
- `),Ot=Oe.length-1,$t=Ze.length-1;Ot>=1&&$t>=0&&Oe[Ot]!==Ze[$t];)$t--;for(;Ot>=1&&$t>=0;Ot--,$t--)if(Oe[Ot]!==Ze[$t]){if(Ot!==1||$t!==1)do if(Ot--,$t--,$t<0||Oe[Ot]!==Ze[$t]){var en=`
77
- `+Oe[Ot].replace(" at new "," at ");return P.displayName&&en.includes("<anonymous>")&&(en=en.replace("<anonymous>",P.displayName)),typeof P=="function"&&st.set(P,en),en}while(Ot>=1&&$t>=0);break}}}finally{Ht=!1,gt.current=$e,Pn(),Error.prepareStackTrace=_e}var _o=P?P.displayName||P.name:"",Us=_o?At(_o):"";return typeof P=="function"&&st.set(P,Us),Us}function Ve(P,j,G){return Er(P,!1)}function wt(P){var j=P.prototype;return!!(j&&j.isReactComponent)}function Ar(P,j,G){if(P==null)return"";if(typeof P=="function")return Er(P,wt(P));if(typeof P=="string")return At(P);switch(P){case f:return At("Suspense");case h:return At("SuspenseList")}if(typeof P=="object")switch(P.$$typeof){case u:return Ve(P.render);case d:return Ar(P.type,j,G);case g:{var ne=P,_e=ne._payload,$e=ne._init;try{return Ar($e(_e),j,G)}catch{}}}return""}var nt=Object.prototype.hasOwnProperty,Lt={},Xr=N.ReactDebugCurrentFrame;function Jr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);Xr.setExtraStackFrame(G)}else Xr.setExtraStackFrame(null)}function On(P,j,G,ne,_e){{var $e=Function.call.bind(nt);for(var Pe in P)if($e(P,Pe)){var Oe=void 0;try{if(typeof P[Pe]!="function"){var Ze=Error((ne||"React class")+": "+G+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof P[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ze.name="Invariant Violation",Ze}Oe=P[Pe](j,Pe,ne,G,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ot){Oe=Ot}Oe&&!(Oe instanceof Error)&&(Jr(_e),I("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ne||"React class",G,Pe,typeof Oe),Jr(null)),Oe instanceof Error&&!(Oe.message in Lt)&&(Lt[Oe.message]=!0,Jr(_e),I("Failed %s type: %s",G,Oe.message),Jr(null))}}}var Mt=Array.isArray;function ze(P){return Mt(P)}function sr(P){{var j=typeof Symbol=="function"&&Symbol.toStringTag,G=j&&P[Symbol.toStringTag]||P.constructor.name||"Object";return G}}function wi(P){try{return rt(P),!1}catch{return!0}}function rt(P){return""+P}function Yr(P){if(wi(P))return I("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",sr(P)),rt(P)}var c=N.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0},p,m,S;S={};function O(P){if(nt.call(P,"ref")){var j=Object.getOwnPropertyDescriptor(P,"ref").get;if(j&&j.isReactWarning)return!1}return P.ref!==void 0}function U(P){if(nt.call(P,"key")){var j=Object.getOwnPropertyDescriptor(P,"key").get;if(j&&j.isReactWarning)return!1}return P.key!==void 0}function ce(P,j){if(typeof P.ref=="string"&&c.current&&j&&c.current.stateNode!==j){var G=F(c.current.type);S[G]||(I('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(c.current.type),P.ref),S[G]=!0)}}function ke(P,j){{var G=function(){p||(p=!0,I("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"key",{get:G,configurable:!0})}}function le(P,j){{var G=function(){m||(m=!0,I("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"ref",{get:G,configurable:!0})}}var ae=function(P,j,G,ne,_e,$e,Pe){var Oe={$$typeof:t,type:P,key:j,ref:G,props:Pe,_owner:$e};return Oe._store={},Object.defineProperty(Oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.defineProperty(Oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_e}),Object.freeze&&(Object.freeze(Oe.props),Object.freeze(Oe)),Oe};function me(P,j,G,ne,_e){{var $e,Pe={},Oe=null,Ze=null;G!==void 0&&(Yr(G),Oe=""+G),U(j)&&(Yr(j.key),Oe=""+j.key),O(j)&&(Ze=j.ref,ce(j,_e));for($e in j)nt.call(j,$e)&&!l.hasOwnProperty($e)&&(Pe[$e]=j[$e]);if(P&&P.defaultProps){var Ot=P.defaultProps;for($e in Ot)Pe[$e]===void 0&&(Pe[$e]=Ot[$e])}if(Oe||Ze){var $t=typeof P=="function"?P.displayName||P.name||"Unknown":P;Oe&&ke(Pe,$t),Ze&&le(Pe,$t)}return ae(P,Oe,Ze,_e,ne,c.current,Pe)}}var bi=N.ReactCurrentOwner,is=N.ReactDebugCurrentFrame;function Zr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);is.setExtraStackFrame(G)}else is.setExtraStackFrame(null)}var Ke;Ke=!1;function Pt(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function Qr(){{if(bi.current){var P=F(bi.current.type);if(P)return`
76
+ `),Pt=Ie.length-1,xt=Ze.length-1;Pt>=1&&xt>=0&&Ie[Pt]!==Ze[xt];)xt--;for(;Pt>=1&&xt>=0;Pt--,xt--)if(Ie[Pt]!==Ze[xt]){if(Pt!==1||xt!==1)do if(Pt--,xt--,xt<0||Ie[Pt]!==Ze[xt]){var en=`
77
+ `+Ie[Pt].replace(" at new "," at ");return P.displayName&&en.includes("<anonymous>")&&(en=en.replace("<anonymous>",P.displayName)),typeof P=="function"&&st.set(P,en),en}while(Pt>=1&&xt>=0);break}}}finally{Lt=!1,pt.current=$e,Tn(),Error.prepareStackTrace=_e}var Ao=P?P.displayName||P.name:"",Cs=Ao?Et(Ao):"";return typeof P=="function"&&st.set(P,Cs),Cs}function Ve(P,j,G){return Er(P,!1)}function yt(P){var j=P.prototype;return!!(j&&j.isReactComponent)}function Ar(P,j,G){if(P==null)return"";if(typeof P=="function")return Er(P,yt(P));if(typeof P=="string")return Et(P);switch(P){case f:return Et("Suspense");case h:return Et("SuspenseList")}if(typeof P=="object")switch(P.$$typeof){case u:return Ve(P.render);case d:return Ar(P.type,j,G);case g:{var ne=P,_e=ne._payload,$e=ne._init;try{return Ar($e(_e),j,G)}catch{}}}return""}var nt=Object.prototype.hasOwnProperty,Ht={},Xr=N.ReactDebugCurrentFrame;function Jr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);Xr.setExtraStackFrame(G)}else Xr.setExtraStackFrame(null)}function _n(P,j,G,ne,_e){{var $e=Function.call.bind(nt);for(var Pe in P)if($e(P,Pe)){var Ie=void 0;try{if(typeof P[Pe]!="function"){var Ze=Error((ne||"React class")+": "+G+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof P[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ze.name="Invariant Violation",Ze}Ie=P[Pe](j,Pe,ne,G,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Pt){Ie=Pt}Ie&&!(Ie instanceof Error)&&(Jr(_e),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ne||"React class",G,Pe,typeof Ie),Jr(null)),Ie instanceof Error&&!(Ie.message in Ht)&&(Ht[Ie.message]=!0,Jr(_e),O("Failed %s type: %s",G,Ie.message),Jr(null))}}}var Mt=Array.isArray;function We(P){return Mt(P)}function or(P){{var j=typeof Symbol=="function"&&Symbol.toStringTag,G=j&&P[Symbol.toStringTag]||P.constructor.name||"Object";return G}}function yi(P){try{return rt(P),!1}catch{return!0}}function rt(P){return""+P}function Yr(P){if(yi(P))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",or(P)),rt(P)}var c=N.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0},p,m,S;S={};function I(P){if(nt.call(P,"ref")){var j=Object.getOwnPropertyDescriptor(P,"ref").get;if(j&&j.isReactWarning)return!1}return P.ref!==void 0}function U(P){if(nt.call(P,"key")){var j=Object.getOwnPropertyDescriptor(P,"key").get;if(j&&j.isReactWarning)return!1}return P.key!==void 0}function ce(P,j){if(typeof P.ref=="string"&&c.current&&j&&c.current.stateNode!==j){var G=F(c.current.type);S[G]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(c.current.type),P.ref),S[G]=!0)}}function ke(P,j){{var G=function(){p||(p=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"key",{get:G,configurable:!0})}}function le(P,j){{var G=function(){m||(m=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",j))};G.isReactWarning=!0,Object.defineProperty(P,"ref",{get:G,configurable:!0})}}var ae=function(P,j,G,ne,_e,$e,Pe){var Ie={$$typeof:t,type:P,key:j,ref:G,props:Pe,_owner:$e};return Ie._store={},Object.defineProperty(Ie._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ie,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.defineProperty(Ie,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_e}),Object.freeze&&(Object.freeze(Ie.props),Object.freeze(Ie)),Ie};function me(P,j,G,ne,_e){{var $e,Pe={},Ie=null,Ze=null;G!==void 0&&(Yr(G),Ie=""+G),U(j)&&(Yr(j.key),Ie=""+j.key),I(j)&&(Ze=j.ref,ce(j,_e));for($e in j)nt.call(j,$e)&&!l.hasOwnProperty($e)&&(Pe[$e]=j[$e]);if(P&&P.defaultProps){var Pt=P.defaultProps;for($e in Pt)Pe[$e]===void 0&&(Pe[$e]=Pt[$e])}if(Ie||Ze){var xt=typeof P=="function"?P.displayName||P.name||"Unknown":P;Ie&&ke(Pe,xt),Ze&&le(Pe,xt)}return ae(P,Ie,Ze,_e,ne,c.current,Pe)}}var gi=N.ReactCurrentOwner,rs=N.ReactDebugCurrentFrame;function Zr(P){if(P){var j=P._owner,G=Ar(P.type,P._source,j?j.type:null);rs.setExtraStackFrame(G)}else rs.setExtraStackFrame(null)}var Ke;Ke=!1;function kt(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function Qr(){{if(gi.current){var P=F(gi.current.type);if(P)return`
78
78
 
79
79
  Check the render method of \``+P+"`."}return""}}function b(P){return""}var y={};function w(P){{var j=Qr();if(!j){var G=typeof P=="string"?P:P.displayName||P.name;G&&(j=`
80
80
 
81
- Check the top-level render call using <`+G+">.")}return j}}function A(P,j){{if(!P._store||P._store.validated||P.key!=null)return;P._store.validated=!0;var G=w(j);if(y[G])return;y[G]=!0;var ne="";P&&P._owner&&P._owner!==bi.current&&(ne=" It was passed a child from "+F(P._owner.type)+"."),Zr(P),I('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',G,ne),Zr(null)}}function _(P,j){{if(typeof P!="object")return;if(ze(P))for(var G=0;G<P.length;G++){var ne=P[G];Pt(ne)&&A(ne,j)}else if(Pt(P))P._store&&(P._store.validated=!0);else if(P){var _e=x(P);if(typeof _e=="function"&&_e!==P.entries)for(var $e=_e.call(P),Pe;!(Pe=$e.next()).done;)Pt(Pe.value)&&A(Pe.value,j)}}}function $(P){{var j=P.type;if(j==null||typeof j=="string")return;var G;if(typeof j=="function")G=j.propTypes;else if(typeof j=="object"&&(j.$$typeof===u||j.$$typeof===d))G=j.propTypes;else return;if(G){var ne=F(j);On(G,P.props,"prop",ne,P)}else if(j.PropTypes!==void 0&&!Ke){Ke=!0;var _e=F(j);I("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_e||"Unknown")}typeof j.getDefaultProps=="function"&&!j.getDefaultProps.isReactClassApproved&&I("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function H(P){{for(var j=Object.keys(P.props),G=0;G<j.length;G++){var ne=j[G];if(ne!=="children"&&ne!=="key"){Zr(P),I("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ne),Zr(null);break}}P.ref!==null&&(Zr(P),I("Invalid attribute `ref` supplied to `React.Fragment`."),Zr(null))}}var K={};function q(P,j,G,ne,_e,$e){{var Pe=Fe(P);if(!Pe){var Oe="";(P===void 0||typeof P=="object"&&P!==null&&Object.keys(P).length===0)&&(Oe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ze=b();Ze?Oe+=Ze:Oe+=Qr();var Ot;P===null?Ot="null":ze(P)?Ot="array":P!==void 0&&P.$$typeof===t?(Ot="<"+(F(P.type)||"Unknown")+" />",Oe=" Did you accidentally export a JSX literal instead of a component?"):Ot=typeof P,I("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ot,Oe)}var $t=me(P,j,G,_e,$e);if($t==null)return $t;if(Pe){var en=j.children;if(en!==void 0)if(ne)if(ze(en)){for(var _o=0;_o<en.length;_o++)_(en[_o],P);Object.freeze&&Object.freeze(en)}else I("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(en,P)}if(nt.call(j,"key")){var Us=F(P),Sr=Object.keys(j).filter(function(o9){return o9!=="key"}),Nd=Sr.length>0?"{key: someKey, "+Sr.join(": ..., ")+": ...}":"{key: someKey}";if(!K[Us+Nd]){var s9=Sr.length>0?"{"+Sr.join(": ..., ")+": ...}":"{}";I(`A props object containing a "key" prop is being spread into JSX:
81
+ Check the top-level render call using <`+G+">.")}return j}}function A(P,j){{if(!P._store||P._store.validated||P.key!=null)return;P._store.validated=!0;var G=w(j);if(y[G])return;y[G]=!0;var ne="";P&&P._owner&&P._owner!==gi.current&&(ne=" It was passed a child from "+F(P._owner.type)+"."),Zr(P),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',G,ne),Zr(null)}}function _(P,j){{if(typeof P!="object")return;if(We(P))for(var G=0;G<P.length;G++){var ne=P[G];kt(ne)&&A(ne,j)}else if(kt(P))P._store&&(P._store.validated=!0);else if(P){var _e=x(P);if(typeof _e=="function"&&_e!==P.entries)for(var $e=_e.call(P),Pe;!(Pe=$e.next()).done;)kt(Pe.value)&&A(Pe.value,j)}}}function $(P){{var j=P.type;if(j==null||typeof j=="string")return;var G;if(typeof j=="function")G=j.propTypes;else if(typeof j=="object"&&(j.$$typeof===u||j.$$typeof===d))G=j.propTypes;else return;if(G){var ne=F(j);_n(G,P.props,"prop",ne,P)}else if(j.PropTypes!==void 0&&!Ke){Ke=!0;var _e=F(j);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_e||"Unknown")}typeof j.getDefaultProps=="function"&&!j.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function L(P){{for(var j=Object.keys(P.props),G=0;G<j.length;G++){var ne=j[G];if(ne!=="children"&&ne!=="key"){Zr(P),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ne),Zr(null);break}}P.ref!==null&&(Zr(P),O("Invalid attribute `ref` supplied to `React.Fragment`."),Zr(null))}}var K={};function q(P,j,G,ne,_e,$e){{var Pe=Fe(P);if(!Pe){var Ie="";(P===void 0||typeof P=="object"&&P!==null&&Object.keys(P).length===0)&&(Ie+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ze=b();Ze?Ie+=Ze:Ie+=Qr();var Pt;P===null?Pt="null":We(P)?Pt="array":P!==void 0&&P.$$typeof===t?(Pt="<"+(F(P.type)||"Unknown")+" />",Ie=" Did you accidentally export a JSX literal instead of a component?"):Pt=typeof P,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Pt,Ie)}var xt=me(P,j,G,_e,$e);if(xt==null)return xt;if(Pe){var en=j.children;if(en!==void 0)if(ne)if(We(en)){for(var Ao=0;Ao<en.length;Ao++)_(en[Ao],P);Object.freeze&&Object.freeze(en)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(en,P)}if(nt.call(j,"key")){var Cs=F(P),Sr=Object.keys(j).filter(function(i9){return i9!=="key"}),xd=Sr.length>0?"{key: someKey, "+Sr.join(": ..., ")+": ...}":"{key: someKey}";if(!K[Cs+xd]){var n9=Sr.length>0?"{"+Sr.join(": ..., ")+": ...}":"{}";O(`A props object containing a "key" prop is being spread into JSX:
82
82
  let props = %s;
83
83
  <%s {...props} />
84
84
  React keys must be passed directly to JSX without using spread:
85
85
  let props = %s;
86
- <%s key={someKey} {...props} />`,Nd,Us,s9,Us),K[Us+Nd]=!0}}return P===n?H($t):$($t),$t}}function z(P,j,G){return q(P,j,G,!0)}function X(P,j,G){return q(P,j,G,!1)}var Z=X,te=z;dl.Fragment=n,dl.jsx=Z,dl.jsxs=te}()),dl}process.env.NODE_ENV==="production"?Cd.exports=z7():Cd.exports=W7();var R=Cd.exports;function q7(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function qb(e,t={}){let r=tn.useCallback(i=>t.keys?q7(e,t.keys,i):e.listen(i),[t.keys,e]),n=e.get.bind(e);return tn.useSyncExternalStore(r,n,n)}function G7({config:e,children:t}){const r=tn.useMemo(()=>new M7(qx(),Gx(e??{network:vt})),[e]),{address:n,paymentAddress:i,publicKey:o,paymentPublicKey:s,accounts:a,balance:u,connected:f,hasProvider:h,isConnecting:d,isInitializing:g,provider:v}=qb(r.$store),E={},T=qb(r.$network);return R.jsx(Vb.Provider,{value:{paymentAddress:i,address:n,publicKey:o,paymentPublicKey:s,library:E,network:T,accounts:a,balance:Number(u),connected:f,isConnecting:d,isInitializing:g,provider:v,hasLeather:h.leather??!1,hasMagicEden:h["magic-eden"]??!1,hasOkx:h.okx??!1,hasOyl:h.oyl??!1,hasOrange:h.orange??!1,hasOpNet:h.op_net??!1,hasPhantom:h.phantom??!1,hasUnisat:h.unisat??!1,hasWizz:h.wizz??!1,hasXverse:h.xverse??!1,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),getBalance:async()=>(await r.getBalance.call(r)??"").toString(),getInscriptions:async()=>await r.getInscriptions.call(r)??[],getNetwork:r.getNetwork.bind(r),getPublicKey:async()=>await r.getPublicKey.call(r)??"",pushPsbt:r.pushPsbt.bind(r),signMessage:async(x,N)=>await r.signMessage.call(r,x,N)??"",requestAccounts:async()=>await r.requestAccounts.call(r)??[],sendBTC:async(x,N)=>await r.sendBTC.call(r,x,N)??"",signPsbt:async(x,N,I)=>await r.signPsbt.call(r,x,N,I)??{signedPsbtBase64:"",signedPsbtHex:""},switchNetwork:async x=>{await r.switchNetwork.call(r,x)}},children:t})}const X7=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"white",style:{fill:"white",fillOpacity:1}})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"white",style:{fill:"white",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}})]}),Gb=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#12100F"}),R.jsx("path",{d:"M74.9171 52.7114C82.4766 51.5408 93.4087 43.5804 93.4087 37.3761C93.4087 35.5031 91.8968 34.2154 89.6871 34.2154C85.5004 34.2154 78.4061 40.5368 74.9171 52.7114ZM39.911 83.4991C30.0256 83.4991 29.2115 93.3324 39.0969 93.3324C43.5163 93.3324 48.8661 91.5764 51.6573 88.4157C47.5868 84.9038 44.2141 83.4991 39.911 83.4991ZM102.829 79.2848C103.41 95.7907 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.0249C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8463 40.0273 72.8463C45.3771 72.8463 49.9128 74.2511 55.7277 77.88L59.5656 64.4177C43.7489 60.0864 35.8405 47.9118 43.6326 30.4693H56.1929C49.215 42.0586 53.9832 51.6578 62.822 52.7114C67.5903 35.7372 77.8246 22.509 91.4316 22.509C99.1074 22.509 105.155 27.5428 105.155 36.6737C105.155 51.3066 86.0819 63.2471 71.6607 64.4177L65.7295 85.3721C72.4748 93.2153 91.199 100.824 91.199 79.2848H102.829Z",fill:"#F5F1ED"})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#F5F1ED"}),R.jsx("path",{d:"M74.9171 52.7115C82.4766 51.5409 93.4087 43.5806 93.4087 37.3762C93.4087 35.5032 91.8968 34.2155 89.6871 34.2155C85.5004 34.2155 78.4061 40.5369 74.9171 52.7115ZM39.911 83.4992C30.0256 83.4992 29.2115 93.3325 39.0969 93.3325C43.5163 93.3325 48.8661 91.5766 51.6573 88.4159C47.5868 84.904 44.2141 83.4992 39.911 83.4992ZM102.829 79.2849C103.41 95.7908 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.025C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8464 40.0273 72.8464C45.3771 72.8464 49.9128 74.2512 55.7277 77.8801L59.5656 64.4179C43.7489 60.0865 35.8405 47.9119 43.6326 30.4695H56.1929C49.215 42.0587 53.9832 51.6579 62.822 52.7115C67.5903 35.7373 77.8246 22.5092 91.4316 22.5092C99.1074 22.5092 105.155 27.5429 105.155 36.6738C105.155 51.3068 86.0819 63.2472 71.6607 64.4179L65.7295 85.3722C72.4748 93.2155 91.199 100.825 91.199 79.2849H102.829Z",fill:"#12100F"})]}),J7=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#AB9FF2",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#FFFDF8",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}):R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#FFFDF8",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#AB9FF2",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}),Y7=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_3_53)",children:[R.jsx("path",{d:"M32 0H10C4.47715 0 0 4.47715 0 10V32C0 37.5228 4.47715 42 10 42H32C37.5228 42 42 37.5228 42 32V10C42 4.47715 37.5228 0 32 0Z",fill:"#181818"}),R.jsx("path",{d:"M32 31.6745V27.6829C32 27.5233 31.9203 27.3636 31.8406 27.2438L14.8225 10.1597C14.7029 10.0399 14.5435 10 14.3841 10H10.3986C10.1993 10 10.0399 10.1597 10.0399 10.3592V14.0715C10.0399 14.2311 10.1196 14.3908 10.1993 14.5105L16.2971 20.6177C16.4565 20.7774 16.4565 20.977 16.2971 21.1366L10.1196 27.3237C10.0399 27.4035 10 27.4834 10 27.5632V31.6346C10 31.8342 10.1594 31.9939 10.3587 31.9939H17.0544C17.2536 31.9939 17.413 31.8342 17.413 31.6346V29.2396C17.413 29.1598 17.4529 29.0401 17.5326 29.0002L20.8406 25.6871C21 25.5275 21.1993 25.5275 21.3587 25.6871L27.4964 31.8342C27.6159 31.954 27.7753 31.9939 27.9348 31.9939H31.6413C31.8406 32.0337 32 31.8741 32 31.6745Z",fill:"white"}),R.jsx("path",{d:"M23.3406 15.0793H26.5592C26.7507 15.0793 26.9039 15.2333 26.9039 15.4257V18.658C26.9039 18.9658 27.2871 19.1197 27.4788 18.8888L31.8851 14.4637C31.9617 14.3867 32 14.3097 32 14.2328V10.3463C32 10.1539 31.8468 10 31.6552 10H27.7469C27.6703 10 27.5554 10.0385 27.5171 10.1154L23.1107 14.5021C22.8808 14.6945 23.0341 15.0793 23.3406 15.0793Z",fill:"#EE7A30"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"clip0_3_53",children:R.jsx("rect",{width:"42",height:"42",fill:"white"})})})]}),Z7=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#b)",d:"m25.517 9.483 5.759 5.611c.49.477.731.959.724 1.445-.008.486-.219.929-.631 1.33-.431.421-.897.634-1.395.644-.497.007-.992-.228-1.482-.705l-5.89-5.738c-.669-.652-1.315-1.114-1.936-1.385a2.873 2.873 0 0 0-1.96-.127c-.685.185-1.42.662-2.21 1.428-1.086 1.06-1.605 2.054-1.552 2.983.053.929.593 1.893 1.617 2.89l5.938 5.786c.496.482.74.964.732 1.443-.008.48-.22.923-.64 1.332-.419.408-.88.62-1.382.638-.502.016-1.001-.217-1.495-.7l-5.76-5.61c-.936-.912-1.613-1.776-2.029-2.59-.416-.815-.572-1.737-.464-2.765.097-.88.384-1.732.863-2.558.477-.827 1.161-1.671 2.048-2.537C15.43 9.268 16.438 8.48 17.4 7.93c.96-.55 1.889-.854 2.786-.917.899-.064 1.784.112 2.66.527.876.415 1.765 1.061 2.67 1.943h.002Z"}),R.jsx("path",{fill:"url(#c)",d:"m16.482 32.123-5.758-5.611c-.49-.479-.731-.959-.724-1.445.008-.486.219-.929.631-1.33.431-.421.897-.634 1.395-.644.498-.007.992.227 1.482.705l5.888 5.738c.671.652 1.315 1.114 1.936 1.385.622.27 1.276.312 1.962.127.685-.185 1.42-.662 2.21-1.43 1.086-1.06 1.605-2.054 1.552-2.983-.053-.929-.593-1.893-1.617-2.891l-3.164-3.056c-.496-.482-.74-.964-.732-1.443.008-.48.22-.923.64-1.332.419-.408.88-.62 1.382-.638.502-.016 1.002.217 1.496.7l2.983 2.88c.936.912 1.613 1.775 2.03 2.59.415.815.571 1.736.463 2.764a6.477 6.477 0 0 1-.863 2.559c-.477.826-1.16 1.67-2.048 2.536-1.057 1.03-2.066 1.819-3.027 2.368-.962.55-1.89.856-2.79.92-.898.063-1.784-.113-2.66-.527-.876-.415-1.765-1.062-2.67-1.944l.003.002Z"}),R.jsx("path",{fill:"url(#d)",d:"M20.073 17.645c1.168 0 2.115-.93 2.115-2.08 0-1.149-.947-2.08-2.115-2.08-1.168 0-2.115.931-2.115 2.08 0 1.15.947 2.08 2.115 2.08Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"b",x1:30.329,x2:12.579,y1:12.752,y2:20.772,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#201C1B"}),R.jsx("stop",{offset:.36,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4B852"})]}),R.jsxs("linearGradient",{id:"c",x1:12.163,x2:32.789,y1:29.085,y2:22.844,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#1F1D1C"}),R.jsx("stop",{offset:.37,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4FB52"})]}),R.jsxs("radialGradient",{id:"d",cx:0,cy:0,r:1,gradientTransform:"matrix(2.11484 0 0 2.08019 20.073 15.567)",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#F4B852"}),R.jsx("stop",{offset:.33,stopColor:"#EA8101"}),R.jsx("stop",{offset:.64,stopColor:"#77390D"}),R.jsx("stop",{offset:1,stopColor:"#211C1D"})]}),R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Q7=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsxs("g",{fillRule:"evenodd",clipPath:"url(#b)",clipRule:"evenodd",children:[R.jsx("path",{fill:"#FFD815",d:"m26.507 17.74-1.623-1.623-1.624 1.623 1.623 1.623 1.624 1.624 1.623-1.624-1.623-1.623Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 8-1.624 1.623 1.624 1.624 1.623-1.624L26.507 8ZM33 14.493l-1.623-1.623-1.624 1.623 1.624 1.623L33 14.493ZM23.26 27.48l1.623 1.623 1.624-1.623-1.623-1.624-1.624 1.624ZM11.897 16.117l1.623 1.623 1.623-1.623-1.623-1.624-1.623 1.624ZM20.014 8 18.39 9.623l1.624 1.624 1.623-1.624L20.014 8ZM13.52 11.247l1.624 1.623 1.623-1.623-1.623-1.624-1.624 1.624ZM31.377 19.363l-1.624 1.623 1.624 1.624L33 20.987l-1.623-1.624ZM28.13 25.856l1.623 1.624 1.624-1.624-1.624-1.623-1.623 1.623Z"}),R.jsx("path",{fill:"#5B5B72",d:"m26.507 20.986-1.624-1.623-1.623 1.623-1.623-1.623-1.623-1.623 1.623-1.624-1.623-1.623-1.624-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623 1.623-.812-.811-1.623 1.623 1.623 1.623-1.623 1.624-1.543 1.542-1.542 1.543-1.624 1.623L8 31.377 9.623 33l1.624-1.623 1.623-1.624 1.543-1.542.08-.08 1.462-1.463.08-.08 1.544-1.543 1.623 1.623 1.623-1.623-.811-.812 1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 14.493-1.624-1.623-1.623 1.623-1.623-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623 1.623 1.623 1.623-1.623-1.623-1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"})]})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M8 8h25v25H8z"})})]})]}),e9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("g",{fill:"#fff",clipPath:"url(#b)",children:R.jsx("path",{d:"M24.578 17.052h-6.787a.523.523 0 0 0-.52.52v6.788c0 .286.235.52.52.52h6.787c.286 0 .521-.234.521-.52v-6.787a.523.523 0 0 0-.52-.521ZM16.733 9.223H9.946a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.285 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM32.424 9.223h-6.787a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.286 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM16.733 24.898H9.946a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.285 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52ZM32.424 24.898h-6.787a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.286 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52Z"})})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),t9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,className:r,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_17_93)",children:[R.jsx("path",{fill:"#070C34",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#paint0_linear_17_93)",d:"m27.666 16.837 1.874 2.177c.215.245.404.446.483.562.56.55.874 1.293.874 2.07-.053.915-.657 1.54-1.213 2.205l-1.311 1.521-.685.79a.184.184 0 0 0 .046.281c.033.02.07.028.107.026h6.835c1.045 0 2.36.868 2.283 2.184 0 .597-.247 1.171-.68 1.595a2.36 2.36 0 0 1-1.637.664H23.936c-.704 0-2.598.076-3.128-1.521a1.841 1.841 0 0 1-.043-1.035 4.5 4.5 0 0 1 .72-1.404 65.543 65.543 0 0 1 1.695-2.343c.741-1.002 1.503-1.971 2.251-2.992a.19.19 0 0 0 .04-.116.19.19 0 0 0-.04-.116l-2.72-3.156a.192.192 0 0 0-.153-.073.192.192 0 0 0-.152.073c-.728.96-3.917 5.203-4.598 6.063-.68.86-2.355.907-3.283 0l-4.255-4.161a.197.197 0 0 0-.1-.053.195.195 0 0 0-.2.082.192.192 0 0 0-.032.106v8a2.678 2.678 0 0 1-.494 1.594c-.33.466-.804.823-1.352 1.014a2.375 2.375 0 0 1-2.111-.293 2.271 2.271 0 0 1-.72-.805A2.22 2.22 0 0 1 5 28.736V14.349a2.416 2.416 0 0 1 .548-1.422c.33-.406.785-.7 1.298-.841a2.632 2.632 0 0 1 2.502.664l6.54 6.381c.019.02.043.034.07.043a.197.197 0 0 0 .161-.013.188.188 0 0 0 .061-.054l4.646-6.27c.215-.254.485-.46.79-.601.304-.142.636-.217.976-.221H34.68c.33 0 .657.07.959.204a2.31 2.31 0 0 1 1.263 1.409c.096.309.122.633.079.952a2.288 2.288 0 0 1-.813 1.42c-.439.364-.996.56-1.572.551h-6.768a.188.188 0 0 0-.163.099.187.187 0 0 0-.022.095c0 .032.013.065.032.093h-.008Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"paint0_linear_17_93",x1:"-0.315",x2:"35.366",y1:"9.343",y2:"30.176",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{offset:"0.23",stopColor:"#FF0074"}),R.jsx("stop",{offset:"0.26",stopColor:"#FF0068"}),R.jsx("stop",{offset:"0.32",stopColor:"#FF0048"}),R.jsx("stop",{offset:"0.39",stopColor:"#FF0015"}),R.jsx("stop",{offset:"0.41",stopColor:"#FF0009"}),R.jsx("stop",{offset:"0.43",stopColor:"#FF0908"}),R.jsx("stop",{offset:"0.54",stopColor:"#FF4003"}),R.jsx("stop",{offset:"0.62",stopColor:"#FF6201"}),R.jsx("stop",{offset:"0.66",stopColor:"#FF6F00"}),R.jsx("stop",{offset:"0.72",stopColor:"#FF8700"}),R.jsx("stop",{offset:"0.83",stopColor:"#FFAB00"}),R.jsx("stop",{offset:"0.92",stopColor:"#FFC100"}),R.jsx("stop",{offset:"0.98",stopColor:"#FFCA00"})]}),R.jsx("clipPath",{id:"clip0_17_93",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),r9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:e,height:e,viewBox:"0 0 42 42",...n,children:[R.jsxs("defs",{children:[R.jsx("clipPath",{id:"clip1",children:R.jsx("path",{d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "})}),R.jsxs("radialGradient",{id:"radial0",gradientUnits:"userSpaceOnUse",cx:0,cy:0,fx:0,fy:0,r:1,gradientTransform:"matrix(0.000000000000001938,31.643555,-31.643555,0.000000000000001938,21,5.578125)",children:[R.jsx("stop",{offset:0,style:{stopColor:"rgb(5.098039%,5.490196%,7.058824%)",stopOpacity:1}}),R.jsx("stop",{offset:1,style:{stopColor:"rgb(0%,0%,0%)",stopOpacity:1}})]}),R.jsx("image",{id:"image91",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAIOUlEQVRYhe2YW4jcVx3HP+fyv8785z+XveUm040xaWraitaHFmkfpKCI6LMgLWq9IUUpiA9CwRdfiqBPtbbWy5MKhRbxnuZFRUSMxhBr2nR6Sdrd2ezOzs7szP9yzvFhdus2TEzWJD7l+zQw53/Oh+/vcjg/uKmbuqmbuqlrkbhB+8o2+CFUUoj6EEWgAQ/Ah2IMpQcbS5C9CkMg/3+Cyjb4GpIE4gLSCsROkyKJLCilAEHpWwbS0M8LNvrQG0KvAxngbiTo2wBzaISahpGknqTxxGE1RLoPSCkWcIwN7p9hYX/54Asc0YKLOuPNElYL6P0J+jcCVLQhKCFOoQo0Ak3NSGaUZPbJI2qolXvECXHnlG83TemeeOxf9jcvlXh+zvk+LC9B9wJsXk9Qrw2VBsQWGnriYAvJ7FOH6ChfPSIE91/pDGF57tNnzO8Cy8tRxusZLGdw8Y8wulZQeRgqGioGalWol4pZJ5n77iKnKon6jIVPAuHVbmgL99jDZ+252PCyzni1AW8uwvBRGL916G4A2xC+E1oRtBTsjTW3FB6HF2PUj2+TrShRz1p4aDeQANITn/pWmxdKzXwY0ahCDISnwd9eo69iH9HeysPKVh4qTVNK5oxg9odH1UUh3TecELfvBu4S1YUv3++UHStHWvjUKj7ZiQHl821k0sJcCVQuQpJCRUBqoYnPjJPMf+8Q5zxfPegE94O45u4h4BCWV0pN4kHse4RH6+TeALHBf3fU2w+JDzULc2I7D2/hVCVRH7aObztBcK2Ab4EKAqEIlCASkghDMLJ4PeBjUFwO1HsHVJtQk7BgfPYeDBl//aDcJ6X4poW5631VGMuKAO05VAAq9FAzErWi4LfruKmg+0HLSagXrE/7+0c47/nqMeCu64s3kXMUFPaMZ2kriUsDpK/xuhnBLGSHUsTUqs8gDaFlFXuevJVz2lc/uFGQAM7y+6+8xj2BoKhpjK9xkUMuhojcw39hk2AqaAoVH1KjWQi0+pqAW24UJM69bo15JpYM6ophYskrAtP0EP0YX1nkYnwZR0tIjKLxs8P8A8FHbhikdWeKsf3OV1/mfVXJeiLpJyGjhocFSD1EWIdzGj01R32olpJ6oeSt8up67a7kHD1n3XOPv277ZzPuqCuWZwQrDUV/XrM5F5LrEreaIRohbHqoqRAStIVQKnHg+hKSO2uP58Yd//JL3BspaGi6s4qlpsdaXdGvK8ZNR+4iysEIt33FTQV1IAVojSvK69OHnLXur6a0z37hJe6OFXc1PN6oC1Ybkm7dY63hc3HWsZEKRmODnSsxmcD1AJddpj0BTkgsjrPXymmte8VYnvn8WXssktzRUlxINOtVyWoq6DV91usevaZjY49g5DvyekzZHeH2B+QXMhziMo7mYHxLMSrsSc9T6wjSXRM61p11P3/8Nds/NeJgy+N8LOinirUU1hKf/oxgPQgYzVoGM5KRceR7fcbnR7h9AdmFDOfJSWFN9esgvNdTvKsQvPund8hEC/GlXQDmztrj49I9//A57qsq1iqKfl2ylkCv7rOeKjbSkEHdMYgtxYJi2DeYGUeWCdzMDsh2SNEdgpp2VgqpllSlJPzbqjv/waasIK/YSx2WvxSlefJzL3LgxDozDc1KU9KdlSzNKJZnQ7rzMavzgn7VMJqHYaoZeZBXLIWRGOnIhxa7GJMXGbZbQCZwU0FjiJRDe4JwxdL+eOCekr6QUoojTEsX614sS55+6KxNjq9TTxUXm5qVumKppVieDViZ16w0fQZzJcMFGLY8htKjqOdkQzCxIyvAlAo7YykubAFmY+xRTT419A1IF2DOwn5f0baKtpXs/dERfq2Q9wopDipBaKy9WFpx5osv2veEgmGsGMSCjZpmvQ69xKdfE6zXAsbzgmFLMKpCtiGxiaUsS8y+kHFnDEphZg1FF7ACl4+wx0KKHtDpXCZH2xCOoNaA+QjmpWKfUewVihaCVAgCZVFK4gJJEQpGFcFmRdBvSjZqIesVwaAZMW5YhrGjmFcMNkpsVVEGhtJITGgphhLbsuTbgGYTl4wpjMD1etADhmCnVn0HsvugfxrkASi1wcSKgRDMCEcqJaH2UNpCJCgriix1jFKPfkMxjAKyBclAG0wDxqEm146iBWbksB7kpcO1KmR2CF2gGGG3AZfWcUvgMnAJuHugvGyXdCCOQLU+eb/Uqh71miIpJUkoCYXDqypcoBBVQdHyGDcjxg1N5hlMXTD2FIUwmKqlGEnsnE/+5iVh3gm40ns74F1QdoBT4K7UzsV9UGmDthE1rYlSjR8pvMwQxwEqFbhEYGcEpe9jW4rCCRyWMjGUmcDtD8gul4cHxhSdHnTBbYDdBjwBbOyYmlzVvfMohBF4pkqofIKaRYceXsUhIx9RGHTFh5ai9H3IczBbDo7HMJTYd0Tk3eFkyFSMsEcj8k4POr1JDvpgpwGubv2+6gvyNPjLILsQHAKxXMXfHyHXSvy4jhAjRBhOkj9k8iBXCgMwrZpPdiZrV8Fsu/jcFMBdOfoW7G348RD59w6eraOCEM8ZVJvJW7pSgXMZej6gXMrQSUkJb3dxu910JyBmZx5eCrlnt6HfqZ/chj88jXygDb/o4++xyDvr8Ac1GRYoO9lTOoQVk4N29sSTnUmoE3C3Q3GC/4R6p4vbkJ+FAnY3KQFgMcS9AvbpDnyoRv6GxJ7swdGE/O6EPFdYI3GFwuYj7GFHdiycFMyfO7gh2E9AXtuCnKZLIeF/HJI9Dl4G8hiIB9rwqwHeG1VUfev/+iXrOz0oBW5zDftRKDrANuSlbk6DBPg3vtO3svqbCX0AAAAASUVORK5CYII="}),R.jsx("filter",{id:"alpha",filterUnits:"objectBoundingBox",x:"0%",y:"0%",width:"100%",height:"100%",children:R.jsx("feColorMatrix",{type:"matrix",in:"SourceGraphic",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})}),R.jsx("image",{id:"image170",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACtklEQVRYhWNgGAWjYBSMglEwCkYcmGslLagZ26TedkTUMOD/H11nY2a5Sb+/sJBiBiOtHMfAwMCg73JCaNrNdN2kh/eF0eXKFXf+qZBhvfbqqMkdYsxior7zGBjUK65yXtwsbBq4/7wDNkcyMDAwdN53ZxE87KQX4tNtRIyZVA1Rc3M7ZpZn5eoNd1lVc1hCmInVJ7ov4fwRl0n38amhWoiyP3kmPbfVyfXNw0gNUhzJwMDA8D/3q1bnt2a8bqE4RFPWPhRMLPDTwxXFxIKtN84cUdFSe4VLnuwQhaVDmbBtjpQ6koGBgWHPo6d8+ORJKiIYGBDp0CgsQTXM4Dczw+9y8l2HBB4kJFEv6p2NmeVYi1m170ewcVLmLEzw6HHhye/yjU9xyRMV9XaXNnLcmHTA9slpbhNaONLtgvpfZV5TnOmTgYGIEP3LGciWdPSB/QmDu7zUcxoquNv66c6fWoZL+NQQDNFwZysdWjpS8mnzhzsL664RUoc3M9ld2sixVWiFvBz13IUC2HjqXtzv4z+jcCf/DyG1eKOeb66bnGTiCRPqOQ0Ccpjzvq3gTr5y9IviE2L14I163YZ8HsqdhQDP3hn9vf8m5tq3r+y7SHEkAwOBqH/ncPYvZU6DgEjWToYZ/8UefWbsusrwd9p3ckpevCEqdNL9E5lug4N58opvn6zy2v/iX/AZhr8nv5NrDl6H7vx0/ZXyhqBf5BisuOLXdxnTr2esH188OCdY/j15zkMAguUoX8haFclViXrEGvjsndHfn/+0bjbzSN4q56r9R5nzEICoKlQvzsrk54IreEspWDp8wdh1lZIoxgWIrusrJBTVpl6R15QSOofR1qzc+eH1kW+Pr1AjiqkCJv3+wuJszCwnwaeq23ZE1JC9Q0ktq+09/0C7axSMglEwCkbBKKA/AABq8ekilgplTAAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask0",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("use",{xlinkHref:"#image170"})})}),R.jsx("image",{id:"image125",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEF0lEQVRYhe2WTYscVRSGn3NvVXdPzySabwQN2SlGkQgjCC4EFWMU/A+CG925EhN0JSiof8BtxC8SSVZZiK7MRjRElPwEF8Ik0z3d9XXPOS6qJhM1pHucGXHRLxRFN9Sth/d977kFCy200EILLfR/kvwXL/n69NFvs6Y56MmGjUIlsU55TK9998eT866xp6DfvHTkcm9Snop1epBkqDuNQulCHWNT9Xq/s5FOv/7rxo1Za2V7AXjhzLEv+pPy5ODm+KSoSlQDdZI5GCQVCtdcKzuuw/5V4MCsNXfV0S9feeD8YKM4vlKVq5J0kJsR3Ajq4JAcygSjBOMkbEhEl3Ky+5dGb/6wdt+91t41Ry8+f+jS8tr6M3nTHNwEjO5EBxdwQFwIAcBxcxSjqY1Q6vKs9XcMevHMka+WxtPV/mh8IqiSWwcISJdXCIFkYIB5+5/jaHJSdIJa3DPQCy8f+3w4nj7auzl6PDYq0YzMncwcCYBDkIAByaAxaBxq2/pdG6iC2ez3bRv0dg/X1p8KSfu5GcGMgBMFEBAEFyG1ewg1qB3qBJVCqU6lLbDOCbEt0AvPHbyyf219Nd7Rw+BOJrQOGnjnYrfRW/e8A0zOVJ0iQaFQK7hu1WHHoJ+9ePTKynjy8HC0cSIzpff3HhpICLc7qNbu8Mah0TbmonEKc6YJxg1MGiikBWiH1g5Bz79w7Pul9Y3Hsro+nJkykLv38E4HN11sNmO21sVJgo0E0wSlQQpCiELMg+4Y1CfFQxTN4dyULBhBWhfv1sOmm5W1Qp2c0pxSaSEVyqaNfCqCBSH2I/kg03wQZ87ze4J++uzhn8NocsJUMTcQcAOTgPtfY07eRlwlpzYo7ujitLuXBjWCx0DWjwxX8rRvf+5vXV3r7Qg01WlfXVmM6m2sgAQB6SB9K+5aodqMWWHadIDWXgnBsoDkgf4g08Ew0+u/jT++DO/MgpwJqrUNK3OkcfIAwQR1QLbibiHbmKvOvYlCqVAZ1CZoDHge6PWi5ctZWh5mcvanW/15AOcCTU5UBVOQbozkAuCdm23MlbbRFtqe5UWCMggmAoNA7EUfLGVpaZhx7tr6tgDnArUQaFyoVUjm1Or0usPuzsgLawHL7rSpRPAQyHqRwXKWloaZvXt99K8A5wINecg0hFQgWZmEQpzYQOiiT9qC1d7GnOSfPfzlxviDS8Z7O4GEOT7z3n9i/6hcr/bV0wZJRugect8aRykIEgOSBXr9aPnwdg9n7uZdA3018MapR1Y+KTaaflMlUmrnknePexQkD/Ty6P1hloZLkXPX1ncNcG5QgI+ePlSMxrVURerVlYl3oCEIsRfo92MaDqKf3QPAbYFu6sPVA1XdKEk9OEgWxXt54O0fb+V7BbjQQgsttNBC/0/9CbvrotNPsOneAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image142",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAAmklEQVRYhe2U0QqAIBAE1/7/n+tFIaQyur21aAdEX4RhDgWMMemUul7BkciZ3JopMqKXGhWcJltOzldMkS3dfhe5bOTBSGWXwF3pjxARBYSyUVFAJMsQBQSyLNF0mKKpVdlF02R/OfpGStWsonTZX4++Qa3qohVaVRfdQanqoh3hqi7KRikaGr+LslGLPh6/i7KxKBuLsvmM6AZK+AVU/UCtAQAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask1",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.6,stroke:"none"}})})}),R.jsx("image",{id:"image148",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEI0lEQVRYhe3XTW4kuREF4I9kZqX+7B61gAFGR5CWPsucZ9zn6Sv4Ct5ZfQAv1IABuaftaUlVmWR4kZS6tPKitBjDegCRZBaT9RA/Lxi84Q1veMMbDkF6msTTPPChz28kP+NTX99+3/+MSwGuhI+47utfhETS169BNEgvCF5JPkluJZeSO8lF/+3rHtl3ncSdcCHcCpfCjXAtXpPs8ILkjeRa8kVyJ7uUkE0SknvJuz2idzgWJg3hUkNzLlxpPiBEJOlQsilI/txJnu+RI7tXJPl5TJKtZJaMwiRshdCE5lhF8141aT4LNL+IlA4jml+QnGRfFQwejE6Mso1qMplwpDl2tj6POTKZVJNs49GIwd8NPituJVfSc0gdgAFcd9d+lb1T/GpwrPhmlAyKwaKoiiy7lxTxsNX626paDDJmZ9At/hd80Q4lmt30pCErsgdFMUg2Tm1kR5IjyYlwKpwa+zOcSk40xzbdst9sMLhXDD2Ufj6UJsOe/GRniq3BHwxmG4uNbFKMFhvJICua1L+omA3mHsfJpsflieY3zZ32LG8HEf0keS/5Z0+gSTEbVWNfTZpJ6cRDUSRNqKowS7bmrh5VM/dwyKqLZ48dSPR2T3pWCsXOIPdEaibVUSe9urVKslAsmkHuKlBVG7MHA93Kt3KXrQOJ/gnfJA/dootiUIRBMqg2hp75q2WH7vjAIssDbVlUYbE1SP2cU0k93Jor0c/doqw2mCRNlrtMMQijbBRGYUDWRElSJRYWydzTsXhUjJLHfu7d4WTz8+xYspEsUo/B78KvOzo6kbyGSE2KppT9fbV/v3StuH8di+b/vuX3ge9EH4SdMAhVyF1mnsYabVXrI9QSa2bX/X2lfz8Ij8LJ69yesp+EP/bDRmHutbuqWDzFXzMXdpoZO9murlV/HWHp9WmVplk46udevMLtyV+td8roFhlUO1W2CItit+a2VJNQ1C74a9aHnWRnsFN7mZi79R+Ef4leUg8keim8F/4h/KiiShbVjNKTg6RZVHlP8Jsqm4WtpRN+tGiq0ndcam5fw6JXwifhx27RrWoy00siqxgtandz2RP8JptVs9HWbKeYHVlQewmN5y7gIKIfcd4vvb+piuTfXU/HnhBh0SxjUebaLVp7smXLJsy7MCt2dmajxb2qai6Eq9cguvY4659WyZnqV0kI30SX/8Fonmu/SDdPJaIJdRe95ofFqRmLE9Vd99LHQ2k+ydNN73cWzVfVD6sFLXaKrerR4MHkXnP/4jl4UD0abTU7T0qxhlF77p8OxP9QK8La2l6LfhNvflLdqU7Mjs0WO5Ote1uTrTOPJlt3/f1i57i7nMXfNOf9rN6JHoohWbtEIXwA4Vzq7W9yqdlKziQnXrbLT0K+Fc722uUvXUleubd/wxve8IY3/B/gP+5/MI8x65+AAAAAAElFTkSuQmCC"}),R.jsx("mask",{id:"mask2",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.701961,stroke:"none"}})})}),R.jsx("image",{id:"image154",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAA/ElEQVRYhe2VwW7DIAxAn9M0qcSN///G3JDaFEIPwRvqoUHdWKXJT/IhMokeNiZgGIZhGIZh/EPkVTLnLGWNxvD0Ti6xAVlEtk6eDA1rBDgBZ2ACZu/9DMzleSz5lm+9zVFFh0pyrELYK5m89/dlWSIQRWT9lOipiE1VnCvRCKwaInLtJXrULj2Xdesn4EJpvXPuT1o/NqxR2Vp4YB+gLYSgki+781PeqUL+dYsGWkT1+tmAxH4uNZJzLpVc1w0ctV4lE3Dne4i+himEEEu+2x0KxxV9Fr0B1ypu3vuVvbpdRVv+TDpEGvXmdBMJ2EQkdvI0DMMwDMMwjI/yAInrT4nWGUiJAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image160",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("mask",{id:"mask3",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.2,stroke:"none"}})})}),R.jsx("image",{id:"image166",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("clipPath",{id:"clip2",children:R.jsx("rect",{x:0,y:0,width:42,height:42})}),R.jsxs("g",{id:"surface169",clipPath:"url(#clip2)",children:[R.jsx("use",{xlinkHref:"#image125"}),R.jsx("use",{xlinkHref:"#image142"}),R.jsx("use",{xlinkHref:"#image148",mask:"url(#mask1)"}),R.jsx("use",{xlinkHref:"#image154",mask:"url(#mask2)"}),R.jsx("use",{xlinkHref:"#image160"}),R.jsx("use",{xlinkHref:"#image166",mask:"url(#mask3)"})]})]}),R.jsx("g",{id:"surface1",children:R.jsxs("g",{clipPath:"url(#clip1)",clipRule:"nonzero",children:[R.jsx("path",{style:{stroke:"none",fillRule:"nonzero",fill:"url(#radial0)"},d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "}),R.jsx("use",{xlinkHref:"#image42"}),R.jsx("use",{xlinkHref:"#image91"}),R.jsx("use",{xlinkHref:"#surface169",mask:"url(#mask0)"})]})})]}),n9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",id:"Ebene_2","data-name":"Ebene 2",viewBox:"0 0 314.29 111.66",width:e,height:e,...n,children:[R.jsx("defs",{children:R.jsx("style",{children:".cls-1{fill:#fff;stroke-width:0}"})}),R.jsxs("g",{id:"Ebene_1-2","data-name":"Ebene 1",children:[R.jsx("path",{d:"M118.13 0c-8.69-.1-16.81 2.21-23.8 6.26-2.57 1.49-3.29 4.91-1.55 7.33 3.44 4.8 6.15 10.15 7.97 15.9 1.01 3.2 4.82 4.23 7.65 2.43 3.55-2.25 7.97-3.25 12.67-2.33 6.53 1.27 11.95 6.44 13.44 12.93 2.61 11.39-5.97 21.5-16.91 21.5-3.41 0-6.58-.99-9.24-2.7-2.82-1.8-6.61-.66-7.63 2.53-4.48 14.04-14.26 25.71-27.02 32.66-1.67.91-2.75 2.6-2.75 4.5v5.58c0 2.8 2.27 5.07 5.07 5.07h19.13c2.8 0 5.07-2.27 5.07-5.07v-9.76c0-3.35 3.16-5.67 6.42-4.87 3.52.86 7.18 1.32 10.96 1.32 26.19 0 47.34-21.59 46.62-47.95C163.55 20.67 142.8.28 118.13 0Z",style:{fill:"#ff7900",strokeWidth:0}}),R.jsx("path",{d:"M46.64 0C20.88 0 0 20.88 0 46.64s20.88 46.64 46.64 46.64S93.28 72.4 93.28 46.64 72.4 0 46.64 0Zm0 64.03c-9.6 0-17.38-7.78-17.38-17.39s7.78-17.39 17.38-17.39 17.39 7.78 17.39 17.39-7.78 17.39-17.39 17.39ZM188.46 41.7l20.14 33.14h11.26V18.5h-13.02v34.05L185.9 18.5h-10.38v56.34h12.94V41.7zM265.74 63.57h-24.29V51.9h15.46V40.8h-15.46V29.77h24.29V18.5h-37.88v56.34h37.88V63.57zM286.16 74.84h14.06V29.77h14.07V18.5H272.1v11.27h14.06v45.07z",className:"cls-1"})]})]}),i9=({size:e,className:t,variant:r,walletName:n})=>n===ii?R.jsx(Y7,{size:e,className:t,variant:r}):n===As?R.jsx(Q7,{size:e,className:t,variant:r}):n===vs?R.jsx(Gb,{size:e,className:t,variant:r}):n===si?R.jsx(t9,{size:e,className:t,variant:r}):n===Es?R.jsx(e9,{size:e,className:t,variant:r}):n===Di?R.jsx(J7,{size:e,className:t,variant:r}):n===ji?R.jsx(Z7,{size:e,className:t,variant:r}):n===ms?R.jsx(X7,{size:e,className:t,variant:r}):n===Mi?R.jsx(r9,{size:e,className:t,variant:r}):n===Fi?R.jsx(n9,{size:e,className:t,variant:r}):R.jsx(Gb,{size:e,className:t,variant:r});Y.FRACTAL_MAINNET=ls,Y.FRACTAL_TESTNET=Qt,Y.LEATHER=Ai,Y.LEATHER_MAINNET=bc,Y.LEATHER_TESTNET=ch,Y.LOCAL_STORAGE_DEFAULT_WALLET=La,Y.LaserEyesClient=E5,Y.LaserEyesProvider=G7,Y.MAGIC_EDEN=Wn,Y.MAINNET=tt,Y.OKX=ss,Y.OKX_MAINNET=$0,Y.OKX_TESTNET=C0,Y.OP_NET=Ti,Y.OP_WALLET_MAINNET=p3,Y.OP_WALLET_TESTNET=y3,Y.ORANGE=Si,Y.ORANGE_MAINNET=ah,Y.ORANGE_TESTNET=N0,Y.OYL=vi,Y.P2PKH=im,Y.P2PSH=sm,Y.P2SH=am,Y.P2TR=Ha,Y.P2WPKH=gl,Y.P2WSH=om,Y.PHANTOM=Ei,Y.REGTEST=g3,Y.SIGNET=Yt,Y.TESTNET=it,Y.TESTNET4=Zt,Y.UNISAT=zn,Y.UNISAT_FRACTAL_MAINNET=rh,Y.UNISAT_FRACTAL_TESTNET=nh,Y.UNISAT_MAINNET=yc,Y.UNISAT_SIGNET=th,Y.UNISAT_TESTNET=Ql,Y.UNISAT_TESTNET4=eh,Y.UNSUPPORTED_PROVIDER_METHOD_ERROR=Hr,Y.WALLETS=cm,Y.WALLET_NOT_INSTALLED_ERROR=I0,Y.WIZZ=os,Y.WIZZ_MAINNET=Fo,Y.WIZZ_SIGNET=oh,Y.WIZZ_TESTNET=wc,Y.WIZZ_TESTNET4=sh,Y.WalletIcon=i9,Y.WalletProvider=ln,Y.XVERSE=In,Y.XVERSE_MAINNET=gc,Y.XVERSE_NETWORK=d3,Y.XVERSE_SIGNET=x0,Y.XVERSE_TESTNET=ih,Y.createConfig=P8,Y.createStores=k8,Y.getLeatherNetwork=w3,Y.getNetworkForLeather=v3,Y.getNetworkForOkx=U0,Y.getNetworkForUnisat=zs,Y.getNetworkForWizz=uh,Y.getNetworkForXverse=m3,Y.getOrangeNetwork=Vo,Y.getSatsConnectNetwork=Vs,Y.getUnisatNetwork=mc,Y.getWizzNetwork=b3,Y.useLaserEyes=V7,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
86
+ <%s key={someKey} {...props} />`,xd,Cs,n9,Cs),K[Cs+xd]=!0}}return P===n?L(xt):$(xt),xt}}function W(P,j,G){return q(P,j,G,!0)}function X(P,j,G){return q(P,j,G,!1)}var Z=X,te=W;ul.Fragment=n,ul.jsx=Z,ul.jsxs=te}()),ul}process.env.NODE_ENV==="production"?Od.exports=F$():Od.exports=V$();var R=Od.exports;function W$(e,t,r){let n=new Set([...t,void 0]);return e.listen((i,o,s)=>{n.has(s)&&r(i,o,s)})}function Gb(e,t={}){let r=tn.useCallback(i=>t.keys?W$(e,t.keys,i):e.listen(i),[t.keys,e]),n=e.get.bind(e);return tn.useSyncExternalStore(r,n,n)}function z$({config:e,children:t}){const r=tn.useMemo(()=>new j$(zx(),qx(e??{network:mt})),[e]),{address:n,paymentAddress:i,publicKey:o,paymentPublicKey:s,accounts:a,balance:u,connected:f,hasProvider:h,isConnecting:d,isInitializing:g,provider:v}=Gb(r.$store),E={},T=Gb(r.$network);return R.jsx(Wb.Provider,{value:{paymentAddress:i,address:n,publicKey:o,paymentPublicKey:s,library:E,network:T,accounts:a,balance:Number(u),connected:f,isConnecting:d,isInitializing:g,provider:v,hasLeather:h.leather??!1,hasMagicEden:h["magic-eden"]??!1,hasOkx:h.okx??!1,hasOyl:h.oyl??!1,hasOrange:h.orange??!1,hasOpNet:h.op_net??!1,hasPhantom:h.phantom??!1,hasUnisat:h.unisat??!1,hasWizz:h.wizz??!1,hasXverse:h.xverse??!1,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),getBalance:async()=>(await r.getBalance.call(r)??"").toString(),getInscriptions:async()=>await r.getInscriptions.call(r)??[],getNetwork:r.getNetwork.bind(r),getPublicKey:async()=>await r.getPublicKey.call(r)??"",pushPsbt:r.pushPsbt.bind(r),signMessage:async(x,N)=>await r.signMessage.call(r,x,N)??"",requestAccounts:async()=>await r.requestAccounts.call(r)??[],sendBTC:async(x,N)=>await r.sendBTC.call(r,x,N)??"",signPsbt:async(x,N,O)=>await r.signPsbt.call(r,x,N,O)??{signedPsbtBase64:"",signedPsbtHex:""},switchNetwork:async x=>{await r.switchNetwork.call(r,x)}},children:t})}const q$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"white",style:{fill:"white",fillOpacity:1}})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"42",height:"42",rx:"10",fill:"white",style:{fill:"white",fillOpacity:1}}),R.jsx("path",{d:"M21 14C29.222 14 38 15.9676 38 20.9054C38 25.8622 29.222 28 21 28C12.778 28 4 26.0324 4 21.0946C4 16.1378 12.778 14 21 14ZM21.0397 25.3135C24.6939 25.3135 30.1752 24.3297 30.1752 21C30.1752 17.6703 24.6939 16.6865 21.0397 16.6865H20.9603C17.3061 16.6865 11.8248 17.6703 11.8248 21C11.8248 24.3297 17.3061 25.3135 20.9603 25.3135H21.0397Z",fill:"#090A0C",style:{fill:"#090A0C",fillOpacity:1}})]}),Xb=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#12100F"}),R.jsx("path",{d:"M74.9171 52.7114C82.4766 51.5408 93.4087 43.5804 93.4087 37.3761C93.4087 35.5031 91.8968 34.2154 89.6871 34.2154C85.5004 34.2154 78.4061 40.5368 74.9171 52.7114ZM39.911 83.4991C30.0256 83.4991 29.2115 93.3324 39.0969 93.3324C43.5163 93.3324 48.8661 91.5764 51.6573 88.4157C47.5868 84.9038 44.2141 83.4991 39.911 83.4991ZM102.829 79.2848C103.41 95.7907 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.0249C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8463 40.0273 72.8463C45.3771 72.8463 49.9128 74.2511 55.7277 77.88L59.5656 64.4177C43.7489 60.0864 35.8405 47.9118 43.6326 30.4693H56.1929C49.215 42.0586 53.9832 51.6578 62.822 52.7114C67.5903 35.7372 77.8246 22.509 91.4316 22.509C99.1074 22.509 105.155 27.5428 105.155 36.6737C105.155 51.3066 86.0819 63.2471 71.6607 64.4177L65.7295 85.3721C72.4748 93.2153 91.199 100.824 91.199 79.2848H102.829Z",fill:"#F5F1ED"})]}):R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 128 128",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsx("rect",{width:"128",height:"128",rx:"26.8387",fill:"#F5F1ED"}),R.jsx("path",{d:"M74.9171 52.7115C82.4766 51.5409 93.4087 43.5806 93.4087 37.3762C93.4087 35.5032 91.8968 34.2155 89.6871 34.2155C85.5004 34.2155 78.4061 40.5369 74.9171 52.7115ZM39.911 83.4992C30.0256 83.4992 29.2115 93.3325 39.0969 93.3325C43.5163 93.3325 48.8661 91.5766 51.6573 88.4159C47.5868 84.904 44.2141 83.4992 39.911 83.4992ZM102.829 79.2849C103.41 95.7908 95.0369 105.039 80.8484 105.039C72.4748 105.039 68.2881 101.878 59.333 96.025C54.681 101.176 45.8423 105.039 38.5154 105.039C13.2785 105.039 14.3252 72.8464 40.0273 72.8464C45.3771 72.8464 49.9128 74.2512 55.7277 77.8801L59.5656 64.4179C43.7489 60.0865 35.8405 47.9119 43.6326 30.4695H56.1929C49.215 42.0587 53.9832 51.6579 62.822 52.7115C67.5903 35.7373 77.8246 22.5092 91.4316 22.5092C99.1074 22.5092 105.155 27.5429 105.155 36.6738C105.155 51.3068 86.0819 63.2472 71.6607 64.4179L65.7295 85.3722C72.4748 93.2155 91.199 100.825 91.199 79.2849H102.829Z",fill:"#12100F"})]}),G$=({size:e=42,variant:t="first",className:r,...n})=>t==="first"?R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#AB9FF2",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#FFFDF8",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}):R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#FFFDF8",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"#AB9FF2",fillRule:"evenodd",d:"M17.686 27.567c-1.676 2.569-4.484 5.819-8.22 5.819-1.767 0-3.466-.728-3.466-3.887C6 21.454 16.984 9 27.176 9c5.798 0 8.108 4.023 8.108 8.59 0 5.864-3.805 12.568-7.587 12.568-1.2 0-1.79-.659-1.79-1.704 0-.273.046-.568.137-.887-1.291 2.205-3.783 4.25-6.116 4.25-1.698 0-2.559-1.068-2.559-2.568 0-.545.114-1.113.317-1.681Zm8.78-10.135c0 1.331-.786 1.997-1.664 1.997-.892 0-1.664-.666-1.664-1.997s.772-1.996 1.664-1.996c.878 0 1.663.665 1.663 1.996Zm4.99 0c0 1.331-.785 1.997-1.663 1.997-.892 0-1.664-.666-1.664-1.997 0-1.33.772-1.996 1.664-1.996.878 0 1.664.665 1.664 1.996Z",clipRule:"evenodd"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})})]}),X$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,width:e,height:e,viewBox:"0 0 42 42",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_3_53)",children:[R.jsx("path",{d:"M32 0H10C4.47715 0 0 4.47715 0 10V32C0 37.5228 4.47715 42 10 42H32C37.5228 42 42 37.5228 42 32V10C42 4.47715 37.5228 0 32 0Z",fill:"#181818"}),R.jsx("path",{d:"M32 31.6745V27.6829C32 27.5233 31.9203 27.3636 31.8406 27.2438L14.8225 10.1597C14.7029 10.0399 14.5435 10 14.3841 10H10.3986C10.1993 10 10.0399 10.1597 10.0399 10.3592V14.0715C10.0399 14.2311 10.1196 14.3908 10.1993 14.5105L16.2971 20.6177C16.4565 20.7774 16.4565 20.977 16.2971 21.1366L10.1196 27.3237C10.0399 27.4035 10 27.4834 10 27.5632V31.6346C10 31.8342 10.1594 31.9939 10.3587 31.9939H17.0544C17.2536 31.9939 17.413 31.8342 17.413 31.6346V29.2396C17.413 29.1598 17.4529 29.0401 17.5326 29.0002L20.8406 25.6871C21 25.5275 21.1993 25.5275 21.3587 25.6871L27.4964 31.8342C27.6159 31.954 27.7753 31.9939 27.9348 31.9939H31.6413C31.8406 32.0337 32 31.8741 32 31.6745Z",fill:"white"}),R.jsx("path",{d:"M23.3406 15.0793H26.5592C26.7507 15.0793 26.9039 15.2333 26.9039 15.4257V18.658C26.9039 18.9658 27.2871 19.1197 27.4788 18.8888L31.8851 14.4637C31.9617 14.3867 32 14.3097 32 14.2328V10.3463C32 10.1539 31.8468 10 31.6552 10H27.7469C27.6703 10 27.5554 10.0385 27.5171 10.1154L23.1107 14.5021C22.8808 14.6945 23.0341 15.0793 23.3406 15.0793Z",fill:"#EE7A30"})]}),R.jsx("defs",{children:R.jsx("clipPath",{id:"clip0_3_53",children:R.jsx("rect",{width:"42",height:"42",fill:"white"})})})]}),J$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#b)",d:"m25.517 9.483 5.759 5.611c.49.477.731.959.724 1.445-.008.486-.219.929-.631 1.33-.431.421-.897.634-1.395.644-.497.007-.992-.228-1.482-.705l-5.89-5.738c-.669-.652-1.315-1.114-1.936-1.385a2.873 2.873 0 0 0-1.96-.127c-.685.185-1.42.662-2.21 1.428-1.086 1.06-1.605 2.054-1.552 2.983.053.929.593 1.893 1.617 2.89l5.938 5.786c.496.482.74.964.732 1.443-.008.48-.22.923-.64 1.332-.419.408-.88.62-1.382.638-.502.016-1.001-.217-1.495-.7l-5.76-5.61c-.936-.912-1.613-1.776-2.029-2.59-.416-.815-.572-1.737-.464-2.765.097-.88.384-1.732.863-2.558.477-.827 1.161-1.671 2.048-2.537C15.43 9.268 16.438 8.48 17.4 7.93c.96-.55 1.889-.854 2.786-.917.899-.064 1.784.112 2.66.527.876.415 1.765 1.061 2.67 1.943h.002Z"}),R.jsx("path",{fill:"url(#c)",d:"m16.482 32.123-5.758-5.611c-.49-.479-.731-.959-.724-1.445.008-.486.219-.929.631-1.33.431-.421.897-.634 1.395-.644.498-.007.992.227 1.482.705l5.888 5.738c.671.652 1.315 1.114 1.936 1.385.622.27 1.276.312 1.962.127.685-.185 1.42-.662 2.21-1.43 1.086-1.06 1.605-2.054 1.552-2.983-.053-.929-.593-1.893-1.617-2.891l-3.164-3.056c-.496-.482-.74-.964-.732-1.443.008-.48.22-.923.64-1.332.419-.408.88-.62 1.382-.638.502-.016 1.002.217 1.496.7l2.983 2.88c.936.912 1.613 1.775 2.03 2.59.415.815.571 1.736.463 2.764a6.477 6.477 0 0 1-.863 2.559c-.477.826-1.16 1.67-2.048 2.536-1.057 1.03-2.066 1.819-3.027 2.368-.962.55-1.89.856-2.79.92-.898.063-1.784-.113-2.66-.527-.876-.415-1.765-1.062-2.67-1.944l.003.002Z"}),R.jsx("path",{fill:"url(#d)",d:"M20.073 17.645c1.168 0 2.115-.93 2.115-2.08 0-1.149-.947-2.08-2.115-2.08-1.168 0-2.115.931-2.115 2.08 0 1.15.947 2.08 2.115 2.08Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"b",x1:30.329,x2:12.579,y1:12.752,y2:20.772,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#201C1B"}),R.jsx("stop",{offset:.36,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4B852"})]}),R.jsxs("linearGradient",{id:"c",x1:12.163,x2:32.789,y1:29.085,y2:22.844,gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#1F1D1C"}),R.jsx("stop",{offset:.37,stopColor:"#77390D"}),R.jsx("stop",{offset:.67,stopColor:"#EA8101"}),R.jsx("stop",{offset:1,stopColor:"#F4FB52"})]}),R.jsxs("radialGradient",{id:"d",cx:0,cy:0,r:1,gradientTransform:"matrix(2.11484 0 0 2.08019 20.073 15.567)",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{stopColor:"#F4B852"}),R.jsx("stop",{offset:.33,stopColor:"#EA8101"}),R.jsx("stop",{offset:.64,stopColor:"#77390D"}),R.jsx("stop",{offset:1,stopColor:"#211C1D"})]}),R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Y$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsxs("g",{fillRule:"evenodd",clipPath:"url(#b)",clipRule:"evenodd",children:[R.jsx("path",{fill:"#FFD815",d:"m26.507 17.74-1.623-1.623-1.624 1.623 1.623 1.623 1.624 1.624 1.623-1.624-1.623-1.623Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 8-1.624 1.623 1.624 1.624 1.623-1.624L26.507 8ZM33 14.493l-1.623-1.623-1.624 1.623 1.624 1.623L33 14.493ZM23.26 27.48l1.623 1.623 1.624-1.623-1.623-1.624-1.624 1.624ZM11.897 16.117l1.623 1.623 1.623-1.623-1.623-1.624-1.623 1.624ZM20.014 8 18.39 9.623l1.624 1.624 1.623-1.624L20.014 8ZM13.52 11.247l1.624 1.623 1.623-1.623-1.623-1.624-1.624 1.624ZM31.377 19.363l-1.624 1.623 1.624 1.624L33 20.987l-1.623-1.624ZM28.13 25.856l1.623 1.624 1.624-1.624-1.624-1.623-1.623 1.623Z"}),R.jsx("path",{fill:"#5B5B72",d:"m26.507 20.986-1.624-1.623-1.623 1.623-1.623-1.623-1.623-1.623 1.623-1.624-1.623-1.623-1.624-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623 1.623-.812-.811-1.623 1.623 1.623 1.623-1.623 1.624-1.543 1.542-1.542 1.543-1.624 1.623L8 31.377 9.623 33l1.624-1.623 1.623-1.624 1.543-1.542.08-.08 1.462-1.463.08-.08 1.544-1.543 1.623 1.623 1.623-1.623-.811-.812 1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"}),R.jsx("path",{fill:"#FF9813",d:"m26.507 14.493-1.624-1.623-1.623 1.623-1.623-1.623-1.623 1.623 1.623 1.623-1.623 1.624 1.623 1.623 1.623 1.623 1.623-1.623-1.623-1.623 1.623-1.623 1.624 1.623 1.623-1.623-1.623-1.624Z"})]})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M8 8h25v25H8z"})})]})]}),Z$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{className:r,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#a)",children:[R.jsx("path",{fill:"#000",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("g",{fill:"#fff",clipPath:"url(#b)",children:R.jsx("path",{d:"M24.578 17.052h-6.787a.523.523 0 0 0-.52.52v6.788c0 .286.235.52.52.52h6.787c.286 0 .521-.234.521-.52v-6.787a.523.523 0 0 0-.52-.521ZM16.733 9.223H9.946a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.285 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM32.424 9.223h-6.787a.523.523 0 0 0-.521.521v6.787c0 .286.235.521.52.521h6.788c.286 0 .52-.235.52-.52V9.743a.523.523 0 0 0-.52-.52ZM16.733 24.898H9.946a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.285 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52ZM32.424 24.898h-6.787a.523.523 0 0 0-.521.52v6.788c0 .285.235.52.52.52h6.788c.286 0 .52-.235.52-.52v-6.788a.523.523 0 0 0-.52-.52Z"})})]}),R.jsxs("defs",{children:[R.jsx("clipPath",{id:"a",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})}),R.jsx("clipPath",{id:"b",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),Q$=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,className:r,viewBox:"0 0 42 42",fill:"none",...n,children:[R.jsxs("g",{clipPath:"url(#clip0_17_93)",children:[R.jsx("path",{fill:"#070C34",d:"M32 0H10C4.477 0 0 4.477 0 10v22c0 5.523 4.477 10 10 10h22c5.523 0 10-4.477 10-10V10c0-5.523-4.477-10-10-10Z"}),R.jsx("path",{fill:"url(#paint0_linear_17_93)",d:"m27.666 16.837 1.874 2.177c.215.245.404.446.483.562.56.55.874 1.293.874 2.07-.053.915-.657 1.54-1.213 2.205l-1.311 1.521-.685.79a.184.184 0 0 0 .046.281c.033.02.07.028.107.026h6.835c1.045 0 2.36.868 2.283 2.184 0 .597-.247 1.171-.68 1.595a2.36 2.36 0 0 1-1.637.664H23.936c-.704 0-2.598.076-3.128-1.521a1.841 1.841 0 0 1-.043-1.035 4.5 4.5 0 0 1 .72-1.404 65.543 65.543 0 0 1 1.695-2.343c.741-1.002 1.503-1.971 2.251-2.992a.19.19 0 0 0 .04-.116.19.19 0 0 0-.04-.116l-2.72-3.156a.192.192 0 0 0-.153-.073.192.192 0 0 0-.152.073c-.728.96-3.917 5.203-4.598 6.063-.68.86-2.355.907-3.283 0l-4.255-4.161a.197.197 0 0 0-.1-.053.195.195 0 0 0-.2.082.192.192 0 0 0-.032.106v8a2.678 2.678 0 0 1-.494 1.594c-.33.466-.804.823-1.352 1.014a2.375 2.375 0 0 1-2.111-.293 2.271 2.271 0 0 1-.72-.805A2.22 2.22 0 0 1 5 28.736V14.349a2.416 2.416 0 0 1 .548-1.422c.33-.406.785-.7 1.298-.841a2.632 2.632 0 0 1 2.502.664l6.54 6.381c.019.02.043.034.07.043a.197.197 0 0 0 .161-.013.188.188 0 0 0 .061-.054l4.646-6.27c.215-.254.485-.46.79-.601.304-.142.636-.217.976-.221H34.68c.33 0 .657.07.959.204a2.31 2.31 0 0 1 1.263 1.409c.096.309.122.633.079.952a2.288 2.288 0 0 1-.813 1.42c-.439.364-.996.56-1.572.551h-6.768a.188.188 0 0 0-.163.099.187.187 0 0 0-.022.095c0 .032.013.065.032.093h-.008Z"})]}),R.jsxs("defs",{children:[R.jsxs("linearGradient",{id:"paint0_linear_17_93",x1:"-0.315",x2:"35.366",y1:"9.343",y2:"30.176",gradientUnits:"userSpaceOnUse",children:[R.jsx("stop",{offset:"0.23",stopColor:"#FF0074"}),R.jsx("stop",{offset:"0.26",stopColor:"#FF0068"}),R.jsx("stop",{offset:"0.32",stopColor:"#FF0048"}),R.jsx("stop",{offset:"0.39",stopColor:"#FF0015"}),R.jsx("stop",{offset:"0.41",stopColor:"#FF0009"}),R.jsx("stop",{offset:"0.43",stopColor:"#FF0908"}),R.jsx("stop",{offset:"0.54",stopColor:"#FF4003"}),R.jsx("stop",{offset:"0.62",stopColor:"#FF6201"}),R.jsx("stop",{offset:"0.66",stopColor:"#FF6F00"}),R.jsx("stop",{offset:"0.72",stopColor:"#FF8700"}),R.jsx("stop",{offset:"0.83",stopColor:"#FFAB00"}),R.jsx("stop",{offset:"0.92",stopColor:"#FFC100"}),R.jsx("stop",{offset:"0.98",stopColor:"#FFCA00"})]}),R.jsx("clipPath",{id:"clip0_17_93",children:R.jsx("path",{fill:"#fff",d:"M0 0h42v42H0z"})})]})]}),e9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:e,height:e,viewBox:"0 0 42 42",...n,children:[R.jsxs("defs",{children:[R.jsx("clipPath",{id:"clip1",children:R.jsx("path",{d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "})}),R.jsxs("radialGradient",{id:"radial0",gradientUnits:"userSpaceOnUse",cx:0,cy:0,fx:0,fy:0,r:1,gradientTransform:"matrix(0.000000000000001938,31.643555,-31.643555,0.000000000000001938,21,5.578125)",children:[R.jsx("stop",{offset:0,style:{stopColor:"rgb(5.098039%,5.490196%,7.058824%)",stopOpacity:1}}),R.jsx("stop",{offset:1,style:{stopColor:"rgb(0%,0%,0%)",stopOpacity:1}})]}),R.jsx("image",{id:"image91",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAIOUlEQVRYhe2YW4jcVx3HP+fyv8785z+XveUm040xaWraitaHFmkfpKCI6LMgLWq9IUUpiA9CwRdfiqBPtbbWy5MKhRbxnuZFRUSMxhBr2nR6Sdrd2ezOzs7szP9yzvFhdus2TEzWJD7l+zQw53/Oh+/vcjg/uKmbuqmbuqlrkbhB+8o2+CFUUoj6EEWgAQ/Ah2IMpQcbS5C9CkMg/3+Cyjb4GpIE4gLSCsROkyKJLCilAEHpWwbS0M8LNvrQG0KvAxngbiTo2wBzaISahpGknqTxxGE1RLoPSCkWcIwN7p9hYX/54Asc0YKLOuPNElYL6P0J+jcCVLQhKCFOoQo0Ak3NSGaUZPbJI2qolXvECXHnlG83TemeeOxf9jcvlXh+zvk+LC9B9wJsXk9Qrw2VBsQWGnriYAvJ7FOH6ChfPSIE91/pDGF57tNnzO8Cy8tRxusZLGdw8Y8wulZQeRgqGioGalWol4pZJ5n77iKnKon6jIVPAuHVbmgL99jDZ+252PCyzni1AW8uwvBRGL916G4A2xC+E1oRtBTsjTW3FB6HF2PUj2+TrShRz1p4aDeQANITn/pWmxdKzXwY0ahCDISnwd9eo69iH9HeysPKVh4qTVNK5oxg9odH1UUh3TecELfvBu4S1YUv3++UHStHWvjUKj7ZiQHl821k0sJcCVQuQpJCRUBqoYnPjJPMf+8Q5zxfPegE94O45u4h4BCWV0pN4kHse4RH6+TeALHBf3fU2w+JDzULc2I7D2/hVCVRH7aObztBcK2Ab4EKAqEIlCASkghDMLJ4PeBjUFwO1HsHVJtQk7BgfPYeDBl//aDcJ6X4poW5631VGMuKAO05VAAq9FAzErWi4LfruKmg+0HLSagXrE/7+0c47/nqMeCu64s3kXMUFPaMZ2kriUsDpK/xuhnBLGSHUsTUqs8gDaFlFXuevJVz2lc/uFGQAM7y+6+8xj2BoKhpjK9xkUMuhojcw39hk2AqaAoVH1KjWQi0+pqAW24UJM69bo15JpYM6ophYskrAtP0EP0YX1nkYnwZR0tIjKLxs8P8A8FHbhikdWeKsf3OV1/mfVXJeiLpJyGjhocFSD1EWIdzGj01R32olpJ6oeSt8up67a7kHD1n3XOPv277ZzPuqCuWZwQrDUV/XrM5F5LrEreaIRohbHqoqRAStIVQKnHg+hKSO2uP58Yd//JL3BspaGi6s4qlpsdaXdGvK8ZNR+4iysEIt33FTQV1IAVojSvK69OHnLXur6a0z37hJe6OFXc1PN6oC1Ybkm7dY63hc3HWsZEKRmODnSsxmcD1AJddpj0BTkgsjrPXymmte8VYnvn8WXssktzRUlxINOtVyWoq6DV91usevaZjY49g5DvyekzZHeH2B+QXMhziMo7mYHxLMSrsSc9T6wjSXRM61p11P3/8Nds/NeJgy+N8LOinirUU1hKf/oxgPQgYzVoGM5KRceR7fcbnR7h9AdmFDOfJSWFN9esgvNdTvKsQvPund8hEC/GlXQDmztrj49I9//A57qsq1iqKfl2ylkCv7rOeKjbSkEHdMYgtxYJi2DeYGUeWCdzMDsh2SNEdgpp2VgqpllSlJPzbqjv/waasIK/YSx2WvxSlefJzL3LgxDozDc1KU9KdlSzNKJZnQ7rzMavzgn7VMJqHYaoZeZBXLIWRGOnIhxa7GJMXGbZbQCZwU0FjiJRDe4JwxdL+eOCekr6QUoojTEsX614sS55+6KxNjq9TTxUXm5qVumKppVieDViZ16w0fQZzJcMFGLY8htKjqOdkQzCxIyvAlAo7YykubAFmY+xRTT419A1IF2DOwn5f0baKtpXs/dERfq2Q9wopDipBaKy9WFpx5osv2veEgmGsGMSCjZpmvQ69xKdfE6zXAsbzgmFLMKpCtiGxiaUsS8y+kHFnDEphZg1FF7ACl4+wx0KKHtDpXCZH2xCOoNaA+QjmpWKfUewVihaCVAgCZVFK4gJJEQpGFcFmRdBvSjZqIesVwaAZMW5YhrGjmFcMNkpsVVEGhtJITGgphhLbsuTbgGYTl4wpjMD1etADhmCnVn0HsvugfxrkASi1wcSKgRDMCEcqJaH2UNpCJCgriix1jFKPfkMxjAKyBclAG0wDxqEm146iBWbksB7kpcO1KmR2CF2gGGG3AZfWcUvgMnAJuHugvGyXdCCOQLU+eb/Uqh71miIpJUkoCYXDqypcoBBVQdHyGDcjxg1N5hlMXTD2FIUwmKqlGEnsnE/+5iVh3gm40ns74F1QdoBT4K7UzsV9UGmDthE1rYlSjR8pvMwQxwEqFbhEYGcEpe9jW4rCCRyWMjGUmcDtD8gul4cHxhSdHnTBbYDdBjwBbOyYmlzVvfMohBF4pkqofIKaRYceXsUhIx9RGHTFh5ai9H3IczBbDo7HMJTYd0Tk3eFkyFSMsEcj8k4POr1JDvpgpwGubv2+6gvyNPjLILsQHAKxXMXfHyHXSvy4jhAjRBhOkj9k8iBXCgMwrZpPdiZrV8Fsu/jcFMBdOfoW7G348RD59w6eraOCEM8ZVJvJW7pSgXMZej6gXMrQSUkJb3dxu910JyBmZx5eCrlnt6HfqZ/chj88jXygDb/o4++xyDvr8Ac1GRYoO9lTOoQVk4N29sSTnUmoE3C3Q3GC/4R6p4vbkJ+FAnY3KQFgMcS9AvbpDnyoRv6GxJ7swdGE/O6EPFdYI3GFwuYj7GFHdiycFMyfO7gh2E9AXtuCnKZLIeF/HJI9Dl4G8hiIB9rwqwHeG1VUfev/+iXrOz0oBW5zDftRKDrANuSlbk6DBPg3vtO3svqbCX0AAAAASUVORK5CYII="}),R.jsx("filter",{id:"alpha",filterUnits:"objectBoundingBox",x:"0%",y:"0%",width:"100%",height:"100%",children:R.jsx("feColorMatrix",{type:"matrix",in:"SourceGraphic",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})}),R.jsx("image",{id:"image170",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACtklEQVRYhWNgGAWjYBSMglEwCkYcmGslLagZ26TedkTUMOD/H11nY2a5Sb+/sJBiBiOtHMfAwMCg73JCaNrNdN2kh/eF0eXKFXf+qZBhvfbqqMkdYsxior7zGBjUK65yXtwsbBq4/7wDNkcyMDAwdN53ZxE87KQX4tNtRIyZVA1Rc3M7ZpZn5eoNd1lVc1hCmInVJ7ov4fwRl0n38amhWoiyP3kmPbfVyfXNw0gNUhzJwMDA8D/3q1bnt2a8bqE4RFPWPhRMLPDTwxXFxIKtN84cUdFSe4VLnuwQhaVDmbBtjpQ6koGBgWHPo6d8+ORJKiIYGBDp0CgsQTXM4Dczw+9y8l2HBB4kJFEv6p2NmeVYi1m170ewcVLmLEzw6HHhye/yjU9xyRMV9XaXNnLcmHTA9slpbhNaONLtgvpfZV5TnOmTgYGIEP3LGciWdPSB/QmDu7zUcxoquNv66c6fWoZL+NQQDNFwZysdWjpS8mnzhzsL664RUoc3M9ld2sixVWiFvBz13IUC2HjqXtzv4z+jcCf/DyG1eKOeb66bnGTiCRPqOQ0Ccpjzvq3gTr5y9IviE2L14I163YZ8HsqdhQDP3hn9vf8m5tq3r+y7SHEkAwOBqH/ncPYvZU6DgEjWToYZ/8UefWbsusrwd9p3ckpevCEqdNL9E5lug4N58opvn6zy2v/iX/AZhr8nv5NrDl6H7vx0/ZXyhqBf5BisuOLXdxnTr2esH188OCdY/j15zkMAguUoX8haFclViXrEGvjsndHfn/+0bjbzSN4q56r9R5nzEICoKlQvzsrk54IreEspWDp8wdh1lZIoxgWIrusrJBTVpl6R15QSOofR1qzc+eH1kW+Pr1AjiqkCJv3+wuJszCwnwaeq23ZE1JC9Q0ktq+09/0C7axSMglEwCkbBKKA/AABq8ekilgplTAAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask0",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("use",{xlinkHref:"#image170"})})}),R.jsx("image",{id:"image125",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEF0lEQVRYhe2WTYscVRSGn3NvVXdPzySabwQN2SlGkQgjCC4EFWMU/A+CG925EhN0JSiof8BtxC8SSVZZiK7MRjRElPwEF8Ik0z3d9XXPOS6qJhM1pHucGXHRLxRFN9Sth/d977kFCy200EILLfR/kvwXL/n69NFvs6Y56MmGjUIlsU55TK9998eT866xp6DfvHTkcm9Snop1epBkqDuNQulCHWNT9Xq/s5FOv/7rxo1Za2V7AXjhzLEv+pPy5ODm+KSoSlQDdZI5GCQVCtdcKzuuw/5V4MCsNXfV0S9feeD8YKM4vlKVq5J0kJsR3Ajq4JAcygSjBOMkbEhEl3Ky+5dGb/6wdt+91t41Ry8+f+jS8tr6M3nTHNwEjO5EBxdwQFwIAcBxcxSjqY1Q6vKs9XcMevHMka+WxtPV/mh8IqiSWwcISJdXCIFkYIB5+5/jaHJSdIJa3DPQCy8f+3w4nj7auzl6PDYq0YzMncwcCYBDkIAByaAxaBxq2/pdG6iC2ez3bRv0dg/X1p8KSfu5GcGMgBMFEBAEFyG1ewg1qB3qBJVCqU6lLbDOCbEt0AvPHbyyf219Nd7Rw+BOJrQOGnjnYrfRW/e8A0zOVJ0iQaFQK7hu1WHHoJ+9ePTKynjy8HC0cSIzpff3HhpICLc7qNbu8Mah0TbmonEKc6YJxg1MGiikBWiH1g5Bz79w7Pul9Y3Hsro+nJkykLv38E4HN11sNmO21sVJgo0E0wSlQQpCiELMg+4Y1CfFQxTN4dyULBhBWhfv1sOmm5W1Qp2c0pxSaSEVyqaNfCqCBSH2I/kg03wQZ87ze4J++uzhn8NocsJUMTcQcAOTgPtfY07eRlwlpzYo7ujitLuXBjWCx0DWjwxX8rRvf+5vXV3r7Qg01WlfXVmM6m2sgAQB6SB9K+5aodqMWWHadIDWXgnBsoDkgf4g08Ew0+u/jT++DO/MgpwJqrUNK3OkcfIAwQR1QLbibiHbmKvOvYlCqVAZ1CZoDHge6PWi5ctZWh5mcvanW/15AOcCTU5UBVOQbozkAuCdm23MlbbRFtqe5UWCMggmAoNA7EUfLGVpaZhx7tr6tgDnArUQaFyoVUjm1Or0usPuzsgLawHL7rSpRPAQyHqRwXKWloaZvXt99K8A5wINecg0hFQgWZmEQpzYQOiiT9qC1d7GnOSfPfzlxviDS8Z7O4GEOT7z3n9i/6hcr/bV0wZJRugect8aRykIEgOSBXr9aPnwdg9n7uZdA3018MapR1Y+KTaaflMlUmrnknePexQkD/Ty6P1hloZLkXPX1ncNcG5QgI+ePlSMxrVURerVlYl3oCEIsRfo92MaDqKf3QPAbYFu6sPVA1XdKEk9OEgWxXt54O0fb+V7BbjQQgsttNBC/0/9CbvrotNPsOneAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image142",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAAmklEQVRYhe2U0QqAIBAE1/7/n+tFIaQyur21aAdEX4RhDgWMMemUul7BkciZ3JopMqKXGhWcJltOzldMkS3dfhe5bOTBSGWXwF3pjxARBYSyUVFAJMsQBQSyLNF0mKKpVdlF02R/OfpGStWsonTZX4++Qa3qohVaVRfdQanqoh3hqi7KRikaGr+LslGLPh6/i7KxKBuLsvmM6AZK+AVU/UCtAQAAAABJRU5ErkJggg=="}),R.jsx("mask",{id:"mask1",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.6,stroke:"none"}})})}),R.jsx("image",{id:"image148",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAEI0lEQVRYhe3XTW4kuREF4I9kZqX+7B61gAFGR5CWPsucZ9zn6Sv4Ct5ZfQAv1IABuaftaUlVmWR4kZS6tPKitBjDegCRZBaT9RA/Lxi84Q1veMMbDkF6msTTPPChz28kP+NTX99+3/+MSwGuhI+47utfhETS169BNEgvCF5JPkluJZeSO8lF/+3rHtl3ncSdcCHcCpfCjXAtXpPs8ILkjeRa8kVyJ7uUkE0SknvJuz2idzgWJg3hUkNzLlxpPiBEJOlQsilI/txJnu+RI7tXJPl5TJKtZJaMwiRshdCE5lhF8141aT4LNL+IlA4jml+QnGRfFQwejE6Mso1qMplwpDl2tj6POTKZVJNs49GIwd8NPituJVfSc0gdgAFcd9d+lb1T/GpwrPhmlAyKwaKoiiy7lxTxsNX626paDDJmZ9At/hd80Q4lmt30pCErsgdFMUg2Tm1kR5IjyYlwKpwa+zOcSk40xzbdst9sMLhXDD2Ufj6UJsOe/GRniq3BHwxmG4uNbFKMFhvJICua1L+omA3mHsfJpsflieY3zZ32LG8HEf0keS/5Z0+gSTEbVWNfTZpJ6cRDUSRNqKowS7bmrh5VM/dwyKqLZ48dSPR2T3pWCsXOIPdEaibVUSe9urVKslAsmkHuKlBVG7MHA93Kt3KXrQOJ/gnfJA/dootiUIRBMqg2hp75q2WH7vjAIssDbVlUYbE1SP2cU0k93Jor0c/doqw2mCRNlrtMMQijbBRGYUDWRElSJRYWydzTsXhUjJLHfu7d4WTz8+xYspEsUo/B78KvOzo6kbyGSE2KppT9fbV/v3StuH8di+b/vuX3ge9EH4SdMAhVyF1mnsYabVXrI9QSa2bX/X2lfz8Ij8LJ69yesp+EP/bDRmHutbuqWDzFXzMXdpoZO9murlV/HWHp9WmVplk46udevMLtyV+td8roFhlUO1W2CItit+a2VJNQ1C74a9aHnWRnsFN7mZi79R+Ef4leUg8keim8F/4h/KiiShbVjNKTg6RZVHlP8Jsqm4WtpRN+tGiq0ndcam5fw6JXwifhx27RrWoy00siqxgtandz2RP8JptVs9HWbKeYHVlQewmN5y7gIKIfcd4vvb+piuTfXU/HnhBh0SxjUebaLVp7smXLJsy7MCt2dmajxb2qai6Eq9cguvY4659WyZnqV0kI30SX/8Fonmu/SDdPJaIJdRe95ofFqRmLE9Vd99LHQ2k+ydNN73cWzVfVD6sFLXaKrerR4MHkXnP/4jl4UD0abTU7T0qxhlF77p8OxP9QK8La2l6LfhNvflLdqU7Mjs0WO5Ote1uTrTOPJlt3/f1i57i7nMXfNOf9rN6JHoohWbtEIXwA4Vzq7W9yqdlKziQnXrbLT0K+Fc722uUvXUleubd/wxve8IY3/B/gP+5/MI8x65+AAAAAAElFTkSuQmCC"}),R.jsx("mask",{id:"mask2",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.701961,stroke:"none"}})})}),R.jsx("image",{id:"image154",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAAA/ElEQVRYhe2VwW7DIAxAn9M0qcSN///G3JDaFEIPwRvqoUHdWKXJT/IhMokeNiZgGIZhGIZh/EPkVTLnLGWNxvD0Ti6xAVlEtk6eDA1rBDgBZ2ACZu/9DMzleSz5lm+9zVFFh0pyrELYK5m89/dlWSIQRWT9lOipiE1VnCvRCKwaInLtJXrULj2Xdesn4EJpvXPuT1o/NqxR2Vp4YB+gLYSgki+781PeqUL+dYsGWkT1+tmAxH4uNZJzLpVc1w0ctV4lE3Dne4i+himEEEu+2x0KxxV9Fr0B1ypu3vuVvbpdRVv+TDpEGvXmdBMJ2EQkdvI0DMMwDMMwjI/yAInrT4nWGUiJAAAAAElFTkSuQmCC"}),R.jsx("image",{id:"image160",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("mask",{id:"mask3",children:R.jsx("g",{filter:"url(#alpha)",children:R.jsx("rect",{x:0,y:0,width:42,height:42,style:{fill:"rgb(0%,0%,0%)",fillOpacity:.2,stroke:"none"}})})}),R.jsx("image",{id:"image166",width:42,height:42,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAABmJLR0QA/wD/AP+gvaeTAAACY0lEQVRYhe2W227iQBBEj7mFcAkbZf3/HxjtLUtCAtjeh6laN9YSDCHSPkxLrZE92BzXVPcM5MiRI0eOj0RxzZc1TeP3FcBAoxOgCWOtsSmKouFEjD4JcNgZBx3ASlmH688FFWQEHAJj5Uhp0ArYA7uQvv85oAGw6ABOgClwoxwLtBbkG/CqhNYO1wUNy+wl7QLeAjPlNIBWgnzRM9Bz2c8CPeJDL/GNAOfAIuSt5gG2AbImLfuW1hYfBz3iw4kApyT1FsBSeafraQDb6P8q0rKPNder87wL2sOHBlwIzrnU3ESvsnJb2iKL7ety0H+oOOoAzgW0HA6Hd1VVrXS90NxEz+5JBdNtUXG8HDRClmU5fnx8dKFEBVfAqqoqqzjXhxiyInnR1e7c6r576VVADWkFV8ovSvvxluRZ+24PvA0Gg+e6rn8DzjXJr1v9phfoexVnX45JKs0FdQ98BUqN97o/04c3AlwDP+u6/g58U/4Q7AvwWpblri/oUSM3TeO2MyMpeQ88CO6BpOZSH2FAL/ELSbkn4JfySfkXFKlaFMX+FGifpXcRuVc6b8Lz7okb4FkwT51cC3Cjj7F3r+JRwxrYhwz0B1vawogqRvUi4GsAdCFdbQv1i7zd7Wj36SFtA19zqOSapK4V7FZ6DdDniHcKtKHtdTv92YZUXA1JJTS34bCqnzn0oQErzjiDngPqE4/95y1wQ7s1Rm9GwK4P60sA+4LGpfZRzft0EeattgHdIw98eCnkOaDQqudjm+/5IOzCioBn+fAjoPZnhPZhwqD2XlfBi5c5R44cOXLkyJHjv40/gQUmD3HnzocAAAAASUVORK5CYII="}),R.jsx("clipPath",{id:"clip2",children:R.jsx("rect",{x:0,y:0,width:42,height:42})}),R.jsxs("g",{id:"surface169",clipPath:"url(#clip2)",children:[R.jsx("use",{xlinkHref:"#image125"}),R.jsx("use",{xlinkHref:"#image142"}),R.jsx("use",{xlinkHref:"#image148",mask:"url(#mask1)"}),R.jsx("use",{xlinkHref:"#image154",mask:"url(#mask2)"}),R.jsx("use",{xlinkHref:"#image160"}),R.jsx("use",{xlinkHref:"#image166",mask:"url(#mask3)"})]})]}),R.jsx("g",{id:"surface1",children:R.jsxs("g",{clipPath:"url(#clip1)",clipRule:"nonzero",children:[R.jsx("path",{style:{stroke:"none",fillRule:"nonzero",fill:"url(#radial0)"},d:"M 9.433594 0 L 32.566406 0 C 37.777344 0 42 4.222656 42 9.433594 L 42 32.566406 C 42 37.777344 37.777344 42 32.566406 42 L 9.433594 42 C 4.222656 42 0 37.777344 0 32.566406 L 0 9.433594 C 0 4.222656 4.222656 0 9.433594 0 Z M 9.433594 0 "}),R.jsx("use",{xlinkHref:"#image42"}),R.jsx("use",{xlinkHref:"#image91"}),R.jsx("use",{xlinkHref:"#surface169",mask:"url(#mask0)"})]})})]}),t9=({size:e=42,variant:t="first",className:r,...n})=>R.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",id:"Ebene_2","data-name":"Ebene 2",viewBox:"0 0 314.29 111.66",width:e,height:e,...n,children:[R.jsx("defs",{children:R.jsx("style",{children:".cls-1{fill:#fff;stroke-width:0}"})}),R.jsxs("g",{id:"Ebene_1-2","data-name":"Ebene 1",children:[R.jsx("path",{d:"M118.13 0c-8.69-.1-16.81 2.21-23.8 6.26-2.57 1.49-3.29 4.91-1.55 7.33 3.44 4.8 6.15 10.15 7.97 15.9 1.01 3.2 4.82 4.23 7.65 2.43 3.55-2.25 7.97-3.25 12.67-2.33 6.53 1.27 11.95 6.44 13.44 12.93 2.61 11.39-5.97 21.5-16.91 21.5-3.41 0-6.58-.99-9.24-2.7-2.82-1.8-6.61-.66-7.63 2.53-4.48 14.04-14.26 25.71-27.02 32.66-1.67.91-2.75 2.6-2.75 4.5v5.58c0 2.8 2.27 5.07 5.07 5.07h19.13c2.8 0 5.07-2.27 5.07-5.07v-9.76c0-3.35 3.16-5.67 6.42-4.87 3.52.86 7.18 1.32 10.96 1.32 26.19 0 47.34-21.59 46.62-47.95C163.55 20.67 142.8.28 118.13 0Z",style:{fill:"#ff7900",strokeWidth:0}}),R.jsx("path",{d:"M46.64 0C20.88 0 0 20.88 0 46.64s20.88 46.64 46.64 46.64S93.28 72.4 93.28 46.64 72.4 0 46.64 0Zm0 64.03c-9.6 0-17.38-7.78-17.38-17.39s7.78-17.39 17.38-17.39 17.39 7.78 17.39 17.39-7.78 17.39-17.39 17.39ZM188.46 41.7l20.14 33.14h11.26V18.5h-13.02v34.05L185.9 18.5h-10.38v56.34h12.94V41.7zM265.74 63.57h-24.29V51.9h15.46V40.8h-15.46V29.77h24.29V18.5h-37.88v56.34h37.88V63.57zM286.16 74.84h14.06V29.77h14.07V18.5H272.1v11.27h14.06v45.07z",className:"cls-1"})]})]}),r9=({size:e,className:t,variant:r,walletName:n})=>n===ri?R.jsx(X$,{size:e,className:t,variant:r}):n===vs?R.jsx(Y$,{size:e,className:t,variant:r}):n===bs?R.jsx(Xb,{size:e,className:t,variant:r}):n===ni?R.jsx(Q$,{size:e,className:t,variant:r}):n===ms?R.jsx(Z$,{size:e,className:t,variant:r}):n===Ki?R.jsx(G$,{size:e,className:t,variant:r}):n===Hi?R.jsx(J$,{size:e,className:t,variant:r}):n===ws?R.jsx(q$,{size:e,className:t,variant:r}):n===ji?R.jsx(e9,{size:e,className:t,variant:r}):n===Hg?R.jsx(t9,{size:e,className:t,variant:r}):R.jsx(Xb,{size:e,className:t,variant:r});Y.FRACTAL_MAINNET=cs,Y.FRACTAL_TESTNET=Zt,Y.LEATHER=vi,Y.LEATHER_MAINNET=pc,Y.LEATHER_TESTNET=ih,Y.LOCAL_STORAGE_DEFAULT_WALLET=Ua,Y.LaserEyesClient=v5,Y.LaserEyesProvider=z$,Y.MAGIC_EDEN=Wn,Y.MAINNET=tt,Y.OKX=ns,Y.OKX_MAINNET=x0,Y.OKX_TESTNET=$0,Y.OP_NET=Ud,Y.OP_WALLET_MAINNET=p3,Y.OP_WALLET_TESTNET=y3,Y.ORANGE=Ei,Y.ORANGE_MAINNET=nh,Y.ORANGE_TESTNET=C0,Y.OYL=bi,Y.P2PKH=im,Y.P2PSH=sm,Y.P2SH=am,Y.P2TR=Na,Y.P2WPKH=fl,Y.P2WSH=om,Y.PHANTOM=mi,Y.REGTEST=g3,Y.SIGNET=Jt,Y.TESTNET=it,Y.TESTNET4=Yt,Y.UNISAT=Vn,Y.UNISAT_FRACTAL_MAINNET=Zl,Y.UNISAT_FRACTAL_TESTNET=Ql,Y.UNISAT_MAINNET=hc,Y.UNISAT_SIGNET=Yl,Y.UNISAT_TESTNET=Xl,Y.UNISAT_TESTNET4=Jl,Y.UNSUPPORTED_PROVIDER_METHOD_ERROR=Lr,Y.WALLETS=cm,Y.WALLET_NOT_INSTALLED_ERROR=I0,Y.WIZZ=is,Y.WIZZ_MAINNET=jo,Y.WIZZ_SIGNET=rh,Y.WIZZ_TESTNET=dc,Y.WIZZ_TESTNET4=th,Y.WalletIcon=r9,Y.WalletProvider=Cn,Y.XVERSE=Pn,Y.XVERSE_MAINNET=fc,Y.XVERSE_NETWORK=d3,Y.XVERSE_SIGNET=O0,Y.XVERSE_TESTNET=eh,Y.createConfig=P8,Y.createStores=k8,Y.getLeatherNetwork=w3,Y.getNetworkForLeather=v3,Y.getNetworkForOkx=N0,Y.getNetworkForUnisat=yc,Y.getNetworkForWizz=oh,Y.getNetworkForXverse=m3,Y.getOrangeNetwork=Do,Y.getSatsConnectNetwork=Ms,Y.getUnisatNetwork=sh,Y.getWizzNetwork=b3,Y.useLaserEyes=M$,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});