function makeSameType(_a, _b) {
  return true;
}
export const shallowEqual = (objA, objB) => {
  if (objA === objB) {
    return true;
  }
  if (objA == null || objB == null) {
    return false;
  }
  const keysA = Object.keys(objA);
  const keysB = Object.keys(objB);
  if (keysA.length !== keysB.length) {
    return false;
  }
  const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
  for (let idx = 0; idx < keysA.length; idx++) {
    const key = keysA[idx];
    if (!bHasOwnProperty(key)) {
      return false;
    }
    if (objA[key] !== objB[key]) {
      return false;
    }
  }
  return true;
};
export const compareArrays = (left, right, compareFn = shallowEqual) => {
  if (left.length !== right.length) {
    return false;
  }
  for (let idx = 0; idx < left.length; idx++) {
    if (!compareFn(left[idx], right[idx])) {
      return false;
    }
  }
  return true;
};
const compareItemWithKeys = (leftItem, rightItem, excludedKeys = []) => Object.keys(leftItem).filter(key => excludedKeys.indexOf(key) === -1).every(key => leftItem[key] instanceof Object ? shallowEqual(leftItem[key], rightItem[key]) : leftItem[key] === rightItem[key]);
export const isSameItem = (leftItem, rightItem) => {
  if (leftItem.type !== rightItem.type) {
    return false;
  }
  switch (leftItem.type) {
    case 'button':
      // Need to typecast `rightItem as typeof leftItem` otherwise we will
      // have to put the `type !==` inside each case.
      return compareItemWithKeys(leftItem, rightItem, ['type', 'onClick', 'onMouseEnter', 'onMouseLeave']);
    case 'copy-button':
      return compareItemWithKeys(leftItem, rightItem, ['type', 'items']);
    case 'input':
      return compareItemWithKeys(leftItem, rightItem, ['type', 'onSubmit', 'onBlur']);
    case 'select':
      if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) && !compareArrays(leftItem.options, rightItem.options, (left, right) => compareItemWithKeys(left, right))) {
        return false;
      }
      return compareItemWithKeys(leftItem, rightItem, ['type', 'onChange', 'options']);
    case 'dropdown':
      if (makeSameType(leftItem, rightItem) && Array.isArray(leftItem.options) && Array.isArray(rightItem.options) &&
      // @ts-expect-error TS2345: Argument of type 'DropdownOptionT<Function>[]' is not assignable to parameter of type 'any[][]'
      !compareArrays(leftItem.options, rightItem.options, (left, right) =>
      // @ts-expect-error  TS2322: Type '"onClick"' is not assignable to type 'keyof any[]'
      compareItemWithKeys(left, right, ['onClick']))) {
        return false;
      }
      return compareItemWithKeys(leftItem, rightItem, ['type', 'options']);
    case 'custom':
      return false;
    case 'separator':
      return compareItemWithKeys(leftItem, rightItem);
    case 'extensions-placeholder':
      return compareItemWithKeys(leftItem, rightItem);
  }
};
export const areSameItems = (leftArr, rightArr) => {
  if (leftArr === undefined && rightArr === undefined) {
    return true;
  }
  if (leftArr === undefined || rightArr === undefined) {
    return false;
  }
  if (leftArr.length !== rightArr.length) {
    return false;
  }
  return leftArr.every((item, index) => isSameItem(rightArr[index], item));
};
export { default as messages } from './messages';