import { CommonError as l } from "./accelbyte-widgets124.mjs";
import { Loading as u, LoadingSize as g } from "./accelbyte-widgets136.mjs";
import { Pagination as d } from "./accelbyte-widgets256.mjs";
import { t as s } from "./accelbyte-widgets58.mjs";
import p from "./accelbyte-widgets210.mjs";
import { SkeletonGameCards as h } from "./accelbyte-widgets531.mjs";
import { Ctx as i } from "./accelbyte-widgets33.mjs";
import { ItemType as S } from "./accelbyte-widgets185.mjs";
import { EcomPath as c } from "./accelbyte-widgets59.mjs";
import { PageTitleUtils as f } from "./accelbyte-widgets188.mjs";
import { ItemListingAppManager as E } from "./accelbyte-widgets532.mjs";
import r from "react";
import { Helmet as L } from "react-helmet";
import { Trans as y } from "react-i18next";
import "./accelbyte-widgets534.mjs";
import { StoreGridItem as B } from "./accelbyte-widgets416.mjs";
class P extends r.Component {
  constructor(e) {
    super(e), this.appStoreLogic = new E(i.getAppState().getSdk()), this.appStoreLogic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    const { page: e, pageSize: t, country: a, language: n } = this.props;
    this.appStoreLogic.getItemsByCriteria({ page: e, pageSize: t, country: a, language: n, itemType: S.enum.BUNDLE }), this.appStoreLogic.getCurrencyMap();
  }
  renderBundleItems() {
    const { platformItemsList: e, currencyMap: t } = this.appStoreLogic.state;
    return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement("div", { className: "bundlesList" }, !t && /* @__PURE__ */ r.createElement(h, { numberOfCards: e == null ? void 0 : e.data.length }), !!e && t && e.data.map((a) => /* @__PURE__ */ r.createElement(B, { key: a.itemId, item: a, currencyMap: t }))));
  }
  renderGamePagination() {
    const { platformItemsList: e } = this.appStoreLogic.state;
    if (!e)
      return;
    const { paging: t } = e, a = !!(t != null && t.next), n = !!(t != null && t.previous), m = this.props.page;
    return /* @__PURE__ */ r.createElement("div", { className: "pagination" }, /* @__PURE__ */ r.createElement(
      d,
      {
        next: a && c.BundleList.withSearchParams({ page: m + 1 }),
        prev: n && c.BundleList.withSearchParams({ page: m - 1 })
      }
    ));
  }
  render() {
    const { error: e, isFetching: t, platformItemsList: a } = this.appStoreLogic.state;
    return /* @__PURE__ */ r.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ r.createElement(L, null, /* @__PURE__ */ r.createElement("title", null, f.getPageTitle(i.getAppState().state.discovery || null, s("BundleStore.title"), s("BundleStore.title")))), t && /* @__PURE__ */ r.createElement(u, { className: g.medium }, /* @__PURE__ */ r.createElement(y, { i18nKey: "InitialUserFetchPage.notice" })), !t && e && /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(l, { error: e })), !t && a && this.renderBundleItems(), !t && a && this.renderGamePagination());
  }
}
const I = p(P, (o, e) => o.country !== e.country), H = p(
  ({ page: o, pageSize: e, language: t }) => {
    const a = i.getAppState().getUser(), n = a && a.country || void 0;
    return /* @__PURE__ */ r.createElement(I, { page: o, pageSize: e, country: n, language: t });
  },
  (o, e) => e.page !== o.page || e.language !== o.language
);
export {
  P as BundleStore,
  H as default
};
