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

import { h as helper } from '../../../chunks/helper.js';
import _typeof from '@babel/runtime/helpers/typeof';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import isString from 'lodash/isString';
import isObject from 'lodash/isObject';
import { renderLNodeJSX } from '../../../utils/render-node.js';
import { Button } from '../../button/index.js';
import '../../../chunks/_commonjsHelpers.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../button/button.js';
import '@ldesign/icons-vue';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../loading/icon/gradient.js';
import '../../../chunks/defineProperty-28395935.js';
import '../../../chunks/set-style.js';
import '../../../chunks/helper2.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';
import '../../../config.js';
import '../../../utils/dom.js';
import 'raf';
import '../../../utils/easing.js';
import '../../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import 'lodash';
import '../../config-provider/context.js';
import '../../../chunks/zh_CN.js';
import '../../config-provider/type.js';
import '../../../utils/mixins.js';
import '../../../utils/with-install.js';
import '../../loading/style';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../button/props.js';
import '../../../utils/ripple.js';
import '../../button/style';
import '../../button/type.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var ActionMixin = Vue.extend({
  components: {
    LButton: Button
  },
  methods: {
    getConfirmBtn: function getConfirmBtn(options) {
      var h = this.$createElement;
      var confirmBtn = options.confirmBtn,
          className = options.className;
      if (confirmBtn === null) return null;

      if (confirmBtn && this.$scopedSlots.confirmBtn) {
        console.warn("Both $props.confirmBtn and $scopedSlots.confirmBtn exist, $props.confirmBtn is preferred.");
      }

      var defaultButtonProps = this.getDefaultConfirmBtnProps(options);

      if (!confirmBtn && !this.$scopedSlots.confirmBtn) {
        return h("l-button", helper([{
          "class": className
        }, {
          "props": _objectSpread({}, defaultButtonProps)
        }]));
      }

      if (confirmBtn && ["string", "object"].includes(_typeof(confirmBtn))) {
        return this.getButtonByProps(confirmBtn, defaultButtonProps, className);
      }

      return renderLNodeJSX(this, "confirmBtn");
    },
    getCancelBtn: function getCancelBtn(options) {
      var h = this.$createElement;
      var cancelBtn = options.cancelBtn,
          className = options.className;
      if (cancelBtn === null) return null;

      if (cancelBtn && this.$scopedSlots.cancelBtn) {
        console.warn("Both $props.cancelBtn and $scopedSlots.cancelBtn exist, $props.cancelBtn is preferred.");
      }

      var defaultButtonProps = this.getDefaultCancelBtnProps(options);

      if (!cancelBtn && !this.$scopedSlots.cancelBtn) {
        return h("l-button", helper([{
          "class": className
        }, {
          "props": _objectSpread({}, defaultButtonProps)
        }]));
      }

      if (cancelBtn && ["string", "object"].includes(_typeof(cancelBtn))) {
        return this.getButtonByProps(cancelBtn, defaultButtonProps);
      }

      return renderLNodeJSX(this, "cancelBtn");
    },
    getButtonByProps: function getButtonByProps(button, defaultButton, className) {
      var h = this.$createElement;
      var newOptions = defaultButton;

      if (isString(button)) {
        newOptions.content = button;
      } else if (isObject(button)) {
        newOptions = _objectSpread(_objectSpread({}, newOptions), button);
      }

      return h("l-button", helper([{
        "class": className
      }, {
        "props": newOptions
      }]));
    },
    confirmBtnAction: function confirmBtnAction(e) {},
    cancelBtnAction: function cancelBtnAction(e) {},
    getDefaultConfirmBtnProps: function getDefaultConfirmBtnProps(options) {
      var _this = this;

      var globalConfirm = options.globalConfirm,
          theme = options.theme,
          globalConfirmBtnTheme = options.globalConfirmBtnTheme;
      var defaultTheme = (globalConfirmBtnTheme === null || globalConfirmBtnTheme === void 0 ? void 0 : globalConfirmBtnTheme[theme]) || "primary";
      var props = {
        theme: defaultTheme,
        content: "\u786E\u5B9A",
        size: options.size,
        onClick: function onClick(e) {
          _this.confirmBtnAction(e);
        }
      };

      if (isString(globalConfirm)) {
        props.content = globalConfirm;
      } else if (isObject(globalConfirm)) {
        props = _objectSpread(_objectSpread({}, props), globalConfirm);
      }

      return props;
    },
    getDefaultCancelBtnProps: function getDefaultCancelBtnProps(options) {
      var _this2 = this;

      var globalCancel = options.globalCancel;
      var props = {
        theme: "default",
        content: "\u53D6\u6D88",
        size: options.size,
        onClick: function onClick(e) {
          _this2.cancelBtnAction(e);
        }
      };

      if (isString(globalCancel)) {
        props.content = globalCancel;
      } else if (isObject(globalCancel)) {
        props = _objectSpread(_objectSpread({}, props), globalCancel);
      }

      return props;
    }
  }
});

export { ActionMixin as default };
//# sourceMappingURL=action.js.map
