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