var u = Object.defineProperty;
var p = (i, t, n) => t in i ? u(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
var o = (i, t, n) => p(i, typeof t != "symbol" ? t + "" : t, n);
import { Z as f, _ as l, a3 as r } from "./address-CBux52Na.mjs";
const v = "0x1::aptos_coin::AptosCoin", s = "::", c = "Aptos", h = (i) => /^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(i), x = (i) => i.split(s)[0];
function m(i) {
  return i.length % 2 !== 0 || i.length < 66 ? (i = i.startsWith("0x") ? i.slice(2) : i, "0x" + i.padStart(64, "0")) : i;
}
const e = class e {
  constructor(t) {
    o(this, "type", "Native");
    // Full 32 bytes of Address
    o(this, "address");
    // Optional module and contract name
    o(this, "module");
    if (e.instanceof(t))
      this.address = t.address, this.module = t.module;
    else if (l.instanceof(t))
      this.address = t.toUint8Array();
    else if (typeof t == "string") {
      if (h(t)) {
        const n = t.split(s);
        this.module = n.slice(1).join(s), t = n[0];
      }
      if (t = m(t), !r.valid(t))
        throw new Error("Invalid Aptos address: " + t);
      this.address = r.decode(t);
    } else
      this.address = t;
  }
  unwrap() {
    const t = r.encode(this.address).replace(/^0+/, ""), n = this.module ? s + this.module : "";
    return `0x${t}${n}`;
  }
  toString() {
    return this.unwrap();
  }
  toNative() {
    return this;
  }
  toUint8Array() {
    return this.address;
  }
  toUniversalAddress() {
    return new l(this.toUint8Array());
  }
  static instanceof(t) {
    return t.constructor.platform === e.platform;
  }
  equals(t) {
    return e.instanceof(t) ? t.unwrap() === this.unwrap() : this.toUniversalAddress().equals(t);
  }
};
o(e, "byteSize", 32), o(e, "platform", c);
let a = e;
f(c, a);
export {
  a as A,
  c as _,
  v as a,
  s as b,
  x as c,
  h as i
};
