@ecency/sdk 2.3.90 → 2.3.91

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.
@@ -1,9 +1,9 @@
1
- import {hexToBytes,bytesToHex}from'@noble/hashes/utils.js';import {ripemd160}from'@noble/hashes/legacy.js';import Je 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 Ke=Object.defineProperty;var Rt=(n,e,t)=>e in n?Ke(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var Nt=(n,e)=>{for(var t in e)Ke(n,t,{get:e[t],enumerable:true});};var y=(n,e,t)=>Rt(n,typeof e!="symbol"?e+"":e,t);var ue=new ArrayBuffer(0),le=null,fe=null;function Mt(){return le||(typeof TextEncoder<"u"?le=new TextEncoder:le={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)}}),le}function He(){return fe||(typeof TextDecoder<"u"?fe=new TextDecoder:fe={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],o;i<128?(o=i,r+=1):(i&224)===192?(o=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(o=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(o=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),o<=65535?t+=String.fromCharCode(o):(o-=65536,t+=String.fromCharCode(55296+(o>>10),56320+(o&1023)));}return t}}),fe}var U=class U{constructor(e=U.DEFAULT_CAPACITY,t=U.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?ue:new ArrayBuffer(e),this.view=e===0?new DataView(ue):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new U(e,t)}static concat(e,t){let r=0;for(let u=0;u<e.length;++u){let c=e[u];if(c instanceof U)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 U(0,t);let i=new U(r,t),o=new Uint8Array(i.buffer),a=0;for(let u=0;u<e.length;++u){let c=e[u];c instanceof U?(o.set(new Uint8Array(c.buffer,c.offset,c.limit-c.offset),a),a+=c.limit-c.offset):c instanceof Uint8Array?(o.set(c,a),a+=c.length):c instanceof ArrayBuffer?(o.set(new Uint8Array(c),a),a+=c.byteLength):(o.set(c,a),a+=c.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof U){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new U(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 U(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(ue));else if(Array.isArray(e))r=new U(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 U?(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 U(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 U(0,this.littleEndian);let r=t-e,i=new U(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 o=typeof t>"u",a=typeof r>"u";t=o?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),o&&(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?ue: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,o;do o=this.view.getUint8(e++),r<5&&(i|=(o&127)<<7*r),++r;while((o&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,o=Mt().encode(e),a=o.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(o,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),o=i.value,a=i.length;e+=a;let u=He().decode(new Uint8Array(this.buffer,e,o));return e+=o,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=He().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};y(U,"LITTLE_ENDIAN",true),y(U,"BIG_ENDIAN",false),y(U,"DEFAULT_CAPACITY",16),y(U,"DEFAULT_ENDIAN",U.BIG_ENDIAN);var A=U;var d={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","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}},Ve=["bridge.get_ranked_posts","bridge.get_account_posts","bridge.get_post","bridge.get_discussion","bridge.get_profile","bridge.get_profiles","bridge.get_community","bridge.list_communities","condenser_api.get_accounts","condenser_api.get_content","condenser_api.get_dynamic_global_properties","condenser_api.get_trending_tags"],de=null,Dt=n=>{if(n===null){de=null;return}if(!n||typeof n!="object")return;let e=typeof n.url=="string"?n.url.trim():"";if(!/^https?:\/\//i.test(e))return;let t={};if(n.headers&&typeof n.headers=="object")for(let[a,u]of Object.entries(n.headers))typeof u=="string"&&u&&!/[\u0000-\u001f\u007f]/.test(u)&&!/[\u0000-\u001f\u007f]/.test(a)&&(t[a]=u);let r=typeof n.timeoutMs=="number"&&Number.isFinite(n.timeoutMs)&&n.timeoutMs>0?n.timeoutMs:2e3,i=n.methods===void 0?[...Ve]:Array.isArray(n.methods)?n.methods.filter(a=>typeof a=="string"&&a.includes(".")):[];if(i.length===0)return;let o=(a,u)=>typeof a=="number"&&Number.isFinite(a)&&a>0?a:u;de={url:e,headers:t,timeoutMs:r,methods:i,failureThreshold:Math.floor(o(n.failureThreshold,3)),cooldownMs:o(n.cooldownMs,1e4),methodSet:new Set(i)};},Te=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)))]:[],Ft=n=>{let e=Te(n);e.length&&(d.nodes=e);},Ct=n=>{let e=Te(n);e.length&&(d.restNodes=e);},Ot=n=>{if(!n||typeof n!="object")return;let e={...d.restNodesByApi};for(let[t,r]of Object.entries(n)){let i=Te(r);i.length?e[t]=i:delete e[t];}d.restNodesByApi=e;},zt=n=>{if(typeof n!="string")return;let e=n.trim();!e||/[\u0000-\u001f\u007f]/.test(e)||(d.userAgent=e);},Kt=n=>{if(!n||typeof n!="object")return;let e=d.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 J=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 o=t.subarray(1);return new n(o,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 L(r.recoverPublicKey(e).toBytes())}};var L=class n{constructor(e,t){y(this,"key");y(this,"prefix");this.key=e,this.prefix=t??d.address_prefix;}static fromString(e){let t=d.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=Je.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 o=i.subarray(0,33),a=i.subarray(33,37),u=ripemd160(o).subarray(0,4);if(!Vt(a,u))throw new Error("Public key checksum mismatch");try{secp256k1.Point.fromBytes(o);}catch{throw new Error("Invalid public key")}return new n(o,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=J.from(t)),secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return Ht(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},Ht=(n,e)=>{let t=ripemd160(n);return e+Je.encode(new Uint8Array([...n,...t.subarray(0,4)]))},Vt=(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 he=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 o=Number.parseFloat(r);if(!Number.isFinite(o))throw new Error(`Invalid asset amount: ${r}`);return new n(o,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 me=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 m={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},D=()=>{throw new Error("Void can not be serialized")},s=(n,e)=>{n.writeVString(e);},qt=(n,e)=>{n.writeInt16(e);},Xe=(n,e)=>{n.writeInt64(e);},Ge=(n,e)=>{n.writeUint8(e);},F=(n,e)=>{n.writeUint16(e);},R=(n,e)=>{n.writeUint32(e);},Qe=(n,e)=>{n.writeUint64(e);},V=(n,e)=>{n.writeByte(e?1:0);},Ze=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},w=(n,e)=>{let t=he.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);},q=(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(L.from(e).key);},et=(n=null)=>(e,t)=>{t=me.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);},tt=et(),Ue=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,o]of r)n(t,i),e(t,o);},E=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(o){throw o.message=`${r}: ${o.message}`,o}},G=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},P=C([["weight_threshold",R],["account_auths",Ue(s,F)],["key_auths",Ue(K,F)]]),Yt=C([["account",s],["weight",F]]),Ee=C([["base",w],["quote",w]]),Wt=C([["account_creation_fee",w],["maximum_block_size",R],["hbd_interest_rate",F]]),p=(n,e)=>{let t=C(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},h={};h.account_create=p(m.account_create,[["fee",w],["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s]]);h.account_create_with_delegation=p(m.account_create_with_delegation,[["fee",w],["delegation",w],["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s],["extensions",E(D)]]);h.account_update=p(m.account_update,[["account",s],["owner",G(P)],["active",G(P)],["posting",G(P)],["memo_key",K],["json_metadata",s]]);h.account_witness_proxy=p(m.account_witness_proxy,[["account",s],["proxy",s]]);h.account_witness_vote=p(m.account_witness_vote,[["account",s],["witness",s],["approve",V]]);h.cancel_transfer_from_savings=p(m.cancel_transfer_from_savings,[["from",s],["request_id",R]]);h.change_recovery_account=p(m.change_recovery_account,[["account_to_recover",s],["new_recovery_account",s],["extensions",E(D)]]);h.claim_account=p(m.claim_account,[["creator",s],["fee",w],["extensions",E(D)]]);h.claim_reward_balance=p(m.claim_reward_balance,[["account",s],["reward_hive",w],["reward_hbd",w],["reward_vests",w]]);h.comment=p(m.comment,[["parent_author",s],["parent_permlink",s],["author",s],["permlink",s],["title",s],["body",s],["json_metadata",s]]);h.comment_options=p(m.comment_options,[["author",s],["permlink",s],["max_accepted_payout",w],["percent_hbd",F],["allow_votes",V],["allow_curation_rewards",V],["extensions",E(Ze([C([["beneficiaries",E(Yt)]])]))]]);h.convert=p(m.convert,[["owner",s],["requestid",R],["amount",w]]);h.create_claimed_account=p(m.create_claimed_account,[["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s],["extensions",E(D)]]);h.custom=p(m.custom,[["required_auths",E(s)],["id",F],["data",tt]]);h.custom_json=p(m.custom_json,[["required_auths",E(s)],["required_posting_auths",E(s)],["id",s],["json",s]]);h.decline_voting_rights=p(m.decline_voting_rights,[["account",s],["decline",V]]);h.delegate_vesting_shares=p(m.delegate_vesting_shares,[["delegator",s],["delegatee",s],["vesting_shares",w]]);h.delete_comment=p(m.delete_comment,[["author",s],["permlink",s]]);h.escrow_approve=p(m.escrow_approve,[["from",s],["to",s],["agent",s],["who",s],["escrow_id",R],["approve",V]]);h.escrow_dispute=p(m.escrow_dispute,[["from",s],["to",s],["agent",s],["who",s],["escrow_id",R]]);h.escrow_release=p(m.escrow_release,[["from",s],["to",s],["agent",s],["who",s],["receiver",s],["escrow_id",R],["hbd_amount",w],["hive_amount",w]]);h.escrow_transfer=p(m.escrow_transfer,[["from",s],["to",s],["hbd_amount",w],["hive_amount",w],["escrow_id",R],["agent",s],["fee",w],["json_meta",s],["ratification_deadline",q],["escrow_expiration",q]]);h.feed_publish=p(m.feed_publish,[["publisher",s],["exchange_rate",Ee]]);h.limit_order_cancel=p(m.limit_order_cancel,[["owner",s],["orderid",R]]);h.limit_order_create=p(m.limit_order_create,[["owner",s],["orderid",R],["amount_to_sell",w],["min_to_receive",w],["fill_or_kill",V],["expiration",q]]);h.limit_order_create2=p(m.limit_order_create2,[["owner",s],["orderid",R],["amount_to_sell",w],["exchange_rate",Ee],["fill_or_kill",V],["expiration",q]]);h.recover_account=p(m.recover_account,[["account_to_recover",s],["new_owner_authority",P],["recent_owner_authority",P],["extensions",E(D)]]);h.request_account_recovery=p(m.request_account_recovery,[["recovery_account",s],["account_to_recover",s],["new_owner_authority",P],["extensions",E(D)]]);h.reset_account=p(m.reset_account,[["reset_account",s],["account_to_reset",s],["new_owner_authority",P]]);h.set_reset_account=p(m.set_reset_account,[["account",s],["current_reset_account",s],["reset_account",s]]);h.set_withdraw_vesting_route=p(m.set_withdraw_vesting_route,[["from_account",s],["to_account",s],["percent",F],["auto_vest",V]]);h.transfer=p(m.transfer,[["from",s],["to",s],["amount",w],["memo",s]]);h.transfer_from_savings=p(m.transfer_from_savings,[["from",s],["request_id",R],["to",s],["amount",w],["memo",s]]);h.transfer_to_savings=p(m.transfer_to_savings,[["from",s],["to",s],["amount",w],["memo",s]]);h.transfer_to_vesting=p(m.transfer_to_vesting,[["from",s],["to",s],["amount",w]]);h.vote=p(m.vote,[["voter",s],["author",s],["permlink",s],["weight",qt]]);h.withdraw_vesting=p(m.withdraw_vesting,[["account",s],["vesting_shares",w]]);h.witness_update=p(m.witness_update,[["owner",s],["url",s],["block_signing_key",K],["props",Wt],["fee",w]]);h.witness_set_properties=p(m.witness_set_properties,[["owner",s],["props",Ue(s,tt)],["extensions",E(D)]]);h.account_update2=p(m.account_update2,[["account",s],["owner",G(P)],["active",G(P)],["posting",G(P)],["memo_key",G(K)],["json_metadata",s],["posting_json_metadata",s],["extensions",E(D)]]);h.create_proposal=p(m.create_proposal,[["creator",s],["receiver",s],["start_date",q],["end_date",q],["daily_pay",w],["subject",s],["permlink",s],["extensions",E(D)]]);h.update_proposal_votes=p(m.update_proposal_votes,[["voter",s],["proposal_ids",E(Xe)],["approve",V],["extensions",E(D)]]);h.remove_proposal=p(m.remove_proposal,[["proposal_owner",s],["proposal_ids",E(Xe)],["extensions",E(D)]]);var Jt=C([["end_date",q]]);h.update_proposal=p(m.update_proposal,[["proposal_id",Qe],["creator",s],["daily_pay",w],["subject",s],["permlink",s],["extensions",E(Ze([D,Jt]))]]);h.collateralized_convert=p(m.collateralized_convert,[["owner",s],["requestid",R],["amount",w]]);h.recurrent_transfer=p(m.recurrent_transfer,[["from",s],["to",s],["amount",w],["memo",s],["recurrence",F],["executions",F],["extensions",E(C([["type",Ge],["value",C([["pair_id",Ge]])]]))]]);var Gt=(n,e)=>{let t=h[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}},Xt=C([["ref_block_num",F],["ref_block_prefix",R],["expiration",q],["operations",E(Gt)],["extensions",E(s)]]),Qt=C([["from",K],["to",K],["nonce",Qe],["check",R],["encrypted",et()]]),O={Asset:w,Memo:Qt,Price:Ee,PublicKey:K,String:s,Transaction:Xt,UInt16:F,UInt32:R};var re=n=>new Promise(e=>setTimeout(e,n));var st=(()=>{try{return !(typeof navigator<"u"&&navigator.product==="ReactNative")&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null}catch{return false}})();function Ne(){return st?{"User-Agent":d.userAgent}:{}}var Z={served:0,fallback:0,skipped:0,fallbackByReason:{status:0,timeout:0,transport:0,validate:0,parse:0}},W=class extends Error{constructor(t,r){super(r);y(this,"reason",t);}},rt=n=>n instanceof Error?n.message:typeof n=="string"?n:String(n),pe=0,ke=0;function Zt(){pe=0,ke=0;}async function er(n,e,t,r,i,o){let a=e.indexOf(".");if(a<=0||a===e.length-1)throw new W("transport",`method without an api prefix: ${e}`);let{signal:u,cleanup:c}=De(Math.min(n.timeoutMs,r)),{signal:f,cleanup:g}=_e(u,i);try{let v;try{v=await fetch(n.url,{method:"POST",body:JSON.stringify({api:e.slice(0,a),method:e.slice(a+1),params:t}),headers:{"Content-Type":"application/json",...Ne(),...n.headers},signal:f});}catch(l){throw i?.aborted?l:new W(u.aborted?"timeout":"transport",rt(l))}if(v.status!==200){try{await v.body?.cancel();}catch{}throw new W("status",`proxy answered ${v.status}`)}let S;try{S=await v.json();}catch(l){throw i?.aborted?l:new W(u.aborted?"timeout":"parse",rt(l))}if(o&&!o(S))throw new W("validate","proxy result rejected by validator");return S}finally{c(),g();}}var N=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);}},X=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 at(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 tr=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"],rr=["Failed to fetch","NetworkError when attempting to fetch","Load failed","fetch failed"];function nr(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 ir(n){if(!n)return false;if(n instanceof X)return true;if(n instanceof N)return false;let e=nr(n);return !!(tr.some(t=>e.includes(t))||rr.some(t=>e.includes(t))||n instanceof SyntaxError||/Unexpected token|JSON\.parse|Unexpected end of JSON/i.test(e))}function Pe(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function ct(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var or=1e4,sr=6e4,ar=12e4,nt=2,it=6e4,ot=12e4,cr=30,ne=.3,Ie=3,ie=5*6e4,ut=6e4,lt=1e3,ft=2e3,ge=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(),apiLatency:new Map},this.health.set(e,t)),t}recordSuccess(e,t,r,i){let o=this.getOrCreate(e);if(o.consecutiveFailures=0,o.rateLimitStreak=0,t){let a=o.apiFailures.get(t);(!a||!(a.defective&&a.cooldownUntil>Date.now()))&&o.apiFailures.delete(t);}typeof r=="number"&&Number.isFinite(r)&&r>=0&&this.recordLatency(o,r,i??t);}recordSlowFailure(e,t,r){!Number.isFinite(t)||t<ft||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 o=r.apiLatency.get(t);return o&&o.sampleCount>=Ie&&i-o.updatedAt<=ie?o.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>ie&&(e.ewmaLatencyMs=void 0,e.latencySampleCount=0,e.apiLatency.clear()),e.ewmaLatencyMs=e.ewmaLatencyMs===void 0?t:ne*t+(1-ne)*e.ewmaLatencyMs,e.latencySampleCount++,e.latencyUpdatedAt=i,r!==void 0){let o=e.apiLatency.get(r);!o||i-o.updatedAt>ie?e.apiLatency.set(r,{ewmaMs:t,sampleCount:1,updatedAt:i}):(o.ewmaMs=ne*t+(1-ne)*o.ewmaMs,o.sampleCount++,o.updatedAt=i);}}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),o=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(o.cooldownUntil>0&&o.cooldownUntil<=i||o.lastFailureTime>0&&i-o.lastFailureTime>3e4)&&(o.count=0,o.cooldownUntil=0),o.count++,o.lastFailureTime=i,o.count>=nt&&(o.cooldownUntil=i+it),r.apiFailures.set(t,o);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordDefectiveResponse(e,t){let r=this.getOrCreate(e),i=Date.now(),o=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};o.count=Math.max(o.count+1,nt),o.lastFailureTime=i,o.cooldownUntil=i+it,o.defective=true,r.apiFailures.set(t,o);}recordRateLimit(e,t){let r=this.getOrCreate(e),i=Date.now();r.rateLimitStreak>0&&i-r.lastRateLimitAt>ar&&(r.rateLimitStreak=0);let o=typeof t=="number"&&Number.isFinite(t)&&t>0,a=o?t:Math.min(or*2**r.rateLimitStreak,sr);o||r.rateLimitStreak++,r.lastRateLimitAt=i,r.rateLimitedUntil=o?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<=ot&&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 o=this.consensusHeadBlock();return !(o>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=ot&&o-r.headBlock>cr)}getOrderedNodes(e,t){let r=[],i=[];for(let c of e)this.isNodeHealthy(c,t)?r.push(c):i.push(c);if(r.length<=1)return [...r,...i];let o=Date.now(),a=r.map((c,f)=>({node:c,i:f,score:this.scoreNode(c,o)})).sort((c,f)=>c.score-f.score||c.i-f.i).map(c=>c.node),u=this.pickReprobeCandidate(r,o);return u&&a[0]!==u?[u,...a.filter(c=>c!==u),...i]:[...a,...i]}isLatencyUsable(e,t){return !!e&&e.ewmaLatencyMs!==void 0&&e.latencySampleCount>=Ie&&t-e.latencyUpdatedAt<=ie}scoreNode(e,t){let r=this.health.get(e);return this.isLatencyUsable(r,t)?r.ewmaLatencyMs:lt}pickReprobeCandidate(e,t){let r=t-ut,i,o=1/0;for(let a of e){let u=this.getOrCreate(a),c=Math.max(u.latencyUpdatedAt,u.lastProbeAt);c<=r&&c<o&&(i=a,o=c);}return i&&(this.getOrCreate(i).lastProbeAt=t),i}},k=new ge,Y=new ge,Le=class{constructor(){y(this,"tokens",d.resilience.hedgeBucketCapacity);}trySpend(){return this.clamp(),this.tokens>=1-1e-9?(this.tokens-=1,true):false}refill(){this.clamp(),this.tokens=Math.min(d.resilience.hedgeBucketCapacity,this.tokens+d.resilience.hedgeRefillPerSuccess);}clamp(){this.tokens>d.resilience.hedgeBucketCapacity&&(this.tokens=d.resilience.hedgeBucketCapacity);}get available(){return this.tokens}reset(e=d.resilience.hedgeBucketCapacity){this.tokens=e;}},Re=new Le;function be(n,e,t,r,i){let o=d.resilience;if(!o.adaptiveTimeout||i)return r;let a=n.getUsableLatencyMs(e,t);return a===void 0?r:Math.ceil(Math.min(r,Math.max(o.adaptiveTimeoutFloorMs,o.adaptiveTimeoutFactor*a)))}function Me(n,e,t,r){t instanceof X?t.isRateLimit?n.recordRateLimit(e,t.rateLimitMs||void 0):n.recordFailure(e,r):t instanceof N?n.recordFailure(e,r):n.recordFailure(e);}function dt(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 ur(){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 De(n){if(n=Math.ceil(n),typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(ur()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function _e(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 o=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:o}}var oe=async(n,e,t,r=d.timeout,i=false,o)=>{let a=Math.floor(Math.random()*1e8),u={jsonrpc:"2.0",method:e,params:t,id:a},{signal:c,cleanup:f}=De(r),{signal:g,cleanup:v}=_e(c,o),S=()=>{f(),v();};try{let l=await fetch(n,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json",...Ne()},signal:g});if(l.status===429)throw new X(n,"HTTP 429 Rate Limited",{rateLimitMs:at(l.headers.get("Retry-After")),isRateLimit:!0});if(l.status>=500&&l.status<600)throw new X(n,`HTTP ${l.status} from ${n}`);let x=await l.json();if(!x||typeof x.id>"u"||x.id!==a||x.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in x)return x.result;if("error"in x){let B=x.error;throw "message"in B&&"code"in B?new N(B):x.error}throw x}catch(l){if(l instanceof N||l instanceof X||o?.aborted)throw l;if(i)return oe(n,e,t,r,false,o);throw l}finally{S();}};function ye(){return re(50+Math.random()*50)}function lr(n){let{method:e,params:t,api:r,primary:i,hedgePool:o,callerTimeout:a,explicitTimeout:u,deadlineAt:c,externalSignal:f,onHedgeFired:g,validate:v}=n;return new Promise((S,l)=>{let x=false,B=0,T=false,j=false,b,$,ee=0,Q=[],H=I=>{if(!x){x=true,$!==void 0&&(clearTimeout($),$=void 0);for(let _ of Q)_.signal.aborted||_.abort();I();}},ce=(I,_)=>{B++;let z=new AbortController;Q.push(z);let te=_e(z.signal,f),Lt=be(k,I,e,a,u),Se=Date.now();_||(ee=Se),oe(I,e,t,Lt,false,te.signal).then(M=>{if(te.cleanup(),B--,_||(j=true),!x){if(v&&!v(M)){if(k.recordDefectiveResponse(I,r),b=new Error(`[hive-tx] response validation failed for ${e} from ${I}`),!_&&!T){H(()=>l(b));return}B===0&&H(()=>l(b));return}k.recordSuccess(I,r,Date.now()-Se,e),dt(k,I,e,M),_?j||k.recordCensoredLatency(i,Date.now()-ee,e):T||Re.refill(),H(()=>S(M));}}).catch(M=>{if(te.cleanup(),B--,_||(j=true),!x){if(f?.aborted){H(()=>l(M));return}if(M instanceof N&&!Pe(M.code,M.message)){H(()=>l(M));return}if(Me(k,I,M,r),k.recordSlowFailure(I,Date.now()-Se,e),b=M,!_&&!T){H(()=>l(M));return}B===0&&H(()=>l(b));}});};ce(i,false);let ve=k.getUsableLatencyMs(i,e)??0,xe=be(k,i,e,a,u),Be=Math.min(Math.max(d.resilience.hedgeDelayFloorMs,d.resilience.hedgeDelayFactor*ve),.8*xe);$=setTimeout(()=>{if($=void 0,x||f?.aborted||Date.now()>=c)return;let I=o.filter(z=>k.isNodeHealthy(z,r));if(I.length===0)return;let _=I[Math.floor(Math.random()*I.length)];Re.trySpend()&&(T=true,g(_),ce(_,true));},Be);})}var we=async(n,e=[],t,r=d.retry,i,o)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an array");if(d.nodes.length===0)throw new Error("config.nodes is empty");let a=t!==void 0,u=t??d.timeout,c=ct(n),f=de;if(f&&st&&f.methodSet.has(n))if(Date.now()<ke)Z.skipped++;else try{let l=await er(f,n,e,u,i,o);return Z.served++,pe=0,l}catch(l){if(i?.aborted)throw l;Z.fallback++;let x=l instanceof W?l.reason:"transport";Z.fallbackByReason[x]=(Z.fallbackByReason[x]??0)+1,++pe>=f.failureThreshold&&(ke=Date.now()+f.cooldownMs,pe=0);}let g=Date.now()+d.resilience.totalBudgetFactor*u,v=new Set,S;for(let l=0;l<=r&&!(l>0&&Date.now()>=g);l++){let x=k.getOrderedNodes(d.nodes,c),B=x.find(b=>!v.has(b));B||(v.clear(),B=x[0]),v.add(B);let T=[];if(d.resilience.hedge&&k.getUsableLatencyMs(B,n)!==void 0&&(T=x.filter(b=>!v.has(b)&&k.isNodeHealthy(b,c)).slice(0,3)),T.length>0)try{return await lr({method:n,params:e,api:c,primary:B,hedgePool:T,callerTimeout:u,explicitTimeout:a,deadlineAt:g,externalSignal:i,onHedgeFired:b=>v.add(b),validate:o})}catch(b){if(b instanceof N&&!Pe(b.code,b.message)||i?.aborted)throw b;S=b,l<r&&await ye();continue}let j=Date.now();try{let b=await oe(B,n,e,be(k,B,n,u,a),!1,i);if(o&&!o(b)){k.recordDefectiveResponse(B,c),S=new Error(`[hive-tx] response validation failed for ${n} from ${B}`),l<r&&await ye();continue}return k.recordSuccess(B,c,Date.now()-j,n),Re.refill(),dt(k,B,n,b),b}catch(b){if(b instanceof N&&!Pe(b.code,b.message)||i?.aborted)throw b;Me(k,B,b,c),k.recordSlowFailure(B,Date.now()-j,n),S=b,l<r&&await ye();}}throw S},Fe=async(n,e=[],t=d.broadcastTimeout,r)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an array");if(d.nodes.length===0)throw new Error("config.nodes is empty");let i=ct(n),o=new Set,a;for(let u=0;u<d.nodes.length;u++){let f=k.getOrderedNodes(d.nodes,i).find(g=>!o.has(g));if(!f)break;if(o.add(f),r?.aborted)throw new Error("Aborted");try{let g=await oe(f,n,e,t,!1,r);return k.recordSuccess(f,i),g}catch(g){if(g instanceof N||r?.aborted||(Me(k,f,g,i),a=g,!ir(g)))throw g}}throw a},fr={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 dr(n,e,t,r,i=d.retry,o){if(!Array.isArray(d.restNodes))throw new Error("config.restNodes is not an array");if(d.restNodes.length===0)throw new Error("config.restNodes is empty");let a=r!==void 0,u=r??d.timeout,c=Date.now()+d.resilience.totalBudgetFactor*u,f=`${n}:${e}`,g=d.restNodesByApi?.[n]?.length?d.restNodesByApi[n]:d.restNodes,v=new Set,S,l=false;for(let x=0;x<=i&&!(x>0&&Date.now()>=c);x++){let B=Y.getOrderedNodes(g,n),T=B.find(_=>!v.has(_));T||(v.clear(),T=B[0]),v.add(T);let j=T+fr[n],b=e,$=t||{},ee=new Set;Object.entries($).forEach(([_,z])=>{b.includes(`{${_}}`)&&(b=b.replace(`{${_}}`,encodeURIComponent(String(z))),ee.add(_));});let Q=new URL(j+b);if(Object.entries($).forEach(([_,z])=>{ee.has(_)||(Array.isArray(z)?z.forEach(te=>Q.searchParams.append(_,String(te))):Q.searchParams.set(_,String(z)));}),o?.aborted)throw new Error("Aborted");l=false;let{signal:H,cleanup:ce}=De(be(Y,T,f,u,a)),{signal:ve,cleanup:xe}=_e(H,o),Be=()=>{ce(),xe();},I=Date.now();try{let _=await fetch(Q.toString(),{signal:ve,headers:Ne()});if(_.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(_.status===429)throw Y.recordRateLimit(T,at(_.headers.get("Retry-After"))||void 0),l=!0,new Error(`HTTP 429 Rate Limited by ${T}`);if(_.status===503)throw Y.recordFailure(T,n),l=!0,new Error(`HTTP 503 Service Unavailable from ${T}`);if(!_.ok)throw Y.recordFailure(T,n),l=!0,new Error(`HTTP ${_.status} from ${T}`);return Y.recordSuccess(T,n,Date.now()-I,f),_.json()}catch(_){if(_?.message?.includes("HTTP 404")||o?.aborted)throw _;l||Y.recordFailure(T,n),Y.recordSlowFailure(T,Date.now()-I,f),S=_,x<i&&await ye();}finally{Be();}}throw S}var hr=async(n,e=[],t=2,r)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an Array");if(t>d.nodes.length)throw new Error("quorum > config.nodes.length");let o=(c=>{let f=[...c];for(let g=f.length-1;g>0;g--){let v=Math.floor(Math.random()*(g+1));[f[g],f[v]]=[f[v],f[g]];}return f})(d.nodes),a=Math.min(t,o.length),u=[];for(;a>0&&o.length>0;){let c=o.splice(0,a),f=[],g=[];for(let S=0;S<c.length;S++)f.push(oe(c[S],n,e,void 0,true,r).then(l=>g.push(l)).catch(()=>{}));await Promise.all(f),u.push(...g);let v=mr(u,t);if(v)return v;if(a=Math.min(t,o.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function mr(n,e){let t=new Map;for(let i of n){let o=JSON.stringify(i);t.has(o)||t.set(o,[]),t.get(o).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var yr=hexToBytes(d.chain_id),Ce=class n{constructor(e){y(this,"transaction");y(this,"expiration",6e4);y(this,"txId");y(this,"createTransaction",async e=>{let t=await we("condenser_api.get_dynamic_global_properties",[]),r=hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),o=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:o,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 o=i.sign(t);this.transaction.signatures.push(o.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 Fe("condenser_api.broadcast_transaction",[this.transaction]);}catch(o){if(!(o instanceof N&&o.message.includes("Duplicate transaction check failed")))throw o}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await re(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 re(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 A(A.DEFAULT_CAPACITY,A.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([...yr,...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),we("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}};var bt=new Uint8Array([128]),ae=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(wr(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 o=e.charCodeAt(i);if(o<128)r.push(o);else if(o<2048)r.push(192|o>>6,128|o&63);else if(o>=55296&&o<=56319&&i+1<e.length){let a=e.charCodeAt(++i);o=65536+((o&1023)<<10)+(a&1023),r.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63);}else r.push(224|o>>12,128|o>>6&63,128|o&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 J.from((r+31).toString(16)+bytesToHex(t.subarray(1)))}createPublic(e){return new L(secp256k1.getPublicKey(this.key),e)}toString(){return _r(new Uint8Array([...bt,...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)}},_t=n=>sha256(sha256(n)),_r=n=>{let e=_t(n);return Je.encode(new Uint8Array([...n,...e.slice(0,4)]))},wr=n=>{let e=Je.decode(n);if(!yt(e.slice(0,1),bt))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=_t(r).slice(0,4);if(!yt(t,i))throw new Error("Private key checksum mismatch");return r},yt=(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 At=(n,e,t,r=Tr())=>xt(n,e,r,t),vt=(n,e,t,r,i)=>xt(n,e,t,r,i).message,xt=(n,e,t,r,i)=>{let o=t,a=n.getSharedSecret(e),u=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);u.writeUint64(o),u.append(a),u.flip();let c=sha512(new Uint8Array(u.toBuffer())),f=c.subarray(32,48),g=c.subarray(0,32),v=sha256(c).subarray(0,4),S=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);S.append(v),S.flip();let l=S.readUint32();if(i!==void 0){if(l!==i)throw new Error("Invalid key");r=Br(r,g,f);}else r=Sr(r,g,f);return {nonce:o,message:r,checksum:l}},Br=(n,e,t)=>{let r=n;return r=cbc(e,t).decrypt(r),r},Sr=(n,e,t)=>{let r=n;return r=cbc(e,t).encrypt(r),r},ze=null,Tr=()=>{if(ze===null){let t=secp256k1.utils.randomSecretKey();ze=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++ze%65536;return n=n<<BigInt(16)|BigInt(e),n};var Bt=n=>{let e=Lr(n,33);return new L(e)},Er=n=>n.readUint64(),kr=n=>n.readUint32(),Pr=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},Ir=n=>e=>{let t={},r=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,o]of n)try{t[i]=o(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function Lr(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 Rr=Ir([["from",Bt],["to",Bt],["nonce",Er],["check",kr],["encrypted",Pr]]),St={Memo:Rr};var Ut=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),kt(),n=Pt(n),e=Nr(e);let i=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);i.writeVString(t);let o=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:u,checksum:c}=At(n,e,o,r),f=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);O.Memo(f,{check:c,encrypted:u,from:n.createPublic(),nonce:a,to:e}),f.flip();let g=new Uint8Array(f.toBuffer());return "#"+Je.encode(g)},Et=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),kt(),n=Pt(n);let t=St.Memo(Je.decode(e)),{from:r,to:i,nonce:o,check:a,encrypted:u}=t,f=n.createPublic().toString()===new L(r.key).toString()?new L(i.key):new L(r.key);t=vt(n,f,o,u,a);let g=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);return g.append(t),g.flip(),"#"+g.readVString()},Ae,kt=()=>{if(Ae===void 0){let n;Ae=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Ut(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=Et(e,r);}finally{Ae=n==="#memo\u7231";}}if(Ae===false)throw new Error("This environment does not support encryption.")},Pt=n=>typeof n=="string"?ae.fromString(n):n,Nr=n=>typeof n=="string"?L.fromString(n):n,Mr={decode:Et,encode:Ut};var It={};Nt(It,{buildWitnessSetProperties:()=>Kr,makeBitMaskFilter:()=>Or,operations:()=>Cr,validateUsername:()=>Fr});var Fr=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 o=0;o<i;o++){let a=r[o];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},Cr={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},Or=n=>n.reduce(zr,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),zr=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Kr=(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,Hr(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},Hr=(n,e)=>{let t=new A(A.DEFAULT_CAPACITY,A.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 Je 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 Ke=Object.defineProperty;var Rt=(n,e,t)=>e in n?Ke(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var Nt=(n,e)=>{for(var t in e)Ke(n,t,{get:e[t],enumerable:true});};var y=(n,e,t)=>Rt(n,typeof e!="symbol"?e+"":e,t);var le=new ArrayBuffer(0),fe=null,de=null;function Mt(){return fe||(typeof TextEncoder<"u"?fe=new TextEncoder:fe={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)}}),fe}function He(){return de||(typeof TextDecoder<"u"?de=new TextDecoder:de={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],o;i<128?(o=i,r+=1):(i&224)===192?(o=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(o=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(o=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),o<=65535?t+=String.fromCharCode(o):(o-=65536,t+=String.fromCharCode(55296+(o>>10),56320+(o&1023)));}return t}}),de}var U=class U{constructor(e=U.DEFAULT_CAPACITY,t=U.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?le:new ArrayBuffer(e),this.view=e===0?new DataView(le):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new U(e,t)}static concat(e,t){let r=0;for(let u=0;u<e.length;++u){let c=e[u];if(c instanceof U)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 U(0,t);let i=new U(r,t),o=new Uint8Array(i.buffer),a=0;for(let u=0;u<e.length;++u){let c=e[u];c instanceof U?(o.set(new Uint8Array(c.buffer,c.offset,c.limit-c.offset),a),a+=c.limit-c.offset):c instanceof Uint8Array?(o.set(c,a),a+=c.length):c instanceof ArrayBuffer?(o.set(new Uint8Array(c),a),a+=c.byteLength):(o.set(c,a),a+=c.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof U){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new U(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 U(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(le));else if(Array.isArray(e))r=new U(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 U?(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 U(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 U(0,this.littleEndian);let r=t-e,i=new U(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 o=typeof t>"u",a=typeof r>"u";t=o?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),o&&(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?le: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,o;do o=this.view.getUint8(e++),r<5&&(i|=(o&127)<<7*r),++r;while((o&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,o=Mt().encode(e),a=o.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(o,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),o=i.value,a=i.length;e+=a;let u=He().decode(new Uint8Array(this.buffer,e,o));return e+=o,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=He().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};y(U,"LITTLE_ENDIAN",true),y(U,"BIG_ENDIAN",false),y(U,"DEFAULT_CAPACITY",16),y(U,"DEFAULT_ENDIAN",U.BIG_ENDIAN);var A=U;var d={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","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}},Ve=["bridge.get_ranked_posts","bridge.get_account_posts","bridge.get_post","bridge.get_discussion","bridge.get_profile","bridge.get_profiles","bridge.get_community","bridge.list_communities","condenser_api.get_accounts","condenser_api.get_content","condenser_api.get_dynamic_global_properties","condenser_api.get_trending_tags"],he=null,Dt=n=>{if(n===null){he=null;return}if(!n||typeof n!="object")return;let e=typeof n.url=="string"?n.url.trim():"";if(!/^https?:\/\//i.test(e))return;let t={};if(n.headers&&typeof n.headers=="object")for(let[a,u]of Object.entries(n.headers))typeof u=="string"&&u&&!/[\u0000-\u001f\u007f]/.test(u)&&!/[\u0000-\u001f\u007f]/.test(a)&&(t[a]=u);let r=typeof n.timeoutMs=="number"&&Number.isFinite(n.timeoutMs)&&n.timeoutMs>0?n.timeoutMs:2e3,i=n.methods===void 0?[...Ve]:Array.isArray(n.methods)?n.methods.filter(a=>typeof a=="string"&&a.includes(".")):[];if(i.length===0)return;let o=(a,u)=>typeof a=="number"&&Number.isFinite(a)&&a>0?a:u;he={url:e,headers:t,timeoutMs:r,methods:i,failureThreshold:Math.floor(o(n.failureThreshold,3)),cooldownMs:o(n.cooldownMs,1e4),methodSet:new Set(i)};},Te=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)))]:[],Ft=n=>{let e=Te(n);e.length&&(d.nodes=e);},Ct=n=>{let e=Te(n);e.length&&(d.restNodes=e);},Ot=n=>{if(!n||typeof n!="object")return;let e={...d.restNodesByApi};for(let[t,r]of Object.entries(n)){let i=Te(r);i.length?e[t]=i:delete e[t];}d.restNodesByApi=e;},zt=n=>{if(typeof n!="string")return;let e=n.trim();!e||/[\u0000-\u001f\u007f]/.test(e)||(d.userAgent=e);},Kt=n=>{if(!n||typeof n!="object")return;let e=d.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 J=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 o=t.subarray(1);return new n(o,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 L(r.recoverPublicKey(e).toBytes())}};var L=class n{constructor(e,t){y(this,"key");y(this,"prefix");this.key=e,this.prefix=t??d.address_prefix;}static fromString(e){let t=d.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=Je.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 o=i.subarray(0,33),a=i.subarray(33,37),u=ripemd160(o).subarray(0,4);if(!Vt(a,u))throw new Error("Public key checksum mismatch");try{secp256k1.Point.fromBytes(o);}catch{throw new Error("Invalid public key")}return new n(o,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=J.from(t)),secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return Ht(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},Ht=(n,e)=>{let t=ripemd160(n);return e+Je.encode(new Uint8Array([...n,...t.subarray(0,4)]))},Vt=(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 me=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 o=Number.parseFloat(r);if(!Number.isFinite(o))throw new Error(`Invalid asset amount: ${r}`);return new n(o,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 pe=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 m={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},D=()=>{throw new Error("Void can not be serialized")},s=(n,e)=>{n.writeVString(e);},qt=(n,e)=>{n.writeInt16(e);},Xe=(n,e)=>{n.writeInt64(e);},Ge=(n,e)=>{n.writeUint8(e);},F=(n,e)=>{n.writeUint16(e);},R=(n,e)=>{n.writeUint32(e);},Qe=(n,e)=>{n.writeUint64(e);},V=(n,e)=>{n.writeByte(e?1:0);},Ze=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},w=(n,e)=>{let t=me.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);},q=(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(L.from(e).key);},et=(n=null)=>(e,t)=>{t=pe.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);},tt=et(),Ue=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,o]of r)n(t,i),e(t,o);},E=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(o){throw o.message=`${r}: ${o.message}`,o}},G=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},P=C([["weight_threshold",R],["account_auths",Ue(s,F)],["key_auths",Ue(K,F)]]),Yt=C([["account",s],["weight",F]]),Ee=C([["base",w],["quote",w]]),Wt=C([["account_creation_fee",w],["maximum_block_size",R],["hbd_interest_rate",F]]),p=(n,e)=>{let t=C(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},h={};h.account_create=p(m.account_create,[["fee",w],["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s]]);h.account_create_with_delegation=p(m.account_create_with_delegation,[["fee",w],["delegation",w],["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s],["extensions",E(D)]]);h.account_update=p(m.account_update,[["account",s],["owner",G(P)],["active",G(P)],["posting",G(P)],["memo_key",K],["json_metadata",s]]);h.account_witness_proxy=p(m.account_witness_proxy,[["account",s],["proxy",s]]);h.account_witness_vote=p(m.account_witness_vote,[["account",s],["witness",s],["approve",V]]);h.cancel_transfer_from_savings=p(m.cancel_transfer_from_savings,[["from",s],["request_id",R]]);h.change_recovery_account=p(m.change_recovery_account,[["account_to_recover",s],["new_recovery_account",s],["extensions",E(D)]]);h.claim_account=p(m.claim_account,[["creator",s],["fee",w],["extensions",E(D)]]);h.claim_reward_balance=p(m.claim_reward_balance,[["account",s],["reward_hive",w],["reward_hbd",w],["reward_vests",w]]);h.comment=p(m.comment,[["parent_author",s],["parent_permlink",s],["author",s],["permlink",s],["title",s],["body",s],["json_metadata",s]]);h.comment_options=p(m.comment_options,[["author",s],["permlink",s],["max_accepted_payout",w],["percent_hbd",F],["allow_votes",V],["allow_curation_rewards",V],["extensions",E(Ze([C([["beneficiaries",E(Yt)]])]))]]);h.convert=p(m.convert,[["owner",s],["requestid",R],["amount",w]]);h.create_claimed_account=p(m.create_claimed_account,[["creator",s],["new_account_name",s],["owner",P],["active",P],["posting",P],["memo_key",K],["json_metadata",s],["extensions",E(D)]]);h.custom=p(m.custom,[["required_auths",E(s)],["id",F],["data",tt]]);h.custom_json=p(m.custom_json,[["required_auths",E(s)],["required_posting_auths",E(s)],["id",s],["json",s]]);h.decline_voting_rights=p(m.decline_voting_rights,[["account",s],["decline",V]]);h.delegate_vesting_shares=p(m.delegate_vesting_shares,[["delegator",s],["delegatee",s],["vesting_shares",w]]);h.delete_comment=p(m.delete_comment,[["author",s],["permlink",s]]);h.escrow_approve=p(m.escrow_approve,[["from",s],["to",s],["agent",s],["who",s],["escrow_id",R],["approve",V]]);h.escrow_dispute=p(m.escrow_dispute,[["from",s],["to",s],["agent",s],["who",s],["escrow_id",R]]);h.escrow_release=p(m.escrow_release,[["from",s],["to",s],["agent",s],["who",s],["receiver",s],["escrow_id",R],["hbd_amount",w],["hive_amount",w]]);h.escrow_transfer=p(m.escrow_transfer,[["from",s],["to",s],["hbd_amount",w],["hive_amount",w],["escrow_id",R],["agent",s],["fee",w],["json_meta",s],["ratification_deadline",q],["escrow_expiration",q]]);h.feed_publish=p(m.feed_publish,[["publisher",s],["exchange_rate",Ee]]);h.limit_order_cancel=p(m.limit_order_cancel,[["owner",s],["orderid",R]]);h.limit_order_create=p(m.limit_order_create,[["owner",s],["orderid",R],["amount_to_sell",w],["min_to_receive",w],["fill_or_kill",V],["expiration",q]]);h.limit_order_create2=p(m.limit_order_create2,[["owner",s],["orderid",R],["amount_to_sell",w],["exchange_rate",Ee],["fill_or_kill",V],["expiration",q]]);h.recover_account=p(m.recover_account,[["account_to_recover",s],["new_owner_authority",P],["recent_owner_authority",P],["extensions",E(D)]]);h.request_account_recovery=p(m.request_account_recovery,[["recovery_account",s],["account_to_recover",s],["new_owner_authority",P],["extensions",E(D)]]);h.reset_account=p(m.reset_account,[["reset_account",s],["account_to_reset",s],["new_owner_authority",P]]);h.set_reset_account=p(m.set_reset_account,[["account",s],["current_reset_account",s],["reset_account",s]]);h.set_withdraw_vesting_route=p(m.set_withdraw_vesting_route,[["from_account",s],["to_account",s],["percent",F],["auto_vest",V]]);h.transfer=p(m.transfer,[["from",s],["to",s],["amount",w],["memo",s]]);h.transfer_from_savings=p(m.transfer_from_savings,[["from",s],["request_id",R],["to",s],["amount",w],["memo",s]]);h.transfer_to_savings=p(m.transfer_to_savings,[["from",s],["to",s],["amount",w],["memo",s]]);h.transfer_to_vesting=p(m.transfer_to_vesting,[["from",s],["to",s],["amount",w]]);h.vote=p(m.vote,[["voter",s],["author",s],["permlink",s],["weight",qt]]);h.withdraw_vesting=p(m.withdraw_vesting,[["account",s],["vesting_shares",w]]);h.witness_update=p(m.witness_update,[["owner",s],["url",s],["block_signing_key",K],["props",Wt],["fee",w]]);h.witness_set_properties=p(m.witness_set_properties,[["owner",s],["props",Ue(s,tt)],["extensions",E(D)]]);h.account_update2=p(m.account_update2,[["account",s],["owner",G(P)],["active",G(P)],["posting",G(P)],["memo_key",G(K)],["json_metadata",s],["posting_json_metadata",s],["extensions",E(D)]]);h.create_proposal=p(m.create_proposal,[["creator",s],["receiver",s],["start_date",q],["end_date",q],["daily_pay",w],["subject",s],["permlink",s],["extensions",E(D)]]);h.update_proposal_votes=p(m.update_proposal_votes,[["voter",s],["proposal_ids",E(Xe)],["approve",V],["extensions",E(D)]]);h.remove_proposal=p(m.remove_proposal,[["proposal_owner",s],["proposal_ids",E(Xe)],["extensions",E(D)]]);var Jt=C([["end_date",q]]);h.update_proposal=p(m.update_proposal,[["proposal_id",Qe],["creator",s],["daily_pay",w],["subject",s],["permlink",s],["extensions",E(Ze([D,Jt]))]]);h.collateralized_convert=p(m.collateralized_convert,[["owner",s],["requestid",R],["amount",w]]);h.recurrent_transfer=p(m.recurrent_transfer,[["from",s],["to",s],["amount",w],["memo",s],["recurrence",F],["executions",F],["extensions",E(C([["type",Ge],["value",C([["pair_id",Ge]])]]))]]);var Gt=(n,e)=>{let t=h[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}},Xt=C([["ref_block_num",F],["ref_block_prefix",R],["expiration",q],["operations",E(Gt)],["extensions",E(s)]]),Qt=C([["from",K],["to",K],["nonce",Qe],["check",R],["encrypted",et()]]),O={Asset:w,Memo:Qt,Price:Ee,PublicKey:K,String:s,Transaction:Xt,UInt16:F,UInt32:R};var re=n=>new Promise(e=>setTimeout(e,n));var st=(()=>{try{return !(typeof navigator<"u"&&navigator.product==="ReactNative")&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null}catch{return false}})();function Ne(){return st?{"User-Agent":d.userAgent}:{}}var Z={served:0,fallback:0,skipped:0,fallbackByReason:{status:0,rpcerror:0,timeout:0,transport:0,validate:0,parse:0}},W=class extends Error{constructor(t,r){super(r);y(this,"reason",t);}},rt=n=>n instanceof Error?n.message:typeof n=="string"?n:String(n),ne=0,ke=0;function Zt(){ne=0,ke=0;}async function er(n,e,t,r,i,o){let a=e.indexOf(".");if(a<=0||a===e.length-1)throw new W("transport",`method without an api prefix: ${e}`);let{signal:u,cleanup:c}=De(Math.min(n.timeoutMs,r)),{signal:f,cleanup:g}=_e(u,i);try{let v;try{v=await fetch(n.url,{method:"POST",body:JSON.stringify({api:e.slice(0,a),method:e.slice(a+1),params:t}),headers:{"Content-Type":"application/json",...Ne(),...n.headers},signal:f});}catch(l){throw i?.aborted?l:new W(u.aborted?"timeout":"transport",rt(l))}if(v.status!==200){try{await v.body?.cancel();}catch{}let l=v.status===502&&(v.headers.get("x-ssr-cache")??"").toUpperCase()==="RPCERROR";throw new W(l?"rpcerror":"status",l?"proxy relayed a node error":`proxy answered ${v.status}`)}let S;try{S=await v.json();}catch(l){throw i?.aborted?l:new W(u.aborted?"timeout":"parse",rt(l))}if(o&&!o(S))throw new W("validate","proxy result rejected by validator");return S}finally{c(),g();}}var N=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);}},X=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 at(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 tr=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"],rr=["Failed to fetch","NetworkError when attempting to fetch","Load failed","fetch failed"];function nr(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 ir(n){if(!n)return false;if(n instanceof X)return true;if(n instanceof N)return false;let e=nr(n);return !!(tr.some(t=>e.includes(t))||rr.some(t=>e.includes(t))||n instanceof SyntaxError||/Unexpected token|JSON\.parse|Unexpected end of JSON/i.test(e))}function Pe(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function ct(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var or=1e4,sr=6e4,ar=12e4,nt=2,it=6e4,ot=12e4,cr=30,ie=.3,Ie=3,oe=5*6e4,ut=6e4,lt=1e3,ft=2e3,ge=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(),apiLatency:new Map},this.health.set(e,t)),t}recordSuccess(e,t,r,i){let o=this.getOrCreate(e);if(o.consecutiveFailures=0,o.rateLimitStreak=0,t){let a=o.apiFailures.get(t);(!a||!(a.defective&&a.cooldownUntil>Date.now()))&&o.apiFailures.delete(t);}typeof r=="number"&&Number.isFinite(r)&&r>=0&&this.recordLatency(o,r,i??t);}recordSlowFailure(e,t,r){!Number.isFinite(t)||t<ft||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 o=r.apiLatency.get(t);return o&&o.sampleCount>=Ie&&i-o.updatedAt<=oe?o.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>oe&&(e.ewmaLatencyMs=void 0,e.latencySampleCount=0,e.apiLatency.clear()),e.ewmaLatencyMs=e.ewmaLatencyMs===void 0?t:ie*t+(1-ie)*e.ewmaLatencyMs,e.latencySampleCount++,e.latencyUpdatedAt=i,r!==void 0){let o=e.apiLatency.get(r);!o||i-o.updatedAt>oe?e.apiLatency.set(r,{ewmaMs:t,sampleCount:1,updatedAt:i}):(o.ewmaMs=ie*t+(1-ie)*o.ewmaMs,o.sampleCount++,o.updatedAt=i);}}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),o=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(o.cooldownUntil>0&&o.cooldownUntil<=i||o.lastFailureTime>0&&i-o.lastFailureTime>3e4)&&(o.count=0,o.cooldownUntil=0),o.count++,o.lastFailureTime=i,o.count>=nt&&(o.cooldownUntil=i+it),r.apiFailures.set(t,o);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordDefectiveResponse(e,t){let r=this.getOrCreate(e),i=Date.now(),o=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};o.count=Math.max(o.count+1,nt),o.lastFailureTime=i,o.cooldownUntil=i+it,o.defective=true,r.apiFailures.set(t,o);}recordRateLimit(e,t){let r=this.getOrCreate(e),i=Date.now();r.rateLimitStreak>0&&i-r.lastRateLimitAt>ar&&(r.rateLimitStreak=0);let o=typeof t=="number"&&Number.isFinite(t)&&t>0,a=o?t:Math.min(or*2**r.rateLimitStreak,sr);o||r.rateLimitStreak++,r.lastRateLimitAt=i,r.rateLimitedUntil=o?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<=ot&&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 o=this.consensusHeadBlock();return !(o>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=ot&&o-r.headBlock>cr)}getOrderedNodes(e,t){let r=[],i=[];for(let c of e)this.isNodeHealthy(c,t)?r.push(c):i.push(c);if(r.length<=1)return [...r,...i];let o=Date.now(),a=r.map((c,f)=>({node:c,i:f,score:this.scoreNode(c,o)})).sort((c,f)=>c.score-f.score||c.i-f.i).map(c=>c.node),u=this.pickReprobeCandidate(r,o);return u&&a[0]!==u?[u,...a.filter(c=>c!==u),...i]:[...a,...i]}isLatencyUsable(e,t){return !!e&&e.ewmaLatencyMs!==void 0&&e.latencySampleCount>=Ie&&t-e.latencyUpdatedAt<=oe}scoreNode(e,t){let r=this.health.get(e);return this.isLatencyUsable(r,t)?r.ewmaLatencyMs:lt}pickReprobeCandidate(e,t){let r=t-ut,i,o=1/0;for(let a of e){let u=this.getOrCreate(a),c=Math.max(u.latencyUpdatedAt,u.lastProbeAt);c<=r&&c<o&&(i=a,o=c);}return i&&(this.getOrCreate(i).lastProbeAt=t),i}},k=new ge,Y=new ge,Le=class{constructor(){y(this,"tokens",d.resilience.hedgeBucketCapacity);}trySpend(){return this.clamp(),this.tokens>=1-1e-9?(this.tokens-=1,true):false}refill(){this.clamp(),this.tokens=Math.min(d.resilience.hedgeBucketCapacity,this.tokens+d.resilience.hedgeRefillPerSuccess);}clamp(){this.tokens>d.resilience.hedgeBucketCapacity&&(this.tokens=d.resilience.hedgeBucketCapacity);}get available(){return this.tokens}reset(e=d.resilience.hedgeBucketCapacity){this.tokens=e;}},Re=new Le;function be(n,e,t,r,i){let o=d.resilience;if(!o.adaptiveTimeout||i)return r;let a=n.getUsableLatencyMs(e,t);return a===void 0?r:Math.ceil(Math.min(r,Math.max(o.adaptiveTimeoutFloorMs,o.adaptiveTimeoutFactor*a)))}function Me(n,e,t,r){t instanceof X?t.isRateLimit?n.recordRateLimit(e,t.rateLimitMs||void 0):n.recordFailure(e,r):t instanceof N?n.recordFailure(e,r):n.recordFailure(e);}function dt(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 ur(){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 De(n){if(n=Math.ceil(n),typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(ur()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function _e(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 o=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:o}}var se=async(n,e,t,r=d.timeout,i=false,o)=>{let a=Math.floor(Math.random()*1e8),u={jsonrpc:"2.0",method:e,params:t,id:a},{signal:c,cleanup:f}=De(r),{signal:g,cleanup:v}=_e(c,o),S=()=>{f(),v();};try{let l=await fetch(n,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json",...Ne()},signal:g});if(l.status===429)throw new X(n,"HTTP 429 Rate Limited",{rateLimitMs:at(l.headers.get("Retry-After")),isRateLimit:!0});if(l.status>=500&&l.status<600)throw new X(n,`HTTP ${l.status} from ${n}`);let x=await l.json();if(!x||typeof x.id>"u"||x.id!==a||x.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in x)return x.result;if("error"in x){let B=x.error;throw "message"in B&&"code"in B?new N(B):x.error}throw x}catch(l){if(l instanceof N||l instanceof X||o?.aborted)throw l;if(i)return se(n,e,t,r,false,o);throw l}finally{S();}};function ye(){return re(50+Math.random()*50)}function lr(n){let{method:e,params:t,api:r,primary:i,hedgePool:o,callerTimeout:a,explicitTimeout:u,deadlineAt:c,externalSignal:f,onHedgeFired:g,validate:v}=n;return new Promise((S,l)=>{let x=false,B=0,T=false,j=false,b,$,ee=0,Q=[],H=I=>{if(!x){x=true,$!==void 0&&(clearTimeout($),$=void 0);for(let _ of Q)_.signal.aborted||_.abort();I();}},ue=(I,_)=>{B++;let z=new AbortController;Q.push(z);let te=_e(z.signal,f),Lt=be(k,I,e,a,u),Se=Date.now();_||(ee=Se),se(I,e,t,Lt,false,te.signal).then(M=>{if(te.cleanup(),B--,_||(j=true),!x){if(v&&!v(M)){if(k.recordDefectiveResponse(I,r),b=new Error(`[hive-tx] response validation failed for ${e} from ${I}`),!_&&!T){H(()=>l(b));return}B===0&&H(()=>l(b));return}k.recordSuccess(I,r,Date.now()-Se,e),dt(k,I,e,M),_?j||k.recordCensoredLatency(i,Date.now()-ee,e):T||Re.refill(),H(()=>S(M));}}).catch(M=>{if(te.cleanup(),B--,_||(j=true),!x){if(f?.aborted){H(()=>l(M));return}if(M instanceof N&&!Pe(M.code,M.message)){H(()=>l(M));return}if(Me(k,I,M,r),k.recordSlowFailure(I,Date.now()-Se,e),b=M,!_&&!T){H(()=>l(M));return}B===0&&H(()=>l(b));}});};ue(i,false);let ve=k.getUsableLatencyMs(i,e)??0,xe=be(k,i,e,a,u),Be=Math.min(Math.max(d.resilience.hedgeDelayFloorMs,d.resilience.hedgeDelayFactor*ve),.8*xe);$=setTimeout(()=>{if($=void 0,x||f?.aborted||Date.now()>=c)return;let I=o.filter(z=>k.isNodeHealthy(z,r));if(I.length===0)return;let _=I[Math.floor(Math.random()*I.length)];Re.trySpend()&&(T=true,g(_),ue(_,true));},Be);})}var we=async(n,e=[],t,r=d.retry,i,o)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an array");if(d.nodes.length===0)throw new Error("config.nodes is empty");let a=t!==void 0,u=t??d.timeout,c=ct(n),f=he;if(f&&st&&f.methodSet.has(n))if(Date.now()<ke)Z.skipped++;else try{let l=await er(f,n,e,u,i,o);return Z.served++,ne=0,l}catch(l){if(i?.aborted)throw l;Z.fallback++;let x=l instanceof W?l.reason:"transport";Z.fallbackByReason[x]=(Z.fallbackByReason[x]??0)+1,x==="rpcerror"?ne=0:++ne>=f.failureThreshold&&(ke=Date.now()+f.cooldownMs,ne=0);}let g=Date.now()+d.resilience.totalBudgetFactor*u,v=new Set,S;for(let l=0;l<=r&&!(l>0&&Date.now()>=g);l++){let x=k.getOrderedNodes(d.nodes,c),B=x.find(b=>!v.has(b));B||(v.clear(),B=x[0]),v.add(B);let T=[];if(d.resilience.hedge&&k.getUsableLatencyMs(B,n)!==void 0&&(T=x.filter(b=>!v.has(b)&&k.isNodeHealthy(b,c)).slice(0,3)),T.length>0)try{return await lr({method:n,params:e,api:c,primary:B,hedgePool:T,callerTimeout:u,explicitTimeout:a,deadlineAt:g,externalSignal:i,onHedgeFired:b=>v.add(b),validate:o})}catch(b){if(b instanceof N&&!Pe(b.code,b.message)||i?.aborted)throw b;S=b,l<r&&await ye();continue}let j=Date.now();try{let b=await se(B,n,e,be(k,B,n,u,a),!1,i);if(o&&!o(b)){k.recordDefectiveResponse(B,c),S=new Error(`[hive-tx] response validation failed for ${n} from ${B}`),l<r&&await ye();continue}return k.recordSuccess(B,c,Date.now()-j,n),Re.refill(),dt(k,B,n,b),b}catch(b){if(b instanceof N&&!Pe(b.code,b.message)||i?.aborted)throw b;Me(k,B,b,c),k.recordSlowFailure(B,Date.now()-j,n),S=b,l<r&&await ye();}}throw S},Fe=async(n,e=[],t=d.broadcastTimeout,r)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an array");if(d.nodes.length===0)throw new Error("config.nodes is empty");let i=ct(n),o=new Set,a;for(let u=0;u<d.nodes.length;u++){let f=k.getOrderedNodes(d.nodes,i).find(g=>!o.has(g));if(!f)break;if(o.add(f),r?.aborted)throw new Error("Aborted");try{let g=await se(f,n,e,t,!1,r);return k.recordSuccess(f,i),g}catch(g){if(g instanceof N||r?.aborted||(Me(k,f,g,i),a=g,!ir(g)))throw g}}throw a},fr={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 dr(n,e,t,r,i=d.retry,o){if(!Array.isArray(d.restNodes))throw new Error("config.restNodes is not an array");if(d.restNodes.length===0)throw new Error("config.restNodes is empty");let a=r!==void 0,u=r??d.timeout,c=Date.now()+d.resilience.totalBudgetFactor*u,f=`${n}:${e}`,g=d.restNodesByApi?.[n]?.length?d.restNodesByApi[n]:d.restNodes,v=new Set,S,l=false;for(let x=0;x<=i&&!(x>0&&Date.now()>=c);x++){let B=Y.getOrderedNodes(g,n),T=B.find(_=>!v.has(_));T||(v.clear(),T=B[0]),v.add(T);let j=T+fr[n],b=e,$=t||{},ee=new Set;Object.entries($).forEach(([_,z])=>{b.includes(`{${_}}`)&&(b=b.replace(`{${_}}`,encodeURIComponent(String(z))),ee.add(_));});let Q=new URL(j+b);if(Object.entries($).forEach(([_,z])=>{ee.has(_)||(Array.isArray(z)?z.forEach(te=>Q.searchParams.append(_,String(te))):Q.searchParams.set(_,String(z)));}),o?.aborted)throw new Error("Aborted");l=false;let{signal:H,cleanup:ue}=De(be(Y,T,f,u,a)),{signal:ve,cleanup:xe}=_e(H,o),Be=()=>{ue(),xe();},I=Date.now();try{let _=await fetch(Q.toString(),{signal:ve,headers:Ne()});if(_.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(_.status===429)throw Y.recordRateLimit(T,at(_.headers.get("Retry-After"))||void 0),l=!0,new Error(`HTTP 429 Rate Limited by ${T}`);if(_.status===503)throw Y.recordFailure(T,n),l=!0,new Error(`HTTP 503 Service Unavailable from ${T}`);if(!_.ok)throw Y.recordFailure(T,n),l=!0,new Error(`HTTP ${_.status} from ${T}`);return Y.recordSuccess(T,n,Date.now()-I,f),_.json()}catch(_){if(_?.message?.includes("HTTP 404")||o?.aborted)throw _;l||Y.recordFailure(T,n),Y.recordSlowFailure(T,Date.now()-I,f),S=_,x<i&&await ye();}finally{Be();}}throw S}var hr=async(n,e=[],t=2,r)=>{if(!Array.isArray(d.nodes))throw new Error("config.nodes is not an Array");if(t>d.nodes.length)throw new Error("quorum > config.nodes.length");let o=(c=>{let f=[...c];for(let g=f.length-1;g>0;g--){let v=Math.floor(Math.random()*(g+1));[f[g],f[v]]=[f[v],f[g]];}return f})(d.nodes),a=Math.min(t,o.length),u=[];for(;a>0&&o.length>0;){let c=o.splice(0,a),f=[],g=[];for(let S=0;S<c.length;S++)f.push(se(c[S],n,e,void 0,true,r).then(l=>g.push(l)).catch(()=>{}));await Promise.all(f),u.push(...g);let v=mr(u,t);if(v)return v;if(a=Math.min(t,o.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function mr(n,e){let t=new Map;for(let i of n){let o=JSON.stringify(i);t.has(o)||t.set(o,[]),t.get(o).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var yr=hexToBytes(d.chain_id),Ce=class n{constructor(e){y(this,"transaction");y(this,"expiration",6e4);y(this,"txId");y(this,"createTransaction",async e=>{let t=await we("condenser_api.get_dynamic_global_properties",[]),r=hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),o=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:o,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 o=i.sign(t);this.transaction.signatures.push(o.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 Fe("condenser_api.broadcast_transaction",[this.transaction]);}catch(o){if(!(o instanceof N&&o.message.includes("Duplicate transaction check failed")))throw o}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await re(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 re(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 A(A.DEFAULT_CAPACITY,A.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([...yr,...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),we("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}};var bt=new Uint8Array([128]),ce=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(wr(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 o=e.charCodeAt(i);if(o<128)r.push(o);else if(o<2048)r.push(192|o>>6,128|o&63);else if(o>=55296&&o<=56319&&i+1<e.length){let a=e.charCodeAt(++i);o=65536+((o&1023)<<10)+(a&1023),r.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63);}else r.push(224|o>>12,128|o>>6&63,128|o&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 J.from((r+31).toString(16)+bytesToHex(t.subarray(1)))}createPublic(e){return new L(secp256k1.getPublicKey(this.key),e)}toString(){return _r(new Uint8Array([...bt,...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)}},_t=n=>sha256(sha256(n)),_r=n=>{let e=_t(n);return Je.encode(new Uint8Array([...n,...e.slice(0,4)]))},wr=n=>{let e=Je.decode(n);if(!yt(e.slice(0,1),bt))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=_t(r).slice(0,4);if(!yt(t,i))throw new Error("Private key checksum mismatch");return r},yt=(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 At=(n,e,t,r=Tr())=>xt(n,e,r,t),vt=(n,e,t,r,i)=>xt(n,e,t,r,i).message,xt=(n,e,t,r,i)=>{let o=t,a=n.getSharedSecret(e),u=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);u.writeUint64(o),u.append(a),u.flip();let c=sha512(new Uint8Array(u.toBuffer())),f=c.subarray(32,48),g=c.subarray(0,32),v=sha256(c).subarray(0,4),S=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);S.append(v),S.flip();let l=S.readUint32();if(i!==void 0){if(l!==i)throw new Error("Invalid key");r=Br(r,g,f);}else r=Sr(r,g,f);return {nonce:o,message:r,checksum:l}},Br=(n,e,t)=>{let r=n;return r=cbc(e,t).decrypt(r),r},Sr=(n,e,t)=>{let r=n;return r=cbc(e,t).encrypt(r),r},ze=null,Tr=()=>{if(ze===null){let t=secp256k1.utils.randomSecretKey();ze=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++ze%65536;return n=n<<BigInt(16)|BigInt(e),n};var Bt=n=>{let e=Lr(n,33);return new L(e)},Er=n=>n.readUint64(),kr=n=>n.readUint32(),Pr=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},Ir=n=>e=>{let t={},r=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,o]of n)try{t[i]=o(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function Lr(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 Rr=Ir([["from",Bt],["to",Bt],["nonce",Er],["check",kr],["encrypted",Pr]]),St={Memo:Rr};var Ut=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),kt(),n=Pt(n),e=Nr(e);let i=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);i.writeVString(t);let o=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:u,checksum:c}=At(n,e,o,r),f=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);O.Memo(f,{check:c,encrypted:u,from:n.createPublic(),nonce:a,to:e}),f.flip();let g=new Uint8Array(f.toBuffer());return "#"+Je.encode(g)},Et=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),kt(),n=Pt(n);let t=St.Memo(Je.decode(e)),{from:r,to:i,nonce:o,check:a,encrypted:u}=t,f=n.createPublic().toString()===new L(r.key).toString()?new L(i.key):new L(r.key);t=vt(n,f,o,u,a);let g=new A(A.DEFAULT_CAPACITY,A.LITTLE_ENDIAN);return g.append(t),g.flip(),"#"+g.readVString()},Ae,kt=()=>{if(Ae===void 0){let n;Ae=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Ut(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=Et(e,r);}finally{Ae=n==="#memo\u7231";}}if(Ae===false)throw new Error("This environment does not support encryption.")},Pt=n=>typeof n=="string"?ce.fromString(n):n,Nr=n=>typeof n=="string"?L.fromString(n):n,Mr={decode:Et,encode:Ut};var It={};Nt(It,{buildWitnessSetProperties:()=>Kr,makeBitMaskFilter:()=>Or,operations:()=>Cr,validateUsername:()=>Fr});var Fr=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 o=0;o<i;o++){let a=r[o];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},Cr={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},Or=n=>n.reduce(zr,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),zr=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Kr=(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,Hr(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},Hr=(n,e)=>{let t=new A(A.DEFAULT_CAPACITY,A.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{Ve as DEFAULT_SERVER_RPC_PROXY_METHODS,Mr as Memo,ae as PrivateKey,L as PublicKey,N as RPCError,J as Signature,Ce as Transaction,dr as callREST,we as callRPC,Fe as callRPCBroadcast,hr as callWithQuorum,d as config,Zt as resetRpcProxyBreaker,Z as rpcProxyStats,Ft as setNodes,Kt as setResilience,Ct as setRestNodes,Ot as setRestNodesByApi,Dt as setServerRpcProxy,zt as setUserAgent,It as utils};//# sourceMappingURL=hive.js.map
8
+ */export{Ve as DEFAULT_SERVER_RPC_PROXY_METHODS,Mr as Memo,ce as PrivateKey,L as PublicKey,N as RPCError,J as Signature,Ce as Transaction,dr as callREST,we as callRPC,Fe as callRPCBroadcast,hr as callWithQuorum,d as config,Zt as resetRpcProxyBreaker,Z as rpcProxyStats,Ft as setNodes,Kt as setResilience,Ct as setRestNodes,Ot as setRestNodesByApi,Dt as setServerRpcProxy,zt as setUserAgent,It as utils};//# sourceMappingURL=hive.js.map
9
9
  //# sourceMappingURL=hive.js.map