"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var error_toast_exports = {};
__export(error_toast_exports, {
  errorToast: () => errorToast
});
module.exports = __toCommonJS(error_toast_exports);
var import_effects = require("redux-saga/effects");
var import_error = require("../../data/error/index.js");
var import_guest = require("../../utils/micro-frontend/guest.js");
var import_micro_frontend = require("../../utils/micro-frontend/index.js");
var import_log_records = require("../../utils/log-records.js");
function* openErrorToast(action) {
  try {
    const microApp = yield (0, import_effects.call)(
      import_guest.CMicroAppGuest.getInstance.bind(import_guest.CMicroAppGuest)
    );
    const host = yield (0, import_effects.call)(microApp.getHost.bind(microApp));
    const message = action?.payload?.description || action?.payload?.messageText;
    if (host && message) yield (0, import_effects.call)(host.openErrorBanner.bind(host), message);
  } catch (ex) {
    (0, import_micro_frontend.getLogger)().error({
      ...import_log_records.logRecords.ERR_TOAST_OPEN_FAILED,
      exception: ex
    });
  }
}
function* errorToast() {
  yield (0, import_effects.takeLatest)(import_error.actions.set.type, openErrorToast);
}
