bitcoin-wagmi
Version:
Bitcoin wallet connect for React
1 lines • 278 kB
JavaScript
"use strict";var t=require("react"),e=require("react/jsx-runtime"),r=require("buffer"),n=require("crypto"),i=require("valibot");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function s(t){if(t&&"object"==typeof t&&"default"in t)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var a=s(t),u=o(r),c=o(n),h=s(i),f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},f(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var p=function(){return p=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},p.apply(this,arguments)};function d(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}function y(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):function(t){return t instanceof r?t:new r((function(e){e(t)}))}(t.value).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function g(t,e){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}"function"==typeof SuppressedError&&SuppressedError;var w=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},b="undefined"==typeof window||"Deno"in globalThis;function m(){}function v(t){return"number"==typeof t&&t>=0&&t!==1/0}function E(t,e){return Math.max(t+(e||0)-Date.now(),0)}function S(t,e){return"function"==typeof t?t(e):t}function _(t,e){return"function"==typeof t?t(e):t}function T(t,e){const{type:r="all",exact:n,fetchStatus:i,predicate:o,queryKey:s,stale:a}=t;if(s)if(n){if(e.queryHash!==k(s,e.options))return!1}else if(!O(e.queryKey,s))return!1;if("all"!==r){const t=e.isActive();if("active"===r&&!t)return!1;if("inactive"===r&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&((!i||i===e.state.fetchStatus)&&!(o&&!o(e)))}function I(t,e){const{exact:r,status:n,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(A(e.options.mutationKey)!==A(o))return!1}else if(!O(e.options.mutationKey,o))return!1}return(!n||e.state.status===n)&&!(i&&!i(e))}function k(t,e){return(e?.queryKeyHashFn||A)(t)}function A(t){return JSON.stringify(t,((t,e)=>H(e)?Object.keys(e).sort().reduce(((t,r)=>(t[r]=e[r],t)),{}):e))}function O(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&Object.keys(e).every((r=>O(t[r],e[r]))))}function P(t,e){if(t===e)return t;const r=B(t)&&B(e);if(r||H(t)&&H(e)){const n=r?t:Object.keys(t),i=n.length,o=r?e:Object.keys(e),s=o.length,a=r?[]:{};let u=0;for(let i=0;i<s;i++){const s=r?i:o[i];(!r&&n.includes(s)||r)&&void 0===t[s]&&void 0===e[s]?(a[s]=void 0,u++):(a[s]=P(t[s],e[s]),a[s]===t[s]&&void 0!==t[s]&&u++)}return i===s&&u===i?t:a}return e}function x(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function B(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function H(t){if(!C(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!C(r)&&(!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype)}function C(t){return"[object Object]"===Object.prototype.toString.call(t)}function U(t,e,r){if("function"==typeof r.structuralSharing)return r.structuralSharing(t,e);if(!1!==r.structuralSharing){if("production"!==process.env.NODE_ENV)try{return P(t,e)}catch(t){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${t}`),t}return P(t,e)}return e}function N(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function R(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var L=Symbol();function j(t,e){return"production"!==process.env.NODE_ENV&&t.queryFn===L&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:t.queryFn&&t.queryFn!==L?t.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`))}var D=new class extends w{#t;#e;#r;constructor(){super(),this.#r=t=>{if(!b&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t((t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach((e=>{e(t)}))}isFocused(){return"boolean"==typeof this.#t?this.#t:"hidden"!==globalThis.document?.visibilityState}},M=new class extends w{#n=!0;#e;#r;constructor(){super(),this.#r=t=>{if(!b&&window.addEventListener){const e=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#n!==t&&(this.#n=t,this.listeners.forEach((e=>{e(t)})))}isOnline(){return this.#n}};function F(){let t,e;const r=new Promise(((r,n)=>{t=r,e=n}));function n(t){Object.assign(r,t),delete r.resolve,delete r.reject}return r.status="pending",r.catch((()=>{})),r.resolve=e=>{n({status:"fulfilled",value:e}),t(e)},r.reject=t=>{n({status:"rejected",reason:t}),e(t)},r}function K(t){return Math.min(1e3*2**t,3e4)}function V(t){return"online"!==(t??"online")||M.isOnline()}var q=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function W(t){return t instanceof q}function G(t){let e,r=!1,n=0,i=!1;const o=F(),s=()=>D.isFocused()&&("always"===t.networkMode||M.isOnline())&&t.canRun(),a=()=>V(t.networkMode)&&t.canRun(),u=r=>{i||(i=!0,t.onSuccess?.(r),e?.(),o.resolve(r))},c=r=>{i||(i=!0,t.onError?.(r),e?.(),o.reject(r))},h=()=>new Promise((r=>{e=t=>{(i||s())&&r(t)},t.onPause?.()})).then((()=>{e=void 0,i||t.onContinue?.()})),f=()=>{if(i)return;let e;const o=0===n?t.initialPromise:void 0;try{e=o??t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(u).catch((e=>{if(i)return;const o=t.retry??(b?0:3),a=t.retryDelay??K,u="function"==typeof a?a(n,e):a,l=!0===o||"number"==typeof o&&n<o||"function"==typeof o&&o(n,e);var p;!r&&l?(n++,t.onFail?.(n,e),(p=u,new Promise((t=>{setTimeout(t,p)}))).then((()=>s()?void 0:h())).then((()=>{r?c(e):f()}))):c(e)}))};return{promise:o,cancel:e=>{i||(c(new q(e)),t.abort?.())},continue:()=>(e?.(),o),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?f():h().then(f),o)}}var X=t=>setTimeout(t,0);var Q=function(){let t=[],e=0,r=t=>{t()},n=t=>{t()},i=X;const o=n=>{e?t.push(n):i((()=>{r(n)}))};return{batch:o=>{let s;e++;try{s=o()}finally{e--,e||(()=>{const e=t;t=[],e.length&&i((()=>{n((()=>{e.forEach((t=>{r(t)}))}))}))})()}return s},batchCalls:t=>(...e)=>{o((()=>{t(...e)}))},schedule:o,setNotifyFunction:t=>{r=t},setBatchNotifyFunction:t=>{n=t},setScheduler:t=>{i=t}}}(),$=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),v(this.gcTime)&&(this.#i=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(b?1/0:3e5))}clearGcTimeout(){this.#i&&(clearTimeout(this.#i),this.#i=void 0)}},z=class extends ${#o;#s;#a;#u;#c;#h;#f;constructor(t){super(),this.#f=!1,this.#h=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#u=t.client,this.#a=this.#u.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#o=function(t){const e="function"==typeof t.initialData?t.initialData():t.initialData,r=void 0!==e,n=r?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}(this.options),this.state=t.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#c?.promise}setOptions(t){this.options={...this.#h,...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#a.remove(this)}setData(t,e){const r=U(this.state.data,t,this.options);return this.#l({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t,e){this.#l({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#c?.promise;return this.#c?.cancel(t),e?e.then(m).catch(m):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some((t=>!1!==_(t.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===L||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return!!this.state.isInvalidated||(this.getObserversCount()>0?this.observers.some((t=>t.getCurrentResult().isStale)):void 0===this.state.data)}isStaleByTime(t=0){return this.state.isInvalidated||void 0===this.state.data||!E(this.state.dataUpdatedAt,t)}onFocus(){const t=this.observers.find((t=>t.shouldFetchOnWindowFocus()));t?.refetch({cancelRefetch:!1}),this.#c?.continue()}onOnline(){const t=this.observers.find((t=>t.shouldFetchOnReconnect()));t?.refetch({cancelRefetch:!1}),this.#c?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter((e=>e!==t)),this.observers.length||(this.#c&&(this.#f?this.#c.cancel({revert:!0}):this.#c.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}fetch(t,e){if("idle"!==this.state.fetchStatus)if(void 0!==this.state.data&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#c)return this.#c.continueRetry(),this.#c.promise;if(t&&this.setOptions(t),!this.options.queryFn){const t=this.observers.find((t=>t.options.queryFn));t&&this.setOptions(t.options)}"production"!==process.env.NODE_ENV&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,n=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(this.#f=!0,r.signal)})},i={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#u,state:this.state,fetchFn:()=>{const t=j(this.options,e),r={client:this.#u,queryKey:this.queryKey,meta:this.meta};return n(r),this.#f=!1,this.options.persister?this.options.persister(t,r,this):t(r)}};n(i),this.options.behavior?.onFetch(i,this),this.#s=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===i.fetchOptions?.meta||this.#l({type:"fetch",meta:i.fetchOptions?.meta});const o=t=>{W(t)&&t.silent||this.#l({type:"error",error:t}),W(t)||(this.#a.config.onError?.(t,this),this.#a.config.onSettled?.(this.state.data,t,this)),this.scheduleGc()};return this.#c=G({initialPromise:e?.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:t=>{if(void 0===t)return"production"!==process.env.NODE_ENV&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),void o(new Error(`${this.queryHash} data is undefined`));try{this.setData(t)}catch(t){return void o(t)}this.#a.config.onSuccess?.(t,this),this.#a.config.onSettled?.(t,this.state.error,this),this.scheduleGc()},onError:o,onFail:(t,e)=>{this.#l({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#c.start()}#l(t){this.state=(e=>{switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,...Y(e.data,this.options),fetchMeta:t.meta??null};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=t.error;return W(r)&&r.revert&&this.#s?{...this.#s,fetchStatus:"idle"}:{...e,error:r,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),Q.batch((()=>{this.observers.forEach((t=>{t.onQueryUpdate()})),this.#a.notify({query:this,type:"updated",action:t})}))}};function Y(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:V(e.networkMode)?"fetching":"paused",...void 0===t&&{error:null,status:"pending"}}}var J=class extends w{constructor(t={}){super(),this.config=t,this.#p=new Map}#p;build(t,e,r){const n=e.queryKey,i=e.queryHash??k(n,e);let o=this.get(i);return o||(o=new z({client:t,queryKey:n,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(o)),o}add(t){this.#p.has(t.queryHash)||(this.#p.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#p.get(t.queryHash);e&&(t.destroy(),e===t&&this.#p.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Q.batch((()=>{this.getAll().forEach((t=>{this.remove(t)}))}))}get(t){return this.#p.get(t)}getAll(){return[...this.#p.values()]}find(t){const e={exact:!0,...t};return this.getAll().find((t=>T(e,t)))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter((e=>T(t,e))):e}notify(t){Q.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){Q.batch((()=>{this.getAll().forEach((t=>{t.onFocus()}))}))}onOnline(){Q.batch((()=>{this.getAll().forEach((t=>{t.onOnline()}))}))}},Z=class extends ${#d;#y;#c;constructor(t){super(),this.mutationId=t.mutationId,this.#y=t.mutationCache,this.#d=[],this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#d.includes(t)||(this.#d.push(t),this.clearGcTimeout(),this.#y.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#d=this.#d.filter((e=>e!==t)),this.scheduleGc(),this.#y.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#d.length||("pending"===this.state.status?this.scheduleGc():this.#y.remove(this))}continue(){return this.#c?.continue()??this.execute(this.state.variables)}async execute(t){this.#c=G({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(t,e)=>{this.#l({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#y.canRun(this)});const e="pending"===this.state.status,r=!this.#c.canStart();try{if(!e){this.#l({type:"pending",variables:t,isPaused:r}),await(this.#y.config.onMutate?.(t,this));const e=await(this.options.onMutate?.(t));e!==this.state.context&&this.#l({type:"pending",context:e,variables:t,isPaused:r})}const n=await this.#c.start();return await(this.#y.config.onSuccess?.(n,t,this.state.context,this)),await(this.options.onSuccess?.(n,t,this.state.context)),await(this.#y.config.onSettled?.(n,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(n,null,t,this.state.context)),this.#l({type:"success",data:n}),n}catch(e){try{throw await(this.#y.config.onError?.(e,t,this.state.context,this)),await(this.options.onError?.(e,t,this.state.context)),await(this.#y.config.onSettled?.(void 0,e,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,e,t,this.state.context)),e}finally{this.#l({type:"error",error:e})}}finally{this.#y.runNext(this)}}#l(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),Q.batch((()=>{this.#d.forEach((e=>{e.onMutationUpdate(t)})),this.#y.notify({mutation:this,type:"updated",action:t})}))}};var tt=class extends w{constructor(t={}){super(),this.config=t,this.#g=new Set,this.#w=new Map,this.#b=0}#g;#w;#b;build(t,e,r){const n=new Z({mutationCache:this,mutationId:++this.#b,options:t.defaultMutationOptions(e),state:r});return this.add(n),n}add(t){this.#g.add(t);const e=et(t);if("string"==typeof e){const r=this.#w.get(e);r?r.push(t):this.#w.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#g.delete(t)){const e=et(t);if("string"==typeof e){const r=this.#w.get(e);if(r)if(r.length>1){const e=r.indexOf(t);-1!==e&&r.splice(e,1)}else r[0]===t&&this.#w.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=et(t);if("string"==typeof e){const r=this.#w.get(e),n=r?.find((t=>"pending"===t.state.status));return!n||n===t}return!0}runNext(t){const e=et(t);if("string"==typeof e){const r=this.#w.get(e)?.find((e=>e!==t&&e.state.isPaused));return r?.continue()??Promise.resolve()}return Promise.resolve()}clear(){Q.batch((()=>{this.#g.forEach((t=>{this.notify({type:"removed",mutation:t})})),this.#g.clear(),this.#w.clear()}))}getAll(){return Array.from(this.#g)}find(t){const e={exact:!0,...t};return this.getAll().find((t=>I(e,t)))}findAll(t={}){return this.getAll().filter((e=>I(t,e)))}notify(t){Q.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.getAll().filter((t=>t.state.isPaused));return Q.batch((()=>Promise.all(t.map((t=>t.continue().catch(m))))))}};function et(t){return t.options.scope?.id}function rt(t){return{onFetch:(e,r)=>{const n=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,o=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let a={pages:[],pageParams:[]},u=0;const c=async()=>{let r=!1;const c=j(e.options,e.fetchOptions),h=async(t,n,i)=>{if(r)return Promise.reject();if(null==n&&t.pages.length)return Promise.resolve(t);const o={client:e.client,queryKey:e.queryKey,pageParam:n,direction:i?"backward":"forward",meta:e.options.meta};var s;s=o,Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(e.signal.aborted?r=!0:e.signal.addEventListener("abort",(()=>{r=!0})),e.signal)});const a=await c(o),{maxPages:u}=e.options,h=i?R:N;return{pages:h(t.pages,a,u),pageParams:h(t.pageParams,n,u)}};if(i&&o.length){const t="backward"===i,e={pages:o,pageParams:s},r=(t?it:nt)(n,e);a=await h(e,r,t)}else{const e=t??o.length;do{const t=0===u?s[0]??n.initialPageParam:nt(n,a);if(u>0&&null==t)break;a=await h(a,t),u++}while(u<e)}return a};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=c}}}function nt(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function it(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}var ot=class{#m;#y;#h;#v;#E;#S;#_;#T;constructor(t={}){this.#m=t.queryCache||new J,this.#y=t.mutationCache||new tt,this.#h=t.defaultOptions||{},this.#v=new Map,this.#E=new Map,this.#S=0}mount(){this.#S++,1===this.#S&&(this.#_=D.subscribe((async t=>{t&&(await this.resumePausedMutations(),this.#m.onFocus())})),this.#T=M.subscribe((async t=>{t&&(await this.resumePausedMutations(),this.#m.onOnline())})))}unmount(){this.#S--,0===this.#S&&(this.#_?.(),this.#_=void 0,this.#T?.(),this.#T=void 0)}isFetching(t){return this.#m.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#y.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#m.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=this.#m.build(this,e),n=r.state.data;return void 0===n?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(S(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return this.#m.findAll(t).map((({queryKey:t,state:e})=>[t,e.data]))}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),i=this.#m.get(n.queryHash),o=i?.state.data,s=function(t,e){return"function"==typeof t?t(e):t}(e,o);if(void 0!==s)return this.#m.build(this,n).setData(s,{...r,manual:!0})}setQueriesData(t,e,r){return Q.batch((()=>this.#m.findAll(t).map((({queryKey:t})=>[t,this.setQueryData(t,e,r)]))))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#m.get(e.queryHash)?.state}removeQueries(t){const e=this.#m;Q.batch((()=>{e.findAll(t).forEach((t=>{e.remove(t)}))}))}resetQueries(t,e){const r=this.#m;return Q.batch((()=>(r.findAll(t).forEach((t=>{t.reset()})),this.refetchQueries({type:"active",...t},e))))}cancelQueries(t,e={}){const r={revert:!0,...e},n=Q.batch((()=>this.#m.findAll(t).map((t=>t.cancel(r)))));return Promise.all(n).then(m).catch(m)}invalidateQueries(t,e={}){return Q.batch((()=>(this.#m.findAll(t).forEach((t=>{t.invalidate()})),"none"===t?.refetchType?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e))))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=Q.batch((()=>this.#m.findAll(t).filter((t=>!t.isDisabled())).map((t=>{let e=t.fetch(void 0,r);return r.throwOnError||(e=e.catch(m)),"paused"===t.state.fetchStatus?Promise.resolve():e}))));return Promise.all(n).then(m)}fetchQuery(t){const e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);const r=this.#m.build(this,e);return r.isStaleByTime(S(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(m).catch(m)}fetchInfiniteQuery(t){return t.behavior=rt(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(m).catch(m)}ensureInfiniteQueryData(t){return t.behavior=rt(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return M.isOnline()?this.#y.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#m}getMutationCache(){return this.#y}getDefaultOptions(){return this.#h}setDefaultOptions(t){this.#h=t}setQueryDefaults(t,e){this.#v.set(A(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#v.values()],r={};return e.forEach((e=>{O(t,e.queryKey)&&Object.assign(r,e.defaultOptions)})),r}setMutationDefaults(t,e){this.#E.set(A(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#E.values()],r={};return e.forEach((e=>{O(t,e.mutationKey)&&Object.assign(r,e.defaultOptions)})),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#h.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=k(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===L&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#h.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#m.clear(),this.#y.clear()}},st=class extends w{constructor(t,e){super(),this.options=e,this.#u=t,this.#I=null,this.#k=F(),this.options.experimental_prefetchInRender||this.#k.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(e)}#u;#A=void 0;#O=void 0;#P=void 0;#x;#B;#k;#I;#H;#C;#U;#N;#R;#L;#j=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#A.addObserver(this),at(this.#A,this.options)?this.#D():this.updateResult(),this.#M())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ut(this.#A,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ut(this.#A,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#F(),this.#K(),this.#A.removeObserver(this)}setOptions(t){const e=this.options,r=this.#A;if(this.options=this.#u.defaultQueryOptions(t),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof _(this.options.enabled,this.#A))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#V(),this.#A.setOptions(this.options),e._defaulted&&!x(this.options,e)&&this.#u.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#A,observer:this});const n=this.hasListeners();n&&ct(this.#A,r,this.options,e)&&this.#D(),this.updateResult(),!n||this.#A===r&&_(this.options.enabled,this.#A)===_(e.enabled,this.#A)&&S(this.options.staleTime,this.#A)===S(e.staleTime,this.#A)||this.#q();const i=this.#W();!n||this.#A===r&&_(this.options.enabled,this.#A)===_(e.enabled,this.#A)&&i===this.#L||this.#G(i)}getOptimisticResult(t){const e=this.#u.getQueryCache().build(this.#u,t),r=this.createResult(e,t);return function(t,e){if(!x(t.getCurrentResult(),e))return!0;return!1}(this,r)&&(this.#P=r,this.#B=this.options,this.#x=this.#A.state),r}getCurrentResult(){return this.#P}trackResult(t,e){const r={};return Object.keys(t).forEach((n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),e?.(n),t[n])})})),r}trackProp(t){this.#j.add(t)}getCurrentQuery(){return this.#A}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#u.defaultQueryOptions(t),r=this.#u.getQueryCache().build(this.#u,e);return r.fetch().then((()=>this.createResult(r,e)))}fetch(t){return this.#D({...t,cancelRefetch:t.cancelRefetch??!0}).then((()=>(this.updateResult(),this.#P)))}#D(t){this.#V();let e=this.#A.fetch(this.options,t);return t?.throwOnError||(e=e.catch(m)),e}#q(){this.#F();const t=S(this.options.staleTime,this.#A);if(b||this.#P.isStale||!v(t))return;const e=E(this.#P.dataUpdatedAt,t)+1;this.#N=setTimeout((()=>{this.#P.isStale||this.updateResult()}),e)}#W(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#A):this.options.refetchInterval)??!1}#G(t){this.#K(),this.#L=t,!b&&!1!==_(this.options.enabled,this.#A)&&v(this.#L)&&0!==this.#L&&(this.#R=setInterval((()=>{(this.options.refetchIntervalInBackground||D.isFocused())&&this.#D()}),this.#L))}#M(){this.#q(),this.#G(this.#W())}#F(){this.#N&&(clearTimeout(this.#N),this.#N=void 0)}#K(){this.#R&&(clearInterval(this.#R),this.#R=void 0)}createResult(t,e){const r=this.#A,n=this.options,i=this.#P,o=this.#x,s=this.#B,a=t!==r?t.state:this.#O,{state:u}=t;let c,h={...u},f=!1;if(e._optimisticResults){const i=this.hasListeners(),o=!i&&at(t,e),s=i&&ct(t,r,e,n);(o||s)&&(h={...h,...Y(u.data,t.options)}),"isRestoring"===e._optimisticResults&&(h.fetchStatus="idle")}let{error:l,errorUpdatedAt:p,status:d}=h;if(e.select&&void 0!==h.data)if(i&&h.data===o?.data&&e.select===this.#H)c=this.#C;else try{this.#H=e.select,c=e.select(h.data),c=U(i?.data,c,e),this.#C=c,this.#I=null}catch(t){this.#I=t}else c=h.data;if(void 0!==e.placeholderData&&void 0===c&&"pending"===d){let t;if(i?.isPlaceholderData&&e.placeholderData===s?.placeholderData)t=i.data;else if(t="function"==typeof e.placeholderData?e.placeholderData(this.#U?.state.data,this.#U):e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),this.#I=null}catch(t){this.#I=t}void 0!==t&&(d="success",c=U(i?.data,t,e),f=!0)}this.#I&&(l=this.#I,c=this.#C,p=Date.now(),d="error");const y="fetching"===h.fetchStatus,g="pending"===d,w="error"===d,b=g&&y,m=void 0!==c,v={status:d,fetchStatus:h.fetchStatus,isPending:g,isSuccess:"success"===d,isError:w,isInitialLoading:b,isLoading:b,data:c,dataUpdatedAt:h.dataUpdatedAt,error:l,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>a.dataUpdateCount||h.errorUpdateCount>a.errorUpdateCount,isFetching:y,isRefetching:y&&!g,isLoadingError:w&&!m,isPaused:"paused"===h.fetchStatus,isPlaceholderData:f,isRefetchError:w&&m,isStale:ht(t,e),refetch:this.refetch,promise:this.#k};if(this.options.experimental_prefetchInRender){const e=t=>{"error"===v.status?t.reject(v.error):void 0!==v.data&&t.resolve(v.data)},n=()=>{const t=this.#k=v.promise=F();e(t)},i=this.#k;switch(i.status){case"pending":t.queryHash===r.queryHash&&e(i);break;case"fulfilled":"error"!==v.status&&v.data===i.value||n();break;case"rejected":"error"===v.status&&v.error===i.reason||n()}}return v}updateResult(){const t=this.#P,e=this.createResult(this.#A,this.options);if(this.#x=this.#A.state,this.#B=this.options,void 0!==this.#x.data&&(this.#U=this.#A),x(e,t))return;this.#P=e;this.#X({listeners:(()=>{if(!t)return!0;const{notifyOnChangeProps:e}=this.options,r="function"==typeof e?e():e;if("all"===r||!r&&!this.#j.size)return!0;const n=new Set(r??this.#j);return this.options.throwOnError&&n.add("error"),Object.keys(this.#P).some((e=>{const r=e;return this.#P[r]!==t[r]&&n.has(r)}))})()})}#V(){const t=this.#u.getQueryCache().build(this.#u,this.options);if(t===this.#A)return;const e=this.#A;this.#A=t,this.#O=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#M()}#X(t){Q.batch((()=>{t.listeners&&this.listeners.forEach((t=>{t(this.#P)})),this.#u.getQueryCache().notify({query:this.#A,type:"observerResultsUpdated"})}))}};function at(t,e){return function(t,e){return!1!==_(e.enabled,t)&&void 0===t.state.data&&!("error"===t.state.status&&!1===e.retryOnMount)}(t,e)||void 0!==t.state.data&&ut(t,e,e.refetchOnMount)}function ut(t,e,r){if(!1!==_(e.enabled,t)){const n="function"==typeof r?r(t):r;return"always"===n||!1!==n&&ht(t,e)}return!1}function ct(t,e,r,n){return(t!==e||!1===_(n.enabled,t))&&(!r.suspense||"error"!==t.state.status)&&ht(t,r)}function ht(t,e){return!1!==_(e.enabled,t)&&t.isStaleByTime(S(e.staleTime,t))}var ft=class extends w{#u;#P=void 0;#Q;#$;constructor(t,e){super(),this.#u=t,this.setOptions(e),this.bindMethods(),this.#z()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#u.defaultMutationOptions(t),x(this.options,e)||this.#u.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#Q,observer:this}),e?.mutationKey&&this.options.mutationKey&&A(e.mutationKey)!==A(this.options.mutationKey)?this.reset():"pending"===this.#Q?.state.status&&this.#Q.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#Q?.removeObserver(this)}onMutationUpdate(t){this.#z(),this.#X(t)}getCurrentResult(){return this.#P}reset(){this.#Q?.removeObserver(this),this.#Q=void 0,this.#z(),this.#X()}mutate(t,e){return this.#$=e,this.#Q?.removeObserver(this),this.#Q=this.#u.getMutationCache().build(this.#u,this.options),this.#Q.addObserver(this),this.#Q.execute(t)}#z(){const t=this.#Q?.state??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};this.#P={...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset}}#X(t){Q.batch((()=>{if(this.#$&&this.hasListeners()){const e=this.#P.variables,r=this.#P.context;"success"===t?.type?(this.#$.onSuccess?.(t.data,e,r),this.#$.onSettled?.(t.data,null,e,r)):"error"===t?.type&&(this.#$.onError?.(t.error,e,r),this.#$.onSettled?.(void 0,t.error,e,r))}this.listeners.forEach((t=>{t(this.#P)}))}))}},lt=a.createContext(void 0),pt=t=>{const e=a.useContext(lt);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},dt=({client:t,children:r})=>(a.useEffect((()=>(t.mount(),()=>{t.unmount()})),[t]),e.jsx(lt.Provider,{value:t,children:r})),yt=a.createContext(!1);yt.Provider;var gt=a.createContext(function(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}());function wt(t,e){return"function"==typeof t?t(...e):!!t}function bt(){}var mt=(t,e,r)=>e.fetchOptimistic(t).catch((()=>{r.clearReset()}));function vt(t,e,r){if("production"!==process.env.NODE_ENV&&("object"!=typeof t||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=pt(),i=a.useContext(yt),o=a.useContext(gt),s=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(s),"production"!==process.env.NODE_ENV&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=i?"isRestoring":"optimistic",(t=>{const e=t.staleTime;t.suspense&&(t.staleTime="function"==typeof e?(...t)=>Math.max(e(...t),1e3):Math.max(e??1e3,1e3),"number"==typeof t.gcTime&&(t.gcTime=Math.max(t.gcTime,1e3)))})(s),((t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))})(s,o),(t=>{a.useEffect((()=>{t.clearReset()}),[t])})(o);const u=!n.getQueryCache().get(s.queryHash),[c]=a.useState((()=>new e(n,s))),h=c.getOptimisticResult(s),f=!i&&!1!==t.subscribed;if(a.useSyncExternalStore(a.useCallback((t=>{const e=f?c.subscribe(Q.batchCalls(t)):bt;return c.updateResult(),e}),[c,f]),(()=>c.getCurrentResult()),(()=>c.getCurrentResult())),a.useEffect((()=>{c.setOptions(s)}),[s,c]),((t,e)=>t?.suspense&&e.isPending)(s,h))throw mt(s,c,o);if((({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(i&&void 0===t.data||wt(r,[t.error,n])))({result:h,errorResetBoundary:o,throwOnError:s.throwOnError,query:n.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw h.error;if(n.getDefaultOptions().queries?._experimental_afterQuery?.(s,h),s.experimental_prefetchInRender&&!b&&((t,e)=>t.isLoading&&t.isFetching&&!e)(h,i)){const t=u?mt(s,c,o):n.getQueryCache().get(s.queryHash)?.promise;t?.catch(bt).finally((()=>{c.updateResult()}))}return s.notifyOnChangeProps?h:c.trackResult(h)}function Et(t,e){const r=pt(),[n]=a.useState((()=>new ft(r,t)));a.useEffect((()=>{n.setOptions(t)}),[n,t]);const i=a.useSyncExternalStore(a.useCallback((t=>n.subscribe(Q.batchCalls(t))),[n]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),o=a.useCallback(((t,e)=>{n.mutate(t,e).catch(bt)}),[n]);if(i.error&&wt(n.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}var St=function(){function t(t){this.ready=!1,this.accounts=[],this.address="",this.listeners={accountChanged:[],networkChanged:[]},this.network=t}return t.prototype.getAccount=function(){return this.address},t.prototype.getAccounts=function(){return this.accounts},t.prototype.isAuthorized=function(){return!!this.getAccount()},t.prototype.on=function(t,e){var r=this;return this.listeners[t].push(e),function(){r.listeners[t]=r.listeners[t].filter((function(t){return t!==e}))}},t.prototype.switchNetwork=function(t){return y(this,void 0,void 0,(function(){return g(this,(function(e){return this.network=t,[2]}))}))},t.prototype.disconnect=function(){this.accounts=[],this.address=void 0,this.publicKey=void 0},t.prototype.getNetwork=function(){return this.network},t.prototype.getPublicKey=function(){return y(this,void 0,void 0,(function(){return g(this,(function(t){if(!this.publicKey)throw new Error("Something went wrong while connecting");return[2,this.publicKey]}))}))},t.prototype.getSigner=function(){return this},t}(),_t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Tt={},It={},kt={};Object.defineProperty(kt,"__esModule",{value:!0}),kt.testnet=kt.regtest=kt.bitcoin=void 0,kt.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},kt.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},kt.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var At={},Ot={},Pt={},xt={};Object.defineProperty(xt,"__esModule",{value:!0}),xt.encode=xt.decode=xt.check=void 0,xt.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return 0!==r&&(6+e+r===t.length&&(!(128&t[4])&&(!(e>1&&0===t[4]&&!(128&t[5]))&&(!(128&t[e+6])&&!(r>1&&0===t[e+6]&&!(128&t[e+7]))))))},xt.decode=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");const e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");const r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},xt.encode=function(t,e){const r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");const i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i};var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.REVERSE_OPS=Bt.OPS=void 0;const Ht={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};Bt.OPS=Ht;const Ct={};Bt.REVERSE_OPS=Ct;for(const t of Object.keys(Ht)){Ct[Ht[t]]=t}var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.decode=Ut.encode=Ut.encodingLength=void 0;const Nt=Bt;function Rt(t){return t<Nt.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}Ut.encodingLength=Rt,Ut.encode=function(t,e,r){const n=Rt(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(Nt.OPS.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(Nt.OPS.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(Nt.OPS.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n},Ut.decode=function(t,e){const r=t.readUInt8(e);let n,i;if(r<Nt.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===Nt.OPS.OP_PUSHDATA1){if(e+2>t.length)return null;n=t.readUInt8(e+1),i=2}else if(r===Nt.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;n=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(r!==Nt.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=t.readUInt32LE(e+1),i=5}return{opcode:r,number:n,size:i}};var Lt={};Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.encode=Lt.decode=void 0,Lt.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e<n;++e)i|=t[e]<<8*e;return 128&t[n-1]?-(i&~(128<<8*(n-1))):i},Lt.encode=function(t){let e=Math.abs(t);const r=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0;for(let t=0;t<r;++t)n.writeUInt8(255&e,t),e>>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n};var jt={},Dt={},Mt={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var Ft in Mt.Null=Mt.Nil,Mt)Mt[Ft].toJSON=function(t){return t}.bind(null,Ft);var Kt=Mt,Vt=Kt;function qt(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function Wt(t){return Vt.Nil(t)?"":qt(t.constructor)}function Gt(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function Xt(t){return Vt.Function(t)?t.toJSON?t.toJSON():qt(t):Vt.Array(t)?"Array":t&&Vt.Object(t)?"Object":void 0!==t?t:""}function Qt(t,e,r){var n=function(t){return Vt.Function(t)?"":Vt.String(t)?JSON.stringify(t):t&&Vt.Object(t)?"":t}(e);return"Expected "+Xt(t)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function $t(t,e,r){r=r||Wt(e),this.message=Qt(t,e,r),Gt(this,$t),this.__type=t,this.__value=e,this.__valueTypeName=r}function zt(t,e,r,n,i){t?(i=i||Wt(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),Qt('property "'+Xt(r)+o+Xt(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',Gt(this,$t),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}$t.prototype=Object.create(Error.prototype),$t.prototype.constructor=$t,zt.prototype=Object.create(Error.prototype),zt.prototype.constructor=$t;var Yt,Jt,Zt={TfTypeError:$t,TfPropertyTypeError:zt,tfCustomError:function(t,e){return new $t(t,{},e)},tfSubError:function(t,e,r){return t instanceof zt?(e=e+"."+t.__property,t=new zt(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof $t&&(t=new zt(t.__type,e,r,t.__value,t.__valueTypeName)),Gt(t),t},tfJSON:Xt,getValueTypeName:Wt};var te=Kt,ee=Zt.tfJSON,re=Zt.TfTypeError,ne=Zt.TfPropertyTypeError,ie=Zt.tfSubError,oe=Zt.getValueTypeName,se={arrayOf:function(t,e){function r(r,n){return!!te.Array(r)&&(!te.Nil(r)&&(!(void 0!==e.minLength&&r.length<e.minLength)&&(!(void 0!==e.maxLength&&r.length>e.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return ue(t,e,n)}catch(t){throw ie(t,r)}}))))))}return t=ae(t),e=e||{},r.toJSON=function(){var r="["+ee(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return te.Nil(r)||e(r,n,t)}return e=ae(e),r.toJSON=function(){return"?"+ee(e)},r},map:function(t,e){function r(r,n){if(!te.Object(r))return!1;if(te.Nil(r))return!1;for(var i in r){try{e&&ue(e,i,n)}catch(t){throw ie(t,i,"key")}try{var o=r[i];ue(t,o,n)}catch(t){throw ie(t,i)}}return!0}return t=ae(t),e&&(e=ae(e)),r.toJSON=e?function(){return"{"+ee(e)+": "+ee(t)+"}"}:function(){return"{"+ee(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=ae(t[r]);function n(t,r){if(!te.Object(t))return!1;if(te.Nil(t))return!1;var n;try{for(n in e){ue(e[n],t[n],r)}}catch(t){throw ie(t,n)}if(r)for(n in t)if(!e[n])throw new ne(void 0,n);return!0}return n.toJSON=function(){return ee(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(ae);function e(e,r){return t.some((function(t){try{return ue(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(ee).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(ae);function e(e,r){return t.every((function(t){try{return ue(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(ee).join(" & ")},e},quacksLike:function(t){function e(e){return t===oe(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(ae);function e(e,r){return!te.Nil(e)&&(!te.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return ue(t,e[n],r)}catch(t){throw ie(t,n)}}))))}return e.toJSON=function(){return"("+t.map(ee).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function ae(t){if(te.String(t))return"?"===t[0]?se.maybe(t.slice(1)):te[t]||se.quacksLike(t);if(t&&te.Object(t)){if(te.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return se.arrayOf(t[0])}return se.object(t)}return te.Function(t)?t:se.value(t)}function ue(t,e,r,n){if(te.Function(t)){if(t(e,r))return!0;throw new re(n||t,e)}retu