import { shallowRef, ref, watchEffect } from 'vue';
import '../../../../utils/index.mjs';
import { isNumber } from 'lodash-es';
import { warning } from '../../../../utils/log.mjs';

function useSearchConfig(showSearch) {
  const mergedShowSearch = shallowRef(false);
  const mergedSearchConfig = ref({});
  watchEffect(() => {
    if (!showSearch.value) {
      mergedShowSearch.value = false;
      mergedSearchConfig.value = {};
      return;
    }
    let searchConfig = {
      matchInputWidth: true,
      limit: 50
    };
    if (showSearch.value && typeof showSearch.value === "object") {
      searchConfig = {
        ...searchConfig,
        ...showSearch.value
      };
    }
    if (isNumber(searchConfig.limit) && searchConfig.limit <= 0) {
      delete searchConfig.limit;
      if (process.env.NODE_ENV !== "production")
        warning(false, "'limit' of showSearch should be positive number or false.");
    }
    mergedShowSearch.value = true;
    mergedSearchConfig.value = searchConfig;
  });
  return { showSearch: mergedShowSearch, searchConfig: mergedSearchConfig };
}

export { useSearchConfig as default };
//# sourceMappingURL=useSearchConfig.mjs.map
