import { computed } from 'vue';
import { isPlainObject } from '../../_util/is';
import { isValidElement } from '../../_util/props-util';
export function isPlaceholderConfig(placeholder) {
  return isPlainObject(placeholder) && !isValidElement(placeholder);
}
export const usePlaceholderConfig = placeholder => {
  const placeholderConfig = computed(() => {
    if (!placeholder.value || !isPlaceholderConfig(placeholder.value)) {
      return {};
    }
    if (typeof placeholder.value.progress === 'boolean') {
      return {
        progressConfig: placeholder.value.progress ? {} : undefined
      };
    }
    return {
      progressConfig: placeholder.value.progress
    };
  });
  const showProgressOverlay = computed(() => placeholderConfig.value.progressConfig !== undefined);
  const placeholderNode = computed(() => isPlaceholderConfig(placeholder.value) ? undefined : placeholder.value);
  return {
    placeholderConfig,
    showProgressOverlay,
    placeholderNode
  };
};