import { jsx as o } from "@emotion/react/jsx-runtime";
import { useEffect as l } from "react";
import { format as y } from "date-fns";
import { useAuth as _, useLocalStorage as f, DomainCountryProvider as h } from "@m4l/core";
import { KEY_LOCAL_STORAGE_THEME_SETTINGS as p, defaultThemeSettings as g, HostThemeProvider as C, FormatterProvider as E } from "@m4l/graphics";
import { getUserThemeOptions as b, fnComponentsOverrides as T } from "@m4l/styles";
function D(s) {
  const { children: m, user: c, pwd: d } = s, { isAuthenticated: t, isInitialized: i, login: a, user: e } = _(), [n] = f(p, g);
  if (l(() => {
    i && t === !1 && a(c, d, !1);
  }, [i, t]), !t)
    return /* @__PURE__ */ o("div", { children: "Pendiente por autenticarse" });
  const r = {
    id: 1,
    currency: "USD",
    currency_decimal_digits: 2,
    decimal_symbol: ".",
    thousands_symbol: ","
  };
  e?.domainCountry && (r.id = e?.domainCountry.id ?? r.id, r.currency = e?.domainCountry.currency ?? r.currency, r.currency_decimal_digits = e?.domainCountry.currency_decimal_digits ?? r.currency_decimal_digits, r.decimal_symbol = e?.domainCountry.decimal_symbol ?? r.decimal_symbol, r.thousands_symbol = e?.domainCountry?.thousands_symbol ?? r.thousands_symbol);
  const u = b(n.themeMode, n.themeColor);
  return /* @__PURE__ */ o(
    C,
    {
      hostThemeOptions: u,
      fnComponentsOverrides: T,
      isMicroFrontEnd: !0,
      children: /* @__PURE__ */ o(h, { ...r, isMicroFrontEnd: !1, children: /* @__PURE__ */ o(
        E,
        {
          isMicroFrontEnd: !1,
          dateFormatter: {
            formatDate: y
          },
          currencyFormatter: {
            code: r.currency,
            decimalDigits: r.currency_decimal_digits
          },
          children: m
        }
      ) })
    }
  );
}
export {
  D as MFAuthApp
};
