/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-a4bd011a.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { InfoCircleFilledIcon, ErrorCircleFilledIcon } from 'tdesign-icons-vue';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins, { getGlobalIconMixins } from '../config-provider/config-receiver.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 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../popup/type.js';
import 'lodash/kebabCase';
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 '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../config.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 _Popconfirm = mixins(ActionMixin, getConfigReceiverMixins("popconfirm"), getGlobalIconMixins()).extend({
  name: "TPopconfirm",
  props: _objectSpread({}, props),
  model: {
    prop: "visible",
    event: "visible-change"
  },
  computed: {
    themeIcon: function themeIcon() {
      var _this$useGlobalIcon = this.useGlobalIcon({
        InfoCircleFilledIcon: InfoCircleFilledIcon,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon
      }),
          InfoCircleFilledIcon$1 = _this$useGlobalIcon.InfoCircleFilledIcon,
          ErrorCircleFilledIcon$1 = _this$useGlobalIcon.ErrorCircleFilledIcon;

      var iconMap = {
        "default": InfoCircleFilledIcon$1,
        warning: ErrorCircleFilledIcon$1,
        danger: ErrorCircleFilledIcon$1
      };
      return iconMap[this.theme];
    },
    iconCls: function iconCls() {
      var theme = this.theme || "default";
      return "".concat(this.componentName, "__icon--").concat(theme);
    },
    innerPopupProps: function innerPopupProps() {
      return _objectSpread({
        showArrow: this.showArrow,
        overlayClassName: [this.componentName, "".concat(this.componentName, "__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,
      size: "small",
      className: "".concat(this.componentName, "__cancel")
    });
    var confirmBtn = this.getConfirmBtn({
      theme: this.theme,
      confirmBtn: this.confirmBtn,
      globalConfirm: this.global.confirm,
      size: "small",
      globalConfirmBtnTheme: this.global.confirmBtnTheme,
      className: "".concat(this.componentName, "__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": "popconfirm"
      }
    }, [h("div", {
      "class": "".concat(this.componentName, "__content")
    }, [h("div", {
      "class": "".concat(this.componentName, "__body")
    }, [this.renderIcon(), h("div", {
      "class": "".concat(this.componentName, "__inner")
    }, [renderTNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": "".concat(this.componentName, "__buttons")
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

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