"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useAlert = useAlert;
var _IButton = require("@inkline/inkline/components/IButton");
var _i18n = require("@inkline/inkline/i18n");
var _utils = require("@grozav/utils");
var _vue = require("vue");
var _builder = require("@inkline/inkline/composables/modals/builder");
function useAlert() {
  const builder = (0, _builder.useModalBuilder)();
  return options => new Promise(resolve => {
    const id = (0, _utils.uid)("alert");
    builder.show({
      id,
      type: "alert",
      onClose: () => resolve(),
      header: options.title,
      body: options.message,
      footer: options.footer || (0, _vue.h)(_IButton.IButton, {
        onClick: () => {
          builder.hide({
            id
          });
        },
        color: "primary",
        ...options.confirmButtonProps
      }, () => options.confirmButtonText ?? (0, _i18n.translate)("modals.confirm")),
      ...options
    });
  });
}