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

import { h as helper } from '../../_chunks/dep-29915b8e.js';
import { InfoCircleFilledIcon, ErrorCircleFilledIcon } from '@ldesign/icons-vue';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins, { getGlobalIconMixins } from '../config-provider/config-receiver.js';
import { Popup } from '../popup/index.js';
import { renderLNodeJSXDefault, renderContent, renderLNodeJSX } from '../../utils/render-node.js';
import { emitEvent } from '../../utils/event.js';
import ActionMixin from '../dialog/mixins/action.js';
import props from './props.js';
import 'vue';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../_chunks/dep-def4c2ce.js';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../_chunks/dep-cf772670.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../_chunks/dep-70c789e5.js';
import '../../_chunks/dep-5210251b.js';
import '../../utils/easing.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../popup/props.js';
import '../popup/container.js';
import 'lodash/isObject';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-eb467ddf.js';
import '../../_chunks/dep-47d77fc8.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';

var _Popconfirm = mixins(ActionMixin, getConfigReceiverMixins("popconfirm"), getGlobalIconMixins()).extend({
  name: "LPopconfirm",
  props: {
    ...props
  },
  components: {
    LPopup: Popup
  },
  model: {
    prop: "visible",
    event: "visible-change"
  },
  computed: {
    themeIcon() {
      const {
        InfoCircleFilledIcon: InfoCircleFilledIcon$1,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon$1
      } = this.useGlobalIcon({
        InfoCircleFilledIcon: InfoCircleFilledIcon,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon
      });
      const iconMap = {
        default: InfoCircleFilledIcon$1,
        warning: ErrorCircleFilledIcon$1,
        danger: ErrorCircleFilledIcon$1
      };
      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) {
      emitEvent(this, "cancel", {
        e
      });
      const cancelContext = {
        e,
        trigger: "cancel"
      };
      emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction(e) {
      emitEvent(this, "confirm", {
        e
      });
      const confirmContext = {
        e,
        trigger: "confirm"
      };
      emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon() {
      const h = this.$createElement;
      const LIcon = this.themeIcon;
      return 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 = 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([{
      "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`
    }, [renderLNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": `${this.componentName}__buttons`
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

export { _Popconfirm as default };
//# sourceMappingURL=popconfirm.js.map
