"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const _Stack = require("./_Stack2.cjs");
const _arrayEach = require("./_arrayEach2.cjs");
const _assignValue = require("./_assignValue2.cjs");
const _baseAssign = require("./_baseAssign2.cjs");
const _baseAssignIn = require("./_baseAssignIn2.cjs");
const _cloneBuffer = require("./_cloneBuffer2.cjs");
const _copyArray = require("./_copyArray2.cjs");
const _copySymbols = require("./_copySymbols2.cjs");
const _copySymbolsIn = require("./_copySymbolsIn2.cjs");
const _getAllKeys = require("./_getAllKeys2.cjs");
const _getTag = require("./_getTag2.cjs");
const _initCloneArray = require("./_initCloneArray2.cjs");
const _initCloneByTag = require("./_initCloneByTag2.cjs");
const _initCloneObject = require("./_initCloneObject2.cjs");
const isArray = require("./isArray2.cjs");
const isBuffer = require("./isBuffer2.cjs");
const isMap = require("./isMap2.cjs");
const isObject = require("./isObject2.cjs");
const isSet = require("./isSet2.cjs");
var CLONE_FLAT_FLAG = 2;
var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
function baseClone(value, bitmask, customizer, key, object, stack) {
  var result, isFlat = bitmask & CLONE_FLAT_FLAG;
  if (result !== void 0) {
    return result;
  }
  if (!isObject.default(value)) {
    return value;
  }
  var isArr = isArray.default(value);
  if (isArr) {
    result = _initCloneArray.default(value);
    {
      return _copyArray.default(value, result);
    }
  } else {
    var tag = _getTag.default(value), isFunc = tag == funcTag || tag == genTag;
    if (isBuffer.default(value)) {
      return _cloneBuffer.default(value);
    }
    if (tag == objectTag || tag == argsTag || isFunc && !object) {
      result = isFunc ? {} : _initCloneObject.default(value);
      {
        return isFlat ? _copySymbolsIn.default(value, _baseAssignIn.default(result, value)) : _copySymbols.default(value, _baseAssign.default(result, value));
      }
    } else {
      if (!cloneableTags[tag]) {
        return object ? value : {};
      }
      result = _initCloneByTag.default(value, tag);
    }
  }
  stack || (stack = new _Stack.default());
  var stacked = stack.get(value);
  if (stacked) {
    return stacked;
  }
  stack.set(value, result);
  if (isSet.default(value)) {
    value.forEach(function(subValue) {
      result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
    });
  } else if (isMap.default(value)) {
    value.forEach(function(subValue, key2) {
      result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
    });
  }
  var keysFunc = _getAllKeys.default;
  var props = isArr ? void 0 : keysFunc(value);
  _arrayEach.default(props || value, function(subValue, key2) {
    if (props) {
      key2 = subValue;
      subValue = value[key2];
    }
    _assignValue.default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
  });
  return result;
}
exports.default = baseClone;
//# sourceMappingURL=_baseClone2.cjs.map
