"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.equalPrintDirection = exports.RightToLeft = exports.LeftToRight = void 0;
exports.fromHeader = fromHeader;
exports.fromValue = fromValue;
exports.values = void 0;

var C = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Collections/Immutable/Chunk"));

var NA = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Collections/Immutable/NonEmptyArray"));

var E = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Either"));

var Eq = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Equal"));

var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Option"));

var Structural = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect-ts/core/Structural"));

var _index = /*#__PURE__*/require("../../FigletException/index.js");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

// -----------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------
const LeftToRight = {
  _tag: "LeftToRight",
  value: 0
};
exports.LeftToRight = LeftToRight;
const RightToLeft = {
  _tag: "RightToLeft",
  value: 1
};
exports.RightToLeft = RightToLeft;
const values = /*#__PURE__*/C.from([LeftToRight, RightToLeft]);
/**
 * Obtains the printing direction starting from the provided value.
 *
 * @param value The number representing the `PrintDirection`.
 * @returns The `PrintDirection` that corresponds to the given numeric value.
 */

exports.values = values;

function fromValue(value) {
  if (value === 0) {
    return E.right(LeftToRight);
  } else if (value === 1) {
    return E.right(RightToLeft);
  } else {
    return E.left(NA.single(new _index.FigHeaderError({
      message: `Could not parse value "${value}" to a PrintDirection`
    })));
  }
}
/**
 * Interprets the header settings and returns the selected `PrintDirection`.
 *
 * @param header The `FigHeader` where the print direction is defined.
 * @returns A `FigletResult` containing the `PrintDirection`.
 */


function fromHeader(header) {
  return O.fold_(header.printDirection, () => E.right(LeftToRight), E.right);
} // -----------------------------------------------------------------------------
// Instances
// -----------------------------------------------------------------------------


const equalPrintDirection = /*#__PURE__*/Eq.makeEqual(Structural.equals);
exports.equalPrintDirection = equalPrintDirection;
//# sourceMappingURL=index.js.map