# @ts-check

import clone_getType from './getType'
import clone_isArray from './isArray'
import clone_isObject from './isObject'
import clone_slice from './slice'

###* @type {import('./clone').Clone} ###
export default (ipt) ->

  if clone_isArray ipt then return clone_slice ipt

  if clone_isObject ipt
    ###* @type typeof ipt ###
    clone_mapNew = {}
    for clone_key, clone_value of ipt
      clone_mapNew[clone_key] = clone_value
    return clone_mapNew

  throw new Error "clone: invalid type '#{clone_getType ipt}'"