/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var helper = require('../_chunks/dep-33ee4bce.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var tdesignIconsVue = require('tdesign-icons-vue');
var utils_mixins = require('../utils/mixins.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var config = require('../config.js');
var popup_index = require('../popup/index.js');
var popconfirm_props = require('./props.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var utils_event = require('../utils/event.js');
var dialog_actions = require('../dialog/actions.js');
require('vue');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../popup/popup.js');
require('@babel/runtime/helpers/typeof');
require('@popperjs/core');
require('../utils/classnames.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/camelCase');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('../utils/map-props.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('lodash/isObject');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/helper.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/plugin.js');
require('../button/props.js');
require('../utils/ripple.js');

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

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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(config.prefix, "-popconfirm");
var popupName = "".concat(config.prefix, "-popup");
var _Popconfirm = utils_mixins["default"](dialog_actions["default"], configProvider_configReceiver["default"]("popconfirm")).extend({
  name: "TPopconfirm",
  props: _objectSpread({}, popconfirm_props["default"]),
  model: {
    prop: "visible",
    event: "visible-change"
  },
  data: function data() {
    return {
      name: name,
      popupName: popupName
    };
  },
  computed: {
    themeIcon: function themeIcon() {
      var iconMap = {
        "default": tdesignIconsVue.InfoCircleFilledIcon,
        warning: tdesignIconsVue.ErrorCircleFilledIcon,
        danger: tdesignIconsVue.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) {
      utils_event.emitEvent(this, "cancel", {
        e: e
      });
      var cancelContext = {
        e: e,
        trigger: "cancel"
      };
      utils_event.emitEvent(this, "visible-change", false, cancelContext);
    },
    confirmBtnAction: function confirmBtnAction(e) {
      utils_event.emitEvent(this, "confirm", {
        e: e
      });
      var confirmContext = {
        e: e,
        trigger: "confirm"
      };
      utils_event.emitEvent(this, "visible-change", false, confirmContext);
    },
    renderIcon: function renderIcon() {
      var h = this.$createElement;
      var Icon = this.themeIcon;
      return utils_renderTnode.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 = utils_renderTnode.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_index.Popup, helper.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")
    }, [utils_renderTnode.renderTNodeJSX(this, "content")])]), Boolean(cancelBtn || confirmBtn) && h("div", {
      "class": "".concat(name, "__buttons")
    }, [cancelBtn, confirmBtn])])]), triggerElement]);
  }
});

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