import { createVNode as _createVNode, mergeProps as _mergeProps, Fragment as _Fragment } from "vue";
import "./styles/message-provider.css";
import { useRender } from "@veno-ui/utils";
import { defineComponent } from "../../utils";
import { Overlay } from "../overlay";
import { Alert } from "../alert";
import { filterAlertProps } from "../alert/alert";
import { MessageKey, message, provideMessage, useMessage } from "../../composables/message";
const MessageProvider = defineComponent({
  name: "VeMessageProvider",
  register(app) {
    app.provide(MessageKey, message);
  },
  props: {
    registered: Boolean
  },
  setup(props, {
    slots
  }) {
    const message2 = !props.registered ? provideMessage() : useMessage();
    const {
      items,
      remove
    } = message2;
    useRender(() => {
      return _createVNode(_Fragment, null, [slots.default?.(), _createVNode(Overlay, {
        "modelValue": items.value.length > 0,
        "scrim": false,
        "scrollStrategy": "none",
        "class": ["ve-message-provider"]
      }, {
        ...slots,
        default: () => _createVNode("ul", null, [items.value.map((item) => {
          const [alertProps] = filterAlertProps(item);
          return _createVNode(Alert, _mergeProps({
            "key": item.id,
            "tag": "li",
            "appear": true,
            "modelValue": item.modelValue,
            "onUpdate:modelValue": ($event) => item.modelValue = $event,
            "on-after-leave": () => remove(item.id)
          }, alertProps), null);
        })])
      })]);
    });
    return message2;
  }
});
export {
  MessageProvider
};
//# sourceMappingURL=message-provider.mjs.map
