PageSourceSearch

https://crystara.trade/_next/static/chunks/8893bd39-61f59ceadaf2d94b.js

js crystara.trade collected 2026-10-07 19:14:57 UTC 217,759 bytes, 472 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6588],{8796:function(e,t,i){let r,n,s,a,o,c,u,l,d;function p(e){return e&&e.__esModule?e:{default:e}}function h(e,t){return null!=e?e:t()}function g(e){let t;let i=e[0],r=1;for(;r<e.length;){let n=e[r],s=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==i)return;"access"===n||"optionalAccess"===n?(t=i,i=s(i)):("call"===n||"optionalCall"===n)&&(i=s((...e)=>i.call(t,...e)),t=void 0)}return i}Object.defineProperty(t,"__esModule",{value:!0});var f,y=i(22611),m=class e{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(t){return new e(y.j.hexInputToUint8Array(t))}read(e){if(this.offset+e>this.buffer.byteLength)throw Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(0!==this.remaining())throw Error("Buffer has remaining bytes")}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if("string"===e)return this.deserializeStr();if("bytes"===e)return this.deserializeBytes();if("fixedBytes"===e){if(void 0===t)throw Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(1!==e&&0!==e)throw Error("Invalid boolean value");return 1===e}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32();return BigInt(BigInt(this.deserializeU32())<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64();return BigInt(this.deserializeU64()<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128();return BigInt(this.deserializeU128()<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<y.d;){let i=this.deserializeU8();if(e|=BigInt(127&i)<<BigInt(t),(128&i)==0)break;t+=7}if(e>y.d)throw Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),i=[];for(let r=0;r<t;r+=1)i.push(this.deserialize(e));return i}},_=class e extends y.l{constructor(e){super(),this.value=y.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(t,i){return new e(t.deserializeFixedBytes(i))}},A=class e extends y.l{constructor(e){super(),this.value=new _(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(t,i){return new e(_.deserialize(t,i).value)}},w=class e extends y.l{constructor(e){super(),y.n.call(void 0,e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new z(e.deserializeU256())}static deserialize(t){return new e(t.deserializeBool())}},b=t.U8=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,0,y.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(t){return new e(t.deserializeU8())}},v=t.U16=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,0,y.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(t){return new e(t.deserializeU16())}},T=t.U32=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,0,y.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(t){return new e(t.deserializeU32())}},E=t.U64=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,BigInt(0),y.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(t){return new e(t.deserializeU64())}},S=t.U128=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,BigInt(0),y.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(t){return new e(t.deserializeU128())}},z=t.U256=class e extends y.l{constructor(e){super(),y.p.call(void 0,e,BigInt(0),y.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(t){return new e(t.deserializeU256())}},C=class e extends y.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}
1serializeForScriptFunction(e){if(void 0!==this.values[0]&&!(this.values[0]instanceof b)){new U(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(t){let i;if(Array.isArray(t)&&0===t.length)i=[];else if(Array.isArray(t)&&"number"==typeof t[0])i=t;else if("string"==typeof t)i=Array.from(y.j.fromHexInput(t).toUint8Array());else if(t instanceof Uint8Array)i=Array.from(t);else throw Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new e(i.map(e=>new b(e)))}static U16(t){return new e(t.map(e=>new v(e)))}static U32(t){return new e(t.map(e=>new T(e)))}static U64(t){return new e(t.map(e=>new E(e)))}static U128(t){return new e(t.map(e=>new S(e)))}static U256(t){return new e(t.map(e=>new z(e)))}static Bool(t){return new e(t.map(e=>new w(e)))}static MoveString(t){return new e(t.map(e=>new x(e)))}serialize(e){e.serializeVector(this.values)}static deserialize(t,i){let r=t.deserializeUleb128AsU32(),n=[];for(let e=0;e<r;e+=1)n.push(i.deserialize(t));return new e(n)}},U=t.Serialized=class e extends y.l{constructor(e){super(),this.value=y.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(t){return new e(t.deserializeBytes())}toMoveVector(e){let t=new m(this.bcsToBytes());return t.deserializeUleb128AsU32(),new C(t.deserializeVector(e))}},x=t.MoveString=class e extends y.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=new TextEncoder().encode(this.value);C.U8(t).serializeForScriptFunction(e)}static deserialize(t){return new e(t.deserializeStr())}},k=t.MoveOption=class e extends y.l{constructor(e){super(),"u">typeof e&&null!==e?this.vec=new C([e]):this.vec=new C([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw Error("Called unwrap on a MoveOption with no value")}isSome(){return 1===this.vec.values.length}serialize(e){this.vec.serialize(e)}static U8(t){return new e(null!=t?new b(t):void 0)}static U16(t){return new e(null!=t?new v(t):void 0)}static U32(t){return new e(null!=t?new T(t):void 0)}static U64(t){return new e(null!=t?new E(t):void 0)}static U128(t){return new e(null!=t?new S(t):void 0)}static U256(t){return new e(null!=t?new z(t):void 0)}static Bool(t){return new e(null!=t?new w(t):void 0)}static MoveString(t){return new e(null!=t?new x(t):void 0)}static deserialize(t,i){return new e(C.deserialize(t,i).values[0])}},P=i(32517),K=class e extends y.l{constructor(t){super();let{data:i}=t,r=y.j.fromHexInput(i);if(r.toUint8Array().length!==e.LENGTH)throw Error(`Authentication Key length should be ${e.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(t){let i=t.deserializeFixedBytes(e.LENGTH);return new e({data:i})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(t){let{scheme:i,input:r}=t,n=new Uint8Array([...y.j.fromHexInput(r).toUint8Array(),i]),s=P.sha3_256.create();return s.update(n),new e({data:s.digest()})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new y.ba(this.data.toUint8Array())}};K.LENGTH=32;var I=class extends y.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return y.j.fromHexInput(e).toString()}},N=t.AccountPublicKey=class extends I{},$=class extends y.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return y.j.fromHexInput(e).toString()}},F=class e extends ${constructor(e){super(),this.value=y.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(t){return new e(t.deserializeBytes())}},R=t.AbstractPublicKey=class extends N{constructor(e){super(),this.accountAddress=e}authKey(){return new K({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw Error("This function is not implemented for AbstractPublicKey.")}}
1,B=i(37822),D=i(26530),O=i(27398),L=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(i(64775)),M=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,V=t.APTOS_BIP44_REGEX=/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,q=t.KeyType=((r=q||{}).ED25519="ed25519 seed",r),H=t.HARDENED_OFFSET=2147483648;function j(e){return V.test(e)}function G(e){return M.test(e)}var W=(e,t)=>{let i=D.hmac.create(O.sha512,e).update(t).digest();return{key:i.slice(0,32),chainCode:i.slice(32)}},J=t.CKDPriv=({key:e,chainCode:t},i)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,i);let n=new Uint8Array(r),s=new Uint8Array([0]);return W(t,new Uint8Array([...s,...e,...n]))},Y=e=>e.replace(/'/g,""),X=t.splitPath=e=>e.split("/").slice(1).map(Y),Z=t.mnemonicToSeed=e=>{let t=e.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return L.mnemonicToSeedSync(t)},Q=class e{static formatPrivateKey(t,i){let r=e.AIP80_PREFIXES[i],n=t;return"string"==typeof n&&n.startsWith(r)&&(n=n.split("-")[2]),`${r}${y.j.fromHexInput(n).toString()}`}static parseHexInput(t,i,r){let n,s=e.AIP80_PREFIXES[i];if("string"==typeof t){if(r||t.startsWith(s)){if(t.startsWith(s))n=y.j.fromHexString(t.split("-")[2]);else throw r?Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):Error("Invalid HexString input while parsing private key.")}else n=y.j.fromHexInput(t),!1!==r&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.")}else n=y.j.fromHexInput(t);return n}};Q.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var ee=e=>"string"==typeof e?y.j.isValid(e).valid?e:new TextEncoder().encode(e):e,et=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function ei(e){let t=e.toUint8Array().slice(32);for(let e=et.length-1;e>=0;e-=1){if(t[e]<et[e])return!0;if(t[e]>et[e])break}return!1}var er=class e extends N{constructor(t){super();let i=y.j.fromHexInput(t);if(i.toUint8Array().length!==e.LENGTH)throw Error(`PublicKey length should be ${e.LENGTH}`);this.key=i}verifySignature(e){let{message:t,signature:i}=e;if(!ei(i))return!1;let r=ee(t),n=y.j.fromHexInput(r).toUint8Array(),s=i.toUint8Array(),a=this.key.toUint8Array();return B.ed25519.verify(s,n,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return K.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(t){return new e(t.deserializeBytes())}static isPublicKey(t){return t instanceof e}static isInstance(t){return"key"in t&&g([t,"access",e=>e.key,"optionalAccess",e=>e.data,"optionalAccess",e=>e.length])===e.LENGTH}};er.LENGTH=32;var en=class e extends y.l{constructor(t,i){super();let r=Q.parseHexInput(t,"ed25519",i);if(r.toUint8Array().length!==e.LENGTH)throw Error(`PrivateKey length should be ${e.LENGTH}`);this.signingKey=r}static generate(){return new e(B.ed25519.utils.randomPrivateKey(),!1)}static fromDerivationPath(t,i){if(!G(t))throw Error(`Invalid derivation path ${t}`);return e.fromDerivationPathInner(t,Z(i))}static fromDerivationPathInner(t,i,r=H){let{key:n,chainCode:s}=W(e.SLIP_0010_SEED,i),{key:a}=X(t).map(e=>parseInt(e,10)).reduce((e,t)=>J(e,t+r),{key:n,chainCode:s});return new e(a,!1)}publicKey(){return new er(B.ed25519.getPublicKey(this.signingKey.toUint8Array()))}sign(e){let t=ee(e),i=y.j.fromHexInput(t).toUint8Array();return new ea(B.ed25519.sign(i,this.signingKey.toUint8Array()))}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Q.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(t){return new e(t.deserializeBytes(),!1)}static isPrivateKey(t){return t instanceof e}};en.LENGTH=32,en.SLIP_0010_SEED="ed25519 seed";var es=class e extends ${constructor(t){super();let i=y.j.fromHexInput(t);if(i.toUint8Array().length!==e.LENGTH)throw Error(`Signature length should be ${e.LENGTH}`);this.data=i}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(t){return new e(t.deserializeBytes())}};es.LENGTH=64;var ea=es,eo=class e extends I{constructor(e){super();let t=e.constructor.name;if(t===er.name)this.publicKey=e,this.variant=0;else throw Error(`Unsupported key for EphemeralPublicKey - ${t}`)}verifySignature(e){let{message:t,signature:i}=e;return this.publicKey.verifySignature({message:t,signature:i.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof er)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw Error("Unknown public key type")}static deserialize(t){let i=t.deserializeUleb128AsU32();if(0===i)return new e(er.deserialize(t));throw Error(`Unknown variant index for EphemeralPublicKey: ${i}`)}static isPublicKey(t){return t instanceof e}},ec=t.EphemeralSignature=class e extends ${constructor(e){super();let t=e.constructor.name;if(t===ea.name)this.signature=e;else throw Error(`Unsupported signature for EphemeralSignature - ${t}`)}static fromHex(t){let i=new m(y.j.fromHexInput(t).toUint8Array());return e.deserialize(i)}serialize(e){if(this.signature instanceof ea)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw Error("Unknown signature type")}static deserialize(t){let i=t.deserializeUleb128AsU32();if(0===i)return new e(ea.deserialize(t));throw Error(`Unknown variant index for EphemeralSignature: ${i}`)}},eu=i(62874),el=i(41489),ed=[el.poseidon1,el.poseidon2,el.poseidon3,el.poseidon4,el.poseidon5,el.poseidon6,el.poseidon7,el.poseidon8,el.poseidon9,el.poseidon10,el.poseidon11,el.poseidon12,el.poseidon13,el.poseidon14,el.poseidon15,el.poseidon16];function ep(e,t){return function(e,t){if(e.length>t)throw Error(`Inputted bytes of length ${e} is longer than ${t}`);return ey(eh(e,t))}(new TextEncoder().encode(e),t)}function eh(e,t){if(e.length>t)throw Error(`Input bytes of length ${e} is longer than ${t}`);return(function(e,t){if(e.length>t)throw Error(`Input bytes of length ${e} is longer than ${t}`);return function(e){if(e.length>465)throw Error(`Can't pack more than 465.  Was given ${e.length} bytes`);return(function(e,t){let i=[];for(let t=0;t<e.length;t+=31)i.push(e.subarray(t,t+31));return i})(e,31).map(e=>eg(e))}(function(e,t){if(t<e.length)throw Error("Padded size must be greater than or equal to the input array size.");let i=new Uint8Array(t);i.set(e);for(let r=e.length;r<t;r+=1)i[r]=0;return i}(e,t))})(e,t).concat([BigInt(e.length)])}function eg(e){let t=BigInt(0);for(let i=e.length-1;i>=0;i-=1)t=t<<BigInt(8)|BigInt(e[i]);return t}function ef(e,t){let i=BigInt(e),r=new Uint8Array(t);for(let e=0;e<t;e+=1)r[e]=Number(i&BigInt(255)),i>>=BigInt(8);return r}function ey(e){if(e.length>ed.length)throw Error(`Unable to hash input of length ${e.length}.  Max input length is ${ed.length}`);return ed[e.length-1](e)}var em=class extends y.l{},e_={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},eA=t.NetworkToNodeAPI={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},ew=t.NetworkToFaucetAPI={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},eb=t.NetworkToPepperAPI={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ev=t.NetworkToProverAPI={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},eT=t.Network=((n=eT||{}).MAINNET="mainnet",n.TESTNET="testnet",n.DEVNET="devnet",n.LOCAL="local",n.CUSTOM="custom",n),eE=t.NetworkToChainId={mainnet:1,testnet:2,local:4},eS=t.NetworkToNetworkName={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"},ez=((s=ez||{}).FULLNODE="Fullnode",s.INDEXER="Indexer",s.FAUCET="Faucet",s.PEPPER="Pepper",s.PROVER="Prover",s),eC=t.DEFAULT_MAX_GAS_AMOUNT=2e5,eU=t.DEFAULT_TXN_EXP_SEC_FROM_NOW=20,ex=t.DEFAULT_TXN_TIMEOUT_SEC=20,ek=t.APTOS_COIN="0x1::aptos_coin::AptosCoin",eP=t.APTOS_FA="0x000000000000000000000000000000000000000000000000000000000000000a",eK=t.RAW_TRANSACTION_SALT="APTOS::RawTransaction",eI=t.RAW_TRANSACTION_WITH_DATA_SALT="APTOS::RawTransactionWithData",eN=t.ProcessorType=((a=eN||{}).ACCOUNT_RESTORATION_PROCESSOR="account_restoration_processor",a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a.OBJECT_PROCESSOR="objects_processor",a),e$=t.FIREBASE_AUTH_ISS_PATTERN=/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function eF(e,t){let i=new m(t.bcsToBytes());return e.deserialize(i)}var eR=((o=eR||{})[o.API_ERROR=0]="API_ERROR",o[o.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",o[o.SESSION_EXPIRED=2]="SESSION_EXPIRED",o[o.INVALID_STATE=3]="INVALID_STATE",o[o.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",o[o.UNKNOWN=5]="UNKNOWN",o),eB=t.KeylessErrorResolutionTip=((c=eB||{}).REAUTHENTICATE="Re-authentiate to continue using your keyless account",c.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",c.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",c.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests.  Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",c.SERVER_ERROR="Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",c.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",c.REINSTANTIATE="Try instantiating the account again.  Avoid manipulating the account object directly",c.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",c.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",c),eD=t.KeylessErrorType=((u=eD||{})[u.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",u[u.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",u[u.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",u[u.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",u[u.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",u[u.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",u[u.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",u[u.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",u[u.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",u[u.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",u[u.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",u[u.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",u[u.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",u[u.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",u[u.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",u[u.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",u[u.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",u[u.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",u[u.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",u[u.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",u[u.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",u[u.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",u[u.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",u[u.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",u[u.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",u[u.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",u[u.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",u[u.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",u[u.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",u[u.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",u[u.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",u[u.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",u[u.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",u[u.UNKNOWN=33]="UNKNOWN",u),eO={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invali
1d.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests.  Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again.  Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later.  See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]}
1,eL=t.KeylessError=class e extends Error{constructor(t){let{innerError:i,category:r,resolutionTip:n,type:s,message:a=eO[s][0],details:o}=t;super(a),this.name="KeylessError",this.innerError=i,this.category=r,this.resolutionTip=n,this.type=s,this.details=o,this.message=e.constructMessage(a,n,i,o)}static constructMessage(e,t,i,r){let n=`
2Message: ${e}`;return r&&(n+=`
3Details: ${r}`),i instanceof eM?n+=`
4AptosApiError: ${i.message}`:void 0!==i&&(n+=`
5Error: ${y.ga.call(void 0,i)}`),n+=`
6KeylessErrorResolutionTip: ${t}`}static fromErrorType(t){let{error:i,type:r,details:n}=t,[s,a,o]=eO[r];return new e({message:s,details:n,innerError:i,category:a,resolutionTip:o,type:r})}},eM=t.AptosApiError=class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:i}){super(function({apiType:e,aptosRequest:t,aptosResponse:i}){let r,n=g([i,"access",e=>e.headers,"optionalAccess",e=>e.traceparent,"optionalAccess",e=>e.split,"call",e=>e("-"),"access",e=>e[1]]),s=n?`(trace_id:${n}) `:"",a=`Request to [${e}]: ${t.method} ${h(i.url,()=>t.url)} ${s}failed with`;return"Indexer"===e&&null!=g([i,"access",e=>e.data,"optionalAccess",e=>e.errors,"optionalAccess",e=>e[0],"optionalAccess",e=>e.message])?`${a}: ${i.data.errors[0].message}`:null!=g([i,"access",e=>e.data,"optionalAccess",e=>e.message])&&null!=g([i,"access",e=>e.data,"optionalAccess",e=>e.error_code])?`${a}: ${JSON.stringify(i.data)}`:`${a} status: ${i.statusText}(code:${i.status}) and response body: ${(r=JSON.stringify(i.data)).length<=400?r:`truncated(original_size:${r.length}): ${r.slice(0,200)}...${r.slice(-200)}`}`}({apiType:e,aptosRequest:t,aptosResponse:i})),this.name="AptosApiError",this.url=i.url,this.status=i.status,this.statusText=i.statusText,this.data=i.data,this.request=t}};async function eV(e,t){let{url:i,method:r,body:n,contentType:s,params:a,overrides:o,originMethod:c}=e,u={...g([o,"optionalAccess",e=>e.HEADERS]),"x-aptos-client":"aptos-typescript-sdk/4.0.0","content-type":h(s,()=>"application/json"),"x-aptos-typescript-sdk-origin-method":c};return g([o,"optionalAccess",e=>e.AUTH_TOKEN])&&(u.Authorization=`Bearer ${g([o,"optionalAccess",e=>e.AUTH_TOKEN])}`),g([o,"optionalAccess",e=>e.API_KEY])&&(u.Authorization=`Bearer ${g([o,"optionalAccess",e=>e.API_KEY])}`),t.provider({url:i,method:r,body:n,params:a,headers:u,overrides:o})}async function eq(e,t,i){let{url:r,path:n}=e,s=n?`${r}/${n}`:r,a=await eV({...e,url:s},t.client),o={status:a.status,statusText:h(a.statusText,()=>"No status text provided"),data:a.data,headers:a.headers,config:a.config,request:a.request,url:s};if(401===o.status)throw new eM({apiType:i,aptosRequest:e,aptosResponse:o});if("Indexer"===i){let t=o.data;if(t.errors)throw new eM({apiType:i,aptosRequest:e,aptosResponse:o});o.data=t.data}else if(("Pepper"===i||"Prover"===i)&&o.status>=400)throw new eM({apiType:i,aptosRequest:e,aptosResponse:o});if(o.status>=200&&o.status<300)return o;throw new eM({apiType:i,aptosRequest:e,aptosResponse:o})}async function eH(e){let{aptosConfig:t,overrides:i,params:r,contentType:n,acceptType:s,path:a,originMethod:o,type:c}=e;return eq({url:t.getRequestUrl(c),method:"GET",originMethod:o,path:a,contentType:n,acceptType:s,params:r,overrides:{...t.clientConfig,...i}},t,e.type)}async function ej(e){let{aptosConfig:t}=e;return eH({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...g([t,"access",e=>e.clientConfig,"optionalAccess",e=>e.HEADERS]),...g([t,"access",e=>e.fullnodeConfig,"optionalAccess",e=>e.HEADERS])}}})}async function eG(e){return eH({...e,type:"Pepper"})}async function eW(e){let t=[],i,r=e.params;do{let n=await eH({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:r,overrides:e.overrides});i=n.headers["x-aptos-cursor"],delete n.headers,t.push(...n.data),r.start=i}while(null!=i);return t}async function eJ(e){let t=[],i,r=e.params,n=r.limit;do{let{response:s,cursor:a}=await eY({...e});if(i=a,t.push(...s.data),g([e,"optionalAccess",e=>e.params])&&(e.params.start=i),void 0!==n){let e=n-t.length;if(e<=0)break;r.limit=e}}while(null!=i);return t}async function eY(e){let t,i={};"string"==typeof g([e,"access",e=>e.params,"optionalAccess",e=>e.cursor])&&(i.start=e.params.cursor),"number"==typeof g([e,"access",e=>e.params,"optionalAccess",e=>e.limit])&&(i.limit=e.params.limit);let r=await eH({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:i,overrides:e.overrides});return t=r.headers["x-aptos-cursor"],{response:r,cursor:t}}async function eX(e){let{type:t,originMethod:i,path:r,body:n,acceptType:s,contentType:a,params:o,aptosConfig:c,overrides:u}=e;return eq({url:c.getRequestUrl(t),method:"POST",originMethod:i,path:r,body:n,contentType:a,acceptType:s,params:o,overrides:u},c,e.type)}async function eZ(e){let{aptosConfig:t}=e;return eX({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...g([t,"access",e=>e.clientConfig,"optionalAccess",e=>e.HEADERS]),...g([t,"access",e=>e.fullnodeConfig,"optionalAccess",e=>e.HEADERS])}}})}async function eQ(e){let{aptosConfig:t}=e;return eX({...e,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...e.overrides,HEADERS:{...g([t,"access",e=>e.clientConfig,"optionalAccess",e=>e.HEADERS]),...g([t,"access",e=>e.indexerConfig,"optionalAccess",e=>e.HEADERS])}}})}async function e0(e){let{aptosConfig:t}=e,i={...t,clientConfig:{...t.clientConfig}};return g([i,"optionalAccess",e=>e.clientConfig,"optionalAccess",e=>delete e.API_KEY]),eX({...e,type:"Faucet",overrides:{...i.clientConfig,...i.faucetConfig,...e.overrides,HEADERS:{...g([i,"access",e=>e.clientConfig,"optionalAccess",e=>e.HEADERS]),...g([i,"access",e=>e.faucetConfig,"optionalAccess",e=>e.HEADERS])}}})}async function e2(e){return eX({...e,type:"Pepper"})}async function e1(e){return eX({...e,type:"Prover"})}var e8=new Map;function e3(e,t,i){return async(...r)=>{if(e8.has(t)){let{value:e,timestamp:r}=e8.get(t);if(void 0===i||Date.now()-r<=i)return e}let n=await e(...r);return e8.set(t,{value:n,timestamp:Date.now()}),n}}var e5=i(36672),e6=i(36170),e4=i(89395),e9=t.MAX_AUD_VAL_BYTES=120,e7=t.MAX_UID_KEY_BYTES=30,te=t.MAX_UID_VAL_BYTES=330,tt=t.MAX_ISS_VAL_BYTES=120,ti=t.MAX_EXTRA_FIELD_BYTES=350,tr=t.MAX_JWT_HEADER_B64_BYTES=300,tn=t.MAX_COMMITED_EPK_BYTES=93,ts=class e extends N{constructor(t,i){super();let r=y.j.fromHexInput(i).toUint8Array();if(r.length!==e.ID_COMMITMENT_LENGTH)throw Error(`Id Commitment length in bytes should be ${e.ID_COMMITMENT_LENGTH}`);this.iss=t,this.idCommitment=r}authKey(){let e=new y.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),K.fromSchemeAndBytes({sc
6heme:2,input:e.toUint8Array()})}verifySignature(e){try{return to({...e,publicKey:this}),!0}catch(e){if(e instanceof eL)return!1;throw e}}async verifySignatureAsync(e){return ta({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(t){return new e(t.deserializeStr(),t.deserializeBytes())}static load(t){return new e(t.deserializeStr(),t.deserializeBytes())}static isPublicKey(t){return t instanceof e}static create(t){return tu(t),new e(t.iss,tu(t))}static fromJwtAndPepper(t){let{jwt:i,pepper:r,uidKey:n="sub"}=t,s=eu.jwtDecode.call(void 0,i);if("string"!=typeof s.iss)throw Error("iss was not found");if("string"!=typeof s.aud)throw Error("aud was not found or an array of values");let a=s[n];return e.create({iss:s.iss,uidKey:n,uidVal:a,aud:s.aud,pepper:r})}static isInstance(e){return"iss"in e&&"string"==typeof e.iss&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};async function ta(e){let{aptosConfig:t,publicKey:i,message:r,signature:n,jwk:s,keylessConfig:a=await tb({aptosConfig:t}),options:o}=e;try{if(!(n instanceof tl))throw eL.fromErrorType({type:26,details:"Not a keyless signature"});return to({message:r,publicKey:i,signature:n,jwk:s||await tc({aptosConfig:t,publicKey:i,kid:n.getJwkKid()}),keylessConfig:a}),!0}catch(e){if(g([o,"optionalAccess",e=>e.throwErrorWithReason]))throw e;return!1}}function to(e){let{publicKey:t,message:i,signature:r,keylessConfig:n,jwk:s}=e,{verificationKey:a,maxExpHorizonSecs:o,trainingWheelsPubkey:c}=n;if(!(r instanceof tl))throw eL.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof t_))throw eL.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let u=r.ephemeralCertificate.signature;if(!(u.proof.proof instanceof tf))throw eL.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=u.proof.proof;if(r.expiryDateSecs<y.ha.call(void 0))throw eL.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(u.expHorizonSecs>o)throw eL.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:i,signature:r.ephemeralSignature}))throw eL.fromErrorType({type:29});let d=function(e){let{publicKey:t,signature:i,jwk:r,keylessConfig:n}=e,s=t instanceof ts?t:t.keylessPublicKey;if(!(i.ephemeralCertificate.signature instanceof t_))throw Error("Signature is not a ZeroKnowledgeSig");let a=i.ephemeralCertificate.signature,o=[];return o.push(...eh(i.ephemeralPublicKey.toUint8Array(),n.maxCommitedEpkBytes)),o.push(eg(s.idCommitment)),o.push(i.expiryDateSecs),o.push(a.expHorizonSecs),o.push(ep(s.iss,n.maxIssValBytes)),a.extraField?(o.push(1n),o.push(ep(a.extraField,n.maxExtraFieldBytes))):(o.push(0n),o.push(ep(" ",n.maxExtraFieldBytes))),o.push(ep(e4.encode.call(void 0,i.jwtHeader,!0)+".",n.maxJwtHeaderB64Bytes)),o.push(r.toScalar()),a.overrideAudVal?(o.push(ep(a.overrideAudVal,e9)),o.push(1n)):(o.push(ep("",e9)),o.push(0n)),ey(o)}({publicKey:t,signature:r,jwk:s,keylessConfig:n});if(!a.verifyProof({publicInputsHash:d,groth16Proof:l}))throw eL.fromErrorType({type:32});if(c){if(!u.trainingWheelsSignature)throw eL.fromErrorType({type:30});let e=new ty(l,d);if(!c.verifySignature({message:e.hash(),signature:u.trainingWheelsSignature}))throw eL.fromErrorType({type:31})}}async function tc(e){let{aptosConfig:t,publicKey:i,kid:r}=e,{iss:n}=i instanceof ts?i:i.keylessPublicKey,s,a=i instanceof tU?i.jwkAddress:void 0;try{s=await tS({aptosConfig:t,jwkAddr:a})}catch(e){throw eL.fromErrorType({type:24,error:e,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let o=s.get(n);if(void 0===o)throw eL.fromErrorType({type:7,details:`JWKs for issuer ${n} not found.`});let c=o.find(e=>e.kid===r);if(void 0===c)throw eL.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${n}' not found.`});return c}function tu(e){let{uidKey:t,uidVal:i,aud:r,pepper:n}=e;return ef(ey([eg(y.j.fromHexInput(n).toUint8Array()),ep(r,e9),ep(i,te),ep(t,e7)]),ts.ID_COMMITMENT_LENGTH)}ts.ID_COMMITMENT_LENGTH=32;var tl=class e extends ${constructor(e){super();let{jwtHeader:t,ephemeralCertificate:i,expiryDateSecs:r,ephemeralPublicKey:n,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=i,this.expiryDateSecs=r,this.ephemeralPublicKey=n,this.ephemeralSignature=s}getJwkKid(){return tC(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(t){let i=td.deserialize(t),r=t.deserializeStr(),n=t.deserializeU64(),s=eo.deserialize(t),a=ec.deserialize(t);return new e({jwtHeader:r,expiryDateSecs:Number(n),ephemeralCertificate:i,ephemeralPublicKey:s,ephemeralSignature:a})}static getSimulationSignature(){return new e({jwtHeader:"{}",ephemeralCertificate:new td(new t_({proof:new tm(new tf({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new eo(new er(new Uint8Array(32))),ephemeralSignature:new ec(new ea(new Uint8Array(64)))})}static isSignature(t){return t instanceof e}},td=t.EphemeralCertificate=class e extends ${constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(t){let i=t.deserializeUleb128AsU32();if(0===i)return new e(t_.deserialize(t),i);throw Error(`Unknown variant index for EphemeralCertificate: ${i}`)}},tp=class e extends y.l{constructor(e){if(super(),this.data=y.j.fromHexInput(e).toUint8Array(),32!==this.data.length)throw Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(t){return new e(t.deserializeFixedBytes(32))}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let t=new Uint8Array(this.data);t.reverse();let i=(128&t[0])>>7,{Fp:r}=e5.bn254.fields,n=r.create(th(t)),s=r.sqrt(r.add(r.pow(n,3n),e.B)),a=r.neg(s),o=s>a==(1===i)?s:a;return e5.bn254.G1.ProjectivePoint.fromAffine({x:n,y:o})}};function th(e){if(32!==e.length)throw Error("Input should be 32 bytes");let t=new Uint8Array(e);return t[0]=63&t[0],e6.bytesToNumberBE.call(void 0,t)}tp.B=e5.bn254.fields.Fp.create(3n);var tg=class e extends y.l{constructor(e){if(super(),this.data=y.j.fromHexInput(e).toUint8Array(),64!==this.data.length)throw Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(t){return new e(t.deserializeFixedBytes(64))}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let t=new Uint8Array(this.data),i=t.slice(0,32).reverse(),r=t.slice(32,64).reverse(),n=(128&r[0])>>7,{Fp2:s}=e5.bn254.fields,a=s.fromBigTuple([th(i),th(r)]),o=s.sqrt(s.add(s.pow(a,3n),e.B)),c=s.neg(o),u=(o.c1>c.c1||o.c1===c.c1&&o.c0>c.c0)==(1===n)?o:c;return e5.bn254.G2.ProjectivePoint.fromAffine({x:a,y:u})}};tg.B=e5.bn254.fields.Fp2.fromBigTuple([0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5n,0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2n]);var tf=t.Groth16Zkp=class e extends em{constructor(e){super();let{a:t,b:i,c:r}=e;this.a=new tp(t),this.b=new tg(i),this.c=new tp(r)}
6serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(t){return new e({a:tp.deserialize(t).bcsToBytes(),b:tg.deserialize(t).bcsToBytes(),c:tp.deserialize(t).bcsToBytes()})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},ty=t.Groth16ProofAndStatement=class e extends y.l{constructor(e,t){if(super(),this.domainSeparator="APTOS::Groth16ProofAndStatement",this.proof=e,this.publicInputsHash="bigint"==typeof t?ef(t,32):y.j.fromHexInput(t).toUint8Array(),32!==this.publicInputsHash.length)throw Error("Invalid public inputs hash")}serialize(e){this.proof.serialize(e),e.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new e(tf.deserialize(t),t.deserializeFixedBytes(32))}hash(){return iM(this.bcsToBytes(),this.domainSeparator)}},tm=t.ZkProof=class e extends y.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(t){let i=t.deserializeUleb128AsU32();if(0===i)return new e(tf.deserialize(t),i);throw Error(`Unknown variant index for ZkProof: ${i}`)}},t_=t.ZeroKnowledgeSig=class e extends ${constructor(e){super();let{proof:t,expHorizonSecs:i,trainingWheelsSignature:r,extraField:n,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=i,this.trainingWheelsSignature=r,this.extraField=n,this.overrideAudVal=s}static fromBytes(t){return e.deserialize(new m(t))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(t){let i=tm.deserialize(t),r=Number(t.deserializeU64()),n=t.deserializeOption("string"),s=t.deserializeOption("string");return new e({proof:i,expHorizonSecs:r,trainingWheelsSignature:t.deserializeOption(ec),extraField:n,overrideAudVal:s})}},tA=t.KeylessConfiguration=class e{constructor(e){let{verificationKey:t,trainingWheelsPubkey:i,maxExpHorizonSecs:r=1e7,maxExtraFieldBytes:n=ti,maxJwtHeaderB64Bytes:s=tr,maxIssValBytes:a=tt,maxCommitedEpkBytes:o=tn}=e;this.verificationKey=t,this.maxExpHorizonSecs=r,i&&(this.trainingWheelsPubkey=new eo(new er(i))),this.maxExtraFieldBytes=n,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=o}static create(t,i){return new e({verificationKey:new tw({alphaG1:t.alpha_g1,betaG2:t.beta_g2,deltaG2:t.delta_g2,gammaAbcG1:t.gamma_abc_g1,gammaG2:t.gamma_g2}),maxExpHorizonSecs:Number(i.max_exp_horizon_secs),trainingWheelsPubkey:i.training_wheels_pubkey.vec[0],maxExtraFieldBytes:i.max_extra_field_bytes,maxJwtHeaderB64Bytes:i.max_jwt_header_b64_bytes,maxIssValBytes:i.max_iss_val_bytes,maxCommitedEpkBytes:i.max_commited_epk_bytes})}},tw=t.Groth16VerificationKey=class e{constructor(e){let{alphaG1:t,betaG2:i,deltaG2:r,gammaAbcG1:n,gammaG2:s}=e;this.alphaG1=new tp(t),this.betaG2=new tg(i),this.deltaG2=new tg(r),this.gammaAbcG1=[new tp(n[0]),new tp(n[1])],this.gammaG2=new tg(s)}hash(){let e=new y.m;return this.serialize(e),P.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(t){return new e({alphaG1:t.alpha_g1,betaG2:t.beta_g2,deltaG2:t.delta_g2,gammaAbcG1:t.gamma_abc_g1,gammaG2:t.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:i}=e;try{let e=i.a.toProjectivePoint(),r=i.b.toProjectivePoint(),n=i.c.toProjectivePoint(),s=this.alphaG1.toProjectivePoint(),a=this.betaG2.toProjectivePoint(),o=this.gammaG2.toProjectivePoint(),c=this.deltaG2.toProjectivePoint(),u=this.gammaAbcG1.map(e=>e.toProjectivePoint()),{Fp12:l}=e5.bn254.fields,d=u[0].add(u[1].multiply(t)),p=e5.bn254.pairing(d,o),h=e5.bn254.pairing(e,r),g=e5.bn254.pairing(s,a),f=e5.bn254.pairing(n,c),y=l.mul(g,l.mul(p,f));return l.eql(h,y)}catch(e){throw eL.fromErrorType({type:32,error:e,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG
61.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function tb(e){let{aptosConfig:t}=e;try{return await e3(async()=>{let[t,i]=await Promise.all([tT(e),tE(e)]);return tA.create(i,t)},`keyless-configuration-${t.network}`,3e5)()}catch(e){throw e instanceof eL?e:eL.fromErrorType({type:25,error:e})}}function tv(e){let{jwt:t,uidKey:i="sub"}=e,r;try{r=eu.jwtDecode.call(void 0,t)}catch(e){throw eL.fromErrorType({type:12,details:`Failed to parse JWT - ${y.ga.call(void 0,e)}`})}if("string"!=typeof r.iss)throw eL.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if("string"!=typeof r.aud)throw eL.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let n=r[i];return{iss:r.iss,aud:r.aud,uidVal:n}}async function tT(e){let{aptosConfig:t,options:i}=e;try{let{data:e}=await ej({aptosConfig:t,originMethod:"getKeylessConfigurationResource",path:`accounts/${y.ba.from("0x1").toString()}/resource/0x1::keyless_account::Configuration`,params:{ledger_version:g([i,"optionalAccess",e=>e.ledgerVersion])}});return e.data}catch(e){throw eL.fromErrorType({type:22,error:e})}}async function tE(e){let{aptosConfig:t,options:i}=e;try{let{data:e}=await ej({aptosConfig:t,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${y.ba.from("0x1").toString()}/resource/0x1::keyless_account::Groth16VerificationKey`,params:{ledger_version:g([i,"optionalAccess",e=>e.ledgerVersion])}});return e.data}catch(e){throw eL.fromErrorType({type:23,error:e})}}async function tS(e){let{aptosConfig:t,jwkAddr:i,options:r}=e,n;if(i){let{data:e}=await ej({aptosConfig:t,originMethod:"getKeylessJWKs",path:`accounts/${y.ba.from(i).toString()}/resource/0x1::jwks::FederatedJWKs`,params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion])}});n=e}else{let{data:e}=await ej({aptosConfig:t,originMethod:"getKeylessJWKs",path:"accounts/0x1/resource/0x1::jwks::PatchedJWKs",params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion])}});n=e}let s=new Map;for(let e of n.data.jwks.entries){let t=[];for(let i of e.jwks){let{data:e}=i.variant,r=new m(y.j.fromHexInput(e).toUint8Array()),n=tz.deserialize(r);t.push(n)}s.set(y.k.call(void 0,e.issuer),t)}return s}var tz=class e extends y.l{constructor(e){super();let{kid:t,kty:i,alg:r,e:n,n:s}=e;this.kid=t,this.kty=i,this.alg=r,this.e=n,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(t){let{data:i}=t.variant,r=new m(y.j.fromHexInput(i).toUint8Array());return e.deserialize(r)}toScalar(){if("RS256"!==this.alg)throw eL.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=(function(e){let t=[];for(let i=0;i<e.length;i+=24){let r=e.slice(i,Math.min(i+24,e.length));if(r.length<24){let e=new Uint8Array(24);e.set(r),t.push(e)}else t.push(r)}return t})(y.ka.call(void 0,this.n).reverse()).map(e=>eg(e));return e.push(256n),ey(e)}static deserialize(t){let i=t.deserializeStr(),r=t.deserializeStr(),n=t.deserializeStr(),s=t.deserializeStr();return new e({kid:i,kty:r,alg:n,n:t.deserializeStr(),e:s})}};function tC(e){try{let t=JSON.parse(e);if(void 0===t.kid)throw Error("JWT header missing kid");return t}catch(e){throw Error("Failed to parse JWT header.")}}var tU=class e extends N{constructor(e,t){super(),this.jwkAddress=y.ba.from(e),this.keylessPublicKey=t}authKey(){let e=new y.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),K.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return to({...e,publicKey:this}),!0}catch(e){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(t){return new e(y.ba.deserialize(t),ts.deserialize(t))}static isPublicKey(t){return t instanceof e}async verifySignatureAsync(e){return ta({...e,publicKey:this})}static create(t){return new e(t.jwkAddress,ts.create(t))}static fromJwtAndPepper(t){return new e(t.jwkAddress,ts.fromJwtAndPepper(t))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof y.ba&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof ts}},tx=i(89984),tk=i(90361),tP=class e extends I{constructor(t){super();let i=y.j.fromHexInput(t),{length:r}=i.toUint8Array();if(r===e.LENGTH)this.key=i;else if(r===e.COMPRESSED_LENGTH){let e=tx.secp256k1.ProjectivePoint.fromHex(i.toUint8Array());this.key=y.j.fromHexInput(e.toRawBytes(!1))}else throw Error(`PublicKey length should be ${e.LENGTH} or ${e.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:i}=e,r=ee(t),n=y.j.fromHexInput(r).toUint8Array(),s=P.sha3_256.call(void 0,n),a=i.toUint8Array();return tx.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){return new tN(e.deserializeBytes())}static deserialize(t){return new e(t.deserializeBytes())}static isPublicKey(t){return t instanceof e}static isInstance(t){return"key"in t&&g([t,"access",e=>e.key,"optionalAccess",e=>e.data,"optionalAccess",e=>e.length])===e.LENGTH}};tP.LENGTH=65,tP.COMPRESSED_LENGTH=33;var tK=class e extends y.l{constructor(t,i){super();let r=Q.parseHexInput(t,"secp256k1",i);if(r.toUint8Array().length!==e.LENGTH)throw Error(`PrivateKey length should be ${e.LENGTH}`);this.key=r}static generate(){return new e(tx.secp256k1.utils.randomPrivateKey(),!1)}static fromDerivationPath(t,i){if(!j(t))throw Error(`Invalid derivation path ${t}`);return e.fromDerivationPathInner(t,Z(i))}static fromDerivationPathInner(t,i){let{privateKey:r}=tk.HDKey.fromMasterSeed(i).derive(t);if(null===r)throw Error("Invalid key");return new e(r,!1)}sign(e){let t=ee(e),i=y.j.fromHexInput(t),r=P.sha3_256.call(void 0,i.toUint8Array());return new tN(tx.secp256k1.sign(r,this.key.toUint8Array(),{lowS:!0}).toCompactRawBytes())}publicKey(){return new tP(tx.secp256k1.getPublicKey(this.key.toUint8Array(),!1))}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return Q.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(t){return new e(t.deserializeBytes(),!1)}static isPrivateKey(t){return t instanceof e}};tK.LENGTH=32;var tI=class e extends ${constructor(t){super();let i=y.j.fromHexInput(t);if(i.toUint8Array().length!==e.LENGTH)throw Error(`Signature length should be ${e.LENGTH}, received ${i.toUint8Array().length}`);this.data=i}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(t){return new e(t.deserializeBytes())}};tI.LENGTH=64;var tN=tI,t$=class e extends N{constructor(e){if(super(),this.publicKey=e,e instanceof er)this.variant=0;else if(e instanceof tP)this.variant=1;else if(e instanceof ts)this.variant=3;else if(e instanceof tU)this.variant=4;else throw Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:i}=e;if(this.publicKey instanceof ts)throw Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:i.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof tF)){if
6(g([e,"access",e=>e.options,"optionalAccess",e=>e.throwErrorWithReason]))throw Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return K.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(t){let i=t.deserializeUleb128AsU32(),r;switch(i){case 0:r=er.deserialize(t);break;case 1:r=tP.deserialize(t);break;case 3:r=ts.deserialize(t);break;case 4:r=tU.deserialize(t);break;default:throw Error(`Unknown variant index for AnyPublicKey: ${i}`)}return new e(r)}static isPublicKey(t){return t instanceof e}isEd25519(){return this.publicKey instanceof er}isSecp256k1PublicKey(){return this.publicKey instanceof tP}static isInstance(e){return"publicKey"in e&&"variant"in e}},tF=t.AnySignature=class e extends ${constructor(e){if(super(),this.signature=e,e instanceof ea)this.variant=0;else if(e instanceof tN)this.variant=1;else if(e instanceof tl)this.variant=3;else throw Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(t){let i=t.deserializeUleb128AsU32(),r;switch(i){case 0:r=ea.deserialize(t);break;case 1:r=tN.deserialize(t);break;case 3:r=tl.deserialize(t);break;default:throw Error(`Unknown variant index for AnySignature: ${i}`)}return new e(r)}static isInstance(e){return"signature"in e&&"object"==typeof e.signature&&null!==e.signature&&"toUint8Array"in e.signature}},tR=t.AbstractMultiKey=class extends N{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,i=new Uint8Array([0,0,0,0]),r=new Set;return t.forEach((e,t)=>{if(t+1>this.publicKeys.length)throw Error(`Signature index ${t+1} is out of public keys range, ${this.publicKeys.length}.`);if(r.has(e))throw Error(`Duplicate bit ${e} detected.`);r.add(e);let n=Math.floor(e/8),s=i[n];s|=128>>e%8,i[n]=s}),i}getIndex(e){let t=this.publicKeys.findIndex(t=>t.toString()===e.toString());if(-1!==t)return t;throw Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},tB=t.MultiKey=class e extends tR{constructor(e){let{publicKeys:t,signaturesRequired:i}=e;if(super({publicKeys:t}),i<1)throw Error("The number of required signatures needs to be greater than 0");if(t.length<i)throw Error(`Provided ${t.length} public keys is smaller than the ${i} required signatures`);if(this.publicKeys=t.map(e=>e instanceof t$?e:new t$(e)),i>3&&this.publicKeys.filter(e=>3===e.variant||4===e.variant).length>3)throw Error(`Construction of MultiKey with more than 3 keyless public keys is not allowed when signaturesRequired 
7          is greater than 3. This is because a maximum of 3 keyless signatures are supported for a 
8          K-of-N MultiKey transaction.`);this.signaturesRequired=i}getSignaturesRequired(){return this.signaturesRequired}verifySignature(e){let{message:t,signature:i}=e;if(i.signatures.length!==this.signaturesRequired)throw Error("The number of signatures does not match the number of required signatures");let r=i.bitMapToSignerIndices();for(let e=0;e<i.signatures.length;e+=1){let n=i.signatures[e];if(!this.publicKeys[r[e]].verifySignature({message:t,signature:n}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof tO))throw Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw Error("The number of signatures does not match the number of required signatures");let i=t.bitMapToSignerIndices();for(let r=0;r<t.signatures.length;r+=1){let n=t.signatures[r];if(!await this.publicKeys[i[r]].verifySignatureAsync({...e,signature:n}))return!1}return!0}catch(t){if(g([e,"access",e=>e.options,"optionalAccess",e=>e.throwErrorWithReason]))throw t;return!1}}
8authKey(){return K.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(t){return new e({publicKeys:t.deserializeVector(t$),signaturesRequired:t.deserializeU8()})}getIndex(e){let t=e instanceof t$?e:new t$(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},tD=class e extends ${constructor(t){super();let{signatures:i,bitmap:r}=t;if(i.length>e.MAX_SIGNATURES_SUPPORTED)throw Error(`The number of signatures cannot be greater than ${e.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=i.map(e=>e instanceof tF?e:new tF(e)),r instanceof Uint8Array){if(r.length!==e.BITMAP_LEN)throw Error(`"bitmap" length should be ${e.BITMAP_LEN}`);this.bitmap=r}else this.bitmap=e.createBitmap({bits:r});let n=this.bitmap.reduce((e,t)=>{let i;return e+(i=t,i-=i>>1&1431655765,((i=(858993459&i)+(i>>2&858993459))+(i>>4)&252645135)*16843009>>24)},0);if(n!==this.signatures.length)throw Error(`Expecting ${n} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(t){let{bits:i}=t,r=new Uint8Array([0,0,0,0]),n=new Set;return i.forEach(t=>{if(t>=e.MAX_SIGNATURES_SUPPORTED)throw Error(`Cannot have a signature larger than ${e.MAX_SIGNATURES_SUPPORTED-1}.`);if(n.has(t))throw Error("Duplicate bits detected.");n.add(t);let i=Math.floor(t/8),s=r[i];s|=128>>t%8,r[i]=s}),r}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let i=this.bitmap[t];for(let r=0;r<8;r+=1)(i&128>>r)!=0&&e.push(8*t+r)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(t){return new e({signatures:t.deserializeVector(tF),bitmap:t.deserializeBytes()})}};tD.BITMAP_LEN=4,tD.MAX_SIGNATURES_SUPPORTED=8*tD.BITMAP_LEN;var tO=tD,tL=class e extends tR{constructor(t){let{publicKeys:i,threshold:r}=t;if(super({publicKeys:i}),i.length>e.MAX_KEYS||i.length<e.MIN_KEYS)throw Error(`Must have between ${e.MIN_KEYS} and ${e.MAX_KEYS} public keys, inclusive`);if(r<e.MIN_THRESHOLD||r>i.length)throw Error(`Threshold must be between ${e.MIN_THRESHOLD} and ${i.length}, inclusive`);this.publicKeys=i,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:i}=e;if(!(i instanceof tV))return!1;let r=[];for(let e=0;e<4;e+=1)for(let t=0;t<8;t+=1)if((i.bitmap[e]&1<<7-t)!=0){let i=8*e+t;r.push(i)}if(r.length!==i.signatures.length)throw Error("Bitmap and signatures length mismatch");if(r.length<this.threshold)throw Error("Not enough signatures");for(let e=0;e<r.length;e+=1)if(!this.publicKeys[r[e]].verifySignature({message:t,signature:i.signatures[e]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return K.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*er.LENGTH+1);return this.publicKeys.forEach((t,i)=>{e.set(t.toUint8Array(),i*er.LENGTH)}),e[this.publicKeys.length*er.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(t){let i=t.deserializeBytes(),r=i[i.length-1],n=[];for(let e=0;e<i.length-1;e+=er.LENGTH){let t=e;n.push(new er(i.subarray(t,t+er.LENGTH)))}return new e({publicKeys:n,threshold:r})}static deserializeWithoutLength(t){let i=t.remaining(),r=t.deserializeFixedBytes(i),n=r[r.length-1],s=[];for(let e=0;e<r.length-1;e+=er.LENGTH){let t=e;s.push(new er(r.subarray(t,t+er.LENGTH)))}return new e({publicKeys:s,threshold:n})}getIndex(e){return super.getIndex(e)}};tL.MAX_KEYS=32,tL.MIN_KEYS=2,tL.MIN_THRESHOLD=1;var tM=class e extends ${constructor(t){super();let{signatures:i,bitmap:r}=t;if(i.length>e.MAX_SIGNATURES_SUPPORTED)throw Error(`The number of signatures cannot be greater than ${e.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=i,r instanceof Uint8Array){if(r.length!==e.BITMAP_LEN)throw Error(`"bitmap" length should be ${e.BITMAP_LEN}`);this.bitmap=r}else this.bitmap=e.createBitmap({bits:r})}toUint8Array(){let t=new Uint8Array(this.signatures.length*ea.LENGTH+e.BITMAP_LEN);
8return this.signatures.forEach((e,i)=>{t.set(e.toUint8Array(),i*ea.LENGTH)}),t.set(this.bitmap,this.signatures.length*ea.LENGTH),t}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(t){let i=t.deserializeBytes(),r=i.subarray(i.length-4),n=[];for(let e=0;e<i.length-r.length;e+=ea.LENGTH){let t=e;n.push(new ea(i.subarray(t,t+ea.LENGTH)))}return new e({signatures:n,bitmap:r})}static createBitmap(t){let{bits:i}=t,r=new Uint8Array([0,0,0,0]),n=new Set;return i.forEach((t,s)=>{if(t>=e.MAX_SIGNATURES_SUPPORTED)throw Error(`Cannot have a signature larger than ${e.MAX_SIGNATURES_SUPPORTED-1}.`);if(n.has(t))throw Error("Duplicate bits detected.");if(s>0&&t<=i[s-1])throw Error("The bits need to be sorted in ascending order.");n.add(t);let a=Math.floor(t/8),o=r[a];o|=128>>t%8,r[a]=o}),r}};tM.MAX_SIGNATURES_SUPPORTED=32,tM.BITMAP_LEN=4;var tV=tM,tq="Multiple possible deserializations found",tH=class extends y.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return tj.load(e);case 1:return tG.load(e);case 2:return tW.load(e);case 3:return tJ.load(e);case 4:return tY.load(e);case 5:return tX.load(e);default:throw Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof tj}isMultiEd25519(){return this instanceof tG}isSingleKey(){return this instanceof tW}isMultiKey(){return this instanceof tJ}},tj=t.AccountAuthenticatorEd25519=class e extends tH{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(t){return new e(er.deserialize(t),ea.deserialize(t))}},tG=t.AccountAuthenticatorMultiEd25519=class e extends tH{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(t){return new e(tL.deserialize(t),tV.deserialize(t))}},tW=t.AccountAuthenticatorSingleKey=class e extends tH{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(t){return new e(t$.deserialize(t),tF.deserialize(t))}},tJ=t.AccountAuthenticatorMultiKey=class e extends tH{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(t){return new e(tB.deserialize(t),tO.deserialize(t))}},tY=t.AccountAuthenticatorNoAccountAuthenticator=class e extends tH{serialize(e){e.serializeU32AsUleb128(4)}static load(t){return new e}},tX=t.AccountAuthenticatorAbstraction=class e extends tH{constructor(e,t,i,r){if(super(),!y.qa.call(void 0,e))throw Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=i,this.signingMessageDigest=y.j.fromHexInput(y.j.fromHexInput(t).toUint8Array()),this.accountIdentity=r}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:i,functionName:r}=y.pa.call(void 0,this.functionInfo);y.ba.fromString(t).serialize(e),e.serializeStr(i),e.serializeStr(r),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(t){let i=y.ba.deserialize(t),r=t.deserializeStr(),n=t.deserializeStr(),s=t.deserializeUleb128AsU32();if(0===s)return new e(`${i}::${r}::${n}`,t.deserializeBytes(),t.deserializeFixedBytes(t.remaining()));if(1===s)return new e(`${i}::${r}::${n}`,t.deserializeBytes(),t.deserializeBytes(),t.deserializeBytes());throw Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${s}`)}},tZ=class e extends y.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(t){return new e(t.deserializeU8())}},tQ=class e extends y.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(t){return new e(t.deserializeStr())}},t0=class e extends y.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(t){let i=t.split("::");if(2!==i.length)throw Error("Invalid module id.");return new e(y.ba.fromString(i[0]),new tQ(i[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(t){return new e(y.ba.deserialize(t),tQ.deserialize(t))}},t2=class e extends y.l{deserialize(t){return new ia(y.ba.deserialize(t),tQ.deserialize(t),tQ.deserialize(t),t.deserializeVector(e))}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return t1.load(e);case 1:return t8.load(e);case 2:return t6.load(e);case 3:return t4.load(e);case 4:return t7.load(e);case 5:return ie.load(e);case 6:return ir.load(e);case 7:return is.load(e);case 8:return t3.load(e);case 9:return t5.load(e);case 10:return t9.load(e);case 255:return ii.load(e);default:throw Error(`Unknown variant index for TypeTag: ${t}`)}}
8isBool(){return this instanceof t1}isAddress(){return this instanceof t7}isGeneric(){return this instanceof ii}isSigner(){return this instanceof ie}isVector(){return this instanceof ir}isStruct(){return this instanceof is}isU8(){return this instanceof t8}isU16(){return this instanceof t3}isU32(){return this instanceof t5}isU64(){return this instanceof t6}isU128(){return this instanceof t4}isU256(){return this instanceof t9}isPrimitive(){return this instanceof ie||this instanceof t7||this instanceof t1||this instanceof t8||this instanceof t3||this instanceof t5||this instanceof t6||this instanceof t4||this instanceof t9}},t1=t.TypeTagBool=class e extends t2{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(t){return new e}},t8=t.TypeTagU8=class e extends t2{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(t){return new e}},t3=t.TypeTagU16=class e extends t2{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(t){return new e}},t5=t.TypeTagU32=class e extends t2{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(t){return new e}},t6=t.TypeTagU64=class e extends t2{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(t){return new e}},t4=t.TypeTagU128=class e extends t2{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(t){return new e}},t9=t.TypeTagU256=class e extends t2{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(t){return new e}},t7=t.TypeTagAddress=class e extends t2{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(t){return new e}},ie=t.TypeTagSigner=class e extends t2{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(t){return new e}},it=t.TypeTagReference=class e extends t2{constructor(e){super(),this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(t){return new e(t2.deserialize(t))}},ii=t.TypeTagGeneric=class e extends t2{constructor(e){if(super(),this.value=e,e<0)throw Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(t){return new e(t.deserializeU32())}},ir=t.TypeTagVector=class e extends t2{constructor(e){super(),this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new e(new t8)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(t){return new e(t2.deserialize(t))}},is=t.TypeTagStruct=class e extends t2{constructor(e){super(),this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(e=>e.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(t){return new e(ia.deserialize(t))}isTypeTag(e,t,i){return this.value.moduleName.identifier===t&&this.value.name.identifier===i&&this.value.address.equals(e)}isString(){return this.isTypeTag(y.ba.ONE,"string","String")}isOption(){return this.isTypeTag(y.ba.ONE,"option","Option")}isObject(){return this.isTypeTag(y.ba.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(y.ba.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(y.ba.ONE,"rate_limiter","RateLimiter")}},ia=t.StructTag=class e extends y.l{constructor(e,t,i,r){super(),this.address=e,this.moduleName=t,this.name=i,this.typeArgs=r}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(t){return new e(y.ba.deserialize(t),tQ.deserialize(t),tQ.deserialize(t),t.deserializeVector(t2))}};function io(){return new ia(y.ba.ONE,new tQ("string"),new tQ("String"),[])}function ic(e){return new ia(y.ba.ONE,new tQ("object"),new tQ("Object"),[e])}function iu(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return b.deserialize(e);case 1:return E.deserialize(e);case 2:return S.deserialize(e);case 3:return y.ba.deserialize(e);case 4:return C.deserialize(e,b);case 5:return w.deserialize(e);case 6:return v.deserialize(e);case 7:return T.deserialize(e);case 8:return z.deserialize(e);case 9:return U.deserialize(e);default:throw Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var il=class extends y.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return id.load(e);case 2:return ip.load(e);case 3:return ih.load(e);case 4:return iA.deserialize(e);default:throw Error(`Unknown variant index for TransactionPayload: ${t}`)}}},id=t.TransactionPayloadScript=class e extends il{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(t){return new e(iy.deserialize(t))}},ip=t.TransactionPayloadEntryFunction=class e extends il{constructor(e){super(),this.entryFunction=e}
8serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(t){return new e(ig.deserialize(t))}},ih=t.TransactionPayloadMultiSig=class e extends il{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(t){return new e(im.deserialize(t))}},ig=t.EntryFunction=class e{constructor(e,t,i,r){this.module_name=e,this.function_name=t,this.type_args=i,this.args=r}static build(t,i,r,n){return new e(t0.fromStr(t),new tQ(i),r,n)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(t){let i=t0.deserialize(t),r=tQ.deserialize(t),n=t.deserializeVector(t2),s=t.deserializeUleb128AsU32(),a=[];for(let e=0;e<s;e+=1){let e=t.deserializeUleb128AsU32(),i=A.deserialize(t,e);a.push(i)}return new e(i,r,n,a)}},iy=t.Script=class e{constructor(e,t,i){this.bytecode=e,this.type_args=t,this.args=i}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(t){let i=t.deserializeBytes(),r=t.deserializeVector(t2),n=t.deserializeUleb128AsU32(),s=[];for(let e=0;e<n;e+=1){let e=iu(t);s.push(e)}return new e(i,r,s)}},im=t.MultiSig=class e{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),void 0===this.transaction_payload?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(t){let i=y.ba.deserialize(t),r;return t.deserializeBool()&&(r=i_.deserialize(t)),new e(i,r)}},i_=t.MultiSigTransactionPayload=class e extends y.l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(t){return t.deserializeUleb128AsU32(),new e(ig.deserialize(t))}},iA=t.TransactionInnerPayload=class extends il{static deserialize(e){let t=e.deserializeUleb128AsU32();if(0===t)return iw.load(e);throw Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}},iw=t.TransactionInnerPayloadV1=class e extends iA{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(t){return new e(ib.deserialize(t),iS.deserialize(t))}},ib=t.TransactionExecutable=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return iv.load(e);case 1:return iT.load(e);case 2:return iE.load(e);default:throw Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},iv=t.TransactionExecutableScript=class e extends ib{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(t){return new e(iy.deserialize(t))}},iT=t.TransactionExecutableEntryFunction=class e extends ib{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(t){return new e(ig.deserialize(t))}},iE=t.TransactionExecutableEmpty=class e extends ib{serialize(e){e.serializeU32AsUleb128(2)}static load(t){return new e}},iS=t.TransactionExtraConfig=class{static deserialize(e){let t=e.deserializeUleb128AsU32();if(0===t)return iz.load(e);throw Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}},iz=t.TransactionExtraConfigV1=class e extends iS{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=void 0!==t?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(void 0!==this.replayProtectionNonce?new E(this.replayProtectionNonce):void 0)}static load(t){return new e(t.deserializeOption(y.ba),g([t.deserializeOption(E),"optionalAccess",e=>e.value]))}},iC=class e extends y.l{constructor(e,t,i,r,n,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=i,this.max_gas_amount=r,this.gas_unit_price=n,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(t){return new e(y.ba.deserialize(t),t.deserializeU64(),il.deserialize(t),t.deserializeU64(),t.deserializeU64(),t.deserializeU64(),tZ.deserialize(t))}},iU=t.RawTransactionWithData=class extends y.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ix.load(e);case 1:return ik.load(e);default:throw Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},ix=t.MultiAgentRawTransaction=class e extends iU{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(t){return new e(iC.deserialize(t),t.deserializeVector(y.ba))}},ik=t.FeePayerRawTransaction=class e extends iU{constructor(e,t,i){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=i}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(t){return new e(iC.deserialize(t),t.deserializeVector(y.ba),y.ba.deserialize(t))}},iP=class extends y.l{constructor(e){super(),this.accountAddress=y.ba.ONE,this.moduleName=new x("account"),this.structName=new x("RotationProofChallenge"),this.sequenceNumber=new E(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=C.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}},iK=class extends y.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return iI.load(e);case 1:return iN.load(e);case 2:return i$.load(e);case 3:return iF.load(e);case 4:return iR.load(e);default:throw Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof iI}isMultiEd25519(){return this instanceof iN}isMultiAgent(){return this instanceof i$}isFeePayer(){return this instanceof iF}isSingleSender(){return this instanceof iR}},iI=t.TransactionAuthenticatorEd25519=class e extends iK{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(t){return new e(er.deserialize(t),ea.deserialize(t))}},iN=t.TransactionAuthenticatorMultiEd25519=class e extends iK{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(t){return new e(tL.deserialize(t),tV.deserialize(t))}},i$=t.TransactionAuthenticatorMultiAgent=class e extends iK{constructor(e,t,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=i}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(t){return new e(tH.deserialize(t),t.deserializeVector(y.ba),t.deserializeVector(tH))}},iF=t.TransactionAuthenticatorFeePayer=class e extends iK{constructor(e,t,i,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=i,this.fee_payer=r}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(t){return new e(tH.deserialize(t),t.deserializeVector(y.ba),t.deserializeVector(tH),{address:y.ba.deserialize(t),authenticator:tH.deserialize(t)})}},iR=t.TransactionAuthenticatorSingleSender=class e extends iK{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(t){return new e(tH.deserialize(t))}},iB=class e extends y.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(t){return new e(iC.deserialize(t),iK.deserialize(t))}},iD=class e extends y.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}
8serialize(e){this.rawTransaction.serialize(e),void 0===this.feePayerAddress?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(t){let i=iC.deserialize(t),r;return t.deserializeBool()&&(r=y.ba.deserialize(t)),new e(i,r)}},iO=class e extends y.l{constructor(e,t,i){super(),this.rawTransaction=e,this.feePayerAddress=i,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),void 0===this.feePayerAddress?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(t){let i=iC.deserialize(t),r=t.deserializeVector(y.ba),n;return t.deserializeBool()&&(n=y.ba.deserialize(t)),new e(i,r,n)}};function iL(e){return e.feePayerAddress?new ik(e.rawTransaction,h(e.secondarySignerAddresses,()=>[]),e.feePayerAddress):e.secondarySignerAddresses?new ix(e.rawTransaction,e.secondarySignerAddresses):e.rawTransaction}function iM(e,t){let i=P.sha3_256.create();if(!t.startsWith("APTOS::"))throw Error(`Domain separator needs to start with 'APTOS::'.  Provided - ${t}`);i.update(t);let r=i.digest(),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}function iV(e){let t=iL(e);return e.feePayerAddress?iM(t.bcsToBytes(),eI):e.secondarySignerAddresses?iM(t.bcsToBytes(),eI):iM(t.bcsToBytes(),eK)}var iq=class e{constructor(e){this.signingScheme=0;let{privateKey:t,address:i}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=i?y.ba.from(i):this.publicKey.authKey().derivedAddress()}static generate(){return new e({privateKey:en.generate()})}static fromDerivationPath(t){let{path:i,mnemonic:r}=t;return new e({privateKey:en.fromDerivationPath(i,r)})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new tj(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new tj(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(iV(e))}};function iH(e){return"object"==typeof e&&null!==e&&"getAnyPublicKey"in e&&"function"==typeof e.getAnyPublicKey}var ij=class e{constructor(e){this.signingScheme=2;let{privateKey:t,address:i}=e;this.privateKey=t,this.publicKey=new t$(t.publicKey()),this.accountAddress=i?y.ba.from(i):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(t={}){let{scheme:i=0}=t,r;switch(i){case 0:r=en.generate();break;case 2:r=tK.generate();break;default:throw Error(`Unsupported signature scheme ${i}`)}return new e({privateKey:r})}static fromDerivationPath(t){let{scheme:i=0,path:r,mnemonic:n}=t,s;switch(i){case 0:s=en.fromDerivationPath(r,n);break;case 2:s=tK.fromDerivationPath(r,n);break;default:throw Error(`Unsupported signature scheme ${i}`)}return new e({privateKey:s})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new tW(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new tW(this.publicKey,this.signTransaction(e))}sign(e){return new tF(this.privateKey.sign(e))}signTransaction(e){return this.sign(iV(e))}static fromEd25519Account(t){return new e({privateKey:t.privateKey,address:t.accountAddress})}},iG=class{static generate(e={}){let{scheme:t=0,legacy:i=!0}=e;return 0===t&&i?iq.generate():ij.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:i,legacy:r=!0}=e;return t instanceof en&&r?new iq({privateKey:t,address:i}):new ij({privateKey:t,address:i})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:i,path:r,legacy:n=!0}=e;return 0===t&&n?iq.fromDerivationPath({mnemonic:i,path:r}):ij.fromDerivationPath({scheme:t,mnemonic:i,path:r})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}},iW=i(28772),iJ=class e extends y.l{constructor(e){super();let{privateKey:t,expiryDateSecs:i,blinder:r}=e;this.privateKey=t,this.publicKey=new eo(t.publicKey()),this.expiryDateSecs=i||y.ia.call(void 0,y.ha.call(void 0)+1209600),this.blinder=void 0!==r?y.j.fromHexInput(r).toUint8Array():iW.randomBytes.call(void 0,iJ.BLINDER_LENGTH);let n=eh(this.publicKey.bcsToBytes(),93);n.push(BigInt(this.expiryDateSecs)),n.push(eg(this.blinder));let s=ey(n);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(t){let i=t.deserializeUleb128AsU32(),r;if(0===i)r=en.deserialize(t);else throw Error(`Unknown variant index for EphemeralPublicKey: ${i}`);let n=t.deserializeU64(),s=t.deserializeFixedBytes(31);return new e({privateKey:r,expiryDateSecs:Number(n),blinder:s})}static fromBytes(t){return e.deserialize(new m(t))}
8static generate(t){return g([t,"optionalAccess",e=>e.scheme]),new e({privateKey:en.generate(),expiryDateSecs:g([t,"optionalAccess",e=>e.expiryDateSecs])})}sign(e){if(this.isExpired())throw Error("EphemeralKeyPair has expired");return new ec(this.privateKey.sign(e))}};iJ.BLINDER_LENGTH=31;var iY=p(i(77625));function iX(e){return null!=e&&"function"==typeof e.checkKeylessAccountValidity}var iZ=class e extends y.l{constructor(t){super(),this.signingScheme=2;let{address:i,ephemeralKeyPair:r,publicKey:n,uidKey:s,uidVal:a,aud:o,pepper:c,proof:u,proofFetchCallback:l,jwt:d,verificationKeyHash:p}=t;if(this.ephemeralKeyPair=r,this.publicKey=n,this.accountAddress=i?y.ba.from(i):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=o,this.jwt=d,this.emitter=new iY.default,this.proofOrPromise=u,u instanceof t_)this.proof=u;else{if(void 0===l)throw Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async e=>{await l(e),this.emitter.removeAllListeners()}),this.init(u)}let h=y.j.fromHexInput(c).toUint8Array();if(h.length!==e.PEPPER_LENGTH)throw Error(`Pepper length in bytes should be ${e.PEPPER_LENGTH}`);if(this.pepper=h,void 0!==p){if(32!==y.j.hexInputToUint8Array(p).length)throw Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=y.j.hexInputToUint8Array(p)}}getAnyPublicKey(){return new t$(this.publicKey)}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(e){e instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:e.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(this.accountAddress.serialize(e),e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),void 0===this.proof)throw Error("Cannot serialize - proof undefined");this.proof.serialize(e),e.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(e){return{address:y.ba.deserialize(e),jwt:e.deserializeStr(),uidKey:e.deserializeStr(),pepper:e.deserializeFixedBytes(31),ephemeralKeyPair:iJ.deserialize(e),proof:t_.deserialize(e),verificationKeyHash:e.deserializeOption("fixedBytes",32)}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let t=new tF(this.sign(e));return new tW(new t$(this.publicKey),t)}signTransactionWithAuthenticator(e){let t=new tF(this.signTransaction(e));return new tW(new t$(this.publicKey),t)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw eL.fromErrorType({type:0});if(await this.waitForProofFetch(),void 0===this.proof)throw eL.fromErrorType({type:2});let i=eu.jwtDecode.call(void 0,this.jwt,{header:!0});if(void 0===i.kid)throw eL.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(void 0!==this.verificationKeyHash){let{verificationKey:e}=await tb({aptosConfig:t});if(y.j.hexInputToString(e.hash())!==y.j.hexInputToString(this.verificationKeyHash))throw eL.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await e.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:i.kid})}sign(e){let{expiryDateSecs:t}=this.ephemeralKeyPair;if(this.isExpired())throw eL.fromErrorType({type:0});if(void 0===this.proof)throw eL.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),r=this.ephemeralKeyPair.sign(e);return new tl({jwtHeader:y.ja.call(void 0,this.jwt.split(".")[0]),ephemeralCertificate:new td(this.proof,0),expiryDateSecs:t,ephemeralPublicKey:i,ephemeralSignature:r})}signTransaction(e){if(void 0===this.proof)throw eL.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let t=new i0(iL(e),this.proof.proof).hash();return this.sign(t)}getSigningMessage(e){if(void 0===this.proof)throw eL.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});return new i0(iL(e),this.proof.proof).hash()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e})}static async fetchJWK(e){return tc(e)}};iZ.PEPPER_LENGTH=31;var iQ=iZ,i0=t.TransactionAndProof=class extends y.l{constructor(e,t){super(),this.domainSeparator="APTOS::TransactionAndProof",this.transaction=e,this.proof=t}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}hash(){return iM(this.bcsToBytes(),this.domainSeparator)}},i2=class e extends iQ{constructor(e){let t=ts.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(t){let{address:i,proof:r,ephemeralKeyPair:n,jwt:s,uidKey:a,pepper:
8o,verificationKeyHash:c}=iQ.partialDeserialize(t),{iss:u,aud:l,uidVal:d}=tv({jwt:s,uidKey:a});return new e({address:i,proof:r,ephemeralKeyPair:n,iss:u,uidKey:a,uidVal:d,aud:l,pepper:o,jwt:s,verificationKeyHash:c})}static fromBytes(t){return e.deserialize(new m(y.j.hexInputToUint8Array(t)))}static create(t){let{address:i,proof:r,jwt:n,ephemeralKeyPair:s,pepper:a,uidKey:o="sub",proofFetchCallback:c,verificationKey:u,verificationKeyHash:l}=t;if(l&&u)throw Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:d,aud:p,uidVal:g}=tv({jwt:n,uidKey:o});return new e({address:i,proof:r,ephemeralKeyPair:s,iss:d,uidKey:o,uidVal:g,aud:p,pepper:a,jwt:n,proofFetchCallback:c,verificationKeyHash:h(l,()=>u?u.hash():void 0)})}},i1=class e extends iQ{constructor(e){let t=tU.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=h(e.audless,()=>!1)}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(t){let{address:i,proof:r,ephemeralKeyPair:n,jwt:s,uidKey:a,pepper:o,verificationKeyHash:c}=iQ.partialDeserialize(t),u=y.ba.deserialize(t),{iss:l,aud:d,uidVal:p}=tv({jwt:s,uidKey:a});return new e({address:i,proof:r,ephemeralKeyPair:n,iss:l,uidKey:a,uidVal:p,aud:d,pepper:o,jwt:s,verificationKeyHash:c,jwkAddress:u})}static fromBytes(t){return e.deserialize(m.fromHex(t))}static create(t){let{address:i,proof:r,jwt:n,ephemeralKeyPair:s,pepper:a,jwkAddress:o,uidKey:c="sub",proofFetchCallback:u,verificationKey:l,verificationKeyHash:d}=t;if(d&&l)throw Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:g,uidVal:f}=tv({jwt:n,uidKey:c});return new e({address:i,proof:r,ephemeralKeyPair:s,iss:p,uidKey:c,uidVal:f,aud:g,pepper:a,jwkAddress:y.ba.from(o),jwt:n,proofFetchCallback:u,verificationKeyHash:h(d,()=>l?l.hash():void 0)})}},i8=class e{constructor(e){this.signingScheme=3;let{multiKey:t,address:i}=e,r=e.signers.map(e=>e instanceof iq?ij.fromEd25519Account(e):e);if(t.signaturesRequired>r.length)throw Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${r.length} provided`);if(t.signaturesRequired<r.length)throw Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${r.length} provided`);this.publicKey=t,this.accountAddress=i?y.ba.from(i):this.publicKey.authKey().derivedAddress();let n=[];for(let e of r)n.push(this.publicKey.getIndex(e.getAnyPublicKey()));let s=r.map((e,t)=>[e,n[t]]);s.sort((e,t)=>e[1]-t[1]),this.signers=s.map(e=>e[0]),this.signerIndicies=s.map(e=>e[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:n})}static fromPublicKeysAndSigners(t){let{address:i,publicKeys:r,signaturesRequired:n,signers:s}=t;return new e({multiKey:new tB({publicKeys:r,signaturesRequired:n}),signers:s,address:i})}static isMultiKeySigner(t){return t instanceof e}signWithAuthenticator(e){return new tJ(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new tJ(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let e=this.signers.filter(e=>e instanceof iQ).map(async e=>e.waitForProofFetch());await Promise.all(e)}async checkKeylessAccountValidity(e){let t=this.signers.filter(e=>e instanceof iQ).map(t=>t.checkKeylessAccountValidity(e));await Promise.all(t)}sign(e){let t=[];for(let i of this.signers)t.push(i.sign(e));return new tO({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let i of this.signers)t.push(i.signTransaction(e));return new tO({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}},i3=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:i,address:r}=e;if(this.publicKey=i,this.accountAddress=r?y.ba.from(r):this.publicKey.authKey().derivedAddress(),i.threshold>t.length)throw Error(`Not enough signers provided to satisfy the required signatures. Need ${i.threshold} signers, but only ${t.length} provided`);if(i.threshold<t.length)throw Error(`More signers provided than required. Need ${i.threshold} signers, but ${t.length} provided`);let n=[];for(let e of t)n.push(this.publicKey.getIndex(e.publicKey()));let s=t.map((e,t)=>[e,n[t]]);s.sort((e,t)=>
8e[1]-t[1]),this.signers=s.map(e=>e[0]),this.signerIndices=s.map(e=>e[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:n})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new tG(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new tG(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let i of this.signers)t.push(i.sign(e));return new tV({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(iV(e))}};function i5(e,t){if(t.serializeStr(e.jwt),t.serializeStr(e.uidKey),t.serializeFixedBytes(e.pepper),e.ephemeralKeyPair.serialize(t),void 0===e.proof)throw Error("Cannot serialize - proof undefined");e.proof.serialize(t),t.serializeOption(e.verificationKeyHash,32)}function i6(e){return{jwt:e.deserializeStr(),uidKey:e.deserializeStr(),pepper:e.deserializeFixedBytes(31),ephemeralKeyPair:iJ.deserialize(e),proof:t_.deserialize(e),verificationKeyHash:e.deserializeOption("fixedBytes",32)}}(e=>{function t(e){let i=new y.m;switch(i.serializeU32AsUleb128(e.signingScheme),e.accountAddress.serialize(i),e.signingScheme){case 0:return e.privateKey.serialize(i),i.toUint8Array();case 2:{if(!iH(e))throw Error("Account is not a SingleKeySigner");let t=e.getAnyPublicKey();switch(i.serializeU32AsUleb128(t.variant),t.variant){case 3:return i5(e,i),i.toUint8Array();case 4:return i5(e,i),e.publicKey.jwkAddress.serialize(i),i.serializeBool(e.audless),i.toUint8Array();case 1:case 0:return e.privateKey.serialize(i),i.toUint8Array();default:throw Error(`Invalid public key variant: ${t.variant}`)}}case 3:return e.publicKey.serialize(i),i.serializeU32AsUleb128(e.signers.length),e.signers.forEach(e=>{i.serializeFixedBytes(t(e))}),i.toUint8Array();default:throw Error(`Deserialization of Account failed: invalid signingScheme value ${e.signingScheme}`)}}function i(e){let{address:t,signingScheme:r}=function(e){let t=e.deserializeUleb128AsU32();if(!Object.values(y.Z).includes(t))throw Error(`Deserialization of Account failed: SigningScheme variant ${t} is invalid`);return{address:y.ba.deserialize(e),signingScheme:t}}(e);switch(r){case 0:return new iq({privateKey:en.deserialize(e),address:t});case 2:{let i=e.deserializeUleb128AsU32();switch(i){case 0:return new ij({privateKey:en.deserialize(e),address:t});case 1:return new ij({privateKey:tK.deserialize(e),address:t});case 3:{let t=i6(e),i=tv(t);return new i2({...t,...i})}case 4:{let t=i6(e),i=y.ba.deserialize(e),r=e.deserializeBool(),n=tv(t);return new i1({...t,...n,jwkAddress:i,audless:r})}default:throw Error(`Unsupported public key variant ${i}`)}}case 3:{let r=tB.deserialize(e),n=e.deserializeUleb128AsU32(),s=[];for(let t=0;t<n;t+=1){let t=i(e);if(!iH(t)&&!(t instanceof iq))throw Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");s.push(t)}return new i8({multiKey:r,signers:s,address:t})}default:throw Error(`Deserialization of Account failed: invalid signingScheme value ${r}`)}}function r(e){return i(m.fromHex(e))}e.toBytes=t,e.toHexStringWithoutPrefix=function(e){return y.j.hexInputToStringWithoutPrefix(t(e))},e.toHexString=function(e){return y.j.hexInputToString(t(e))},e.deserialize=i,e.keylessAccountFromHex=function(e){let t=r(e);if(!(t instanceof i2))throw Error("Deserialization of KeylessAccount failed");return t},e.federatedKeylessAccountFromHex=function(e){let t=r(e);if(!(t instanceof i1))throw Error("Deserialization of FederatedKeylessAccount failed");return t},e.multiKeyAccountFromHex=function(e){let t=r(e);if(!(t instanceof i8))throw Error("Deserialization of MultiKeyAccount failed");return t},e.singleKeyAccountFromHex=function(e){let t=r(e);if(!(t instanceof ij))throw Error("Deserialization of SingleKeyAccount failed");return t},e.ed25519AccountFromHex=function(e){let t=r(e);if(!(t instanceof iq))throw Error("Deserialization of Ed25519Account failed");return t},e.fromHex=r,e.fromBytes=function(e){return r(e)}})(f||(f=t.AccountUtils={}));var i4=class e extends iG{constructor({signer:e,accountAddress:t,authenticationFunction:i}){if(super(),this.signingScheme=2,!y.qa.call(void 0,i))throw Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=t,this.publicKey=new R(this.accountAddress),this.sign=t=>new F(e(t))}static fromPermissionedSigner({signer:t,accountAddress:i}){return new e({signer:e=>{let i=new y.m;return t.publicKey.serialize(i),t.sign(e).serialize(i),i.toUint8Array()},accountAddress:h(i,()=>t.accountAddress),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(e){return new tX(this.authenticationFunction,P.sha3_256.call(void 0,e),this.sign(P.sha3_256.call(void 0,e)).toUint8Array())}signTransactionWithAuthenticator(e){return this.signWithAuthenticator(iV(e))}signTransaction(e){return this.sign(iV(e))}setSigner(e){this.sign=t=>new F(e(t))}},i9=class e extends i4{constructor({signer:t,authenticationFunction:i,abstractPublicKey:r}){super({accountAddress:new y.ba(e.computeAccountAddress(i,r)),signer:t,authenticationFunction:i}),this.abstractPublicKey=r}static computeAccountAddress(t,i){if(!y.qa.call(void 0,t))throw Error(`Invalid authentication function ${t} passed into DerivableAbstractedAccount`);let[r,n,s]=t.split("::"),a=P.sha3_256.create(),o=new y.m;y.ba.fromString(r).serialize(o),o.serializeStr(n),o.serializeStr(s),a.update(o.toUint8Array());let c=new y.m;return c.serializeBytes(i),a.update(c.toUint8Array()),a.update(new Uint8Array([e.ADDRESS_DOMAIN_SEPERATOR])),a.digest()}signWithAuthenticator(e){return new tX(this.authenticationFunction,P.sha3_256.call(void 0,e),this.sign(P.sha3_256.call(void 0,e)).value,this.abstractPublicKey)}};i9.ADDRESS_DOMAIN_SEPERATOR=5;var i7=`
9    fragment TokenActivitiesFields on token_activities_v2 {
10  after_value
11  before_value
12  entry_function_id_str
13  event_account_address
14  event_index
15  from_address
16  is_fungible_v2
17  property_version_v1
18  to_address
19  token_amount
20  token_data_id
21  token_standard
22  transaction_timestamp
23  transaction_version
24  type
25}
26    `,re=`
27    fragment AnsTokenFragment on current_aptos_names {
28  domain
29  expiration_timestamp
30  registered_address
31  subdomain
32  token_standard
33  is_primary
34  owner_address
35  subdomain_expiration_policy
36  domain_expiration_timestamp
37}
38    `,rt=`
39    fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
40  token_standard
41  token_properties_mutated_v1
42  token_data_id
43  table_type_v1
44  storage_id
45  property_version_v1
46  owner_address
47  last_transaction_version
48  last_transaction_timestamp
49  is_soulbound_v2
50  is_fungible_v2
51  amount
52  current_token_data {
53    collection_id
54    description
55    is_fungible_v2
56    largest_property_version_v1
57    last_transaction_timestamp
58    last_transaction_version
59    maximum
60    supply
61    token_data_id
62    token_name
63    token_properties
64    token_standard
65    token_uri
66    decimals
67    current_collection {
68      collection_id
69      collection_name
70      creator_address
71      current_supply
72      description
73      last_transaction_timestamp
74      last_transaction_version
75      max_supply
76      mutable_description
77      mutable_uri
78      table_handle_v1
79      token_standard
80      total_minted_v2
81      uri
82    }
83  }
84}
85    `,ri=`
86    query getAccountAddressesForAuthKey($where_condition: auth_key_account_addresses_bool_exp, $order_by: [auth_key_account_addresses_order_by!]) {
87  auth_key_account_addresses(where: $where_condition, order_by: $order_by) {
88    auth_key
89    account_address
90    last_transaction_version
91    is_auth_key_used
92  }
93}
94    `,rr=`
95    query getAccountCoinsCount($address: String) {
96  current_fungible_asset_balances_aggregate(
97    where: {owner_address: {_eq: $address}}
98  ) {
99    aggregate {
100      count
101    }
102  }
103}
104    `,rn=`
105    query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
106  current_fungible_asset_balances(
107    where: $where_condition
108    offset: $offset
109    limit: $limit
110    order_by: $order_by
111  ) {
112    amount
113    asset_type
114    is_frozen
115    is_primary
116    last_transaction_timestamp
117    last_transaction_version
118    owner_address
119    storage_id
120    token_standard
121    metadata {
122      token_standard
123      symbol
124      supply_aggregator_table_key_v1
125      supply_aggregator_table_handle_v1
126      project_uri
127      name
128      last_transaction_version
129      last_transaction_timestamp
130      icon_uri
131      decimals
132      creator_address
133      asset_type
134    }
135  }
136}
137    `,rs=`
138    query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
139  current_collection_ownership_v2_view(
140    where: $where_condition
141    offset: $offset
142    limit: $limit
143    order_by: $order_by
144  ) {
145    current_collection {
146      collection_id
147      collection_name
148      creator_address
149      current_supply
150      description
151      last_transaction_timestamp
152      last_transaction_version
153      mutable_description
154      max_supply
155      mutable_uri
156      table_handle_v1
157      token_standard
158      total_minted_v2
159      uri
160    }
161    collection_id
162    collection_name
163    collection_uri
164    creator_address
165    distinct_tokens
166    last_transaction_version
167    owner_address
168    single_token_uri
169  }
170}
171    `,ra=`
172    query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
173  current_token_ownerships_v2(
174    where: $where_condition
175    offset: $offset
176    limit: $limit
177    order_by: $order_by
178  ) {
179    ...CurrentTokenOwnershipFields
180  }
181}
182    ${rt}`,ro=`
183    query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
184  current_token_ownerships_v2(
185    where: $where_condition
186    offset: $offset
187    limit: $limit
188    order_by: $order_by
189  ) {
190    ...CurrentTokenOwnershipFields
191  }
192}
193    ${rt}`,rc=`
194    query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
195  current_token_ownerships_v2_aggregate(
196    where: $where_condition
197    offset: $offset
198    limit: $limit
199  ) {
200    aggregate {
201      count
202    }
203  }
204}
205    `,ru=`
206    query getAccountTransactionsCount($address: String) {
207  account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
208    aggregate {
209      count
210    }
211  }
212}
213    `,rl=`
214    query getAuthKeysForPublicKey($where_condition: public_key_auth_keys_bool_exp, $order_by: [public_key_auth_keys_order_by!]) {
215  public_key_auth_keys(where: $where_condition, order_by: $order_by) {
216    public_key
217    public_key_type
218    auth_key
219    account_public_key
220    last_transaction_version
221    is_public_key_used
222    signature_type
223  }
224}
225    `,rd=`
226    query getChainTopUserTransactions($limit: Int) {
227  user_transactions(limit: $limit, order_by: {version: desc}) {
228    version
229  }
230}
231    `,rp=`
232    query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
233  current_collections_v2(where: $where_condition) {
234    uri
235    total_minted_v2
236    token_standard
237    table_handle_v1
238    mutable_uri
239    mutable_description
240    max_supply
241    collection_id
242    collection_name
243    creator_address
244    current_supply
245    description
246    last_transaction_timestamp
247    last_transaction_version
248    cdn_asset_uris {
249      cdn_image_uri
250      asset_uri
251      animation_optimizer_retry_count
252      cdn_animation_uri
253      cdn_json_uri
254      image_optimizer_retry_count
255      json_parser_retry_count
256      raw_animation_uri
257      raw_image_uri
258    }
259  }
260}
261    `,rh=`
262    query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
263  current_fungible_asset_balances(
264    where: $where_condition
265    offset: $offset
266    limit: $limit
267  ) {
268    amount
269    asset_type
270    is_frozen
271    is_primary
272    last_transaction_timestamp
273    last_transaction_version
274    owner_address
275    storage_id
276    token_standard
277  }
278}
279    `,rg=`
280    query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
281  delegated_staking_activities(
282    where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
283  ) {
284    amount
285    delegator_address
286    event_index
287    event_type
288    pool_address
289    transaction_version
290  }
291}
292    `,rf=`
293    query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
294  fungible_asset_activities(
295    where: $where_condition
296    offset: $offset
297    limit: $limit
298  ) {
299    amount
300    asset_type
301    block_height
302    entry_function_id_str
303    event_index
304    gas_fee_payer_address
305    is_frozen
306    is_gas_fee
307    is_transaction_success
308    owner_address
309    storage_id
310    storage_refund_amount
311    token_standard
312    transaction_timestamp
313    transaction_version
314    type
315  }
316}
317    `,ry=`
318    query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
319  fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
320    icon_uri
321    project_uri
322    supply_aggregator_table_handle_v1
323    supply_aggregator_table_key_v1
324    creator_address
325    asset_type
326    decimals
327    last_transaction_timestamp
328    last_transaction_version
329    name
330    symbol
331    token_standard
332    supply_v2
333    maximum_v2
334  }
335}
336    `,rm=`
337    query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
338  current_aptos_names(
339    limit: $limit
340    where: $where_condition
341    order_by: $order_by
342    offset: $offset
343  ) {
344    ...AnsTokenFragment
345  }
346}
347    ${re}`,r_=`
348    query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
349  num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
350    num_active_delegator
351    pool_address
352  }
353}
354    `,rA=`
355    query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
356  current_objects(
357    where: $where_condition
358    offset: $offset
359    limit: $limit
360    order_by: $order_by
361  ) {
362    allow_ungated_transfer
363    state_key_hash
364    owner_address
365    object_address
366    last_transaction_version
367    last_guid_creation_num
368    is_deleted
369  }
370}
371    `,rw=`
372    query getProcessorStatus($where_condition: processor_status_bool_exp) {
373  processor_status(where: $where_condition) {
374    last_success_version
375    processor
376    last_updated
377  }
378}
379    `,rb=`
380    query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
381  table_items(
382    where: $where_condition
383    offset: $offset
384    limit: $limit
385    order_by: $order_by
386  ) {
387    decoded_key
388    decoded_value
389    key
390    table_handle
391    transaction_version
392    write_set_change_index
393  }
394}
395    `,rv=`
396    query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
397  table_metadatas(
398    where: $where_condition
399    offset: $offset
400    limit: $limit
401    order_by: $order_by
402  ) {
403    handle
404    key_type
405    value_type
406  }
407}
408    `,rT=`
409    query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
410  token_activities_v2(
411    where: $where_condition
412    order_by: $order_by
413    offset: $offset
414    limit: $limit
415  ) {
416    ...TokenActivitiesFields
417  }
418}
419    ${i7}`,rE=`
420    query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
421  current_token_ownerships_v2(
422    where: $where_condition
423    offset: $offset
424    limit: $limit
425    order_by: $order_by
426  ) {
427    ...CurrentTokenOwnershipFields
428  }
429}
430    ${rt}`,rS=`
431    query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
432  current_token_datas_v2(
433    where: $where_condition
434    offset: $offset
435    limit: $limit
436    order_by: $order_by
437  ) {
438    collection_id
439    description
440    is_fungible_v2
441    largest_property_version_v1
442    last_transaction_timestamp
443    last_transaction_version
444    maximum
445    supply
446    token_data_id
447    token_name
448    token_properties
449    token_standard
450    token_uri
451    decimals
452    current_collection {
453      collection_id
454      collection_name
455      creator_address
456      current_supply
457      description
458      last_transaction_timestamp
459      last_transaction_version
460      max_supply
461      mutable_description
462      mutable_uri
463      table_handle_v1
464      token_standard
465      total_minted_v2
466      uri
467    }
468  }
469}
470    `;async function rz(e){let{aptosConfig:t}=e,{data:i}=await ej({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return i}async function rC(e){let{aptosConfig:t,limit:i}=e;return(await rU({aptosConfig:t,query:{query:rd,variables:{limit:i}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function rU(e){let{aptosConfig:t,query:i,originMethod:r}=e,{data:n}=await eQ({aptosConfig:t,originMethod:h(r,()=>"queryIndexer"),path:"",body:i,overrides:{WITH_CREDENTIALS:!1}});return n}async function rx(e){let{aptosConfig:t}=e;return(await rU({aptosConfig:t,query:{query:rw},originMethod:"getProcessorStatuses"})).processor_status}async function rk(e){return BigInt((await rx({aptosConfig:e.aptosConfig}))[0].last_success_version)}async function rP(e){let{aptosConfig:t,processorType:i}=e;return(await rU({aptosConfig:t,query:{query:rw,variables:{where_condition:{processor:{_eq:i}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function rK(e){let{aptosConfig:t,accountAddress:i}=e,{data:r}=await ej({aptosConfig:t,originMethod:"getInfo",path:`accounts/${y.ba.from(i).toString()}`});return r}async function rI(e){return void 0!==g([e,"access",e=>e.options,"optionalAccess",e=>e.ledgerVersion])?rN(e):e3(async()=>rN(e),`module-${e.accountAddress}-${e.moduleName}`,3e5)()}async function rN(e){let{aptosConfig:t,accountAddress:i,moduleName:r,options:n}=e,{data:s}=await ej({aptosConfig:t,originMethod:"getModule",path:`accounts/${y.ba.from(i).toString()}/module/${r}`,params:{ledger_version:g([n,"optionalAccess",e=>e.ledgerVersion])}});return s}async function r$(e){let{aptosConfig:t,handle:i,data:r,options:n}=e;return(await eZ({aptosConfig:t,originMethod:"getTableItem",path:`tables/${i}/item`,params:{ledger_version:g([n,"optionalAccess",e=>e.ledgerVersion])},body:r})).data}async function rF(e){let{aptosConfig:t,options:i}=e,r={query:rb,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),offset:g([i,"optionalAccess",e=>e.offset]),limit:g([i,"optionalAccess",e=>e.limit]),order_by:g([i,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:r,originMethod:"getTableItemsData"})).table_items}async function rR(e){let{aptosConfig:t,options:i}=e,r={query:rv,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),offset:g([i,"optionalAccess",e=>e.offset]),limit:g([i,"optionalAccess",e=>e.limit]),order_by:g([i,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function rB(e){let{aptosConfig:t,options:i}=e;return eW({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:g([i,"optionalAccess",e=>e.offset]),limit:g([i,"optionalAccess",e=>e.limit])}})}async function rD(e){let{aptosConfig:t}=e;return e3(async()=>{let{data:e}=await ej({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,3e5)()}async function rO(e){let{aptosConfig:t,ledgerVersion:i}=e,{data:r}=await ej({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${i}`});return r}async function rL(e){let{aptosConfig:t,transactionHash:i}=e,{data:r}=await ej({aptosConfig:t,path:`transactions/by_hash/${i}`,originMethod:"getTransactionByHash"});return r}async function rM(e){let{aptosConfig:t,transactionHash:i}=e;try{return"pending_transaction"===(await rL({aptosConfig:t,transactionHash:i})).type}catch(e){if(404===g([e,"optionalAccess",e=>e.status]))return!0;throw e}}async function rV(e){let{aptosConfig:t,transactionHash:i}=e,{data:r}=await ej({aptosConfig:t,path:`transactions/wait_by_hash/${i}`,originMethod:"longWaitForTransaction"});return r}async function rq(e){let{aptosConfig:t,transactionHash:i,options:r}=e,n=h(g([r,"optionalAccess",e=>e.timeoutSecs]),()=>20),s=h(g([r,"optionalAccess",e=>
470e.checkSuccess]),()=>!0),a=!0,o=0,c,u,l=200;function d(e){if(!(e instanceof eM)||(u=e,404!==e.status&&e.status>=400&&e.status<500))throw e}try{c=await rL({aptosConfig:t,transactionHash:i}),a="pending_transaction"===c.type}catch(e){d(e)}if(a){let e=Date.now();try{c=await rV({aptosConfig:t,transactionHash:i}),a="pending_transaction"===c.type}catch(e){d(e)}o=(Date.now()-e)/1e3}for(;a&&!(o>=n);){try{if(c=await rL({aptosConfig:t,transactionHash:i}),!(a="pending_transaction"===c.type))break}catch(e){d(e)}await y.fa.call(void 0,l),o+=l/1e3,l*=1.5}if(void 0===c)throw u||new rj(`Fetching transaction ${i} failed and timed out after ${n} seconds`,c);if("pending_transaction"===c.type)throw new rj(`Transaction ${i} timed out in pending state after ${n} seconds`,c);if(!s)return c;if(!c.success)throw new rG(`Transaction ${i} failed with an error: ${c.vm_status}`,c);return c}async function rH(e){let{aptosConfig:t,processorType:i}=e,r=BigInt(e.minimumLedgerVersion),n=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-n>3e3)throw Error("waitForLastSuccessIndexerVersionSync timeout");if((s=void 0===i?await rk({aptosConfig:t}):(await rP({aptosConfig:t,processorType:i})).last_success_version)>=r)break;await y.fa.call(void 0,200)}}var rj=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},rG=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function rW(e){let{aptosConfig:t,ledgerVersion:i,options:r}=e,{data:n}=await ej({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${i}`,params:{with_transactions:g([r,"optionalAccess",e=>e.withTransactions])}});return rY({block:n,...e})}async function rJ(e){let{aptosConfig:t,blockHeight:i,options:r}=e,{data:n}=await ej({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${i}`,params:{with_transactions:g([r,"optionalAccess",e=>e.withTransactions])}});return rY({block:n,...e})}async function rY(e){let{aptosConfig:t,block:i,options:r}=e;if(g([r,"optionalAccess",e=>e.withTransactions])){i.transactions=h(i.transactions,()=>[]);let e=i.transactions[i.transactions.length-1],r=BigInt(i.first_version),n=BigInt(i.last_version),s=g([e,"optionalAccess",e=>e.version]),a;if((a=void 0===s?r-1n:BigInt(s))===n)return i;let o=[];for(let e=a+1n;e<n;e+=BigInt(100))o.push(rB({aptosConfig:t,options:{offset:e,limit:Math.min(Number(100n),Number(n-e+1n))}}));for(let e of(await Promise.all(o)))i.transactions.push(...e)}return i}function rX(e){return!!e.match(/^[_a-zA-Z0-9]+$/)}function rZ(e){return!!e.match(/\s/)}var rQ=((l=rQ||{}).InvalidTypeTag="unknown type",l.UnexpectedGenericType="unexpected generic type",l.UnexpectedTypeArgumentClose="unexpected '>'",l.UnexpectedWhitespaceCharacter="unexpected whitespace character",l.UnexpectedComma="unexpected ','",l.TypeArgumentCountMismatch="type argument count doesn't match expected amount",l.MissingTypeArgumentClose="no matching '>' for '<'",l.MissingTypeArgument="no type argument before ','",l.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",l.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",l.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",l.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",l.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",l.InvalidAddress="struct address must be valid",l),r0=t.TypeTagParserError=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function r2(e,t){let i=h(g([t,"optionalAccess",e=>e.allowGenerics]),()=>!1),r=[],n=[],s=[],a=0,o="",c=1;for(;a<e.length;){let t=e[a];if("<"===t)r.push({savedExpectedTypes:c,savedStr:o,savedTypes:s}),o="",s=[],c=1;else if(">"===t){if(""!==o){let e=r1(o,n,i);s.push(e)}let t=r.pop();if(void 0===t)throw new r0(e,"unexpected '>'");if(c!==s.length)throw new r0(e,"type argument count doesn't match expected amount");let{savedStr:a,savedTypes:u,savedExpectedTypes:l}=t;n=s,s=u,o=a,c=l}else if(","===t){if(0===r.length)throw new r0(e,"unexpected ','");if(0===o.length)throw new r0(e,"no type argument before ','");let t=r1(o,n,i);n=[],s.push(t),o="",c+=1}else if(rZ(t)){let t=!1;if(0!==o.length){let e=r1(o,n,i);n=[],s.push(e),o="",t=!0}a=function(e,t){let i=t;for(;i<e.length&&rZ(e[i]);i+=1);return i}(e,a);let r=e[a];if(a<e.length&&t&&","!==r&&">"!==r)throw new r0(e,"unexpected whitespace character");continue}else o+=t;a+=1}if(r.length>0)throw new r0(e,"no matching '>' for '<'");switch(s.length){case 0:return r1(o,n,i);case 1:if(""===o)return s[0];throw new r0(e,"unexpected ','");default:throw new r0(e,"unexpected whitespace character")}}function r1(e,t,i){let r=e.trim();if(function(e){switch(e){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}(r.toLowerCase())&&t.length>0)throw new r0(e,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new ie;case"bool":return new t1;case"address":return new t7;case"u8":return new t8;case"u16":return new t3;case"u32":return new t5;case"u64":return new t6;case"u128":return new t4;case"u256":return new t9;case"vector":if(1!==t.length)throw new r0(e,"vector type expected to have exactly one type argument");return new ir(t[0]);default:let n;if(r.match(/^&.+$/))return new it(r1(r.substring(1),t,i));if(r.match(/^T[0-9]+$/)){if(i)return new ii(Number(r.split("T")[1]));throw new r0(e,"unexpected generic type")}if(!r.match(/:/))throw new r0(e,"unknown type");let s=r.split("::");if(3!==s.length)throw new r0(e,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");try{n=y.ba.fromString(s[0])}catch(t){throw new r0(e,"struct address must be valid")}if(!rX(s[1]))throw new r0(e,"module name must only contain alphanumeric or '_' characters");if(!rX(s[2]))throw new r0(e,"struct name must only contain alphanumeric or '_' characters");return new is(new ia(n,new tQ(s[1]),new tQ(s[2]),t))}}function r8(e){return"boolean"==typeof e}function r3(e){return"string"==typeof e}function r5(e){return"number"==typeof e}function r6(e){return r5(e)?e:r3(e)&&""!==e?Number.parseInt(e,10):void 0}function r4(e){return"number"==typeof e||"bigint"==typeof e||"string"==typeof e}function r9(e){return null==e}function r7(e){return ne(e)||nn(e)||ns(e)||na(e)||no(e)||nc(e)||nu(e)||nt(e)||ni(e)||nr(e)||e instanceof C||e instanceof k}function ne(e){return e instanceof w}function nt(e){return e instanceof y.ba}function ni(e){return e instanceof x}function nr(e){return e instanceof _}function nn(e){return e instanceof b}function ns(e){return e instanceof v}function na(e){return e instanceof T}function no(e){return e instanceof E}function nc(e){return e instanceof S}function nu(e){return e instanceof z}function nl(e){return"bytecode"in e}
470function nd(e,t){throw Error(`Type mismatch for argument ${t}, expected '${e}'`)}function np(e){let t=e.params.findIndex(e=>"signer"!==e&&"&signer"!==e);return t<0?e.params.length:t}var nh=new TextEncoder;function ng(e){return h(g([e,"optionalAccess",e=>e.map,"call",e=>e(e=>r3(e)?r2(e):e)]),()=>[])}async function nf(e,t,i){return(await nJ({aptosConfig:i,accountAddress:e,moduleName:t})).abi}async function ny(e,t,i,r){let n=await nf(e,t,r);if(!n)throw Error(`Could not find module ABI for '${e}::${t}'`);return n.exposed_functions.find(e=>e.name===i)}async function nm(e,t,i,r){let n=await ny(e,t,i,r);if(!n)throw Error(`Could not find function ABI for '${e}::${t}::${i}'`);let s=[];for(let e=0;e<n.params.length;e+=1)s.push(r2(n.params[e],{allowGenerics:!0}));return{typeParameters:n.generic_type_params,parameters:s}}async function n_(e,t,i,r){let n=await ny(e,t,i,r);if(!n)throw Error(`Could not find entry function ABI for '${e}::${t}::${i}'`);if(!n.is_entry)throw Error(`'${e}::${t}::${i}' is not an entry function`);let s=np(n),a=[];for(let e=s;e<n.params.length;e+=1)a.push(r2(n.params[e],{allowGenerics:!0}));return{signers:s,typeParameters:n.generic_type_params,parameters:a}}async function nA(e,t,i,r){let n=await ny(e,t,i,r);if(!n)throw Error(`Could not find view function ABI for '${e}::${t}::${i}'`);if(!n.is_view)throw Error(`'${e}::${t}::${i}' is not an view function`);let s=[];for(let e=0;e<n.params.length;e+=1)s.push(r2(n.params[e],{allowGenerics:!0}));let a=[];for(let e=0;e<n.return.length;e+=1)a.push(r2(n.return[e],{allowGenerics:!0}));return{typeParameters:n.generic_type_params,parameters:s,returnTypes:a}}function nw(e,t,i,r,n,s){let a;if("exposed_functions"in t){let i=t.exposed_functions.find(t=>t.name===e);if(!i)throw Error(`Could not find function ABI for '${t.address}::${t.name}::${e}'`);if(r>=i.params.length)throw Error(`Too many arguments for '${e}', expected ${i.params.length}`);a=r2(i.params[r],{allowGenerics:!0})}else{if(r>=t.parameters.length)throw Error(`Too many arguments for '${e}', expected ${t.parameters.length}`);a=t.parameters[r]}return nb(i,a,r,n,"exposed_functions"in t?t:void 0,s)}function nb(e,t,i,r,n,s){return r7(e)?(function e(t,i,r){if(t.isBool()){if(ne(i))return;nd("Bool",r)}if(t.isAddress()){if(nt(i))return;nd("AccountAddress",r)}if(t.isU8()){if(nn(i))return;nd("U8",r)}if(t.isU16()){if(ns(i))return;nd("U16",r)}if(t.isU32()){if(na(i))return;nd("U32",r)}if(t.isU64()){if(no(i))return;nd("U64",r)}if(t.isU128()){if(nc(i))return;nd("U128",r)}if(t.isU256()){if(nu(i))return;nd("U256",r)}if(t.isVector()){if(i instanceof C){i.values.length>0&&e(t.value,i.values[0],r);return}nd("MoveVector",r)}if(t instanceof is){if(t.isString()){if(ni(i))return;nd("MoveString",r)}if(t.isObject()){if(nt(i))return;nd("AccountAddress",r)}if(t.isOption()){if(i instanceof k){void 0!==i.value&&e(t.value.typeArgs[0],i.value,r);return}nd("MoveOption",r)}}throw Error(`Type mismatch for argument ${r}, expected '${t.toString()}'`)}(t,e,i),e):function(e,t,i,r,n,s){if(t.isBool()){if(r8(e))return new w(e);if(r3(e)){if("true"===e)return new w(!0);if("false"===e)return new w(!1)}nd("boolean",i)}if(t.isAddress()){if(r3(e))return y.ba.fromString(e);if(e&&"object"==typeof e&&"data"in e&&e.data instanceof Uint8Array)return new y.ba(e.data);nd("string | AccountAddress",i)}if(t.isU8()){let t=r6(e);if(void 0!==t)return new b(t);nd("number | string",i)}if(t.isU16()){let t=r6(e);if(void 0!==t)return new v(t);nd("number | string",i)}if(t.isU32()){let t=r6(e);if(void 0!==t)return new T(t);nd("number | string",i)}if(t.isU64()){if(r4(e))return new E(BigInt(e));nd("bigint | number | string",i)}if(t.isU128()){if(r4(e))return new S(BigInt(e));nd("bigint | number | string",i)}if(t.isU256()){if(r4(e))return new z(BigInt(e));nd("bigint | number | string",i)}if(t.isGeneric()){let s=t.value;if(s<0||s>=r.length)throw Error(`Generic argument ${t.toString()}
470 is invalid for argument ${i}`);return nb(e,r[s],i,r,n)}if(t.isVector()){if(t.value.isU8()){if(r3(e))return C.U8(nh.encode(e));if(e instanceof Uint8Array)return C.U8(e);if(e instanceof ArrayBuffer)return C.U8(new Uint8Array(e))}if(r3(e)&&e.startsWith("["))return nb(JSON.parse(e),t,i,r);if(Array.isArray(e))return new C(e.map(e=>nb(e,t.value,i,r,n)));throw Error(`Type mismatch for argument ${i}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(r3(e))return new x(e);nd("string",i)}if(t.isObject()){if(r3(e))return y.ba.fromString(e);if(e&&"object"==typeof e&&"data"in e&&e.data instanceof Uint8Array)return new y.ba(e.data);nd("string | AccountAddress",i)}if(t.isDelegationKey()||t.isRateLimiter()){if(e instanceof Uint8Array)return new _(e);nd("Uint8Array",i)}if(t.isOption())return r9(e)?(t.value.typeArgs[0],new k(null)):new k(nb(e,t.value.typeArgs[0],i,r,n));if(0===g([n,"optionalAccess",e=>e.structs,"access",e=>e.find,"call",e=>e(e=>e.name===t.value.name.identifier),"optionalAccess",e=>e.fields,"access",e=>e.length])&&e instanceof Uint8Array)return new _(e);if(e instanceof Uint8Array&&g([s,"optionalAccess",e=>e.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${i}. Continuing since 'allowUnknownStructs' is enabled.`),new _(e);throw Error(`Unsupported struct input type for argument ${i}, type '${t.toString()}'`)}throw Error(`Type mismatch for argument ${i}, type '${t.toString()}'`)}(e,t,i,r,n,s)}async function nv(e){if(nl(e))return new id(new iy(y.j.fromHexInput(e.bytecode).toUint8Array(),ng(e.typeArguments),e.functionArguments));let{moduleAddress:t,moduleName:i,functionName:r}=y.pa.call(void 0,e.function),n=await nN({key:"entry-function",moduleAddress:t,moduleName:i,functionName:r,aptosConfig:e.aptosConfig,abi:e.abi,fetch:n_});return nT({...e,abi:n})}function nT(e){let t=e.abi,{moduleAddress:i,moduleName:r,functionName:n}=y.pa.call(void 0,e.function),s=ng(e.typeArguments);if(s.length!==t.typeParameters.length)throw Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let a=e.functionArguments.map((i,r)=>nw(e.function,t,i,r,s));if(a.length!==t.parameters.length)throw Error(`Too few arguments for '${i}::${r}::${n}', expected ${t.parameters.length} but got ${a.length}`);let o=ig.build(`${i}::${r}`,n,s,a);return"multisigAddress"in e?new ih(new im(y.ba.from(e.multisigAddress),new i_(o))):new ip(o)}async function nE(e){let{moduleAddress:t,moduleName:i,functionName:r}=y.pa.call(void 0,e.function);return nS({abi:await nN({key:"view-function",moduleAddress:t,moduleName:i,functionName:r,aptosConfig:e.aptosConfig,abi:e.abi,fetch:nA}),...e})}function nS(e){let t=e.abi,{moduleAddress:i,moduleName:r,functionName:n}=y.pa.call(void 0,e.function),s=ng(e.typeArguments);if(s.length!==t.typeParameters.length)throw Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${s.length}`);let a=h(g([e,"optionalAccess",e=>e.functionArguments,"optionalAccess",e=>e.map,"call",i=>i((i,r)=>nw(e.function,t,i,r,s))]),()=>[]);if(a.length!==t.parameters.length)throw Error(`Too few arguments for '${i}::${r}::${n}', expected ${t.parameters.length} but got ${a.length}`);return ig.build(`${i}::${r}`,n,s,a)}async function nz(e){let{aptosConfig:t,sender:i,payload:r,options:n,feePayerAddress:s}=e;if(void 0!==g([n,"optionalAccess",e=>e.replayProtectionNonce])&&void 0!==g([n,"optionalAccess",e=>e.accountSequenceNumber]))throw Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let a=async()=>eE[t.network]?{chainId:eE[t.network]}:{chainId:(await rz({aptosConfig:t})).chain_id},o=async()=>g([n,"optionalAccess",e=>e.gasUnitPrice])?{gasEstimate:n.gasUnitPrice}:{gasEstimate:(await rD({aptosConfig:t})).gas_estimate},c=async()=>{let e=async()=>void 0!==g([n,"optionalAccess",e=>e.accountSequenceNumber])?n.accountSequenceNumber:void 0!==g([n,"optionalAccess",e=>e.replayProtectionNonce])?3735928559n:(await rK({aptosConfig:t,accountAddress:i})).sequence_number;if(!(s&&y.ba.from(s).equals(y.ba.ZERO)))return e();try{return await e()}catch(e){return 0}},[{chainId:u},{gasEstimate:l},d]=await Promise.all([a(),o(),c()]),{maxGasAmount:p,gasUnitPrice:f,expireTimestamp:m,replayProtectionNonce:_}={maxGasAmount:g([n,"optionalAccess",e=>e.maxGasAmount])?BigInt(n.maxGasAmount):BigInt(t.getDefaultMaxGasAmount()),gasUnitPrice:h(g([n,"optionalAccess",e=>e.gasUnitPrice]),()=>BigInt(l)),expireTimestamp:h(g([n,"optionalAccess",e=>
470e.expireTimestamp]),()=>BigInt(Math.floor(Date.now()/1e3)+t.getDefaultTxnExpirySecFromNow())),replayProtectionNonce:g([n,"optionalAccess",e=>e.replayProtectionNonce])?BigInt(n.replayProtectionNonce):void 0},A=r;return void 0!==_&&(A=nC(r,_)),new iC(y.ba.from(i),BigInt(d),A,BigInt(p),BigInt(f),BigInt(m),new tZ(u))}function nC(e,t){if(e instanceof id)return new iw(new iv(e.script),new iz(void 0,t));if(e instanceof ip)return new iw(new iT(e.entryFunction),new iz(void 0,t));if(e instanceof ih){let i=e.multiSig.transaction_payload,r;if(void 0===i||void 0===g([i,"optionalAccess",e=>e.transaction_payload]))r=new iE;else if(i.transaction_payload instanceof ig)r=new iT(i.transaction_payload);else throw Error("Scripts are not supported in multi-sig transactions.");return new iw(r,new iz(e.multiSig.multisig_address,t))}throw Error(`Unsupported payload type: ${e}`)}async function nU(e){let{aptosConfig:t,sender:i,payload:r,options:n,feePayerAddress:s}=e,a=await nz({aptosConfig:t,sender:i,payload:r,options:n,feePayerAddress:s});return"secondarySignerAddresses"in e?new iO(a,h(g([e,"access",e=>e.secondarySignerAddresses,"optionalAccess",e=>e.map,"call",e=>e(e=>y.ba.from(e))]),()=>[]),e.feePayerAddress?y.ba.from(e.feePayerAddress):void 0):new iD(a,e.feePayerAddress?y.ba.from(e.feePayerAddress):void 0)}function nx(e){let t,{signerPublicKey:i,transaction:r,secondarySignersPublicKeys:n,feePayerPublicKey:s}=e,a=nk(i);if(r.feePayerAddress){let e=new ik(r.rawTransaction,h(r.secondarySignerAddresses,()=>[]),r.feePayerAddress),t=[];r.secondarySignerAddresses&&(t=n?n.map(e=>nk(e)):Array.from({length:r.secondarySignerAddresses.length},()=>nk(void 0)));let i=nk(s),o=new iF(a,h(r.secondarySignerAddresses,()=>[]),t,{address:r.feePayerAddress,authenticator:i});return new iB(e.raw_txn,o).bcsToBytes()}if(r.secondarySignerAddresses){let e=new ix(r.rawTransaction,r.secondarySignerAddresses),t=[];t=n?n.map(e=>nk(e)):Array.from({length:r.secondarySignerAddresses.length},()=>nk(void 0));let i=new i$(a,r.secondarySignerAddresses,t);return new iB(e.raw_txn,i).bcsToBytes()}if(a instanceof tj)t=new iI(a.public_key,a.signature);else if(a instanceof tW||a instanceof tJ)t=new iR(a);else if(a instanceof tY)t=new iR(a);else throw Error("Invalid public key");return new iB(r.rawTransaction,t).bcsToBytes()}function nk(e){if(!e)return new tY;let t=ts.isInstance(e)||tU.isInstance(e)||tP.isInstance(e)?new t$(e):e,i=new ea(new Uint8Array(64));if(er.isInstance(t))return new tj(t,i);if(t$.isInstance(t))return ts.isInstance(t.publicKey)?new tW(t,new tF(tl.getSimulationSignature())):new tW(t,new tF(i));if(tB.isInstance(t))return new tJ(t,new tO({signatures:t.publicKeys.map(e=>new tF(ts.isInstance(e.publicKey)||tU.isInstance(e.publicKey)?tl.getSimulationSignature():i)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((e,t)=>t)})}));throw Error("Unsupported PublicKey used for simulations")}function nP(e){let{transaction:t,feePayerAuthenticator:i,additionalSignersAuthenticators:r}=e,n=eF(tH,e.senderAuthenticator),s;if(t.feePayerAddress){if(!i)throw Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");s=new iF(n,h(t.secondarySignerAddresses,()=>[]),h(r,()=>[]),{address:t.feePayerAddress,authenticator:i})}else if(t.secondarySignerAddresses){if(!r)throw Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");s=new i$(n,t.secondarySignerAddresses,r)}else s=n instanceof tj?new iI(n.public_key,n.signature):n instanceof tG?new iN(n.public_key,n.signature):new iR(n);return new iB(t.rawTransaction,s).bcsToBytes()}function nK(e){let t=P.sha3_256.create();for(let i of e)t.update(i);return t.digest()}var nI=nK(["APTOS::Transaction"]);async function nN({key:e,moduleAddress:t,moduleName:i,functionName:r,aptosConfig:n,abi:s,fetch:a}){return void 0!==s?s:e3(async()=>a(t,i,r,n),`${e}-${n.network}-${t}-${i}-${r}`,3e5)()}async function n$(e){let t=await nF(e);return nR(e,t)}async function nF(e){let{aptosConfig:t,data:i}=e,r,n;return"bytecode"in i?n=await nv(i):(r="multisigAddress"in i?{aptosConfig:t,multisigAddress:i.multisigAddress,function:i.function,functionArguments:i.functionArguments,typeArguments:i.typeArguments,abi:i.abi}:{aptosConfig:t,function:i.function,functionArguments:i.functionArguments,typeArguments:i.typeArguments,abi:i.abi},n=await nv(r)),n}async function nR(e,t){let{aptosConfig:i,sender:r,options:n}=e,s;if(!0===e.withFeePayer&&(s=y.ba.ZERO.toString()),"secondarySignerAddresses"in e){let{secondarySignerAddresses:a}=e;return nU({aptosConfig:i,sender:r,payload:t,options:n,secondarySignerAddresses:a,feePayerAddress:s})}return nU({aptosConfig:i,sender:r,payload:t,options:n,feePayerAddress:s})}function nB(e){let{signer:t,transaction:i}=e;return t.signTransactionWithAuthenticator(i)}function nD(e){let{signer:t,transaction:i}=e;if(!i.feePayerAddress)throw Error(`Transaction ${i} is not a Fee Payer transaction`);return i.feePayerAddress=t.accountAddress,nB({signer:t,transaction:i})}async function nO(e){let{aptosConfig:t,transaction:i,signerPublicKey:r,secondarySignersPublicKeys:n,feePayerPublicKey:s,options:a}=e,o=nx({transaction:i,signerPublicKey:r,secondarySignersPublicKeys:n,feePayerPublicKey:s,options:a}),{data:c}=await eZ({aptosConfig:t,body:o,path:"transactions/simulate",params:{estimate_gas_unit_price:h(g([e,"access",e=>e.options,"optionalAccess",e=>e.estimateGasUnitPrice]),()=>!1),estimate_max_gas_amount:h(g([e,"access",e=>e.options,"optionalAccess",e=>e.estimateMaxGasAmount]),()=>!1),estimate_prioritized_gas_unit_price:h(g([e,"access",e=>e.options,"optionalAccess",e=>e.estimatePrioritizedGasUnitPrice]),()=>!1)},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function nL(e){let{aptosConfig:t,transactionSubmitter:i}=e,r=void 0===i?t.getTransactionSubmitter():i;
470if(r)return r.submitTransaction(e);let n=nP({...e});try{let{data:e}=await eZ({aptosConfig:t,body:n,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return e}catch(i){let e=iB.deserialize(new m(n));throw e.authenticator.isSingleSender()&&e.authenticator.sender.isSingleKey()&&(e.authenticator.sender.public_key.publicKey instanceof ts||e.authenticator.sender.public_key.publicKey instanceof tU)&&await iQ.fetchJWK({aptosConfig:t,publicKey:e.authenticator.sender.public_key.publicKey,kid:e.authenticator.sender.signature.signature.getJwkKid()}),i}}async function nM(e){let{aptosConfig:t,signer:i,feePayer:r,transaction:n,...s}=e;iX(i)&&await i.checkKeylessAccountValidity(t),iX(r)&&await r.checkKeylessAccountValidity(t);let a=e.feePayerAuthenticator||r&&nD({signer:r,transaction:n}),o=nB({signer:i,transaction:n});return nL({aptosConfig:t,transaction:n,senderAuthenticator:o,feePayerAuthenticator:a,...s})}async function nV(e){let{aptosConfig:t,senderAuthenticator:i,feePayer:r,transaction:n,...s}=e;iX(r)&&await r.checkKeylessAccountValidity(t);let a=nD({signer:r,transaction:n});return nL({aptosConfig:t,transaction:n,senderAuthenticator:i,feePayerAuthenticator:a,...s})}var nq={typeParameters:[],parameters:[ir.u8(),new ir(ir.u8())]};async function nH(e){let{aptosConfig:t,account:i,metadataBytes:r,moduleBytecode:n,options:s}=e,a=n.map(e=>C.U8(e));return n$({aptosConfig:t,sender:y.ba.from(i),data:{function:"0x1::code::publish_package_txn",functionArguments:[C.U8(r),new C(a)],abi:nq},options:s})}async function nj(e){return rK(e)}async function nG(e){let{aptosConfig:t,accountAddress:i,options:r}=e;return eJ({aptosConfig:t,originMethod:"getModules",path:`accounts/${y.ba.from(i).toString()}/modules`,params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion]),limit:h(g([r,"optionalAccess",e=>e.limit]),()=>1e3)}})}async function nW(e){let{aptosConfig:t,accountAddress:i,options:r}=e,{response:n,cursor:s}=await eY({aptosConfig:t,originMethod:"getModulesPage",path:`accounts/${y.ba.from(i).toString()}/modules`,params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion]),cursor:g([r,"optionalAccess",e=>e.cursor]),limit:h(g([r,"optionalAccess",e=>e.limit]),()=>100)}});return{modules:n.data,cursor:s}}async function nJ(e){return rI(e)}async function nY(e){let{aptosConfig:t,accountAddress:i,options:r}=e;return eW({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${y.ba.from(i).toString()}/transactions`,params:{start:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit])}})}async function nX(e){let{aptosConfig:t,accountAddress:i,options:r}=e;return eJ({aptosConfig:t,originMethod:"getResources",path:`accounts/${y.ba.from(i).toString()}/resources`,params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion]),limit:h(g([r,"optionalAccess",e=>e.limit]),()=>999)}})}async function nZ(e){let{aptosConfig:t,accountAddress:i,options:r}=e,{response:n,cursor:s}=await eY({aptosConfig:t,originMethod:"getResourcesPage",path:`accounts/${y.ba.from(i).toString()}/resources`,params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion]),cursor:g([r,"optionalAccess",e=>e.cursor]),limit:h(g([r,"optionalAccess",e=>e.limit]),()=>100)}});return{resources:n.data,cursor:s}}async function nQ(e){let{aptosConfig:t,accountAddress:i,resourceType:r,options:n}=e,{data:s}=await ej({aptosConfig:t,originMethod:"getResource",path:`accounts/${y.ba.from(i).toString()}/resource/${r}`,params:{ledger_version:g([n,"optionalAccess",e=>e.ledgerVersion])}});return s.data}async function n0(e){let{aptosConfig:t,authenticationKey:i,options:r}=e,{address_map:{handle:n}}=await nQ({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),s=y.ba.from(i);try{let e=await r$({aptosConfig:t,handle:n,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return y.ba.from(e)}catch(e){if(e instanceof eM&&"table_item_not_found"===e.data.error_code)return s;throw e}}async function n2(e){let{aptosConfig:t,accountAddress:i}=e,r={owner_address:{_eq:y.ba.from(i).toStringLong()},amount:{_gt:0}},n=await rU({aptosConfig:t,query:{query:rc,variables:{where_condition:r}},originMethod:"getAccountTokensCount"});return n.current_token_ownerships_v2_aggregate.aggregate?n.current_token_ownerships_v2_aggregate.aggregate.count:0}async function n1(e){let{aptosConfig:t,accountAddress:i,options:r}=e,n={owner_address:{_eq:y.ba.from(i).toStringLong()},amount:{_gt:0}};g([r,"optionalAccess",e=>e.tokenStandard])&&(n.token_standard={_eq:g([r,"optionalAccess",e=>e.tokenStandard])});let s={query:ra,variables:{where_condition:n,offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function n8(e){let{aptosConfig:t,accountAddress:i,collectionAddress:r,options:n}=e,s={owner_address:{_eq:y.ba.from(i).toStringLong()},current_token_data:{collection_id:{_eq:y.ba.from(r).toStringLong()}},amount:{_gt:0}};g([n,"optionalAccess",e=>e.tokenStandard])&&(s.token_standard={_eq:g([n,"optionalAccess",e=>e.tokenStandard])});let a={query:ro,variables:{where_condition:s,offset:g([n,"optionalAccess",e=>e.offset]),limit:g([n,"optionalAccess",e=>e.limit]),order_by:g([n,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:a,originMethod:"getAccountOwnedTokens
470FromCollectionAddress"})).current_token_ownerships_v2}async function n3(e){let{aptosConfig:t,accountAddress:i,options:r}=e,n={owner_address:{_eq:y.ba.from(i).toStringLong()}};g([r,"optionalAccess",e=>e.tokenStandard])&&(n.current_collection={token_standard:{_eq:g([r,"optionalAccess",e=>e.tokenStandard])}});let s={query:rs,variables:{where_condition:n,offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function n5(e){let{aptosConfig:t,accountAddress:i}=e,r=y.ba.from(i).toStringLong(),n=await rU({aptosConfig:t,query:{query:ru,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return n.account_transactions_aggregate.aggregate?n.account_transactions_aggregate.aggregate.count:0}async function n6(e){let{aptosConfig:t,accountAddress:i,options:r}=e,n=y.ba.from(i).toStringLong(),s={query:rn,variables:{where_condition:{...g([r,"optionalAccess",e=>e.where]),owner_address:{_eq:n}},offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function n4(e){let{aptosConfig:t,accountAddress:i}=e,r=y.ba.from(i).toStringLong(),n=await rU({aptosConfig:t,query:{query:rr,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!n.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return n.current_fungible_asset_balances_aggregate.aggregate.count}async function n9(e){let{aptosConfig:t,accountAddress:i,options:r}=e,n={query:rA,variables:{where_condition:{owner_address:{_eq:y.ba.from(i).toStringLong()}},offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:n,originMethod:"getAccountOwnedObjects"})).current_objects}async function n7(e){let{aptosConfig:t,privateKey:i,options:r}=e,n=h(g([r,"optionalAccess",e=>e.throwIfNoAccountFound]),()=>!1),s=await su({aptosConfig:t,privateKey:i});if(0===s.length){if(n)throw Error("No existing account found for private key.");return iG.fromPrivateKey({privateKey:i})}return s[0]}async function se(e){let{aptosConfig:t,accountAddress:i,options:r}=e;try{let[e,n]=await Promise.all([nX({aptosConfig:t,accountAddress:i}),n9({aptosConfig:t,accountAddress:i,options:{limit:1}})]),s=e.find(e=>"0x1::account::Account"===e.type);if(!s&&0===n.length)return!1;if(!g([r,"optionalAccess",e=>e.withAuthKey]))return!0;return(s?s.data.authentication_key:i.toStringLong())===r.withAuthKey.toString()}catch(e){throw Error(`Error while checking if account exists at ${i.toString()}: ${e}`)}}var st={typeParameters:[],parameters:[new t8,ir.u8(),new t8,ir.u8(),ir.u8(),ir.u8()]};async function si(e){let t,{aptosConfig:i,fromAccount:r,dangerouslySkipVerification:n,options:s}=e;if("toNewPrivateKey"in e)return sr({aptosConfig:i,fromAccount:r,toNewPrivateKey:e.toNewPrivateKey,options:s});if("toAccount"in e){if(e.toAccount instanceof iq)return sr({aptosConfig:i,fromAccount:r,toNewPrivateKey:e.toAccount.privateKey,options:s});if(e.toAccount instanceof i3)return sr({aptosConfig:i,fromAccount:r,toAccount:e.toAccount,options:s});t=e.toAccount.publicKey.authKey()}else if("toAuthKey"in e)t=e.toAuthKey;else throw Error("Invalid arguments");let a=await ss({aptosConfig:i,fromAccount:r,toAuthKey:t,options:s});if(!0===n)return a;let o=await rq({aptosConfig:i,transactionHash:a.hash});if(!o.success)throw Error(`Failed to rotate authentication key - ${o}`);let c=await n$({aptosConfig:i,sender:r.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return nM({aptosConfig:i,signer:e.toAccount,transaction:c})}async function sr(e){let{aptosConfig:t,fromAccount:i,options:r}=e,n=await nj({aptosConfig:t,accountAddress:i.accountAddress}),s;s="toNewPrivateKey"in e?iG.fromPrivateKey({privateKey:e.toNewPrivateKey,legacy:!0}):e.toAccount;let a=new iP({sequenceNumber:BigInt(n.sequence_number),originator:i.accountAddress,currentAuthKey:y.ba.from(n.authentication_key),newPublicKey:s.publicKey}).bcsToBytes(),o=i.sign(a),c=s.sign(a),u=await n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new b(i.signingScheme),C.U8(i.publicKey.toUint8Array()),new b(s.signingScheme),C.U8(s.publicKey.toUint8Array()),C.U8(o.toUint8Array()),C.U8(c.toUint8Array())],abi:st},options:r});return nM({aptosConfig:t,signer:i,transaction:u})}var sn={typeParameters:[],parameters:[ir.u8()]};async function ss(e){let{aptosConfig:t,fromAccount:i,toAuthKey:r,options:n}=e,s=await n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[C.U8(r.toUint8Array())],abi:sn},options:n});return nM({aptosConfig:t,signer:i,transaction:s})}async function sa(e){let{aptosConfig:t,publicKey:i,options:r}=e,n=h(g([r,"optionalAccess",e=>e.noMultiKey]),()=>!1);if(n&&i instanceof tR)throw Error("Multi-key accounts are not supported when noMultiKey is true.");let s=[i];i instanceof t$&&i.publicKey instanceof er?s.push(i.publicKey):i instanceof er&&s.push(new t$(i));let[a,o]=await Promise.all([Promise.all(s.map(async e=>{let i=await sh({aptosConfig:t,publicKey:e});if(i)return{...i,publicKey:e}})),i instanceof tR||n?Promise.resolve([]):sl({aptosConfig:t,publicKey:i,options:r})]),c=[];for(let e of a)e&&c.push(e);s.push(...o);let u=new Map(s.map(e=>[e.authKey().toString(),e]));for(let e of(await sd({aptosConfig:t,authKeys:s.map(e=>e.authKey()),options:r}))){if(c.find(t=>t.accountAddress===e.accountAddress))continue;let t=u.get(e.authKey.toString());if(!t)throw Error(`No publicKey found for authentication key ${e.authKey}. This should never happen.`);c.push({accountAddress:e.accountAddress,publicKey:t,lastTransactionVersion:e.lastTransactionVersion})}return c.sort((e,t)=>
470t.lastTransactionVersion-e.lastTransactionVersion)}async function so(e){let{aptosConfig:t,signer:i,options:r}=e;if(i instanceof en||i instanceof tK)return su({aptosConfig:t,privateKey:i,options:r});if(i instanceof iq||i instanceof ij)return su({aptosConfig:t,privateKey:i.privateKey,options:r});if(i instanceof i2||i instanceof i1)return sc({aptosConfig:t,keylessAccount:i,options:r});if(i instanceof i8&&1===i.signers.length)return so({aptosConfig:t,signer:i.signers[0],options:r});if(i instanceof i3&&1===i.signers.length)return su({aptosConfig:t,privateKey:i.signers[0],options:r});throw Error("Unknown signer type")}async function sc(e){let{aptosConfig:t,keylessAccount:i,options:r}=e,n=await sa({aptosConfig:t,publicKey:i.getAnyPublicKey(),options:r}),s={proof:i.proofOrPromise,jwt:i.jwt,ephemeralKeyPair:i.ephemeralKeyPair,pepper:i.pepper,verificationKeyHash:i.verificationKeyHash},a=[];for(let{accountAddress:e,publicKey:t}of n)if(t instanceof tR){if(t.getSignaturesRequired()>1)continue;if(t instanceof tL)throw Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");t instanceof tB&&a.push(new i8({multiKey:t,signers:[i],address:e}))}else i instanceof i1?a.push(i1.create({...s,address:e,jwkAddress:i.publicKey.jwkAddress})):a.push(i2.create({...s,address:e}));return a}async function su(e){let{aptosConfig:t,privateKey:i,options:r}=e,n=iG.fromPrivateKey({privateKey:i,legacy:!1}),s=await sa({aptosConfig:t,publicKey:new t$(i.publicKey()),options:r}),a=[];for(let{accountAddress:e,publicKey:t}of s)if(t instanceof tR){if(t.getSignaturesRequired()>1)continue;t instanceof tL?a.push(new i3({publicKey:t,signers:[i],address:e})):t instanceof tB&&a.push(new i8({multiKey:t,signers:[n],address:e}))}else{let r=t instanceof er;a.push(iG.fromPrivateKey({privateKey:i,address:e,legacy:r}))}return a}async function sl(e){let{aptosConfig:t,publicKey:i,options:r}=e;if(i instanceof tR)throw Error("Public key is a multi-key.");let n=h(g([r,"optionalAccess",e=>e.includeUnverified]),()=>!1),s=i instanceof t$?i:new t$(i),a=s.publicKey,o=y.C.call(void 0,s.variant),c={public_key:{_eq:a.toString()},public_key_type:{_eq:o},...n?{}:{is_public_key_used:{_eq:!0}}},{public_key_auth_keys:u}=await rU({aptosConfig:t,query:{query:rl,variables:{where_condition:c}},originMethod:"getMultiKeysForPublicKey"});return u.map(e=>{switch(e.signature_type){case"multi_ed25519_signature":return tL.deserializeWithoutLength(m.fromHex(e.account_public_key));case"multi_key_signature":return tB.deserialize(m.fromHex(e.account_public_key));default:throw Error(`Unknown multi-signature type: ${e.signature_type}`)}})}async function sd(e){let{aptosConfig:t,authKeys:i,options:r}=e,n=h(g([r,"optionalAccess",e=>e.includeUnverified]),()=>!1);if(0===i.length)throw Error("No authentication keys provided");let s={auth_key:{_in:i.map(e=>e.toString())},...n?{}:{is_auth_key_used:{_eq:!0}}},{auth_key_account_addresses:a}=await rU({aptosConfig:t,query:{query:ri,variables:{where_condition:s,order_by:[{last_transaction_version:"desc"}]}},originMethod:"getAccountAddressesForAuthKeys"});return a.map(e=>({authKey:new K({data:e.auth_key}),accountAddress:new y.ba(y.j.hexInputToUint8Array(e.account_address)),lastTransactionVersion:Number(e.last_transaction_version)}))}async function sp(e){let{aptosConfig:t,accountAddress:i}=e,r=await nY({aptosConfig:t,accountAddress:i,options:{limit:1}});return 0===r.length?0:Number(r[0].version)}async function sh(e){let{aptosConfig:t,publicKey:i}=e,r=i.authKey().derivedAddress(),[n,s]=await Promise.all([sp({aptosConfig:t,accountAddress:r}),se({aptosConfig:t,accountAddress:r,options:{withAuthKey:i.authKey()}})]);if(s)return{accountAddress:r,lastTransactionVersion:n}}async function sg(e){void 0!==e.minimumLedgerVersion&&await rH({aptosConfig:e.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:e.processorType})}async function sf(e){let{aptosConfig:t,payload:i,options:r}=e,n=await nE({...i,aptosConfig:t}),s=new y.m;n.serialize(s);let a=s.toUint8Array(),{data:o}=await eZ({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion])},body:a});return o}async function sy(e){let{aptosConfig:t,payload:i,options:r}=e,{data:n}=await eZ({aptosConfig:t,originMethod:"viewJson",path:"view",params:{ledger_version:g([r,"optionalAccess",e=>e.ledgerVersion])},body:{function:i.function,type_arguments:h(i.typeArguments,()=>[]),arguments:h(i.functionArguments,()=>[])}});return n}async function sm(e){let{aptosConfig:t,sender:i,authenticationFunction:r,options:n}=e,{moduleAddress:s,moduleName:a,functionName:o}=y.pa.call(void 0,r);return n$({aptosConfig:t,sender:i,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[s,a,o],abi:{typeParameters:[],parameters:[new t7,new is(io()),new is(io())]}},options:n})}async function s_(e){let{aptosConfig:t,sender:i,authenticationFunction:r,options:n}=e,{moduleAddress:s,moduleName:a,functionName:o}=y.pa.call(void 0,r);return n$({aptosConfig:t,sender:i,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[s,a,o],abi:{typeParameters:[],parameters:[new t7,new is(io()),new is(io())]}},options:n})}async function sA(e){let{aptosConfig:t,sender:i,options:r}=e;return n$({aptosConfig:t,sender:i,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var sw=class{constructor(e){this.config=e,this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:i,moduleName:r,functionName:n}=y.pa.call(void 0,e.authenticationFunction);return h(g([t,"optionalAccess",e=>e.some,"call",e=>e(e=>y.ba.fromString(i).equals(e.moduleAddress)&&r===e.moduleName&&n===e.functionName)]),(
470)=>!1)},this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction,this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:i,options:r}=e;return i?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:i,options:r}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:r})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:i,options:r}=e;return sm({aptosConfig:this.config,authenticationFunction:i,sender:t,options:r})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:i,options:r}=e;return s_({aptosConfig:this.config,sender:t,authenticationFunction:i,options:r})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:i}=e;return sA({aptosConfig:this.config,sender:t,options:i})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:i}]=await sf({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[y.ba.from(t)],abi:{typeParameters:[],parameters:[new t7],returnTypes:[]}}});if(0!==i.length)return i[0].map(e=>({moduleAddress:y.ba.fromString(e.module_address),moduleName:e.module_name,functionName:e.function_name}))}},sb=class{constructor(e){this.config=e,this.abstraction=new sw(e)}async getAccountInfo(e){return nj({aptosConfig:this.config,...e})}async getAccountModules(e){return nG({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return nW({aptosConfig:this.config,...e})}async getAccountModule(e){return nJ({aptosConfig:this.config,...e})}async getAccountTransactions(e){return nY({aptosConfig:this.config,...e})}async getAccountResources(e){return nX({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return nZ({aptosConfig:this.config,...e})}async getAccountResource(e){return nQ({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return n0({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),n2({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),n1({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),n8({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),n3({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),n5({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),n6({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),n4({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:ek,faMetadataAddress:eP,...e})}async getAccountCoinAmount(e){let t,{accountAddress:i,coinType:r,faMetadataAddress:n,minimumLedgerVersion:s}=e;s&&console.warn(`minimumLedgerVersion is not used anymore, here for backward 
471        compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, 
472        will be removed in the near future`);let a=r;if(void 0===r&&void 0!==n&&(a=await e3(async()=>{try{let e=(await sf({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[n]}})).at(0);if(e.vec.length>0&&y.oa.call(void 0,e.vec[0]))return y.na.call(void 0,e.vec[0])}catch(e){}},`coin-mapping-${n.toString()}`,3e5)()),void 0!==r&&void 0!==n)t=y.ba.from(n).toStringLong();else if(void 0!==r&&void 0===n)t=r===ek?y.ba.A.toStringLong():y.ca.call(void 0,y.ba.A,r).toStringLong();else if(void 0===r&&void 0!==n){let e=y.ba.from(n);t=e.toStringLong(),e===y.ba.A&&(a=ek)}else throw Error("Either coinType, faMetadataAddress, or both must be provided");
472if(void 0!==a){let[e]=await sf({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[a],functionArguments:[i]}});return parseInt(e,10)}let[o]=await sf({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[i,t]}});return parseInt(o,10)}async getAccountOwnedObjects(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),n9({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),n7({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),so({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),sa({aptosConfig:this.config,...e})}},sv=p(i(8171)),sT=class{constructor(e){if(g([e,"optionalAccess",e=>e.fullnode])||g([e,"optionalAccess",e=>e.indexer])||g([e,"optionalAccess",e=>e.faucet])||g([e,"optionalAccess",e=>e.pepper])||g([e,"optionalAccess",e=>e.prover])){if("custom"===g([e,"optionalAccess",e=>e.network]))console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!g([e,"optionalAccess",e=>e.network]))throw Error("Custom endpoints require a network to be specified")}this.network=h(g([e,"optionalAccess",e=>e.network]),()=>"devnet"),this.fullnode=g([e,"optionalAccess",e=>e.fullnode]),this.faucet=g([e,"optionalAccess",e=>e.faucet]),this.pepper=g([e,"optionalAccess",e=>e.pepper]),this.prover=g([e,"optionalAccess",e=>e.prover]),this.indexer=g([e,"optionalAccess",e=>e.indexer]),this.client=h(g([e,"optionalAccess",e=>e.client]),()=>({provider:sv.default})),this.clientConfig=h(g([e,"optionalAccess",e=>e.clientConfig]),()=>({})),this.fullnodeConfig=h(g([e,"optionalAccess",e=>e.fullnodeConfig]),()=>({})),this.indexerConfig=h(g([e,"optionalAccess",e=>e.indexerConfig]),()=>({})),this.faucetConfig=h(g([e,"optionalAccess",e=>e.faucetConfig]),()=>({})),this.transactionGenerationConfig=h(g([e,"optionalAccess",e=>e.transactionGenerationConfig]),()=>({})),this.pluginConfig=g([e,"optionalAccess",e=>e.pluginSettings])?{...e.pluginSettings,IGNORE_TRANSACTION_SUBMITTER:!1}:void 0}getRequestUrl(e){switch(e){case"Fullnode":if(void 0!==this.fullnode)return this.fullnode;if("custom"===this.network)throw Error("Please provide a custom full node url");return eA[this.network];case"Faucet":if(void 0!==this.faucet)return this.faucet;if("testnet"===this.network)throw Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if("mainnet"===this.network)throw Error("There is no mainnet faucet");if("custom"===this.network)throw Error("Please provide a custom faucet url");return ew[this.network];case"Indexer":if(void 0!==this.indexer)return this.indexer;if("custom"===this.network)throw Error("Please provide a custom indexer url");return e_[this.network];case"Pepper":if(void 0!==this.pepper)return this.pepper;if("custom"===this.network)throw Error("Please provide a custom pepper service url");return eb[this.network];case"Prover":if(void 0!==this.prover)return this.prover;if("custom"===this.network)throw Error("Please provide a custom prover service url");return ev[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return eb[this.network]===e}isProverServiceRequest(e){return ev[this.network]===e}getDefaultMaxGasAmount(){return h(g([this,"access",e=>e.transactionGenerationConfig,"optionalAccess",e=>e.defaultMaxGasAmount]),()=>2e5)}getDefaultTxnExpirySecFromNow(){return h(g([this,"access",e=>e.transactionGenerationConfig,"optionalAccess",e=>e.defaultTxnExpirySecFromNow]),()=>20)}setIgnoreTransactionSubmitter(e){this.pluginConfig&&(this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER=e)}getTransactionSubmitter(){if(void 0!==this.pluginConfig&&!0!==this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER)return this.pluginConfig.TRANSACTION_SUBMITTER}},sE={typeParameters:[{constraints:[]}],parameters:[new t7,new t6]};async function sS(e){let{aptosConfig:t,sender:i,recipient:r,amount:n,coinType:s,options:a}=e;return n$({aptosConfig:t,sender:i,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[h(s,()=>ek)],functionArguments:[r,n],abi:sE},options:a})}var sz=class{constructor(e){this.config=e}async transferCoinTransaction(e){return sS({aptosConfig:this.config,...e})}}
472,sC={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},sU="0x4::token::Token";async function sx(e){let{aptosConfig:t,digitalAssetAddress:i}=e,r={token_data_id:{_eq:y.ba.from(i).toStringLong()}};return(await rU({aptosConfig:t,query:{query:rS,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function sk(e){let{aptosConfig:t,digitalAssetAddress:i}=e,r={token_data_id:{_eq:y.ba.from(i).toStringLong()},amount:{_gt:0}};return(await rU({aptosConfig:t,query:{query:rE,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function sP(e){let{aptosConfig:t,ownerAddress:i,options:r}=e,n={query:rE,variables:{where_condition:{owner_address:{_eq:y.ba.from(i).toStringLong()},amount:{_gt:0}},offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:n,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function sK(e){let{aptosConfig:t,digitalAssetAddress:i,options:r}=e,n={query:rT,variables:{where_condition:{token_data_id:{_eq:y.ba.from(i).toStringLong()}},offset:g([r,"optionalAccess",e=>e.offset]),limit:g([r,"optionalAccess",e=>e.limit]),order_by:g([r,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:n,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var sI={typeParameters:[],parameters:[new is(io()),new t6,new is(io()),new is(io()),new t1,new t1,new t1,new t1,new t1,new t1,new t1,new t1,new t1,new t6,new t6]};async function sN(e){let{aptosConfig:t,options:i,creator:r}=e;return n$({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(e.description),new E(h(e.maxSupply,()=>y.e)),new x(e.name),new x(e.uri),new w(h(e.mutableDescription,()=>!0)),new w(h(e.mutableRoyalty,()=>!0)),new w(h(e.mutableURI,()=>!0)),new w(h(e.mutableTokenDescription,()=>!0)),new w(h(e.mutableTokenName,()=>!0)),new w(h(e.mutableTokenProperties,()=>!0)),new w(h(e.mutableTokenURI,()=>!0)),new w(h(e.tokensBurnableByCreator,()=>!0)),new w(h(e.tokensFreezableByCreator,()=>!0)),new E(h(e.royaltyNumerator,()=>0)),new E(h(e.royaltyDenominator,()=>1))],abi:sI},options:i})}async function s$(e){let{aptosConfig:t,options:i}=e,r=g([i,"optionalAccess",e=>e.where]);g([i,"optionalAccess",e=>e.tokenStandard])&&(r.token_standard={_eq:h(g([i,"optionalAccess",e=>e.tokenStandard]),()=>"v2")});let n={query:rp,variables:{where_condition:r,offset:g([i,"optionalAccess",e=>e.offset]),limit:g([i,"optionalAccess",e=>e.limit])}};return(await rU({aptosConfig:t,query:n,originMethod:"getCollectionData"})).current_collections_v2[0]}async function sF(e){let{aptosConfig:t,creatorAddress:i,collectionName:r,options:n}=e,s={collection_name:{_eq:r},creator_address:{_eq:y.ba.from(i).toStringLong()}};return g([n,"optionalAccess",e=>e.tokenStandard])&&(s.token_standard={_eq:h(g([n,"optionalAccess",e=>e.tokenStandard]),()=>"v2")}),s$({aptosConfig:t,options:{...n,where:s}})}async function sR(e){let{aptosConfig:t,creatorAddress:i,options:r}=e,n={creator_address:{_eq:y.ba.from(i).toStringLong()}};return g([r,"optionalAccess",e=>e.tokenStandard])&&(n.token_standard={_eq:h(g([r,"optionalAccess",e=>e.tokenStandard]),()=>"v2")}),s$({aptosConfig:t,options:{...r,where:n}})}async function sB(e){let{aptosConfig:t,collectionId:i,options:r}=e,n={collection_id:{_eq:y.ba.from(i).toStringLong()}};return g([r,"optionalAccess",e=>e.tokenStandard])&&(n.token_standard={_eq:h(g([r,"optionalAccess",e=>e.tokenStandard]),()=>"v2")}),s$({aptosConfig:t,options:{...r,where:n}})}async function sD(e){let{creatorAddress:t,collectionName:i,options:r,aptosConfig:n}=e,s={collection_name:{_eq:i},creator_address:{_eq:y.ba.from(t).toStringLong()}};return g([r,"optionalAccess",e=>e.tokenStandard])&&(s.token_standard={_eq:h(g([r,"optionalAccess",e=>e.tokenStandard]),()=>"v2")}),(await s$({aptosConfig:n,options:{where:s}}
472)).collection_id}var sO={typeParameters:[],parameters:[new is(io()),new is(io()),new is(io()),new is(io()),new ir(new is(io())),new ir(new is(io())),new ir(ir.u8())]};async function sL(e){let{aptosConfig:t,options:i,creator:r,collection:n,description:s,name:a,uri:o,propertyKeys:c,propertyTypes:u,propertyValues:l}=e,d=g([u,"optionalAccess",e=>e.map,"call",e=>e(e=>sC[e])]);return n$({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(n),new x(s),new x(a),new x(o),C.MoveString(h(c,()=>[])),C.MoveString(h(d,()=>[])),an(h(l,()=>[]),h(d,()=>[]))],abi:sO},options:i})}var sM={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new t7]};async function sV(e){let{aptosConfig:t,sender:i,digitalAssetAddress:r,recipient:n,digitalAssetType:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[h(s,()=>sU)],functionArguments:[y.ba.from(r),y.ba.from(n)],abi:sM},options:a})}var sq={typeParameters:[],parameters:[new is(io()),new is(io()),new is(io()),new is(io()),new ir(new is(io())),new ir(new is(io())),new ir(ir.u8()),new t7]};async function sH(e){let{aptosConfig:t,account:i,collection:r,description:n,name:s,uri:a,recipient:o,propertyKeys:c,propertyTypes:u,propertyValues:l,options:d}=e;if(g([c,"optionalAccess",e=>e.length])!==g([l,"optionalAccess",e=>e.length]))throw Error("Property keys and property values counts do not match");if(g([u,"optionalAccess",e=>e.length])!==g([l,"optionalAccess",e=>e.length]))throw Error("Property types and property values counts do not match");let p=g([u,"optionalAccess",e=>e.map,"call",e=>e(e=>sC[e])]);return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,n,s,a,C.MoveString(h(c,()=>[])),C.MoveString(h(p,()=>[])),an(h(l,()=>[]),h(p,()=>[])),o],abi:sq},options:d})}var sj={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0)))]};async function sG(e){let{aptosConfig:t,creator:i,digitalAssetAddress:r,digitalAssetType:n,options:s}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[h(n,()=>sU)],functionArguments:[y.ba.from(r)],abi:sj},options:s})}var sW={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0)))]};async function sJ(e){let{aptosConfig:t,creator:i,digitalAssetAddress:r,digitalAssetType:n,options:s}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[h(n,()=>sU)],functionArguments:[r],abi:sW},options:s})}var sY={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0)))]};async function sX(e){let{aptosConfig:t,creator:i,digitalAssetAddress:r,digitalAssetType:n,options:s}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[h(n,()=>sU)],functionArguments:[r],abi:sY},options:s})}var sZ={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io())]};async function sQ(e){let{aptosConfig:t,creator:i,description:r,digitalAssetAddress:n,digitalAssetType:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[h(s,()=>sU)],functionArguments:[y.ba.from(n),new x(r)],abi:sZ},options:a})}var s0={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io())]};async function s2(e){let{aptosConfig:t,creator:i,name:r,digitalAssetAddress:n,digitalAssetType:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[h(s,()=>sU)],functionArguments:[y.ba.from(n),new x(r)],abi:s0},options:a})}var s1={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io())]};async function s8(e){let{aptosConfig:t,creator:i,uri:r,digitalAssetAddress:n,digitalAssetType:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[h(s,()=>sU)],functionArguments:[y.ba.from(n),new x(r)],abi:s1},options:a})}var s3={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io()),new is(io()),ir.u8()]};async function s5(e){let{aptosConfig:t,creator:i,propertyKey:r,propertyType:n,propertyValue:s,digitalAssetAddress:a,digitalAssetType:o,options:c}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[h(o,()=>sU)],functionArguments:[y.ba.from(a),new x(r),new x(sC[n]),C.U8(as(s,sC[n]))],abi:s3},options:c})}var s6={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io())]};async function s4(e){let{aptosConfig:t,creator:i,propertyKey:r,digitalAssetAddress:n,digitalAssetType:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[h(s,()=>sU)],functionArguments:[y.ba.from(n),new x(r)],abi:s6},options:a})}var s9={typeParameters:[{constraints:["key"]}],parameters:[new is(ic(new ii(0))),new is(io()),new is(io()),ir.u8()]};async function s7(e){let{aptosConfig:t,creator:i,propertyKey:r,propertyType:n,propertyValue:s,digitalAssetAddress:a,digitalAssetType:o,options:c}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[h(o,()=>sU)],functionArguments:[y.ba.from(a),new x(r),new x(sC[n]),as(s,sC[n])],abi:s9},options:c})}var ae={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new is(ic(new ii(0))),new is(io()),new ii(1)]};async function at(e){let{aptosConfig:t,creator:i,propertyKey:r,propertyType:n,propertyValue:s,digitalAssetAddress:a,digitalAssetType:o,options:c}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[h(o,()=>sU),sC[n]],functionArguments:[y.ba.from(a),new x(r),s],abi:ae},options:c})}var ai={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new is(ic(new ii(0))),new is(io()),new ii(1)]};async function ar(e){let{aptosConfig:t,creator:i,propertyKey:r,propertyType:n,propertyValue:s,digitalAssetAddress:a,digitalAssetType:o,options:c}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[h(o,()=>sU),sC[n]],functionArguments:[y.ba.from(a),new x(r),s],abi:ai},options:c})}function an(e,t){let i=[];return t.forEach((t,r)=>{i.push(as(e[r],t))}),i}
472function as(e,t){return nb(e,r2(t),0,[]).bcsToBytes()}var aa=class{constructor(e){this.config=e}async getCollectionData(e){await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:i,options:r}=e,n={collection_name:{_eq:i},creator_address:{_eq:y.ba.from(t).toStringLong()}};return g([r,"optionalAccess",e=>e.tokenStandard])&&(n.token_standard={_eq:h(g([r,"optionalAccess",e=>e.tokenStandard]),()=>"v2")}),s$({aptosConfig:this.config,options:{where:n}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sF({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sR({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sB({aptosConfig:this.config,...e})}async getCollectionId(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sD({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sx({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sk({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sP({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sK({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sN({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return sL({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return sV({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return sH({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return sG({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return sJ({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return sX({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return sQ({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return s2({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return s8({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return s5({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return s4({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return s7({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return at({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return ar({aptosConfig:this.config,...e})}};async function ao(e){let{aptosConfig:t,accountAddress:i,amount:r,options:n}=e,s=g([n,"optionalAccess",e=>e.timeoutSecs])||20,{data:a}=await e0({aptosConfig:t,path:"fund",body:{address:y.ba.from(i).toString(),amount:r},originMethod:"fundAccount"}),o=a.txn_hashes[0],c=await rq({aptosConfig:t,transactionHash:o,options:{timeoutSecs:s,checkSuccess:g([n,"optionalAccess",e=>e.checkSuccess])}});if("user_transaction"===c.type)return c;throw Error(`Unexpected transaction received for fund account: ${c.type}`)}var ac=class{constructor(e){this.config=e}async fundAccount(e){let t=await ao({aptosConfig:this.config,...e});return(void 0===g([e,"access",e=>e.options,"optionalAccess",e=>e.waitForIndexer])||g([e,"access",e=>e.options,"optionalAccess",e=>e.waitForIndexer]))&&await rH({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function au(e){let{aptosConfig:t,options:i}=e,r={query:ry,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset])}};return(await rU({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function al(e){let{aptosConfig:t,options:i}=e,r={query:rf,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset])}};return(await rU({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ad(e){let{aptosConfig:t,options:i}=e,r={query:rh,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset])}};return(await rU({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ap={typeParameters:[{constraints:[]}],parameters:[r2("0x1::object::Object"),new t7,new t6]};async function ah(e){let{aptosConfig:t,sender:i,fungibleAssetMetadataAddress:r,recipient:n,amount:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,n,s],abi:ap},options:a})}async function ag(e){let{aptosConfig:t,sender:i,fromStore:r,toStore:n,amount:s,options:a}=e;return n$({aptosConfig:t,sender:i.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::
472FungibleStore"],functionArguments:[r,n,s],abi:ap},options:a})}var af=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),au({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await au({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await au({aptosConfig:this.config,options:{where:{creator_address:{_eq:y.ba.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),al({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ad({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ah({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return ag({aptosConfig:this.config,...e})}},ay=class{constructor(e){this.config=e}async getLedgerInfo(){return rz({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return rW({aptosConfig:this.config,...e})}async getBlockByHeight(e){return rJ({aptosConfig:this.config,...e})}async view(e){return sf({aptosConfig:this.config,...e})}async viewJson(e){return sy({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return rC({aptosConfig:this.config,...e})}async queryIndexer(e){return rU({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return rk({aptosConfig:this.config})}async getProcessorStatus(e){return rP({aptosConfig:this.config,processorType:e})}},am="A name must be between 3 and 63 characters long, and can only contain lowercase a-z, 0-9, and hyphens. A name may not start or end with a hyphen.";function a_(e){return!(!e||e.length<3||e.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(e))}function aA(e){let[t,i,...r]=e.replace(/\.apt$/,"").split(".");if(r.length>0)throw Error(`${e} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!a_(t))throw Error(`${t} is not valid. ${am}`);if(i&&!a_(i))throw Error(`${i} is not valid. ${am}`);return{domainName:i||t,subdomainName:i?t:void 0}}function aw(e){if(!e)return!1;let t=new Date(e.domain_expiration_timestamp).getTime()<Date.now(),i=new Date(e.expiration_timestamp).getTime()<Date.now();return(!e.subdomain||!t)&&(!!e.subdomain&&1===e.subdomain_expiration_policy||!i)}var ab={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:"0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",custom:null,devnet:null};function av(e){let t=ab[e.network];if(!t)throw Error(`The ANS contract is not deployed to ${e.network}`);return t}var aT=e=>{if(e&&"object"==typeof e&&"vec"in e&&Array.isArray(e.vec))return e.vec[0]};async function aE(e){let{aptosConfig:t,name:i}=e,r=av(t),{domainName:n,subdomainName:s}=aA(i),a=aT((await sf({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[n,s]}}))[0]);return a?y.ba.from(a):void 0}async function aS(e){let{aptosConfig:t,expiration:i,name:r,sender:n,targetAddress:s,toAddress:a,options:o,transferable:c}=e,u=av(t),{domainName:l,subdomainName:d}=aA(r),p="subdomain:independent"===i.policy||"subdomain:follow-domain"===i.policy;if(d&&!p)throw Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!d)throw Error(`Policy is set to ${i.policy} but no subdomain was provided`);if("domain"===i.policy){let e=h(i.years,()=>1);if(1!==e)throw Error("For now, names can only be registered for 1 year at a time");return await n$({aptosConfig:t,sender:n.accountAddress.toString(),data:{function:`${u}::router::register_domain`,functionArguments:[l,31536e3*e,s,a]},options:o})}if(!d)throw Error(`${i.policy} requires a subdomain to be provided.`);let g=await az({aptosConfig:t,name:l});if(!g)throw Error("The domain does not exist");let f="subdomain:independent"===i.policy?i.expirationDate:g;if(f>g)throw Error("The subdomain expiration time cannot be greater than the domain expiration time");return await n$({aptosConfig:t,sender:n.accountAddress.toString(),data:{function:`${u}::router::register_subdomain`,functionArguments:[l,d,Math.round(f/1e3),"subdomain:follow-domain"===i.policy?1:0,!!c,s,a]},options:o})}async function az(e){let{aptosConfig:t,name:i}=e,r=av(t),{domainName:n,subdomainName:s}=aA(i);try{let e=await sf({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[n,s]}});return 1e3*Number(e[0])}catch(e){return}}async function aC(e){let{aptosConfig:t,address:i}=e,r=av(t),n=await sf({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[y.ba.from(i).toString()]}}),s=aT(n[1]),a=aT(n[0]);
472if(s)return[a,s].filter(Boolean).join(".")}async function aU(e){let{aptosConfig:t,sender:i,name:r,options:n}=e,s=av(t);if(!r)return await n$({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${s}::router::clear_primary_name`,functionArguments:[]},options:n});let{domainName:a,subdomainName:o}=aA(r);return await n$({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${s}::router::set_primary_name`,functionArguments:[a,o]},options:n})}async function ax(e){let{aptosConfig:t,name:i}=e,r=av(t),{domainName:n,subdomainName:s}=aA(i),a=aT((await sf({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[n,s]}}))[0]);return a?y.ba.from(a):void 0}async function ak(e){let{aptosConfig:t,sender:i,name:r,address:n,options:s}=e,a=av(t),{domainName:o,subdomainName:c}=aA(r);return await n$({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${a}::router::set_target_addr`,functionArguments:[o,c,n]},options:s})}async function aP(e){let{aptosConfig:t,name:i}=e,{domainName:r,subdomainName:n=""}=aA(i),s=(await rU({aptosConfig:t,query:{query:rm,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:n}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return s&&(s=aB(s)),aw(s)?s:void 0}async function aK(e){let{aptosConfig:t,options:i,accountAddress:r}=e,n=await aF({aptosConfig:t});return(await rU({aptosConfig:t,originMethod:"getAccountNames",query:{query:rm,variables:{limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset]),order_by:g([i,"optionalAccess",e=>e.orderBy]),where_condition:{...h(g([e,"access",e=>e.options,"optionalAccess",e=>e.where]),()=>({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:n}}}}})).current_aptos_names.map(aB)}async function aI(e){let{aptosConfig:t,options:i,accountAddress:r}=e,n=await aF({aptosConfig:t});return(await rU({aptosConfig:t,originMethod:"getAccountDomains",query:{query:rm,variables:{limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset]),order_by:g([i,"optionalAccess",e=>e.orderBy]),where_condition:{...h(g([e,"access",e=>e.options,"optionalAccess",e=>e.where]),()=>({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:n},subdomain:{_eq:""}}}}})).current_aptos_names.map(aB)}async function aN(e){let{aptosConfig:t,options:i,accountAddress:r}=e,n=await aF({aptosConfig:t});return(await rU({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:rm,variables:{limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset]),order_by:g([i,"optionalAccess",e=>e.orderBy]),where_condition:{...h(g([e,"access",e=>e.options,"optionalAccess",e=>e.where]),()=>({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(aB)}async function a$(e){let{aptosConfig:t,options:i,domain:r}=e;return(await rU({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:rm,variables:{limit:g([i,"optionalAccess",e=>e.limit]),offset:g([i,"optionalAccess",e=>e.offset]),order_by:g([i,"optionalAccess",e=>e.orderBy]),where_condition:{...h(g([e,"access",e=>e.options,"optionalAccess",e=>e.where]),()=>({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(aB).filter(aw)}async function aF(e){let{aptosConfig:t}=e,i=av(t),[r]=await sf({aptosConfig:t,payload:{function:`${i}::config::reregistration_grace_sec`,functionArguments:[]}}),n=()=>new Date;return new Date(n().setDate(n().getDate()-r/60/60/24)).toISOString()}async function aR(e){let{aptosConfig:t,sender:i,name:r,years:n=1,options:s}=e,a=av(t),{domainName:o,subdomainName:c}=aA(r);if(c)throw Error("Subdomains cannot be renewed");if(1!==n)throw Error("Currently, only 1 year renewals are supported");return await n$({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${a}::router::renew_domain`,functionArguments:[o,31536e3*n]},options:s})}function aB(e){return{...e,expiration_timestamp:new Date(e.expiration_timestamp).getTime()}}var aD=class{constructor(e){this.config=e}async getOwnerAddress(e){return aE({aptosConfig:this.config,...e})}async getExpiration(e){return az({aptosConfig:this.config,...e})}async getTargetAddress(e){return ax({aptosConfig:this.config,...e})}async setTargetAddress(e){return ak({aptosConfig:this.config,...e})}async getPrimaryName(e){return aC({aptosConfig:this.config,...e})}async setPrimaryName(e){return aU({aptosConfig:this.config,...e})}async registerName(e){return aS({aptosConfig:this.config,...e})}async renewDomain(e){return aR({aptosConfig:this.config,...e})}async getName(e){return aP({aptosConfig:this.config,...e})}async getAccountNames(e){return aK({aptosConfig:this.config,...e})}async getAccountDomains(e){return aI({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return aN({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return a$({aptosConfig:this.config,...e})}};async function aO(e){let{aptosConfig:t,poolAddress:i}=e,r=y.ba.from(i).toStringLong(),n=await rU({aptosConfig:t,query:{query:r_,variables:{where_condition:{pool_address:{_eq:r}}}}});return n.num_active_delegator_per_pool[0]?n.num_active_delegator_per_pool[0].num_active_delegator:0}async function aL(e){let{aptosConfig:t,options:i}=e,r={query:r_,variables:{order_by:g([i,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function aM(e){let{aptosConfig:t,delegatorAddress:i,poolAddress:r}=e,n={query:rg,variables:{delegatorAddress:y.ba.from(i).toStringLong(),poolAddress:y.ba.from(r).toStringLong()}};return(await rU({aptosConfig:t,query:n})).delegated_staking_activities}var aV=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"stake_processor"}),aO({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"stake_processor"}),aL({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await sg({config:this.config,minimumLedgerVersion:g([e,"optionalAccess",e=>e.minimumLedgerVersion]),processorType:"stake_processor"}),aM({aptosConfig:this.config,...e})}},aq=class{constructor(e){this.config=e}async simple(e){return n$({aptosConfig:this.config,...e})}async multiAgent(e){return n$({aptosConfig:this.config,...e})}};function aH(e,t){if(!(void 0!==e.getTransactionSubmitter()||void 0!==t.transactionSubmitter)&&t.transaction.feePayerAddress&&!t.feePayerAuthenticator)throw Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator")}function aj(e,t,i){let r=i.value;return i.value=async function(...e){return r.apply(this,e)},i}var aG=class{constructor(e){this.config=e}async simple(e){return nO({aptosConfig:this.config,...e})}async multiAgent(e){return nO({aptosConfig:this.config,...e})}};y.a.call(void 0,[aj],aG.prototype,"simple",1),y.a.call(void 0,[aj],aG.prototype,"multiAgent",1);var aW=class{constructor(e){this.config=e}async simple(e){return aH(this.config,e),nL({aptosConfig:this.config,...e})}async multiAgent(e){return aH(this.config,e),nL({aptosConfig:this.config,...e})}},aJ=class{constructor(e,t,i,r,n){this.lastUncommintedNumber=null,this.currentNumber=null,this.lock=!1,this.aptosConfig=e,this.account=t,this.maxWaitTime=i,this.maximumInFlight=r,this.sleepTime=n}async nextSequenceNumber(){for(;this.lock;
472)await y.fa.call(void 0,this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((null===this.lastUncommintedNumber||null===this.currentNumber)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=y.ha.call(void 0);for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await y.fa.call(void 0,this.sleepTime),y.ha.call(void 0)-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await nj({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await nj({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await y.fa.call(void 0,this.sleepTime);this.lock=!0;try{await this.update();let e=y.ha.call(void 0);for(;this.lastUncommintedNumber!==this.currentNumber;)y.ha.call(void 0)-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await y.fa.call(void 0,this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}},aY=class{constructor(){this.queue=[],this.pendingDequeue=[],this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){g([this,"access",e=>e.pendingDequeue,"access",e=>e.shift,"call",e=>e(),"optionalAccess",e=>e.resolve,"call",t=>t(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return 0===this.queue.length}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new aX("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},aX=class extends Error{},aZ="fulfilled",aQ=t.TransactionWorkerEventsEnum=((d=aQ||{}).TransactionSent="transactionSent",d.TransactionSendFailed="transactionSendFailed",d.TransactionExecuted="transactionExecuted",d.TransactionExecutionFailed="transactionExecutionFailed",d.ExecutionFinish="executionFinish",d),a0=t.TransactionWorker=class extends iY.default{constructor(e,t,i=30,r=100,n=10){super(),this.taskQueue=new aY,this.transactionsQueue=new aY,this.outstandingTransactions=new aY,this.sentTransactions=[],this.executedTransactions=[],this.aptosConfig=e,this.account=t,this.started=!1,this.accountSequnceNumber=new aJ(e,t,i,r,n)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(null===e)return;let t=await this.generateNextTransaction(this.account,e);if(!t)return;let i=nM({aptosConfig:this.aptosConfig,transaction:t,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof aX)return;throw Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],t=[],[i,r]=await this.outstandingTransactions.dequeue();for(e.push(i),t.push(r);!this.outstandingTransactions.isEmpty();)[i,r]=await this.outstandingTransactions.dequeue(),e.push(i),t.push(r);let n=await Promise.allSettled(e);for(let e=0;e<n.length&&e<t.length;e+=1){let i=n[e];r=t[e],i.status===aZ?(this.sentTransactions.push([i.value.hash,r,null]),this.emit("transactionSent",{message:`transaction hash ${i.value.hash} has been committed to chain`,transactionHash:i.value.hash}),await this.checkTransaction(i,r)):(this.sentTransactions.push([i.status,r,i.reason]),this.emit
472("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${i.reason}`,error:i.reason}))}this.emit("executionFinish",{message:`execute ${n.length} transactions finished`})}}catch(e){if(e instanceof aX)return;throw Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,t){try{let i=[];i.push(rq({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let r=await Promise.allSettled(i);for(let i=0;i<r.length;i+=1){let n=r[i];n.status===aZ?(this.executedTransactions.push([n.value.hash,t,null]),this.emit("transactionExecuted",{message:`transaction hash ${n.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([n.status,t,n.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${n.reason}`,error:n.reason}))}}catch(e){throw Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async push(e,t){this.transactionsQueue.enqueue([e,t])}async generateNextTransaction(e,t){if(this.transactionsQueue.isEmpty())return;let[i,r]=await this.transactionsQueue.dequeue();return n$({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...r,accountSequenceNumber:t,replayProtectionNonce:void 0}})}async run(){try{for(;!this.taskQueue.isCancelled();)await (await this.taskQueue.dequeue())()}catch(e){throw Error(`Unable to start transaction batching: ${e}`)}}start(){if(this.started)throw Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}},a2=class extends iY.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new a0(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:i}=e;for(let e of t)this.transactionWorker.push(e,i)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:i,options:r}=e;this.start({sender:t}),this.push({data:i,options:r})}catch(e){throw Error(`failed to submit transactions with error: ${e}`)}}},a1=class{constructor(e){this.config=e,this.build=new aq(this.config),this.simulate=new aG(this.config),this.submit=new aW(this.config),this.batch=new a2(this.config)}async getTransactions(e){return rB({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return rO({aptosConfig:this.config,...e})}async getTransactionByHash(e){return rL({aptosConfig:this.config,...e})}async isPendingTransaction(e){return rM({aptosConfig:this.config,...e})}async waitForTransaction(e){return rq({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return rD({aptosConfig:this.config})}getSigningMessage(e){return function(e){let{transaction:t}=e;return iV(t)}(e)}async publishPackageTransaction(e){return nH({aptosConfig:this.config,...e})}async rotateAuthKey(e){return si({aptosConfig:this.config,...e})}sign(e){return nB({...e})}signAsFeePayer(e){return nD({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:i,options:r}=e;this.batch.forSingleAccount({sender:t,data:i,options:r})}catch(e){throw Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(e){return nM({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return nV({aptosConfig:this.config,...e})}},a8=class{constructor(e){this.config=e}async getTableItem(e){return r$({aptosConfig:this.config,...e})}async getTableItemsData(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),rF({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),rR({aptosConfig:this.config,...e})}};async function a3(e){let{aptosConfig:t,jwt:i,ephemeralKeyPair:r,uidKey:n="sub",derivationPath:s}=e,a={jwt_b64:i,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:y.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:n,derivation_path:s},{data:o}=await e2({aptosConfig:t,path:"fetch",body:a,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return y.j.fromHexInput(o.pepper).toUint8Array()}async function a5(e){let{aptosConfig:t,jwt:i,ephemeralKeyPair:r,pepper:n=await a3(e),uidKey:s="sub",maxExpHorizonSecs:a=(await tb({aptosConfig:t})).maxExpHorizonSecs}=e;if(y.j.fromHexInput(n).toUint8Array().length!==i2.PEPPER_LENGTH)throw Error(`Pepper needs to be ${i2.PEPPER_LENGTH} bytes`);let o=eu.jwtDecode.call(void 0,i);if("number"!=typeof o.iat)throw Error("iat was not found");if(a<r.expiryDateSecs-o.iat)throw Error(`The EphemeralKeyPair is too long lived.  It's lifespan must be less than ${a}`);let c={jwt_b64:i,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:y.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:a,pepper:y.j.fromHexInput(n).toStringWithoutPrefix(),uid_key:s},{data:u}=await e1({aptosConfig:t,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=u.proof;return new t_({proof:new tm(new tf({a:l.a,b:l.b,c:l.c}),0),trainingWheelsSignature:ec.fromHex(u.training_wheels_signature),expHorizonSecs:a})}async function a6(e){let{aptosConfig:t,jwt:i,jwkAddress:r,uidKey:n,proofFetchCallback:s,pepper:a=await a3(e)}=e,{verificationKey:o,maxExpHorizonSecs:c}=await tb({aptosConfig:t}),u=a5({...e,pepper:a,maxExpHorizonSecs:c}),l=s?u:await u;if(void 0!==r){let c=tU.fromJwtAndPepper({jwt:i,pepper:a,jwkAddress:r,uidKey:n}),u=await n0({aptosConfig:t,authenticationKey:c.authKey().derivedAddress()});return i1.create({...e,address:u,proof:l,pepper:a,proofFetchCallback:s,jwkAddress:r,verificationKey:o})}let d=ts.fromJwtAndPepper({jwt:i,pepper:a,uidKey:n}),p=await n0({aptosConfig:t,authenticationKey:d.authKey().derivedAddress()});return i2.create({...e,address:p,proof:l,pepper:a,proofFetchCallback:s,verificationKey:o})}async function a4(e){let t,{aptosConfig:i,sender:r,iss:n,options:s}=e,{jwksUrl:a}=e;void 0===a&&(a=e$.test(n)?"https://www.googleapis.com/service_accounts/v1/jwk/[email protected]":n.endsWith("/")?`${n}.well-known/jwks.json`:`${n}/.well-known/jwks.json`);
472try{if(!(t=await fetch(a)).ok)throw Error(`${t.status} ${t.statusText}`)}catch(t){let e;throw e=t instanceof Error?`${t.message}`:`error unknown - ${t}`,eL.fromErrorType({type:14,details:`Failed to fetch JWKS at ${a}: ${e}`})}let o=await t.json();return n$({aptosConfig:i,sender:r.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[n,C.MoveString(o.keys.map(e=>e.kid)),C.MoveString(o.keys.map(e=>e.alg)),C.MoveString(o.keys.map(e=>e.e)),C.MoveString(o.keys.map(e=>e.n))]},options:s})}var a9=class{constructor(e){this.config=e}async getPepper(e){return a3({aptosConfig:this.config,...e})}async getProof(e){return a5({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return a6({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return a4({aptosConfig:this.config,...e})}};async function a7(e){let{aptosConfig:t,options:i}=e,r={query:rA,variables:{where_condition:g([i,"optionalAccess",e=>e.where]),offset:g([i,"optionalAccess",e=>e.offset]),limit:g([i,"optionalAccess",e=>e.limit]),order_by:g([i,"optionalAccess",e=>e.orderBy])}};return(await rU({aptosConfig:t,query:r,originMethod:"getObjectData"})).current_objects}async function oe(e){let{aptosConfig:t,objectAddress:i,options:r}=e,n={object_address:{_eq:y.ba.from(i).toStringLong()}};return(await a7({aptosConfig:t,options:{...r,where:n}}))[0]}var ot=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await sg({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),oe({aptosConfig:this.config,...e})}},oi=class{constructor(e){this.config=h(e,()=>new sT),this.account=new sb(this.config),this.abstraction=new sw(this.config),this.ans=new aD(this.config),this.coin=new sz(this.config),this.digitalAsset=new aa(this.config),this.faucet=new ac(this.config),this.fungibleAsset=new af(this.config),this.general=new ay(this.config),this.staking=new aV(this.config),this.transaction=new a1(this.config),this.table=new a8(this.config),this.keyless=new a9(this.config),this.object=new ot(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function or(e,t,i){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,{value:function(...e){return this[i][r](...e)},writable:n.writable,configurable:n.configurable,enumerable:n.enumerable})})}or(oi,sb,"account"),or(oi,sw,"abstraction"),or(oi,aD,"ans"),or(oi,sz,"coin"),or(oi,aa,"digitalAsset"),or(oi,Event,"event"),or(oi,ac,"faucet"),or(oi,af,"fungibleAsset"),or(oi,ay,"general"),or(oi,aV,"staking"),or(oi,a1,"transaction"),or(oi,a8,"table"),or(oi,a9,"keyless"),or(oi,ot,"object"),t.APTOS_BIP44_REGEX=V,t.APTOS_COIN=ek,t.APTOS_FA=eP,t.APTOS_HARDENED_REGEX=M,t.AbstractKeylessAccount=iQ,t.AbstractMultiKey=tR,t.AbstractPublicKey=R,t.AbstractSignature=F,t.AbstractedAccount=i4,t.Account=iG,t.AccountAddress=y.ba,t.AccountAuthenticator=tH,t.AccountAuthenticatorAbstraction=tX,t.AccountAuthenticatorEd25519=tj,t.AccountAuthenticatorMultiEd25519=tG,t.AccountAuthenticatorMultiKey=tJ,t.AccountAuthenticatorNoAccountAuthenticator=tY,t.AccountAuthenticatorSingleKey=tW,t.AccountAuthenticatorVariant=y.z,t.AccountPublicKey=N,t.AccountSequenceNumber=aJ,t.AccountUtils=f,t.AddressInvalidReason=y.aa,t.AnyPublicKey=t$,t.AnyPublicKeyVariant=y.B,t.AnySignature=tF,t.AnySignatureVariant=y.D,t.Aptos=oi,t.AptosApiError=eM,t.AptosApiType=ez,t.AptosConfig=sT,t.AuthenticationKey=K,t.Bool=w,t.CKDPriv=J,t.ChainId=tZ,t.DEFAULT_MAX_GAS_AMOUNT=eC,t.DEFAULT_TXN_EXP_SEC_FROM_NOW=eU,t.DEFAULT_TXN_TIMEOUT_SEC=ex,t.DerivableAbstractedAccount=i9,t.DeriveScheme=y.$,t.Deserializer=m,t.EPK_HORIZON_SECS=1e7,t.Ed25519Account=iq,t.Ed25519PrivateKey=en,t.Ed25519PublicKey=er,t.Ed25519Signature=ea,t.EntryFunction=ig,t.EntryFunctionBytes=A,t.EphemeralCertificate=td,t.EphemeralCertificateVariant=y.G,t.EphemeralKeyPair=iJ,t.EphemeralPublicKey=eo,t.EphemeralPublicKeyVariant=y.E,t.EphemeralSignature=ec,t.EphemeralSignatureVariant=y.F,t.FIREBASE_AUTH_ISS_PATTERN=e$,t.FederatedKeylessAccount=i1,t.FederatedKeylessPublicKey=tU,t.FeePayerRawTransaction=ik,t.FixedBytes=_,t.Groth16ProofAndStatement=ty,t.Groth16VerificationKey=tw,t.Groth16Zkp=tf,t.HARDENED_OFFSET=H,t.Hex=y.j,t.HexInvalidReason=y.i,t.Identifier=tQ,t.KeyType=q,t.KeylessAccount=i2,t.KeylessConfiguration=tA,t.KeylessError=eL,t.KeylessErrorCategory=eR,t.KeylessErrorResolutionTip=eB,t.KeylessErrorType=eD,t.KeylessPublicKey=ts,t.KeylessSignature=tl,t.MAX_AUD_VAL_BYTES=e9,t.MAX_COMMITED_EPK_BYTES=tn,t.MAX_EXTRA_FIELD_BYTES=ti,t.MAX_ISS_VAL_BYTES=tt,t.MAX_JWT_HEADER_B64_BYTES=tr,t.MAX_UID_KEY_BYTES=e7,t.MAX_UID_VAL_BYTES=te,t.MimeType=y.q,t.ModuleId=t0,t.MoveAbility=y.X,t.MoveFunctionVisibility=y.W,t.MoveJWK=tz,t.MoveOption=k,t.MoveStr
472ing=x,t.MoveVector=C,t.MultiAgentRawTransaction=ix,t.MultiAgentTransaction=iO,t.MultiEd25519Account=i3,t.MultiEd25519PublicKey=tL,t.MultiEd25519Signature=tV,t.MultiKey=tB,t.MultiKeyAccount=i8,t.MultiKeySignature=tO,t.MultiSig=im,t.MultiSigTransactionPayload=i_,t.Network=eT,t.NetworkToChainId=eE,t.NetworkToFaucetAPI=ew,t.NetworkToIndexerAPI=e_,t.NetworkToNetworkName=eS,t.NetworkToNodeAPI=eA,t.NetworkToPepperAPI=eb,t.NetworkToProverAPI=ev,t.ParsingError=y.h,t.PrivateKey=Q,t.PrivateKeyVariants=y.A,t.ProcessorType=eN,t.PublicKey=I,t.RAW_TRANSACTION_SALT=eK,t.RAW_TRANSACTION_WITH_DATA_SALT=eI,t.RawTransaction=iC,t.RawTransactionWithData=iU,t.RoleType=y.Y,t.RotationProofChallenge=iP,t.Script=iy,t.ScriptTransactionArgumentVariants=y.s,t.Secp256k1PrivateKey=tK,t.Secp256k1PublicKey=tP,t.Secp256k1Signature=tN,t.Serializable=y.l,t.Serialized=U,t.Serializer=y.m,t.Signature=$,t.SignedTransaction=iB,t.SigningScheme=y.Z,t.SigningSchemeInput=y._,t.SimpleTransaction=iD,t.SingleKeyAccount=ij,t.StructTag=ia,t.TransactionAndProof=i0,t.TransactionAuthenticator=iK,t.TransactionAuthenticatorEd25519=iI,t.TransactionAuthenticatorFeePayer=iF,t.TransactionAuthenticatorMultiAgent=i$,t.TransactionAuthenticatorMultiEd25519=iN,t.TransactionAuthenticatorSingleSender=iR,t.TransactionAuthenticatorVariant=y.y,t.TransactionExecutable=ib,t.TransactionExecutableEmpty=iE,t.TransactionExecutableEntryFunction=iT,t.TransactionExecutableScript=iv,t.TransactionExecutableVariants=y.v,t.TransactionExtraConfig=iS,t.TransactionExtraConfigV1=iz,t.TransactionExtraConfigVariants=y.w,t.TransactionInnerPayload=iA,t.TransactionInnerPayloadV1=iw,t.TransactionInnerPayloadVariants=y.u,t.TransactionPayload=il,t.TransactionPayloadEntryFunction=ip,t.TransactionPayloadMultiSig=ih,t.TransactionPayloadScript=id,t.TransactionPayloadVariants=y.t,t.TransactionResponseType=y.I,t.TransactionVariants=y.x,t.TransactionWorker=a0,t.TransactionWorkerEventsEnum=aQ,t.TypeTag=t2,t.TypeTagAddress=t7,t.TypeTagBool=t1,t.TypeTagGeneric=ii,t.TypeTagParserError=r0,t.TypeTagParserErrorType=rQ,t.TypeTagReference=it,t.TypeTagSigner=ie,t.TypeTagStruct=is,t.TypeTagU128=t4,t.TypeTagU16=t3,t.TypeTagU256=t9,t.TypeTagU32=t5,t.TypeTagU64=t6,t.TypeTagU8=t8,t.TypeTagVariants=y.r,t.TypeTagVector=ir,t.U128=S,t.U16=v,t.U256=z,t.U32=T,t.U64=E,t.U8=b,t.ZeroKnowledgeSig=t_,t.ZkProof=tm,t.ZkpVariant=y.H,t.anyPublicKeyVariantToString=y.C,t.aptosCoinStructTag=function(){return new ia(y.ba.ONE,new tQ("aptos_coin"),new tQ("AptosCoin"),[])},t.aptosRequest=eq,t.base64UrlDecode=y.ja,t.base64UrlToBytes=y.ka,t.bigIntToBytesLE=ef,t.buildTransaction=nU,t.bytesToBigIntLE=eg,t.checkOrConvertArgument=nb,t.convertAmountFromHumanReadableToOnChain=y.la,t.convertAmountFromOnChainToHumanReadable=y.ma,t.convertArgument=nw,t.convertNumber=r6,t.convertPayloadToInnerPayload=nC,t.createObjectAddress=y.ca,t.createResourceAddress=y.da,t.createTokenAddress=y.ea,t.deriveKey=W,t.deriveTransactionType=iL,t.deserializeFromScriptArgument=iu,t.deserializePublicKey=function(e){let t;for(let i of[er,t$,tL,tB,ts,tU,tP])try{let r=m.fromHex(e),n=i.deserialize(r);if(r.assertFinished(),t)throw Error(`${tq}: ${e}`);t=n}catch(e){if(e instanceof Error&&e.message.includes(tq))throw e}if(!t)throw Error(`Failed to deserialize public key: ${e}`);return t},t.deserializeSignature=function(e){let t;for(let i of[ea,tF,tV,tO,tl,tN])try{let r=m.fromHex(e),n=i.deserialize(r);if(r.assertFinished(),t)throw Error(`${tq}: ${e}`);t=n}catch(e){if(e instanceof Error&&e.message.includes(tq))throw e}if(!t)throw Error(`Failed to deserialize signature: ${e}`);return t},t.ensureBoolean=y.n,t.fetchEntryFunctionAbi=n_,t.fetchFunctionAbi=ny,t.fetchJWK=tc,t.fetchModuleAbi=nf,t.fetchMoveFunctionAbi=nm,t.fetchViewFunctionAbi=nA,t.findFirstNonSignerArg=np,t.floorToWholeHour=y.ia,t.generateRawTransaction=nz,t.generateSignedTransaction=nP,t.generateSignedTransactionForSimulation=nx,t.generateSigningMessage=iM,t.generateSigningMessageForSerializable=function(e){return iM(e.bcsToBytes(),`APTOS::${e.constructor.name}`)},t.generateSigningMessageForTransaction=iV,t.generateTransactionPayload=nv,t.generateTransactionPayloadWithABI=nT,t.generateUserTransactionHash=function(e){let t=nP(e);return new(0,y.j)(nK([nI,new Uint8Array([0]),t])).toString()},t.generateViewFunctionPayload=nE,t.generateViewFunctionPayloadWithABI=nS,t.get=eH,t.getAptosFullNode=ej,t.getAptosPepperService=eG,t.getAuthenticatorForSimulation=nk,t.getErrorMessage=y.ga,t.getFunctionParts=y.pa,t.getIssAudAndUidVal=tv,t.getKeylessConfig=tb,t.getKeylessJWKs=tS,t.getPageWithObfuscatedCursor=eY,t.hashStrTo
472Field=ep,t.hashValues=nK,t.hexToAsciiString=y.k,t.isBcsAddress=nt,t.isBcsBool=ne,t.isBcsFixedBytes=nr,t.isBcsString=ni,t.isBcsU128=nc,t.isBcsU16=ns,t.isBcsU256=nu,t.isBcsU32=na,t.isBcsU64=no,t.isBcsU8=nn,t.isBlockEpilogueTransactionResponse=y.P,t.isBlockMetadataTransactionResponse=y.M,t.isBool=r8,t.isCanonicalEd25519Signature=ei,t.isEd25519Signature=y.Q,t.isEmptyOption=r9,t.isEncodedEntryFunctionArgument=r7,t.isEncodedStruct=y.oa,t.isFeePayerSignature=y.T,t.isGenesisTransactionResponse=y.L,t.isKeylessSigner=iX,t.isLargeNumber=r4,t.isMultiAgentSignature=y.S,t.isMultiEd25519Signature=y.U,t.isNumber=r5,t.isPendingTransactionResponse=y.J,t.isScriptDataInput=nl,t.isSecp256k1Signature=y.R,t.isSingleKeySigner=iH,t.isSingleSenderSignature=y.V,t.isStateCheckpointTransactionResponse=y.N,t.isString=r3,t.isUserTransactionResponse=y.K,t.isValidBIP44Path=j,t.isValidFunctionInfo=y.qa,t.isValidHardenedPath=G,t.isValidatorTransactionResponse=y.O,t.mnemonicToSeed=Z,t.normalizeBundle=eF,t.nowInSeconds=y.ha,t.objectStructTag=ic,t.optionStructTag=function(e){return new ia(y.ba.ONE,new tQ("option"),new tQ("Option"),[e])},t.outOfRangeErrorMessage=y.o,t.padAndPackBytesWithLen=eh,t.paginateWithCursor=eW,t.paginateWithObfuscatedCursor=eJ,t.pairedFaMetadataAddress=y.sa,t.parseEncodedStruct=y.na,t.parseJwtHeader=tC,t.parseTypeTag=r2,t.poseidonHash=ey,t.post=eX,t.postAptosFaucet=e0,t.postAptosFullNode=eZ,t.postAptosIndexer=eQ,t.postAptosPepperService=e2,t.postAptosProvingService=e1,t.promiseFulfilledStatus=aZ,t.request=eV,t.sleep=y.fa,t.splitPath=X,t.standardizeTypeTags=ng,t.stringStructTag=io,t.throwTypeMismatch=nd,t.truncateAddress=y.ra,t.validateNumberInRange=y.p,t.verifyKeylessSignature=ta,t.verifyKeylessSignatureWithJwkAndConfig=to}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.