'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var is = require('../../_util/is.js');
var warning = require('../../vc-util/warning.js');

function useSearchConfig(showSearch) {
  const mergedShowSearch = vue.shallowRef(false);
  const mergedSearchConfig = vue.ref({});
  vue.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 (is.isNumber(searchConfig.limit) && searchConfig.limit <= 0) {
      delete searchConfig.limit;
      if (process.env.NODE_ENV !== "production")
        warning.warning(false, "'limit' of showSearch should be positive number or false.");
    }
    mergedShowSearch.value = true;
    mergedSearchConfig.value = searchConfig;
  });
  return { showSearch: mergedShowSearch, searchConfig: mergedSearchConfig };
}

exports.default = useSearchConfig;
//# sourceMappingURL=useSearchConfig.js.map
