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