/**
 * ldesign v0.2.3
 * (c) 2022年9月24日 swimly
 * @license MIT
 */

import Vue from 'vue';
import { capitalize } from 'lodash';
import { PREFIX } from '../config.js';

function withInstall(comp, dep) {
  var _c$options, _Vue$_installedPlugin;

  const c = comp;
  const name = (c === null || c === void 0 ? void 0 : (_c$options = c.options) === null || _c$options === void 0 ? void 0 : _c$options.name) || c.name;

  c.install = (Vue2, config) => {
    const installConfig = {
      prefix: PREFIX,
      ...config
    };
    let componentName = name.replace("-mapprops", "").replace("L", "");
    componentName = capitalize(installConfig.prefix) + componentName;
    Vue2.component(componentName, comp);
  };

  if (dep && (Vue === null || Vue === void 0 ? void 0 : (_Vue$_installedPlugin = Vue._installedPlugins) === null || _Vue$_installedPlugin === void 0 ? void 0 : _Vue$_installedPlugin.indexOf(dep)) === -1) {
    Vue.use(dep);
  }

  return comp;
}

export { withInstall as default, withInstall };
//# sourceMappingURL=with-install.js.map
