/**
 * 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 iconsVue = require('@ldesign/icons-vue');
var utils_mixins = require('../../utils/mixins.js');
var components_configProvider_configReceiver = require('../config-provider/config-receiver.js');
var components_popup_index = require('../popup/index.js');
var utils_renderNode = require('../../utils/render-node.js');
var utils_event = require('../../utils/event.js');
var components_dialog_mixins_action = require('../dialog/mixins/action.js');
var components_popconfirm_props = require('./props.js');
require('vue');
require('lodash/mergeWith');
require('lodash');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/map-props.js');
require('../../utils/with-install.js');
require('../../config.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../popup/props.js');
require('../popup/container.js');
require('lodash/isObject');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');
require('../../utils/ripple.js');
require('../button/props.js');

var _Popconfirm = utils_mixins["default"](components_dialog_mixins_action["default"], components_configProvider_configReceiver["default"]("popconfirm"), components_configProvider_configReceiver.getGlobalIconMixins()).extend({
  name: "LPopconfirm",
  props: {
    ...components_popconfirm_props["default"]
  },
  components: {
    LPopup: components_popup_index.Popup
  },
  model: {
    prop: "visible",
    event: "visible-change"
  },
  computed: {
    themeIcon() {
      const {
        InfoCircleFilledIcon,
        ErrorCircleFilledIcon
      } = this.useGlobalIcon({
        InfoCircleFilledIcon: iconsVue.InfoCircleFilledIcon,
        ErrorCircleFilledIcon: iconsVue.ErrorCircleFilledIcon
      });
      const iconMap = {
        default: InfoCircleFilledIcon,
        warning: ErrorCircleFilledIcon,
        danger: ErrorCircleFilledIcon
      };
      return iconMap[this.theme];
    },
    iconCls() {
      const theme = this.theme || "default";
      return `${this.componentName}__icon--${theme}`;
    },
    innerPopupProps() {
      return {
        showArrow: this.showArrow,
        overlayClassName: [this.componentName, `${this.componentName}__popup--${this.theme || "default"}`],
        trigger: "click",
        destroyOnClose: this.destroyOnClose,
        placement: this.placement,
        ...this.popupProps
      };
    }
  },
  methods: {
    cancelBtnAction(e) {
      utils_event.emitEvent(this, "cancel", {
        e
      });
      const cancelContext = {
        e,
        trigger: "cancel"
      };
      utils_event.emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction(e) {
      utils_event.emitEvent(this, "confirm", {
        e
      });
      const confirmContext = {
        e,
        trigger: "confirm"
      };
      utils_event.emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon() {
      const h = this.$createElement;
      const LIcon = this.themeIcon;
      return utils_renderNode.renderLNodeJSXDefault(this, "icon", h(LIcon, {
        "class": this.iconCls
      }));
    },
    onPopupVisibleChange(val, context) {
      this.$emit("visible-change", val, context);
      this.onVisibleChange && this.onVisibleChange(val, context);
    }
  },
  render() {
    const h = arguments[0];
    const triggerElement = utils_renderNode.renderContent(this, "default", "triggerElement");
    const cancelBtn = this.getCancelBtn({
      cancelBtn: this.cancelBtn,
      globalCancel: this.global.cancel,
      size: "small",
      className: `${this.componentName}__cancel`
    });
    const confirmBtn = this.getConfirmBtn({
      theme: this.theme,
      confirmBtn: this.confirmBtn,
      globalConfirm: this.global.confirm,
      size: "small",
      globalConfirmBtnTheme: this.global.confirmBtnTheme,
      className: `${this.componentName}__confirm`
    });
    return h("l-popup", helper.helper([{
      "ref": "popup",
      "attrs": {
        "visible": this.visible
      }
    }, {
      "props": this.innerPopupProps
    }, {}, {
      "on": {
        "visible-change": this.onPopupVisibleChange
      }
    }]), [h("template", {
      "slot": "content",
      "attrs": {
        "role": "popconfirm"
      }
    }, [h("div", {
      "class": `${this.componentName}__content`
    }, [h("div", {
      "class": `${this.componentName}__body`
    }, [this.renderIcon(), h("div", {
      "class": `${this.componentName}__inner`
    }, [utils_renderNode.renderLNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": `${this.componentName}__buttons`
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

exports["default"] = _Popconfirm;
//# sourceMappingURL=popconfirm.js.map
