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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, toRefs, computed, createVNode, mergeProps } from 'vue';
import { InfoCircleFilledIcon, ErrorCircleFilledIcon } from '@ldesign/icons-vue-next';
import { usePrefixClass } from '../hooks/useConfig.js';
import { useGlobalIcon } from '../hooks/useGlobalIcon.js';
import { Popup } from '../popup/index.js';
import { useTNodeJSX, useTNodeDefault, useContent } from '../hooks/tnode.js';
import useVModel from '../hooks/useVModel.js';
import { useAction } from '../dialog/hooks.js';
import props from './props.js';
import { useConfig } from '../config-provider/useConfig.js';
import '../utils/withInstall.js';
import '../popup/popup.js';
import '@popperjs/core';
import 'lodash/isString';
import 'lodash/isFunction';
import 'lodash/isObject';
import '../utils/dom.js';
import '../_chunks/dep-e041f5b0.js';
import 'lodash/isArray';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'lodash/isUndefined';
import '../hooks/useResizeObserver.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import 'dayjs';
import 'lodash/omit';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../loading/loading.js';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isNumber';
import '../hooks/useRipple.js';
import '../utils/set-style.js';
import '../hooks/useKeepAnimation.js';
import '../form/hooks.js';
import '../button/props.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 = defineComponent({
  name: "TPopconfirm",
  props: props,
  setup: function setup(props2) {
    var _useConfig = useConfig("popconfirm"),
      globalConfig = _useConfig.globalConfig;
    var COMPONENT_NAME = usePrefixClass("popconfirm");
    var _useGlobalIcon = useGlobalIcon({
        InfoCircleFilledIcon: InfoCircleFilledIcon,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon
      }),
      InfoCircleFilledIcon$1 = _useGlobalIcon.InfoCircleFilledIcon,
      ErrorCircleFilledIcon$1 = _useGlobalIcon.ErrorCircleFilledIcon;
    var _toRefs = toRefs(props2),
      visible = _toRefs.visible,
      modelValue = _toRefs.modelValue;
    var _useVModel = useVModel(visible, modelValue, props2.defaultVisible, props2.onVisibleChange, "visible"),
      _useVModel2 = _slicedToArray(_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 = useAction({
        confirmBtnAction: confirmBtnAction,
        cancelBtnAction: cancelBtnAction
      }),
      getConfirmBtn = _useAction.getConfirmBtn,
      getCancelBtn = _useAction.getCancelBtn;
    var renderTNodeJSX = useTNodeJSX();
    var innerPopupProps = computed(function () {
      return _objectSpread({
        showArrow: props2.showArrow,
        overlayClassName: COMPONENT_NAME.value,
        trigger: "click",
        destroyOnClose: props2.destroyOnClose,
        placement: props2.placement
      }, props2.popupProps);
    });
    var renderTNodeDefault = 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$1,
          warning: ErrorCircleFilledIcon$1,
          danger: ErrorCircleFilledIcon$1
        }[props2.theme];
        var theme = props2.theme || "default";
        return renderTNodeDefault("icon", createVNode(Icon, {
          "class": "".concat(COMPONENT_NAME.value, "__icon--").concat(theme)
        }, null));
      };
      return createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__content")
      }, [createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__body")
      }, [renderIcon(), createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__inner")
      }, [renderTNodeJSX("content")])]), Boolean(cancelBtn || confirmBtn) && createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__buttons")
      }, [cancelBtn, confirmBtn])]);
    };
    var onPopupVisibleChange = function onPopupVisibleChange(val, context) {
      setInnerVisible(val, context);
    };
    var renderTNodeContent = useContent();
    return function () {
      return createVNode(Popup, mergeProps({
        "visible": innerVisible.value
      }, innerPopupProps.value, {
        "onVisibleChange": onPopupVisibleChange
      }), {
        "default": function _default() {
          return [renderTNodeContent("default", "triggerElement")];
        },
        content: renderContent
      });
    };
  }
});

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