import { Breadcrumbs as b } from "./accelbyte-widgets190.mjs";
import { Lightbox as v } from "./accelbyte-widgets191.mjs";
import C from "./accelbyte-widgets210.mjs";
import { ItemHelper as L } from "./accelbyte-widgets192.mjs";
import { gaSendErrorEvent as S } from "./accelbyte-widgets145.mjs";
import { Ctx as u } from "./accelbyte-widgets33.mjs";
import { EcommerceErrorCode as x } from "./accelbyte-widgets185.mjs";
import { EcomPath as d } from "./accelbyte-widgets59.mjs";
import { ErrorPath as y } from "./accelbyte-widgets69.mjs";
import { ErrorHelper as I } from "./accelbyte-widgets120.mjs";
import { PageTitleUtils as A } from "./accelbyte-widgets188.mjs";
import { PurchaseHelper as N } from "./accelbyte-widgets211.mjs";
import { DesktopChecker as B } from "@accelbyte/sdk";
import e from "react";
import O from "react-helmet";
import { Trans as c } from "react-i18next";
import { Link as p } from "react-router-dom";
import { DiscountCountdownWidget as k } from "./accelbyte-widgets194.mjs";
import { AppDetailGallery as G } from "./accelbyte-widgets195.mjs";
import { CatalogItemBanner as M } from "./accelbyte-widgets196.mjs";
import R from "./accelbyte-widgets197.mjs";
import { CatalogPurchaseWidget as T } from "./accelbyte-widgets198.mjs";
import w from "./accelbyte-widgets199.mjs";
import { InAppStore as U } from "./accelbyte-widgets212.mjs";
import "./accelbyte-widgets201.mjs";
import { ItemDetailPageLoadingScreen as H, ItemDetailPageError as K } from "./accelbyte-widgets67.mjs";
import "./accelbyte-widgets213.mjs";
import { ItemDetailPurchaseAlert as W } from "./accelbyte-widgets202.mjs";
import { BundleItemDetailPageLogic as _ } from "./accelbyte-widgets214.mjs";
import { CatalogBundleItemList as q } from "./accelbyte-widgets215.mjs";
class F extends e.Component {
  constructor(t) {
    super(t), this.openLightbox = (o) => {
      this.setState({ isLightboxOpen: !0, selectedImagePosition: o });
    }, this.closeLightbox = () => {
      this.setState({ isLightboxOpen: !1 });
    };
    const { itemId: i, country: a, language: r, user: n } = this.props;
    this.logic = new _({ itemId: i, country: a, language: r, user: n }), this.logic.subscribe(() => this.setState({})), this.state = {
      isLightboxOpen: !1,
      selectedImagePosition: 0
    };
  }
  componentDidMount() {
    this.logic.init();
  }
  hasPendingOrder() {
    var t, i, a;
    return !!((a = (i = (t = this.logic.purchaseLogic) == null ? void 0 : t.state) == null ? void 0 : i.pendingOrders) != null && a[0]);
  }
  isItemUnavailable() {
    const { purchaseLogic: t } = this.logic;
    return !!(t && t.state.purchaseConstraint && N.purchaseUnavailable(t.state.purchaseConstraint));
  }
  render() {
    const t = u.getAppState().isSingleGame(), { user: i } = this.props, { isFetching: a, bundleItem: r, error: n, baseApp: o, itemsInBundle: h, itemPublishingContent: E } = this.logic.state;
    n && I.extractServiceErrorCode(n) === x.ITEM_NOT_FOUND && S({
      eventCategory: y.Error404.makePath(),
      eventLabel: I.errorToString(n)
    });
    const { purchaseLogic: m } = this.logic, g = m == null ? void 0 : m.state.currencyMap, D = m == null ? void 0 : m.state.activatedRegionData, { isLightboxOpen: f, selectedImagePosition: P } = this.state, s = L.getMedia(r, E);
    return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
      W,
      {
        purchaseLogic: m,
        user: i,
        isFetching: a
      }
    ), /* @__PURE__ */ e.createElement(O, null, r && /* @__PURE__ */ e.createElement("title", null, A.getPageTitle(u.getAppState().state.discovery || null, r.title, r.title))), a && /* @__PURE__ */ e.createElement(H, null), n && /* @__PURE__ */ e.createElement(K, { error: n }), r && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(M, { item: r, itemPublishingContent: E }, /* @__PURE__ */ e.createElement(b, null, /* @__PURE__ */ e.createElement(p, { to: d.GameList.makePath() }, /* @__PURE__ */ e.createElement(c, { i18nKey: "Navigation.links.games" }, "Games")), o && /* @__PURE__ */ e.createElement(p, { to: d.getItemDetailRoute(o) }, o.title), r.title)), s && /* @__PURE__ */ e.createElement(G, { itemMedias: s, openLightbox: this.openLightbox }), f && s && /* @__PURE__ */ e.createElement(
      v,
      {
        itemMedias: s,
        isOpen: f,
        onClose: this.closeLightbox,
        selectedPosition: P
      }
    ), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(
      q,
      {
        items: h,
        bundleItem: r,
        activatedRegionData: D,
        currencyMap: g
      }
    ), /* @__PURE__ */ e.createElement(R, { item: r })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(w, { item: r }, g && /* @__PURE__ */ e.createElement(k, { item: r, currencyMap: g, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(
      T,
      {
        item: r,
        bundleLogic: this.logic,
        purchaseLogic: m,
        itemsInBundle: h
      }
    )), o && /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(c, { i18nKey: "BundleItemDetailPage.requiredAppNotice" }, "Required Game"), B.isDesktopApp() && t ? /* @__PURE__ */ e.createElement(p, { to: "/game" }, o.title) : /* @__PURE__ */ e.createElement(p, { to: d.getItemDetailRoute(o) }, o.title)))), /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ e.createElement("h2", null, /* @__PURE__ */ e.createElement(c, { i18nKey: "BundleItemDetailPage.inAppStore.heading" }, "Related Items")), /* @__PURE__ */ e.createElement(
      U,
      {
        baseItem: r,
        language: this.props.language,
        noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(c, { i18nKey: "BundleItemDetailPage.inAppStore.noItem" }, "Looks like there are no related items yet."))
      }
    ))));
  }
}
const be = C(
  ({ itemId: l, language: t }) => {
    const i = u.getAppState().getUser() || void 0, a = i && i.country || void 0;
    return /* @__PURE__ */ e.createElement(F, { itemId: l, country: a, user: i, language: t });
  },
  (l, t) => l.itemId !== t.itemId || t.language !== l.language
);
export {
  F as BundleItemDetailPage,
  be as default
};
