/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var vue = require('vue');
var iconsVueNext = require('@ldesign/icons-vue-next');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../hooks/useGlobalIcon.js');
var popup_index = require('../popup/index.js');
var hooks_tnode = require('../hooks/tnode.js');
var hooks_useVModel = require('../hooks/useVModel.js');
var dialog_hooks = require('../dialog/hooks.js');
var popconfirm_props = require('./props.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('../utils/withInstall.js');
require('../popup/popup.js');
require('@popperjs/core');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isObject');
require('../utils/dom.js');
require('../_chunks/dep-f4db2590.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isUndefined');
require('../hooks/useResizeObserver.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('lodash/omit');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isNumber');
require('../hooks/useRipple.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../form/hooks.js');
require('../button/props.js');

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

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

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 _Popconfirm = vue.defineComponent({
  name: "TPopconfirm",
  props: popconfirm_props["default"],
  setup: function setup(props2) {
    var _useConfig = configProvider_useConfig.useConfig("popconfirm"),
      globalConfig = _useConfig.globalConfig;
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("popconfirm");
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        InfoCircleFilledIcon: iconsVueNext.InfoCircleFilledIcon,
        ErrorCircleFilledIcon: iconsVueNext.ErrorCircleFilledIcon
      }),
      InfoCircleFilledIcon = _useGlobalIcon.InfoCircleFilledIcon,
      ErrorCircleFilledIcon = _useGlobalIcon.ErrorCircleFilledIcon;
    var _toRefs = vue.toRefs(props2),
      visible = _toRefs.visible,
      modelValue = _toRefs.modelValue;
    var _useVModel = hooks_useVModel["default"](visible, modelValue, props2.defaultVisible, props2.onVisibleChange, "visible"),
      _useVModel2 = _slicedToArray__default["default"](_useVModel, 2),
      innerVisible = _useVModel2[0],
      setInnerVisible = _useVModel2[1];
    var confirmBtnAction = function confirmBtnAction(e) {
      var _props2$onConfirm;
      (_props2$onConfirm = props2.onConfirm) === null || _props2$onConfirm === void 0 ? void 0 : _props2$onConfirm.call(props2, {
        e: e
      });
      setInnerVisible(false, {
        e: e,
        trigger: "confirm"
      });
    };
    var cancelBtnAction = function cancelBtnAction(e) {
      var _props2$onCancel;
      (_props2$onCancel = props2.onCancel) === null || _props2$onCancel === void 0 ? void 0 : _props2$onCancel.call(props2, {
        e: e
      });
      setInnerVisible(false, {
        e: e,
        trigger: "cancel"
      });
    };
    var _useAction = dialog_hooks.useAction({
        confirmBtnAction: confirmBtnAction,
        cancelBtnAction: cancelBtnAction
      }),
      getConfirmBtn = _useAction.getConfirmBtn,
      getCancelBtn = _useAction.getCancelBtn;
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var innerPopupProps = vue.computed(function () {
      return _objectSpread({
        showArrow: props2.showArrow,
        overlayClassName: COMPONENT_NAME.value,
        trigger: "click",
        destroyOnClose: props2.destroyOnClose,
        placement: props2.placement
      }, props2.popupProps);
    });
    var renderTNodeDefault = hooks_tnode.useTNodeDefault();
    var renderContent = function renderContent() {
      var cancelBtn = getCancelBtn({
        cancelBtn: props2.cancelBtn,
        globalCancel: globalConfig.value.cancel,
        className: "".concat(COMPONENT_NAME.value, "__cancel"),
        size: "small"
      });
      var confirmBtn = getConfirmBtn({
        theme: props2.theme,
        confirmBtn: props2.confirmBtn,
        globalConfirm: globalConfig.value.confirm,
        globalConfirmBtnTheme: globalConfig.value.confirmBtnTheme,
        className: "".concat(COMPONENT_NAME.value, "__confirm"),
        size: "small"
      });
      var renderIcon = function renderIcon() {
        var Icon = {
          "default": InfoCircleFilledIcon,
          warning: ErrorCircleFilledIcon,
          danger: ErrorCircleFilledIcon
        }[props2.theme];
        var theme = props2.theme || "default";
        return renderTNodeDefault("icon", vue.createVNode(Icon, {
          "class": "".concat(COMPONENT_NAME.value, "__icon--").concat(theme)
        }, null));
      };
      return vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__content")
      }, [vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__body")
      }, [renderIcon(), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__inner")
      }, [renderTNodeJSX("content")])]), Boolean(cancelBtn || confirmBtn) && vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__buttons")
      }, [cancelBtn, confirmBtn])]);
    };
    var onPopupVisibleChange = function onPopupVisibleChange(val, context) {
      setInnerVisible(val, context);
    };
    var renderTNodeContent = hooks_tnode.useContent();
    return function () {
      return vue.createVNode(popup_index.Popup, vue.mergeProps({
        "visible": innerVisible.value
      }, innerPopupProps.value, {
        "onVisibleChange": onPopupVisibleChange
      }), {
        "default": function _default() {
          return [renderTNodeContent("default", "triggerElement")];
        },
        content: renderContent
      });
    };
  }
});

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