/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-42d5c87e.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { InfoCircleFilledIcon, ErrorCircleFilledIcon } from 'tdesign-icons-vue';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins from '../config-provider/config-receiver.js';
import { prefix } from '../config.js';
import { Popup } from '../popup/index.js';
import props from './props.js';
import { renderTNodeJSXDefault, renderContent, renderTNodeJSX } from '../utils/render-tnode.js';
import { emitEvent } from '../utils/event.js';
import ActionMixin from '../dialog/actions.js';
import 'vue';
import '../config-provider/zh_CN_config.js';
import '../config-provider/type.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../_chunks/dep-1db5c91c.js';
import '../utils/classnames.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../popup/props.js';
import '../utils/set-style.js';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../popup/type.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import 'lodash/isObject';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../button/props.js';
import '../utils/ripple.js';
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 name = "".concat(prefix, "-popconfirm");
var popupName = "".concat(prefix, "-popup");
var _Popconfirm = mixins(ActionMixin, getConfigReceiverMixins("popconfirm")).extend({
  name: "TPopconfirm",
  props: _objectSpread({}, props),
  model: {
    prop: "visible",
    event: "visible-change"
  },
  data: function data() {
    return {
      name: name,
      popupName: popupName
    };
  },
  computed: {
    themeIcon: function themeIcon() {
      var iconMap = {
        "default": InfoCircleFilledIcon,
        warning: ErrorCircleFilledIcon,
        danger: ErrorCircleFilledIcon
      };
      return iconMap[this.theme];
    },
    iconCls: function iconCls() {
      var theme = this.theme || "default";
      return "".concat(name, "__icon--").concat(theme);
    },
    innerPopupProps: function innerPopupProps() {
      return _objectSpread({
        showArrow: this.showArrow,
        overlayClassName: [name, "".concat(name, "__popup--").concat(this.theme || "default")],
        trigger: "click",
        destroyOnClose: this.destroyOnClose,
        placement: this.placement
      }, this.popupProps);
    }
  },
  methods: {
    cancelBtnAction: function cancelBtnAction(e) {
      emitEvent(this, "cancel", {
        e: e
      });
      var cancelContext = {
        e: e,
        trigger: "cancel"
      };
      emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction: function confirmBtnAction(e) {
      emitEvent(this, "confirm", {
        e: e
      });
      var confirmContext = {
        e: e,
        trigger: "confirm"
      };
      emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon: function renderIcon() {
      var h = this.$createElement;
      var Icon = this.themeIcon;
      return renderTNodeJSXDefault(this, "icon", h(Icon, {
        "class": this.iconCls
      }));
    },
    onPopupVisibleChange: function onPopupVisibleChange(val, context) {
      this.$emit("visible-change", val, context);
      this.onVisibleChange && this.onVisibleChange(val, context);
    }
  },
  render: function render() {
    var h = arguments[0];
    var triggerElement = renderContent(this, "default", "triggerElement");
    var cancelBtn = this.getCancelBtn({
      cancelBtn: this.cancelBtn,
      globalCancel: this.global.cancel,
      className: "".concat(name, "__cancel")
    });
    var confirmBtn = this.getConfirmBtn({
      theme: this.theme,
      confirmBtn: this.confirmBtn,
      globalConfirm: this.global.confirm,
      globalConfirmBtnTheme: this.global.confirmBtnTheme,
      className: "".concat(name, "__confirm")
    });
    return h(Popup, helper([{
      "ref": "popup",
      "attrs": {
        "visible": this.visible
      }
    }, {
      "props": this.innerPopupProps
    }, {}, {
      "on": {
        "visible-change": this.onPopupVisibleChange
      }
    }]), [h("template", {
      "slot": "content",
      "attrs": {
        "role": "poppconfirm"
      }
    }, [h("div", {
      "class": "".concat(name, "__content")
    }, [h("div", {
      "class": "".concat(name, "__body")
    }, [this.renderIcon(), h("div", {
      "class": "".concat(name, "__inner")
    }, [renderTNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": "".concat(name, "__buttons")
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

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