@babylonlabs-io/wallet-connector 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nt=Object.defineProperty;var Ut=(e,t,r)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var at=(e,t,r)=>Ut(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),coreUi=require("@babylonlabs-io/core-ui"),tailwindMerge=require("tailwind-merge"),react=require("react"),btcStakingTs=require("@babylonlabs-io/btc-staking-ts"),sdk$1=require("@keystonehq/sdk"),bitcoinjsLib=require("bitcoinjs-lib");function WalletButton({className:e,disabled:t=!1,name:r,logo:s,label:o,fallbackLink:n,installed:a=!0,onClick:l}){const p=a?{as:"button",disabled:t,onClick:l}:{as:"a",href:n,target:"_blank"};return jsxRuntime.jsxs(coreUi.Text,{className:tailwindMerge.twMerge("flex h-14 w-full cursor-pointer items-center gap-2.5 rounded border border-secondary-strokeLight text-accent-primary px-2",t?"cursor-default":"cursor-pointer",e),...p,children:[jsxRuntime.jsx(coreUi.Avatar,{variant:"rounded",className:"shrink-0",alt:r,url:s}),r,o&&jsxRuntime.jsx(coreUi.Chip,{className:"ml-auto shrink-0",children:o})]})}class Wallet{constructor({id:t,origin:r,name:s,icon:o,docs:n,networks:a,provider:l,label:p}){at(this,"id");at(this,"origin");at(this,"name");at(this,"icon");at(this,"docs");at(this,"networks");at(this,"provider",null);at(this,"_label");at(this,"account",null);this.id=t,this.origin=r,this.name=s,this.icon=o,this.docs=n,this.networks=a,this.provider=l,this._label=p}get installed(){return!!this.provider}get label(){return this._label??(this.installed?"Installed":"")}async connect(){if(!this.provider)throw Error("Provider not found");await this.provider.connectWallet();const[t,r]=await Promise.all([this.provider.getAddress(),this.provider.getPublicKeyHex()]);return this.account={address:t,publicKeyHex:r},this}clone(){return new Wallet({id:this.id,origin:this.origin,name:this.name,icon:this.icon,docs:this.docs,networks:this.networks,provider:this.provider})}}let createNanoEvents=()=>({emit(e,...t){for(let r=this.events[e]||[],s=0,o=r.length;s<o;s++)r[s](...t)},events:{},on(e,t){var r;return((r=this.events)[e]||(r[e]=[])).push(t),()=>{var s;this.events[e]=(s=this.events[e])==null?void 0:s.filter(o=>t!==o)}}});class WalletConnector{constructor(t,r,s,o,n){at(this,"_connectedWallet",null);at(this,"_ee",createNanoEvents());this.id=t,this.name=r,this.icon=s,this.wallets=o,this.config=n}get connectedWallet(){return this._connectedWallet}async connect(t){try{const r=typeof t=="string"?this.wallets.find(s=>s.id===t):t;if(!r)throw new Error("Wallet not found");return this._ee.emit("connecting",`Connecting ${r.name}`),await r.connect(),this._connectedWallet=r,this._ee.emit("connect",this._connectedWallet),this.connectedWallet}catch(r){return this._ee.emit("error",r),null}}async disconnect(){this._connectedWallet&&(this._ee.emit("disconnect",this._connectedWallet),this._connectedWallet=null)}clone(){return new WalletConnector(this.id,this.name,this.icon,this.wallets,this.config)}on(t,r){return this._ee.on(t,r)}}var Network=(e=>(e.MAINNET="mainnet",e.CANARY="canary",e.TESTNET="testnet",e.SIGNET="signet",e))(Network||{});const defaultWalletGetter=e=>t=>t[e],createWallet=async({metadata:e,context:t,config:r})=>{const{id:s,wallet:o,name:n,icon:a,docs:l="",networks:p=[],createProvider:u,label:c}=e,v={id:s,name:"",icon:"",origin:null,provider:null,docs:l,networks:p,label:c};if(o){const w=typeof o=="string"?defaultWalletGetter(o):o;v.origin=w(t,r)??null,v.provider=v.origin?u(v.origin,r):null}else v.origin=null,v.provider=u(null,r);return typeof n=="string"?v.name=n??"":v.name=v.origin?await n(v.origin,r):"",typeof a=="string"?v.icon=a??"":v.icon=v.origin?await a(v.origin,r):"",new Wallet(v)},createExternalWallet=({id:e,name:t,icon:r,provider:s})=>new Wallet({id:e,origin:null,name:t,icon:r,docs:"",networks:[Network.MAINNET,Network.SIGNET],provider:s}),createWalletConnector=async({metadata:e,context:t,config:r,accountStorage:s})=>{const o=[],n=s.get(e.chain);for(const l of e.wallets)o.push(await createWallet({metadata:l,context:t,config:r}));const a=new WalletConnector(e.chain,e.name,e.icon,o,r);return n&&await a.connect(n),a},icon$1="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20800'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23ce6533;fill-rule:evenodd;}%3c/style%3e%3c/defs%3e%3cpath%20class='cls-1'%20d='M66.5,198.56c-3.27-8.85-1.09-18.79,5.58-25.47l90.82-90.82c6.67-6.67,16.62-8.85,25.46-5.59l193.65,71.14c4.76,1.75,7.92,6.28,7.92,11.35v42.4c0,3.21-1.27,6.28-3.54,8.55l-47.14,47.13c-3.33,3.34-8.3,4.43-12.73,2.79l-52.02-19.18-57.16-21.09c-4.83-1.79-9.55,2.92-7.76,7.76l40.27,109.18c1.63,4.43,.55,9.4-2.79,12.73l-41.91,41.89c-4.72,4.72-4.72,12.38,0,17.1l42.13,42.13c3.34,3.34,4.43,8.31,2.79,12.73l-40.27,109.17c-1.79,4.84,2.92,9.55,7.76,7.76l109.18-40.28c4.43-1.63,9.4-.54,12.73,2.79l46.91,46.91c2.27,2.27,3.54,5.34,3.54,8.55v42.41c0,5.06-3.15,9.59-7.9,11.34l-193.42,71.36c-8.85,3.27-18.8,1.08-25.47-5.59l-90.83-90.83c-6.67-6.67-8.85-16.61-5.58-25.47l71.11-192.77c1.99-5.4,1.99-11.34,0-16.74L66.5,198.56Z'/%3e%3cpath%20class='cls-1'%20d='M733.5,601.44c3.27,8.85,1.09,18.79-5.58,25.47l-90.82,90.83c-6.67,6.67-16.61,8.85-25.46,5.59l-193.65-71.14c-4.76-1.75-7.92-6.28-7.92-11.35v-42.4c0-3.21,1.27-6.28,3.54-8.55l47.14-47.13c3.33-3.34,8.3-4.43,12.73-2.79l52.02,19.18,57.16,21.09c4.83,1.79,9.54-2.92,7.76-7.76l-40.27-109.18c-1.63-4.43-.55-9.4,2.79-12.73l41.91-41.89c4.72-4.72,4.72-12.38,0-17.1l-42.13-42.13c-3.34-3.34-4.43-8.31-2.79-12.73l40.27-109.17c1.79-4.84-2.92-9.55-7.76-7.76l-109.18,40.28c-4.43,1.63-9.4,.54-12.73-2.79l-46.91-46.91c-2.27-2.27-3.54-5.34-3.54-8.55v-42.41c0-5.06,3.15-9.59,7.9-11.34l193.42-71.36c8.85-3.27,18.79-1.08,25.47,5.59l90.82,90.83c6.68,6.67,8.86,16.61,5.59,25.47l-71.11,192.77c-2,5.4-2,11.34,0,16.74l71.34,193.37h0Z'/%3e%3c/svg%3e",metadata$b={id:"injectable",name:e=>{var t;return(t=e.getWalletProviderName)==null?void 0:t.call(e)},icon:e=>{var t;return(t=e.getWalletProviderIcon)==null?void 0:t.call(e)},docs:"",wallet:"bbnwallet",createProvider:e=>e,networks:[Network.MAINNET,Network.SIGNET],label:"Injectable"},logo$6="data:image/svg+xml,%3csvg%20width='42'%20height='42'%20viewBox='0%200%2042%2042'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_425_5107)'%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint0_linear_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint1_radial_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint2_radial_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint3_radial_425_5107)'/%3e%3cpath%20d='M17.2526%2032.2614V22.5192L26.7185%2032.2614H31.9849V32.0079L21.0964%2020.9122L31.1469%2010.3857V10.2614H25.8464L17.2526%2019.5635V10.2614H12.9849V32.2614H17.2526Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_425_5107'%20x1='21'%20y1='0'%20x2='21'%20y2='42'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231FD1FF'/%3e%3cstop%20offset='1'%20stop-color='%231BB8FF'/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint1_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(2.00623%2040.4086)%20rotate(-45.1556)%20scale(67.3547%2068.3624)'%3e%3cstop%20stop-color='%23232DE3'/%3e%3cstop%20offset='1'%20stop-color='%23232DE3'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint2_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(39.7379%2041.7602)%20rotate(-138.45)%20scale(42.1137%2064.2116)'%3e%3cstop%20stop-color='%238B4DFF'/%3e%3cstop%20offset='1'%20stop-color='%238B4DFF'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint3_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(20.6501%200.311498)%20rotate(90)%20scale(33.1135%2080.3423)'%3e%3cstop%20stop-color='%2324D5FF'/%3e%3cstop%20offset='1'%20stop-color='%231BB8FF'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cclipPath%20id='clip0_425_5107'%3e%3crect%20width='42'%20height='42'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";var buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$9=0,len=code.length;i$9<len;++i$9)lookup[i$9]=code[i$9],revLookup[code.charCodeAt(i$9)]=i$9;revLookup[45]=62;revLookup[95]=63;function getLens(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 s=r===t?0:4-r%4;return[r,s]}function byteLength(e){var t=getLens(e),r=t[0],s=t[1];return(r+s)*3/4-s}function _byteLength(e,t,r){return(t+r)*3/4-r}function toByteArray(e){var t,r=getLens(e),s=r[0],o=r[1],n=new Arr(_byteLength(e,s,o)),a=0,l=o>0?s-4:s,p;for(p=0;p<l;p+=4)t=revLookup[e.charCodeAt(p)]<<18|revLookup[e.charCodeAt(p+1)]<<12|revLookup[e.charCodeAt(p+2)]<<6|revLookup[e.charCodeAt(p+3)],n[a++]=t>>16&255,n[a++]=t>>8&255,n[a++]=t&255;return o===2&&(t=revLookup[e.charCodeAt(p)]<<2|revLookup[e.charCodeAt(p+1)]>>4,n[a++]=t&255),o===1&&(t=revLookup[e.charCodeAt(p)]<<10|revLookup[e.charCodeAt(p+1)]<<4|revLookup[e.charCodeAt(p+2)]>>2,n[a++]=t>>8&255,n[a++]=t&255),n}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){for(var s,o=[],n=t;n<r;n+=3)s=(e[n]<<16&16711680)+(e[n+1]<<8&65280)+(e[n+2]&255),o.push(tripletToBase64(s));return o.join("")}function fromByteArray(e){for(var t,r=e.length,s=r%3,o=[],n=16383,a=0,l=r-s;a<l;a+=n)o.push(encodeChunk(e,a,a+n>l?l:a+n));return s===1?(t=e[r-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):s===2&&(t=(e[r-2]<<8)+e[r-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}var ieee754={};ieee754.read=function(e,t,r,s,o){var n,a,l=o*8-s-1,p=(1<<l)-1,u=p>>1,c=-7,v=r?o-1:0,w=r?-1:1,b=e[t+v];for(v+=w,n=b&(1<<-c)-1,b>>=-c,c+=l;c>0;n=n*256+e[t+v],v+=w,c-=8);for(a=n&(1<<-c)-1,n>>=-c,c+=s;c>0;a=a*256+e[t+v],v+=w,c-=8);if(n===0)n=1-u;else{if(n===p)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,s),n=n-u}return(b?-1:1)*a*Math.pow(2,n-s)};ieee754.write=function(e,t,r,s,o,n){var a,l,p,u=n*8-o-1,c=(1<<u)-1,v=c>>1,w=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=s?0:n-1,E=s?1:-1,I=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-a))<1&&(a--,p*=2),a+v>=1?t+=w/p:t+=w*Math.pow(2,1-v),t*p>=2&&(a++,p/=2),a+v>=c?(l=0,a=c):a+v>=1?(l=(t*p-1)*Math.pow(2,o),a=a+v):(l=t*Math.pow(2,v-1)*Math.pow(2,o),a=0));o>=8;e[r+b]=l&255,b+=E,l/=256,o-=8);for(a=a<<o|l,u+=o;u>0;e[r+b]=a&255,b+=E,a/=256,u-=8);e[r+b-E]|=I*128};(function(e){const t=base64Js,r=ieee754,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=F,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o;const{Uint8Array:n,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;c.TYPED_ARRAY_SUPPORT=p(),!c.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 p(){try{const re=new n(1),z={foo:function(){return 42}};return Object.setPrototypeOf(z,n.prototype),Object.setPrototypeOf(re,z),re.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function u(re){if(re>o)throw new RangeError('The value "'+re+'" is invalid for option "size"');const z=new n(re);return Object.setPrototypeOf(z,c.prototype),z}function c(re,z,Q){if(typeof re=="number"){if(typeof z=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(re)}return v(re,z,Q)}c.poolSize=8192;function v(re,z,Q){if(typeof re=="string")return I(re,z);if(a.isView(re))return B(re);if(re==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re);if(xe(re,a)||re&&xe(re.buffer,a)||typeof l<"u"&&(xe(re,l)||re&&xe(re.buffer,l)))return M(re,z,Q);if(typeof re=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const ue=re.valueOf&&re.valueOf();if(ue!=null&&ue!==re)return c.from(ue,z,Q);const we=q(re);if(we)return we;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof re[Symbol.toPrimitive]=="function")return c.from(re[Symbol.toPrimitive]("string"),z,Q);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re)}c.from=function(re,z,Q){return v(re,z,Q)},Object.setPrototypeOf(c.prototype,n.prototype),Object.setPrototypeOf(c,n);function w(re){if(typeof re!="number")throw new TypeError('"size" argument must be of type number');if(re<0)throw new RangeError('The value "'+re+'" is invalid for option "size"')}function b(re,z,Q){return w(re),re<=0?u(re):z!==void 0?typeof Q=="string"?u(re).fill(z,Q):u(re).fill(z):u(re)}c.alloc=function(re,z,Q){return b(re,z,Q)};function E(re){return w(re),u(re<0?0:U(re)|0)}c.allocUnsafe=function(re){return E(re)},c.allocUnsafeSlow=function(re){return E(re)};function I(re,z){if((typeof z!="string"||z==="")&&(z="utf8"),!c.isEncoding(z))throw new TypeError("Unknown encoding: "+z);const Q=j(re,z)|0;let ue=u(Q);const we=ue.write(re,z);return we!==Q&&(ue=ue.slice(0,we)),ue}function x(re){const z=re.length<0?0:U(re.length)|0,Q=u(z);for(let ue=0;ue<z;ue+=1)Q[ue]=re[ue]&255;return Q}function B(re){if(xe(re,n)){const z=new n(re);return M(z.buffer,z.byteOffset,z.byteLength)}return x(re)}function M(re,z,Q){if(z<0||re.byteLength<z)throw new RangeError('"offset" is outside of buffer bounds');if(re.byteLength<z+(Q||0))throw new RangeError('"length" is outside of buffer bounds');let ue;return z===void 0&&Q===void 0?ue=new n(re):Q===void 0?ue=new n(re,z):ue=new n(re,z,Q),Object.setPrototypeOf(ue,c.prototype),ue}function q(re){if(c.isBuffer(re)){const z=U(re.length)|0,Q=u(z);return Q.length===0||re.copy(Q,0,0,z),Q}if(re.length!==void 0)return typeof re.length!="number"||he(re.length)?u(0):x(re);if(re.type==="Buffer"&&Array.isArray(re.data))return x(re.data)}function U(re){if(re>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return re|0}function F(re){return+re!=re&&(re=0),c.alloc(+re)}c.isBuffer=function(z){return z!=null&&z._isBuffer===!0&&z!==c.prototype},c.compare=function(z,Q){if(xe(z,n)&&(z=c.from(z,z.offset,z.byteLength)),xe(Q,n)&&(Q=c.from(Q,Q.offset,Q.byteLength)),!c.isBuffer(z)||!c.isBuffer(Q))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(z===Q)return 0;let ue=z.length,we=Q.length;for(let Ne=0,De=Math.min(ue,we);Ne<De;++Ne)if(z[Ne]!==Q[Ne]){ue=z[Ne],we=Q[Ne];break}return ue<we?-1:we<ue?1:0},c.isEncoding=function(z){switch(String(z).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}},c.concat=function(z,Q){if(!Array.isArray(z))throw new TypeError('"list" argument must be an Array of Buffers');if(z.length===0)return c.alloc(0);let ue;if(Q===void 0)for(Q=0,ue=0;ue<z.length;++ue)Q+=z[ue].length;const we=c.allocUnsafe(Q);let Ne=0;for(ue=0;ue<z.length;++ue){let De=z[ue];if(xe(De,n))Ne+De.length>we.length?(c.isBuffer(De)||(De=c.from(De)),De.copy(we,Ne)):n.prototype.set.call(we,De,Ne);else if(c.isBuffer(De))De.copy(we,Ne);else throw new TypeError('"list" argument must be an Array of Buffers');Ne+=De.length}return we};function j(re,z){if(c.isBuffer(re))return re.length;if(a.isView(re)||xe(re,a))return re.byteLength;if(typeof re!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof re);const Q=re.length,ue=arguments.length>2&&arguments[2]===!0;if(!ue&&Q===0)return 0;let we=!1;for(;;)switch(z){case"ascii":case"latin1":case"binary":return Q;case"utf8":case"utf-8":return Ue(re).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q*2;case"hex":return Q>>>1;case"base64":return tt(re).length;default:if(we)return ue?-1:Ue(re).length;z=(""+z).toLowerCase(),we=!0}}c.byteLength=j;function y(re,z,Q){let ue=!1;if((z===void 0||z<0)&&(z=0),z>this.length||((Q===void 0||Q>this.length)&&(Q=this.length),Q<=0)||(Q>>>=0,z>>>=0,Q<=z))return"";for(re||(re="utf8");;)switch(re){case"hex":return H(this,z,Q);case"utf8":case"utf-8":return N(this,z,Q);case"ascii":return m(this,z,Q);case"latin1":case"binary":return P(this,z,Q);case"base64":return O(this,z,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J(this,z,Q);default:if(ue)throw new TypeError("Unknown encoding: "+re);re=(re+"").toLowerCase(),ue=!0}}c.prototype._isBuffer=!0;function T(re,z,Q){const ue=re[z];re[z]=re[Q],re[Q]=ue}c.prototype.swap16=function(){const z=this.length;if(z%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let Q=0;Q<z;Q+=2)T(this,Q,Q+1);return this},c.prototype.swap32=function(){const z=this.length;if(z%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let Q=0;Q<z;Q+=4)T(this,Q,Q+3),T(this,Q+1,Q+2);return this},c.prototype.swap64=function(){const z=this.length;if(z%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let Q=0;Q<z;Q+=8)T(this,Q,Q+7),T(this,Q+1,Q+6),T(this,Q+2,Q+5),T(this,Q+3,Q+4);return this},c.prototype.toString=function(){const z=this.length;return z===0?"":arguments.length===0?N(this,0,z):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(z){if(!c.isBuffer(z))throw new TypeError("Argument must be a Buffer");return this===z?!0:c.compare(this,z)===0},c.prototype.inspect=function(){let z="";const Q=e.INSPECT_MAX_BYTES;return z=this.toString("hex",0,Q).replace(/(.{2})/g,"$1 ").trim(),this.length>Q&&(z+=" ... "),"<Buffer "+z+">"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(z,Q,ue,we,Ne){if(xe(z,n)&&(z=c.from(z,z.offset,z.byteLength)),!c.isBuffer(z))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof z);if(Q===void 0&&(Q=0),ue===void 0&&(ue=z?z.length:0),we===void 0&&(we=0),Ne===void 0&&(Ne=this.length),Q<0||ue>z.length||we<0||Ne>this.length)throw new RangeError("out of range index");if(we>=Ne&&Q>=ue)return 0;if(we>=Ne)return-1;if(Q>=ue)return 1;if(Q>>>=0,ue>>>=0,we>>>=0,Ne>>>=0,this===z)return 0;let De=Ne-we,je=ue-Q;const ot=Math.min(De,je),He=this.slice(we,Ne),We=z.slice(Q,ue);for(let ht=0;ht<ot;++ht)if(He[ht]!==We[ht]){De=He[ht],je=We[ht];break}return De<je?-1:je<De?1:0};function D(re,z,Q,ue,we){if(re.length===0)return-1;if(typeof Q=="string"?(ue=Q,Q=0):Q>2147483647?Q=2147483647:Q<-2147483648&&(Q=-2147483648),Q=+Q,he(Q)&&(Q=we?0:re.length-1),Q<0&&(Q=re.length+Q),Q>=re.length){if(we)return-1;Q=re.length-1}else if(Q<0)if(we)Q=0;else return-1;if(typeof z=="string"&&(z=c.from(z,ue)),c.isBuffer(z))return z.length===0?-1:L(re,z,Q,ue,we);if(typeof z=="number")return z=z&255,typeof n.prototype.indexOf=="function"?we?n.prototype.indexOf.call(re,z,Q):n.prototype.lastIndexOf.call(re,z,Q):L(re,[z],Q,ue,we);throw new TypeError("val must be string, number or Buffer")}function L(re,z,Q,ue,we){let Ne=1,De=re.length,je=z.length;if(ue!==void 0&&(ue=String(ue).toLowerCase(),ue==="ucs2"||ue==="ucs-2"||ue==="utf16le"||ue==="utf-16le")){if(re.length<2||z.length<2)return-1;Ne=2,De/=2,je/=2,Q/=2}function ot(We,ht){return Ne===1?We[ht]:We.readUInt16BE(ht*Ne)}let He;if(we){let We=-1;for(He=Q;He<De;He++)if(ot(re,He)===ot(z,We===-1?0:He-We)){if(We===-1&&(We=He),He-We+1===je)return We*Ne}else We!==-1&&(He-=He-We),We=-1}else for(Q+je>De&&(Q=De-je),He=Q;He>=0;He--){let We=!0;for(let ht=0;ht<je;ht++)if(ot(re,He+ht)!==ot(z,ht)){We=!1;break}if(We)return He}return-1}c.prototype.includes=function(z,Q,ue){return this.indexOf(z,Q,ue)!==-1},c.prototype.indexOf=function(z,Q,ue){return D(this,z,Q,ue,!0)},c.prototype.lastIndexOf=function(z,Q,ue){return D(this,z,Q,ue,!1)};function C(re,z,Q,ue){Q=Number(Q)||0;const we=re.length-Q;ue?(ue=Number(ue),ue>we&&(ue=we)):ue=we;const Ne=z.length;ue>Ne/2&&(ue=Ne/2);let De;for(De=0;De<ue;++De){const je=parseInt(z.substr(De*2,2),16);if(he(je))return De;re[Q+De]=je}return De}function d(re,z,Q,ue){return Ie(Ue(z,re.length-Q),re,Q,ue)}function _(re,z,Q,ue){return Ie(Me(z),re,Q,ue)}function $(re,z,Q,ue){return Ie(tt(z),re,Q,ue)}function S(re,z,Q,ue){return Ie(ke(z,re.length-Q),re,Q,ue)}c.prototype.write=function(z,Q,ue,we){if(Q===void 0)we="utf8",ue=this.length,Q=0;else if(ue===void 0&&typeof Q=="string")we=Q,ue=this.length,Q=0;else if(isFinite(Q))Q=Q>>>0,isFinite(ue)?(ue=ue>>>0,we===void 0&&(we="utf8")):(we=ue,ue=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Ne=this.length-Q;if((ue===void 0||ue>Ne)&&(ue=Ne),z.length>0&&(ue<0||Q<0)||Q>this.length)throw new RangeError("Attempt to write outside buffer bounds");we||(we="utf8");let De=!1;for(;;)switch(we){case"hex":return C(this,z,Q,ue);case"utf8":case"utf-8":return d(this,z,Q,ue);case"ascii":case"latin1":case"binary":return _(this,z,Q,ue);case"base64":return $(this,z,Q,ue);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,z,Q,ue);default:if(De)throw new TypeError("Unknown encoding: "+we);we=(""+we).toLowerCase(),De=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(re,z,Q){return z===0&&Q===re.length?t.fromByteArray(re):t.fromByteArray(re.slice(z,Q))}function N(re,z,Q){Q=Math.min(re.length,Q);const ue=[];let we=z;for(;we<Q;){const Ne=re[we];let De=null,je=Ne>239?4:Ne>223?3:Ne>191?2:1;if(we+je<=Q){let ot,He,We,ht;switch(je){case 1:Ne<128&&(De=Ne);break;case 2:ot=re[we+1],(ot&192)===128&&(ht=(Ne&31)<<6|ot&63,ht>127&&(De=ht));break;case 3:ot=re[we+1],He=re[we+2],(ot&192)===128&&(He&192)===128&&(ht=(Ne&15)<<12|(ot&63)<<6|He&63,ht>2047&&(ht<55296||ht>57343)&&(De=ht));break;case 4:ot=re[we+1],He=re[we+2],We=re[we+3],(ot&192)===128&&(He&192)===128&&(We&192)===128&&(ht=(Ne&15)<<18|(ot&63)<<12|(He&63)<<6|We&63,ht>65535&&ht<1114112&&(De=ht))}}De===null?(De=65533,je=1):De>65535&&(De-=65536,ue.push(De>>>10&1023|55296),De=56320|De&1023),ue.push(De),we+=je}return A(ue)}const k=4096;function A(re){const z=re.length;if(z<=k)return String.fromCharCode.apply(String,re);let Q="",ue=0;for(;ue<z;)Q+=String.fromCharCode.apply(String,re.slice(ue,ue+=k));return Q}function m(re,z,Q){let ue="";Q=Math.min(re.length,Q);for(let we=z;we<Q;++we)ue+=String.fromCharCode(re[we]&127);return ue}function P(re,z,Q){let ue="";Q=Math.min(re.length,Q);for(let we=z;we<Q;++we)ue+=String.fromCharCode(re[we]);return ue}function H(re,z,Q){const ue=re.length;(!z||z<0)&&(z=0),(!Q||Q<0||Q>ue)&&(Q=ue);let we="";for(let Ne=z;Ne<Q;++Ne)we+=ae[re[Ne]];return we}function J(re,z,Q){const ue=re.slice(z,Q);let we="";for(let Ne=0;Ne<ue.length-1;Ne+=2)we+=String.fromCharCode(ue[Ne]+ue[Ne+1]*256);return we}c.prototype.slice=function(z,Q){const ue=this.length;z=~~z,Q=Q===void 0?ue:~~Q,z<0?(z+=ue,z<0&&(z=0)):z>ue&&(z=ue),Q<0?(Q+=ue,Q<0&&(Q=0)):Q>ue&&(Q=ue),Q<z&&(Q=z);const we=this.subarray(z,Q);return Object.setPrototypeOf(we,c.prototype),we};function X(re,z,Q){if(re%1!==0||re<0)throw new RangeError("offset is not uint");if(re+z>Q)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z],Ne=1,De=0;for(;++De<Q&&(Ne*=256);)we+=this[z+De]*Ne;return we},c.prototype.readUintBE=c.prototype.readUIntBE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z+--Q],Ne=1;for(;Q>0&&(Ne*=256);)we+=this[z+--Q]*Ne;return we},c.prototype.readUint8=c.prototype.readUInt8=function(z,Q){return z=z>>>0,Q||X(z,1,this.length),this[z]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(z,Q){return z=z>>>0,Q||X(z,2,this.length),this[z]|this[z+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(z,Q){return z=z>>>0,Q||X(z,2,this.length),this[z]<<8|this[z+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),(this[z]|this[z+1]<<8|this[z+2]<<16)+this[z+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]*16777216+(this[z+1]<<16|this[z+2]<<8|this[z+3])},c.prototype.readBigUInt64LE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=Q+this[++z]*2**8+this[++z]*2**16+this[++z]*2**24,Ne=this[++z]+this[++z]*2**8+this[++z]*2**16+ue*2**24;return BigInt(we)+(BigInt(Ne)<<BigInt(32))}),c.prototype.readBigUInt64BE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=Q*2**24+this[++z]*2**16+this[++z]*2**8+this[++z],Ne=this[++z]*2**24+this[++z]*2**16+this[++z]*2**8+ue;return(BigInt(we)<<BigInt(32))+BigInt(Ne)}),c.prototype.readIntLE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z],Ne=1,De=0;for(;++De<Q&&(Ne*=256);)we+=this[z+De]*Ne;return Ne*=128,we>=Ne&&(we-=Math.pow(2,8*Q)),we},c.prototype.readIntBE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=Q,Ne=1,De=this[z+--we];for(;we>0&&(Ne*=256);)De+=this[z+--we]*Ne;return Ne*=128,De>=Ne&&(De-=Math.pow(2,8*Q)),De},c.prototype.readInt8=function(z,Q){return z=z>>>0,Q||X(z,1,this.length),this[z]&128?(255-this[z]+1)*-1:this[z]},c.prototype.readInt16LE=function(z,Q){z=z>>>0,Q||X(z,2,this.length);const ue=this[z]|this[z+1]<<8;return ue&32768?ue|4294901760:ue},c.prototype.readInt16BE=function(z,Q){z=z>>>0,Q||X(z,2,this.length);const ue=this[z+1]|this[z]<<8;return ue&32768?ue|4294901760:ue},c.prototype.readInt32LE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]|this[z+1]<<8|this[z+2]<<16|this[z+3]<<24},c.prototype.readInt32BE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]<<24|this[z+1]<<16|this[z+2]<<8|this[z+3]},c.prototype.readBigInt64LE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=this[z+4]+this[z+5]*2**8+this[z+6]*2**16+(ue<<24);return(BigInt(we)<<BigInt(32))+BigInt(Q+this[++z]*2**8+this[++z]*2**16+this[++z]*2**24)}),c.prototype.readBigInt64BE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=(Q<<24)+this[++z]*2**16+this[++z]*2**8+this[++z];return(BigInt(we)<<BigInt(32))+BigInt(this[++z]*2**24+this[++z]*2**16+this[++z]*2**8+ue)}),c.prototype.readFloatLE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),r.read(this,z,!0,23,4)},c.prototype.readFloatBE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),r.read(this,z,!1,23,4)},c.prototype.readDoubleLE=function(z,Q){return z=z>>>0,Q||X(z,8,this.length),r.read(this,z,!0,52,8)},c.prototype.readDoubleBE=function(z,Q){return z=z>>>0,Q||X(z,8,this.length),r.read(this,z,!1,52,8)};function se(re,z,Q,ue,we,Ne){if(!c.isBuffer(re))throw new TypeError('"buffer" argument must be a Buffer instance');if(z>we||z<Ne)throw new RangeError('"value" argument is out of bounds');if(Q+ue>re.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,ue=ue>>>0,!we){const je=Math.pow(2,8*ue)-1;se(this,z,Q,ue,je,0)}let Ne=1,De=0;for(this[Q]=z&255;++De<ue&&(Ne*=256);)this[Q+De]=z/Ne&255;return Q+ue},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,ue=ue>>>0,!we){const je=Math.pow(2,8*ue)-1;se(this,z,Q,ue,je,0)}let Ne=ue-1,De=1;for(this[Q+Ne]=z&255;--Ne>=0&&(De*=256);)this[Q+Ne]=z/De&255;return Q+ue},c.prototype.writeUint8=c.prototype.writeUInt8=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,1,255,0),this[Q]=z&255,Q+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,65535,0),this[Q]=z&255,this[Q+1]=z>>>8,Q+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,65535,0),this[Q]=z>>>8,this[Q+1]=z&255,Q+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,4294967295,0),this[Q+3]=z>>>24,this[Q+2]=z>>>16,this[Q+1]=z>>>8,this[Q]=z&255,Q+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,4294967295,0),this[Q]=z>>>24,this[Q+1]=z>>>16,this[Q+2]=z>>>8,this[Q+3]=z&255,Q+4};function ne(re,z,Q,ue,we){me(z,ue,we,re,Q,7);let Ne=Number(z&BigInt(4294967295));re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne;let De=Number(z>>BigInt(32)&BigInt(4294967295));return re[Q++]=De,De=De>>8,re[Q++]=De,De=De>>8,re[Q++]=De,De=De>>8,re[Q++]=De,Q}function Z(re,z,Q,ue,we){me(z,ue,we,re,Q,7);let Ne=Number(z&BigInt(4294967295));re[Q+7]=Ne,Ne=Ne>>8,re[Q+6]=Ne,Ne=Ne>>8,re[Q+5]=Ne,Ne=Ne>>8,re[Q+4]=Ne;let De=Number(z>>BigInt(32)&BigInt(4294967295));return re[Q+3]=De,De=De>>8,re[Q+2]=De,De=De>>8,re[Q+1]=De,De=De>>8,re[Q]=De,Q+8}c.prototype.writeBigUInt64LE=be(function(z,Q=0){return ne(this,z,Q,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=be(function(z,Q=0){return Z(this,z,Q,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,!we){const ot=Math.pow(2,8*ue-1);se(this,z,Q,ue,ot-1,-ot)}let Ne=0,De=1,je=0;for(this[Q]=z&255;++Ne<ue&&(De*=256);)z<0&&je===0&&this[Q+Ne-1]!==0&&(je=1),this[Q+Ne]=(z/De>>0)-je&255;return Q+ue},c.prototype.writeIntBE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,!we){const ot=Math.pow(2,8*ue-1);se(this,z,Q,ue,ot-1,-ot)}let Ne=ue-1,De=1,je=0;for(this[Q+Ne]=z&255;--Ne>=0&&(De*=256);)z<0&&je===0&&this[Q+Ne+1]!==0&&(je=1),this[Q+Ne]=(z/De>>0)-je&255;return Q+ue},c.prototype.writeInt8=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,1,127,-128),z<0&&(z=255+z+1),this[Q]=z&255,Q+1},c.prototype.writeInt16LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,32767,-32768),this[Q]=z&255,this[Q+1]=z>>>8,Q+2},c.prototype.writeInt16BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,32767,-32768),this[Q]=z>>>8,this[Q+1]=z&255,Q+2},c.prototype.writeInt32LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,2147483647,-2147483648),this[Q]=z&255,this[Q+1]=z>>>8,this[Q+2]=z>>>16,this[Q+3]=z>>>24,Q+4},c.prototype.writeInt32BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,2147483647,-2147483648),z<0&&(z=4294967295+z+1),this[Q]=z>>>24,this[Q+1]=z>>>16,this[Q+2]=z>>>8,this[Q+3]=z&255,Q+4},c.prototype.writeBigInt64LE=be(function(z,Q=0){return ne(this,z,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=be(function(z,Q=0){return Z(this,z,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function oe(re,z,Q,ue,we,Ne){if(Q+ue>re.length)throw new RangeError("Index out of range");if(Q<0)throw new RangeError("Index out of range")}function ye(re,z,Q,ue,we){return z=+z,Q=Q>>>0,we||oe(re,z,Q,4),r.write(re,z,Q,ue,23,4),Q+4}c.prototype.writeFloatLE=function(z,Q,ue){return ye(this,z,Q,!0,ue)},c.prototype.writeFloatBE=function(z,Q,ue){return ye(this,z,Q,!1,ue)};function Y(re,z,Q,ue,we){return z=+z,Q=Q>>>0,we||oe(re,z,Q,8),r.write(re,z,Q,ue,52,8),Q+8}c.prototype.writeDoubleLE=function(z,Q,ue){return Y(this,z,Q,!0,ue)},c.prototype.writeDoubleBE=function(z,Q,ue){return Y(this,z,Q,!1,ue)},c.prototype.copy=function(z,Q,ue,we){if(!c.isBuffer(z))throw new TypeError("argument should be a Buffer");if(ue||(ue=0),!we&&we!==0&&(we=this.length),Q>=z.length&&(Q=z.length),Q||(Q=0),we>0&&we<ue&&(we=ue),we===ue||z.length===0||this.length===0)return 0;if(Q<0)throw new RangeError("targetStart out of bounds");if(ue<0||ue>=this.length)throw new RangeError("Index out of range");if(we<0)throw new RangeError("sourceEnd out of bounds");we>this.length&&(we=this.length),z.length-Q<we-ue&&(we=z.length-Q+ue);const Ne=we-ue;return this===z&&typeof n.prototype.copyWithin=="function"?this.copyWithin(Q,ue,we):n.prototype.set.call(z,this.subarray(ue,we),Q),Ne},c.prototype.fill=function(z,Q,ue,we){if(typeof z=="string"){if(typeof Q=="string"?(we=Q,Q=0,ue=this.length):typeof ue=="string"&&(we=ue,ue=this.length),we!==void 0&&typeof we!="string")throw new TypeError("encoding must be a string");if(typeof we=="string"&&!c.isEncoding(we))throw new TypeError("Unknown encoding: "+we);if(z.length===1){const De=z.charCodeAt(0);(we==="utf8"&&De<128||we==="latin1")&&(z=De)}}else typeof z=="number"?z=z&255:typeof z=="boolean"&&(z=Number(z));if(Q<0||this.length<Q||this.length<ue)throw new RangeError("Out of range index");if(ue<=Q)return this;Q=Q>>>0,ue=ue===void 0?this.length:ue>>>0,z||(z=0);let Ne;if(typeof z=="number")for(Ne=Q;Ne<ue;++Ne)this[Ne]=z;else{const De=c.isBuffer(z)?z:c.from(z,we),je=De.length;if(je===0)throw new TypeError('The value "'+z+'" is invalid for argument "value"');for(Ne=0;Ne<ue-Q;++Ne)this[Ne+Q]=De[Ne%je]}return this};const G={};function V(re,z,Q){G[re]=class extends Q{constructor(){super(),Object.defineProperty(this,"message",{value:z.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${re}]`,this.stack,delete this.name}get code(){return re}set code(we){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:we,writable:!0})}toString(){return`${this.name} [${re}]: ${this.message}`}}}V("ERR_BUFFER_OUT_OF_BOUNDS",function(re){return re?`${re} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),V("ERR_INVALID_ARG_TYPE",function(re,z){return`The "${re}" argument must be of type number. Received type ${typeof z}`},TypeError),V("ERR_OUT_OF_RANGE",function(re,z,Q){let ue=`The value of "${re}" is out of range.`,we=Q;return Number.isInteger(Q)&&Math.abs(Q)>2**32?we=te(String(Q)):typeof Q=="bigint"&&(we=String(Q),(Q>BigInt(2)**BigInt(32)||Q<-(BigInt(2)**BigInt(32)))&&(we=te(we)),we+="n"),ue+=` It must be ${z}. Received ${we}`,ue},RangeError);function te(re){let z="",Q=re.length;const ue=re[0]==="-"?1:0;for(;Q>=ue+4;Q-=3)z=`_${re.slice(Q-3,Q)}${z}`;return`${re.slice(0,Q)}${z}`}function le(re,z,Q){Re(z,"offset"),(re[z]===void 0||re[z+Q]===void 0)&&Be(z,re.length-(Q+1))}function me(re,z,Q,ue,we,Ne){if(re>Q||re<z){const De=typeof z=="bigint"?"n":"";let je;throw z===0||z===BigInt(0)?je=`>= 0${De} and < 2${De} ** ${(Ne+1)*8}${De}`:je=`>= -(2${De} ** ${(Ne+1)*8-1}${De}) and < 2 ** ${(Ne+1)*8-1}${De}`,new G.ERR_OUT_OF_RANGE("value",je,re)}le(ue,we,Ne)}function Re(re,z){if(typeof re!="number")throw new G.ERR_INVALID_ARG_TYPE(z,"number",re)}function Be(re,z,Q){throw Math.floor(re)!==re?(Re(re,Q),new G.ERR_OUT_OF_RANGE("offset","an integer",re)):z<0?new G.ERR_BUFFER_OUT_OF_BOUNDS:new G.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${z}`,re)}const Ce=/[^+/0-9A-Za-z-_]/g;function $e(re){if(re=re.split("=")[0],re=re.trim().replace(Ce,""),re.length<2)return"";for(;re.length%4!==0;)re=re+"=";return re}function Ue(re,z){z=z||1/0;let Q;const ue=re.length;let we=null;const Ne=[];for(let De=0;De<ue;++De){if(Q=re.charCodeAt(De),Q>55295&&Q<57344){if(!we){if(Q>56319){(z-=3)>-1&&Ne.push(239,191,189);continue}else if(De+1===ue){(z-=3)>-1&&Ne.push(239,191,189);continue}we=Q;continue}if(Q<56320){(z-=3)>-1&&Ne.push(239,191,189),we=Q;continue}Q=(we-55296<<10|Q-56320)+65536}else we&&(z-=3)>-1&&Ne.push(239,191,189);if(we=null,Q<128){if((z-=1)<0)break;Ne.push(Q)}else if(Q<2048){if((z-=2)<0)break;Ne.push(Q>>6|192,Q&63|128)}else if(Q<65536){if((z-=3)<0)break;Ne.push(Q>>12|224,Q>>6&63|128,Q&63|128)}else if(Q<1114112){if((z-=4)<0)break;Ne.push(Q>>18|240,Q>>12&63|128,Q>>6&63|128,Q&63|128)}else throw new Error("Invalid code point")}return Ne}function Me(re){const z=[];for(let Q=0;Q<re.length;++Q)z.push(re.charCodeAt(Q)&255);return z}function ke(re,z){let Q,ue,we;const Ne=[];for(let De=0;De<re.length&&!((z-=2)<0);++De)Q=re.charCodeAt(De),ue=Q>>8,we=Q%256,Ne.push(we),Ne.push(ue);return Ne}function tt(re){return t.toByteArray($e(re))}function Ie(re,z,Q,ue){let we;for(we=0;we<ue&&!(we+Q>=z.length||we>=re.length);++we)z[we+Q]=re[we];return we}function xe(re,z){return re instanceof z||re!=null&&re.constructor!=null&&re.constructor.name!=null&&re.constructor.name===z.name}function he(re){return re!==re}const ae=function(){const re="0123456789abcdef",z=new Array(256);for(let Q=0;Q<16;++Q){const ue=Q*16;for(let we=0;we<16;++we)z[ue+we]=re[Q]+re[we]}return z}();function be(re){return typeof BigInt>"u"?Ae:re}function Ae(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer$e=buffer$1.Buffer,Blob$1=buffer$1.Blob,BlobOptions=buffer$1.BlobOptions,Buffer$1$1=buffer$1.Buffer,File=buffer$1.File,FileOptions$1=buffer$1.FileOptions,INSPECT_MAX_BYTES=buffer$1.INSPECT_MAX_BYTES,SlowBuffer=buffer$1.SlowBuffer,TranscodeEncoding=buffer$1.TranscodeEncoding,atob=buffer$1.atob,btoa=buffer$1.btoa,constants$5=buffer$1.constants,isAscii=buffer$1.isAscii,isUtf8=buffer$1.isUtf8,kMaxLength=buffer$1.kMaxLength,kStringMaxLength=buffer$1.kStringMaxLength,resolveObjectURL=buffer$1.resolveObjectURL,transcode=buffer$1.transcode,dist$w=Object.freeze(Object.defineProperty({__proto__:null,Blob:Blob$1,BlobOptions,Buffer:Buffer$1$1,File,FileOptions:FileOptions$1,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding,atob,btoa,constants:constants$5,default:Buffer$e,isAscii,isUtf8,kMaxLength,kStringMaxLength,resolveObjectURL,transcode},Symbol.toStringTag,{value:"Module"})),WALLET_PROVIDER_NAME$6="Keplr";class KeplrProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("keplr_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("keplr_keystorechange",r)});if(this.keplr=t,!t)throw new Error("Keplr extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.keplr)throw new Error("Keplr extension not found");try{await this.keplr.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId))try{await this.keplr.experimentalSuggestChain(this.chainData),await this.keplr.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("Keplr wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("Keplr extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to Keplr")}const t=await this.keplr.getKey(this.chainId);if(!t)throw new Error("Failed to get Keplr key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to Keplr")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$6}async getWalletProviderIcon(){return logo$6}async getOfflineSigner(){if(!this.keplr)throw new Error("Keplr extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.keplr.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.keplr)throw new Error("Keplr extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.keplr.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$a={id:"keplr",name:WALLET_PROVIDER_NAME$6,icon:logo$6,docs:"https://www.keplr.app/",wallet:"keplr",createProvider:(e,t)=>new KeplrProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$5="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='58'%20height='58'%3e%3cg%20fill='none'%20fill-rule='nonzero'%3e%3cpath%20fill='%2324A95A'%20stroke='%23138D3E'%20stroke-width='.039'%20d='M51.466%2036.118c0%204.001-2.44%206.816-6.403%208.631-3.963%201.816-9.446%202.631-15.522%202.631-6.077%200-11.595-.815-15.594-2.63-3.999-1.816-6.474-4.631-6.474-8.632%200-4.002%202.46-7.625%206.44-10.248%203.982-2.623%209.482-4.245%2015.556-4.245%206.075%200%2011.575%201.626%2015.556%204.25%203.981%202.625%206.441%206.248%206.441%2010.243Z'/%3e%3cpath%20fill='%2332DA6D'%20stroke='%23138D3E'%20stroke-width='.039'%20d='m35.608%2013.791.012.003.007-.009A7.686%207.686%200%200%201%2041.555%2011c4.236%200%207.675%203.421%207.675%207.634%200%201.385-.37%202.671-1.009%203.788l-.005.009.004.01a9.644%209.644%200%200%201%20.94%204.13c0%203.711-2.198%207.072-5.753%209.505-3.555%202.434-8.468%203.939-13.893%203.939-5.426%200-10.339-1.505-13.894-3.939-3.555-2.433-5.752-5.794-5.752-9.506%200-1.442.327-2.829.939-4.13l.004-.009-.005-.009a7.583%207.583%200%200%201-1.01-3.788c0-4.213%203.44-7.634%207.676-7.634a7.73%207.73%200%200%201%205.928%202.785l.007.01.012-.004a27.43%2027.43%200%200%201%206.095-.665c2.121%200%204.172.24%206.094.665Z'/%3e%3cpath%20fill='%23FFF'%20d='M16.845%2022.88c2.597%200%204.703-2.094%204.703-4.677%200-2.583-2.106-4.677-4.703-4.677-2.597%200-4.702%202.094-4.702%204.677%200%202.583%202.105%204.677%204.702%204.677ZM41.932%2022.88c2.597%200%204.702-2.094%204.702-4.677%200-2.583-2.105-4.677-4.702-4.677-2.598%200-4.703%202.094-4.703%204.677%200%202.583%202.105%204.677%204.703%204.677Z'/%3e%3cpath%20fill='%2332DA6D'%20stroke='%23138D3E'%20stroke-width='.039'%20d='M4.032%2044.13a.163.163%200%200%200%20.018-.008l-.002-.004-.004-.01-.017-.046-.066-.174a70.962%2070.962%200%200%201-1.02-2.947c-.6-1.87-1.295-4.301-1.669-6.54-.187-1.12-.293-2.192-.268-3.122.025-.93.181-1.716.52-2.266.337-.55.855-.865%201.608-.856.754.01%201.746.347%203.027%201.108%207.702%204.573%209.453%2012.176%209.866%2015.688.113.98-.676%201.85-1.676%201.85H2.308c-.794%200-1.084-1.037-.39-1.438l2.123-1.219.015-.008-.006-.016-.018.007ZM54.276%2044.123l.018.006a.481.481%200%200%201-.018-.006v-.001l.002-.003.003-.011.016-.045a44.607%2044.607%200%200%200%20.276-.83c.183-.56.433-1.356.705-2.291.543-1.871%201.17-4.302%201.507-6.541.169-1.12.265-2.192.242-3.122-.023-.93-.165-1.716-.47-2.267a1.677%201.677%200%200%200-.587-.637%201.587%201.587%200%200%200-.867-.218c-.681.01-1.577.346-2.736%201.107-6.946%204.573-8.541%2012.19-8.897%2015.69-.1.982.606%201.849%201.505%201.849h10.887c.352%200%20.596-.258.672-.569.077-.31-.014-.67-.326-.87l-1.932-1.241Zm0%200-.005.014.013.009%201.924%201.218-1.932-1.241Z'/%3e%3cpath%20fill='%23092511'%20d='M16.893%2021.02a2.805%202.805%200%201%200%200-5.61%202.805%202.805%200%200%200%200%205.61ZM41.98%2021.02a2.805%202.805%200%201%200%200-5.61%202.805%202.805%200%200%200%200%205.61ZM36.998%2029.488a7.536%207.536%200%200%201-10.976%206.042%207.534%207.534%200%200%201-4.037-7.334l7.507.646%207.506.646Z'/%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME$5="Leap";class LeapProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("leap_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("leap_keystorechange",r)});if(this.wallet=t,!t)throw new Error("Leap extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.wallet)throw new Error("Leap extension not found");try{await this.wallet.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId)||o!=null&&o.message.includes("chain id"))try{await this.wallet.experimentalSuggestChain(this.chainData),await this.wallet.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("Leap wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("Leap extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to Leap")}const t=await this.wallet.getKey(this.chainId);if(!t)throw new Error("Failed to get Leap key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to Leap")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$5}async getWalletProviderIcon(){return logo$5}async getOfflineSigner(){if(!this.wallet)throw new Error("Leap extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.wallet)throw new Error("Leap extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$9={id:"leap",name:WALLET_PROVIDER_NAME$5,icon:logo$5,docs:"https://www.leapwallet.io/",wallet:"leap",createProvider:(e,t)=>new LeapProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$4="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='225px'%20height='224px'%20viewBox='0%200%20225%20224'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eokx%3c/title%3e%3cg%20id='Page-1'%20stroke='none'%20strokeWidth='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='okx'%20transform='translate(0.401000,%200.006000)'%20fill='%23000000'%20fill-rule='nonzero'%3e%3cpath%20d='M144.382,74.667%20L79.673,74.667%20C76.924,74.667%2074.695,76.895%2074.695,79.644%20L74.695,144.354%20C74.695,147.103%2076.924,149.332%2079.673,149.332%20L144.382,149.332%20C147.131,149.332%20149.36,147.103%20149.36,144.354%20L149.36,79.644%20C149.36,76.895%20147.131,74.667%20144.382,74.667%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,0%20L4.978,0%20C2.229,0%200,2.228%200,4.978%20L0,69.687%20C0,72.436%202.229,74.665%204.978,74.665%20L69.687,74.665%20C72.437,74.665%2074.665,72.436%2074.665,69.687%20L74.665,4.978%20C74.665,2.228%2072.437,0%2069.687,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,0%20L154.307,0%20C151.558,0%20149.329,2.228%20149.329,4.978%20L149.329,69.687%20C149.329,72.436%20151.558,74.665%20154.307,74.665%20L219.017,74.665%20C221.766,74.665%20223.994,72.436%20223.994,69.687%20L223.994,4.978%20C223.994,2.228%20221.766,0%20219.017,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,149.328%20L4.978,149.328%20C2.229,149.328%200,151.556%200,154.305%20L0,219.015%20C0,221.764%202.229,223.993%204.978,223.993%20L69.687,223.993%20C72.437,223.993%2074.665,221.764%2074.665,219.015%20L74.665,154.305%20C74.665,151.556%2072.437,149.328%2069.687,149.328%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,149.328%20L154.307,149.328%20C151.558,149.328%20149.329,151.556%20149.329,154.305%20L149.329,219.015%20C149.329,221.764%20151.558,223.993%20154.307,223.993%20L219.017,223.993%20C221.766,223.993%20223.994,221.764%20223.994,219.015%20L223.994,154.305%20C223.994,151.556%20221.766,149.328%20219.017,149.328%20Z'%20id='Path'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME$4="OKX";class OKXBabylonProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("okx_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("okx_keystorechange",r)});if(this.wallet=t,!t||!t.keplr)throw new Error("OKX Wallet extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");try{await this.wallet.keplr.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId))try{await this.wallet.keplr.experimentalSuggestChain(this.chainData),await this.wallet.keplr.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("OKX Wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("OKX Wallet extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to OKX Wallet")}const t=await this.wallet.keplr.getKey(this.chainId);if(!t)throw new Error("Failed to get OKX Wallet key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to OKX Wallet")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$4}async getWalletProviderIcon(){return logo$4}async getOfflineSigner(){if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.keplr.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.keplr.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$8={id:"okx",name:WALLET_PROVIDER_NAME$4,icon:logo$4,docs:"https://www.okx.com/web3",wallet:"okxwallet",createProvider:(e,t)=>new OKXBabylonProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},metadata$7={chain:"BBN",name:"Babylon Chain",icon:icon$1,wallets:[metadata$b,metadata$8,metadata$a,metadata$9]},icon="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='64'%20height='64'%3e%3cpath%20fill='%23f7931a'%20d='M63.04%2039.741c-4.275%2017.143-21.638%2027.576-38.783%2023.301C7.12%2058.768-3.313%2041.404.962%2024.262%205.234%207.117%2022.597-3.317%2039.737.957c17.144%204.274%2027.576%2021.64%2023.302%2038.784z'/%3e%3cpath%20fill='%23FFF'%20d='M46.11%2027.441c.636-4.258-2.606-6.547-7.039-8.074l1.438-5.768-3.51-.875-1.4%205.616c-.924-.23-1.872-.447-2.814-.662l1.41-5.653-3.509-.875-1.439%205.766c-.764-.174-1.514-.346-2.242-.527l.004-.018-4.842-1.209-.934%203.75s2.605.597%202.55.634c1.422.355%201.68%201.296%201.636%202.042l-1.638%206.571c.098.025.225.061.365.117l-.37-.092-2.297%209.205c-.174.432-.615%201.08-1.609.834.035.051-2.552-.637-2.552-.637l-1.743%204.019%204.57%201.139c.85.213%201.682.436%202.502.646l-1.453%205.834%203.507.875%201.44-5.772c.957.26%201.887.5%202.797.726l-1.434%205.745%203.511.875%201.453-5.823c5.987%201.133%2010.49.676%2012.384-4.739%201.527-4.36-.076-6.875-3.226-8.515%202.294-.529%204.022-2.038%204.483-5.155zM38.086%2038.69c-1.085%204.36-8.426%202.003-10.806%201.412l1.928-7.729c2.38.594%2010.012%201.77%208.878%206.317zm1.086-11.312c-.99%203.966-7.1%201.951-9.082%201.457l1.748-7.01c1.982.494%208.365%201.416%207.334%205.553z'/%3e%3c/svg%3e",metadata$6={id:"injectable",name:e=>{var t;return(t=e.getWalletProviderName)==null?void 0:t.call(e)},icon:e=>{var t;return(t=e.getWalletProviderIcon)==null?void 0:t.call(e)},docs:"",wallet:"btcwallet",createProvider:e=>e,networks:[Network.MAINNET,Network.SIGNET],label:"Injectable"},logo$3="data:image/svg+xml,%3csvg%20width='160'%20height='160'%20viewBox='0%200%20160%20160'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M30%2025H90L50%20110H20L30%2025Z'%20fill='black'/%3e%3cpath%20d='M130%20135L70%20135L110%2050L140%2050L130%20135Z'%20fill='%23F5870A'/%3e%3c/svg%3e";var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function s(){return this instanceof s?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(s){var o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,o.get?o:{enumerable:!0,get:function(){return e[s]}})}),r}var dist$v={},utils$o={},stringHelper={},commonjsBrowser$3={},v1$d={},rng$e={};Object.defineProperty(rng$e,"__esModule",{value:!0});rng$e.default=rng$d;let getRandomValues$a;const rnds8$a=new Uint8Array(16);function rng$d(){if(!getRandomValues$a&&(getRandomValues$a=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!getRandomValues$a))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues$a(rnds8$a)}var stringify$d={},validate$d={},regex$3={};Object.defineProperty(regex$3,"__esModule",{value:!0});regex$3.default=void 0;var _default$c=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;regex$3.default=_default$c;Object.defineProperty(validate$d,"__esModule",{value:!0});validate$d.default=void 0;var _regex=_interopRequireDefault$8(regex$3);function _interopRequireDefault$8(e){return e&&e.__esModule?e:{default:e}}function validate$c(e){return typeof e=="string"&&_regex.default.test(e)}var _default$b=validate$c;validate$d.default=_default$b;Object.defineProperty(stringify$d,"__esModule",{value:!0});stringify$d.default=void 0;stringify$d.unsafeStringify=unsafeStringify$1;var _validate$2=_interopRequireDefault$7(validate$d);function _interopRequireDefault$7(e){return e&&e.__esModule?e:{default:e}}const byteToHex$a=[];for(let e=0;e<256;++e)byteToHex$a.push((e+256).toString(16).slice(1));function unsafeStringify$1(e,t=0){return byteToHex$a[e[t+0]]+byteToHex$a[e[t+1]]+byteToHex$a[e[t+2]]+byteToHex$a[e[t+3]]+"-"+byteToHex$a[e[t+4]]+byteToHex$a[e[t+5]]+"-"+byteToHex$a[e[t+6]]+byteToHex$a[e[t+7]]+"-"+byteToHex$a[e[t+8]]+byteToHex$a[e[t+9]]+"-"+byteToHex$a[e[t+10]]+byteToHex$a[e[t+11]]+byteToHex$a[e[t+12]]+byteToHex$a[e[t+13]]+byteToHex$a[e[t+14]]+byteToHex$a[e[t+15]]}function stringify$c(e,t=0){const r=unsafeStringify$1(e,t);if(!(0,_validate$2.default)(r))throw TypeError("Stringified UUID is invalid");return r}var _default$a=stringify$c;stringify$d.default=_default$a;Object.defineProperty(v1$d,"__esModule",{value:!0});v1$d.default=void 0;var _rng$1=_interopRequireDefault$6(rng$e),_stringify$2=stringify$d;function _interopRequireDefault$6(e){return e&&e.__esModule?e:{default:e}}let _nodeId$9,_clockseq$9,_lastMSecs$9=0,_lastNSecs$9=0;function v1$c(e,t,r){let s=t&&r||0;const o=t||new Array(16);e=e||{};let n=e.node||_nodeId$9,a=e.clockseq!==void 0?e.clockseq:_clockseq$9;if(n==null||a==null){const w=e.random||(e.rng||_rng$1.default)();n==null&&(n=_nodeId$9=[w[0]|1,w[1],w[2],w[3],w[4],w[5]]),a==null&&(a=_clockseq$9=(w[6]<<8|w[7])&16383)}let l=e.msecs!==void 0?e.msecs:Date.now(),p=e.nsecs!==void 0?e.nsecs:_lastNSecs$9+1;const u=l-_lastMSecs$9+(p-_lastNSecs$9)/1e4;if(u<0&&e.clockseq===void 0&&(a=a+1&16383),(u<0||l>_lastMSecs$9)&&e.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs$9=l,_lastNSecs$9=p,_clockseq$9=a,l+=122192928e5;const c=((l&268435455)*1e4+p)%4294967296;o[s++]=c>>>24&255,o[s++]=c>>>16&255,o[s++]=c>>>8&255,o[s++]=c&255;const v=l/4294967296*1e4&268435455;o[s++]=v>>>8&255,o[s++]=v&255,o[s++]=v>>>24&15|16,o[s++]=v>>>16&255,o[s++]=a>>>8|128,o[s++]=a&255;for(let w=0;w<6;++w)o[s+w]=n[w];return t||(0,_stringify$2.unsafeStringify)(o)}var _default$9=v1$c;v1$d.default=_default$9;var v3$d={},v35$d={},parse$d={};Object.defineProperty(parse$d,"__esModule",{value:!0});parse$d.default=void 0;var _validate$1=_interopRequireDefault$5(validate$d);function _interopRequireDefault$5(e){return e&&e.__esModule?e:{default:e}}function parse$c(e){if(!(0,_validate$1.default)(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var _default$8=parse$c;parse$d.default=_default$8;Object.defineProperty(v35$d,"__esModule",{value:!0});v35$d.URL=v35$d.DNS=void 0;v35$d.default=v35$c;var _stringify$1=stringify$d,_parse=_interopRequireDefault$4(parse$d);function _interopRequireDefault$4(e){return e&&e.__esModule?e:{default:e}}function stringToBytes$9(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}const DNS$9="6ba7b810-9dad-11d1-80b4-00c04fd430c8";v35$d.DNS=DNS$9;const URL$9="6ba7b811-9dad-11d1-80b4-00c04fd430c8";v35$d.URL=URL$9;function v35$c(e,t,r){function s(o,n,a,l){var p;if(typeof o=="string"&&(o=stringToBytes$9(o)),typeof n=="string"&&(n=(0,_parse.default)(n)),((p=n)===null||p===void 0?void 0:p.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+o.length);if(u.set(n),u.set(o,n.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,a){l=l||0;for(let c=0;c<16;++c)a[l+c]=u[c];return a}return(0,_stringify$1.unsafeStringify)(u)}try{s.name=e}catch{}return s.DNS=DNS$9,s.URL=URL$9,s}var md5$e={};Object.defineProperty(md5$e,"__esModule",{value:!0});md5$e.default=void 0;function md5$d(e){if(typeof e=="string"){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return md5ToHexEncodedArray$9(wordsToMd5$9(bytesToWords$9(e),e.length*8))}function md5ToHexEncodedArray$9(e){const t=[],r=e.length*32,s="0123456789abcdef";for(let o=0;o<r;o+=8){const n=e[o>>5]>>>o%32&255,a=parseInt(s.charAt(n>>>4&15)+s.charAt(n&15),16);t.push(a)}return t}function getOutputLength$9(e){return(e+64>>>9<<4)+14+1}function wordsToMd5$9(e,t){e[t>>5]|=128<<t%32,e[getOutputLength$9(t)-1]=t;let r=1732584193,s=-271733879,o=-1732584194,n=271733878;for(let a=0;a<e.length;a+=16){const l=r,p=s,u=o,c=n;r=md5ff$9(r,s,o,n,e[a],7,-680876936),n=md5ff$9(n,r,s,o,e[a+1],12,-389564586),o=md5ff$9(o,n,r,s,e[a+2],17,606105819),s=md5ff$9(s,o,n,r,e[a+3],22,-1044525330),r=md5ff$9(r,s,o,n,e[a+4],7,-176418897),n=md5ff$9(n,r,s,o,e[a+5],12,1200080426),o=md5ff$9(o,n,r,s,e[a+6],17,-1473231341),s=md5ff$9(s,o,n,r,e[a+7],22,-45705983),r=md5ff$9(r,s,o,n,e[a+8],7,1770035416),n=md5ff$9(n,r,s,o,e[a+9],12,-1958414417),o=md5ff$9(o,n,r,s,e[a+10],17,-42063),s=md5ff$9(s,o,n,r,e[a+11],22,-1990404162),r=md5ff$9(r,s,o,n,e[a+12],7,1804603682),n=md5ff$9(n,r,s,o,e[a+13],12,-40341101),o=md5ff$9(o,n,r,s,e[a+14],17,-1502002290),s=md5ff$9(s,o,n,r,e[a+15],22,1236535329),r=md5gg$9(r,s,o,n,e[a+1],5,-165796510),n=md5gg$9(n,r,s,o,e[a+6],9,-1069501632),o=md5gg$9(o,n,r,s,e[a+11],14,643717713),s=md5gg$9(s,o,n,r,e[a],20,-373897302),r=md5gg$9(r,s,o,n,e[a+5],5,-701558691),n=md5gg$9(n,r,s,o,e[a+10],9,38016083),o=md5gg$9(o,n,r,s,e[a+15],14,-660478335),s=md5gg$9(s,o,n,r,e[a+4],20,-405537848),r=md5gg$9(r,s,o,n,e[a+9],5,568446438),n=md5gg$9(n,r,s,o,e[a+14],9,-1019803690),o=md5gg$9(o,n,r,s,e[a+3],14,-187363961),s=md5gg$9(s,o,n,r,e[a+8],20,1163531501),r=md5gg$9(r,s,o,n,e[a+13],5,-1444681467),n=md5gg$9(n,r,s,o,e[a+2],9,-51403784),o=md5gg$9(o,n,r,s,e[a+7],14,1735328473),s=md5gg$9(s,o,n,r,e[a+12],20,-1926607734),r=md5hh$9(r,s,o,n,e[a+5],4,-378558),n=md5hh$9(n,r,s,o,e[a+8],11,-2022574463),o=md5hh$9(o,n,r,s,e[a+11],16,1839030562),s=md5hh$9(s,o,n,r,e[a+14],23,-35309556),r=md5hh$9(r,s,o,n,e[a+1],4,-1530992060),n=md5hh$9(n,r,s,o,e[a+4],11,1272893353),o=md5hh$9(o,n,r,s,e[a+7],16,-155497632),s=md5hh$9(s,o,n,r,e[a+10],23,-1094730640),r=md5hh$9(r,s,o,n,e[a+13],4,681279174),n=md5hh$9(n,r,s,o,e[a],11,-358537222),o=md5hh$9(o,n,r,s,e[a+3],16,-722521979),s=md5hh$9(s,o,n,r,e[a+6],23,76029189),r=md5hh$9(r,s,o,n,e[a+9],4,-640364487),n=md5hh$9(n,r,s,o,e[a+12],11,-421815835),o=md5hh$9(o,n,r,s,e[a+15],16,530742520),s=md5hh$9(s,o,n,r,e[a+2],23,-995338651),r=md5ii$9(r,s,o,n,e[a],6,-198630844),n=md5ii$9(n,r,s,o,e[a+7],10,1126891415),o=md5ii$9(o,n,r,s,e[a+14],15,-1416354905),s=md5ii$9(s,o,n,r,e[a+5],21,-57434055),r=md5ii$9(r,s,o,n,e[a+12],6,1700485571),n=md5ii$9(n,r,s,o,e[a+3],10,-1894986606),o=md5ii$9(o,n,r,s,e[a+10],15,-1051523),s=md5ii$9(s,o,n,r,e[a+1],21,-2054922799),r=md5ii$9(r,s,o,n,e[a+8],6,1873313359),n=md5ii$9(n,r,s,o,e[a+15],10,-30611744),o=md5ii$9(o,n,r,s,e[a+6],15,-1560198380),s=md5ii$9(s,o,n,r,e[a+13],21,1309151649),r=md5ii$9(r,s,o,n,e[a+4],6,-145523070),n=md5ii$9(n,r,s,o,e[a+11],10,-1120210379),o=md5ii$9(o,n,r,s,e[a+2],15,718787259),s=md5ii$9(s,o,n,r,e[a+9],21,-343485551),r=safeAdd$9(r,l),s=safeAdd$9(s,p),o=safeAdd$9(o,u),n=safeAdd$9(n,c)}return[r,s,o,n]}function bytesToWords$9(e){if(e.length===0)return[];const t=e.length*8,r=new Uint32Array(getOutputLength$9(t));for(let s=0;s<t;s+=8)r[s>>5]|=(e[s/8]&255)<<s%32;return r}function safeAdd$9(e,t){const r=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(r>>16)<<16|r&65535}function bitRotateLeft$9(e,t){return e<<t|e>>>32-t}function md5cmn$9(e,t,r,s,o,n){return safeAdd$9(bitRotateLeft$9(safeAdd$9(safeAdd$9(t,e),safeAdd$9(s,n)),o),r)}function md5ff$9(e,t,r,s,o,n,a){return md5cmn$9(t&r|~t&s,e,t,o,n,a)}function md5gg$9(e,t,r,s,o,n,a){return md5cmn$9(t&s|r&~s,e,t,o,n,a)}function md5hh$9(e,t,r,s,o,n,a){return md5cmn$9(t^r^s,e,t,o,n,a)}function md5ii$9(e,t,r,s,o,n,a){return md5cmn$9(r^(t|~s),e,t,o,n,a)}var _default$7=md5$d;md5$e.default=_default$7;Object.defineProperty(v3$d,"__esModule",{value:!0});v3$d.default=void 0;var _v$1=_interopRequireDefault$3(v35$d),_md$2=_interopRequireDefault$3(md5$e);function _interopRequireDefault$3(e){return e&&e.__esModule?e:{default:e}}const v3$c=(0,_v$1.default)("v3",48,_md$2.default);var _default$6=v3$c;v3$d.default=_default$6;var v4$e={},native$6={};Object.defineProperty(native$6,"__esModule",{value:!0});native$6.default=void 0;const randomUUID$1=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var _default$5={randomUUID:randomUUID$1};native$6.default=_default$5;Object.defineProperty(v4$e,"__esModule",{value:!0});v4$e.default=void 0;var _native=_interopRequireDefault$2(native$6),_rng=_interopRequireDefault$2(rng$e),_stringify=stringify$d;function _interopRequireDefault$2(e){return e&&e.__esModule?e:{default:e}}function v4$d(e,t,r){if(_native.default.randomUUID&&!t&&!e)return _native.default.randomUUID();e=e||{};const s=e.random||(e.rng||_rng.default)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=s[o];return t}return(0,_stringify.unsafeStringify)(s)}var _default$4=v4$d;v4$e.default=_default$4;var v5$d={},sha1$f={};Object.defineProperty(sha1$f,"__esModule",{value:!0});sha1$f.default=void 0;function f$b(e,t,r,s){switch(e){case 0:return t&r^~t&s;case 1:return t^r^s;case 2:return t&r^t&s^r&s;case 3:return t^r^s}}function ROTL$9(e,t){return e<<t|e>>>32-t}function sha1$e(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){const a=unescape(encodeURIComponent(e));e=[];for(let l=0;l<a.length;++l)e.push(a.charCodeAt(l))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const s=e.length/4+2,o=Math.ceil(s/16),n=new Array(o);for(let a=0;a<o;++a){const l=new Uint32Array(16);for(let p=0;p<16;++p)l[p]=e[a*64+p*4]<<24|e[a*64+p*4+1]<<16|e[a*64+p*4+2]<<8|e[a*64+p*4+3];n[a]=l}n[o-1][14]=(e.length-1)*8/Math.pow(2,32),n[o-1][14]=Math.floor(n[o-1][14]),n[o-1][15]=(e.length-1)*8&4294967295;for(let a=0;a<o;++a){const l=new Uint32Array(80);for(let b=0;b<16;++b)l[b]=n[a][b];for(let b=16;b<80;++b)l[b]=ROTL$9(l[b-3]^l[b-8]^l[b-14]^l[b-16],1);let p=r[0],u=r[1],c=r[2],v=r[3],w=r[4];for(let b=0;b<80;++b){const E=Math.floor(b/20),I=ROTL$9(p,5)+f$b(E,u,c,v)+w+t[E]+l[b]>>>0;w=v,v=c,c=ROTL$9(u,30)>>>0,u=p,p=I}r[0]=r[0]+p>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+c>>>0,r[3]=r[3]+v>>>0,r[4]=r[4]+w>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var _default$3=sha1$e;sha1$f.default=_default$3;Object.defineProperty(v5$d,"__esModule",{value:!0});v5$d.default=void 0;var _v=_interopRequireDefault$1(v35$d),_sha=_interopRequireDefault$1(sha1$f);function _interopRequireDefault$1(e){return e&&e.__esModule?e:{default:e}}const v5$c=(0,_v.default)("v5",80,_sha.default);var _default$2=v5$c;v5$d.default=_default$2;var nil$c={};Object.defineProperty(nil$c,"__esModule",{value:!0});nil$c.default=void 0;var _default$1="00000000-0000-0000-0000-000000000000";nil$c.default=_default$1;var version$e={};Object.defineProperty(version$e,"__esModule",{value:!0});version$e.default=void 0;var _validate=_interopRequireDefault(validate$d);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function version$d(e){if(!(0,_validate.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var _default=version$d;version$e.default=_default;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return p.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.default}});var t=c(v1$d),r=c(v3$d),s=c(v4$e),o=c(v5$d),n=c(nil$c),a=c(version$e),l=c(validate$d),p=c(stringify$d),u=c(parse$d);function c(v){return v&&v.__esModule?v:{default:v}}})(commonjsBrowser$3);var coin={};Object.defineProperty(coin,"__esModule",{value:!0});coin.getCoinSymbol=void 0;function getCoinSymbol(e){var t;return(t={0:"BTC",2:"LTC",3:"DOGE",4:"RDD",5:"DASH",6:"PPC",7:"NMC",8:"FTC",9:"XCP",10:"BLK",11:"NSR",12:"NBT",13:"MZC",14:"VIA",15:"XCH",16:"RBY",17:"GRS",18:"DGC",19:"CCN",20:"DGB",22:"MONA",23:"CLAM",24:"XPM",25:"NEOS",26:"JBS",27:"ZRC",28:"VTC",29:"NXT",30:"BURST",31:"MUE",32:"ZOOM",33:"VASH",34:"CDN",35:"SDC",36:"PKB",37:"PND",38:"START",39:"MOIN",40:"EXP",41:"EMC2",42:"DCR",43:"XEM",44:"PART",45:"ARG",48:"SHR",49:"GCR",50:"NVC",51:"AC",52:"BTCD",53:"DOPE",54:"TPC",55:"AIB",56:"EDRC",57:"SYS",58:"SLR",59:"SMLY",60:"ETH",61:"ETC",62:"PSB",63:"LDCN",65:"XBC",66:"IOP",67:"NXS",68:"INSN",69:"OK",70:"BRIT",71:"CMP",72:"CRW",73:"BELA",74:"ICX",75:"FJC",76:"MIX",77:"XVG",78:"EFL",79:"CLUB",80:"RICHX",81:"POT",82:"QRK",83:"TRC",84:"GRC",85:"AUR",86:"IXC",87:"NLG",88:"BITB",89:"BTA",90:"XMY",91:"BSD",92:"UNO",93:"MTR",94:"GB",95:"SHM",96:"CRX",97:"BIQ",98:"EVO",99:"STO",100:"BIGUP",101:"GAME",102:"DLC",103:"ZYD",104:"DBIC",105:"STRAT",106:"SH",107:"MARS",108:"UBQ",109:"PTC",110:"NRO",111:"ARK",112:"USC",113:"THC",114:"LINX",115:"ECN",116:"DNR",117:"PINK",118:"ATOM",119:"PIVX",120:"FLASH",121:"ZEN",122:"PUT",123:"ZNY",124:"UNIFY",125:"XST",126:"BRK",127:"VC",128:"XMR",129:"VOX",130:"NAV",131:"FCT",132:"EC",133:"ZEC",134:"LSK",135:"STEEM",136:"XZC",137:"RBTC",139:"RPT",140:"LBC",141:"KMD",142:"BSQ",143:"RIC",144:"XRP",145:"BCH",146:"NEBL",147:"ZCL",148:"XLM",149:"NLC2",150:"WHL",151:"ERC",152:"DMD",153:"BTM",154:"BIO",155:"XWCC",156:"BTG",157:"BTC2X",158:"SSN",159:"TOA",160:"BTX",161:"ACC",162:"BCO",163:"ELLA",164:"PIRL",165:"XNO",166:"VIVO",167:"FRST",168:"HNC",169:"BUZZ",170:"MBRS",171:"HC",172:"HTML",173:"ODN",174:"ONX",175:"RVN",176:"GBX",177:"BTCZ",178:"POA",179:"NYC",180:"MXT",181:"WC",182:"MNX",183:"BTCP",184:"MUSIC",185:"BCA",186:"CRAVE",187:"STAK",188:"WBTC",189:"LCH",190:"EXCL",192:"LCC",193:"XFE",194:"EOS",195:"TRX",196:"KOBO",197:"HUSH",198:"BAN",199:"ETF",200:"OMNI",201:"BIFI",202:"UFO",203:"CNMC",204:"BCN",205:"RIN",206:"ATP",207:"EVT",208:"ATN",209:"BIS",210:"NEET",211:"BOPO",212:"OOT",213:"ALIAS",214:"MONK",215:"BOXY",216:"FLO",217:"MEC",218:"BTDX",219:"XAX",220:"ANON",221:"LTZ",222:"BITG",223:"ICP",224:"SMART",225:"XUEZ",226:"HLM",227:"WEB",228:"ACM",229:"NOS",230:"BITC",231:"HTH",232:"TZC",233:"VAR",234:"IOV",235:"FIO",236:"BSV",237:"DXN",238:"QRL",239:"PCX",240:"LOKI",242:"NIM",243:"SOV",244:"JCT",245:"SLP",246:"EWT",247:"UC",248:"EXOS",249:"ECA",250:"SOOM",251:"XRD",252:"FREE",253:"NPW",254:"BST",256:"NANO",257:"BTCC",259:"ZEST",260:"ABT",261:"PION",262:"DT3",263:"ZBUX",264:"KPL",265:"TPAY",266:"ZILLA",267:"ANK",268:"BCC",269:"HPB",270:"ONE",271:"SBC",272:"IPC",273:"DMTC",274:"OGC",275:"SHIT",276:"ANDES",277:"AREPA",278:"BOLI",279:"RIL",280:"HTR",281:"FCTID",282:"BRAVO",283:"ALGO",284:"BZX",285:"GXX",286:"HEAT",287:"XDN",288:"FSN",289:"CPC",290:"BOLD",291:"IOST",292:"TKEY",293:"USE",294:"BCZ",295:"IOC",296:"ASF",297:"MASS",298:"FAIR",299:"NUKO",300:"GNX",301:"DIVI",302:"CMT",303:"EUNO",304:"IOTX",305:"ONION",306:"8BIT",307:"ATC",308:"BTS",309:"CKB",310:"UGAS",311:"ADS",312:"ARA",313:"ZIL",314:"MOAC",315:"SWTC",316:"VNSC",317:"PLUG",318:"MAN",319:"ECC",320:"RPD",321:"RAP",322:"GARD",323:"ZER",324:"EBST",325:"SHARD",326:"MRX",327:"CMM",328:"BLOCK",329:"AUDAX",330:"LUNA",331:"ZPM",332:"KUVA",333:"MEM",334:"CS",335:"SWIFT",336:"FIX",337:"CPC",338:"VGO",339:"DVT",340:"N8V",341:"MTNS",342:"BLAST",343:"DCT",344:"AUX",345:"USDP",346:"HTDF",347:"YEC",348:"QLC",349:"TEA",350:"ARW",351:"MDM",352:"CYB",353:"LTO",354:"DOT",355:"AEON",356:"RES",357:"AYA",358:"DAPS",359:"CSC",360:"VSYS",361:"NOLLAR",362:"XNOS",363:"CPU",364:"LAMB",365:"VCT",366:"CZR",367:"ABBC",368:"HET",369:"XAS",370:"VDL",371:"MED",372:"ZVC",373:"VESTX",374:"DBT",375:"SEOS",376:"MXW",377:"ZNZ",378:"XCX",379:"SOX",380:"NYZO",381:"ULC",382:"RYO",383:"KAL",384:"XSN",385:"DOGEC",386:"BMV",387:"QBC",388:"IMG",389:"QOS",390:"PKT",391:"LHD",392:"CENNZ",393:"HSN",394:"CRO",395:"UMBRU",396:"EVER",397:"NEAR",398:"XPC",399:"ZOC",400:"NIX",401:"UC",402:"GALI",403:"OLT",404:"XBI",405:"DONU",406:"EARTHS",407:"HDD",408:"SUGAR",409:"AILE",410:"TENT",411:"TAN",412:"AIN",413:"MSR",414:"SUMO",415:"ETN",416:"BYTZ",417:"WOW",418:"XTNC",419:"LTHN",420:"NODE",421:"AGM",422:"CCX",423:"TNET",424:"TELOS",425:"AION",426:"BC",427:"KTV",428:"ZCR",429:"ERG",430:"PESO",431:"BTC2",432:"XRPHD",433:"WE",434:"KSM",435:"PCN",436:"NCH",437:"ICU",438:"LN",439:"DTP",440:"BTCR",441:"AERGO",442:"XTH",443:"LV",444:"PHR",445:"VITAE",446:"COCOS",447:"DIN",448:"SPL",449:"YCE",450:"XLR",451:"KTS",452:"DGLD",453:"XNS",454:"EM",455:"SHN",456:"SEELE",457:"AE",458:"ODX",459:"KAVA",460:"GLEEC",461:"FIL",462:"RUTA",463:"CSDT",464:"ETI",465:"ZSLP",466:"ERE",467:"DX",468:"CPS",469:"BTH",470:"MESG",471:"FIMK",472:"AR",473:"OGO",474:"ROSE",475:"BARE",476:"GLEEC",477:"CLR",478:"RNG",479:"OLO",480:"PEXA",481:"MOON",482:"OCEAN",483:"BNT",484:"AMO",485:"FCH",486:"LAT",487:"COIN",488:"VEO",489:"CCA",490:"GFN",491:"BIP",492:"KPG",493:"FIN",494:"BAND",495:"DROP",496:"BHT",497:"LYRA",498:"CS",499:"RUPX",500:"THETA",501:"SOL",502:"THT",503:"CFX",504:"KUMA",505:"HASH",506:"CSPR",507:"EARTH",508:"EGLD",509:"CHI",510:"KOTO",511:"OTC",512:"XRD",513:"SEELEN",514:"AETH",515:"DNA",516:"VEE",517:"SIERRA",518:"LET",519:"BSC",520:"BTCV",521:"ABA",522:"SCC",523:"EDG",524:"AMS",525:"GOSS",526:"BU",527:"GRAM",528:"YAP",529:"SCRT",530:"NOVO",531:"GHOST",532:"HST",533:"PRJ",534:"YOU",535:"XHV",536:"BYND",537:"JOYS",538:"VAL",539:"FLOW",540:"SMESH",541:"SCDO",542:"IQS",543:"BIND",544:"COINEVO",545:"SCRIBE",546:"HYN",547:"BHP",548:"BBC",549:"MKF",550:"XDC",551:"STR",552:"SUM",553:"HBC",555:"BCS",556:"KTS",557:"LKR",558:"TAO",559:"XWC",560:"DEAL",561:"NTY",562:"TOP",564:"AG",565:"CICO",566:"IRIS",567:"NCG",568:"LRG",569:"SERO",570:"BDX",571:"CCXX",572:"SLS",573:"SRM",575:"VIVT",576:"BPS",577:"NKN",578:"ICL",579:"BONO",580:"PLC",581:"DUN",582:"DMCH",583:"CTC",584:"KELP",585:"GBCR",586:"XDAG",587:"PRV",588:"SCAP",589:"TFUEL",590:"GTM",591:"RNL",592:"GRIN",593:"MWC",594:"DOCK",595:"POLYX",596:"DIVER",597:"XEP",598:"APN",599:"TFC",600:"UTE",601:"MTC",602:"NC",603:"XINY",604:"DYN",605:"BUFS",606:"STOS",607:"TON",608:"TAFT",609:"HYDRA",610:"NOR",613:"WCN",614:"OPT",615:"PSWAP",616:"VAL",617:"XOR",618:"SSP",619:"DEI",621:"ZERO",622:"ALPHA",623:"BDECO",624:"NOBL",625:"EAST",626:"KDA",627:"SOUL",628:"LORE",629:"FNR",630:"NEXUS",631:"QTZ",632:"XMA",633:"CALL",634:"VAL",635:"POKT",636:"EMIT",637:"APTOS",638:"ADON",639:"BTSG",640:"LFC",641:"KCS",642:"KCC",643:"AZERO",644:"TREE",645:"LX",646:"XLN",647:"CIC",648:"ZRB",650:"UCO",651:"SFX",652:"SFT",653:"WSFX",654:"USDG",655:"WMP",659:"KOIN",660:"PIRATE",663:"SFRX",666:"ACT",667:"PRKL",668:"SSC",669:"GC",670:"PLGR",671:"MPLGR",672:"KNOX",673:"ZED",674:"CNDL",675:"WLKR",676:"WLKRR",677:"YUNGE",678:"Voken",679:"APL",680:"Evrynet",681:"NENG",682:"CHTA",685:"OAS",686:"KAR",688:"CET",690:"KLV",694:"VTBC",698:"VEIL",699:"GTB",700:"XDAI",701:"COM",702:"CCC",707:"MCOIN",711:"CHC",712:"SERF",713:"XTL",714:"BNB",715:"SIN",716:"DLN",717:"BONTE",718:"PEER",725:"MCX",730:"HEALIOS",731:"BMK",734:"DENTX",737:"ATOP",747:"CFG",750:"XPRT",757:"HONEY",768:"BALLZ",770:"COSA",771:"BR",775:"PLSR",776:"KEY",777:"BTW",780:"PLCUC",781:"PLCUX",782:"PLCU",784:"SUI",786:"UIDD",787:"ACA",788:"BNC",789:"TAU",799:"PDEX",800:"BEET",801:"DST",804:"ZKS",808:"QVT",809:"SDN",810:"ASTR",813:"MEER",818:"VET",819:"REEF",820:"CLO",822:"BDB",827:"ACE",828:"CCN",831:"CRUZ",832:"SAPP",833:"777",834:"KYAN",835:"AZR",836:"CFL",837:"DASHD",838:"TRTT",839:"UCR",840:"PNY",841:"BECN",842:"MONK",843:"SAGA",844:"SUV",845:"ESK",846:"OWO",847:"PEPS",848:"BIR",849:"MOBIC",850:"FLS",852:"DSM",853:"PRCY",858:"HVH",866:"MOB",868:"IF",877:"NAM",880:"LUM",883:"ZBC",886:"ADF",888:"NEO",889:"TOMO",890:"XSEL",896:"LKSC",898:"AS",899:"XEC",900:"LMO",901:"NXT",904:"HNT",907:"FIS",909:"SGE",911:"GERT",916:"META",917:"FRA",919:"CCD",921:"AVN",925:"DIP",928:"GHM",931:"RUNE",945:"UNLOCK",955:"LTP",960:"VKAX",966:"MATIC",968:"UNW",970:"TWINS",977:"TLOS",981:"TAFECO",985:"AU",987:"VCG",988:"XAZAB",989:"AIOZ",990:"CORE",991:"PEC",992:"UNT",993:"XRB",994:"QUAI",995:"CAPS",996:"OKT",997:"SUM",998:"LBTC",999:"BCD",1e3:"BTN",1001:"TT",1002:"BKT",1003:"NODL",1004:"PCOIN",1005:"TAO",1006:"HSK",1007:"FTM",1008:"RPG",1010:"HT",1011:"ELV",1013:"BIC",1020:"EVC",1022:"XRD",1023:"ONE",1024:"ONT",1025:"CZZ",1026:"KEX",1027:"MCM",1032:"BTCR",1042:"MFID",1111:"BBC",1120:"RISE",1122:"CMT",1128:"ETSC",1129:"DFI",1130:"DFI",1137:"$DAG",1145:"CDY",1155:"EFI",1170:"HOO",1234:"ALPH",1284:"GLMR",1285:"MOVR",1298:"WPC",1308:"WEI",1337:"DFC",1397:"HYC",1410:"TENTSLP",1510:"XSC",1512:"AAC",1533:"BEAM",1555:"APC",1616:"ELF",1618:"AUDL",1620:"ATH",1627:"LUME",1642:"NEW",1657:"BTA",1668:"NEOX",1669:"MEWC",1688:"BCX",1729:"XTZ",1776:"LBTC",1777:"BBP",1784:"JPYS",1789:"VEGA",1815:"ADA",1818:"CUBE",1856:"TES",1888:"ZTX",1899:"XEC",1901:"CLC",1919:"VIPS",1926:"CITY",1955:"XX",1977:"XMX",1984:"TRTL",1985:"SLRT",1986:"QTH",1987:"EGEM",1988:"MIRA",1989:"HODL",1990:"PHL",1991:"SC",1996:"MYT",1997:"POLIS",1998:"XMCC",1999:"COLX",2e3:"GIN",2001:"MNP",2002:"MLN",2017:"KIN",2018:"EOSC",2019:"GBT",2020:"PKC",2021:"SKT",2022:"XHT",2048:"MCASH",2049:"TRUE",2086:"KILT",2109:"SAMA",2112:"IoTE",2137:"XRG",2182:"CHZ",2221:"ASK",2301:"QTUM",2302:"ETP",2303:"GXC",2304:"CRP",2305:"ELA",2338:"SNOW",2365:"XIN",2570:"AOA",2718:"NAS",2894:"REOSC",2941:"BND",3003:"LUX",3030:"HBAR",3077:"COS",3276:"CCC",3333:"SXP",3377:"ROI",3381:"DYN",3383:"SEQ",3552:"DEO",3564:"DST",3601:"CY",4040:"FC8",4096:"YEE",4218:"IOTA",4219:"SMR",4242:"AXE",4343:"XYM",4444:"C4E",4919:"XVM",5006:"SBC",5248:"FIC",5353:"HNS",5404:"ISK",5467:"ALTME",5555:"FUND",5757:"STX",5895:"VOW",5920:"SLU",6060:"GO",6174:"MOI",6599:"RSC",6666:"BPA",6688:"SAFE",6779:"COTI",6969:"ROGER",7091:"TOPL",7331:"KLY",7341:"SHFT",7777:"BTV",8e3:"SKY",8192:"PAC",8217:"KLAY",8339:"BTQ",8444:"XCH",8680:"PLMNT",8888:"SBTC",8964:"NULS",8997:"BBC",8998:"JGC",8999:"BTP",9e3:"AVAX",9001:"ARB1",9002:"BOBA",9003:"LOOP",9004:"STRK",9005:"AVAXC",9006:"BSC",9797:"NRG",9888:"BTF",9999:"GOD",1e4:"FO",10226:"RTM",10291:"XRC",10605:"XPI",11111:"ESS",12345:"IPOS",12586:"MINA",13107:"BTY",13108:"YCC",14001:"WAX",15845:"SDGO",16181:"XTX",16754:"ARDR",18e3:"MTR",19165:"SAFE",19167:"FLUX",19169:"RITO",20036:"XND",21004:"C4EI",21888:"PCT",22504:"PWR",25252:"BELL",25718:"CHX",29223:"NEXA",31102:"ESN",33416:"TEO",33878:"BTCS",34952:"BTT",37992:"FXTC",39321:"AMA",42069:"FACT",43028:"AXIV",49262:"EVE",49344:"STASH",52752:"CELO",61616:"TH",65536:"KETH",69420:"GRLC",70007:"GWL",77777:"ZYN",88888:"RYO",99999:"WICC",100500:"HOME",101010:"STC",105105:"STRAX",111111:"KAS",161803:"APTA",200625:"AKA",200665:"GENOM",246529:"ATS",261131:"ZAMA",314159:"PI",333332:"VALUE",333333:"3333",424242:"X42",534352:"SCR",666666:"VITE",888888:"SEA",1048576:"AMAX",1171337:"ILT",1313114:"ETHO",1313500:"XERO",1712144:"LAX",3924011:"EPK",4741444:"HYD",5249353:"BCO",5249354:"BHD",5264462:"PTN",5655640:"VLX",5718350:"WAN",5741564:"WAVES",5741565:"WEST",6382179:"ABC",6517357:"CRM",7562605:"SEM",7567736:"ION",7777777:"FCT",7825266:"WGR",7825267:"OBSR",8163271:"AFS",15118976:"XDS",61717561:"AQUA",88888888:"HATCH",91927009:"kUSD",99999996:"GENS",99999997:"EQ",99999998:"FLUID",99999999:"QKC",608589380:"FVDC"}[e])!==null&&t!==void 0?t:""}coin.getCoinSymbol=getCoinSymbol;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(v,w,b,E){E===void 0&&(E=b);var I=Object.getOwnPropertyDescriptor(w,b);(!I||("get"in I?!w.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return w[b]}}),Object.defineProperty(v,E,I)}:function(v,w,b,E){E===void 0&&(E=b),v[E]=w[b]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(v,w){Object.defineProperty(v,"default",{enumerable:!0,value:w})}:function(v,w){v.default=w}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(v){if(v&&v.__esModule)return v;var w={};if(v!=null)for(var b in v)b!=="default"&&Object.prototype.hasOwnProperty.call(v,b)&&t(w,v,b);return r(w,v),w},o=commonjsGlobal&&commonjsGlobal.__exportStar||function(v,w){for(var b in v)b!=="default"&&!Object.prototype.hasOwnProperty.call(w,b)&&t(w,v,b)};Object.defineProperty(e,"__esModule",{value:!0}),e.parsePath=e.uuidStringify=e.uuidParse=e.toBuffer=e.toHex=e.uuid=void 0;const n=s(commonjsBrowser$3);e.uuid=n,o(coin,e);function a(v){return v===void 0?"":Buffer$e.from(v).toString("hex")}e.toHex=a;function l(v){return Buffer$e.from(v??"","hex")}e.toBuffer=l;function p(v){return Buffer$e.from(n.parse(v))}e.uuidParse=p;function u(v){return n.stringify(v)}e.uuidStringify=u;function c(v){return v.replace(/^m\//i,"").split("/").map(b=>{const E=b.endsWith("'");return{index:Number(E?b.substring(0,b.length-1):b),hardened:E}})}e.parsePath=c})(stringHelper);var crypto$5={},dist$u={},extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},extendStatics(e,t)};function __extends(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");extendStatics(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=function(){return __assign=Object.assign||function(t){for(var r,s=1,o=arguments.length;s<o;s++){r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},__assign.apply(this,arguments)};function __rest(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function __decorate(e,t,r,s){var o=arguments.length,n=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function __param(e,t){return function(r,s){t(r,s,e)}}function __esDecorate(e,t,r,s,o,n){function a(B){if(B!==void 0&&typeof B!="function")throw new TypeError("Function expected");return B}for(var l=s.kind,p=l==="getter"?"get":l==="setter"?"set":"value",u=!t&&e?s.static?e:e.prototype:null,c=t||(u?Object.getOwnPropertyDescriptor(u,s.name):{}),v,w=!1,b=r.length-1;b>=0;b--){var E={};for(var I in s)E[I]=I==="access"?{}:s[I];for(var I in s.access)E.access[I]=s.access[I];E.addInitializer=function(B){if(w)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(B||null))};var x=(0,r[b])(l==="accessor"?{get:c.get,set:c.set}:c[p],E);if(l==="accessor"){if(x===void 0)continue;if(x===null||typeof x!="object")throw new TypeError("Object expected");(v=a(x.get))&&(c.get=v),(v=a(x.set))&&(c.set=v),(v=a(x.init))&&o.unshift(v)}else(v=a(x))&&(l==="field"?o.unshift(v):c[p]=v)}u&&Object.defineProperty(u,s.name,c),w=!0}function __runInitializers(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function __propKey(e){return typeof e=="symbol"?e:"".concat(e)}function __setFunctionName(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function __metadata(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function __awaiter$1(e,t,r,s){function o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,a){function l(c){try{u(s.next(c))}catch(v){a(v)}}function p(c){try{u(s.throw(c))}catch(v){a(v)}}function u(c){c.done?n(c.value):o(c.value).then(l,p)}u((s=s.apply(e,t||[])).next())})}function __generator(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,o,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(u){return function(c){return p([u,c])}}function p(u){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(r=0)),r;)try{if(s=1,o&&(n=u[0]&2?o.return:u[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,u[1])).done)return n;switch(o=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,o=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){r.label=u[1];break}if(u[0]===6&&r.label<n[1]){r.label=n[1],n=u;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(u);break}n[2]&&r.ops.pop(),r.trys.pop();continue}u=t.call(e,r)}catch(c){u=[6,c],o=0}finally{s=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var __createBinding$3=Object.create?function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]};function __exportStar(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&__createBinding$3(t,e,r)}function __values$1(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),o,n=[],a;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(l){a={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return n}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}function __spreadArrays(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var n=arguments[t],a=0,l=n.length;a<l;a++,o++)s[o]=n[a];return s}function __spreadArray(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,n;s<o;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}function __await(e){return this instanceof __await?(this.v=e,this):new __await(e)}function __asyncGenerator(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),o,n=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(b){return function(E){return Promise.resolve(E).then(b,v)}}function l(b,E){s[b]&&(o[b]=function(I){return new Promise(function(x,B){n.push([b,I,x,B])>1||p(b,I)})},E&&(o[b]=E(o[b])))}function p(b,E){try{u(s[b](E))}catch(I){w(n[0][3],I)}}function u(b){b.value instanceof __await?Promise.resolve(b.value.v).then(c,v):w(n[0][2],b)}function c(b){p("next",b)}function v(b){p("throw",b)}function w(b,E){b(E),n.shift(),n.length&&p(n[0][0],n[0][1])}}function __asyncDelegator(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,n){t[o]=e[o]?function(a){return(r=!r)?{value:__await(e[o](a)),done:!1}:n?n(a):a}:n}}function __asyncValues(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values$1=="function"?__values$1(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=e[n]&&function(a){return new Promise(function(l,p){a=e[n](a),o(l,p,a.done,a.value)})}}function o(n,a,l,p){Promise.resolve(p).then(function(u){n({value:u,done:l})},a)}}function __makeTemplateObject(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var __setModuleDefault$3=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},ownKeys=function(e){return ownKeys=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ownKeys(e)};function __importStar$3(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),s=0;s<r.length;s++)r[s]!=="default"&&__createBinding$3(t,e,r[s]);return __setModuleDefault$3(t,e),t}function __importDefault$9(e){return e&&e.__esModule?e:{default:e}}function __classPrivateFieldGet(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function __classPrivateFieldSet(e,t,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r}function __classPrivateFieldIn(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function __addDisposableResource(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}var _SuppressedError=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function __disposeResources(e){function t(n){e.error=e.hasError?new _SuppressedError(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(o,function(a){return t(a),o()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function __rewriteRelativeImportExtension(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,n,a){return s?t?".jsx":".js":o&&(!n||!a)?r:o+n+"."+a.toLowerCase()+"js"}):e}const tslib_es6={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter:__awaiter$1,__generator,__createBinding:__createBinding$3,__exportStar,__values:__values$1,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar:__importStar$3,__importDefault:__importDefault$9,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension},tslib_es6$1=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource,get __assign(){return __assign},__asyncDelegator,__asyncGenerator,__asyncValues,__await,__awaiter:__awaiter$1,__classPrivateFieldGet,__classPrivateFieldIn,__classPrivateFieldSet,__createBinding:__createBinding$3,__decorate,__disposeResources,__esDecorate,__exportStar,__extends,__generator,__importDefault:__importDefault$9,__importStar:__importStar$3,__makeTemplateObject,__metadata,__param,__propKey,__read,__rest,__rewriteRelativeImportExtension,__runInitializers,__setFunctionName,__spread,__spreadArray,__spreadArrays,__values:__values$1,default:tslib_es6},Symbol.toStringTag,{value:"Module"})),require$$0$4=getAugmentedNamespace(tslib_es6$1);var patchCBOR$c={},utils$n={},lib$d={},cborSync$c={exports:{}},DataItem$d={};Object.defineProperty(DataItem$d,"__esModule",{value:!0});DataItem$d.DataItem=void 0;let DataItem$c=class{constructor(t,r){this.setTag=s=>{this.tag=s},this.clearTag=()=>{this.tag=void 0},this.getTag=()=>this.tag,this.getData=()=>this.data,this.data=t,this.tag=r}};DataItem$d.DataItem=DataItem$c;(function(e){(function(t,r){e.exports?e.exports=r():t.CBOR=r()})(commonjsGlobal,function(){const{DataItem:t}=DataItem$d;var r=function(){function s(y){this.$hex=y}s.prototype={length:function(){return this.$hex.length/2},toString:function(y){if(!y||y==="hex"||y===16)return this.$hex;if(y==="utf-8"){for(var T="",D=0;D<this.$hex.length;D+=2)T+="%"+this.$hex.substring(D,D+2);return decodeURIComponent(T)}if(y==="latin"){for(var T=[],D=0;D<this.$hex.length;D+=2)T.push(parseInt(this.$hex.substring(D,D+2),16));return String.fromCharCode.apply(String,T)}throw new Error("Unrecognised format: "+y)}},s.fromLatinString=function(y){for(var T="",D=0;D<y.length;D++){var L=y.charCodeAt(D).toString(16);L.length===1&&(L="0"+L),T+=L}return new s(T)},s.fromUtf8String=function(y){for(var T=encodeURIComponent(y),D="",L=0;L<T.length;L++)if(T.charAt(L)==="%")D+=T.substring(L+1,L+3),L+=2;else{var C=T.charCodeAt(L).toString(16);C.length<2&&(C="0"+C),D+=C}return new s(D)};var o=[],n={},a=function(y){return function(){throw new Error(y+" not implemented")}};function l(){}l.prototype={peekByte:a("peekByte"),readByte:a("readByte"),readChunk:a("readChunk"),readFloat16:function(){var y=this.readUint16(),T=(y&32767)>>10,D=y&1023,L=y&32768;if(T===31)return D===0?L?-1/0:1/0:NaN;var C=T?Math.pow(2,T-25)*(1024+D):Math.pow(2,-24)*D;return L?-C:C},readFloat32:function(){var y=this.readUint32(),T=(y&2147483647)>>23,D=y&8388607,L=y&2147483648;if(T===255)return D===0?L?-1/0:1/0:NaN;var C=T?Math.pow(2,T-23-127)*(8388608+D):Math.pow(2,-149)*D;return L?-C:C},readFloat64:function(){var y=this.readUint32(),T=this.readUint32(),D=y>>20&2047,L=(y&1048575)*4294967296+T,C=y&2147483648;if(D===2047)return L===0?C?-1/0:1/0:NaN;var d=D?Math.pow(2,D-52-1023)*(4503599627370496+L):Math.pow(2,-1074)*L;return C?-d:d},readUint16:function(){return this.readByte()*256+this.readByte()},readUint32:function(){return this.readUint16()*65536+this.readUint16()},readUint64:function(){return this.readUint32()*4294967296+this.readUint32()}};function p(){}p.prototype={writeByte:a("writeByte"),result:a("result"),writeFloat16:a("writeFloat16"),writeFloat32:a("writeFloat32"),writeFloat64:a("writeFloat64"),writeUint16:function(y){this.writeByte(y>>8&255),this.writeByte(y&255)},writeUint32:function(y){this.writeUint16(y>>16&65535),this.writeUint16(y&65535)},writeUint64:function(y){if(y>=9007199254740992||y<=-9007199254740992)throw new Error("Cannot encode Uint64 of: "+y+" magnitude to big (floating point errors)");this.writeUint32(Math.floor(y/4294967296)),this.writeUint32(y%4294967296)},writeString:a("writeString"),canWriteBinary:function(y){return!1},writeBinary:a("writeChunk")};function u(y){var T=y.readByte(),D=T>>5,L=T&31;return{type:D,value:L}}function c(y,T){var D=y.value;if(D<24)return D;if(D==24)return T.readByte();if(D==25)return T.readUint16();if(D==26)return T.readUint32();if(D==27)return T.readUint64();if(D==31)return null;a("Additional info: "+D)()}function v(y,T,D){D.writeByte(y<<5|T)}function w(y,T,D){var L=y<<5;T<24?D.writeByte(L|T):T<256?(D.writeByte(L|24),D.writeByte(T)):T<65536?(D.writeByte(L|25),D.writeUint16(T)):T<4294967296?(D.writeByte(L|26),D.writeUint32(T)):(D.writeByte(L|27),D.writeUint64(T))}var b=new Error;function E(y){var T=u(y);switch(T.type){case 0:return c(T,y);case 1:return-1-c(T,y);case 2:return y.readChunk(c(T,y));case 3:var D=y.readChunk(c(T,y));return D.toString("utf-8");case 4:case 5:var L=c(T,y),O=[];if(L!==null){T.type===5&&(L*=2);for(var C=0;C<L;C++)O[C]=E(y)}else for(var d;(d=E(y))!==b;)O.push(d);if(T.type===5){for(var _={},C=0;C<O.length;C+=2)_[O[C]]=O[C+1];return _}else return O;case 6:var $=c(T,y),S=n[$],O=E(y);return S?S(O):O;case 7:if(T.value===25)return y.readFloat16();if(T.value===26)return y.readFloat32();if(T.value===27)return y.readFloat64();switch(c(T,y)){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case null:return b;default:throw new Error("Unknown fixed value: "+T.value)}default:throw new Error("Unsupported header: "+JSON.stringify(T))}throw new Error("not implemented yet")}function I(y,T){for(var D=0;D<o.length;D++){var L=o[D].fn(y);if(L!==void 0)return w(6,o[D].tag,T),I(L,T)}if(y&&typeof y.toCBOR=="function"&&(y=y.toCBOR()),y===!1)w(7,20,T);else if(y===!0)w(7,21,T);else if(y===null)w(7,22,T);else if(y===void 0)w(7,23,T);else if(typeof y=="number")Math.floor(y)===y&&y<9007199254740992&&y>-9007199254740992?y<0?w(1,-1-y,T):w(0,y,T):(v(7,27,T),T.writeFloat64(y));else if(typeof y=="string")T.writeString(y,function(d){w(3,d,T)});else if(T.canWriteBinary(y))T.writeBinary(y,function(d){w(2,d,T)});else if(typeof y=="object")if(M.config.useToJSON&&typeof y.toJSON=="function"&&(y=y.toJSON()),Array.isArray(y)){w(4,y.length,T);for(var D=0;D<y.length;D++)I(y[D],T)}else{var C=Object.keys(y);w(5,C.length,T);for(var D=0;D<C.length;D++){const _=parseInt(C[D]);isNaN(_)?(I(C[D],T),I(y[C[D]],T)):(I(_,T),I(y[C[D]],T))}}else throw new Error("CBOR encoding not supported: "+y)}var x=[],B=[],M={config:{useToJSON:!0},addWriter:function(y,T){typeof y=="string"?B.push(function(D){if(y===D)return T(D)}):B.push(y)},addReader:function(y,T){typeof y=="string"?x.push(function(D,L){if(y===L)return T(D,L)}):x.push(y)},encode:function(y,T){for(var D=0;D<B.length;D++){var L=B[D],C=L(T);if(C)return I(y,C),C.result()}throw new Error("Unsupported output format: "+T)},encodeDataItem:function(y,T){for(var D=0;D<B.length;D++){var L=B[D],C=L(T);if(C)return y.getTag()!==void 0?(I(y,C),C.result()):(I(y.getData(),C),C.result())}throw new Error("Unsupported output format: "+T)},decode:function(y,T){for(var D=0;D<x.length;D++){var L=x[D],C=L(y,T);if(C)return E(C)}throw new Error("Unsupported input format: "+T)},decodeToDataItem:function(y,T){for(var D=0;D<x.length;D++){var L=x[D],C=L(y,T);if(C){const d=E(C);return d instanceof t?d:new t(d)}}throw new Error("Unsupported input format: "+T)},addSemanticEncode:function(y,T){if(typeof y!="number"||y%1!==0||y<0)throw new Error("Tag must be a positive integer");return o.push({tag:y,fn:T}),this},addSemanticDecode:function(y,T){if(typeof y!="number"||y%1!==0||y<0)throw new Error("Tag must be a positive integer");return n[y]=T,this}};function q(y){this.buffer=y,this.pos=0}q.prototype=Object.create(l.prototype),q.prototype.peekByte=function(){return this.buffer[this.pos]},q.prototype.readByte=function(){return this.buffer[this.pos++]},q.prototype.readUint16=function(){var y=this.buffer.readUInt16BE(this.pos);return this.pos+=2,y},q.prototype.readUint32=function(){var y=this.buffer.readUInt32BE(this.pos);return this.pos+=4,y},q.prototype.readFloat32=function(){var y=this.buffer.readFloatBE(this.pos);return this.pos+=4,y},q.prototype.readFloat64=function(){var y=this.buffer.readDoubleBE(this.pos);return this.pos+=8,y},q.prototype.readChunk=function(y){var T=Buffer$e.alloc(y);return this.buffer.copy(T,0,this.pos,this.pos+=y),T};function U(y){this.byteLength=0,this.defaultBufferLength=16384,this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0,this.completeBuffers=[],this.stringFormat=y}U.prototype=Object.create(p.prototype),U.prototype.writeByte=function(y){this.latestBuffer[this.latestBufferOffset++]=y,this.latestBufferOffset>=this.latestBuffer.length&&(this.completeBuffers.push(this.latestBuffer),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0),this.byteLength++},U.prototype.writeFloat32=function(y){var T=Buffer$e.alloc(4);T.writeFloatBE(y,0),this.writeBuffer(T)},U.prototype.writeFloat64=function(y){var T=Buffer$e.alloc(8);T.writeDoubleBE(y,0),this.writeBuffer(T)},U.prototype.writeString=function(y,T){var D=Buffer$e.from(y,"utf-8");T(D.length),this.writeBuffer(D)},U.prototype.canWriteBinary=function(y){return y instanceof Buffer$e},U.prototype.writeBinary=function(y,T){T(y.length),this.writeBuffer(y)},U.prototype.writeBuffer=function(y){if(!(y instanceof Buffer$e))throw new TypeError("BufferWriter only accepts Buffers");this.latestBufferOffset?this.latestBuffer.length-this.latestBufferOffset>=y.length?(y.copy(this.latestBuffer,this.latestBufferOffset),this.latestBufferOffset+=y.length,this.latestBufferOffset>=this.latestBuffer.length&&(this.completeBuffers.push(this.latestBuffer),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0)):(this.completeBuffers.push(this.latestBuffer.slice(0,this.latestBufferOffset)),this.completeBuffers.push(y),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0):this.completeBuffers.push(y),this.byteLength+=y.length},U.prototype.result=function(){for(var y=Buffer$e.alloc(this.byteLength),T=0,D=0;D<this.completeBuffers.length;D++){var L=this.completeBuffers[D];L.copy(y,T,0,L.length),T+=L.length}return this.latestBufferOffset&&this.latestBuffer.copy(y,T,0,this.latestBufferOffset),this.stringFormat?y.toString(this.stringFormat):y},typeof Buffer$e=="function"&&(M.addReader(function(y,T){if(Buffer$e.isBuffer(y))return new q(y);if(T==="hex"||T==="base64"){var D=Buffer$e.from(y,T);return new q(D)}}),M.addWriter(function(y){if(!y||y==="buffer")return new U;if(y==="hex"||y==="base64")return new U(y)}));function F(y){this.hex=y,this.pos=0}F.prototype=Object.create(l.prototype),F.prototype.peekByte=function(){var y=this.hex.substring(this.pos,2);return parseInt(y,16)},F.prototype.readByte=function(){var y=this.hex.substring(this.pos,this.pos+2);return this.pos+=2,parseInt(y,16)},F.prototype.readChunk=function(y){var T=this.hex.substring(this.pos,this.pos+y*2);return this.pos+=y*2,typeof Buffer$e=="function"?Buffer$e.from(T,"hex"):new s(T)};function j(y){this.$hex="",this.finalFormat=y||"hex"}return j.prototype=Object.create(p.prototype),j.prototype.writeByte=function(y){if(y<0||y>255)throw new Error("Byte value out of range: "+y);var T=y.toString(16);T.length==1&&(T="0"+T),this.$hex+=T},j.prototype.canWriteBinary=function(y){return y instanceof s||typeof Buffer$e=="function"&&y instanceof Buffer$e},j.prototype.writeBinary=function(y,T){if(y instanceof s)T(y.length()),this.$hex+=y.$hex;else if(typeof Buffer$e=="function"&&y instanceof Buffer$e)T(y.length),this.$hex+=y.toString("hex");else throw new TypeError("HexWriter only accepts BinaryHex or Buffers")},j.prototype.result=function(){return this.finalFormat==="buffer"&&typeof Buffer$e=="function"?Buffer$e.from(this.$hex,"hex"):new s(this.$hex).toString(this.finalFormat)},j.prototype.writeString=function(y,T){var D=s.fromUtf8String(y);T(D.length()),this.$hex+=D.$hex},M.addReader(function(y,T){if(y instanceof s||y.$hex)return new F(y.$hex);if(T==="hex")return new F(y)}),M.addWriter(function(y){if(y==="hex")return new j}),M}();return r.addSemanticEncode(0,function(s){if(s instanceof Date)return s.toISOString()}).addSemanticDecode(0,function(s){return new Date(s)}).addSemanticDecode(1,function(s){return new Date(s)}),r})})(cborSync$c);var cborSyncExports=cborSync$c.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DataItem=e.addWriter=e.addReader=e.addSemanticEncode=e.addSemanticDecode=e.decodeToDataItem=e.encodeDataItem=void 0;var t=cborSyncExports;Object.defineProperty(e,"encodeDataItem",{enumerable:!0,get:function(){return t.encodeDataItem}}),Object.defineProperty(e,"decodeToDataItem",{enumerable:!0,get:function(){return t.decodeToDataItem}}),Object.defineProperty(e,"addSemanticDecode",{enumerable:!0,get:function(){return t.addSemanticDecode}}),Object.defineProperty(e,"addSemanticEncode",{enumerable:!0,get:function(){return t.addSemanticEncode}}),Object.defineProperty(e,"addReader",{enumerable:!0,get:function(){return t.addReader}}),Object.defineProperty(e,"addWriter",{enumerable:!0,get:function(){return t.addWriter}});var r=DataItem$d;Object.defineProperty(e,"DataItem",{enumerable:!0,get:function(){return r.DataItem}})})(lib$d);Object.defineProperty(utils$n,"__esModule",{value:!0});utils$n.patchTags=void 0;const lib_1$9=lib$d,alreadyPatchedTag=[],patchTags=e=>{e.forEach(t=>{alreadyPatchedTag.find(r=>r===t)||((0,lib_1$9.addSemanticEncode)(t,r=>{if(r instanceof lib_1$9.DataItem&&r.getTag()===t)return r.getData()}),(0,lib_1$9.addSemanticDecode)(t,r=>new lib_1$9.DataItem(r,t)),alreadyPatchedTag.push(t))})};utils$n.patchTags=patchTags;var RegistryType$d={};Object.defineProperty(RegistryType$d,"__esModule",{value:!0});RegistryType$d.RegistryTypes=RegistryType$d.RegistryType=void 0;let RegistryType$c=class{constructor(t,r){this.type=t,this.tag=r,this.getTag=()=>this.tag,this.getType=()=>this.type}};RegistryType$d.RegistryType=RegistryType$c;RegistryType$d.RegistryTypes={UUID:new RegistryType$c("uuid",37),BYTES:new RegistryType$c("bytes",void 0),CRYPTO_HDKEY:new RegistryType$c("crypto-hdkey",303),CRYPTO_KEYPATH:new RegistryType$c("crypto-keypath",304),CRYPTO_COIN_INFO:new RegistryType$c("crypto-coin-info",305),CRYPTO_ECKEY:new RegistryType$c("crypto-eckey",306),CRYPTO_OUTPUT:new RegistryType$c("crypto-output",308),CRYPTO_PSBT:new RegistryType$c("crypto-psbt",310),CRYPTO_ACCOUNT:new RegistryType$c("crypto-account",311),CRYPTO_MULTI_ACCOUNTS:new RegistryType$c("crypto-multi-accounts",1103),QR_HARDWARE_CALL:new RegistryType$c("qr-hardware-call",1201),KEY_DERIVATION_CALL:new RegistryType$c("key-derivation-call",1301),KEY_DERIVATION_SCHEMA:new RegistryType$c("key-derivation-schema",1302)};var ScriptExpression$c={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ScriptExpressions=e.ScriptExpression=void 0;class t{constructor(s,o){this.tag=s,this.expression=o,this.getTag=()=>this.tag,this.getExpression=()=>this.expression}}e.ScriptExpression=t,t.fromTag=r=>Object.values(e.ScriptExpressions).find(o=>o.getTag()===r),e.ScriptExpressions={SCRIPT_HASH:new t(400,"sh"),WITNESS_SCRIPT_HASH:new t(401,"wsh"),PUBLIC_KEY:new t(402,"pk"),PUBLIC_KEY_HASH:new t(403,"pkh"),WITNESS_PUBLIC_KEY_HASH:new t(404,"wpkh"),COMBO:new t(405,"combo"),MULTISIG:new t(406,"multi"),SORTED_MULTISIG:new t(407,"sortedmulti"),ADDRESS:new t(307,"addr"),RAW_SCRIPT:new t(408,"raw")}})(ScriptExpression$c);Object.defineProperty(patchCBOR$c,"__esModule",{value:!0});const utils_1$o=utils$n,RegistryType_1$9=RegistryType$d,ScriptExpression_1$1=ScriptExpression$c,registryTags=Object.values(RegistryType_1$9.RegistryTypes).filter(e=>!!e.getTag()).map(e=>e.getTag()),scriptExpressionTags=Object.values(ScriptExpression_1$1.ScriptExpressions).map(e=>e.getTag());(0,utils_1$o.patchTags)(registryTags.concat(scriptExpressionTags));var dist$t={};(function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t={},r={};r.byteLength=c,r.toByteArray=w,r.fromByteArray=I;for(var s=[],o=[],n=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=a.length;l<p;++l)s[l]=a[l],o[a.charCodeAt(l)]=l;o[45]=62,o[95]=63;function u(M){var q=M.length;if(q%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var U=M.indexOf("=");U===-1&&(U=q);var F=U===q?0:4-U%4;return[U,F]}function c(M){var q=u(M),U=q[0],F=q[1];return(U+F)*3/4-F}function v(M,q,U){return(q+U)*3/4-U}function w(M){var q,U=u(M),F=U[0],j=U[1],y=new n(v(M,F,j)),T=0,D=j>0?F-4:F,L;for(L=0;L<D;L+=4)q=o[M.charCodeAt(L)]<<18|o[M.charCodeAt(L+1)]<<12|o[M.charCodeAt(L+2)]<<6|o[M.charCodeAt(L+3)],y[T++]=q>>16&255,y[T++]=q>>8&255,y[T++]=q&255;return j===2&&(q=o[M.charCodeAt(L)]<<2|o[M.charCodeAt(L+1)]>>4,y[T++]=q&255),j===1&&(q=o[M.charCodeAt(L)]<<10|o[M.charCodeAt(L+1)]<<4|o[M.charCodeAt(L+2)]>>2,y[T++]=q>>8&255,y[T++]=q&255),y}function b(M){return s[M>>18&63]+s[M>>12&63]+s[M>>6&63]+s[M&63]}function E(M,q,U){for(var F,j=[],y=q;y<U;y+=3)F=(M[y]<<16&16711680)+(M[y+1]<<8&65280)+(M[y+2]&255),j.push(b(F));return j.join("")}function I(M){for(var q,U=M.length,F=U%3,j=[],y=16383,T=0,D=U-F;T<D;T+=y)j.push(E(M,T,T+y>D?D:T+y));return F===1?(q=M[U-1],j.push(s[q>>2]+s[q<<4&63]+"==")):F===2&&(q=(M[U-2]<<8)+M[U-1],j.push(s[q>>10]+s[q>>4&63]+s[q<<2&63]+"=")),j.join("")}var x={};x.read=function(M,q,U,F,j){var y,T,D=j*8-F-1,L=(1<<D)-1,C=L>>1,d=-7,_=U?j-1:0,$=U?-1:1,S=M[q+_];for(_+=$,y=S&(1<<-d)-1,S>>=-d,d+=D;d>0;y=y*256+M[q+_],_+=$,d-=8);for(T=y&(1<<-d)-1,y>>=-d,d+=F;d>0;T=T*256+M[q+_],_+=$,d-=8);if(y===0)y=1-C;else{if(y===L)return T?NaN:(S?-1:1)*(1/0);T=T+Math.pow(2,F),y=y-C}return(S?-1:1)*T*Math.pow(2,y-F)},x.write=function(M,q,U,F,j,y){var T,D,L,C=y*8-j-1,d=(1<<C)-1,_=d>>1,$=j===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=F?0:y-1,O=F?1:-1,N=q<0||q===0&&1/q<0?1:0;for(q=Math.abs(q),isNaN(q)||q===1/0?(D=isNaN(q)?1:0,T=d):(T=Math.floor(Math.log(q)/Math.LN2),q*(L=Math.pow(2,-T))<1&&(T--,L*=2),T+_>=1?q+=$/L:q+=$*Math.pow(2,1-_),q*L>=2&&(T++,L/=2),T+_>=d?(D=0,T=d):T+_>=1?(D=(q*L-1)*Math.pow(2,j),T=T+_):(D=q*Math.pow(2,_-1)*Math.pow(2,j),T=0));j>=8;M[U+S]=D&255,S+=O,D/=256,j-=8);for(T=T<<j|D,C+=j;C>0;M[U+S]=T&255,S+=O,T/=256,C-=8);M[U+S-O]|=N*128};(function(M){const q=r,U=x,F=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;M.Buffer=d,M.SlowBuffer=J,M.INSPECT_MAX_BYTES=50;const j=2147483647;M.kMaxLength=j;const{Uint8Array:y,ArrayBuffer:T,SharedArrayBuffer:D}=globalThis;d.TYPED_ARRAY_SUPPORT=L(),!d.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 L(){try{const pe=new y(1),ee={foo:function(){return 42}};return Object.setPrototypeOf(ee,y.prototype),Object.setPrototypeOf(pe,ee),pe.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function C(pe){if(pe>j)throw new RangeError('The value "'+pe+'" is invalid for option "size"');const ee=new y(pe);return Object.setPrototypeOf(ee,d.prototype),ee}function d(pe,ee,ce){if(typeof pe=="number"){if(typeof ee=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return O(pe)}return _(pe,ee,ce)}d.poolSize=8192;function _(pe,ee,ce){if(typeof pe=="string")return N(pe,ee);if(T.isView(pe))return A(pe);if(pe==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof pe);if(rt(pe,T)||pe&&rt(pe.buffer,T)||typeof D<"u"&&(rt(pe,D)||pe&&rt(pe.buffer,D)))return m(pe,ee,ce);if(typeof pe=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Te=pe.valueOf&&pe.valueOf();if(Te!=null&&Te!==pe)return d.from(Te,ee,ce);const Oe=P(pe);if(Oe)return Oe;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof pe[Symbol.toPrimitive]=="function")return d.from(pe[Symbol.toPrimitive]("string"),ee,ce);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof pe)}d.from=function(pe,ee,ce){return _(pe,ee,ce)},Object.setPrototypeOf(d.prototype,y.prototype),Object.setPrototypeOf(d,y);function $(pe){if(typeof pe!="number")throw new TypeError('"size" argument must be of type number');if(pe<0)throw new RangeError('The value "'+pe+'" is invalid for option "size"')}function S(pe,ee,ce){return $(pe),pe<=0?C(pe):ee!==void 0?typeof ce=="string"?C(pe).fill(ee,ce):C(pe).fill(ee):C(pe)}d.alloc=function(pe,ee,ce){return S(pe,ee,ce)};function O(pe){return $(pe),C(pe<0?0:H(pe)|0)}d.allocUnsafe=function(pe){return O(pe)},d.allocUnsafeSlow=function(pe){return O(pe)};function N(pe,ee){if((typeof ee!="string"||ee==="")&&(ee="utf8"),!d.isEncoding(ee))throw new TypeError("Unknown encoding: "+ee);const ce=X(pe,ee)|0;let Te=C(ce);const Oe=Te.write(pe,ee);return Oe!==ce&&(Te=Te.slice(0,Oe)),Te}function k(pe){const ee=pe.length<0?0:H(pe.length)|0,ce=C(ee);for(let Te=0;Te<ee;Te+=1)ce[Te]=pe[Te]&255;return ce}function A(pe){if(rt(pe,y)){const ee=new y(pe);return m(ee.buffer,ee.byteOffset,ee.byteLength)}return k(pe)}function m(pe,ee,ce){if(ee<0||pe.byteLength<ee)throw new RangeError('"offset" is outside of buffer bounds');if(pe.byteLength<ee+(ce||0))throw new RangeError('"length" is outside of buffer bounds');let Te;return ee===void 0&&ce===void 0?Te=new y(pe):ce===void 0?Te=new y(pe,ee):Te=new y(pe,ee,ce),Object.setPrototypeOf(Te,d.prototype),Te}function P(pe){if(d.isBuffer(pe)){const ee=H(pe.length)|0,ce=C(ee);return ce.length===0||pe.copy(ce,0,0,ee),ce}if(pe.length!==void 0)return typeof pe.length!="number"||mt(pe.length)?C(0):k(pe);if(pe.type==="Buffer"&&Array.isArray(pe.data))return k(pe.data)}function H(pe){if(pe>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return pe|0}function J(pe){return+pe!=pe&&(pe=0),d.alloc(+pe)}d.isBuffer=function(ee){return ee!=null&&ee._isBuffer===!0&&ee!==d.prototype},d.compare=function(ee,ce){if(rt(ee,y)&&(ee=d.from(ee,ee.offset,ee.byteLength)),rt(ce,y)&&(ce=d.from(ce,ce.offset,ce.byteLength)),!d.isBuffer(ee)||!d.isBuffer(ce))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(ee===ce)return 0;let Te=ee.length,Oe=ce.length;for(let Ve=0,qe=Math.min(Te,Oe);Ve<qe;++Ve)if(ee[Ve]!==ce[Ve]){Te=ee[Ve],Oe=ce[Ve];break}return Te<Oe?-1:Oe<Te?1:0},d.isEncoding=function(ee){switch(String(ee).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}},d.concat=function(ee,ce){if(!Array.isArray(ee))throw new TypeError('"list" argument must be an Array of Buffers');if(ee.length===0)return d.alloc(0);let Te;if(ce===void 0)for(ce=0,Te=0;Te<ee.length;++Te)ce+=ee[Te].length;const Oe=d.allocUnsafe(ce);let Ve=0;for(Te=0;Te<ee.length;++Te){let qe=ee[Te];if(rt(qe,y))Ve+qe.length>Oe.length?(d.isBuffer(qe)||(qe=d.from(qe)),qe.copy(Oe,Ve)):y.prototype.set.call(Oe,qe,Ve);else if(d.isBuffer(qe))qe.copy(Oe,Ve);else throw new TypeError('"list" argument must be an Array of Buffers');Ve+=qe.length}return Oe};function X(pe,ee){if(d.isBuffer(pe))return pe.length;if(T.isView(pe)||rt(pe,T))return pe.byteLength;if(typeof pe!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof pe);const ce=pe.length,Te=arguments.length>2&&arguments[2]===!0;if(!Te&&ce===0)return 0;let Oe=!1;for(;;)switch(ee){case"ascii":case"latin1":case"binary":return ce;case"utf8":case"utf-8":return ot(pe).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce*2;case"hex":return ce>>>1;case"base64":return ht(pe).length;default:if(Oe)return Te?-1:ot(pe).length;ee=(""+ee).toLowerCase(),Oe=!0}}d.byteLength=X;function se(pe,ee,ce){let Te=!1;if((ee===void 0||ee<0)&&(ee=0),ee>this.length||((ce===void 0||ce>this.length)&&(ce=this.length),ce<=0)||(ce>>>=0,ee>>>=0,ce<=ee))return"";for(pe||(pe="utf8");;)switch(pe){case"hex":return Ue(this,ee,ce);case"utf8":case"utf-8":return me(this,ee,ce);case"ascii":return Ce(this,ee,ce);case"latin1":case"binary":return $e(this,ee,ce);case"base64":return le(this,ee,ce);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Me(this,ee,ce);default:if(Te)throw new TypeError("Unknown encoding: "+pe);pe=(pe+"").toLowerCase(),Te=!0}}d.prototype._isBuffer=!0;function ne(pe,ee,ce){const Te=pe[ee];pe[ee]=pe[ce],pe[ce]=Te}d.prototype.swap16=function(){const ee=this.length;if(ee%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let ce=0;ce<ee;ce+=2)ne(this,ce,ce+1);return this},d.prototype.swap32=function(){const ee=this.length;if(ee%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let ce=0;ce<ee;ce+=4)ne(this,ce,ce+3),ne(this,ce+1,ce+2);return this},d.prototype.swap64=function(){const ee=this.length;if(ee%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let ce=0;ce<ee;ce+=8)ne(this,ce,ce+7),ne(this,ce+1,ce+6),ne(this,ce+2,ce+5),ne(this,ce+3,ce+4);return this},d.prototype.toString=function(){const ee=this.length;return ee===0?"":arguments.length===0?me(this,0,ee):se.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(ee){if(!d.isBuffer(ee))throw new TypeError("Argument must be a Buffer");return this===ee?!0:d.compare(this,ee)===0},d.prototype.inspect=function(){let ee="";const ce=M.INSPECT_MAX_BYTES;return ee=this.toString("hex",0,ce).replace(/(.{2})/g,"$1 ").trim(),this.length>ce&&(ee+=" ... "),"<Buffer "+ee+">"},F&&(d.prototype[F]=d.prototype.inspect),d.prototype.compare=function(ee,ce,Te,Oe,Ve){if(rt(ee,y)&&(ee=d.from(ee,ee.offset,ee.byteLength)),!d.isBuffer(ee))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof ee);if(ce===void 0&&(ce=0),Te===void 0&&(Te=ee?ee.length:0),Oe===void 0&&(Oe=0),Ve===void 0&&(Ve=this.length),ce<0||Te>ee.length||Oe<0||Ve>this.length)throw new RangeError("out of range index");if(Oe>=Ve&&ce>=Te)return 0;if(Oe>=Ve)return-1;if(ce>=Te)return 1;if(ce>>>=0,Te>>>=0,Oe>>>=0,Ve>>>=0,this===ee)return 0;let qe=Ve-Oe,Ye=Te-ce;const pt=Math.min(qe,Ye),Ge=this.slice(Oe,Ve),Xe=ee.slice(ce,Te);for(let lt=0;lt<pt;++lt)if(Ge[lt]!==Xe[lt]){qe=Ge[lt],Ye=Xe[lt];break}return qe<Ye?-1:Ye<qe?1:0};function Z(pe,ee,ce,Te,Oe){if(pe.length===0)return-1;if(typeof ce=="string"?(Te=ce,ce=0):ce>2147483647?ce=2147483647:ce<-2147483648&&(ce=-2147483648),ce=+ce,mt(ce)&&(ce=Oe?0:pe.length-1),ce<0&&(ce=pe.length+ce),ce>=pe.length){if(Oe)return-1;ce=pe.length-1}else if(ce<0)if(Oe)ce=0;else return-1;if(typeof ee=="string"&&(ee=d.from(ee,Te)),d.isBuffer(ee))return ee.length===0?-1:oe(pe,ee,ce,Te,Oe);if(typeof ee=="number")return ee=ee&255,typeof y.prototype.indexOf=="function"?Oe?y.prototype.indexOf.call(pe,ee,ce):y.prototype.lastIndexOf.call(pe,ee,ce):oe(pe,[ee],ce,Te,Oe);throw new TypeError("val must be string, number or Buffer")}function oe(pe,ee,ce,Te,Oe){let Ve=1,qe=pe.length,Ye=ee.length;if(Te!==void 0&&(Te=String(Te).toLowerCase(),Te==="ucs2"||Te==="ucs-2"||Te==="utf16le"||Te==="utf-16le")){if(pe.length<2||ee.length<2)return-1;Ve=2,qe/=2,Ye/=2,ce/=2}function pt(Xe,lt){return Ve===1?Xe[lt]:Xe.readUInt16BE(lt*Ve)}let Ge;if(Oe){let Xe=-1;for(Ge=ce;Ge<qe;Ge++)if(pt(pe,Ge)===pt(ee,Xe===-1?0:Ge-Xe)){if(Xe===-1&&(Xe=Ge),Ge-Xe+1===Ye)return Xe*Ve}else Xe!==-1&&(Ge-=Ge-Xe),Xe=-1}else for(ce+Ye>qe&&(ce=qe-Ye),Ge=ce;Ge>=0;Ge--){let Xe=!0;for(let lt=0;lt<Ye;lt++)if(pt(pe,Ge+lt)!==pt(ee,lt)){Xe=!1;break}if(Xe)return Ge}return-1}d.prototype.includes=function(ee,ce,Te){return this.indexOf(ee,ce,Te)!==-1},d.prototype.indexOf=function(ee,ce,Te){return Z(this,ee,ce,Te,!0)},d.prototype.lastIndexOf=function(ee,ce,Te){return Z(this,ee,ce,Te,!1)};function ye(pe,ee,ce,Te){ce=Number(ce)||0;const Oe=pe.length-ce;Te?(Te=Number(Te),Te>Oe&&(Te=Oe)):Te=Oe;const Ve=ee.length;Te>Ve/2&&(Te=Ve/2);let qe;for(qe=0;qe<Te;++qe){const Ye=parseInt(ee.substr(qe*2,2),16);if(mt(Ye))return qe;pe[ce+qe]=Ye}return qe}function Y(pe,ee,ce,Te){return Je(ot(ee,pe.length-ce),pe,ce,Te)}function G(pe,ee,ce,Te){return Je(He(ee),pe,ce,Te)}function V(pe,ee,ce,Te){return Je(ht(ee),pe,ce,Te)}function te(pe,ee,ce,Te){return Je(We(ee,pe.length-ce),pe,ce,Te)}d.prototype.write=function(ee,ce,Te,Oe){if(ce===void 0)Oe="utf8",Te=this.length,ce=0;else if(Te===void 0&&typeof ce=="string")Oe=ce,Te=this.length,ce=0;else if(isFinite(ce))ce=ce>>>0,isFinite(Te)?(Te=Te>>>0,Oe===void 0&&(Oe="utf8")):(Oe=Te,Te=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Ve=this.length-ce;if((Te===void 0||Te>Ve)&&(Te=Ve),ee.length>0&&(Te<0||ce<0)||ce>this.length)throw new RangeError("Attempt to write outside buffer bounds");Oe||(Oe="utf8");let qe=!1;for(;;)switch(Oe){case"hex":return ye(this,ee,ce,Te);case"utf8":case"utf-8":return Y(this,ee,ce,Te);case"ascii":case"latin1":case"binary":return G(this,ee,ce,Te);case"base64":return V(this,ee,ce,Te);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return te(this,ee,ce,Te);default:if(qe)throw new TypeError("Unknown encoding: "+Oe);Oe=(""+Oe).toLowerCase(),qe=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function le(pe,ee,ce){return ee===0&&ce===pe.length?q.fromByteArray(pe):q.fromByteArray(pe.slice(ee,ce))}function me(pe,ee,ce){ce=Math.min(pe.length,ce);const Te=[];let Oe=ee;for(;Oe<ce;){const Ve=pe[Oe];let qe=null,Ye=Ve>239?4:Ve>223?3:Ve>191?2:1;if(Oe+Ye<=ce){let pt,Ge,Xe,lt;switch(Ye){case 1:Ve<128&&(qe=Ve);break;case 2:pt=pe[Oe+1],(pt&192)===128&&(lt=(Ve&31)<<6|pt&63,lt>127&&(qe=lt));break;case 3:pt=pe[Oe+1],Ge=pe[Oe+2],(pt&192)===128&&(Ge&192)===128&&(lt=(Ve&15)<<12|(pt&63)<<6|Ge&63,lt>2047&&(lt<55296||lt>57343)&&(qe=lt));break;case 4:pt=pe[Oe+1],Ge=pe[Oe+2],Xe=pe[Oe+3],(pt&192)===128&&(Ge&192)===128&&(Xe&192)===128&&(lt=(Ve&15)<<18|(pt&63)<<12|(Ge&63)<<6|Xe&63,lt>65535&&lt<1114112&&(qe=lt))}}qe===null?(qe=65533,Ye=1):qe>65535&&(qe-=65536,Te.push(qe>>>10&1023|55296),qe=56320|qe&1023),Te.push(qe),Oe+=Ye}return Be(Te)}const Re=4096;function Be(pe){const ee=pe.length;if(ee<=Re)return String.fromCharCode.apply(String,pe);let ce="",Te=0;for(;Te<ee;)ce+=String.fromCharCode.apply(String,pe.slice(Te,Te+=Re));return ce}function Ce(pe,ee,ce){let Te="";ce=Math.min(pe.length,ce);for(let Oe=ee;Oe<ce;++Oe)Te+=String.fromCharCode(pe[Oe]&127);return Te}function $e(pe,ee,ce){let Te="";ce=Math.min(pe.length,ce);for(let Oe=ee;Oe<ce;++Oe)Te+=String.fromCharCode(pe[Oe]);return Te}function Ue(pe,ee,ce){const Te=pe.length;(!ee||ee<0)&&(ee=0),(!ce||ce<0||ce>Te)&&(ce=Te);let Oe="";for(let Ve=ee;Ve<ce;++Ve)Oe+=Ze[pe[Ve]];return Oe}function Me(pe,ee,ce){const Te=pe.slice(ee,ce);let Oe="";for(let Ve=0;Ve<Te.length-1;Ve+=2)Oe+=String.fromCharCode(Te[Ve]+Te[Ve+1]*256);return Oe}d.prototype.slice=function(ee,ce){const Te=this.length;ee=~~ee,ce=ce===void 0?Te:~~ce,ee<0?(ee+=Te,ee<0&&(ee=0)):ee>Te&&(ee=Te),ce<0?(ce+=Te,ce<0&&(ce=0)):ce>Te&&(ce=Te),ce<ee&&(ce=ee);const Oe=this.subarray(ee,ce);return Object.setPrototypeOf(Oe,d.prototype),Oe};function ke(pe,ee,ce){if(pe%1!==0||pe<0)throw new RangeError("offset is not uint");if(pe+ee>ce)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee],Ve=1,qe=0;for(;++qe<ce&&(Ve*=256);)Oe+=this[ee+qe]*Ve;return Oe},d.prototype.readUintBE=d.prototype.readUIntBE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee+--ce],Ve=1;for(;ce>0&&(Ve*=256);)Oe+=this[ee+--ce]*Ve;return Oe},d.prototype.readUint8=d.prototype.readUInt8=function(ee,ce){return ee=ee>>>0,ce||ke(ee,1,this.length),this[ee]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,2,this.length),this[ee]|this[ee+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,2,this.length),this[ee]<<8|this[ee+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),(this[ee]|this[ee+1]<<8|this[ee+2]<<16)+this[ee+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]*16777216+(this[ee+1]<<16|this[ee+2]<<8|this[ee+3])},d.prototype.readBigUInt64LE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=ce+this[++ee]*2**8+this[++ee]*2**16+this[++ee]*2**24,Ve=this[++ee]+this[++ee]*2**8+this[++ee]*2**16+Te*2**24;return BigInt(Oe)+(BigInt(Ve)<<BigInt(32))}),d.prototype.readBigUInt64BE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=ce*2**24+this[++ee]*2**16+this[++ee]*2**8+this[++ee],Ve=this[++ee]*2**24+this[++ee]*2**16+this[++ee]*2**8+Te;return(BigInt(Oe)<<BigInt(32))+BigInt(Ve)}),d.prototype.readIntLE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee],Ve=1,qe=0;for(;++qe<ce&&(Ve*=256);)Oe+=this[ee+qe]*Ve;return Ve*=128,Oe>=Ve&&(Oe-=Math.pow(2,8*ce)),Oe},d.prototype.readIntBE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=ce,Ve=1,qe=this[ee+--Oe];for(;Oe>0&&(Ve*=256);)qe+=this[ee+--Oe]*Ve;return Ve*=128,qe>=Ve&&(qe-=Math.pow(2,8*ce)),qe},d.prototype.readInt8=function(ee,ce){return ee=ee>>>0,ce||ke(ee,1,this.length),this[ee]&128?(255-this[ee]+1)*-1:this[ee]},d.prototype.readInt16LE=function(ee,ce){ee=ee>>>0,ce||ke(ee,2,this.length);const Te=this[ee]|this[ee+1]<<8;return Te&32768?Te|4294901760:Te},d.prototype.readInt16BE=function(ee,ce){ee=ee>>>0,ce||ke(ee,2,this.length);const Te=this[ee+1]|this[ee]<<8;return Te&32768?Te|4294901760:Te},d.prototype.readInt32LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]|this[ee+1]<<8|this[ee+2]<<16|this[ee+3]<<24},d.prototype.readInt32BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]<<24|this[ee+1]<<16|this[ee+2]<<8|this[ee+3]},d.prototype.readBigInt64LE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=this[ee+4]+this[ee+5]*2**8+this[ee+6]*2**16+(Te<<24);return(BigInt(Oe)<<BigInt(32))+BigInt(ce+this[++ee]*2**8+this[++ee]*2**16+this[++ee]*2**24)}),d.prototype.readBigInt64BE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=(ce<<24)+this[++ee]*2**16+this[++ee]*2**8+this[++ee];return(BigInt(Oe)<<BigInt(32))+BigInt(this[++ee]*2**24+this[++ee]*2**16+this[++ee]*2**8+Te)}),d.prototype.readFloatLE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),U.read(this,ee,!0,23,4)},d.prototype.readFloatBE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),U.read(this,ee,!1,23,4)},d.prototype.readDoubleLE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,8,this.length),U.read(this,ee,!0,52,8)},d.prototype.readDoubleBE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,8,this.length),U.read(this,ee,!1,52,8)};function tt(pe,ee,ce,Te,Oe,Ve){if(!d.isBuffer(pe))throw new TypeError('"buffer" argument must be a Buffer instance');if(ee>Oe||ee<Ve)throw new RangeError('"value" argument is out of bounds');if(ce+Te>pe.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,Te=Te>>>0,!Oe){const Ye=Math.pow(2,8*Te)-1;tt(this,ee,ce,Te,Ye,0)}let Ve=1,qe=0;for(this[ce]=ee&255;++qe<Te&&(Ve*=256);)this[ce+qe]=ee/Ve&255;return ce+Te},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,Te=Te>>>0,!Oe){const Ye=Math.pow(2,8*Te)-1;tt(this,ee,ce,Te,Ye,0)}let Ve=Te-1,qe=1;for(this[ce+Ve]=ee&255;--Ve>=0&&(qe*=256);)this[ce+Ve]=ee/qe&255;return ce+Te},d.prototype.writeUint8=d.prototype.writeUInt8=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,1,255,0),this[ce]=ee&255,ce+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,65535,0),this[ce]=ee&255,this[ce+1]=ee>>>8,ce+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,65535,0),this[ce]=ee>>>8,this[ce+1]=ee&255,ce+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,4294967295,0),this[ce+3]=ee>>>24,this[ce+2]=ee>>>16,this[ce+1]=ee>>>8,this[ce]=ee&255,ce+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,4294967295,0),this[ce]=ee>>>24,this[ce+1]=ee>>>16,this[ce+2]=ee>>>8,this[ce+3]=ee&255,ce+4};function Ie(pe,ee,ce,Te,Oe){ue(ee,Te,Oe,pe,ce,7);let Ve=Number(ee&BigInt(4294967295));pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve;let qe=Number(ee>>BigInt(32)&BigInt(4294967295));return pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,ce}function xe(pe,ee,ce,Te,Oe){ue(ee,Te,Oe,pe,ce,7);let Ve=Number(ee&BigInt(4294967295));pe[ce+7]=Ve,Ve=Ve>>8,pe[ce+6]=Ve,Ve=Ve>>8,pe[ce+5]=Ve,Ve=Ve>>8,pe[ce+4]=Ve;let qe=Number(ee>>BigInt(32)&BigInt(4294967295));return pe[ce+3]=qe,qe=qe>>8,pe[ce+2]=qe,qe=qe>>8,pe[ce+1]=qe,qe=qe>>8,pe[ce]=qe,ce+8}d.prototype.writeBigUInt64LE=it(function(ee,ce=0){return Ie(this,ee,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=it(function(ee,ce=0){return xe(this,ee,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,!Oe){const pt=Math.pow(2,8*Te-1);tt(this,ee,ce,Te,pt-1,-pt)}let Ve=0,qe=1,Ye=0;for(this[ce]=ee&255;++Ve<Te&&(qe*=256);)ee<0&&Ye===0&&this[ce+Ve-1]!==0&&(Ye=1),this[ce+Ve]=(ee/qe>>0)-Ye&255;return ce+Te},d.prototype.writeIntBE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,!Oe){const pt=Math.pow(2,8*Te-1);tt(this,ee,ce,Te,pt-1,-pt)}let Ve=Te-1,qe=1,Ye=0;for(this[ce+Ve]=ee&255;--Ve>=0&&(qe*=256);)ee<0&&Ye===0&&this[ce+Ve+1]!==0&&(Ye=1),this[ce+Ve]=(ee/qe>>0)-Ye&255;return ce+Te},d.prototype.writeInt8=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,1,127,-128),ee<0&&(ee=255+ee+1),this[ce]=ee&255,ce+1},d.prototype.writeInt16LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,32767,-32768),this[ce]=ee&255,this[ce+1]=ee>>>8,ce+2},d.prototype.writeInt16BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,32767,-32768),this[ce]=ee>>>8,this[ce+1]=ee&255,ce+2},d.prototype.writeInt32LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,2147483647,-2147483648),this[ce]=ee&255,this[ce+1]=ee>>>8,this[ce+2]=ee>>>16,this[ce+3]=ee>>>24,ce+4},d.prototype.writeInt32BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,2147483647,-2147483648),ee<0&&(ee=4294967295+ee+1),this[ce]=ee>>>24,this[ce+1]=ee>>>16,this[ce+2]=ee>>>8,this[ce+3]=ee&255,ce+4},d.prototype.writeBigInt64LE=it(function(ee,ce=0){return Ie(this,ee,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=it(function(ee,ce=0){return xe(this,ee,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function he(pe,ee,ce,Te,Oe,Ve){if(ce+Te>pe.length)throw new RangeError("Index out of range");if(ce<0)throw new RangeError("Index out of range")}function ae(pe,ee,ce,Te,Oe){return ee=+ee,ce=ce>>>0,Oe||he(pe,ee,ce,4),U.write(pe,ee,ce,Te,23,4),ce+4}d.prototype.writeFloatLE=function(ee,ce,Te){return ae(this,ee,ce,!0,Te)},d.prototype.writeFloatBE=function(ee,ce,Te){return ae(this,ee,ce,!1,Te)};function be(pe,ee,ce,Te,Oe){return ee=+ee,ce=ce>>>0,Oe||he(pe,ee,ce,8),U.write(pe,ee,ce,Te,52,8),ce+8}d.prototype.writeDoubleLE=function(ee,ce,Te){return be(this,ee,ce,!0,Te)},d.prototype.writeDoubleBE=function(ee,ce,Te){return be(this,ee,ce,!1,Te)},d.prototype.copy=function(ee,ce,Te,Oe){if(!d.isBuffer(ee))throw new TypeError("argument should be a Buffer");if(Te||(Te=0),!Oe&&Oe!==0&&(Oe=this.length),ce>=ee.length&&(ce=ee.length),ce||(ce=0),Oe>0&&Oe<Te&&(Oe=Te),Oe===Te||ee.length===0||this.length===0)return 0;if(ce<0)throw new RangeError("targetStart out of bounds");if(Te<0||Te>=this.length)throw new RangeError("Index out of range");if(Oe<0)throw new RangeError("sourceEnd out of bounds");Oe>this.length&&(Oe=this.length),ee.length-ce<Oe-Te&&(Oe=ee.length-ce+Te);const Ve=Oe-Te;return this===ee&&typeof y.prototype.copyWithin=="function"?this.copyWithin(ce,Te,Oe):y.prototype.set.call(ee,this.subarray(Te,Oe),ce),Ve},d.prototype.fill=function(ee,ce,Te,Oe){if(typeof ee=="string"){if(typeof ce=="string"?(Oe=ce,ce=0,Te=this.length):typeof Te=="string"&&(Oe=Te,Te=this.length),Oe!==void 0&&typeof Oe!="string")throw new TypeError("encoding must be a string");if(typeof Oe=="string"&&!d.isEncoding(Oe))throw new TypeError("Unknown encoding: "+Oe);if(ee.length===1){const qe=ee.charCodeAt(0);(Oe==="utf8"&&qe<128||Oe==="latin1")&&(ee=qe)}}else typeof ee=="number"?ee=ee&255:typeof ee=="boolean"&&(ee=Number(ee));if(ce<0||this.length<ce||this.length<Te)throw new RangeError("Out of range index");if(Te<=ce)return this;ce=ce>>>0,Te=Te===void 0?this.length:Te>>>0,ee||(ee=0);let Ve;if(typeof ee=="number")for(Ve=ce;Ve<Te;++Ve)this[Ve]=ee;else{const qe=d.isBuffer(ee)?ee:d.from(ee,Oe),Ye=qe.length;if(Ye===0)throw new TypeError('The value "'+ee+'" is invalid for argument "value"');for(Ve=0;Ve<Te-ce;++Ve)this[Ve+ce]=qe[Ve%Ye]}return this};const Ae={};function re(pe,ee,ce){Ae[pe]=class extends ce{constructor(){super(),Object.defineProperty(this,"message",{value:ee.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${pe}]`,this.stack,delete this.name}get code(){return pe}set code(Oe){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Oe,writable:!0})}toString(){return`${this.name} [${pe}]: ${this.message}`}}}re("ERR_BUFFER_OUT_OF_BOUNDS",function(pe){return pe?`${pe} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),re("ERR_INVALID_ARG_TYPE",function(pe,ee){return`The "${pe}" argument must be of type number. Received type ${typeof ee}`},TypeError),re("ERR_OUT_OF_RANGE",function(pe,ee,ce){let Te=`The value of "${pe}" is out of range.`,Oe=ce;return Number.isInteger(ce)&&Math.abs(ce)>2**32?Oe=z(String(ce)):typeof ce=="bigint"&&(Oe=String(ce),(ce>BigInt(2)**BigInt(32)||ce<-(BigInt(2)**BigInt(32)))&&(Oe=z(Oe)),Oe+="n"),Te+=` It must be ${ee}. Received ${Oe}`,Te},RangeError);function z(pe){let ee="",ce=pe.length;const Te=pe[0]==="-"?1:0;for(;ce>=Te+4;ce-=3)ee=`_${pe.slice(ce-3,ce)}${ee}`;return`${pe.slice(0,ce)}${ee}`}function Q(pe,ee,ce){we(ee,"offset"),(pe[ee]===void 0||pe[ee+ce]===void 0)&&Ne(ee,pe.length-(ce+1))}function ue(pe,ee,ce,Te,Oe,Ve){if(pe>ce||pe<ee){const qe=typeof ee=="bigint"?"n":"";let Ye;throw ee===0||ee===BigInt(0)?Ye=`>= 0${qe} and < 2${qe} ** ${(Ve+1)*8}${qe}`:Ye=`>= -(2${qe} ** ${(Ve+1)*8-1}${qe}) and < 2 ** ${(Ve+1)*8-1}${qe}`,new Ae.ERR_OUT_OF_RANGE("value",Ye,pe)}Q(Te,Oe,Ve)}function we(pe,ee){if(typeof pe!="number")throw new Ae.ERR_INVALID_ARG_TYPE(ee,"number",pe)}function Ne(pe,ee,ce){throw Math.floor(pe)!==pe?(we(pe,ce),new Ae.ERR_OUT_OF_RANGE("offset","an integer",pe)):ee<0?new Ae.ERR_BUFFER_OUT_OF_BOUNDS:new Ae.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${ee}`,pe)}const De=/[^+/0-9A-Za-z-_]/g;function je(pe){if(pe=pe.split("=")[0],pe=pe.trim().replace(De,""),pe.length<2)return"";for(;pe.length%4!==0;)pe=pe+"=";return pe}function ot(pe,ee){ee=ee||1/0;let ce;const Te=pe.length;let Oe=null;const Ve=[];for(let qe=0;qe<Te;++qe){if(ce=pe.charCodeAt(qe),ce>55295&&ce<57344){if(!Oe){if(ce>56319){(ee-=3)>-1&&Ve.push(239,191,189);continue}else if(qe+1===Te){(ee-=3)>-1&&Ve.push(239,191,189);continue}Oe=ce;continue}if(ce<56320){(ee-=3)>-1&&Ve.push(239,191,189),Oe=ce;continue}ce=(Oe-55296<<10|ce-56320)+65536}else Oe&&(ee-=3)>-1&&Ve.push(239,191,189);if(Oe=null,ce<128){if((ee-=1)<0)break;Ve.push(ce)}else if(ce<2048){if((ee-=2)<0)break;Ve.push(ce>>6|192,ce&63|128)}else if(ce<65536){if((ee-=3)<0)break;Ve.push(ce>>12|224,ce>>6&63|128,ce&63|128)}else if(ce<1114112){if((ee-=4)<0)break;Ve.push(ce>>18|240,ce>>12&63|128,ce>>6&63|128,ce&63|128)}else throw new Error("Invalid code point")}return Ve}function He(pe){const ee=[];for(let ce=0;ce<pe.length;++ce)ee.push(pe.charCodeAt(ce)&255);return ee}function We(pe,ee){let ce,Te,Oe;const Ve=[];for(let qe=0;qe<pe.length&&!((ee-=2)<0);++qe)ce=pe.charCodeAt(qe),Te=ce>>8,Oe=ce%256,Ve.push(Oe),Ve.push(Te);return Ve}function ht(pe){return q.toByteArray(je(pe))}function Je(pe,ee,ce,Te){let Oe;for(Oe=0;Oe<Te&&!(Oe+ce>=ee.length||Oe>=pe.length);++Oe)ee[Oe+ce]=pe[Oe];return Oe}function rt(pe,ee){return pe instanceof ee||pe!=null&&pe.constructor!=null&&pe.constructor.name!=null&&pe.constructor.name===ee.name}function mt(pe){return pe!==pe}const Ze=function(){const pe="0123456789abcdef",ee=new Array(256);for(let ce=0;ce<16;++ce){const Te=ce*16;for(let Oe=0;Oe<16;++Oe)ee[Te+Oe]=pe[ce]+pe[Oe]}return ee}();function it(pe){return typeof BigInt>"u"?_t:pe}function _t(){throw new Error("BigInt not supported")}})(t);const B=t.Buffer;e.Blob=t.Blob,e.BlobOptions=t.BlobOptions,e.Buffer=t.Buffer,e.File=t.File,e.FileOptions=t.FileOptions,e.INSPECT_MAX_BYTES=t.INSPECT_MAX_BYTES,e.SlowBuffer=t.SlowBuffer,e.TranscodeEncoding=t.TranscodeEncoding,e.atob=t.atob,e.btoa=t.btoa,e.constants=t.constants,e.default=B,e.isAscii=t.isAscii,e.isUtf8=t.isUtf8,e.kMaxLength=t.kMaxLength,e.kStringMaxLength=t.kStringMaxLength,e.resolveObjectURL=t.resolveObjectURL,e.transcode=t.transcode})(dist$t);var CryptoHDKey$d={},inherits_browser={exports:{}};typeof Object.create=="function"?inherits_browser.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser.exports=function(t,r){if(r){t.super_=r;var s=function(){};s.prototype=r.prototype,t.prototype=new s,t.prototype.constructor=t}};var inherits_browserExports=inherits_browser.exports,safeBuffer$1={exports:{}};const require$$0$3=getAugmentedNamespace(dist$w);(function(e,t){var r=require$$0$3,s=r.Buffer;function o(a,l){for(var p in a)l[p]=a[p]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=n);function n(a,l,p){return s(a,l,p)}n.prototype=Object.create(s.prototype),o(s,n),n.from=function(a,l,p){if(typeof a=="number")throw new TypeError("Argument must not be a number");return s(a,l,p)},n.alloc=function(a,l,p){if(typeof a!="number")throw new TypeError("Argument must be a number");var u=s(a);return l!==void 0?typeof p=="string"?u.fill(l,p):u.fill(l):u.fill(0),u},n.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return s(a)},n.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}})(safeBuffer$1,safeBuffer$1.exports);var safeBufferExports=safeBuffer$1.exports,readableBrowser$1={exports:{}};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var browser$c={exports:{}},process=browser$c.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch{try{return cachedSetTimeout.call(null,e,0)}catch{return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch{try{return cachedClearTimeout.call(null,e)}catch{return cachedClearTimeout.call(this,e)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=!0;process.env={};process.argv=[];process.version="";process.versions={};function noop$2(){}process.on=noop$2;process.addListener=noop$2;process.once=noop$2;process.off=noop$2;process.removeListener=noop$2;process.removeAllListeners=noop$2;process.emit=noop$2;process.prependListener=noop$2;process.prependOnceListener=noop$2;process.listeners=function(e){return[]};process.binding=function(e){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(e){throw new Error("process.chdir is not supported")};process.umask=function(){return 0};var browserExports=browser$c.exports;const process$1=getDefaultExportFromCjs(browserExports);var events={exports:{}},R=typeof Reflect=="object"?Reflect:null,ReflectApply=R&&typeof R.apply=="function"?R.apply:function(t,r,s){return Function.prototype.apply.call(t,r,s)},ReflectOwnKeys;R&&typeof R.ownKeys=="function"?ReflectOwnKeys=R.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}var NumberIsNaN=Number.isNaN||function(t){return t!==t};function EventEmitter(){EventEmitter.init.call(this)}events.exports=EventEmitter;events.exports.once=once$2;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=void 0;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if(typeof e!="number"||e<0||NumberIsNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");defaultMaxListeners=e}});EventEmitter.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||NumberIsNaN(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function _getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function(t){for(var r=[],s=1;s<arguments.length;s++)r.push(arguments[s]);var o=t==="error",n=this._events;if(n!==void 0)o=o&&n.error===void 0;else if(!o)return!1;if(o){var a;if(r.length>0&&(a=r[0]),a instanceof Error)throw a;var l=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw l.context=a,l}var p=n[t];if(p===void 0)return!1;if(typeof p=="function")ReflectApply(p,this,r);else for(var u=p.length,c=arrayClone(p,u),s=0;s<u;++s)ReflectApply(c[s],this,r);return!0};function _addListener(e,t,r,s){var o,n,a;if(checkListener(r),n=e._events,n===void 0?(n=e._events=Object.create(null),e._eventsCount=0):(n.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),a=n[t]),a===void 0)a=n[t]=r,++e._eventsCount;else if(typeof a=="function"?a=n[t]=s?[r,a]:[a,r]:s?a.unshift(r):a.push(r),o=_getMaxListeners(e),o>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,ProcessEmitWarning(l)}return e}EventEmitter.prototype.addListener=function(t,r){return _addListener(this,t,r,!1)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function(t,r){return _addListener(this,t,r,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,r){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=onceWrapper.bind(s);return o.listener=r,s.wrapFn=o,o}EventEmitter.prototype.once=function(t,r){return checkListener(r),this.on(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.prependOnceListener=function(t,r){return checkListener(r),this.prependListener(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.removeListener=function(t,r){var s,o,n,a,l;if(checkListener(r),o=this._events,o===void 0)return this;if(s=o[t],s===void 0)return this;if(s===r||s.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,s.listener||r));else if(typeof s!="function"){for(n=-1,a=s.length-1;a>=0;a--)if(s[a]===r||s[a].listener===r){l=s[a].listener,n=a;break}if(n<0)return this;n===0?s.shift():spliceOne(s,n),s.length===1&&(o[t]=s[0]),o.removeListener!==void 0&&this.emit("removeListener",t,l||r)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function(t){var r,s,o;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var n=Object.keys(s),a;for(o=0;o<n.length;++o)a=n[o],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=s[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(o=r.length-1;o>=0;o--)this.removeListener(t,r[o]);return this};function _listeners(e,t,r){var s=e._events;if(s===void 0)return[];var o=s[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?unwrapListeners(o):arrayClone(o,o.length)}EventEmitter.prototype.listeners=function(t){return _listeners(this,t,!0)};EventEmitter.prototype.rawListeners=function(t){return _listeners(this,t,!1)};EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount.call(e,t)};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(e,t){for(var r=new Array(t),s=0;s<t;++s)r[s]=e[s];return r}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function once$2(e,t){return new Promise(function(r,s){function o(a){e.removeListener(t,n),s(a)}function n(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}eventTargetAgnosticAddListener(e,t,n,{once:!0}),t!=="error"&&addErrorHandlerIfEventEmitter(e,o,{once:!0})})}function addErrorHandlerIfEventEmitter(e,t,r){typeof e.on=="function"&&eventTargetAgnosticAddListener(e,"error",t,r)}function eventTargetAgnosticAddListener(e,t,r,s){if(typeof e.on=="function")s.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function o(n){s.once&&e.removeEventListener(t,o),r(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var eventsExports=events.exports,streamBrowser$1=eventsExports.EventEmitter,util$1={},types$l={},shams$1=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),s=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var o=42;t[r]=o;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var a=Object.getOwnPropertySymbols(t);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(t,r);if(l.value!==o||l.enumerable!==!0)return!1}return!0},hasSymbols$3=shams$1,shams=function(){return hasSymbols$3()&&!!Symbol.toStringTag},esObjectAtoms=Object,esErrors=Error,_eval=EvalError,range=RangeError,ref=ReferenceError,syntax=SyntaxError,type=TypeError,uri=URIError,abs$1=Math.abs,floor$1=Math.floor,max$1=Math.max,min$1=Math.min,pow$2=Math.pow,gOPD$2=Object.getOwnPropertyDescriptor,$gOPD$1=gOPD$2;if($gOPD$1)try{$gOPD$1([],"length")}catch{$gOPD$1=null}var gopd$1=$gOPD$1,$defineProperty$3=Object.defineProperty||!1;if($defineProperty$3)try{$defineProperty$3({},"a",{value:1})}catch{$defineProperty$3=!1}var esDefineProperty=$defineProperty$3,hasSymbols$2,hasRequiredHasSymbols;function requireHasSymbols(){if(hasRequiredHasSymbols)return hasSymbols$2;hasRequiredHasSymbols=1;var e=typeof Symbol<"u"&&Symbol,t=shams$1;return hasSymbols$2=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},hasSymbols$2}var implementation$6,hasRequiredImplementation$2;function requireImplementation$2(){if(hasRequiredImplementation$2)return implementation$6;hasRequiredImplementation$2=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,s="[object Function]",o=function(p,u){for(var c=[],v=0;v<p.length;v+=1)c[v]=p[v];for(var w=0;w<u.length;w+=1)c[w+p.length]=u[w];return c},n=function(p,u){for(var c=[],v=u,w=0;v<p.length;v+=1,w+=1)c[w]=p[v];return c},a=function(l,p){for(var u="",c=0;c<l.length;c+=1)u+=l[c],c+1<l.length&&(u+=p);return u};return implementation$6=function(p){var u=this;if(typeof u!="function"||t.apply(u)!==s)throw new TypeError(e+u);for(var c=n(arguments,1),v,w=function(){if(this instanceof v){var B=u.apply(this,o(c,arguments));return Object(B)===B?B:this}return u.apply(p,o(c,arguments))},b=r(0,u.length-c.length),E=[],I=0;I<b;I++)E[I]="$"+I;if(v=Function("binder","return function ("+a(E,",")+"){ return binder.apply(this,arguments); }")(w),u.prototype){var x=function(){};x.prototype=u.prototype,v.prototype=new x,x.prototype=null}return v},implementation$6}var functionBind,hasRequiredFunctionBind;function requireFunctionBind(){if(hasRequiredFunctionBind)return functionBind;hasRequiredFunctionBind=1;var e=requireImplementation$2();return functionBind=Function.prototype.bind||e,functionBind}var functionCall,hasRequiredFunctionCall;function requireFunctionCall(){return hasRequiredFunctionCall||(hasRequiredFunctionCall=1,functionCall=Function.prototype.call),functionCall}var functionApply,hasRequiredFunctionApply;function requireFunctionApply(){return hasRequiredFunctionApply||(hasRequiredFunctionApply=1,functionApply=Function.prototype.apply),functionApply}var reflectApply$1=typeof Reflect<"u"&&Reflect&&Reflect.apply,bind$3=requireFunctionBind(),$apply$2=requireFunctionApply(),$call$2=requireFunctionCall(),$reflectApply=reflectApply$1,actualApply$1=$reflectApply||bind$3.call($call$2,$apply$2),bind$2=requireFunctionBind(),$TypeError$3=type,$call$1=requireFunctionCall(),$actualApply=actualApply$1,callBindApplyHelpers=function(t){if(t.length<1||typeof t[0]!="function")throw new $TypeError$3("a function is required");return $actualApply(bind$2,$call$1,t)},get,hasRequiredGet;function requireGet(){if(hasRequiredGet)return get;hasRequiredGet=1;var e=callBindApplyHelpers,t=gopd$1,r;try{r=[].__proto__===Array.prototype}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var s=!!r&&t&&t(Object.prototype,"__proto__"),o=Object,n=o.getPrototypeOf;return get=s&&typeof s.get=="function"?e([s.get]):typeof n=="function"?function(l){return n(l==null?l:o(l))}:!1,get}var hasown,hasRequiredHasown;function requireHasown(){if(hasRequiredHasown)return hasown;hasRequiredHasown=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=requireFunctionBind();return hasown=r.call(e,t),hasown}var undefined$1,$Object$1=esObjectAtoms,$Error=esErrors,$EvalError=_eval,$RangeError=range,$ReferenceError=ref,$SyntaxError$1=syntax,$TypeError$2=type,$URIError=uri,abs=abs$1,floor=floor$1,max=max$1,min=min$1,pow$1=pow$2,$Function=Function,getEvalledConstructor=function(e){try{return $Function('"use strict"; return ('+e+").constructor;")()}catch{}},$gOPD=gopd$1,$defineProperty$2=esDefineProperty,throwTypeError=function(){throw new $TypeError$2},ThrowTypeError=$gOPD?function(){try{return arguments.callee,throwTypeError}catch{try{return $gOPD(arguments,"callee").get}catch{return throwTypeError}}}():throwTypeError,hasSymbols$1=requireHasSymbols()(),getDunderProto=requireGet(),getProto$1=typeof Reflect=="function"&&Reflect.getPrototypeOf||$Object$1.getPrototypeOf||getDunderProto,$apply$1=requireFunctionApply(),$call=requireFunctionCall(),needsEval={},TypedArray=typeof Uint8Array>"u"||!getProto$1?undefined$1:getProto$1(Uint8Array),INTRINSICS={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?undefined$1:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?undefined$1:ArrayBuffer,"%ArrayIteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1([][Symbol.iterator]()):undefined$1,"%AsyncFromSyncIteratorPrototype%":undefined$1,"%AsyncFunction%":needsEval,"%AsyncGenerator%":needsEval,"%AsyncGeneratorFunction%":needsEval,"%AsyncIteratorPrototype%":needsEval,"%Atomics%":typeof Atomics>"u"?undefined$1:Atomics,"%BigInt%":typeof BigInt>"u"?undefined$1:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?undefined$1:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?undefined$1:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?undefined$1:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":$Error,"%eval%":eval,"%EvalError%":$EvalError,"%Float32Array%":typeof Float32Array>"u"?undefined$1:Float32Array,"%Float64Array%":typeof Float64Array>"u"?undefined$1:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?undefined$1:FinalizationRegistry,"%Function%":$Function,"%GeneratorFunction%":needsEval,"%Int8Array%":typeof Int8Array>"u"?undefined$1:Int8Array,"%Int16Array%":typeof Int16Array>"u"?undefined$1:Int16Array,"%Int32Array%":typeof Int32Array>"u"?undefined$1:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1(getProto$1([][Symbol.iterator]())):undefined$1,"%JSON%":typeof JSON=="object"?JSON:undefined$1,"%Map%":typeof Map>"u"?undefined$1:Map,"%MapIteratorPrototype%":typeof Map>"u"||!hasSymbols$1||!getProto$1?undefined$1:getProto$1(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":$Object$1,"%Object.getOwnPropertyDescriptor%":$gOPD,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?undefined$1:Promise,"%Proxy%":typeof Proxy>"u"?undefined$1:Proxy,"%RangeError%":$RangeError,"%ReferenceError%":$ReferenceError,"%Reflect%":typeof Reflect>"u"?undefined$1:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?undefined$1:Set,"%SetIteratorPrototype%":typeof Set>"u"||!hasSymbols$1||!getProto$1?undefined$1:getProto$1(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?undefined$1:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1(""[Symbol.iterator]()):undefined$1,"%Symbol%":hasSymbols$1?Symbol:undefined$1,"%SyntaxError%":$SyntaxError$1,"%ThrowTypeError%":ThrowTypeError,"%TypedArray%":TypedArray,"%TypeError%":$TypeError$2,"%Uint8Array%":typeof Uint8Array>"u"?undefined$1:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?undefined$1:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?undefined$1:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?undefined$1:Uint32Array,"%URIError%":$URIError,"%WeakMap%":typeof WeakMap>"u"?undefined$1:WeakMap,"%WeakRef%":typeof WeakRef>"u"?undefined$1:WeakRef,"%WeakSet%":typeof WeakSet>"u"?undefined$1:WeakSet,"%Function.prototype.call%":$call,"%Function.prototype.apply%":$apply$1,"%Object.defineProperty%":$defineProperty$2,"%Math.abs%":abs,"%Math.floor%":floor,"%Math.max%":max,"%Math.min%":min,"%Math.pow%":pow$1};if(getProto$1)try{null.error}catch(e){var errorProto=getProto$1(getProto$1(e));INTRINSICS["%Error.prototype%"]=errorProto}var doEval=function e(t){var r;if(t==="%AsyncFunction%")r=getEvalledConstructor("async function () {}");else if(t==="%GeneratorFunction%")r=getEvalledConstructor("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=getEvalledConstructor("async function* () {}");else if(t==="%AsyncGenerator%"){var s=e("%AsyncGeneratorFunction%");s&&(r=s.prototype)}else if(t==="%AsyncIteratorPrototype%"){var o=e("%AsyncGenerator%");o&&getProto$1&&(r=getProto$1(o.prototype))}return INTRINSICS[t]=r,r},LEGACY_ALIASES={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},bind$1=requireFunctionBind(),hasOwn=requireHasown(),$concat=bind$1.call($call,Array.prototype.concat),$spliceApply=bind$1.call($apply$1,Array.prototype.splice),$replace=bind$1.call($call,String.prototype.replace),$strSlice=bind$1.call($call,String.prototype.slice),$exec=bind$1.call($call,RegExp.prototype.exec),rePropName=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=function(t){var r=$strSlice(t,0,1),s=$strSlice(t,-1);if(r==="%"&&s!=="%")throw new $SyntaxError$1("invalid intrinsic syntax, expected closing `%`");if(s==="%"&&r!=="%")throw new $SyntaxError$1("invalid intrinsic syntax, expected opening `%`");var o=[];return $replace(t,rePropName,function(n,a,l,p){o[o.length]=l?$replace(p,reEscapeChar,"$1"):a||n}),o},getBaseIntrinsic=function(t,r){var s=t,o;if(hasOwn(LEGACY_ALIASES,s)&&(o=LEGACY_ALIASES[s],s="%"+o[0]+"%"),hasOwn(INTRINSICS,s)){var n=INTRINSICS[s];if(n===needsEval&&(n=doEval(s)),typeof n>"u"&&!r)throw new $TypeError$2("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:o,name:s,value:n}}throw new $SyntaxError$1("intrinsic "+t+" does not exist!")},getIntrinsic=function(t,r){if(typeof t!="string"||t.length===0)throw new $TypeError$2("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new $TypeError$2('"allowMissing" argument must be a boolean');if($exec(/^%?[^%]*%?$/,t)===null)throw new $SyntaxError$1("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var s=stringToPath(t),o=s.length>0?s[0]:"",n=getBaseIntrinsic("%"+o+"%",r),a=n.name,l=n.value,p=!1,u=n.alias;u&&(o=u[0],$spliceApply(s,$concat([0,1],u)));for(var c=1,v=!0;c<s.length;c+=1){var w=s[c],b=$strSlice(w,0,1),E=$strSlice(w,-1);if((b==='"'||b==="'"||b==="`"||E==='"'||E==="'"||E==="`")&&b!==E)throw new $SyntaxError$1("property names with quotes must have matching quotes");if((w==="constructor"||!v)&&(p=!0),o+="."+w,a="%"+o+"%",hasOwn(INTRINSICS,a))l=INTRINSICS[a];else if(l!=null){if(!(w in l)){if(!r)throw new $TypeError$2("base intrinsic for "+t+" exists, but the property is not available.");return}if($gOPD&&c+1>=s.length){var I=$gOPD(l,w);v=!!I,v&&"get"in I&&!("originalValue"in I.get)?l=I.get:l=l[w]}else v=hasOwn(l,w),l=l[w];v&&!p&&(INTRINSICS[a]=l)}}return l},GetIntrinsic$2=getIntrinsic,callBindBasic=callBindApplyHelpers,$indexOf$2=callBindBasic([GetIntrinsic$2("%String.prototype.indexOf%")]),callBound$4=function(t,r){var s=GetIntrinsic$2(t,!!r);return typeof s=="function"&&$indexOf$2(t,".prototype.")>-1?callBindBasic([s]):s},hasToStringTag$3=shams(),callBound$3=callBound$4,$toString$1=callBound$3("Object.prototype.toString"),isStandardArguments=function(t){return hasToStringTag$3&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:$toString$1(t)==="[object Arguments]"},isLegacyArguments=function(t){return isStandardArguments(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&$toString$1(t)!=="[object Array]"&&"callee"in t&&$toString$1(t.callee)==="[object Function]"},supportsStandardArguments=function(){return isStandardArguments(arguments)}();isStandardArguments.isLegacyArguments=isLegacyArguments;var isArguments$1=supportsStandardArguments?isStandardArguments:isLegacyArguments,toStr$3=Object.prototype.toString,fnToStr$1=Function.prototype.toString,isFnRegex=/^\s*(?:function)?\*/,hasToStringTag$2=shams(),getProto=Object.getPrototypeOf,getGeneratorFunc=function(){if(!hasToStringTag$2)return!1;try{return Function("return function*() {}")()}catch{}},GeneratorFunction,isGeneratorFunction=function(t){if(typeof t!="function")return!1;if(isFnRegex.test(fnToStr$1.call(t)))return!0;if(!hasToStringTag$2){var r=toStr$3.call(t);return r==="[object GeneratorFunction]"}if(!getProto)return!1;if(typeof GeneratorFunction>"u"){var s=getGeneratorFunc();GeneratorFunction=s?getProto(s):!1}return getProto(t)===GeneratorFunction},fnToStr=Function.prototype.toString,reflectApply=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,badArrayLike,isCallableMarker;if(typeof reflectApply=="function"&&typeof Object.defineProperty=="function")try{badArrayLike=Object.defineProperty({},"length",{get:function(){throw isCallableMarker}}),isCallableMarker={},reflectApply(function(){throw 42},null,badArrayLike)}catch(e){e!==isCallableMarker&&(reflectApply=null)}else reflectApply=null;var constructorRegex=/^\s*class\b/,isES6ClassFn=function(t){try{var r=fnToStr.call(t);return constructorRegex.test(r)}catch{return!1}},tryFunctionObject=function(t){try{return isES6ClassFn(t)?!1:(fnToStr.call(t),!0)}catch{return!1}},toStr$2=Object.prototype.toString,objectClass="[object Object]",fnClass="[object Function]",genClass="[object GeneratorFunction]",ddaClass="[object HTMLAllCollection]",ddaClass2="[object HTML document.all class]",ddaClass3="[object HTMLCollection]",hasToStringTag$1=typeof Symbol=="function"&&!!Symbol.toStringTag,isIE68=!(0 in[,]),isDDA=function(){return!1};if(typeof document=="object"){var all=document.all;toStr$2.call(all)===toStr$2.call(document.all)&&(isDDA=function(t){if((isIE68||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=toStr$2.call(t);return(r===ddaClass||r===ddaClass2||r===ddaClass3||r===objectClass)&&t("")==null}catch{}return!1})}var isCallable$1=reflectApply?function(t){if(isDDA(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{reflectApply(t,null,badArrayLike)}catch(r){if(r!==isCallableMarker)return!1}return!isES6ClassFn(t)&&tryFunctionObject(t)}:function(t){if(isDDA(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(hasToStringTag$1)return tryFunctionObject(t);if(isES6ClassFn(t))return!1;var r=toStr$2.call(t);return r!==fnClass&&r!==genClass&&!/^\[object HTML/.test(r)?!1:tryFunctionObject(t)},isCallable=isCallable$1,toStr$1=Object.prototype.toString,hasOwnProperty=Object.prototype.hasOwnProperty,forEachArray=function(t,r,s){for(var o=0,n=t.length;o<n;o++)hasOwnProperty.call(t,o)&&(s==null?r(t[o],o,t):r.call(s,t[o],o,t))},forEachString=function(t,r,s){for(var o=0,n=t.length;o<n;o++)s==null?r(t.charAt(o),o,t):r.call(s,t.charAt(o),o,t)},forEachObject=function(t,r,s){for(var o in t)hasOwnProperty.call(t,o)&&(s==null?r(t[o],o,t):r.call(s,t[o],o,t))},forEach$1=function(t,r,s){if(!isCallable(r))throw new TypeError("iterator must be a function");var o;arguments.length>=3&&(o=s),toStr$1.call(t)==="[object Array]"?forEachArray(t,r,o):typeof t=="string"?forEachString(t,r,o):forEachObject(t,r,o)},forEach_1=forEach$1,possibleTypedArrayNames=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],possibleNames=possibleTypedArrayNames,g$1=typeof globalThis>"u"?commonjsGlobal:globalThis,availableTypedArrays$1=function(){for(var t=[],r=0;r<possibleNames.length;r++)typeof g$1[possibleNames[r]]=="function"&&(t[t.length]=possibleNames[r]);return t},callBind$2={exports:{}},$defineProperty$1=esDefineProperty,$SyntaxError=syntax,$TypeError$1=type,gopd=gopd$1,defineDataProperty=function(t,r,s){if(!t||typeof t!="object"&&typeof t!="function")throw new $TypeError$1("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new $TypeError$1("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new $TypeError$1("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new $TypeError$1("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new $TypeError$1("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new $TypeError$1("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,l=arguments.length>6?arguments[6]:!1,p=!!gopd&&gopd(t,r);if($defineProperty$1)$defineProperty$1(t,r,{configurable:a===null&&p?p.configurable:!a,enumerable:o===null&&p?p.enumerable:!o,value:s,writable:n===null&&p?p.writable:!n});else if(l||!o&&!n&&!a)t[r]=s;else throw new $SyntaxError("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},$defineProperty=esDefineProperty,hasPropertyDescriptors=function(){return!!$defineProperty};hasPropertyDescriptors.hasArrayLengthDefineBug=function(){if(!$defineProperty)return null;try{return $defineProperty([],"length",{value:1}).length!==1}catch{return!0}};var hasPropertyDescriptors_1=hasPropertyDescriptors,GetIntrinsic$1=getIntrinsic,define=defineDataProperty,hasDescriptors=hasPropertyDescriptors_1(),gOPD$1=gopd$1,$TypeError=type,$floor=GetIntrinsic$1("%Math.floor%"),setFunctionLength=function(t,r){if(typeof t!="function")throw new $TypeError("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||$floor(r)!==r)throw new $TypeError("`length` must be a positive 32-bit integer");var s=arguments.length>2&&!!arguments[2],o=!0,n=!0;if("length"in t&&gOPD$1){var a=gOPD$1(t,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(n=!1)}return(o||n||!s)&&(hasDescriptors?define(t,"length",r,!0,!0):define(t,"length",r)),t},bind=requireFunctionBind(),$apply=requireFunctionApply(),actualApply=actualApply$1,applyBind=function(){return actualApply(bind,$apply,arguments)};(function(e){var t=setFunctionLength,r=esDefineProperty,s=callBindApplyHelpers,o=applyBind;e.exports=function(a){var l=s(arguments),p=a.length-(arguments.length-1);return t(l,1+(p>0?p:0),!0)},r?r(e.exports,"apply",{value:o}):e.exports.apply=o})(callBind$2);var callBindExports=callBind$2.exports,forEach=forEach_1,availableTypedArrays=availableTypedArrays$1,callBind$1=callBindExports,callBound$2=callBound$4,gOPD=gopd$1,$toString=callBound$2("Object.prototype.toString"),hasToStringTag=shams(),g=typeof globalThis>"u"?commonjsGlobal:globalThis,typedArrays=availableTypedArrays(),$slice=callBound$2("String.prototype.slice"),getPrototypeOf=Object.getPrototypeOf,$indexOf$1=callBound$2("Array.prototype.indexOf",!0)||function(t,r){for(var s=0;s<t.length;s+=1)if(t[s]===r)return s;return-1},cache={__proto__:null};hasToStringTag&&gOPD&&getPrototypeOf?forEach(typedArrays,function(e){var t=new g[e];if(Symbol.toStringTag in t){var r=getPrototypeOf(t),s=gOPD(r,Symbol.toStringTag);if(!s){var o=getPrototypeOf(r);s=gOPD(o,Symbol.toStringTag)}cache["$"+e]=callBind$1(s.get)}}):forEach(typedArrays,function(e){var t=new g[e],r=t.slice||t.set;r&&(cache["$"+e]=callBind$1(r))});var tryTypedArrays=function(t){var r=!1;return forEach(cache,function(s,o){if(!r)try{"$"+s(t)===o&&(r=$slice(o,1))}catch{}}),r},trySlices=function(t){var r=!1;return forEach(cache,function(s,o){if(!r)try{s(t),r=$slice(o,1)}catch{}}),r},whichTypedArray$1=function(t){if(!t||typeof t!="object")return!1;if(!hasToStringTag){var r=$slice($toString(t),8,-1);return $indexOf$1(typedArrays,r)>-1?r:r!=="Object"?!1:trySlices(t)}return gOPD?tryTypedArrays(t):null},whichTypedArray=whichTypedArray$1,isTypedArray=function(t){return!!whichTypedArray(t)};(function(e){var t=isArguments$1,r=isGeneratorFunction,s=whichTypedArray$1,o=isTypedArray;function n($e){return $e.call.bind($e)}var a=typeof BigInt<"u",l=typeof Symbol<"u",p=n(Object.prototype.toString),u=n(Number.prototype.valueOf),c=n(String.prototype.valueOf),v=n(Boolean.prototype.valueOf);if(a)var w=n(BigInt.prototype.valueOf);if(l)var b=n(Symbol.prototype.valueOf);function E($e,Ue){if(typeof $e!="object")return!1;try{return Ue($e),!0}catch{return!1}}e.isArgumentsObject=t,e.isGeneratorFunction=r,e.isTypedArray=o;function I($e){return typeof Promise<"u"&&$e instanceof Promise||$e!==null&&typeof $e=="object"&&typeof $e.then=="function"&&typeof $e.catch=="function"}e.isPromise=I;function x($e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView($e):o($e)||J($e)}e.isArrayBufferView=x;function B($e){return s($e)==="Uint8Array"}e.isUint8Array=B;function M($e){return s($e)==="Uint8ClampedArray"}e.isUint8ClampedArray=M;function q($e){return s($e)==="Uint16Array"}e.isUint16Array=q;function U($e){return s($e)==="Uint32Array"}e.isUint32Array=U;function F($e){return s($e)==="Int8Array"}e.isInt8Array=F;function j($e){return s($e)==="Int16Array"}e.isInt16Array=j;function y($e){return s($e)==="Int32Array"}e.isInt32Array=y;function T($e){return s($e)==="Float32Array"}e.isFloat32Array=T;function D($e){return s($e)==="Float64Array"}e.isFloat64Array=D;function L($e){return s($e)==="BigInt64Array"}e.isBigInt64Array=L;function C($e){return s($e)==="BigUint64Array"}e.isBigUint64Array=C;function d($e){return p($e)==="[object Map]"}d.working=typeof Map<"u"&&d(new Map);function _($e){return typeof Map>"u"?!1:d.working?d($e):$e instanceof Map}e.isMap=_;function $($e){return p($e)==="[object Set]"}$.working=typeof Set<"u"&&$(new Set);function S($e){return typeof Set>"u"?!1:$.working?$($e):$e instanceof Set}e.isSet=S;function O($e){return p($e)==="[object WeakMap]"}O.working=typeof WeakMap<"u"&&O(new WeakMap);function N($e){return typeof WeakMap>"u"?!1:O.working?O($e):$e instanceof WeakMap}e.isWeakMap=N;function k($e){return p($e)==="[object WeakSet]"}k.working=typeof WeakSet<"u"&&k(new WeakSet);function A($e){return k($e)}e.isWeakSet=A;function m($e){return p($e)==="[object ArrayBuffer]"}m.working=typeof ArrayBuffer<"u"&&m(new ArrayBuffer);function P($e){return typeof ArrayBuffer>"u"?!1:m.working?m($e):$e instanceof ArrayBuffer}e.isArrayBuffer=P;function H($e){return p($e)==="[object DataView]"}H.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&H(new DataView(new ArrayBuffer(1),0,1));function J($e){return typeof DataView>"u"?!1:H.working?H($e):$e instanceof DataView}e.isDataView=J;var X=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function se($e){return p($e)==="[object SharedArrayBuffer]"}function ne($e){return typeof X>"u"?!1:(typeof se.working>"u"&&(se.working=se(new X)),se.working?se($e):$e instanceof X)}e.isSharedArrayBuffer=ne;function Z($e){return p($e)==="[object AsyncFunction]"}e.isAsyncFunction=Z;function oe($e){return p($e)==="[object Map Iterator]"}e.isMapIterator=oe;function ye($e){return p($e)==="[object Set Iterator]"}e.isSetIterator=ye;function Y($e){return p($e)==="[object Generator]"}e.isGeneratorObject=Y;function G($e){return p($e)==="[object WebAssembly.Module]"}e.isWebAssemblyCompiledModule=G;function V($e){return E($e,u)}e.isNumberObject=V;function te($e){return E($e,c)}e.isStringObject=te;function le($e){return E($e,v)}e.isBooleanObject=le;function me($e){return a&&E($e,w)}e.isBigIntObject=me;function Re($e){return l&&E($e,b)}e.isSymbolObject=Re;function Be($e){return V($e)||te($e)||le($e)||me($e)||Re($e)}e.isBoxedPrimitive=Be;function Ce($e){return typeof Uint8Array<"u"&&(P($e)||ne($e))}e.isAnyArrayBuffer=Ce,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function($e){Object.defineProperty(e,$e,{enumerable:!1,value:function(){throw new Error($e+" is not supported in userland")}})})})(types$l);var isBufferBrowser=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"};(function(e){var t=Object.getOwnPropertyDescriptors||function(J){for(var X=Object.keys(J),se={},ne=0;ne<X.length;ne++)se[X[ne]]=Object.getOwnPropertyDescriptor(J,X[ne]);return se},r=/%[sdj%]/g;e.format=function(H){if(!F(H)){for(var J=[],X=0;X<arguments.length;X++)J.push(a(arguments[X]));return J.join(" ")}for(var X=1,se=arguments,ne=se.length,Z=String(H).replace(r,function(ye){if(ye==="%%")return"%";if(X>=ne)return ye;switch(ye){case"%s":return String(se[X++]);case"%d":return Number(se[X++]);case"%j":try{return JSON.stringify(se[X++])}catch{return"[Circular]"}default:return ye}}),oe=se[X];X<ne;oe=se[++X])M(oe)||!D(oe)?Z+=" "+oe:Z+=" "+a(oe);return Z},e.deprecate=function(H,J){if(typeof process$1<"u"&&process$1.noDeprecation===!0)return H;if(typeof process$1>"u")return function(){return e.deprecate(H,J).apply(this,arguments)};var X=!1;function se(){if(!X){if(process$1.throwDeprecation)throw new Error(J);process$1.traceDeprecation?console.trace(J):console.error(J),X=!0}return H.apply(this,arguments)}return se};var s={},o=/^$/;if(process$1.env.NODE_DEBUG){var n=process$1.env.NODE_DEBUG;n=n.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),o=new RegExp("^"+n+"$","i")}e.debuglog=function(H){if(H=H.toUpperCase(),!s[H])if(o.test(H)){var J=process$1.pid;s[H]=function(){var X=e.format.apply(e,arguments);console.error("%s %d: %s",H,J,X)}}else s[H]=function(){};return s[H]};function a(H,J){var X={seen:[],stylize:p};return arguments.length>=3&&(X.depth=arguments[2]),arguments.length>=4&&(X.colors=arguments[3]),B(J)?X.showHidden=J:J&&e._extend(X,J),y(X.showHidden)&&(X.showHidden=!1),y(X.depth)&&(X.depth=2),y(X.colors)&&(X.colors=!1),y(X.customInspect)&&(X.customInspect=!0),X.colors&&(X.stylize=l),c(X,H,X.depth)}e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function l(H,J){var X=a.styles[J];return X?"\x1B["+a.colors[X][0]+"m"+H+"\x1B["+a.colors[X][1]+"m":H}function p(H,J){return H}function u(H){var J={};return H.forEach(function(X,se){J[X]=!0}),J}function c(H,J,X){if(H.customInspect&&J&&d(J.inspect)&&J.inspect!==e.inspect&&!(J.constructor&&J.constructor.prototype===J)){var se=J.inspect(X,H);return F(se)||(se=c(H,se,X)),se}var ne=v(H,J);if(ne)return ne;var Z=Object.keys(J),oe=u(Z);if(H.showHidden&&(Z=Object.getOwnPropertyNames(J)),C(J)&&(Z.indexOf("message")>=0||Z.indexOf("description")>=0))return w(J);if(Z.length===0){if(d(J)){var ye=J.name?": "+J.name:"";return H.stylize("[Function"+ye+"]","special")}if(T(J))return H.stylize(RegExp.prototype.toString.call(J),"regexp");if(L(J))return H.stylize(Date.prototype.toString.call(J),"date");if(C(J))return w(J)}var Y="",G=!1,V=["{","}"];if(x(J)&&(G=!0,V=["[","]"]),d(J)){var te=J.name?": "+J.name:"";Y=" [Function"+te+"]"}if(T(J)&&(Y=" "+RegExp.prototype.toString.call(J)),L(J)&&(Y=" "+Date.prototype.toUTCString.call(J)),C(J)&&(Y=" "+w(J)),Z.length===0&&(!G||J.length==0))return V[0]+Y+V[1];if(X<0)return T(J)?H.stylize(RegExp.prototype.toString.call(J),"regexp"):H.stylize("[Object]","special");H.seen.push(J);var le;return G?le=b(H,J,X,oe,Z):le=Z.map(function(me){return E(H,J,X,oe,me,G)}),H.seen.pop(),I(le,Y,V)}function v(H,J){if(y(J))return H.stylize("undefined","undefined");if(F(J)){var X="'"+JSON.stringify(J).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return H.stylize(X,"string")}if(U(J))return H.stylize(""+J,"number");if(B(J))return H.stylize(""+J,"boolean");if(M(J))return H.stylize("null","null")}function w(H){return"["+Error.prototype.toString.call(H)+"]"}function b(H,J,X,se,ne){for(var Z=[],oe=0,ye=J.length;oe<ye;++oe)k(J,String(oe))?Z.push(E(H,J,X,se,String(oe),!0)):Z.push("");return ne.forEach(function(Y){Y.match(/^\d+$/)||Z.push(E(H,J,X,se,Y,!0))}),Z}function E(H,J,X,se,ne,Z){var oe,ye,Y;if(Y=Object.getOwnPropertyDescriptor(J,ne)||{value:J[ne]},Y.get?Y.set?ye=H.stylize("[Getter/Setter]","special"):ye=H.stylize("[Getter]","special"):Y.set&&(ye=H.stylize("[Setter]","special")),k(se,ne)||(oe="["+ne+"]"),ye||(H.seen.indexOf(Y.value)<0?(M(X)?ye=c(H,Y.value,null):ye=c(H,Y.value,X-1),ye.indexOf(`
1
+ "use strict";var Nt=Object.defineProperty;var Ut=(e,t,r)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var at=(e,t,r)=>Ut(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),coreUi=require("@babylonlabs-io/core-ui"),tailwindMerge=require("tailwind-merge"),react=require("react"),btcStakingTs=require("@babylonlabs-io/btc-staking-ts"),sdk$1=require("@keystonehq/sdk"),bitcoinjsLib=require("bitcoinjs-lib");function WalletButton({className:e,disabled:t=!1,name:r,logo:s,label:o,fallbackLink:n,installed:a=!0,onClick:l}){const p=a?{as:"button",disabled:t,onClick:l}:{as:"a",href:n,target:"_blank"};return jsxRuntime.jsxs(coreUi.Text,{className:tailwindMerge.twMerge("flex h-14 w-full cursor-pointer items-center gap-2.5 rounded border border-secondary-strokeLight text-accent-primary px-2",t?"cursor-default":"cursor-pointer",e),...p,children:[jsxRuntime.jsx(coreUi.Avatar,{variant:"rounded",className:"shrink-0",alt:r,url:s}),r,o&&jsxRuntime.jsx(coreUi.Chip,{className:"ml-auto shrink-0",children:o})]})}class Wallet{constructor({id:t,origin:r,name:s,icon:o,docs:n,networks:a,provider:l,label:p}){at(this,"id");at(this,"origin");at(this,"name");at(this,"icon");at(this,"docs");at(this,"networks");at(this,"provider",null);at(this,"_label");at(this,"account",null);this.id=t,this.origin=r,this.name=s,this.icon=o,this.docs=n,this.networks=a,this.provider=l,this._label=p}get installed(){return!!this.provider}get label(){return this._label??(this.installed?"Installed":"")}async connect(){if(!this.provider)throw Error("Provider not found");await this.provider.connectWallet();const[t,r]=await Promise.all([this.provider.getAddress(),this.provider.getPublicKeyHex()]);return this.account={address:t,publicKeyHex:r},this}clone(){return new Wallet({id:this.id,origin:this.origin,name:this.name,icon:this.icon,docs:this.docs,networks:this.networks,provider:this.provider})}}let createNanoEvents=()=>({emit(e,...t){for(let r=this.events[e]||[],s=0,o=r.length;s<o;s++)r[s](...t)},events:{},on(e,t){var r;return((r=this.events)[e]||(r[e]=[])).push(t),()=>{var s;this.events[e]=(s=this.events[e])==null?void 0:s.filter(o=>t!==o)}}});class WalletConnector{constructor(t,r,s,o,n){at(this,"_connectedWallet",null);at(this,"_ee",createNanoEvents());this.id=t,this.name=r,this.icon=s,this.wallets=o,this.config=n}get connectedWallet(){return this._connectedWallet}async connect(t){try{const r=typeof t=="string"?this.wallets.find(s=>s.id===t):t;if(!r)throw new Error("Wallet not found");return this._ee.emit("connecting",`Connecting ${r.name}`),await r.connect(),this._connectedWallet=r,this._ee.emit("connect",this._connectedWallet),this.connectedWallet}catch(r){return this._ee.emit("error",r),null}}async disconnect(){this._connectedWallet&&(this._ee.emit("disconnect",this._connectedWallet),this._connectedWallet=null)}clone(){return new WalletConnector(this.id,this.name,this.icon,this.wallets,this.config)}on(t,r){return this._ee.on(t,r)}}var Network=(e=>(e.MAINNET="mainnet",e.CANARY="canary",e.TESTNET="testnet",e.SIGNET="signet",e))(Network||{});const defaultWalletGetter=e=>t=>t[e],createWallet=async({metadata:e,context:t,config:r})=>{const{id:s,wallet:o,name:n,icon:a,docs:l="",networks:p=[],createProvider:u,label:c}=e,v={id:s,name:"",icon:"",origin:null,provider:null,docs:l,networks:p,label:c};if(o){const w=typeof o=="string"?defaultWalletGetter(o):o;v.origin=w(t,r)??null,v.provider=v.origin?u(v.origin,r):null}else v.origin=null,v.provider=u(null,r);return typeof n=="string"?v.name=n??"":v.name=v.origin?await n(v.origin,r):"",typeof a=="string"?v.icon=a??"":v.icon=v.origin?await a(v.origin,r):"",new Wallet(v)},createExternalWallet=({id:e,name:t,icon:r,provider:s})=>new Wallet({id:e,origin:null,name:t,icon:r,docs:"",networks:[Network.MAINNET,Network.SIGNET],provider:s}),createWalletConnector=async({persistent:e,metadata:t,context:r,config:s,accountStorage:o})=>{const n=[],a=e?o.get(t.chain):void 0;for(const p of t.wallets)n.push(await createWallet({metadata:p,context:r,config:s}));const l=new WalletConnector(t.chain,t.name,t.icon,n,s);return a&&await l.connect(a),l},icon$1="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20800'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23ce6533;fill-rule:evenodd;}%3c/style%3e%3c/defs%3e%3cpath%20class='cls-1'%20d='M66.5,198.56c-3.27-8.85-1.09-18.79,5.58-25.47l90.82-90.82c6.67-6.67,16.62-8.85,25.46-5.59l193.65,71.14c4.76,1.75,7.92,6.28,7.92,11.35v42.4c0,3.21-1.27,6.28-3.54,8.55l-47.14,47.13c-3.33,3.34-8.3,4.43-12.73,2.79l-52.02-19.18-57.16-21.09c-4.83-1.79-9.55,2.92-7.76,7.76l40.27,109.18c1.63,4.43,.55,9.4-2.79,12.73l-41.91,41.89c-4.72,4.72-4.72,12.38,0,17.1l42.13,42.13c3.34,3.34,4.43,8.31,2.79,12.73l-40.27,109.17c-1.79,4.84,2.92,9.55,7.76,7.76l109.18-40.28c4.43-1.63,9.4-.54,12.73,2.79l46.91,46.91c2.27,2.27,3.54,5.34,3.54,8.55v42.41c0,5.06-3.15,9.59-7.9,11.34l-193.42,71.36c-8.85,3.27-18.8,1.08-25.47-5.59l-90.83-90.83c-6.67-6.67-8.85-16.61-5.58-25.47l71.11-192.77c1.99-5.4,1.99-11.34,0-16.74L66.5,198.56Z'/%3e%3cpath%20class='cls-1'%20d='M733.5,601.44c3.27,8.85,1.09,18.79-5.58,25.47l-90.82,90.83c-6.67,6.67-16.61,8.85-25.46,5.59l-193.65-71.14c-4.76-1.75-7.92-6.28-7.92-11.35v-42.4c0-3.21,1.27-6.28,3.54-8.55l47.14-47.13c3.33-3.34,8.3-4.43,12.73-2.79l52.02,19.18,57.16,21.09c4.83,1.79,9.54-2.92,7.76-7.76l-40.27-109.18c-1.63-4.43-.55-9.4,2.79-12.73l41.91-41.89c4.72-4.72,4.72-12.38,0-17.1l-42.13-42.13c-3.34-3.34-4.43-8.31-2.79-12.73l40.27-109.17c1.79-4.84-2.92-9.55-7.76-7.76l-109.18,40.28c-4.43,1.63-9.4,.54-12.73-2.79l-46.91-46.91c-2.27-2.27-3.54-5.34-3.54-8.55v-42.41c0-5.06,3.15-9.59,7.9-11.34l193.42-71.36c8.85-3.27,18.79-1.08,25.47,5.59l90.82,90.83c6.68,6.67,8.86,16.61,5.59,25.47l-71.11,192.77c-2,5.4-2,11.34,0,16.74l71.34,193.37h0Z'/%3e%3c/svg%3e",metadata$b={id:"injectable",name:e=>{var t;return(t=e.getWalletProviderName)==null?void 0:t.call(e)},icon:e=>{var t;return(t=e.getWalletProviderIcon)==null?void 0:t.call(e)},docs:"",wallet:"bbnwallet",createProvider:e=>e,networks:[Network.MAINNET,Network.SIGNET],label:"Injectable"},logo$6="data:image/svg+xml,%3csvg%20width='42'%20height='42'%20viewBox='0%200%2042%2042'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_425_5107)'%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint0_linear_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint1_radial_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint2_radial_425_5107)'/%3e%3cpath%20d='M32.4545%200H9.54545C4.27365%200%200%204.27365%200%209.54545V32.4545C0%2037.7264%204.27365%2042%209.54545%2042H32.4545C37.7264%2042%2042%2037.7264%2042%2032.4545V9.54545C42%204.27365%2037.7264%200%2032.4545%200Z'%20fill='url(%23paint3_radial_425_5107)'/%3e%3cpath%20d='M17.2526%2032.2614V22.5192L26.7185%2032.2614H31.9849V32.0079L21.0964%2020.9122L31.1469%2010.3857V10.2614H25.8464L17.2526%2019.5635V10.2614H12.9849V32.2614H17.2526Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_425_5107'%20x1='21'%20y1='0'%20x2='21'%20y2='42'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231FD1FF'/%3e%3cstop%20offset='1'%20stop-color='%231BB8FF'/%3e%3c/linearGradient%3e%3cradialGradient%20id='paint1_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(2.00623%2040.4086)%20rotate(-45.1556)%20scale(67.3547%2068.3624)'%3e%3cstop%20stop-color='%23232DE3'/%3e%3cstop%20offset='1'%20stop-color='%23232DE3'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint2_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(39.7379%2041.7602)%20rotate(-138.45)%20scale(42.1137%2064.2116)'%3e%3cstop%20stop-color='%238B4DFF'/%3e%3cstop%20offset='1'%20stop-color='%238B4DFF'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint3_radial_425_5107'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(20.6501%200.311498)%20rotate(90)%20scale(33.1135%2080.3423)'%3e%3cstop%20stop-color='%2324D5FF'/%3e%3cstop%20offset='1'%20stop-color='%231BB8FF'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cclipPath%20id='clip0_425_5107'%3e%3crect%20width='42'%20height='42'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";var buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$9=0,len=code.length;i$9<len;++i$9)lookup[i$9]=code[i$9],revLookup[code.charCodeAt(i$9)]=i$9;revLookup[45]=62;revLookup[95]=63;function getLens(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 s=r===t?0:4-r%4;return[r,s]}function byteLength(e){var t=getLens(e),r=t[0],s=t[1];return(r+s)*3/4-s}function _byteLength(e,t,r){return(t+r)*3/4-r}function toByteArray(e){var t,r=getLens(e),s=r[0],o=r[1],n=new Arr(_byteLength(e,s,o)),a=0,l=o>0?s-4:s,p;for(p=0;p<l;p+=4)t=revLookup[e.charCodeAt(p)]<<18|revLookup[e.charCodeAt(p+1)]<<12|revLookup[e.charCodeAt(p+2)]<<6|revLookup[e.charCodeAt(p+3)],n[a++]=t>>16&255,n[a++]=t>>8&255,n[a++]=t&255;return o===2&&(t=revLookup[e.charCodeAt(p)]<<2|revLookup[e.charCodeAt(p+1)]>>4,n[a++]=t&255),o===1&&(t=revLookup[e.charCodeAt(p)]<<10|revLookup[e.charCodeAt(p+1)]<<4|revLookup[e.charCodeAt(p+2)]>>2,n[a++]=t>>8&255,n[a++]=t&255),n}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){for(var s,o=[],n=t;n<r;n+=3)s=(e[n]<<16&16711680)+(e[n+1]<<8&65280)+(e[n+2]&255),o.push(tripletToBase64(s));return o.join("")}function fromByteArray(e){for(var t,r=e.length,s=r%3,o=[],n=16383,a=0,l=r-s;a<l;a+=n)o.push(encodeChunk(e,a,a+n>l?l:a+n));return s===1?(t=e[r-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):s===2&&(t=(e[r-2]<<8)+e[r-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}var ieee754={};ieee754.read=function(e,t,r,s,o){var n,a,l=o*8-s-1,p=(1<<l)-1,u=p>>1,c=-7,v=r?o-1:0,w=r?-1:1,b=e[t+v];for(v+=w,n=b&(1<<-c)-1,b>>=-c,c+=l;c>0;n=n*256+e[t+v],v+=w,c-=8);for(a=n&(1<<-c)-1,n>>=-c,c+=s;c>0;a=a*256+e[t+v],v+=w,c-=8);if(n===0)n=1-u;else{if(n===p)return a?NaN:(b?-1:1)*(1/0);a=a+Math.pow(2,s),n=n-u}return(b?-1:1)*a*Math.pow(2,n-s)};ieee754.write=function(e,t,r,s,o,n){var a,l,p,u=n*8-o-1,c=(1<<u)-1,v=c>>1,w=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=s?0:n-1,E=s?1:-1,I=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-a))<1&&(a--,p*=2),a+v>=1?t+=w/p:t+=w*Math.pow(2,1-v),t*p>=2&&(a++,p/=2),a+v>=c?(l=0,a=c):a+v>=1?(l=(t*p-1)*Math.pow(2,o),a=a+v):(l=t*Math.pow(2,v-1)*Math.pow(2,o),a=0));o>=8;e[r+b]=l&255,b+=E,l/=256,o-=8);for(a=a<<o|l,u+=o;u>0;e[r+b]=a&255,b+=E,a/=256,u-=8);e[r+b-E]|=I*128};(function(e){const t=base64Js,r=ieee754,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=F,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o;const{Uint8Array:n,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;c.TYPED_ARRAY_SUPPORT=p(),!c.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 p(){try{const re=new n(1),z={foo:function(){return 42}};return Object.setPrototypeOf(z,n.prototype),Object.setPrototypeOf(re,z),re.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function u(re){if(re>o)throw new RangeError('The value "'+re+'" is invalid for option "size"');const z=new n(re);return Object.setPrototypeOf(z,c.prototype),z}function c(re,z,Q){if(typeof re=="number"){if(typeof z=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(re)}return v(re,z,Q)}c.poolSize=8192;function v(re,z,Q){if(typeof re=="string")return I(re,z);if(a.isView(re))return B(re);if(re==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re);if(xe(re,a)||re&&xe(re.buffer,a)||typeof l<"u"&&(xe(re,l)||re&&xe(re.buffer,l)))return M(re,z,Q);if(typeof re=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const ue=re.valueOf&&re.valueOf();if(ue!=null&&ue!==re)return c.from(ue,z,Q);const we=q(re);if(we)return we;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof re[Symbol.toPrimitive]=="function")return c.from(re[Symbol.toPrimitive]("string"),z,Q);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof re)}c.from=function(re,z,Q){return v(re,z,Q)},Object.setPrototypeOf(c.prototype,n.prototype),Object.setPrototypeOf(c,n);function w(re){if(typeof re!="number")throw new TypeError('"size" argument must be of type number');if(re<0)throw new RangeError('The value "'+re+'" is invalid for option "size"')}function b(re,z,Q){return w(re),re<=0?u(re):z!==void 0?typeof Q=="string"?u(re).fill(z,Q):u(re).fill(z):u(re)}c.alloc=function(re,z,Q){return b(re,z,Q)};function E(re){return w(re),u(re<0?0:U(re)|0)}c.allocUnsafe=function(re){return E(re)},c.allocUnsafeSlow=function(re){return E(re)};function I(re,z){if((typeof z!="string"||z==="")&&(z="utf8"),!c.isEncoding(z))throw new TypeError("Unknown encoding: "+z);const Q=j(re,z)|0;let ue=u(Q);const we=ue.write(re,z);return we!==Q&&(ue=ue.slice(0,we)),ue}function x(re){const z=re.length<0?0:U(re.length)|0,Q=u(z);for(let ue=0;ue<z;ue+=1)Q[ue]=re[ue]&255;return Q}function B(re){if(xe(re,n)){const z=new n(re);return M(z.buffer,z.byteOffset,z.byteLength)}return x(re)}function M(re,z,Q){if(z<0||re.byteLength<z)throw new RangeError('"offset" is outside of buffer bounds');if(re.byteLength<z+(Q||0))throw new RangeError('"length" is outside of buffer bounds');let ue;return z===void 0&&Q===void 0?ue=new n(re):Q===void 0?ue=new n(re,z):ue=new n(re,z,Q),Object.setPrototypeOf(ue,c.prototype),ue}function q(re){if(c.isBuffer(re)){const z=U(re.length)|0,Q=u(z);return Q.length===0||re.copy(Q,0,0,z),Q}if(re.length!==void 0)return typeof re.length!="number"||he(re.length)?u(0):x(re);if(re.type==="Buffer"&&Array.isArray(re.data))return x(re.data)}function U(re){if(re>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return re|0}function F(re){return+re!=re&&(re=0),c.alloc(+re)}c.isBuffer=function(z){return z!=null&&z._isBuffer===!0&&z!==c.prototype},c.compare=function(z,Q){if(xe(z,n)&&(z=c.from(z,z.offset,z.byteLength)),xe(Q,n)&&(Q=c.from(Q,Q.offset,Q.byteLength)),!c.isBuffer(z)||!c.isBuffer(Q))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(z===Q)return 0;let ue=z.length,we=Q.length;for(let Ne=0,De=Math.min(ue,we);Ne<De;++Ne)if(z[Ne]!==Q[Ne]){ue=z[Ne],we=Q[Ne];break}return ue<we?-1:we<ue?1:0},c.isEncoding=function(z){switch(String(z).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}},c.concat=function(z,Q){if(!Array.isArray(z))throw new TypeError('"list" argument must be an Array of Buffers');if(z.length===0)return c.alloc(0);let ue;if(Q===void 0)for(Q=0,ue=0;ue<z.length;++ue)Q+=z[ue].length;const we=c.allocUnsafe(Q);let Ne=0;for(ue=0;ue<z.length;++ue){let De=z[ue];if(xe(De,n))Ne+De.length>we.length?(c.isBuffer(De)||(De=c.from(De)),De.copy(we,Ne)):n.prototype.set.call(we,De,Ne);else if(c.isBuffer(De))De.copy(we,Ne);else throw new TypeError('"list" argument must be an Array of Buffers');Ne+=De.length}return we};function j(re,z){if(c.isBuffer(re))return re.length;if(a.isView(re)||xe(re,a))return re.byteLength;if(typeof re!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof re);const Q=re.length,ue=arguments.length>2&&arguments[2]===!0;if(!ue&&Q===0)return 0;let we=!1;for(;;)switch(z){case"ascii":case"latin1":case"binary":return Q;case"utf8":case"utf-8":return Ue(re).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q*2;case"hex":return Q>>>1;case"base64":return tt(re).length;default:if(we)return ue?-1:Ue(re).length;z=(""+z).toLowerCase(),we=!0}}c.byteLength=j;function y(re,z,Q){let ue=!1;if((z===void 0||z<0)&&(z=0),z>this.length||((Q===void 0||Q>this.length)&&(Q=this.length),Q<=0)||(Q>>>=0,z>>>=0,Q<=z))return"";for(re||(re="utf8");;)switch(re){case"hex":return H(this,z,Q);case"utf8":case"utf-8":return N(this,z,Q);case"ascii":return m(this,z,Q);case"latin1":case"binary":return P(this,z,Q);case"base64":return O(this,z,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J(this,z,Q);default:if(ue)throw new TypeError("Unknown encoding: "+re);re=(re+"").toLowerCase(),ue=!0}}c.prototype._isBuffer=!0;function T(re,z,Q){const ue=re[z];re[z]=re[Q],re[Q]=ue}c.prototype.swap16=function(){const z=this.length;if(z%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let Q=0;Q<z;Q+=2)T(this,Q,Q+1);return this},c.prototype.swap32=function(){const z=this.length;if(z%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let Q=0;Q<z;Q+=4)T(this,Q,Q+3),T(this,Q+1,Q+2);return this},c.prototype.swap64=function(){const z=this.length;if(z%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let Q=0;Q<z;Q+=8)T(this,Q,Q+7),T(this,Q+1,Q+6),T(this,Q+2,Q+5),T(this,Q+3,Q+4);return this},c.prototype.toString=function(){const z=this.length;return z===0?"":arguments.length===0?N(this,0,z):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(z){if(!c.isBuffer(z))throw new TypeError("Argument must be a Buffer");return this===z?!0:c.compare(this,z)===0},c.prototype.inspect=function(){let z="";const Q=e.INSPECT_MAX_BYTES;return z=this.toString("hex",0,Q).replace(/(.{2})/g,"$1 ").trim(),this.length>Q&&(z+=" ... "),"<Buffer "+z+">"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(z,Q,ue,we,Ne){if(xe(z,n)&&(z=c.from(z,z.offset,z.byteLength)),!c.isBuffer(z))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof z);if(Q===void 0&&(Q=0),ue===void 0&&(ue=z?z.length:0),we===void 0&&(we=0),Ne===void 0&&(Ne=this.length),Q<0||ue>z.length||we<0||Ne>this.length)throw new RangeError("out of range index");if(we>=Ne&&Q>=ue)return 0;if(we>=Ne)return-1;if(Q>=ue)return 1;if(Q>>>=0,ue>>>=0,we>>>=0,Ne>>>=0,this===z)return 0;let De=Ne-we,je=ue-Q;const ot=Math.min(De,je),He=this.slice(we,Ne),We=z.slice(Q,ue);for(let ht=0;ht<ot;++ht)if(He[ht]!==We[ht]){De=He[ht],je=We[ht];break}return De<je?-1:je<De?1:0};function D(re,z,Q,ue,we){if(re.length===0)return-1;if(typeof Q=="string"?(ue=Q,Q=0):Q>2147483647?Q=2147483647:Q<-2147483648&&(Q=-2147483648),Q=+Q,he(Q)&&(Q=we?0:re.length-1),Q<0&&(Q=re.length+Q),Q>=re.length){if(we)return-1;Q=re.length-1}else if(Q<0)if(we)Q=0;else return-1;if(typeof z=="string"&&(z=c.from(z,ue)),c.isBuffer(z))return z.length===0?-1:L(re,z,Q,ue,we);if(typeof z=="number")return z=z&255,typeof n.prototype.indexOf=="function"?we?n.prototype.indexOf.call(re,z,Q):n.prototype.lastIndexOf.call(re,z,Q):L(re,[z],Q,ue,we);throw new TypeError("val must be string, number or Buffer")}function L(re,z,Q,ue,we){let Ne=1,De=re.length,je=z.length;if(ue!==void 0&&(ue=String(ue).toLowerCase(),ue==="ucs2"||ue==="ucs-2"||ue==="utf16le"||ue==="utf-16le")){if(re.length<2||z.length<2)return-1;Ne=2,De/=2,je/=2,Q/=2}function ot(We,ht){return Ne===1?We[ht]:We.readUInt16BE(ht*Ne)}let He;if(we){let We=-1;for(He=Q;He<De;He++)if(ot(re,He)===ot(z,We===-1?0:He-We)){if(We===-1&&(We=He),He-We+1===je)return We*Ne}else We!==-1&&(He-=He-We),We=-1}else for(Q+je>De&&(Q=De-je),He=Q;He>=0;He--){let We=!0;for(let ht=0;ht<je;ht++)if(ot(re,He+ht)!==ot(z,ht)){We=!1;break}if(We)return He}return-1}c.prototype.includes=function(z,Q,ue){return this.indexOf(z,Q,ue)!==-1},c.prototype.indexOf=function(z,Q,ue){return D(this,z,Q,ue,!0)},c.prototype.lastIndexOf=function(z,Q,ue){return D(this,z,Q,ue,!1)};function C(re,z,Q,ue){Q=Number(Q)||0;const we=re.length-Q;ue?(ue=Number(ue),ue>we&&(ue=we)):ue=we;const Ne=z.length;ue>Ne/2&&(ue=Ne/2);let De;for(De=0;De<ue;++De){const je=parseInt(z.substr(De*2,2),16);if(he(je))return De;re[Q+De]=je}return De}function d(re,z,Q,ue){return Ie(Ue(z,re.length-Q),re,Q,ue)}function _(re,z,Q,ue){return Ie(Me(z),re,Q,ue)}function $(re,z,Q,ue){return Ie(tt(z),re,Q,ue)}function S(re,z,Q,ue){return Ie(ke(z,re.length-Q),re,Q,ue)}c.prototype.write=function(z,Q,ue,we){if(Q===void 0)we="utf8",ue=this.length,Q=0;else if(ue===void 0&&typeof Q=="string")we=Q,ue=this.length,Q=0;else if(isFinite(Q))Q=Q>>>0,isFinite(ue)?(ue=ue>>>0,we===void 0&&(we="utf8")):(we=ue,ue=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Ne=this.length-Q;if((ue===void 0||ue>Ne)&&(ue=Ne),z.length>0&&(ue<0||Q<0)||Q>this.length)throw new RangeError("Attempt to write outside buffer bounds");we||(we="utf8");let De=!1;for(;;)switch(we){case"hex":return C(this,z,Q,ue);case"utf8":case"utf-8":return d(this,z,Q,ue);case"ascii":case"latin1":case"binary":return _(this,z,Q,ue);case"base64":return $(this,z,Q,ue);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,z,Q,ue);default:if(De)throw new TypeError("Unknown encoding: "+we);we=(""+we).toLowerCase(),De=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(re,z,Q){return z===0&&Q===re.length?t.fromByteArray(re):t.fromByteArray(re.slice(z,Q))}function N(re,z,Q){Q=Math.min(re.length,Q);const ue=[];let we=z;for(;we<Q;){const Ne=re[we];let De=null,je=Ne>239?4:Ne>223?3:Ne>191?2:1;if(we+je<=Q){let ot,He,We,ht;switch(je){case 1:Ne<128&&(De=Ne);break;case 2:ot=re[we+1],(ot&192)===128&&(ht=(Ne&31)<<6|ot&63,ht>127&&(De=ht));break;case 3:ot=re[we+1],He=re[we+2],(ot&192)===128&&(He&192)===128&&(ht=(Ne&15)<<12|(ot&63)<<6|He&63,ht>2047&&(ht<55296||ht>57343)&&(De=ht));break;case 4:ot=re[we+1],He=re[we+2],We=re[we+3],(ot&192)===128&&(He&192)===128&&(We&192)===128&&(ht=(Ne&15)<<18|(ot&63)<<12|(He&63)<<6|We&63,ht>65535&&ht<1114112&&(De=ht))}}De===null?(De=65533,je=1):De>65535&&(De-=65536,ue.push(De>>>10&1023|55296),De=56320|De&1023),ue.push(De),we+=je}return A(ue)}const k=4096;function A(re){const z=re.length;if(z<=k)return String.fromCharCode.apply(String,re);let Q="",ue=0;for(;ue<z;)Q+=String.fromCharCode.apply(String,re.slice(ue,ue+=k));return Q}function m(re,z,Q){let ue="";Q=Math.min(re.length,Q);for(let we=z;we<Q;++we)ue+=String.fromCharCode(re[we]&127);return ue}function P(re,z,Q){let ue="";Q=Math.min(re.length,Q);for(let we=z;we<Q;++we)ue+=String.fromCharCode(re[we]);return ue}function H(re,z,Q){const ue=re.length;(!z||z<0)&&(z=0),(!Q||Q<0||Q>ue)&&(Q=ue);let we="";for(let Ne=z;Ne<Q;++Ne)we+=ae[re[Ne]];return we}function J(re,z,Q){const ue=re.slice(z,Q);let we="";for(let Ne=0;Ne<ue.length-1;Ne+=2)we+=String.fromCharCode(ue[Ne]+ue[Ne+1]*256);return we}c.prototype.slice=function(z,Q){const ue=this.length;z=~~z,Q=Q===void 0?ue:~~Q,z<0?(z+=ue,z<0&&(z=0)):z>ue&&(z=ue),Q<0?(Q+=ue,Q<0&&(Q=0)):Q>ue&&(Q=ue),Q<z&&(Q=z);const we=this.subarray(z,Q);return Object.setPrototypeOf(we,c.prototype),we};function X(re,z,Q){if(re%1!==0||re<0)throw new RangeError("offset is not uint");if(re+z>Q)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z],Ne=1,De=0;for(;++De<Q&&(Ne*=256);)we+=this[z+De]*Ne;return we},c.prototype.readUintBE=c.prototype.readUIntBE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z+--Q],Ne=1;for(;Q>0&&(Ne*=256);)we+=this[z+--Q]*Ne;return we},c.prototype.readUint8=c.prototype.readUInt8=function(z,Q){return z=z>>>0,Q||X(z,1,this.length),this[z]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(z,Q){return z=z>>>0,Q||X(z,2,this.length),this[z]|this[z+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(z,Q){return z=z>>>0,Q||X(z,2,this.length),this[z]<<8|this[z+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),(this[z]|this[z+1]<<8|this[z+2]<<16)+this[z+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]*16777216+(this[z+1]<<16|this[z+2]<<8|this[z+3])},c.prototype.readBigUInt64LE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=Q+this[++z]*2**8+this[++z]*2**16+this[++z]*2**24,Ne=this[++z]+this[++z]*2**8+this[++z]*2**16+ue*2**24;return BigInt(we)+(BigInt(Ne)<<BigInt(32))}),c.prototype.readBigUInt64BE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=Q*2**24+this[++z]*2**16+this[++z]*2**8+this[++z],Ne=this[++z]*2**24+this[++z]*2**16+this[++z]*2**8+ue;return(BigInt(we)<<BigInt(32))+BigInt(Ne)}),c.prototype.readIntLE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=this[z],Ne=1,De=0;for(;++De<Q&&(Ne*=256);)we+=this[z+De]*Ne;return Ne*=128,we>=Ne&&(we-=Math.pow(2,8*Q)),we},c.prototype.readIntBE=function(z,Q,ue){z=z>>>0,Q=Q>>>0,ue||X(z,Q,this.length);let we=Q,Ne=1,De=this[z+--we];for(;we>0&&(Ne*=256);)De+=this[z+--we]*Ne;return Ne*=128,De>=Ne&&(De-=Math.pow(2,8*Q)),De},c.prototype.readInt8=function(z,Q){return z=z>>>0,Q||X(z,1,this.length),this[z]&128?(255-this[z]+1)*-1:this[z]},c.prototype.readInt16LE=function(z,Q){z=z>>>0,Q||X(z,2,this.length);const ue=this[z]|this[z+1]<<8;return ue&32768?ue|4294901760:ue},c.prototype.readInt16BE=function(z,Q){z=z>>>0,Q||X(z,2,this.length);const ue=this[z+1]|this[z]<<8;return ue&32768?ue|4294901760:ue},c.prototype.readInt32LE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]|this[z+1]<<8|this[z+2]<<16|this[z+3]<<24},c.prototype.readInt32BE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),this[z]<<24|this[z+1]<<16|this[z+2]<<8|this[z+3]},c.prototype.readBigInt64LE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=this[z+4]+this[z+5]*2**8+this[z+6]*2**16+(ue<<24);return(BigInt(we)<<BigInt(32))+BigInt(Q+this[++z]*2**8+this[++z]*2**16+this[++z]*2**24)}),c.prototype.readBigInt64BE=be(function(z){z=z>>>0,Re(z,"offset");const Q=this[z],ue=this[z+7];(Q===void 0||ue===void 0)&&Be(z,this.length-8);const we=(Q<<24)+this[++z]*2**16+this[++z]*2**8+this[++z];return(BigInt(we)<<BigInt(32))+BigInt(this[++z]*2**24+this[++z]*2**16+this[++z]*2**8+ue)}),c.prototype.readFloatLE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),r.read(this,z,!0,23,4)},c.prototype.readFloatBE=function(z,Q){return z=z>>>0,Q||X(z,4,this.length),r.read(this,z,!1,23,4)},c.prototype.readDoubleLE=function(z,Q){return z=z>>>0,Q||X(z,8,this.length),r.read(this,z,!0,52,8)},c.prototype.readDoubleBE=function(z,Q){return z=z>>>0,Q||X(z,8,this.length),r.read(this,z,!1,52,8)};function se(re,z,Q,ue,we,Ne){if(!c.isBuffer(re))throw new TypeError('"buffer" argument must be a Buffer instance');if(z>we||z<Ne)throw new RangeError('"value" argument is out of bounds');if(Q+ue>re.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,ue=ue>>>0,!we){const je=Math.pow(2,8*ue)-1;se(this,z,Q,ue,je,0)}let Ne=1,De=0;for(this[Q]=z&255;++De<ue&&(Ne*=256);)this[Q+De]=z/Ne&255;return Q+ue},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,ue=ue>>>0,!we){const je=Math.pow(2,8*ue)-1;se(this,z,Q,ue,je,0)}let Ne=ue-1,De=1;for(this[Q+Ne]=z&255;--Ne>=0&&(De*=256);)this[Q+Ne]=z/De&255;return Q+ue},c.prototype.writeUint8=c.prototype.writeUInt8=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,1,255,0),this[Q]=z&255,Q+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,65535,0),this[Q]=z&255,this[Q+1]=z>>>8,Q+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,65535,0),this[Q]=z>>>8,this[Q+1]=z&255,Q+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,4294967295,0),this[Q+3]=z>>>24,this[Q+2]=z>>>16,this[Q+1]=z>>>8,this[Q]=z&255,Q+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,4294967295,0),this[Q]=z>>>24,this[Q+1]=z>>>16,this[Q+2]=z>>>8,this[Q+3]=z&255,Q+4};function ne(re,z,Q,ue,we){me(z,ue,we,re,Q,7);let Ne=Number(z&BigInt(4294967295));re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne,Ne=Ne>>8,re[Q++]=Ne;let De=Number(z>>BigInt(32)&BigInt(4294967295));return re[Q++]=De,De=De>>8,re[Q++]=De,De=De>>8,re[Q++]=De,De=De>>8,re[Q++]=De,Q}function Z(re,z,Q,ue,we){me(z,ue,we,re,Q,7);let Ne=Number(z&BigInt(4294967295));re[Q+7]=Ne,Ne=Ne>>8,re[Q+6]=Ne,Ne=Ne>>8,re[Q+5]=Ne,Ne=Ne>>8,re[Q+4]=Ne;let De=Number(z>>BigInt(32)&BigInt(4294967295));return re[Q+3]=De,De=De>>8,re[Q+2]=De,De=De>>8,re[Q+1]=De,De=De>>8,re[Q]=De,Q+8}c.prototype.writeBigUInt64LE=be(function(z,Q=0){return ne(this,z,Q,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=be(function(z,Q=0){return Z(this,z,Q,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,!we){const ot=Math.pow(2,8*ue-1);se(this,z,Q,ue,ot-1,-ot)}let Ne=0,De=1,je=0;for(this[Q]=z&255;++Ne<ue&&(De*=256);)z<0&&je===0&&this[Q+Ne-1]!==0&&(je=1),this[Q+Ne]=(z/De>>0)-je&255;return Q+ue},c.prototype.writeIntBE=function(z,Q,ue,we){if(z=+z,Q=Q>>>0,!we){const ot=Math.pow(2,8*ue-1);se(this,z,Q,ue,ot-1,-ot)}let Ne=ue-1,De=1,je=0;for(this[Q+Ne]=z&255;--Ne>=0&&(De*=256);)z<0&&je===0&&this[Q+Ne+1]!==0&&(je=1),this[Q+Ne]=(z/De>>0)-je&255;return Q+ue},c.prototype.writeInt8=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,1,127,-128),z<0&&(z=255+z+1),this[Q]=z&255,Q+1},c.prototype.writeInt16LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,32767,-32768),this[Q]=z&255,this[Q+1]=z>>>8,Q+2},c.prototype.writeInt16BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,2,32767,-32768),this[Q]=z>>>8,this[Q+1]=z&255,Q+2},c.prototype.writeInt32LE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,2147483647,-2147483648),this[Q]=z&255,this[Q+1]=z>>>8,this[Q+2]=z>>>16,this[Q+3]=z>>>24,Q+4},c.prototype.writeInt32BE=function(z,Q,ue){return z=+z,Q=Q>>>0,ue||se(this,z,Q,4,2147483647,-2147483648),z<0&&(z=4294967295+z+1),this[Q]=z>>>24,this[Q+1]=z>>>16,this[Q+2]=z>>>8,this[Q+3]=z&255,Q+4},c.prototype.writeBigInt64LE=be(function(z,Q=0){return ne(this,z,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=be(function(z,Q=0){return Z(this,z,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function oe(re,z,Q,ue,we,Ne){if(Q+ue>re.length)throw new RangeError("Index out of range");if(Q<0)throw new RangeError("Index out of range")}function ye(re,z,Q,ue,we){return z=+z,Q=Q>>>0,we||oe(re,z,Q,4),r.write(re,z,Q,ue,23,4),Q+4}c.prototype.writeFloatLE=function(z,Q,ue){return ye(this,z,Q,!0,ue)},c.prototype.writeFloatBE=function(z,Q,ue){return ye(this,z,Q,!1,ue)};function Y(re,z,Q,ue,we){return z=+z,Q=Q>>>0,we||oe(re,z,Q,8),r.write(re,z,Q,ue,52,8),Q+8}c.prototype.writeDoubleLE=function(z,Q,ue){return Y(this,z,Q,!0,ue)},c.prototype.writeDoubleBE=function(z,Q,ue){return Y(this,z,Q,!1,ue)},c.prototype.copy=function(z,Q,ue,we){if(!c.isBuffer(z))throw new TypeError("argument should be a Buffer");if(ue||(ue=0),!we&&we!==0&&(we=this.length),Q>=z.length&&(Q=z.length),Q||(Q=0),we>0&&we<ue&&(we=ue),we===ue||z.length===0||this.length===0)return 0;if(Q<0)throw new RangeError("targetStart out of bounds");if(ue<0||ue>=this.length)throw new RangeError("Index out of range");if(we<0)throw new RangeError("sourceEnd out of bounds");we>this.length&&(we=this.length),z.length-Q<we-ue&&(we=z.length-Q+ue);const Ne=we-ue;return this===z&&typeof n.prototype.copyWithin=="function"?this.copyWithin(Q,ue,we):n.prototype.set.call(z,this.subarray(ue,we),Q),Ne},c.prototype.fill=function(z,Q,ue,we){if(typeof z=="string"){if(typeof Q=="string"?(we=Q,Q=0,ue=this.length):typeof ue=="string"&&(we=ue,ue=this.length),we!==void 0&&typeof we!="string")throw new TypeError("encoding must be a string");if(typeof we=="string"&&!c.isEncoding(we))throw new TypeError("Unknown encoding: "+we);if(z.length===1){const De=z.charCodeAt(0);(we==="utf8"&&De<128||we==="latin1")&&(z=De)}}else typeof z=="number"?z=z&255:typeof z=="boolean"&&(z=Number(z));if(Q<0||this.length<Q||this.length<ue)throw new RangeError("Out of range index");if(ue<=Q)return this;Q=Q>>>0,ue=ue===void 0?this.length:ue>>>0,z||(z=0);let Ne;if(typeof z=="number")for(Ne=Q;Ne<ue;++Ne)this[Ne]=z;else{const De=c.isBuffer(z)?z:c.from(z,we),je=De.length;if(je===0)throw new TypeError('The value "'+z+'" is invalid for argument "value"');for(Ne=0;Ne<ue-Q;++Ne)this[Ne+Q]=De[Ne%je]}return this};const G={};function V(re,z,Q){G[re]=class extends Q{constructor(){super(),Object.defineProperty(this,"message",{value:z.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${re}]`,this.stack,delete this.name}get code(){return re}set code(we){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:we,writable:!0})}toString(){return`${this.name} [${re}]: ${this.message}`}}}V("ERR_BUFFER_OUT_OF_BOUNDS",function(re){return re?`${re} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),V("ERR_INVALID_ARG_TYPE",function(re,z){return`The "${re}" argument must be of type number. Received type ${typeof z}`},TypeError),V("ERR_OUT_OF_RANGE",function(re,z,Q){let ue=`The value of "${re}" is out of range.`,we=Q;return Number.isInteger(Q)&&Math.abs(Q)>2**32?we=te(String(Q)):typeof Q=="bigint"&&(we=String(Q),(Q>BigInt(2)**BigInt(32)||Q<-(BigInt(2)**BigInt(32)))&&(we=te(we)),we+="n"),ue+=` It must be ${z}. Received ${we}`,ue},RangeError);function te(re){let z="",Q=re.length;const ue=re[0]==="-"?1:0;for(;Q>=ue+4;Q-=3)z=`_${re.slice(Q-3,Q)}${z}`;return`${re.slice(0,Q)}${z}`}function le(re,z,Q){Re(z,"offset"),(re[z]===void 0||re[z+Q]===void 0)&&Be(z,re.length-(Q+1))}function me(re,z,Q,ue,we,Ne){if(re>Q||re<z){const De=typeof z=="bigint"?"n":"";let je;throw z===0||z===BigInt(0)?je=`>= 0${De} and < 2${De} ** ${(Ne+1)*8}${De}`:je=`>= -(2${De} ** ${(Ne+1)*8-1}${De}) and < 2 ** ${(Ne+1)*8-1}${De}`,new G.ERR_OUT_OF_RANGE("value",je,re)}le(ue,we,Ne)}function Re(re,z){if(typeof re!="number")throw new G.ERR_INVALID_ARG_TYPE(z,"number",re)}function Be(re,z,Q){throw Math.floor(re)!==re?(Re(re,Q),new G.ERR_OUT_OF_RANGE("offset","an integer",re)):z<0?new G.ERR_BUFFER_OUT_OF_BOUNDS:new G.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${z}`,re)}const Ce=/[^+/0-9A-Za-z-_]/g;function $e(re){if(re=re.split("=")[0],re=re.trim().replace(Ce,""),re.length<2)return"";for(;re.length%4!==0;)re=re+"=";return re}function Ue(re,z){z=z||1/0;let Q;const ue=re.length;let we=null;const Ne=[];for(let De=0;De<ue;++De){if(Q=re.charCodeAt(De),Q>55295&&Q<57344){if(!we){if(Q>56319){(z-=3)>-1&&Ne.push(239,191,189);continue}else if(De+1===ue){(z-=3)>-1&&Ne.push(239,191,189);continue}we=Q;continue}if(Q<56320){(z-=3)>-1&&Ne.push(239,191,189),we=Q;continue}Q=(we-55296<<10|Q-56320)+65536}else we&&(z-=3)>-1&&Ne.push(239,191,189);if(we=null,Q<128){if((z-=1)<0)break;Ne.push(Q)}else if(Q<2048){if((z-=2)<0)break;Ne.push(Q>>6|192,Q&63|128)}else if(Q<65536){if((z-=3)<0)break;Ne.push(Q>>12|224,Q>>6&63|128,Q&63|128)}else if(Q<1114112){if((z-=4)<0)break;Ne.push(Q>>18|240,Q>>12&63|128,Q>>6&63|128,Q&63|128)}else throw new Error("Invalid code point")}return Ne}function Me(re){const z=[];for(let Q=0;Q<re.length;++Q)z.push(re.charCodeAt(Q)&255);return z}function ke(re,z){let Q,ue,we;const Ne=[];for(let De=0;De<re.length&&!((z-=2)<0);++De)Q=re.charCodeAt(De),ue=Q>>8,we=Q%256,Ne.push(we),Ne.push(ue);return Ne}function tt(re){return t.toByteArray($e(re))}function Ie(re,z,Q,ue){let we;for(we=0;we<ue&&!(we+Q>=z.length||we>=re.length);++we)z[we+Q]=re[we];return we}function xe(re,z){return re instanceof z||re!=null&&re.constructor!=null&&re.constructor.name!=null&&re.constructor.name===z.name}function he(re){return re!==re}const ae=function(){const re="0123456789abcdef",z=new Array(256);for(let Q=0;Q<16;++Q){const ue=Q*16;for(let we=0;we<16;++we)z[ue+we]=re[Q]+re[we]}return z}();function be(re){return typeof BigInt>"u"?Ae:re}function Ae(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer$e=buffer$1.Buffer,Blob$1=buffer$1.Blob,BlobOptions=buffer$1.BlobOptions,Buffer$1$1=buffer$1.Buffer,File=buffer$1.File,FileOptions$1=buffer$1.FileOptions,INSPECT_MAX_BYTES=buffer$1.INSPECT_MAX_BYTES,SlowBuffer=buffer$1.SlowBuffer,TranscodeEncoding=buffer$1.TranscodeEncoding,atob=buffer$1.atob,btoa=buffer$1.btoa,constants$5=buffer$1.constants,isAscii=buffer$1.isAscii,isUtf8=buffer$1.isUtf8,kMaxLength=buffer$1.kMaxLength,kStringMaxLength=buffer$1.kStringMaxLength,resolveObjectURL=buffer$1.resolveObjectURL,transcode=buffer$1.transcode,dist$w=Object.freeze(Object.defineProperty({__proto__:null,Blob:Blob$1,BlobOptions,Buffer:Buffer$1$1,File,FileOptions:FileOptions$1,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding,atob,btoa,constants:constants$5,default:Buffer$e,isAscii,isUtf8,kMaxLength,kStringMaxLength,resolveObjectURL,transcode},Symbol.toStringTag,{value:"Module"})),WALLET_PROVIDER_NAME$6="Keplr";class KeplrProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("keplr_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("keplr_keystorechange",r)});if(this.keplr=t,!t)throw new Error("Keplr extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.keplr)throw new Error("Keplr extension not found");try{await this.keplr.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId))try{await this.keplr.experimentalSuggestChain(this.chainData),await this.keplr.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("Keplr wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("Keplr extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to Keplr")}const t=await this.keplr.getKey(this.chainId);if(!t)throw new Error("Failed to get Keplr key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to Keplr")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$6}async getWalletProviderIcon(){return logo$6}async getOfflineSigner(){if(!this.keplr)throw new Error("Keplr extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.keplr.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.keplr)throw new Error("Keplr extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.keplr.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$a={id:"keplr",name:WALLET_PROVIDER_NAME$6,icon:logo$6,docs:"https://www.keplr.app/",wallet:"keplr",createProvider:(e,t)=>new KeplrProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$5="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='58'%20height='58'%3e%3cg%20fill='none'%20fill-rule='nonzero'%3e%3cpath%20fill='%2324A95A'%20stroke='%23138D3E'%20stroke-width='.039'%20d='M51.466%2036.118c0%204.001-2.44%206.816-6.403%208.631-3.963%201.816-9.446%202.631-15.522%202.631-6.077%200-11.595-.815-15.594-2.63-3.999-1.816-6.474-4.631-6.474-8.632%200-4.002%202.46-7.625%206.44-10.248%203.982-2.623%209.482-4.245%2015.556-4.245%206.075%200%2011.575%201.626%2015.556%204.25%203.981%202.625%206.441%206.248%206.441%2010.243Z'/%3e%3cpath%20fill='%2332DA6D'%20stroke='%23138D3E'%20stroke-width='.039'%20d='m35.608%2013.791.012.003.007-.009A7.686%207.686%200%200%201%2041.555%2011c4.236%200%207.675%203.421%207.675%207.634%200%201.385-.37%202.671-1.009%203.788l-.005.009.004.01a9.644%209.644%200%200%201%20.94%204.13c0%203.711-2.198%207.072-5.753%209.505-3.555%202.434-8.468%203.939-13.893%203.939-5.426%200-10.339-1.505-13.894-3.939-3.555-2.433-5.752-5.794-5.752-9.506%200-1.442.327-2.829.939-4.13l.004-.009-.005-.009a7.583%207.583%200%200%201-1.01-3.788c0-4.213%203.44-7.634%207.676-7.634a7.73%207.73%200%200%201%205.928%202.785l.007.01.012-.004a27.43%2027.43%200%200%201%206.095-.665c2.121%200%204.172.24%206.094.665Z'/%3e%3cpath%20fill='%23FFF'%20d='M16.845%2022.88c2.597%200%204.703-2.094%204.703-4.677%200-2.583-2.106-4.677-4.703-4.677-2.597%200-4.702%202.094-4.702%204.677%200%202.583%202.105%204.677%204.702%204.677ZM41.932%2022.88c2.597%200%204.702-2.094%204.702-4.677%200-2.583-2.105-4.677-4.702-4.677-2.598%200-4.703%202.094-4.703%204.677%200%202.583%202.105%204.677%204.703%204.677Z'/%3e%3cpath%20fill='%2332DA6D'%20stroke='%23138D3E'%20stroke-width='.039'%20d='M4.032%2044.13a.163.163%200%200%200%20.018-.008l-.002-.004-.004-.01-.017-.046-.066-.174a70.962%2070.962%200%200%201-1.02-2.947c-.6-1.87-1.295-4.301-1.669-6.54-.187-1.12-.293-2.192-.268-3.122.025-.93.181-1.716.52-2.266.337-.55.855-.865%201.608-.856.754.01%201.746.347%203.027%201.108%207.702%204.573%209.453%2012.176%209.866%2015.688.113.98-.676%201.85-1.676%201.85H2.308c-.794%200-1.084-1.037-.39-1.438l2.123-1.219.015-.008-.006-.016-.018.007ZM54.276%2044.123l.018.006a.481.481%200%200%201-.018-.006v-.001l.002-.003.003-.011.016-.045a44.607%2044.607%200%200%200%20.276-.83c.183-.56.433-1.356.705-2.291.543-1.871%201.17-4.302%201.507-6.541.169-1.12.265-2.192.242-3.122-.023-.93-.165-1.716-.47-2.267a1.677%201.677%200%200%200-.587-.637%201.587%201.587%200%200%200-.867-.218c-.681.01-1.577.346-2.736%201.107-6.946%204.573-8.541%2012.19-8.897%2015.69-.1.982.606%201.849%201.505%201.849h10.887c.352%200%20.596-.258.672-.569.077-.31-.014-.67-.326-.87l-1.932-1.241Zm0%200-.005.014.013.009%201.924%201.218-1.932-1.241Z'/%3e%3cpath%20fill='%23092511'%20d='M16.893%2021.02a2.805%202.805%200%201%200%200-5.61%202.805%202.805%200%200%200%200%205.61ZM41.98%2021.02a2.805%202.805%200%201%200%200-5.61%202.805%202.805%200%200%200%200%205.61ZM36.998%2029.488a7.536%207.536%200%200%201-10.976%206.042%207.534%207.534%200%200%201-4.037-7.334l7.507.646%207.506.646Z'/%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME$5="Leap";class LeapProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("leap_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("leap_keystorechange",r)});if(this.wallet=t,!t)throw new Error("Leap extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.wallet)throw new Error("Leap extension not found");try{await this.wallet.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId)||o!=null&&o.message.includes("chain id"))try{await this.wallet.experimentalSuggestChain(this.chainData),await this.wallet.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("Leap wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("Leap extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to Leap")}const t=await this.wallet.getKey(this.chainId);if(!t)throw new Error("Failed to get Leap key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to Leap")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$5}async getWalletProviderIcon(){return logo$5}async getOfflineSigner(){if(!this.wallet)throw new Error("Leap extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.wallet)throw new Error("Leap extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$9={id:"leap",name:WALLET_PROVIDER_NAME$5,icon:logo$5,docs:"https://www.leapwallet.io/",wallet:"leap",createProvider:(e,t)=>new LeapProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$4="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='225px'%20height='224px'%20viewBox='0%200%20225%20224'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eokx%3c/title%3e%3cg%20id='Page-1'%20stroke='none'%20strokeWidth='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='okx'%20transform='translate(0.401000,%200.006000)'%20fill='%23000000'%20fill-rule='nonzero'%3e%3cpath%20d='M144.382,74.667%20L79.673,74.667%20C76.924,74.667%2074.695,76.895%2074.695,79.644%20L74.695,144.354%20C74.695,147.103%2076.924,149.332%2079.673,149.332%20L144.382,149.332%20C147.131,149.332%20149.36,147.103%20149.36,144.354%20L149.36,79.644%20C149.36,76.895%20147.131,74.667%20144.382,74.667%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,0%20L4.978,0%20C2.229,0%200,2.228%200,4.978%20L0,69.687%20C0,72.436%202.229,74.665%204.978,74.665%20L69.687,74.665%20C72.437,74.665%2074.665,72.436%2074.665,69.687%20L74.665,4.978%20C74.665,2.228%2072.437,0%2069.687,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,0%20L154.307,0%20C151.558,0%20149.329,2.228%20149.329,4.978%20L149.329,69.687%20C149.329,72.436%20151.558,74.665%20154.307,74.665%20L219.017,74.665%20C221.766,74.665%20223.994,72.436%20223.994,69.687%20L223.994,4.978%20C223.994,2.228%20221.766,0%20219.017,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,149.328%20L4.978,149.328%20C2.229,149.328%200,151.556%200,154.305%20L0,219.015%20C0,221.764%202.229,223.993%204.978,223.993%20L69.687,223.993%20C72.437,223.993%2074.665,221.764%2074.665,219.015%20L74.665,154.305%20C74.665,151.556%2072.437,149.328%2069.687,149.328%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,149.328%20L154.307,149.328%20C151.558,149.328%20149.329,151.556%20149.329,154.305%20L149.329,219.015%20C149.329,221.764%20151.558,223.993%20154.307,223.993%20L219.017,223.993%20C221.766,223.993%20223.994,221.764%20223.994,219.015%20L223.994,154.305%20C223.994,151.556%20221.766,149.328%20219.017,149.328%20Z'%20id='Path'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME$4="OKX";class OKXBabylonProvider{constructor(t,r){at(this,"walletInfo");at(this,"chainId");at(this,"rpc");at(this,"chainData");at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.addEventListener("okx_keystorechange",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Wallet not connected");t==="accountChanged"&&window.removeEventListener("okx_keystorechange",r)});if(this.wallet=t,!t||!t.keplr)throw new Error("OKX Wallet extension not found");this.chainId=r.chainId,this.rpc=r.rpc,this.chainData=r.chainData}async connectWallet(){if(!this.chainId)throw new Error("Chain ID is not initialized");if(!this.rpc)throw new Error("RPC URL is not initialized");if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");try{await this.wallet.keplr.enable(this.chainId)}catch(o){if(o!=null&&o.message.includes(this.chainId))try{await this.wallet.keplr.experimentalSuggestChain(this.chainData),await this.wallet.keplr.enable(this.chainId)}catch{throw new Error("Failed to add BBN chain")}else throw o!=null&&o.message.includes("rejected")?new Error("OKX Wallet connection request rejected"):o!=null&&o.message.includes("context invalidated")?new Error("OKX Wallet extension context invalidated"):new Error((o==null?void 0:o.message)||"Failed to connect to OKX Wallet")}const t=await this.wallet.keplr.getKey(this.chainId);if(!t)throw new Error("Failed to get OKX Wallet key");const{bech32Address:r,pubKey:s}=t;if(r&&s)this.walletInfo={publicKeyHex:Buffer$1$1.from(t.pubKey).toString("hex"),address:r};else throw new Error("Could not connect to OKX Wallet")}async getAddress(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.address}async getPublicKeyHex(){if(!this.walletInfo)throw new Error("Wallet not connected");return this.walletInfo.publicKeyHex}async getWalletProviderName(){return WALLET_PROVIDER_NAME$4}async getWalletProviderIcon(){return logo$4}async getOfflineSigner(){if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.keplr.getOfflineSigner(this.chainId)}catch{throw new Error("Failed to get offline signer")}}async getOfflineSignerAuto(){if(!this.wallet.keplr)throw new Error("OKX Wallet extension not found");if(!this.chainId)throw new Error("Chain ID is not initialized");try{return this.wallet.keplr.getOfflineSignerAuto(this.chainId)}catch{throw new Error("Failed to get offline signer auto")}}}const metadata$8={id:"okx",name:WALLET_PROVIDER_NAME$4,icon:logo$4,docs:"https://www.okx.com/web3",wallet:"okxwallet",createProvider:(e,t)=>new OKXBabylonProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},metadata$7={chain:"BBN",name:"Babylon Chain",icon:icon$1,wallets:[metadata$b,metadata$8,metadata$a,metadata$9]},icon="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='64'%20height='64'%3e%3cpath%20fill='%23f7931a'%20d='M63.04%2039.741c-4.275%2017.143-21.638%2027.576-38.783%2023.301C7.12%2058.768-3.313%2041.404.962%2024.262%205.234%207.117%2022.597-3.317%2039.737.957c17.144%204.274%2027.576%2021.64%2023.302%2038.784z'/%3e%3cpath%20fill='%23FFF'%20d='M46.11%2027.441c.636-4.258-2.606-6.547-7.039-8.074l1.438-5.768-3.51-.875-1.4%205.616c-.924-.23-1.872-.447-2.814-.662l1.41-5.653-3.509-.875-1.439%205.766c-.764-.174-1.514-.346-2.242-.527l.004-.018-4.842-1.209-.934%203.75s2.605.597%202.55.634c1.422.355%201.68%201.296%201.636%202.042l-1.638%206.571c.098.025.225.061.365.117l-.37-.092-2.297%209.205c-.174.432-.615%201.08-1.609.834.035.051-2.552-.637-2.552-.637l-1.743%204.019%204.57%201.139c.85.213%201.682.436%202.502.646l-1.453%205.834%203.507.875%201.44-5.772c.957.26%201.887.5%202.797.726l-1.434%205.745%203.511.875%201.453-5.823c5.987%201.133%2010.49.676%2012.384-4.739%201.527-4.36-.076-6.875-3.226-8.515%202.294-.529%204.022-2.038%204.483-5.155zM38.086%2038.69c-1.085%204.36-8.426%202.003-10.806%201.412l1.928-7.729c2.38.594%2010.012%201.77%208.878%206.317zm1.086-11.312c-.99%203.966-7.1%201.951-9.082%201.457l1.748-7.01c1.982.494%208.365%201.416%207.334%205.553z'/%3e%3c/svg%3e",metadata$6={id:"injectable",name:e=>{var t;return(t=e.getWalletProviderName)==null?void 0:t.call(e)},icon:e=>{var t;return(t=e.getWalletProviderIcon)==null?void 0:t.call(e)},docs:"",wallet:"btcwallet",createProvider:e=>e,networks:[Network.MAINNET,Network.SIGNET],label:"Injectable"},logo$3="data:image/svg+xml,%3csvg%20width='160'%20height='160'%20viewBox='0%200%20160%20160'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M30%2025H90L50%20110H20L30%2025Z'%20fill='black'/%3e%3cpath%20d='M130%20135L70%20135L110%2050L140%2050L130%20135Z'%20fill='%23F5870A'/%3e%3c/svg%3e";var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function s(){return this instanceof s?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(s){var o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,o.get?o:{enumerable:!0,get:function(){return e[s]}})}),r}var dist$v={},utils$o={},stringHelper={},commonjsBrowser$3={},v1$d={},rng$e={};Object.defineProperty(rng$e,"__esModule",{value:!0});rng$e.default=rng$d;let getRandomValues$a;const rnds8$a=new Uint8Array(16);function rng$d(){if(!getRandomValues$a&&(getRandomValues$a=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!getRandomValues$a))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues$a(rnds8$a)}var stringify$d={},validate$d={},regex$3={};Object.defineProperty(regex$3,"__esModule",{value:!0});regex$3.default=void 0;var _default$c=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;regex$3.default=_default$c;Object.defineProperty(validate$d,"__esModule",{value:!0});validate$d.default=void 0;var _regex=_interopRequireDefault$8(regex$3);function _interopRequireDefault$8(e){return e&&e.__esModule?e:{default:e}}function validate$c(e){return typeof e=="string"&&_regex.default.test(e)}var _default$b=validate$c;validate$d.default=_default$b;Object.defineProperty(stringify$d,"__esModule",{value:!0});stringify$d.default=void 0;stringify$d.unsafeStringify=unsafeStringify$1;var _validate$2=_interopRequireDefault$7(validate$d);function _interopRequireDefault$7(e){return e&&e.__esModule?e:{default:e}}const byteToHex$a=[];for(let e=0;e<256;++e)byteToHex$a.push((e+256).toString(16).slice(1));function unsafeStringify$1(e,t=0){return byteToHex$a[e[t+0]]+byteToHex$a[e[t+1]]+byteToHex$a[e[t+2]]+byteToHex$a[e[t+3]]+"-"+byteToHex$a[e[t+4]]+byteToHex$a[e[t+5]]+"-"+byteToHex$a[e[t+6]]+byteToHex$a[e[t+7]]+"-"+byteToHex$a[e[t+8]]+byteToHex$a[e[t+9]]+"-"+byteToHex$a[e[t+10]]+byteToHex$a[e[t+11]]+byteToHex$a[e[t+12]]+byteToHex$a[e[t+13]]+byteToHex$a[e[t+14]]+byteToHex$a[e[t+15]]}function stringify$c(e,t=0){const r=unsafeStringify$1(e,t);if(!(0,_validate$2.default)(r))throw TypeError("Stringified UUID is invalid");return r}var _default$a=stringify$c;stringify$d.default=_default$a;Object.defineProperty(v1$d,"__esModule",{value:!0});v1$d.default=void 0;var _rng$1=_interopRequireDefault$6(rng$e),_stringify$2=stringify$d;function _interopRequireDefault$6(e){return e&&e.__esModule?e:{default:e}}let _nodeId$9,_clockseq$9,_lastMSecs$9=0,_lastNSecs$9=0;function v1$c(e,t,r){let s=t&&r||0;const o=t||new Array(16);e=e||{};let n=e.node||_nodeId$9,a=e.clockseq!==void 0?e.clockseq:_clockseq$9;if(n==null||a==null){const w=e.random||(e.rng||_rng$1.default)();n==null&&(n=_nodeId$9=[w[0]|1,w[1],w[2],w[3],w[4],w[5]]),a==null&&(a=_clockseq$9=(w[6]<<8|w[7])&16383)}let l=e.msecs!==void 0?e.msecs:Date.now(),p=e.nsecs!==void 0?e.nsecs:_lastNSecs$9+1;const u=l-_lastMSecs$9+(p-_lastNSecs$9)/1e4;if(u<0&&e.clockseq===void 0&&(a=a+1&16383),(u<0||l>_lastMSecs$9)&&e.nsecs===void 0&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs$9=l,_lastNSecs$9=p,_clockseq$9=a,l+=122192928e5;const c=((l&268435455)*1e4+p)%4294967296;o[s++]=c>>>24&255,o[s++]=c>>>16&255,o[s++]=c>>>8&255,o[s++]=c&255;const v=l/4294967296*1e4&268435455;o[s++]=v>>>8&255,o[s++]=v&255,o[s++]=v>>>24&15|16,o[s++]=v>>>16&255,o[s++]=a>>>8|128,o[s++]=a&255;for(let w=0;w<6;++w)o[s+w]=n[w];return t||(0,_stringify$2.unsafeStringify)(o)}var _default$9=v1$c;v1$d.default=_default$9;var v3$d={},v35$d={},parse$d={};Object.defineProperty(parse$d,"__esModule",{value:!0});parse$d.default=void 0;var _validate$1=_interopRequireDefault$5(validate$d);function _interopRequireDefault$5(e){return e&&e.__esModule?e:{default:e}}function parse$c(e){if(!(0,_validate$1.default)(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var _default$8=parse$c;parse$d.default=_default$8;Object.defineProperty(v35$d,"__esModule",{value:!0});v35$d.URL=v35$d.DNS=void 0;v35$d.default=v35$c;var _stringify$1=stringify$d,_parse=_interopRequireDefault$4(parse$d);function _interopRequireDefault$4(e){return e&&e.__esModule?e:{default:e}}function stringToBytes$9(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}const DNS$9="6ba7b810-9dad-11d1-80b4-00c04fd430c8";v35$d.DNS=DNS$9;const URL$9="6ba7b811-9dad-11d1-80b4-00c04fd430c8";v35$d.URL=URL$9;function v35$c(e,t,r){function s(o,n,a,l){var p;if(typeof o=="string"&&(o=stringToBytes$9(o)),typeof n=="string"&&(n=(0,_parse.default)(n)),((p=n)===null||p===void 0?void 0:p.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+o.length);if(u.set(n),u.set(o,n.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,a){l=l||0;for(let c=0;c<16;++c)a[l+c]=u[c];return a}return(0,_stringify$1.unsafeStringify)(u)}try{s.name=e}catch{}return s.DNS=DNS$9,s.URL=URL$9,s}var md5$e={};Object.defineProperty(md5$e,"__esModule",{value:!0});md5$e.default=void 0;function md5$d(e){if(typeof e=="string"){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return md5ToHexEncodedArray$9(wordsToMd5$9(bytesToWords$9(e),e.length*8))}function md5ToHexEncodedArray$9(e){const t=[],r=e.length*32,s="0123456789abcdef";for(let o=0;o<r;o+=8){const n=e[o>>5]>>>o%32&255,a=parseInt(s.charAt(n>>>4&15)+s.charAt(n&15),16);t.push(a)}return t}function getOutputLength$9(e){return(e+64>>>9<<4)+14+1}function wordsToMd5$9(e,t){e[t>>5]|=128<<t%32,e[getOutputLength$9(t)-1]=t;let r=1732584193,s=-271733879,o=-1732584194,n=271733878;for(let a=0;a<e.length;a+=16){const l=r,p=s,u=o,c=n;r=md5ff$9(r,s,o,n,e[a],7,-680876936),n=md5ff$9(n,r,s,o,e[a+1],12,-389564586),o=md5ff$9(o,n,r,s,e[a+2],17,606105819),s=md5ff$9(s,o,n,r,e[a+3],22,-1044525330),r=md5ff$9(r,s,o,n,e[a+4],7,-176418897),n=md5ff$9(n,r,s,o,e[a+5],12,1200080426),o=md5ff$9(o,n,r,s,e[a+6],17,-1473231341),s=md5ff$9(s,o,n,r,e[a+7],22,-45705983),r=md5ff$9(r,s,o,n,e[a+8],7,1770035416),n=md5ff$9(n,r,s,o,e[a+9],12,-1958414417),o=md5ff$9(o,n,r,s,e[a+10],17,-42063),s=md5ff$9(s,o,n,r,e[a+11],22,-1990404162),r=md5ff$9(r,s,o,n,e[a+12],7,1804603682),n=md5ff$9(n,r,s,o,e[a+13],12,-40341101),o=md5ff$9(o,n,r,s,e[a+14],17,-1502002290),s=md5ff$9(s,o,n,r,e[a+15],22,1236535329),r=md5gg$9(r,s,o,n,e[a+1],5,-165796510),n=md5gg$9(n,r,s,o,e[a+6],9,-1069501632),o=md5gg$9(o,n,r,s,e[a+11],14,643717713),s=md5gg$9(s,o,n,r,e[a],20,-373897302),r=md5gg$9(r,s,o,n,e[a+5],5,-701558691),n=md5gg$9(n,r,s,o,e[a+10],9,38016083),o=md5gg$9(o,n,r,s,e[a+15],14,-660478335),s=md5gg$9(s,o,n,r,e[a+4],20,-405537848),r=md5gg$9(r,s,o,n,e[a+9],5,568446438),n=md5gg$9(n,r,s,o,e[a+14],9,-1019803690),o=md5gg$9(o,n,r,s,e[a+3],14,-187363961),s=md5gg$9(s,o,n,r,e[a+8],20,1163531501),r=md5gg$9(r,s,o,n,e[a+13],5,-1444681467),n=md5gg$9(n,r,s,o,e[a+2],9,-51403784),o=md5gg$9(o,n,r,s,e[a+7],14,1735328473),s=md5gg$9(s,o,n,r,e[a+12],20,-1926607734),r=md5hh$9(r,s,o,n,e[a+5],4,-378558),n=md5hh$9(n,r,s,o,e[a+8],11,-2022574463),o=md5hh$9(o,n,r,s,e[a+11],16,1839030562),s=md5hh$9(s,o,n,r,e[a+14],23,-35309556),r=md5hh$9(r,s,o,n,e[a+1],4,-1530992060),n=md5hh$9(n,r,s,o,e[a+4],11,1272893353),o=md5hh$9(o,n,r,s,e[a+7],16,-155497632),s=md5hh$9(s,o,n,r,e[a+10],23,-1094730640),r=md5hh$9(r,s,o,n,e[a+13],4,681279174),n=md5hh$9(n,r,s,o,e[a],11,-358537222),o=md5hh$9(o,n,r,s,e[a+3],16,-722521979),s=md5hh$9(s,o,n,r,e[a+6],23,76029189),r=md5hh$9(r,s,o,n,e[a+9],4,-640364487),n=md5hh$9(n,r,s,o,e[a+12],11,-421815835),o=md5hh$9(o,n,r,s,e[a+15],16,530742520),s=md5hh$9(s,o,n,r,e[a+2],23,-995338651),r=md5ii$9(r,s,o,n,e[a],6,-198630844),n=md5ii$9(n,r,s,o,e[a+7],10,1126891415),o=md5ii$9(o,n,r,s,e[a+14],15,-1416354905),s=md5ii$9(s,o,n,r,e[a+5],21,-57434055),r=md5ii$9(r,s,o,n,e[a+12],6,1700485571),n=md5ii$9(n,r,s,o,e[a+3],10,-1894986606),o=md5ii$9(o,n,r,s,e[a+10],15,-1051523),s=md5ii$9(s,o,n,r,e[a+1],21,-2054922799),r=md5ii$9(r,s,o,n,e[a+8],6,1873313359),n=md5ii$9(n,r,s,o,e[a+15],10,-30611744),o=md5ii$9(o,n,r,s,e[a+6],15,-1560198380),s=md5ii$9(s,o,n,r,e[a+13],21,1309151649),r=md5ii$9(r,s,o,n,e[a+4],6,-145523070),n=md5ii$9(n,r,s,o,e[a+11],10,-1120210379),o=md5ii$9(o,n,r,s,e[a+2],15,718787259),s=md5ii$9(s,o,n,r,e[a+9],21,-343485551),r=safeAdd$9(r,l),s=safeAdd$9(s,p),o=safeAdd$9(o,u),n=safeAdd$9(n,c)}return[r,s,o,n]}function bytesToWords$9(e){if(e.length===0)return[];const t=e.length*8,r=new Uint32Array(getOutputLength$9(t));for(let s=0;s<t;s+=8)r[s>>5]|=(e[s/8]&255)<<s%32;return r}function safeAdd$9(e,t){const r=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(r>>16)<<16|r&65535}function bitRotateLeft$9(e,t){return e<<t|e>>>32-t}function md5cmn$9(e,t,r,s,o,n){return safeAdd$9(bitRotateLeft$9(safeAdd$9(safeAdd$9(t,e),safeAdd$9(s,n)),o),r)}function md5ff$9(e,t,r,s,o,n,a){return md5cmn$9(t&r|~t&s,e,t,o,n,a)}function md5gg$9(e,t,r,s,o,n,a){return md5cmn$9(t&s|r&~s,e,t,o,n,a)}function md5hh$9(e,t,r,s,o,n,a){return md5cmn$9(t^r^s,e,t,o,n,a)}function md5ii$9(e,t,r,s,o,n,a){return md5cmn$9(r^(t|~s),e,t,o,n,a)}var _default$7=md5$d;md5$e.default=_default$7;Object.defineProperty(v3$d,"__esModule",{value:!0});v3$d.default=void 0;var _v$1=_interopRequireDefault$3(v35$d),_md$2=_interopRequireDefault$3(md5$e);function _interopRequireDefault$3(e){return e&&e.__esModule?e:{default:e}}const v3$c=(0,_v$1.default)("v3",48,_md$2.default);var _default$6=v3$c;v3$d.default=_default$6;var v4$e={},native$6={};Object.defineProperty(native$6,"__esModule",{value:!0});native$6.default=void 0;const randomUUID$1=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var _default$5={randomUUID:randomUUID$1};native$6.default=_default$5;Object.defineProperty(v4$e,"__esModule",{value:!0});v4$e.default=void 0;var _native=_interopRequireDefault$2(native$6),_rng=_interopRequireDefault$2(rng$e),_stringify=stringify$d;function _interopRequireDefault$2(e){return e&&e.__esModule?e:{default:e}}function v4$d(e,t,r){if(_native.default.randomUUID&&!t&&!e)return _native.default.randomUUID();e=e||{};const s=e.random||(e.rng||_rng.default)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=s[o];return t}return(0,_stringify.unsafeStringify)(s)}var _default$4=v4$d;v4$e.default=_default$4;var v5$d={},sha1$f={};Object.defineProperty(sha1$f,"__esModule",{value:!0});sha1$f.default=void 0;function f$b(e,t,r,s){switch(e){case 0:return t&r^~t&s;case 1:return t^r^s;case 2:return t&r^t&s^r&s;case 3:return t^r^s}}function ROTL$9(e,t){return e<<t|e>>>32-t}function sha1$e(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){const a=unescape(encodeURIComponent(e));e=[];for(let l=0;l<a.length;++l)e.push(a.charCodeAt(l))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const s=e.length/4+2,o=Math.ceil(s/16),n=new Array(o);for(let a=0;a<o;++a){const l=new Uint32Array(16);for(let p=0;p<16;++p)l[p]=e[a*64+p*4]<<24|e[a*64+p*4+1]<<16|e[a*64+p*4+2]<<8|e[a*64+p*4+3];n[a]=l}n[o-1][14]=(e.length-1)*8/Math.pow(2,32),n[o-1][14]=Math.floor(n[o-1][14]),n[o-1][15]=(e.length-1)*8&4294967295;for(let a=0;a<o;++a){const l=new Uint32Array(80);for(let b=0;b<16;++b)l[b]=n[a][b];for(let b=16;b<80;++b)l[b]=ROTL$9(l[b-3]^l[b-8]^l[b-14]^l[b-16],1);let p=r[0],u=r[1],c=r[2],v=r[3],w=r[4];for(let b=0;b<80;++b){const E=Math.floor(b/20),I=ROTL$9(p,5)+f$b(E,u,c,v)+w+t[E]+l[b]>>>0;w=v,v=c,c=ROTL$9(u,30)>>>0,u=p,p=I}r[0]=r[0]+p>>>0,r[1]=r[1]+u>>>0,r[2]=r[2]+c>>>0,r[3]=r[3]+v>>>0,r[4]=r[4]+w>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var _default$3=sha1$e;sha1$f.default=_default$3;Object.defineProperty(v5$d,"__esModule",{value:!0});v5$d.default=void 0;var _v=_interopRequireDefault$1(v35$d),_sha=_interopRequireDefault$1(sha1$f);function _interopRequireDefault$1(e){return e&&e.__esModule?e:{default:e}}const v5$c=(0,_v.default)("v5",80,_sha.default);var _default$2=v5$c;v5$d.default=_default$2;var nil$c={};Object.defineProperty(nil$c,"__esModule",{value:!0});nil$c.default=void 0;var _default$1="00000000-0000-0000-0000-000000000000";nil$c.default=_default$1;var version$e={};Object.defineProperty(version$e,"__esModule",{value:!0});version$e.default=void 0;var _validate=_interopRequireDefault(validate$d);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function version$d(e){if(!(0,_validate.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var _default=version$d;version$e.default=_default;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return p.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.default}});var t=c(v1$d),r=c(v3$d),s=c(v4$e),o=c(v5$d),n=c(nil$c),a=c(version$e),l=c(validate$d),p=c(stringify$d),u=c(parse$d);function c(v){return v&&v.__esModule?v:{default:v}}})(commonjsBrowser$3);var coin={};Object.defineProperty(coin,"__esModule",{value:!0});coin.getCoinSymbol=void 0;function getCoinSymbol(e){var t;return(t={0:"BTC",2:"LTC",3:"DOGE",4:"RDD",5:"DASH",6:"PPC",7:"NMC",8:"FTC",9:"XCP",10:"BLK",11:"NSR",12:"NBT",13:"MZC",14:"VIA",15:"XCH",16:"RBY",17:"GRS",18:"DGC",19:"CCN",20:"DGB",22:"MONA",23:"CLAM",24:"XPM",25:"NEOS",26:"JBS",27:"ZRC",28:"VTC",29:"NXT",30:"BURST",31:"MUE",32:"ZOOM",33:"VASH",34:"CDN",35:"SDC",36:"PKB",37:"PND",38:"START",39:"MOIN",40:"EXP",41:"EMC2",42:"DCR",43:"XEM",44:"PART",45:"ARG",48:"SHR",49:"GCR",50:"NVC",51:"AC",52:"BTCD",53:"DOPE",54:"TPC",55:"AIB",56:"EDRC",57:"SYS",58:"SLR",59:"SMLY",60:"ETH",61:"ETC",62:"PSB",63:"LDCN",65:"XBC",66:"IOP",67:"NXS",68:"INSN",69:"OK",70:"BRIT",71:"CMP",72:"CRW",73:"BELA",74:"ICX",75:"FJC",76:"MIX",77:"XVG",78:"EFL",79:"CLUB",80:"RICHX",81:"POT",82:"QRK",83:"TRC",84:"GRC",85:"AUR",86:"IXC",87:"NLG",88:"BITB",89:"BTA",90:"XMY",91:"BSD",92:"UNO",93:"MTR",94:"GB",95:"SHM",96:"CRX",97:"BIQ",98:"EVO",99:"STO",100:"BIGUP",101:"GAME",102:"DLC",103:"ZYD",104:"DBIC",105:"STRAT",106:"SH",107:"MARS",108:"UBQ",109:"PTC",110:"NRO",111:"ARK",112:"USC",113:"THC",114:"LINX",115:"ECN",116:"DNR",117:"PINK",118:"ATOM",119:"PIVX",120:"FLASH",121:"ZEN",122:"PUT",123:"ZNY",124:"UNIFY",125:"XST",126:"BRK",127:"VC",128:"XMR",129:"VOX",130:"NAV",131:"FCT",132:"EC",133:"ZEC",134:"LSK",135:"STEEM",136:"XZC",137:"RBTC",139:"RPT",140:"LBC",141:"KMD",142:"BSQ",143:"RIC",144:"XRP",145:"BCH",146:"NEBL",147:"ZCL",148:"XLM",149:"NLC2",150:"WHL",151:"ERC",152:"DMD",153:"BTM",154:"BIO",155:"XWCC",156:"BTG",157:"BTC2X",158:"SSN",159:"TOA",160:"BTX",161:"ACC",162:"BCO",163:"ELLA",164:"PIRL",165:"XNO",166:"VIVO",167:"FRST",168:"HNC",169:"BUZZ",170:"MBRS",171:"HC",172:"HTML",173:"ODN",174:"ONX",175:"RVN",176:"GBX",177:"BTCZ",178:"POA",179:"NYC",180:"MXT",181:"WC",182:"MNX",183:"BTCP",184:"MUSIC",185:"BCA",186:"CRAVE",187:"STAK",188:"WBTC",189:"LCH",190:"EXCL",192:"LCC",193:"XFE",194:"EOS",195:"TRX",196:"KOBO",197:"HUSH",198:"BAN",199:"ETF",200:"OMNI",201:"BIFI",202:"UFO",203:"CNMC",204:"BCN",205:"RIN",206:"ATP",207:"EVT",208:"ATN",209:"BIS",210:"NEET",211:"BOPO",212:"OOT",213:"ALIAS",214:"MONK",215:"BOXY",216:"FLO",217:"MEC",218:"BTDX",219:"XAX",220:"ANON",221:"LTZ",222:"BITG",223:"ICP",224:"SMART",225:"XUEZ",226:"HLM",227:"WEB",228:"ACM",229:"NOS",230:"BITC",231:"HTH",232:"TZC",233:"VAR",234:"IOV",235:"FIO",236:"BSV",237:"DXN",238:"QRL",239:"PCX",240:"LOKI",242:"NIM",243:"SOV",244:"JCT",245:"SLP",246:"EWT",247:"UC",248:"EXOS",249:"ECA",250:"SOOM",251:"XRD",252:"FREE",253:"NPW",254:"BST",256:"NANO",257:"BTCC",259:"ZEST",260:"ABT",261:"PION",262:"DT3",263:"ZBUX",264:"KPL",265:"TPAY",266:"ZILLA",267:"ANK",268:"BCC",269:"HPB",270:"ONE",271:"SBC",272:"IPC",273:"DMTC",274:"OGC",275:"SHIT",276:"ANDES",277:"AREPA",278:"BOLI",279:"RIL",280:"HTR",281:"FCTID",282:"BRAVO",283:"ALGO",284:"BZX",285:"GXX",286:"HEAT",287:"XDN",288:"FSN",289:"CPC",290:"BOLD",291:"IOST",292:"TKEY",293:"USE",294:"BCZ",295:"IOC",296:"ASF",297:"MASS",298:"FAIR",299:"NUKO",300:"GNX",301:"DIVI",302:"CMT",303:"EUNO",304:"IOTX",305:"ONION",306:"8BIT",307:"ATC",308:"BTS",309:"CKB",310:"UGAS",311:"ADS",312:"ARA",313:"ZIL",314:"MOAC",315:"SWTC",316:"VNSC",317:"PLUG",318:"MAN",319:"ECC",320:"RPD",321:"RAP",322:"GARD",323:"ZER",324:"EBST",325:"SHARD",326:"MRX",327:"CMM",328:"BLOCK",329:"AUDAX",330:"LUNA",331:"ZPM",332:"KUVA",333:"MEM",334:"CS",335:"SWIFT",336:"FIX",337:"CPC",338:"VGO",339:"DVT",340:"N8V",341:"MTNS",342:"BLAST",343:"DCT",344:"AUX",345:"USDP",346:"HTDF",347:"YEC",348:"QLC",349:"TEA",350:"ARW",351:"MDM",352:"CYB",353:"LTO",354:"DOT",355:"AEON",356:"RES",357:"AYA",358:"DAPS",359:"CSC",360:"VSYS",361:"NOLLAR",362:"XNOS",363:"CPU",364:"LAMB",365:"VCT",366:"CZR",367:"ABBC",368:"HET",369:"XAS",370:"VDL",371:"MED",372:"ZVC",373:"VESTX",374:"DBT",375:"SEOS",376:"MXW",377:"ZNZ",378:"XCX",379:"SOX",380:"NYZO",381:"ULC",382:"RYO",383:"KAL",384:"XSN",385:"DOGEC",386:"BMV",387:"QBC",388:"IMG",389:"QOS",390:"PKT",391:"LHD",392:"CENNZ",393:"HSN",394:"CRO",395:"UMBRU",396:"EVER",397:"NEAR",398:"XPC",399:"ZOC",400:"NIX",401:"UC",402:"GALI",403:"OLT",404:"XBI",405:"DONU",406:"EARTHS",407:"HDD",408:"SUGAR",409:"AILE",410:"TENT",411:"TAN",412:"AIN",413:"MSR",414:"SUMO",415:"ETN",416:"BYTZ",417:"WOW",418:"XTNC",419:"LTHN",420:"NODE",421:"AGM",422:"CCX",423:"TNET",424:"TELOS",425:"AION",426:"BC",427:"KTV",428:"ZCR",429:"ERG",430:"PESO",431:"BTC2",432:"XRPHD",433:"WE",434:"KSM",435:"PCN",436:"NCH",437:"ICU",438:"LN",439:"DTP",440:"BTCR",441:"AERGO",442:"XTH",443:"LV",444:"PHR",445:"VITAE",446:"COCOS",447:"DIN",448:"SPL",449:"YCE",450:"XLR",451:"KTS",452:"DGLD",453:"XNS",454:"EM",455:"SHN",456:"SEELE",457:"AE",458:"ODX",459:"KAVA",460:"GLEEC",461:"FIL",462:"RUTA",463:"CSDT",464:"ETI",465:"ZSLP",466:"ERE",467:"DX",468:"CPS",469:"BTH",470:"MESG",471:"FIMK",472:"AR",473:"OGO",474:"ROSE",475:"BARE",476:"GLEEC",477:"CLR",478:"RNG",479:"OLO",480:"PEXA",481:"MOON",482:"OCEAN",483:"BNT",484:"AMO",485:"FCH",486:"LAT",487:"COIN",488:"VEO",489:"CCA",490:"GFN",491:"BIP",492:"KPG",493:"FIN",494:"BAND",495:"DROP",496:"BHT",497:"LYRA",498:"CS",499:"RUPX",500:"THETA",501:"SOL",502:"THT",503:"CFX",504:"KUMA",505:"HASH",506:"CSPR",507:"EARTH",508:"EGLD",509:"CHI",510:"KOTO",511:"OTC",512:"XRD",513:"SEELEN",514:"AETH",515:"DNA",516:"VEE",517:"SIERRA",518:"LET",519:"BSC",520:"BTCV",521:"ABA",522:"SCC",523:"EDG",524:"AMS",525:"GOSS",526:"BU",527:"GRAM",528:"YAP",529:"SCRT",530:"NOVO",531:"GHOST",532:"HST",533:"PRJ",534:"YOU",535:"XHV",536:"BYND",537:"JOYS",538:"VAL",539:"FLOW",540:"SMESH",541:"SCDO",542:"IQS",543:"BIND",544:"COINEVO",545:"SCRIBE",546:"HYN",547:"BHP",548:"BBC",549:"MKF",550:"XDC",551:"STR",552:"SUM",553:"HBC",555:"BCS",556:"KTS",557:"LKR",558:"TAO",559:"XWC",560:"DEAL",561:"NTY",562:"TOP",564:"AG",565:"CICO",566:"IRIS",567:"NCG",568:"LRG",569:"SERO",570:"BDX",571:"CCXX",572:"SLS",573:"SRM",575:"VIVT",576:"BPS",577:"NKN",578:"ICL",579:"BONO",580:"PLC",581:"DUN",582:"DMCH",583:"CTC",584:"KELP",585:"GBCR",586:"XDAG",587:"PRV",588:"SCAP",589:"TFUEL",590:"GTM",591:"RNL",592:"GRIN",593:"MWC",594:"DOCK",595:"POLYX",596:"DIVER",597:"XEP",598:"APN",599:"TFC",600:"UTE",601:"MTC",602:"NC",603:"XINY",604:"DYN",605:"BUFS",606:"STOS",607:"TON",608:"TAFT",609:"HYDRA",610:"NOR",613:"WCN",614:"OPT",615:"PSWAP",616:"VAL",617:"XOR",618:"SSP",619:"DEI",621:"ZERO",622:"ALPHA",623:"BDECO",624:"NOBL",625:"EAST",626:"KDA",627:"SOUL",628:"LORE",629:"FNR",630:"NEXUS",631:"QTZ",632:"XMA",633:"CALL",634:"VAL",635:"POKT",636:"EMIT",637:"APTOS",638:"ADON",639:"BTSG",640:"LFC",641:"KCS",642:"KCC",643:"AZERO",644:"TREE",645:"LX",646:"XLN",647:"CIC",648:"ZRB",650:"UCO",651:"SFX",652:"SFT",653:"WSFX",654:"USDG",655:"WMP",659:"KOIN",660:"PIRATE",663:"SFRX",666:"ACT",667:"PRKL",668:"SSC",669:"GC",670:"PLGR",671:"MPLGR",672:"KNOX",673:"ZED",674:"CNDL",675:"WLKR",676:"WLKRR",677:"YUNGE",678:"Voken",679:"APL",680:"Evrynet",681:"NENG",682:"CHTA",685:"OAS",686:"KAR",688:"CET",690:"KLV",694:"VTBC",698:"VEIL",699:"GTB",700:"XDAI",701:"COM",702:"CCC",707:"MCOIN",711:"CHC",712:"SERF",713:"XTL",714:"BNB",715:"SIN",716:"DLN",717:"BONTE",718:"PEER",725:"MCX",730:"HEALIOS",731:"BMK",734:"DENTX",737:"ATOP",747:"CFG",750:"XPRT",757:"HONEY",768:"BALLZ",770:"COSA",771:"BR",775:"PLSR",776:"KEY",777:"BTW",780:"PLCUC",781:"PLCUX",782:"PLCU",784:"SUI",786:"UIDD",787:"ACA",788:"BNC",789:"TAU",799:"PDEX",800:"BEET",801:"DST",804:"ZKS",808:"QVT",809:"SDN",810:"ASTR",813:"MEER",818:"VET",819:"REEF",820:"CLO",822:"BDB",827:"ACE",828:"CCN",831:"CRUZ",832:"SAPP",833:"777",834:"KYAN",835:"AZR",836:"CFL",837:"DASHD",838:"TRTT",839:"UCR",840:"PNY",841:"BECN",842:"MONK",843:"SAGA",844:"SUV",845:"ESK",846:"OWO",847:"PEPS",848:"BIR",849:"MOBIC",850:"FLS",852:"DSM",853:"PRCY",858:"HVH",866:"MOB",868:"IF",877:"NAM",880:"LUM",883:"ZBC",886:"ADF",888:"NEO",889:"TOMO",890:"XSEL",896:"LKSC",898:"AS",899:"XEC",900:"LMO",901:"NXT",904:"HNT",907:"FIS",909:"SGE",911:"GERT",916:"META",917:"FRA",919:"CCD",921:"AVN",925:"DIP",928:"GHM",931:"RUNE",945:"UNLOCK",955:"LTP",960:"VKAX",966:"MATIC",968:"UNW",970:"TWINS",977:"TLOS",981:"TAFECO",985:"AU",987:"VCG",988:"XAZAB",989:"AIOZ",990:"CORE",991:"PEC",992:"UNT",993:"XRB",994:"QUAI",995:"CAPS",996:"OKT",997:"SUM",998:"LBTC",999:"BCD",1e3:"BTN",1001:"TT",1002:"BKT",1003:"NODL",1004:"PCOIN",1005:"TAO",1006:"HSK",1007:"FTM",1008:"RPG",1010:"HT",1011:"ELV",1013:"BIC",1020:"EVC",1022:"XRD",1023:"ONE",1024:"ONT",1025:"CZZ",1026:"KEX",1027:"MCM",1032:"BTCR",1042:"MFID",1111:"BBC",1120:"RISE",1122:"CMT",1128:"ETSC",1129:"DFI",1130:"DFI",1137:"$DAG",1145:"CDY",1155:"EFI",1170:"HOO",1234:"ALPH",1284:"GLMR",1285:"MOVR",1298:"WPC",1308:"WEI",1337:"DFC",1397:"HYC",1410:"TENTSLP",1510:"XSC",1512:"AAC",1533:"BEAM",1555:"APC",1616:"ELF",1618:"AUDL",1620:"ATH",1627:"LUME",1642:"NEW",1657:"BTA",1668:"NEOX",1669:"MEWC",1688:"BCX",1729:"XTZ",1776:"LBTC",1777:"BBP",1784:"JPYS",1789:"VEGA",1815:"ADA",1818:"CUBE",1856:"TES",1888:"ZTX",1899:"XEC",1901:"CLC",1919:"VIPS",1926:"CITY",1955:"XX",1977:"XMX",1984:"TRTL",1985:"SLRT",1986:"QTH",1987:"EGEM",1988:"MIRA",1989:"HODL",1990:"PHL",1991:"SC",1996:"MYT",1997:"POLIS",1998:"XMCC",1999:"COLX",2e3:"GIN",2001:"MNP",2002:"MLN",2017:"KIN",2018:"EOSC",2019:"GBT",2020:"PKC",2021:"SKT",2022:"XHT",2048:"MCASH",2049:"TRUE",2086:"KILT",2109:"SAMA",2112:"IoTE",2137:"XRG",2182:"CHZ",2221:"ASK",2301:"QTUM",2302:"ETP",2303:"GXC",2304:"CRP",2305:"ELA",2338:"SNOW",2365:"XIN",2570:"AOA",2718:"NAS",2894:"REOSC",2941:"BND",3003:"LUX",3030:"HBAR",3077:"COS",3276:"CCC",3333:"SXP",3377:"ROI",3381:"DYN",3383:"SEQ",3552:"DEO",3564:"DST",3601:"CY",4040:"FC8",4096:"YEE",4218:"IOTA",4219:"SMR",4242:"AXE",4343:"XYM",4444:"C4E",4919:"XVM",5006:"SBC",5248:"FIC",5353:"HNS",5404:"ISK",5467:"ALTME",5555:"FUND",5757:"STX",5895:"VOW",5920:"SLU",6060:"GO",6174:"MOI",6599:"RSC",6666:"BPA",6688:"SAFE",6779:"COTI",6969:"ROGER",7091:"TOPL",7331:"KLY",7341:"SHFT",7777:"BTV",8e3:"SKY",8192:"PAC",8217:"KLAY",8339:"BTQ",8444:"XCH",8680:"PLMNT",8888:"SBTC",8964:"NULS",8997:"BBC",8998:"JGC",8999:"BTP",9e3:"AVAX",9001:"ARB1",9002:"BOBA",9003:"LOOP",9004:"STRK",9005:"AVAXC",9006:"BSC",9797:"NRG",9888:"BTF",9999:"GOD",1e4:"FO",10226:"RTM",10291:"XRC",10605:"XPI",11111:"ESS",12345:"IPOS",12586:"MINA",13107:"BTY",13108:"YCC",14001:"WAX",15845:"SDGO",16181:"XTX",16754:"ARDR",18e3:"MTR",19165:"SAFE",19167:"FLUX",19169:"RITO",20036:"XND",21004:"C4EI",21888:"PCT",22504:"PWR",25252:"BELL",25718:"CHX",29223:"NEXA",31102:"ESN",33416:"TEO",33878:"BTCS",34952:"BTT",37992:"FXTC",39321:"AMA",42069:"FACT",43028:"AXIV",49262:"EVE",49344:"STASH",52752:"CELO",61616:"TH",65536:"KETH",69420:"GRLC",70007:"GWL",77777:"ZYN",88888:"RYO",99999:"WICC",100500:"HOME",101010:"STC",105105:"STRAX",111111:"KAS",161803:"APTA",200625:"AKA",200665:"GENOM",246529:"ATS",261131:"ZAMA",314159:"PI",333332:"VALUE",333333:"3333",424242:"X42",534352:"SCR",666666:"VITE",888888:"SEA",1048576:"AMAX",1171337:"ILT",1313114:"ETHO",1313500:"XERO",1712144:"LAX",3924011:"EPK",4741444:"HYD",5249353:"BCO",5249354:"BHD",5264462:"PTN",5655640:"VLX",5718350:"WAN",5741564:"WAVES",5741565:"WEST",6382179:"ABC",6517357:"CRM",7562605:"SEM",7567736:"ION",7777777:"FCT",7825266:"WGR",7825267:"OBSR",8163271:"AFS",15118976:"XDS",61717561:"AQUA",88888888:"HATCH",91927009:"kUSD",99999996:"GENS",99999997:"EQ",99999998:"FLUID",99999999:"QKC",608589380:"FVDC"}[e])!==null&&t!==void 0?t:""}coin.getCoinSymbol=getCoinSymbol;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(v,w,b,E){E===void 0&&(E=b);var I=Object.getOwnPropertyDescriptor(w,b);(!I||("get"in I?!w.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return w[b]}}),Object.defineProperty(v,E,I)}:function(v,w,b,E){E===void 0&&(E=b),v[E]=w[b]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(v,w){Object.defineProperty(v,"default",{enumerable:!0,value:w})}:function(v,w){v.default=w}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(v){if(v&&v.__esModule)return v;var w={};if(v!=null)for(var b in v)b!=="default"&&Object.prototype.hasOwnProperty.call(v,b)&&t(w,v,b);return r(w,v),w},o=commonjsGlobal&&commonjsGlobal.__exportStar||function(v,w){for(var b in v)b!=="default"&&!Object.prototype.hasOwnProperty.call(w,b)&&t(w,v,b)};Object.defineProperty(e,"__esModule",{value:!0}),e.parsePath=e.uuidStringify=e.uuidParse=e.toBuffer=e.toHex=e.uuid=void 0;const n=s(commonjsBrowser$3);e.uuid=n,o(coin,e);function a(v){return v===void 0?"":Buffer$e.from(v).toString("hex")}e.toHex=a;function l(v){return Buffer$e.from(v??"","hex")}e.toBuffer=l;function p(v){return Buffer$e.from(n.parse(v))}e.uuidParse=p;function u(v){return n.stringify(v)}e.uuidStringify=u;function c(v){return v.replace(/^m\//i,"").split("/").map(b=>{const E=b.endsWith("'");return{index:Number(E?b.substring(0,b.length-1):b),hardened:E}})}e.parsePath=c})(stringHelper);var crypto$5={},dist$u={},extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},extendStatics(e,t)};function __extends(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");extendStatics(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=function(){return __assign=Object.assign||function(t){for(var r,s=1,o=arguments.length;s<o;s++){r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},__assign.apply(this,arguments)};function __rest(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function __decorate(e,t,r,s){var o=arguments.length,n=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function __param(e,t){return function(r,s){t(r,s,e)}}function __esDecorate(e,t,r,s,o,n){function a(B){if(B!==void 0&&typeof B!="function")throw new TypeError("Function expected");return B}for(var l=s.kind,p=l==="getter"?"get":l==="setter"?"set":"value",u=!t&&e?s.static?e:e.prototype:null,c=t||(u?Object.getOwnPropertyDescriptor(u,s.name):{}),v,w=!1,b=r.length-1;b>=0;b--){var E={};for(var I in s)E[I]=I==="access"?{}:s[I];for(var I in s.access)E.access[I]=s.access[I];E.addInitializer=function(B){if(w)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(B||null))};var x=(0,r[b])(l==="accessor"?{get:c.get,set:c.set}:c[p],E);if(l==="accessor"){if(x===void 0)continue;if(x===null||typeof x!="object")throw new TypeError("Object expected");(v=a(x.get))&&(c.get=v),(v=a(x.set))&&(c.set=v),(v=a(x.init))&&o.unshift(v)}else(v=a(x))&&(l==="field"?o.unshift(v):c[p]=v)}u&&Object.defineProperty(u,s.name,c),w=!0}function __runInitializers(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function __propKey(e){return typeof e=="symbol"?e:"".concat(e)}function __setFunctionName(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function __metadata(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function __awaiter$1(e,t,r,s){function o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,a){function l(c){try{u(s.next(c))}catch(v){a(v)}}function p(c){try{u(s.throw(c))}catch(v){a(v)}}function u(c){c.done?n(c.value):o(c.value).then(l,p)}u((s=s.apply(e,t||[])).next())})}function __generator(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,o,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(u){return function(c){return p([u,c])}}function p(u){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(r=0)),r;)try{if(s=1,o&&(n=u[0]&2?o.return:u[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,u[1])).done)return n;switch(o=0,n&&(u=[u[0]&2,n.value]),u[0]){case 0:case 1:n=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,o=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!n||u[1]>n[0]&&u[1]<n[3])){r.label=u[1];break}if(u[0]===6&&r.label<n[1]){r.label=n[1],n=u;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(u);break}n[2]&&r.ops.pop(),r.trys.pop();continue}u=t.call(e,r)}catch(c){u=[6,c],o=0}finally{s=n=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var __createBinding$3=Object.create?function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]};function __exportStar(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&__createBinding$3(t,e,r)}function __values$1(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),o,n=[],a;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(l){a={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return n}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}function __spreadArrays(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var n=arguments[t],a=0,l=n.length;a<l;a++,o++)s[o]=n[a];return s}function __spreadArray(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,n;s<o;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}function __await(e){return this instanceof __await?(this.v=e,this):new __await(e)}function __asyncGenerator(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),o,n=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(b){return function(E){return Promise.resolve(E).then(b,v)}}function l(b,E){s[b]&&(o[b]=function(I){return new Promise(function(x,B){n.push([b,I,x,B])>1||p(b,I)})},E&&(o[b]=E(o[b])))}function p(b,E){try{u(s[b](E))}catch(I){w(n[0][3],I)}}function u(b){b.value instanceof __await?Promise.resolve(b.value.v).then(c,v):w(n[0][2],b)}function c(b){p("next",b)}function v(b){p("throw",b)}function w(b,E){b(E),n.shift(),n.length&&p(n[0][0],n[0][1])}}function __asyncDelegator(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,n){t[o]=e[o]?function(a){return(r=!r)?{value:__await(e[o](a)),done:!1}:n?n(a):a}:n}}function __asyncValues(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values$1=="function"?__values$1(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=e[n]&&function(a){return new Promise(function(l,p){a=e[n](a),o(l,p,a.done,a.value)})}}function o(n,a,l,p){Promise.resolve(p).then(function(u){n({value:u,done:l})},a)}}function __makeTemplateObject(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var __setModuleDefault$3=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},ownKeys=function(e){return ownKeys=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ownKeys(e)};function __importStar$3(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),s=0;s<r.length;s++)r[s]!=="default"&&__createBinding$3(t,e,r[s]);return __setModuleDefault$3(t,e),t}function __importDefault$9(e){return e&&e.__esModule?e:{default:e}}function __classPrivateFieldGet(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function __classPrivateFieldSet(e,t,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r}function __classPrivateFieldIn(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function __addDisposableResource(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}var _SuppressedError=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function __disposeResources(e){function t(n){e.error=e.hasError?new _SuppressedError(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(o,function(a){return t(a),o()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function __rewriteRelativeImportExtension(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,n,a){return s?t?".jsx":".js":o&&(!n||!a)?r:o+n+"."+a.toLowerCase()+"js"}):e}const tslib_es6={__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter:__awaiter$1,__generator,__createBinding:__createBinding$3,__exportStar,__values:__values$1,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar:__importStar$3,__importDefault:__importDefault$9,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension},tslib_es6$1=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource,get __assign(){return __assign},__asyncDelegator,__asyncGenerator,__asyncValues,__await,__awaiter:__awaiter$1,__classPrivateFieldGet,__classPrivateFieldIn,__classPrivateFieldSet,__createBinding:__createBinding$3,__decorate,__disposeResources,__esDecorate,__exportStar,__extends,__generator,__importDefault:__importDefault$9,__importStar:__importStar$3,__makeTemplateObject,__metadata,__param,__propKey,__read,__rest,__rewriteRelativeImportExtension,__runInitializers,__setFunctionName,__spread,__spreadArray,__spreadArrays,__values:__values$1,default:tslib_es6},Symbol.toStringTag,{value:"Module"})),require$$0$4=getAugmentedNamespace(tslib_es6$1);var patchCBOR$c={},utils$n={},lib$d={},cborSync$c={exports:{}},DataItem$d={};Object.defineProperty(DataItem$d,"__esModule",{value:!0});DataItem$d.DataItem=void 0;let DataItem$c=class{constructor(t,r){this.setTag=s=>{this.tag=s},this.clearTag=()=>{this.tag=void 0},this.getTag=()=>this.tag,this.getData=()=>this.data,this.data=t,this.tag=r}};DataItem$d.DataItem=DataItem$c;(function(e){(function(t,r){e.exports?e.exports=r():t.CBOR=r()})(commonjsGlobal,function(){const{DataItem:t}=DataItem$d;var r=function(){function s(y){this.$hex=y}s.prototype={length:function(){return this.$hex.length/2},toString:function(y){if(!y||y==="hex"||y===16)return this.$hex;if(y==="utf-8"){for(var T="",D=0;D<this.$hex.length;D+=2)T+="%"+this.$hex.substring(D,D+2);return decodeURIComponent(T)}if(y==="latin"){for(var T=[],D=0;D<this.$hex.length;D+=2)T.push(parseInt(this.$hex.substring(D,D+2),16));return String.fromCharCode.apply(String,T)}throw new Error("Unrecognised format: "+y)}},s.fromLatinString=function(y){for(var T="",D=0;D<y.length;D++){var L=y.charCodeAt(D).toString(16);L.length===1&&(L="0"+L),T+=L}return new s(T)},s.fromUtf8String=function(y){for(var T=encodeURIComponent(y),D="",L=0;L<T.length;L++)if(T.charAt(L)==="%")D+=T.substring(L+1,L+3),L+=2;else{var C=T.charCodeAt(L).toString(16);C.length<2&&(C="0"+C),D+=C}return new s(D)};var o=[],n={},a=function(y){return function(){throw new Error(y+" not implemented")}};function l(){}l.prototype={peekByte:a("peekByte"),readByte:a("readByte"),readChunk:a("readChunk"),readFloat16:function(){var y=this.readUint16(),T=(y&32767)>>10,D=y&1023,L=y&32768;if(T===31)return D===0?L?-1/0:1/0:NaN;var C=T?Math.pow(2,T-25)*(1024+D):Math.pow(2,-24)*D;return L?-C:C},readFloat32:function(){var y=this.readUint32(),T=(y&2147483647)>>23,D=y&8388607,L=y&2147483648;if(T===255)return D===0?L?-1/0:1/0:NaN;var C=T?Math.pow(2,T-23-127)*(8388608+D):Math.pow(2,-149)*D;return L?-C:C},readFloat64:function(){var y=this.readUint32(),T=this.readUint32(),D=y>>20&2047,L=(y&1048575)*4294967296+T,C=y&2147483648;if(D===2047)return L===0?C?-1/0:1/0:NaN;var d=D?Math.pow(2,D-52-1023)*(4503599627370496+L):Math.pow(2,-1074)*L;return C?-d:d},readUint16:function(){return this.readByte()*256+this.readByte()},readUint32:function(){return this.readUint16()*65536+this.readUint16()},readUint64:function(){return this.readUint32()*4294967296+this.readUint32()}};function p(){}p.prototype={writeByte:a("writeByte"),result:a("result"),writeFloat16:a("writeFloat16"),writeFloat32:a("writeFloat32"),writeFloat64:a("writeFloat64"),writeUint16:function(y){this.writeByte(y>>8&255),this.writeByte(y&255)},writeUint32:function(y){this.writeUint16(y>>16&65535),this.writeUint16(y&65535)},writeUint64:function(y){if(y>=9007199254740992||y<=-9007199254740992)throw new Error("Cannot encode Uint64 of: "+y+" magnitude to big (floating point errors)");this.writeUint32(Math.floor(y/4294967296)),this.writeUint32(y%4294967296)},writeString:a("writeString"),canWriteBinary:function(y){return!1},writeBinary:a("writeChunk")};function u(y){var T=y.readByte(),D=T>>5,L=T&31;return{type:D,value:L}}function c(y,T){var D=y.value;if(D<24)return D;if(D==24)return T.readByte();if(D==25)return T.readUint16();if(D==26)return T.readUint32();if(D==27)return T.readUint64();if(D==31)return null;a("Additional info: "+D)()}function v(y,T,D){D.writeByte(y<<5|T)}function w(y,T,D){var L=y<<5;T<24?D.writeByte(L|T):T<256?(D.writeByte(L|24),D.writeByte(T)):T<65536?(D.writeByte(L|25),D.writeUint16(T)):T<4294967296?(D.writeByte(L|26),D.writeUint32(T)):(D.writeByte(L|27),D.writeUint64(T))}var b=new Error;function E(y){var T=u(y);switch(T.type){case 0:return c(T,y);case 1:return-1-c(T,y);case 2:return y.readChunk(c(T,y));case 3:var D=y.readChunk(c(T,y));return D.toString("utf-8");case 4:case 5:var L=c(T,y),O=[];if(L!==null){T.type===5&&(L*=2);for(var C=0;C<L;C++)O[C]=E(y)}else for(var d;(d=E(y))!==b;)O.push(d);if(T.type===5){for(var _={},C=0;C<O.length;C+=2)_[O[C]]=O[C+1];return _}else return O;case 6:var $=c(T,y),S=n[$],O=E(y);return S?S(O):O;case 7:if(T.value===25)return y.readFloat16();if(T.value===26)return y.readFloat32();if(T.value===27)return y.readFloat64();switch(c(T,y)){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case null:return b;default:throw new Error("Unknown fixed value: "+T.value)}default:throw new Error("Unsupported header: "+JSON.stringify(T))}throw new Error("not implemented yet")}function I(y,T){for(var D=0;D<o.length;D++){var L=o[D].fn(y);if(L!==void 0)return w(6,o[D].tag,T),I(L,T)}if(y&&typeof y.toCBOR=="function"&&(y=y.toCBOR()),y===!1)w(7,20,T);else if(y===!0)w(7,21,T);else if(y===null)w(7,22,T);else if(y===void 0)w(7,23,T);else if(typeof y=="number")Math.floor(y)===y&&y<9007199254740992&&y>-9007199254740992?y<0?w(1,-1-y,T):w(0,y,T):(v(7,27,T),T.writeFloat64(y));else if(typeof y=="string")T.writeString(y,function(d){w(3,d,T)});else if(T.canWriteBinary(y))T.writeBinary(y,function(d){w(2,d,T)});else if(typeof y=="object")if(M.config.useToJSON&&typeof y.toJSON=="function"&&(y=y.toJSON()),Array.isArray(y)){w(4,y.length,T);for(var D=0;D<y.length;D++)I(y[D],T)}else{var C=Object.keys(y);w(5,C.length,T);for(var D=0;D<C.length;D++){const _=parseInt(C[D]);isNaN(_)?(I(C[D],T),I(y[C[D]],T)):(I(_,T),I(y[C[D]],T))}}else throw new Error("CBOR encoding not supported: "+y)}var x=[],B=[],M={config:{useToJSON:!0},addWriter:function(y,T){typeof y=="string"?B.push(function(D){if(y===D)return T(D)}):B.push(y)},addReader:function(y,T){typeof y=="string"?x.push(function(D,L){if(y===L)return T(D,L)}):x.push(y)},encode:function(y,T){for(var D=0;D<B.length;D++){var L=B[D],C=L(T);if(C)return I(y,C),C.result()}throw new Error("Unsupported output format: "+T)},encodeDataItem:function(y,T){for(var D=0;D<B.length;D++){var L=B[D],C=L(T);if(C)return y.getTag()!==void 0?(I(y,C),C.result()):(I(y.getData(),C),C.result())}throw new Error("Unsupported output format: "+T)},decode:function(y,T){for(var D=0;D<x.length;D++){var L=x[D],C=L(y,T);if(C)return E(C)}throw new Error("Unsupported input format: "+T)},decodeToDataItem:function(y,T){for(var D=0;D<x.length;D++){var L=x[D],C=L(y,T);if(C){const d=E(C);return d instanceof t?d:new t(d)}}throw new Error("Unsupported input format: "+T)},addSemanticEncode:function(y,T){if(typeof y!="number"||y%1!==0||y<0)throw new Error("Tag must be a positive integer");return o.push({tag:y,fn:T}),this},addSemanticDecode:function(y,T){if(typeof y!="number"||y%1!==0||y<0)throw new Error("Tag must be a positive integer");return n[y]=T,this}};function q(y){this.buffer=y,this.pos=0}q.prototype=Object.create(l.prototype),q.prototype.peekByte=function(){return this.buffer[this.pos]},q.prototype.readByte=function(){return this.buffer[this.pos++]},q.prototype.readUint16=function(){var y=this.buffer.readUInt16BE(this.pos);return this.pos+=2,y},q.prototype.readUint32=function(){var y=this.buffer.readUInt32BE(this.pos);return this.pos+=4,y},q.prototype.readFloat32=function(){var y=this.buffer.readFloatBE(this.pos);return this.pos+=4,y},q.prototype.readFloat64=function(){var y=this.buffer.readDoubleBE(this.pos);return this.pos+=8,y},q.prototype.readChunk=function(y){var T=Buffer$e.alloc(y);return this.buffer.copy(T,0,this.pos,this.pos+=y),T};function U(y){this.byteLength=0,this.defaultBufferLength=16384,this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0,this.completeBuffers=[],this.stringFormat=y}U.prototype=Object.create(p.prototype),U.prototype.writeByte=function(y){this.latestBuffer[this.latestBufferOffset++]=y,this.latestBufferOffset>=this.latestBuffer.length&&(this.completeBuffers.push(this.latestBuffer),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0),this.byteLength++},U.prototype.writeFloat32=function(y){var T=Buffer$e.alloc(4);T.writeFloatBE(y,0),this.writeBuffer(T)},U.prototype.writeFloat64=function(y){var T=Buffer$e.alloc(8);T.writeDoubleBE(y,0),this.writeBuffer(T)},U.prototype.writeString=function(y,T){var D=Buffer$e.from(y,"utf-8");T(D.length),this.writeBuffer(D)},U.prototype.canWriteBinary=function(y){return y instanceof Buffer$e},U.prototype.writeBinary=function(y,T){T(y.length),this.writeBuffer(y)},U.prototype.writeBuffer=function(y){if(!(y instanceof Buffer$e))throw new TypeError("BufferWriter only accepts Buffers");this.latestBufferOffset?this.latestBuffer.length-this.latestBufferOffset>=y.length?(y.copy(this.latestBuffer,this.latestBufferOffset),this.latestBufferOffset+=y.length,this.latestBufferOffset>=this.latestBuffer.length&&(this.completeBuffers.push(this.latestBuffer),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0)):(this.completeBuffers.push(this.latestBuffer.slice(0,this.latestBufferOffset)),this.completeBuffers.push(y),this.latestBuffer=Buffer$e.alloc(this.defaultBufferLength),this.latestBufferOffset=0):this.completeBuffers.push(y),this.byteLength+=y.length},U.prototype.result=function(){for(var y=Buffer$e.alloc(this.byteLength),T=0,D=0;D<this.completeBuffers.length;D++){var L=this.completeBuffers[D];L.copy(y,T,0,L.length),T+=L.length}return this.latestBufferOffset&&this.latestBuffer.copy(y,T,0,this.latestBufferOffset),this.stringFormat?y.toString(this.stringFormat):y},typeof Buffer$e=="function"&&(M.addReader(function(y,T){if(Buffer$e.isBuffer(y))return new q(y);if(T==="hex"||T==="base64"){var D=Buffer$e.from(y,T);return new q(D)}}),M.addWriter(function(y){if(!y||y==="buffer")return new U;if(y==="hex"||y==="base64")return new U(y)}));function F(y){this.hex=y,this.pos=0}F.prototype=Object.create(l.prototype),F.prototype.peekByte=function(){var y=this.hex.substring(this.pos,2);return parseInt(y,16)},F.prototype.readByte=function(){var y=this.hex.substring(this.pos,this.pos+2);return this.pos+=2,parseInt(y,16)},F.prototype.readChunk=function(y){var T=this.hex.substring(this.pos,this.pos+y*2);return this.pos+=y*2,typeof Buffer$e=="function"?Buffer$e.from(T,"hex"):new s(T)};function j(y){this.$hex="",this.finalFormat=y||"hex"}return j.prototype=Object.create(p.prototype),j.prototype.writeByte=function(y){if(y<0||y>255)throw new Error("Byte value out of range: "+y);var T=y.toString(16);T.length==1&&(T="0"+T),this.$hex+=T},j.prototype.canWriteBinary=function(y){return y instanceof s||typeof Buffer$e=="function"&&y instanceof Buffer$e},j.prototype.writeBinary=function(y,T){if(y instanceof s)T(y.length()),this.$hex+=y.$hex;else if(typeof Buffer$e=="function"&&y instanceof Buffer$e)T(y.length),this.$hex+=y.toString("hex");else throw new TypeError("HexWriter only accepts BinaryHex or Buffers")},j.prototype.result=function(){return this.finalFormat==="buffer"&&typeof Buffer$e=="function"?Buffer$e.from(this.$hex,"hex"):new s(this.$hex).toString(this.finalFormat)},j.prototype.writeString=function(y,T){var D=s.fromUtf8String(y);T(D.length()),this.$hex+=D.$hex},M.addReader(function(y,T){if(y instanceof s||y.$hex)return new F(y.$hex);if(T==="hex")return new F(y)}),M.addWriter(function(y){if(y==="hex")return new j}),M}();return r.addSemanticEncode(0,function(s){if(s instanceof Date)return s.toISOString()}).addSemanticDecode(0,function(s){return new Date(s)}).addSemanticDecode(1,function(s){return new Date(s)}),r})})(cborSync$c);var cborSyncExports=cborSync$c.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DataItem=e.addWriter=e.addReader=e.addSemanticEncode=e.addSemanticDecode=e.decodeToDataItem=e.encodeDataItem=void 0;var t=cborSyncExports;Object.defineProperty(e,"encodeDataItem",{enumerable:!0,get:function(){return t.encodeDataItem}}),Object.defineProperty(e,"decodeToDataItem",{enumerable:!0,get:function(){return t.decodeToDataItem}}),Object.defineProperty(e,"addSemanticDecode",{enumerable:!0,get:function(){return t.addSemanticDecode}}),Object.defineProperty(e,"addSemanticEncode",{enumerable:!0,get:function(){return t.addSemanticEncode}}),Object.defineProperty(e,"addReader",{enumerable:!0,get:function(){return t.addReader}}),Object.defineProperty(e,"addWriter",{enumerable:!0,get:function(){return t.addWriter}});var r=DataItem$d;Object.defineProperty(e,"DataItem",{enumerable:!0,get:function(){return r.DataItem}})})(lib$d);Object.defineProperty(utils$n,"__esModule",{value:!0});utils$n.patchTags=void 0;const lib_1$9=lib$d,alreadyPatchedTag=[],patchTags=e=>{e.forEach(t=>{alreadyPatchedTag.find(r=>r===t)||((0,lib_1$9.addSemanticEncode)(t,r=>{if(r instanceof lib_1$9.DataItem&&r.getTag()===t)return r.getData()}),(0,lib_1$9.addSemanticDecode)(t,r=>new lib_1$9.DataItem(r,t)),alreadyPatchedTag.push(t))})};utils$n.patchTags=patchTags;var RegistryType$d={};Object.defineProperty(RegistryType$d,"__esModule",{value:!0});RegistryType$d.RegistryTypes=RegistryType$d.RegistryType=void 0;let RegistryType$c=class{constructor(t,r){this.type=t,this.tag=r,this.getTag=()=>this.tag,this.getType=()=>this.type}};RegistryType$d.RegistryType=RegistryType$c;RegistryType$d.RegistryTypes={UUID:new RegistryType$c("uuid",37),BYTES:new RegistryType$c("bytes",void 0),CRYPTO_HDKEY:new RegistryType$c("crypto-hdkey",303),CRYPTO_KEYPATH:new RegistryType$c("crypto-keypath",304),CRYPTO_COIN_INFO:new RegistryType$c("crypto-coin-info",305),CRYPTO_ECKEY:new RegistryType$c("crypto-eckey",306),CRYPTO_OUTPUT:new RegistryType$c("crypto-output",308),CRYPTO_PSBT:new RegistryType$c("crypto-psbt",310),CRYPTO_ACCOUNT:new RegistryType$c("crypto-account",311),CRYPTO_MULTI_ACCOUNTS:new RegistryType$c("crypto-multi-accounts",1103),QR_HARDWARE_CALL:new RegistryType$c("qr-hardware-call",1201),KEY_DERIVATION_CALL:new RegistryType$c("key-derivation-call",1301),KEY_DERIVATION_SCHEMA:new RegistryType$c("key-derivation-schema",1302)};var ScriptExpression$c={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ScriptExpressions=e.ScriptExpression=void 0;class t{constructor(s,o){this.tag=s,this.expression=o,this.getTag=()=>this.tag,this.getExpression=()=>this.expression}}e.ScriptExpression=t,t.fromTag=r=>Object.values(e.ScriptExpressions).find(o=>o.getTag()===r),e.ScriptExpressions={SCRIPT_HASH:new t(400,"sh"),WITNESS_SCRIPT_HASH:new t(401,"wsh"),PUBLIC_KEY:new t(402,"pk"),PUBLIC_KEY_HASH:new t(403,"pkh"),WITNESS_PUBLIC_KEY_HASH:new t(404,"wpkh"),COMBO:new t(405,"combo"),MULTISIG:new t(406,"multi"),SORTED_MULTISIG:new t(407,"sortedmulti"),ADDRESS:new t(307,"addr"),RAW_SCRIPT:new t(408,"raw")}})(ScriptExpression$c);Object.defineProperty(patchCBOR$c,"__esModule",{value:!0});const utils_1$o=utils$n,RegistryType_1$9=RegistryType$d,ScriptExpression_1$1=ScriptExpression$c,registryTags=Object.values(RegistryType_1$9.RegistryTypes).filter(e=>!!e.getTag()).map(e=>e.getTag()),scriptExpressionTags=Object.values(ScriptExpression_1$1.ScriptExpressions).map(e=>e.getTag());(0,utils_1$o.patchTags)(registryTags.concat(scriptExpressionTags));var dist$t={};(function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t={},r={};r.byteLength=c,r.toByteArray=w,r.fromByteArray=I;for(var s=[],o=[],n=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=a.length;l<p;++l)s[l]=a[l],o[a.charCodeAt(l)]=l;o[45]=62,o[95]=63;function u(M){var q=M.length;if(q%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var U=M.indexOf("=");U===-1&&(U=q);var F=U===q?0:4-U%4;return[U,F]}function c(M){var q=u(M),U=q[0],F=q[1];return(U+F)*3/4-F}function v(M,q,U){return(q+U)*3/4-U}function w(M){var q,U=u(M),F=U[0],j=U[1],y=new n(v(M,F,j)),T=0,D=j>0?F-4:F,L;for(L=0;L<D;L+=4)q=o[M.charCodeAt(L)]<<18|o[M.charCodeAt(L+1)]<<12|o[M.charCodeAt(L+2)]<<6|o[M.charCodeAt(L+3)],y[T++]=q>>16&255,y[T++]=q>>8&255,y[T++]=q&255;return j===2&&(q=o[M.charCodeAt(L)]<<2|o[M.charCodeAt(L+1)]>>4,y[T++]=q&255),j===1&&(q=o[M.charCodeAt(L)]<<10|o[M.charCodeAt(L+1)]<<4|o[M.charCodeAt(L+2)]>>2,y[T++]=q>>8&255,y[T++]=q&255),y}function b(M){return s[M>>18&63]+s[M>>12&63]+s[M>>6&63]+s[M&63]}function E(M,q,U){for(var F,j=[],y=q;y<U;y+=3)F=(M[y]<<16&16711680)+(M[y+1]<<8&65280)+(M[y+2]&255),j.push(b(F));return j.join("")}function I(M){for(var q,U=M.length,F=U%3,j=[],y=16383,T=0,D=U-F;T<D;T+=y)j.push(E(M,T,T+y>D?D:T+y));return F===1?(q=M[U-1],j.push(s[q>>2]+s[q<<4&63]+"==")):F===2&&(q=(M[U-2]<<8)+M[U-1],j.push(s[q>>10]+s[q>>4&63]+s[q<<2&63]+"=")),j.join("")}var x={};x.read=function(M,q,U,F,j){var y,T,D=j*8-F-1,L=(1<<D)-1,C=L>>1,d=-7,_=U?j-1:0,$=U?-1:1,S=M[q+_];for(_+=$,y=S&(1<<-d)-1,S>>=-d,d+=D;d>0;y=y*256+M[q+_],_+=$,d-=8);for(T=y&(1<<-d)-1,y>>=-d,d+=F;d>0;T=T*256+M[q+_],_+=$,d-=8);if(y===0)y=1-C;else{if(y===L)return T?NaN:(S?-1:1)*(1/0);T=T+Math.pow(2,F),y=y-C}return(S?-1:1)*T*Math.pow(2,y-F)},x.write=function(M,q,U,F,j,y){var T,D,L,C=y*8-j-1,d=(1<<C)-1,_=d>>1,$=j===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=F?0:y-1,O=F?1:-1,N=q<0||q===0&&1/q<0?1:0;for(q=Math.abs(q),isNaN(q)||q===1/0?(D=isNaN(q)?1:0,T=d):(T=Math.floor(Math.log(q)/Math.LN2),q*(L=Math.pow(2,-T))<1&&(T--,L*=2),T+_>=1?q+=$/L:q+=$*Math.pow(2,1-_),q*L>=2&&(T++,L/=2),T+_>=d?(D=0,T=d):T+_>=1?(D=(q*L-1)*Math.pow(2,j),T=T+_):(D=q*Math.pow(2,_-1)*Math.pow(2,j),T=0));j>=8;M[U+S]=D&255,S+=O,D/=256,j-=8);for(T=T<<j|D,C+=j;C>0;M[U+S]=T&255,S+=O,T/=256,C-=8);M[U+S-O]|=N*128};(function(M){const q=r,U=x,F=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;M.Buffer=d,M.SlowBuffer=J,M.INSPECT_MAX_BYTES=50;const j=2147483647;M.kMaxLength=j;const{Uint8Array:y,ArrayBuffer:T,SharedArrayBuffer:D}=globalThis;d.TYPED_ARRAY_SUPPORT=L(),!d.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 L(){try{const pe=new y(1),ee={foo:function(){return 42}};return Object.setPrototypeOf(ee,y.prototype),Object.setPrototypeOf(pe,ee),pe.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function C(pe){if(pe>j)throw new RangeError('The value "'+pe+'" is invalid for option "size"');const ee=new y(pe);return Object.setPrototypeOf(ee,d.prototype),ee}function d(pe,ee,ce){if(typeof pe=="number"){if(typeof ee=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return O(pe)}return _(pe,ee,ce)}d.poolSize=8192;function _(pe,ee,ce){if(typeof pe=="string")return N(pe,ee);if(T.isView(pe))return A(pe);if(pe==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof pe);if(rt(pe,T)||pe&&rt(pe.buffer,T)||typeof D<"u"&&(rt(pe,D)||pe&&rt(pe.buffer,D)))return m(pe,ee,ce);if(typeof pe=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Te=pe.valueOf&&pe.valueOf();if(Te!=null&&Te!==pe)return d.from(Te,ee,ce);const Oe=P(pe);if(Oe)return Oe;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof pe[Symbol.toPrimitive]=="function")return d.from(pe[Symbol.toPrimitive]("string"),ee,ce);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof pe)}d.from=function(pe,ee,ce){return _(pe,ee,ce)},Object.setPrototypeOf(d.prototype,y.prototype),Object.setPrototypeOf(d,y);function $(pe){if(typeof pe!="number")throw new TypeError('"size" argument must be of type number');if(pe<0)throw new RangeError('The value "'+pe+'" is invalid for option "size"')}function S(pe,ee,ce){return $(pe),pe<=0?C(pe):ee!==void 0?typeof ce=="string"?C(pe).fill(ee,ce):C(pe).fill(ee):C(pe)}d.alloc=function(pe,ee,ce){return S(pe,ee,ce)};function O(pe){return $(pe),C(pe<0?0:H(pe)|0)}d.allocUnsafe=function(pe){return O(pe)},d.allocUnsafeSlow=function(pe){return O(pe)};function N(pe,ee){if((typeof ee!="string"||ee==="")&&(ee="utf8"),!d.isEncoding(ee))throw new TypeError("Unknown encoding: "+ee);const ce=X(pe,ee)|0;let Te=C(ce);const Oe=Te.write(pe,ee);return Oe!==ce&&(Te=Te.slice(0,Oe)),Te}function k(pe){const ee=pe.length<0?0:H(pe.length)|0,ce=C(ee);for(let Te=0;Te<ee;Te+=1)ce[Te]=pe[Te]&255;return ce}function A(pe){if(rt(pe,y)){const ee=new y(pe);return m(ee.buffer,ee.byteOffset,ee.byteLength)}return k(pe)}function m(pe,ee,ce){if(ee<0||pe.byteLength<ee)throw new RangeError('"offset" is outside of buffer bounds');if(pe.byteLength<ee+(ce||0))throw new RangeError('"length" is outside of buffer bounds');let Te;return ee===void 0&&ce===void 0?Te=new y(pe):ce===void 0?Te=new y(pe,ee):Te=new y(pe,ee,ce),Object.setPrototypeOf(Te,d.prototype),Te}function P(pe){if(d.isBuffer(pe)){const ee=H(pe.length)|0,ce=C(ee);return ce.length===0||pe.copy(ce,0,0,ee),ce}if(pe.length!==void 0)return typeof pe.length!="number"||mt(pe.length)?C(0):k(pe);if(pe.type==="Buffer"&&Array.isArray(pe.data))return k(pe.data)}function H(pe){if(pe>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return pe|0}function J(pe){return+pe!=pe&&(pe=0),d.alloc(+pe)}d.isBuffer=function(ee){return ee!=null&&ee._isBuffer===!0&&ee!==d.prototype},d.compare=function(ee,ce){if(rt(ee,y)&&(ee=d.from(ee,ee.offset,ee.byteLength)),rt(ce,y)&&(ce=d.from(ce,ce.offset,ce.byteLength)),!d.isBuffer(ee)||!d.isBuffer(ce))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(ee===ce)return 0;let Te=ee.length,Oe=ce.length;for(let Ve=0,qe=Math.min(Te,Oe);Ve<qe;++Ve)if(ee[Ve]!==ce[Ve]){Te=ee[Ve],Oe=ce[Ve];break}return Te<Oe?-1:Oe<Te?1:0},d.isEncoding=function(ee){switch(String(ee).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}},d.concat=function(ee,ce){if(!Array.isArray(ee))throw new TypeError('"list" argument must be an Array of Buffers');if(ee.length===0)return d.alloc(0);let Te;if(ce===void 0)for(ce=0,Te=0;Te<ee.length;++Te)ce+=ee[Te].length;const Oe=d.allocUnsafe(ce);let Ve=0;for(Te=0;Te<ee.length;++Te){let qe=ee[Te];if(rt(qe,y))Ve+qe.length>Oe.length?(d.isBuffer(qe)||(qe=d.from(qe)),qe.copy(Oe,Ve)):y.prototype.set.call(Oe,qe,Ve);else if(d.isBuffer(qe))qe.copy(Oe,Ve);else throw new TypeError('"list" argument must be an Array of Buffers');Ve+=qe.length}return Oe};function X(pe,ee){if(d.isBuffer(pe))return pe.length;if(T.isView(pe)||rt(pe,T))return pe.byteLength;if(typeof pe!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof pe);const ce=pe.length,Te=arguments.length>2&&arguments[2]===!0;if(!Te&&ce===0)return 0;let Oe=!1;for(;;)switch(ee){case"ascii":case"latin1":case"binary":return ce;case"utf8":case"utf-8":return ot(pe).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce*2;case"hex":return ce>>>1;case"base64":return ht(pe).length;default:if(Oe)return Te?-1:ot(pe).length;ee=(""+ee).toLowerCase(),Oe=!0}}d.byteLength=X;function se(pe,ee,ce){let Te=!1;if((ee===void 0||ee<0)&&(ee=0),ee>this.length||((ce===void 0||ce>this.length)&&(ce=this.length),ce<=0)||(ce>>>=0,ee>>>=0,ce<=ee))return"";for(pe||(pe="utf8");;)switch(pe){case"hex":return Ue(this,ee,ce);case"utf8":case"utf-8":return me(this,ee,ce);case"ascii":return Ce(this,ee,ce);case"latin1":case"binary":return $e(this,ee,ce);case"base64":return le(this,ee,ce);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Me(this,ee,ce);default:if(Te)throw new TypeError("Unknown encoding: "+pe);pe=(pe+"").toLowerCase(),Te=!0}}d.prototype._isBuffer=!0;function ne(pe,ee,ce){const Te=pe[ee];pe[ee]=pe[ce],pe[ce]=Te}d.prototype.swap16=function(){const ee=this.length;if(ee%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let ce=0;ce<ee;ce+=2)ne(this,ce,ce+1);return this},d.prototype.swap32=function(){const ee=this.length;if(ee%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let ce=0;ce<ee;ce+=4)ne(this,ce,ce+3),ne(this,ce+1,ce+2);return this},d.prototype.swap64=function(){const ee=this.length;if(ee%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let ce=0;ce<ee;ce+=8)ne(this,ce,ce+7),ne(this,ce+1,ce+6),ne(this,ce+2,ce+5),ne(this,ce+3,ce+4);return this},d.prototype.toString=function(){const ee=this.length;return ee===0?"":arguments.length===0?me(this,0,ee):se.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(ee){if(!d.isBuffer(ee))throw new TypeError("Argument must be a Buffer");return this===ee?!0:d.compare(this,ee)===0},d.prototype.inspect=function(){let ee="";const ce=M.INSPECT_MAX_BYTES;return ee=this.toString("hex",0,ce).replace(/(.{2})/g,"$1 ").trim(),this.length>ce&&(ee+=" ... "),"<Buffer "+ee+">"},F&&(d.prototype[F]=d.prototype.inspect),d.prototype.compare=function(ee,ce,Te,Oe,Ve){if(rt(ee,y)&&(ee=d.from(ee,ee.offset,ee.byteLength)),!d.isBuffer(ee))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof ee);if(ce===void 0&&(ce=0),Te===void 0&&(Te=ee?ee.length:0),Oe===void 0&&(Oe=0),Ve===void 0&&(Ve=this.length),ce<0||Te>ee.length||Oe<0||Ve>this.length)throw new RangeError("out of range index");if(Oe>=Ve&&ce>=Te)return 0;if(Oe>=Ve)return-1;if(ce>=Te)return 1;if(ce>>>=0,Te>>>=0,Oe>>>=0,Ve>>>=0,this===ee)return 0;let qe=Ve-Oe,Ye=Te-ce;const pt=Math.min(qe,Ye),Ge=this.slice(Oe,Ve),Xe=ee.slice(ce,Te);for(let lt=0;lt<pt;++lt)if(Ge[lt]!==Xe[lt]){qe=Ge[lt],Ye=Xe[lt];break}return qe<Ye?-1:Ye<qe?1:0};function Z(pe,ee,ce,Te,Oe){if(pe.length===0)return-1;if(typeof ce=="string"?(Te=ce,ce=0):ce>2147483647?ce=2147483647:ce<-2147483648&&(ce=-2147483648),ce=+ce,mt(ce)&&(ce=Oe?0:pe.length-1),ce<0&&(ce=pe.length+ce),ce>=pe.length){if(Oe)return-1;ce=pe.length-1}else if(ce<0)if(Oe)ce=0;else return-1;if(typeof ee=="string"&&(ee=d.from(ee,Te)),d.isBuffer(ee))return ee.length===0?-1:oe(pe,ee,ce,Te,Oe);if(typeof ee=="number")return ee=ee&255,typeof y.prototype.indexOf=="function"?Oe?y.prototype.indexOf.call(pe,ee,ce):y.prototype.lastIndexOf.call(pe,ee,ce):oe(pe,[ee],ce,Te,Oe);throw new TypeError("val must be string, number or Buffer")}function oe(pe,ee,ce,Te,Oe){let Ve=1,qe=pe.length,Ye=ee.length;if(Te!==void 0&&(Te=String(Te).toLowerCase(),Te==="ucs2"||Te==="ucs-2"||Te==="utf16le"||Te==="utf-16le")){if(pe.length<2||ee.length<2)return-1;Ve=2,qe/=2,Ye/=2,ce/=2}function pt(Xe,lt){return Ve===1?Xe[lt]:Xe.readUInt16BE(lt*Ve)}let Ge;if(Oe){let Xe=-1;for(Ge=ce;Ge<qe;Ge++)if(pt(pe,Ge)===pt(ee,Xe===-1?0:Ge-Xe)){if(Xe===-1&&(Xe=Ge),Ge-Xe+1===Ye)return Xe*Ve}else Xe!==-1&&(Ge-=Ge-Xe),Xe=-1}else for(ce+Ye>qe&&(ce=qe-Ye),Ge=ce;Ge>=0;Ge--){let Xe=!0;for(let lt=0;lt<Ye;lt++)if(pt(pe,Ge+lt)!==pt(ee,lt)){Xe=!1;break}if(Xe)return Ge}return-1}d.prototype.includes=function(ee,ce,Te){return this.indexOf(ee,ce,Te)!==-1},d.prototype.indexOf=function(ee,ce,Te){return Z(this,ee,ce,Te,!0)},d.prototype.lastIndexOf=function(ee,ce,Te){return Z(this,ee,ce,Te,!1)};function ye(pe,ee,ce,Te){ce=Number(ce)||0;const Oe=pe.length-ce;Te?(Te=Number(Te),Te>Oe&&(Te=Oe)):Te=Oe;const Ve=ee.length;Te>Ve/2&&(Te=Ve/2);let qe;for(qe=0;qe<Te;++qe){const Ye=parseInt(ee.substr(qe*2,2),16);if(mt(Ye))return qe;pe[ce+qe]=Ye}return qe}function Y(pe,ee,ce,Te){return Je(ot(ee,pe.length-ce),pe,ce,Te)}function G(pe,ee,ce,Te){return Je(He(ee),pe,ce,Te)}function V(pe,ee,ce,Te){return Je(ht(ee),pe,ce,Te)}function te(pe,ee,ce,Te){return Je(We(ee,pe.length-ce),pe,ce,Te)}d.prototype.write=function(ee,ce,Te,Oe){if(ce===void 0)Oe="utf8",Te=this.length,ce=0;else if(Te===void 0&&typeof ce=="string")Oe=ce,Te=this.length,ce=0;else if(isFinite(ce))ce=ce>>>0,isFinite(Te)?(Te=Te>>>0,Oe===void 0&&(Oe="utf8")):(Oe=Te,Te=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Ve=this.length-ce;if((Te===void 0||Te>Ve)&&(Te=Ve),ee.length>0&&(Te<0||ce<0)||ce>this.length)throw new RangeError("Attempt to write outside buffer bounds");Oe||(Oe="utf8");let qe=!1;for(;;)switch(Oe){case"hex":return ye(this,ee,ce,Te);case"utf8":case"utf-8":return Y(this,ee,ce,Te);case"ascii":case"latin1":case"binary":return G(this,ee,ce,Te);case"base64":return V(this,ee,ce,Te);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return te(this,ee,ce,Te);default:if(qe)throw new TypeError("Unknown encoding: "+Oe);Oe=(""+Oe).toLowerCase(),qe=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function le(pe,ee,ce){return ee===0&&ce===pe.length?q.fromByteArray(pe):q.fromByteArray(pe.slice(ee,ce))}function me(pe,ee,ce){ce=Math.min(pe.length,ce);const Te=[];let Oe=ee;for(;Oe<ce;){const Ve=pe[Oe];let qe=null,Ye=Ve>239?4:Ve>223?3:Ve>191?2:1;if(Oe+Ye<=ce){let pt,Ge,Xe,lt;switch(Ye){case 1:Ve<128&&(qe=Ve);break;case 2:pt=pe[Oe+1],(pt&192)===128&&(lt=(Ve&31)<<6|pt&63,lt>127&&(qe=lt));break;case 3:pt=pe[Oe+1],Ge=pe[Oe+2],(pt&192)===128&&(Ge&192)===128&&(lt=(Ve&15)<<12|(pt&63)<<6|Ge&63,lt>2047&&(lt<55296||lt>57343)&&(qe=lt));break;case 4:pt=pe[Oe+1],Ge=pe[Oe+2],Xe=pe[Oe+3],(pt&192)===128&&(Ge&192)===128&&(Xe&192)===128&&(lt=(Ve&15)<<18|(pt&63)<<12|(Ge&63)<<6|Xe&63,lt>65535&&lt<1114112&&(qe=lt))}}qe===null?(qe=65533,Ye=1):qe>65535&&(qe-=65536,Te.push(qe>>>10&1023|55296),qe=56320|qe&1023),Te.push(qe),Oe+=Ye}return Be(Te)}const Re=4096;function Be(pe){const ee=pe.length;if(ee<=Re)return String.fromCharCode.apply(String,pe);let ce="",Te=0;for(;Te<ee;)ce+=String.fromCharCode.apply(String,pe.slice(Te,Te+=Re));return ce}function Ce(pe,ee,ce){let Te="";ce=Math.min(pe.length,ce);for(let Oe=ee;Oe<ce;++Oe)Te+=String.fromCharCode(pe[Oe]&127);return Te}function $e(pe,ee,ce){let Te="";ce=Math.min(pe.length,ce);for(let Oe=ee;Oe<ce;++Oe)Te+=String.fromCharCode(pe[Oe]);return Te}function Ue(pe,ee,ce){const Te=pe.length;(!ee||ee<0)&&(ee=0),(!ce||ce<0||ce>Te)&&(ce=Te);let Oe="";for(let Ve=ee;Ve<ce;++Ve)Oe+=Ze[pe[Ve]];return Oe}function Me(pe,ee,ce){const Te=pe.slice(ee,ce);let Oe="";for(let Ve=0;Ve<Te.length-1;Ve+=2)Oe+=String.fromCharCode(Te[Ve]+Te[Ve+1]*256);return Oe}d.prototype.slice=function(ee,ce){const Te=this.length;ee=~~ee,ce=ce===void 0?Te:~~ce,ee<0?(ee+=Te,ee<0&&(ee=0)):ee>Te&&(ee=Te),ce<0?(ce+=Te,ce<0&&(ce=0)):ce>Te&&(ce=Te),ce<ee&&(ce=ee);const Oe=this.subarray(ee,ce);return Object.setPrototypeOf(Oe,d.prototype),Oe};function ke(pe,ee,ce){if(pe%1!==0||pe<0)throw new RangeError("offset is not uint");if(pe+ee>ce)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee],Ve=1,qe=0;for(;++qe<ce&&(Ve*=256);)Oe+=this[ee+qe]*Ve;return Oe},d.prototype.readUintBE=d.prototype.readUIntBE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee+--ce],Ve=1;for(;ce>0&&(Ve*=256);)Oe+=this[ee+--ce]*Ve;return Oe},d.prototype.readUint8=d.prototype.readUInt8=function(ee,ce){return ee=ee>>>0,ce||ke(ee,1,this.length),this[ee]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,2,this.length),this[ee]|this[ee+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,2,this.length),this[ee]<<8|this[ee+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),(this[ee]|this[ee+1]<<8|this[ee+2]<<16)+this[ee+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]*16777216+(this[ee+1]<<16|this[ee+2]<<8|this[ee+3])},d.prototype.readBigUInt64LE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=ce+this[++ee]*2**8+this[++ee]*2**16+this[++ee]*2**24,Ve=this[++ee]+this[++ee]*2**8+this[++ee]*2**16+Te*2**24;return BigInt(Oe)+(BigInt(Ve)<<BigInt(32))}),d.prototype.readBigUInt64BE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=ce*2**24+this[++ee]*2**16+this[++ee]*2**8+this[++ee],Ve=this[++ee]*2**24+this[++ee]*2**16+this[++ee]*2**8+Te;return(BigInt(Oe)<<BigInt(32))+BigInt(Ve)}),d.prototype.readIntLE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=this[ee],Ve=1,qe=0;for(;++qe<ce&&(Ve*=256);)Oe+=this[ee+qe]*Ve;return Ve*=128,Oe>=Ve&&(Oe-=Math.pow(2,8*ce)),Oe},d.prototype.readIntBE=function(ee,ce,Te){ee=ee>>>0,ce=ce>>>0,Te||ke(ee,ce,this.length);let Oe=ce,Ve=1,qe=this[ee+--Oe];for(;Oe>0&&(Ve*=256);)qe+=this[ee+--Oe]*Ve;return Ve*=128,qe>=Ve&&(qe-=Math.pow(2,8*ce)),qe},d.prototype.readInt8=function(ee,ce){return ee=ee>>>0,ce||ke(ee,1,this.length),this[ee]&128?(255-this[ee]+1)*-1:this[ee]},d.prototype.readInt16LE=function(ee,ce){ee=ee>>>0,ce||ke(ee,2,this.length);const Te=this[ee]|this[ee+1]<<8;return Te&32768?Te|4294901760:Te},d.prototype.readInt16BE=function(ee,ce){ee=ee>>>0,ce||ke(ee,2,this.length);const Te=this[ee+1]|this[ee]<<8;return Te&32768?Te|4294901760:Te},d.prototype.readInt32LE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]|this[ee+1]<<8|this[ee+2]<<16|this[ee+3]<<24},d.prototype.readInt32BE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),this[ee]<<24|this[ee+1]<<16|this[ee+2]<<8|this[ee+3]},d.prototype.readBigInt64LE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=this[ee+4]+this[ee+5]*2**8+this[ee+6]*2**16+(Te<<24);return(BigInt(Oe)<<BigInt(32))+BigInt(ce+this[++ee]*2**8+this[++ee]*2**16+this[++ee]*2**24)}),d.prototype.readBigInt64BE=it(function(ee){ee=ee>>>0,we(ee,"offset");const ce=this[ee],Te=this[ee+7];(ce===void 0||Te===void 0)&&Ne(ee,this.length-8);const Oe=(ce<<24)+this[++ee]*2**16+this[++ee]*2**8+this[++ee];return(BigInt(Oe)<<BigInt(32))+BigInt(this[++ee]*2**24+this[++ee]*2**16+this[++ee]*2**8+Te)}),d.prototype.readFloatLE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),U.read(this,ee,!0,23,4)},d.prototype.readFloatBE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,4,this.length),U.read(this,ee,!1,23,4)},d.prototype.readDoubleLE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,8,this.length),U.read(this,ee,!0,52,8)},d.prototype.readDoubleBE=function(ee,ce){return ee=ee>>>0,ce||ke(ee,8,this.length),U.read(this,ee,!1,52,8)};function tt(pe,ee,ce,Te,Oe,Ve){if(!d.isBuffer(pe))throw new TypeError('"buffer" argument must be a Buffer instance');if(ee>Oe||ee<Ve)throw new RangeError('"value" argument is out of bounds');if(ce+Te>pe.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,Te=Te>>>0,!Oe){const Ye=Math.pow(2,8*Te)-1;tt(this,ee,ce,Te,Ye,0)}let Ve=1,qe=0;for(this[ce]=ee&255;++qe<Te&&(Ve*=256);)this[ce+qe]=ee/Ve&255;return ce+Te},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,Te=Te>>>0,!Oe){const Ye=Math.pow(2,8*Te)-1;tt(this,ee,ce,Te,Ye,0)}let Ve=Te-1,qe=1;for(this[ce+Ve]=ee&255;--Ve>=0&&(qe*=256);)this[ce+Ve]=ee/qe&255;return ce+Te},d.prototype.writeUint8=d.prototype.writeUInt8=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,1,255,0),this[ce]=ee&255,ce+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,65535,0),this[ce]=ee&255,this[ce+1]=ee>>>8,ce+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,65535,0),this[ce]=ee>>>8,this[ce+1]=ee&255,ce+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,4294967295,0),this[ce+3]=ee>>>24,this[ce+2]=ee>>>16,this[ce+1]=ee>>>8,this[ce]=ee&255,ce+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,4294967295,0),this[ce]=ee>>>24,this[ce+1]=ee>>>16,this[ce+2]=ee>>>8,this[ce+3]=ee&255,ce+4};function Ie(pe,ee,ce,Te,Oe){ue(ee,Te,Oe,pe,ce,7);let Ve=Number(ee&BigInt(4294967295));pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve,Ve=Ve>>8,pe[ce++]=Ve;let qe=Number(ee>>BigInt(32)&BigInt(4294967295));return pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,qe=qe>>8,pe[ce++]=qe,ce}function xe(pe,ee,ce,Te,Oe){ue(ee,Te,Oe,pe,ce,7);let Ve=Number(ee&BigInt(4294967295));pe[ce+7]=Ve,Ve=Ve>>8,pe[ce+6]=Ve,Ve=Ve>>8,pe[ce+5]=Ve,Ve=Ve>>8,pe[ce+4]=Ve;let qe=Number(ee>>BigInt(32)&BigInt(4294967295));return pe[ce+3]=qe,qe=qe>>8,pe[ce+2]=qe,qe=qe>>8,pe[ce+1]=qe,qe=qe>>8,pe[ce]=qe,ce+8}d.prototype.writeBigUInt64LE=it(function(ee,ce=0){return Ie(this,ee,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=it(function(ee,ce=0){return xe(this,ee,ce,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,!Oe){const pt=Math.pow(2,8*Te-1);tt(this,ee,ce,Te,pt-1,-pt)}let Ve=0,qe=1,Ye=0;for(this[ce]=ee&255;++Ve<Te&&(qe*=256);)ee<0&&Ye===0&&this[ce+Ve-1]!==0&&(Ye=1),this[ce+Ve]=(ee/qe>>0)-Ye&255;return ce+Te},d.prototype.writeIntBE=function(ee,ce,Te,Oe){if(ee=+ee,ce=ce>>>0,!Oe){const pt=Math.pow(2,8*Te-1);tt(this,ee,ce,Te,pt-1,-pt)}let Ve=Te-1,qe=1,Ye=0;for(this[ce+Ve]=ee&255;--Ve>=0&&(qe*=256);)ee<0&&Ye===0&&this[ce+Ve+1]!==0&&(Ye=1),this[ce+Ve]=(ee/qe>>0)-Ye&255;return ce+Te},d.prototype.writeInt8=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,1,127,-128),ee<0&&(ee=255+ee+1),this[ce]=ee&255,ce+1},d.prototype.writeInt16LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,32767,-32768),this[ce]=ee&255,this[ce+1]=ee>>>8,ce+2},d.prototype.writeInt16BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,2,32767,-32768),this[ce]=ee>>>8,this[ce+1]=ee&255,ce+2},d.prototype.writeInt32LE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,2147483647,-2147483648),this[ce]=ee&255,this[ce+1]=ee>>>8,this[ce+2]=ee>>>16,this[ce+3]=ee>>>24,ce+4},d.prototype.writeInt32BE=function(ee,ce,Te){return ee=+ee,ce=ce>>>0,Te||tt(this,ee,ce,4,2147483647,-2147483648),ee<0&&(ee=4294967295+ee+1),this[ce]=ee>>>24,this[ce+1]=ee>>>16,this[ce+2]=ee>>>8,this[ce+3]=ee&255,ce+4},d.prototype.writeBigInt64LE=it(function(ee,ce=0){return Ie(this,ee,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=it(function(ee,ce=0){return xe(this,ee,ce,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function he(pe,ee,ce,Te,Oe,Ve){if(ce+Te>pe.length)throw new RangeError("Index out of range");if(ce<0)throw new RangeError("Index out of range")}function ae(pe,ee,ce,Te,Oe){return ee=+ee,ce=ce>>>0,Oe||he(pe,ee,ce,4),U.write(pe,ee,ce,Te,23,4),ce+4}d.prototype.writeFloatLE=function(ee,ce,Te){return ae(this,ee,ce,!0,Te)},d.prototype.writeFloatBE=function(ee,ce,Te){return ae(this,ee,ce,!1,Te)};function be(pe,ee,ce,Te,Oe){return ee=+ee,ce=ce>>>0,Oe||he(pe,ee,ce,8),U.write(pe,ee,ce,Te,52,8),ce+8}d.prototype.writeDoubleLE=function(ee,ce,Te){return be(this,ee,ce,!0,Te)},d.prototype.writeDoubleBE=function(ee,ce,Te){return be(this,ee,ce,!1,Te)},d.prototype.copy=function(ee,ce,Te,Oe){if(!d.isBuffer(ee))throw new TypeError("argument should be a Buffer");if(Te||(Te=0),!Oe&&Oe!==0&&(Oe=this.length),ce>=ee.length&&(ce=ee.length),ce||(ce=0),Oe>0&&Oe<Te&&(Oe=Te),Oe===Te||ee.length===0||this.length===0)return 0;if(ce<0)throw new RangeError("targetStart out of bounds");if(Te<0||Te>=this.length)throw new RangeError("Index out of range");if(Oe<0)throw new RangeError("sourceEnd out of bounds");Oe>this.length&&(Oe=this.length),ee.length-ce<Oe-Te&&(Oe=ee.length-ce+Te);const Ve=Oe-Te;return this===ee&&typeof y.prototype.copyWithin=="function"?this.copyWithin(ce,Te,Oe):y.prototype.set.call(ee,this.subarray(Te,Oe),ce),Ve},d.prototype.fill=function(ee,ce,Te,Oe){if(typeof ee=="string"){if(typeof ce=="string"?(Oe=ce,ce=0,Te=this.length):typeof Te=="string"&&(Oe=Te,Te=this.length),Oe!==void 0&&typeof Oe!="string")throw new TypeError("encoding must be a string");if(typeof Oe=="string"&&!d.isEncoding(Oe))throw new TypeError("Unknown encoding: "+Oe);if(ee.length===1){const qe=ee.charCodeAt(0);(Oe==="utf8"&&qe<128||Oe==="latin1")&&(ee=qe)}}else typeof ee=="number"?ee=ee&255:typeof ee=="boolean"&&(ee=Number(ee));if(ce<0||this.length<ce||this.length<Te)throw new RangeError("Out of range index");if(Te<=ce)return this;ce=ce>>>0,Te=Te===void 0?this.length:Te>>>0,ee||(ee=0);let Ve;if(typeof ee=="number")for(Ve=ce;Ve<Te;++Ve)this[Ve]=ee;else{const qe=d.isBuffer(ee)?ee:d.from(ee,Oe),Ye=qe.length;if(Ye===0)throw new TypeError('The value "'+ee+'" is invalid for argument "value"');for(Ve=0;Ve<Te-ce;++Ve)this[Ve+ce]=qe[Ve%Ye]}return this};const Ae={};function re(pe,ee,ce){Ae[pe]=class extends ce{constructor(){super(),Object.defineProperty(this,"message",{value:ee.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${pe}]`,this.stack,delete this.name}get code(){return pe}set code(Oe){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Oe,writable:!0})}toString(){return`${this.name} [${pe}]: ${this.message}`}}}re("ERR_BUFFER_OUT_OF_BOUNDS",function(pe){return pe?`${pe} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),re("ERR_INVALID_ARG_TYPE",function(pe,ee){return`The "${pe}" argument must be of type number. Received type ${typeof ee}`},TypeError),re("ERR_OUT_OF_RANGE",function(pe,ee,ce){let Te=`The value of "${pe}" is out of range.`,Oe=ce;return Number.isInteger(ce)&&Math.abs(ce)>2**32?Oe=z(String(ce)):typeof ce=="bigint"&&(Oe=String(ce),(ce>BigInt(2)**BigInt(32)||ce<-(BigInt(2)**BigInt(32)))&&(Oe=z(Oe)),Oe+="n"),Te+=` It must be ${ee}. Received ${Oe}`,Te},RangeError);function z(pe){let ee="",ce=pe.length;const Te=pe[0]==="-"?1:0;for(;ce>=Te+4;ce-=3)ee=`_${pe.slice(ce-3,ce)}${ee}`;return`${pe.slice(0,ce)}${ee}`}function Q(pe,ee,ce){we(ee,"offset"),(pe[ee]===void 0||pe[ee+ce]===void 0)&&Ne(ee,pe.length-(ce+1))}function ue(pe,ee,ce,Te,Oe,Ve){if(pe>ce||pe<ee){const qe=typeof ee=="bigint"?"n":"";let Ye;throw ee===0||ee===BigInt(0)?Ye=`>= 0${qe} and < 2${qe} ** ${(Ve+1)*8}${qe}`:Ye=`>= -(2${qe} ** ${(Ve+1)*8-1}${qe}) and < 2 ** ${(Ve+1)*8-1}${qe}`,new Ae.ERR_OUT_OF_RANGE("value",Ye,pe)}Q(Te,Oe,Ve)}function we(pe,ee){if(typeof pe!="number")throw new Ae.ERR_INVALID_ARG_TYPE(ee,"number",pe)}function Ne(pe,ee,ce){throw Math.floor(pe)!==pe?(we(pe,ce),new Ae.ERR_OUT_OF_RANGE("offset","an integer",pe)):ee<0?new Ae.ERR_BUFFER_OUT_OF_BOUNDS:new Ae.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${ee}`,pe)}const De=/[^+/0-9A-Za-z-_]/g;function je(pe){if(pe=pe.split("=")[0],pe=pe.trim().replace(De,""),pe.length<2)return"";for(;pe.length%4!==0;)pe=pe+"=";return pe}function ot(pe,ee){ee=ee||1/0;let ce;const Te=pe.length;let Oe=null;const Ve=[];for(let qe=0;qe<Te;++qe){if(ce=pe.charCodeAt(qe),ce>55295&&ce<57344){if(!Oe){if(ce>56319){(ee-=3)>-1&&Ve.push(239,191,189);continue}else if(qe+1===Te){(ee-=3)>-1&&Ve.push(239,191,189);continue}Oe=ce;continue}if(ce<56320){(ee-=3)>-1&&Ve.push(239,191,189),Oe=ce;continue}ce=(Oe-55296<<10|ce-56320)+65536}else Oe&&(ee-=3)>-1&&Ve.push(239,191,189);if(Oe=null,ce<128){if((ee-=1)<0)break;Ve.push(ce)}else if(ce<2048){if((ee-=2)<0)break;Ve.push(ce>>6|192,ce&63|128)}else if(ce<65536){if((ee-=3)<0)break;Ve.push(ce>>12|224,ce>>6&63|128,ce&63|128)}else if(ce<1114112){if((ee-=4)<0)break;Ve.push(ce>>18|240,ce>>12&63|128,ce>>6&63|128,ce&63|128)}else throw new Error("Invalid code point")}return Ve}function He(pe){const ee=[];for(let ce=0;ce<pe.length;++ce)ee.push(pe.charCodeAt(ce)&255);return ee}function We(pe,ee){let ce,Te,Oe;const Ve=[];for(let qe=0;qe<pe.length&&!((ee-=2)<0);++qe)ce=pe.charCodeAt(qe),Te=ce>>8,Oe=ce%256,Ve.push(Oe),Ve.push(Te);return Ve}function ht(pe){return q.toByteArray(je(pe))}function Je(pe,ee,ce,Te){let Oe;for(Oe=0;Oe<Te&&!(Oe+ce>=ee.length||Oe>=pe.length);++Oe)ee[Oe+ce]=pe[Oe];return Oe}function rt(pe,ee){return pe instanceof ee||pe!=null&&pe.constructor!=null&&pe.constructor.name!=null&&pe.constructor.name===ee.name}function mt(pe){return pe!==pe}const Ze=function(){const pe="0123456789abcdef",ee=new Array(256);for(let ce=0;ce<16;++ce){const Te=ce*16;for(let Oe=0;Oe<16;++Oe)ee[Te+Oe]=pe[ce]+pe[Oe]}return ee}();function it(pe){return typeof BigInt>"u"?_t:pe}function _t(){throw new Error("BigInt not supported")}})(t);const B=t.Buffer;e.Blob=t.Blob,e.BlobOptions=t.BlobOptions,e.Buffer=t.Buffer,e.File=t.File,e.FileOptions=t.FileOptions,e.INSPECT_MAX_BYTES=t.INSPECT_MAX_BYTES,e.SlowBuffer=t.SlowBuffer,e.TranscodeEncoding=t.TranscodeEncoding,e.atob=t.atob,e.btoa=t.btoa,e.constants=t.constants,e.default=B,e.isAscii=t.isAscii,e.isUtf8=t.isUtf8,e.kMaxLength=t.kMaxLength,e.kStringMaxLength=t.kStringMaxLength,e.resolveObjectURL=t.resolveObjectURL,e.transcode=t.transcode})(dist$t);var CryptoHDKey$d={},inherits_browser={exports:{}};typeof Object.create=="function"?inherits_browser.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser.exports=function(t,r){if(r){t.super_=r;var s=function(){};s.prototype=r.prototype,t.prototype=new s,t.prototype.constructor=t}};var inherits_browserExports=inherits_browser.exports,safeBuffer$1={exports:{}};const require$$0$3=getAugmentedNamespace(dist$w);(function(e,t){var r=require$$0$3,s=r.Buffer;function o(a,l){for(var p in a)l[p]=a[p]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=n);function n(a,l,p){return s(a,l,p)}n.prototype=Object.create(s.prototype),o(s,n),n.from=function(a,l,p){if(typeof a=="number")throw new TypeError("Argument must not be a number");return s(a,l,p)},n.alloc=function(a,l,p){if(typeof a!="number")throw new TypeError("Argument must be a number");var u=s(a);return l!==void 0?typeof p=="string"?u.fill(l,p):u.fill(l):u.fill(0),u},n.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return s(a)},n.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}})(safeBuffer$1,safeBuffer$1.exports);var safeBufferExports=safeBuffer$1.exports,readableBrowser$1={exports:{}};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var browser$c={exports:{}},process=browser$c.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch{try{return cachedSetTimeout.call(null,e,0)}catch{return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch{try{return cachedClearTimeout.call(null,e)}catch{return cachedClearTimeout.call(this,e)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=!0;process.env={};process.argv=[];process.version="";process.versions={};function noop$2(){}process.on=noop$2;process.addListener=noop$2;process.once=noop$2;process.off=noop$2;process.removeListener=noop$2;process.removeAllListeners=noop$2;process.emit=noop$2;process.prependListener=noop$2;process.prependOnceListener=noop$2;process.listeners=function(e){return[]};process.binding=function(e){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(e){throw new Error("process.chdir is not supported")};process.umask=function(){return 0};var browserExports=browser$c.exports;const process$1=getDefaultExportFromCjs(browserExports);var events={exports:{}},R=typeof Reflect=="object"?Reflect:null,ReflectApply=R&&typeof R.apply=="function"?R.apply:function(t,r,s){return Function.prototype.apply.call(t,r,s)},ReflectOwnKeys;R&&typeof R.ownKeys=="function"?ReflectOwnKeys=R.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}var NumberIsNaN=Number.isNaN||function(t){return t!==t};function EventEmitter(){EventEmitter.init.call(this)}events.exports=EventEmitter;events.exports.once=once$2;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=void 0;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if(typeof e!="number"||e<0||NumberIsNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");defaultMaxListeners=e}});EventEmitter.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||NumberIsNaN(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function _getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function(t){for(var r=[],s=1;s<arguments.length;s++)r.push(arguments[s]);var o=t==="error",n=this._events;if(n!==void 0)o=o&&n.error===void 0;else if(!o)return!1;if(o){var a;if(r.length>0&&(a=r[0]),a instanceof Error)throw a;var l=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw l.context=a,l}var p=n[t];if(p===void 0)return!1;if(typeof p=="function")ReflectApply(p,this,r);else for(var u=p.length,c=arrayClone(p,u),s=0;s<u;++s)ReflectApply(c[s],this,r);return!0};function _addListener(e,t,r,s){var o,n,a;if(checkListener(r),n=e._events,n===void 0?(n=e._events=Object.create(null),e._eventsCount=0):(n.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),a=n[t]),a===void 0)a=n[t]=r,++e._eventsCount;else if(typeof a=="function"?a=n[t]=s?[r,a]:[a,r]:s?a.unshift(r):a.push(r),o=_getMaxListeners(e),o>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,ProcessEmitWarning(l)}return e}EventEmitter.prototype.addListener=function(t,r){return _addListener(this,t,r,!1)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function(t,r){return _addListener(this,t,r,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,r){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=onceWrapper.bind(s);return o.listener=r,s.wrapFn=o,o}EventEmitter.prototype.once=function(t,r){return checkListener(r),this.on(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.prependOnceListener=function(t,r){return checkListener(r),this.prependListener(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.removeListener=function(t,r){var s,o,n,a,l;if(checkListener(r),o=this._events,o===void 0)return this;if(s=o[t],s===void 0)return this;if(s===r||s.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,s.listener||r));else if(typeof s!="function"){for(n=-1,a=s.length-1;a>=0;a--)if(s[a]===r||s[a].listener===r){l=s[a].listener,n=a;break}if(n<0)return this;n===0?s.shift():spliceOne(s,n),s.length===1&&(o[t]=s[0]),o.removeListener!==void 0&&this.emit("removeListener",t,l||r)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function(t){var r,s,o;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var n=Object.keys(s),a;for(o=0;o<n.length;++o)a=n[o],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=s[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(o=r.length-1;o>=0;o--)this.removeListener(t,r[o]);return this};function _listeners(e,t,r){var s=e._events;if(s===void 0)return[];var o=s[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?unwrapListeners(o):arrayClone(o,o.length)}EventEmitter.prototype.listeners=function(t){return _listeners(this,t,!0)};EventEmitter.prototype.rawListeners=function(t){return _listeners(this,t,!1)};EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount.call(e,t)};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(e,t){for(var r=new Array(t),s=0;s<t;++s)r[s]=e[s];return r}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function once$2(e,t){return new Promise(function(r,s){function o(a){e.removeListener(t,n),s(a)}function n(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}eventTargetAgnosticAddListener(e,t,n,{once:!0}),t!=="error"&&addErrorHandlerIfEventEmitter(e,o,{once:!0})})}function addErrorHandlerIfEventEmitter(e,t,r){typeof e.on=="function"&&eventTargetAgnosticAddListener(e,"error",t,r)}function eventTargetAgnosticAddListener(e,t,r,s){if(typeof e.on=="function")s.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function o(n){s.once&&e.removeEventListener(t,o),r(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var eventsExports=events.exports,streamBrowser$1=eventsExports.EventEmitter,util$1={},types$l={},shams$1=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),s=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var o=42;t[r]=o;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var a=Object.getOwnPropertySymbols(t);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(t,r);if(l.value!==o||l.enumerable!==!0)return!1}return!0},hasSymbols$3=shams$1,shams=function(){return hasSymbols$3()&&!!Symbol.toStringTag},esObjectAtoms=Object,esErrors=Error,_eval=EvalError,range=RangeError,ref=ReferenceError,syntax=SyntaxError,type=TypeError,uri=URIError,abs$1=Math.abs,floor$1=Math.floor,max$1=Math.max,min$1=Math.min,pow$2=Math.pow,gOPD$2=Object.getOwnPropertyDescriptor,$gOPD$1=gOPD$2;if($gOPD$1)try{$gOPD$1([],"length")}catch{$gOPD$1=null}var gopd$1=$gOPD$1,$defineProperty$3=Object.defineProperty||!1;if($defineProperty$3)try{$defineProperty$3({},"a",{value:1})}catch{$defineProperty$3=!1}var esDefineProperty=$defineProperty$3,hasSymbols$2,hasRequiredHasSymbols;function requireHasSymbols(){if(hasRequiredHasSymbols)return hasSymbols$2;hasRequiredHasSymbols=1;var e=typeof Symbol<"u"&&Symbol,t=shams$1;return hasSymbols$2=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},hasSymbols$2}var implementation$6,hasRequiredImplementation$2;function requireImplementation$2(){if(hasRequiredImplementation$2)return implementation$6;hasRequiredImplementation$2=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,s="[object Function]",o=function(p,u){for(var c=[],v=0;v<p.length;v+=1)c[v]=p[v];for(var w=0;w<u.length;w+=1)c[w+p.length]=u[w];return c},n=function(p,u){for(var c=[],v=u,w=0;v<p.length;v+=1,w+=1)c[w]=p[v];return c},a=function(l,p){for(var u="",c=0;c<l.length;c+=1)u+=l[c],c+1<l.length&&(u+=p);return u};return implementation$6=function(p){var u=this;if(typeof u!="function"||t.apply(u)!==s)throw new TypeError(e+u);for(var c=n(arguments,1),v,w=function(){if(this instanceof v){var B=u.apply(this,o(c,arguments));return Object(B)===B?B:this}return u.apply(p,o(c,arguments))},b=r(0,u.length-c.length),E=[],I=0;I<b;I++)E[I]="$"+I;if(v=Function("binder","return function ("+a(E,",")+"){ return binder.apply(this,arguments); }")(w),u.prototype){var x=function(){};x.prototype=u.prototype,v.prototype=new x,x.prototype=null}return v},implementation$6}var functionBind,hasRequiredFunctionBind;function requireFunctionBind(){if(hasRequiredFunctionBind)return functionBind;hasRequiredFunctionBind=1;var e=requireImplementation$2();return functionBind=Function.prototype.bind||e,functionBind}var functionCall,hasRequiredFunctionCall;function requireFunctionCall(){return hasRequiredFunctionCall||(hasRequiredFunctionCall=1,functionCall=Function.prototype.call),functionCall}var functionApply,hasRequiredFunctionApply;function requireFunctionApply(){return hasRequiredFunctionApply||(hasRequiredFunctionApply=1,functionApply=Function.prototype.apply),functionApply}var reflectApply$1=typeof Reflect<"u"&&Reflect&&Reflect.apply,bind$3=requireFunctionBind(),$apply$2=requireFunctionApply(),$call$2=requireFunctionCall(),$reflectApply=reflectApply$1,actualApply$1=$reflectApply||bind$3.call($call$2,$apply$2),bind$2=requireFunctionBind(),$TypeError$3=type,$call$1=requireFunctionCall(),$actualApply=actualApply$1,callBindApplyHelpers=function(t){if(t.length<1||typeof t[0]!="function")throw new $TypeError$3("a function is required");return $actualApply(bind$2,$call$1,t)},get,hasRequiredGet;function requireGet(){if(hasRequiredGet)return get;hasRequiredGet=1;var e=callBindApplyHelpers,t=gopd$1,r;try{r=[].__proto__===Array.prototype}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var s=!!r&&t&&t(Object.prototype,"__proto__"),o=Object,n=o.getPrototypeOf;return get=s&&typeof s.get=="function"?e([s.get]):typeof n=="function"?function(l){return n(l==null?l:o(l))}:!1,get}var hasown,hasRequiredHasown;function requireHasown(){if(hasRequiredHasown)return hasown;hasRequiredHasown=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=requireFunctionBind();return hasown=r.call(e,t),hasown}var undefined$1,$Object$1=esObjectAtoms,$Error=esErrors,$EvalError=_eval,$RangeError=range,$ReferenceError=ref,$SyntaxError$1=syntax,$TypeError$2=type,$URIError=uri,abs=abs$1,floor=floor$1,max=max$1,min=min$1,pow$1=pow$2,$Function=Function,getEvalledConstructor=function(e){try{return $Function('"use strict"; return ('+e+").constructor;")()}catch{}},$gOPD=gopd$1,$defineProperty$2=esDefineProperty,throwTypeError=function(){throw new $TypeError$2},ThrowTypeError=$gOPD?function(){try{return arguments.callee,throwTypeError}catch{try{return $gOPD(arguments,"callee").get}catch{return throwTypeError}}}():throwTypeError,hasSymbols$1=requireHasSymbols()(),getDunderProto=requireGet(),getProto$1=typeof Reflect=="function"&&Reflect.getPrototypeOf||$Object$1.getPrototypeOf||getDunderProto,$apply$1=requireFunctionApply(),$call=requireFunctionCall(),needsEval={},TypedArray=typeof Uint8Array>"u"||!getProto$1?undefined$1:getProto$1(Uint8Array),INTRINSICS={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?undefined$1:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?undefined$1:ArrayBuffer,"%ArrayIteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1([][Symbol.iterator]()):undefined$1,"%AsyncFromSyncIteratorPrototype%":undefined$1,"%AsyncFunction%":needsEval,"%AsyncGenerator%":needsEval,"%AsyncGeneratorFunction%":needsEval,"%AsyncIteratorPrototype%":needsEval,"%Atomics%":typeof Atomics>"u"?undefined$1:Atomics,"%BigInt%":typeof BigInt>"u"?undefined$1:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?undefined$1:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?undefined$1:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?undefined$1:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":$Error,"%eval%":eval,"%EvalError%":$EvalError,"%Float32Array%":typeof Float32Array>"u"?undefined$1:Float32Array,"%Float64Array%":typeof Float64Array>"u"?undefined$1:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?undefined$1:FinalizationRegistry,"%Function%":$Function,"%GeneratorFunction%":needsEval,"%Int8Array%":typeof Int8Array>"u"?undefined$1:Int8Array,"%Int16Array%":typeof Int16Array>"u"?undefined$1:Int16Array,"%Int32Array%":typeof Int32Array>"u"?undefined$1:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1(getProto$1([][Symbol.iterator]())):undefined$1,"%JSON%":typeof JSON=="object"?JSON:undefined$1,"%Map%":typeof Map>"u"?undefined$1:Map,"%MapIteratorPrototype%":typeof Map>"u"||!hasSymbols$1||!getProto$1?undefined$1:getProto$1(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":$Object$1,"%Object.getOwnPropertyDescriptor%":$gOPD,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?undefined$1:Promise,"%Proxy%":typeof Proxy>"u"?undefined$1:Proxy,"%RangeError%":$RangeError,"%ReferenceError%":$ReferenceError,"%Reflect%":typeof Reflect>"u"?undefined$1:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?undefined$1:Set,"%SetIteratorPrototype%":typeof Set>"u"||!hasSymbols$1||!getProto$1?undefined$1:getProto$1(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?undefined$1:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":hasSymbols$1&&getProto$1?getProto$1(""[Symbol.iterator]()):undefined$1,"%Symbol%":hasSymbols$1?Symbol:undefined$1,"%SyntaxError%":$SyntaxError$1,"%ThrowTypeError%":ThrowTypeError,"%TypedArray%":TypedArray,"%TypeError%":$TypeError$2,"%Uint8Array%":typeof Uint8Array>"u"?undefined$1:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?undefined$1:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?undefined$1:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?undefined$1:Uint32Array,"%URIError%":$URIError,"%WeakMap%":typeof WeakMap>"u"?undefined$1:WeakMap,"%WeakRef%":typeof WeakRef>"u"?undefined$1:WeakRef,"%WeakSet%":typeof WeakSet>"u"?undefined$1:WeakSet,"%Function.prototype.call%":$call,"%Function.prototype.apply%":$apply$1,"%Object.defineProperty%":$defineProperty$2,"%Math.abs%":abs,"%Math.floor%":floor,"%Math.max%":max,"%Math.min%":min,"%Math.pow%":pow$1};if(getProto$1)try{null.error}catch(e){var errorProto=getProto$1(getProto$1(e));INTRINSICS["%Error.prototype%"]=errorProto}var doEval=function e(t){var r;if(t==="%AsyncFunction%")r=getEvalledConstructor("async function () {}");else if(t==="%GeneratorFunction%")r=getEvalledConstructor("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=getEvalledConstructor("async function* () {}");else if(t==="%AsyncGenerator%"){var s=e("%AsyncGeneratorFunction%");s&&(r=s.prototype)}else if(t==="%AsyncIteratorPrototype%"){var o=e("%AsyncGenerator%");o&&getProto$1&&(r=getProto$1(o.prototype))}return INTRINSICS[t]=r,r},LEGACY_ALIASES={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},bind$1=requireFunctionBind(),hasOwn=requireHasown(),$concat=bind$1.call($call,Array.prototype.concat),$spliceApply=bind$1.call($apply$1,Array.prototype.splice),$replace=bind$1.call($call,String.prototype.replace),$strSlice=bind$1.call($call,String.prototype.slice),$exec=bind$1.call($call,RegExp.prototype.exec),rePropName=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=function(t){var r=$strSlice(t,0,1),s=$strSlice(t,-1);if(r==="%"&&s!=="%")throw new $SyntaxError$1("invalid intrinsic syntax, expected closing `%`");if(s==="%"&&r!=="%")throw new $SyntaxError$1("invalid intrinsic syntax, expected opening `%`");var o=[];return $replace(t,rePropName,function(n,a,l,p){o[o.length]=l?$replace(p,reEscapeChar,"$1"):a||n}),o},getBaseIntrinsic=function(t,r){var s=t,o;if(hasOwn(LEGACY_ALIASES,s)&&(o=LEGACY_ALIASES[s],s="%"+o[0]+"%"),hasOwn(INTRINSICS,s)){var n=INTRINSICS[s];if(n===needsEval&&(n=doEval(s)),typeof n>"u"&&!r)throw new $TypeError$2("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:o,name:s,value:n}}throw new $SyntaxError$1("intrinsic "+t+" does not exist!")},getIntrinsic=function(t,r){if(typeof t!="string"||t.length===0)throw new $TypeError$2("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new $TypeError$2('"allowMissing" argument must be a boolean');if($exec(/^%?[^%]*%?$/,t)===null)throw new $SyntaxError$1("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var s=stringToPath(t),o=s.length>0?s[0]:"",n=getBaseIntrinsic("%"+o+"%",r),a=n.name,l=n.value,p=!1,u=n.alias;u&&(o=u[0],$spliceApply(s,$concat([0,1],u)));for(var c=1,v=!0;c<s.length;c+=1){var w=s[c],b=$strSlice(w,0,1),E=$strSlice(w,-1);if((b==='"'||b==="'"||b==="`"||E==='"'||E==="'"||E==="`")&&b!==E)throw new $SyntaxError$1("property names with quotes must have matching quotes");if((w==="constructor"||!v)&&(p=!0),o+="."+w,a="%"+o+"%",hasOwn(INTRINSICS,a))l=INTRINSICS[a];else if(l!=null){if(!(w in l)){if(!r)throw new $TypeError$2("base intrinsic for "+t+" exists, but the property is not available.");return}if($gOPD&&c+1>=s.length){var I=$gOPD(l,w);v=!!I,v&&"get"in I&&!("originalValue"in I.get)?l=I.get:l=l[w]}else v=hasOwn(l,w),l=l[w];v&&!p&&(INTRINSICS[a]=l)}}return l},GetIntrinsic$2=getIntrinsic,callBindBasic=callBindApplyHelpers,$indexOf$2=callBindBasic([GetIntrinsic$2("%String.prototype.indexOf%")]),callBound$4=function(t,r){var s=GetIntrinsic$2(t,!!r);return typeof s=="function"&&$indexOf$2(t,".prototype.")>-1?callBindBasic([s]):s},hasToStringTag$3=shams(),callBound$3=callBound$4,$toString$1=callBound$3("Object.prototype.toString"),isStandardArguments=function(t){return hasToStringTag$3&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:$toString$1(t)==="[object Arguments]"},isLegacyArguments=function(t){return isStandardArguments(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&$toString$1(t)!=="[object Array]"&&"callee"in t&&$toString$1(t.callee)==="[object Function]"},supportsStandardArguments=function(){return isStandardArguments(arguments)}();isStandardArguments.isLegacyArguments=isLegacyArguments;var isArguments$1=supportsStandardArguments?isStandardArguments:isLegacyArguments,toStr$3=Object.prototype.toString,fnToStr$1=Function.prototype.toString,isFnRegex=/^\s*(?:function)?\*/,hasToStringTag$2=shams(),getProto=Object.getPrototypeOf,getGeneratorFunc=function(){if(!hasToStringTag$2)return!1;try{return Function("return function*() {}")()}catch{}},GeneratorFunction,isGeneratorFunction=function(t){if(typeof t!="function")return!1;if(isFnRegex.test(fnToStr$1.call(t)))return!0;if(!hasToStringTag$2){var r=toStr$3.call(t);return r==="[object GeneratorFunction]"}if(!getProto)return!1;if(typeof GeneratorFunction>"u"){var s=getGeneratorFunc();GeneratorFunction=s?getProto(s):!1}return getProto(t)===GeneratorFunction},fnToStr=Function.prototype.toString,reflectApply=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,badArrayLike,isCallableMarker;if(typeof reflectApply=="function"&&typeof Object.defineProperty=="function")try{badArrayLike=Object.defineProperty({},"length",{get:function(){throw isCallableMarker}}),isCallableMarker={},reflectApply(function(){throw 42},null,badArrayLike)}catch(e){e!==isCallableMarker&&(reflectApply=null)}else reflectApply=null;var constructorRegex=/^\s*class\b/,isES6ClassFn=function(t){try{var r=fnToStr.call(t);return constructorRegex.test(r)}catch{return!1}},tryFunctionObject=function(t){try{return isES6ClassFn(t)?!1:(fnToStr.call(t),!0)}catch{return!1}},toStr$2=Object.prototype.toString,objectClass="[object Object]",fnClass="[object Function]",genClass="[object GeneratorFunction]",ddaClass="[object HTMLAllCollection]",ddaClass2="[object HTML document.all class]",ddaClass3="[object HTMLCollection]",hasToStringTag$1=typeof Symbol=="function"&&!!Symbol.toStringTag,isIE68=!(0 in[,]),isDDA=function(){return!1};if(typeof document=="object"){var all=document.all;toStr$2.call(all)===toStr$2.call(document.all)&&(isDDA=function(t){if((isIE68||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=toStr$2.call(t);return(r===ddaClass||r===ddaClass2||r===ddaClass3||r===objectClass)&&t("")==null}catch{}return!1})}var isCallable$1=reflectApply?function(t){if(isDDA(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{reflectApply(t,null,badArrayLike)}catch(r){if(r!==isCallableMarker)return!1}return!isES6ClassFn(t)&&tryFunctionObject(t)}:function(t){if(isDDA(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(hasToStringTag$1)return tryFunctionObject(t);if(isES6ClassFn(t))return!1;var r=toStr$2.call(t);return r!==fnClass&&r!==genClass&&!/^\[object HTML/.test(r)?!1:tryFunctionObject(t)},isCallable=isCallable$1,toStr$1=Object.prototype.toString,hasOwnProperty=Object.prototype.hasOwnProperty,forEachArray=function(t,r,s){for(var o=0,n=t.length;o<n;o++)hasOwnProperty.call(t,o)&&(s==null?r(t[o],o,t):r.call(s,t[o],o,t))},forEachString=function(t,r,s){for(var o=0,n=t.length;o<n;o++)s==null?r(t.charAt(o),o,t):r.call(s,t.charAt(o),o,t)},forEachObject=function(t,r,s){for(var o in t)hasOwnProperty.call(t,o)&&(s==null?r(t[o],o,t):r.call(s,t[o],o,t))},forEach$1=function(t,r,s){if(!isCallable(r))throw new TypeError("iterator must be a function");var o;arguments.length>=3&&(o=s),toStr$1.call(t)==="[object Array]"?forEachArray(t,r,o):typeof t=="string"?forEachString(t,r,o):forEachObject(t,r,o)},forEach_1=forEach$1,possibleTypedArrayNames=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],possibleNames=possibleTypedArrayNames,g$1=typeof globalThis>"u"?commonjsGlobal:globalThis,availableTypedArrays$1=function(){for(var t=[],r=0;r<possibleNames.length;r++)typeof g$1[possibleNames[r]]=="function"&&(t[t.length]=possibleNames[r]);return t},callBind$2={exports:{}},$defineProperty$1=esDefineProperty,$SyntaxError=syntax,$TypeError$1=type,gopd=gopd$1,defineDataProperty=function(t,r,s){if(!t||typeof t!="object"&&typeof t!="function")throw new $TypeError$1("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new $TypeError$1("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new $TypeError$1("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new $TypeError$1("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new $TypeError$1("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new $TypeError$1("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,l=arguments.length>6?arguments[6]:!1,p=!!gopd&&gopd(t,r);if($defineProperty$1)$defineProperty$1(t,r,{configurable:a===null&&p?p.configurable:!a,enumerable:o===null&&p?p.enumerable:!o,value:s,writable:n===null&&p?p.writable:!n});else if(l||!o&&!n&&!a)t[r]=s;else throw new $SyntaxError("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},$defineProperty=esDefineProperty,hasPropertyDescriptors=function(){return!!$defineProperty};hasPropertyDescriptors.hasArrayLengthDefineBug=function(){if(!$defineProperty)return null;try{return $defineProperty([],"length",{value:1}).length!==1}catch{return!0}};var hasPropertyDescriptors_1=hasPropertyDescriptors,GetIntrinsic$1=getIntrinsic,define=defineDataProperty,hasDescriptors=hasPropertyDescriptors_1(),gOPD$1=gopd$1,$TypeError=type,$floor=GetIntrinsic$1("%Math.floor%"),setFunctionLength=function(t,r){if(typeof t!="function")throw new $TypeError("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||$floor(r)!==r)throw new $TypeError("`length` must be a positive 32-bit integer");var s=arguments.length>2&&!!arguments[2],o=!0,n=!0;if("length"in t&&gOPD$1){var a=gOPD$1(t,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(n=!1)}return(o||n||!s)&&(hasDescriptors?define(t,"length",r,!0,!0):define(t,"length",r)),t},bind=requireFunctionBind(),$apply=requireFunctionApply(),actualApply=actualApply$1,applyBind=function(){return actualApply(bind,$apply,arguments)};(function(e){var t=setFunctionLength,r=esDefineProperty,s=callBindApplyHelpers,o=applyBind;e.exports=function(a){var l=s(arguments),p=a.length-(arguments.length-1);return t(l,1+(p>0?p:0),!0)},r?r(e.exports,"apply",{value:o}):e.exports.apply=o})(callBind$2);var callBindExports=callBind$2.exports,forEach=forEach_1,availableTypedArrays=availableTypedArrays$1,callBind$1=callBindExports,callBound$2=callBound$4,gOPD=gopd$1,$toString=callBound$2("Object.prototype.toString"),hasToStringTag=shams(),g=typeof globalThis>"u"?commonjsGlobal:globalThis,typedArrays=availableTypedArrays(),$slice=callBound$2("String.prototype.slice"),getPrototypeOf=Object.getPrototypeOf,$indexOf$1=callBound$2("Array.prototype.indexOf",!0)||function(t,r){for(var s=0;s<t.length;s+=1)if(t[s]===r)return s;return-1},cache={__proto__:null};hasToStringTag&&gOPD&&getPrototypeOf?forEach(typedArrays,function(e){var t=new g[e];if(Symbol.toStringTag in t){var r=getPrototypeOf(t),s=gOPD(r,Symbol.toStringTag);if(!s){var o=getPrototypeOf(r);s=gOPD(o,Symbol.toStringTag)}cache["$"+e]=callBind$1(s.get)}}):forEach(typedArrays,function(e){var t=new g[e],r=t.slice||t.set;r&&(cache["$"+e]=callBind$1(r))});var tryTypedArrays=function(t){var r=!1;return forEach(cache,function(s,o){if(!r)try{"$"+s(t)===o&&(r=$slice(o,1))}catch{}}),r},trySlices=function(t){var r=!1;return forEach(cache,function(s,o){if(!r)try{s(t),r=$slice(o,1)}catch{}}),r},whichTypedArray$1=function(t){if(!t||typeof t!="object")return!1;if(!hasToStringTag){var r=$slice($toString(t),8,-1);return $indexOf$1(typedArrays,r)>-1?r:r!=="Object"?!1:trySlices(t)}return gOPD?tryTypedArrays(t):null},whichTypedArray=whichTypedArray$1,isTypedArray=function(t){return!!whichTypedArray(t)};(function(e){var t=isArguments$1,r=isGeneratorFunction,s=whichTypedArray$1,o=isTypedArray;function n($e){return $e.call.bind($e)}var a=typeof BigInt<"u",l=typeof Symbol<"u",p=n(Object.prototype.toString),u=n(Number.prototype.valueOf),c=n(String.prototype.valueOf),v=n(Boolean.prototype.valueOf);if(a)var w=n(BigInt.prototype.valueOf);if(l)var b=n(Symbol.prototype.valueOf);function E($e,Ue){if(typeof $e!="object")return!1;try{return Ue($e),!0}catch{return!1}}e.isArgumentsObject=t,e.isGeneratorFunction=r,e.isTypedArray=o;function I($e){return typeof Promise<"u"&&$e instanceof Promise||$e!==null&&typeof $e=="object"&&typeof $e.then=="function"&&typeof $e.catch=="function"}e.isPromise=I;function x($e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView($e):o($e)||J($e)}e.isArrayBufferView=x;function B($e){return s($e)==="Uint8Array"}e.isUint8Array=B;function M($e){return s($e)==="Uint8ClampedArray"}e.isUint8ClampedArray=M;function q($e){return s($e)==="Uint16Array"}e.isUint16Array=q;function U($e){return s($e)==="Uint32Array"}e.isUint32Array=U;function F($e){return s($e)==="Int8Array"}e.isInt8Array=F;function j($e){return s($e)==="Int16Array"}e.isInt16Array=j;function y($e){return s($e)==="Int32Array"}e.isInt32Array=y;function T($e){return s($e)==="Float32Array"}e.isFloat32Array=T;function D($e){return s($e)==="Float64Array"}e.isFloat64Array=D;function L($e){return s($e)==="BigInt64Array"}e.isBigInt64Array=L;function C($e){return s($e)==="BigUint64Array"}e.isBigUint64Array=C;function d($e){return p($e)==="[object Map]"}d.working=typeof Map<"u"&&d(new Map);function _($e){return typeof Map>"u"?!1:d.working?d($e):$e instanceof Map}e.isMap=_;function $($e){return p($e)==="[object Set]"}$.working=typeof Set<"u"&&$(new Set);function S($e){return typeof Set>"u"?!1:$.working?$($e):$e instanceof Set}e.isSet=S;function O($e){return p($e)==="[object WeakMap]"}O.working=typeof WeakMap<"u"&&O(new WeakMap);function N($e){return typeof WeakMap>"u"?!1:O.working?O($e):$e instanceof WeakMap}e.isWeakMap=N;function k($e){return p($e)==="[object WeakSet]"}k.working=typeof WeakSet<"u"&&k(new WeakSet);function A($e){return k($e)}e.isWeakSet=A;function m($e){return p($e)==="[object ArrayBuffer]"}m.working=typeof ArrayBuffer<"u"&&m(new ArrayBuffer);function P($e){return typeof ArrayBuffer>"u"?!1:m.working?m($e):$e instanceof ArrayBuffer}e.isArrayBuffer=P;function H($e){return p($e)==="[object DataView]"}H.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&H(new DataView(new ArrayBuffer(1),0,1));function J($e){return typeof DataView>"u"?!1:H.working?H($e):$e instanceof DataView}e.isDataView=J;var X=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function se($e){return p($e)==="[object SharedArrayBuffer]"}function ne($e){return typeof X>"u"?!1:(typeof se.working>"u"&&(se.working=se(new X)),se.working?se($e):$e instanceof X)}e.isSharedArrayBuffer=ne;function Z($e){return p($e)==="[object AsyncFunction]"}e.isAsyncFunction=Z;function oe($e){return p($e)==="[object Map Iterator]"}e.isMapIterator=oe;function ye($e){return p($e)==="[object Set Iterator]"}e.isSetIterator=ye;function Y($e){return p($e)==="[object Generator]"}e.isGeneratorObject=Y;function G($e){return p($e)==="[object WebAssembly.Module]"}e.isWebAssemblyCompiledModule=G;function V($e){return E($e,u)}e.isNumberObject=V;function te($e){return E($e,c)}e.isStringObject=te;function le($e){return E($e,v)}e.isBooleanObject=le;function me($e){return a&&E($e,w)}e.isBigIntObject=me;function Re($e){return l&&E($e,b)}e.isSymbolObject=Re;function Be($e){return V($e)||te($e)||le($e)||me($e)||Re($e)}e.isBoxedPrimitive=Be;function Ce($e){return typeof Uint8Array<"u"&&(P($e)||ne($e))}e.isAnyArrayBuffer=Ce,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function($e){Object.defineProperty(e,$e,{enumerable:!1,value:function(){throw new Error($e+" is not supported in userland")}})})})(types$l);var isBufferBrowser=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"};(function(e){var t=Object.getOwnPropertyDescriptors||function(J){for(var X=Object.keys(J),se={},ne=0;ne<X.length;ne++)se[X[ne]]=Object.getOwnPropertyDescriptor(J,X[ne]);return se},r=/%[sdj%]/g;e.format=function(H){if(!F(H)){for(var J=[],X=0;X<arguments.length;X++)J.push(a(arguments[X]));return J.join(" ")}for(var X=1,se=arguments,ne=se.length,Z=String(H).replace(r,function(ye){if(ye==="%%")return"%";if(X>=ne)return ye;switch(ye){case"%s":return String(se[X++]);case"%d":return Number(se[X++]);case"%j":try{return JSON.stringify(se[X++])}catch{return"[Circular]"}default:return ye}}),oe=se[X];X<ne;oe=se[++X])M(oe)||!D(oe)?Z+=" "+oe:Z+=" "+a(oe);return Z},e.deprecate=function(H,J){if(typeof process$1<"u"&&process$1.noDeprecation===!0)return H;if(typeof process$1>"u")return function(){return e.deprecate(H,J).apply(this,arguments)};var X=!1;function se(){if(!X){if(process$1.throwDeprecation)throw new Error(J);process$1.traceDeprecation?console.trace(J):console.error(J),X=!0}return H.apply(this,arguments)}return se};var s={},o=/^$/;if(process$1.env.NODE_DEBUG){var n=process$1.env.NODE_DEBUG;n=n.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),o=new RegExp("^"+n+"$","i")}e.debuglog=function(H){if(H=H.toUpperCase(),!s[H])if(o.test(H)){var J=process$1.pid;s[H]=function(){var X=e.format.apply(e,arguments);console.error("%s %d: %s",H,J,X)}}else s[H]=function(){};return s[H]};function a(H,J){var X={seen:[],stylize:p};return arguments.length>=3&&(X.depth=arguments[2]),arguments.length>=4&&(X.colors=arguments[3]),B(J)?X.showHidden=J:J&&e._extend(X,J),y(X.showHidden)&&(X.showHidden=!1),y(X.depth)&&(X.depth=2),y(X.colors)&&(X.colors=!1),y(X.customInspect)&&(X.customInspect=!0),X.colors&&(X.stylize=l),c(X,H,X.depth)}e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function l(H,J){var X=a.styles[J];return X?"\x1B["+a.colors[X][0]+"m"+H+"\x1B["+a.colors[X][1]+"m":H}function p(H,J){return H}function u(H){var J={};return H.forEach(function(X,se){J[X]=!0}),J}function c(H,J,X){if(H.customInspect&&J&&d(J.inspect)&&J.inspect!==e.inspect&&!(J.constructor&&J.constructor.prototype===J)){var se=J.inspect(X,H);return F(se)||(se=c(H,se,X)),se}var ne=v(H,J);if(ne)return ne;var Z=Object.keys(J),oe=u(Z);if(H.showHidden&&(Z=Object.getOwnPropertyNames(J)),C(J)&&(Z.indexOf("message")>=0||Z.indexOf("description")>=0))return w(J);if(Z.length===0){if(d(J)){var ye=J.name?": "+J.name:"";return H.stylize("[Function"+ye+"]","special")}if(T(J))return H.stylize(RegExp.prototype.toString.call(J),"regexp");if(L(J))return H.stylize(Date.prototype.toString.call(J),"date");if(C(J))return w(J)}var Y="",G=!1,V=["{","}"];if(x(J)&&(G=!0,V=["[","]"]),d(J)){var te=J.name?": "+J.name:"";Y=" [Function"+te+"]"}if(T(J)&&(Y=" "+RegExp.prototype.toString.call(J)),L(J)&&(Y=" "+Date.prototype.toUTCString.call(J)),C(J)&&(Y=" "+w(J)),Z.length===0&&(!G||J.length==0))return V[0]+Y+V[1];if(X<0)return T(J)?H.stylize(RegExp.prototype.toString.call(J),"regexp"):H.stylize("[Object]","special");H.seen.push(J);var le;return G?le=b(H,J,X,oe,Z):le=Z.map(function(me){return E(H,J,X,oe,me,G)}),H.seen.pop(),I(le,Y,V)}function v(H,J){if(y(J))return H.stylize("undefined","undefined");if(F(J)){var X="'"+JSON.stringify(J).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return H.stylize(X,"string")}if(U(J))return H.stylize(""+J,"number");if(B(J))return H.stylize(""+J,"boolean");if(M(J))return H.stylize("null","null")}function w(H){return"["+Error.prototype.toString.call(H)+"]"}function b(H,J,X,se,ne){for(var Z=[],oe=0,ye=J.length;oe<ye;++oe)k(J,String(oe))?Z.push(E(H,J,X,se,String(oe),!0)):Z.push("");return ne.forEach(function(Y){Y.match(/^\d+$/)||Z.push(E(H,J,X,se,Y,!0))}),Z}function E(H,J,X,se,ne,Z){var oe,ye,Y;if(Y=Object.getOwnPropertyDescriptor(J,ne)||{value:J[ne]},Y.get?Y.set?ye=H.stylize("[Getter/Setter]","special"):ye=H.stylize("[Getter]","special"):Y.set&&(ye=H.stylize("[Setter]","special")),k(se,ne)||(oe="["+ne+"]"),ye||(H.seen.indexOf(Y.value)<0?(M(X)?ye=c(H,Y.value,null):ye=c(H,Y.value,X-1),ye.indexOf(`
2
2
  `)>-1&&(Z?ye=ye.split(`
3
3
  `).map(function(G){return" "+G}).join(`
4
4
  `).slice(2):ye=`
@@ -76,5 +76,5 @@ ${E.length}`);return(0,e.keccak256)((0,r.concatBytes)(I,E))};return signature$1.
76
76
  Given value: ${r.toString()}`);this[t]=new Bytes(t,r,this.ordinalWidth),this[r.toString()]=this[t]}from(t){return t instanceof Bytes?t:this[t]}fromParser(t){return this.from(t.readUIntN(this.ordinalWidth).toString())}}bytes$2.BytesLookup=BytesLookup;var field={},serializedType={},binarySerializer={},__createBinding$2=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),__setModuleDefault$2=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar$2=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding$2(t,e,r);return __setModuleDefault$2(t,e),t};Object.defineProperty(binarySerializer,"__esModule",{value:!0});binarySerializer.BinarySerializer=binarySerializer.BytesList=void 0;const assert$3=__importStar$2(requireAssert()),buffer_1$n=dist$t;class BytesList{constructor(){this.bytesArray=[]}getLength(){return buffer_1$n.Buffer.concat(this.bytesArray).byteLength}put(t){const r=buffer_1$n.Buffer.from(t);return this.bytesArray.push(r),this}toBytesSink(t){t.put(this.toBytes())}toBytes(){return buffer_1$n.Buffer.concat(this.bytesArray)}toHex(){return this.toBytes().toString("hex").toUpperCase()}}binarySerializer.BytesList=BytesList;class BinarySerializer{constructor(t){this.sink=new BytesList,this.sink=t}write(t){t.toBytesSink(this.sink)}put(t){this.sink.put(t)}writeType(t,r){this.write(t.from(r))}writeBytesList(t){t.toBytesSink(this.sink)}encodeVariableLength(t){const r=buffer_1$n.Buffer.alloc(3);if(t<=192)return r[0]=t,r.slice(0,1);if(t<=12480)return t-=193,r[0]=193+(t>>>8),r[1]=t&255,r.slice(0,2);if(t<=918744)return t-=12481,r[0]=241+(t>>>16),r[1]=t>>8&255,r[2]=t&255,r.slice(0,3);throw new Error("Overflow error")}writeFieldAndValue(t,r,s=!1){const o=t.associatedType.from(r);assert$3.ok(o.toBytesSink!==void 0),assert$3.ok(t.name!==void 0),this.sink.put(t.header),t.isVariableLengthEncoded?this.writeLengthEncoded(o,s):o.toBytesSink(this.sink)}writeLengthEncoded(t,r=!1){const s=new BytesList;r||t.toBytesSink(s),this.put(this.encodeVariableLength(s.getLength())),this.writeBytesList(s)}}binarySerializer.BinarySerializer=BinarySerializer;Object.defineProperty(serializedType,"__esModule",{value:!0});serializedType.Comparable=serializedType.SerializedType=void 0;const binary_serializer_1$2=binarySerializer,buffer_1$m=dist$t;class SerializedType{constructor(t){this.bytes=buffer_1$m.Buffer.alloc(0),this.bytes=t??buffer_1$m.Buffer.alloc(0)}static fromParser(t,r){throw new Error("fromParser not implemented")}static from(t){throw new Error("from not implemented")}toBytesSink(t){t.put(this.bytes)}toHex(){return this.toBytes().toString("hex").toUpperCase()}toBytes(){if(this.bytes)return this.bytes;const t=new binary_serializer_1$2.BytesList;return this.toBytesSink(t),t.toBytes()}toJSON(t){return this.toHex()}toString(){return this.toHex()}}serializedType.SerializedType=SerializedType;class Comparable extends SerializedType{lt(t){return this.compareTo(t)<0}eq(t){return this.compareTo(t)===0}gt(t){return this.compareTo(t)>0}gte(t){return this.compareTo(t)>-1}lte(t){return this.compareTo(t)<1}compareTo(t){throw new Error(`cannot compare ${this.toString()} and ${t.toString()}`)}}serializedType.Comparable=Comparable;var constants={};Object.defineProperty(constants,"__esModule",{value:!0});constants.TRANSACTION_RESULT_WIDTH=constants.TRANSACTION_TYPE_WIDTH=constants.LEDGER_ENTRY_WIDTH=constants.TYPE_WIDTH=void 0;constants.TYPE_WIDTH=2;constants.LEDGER_ENTRY_WIDTH=2;constants.TRANSACTION_TYPE_WIDTH=2;constants.TRANSACTION_RESULT_WIDTH=1;Object.defineProperty(field,"__esModule",{value:!0});field.FieldLookup=void 0;const bytes_1=bytes$2,serialized_type_1$8=serializedType,constants_1=constants,buffer_1$l=dist$t;function fieldHeader(e,t){const r=[];return e<16?t<16?r.push(e<<4|t):r.push(e<<4,t):t<16?r.push(t,e):r.push(0,e,t),buffer_1$l.Buffer.from(r)}function buildField([e,t],r){const s=fieldHeader(r,t.nth);return{name:e,nth:t.nth,isVariableLengthEncoded:t.isVLEncoded,isSerialized:t.isSerialized,isSigningField:t.isSigningField,ordinal:r<<16|t.nth,type:new bytes_1.Bytes(t.type,r,constants_1.TYPE_WIDTH),header:s,associatedType:serialized_type_1$8.SerializedType}}class FieldLookup{constructor(t,r){t.forEach(([s,o])=>{const n=r[o.type];this[s]=buildField([s,o],n),this[this[s].ordinal.toString()]=this[s]})}fromString(t){return this[t]}}field.FieldLookup=FieldLookup;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.BytesLookup=e.Bytes=e.FieldLookup=e.XrplDefinitionsBase=void 0;const t=bytes$2;Object.defineProperty(e,"Bytes",{enumerable:!0,get:function(){return t.Bytes}}),Object.defineProperty(e,"BytesLookup",{enumerable:!0,get:function(){return t.BytesLookup}});const r=field;Object.defineProperty(e,"FieldLookup",{enumerable:!0,get:function(){return r.FieldLookup}});const s=constants;class o{constructor(a,l){this.type=new t.BytesLookup(a.TYPES,s.TYPE_WIDTH),this.ledgerEntryType=new t.BytesLookup(a.LEDGER_ENTRY_TYPES,s.LEDGER_ENTRY_WIDTH),this.transactionType=new t.BytesLookup(a.TRANSACTION_TYPES,s.TRANSACTION_TYPE_WIDTH),this.transactionResult=new t.BytesLookup(a.TRANSACTION_RESULTS,s.TRANSACTION_RESULT_WIDTH),this.field=new r.FieldLookup(a.FIELDS,a.TYPES),this.transactionNames=Object.entries(a.TRANSACTION_TYPES).filter(([p,u])=>u>=0).map(([p,u])=>p),this.dataTypes={},this.associateTypes(l)}associateTypes(a){this.dataTypes=Object.assign({},this.dataTypes,a),Object.values(this.field).forEach(l=>{l.associatedType=this.dataTypes[l.type.name]}),this.field.TransactionType.associatedType=this.transactionType,this.field.TransactionResult.associatedType=this.transactionResult,this.field.LedgerEntryType.associatedType=this.ledgerEntryType}getAssociatedTypes(){return this.dataTypes}}e.XrplDefinitionsBase=o})(xrplDefinitionsBase);(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(b,E,I,x){x===void 0&&(x=I);var B=Object.getOwnPropertyDescriptor(E,I);(!B||("get"in B?!E.__esModule:B.writable||B.configurable))&&(B={enumerable:!0,get:function(){return E[I]}}),Object.defineProperty(b,x,B)}:function(b,E,I,x){x===void 0&&(x=I),b[x]=E[I]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(b,E){Object.defineProperty(b,"default",{enumerable:!0,value:E})}:function(b,E){b.default=E}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(b){if(b&&b.__esModule)return b;var E={};if(b!=null)for(var I in b)I!=="default"&&Object.prototype.hasOwnProperty.call(b,I)&&t(E,b,I);return r(E,b),E};Object.defineProperty(e,"__esModule",{value:!0}),e.TRANSACTION_TYPES=e.TransactionType=e.TransactionResult=e.LedgerEntryType=e.Type=e.Field=e.DEFAULT_DEFINITIONS=e.XrplDefinitionsBase=e.Bytes=void 0;const o=s(require$$0),n=xrplDefinitionsBase;Object.defineProperty(e,"XrplDefinitionsBase",{enumerable:!0,get:function(){return n.XrplDefinitionsBase}}),Object.defineProperty(e,"Bytes",{enumerable:!0,get:function(){return n.Bytes}});const a=new n.XrplDefinitionsBase(o,{});e.DEFAULT_DEFINITIONS=a;const l=a.type;e.Type=l;const p=a.ledgerEntryType;e.LedgerEntryType=p;const u=a.transactionType;e.TransactionType=u;const c=a.transactionResult;e.TransactionResult=c;const v=a.field;e.Field=v;const w=a.transactionNames;e.TRANSACTION_TYPES=w})(enums);var types$5={},accountId={},dist$1={},xrpCodec={},_Buffer=safeBufferExports.Buffer;function base(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var o=e.charAt(s),n=o.charCodeAt(0);if(t[n]!==255)throw new TypeError(o+" is ambiguous");t[n]=s}var a=e.length,l=e.charAt(0),p=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function c(b){if((Array.isArray(b)||b instanceof Uint8Array)&&(b=_Buffer.from(b)),!_Buffer.isBuffer(b))throw new TypeError("Expected Buffer");if(b.length===0)return"";for(var E=0,I=0,x=0,B=b.length;x!==B&&b[x]===0;)x++,E++;for(var M=(B-x)*u+1>>>0,q=new Uint8Array(M);x!==B;){for(var U=b[x],F=0,j=M-1;(U!==0||F<I)&&j!==-1;j--,F++)U+=256*q[j]>>>0,q[j]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");I=F,x++}for(var y=M-I;y!==M&&q[y]===0;)y++;for(var T=l.repeat(E);y<M;++y)T+=e.charAt(q[y]);return T}function v(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return _Buffer.alloc(0);for(var E=0,I=0,x=0;b[E]===l;)I++,E++;for(var B=(b.length-E)*p+1>>>0,M=new Uint8Array(B);E<b.length;){var q=t[b.charCodeAt(E)];if(q===255)return;for(var U=0,F=B-1;(q!==0||U<x)&&F!==-1;F--,U++)q+=a*M[F]>>>0,M[F]=q%256>>>0,q=q/256>>>0;if(q!==0)throw new Error("Non-zero carry");x=U,E++}for(var j=B-x;j!==B&&M[j]===0;)j++;var y=_Buffer.allocUnsafe(I+(B-j));y.fill(0,0,I);for(var T=I;j!==B;)y[T++]=M[j++];return y}function w(b){var E=v(b);if(E)return E;throw new Error("Non-base"+a+" character")}return{encode:c,decodeUnsafe:v,decode:w}}var src=base,utils={};Object.defineProperty(utils,"__esModule",{value:!0});utils.concatArgs=utils.seqEqual=void 0;function seqEqual(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}utils.seqEqual=seqEqual;function isSequence(e){return typeof e!="number"}function concatArgs(...e){const t=[];return e.forEach(r=>{if(isSequence(r))for(const s of r)t.push(s);else t.push(r)}),t}utils.concatArgs=concatArgs;Object.defineProperty(xrpCodec,"__esModule",{value:!0});xrpCodec.isValidClassicAddress=xrpCodec.decodeAccountPublic=xrpCodec.encodeAccountPublic=xrpCodec.encodeNodePublic=xrpCodec.decodeNodePublic=xrpCodec.decodeAddress=xrpCodec.decodeAccountID=xrpCodec.encodeAddress=xrpCodec.encodeAccountID=xrpCodec.decodeSeed=xrpCodec.encodeSeed=xrpCodec.codec=void 0;const baseCodec=src,createHash$1=browser$a,utils_1=utils;class Codec{constructor(t){this._sha256=t.sha256,this._alphabet=t.alphabet,this._codec=baseCodec(this._alphabet)}encode(t,r){const s=r.versions;return this._encodeVersioned(t,s,r.expectedLength)}decode(t,r){var s;const o=r.versions,n=r.versionTypes,a=this.decodeChecked(t);if(o.length>1&&!r.expectedLength)throw new Error("expectedLength is required because there are >= 2 possible versions");const l=typeof o[0]=="number"?1:o[0].length,p=(s=r.expectedLength)!==null&&s!==void 0?s:a.length-l,u=a.slice(0,-p),c=a.slice(-p);for(let v=0;v<o.length;v++){const w=Array.isArray(o[v])?o[v]:[o[v]];if((0,utils_1.seqEqual)(u,w))return{version:w,bytes:c,type:n?n[v]:null}}throw new Error("version_invalid: version bytes do not match any of the provided version(s)")}encodeChecked(t){const r=this._sha256(this._sha256(t)).slice(0,4);return this._encodeRaw(Buffer$e.from((0,utils_1.concatArgs)(t,r)))}decodeChecked(t){const r=this._decodeRaw(t);if(r.length<5)throw new Error("invalid_input_size: decoded data must have length >= 5");if(!this._verifyCheckSum(r))throw new Error("checksum_invalid");return r.slice(0,-4)}_encodeVersioned(t,r,s){if(s&&t.length!==s)throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Buffer.");return this.encodeChecked(Buffer$e.from((0,utils_1.concatArgs)(r,t)))}_encodeRaw(t){return this._codec.encode(t)}_decodeRaw(t){return this._codec.decode(t)}_verifyCheckSum(t){const r=this._sha256(this._sha256(t.slice(0,-4))).slice(0,4),s=t.slice(-4);return(0,utils_1.seqEqual)(r,s)}}const ACCOUNT_ID=0,ACCOUNT_PUBLIC_KEY=35,FAMILY_SEED=33,NODE_PUBLIC=28,ED25519_SEED=[1,225,75],codecOptions={sha256(e){return createHash$1("sha256").update(Buffer$e.from(e)).digest()},alphabet:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"},codecWithXrpAlphabet=new Codec(codecOptions);xrpCodec.codec=codecWithXrpAlphabet;function encodeSeed(e,t){if(e.length!==16)throw new Error("entropy must have length 16");const r={expectedLength:16,versions:t==="ed25519"?ED25519_SEED:[FAMILY_SEED]};return codecWithXrpAlphabet.encode(e,r)}xrpCodec.encodeSeed=encodeSeed;function decodeSeed(e,t={versionTypes:["ed25519","secp256k1"],versions:[ED25519_SEED,FAMILY_SEED],expectedLength:16}){return codecWithXrpAlphabet.decode(e,t)}xrpCodec.decodeSeed=decodeSeed;function encodeAccountID(e){const t={versions:[ACCOUNT_ID],expectedLength:20};return codecWithXrpAlphabet.encode(e,t)}xrpCodec.encodeAccountID=encodeAccountID;xrpCodec.encodeAddress=encodeAccountID;function decodeAccountID(e){const t={versions:[ACCOUNT_ID],expectedLength:20};return codecWithXrpAlphabet.decode(e,t).bytes}xrpCodec.decodeAccountID=decodeAccountID;xrpCodec.decodeAddress=decodeAccountID;function decodeNodePublic(e){const t={versions:[NODE_PUBLIC],expectedLength:33};return codecWithXrpAlphabet.decode(e,t).bytes}xrpCodec.decodeNodePublic=decodeNodePublic;function encodeNodePublic(e){const t={versions:[NODE_PUBLIC],expectedLength:33};return codecWithXrpAlphabet.encode(e,t)}xrpCodec.encodeNodePublic=encodeNodePublic;function encodeAccountPublic(e){const t={versions:[ACCOUNT_PUBLIC_KEY],expectedLength:33};return codecWithXrpAlphabet.encode(e,t)}xrpCodec.encodeAccountPublic=encodeAccountPublic;function decodeAccountPublic(e){const t={versions:[ACCOUNT_PUBLIC_KEY],expectedLength:33};return codecWithXrpAlphabet.decode(e,t).bytes}xrpCodec.decodeAccountPublic=decodeAccountPublic;function isValidClassicAddress(e){try{decodeAccountID(e)}catch{return!1}return!0}xrpCodec.isValidClassicAddress=isValidClassicAddress;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(I,x,B,M){M===void 0&&(M=B);var q=Object.getOwnPropertyDescriptor(x,B);(!q||("get"in q?!x.__esModule:q.writable||q.configurable))&&(q={enumerable:!0,get:function(){return x[B]}}),Object.defineProperty(I,M,q)}:function(I,x,B,M){M===void 0&&(M=B),I[M]=x[B]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(I,x){Object.defineProperty(I,"default",{enumerable:!0,value:x})}:function(I,x){I.default=x}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(I){if(I&&I.__esModule)return I;var x={};if(I!=null)for(var B in I)B!=="default"&&Object.prototype.hasOwnProperty.call(I,B)&&t(x,I,B);return r(x,I),x};Object.defineProperty(e,"__esModule",{value:!0}),e.isValidXAddress=e.decodeXAddress=e.xAddressToClassicAddress=e.encodeXAddress=e.classicAddressToXAddress=e.isValidClassicAddress=e.decodeAccountPublic=e.encodeAccountPublic=e.decodeNodePublic=e.encodeNodePublic=e.decodeAccountID=e.encodeAccountID=e.decodeSeed=e.encodeSeed=e.codec=void 0;const o=s(requireAssert()),n=xrpCodec;Object.defineProperty(e,"codec",{enumerable:!0,get:function(){return n.codec}}),Object.defineProperty(e,"encodeSeed",{enumerable:!0,get:function(){return n.encodeSeed}}),Object.defineProperty(e,"decodeSeed",{enumerable:!0,get:function(){return n.decodeSeed}}),Object.defineProperty(e,"encodeAccountID",{enumerable:!0,get:function(){return n.encodeAccountID}}),Object.defineProperty(e,"decodeAccountID",{enumerable:!0,get:function(){return n.decodeAccountID}}),Object.defineProperty(e,"encodeNodePublic",{enumerable:!0,get:function(){return n.encodeNodePublic}}),Object.defineProperty(e,"decodeNodePublic",{enumerable:!0,get:function(){return n.decodeNodePublic}}),Object.defineProperty(e,"encodeAccountPublic",{enumerable:!0,get:function(){return n.encodeAccountPublic}}),Object.defineProperty(e,"decodeAccountPublic",{enumerable:!0,get:function(){return n.decodeAccountPublic}}),Object.defineProperty(e,"isValidClassicAddress",{enumerable:!0,get:function(){return n.isValidClassicAddress}});const a={main:Buffer$e.from([5,68]),test:Buffer$e.from([4,147])},l=4294967295;function p(I,x,B){const M=(0,n.decodeAccountID)(I);return u(M,x,B)}e.classicAddressToXAddress=p;function u(I,x,B){if(I.length!==20)throw new Error("Account ID must be 20 bytes");if(x>l)throw new Error("Invalid tag");const M=x||0,q=x===!1||x==null?0:1,U=Buffer$e.concat([B?a.test:a.main,I,Buffer$e.from([q,M&255,M>>8&255,M>>16&255,M>>24&255,0,0,0,0])]);return n.codec.encodeChecked(U)}e.encodeXAddress=u;function c(I){const{accountId:x,tag:B,test:M}=v(I);return{classicAddress:(0,n.encodeAccountID)(x),tag:B,test:M}}e.xAddressToClassicAddress=c;function v(I){const x=n.codec.decodeChecked(I),B=w(x),M=x.slice(2,22),q=b(x);return{accountId:M,tag:q,test:B}}e.decodeXAddress=v;function w(I){const x=I.slice(0,2);if(a.main.equals(x))return!1;if(a.test.equals(x))return!0;throw new Error("Invalid X-address: bad prefix")}function b(I){const x=I[22];if(x>=2)throw new Error("Unsupported X-address");return x===1?I[23]+I[24]*256+I[25]*65536+I[26]*16777216:(o.strictEqual(x,0,"flag must be zero to indicate no tag"),o.ok(Buffer$e.from("0000000000000000","hex").equals(I.slice(23,31)),"remaining bytes must be zero"),!1)}function E(I){try{v(I)}catch{return!1}return!0}e.isValidXAddress=E})(dist$1);var hash160$1={},hash$1={};Object.defineProperty(hash$1,"__esModule",{value:!0});hash$1.Hash=void 0;const serialized_type_1$7=serializedType,buffer_1$k=dist$t;let Hash$1=class extends serialized_type_1$7.Comparable{constructor(t){if(super(t),this.bytes.byteLength!==this.constructor.width)throw new Error(`Invalid Hash length ${this.bytes.byteLength}`)}static from(t){if(t instanceof this)return t;if(typeof t=="string")return new this(buffer_1$k.Buffer.from(t,"hex"));throw new Error("Cannot construct Hash from given value")}static fromParser(t,r){return new this(t.read(r??this.width))}compareTo(t){return this.bytes.compare(this.constructor.from(t).bytes)}toString(){return this.toHex()}nibblet(t){const r=t>0?t/2|0:0;let s=this.bytes[r];return t%2===0?s=(s&240)>>>4:s=s&15,s}};hash$1.Hash=Hash$1;Object.defineProperty(hash160$1,"__esModule",{value:!0});hash160$1.Hash160=void 0;const hash_1$2=hash$1,buffer_1$j=dist$t;class Hash160 extends hash_1$2.Hash{constructor(t){t&&t.byteLength===0&&(t=Hash160.ZERO_160.bytes),super(t??Hash160.ZERO_160.bytes)}}hash160$1.Hash160=Hash160;Hash160.width=20;Hash160.ZERO_160=new Hash160(buffer_1$j.Buffer.alloc(Hash160.width));Object.defineProperty(accountId,"__esModule",{value:!0});accountId.AccountID=void 0;const ripple_address_codec_1=dist$1,hash_160_1$1=hash160$1,buffer_1$i=dist$t,HEX_REGEX$2=/^[A-F0-9]{40}$/;class AccountID extends hash_160_1$1.Hash160{constructor(t){super(t??AccountID.defaultAccountID.bytes)}static from(t){if(t instanceof AccountID)return t;if(typeof t=="string")return t===""?new AccountID:HEX_REGEX$2.test(t)?new AccountID(buffer_1$i.Buffer.from(t,"hex")):this.fromBase58(t);throw new Error("Cannot construct AccountID from value given")}static fromBase58(t){if((0,ripple_address_codec_1.isValidXAddress)(t)){const r=(0,ripple_address_codec_1.xAddressToClassicAddress)(t);if(r.tag!==!1)throw new Error("Only allowed to have tag on Account or Destination");t=r.classicAddress}return new AccountID(buffer_1$i.Buffer.from((0,ripple_address_codec_1.decodeAccountID)(t)))}toJSON(){return this.toBase58()}toBase58(){return(0,ripple_address_codec_1.encodeAccountID)(this.bytes)}}accountId.AccountID=AccountID;AccountID.defaultAccountID=new AccountID(buffer_1$i.Buffer.alloc(20));var amount={},decimal={exports:{}};(function(e){(function(t){var r=9e15,s=1e9,o="0123456789abcdef",n="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",a="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",l={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-r,maxE:r,crypto:!1},p,u,c,v,w=!0,b="[DecimalError] ",E=b+"Invalid argument: ",I=b+"Precision limit exceeded",x=b+"crypto unavailable",B="[object Decimal]",M=Math.floor,q=Math.pow,U=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,F=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,j=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,y=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,T=1e7,D=7,L=9007199254740991,C=n.length-1,d=a.length-1,_={toStringTag:B};_.absoluteValue=_.abs=function(){var ie=new this.constructor(this);return ie.s<0&&(ie.s=1),m(ie)},_.ceil=function(){return m(new this.constructor(this),this.e+1,2)},_.clampedTo=_.clamp=function(ie,de){var ve,_e=this,Ee=_e.constructor;if(ie=new Ee(ie),de=new Ee(de),!ie.s||!de.s)return new Ee(NaN);if(ie.gt(de))throw Error(E+de);return ve=_e.cmp(ie),ve<0?ie:_e.cmp(de)>0?de:new Ee(_e)},_.comparedTo=_.cmp=function(ie){var de,ve,_e,Ee,Se=this,Pe=Se.d,Le=(ie=new Se.constructor(ie)).d,Ke=Se.s,Fe=ie.s;if(!Pe||!Le)return!Ke||!Fe?NaN:Ke!==Fe?Ke:Pe===Le?0:!Pe^Ke<0?1:-1;if(!Pe[0]||!Le[0])return Pe[0]?Ke:Le[0]?-Fe:0;if(Ke!==Fe)return Ke;if(Se.e!==ie.e)return Se.e>ie.e^Ke<0?1:-1;for(_e=Pe.length,Ee=Le.length,de=0,ve=_e<Ee?_e:Ee;de<ve;++de)if(Pe[de]!==Le[de])return Pe[de]>Le[de]^Ke<0?1:-1;return _e===Ee?0:_e>Ee^Ke<0?1:-1},_.cosine=_.cos=function(){var ie,de,ve=this,_e=ve.constructor;return ve.d?ve.d[0]?(ie=_e.precision,de=_e.rounding,_e.precision=ie+Math.max(ve.e,ve.sd())+D,_e.rounding=1,ve=k(_e,Ce(_e,ve)),_e.precision=ie,_e.rounding=de,m(v==2||v==3?ve.neg():ve,ie,de,!0)):new _e(1):new _e(NaN)},_.cubeRoot=_.cbrt=function(){var ie,de,ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze=this,et=ze.constructor;if(!ze.isFinite()||ze.isZero())return new et(ze);for(w=!1,Se=ze.s*q(ze.s*ze,1/3),!Se||Math.abs(Se)==1/0?(ve=$(ze.d),ie=ze.e,(Se=(ie-ve.length+1)%3)&&(ve+=Se==1||Se==-2?"0":"00"),Se=q(ve,1/3),ie=M((ie+1)/3)-(ie%3==(ie<0?-1:2)),Se==1/0?ve="5e"+ie:(ve=Se.toExponential(),ve=ve.slice(0,ve.indexOf("e")+1)+ie),_e=new et(ve),_e.s=ze.s):_e=new et(Se.toString()),Pe=(ie=et.precision)+3;;)if(Le=_e,Ke=Le.times(Le).times(Le),Fe=Ke.plus(ze),_e=A(Fe.plus(ze).times(Le),Fe.plus(Ke),Pe+2,1),$(Le.d).slice(0,Pe)===(ve=$(_e.d)).slice(0,Pe))if(ve=ve.slice(Pe-3,Pe+1),ve=="9999"||!Ee&&ve=="4999"){if(!Ee&&(m(Le,ie+1,0),Le.times(Le).times(Le).eq(ze))){_e=Le;break}Pe+=4,Ee=1}else{(!+ve||!+ve.slice(1)&&ve.charAt(0)=="5")&&(m(_e,ie+1,1),de=!_e.times(_e).times(_e).eq(ze));break}return w=!0,m(_e,ie,et.rounding,de)},_.decimalPlaces=_.dp=function(){var ie,de=this.d,ve=NaN;if(de){if(ie=de.length-1,ve=(ie-M(this.e/D))*D,ie=de[ie],ie)for(;ie%10==0;ie/=10)ve--;ve<0&&(ve=0)}return ve},_.dividedBy=_.div=function(ie){return A(this,new this.constructor(ie))},_.dividedToIntegerBy=_.divToInt=function(ie){var de=this,ve=de.constructor;return m(A(de,new ve(ie),0,1,1),ve.precision,ve.rounding)},_.equals=_.eq=function(ie){return this.cmp(ie)===0},_.floor=function(){return m(new this.constructor(this),this.e+1,3)},_.greaterThan=_.gt=function(ie){return this.cmp(ie)>0},_.greaterThanOrEqualTo=_.gte=function(ie){var de=this.cmp(ie);return de==1||de===0},_.hyperbolicCosine=_.cosh=function(){var ie,de,ve,_e,Ee,Se=this,Pe=Se.constructor,Le=new Pe(1);if(!Se.isFinite())return new Pe(Se.s?1/0:NaN);if(Se.isZero())return Le;ve=Pe.precision,_e=Pe.rounding,Pe.precision=ve+Math.max(Se.e,Se.sd())+4,Pe.rounding=1,Ee=Se.d.length,Ee<32?(ie=Math.ceil(Ee/3),de=(1/Be(4,ie)).toString()):(ie=16,de="2.3283064365386962890625e-10"),Se=Re(Pe,1,Se.times(de),new Pe(1),!0);for(var Ke,Fe=ie,ze=new Pe(8);Fe--;)Ke=Se.times(Se),Se=Le.minus(Ke.times(ze.minus(Ke.times(ze))));return m(Se,Pe.precision=ve,Pe.rounding=_e,!0)},_.hyperbolicSine=_.sinh=function(){var ie,de,ve,_e,Ee=this,Se=Ee.constructor;if(!Ee.isFinite()||Ee.isZero())return new Se(Ee);if(de=Se.precision,ve=Se.rounding,Se.precision=de+Math.max(Ee.e,Ee.sd())+4,Se.rounding=1,_e=Ee.d.length,_e<3)Ee=Re(Se,2,Ee,Ee,!0);else{ie=1.4*Math.sqrt(_e),ie=ie>16?16:ie|0,Ee=Ee.times(1/Be(5,ie)),Ee=Re(Se,2,Ee,Ee,!0);for(var Pe,Le=new Se(5),Ke=new Se(16),Fe=new Se(20);ie--;)Pe=Ee.times(Ee),Ee=Ee.times(Le.plus(Pe.times(Ke.times(Pe).plus(Fe))))}return Se.precision=de,Se.rounding=ve,m(Ee,de,ve,!0)},_.hyperbolicTangent=_.tanh=function(){var ie,de,ve=this,_e=ve.constructor;return ve.isFinite()?ve.isZero()?new _e(ve):(ie=_e.precision,de=_e.rounding,_e.precision=ie+7,_e.rounding=1,A(ve.sinh(),ve.cosh(),_e.precision=ie,_e.rounding=de)):new _e(ve.s)},_.inverseCosine=_.acos=function(){var ie,de=this,ve=de.constructor,_e=de.abs().cmp(1),Ee=ve.precision,Se=ve.rounding;return _e!==-1?_e===0?de.isNeg()?X(ve,Ee,Se):new ve(0):new ve(NaN):de.isZero()?X(ve,Ee+4,Se).times(.5):(ve.precision=Ee+6,ve.rounding=1,de=de.asin(),ie=X(ve,Ee+4,Se).times(.5),ve.precision=Ee,ve.rounding=Se,ie.minus(de))},_.inverseHyperbolicCosine=_.acosh=function(){var ie,de,ve=this,_e=ve.constructor;return ve.lte(1)?new _e(ve.eq(1)?0:NaN):ve.isFinite()?(ie=_e.precision,de=_e.rounding,_e.precision=ie+Math.max(Math.abs(ve.e),ve.sd())+4,_e.rounding=1,w=!1,ve=ve.times(ve).minus(1).sqrt().plus(ve),w=!0,_e.precision=ie,_e.rounding=de,ve.ln()):new _e(ve)},_.inverseHyperbolicSine=_.asinh=function(){var ie,de,ve=this,_e=ve.constructor;return!ve.isFinite()||ve.isZero()?new _e(ve):(ie=_e.precision,de=_e.rounding,_e.precision=ie+2*Math.max(Math.abs(ve.e),ve.sd())+6,_e.rounding=1,w=!1,ve=ve.times(ve).plus(1).sqrt().plus(ve),w=!0,_e.precision=ie,_e.rounding=de,ve.ln())},_.inverseHyperbolicTangent=_.atanh=function(){var ie,de,ve,_e,Ee=this,Se=Ee.constructor;return Ee.isFinite()?Ee.e>=0?new Se(Ee.abs().eq(1)?Ee.s/0:Ee.isZero()?Ee:NaN):(ie=Se.precision,de=Se.rounding,_e=Ee.sd(),Math.max(_e,ie)<2*-Ee.e-1?m(new Se(Ee),ie,de,!0):(Se.precision=ve=_e-Ee.e,Ee=A(Ee.plus(1),new Se(1).minus(Ee),ve+ie,1),Se.precision=ie+4,Se.rounding=1,Ee=Ee.ln(),Se.precision=ie,Se.rounding=de,Ee.times(.5))):new Se(NaN)},_.inverseSine=_.asin=function(){var ie,de,ve,_e,Ee=this,Se=Ee.constructor;return Ee.isZero()?new Se(Ee):(de=Ee.abs().cmp(1),ve=Se.precision,_e=Se.rounding,de!==-1?de===0?(ie=X(Se,ve+4,_e).times(.5),ie.s=Ee.s,ie):new Se(NaN):(Se.precision=ve+6,Se.rounding=1,Ee=Ee.div(new Se(1).minus(Ee.times(Ee)).sqrt().plus(1)).atan(),Se.precision=ve,Se.rounding=_e,Ee.times(2)))},_.inverseTangent=_.atan=function(){var ie,de,ve,_e,Ee,Se,Pe,Le,Ke,Fe=this,ze=Fe.constructor,et=ze.precision,nt=ze.rounding;if(Fe.isFinite()){if(Fe.isZero())return new ze(Fe);if(Fe.abs().eq(1)&&et+4<=d)return Pe=X(ze,et+4,nt).times(.25),Pe.s=Fe.s,Pe}else{if(!Fe.s)return new ze(NaN);if(et+4<=d)return Pe=X(ze,et+4,nt).times(.5),Pe.s=Fe.s,Pe}for(ze.precision=Le=et+10,ze.rounding=1,ve=Math.min(28,Le/D+2|0),ie=ve;ie;--ie)Fe=Fe.div(Fe.times(Fe).plus(1).sqrt().plus(1));for(w=!1,de=Math.ceil(Le/D),_e=1,Ke=Fe.times(Fe),Pe=new ze(Fe),Ee=Fe;ie!==-1;)if(Ee=Ee.times(Ke),Se=Pe.minus(Ee.div(_e+=2)),Ee=Ee.times(Ke),Pe=Se.plus(Ee.div(_e+=2)),Pe.d[de]!==void 0)for(ie=de;Pe.d[ie]===Se.d[ie]&&ie--;);return ve&&(Pe=Pe.times(2<<ve-1)),w=!0,m(Pe,ze.precision=et,ze.rounding=nt,!0)},_.isFinite=function(){return!!this.d},_.isInteger=_.isInt=function(){return!!this.d&&M(this.e/D)>this.d.length-2},_.isNaN=function(){return!this.s},_.isNegative=_.isNeg=function(){return this.s<0},_.isPositive=_.isPos=function(){return this.s>0},_.isZero=function(){return!!this.d&&this.d[0]===0},_.lessThan=_.lt=function(ie){return this.cmp(ie)<0},_.lessThanOrEqualTo=_.lte=function(ie){return this.cmp(ie)<1},_.logarithm=_.log=function(ie){var de,ve,_e,Ee,Se,Pe,Le,Ke,Fe=this,ze=Fe.constructor,et=ze.precision,nt=ze.rounding,ct=5;if(ie==null)ie=new ze(10),de=!0;else{if(ie=new ze(ie),ve=ie.d,ie.s<0||!ve||!ve[0]||ie.eq(1))return new ze(NaN);de=ie.eq(10)}if(ve=Fe.d,Fe.s<0||!ve||!ve[0]||Fe.eq(1))return new ze(ve&&!ve[0]?-1/0:Fe.s!=1?NaN:ve?0:1/0);if(de)if(ve.length>1)Se=!0;else{for(Ee=ve[0];Ee%10===0;)Ee/=10;Se=Ee!==1}if(w=!1,Le=et+ct,Pe=G(Fe,Le),_e=de?J(ze,Le+10):G(ie,Le),Ke=A(Pe,_e,Le,1),O(Ke.d,Ee=et,nt))do if(Le+=10,Pe=G(Fe,Le),_e=de?J(ze,Le+10):G(ie,Le),Ke=A(Pe,_e,Le,1),!Se){+$(Ke.d).slice(Ee+1,Ee+15)+1==1e14&&(Ke=m(Ke,et+1,0));break}while(O(Ke.d,Ee+=10,nt));return w=!0,m(Ke,et,nt)},_.minus=_.sub=function(ie){var de,ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze,et,nt,ct=this,yt=ct.constructor;if(ie=new yt(ie),!ct.d||!ie.d)return!ct.s||!ie.s?ie=new yt(NaN):ct.d?ie.s=-ie.s:ie=new yt(ie.d||ct.s!==ie.s?ct:NaN),ie;if(ct.s!=ie.s)return ie.s=-ie.s,ct.plus(ie);if(Fe=ct.d,nt=ie.d,Le=yt.precision,Ke=yt.rounding,!Fe[0]||!nt[0]){if(nt[0])ie.s=-ie.s;else if(Fe[0])ie=new yt(ct);else return new yt(Ke===3?-0:0);return w?m(ie,Le,Ke):ie}if(ve=M(ie.e/D),ze=M(ct.e/D),Fe=Fe.slice(),Se=ze-ve,Se){for(et=Se<0,et?(de=Fe,Se=-Se,Pe=nt.length):(de=nt,ve=ze,Pe=Fe.length),_e=Math.max(Math.ceil(Le/D),Pe)+2,Se>_e&&(Se=_e,de.length=1),de.reverse(),_e=Se;_e--;)de.push(0);de.reverse()}else{for(_e=Fe.length,Pe=nt.length,et=_e<Pe,et&&(Pe=_e),_e=0;_e<Pe;_e++)if(Fe[_e]!=nt[_e]){et=Fe[_e]<nt[_e];break}Se=0}for(et&&(de=Fe,Fe=nt,nt=de,ie.s=-ie.s),Pe=Fe.length,_e=nt.length-Pe;_e>0;--_e)Fe[Pe++]=0;for(_e=nt.length;_e>Se;){if(Fe[--_e]<nt[_e]){for(Ee=_e;Ee&&Fe[--Ee]===0;)Fe[Ee]=T-1;--Fe[Ee],Fe[_e]+=T}Fe[_e]-=nt[_e]}for(;Fe[--Pe]===0;)Fe.pop();for(;Fe[0]===0;Fe.shift())--ve;return Fe[0]?(ie.d=Fe,ie.e=H(Fe,ve),w?m(ie,Le,Ke):ie):new yt(Ke===3?-0:0)},_.modulo=_.mod=function(ie){var de,ve=this,_e=ve.constructor;return ie=new _e(ie),!ve.d||!ie.s||ie.d&&!ie.d[0]?new _e(NaN):!ie.d||ve.d&&!ve.d[0]?m(new _e(ve),_e.precision,_e.rounding):(w=!1,_e.modulo==9?(de=A(ve,ie.abs(),0,3,1),de.s*=ie.s):de=A(ve,ie,0,_e.modulo,1),de=de.times(ie),w=!0,ve.minus(de))},_.naturalExponential=_.exp=function(){return Y(this)},_.naturalLogarithm=_.ln=function(){return G(this)},_.negated=_.neg=function(){var ie=new this.constructor(this);return ie.s=-ie.s,m(ie)},_.plus=_.add=function(ie){var de,ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze,et=this,nt=et.constructor;if(ie=new nt(ie),!et.d||!ie.d)return!et.s||!ie.s?ie=new nt(NaN):et.d||(ie=new nt(ie.d||et.s===ie.s?et:NaN)),ie;if(et.s!=ie.s)return ie.s=-ie.s,et.minus(ie);if(Fe=et.d,ze=ie.d,Le=nt.precision,Ke=nt.rounding,!Fe[0]||!ze[0])return ze[0]||(ie=new nt(et)),w?m(ie,Le,Ke):ie;if(Se=M(et.e/D),_e=M(ie.e/D),Fe=Fe.slice(),Ee=Se-_e,Ee){for(Ee<0?(ve=Fe,Ee=-Ee,Pe=ze.length):(ve=ze,_e=Se,Pe=Fe.length),Se=Math.ceil(Le/D),Pe=Se>Pe?Se+1:Pe+1,Ee>Pe&&(Ee=Pe,ve.length=1),ve.reverse();Ee--;)ve.push(0);ve.reverse()}for(Pe=Fe.length,Ee=ze.length,Pe-Ee<0&&(Ee=Pe,ve=ze,ze=Fe,Fe=ve),de=0;Ee;)de=(Fe[--Ee]=Fe[Ee]+ze[Ee]+de)/T|0,Fe[Ee]%=T;for(de&&(Fe.unshift(de),++_e),Pe=Fe.length;Fe[--Pe]==0;)Fe.pop();return ie.d=Fe,ie.e=H(Fe,_e),w?m(ie,Le,Ke):ie},_.precision=_.sd=function(ie){var de,ve=this;if(ie!==void 0&&ie!==!!ie&&ie!==1&&ie!==0)throw Error(E+ie);return ve.d?(de=se(ve.d),ie&&ve.e+1>de&&(de=ve.e+1)):de=NaN,de},_.round=function(){var ie=this,de=ie.constructor;return m(new de(ie),ie.e+1,de.rounding)},_.sine=_.sin=function(){var ie,de,ve=this,_e=ve.constructor;return ve.isFinite()?ve.isZero()?new _e(ve):(ie=_e.precision,de=_e.rounding,_e.precision=ie+Math.max(ve.e,ve.sd())+D,_e.rounding=1,ve=me(_e,Ce(_e,ve)),_e.precision=ie,_e.rounding=de,m(v>2?ve.neg():ve,ie,de,!0)):new _e(NaN)},_.squareRoot=_.sqrt=function(){var ie,de,ve,_e,Ee,Se,Pe=this,Le=Pe.d,Ke=Pe.e,Fe=Pe.s,ze=Pe.constructor;if(Fe!==1||!Le||!Le[0])return new ze(!Fe||Fe<0&&(!Le||Le[0])?NaN:Le?Pe:1/0);for(w=!1,Fe=Math.sqrt(+Pe),Fe==0||Fe==1/0?(de=$(Le),(de.length+Ke)%2==0&&(de+="0"),Fe=Math.sqrt(de),Ke=M((Ke+1)/2)-(Ke<0||Ke%2),Fe==1/0?de="5e"+Ke:(de=Fe.toExponential(),de=de.slice(0,de.indexOf("e")+1)+Ke),_e=new ze(de)):_e=new ze(Fe.toString()),ve=(Ke=ze.precision)+3;;)if(Se=_e,_e=Se.plus(A(Pe,Se,ve+2,1)).times(.5),$(Se.d).slice(0,ve)===(de=$(_e.d)).slice(0,ve))if(de=de.slice(ve-3,ve+1),de=="9999"||!Ee&&de=="4999"){if(!Ee&&(m(Se,Ke+1,0),Se.times(Se).eq(Pe))){_e=Se;break}ve+=4,Ee=1}else{(!+de||!+de.slice(1)&&de.charAt(0)=="5")&&(m(_e,Ke+1,1),ie=!_e.times(_e).eq(Pe));break}return w=!0,m(_e,Ke,ze.rounding,ie)},_.tangent=_.tan=function(){var ie,de,ve=this,_e=ve.constructor;return ve.isFinite()?ve.isZero()?new _e(ve):(ie=_e.precision,de=_e.rounding,_e.precision=ie+10,_e.rounding=1,ve=ve.sin(),ve.s=1,ve=A(ve,new _e(1).minus(ve.times(ve)).sqrt(),ie+10,0),_e.precision=ie,_e.rounding=de,m(v==2||v==4?ve.neg():ve,ie,de,!0)):new _e(NaN)},_.times=_.mul=function(ie){var de,ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze=this,et=ze.constructor,nt=ze.d,ct=(ie=new et(ie)).d;if(ie.s*=ze.s,!nt||!nt[0]||!ct||!ct[0])return new et(!ie.s||nt&&!nt[0]&&!ct||ct&&!ct[0]&&!nt?NaN:!nt||!ct?ie.s/0:ie.s*0);for(ve=M(ze.e/D)+M(ie.e/D),Ke=nt.length,Fe=ct.length,Ke<Fe&&(Se=nt,nt=ct,ct=Se,Pe=Ke,Ke=Fe,Fe=Pe),Se=[],Pe=Ke+Fe,_e=Pe;_e--;)Se.push(0);for(_e=Fe;--_e>=0;){for(de=0,Ee=Ke+_e;Ee>_e;)Le=Se[Ee]+ct[_e]*nt[Ee-_e-1]+de,Se[Ee--]=Le%T|0,de=Le/T|0;Se[Ee]=(Se[Ee]+de)%T|0}for(;!Se[--Pe];)Se.pop();return de?++ve:Se.shift(),ie.d=Se,ie.e=H(Se,ve),w?m(ie,et.precision,et.rounding):ie},_.toBinary=function(ie,de){return $e(this,2,ie,de)},_.toDecimalPlaces=_.toDP=function(ie,de){var ve=this,_e=ve.constructor;return ve=new _e(ve),ie===void 0?ve:(S(ie,0,s),de===void 0?de=_e.rounding:S(de,0,8),m(ve,ie+ve.e+1,de))},_.toExponential=function(ie,de){var ve,_e=this,Ee=_e.constructor;return ie===void 0?ve=P(_e,!0):(S(ie,0,s),de===void 0?de=Ee.rounding:S(de,0,8),_e=m(new Ee(_e),ie+1,de),ve=P(_e,!0,ie+1)),_e.isNeg()&&!_e.isZero()?"-"+ve:ve},_.toFixed=function(ie,de){var ve,_e,Ee=this,Se=Ee.constructor;return ie===void 0?ve=P(Ee):(S(ie,0,s),de===void 0?de=Se.rounding:S(de,0,8),_e=m(new Se(Ee),ie+Ee.e+1,de),ve=P(_e,!1,ie+_e.e+1)),Ee.isNeg()&&!Ee.isZero()?"-"+ve:ve},_.toFraction=function(ie){var de,ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze,et,nt,ct=this,yt=ct.d,dt=ct.constructor;if(!yt)return new dt(ct);if(Fe=ve=new dt(1),_e=Ke=new dt(0),de=new dt(_e),Se=de.e=se(yt)-ct.e-1,Pe=Se%D,de.d[0]=q(10,Pe<0?D+Pe:Pe),ie==null)ie=Se>0?de:Fe;else{if(Le=new dt(ie),!Le.isInt()||Le.lt(Fe))throw Error(E+Le);ie=Le.gt(de)?Se>0?de:Fe:Le}for(w=!1,Le=new dt($(yt)),ze=dt.precision,dt.precision=Se=yt.length*D*2;et=A(Le,de,0,1,1),Ee=ve.plus(et.times(_e)),Ee.cmp(ie)!=1;)ve=_e,_e=Ee,Ee=Fe,Fe=Ke.plus(et.times(Ee)),Ke=Ee,Ee=de,de=Le.minus(et.times(Ee)),Le=Ee;return Ee=A(ie.minus(ve),_e,0,1,1),Ke=Ke.plus(Ee.times(Fe)),ve=ve.plus(Ee.times(_e)),Ke.s=Fe.s=ct.s,nt=A(Fe,_e,Se,1).minus(ct).abs().cmp(A(Ke,ve,Se,1).minus(ct).abs())<1?[Fe,_e]:[Ke,ve],dt.precision=ze,w=!0,nt},_.toHexadecimal=_.toHex=function(ie,de){return $e(this,16,ie,de)},_.toNearest=function(ie,de){var ve=this,_e=ve.constructor;if(ve=new _e(ve),ie==null){if(!ve.d)return ve;ie=new _e(1),de=_e.rounding}else{if(ie=new _e(ie),de===void 0?de=_e.rounding:S(de,0,8),!ve.d)return ie.s?ve:ie;if(!ie.d)return ie.s&&(ie.s=ve.s),ie}return ie.d[0]?(w=!1,ve=A(ve,ie,0,de,1).times(ie),w=!0,m(ve)):(ie.s=ve.s,ve=ie),ve},_.toNumber=function(){return+this},_.toOctal=function(ie,de){return $e(this,8,ie,de)},_.toPower=_.pow=function(ie){var de,ve,_e,Ee,Se,Pe,Le=this,Ke=Le.constructor,Fe=+(ie=new Ke(ie));if(!Le.d||!ie.d||!Le.d[0]||!ie.d[0])return new Ke(q(+Le,Fe));if(Le=new Ke(Le),Le.eq(1))return Le;if(_e=Ke.precision,Se=Ke.rounding,ie.eq(1))return m(Le,_e,Se);if(de=M(ie.e/D),de>=ie.d.length-1&&(ve=Fe<0?-Fe:Fe)<=L)return Ee=Z(Ke,Le,ve,_e),ie.s<0?new Ke(1).div(Ee):m(Ee,_e,Se);if(Pe=Le.s,Pe<0){if(de<ie.d.length-1)return new Ke(NaN);if(ie.d[de]&1||(Pe=1),Le.e==0&&Le.d[0]==1&&Le.d.length==1)return Le.s=Pe,Le}return ve=q(+Le,Fe),de=ve==0||!isFinite(ve)?M(Fe*(Math.log("0."+$(Le.d))/Math.LN10+Le.e+1)):new Ke(ve+"").e,de>Ke.maxE+1||de<Ke.minE-1?new Ke(de>0?Pe/0:0):(w=!1,Ke.rounding=Le.s=1,ve=Math.min(12,(de+"").length),Ee=Y(ie.times(G(Le,_e+ve)),_e),Ee.d&&(Ee=m(Ee,_e+5,1),O(Ee.d,_e,Se)&&(de=_e+10,Ee=m(Y(ie.times(G(Le,de+ve)),de),de+5,1),+$(Ee.d).slice(_e+1,_e+15)+1==1e14&&(Ee=m(Ee,_e+1,0)))),Ee.s=Pe,w=!0,Ke.rounding=Se,m(Ee,_e,Se))},_.toPrecision=function(ie,de){var ve,_e=this,Ee=_e.constructor;return ie===void 0?ve=P(_e,_e.e<=Ee.toExpNeg||_e.e>=Ee.toExpPos):(S(ie,1,s),de===void 0?de=Ee.rounding:S(de,0,8),_e=m(new Ee(_e),ie,de),ve=P(_e,ie<=_e.e||_e.e<=Ee.toExpNeg,ie)),_e.isNeg()&&!_e.isZero()?"-"+ve:ve},_.toSignificantDigits=_.toSD=function(ie,de){var ve=this,_e=ve.constructor;return ie===void 0?(ie=_e.precision,de=_e.rounding):(S(ie,1,s),de===void 0?de=_e.rounding:S(de,0,8)),m(new _e(ve),ie,de)},_.toString=function(){var ie=this,de=ie.constructor,ve=P(ie,ie.e<=de.toExpNeg||ie.e>=de.toExpPos);return ie.isNeg()&&!ie.isZero()?"-"+ve:ve},_.truncated=_.trunc=function(){return m(new this.constructor(this),this.e+1,1)},_.valueOf=_.toJSON=function(){var ie=this,de=ie.constructor,ve=P(ie,ie.e<=de.toExpNeg||ie.e>=de.toExpPos);return ie.isNeg()?"-"+ve:ve};function $(ie){var de,ve,_e,Ee=ie.length-1,Se="",Pe=ie[0];if(Ee>0){for(Se+=Pe,de=1;de<Ee;de++)_e=ie[de]+"",ve=D-_e.length,ve&&(Se+=ne(ve)),Se+=_e;Pe=ie[de],_e=Pe+"",ve=D-_e.length,ve&&(Se+=ne(ve))}else if(Pe===0)return"0";for(;Pe%10===0;)Pe/=10;return Se+Pe}function S(ie,de,ve){if(ie!==~~ie||ie<de||ie>ve)throw Error(E+ie)}function O(ie,de,ve,_e){var Ee,Se,Pe,Le;for(Se=ie[0];Se>=10;Se/=10)--de;return--de<0?(de+=D,Ee=0):(Ee=Math.ceil((de+1)/D),de%=D),Se=q(10,D-de),Le=ie[Ee]%Se|0,_e==null?de<3?(de==0?Le=Le/100|0:de==1&&(Le=Le/10|0),Pe=ve<4&&Le==99999||ve>3&&Le==49999||Le==5e4||Le==0):Pe=(ve<4&&Le+1==Se||ve>3&&Le+1==Se/2)&&(ie[Ee+1]/Se/100|0)==q(10,de-2)-1||(Le==Se/2||Le==0)&&(ie[Ee+1]/Se/100|0)==0:de<4?(de==0?Le=Le/1e3|0:de==1?Le=Le/100|0:de==2&&(Le=Le/10|0),Pe=(_e||ve<4)&&Le==9999||!_e&&ve>3&&Le==4999):Pe=((_e||ve<4)&&Le+1==Se||!_e&&ve>3&&Le+1==Se/2)&&(ie[Ee+1]/Se/1e3|0)==q(10,de-3)-1,Pe}function N(ie,de,ve){for(var _e,Ee=[0],Se,Pe=0,Le=ie.length;Pe<Le;){for(Se=Ee.length;Se--;)Ee[Se]*=de;for(Ee[0]+=o.indexOf(ie.charAt(Pe++)),_e=0;_e<Ee.length;_e++)Ee[_e]>ve-1&&(Ee[_e+1]===void 0&&(Ee[_e+1]=0),Ee[_e+1]+=Ee[_e]/ve|0,Ee[_e]%=ve)}return Ee.reverse()}function k(ie,de){var ve,_e,Ee;if(de.isZero())return de;_e=de.d.length,_e<32?(ve=Math.ceil(_e/3),Ee=(1/Be(4,ve)).toString()):(ve=16,Ee="2.3283064365386962890625e-10"),ie.precision+=ve,de=Re(ie,1,de.times(Ee),new ie(1));for(var Se=ve;Se--;){var Pe=de.times(de);de=Pe.times(Pe).minus(Pe).times(8).plus(1)}return ie.precision-=ve,de}var A=function(){function ie(_e,Ee,Se){var Pe,Le=0,Ke=_e.length;for(_e=_e.slice();Ke--;)Pe=_e[Ke]*Ee+Le,_e[Ke]=Pe%Se|0,Le=Pe/Se|0;return Le&&_e.unshift(Le),_e}function de(_e,Ee,Se,Pe){var Le,Ke;if(Se!=Pe)Ke=Se>Pe?1:-1;else for(Le=Ke=0;Le<Se;Le++)if(_e[Le]!=Ee[Le]){Ke=_e[Le]>Ee[Le]?1:-1;break}return Ke}function ve(_e,Ee,Se,Pe){for(var Le=0;Se--;)_e[Se]-=Le,Le=_e[Se]<Ee[Se]?1:0,_e[Se]=Le*Pe+_e[Se]-Ee[Se];for(;!_e[0]&&_e.length>1;)_e.shift()}return function(_e,Ee,Se,Pe,Le,Ke){var Fe,ze,et,nt,ct,yt,dt,vt,gt,bt,wt,It,Ct,Et,Ot,xt,St,Mt,Rt,Bt,Dt=_e.constructor,At=_e.s==Ee.s?1:-1,Tt=_e.d,$t=Ee.d;if(!Tt||!Tt[0]||!$t||!$t[0])return new Dt(!_e.s||!Ee.s||(Tt?$t&&Tt[0]==$t[0]:!$t)?NaN:Tt&&Tt[0]==0||!$t?At*0:At/0);for(Ke?(ct=1,ze=_e.e-Ee.e):(Ke=T,ct=D,ze=M(_e.e/ct)-M(Ee.e/ct)),Rt=$t.length,St=Tt.length,gt=new Dt(At),bt=gt.d=[],et=0;$t[et]==(Tt[et]||0);et++);if($t[et]>(Tt[et]||0)&&ze--,Se==null?(Et=Se=Dt.precision,Pe=Dt.rounding):Le?Et=Se+(_e.e-Ee.e)+1:Et=Se,Et<0)bt.push(1),yt=!0;else{if(Et=Et/ct+2|0,et=0,Rt==1){for(nt=0,$t=$t[0],Et++;(et<St||nt)&&Et--;et++)Ot=nt*Ke+(Tt[et]||0),bt[et]=Ot/$t|0,nt=Ot%$t|0;yt=nt||et<St}else{for(nt=Ke/($t[0]+1)|0,nt>1&&($t=ie($t,nt,Ke),Tt=ie(Tt,nt,Ke),Rt=$t.length,St=Tt.length),xt=Rt,wt=Tt.slice(0,Rt),It=wt.length;It<Rt;)wt[It++]=0;Bt=$t.slice(),Bt.unshift(0),Mt=$t[0],$t[1]>=Ke/2&&++Mt;do nt=0,Fe=de($t,wt,Rt,It),Fe<0?(Ct=wt[0],Rt!=It&&(Ct=Ct*Ke+(wt[1]||0)),nt=Ct/Mt|0,nt>1?(nt>=Ke&&(nt=Ke-1),dt=ie($t,nt,Ke),vt=dt.length,It=wt.length,Fe=de(dt,wt,vt,It),Fe==1&&(nt--,ve(dt,Rt<vt?Bt:$t,vt,Ke))):(nt==0&&(Fe=nt=1),dt=$t.slice()),vt=dt.length,vt<It&&dt.unshift(0),ve(wt,dt,It,Ke),Fe==-1&&(It=wt.length,Fe=de($t,wt,Rt,It),Fe<1&&(nt++,ve(wt,Rt<It?Bt:$t,It,Ke))),It=wt.length):Fe===0&&(nt++,wt=[0]),bt[et++]=nt,Fe&&wt[0]?wt[It++]=Tt[xt]||0:(wt=[Tt[xt]],It=1);while((xt++<St||wt[0]!==void 0)&&Et--);yt=wt[0]!==void 0}bt[0]||bt.shift()}if(ct==1)gt.e=ze,u=yt;else{for(et=1,nt=bt[0];nt>=10;nt/=10)et++;gt.e=et+ze*ct-1,m(gt,Le?Se+gt.e+1:Se,Pe,yt)}return gt}}();function m(ie,de,ve,_e){var Ee,Se,Pe,Le,Ke,Fe,ze,et,nt,ct=ie.constructor;e:if(de!=null){if(et=ie.d,!et)return ie;for(Ee=1,Le=et[0];Le>=10;Le/=10)Ee++;if(Se=de-Ee,Se<0)Se+=D,Pe=de,ze=et[nt=0],Ke=ze/q(10,Ee-Pe-1)%10|0;else if(nt=Math.ceil((Se+1)/D),Le=et.length,nt>=Le)if(_e){for(;Le++<=nt;)et.push(0);ze=Ke=0,Ee=1,Se%=D,Pe=Se-D+1}else break e;else{for(ze=Le=et[nt],Ee=1;Le>=10;Le/=10)Ee++;Se%=D,Pe=Se-D+Ee,Ke=Pe<0?0:ze/q(10,Ee-Pe-1)%10|0}if(_e=_e||de<0||et[nt+1]!==void 0||(Pe<0?ze:ze%q(10,Ee-Pe-1)),Fe=ve<4?(Ke||_e)&&(ve==0||ve==(ie.s<0?3:2)):Ke>5||Ke==5&&(ve==4||_e||ve==6&&(Se>0?Pe>0?ze/q(10,Ee-Pe):0:et[nt-1])%10&1||ve==(ie.s<0?8:7)),de<1||!et[0])return et.length=0,Fe?(de-=ie.e+1,et[0]=q(10,(D-de%D)%D),ie.e=-de||0):et[0]=ie.e=0,ie;if(Se==0?(et.length=nt,Le=1,nt--):(et.length=nt+1,Le=q(10,D-Se),et[nt]=Pe>0?(ze/q(10,Ee-Pe)%q(10,Pe)|0)*Le:0),Fe)for(;;)if(nt==0){for(Se=1,Pe=et[0];Pe>=10;Pe/=10)Se++;for(Pe=et[0]+=Le,Le=1;Pe>=10;Pe/=10)Le++;Se!=Le&&(ie.e++,et[0]==T&&(et[0]=1));break}else{if(et[nt]+=Le,et[nt]!=T)break;et[nt--]=0,Le=1}for(Se=et.length;et[--Se]===0;)et.pop()}return w&&(ie.e>ct.maxE?(ie.d=null,ie.e=NaN):ie.e<ct.minE&&(ie.e=0,ie.d=[0])),ie}function P(ie,de,ve){if(!ie.isFinite())return V(ie);var _e,Ee=ie.e,Se=$(ie.d),Pe=Se.length;return de?(ve&&(_e=ve-Pe)>0?Se=Se.charAt(0)+"."+Se.slice(1)+ne(_e):Pe>1&&(Se=Se.charAt(0)+"."+Se.slice(1)),Se=Se+(ie.e<0?"e":"e+")+ie.e):Ee<0?(Se="0."+ne(-Ee-1)+Se,ve&&(_e=ve-Pe)>0&&(Se+=ne(_e))):Ee>=Pe?(Se+=ne(Ee+1-Pe),ve&&(_e=ve-Ee-1)>0&&(Se=Se+"."+ne(_e))):((_e=Ee+1)<Pe&&(Se=Se.slice(0,_e)+"."+Se.slice(_e)),ve&&(_e=ve-Pe)>0&&(Ee+1===Pe&&(Se+="."),Se+=ne(_e))),Se}function H(ie,de){var ve=ie[0];for(de*=D;ve>=10;ve/=10)de++;return de}function J(ie,de,ve){if(de>C)throw w=!0,ve&&(ie.precision=ve),Error(I);return m(new ie(n),de,1,!0)}function X(ie,de,ve){if(de>d)throw Error(I);return m(new ie(a),de,ve,!0)}function se(ie){var de=ie.length-1,ve=de*D+1;if(de=ie[de],de){for(;de%10==0;de/=10)ve--;for(de=ie[0];de>=10;de/=10)ve++}return ve}function ne(ie){for(var de="";ie--;)de+="0";return de}function Z(ie,de,ve,_e){var Ee,Se=new ie(1),Pe=Math.ceil(_e/D+4);for(w=!1;;){if(ve%2&&(Se=Se.times(de),Ue(Se.d,Pe)&&(Ee=!0)),ve=M(ve/2),ve===0){ve=Se.d.length-1,Ee&&Se.d[ve]===0&&++Se.d[ve];break}de=de.times(de),Ue(de.d,Pe)}return w=!0,Se}function oe(ie){return ie.d[ie.d.length-1]&1}function ye(ie,de,ve){for(var _e,Ee=new ie(de[0]),Se=0;++Se<de.length;)if(_e=new ie(de[Se]),_e.s)Ee[ve](_e)&&(Ee=_e);else{Ee=_e;break}return Ee}function Y(ie,de){var ve,_e,Ee,Se,Pe,Le,Ke,Fe=0,ze=0,et=0,nt=ie.constructor,ct=nt.rounding,yt=nt.precision;if(!ie.d||!ie.d[0]||ie.e>17)return new nt(ie.d?ie.d[0]?ie.s<0?0:1/0:1:ie.s?ie.s<0?0:ie:NaN);for(de==null?(w=!1,Ke=yt):Ke=de,Le=new nt(.03125);ie.e>-2;)ie=ie.times(Le),et+=5;for(_e=Math.log(q(2,et))/Math.LN10*2+5|0,Ke+=_e,ve=Se=Pe=new nt(1),nt.precision=Ke;;){if(Se=m(Se.times(ie),Ke,1),ve=ve.times(++ze),Le=Pe.plus(A(Se,ve,Ke,1)),$(Le.d).slice(0,Ke)===$(Pe.d).slice(0,Ke)){for(Ee=et;Ee--;)Pe=m(Pe.times(Pe),Ke,1);if(de==null)if(Fe<3&&O(Pe.d,Ke-_e,ct,Fe))nt.precision=Ke+=10,ve=Se=Le=new nt(1),ze=0,Fe++;else return m(Pe,nt.precision=yt,ct,w=!0);else return nt.precision=yt,Pe}Pe=Le}}function G(ie,de){var ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze,et,nt,ct=1,yt=10,dt=ie,vt=dt.d,gt=dt.constructor,bt=gt.rounding,wt=gt.precision;if(dt.s<0||!vt||!vt[0]||!dt.e&&vt[0]==1&&vt.length==1)return new gt(vt&&!vt[0]?-1/0:dt.s!=1?NaN:vt?0:dt);if(de==null?(w=!1,ze=wt):ze=de,gt.precision=ze+=yt,ve=$(vt),_e=ve.charAt(0),Math.abs(Se=dt.e)<15e14){for(;_e<7&&_e!=1||_e==1&&ve.charAt(1)>3;)dt=dt.times(ie),ve=$(dt.d),_e=ve.charAt(0),ct++;Se=dt.e,_e>1?(dt=new gt("0."+ve),Se++):dt=new gt(_e+"."+ve.slice(1))}else return Fe=J(gt,ze+2,wt).times(Se+""),dt=G(new gt(_e+"."+ve.slice(1)),ze-yt).plus(Fe),gt.precision=wt,de==null?m(dt,wt,bt,w=!0):dt;for(et=dt,Ke=Pe=dt=A(dt.minus(1),dt.plus(1),ze,1),nt=m(dt.times(dt),ze,1),Ee=3;;){if(Pe=m(Pe.times(nt),ze,1),Fe=Ke.plus(A(Pe,new gt(Ee),ze,1)),$(Fe.d).slice(0,ze)===$(Ke.d).slice(0,ze))if(Ke=Ke.times(2),Se!==0&&(Ke=Ke.plus(J(gt,ze+2,wt).times(Se+""))),Ke=A(Ke,new gt(ct),ze,1),de==null)if(O(Ke.d,ze-yt,bt,Le))gt.precision=ze+=yt,Fe=Pe=dt=A(et.minus(1),et.plus(1),ze,1),nt=m(dt.times(dt),ze,1),Ee=Le=1;else return m(Ke,gt.precision=wt,bt,w=!0);else return gt.precision=wt,Ke;Ke=Fe,Ee+=2}}function V(ie){return String(ie.s*ie.s/0)}function te(ie,de){var ve,_e,Ee;for((ve=de.indexOf("."))>-1&&(de=de.replace(".","")),(_e=de.search(/e/i))>0?(ve<0&&(ve=_e),ve+=+de.slice(_e+1),de=de.substring(0,_e)):ve<0&&(ve=de.length),_e=0;de.charCodeAt(_e)===48;_e++);for(Ee=de.length;de.charCodeAt(Ee-1)===48;--Ee);if(de=de.slice(_e,Ee),de){if(Ee-=_e,ie.e=ve=ve-_e-1,ie.d=[],_e=(ve+1)%D,ve<0&&(_e+=D),_e<Ee){for(_e&&ie.d.push(+de.slice(0,_e)),Ee-=D;_e<Ee;)ie.d.push(+de.slice(_e,_e+=D));de=de.slice(_e),_e=D-de.length}else _e-=Ee;for(;_e--;)de+="0";ie.d.push(+de),w&&(ie.e>ie.constructor.maxE?(ie.d=null,ie.e=NaN):ie.e<ie.constructor.minE&&(ie.e=0,ie.d=[0]))}else ie.e=0,ie.d=[0];return ie}function le(ie,de){var ve,_e,Ee,Se,Pe,Le,Ke,Fe,ze;if(de.indexOf("_")>-1){if(de=de.replace(/(\d)_(?=\d)/g,"$1"),y.test(de))return te(ie,de)}else if(de==="Infinity"||de==="NaN")return+de||(ie.s=NaN),ie.e=NaN,ie.d=null,ie;if(F.test(de))ve=16,de=de.toLowerCase();else if(U.test(de))ve=2;else if(j.test(de))ve=8;else throw Error(E+de);for(Se=de.search(/p/i),Se>0?(Ke=+de.slice(Se+1),de=de.substring(2,Se)):de=de.slice(2),Se=de.indexOf("."),Pe=Se>=0,_e=ie.constructor,Pe&&(de=de.replace(".",""),Le=de.length,Se=Le-Se,Ee=Z(_e,new _e(ve),Se,Se*2)),Fe=N(de,ve,T),ze=Fe.length-1,Se=ze;Fe[Se]===0;--Se)Fe.pop();return Se<0?new _e(ie.s*0):(ie.e=H(Fe,ze),ie.d=Fe,w=!1,Pe&&(ie=A(ie,Ee,Le*4)),Ke&&(ie=ie.times(Math.abs(Ke)<54?q(2,Ke):p.pow(2,Ke))),w=!0,ie)}function me(ie,de){var ve,_e=de.d.length;if(_e<3)return de.isZero()?de:Re(ie,2,de,de);ve=1.4*Math.sqrt(_e),ve=ve>16?16:ve|0,de=de.times(1/Be(5,ve)),de=Re(ie,2,de,de);for(var Ee,Se=new ie(5),Pe=new ie(16),Le=new ie(20);ve--;)Ee=de.times(de),de=de.times(Se.plus(Ee.times(Pe.times(Ee).minus(Le))));return de}function Re(ie,de,ve,_e,Ee){var Se,Pe,Le,Ke,Fe=ie.precision,ze=Math.ceil(Fe/D);for(w=!1,Ke=ve.times(ve),Le=new ie(_e);;){if(Pe=A(Le.times(Ke),new ie(de++*de++),Fe,1),Le=Ee?_e.plus(Pe):_e.minus(Pe),_e=A(Pe.times(Ke),new ie(de++*de++),Fe,1),Pe=Le.plus(_e),Pe.d[ze]!==void 0){for(Se=ze;Pe.d[Se]===Le.d[Se]&&Se--;);if(Se==-1)break}Se=Le,Le=_e,_e=Pe,Pe=Se}return w=!0,Pe.d.length=ze+1,Pe}function Be(ie,de){for(var ve=ie;--de;)ve*=ie;return ve}function Ce(ie,de){var ve,_e=de.s<0,Ee=X(ie,ie.precision,1),Se=Ee.times(.5);if(de=de.abs(),de.lte(Se))return v=_e?4:1,de;if(ve=de.divToInt(Ee),ve.isZero())v=_e?3:2;else{if(de=de.minus(ve.times(Ee)),de.lte(Se))return v=oe(ve)?_e?2:3:_e?4:1,de;v=oe(ve)?_e?1:4:_e?3:2}return de.minus(Ee).abs()}function $e(ie,de,ve,_e){var Ee,Se,Pe,Le,Ke,Fe,ze,et,nt,ct=ie.constructor,yt=ve!==void 0;if(yt?(S(ve,1,s),_e===void 0?_e=ct.rounding:S(_e,0,8)):(ve=ct.precision,_e=ct.rounding),!ie.isFinite())ze=V(ie);else{for(ze=P(ie),Pe=ze.indexOf("."),yt?(Ee=2,de==16?ve=ve*4-3:de==8&&(ve=ve*3-2)):Ee=de,Pe>=0&&(ze=ze.replace(".",""),nt=new ct(1),nt.e=ze.length-Pe,nt.d=N(P(nt),10,Ee),nt.e=nt.d.length),et=N(ze,10,Ee),Se=Ke=et.length;et[--Ke]==0;)et.pop();if(!et[0])ze=yt?"0p+0":"0";else{if(Pe<0?Se--:(ie=new ct(ie),ie.d=et,ie.e=Se,ie=A(ie,nt,ve,_e,0,Ee),et=ie.d,Se=ie.e,Fe=u),Pe=et[ve],Le=Ee/2,Fe=Fe||et[ve+1]!==void 0,Fe=_e<4?(Pe!==void 0||Fe)&&(_e===0||_e===(ie.s<0?3:2)):Pe>Le||Pe===Le&&(_e===4||Fe||_e===6&&et[ve-1]&1||_e===(ie.s<0?8:7)),et.length=ve,Fe)for(;++et[--ve]>Ee-1;)et[ve]=0,ve||(++Se,et.unshift(1));for(Ke=et.length;!et[Ke-1];--Ke);for(Pe=0,ze="";Pe<Ke;Pe++)ze+=o.charAt(et[Pe]);if(yt){if(Ke>1)if(de==16||de==8){for(Pe=de==16?4:3,--Ke;Ke%Pe;Ke++)ze+="0";for(et=N(ze,Ee,de),Ke=et.length;!et[Ke-1];--Ke);for(Pe=1,ze="1.";Pe<Ke;Pe++)ze+=o.charAt(et[Pe])}else ze=ze.charAt(0)+"."+ze.slice(1);ze=ze+(Se<0?"p":"p+")+Se}else if(Se<0){for(;++Se;)ze="0"+ze;ze="0."+ze}else if(++Se>Ke)for(Se-=Ke;Se--;)ze+="0";else Se<Ke&&(ze=ze.slice(0,Se)+"."+ze.slice(Se))}ze=(de==16?"0x":de==2?"0b":de==8?"0o":"")+ze}return ie.s<0?"-"+ze:ze}function Ue(ie,de){if(ie.length>de)return ie.length=de,!0}function Me(ie){return new this(ie).abs()}function ke(ie){return new this(ie).acos()}function tt(ie){return new this(ie).acosh()}function Ie(ie,de){return new this(ie).plus(de)}function xe(ie){return new this(ie).asin()}function he(ie){return new this(ie).asinh()}function ae(ie){return new this(ie).atan()}function be(ie){return new this(ie).atanh()}function Ae(ie,de){ie=new this(ie),de=new this(de);var ve,_e=this.precision,Ee=this.rounding,Se=_e+4;return!ie.s||!de.s?ve=new this(NaN):!ie.d&&!de.d?(ve=X(this,Se,1).times(de.s>0?.25:.75),ve.s=ie.s):!de.d||ie.isZero()?(ve=de.s<0?X(this,_e,Ee):new this(0),ve.s=ie.s):!ie.d||de.isZero()?(ve=X(this,Se,1).times(.5),ve.s=ie.s):de.s<0?(this.precision=Se,this.rounding=1,ve=this.atan(A(ie,de,Se,1)),de=X(this,Se,1),this.precision=_e,this.rounding=Ee,ve=ie.s<0?ve.minus(de):ve.plus(de)):ve=this.atan(A(ie,de,Se,1)),ve}function re(ie){return new this(ie).cbrt()}function z(ie){return m(ie=new this(ie),ie.e+1,2)}function Q(ie,de,ve){return new this(ie).clamp(de,ve)}function ue(ie){if(!ie||typeof ie!="object")throw Error(b+"Object expected");var de,ve,_e,Ee=ie.defaults===!0,Se=["precision",1,s,"rounding",0,8,"toExpNeg",-r,0,"toExpPos",0,r,"maxE",0,r,"minE",-r,0,"modulo",0,9];for(de=0;de<Se.length;de+=3)if(ve=Se[de],Ee&&(this[ve]=l[ve]),(_e=ie[ve])!==void 0)if(M(_e)===_e&&_e>=Se[de+1]&&_e<=Se[de+2])this[ve]=_e;else throw Error(E+ve+": "+_e);if(ve="crypto",Ee&&(this[ve]=l[ve]),(_e=ie[ve])!==void 0)if(_e===!0||_e===!1||_e===0||_e===1)if(_e)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[ve]=!0;else throw Error(x);else this[ve]=!1;else throw Error(E+ve+": "+_e);return this}function we(ie){return new this(ie).cos()}function Ne(ie){return new this(ie).cosh()}function De(ie){var de,ve,_e;function Ee(Se){var Pe,Le,Ke,Fe=this;if(!(Fe instanceof Ee))return new Ee(Se);if(Fe.constructor=Ee,ht(Se)){Fe.s=Se.s,w?!Se.d||Se.e>Ee.maxE?(Fe.e=NaN,Fe.d=null):Se.e<Ee.minE?(Fe.e=0,Fe.d=[0]):(Fe.e=Se.e,Fe.d=Se.d.slice()):(Fe.e=Se.e,Fe.d=Se.d?Se.d.slice():Se.d);return}if(Ke=typeof Se,Ke==="number"){if(Se===0){Fe.s=1/Se<0?-1:1,Fe.e=0,Fe.d=[0];return}if(Se<0?(Se=-Se,Fe.s=-1):Fe.s=1,Se===~~Se&&Se<1e7){for(Pe=0,Le=Se;Le>=10;Le/=10)Pe++;w?Pe>Ee.maxE?(Fe.e=NaN,Fe.d=null):Pe<Ee.minE?(Fe.e=0,Fe.d=[0]):(Fe.e=Pe,Fe.d=[Se]):(Fe.e=Pe,Fe.d=[Se]);return}else if(Se*0!==0){Se||(Fe.s=NaN),Fe.e=NaN,Fe.d=null;return}return te(Fe,Se.toString())}else if(Ke!=="string")throw Error(E+Se);return(Le=Se.charCodeAt(0))===45?(Se=Se.slice(1),Fe.s=-1):(Le===43&&(Se=Se.slice(1)),Fe.s=1),y.test(Se)?te(Fe,Se):le(Fe,Se)}if(Ee.prototype=_,Ee.ROUND_UP=0,Ee.ROUND_DOWN=1,Ee.ROUND_CEIL=2,Ee.ROUND_FLOOR=3,Ee.ROUND_HALF_UP=4,Ee.ROUND_HALF_DOWN=5,Ee.ROUND_HALF_EVEN=6,Ee.ROUND_HALF_CEIL=7,Ee.ROUND_HALF_FLOOR=8,Ee.EUCLID=9,Ee.config=Ee.set=ue,Ee.clone=De,Ee.isDecimal=ht,Ee.abs=Me,Ee.acos=ke,Ee.acosh=tt,Ee.add=Ie,Ee.asin=xe,Ee.asinh=he,Ee.atan=ae,Ee.atanh=be,Ee.atan2=Ae,Ee.cbrt=re,Ee.ceil=z,Ee.clamp=Q,Ee.cos=we,Ee.cosh=Ne,Ee.div=je,Ee.exp=ot,Ee.floor=He,Ee.hypot=We,Ee.ln=Je,Ee.log=rt,Ee.log10=Ze,Ee.log2=mt,Ee.max=it,Ee.min=_t,Ee.mod=pe,Ee.mul=ee,Ee.pow=ce,Ee.random=Te,Ee.round=Oe,Ee.sign=Ve,Ee.sin=qe,Ee.sinh=Ye,Ee.sqrt=pt,Ee.sub=Ge,Ee.sum=Xe,Ee.tan=lt,Ee.tanh=Qe,Ee.trunc=st,ie===void 0&&(ie={}),ie&&ie.defaults!==!0)for(_e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],de=0;de<_e.length;)ie.hasOwnProperty(ve=_e[de++])||(ie[ve]=this[ve]);return Ee.config(ie),Ee}function je(ie,de){return new this(ie).div(de)}function ot(ie){return new this(ie).exp()}function He(ie){return m(ie=new this(ie),ie.e+1,3)}function We(){var ie,de,ve=new this(0);for(w=!1,ie=0;ie<arguments.length;)if(de=new this(arguments[ie++]),de.d)ve.d&&(ve=ve.plus(de.times(de)));else{if(de.s)return w=!0,new this(1/0);ve=de}return w=!0,ve.sqrt()}function ht(ie){return ie instanceof p||ie&&ie.toStringTag===B||!1}function Je(ie){return new this(ie).ln()}function rt(ie,de){return new this(ie).log(de)}function mt(ie){return new this(ie).log(2)}function Ze(ie){return new this(ie).log(10)}function it(){return ye(this,arguments,"lt")}function _t(){return ye(this,arguments,"gt")}function pe(ie,de){return new this(ie).mod(de)}function ee(ie,de){return new this(ie).mul(de)}function ce(ie,de){return new this(ie).pow(de)}function Te(ie){var de,ve,_e,Ee,Se=0,Pe=new this(1),Le=[];if(ie===void 0?ie=this.precision:S(ie,1,s),_e=Math.ceil(ie/D),this.crypto)if(crypto.getRandomValues)for(de=crypto.getRandomValues(new Uint32Array(_e));Se<_e;)Ee=de[Se],Ee>=429e7?de[Se]=crypto.getRandomValues(new Uint32Array(1))[0]:Le[Se++]=Ee%1e7;else if(crypto.randomBytes){for(de=crypto.randomBytes(_e*=4);Se<_e;)Ee=de[Se]+(de[Se+1]<<8)+(de[Se+2]<<16)+((de[Se+3]&127)<<24),Ee>=214e7?crypto.randomBytes(4).copy(de,Se):(Le.push(Ee%1e7),Se+=4);Se=_e/4}else throw Error(x);else for(;Se<_e;)Le[Se++]=Math.random()*1e7|0;for(_e=Le[--Se],ie%=D,_e&&ie&&(Ee=q(10,D-ie),Le[Se]=(_e/Ee|0)*Ee);Le[Se]===0;Se--)Le.pop();if(Se<0)ve=0,Le=[0];else{for(ve=-1;Le[0]===0;ve-=D)Le.shift();for(_e=1,Ee=Le[0];Ee>=10;Ee/=10)_e++;_e<D&&(ve-=D-_e)}return Pe.e=ve,Pe.d=Le,Pe}function Oe(ie){return m(ie=new this(ie),ie.e+1,this.rounding)}function Ve(ie){return ie=new this(ie),ie.d?ie.d[0]?ie.s:0*ie.s:ie.s||NaN}function qe(ie){return new this(ie).sin()}function Ye(ie){return new this(ie).sinh()}function pt(ie){return new this(ie).sqrt()}function Ge(ie,de){return new this(ie).sub(de)}function Xe(){var ie=0,de=arguments,ve=new this(de[ie]);for(w=!1;ve.s&&++ie<de.length;)ve=ve.plus(de[ie]);return w=!0,m(ve,this.precision,this.rounding)}function lt(ie){return new this(ie).tan()}function Qe(ie){return new this(ie).tanh()}function st(ie){return m(ie=new this(ie),ie.e+1,1)}p=De(l),p.prototype.constructor=p,p.default=p.Decimal=p,n=new p(n),a=new p(a),e.exports?(typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"&&(_[Symbol.for("nodejs.util.inspect.custom")]=_.toString,_[Symbol.toStringTag]="Decimal"),e.exports=p):(t||(t=typeof self<"u"&&self&&self.self==self?self:window),c=t.Decimal,p.noConflict=function(){return t.Decimal=c,p},t.Decimal=p)})(commonjsGlobal)})(decimal);var decimalExports=decimal.exports,binaryParser={},__createBinding$1=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),__setModuleDefault$1=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar$1=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding$1(t,e,r);return __setModuleDefault$1(t,e),t};Object.defineProperty(binaryParser,"__esModule",{value:!0});binaryParser.BinaryParser=void 0;const assert$2=__importStar$1(requireAssert()),enums_1=enums,buffer_1$h=dist$t;class BinaryParser{constructor(t,r=enums_1.DEFAULT_DEFINITIONS){this.bytes=buffer_1$h.Buffer.from(t,"hex"),this.definitions=r}peek(){return assert$2.ok(this.bytes.byteLength!==0),this.bytes[0]}skip(t){assert$2.ok(t<=this.bytes.byteLength),this.bytes=this.bytes.slice(t)}read(t){assert$2.ok(t<=this.bytes.byteLength);const r=this.bytes.slice(0,t);return this.skip(t),r}readUIntN(t){return assert$2.ok(0<t&&t<=4,"invalid n"),this.read(t).reduce((r,s)=>r<<8|s)>>>0}readUInt8(){return this.readUIntN(1)}readUInt16(){return this.readUIntN(2)}readUInt32(){return this.readUIntN(4)}size(){return this.bytes.byteLength}end(t){const r=this.bytes.byteLength;return r===0||t!==void 0&&r<=t}readVariableLength(){return this.read(this.readVariableLengthLength())}readVariableLengthLength(){const t=this.readUInt8();if(t<=192)return t;if(t<=240){const r=this.readUInt8();return 193+(t-193)*256+r}else if(t<=254){const r=this.readUInt8(),s=this.readUInt8();return 12481+(t-241)*65536+r*256+s}throw new Error("Invalid variable length indicator")}readFieldOrdinal(){let t=this.readUInt8(),r=t&15;if(t>>=4,t===0&&(t=this.readUInt8(),t===0||t<16))throw new Error("Cannot read FieldOrdinal, type_code out of range");if(r===0&&(r=this.readUInt8(),r===0||r<16))throw new Error("Cannot read FieldOrdinal, field_code out of range");return t<<16|r}readField(){return this.definitions.field.fromString(this.readFieldOrdinal().toString())}readType(t){return t.fromParser(this)}typeForField(t){return t.associatedType}readFieldValue(t){const r=this.typeForField(t);if(!r)throw new Error(`unsupported: (${t.name}, ${t.type.name})`);const s=t.isVariableLengthEncoded?this.readVariableLengthLength():void 0,o=r.fromParser(this,s);if(o===void 0)throw new Error(`fromParser for (${t.name}, ${t.type.name}) -> undefined `);return o}readFieldAndValue(){const t=this.readField();return[t,this.readFieldValue(t)]}}binaryParser.BinaryParser=BinaryParser;var currency={};Object.defineProperty(currency,"__esModule",{value:!0});currency.Currency=void 0;const hash_160_1=hash160$1,buffer_1$g=dist$t,XRP_HEX_REGEX=/^0{40}$/,ISO_REGEX=/^[A-Z0-9a-z?!@#$%^&*(){}[\]|]{3}$/,HEX_REGEX$1=/^[A-F0-9]{40}$/,STANDARD_FORMAT_HEX_REGEX=/^0{24}[\x00-\x7F]{6}0{10}$/;function isoToBytes(e){const t=buffer_1$g.Buffer.alloc(20);if(e!=="XRP"){const r=e.split("").map(s=>s.charCodeAt(0));t.set(r,12)}return t}function isIsoCode(e){return ISO_REGEX.test(e)}function isoCodeFromHex(e){const t=e.toString();return t==="XRP"?null:isIsoCode(t)?t:null}function isHex(e){return HEX_REGEX$1.test(e)}function isStringRepresentation(e){return e.length===3||isHex(e)}function isBytesArray(e){return e.byteLength===20}function isValidRepresentation(e){return e instanceof buffer_1$g.Buffer?isBytesArray(e):isStringRepresentation(e)}function bytesFromRepresentation(e){if(!isValidRepresentation(e))throw new Error(`Unsupported Currency representation: ${e}`);return e.length===3?isoToBytes(e):buffer_1$g.Buffer.from(e,"hex")}class Currency extends hash_160_1.Hash160{constructor(t){super(t??Currency.XRP.bytes);const r=this.bytes.toString("hex");XRP_HEX_REGEX.test(r)?this._iso="XRP":STANDARD_FORMAT_HEX_REGEX.test(r)?this._iso=isoCodeFromHex(this.bytes.slice(12,15)):this._iso=null}iso(){return this._iso}static from(t){if(t instanceof Currency)return t;if(typeof t=="string")return new Currency(bytesFromRepresentation(t));throw new Error("Cannot construct Currency from value given")}toJSON(){const t=this.iso();return t!==null?t:this.bytes.toString("hex").toUpperCase()}}currency.Currency=Currency;Currency.XRP=new Currency(buffer_1$g.Buffer.alloc(20));var BigInteger={exports:{}};(function(e){var t=function(r){var s=1e7,o=7,n=9007199254740992,a=E(n),l="0123456789abcdefghijklmnopqrstuvwxyz",p=typeof BigInt=="function";function u(he,ae,be,Ae){return typeof he>"u"?u[0]:typeof ae<"u"?+ae==10&&!be?Ie(he):Be(he,ae,be,Ae):Ie(he)}function c(he,ae){this.value=he,this.sign=ae,this.isSmall=!1}c.prototype=Object.create(u.prototype);function v(he){this.value=he,this.sign=he<0,this.isSmall=!0}v.prototype=Object.create(u.prototype);function w(he){this.value=he}w.prototype=Object.create(u.prototype);function b(he){return-n<he&&he<n}function E(he){return he<1e7?[he]:he<1e14?[he%1e7,Math.floor(he/1e7)]:[he%1e7,Math.floor(he/1e7)%1e7,Math.floor(he/1e14)]}function I(he){x(he);var ae=he.length;if(ae<4&&m(he,a)<0)switch(ae){case 0:return 0;case 1:return he[0];case 2:return he[0]+he[1]*s;default:return he[0]+(he[1]+he[2]*s)*s}return he}function x(he){for(var ae=he.length;he[--ae]===0;);he.length=ae+1}function B(he){for(var ae=new Array(he),be=-1;++be<he;)ae[be]=0;return ae}function M(he){return he>0?Math.floor(he):Math.ceil(he)}function q(he,ae){var be=he.length,Ae=ae.length,re=new Array(be),z=0,Q=s,ue,we;for(we=0;we<Ae;we++)ue=he[we]+ae[we]+z,z=ue>=Q?1:0,re[we]=ue-z*Q;for(;we<be;)ue=he[we]+z,z=ue===Q?1:0,re[we++]=ue-z*Q;return z>0&&re.push(z),re}function U(he,ae){return he.length>=ae.length?q(he,ae):q(ae,he)}function F(he,ae){var be=he.length,Ae=new Array(be),re=s,z,Q;for(Q=0;Q<be;Q++)z=he[Q]-re+ae,ae=Math.floor(z/re),Ae[Q]=z-ae*re,ae+=1;for(;ae>0;)Ae[Q++]=ae%re,ae=Math.floor(ae/re);return Ae}c.prototype.add=function(he){var ae=Ie(he);if(this.sign!==ae.sign)return this.subtract(ae.negate());var be=this.value,Ae=ae.value;return ae.isSmall?new c(F(be,Math.abs(Ae)),this.sign):new c(U(be,Ae),this.sign)},c.prototype.plus=c.prototype.add,v.prototype.add=function(he){var ae=Ie(he),be=this.value;if(be<0!==ae.sign)return this.subtract(ae.negate());var Ae=ae.value;if(ae.isSmall){if(b(be+Ae))return new v(be+Ae);Ae=E(Math.abs(Ae))}return new c(F(Ae,Math.abs(be)),be<0)},v.prototype.plus=v.prototype.add,w.prototype.add=function(he){return new w(this.value+Ie(he).value)},w.prototype.plus=w.prototype.add;function j(he,ae){var be=he.length,Ae=ae.length,re=new Array(be),z=0,Q=s,ue,we;for(ue=0;ue<Ae;ue++)we=he[ue]-z-ae[ue],we<0?(we+=Q,z=1):z=0,re[ue]=we;for(ue=Ae;ue<be;ue++){if(we=he[ue]-z,we<0)we+=Q;else{re[ue++]=we;break}re[ue]=we}for(;ue<be;ue++)re[ue]=he[ue];return x(re),re}function y(he,ae,be){var Ae;return m(he,ae)>=0?Ae=j(he,ae):(Ae=j(ae,he),be=!be),Ae=I(Ae),typeof Ae=="number"?(be&&(Ae=-Ae),new v(Ae)):new c(Ae,be)}function T(he,ae,be){var Ae=he.length,re=new Array(Ae),z=-ae,Q=s,ue,we;for(ue=0;ue<Ae;ue++)we=he[ue]+z,z=Math.floor(we/Q),we%=Q,re[ue]=we<0?we+Q:we;return re=I(re),typeof re=="number"?(be&&(re=-re),new v(re)):new c(re,be)}c.prototype.subtract=function(he){var ae=Ie(he);if(this.sign!==ae.sign)return this.add(ae.negate());var be=this.value,Ae=ae.value;return ae.isSmall?T(be,Math.abs(Ae),this.sign):y(be,Ae,this.sign)},c.prototype.minus=c.prototype.subtract,v.prototype.subtract=function(he){var ae=Ie(he),be=this.value;if(be<0!==ae.sign)return this.add(ae.negate());var Ae=ae.value;return ae.isSmall?new v(be-Ae):T(Ae,Math.abs(be),be>=0)},v.prototype.minus=v.prototype.subtract,w.prototype.subtract=function(he){return new w(this.value-Ie(he).value)},w.prototype.minus=w.prototype.subtract,c.prototype.negate=function(){return new c(this.value,!this.sign)},v.prototype.negate=function(){var he=this.sign,ae=new v(-this.value);return ae.sign=!he,ae},w.prototype.negate=function(){return new w(-this.value)},c.prototype.abs=function(){return new c(this.value,!1)},v.prototype.abs=function(){return new v(Math.abs(this.value))},w.prototype.abs=function(){return new w(this.value>=0?this.value:-this.value)};function D(he,ae){var be=he.length,Ae=ae.length,re=be+Ae,z=B(re),Q=s,ue,we,Ne,De,je;for(Ne=0;Ne<be;++Ne){De=he[Ne];for(var ot=0;ot<Ae;++ot)je=ae[ot],ue=De*je+z[Ne+ot],we=Math.floor(ue/Q),z[Ne+ot]=ue-we*Q,z[Ne+ot+1]+=we}return x(z),z}function L(he,ae){var be=he.length,Ae=new Array(be),re=s,z=0,Q,ue;for(ue=0;ue<be;ue++)Q=he[ue]*ae+z,z=Math.floor(Q/re),Ae[ue]=Q-z*re;for(;z>0;)Ae[ue++]=z%re,z=Math.floor(z/re);return Ae}function C(he,ae){for(var be=[];ae-- >0;)be.push(0);return be.concat(he)}function d(he,ae){var be=Math.max(he.length,ae.length);if(be<=30)return D(he,ae);be=Math.ceil(be/2);var Ae=he.slice(be),re=he.slice(0,be),z=ae.slice(be),Q=ae.slice(0,be),ue=d(re,Q),we=d(Ae,z),Ne=d(U(re,Ae),U(Q,z)),De=U(U(ue,C(j(j(Ne,ue),we),be)),C(we,2*be));return x(De),De}function _(he,ae){return-.012*he-.012*ae+15e-6*he*ae>0}c.prototype.multiply=function(he){var ae=Ie(he),be=this.value,Ae=ae.value,re=this.sign!==ae.sign,z;if(ae.isSmall){if(Ae===0)return u[0];if(Ae===1)return this;if(Ae===-1)return this.negate();if(z=Math.abs(Ae),z<s)return new c(L(be,z),re);Ae=E(z)}return _(be.length,Ae.length)?new c(d(be,Ae),re):new c(D(be,Ae),re)},c.prototype.times=c.prototype.multiply;function $(he,ae,be){return he<s?new c(L(ae,he),be):new c(D(ae,E(he)),be)}v.prototype._multiplyBySmall=function(he){return b(he.value*this.value)?new v(he.value*this.value):$(Math.abs(he.value),E(Math.abs(this.value)),this.sign!==he.sign)},c.prototype._multiplyBySmall=function(he){return he.value===0?u[0]:he.value===1?this:he.value===-1?this.negate():$(Math.abs(he.value),this.value,this.sign!==he.sign)},v.prototype.multiply=function(he){return Ie(he)._multiplyBySmall(this)},v.prototype.times=v.prototype.multiply,w.prototype.multiply=function(he){return new w(this.value*Ie(he).value)},w.prototype.times=w.prototype.multiply;function S(he){var ae=he.length,be=B(ae+ae),Ae=s,re,z,Q,ue,we;for(Q=0;Q<ae;Q++){ue=he[Q],z=0-ue*ue;for(var Ne=Q;Ne<ae;Ne++)we=he[Ne],re=2*(ue*we)+be[Q+Ne]+z,z=Math.floor(re/Ae),be[Q+Ne]=re-z*Ae;be[Q+ae]=z}return x(be),be}c.prototype.square=function(){return new c(S(this.value),!1)},v.prototype.square=function(){var he=this.value*this.value;return b(he)?new v(he):new c(S(E(Math.abs(this.value))),!1)},w.prototype.square=function(he){return new w(this.value*this.value)};function O(he,ae){var be=he.length,Ae=ae.length,re=s,z=B(ae.length),Q=ae[Ae-1],ue=Math.ceil(re/(2*Q)),we=L(he,ue),Ne=L(ae,ue),De,je,ot,He,We,ht,Je;for(we.length<=be&&we.push(0),Ne.push(0),Q=Ne[Ae-1],je=be-Ae;je>=0;je--){for(De=re-1,we[je+Ae]!==Q&&(De=Math.floor((we[je+Ae]*re+we[je+Ae-1])/Q)),ot=0,He=0,ht=Ne.length,We=0;We<ht;We++)ot+=De*Ne[We],Je=Math.floor(ot/re),He+=we[je+We]-(ot-Je*re),ot=Je,He<0?(we[je+We]=He+re,He=-1):(we[je+We]=He,He=0);for(;He!==0;){for(De-=1,ot=0,We=0;We<ht;We++)ot+=we[je+We]-re+Ne[We],ot<0?(we[je+We]=ot+re,ot=0):(we[je+We]=ot,ot=1);He+=ot}z[je]=De}return we=k(we,ue)[0],[I(z),I(we)]}function N(he,ae){for(var be=he.length,Ae=ae.length,re=[],z=[],Q=s,ue,we,Ne,De,je;be;){if(z.unshift(he[--be]),x(z),m(z,ae)<0){re.push(0);continue}we=z.length,Ne=z[we-1]*Q+z[we-2],De=ae[Ae-1]*Q+ae[Ae-2],we>Ae&&(Ne=(Ne+1)*Q),ue=Math.ceil(Ne/De);do{if(je=L(ae,ue),m(je,z)<=0)break;ue--}while(ue);re.push(ue),z=j(z,je)}return re.reverse(),[I(re),I(z)]}function k(he,ae){var be=he.length,Ae=B(be),re=s,z,Q,ue,we;for(ue=0,z=be-1;z>=0;--z)we=ue*re+he[z],Q=M(we/ae),ue=we-Q*ae,Ae[z]=Q|0;return[Ae,ue|0]}function A(he,ae){var be,Ae=Ie(ae);if(p)return[new w(he.value/Ae.value),new w(he.value%Ae.value)];var re=he.value,z=Ae.value,Q;if(z===0)throw new Error("Cannot divide by zero");if(he.isSmall)return Ae.isSmall?[new v(M(re/z)),new v(re%z)]:[u[0],he];if(Ae.isSmall){if(z===1)return[he,u[0]];if(z==-1)return[he.negate(),u[0]];var ue=Math.abs(z);if(ue<s){be=k(re,ue),Q=I(be[0]);var we=be[1];return he.sign&&(we=-we),typeof Q=="number"?(he.sign!==Ae.sign&&(Q=-Q),[new v(Q),new v(we)]):[new c(Q,he.sign!==Ae.sign),new v(we)]}z=E(ue)}var Ne=m(re,z);if(Ne===-1)return[u[0],he];if(Ne===0)return[u[he.sign===Ae.sign?1:-1],u[0]];re.length+z.length<=200?be=O(re,z):be=N(re,z),Q=be[0];var De=he.sign!==Ae.sign,je=be[1],ot=he.sign;return typeof Q=="number"?(De&&(Q=-Q),Q=new v(Q)):Q=new c(Q,De),typeof je=="number"?(ot&&(je=-je),je=new v(je)):je=new c(je,ot),[Q,je]}c.prototype.divmod=function(he){var ae=A(this,he);return{quotient:ae[0],remainder:ae[1]}},w.prototype.divmod=v.prototype.divmod=c.prototype.divmod,c.prototype.divide=function(he){return A(this,he)[0]},w.prototype.over=w.prototype.divide=function(he){return new w(this.value/Ie(he).value)},v.prototype.over=v.prototype.divide=c.prototype.over=c.prototype.divide,c.prototype.mod=function(he){return A(this,he)[1]},w.prototype.mod=w.prototype.remainder=function(he){return new w(this.value%Ie(he).value)},v.prototype.remainder=v.prototype.mod=c.prototype.remainder=c.prototype.mod,c.prototype.pow=function(he){var ae=Ie(he),be=this.value,Ae=ae.value,re,z,Q;if(Ae===0)return u[1];if(be===0)return u[0];if(be===1)return u[1];if(be===-1)return ae.isEven()?u[1]:u[-1];if(ae.sign)return u[0];if(!ae.isSmall)throw new Error("The exponent "+ae.toString()+" is too large.");if(this.isSmall&&b(re=Math.pow(be,Ae)))return new v(M(re));for(z=this,Q=u[1];Ae&!0&&(Q=Q.times(z),--Ae),Ae!==0;)Ae/=2,z=z.square();return Q},v.prototype.pow=c.prototype.pow,w.prototype.pow=function(he){var ae=Ie(he),be=this.value,Ae=ae.value,re=BigInt(0),z=BigInt(1),Q=BigInt(2);if(Ae===re)return u[1];if(be===re)return u[0];if(be===z)return u[1];if(be===BigInt(-1))return ae.isEven()?u[1]:u[-1];if(ae.isNegative())return new w(re);for(var ue=this,we=u[1];(Ae&z)===z&&(we=we.times(ue),--Ae),Ae!==re;)Ae/=Q,ue=ue.square();return we},c.prototype.modPow=function(he,ae){if(he=Ie(he),ae=Ie(ae),ae.isZero())throw new Error("Cannot take modPow with modulus 0");var be=u[1],Ae=this.mod(ae);for(he.isNegative()&&(he=he.multiply(u[-1]),Ae=Ae.modInv(ae));he.isPositive();){if(Ae.isZero())return u[0];he.isOdd()&&(be=be.multiply(Ae).mod(ae)),he=he.divide(2),Ae=Ae.square().mod(ae)}return be},w.prototype.modPow=v.prototype.modPow=c.prototype.modPow;function m(he,ae){if(he.length!==ae.length)return he.length>ae.length?1:-1;for(var be=he.length-1;be>=0;be--)if(he[be]!==ae[be])return he[be]>ae[be]?1:-1;return 0}c.prototype.compareAbs=function(he){var ae=Ie(he),be=this.value,Ae=ae.value;return ae.isSmall?1:m(be,Ae)},v.prototype.compareAbs=function(he){var ae=Ie(he),be=Math.abs(this.value),Ae=ae.value;return ae.isSmall?(Ae=Math.abs(Ae),be===Ae?0:be>Ae?1:-1):-1},w.prototype.compareAbs=function(he){var ae=this.value,be=Ie(he).value;return ae=ae>=0?ae:-ae,be=be>=0?be:-be,ae===be?0:ae>be?1:-1},c.prototype.compare=function(he){if(he===1/0)return-1;if(he===-1/0)return 1;var ae=Ie(he),be=this.value,Ae=ae.value;return this.sign!==ae.sign?ae.sign?1:-1:ae.isSmall?this.sign?-1:1:m(be,Ae)*(this.sign?-1:1)},c.prototype.compareTo=c.prototype.compare,v.prototype.compare=function(he){if(he===1/0)return-1;if(he===-1/0)return 1;var ae=Ie(he),be=this.value,Ae=ae.value;return ae.isSmall?be==Ae?0:be>Ae?1:-1:be<0!==ae.sign?be<0?-1:1:be<0?1:-1},v.prototype.compareTo=v.prototype.compare,w.prototype.compare=function(he){if(he===1/0)return-1;if(he===-1/0)return 1;var ae=this.value,be=Ie(he).value;return ae===be?0:ae>be?1:-1},w.prototype.compareTo=w.prototype.compare,c.prototype.equals=function(he){return this.compare(he)===0},w.prototype.eq=w.prototype.equals=v.prototype.eq=v.prototype.equals=c.prototype.eq=c.prototype.equals,c.prototype.notEquals=function(he){return this.compare(he)!==0},w.prototype.neq=w.prototype.notEquals=v.prototype.neq=v.prototype.notEquals=c.prototype.neq=c.prototype.notEquals,c.prototype.greater=function(he){return this.compare(he)>0},w.prototype.gt=w.prototype.greater=v.prototype.gt=v.prototype.greater=c.prototype.gt=c.prototype.greater,c.prototype.lesser=function(he){return this.compare(he)<0},w.prototype.lt=w.prototype.lesser=v.prototype.lt=v.prototype.lesser=c.prototype.lt=c.prototype.lesser,c.prototype.greaterOrEquals=function(he){return this.compare(he)>=0},w.prototype.geq=w.prototype.greaterOrEquals=v.prototype.geq=v.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals,c.prototype.lesserOrEquals=function(he){return this.compare(he)<=0},w.prototype.leq=w.prototype.lesserOrEquals=v.prototype.leq=v.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals,c.prototype.isEven=function(){return(this.value[0]&1)===0},v.prototype.isEven=function(){return(this.value&1)===0},w.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},c.prototype.isOdd=function(){return(this.value[0]&1)===1},v.prototype.isOdd=function(){return(this.value&1)===1},w.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},c.prototype.isPositive=function(){return!this.sign},v.prototype.isPositive=function(){return this.value>0},w.prototype.isPositive=v.prototype.isPositive,c.prototype.isNegative=function(){return this.sign},v.prototype.isNegative=function(){return this.value<0},w.prototype.isNegative=v.prototype.isNegative,c.prototype.isUnit=function(){return!1},v.prototype.isUnit=function(){return Math.abs(this.value)===1},w.prototype.isUnit=function(){return this.abs().value===BigInt(1)},c.prototype.isZero=function(){return!1},v.prototype.isZero=function(){return this.value===0},w.prototype.isZero=function(){return this.value===BigInt(0)},c.prototype.isDivisibleBy=function(he){var ae=Ie(he);return ae.isZero()?!1:ae.isUnit()?!0:ae.compareAbs(2)===0?this.isEven():this.mod(ae).isZero()},w.prototype.isDivisibleBy=v.prototype.isDivisibleBy=c.prototype.isDivisibleBy;function P(he){var ae=he.abs();if(ae.isUnit())return!1;if(ae.equals(2)||ae.equals(3)||ae.equals(5))return!0;if(ae.isEven()||ae.isDivisibleBy(3)||ae.isDivisibleBy(5))return!1;if(ae.lesser(49))return!0}function H(he,ae){for(var be=he.prev(),Ae=be,re=0,z,Q,ue;Ae.isEven();)Ae=Ae.divide(2),re++;e:for(Q=0;Q<ae.length;Q++)if(!he.lesser(ae[Q])&&(ue=t(ae[Q]).modPow(Ae,he),!(ue.isUnit()||ue.equals(be)))){for(z=re-1;z!=0;z--){if(ue=ue.square().mod(he),ue.isUnit())return!1;if(ue.equals(be))continue e}return!1}return!0}c.prototype.isPrime=function(he){var ae=P(this);if(ae!==r)return ae;var be=this.abs(),Ae=be.bitLength();if(Ae<=64)return H(be,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var re=Math.log(2)*Ae.toJSNumber(),z=Math.ceil(he===!0?2*Math.pow(re,2):re),Q=[],ue=0;ue<z;ue++)Q.push(t(ue+2));return H(be,Q)},w.prototype.isPrime=v.prototype.isPrime=c.prototype.isPrime,c.prototype.isProbablePrime=function(he,ae){var be=P(this);if(be!==r)return be;for(var Ae=this.abs(),re=he===r?5:he,z=[],Q=0;Q<re;Q++)z.push(t.randBetween(2,Ae.minus(2),ae));return H(Ae,z)},w.prototype.isProbablePrime=v.prototype.isProbablePrime=c.prototype.isProbablePrime,c.prototype.modInv=function(he){for(var ae=t.zero,be=t.one,Ae=Ie(he),re=this.abs(),z,Q,ue;!re.isZero();)z=Ae.divide(re),Q=ae,ue=Ae,ae=be,Ae=re,be=Q.subtract(z.multiply(be)),re=ue.subtract(z.multiply(re));if(!Ae.isUnit())throw new Error(this.toString()+" and "+he.toString()+" are not co-prime");return ae.compare(0)===-1&&(ae=ae.add(he)),this.isNegative()?ae.negate():ae},w.prototype.modInv=v.prototype.modInv=c.prototype.modInv,c.prototype.next=function(){var he=this.value;return this.sign?T(he,1,this.sign):new c(F(he,1),this.sign)},v.prototype.next=function(){var he=this.value;return he+1<n?new v(he+1):new c(a,!1)},w.prototype.next=function(){return new w(this.value+BigInt(1))},c.prototype.prev=function(){var he=this.value;return this.sign?new c(F(he,1),!0):T(he,1,this.sign)},v.prototype.prev=function(){var he=this.value;return he-1>-n?new v(he-1):new c(a,!0)},w.prototype.prev=function(){return new w(this.value-BigInt(1))};for(var J=[1];2*J[J.length-1]<=s;)J.push(2*J[J.length-1]);var X=J.length,se=J[X-1];function ne(he){return Math.abs(he)<=s}c.prototype.shiftLeft=function(he){var ae=Ie(he).toJSNumber();if(!ne(ae))throw new Error(String(ae)+" is too large for shifting.");if(ae<0)return this.shiftRight(-ae);var be=this;if(be.isZero())return be;for(;ae>=X;)be=be.multiply(se),ae-=X-1;return be.multiply(J[ae])},w.prototype.shiftLeft=v.prototype.shiftLeft=c.prototype.shiftLeft,c.prototype.shiftRight=function(he){var ae,be=Ie(he).toJSNumber();if(!ne(be))throw new Error(String(be)+" is too large for shifting.");if(be<0)return this.shiftLeft(-be);for(var Ae=this;be>=X;){if(Ae.isZero()||Ae.isNegative()&&Ae.isUnit())return Ae;ae=A(Ae,se),Ae=ae[1].isNegative()?ae[0].prev():ae[0],be-=X-1}return ae=A(Ae,J[be]),ae[1].isNegative()?ae[0].prev():ae[0]},w.prototype.shiftRight=v.prototype.shiftRight=c.prototype.shiftRight;function Z(he,ae,be){ae=Ie(ae);for(var Ae=he.isNegative(),re=ae.isNegative(),z=Ae?he.not():he,Q=re?ae.not():ae,ue=0,we=0,Ne=null,De=null,je=[];!z.isZero()||!Q.isZero();)Ne=A(z,se),ue=Ne[1].toJSNumber(),Ae&&(ue=se-1-ue),De=A(Q,se),we=De[1].toJSNumber(),re&&(we=se-1-we),z=Ne[0],Q=De[0],je.push(be(ue,we));for(var ot=be(Ae?1:0,re?1:0)!==0?t(-1):t(0),He=je.length-1;He>=0;He-=1)ot=ot.multiply(se).add(t(je[He]));return ot}c.prototype.not=function(){return this.negate().prev()},w.prototype.not=v.prototype.not=c.prototype.not,c.prototype.and=function(he){return Z(this,he,function(ae,be){return ae&be})},w.prototype.and=v.prototype.and=c.prototype.and,c.prototype.or=function(he){return Z(this,he,function(ae,be){return ae|be})},w.prototype.or=v.prototype.or=c.prototype.or,c.prototype.xor=function(he){return Z(this,he,function(ae,be){return ae^be})},w.prototype.xor=v.prototype.xor=c.prototype.xor;var oe=1<<30,ye=(s&-s)*(s&-s)|oe;function Y(he){var ae=he.value,be=typeof ae=="number"?ae|oe:typeof ae=="bigint"?ae|BigInt(oe):ae[0]+ae[1]*s|ye;return be&-be}function G(he,ae){if(ae.compareTo(he)<=0){var be=G(he,ae.square(ae)),Ae=be.p,re=be.e,z=Ae.multiply(ae);return z.compareTo(he)<=0?{p:z,e:re*2+1}:{p:Ae,e:re*2}}return{p:t(1),e:0}}c.prototype.bitLength=function(){var he=this;return he.compareTo(t(0))<0&&(he=he.negate().subtract(t(1))),he.compareTo(t(0))===0?t(0):t(G(he,t(2)).e).add(t(1))},w.prototype.bitLength=v.prototype.bitLength=c.prototype.bitLength;function V(he,ae){return he=Ie(he),ae=Ie(ae),he.greater(ae)?he:ae}function te(he,ae){return he=Ie(he),ae=Ie(ae),he.lesser(ae)?he:ae}function le(he,ae){if(he=Ie(he).abs(),ae=Ie(ae).abs(),he.equals(ae))return he;if(he.isZero())return ae;if(ae.isZero())return he;for(var be=u[1],Ae,re;he.isEven()&&ae.isEven();)Ae=te(Y(he),Y(ae)),he=he.divide(Ae),ae=ae.divide(Ae),be=be.multiply(Ae);for(;he.isEven();)he=he.divide(Y(he));do{for(;ae.isEven();)ae=ae.divide(Y(ae));he.greater(ae)&&(re=ae,ae=he,he=re),ae=ae.subtract(he)}while(!ae.isZero());return be.isUnit()?he:he.multiply(be)}function me(he,ae){return he=Ie(he).abs(),ae=Ie(ae).abs(),he.divide(le(he,ae)).multiply(ae)}function Re(he,ae,be){he=Ie(he),ae=Ie(ae);var Ae=be||Math.random,re=te(he,ae),z=V(he,ae),Q=z.subtract(re).add(1);if(Q.isSmall)return re.add(Math.floor(Ae()*Q));for(var ue=Ue(Q,s).value,we=[],Ne=!0,De=0;De<ue.length;De++){var je=Ne?ue[De]+(De+1<ue.length?ue[De+1]/s:0):s,ot=M(Ae()*je);we.push(ot),ot<ue[De]&&(Ne=!1)}return re.add(u.fromArray(we,s,!1))}var Be=function(he,ae,be,Ae){be=be||l,he=String(he),Ae||(he=he.toLowerCase(),be=be.toLowerCase());var re=he.length,z,Q=Math.abs(ae),ue={};for(z=0;z<be.length;z++)ue[be[z]]=z;for(z=0;z<re;z++){var we=he[z];if(we!=="-"&&we in ue&&ue[we]>=Q){if(we==="1"&&Q===1)continue;throw new Error(we+" is not a valid digit in base "+ae+".")}}ae=Ie(ae);var Ne=[],De=he[0]==="-";for(z=De?1:0;z<he.length;z++){var we=he[z];if(we in ue)Ne.push(Ie(ue[we]));else if(we==="<"){var je=z;do z++;while(he[z]!==">"&&z<he.length);Ne.push(Ie(he.slice(je+1,z)))}else throw new Error(we+" is not a valid character")}return Ce(Ne,ae,De)};function Ce(he,ae,be){var Ae=u[0],re=u[1],z;for(z=he.length-1;z>=0;z--)Ae=Ae.add(he[z].times(re)),re=re.times(ae);return be?Ae.negate():Ae}function $e(he,ae){return ae=ae||l,he<ae.length?ae[he]:"<"+he+">"}function Ue(he,ae){if(ae=t(ae),ae.isZero()){if(he.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(ae.equals(-1)){if(he.isZero())return{value:[0],isNegative:!1};if(he.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-he.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var be=Array.apply(null,Array(he.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return be.unshift([1]),{value:[].concat.apply([],be),isNegative:!1}}var Ae=!1;if(he.isNegative()&&ae.isPositive()&&(Ae=!0,he=he.abs()),ae.isUnit())return he.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(he.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:Ae};for(var re=[],z=he,Q;z.isNegative()||z.compareAbs(ae)>=0;){Q=z.divmod(ae),z=Q.quotient;var ue=Q.remainder;ue.isNegative()&&(ue=ae.minus(ue).abs(),z=z.next()),re.push(ue.toJSNumber())}return re.push(z.toJSNumber()),{value:re.reverse(),isNegative:Ae}}function Me(he,ae,be){var Ae=Ue(he,ae);return(Ae.isNegative?"-":"")+Ae.value.map(function(re){return $e(re,be)}).join("")}c.prototype.toArray=function(he){return Ue(this,he)},v.prototype.toArray=function(he){return Ue(this,he)},w.prototype.toArray=function(he){return Ue(this,he)},c.prototype.toString=function(he,ae){if(he===r&&(he=10),he!==10||ae)return Me(this,he,ae);for(var be=this.value,Ae=be.length,re=String(be[--Ae]),z="0000000",Q;--Ae>=0;)Q=String(be[Ae]),re+=z.slice(Q.length)+Q;var ue=this.sign?"-":"";return ue+re},v.prototype.toString=function(he,ae){return he===r&&(he=10),he!=10||ae?Me(this,he,ae):String(this.value)},w.prototype.toString=v.prototype.toString,w.prototype.toJSON=c.prototype.toJSON=v.prototype.toJSON=function(){return this.toString()},c.prototype.valueOf=function(){return parseInt(this.toString(),10)},c.prototype.toJSNumber=c.prototype.valueOf,v.prototype.valueOf=function(){return this.value},v.prototype.toJSNumber=v.prototype.valueOf,w.prototype.valueOf=w.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function ke(he){if(b(+he)){var ae=+he;if(ae===M(ae))return p?new w(BigInt(ae)):new v(ae);throw new Error("Invalid integer: "+he)}var be=he[0]==="-";be&&(he=he.slice(1));var Ae=he.split(/e/i);if(Ae.length>2)throw new Error("Invalid integer: "+Ae.join("e"));if(Ae.length===2){var re=Ae[1];if(re[0]==="+"&&(re=re.slice(1)),re=+re,re!==M(re)||!b(re))throw new Error("Invalid integer: "+re+" is not a valid exponent.");var z=Ae[0],Q=z.indexOf(".");if(Q>=0&&(re-=z.length-Q-1,z=z.slice(0,Q)+z.slice(Q+1)),re<0)throw new Error("Cannot include negative exponent part for integers");z+=new Array(re+1).join("0"),he=z}var ue=/^([0-9][0-9]*)$/.test(he);if(!ue)throw new Error("Invalid integer: "+he);if(p)return new w(BigInt(be?"-"+he:he));for(var we=[],Ne=he.length,De=o,je=Ne-De;Ne>0;)we.push(+he.slice(je,Ne)),je-=De,je<0&&(je=0),Ne-=De;return x(we),new c(we,be)}function tt(he){if(p)return new w(BigInt(he));if(b(he)){if(he!==M(he))throw new Error(he+" is not an integer.");return new v(he)}return ke(he.toString())}function Ie(he){return typeof he=="number"?tt(he):typeof he=="string"?ke(he):typeof he=="bigint"?new w(he):he}for(var xe=0;xe<1e3;xe++)u[xe]=Ie(xe),xe>0&&(u[-xe]=Ie(-xe));return u.one=u[1],u.zero=u[0],u.minusOne=u[-1],u.max=V,u.min=te,u.gcd=le,u.lcm=me,u.isInstance=function(he){return he instanceof c||he instanceof v||he instanceof w},u.randBetween=Re,u.fromArray=function(he,ae,be){return Ce(he.map(Ie),Ie(ae||10),be)},u}();e.hasOwnProperty("exports")&&(e.exports=t)})(BigInteger);var BigIntegerExports=BigInteger.exports;Object.defineProperty(amount,"__esModule",{value:!0});amount.Amount=void 0;const decimal_js_1$1=decimalExports,binary_parser_1$4=binaryParser,account_id_1$3=accountId,currency_1$2=currency,serialized_type_1$6=serializedType,bigInt$3=BigIntegerExports,buffer_1$f=dist$t,MIN_IOU_EXPONENT=-96,MAX_IOU_EXPONENT=80,MAX_IOU_PRECISION=16,MAX_DROPS=new decimal_js_1$1.Decimal("1e17"),MIN_XRP=new decimal_js_1$1.Decimal("1e-6"),mask$1=bigInt$3(4294967295);decimal_js_1$1.Decimal.config({toExpPos:MAX_IOU_EXPONENT+MAX_IOU_PRECISION,toExpNeg:MIN_IOU_EXPONENT-MAX_IOU_PRECISION});function isAmountObject(e){const t=Object.keys(e).sort();return t.length===3&&t[0]==="currency"&&t[1]==="issuer"&&t[2]==="value"}class Amount extends serialized_type_1$6.SerializedType{constructor(t){super(t??Amount.defaultAmount.bytes)}static from(t){if(t instanceof Amount)return t;let r=buffer_1$f.Buffer.alloc(8);if(typeof t=="string"){Amount.assertXrpIsValid(t);const s=bigInt$3(t),o=[buffer_1$f.Buffer.alloc(4),buffer_1$f.Buffer.alloc(4)];return o[0].writeUInt32BE(Number(s.shiftRight(32)),0),o[1].writeUInt32BE(Number(s.and(mask$1)),0),r=buffer_1$f.Buffer.concat(o),r[0]|=64,new Amount(r)}if(isAmountObject(t)){const s=new decimal_js_1$1.Decimal(t.value);if(Amount.assertIouIsValid(s),s.isZero())r[0]|=128;else{const a=s.times(`1e${-(s.e-15)}`).abs().toString(),l=bigInt$3(a),p=[buffer_1$f.Buffer.alloc(4),buffer_1$f.Buffer.alloc(4)];p[0].writeUInt32BE(Number(l.shiftRight(32)),0),p[1].writeUInt32BE(Number(l.and(mask$1)),0),r=buffer_1$f.Buffer.concat(p),r[0]|=128,s.gt(new decimal_js_1$1.Decimal(0))&&(r[0]|=64);const c=97+(s.e-15);r[0]|=c>>>2,r[1]|=(c&3)<<6}const o=currency_1$2.Currency.from(t.currency).toBytes(),n=account_id_1$3.AccountID.from(t.issuer).toBytes();return new Amount(buffer_1$f.Buffer.concat([r,o,n]))}throw new Error("Invalid type to construct an Amount")}static fromParser(t){const s=t.peek()&128?48:8;return new Amount(t.read(s))}toJSON(){if(this.isNative()){const t=this.bytes,s=t[0]&64?"":"-";t[0]&=63;const o=bigInt$3(t.slice(0,4).readUInt32BE(0)),n=bigInt$3(t.slice(4).readUInt32BE(0)),a=o.shiftLeft(32).or(n);return`${s}${a.toString()}`}else{const t=new binary_parser_1$4.BinaryParser(this.toString()),r=t.read(8),s=currency_1$2.Currency.fromParser(t),o=account_id_1$3.AccountID.fromParser(t),n=r[0],a=r[1],p=n&64?"":"-",u=((n&63)<<2)+((a&255)>>6)-97;r[0]=0,r[1]&=63;const c=new decimal_js_1$1.Decimal(`${p}0x${r.toString("hex")}`).times(`1e${u}`);return Amount.assertIouIsValid(c),{value:c.toString(),currency:s.toJSON(),issuer:o.toJSON()}}}static assertXrpIsValid(t){if(t.indexOf(".")!==-1)throw new Error(`${t.toString()} is an illegal amount`);const r=new decimal_js_1$1.Decimal(t);if(!r.isZero()&&(r.lt(MIN_XRP)||r.gt(MAX_DROPS)))throw new Error(`${t.toString()} is an illegal amount`)}static assertIouIsValid(t){if(!t.isZero()){const r=t.precision(),s=t.e-15;if(r>MAX_IOU_PRECISION||s>MAX_IOU_EXPONENT||s<MIN_IOU_EXPONENT)throw new Error("Decimal precision out of range");this.verifyNoDecimal(t)}}static verifyNoDecimal(t){if(t.times(`1e${-(t.e-15)}`).abs().toString().indexOf(".")!==-1)throw new Error("Decimal place found in integerNumberString")}isNative(){return(this.bytes[0]&128)===0}}amount.Amount=Amount;Amount.defaultAmount=new Amount(buffer_1$f.Buffer.from("4000000000000000","hex"));var blob={};Object.defineProperty(blob,"__esModule",{value:!0});blob.Blob=void 0;const serialized_type_1$5=serializedType,buffer_1$e=dist$t;class Blob extends serialized_type_1$5.SerializedType{constructor(t){super(t)}static fromParser(t,r){return new Blob(t.read(r))}static from(t){if(t instanceof Blob)return t;if(typeof t=="string")return new Blob(buffer_1$e.Buffer.from(t,"hex"));throw new Error("Cannot construct Blob from value given")}}blob.Blob=Blob;var hash128={};Object.defineProperty(hash128,"__esModule",{value:!0});hash128.Hash128=void 0;const hash_1$1=hash$1,buffer_1$d=dist$t;class Hash128 extends hash_1$1.Hash{constructor(t){t&&t.byteLength===0&&(t=Hash128.ZERO_128.bytes),super(t??Hash128.ZERO_128.bytes)}toHex(){const t=this.toBytes().toString("hex").toUpperCase();return/^0+$/.exec(t)?"":t}}hash128.Hash128=Hash128;Hash128.width=16;Hash128.ZERO_128=new Hash128(buffer_1$d.Buffer.alloc(Hash128.width));var hash256={};Object.defineProperty(hash256,"__esModule",{value:!0});hash256.Hash256=void 0;const hash_1=hash$1,buffer_1$c=dist$t;class Hash256 extends hash_1.Hash{constructor(t){super(t??Hash256.ZERO_256.bytes)}}hash256.Hash256=Hash256;Hash256.width=32;Hash256.ZERO_256=new Hash256(buffer_1$c.Buffer.alloc(Hash256.width));var issue={};Object.defineProperty(issue,"__esModule",{value:!0});issue.Issue=void 0;const binary_parser_1$3=binaryParser,account_id_1$2=accountId,currency_1$1=currency,serialized_type_1$4=serializedType,buffer_1$b=dist$t;function isIssueObject(e){const t=Object.keys(e).sort();return t.length===1?t[0]==="currency":t.length===2&&t[0]==="currency"&&t[1]==="issuer"}class Issue extends serialized_type_1$4.SerializedType{constructor(t){super(t??Issue.ZERO_ISSUED_CURRENCY.bytes)}static from(t){if(t instanceof Issue)return t;if(isIssueObject(t)){const r=currency_1$1.Currency.from(t.currency).toBytes();if(t.issuer==null)return new Issue(r);const s=account_id_1$2.AccountID.from(t.issuer).toBytes();return new Issue(buffer_1$b.Buffer.concat([r,s]))}throw new Error("Invalid type to construct an Amount")}static fromParser(t){const r=t.read(20);if(new currency_1$1.Currency(r).toJSON()==="XRP")return new Issue(r);const s=[r,t.read(20)];return new Issue(buffer_1$b.Buffer.concat(s))}toJSON(){const t=new binary_parser_1$3.BinaryParser(this.toString()),r=currency_1$1.Currency.fromParser(t);if(r.toJSON()==="XRP")return{currency:r.toJSON()};const s=account_id_1$2.AccountID.fromParser(t);return{currency:r.toJSON(),issuer:s.toJSON()}}}issue.Issue=Issue;Issue.ZERO_ISSUED_CURRENCY=new Issue(buffer_1$b.Buffer.alloc(20));var pathSet={};Object.defineProperty(pathSet,"__esModule",{value:!0});pathSet.PathSet=void 0;const account_id_1$1=accountId,currency_1=currency,binary_parser_1$2=binaryParser,serialized_type_1$3=serializedType,buffer_1$a=dist$t,PATHSET_END_BYTE=0,PATH_SEPARATOR_BYTE=255,TYPE_ACCOUNT=1,TYPE_CURRENCY=16,TYPE_ISSUER=32;function isHopObject(e){return e.issuer!==void 0||e.account!==void 0||e.currency!==void 0}function isPathSet(e){return Array.isArray(e)&&e.length===0||Array.isArray(e)&&Array.isArray(e[0])&&e[0].length===0||Array.isArray(e)&&Array.isArray(e[0])&&isHopObject(e[0][0])}class Hop extends serialized_type_1$3.SerializedType{static from(t){if(t instanceof Hop)return t;const r=[buffer_1$a.Buffer.from([0])];return t.account&&(r.push(account_id_1$1.AccountID.from(t.account).toBytes()),r[0][0]|=TYPE_ACCOUNT),t.currency&&(r.push(currency_1.Currency.from(t.currency).toBytes()),r[0][0]|=TYPE_CURRENCY),t.issuer&&(r.push(account_id_1$1.AccountID.from(t.issuer).toBytes()),r[0][0]|=TYPE_ISSUER),new Hop(buffer_1$a.Buffer.concat(r))}static fromParser(t){const r=t.readUInt8(),s=[buffer_1$a.Buffer.from([r])];return r&TYPE_ACCOUNT&&s.push(t.read(account_id_1$1.AccountID.width)),r&TYPE_CURRENCY&&s.push(t.read(currency_1.Currency.width)),r&TYPE_ISSUER&&s.push(t.read(account_id_1$1.AccountID.width)),new Hop(buffer_1$a.Buffer.concat(s))}toJSON(){const t=new binary_parser_1$2.BinaryParser(this.bytes.toString("hex")),r=t.readUInt8();let s,o,n;r&TYPE_ACCOUNT&&(s=account_id_1$1.AccountID.fromParser(t).toJSON()),r&TYPE_CURRENCY&&(o=currency_1.Currency.fromParser(t).toJSON()),r&TYPE_ISSUER&&(n=account_id_1$1.AccountID.fromParser(t).toJSON());const a={};return s&&(a.account=s),n&&(a.issuer=n),o&&(a.currency=o),a}type(){return this.bytes[0]}}class Path extends serialized_type_1$3.SerializedType{static from(t){if(t instanceof Path)return t;const r=[];return t.forEach(s=>{r.push(Hop.from(s).toBytes())}),new Path(buffer_1$a.Buffer.concat(r))}static fromParser(t){const r=[];for(;!t.end()&&(r.push(Hop.fromParser(t).toBytes()),!(t.peek()===PATHSET_END_BYTE||t.peek()===PATH_SEPARATOR_BYTE)););return new Path(buffer_1$a.Buffer.concat(r))}toJSON(){const t=[],r=new binary_parser_1$2.BinaryParser(this.toString());for(;!r.end();)t.push(Hop.fromParser(r).toJSON());return t}}class PathSet extends serialized_type_1$3.SerializedType{static from(t){if(t instanceof PathSet)return t;if(isPathSet(t)){const r=[];return t.forEach(s=>{r.push(Path.from(s).toBytes()),r.push(buffer_1$a.Buffer.from([PATH_SEPARATOR_BYTE]))}),r[r.length-1]=buffer_1$a.Buffer.from([PATHSET_END_BYTE]),new PathSet(buffer_1$a.Buffer.concat(r))}throw new Error("Cannot construct PathSet from given value")}static fromParser(t){const r=[];for(;!t.end()&&(r.push(Path.fromParser(t).toBytes()),r.push(t.read(1)),r[r.length-1][0]!=PATHSET_END_BYTE););return new PathSet(buffer_1$a.Buffer.concat(r))}toJSON(){const t=[],r=new binary_parser_1$2.BinaryParser(this.toString());for(;!r.end();)t.push(Path.fromParser(r).toJSON()),r.skip(1);return t}}pathSet.PathSet=PathSet;var stArray={},stObject={},hasRequiredStObject;function requireStObject(){if(hasRequiredStObject)return stObject;hasRequiredStObject=1,Object.defineProperty(stObject,"__esModule",{value:!0}),stObject.STObject=void 0;const e=enums,t=serializedType,r=dist$1,s=binaryParser,o=binarySerializer,n=dist$t,a=requireStArray(),l=n.Buffer.from([225]),p="ObjectEndMarker",u="STObject",c="Destination",v="Account",w="SourceTag",b="DestinationTag";function E(B,M){const q=(0,r.xAddressToClassicAddress)(M);let U;if(B===c)U=b;else if(B===v)U=w;else if(q.tag!==!1)throw new Error(`${B} cannot have an associated tag`);return q.tag!==!1?{[B]:q.classicAddress,[U]:q.tag}:{[B]:q.classicAddress}}function I(B,M){if(!(B[w]===void 0||M[w]===void 0))throw new Error("Cannot have Account X-Address and SourceTag");if(!(B[b]===void 0||M[b]===void 0))throw new Error("Cannot have Destination X-Address and DestinationTag")}class x extends t.SerializedType{static fromParser(M){const q=new o.BytesList,U=new o.BinarySerializer(q);for(;!M.end();){const F=M.readField();if(F.name===p)break;const j=M.readFieldValue(F);U.writeFieldAndValue(F,j),F.type.name===u&&U.put(l)}return new x(q.toBytes())}static from(M,q,U=e.DEFAULT_DEFINITIONS){if(M instanceof x)return M;const F=new o.BytesList,j=new o.BinarySerializer(F);let y=!1;const T=Object.entries(M).reduce((L,[C,d])=>{let _;return d&&(0,r.isValidXAddress)(d.toString())&&(_=E(C,d.toString()),I(_,M)),Object.assign(L,_??{[C]:d})},{});let D=Object.keys(T).map(L=>U.field[L]).filter(L=>L!==void 0&&T[L.name]!==void 0&&L.isSerialized).sort((L,C)=>L.ordinal-C.ordinal);return q!==void 0&&(D=D.filter(q)),D.forEach(L=>{const C=L.type.name===u?this.from(T[L.name],void 0,U):L.type.name==="STArray"?a.STArray.from(T[L.name],U):L.associatedType.from(T[L.name]);if(C==null)throw new TypeError(`Unable to interpret "${L.name}: ${T[L.name]}".`);C.name==="UNLModify"&&(y=!0);const d=L.name=="Account"&&y;j.writeFieldAndValue(L,C,d),L.type.name===u&&j.put(l)}),new x(F.toBytes())}toJSON(M){const q=new s.BinaryParser(this.toString(),M),U={};for(;!q.end();){const F=q.readField();if(F.name===p)break;U[F.name]=q.readFieldValue(F).toJSON(M)}return U}}return stObject.STObject=x,stObject}var hasRequiredStArray;function requireStArray(){if(hasRequiredStArray)return stArray;hasRequiredStArray=1,Object.defineProperty(stArray,"__esModule",{value:!0}),stArray.STArray=void 0;const e=enums,t=serializedType,r=requireStObject(),s=binaryParser,o=dist$t,n=o.Buffer.from([241]),a="ArrayEndMarker",l=o.Buffer.from([225]);function p(c){return Array.isArray(c)&&(c.length===0||typeof c[0]=="object")}class u extends t.SerializedType{static fromParser(v){const w=[];for(;!v.end();){const b=v.readField();if(b.name===a)break;w.push(b.header,v.readFieldValue(b).toBytes(),l)}return w.push(n),new u(o.Buffer.concat(w))}static from(v,w=e.DEFAULT_DEFINITIONS){if(v instanceof u)return v;if(p(v)){const b=[];return v.forEach(E=>{b.push(r.STObject.from(E,void 0,w).toBytes())}),b.push(n),new u(o.Buffer.concat(b))}throw new Error("Cannot construct STArray from value given")}toJSON(v=e.DEFAULT_DEFINITIONS){const w=[],b=new s.BinaryParser(this.toString(),v);for(;!b.end();){const E=b.readField();if(E.name===a)break;const I={};I[E.name]=r.STObject.fromParser(b).toJSON(v),w.push(I)}return w}}return stArray.STArray=u,stArray}var uint16={},uint={};Object.defineProperty(uint,"__esModule",{value:!0});uint.UInt=void 0;const serialized_type_1$2=serializedType;function compare(e,t){return e<t?-1:e==t?0:1}class UInt extends serialized_type_1$2.Comparable{constructor(t){super(t)}compareTo(t){return compare(this.valueOf(),t.valueOf())}toJSON(){const t=this.valueOf();return typeof t=="number"?t:t.toString()}}uint.UInt=UInt;Object.defineProperty(uint16,"__esModule",{value:!0});uint16.UInt16=void 0;const uint_1$3=uint,buffer_1$9=dist$t;class UInt16 extends uint_1$3.UInt{constructor(t){super(t??UInt16.defaultUInt16.bytes)}static fromParser(t){return new UInt16(t.read(UInt16.width))}static from(t){if(t instanceof UInt16)return t;if(typeof t=="number"){const r=buffer_1$9.Buffer.alloc(UInt16.width);return r.writeUInt16BE(t,0),new UInt16(r)}throw new Error("Can not construct UInt16 with given value")}valueOf(){return this.bytes.readUInt16BE(0)}}uint16.UInt16=UInt16;UInt16.width=16/8;UInt16.defaultUInt16=new UInt16(buffer_1$9.Buffer.alloc(UInt16.width));var uint32={};Object.defineProperty(uint32,"__esModule",{value:!0});uint32.UInt32=void 0;const uint_1$2=uint,buffer_1$8=dist$t;class UInt32 extends uint_1$2.UInt{constructor(t){super(t??UInt32.defaultUInt32.bytes)}static fromParser(t){return new UInt32(t.read(UInt32.width))}static from(t){if(t instanceof UInt32)return t;const r=buffer_1$8.Buffer.alloc(UInt32.width);if(typeof t=="string"){const s=Number.parseInt(t);return r.writeUInt32BE(s,0),new UInt32(r)}if(typeof t=="number")return r.writeUInt32BE(t,0),new UInt32(r);throw new Error("Cannot construct UInt32 from given value")}valueOf(){return this.bytes.readUInt32BE(0)}}uint32.UInt32=UInt32;UInt32.width=32/8;UInt32.defaultUInt32=new UInt32(buffer_1$8.Buffer.alloc(UInt32.width));var uint64={};Object.defineProperty(uint64,"__esModule",{value:!0});uint64.UInt64=void 0;const uint_1$1=uint,bigInt$2=BigIntegerExports,big_integer_1=BigIntegerExports,buffer_1$7=dist$t,HEX_REGEX=/^[a-fA-F0-9]{1,16}$/,mask=bigInt$2(4294967295);class UInt64 extends uint_1$1.UInt{constructor(t){super(t??UInt64.defaultUInt64.bytes)}static fromParser(t){return new UInt64(t.read(UInt64.width))}static from(t){if(t instanceof UInt64)return t;let r=buffer_1$7.Buffer.alloc(UInt64.width);if(typeof t=="number"){if(t<0)throw new Error("value must be an unsigned integer");const s=bigInt$2(t),o=[buffer_1$7.Buffer.alloc(4),buffer_1$7.Buffer.alloc(4)];return o[0].writeUInt32BE(Number(s.shiftRight(32)),0),o[1].writeUInt32BE(Number(s.and(mask)),0),new UInt64(buffer_1$7.Buffer.concat(o))}if(typeof t=="string"){if(!HEX_REGEX.test(t))throw new Error(`${t} is not a valid hex-string`);const s=t.padStart(16,"0");return r=buffer_1$7.Buffer.from(s,"hex"),new UInt64(r)}if((0,big_integer_1.isInstance)(t)){const s=[buffer_1$7.Buffer.alloc(4),buffer_1$7.Buffer.alloc(4)];return s[0].writeUInt32BE(Number(t.shiftRight(bigInt$2(32))),0),s[1].writeUInt32BE(Number(t.and(mask)),0),new UInt64(buffer_1$7.Buffer.concat(s))}throw new Error("Cannot construct UInt64 from given value")}toJSON(){return this.bytes.toString("hex").toUpperCase()}valueOf(){const t=bigInt$2(this.bytes.slice(0,4).readUInt32BE(0)),r=bigInt$2(this.bytes.slice(4).readUInt32BE(0));return t.shiftLeft(bigInt$2(32)).or(r)}toBytes(){return this.bytes}}uint64.UInt64=UInt64;UInt64.width=64/8;UInt64.defaultUInt64=new UInt64(buffer_1$7.Buffer.alloc(UInt64.width));var uint8={};Object.defineProperty(uint8,"__esModule",{value:!0});uint8.UInt8=void 0;const uint_1=uint,buffer_1$6=dist$t;class UInt8 extends uint_1.UInt{constructor(t){super(t??UInt8.defaultUInt8.bytes)}static fromParser(t){return new UInt8(t.read(UInt8.width))}static from(t){if(t instanceof UInt8)return t;if(typeof t=="number"){const r=buffer_1$6.Buffer.alloc(UInt8.width);return r.writeUInt8(t,0),new UInt8(r)}throw new Error("Cannot construct UInt8 from given value")}valueOf(){return this.bytes.readUInt8(0)}}uint8.UInt8=UInt8;UInt8.width=8/8;UInt8.defaultUInt8=new UInt8(buffer_1$6.Buffer.alloc(UInt8.width));var vector256={};Object.defineProperty(vector256,"__esModule",{value:!0});vector256.Vector256=void 0;const serialized_type_1$1=serializedType,hash_256_1$2=hash256,binary_serializer_1$1=binarySerializer;function isStrings(e){return Array.isArray(e)&&(e.length===0||typeof e[0]=="string")}class Vector256 extends serialized_type_1$1.SerializedType{constructor(t){super(t)}static fromParser(t,r){const s=new binary_serializer_1$1.BytesList,n=(r??t.size())/32;for(let a=0;a<n;a++)hash_256_1$2.Hash256.fromParser(t).toBytesSink(s);return new Vector256(s.toBytes())}static from(t){if(t instanceof Vector256)return t;if(isStrings(t)){const r=new binary_serializer_1$1.BytesList;return t.forEach(s=>{hash_256_1$2.Hash256.from(s).toBytesSink(r)}),new Vector256(r.toBytes())}throw new Error("Cannot construct Vector256 from given value")}toJSON(){if(this.bytes.byteLength%32!==0)throw new Error("Invalid bytes for Vector256");const t=[];for(let r=0;r<this.bytes.byteLength;r+=32)t.push(this.bytes.slice(r,r+32).toString("hex").toUpperCase());return t}}vector256.Vector256=Vector256;var xchainBridge={};Object.defineProperty(xchainBridge,"__esModule",{value:!0});xchainBridge.XChainBridge=void 0;const binary_parser_1$1=binaryParser,account_id_1=accountId,serialized_type_1=serializedType,buffer_1$5=dist$t,issue_1=issue;function isXChainBridgeObject(e){const t=Object.keys(e).sort();return t.length===4&&t[0]==="IssuingChainDoor"&&t[1]==="IssuingChainIssue"&&t[2]==="LockingChainDoor"&&t[3]==="LockingChainIssue"}class XChainBridge extends serialized_type_1.SerializedType{constructor(t){super(t??XChainBridge.ZERO_XCHAIN_BRIDGE.bytes)}static from(t){if(t instanceof XChainBridge)return t;if(!isXChainBridgeObject(t))throw new Error("Invalid type to construct an XChainBridge");const r=[];return this.TYPE_ORDER.forEach(s=>{const{name:o,type:n}=s;n===account_id_1.AccountID&&r.push(buffer_1$5.Buffer.from([20]));const a=n.from(t[o]);r.push(a.toBytes())}),new XChainBridge(buffer_1$5.Buffer.concat(r))}static fromParser(t){const r=[];return this.TYPE_ORDER.forEach(s=>{const{type:o}=s;o===account_id_1.AccountID&&(t.skip(1),r.push(buffer_1$5.Buffer.from([20])));const n=o.fromParser(t);r.push(n.toBytes())}),new XChainBridge(buffer_1$5.Buffer.concat(r))}toJSON(){const t=new binary_parser_1$1.BinaryParser(this.toString()),r={};return XChainBridge.TYPE_ORDER.forEach(s=>{const{name:o,type:n}=s;n===account_id_1.AccountID&&t.skip(1);const a=n.fromParser(t).toJSON();r[o]=a}),r}}xchainBridge.XChainBridge=XChainBridge;XChainBridge.ZERO_XCHAIN_BRIDGE=new XChainBridge(buffer_1$5.Buffer.concat([buffer_1$5.Buffer.from([20]),buffer_1$5.Buffer.alloc(40),buffer_1$5.Buffer.from([20]),buffer_1$5.Buffer.alloc(40)]));XChainBridge.TYPE_ORDER=[{name:"LockingChainDoor",type:account_id_1.AccountID},{name:"LockingChainIssue",type:issue_1.Issue},{name:"IssuingChainDoor",type:account_id_1.AccountID},{name:"IssuingChainIssue",type:issue_1.Issue}];(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Vector256=e.UInt64=e.UInt32=e.UInt16=e.UInt8=e.STObject=e.STArray=e.PathSet=e.Hash256=e.Hash160=e.Hash128=e.Currency=e.Blob=e.Amount=e.AccountID=e.coreTypes=void 0;const t=accountId;Object.defineProperty(e,"AccountID",{enumerable:!0,get:function(){return t.AccountID}});const r=amount;Object.defineProperty(e,"Amount",{enumerable:!0,get:function(){return r.Amount}});const s=blob;Object.defineProperty(e,"Blob",{enumerable:!0,get:function(){return s.Blob}});const o=currency;Object.defineProperty(e,"Currency",{enumerable:!0,get:function(){return o.Currency}});const n=hash128;Object.defineProperty(e,"Hash128",{enumerable:!0,get:function(){return n.Hash128}});const a=hash160$1;Object.defineProperty(e,"Hash160",{enumerable:!0,get:function(){return a.Hash160}});const l=hash256;Object.defineProperty(e,"Hash256",{enumerable:!0,get:function(){return l.Hash256}});const p=issue,u=pathSet;Object.defineProperty(e,"PathSet",{enumerable:!0,get:function(){return u.PathSet}});const c=requireStArray();Object.defineProperty(e,"STArray",{enumerable:!0,get:function(){return c.STArray}});const v=requireStObject();Object.defineProperty(e,"STObject",{enumerable:!0,get:function(){return v.STObject}});const w=uint16;Object.defineProperty(e,"UInt16",{enumerable:!0,get:function(){return w.UInt16}});const b=uint32;Object.defineProperty(e,"UInt32",{enumerable:!0,get:function(){return b.UInt32}});const E=uint64;Object.defineProperty(e,"UInt64",{enumerable:!0,get:function(){return E.UInt64}});const I=uint8;Object.defineProperty(e,"UInt8",{enumerable:!0,get:function(){return I.UInt8}});const x=vector256;Object.defineProperty(e,"Vector256",{enumerable:!0,get:function(){return x.Vector256}});const B=xchainBridge,M=enums,q={AccountID:t.AccountID,Amount:r.Amount,Blob:s.Blob,Currency:o.Currency,Hash128:n.Hash128,Hash160:a.Hash160,Hash256:l.Hash256,Issue:p.Issue,PathSet:u.PathSet,STArray:c.STArray,STObject:v.STObject,UInt8:I.UInt8,UInt16:w.UInt16,UInt32:b.UInt32,UInt64:E.UInt64,Vector256:x.Vector256,XChainBridge:B.XChainBridge};e.coreTypes=q,M.DEFAULT_DEFINITIONS.associateTypes(q)})(types$5);var binary={},hashPrefixes={};Object.defineProperty(hashPrefixes,"__esModule",{value:!0});hashPrefixes.HashPrefix=void 0;const buffer_1$4=dist$t;function bytes$1(e){const t=buffer_1$4.Buffer.alloc(4);return t.writeUInt32BE(e,0),t}const HashPrefix={transactionID:bytes$1(1415073280),transaction:bytes$1(1397638144),accountStateEntry:bytes$1(1296846336),innerNode:bytes$1(1296649728),ledgerHeader:bytes$1(1280791040),transactionSig:bytes$1(1398036480),transactionMultiSig:bytes$1(1397576704),validation:bytes$1(1447119872),proposal:bytes$1(1347571712),paymentChannelClaim:bytes$1(1129073920)};hashPrefixes.HashPrefix=HashPrefix;var hashes={};Object.defineProperty(hashes,"__esModule",{value:!0});hashes.transactionID=hashes.sha512Half=hashes.Sha512Half=void 0;const hash_prefixes_1$2=hashPrefixes,createHash=browser$a,hash_256_1$1=hash256,binary_serializer_1=binarySerializer,buffer_1$3=dist$t;class Sha512Half extends binary_serializer_1.BytesList{constructor(){super(...arguments),this.hash=createHash("sha512")}static put(t){return new Sha512Half().put(t)}put(t){return this.hash.update(t),this}finish256(){return buffer_1$3.Buffer.from(this.hash.digest().slice(0,32))}finish(){return new hash_256_1$1.Hash256(this.finish256())}}hashes.Sha512Half=Sha512Half;function sha512Half(...e){const t=new Sha512Half;return e.forEach(r=>t.put(r)),t.finish256()}hashes.sha512Half=sha512Half;function transactionID(e){return new hash_256_1$1.Hash256(sha512Half(hash_prefixes_1$2.HashPrefix.transactionID,e))}hashes.transactionID=transactionID;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.transactionID=e.sha512Half=e.binaryToJSON=e.signingClaimData=e.signingData=e.multiSigningData=e.readJSON=e.serializeObject=e.makeParser=e.BytesList=e.BinarySerializer=e.BinaryParser=void 0;const t=types$5,r=binaryParser;Object.defineProperty(e,"BinaryParser",{enumerable:!0,get:function(){return r.BinaryParser}});const s=hashPrefixes,o=binarySerializer;Object.defineProperty(e,"BinarySerializer",{enumerable:!0,get:function(){return o.BinarySerializer}}),Object.defineProperty(e,"BytesList",{enumerable:!0,get:function(){return o.BytesList}});const n=hashes;Object.defineProperty(e,"sha512Half",{enumerable:!0,get:function(){return n.sha512Half}}),Object.defineProperty(e,"transactionID",{enumerable:!0,get:function(){return n.transactionID}});const a=enums,l=BigIntegerExports,p=(I,x)=>new r.BinaryParser(I,x);e.makeParser=p;const u=(I,x=a.DEFAULT_DEFINITIONS)=>I.readType(t.coreTypes.STObject).toJSON(x);e.readJSON=u;const c=(I,x)=>u(p(I,x),x);e.binaryToJSON=c;function v(I,x={}){const{prefix:B,suffix:M,signingFieldsOnly:q=!1,definitions:U}=x,F=new o.BytesList;B&&F.put(B);const j=q?y=>y.isSigningField:void 0;return t.coreTypes.STObject.from(I,j,U).toBytesSink(F),M&&F.put(M),F.toBytes()}e.serializeObject=v;function w(I,x=s.HashPrefix.transactionSig,B={}){return v(I,{prefix:x,signingFieldsOnly:!0,definitions:B.definitions})}e.signingData=w;function b(I){const x=l(String(I.amount)),B=s.HashPrefix.paymentChannelClaim,M=t.coreTypes.Hash256.from(I.channel).toBytes(),q=t.coreTypes.UInt64.from(x).toBytes(),U=new o.BytesList;return U.put(B),U.put(M),U.put(q),U.toBytes()}e.signingClaimData=b;function E(I,x,B={definitions:a.DEFAULT_DEFINITIONS}){const M=s.HashPrefix.transactionMultiSig,q=t.coreTypes.AccountID.from(x).toBytes();return v(I,{prefix:M,suffix:q,signingFieldsOnly:!0,definitions:B.definitions})}e.multiSigningData=E})(binary);var shamap={};Object.defineProperty(shamap,"__esModule",{value:!0});shamap.ShaMapLeaf=shamap.ShaMapNode=shamap.ShaMap=void 0;const assert_1=requireAssert(),types_1$b=types$5,hash_prefixes_1$1=hashPrefixes,hashes_1$1=hashes,buffer_1$2=dist$t;class ShaMapNode{}shamap.ShaMapNode=ShaMapNode;class ShaMapLeaf extends ShaMapNode{constructor(t,r){super(),this.index=t,this.item=r}isLeaf(){return!0}isInner(){return!1}hashPrefix(){return this.item===void 0?buffer_1$2.Buffer.alloc(0):this.item.hashPrefix()}hash(){const t=hashes_1$1.Sha512Half.put(this.hashPrefix());return this.toBytesSink(t),t.finish()}toBytesSink(t){this.item!==void 0&&this.item.toBytesSink(t),this.index.toBytesSink(t)}}shamap.ShaMapLeaf=ShaMapLeaf;class ShaMapInner extends ShaMapNode{constructor(t=0){super(),this.depth=t,this.slotBits=0,this.branches=Array(16)}isInner(){return!0}isLeaf(){return!1}hashPrefix(){return hash_prefixes_1$1.HashPrefix.innerNode}setBranch(t,r){this.slotBits=this.slotBits|1<<t,this.branches[t]=r}empty(){return this.slotBits===0}hash(){if(this.empty())return types_1$b.coreTypes.Hash256.ZERO_256;const t=hashes_1$1.Sha512Half.put(this.hashPrefix());return this.toBytesSink(t),t.finish()}toBytesSink(t){for(let r=0;r<this.branches.length;r++){const s=this.branches[r];(s?s.hash():types_1$b.coreTypes.Hash256.ZERO_256).toBytesSink(t)}}addItem(t,r,s){if(assert_1.strict.ok(t!==void 0),t!==void 0){const o=t.nibblet(this.depth),n=this.branches[o];if(n===void 0)this.setBranch(o,s||new ShaMapLeaf(t,r));else if(n instanceof ShaMapLeaf){const a=new ShaMapInner(this.depth+1);a.addItem(n.index,void 0,n),a.addItem(t,r,s),this.setBranch(o,a)}else if(n instanceof ShaMapInner)n.addItem(t,r,s);else throw new Error("invalid ShaMap.addItem call")}}}class ShaMap extends ShaMapInner{}shamap.ShaMap=ShaMap;var ledgerHashes={},__createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),__setModuleDefault=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t};Object.defineProperty(ledgerHashes,"__esModule",{value:!0});ledgerHashes.decodeLedgerData=ledgerHashes.ledgerHash=ledgerHashes.transactionTreeHash=ledgerHashes.accountStateHash=void 0;const assert$1=__importStar(requireAssert()),shamap_1=shamap,hash_prefixes_1=hashPrefixes,hashes_1=hashes,binary_1=binary,hash_256_1=hash256,st_object_1=requireStObject(),uint_64_1=uint64,uint_32_1=uint32,uint_8_1=uint8,binary_parser_1=binaryParser,bigInt$1=BigIntegerExports;function computeHash(e,t){const r=new shamap_1.ShaMap;return t.forEach(s=>r.addItem(...e(s))),r.hash()}function transactionItemizer(e){return assert$1.ok(e.hash),[hash_256_1.Hash256.from(e.hash),{hashPrefix(){return hash_prefixes_1.HashPrefix.transaction},toBytesSink(s){const o=new binary_1.BinarySerializer(s);o.writeLengthEncoded(st_object_1.STObject.from(e)),o.writeLengthEncoded(st_object_1.STObject.from(e.metaData))}},void 0]}function entryItemizer(e){const t=hash_256_1.Hash256.from(e.index),r=(0,binary_1.serializeObject)(e);return[t,{hashPrefix(){return hash_prefixes_1.HashPrefix.accountStateEntry},toBytesSink(o){o.put(r)}},void 0]}function transactionTreeHash(e){return computeHash(transactionItemizer,e)}ledgerHashes.transactionTreeHash=transactionTreeHash;function accountStateHash(e){return computeHash(entryItemizer,e)}ledgerHashes.accountStateHash=accountStateHash;function ledgerHash(e){const t=new hashes_1.Sha512Half;return t.put(hash_prefixes_1.HashPrefix.ledgerHeader),assert$1.ok(e.parent_close_time!==void 0),assert$1.ok(e.close_flags!==void 0),uint_32_1.UInt32.from(e.ledger_index).toBytesSink(t),uint_64_1.UInt64.from(bigInt$1(String(e.total_coins))).toBytesSink(t),hash_256_1.Hash256.from(e.parent_hash).toBytesSink(t),hash_256_1.Hash256.from(e.transaction_hash).toBytesSink(t),hash_256_1.Hash256.from(e.account_hash).toBytesSink(t),uint_32_1.UInt32.from(e.parent_close_time).toBytesSink(t),uint_32_1.UInt32.from(e.close_time).toBytesSink(t),uint_8_1.UInt8.from(e.close_time_resolution).toBytesSink(t),uint_8_1.UInt8.from(e.close_flags).toBytesSink(t),t.finish()}ledgerHashes.ledgerHash=ledgerHash;function decodeLedgerData(e,t){assert$1.ok(typeof e=="string","binary must be a hex string");const r=new binary_parser_1.BinaryParser(e,t);return{ledger_index:r.readUInt32(),total_coins:r.readType(uint_64_1.UInt64).valueOf().toString(),parent_hash:r.readType(hash_256_1.Hash256).toHex(),transaction_hash:r.readType(hash_256_1.Hash256).toHex(),account_hash:r.readType(hash_256_1.Hash256).toHex(),parent_close_time:r.readUInt32(),close_time:r.readUInt32(),close_time_resolution:r.readUInt8(),close_flags:r.readUInt8()}}ledgerHashes.decodeLedgerData=decodeLedgerData;var quality$1={};Object.defineProperty(quality$1,"__esModule",{value:!0});quality$1.quality=void 0;const types_1$a=types$5,decimal_js_1=decimalExports,bigInt=BigIntegerExports,buffer_1$1=dist$t;class quality{static encode(t){const r=new decimal_js_1.Decimal(t),s=r.e-15,o=r.times(`1e${-s}`).abs().toString(),n=types_1$a.coreTypes.UInt64.from(bigInt(o)).toBytes();return n[0]=s+100,n}static decode(t){const r=buffer_1$1.Buffer.from(t,"hex").slice(-8),s=r[0]-100;return new decimal_js_1.Decimal(`0x${r.slice(1).toString("hex")}`).times(`1e${s}`)}}quality$1.quality=quality;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(w,b,E,I){I===void 0&&(I=E);var x=Object.getOwnPropertyDescriptor(b,E);(!x||("get"in x?!b.__esModule:x.writable||x.configurable))&&(x={enumerable:!0,get:function(){return b[E]}}),Object.defineProperty(w,I,x)}:function(w,b,E,I){I===void 0&&(I=E),w[I]=b[E]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(w,b){Object.defineProperty(w,"default",{enumerable:!0,value:b})}:function(w,b){w.default=b}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(w){if(w&&w.__esModule)return w;var b={};if(w!=null)for(var E in w)E!=="default"&&Object.prototype.hasOwnProperty.call(w,E)&&t(b,w,E);return r(b,w),b};Object.defineProperty(e,"__esModule",{value:!0}),e.types=e.ShaMap=e.HashPrefix=e.quality=e.TransactionResult=e.Type=e.LedgerEntryType=e.TransactionType=e.Field=e.DEFAULT_DEFINITIONS=e.ledgerHashes=e.binary=e.hashes=void 0;const o=enums;Object.defineProperty(e,"DEFAULT_DEFINITIONS",{enumerable:!0,get:function(){return o.DEFAULT_DEFINITIONS}}),Object.defineProperty(e,"Field",{enumerable:!0,get:function(){return o.Field}}),Object.defineProperty(e,"TransactionType",{enumerable:!0,get:function(){return o.TransactionType}}),Object.defineProperty(e,"LedgerEntryType",{enumerable:!0,get:function(){return o.LedgerEntryType}}),Object.defineProperty(e,"Type",{enumerable:!0,get:function(){return o.Type}}),Object.defineProperty(e,"TransactionResult",{enumerable:!0,get:function(){return o.TransactionResult}});const n=s(types$5);e.types=n;const a=s(binary);e.binary=a;const l=shamap;Object.defineProperty(e,"ShaMap",{enumerable:!0,get:function(){return l.ShaMap}});const p=s(ledgerHashes);e.ledgerHashes=p;const u=s(hashes);e.hashes=u;const c=quality$1;Object.defineProperty(e,"quality",{enumerable:!0,get:function(){return c.quality}});const v=hashPrefixes;Object.defineProperty(e,"HashPrefix",{enumerable:!0,get:function(){return v.HashPrefix}})})(coretypes);var xrplDefinitions={};Object.defineProperty(xrplDefinitions,"__esModule",{value:!0});xrplDefinitions.XrplDefinitions=void 0;const xrpl_definitions_base_1=xrplDefinitionsBase,types_1$9=types$5;class XrplDefinitions extends xrpl_definitions_base_1.XrplDefinitionsBase{constructor(t,r){const s=Object.assign({},types_1$9.coreTypes,r);super(t,s)}}xrplDefinitions.XrplDefinitions=XrplDefinitions;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(j,y,T,D){D===void 0&&(D=T);var L=Object.getOwnPropertyDescriptor(y,T);(!L||("get"in L?!y.__esModule:L.writable||L.configurable))&&(L={enumerable:!0,get:function(){return y[T]}}),Object.defineProperty(j,D,L)}:function(j,y,T,D){D===void 0&&(D=T),j[D]=y[T]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(j,y){Object.defineProperty(j,"default",{enumerable:!0,value:y})}:function(j,y){j.default=y}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(j){if(j&&j.__esModule)return j;var y={};if(j!=null)for(var T in j)T!=="default"&&Object.prototype.hasOwnProperty.call(j,T)&&t(y,j,T);return r(y,j),y};Object.defineProperty(e,"__esModule",{value:!0}),e.coreTypes=e.DEFAULT_DEFINITIONS=e.XrplDefinitionsBase=e.XrplDefinitions=e.TRANSACTION_TYPES=e.decodeLedgerData=e.decodeQuality=e.encodeQuality=e.encodeForMultisigning=e.encodeForSigningClaim=e.encodeForSigning=e.encode=e.decode=void 0;const o=s(requireAssert()),n=coretypes,a=ledgerHashes;Object.defineProperty(e,"decodeLedgerData",{enumerable:!0,get:function(){return a.decodeLedgerData}});const l=enums;Object.defineProperty(e,"XrplDefinitionsBase",{enumerable:!0,get:function(){return l.XrplDefinitionsBase}}),Object.defineProperty(e,"TRANSACTION_TYPES",{enumerable:!0,get:function(){return l.TRANSACTION_TYPES}}),Object.defineProperty(e,"DEFAULT_DEFINITIONS",{enumerable:!0,get:function(){return l.DEFAULT_DEFINITIONS}});const p=xrplDefinitions;Object.defineProperty(e,"XrplDefinitions",{enumerable:!0,get:function(){return p.XrplDefinitions}});const u=types$5;Object.defineProperty(e,"coreTypes",{enumerable:!0,get:function(){return u.coreTypes}});const{signingData:c,signingClaimData:v,multiSigningData:w,binaryToJSON:b,serializeObject:E}=n.binary;function I(j,y){return o.ok(typeof j=="string","binary must be a hex string"),b(j,y)}e.decode=I;function x(j,y){return o.ok(typeof j=="object"),E(j,{definitions:y}).toString("hex").toUpperCase()}e.encode=x;function B(j,y){return o.ok(typeof j=="object"),c(j,n.HashPrefix.transactionSig,{definitions:y}).toString("hex").toUpperCase()}e.encodeForSigning=B;function M(j){return o.ok(typeof j=="object"),v(j).toString("hex").toUpperCase()}e.encodeForSigningClaim=M;function q(j,y,T){return o.ok(typeof j=="object"),o.equal(j.SigningPubKey,""),w(j,y,T?{definitions:T}:void 0).toString("hex").toUpperCase()}e.encodeForMultisigning=q;function U(j){return o.ok(typeof j=="string"),n.quality.encode(j).toString("hex").toUpperCase()}e.encodeQuality=U;function F(j){return o.ok(typeof j=="string"),n.quality.decode(j).toString()}e.decodeQuality=F})(dist$2);Object.defineProperty(xrp,"__esModule",{value:!0});xrp.KeystoneXrpSDK=void 0;const bc_ur_1=dist$s,ripple_binary_codec_1=dist$2;class KeystoneXrpSDK{parseAccount(t){const r=t.decodeCBOR().toString();return JSON.parse(r)}parseSignature(t){if(t.type!=="bytes")throw new Error("type not match");try{const r=t.decodeCBOR().toString("hex");return(0,ripple_binary_codec_1.decode)(r).TxnSignature}catch{throw new Error("signature is invalid")}}generateSignRequest(t){const r=JSON.stringify(t);return bc_ur_1.UR.fromBuffer(Buffer$e.from(r))}}xrp.KeystoneXrpSDK=KeystoneXrpSDK;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(s,o,n,a){a===void 0&&(a=n);var l=Object.getOwnPropertyDescriptor(o,n);(!l||("get"in l?!o.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return o[n]}}),Object.defineProperty(s,a,l)}:function(s,o,n,a){a===void 0&&(a=n),s[a]=o[n]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(s,o){for(var n in s)n!=="default"&&!Object.prototype.hasOwnProperty.call(o,n)&&t(o,s,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(xrp,e)})(xrp$1);var __awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,r,s){function o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,a){function l(c){try{u(s.next(c))}catch(v){a(v)}}function p(c){try{u(s.throw(c))}catch(v){a(v)}}function u(c){c.done?n(c.value):o(c.value).then(l,p)}u((s=s.apply(e,t||[])).next())})};Object.defineProperty(sdk,"__esModule",{value:!0});sdk.KeystoneSDK=void 0;const chains_1=chains,wallet_1=wallet,xrp_1=xrp$1,CONFIG_URL="https://keyst.one/statics/sdk/config.json";class KeystoneSDK{constructor(t){this.parseMultiAccounts=wallet_1.parseMultiAccounts,this.parseTonAccount=wallet_1.parseTonAccount,this.parseHDKey=wallet_1.parseHDKey,this.parseAccount=wallet_1.parseAccount,this.generateKeyDerivationCall=wallet_1.generateKeyDerivationCall,this.config=t}static create(t){return __awaiter(this,void 0,void 0,function*(){try{const s=yield(yield fetch(CONFIG_URL)).json();return new KeystoneSDK(Object.assign(Object.assign({},t),s))}catch(r){return console.error("fetch config error",r),new KeystoneSDK(t)}})}get btc(){return this._btc===void 0&&(this._btc=new chains_1.KeystoneBitcoinSDK),this._btc}get eth(){return this._eth===void 0&&(this._eth=new chains_1.KeystoneEthereumSDK(this.config)),this._eth}get sol(){return this._sol===void 0&&(this._sol=new chains_1.KeystoneSolanaSDK),this._sol}get stellar(){return this._stellar===void 0&&(this._stellar=new chains_1.KeystoneStellarSDK),this._stellar}get cosmos(){return this._cosmos===void 0&&(this._cosmos=new chains_1.KeystoneCosmosSDK(this.config)),this._cosmos}get evm(){return this._evm===void 0&&(this._evm=new chains_1.KeystoneEvmSDK(this.config)),this._evm}get tron(){return this._tron===void 0&&(this._tron=new chains_1.KeystoneTronSDK),this._tron}get ltc(){return this._ltc===void 0&&(this._ltc=new chains_1.KeystoneLitecoinSDK),this._ltc}get bch(){return this._bch===void 0&&(this._bch=new chains_1.KeystoneBitcoinCashSDK),this._bch}get dash(){return this._dash===void 0&&(this._dash=new chains_1.KeystoneDashSDK),this._dash}get aptos(){return this._aptos===void 0&&(this._aptos=new chains_1.KeystoneAptosSDK),this._aptos}get near(){return this._near===void 0&&(this._near=new chains_1.KeystoneNearSDK),this._near}get arweave(){return this._arweave===void 0&&(this._arweave=new chains_1.KeystoneArweaveSDK),this._arweave}get sui(){return this._sui===void 0&&(this._sui=new chains_1.KeystoneSuiSDK(this.config)),this._sui}get cardano(){return this._cardano===void 0&&(this._cardano=new chains_1.KeystoneCardanoSDK),this._cardano}get xrp(){return this._xrp===void 0&&(this._xrp=new xrp_1.KeystoneXrpSDK),this._xrp}get ton(){return this._ton===void 0&&(this._ton=new chains_1.KeystoneTonSDK(this.config)),this._ton}}KeystoneSDK.parseMultiAccounts=wallet_1.parseMultiAccounts;KeystoneSDK.parseHDKey=wallet_1.parseHDKey;KeystoneSDK.generateKeyDerivationCall=wallet_1.generateKeyDerivationCall;sdk.KeystoneSDK=KeystoneSDK;(function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(u,c,v,w){w===void 0&&(w=v);var b=Object.getOwnPropertyDescriptor(c,v);(!b||("get"in b?!c.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return c[v]}}),Object.defineProperty(u,w,b)}:function(u,c,v,w){w===void 0&&(w=v),u[w]=c[v]}),r=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(u,c){Object.defineProperty(u,"default",{enumerable:!0,value:c})}:function(u,c){u.default=c}),s=commonjsGlobal&&commonjsGlobal.__importStar||function(u){if(u&&u.__esModule)return u;var c={};if(u!=null)for(var v in u)v!=="default"&&Object.prototype.hasOwnProperty.call(u,v)&&t(c,u,v);return r(c,u),c},o=commonjsGlobal&&commonjsGlobal.__exportStar||function(u,c){for(var v in u)v!=="default"&&!Object.prototype.hasOwnProperty.call(c,v)&&t(c,u,v)};Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.KeystoneSDK=e.QRHardwareCallVersion=e.DerivationAlgorithm=e.Curve=void 0;const n=s(utils$o);e.utils=n;const a=sdk;Object.defineProperty(e,"KeystoneSDK",{enumerable:!0,get:function(){return a.KeystoneSDK}}),o(dist$s,e),o(types$6,e),o(chains,e);var l=hardwareCall;Object.defineProperty(e,"Curve",{enumerable:!0,get:function(){return l.Curve}}),Object.defineProperty(e,"DerivationAlgorithm",{enumerable:!0,get:function(){return l.DerivationAlgorithm}});var p=requireDist$c();Object.defineProperty(e,"QRHardwareCallVersion",{enumerable:!0,get:function(){return p.QRHardwareCallVersion}}),e.default=a.KeystoneSDK})(dist$v);function number(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function isBytes$1(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function bytes(e,...t){if(!isBytes$1(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 hash(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number(e.outputLen),number(e.blockLen)}function exists(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 output(e,t){bytes(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,rotl=(e,t)=>e<<t|e>>>32-t>>>0;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const hexes=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(e){bytes(e);let t="";for(let r=0;r<e.length;r++)t+=hexes[e[r]];return t}const asciis={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function asciiToBase16(e){if(e>=asciis._0&&e<=asciis._9)return e-asciis._0;if(e>=asciis._A&&e<=asciis._F)return e-(asciis._A-10);if(e>=asciis._a&&e<=asciis._f)return e-(asciis._a-10)}function hexToBytes(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let o=0,n=0;o<r;o++,n+=2){const a=asciiToBase16(e.charCodeAt(n)),l=asciiToBase16(e.charCodeAt(n+1));if(a===void 0||l===void 0){const p=e[n]+e[n+1];throw new Error('hex string expected, got non-hex character "'+p+'" at index '+n)}s[o]=a*16+l}return s}function utf8ToBytes(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function toBytes(e){return typeof e=="string"&&(e=utf8ToBytes(e)),bytes(e),e}function concatBytes(...e){let t=0;for(let s=0;s<e.length;s++){const o=e[s];bytes(o),t+=o.length}const r=new Uint8Array(t);for(let s=0,o=0;s<e.length;s++){const n=e[s];r.set(n,o),o+=n.length}return r}class Hash{clone(){return this._cloneInto()}}function wrapConstructor(e){const t=s=>e().update(toBytes(s)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}class HMAC extends Hash{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,hash(t);const s=toBytes(r);if(this.iHash=t.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 o=this.blockLen,n=new Uint8Array(o);n.set(s.length>o?t.create().update(s).digest():s);for(let a=0;a<n.length;a++)n[a]^=54;this.iHash.update(n),this.oHash=t.create();for(let a=0;a<n.length;a++)n[a]^=106;this.oHash.update(n),n.fill(0)}update(t){return exists(this),this.iHash.update(t),this}digestInto(t){exists(this),bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:s,finished:o,destroyed:n,blockLen:a,outputLen:l}=this;return t=t,t.finished=o,t.destroyed=n,t.blockLen=a,t.outputLen=l,t.oHash=r._cloneInto(t.oHash),t.iHash=s._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(e,t,r)=>new HMAC(e,t).update(r).digest();hmac.create=(e,t)=>new HMAC(e,t);function setBigUint64(e,t,r,s){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,s);const o=BigInt(32),n=BigInt(4294967295),a=Number(r>>o&n),l=Number(r&n),p=s?4:0,u=s?0:4;e.setUint32(t+p,a,s),e.setUint32(t+u,l,s)}const Chi=(e,t,r)=>e&t^~e&r,Maj=(e,t,r)=>e&t^e&r^t&r;class HashMD extends Hash{constructor(t,r,s,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=s,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=createView(this.buffer)}update(t){exists(this);const{view:r,buffer:s,blockLen:o}=this;t=toBytes(t);const n=t.length;for(let a=0;a<n;){const l=Math.min(o-this.pos,n-a);if(l===o){const p=createView(t);for(;o<=n-a;a+=o)this.process(p,a);continue}s.set(t.subarray(a,a+l),this.pos),this.pos+=l,a+=l,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){exists(this),output(t,this),this.finished=!0;const{buffer:r,view:s,blockLen:o,isLE:n}=this;let{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(s,0),a=0);for(let v=a;v<o;v++)r[v]=0;setBigUint64(s,o-8,BigInt(this.length*8),n),this.process(s,0);const l=createView(t),p=this.outputLen;if(p%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=p/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let v=0;v<u;v++)l.setUint32(4*v,c[v],n)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const s=t.slice(0,r);return this.destroy(),s}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:s,length:o,finished:n,destroyed:a,pos:l}=this;return t.length=o,t.pos=l,t.finished=n,t.destroyed=a,o%r&&t.buffer.set(s),t}}const Rho$1=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id$1=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Pi$1=Id$1.map(e=>(9*e+5)%16);let idxL$1=[Id$1],idxR$1=[Pi$1];for(let e=0;e<4;e++)for(let t of[idxL$1,idxR$1])t.push(t[e].map(r=>Rho$1[r]));const shifts$1=[[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)),shiftsL$1=idxL$1.map((e,t)=>e.map(r=>shifts$1[t][r])),shiftsR$1=idxR$1.map((e,t)=>e.map(r=>shifts$1[t][r])),Kl$1=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr$1=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function f$1(e,t,r,s){return e===0?t^r^s:e===1?t&r|~t&s:e===2?(t|~r)^s:e===3?t&s|r&~s:t^(r|~s)}const R_BUF$1=new Uint32Array(16);let RIPEMD160$1=class extends HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:s,h3:o,h4:n}=this;return[t,r,s,o,n]}set(t,r,s,o,n){this.h0=t|0,this.h1=r|0,this.h2=s|0,this.h3=o|0,this.h4=n|0}process(t,r){for(let b=0;b<16;b++,r+=4)R_BUF$1[b]=t.getUint32(r,!0);let s=this.h0|0,o=s,n=this.h1|0,a=n,l=this.h2|0,p=l,u=this.h3|0,c=u,v=this.h4|0,w=v;for(let b=0;b<5;b++){const E=4-b,I=Kl$1[b],x=Kr$1[b],B=idxL$1[b],M=idxR$1[b],q=shiftsL$1[b],U=shiftsR$1[b];for(let F=0;F<16;F++){const j=rotl(s+f$1(b,n,l,u)+R_BUF$1[B[F]]+I,q[F])+v|0;s=v,v=u,u=rotl(l,10)|0,l=n,n=j}for(let F=0;F<16;F++){const j=rotl(o+f$1(E,a,p,c)+R_BUF$1[M[F]]+x,U[F])+w|0;o=w,w=c,c=rotl(p,10)|0,p=a,a=j}}this.set(this.h1+l+c|0,this.h2+u+w|0,this.h3+v+o|0,this.h4+s+a|0,this.h0+n+p|0)}roundClean(){R_BUF$1.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const ripemd160$1=wrapConstructor(()=>new RIPEMD160$1),SHA256_K=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]),SHA256_IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);class SHA256 extends HashMD{constructor(){super(64,32,8,!1),this.A=SHA256_IV[0]|0,this.B=SHA256_IV[1]|0,this.C=SHA256_IV[2]|0,this.D=SHA256_IV[3]|0,this.E=SHA256_IV[4]|0,this.F=SHA256_IV[5]|0,this.G=SHA256_IV[6]|0,this.H=SHA256_IV[7]|0}get(){const{A:t,B:r,C:s,D:o,E:n,F:a,G:l,H:p}=this;return[t,r,s,o,n,a,l,p]}set(t,r,s,o,n,a,l,p){this.A=t|0,this.B=r|0,this.C=s|0,this.D=o|0,this.E=n|0,this.F=a|0,this.G=l|0,this.H=p|0}process(t,r){for(let v=0;v<16;v++,r+=4)SHA256_W[v]=t.getUint32(r,!1);for(let v=16;v<64;v++){const w=SHA256_W[v-15],b=SHA256_W[v-2],E=rotr(w,7)^rotr(w,18)^w>>>3,I=rotr(b,17)^rotr(b,19)^b>>>10;SHA256_W[v]=I+SHA256_W[v-7]+E+SHA256_W[v-16]|0}let{A:s,B:o,C:n,D:a,E:l,F:p,G:u,H:c}=this;for(let v=0;v<64;v++){const w=rotr(l,6)^rotr(l,11)^rotr(l,25),b=c+w+Chi(l,p,u)+SHA256_K[v]+SHA256_W[v]|0,I=(rotr(s,2)^rotr(s,13)^rotr(s,22))+Maj(s,o,n)|0;c=u,u=p,p=l,l=a+b|0,a=n,n=o,o=s,s=b+I|0}s=s+this.A|0,o=o+this.B|0,n=n+this.C|0,a=a+this.D|0,l=l+this.E|0,p=p+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(s,o,n,a,l,p,u,c)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256=wrapConstructor(()=>new SHA256),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(e,t=!1){return t?{h:Number(e&U32_MASK64),l:Number(e>>_32n&U32_MASK64)}:{h:Number(e>>_32n&U32_MASK64)|0,l:Number(e&U32_MASK64)|0}}function split(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:n,l:a}=fromBig(e[o],t);[r[o],s[o]]=[n,a]}return[r,s]}const toBig=(e,t)=>BigInt(e>>>0)<<_32n|BigInt(t>>>0),shrSH=(e,t,r)=>e>>>r,shrSL=(e,t,r)=>e<<32-r|t>>>r,rotrSH=(e,t,r)=>e>>>r|t<<32-r,rotrSL=(e,t,r)=>e<<32-r|t>>>r,rotrBH=(e,t,r)=>e<<64-r|t>>>r-32,rotrBL=(e,t,r)=>e>>>r-32|t<<64-r,rotr32H=(e,t)=>t,rotr32L=(e,t)=>e,rotlSH=(e,t,r)=>e<<r|t>>>32-r,rotlSL=(e,t,r)=>t<<r|e>>>32-r,rotlBH=(e,t,r)=>t<<r-32|e>>>64-r,rotlBL=(e,t,r)=>e<<r-32|t>>>64-r;function add(e,t,r,s){const o=(t>>>0)+(s>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}const add3L=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H=(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L=(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H=(e,t,r,s,o)=>t+r+s+o+(e/2**32|0)|0,add5L=(e,t,r,s,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(o>>>0),add5H=(e,t,r,s,o,n)=>t+r+s+o+n+(e/2**32|0)|0,u64={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},[SHA512_Kh,SHA512_Kl]=u64.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:r,Bh:s,Bl:o,Ch:n,Cl:a,Dh:l,Dl:p,Eh:u,El:c,Fh:v,Fl:w,Gh:b,Gl:E,Hh:I,Hl:x}=this;return[t,r,s,o,n,a,l,p,u,c,v,w,b,E,I,x]}set(t,r,s,o,n,a,l,p,u,c,v,w,b,E,I,x){this.Ah=t|0,this.Al=r|0,this.Bh=s|0,this.Bl=o|0,this.Ch=n|0,this.Cl=a|0,this.Dh=l|0,this.Dl=p|0,this.Eh=u|0,this.El=c|0,this.Fh=v|0,this.Fl=w|0,this.Gh=b|0,this.Gl=E|0,this.Hh=I|0,this.Hl=x|0}process(t,r){for(let q=0;q<16;q++,r+=4)SHA512_W_H[q]=t.getUint32(r),SHA512_W_L[q]=t.getUint32(r+=4);for(let q=16;q<80;q++){const U=SHA512_W_H[q-15]|0,F=SHA512_W_L[q-15]|0,j=u64.rotrSH(U,F,1)^u64.rotrSH(U,F,8)^u64.shrSH(U,F,7),y=u64.rotrSL(U,F,1)^u64.rotrSL(U,F,8)^u64.shrSL(U,F,7),T=SHA512_W_H[q-2]|0,D=SHA512_W_L[q-2]|0,L=u64.rotrSH(T,D,19)^u64.rotrBH(T,D,61)^u64.shrSH(T,D,6),C=u64.rotrSL(T,D,19)^u64.rotrBL(T,D,61)^u64.shrSL(T,D,6),d=u64.add4L(y,C,SHA512_W_L[q-7],SHA512_W_L[q-16]),_=u64.add4H(d,j,L,SHA512_W_H[q-7],SHA512_W_H[q-16]);SHA512_W_H[q]=_|0,SHA512_W_L[q]=d|0}let{Ah:s,Al:o,Bh:n,Bl:a,Ch:l,Cl:p,Dh:u,Dl:c,Eh:v,El:w,Fh:b,Fl:E,Gh:I,Gl:x,Hh:B,Hl:M}=this;for(let q=0;q<80;q++){const U=u64.rotrSH(v,w,14)^u64.rotrSH(v,w,18)^u64.rotrBH(v,w,41),F=u64.rotrSL(v,w,14)^u64.rotrSL(v,w,18)^u64.rotrBL(v,w,41),j=v&b^~v&I,y=w&E^~w&x,T=u64.add5L(M,F,y,SHA512_Kl[q],SHA512_W_L[q]),D=u64.add5H(T,B,U,j,SHA512_Kh[q],SHA512_W_H[q]),L=T|0,C=u64.rotrSH(s,o,28)^u64.rotrBH(s,o,34)^u64.rotrBH(s,o,39),d=u64.rotrSL(s,o,28)^u64.rotrBL(s,o,34)^u64.rotrBL(s,o,39),_=s&n^s&l^n&l,$=o&a^o&p^a&p;B=I|0,M=x|0,I=b|0,x=E|0,b=v|0,E=w|0,{h:v,l:w}=u64.add(u|0,c|0,D|0,L|0),u=l|0,c=p|0,l=n|0,p=a|0,n=s|0,a=o|0;const S=u64.add3L(L,d,$);s=u64.add3H(S,D,C,_),o=S|0}({h:s,l:o}=u64.add(this.Ah|0,this.Al|0,s|0,o|0)),{h:n,l:a}=u64.add(this.Bh|0,this.Bl|0,n|0,a|0),{h:l,l:p}=u64.add(this.Ch|0,this.Cl|0,l|0,p|0),{h:u,l:c}=u64.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:v,l:w}=u64.add(this.Eh|0,this.El|0,v|0,w|0),{h:b,l:E}=u64.add(this.Fh|0,this.Fl|0,b|0,E|0),{h:I,l:x}=u64.add(this.Gh|0,this.Gl|0,I|0,x|0),{h:B,l:M}=u64.add(this.Hh|0,this.Hl|0,B|0,M|0),this.set(s,o,n,a,l,p,u,c,v,w,b,E,I,x,B,M)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512=wrapConstructor(()=>new SHA512);function isBytes(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function chain(...e){const t=n=>n,r=(n,a)=>l=>n(a(l)),s=e.map(n=>n.encode).reduceRight(r,t),o=e.map(n=>n.decode).reduce(r,t);return{encode:s,decode:o}}function alphabet(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(r=>{if(r<0||r>=e.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${e.length})`);return e[r]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(r=>{if(typeof r!="string")throw new Error(`alphabet.decode: not string element=${r}`);const s=e.indexOf(r);if(s===-1)throw new Error(`Unknown letter: "${r}". Allowed: ${e}`);return s})}}}function join(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let r of t)if(typeof r!="string")throw new Error(`join.encode: non-string input=${r}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function convertRadix(e,t,r){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let s=0;const o=[],n=Array.from(e);for(n.forEach(a=>{if(a<0||a>=t)throw new Error(`Wrong integer: ${a}`)});;){let a=0,l=!0;for(let p=s;p<n.length;p++){const u=n[p],c=t*a+u;if(!Number.isSafeInteger(c)||t*a/t!==a||c-u!==t*a)throw new Error("convertRadix: carry overflow");a=c%r;const v=Math.floor(c/r);if(n[p]=v,!Number.isSafeInteger(v)||v*r+a!==c)throw new Error("convertRadix: carry overflow");if(l)v?l=!1:s=p;else continue}if(o.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)o.push(0);return o.reverse()}function radix(e){return{encode:t=>{if(!isBytes(t))throw new Error("radix.encode input should be Uint8Array");return convertRadix(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(convertRadix(t,e,2**8))}}}function checksum(e,t){if(typeof t!="function")throw new Error("checksum fn should be function");return{encode(r){if(!isBytes(r))throw new Error("checksum.encode: input should be Uint8Array");const s=t(r).slice(0,e),o=new Uint8Array(r.length+e);return o.set(r),o.set(s,r.length),o},decode(r){if(!isBytes(r))throw new Error("checksum.decode: input should be Uint8Array");const s=r.slice(0,-e),o=t(s).slice(0,e),n=r.slice(-e);for(let a=0;a<e;a++)if(o[a]!==n[a])throw new Error("Invalid checksum");return s}}}const genBase58=e=>chain(radix(58),alphabet(e),join("")),base58=genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),createBase58check=e=>chain(checksum(4,t=>e(e(t))),base58);const Point=secp256k1.ProjectivePoint,base58check=createBase58check(sha256);function bytesToNumber(e){return BigInt(`0x${bytesToHex(e)}`)}function numberToBytes(e){return hexToBytes(e.toString(16).padStart(64,"0"))}const MASTER_SECRET=utf8ToBytes("Bitcoin seed"),BITCOIN_VERSIONS={private:76066276,public:76067358},HARDENED_OFFSET=2147483648,hash160=e=>ripemd160$1(sha256(e)),fromU32=e=>createView(e).getUint32(0,!1),toU32=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return createView(t).setUint32(0,e,!1),t};class HDKey{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return fromU32(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const t=this.privateKey;if(!t)throw new Error("No private key");return base58check.encode(this.serialize(this.versions.private,concatBytes(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return base58check.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,r=BITCOIN_VERSIONS){if(bytes(t),8*t.length<128||8*t.length>512)throw new Error(`HDKey: wrong seed length=${t.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const s=hmac(sha512,MASTER_SECRET,t);return new HDKey({versions:r,chainCode:s.slice(32),privateKey:s.slice(0,32)})}static fromExtendedKey(t,r=BITCOIN_VERSIONS){const s=base58check.decode(t),o=createView(s),n=o.getUint32(0,!1),a={versions:r,depth:s[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:s.slice(13,45)},l=s.slice(45),p=l[0]===0;if(n!==r[p?"private":"public"])throw new Error("Version mismatch");return p?new HDKey({...a,privateKey:l.slice(1)}):new HDKey({...a,publicKey:l})}static fromJSON(t){return HDKey.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||BITCOIN_VERSIONS,this.depth=t.depth||0,this.chainCode=t.chainCode||null,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!secp256k1.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:bytesToNumber(t.privateKey),this.privKeyBytes=numberToBytes(this.privKey),this.pubKey=secp256k1.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=Point.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=hash160(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;const r=t.replace(/^[mM]'?\//,"").split("/");let s=this;for(const o of r){const n=/^(\d+)('?)$/.exec(o),a=n&&n[1];if(!n||n.length!==3||typeof a!="string")throw new Error(`Invalid child index: ${o}`);let l=+a;if(!Number.isSafeInteger(l)||l>=HARDENED_OFFSET)throw new Error("Invalid index");n[2]==="'"&&(l+=HARDENED_OFFSET),s=s.deriveChild(l)}return s}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let r=toU32(t);if(t>=HARDENED_OFFSET){const l=this.privateKey;if(!l)throw new Error("Could not derive hardened child key");r=concatBytes(new Uint8Array([0]),l,r)}else r=concatBytes(this.pubKey,r);const s=hmac(sha512,this.chainCode,r),o=bytesToNumber(s.slice(0,32)),n=s.slice(32);if(!secp256k1.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");const a={versions:this.versions,chainCode:n,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){const l=mod(this.privKey+o,secp256k1.CURVE.n);if(!secp256k1.utils.isValidPrivateKey(l))throw new Error("The tweak was out of range or the resulted private key is invalid");a.privateKey=l}else{const l=Point.fromHex(this.pubKey).add(Point.fromPrivateKey(o));if(l.equals(Point.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");a.publicKey=l.toRawBytes(!0)}return new HDKey(a)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return bytes(t,32),secp256k1.sign(t,this.privKey).toCompactRawBytes()}verify(t,r){if(bytes(t,32),bytes(r,64),!this.publicKey)throw new Error("No publicKey set!");let s;try{s=secp256k1.Signature.fromCompact(r)}catch{return!1}return secp256k1.verify(s,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,r){if(!this.chainCode)throw new Error("No chainCode set");return bytes(r,33),concatBytes(toU32(t),new Uint8Array([this.depth]),toU32(this.parentFingerprint),toU32(this.index),this.chainCode,r)}}var bip341={},ecc_lib={};Object.defineProperty(ecc_lib,"__esModule",{value:!0});ecc_lib.getEccLib=ecc_lib.initEccLib=void 0;const _ECCLIB_CACHE={};function initEccLib(e){e?e!==_ECCLIB_CACHE.eccLib&&(verifyEcc(e),_ECCLIB_CACHE.eccLib=e):_ECCLIB_CACHE.eccLib=e}ecc_lib.initEccLib=initEccLib;function getEccLib(){if(!_ECCLIB_CACHE.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return _ECCLIB_CACHE.eccLib}ecc_lib.getEccLib=getEccLib;const h=e=>Buffer$e.from(e,"hex");function verifyEcc(e){assert(typeof e.isXOnlyPoint=="function"),assert(e.isXOnlyPoint(h("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),assert(e.isXOnlyPoint(h("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),assert(e.isXOnlyPoint(h("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),assert(e.isXOnlyPoint(h("0000000000000000000000000000000000000000000000000000000000000001"))),assert(!e.isXOnlyPoint(h("0000000000000000000000000000000000000000000000000000000000000000"))),assert(!e.isXOnlyPoint(h("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),assert(typeof e.xOnlyPointAddTweak=="function"),tweakAddVectors.forEach(t=>{const r=e.xOnlyPointAddTweak(h(t.pubkey),h(t.tweak));t.result===null?assert(r===null):(assert(r!==null),assert(r.parity===t.parity),assert(Buffer$e.from(r.xOnlyPubkey).equals(h(t.result))))})}function assert(e){if(!e)throw new Error("ecc library invalid")}const tweakAddVectors=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}];var crypto$1={},ripemd160={};Object.defineProperty(ripemd160,"__esModule",{value:!0});ripemd160.ripemd160=ripemd160.RIPEMD160=void 0;const _md_js_1$1=_md,utils_js_1$1=utils$b,Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Pi=Id.map(e=>(9*e+5)%16);let idxL=[Id],idxR=[Pi];for(let e=0;e<4;e++)for(let t of[idxL,idxR])t.push(t[e].map(r=>Rho[r]));const shifts=[[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)),shiftsL=idxL.map((e,t)=>e.map(r=>shifts[t][r])),shiftsR=idxR.map((e,t)=>e.map(r=>shifts[t][r])),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function f(e,t,r,s){return e===0?t^r^s:e===1?t&r|~t&s:e===2?(t|~r)^s:e===3?t&s|r&~s:t^(r|~s)}const R_BUF=new Uint32Array(16);class RIPEMD160 extends _md_js_1$1.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:s,h3:o,h4:n}=this;return[t,r,s,o,n]}set(t,r,s,o,n){this.h0=t|0,this.h1=r|0,this.h2=s|0,this.h3=o|0,this.h4=n|0}process(t,r){for(let b=0;b<16;b++,r+=4)R_BUF[b]=t.getUint32(r,!0);let s=this.h0|0,o=s,n=this.h1|0,a=n,l=this.h2|0,p=l,u=this.h3|0,c=u,v=this.h4|0,w=v;for(let b=0;b<5;b++){const E=4-b,I=Kl[b],x=Kr[b],B=idxL[b],M=idxR[b],q=shiftsL[b],U=shiftsR[b];for(let F=0;F<16;F++){const j=(0,utils_js_1$1.rotl)(s+f(b,n,l,u)+R_BUF[B[F]]+I,q[F])+v|0;s=v,v=u,u=(0,utils_js_1$1.rotl)(l,10)|0,l=n,n=j}for(let F=0;F<16;F++){const j=(0,utils_js_1$1.rotl)(o+f(E,a,p,c)+R_BUF[M[F]]+x,U[F])+w|0;o=w,w=c,c=(0,utils_js_1$1.rotl)(p,10)|0,p=a,a=j}}this.set(this.h1+l+c|0,this.h2+u+w|0,this.h3+v+o|0,this.h4+s+a|0,this.h0+n+p|0)}roundClean(){R_BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}ripemd160.RIPEMD160=RIPEMD160;ripemd160.ripemd160=(0,utils_js_1$1.wrapConstructor)(()=>new RIPEMD160);var sha1={};Object.defineProperty(sha1,"__esModule",{value:!0});sha1.sha1=sha1.SHA1=void 0;const _md_js_1=_md,utils_js_1=utils$b,SHA1_IV=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),SHA1_W=new Uint32Array(80);class SHA1 extends _md_js_1.HashMD{constructor(){super(64,20,8,!1),this.A=SHA1_IV[0]|0,this.B=SHA1_IV[1]|0,this.C=SHA1_IV[2]|0,this.D=SHA1_IV[3]|0,this.E=SHA1_IV[4]|0}get(){const{A:t,B:r,C:s,D:o,E:n}=this;return[t,r,s,o,n]}set(t,r,s,o,n){this.A=t|0,this.B=r|0,this.C=s|0,this.D=o|0,this.E=n|0}process(t,r){for(let p=0;p<16;p++,r+=4)SHA1_W[p]=t.getUint32(r,!1);for(let p=16;p<80;p++)SHA1_W[p]=(0,utils_js_1.rotl)(SHA1_W[p-3]^SHA1_W[p-8]^SHA1_W[p-14]^SHA1_W[p-16],1);let{A:s,B:o,C:n,D:a,E:l}=this;for(let p=0;p<80;p++){let u,c;p<20?(u=(0,_md_js_1.Chi)(o,n,a),c=1518500249):p<40?(u=o^n^a,c=1859775393):p<60?(u=(0,_md_js_1.Maj)(o,n,a),c=2400959708):(u=o^n^a,c=3395469782);const v=(0,utils_js_1.rotl)(s,5)+u+l+c+SHA1_W[p]|0;l=a,a=n,n=(0,utils_js_1.rotl)(o,30),o=s,s=v}s=s+this.A|0,o=o+this.B|0,n=n+this.C|0,a=a+this.D|0,l=l+this.E|0,this.set(s,o,n,a,l)}roundClean(){SHA1_W.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}sha1.SHA1=SHA1;sha1.sha1=(0,utils_js_1.wrapConstructor)(()=>new SHA1);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const t=ripemd160,r=sha1,s=sha256$2;function o(c){return Buffer$e.from((0,t.ripemd160)(Uint8Array.from(c)))}e.ripemd160=o;function n(c){return Buffer$e.from((0,r.sha1)(Uint8Array.from(c)))}e.sha1=n;function a(c){return Buffer$e.from((0,s.sha256)(Uint8Array.from(c)))}e.sha256=a;function l(c){return Buffer$e.from((0,t.ripemd160)((0,s.sha256)(Uint8Array.from(c))))}e.hash160=l;function p(c){return Buffer$e.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(c))))}e.hash256=p,e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":Buffer$e.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":Buffer$e.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":Buffer$e.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:Buffer$e.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:Buffer$e.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:Buffer$e.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:Buffer$e.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":Buffer$e.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":Buffer$e.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 u(c,v){return a(Buffer$e.concat([e.TAGGED_HASH_PREFIXES[c],v]))}e.taggedHash=u})(crypto$1);var bufferutils={},types$4={},types$3={Array:function(e){return e!=null&&e.constructor===Array},Boolean:function(e){return typeof e=="boolean"},Function:function(e){return typeof e=="function"},Nil:function(e){return e==null},Number:function(e){return typeof e=="number"},Object:function(e){return typeof e=="object"},String:function(e){return typeof e=="string"},"":function(){return!0}};types$3.Null=types$3.Nil;for(var typeName$1 in types$3)types$3[typeName$1].toJSON=(function(e){return e}).bind(null,typeName$1);var native$2=types$3,native$1=native$2;function getTypeName(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function getValueTypeName$1(e){return native$1.Nil(e)?"":getTypeName(e.constructor)}function getValue(e){return native$1.Function(e)?"":native$1.String(e)?JSON.stringify(e):e&&native$1.Object(e)?"":e}function captureStackTrace(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function tfJSON$1(e){return native$1.Function(e)?e.toJSON?e.toJSON():getTypeName(e):native$1.Array(e)?"Array":e&&native$1.Object(e)?"Object":e!==void 0?e:""}function tfErrorString(e,t,r){var s=getValue(t);return"Expected "+tfJSON$1(e)+", got"+(r!==""?" "+r:"")+(s!==""?" "+s:"")}function TfTypeError$1(e,t,r){r=r||getValueTypeName$1(t),this.message=tfErrorString(e,t,r),captureStackTrace(this,TfTypeError$1),this.__type=e,this.__value=t,this.__valueTypeName=r}TfTypeError$1.prototype=Object.create(Error.prototype);TfTypeError$1.prototype.constructor=TfTypeError$1;function tfPropertyErrorString(e,t,r,s,o){var n='" of type ';return t==="key"&&(n='" with key type '),tfErrorString('property "'+tfJSON$1(r)+n+tfJSON$1(e),s,o)}function TfPropertyTypeError$1(e,t,r,s,o){e?(o=o||getValueTypeName$1(s),this.message=tfPropertyErrorString(e,r,t,s,o)):this.message='Unexpected property "'+t+'"',captureStackTrace(this,TfTypeError$1),this.__label=r,this.__property=t,this.__type=e,this.__value=s,this.__valueTypeName=o}TfPropertyTypeError$1.prototype=Object.create(Error.prototype);TfPropertyTypeError$1.prototype.constructor=TfTypeError$1;function tfCustomError(e,t){return new TfTypeError$1(e,{},t)}function tfSubError$1(e,t,r){return e instanceof TfPropertyTypeError$1?(t=t+"."+e.__property,e=new TfPropertyTypeError$1(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof TfTypeError$1&&(e=new TfPropertyTypeError$1(e.__type,t,r,e.__value,e.__valueTypeName)),captureStackTrace(e),e}var errors={TfTypeError:TfTypeError$1,TfPropertyTypeError:TfPropertyTypeError$1,tfCustomError,tfSubError:tfSubError$1,tfJSON:tfJSON$1,getValueTypeName:getValueTypeName$1},extra,hasRequiredExtra;function requireExtra(){if(hasRequiredExtra)return extra;hasRequiredExtra=1;var e=native$2,t=errors;function r(j){return Buffer$e.isBuffer(j)}function s(j){return typeof j=="string"&&/^([0-9a-f]{2})+$/i.test(j)}function o(j,y){var T=j.toJSON();function D(L){if(!j(L))return!1;if(L.length===y)return!0;throw t.tfCustomError(T+"(Length: "+y+")",T+"(Length: "+L.length+")")}return D.toJSON=function(){return T},D}var n=o.bind(null,e.Array),a=o.bind(null,r),l=o.bind(null,s),p=o.bind(null,e.String);function u(j,y,T){T=T||e.Number;function D(L,C){return T(L,C)&&L>j&&L<y}return D.toJSON=function(){return`${T.toJSON()} between [${j}, ${y}]`},D}var c=Math.pow(2,53)-1;function v(j){return typeof j=="number"&&isFinite(j)}function w(j){return j<<24>>24===j}function b(j){return j<<16>>16===j}function E(j){return(j|0)===j}function I(j){return typeof j=="number"&&j>=-c&&j<=c&&Math.floor(j)===j}function x(j){return(j&255)===j}function B(j){return(j&65535)===j}function M(j){return j>>>0===j}function q(j){return typeof j=="number"&&j>=0&&j<=c&&Math.floor(j)===j}var U={ArrayN:n,Buffer:r,BufferN:a,Finite:v,Hex:s,HexN:l,Int8:w,Int16:b,Int32:E,Int53:I,Range:u,StringN:p,UInt8:x,UInt16:B,UInt32:M,UInt53:q};for(var F in U)U[F].toJSON=(function(j){return j}).bind(null,F);return extra=U,extra}var ERRORS=errors,NATIVE=native$2,tfJSON=ERRORS.tfJSON,TfTypeError=ERRORS.TfTypeError,TfPropertyTypeError=ERRORS.TfPropertyTypeError,tfSubError=ERRORS.tfSubError,getValueTypeName=ERRORS.getValueTypeName,TYPES={arrayOf:function e(t,r){t=compile(t),r=r||{};function s(o,n){return!NATIVE.Array(o)||NATIVE.Nil(o)||r.minLength!==void 0&&o.length<r.minLength||r.maxLength!==void 0&&o.length>r.maxLength||r.length!==void 0&&o.length!==r.length?!1:o.every(function(a,l){try{return typeforce$3(t,a,n)}catch(p){throw tfSubError(p,l)}})}return s.toJSON=function(){var o="["+tfJSON(t)+"]";return r.length!==void 0?o+="{"+r.length+"}":(r.minLength!==void 0||r.maxLength!==void 0)&&(o+="{"+(r.minLength===void 0?0:r.minLength)+","+(r.maxLength===void 0?1/0:r.maxLength)+"}"),o},s},maybe:function e(t){t=compile(t);function r(s,o){return NATIVE.Nil(s)||t(s,o,e)}return r.toJSON=function(){return"?"+tfJSON(t)},r},map:function e(t,r){t=compile(t),r&&(r=compile(r));function s(o,n){if(!NATIVE.Object(o)||NATIVE.Nil(o))return!1;for(var a in o){try{r&&typeforce$3(r,a,n)}catch(p){throw tfSubError(p,a,"key")}try{var l=o[a];typeforce$3(t,l,n)}catch(p){throw tfSubError(p,a)}}return!0}return r?s.toJSON=function(){return"{"+tfJSON(r)+": "+tfJSON(t)+"}"}:s.toJSON=function(){return"{"+tfJSON(t)+"}"},s},object:function e(t){var r={};for(var s in t)r[s]=compile(t[s]);function o(n,a){if(!NATIVE.Object(n)||NATIVE.Nil(n))return!1;var l;try{for(l in r){var p=r[l],u=n[l];typeforce$3(p,u,a)}}catch(c){throw tfSubError(c,l)}if(a){for(l in n)if(!r[l])throw new TfPropertyTypeError(void 0,l)}return!0}return o.toJSON=function(){return tfJSON(r)},o},anyOf:function e(){var t=[].slice.call(arguments).map(compile);function r(s,o){return t.some(function(n){try{return typeforce$3(n,s,o)}catch{return!1}})}return r.toJSON=function(){return t.map(tfJSON).join("|")},r},allOf:function e(){var t=[].slice.call(arguments).map(compile);function r(s,o){return t.every(function(n){try{return typeforce$3(n,s,o)}catch{return!1}})}return r.toJSON=function(){return t.map(tfJSON).join(" & ")},r},quacksLike:function e(t){function r(s){return t===getValueTypeName(s)}return r.toJSON=function(){return t},r},tuple:function e(){var t=[].slice.call(arguments).map(compile);function r(s,o){return NATIVE.Nil(s)||NATIVE.Nil(s.length)||o&&s.length!==t.length?!1:t.every(function(n,a){try{return typeforce$3(n,s[a],o)}catch(l){throw tfSubError(l,a)}})}return r.toJSON=function(){return"("+t.map(tfJSON).join(", ")+")"},r},value:function e(t){function r(s){return s===t}return r.toJSON=function(){return t},r}};TYPES.oneOf=TYPES.anyOf;function compile(e){if(NATIVE.String(e))return e[0]==="?"?TYPES.maybe(e.slice(1)):NATIVE[e]||TYPES.quacksLike(e);if(e&&NATIVE.Object(e)){if(NATIVE.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return TYPES.arrayOf(e[0])}return TYPES.object(e)}else if(NATIVE.Function(e))return e;return TYPES.value(e)}function typeforce$3(e,t,r,s){if(NATIVE.Function(e)){if(e(t,r))return!0;throw new TfTypeError(s||e,t)}return typeforce$3(compile(e),t,r)}for(var typeName in NATIVE)typeforce$3[typeName]=NATIVE[typeName];for(typeName in TYPES)typeforce$3[typeName]=TYPES[typeName];var EXTRA=requireExtra();for(typeName in EXTRA)typeforce$3[typeName]=EXTRA[typeName];typeforce$3.compile=compile;typeforce$3.TfTypeError=TfTypeError;typeforce$3.TfPropertyTypeError=TfPropertyTypeError;var typeforce_1=typeforce$3;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const t=require$$0$3;e.typeforce=typeforce_1;const r=t.Buffer.alloc(32,0),s=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function o(b){if(!t.Buffer.isBuffer(b)||b.length<33)return!1;const E=b[0],I=b.slice(1,33);if(I.compare(r)===0||I.compare(s)>=0)return!1;if((E===2||E===3)&&b.length===33)return!0;const x=b.slice(33);return x.compare(r)===0||x.compare(s)>=0?!1:E===4&&b.length===65}e.isPoint=o;const n=Math.pow(2,31)-1;function a(b){return e.typeforce.UInt32(b)&&b<=n}e.UInt31=a;function l(b){return e.typeforce.String(b)&&!!b.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}e.BIP32Path=l,l.toJSON=()=>"BIP32 derivation path";function p(b){return(e.typeforce.Buffer(b.publicKey)||typeof b.getPublicKey=="function")&&typeof b.sign=="function"}e.Signer=p;const u=21*1e14;function c(b){return e.typeforce.UInt53(b)&&b<=u}e.Satoshi=c,e.ECPoint=e.typeforce.quacksLike("Point"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254;function v(b){return!b||!("output"in b)||!t.Buffer.isBuffer(b.output)?!1:b.version!==void 0?(b.version&e.TAPLEAF_VERSION_MASK)===b.version:!0}e.isTapleaf=v;function w(b){return(0,e.Array)(b)?b.length!==2?!1:b.every(E=>w(E)):v(b)}e.isTaptree=w,e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf})(types$4);var Buffer=safeBufferExports.Buffer,MAX_SAFE_INTEGER$1=9007199254740991;function checkUInt53$1(e){if(e<0||e>MAX_SAFE_INTEGER$1||e%1!==0)throw new RangeError("value out of range")}function encode$5(e,t,r){if(checkUInt53$1(e),t||(t=Buffer.allocUnsafe(encodingLength$2(e))),!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),e<253?(t.writeUInt8(e,r),encode$5.bytes=1):e<=65535?(t.writeUInt8(253,r),t.writeUInt16LE(e,r+1),encode$5.bytes=3):e<=4294967295?(t.writeUInt8(254,r),t.writeUInt32LE(e,r+1),encode$5.bytes=5):(t.writeUInt8(255,r),t.writeUInt32LE(e>>>0,r+1),t.writeUInt32LE(e/4294967296|0,r+5),encode$5.bytes=9),t}function decode$5(e,t){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");t||(t=0);var r=e.readUInt8(t);if(r<253)return decode$5.bytes=1,r;if(r===253)return decode$5.bytes=3,e.readUInt16LE(t+1);if(r===254)return decode$5.bytes=5,e.readUInt32LE(t+1);decode$5.bytes=9;var s=e.readUInt32LE(t+1),o=e.readUInt32LE(t+5),n=o*4294967296+s;return checkUInt53$1(n),n}function encodingLength$2(e){return checkUInt53$1(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var varuintBitcoin={encode:encode$5,decode:decode$5,encodingLength:encodingLength$2};Object.defineProperty(bufferutils,"__esModule",{value:!0});bufferutils.BufferReader=bufferutils.BufferWriter=bufferutils.cloneBuffer=bufferutils.reverseBuffer=bufferutils.writeUInt64LE=bufferutils.readUInt64LE=bufferutils.varuint=void 0;const types$2=types$4,{typeforce:typeforce$2}=types$2,varuint$1=varuintBitcoin;bufferutils.varuint=varuint$1;function verifuint(e,t){if(typeof e!="number")throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function readUInt64LE(e,t){const r=e.readUInt32LE(t);let s=e.readUInt32LE(t+4);return s*=4294967296,verifuint(s+r,9007199254740991),s+r}bufferutils.readUInt64LE=readUInt64LE;function writeUInt64LE(e,t,r){return verifuint(t,9007199254740991),e.writeInt32LE(t&-1,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}bufferutils.writeUInt64LE=writeUInt64LE;function reverseBuffer(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let s=0;s<e.length/2;s++)r=e[s],e[s]=e[t],e[t]=r,t--;return e}bufferutils.reverseBuffer=reverseBuffer;function cloneBuffer(e){const t=Buffer$e.allocUnsafe(e.length);return e.copy(t),t}bufferutils.cloneBuffer=cloneBuffer;class BufferWriter{static withCapacity(t){return new BufferWriter(Buffer$e.alloc(t))}constructor(t,r=0){this.buffer=t,this.offset=r,typeforce$2(types$2.tuple(types$2.Buffer,types$2.UInt32),[t,r])}writeUInt8(t){this.offset=this.buffer.writeUInt8(t,this.offset)}writeInt32(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}writeUInt32(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}writeUInt64(t){this.offset=writeUInt64LE(this.buffer,t,this.offset)}writeVarInt(t){varuint$1.encode(t,this.buffer,this.offset),this.offset+=varuint$1.encode.bytes}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}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}`)}}bufferutils.BufferWriter=BufferWriter;class BufferReader{constructor(t,r=0){this.buffer=t,this.offset=r,typeforce$2(types$2.tuple(types$2.Buffer,types$2.UInt32),[t,r])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=readUInt64LE(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=varuint$1.decode(this.buffer,this.offset);return this.offset+=varuint$1.decode.bytes,t}readSlice(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");const r=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,r}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),r=[];for(let s=0;s<t;s++)r.push(this.readVarSlice());return r}}bufferutils.BufferReader=BufferReader;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const t=require$$0$3,r=ecc_lib,s=crypto$1,o=bufferutils,n=types$4;e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;const a=I=>"left"in I&&"right"in I;function l(I,x){if(I.length<33)throw new TypeError(`The control-block length is too small. Got ${I.length}, expected min 33.`);const B=(I.length-33)/32;let M=x;for(let q=0;q<B;q++){const U=I.slice(33+32*q,65+32*q);M.compare(U)<0?M=b(M,U):M=b(U,M)}return M}e.rootHashFromPath=l;function p(I){if((0,n.isTapleaf)(I))return{hash:c(I)};const x=[p(I[0]),p(I[1])];x.sort((q,U)=>q.hash.compare(U.hash));const[B,M]=x;return{hash:b(B.hash,M.hash),left:B,right:M}}e.toHashTree=p;function u(I,x){if(a(I)){const B=u(I.left,x);if(B!==void 0)return[...B,I.right.hash];const M=u(I.right,x);if(M!==void 0)return[...M,I.left.hash]}else if(I.hash.equals(x))return[]}e.findScriptPath=u;function c(I){const x=I.version||e.LEAF_VERSION_TAPSCRIPT;return s.taggedHash("TapLeaf",t.Buffer.concat([t.Buffer.from([x]),E(I.output)]))}e.tapleafHash=c;function v(I,x){return s.taggedHash("TapTweak",t.Buffer.concat(x?[I,x]:[I]))}e.tapTweakHash=v;function w(I,x){if(!t.Buffer.isBuffer(I)||I.length!==32||x&&x.length!==32)return null;const B=v(I,x),M=(0,r.getEccLib)().xOnlyPointAddTweak(I,B);return!M||M.xOnlyPubkey===null?null:{parity:M.parity,x:t.Buffer.from(M.xOnlyPubkey)}}e.tweakKey=w;function b(I,x){return s.taggedHash("TapBranch",t.Buffer.concat([I,x]))}function E(I){const x=o.varuint.encodingLength(I.length),B=t.Buffer.allocUnsafe(x);return o.varuint.encode(I.length,B),t.Buffer.concat([B,I])}})(bip341);var bip371={},transaction={},script={},bip66$1={};Object.defineProperty(bip66$1,"__esModule",{value:!0});bip66$1.encode=bip66$1.decode=bip66$1.check=void 0;function check(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))}bip66$1.check=check;function decode$4(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)}}bip66$1.decode=decode$4;function encode$4(e,t){const r=e.length,s=t.length;if(r===0)throw new Error("R length is zero");if(s===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(s>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(s>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const o=Buffer$e.allocUnsafe(6+r+s);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}bip66$1.encode=encode$4;var ops={};Object.defineProperty(ops,"__esModule",{value:!0});ops.REVERSE_OPS=ops.OPS=void 0;const OPS$8={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};ops.OPS=OPS$8;const REVERSE_OPS={};ops.REVERSE_OPS=REVERSE_OPS;for(const e of Object.keys(OPS$8)){const t=OPS$8[e];REVERSE_OPS[t]=e}var push_data={};Object.defineProperty(push_data,"__esModule",{value:!0});push_data.decode=push_data.encode=push_data.encodingLength=void 0;const ops_1=ops;function encodingLength$1(e){return e<ops_1.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}push_data.encodingLength=encodingLength$1;function encode$3(e,t,r){const s=encodingLength$1(t);return s===1?e.writeUInt8(t,r):s===2?(e.writeUInt8(ops_1.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):s===3?(e.writeUInt8(ops_1.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(ops_1.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),s}push_data.encode=encode$3;function decode$3(e,t){const r=e.readUInt8(t);let s,o;if(r<ops_1.OPS.OP_PUSHDATA1)s=r,o=1;else if(r===ops_1.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;s=e.readUInt8(t+1),o=2}else if(r===ops_1.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;s=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(r!==ops_1.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");s=e.readUInt32LE(t+1),o=5}return{opcode:r,number:s,size:o}}push_data.decode=decode$3;var script_number={};Object.defineProperty(script_number,"__esModule",{value:!0});script_number.encode=script_number.decode=void 0;function decode$2(e,t,r){t=t||4,r=r===void 0?!0:r;const s=e.length;if(s===0)return 0;if(s>t)throw new TypeError("Script number overflow");if(r&&!(e[s-1]&127)&&(s<=1||!(e[s-2]&128)))throw new Error("Non-minimally encoded script number");if(s===5){const n=e.readUInt32LE(0),a=e.readUInt8(4);return a&128?-((a&-129)*4294967296+n):a*4294967296+n}let o=0;for(let n=0;n<s;++n)o|=e[n]<<8*n;return e[s-1]&128?-(o&~(128<<8*(s-1))):o}script_number.decode=decode$2;function scriptNumSize(e){return e>2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}function encode$2(e){let t=Math.abs(e);const r=scriptNumSize(t),s=Buffer$e.allocUnsafe(r),o=e<0;for(let n=0;n<r;++n)s.writeUInt8(t&255,n),t>>=8;return s[r-1]&128?s.writeUInt8(o?128:0,r-1):o&&(s[r-1]|=128),s}script_number.encode=encode$2;var script_signature={};Object.defineProperty(script_signature,"__esModule",{value:!0});script_signature.encode=script_signature.decode=void 0;const bip66=bip66$1,types$1=types$4,{typeforce:typeforce$1}=types$1,ZERO$1=Buffer$e.alloc(1,0);function toDER(e){let t=0;for(;e[t]===0;)++t;return t===e.length?ZERO$1:(e=e.slice(t),e[0]&128?Buffer$e.concat([ZERO$1,e],1+e.length):e)}function fromDER(e){e[0]===0&&(e=e.slice(1));const t=Buffer$e.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}function decode$1(e){const t=e.readUInt8(e.length-1),r=t&-129;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);const s=bip66.decode(e.slice(0,-1)),o=fromDER(s.r),n=fromDER(s.s);return{signature:Buffer$e.concat([o,n],64),hashType:t}}script_signature.decode=decode$1;function encode$1(e,t){typeforce$1({signature:types$1.BufferN(64),hashType:types$1.UInt8},{signature:e,hashType:t});const r=t&-129;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);const s=Buffer$e.allocUnsafe(1);s.writeUInt8(t,0);const o=toDER(e.slice(0,32)),n=toDER(e.slice(32,64));return Buffer$e.concat([bip66.encode(o,n),s])}script_signature.encode=encode$1;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const t=bip66$1,r=ops;Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return r.OPS}});const s=push_data,o=script_number,n=script_signature,a=types$4,{typeforce:l}=a,p=r.OPS.OP_RESERVED;function u(D){return a.Number(D)&&(D===r.OPS.OP_0||D>=r.OPS.OP_1&&D<=r.OPS.OP_16||D===r.OPS.OP_1NEGATE)}function c(D){return a.Buffer(D)||u(D)}function v(D){return a.Array(D)&&D.every(c)}e.isPushOnly=v;function w(D){return D.length-D.filter(c).length}e.countNonPushOnlyOPs=w;function b(D){if(D.length===0)return r.OPS.OP_0;if(D.length===1){if(D[0]>=1&&D[0]<=16)return p+D[0];if(D[0]===129)return r.OPS.OP_1NEGATE}}function E(D){return Buffer$e.isBuffer(D)}function I(D){return a.Array(D)}function x(D){return Buffer$e.isBuffer(D)}function B(D){if(E(D))return D;l(a.Array,D);const L=D.reduce((_,$)=>x($)?$.length===1&&b($)!==void 0?_+1:_+s.encodingLength($.length)+$.length:_+1,0),C=Buffer$e.allocUnsafe(L);let d=0;if(D.forEach(_=>{if(x(_)){const $=b(_);if($!==void 0){C.writeUInt8($,d),d+=1;return}d+=s.encode(C,_.length,d),_.copy(C,d),d+=_.length}else C.writeUInt8(_,d),d+=1}),d!==C.length)throw new Error("Could not decode chunks");return C}e.compile=B;function M(D){if(I(D))return D;l(a.Buffer,D);const L=[];let C=0;for(;C<D.length;){const d=D[C];if(d>r.OPS.OP_0&&d<=r.OPS.OP_PUSHDATA4){const _=s.decode(D,C);if(_===null||(C+=_.size,C+_.number>D.length))return null;const $=D.slice(C,C+_.number);C+=_.number;const S=b($);S!==void 0?L.push(S):L.push($)}else L.push(d),C+=1}return L}e.decompile=M;function q(D){return E(D)&&(D=M(D)),D.map(L=>{if(x(L)){const C=b(L);if(C===void 0)return L.toString("hex");L=C}return r.REVERSE_OPS[L]}).join(" ")}e.toASM=q;function U(D){return l(a.String,D),B(D.split(" ").map(L=>r.OPS[L]!==void 0?r.OPS[L]:(l(a.Hex,L),Buffer$e.from(L,"hex"))))}e.fromASM=U;function F(D){return D=M(D),l(v,D),D.map(L=>x(L)?L:L===r.OPS.OP_0?Buffer$e.allocUnsafe(0):o.encode(L-p))}e.toStack=F;function j(D){return a.isPoint(D)}e.isCanonicalPubKey=j;function y(D){const L=D&-129;return L>0&&L<4}e.isDefinedHashType=y;function T(D){return!Buffer$e.isBuffer(D)||!y(D[D.length-1])?!1:t.check(D.slice(0,-1))}e.isCanonicalScriptSignature=T,e.number=o,e.signature=n})(script);Object.defineProperty(transaction,"__esModule",{value:!0});transaction.Transaction=void 0;const bufferutils_1=bufferutils,bcrypto$4=crypto$1,bscript$9=script,script_1=script,types=types$4,{typeforce}=types;function varSliceSize(e){const t=e.length;return bufferutils_1.varuint.encodingLength(t)+t}function vectorSize(e){const t=e.length;return bufferutils_1.varuint.encodingLength(t)+e.reduce((r,s)=>r+varSliceSize(s),0)}const EMPTY_BUFFER$2=Buffer$e.allocUnsafe(0),EMPTY_WITNESS=[],ZERO=Buffer$e.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),ONE=Buffer$e.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),VALUE_UINT64_MAX=Buffer$e.from("ffffffffffffffff","hex"),BLANK_OUTPUT={script:EMPTY_BUFFER$2,valueBuffer:VALUE_UINT64_MAX};function isOutput(e){return e.value!==void 0}class Transaction{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,r){const s=new bufferutils_1.BufferReader(t),o=new Transaction;o.version=s.readInt32();const n=s.readUInt8(),a=s.readUInt8();let l=!1;n===Transaction.ADVANCED_TRANSACTION_MARKER&&a===Transaction.ADVANCED_TRANSACTION_FLAG?l=!0:s.offset-=2;const p=s.readVarInt();for(let c=0;c<p;++c)o.ins.push({hash:s.readSlice(32),index:s.readUInt32(),script:s.readVarSlice(),sequence:s.readUInt32(),witness:EMPTY_WITNESS});const u=s.readVarInt();for(let c=0;c<u;++c)o.outs.push({value:s.readUInt64(),script:s.readVarSlice()});if(l){for(let c=0;c<p;++c)o.ins[c].witness=s.readVector();if(!o.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(o.locktime=s.readUInt32(),r)return o;if(s.offset!==t.length)throw new Error("Transaction has unexpected data");return o}static fromHex(t){return Transaction.fromBuffer(Buffer$e.from(t,"hex"),!1)}static isCoinbaseHash(t){typeforce(types.Hash256bit,t);for(let r=0;r<32;++r)if(t[r]!==0)return!1;return!0}isCoinbase(){return this.ins.length===1&&Transaction.isCoinbaseHash(this.ins[0].hash)}addInput(t,r,s,o){return typeforce(types.tuple(types.Hash256bit,types.UInt32,types.maybe(types.UInt32),types.maybe(types.Buffer)),arguments),types.Null(s)&&(s=Transaction.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:r,script:o||EMPTY_BUFFER$2,sequence:s,witness:EMPTY_WITNESS})-1}addOutput(t,r){return typeforce(types.tuple(types.Buffer,types.Satoshi),arguments),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)+bufferutils_1.varuint.encodingLength(this.ins.length)+bufferutils_1.varuint.encodingLength(this.outs.length)+this.ins.reduce((s,o)=>s+40+varSliceSize(o.script),0)+this.outs.reduce((s,o)=>s+8+varSliceSize(o.script),0)+(r?this.ins.reduce((s,o)=>s+vectorSize(o.witness),0):0)}clone(){const t=new Transaction;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,s){if(typeforce(types.tuple(types.UInt32,types.Buffer,types.Number),arguments),t>=this.ins.length)return ONE;const o=bscript$9.compile(bscript$9.decompile(r).filter(l=>l!==script_1.OPS.OP_CODESEPARATOR)),n=this.clone();if((s&31)===Transaction.SIGHASH_NONE)n.outs=[],n.ins.forEach((l,p)=>{p!==t&&(l.sequence=0)});else if((s&31)===Transaction.SIGHASH_SINGLE){if(t>=this.outs.length)return ONE;n.outs.length=t+1;for(let l=0;l<t;l++)n.outs[l]=BLANK_OUTPUT;n.ins.forEach((l,p)=>{p!==t&&(l.sequence=0)})}s&Transaction.SIGHASH_ANYONECANPAY?(n.ins=[n.ins[t]],n.ins[0].script=o):(n.ins.forEach(l=>{l.script=EMPTY_BUFFER$2}),n.ins[t].script=o);const a=Buffer$e.allocUnsafe(n.byteLength(!1)+4);return a.writeInt32LE(s,a.length-4),n.__toBuffer(a,0,!1),bcrypto$4.hash256(a)}hashForWitnessV1(t,r,s,o,n,a){if(typeforce(types.tuple(types.UInt32,typeforce.arrayOf(types.Buffer),typeforce.arrayOf(types.Satoshi),types.UInt32),arguments),s.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=o===Transaction.SIGHASH_DEFAULT?Transaction.SIGHASH_ALL:o&Transaction.SIGHASH_OUTPUT_MASK,u=(o&Transaction.SIGHASH_INPUT_MASK)===Transaction.SIGHASH_ANYONECANPAY,c=l===Transaction.SIGHASH_NONE,v=l===Transaction.SIGHASH_SINGLE;let w=EMPTY_BUFFER$2,b=EMPTY_BUFFER$2,E=EMPTY_BUFFER$2,I=EMPTY_BUFFER$2,x=EMPTY_BUFFER$2;if(!u){let U=bufferutils_1.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach(F=>{U.writeSlice(F.hash),U.writeUInt32(F.index)}),w=bcrypto$4.sha256(U.end()),U=bufferutils_1.BufferWriter.withCapacity(8*this.ins.length),s.forEach(F=>U.writeUInt64(F)),b=bcrypto$4.sha256(U.end()),U=bufferutils_1.BufferWriter.withCapacity(r.map(varSliceSize).reduce((F,j)=>F+j)),r.forEach(F=>U.writeVarSlice(F)),E=bcrypto$4.sha256(U.end()),U=bufferutils_1.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach(F=>U.writeUInt32(F.sequence)),I=bcrypto$4.sha256(U.end())}if(c||v){if(v&&t<this.outs.length){const U=this.outs[t],F=bufferutils_1.BufferWriter.withCapacity(8+varSliceSize(U.script));F.writeUInt64(U.value),F.writeVarSlice(U.script),x=bcrypto$4.sha256(F.end())}}else{const U=this.outs.map(j=>8+varSliceSize(j.script)).reduce((j,y)=>j+y),F=bufferutils_1.BufferWriter.withCapacity(U);this.outs.forEach(j=>{F.writeUInt64(j.value),F.writeVarSlice(j.script)}),x=bcrypto$4.sha256(F.end())}const B=(n?2:0)+(a?1:0),M=174-(u?49:0)-(c?32:0)+(a?32:0)+(n?37:0),q=bufferutils_1.BufferWriter.withCapacity(M);if(q.writeUInt8(o),q.writeInt32(this.version),q.writeUInt32(this.locktime),q.writeSlice(w),q.writeSlice(b),q.writeSlice(E),q.writeSlice(I),c||v||q.writeSlice(x),q.writeUInt8(B),u){const U=this.ins[t];q.writeSlice(U.hash),q.writeUInt32(U.index),q.writeUInt64(s[t]),q.writeVarSlice(r[t]),q.writeUInt32(U.sequence)}else q.writeUInt32(t);if(a){const U=bufferutils_1.BufferWriter.withCapacity(varSliceSize(a));U.writeVarSlice(a),q.writeSlice(bcrypto$4.sha256(U.end()))}return v&&q.writeSlice(x),n&&(q.writeSlice(n),q.writeUInt8(0),q.writeUInt32(4294967295)),bcrypto$4.taggedHash("TapSighash",Buffer$e.concat([Buffer$e.from([0]),q.end()]))}hashForWitnessV0(t,r,s,o){typeforce(types.tuple(types.UInt32,types.Buffer,types.Satoshi,types.UInt32),arguments);let n=Buffer$e.from([]),a,l=ZERO,p=ZERO,u=ZERO;if(o&Transaction.SIGHASH_ANYONECANPAY||(n=Buffer$e.allocUnsafe(36*this.ins.length),a=new bufferutils_1.BufferWriter(n,0),this.ins.forEach(v=>{a.writeSlice(v.hash),a.writeUInt32(v.index)}),p=bcrypto$4.hash256(n)),!(o&Transaction.SIGHASH_ANYONECANPAY)&&(o&31)!==Transaction.SIGHASH_SINGLE&&(o&31)!==Transaction.SIGHASH_NONE&&(n=Buffer$e.allocUnsafe(4*this.ins.length),a=new bufferutils_1.BufferWriter(n,0),this.ins.forEach(v=>{a.writeUInt32(v.sequence)}),u=bcrypto$4.hash256(n)),(o&31)!==Transaction.SIGHASH_SINGLE&&(o&31)!==Transaction.SIGHASH_NONE){const v=this.outs.reduce((w,b)=>w+8+varSliceSize(b.script),0);n=Buffer$e.allocUnsafe(v),a=new bufferutils_1.BufferWriter(n,0),this.outs.forEach(w=>{a.writeUInt64(w.value),a.writeVarSlice(w.script)}),l=bcrypto$4.hash256(n)}else if((o&31)===Transaction.SIGHASH_SINGLE&&t<this.outs.length){const v=this.outs[t];n=Buffer$e.allocUnsafe(8+varSliceSize(v.script)),a=new bufferutils_1.BufferWriter(n,0),a.writeUInt64(v.value),a.writeVarSlice(v.script),l=bcrypto$4.hash256(n)}n=Buffer$e.allocUnsafe(156+varSliceSize(r)),a=new bufferutils_1.BufferWriter(n,0);const c=this.ins[t];return a.writeInt32(this.version),a.writeSlice(p),a.writeSlice(u),a.writeSlice(c.hash),a.writeUInt32(c.index),a.writeVarSlice(r),a.writeUInt64(s),a.writeUInt32(c.sequence),a.writeSlice(l),a.writeUInt32(this.locktime),a.writeUInt32(o),bcrypto$4.hash256(n)}getHash(t){return t&&this.isCoinbase()?Buffer$e.alloc(32,0):bcrypto$4.hash256(this.__toBuffer(void 0,void 0,t))}getId(){return(0,bufferutils_1.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(t,r){return this.__toBuffer(t,r,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(t,r){typeforce(types.tuple(types.Number,types.Buffer),arguments),this.ins[t].script=r}setWitness(t,r){typeforce(types.tuple(types.Number,[types.Buffer]),arguments),this.ins[t].witness=r}__toBuffer(t,r,s=!1){t||(t=Buffer$e.allocUnsafe(this.byteLength(s)));const o=new bufferutils_1.BufferWriter(t,r||0);o.writeInt32(this.version);const n=s&&this.hasWitnesses();return n&&(o.writeUInt8(Transaction.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(Transaction.ADVANCED_TRANSACTION_FLAG)),o.writeVarInt(this.ins.length),this.ins.forEach(a=>{o.writeSlice(a.hash),o.writeUInt32(a.index),o.writeVarSlice(a.script),o.writeUInt32(a.sequence)}),o.writeVarInt(this.outs.length),this.outs.forEach(a=>{isOutput(a)?o.writeUInt64(a.value):o.writeSlice(a.valueBuffer),o.writeVarSlice(a.script)}),n&&this.ins.forEach(a=>{o.writeVector(a.witness)}),o.writeUInt32(this.locktime),r!==void 0?t.slice(r,o.offset):t}}transaction.Transaction=Transaction;Transaction.DEFAULT_SEQUENCE=4294967295;Transaction.SIGHASH_DEFAULT=0;Transaction.SIGHASH_ALL=1;Transaction.SIGHASH_NONE=2;Transaction.SIGHASH_SINGLE=3;Transaction.SIGHASH_ANYONECANPAY=128;Transaction.SIGHASH_OUTPUT_MASK=3;Transaction.SIGHASH_INPUT_MASK=128;Transaction.ADVANCED_TRANSACTION_MARKER=0;Transaction.ADVANCED_TRANSACTION_FLAG=1;var psbtutils={},varint={};Object.defineProperty(varint,"__esModule",{value:!0});const MAX_SAFE_INTEGER=9007199254740991;function checkUInt53(e){if(e<0||e>MAX_SAFE_INTEGER||e%1!==0)throw new RangeError("value out of range")}function encode(e,t,r){if(checkUInt53(e),t||(t=Buffer$e.allocUnsafe(encodingLength(e))),!Buffer$e.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),e<253?(t.writeUInt8(e,r),Object.assign(encode,{bytes:1})):e<=65535?(t.writeUInt8(253,r),t.writeUInt16LE(e,r+1),Object.assign(encode,{bytes:3})):e<=4294967295?(t.writeUInt8(254,r),t.writeUInt32LE(e,r+1),Object.assign(encode,{bytes:5})):(t.writeUInt8(255,r),t.writeUInt32LE(e>>>0,r+1),t.writeUInt32LE(e/4294967296|0,r+5),Object.assign(encode,{bytes:9})),t}varint.encode=encode;function decode(e,t){if(!Buffer$e.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");t||(t=0);const r=e.readUInt8(t);if(r<253)return Object.assign(decode,{bytes:1}),r;if(r===253)return Object.assign(decode,{bytes:3}),e.readUInt16LE(t+1);if(r===254)return Object.assign(decode,{bytes:5}),e.readUInt32LE(t+1);{Object.assign(decode,{bytes:9});const s=e.readUInt32LE(t+1),n=e.readUInt32LE(t+5)*4294967296+s;return checkUInt53(n),n}}varint.decode=decode;function encodingLength(e){return checkUInt53(e),e<253?1:e<=65535?3:e<=4294967295?5:9}varint.encodingLength=encodingLength;var payments$1={},embed={},networks={};Object.defineProperty(networks,"__esModule",{value:!0});networks.testnet=networks.regtest=networks.bitcoin=void 0;networks.bitcoin={messagePrefix:`Bitcoin Signed Message:
77
77
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};networks.regtest={messagePrefix:`Bitcoin Signed Message:
78
78
  `,bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};networks.testnet={messagePrefix:`Bitcoin Signed Message:
79
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var lazy$8={};Object.defineProperty(lazy$8,"__esModule",{value:!0});lazy$8.value=lazy$8.prop=void 0;function prop(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const s=r.call(this);return this[t]=s,s},set(s){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:s,writable:!0})}})}lazy$8.prop=prop;function value(e){let t;return()=>(t!==void 0||(t=e()),t)}lazy$8.value=value;Object.defineProperty(embed,"__esModule",{value:!0});embed.p2data=void 0;const networks_1$7=networks,bscript$8=script,types_1$8=types$4,lazy$7=lazy$8,OPS$7=bscript$8.OPS;function stacksEqual$4(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2data(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,types_1$8.typeforce)({network:types_1$8.typeforce.maybe(types_1$8.typeforce.Object),output:types_1$8.typeforce.maybe(types_1$8.typeforce.Buffer),data:types_1$8.typeforce.maybe(types_1$8.typeforce.arrayOf(types_1$8.typeforce.Buffer))},e);const s={name:"embed",network:e.network||networks_1$7.bitcoin};if(lazy$7.prop(s,"output",()=>{if(e.data)return bscript$8.compile([OPS$7.OP_RETURN].concat(e.data))}),lazy$7.prop(s,"data",()=>{if(e.output)return bscript$8.decompile(e.output).slice(1)}),t.validate&&e.output){const o=bscript$8.decompile(e.output);if(o[0]!==OPS$7.OP_RETURN)throw new TypeError("Output is invalid");if(!o.slice(1).every(types_1$8.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!stacksEqual$4(e.data,s.data))throw new TypeError("Data mismatch")}return Object.assign(s,e)}embed.p2data=p2data;var p2ms$1={};Object.defineProperty(p2ms$1,"__esModule",{value:!0});p2ms$1.p2ms=void 0;const networks_1$6=networks,bscript$7=script,types_1$7=types$4,lazy$6=lazy$8,OPS$6=bscript$7.OPS,OP_INT_BASE=OPS$6.OP_RESERVED;function stacksEqual$3(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2ms(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(p){return bscript$7.isCanonicalScriptSignature(p)||(t.allowIncomplete&&p===OPS$6.OP_0)!==void 0}(0,types_1$7.typeforce)({network:types_1$7.typeforce.maybe(types_1$7.typeforce.Object),m:types_1$7.typeforce.maybe(types_1$7.typeforce.Number),n:types_1$7.typeforce.maybe(types_1$7.typeforce.Number),output:types_1$7.typeforce.maybe(types_1$7.typeforce.Buffer),pubkeys:types_1$7.typeforce.maybe(types_1$7.typeforce.arrayOf(types_1$7.isPoint)),signatures:types_1$7.typeforce.maybe(types_1$7.typeforce.arrayOf(r)),input:types_1$7.typeforce.maybe(types_1$7.typeforce.Buffer)},e);const o={network:e.network||networks_1$6.bitcoin};let n=[],a=!1;function l(p){a||(a=!0,n=bscript$7.decompile(p),o.m=n[0]-OP_INT_BASE,o.n=n[n.length-2]-OP_INT_BASE,o.pubkeys=n.slice(1,-2))}if(lazy$6.prop(o,"output",()=>{if(e.m&&o.n&&e.pubkeys)return bscript$7.compile([].concat(OP_INT_BASE+e.m,e.pubkeys,OP_INT_BASE+o.n,OPS$6.OP_CHECKMULTISIG))}),lazy$6.prop(o,"m",()=>{if(o.output)return l(o.output),o.m}),lazy$6.prop(o,"n",()=>{if(o.pubkeys)return o.pubkeys.length}),lazy$6.prop(o,"pubkeys",()=>{if(e.output)return l(e.output),o.pubkeys}),lazy$6.prop(o,"signatures",()=>{if(e.input)return bscript$7.decompile(e.input).slice(1)}),lazy$6.prop(o,"input",()=>{if(e.signatures)return bscript$7.compile([OPS$6.OP_0].concat(e.signatures))}),lazy$6.prop(o,"witness",()=>{if(o.input)return[]}),lazy$6.prop(o,"name",()=>{if(!(!o.m||!o.n))return`p2ms(${o.m} of ${o.n})`}),t.validate){if(e.output){if(l(e.output),!types_1$7.typeforce.Number(n[0]))throw new TypeError("Output is invalid");if(!types_1$7.typeforce.Number(n[n.length-2]))throw new TypeError("Output is invalid");if(n[n.length-1]!==OPS$6.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(o.m<=0||o.n>16||o.m>o.n||o.n!==n.length-3)throw new TypeError("Output is invalid");if(!o.pubkeys.every(p=>(0,types_1$7.isPoint)(p)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==o.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==o.n)throw new TypeError("n mismatch");if(e.pubkeys&&!stacksEqual$3(e.pubkeys,o.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(o.n=e.pubkeys.length,o.n<o.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<o.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>o.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==OPS$6.OP_0)throw new TypeError("Input is invalid");if(o.signatures.length===0||!o.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!stacksEqual$3(e.signatures,o.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(o,e)}p2ms$1.p2ms=p2ms;var p2pk$1={};Object.defineProperty(p2pk$1,"__esModule",{value:!0});p2pk$1.p2pk=void 0;const networks_1$5=networks,bscript$6=script,types_1$6=types$4,lazy$5=lazy$8,OPS$5=bscript$6.OPS;function p2pk(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||{}),(0,types_1$6.typeforce)({network:types_1$6.typeforce.maybe(types_1$6.typeforce.Object),output:types_1$6.typeforce.maybe(types_1$6.typeforce.Buffer),pubkey:types_1$6.typeforce.maybe(types_1$6.isPoint),signature:types_1$6.typeforce.maybe(bscript$6.isCanonicalScriptSignature),input:types_1$6.typeforce.maybe(types_1$6.typeforce.Buffer)},e);const r=lazy$5.value(()=>bscript$6.decompile(e.input)),o={name:"p2pk",network:e.network||networks_1$5.bitcoin};if(lazy$5.prop(o,"output",()=>{if(e.pubkey)return bscript$6.compile([e.pubkey,OPS$5.OP_CHECKSIG])}),lazy$5.prop(o,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),lazy$5.prop(o,"signature",()=>{if(e.input)return r()[0]}),lazy$5.prop(o,"input",()=>{if(e.signature)return bscript$6.compile([e.signature])}),lazy$5.prop(o,"witness",()=>{if(o.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==OPS$5.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,types_1$6.isPoint)(o.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(o.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(o.input))throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!bscript$6.isCanonicalScriptSignature(o.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(o,e)}p2pk$1.p2pk=p2pk;var p2pkh$1={};Object.defineProperty(p2pkh$1,"__esModule",{value:!0});p2pkh$1.p2pkh=void 0;const bcrypto$3=crypto$1,networks_1$4=networks,bscript$5=script,types_1$5=types$4,lazy$4=lazy$8,bs58check$1=bs58check$a,OPS$4=bscript$5.OPS;function p2pkh(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||{}),(0,types_1$5.typeforce)({network:types_1$5.typeforce.maybe(types_1$5.typeforce.Object),address:types_1$5.typeforce.maybe(types_1$5.typeforce.String),hash:types_1$5.typeforce.maybe(types_1$5.typeforce.BufferN(20)),output:types_1$5.typeforce.maybe(types_1$5.typeforce.BufferN(25)),pubkey:types_1$5.typeforce.maybe(types_1$5.isPoint),signature:types_1$5.typeforce.maybe(bscript$5.isCanonicalScriptSignature),input:types_1$5.typeforce.maybe(types_1$5.typeforce.Buffer)},e);const r=lazy$4.value(()=>{const a=Buffer$e.from(bs58check$1.decode(e.address)),l=a.readUInt8(0),p=a.slice(1);return{version:l,hash:p}}),s=lazy$4.value(()=>bscript$5.decompile(e.input)),o=e.network||networks_1$4.bitcoin,n={name:"p2pkh",network:o};if(lazy$4.prop(n,"address",()=>{if(!n.hash)return;const a=Buffer$e.allocUnsafe(21);return a.writeUInt8(o.pubKeyHash,0),n.hash.copy(a,1),bs58check$1.encode(a)}),lazy$4.prop(n,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||n.pubkey)return bcrypto$3.hash160(e.pubkey||n.pubkey)}),lazy$4.prop(n,"output",()=>{if(n.hash)return bscript$5.compile([OPS$4.OP_DUP,OPS$4.OP_HASH160,n.hash,OPS$4.OP_EQUALVERIFY,OPS$4.OP_CHECKSIG])}),lazy$4.prop(n,"pubkey",()=>{if(e.input)return s()[1]}),lazy$4.prop(n,"signature",()=>{if(e.input)return s()[0]}),lazy$4.prop(n,"input",()=>{if(e.pubkey&&e.signature)return bscript$5.compile([e.signature,e.pubkey])}),lazy$4.prop(n,"witness",()=>{if(n.input)return[]}),t.validate){let a=Buffer$e.from([]);if(e.address){if(r().version!==o.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");a=r().hash}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==OPS$4.OP_DUP||e.output[1]!==OPS$4.OP_HASH160||e.output[2]!==20||e.output[23]!==OPS$4.OP_EQUALVERIFY||e.output[24]!==OPS$4.OP_CHECKSIG)throw new TypeError("Output is invalid");const l=e.output.slice(3,23);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.pubkey){const l=bcrypto$3.hash160(e.pubkey);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.input){const l=s();if(l.length!==2)throw new TypeError("Input is invalid");if(!bscript$5.isCanonicalScriptSignature(l[0]))throw new TypeError("Input has invalid signature");if(!(0,types_1$5.isPoint)(l[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(l[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(l[1]))throw new TypeError("Pubkey mismatch");const p=bcrypto$3.hash160(l[1]);if(a.length>0&&!a.equals(p))throw new TypeError("Hash mismatch")}}return Object.assign(n,e)}p2pkh$1.p2pkh=p2pkh;var p2sh$1={};Object.defineProperty(p2sh$1,"__esModule",{value:!0});p2sh$1.p2sh=void 0;const bcrypto$2=crypto$1,networks_1$3=networks,bscript$4=script,types_1$4=types$4,lazy$3=lazy$8,bs58check=bs58check$a,OPS$3=bscript$4.OPS;function stacksEqual$2(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2sh(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||{}),(0,types_1$4.typeforce)({network:types_1$4.typeforce.maybe(types_1$4.typeforce.Object),address:types_1$4.typeforce.maybe(types_1$4.typeforce.String),hash:types_1$4.typeforce.maybe(types_1$4.typeforce.BufferN(20)),output:types_1$4.typeforce.maybe(types_1$4.typeforce.BufferN(23)),redeem:types_1$4.typeforce.maybe({network:types_1$4.typeforce.maybe(types_1$4.typeforce.Object),output:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),input:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),witness:types_1$4.typeforce.maybe(types_1$4.typeforce.arrayOf(types_1$4.typeforce.Buffer))}),input:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),witness:types_1$4.typeforce.maybe(types_1$4.typeforce.arrayOf(types_1$4.typeforce.Buffer))},e);let r=e.network;r||(r=e.redeem&&e.redeem.network||networks_1$3.bitcoin);const s={network:r},o=lazy$3.value(()=>{const l=Buffer$e.from(bs58check.decode(e.address)),p=l.readUInt8(0),u=l.slice(1);return{version:p,hash:u}}),n=lazy$3.value(()=>bscript$4.decompile(e.input)),a=lazy$3.value(()=>{const l=n(),p=l[l.length-1];return{network:r,output:p===OPS$3.OP_FALSE?Buffer$e.from([]):p,input:bscript$4.compile(l.slice(0,-1)),witness:e.witness||[]}});if(lazy$3.prop(s,"address",()=>{if(!s.hash)return;const l=Buffer$e.allocUnsafe(21);return l.writeUInt8(s.network.scriptHash,0),s.hash.copy(l,1),bs58check.encode(l)}),lazy$3.prop(s,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return o().hash;if(s.redeem&&s.redeem.output)return bcrypto$2.hash160(s.redeem.output)}),lazy$3.prop(s,"output",()=>{if(s.hash)return bscript$4.compile([OPS$3.OP_HASH160,s.hash,OPS$3.OP_EQUAL])}),lazy$3.prop(s,"redeem",()=>{if(e.input)return a()}),lazy$3.prop(s,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return bscript$4.compile([].concat(bscript$4.decompile(e.redeem.input),e.redeem.output))}),lazy$3.prop(s,"witness",()=>{if(s.redeem&&s.redeem.witness)return s.redeem.witness;if(s.input)return[]}),lazy$3.prop(s,"name",()=>{const l=["p2sh"];return s.redeem!==void 0&&s.redeem.name!==void 0&&l.push(s.redeem.name),l.join("-")}),t.validate){let l=Buffer$e.from([]);if(e.address){if(o().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(o().hash.length!==20)throw new TypeError("Invalid address");l=o().hash}if(e.hash){if(l.length>0&&!l.equals(e.hash))throw new TypeError("Hash mismatch");l=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==OPS$3.OP_HASH160||e.output[1]!==20||e.output[22]!==OPS$3.OP_EQUAL)throw new TypeError("Output is invalid");const u=e.output.slice(2,22);if(l.length>0&&!l.equals(u))throw new TypeError("Hash mismatch");l=u}const p=u=>{if(u.output){const c=bscript$4.decompile(u.output);if(!c||c.length<1)throw new TypeError("Redeem.output too short");if(u.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(bscript$4.countNonPushOnlyOPs(c)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const v=bcrypto$2.hash160(u.output);if(l.length>0&&!l.equals(v))throw new TypeError("Hash mismatch");l=v}if(u.input){const c=u.input.length>0,v=u.witness&&u.witness.length>0;if(!c&&!v)throw new TypeError("Empty input");if(c&&v)throw new TypeError("Input and witness provided");if(c){const w=bscript$4.decompile(u.input);if(!bscript$4.isPushOnly(w))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const u=n();if(!u||u.length<1)throw new TypeError("Input too short");if(!Buffer$e.isBuffer(a().output))throw new TypeError("Input is invalid");p(a())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const u=a();if(e.redeem.output&&!e.redeem.output.equals(u.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(u.input))throw new TypeError("Redeem.input mismatch")}p(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!stacksEqual$2(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(s,e)}p2sh$1.p2sh=p2sh;var p2wpkh$1={},dist={};Object.defineProperty(dist,"__esModule",{value:!0});dist.bech32m=dist.bech32=void 0;const ALPHABET="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP={};for(let e=0;e<ALPHABET.length;e++){const t=ALPHABET.charAt(e);ALPHABET_MAP[t]=e}function polymodStep(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 prefixChk(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=polymodStep(t)^s>>5}t=polymodStep(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=polymodStep(t)^s&31}return t}function convert(e,t,r,s){let o=0,n=0;const a=(1<<r)-1,l=[];for(let p=0;p<e.length;++p)for(o=o<<t|e[p],n+=t;n>=r;)n-=r,l.push(o>>n&a);if(s)n>0&&l.push(o<<r-n&a);else{if(n>=t)return"Excess padding";if(o<<r-n&a)return"Non-zero padding"}return l}function toWords(e){return convert(e,8,5,!0)}function fromWordsUnsafe(e){const t=convert(e,5,8,!1);if(Array.isArray(t))return t}function fromWords(e){const t=convert(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function getLibraryFromEncoding(e){let t;e==="bech32"?t=1:t=734539939;function r(a,l,p){if(p=p||90,a.length+7+l.length>p)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let u=prefixChk(a);if(typeof u=="string")throw new Error(u);let c=a+"1";for(let v=0;v<l.length;++v){const w=l[v];if(w>>5)throw new Error("Non 5-bit word");u=polymodStep(u)^w,c+=ALPHABET.charAt(w)}for(let v=0;v<6;++v)u=polymodStep(u);u^=t;for(let v=0;v<6;++v){const w=u>>(5-v)*5&31;c+=ALPHABET.charAt(w)}return c}function s(a,l){if(l=l||90,a.length<8)return a+" too short";if(a.length>l)return"Exceeds length limit";const p=a.toLowerCase(),u=a.toUpperCase();if(a!==p&&a!==u)return"Mixed-case string "+a;a=p;const c=a.lastIndexOf("1");if(c===-1)return"No separator character for "+a;if(c===0)return"Missing prefix for "+a;const v=a.slice(0,c),w=a.slice(c+1);if(w.length<6)return"Data too short";let b=prefixChk(v);if(typeof b=="string")return b;const E=[];for(let I=0;I<w.length;++I){const x=w.charAt(I),B=ALPHABET_MAP[x];if(B===void 0)return"Unknown character "+x;b=polymodStep(b)^B,!(I+6>=w.length)&&E.push(B)}return b!==t?"Invalid checksum for "+a:{prefix:v,words:E}}function o(a,l){const p=s(a,l);if(typeof p=="object")return p}function n(a,l){const p=s(a,l);if(typeof p=="object")return p;throw new Error(p)}return{decodeUnsafe:o,decode:n,encode:r,toWords,fromWordsUnsafe,fromWords}}dist.bech32=getLibraryFromEncoding("bech32");dist.bech32m=getLibraryFromEncoding("bech32m");Object.defineProperty(p2wpkh$1,"__esModule",{value:!0});p2wpkh$1.p2wpkh=void 0;const bcrypto$1=crypto$1,networks_1$2=networks,bscript$3=script,types_1$3=types$4,lazy$2=lazy$8,bech32_1$2=dist,OPS$2=bscript$3.OPS,EMPTY_BUFFER$1=Buffer$e.alloc(0);function p2wpkh(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||{}),(0,types_1$3.typeforce)({address:types_1$3.typeforce.maybe(types_1$3.typeforce.String),hash:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(20)),input:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(0)),network:types_1$3.typeforce.maybe(types_1$3.typeforce.Object),output:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(22)),pubkey:types_1$3.typeforce.maybe(types_1$3.isPoint),signature:types_1$3.typeforce.maybe(bscript$3.isCanonicalScriptSignature),witness:types_1$3.typeforce.maybe(types_1$3.typeforce.arrayOf(types_1$3.typeforce.Buffer))},e);const r=lazy$2.value(()=>{const n=bech32_1$2.bech32.decode(e.address),a=n.words.shift(),l=bech32_1$2.bech32.fromWords(n.words);return{version:a,prefix:n.prefix,data:Buffer$e.from(l)}}),s=e.network||networks_1$2.bitcoin,o={name:"p2wpkh",network:s};if(lazy$2.prop(o,"address",()=>{if(!o.hash)return;const n=bech32_1$2.bech32.toWords(o.hash);return n.unshift(0),bech32_1$2.bech32.encode(s.bech32,n)}),lazy$2.prop(o,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||o.pubkey)return bcrypto$1.hash160(e.pubkey||o.pubkey)}),lazy$2.prop(o,"output",()=>{if(o.hash)return bscript$3.compile([OPS$2.OP_0,o.hash])}),lazy$2.prop(o,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),lazy$2.prop(o,"signature",()=>{if(e.witness)return e.witness[0]}),lazy$2.prop(o,"input",()=>{if(o.witness)return EMPTY_BUFFER$1}),lazy$2.prop(o,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let n=Buffer$e.from([]);if(e.address){if(s&&s.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");n=r().data}if(e.hash){if(n.length>0&&!n.equals(e.hash))throw new TypeError("Hash mismatch");n=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==OPS$2.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(n.length>0&&!n.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");n=e.output.slice(2)}if(e.pubkey){const a=bcrypto$1.hash160(e.pubkey);if(n.length>0&&!n.equals(a))throw new TypeError("Hash mismatch");if(n=a,!(0,types_1$3.isPoint)(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(!bscript$3.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,types_1$3.isPoint)(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const a=bcrypto$1.hash160(e.witness[1]);if(n.length>0&&!n.equals(a))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}p2wpkh$1.p2wpkh=p2wpkh;var p2wsh$1={};Object.defineProperty(p2wsh$1,"__esModule",{value:!0});p2wsh$1.p2wsh=void 0;const bcrypto=crypto$1,networks_1$1=networks,bscript$2=script,types_1$2=types$4,lazy$1=lazy$8,bech32_1$1=dist,OPS$1=bscript$2.OPS,EMPTY_BUFFER=Buffer$e.alloc(0);function stacksEqual$1(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function chunkHasUncompressedPubkey(e){return!!(Buffer$e.isBuffer(e)&&e.length===65&&e[0]===4&&(0,types_1$2.isPoint)(e))}function p2wsh(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||{}),(0,types_1$2.typeforce)({network:types_1$2.typeforce.maybe(types_1$2.typeforce.Object),address:types_1$2.typeforce.maybe(types_1$2.typeforce.String),hash:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(32)),output:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(34)),redeem:types_1$2.typeforce.maybe({input:types_1$2.typeforce.maybe(types_1$2.typeforce.Buffer),network:types_1$2.typeforce.maybe(types_1$2.typeforce.Object),output:types_1$2.typeforce.maybe(types_1$2.typeforce.Buffer),witness:types_1$2.typeforce.maybe(types_1$2.typeforce.arrayOf(types_1$2.typeforce.Buffer))}),input:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(0)),witness:types_1$2.typeforce.maybe(types_1$2.typeforce.arrayOf(types_1$2.typeforce.Buffer))},e);const r=lazy$1.value(()=>{const a=bech32_1$1.bech32.decode(e.address),l=a.words.shift(),p=bech32_1$1.bech32.fromWords(a.words);return{version:l,prefix:a.prefix,data:Buffer$e.from(p)}}),s=lazy$1.value(()=>bscript$2.decompile(e.redeem.input));let o=e.network;o||(o=e.redeem&&e.redeem.network||networks_1$1.bitcoin);const n={network:o};if(lazy$1.prop(n,"address",()=>{if(!n.hash)return;const a=bech32_1$1.bech32.toWords(n.hash);return a.unshift(0),bech32_1$1.bech32.encode(o.bech32,a)}),lazy$1.prop(n,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(n.redeem&&n.redeem.output)return bcrypto.sha256(n.redeem.output)}),lazy$1.prop(n,"output",()=>{if(n.hash)return bscript$2.compile([OPS$1.OP_0,n.hash])}),lazy$1.prop(n,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:EMPTY_BUFFER,witness:e.witness.slice(0,-1)}}),lazy$1.prop(n,"input",()=>{if(n.witness)return EMPTY_BUFFER}),lazy$1.prop(n,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const a=bscript$2.toStack(s());return n.redeem=Object.assign({witness:a},e.redeem),n.redeem.input=EMPTY_BUFFER,[].concat(a,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),lazy$1.prop(n,"name",()=>{const a=["p2wsh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Buffer$e.from([]);if(e.address){if(r().prefix!==o.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");a=r().data}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==OPS$1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const l=e.output.slice(2);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.redeem){if(e.redeem.network&&e.redeem.network!==o)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 l=bscript$2.decompile(e.redeem.output);if(!l||l.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(bscript$2.countNonPushOnlyOPs(l)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const p=bcrypto.sha256(e.redeem.output);if(a.length>0&&!a.equals(p))throw new TypeError("Hash mismatch");a=p}if(e.redeem.input&&!bscript$2.isPushOnly(s()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!stacksEqual$1(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&s().some(chunkHasUncompressedPubkey)||e.redeem.output&&(bscript$2.decompile(e.redeem.output)||[]).some(chunkHasUncompressedPubkey))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const l=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(l))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(chunkHasUncompressedPubkey)||(bscript$2.decompile(l)||[]).some(chunkHasUncompressedPubkey))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(n,e)}p2wsh$1.p2wsh=p2wsh;var p2tr$1={};Object.defineProperty(p2tr$1,"__esModule",{value:!0});p2tr$1.p2tr=void 0;const buffer_1=require$$0$3,networks_1=networks,bscript$1=script,types_1$1=types$4,ecc_lib_1=ecc_lib,bip341_1$1=bip341,lazy=lazy$8,bech32_1=dist,OPS=bscript$1.OPS,TAPROOT_WITNESS_VERSION=1,ANNEX_PREFIX=80;function p2tr(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||{}),(0,types_1$1.typeforce)({address:types_1$1.typeforce.maybe(types_1$1.typeforce.String),input:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(0)),network:types_1$1.typeforce.maybe(types_1$1.typeforce.Object),output:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(34)),internalPubkey:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),hash:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),pubkey:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),signature:types_1$1.typeforce.maybe(types_1$1.typeforce.anyOf(types_1$1.typeforce.BufferN(64),types_1$1.typeforce.BufferN(65))),witness:types_1$1.typeforce.maybe(types_1$1.typeforce.arrayOf(types_1$1.typeforce.Buffer)),scriptTree:types_1$1.typeforce.maybe(types_1$1.isTaptree),redeem:types_1$1.typeforce.maybe({output:types_1$1.typeforce.maybe(types_1$1.typeforce.Buffer),redeemVersion:types_1$1.typeforce.maybe(types_1$1.typeforce.Number),witness:types_1$1.typeforce.maybe(types_1$1.typeforce.arrayOf(types_1$1.typeforce.Buffer))}),redeemVersion:types_1$1.typeforce.maybe(types_1$1.typeforce.Number)},e);const r=lazy.value(()=>{const l=bech32_1.bech32m.decode(e.address),p=l.words.shift(),u=bech32_1.bech32m.fromWords(l.words);return{version:p,prefix:l.prefix,data:buffer_1.Buffer.from(u)}}),s=lazy.value(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===ANNEX_PREFIX?e.witness.slice(0,-1):e.witness.slice()}),o=lazy.value(()=>{if(e.scriptTree)return(0,bip341_1$1.toHashTree)(e.scriptTree);if(e.hash)return{hash:e.hash}}),n=e.network||networks_1.bitcoin,a={name:"p2tr",network:n};if(lazy.prop(a,"address",()=>{if(!a.pubkey)return;const l=bech32_1.bech32m.toWords(a.pubkey);return l.unshift(TAPROOT_WITNESS_VERSION),bech32_1.bech32m.encode(n.bech32,l)}),lazy.prop(a,"hash",()=>{const l=o();if(l)return l.hash;const p=s();if(p&&p.length>1){const u=p[p.length-1],c=u[0]&types_1$1.TAPLEAF_VERSION_MASK,v=p[p.length-2],w=(0,bip341_1$1.tapleafHash)({output:v,version:c});return(0,bip341_1$1.rootHashFromPath)(u,w)}return null}),lazy.prop(a,"output",()=>{if(a.pubkey)return bscript$1.compile([OPS.OP_1,a.pubkey])}),lazy.prop(a,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:bip341_1$1.LEAF_VERSION_TAPSCRIPT),lazy.prop(a,"redeem",()=>{const l=s();if(!(!l||l.length<2))return{output:l[l.length-2],witness:l.slice(0,-2),redeemVersion:l[l.length-1][0]&types_1$1.TAPLEAF_VERSION_MASK}}),lazy.prop(a,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(a.internalPubkey){const l=(0,bip341_1$1.tweakKey)(a.internalPubkey,a.hash);if(l)return l.x}}),lazy.prop(a,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const l=s();if(l&&l.length>1)return l[l.length-1].slice(1,33)}),lazy.prop(a,"signature",()=>{if(e.signature)return e.signature;const l=s();if(!(!l||l.length!==1))return l[0]}),lazy.prop(a,"witness",()=>{if(e.witness)return e.witness;const l=o();if(l&&e.redeem&&e.redeem.output&&e.internalPubkey){const p=(0,bip341_1$1.tapleafHash)({output:e.redeem.output,version:a.redeemVersion}),u=(0,bip341_1$1.findScriptPath)(l,p);if(!u)return;const c=(0,bip341_1$1.tweakKey)(e.internalPubkey,l.hash);if(!c)return;const v=buffer_1.Buffer.concat([buffer_1.Buffer.from([a.redeemVersion|c.parity]),e.internalPubkey].concat(u));return[e.redeem.output,v]}if(e.signature)return[e.signature]}),t.validate){let l=buffer_1.Buffer.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==TAPROOT_WITNESS_VERSION)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");l=r().data}if(e.pubkey){if(l.length>0&&!l.equals(e.pubkey))throw new TypeError("Pubkey mismatch");l=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==OPS.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(l.length>0&&!l.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");l=e.output.slice(2)}if(e.internalPubkey){const c=(0,bip341_1$1.tweakKey)(e.internalPubkey,a.hash);if(l.length>0&&!l.equals(c.x))throw new TypeError("Pubkey mismatch");l=c.x}if(l&&l.length&&!(0,ecc_lib_1.getEccLib)().isXOnlyPoint(l))throw new TypeError("Invalid pubkey for p2tr");const p=o();if(e.hash&&p&&!e.hash.equals(p.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&p){const c=(0,bip341_1$1.tapleafHash)({output:e.redeem.output,version:a.redeemVersion});if(!(0,bip341_1$1.findScriptPath)(p,c))throw new TypeError("Redeem script not in tree")}const u=s();if(e.redeem&&a.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(bscript$1.decompile(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!e.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&a.redeem.witness&&!stacksEqual(e.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(u&&u.length)if(u.length===1){if(e.signature&&!e.signature.equals(u[0]))throw new TypeError("Signature mismatch")}else{const c=u[u.length-1];if(c.length<33)throw new TypeError(`The control-block length is too small. Got ${c.length}, expected min 33.`);if((c.length-33)%32!==0)throw new TypeError(`The control-block length of ${c.length} is incorrect!`);const v=(c.length-33)/32;if(v>128)throw new TypeError(`The script path is too long. Got ${v}, expected max 128.`);const w=c.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(w))throw new TypeError("Internal pubkey mismatch");if(!(0,ecc_lib_1.getEccLib)().isXOnlyPoint(w))throw new TypeError("Invalid internalPubkey for p2tr witness");const b=c[0]&types_1$1.TAPLEAF_VERSION_MASK,E=u[u.length-2],I=(0,bip341_1$1.tapleafHash)({output:E,version:b}),x=(0,bip341_1$1.rootHashFromPath)(c,I),B=(0,bip341_1$1.tweakKey)(w,x);if(!B)throw new TypeError("Invalid outputKey for p2tr witness");if(l.length&&!l.equals(B.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(B.parity!==(c[0]&1))throw new Error("Incorrect parity")}}return Object.assign(a,e)}p2tr$1.p2tr=p2tr;function stacksEqual(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const t=embed;Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});const r=p2ms$1;Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return r.p2ms}});const s=p2pk$1;Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return s.p2pk}});const o=p2pkh$1;Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return o.p2pkh}});const n=p2sh$1;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return n.p2sh}});const a=p2wpkh$1;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return a.p2wpkh}});const l=p2wsh$1;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return l.p2wsh}});const p=p2tr$1;Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return p.p2tr}})})(payments$1);Object.defineProperty(psbtutils,"__esModule",{value:!0});psbtutils.signatureBlocksAction=psbtutils.checkInputForSig=pubkeyInScript_1=psbtutils.pubkeyInScript=psbtutils.pubkeyPositionInScript=psbtutils.witnessStackToScriptWitness=psbtutils.isP2TR=psbtutils.isP2SHScript=psbtutils.isP2WSHScript=psbtutils.isP2WPKH=psbtutils.isP2PKH=psbtutils.isP2PK=psbtutils.isP2MS=void 0;const varuint=varint,bscript=script,transaction_1$1=transaction,crypto_1=crypto$1,payments=payments$1;function isPaymentFactory(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}psbtutils.isP2MS=isPaymentFactory(payments.p2ms);psbtutils.isP2PK=isPaymentFactory(payments.p2pk);psbtutils.isP2PKH=isPaymentFactory(payments.p2pkh);psbtutils.isP2WPKH=isPaymentFactory(payments.p2wpkh);psbtutils.isP2WSHScript=isPaymentFactory(payments.p2wsh);psbtutils.isP2SHScript=isPaymentFactory(payments.p2sh);psbtutils.isP2TR=isPaymentFactory(payments.p2tr);function witnessStackToScriptWitness(e){let t=Buffer$e.allocUnsafe(0);function r(a){t=Buffer$e.concat([t,Buffer$e.from(a)])}function s(a){const l=t.length,p=varuint.encodingLength(a);t=Buffer$e.concat([t,Buffer$e.allocUnsafe(p)]),varuint.encode(a,t,l)}function o(a){s(a.length),r(a)}function n(a){s(a.length),a.forEach(o)}return n(e),t}psbtutils.witnessStackToScriptWitness=witnessStackToScriptWitness;function pubkeyPositionInScript(e,t){const r=(0,crypto_1.hash160)(e),s=e.slice(1,33),o=bscript.decompile(t);if(o===null)throw new Error("Unknown script error");return o.findIndex(n=>typeof n=="number"?!1:n.equals(e)||n.equals(r)||n.equals(s))}psbtutils.pubkeyPositionInScript=pubkeyPositionInScript;function pubkeyInScript(e,t){return pubkeyPositionInScript(e,t)!==-1}var pubkeyInScript_1=psbtutils.pubkeyInScript=pubkeyInScript;function checkInputForSig(e,t){return extractPartialSigs(e).some(s=>signatureBlocksAction(s,bscript.signature.decode,t))}psbtutils.checkInputForSig=checkInputForSig;function signatureBlocksAction(e,t,r){const{hashType:s}=t(e),o=[];switch(s&transaction_1$1.Transaction.SIGHASH_ANYONECANPAY&&o.push("addInput"),s&31){case transaction_1$1.Transaction.SIGHASH_ALL:break;case transaction_1$1.Transaction.SIGHASH_SINGLE:case transaction_1$1.Transaction.SIGHASH_NONE:o.push("addOutput"),o.push("setInputSequence");break}return o.indexOf(r)===-1}psbtutils.signatureBlocksAction=signatureBlocksAction;function extractPartialSigs(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=getPsigsFromInputFinalScripts(e)}else t=e.partialSig;return t.map(r=>r.signature)}function getPsigsFromInputFinalScripts(e){const t=e.finalScriptSig?bscript.decompile(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?bscript.decompile(e.finalScriptWitness)||[]:[];return t.concat(r).filter(s=>Buffer$e.isBuffer(s)&&bscript.isCanonicalScriptSignature(s)).map(s=>({signature:s}))}Object.defineProperty(bip371,"__esModule",{value:!0});bip371.checkTaprootInputForSigs=bip371.tapTreeFromList=bip371.tapTreeToList=bip371.tweakInternalPubKey=bip371.checkTaprootOutputFields=bip371.checkTaprootInputFields=bip371.isTaprootOutput=bip371.isTaprootInput=bip371.serializeTaprootSignature=bip371.tapScriptFinalizer=toXOnly_1=bip371.toXOnly=void 0;const types_1=types$4,transaction_1=transaction,psbtutils_1=psbtutils,bip341_1=bip341,payments_1=payments$1,psbtutils_2=psbtutils,toXOnly=e=>e.length===32?e:e.slice(1,33);var toXOnly_1=bip371.toXOnly=toXOnly;function tapScriptFinalizer(e,t,r){const s=findTapLeafToFinalize(t,e,r);try{const n=sortSignatures(t,s).concat(s.script).concat(s.controlBlock);return{finalScriptWitness:(0,psbtutils_1.witnessStackToScriptWitness)(n)}}catch(o){throw new Error(`Can not finalize taproot input #${e}: ${o}`)}}bip371.tapScriptFinalizer=tapScriptFinalizer;function serializeTaprootSignature(e,t){const r=t?Buffer$e.from([t]):Buffer$e.from([]);return Buffer$e.concat([e,r])}bip371.serializeTaprootSignature=serializeTaprootSignature;function isTaprootInput(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,psbtutils_1.isP2TR)(e.witnessUtxo.script))}bip371.isTaprootInput=isTaprootInput;function isTaprootOutput(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,psbtutils_1.isP2TR)(t))}bip371.isTaprootOutput=isTaprootOutput;function checkTaprootInputFields(e,t,r){checkMixedTaprootAndNonTaprootInputFields(e,t,r),checkIfTapLeafInTree(e,t,r)}bip371.checkTaprootInputFields=checkTaprootInputFields;function checkTaprootOutputFields(e,t,r){checkMixedTaprootAndNonTaprootOutputFields(e,t,r),checkTaprootScriptPubkey(e,t)}bip371.checkTaprootOutputFields=checkTaprootOutputFields;function checkTaprootScriptPubkey(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,s=t.tapTree||e.tapTree;if(r){const{script:o}=e,n=getTaprootScripPubkey(r,s);if(o&&!o.equals(n))throw new Error("Error adding output. Script or address missmatch.")}}function getTaprootScripPubkey(e,t){const r=t&&tapTreeFromList(t.leaves),{output:s}=(0,payments_1.p2tr)({internalPubkey:e,scriptTree:r});return s}function tweakInternalPubKey(e,t){const r=t.tapInternalKey,s=r&&(0,bip341_1.tweakKey)(r,t.tapMerkleRoot);if(!s)throw new Error(`Cannot tweak tap internal key for input #${e}. Public key: ${r&&r.toString("hex")}`);return s.x}bip371.tweakInternalPubKey=tweakInternalPubKey;function tapTreeToList(e){if(!(0,types_1.isTaptree)(e))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return _tapTreeToList(e)}bip371.tapTreeToList=tapTreeToList;function tapTreeFromList(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:instertLeavesInTree(e)}bip371.tapTreeFromList=tapTreeFromList;function checkTaprootInputForSigs(e,t){return extractTaprootSigs(e).some(s=>(0,psbtutils_2.signatureBlocksAction)(s,decodeSchnorrSignature,t))}bip371.checkTaprootInputForSigs=checkTaprootInputForSigs;function decodeSchnorrSignature(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||transaction_1.Transaction.SIGHASH_DEFAULT}}function extractTaprootSigs(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=getTapKeySigFromWithness(e.finalScriptWitness);r&&t.push(r)}return t}function getTapKeySigFromWithness(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function _tapTreeToList(e,t=[],r=0){if(r>bip341_1.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return e?(0,types_1.isTapleaf)(e)?(t.push({depth:r,leafVersion:e.version||bip341_1.LEAF_VERSION_TAPSCRIPT,script:e.output}),t):(e[0]&&_tapTreeToList(e[0],t,r+1),e[1]&&_tapTreeToList(e[1],t,r+1),t):[]}function instertLeavesInTree(e){let t;for(const r of e)if(t=instertLeafInTree(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function instertLeafInTree(e,t,r=0){if(r>bip341_1.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if((0,types_1.isTapleaf)(t))return;const s=instertLeafInTree(e,t&&t[0],r+1);if(s)return[s,t&&t[1]];const o=instertLeafInTree(e,t&&t[1],r+1);if(o)return[t&&t[0],o]}function checkMixedTaprootAndNonTaprootInputFields(e,t,r){const s=isTaprootInput(e)&&hasNonTaprootFields(t),o=hasNonTaprootFields(e)&&isTaprootInput(t),n=e===t&&isTaprootInput(t)&&hasNonTaprootFields(t);if(s||o||n)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function checkMixedTaprootAndNonTaprootOutputFields(e,t,r){const s=isTaprootOutput(e)&&hasNonTaprootFields(t),o=hasNonTaprootFields(e)&&isTaprootOutput(t),n=e===t&&isTaprootOutput(t)&&hasNonTaprootFields(t);if(s||o||n)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function checkIfTapLeafInTree(e,t,r){if(t.tapMerkleRoot){const s=(t.tapLeafScript||[]).every(n=>isTapLeafInTree(n,t.tapMerkleRoot)),o=(e.tapLeafScript||[]).every(n=>isTapLeafInTree(n,t.tapMerkleRoot));if(!s||!o)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(o=>isTapLeafInTree(o,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function isTapLeafInTree(e,t){if(!t)return!0;const r=(0,bip341_1.tapleafHash)({output:e.script,version:e.leafVersion});return(0,bip341_1.rootHashFromPath)(e.controlBlock,r).equals(t)}function sortSignatures(e,t){const r=(0,bip341_1.tapleafHash)({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(s=>s.leafHash.equals(r)).map(s=>addPubkeyPositionInScript(t.script,s)).sort((s,o)=>o.positionInScript-s.positionInScript).map(s=>s.signature)}function addPubkeyPositionInScript(e,t){return Object.assign({positionInScript:(0,psbtutils_1.pubkeyPositionInScript)(t.pubkey,e)},t)}function findTapLeafToFinalize(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const s=(e.tapLeafScript||[]).sort((o,n)=>o.controlBlock.length-n.controlBlock.length).find(o=>canFinalizeLeaf(o,e.tapScriptSig,r));if(!s)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return s}function canFinalizeLeaf(e,t,r){const s=(0,bip341_1.tapleafHash)({output:e.script,version:e.leafVersion});return(!r||r.equals(s))&&t.find(n=>n.leafHash.equals(s))!==void 0}function hasNonTaprootFields(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const byteToHex=[];for(let e=0;e<256;++e)byteToHex.push((e+256).toString(16).slice(1));function unsafeStringify(e,t=0){return(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(e,t,r){var o;if(native.randomUUID&&!t&&!e)return native.randomUUID();e=e||{};const s=e.random??((o=e.rng)==null?void 0:o.call(e))??rng();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,unsafeStringify(s)}const COMPRESSED_PUBLIC_KEY_HEX_LENGTH=66,NETWORKS={[Network.MAINNET]:{name:"Mainnet",config:bitcoinjsLib.networks.bitcoin,addressPrefix:{common:"bc1",nativeSegWit:"bc1q",taproot:"bc1p"}},[Network.CANARY]:{name:"Canary",config:bitcoinjsLib.networks.bitcoin,addressPrefix:{common:"bc1",nativeSegWit:"bc1q",taproot:"bc1p"}},[Network.TESTNET]:{name:"Testnet",config:bitcoinjsLib.networks.testnet,addressPrefix:{common:"tb1",nativeSegWit:"tb1q",taproot:"tb1p"}},[Network.SIGNET]:{name:"Signet",config:bitcoinjsLib.networks.testnet,addressPrefix:{common:"tb1",nativeSegWit:"tb1q",taproot:"tb1p"}}},getTaprootAddress=(e,t)=>{e.length==COMPRESSED_PUBLIC_KEY_HEX_LENGTH&&(e=e.slice(2));const r=Buffer$e.from(e,"hex"),{address:s,output:o}=bitcoinjsLib.payments.p2tr({internalPubkey:toXOnly_1(r),network:NETWORKS[t].config});if(!s||!o)throw new Error("Failed to generate taproot address or script from public key");return s},getNativeSegwitAddress=(e,t)=>{if(e.length!==COMPRESSED_PUBLIC_KEY_HEX_LENGTH)throw new Error("Invalid public key length for generating native segwit address");const r=Buffer$e.from(e,"hex"),{address:s,output:o}=bitcoinjsLib.payments.p2wpkh({pubkey:r,network:NETWORKS[t].config});if(!s||!o)throw new Error("Failed to generate native segwit address or script from public key");return s};function validateAddressWithPK(e,t,r){return e.startsWith(NETWORKS[r].addressPrefix.taproot)?e===getTaprootAddress(t,r):e.startsWith(NETWORKS[r].addressPrefix.nativeSegWit)?e===getNativeSegwitAddress(t,r):!1}function validateAddress(e,t){const{addressPrefix:r,name:s}=NETWORKS[e];if(!(e in NETWORKS))throw new Error(`Unsupported network: ${e}. Please provide a valid network.`);if(!t.startsWith(r.common))throw new Error(`Incorrect address prefix for ${s}. Expected address to start with '${r}'.`)}const toNetwork=e=>NETWORKS[e].config,WALLET_PROVIDER_NAME$3="Keystone";class KeystoneProvider{constructor(t,r){at(this,"keystoneWaleltInfo");at(this,"viewSDK");at(this,"dataSdk");at(this,"config");at(this,"connectWallet",async()=>{const r=await(await this.viewSDK.getSdk()).read([sdk$1.SupportedResult.UR_CRYPTO_ACCOUNT],{title:"Sync Keystone with Babylon Staking App",description:"Please scan the QR code displayed on your Keystone, Currently only the first Taproot Address will be used",renderInitial:{walletMode:"btc",link:"",description:["1. Turn on your Keystone 3 with BTC only firmware.",'2. Click connect software wallet and use "Sparrow" for connection.','3. Press the "Sync Keystone" button and scan the QR Code displayed on your Keystone hardware wallet',"4. The first Taproot address will be used for staking."]},URTypeErrorMessage:"The scanned QR code is not the sync code from the Keystone hardware wallet. Please verify the code and try again."});if(r.status===sdk$1.ReadStatus.canceled)throw new Error("Connection to Keystone was canceled");if(r.status!==sdk$1.ReadStatus.success)throw new Error("Error reading QR code, Please try again.");const s=this.dataSdk.parseAccount(r.result),o=3,n=s.keys[o].extendedPublicKey;if(this.keystoneWaleltInfo={mfp:s.masterFingerprint,extendedPublicKey:n,path:s.keys[o].path,address:void 0,publicKeyHex:void 0,scriptPubKeyHex:void 0},!this.keystoneWaleltInfo.extendedPublicKey)throw new Error("Could not retrieve the extended public key");const{address:a,pubkeyHex:l,scriptPubKeyHex:p}=generateP2trAddressFromXpub(this.keystoneWaleltInfo.extendedPublicKey,"M/0/0",toNetwork(this.config.network));this.keystoneWaleltInfo.address=a,this.keystoneWaleltInfo.publicKeyHex=l,this.keystoneWaleltInfo.scriptPubKeyHex=p});at(this,"getAddress",async()=>{var t;if(!((t=this.keystoneWaleltInfo)!=null&&t.address))throw new Error("Could not retrieve the address");return this.keystoneWaleltInfo.address});at(this,"getPublicKeyHex",async()=>{var t;if(!((t=this.keystoneWaleltInfo)!=null&&t.publicKeyHex))throw new Error("Could not retrieve the BTC public key");return this.keystoneWaleltInfo.publicKeyHex});at(this,"signPsbt",async t=>{var n,a;if(!((n=this.keystoneWaleltInfo)!=null&&n.address)||!((a=this.keystoneWaleltInfo)!=null&&a.publicKeyHex))throw new Error("Keystone Wallet not connected");if(!t)throw new Error("psbt hex is required");let r=bitcoinjsLib.Psbt.fromHex(t);r=this.enhancePsbt(r);const s=r.toHex();return(await this.sign(s)).toHex()});at(this,"signPsbts",async t=>{var s,o;if(!((s=this.keystoneWaleltInfo)!=null&&s.address)||!((o=this.keystoneWaleltInfo)!=null&&o.publicKeyHex))throw new Error("Keystone Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");const r=[];for(const n of t){const a=await this.signPsbt(n);r.push(a)}return r});at(this,"getNetwork",async()=>this.config.network);at(this,"signMessage",async(t,r)=>{if(r!=="ecdsa")throw new Error("Only ECDSA signature is supported");if(!this.keystoneWaleltInfo)throw new Error("Keystone Wallet not connected");const s=this.dataSdk.btc.generateSignRequest({requestId:v4(),signData:Buffer$1$1.from(t,"utf-8").toString("hex"),dataType:dist$v.KeystoneBitcoinSDK.DataType.message,accounts:[{path:`${this.keystoneWaleltInfo.path}/0/0`,xfp:`${this.keystoneWaleltInfo.mfp}`,address:this.keystoneWaleltInfo.address}],origin:"babylon staking app"}),o=composeQRProcess(sdk$1.SupportedResult.UR_BTC_SIGNATURE),n=await this.viewSDK.getSdk(),a=await o(n,s),l=this.dataSdk.btc.parseSignature(a);return Buffer$1$1.from(l.signature,"hex").toString("base64")});at(this,"getInscriptions",async()=>{throw new Error("Method not implemented.")});at(this,"on",()=>{});at(this,"off",()=>{});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$3);at(this,"getWalletProviderIcon",async()=>logo$3);at(this,"sign",async t=>{if(!t)throw new Error("psbt hex is required");const r=this.dataSdk.btc.generatePSBT(Buffer$1$1.from(t,"hex")),s=composeQRProcess(sdk$1.SupportedResult.UR_PSBT),o=await this.viewSDK.getSdk(),n=await s(o,r),a=this.dataSdk.btc.parsePSBT(n),l=bitcoinjsLib.Psbt.fromHex(a);return l.finalizeAllInputs(),l});at(this,"enhancePsbt",t=>{var s,o,n,a;if(!((s=this.keystoneWaleltInfo)!=null&&s.scriptPubKeyHex)||!((o=this.keystoneWaleltInfo)!=null&&o.publicKeyHex)||!((n=this.keystoneWaleltInfo)!=null&&n.mfp)||!((a=this.keystoneWaleltInfo)!=null&&a.path))throw new Error("Keystone Wallet not connected");const r={masterFingerprint:Buffer$1$1.from(this.keystoneWaleltInfo.mfp,"hex"),path:`${this.keystoneWaleltInfo.path}/0/0`,pubkey:Buffer$1$1.from(this.keystoneWaleltInfo.publicKeyHex,"hex")};return t.data.inputs.forEach(l=>{l.tapBip32Derivation=[{...r,pubkey:toXOnly_1(r.pubkey),leafHashes:caculateTapLeafHash(l,r.pubkey)}]}),t});this.config=r,sdk$1.viewSdk.bootstrap(),this.viewSDK=sdk$1.viewSdk,this.dataSdk=new dist$v.KeystoneSDK({origin:"babylon staking app"})}}const composeQRProcess=e=>async(t,r)=>{if(await t.play(r,{title:"Scan the QR Code",description:"Please scan the QR code with your Keystone device."})!==sdk$1.PlayStatus.success)throw new Error("Could not generate the QR code, please try again.");const o=await t.read([e],{title:"Get the Signature from Keystone",description:"Please scan the QR code displayed on your Keystone",URTypeErrorMessage:"The scanned QR code can't be read. please verify and try again."});if(o.status!==sdk$1.ReadStatus.success)throw new Error("Could not extract the signature, please try again.");return o.result},generateP2trAddressFromXpub=(e,t,r)=>{const o=HDKey.fromExtendedKey(e).derive(t),n=Buffer$1$1.from(o.publicKey),a=toXOnly_1(n);let l,p;try{const u=bitcoinjsLib.payments.p2tr({internalPubkey:a,network:r});l=u.address,p=u.output}catch(u){if(u instanceof Error&&u.message.includes("ECC")){btcStakingTs.initBTCCurve();const c=bitcoinjsLib.payments.p2tr({internalPubkey:a,network:r});l=c.address,p=c.output}else throw new Error(u)}return{address:l,pubkeyHex:n.toString("hex"),scriptPubKeyHex:p.toString("hex")}},caculateTapLeafHash=(e,t)=>e.tapInternalKey&&!e.tapLeafScript?[]:(e.tapLeafScript||[]).filter(s=>pubkeyInScript_1(t,s.script)).map(s=>{const o=bip341.tapleafHash({output:s.script,version:s.leafVersion});return Object.assign({hash:o},s)}).map(s=>s.hash),metadata$5={id:"keystone",name:WALLET_PROVIDER_NAME$3,icon:logo$3,docs:"https://www.keyst.one/btc-only",createProvider:(e,t)=>new KeystoneProvider(e,t),networks:[Network.MAINNET,Network.SIGNET],label:"Hardware wallet"},logo$2="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='225px'%20height='224px'%20viewBox='0%200%20225%20224'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eokx%3c/title%3e%3cg%20id='Page-1'%20stroke='none'%20strokeWidth='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='okx'%20transform='translate(0.401000,%200.006000)'%20fill='%23000000'%20fill-rule='nonzero'%3e%3cpath%20d='M144.382,74.667%20L79.673,74.667%20C76.924,74.667%2074.695,76.895%2074.695,79.644%20L74.695,144.354%20C74.695,147.103%2076.924,149.332%2079.673,149.332%20L144.382,149.332%20C147.131,149.332%20149.36,147.103%20149.36,144.354%20L149.36,79.644%20C149.36,76.895%20147.131,74.667%20144.382,74.667%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,0%20L4.978,0%20C2.229,0%200,2.228%200,4.978%20L0,69.687%20C0,72.436%202.229,74.665%204.978,74.665%20L69.687,74.665%20C72.437,74.665%2074.665,72.436%2074.665,69.687%20L74.665,4.978%20C74.665,2.228%2072.437,0%2069.687,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,0%20L154.307,0%20C151.558,0%20149.329,2.228%20149.329,4.978%20L149.329,69.687%20C149.329,72.436%20151.558,74.665%20154.307,74.665%20L219.017,74.665%20C221.766,74.665%20223.994,72.436%20223.994,69.687%20L223.994,4.978%20C223.994,2.228%20221.766,0%20219.017,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,149.328%20L4.978,149.328%20C2.229,149.328%200,151.556%200,154.305%20L0,219.015%20C0,221.764%202.229,223.993%204.978,223.993%20L69.687,223.993%20C72.437,223.993%2074.665,221.764%2074.665,219.015%20L74.665,154.305%20C74.665,151.556%2072.437,149.328%2069.687,149.328%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,149.328%20L154.307,149.328%20C151.558,149.328%20149.329,151.556%20149.329,154.305%20L149.329,219.015%20C149.329,221.764%20151.558,223.993%20154.307,223.993%20L219.017,223.993%20C221.766,223.993%20223.994,221.764%20223.994,219.015%20L223.994,154.305%20C223.994,151.556%20221.766,149.328%20219.017,149.328%20Z'%20id='Path'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e",PROVIDER_NAMES={[Network.MAINNET]:"bitcoin",[Network.CANARY]:"bitcoin",[Network.TESTNET]:"bitcoinTestnet",[Network.SIGNET]:"bitcoinSignet"},WALLET_PROVIDER_NAME$2="OKX";class OKXProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var o;try{await this.wallet.enable()}catch(n){throw(o=n==null?void 0:n.message)!=null&&o.includes("rejected")?new Error("Connection to OKX Wallet was rejected"):new Error(n==null?void 0:n.message)}let t;try{t=await this.provider.connect()}catch{throw new Error(`BTC ${this.config.network} is not enabled in OKX Wallet`)}const{address:r,compressedPublicKey:s}=t;if(validateAddress(this.config.network,r),s&&r)this.walletInfo={publicKeyHex:s,address:r};else throw new Error("Could not connect to OKX Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signPsbt(t)});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signPsbts(t)});at(this,"getNetwork",async()=>{if(!this.config.network)throw new Error("Network not set");return this.config.network});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on OKX Wallet BTC mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from OKX Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(t==="accountChanged")return this.provider.on(t,r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(t==="accountChanged")return this.provider.off(t,r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$2);at(this,"getWalletProviderIcon",async()=>logo$2);if(this.wallet=t,this.config=r,!t)throw new Error("OKX Wallet extension not found");const s=PROVIDER_NAMES[r.network];if(!s)throw new Error("Unsupported network");this.provider=t[s]}}const metadata$4={id:"okx",name:WALLET_PROVIDER_NAME$2,icon:logo$2,docs:"https://www.okx.com/web3",wallet:"okxwallet",createProvider:(e,t)=>new OKXProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$1="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_45922_88)'%3e%3cpath%20d='M127.61%2063.8049C127.61%20107.853%20107.853%20127.61%2063.8049%20127.61C19.7568%20127.61%200%20107.853%200%2063.8049C0%2019.7568%2019.7568%200%2063.8049%200C107.853%200%20127.61%2019.7568%20127.61%2063.8049Z'%20fill='%233BD23D'/%3e%3cpath%20d='M69.5699%2027.0557L51.8197%2027.0557L48.7056%2036.4719H58.5645L58.5645%2056.3063H69.5699V27.0557Z'%20fill='black'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M84.0486%2080.3111C84.0486%2091.4912%2074.9854%20100.554%2063.8053%20100.554C52.6253%20100.554%2043.5621%2091.4912%2043.5621%2080.3111C43.5621%2069.1311%2052.6253%2060.0678%2063.8053%2060.0678C74.9854%2060.0678%2084.0486%2069.1311%2084.0486%2080.3111ZM74.8584%2080.3111C74.8584%2086.4155%2069.9097%2091.3641%2063.8053%2091.3641C57.7008%2091.3641%2052.7522%2086.4155%2052.7522%2080.3111C52.7522%2074.2066%2057.7008%2069.258%2063.8053%2069.258C69.9097%2069.258%2074.8584%2074.2066%2074.8584%2080.3111Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_45922_88'%3e%3crect%20width='128'%20height='128'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",INTERNAL_NETWORK_NAMES={[Network.MAINNET]:"livenet",[Network.TESTNET]:"testnet",[Network.SIGNET]:"signet"},WALLET_PROVIDER_NAME$1="OneKey";class OneKeyProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var s;try{await this.provider.connectWallet()}catch(o){throw(s=o==null?void 0:o.message)!=null&&s.includes("rejected")?new Error("Connection to OneKey Wallet was rejected"):new Error(o==null?void 0:o.message)}const t=await this.provider.getAddress();validateAddress(this.config.network,t);const r=await this.provider.getPublicKeyHex();if(r&&t)this.walletInfo={publicKeyHex:r,address:t};else throw new Error("Could not connect to OneKey Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(!t)throw new Error("psbt hex is required");return this.provider.signPsbt(t)});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");return this.provider.signPsbts(t)});at(this,"getNetwork",async()=>{const t=await this.provider.getNetwork();for(const[r,s]of Object.entries(INTERNAL_NETWORK_NAMES)){if(s==="testnet")return Network.SIGNET;if(s===t)return r}throw new Error("Unsupported network")});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on OneKey Wallet BTC Mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from OneKey Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(t==="accountChanged")return this.provider.on(t,r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(t==="accountChanged")return this.provider.off(t,r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$1);at(this,"getWalletProviderIcon",async()=>logo$1);if(this.config=r,!(t!=null&&t.btcwallet))throw new Error("OneKey Wallet extension not found");this.provider=t.btcwallet}}const metadata$3={id:"onekey",name:WALLET_PROVIDER_NAME$1,icon:logo$1,docs:"https://onekey.so/download",wallet:"$onekey",createProvider:(e,t)=>new OneKeyProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='59'%20height='59'%3e%3cdefs%3e%3clinearGradient%20id='a'%20x1='91.9%25'%20x2='5.127%25'%20y1='28.561%25'%20y2='67.452%25'%3e%3cstop%20offset='0%25'%20stop-color='%23070100'/%3e%3cstop%20offset='36%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='67%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='100%25'%20stop-color='%23F4B852'/%3e%3c/linearGradient%3e%3clinearGradient%20id='b'%20x1='10.514%25'%20x2='111.046%25'%20y1='63.228%25'%20y2='37.55%25'%3e%3cstop%20offset='0%25'%20stop-color='%23070100'/%3e%3cstop%20offset='37%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='67%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='100%25'%20stop-color='%23F4FB52'/%3e%3c/linearGradient%3e%3cradialGradient%20id='c'%20cx='49.933%25'%20cy='50.067%25'%20r='50%25'%20fx='49.933%25'%20fy='50.067%25'%3e%3cstop%20offset='0%25'%20stop-color='%23F4B852'/%3e%3cstop%20offset='33%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='64%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='100%25'%20stop-color='%23070100'/%3e%3c/radialGradient%3e%3c/defs%3e%3cg%20fill='none'%20fill-rule='nonzero'%20transform='translate(7%201)'%3e%3cpath%20fill='url(%23a)'%20d='m31.764%205.2%2011.761%2011.745c1%20.997%201.492%202.006%201.475%203.027-.018%201.014-.446%201.947-1.29%202.787-.879.88-1.827%201.33-2.845%201.347-1.017.018-2.023-.478-3.03-1.475L25.81%2010.617c-1.365-1.364-2.683-2.332-3.955-2.898-1.267-.566-2.602-.653-4.002-.268-1.399.385-2.902%201.382-4.51%202.991-2.22%202.217-3.278%204.298-3.168%206.246.11%201.948%201.208%203.96%203.301%206.054L25.6%2034.854c1.012%201.01%201.51%202.018%201.492%203.021-.017%201.003-.45%201.936-1.307%202.788-.855.851-1.792%201.3-2.821%201.335-1.024.035-2.041-.455-3.053-1.464L8.16%2028.79c-1.913-1.913-3.295-3.72-4.145-5.423-.85-1.703-1.168-3.633-.949-5.785.197-1.843.787-3.628%201.758-5.36.977-1.732%202.37-3.499%204.18-5.313%202.157-2.157%204.216-3.808%206.182-4.957C17.153.803%2019.049.161%2020.882.027c1.833-.134%203.643.233%205.435%201.102%201.787.869%203.603%202.222%205.453%204.07h-.006Z'/%3e%3cpath%20fill='url(%23b)'%20d='M13.234%2051.841%201.474%2040.188c-1-.99-1.49-1.99-1.474-3.003.018-1.012.446-1.932%201.29-2.766.878-.873%201.827-1.319%202.844-1.336%201.018-.017%202.024.469%203.03%201.464l12.025%2011.919c1.37%201.354%202.682%202.314%203.954%202.876%201.272.56%202.602.648%204%20.266%201.4-.382%202.903-1.372%204.51-2.968%202.22-2.2%203.278-4.265%203.169-6.197-.11-1.933-1.209-3.935-3.302-6.006l-6.457-6.347c-1.012-1.001-1.51-2.002-1.492-2.998.017-.995.451-1.92%201.307-2.765.855-.845%201.792-1.29%202.82-1.325%201.024-.035%202.042.451%203.053%201.452l6.088%205.983c1.914%201.898%203.296%203.691%204.145%205.38.85%201.69%201.168%203.605.949%205.74-.197%201.829-.787%203.6-1.758%205.318-.977%201.718-2.37%203.471-4.18%205.27-2.156%202.142-4.214%203.78-6.18%204.919-1.966%201.14-3.862%201.776-5.695%201.91-1.832.132-3.642-.232-5.434-1.094-1.787-.862-3.608-2.205-5.452-4.039Z'/%3e%3ccircle%20cx='20'%20cy='18'%20r='4'%20fill='url(%23c)'/%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME="Unisat";class UnisatProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var o;let t;try{t=await this.provider.requestAccounts()}catch(n){throw(o=n==null?void 0:n.message)!=null&&o.includes("rejected")?new Error("Connection to Unisat Wallet was rejected"):new Error(n==null?void 0:n.message)}const r=t[0];validateAddress(this.config.network,r);const s=await this.provider.getPublicKey();if(s&&r)this.walletInfo={publicKeyHex:s,address:r};else throw new Error("Could not connect to Unisat Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(!t)throw new Error("psbt hex is required");const r=await this.getNetwork();try{return await this.provider.signPsbt(t,this.getSignPsbtDefaultOptions(t,r))}catch(s){throw new Error((s==null?void 0:s.message)||s)}});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");const r=await this.getNetwork();try{return await this.provider.signPsbts(t,t.map(s=>this.getSignPsbtDefaultOptions(s,r)))}catch(s){throw new Error((s==null?void 0:s.message)||s)}});at(this,"getNetwork",async()=>{switch((await this.provider.getChain()).enum){case"BITCOIN_MAINNET":return Network.MAINNET;case"BITCOIN_SIGNET":return Network.SIGNET;case"BITCOIN_TESTNET":return Network.SIGNET;default:throw new Error("Unsupported network")}});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on Unisat Wallet BTC Mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from Unisat Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(t==="accountChanged")return this.provider.on("accountsChanged",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(t==="accountChanged")return this.provider.removeListener("accountsChanged",r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME);at(this,"getWalletProviderIcon",async()=>logo);if(this.config=r,!t)throw new Error("Unisat Wallet extension not found");this.provider=t}getSignPsbtDefaultOptions(t,r){const s=[];return bitcoinjsLib.Psbt.fromHex(t).data.inputs.forEach((n,a)=>{var u,c;let l=!1;if(n.witnessUtxo&&n.witnessUtxo.script){let v=bitcoinjsLib.networks.bitcoin;(r===Network.TESTNET||r===Network.SIGNET)&&(v=bitcoinjsLib.networks.testnet);let w;try{w=bitcoinjsLib.address.fromOutputScript(n.witnessUtxo.script,v)}catch(I){if(I instanceof Error&&I.message.toLowerCase().includes("has no matching address"))btcStakingTs.initBTCCurve(),w=bitcoinjsLib.address.fromOutputScript(n.witnessUtxo.script,v);else throw new Error(I)}const b=w.indexOf("tb1p")===0||w.indexOf("bc1p")===0,E=w===((u=this.walletInfo)==null?void 0:u.address);b&&E&&(l=!0)}n.finalScriptSig||n.finalScriptWitness||s.push({index:a,publicKey:(c=this.walletInfo)==null?void 0:c.publicKeyHex,sighashTypes:void 0,useTweakedSigner:l})}),{autoFinalized:!0,toSignInputs:s}}}const metadata$2={id:"unisat",name:WALLET_PROVIDER_NAME,icon:logo,docs:"https://unisat.io/download",wallet:"unisat",createProvider:(e,t)=>new UnisatProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},metadata$1={chain:"BTC",name:"Bitcoin",icon,wallets:[metadata$6,metadata$4,metadata$3,metadata$2,metadata$5]},metadata={BTC:metadata$1,BBN:metadata$7};function usePersistState(e,t,r){function s(){const a=r;if(typeof t>"u")return a;const l=t.getItem(e);return(l?JSON.parse(l):null)??a}const[o,n]=react.useState(s);return react.useEffect(function(){t.setItem(e,JSON.stringify(o??""))},[e,t,o]),[o,n]}const Context$2=react.createContext({lockInscriptions:!0,showAgain:!0});function InscriptionProvider({children:e,context:t}){const[r,s]=usePersistState("bwc-inscription-modal-show-again",t.localStorage,!0),[o,n]=usePersistState("bwc-inscription-modal-lock",t.localStorage,!0),a=react.useMemo(()=>({showAgain:r,lockInscriptions:o,toggleLockInscriptions:n,toggleShowAgain:s}),[r,o,n,s]);return jsxRuntime.jsx(Context$2.Provider,{value:a,children:e})}const useInscriptionProvider=()=>react.useContext(Context$2),defaultState$2={confirmed:!1,visible:!1,screen:{type:"TERMS_OF_SERVICE"},chains:{},selectedWallets:{}},StateContext=react.createContext(defaultState$2);function StateProvider({children:e,chains:t}){const[r,s]=react.useState(defaultState$2);react.useEffect(()=>{s(a=>({...a,chains:t.reduce((l,p)=>({...l,[p.id]:p}),{})}))},[t]);const o=react.useMemo(()=>({open:()=>{s(a=>({...a,visible:!0}))},close:()=>{s(a=>({...a,visible:!1}))},reset:()=>{s(({chains:a})=>({...defaultState$2,chains:a}))},displayLoader:(a="")=>{s(l=>({...l,screen:{type:"LOADER",params:{message:a}}}))},displayTermsOfService:()=>{s(a=>({...a,screen:{type:"TERMS_OF_SERVICE"}}))},displayChains:()=>{s(a=>({...a,screen:{type:"CHAINS"}}))},displayWallets:a=>{s(l=>({...l,screen:{type:"WALLETS",params:{chain:a}}}))},displayInscriptions:()=>{s(a=>({...a,screen:{type:"INSCRIPTIONS"}}))},displayError:a=>{s(l=>({...l,screen:{type:"ERROR",params:a}}))},selectWallet:(a,l)=>{s(p=>({...p,selectedWallets:{...p.selectedWallets,[a]:l}}))},removeWallet:a=>{s(l=>({...l,selectedWallets:{...l.selectedWallets,[a]:void 0}}))},confirm:()=>{s(a=>({...a,confirmed:!0}))}}),[]),n=react.useMemo(()=>({...r,...o}),[r,o]);return jsxRuntime.jsx(StateContext.Provider,{value:n,children:e})}const defaultState$1={BTC:null,BBN:null},Context$1=react.createContext(defaultState$1);function ChainProvider({storage:e,children:t,context:r,config:s,onError:o}){const[n,a]=react.useState(defaultState$1),l=react.useCallback(async()=>{const u=s.filter(v=>metadata[v.chain]).map(({chain:v,config:w})=>createWalletConnector({metadata:metadata[v],context:r,config:w,accountStorage:e}));return(await Promise.all(u)).reduce((v,w)=>({...v,[w.id]:w}),{})},[]);react.useEffect(()=>{l().then(u=>{a(u)}).catch(o)},[a,l,o]);const p=react.useMemo(()=>Object.values(n).filter(Boolean),[n]);return jsxRuntime.jsx(InscriptionProvider,{context:r,children:jsxRuntime.jsx(StateProvider,{chains:p,children:jsxRuntime.jsx(Context$1.Provider,{value:n,children:t})})})}const useChainProviders=()=>react.useContext(Context$1),Context=react.createContext({});function LifeCycleHooksProvider({children:e,value:t}){const r=react.useMemo(()=>t??{},[t]);return jsxRuntime.jsx(Context.Provider,{value:r,children:e})}const useLifeCycleHooks=()=>react.useContext(Context),CONNECTED_ACCOUNTS_KEY="baby-connected-wallet-accounts",createAccountStorage=e=>({get:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};if(!(r._timestamp&&Date.now()-r._timestamp>e))return r[t]},has:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};return r._timestamp&&Date.now()-r._timestamp>e?!1:!!r[t]},set:(t,r)=>{const s=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};s[t]=r,s._timestamp=Date.now(),localStorage.setItem(CONNECTED_ACCOUNTS_KEY,JSON.stringify(s))},delete:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{},s=Reflect.deleteProperty(r,t);return localStorage.setItem(CONNECTED_ACCOUNTS_KEY,JSON.stringify(r)),s}});var freeGlobal=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self;freeGlobal||freeSelf||Function("return this")();var useIsomorphicLayoutEffect=typeof window<"u"?react.useLayoutEffect:react.useEffect,IS_SERVER2=typeof window>"u";function useMediaQuery(e,{defaultValue:t=!1,initializeWithValue:r=!0}={}){const s=l=>IS_SERVER2?t:window.matchMedia(l).matches,[o,n]=react.useState(()=>r?s(e):t);function a(){n(s(e))}return useIsomorphicLayoutEffect(()=>{const l=window.matchMedia(e);return a(),l.addListener?l.addListener(a):l.addEventListener("change",a),()=>{l.removeListener?l.removeListener(a):l.removeEventListener("change",a)}},[e]),o}const useIsMobileView=()=>useMediaQuery("(max-width: 768px)");function ResponsiveDialog(e){const r=useIsMobileView()?coreUi.MobileDialog:coreUi.Dialog;return jsxRuntime.jsx(r,{...e})}const useWidgetState=()=>react.useContext(StateContext);function useWalletConnect(){const{confirmed:e,chains:t,selectedWallets:r,open:s,reset:o}=useWidgetState(),n=useChainProviders(),a=react.useCallback(()=>{o==null||o(),s==null||s()},[s,o]),l=react.useCallback(async()=>{for(const u of Object.values(n))u&&await u.disconnect();o==null||o()},[n,o]),p=react.useMemo(()=>Object.values(t).filter(Boolean).map(v=>r[v.id]).every(Boolean),[t,r]);return{selected:p,connected:p&&e,open:a,disconnect:l}}const ANIMATION_DELAY$1=1e3;function useWalletConnectors({accountStorage:e,onError:t}){const r=useChainProviders(),{selectWallet:s,removeWallet:o,displayLoader:n,displayChains:a,displayInscriptions:l,displayError:p,confirm:u,close:c,reset:v}=useWidgetState(),{showAgain:w}=useInscriptionProvider(),{verifyBTCAddress:b}=useLifeCycleHooks();react.useEffect(()=>{const B=Object.values(r).filter(Boolean).map(M=>M.on("connecting",q=>{n==null||n(q)}));return()=>B.forEach(M=>M())},[n,r]),react.useEffect(()=>{const x=Object.values(r).filter(Boolean),B={BTC:q=>async U=>{var j,y,T;U&&(s==null||s("BTC",U),e.set(q.id,U.id));const F=()=>void(w?l==null?void 0:l():a==null?void 0:a());if(!validateAddressWithPK(((j=U.account)==null?void 0:j.address)??"",((y=U.account)==null?void 0:y.publicKeyHex)??"",q.config.network)){p==null||p({title:"Public Key Mismatch",description:"The Bitcoin address and Public Key for this wallet do not match. Please contact your wallet provider for support.",onSubmit:F,onCancel:()=>{o==null||o(q.id),a==null||a()}});return}if(b&&!await b(((T=U.account)==null?void 0:T.address)??"")){for(const D of x)await D.disconnect();p==null||p({title:"Connection Failed",description:"The wallet cannot be connected.",submitButton:"",cancelButton:"Done",onCancel:async()=>{c==null||c(),setTimeout(()=>void(v==null?void 0:v()),ANIMATION_DELAY$1)}});return}F()},BBN:q=>U=>{U&&(s==null||s(q.id,U),e.set(q.id,U.id)),a==null||a()}},M=x.map(q=>{var U;return q.on("connect",(U=B[q.id])==null?void 0:U.call(B,q))});return x.forEach(q=>{s==null||s(q.id,q.connectedWallet)}),()=>M.forEach(q=>q())},[s,o,l,a,b,v,c,r,w]),react.useEffect(()=>{const B=Object.values(r).filter(Boolean).map(M=>M.on("disconnect",q=>{q&&(o==null||o(M.id),a==null||a(),e.delete(M.id))}));return()=>B.forEach(M=>M())},[o,a,r]),react.useEffect(()=>{const B=Object.values(r).filter(Boolean).map(M=>M.on("error",q=>{t==null||t(q),a==null||a()}));return()=>B.forEach(M=>M())},[t,a,r]),react.useEffect(()=>{const x=Object.values(r).filter(Boolean);x.length&&x.every(B=>e.has(B.id))&&(u==null||u(),a==null||a())},[r,u,a]);const E=react.useCallback(async(x,B)=>{const M=r[x.id];await(M==null?void 0:M.connect(B.id))},[r]),I=react.useCallback(async x=>{const B=r[x];await(B==null?void 0:B.disconnect())},[r]);return{connect:E,disconnect:I}}function useWalletWidgets(e,t){const r=react.useCallback((s,o)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:o.map(({id:n,widget:a})=>jsxRuntime.jsx(a,{id:n,connector:e[s],createWallet:createExternalWallet},n))}),[e]);return react.useMemo(()=>t.reduce((s,o)=>({...s,[o.chain]:r(o.chain,o.connectors??[])}),{}),[r,t])}function ChainButton({className:e,disabled:t,alt:r,logo:s,title:o,children:n,onClick:a}){const l=typeof s=="string"?jsxRuntime.jsx(coreUi.Avatar,{url:s,alt:r}):jsxRuntime.jsx(coreUi.Avatar,{children:s});return jsxRuntime.jsxs(coreUi.Text,{disabled:t,as:t?"div":"button",className:tailwindMerge.twMerge("flex w-full flex-col gap-2.5 rounded border border-secondary-strokeLight bg-surface p-4 text-accent-primary",t?"pointer-events-none":"pointer-events-auto",t?"cursor-default":"cursor-pointer",e),onClick:a,children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2.5",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:l}),o,!t&&jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"ml-auto block",children:jsxRuntime.jsx("path",{d:"M8.58984 16.59L13.1698 12L8.58984 7.41L9.99984 6L15.9998 12L9.99984 18L8.58984 16.59Z",fill:"currentColor"})})]}),n&&jsxRuntime.jsx("div",{className:"pointer-events-auto w-full",onClick:p=>p.stopPropagation(),children:n})]})}const formatAddress=(e,t=8)=>e.length<=t?e:t===0?"...":`${e.slice(0,t/2)}...${e.slice(-t/2)}`,ConnectedWallet=react.memo(({className:e,chainId:t,logo:r,name:s,address:o,onDisconnect:n})=>jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex shrink-0 items-center gap-2.5 rounded border border-secondary-main/30 p-2",e),children:[jsxRuntime.jsx(coreUi.Avatar,{variant:"rounded",size:"medium",url:r}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col items-start",children:[jsxRuntime.jsx(coreUi.Text,{as:"div",variant:"body2",className:"leading-4 text-accent-primary",children:s}),!!o&&jsxRuntime.jsx(coreUi.Text,{as:"div",variant:"caption",className:"leading-4 text-accent-secondary",children:formatAddress(o)})]}),jsxRuntime.jsx("button",{className:"shrink-0 cursor-pointer",onClick:()=>void(n==null?void 0:n(t)),children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",className:"text-secondary-main",fill:"none",children:jsxRuntime.jsx("path",{d:"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",fill:"currentColor"})})})]})),Chains=react.memo(({disabled:e=!1,chains:t,selectedWallets:r={},className:s,onClose:o,onConfirm:n,onSelectChain:a,onDisconnectWallet:l})=>jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col text-accent-primary",s),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"mb-10",title:"Connect Wallets",onClose:o,children:jsxRuntime.jsx(coreUi.Text,{className:"text-accent-secondary",children:"Connect to both Bitcoin and Babylon Chain Wallets"})}),jsxRuntime.jsx(coreUi.DialogBody,{className:"flex flex-col gap-6",children:t.map(p=>{var c;const u=r[p.id];return jsxRuntime.jsx(ChainButton,{disabled:!!u,title:`Select ${p.name} Wallet`,logo:p.icon,alt:p.name,onClick:()=>void(a==null?void 0:a(p)),children:u&&jsxRuntime.jsx(ConnectedWallet,{chainId:p.id,logo:u.icon,name:u.name,address:((c=u.account)==null?void 0:c.address)??"",onDisconnect:l})},p.id)})}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"mt-auto flex gap-4 pt-10",children:[jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:o,children:"Cancel"}),jsxRuntime.jsx(coreUi.Button,{disabled:e,fluid:!0,onClick:n,children:"Done"})]})]}));function ChainsContainer(e){const{chains:t,selectedWallets:r,displayWallets:s}=useWidgetState(),{selected:o}=useWalletConnect(),n=react.useMemo(()=>Object.values(t),[t]),a=react.useCallback(l=>{s==null||s(l.id)},[s]);return jsxRuntime.jsx(Chains,{disabled:!o,chains:n,selectedWallets:r,onSelectChain:a,...e})}const DEFAULT_ICON=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"52",height:"52",viewBox:"0 0 52 52",fill:"none",children:jsxRuntime.jsx("path",{d:"M2.16675 46.5837H49.8334L26.0001 5.41699L2.16675 46.5837ZM28.1667 40.0837H23.8334V35.7503H28.1667V40.0837ZM28.1667 31.417H23.8334V22.7503H28.1667V31.417Z",fill:"#387085"})});function Error$1({className:e,icon:t=DEFAULT_ICON,title:r,description:s,cancelButton:o="Cancel",submitButton:n=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Continue ",jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Anyway"})]}),onCancel:a,onSubmit:l}){return jsxRuntime.jsxs("div",{className:e,children:[jsxRuntime.jsxs(coreUi.DialogBody,{className:"py-16 text-center",children:[jsxRuntime.jsx("div",{className:"mb-6 inline-flex h-20 w-20 items-center justify-center bg-primary-contrast text-primary-light",children:t}),jsxRuntime.jsx(coreUi.Heading,{variant:"h4",className:"mb-4 text-accent-primary",children:r}),jsxRuntime.jsx(coreUi.Text,{as:"div",className:"text-accent-secondary",children:s})]}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"flex gap-4",children:[o&&jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:a,children:o}),n&&jsxRuntime.jsx(coreUi.Button,{fluid:!0,onClick:l,children:n})]})]})}function ErrorContainer({className:e}){const{screen:t}=useWidgetState(),{icon:r,title:s,description:o,cancelButton:n,submitButton:a,onCancel:l,onSubmit:p}=t.params??{};return jsxRuntime.jsx(Error$1,{className:e,icon:r,title:s,description:o,cancelButton:n,submitButton:a,onCancel:l,onSubmit:p})}function FieldControl({label:e,className:t,children:r}){return jsxRuntime.jsxs("label",{className:tailwindMerge.twMerge("flex cursor-pointer gap-4 rounded border border-secondary-strokeLight text-accent-primary p-4",t),children:[r,e]})}function Inscriptions({className:e,config:t,onSubmit:r}){const[s=!0,o]=react.useState(),[n=!0,a]=react.useState();if(!t)return null;const{coinName:l}=t;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",e),children:[jsxRuntime.jsx(coreUi.DialogHeader,{title:`Manage ${l} Inscriptions`,className:"mb-4 text-accent-primary",onClose:()=>void(r==null?void 0:r(s,n))}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsxs(coreUi.Text,{className:"mb-8 text-accent-secondary",children:["By default, we will not use ",l," that contains Inscriptions - such as Ordinals, NFTs, or Runes - in your stakeable balance. This helps prevent any accidental loss of your Inscriptions due to staking, unbonding, or withdrawal fees."]}),jsxRuntime.jsxs(coreUi.Text,{className:"mb-10 text-accent-secondary",children:["If you would like to include ",l," with Inscriptions in your stakeable balance, please select the option below."]}),jsxRuntime.jsxs("form",{action:"",children:[jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("strong",{className:"mr-2",children:"Do not use"})," ",l," with Inscriptions for staking. (Recommended)"]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Radio,{name:"inscriptions",checked:s,onChange:()=>o(!0)})}),jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("strong",{className:"mr-2",children:"Use"})," ",l," with Inscriptions in my stakable balance."]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Radio,{name:"inscriptions",checked:!s,onChange:()=>o(!1)})})]})]}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"mt-auto pt-10",children:[jsxRuntime.jsx(coreUi.Checkbox,{checked:!n,label:"Do not show again",labelClassName:"mb-6",onChange:p=>a(!p)}),jsxRuntime.jsx(coreUi.Button,{fluid:!0,onClick:()=>void(r==null?void 0:r(s,n)),children:"Save"})]})]})}function InscriptionsContainer({className:e,onSubmit:t}){var s;const{chains:r}=useWidgetState();return jsxRuntime.jsx(Inscriptions,{className:e,onSubmit:t,config:(s=r.BTC)==null?void 0:s.config})}function LoaderScreen({className:e,title:t}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-col items-center justify-center gap-6",e),children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center bg-primary-contrast p-6",children:jsxRuntime.jsx(coreUi.Loader,{className:"text-primary-light"})}),t&&jsxRuntime.jsx(coreUi.Heading,{variant:"h4",className:"capitalize text-accent-primary",children:t})]})}const defaultState={termsOfUse:!1,inscriptions:!1,staking:!1};function TermsOfService({className:e,onClose:t,onSubmit:r}){const[s,o]=react.useState(defaultState),n=react.useMemo(()=>Object.values(s).every(l=>l),[s]),a=react.useCallback(l=>(p=!1)=>{o(u=>({...u,[l]:p}))},[]);return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",e),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"mb-10 text-accent-primary",title:"Connect Wallets",onClose:t,children:jsxRuntime.jsx(coreUi.Text,{className:"text-accent-secondary",children:"Please read and accept the following terms"})}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{className:"block",children:["I certify that I have read and accept the updated"," ",jsxRuntime.jsx("a",{href:"https://babylonlabs.io/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Terms of Use"})," ","and"," ",jsxRuntime.jsx("a",{href:"https://babylonlabs.io/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Privacy Policy"}),"."]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.termsOfUse,onChange:a("termsOfUse")})}),jsxRuntime.jsx(FieldControl,{label:"I certify that I wish to stake bitcoin and agree that doing so may cause some or all of the bitcoin ordinals, NFTs, Runes, and other inscriptions in the connected bitcoin wallet to be lost. I acknowledge that this interface will not detect all Inscriptions.",className:"mb-8",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.inscriptions,onChange:a("inscriptions")})}),jsxRuntime.jsx(FieldControl,{label:"I acknowledge that the following are the only hardware wallets supporting Bitcoin Staking: (1) Keystone -- via QR code and (2) OneKey -- via the OneKey Chrome extension and the hardware devices (a) OneKey Pro and (b) OneKey Classic 1s (experimental, 3.10.1 firmware or higher) using Taproot only. Using any other hardware wallet through any means (such as connection to a software/extension/mobile wallet) can lead to permanent inability to withdraw the stake.",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.staking,onChange:a("staking")})})]}),jsxRuntime.jsx(coreUi.DialogFooter,{className:"mt-auto pt-10",children:jsxRuntime.jsx(coreUi.Button,{disabled:!n,fluid:!0,onClick:r,children:"Next"})})]})}function TermsOfServiceContainer(e){var r;const{chains:t}=useWidgetState();return jsxRuntime.jsx(TermsOfService,{...e,config:(r=t.BTC)==null?void 0:r.config})}const Wallets=react.memo(({chain:e,className:t,append:r,onClose:s,onBack:o,onSelectWallet:n})=>{const a=react.useMemo(()=>e.wallets.find(u=>u.id==="injectable"&&u.installed),[e]),l=react.useMemo(()=>e.wallets.filter(u=>u.id!=="injectable"),[e]),p=react.useMemo(()=>e.wallets.filter(u=>u.id!=="injectable"||u.installed).length,[e]);return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",t),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"text-accent-primary mb-10",title:"Select Wallet",onClose:s,children:jsxRuntime.jsxs(coreUi.Text,{className:"text-accent-secondary",children:["Connect a ",e.name," Wallet"]})}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("grid gap-6",p>1?"grid-cols-1 md:grid-cols-2":"grid-cols-1"),children:[a&&jsxRuntime.jsx(WalletButton,{installed:!0,name:a.name,logo:a.icon,label:a.label,onClick:()=>n==null?void 0:n(e,a)}),l.map(u=>jsxRuntime.jsx(WalletButton,{installed:u.installed,name:u.name,logo:u.icon,label:u.label,fallbackLink:u.docs,onClick:()=>n==null?void 0:n(e,u)},u.id))]}),r]}),jsxRuntime.jsx(coreUi.DialogFooter,{className:"mt-auto pt-10",children:jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:o,children:"Back"})})]})});function WalletsContainer({widgets:e={},...t}){var p;const{chains:r,screen:s,displayChains:o}=useWidgetState(),n=((p=s.params)==null?void 0:p.chain)??"",a=r==null?void 0:r[n],l=e==null?void 0:e[n];return jsxRuntime.jsx(Wallets,{append:l,chain:a,onBack:o,...t})}const SCREENS={TERMS_OF_SERVICE:({className:e,onClose:t,onAccepTermsOfService:r})=>jsxRuntime.jsx(TermsOfServiceContainer,{className:e,onClose:t,onSubmit:r}),CHAINS:({className:e,onClose:t,onConfirm:r,onDisconnectWallet:s})=>jsxRuntime.jsx(ChainsContainer,{className:e,onClose:t,onConfirm:r,onDisconnectWallet:s}),WALLETS:({className:e,widgets:t,onClose:r,onSelectWallet:s})=>jsxRuntime.jsx(WalletsContainer,{widgets:t,className:e,onClose:r,onSelectWallet:s}),INSCRIPTIONS:({className:e,onToggleInscriptions:t})=>jsxRuntime.jsx(InscriptionsContainer,{className:e,onSubmit:t}),LOADER:({className:e,current:t})=>{var r;return jsxRuntime.jsx(LoaderScreen,{className:e,title:(r=t==null?void 0:t.params)==null?void 0:r.message})},ERROR:()=>jsxRuntime.jsx(ErrorContainer,{className:"min-h-0 md:w-[600px]"}),EMPTY:({className:e})=>jsxRuntime.jsx("div",{className:e})};function Screen(e){const t=SCREENS[e.current.type]??SCREENS.EMPTY;return jsxRuntime.jsx(t,{...e})}const ANIMATION_DELAY=1e3;function WalletDialog({storage:e,config:t,onError:r}){const{visible:s,screen:o,confirmed:n,close:a,confirm:l,displayChains:p}=useWidgetState(),{toggleShowAgain:u,toggleLockInscriptions:c}=useInscriptionProvider(),v=useChainProviders(),w=useWalletWidgets(v,t),{connect:b,disconnect:E}=useWalletConnectors({accountStorage:e,onError:r}),{disconnect:I}=useWalletConnect(),{acceptTermsOfService:x}=useLifeCycleHooks(),B=react.useCallback(()=>{p==null||p(),x==null||x()},[p,x]),M=react.useCallback((F,j)=>{u==null||u(j),c==null||c(F),p==null||p()},[u,c,p]),q=react.useCallback(()=>{a==null||a(),n||setTimeout(I,ANIMATION_DELAY)},[a,I,n]),U=react.useCallback(()=>{l==null||l(),a==null||a()},[l]);return jsxRuntime.jsx(ResponsiveDialog,{className:"min-h-[80%]",open:s,onClose:q,children:jsxRuntime.jsx(Screen,{current:o,widgets:w,className:"min-h-0 md:size-[600px]",onClose:q,onConfirm:U,onSelectWallet:b,onAccepTermsOfService:B,onToggleInscriptions:M,onDisconnectWallet:E})})}const BBN_TESTNET_RPC_URL="https://rpc-dapp.testnet.babylonlabs.io/",BBN_TESTNET_LCD_URL="https://lcd-dapp.testnet.babylonlabs.io/",bbnTestnet={chainId:"bbn-test-5",chainName:"Babylon Testnet",chainSymbolImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png",rpc:BBN_TESTNET_RPC_URL,rest:BBN_TESTNET_LCD_URL,nodeProvider:{name:"Babylonlabs",email:"contact@babylonlabs.io",website:"https://babylonlabs.io/"},bip44:{coinType:118},bech32Config:{bech32PrefixAccAddr:"bbn",bech32PrefixAccPub:"bbnpub",bech32PrefixValAddr:"bbnvaloper",bech32PrefixValPub:"bbnvaloperpub",bech32PrefixConsAddr:"bbnvalcons",bech32PrefixConsPub:"bbnvalconspub"},currencies:[{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png"}],feeCurrencies:[{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png",gasPriceStep:{low:.007,average:.007,high:.01}}],stakeCurrency:{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png"},features:["cosmwasm"]},ONE_HOUR=60*60*1e3;Network.SIGNET,bbnTestnet.currencies[0].coinDenom,bbnTestnet.chainName,bbnTestnet.currencies[0].coinDenom,bbnTestnet.chainId;const storage=createAccountStorage(ONE_HOUR);function WalletProvider({lifecycleHooks:e,children:t,config:r,context:s=window,onError:o}){return jsxRuntime.jsx(LifeCycleHooksProvider,{value:e,children:jsxRuntime.jsxs(ChainProvider,{storage,context:s,config:r,onError:o,children:[t,jsxRuntime.jsx(WalletDialog,{storage,config:r,onError:o})]})})}function useChainConnector(e){const t=useChainProviders();return(t==null?void 0:t[e])??null}exports.Network=Network;exports.StateContext=StateContext;exports.StateProvider=StateProvider;exports.WalletButton=WalletButton;exports.WalletProvider=WalletProvider;exports.createExternalWallet=createExternalWallet;exports.useChainConnector=useChainConnector;exports.useInscriptionProvider=useInscriptionProvider;exports.useWalletConnect=useWalletConnect;exports.useWidgetState=useWidgetState;
79
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var lazy$8={};Object.defineProperty(lazy$8,"__esModule",{value:!0});lazy$8.value=lazy$8.prop=void 0;function prop(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const s=r.call(this);return this[t]=s,s},set(s){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:s,writable:!0})}})}lazy$8.prop=prop;function value(e){let t;return()=>(t!==void 0||(t=e()),t)}lazy$8.value=value;Object.defineProperty(embed,"__esModule",{value:!0});embed.p2data=void 0;const networks_1$7=networks,bscript$8=script,types_1$8=types$4,lazy$7=lazy$8,OPS$7=bscript$8.OPS;function stacksEqual$4(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2data(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,types_1$8.typeforce)({network:types_1$8.typeforce.maybe(types_1$8.typeforce.Object),output:types_1$8.typeforce.maybe(types_1$8.typeforce.Buffer),data:types_1$8.typeforce.maybe(types_1$8.typeforce.arrayOf(types_1$8.typeforce.Buffer))},e);const s={name:"embed",network:e.network||networks_1$7.bitcoin};if(lazy$7.prop(s,"output",()=>{if(e.data)return bscript$8.compile([OPS$7.OP_RETURN].concat(e.data))}),lazy$7.prop(s,"data",()=>{if(e.output)return bscript$8.decompile(e.output).slice(1)}),t.validate&&e.output){const o=bscript$8.decompile(e.output);if(o[0]!==OPS$7.OP_RETURN)throw new TypeError("Output is invalid");if(!o.slice(1).every(types_1$8.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!stacksEqual$4(e.data,s.data))throw new TypeError("Data mismatch")}return Object.assign(s,e)}embed.p2data=p2data;var p2ms$1={};Object.defineProperty(p2ms$1,"__esModule",{value:!0});p2ms$1.p2ms=void 0;const networks_1$6=networks,bscript$7=script,types_1$7=types$4,lazy$6=lazy$8,OPS$6=bscript$7.OPS,OP_INT_BASE=OPS$6.OP_RESERVED;function stacksEqual$3(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2ms(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(p){return bscript$7.isCanonicalScriptSignature(p)||(t.allowIncomplete&&p===OPS$6.OP_0)!==void 0}(0,types_1$7.typeforce)({network:types_1$7.typeforce.maybe(types_1$7.typeforce.Object),m:types_1$7.typeforce.maybe(types_1$7.typeforce.Number),n:types_1$7.typeforce.maybe(types_1$7.typeforce.Number),output:types_1$7.typeforce.maybe(types_1$7.typeforce.Buffer),pubkeys:types_1$7.typeforce.maybe(types_1$7.typeforce.arrayOf(types_1$7.isPoint)),signatures:types_1$7.typeforce.maybe(types_1$7.typeforce.arrayOf(r)),input:types_1$7.typeforce.maybe(types_1$7.typeforce.Buffer)},e);const o={network:e.network||networks_1$6.bitcoin};let n=[],a=!1;function l(p){a||(a=!0,n=bscript$7.decompile(p),o.m=n[0]-OP_INT_BASE,o.n=n[n.length-2]-OP_INT_BASE,o.pubkeys=n.slice(1,-2))}if(lazy$6.prop(o,"output",()=>{if(e.m&&o.n&&e.pubkeys)return bscript$7.compile([].concat(OP_INT_BASE+e.m,e.pubkeys,OP_INT_BASE+o.n,OPS$6.OP_CHECKMULTISIG))}),lazy$6.prop(o,"m",()=>{if(o.output)return l(o.output),o.m}),lazy$6.prop(o,"n",()=>{if(o.pubkeys)return o.pubkeys.length}),lazy$6.prop(o,"pubkeys",()=>{if(e.output)return l(e.output),o.pubkeys}),lazy$6.prop(o,"signatures",()=>{if(e.input)return bscript$7.decompile(e.input).slice(1)}),lazy$6.prop(o,"input",()=>{if(e.signatures)return bscript$7.compile([OPS$6.OP_0].concat(e.signatures))}),lazy$6.prop(o,"witness",()=>{if(o.input)return[]}),lazy$6.prop(o,"name",()=>{if(!(!o.m||!o.n))return`p2ms(${o.m} of ${o.n})`}),t.validate){if(e.output){if(l(e.output),!types_1$7.typeforce.Number(n[0]))throw new TypeError("Output is invalid");if(!types_1$7.typeforce.Number(n[n.length-2]))throw new TypeError("Output is invalid");if(n[n.length-1]!==OPS$6.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(o.m<=0||o.n>16||o.m>o.n||o.n!==n.length-3)throw new TypeError("Output is invalid");if(!o.pubkeys.every(p=>(0,types_1$7.isPoint)(p)))throw new TypeError("Output is invalid");if(e.m!==void 0&&e.m!==o.m)throw new TypeError("m mismatch");if(e.n!==void 0&&e.n!==o.n)throw new TypeError("n mismatch");if(e.pubkeys&&!stacksEqual$3(e.pubkeys,o.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(o.n=e.pubkeys.length,o.n<o.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<o.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>o.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==OPS$6.OP_0)throw new TypeError("Input is invalid");if(o.signatures.length===0||!o.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!stacksEqual$3(e.signatures,o.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(o,e)}p2ms$1.p2ms=p2ms;var p2pk$1={};Object.defineProperty(p2pk$1,"__esModule",{value:!0});p2pk$1.p2pk=void 0;const networks_1$5=networks,bscript$6=script,types_1$6=types$4,lazy$5=lazy$8,OPS$5=bscript$6.OPS;function p2pk(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||{}),(0,types_1$6.typeforce)({network:types_1$6.typeforce.maybe(types_1$6.typeforce.Object),output:types_1$6.typeforce.maybe(types_1$6.typeforce.Buffer),pubkey:types_1$6.typeforce.maybe(types_1$6.isPoint),signature:types_1$6.typeforce.maybe(bscript$6.isCanonicalScriptSignature),input:types_1$6.typeforce.maybe(types_1$6.typeforce.Buffer)},e);const r=lazy$5.value(()=>bscript$6.decompile(e.input)),o={name:"p2pk",network:e.network||networks_1$5.bitcoin};if(lazy$5.prop(o,"output",()=>{if(e.pubkey)return bscript$6.compile([e.pubkey,OPS$5.OP_CHECKSIG])}),lazy$5.prop(o,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),lazy$5.prop(o,"signature",()=>{if(e.input)return r()[0]}),lazy$5.prop(o,"input",()=>{if(e.signature)return bscript$6.compile([e.signature])}),lazy$5.prop(o,"witness",()=>{if(o.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==OPS$5.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,types_1$6.isPoint)(o.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(o.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(o.input))throw new TypeError("Signature mismatch");if(e.input){if(r().length!==1)throw new TypeError("Input is invalid");if(!bscript$6.isCanonicalScriptSignature(o.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(o,e)}p2pk$1.p2pk=p2pk;var p2pkh$1={};Object.defineProperty(p2pkh$1,"__esModule",{value:!0});p2pkh$1.p2pkh=void 0;const bcrypto$3=crypto$1,networks_1$4=networks,bscript$5=script,types_1$5=types$4,lazy$4=lazy$8,bs58check$1=bs58check$a,OPS$4=bscript$5.OPS;function p2pkh(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||{}),(0,types_1$5.typeforce)({network:types_1$5.typeforce.maybe(types_1$5.typeforce.Object),address:types_1$5.typeforce.maybe(types_1$5.typeforce.String),hash:types_1$5.typeforce.maybe(types_1$5.typeforce.BufferN(20)),output:types_1$5.typeforce.maybe(types_1$5.typeforce.BufferN(25)),pubkey:types_1$5.typeforce.maybe(types_1$5.isPoint),signature:types_1$5.typeforce.maybe(bscript$5.isCanonicalScriptSignature),input:types_1$5.typeforce.maybe(types_1$5.typeforce.Buffer)},e);const r=lazy$4.value(()=>{const a=Buffer$e.from(bs58check$1.decode(e.address)),l=a.readUInt8(0),p=a.slice(1);return{version:l,hash:p}}),s=lazy$4.value(()=>bscript$5.decompile(e.input)),o=e.network||networks_1$4.bitcoin,n={name:"p2pkh",network:o};if(lazy$4.prop(n,"address",()=>{if(!n.hash)return;const a=Buffer$e.allocUnsafe(21);return a.writeUInt8(o.pubKeyHash,0),n.hash.copy(a,1),bs58check$1.encode(a)}),lazy$4.prop(n,"hash",()=>{if(e.output)return e.output.slice(3,23);if(e.address)return r().hash;if(e.pubkey||n.pubkey)return bcrypto$3.hash160(e.pubkey||n.pubkey)}),lazy$4.prop(n,"output",()=>{if(n.hash)return bscript$5.compile([OPS$4.OP_DUP,OPS$4.OP_HASH160,n.hash,OPS$4.OP_EQUALVERIFY,OPS$4.OP_CHECKSIG])}),lazy$4.prop(n,"pubkey",()=>{if(e.input)return s()[1]}),lazy$4.prop(n,"signature",()=>{if(e.input)return s()[0]}),lazy$4.prop(n,"input",()=>{if(e.pubkey&&e.signature)return bscript$5.compile([e.signature,e.pubkey])}),lazy$4.prop(n,"witness",()=>{if(n.input)return[]}),t.validate){let a=Buffer$e.from([]);if(e.address){if(r().version!==o.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(r().hash.length!==20)throw new TypeError("Invalid address");a=r().hash}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==25||e.output[0]!==OPS$4.OP_DUP||e.output[1]!==OPS$4.OP_HASH160||e.output[2]!==20||e.output[23]!==OPS$4.OP_EQUALVERIFY||e.output[24]!==OPS$4.OP_CHECKSIG)throw new TypeError("Output is invalid");const l=e.output.slice(3,23);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.pubkey){const l=bcrypto$3.hash160(e.pubkey);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.input){const l=s();if(l.length!==2)throw new TypeError("Input is invalid");if(!bscript$5.isCanonicalScriptSignature(l[0]))throw new TypeError("Input has invalid signature");if(!(0,types_1$5.isPoint)(l[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(l[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(l[1]))throw new TypeError("Pubkey mismatch");const p=bcrypto$3.hash160(l[1]);if(a.length>0&&!a.equals(p))throw new TypeError("Hash mismatch")}}return Object.assign(n,e)}p2pkh$1.p2pkh=p2pkh;var p2sh$1={};Object.defineProperty(p2sh$1,"__esModule",{value:!0});p2sh$1.p2sh=void 0;const bcrypto$2=crypto$1,networks_1$3=networks,bscript$4=script,types_1$4=types$4,lazy$3=lazy$8,bs58check=bs58check$a,OPS$3=bscript$4.OPS;function stacksEqual$2(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function p2sh(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||{}),(0,types_1$4.typeforce)({network:types_1$4.typeforce.maybe(types_1$4.typeforce.Object),address:types_1$4.typeforce.maybe(types_1$4.typeforce.String),hash:types_1$4.typeforce.maybe(types_1$4.typeforce.BufferN(20)),output:types_1$4.typeforce.maybe(types_1$4.typeforce.BufferN(23)),redeem:types_1$4.typeforce.maybe({network:types_1$4.typeforce.maybe(types_1$4.typeforce.Object),output:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),input:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),witness:types_1$4.typeforce.maybe(types_1$4.typeforce.arrayOf(types_1$4.typeforce.Buffer))}),input:types_1$4.typeforce.maybe(types_1$4.typeforce.Buffer),witness:types_1$4.typeforce.maybe(types_1$4.typeforce.arrayOf(types_1$4.typeforce.Buffer))},e);let r=e.network;r||(r=e.redeem&&e.redeem.network||networks_1$3.bitcoin);const s={network:r},o=lazy$3.value(()=>{const l=Buffer$e.from(bs58check.decode(e.address)),p=l.readUInt8(0),u=l.slice(1);return{version:p,hash:u}}),n=lazy$3.value(()=>bscript$4.decompile(e.input)),a=lazy$3.value(()=>{const l=n(),p=l[l.length-1];return{network:r,output:p===OPS$3.OP_FALSE?Buffer$e.from([]):p,input:bscript$4.compile(l.slice(0,-1)),witness:e.witness||[]}});if(lazy$3.prop(s,"address",()=>{if(!s.hash)return;const l=Buffer$e.allocUnsafe(21);return l.writeUInt8(s.network.scriptHash,0),s.hash.copy(l,1),bs58check.encode(l)}),lazy$3.prop(s,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return o().hash;if(s.redeem&&s.redeem.output)return bcrypto$2.hash160(s.redeem.output)}),lazy$3.prop(s,"output",()=>{if(s.hash)return bscript$4.compile([OPS$3.OP_HASH160,s.hash,OPS$3.OP_EQUAL])}),lazy$3.prop(s,"redeem",()=>{if(e.input)return a()}),lazy$3.prop(s,"input",()=>{if(!(!e.redeem||!e.redeem.input||!e.redeem.output))return bscript$4.compile([].concat(bscript$4.decompile(e.redeem.input),e.redeem.output))}),lazy$3.prop(s,"witness",()=>{if(s.redeem&&s.redeem.witness)return s.redeem.witness;if(s.input)return[]}),lazy$3.prop(s,"name",()=>{const l=["p2sh"];return s.redeem!==void 0&&s.redeem.name!==void 0&&l.push(s.redeem.name),l.join("-")}),t.validate){let l=Buffer$e.from([]);if(e.address){if(o().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(o().hash.length!==20)throw new TypeError("Invalid address");l=o().hash}if(e.hash){if(l.length>0&&!l.equals(e.hash))throw new TypeError("Hash mismatch");l=e.hash}if(e.output){if(e.output.length!==23||e.output[0]!==OPS$3.OP_HASH160||e.output[1]!==20||e.output[22]!==OPS$3.OP_EQUAL)throw new TypeError("Output is invalid");const u=e.output.slice(2,22);if(l.length>0&&!l.equals(u))throw new TypeError("Hash mismatch");l=u}const p=u=>{if(u.output){const c=bscript$4.decompile(u.output);if(!c||c.length<1)throw new TypeError("Redeem.output too short");if(u.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(bscript$4.countNonPushOnlyOPs(c)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const v=bcrypto$2.hash160(u.output);if(l.length>0&&!l.equals(v))throw new TypeError("Hash mismatch");l=v}if(u.input){const c=u.input.length>0,v=u.witness&&u.witness.length>0;if(!c&&!v)throw new TypeError("Empty input");if(c&&v)throw new TypeError("Input and witness provided");if(c){const w=bscript$4.decompile(u.input);if(!bscript$4.isPushOnly(w))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const u=n();if(!u||u.length<1)throw new TypeError("Input too short");if(!Buffer$e.isBuffer(a().output))throw new TypeError("Input is invalid");p(a())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const u=a();if(e.redeem.output&&!e.redeem.output.equals(u.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(u.input))throw new TypeError("Redeem.input mismatch")}p(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!stacksEqual$2(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(s,e)}p2sh$1.p2sh=p2sh;var p2wpkh$1={},dist={};Object.defineProperty(dist,"__esModule",{value:!0});dist.bech32m=dist.bech32=void 0;const ALPHABET="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP={};for(let e=0;e<ALPHABET.length;e++){const t=ALPHABET.charAt(e);ALPHABET_MAP[t]=e}function polymodStep(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 prefixChk(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=polymodStep(t)^s>>5}t=polymodStep(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=polymodStep(t)^s&31}return t}function convert(e,t,r,s){let o=0,n=0;const a=(1<<r)-1,l=[];for(let p=0;p<e.length;++p)for(o=o<<t|e[p],n+=t;n>=r;)n-=r,l.push(o>>n&a);if(s)n>0&&l.push(o<<r-n&a);else{if(n>=t)return"Excess padding";if(o<<r-n&a)return"Non-zero padding"}return l}function toWords(e){return convert(e,8,5,!0)}function fromWordsUnsafe(e){const t=convert(e,5,8,!1);if(Array.isArray(t))return t}function fromWords(e){const t=convert(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function getLibraryFromEncoding(e){let t;e==="bech32"?t=1:t=734539939;function r(a,l,p){if(p=p||90,a.length+7+l.length>p)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let u=prefixChk(a);if(typeof u=="string")throw new Error(u);let c=a+"1";for(let v=0;v<l.length;++v){const w=l[v];if(w>>5)throw new Error("Non 5-bit word");u=polymodStep(u)^w,c+=ALPHABET.charAt(w)}for(let v=0;v<6;++v)u=polymodStep(u);u^=t;for(let v=0;v<6;++v){const w=u>>(5-v)*5&31;c+=ALPHABET.charAt(w)}return c}function s(a,l){if(l=l||90,a.length<8)return a+" too short";if(a.length>l)return"Exceeds length limit";const p=a.toLowerCase(),u=a.toUpperCase();if(a!==p&&a!==u)return"Mixed-case string "+a;a=p;const c=a.lastIndexOf("1");if(c===-1)return"No separator character for "+a;if(c===0)return"Missing prefix for "+a;const v=a.slice(0,c),w=a.slice(c+1);if(w.length<6)return"Data too short";let b=prefixChk(v);if(typeof b=="string")return b;const E=[];for(let I=0;I<w.length;++I){const x=w.charAt(I),B=ALPHABET_MAP[x];if(B===void 0)return"Unknown character "+x;b=polymodStep(b)^B,!(I+6>=w.length)&&E.push(B)}return b!==t?"Invalid checksum for "+a:{prefix:v,words:E}}function o(a,l){const p=s(a,l);if(typeof p=="object")return p}function n(a,l){const p=s(a,l);if(typeof p=="object")return p;throw new Error(p)}return{decodeUnsafe:o,decode:n,encode:r,toWords,fromWordsUnsafe,fromWords}}dist.bech32=getLibraryFromEncoding("bech32");dist.bech32m=getLibraryFromEncoding("bech32m");Object.defineProperty(p2wpkh$1,"__esModule",{value:!0});p2wpkh$1.p2wpkh=void 0;const bcrypto$1=crypto$1,networks_1$2=networks,bscript$3=script,types_1$3=types$4,lazy$2=lazy$8,bech32_1$2=dist,OPS$2=bscript$3.OPS,EMPTY_BUFFER$1=Buffer$e.alloc(0);function p2wpkh(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||{}),(0,types_1$3.typeforce)({address:types_1$3.typeforce.maybe(types_1$3.typeforce.String),hash:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(20)),input:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(0)),network:types_1$3.typeforce.maybe(types_1$3.typeforce.Object),output:types_1$3.typeforce.maybe(types_1$3.typeforce.BufferN(22)),pubkey:types_1$3.typeforce.maybe(types_1$3.isPoint),signature:types_1$3.typeforce.maybe(bscript$3.isCanonicalScriptSignature),witness:types_1$3.typeforce.maybe(types_1$3.typeforce.arrayOf(types_1$3.typeforce.Buffer))},e);const r=lazy$2.value(()=>{const n=bech32_1$2.bech32.decode(e.address),a=n.words.shift(),l=bech32_1$2.bech32.fromWords(n.words);return{version:a,prefix:n.prefix,data:Buffer$e.from(l)}}),s=e.network||networks_1$2.bitcoin,o={name:"p2wpkh",network:s};if(lazy$2.prop(o,"address",()=>{if(!o.hash)return;const n=bech32_1$2.bech32.toWords(o.hash);return n.unshift(0),bech32_1$2.bech32.encode(s.bech32,n)}),lazy$2.prop(o,"hash",()=>{if(e.output)return e.output.slice(2,22);if(e.address)return r().data;if(e.pubkey||o.pubkey)return bcrypto$1.hash160(e.pubkey||o.pubkey)}),lazy$2.prop(o,"output",()=>{if(o.hash)return bscript$3.compile([OPS$2.OP_0,o.hash])}),lazy$2.prop(o,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.witness)return e.witness[1]}),lazy$2.prop(o,"signature",()=>{if(e.witness)return e.witness[0]}),lazy$2.prop(o,"input",()=>{if(o.witness)return EMPTY_BUFFER$1}),lazy$2.prop(o,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let n=Buffer$e.from([]);if(e.address){if(s&&s.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");n=r().data}if(e.hash){if(n.length>0&&!n.equals(e.hash))throw new TypeError("Hash mismatch");n=e.hash}if(e.output){if(e.output.length!==22||e.output[0]!==OPS$2.OP_0||e.output[1]!==20)throw new TypeError("Output is invalid");if(n.length>0&&!n.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");n=e.output.slice(2)}if(e.pubkey){const a=bcrypto$1.hash160(e.pubkey);if(n.length>0&&!n.equals(a))throw new TypeError("Hash mismatch");if(n=a,!(0,types_1$3.isPoint)(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(!bscript$3.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,types_1$3.isPoint)(e.witness[1])||e.witness[1].length!==33)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const a=bcrypto$1.hash160(e.witness[1]);if(n.length>0&&!n.equals(a))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}p2wpkh$1.p2wpkh=p2wpkh;var p2wsh$1={};Object.defineProperty(p2wsh$1,"__esModule",{value:!0});p2wsh$1.p2wsh=void 0;const bcrypto=crypto$1,networks_1$1=networks,bscript$2=script,types_1$2=types$4,lazy$1=lazy$8,bech32_1$1=dist,OPS$1=bscript$2.OPS,EMPTY_BUFFER=Buffer$e.alloc(0);function stacksEqual$1(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}function chunkHasUncompressedPubkey(e){return!!(Buffer$e.isBuffer(e)&&e.length===65&&e[0]===4&&(0,types_1$2.isPoint)(e))}function p2wsh(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||{}),(0,types_1$2.typeforce)({network:types_1$2.typeforce.maybe(types_1$2.typeforce.Object),address:types_1$2.typeforce.maybe(types_1$2.typeforce.String),hash:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(32)),output:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(34)),redeem:types_1$2.typeforce.maybe({input:types_1$2.typeforce.maybe(types_1$2.typeforce.Buffer),network:types_1$2.typeforce.maybe(types_1$2.typeforce.Object),output:types_1$2.typeforce.maybe(types_1$2.typeforce.Buffer),witness:types_1$2.typeforce.maybe(types_1$2.typeforce.arrayOf(types_1$2.typeforce.Buffer))}),input:types_1$2.typeforce.maybe(types_1$2.typeforce.BufferN(0)),witness:types_1$2.typeforce.maybe(types_1$2.typeforce.arrayOf(types_1$2.typeforce.Buffer))},e);const r=lazy$1.value(()=>{const a=bech32_1$1.bech32.decode(e.address),l=a.words.shift(),p=bech32_1$1.bech32.fromWords(a.words);return{version:l,prefix:a.prefix,data:Buffer$e.from(p)}}),s=lazy$1.value(()=>bscript$2.decompile(e.redeem.input));let o=e.network;o||(o=e.redeem&&e.redeem.network||networks_1$1.bitcoin);const n={network:o};if(lazy$1.prop(n,"address",()=>{if(!n.hash)return;const a=bech32_1$1.bech32.toWords(n.hash);return a.unshift(0),bech32_1$1.bech32.encode(o.bech32,a)}),lazy$1.prop(n,"hash",()=>{if(e.output)return e.output.slice(2);if(e.address)return r().data;if(n.redeem&&n.redeem.output)return bcrypto.sha256(n.redeem.output)}),lazy$1.prop(n,"output",()=>{if(n.hash)return bscript$2.compile([OPS$1.OP_0,n.hash])}),lazy$1.prop(n,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:EMPTY_BUFFER,witness:e.witness.slice(0,-1)}}),lazy$1.prop(n,"input",()=>{if(n.witness)return EMPTY_BUFFER}),lazy$1.prop(n,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const a=bscript$2.toStack(s());return n.redeem=Object.assign({witness:a},e.redeem),n.redeem.input=EMPTY_BUFFER,[].concat(a,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),lazy$1.prop(n,"name",()=>{const a=["p2wsh"];return n.redeem!==void 0&&n.redeem.name!==void 0&&a.push(n.redeem.name),a.join("-")}),t.validate){let a=Buffer$e.from([]);if(e.address){if(r().prefix!==o.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");a=r().data}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(e.output.length!==34||e.output[0]!==OPS$1.OP_0||e.output[1]!==32)throw new TypeError("Output is invalid");const l=e.output.slice(2);if(a.length>0&&!a.equals(l))throw new TypeError("Hash mismatch");a=l}if(e.redeem){if(e.redeem.network&&e.redeem.network!==o)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 l=bscript$2.decompile(e.redeem.output);if(!l||l.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(bscript$2.countNonPushOnlyOPs(l)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const p=bcrypto.sha256(e.redeem.output);if(a.length>0&&!a.equals(p))throw new TypeError("Hash mismatch");a=p}if(e.redeem.input&&!bscript$2.isPushOnly(s()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!stacksEqual$1(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&s().some(chunkHasUncompressedPubkey)||e.redeem.output&&(bscript$2.decompile(e.redeem.output)||[]).some(chunkHasUncompressedPubkey))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const l=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(l))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(chunkHasUncompressedPubkey)||(bscript$2.decompile(l)||[]).some(chunkHasUncompressedPubkey))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(n,e)}p2wsh$1.p2wsh=p2wsh;var p2tr$1={};Object.defineProperty(p2tr$1,"__esModule",{value:!0});p2tr$1.p2tr=void 0;const buffer_1=require$$0$3,networks_1=networks,bscript$1=script,types_1$1=types$4,ecc_lib_1=ecc_lib,bip341_1$1=bip341,lazy=lazy$8,bech32_1=dist,OPS=bscript$1.OPS,TAPROOT_WITNESS_VERSION=1,ANNEX_PREFIX=80;function p2tr(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||{}),(0,types_1$1.typeforce)({address:types_1$1.typeforce.maybe(types_1$1.typeforce.String),input:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(0)),network:types_1$1.typeforce.maybe(types_1$1.typeforce.Object),output:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(34)),internalPubkey:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),hash:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),pubkey:types_1$1.typeforce.maybe(types_1$1.typeforce.BufferN(32)),signature:types_1$1.typeforce.maybe(types_1$1.typeforce.anyOf(types_1$1.typeforce.BufferN(64),types_1$1.typeforce.BufferN(65))),witness:types_1$1.typeforce.maybe(types_1$1.typeforce.arrayOf(types_1$1.typeforce.Buffer)),scriptTree:types_1$1.typeforce.maybe(types_1$1.isTaptree),redeem:types_1$1.typeforce.maybe({output:types_1$1.typeforce.maybe(types_1$1.typeforce.Buffer),redeemVersion:types_1$1.typeforce.maybe(types_1$1.typeforce.Number),witness:types_1$1.typeforce.maybe(types_1$1.typeforce.arrayOf(types_1$1.typeforce.Buffer))}),redeemVersion:types_1$1.typeforce.maybe(types_1$1.typeforce.Number)},e);const r=lazy.value(()=>{const l=bech32_1.bech32m.decode(e.address),p=l.words.shift(),u=bech32_1.bech32m.fromWords(l.words);return{version:p,prefix:l.prefix,data:buffer_1.Buffer.from(u)}}),s=lazy.value(()=>{if(!(!e.witness||!e.witness.length))return e.witness.length>=2&&e.witness[e.witness.length-1][0]===ANNEX_PREFIX?e.witness.slice(0,-1):e.witness.slice()}),o=lazy.value(()=>{if(e.scriptTree)return(0,bip341_1$1.toHashTree)(e.scriptTree);if(e.hash)return{hash:e.hash}}),n=e.network||networks_1.bitcoin,a={name:"p2tr",network:n};if(lazy.prop(a,"address",()=>{if(!a.pubkey)return;const l=bech32_1.bech32m.toWords(a.pubkey);return l.unshift(TAPROOT_WITNESS_VERSION),bech32_1.bech32m.encode(n.bech32,l)}),lazy.prop(a,"hash",()=>{const l=o();if(l)return l.hash;const p=s();if(p&&p.length>1){const u=p[p.length-1],c=u[0]&types_1$1.TAPLEAF_VERSION_MASK,v=p[p.length-2],w=(0,bip341_1$1.tapleafHash)({output:v,version:c});return(0,bip341_1$1.rootHashFromPath)(u,w)}return null}),lazy.prop(a,"output",()=>{if(a.pubkey)return bscript$1.compile([OPS.OP_1,a.pubkey])}),lazy.prop(a,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&e.redeem.redeemVersion!==void 0&&e.redeem.redeemVersion!==null?e.redeem.redeemVersion:bip341_1$1.LEAF_VERSION_TAPSCRIPT),lazy.prop(a,"redeem",()=>{const l=s();if(!(!l||l.length<2))return{output:l[l.length-2],witness:l.slice(0,-2),redeemVersion:l[l.length-1][0]&types_1$1.TAPLEAF_VERSION_MASK}}),lazy.prop(a,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(a.internalPubkey){const l=(0,bip341_1$1.tweakKey)(a.internalPubkey,a.hash);if(l)return l.x}}),lazy.prop(a,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const l=s();if(l&&l.length>1)return l[l.length-1].slice(1,33)}),lazy.prop(a,"signature",()=>{if(e.signature)return e.signature;const l=s();if(!(!l||l.length!==1))return l[0]}),lazy.prop(a,"witness",()=>{if(e.witness)return e.witness;const l=o();if(l&&e.redeem&&e.redeem.output&&e.internalPubkey){const p=(0,bip341_1$1.tapleafHash)({output:e.redeem.output,version:a.redeemVersion}),u=(0,bip341_1$1.findScriptPath)(l,p);if(!u)return;const c=(0,bip341_1$1.tweakKey)(e.internalPubkey,l.hash);if(!c)return;const v=buffer_1.Buffer.concat([buffer_1.Buffer.from([a.redeemVersion|c.parity]),e.internalPubkey].concat(u));return[e.redeem.output,v]}if(e.signature)return[e.signature]}),t.validate){let l=buffer_1.Buffer.from([]);if(e.address){if(n&&n.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==TAPROOT_WITNESS_VERSION)throw new TypeError("Invalid address version");if(r().data.length!==32)throw new TypeError("Invalid address data");l=r().data}if(e.pubkey){if(l.length>0&&!l.equals(e.pubkey))throw new TypeError("Pubkey mismatch");l=e.pubkey}if(e.output){if(e.output.length!==34||e.output[0]!==OPS.OP_1||e.output[1]!==32)throw new TypeError("Output is invalid");if(l.length>0&&!l.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");l=e.output.slice(2)}if(e.internalPubkey){const c=(0,bip341_1$1.tweakKey)(e.internalPubkey,a.hash);if(l.length>0&&!l.equals(c.x))throw new TypeError("Pubkey mismatch");l=c.x}if(l&&l.length&&!(0,ecc_lib_1.getEccLib)().isXOnlyPoint(l))throw new TypeError("Invalid pubkey for p2tr");const p=o();if(e.hash&&p&&!e.hash.equals(p.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&p){const c=(0,bip341_1$1.tapleafHash)({output:e.redeem.output,version:a.redeemVersion});if(!(0,bip341_1$1.findScriptPath)(p,c))throw new TypeError("Redeem script not in tree")}const u=s();if(e.redeem&&a.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==a.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(bscript$1.decompile(e.redeem.output).length===0)throw new TypeError("Redeem.output is invalid");if(a.redeem.output&&!e.redeem.output.equals(a.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&a.redeem.witness&&!stacksEqual(e.redeem.witness,a.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(u&&u.length)if(u.length===1){if(e.signature&&!e.signature.equals(u[0]))throw new TypeError("Signature mismatch")}else{const c=u[u.length-1];if(c.length<33)throw new TypeError(`The control-block length is too small. Got ${c.length}, expected min 33.`);if((c.length-33)%32!==0)throw new TypeError(`The control-block length of ${c.length} is incorrect!`);const v=(c.length-33)/32;if(v>128)throw new TypeError(`The script path is too long. Got ${v}, expected max 128.`);const w=c.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(w))throw new TypeError("Internal pubkey mismatch");if(!(0,ecc_lib_1.getEccLib)().isXOnlyPoint(w))throw new TypeError("Invalid internalPubkey for p2tr witness");const b=c[0]&types_1$1.TAPLEAF_VERSION_MASK,E=u[u.length-2],I=(0,bip341_1$1.tapleafHash)({output:E,version:b}),x=(0,bip341_1$1.rootHashFromPath)(c,I),B=(0,bip341_1$1.tweakKey)(w,x);if(!B)throw new TypeError("Invalid outputKey for p2tr witness");if(l.length&&!l.equals(B.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(B.parity!==(c[0]&1))throw new Error("Incorrect parity")}}return Object.assign(a,e)}p2tr$1.p2tr=p2tr;function stacksEqual(e,t){return e.length!==t.length?!1:e.every((r,s)=>r.equals(t[s]))}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const t=embed;Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});const r=p2ms$1;Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return r.p2ms}});const s=p2pk$1;Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return s.p2pk}});const o=p2pkh$1;Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return o.p2pkh}});const n=p2sh$1;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return n.p2sh}});const a=p2wpkh$1;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return a.p2wpkh}});const l=p2wsh$1;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return l.p2wsh}});const p=p2tr$1;Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return p.p2tr}})})(payments$1);Object.defineProperty(psbtutils,"__esModule",{value:!0});psbtutils.signatureBlocksAction=psbtutils.checkInputForSig=pubkeyInScript_1=psbtutils.pubkeyInScript=psbtutils.pubkeyPositionInScript=psbtutils.witnessStackToScriptWitness=psbtutils.isP2TR=psbtutils.isP2SHScript=psbtutils.isP2WSHScript=psbtutils.isP2WPKH=psbtutils.isP2PKH=psbtutils.isP2PK=psbtutils.isP2MS=void 0;const varuint=varint,bscript=script,transaction_1$1=transaction,crypto_1=crypto$1,payments=payments$1;function isPaymentFactory(e){return t=>{try{return e({output:t}),!0}catch{return!1}}}psbtutils.isP2MS=isPaymentFactory(payments.p2ms);psbtutils.isP2PK=isPaymentFactory(payments.p2pk);psbtutils.isP2PKH=isPaymentFactory(payments.p2pkh);psbtutils.isP2WPKH=isPaymentFactory(payments.p2wpkh);psbtutils.isP2WSHScript=isPaymentFactory(payments.p2wsh);psbtutils.isP2SHScript=isPaymentFactory(payments.p2sh);psbtutils.isP2TR=isPaymentFactory(payments.p2tr);function witnessStackToScriptWitness(e){let t=Buffer$e.allocUnsafe(0);function r(a){t=Buffer$e.concat([t,Buffer$e.from(a)])}function s(a){const l=t.length,p=varuint.encodingLength(a);t=Buffer$e.concat([t,Buffer$e.allocUnsafe(p)]),varuint.encode(a,t,l)}function o(a){s(a.length),r(a)}function n(a){s(a.length),a.forEach(o)}return n(e),t}psbtutils.witnessStackToScriptWitness=witnessStackToScriptWitness;function pubkeyPositionInScript(e,t){const r=(0,crypto_1.hash160)(e),s=e.slice(1,33),o=bscript.decompile(t);if(o===null)throw new Error("Unknown script error");return o.findIndex(n=>typeof n=="number"?!1:n.equals(e)||n.equals(r)||n.equals(s))}psbtutils.pubkeyPositionInScript=pubkeyPositionInScript;function pubkeyInScript(e,t){return pubkeyPositionInScript(e,t)!==-1}var pubkeyInScript_1=psbtutils.pubkeyInScript=pubkeyInScript;function checkInputForSig(e,t){return extractPartialSigs(e).some(s=>signatureBlocksAction(s,bscript.signature.decode,t))}psbtutils.checkInputForSig=checkInputForSig;function signatureBlocksAction(e,t,r){const{hashType:s}=t(e),o=[];switch(s&transaction_1$1.Transaction.SIGHASH_ANYONECANPAY&&o.push("addInput"),s&31){case transaction_1$1.Transaction.SIGHASH_ALL:break;case transaction_1$1.Transaction.SIGHASH_SINGLE:case transaction_1$1.Transaction.SIGHASH_NONE:o.push("addOutput"),o.push("setInputSequence");break}return o.indexOf(r)===-1}psbtutils.signatureBlocksAction=signatureBlocksAction;function extractPartialSigs(e){let t=[];if((e.partialSig||[]).length===0){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=getPsigsFromInputFinalScripts(e)}else t=e.partialSig;return t.map(r=>r.signature)}function getPsigsFromInputFinalScripts(e){const t=e.finalScriptSig?bscript.decompile(e.finalScriptSig)||[]:[],r=e.finalScriptWitness?bscript.decompile(e.finalScriptWitness)||[]:[];return t.concat(r).filter(s=>Buffer$e.isBuffer(s)&&bscript.isCanonicalScriptSignature(s)).map(s=>({signature:s}))}Object.defineProperty(bip371,"__esModule",{value:!0});bip371.checkTaprootInputForSigs=bip371.tapTreeFromList=bip371.tapTreeToList=bip371.tweakInternalPubKey=bip371.checkTaprootOutputFields=bip371.checkTaprootInputFields=bip371.isTaprootOutput=bip371.isTaprootInput=bip371.serializeTaprootSignature=bip371.tapScriptFinalizer=toXOnly_1=bip371.toXOnly=void 0;const types_1=types$4,transaction_1=transaction,psbtutils_1=psbtutils,bip341_1=bip341,payments_1=payments$1,psbtutils_2=psbtutils,toXOnly=e=>e.length===32?e:e.slice(1,33);var toXOnly_1=bip371.toXOnly=toXOnly;function tapScriptFinalizer(e,t,r){const s=findTapLeafToFinalize(t,e,r);try{const n=sortSignatures(t,s).concat(s.script).concat(s.controlBlock);return{finalScriptWitness:(0,psbtutils_1.witnessStackToScriptWitness)(n)}}catch(o){throw new Error(`Can not finalize taproot input #${e}: ${o}`)}}bip371.tapScriptFinalizer=tapScriptFinalizer;function serializeTaprootSignature(e,t){const r=t?Buffer$e.from([t]):Buffer$e.from([]);return Buffer$e.concat([e,r])}bip371.serializeTaprootSignature=serializeTaprootSignature;function isTaprootInput(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,psbtutils_1.isP2TR)(e.witnessUtxo.script))}bip371.isTaprootInput=isTaprootInput;function isTaprootOutput(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,psbtutils_1.isP2TR)(t))}bip371.isTaprootOutput=isTaprootOutput;function checkTaprootInputFields(e,t,r){checkMixedTaprootAndNonTaprootInputFields(e,t,r),checkIfTapLeafInTree(e,t,r)}bip371.checkTaprootInputFields=checkTaprootInputFields;function checkTaprootOutputFields(e,t,r){checkMixedTaprootAndNonTaprootOutputFields(e,t,r),checkTaprootScriptPubkey(e,t)}bip371.checkTaprootOutputFields=checkTaprootOutputFields;function checkTaprootScriptPubkey(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,s=t.tapTree||e.tapTree;if(r){const{script:o}=e,n=getTaprootScripPubkey(r,s);if(o&&!o.equals(n))throw new Error("Error adding output. Script or address missmatch.")}}function getTaprootScripPubkey(e,t){const r=t&&tapTreeFromList(t.leaves),{output:s}=(0,payments_1.p2tr)({internalPubkey:e,scriptTree:r});return s}function tweakInternalPubKey(e,t){const r=t.tapInternalKey,s=r&&(0,bip341_1.tweakKey)(r,t.tapMerkleRoot);if(!s)throw new Error(`Cannot tweak tap internal key for input #${e}. Public key: ${r&&r.toString("hex")}`);return s.x}bip371.tweakInternalPubKey=tweakInternalPubKey;function tapTreeToList(e){if(!(0,types_1.isTaptree)(e))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return _tapTreeToList(e)}bip371.tapTreeToList=tapTreeToList;function tapTreeFromList(e=[]){return e.length===1&&e[0].depth===0?{output:e[0].script,version:e[0].leafVersion}:instertLeavesInTree(e)}bip371.tapTreeFromList=tapTreeFromList;function checkTaprootInputForSigs(e,t){return extractTaprootSigs(e).some(s=>(0,psbtutils_2.signatureBlocksAction)(s,decodeSchnorrSignature,t))}bip371.checkTaprootInputForSigs=checkTaprootInputForSigs;function decodeSchnorrSignature(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||transaction_1.Transaction.SIGHASH_DEFAULT}}function extractTaprootSigs(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map(r=>r.signature)),!t.length){const r=getTapKeySigFromWithness(e.finalScriptWitness);r&&t.push(r)}return t}function getTapKeySigFromWithness(e){if(!e)return;const t=e.slice(2);if(t.length===64||t.length===65)return t}function _tapTreeToList(e,t=[],r=0){if(r>bip341_1.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return e?(0,types_1.isTapleaf)(e)?(t.push({depth:r,leafVersion:e.version||bip341_1.LEAF_VERSION_TAPSCRIPT,script:e.output}),t):(e[0]&&_tapTreeToList(e[0],t,r+1),e[1]&&_tapTreeToList(e[1],t,r+1),t):[]}function instertLeavesInTree(e){let t;for(const r of e)if(t=instertLeafInTree(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}function instertLeafInTree(e,t,r=0){if(r>bip341_1.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if((0,types_1.isTapleaf)(t))return;const s=instertLeafInTree(e,t&&t[0],r+1);if(s)return[s,t&&t[1]];const o=instertLeafInTree(e,t&&t[1],r+1);if(o)return[t&&t[0],o]}function checkMixedTaprootAndNonTaprootInputFields(e,t,r){const s=isTaprootInput(e)&&hasNonTaprootFields(t),o=hasNonTaprootFields(e)&&isTaprootInput(t),n=e===t&&isTaprootInput(t)&&hasNonTaprootFields(t);if(s||o||n)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function checkMixedTaprootAndNonTaprootOutputFields(e,t,r){const s=isTaprootOutput(e)&&hasNonTaprootFields(t),o=hasNonTaprootFields(e)&&isTaprootOutput(t),n=e===t&&isTaprootOutput(t)&&hasNonTaprootFields(t);if(s||o||n)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}function checkIfTapLeafInTree(e,t,r){if(t.tapMerkleRoot){const s=(t.tapLeafScript||[]).every(n=>isTapLeafInTree(n,t.tapMerkleRoot)),o=(e.tapLeafScript||[]).every(n=>isTapLeafInTree(n,t.tapMerkleRoot));if(!s||!o)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every(o=>isTapLeafInTree(o,e.tapMerkleRoot)))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}function isTapLeafInTree(e,t){if(!t)return!0;const r=(0,bip341_1.tapleafHash)({output:e.script,version:e.leafVersion});return(0,bip341_1.rootHashFromPath)(e.controlBlock,r).equals(t)}function sortSignatures(e,t){const r=(0,bip341_1.tapleafHash)({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter(s=>s.leafHash.equals(r)).map(s=>addPubkeyPositionInScript(t.script,s)).sort((s,o)=>o.positionInScript-s.positionInScript).map(s=>s.signature)}function addPubkeyPositionInScript(e,t){return Object.assign({positionInScript:(0,psbtutils_1.pubkeyPositionInScript)(t.pubkey,e)},t)}function findTapLeafToFinalize(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const s=(e.tapLeafScript||[]).sort((o,n)=>o.controlBlock.length-n.controlBlock.length).find(o=>canFinalizeLeaf(o,e.tapScriptSig,r));if(!s)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return s}function canFinalizeLeaf(e,t,r){const s=(0,bip341_1.tapleafHash)({output:e.script,version:e.leafVersion});return(!r||r.equals(s))&&t.find(n=>n.leafHash.equals(s))!==void 0}function hasNonTaprootFields(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}const byteToHex=[];for(let e=0;e<256;++e)byteToHex.push((e+256).toString(16).slice(1));function unsafeStringify(e,t=0){return(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(e,t,r){var o;if(native.randomUUID&&!t&&!e)return native.randomUUID();e=e||{};const s=e.random??((o=e.rng)==null?void 0:o.call(e))??rng();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,unsafeStringify(s)}const COMPRESSED_PUBLIC_KEY_HEX_LENGTH=66,NETWORKS={[Network.MAINNET]:{name:"Mainnet",config:bitcoinjsLib.networks.bitcoin,addressPrefix:{common:"bc1",nativeSegWit:"bc1q",taproot:"bc1p"}},[Network.CANARY]:{name:"Canary",config:bitcoinjsLib.networks.bitcoin,addressPrefix:{common:"bc1",nativeSegWit:"bc1q",taproot:"bc1p"}},[Network.TESTNET]:{name:"Testnet",config:bitcoinjsLib.networks.testnet,addressPrefix:{common:"tb1",nativeSegWit:"tb1q",taproot:"tb1p"}},[Network.SIGNET]:{name:"Signet",config:bitcoinjsLib.networks.testnet,addressPrefix:{common:"tb1",nativeSegWit:"tb1q",taproot:"tb1p"}}},getTaprootAddress=(e,t)=>{e.length==COMPRESSED_PUBLIC_KEY_HEX_LENGTH&&(e=e.slice(2));const r=Buffer$e.from(e,"hex"),{address:s,output:o}=bitcoinjsLib.payments.p2tr({internalPubkey:toXOnly_1(r),network:NETWORKS[t].config});if(!s||!o)throw new Error("Failed to generate taproot address or script from public key");return s},getNativeSegwitAddress=(e,t)=>{if(e.length!==COMPRESSED_PUBLIC_KEY_HEX_LENGTH)throw new Error("Invalid public key length for generating native segwit address");const r=Buffer$e.from(e,"hex"),{address:s,output:o}=bitcoinjsLib.payments.p2wpkh({pubkey:r,network:NETWORKS[t].config});if(!s||!o)throw new Error("Failed to generate native segwit address or script from public key");return s};function validateAddressWithPK(e,t,r){return e.startsWith(NETWORKS[r].addressPrefix.taproot)?e===getTaprootAddress(t,r):e.startsWith(NETWORKS[r].addressPrefix.nativeSegWit)?e===getNativeSegwitAddress(t,r):!1}function validateAddress(e,t){const{addressPrefix:r,name:s}=NETWORKS[e];if(!(e in NETWORKS))throw new Error(`Unsupported network: ${e}. Please provide a valid network.`);if(!t.startsWith(r.common))throw new Error(`Incorrect address prefix for ${s}. Expected address to start with '${r}'.`)}const toNetwork=e=>NETWORKS[e].config,WALLET_PROVIDER_NAME$3="Keystone";class KeystoneProvider{constructor(t,r){at(this,"keystoneWaleltInfo");at(this,"viewSDK");at(this,"dataSdk");at(this,"config");at(this,"connectWallet",async()=>{const r=await(await this.viewSDK.getSdk()).read([sdk$1.SupportedResult.UR_CRYPTO_ACCOUNT],{title:"Sync Keystone with Babylon Staking App",description:"Please scan the QR code displayed on your Keystone, Currently only the first Taproot Address will be used",renderInitial:{walletMode:"btc",link:"",description:["1. Turn on your Keystone 3 with BTC only firmware.",'2. Click connect software wallet and use "Sparrow" for connection.','3. Press the "Sync Keystone" button and scan the QR Code displayed on your Keystone hardware wallet',"4. The first Taproot address will be used for staking."]},URTypeErrorMessage:"The scanned QR code is not the sync code from the Keystone hardware wallet. Please verify the code and try again."});if(r.status===sdk$1.ReadStatus.canceled)throw new Error("Connection to Keystone was canceled");if(r.status!==sdk$1.ReadStatus.success)throw new Error("Error reading QR code, Please try again.");const s=this.dataSdk.parseAccount(r.result),o=3,n=s.keys[o].extendedPublicKey;if(this.keystoneWaleltInfo={mfp:s.masterFingerprint,extendedPublicKey:n,path:s.keys[o].path,address:void 0,publicKeyHex:void 0,scriptPubKeyHex:void 0},!this.keystoneWaleltInfo.extendedPublicKey)throw new Error("Could not retrieve the extended public key");const{address:a,pubkeyHex:l,scriptPubKeyHex:p}=generateP2trAddressFromXpub(this.keystoneWaleltInfo.extendedPublicKey,"M/0/0",toNetwork(this.config.network));this.keystoneWaleltInfo.address=a,this.keystoneWaleltInfo.publicKeyHex=l,this.keystoneWaleltInfo.scriptPubKeyHex=p});at(this,"getAddress",async()=>{var t;if(!((t=this.keystoneWaleltInfo)!=null&&t.address))throw new Error("Could not retrieve the address");return this.keystoneWaleltInfo.address});at(this,"getPublicKeyHex",async()=>{var t;if(!((t=this.keystoneWaleltInfo)!=null&&t.publicKeyHex))throw new Error("Could not retrieve the BTC public key");return this.keystoneWaleltInfo.publicKeyHex});at(this,"signPsbt",async t=>{var n,a;if(!((n=this.keystoneWaleltInfo)!=null&&n.address)||!((a=this.keystoneWaleltInfo)!=null&&a.publicKeyHex))throw new Error("Keystone Wallet not connected");if(!t)throw new Error("psbt hex is required");let r=bitcoinjsLib.Psbt.fromHex(t);r=this.enhancePsbt(r);const s=r.toHex();return(await this.sign(s)).toHex()});at(this,"signPsbts",async t=>{var s,o;if(!((s=this.keystoneWaleltInfo)!=null&&s.address)||!((o=this.keystoneWaleltInfo)!=null&&o.publicKeyHex))throw new Error("Keystone Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");const r=[];for(const n of t){const a=await this.signPsbt(n);r.push(a)}return r});at(this,"getNetwork",async()=>this.config.network);at(this,"signMessage",async(t,r)=>{if(r!=="ecdsa")throw new Error("Only ECDSA signature is supported");if(!this.keystoneWaleltInfo)throw new Error("Keystone Wallet not connected");const s=this.dataSdk.btc.generateSignRequest({requestId:v4(),signData:Buffer$1$1.from(t,"utf-8").toString("hex"),dataType:dist$v.KeystoneBitcoinSDK.DataType.message,accounts:[{path:`${this.keystoneWaleltInfo.path}/0/0`,xfp:`${this.keystoneWaleltInfo.mfp}`,address:this.keystoneWaleltInfo.address}],origin:"babylon staking app"}),o=composeQRProcess(sdk$1.SupportedResult.UR_BTC_SIGNATURE),n=await this.viewSDK.getSdk(),a=await o(n,s),l=this.dataSdk.btc.parseSignature(a);return Buffer$1$1.from(l.signature,"hex").toString("base64")});at(this,"getInscriptions",async()=>{throw new Error("Method not implemented.")});at(this,"on",()=>{});at(this,"off",()=>{});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$3);at(this,"getWalletProviderIcon",async()=>logo$3);at(this,"sign",async t=>{if(!t)throw new Error("psbt hex is required");const r=this.dataSdk.btc.generatePSBT(Buffer$1$1.from(t,"hex")),s=composeQRProcess(sdk$1.SupportedResult.UR_PSBT),o=await this.viewSDK.getSdk(),n=await s(o,r),a=this.dataSdk.btc.parsePSBT(n),l=bitcoinjsLib.Psbt.fromHex(a);return l.finalizeAllInputs(),l});at(this,"enhancePsbt",t=>{var s,o,n,a;if(!((s=this.keystoneWaleltInfo)!=null&&s.scriptPubKeyHex)||!((o=this.keystoneWaleltInfo)!=null&&o.publicKeyHex)||!((n=this.keystoneWaleltInfo)!=null&&n.mfp)||!((a=this.keystoneWaleltInfo)!=null&&a.path))throw new Error("Keystone Wallet not connected");const r={masterFingerprint:Buffer$1$1.from(this.keystoneWaleltInfo.mfp,"hex"),path:`${this.keystoneWaleltInfo.path}/0/0`,pubkey:Buffer$1$1.from(this.keystoneWaleltInfo.publicKeyHex,"hex")};return t.data.inputs.forEach(l=>{l.tapBip32Derivation=[{...r,pubkey:toXOnly_1(r.pubkey),leafHashes:caculateTapLeafHash(l,r.pubkey)}]}),t});this.config=r,sdk$1.viewSdk.bootstrap(),this.viewSDK=sdk$1.viewSdk,this.dataSdk=new dist$v.KeystoneSDK({origin:"babylon staking app"})}}const composeQRProcess=e=>async(t,r)=>{if(await t.play(r,{title:"Scan the QR Code",description:"Please scan the QR code with your Keystone device."})!==sdk$1.PlayStatus.success)throw new Error("Could not generate the QR code, please try again.");const o=await t.read([e],{title:"Get the Signature from Keystone",description:"Please scan the QR code displayed on your Keystone",URTypeErrorMessage:"The scanned QR code can't be read. please verify and try again."});if(o.status!==sdk$1.ReadStatus.success)throw new Error("Could not extract the signature, please try again.");return o.result},generateP2trAddressFromXpub=(e,t,r)=>{const o=HDKey.fromExtendedKey(e).derive(t),n=Buffer$1$1.from(o.publicKey),a=toXOnly_1(n);let l,p;try{const u=bitcoinjsLib.payments.p2tr({internalPubkey:a,network:r});l=u.address,p=u.output}catch(u){if(u instanceof Error&&u.message.includes("ECC")){btcStakingTs.initBTCCurve();const c=bitcoinjsLib.payments.p2tr({internalPubkey:a,network:r});l=c.address,p=c.output}else throw new Error(u)}return{address:l,pubkeyHex:n.toString("hex"),scriptPubKeyHex:p.toString("hex")}},caculateTapLeafHash=(e,t)=>e.tapInternalKey&&!e.tapLeafScript?[]:(e.tapLeafScript||[]).filter(s=>pubkeyInScript_1(t,s.script)).map(s=>{const o=bip341.tapleafHash({output:s.script,version:s.leafVersion});return Object.assign({hash:o},s)}).map(s=>s.hash),metadata$5={id:"keystone",name:WALLET_PROVIDER_NAME$3,icon:logo$3,docs:"https://www.keyst.one/btc-only",createProvider:(e,t)=>new KeystoneProvider(e,t),networks:[Network.MAINNET,Network.SIGNET],label:"Hardware wallet"},logo$2="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='225px'%20height='224px'%20viewBox='0%200%20225%20224'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eokx%3c/title%3e%3cg%20id='Page-1'%20stroke='none'%20strokeWidth='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='okx'%20transform='translate(0.401000,%200.006000)'%20fill='%23000000'%20fill-rule='nonzero'%3e%3cpath%20d='M144.382,74.667%20L79.673,74.667%20C76.924,74.667%2074.695,76.895%2074.695,79.644%20L74.695,144.354%20C74.695,147.103%2076.924,149.332%2079.673,149.332%20L144.382,149.332%20C147.131,149.332%20149.36,147.103%20149.36,144.354%20L149.36,79.644%20C149.36,76.895%20147.131,74.667%20144.382,74.667%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,0%20L4.978,0%20C2.229,0%200,2.228%200,4.978%20L0,69.687%20C0,72.436%202.229,74.665%204.978,74.665%20L69.687,74.665%20C72.437,74.665%2074.665,72.436%2074.665,69.687%20L74.665,4.978%20C74.665,2.228%2072.437,0%2069.687,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,0%20L154.307,0%20C151.558,0%20149.329,2.228%20149.329,4.978%20L149.329,69.687%20C149.329,72.436%20151.558,74.665%20154.307,74.665%20L219.017,74.665%20C221.766,74.665%20223.994,72.436%20223.994,69.687%20L223.994,4.978%20C223.994,2.228%20221.766,0%20219.017,0%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M69.687,149.328%20L4.978,149.328%20C2.229,149.328%200,151.556%200,154.305%20L0,219.015%20C0,221.764%202.229,223.993%204.978,223.993%20L69.687,223.993%20C72.437,223.993%2074.665,221.764%2074.665,219.015%20L74.665,154.305%20C74.665,151.556%2072.437,149.328%2069.687,149.328%20Z'%20id='Path'%3e%3c/path%3e%3cpath%20d='M219.017,149.328%20L154.307,149.328%20C151.558,149.328%20149.329,151.556%20149.329,154.305%20L149.329,219.015%20C149.329,221.764%20151.558,223.993%20154.307,223.993%20L219.017,223.993%20C221.766,223.993%20223.994,221.764%20223.994,219.015%20L223.994,154.305%20C223.994,151.556%20221.766,149.328%20219.017,149.328%20Z'%20id='Path'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e",PROVIDER_NAMES={[Network.MAINNET]:"bitcoin",[Network.CANARY]:"bitcoin",[Network.TESTNET]:"bitcoinTestnet",[Network.SIGNET]:"bitcoinSignet"},WALLET_PROVIDER_NAME$2="OKX";class OKXProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var o;try{await this.wallet.enable()}catch(n){throw(o=n==null?void 0:n.message)!=null&&o.includes("rejected")?new Error("Connection to OKX Wallet was rejected"):new Error(n==null?void 0:n.message)}let t;try{t=await this.provider.connect()}catch{throw new Error(`BTC ${this.config.network} is not enabled in OKX Wallet`)}const{address:r,compressedPublicKey:s}=t;if(validateAddress(this.config.network,r),s&&r)this.walletInfo={publicKeyHex:s,address:r};else throw new Error("Could not connect to OKX Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signPsbt(t)});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signPsbts(t)});at(this,"getNetwork",async()=>{if(!this.config.network)throw new Error("Network not set");return this.config.network});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on OKX Wallet BTC mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from OKX Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(t==="accountChanged")return this.provider.on(t,r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("OKX Wallet not connected");if(t==="accountChanged")return this.provider.off(t,r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$2);at(this,"getWalletProviderIcon",async()=>logo$2);if(this.wallet=t,this.config=r,!t)throw new Error("OKX Wallet extension not found");const s=PROVIDER_NAMES[r.network];if(!s)throw new Error("Unsupported network");this.provider=t[s]}}const metadata$4={id:"okx",name:WALLET_PROVIDER_NAME$2,icon:logo$2,docs:"https://www.okx.com/web3",wallet:"okxwallet",createProvider:(e,t)=>new OKXProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo$1="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_45922_88)'%3e%3cpath%20d='M127.61%2063.8049C127.61%20107.853%20107.853%20127.61%2063.8049%20127.61C19.7568%20127.61%200%20107.853%200%2063.8049C0%2019.7568%2019.7568%200%2063.8049%200C107.853%200%20127.61%2019.7568%20127.61%2063.8049Z'%20fill='%233BD23D'/%3e%3cpath%20d='M69.5699%2027.0557L51.8197%2027.0557L48.7056%2036.4719H58.5645L58.5645%2056.3063H69.5699V27.0557Z'%20fill='black'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M84.0486%2080.3111C84.0486%2091.4912%2074.9854%20100.554%2063.8053%20100.554C52.6253%20100.554%2043.5621%2091.4912%2043.5621%2080.3111C43.5621%2069.1311%2052.6253%2060.0678%2063.8053%2060.0678C74.9854%2060.0678%2084.0486%2069.1311%2084.0486%2080.3111ZM74.8584%2080.3111C74.8584%2086.4155%2069.9097%2091.3641%2063.8053%2091.3641C57.7008%2091.3641%2052.7522%2086.4155%2052.7522%2080.3111C52.7522%2074.2066%2057.7008%2069.258%2063.8053%2069.258C69.9097%2069.258%2074.8584%2074.2066%2074.8584%2080.3111Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_45922_88'%3e%3crect%20width='128'%20height='128'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",INTERNAL_NETWORK_NAMES={[Network.MAINNET]:"livenet",[Network.TESTNET]:"testnet",[Network.SIGNET]:"signet"},WALLET_PROVIDER_NAME$1="OneKey";class OneKeyProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var s;try{await this.provider.connectWallet()}catch(o){throw(s=o==null?void 0:o.message)!=null&&s.includes("rejected")?new Error("Connection to OneKey Wallet was rejected"):new Error(o==null?void 0:o.message)}const t=await this.provider.getAddress();validateAddress(this.config.network,t);const r=await this.provider.getPublicKeyHex();if(r&&t)this.walletInfo={publicKeyHex:r,address:t};else throw new Error("Could not connect to OneKey Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(!t)throw new Error("psbt hex is required");return this.provider.signPsbt(t)});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");return this.provider.signPsbts(t)});at(this,"getNetwork",async()=>{const t=await this.provider.getNetwork();for(const[r,s]of Object.entries(INTERNAL_NETWORK_NAMES)){if(s==="testnet")return Network.SIGNET;if(s===t)return r}throw new Error("Unsupported network")});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on OneKey Wallet BTC Mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from OneKey Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(t==="accountChanged")return this.provider.on(t,r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("OneKey Wallet not connected");if(t==="accountChanged")return this.provider.off(t,r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME$1);at(this,"getWalletProviderIcon",async()=>logo$1);if(this.config=r,!(t!=null&&t.btcwallet))throw new Error("OneKey Wallet extension not found");this.provider=t.btcwallet}}const metadata$3={id:"onekey",name:WALLET_PROVIDER_NAME$1,icon:logo$1,docs:"https://onekey.so/download",wallet:"$onekey",createProvider:(e,t)=>new OneKeyProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},logo="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='59'%20height='59'%3e%3cdefs%3e%3clinearGradient%20id='a'%20x1='91.9%25'%20x2='5.127%25'%20y1='28.561%25'%20y2='67.452%25'%3e%3cstop%20offset='0%25'%20stop-color='%23070100'/%3e%3cstop%20offset='36%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='67%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='100%25'%20stop-color='%23F4B852'/%3e%3c/linearGradient%3e%3clinearGradient%20id='b'%20x1='10.514%25'%20x2='111.046%25'%20y1='63.228%25'%20y2='37.55%25'%3e%3cstop%20offset='0%25'%20stop-color='%23070100'/%3e%3cstop%20offset='37%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='67%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='100%25'%20stop-color='%23F4FB52'/%3e%3c/linearGradient%3e%3cradialGradient%20id='c'%20cx='49.933%25'%20cy='50.067%25'%20r='50%25'%20fx='49.933%25'%20fy='50.067%25'%3e%3cstop%20offset='0%25'%20stop-color='%23F4B852'/%3e%3cstop%20offset='33%25'%20stop-color='%23EA8101'/%3e%3cstop%20offset='64%25'%20stop-color='%2377390D'/%3e%3cstop%20offset='100%25'%20stop-color='%23070100'/%3e%3c/radialGradient%3e%3c/defs%3e%3cg%20fill='none'%20fill-rule='nonzero'%20transform='translate(7%201)'%3e%3cpath%20fill='url(%23a)'%20d='m31.764%205.2%2011.761%2011.745c1%20.997%201.492%202.006%201.475%203.027-.018%201.014-.446%201.947-1.29%202.787-.879.88-1.827%201.33-2.845%201.347-1.017.018-2.023-.478-3.03-1.475L25.81%2010.617c-1.365-1.364-2.683-2.332-3.955-2.898-1.267-.566-2.602-.653-4.002-.268-1.399.385-2.902%201.382-4.51%202.991-2.22%202.217-3.278%204.298-3.168%206.246.11%201.948%201.208%203.96%203.301%206.054L25.6%2034.854c1.012%201.01%201.51%202.018%201.492%203.021-.017%201.003-.45%201.936-1.307%202.788-.855.851-1.792%201.3-2.821%201.335-1.024.035-2.041-.455-3.053-1.464L8.16%2028.79c-1.913-1.913-3.295-3.72-4.145-5.423-.85-1.703-1.168-3.633-.949-5.785.197-1.843.787-3.628%201.758-5.36.977-1.732%202.37-3.499%204.18-5.313%202.157-2.157%204.216-3.808%206.182-4.957C17.153.803%2019.049.161%2020.882.027c1.833-.134%203.643.233%205.435%201.102%201.787.869%203.603%202.222%205.453%204.07h-.006Z'/%3e%3cpath%20fill='url(%23b)'%20d='M13.234%2051.841%201.474%2040.188c-1-.99-1.49-1.99-1.474-3.003.018-1.012.446-1.932%201.29-2.766.878-.873%201.827-1.319%202.844-1.336%201.018-.017%202.024.469%203.03%201.464l12.025%2011.919c1.37%201.354%202.682%202.314%203.954%202.876%201.272.56%202.602.648%204%20.266%201.4-.382%202.903-1.372%204.51-2.968%202.22-2.2%203.278-4.265%203.169-6.197-.11-1.933-1.209-3.935-3.302-6.006l-6.457-6.347c-1.012-1.001-1.51-2.002-1.492-2.998.017-.995.451-1.92%201.307-2.765.855-.845%201.792-1.29%202.82-1.325%201.024-.035%202.042.451%203.053%201.452l6.088%205.983c1.914%201.898%203.296%203.691%204.145%205.38.85%201.69%201.168%203.605.949%205.74-.197%201.829-.787%203.6-1.758%205.318-.977%201.718-2.37%203.471-4.18%205.27-2.156%202.142-4.214%203.78-6.18%204.919-1.966%201.14-3.862%201.776-5.695%201.91-1.832.132-3.642-.232-5.434-1.094-1.787-.862-3.608-2.205-5.452-4.039Z'/%3e%3ccircle%20cx='20'%20cy='18'%20r='4'%20fill='url(%23c)'/%3e%3c/g%3e%3c/svg%3e",WALLET_PROVIDER_NAME="Unisat";class UnisatProvider{constructor(t,r){at(this,"provider");at(this,"walletInfo");at(this,"config");at(this,"connectWallet",async()=>{var o;let t;try{t=await this.provider.requestAccounts()}catch(n){throw(o=n==null?void 0:n.message)!=null&&o.includes("rejected")?new Error("Connection to Unisat Wallet was rejected"):new Error(n==null?void 0:n.message)}const r=t[0];validateAddress(this.config.network,r);const s=await this.provider.getPublicKey();if(s&&r)this.walletInfo={publicKeyHex:s,address:r};else throw new Error("Could not connect to Unisat Wallet")});at(this,"getAddress",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return this.walletInfo.address});at(this,"getPublicKeyHex",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return this.walletInfo.publicKeyHex});at(this,"signPsbt",async t=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(!t)throw new Error("psbt hex is required");const r=await this.getNetwork();try{return await this.provider.signPsbt(t,this.getSignPsbtDefaultOptions(t,r))}catch(s){throw new Error((s==null?void 0:s.message)||s)}});at(this,"signPsbts",async t=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(!t&&!Array.isArray(t))throw new Error("psbts hexes are required");const r=await this.getNetwork();try{return await this.provider.signPsbts(t,t.map(s=>this.getSignPsbtDefaultOptions(s,r)))}catch(s){throw new Error((s==null?void 0:s.message)||s)}});at(this,"getNetwork",async()=>{switch((await this.provider.getChain()).enum){case"BITCOIN_MAINNET":return Network.MAINNET;case"BITCOIN_SIGNET":return Network.SIGNET;case"BITCOIN_TESTNET":return Network.SIGNET;default:throw new Error("Unsupported network")}});at(this,"signMessage",async(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");return await this.provider.signMessage(t,r)});at(this,"getInscriptions",async()=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(this.config.network!==Network.MAINNET)throw new Error("Inscriptions are only available on Unisat Wallet BTC Mainnet");const t=100,r=100,s=[];let o=0,n=0;try{for(;n<t;){const{list:a}=await this.provider.getInscriptions(o,r),l=a.map(p=>{const[u,c]=p.output.split(":");return{txid:u,vout:c}});if(s.push(...l),a.length<r)break;if(o+=r,n++,n>=t)throw new Error("Exceeded maximum iterations when fetching inscriptions")}}catch{throw new Error("Failed to get inscriptions from Unisat Wallet")}return s});at(this,"on",(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(t==="accountChanged")return this.provider.on("accountsChanged",r)});at(this,"off",(t,r)=>{if(!this.walletInfo)throw new Error("Unisat Wallet not connected");if(t==="accountChanged")return this.provider.removeListener("accountsChanged",r)});at(this,"getWalletProviderName",async()=>WALLET_PROVIDER_NAME);at(this,"getWalletProviderIcon",async()=>logo);if(this.config=r,!t)throw new Error("Unisat Wallet extension not found");this.provider=t}getSignPsbtDefaultOptions(t,r){const s=[];return bitcoinjsLib.Psbt.fromHex(t).data.inputs.forEach((n,a)=>{var u,c;let l=!1;if(n.witnessUtxo&&n.witnessUtxo.script){let v=bitcoinjsLib.networks.bitcoin;(r===Network.TESTNET||r===Network.SIGNET)&&(v=bitcoinjsLib.networks.testnet);let w;try{w=bitcoinjsLib.address.fromOutputScript(n.witnessUtxo.script,v)}catch(I){if(I instanceof Error&&I.message.toLowerCase().includes("has no matching address"))btcStakingTs.initBTCCurve(),w=bitcoinjsLib.address.fromOutputScript(n.witnessUtxo.script,v);else throw new Error(I)}const b=w.indexOf("tb1p")===0||w.indexOf("bc1p")===0,E=w===((u=this.walletInfo)==null?void 0:u.address);b&&E&&(l=!0)}n.finalScriptSig||n.finalScriptWitness||s.push({index:a,publicKey:(c=this.walletInfo)==null?void 0:c.publicKeyHex,sighashTypes:void 0,useTweakedSigner:l})}),{autoFinalized:!0,toSignInputs:s}}}const metadata$2={id:"unisat",name:WALLET_PROVIDER_NAME,icon:logo,docs:"https://unisat.io/download",wallet:"unisat",createProvider:(e,t)=>new UnisatProvider(e,t),networks:[Network.MAINNET,Network.SIGNET]},metadata$1={chain:"BTC",name:"Bitcoin",icon,wallets:[metadata$6,metadata$4,metadata$3,metadata$2,metadata$5]},metadata={BTC:metadata$1,BBN:metadata$7};function usePersistState(e,t,r){function s(){const a=r;if(typeof t>"u")return a;const l=t.getItem(e);return(l?JSON.parse(l):null)??a}const[o,n]=react.useState(s);return react.useEffect(function(){t.setItem(e,JSON.stringify(o??""))},[e,t,o]),[o,n]}const Context$2=react.createContext({lockInscriptions:!0,showAgain:!0});function InscriptionProvider({children:e,context:t}){const[r,s]=usePersistState("bwc-inscription-modal-show-again",t.localStorage,!0),[o,n]=usePersistState("bwc-inscription-modal-lock",t.localStorage,!0),a=react.useMemo(()=>({showAgain:r,lockInscriptions:o,toggleLockInscriptions:n,toggleShowAgain:s}),[r,o,n,s]);return jsxRuntime.jsx(Context$2.Provider,{value:a,children:e})}const useInscriptionProvider=()=>react.useContext(Context$2),defaultState$2={confirmed:!1,visible:!1,screen:{type:"TERMS_OF_SERVICE"},chains:{},selectedWallets:{}},StateContext=react.createContext(defaultState$2);function StateProvider({children:e,chains:t}){const[r,s]=react.useState(defaultState$2);react.useEffect(()=>{s(a=>({...a,chains:t.reduce((l,p)=>({...l,[p.id]:p}),{})}))},[t]);const o=react.useMemo(()=>({open:()=>{s(a=>({...a,visible:!0}))},close:()=>{s(a=>({...a,visible:!1}))},reset:()=>{s(({chains:a})=>({...defaultState$2,chains:a}))},displayLoader:(a="")=>{s(l=>({...l,screen:{type:"LOADER",params:{message:a}}}))},displayTermsOfService:()=>{s(a=>({...a,screen:{type:"TERMS_OF_SERVICE"}}))},displayChains:()=>{s(a=>({...a,screen:{type:"CHAINS"}}))},displayWallets:a=>{s(l=>({...l,screen:{type:"WALLETS",params:{chain:a}}}))},displayInscriptions:()=>{s(a=>({...a,screen:{type:"INSCRIPTIONS"}}))},displayError:a=>{s(l=>({...l,screen:{type:"ERROR",params:a}}))},selectWallet:(a,l)=>{s(p=>({...p,selectedWallets:{...p.selectedWallets,[a]:l}}))},removeWallet:a=>{s(l=>({...l,selectedWallets:{...l.selectedWallets,[a]:void 0}}))},confirm:()=>{s(a=>({...a,confirmed:!0}))}}),[]),n=react.useMemo(()=>({...r,...o}),[r,o]);return jsxRuntime.jsx(StateContext.Provider,{value:n,children:e})}const defaultState$1={BTC:null,BBN:null},Context$1=react.createContext(defaultState$1);function ChainProvider({persistent:e,storage:t,children:r,context:s,config:o,onError:n}){const[a,l]=react.useState(defaultState$1),p=react.useCallback(async()=>{const c=o.filter(w=>metadata[w.chain]).map(({chain:w,config:b})=>createWalletConnector({persistent:e,metadata:metadata[w],context:s,config:b,accountStorage:t}));return(await Promise.all(c)).reduce((w,b)=>({...w,[b.id]:b}),{})},[e]);react.useEffect(()=>{p().then(c=>{l(c)}).catch(n)},[l,p,n]);const u=react.useMemo(()=>Object.values(a).filter(Boolean),[a]);return jsxRuntime.jsx(InscriptionProvider,{context:s,children:jsxRuntime.jsx(StateProvider,{chains:u,children:jsxRuntime.jsx(Context$1.Provider,{value:a,children:r})})})}const useChainProviders=()=>react.useContext(Context$1),Context=react.createContext({});function LifeCycleHooksProvider({children:e,value:t}){const r=react.useMemo(()=>t??{},[t]);return jsxRuntime.jsx(Context.Provider,{value:r,children:e})}const useLifeCycleHooks=()=>react.useContext(Context),CONNECTED_ACCOUNTS_KEY="baby-connected-wallet-accounts",createAccountStorage=e=>({get:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};if(!(r._timestamp&&Date.now()-r._timestamp>e))return r[t]},has:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};return r._timestamp&&Date.now()-r._timestamp>e?!1:!!r[t]},set:(t,r)=>{const s=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{};s[t]=r,s._timestamp=Date.now(),localStorage.setItem(CONNECTED_ACCOUNTS_KEY,JSON.stringify(s))},delete:t=>{const r=localStorage.getItem(CONNECTED_ACCOUNTS_KEY)?JSON.parse(localStorage.getItem(CONNECTED_ACCOUNTS_KEY)||"{}"):{},s=Reflect.deleteProperty(r,t);return localStorage.setItem(CONNECTED_ACCOUNTS_KEY,JSON.stringify(r)),s}});var freeGlobal=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self;freeGlobal||freeSelf||Function("return this")();var useIsomorphicLayoutEffect=typeof window<"u"?react.useLayoutEffect:react.useEffect,IS_SERVER2=typeof window>"u";function useMediaQuery(e,{defaultValue:t=!1,initializeWithValue:r=!0}={}){const s=l=>IS_SERVER2?t:window.matchMedia(l).matches,[o,n]=react.useState(()=>r?s(e):t);function a(){n(s(e))}return useIsomorphicLayoutEffect(()=>{const l=window.matchMedia(e);return a(),l.addListener?l.addListener(a):l.addEventListener("change",a),()=>{l.removeListener?l.removeListener(a):l.removeEventListener("change",a)}},[e]),o}const useIsMobileView=()=>useMediaQuery("(max-width: 768px)");function ResponsiveDialog(e){const r=useIsMobileView()?coreUi.MobileDialog:coreUi.Dialog;return jsxRuntime.jsx(r,{...e})}const useWidgetState=()=>react.useContext(StateContext);function useWalletConnect(){const{confirmed:e,chains:t,selectedWallets:r,open:s,reset:o}=useWidgetState(),n=useChainProviders(),a=react.useCallback(()=>{o==null||o(),s==null||s()},[s,o]),l=react.useCallback(async()=>{for(const u of Object.values(n))u&&await u.disconnect();o==null||o()},[n,o]),p=react.useMemo(()=>Object.values(t).filter(Boolean).map(v=>r[v.id]).every(Boolean),[t,r]);return{selected:p,connected:p&&e,open:a,disconnect:l}}const ANIMATION_DELAY$1=1e3;function useWalletConnectors({persistent:e,accountStorage:t,onError:r}){const s=useChainProviders(),{selectWallet:o,removeWallet:n,displayLoader:a,displayChains:l,displayInscriptions:p,displayError:u,confirm:c,close:v,reset:w}=useWidgetState(),{showAgain:b}=useInscriptionProvider(),{verifyBTCAddress:E,acceptTermsOfService:I}=useLifeCycleHooks();react.useEffect(()=>{const q=Object.values(s).filter(Boolean).map(U=>U.on("connecting",F=>{a==null||a(F)}));return()=>q.forEach(U=>U())},[a,s]),react.useEffect(()=>{const M=Object.values(s).filter(Boolean),q={BTC:F=>async j=>{var y,T,D;try{j&&j.account&&(o==null||o("BTC",j),e&&t.set(F.id,j.id),await(I==null?void 0:I({address:j.account.address,public_key:j.account.publicKeyHex})));const L=()=>void(b?p==null?void 0:p():l==null?void 0:l());if(!validateAddressWithPK(((y=j.account)==null?void 0:y.address)??"",((T=j.account)==null?void 0:T.publicKeyHex)??"",F.config.network)){u==null||u({title:"Public Key Mismatch",description:"The Bitcoin address and Public Key for this wallet do not match. Please contact your wallet provider for support.",onSubmit:L,onCancel:()=>{n==null||n(F.id),l==null||l()}});return}if(E&&!await E(((D=j.account)==null?void 0:D.address)??"")){for(const C of M)await C.disconnect();u==null||u({title:"Connection Failed",description:"The wallet cannot be connected.",submitButton:"",cancelButton:"Done",onCancel:async()=>{v==null||v(),setTimeout(()=>void(w==null?void 0:w()),ANIMATION_DELAY$1)}});return}L()}catch(L){r==null||r(L)}},BBN:F=>j=>{j&&(o==null||o(F.id,j),e&&t.set(F.id,j.id)),l==null||l()}},U=M.map(F=>{var j;return F.on("connect",(j=q[F.id])==null?void 0:j.call(q,F))});return M.forEach(F=>{o==null||o(F.id,F.connectedWallet)}),()=>U.forEach(F=>F())},[r,o,n,p,l,E,w,v,s,b,e]),react.useEffect(()=>{const q=Object.values(s).filter(Boolean).map(U=>U.on("disconnect",F=>{F&&(n==null||n(U.id),l==null||l(),e&&t.delete(U.id))}));return()=>q.forEach(U=>U())},[n,l,s,e]),react.useEffect(()=>{const q=Object.values(s).filter(Boolean).map(U=>U.on("error",F=>{r==null||r(F),l==null||l()}));return()=>q.forEach(U=>U())},[r,l,s]),react.useEffect(()=>{const M=Object.values(s).filter(Boolean);e&&M.length&&M.every(q=>t.has(q.id))&&(c==null||c(),l==null||l())},[e,s,c,l]);const x=react.useCallback(async(M,q)=>{const U=s[M.id];await(U==null?void 0:U.connect(q.id))},[s]),B=react.useCallback(async M=>{const q=s[M];await(q==null?void 0:q.disconnect())},[s]);return{connect:x,disconnect:B}}function useWalletWidgets(e,t){const r=react.useCallback((s,o)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:o.map(({id:n,widget:a})=>jsxRuntime.jsx(a,{id:n,connector:e[s],createWallet:createExternalWallet},n))}),[e]);return react.useMemo(()=>t.reduce((s,o)=>({...s,[o.chain]:r(o.chain,o.connectors??[])}),{}),[r,t])}function ChainButton({className:e,disabled:t,alt:r,logo:s,title:o,children:n,onClick:a}){const l=typeof s=="string"?jsxRuntime.jsx(coreUi.Avatar,{url:s,alt:r}):jsxRuntime.jsx(coreUi.Avatar,{children:s});return jsxRuntime.jsxs(coreUi.Text,{disabled:t,as:t?"div":"button",className:tailwindMerge.twMerge("flex w-full flex-col gap-2.5 rounded border border-secondary-strokeLight bg-surface p-4 text-accent-primary",t?"pointer-events-none":"pointer-events-auto",t?"cursor-default":"cursor-pointer",e),onClick:a,children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2.5",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:l}),o,!t&&jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"ml-auto block",children:jsxRuntime.jsx("path",{d:"M8.58984 16.59L13.1698 12L8.58984 7.41L9.99984 6L15.9998 12L9.99984 18L8.58984 16.59Z",fill:"currentColor"})})]}),n&&jsxRuntime.jsx("div",{className:"pointer-events-auto w-full",onClick:p=>p.stopPropagation(),children:n})]})}const formatAddress=(e,t=8)=>e.length<=t?e:t===0?"...":`${e.slice(0,t/2)}...${e.slice(-t/2)}`,ConnectedWallet=react.memo(({className:e,chainId:t,logo:r,name:s,address:o,onDisconnect:n})=>jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex shrink-0 items-center gap-2.5 rounded border border-secondary-main/30 p-2",e),children:[jsxRuntime.jsx(coreUi.Avatar,{variant:"rounded",size:"medium",url:r}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col items-start",children:[jsxRuntime.jsx(coreUi.Text,{as:"div",variant:"body2",className:"leading-4 text-accent-primary",children:s}),!!o&&jsxRuntime.jsx(coreUi.Text,{as:"div",variant:"caption",className:"leading-4 text-accent-secondary",children:formatAddress(o)})]}),jsxRuntime.jsx("button",{className:"shrink-0 cursor-pointer",onClick:()=>void(n==null?void 0:n(t)),children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",className:"text-secondary-main",fill:"none",children:jsxRuntime.jsx("path",{d:"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",fill:"currentColor"})})})]})),Chains=react.memo(({disabled:e=!1,chains:t,selectedWallets:r={},className:s,onClose:o,onConfirm:n,onSelectChain:a,onDisconnectWallet:l})=>jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col text-accent-primary",s),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"mb-10",title:"Connect Wallets",onClose:o,children:jsxRuntime.jsx(coreUi.Text,{className:"text-accent-secondary",children:"Connect to both Bitcoin and Babylon Chain Wallets"})}),jsxRuntime.jsx(coreUi.DialogBody,{className:"flex flex-col gap-6",children:t.map(p=>{var c;const u=r[p.id];return jsxRuntime.jsx(ChainButton,{disabled:!!u,title:`Select ${p.name} Wallet`,logo:p.icon,alt:p.name,onClick:()=>void(a==null?void 0:a(p)),children:u&&jsxRuntime.jsx(ConnectedWallet,{chainId:p.id,logo:u.icon,name:u.name,address:((c=u.account)==null?void 0:c.address)??"",onDisconnect:l})},p.id)})}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"mt-auto flex gap-4 pt-10",children:[jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:o,children:"Cancel"}),jsxRuntime.jsx(coreUi.Button,{disabled:e,fluid:!0,onClick:n,children:"Done"})]})]}));function ChainsContainer(e){const{chains:t,selectedWallets:r,displayWallets:s}=useWidgetState(),{selected:o}=useWalletConnect(),n=react.useMemo(()=>Object.values(t),[t]),a=react.useCallback(l=>{s==null||s(l.id)},[s]);return jsxRuntime.jsx(Chains,{disabled:!o,chains:n,selectedWallets:r,onSelectChain:a,...e})}const DEFAULT_ICON=jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"52",height:"52",viewBox:"0 0 52 52",fill:"none",children:jsxRuntime.jsx("path",{d:"M2.16675 46.5837H49.8334L26.0001 5.41699L2.16675 46.5837ZM28.1667 40.0837H23.8334V35.7503H28.1667V40.0837ZM28.1667 31.417H23.8334V22.7503H28.1667V31.417Z",fill:"#387085"})});function Error$1({className:e,icon:t=DEFAULT_ICON,title:r,description:s,cancelButton:o="Cancel",submitButton:n=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Continue ",jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Anyway"})]}),onCancel:a,onSubmit:l}){return jsxRuntime.jsxs("div",{className:e,children:[jsxRuntime.jsxs(coreUi.DialogBody,{className:"py-16 text-center",children:[jsxRuntime.jsx("div",{className:"mb-6 inline-flex h-20 w-20 items-center justify-center bg-primary-contrast text-primary-light",children:t}),jsxRuntime.jsx(coreUi.Heading,{variant:"h4",className:"mb-4 text-accent-primary",children:r}),jsxRuntime.jsx(coreUi.Text,{as:"div",className:"text-accent-secondary",children:s})]}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"flex gap-4",children:[o&&jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:a,children:o}),n&&jsxRuntime.jsx(coreUi.Button,{fluid:!0,onClick:l,children:n})]})]})}function ErrorContainer({className:e}){const{screen:t}=useWidgetState(),{icon:r,title:s,description:o,cancelButton:n,submitButton:a,onCancel:l,onSubmit:p}=t.params??{};return jsxRuntime.jsx(Error$1,{className:e,icon:r,title:s,description:o,cancelButton:n,submitButton:a,onCancel:l,onSubmit:p})}function FieldControl({label:e,className:t,children:r}){return jsxRuntime.jsxs("label",{className:tailwindMerge.twMerge("flex cursor-pointer gap-4 rounded border border-secondary-strokeLight text-accent-primary p-4",t),children:[r,e]})}function Inscriptions({className:e,config:t,onSubmit:r}){const[s=!0,o]=react.useState(),[n=!0,a]=react.useState();if(!t)return null;const{coinName:l}=t;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",e),children:[jsxRuntime.jsx(coreUi.DialogHeader,{title:`Manage ${l} Inscriptions`,className:"mb-4 text-accent-primary",onClose:()=>void(r==null?void 0:r(s,n))}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsxs(coreUi.Text,{className:"mb-8 text-accent-secondary",children:["By default, we will not use ",l," that contains Inscriptions - such as Ordinals, NFTs, or Runes - in your stakeable balance. This helps prevent any accidental loss of your Inscriptions due to staking, unbonding, or withdrawal fees."]}),jsxRuntime.jsxs(coreUi.Text,{className:"mb-10 text-accent-secondary",children:["If you would like to include ",l," with Inscriptions in your stakeable balance, please select the option below."]}),jsxRuntime.jsxs("form",{action:"",children:[jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("strong",{className:"mr-2",children:"Do not use"})," ",l," with Inscriptions for staking. (Recommended)"]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Radio,{name:"inscriptions",checked:s,onChange:()=>o(!0)})}),jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("strong",{className:"mr-2",children:"Use"})," ",l," with Inscriptions in my stakable balance."]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Radio,{name:"inscriptions",checked:!s,onChange:()=>o(!1)})})]})]}),jsxRuntime.jsxs(coreUi.DialogFooter,{className:"mt-auto pt-10",children:[jsxRuntime.jsx(coreUi.Checkbox,{checked:!n,label:"Do not show again",labelClassName:"mb-6",onChange:p=>a(!p)}),jsxRuntime.jsx(coreUi.Button,{fluid:!0,onClick:()=>void(r==null?void 0:r(s,n)),children:"Save"})]})]})}function InscriptionsContainer({className:e,onSubmit:t}){var s;const{chains:r}=useWidgetState();return jsxRuntime.jsx(Inscriptions,{className:e,onSubmit:t,config:(s=r.BTC)==null?void 0:s.config})}function LoaderScreen({className:e,title:t}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-col items-center justify-center gap-6",e),children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center bg-primary-contrast p-6",children:jsxRuntime.jsx(coreUi.Loader,{className:"text-primary-light"})}),t&&jsxRuntime.jsx(coreUi.Heading,{variant:"h4",className:"capitalize text-accent-primary",children:t})]})}const defaultState={termsOfUse:!1,inscriptions:!1,staking:!1};function TermsOfService({className:e,onClose:t,onSubmit:r}){const[s,o]=react.useState(defaultState),n=react.useMemo(()=>Object.values(s).every(l=>l),[s]),a=react.useCallback(l=>(p=!1)=>{o(u=>({...u,[l]:p}))},[]);return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",e),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"mb-10 text-accent-primary",title:"Connect Wallets",onClose:t,children:jsxRuntime.jsx(coreUi.Text,{className:"text-accent-secondary",children:"Please read and accept the following terms"})}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsx(FieldControl,{label:jsxRuntime.jsxs("div",{className:"block",children:["I certify that I have read and accept the updated"," ",jsxRuntime.jsx("a",{href:"https://babylonlabs.io/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Terms of Use"})," ","and"," ",jsxRuntime.jsx("a",{href:"https://babylonlabs.io/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Privacy Policy"}),"."]}),className:"mb-8",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.termsOfUse,onChange:a("termsOfUse")})}),jsxRuntime.jsx(FieldControl,{label:"I certify that I wish to stake bitcoin and agree that doing so may cause some or all of the bitcoin ordinals, NFTs, Runes, and other inscriptions in the connected bitcoin wallet to be lost. I acknowledge that this interface will not detect all Inscriptions.",className:"mb-8",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.inscriptions,onChange:a("inscriptions")})}),jsxRuntime.jsx(FieldControl,{label:"I acknowledge that the following are the only hardware wallets supporting Bitcoin Staking: (1) Keystone -- via QR code and (2) OneKey -- via the OneKey Chrome extension and the hardware devices (a) OneKey Pro and (b) OneKey Classic 1s (experimental, 3.10.1 firmware or higher) using Taproot only. Using any other hardware wallet through any means (such as connection to a software/extension/mobile wallet) can lead to permanent inability to withdraw the stake.",children:jsxRuntime.jsx(coreUi.Checkbox,{checked:s.staking,onChange:a("staking")})})]}),jsxRuntime.jsx(coreUi.DialogFooter,{className:"mt-auto pt-10",children:jsxRuntime.jsx(coreUi.Button,{disabled:!n,fluid:!0,onClick:r,children:"Next"})})]})}function TermsOfServiceContainer(e){var r;const{chains:t}=useWidgetState();return jsxRuntime.jsx(TermsOfService,{...e,config:(r=t.BTC)==null?void 0:r.config})}const Wallets=react.memo(({chain:e,className:t,append:r,onClose:s,onBack:o,onSelectWallet:n})=>{const a=react.useMemo(()=>e.wallets.find(u=>u.id==="injectable"&&u.installed),[e]),l=react.useMemo(()=>e.wallets.filter(u=>u.id!=="injectable"),[e]),p=react.useMemo(()=>e.wallets.filter(u=>u.id!=="injectable"||u.installed).length,[e]);return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-1 flex-col",t),children:[jsxRuntime.jsx(coreUi.DialogHeader,{className:"text-accent-primary mb-10",title:"Select Wallet",onClose:s,children:jsxRuntime.jsxs(coreUi.Text,{className:"text-accent-secondary",children:["Connect a ",e.name," Wallet"]})}),jsxRuntime.jsxs(coreUi.DialogBody,{children:[jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("grid gap-6",p>1?"grid-cols-1 md:grid-cols-2":"grid-cols-1"),children:[a&&jsxRuntime.jsx(WalletButton,{installed:!0,name:a.name,logo:a.icon,label:a.label,onClick:()=>n==null?void 0:n(e,a)}),l.map(u=>jsxRuntime.jsx(WalletButton,{installed:u.installed,name:u.name,logo:u.icon,label:u.label,fallbackLink:u.docs,onClick:()=>n==null?void 0:n(e,u)},u.id))]}),r]}),jsxRuntime.jsx(coreUi.DialogFooter,{className:"mt-auto pt-10",children:jsxRuntime.jsx(coreUi.Button,{variant:"outlined",fluid:!0,onClick:o,children:"Back"})})]})});function WalletsContainer({widgets:e={},...t}){var p;const{chains:r,screen:s,displayChains:o}=useWidgetState(),n=((p=s.params)==null?void 0:p.chain)??"",a=r==null?void 0:r[n],l=e==null?void 0:e[n];return jsxRuntime.jsx(Wallets,{append:l,chain:a,onBack:o,...t})}const SCREENS={TERMS_OF_SERVICE:({className:e,onClose:t,onAccepTermsOfService:r})=>jsxRuntime.jsx(TermsOfServiceContainer,{className:e,onClose:t,onSubmit:r}),CHAINS:({className:e,onClose:t,onConfirm:r,onDisconnectWallet:s})=>jsxRuntime.jsx(ChainsContainer,{className:e,onClose:t,onConfirm:r,onDisconnectWallet:s}),WALLETS:({className:e,widgets:t,onClose:r,onSelectWallet:s})=>jsxRuntime.jsx(WalletsContainer,{widgets:t,className:e,onClose:r,onSelectWallet:s}),INSCRIPTIONS:({className:e,onToggleInscriptions:t})=>jsxRuntime.jsx(InscriptionsContainer,{className:e,onSubmit:t}),LOADER:({className:e,current:t})=>{var r;return jsxRuntime.jsx(LoaderScreen,{className:e,title:(r=t==null?void 0:t.params)==null?void 0:r.message})},ERROR:()=>jsxRuntime.jsx(ErrorContainer,{className:"min-h-0 md:w-[600px]"}),EMPTY:({className:e})=>jsxRuntime.jsx("div",{className:e})};function Screen(e){const t=SCREENS[e.current.type]??SCREENS.EMPTY;return jsxRuntime.jsx(t,{...e})}const ANIMATION_DELAY=1e3;function WalletDialog({persistent:e,storage:t,config:r,onError:s}){const{visible:o,screen:n,confirmed:a,close:l,confirm:p,displayChains:u}=useWidgetState(),{toggleShowAgain:c,toggleLockInscriptions:v}=useInscriptionProvider(),w=useChainProviders(),b=useWalletWidgets(w,r),{connect:E,disconnect:I}=useWalletConnectors({persistent:e,accountStorage:t,onError:s}),{disconnect:x}=useWalletConnect(),B=react.useCallback(()=>{u==null||u()},[u]),M=react.useCallback((F,j)=>{c==null||c(j),v==null||v(F),u==null||u()},[c,v,u]),q=react.useCallback(()=>{l==null||l(),a||setTimeout(x,ANIMATION_DELAY)},[l,x,a]),U=react.useCallback(()=>{p==null||p(),l==null||l()},[p]);return jsxRuntime.jsx(ResponsiveDialog,{className:"min-h-[80%]",open:o,onClose:q,children:jsxRuntime.jsx(Screen,{current:n,widgets:b,className:"min-h-0 md:size-[600px]",onClose:q,onConfirm:U,onSelectWallet:E,onAccepTermsOfService:B,onToggleInscriptions:M,onDisconnectWallet:I})})}const BBN_TESTNET_RPC_URL="https://rpc-dapp.testnet.babylonlabs.io/",BBN_TESTNET_LCD_URL="https://lcd-dapp.testnet.babylonlabs.io/",bbnTestnet={chainId:"bbn-test-5",chainName:"Babylon Testnet",chainSymbolImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png",rpc:BBN_TESTNET_RPC_URL,rest:BBN_TESTNET_LCD_URL,nodeProvider:{name:"Babylonlabs",email:"contact@babylonlabs.io",website:"https://babylonlabs.io/"},bip44:{coinType:118},bech32Config:{bech32PrefixAccAddr:"bbn",bech32PrefixAccPub:"bbnpub",bech32PrefixValAddr:"bbnvaloper",bech32PrefixValPub:"bbnvaloperpub",bech32PrefixConsAddr:"bbnvalcons",bech32PrefixConsPub:"bbnvalconspub"},currencies:[{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png"}],feeCurrencies:[{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png",gasPriceStep:{low:.007,average:.007,high:.01}}],stakeCurrency:{coinDenom:"BABY",coinMinimalDenom:"ubbn",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bbn-test/chain.png"},features:["cosmwasm"]},ONE_HOUR=60*60*1e3;Network.SIGNET,bbnTestnet.currencies[0].coinDenom,bbnTestnet.chainName,bbnTestnet.currencies[0].coinDenom,bbnTestnet.chainId;const storage=createAccountStorage(ONE_HOUR);function WalletProvider({persistent:e=!1,lifecycleHooks:t,children:r,config:s,context:o=window,onError:n}){return jsxRuntime.jsx(LifeCycleHooksProvider,{value:t,children:jsxRuntime.jsxs(ChainProvider,{persistent:e,storage,context:o,config:s,onError:n,children:[r,jsxRuntime.jsx(WalletDialog,{persistent:e,storage,config:s,onError:n})]})})}function useChainConnector(e){const t=useChainProviders();return(t==null?void 0:t[e])??null}exports.Network=Network;exports.StateContext=StateContext;exports.StateProvider=StateProvider;exports.WalletButton=WalletButton;exports.WalletProvider=WalletProvider;exports.createExternalWallet=createExternalWallet;exports.useChainConnector=useChainConnector;exports.useInscriptionProvider=useInscriptionProvider;exports.useWalletConnect=useWalletConnect;exports.useWidgetState=useWidgetState;
80
80
  //# sourceMappingURL=index.cjs.js.map