import { CommonError as m } from "./accelbyte-widgets124.mjs";
import { Loading as l, LoadingSize as p } from "./accelbyte-widgets136.mjs";
import { Ctx as c } from "./accelbyte-widgets33.mjs";
import { GlobalPath as g } from "./accelbyte-widgets104.mjs";
import { LoginPath as h } from "./accelbyte-widgets35.mjs";
import { UrlUtils as a } from "./accelbyte-widgets90.mjs";
import e from "react";
import { Trans as L } from "react-i18next";
import n from "shortid";
import d from "./accelbyte-widgets137.mjs";
import { IamUserAuthorizationClient as f } from "@accelbyte/sdk-iam";
class x extends e.Component {
  constructor(t) {
    super(t), this.randString = n(), this.state = { error: null }, this.randString = n(), this.appState = c.getAppState();
  }
  componentDidMount() {
    this.tryLogin();
  }
  tryLogin() {
    const t = this.appState, { appHistory: r } = t.state;
    if (!!t.getUser())
      return r.replace(g.Home.link);
    const o = a.silentSearchParamsBuilder(r.location.search), i = o.get(h.LoginURLGeneratorParamKeys.RETURN_PATH_PARAMS_KEY);
    r.replace(`${a.makeAbsolutePath(r.location.pathname)}?${o.toString()}`);
    const s = new f(t.getSdk()).createLoginURL(i);
    window.location.replace(s);
  }
  render() {
    const { error: t } = this.state;
    return /* @__PURE__ */ e.createElement("div", { className: d.loginURLGenerator }, !t && /* @__PURE__ */ e.createElement(l, { className: p.tall }, /* @__PURE__ */ e.createElement(L, { i18nKey: "InitialUserFetchPage.notice" })), t && /* @__PURE__ */ e.createElement(m, { error: t }));
  }
}
export {
  x as default
};
