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

'use strict';

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

var utils_helper = require('./helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('@babel/runtime/helpers/defineProperty');
require('lodash/camelCase');

function emitEvent(vm, eventName) {
  var emitEventName;
  var emitEventMethodName;

  if (typeof eventName === "string") {
    emitEventName = eventName;
    emitEventMethodName = utils_helper.getPropsApiByEvent(eventName);
  } else {
    emitEventName = eventName.event;
    emitEventMethodName = eventName.method;
  }

  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
    args[_key - 2] = arguments[_key];
  }

  if (vm.$listeners["".concat(emitEventName)]) {
    vm.$emit.apply(vm, [emitEventName].concat(args));
  }

  if (typeof vm.$props[emitEventMethodName] === "function") {
    var _vm$$props;

    (_vm$$props = vm.$props)[emitEventMethodName].apply(_vm$$props, args);
  }
}

exports.emitEvent = emitEvent;
//# sourceMappingURL=event.js.map
