"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

function _bytebuffer() {
  const data = _interopRequireDefault(require("bytebuffer"));

  _bytebuffer = function _bytebuffer() {
    return data;
  };

  return data;
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

const aobIssuer = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator(function* (asset) {
    // const bb = new ByteBuffer()
    // bb.writeString(asset.name)
    // bb.writeString(asset.desc)
    // bb.flip()
    // return bb.toBuffer()
    const buffer = Buffer.concat([Buffer.from(asset.name, 'utf8'), Buffer.from(asset.desc || '', 'utf8')]);
    return buffer;
  });

  return function aobIssuer(_x) {
    return _ref.apply(this, arguments);
  };
}();

const aobAsset = /*#__PURE__*/function () {
  var _ref2 = _asyncToGenerator(function* (asset) {
    let buffer = Buffer.concat([Buffer.from(asset.name, 'utf8'), Buffer.from(asset.desc || '', 'utf8'), Buffer.from(asset.maximum, 'utf8'), Buffer.from([asset.precision || 0]), Buffer.from([asset.allow_writeoff || '0']), Buffer.from([asset.allow_whitelist || '0']), Buffer.from([asset.allow_blacklist || '0'])]);

    if (asset.strategy) {
      buffer = Buffer.concat([Buffer.from(asset.strategy, 'utf8')]);
    }

    return buffer;
  });

  return function aobAsset(_x2) {
    return _ref2.apply(this, arguments);
  };
}();

const aobFlags = /*#__PURE__*/function () {
  var _ref3 = _asyncToGenerator(function* (asset) {
    const buffer = Buffer.concat([Buffer.from(asset.currency, 'utf8'), Buffer.from([asset.flag || 0]), Buffer.from([asset.flag_type || '0'])]);
    return buffer;
  });

  return function aobFlags(_x3) {
    return _ref3.apply(this, arguments);
  };
}();

const aobAcl = /*#__PURE__*/function () {
  var _ref4 = _asyncToGenerator(function* (asset) {
    const bb = new (_bytebuffer().default)();
    bb.writeString(asset.currency);
    bb.writeString(asset.operator);
    bb.writeByte(asset.flag);

    if (asset.list) {
      bb.writeString(asset.list);
    }

    bb.flip();
    return bb.toBuffer();
  });

  return function aobAcl(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

const aobIssue = /*#__PURE__*/function () {
  var _ref5 = _asyncToGenerator(function* (asset) {
    const buffer = Buffer.concat([Buffer.from(asset.currency, 'utf8'), Buffer.from(asset.amount, 'utf8')]);
    return buffer;
  });

  return function aobIssue(_x5) {
    return _ref5.apply(this, arguments);
  };
}();

const aobTransfer = /*#__PURE__*/function () {
  var _ref6 = _asyncToGenerator(function* (asset) {
    const buffer = Buffer.concat([Buffer.from(asset.currency, 'utf8'), Buffer.from(asset.amount, 'utf8'), Buffer.from(asset.content || '', 'utf8')]);
    return buffer;
  });

  return function aobTransfer(_x6) {
    return _ref6.apply(this, arguments);
  };
}();

var _default = {
  aobIssuer,
  aobAsset,
  aobFlags,
  aobIssue,
  aobTransfer,
  aobAcl
};
exports.default = _default;