UNPKG

bitcoin-wagmi

Version:
1 lines 278 kB
import*as t from"react";import e,{createContext as r,useContext as n,useState as i,useRef as o,useEffect as s,useCallback as a}from"react";import{jsx as u}from"react/jsx-runtime";import c from"buffer";import h from"crypto";import*as f from"valibot";var l=function(t,e){return l=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])},l(t,e)};function p(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}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var d=function(){return d=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},d.apply(this,arguments)};function y(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 g(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 w(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 b=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(){}},m="undefined"==typeof window||"Deno"in globalThis;function v(){}function E(t){return"number"==typeof t&&t>=0&&t!==1/0}function S(t,e){return Math.max(t+(e||0)-Date.now(),0)}function _(t,e){return"function"==typeof t?t(e):t}function T(t,e){return"function"==typeof t?t(e):t}function I(t,e){const{type:r="all",exact:n,fetchStatus:i,predicate:o,queryKey:s,stale:a}=t;if(s)if(n){if(e.queryHash!==A(s,e.options))return!1}else if(!P(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 k(t,e){const{exact:r,status:n,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(O(e.options.mutationKey)!==O(o))return!1}else if(!P(e.options.mutationKey,o))return!1}return(!n||e.state.status===n)&&!(i&&!i(e))}function A(t,e){return(e?.queryKeyHashFn||O)(t)}function O(t){return JSON.stringify(t,((t,e)=>C(e)?Object.keys(e).sort().reduce(((t,r)=>(t[r]=e[r],t)),{}):e))}function P(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&Object.keys(e).every((r=>P(t[r],e[r]))))}function B(t,e){if(t===e)return t;const r=H(t)&&H(e);if(r||C(t)&&C(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]=B(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 H(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function C(t){if(!U(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!U(r)&&(!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype)}function U(t){return"[object Object]"===Object.prototype.toString.call(t)}function N(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 B(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 B(t,e)}return e}function R(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function L(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var j=Symbol();function D(t,e){return"production"!==process.env.NODE_ENV&&t.queryFn===j&&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!==j?t.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`))}var M=new class extends b{#t;#e;#r;constructor(){super(),this.#r=t=>{if(!m&&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}},F=new class extends b{#n=!0;#e;#r;constructor(){super(),this.#r=t=>{if(!m&&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 K(){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 V(t){return Math.min(1e3*2**t,3e4)}function q(t){return"online"!==(t??"online")||F.isOnline()}var G=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function W(t){return t instanceof G}function X(t){let e,r=!1,n=0,i=!1;const o=K(),s=()=>M.isFocused()&&("always"===t.networkMode||F.isOnline())&&t.canRun(),a=()=>q(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??(m?0:3),a=t.retryDelay??V,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 G(e)),t.abort?.())},continue:()=>(e?.(),o),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?f():h().then(f),o)}}var Q=t=>setTimeout(t,0);var $=function(){let t=[],e=0,r=t=>{t()},n=t=>{t()},i=Q;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}}}(),z=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),E(this.gcTime)&&(this.#i=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(m?1/0:3e5))}clearGcTimeout(){this.#i&&(clearTimeout(this.#i),this.#i=void 0)}},Y=class extends z{#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=N(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(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some((t=>!1!==T(t.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||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||!S(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=D(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=X({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,...J(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),$.batch((()=>{this.observers.forEach((t=>{t.onQueryUpdate()})),this.#a.notify({query:this,type:"updated",action:t})}))}};function J(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:q(e.networkMode)?"fetching":"paused",...void 0===t&&{error:null,status:"pending"}}}var Z=class extends b{constructor(t={}){super(),this.config=t,this.#p=new Map}#p;build(t,e,r){const n=e.queryKey,i=e.queryHash??A(n,e);let o=this.get(i);return o||(o=new Y({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(){$.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=>I(e,t)))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter((e=>I(t,e))):e}notify(t){$.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){$.batch((()=>{this.getAll().forEach((t=>{t.onFocus()}))}))}onOnline(){$.batch((()=>{this.getAll().forEach((t=>{t.onOnline()}))}))}},tt=class extends z{#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=X({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),$.batch((()=>{this.#d.forEach((e=>{e.onMutationUpdate(t)})),this.#y.notify({mutation:this,type:"updated",action:t})}))}};var et=class extends b{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 tt({mutationCache:this,mutationId:++this.#b,options:t.defaultMutationOptions(e),state:r});return this.add(n),n}add(t){this.#g.add(t);const e=rt(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=rt(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=rt(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=rt(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(){$.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=>k(e,t)))}findAll(t={}){return this.getAll().filter((e=>k(t,e)))}notify(t){$.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.getAll().filter((t=>t.state.isPaused));return $.batch((()=>Promise.all(t.map((t=>t.continue().catch(v))))))}};function rt(t){return t.options.scope?.id}function nt(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=D(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?L:R;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?ot:it)(n,e);a=await h(e,r,t)}else{const e=t??o.length;do{const t=0===u?s[0]??n.initialPageParam:it(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 it(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 ot(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}var st=class{#m;#y;#h;#v;#E;#S;#_;#T;constructor(t={}){this.#m=t.queryCache||new Z,this.#y=t.mutationCache||new et,this.#h=t.defaultOptions||{},this.#v=new Map,this.#E=new Map,this.#S=0}mount(){this.#S++,1===this.#S&&(this.#_=M.subscribe((async t=>{t&&(await this.resumePausedMutations(),this.#m.onFocus())})),this.#T=F.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(_(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 $.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;$.batch((()=>{e.findAll(t).forEach((t=>{e.remove(t)}))}))}resetQueries(t,e){const r=this.#m;return $.batch((()=>(r.findAll(t).forEach((t=>{t.reset()})),this.refetchQueries({type:"active",...t},e))))}cancelQueries(t,e={}){const r={revert:!0,...e},n=$.batch((()=>this.#m.findAll(t).map((t=>t.cancel(r)))));return Promise.all(n).then(v).catch(v)}invalidateQueries(t,e={}){return $.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=$.batch((()=>this.#m.findAll(t).filter((t=>!t.isDisabled())).map((t=>{let e=t.fetch(void 0,r);return r.throwOnError||(e=e.catch(v)),"paused"===t.state.fetchStatus?Promise.resolve():e}))));return Promise.all(n).then(v)}fetchQuery(t){const e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);const r=this.#m.build(this,e);return r.isStaleByTime(_(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(v).catch(v)}fetchInfiniteQuery(t){return t.behavior=nt(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(v).catch(v)}ensureInfiniteQueryData(t){return t.behavior=nt(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return F.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(O(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#v.values()],r={};return e.forEach((e=>{P(t,e.queryKey)&&Object.assign(r,e.defaultOptions)})),r}setMutationDefaults(t,e){this.#E.set(O(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#E.values()],r={};return e.forEach((e=>{P(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=A(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===j&&(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()}},at=class extends b{constructor(t,e){super(),this.options=e,this.#u=t,this.#I=null,this.#k=K(),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;#B;#x;#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),ut(this.#A,this.options)?this.#D():this.updateResult(),this.#M())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ct(this.#A,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ct(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 T(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&&ht(this.#A,r,this.options,e)&&this.#D(),this.updateResult(),!n||this.#A===r&&T(this.options.enabled,this.#A)===T(e.enabled,this.#A)&&_(this.options.staleTime,this.#A)===_(e.staleTime,this.#A)||this.#q();const i=this.#G();!n||this.#A===r&&T(this.options.enabled,this.#A)===T(e.enabled,this.#A)&&i===this.#L||this.#W(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.#x=this.options,this.#B=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(v)),e}#q(){this.#F();const t=_(this.options.staleTime,this.#A);if(m||this.#P.isStale||!E(t))return;const e=S(this.#P.dataUpdatedAt,t)+1;this.#N=setTimeout((()=>{this.#P.isStale||this.updateResult()}),e)}#G(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#A):this.options.refetchInterval)??!1}#W(t){this.#K(),this.#L=t,!m&&!1!==T(this.options.enabled,this.#A)&&E(this.#L)&&0!==this.#L&&(this.#R=setInterval((()=>{(this.options.refetchIntervalInBackground||M.isFocused())&&this.#D()}),this.#L))}#M(){this.#q(),this.#W(this.#G())}#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.#B,s=this.#x,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&&ut(t,e),s=i&&ht(t,r,e,n);(o||s)&&(h={...h,...J(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=N(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=N(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:ft(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=K();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.#B=this.#A.state,this.#x=this.options,void 0!==this.#B.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){$.batch((()=>{t.listeners&&this.listeners.forEach((t=>{t(this.#P)})),this.#u.getQueryCache().notify({query:this.#A,type:"observerResultsUpdated"})}))}};function ut(t,e){return function(t,e){return!1!==T(e.enabled,t)&&void 0===t.state.data&&!("error"===t.state.status&&!1===e.retryOnMount)}(t,e)||void 0!==t.state.data&&ct(t,e,e.refetchOnMount)}function ct(t,e,r){if(!1!==T(e.enabled,t)){const n="function"==typeof r?r(t):r;return"always"===n||!1!==n&&ft(t,e)}return!1}function ht(t,e,r,n){return(t!==e||!1===T(n.enabled,t))&&(!r.suspense||"error"!==t.state.status)&&ft(t,r)}function ft(t,e){return!1!==T(e.enabled,t)&&t.isStaleByTime(_(e.staleTime,t))}var lt=class extends b{#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&&O(e.mutationKey)!==O(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){$.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)}))}))}},pt=t.createContext(void 0),dt=e=>{const r=t.useContext(pt);if(!r)throw new Error("No QueryClient set, use QueryClientProvider to set one");return r},yt=({client:e,children:r})=>(t.useEffect((()=>(e.mount(),()=>{e.unmount()})),[e]),u(pt.Provider,{value:e,children:r})),gt=t.createContext(!1);gt.Provider;var wt=t.createContext(function(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}());function bt(t,e){return"function"==typeof t?t(...e):!!t}function mt(){}var vt=(t,e,r)=>e.fetchOptimistic(t).catch((()=>{r.clearReset()}));function Et(e,r,n){if("production"!==process.env.NODE_ENV&&("object"!=typeof e||Array.isArray(e)))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 i=dt(),o=t.useContext(gt),s=t.useContext(wt),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),"production"!==process.env.NODE_ENV&&(a.queryFn||console.error(`[${a.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`)),a._optimisticResults=o?"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)))})(a),((t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))})(a,s),(e=>{t.useEffect((()=>{e.clearReset()}),[e])})(s);const u=!i.getQueryCache().get(a.queryHash),[c]=t.useState((()=>new r(i,a))),h=c.getOptimisticResult(a),f=!o&&!1!==e.subscribed;if(t.useSyncExternalStore(t.useCallback((t=>{const e=f?c.subscribe($.batchCalls(t)):mt;return c.updateResult(),e}),[c,f]),(()=>c.getCurrentResult()),(()=>c.getCurrentResult())),t.useEffect((()=>{c.setOptions(a)}),[a,c]),((t,e)=>t?.suspense&&e.isPending)(a,h))throw vt(a,c,s);if((({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(i&&void 0===t.data||bt(r,[t.error,n])))({result:h,errorResetBoundary:s,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw h.error;if(i.getDefaultOptions().queries?._experimental_afterQuery?.(a,h),a.experimental_prefetchInRender&&!m&&((t,e)=>t.isLoading&&t.isFetching&&!e)(h,o)){const t=u?vt(a,c,s):i.getQueryCache().get(a.queryHash)?.promise;t?.catch(mt).finally((()=>{c.updateResult()}))}return a.notifyOnChangeProps?h:c.trackResult(h)}function St(e,r){const n=dt(),[i]=t.useState((()=>new lt(n,e)));t.useEffect((()=>{i.setOptions(e)}),[i,e]);const o=t.useSyncExternalStore(t.useCallback((t=>i.subscribe($.batchCalls(t))),[i]),(()=>i.getCurrentResult()),(()=>i.getCurrentResult())),s=t.useCallback(((t,e)=>{i.mutate(t,e).catch(mt)}),[i]);if(o.error&&bt(i.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}var _t=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 g(this,void 0,void 0,(function(){return w(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 g(this,void 0,void 0,(function(){return w(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}(),Tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},It={},kt={},At={};Object.defineProperty(At,"__esModule",{value:!0}),At.testnet=At.regtest=At.bitcoin=void 0,At.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},At.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},At.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var Ot={},Pt={},Bt={},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 Ht={};Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.REVERSE_OPS=Ht.OPS=void 0;const Ct={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};Ht.OPS=Ct;const Ut={};Ht.REVERSE_OPS=Ut;for(const t of Object.keys(Ct)){Ut[Ct[t]]=t}var Nt={};Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.decode=Nt.encode=Nt.encodingLength=void 0;const Rt=Ht;function Lt(t){return t<Rt.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}Nt.encodingLength=Lt,Nt.encode=function(t,e,r){const n=Lt(e);return 1===n?t.writeUInt8(e,r):2===n?(t.writeUInt8(Rt.OPS.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===n?(t.writeUInt8(Rt.OPS.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(Rt.OPS.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),n},Nt.decode=function(t,e){const r=t.readUInt8(e);let n,i;if(r<Rt.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===Rt.OPS.OP_PUSHDATA1){if(e+2>t.length)return null;n=t.readUInt8(e+1),i=2}else if(r===Rt.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!==Rt.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=t.readUInt32LE(e+1),i=5}return{opcode:r,number:n,size:i}};var jt={};Object.defineProperty(jt,"__esModule",{value:!0}),jt.encode=jt.decode=void 0,jt.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},jt.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 Dt={},Mt={},Ft={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 Kt in Ft.Null=Ft.Nil,Ft)Ft[Kt].toJSON=function(t){return t}.bind(null,Kt);var Vt=Ft,qt=Vt;function Gt(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function Wt(t){return qt.Nil(t)?"":Gt(t.constructor)}function Xt(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function Qt(t){return qt.Function(t)?t.toJSON?t.toJSON():Gt(t):qt.Array(t)?"Array":t&&qt.Object(t)?"Object":void 0!==t?t:""}function $t(t,e,r){var n=function(t){return qt.Function(t)?"":qt.String(t)?JSON.stringify(t):t&&qt.Object(t)?"":t}(e);return"Expected "+Qt(t)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function zt(t,e,r){r=r||Wt(e),this.message=$t(t,e,r),Xt(this,zt),this.__type=t,this.__value=e,this.__valueTypeName=r}function Yt(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 '),$t('property "'+Qt(r)+o+Qt(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',Xt(this,zt),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}zt.prototype=Object.create(Error.prototype),zt.prototype.constructor=zt,Yt.prototype=Object.create(Error.prototype),Yt.prototype.constructor=zt;var Jt,Zt,te={TfTypeError:zt,TfPropertyTypeError:Yt,tfCustomError:function(t,e){return new zt(t,{},e)},tfSubError:function(t,e,r){return t instanceof Yt?(e=e+"."+t.__property,t=new Yt(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof zt&&(t=new Yt(t.__type,e,r,t.__value,t.__valueTypeName)),Xt(t),t},tfJSON:Qt,getValueTypeName:Wt};var ee=Vt,re=te.tfJSON,ne=te.TfTypeError,ie=te.TfPropertyTypeError,oe=te.tfSubError,se=te.getValueTypeName,ae={arrayOf:function(t,e){function r(r,n){return!!ee.Array(r)&&(!ee.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 ce(t,e,n)}catch(t){throw oe(t,r)}}))))))}return t=ue(t),e=e||{},r.toJSON=function(){var r="["+re(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 ee.Nil(r)||e(r,n,t)}return e=ue(e),r.toJSON=function(){return"?"+re(e)},r},map:function(t,e){function r(r,n){if(!ee.Object(r))return!1;if(ee.Nil(r))return!1;for(var i in r){try{e&&ce(e,i,n)}catch(t){throw oe(t,i,"key")}try{var o=r[i];ce(t,o,n)}catch(t){throw oe(t,i)}}return!0}return t=ue(t),e&&(e=ue(e)),r.toJSON=e?function(){return"{"+re(e)+": "+re(t)+"}"}:function(){return"{"+re(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=ue(t[r]);function n(t,r){if(!ee.Object(t))return!1;if(ee.Nil(t))return!1;var n;try{for(n in e){ce(e[n],t[n],r)}}catch(t){throw oe(t,n)}if(r)for(n in t)if(!e[n])throw new ie(void 0,n);return!0}return n.toJSON=function(){return re(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(ue);function e(e,r){return t.some((function(t){try{return ce(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(re).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(ue);function e(e,r){return t.every((function(t){try{return ce(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(re).join(" & ")},e},quacksLike:function(t){function e(e){return t===se(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(ue);function e(e,r){return!ee.Nil(e)&&(!ee.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return ce(t,e[n],r)}catch(t){throw oe(t,n)}}))))}return e.toJSON=function(){return"("+t.map(re).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function ue(t){if(ee.String(t))return"?"===t[0]?ae.maybe(t.slice(1)):ee[t]||ae.quacksLike(t);if(t&&ee.Object(t)){if(ee.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return ae.arrayOf(t[0])}return ae.object(t)}return ee.Function(t)?t:ae.value(t)}function ce(t,e,r,n){if(ee.Function(t)){if(t(e,r))return!0;throw new ne(n||t,e)}return ce(ue(t),e,r)}for(var he in ae.oneOf=ae.anyOf,ee)ce[he]=ee[he];for(he in ae)ce[he]=ae[he];var fe=function(){if(Zt)return Jt;Zt=1;var t=Vt,e=te;function r(t){return Buffer.isBuffer(t)}function n(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function i(t,r){var n=t.toJSON();fu