import { jsxs as a, jsx as r } from "react/jsx-runtime";
import { useState as p, useEffect as u } from "react";
import { s as t, c as m, f as d, d as f, u as S, F as y } from "./index2.js";
import { u as v, i as h } from "./app.js";
import { S as g } from "./useStreamLayerApp2.js";
const A = /* @__PURE__ */ t("div")({
  name: "PointsContainer",
  class: "psiob9b",
  propsAsIs: !1
}), I = /* @__PURE__ */ t("div")({
  name: "PointsIcon",
  class: "p1gqe4lh",
  propsAsIs: !1
}), P = () => m, k = /* @__PURE__ */ t(P())({
  name: "PointsSvg",
  class: "p15syg2y",
  propsAsIs: !0
}), b = /* @__PURE__ */ t("div")({
  name: "PointsBody",
  class: "p12n4f2h",
  propsAsIs: !1
}), x = /* @__PURE__ */ t("div")({
  name: "PointsTitle",
  class: "poqmx89",
  propsAsIs: !1
}), C = /* @__PURE__ */ t("div")({
  name: "PointsValue",
  class: "prj9b3v",
  propsAsIs: !1
}), F = ({ points: s, onClick: e }) => /* @__PURE__ */ a(A, { className: d, onClick: e, children: [
  /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(k, { name: "icon-trophy" }) }),
  /* @__PURE__ */ a(b, { children: [
    /* @__PURE__ */ r(x, { children: "Total points" }),
    /* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(f, { value: s }) })
  ] })
] }), L = ({ gamification: s }) => {
  const e = s.userSummary.$store, [i, l] = p(0);
  return u(() => {
    const c = e.subscribe((n) => {
      var o;
      (o = n == null ? void 0 : n.summary) != null && o.points && l(n.summary.points);
    });
    return () => {
      c();
    };
  }, [e]), /* @__PURE__ */ r(F, { points: i, onClick: () => {
    s.status.get() === y.Suspended && s.openFeature();
  } });
}, j = ({ sdk: s }) => {
  if (!S(s.featuresList.getStore()))
    return null;
  const e = s.getFeature(g.GAMES);
  return e ? /* @__PURE__ */ r(L, { gamification: e }) : null;
}, K = () => {
  const s = v();
  return s ? /* @__PURE__ */ r("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ r(h, { children: /* @__PURE__ */ r(j, { sdk: s }) }) }) : null;
};
export {
  K as StreamLayerSDKPoints
};
