import { a as s, ad as c, ab as n, F as l, t as u, av as g, i as d } from "./index-162fd1aa.mjs";
import { P as h } from "./Pagination-a353297b.mjs";
import { w as p } from "./WithPropsGuard-9dd19ecc.mjs";
import { I as S, S as E } from "./StorePage-6e44d537.mjs";
import r from "react";
import { H as f } from "./Helmet-ed6d5573.mjs";
import { S as y } from "./ItemDetailPurchaseAlert-3cdb1ea7.mjs";
import "./dateFns-2367ee5b.mjs";
import "./validator-61879ab7.mjs";
import "./reactPlayer-2f69f369.mjs";
import "react-router-dom";
import "./reactSlick-cb4a2d39.mjs";
import "./CommonError-0ae83068.mjs";
import "./starBgGradient-589e5185.mjs";
import "./CommonError-4ed993c7.mjs";
import "./Tabs-8498653e.mjs";
import "./NavItemPlaceholder-0cfc6c3b.mjs";
import "./AppDetailPage-d989694b.mjs";
import "./ItemHelper-37a12c2c.mjs";
import "./PlatformRequirements-fc8525b3.mjs";
import "./MockVars-1cf2eb0a.mjs";
import "./default-item-image-9aab0e29.mjs";
import "./SuccessFlatIcon-54f5f907.mjs";
import "./WarningIcon-c5874dd2.mjs";
import "./PendingOrdersAppManager-4782fef4.mjs";
import "./PaymentStatusDialog-3afb3b20.mjs";
import "./Radio-b897ba55.mjs";
class A extends r.Component {
  constructor(t) {
    super(t), this.logic = new S(s.getAppState().getSdk()), this.logic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    const { page: t, pageSize: e, country: a, language: i, plan: m } = this.props;
    this.logic.getItemsByCriteria({
      page: t,
      pageSize: e,
      country: a,
      language: i,
      plan: m,
      itemType: c.enum.APP
    }), this.logic.getCurrencyMap();
  }
  renderGameItems() {
    const { platformItemsList: t, currencyMap: e } = this.logic.state;
    return /* @__PURE__ */ r.createElement("div", { className: "appsList" }, !e && /* @__PURE__ */ r.createElement(E, { numberOfCards: t == null ? void 0 : t.data.length }), !!t && e && t.data.map((a) => /* @__PURE__ */ r.createElement(y, { key: a.itemId, item: a, currencyMap: e })));
  }
  renderGamePagination() {
    const { platformItemsList: t } = this.logic.state;
    if (!t)
      return;
    const { paging: e } = t, a = !!(e != null && e.next), i = !!(e != null && e.previous), m = this.props.page;
    return /* @__PURE__ */ r.createElement("div", { className: "pagination" }, /* @__PURE__ */ r.createElement(
      h,
      {
        next: a && n.GameList.withSearchParams({
          page: m + 1
        }),
        prev: i && n.GameList.withSearchParams({
          page: m - 1
        })
      }
    ));
  }
  render() {
    const { error: t, isFetching: e, platformItemsList: a } = this.logic.state;
    return /* @__PURE__ */ r.createElement("div", { className: "storeContainer" }, /* @__PURE__ */ r.createElement(f, null, /* @__PURE__ */ r.createElement("title", null, l.makeTitleWithAppName(u("AppStore.title")))), e && /* @__PURE__ */ r.createElement(g, null), !e && t && /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(d, { error: t })), !e && a && this.renderGameItems(), !e && a && this.renderGamePagination());
  }
}
const G = p(A, (o, t) => o.country !== t.country), Q = p(
  ({ page: o, pageSize: t, language: e, plan: a }) => {
    const i = s.getAppState().getUser(), m = i && i.country || void 0;
    return /* @__PURE__ */ r.createElement(G, { page: o, pageSize: t, country: m, language: e, plan: a });
  },
  (o, t) => t.page !== o.page || t.language !== o.language || t.plan !== o.plan
);
export {
  A as AppStore,
  Q as default
};
