/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var helper = require('../../../chunks/helper.js');
var Vue = require('vue');
var isString = require('lodash/isString');
var isObject = require('lodash/isObject');
var utils_renderNode = require('../../../utils/render-node.js');
var components_button_index = require('../../button/index.js');
require('lodash');
require('../../../utils/with-install.js');
require('../../../config.js');
require('../../button/button.js');
require('@ldesign/icons-vue');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../../utils/dom.js');
require('raf');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/easing.js');
require('../../../utils/transfer-dom.js');
require('../../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../config-provider/context.js');
require('../../../chunks/zh_CN.js');
require('../../../utils/mixins.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('../../loading/plugin.js');
require('../../../utils/ripple.js');
require('../../button/props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);

var ActionMixin = Vue__default["default"].extend({
  methods: {
    getConfirmBtn(options) {
      const h = this.$createElement;
      const {
        confirmBtn,
        className
      } = options;
      if (confirmBtn === null) return null;
      if (confirmBtn && this.$scopedSlots.confirmBtn) console.warn("Both $props.confirmBtn and $scopedSlots.confirmBtn exist, $props.confirmBtn is preferred.");
      const defaultButtonProps = this.getDefaultConfirmBtnProps(options);
      if (!confirmBtn && !this.$scopedSlots.confirmBtn) return h(components_button_index.Button, helper.helper([{
        "class": className
      }, {
        "props": {
          ...defaultButtonProps
        }
      }]));
      if (confirmBtn && ["string", "object"].includes(typeof confirmBtn)) return this.getButtonByProps(confirmBtn, defaultButtonProps, className);
      return utils_renderNode.renderLNodeJSX(this, "confirmBtn");
    },
    getCancelBtn(options) {
      const h = this.$createElement;
      const {
        cancelBtn,
        className
      } = options;
      if (cancelBtn === null) return null;
      if (cancelBtn && this.$scopedSlots.cancelBtn) console.warn("Both $props.cancelBtn and $scopedSlots.cancelBtn exist, $props.cancelBtn is preferred.");
      const defaultButtonProps = this.getDefaultCancelBtnProps(options);
      if (!cancelBtn && !this.$scopedSlots.cancelBtn) return h(components_button_index.Button, helper.helper([{
        "class": className
      }, {
        "props": {
          ...defaultButtonProps
        }
      }]));
      if (cancelBtn && ["string", "object"].includes(typeof cancelBtn)) return this.getButtonByProps(cancelBtn, defaultButtonProps);
      return utils_renderNode.renderLNodeJSX(this, "cancelBtn");
    },
    getButtonByProps(button, defaultButton, className) {
      const h = this.$createElement;
      let newOptions = defaultButton;
      if (isString__default["default"](button)) newOptions.content = button;else if (isObject__default["default"](button)) newOptions = {
        ...newOptions,
        ...button
      };
      return h(components_button_index.Button, helper.helper([{
        "class": className
      }, {
        "props": newOptions
      }]));
    },
    confirmBtnAction(e) {},
    cancelBtnAction(e) {},
    getDefaultConfirmBtnProps(options) {
      const {
        globalConfirm,
        theme,
        globalConfirmBtnTheme
      } = options;
      const defaultTheme = (globalConfirmBtnTheme === null || globalConfirmBtnTheme === void 0 ? void 0 : globalConfirmBtnTheme[theme]) || "primary";
      let props = {
        theme: defaultTheme,
        content: "\u786E\u5B9A",
        size: options.size,
        onClick: e => {
          this.confirmBtnAction(e);
        }
      };
      if (isString__default["default"](globalConfirm)) props.content = globalConfirm;else if (isObject__default["default"](globalConfirm)) props = {
        ...props,
        ...globalConfirm
      };
      return props;
    },
    getDefaultCancelBtnProps(options) {
      const {
        globalCancel
      } = options;
      let props = {
        theme: "default",
        content: "\u53D6\u6D88",
        size: options.size,
        onClick: e => {
          this.cancelBtnAction(e);
        }
      };
      if (isString__default["default"](globalCancel)) props.content = globalCancel;else if (isObject__default["default"](globalCancel)) props = {
        ...props,
        ...globalCancel
      };
      return props;
    }
  }
});

exports["default"] = ActionMixin;
//# sourceMappingURL=action.js.map
