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