'use strict';

(({ App }) => {
  const LENGTH_KEY = '__length__';

  App.Inspector.utils.getTreeProps = ({ maxLength = 100 } = {}) => ({
    maxLength,

    keysFilter({ keys, isArray, isObject }) {
      return keys.filter((key, index) => !(isObject && key === LENGTH_KEY));
    },

    lengthResolver({ keys, value, isArray, isObject }) {
      if (keys.length > maxLength) {
        return isObject ? value[LENGTH_KEY] : isArray ? value[keys.length - 1] : keys.length;
      }

      return keys.length;
    },
  });
})(window);
