@ecency/sdk 2.3.32 → 2.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -691,7 +691,9 @@ type APIMethods = 'balance' | 'hafah' | 'hafbe' | 'hivemind' | 'hivesense' | 're
691
691
  * @param method - The API method name (e.g., 'condenser_api.get_accounts')
692
692
  * @param params - Parameters for the API method as array or object
693
693
  * @param timeout - Request timeout in milliseconds (default: config.timeout)
694
- * @param retry - Maximum number of retry attempts (default: config.retry)
694
+ * @param retry - Maximum number of retry attempts (default: config.retry). The
695
+ * wall-clock budget (`config.resilience.totalBudgetFactor` × timeout) may end
696
+ * the failover walk before the retry count is exhausted.
695
697
  * @returns Promise resolving to the API response
696
698
  * @throws {RPCError} On blockchain-level errors (bad params, missing authority, etc.)
697
699
  * @throws {Error} If all retry attempts fail
@@ -731,7 +733,9 @@ declare const callRPCBroadcast: <T = any>(method: string, params?: any[] | objec
731
733
  * @param endpoint - The specific endpoint path within the API
732
734
  * @param params - Optional parameters for path and query string replacement
733
735
  * @param timeout - Request timeout in milliseconds (default: config.timeout)
734
- * @param retry - Number of retry attempts before throwing an error (default: config.retry)
736
+ * @param retry - Number of retry attempts before throwing an error (default:
737
+ * config.retry). The wall-clock budget (`config.resilience.totalBudgetFactor`
738
+ * × timeout) may end the failover walk before the retry count is exhausted.
735
739
  *
736
740
  * @returns Promise resolving to the API response data with proper typing
737
741
  * @throws Error if all retry attempts fail
@@ -825,7 +829,53 @@ declare const config: {
825
829
  * caller while the rest of the list is healthy.
826
830
  */
827
831
  retry: number;
832
+ /**
833
+ * Tail-latency resilience for READ calls. Motivation: on a shared public-node
834
+ * pool a node can slow down or throttle *mid-request*; a fixed `timeout` means
835
+ * the caller only notices after the full window, and under SSR concurrency
836
+ * those stalled renders pile up. Two mechanisms, both scoped to reads only
837
+ * (broadcasts never hedge and keep their fixed `broadcastTimeout`):
838
+ *
839
+ * - Adaptive per-attempt timeout (`adaptiveTimeout`, default ON): when a
840
+ * node has a usable latency profile (EWMA), the per-attempt timeout becomes
841
+ * `min(callerTimeout, max(floorMs, factor × EWMA))` — a node running far
842
+ * above its own baseline is abandoned early and failover starts sooner.
843
+ * Never *raises* the caller's timeout; unprofiled nodes keep it unchanged.
844
+ *
845
+ * - Hedged requests (`hedge`, default OFF — opt in via `setResilience`): if
846
+ * the primary attempt is still pending after `max(hedgeDelayFloorMs,
847
+ * hedgeDelayFactor × EWMA)`, a duplicate request is fired at the next
848
+ * healthy untried node and the first success wins (the loser is aborted).
849
+ * A token bucket (`hedgeBucketCapacity` burst, refilled by
850
+ * `hedgeRefillPerSuccess` per un-hedged success) caps hedges to roughly
851
+ * `hedgeRefillPerSuccess` of traffic, so only the slow tail hedges — and
852
+ * under pool-wide slowness the bucket drains and hedging auto-disables
853
+ * instead of amplifying load into public-node rate limits.
854
+ */
855
+ resilience: {
856
+ adaptiveTimeout: boolean;
857
+ adaptiveTimeoutFloorMs: number;
858
+ adaptiveTimeoutFactor: number;
859
+ hedge: boolean;
860
+ hedgeDelayFloorMs: number;
861
+ hedgeDelayFactor: number;
862
+ hedgeBucketCapacity: number;
863
+ hedgeRefillPerSuccess: number;
864
+ /**
865
+ * Wall-clock budget for one read call across ALL failover attempts, as a
866
+ * multiple of the per-attempt timeout: no NEW attempt starts past
867
+ * `totalBudgetFactor × timeout` (an in-flight attempt still finishes its
868
+ * own window). Bounds the pathological pool-wide-slowness walk — without
869
+ * it a read could hold its caller for (retry+1) × timeout ≈ 30s, which
870
+ * under SSR concurrency is a memory pile-up, the exact incident this
871
+ * feature exists for. Applies to reads only (callRPC / callREST);
872
+ * broadcasts keep their try-each-node-once semantics.
873
+ */
874
+ totalBudgetFactor: number;
875
+ };
828
876
  };
877
+ /** Shape of the `config.resilience` bag (see its doc comment). */
878
+ type ResilienceOptions = typeof config.resilience;
829
879
  declare const setNodes: (nodes: string[]) => void;
830
880
  /**
831
881
  * Validated setter for the REST-API node list — replaces `config.restNodes`.
@@ -855,6 +905,18 @@ declare const setRestNodesByApi: (map: Partial<Record<APIMethods, string[]>>) =>
855
905
  * `ConfigManager.setUserAgent`) and the lean `@ecency/sdk/hive` server/CLI entry.
856
906
  */
857
907
  declare const setUserAgent: (ua: string) => void;
908
+ /**
909
+ * Validated partial setter for `config.resilience` (adaptive read timeouts +
910
+ * hedged requests — see the field's doc comment). Booleans must be booleans;
911
+ * numeric fields must be finite and positive, with the refill rate additionally
912
+ * capped at 1 so a typo can't turn the tail-hedge into a traffic doubler
913
+ * (refill ≤ 1 ⇒ hedges can never exceed un-hedged successes). Invalid values
914
+ * are ignored field-by-field, so one bad entry can't block the rest. Lives in
915
+ * the React-free `hive-tx` core (like the other setters) so both `@ecency/sdk`
916
+ * (via `ConfigManager.setResilience`) and the lean `@ecency/sdk/hive` entry
917
+ * can reach it.
918
+ */
919
+ declare const setResilience: (opts: Partial<ResilienceOptions>) => void;
858
920
 
859
921
  type Memo = {
860
922
  /**
@@ -1020,4 +1082,4 @@ declare namespace utils {
1020
1082
  export { type utils_WitnessProps as WitnessProps, utils_buildWitnessSetProperties as buildWitnessSetProperties, utils_makeBitMaskFilter as makeBitMaskFilter, utils_operations as operations, utils_validateUsername as validateUsername };
1021
1083
  }
1022
1084
 
1023
- export { Signature as $, type APIMethods as A, type Beneficiary as B, type CallResponse as C, type DeclineVotingRightsOperation as D, type EscrowApproveOperation as E, type EscrowDisputeOperation as F, type EscrowReleaseOperation as G, type EscrowTransferOperation as H, type Extension as I, type FeedPublishOperation as J, type LimitOrderCreate2Operation as K, type LimitOrderCancelOperation as L, type LimitOrderCreateOperation as M, Memo as N, type Operation as O, type OperationBody as P, type OperationName as Q, type Price as R, PrivateKey as S, PublicKey as T, type RecoverAccountOperation as U, type RecurrentTransferOperation as V, type RemoveProposalOperation as W, type RequestAccountRecoveryOperation as X, type ResetAccountOperation as Y, type SetResetAccountOperation as Z, type SetWithdrawVestingRouteOperation as _, type AccountCreateOperation as a, Transaction as a0, type TransactionStatus as a1, type TransactionType as a2, type TransferFromSavingsOperation as a3, type TransferOperation as a4, type TransferToSavingsOperation as a5, type TransferToVestingOperation as a6, type UpdateProposalOperation as a7, type UpdateProposalVotesOperation as a8, type VoteOperation as a9, type WithdrawVestingOperation as aa, type WitnessProps$1 as ab, type WitnessSetPropertiesOperation as ac, type WitnessSetPropertiesParams as ad, type WitnessUpdateOperation as ae, callREST as af, callRPC as ag, callRPCBroadcast as ah, callWithQuorum as ai, config as aj, operations as ak, setNodes as al, setRestNodes as am, setRestNodesByApi as an, setUserAgent as ao, utils as ap, type AccountCreateWithDelegationOperation as b, type AccountUpdate2Operation as c, type AccountUpdateOperation as d, type AccountWitnessProxyOperation as e, type AccountWitnessVoteOperation as f, type AssetSymbol as g, type Authority as h, type BroadcastError as i, type BroadcastResult as j, type CancelTransferFromSavingsOperation as k, type ChainProperties as l, type ChangeRecoveryAccountOperation as m, type ClaimAccountOperation as n, type ClaimRewardBalanceOperation as o, type CollateralizedConvertOperation as p, type CommentOperation as q, type CommentOptionsOperation as r, type ConvertOperation as s, type CreateClaimedAccountOperation as t, type CreateProposalOperation as u, type CustomJsonOperation as v, type CustomOperation as w, type DelegateVestingSharesOperation as x, type DeleteCommentOperation as y, type DigestData as z };
1085
+ export { type SetWithdrawVestingRouteOperation as $, type APIMethods as A, type Beneficiary as B, type CallResponse as C, type DeclineVotingRightsOperation as D, type EscrowApproveOperation as E, type EscrowDisputeOperation as F, type EscrowReleaseOperation as G, type EscrowTransferOperation as H, type Extension as I, type FeedPublishOperation as J, type LimitOrderCreate2Operation as K, type LimitOrderCancelOperation as L, type LimitOrderCreateOperation as M, Memo as N, type Operation as O, type OperationBody as P, type OperationName as Q, type Price as R, PrivateKey as S, PublicKey as T, type RecoverAccountOperation as U, type RecurrentTransferOperation as V, type RemoveProposalOperation as W, type RequestAccountRecoveryOperation as X, type ResetAccountOperation as Y, type ResilienceOptions as Z, type SetResetAccountOperation as _, type AccountCreateOperation as a, Signature as a0, Transaction as a1, type TransactionStatus as a2, type TransactionType as a3, type TransferFromSavingsOperation as a4, type TransferOperation as a5, type TransferToSavingsOperation as a6, type TransferToVestingOperation as a7, type UpdateProposalOperation as a8, type UpdateProposalVotesOperation as a9, type VoteOperation as aa, type WithdrawVestingOperation as ab, type WitnessProps$1 as ac, type WitnessSetPropertiesOperation as ad, type WitnessSetPropertiesParams as ae, type WitnessUpdateOperation as af, callREST as ag, callRPC as ah, callRPCBroadcast as ai, callWithQuorum as aj, config as ak, operations as al, setNodes as am, setResilience as an, setRestNodes as ao, setRestNodesByApi as ap, setUserAgent as aq, utils as ar, type AccountCreateWithDelegationOperation as b, type AccountUpdate2Operation as c, type AccountUpdateOperation as d, type AccountWitnessProxyOperation as e, type AccountWitnessVoteOperation as f, type AssetSymbol as g, type Authority as h, type BroadcastError as i, type BroadcastResult as j, type CancelTransferFromSavingsOperation as k, type ChainProperties as l, type ChangeRecoveryAccountOperation as m, type ClaimAccountOperation as n, type ClaimRewardBalanceOperation as o, type CollateralizedConvertOperation as p, type CommentOperation as q, type CommentOptionsOperation as r, type ConvertOperation as s, type CreateClaimedAccountOperation as t, type CreateProposalOperation as u, type CustomJsonOperation as v, type CustomOperation as w, type DelegateVestingSharesOperation as x, type DeleteCommentOperation as y, type DigestData as z };
@@ -1 +1 @@
1
- export { a as AccountCreateOperation, b as AccountCreateWithDelegationOperation, c as AccountUpdate2Operation, d as AccountUpdateOperation, e as AccountWitnessProxyOperation, f as AccountWitnessVoteOperation, g as AssetSymbol, h as Authority, B as Beneficiary, i as BroadcastError, j as BroadcastResult, C as CallResponse, k as CancelTransferFromSavingsOperation, l as ChainProperties, m as ChangeRecoveryAccountOperation, n as ClaimAccountOperation, o as ClaimRewardBalanceOperation, p as CollateralizedConvertOperation, q as CommentOperation, r as CommentOptionsOperation, s as ConvertOperation, t as CreateClaimedAccountOperation, u as CreateProposalOperation, v as CustomJsonOperation, w as CustomOperation, D as DeclineVotingRightsOperation, x as DelegateVestingSharesOperation, y as DeleteCommentOperation, z as DigestData, E as EscrowApproveOperation, F as EscrowDisputeOperation, G as EscrowReleaseOperation, H as EscrowTransferOperation, I as Extension, J as FeedPublishOperation, L as LimitOrderCancelOperation, K as LimitOrderCreate2Operation, M as LimitOrderCreateOperation, N as Memo, O as Operation, P as OperationBody, Q as OperationName, R as Price, S as PrivateKey, T as PublicKey, U as RecoverAccountOperation, V as RecurrentTransferOperation, W as RemoveProposalOperation, X as RequestAccountRecoveryOperation, Y as ResetAccountOperation, Z as SetResetAccountOperation, _ as SetWithdrawVestingRouteOperation, $ as Signature, a0 as Transaction, a1 as TransactionStatus, a2 as TransactionType, a3 as TransferFromSavingsOperation, a4 as TransferOperation, a5 as TransferToSavingsOperation, a6 as TransferToVestingOperation, a7 as UpdateProposalOperation, a8 as UpdateProposalVotesOperation, a9 as VoteOperation, aa as WithdrawVestingOperation, ab as WitnessProps, ac as WitnessSetPropertiesOperation, ad as WitnessSetPropertiesParams, ae as WitnessUpdateOperation, af as callREST, ag as callRPC, ah as callRPCBroadcast, ai as callWithQuorum, aj as config, al as setNodes, am as setRestNodes, an as setRestNodesByApi, ao as setUserAgent, ap as utils } from './hive-CMt4SNd2.js';
1
+ export { a as AccountCreateOperation, b as AccountCreateWithDelegationOperation, c as AccountUpdate2Operation, d as AccountUpdateOperation, e as AccountWitnessProxyOperation, f as AccountWitnessVoteOperation, g as AssetSymbol, h as Authority, B as Beneficiary, i as BroadcastError, j as BroadcastResult, C as CallResponse, k as CancelTransferFromSavingsOperation, l as ChainProperties, m as ChangeRecoveryAccountOperation, n as ClaimAccountOperation, o as ClaimRewardBalanceOperation, p as CollateralizedConvertOperation, q as CommentOperation, r as CommentOptionsOperation, s as ConvertOperation, t as CreateClaimedAccountOperation, u as CreateProposalOperation, v as CustomJsonOperation, w as CustomOperation, D as DeclineVotingRightsOperation, x as DelegateVestingSharesOperation, y as DeleteCommentOperation, z as DigestData, E as EscrowApproveOperation, F as EscrowDisputeOperation, G as EscrowReleaseOperation, H as EscrowTransferOperation, I as Extension, J as FeedPublishOperation, L as LimitOrderCancelOperation, K as LimitOrderCreate2Operation, M as LimitOrderCreateOperation, N as Memo, O as Operation, P as OperationBody, Q as OperationName, R as Price, S as PrivateKey, T as PublicKey, U as RecoverAccountOperation, V as RecurrentTransferOperation, W as RemoveProposalOperation, X as RequestAccountRecoveryOperation, Y as ResetAccountOperation, Z as ResilienceOptions, _ as SetResetAccountOperation, $ as SetWithdrawVestingRouteOperation, a0 as Signature, a1 as Transaction, a2 as TransactionStatus, a3 as TransactionType, a4 as TransferFromSavingsOperation, a5 as TransferOperation, a6 as TransferToSavingsOperation, a7 as TransferToVestingOperation, a8 as UpdateProposalOperation, a9 as UpdateProposalVotesOperation, aa as VoteOperation, ab as WithdrawVestingOperation, ac as WitnessProps, ad as WitnessSetPropertiesOperation, ae as WitnessSetPropertiesParams, af as WitnessUpdateOperation, ag as callREST, ah as callRPC, ai as callRPCBroadcast, aj as callWithQuorum, ak as config, am as setNodes, an as setResilience, ao as setRestNodes, ap as setRestNodesByApi, aq as setUserAgent, ar as utils } from './hive-UyJkAmOk.js';
@@ -1,9 +1,9 @@
1
- import {hexToBytes,bytesToHex}from'@noble/hashes/utils.js';import {ripemd160}from'@noble/hashes/legacy.js';import Ae from'bs58';import {secp256k1}from'@noble/curves/secp256k1.js';import {sha256,sha512}from'@noble/hashes/sha2.js';import {cbc}from'@noble/ciphers/aes.js';var me=Object.defineProperty;var ht=(n,e,t)=>e in n?me(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var mt=(n,e)=>{for(var t in e)me(n,t,{get:e[t],enumerable:true});};var y=(n,e,t)=>ht(n,typeof e!="symbol"?e+"":e,t);var Y=new ArrayBuffer(0),W=null,J=null;function yt(){return W||(typeof TextEncoder<"u"?W=new TextEncoder:W={encode(n){let e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<128)e.push(r);else if(r<2048)e.push(192|r>>6,128|r&63);else if(r>=55296&&r<=56319&&t+1<n.length){let i=n.charCodeAt(++t);r=65536+((r&1023)<<10)+(i&1023),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63);}else e.push(224|r>>12,128|r>>6&63,128|r&63);}return new Uint8Array(e)}}),W}function ye(){return J||(typeof TextDecoder<"u"?J=new TextDecoder:J={decode(n){let e=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength),t="";for(let r=0;r<e.length;){let i=e[r],s;i<128?(s=i,r+=1):(i&224)===192?(s=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(s=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(s=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10),56320+(s&1023)));}return t}}),J}var A=class A{constructor(e=A.DEFAULT_CAPACITY,t=A.DEFAULT_ENDIAN){y(this,"buffer");y(this,"view");y(this,"offset");y(this,"markedOffset");y(this,"limit");y(this,"littleEndian");y(this,"readUInt32",this.readUint32);this.buffer=e===0?Y:new ArrayBuffer(e),this.view=e===0?new DataView(Y):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new A(e,t)}static concat(e,t){let r=0;for(let u=0;u<e.length;++u){let c=e[u];if(c instanceof A)r+=c.limit-c.offset;else if(c instanceof Uint8Array)r+=c.length;else if(c instanceof ArrayBuffer)r+=c.byteLength;else if(Array.isArray(c))r+=c.length;else throw TypeError("Illegal buffer")}if(r===0)return new A(0,t);let i=new A(r,t),s=new Uint8Array(i.buffer),a=0;for(let u=0;u<e.length;++u){let c=e[u];c instanceof A?(s.set(new Uint8Array(c.buffer,c.offset,c.limit-c.offset),a),a+=c.limit-c.offset):c instanceof Uint8Array?(s.set(c,a),a+=c.length):c instanceof ArrayBuffer?(s.set(new Uint8Array(c),a),a+=c.byteLength):(s.set(c,a),a+=c.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof A){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new A(0,t),e.length>0&&(r.buffer=e.buffer,r.offset=e.byteOffset,r.limit=e.byteOffset+e.byteLength,r.view=new DataView(e.buffer));else if(e instanceof ArrayBuffer)r=new A(0,t),e.byteLength>0&&(r.buffer=e,r.offset=0,r.limit=e.byteLength,r.view=e.byteLength>0?new DataView(e):new DataView(Y));else if(Array.isArray(e))r=new A(e.length,t),r.limit=e.length,new Uint8Array(r.buffer).set(e);else throw TypeError("Illegal buffer");return r}writeBytes(e,t){return this.append(e,t)}writeInt8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setInt8(t,e),r&&(this.offset+=1),this}writeByte(e,t){return this.writeInt8(e,t)}writeUint8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setUint8(t,e),r&&(this.offset+=1),this}writeUInt8(e,t){return this.writeUint8(e,t)}readUint8(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint8(e);return t&&(this.offset+=1),r}readUInt8(e){return this.readUint8(e)}writeInt16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setInt16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeShort(e,t){return this.writeInt16(e,t)}writeUint16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setUint16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeUInt16(e,t){return this.writeUint16(e,t)}writeInt32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setInt32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeInt(e,t){return this.writeInt32(e,t)}writeUint32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setUint32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeUInt32(e,t){return this.writeUint32(e,t)}readUint32(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint32(e,this.littleEndian);return t&&(this.offset+=4),r}append(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i;return e instanceof A?(i=new Uint8Array(e.buffer,e.offset,e.limit-e.offset),e.offset+=i.length):e instanceof Uint8Array?i=e:e instanceof ArrayBuffer?i=new Uint8Array(e):i=new Uint8Array(e),i.length<=0?this:(t+i.length>this.buffer.byteLength&&this.resize(t+i.length),new Uint8Array(this.buffer).set(i,t),r&&(this.offset+=i.length),this)}clone(e){let t=new A(0,this.littleEndian);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(t.buffer).set(new Uint8Array(this.buffer)),t.view=new DataView(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t}copy(e,t){if(e===void 0&&(e=this.offset),t===void 0&&(t=this.limit),e===t)return new A(0,this.littleEndian);let r=t-e,i=new A(r,this.littleEndian);return i.offset=0,i.limit=r,new Uint8Array(i.buffer).set(new Uint8Array(this.buffer).subarray(e,t),0),i}copyTo(e,t,r,i){let s=typeof t>"u",a=typeof r>"u";t=s?e.offset:t,r=a?this.offset:r,i=i===void 0?this.limit:i;let u=i-r;return u===0?e:(e.ensureCapacity(t+u),new Uint8Array(e.buffer).set(new Uint8Array(this.buffer).subarray(r,i),t),a&&(this.offset+=u),s&&(e.offset+=u),this)}ensureCapacity(e){let t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this}flip(){return this.limit=this.offset,this.offset=0,this}resize(e){if(this.buffer.byteLength<e){let t=new ArrayBuffer(e);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t);}return this}skip(e){return this.offset+=e,this}writeInt64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigInt64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeLong(e,t){return this.writeInt64(e,t)}readInt64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigInt64(e,this.littleEndian);return t&&(this.offset+=8),r}readLong(e){return this.readInt64(e)}writeUint64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigUint64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeUInt64(e,t){return this.writeUint64(e,t)}readUint64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigUint64(e,this.littleEndian);return t&&(this.offset+=8),r}readUInt64(e){return this.readUint64(e)}toBuffer(e){let t=this.offset,r=this.limit;return !e&&t===0&&r===this.buffer.byteLength?this.buffer:t===r?Y:this.buffer.slice(t,r)}toArrayBuffer(e){return this.toBuffer(e)}writeVarint32(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=this.calculateVarint32(e);for(t+i>this.buffer.byteLength&&this.resize(t+i),e>>>=0;e>=128;)this.view.setUint8(t++,e&127|128),e>>>=7;return this.view.setUint8(t++,e),r?(this.offset=t,this):i}readVarint32(e){let t=typeof e>"u";typeof e>"u"&&(e=this.offset);let r=0,i=0,s;do s=this.view.getUint8(e++),r<5&&(i|=(s&127)<<7*r),++r;while((s&128)!==0);return i|=0,t?(this.offset=e,i):{value:i,length:r}}calculateVarint32(e){return e=e>>>0,e<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5}writeVString(e,t){let r=typeof t>"u",i=r?this.offset:t,s=yt().encode(e),a=s.length,u=this.calculateVarint32(a);return i+u+a>this.buffer.byteLength&&this.resize(i+u+a),this.writeVarint32(a,i),i+=u,new Uint8Array(this.buffer).set(s,i),i+=a,r?(this.offset=i,this):i-(t||0)}readVString(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=e,i=this.readVarint32(e),s=i.value,a=i.length;e+=a;let u=ye().decode(new Uint8Array(this.buffer,e,s));return e+=s,t?(this.offset=e,u):{string:u,length:e-r}}readUTF8String(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=ye().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};y(A,"LITTLE_ENDIAN",true),y(A,"BIG_ENDIAN",false),y(A,"DEFAULT_CAPACITY",16),y(A,"DEFAULT_ENDIAN",A.BIG_ENDIAN);var b=A;var g={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","https://techcoderx.com","https://api.syncad.com","https://rpc.mahdiyari.info"],restNodes:["https://api.hive.blog","https://rpc.mahdiyari.info","https://api.syncad.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],restNodesByApi:{hivesense:["https://api.hive.blog","https://api.syncad.com"]},userAgent:"ecency-sdk",chain_id:"beeab0de00000000000000000000000000000000000000000000000000000000",address_prefix:"STM",timeout:5e3,broadcastTimeout:15e3,retry:5},ne=n=>Array.isArray(n)?[...new Set(n.filter(e=>typeof e=="string").map(e=>e.trim().replace(/\/+$/,"")).filter(e=>e.length>0&&/^https?:\/\/.+/.test(e)))]:[],pt=n=>{let e=ne(n);e.length&&(g.nodes=e);},gt=n=>{let e=ne(n);e.length&&(g.restNodes=e);},_t=n=>{if(!n||typeof n!="object")return;let e={...g.restNodesByApi};for(let[t,r]of Object.entries(n)){let i=ne(r);i.length?e[t]=i:delete e[t];}g.restNodesByApi=e;},bt=n=>{if(typeof n!="string")return;let e=n.trim();!e||/[\u0000-\u001f\u007f]/.test(e)||(g.userAgent=e);};var M=class n{constructor(e,t,r){y(this,"data");y(this,"recovery");y(this,"compressed");this.data=e,this.recovery=t,this.compressed=r??true;}static from(e){if(typeof e=="string"){let t=hexToBytes(e),r=parseInt(bytesToHex(t.subarray(0,1)),16)-31,i=true;r<0&&(i=false,r=r+4);let s=t.subarray(1);return new n(s,r,i)}else throw new Error("Expected string for data")}toBuffer(){let e=new Uint8Array(65).fill(0);return this.compressed?e[0]=this.recovery+31&255:e[0]=this.recovery+27&255,e.set(this.data,1),e}customToString(){return bytesToHex(this.toBuffer())}toString(){return this.customToString()}getPublicKey(e){if(e instanceof Uint8Array&&e.length!==32||typeof e=="string"&&e.length!==64)throw new Error("Expected a valid sha256 hash as message");typeof e=="string"&&(e=hexToBytes(e));let t=secp256k1.Signature.fromBytes(this.data,"compact"),r=new secp256k1.Signature(t.r,t.s,this.recovery);return new S(r.recoverPublicKey(e).toBytes())}};var S=class n{constructor(e,t){y(this,"key");y(this,"prefix");this.key=e,this.prefix=t??g.address_prefix;}static fromString(e){let t=g.address_prefix;if(typeof e!="string"||e.length<=t.length)throw new Error("Invalid public key");let r=e.slice(0,t.length);if(r!==t)throw new Error(`Public key must start with ${t}`);let i;try{i=Ae.decode(e.slice(t.length));}catch{throw new Error("Invalid public key encoding")}if(i.length!==37)throw new Error("Invalid public key length");let s=i.subarray(0,33),a=i.subarray(33,37),u=ripemd160(s).subarray(0,4);if(!At(a,u))throw new Error("Public key checksum mismatch");try{secp256k1.Point.fromBytes(s);}catch{throw new Error("Invalid public key")}return new n(s,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=M.from(t)),secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return wt(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},wt=(n,e)=>{let t=ripemd160(n);return e+Ae.encode(new Uint8Array([...n,...t.subarray(0,4)]))},At=(n,e)=>{if(n.byteLength!==e.byteLength)return false;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return false;return true};var G=class n{constructor(e,t){y(this,"amount");y(this,"symbol");this.amount=e,this.symbol=t==="HIVE"?"STEEM":t==="HBD"?"SBD":t;}static fromString(e,t=null){let[r,i]=e.split(" ");if(["STEEM","VESTS","SBD","TESTS","TBD","HIVE","HBD"].indexOf(i)===-1)throw new Error(`Invalid asset symbol: ${i}`);if(t&&i!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${i}`);let s=Number.parseFloat(r);if(!Number.isFinite(s))throw new Error(`Invalid asset amount: ${r}`);return new n(s,i)}static from(e,t){if(e instanceof n){if(t&&e.symbol!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${e.symbol}`);return e}else {if(typeof e=="number"&&Number.isFinite(e))return new n(e,t||"STEEM");if(typeof e=="string")return n.fromString(e,t);throw new Error(`Invalid asset '${String(e)}'`)}}getPrecision(){switch(this.symbol){case "TESTS":case "TBD":case "STEEM":case "SBD":case "HBD":case "HIVE":return 3;case "VESTS":return 6;default:return 3}}toString(){return `${this.amount.toFixed(this.getPrecision())} ${this.symbol}`}toJSON(){return this.toString()}};var X=class n{constructor(e){y(this,"buffer");this.buffer=e;}static from(e){return e instanceof n?e:e instanceof Uint8Array?new n(e):typeof e=="string"?new n(hexToBytes(e)):new n(new Uint8Array(e))}toString(){return bytesToHex(this.buffer)}toJSON(){return this.toString()}};var h={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,custom:15,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49},I=()=>{throw new Error("Void can not be serialized")},o=(n,e)=>{n.writeVString(e);},xt=(n,e)=>{n.writeInt16(e);},Be=(n,e)=>{n.writeInt64(e);},ve=(n,e)=>{n.writeUint8(e);},P=(n,e)=>{n.writeUint16(e);},U=(n,e)=>{n.writeUint32(e);},xe=(n,e)=>{n.writeUint64(e);},O=(n,e)=>{n.writeByte(e?1:0);},Se=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},_=(n,e)=>{let t=G.from(e),r=t.getPrecision();n.writeInt64(Math.round(t.amount*Math.pow(10,r))),n.writeUint8(r);for(let i=0;i<7;i++)n.writeUint8(t.symbol.charCodeAt(i)||0);},D=(n,e)=>{n.writeUint32(Math.floor(new Date(e+"Z").getTime()/1e3));},N=(n,e)=>{e===null||typeof e=="string"&&e.slice(-39)==="1111111111111111111111111111111114T1Anm"?n.append(new Uint8Array(33).fill(0)):n.append(S.from(e).key);},Ue=(n=null)=>(e,t)=>{t=X.from(t);let r=t.buffer.length;if(n){if(r!==n)throw new Error(`Unable to serialize binary. Expected ${n} bytes, got ${r}`)}else e.writeVarint32(r);e.append(t.buffer);},Ee=Ue(),ie=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,s]of r)n(t,i),e(t,s);},v=n=>(e,t)=>{e.writeVarint32(t.length);for(let r of t)n(e,r);},k=n=>(e,t)=>{for(let[r,i]of n)try{i(e,t[r]);}catch(s){throw s.message=`${r}: ${s.message}`,s}},z=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},x=k([["weight_threshold",U],["account_auths",ie(o,P)],["key_auths",ie(N,P)]]),St=k([["account",o],["weight",P]]),se=k([["base",_],["quote",_]]),Ut=k([["account_creation_fee",_],["maximum_block_size",U],["hbd_interest_rate",P]]),m=(n,e)=>{let t=k(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},d={};d.account_create=m(h.account_create,[["fee",_],["creator",o],["new_account_name",o],["owner",x],["active",x],["posting",x],["memo_key",N],["json_metadata",o]]);d.account_create_with_delegation=m(h.account_create_with_delegation,[["fee",_],["delegation",_],["creator",o],["new_account_name",o],["owner",x],["active",x],["posting",x],["memo_key",N],["json_metadata",o],["extensions",v(I)]]);d.account_update=m(h.account_update,[["account",o],["owner",z(x)],["active",z(x)],["posting",z(x)],["memo_key",N],["json_metadata",o]]);d.account_witness_proxy=m(h.account_witness_proxy,[["account",o],["proxy",o]]);d.account_witness_vote=m(h.account_witness_vote,[["account",o],["witness",o],["approve",O]]);d.cancel_transfer_from_savings=m(h.cancel_transfer_from_savings,[["from",o],["request_id",U]]);d.change_recovery_account=m(h.change_recovery_account,[["account_to_recover",o],["new_recovery_account",o],["extensions",v(I)]]);d.claim_account=m(h.claim_account,[["creator",o],["fee",_],["extensions",v(I)]]);d.claim_reward_balance=m(h.claim_reward_balance,[["account",o],["reward_hive",_],["reward_hbd",_],["reward_vests",_]]);d.comment=m(h.comment,[["parent_author",o],["parent_permlink",o],["author",o],["permlink",o],["title",o],["body",o],["json_metadata",o]]);d.comment_options=m(h.comment_options,[["author",o],["permlink",o],["max_accepted_payout",_],["percent_hbd",P],["allow_votes",O],["allow_curation_rewards",O],["extensions",v(Se([k([["beneficiaries",v(St)]])]))]]);d.convert=m(h.convert,[["owner",o],["requestid",U],["amount",_]]);d.create_claimed_account=m(h.create_claimed_account,[["creator",o],["new_account_name",o],["owner",x],["active",x],["posting",x],["memo_key",N],["json_metadata",o],["extensions",v(I)]]);d.custom=m(h.custom,[["required_auths",v(o)],["id",P],["data",Ee]]);d.custom_json=m(h.custom_json,[["required_auths",v(o)],["required_posting_auths",v(o)],["id",o],["json",o]]);d.decline_voting_rights=m(h.decline_voting_rights,[["account",o],["decline",O]]);d.delegate_vesting_shares=m(h.delegate_vesting_shares,[["delegator",o],["delegatee",o],["vesting_shares",_]]);d.delete_comment=m(h.delete_comment,[["author",o],["permlink",o]]);d.escrow_approve=m(h.escrow_approve,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U],["approve",O]]);d.escrow_dispute=m(h.escrow_dispute,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U]]);d.escrow_release=m(h.escrow_release,[["from",o],["to",o],["agent",o],["who",o],["receiver",o],["escrow_id",U],["hbd_amount",_],["hive_amount",_]]);d.escrow_transfer=m(h.escrow_transfer,[["from",o],["to",o],["hbd_amount",_],["hive_amount",_],["escrow_id",U],["agent",o],["fee",_],["json_meta",o],["ratification_deadline",D],["escrow_expiration",D]]);d.feed_publish=m(h.feed_publish,[["publisher",o],["exchange_rate",se]]);d.limit_order_cancel=m(h.limit_order_cancel,[["owner",o],["orderid",U]]);d.limit_order_create=m(h.limit_order_create,[["owner",o],["orderid",U],["amount_to_sell",_],["min_to_receive",_],["fill_or_kill",O],["expiration",D]]);d.limit_order_create2=m(h.limit_order_create2,[["owner",o],["orderid",U],["amount_to_sell",_],["exchange_rate",se],["fill_or_kill",O],["expiration",D]]);d.recover_account=m(h.recover_account,[["account_to_recover",o],["new_owner_authority",x],["recent_owner_authority",x],["extensions",v(I)]]);d.request_account_recovery=m(h.request_account_recovery,[["recovery_account",o],["account_to_recover",o],["new_owner_authority",x],["extensions",v(I)]]);d.reset_account=m(h.reset_account,[["reset_account",o],["account_to_reset",o],["new_owner_authority",x]]);d.set_reset_account=m(h.set_reset_account,[["account",o],["current_reset_account",o],["reset_account",o]]);d.set_withdraw_vesting_route=m(h.set_withdraw_vesting_route,[["from_account",o],["to_account",o],["percent",P],["auto_vest",O]]);d.transfer=m(h.transfer,[["from",o],["to",o],["amount",_],["memo",o]]);d.transfer_from_savings=m(h.transfer_from_savings,[["from",o],["request_id",U],["to",o],["amount",_],["memo",o]]);d.transfer_to_savings=m(h.transfer_to_savings,[["from",o],["to",o],["amount",_],["memo",o]]);d.transfer_to_vesting=m(h.transfer_to_vesting,[["from",o],["to",o],["amount",_]]);d.vote=m(h.vote,[["voter",o],["author",o],["permlink",o],["weight",xt]]);d.withdraw_vesting=m(h.withdraw_vesting,[["account",o],["vesting_shares",_]]);d.witness_update=m(h.witness_update,[["owner",o],["url",o],["block_signing_key",N],["props",Ut],["fee",_]]);d.witness_set_properties=m(h.witness_set_properties,[["owner",o],["props",ie(o,Ee)],["extensions",v(I)]]);d.account_update2=m(h.account_update2,[["account",o],["owner",z(x)],["active",z(x)],["posting",z(x)],["memo_key",z(N)],["json_metadata",o],["posting_json_metadata",o],["extensions",v(I)]]);d.create_proposal=m(h.create_proposal,[["creator",o],["receiver",o],["start_date",D],["end_date",D],["daily_pay",_],["subject",o],["permlink",o],["extensions",v(I)]]);d.update_proposal_votes=m(h.update_proposal_votes,[["voter",o],["proposal_ids",v(Be)],["approve",O],["extensions",v(I)]]);d.remove_proposal=m(h.remove_proposal,[["proposal_owner",o],["proposal_ids",v(Be)],["extensions",v(I)]]);var Et=k([["end_date",D]]);d.update_proposal=m(h.update_proposal,[["proposal_id",xe],["creator",o],["daily_pay",_],["subject",o],["permlink",o],["extensions",v(Se([I,Et]))]]);d.collateralized_convert=m(h.collateralized_convert,[["owner",o],["requestid",U],["amount",_]]);d.recurrent_transfer=m(h.recurrent_transfer,[["from",o],["to",o],["amount",_],["memo",o],["recurrence",P],["executions",P],["extensions",v(k([["type",ve],["value",k([["pair_id",ve]])]]))]]);var Tt=(n,e)=>{let t=d[e[0]];if(!t)throw new Error(`No serializer for operation: ${e[0]}`);try{t(n,e[1]);}catch(r){throw r.message=`${e[0]}: ${r.message}`,r}},It=k([["ref_block_num",P],["ref_block_prefix",U],["expiration",D],["operations",v(Tt)],["extensions",v(o)]]),Pt=k([["from",N],["to",N],["nonce",xe],["check",U],["encrypted",Ue()]]),L={Asset:_,Memo:Pt,Price:se,PublicKey:N,String:o,Transaction:It,UInt16:P,UInt32:U};var j=n=>new Promise(e=>setTimeout(e,n));var kt=(()=>{try{return !(typeof navigator<"u"&&navigator.product==="ReactNative")&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null}catch{return false}})();function Ie(){return kt?{"User-Agent":g.userAgent}:{}}var R=class extends Error{constructor(t){super(t.message);y(this,"name","RPCError");y(this,"data");y(this,"code");y(this,"stack");this.code=t.code,"data"in t&&(this.data=t.data);}},K=class extends Error{constructor(t,r,i={}){super(r);y(this,"node");y(this,"rateLimitMs");y(this,"isRateLimit");this.node=t,this.rateLimitMs=i.rateLimitMs??0,this.isRateLimit=i.isRateLimit??false;}};function Pe(n){if(!n)return 0;let e=Number(n);if(Number.isFinite(e))return e>0?e*1e3:0;let t=Date.parse(n);if(Number.isFinite(t)){let r=t-Date.now();return r>0?r:0}return 0}var Lt=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"],Nt=["Failed to fetch","NetworkError when attempting to fetch","Load failed","fetch failed"];function Rt(n){if(!n)return "";let e=[String(n.name||""),String(n.message||""),String(n.code||"")],t=n.cause;for(let r=0;t&&r<5;r++)e.push(String(t.code||""),String(t.message||"")),t=t.cause;return e.join(" ")}function Ot(n){if(!n)return false;if(n instanceof K)return true;if(n instanceof R)return false;let e=Rt(n);return !!(Lt.some(t=>e.includes(t))||Nt.some(t=>e.includes(t))||n instanceof SyntaxError||/Unexpected token|JSON\.parse|Unexpected end of JSON/i.test(e))}function Dt(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function ke(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var Ct=1e4,Mt=6e4,zt=12e4,Ft=2,Kt=6e4,Te=12e4,Ht=30,oe=.3,Le=3,ae=5*6e4,Ne=6e4,Re=1e3,Oe=2e3,De=700,Ce=2.5,Vt=new Set(["hapi.ecency.com","api.ecency.com"]);function jt(n){try{return Vt.has(new URL(n).hostname)}catch{return false}}var Q=class{constructor(){y(this,"health",new Map);}getOrCreate(e){let t=this.health.get(e);return t||(t={consecutiveFailures:0,lastFailureTime:0,rateLimitedUntil:0,rateLimitStreak:0,lastRateLimitAt:0,apiFailures:new Map,headBlock:0,headBlockUpdatedAt:0,ewmaLatencyMs:void 0,latencySampleCount:0,latencyUpdatedAt:0,lastProbeAt:Date.now()},this.health.set(e,t)),t}recordSuccess(e,t,r){let i=this.getOrCreate(e);i.consecutiveFailures=0,i.rateLimitStreak=0,t&&i.apiFailures.delete(t),typeof r=="number"&&Number.isFinite(r)&&r>=0&&this.recordLatency(i,r);}recordSlowFailure(e,t){!Number.isFinite(t)||t<Oe||this.recordLatency(this.getOrCreate(e),t);}recordLatency(e,t){let r=Date.now();e.latencyUpdatedAt>0&&r-e.latencyUpdatedAt>ae&&(e.ewmaLatencyMs=void 0,e.latencySampleCount=0),e.ewmaLatencyMs=e.ewmaLatencyMs===void 0?t:oe*t+(1-oe)*e.ewmaLatencyMs,e.latencySampleCount++,e.latencyUpdatedAt=r;}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),s=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(s.cooldownUntil>0&&s.cooldownUntil<=i||s.lastFailureTime>0&&i-s.lastFailureTime>3e4)&&(s.count=0,s.cooldownUntil=0),s.count++,s.lastFailureTime=i,s.count>=Ft&&(s.cooldownUntil=i+Kt),r.apiFailures.set(t,s);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordRateLimit(e,t){let r=this.getOrCreate(e),i=Date.now();r.rateLimitStreak>0&&i-r.lastRateLimitAt>zt&&(r.rateLimitStreak=0);let s=typeof t=="number"&&Number.isFinite(t)&&t>0,a=s?t:Math.min(Ct*2**r.rateLimitStreak,Mt);s||r.rateLimitStreak++,r.lastRateLimitAt=i,r.rateLimitedUntil=s?i+a:Math.max(r.rateLimitedUntil,i+a),r.consecutiveFailures++,r.lastFailureTime=i;}recordHeadBlock(e,t){if(!t||!Number.isFinite(t))return;let r=this.getOrCreate(e);r.headBlock=t,r.headBlockUpdatedAt=Date.now();}consensusHeadBlock(){let e=Date.now(),t=[];for(let r of this.health.values())r.headBlock>0&&e-r.headBlockUpdatedAt<=Te&&t.push(r.headBlock);return t.length<2?0:(t.sort((r,i)=>r-i),t[Math.floor((t.length-1)/2)])}isNodeHealthy(e,t){let r=this.health.get(e);if(!r)return true;let i=Date.now();if(r.rateLimitedUntil>i||r.consecutiveFailures>=3&&i-r.lastFailureTime<3e4)return false;if(t){let a=r.apiFailures.get(t);if(a&&a.cooldownUntil>i)return false}let s=this.consensusHeadBlock();return !(s>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=Te&&s-r.headBlock>Ht)}getOrderedNodes(e,t){let r=[],i=[];for(let f of e)this.isNodeHealthy(f,t)?r.push(f):i.push(f);if(r.length<=1)return [...r,...i];let s=Date.now(),a=this.fastestUsableLatency(r,s),u=r.map((f,l)=>({node:f,i:l,score:this.scoreNode(f,a,s)})).sort((f,l)=>f.score-l.score||f.i-l.i).map(f=>f.node),c=this.pickReprobeCandidate(r,s);return c&&u[0]!==c?[c,...u.filter(f=>f!==c),...i]:[...u,...i]}isLatencyUsable(e,t){return !!e&&e.ewmaLatencyMs!==void 0&&e.latencySampleCount>=Le&&t-e.latencyUpdatedAt<=ae}fastestUsableLatency(e,t){let r=1/0;for(let i of e){let s=this.health.get(i);this.isLatencyUsable(s,t)&&(r=Math.min(r,s.ewmaLatencyMs));}return r}scoreNode(e,t,r){let i=this.health.get(e);if(!this.isLatencyUsable(i,r))return Re;let s=i.ewmaLatencyMs;return jt(e)?t>0&&t!==1/0&&s>Ce*t?s:Math.max(s-De,0):s}pickReprobeCandidate(e,t){let r=t-Ne,i,s=1/0;for(let a of e){let u=this.getOrCreate(a),c=Math.max(u.latencyUpdatedAt,u.lastProbeAt);c<=r&&c<s&&(i=a,s=c);}return i&&(this.getOrCreate(i).lastProbeAt=t),i}},C=new Q,F=new Q;function Me(n,e,t,r){t instanceof K?t.isRateLimit?n.recordRateLimit(e,t.rateLimitMs||void 0):n.recordFailure(e,r):t instanceof R?n.recordFailure(e,r):n.recordFailure(e);}function $t(n,e,t,r){if(!r||typeof r!="object"||!t.includes("get_dynamic_global_properties"))return;let i=r.head_block_number;typeof i=="number"&&n.recordHeadBlock(e,i);}function qt(){if(typeof DOMException<"u")return new DOMException("The operation was aborted due to timeout","TimeoutError");let n=new Error("The operation was aborted due to timeout");return n.name="TimeoutError",n}function ze(n){if(typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(qt()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function Fe(n,e){if(!e)return {signal:n,cleanup:()=>{}};if(typeof AbortSignal.any=="function")return {signal:AbortSignal.any([n,e]),cleanup:()=>{}};let t=new AbortController;if(n.aborted)return t.abort(n.reason),{signal:t.signal,cleanup:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,cleanup:()=>{}};let r=()=>t.abort(n.reason),i=()=>t.abort(e.reason);n.addEventListener("abort",r,{once:true}),e.addEventListener("abort",i,{once:true});let s=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:s}}var Z=async(n,e,t,r=g.timeout,i=false,s)=>{let a=Math.floor(Math.random()*1e8),u={jsonrpc:"2.0",method:e,params:t,id:a},{signal:c,cleanup:f}=ze(r),{signal:l,cleanup:E}=Fe(c,s),p=()=>{f(),E();};try{let B=await fetch(n,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json",...Ie()},signal:l});if(B.status===429)throw new K(n,"HTTP 429 Rate Limited",{rateLimitMs:Pe(B.headers.get("Retry-After")),isRateLimit:!0});if(B.status>=500&&B.status<600)throw new K(n,`HTTP ${B.status} from ${n}`);let T=await B.json();if(!T||typeof T.id>"u"||T.id!==a||T.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in T)return T.result;if("error"in T){let H=T.error;throw "message"in H&&"code"in H?new R(H):T.error}throw T}catch(B){if(B instanceof R||B instanceof K||s?.aborted)throw B;if(i)return Z(n,e,t,r,false,s);throw B}finally{p();}};function Ke(){return j(50+Math.random()*50)}var ee=async(n,e=[],t=g.timeout,r=g.retry,i)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let s=ke(n),a=new Set,u;for(let c=0;c<=r;c++){let f=C.getOrderedNodes(g.nodes,s),l=f.find(p=>!a.has(p));l||(a.clear(),l=f[0]),a.add(l);let E=Date.now();try{let p=await Z(l,n,e,t,!1,i);return C.recordSuccess(l,s,Date.now()-E),$t(C,l,n,p),p}catch(p){if(p instanceof R&&!Dt(p.code,p.message)||i?.aborted)throw p;Me(C,l,p,s),C.recordSlowFailure(l,Date.now()-E),u=p,c<r&&await Ke();}}throw u},ce=async(n,e=[],t=g.broadcastTimeout,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let i=ke(n),s=new Set,a;for(let u=0;u<g.nodes.length;u++){let f=C.getOrderedNodes(g.nodes,i).find(l=>!s.has(l));if(!f)break;if(s.add(f),r?.aborted)throw new Error("Aborted");try{let l=await Z(f,n,e,t,!1,r);return C.recordSuccess(f,i),l}catch(l){if(l instanceof R||r?.aborted||(Me(C,f,l,i),a=l,!Ot(l)))throw l}}throw a},Yt={balance:"/balance-api",hafah:"/hafah-api",hafbe:"/hafbe-api",hivemind:"/hivemind-api",hivesense:"/hivesense-api",reputation:"/reputation-api","nft-tracker":"/nft-tracker-api",hafsql:"/hafsql",status:"/status-api"};async function Wt(n,e,t,r=g.timeout,i=g.retry,s){if(!Array.isArray(g.restNodes))throw new Error("config.restNodes is not an array");if(g.restNodes.length===0)throw new Error("config.restNodes is empty");let a=g.restNodesByApi?.[n]?.length?g.restNodesByApi[n]:g.restNodes,u=new Set,c,f=false;for(let l=0;l<=i;l++){let E=F.getOrderedNodes(a,n),p=E.find(w=>!u.has(w));p||(u.clear(),p=E[0]),u.add(p);let B=p+Yt[n],T=e,H=t||{},de=new Set;Object.entries(H).forEach(([w,V])=>{T.includes(`{${w}}`)&&(T=T.replace(`{${w}}`,encodeURIComponent(String(V))),de.add(w));});let re=new URL(B+T);if(Object.entries(H).forEach(([w,V])=>{de.has(w)||(Array.isArray(V)?V.forEach(dt=>re.searchParams.append(w,String(dt))):re.searchParams.set(w,String(V)));}),s?.aborted)throw new Error("Aborted");f=false;let{signal:at,cleanup:ct}=ze(r),{signal:ut,cleanup:ft}=Fe(at,s),lt=()=>{ct(),ft();},he=Date.now();try{let w=await fetch(re.toString(),{signal:ut,headers:Ie()});if(w.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(w.status===429)throw F.recordRateLimit(p,Pe(w.headers.get("Retry-After"))||void 0),f=!0,new Error(`HTTP 429 Rate Limited by ${p}`);if(w.status===503)throw F.recordFailure(p,n),f=!0,new Error(`HTTP 503 Service Unavailable from ${p}`);if(!w.ok)throw F.recordFailure(p,n),f=!0,new Error(`HTTP ${w.status} from ${p}`);return F.recordSuccess(p,n,Date.now()-he),w.json()}catch(w){if(w?.message?.includes("HTTP 404")||s?.aborted)throw w;f||F.recordFailure(p,n),F.recordSlowFailure(p,Date.now()-he),c=w,l<i&&await Ke();}finally{lt();}}throw c}var Jt=async(n,e=[],t=2,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an Array");if(t>g.nodes.length)throw new Error("quorum > config.nodes.length");let s=(c=>{let f=[...c];for(let l=f.length-1;l>0;l--){let E=Math.floor(Math.random()*(l+1));[f[l],f[E]]=[f[E],f[l]];}return f})(g.nodes),a=Math.min(t,s.length),u=[];for(;a>0&&s.length>0;){let c=s.splice(0,a),f=[],l=[];for(let p=0;p<c.length;p++)f.push(Z(c[p],n,e,void 0,true,r).then(B=>l.push(B)).catch(()=>{}));await Promise.all(f),u.push(...l);let E=Gt(u,t);if(E)return E;if(a=Math.min(t,s.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function Gt(n,e){let t=new Map;for(let i of n){let s=JSON.stringify(i);t.has(s)||t.set(s,[]),t.get(s).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var Qt=hexToBytes(g.chain_id),ue=class n{constructor(e){y(this,"transaction");y(this,"expiration",6e4);y(this,"txId");y(this,"createTransaction",async e=>{let t=await ee("condenser_api.get_dynamic_global_properties",[]),r=hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),s=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:s,extensions:[],operations:[],ref_block_num:t.head_block_number&65535,ref_block_prefix:i,signatures:[]};});e?.transaction&&(e.transaction instanceof n?(this.transaction=e.transaction.transaction,this.expiration=e.transaction.expiration):this.transaction=e.transaction,this.transaction&&!Array.isArray(this.transaction.signatures)&&(this.transaction.signatures=[]),this.txId=this.digest().txId),e?.expiration&&(this.expiration=e.expiration);}async addOperation(e,t){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([e,t]);}sign(e){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");if(this.transaction){let{digest:t,txId:r}=this.digest();Array.isArray(e)||(e=[e]);for(let i of e){let s=i.sign(t);this.transaction.signatures.push(s.customToString());}return this.txId=r,this.transaction}else throw new Error("No transaction to sign")}async broadcast(e=false){if(!this.transaction)throw new Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(this.transaction.signatures.length===0)throw new Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await ce("condenser_api.broadcast_transaction",[this.transaction]);}catch(s){if(!(s instanceof R&&s.message.includes("Duplicate transaction check failed")))throw s}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await j(1e3);let r=await this.checkStatus(),i=1;for(;r?.status!=="within_irreversible_block"&&r?.status!=="expired_irreversible"&&r?.status!=="too_old"&&i<t;)await j(1e3+i*300),r=await this.checkStatus(),i++;return {tx_id:this.txId,status:r?.status??"unknown"}}digest(){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");let e=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN),t={...this.transaction};try{L.Transaction(e,t);}catch(a){throw new Error("Unable to serialize transaction: "+a)}e.flip();let r=new Uint8Array(e.toBuffer()),i=bytesToHex(sha256(r)).slice(0,40);return {digest:sha256(new Uint8Array([...Qt,...r])),txId:i}}addSignature(e){if(!this.transaction)throw new Error("First create a transaction by .create(operations)");if(typeof e!="string")throw new Error("Signature must be string");if(e.length!==130)throw new Error("Signature must be 130 characters long");return this.transaction.signatures.push(e),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),ee("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}};var Ye=new Uint8Array([128]),q=class n{constructor(e){y(this,"key");this.key=e;try{secp256k1.getPublicKey(e);}catch{throw new Error("invalid private key")}}static from(e){return typeof e=="string"?n.fromString(e):new n(e)}static fromString(e){return new n(rr(e).subarray(1))}static fromSeed(e){if(typeof e=="string")if(/^[0-9a-fA-F]+$/.test(e))e=hexToBytes(e);else {let r=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s<128)r.push(s);else if(s<2048)r.push(192|s>>6,128|s&63);else if(s>=55296&&s<=56319&&i+1<e.length){let a=e.charCodeAt(++i);s=65536+((s&1023)<<10)+(a&1023),r.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63);}else r.push(224|s>>12,128|s>>6&63,128|s&63);}e=new Uint8Array(r);}return new n(sha256(e))}static fromLogin(e,t,r="active"){let i=e+r+t;return n.fromSeed(i)}sign(e){let t=secp256k1.sign(e,this.key,{extraEntropy:true,format:"recovered",prehash:false}),r=parseInt(bytesToHex(t.subarray(0,1)),16);return M.from((r+31).toString(16)+bytesToHex(t.subarray(1)))}createPublic(e){return new S(secp256k1.getPublicKey(this.key),e)}toString(){return tr(new Uint8Array([...Ye,...this.key]))}inspect(){let e=this.toString();return `PrivateKey: ${e.slice(0,6)}...${e.slice(-6)}`}getSharedSecret(e){let t=secp256k1.getSharedSecret(this.key,e.key);return sha512(t.subarray(1))}static randomKey(){return new n(secp256k1.keygen().secretKey)}},We=n=>sha256(sha256(n)),tr=n=>{let e=We(n);return Ae.encode(new Uint8Array([...n,...e.slice(0,4)]))},rr=n=>{let e=Ae.decode(n);if(!$e(e.slice(0,1),Ye))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=We(r).slice(0,4);if(!$e(t,i))throw new Error("Private key checksum mismatch");return r},$e=(n,e)=>{if(n===e)return true;if(n.byteLength!==e.byteLength)return false;let t=n.byteLength,r=0;for(;r<t&&n[r]===e[r];)r++;return r===t};var Ge=(n,e,t,r=cr())=>Qe(n,e,r,t),Xe=(n,e,t,r,i)=>Qe(n,e,t,r,i).message,Qe=(n,e,t,r,i)=>{let s=t,a=n.getSharedSecret(e),u=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);u.writeUint64(s),u.append(a),u.flip();let c=sha512(new Uint8Array(u.toBuffer())),f=c.subarray(32,48),l=c.subarray(0,32),E=sha256(c).subarray(0,4),p=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);p.append(E),p.flip();let B=p.readUint32();if(i!==void 0){if(B!==i)throw new Error("Invalid key");r=or(r,l,f);}else r=ar(r,l,f);return {nonce:s,message:r,checksum:B}},or=(n,e,t)=>{let r=n;return r=cbc(e,t).decrypt(r),r},ar=(n,e,t)=>{let r=n;return r=cbc(e,t).encrypt(r),r},le=null,cr=()=>{if(le===null){let t=secp256k1.utils.randomSecretKey();le=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++le%65536;return n=n<<BigInt(16)|BigInt(e),n};var Ze=n=>{let e=mr(n,33);return new S(e)},fr=n=>n.readUint64(),lr=n=>n.readUint32(),dr=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},hr=n=>e=>{let t={},r=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,s]of n)try{t[i]=s(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function mr(n,e){if(n){let t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())}else throw Error("No buffer found on first parameter")}var yr=hr([["from",Ze],["to",Ze],["nonce",fr],["check",lr],["encrypted",dr]]),et={Memo:yr};var rt=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),it(),n=st(n),e=pr(e);let i=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);i.writeVString(t);let s=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:u,checksum:c}=Ge(n,e,s,r),f=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);L.Memo(f,{check:c,encrypted:u,from:n.createPublic(),nonce:a,to:e}),f.flip();let l=new Uint8Array(f.toBuffer());return "#"+Ae.encode(l)},nt=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),it(),n=st(n);let t=et.Memo(Ae.decode(e)),{from:r,to:i,nonce:s,check:a,encrypted:u}=t,f=n.createPublic().toString()===new S(r.key).toString()?new S(i.key):new S(r.key);t=Xe(n,f,s,u,a);let l=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);return l.append(t),l.flip(),"#"+l.readVString()},te,it=()=>{if(te===void 0){let n;te=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=rt(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=nt(e,r);}finally{te=n==="#memo\u7231";}}if(te===false)throw new Error("This environment does not support encryption.")},st=n=>typeof n=="string"?q.fromString(n):n,pr=n=>typeof n=="string"?S.fromString(n):n,gr={decode:nt,encode:rt};var ot={};mt(ot,{buildWitnessSetProperties:()=>Br,makeBitMaskFilter:()=>Ar,operations:()=>wr,validateUsername:()=>br});var br=n=>{let e="Account name should ";if(!n)return e+"not be empty.";let t=n.length;if(t<3)return e+"be longer.";if(t>16)return e+"be shorter.";/\./.test(n)&&(e="Each account segment should ");let r=n.split("."),i=r.length;for(let s=0;s<i;s++){let a=r[s];if(!/^[a-z]/.test(a))return e+"start with a lowercase letter.";if(!/^[a-z0-9-]*$/.test(a))return e+"have only lowercase letters, digits, or dashes.";if(!/[a-z0-9]$/.test(a))return e+"end with a lowercase letter or digit.";if(a.length<3)return e+"be longer."}return null},wr={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,pow:14,custom:15,report_over_production:16,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,pow2:30,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,custom_binary:35,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49,fill_convert_request:50,author_reward:51,curation_reward:52,comment_reward:53,liquidity_reward:54,interest:55,fill_vesting_withdraw:56,fill_order:57,shutdown_witness:58,fill_transfer_from_savings:59,hardfork:60,comment_payout_update:61,return_vesting_delegation:62,comment_benefactor_reward:63,producer_reward:64,clear_null_account_balance:65,proposal_pay:66,sps_fund:67,hardfork_hive:68,hardfork_hive_restore:69,delayed_voting:70,consolidate_treasury_balance:71,effective_comment_vote:72,ineffective_delete_comment:73,sps_convert:74,expired_account_notification:75,changed_recovery_account:76,transfer_to_vesting_completed:77,pow_reward:78,vesting_shares_split:79,account_created:80,fill_collateralized_convert_request:81,system_warning:82,fill_recurrent_transfer:83,failed_recurrent_transfer:84,limit_order_cancelled:85,producer_missed:86,proposal_fee:87,collateralized_convert_immediate_conversion:88,escrow_approved:89,escrow_rejected:90,proxy_cleared:91,declined_voting_rights:92},Ar=n=>n.reduce(vr,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),vr=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Br=(n,e)=>{let t={extensions:[],owner:n,props:[]};for(let r of Object.keys(e)){if(e[r]===void 0)continue;let i;switch(r){case "key":case "new_signing_key":i=L.PublicKey;break;case "account_subsidy_budget":case "account_subsidy_decay":case "maximum_block_size":i=L.UInt32;break;case "hbd_interest_rate":i=L.UInt16;break;case "url":i=L.String;break;case "hbd_exchange_rate":i=L.Price;break;case "account_creation_fee":i=L.Asset;break;default:throw new Error(`Unknown witness prop: ${r}`)}t.props.push([r,xr(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},xr=(n,e)=>{let t=new b(b.DEFAULT_CAPACITY,b.LITTLE_ENDIAN);return n(t,e),t.flip(),bytesToHex(new Uint8Array(t.toBuffer()))};/**
1
+ import {hexToBytes,bytesToHex}from'@noble/hashes/utils.js';import {ripemd160}from'@noble/hashes/legacy.js';import Ke from'bs58';import {secp256k1}from'@noble/curves/secp256k1.js';import {sha256,sha512}from'@noble/hashes/sha2.js';import {cbc}from'@noble/ciphers/aes.js';var Re=Object.defineProperty;var xt=(n,e,t)=>e in n?Re(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var St=(n,e)=>{for(var t in e)Re(n,t,{get:e[t],enumerable:true});};var _=(n,e,t)=>xt(n,typeof e!="symbol"?e+"":e,t);var oe=new ArrayBuffer(0),ae=null,ce=null;function Ut(){return ae||(typeof TextEncoder<"u"?ae=new TextEncoder:ae={encode(n){let e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<128)e.push(r);else if(r<2048)e.push(192|r>>6,128|r&63);else if(r>=55296&&r<=56319&&t+1<n.length){let i=n.charCodeAt(++t);r=65536+((r&1023)<<10)+(i&1023),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63);}else e.push(224|r>>12,128|r>>6&63,128|r&63);}return new Uint8Array(e)}}),ae}function De(){return ce||(typeof TextDecoder<"u"?ce=new TextDecoder:ce={decode(n){let e=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength),t="";for(let r=0;r<e.length;){let i=e[r],s;i<128?(s=i,r+=1):(i&224)===192?(s=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(s=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(s=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10),56320+(s&1023)));}return t}}),ce}var B=class B{constructor(e=B.DEFAULT_CAPACITY,t=B.DEFAULT_ENDIAN){_(this,"buffer");_(this,"view");_(this,"offset");_(this,"markedOffset");_(this,"limit");_(this,"littleEndian");_(this,"readUInt32",this.readUint32);this.buffer=e===0?oe:new ArrayBuffer(e),this.view=e===0?new DataView(oe):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new B(e,t)}static concat(e,t){let r=0;for(let c=0;c<e.length;++c){let u=e[c];if(u instanceof B)r+=u.limit-u.offset;else if(u instanceof Uint8Array)r+=u.length;else if(u instanceof ArrayBuffer)r+=u.byteLength;else if(Array.isArray(u))r+=u.length;else throw TypeError("Illegal buffer")}if(r===0)return new B(0,t);let i=new B(r,t),s=new Uint8Array(i.buffer),a=0;for(let c=0;c<e.length;++c){let u=e[c];u instanceof B?(s.set(new Uint8Array(u.buffer,u.offset,u.limit-u.offset),a),a+=u.limit-u.offset):u instanceof Uint8Array?(s.set(u,a),a+=u.length):u instanceof ArrayBuffer?(s.set(new Uint8Array(u),a),a+=u.byteLength):(s.set(u,a),a+=u.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof B){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new B(0,t),e.length>0&&(r.buffer=e.buffer,r.offset=e.byteOffset,r.limit=e.byteOffset+e.byteLength,r.view=new DataView(e.buffer));else if(e instanceof ArrayBuffer)r=new B(0,t),e.byteLength>0&&(r.buffer=e,r.offset=0,r.limit=e.byteLength,r.view=e.byteLength>0?new DataView(e):new DataView(oe));else if(Array.isArray(e))r=new B(e.length,t),r.limit=e.length,new Uint8Array(r.buffer).set(e);else throw TypeError("Illegal buffer");return r}writeBytes(e,t){return this.append(e,t)}writeInt8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setInt8(t,e),r&&(this.offset+=1),this}writeByte(e,t){return this.writeInt8(e,t)}writeUint8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setUint8(t,e),r&&(this.offset+=1),this}writeUInt8(e,t){return this.writeUint8(e,t)}readUint8(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint8(e);return t&&(this.offset+=1),r}readUInt8(e){return this.readUint8(e)}writeInt16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setInt16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeShort(e,t){return this.writeInt16(e,t)}writeUint16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setUint16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeUInt16(e,t){return this.writeUint16(e,t)}writeInt32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setInt32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeInt(e,t){return this.writeInt32(e,t)}writeUint32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setUint32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeUInt32(e,t){return this.writeUint32(e,t)}readUint32(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint32(e,this.littleEndian);return t&&(this.offset+=4),r}append(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i;return e instanceof B?(i=new Uint8Array(e.buffer,e.offset,e.limit-e.offset),e.offset+=i.length):e instanceof Uint8Array?i=e:e instanceof ArrayBuffer?i=new Uint8Array(e):i=new Uint8Array(e),i.length<=0?this:(t+i.length>this.buffer.byteLength&&this.resize(t+i.length),new Uint8Array(this.buffer).set(i,t),r&&(this.offset+=i.length),this)}clone(e){let t=new B(0,this.littleEndian);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(t.buffer).set(new Uint8Array(this.buffer)),t.view=new DataView(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t}copy(e,t){if(e===void 0&&(e=this.offset),t===void 0&&(t=this.limit),e===t)return new B(0,this.littleEndian);let r=t-e,i=new B(r,this.littleEndian);return i.offset=0,i.limit=r,new Uint8Array(i.buffer).set(new Uint8Array(this.buffer).subarray(e,t),0),i}copyTo(e,t,r,i){let s=typeof t>"u",a=typeof r>"u";t=s?e.offset:t,r=a?this.offset:r,i=i===void 0?this.limit:i;let c=i-r;return c===0?e:(e.ensureCapacity(t+c),new Uint8Array(e.buffer).set(new Uint8Array(this.buffer).subarray(r,i),t),a&&(this.offset+=c),s&&(e.offset+=c),this)}ensureCapacity(e){let t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this}flip(){return this.limit=this.offset,this.offset=0,this}resize(e){if(this.buffer.byteLength<e){let t=new ArrayBuffer(e);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t);}return this}skip(e){return this.offset+=e,this}writeInt64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigInt64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeLong(e,t){return this.writeInt64(e,t)}readInt64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigInt64(e,this.littleEndian);return t&&(this.offset+=8),r}readLong(e){return this.readInt64(e)}writeUint64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigUint64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeUInt64(e,t){return this.writeUint64(e,t)}readUint64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigUint64(e,this.littleEndian);return t&&(this.offset+=8),r}readUInt64(e){return this.readUint64(e)}toBuffer(e){let t=this.offset,r=this.limit;return !e&&t===0&&r===this.buffer.byteLength?this.buffer:t===r?oe:this.buffer.slice(t,r)}toArrayBuffer(e){return this.toBuffer(e)}writeVarint32(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=this.calculateVarint32(e);for(t+i>this.buffer.byteLength&&this.resize(t+i),e>>>=0;e>=128;)this.view.setUint8(t++,e&127|128),e>>>=7;return this.view.setUint8(t++,e),r?(this.offset=t,this):i}readVarint32(e){let t=typeof e>"u";typeof e>"u"&&(e=this.offset);let r=0,i=0,s;do s=this.view.getUint8(e++),r<5&&(i|=(s&127)<<7*r),++r;while((s&128)!==0);return i|=0,t?(this.offset=e,i):{value:i,length:r}}calculateVarint32(e){return e=e>>>0,e<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5}writeVString(e,t){let r=typeof t>"u",i=r?this.offset:t,s=Ut().encode(e),a=s.length,c=this.calculateVarint32(a);return i+c+a>this.buffer.byteLength&&this.resize(i+c+a),this.writeVarint32(a,i),i+=c,new Uint8Array(this.buffer).set(s,i),i+=a,r?(this.offset=i,this):i-(t||0)}readVString(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=e,i=this.readVarint32(e),s=i.value,a=i.length;e+=a;let c=De().decode(new Uint8Array(this.buffer,e,s));return e+=s,t?(this.offset=e,c):{string:c,length:e-r}}readUTF8String(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=De().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};_(B,"LITTLE_ENDIAN",true),_(B,"BIG_ENDIAN",false),_(B,"DEFAULT_CAPACITY",16),_(B,"DEFAULT_ENDIAN",B.BIG_ENDIAN);var w=B;var f={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","https://techcoderx.com","https://api.syncad.com","https://rpc.mahdiyari.info"],restNodes:["https://api.hive.blog","https://rpc.mahdiyari.info","https://api.syncad.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],restNodesByApi:{hivesense:["https://api.hive.blog","https://api.syncad.com"]},userAgent:"ecency-sdk",chain_id:"beeab0de00000000000000000000000000000000000000000000000000000000",address_prefix:"STM",timeout:5e3,broadcastTimeout:15e3,retry:5,resilience:{adaptiveTimeout:true,adaptiveTimeoutFloorMs:2e3,adaptiveTimeoutFactor:4,hedge:false,hedgeDelayFloorMs:750,hedgeDelayFactor:2,hedgeBucketCapacity:10,hedgeRefillPerSuccess:.1,totalBudgetFactor:2}},we=n=>Array.isArray(n)?[...new Set(n.filter(e=>typeof e=="string").map(e=>e.trim().replace(/\/+$/,"")).filter(e=>e.length>0&&/^https?:\/\/.+/.test(e)))]:[],Tt=n=>{let e=we(n);e.length&&(f.nodes=e);},Et=n=>{let e=we(n);e.length&&(f.restNodes=e);},kt=n=>{if(!n||typeof n!="object")return;let e={...f.restNodesByApi};for(let[t,r]of Object.entries(n)){let i=we(r);i.length?e[t]=i:delete e[t];}f.restNodesByApi=e;},Pt=n=>{if(typeof n!="string")return;let e=n.trim();!e||/[\u0000-\u001f\u007f]/.test(e)||(f.userAgent=e);},It=n=>{if(!n||typeof n!="object")return;let e=f.resilience,t=i=>typeof i=="boolean",r=i=>typeof i=="number"&&Number.isFinite(i)&&i>0;t(n.adaptiveTimeout)&&(e.adaptiveTimeout=n.adaptiveTimeout),r(n.adaptiveTimeoutFloorMs)&&(e.adaptiveTimeoutFloorMs=Math.max(n.adaptiveTimeoutFloorMs,2e3)),r(n.adaptiveTimeoutFactor)&&(e.adaptiveTimeoutFactor=n.adaptiveTimeoutFactor),t(n.hedge)&&(e.hedge=n.hedge),r(n.hedgeDelayFloorMs)&&(e.hedgeDelayFloorMs=n.hedgeDelayFloorMs),r(n.hedgeDelayFactor)&&(e.hedgeDelayFactor=n.hedgeDelayFactor),r(n.hedgeBucketCapacity)&&(e.hedgeBucketCapacity=n.hedgeBucketCapacity),r(n.hedgeRefillPerSuccess)&&(e.hedgeRefillPerSuccess=Math.min(n.hedgeRefillPerSuccess,1)),r(n.totalBudgetFactor)&&(e.totalBudgetFactor=Math.max(n.totalBudgetFactor,1));};var Y=class n{constructor(e,t,r){_(this,"data");_(this,"recovery");_(this,"compressed");this.data=e,this.recovery=t,this.compressed=r??true;}static from(e){if(typeof e=="string"){let t=hexToBytes(e),r=parseInt(bytesToHex(t.subarray(0,1)),16)-31,i=true;r<0&&(i=false,r=r+4);let s=t.subarray(1);return new n(s,r,i)}else throw new Error("Expected string for data")}toBuffer(){let e=new Uint8Array(65).fill(0);return this.compressed?e[0]=this.recovery+31&255:e[0]=this.recovery+27&255,e.set(this.data,1),e}customToString(){return bytesToHex(this.toBuffer())}toString(){return this.customToString()}getPublicKey(e){if(e instanceof Uint8Array&&e.length!==32||typeof e=="string"&&e.length!==64)throw new Error("Expected a valid sha256 hash as message");typeof e=="string"&&(e=hexToBytes(e));let t=secp256k1.Signature.fromBytes(this.data,"compact"),r=new secp256k1.Signature(t.r,t.s,this.recovery);return new k(r.recoverPublicKey(e).toBytes())}};var k=class n{constructor(e,t){_(this,"key");_(this,"prefix");this.key=e,this.prefix=t??f.address_prefix;}static fromString(e){let t=f.address_prefix;if(typeof e!="string"||e.length<=t.length)throw new Error("Invalid public key");let r=e.slice(0,t.length);if(r!==t)throw new Error(`Public key must start with ${t}`);let i;try{i=Ke.decode(e.slice(t.length));}catch{throw new Error("Invalid public key encoding")}if(i.length!==37)throw new Error("Invalid public key length");let s=i.subarray(0,33),a=i.subarray(33,37),c=ripemd160(s).subarray(0,4);if(!Nt(a,c))throw new Error("Public key checksum mismatch");try{secp256k1.Point.fromBytes(s);}catch{throw new Error("Invalid public key")}return new n(s,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=Y.from(t)),secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return Lt(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},Lt=(n,e)=>{let t=ripemd160(n);return e+Ke.encode(new Uint8Array([...n,...t.subarray(0,4)]))},Nt=(n,e)=>{if(n.byteLength!==e.byteLength)return false;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return false;return true};var ue=class n{constructor(e,t){_(this,"amount");_(this,"symbol");this.amount=e,this.symbol=t==="HIVE"?"STEEM":t==="HBD"?"SBD":t;}static fromString(e,t=null){let[r,i]=e.split(" ");if(["STEEM","VESTS","SBD","TESTS","TBD","HIVE","HBD"].indexOf(i)===-1)throw new Error(`Invalid asset symbol: ${i}`);if(t&&i!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${i}`);let s=Number.parseFloat(r);if(!Number.isFinite(s))throw new Error(`Invalid asset amount: ${r}`);return new n(s,i)}static from(e,t){if(e instanceof n){if(t&&e.symbol!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${e.symbol}`);return e}else {if(typeof e=="number"&&Number.isFinite(e))return new n(e,t||"STEEM");if(typeof e=="string")return n.fromString(e,t);throw new Error(`Invalid asset '${String(e)}'`)}}getPrecision(){switch(this.symbol){case "TESTS":case "TBD":case "STEEM":case "SBD":case "HBD":case "HIVE":return 3;case "VESTS":return 6;default:return 3}}toString(){return `${this.amount.toFixed(this.getPrecision())} ${this.symbol}`}toJSON(){return this.toString()}};var le=class n{constructor(e){_(this,"buffer");this.buffer=e;}static from(e){return e instanceof n?e:e instanceof Uint8Array?new n(e):typeof e=="string"?new n(hexToBytes(e)):new n(new Uint8Array(e))}toString(){return bytesToHex(this.buffer)}toJSON(){return this.toString()}};var h={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,custom:15,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49},R=()=>{throw new Error("Void can not be serialized")},o=(n,e)=>{n.writeVString(e);},Mt=(n,e)=>{n.writeInt16(e);},Ve=(n,e)=>{n.writeInt64(e);},He=(n,e)=>{n.writeUint8(e);},F=(n,e)=>{n.writeUint16(e);},P=(n,e)=>{n.writeUint32(e);},je=(n,e)=>{n.writeUint64(e);},j=(n,e)=>{n.writeByte(e?1:0);},$e=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},b=(n,e)=>{let t=ue.from(e),r=t.getPrecision();n.writeInt64(Math.round(t.amount*Math.pow(10,r))),n.writeUint8(r);for(let i=0;i<7;i++)n.writeUint8(t.symbol.charCodeAt(i)||0);},$=(n,e)=>{n.writeUint32(Math.floor(new Date(e+"Z").getTime()/1e3));},K=(n,e)=>{e===null||typeof e=="string"&&e.slice(-39)==="1111111111111111111111111111111114T1Anm"?n.append(new Uint8Array(33).fill(0)):n.append(k.from(e).key);},qe=(n=null)=>(e,t)=>{t=le.from(t);let r=t.buffer.length;if(n){if(r!==n)throw new Error(`Unable to serialize binary. Expected ${n} bytes, got ${r}`)}else e.writeVarint32(r);e.append(t.buffer);},Ye=qe(),Ae=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,s]of r)n(t,i),e(t,s);},x=n=>(e,t)=>{e.writeVarint32(t.length);for(let r of t)n(e,r);},C=n=>(e,t)=>{for(let[r,i]of n)try{i(e,t[r]);}catch(s){throw s.message=`${r}: ${s.message}`,s}},W=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},E=C([["weight_threshold",P],["account_auths",Ae(o,F)],["key_auths",Ae(K,F)]]),Ft=C([["account",o],["weight",F]]),ve=C([["base",b],["quote",b]]),Ct=C([["account_creation_fee",b],["maximum_block_size",P],["hbd_interest_rate",F]]),m=(n,e)=>{let t=C(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},d={};d.account_create=m(h.account_create,[["fee",b],["creator",o],["new_account_name",o],["owner",E],["active",E],["posting",E],["memo_key",K],["json_metadata",o]]);d.account_create_with_delegation=m(h.account_create_with_delegation,[["fee",b],["delegation",b],["creator",o],["new_account_name",o],["owner",E],["active",E],["posting",E],["memo_key",K],["json_metadata",o],["extensions",x(R)]]);d.account_update=m(h.account_update,[["account",o],["owner",W(E)],["active",W(E)],["posting",W(E)],["memo_key",K],["json_metadata",o]]);d.account_witness_proxy=m(h.account_witness_proxy,[["account",o],["proxy",o]]);d.account_witness_vote=m(h.account_witness_vote,[["account",o],["witness",o],["approve",j]]);d.cancel_transfer_from_savings=m(h.cancel_transfer_from_savings,[["from",o],["request_id",P]]);d.change_recovery_account=m(h.change_recovery_account,[["account_to_recover",o],["new_recovery_account",o],["extensions",x(R)]]);d.claim_account=m(h.claim_account,[["creator",o],["fee",b],["extensions",x(R)]]);d.claim_reward_balance=m(h.claim_reward_balance,[["account",o],["reward_hive",b],["reward_hbd",b],["reward_vests",b]]);d.comment=m(h.comment,[["parent_author",o],["parent_permlink",o],["author",o],["permlink",o],["title",o],["body",o],["json_metadata",o]]);d.comment_options=m(h.comment_options,[["author",o],["permlink",o],["max_accepted_payout",b],["percent_hbd",F],["allow_votes",j],["allow_curation_rewards",j],["extensions",x($e([C([["beneficiaries",x(Ft)]])]))]]);d.convert=m(h.convert,[["owner",o],["requestid",P],["amount",b]]);d.create_claimed_account=m(h.create_claimed_account,[["creator",o],["new_account_name",o],["owner",E],["active",E],["posting",E],["memo_key",K],["json_metadata",o],["extensions",x(R)]]);d.custom=m(h.custom,[["required_auths",x(o)],["id",F],["data",Ye]]);d.custom_json=m(h.custom_json,[["required_auths",x(o)],["required_posting_auths",x(o)],["id",o],["json",o]]);d.decline_voting_rights=m(h.decline_voting_rights,[["account",o],["decline",j]]);d.delegate_vesting_shares=m(h.delegate_vesting_shares,[["delegator",o],["delegatee",o],["vesting_shares",b]]);d.delete_comment=m(h.delete_comment,[["author",o],["permlink",o]]);d.escrow_approve=m(h.escrow_approve,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",P],["approve",j]]);d.escrow_dispute=m(h.escrow_dispute,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",P]]);d.escrow_release=m(h.escrow_release,[["from",o],["to",o],["agent",o],["who",o],["receiver",o],["escrow_id",P],["hbd_amount",b],["hive_amount",b]]);d.escrow_transfer=m(h.escrow_transfer,[["from",o],["to",o],["hbd_amount",b],["hive_amount",b],["escrow_id",P],["agent",o],["fee",b],["json_meta",o],["ratification_deadline",$],["escrow_expiration",$]]);d.feed_publish=m(h.feed_publish,[["publisher",o],["exchange_rate",ve]]);d.limit_order_cancel=m(h.limit_order_cancel,[["owner",o],["orderid",P]]);d.limit_order_create=m(h.limit_order_create,[["owner",o],["orderid",P],["amount_to_sell",b],["min_to_receive",b],["fill_or_kill",j],["expiration",$]]);d.limit_order_create2=m(h.limit_order_create2,[["owner",o],["orderid",P],["amount_to_sell",b],["exchange_rate",ve],["fill_or_kill",j],["expiration",$]]);d.recover_account=m(h.recover_account,[["account_to_recover",o],["new_owner_authority",E],["recent_owner_authority",E],["extensions",x(R)]]);d.request_account_recovery=m(h.request_account_recovery,[["recovery_account",o],["account_to_recover",o],["new_owner_authority",E],["extensions",x(R)]]);d.reset_account=m(h.reset_account,[["reset_account",o],["account_to_reset",o],["new_owner_authority",E]]);d.set_reset_account=m(h.set_reset_account,[["account",o],["current_reset_account",o],["reset_account",o]]);d.set_withdraw_vesting_route=m(h.set_withdraw_vesting_route,[["from_account",o],["to_account",o],["percent",F],["auto_vest",j]]);d.transfer=m(h.transfer,[["from",o],["to",o],["amount",b],["memo",o]]);d.transfer_from_savings=m(h.transfer_from_savings,[["from",o],["request_id",P],["to",o],["amount",b],["memo",o]]);d.transfer_to_savings=m(h.transfer_to_savings,[["from",o],["to",o],["amount",b],["memo",o]]);d.transfer_to_vesting=m(h.transfer_to_vesting,[["from",o],["to",o],["amount",b]]);d.vote=m(h.vote,[["voter",o],["author",o],["permlink",o],["weight",Mt]]);d.withdraw_vesting=m(h.withdraw_vesting,[["account",o],["vesting_shares",b]]);d.witness_update=m(h.witness_update,[["owner",o],["url",o],["block_signing_key",K],["props",Ct],["fee",b]]);d.witness_set_properties=m(h.witness_set_properties,[["owner",o],["props",Ae(o,Ye)],["extensions",x(R)]]);d.account_update2=m(h.account_update2,[["account",o],["owner",W(E)],["active",W(E)],["posting",W(E)],["memo_key",W(K)],["json_metadata",o],["posting_json_metadata",o],["extensions",x(R)]]);d.create_proposal=m(h.create_proposal,[["creator",o],["receiver",o],["start_date",$],["end_date",$],["daily_pay",b],["subject",o],["permlink",o],["extensions",x(R)]]);d.update_proposal_votes=m(h.update_proposal_votes,[["voter",o],["proposal_ids",x(Ve)],["approve",j],["extensions",x(R)]]);d.remove_proposal=m(h.remove_proposal,[["proposal_owner",o],["proposal_ids",x(Ve)],["extensions",x(R)]]);var Ot=C([["end_date",$]]);d.update_proposal=m(h.update_proposal,[["proposal_id",je],["creator",o],["daily_pay",b],["subject",o],["permlink",o],["extensions",x($e([R,Ot]))]]);d.collateralized_convert=m(h.collateralized_convert,[["owner",o],["requestid",P],["amount",b]]);d.recurrent_transfer=m(h.recurrent_transfer,[["from",o],["to",o],["amount",b],["memo",o],["recurrence",F],["executions",F],["extensions",x(C([["type",He],["value",C([["pair_id",He]])]]))]]);var zt=(n,e)=>{let t=d[e[0]];if(!t)throw new Error(`No serializer for operation: ${e[0]}`);try{t(n,e[1]);}catch(r){throw r.message=`${e[0]}: ${r.message}`,r}},Kt=C([["ref_block_num",F],["ref_block_prefix",P],["expiration",$],["operations",x(zt)],["extensions",x(o)]]),Ht=C([["from",K],["to",K],["nonce",je],["check",P],["encrypted",qe()]]),O={Asset:b,Memo:Ht,Price:ve,PublicKey:K,String:o,Transaction:Kt,UInt16:F,UInt32:P};var Q=n=>new Promise(e=>setTimeout(e,n));var Vt=(()=>{try{return !(typeof navigator<"u"&&navigator.product==="ReactNative")&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null}catch{return false}})();function Je(){return Vt?{"User-Agent":f.userAgent}:{}}var D=class extends Error{constructor(t){super(t.message);_(this,"name","RPCError");_(this,"data");_(this,"code");_(this,"stack");this.code=t.code,"data"in t&&(this.data=t.data);}},J=class extends Error{constructor(t,r,i={}){super(r);_(this,"node");_(this,"rateLimitMs");_(this,"isRateLimit");this.node=t,this.rateLimitMs=i.rateLimitMs??0,this.isRateLimit=i.isRateLimit??false;}};function Ge(n){if(!n)return 0;let e=Number(n);if(Number.isFinite(e))return e>0?e*1e3:0;let t=Date.parse(n);if(Number.isFinite(t)){let r=t-Date.now();return r>0?r:0}return 0}var jt=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"],$t=["Failed to fetch","NetworkError when attempting to fetch","Load failed","fetch failed"];function qt(n){if(!n)return "";let e=[String(n.name||""),String(n.message||""),String(n.code||"")],t=n.cause;for(let r=0;t&&r<5;r++)e.push(String(t.code||""),String(t.message||"")),t=t.cause;return e.join(" ")}function Yt(n){if(!n)return false;if(n instanceof J)return true;if(n instanceof D)return false;let e=qt(n);return !!(jt.some(t=>e.includes(t))||$t.some(t=>e.includes(t))||n instanceof SyntaxError||/Unexpected token|JSON\.parse|Unexpected end of JSON/i.test(e))}function Be(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function Xe(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var Wt=1e4,Jt=6e4,Gt=12e4,Xt=2,Qt=6e4,We=12e4,Zt=30,Z=.3,xe=3,ee=5*6e4,Qe=6e4,Ze=1e3,et=2e3,tt=700,rt=2.5,er=new Set(["hapi.ecency.com","api.ecency.com"]);function tr(n){try{return er.has(new URL(n).hostname)}catch{return false}}var fe=class{constructor(){_(this,"health",new Map);}getOrCreate(e){let t=this.health.get(e);return t||(t={consecutiveFailures:0,lastFailureTime:0,rateLimitedUntil:0,rateLimitStreak:0,lastRateLimitAt:0,apiFailures:new Map,headBlock:0,headBlockUpdatedAt:0,ewmaLatencyMs:void 0,latencySampleCount:0,latencyUpdatedAt:0,lastProbeAt:Date.now(),apiLatency:new Map},this.health.set(e,t)),t}recordSuccess(e,t,r,i){let s=this.getOrCreate(e);s.consecutiveFailures=0,s.rateLimitStreak=0,t&&s.apiFailures.delete(t),typeof r=="number"&&Number.isFinite(r)&&r>=0&&this.recordLatency(s,r,i??t);}recordSlowFailure(e,t,r){!Number.isFinite(t)||t<et||this.recordLatency(this.getOrCreate(e),t,r);}getUsableLatencyMs(e,t){let r=this.health.get(e);if(!r)return;let i=Date.now();if(t!==void 0){let s=r.apiLatency.get(t);return s&&s.sampleCount>=xe&&i-s.updatedAt<=ee?s.ewmaMs:void 0}return this.isLatencyUsable(r,i)?r.ewmaLatencyMs:void 0}recordCensoredLatency(e,t,r){!Number.isFinite(t)||t<50||this.recordLatency(this.getOrCreate(e),t,r);}recordLatency(e,t,r){let i=Date.now();if(e.latencyUpdatedAt>0&&i-e.latencyUpdatedAt>ee&&(e.ewmaLatencyMs=void 0,e.latencySampleCount=0,e.apiLatency.clear()),e.ewmaLatencyMs=e.ewmaLatencyMs===void 0?t:Z*t+(1-Z)*e.ewmaLatencyMs,e.latencySampleCount++,e.latencyUpdatedAt=i,r!==void 0){let s=e.apiLatency.get(r);!s||i-s.updatedAt>ee?e.apiLatency.set(r,{ewmaMs:t,sampleCount:1,updatedAt:i}):(s.ewmaMs=Z*t+(1-Z)*s.ewmaMs,s.sampleCount++,s.updatedAt=i);}}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),s=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(s.cooldownUntil>0&&s.cooldownUntil<=i||s.lastFailureTime>0&&i-s.lastFailureTime>3e4)&&(s.count=0,s.cooldownUntil=0),s.count++,s.lastFailureTime=i,s.count>=Xt&&(s.cooldownUntil=i+Qt),r.apiFailures.set(t,s);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordRateLimit(e,t){let r=this.getOrCreate(e),i=Date.now();r.rateLimitStreak>0&&i-r.lastRateLimitAt>Gt&&(r.rateLimitStreak=0);let s=typeof t=="number"&&Number.isFinite(t)&&t>0,a=s?t:Math.min(Wt*2**r.rateLimitStreak,Jt);s||r.rateLimitStreak++,r.lastRateLimitAt=i,r.rateLimitedUntil=s?i+a:Math.max(r.rateLimitedUntil,i+a),r.consecutiveFailures++,r.lastFailureTime=i;}recordHeadBlock(e,t){if(!t||!Number.isFinite(t))return;let r=this.getOrCreate(e);r.headBlock=t,r.headBlockUpdatedAt=Date.now();}consensusHeadBlock(){let e=Date.now(),t=[];for(let r of this.health.values())r.headBlock>0&&e-r.headBlockUpdatedAt<=We&&t.push(r.headBlock);return t.length<2?0:(t.sort((r,i)=>r-i),t[Math.floor((t.length-1)/2)])}isNodeHealthy(e,t){let r=this.health.get(e);if(!r)return true;let i=Date.now();if(r.rateLimitedUntil>i||r.consecutiveFailures>=3&&i-r.lastFailureTime<3e4)return false;if(t){let a=r.apiFailures.get(t);if(a&&a.cooldownUntil>i)return false}let s=this.consensusHeadBlock();return !(s>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=We&&s-r.headBlock>Zt)}getOrderedNodes(e,t){let r=[],i=[];for(let l of e)this.isNodeHealthy(l,t)?r.push(l):i.push(l);if(r.length<=1)return [...r,...i];let s=Date.now(),a=this.fastestUsableLatency(r,s),c=r.map((l,y)=>({node:l,i:y,score:this.scoreNode(l,a,s)})).sort((l,y)=>l.score-y.score||l.i-y.i).map(l=>l.node),u=this.pickReprobeCandidate(r,s);return u&&c[0]!==u?[u,...c.filter(l=>l!==u),...i]:[...c,...i]}isLatencyUsable(e,t){return !!e&&e.ewmaLatencyMs!==void 0&&e.latencySampleCount>=xe&&t-e.latencyUpdatedAt<=ee}fastestUsableLatency(e,t){let r=1/0;for(let i of e){let s=this.health.get(i);this.isLatencyUsable(s,t)&&(r=Math.min(r,s.ewmaLatencyMs));}return r}scoreNode(e,t,r){let i=this.health.get(e);if(!this.isLatencyUsable(i,r))return Ze;let s=i.ewmaLatencyMs;return tr(e)?t>0&&t!==1/0&&s>rt*t?s:Math.max(s-tt,0):s}pickReprobeCandidate(e,t){let r=t-Qe,i,s=1/0;for(let a of e){let c=this.getOrCreate(a),u=Math.max(c.latencyUpdatedAt,c.lastProbeAt);u<=r&&u<s&&(i=a,s=u);}return i&&(this.getOrCreate(i).lastProbeAt=t),i}},T=new fe,q=new fe,Se=class{constructor(){_(this,"tokens",f.resilience.hedgeBucketCapacity);}trySpend(){return this.clamp(),this.tokens>=1-1e-9?(this.tokens-=1,true):false}refill(){this.clamp(),this.tokens=Math.min(f.resilience.hedgeBucketCapacity,this.tokens+f.resilience.hedgeRefillPerSuccess);}clamp(){this.tokens>f.resilience.hedgeBucketCapacity&&(this.tokens=f.resilience.hedgeBucketCapacity);}get available(){return this.tokens}reset(e=f.resilience.hedgeBucketCapacity){this.tokens=e;}},Ue=new Se;function de(n,e,t,r,i){let s=f.resilience;if(!s.adaptiveTimeout||i)return r;let a=n.getUsableLatencyMs(e,t);return a===void 0?r:Math.ceil(Math.min(r,Math.max(s.adaptiveTimeoutFloorMs,s.adaptiveTimeoutFactor*a)))}function Ee(n,e,t,r){t instanceof J?t.isRateLimit?n.recordRateLimit(e,t.rateLimitMs||void 0):n.recordFailure(e,r):t instanceof D?n.recordFailure(e,r):n.recordFailure(e);}function nt(n,e,t,r){if(!r||typeof r!="object"||!t.includes("get_dynamic_global_properties"))return;let i=r.head_block_number;typeof i=="number"&&n.recordHeadBlock(e,i);}function rr(){if(typeof DOMException<"u")return new DOMException("The operation was aborted due to timeout","TimeoutError");let n=new Error("The operation was aborted due to timeout");return n.name="TimeoutError",n}function it(n){if(n=Math.ceil(n),typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(rr()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function ke(n,e){if(!e)return {signal:n,cleanup:()=>{}};if(typeof AbortSignal.any=="function")return {signal:AbortSignal.any([n,e]),cleanup:()=>{}};let t=new AbortController;if(n.aborted)return t.abort(n.reason),{signal:t.signal,cleanup:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,cleanup:()=>{}};let r=()=>t.abort(n.reason),i=()=>t.abort(e.reason);n.addEventListener("abort",r,{once:true}),e.addEventListener("abort",i,{once:true});let s=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:s}}var te=async(n,e,t,r=f.timeout,i=false,s)=>{let a=Math.floor(Math.random()*1e8),c={jsonrpc:"2.0",method:e,params:t,id:a},{signal:u,cleanup:l}=it(r),{signal:y,cleanup:S}=ke(u,s),U=()=>{l(),S();};try{let g=await fetch(n,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json",...Je()},signal:y});if(g.status===429)throw new J(n,"HTTP 429 Rate Limited",{rateLimitMs:Ge(g.headers.get("Retry-After")),isRateLimit:!0});if(g.status>=500&&g.status<600)throw new J(n,`HTTP ${g.status} from ${n}`);let v=await g.json();if(!v||typeof v.id>"u"||v.id!==a||v.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in v)return v.result;if("error"in v){let N=v.error;throw "message"in N&&"code"in N?new D(N):v.error}throw v}catch(g){if(g instanceof D||g instanceof J||s?.aborted)throw g;if(i)return te(n,e,t,r,false,s);throw g}finally{U();}};function Te(){return Q(50+Math.random()*50)}function nr(n){let{method:e,params:t,api:r,primary:i,hedgePool:s,callerTimeout:a,explicitTimeout:c,deadlineAt:u,externalSignal:l,onHedgeFired:y}=n;return new Promise((S,U)=>{let g=false,v=0,N=false,p=false,ie,z,G=0,X=[],H=I=>{if(!g){g=true,z!==void 0&&(clearTimeout(z),z=void 0);for(let L of X)L.signal.aborted||L.abort();I();}},se=(I,L)=>{v++;let A=new AbortController;X.push(A);let V=ke(A.signal,l),_e=de(T,I,e,a,c),be=Date.now();L||(G=be),te(I,e,t,_e,false,V.signal).then(M=>{V.cleanup(),v--,L||(p=true),!g&&(T.recordSuccess(I,r,Date.now()-be,e),nt(T,I,e,M),L?p||T.recordCensoredLatency(i,Date.now()-G,e):N||Ue.refill(),H(()=>S(M)));}).catch(M=>{if(V.cleanup(),v--,L||(p=true),!g){if(l?.aborted){H(()=>U(M));return}if(M instanceof D&&!Be(M.code,M.message)){H(()=>U(M));return}if(Ee(T,I,M,r),T.recordSlowFailure(I,Date.now()-be,e),ie=M,!L&&!N){H(()=>U(M));return}v===0&&H(()=>U(ie));}});};se(i,false);let ye=T.getUsableLatencyMs(i,e)??0,pe=de(T,i,e,a,c),ge=Math.min(Math.max(f.resilience.hedgeDelayFloorMs,f.resilience.hedgeDelayFactor*ye),.8*pe);z=setTimeout(()=>{if(z=void 0,g||l?.aborted||Date.now()>=u)return;let I=s.filter(A=>T.isNodeHealthy(A,r));if(I.length===0)return;let L=I[Math.floor(Math.random()*I.length)];Ue.trySpend()&&(N=true,y(L),se(L,true));},ge);})}var he=async(n,e=[],t,r=f.retry,i)=>{if(!Array.isArray(f.nodes))throw new Error("config.nodes is not an array");if(f.nodes.length===0)throw new Error("config.nodes is empty");let s=t!==void 0,a=t??f.timeout,c=Xe(n),u=Date.now()+f.resilience.totalBudgetFactor*a,l=new Set,y;for(let S=0;S<=r&&!(S>0&&Date.now()>=u);S++){let U=T.getOrderedNodes(f.nodes,c),g=U.find(p=>!l.has(p));g||(l.clear(),g=U[0]),l.add(g);let v=[];if(f.resilience.hedge&&T.getUsableLatencyMs(g,n)!==void 0&&(v=U.filter(p=>!l.has(p)&&T.isNodeHealthy(p,c)).slice(0,3)),v.length>0)try{return await nr({method:n,params:e,api:c,primary:g,hedgePool:v,callerTimeout:a,explicitTimeout:s,deadlineAt:u,externalSignal:i,onHedgeFired:p=>l.add(p)})}catch(p){if(p instanceof D&&!Be(p.code,p.message)||i?.aborted)throw p;y=p,S<r&&await Te();continue}let N=Date.now();try{let p=await te(g,n,e,de(T,g,n,a,s),!1,i);return T.recordSuccess(g,c,Date.now()-N,n),Ue.refill(),nt(T,g,n,p),p}catch(p){if(p instanceof D&&!Be(p.code,p.message)||i?.aborted)throw p;Ee(T,g,p,c),T.recordSlowFailure(g,Date.now()-N,n),y=p,S<r&&await Te();}}throw y},Pe=async(n,e=[],t=f.broadcastTimeout,r)=>{if(!Array.isArray(f.nodes))throw new Error("config.nodes is not an array");if(f.nodes.length===0)throw new Error("config.nodes is empty");let i=Xe(n),s=new Set,a;for(let c=0;c<f.nodes.length;c++){let l=T.getOrderedNodes(f.nodes,i).find(y=>!s.has(y));if(!l)break;if(s.add(l),r?.aborted)throw new Error("Aborted");try{let y=await te(l,n,e,t,!1,r);return T.recordSuccess(l,i),y}catch(y){if(y instanceof D||r?.aborted||(Ee(T,l,y,i),a=y,!Yt(y)))throw y}}throw a},ir={balance:"/balance-api",hafah:"/hafah-api",hafbe:"/hafbe-api",hivemind:"/hivemind-api",hivesense:"/hivesense-api",reputation:"/reputation-api","nft-tracker":"/nft-tracker-api",hafsql:"/hafsql",status:"/status-api"};async function sr(n,e,t,r,i=f.retry,s){if(!Array.isArray(f.restNodes))throw new Error("config.restNodes is not an array");if(f.restNodes.length===0)throw new Error("config.restNodes is empty");let a=r!==void 0,c=r??f.timeout,u=Date.now()+f.resilience.totalBudgetFactor*c,l=`${n}:${e}`,y=f.restNodesByApi?.[n]?.length?f.restNodesByApi[n]:f.restNodes,S=new Set,U,g=false;for(let v=0;v<=i&&!(v>0&&Date.now()>=u);v++){let N=q.getOrderedNodes(y,n),p=N.find(A=>!S.has(A));p||(S.clear(),p=N[0]),S.add(p);let ie=p+ir[n],z=e,G=t||{},X=new Set;Object.entries(G).forEach(([A,V])=>{z.includes(`{${A}}`)&&(z=z.replace(`{${A}}`,encodeURIComponent(String(V))),X.add(A));});let H=new URL(ie+z);if(Object.entries(G).forEach(([A,V])=>{X.has(A)||(Array.isArray(V)?V.forEach(_e=>H.searchParams.append(A,String(_e))):H.searchParams.set(A,String(V)));}),s?.aborted)throw new Error("Aborted");g=false;let{signal:se,cleanup:ye}=it(de(q,p,l,c,a)),{signal:pe,cleanup:ge}=ke(se,s),I=()=>{ye(),ge();},L=Date.now();try{let A=await fetch(H.toString(),{signal:pe,headers:Je()});if(A.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(A.status===429)throw q.recordRateLimit(p,Ge(A.headers.get("Retry-After"))||void 0),g=!0,new Error(`HTTP 429 Rate Limited by ${p}`);if(A.status===503)throw q.recordFailure(p,n),g=!0,new Error(`HTTP 503 Service Unavailable from ${p}`);if(!A.ok)throw q.recordFailure(p,n),g=!0,new Error(`HTTP ${A.status} from ${p}`);return q.recordSuccess(p,n,Date.now()-L,l),A.json()}catch(A){if(A?.message?.includes("HTTP 404")||s?.aborted)throw A;g||q.recordFailure(p,n),q.recordSlowFailure(p,Date.now()-L,l),U=A,v<i&&await Te();}finally{I();}}throw U}var or=async(n,e=[],t=2,r)=>{if(!Array.isArray(f.nodes))throw new Error("config.nodes is not an Array");if(t>f.nodes.length)throw new Error("quorum > config.nodes.length");let s=(u=>{let l=[...u];for(let y=l.length-1;y>0;y--){let S=Math.floor(Math.random()*(y+1));[l[y],l[S]]=[l[S],l[y]];}return l})(f.nodes),a=Math.min(t,s.length),c=[];for(;a>0&&s.length>0;){let u=s.splice(0,a),l=[],y=[];for(let U=0;U<u.length;U++)l.push(te(u[U],n,e,void 0,true,r).then(g=>y.push(g)).catch(()=>{}));await Promise.all(l),c.push(...y);let S=ar(c,t);if(S)return S;if(a=Math.min(t,s.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function ar(n,e){let t=new Map;for(let i of n){let s=JSON.stringify(i);t.has(s)||t.set(s,[]),t.get(s).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var ur=hexToBytes(f.chain_id),Ie=class n{constructor(e){_(this,"transaction");_(this,"expiration",6e4);_(this,"txId");_(this,"createTransaction",async e=>{let t=await he("condenser_api.get_dynamic_global_properties",[]),r=hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),s=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:s,extensions:[],operations:[],ref_block_num:t.head_block_number&65535,ref_block_prefix:i,signatures:[]};});e?.transaction&&(e.transaction instanceof n?(this.transaction=e.transaction.transaction,this.expiration=e.transaction.expiration):this.transaction=e.transaction,this.transaction&&!Array.isArray(this.transaction.signatures)&&(this.transaction.signatures=[]),this.txId=this.digest().txId),e?.expiration&&(this.expiration=e.expiration);}async addOperation(e,t){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([e,t]);}sign(e){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");if(this.transaction){let{digest:t,txId:r}=this.digest();Array.isArray(e)||(e=[e]);for(let i of e){let s=i.sign(t);this.transaction.signatures.push(s.customToString());}return this.txId=r,this.transaction}else throw new Error("No transaction to sign")}async broadcast(e=false){if(!this.transaction)throw new Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(this.transaction.signatures.length===0)throw new Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await Pe("condenser_api.broadcast_transaction",[this.transaction]);}catch(s){if(!(s instanceof D&&s.message.includes("Duplicate transaction check failed")))throw s}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await Q(1e3);let r=await this.checkStatus(),i=1;for(;r?.status!=="within_irreversible_block"&&r?.status!=="expired_irreversible"&&r?.status!=="too_old"&&i<t;)await Q(1e3+i*300),r=await this.checkStatus(),i++;return {tx_id:this.txId,status:r?.status??"unknown"}}digest(){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");let e=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN),t={...this.transaction};try{O.Transaction(e,t);}catch(a){throw new Error("Unable to serialize transaction: "+a)}e.flip();let r=new Uint8Array(e.toBuffer()),i=bytesToHex(sha256(r)).slice(0,40);return {digest:sha256(new Uint8Array([...ur,...r])),txId:i}}addSignature(e){if(!this.transaction)throw new Error("First create a transaction by .create(operations)");if(typeof e!="string")throw new Error("Signature must be string");if(e.length!==130)throw new Error("Signature must be 130 characters long");return this.transaction.signatures.push(e),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),he("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}};var lt=new Uint8Array([128]),ne=class n{constructor(e){_(this,"key");this.key=e;try{secp256k1.getPublicKey(e);}catch{throw new Error("invalid private key")}}static from(e){return typeof e=="string"?n.fromString(e):new n(e)}static fromString(e){return new n(hr(e).subarray(1))}static fromSeed(e){if(typeof e=="string")if(/^[0-9a-fA-F]+$/.test(e))e=hexToBytes(e);else {let r=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s<128)r.push(s);else if(s<2048)r.push(192|s>>6,128|s&63);else if(s>=55296&&s<=56319&&i+1<e.length){let a=e.charCodeAt(++i);s=65536+((s&1023)<<10)+(a&1023),r.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63);}else r.push(224|s>>12,128|s>>6&63,128|s&63);}e=new Uint8Array(r);}return new n(sha256(e))}static fromLogin(e,t,r="active"){let i=e+r+t;return n.fromSeed(i)}sign(e){let t=secp256k1.sign(e,this.key,{extraEntropy:true,format:"recovered",prehash:false}),r=parseInt(bytesToHex(t.subarray(0,1)),16);return Y.from((r+31).toString(16)+bytesToHex(t.subarray(1)))}createPublic(e){return new k(secp256k1.getPublicKey(this.key),e)}toString(){return dr(new Uint8Array([...lt,...this.key]))}inspect(){let e=this.toString();return `PrivateKey: ${e.slice(0,6)}...${e.slice(-6)}`}getSharedSecret(e){let t=secp256k1.getSharedSecret(this.key,e.key);return sha512(t.subarray(1))}static randomKey(){return new n(secp256k1.keygen().secretKey)}},ft=n=>sha256(sha256(n)),dr=n=>{let e=ft(n);return Ke.encode(new Uint8Array([...n,...e.slice(0,4)]))},hr=n=>{let e=Ke.decode(n);if(!ct(e.slice(0,1),lt))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=ft(r).slice(0,4);if(!ct(t,i))throw new Error("Private key checksum mismatch");return r},ct=(n,e)=>{if(n===e)return true;if(n.byteLength!==e.byteLength)return false;let t=n.byteLength,r=0;for(;r<t&&n[r]===e[r];)r++;return r===t};var ht=(n,e,t,r=br())=>yt(n,e,r,t),mt=(n,e,t,r,i)=>yt(n,e,t,r,i).message,yt=(n,e,t,r,i)=>{let s=t,a=n.getSharedSecret(e),c=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);c.writeUint64(s),c.append(a),c.flip();let u=sha512(new Uint8Array(c.toBuffer())),l=u.subarray(32,48),y=u.subarray(0,32),S=sha256(u).subarray(0,4),U=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);U.append(S),U.flip();let g=U.readUint32();if(i!==void 0){if(g!==i)throw new Error("Invalid key");r=gr(r,y,l);}else r=_r(r,y,l);return {nonce:s,message:r,checksum:g}},gr=(n,e,t)=>{let r=n;return r=cbc(e,t).decrypt(r),r},_r=(n,e,t)=>{let r=n;return r=cbc(e,t).encrypt(r),r},Ne=null,br=()=>{if(Ne===null){let t=secp256k1.utils.randomSecretKey();Ne=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++Ne%65536;return n=n<<BigInt(16)|BigInt(e),n};var pt=n=>{let e=Sr(n,33);return new k(e)},Ar=n=>n.readUint64(),vr=n=>n.readUint32(),Br=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},xr=n=>e=>{let t={},r=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,s]of n)try{t[i]=s(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function Sr(n,e){if(n){let t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())}else throw Error("No buffer found on first parameter")}var Ur=xr([["from",pt],["to",pt],["nonce",Ar],["check",vr],["encrypted",Br]]),gt={Memo:Ur};var bt=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),At(),n=vt(n),e=Tr(e);let i=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);i.writeVString(t);let s=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:c,checksum:u}=ht(n,e,s,r),l=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);O.Memo(l,{check:u,encrypted:c,from:n.createPublic(),nonce:a,to:e}),l.flip();let y=new Uint8Array(l.toBuffer());return "#"+Ke.encode(y)},wt=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),At(),n=vt(n);let t=gt.Memo(Ke.decode(e)),{from:r,to:i,nonce:s,check:a,encrypted:c}=t,l=n.createPublic().toString()===new k(r.key).toString()?new k(i.key):new k(r.key);t=mt(n,l,s,c,a);let y=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);return y.append(t),y.flip(),"#"+y.readVString()},me,At=()=>{if(me===void 0){let n;me=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=bt(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=wt(e,r);}finally{me=n==="#memo\u7231";}}if(me===false)throw new Error("This environment does not support encryption.")},vt=n=>typeof n=="string"?ne.fromString(n):n,Tr=n=>typeof n=="string"?k.fromString(n):n,Er={decode:wt,encode:bt};var Bt={};St(Bt,{buildWitnessSetProperties:()=>Rr,makeBitMaskFilter:()=>Lr,operations:()=>Ir,validateUsername:()=>Pr});var Pr=n=>{let e="Account name should ";if(!n)return e+"not be empty.";let t=n.length;if(t<3)return e+"be longer.";if(t>16)return e+"be shorter.";/\./.test(n)&&(e="Each account segment should ");let r=n.split("."),i=r.length;for(let s=0;s<i;s++){let a=r[s];if(!/^[a-z]/.test(a))return e+"start with a lowercase letter.";if(!/^[a-z0-9-]*$/.test(a))return e+"have only lowercase letters, digits, or dashes.";if(!/[a-z0-9]$/.test(a))return e+"end with a lowercase letter or digit.";if(a.length<3)return e+"be longer."}return null},Ir={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,pow:14,custom:15,report_over_production:16,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,pow2:30,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,custom_binary:35,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49,fill_convert_request:50,author_reward:51,curation_reward:52,comment_reward:53,liquidity_reward:54,interest:55,fill_vesting_withdraw:56,fill_order:57,shutdown_witness:58,fill_transfer_from_savings:59,hardfork:60,comment_payout_update:61,return_vesting_delegation:62,comment_benefactor_reward:63,producer_reward:64,clear_null_account_balance:65,proposal_pay:66,sps_fund:67,hardfork_hive:68,hardfork_hive_restore:69,delayed_voting:70,consolidate_treasury_balance:71,effective_comment_vote:72,ineffective_delete_comment:73,sps_convert:74,expired_account_notification:75,changed_recovery_account:76,transfer_to_vesting_completed:77,pow_reward:78,vesting_shares_split:79,account_created:80,fill_collateralized_convert_request:81,system_warning:82,fill_recurrent_transfer:83,failed_recurrent_transfer:84,limit_order_cancelled:85,producer_missed:86,proposal_fee:87,collateralized_convert_immediate_conversion:88,escrow_approved:89,escrow_rejected:90,proxy_cleared:91,declined_voting_rights:92},Lr=n=>n.reduce(Nr,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),Nr=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Rr=(n,e)=>{let t={extensions:[],owner:n,props:[]};for(let r of Object.keys(e)){if(e[r]===void 0)continue;let i;switch(r){case "key":case "new_signing_key":i=O.PublicKey;break;case "account_subsidy_budget":case "account_subsidy_decay":case "maximum_block_size":i=O.UInt32;break;case "hbd_interest_rate":i=O.UInt16;break;case "url":i=O.String;break;case "hbd_exchange_rate":i=O.Price;break;case "account_creation_fee":i=O.Asset;break;default:throw new Error(`Unknown witness prop: ${r}`)}t.props.push([r,Dr(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},Dr=(n,e)=>{let t=new w(w.DEFAULT_CAPACITY,w.LITTLE_ENDIAN);return n(t,e),t.flip(),bytesToHex(new Uint8Array(t.toBuffer()))};/**
2
2
  * @license bytebuffer.ts (c) 2015 Daniel Wirtz <dcode@dcode.io>
3
3
  * Backing buffer: ArrayBuffer, Accessor: DataView
4
4
  * Released under the Apache License, Version 2.0
5
5
  * see: https://github.com/dcodeIO/bytebuffer.ts for details
6
6
  * modified by @xmcl/bytebuffer
7
7
  * And customized for hive-tx
8
- */export{gr as Memo,q as PrivateKey,S as PublicKey,M as Signature,ue as Transaction,Wt as callREST,ee as callRPC,ce as callRPCBroadcast,Jt as callWithQuorum,g as config,pt as setNodes,gt as setRestNodes,_t as setRestNodesByApi,bt as setUserAgent,ot as utils};//# sourceMappingURL=hive.js.map
8
+ */export{Er as Memo,ne as PrivateKey,k as PublicKey,Y as Signature,Ie as Transaction,sr as callREST,he as callRPC,Pe as callRPCBroadcast,or as callWithQuorum,f as config,Tt as setNodes,It as setResilience,Et as setRestNodes,kt as setRestNodesByApi,Pt as setUserAgent,Bt as utils};//# sourceMappingURL=hive.js.map
9
9
  //# sourceMappingURL=hive.js.map