'use strict';

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

var vue = require('vue');
require('../../../../utils/index.cjs');
require('../../../../locale/index.cjs');
var ConfirmDialog = require('../ConfirmDialog.cjs');
require('../../../config-provider/index.cjs');
require('../../../locale-provider/index.cjs');
var initDefaultProps = require('../../../../utils/vue/initDefaultProps.cjs');
var context = require('../../../config-provider/src/context/context.cjs');
var useLocaleReceiver = require('../../../locale-provider/src/useLocaleReceiver.cjs');
var en_US = require('../../../../locale/lang/en_US.cjs');

function comfirmFuncProps() {
  return {
    config: Object,
    afterClose: Function,
    destroyAction: Function,
    open: Boolean
  };
}
var HookModal = /* @__PURE__ */ vue.defineComponent({
  name: "HookModal",
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(comfirmFuncProps(), {
    config: {
      width: 520,
      okType: "primary"
    }
  }),
  setup(props, {
    expose
  }) {
    var _a;
    const open = vue.computed(() => props.open);
    const innerConfig = vue.computed(() => props.config);
    const {
      direction,
      getPrefixCls
    } = context.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.useLocaleReceiver("Modal", en_US.default.Modal);
    return () => vue.createVNode(ConfirmDialog.default, {
      "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);
  }
});

exports.default = HookModal;
//# sourceMappingURL=HookModal.cjs.map
