import e, { useEffect as u, useState as Le, useCallback as ke } from "react";
import { u as X, F as He, c as J, b as ee, e as ae, S as Z, P as re, B as ne, C as oe, f as se, L as ie, g as le, h as me, D as ce, i as pe, j as ue, k as qe, O as We, l as Ze, m as je, n as j, o as Ne } from "./AppStoreDetail-5e836fd3.mjs";
import { A as fr, p as hr } from "./AppStoreDetail-5e836fd3.mjs";
import { u as de } from "./useDiscoveryConfigs-cf63cd60.mjs";
import De from "classnames";
import { Trans as p } from "react-i18next";
import { T as xe } from "./Radio-913d38b8.mjs";
import { N as _e, L } from "./index-0462597a.mjs";
import { a as Oe, u as te } from "./useUserInfo-ad7006e5.mjs";
import { DecodeError as ze, DesktopChecker as be } from "@accelbyte/sdk";
import { s as Qe, t as Fe, q as Xe } from "./MockVars-8f827f39.mjs";
import { F as _, E as x, b as Y, u as Me, W as we } from "./FetchConfigsUtils-476a602b.mjs";
import { L as Ke } from "./LoadingPage-37f53f05.mjs";
import { C as Ye, N as Ve } from "./CommonError-67040eba.mjs";
import { u as Je, I as et, a as tt, d as Ae, b as W } from "./default-item-image-5b912e0f.mjs";
import { C as at } from "./ConfigsUtils-dd5e59d2.mjs";
import { g as K, t as rt } from "./i18n-c7e26598.mjs";
import { B as Ee } from "./HtmlUtils-4c7d14e3.mjs";
import { C as Re, g as V } from "./CommonError-e27d39d7.mjs";
import { A as Ue, I as B, E as Q, F as Ie } from "./FetchUtils-cc53dbb5.mjs";
import { a as D, P as nt } from "./PageRoute-6bc6614c.mjs";
import { u as ge } from "./PaymentStatusDialog-46916c30.mjs";
import { u as Se } from "./usePendingOrders-53ca2538.mjs";
import { EligibleUser as ot } from "@accelbyte/sdk-iam";
import { Platform as ye } from "@accelbyte/sdk-platform";
import { D as st, a as it, b as lt } from "./Dialog-b2e1c8bb.mjs";
import { U as mt } from "./UrlUtils-45b0efe7.mjs";
import { I as Te } from "./ItemPlaceholder-da243b7a.mjs";
import "zod";
import "react-dom";
import "react-player";
import "react-slick";
import "./ArrowIcon-647b10f0.mjs";
import "./Alert-c2425f39.mjs";
import "./InfoIcon-c86fd057.mjs";
import "./Alert-1277e378.mjs";
import "react-feather";
import "./Button-c97a7217.mjs";
import "./Loading-16af3910.mjs";
import "date-fns";
import "./numbers-4344265e.mjs";
import "./LauncherDownloadButton-080a25e6.mjs";
import "./Env-161a418e.mjs";
import "./useAppConfigs-0fb5df89.mjs";
import "./widget-ctx-5e46828e.mjs";
import "@accelbyte/sdk-basic";
import "./RouteUtils-f2d71427.mjs";
import "uuid";
import "axios";
import "./starBgGradient-589e5185.mjs";
import "flat";
import "i18next";
import "./SSRHelper-8eb361ff.mjs";
import "dompurify";
import "react-router";
function Va({ children: t }) {
  const {
    state: { isSingleGame: r }
  } = de(), {
    mutations: { fetchCurrencyMap: s }
  } = X();
  return u(() => {
    s();
  }, [s]), /* @__PURE__ */ e.createElement("div", { className: "storeWidget" }, /* @__PURE__ */ e.createElement("div", null, typeof t == "function" ? t({ isSingleGame: r }) : t));
}
const ct = "storeEntry _storeEntry_25574", pt = {
  storeEntry: ct
};
function Ja({ children: t }) {
  return /* @__PURE__ */ e.createElement("div", { className: De("container mx-auto px-2", pt.storeEntry) }, /* @__PURE__ */ e.createElement("h2", { className: "storeEntryTitle" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "StorePageTitle" }, "Store")), t);
}
const er = ({ tabLinks: t, children: r }) => {
  const {
    state: { location: s }
  } = Oe();
  return s ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(xe, null, t.map((i, a) => /* @__PURE__ */ e.createElement(_e, { key: a, className: `tab ${i.className}`, to: i.link }, i.icon, i.label))), /* @__PURE__ */ e.createElement("div", { className: "gridContainer" }, r)) : null;
};
function tr({ tabLinks: t, children: r }) {
  return /* @__PURE__ */ e.createElement("div", { className: "pb-6" }, /* @__PURE__ */ e.createElement(xe, null, t.map((s, i) => /* @__PURE__ */ e.createElement(_e, { key: i, className: `tab ${s.className}`, to: s.link }, s.icon, s.label))), /* @__PURE__ */ e.createElement("div", { className: "gridContainer" }, r));
}
const ut = () => /* @__PURE__ */ e.createElement(Ke, { className: "mt-3 md:mt-7" }), dt = ({ error: t }) => {
  const r = () => {
    switch (!0) {
      case t instanceof He:
      case t instanceof ze:
        return /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.item.decodeError" }, "The game data from the server is invalid. Please refresh the page.");
      default:
        return /* @__PURE__ */ e.createElement(Ye, { error: t });
    }
  };
  return /* @__PURE__ */ e.createElement("div", { className: "error" }, r());
}, Et = J();
function ar({ isPreviewMode: t, children: r }) {
  var A;
  const { state: s } = te(), i = (A = s.user) == null ? void 0 : A.country, { state: a } = de(), l = at.getAppId(a.discoveryConfigData), {
    state: { activeGame: c },
    mutations: { fetchItemInfo: m }
  } = Je(), n = t ? Qe : c == null ? void 0 : c.itemId, {
    state: { itemLocale: o, itemLocaleFetchStatus: d, itemLocaleError: g },
    mutations: { fetchItemLocale: h }
  } = ee(Et);
  if (u(() => {
    m({ appId: l });
  }, [l]), u(() => {
    h({ itemId: n, language: K(), country: i });
  }, [h, n, i]), !n)
    return /* @__PURE__ */ e.createElement(
      Ve,
      {
        appId: l || "",
        error: null,
        isWithBackground: !be.isDesktopApp()
      }
    );
  const y = t ? Fe : o;
  return d === _.FETCHING ? /* @__PURE__ */ e.createElement(ut, null) : g ? /* @__PURE__ */ e.createElement(dt, { error: g }) : typeof r == "function" ? r({ baseItem: y }) : r;
}
const z = class {
};
let f = z;
f.GameList = new D("/store/apps");
f.GameItem = new D("/store/apps/:itemId");
f.DlcList = new D("/store/dlcs");
f.DlcItem = new D("/store/dlcs/:itemId");
f.InGameItem = new D("/store/in-game-items/:itemId");
f.BundleList = new D("/store/bundles");
f.BundleItem = new D("/store/bundles/:itemId");
f.CodeList = new D("/store/code");
f.CodeItem = new D("/store/code/:itemId");
f.OptionboxList = new D("/store/optionbox");
f.OptionboxItem = new D("/store/optionbox/:itemId");
f.Store = new D("/store");
f.Recharge = new D("/recharge");
f.OrderDetail = new D("/orders/:orderNo");
f.SubscriptionOrder = new D("/subscription/:subscriptionId");
f.Subscription = new D("/subscription");
f.PaymentSuccessCallback = new D("/callback/order/success");
f.getItemDetailRoute = (t) => {
  const r = t.itemId;
  if (t.appType === Ue.enum.DLC)
    return z.DlcItem.makePath({ itemId: r });
  switch (t.itemType) {
    case B.enum.APP:
      return z.GameItem.makePath({ itemId: r });
    case B.enum.BUNDLE:
      return z.BundleItem.makePath({ itemId: r });
    case B.enum.CODE:
      return z.CodeItem.makePath({ itemId: r });
    case B.enum.OPTIONBOX:
      return z.OptionboxItem.makePath({ itemId: r });
    case B.enum.INGAMEITEM:
      return z.InGameItem.makePath({ itemId: r });
  }
  return "";
};
const fe = ({ error: t }) => {
  const r = () => t && x.extractServiceErrorCode(t) === Q.PRODUCT_KEY_NOT_AVAILABLE ? /* @__PURE__ */ e.createElement(p, { i18nKey: "StoreDetail.item.productKeyNotAvailable" }, "This product key is no longer available") : /* @__PURE__ */ e.createElement(Re, { error: t });
  return /* @__PURE__ */ e.createElement("div", { className: "error" }, r());
}, It = "catalogBundleItemList _catalogBundleItemList_d379a", gt = {
  catalogBundleItemList: It
}, St = ({ link: t, thumbnail: r, name: s, type: i, quantity: a }) => /* @__PURE__ */ e.createElement(L, { to: t, className: "catalogItem" }, /* @__PURE__ */ e.createElement("div", { className: "catalogItemImage" }, /* @__PURE__ */ e.createElement("img", { src: r || Ae, loading: "lazy" })), /* @__PURE__ */ e.createElement("div", { className: "catalogItemDetail" }, /* @__PURE__ */ e.createElement("div", { className: "catalogItemHeading" }, s), /* @__PURE__ */ e.createElement("div", { className: "catalogItemType" }, i), /* @__PURE__ */ e.createElement("div", { className: "catalogItemQty" }, a > 1 && `x${a}`)));
function ft({ bundleItem: t, items: r }) {
  const s = r || [];
  return /* @__PURE__ */ e.createElement("div", { className: De(gt.catalogBundleItemList, "catalogBundleItemList") }, /* @__PURE__ */ e.createElement("h2", { className: "catalogHeading" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "BundleStoreDetailCatalog.heading" }, "Inside the Bundle")), s.length > 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogList" }, s.map((i) => {
    const a = i.appType || i.itemType, l = et.getFilteredImageUrlByTag(i.images, tt.productCover) || Ae;
    return /* @__PURE__ */ e.createElement(
      St,
      {
        key: i.itemId,
        link: f.getItemDetailRoute(i),
        thumbnail: l,
        name: i.title || i.name || "",
        type: a,
        quantity: t.itemQty ? t.itemQty[i.itemId] : 1
      }
    );
  })), s.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogNoItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "BundleStoreDetailCatalog.noItem" }, "Looks like there aren't any bundles for this game yet.")));
}
const ht = ae(), yt = J();
function rr({ itemId: t }) {
  const { state: r, closeLightbox: s, openLightbox: i } = Z.useStoreDetailCommonStates(), {
    state: { user: a }
  } = te(), { state: l } = Y(), { state: c } = de(), m = a == null ? void 0 : a.country, n = K(), {
    state: { itemLocale: o, itemLocaleError: d, itemLocaleFetchStatus: g },
    mutations: { fetchItemLocale: h }
  } = ee(yt), {
    state: b,
    mutations: { fetchBundleContents: y }
  } = Z.useBundleInformation(), {
    state: { prepurchaseInformation: A },
    mutations: { prepareOrderProcess: w, resetState: U }
  } = ge(), {
    state: { pendingOrders: $ },
    mutations: { fetchPendingOrders: H, resetState: E }
  } = Se(), {
    state: { currencyMap: I },
    mutations: { fetchCurrencyMap: S }
  } = X();
  u(() => {
    I || S();
  }, [I]), u(() => {
    h({ itemId: t, language: n, country: m });
  }, [t, n, m]), u(() => {
    !I || !o || (w({ item: o, userId: a == null ? void 0 : a.userId, currencyMap: I }), a != null && a.userId && H({ itemId: o.itemId, userId: a.userId }));
  }, [o, a == null ? void 0 : a.userId, I]), u(() => {
    var T;
    !o || !((T = o.itemIds) != null && T.length) || y({ itemIds: o.itemIds, baseAppId: o.baseAppId, country: m, language: n });
  }, [o, m, n]), u(() => () => {
    U(), E();
  }, []);
  const q = c.isSingleGame, { baseApp: N, bundleInfoError: P, bundleInfoFetchStatus: F, items: v } = b, k = d || P, C = Ie.isMatchStatus([F, g], _.FETCHING);
  k && x.extractServiceErrorCode(k) === Q.ITEM_NOT_FOUND && V({ eventCategory: l.error.err404.link, eventLabel: x.errorToString(k) });
  const { isLightboxOpen: G, selectedImagePosition: M } = r, O = W.getMedia(o, null);
  return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
    re,
    {
      user: a,
      prepurchaseInformation: A,
      pendingOrders: $,
      isFetching: C
    }
  ), C && /* @__PURE__ */ e.createElement(ne, null), k && /* @__PURE__ */ e.createElement(fe, { error: k }), o && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { item: o, itemPublishingContent: null }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(L, { to: l.store.apps.index.link }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.games" }, "Games")), N && /* @__PURE__ */ e.createElement(L, { to: W.getItemDetailRoute(l, N) }, N.title), o.title)), O && /* @__PURE__ */ e.createElement(se, { itemMedias: O, openLightbox: i }), G && O && /* @__PURE__ */ e.createElement(ie, { itemMedias: O, isOpen: G, onClose: s, selectedPosition: M }), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(ft, { items: v, bundleItem: o }), /* @__PURE__ */ e.createElement(le, { item: o })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(me, { item: o }, I && /* @__PURE__ */ e.createElement(ce, { item: o, currencyMap: I, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(pe, { item: o })), N && /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "BundleItemDetailPage.requiredAppNotice" }, "Required Game"), be.isDesktopApp() && q ? /* @__PURE__ */ e.createElement(L, { to: "/game" }, N.title) : /* @__PURE__ */ e.createElement(L, { to: f.getItemDetailRoute(N) }, N.title)))), /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ e.createElement("h2", null, /* @__PURE__ */ e.createElement(p, { i18nKey: "BundleItemDetailPage.inAppStore.heading" }, "Related Items")), /* @__PURE__ */ e.createElement(
    ue,
    {
      store: ht,
      baseItem: o,
      language: n,
      noItemMessage: /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.inAppStore.noItem" }, "Looks like there are not any items for this game yet.")
    }
  ))));
}
const Nt = ae(), bt = J();
function nr({ itemId: t }) {
  const { state: r, closeLightbox: s, openLightbox: i } = Z.useStoreDetailCommonStates(), {
    state: { user: a }
  } = te(), { state: l } = Y(), c = a == null ? void 0 : a.country, m = K(), {
    state: { itemLocale: n, itemLocaleError: o, itemLocaleFetchStatus: d },
    mutations: { fetchItemLocale: g }
  } = ee(bt), {
    state: h,
    mutations: { fetchBundleContents: b }
  } = Z.useBundleInformation(), {
    state: { prepurchaseInformation: y },
    mutations: { prepareOrderProcess: A, resetState: w }
  } = ge(), {
    state: { pendingOrders: U },
    mutations: { fetchPendingOrders: $, resetState: H }
  } = Se(), {
    state: { currencyMap: E },
    mutations: { fetchCurrencyMap: I }
  } = X();
  u(() => {
    E || I();
  }, [E]), u(() => {
    g({ itemId: t, language: m, country: c });
  }, [t, m, c]), u(() => {
    !E || !n || (A({ item: n, userId: a == null ? void 0 : a.userId, currencyMap: E }), a != null && a.userId && $({ itemId: n.itemId, userId: a.userId }));
  }, [n, a == null ? void 0 : a.userId, E]), u(() => {
    n && b({ itemIds: n.itemIds || [n.itemId], baseAppId: n.baseAppId, country: c, language: m });
  }, [n, c, m]), u(() => () => {
    w(), H();
  }, []);
  const { baseApp: S, bundleInfoError: q, bundleInfoFetchStatus: N } = h, P = o || q, F = Ie.isMatchStatus([N, d], _.FETCHING);
  P && x.extractServiceErrorCode(P) === Q.ITEM_NOT_FOUND && V({ eventCategory: l.error.err404.link, eventLabel: x.errorToString(P) });
  const { isLightboxOpen: v, selectedImagePosition: k } = r, C = W.getMedia(n, null);
  return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
    re,
    {
      user: a,
      prepurchaseInformation: y,
      pendingOrders: U,
      isFetching: F
    }
  ), F && /* @__PURE__ */ e.createElement(ne, null), P && /* @__PURE__ */ e.createElement(fe, { error: P }), n && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { item: n, itemPublishingContent: null }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(L, { to: l.store.codes.index.link }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.productKeys" }, "Product Keys")), S && /* @__PURE__ */ e.createElement(L, { to: W.getItemDetailRoute(l, S) }, S.title), n.title)), C && /* @__PURE__ */ e.createElement(se, { itemMedias: C, openLightbox: i }), v && C && /* @__PURE__ */ e.createElement(ie, { itemMedias: C, isOpen: v, onClose: s, selectedPosition: k }), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(le, { item: n })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(me, { item: n, tag: rt("CodeItemDetailPage.tag") }, E && /* @__PURE__ */ e.createElement(ce, { item: n, currencyMap: E, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(pe, { item: n })), S && /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "CodeItemDetailPage.requiredAppNotice" }, "Required Game"), /* @__PURE__ */ e.createElement(L, { to: W.getItemDetailRoute(l, S) }, S.title)))), /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ e.createElement("h2", null, /* @__PURE__ */ e.createElement(p, { i18nKey: "CodeItemDetailPage.inAppStore.heading" }, "Related Items")), /* @__PURE__ */ e.createElement(
    ue,
    {
      store: Nt,
      baseItem: n,
      language: m,
      itemType: B.enum.CODE,
      noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "CodeItemDetailPage.inAppStore.noItem" }, "Looks like there are no related items yet."))
    }
  ))));
}
const At = {
  useBaseApp: Pt
};
function Pt() {
  const [t] = Me(), [r, s] = Le({
    baseApp: null,
    baseAppFetchStatus: _.IDLE,
    baseAppError: null
  }), i = ke(
    async ({
      country: a,
      language: l,
      baseAppId: c
    }) => {
      let m = null, n = null;
      try {
        if (s((o) => ({
          ...o,
          baseAppError: null,
          baseAppFetchStatus: _.FETCHING
        })), !c)
          throw new Pe("");
        return m = await ye.ItemApi(t).getItemsByAppId({
          appId: c,
          region: a,
          language: l
        }), { error: null, data: m };
      } catch (o) {
        return n = we.getErrorType(o), { error: n, data: null };
      } finally {
        s({
          baseApp: m,
          baseAppError: n,
          baseAppFetchStatus: _.IDLE
        });
      }
    },
    [t]
  );
  return {
    state: r,
    mutations: { fetchBaseApp: i }
  };
}
class Pe extends Error {
  constructor(r) {
    super(r), Object.setPrototypeOf(this, Pe.prototype);
  }
}
const Ct = 31142, Lt = {
  useDlcInformation: Dt
};
function Dt() {
  const [t] = Me(), [r, s] = Le({
    baseApp: null,
    isBaseAppOwned: null,
    appInfo: null,
    dlcInformationFetchStatus: _.IDLE,
    dlcInformationError: null
  }), i = ke(
    async ({
      country: a,
      language: l,
      user: c,
      dlcItem: m
    }) => {
      let n = null, o = null, d = null, g = null;
      try {
        if (!m.appId)
          throw new ve("");
        if (!m.baseAppId)
          throw new Pe("");
        s((w) => ({
          ...w,
          dlcInformationError: null,
          dlcInformationFetchStatus: _.FETCHING
        }));
        const h = ot.safeParse(c), [b, y, A] = await Promise.allSettled([
          ye.ItemApi(t).getAppLocale_ByItemId(m.itemId),
          ye.ItemApi(t).getItemsByAppId({
            appId: m.baseAppId,
            region: a,
            language: l
          }),
          h.success ? ye.EntitlementApi(t).getEntitlementsByAppId_ByUserId(h.data.userId, { appId: m.baseAppId }) : Promise.resolve(null)
        ]);
        if (b.status === "rejected")
          throw b.reason;
        if (y.status === "rejected")
          throw y.reason;
        if (A.status === "rejected")
          if (x.extractServiceErrorCode(A.reason) === Ct)
            d = !1;
          else
            throw A.reason;
        return d === null && (d = A.status === "fulfilled"), o = b.value, n = y.value, {
          error: null,
          data: {
            appInfo: o,
            baseApp: n,
            isBaseAppOwned: d
          }
        };
      } catch (h) {
        return g = we.getErrorType(h), { error: g, data: null };
      } finally {
        s({
          appInfo: o,
          baseApp: n,
          isBaseAppOwned: d,
          dlcInformationError: g,
          dlcInformationFetchStatus: _.IDLE
        });
      }
    },
    [t]
  );
  return {
    state: r,
    mutations: { fetchDlcInformation: i }
  };
}
class ve extends Error {
  constructor(r) {
    super(r), Object.setPrototypeOf(this, ve.prototype);
  }
}
const Ot = ({ baseApp: t, onClose: r }) => {
  const { state: s } = Y();
  return /* @__PURE__ */ e.createElement(st, { isOpen: !0, className: "purchaseBaseAppDialog" }, /* @__PURE__ */ e.createElement(it, null, /* @__PURE__ */ e.createElement(p, { i18nKey: "PurchaseBaseApp.lockedDownloadableContent.content" }, "This expansion requires the base game ", { appTitle: t.title }, " to play")), /* @__PURE__ */ e.createElement(lt, { className: "dialogFooter" }, /* @__PURE__ */ e.createElement("button", { onClick: r, className: "btn small btn-ghost btnCancel" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "PurchaseBaseApp.cancel" }, "Cancel")), /* @__PURE__ */ e.createElement(
    L,
    {
      to: s.store.apps.detail.makePath({
        params: { itemId: t.itemId }
      }),
      className: "btn small btn-primary btnGoToGamePage"
    },
    /* @__PURE__ */ e.createElement(p, { i18nKey: "PurchaseBaseApp.goToGamePage" }, "Go to the game page")
  )));
};
function vt({ baseApp: t }) {
  const [r, s] = Le(!1);
  return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("button", { className: "btn big btn-primary btnGoToLibrary", onClick: () => s(!0) }, /* @__PURE__ */ e.createElement(p, { i18nKey: "PurchaseBaseApp.goToLibrary" }, "GO TO LIBRARY")), r && /* @__PURE__ */ e.createElement(Ot, { baseApp: t, onClose: () => s(!1) }));
}
const Gt = ae(), Tt = J();
function or({ itemId: t, previewMode: r }) {
  const { state: s, closeLightbox: i, openLightbox: a } = Z.useStoreDetailCommonStates(), {
    state: { user: l }
  } = te(), { state: c } = Y(), { state: m } = de(), n = l == null ? void 0 : l.country, o = K(), {
    state: { itemLocale: d, itemLocaleError: g, itemLocaleFetchStatus: h },
    mutations: { fetchItemLocale: b }
  } = ee(Tt), {
    state: y,
    mutations: { fetchDlcInformation: A }
  } = Lt.useDlcInformation(), {
    state: { prepurchaseInformation: w },
    mutations: { prepareOrderProcess: U, resetState: $ }
  } = ge(), {
    state: { pendingOrders: H },
    mutations: { fetchPendingOrders: E, resetState: I }
  } = Se(), {
    state: { currencyMap: S },
    mutations: { fetchCurrencyMap: q }
  } = X();
  u(() => {
    S || q();
  }, [S]), u(() => {
    b({ itemId: t, language: o, country: n });
  }, [t, o, n]), u(() => {
    !S || !d || (U({ item: d, userId: l == null ? void 0 : l.userId, currencyMap: S }), l != null && l.userId && E({ itemId: d.itemId, userId: l.userId }));
  }, [d, l == null ? void 0 : l.userId, S]), u(() => {
    d && A({ dlcItem: d, user: l, country: n, language: o });
  }, [d, l, o]), u(() => () => {
    $(), I();
  }, []);
  const N = m.isSingleGame, { baseApp: P, appInfo: F, isBaseAppOwned: v, dlcInformationError: k, dlcInformationFetchStatus: C } = y, G = g || k, M = Ie.isMatchStatus([C, h], _.FETCHING);
  G && x.extractServiceErrorCode(G) === Q.ITEM_NOT_FOUND && V({ eventCategory: c.error.err404.link, eventLabel: x.errorToString(G) });
  const O = r ? Xe.data[2] : d, T = r ? Fe : P;
  G && x.extractServiceErrorCode(G) === Q.ITEM_NOT_FOUND && V({ eventCategory: c.error.err404.link, eventLabel: x.errorToString(G) });
  const { isLightboxOpen: Ge, selectedImagePosition: $e } = s, he = W.getMedia(d, null);
  return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
    re,
    {
      user: l,
      prepurchaseInformation: w,
      pendingOrders: H,
      isFetching: M
    }
  ), M && /* @__PURE__ */ e.createElement(ne, null), G && /* @__PURE__ */ e.createElement(fe, { error: G }), O && T && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { item: O, itemPublishingContent: null }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(L, { to: c.store.apps.index.link }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.games" }, "Games")), T && /* @__PURE__ */ e.createElement(L, { to: c.store.apps.detail.makePath({ params: { itemId: T.itemId } }) }, T.title), O.title)), he && /* @__PURE__ */ e.createElement(se, { itemMedias: he, openLightbox: a }), Ge && he && /* @__PURE__ */ e.createElement(ie, { itemMedias: he, isOpen: Ge, onClose: i, selectedPosition: $e }), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(le, { item: O }), F && /* @__PURE__ */ e.createElement(qe, { className: "requirementsDesktop", additionalAppInfo: F })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(me, { item: O }, S && /* @__PURE__ */ e.createElement(ce, { item: O, currencyMap: S, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(
    pe,
    {
      item: O,
      additionalAppInfo: F,
      launcherGoToLibraryButton: /* @__PURE__ */ e.createElement(Bt, { baseApp: T, dlcLocale: d, isBaseAppOwned: v }),
      previewMode: r
    }
  )), T && /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.requiredAppNotice" }, "Required Game"), /* @__PURE__ */ e.createElement(
    L,
    {
      to: be.isDesktopApp() && N ? c.game.index.link : c.store.apps.detail.makePath({ params: { itemId: T.itemId } })
    },
    T.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(
    ue,
    {
      store: Gt,
      baseItem: O,
      language: o,
      noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.inAppStore.noItem" }, "Looks like there are no related items yet.")),
      isPreviewMode: !!r
    }
  ))));
}
function Bt({
  baseApp: t,
  dlcLocale: r,
  isBaseAppOwned: s
}) {
  return r ? !t || s ? /* @__PURE__ */ e.createElement(We, { item: t || r }) : /* @__PURE__ */ e.createElement(vt, { baseApp: t }) : null;
}
const kt = ae(), xt = J();
function sr({ itemId: t }) {
  const { state: r, closeLightbox: s, openLightbox: i } = Z.useStoreDetailCommonStates(), {
    state: { user: a }
  } = te(), { state: l } = Y(), { state: c } = de(), m = a == null ? void 0 : a.country, n = K(), {
    state: { itemLocale: o, itemLocaleError: d, itemLocaleFetchStatus: g },
    mutations: { fetchItemLocale: h }
  } = ee(xt), {
    state: b,
    mutations: { fetchBaseApp: y }
  } = At.useBaseApp(), {
    state: { prepurchaseInformation: A },
    mutations: { prepareOrderProcess: w, resetState: U }
  } = ge(), {
    state: { pendingOrders: $ },
    mutations: { fetchPendingOrders: H, resetState: E }
  } = Se(), {
    state: { currencyMap: I },
    mutations: { fetchCurrencyMap: S }
  } = X();
  u(() => {
    I || S();
  }, [I]), u(() => {
    h({ itemId: t, language: n, country: m });
  }, [t, n, m]), u(() => {
    !I || !o || (w({ item: o, userId: a == null ? void 0 : a.userId, currencyMap: I }), a != null && a.userId && H({ itemId: o.itemId, userId: a.userId }));
  }, [o, a == null ? void 0 : a.userId, I]), u(() => {
    o && y({ baseAppId: o.baseAppId, country: m, language: n });
  }, [o == null ? void 0 : o.baseAppId, m, n]), u(() => () => {
    U(), E();
  }, []);
  const q = c.isSingleGame, { baseApp: N, baseAppError: P, baseAppFetchStatus: F } = b, v = d || P, k = Ie.isMatchStatus([F, g], _.FETCHING);
  v && x.extractServiceErrorCode(v) === Q.ITEM_NOT_FOUND && V({ eventCategory: l.error.err404.link, eventLabel: x.errorToString(v) });
  const { isLightboxOpen: C, selectedImagePosition: G } = r, M = W.getMedia(o, null);
  return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
    re,
    {
      user: a,
      prepurchaseInformation: A,
      pendingOrders: $,
      isFetching: k
    }
  ), k && /* @__PURE__ */ e.createElement(ne, null), v && /* @__PURE__ */ e.createElement(fe, { error: v }), o && N && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { item: o, itemPublishingContent: null }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(L, { to: l.store.apps.index.link }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.games" }, "Games")), /* @__PURE__ */ e.createElement(L, { to: l.store.apps.detail.makePath({ params: { itemId: N.itemId } }) }, N.title), o.title)), M && /* @__PURE__ */ e.createElement(se, { itemMedias: M, openLightbox: i }), C && M && /* @__PURE__ */ e.createElement(ie, { itemMedias: M, isOpen: C, onClose: s, selectedPosition: G }), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent container" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(le, { item: o })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(me, { item: o }, I && /* @__PURE__ */ e.createElement(ce, { item: o, currencyMap: I, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(pe, { item: o })), /* @__PURE__ */ e.createElement("div", { className: "requiredApp" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.requiredAppNotice" }, "Required Game"), /* @__PURE__ */ e.createElement(
    L,
    {
      to: be.isDesktopApp() && q ? l.game.index.link : l.game.detail.makePath({ params: { gameId: N.itemId } })
    },
    N.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(
    ue,
    {
      store: kt,
      baseItem: o,
      language: n,
      noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "InGameItemDetailPage.inAppStore.noItem" }, "Looks like there are no related items yet."))
    }
  ))));
}
const _t = "catalogOptionboxItemList _catalogOptionboxItemList_ee82e", Ft = {
  catalogOptionboxItemList: _t
}, Mt = ({ link: t, thumbnail: r, name: s, type: i, quantity: a }) => /* @__PURE__ */ e.createElement(L, { to: t, className: "catalogItem" }, /* @__PURE__ */ e.createElement("div", { className: "catalogItemImage" }, /* @__PURE__ */ e.createElement("img", { src: r || Ae, loading: "lazy" })), /* @__PURE__ */ e.createElement("div", { className: "catalogItemDetail" }, /* @__PURE__ */ e.createElement("div", { className: "catalogItemHeading" }, s), /* @__PURE__ */ e.createElement("div", { className: "catalogItemType" }, i), /* @__PURE__ */ e.createElement("div", { className: "catalogItemQty" }, a > 1 && `x${a}`)));
function wt({ items: t, optionboxItem: r }) {
  const { state: s } = Y(), i = t || [];
  return /* @__PURE__ */ e.createElement("div", { className: De(Ft.catalogOptionboxItemList, "catalogOptionboxItemList") }, /* @__PURE__ */ e.createElement("h2", { className: "catalogHeading" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "CatalogOptionboxItemList.heading" }, "Inside The Option Box")), i.length > 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogList" }, i.map((a) => {
    const l = a.appType || a.itemType, c = a.thumbnailUrl || Ae;
    return /* @__PURE__ */ e.createElement(
      Mt,
      {
        key: a.itemId,
        link: W.getItemDetailRoute(s, a),
        thumbnail: c,
        name: a.title || a.name || "",
        type: l,
        quantity: r.itemQty ? r.itemQty[a.itemId] : 1
      }
    );
  })), i.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "catalogNoItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "CatalogOptionboxItemList.noItem" }, "Looks like there aren't any optionbox item yet.")));
}
const Kt = ae(), Rt = J();
function ir({ itemId: t }) {
  const { state: r, closeLightbox: s, openLightbox: i } = Z.useStoreDetailCommonStates(), {
    state: { user: a }
  } = te(), { state: l } = Y(), c = a == null ? void 0 : a.country, m = K(), {
    state: { itemLocale: n, itemLocaleError: o, itemLocaleFetchStatus: d },
    mutations: { fetchItemLocale: g }
  } = ee(Rt), {
    state: h,
    mutations: { fetchBundleContents: b }
  } = Z.useBundleInformation(), {
    state: { prepurchaseInformation: y },
    mutations: { prepareOrderProcess: A, resetState: w }
  } = ge(), {
    state: { pendingOrders: U },
    mutations: { fetchPendingOrders: $, resetState: H }
  } = Se(), {
    state: { currencyMap: E },
    mutations: { fetchCurrencyMap: I }
  } = X();
  u(() => {
    E || I();
  }, [E]), u(() => {
    g({ itemId: t, language: m, country: c });
  }, [t, m, c]), u(() => {
    !E || !n || (A({ item: n, userId: a == null ? void 0 : a.userId, currencyMap: E }), a != null && a.userId && $({ itemId: n.itemId, userId: a.userId }));
  }, [n, a == null ? void 0 : a.userId, E]), u(() => {
    var M, O;
    if (!n)
      return;
    const G = (O = (M = n.optionBoxConfig) == null ? void 0 : M.boxItems) == null ? void 0 : O.filter(({ itemId: T }) => !!T).map(({ itemId: T }) => T);
    b({ itemIds: G || [], country: c, language: m });
  }, [n, c, m]), u(() => () => {
    w(), H();
  }, []);
  const { bundleInfoError: S, bundleInfoFetchStatus: q, items: N } = h, P = o || S, F = Ie.isMatchStatus([q, d], _.FETCHING);
  P && x.extractServiceErrorCode(P) === Q.ITEM_NOT_FOUND && V({ eventCategory: l.error.err404.link, eventLabel: x.errorToString(P) });
  const { isLightboxOpen: v, selectedImagePosition: k } = r, C = W.getMedia(n, null);
  return /* @__PURE__ */ e.createElement("main", { className: "itemDetailPage" }, /* @__PURE__ */ e.createElement(
    re,
    {
      user: a,
      prepurchaseInformation: y,
      pendingOrders: U,
      isFetching: F
    }
  ), F && /* @__PURE__ */ e.createElement(ne, null), P && /* @__PURE__ */ e.createElement(fe, { error: P }), n && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { item: n, itemPublishingContent: null }, /* @__PURE__ */ e.createElement(Ee, null, /* @__PURE__ */ e.createElement(L, { to: l.store.apps.index.link }, /* @__PURE__ */ e.createElement(p, { i18nKey: "Navigation.links.games" }, "Games")), n.title)), C && /* @__PURE__ */ e.createElement(se, { itemMedias: C, openLightbox: i }), v && C && /* @__PURE__ */ e.createElement(ie, { itemMedias: C, isOpen: v, onClose: s, selectedPosition: k }), /* @__PURE__ */ e.createElement("div", { className: "itemDetailContent" }, /* @__PURE__ */ e.createElement("div", { className: "description" }, /* @__PURE__ */ e.createElement(wt, { items: N, optionboxItem: n }), /* @__PURE__ */ e.createElement(le, { item: n })), /* @__PURE__ */ e.createElement("div", { className: "detailWidget" }, /* @__PURE__ */ e.createElement(me, { item: n }, E && /* @__PURE__ */ e.createElement(ce, { item: n, currencyMap: E, position: "right", showDetail: !0 })), /* @__PURE__ */ e.createElement("div", { className: "protruded" }, /* @__PURE__ */ e.createElement(pe, { item: n })))), /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ e.createElement("h2", null, /* @__PURE__ */ e.createElement(p, { i18nKey: "OptionboxItemDetailPage.relatedItems.heading" }, "Related Items")), /* @__PURE__ */ e.createElement(
    ue,
    {
      store: Kt,
      baseItem: n,
      language: m,
      itemType: B.enum.OPTIONBOX,
      noItemMessage: /* @__PURE__ */ e.createElement("div", { className: "noItem" }, /* @__PURE__ */ e.createElement(p, { i18nKey: "OptionboxItemDetailPage.relatedItems.noItem" }, "Looks like there are no related items yet."))
    }
  ))));
}
class R {
}
R.SINGLE_GAME_STORE_PAGE_SIZE = 100;
R.MULTIPLE_GAME_STORE_PAGE_SIZE = 16;
const Ut = ({ numberOfCards: t = 8 }) => /* @__PURE__ */ e.createElement(e.Fragment, null, Array.from(new Array(t)).map((r, s) => /* @__PURE__ */ e.createElement("div", { className: "storeGridItem", key: s }, /* @__PURE__ */ e.createElement("div", { className: "skeletonContainer" }), /* @__PURE__ */ e.createElement("div", { className: "title w-max" }, /* @__PURE__ */ e.createElement(Te, null)), /* @__PURE__ */ e.createElement("div", { className: "paymentOptions -mb-5 w-max" }, /* @__PURE__ */ e.createElement(Te, null)))));
function Ce({ baseAppId: t, page: r, itemType: s, country: i, language: a, pageSize: l, plan: c, children: m, store: n }) {
  const { state: o, mutations: d } = Ze(n), { state: g, mutations: h } = X();
  u(() => {
    d.fetchItemsByCriteria({
      queryParams: {
        baseAppId: t,
        page: r,
        pageSize: l,
        country: i,
        language: a,
        plan: c,
        itemType: s
      }
    });
  }, [t, r, l, i, a, c, s]), u(() => {
    h.fetchCurrencyMap();
  }, []);
  const b = o.itemsFetchStatus === _.FETCHING || g.currencyMapFetchStatus === _.FETCHING, y = o.itemsError || g.currencyMapError;
  return /* @__PURE__ */ e.createElement("div", { className: "storeContainer" }, m, b && /* @__PURE__ */ e.createElement(Ke, null), !b && y && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(Re, { error: y })), !b && !y && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement($t, { itemsList: o.items, currencyMap: g.currencyMap }), /* @__PURE__ */ e.createElement(Ht, { itemsList: o.items, currentPage: r })));
}
function $t({
  itemsList: t,
  currencyMap: r
}) {
  return /* @__PURE__ */ e.createElement("div", { className: "itemsList" }, !r && /* @__PURE__ */ e.createElement(Ut, { numberOfCards: t == null ? void 0 : t.data.length }), !!t && r && t.data.map((s) => /* @__PURE__ */ e.createElement(je, { key: s.itemId, item: s, currencyMap: r })));
}
function Ht({ itemsList: t, currentPage: r }) {
  const {
    state: { location: s }
  } = Oe();
  if (!t)
    return null;
  const { paging: i } = t, a = !!(i != null && i.next), l = !!(i != null && i.previous);
  return /* @__PURE__ */ e.createElement("div", { className: "pagination" }, /* @__PURE__ */ e.createElement(
    nt,
    {
      next: a && Be(s, r + 1),
      prev: l && Be(s, r - 1)
    }
  ));
}
function Be(t, r) {
  const s = new URLSearchParams((t == null ? void 0 : t.search) || "");
  return s.set("page", `${r}`), `${(t == null ? void 0 : t.pathname) || ""}?${s.toString()}`;
}
const qt = j(), lr = ({ pageSize: t = R.MULTIPLE_GAME_STORE_PAGE_SIZE, ...r }) => {
  const { state: s } = Oe(), i = mt.silentSearchParamsBuilder(s.location.search).get("plan") || void 0;
  return /* @__PURE__ */ e.createElement(Ce, { ...r, pageSize: t, itemType: B.Enum.APP, plan: i, store: qt });
}, Wt = j(), mr = ({ baseItem: t }) => t ? /* @__PURE__ */ e.createElement(
  Ne,
  {
    store: Wt,
    baseItem: t,
    itemType: B.enum.APP,
    appType: Ue.enum.DLC,
    pageSize: R.SINGLE_GAME_STORE_PAGE_SIZE,
    language: K(),
    noItemMessage: /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.inAppStore.noItem" }, "Looks like there aren`t any items for this game yet.")
  }
) : null, Zt = j(), cr = ({ pageSize: t = R.MULTIPLE_GAME_STORE_PAGE_SIZE, ...r }) => /* @__PURE__ */ e.createElement(Ce, { ...r, itemType: B.Enum.CODE, store: Zt }), jt = j(), pr = ({ pageSize: t = R.MULTIPLE_GAME_STORE_PAGE_SIZE, ...r }) => /* @__PURE__ */ e.createElement(Ce, { ...r, itemType: B.Enum.BUNDLE, pageSize: t, store: jt }), zt = j(), ur = ({ baseItem: t }) => t ? /* @__PURE__ */ e.createElement(
  Ne,
  {
    store: zt,
    baseItem: t,
    itemType: B.enum.BUNDLE,
    pageSize: R.SINGLE_GAME_STORE_PAGE_SIZE,
    language: K(),
    noItemMessage: /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.inAppStore.noItem" }, "Looks like there aren`t any items for this game yet.")
  }
) : null, Qt = j(), dr = ({ baseItem: t }) => t ? /* @__PURE__ */ e.createElement(
  Ne,
  {
    store: Qt,
    baseItem: t,
    itemType: B.enum.INGAMEITEM,
    pageSize: R.SINGLE_GAME_STORE_PAGE_SIZE,
    language: K(),
    noItemMessage: /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.inAppStore.noItem" }, "Looks like there aren`t any items for this game yet.")
  }
) : null, Xt = j(), Er = ({ pageSize: t = R.MULTIPLE_GAME_STORE_PAGE_SIZE, ...r }) => /* @__PURE__ */ e.createElement(Ce, { ...r, itemType: B.Enum.OPTIONBOX, pageSize: t, store: Xt }), Yt = j(), Ir = ({ baseItem: t }) => t ? /* @__PURE__ */ e.createElement(
  Ne,
  {
    store: Yt,
    baseItem: t,
    itemType: B.enum.OPTIONBOX,
    pageSize: R.SINGLE_GAME_STORE_PAGE_SIZE,
    language: K(),
    noItemMessage: /* @__PURE__ */ e.createElement(p, { i18nKey: "AppDetailPage.inAppStore.noItem" }, "Looks like there aren`t any items for this game yet.")
  }
) : null;
export {
  lr as AppStore,
  fr as AppStoreDetail,
  hr as AppStoreDetailError,
  pr as BundleStore,
  rr as BundleStoreDetail,
  cr as CodeStore,
  nr as CodeStoreDetail,
  or as DlcStoreDetail,
  sr as IngameItemStoreDetail,
  er as MultipleGameStore,
  Er as OptionboxStore,
  ir as OptionboxStoreDetail,
  mr as SingleGameAppStore,
  ur as SingleGameBundleStore,
  Ir as SingleGameOptionboxStore,
  tr as SingleGameStore,
  ar as SingleGameStoreWrapper,
  dr as SingleInGameItemsStore,
  Ja as StoreEntry,
  Va as StoreWidget
};
