import e, { useRef as f, useState as v } from "react";
import { L as N } from "./LauncherDownloadButton-aa87e3fc.mjs";
import { t as H } from "./i18n-6228a4ed.mjs";
import { A as k, O as w, b as R, a as b } from "./FetchConfigsUtils-476a602b.mjs";
import l from "classnames";
import { Trans as M } from "react-i18next";
import { U as p } from "./UrlUtils-45b0efe7.mjs";
import { L as O } from "./LoginWidget-b2005a0c.mjs";
import { u as S } from "./useAppConfigs-0fb5df89.mjs";
import { L as T, N as A } from "./index-0462597a.mjs";
import { H as B } from "./HeaderAlerts-7d33c741.mjs";
import { u as C } from "./useCompanyLogo-b952c2f7.mjs";
import { u as x } from "./useDiscoveryConfigs-cf63cd60.mjs";
import "./MockVars-8f827f39.mjs";
import "flat";
import "i18next";
import "date-fns";
import "./SSRHelper-8eb361ff.mjs";
import "@accelbyte/sdk";
import "./RouteUtils-f2d71427.mjs";
import "zod";
import "uuid";
import "axios";
import "@accelbyte/sdk-iam";
import "./Env-161a418e.mjs";
import "./LoginIcon-409b27ef.mjs";
import "./Button-c97a7217.mjs";
import "react-feather";
import "./CommonError-e27d39d7.mjs";
import "./ArrowIcon-7c2378f0.mjs";
import "./Loading-9dff8957.mjs";
import "./ProfileImage-6c73026b.mjs";
import "./LogoutIcon-947c7425.mjs";
import "./useUserInfo-ad7006e5.mjs";
import "@accelbyte/sdk-basic";
import "./useAppState-80c04995.mjs";
import "@accelbyte/sdk-gdpr";
import "@accelbyte/sdk-legal";
import "./widget-ctx-5e46828e.mjs";
import "shortid";
import "./InfoIcon-c86fd057.mjs";
import "./Alert-1277e378.mjs";
import "./useHeaderAlerts-15020c2b.mjs";
const I = ({ className: r, title: o }) => /* @__PURE__ */ e.createElement("i", { className: r }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg" }, !!o && /* @__PURE__ */ e.createElement("title", null, o), /* @__PURE__ */ e.createElement("path", { d: "M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z" })));
const U = ({ logo: r, isHomepageDisabled: o, siteBrandURL: n, redirectionURL: i }) => {
  const { state: t } = R(), [s] = b();
  let m = t.home.link, c = !1;
  if (o) {
    if (n) {
      const a = p.getRouterRedirection(n, s.baseURL);
      c = !a, m = a || n;
    }
    if (!n && i) {
      const a = p.getRouterRedirection(i, s.baseURL);
      c = !a, m = a || i;
    }
  }
  return c ? /* @__PURE__ */ e.createElement("a", { className: "logo", href: m }, /* @__PURE__ */ e.createElement("img", { src: r, alt: "logo" })) : /* @__PURE__ */ e.createElement(T, { className: "logo", to: m }, /* @__PURE__ */ e.createElement("img", { src: r, alt: "logo" }));
}, V = ({ menus: r }) => /* @__PURE__ */ e.createElement("nav", { className: "navigationContainer" }, r == null ? void 0 : r.map((o, n) => /* @__PURE__ */ e.createElement(A, { key: `menuLink-${n}`, className: "menuLink", to: o.pathname }, o.label))), Me = (r) => {
  const { areLinksHidden: o, menus: n, userDropdownMenus: i } = r, {
    state: { playerPortalConfigData: t }
  } = S(), {
    state: { flags: s }
  } = x(), { companyLogo: m } = C(k.PP, "header"), c = f(null), [a, u] = v(!1), d = t == null ? void 0 : t.homepage.data.siteBrandURL, g = t == null ? void 0 : t.homepage.data.redirectionURL, E = !!(t != null && t.homepage.data.isDisabled), h = s == null ? void 0 : s.isGetLauncherVisible, L = () => {
    u(!a);
  };
  return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("header", { className: l("headerPP", w.TITLE_FONT, "headerPreview") }, /* @__PURE__ */ e.createElement("div", { className: "translucent" }), /* @__PURE__ */ e.createElement("div", { className: "headerContent" }, /* @__PURE__ */ e.createElement("div", { className: "logoContainer" }, m && /* @__PURE__ */ e.createElement(
    U,
    {
      logo: m,
      isHomepageDisabled: E,
      siteBrandURL: d,
      redirectionURL: g
    }
  )), !o && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "hamburgerMenu" }, /* @__PURE__ */ e.createElement("button", { ref: c, className: "menuIconContainer", onClick: L }, /* @__PURE__ */ e.createElement(I, { className: "menuIcon", title: H("Header.menuTitle") }))), /* @__PURE__ */ e.createElement("div", { className: l("dropdownMenu", a ? "open" : "closed") }, /* @__PURE__ */ e.createElement(V, { menus: n }), /* @__PURE__ */ e.createElement(O, { userDropdownMenus: i }), h && /* @__PURE__ */ e.createElement("div", { className: "getLauncherButtonContainer" }, /* @__PURE__ */ e.createElement(N, null, /* @__PURE__ */ e.createElement(M, { i18nKey: "Header.getLauncherButton" }, "Get Launcher")))))), /* @__PURE__ */ e.createElement(B, { className: "headerAlerts" })));
};
export {
  Me as HeaderWidget
};
