import { aI as A, c7 as _, ax as V, aC as Z, c8 as Ct, an as B, aj as q, ap as ct, ao as dt, ah as U, c9 as mt, d as X, W as z, J as Y, u as G, f as ut, v as $, y as D, R as lt, e as x, n as H, i as O, N as F, o as At, h as tt, Y as nt, ag as et, z as at, as as pt, j as vt, q as kt, _ as xt, $ as bt } from "./platform-Cil_UtAQ.mjs";
const W = (t) => [
  { name: "id", binary: "bytes", size: 32 },
  { name: "sender", ...A },
  _({ name: "payload", lengthSize: 2 }, t)
], M = (t) => ({
  name: "prefix",
  binary: "bytes",
  custom: Uint8Array.from(t),
  omit: !0
}), It = (t, e, i) => [
  M(t),
  { name: "sourceNttManager", ...A },
  { name: "recipientNttManager", ...A },
  _({ name: "nttManagerPayload", lengthSize: 2 }, e),
  _({ name: "transceiverPayload", lengthSize: 2 }, i)
], St = [
  M([156, 35, 189, 59]),
  { name: "managerAddress", ...A },
  { name: "mode", binary: "uint", size: 1 },
  { name: "token", ...A },
  { name: "decimals", binary: "uint", size: 1 }
], Nt = [
  M([24, 252, 103, 194]),
  { name: "chain", ...V() },
  { name: "transceiver", ...A }
], Dt = [
  { name: "decimals", binary: "uint", size: 1 },
  { name: "amount", binary: "uint", size: 8 }
], ft = {
  binary: "bytes",
  layout: Dt
};
function Lt(t, e) {
  let i = 0n;
  for (let c = 0; c < e; ++c)
    i |= BigInt(t[c]) << BigInt(8 * (e - c - 1));
  return Number(i);
}
function _t(t, e) {
  const i = 2n ** BigInt(e * 8);
  if (t >= i)
    throw new Error(`Value ${t} is too large for ${e} bytes`);
  const c = new Uint8Array(e);
  for (let d = 0; d < e; ++d)
    c[d] = Number(BigInt(t) >> BigInt(8 * (e - d - 1)) & 0xffn);
  return c;
}
const Mt = {
  binary: "bytes",
  custom: {
    to: (t) => {
      if (t.byteLength >= 2) {
        const e = Lt(t, 2);
        return t.slice(2, 2 + e);
      }
      return new Uint8Array();
    },
    from: (t) => t.byteLength > 0 ? new Uint8Array([..._t(t.byteLength, 2), ...t]) : new Uint8Array()
  }
}, R = [
  M([153, 78, 84, 84]),
  { name: "trimmedAmount", ...ft },
  { name: "sourceToken", ...A },
  { name: "recipientAddress", ...A },
  { name: "recipientChain", ...V() },
  { name: "additionalPayload", ...Mt }
], Ft = [
  { name: "name", ...Z(32) },
  { name: "symbol", ...Z(32) },
  { name: "decimals", binary: "uint", size: 1 }
], Ut = {
  binary: "bytes",
  layout: Ft
}, Wt = [
  { name: "chainId", ...V() },
  { name: "tokenAddress", ...A }
], Pt = {
  binary: "bytes",
  layout: Wt
}, Ot = [
  { name: "meta", ...Ut },
  { name: "token", ...Pt }
], zt = {
  binary: "bytes",
  layout: Ot
}, ht = [
  // bytes4 constant MTT_PREFIX = 0x994D5454;
  M([153, 77, 84, 84]),
  { name: "trimmedAmount", ...ft },
  { name: "token", ...zt },
  { name: "sender", ...A },
  { name: "to", ...A },
  _({ name: "additionalPayload", lengthSize: 2 })
], gt = (t) => [
  M([153, 71, 77, 80]),
  { name: "toChain", ...V() },
  { name: "callee", ...A },
  { name: "sender", ...A },
  _({ name: "data", lengthSize: 2 }, t)
], Q = (t) => It([153, 69, 255, 16], t, new Uint8Array(0)), $t = (t) => [
  { name: "index", binary: "uint", size: 1 },
  _({ name: "payload", lengthSize: 1 }, t)
], jt = [
  [
    "WormholeTransfer",
    Q(W(R))
  ],
  [
    "WormholeTransferStandardRelayer",
    Ct(Q(W(R)))
  ],
  ["TransceiverInfo", St],
  ["TransceiverRegistration", Nt]
], Vt = [
  [
    "WormholeTransfer",
    Q(W(gt(ht)))
  ]
];
var ot;
(function(t) {
  t.DEFAULT_SVM_SHIM_ADDRESSES = {
    Solana: {
      postMessageShim: "EtZMZM22ViKMo4r5y4Anovs3wKQ2owUmDpjygnMMcdEX",
      verifyVaaShim: "EFaNWErqAtVWufdNb7yofSHHfWFos843DFpu4JBw24at"
    },
    Fogo: {
      postMessageShim: "EtZMZM22ViKMo4r5y4Anovs3wKQ2owUmDpjygnMMcdEX",
      verifyVaaShim: "EFaNWErqAtVWufdNb7yofSHHfWFos843DFpu4JBw24at"
    }
  };
  function e(d) {
    if (d.length > 255)
      throw new Error(`Too many instructions (${d.length})`);
    return B.concat(new Uint8Array([d.length]), ...d.map((w) => q($t(), w)));
  }
  t.encodeTransceiverInstructions = e;
  function i(d, w) {
    return ct(B.concat(dt.toBytes(U(d), 2), q(W(R), w)));
  }
  t.messageDigest = i;
  function c(d, w) {
    const C = (f) => {
      const h = /^(\d+)\.(\d+)\.(.*)$/, a = f.match(h);
      if (!a)
        throw new Error(`Invalid version format: ${f}`);
      const [, n, o, r] = a;
      return { major: Number(n), minor: Number(o), patchAndTag: r };
    }, { major: b, minor: p } = C(d), { major: l, minor: u } = C(w);
    return b === l && p >= u;
  }
  t.abiVersionMatches = c;
})(ot || (ot = {}));
var rt;
(function(t) {
  function e(i, c) {
    return ct(B.concat(dt.toBytes(U(i), 2), q(W(gt(ht)), c)));
  }
  t.messageDigest = e;
})(rt || (rt = {}));
const Xt = {
  Ethereum: "ethereum",
  Monad: "monad",
  Sepolia: "ethereum-sepolia"
  // add more as needed
};
var N;
(function(t) {
  t.SRC_GATEWAY_CALLED = "source_gateway_called", t.DEST_GATEWAY_APPROVED = "destination_gateway_approved", t.DEST_EXECUTED = "destination_executed", t.EXPRESS_EXECUTED = "express_executed", t.DEST_EXECUTE_ERROR = "error", t.DEST_EXECUTING = "executing", t.APPROVING = "approving", t.FORECALLED = "forecalled", t.FORECALLED_WITHOUT_GAS_PAID = "forecalled_without_gas_paid", t.NOT_EXECUTED = "not_executed", t.NOT_EXECUTED_WITHOUT_GAS_PAID = "not_executed_without_gas_paid", t.INSUFFICIENT_FEE = "insufficient_fee", t.UNKNOWN_ERROR = "unknown_error", t.CANNOT_FETCH_STATUS = "cannot_fetch_status", t.SRC_GATEWAY_CONFIRMED = "confirmed";
})(N || (N = {}));
function wt(t) {
  return t === "Mainnet" ? "https://api.axelarscan.io" : "https://testnet.api.axelarscan.io";
}
function J(t) {
  const e = Xt[t];
  if (!e)
    throw new Error(`Unsupported axelar chain: ${t}`);
  return e;
}
async function tn(t, e, i, c, d = "auto", w = 1e4) {
  const C = `${wt(t)}/gmp/estimateGasFee`, b = J(e), p = J(i), l = new AbortController(), u = setTimeout(() => l.abort(), w);
  let f = 1n;
  try {
    const h = await fetch(C, {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        sourceChain: b,
        destinationChain: p,
        gasMultiplier: d,
        gasLimit: c.toString()
      }),
      signal: l.signal
    });
    if (!h.ok) {
      const o = await h.text();
      throw new Error(`Failed to estimate gas fee: ${h.status} ${o}`);
    }
    const a = await h.json(), n = BigInt(a);
    n > 0n && (f = n);
  } finally {
    clearTimeout(u);
  }
  return f;
}
async function Bt(t, e, i, c = 1e4) {
  const d = `${wt(t)}/gmp/searchGMP`, w = J(e), C = new AbortController(), b = setTimeout(() => C.abort(), c);
  try {
    const p = await fetch(d, {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        sourceChain: w,
        txHash: i
      }),
      signal: C.signal
    });
    if (!p.ok) {
      const f = await p.text();
      throw new Error(`Failed to get transaction status: ${p.status} ${f}`);
    }
    const l = await p.json();
    if (!l.data || l.data.length === 0)
      throw new Error("No transaction details found");
    const u = l.data[0];
    return {
      status: qt(u),
      error: Gt(u)
    };
  } finally {
    clearTimeout(b);
  }
}
function qt(t) {
  const { error: e, status: i } = t;
  switch (i) {
    case "error":
      return e ? N.DEST_EXECUTE_ERROR : i;
    case "executed":
      return N.DEST_EXECUTED;
    case "approved":
      return N.DEST_GATEWAY_APPROVED;
    case "called":
      return N.SRC_GATEWAY_CALLED;
    case "executing":
      return N.DEST_EXECUTING;
    default:
      return i;
  }
}
function Gt(t) {
  if (t.error)
    return {
      message: t.error.error.message,
      txHash: t.error.sourceTransactionHash,
      chain: t.error.chain
    };
  if (t.is_insufficient_fee)
    return {
      message: "Insufficient gas",
      txHash: t.call.transaction.hash,
      chain: t.call.chain
    };
}
function Ht(t, e) {
  return t === "Mainnet" ? `https://axelarscan.io/gmp/${e}` : `https://testnet.axelarscan.io/gmp/${e}`;
}
mt("Ntt", jt);
mt("MultiTokenNtt", Vt);
const K = {
  Mainnet: "https://executor.labsapis.com",
  Testnet: "https://executor-testnet.labsapis.com"
}, nn = (t) => {
  let e = "";
  if (X(t) === "Evm")
    e = "0x9b2A3B92b1D86938D3Ed37B0519952C227bA6D09";
  else if (X(t) === "Solana")
    e = "9q2q3EtP1VNdyaxzju1CGfh3EDj7heGABgxAJNyQDXgT";
  else if (X(t) === "Sui")
    e = "0xbfa1240e48c622d97881473953be730091161b7931d89bd6afe667841cf69ef4";
  else
    throw new Error(`No referrer address for chain ${t}`);
  return z.chainAddress(t, e);
};
var L;
(function(t) {
  t.Pending = "pending", t.Failed = "failed", t.Unsupported = "unsupported", t.Submitted = "submitted", t.Underpaid = "underpaid", t.Aborted = "aborted";
})(L || (L = {}));
var st;
(function(t) {
  t.ERM1 = "ERM1", t.ERV1 = "ERV1", t.ERN1 = "ERN1", t.ERC1 = "ERC1", t.ERC2 = "ERC2";
})(st || (st = {}));
async function en(t) {
  const e = `${K[t]}/v0/capabilities`;
  try {
    return (await Y.get(e)).data;
  } catch {
    throw new Error(`Failed to fetch capabilities for network: ${t}.`);
  }
}
async function an(t, e, i, c) {
  const d = `${K[t]}/v0/quote`;
  try {
    return (await Y.post(d, {
      srcChain: U(e),
      dstChain: U(i),
      relayInstructions: c
    })).data;
  } catch {
    throw new Error("Failed to fetch signed quote.");
  }
}
async function Rt(t, e, i) {
  const c = `${K[t]}/v0/status/tx`;
  try {
    return (await Y.post(c, {
      txHash: e,
      chainId: U(i)
    })).data;
  } catch {
    throw new Error(`Failed to fetch status for txHash: ${e}.`);
  }
}
function Qt(t) {
  return t === L.Failed || // this could happen if simulation fails
  t === L.Underpaid || // only happens if you don't pay at least the costEstimate
  t === L.Unsupported || // capabilities check didn't pass
  t === L.Aborted;
}
const Jt = 65535n;
function on(t, e, i) {
  if (e > Jt)
    throw new Error("dBps exceeds max u16");
  const c = G(t);
  let d = c, w = 0n;
  if (e > 0) {
    w = c * e / 100000n;
    const C = j.trimAmount(ut(w, t.decimals), i);
    d = c - G(C);
  }
  return { referrerFee: w, remainingAmount: d, referrerFeeDbps: e };
}
async function Yt(t, e) {
  if (!$(e) && !D(e))
    return e;
  if (e.originTxs.length === 0)
    throw new Error("No origin transactions found in receipt");
  const i = e.originTxs.at(-1).txid, [c] = await Rt(t, i, e.from);
  if (!c)
    throw new Error("No transaction status found");
  const d = c.status;
  return Qt(d) ? {
    ...e,
    state: x.Failed,
    error: new lt(`Relay failed with status: ${d}`)
  } : D(e) ? {
    ...e,
    state: x.Attested,
    // @ts-ignore
    error: void 0
  } : e;
}
async function Kt(t, e) {
  if (!$(e) && !D(e))
    return e;
  if (e.originTxs.length === 0)
    throw new Error("No origin transactions found in receipt");
  const i = e.originTxs.at(-1).txid, c = await Bt(t, e.from, i);
  return c.error ? {
    ...e,
    state: x.Failed,
    error: new lt(
      `Axelar error: ${c.error.message}`,
      // @ts-ignore
      {
        url: Ht(t, i),
        name: "Axelarscan"
      }
    )
  } : D(e) ? {
    ...e,
    state: x.Attested,
    // @ts-ignore
    error: void 0
  } : e;
}
var j;
(function(t) {
  t.TRIMMED_DECIMALS = 8, t.ManualOptions = {
    automatic: !1
  }, t.AutomaticOptions = {
    automatic: !0
  };
  function e(l) {
    return ["Mainnet", "Testnet"];
  }
  t.resolveSupportedNetworks = e;
  function i(l, u) {
    return Object.values(l.tokens).flatMap((h) => h.map((a) => a.chain));
  }
  t.resolveSupportedChains = i;
  function c(l, u) {
    return Object.entries(l.tokens).reduce((h, [, a]) => {
      const n = a.find((o) => o.chain === u.chain);
      return n && (h.push(z.tokenId(u.chain, n.token)), n.isWrappedGasToken && h.push(H(u.chain))), h;
    }, []);
  }
  t.resolveSourceTokens = c;
  function d(l, u, f, h) {
    return Object.entries(l.tokens).map(([, a]) => {
      if (!a.find((r) => r.chain === f.chain && (r.token.toLowerCase() === F(u).toLowerCase() || O(u.address) && r.isWrappedGasToken)))
        return;
      const o = a.find((r) => r.chain === h.chain);
      if (o)
        return z.tokenId(h.chain, o.token);
    }).filter((a) => !!a);
  }
  t.resolveDestinationTokens = d;
  function w(l, u, f) {
    const h = Object.values(l.tokens), a = F(u), n = F(f);
    for (const o of h) {
      const r = o.find((s) => s.chain === u.chain && (s.token.toLowerCase() === a.toLowerCase() || O(u.address) && s.isWrappedGasToken));
      if (r) {
        const s = o.find((m) => m.chain === f.chain && (m.token.toLowerCase() === n.toLowerCase() || O(f.address) && m.isWrappedGasToken));
        if (s)
          return {
            srcContracts: {
              token: r.token,
              manager: r.manager,
              transceiver: {
                wormhole: r.transceiver.find((m) => m.type === "wormhole").address
              },
              quoter: r.quoter,
              svmShims: r.svmShims
            },
            dstContracts: {
              token: s.token,
              manager: s.manager,
              transceiver: {
                wormhole: s.transceiver.find((m) => m.type === "wormhole").address
              },
              svmShims: s.svmShims
            }
          };
      }
    }
    throw new Error("Cannot find Ntt contracts in config for: " + a);
  }
  t.resolveNttContracts = w;
  function C(l, u, f) {
    const h = Object.values(l.tokens), a = F(u);
    for (const n of h)
      if (n.find((r) => r.manager.toLowerCase() === a.toLowerCase() && r.chain === u.chain)) {
        const r = n.find((s) => s.chain === f);
        if (!r)
          throw new Error(`Cannot find destination Ntt contracts in config for: ${a}`);
        return {
          token: r.token,
          manager: r.manager,
          transceiver: {
            wormhole: r.transceiver.find((s) => s.type === "wormhole").address
          },
          quoter: r.quoter,
          svmShims: r.svmShims
        };
      }
    throw new Error("Cannot find Ntt contracts in config for: " + a);
  }
  t.resolveDestinationNttContracts = C;
  function b(l, u) {
    const f = u * 95n / 100n;
    return l > f;
  }
  t.isCapacityThresholdExceeded = b;
  function p(l, u) {
    return At(l, Math.min(l.decimals, u, t.TRIMMED_DECIMALS));
  }
  t.trimAmount = p;
})(j || (j = {}));
var it;
(function(t) {
  function e(a) {
    return ["Mainnet", "Testnet"];
  }
  t.resolveSupportedNetworks = e;
  function i(a, n) {
    return a.flatMap((o) => o.chain);
  }
  t.resolveSupportedChains = i;
  function c(a, n) {
    const o = a.find((r) => r.chain === n);
    if (!o)
      throw new Error("Cannot find MultiTokenNtt contracts in config for: " + n);
    return o;
  }
  t.resolveContracts = c;
  async function d(a, n, o, r, s) {
    if (a.chain !== n.chain)
      throw new Error("Source token must be native to the source chain");
    const m = await n.getProtocol("MultiTokenNtt", {
      multiTokenNtt: t.resolveContracts(r, n.chain)
    }), y = await o.getProtocol("MultiTokenNtt", {
      multiTokenNtt: t.resolveContracts(r, o.chain)
    });
    O(a.address) && (a = await m.getWrappedNativeToken()), s = s ?? await m.getOriginalToken(a);
    const T = await y.getLocalToken(s);
    if (T) {
      const I = await y.getWrappedNativeToken();
      return tt(I, T) ? H(o.chain) : T;
    }
    const g = await m.getTokenMeta(a), k = await y.calculateLocalTokenAddress(s, g);
    return {
      chain: o.chain,
      address: k,
      isUnattested: !0,
      // TODO: decimals may need to be adjusted for non-EVM platforms if we support them
      decimals: g.decimals,
      originalTokenId: z.tokenId(a.chain, a.address.toString())
    };
  }
  t.getDestinationTokenId = d;
  async function w(a, n, o, r) {
    if (r) {
      const T = F(a.destination.id), g = r[a.destination.id.chain]?.[T];
      if (g?.gasLimit !== void 0)
        return g.gasLimit;
    }
    const s = t.resolveContracts(o, a.toChain.chain);
    return await (await a.toChain.getProtocol("MultiTokenNtt", {
      multiTokenNtt: s
    })).estimateGasLimit(n);
  }
  t.estimateGasLimit = w;
  async function C(a, n, o, r, s) {
    if (s > 0n && await a.getInboundLimit(o, n) !== null) {
      const y = await a.getCurrentInboundCapacity(o, n);
      if (j.isCapacityThresholdExceeded(G(r), y))
        return [
          {
            type: "DestinationCapacityWarning",
            delayDurationSec: Number(s)
          }
        ];
    }
  }
  t.checkRateLimit = C;
  async function b(a, n, o) {
    return await (await a.getProtocol("MultiTokenNtt", {
      multiTokenNtt: t.resolveContracts(o, a.chain)
    })).isWrappedToken(n);
  }
  t.isWrappedToken = b;
  async function p(a, n, o) {
    const s = await (await a.getProtocol("MultiTokenNtt", {
      multiTokenNtt: t.resolveContracts(o, a.chain)
    })).getOriginalToken(n);
    if (s === null)
      throw new Error("Token is not a wrapped token");
    return {
      chain: s.chain,
      address: s.address.toNative(s.chain)
    };
  }
  t.getOriginalToken = p;
  async function l(a, n, o) {
    if (!$(o) && !D(o)) {
      if (nt(o))
        return o;
      throw new Error("The source must be finalized in order to complete the transfer");
    }
    if (!o.attestation)
      throw new Error("No attestation found on the transfer receipt");
    const r = await n.getProtocol("MultiTokenNtt", {
      multiTokenNtt: o.params.normalizedParams.destinationContracts
    }), { sendTransceivers: s } = o.params.normalizedParams, m = s.find((g) => g.type.toLowerCase() === "wormhole");
    if (!m)
      throw new Error("No Wormhole transceiver found, cannot complete manual transfer");
    if (await r.transceiverAttestedToMessage(o.from, o.attestation.attestation.payload.nttManagerPayload, m.index))
      return o;
    const T = r.redeem(o.attestation.attestation);
    return await et(n, T, a), o;
  }
  t.complete = l;
  async function u(a, n, o) {
    if (!at(o))
      throw new Error("The transfer must be destination queued in order to finalize");
    const { attestation: { attestation: r } } = o, m = (await n.getProtocol("MultiTokenNtt", {
      multiTokenNtt: o.params.normalizedParams.destinationContracts
    })).completeInboundQueuedTransfer(o.from, r.payload.nttManagerPayload), y = await et(n, m, a);
    return {
      ...o,
      state: x.DestinationFinalized,
      destinationTxs: [...o.destinationTxs ?? [], ...y]
    };
  }
  t.finalize = u;
  async function f(a, n, o) {
    const r = n.getChain(a.chain), [s] = await r.parseTransaction(a.txid);
    if (!s)
      throw new Error("No Wormhole messages found");
    const m = await n.getVaa(s, "MultiTokenNtt:WormholeTransfer");
    if (!m)
      throw new Error("No VAA found for transaction: " + a.txid);
    const { payload: y } = m.payload.nttManagerPayload, T = t.resolveContracts(o, r.chain);
    if (!y.sender.equals(pt(r.chain, T.manager)))
      throw new Error("Invalid source manager");
    const g = t.resolveContracts(o, y.toChain), { trimmedAmount: k } = y.data, I = ut(k.amount, k.decimals), E = {
      chain: y.data.token.token.chainId,
      address: y.data.token.token.tokenAddress
    }, v = await r.getProtocol("MultiTokenNtt", {
      multiTokenNtt: T
    });
    let S = await v.getLocalToken(E);
    if (S === null)
      throw new Error("Source token not found");
    const P = await v.getWrappedNativeToken();
    tt(P, S) && (S = H(r.chain));
    const yt = await t.getDestinationTokenId(S, r, n.getChain(y.toChain), o, E), Tt = await v.getSendTransceivers(y.toChain), Et = {
      chain: m.emitterChain,
      emitter: m.emitterAddress,
      sequence: m.sequence
    };
    return {
      from: m.emitterChain,
      to: y.toChain,
      state: x.Attested,
      originTxs: [a],
      attestation: {
        id: Et,
        attestation: m
      },
      params: {
        amount: vt(I),
        normalizedParams: {
          amount: I,
          sourceContracts: T,
          destinationContracts: g,
          sourceTokenId: S,
          destinationTokenId: yt,
          originalTokenId: E,
          sendTransceivers: Tt,
          gasLimit: 0n
        },
        options: {}
      },
      trackingInfo: { transceiverAttested: {} }
    };
  }
  t.resume = f;
  async function* h(a, n, o, r) {
    let s = r || 36e5;
    for (; s > 0 && !kt(n); ) {
      const m = Date.now();
      if (xt(n) || bt(n)) {
        const g = n.originTxs.at(-1), k = a.getChain(n.from), [I] = await k.parseTransaction(g.txid);
        if (!I)
          throw new Error("No Wormhole messages found");
        const E = await a.getVaa(I, "MultiTokenNtt:WormholeTransfer", r);
        if (!E)
          throw new Error("No VAA found for transaction: " + g.txid);
        const v = {
          chain: E.emitterChain,
          emitter: E.emitterAddress,
          sequence: E.sequence
        };
        n = {
          ...n,
          state: x.Attested,
          attestation: {
            id: v,
            attestation: E
          }
        }, yield n;
      }
      const T = await a.getChain(n.to).getProtocol("MultiTokenNtt", {
        multiTokenNtt: n.params.normalizedParams.destinationContracts
      });
      if ($(n) || D(n)) {
        if (!n.attestation)
          throw new Error("No attestation found");
        const g = n.attestation.attestation;
        if (await T.getIsApproved(g))
          n = {
            ...n,
            state: x.DestinationInitiated,
            attestation: n.attestation
          }, yield n;
        else {
          const { sendTransceivers: k } = n.params.normalizedParams, I = [...k].sort((E, v) => {
            const S = E.type.toLowerCase(), P = v.type.toLowerCase();
            return S === "wormhole" && P !== "wormhole" ? 1 : S !== "wormhole" && P === "wormhole" ? -1 : 0;
          });
          for (const E of I) {
            const v = E.type.toLowerCase();
            if (n.trackingInfo.transceiverAttested[v])
              continue;
            if (await T.transceiverAttestedToMessage(n.from, g.payload.nttManagerPayload, E.index)) {
              n.trackingInfo.transceiverAttested[v] = !0, D(n) && (n = {
                ...n,
                attestation: n.attestation,
                state: x.Attested
              }, yield n);
              continue;
            }
            if (v === "wormhole")
              o || (n = await Yt(a.network, n));
            else if (v === "axelar")
              n = await Kt(a.network, n);
            else
              throw new Error(`Unsupported transceiver type: ${E.type}`);
            yield n;
            break;
          }
        }
      }
      if (nt(n) || at(n)) {
        const g = n.attestation.attestation, k = await T.getInboundQueuedTransfer(g.emitterChain, g.payload.nttManagerPayload);
        k !== null ? n = {
          ...n,
          state: x.DestinationQueued,
          queueReleaseTime: new Date(k.rateLimitExpiryTimestamp * 1e3)
        } : await T.getIsExecuted(g) && (n = {
          ...n,
          state: x.DestinationFinalized
        });
      }
      yield n, await new Promise((g) => setTimeout(g, 5e3)), s -= Date.now() - m;
    }
    return n;
  }
  t.track = h;
})(it || (it = {}));
export {
  it as M,
  j as N,
  an as a,
  Rt as b,
  on as c,
  ot as d,
  rt as e,
  en as f,
  nn as g,
  tn as h,
  Qt as i,
  R as n
};
