import withFrom from './with-from.js';
import 'bs58';
import 'crypto';
import { withExtendedStaticProperties } from '../../utils/inheritance.js';
import { decodeFromBase58btc, encodeAsBase58btc } from '../../utils/encoding/base-58-btc.js';
import '../../utils/encoding/ss-58.js';
import '../../utils/types/object.js';
import '../../utils/types/iterable.js';
import '../../utils/types/set.js';
import 'multiformats/bases/base58';
import 'varint';
import '../../utils/types/string.js';
import '../../utils/types/bytes.js';
import '../../utils/interfaces.js';
import '../../utils/assert.js';
import '../../utils/error.js';
import 'blake2b';

function withBase58btc(klass) {
  const name = `withBase58btc(${klass.name})`;
  const obj = {
    [name]: class extends klass {
      // Define the static prefix as a class variable
      static Prefix;

      toString() {
        return this.toBase58btc();
      }

      toJSON() {
        return String(this);
      }

      get value() {
        return this.toBase58btc();
      }

      static fromBase58btc(str) {
        return this.from(decodeFromBase58btc(str));
      }

      toBase58btc() {
        const {
          constructor: { Prefix },
        } = this;

        return encodeAsBase58btc(Prefix, this.bytes);
      }
    },
  };

  return withExtendedStaticProperties(
    ['Prefix'],
    withFrom(obj[name], (value, from) => (typeof value === 'string' ? this.fromBase58btc(value) : from(value))),
  );
}

export { withBase58btc as default };
//# sourceMappingURL=with-base58btc.js.map
