import * as C from "@effect-ts/core/Collections/Immutable/Chunk";
import * as NA from "@effect-ts/core/Collections/Immutable/NonEmptyArray";
import * as E from "@effect-ts/core/Either";
import { pipe } from "@effect-ts/core/Function";
import { makeEqual } from "@effect-ts/system/Equal";
import { FigHeaderError } from "../../FigletException/index.mjs";
export const FullWidth = {
  _tag: "FullWidth",
  value: -1
};
export const HorizontalFitting = {
  _tag: "HorizontalFitting",
  value: 0
};
export const EqualCharacterSmushing = {
  _tag: "EqualCharacterSmushing",
  value: 1
};
export const UnderscoreSmushing = {
  _tag: "UnderscoreSmushing",
  value: 2
};
export const HierarchySmushing = {
  _tag: "HierarchySmushing",
  value: 4
};
export const OppositePairSmushing = {
  _tag: "OppositePairSmushing",
  value: 8
};
export const BigXSmushing = {
  _tag: "BigXSmushing",
  value: 16
};
export const HardblankSmushing = {
  _tag: "HardblankSmushing",
  value: 32
};
export const values = /*#__PURE__*/C.from([FullWidth, HorizontalFitting, EqualCharacterSmushing, UnderscoreSmushing, HierarchySmushing, OppositePairSmushing, BigXSmushing, HardblankSmushing]); // -----------------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------------

/**
 * Obtains the list of requested settings starting from the provided value.
 *
 * @param requestedSettings The number representing the `OldLayout`.
 * @return The `OldLayout` that corresponds to the given numeric value.
 */

export function fromValue(requestedSettings) {
  if (requestedSettings < -1 || requestedSettings > 63) {
    return E.left(NA.single(new FigHeaderError({
      message: `OldLayout needs a value between 1 and 63, inclusive, received "${requestedSettings}"`
    })));
  }

  if (requestedSettings === -1) {
    return E.right(C.single(FullWidth));
  }

  if (requestedSettings === 0) {
    return E.right(C.single(HorizontalFitting));
  }

  const result = C.chain_(C.filter_(values, setting => setting.value !== 0), setting => (requestedSettings & setting.value) === setting.value ? C.single(setting) : C.empty());
  return E.right(result);
} // -----------------------------------------------------------------------------
// Instances
// -----------------------------------------------------------------------------

export const equalOldLayout = /*#__PURE__*/makeEqual((x, y) => x._tag === y._tag && x.value === y.value);
//# sourceMappingURL=index.mjs.map