"use strict";var D=Object.defineProperty;var E=n=>{throw TypeError(n)};var L=(n,s,e)=>s in n?D(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e;var f=(n,s,e)=>L(n,typeof s!="symbol"?s+"":s,e),G=(n,s,e)=>s.has(n)||E("Cannot "+e);var l=(n,s,e)=>(G(n,s,"read from private field"),e?e.call(n):s.get(n)),p=(n,s,e)=>s.has(n)?E("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(n):s.set(n,e),c=(n,s,e,t)=>(G(n,s,"write to private field"),t?t.call(n,e):s.set(n,e),e);var A=(n,s,e,t)=>({set _(a){c(n,s,a,e)},get _(){return l(n,s,t)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-CDGktAjP.js");var o,g;const v=class v extends r.AbstractSigner{constructor(e){super(e.provider);f(this,"signer");p(this,o);p(this,g);r.defineProperties(this,{signer:e}),c(this,o,null),c(this,g,0)}async getAddress(){return this.signer.getAddress()}connect(e){return new v(this.signer.connect(e))}async getNonce(e){if(e==="pending"){l(this,o)==null&&c(this,o,super.getNonce("pending"));const t=l(this,g);return await l(this,o)+t}return super.getNonce(e)}increment(){A(this,g)._++}reset(){c(this,g,0),c(this,o,null)}async sendTransaction(e){const t=this.getNonce("pending");return this.increment(),e=await this.signer.populateTransaction(e),e.nonce=await t,await this.signer.sendTransaction(e)}signTransaction(e){return this.signer.signTransaction(e)}signMessage(e){return this.signer.signMessage(e)}signTypedData(e,t,a){return this.signer.signTypedData(e,t,a)}};o=new WeakMap,g=new WeakMap;let P=v;async function O(n,s,e){const t=typeof s=="string"?new r.Wallet(s,n):s,a=(e==null?void 0:e.chain)??(await r.EvmPlatform.chainFromRpc(n))[1],i=new P(t);if(i.provider===null)try{i.connect(n)}catch(d){console.error("Cannot connect to network for signer",d)}return new b(a,await t.getAddress(),i,e)}class b extends r.PlatformNativeSigner{constructor(e,t,a,i){super(e,t,a);f(this,"opts");this.opts=i}chain(){return this._chain}address(){return this._address}async sign(e){var w,y,x,C,S,T;const t=this.chain(),a=[];let i=500000n,d=100000000000n,m=1500000000n,u=100000000n;if(((w=this.opts)==null?void 0:w.overrides)===void 0&&t!=="Celo"){const h=await this._signer.provider.getFeeData();d=h.gasPrice??d,m=h.maxFeePerGas??m,u=h.maxPriorityFeePerGas??u}((y=this.opts)==null?void 0:y.maxGasLimit)!==void 0&&(i=i>((x=this.opts)==null?void 0:x.maxGasLimit)?(C=this.opts)==null?void 0:C.maxGasLimit:i);const F=t==="Oasis"?{gasLimit:i,gasPrice:d,type:0}:{gasLimit:i,maxFeePerGas:m,maxPriorityFeePerGas:u};for(const h of e){const{transaction:N,description:q}=h;(S=this.opts)!=null&&S.debug&&console.log(`Signing: ${q} for ${this.address()}`);const _={...N,...F,from:this.address(),nonce:await this._signer.getNonce(),...(T=this.opts)==null?void 0:T.overrides};a.push(await this._signer.signTransaction(_))}return a}}const B={Address:r.EvmAddress,Platform:r.EvmPlatform,getSigner:O,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-CDGktAjP.js")).then(n=>n.index$1),TokenBridge:()=>Promise.resolve().then(()=>require("./index-C7amSMG9.js")),PorticoBridge:()=>Promise.resolve().then(()=>require("./index-CAkX47d8.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-CFVm1KSi.js"))},getChain:(n,s,e)=>new r.EvmChain(s,new r.EvmPlatform(n,r.applyChainsConfigConfigOverrides(n,r._platform,{[s]:e})))};exports.default=B;
