import { defineComponent, computed, createVNode, mergeProps } from 'vue';
import localeValues from '../../locale/lang/en_US.mjs';
import ConfirmDialog from '../ConfirmDialog.mjs';
import { useConfigContextInject } from '../../config-provider/context.mjs';
import { useLocaleReceiver } from '../../locale-provider/LocaleReceiver.mjs';
import initDefaultProps from '../../_util/props-util/initDefaultProps.mjs';

const comfirmFuncProps = () => ({
  config: Object,
  afterClose: Function,
  destroyAction: Function,
  open: Boolean
});
var HookModal = /* @__PURE__ */ defineComponent({
  name: "HookModal",
  inheritAttrs: false,
  props: initDefaultProps(comfirmFuncProps(), {
    config: {
      width: 520,
      okType: "primary"
    }
  }),
  setup(props, {
    expose
  }) {
    var _a;
    const open = computed(() => props.open);
    const innerConfig = computed(() => props.config);
    const {
      direction,
      getPrefixCls
    } = useConfigContextInject();
    const prefixCls = getPrefixCls("modal");
    const rootPrefixCls = getPrefixCls();
    const afterClose = () => {
      var _a2, _b;
      props == null ? void 0 : props.afterClose();
      (_b = (_a2 = innerConfig.value).afterClose) == null ? void 0 : _b.call(_a2);
    };
    const close = (...args) => {
      props.destroyAction(...args);
    };
    expose({
      destroy: close
    });
    const mergedOkCancel = (_a = innerConfig.value.okCancel) != null ? _a : innerConfig.value.type === "confirm";
    const [contextLocale] = useLocaleReceiver("Modal", localeValues.Modal);
    return () => createVNode(ConfirmDialog, mergeProps({
      "prefixCls": prefixCls,
      "rootPrefixCls": rootPrefixCls
    }, innerConfig.value, {
      "close": close,
      "open": open.value,
      "afterClose": afterClose,
      "okText": innerConfig.value.okText || (mergedOkCancel ? contextLocale == null ? void 0 : contextLocale.value.okText : contextLocale == null ? void 0 : contextLocale.value.justOkText),
      "direction": innerConfig.value.direction || direction.value,
      "cancelText": innerConfig.value.cancelText || (contextLocale == null ? void 0 : contextLocale.value.cancelText)
    }), null);
  }
});

export { HookModal as default };
//# sourceMappingURL=HookModal.mjs.map
