"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useConfirm = useConfirm;
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 useConfirm() {
  const builder = (0, _builder.useModalBuilder)();
  return options => new Promise(resolve => {
    const id = (0, _utils.uid)("confirm");
    builder.show({
      id,
      type: "confirm",
      onClose: () => resolve(false),
      header: options.title,
      body: options.message,
      footer: options.footer || (0, _vue.h)("div", [(0, _vue.h)(_IButton.IButton, {
        onClick: () => {
          builder.hide({
            id
          });
          resolve(false);
        },
        ...options.cancelButtonProps
      }, () => options.cancelButtonText ?? (0, _i18n.translate)("modals.cancel")), (0, _vue.h)(_IButton.IButton, {
        onClick: () => {
          builder.hide({
            id
          });
          resolve(true);
        },
        color: "primary",
        ...options.confirmButtonProps
      }, () => options.confirmButtonText ?? (0, _i18n.translate)("modals.confirm"))]),
      ...options
    });
  });
}