import { u as L, O as p } from "./Env-92498313.mjs";
import { m as k } from "./MockVars-a56587d1.mjs";
import { L as w } from "./LauncherLink-a04d50bf.mjs";
import D from "classnames";
import * as v from "react";
import { useState as b, useEffect as g } from "react";
import { u as l, a as y } from "./index-28007ca6.mjs";
const T = (i) => {
  const {
    state: { playerPortalConfigData: t }
  } = l(), {
    state: { discoveryConfigData: e }
  } = y(), {
    mutations: { fetchLauncherConfigs: u }
  } = l(), { children: m, className: d } = i, [o] = L();
  let r = !1;
  try {
    r = location.pathname.includes("/player-portal");
  } catch {
  }
  const [a, f] = b(
    r ? k : t == null ? void 0 : t.launcherDownloadLink.data.value
  );
  return g(() => {
    if (!o)
      return;
    (async () => {
      var c;
      if (e && !a) {
        const n = await u(e), h = await w.getLauncherDownloadLink((c = n == null ? void 0 : n.data) == null ? void 0 : c.launcherUpdateUrl.data.value);
        f(h);
      }
      return null;
    })();
  }, [o, a]), /* @__PURE__ */ v.createElement(
    "a",
    {
      className: D(
        d,
        "btn small btn-primary",
        "launcherDownloadButton",
        !a && "disabled",
        p.TITLE_FONT
      ),
      title: a || "Not available",
      target: "_blank",
      rel: "noreferrer",
      href: a || "",
      onClick: (s) => {
        a || s.preventDefault();
      }
    },
    m
  );
};
export {
  T as L
};
