'use strict';

var types_generic_withFrom = require('./with-from.cjs');
require('bs58');
require('crypto');
var utils_inheritance = require('../../utils/inheritance.cjs');
var utils_encoding_base58Btc = require('../../utils/encoding/base-58-btc.cjs');
require('../../utils/encoding/ss-58.cjs');
require('../../utils/types/object.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/set.cjs');
require('multiformats/bases/base58');
require('varint');
require('../../utils/types/string.cjs');
require('../../utils/types/bytes.cjs');
require('../../utils/interfaces.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');
require('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(utils_encoding_base58Btc.decodeFromBase58btc(str));
      }

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

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

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

module.exports = withBase58btc;
//# sourceMappingURL=with-base58btc.cjs.map
