import { Breadcrumbs as D } from "./accelbyte-widgets190.mjs";
import { Lightbox as y } from "./accelbyte-widgets191.mjs";
import { Loading as A, LoadingSize as G } from "./accelbyte-widgets136.mjs";
import S from "./accelbyte-widgets210.mjs";
import { ItemHelper as k } from "./accelbyte-widgets192.mjs";
import { gaSendErrorEvent as C } from "./accelbyte-widgets145.mjs";
import { Ctx as f } from "./accelbyte-widgets33.mjs";
import { EcommerceErrorCode as N } from "./accelbyte-widgets185.mjs";
import { EcomPath as h } from "./accelbyte-widgets59.mjs";
import { ErrorPath as w } from "./accelbyte-widgets69.mjs";
import { GlobalPath as M } from "./accelbyte-widgets104.mjs";
import { ErrorHelper as b } from "./accelbyte-widgets120.mjs";
import { PageTitleUtils as x } from "./accelbyte-widgets188.mjs";
import e from "react";
import { Helmet as O } from "react-helmet";
import { Trans as p } from "react-i18next";
import { Link as E } from "react-router-dom";
import { DiscountCountdownWidget as T } from "./accelbyte-widgets194.mjs";
import { AppDetailGallery as B } from "./accelbyte-widgets195.mjs";
import { CatalogItemBanner as q } from "./accelbyte-widgets196.mjs";
import K from "./accelbyte-widgets197.mjs";
import { CatalogPurchaseWidget as F } from "./accelbyte-widgets198.mjs";
import { PurchaseBaseAppButton as R } from "./accelbyte-widgets218.mjs";
import U from "./accelbyte-widgets199.mjs";
import { InAppStore as W } from "./accelbyte-widgets212.mjs";
import { OpenLibraryLauncherButton as _ } from "./accelbyte-widgets219.mjs";
import "./accelbyte-widgets201.mjs";
import { PlatformRequirements as H } from "./accelbyte-widgets220.mjs";
import { ItemDetailPageError as z } from "./accelbyte-widgets67.mjs";
import { ItemDetailPurchaseAlert as $ } from "./accelbyte-widgets202.mjs";
import "./accelbyte-widgets221.mjs";
import { DlcDetailPageLogic as j } from "./accelbyte-widgets222.mjs";
import { mockStoreItem as J, mockSingleGameInfo as Q } from "./accelbyte-widgets209.mjs";
import { DesktopChecker as V } from "@accelbyte/sdk";
const X = () => /* @__PURE__ */ e.createElement(A, { className: G.tall }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InitialUserFetchPage.notice" }));
class Y extends e.Component {
  constructor(i) {
    super(i), this.openLightbox = (o) => {
      this.setState({ isLightboxOpen: !0, selectedImagePosition: o });
    }, this.closeLightbox = () => {
      this.setState({ isLightboxOpen: !1 });
    }, this.renderLauncherGoToLibraryButton = () => {
      const { dlcItem: o, baseApp: l, isBaseAppOwned: s } = this.logic.state;
      return o ? !l || s ? /* @__PURE__ */ e.createElement(_, { item: l || o }) : /* @__PURE__ */ e.createElement(R, { baseApp: l }) : "";
    };
    const { itemId: n, country: t, language: m, user: u } = i;
    this.logic = new j({ itemId: n, country: t, language: m, user: u }), this.logic.subscribe(() => this.setState({})), this.state = {
      isLightboxOpen: !1,
      selectedImagePosition: 0
    };
  }
  componentDidMount() {
    this.props.isPreviewMode || this.logic.init();
  }
  render() {
    const i = f.getAppState().isSingleGame(), { user: n, isPreviewMode: t } = this.props, { isFetching: m, dlcItem: u, error: o, baseApp: l, additionalAppInfo: s, itemPublishingContent: I } = this.logic.state, r = t ? J.data[2] : u, c = t ? Q : l;
    o && b.extractServiceErrorCode(o) === N.ITEM_NOT_FOUND && C({
      eventCategory: w.Error404.makePath(),
      eventLabel: b.errorToString(o)
    });
    const { purchaseLogic: g } = this.logic, P = g && g.state.currencyMap, { isLightboxOpen: L, selectedImagePosition: v } = this.state, d = k.getMedia(r, I);
    return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
      $,
      {
        purchaseLogic: g,
        user: n,
        isFetching: m,
        isPreviewMode: !!t
      }
    ), /* @__PURE__ */ e.createElement(O, null, r && /* @__PURE__ */ e.createElement("title", null, x.getPageTitle(f.getAppState().state.discovery || null, r.title, r.title))), m && /* @__PURE__ */ e.createElement(X, null), o && /* @__PURE__ */ e.createElement(z, { error: o }), r && c && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(q, { item: r, itemPublishingContent: I }, /* @__PURE__ */ e.createElement(D, null, /* @__PURE__ */ e.createElement(E, { to: h.GameList.makePath() }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.games" }, "Games")), /* @__PURE__ */ e.createElement(
      E,
      {
        to: h.GameItem.makePath({
          itemId: c.itemId
        })
      },
      c.title
    ), r.title)), d && /* @__PURE__ */ e.createElement(B, { itemMedias: d, openLightbox: this.openLightbox }), L && d && /* @__PURE__ */ e.createElement(
      y,
      {
        itemMedias: d,
        isOpen: L,
        onClose: this.closeLightbox,
        selectedPosition: v
      }
    ), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(K, { item: r }), s && /* @__PURE__ */ e.createElement(H, { className: "requirementsDesktop", additionalAppInfo: s })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(U, { item: r }, P && /* @__PURE__ */ e.createElement(T, { item: r, currencyMap: P, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(
      F,
      {
        item: r,
        purchaseLogic: g,
        additionalAppInfo: s,
        renderLauncherGoToLibraryButton: this.renderLauncherGoToLibraryButton,
        isPreviewMode: !!t,
        isCheckoutPreview: t == null ? void 0 : t.isCheckoutModalPreview
      }
    )), /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.requiredAppNotice" }, "Required Game"), /* @__PURE__ */ e.createElement(
      E,
      {
        to: V.isDesktopApp() && i ? M.Game.link : h.GameItem.makePath({
          itemId: c.itemId
        })
      },
      c.title
    )))), /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ e.createElement("h2", null, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.inAppStore.heading" }, "Related Items")), /* @__PURE__ */ e.createElement(
      W,
      {
        baseItem: r,
        language: this.props.language,
        noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.inAppStore.noItem" }, "Looks like there are no related items yet.")),
        isPreviewMode: !!t
      }
    ))));
  }
}
const xe = S(
  ({ itemId: a, language: i, isPreviewMode: n }) => {
    const t = f.getAppState().getUser() || void 0, m = t && t.country || void 0;
    return /* @__PURE__ */ e.createElement(Y, { itemId: a, country: m, user: t, language: i, isPreviewMode: n });
  },
  (a, i) => a.itemId !== i.itemId || i.language !== a.language || a.isPreviewMode !== i.isPreviewMode
);
export {
  Y as DlcDetailPage,
  X as ItemDetailPageLoadingScreen,
  xe as default
};
