text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.clone = void 0;
  const tslib_1 = require("tslib");
  const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
  const mapValues_1 = tslib_1.__importDefault(require("lodash/mapValues"));
  function clone(value, options) {
      if (Array.isArray(value)) {
          return cloneArray(value, options);
      }
      if (isObjectLike_1.default(value)) {
          return cloneObject(value, options);
      }
      if (typeof value === 'function') {
          throw new Error('Cannot clone a function');
      }
      return value;
  }
  exports.clone = clone;
  function cloneObject(object, options) {
      const objectCloner = options === null || options === void 0 ? void 0 : options.objectCloner;
      if (objectCloner !== undefined) {
          const clonedObject = objectCloner(object);
          if (clonedObject !== undefined) {
              return clonedObject;
          }
      }
      if (object instanceof Date) {
          return cloneDate(object);
      }
      if (object instanceof RegExp) {
          return cloneRegExp(object);
      }
      if (object instanceof Error) {
          return cloneError(object, options);
      }
      return cloneAttributes(object, options);
  }
  function cloneArray(array, options) {
      return array.map((item) => clone(item, options));
  }
  function cloneDate(date) {
      return new Date(date);
  }
  function cloneRegExp(regExp) {
      return new RegExp(regExp.source, regExp.flags);
  }
  function cloneError(error, options) {
      const clonedError = new Error(error.message);
      Object.assign(clonedError, cloneAttributes(error, options));
      return clonedError;
  }
  function cloneAttributes(object, options) {
      return mapValues_1.default(object, (value) => clone(value, options));
  }
  //# sourceMappingURL=cloning.js.map