"use strict"
var __createBinding =
  (this && this.__createBinding) ||
  (Object.create
    ? function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        Object.defineProperty(o, k2, {
          enumerable: true,
          get: function () {
            return m[k]
          }
        })
      }
    : function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        o[k2] = m[k]
      })
var __setModuleDefault =
  (this && this.__setModuleDefault) ||
  (Object.create
    ? function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v })
      }
    : function (o, v) {
        o["default"] = v
      })
var __importStar =
  (this && this.__importStar) ||
  function (mod) {
    if (mod && mod.__esModule) return mod
    var result = {}
    if (mod != null)
      for (var k in mod)
        if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
          __createBinding(result, mod, k)
    __setModuleDefault(result, mod)
    return result
  }
Object.defineProperty(exports, "__esModule", { value: true })
exports.reduceWithIndex_ =
  exports.reduceWithIndex =
  exports.reduceRightWithIndex_ =
  exports.reduceRightWithIndex =
  exports.reduceRight_ =
  exports.reduceRight =
  exports.reduce_ =
  exports.reduce =
  exports.mapWithIndex_ =
  exports.mapWithIndex =
  exports.map_ =
  exports.map =
  exports.flatten =
  exports.extend_ =
  exports.extend =
  exports.duplicate =
  exports.tap_ =
  exports.tap =
  exports.chain_ =
  exports.chain =
  exports.ap_ =
  exports.ap =
  exports.unzip =
  exports.zip =
  exports.zip_ =
  exports.zipWith =
  exports.zipWith_ =
  exports.concat =
  exports.concat_ =
  exports.single =
  exports.filterWithIndex_ =
  exports.filterWithIndex =
  exports.filter_ =
  exports.filter =
  exports.modifyAt_ =
  exports.modifyAt =
  exports.updateAt_ =
  exports.updateAt =
  exports.insertAt_ =
  exports.insertAt =
  exports.init =
  exports.last =
  exports.reverse =
  exports.tail =
  exports.head =
  exports.fromArray =
  exports.snoc =
  exports.snoc_ =
  exports.cons =
  exports.cons_ =
    void 0
exports.make = void 0
// tracing: off
/* adapted from https://github.com/gcanti/fp-ts */
/**
 * Data structure which represents non-empty arrays
 */
require("../../../Operator")
const Option_1 = require("../../../Option")
const A = __importStar(require("../Array"))
/**
 * Append an element to the front of an array, creating a new non empty array
 *
 * @example
 * assert.deepStrictEqual(cons(1, [2, 3, 4]), [1, 2, 3, 4])
 */
exports.cons_ = A.cons_
/**
 * Append an element to the front of an array, creating a new non empty array
 */
exports.cons = A.cons
/**
 * Append an element to the end of an array, creating a new non empty array
 *
 * @example
 * assert.deepStrictEqual(snoc([1, 2, 3], 4), [1, 2, 3, 4])
 */
exports.snoc_ = A.snoc_
/**
 * Append an element to the end of an array, creating a new non empty array
 */
exports.snoc = A.snoc
/**
 * Builds a `ReadonlyNonEmptyArray` from an array returning `none` if `as` is an empty array
 */
function fromArray(as) {
  return A.isNonEmpty(as) ? (0, Option_1.some)(as) : Option_1.none
}
exports.fromArray = fromArray
/**
 * Takes the first element
 */
function head(nea) {
  return nea[0]
}
exports.head = head
/**
 * Takes the last element
 */
function tail(nea) {
  return nea.slice(1)
}
exports.tail = tail
/**
 * Reverse the array
 */
exports.reverse = A.reverse
/**
 * Takes the last element
 */
function last(nea) {
  return nea[nea.length - 1]
}
exports.last = last
/**
 * Get all but the last element of a non empty array, creating a new array.
 *
 * @example
 * assert.deepStrictEqual(init([1, 2, 3]), [1, 2])
 * assert.deepStrictEqual(init([1]), [])
 */
function init(nea) {
  return nea.slice(0, -1)
}
exports.init = init
/**
 * Insert an element at the specified index, creating a new array,
 * or returning None if the index is out of bounds
 */
function insertAt(i, a) {
  return A.insertAt(i, a)
}
exports.insertAt = insertAt
/**
 * Insert an element at the specified index, creating a new array,
 * or returning None if the index is out of bounds
 */
function insertAt_(nea, i, a) {
  return A.insertAt_(nea, i, a)
}
exports.insertAt_ = insertAt_
/**
 * Change the element at the specified index,
 * creating a new array, or returning None if the index is out of bounds
 */
function updateAt(i, a) {
  return A.updateAt(i, a)
}
exports.updateAt = updateAt
/**
 * Change the element at the specified index,
 * creating a new array, or returning None if the index is out of bounds
 */
function updateAt_(nea, i, a) {
  return A.updateAt_(nea, i, a)
}
exports.updateAt_ = updateAt_
/**
 * Apply a function to the element at the specified index,
 * creating a new array, or returning None if the index is out of bounds
 */
function modifyAt(i, f) {
  return A.modifyAt(i, f)
}
exports.modifyAt = modifyAt
/**
 * Apply a function to the element at the specified index,
 * creating a new array, or returning None if the index is out of bounds
 */
function modifyAt_(nea, i, f) {
  return A.modifyAt_(nea, i, f)
}
exports.modifyAt_ = modifyAt_
function filter(predicate) {
  return (nea) => filter_(nea, predicate)
}
exports.filter = filter
function filter_(nea, predicate) {
  return fromArray(A.filter_(nea, predicate))
}
exports.filter_ = filter_
/**
 * Filters the array also passing element index
 */
function filterWithIndex(predicate) {
  return (nea) => fromArray(nea.filter((a, i) => predicate(i, a)))
}
exports.filterWithIndex = filterWithIndex
/**
 * Filters the array also passing element index
 */
function filterWithIndex_(nea, predicate) {
  return fromArray(nea.filter((a, i) => predicate(i, a)))
}
exports.filterWithIndex_ = filterWithIndex_
/**
 * Construct an array with a single element
 */
exports.single = A.single
function concat_(fx, fy) {
  return fx.concat(fy)
}
exports.concat_ = concat_
function concat(fy) {
  return (fx) => fx.concat(fy)
}
exports.concat = concat
/**
 * Apply a function to pairs of elements at the same index in two arrays,
 * collecting the results in a new array. If one input array is short, excess
 * elements of the longer array are discarded.
 */
exports.zipWith_ = A.zipWith_
/**
 * Apply a function to pairs of elements at the same index in two arrays,
 * collecting the results in a new array. If one input array is short, excess
 * elements of the longer array are discarded.
 */
exports.zipWith = A.zipWith
/**
 * Takes two arrays and returns an array of corresponding pairs.
 * If one input array is short, excess elements of the longer array are discarded
 */
exports.zip_ = A.zip_
/**
 * Takes two arrays and returns an array of corresponding pairs.
 * If one input array is short, excess elements of the longer array are discarded
 */
exports.zip = A.zip
/**
 * The function is reverse of zip. Takes an array of pairs
 * and return two corresponding arrays
 */
exports.unzip = A.unzip
/**
 * Classic Applicative's ap
 */
exports.ap = A.ap
/**
 * Classic Applicative's ap
 */
exports.ap_ = A.ap_
/**
 * Composes computations in sequence, using the return value
 * of one computation to determine the next computation.
 */
exports.chain = A.chain
/**
 * Composes computations in sequence, using the return value
 * of one computation to determine the next computation.
 */
exports.chain_ = A.chain_
/**
 * Like chain but ignores output
 */
exports.tap = A.tap
/**
 * Like chain but ignores output
 */
exports.tap_ = A.tap_
/**
 * Array[A] => Array[Array[A]]
 */
exports.duplicate = A.duplicate
/**
 * Extends calls f with all the progressive slices up to the current
 * element's index, and uses the return value to construct the result array
 *
 * i.e: like map that also consumes all the elements up to `i`
 */
exports.extend = A.extend
/**
 * Extends calls f with all the progressive slices up to the current
 * element's index, and uses the return value to construct the result array
 *
 * i.e: like map that also consumes all the elements up to `i`
 */
exports.extend_ = A.extend_
/**
 * Removes one level of nesting
 */
exports.flatten = A.flatten
/**
 * Apply f to every element of Array returning Array
 */
exports.map = A.map
/**
 * Apply f to every element of Array returning Array
 */
exports.map_ = A.map_
/**
 * Like map but also passes the index to f
 */
exports.mapWithIndex = A.mapWithIndex
/**
 * Like map but also passes the index to f
 */
exports.mapWithIndex_ = A.mapWithIndex_
/**
 * Construct B by compacting with f over the array from left to right
 */
exports.reduce = A.reduce
/**
 * Construct B by compacting with f over the array from left to right
 */
exports.reduce_ = A.reduce_
/**
 * Construct B by compacting with f over the array from right to left
 */
exports.reduceRight = A.reduceRight
/**
 * Construct B by compacting with f over the array from right to left
 */
exports.reduceRight_ = A.reduceRight_
/**
 * Construct B by compacting with f over the array from right to left
 */
exports.reduceRightWithIndex = A.reduceRightWithIndex
/**
 * Construct B by compacting with f over the array from right to left
 */
exports.reduceRightWithIndex_ = A.reduceRightWithIndex_
/**
 * Construct B by compacting with f over the array from left to right
 */
exports.reduceWithIndex = A.reduceWithIndex
/**
 * Construct B by compacting with f over the array from left to right
 */
exports.reduceWithIndex_ = A.reduceWithIndex_
/**
 * Constructs a NonEmptyArray
 */
function make(arr) {
  return arr
}
exports.make = make
//# sourceMappingURL=index.js.map
