import _assignMergeValue from "./_assignMergeValue.js";
import "./_cloneBuffer.js";
import _cloneTypedArray from "./_cloneTypedArray.js";
import _copyArray from "./_copyArray.js";
import _initCloneObject from "./_initCloneObject.js";
import isArguments_1 from "./isArguments.js";
import isArray_1 from "./isArray.js";
import isArrayLikeObject_1 from "./isArrayLikeObject.js";
import "./isBuffer.js";
import isFunction_1 from "./isFunction.js";
import isObject_1 from "./isObject.js";
import isPlainObject_1 from "./isPlainObject.js";
import isTypedArray_1 from "./isTypedArray.js";
import _safeGet from "./_safeGet.js";
import toPlainObject_1 from "./toPlainObject.js";
import { _ as _cloneBuffer } from "../../../../../_virtual/_cloneBuffer.js";
import { i as isBuffer$1 } from "../../../../../_virtual/isBuffer.js";
var assignMergeValue = _assignMergeValue, cloneBuffer = _cloneBuffer.exports, cloneTypedArray = _cloneTypedArray, copyArray = _copyArray, initCloneObject = _initCloneObject, isArguments = isArguments_1, isArray = isArray_1, isArrayLikeObject = isArrayLikeObject_1, isBuffer = isBuffer$1.exports, isFunction = isFunction_1, isObject = isObject_1, isPlainObject = isPlainObject_1, isTypedArray = isTypedArray_1, safeGet = _safeGet, toPlainObject = toPlainObject_1;
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
  if (stacked) {
    assignMergeValue(object, key, stacked);
    return;
  }
  var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0;
  var isCommon = newValue === void 0;
  if (isCommon) {
    var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
    newValue = srcValue;
    if (isArr || isBuff || isTyped) {
      if (isArray(objValue)) {
        newValue = objValue;
      } else if (isArrayLikeObject(objValue)) {
        newValue = copyArray(objValue);
      } else if (isBuff) {
        isCommon = false;
        newValue = cloneBuffer(srcValue, true);
      } else if (isTyped) {
        isCommon = false;
        newValue = cloneTypedArray(srcValue, true);
      } else {
        newValue = [];
      }
    } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
      newValue = objValue;
      if (isArguments(objValue)) {
        newValue = toPlainObject(objValue);
      } else if (!isObject(objValue) || isFunction(objValue)) {
        newValue = initCloneObject(srcValue);
      }
    } else {
      isCommon = false;
    }
  }
  if (isCommon) {
    stack.set(srcValue, newValue);
    mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
    stack["delete"](srcValue);
  }
  assignMergeValue(object, key, newValue);
}
var _baseMergeDeep = baseMergeDeep;
export {
  _baseMergeDeep as default
};
//# sourceMappingURL=_baseMergeDeep.js.map
