import { S as Z, b as K, s as V, f as I, d as Q, n as C, e as L, C as X, D as Y, g as k, p as y, l as p, m as f, N as J, w as $, o as ee, A as te, L as z, M as N, j as se, E as M, F as P, h as H, k as E, t as S, I as re, J as le, K as ie, c as ne } from "./CasinoGameOverlay-BPPzj3qo.js";
import { f as oe } from "./LotteryProgramWof-CfqijiFp.js";
import { $ as T, b as ae, a as ce, i as he, c as ue } from "./CasinoMysteryChestContainer-BLcBHE6I.js";
import { f as me } from "./CasinoMysteryChestsList-qoTia4kI.js";
import "../stencil/ui-skeleton-W50o8tfg.js";
const D = {
  en: {
    History: "History",
    NoHistories: "No histories"
  }
};
function fe({ withLocale: l, translations: e }) {
  T.subscribe((t) => {
    t == null && (ae.set(e), T.set(l));
  });
}
function W(l, e) {
  ce(l, e);
}
function ye(l) {
  T.set(l);
}
const de = () => {
  fe({ withLocale: "en", translations: {} }), Object.keys(D).forEach((l) => {
    W(l, D[l]);
  });
}, F = async (l, e, t, s = {}) => {
  const r = new URL(l + "/v1" + e);
  s.params && Object.keys(s.params).forEach((m) => r.searchParams.append(m, s.params[m]));
  const o = {
    method: s.method || "GET",
    headers: {
      "Content-Type": "application/json",
      Accept: "text/plain",
      ...t ? { "x-SessionId": t } : {},
      ...s.headers
    },
    body: s.body
  }, n = await (await fetch(r.toString(), o)).text();
  return JSON.parse(n);
}, ve = {
  fetchLotteries: async (l, e, t) => await F(l, "/wof/lotteries", e, {
    params: t?.length ? { filter: t.map((s) => `Types[]=${s}`).join(",") } : { filter: "Types[]=wheelOfFortune" }
  }),
  fetchFullHistory: async (l, e, t, s) => {
    const r = (a) => {
      const _ = new URL(l + "/v1" + a);
      return s?.length && s.forEach((w) => _.searchParams.append("filter", `Types[]=${w}`)), _.toString();
    }, o = async (a) => (await fetch(r(a), {
      headers: {
        "Content-Type": "application/json",
        Accept: "text/plain",
        ...e ? { "x-SessionId": e } : {}
      }
    })).json(), [i, n] = await Promise.all([
      o("/wof/lotteryHistory"),
      o("/wof/lotteries")
    ]), m = n?.items || [], g = i?.items || [], u = new Set(m.map((a) => a.program.id)), h = g.map((a) => a.programID).filter((a) => u.has(a));
    return h.length === 0 ? [] : (await Promise.all(
      h.map(async (a) => {
        const _ = await F(l, `/wof/outcome/${a}`, e), w = m.find((v) => v.program.id === a);
        if (!_?.items?.length)
          return null;
        const x = _.items.map((v) => {
          const b = v.draw.result.wheelOfFortunePartitionIndex, c = w?.program?.wheelOfFortune?.partitions[b];
          return {
            prizeName: c?.name?.[t] || c?.name?.["*"],
            prizeImage: c?.prizeImage?.[t] || c?.prizeImage?.["*"] || c?.image1?.[t] || c?.image1?.["*"],
            state: v.draw.state === "fulfilled",
            date: me(new Date(v.draw.time), "LLL d, yyyy HH:mm:ss")
          };
        });
        return {
          id: a,
          name: w?.program?.name[t] || w?.program?.name["*"] || "Unknown Game",
          outcomes: x
        };
      })
    )).filter((a) => a !== null);
  }
}, A = "data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M15.1724%204.72381C15.4708%205.02223%2015.4708%205.50607%2015.1724%205.80449L7.70071%2013.2762C7.40229%2013.5746%206.91846%2013.5746%206.62004%2013.2762L3.22381%209.87996C2.9254%209.58154%202.9254%209.09771%203.22381%208.79929C3.52223%208.50087%204.00607%208.50087%204.30449%208.79929L7.16038%2011.6552L14.0917%204.72381C14.3902%204.4254%2014.874%204.4254%2015.1724%204.72381Z'%20fill='%2358DB4A'/%3e%3c/svg%3e", G = "data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M3.96967%203.96967C4.26256%203.67678%204.73744%203.67678%205.03033%203.96967L9%207.93934L12.9697%203.96967C13.2626%203.67678%2013.7374%203.67678%2014.0303%203.96967C14.3232%204.26256%2014.3232%204.73744%2014.0303%205.03033L10.0607%209L14.0303%2012.9697C14.3232%2013.2626%2014.3232%2013.7374%2014.0303%2014.0303C13.7374%2014.3232%2013.2626%2014.3232%2012.9697%2014.0303L9%2010.0607L5.03033%2014.0303C4.73744%2014.3232%204.26256%2014.3232%203.96967%2014.0303C3.67678%2013.7374%203.67678%2013.2626%203.96967%2012.9697L7.93934%209L3.96967%205.03033C3.67678%204.73744%203.67678%204.26256%203.96967%203.96967Z'%20fill='%23FF9B59'/%3e%3c/svg%3e";
function ge(l) {
  Q(l, "svelte-1r6yeh4", ':host{display:block;height:100%;flex-grow:1}.PrizeHistoryContent.svelte-1r6yeh4.svelte-1r6yeh4{width:100%;height:100%;display:flex;flex-direction:column;font-family:var(--emw--font-family-primary, "Ubuntu", sans-serif);margin:30px auto}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4,.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4{overflow-y:auto}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar,.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar{width:4px}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-track,.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-track{background:transparent}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-thumb,.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-thumb{background:var(--emw--color-gray-105, #1b2e31);border-radius:2px}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-thumb:hover,.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4::-webkit-scrollbar-thumb:hover{background:var(--emw--color-gray-290, #284044)}.HistoryList.svelte-1r6yeh4.svelte-1r6yeh4{flex-grow:1;display:flex;flex-direction:column;gap:24px;padding-right:10px;padding-bottom:50px}.HistoryItem.svelte-1r6yeh4.svelte-1r6yeh4{margin-bottom:40px;flex-shrink:0}.GroupName.svelte-1r6yeh4.svelte-1r6yeh4{color:var(--emw--color-white, #ffffff);font-size:var(--emw--font-size-medium, 16px);font-weight:700;line-height:18px;margin-bottom:16px}.OutcomesList.svelte-1r6yeh4.svelte-1r6yeh4{max-height:215px;display:flex;flex-direction:column}.OutcomeItem.svelte-1r6yeh4.svelte-1r6yeh4{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid var(--emw--color-gray-transparency-20, rgba(114, 151, 135, 0.2));color:var(--emw--color-primary-variant, #a9ccbe);min-height:40px}.OutcomeItem.svelte-1r6yeh4 .OutcomeLeft.svelte-1r6yeh4{display:flex;align-items:center;gap:16px}.OutcomeItem.svelte-1r6yeh4 .PrizeInfo.svelte-1r6yeh4{display:flex;align-items:center;gap:8px}.OutcomeItem.svelte-1r6yeh4 .PrizeInfo .PrizeImg.svelte-1r6yeh4{height:20px}.OutcomeItem.svelte-1r6yeh4 .PrizeInfo .StatusIcon.svelte-1r6yeh4{height:16px}.OutcomeItem.svelte-1r6yeh4 .Date.svelte-1r6yeh4{font-size:var(--emw--font-size-small, 14px)}.HistoryLoader.svelte-1r6yeh4.svelte-1r6yeh4{display:flex;flex-direction:column;gap:16px;margin-bottom:32px}.HistoryLoader.svelte-1r6yeh4 .Skeleton{border-radius:var(--emw--border-radius-small, 12px);--emw-skeleton-primary-color:var(--emw--color-primary, #d9d9d9);--emw-skeleton-secondary-color:var(--emw--color-secondary, #999999);--emw-skeleton-text-width:255px}.HistoryLoader.svelte-1r6yeh4 .GroupLoader.svelte-1r6yeh4{display:flex;flex-direction:column;gap:16px;margin-bottom:32px}.HistoryLoader.svelte-1r6yeh4 .LoaderBody.svelte-1r6yeh4{display:flex;justify-content:space-between}.HistoryLoader.svelte-1r6yeh4 .LoaderLeft.svelte-1r6yeh4{display:flex}.HistoryLoader.svelte-1r6yeh4 .Dot.svelte-1r6yeh4 .Skeleton{border-radius:50%;margin-right:10px}.HistoryLoader.svelte-1r6yeh4 .Text.svelte-1r6yeh4 .Skeleton{margin-right:20px}.HistoryLoader.Mobile.svelte-1r6yeh4 .Skeleton{--emw-skeleton-text-width:235px}.EmptyState.svelte-1r6yeh4.svelte-1r6yeh4{display:flex;justify-content:center;align-items:center;height:200px;color:var(--emw--color-secondary-variant, #a9ccbe)}.Mobile.svelte-1r6yeh4 .GroupName.svelte-1r6yeh4{font-size:var(--emw--font-size-small, 14px)}.Mobile.svelte-1r6yeh4 .OutcomeItem.svelte-1r6yeh4{font-size:var(--emw--font-size-x-small, 12px);padding:0}.Mobile.svelte-1r6yeh4 .OutcomeItem .Date.svelte-1r6yeh4{font-size:11px}');
}
function R(l, e, t) {
  const s = l.slice();
  return s[21] = e[t], s;
}
function U(l, e, t) {
  const s = l.slice();
  return s[24] = e[t], s[26] = t, s;
}
function pe(l, e, t) {
  const s = l.slice();
  return s[16] = e[t], s;
}
function _e(l, e, t) {
  const s = l.slice();
  return s[16] = e[t], s;
}
function be(l) {
  let e, t, s = (
    /*$_*/
    l[3]("NoHistories") + ""
  ), r;
  return {
    c() {
      e = p("div"), t = p("p"), r = P(s), f(e, "class", "EmptyState svelte-1r6yeh4");
    },
    m(o, i) {
      k(o, e, i), y(e, t), y(t, r);
    },
    p(o, i) {
      i & /*$_*/
      8 && s !== (s = /*$_*/
      o[3]("NoHistories") + "") && M(r, s);
    },
    d(o) {
      o && L(e);
    }
  };
}
function we(l) {
  let e, t = z(
    /*historyData*/
    l[2]
  ), s = [];
  for (let r = 0; r < t.length; r += 1)
    s[r] = q(R(l, t, r));
  return {
    c() {
      for (let r = 0; r < s.length; r += 1)
        s[r].c();
      e = se();
    },
    m(r, o) {
      for (let i = 0; i < s.length; i += 1)
        s[i] && s[i].m(r, o);
      k(r, e, o);
    },
    p(r, o) {
      if (o & /*historyData*/
      4) {
        t = z(
          /*historyData*/
          r[2]
        );
        let i;
        for (i = 0; i < t.length; i += 1) {
          const n = R(r, t, i);
          s[i] ? s[i].p(n, o) : (s[i] = q(n), s[i].c(), s[i].m(e.parentNode, e));
        }
        for (; i < s.length; i += 1)
          s[i].d(1);
        s.length = t.length;
      }
    },
    d(r) {
      r && L(e), N(s, r);
    }
  };
}
function xe(l) {
  let e, t = z([1, 2, 3]), s = [];
  for (let r = 0; r < 3; r += 1)
    s[r] = He(pe(l, t, r));
  return {
    c() {
      e = p("div");
      for (let r = 0; r < 3; r += 1)
        s[r].c();
      f(e, "class", "HistoryLoader svelte-1r6yeh4"), J(
        e,
        "Mobile",
        /*mobileView*/
        l[4]
      );
    },
    m(r, o) {
      k(r, e, o);
      for (let i = 0; i < 3; i += 1)
        s[i] && s[i].m(e, null);
    },
    p: C,
    d(r) {
      r && L(e), N(s, r);
    }
  };
}
function Le(l) {
  let e, t;
  return {
    c() {
      e = p("img"), S(e.src, t = /*outcome*/
      l[24].prizeImage) || f(e, "src", t), f(e, "alt", "prize"), f(e, "class", "PrizeImg svelte-1r6yeh4");
    },
    m(s, r) {
      k(s, e, r);
    },
    p(s, r) {
      r & /*historyData*/
      4 && !S(e.src, t = /*outcome*/
      s[24].prizeImage) && f(e, "src", t);
    },
    d(s) {
      s && L(e);
    }
  };
}
function ke(l) {
  let e, t = (
    /*outcome*/
    l[24].prizeName + ""
  ), s;
  return {
    c() {
      e = p("span"), s = P(t);
    },
    m(r, o) {
      k(r, e, o), y(e, s);
    },
    p(r, o) {
      o & /*historyData*/
      4 && t !== (t = /*outcome*/
      r[24].prizeName + "") && M(s, t);
    },
    d(r) {
      r && L(e);
    }
  };
}
function B(l) {
  let e, t, s, r, o, i, n, m, g, u, h, d = (
    /*outcome*/
    l[24].date + ""
  ), a, _;
  function w(b, c) {
    if (
      /*outcome*/
      b[24].prizeName
    )
      return ke;
    if (
      /*outcome*/
      b[24].prizeImage
    )
      return Le;
  }
  let x = w(l), v = x && x(l);
  return {
    c() {
      e = p("div"), t = p("div"), s = p("span"), s.textContent = `${/*index*/
      l[26] + 1}`, r = H(), o = p("div"), v && v.c(), i = H(), n = p("img"), g = H(), u = p("div"), h = p("span"), a = P(d), _ = H(), f(s, "class", "Index"), S(n.src, m = /*outcome*/
      l[24].state ? A : G) || f(n, "src", m), f(n, "alt", "status"), f(n, "class", "StatusIcon svelte-1r6yeh4"), f(o, "class", "PrizeInfo svelte-1r6yeh4"), f(t, "class", "OutcomeLeft svelte-1r6yeh4"), f(h, "class", "Date svelte-1r6yeh4"), f(u, "class", "OutcomeRight"), f(e, "class", "OutcomeItem svelte-1r6yeh4");
    },
    m(b, c) {
      k(b, e, c), y(e, t), y(t, s), y(t, r), y(t, o), v && v.m(o, null), y(o, i), y(o, n), y(e, g), y(e, u), y(u, h), y(h, a), y(e, _);
    },
    p(b, c) {
      x === (x = w(b)) && v ? v.p(b, c) : (v && v.d(1), v = x && x(b), v && (v.c(), v.m(o, i))), c & /*historyData*/
      4 && !S(n.src, m = /*outcome*/
      b[24].state ? A : G) && f(n, "src", m), c & /*historyData*/
      4 && d !== (d = /*outcome*/
      b[24].date + "") && M(a, d);
    },
    d(b) {
      b && L(e), v && v.d();
    }
  };
}
function q(l) {
  let e, t, s = (
    /*group*/
    l[21].name + ""
  ), r, o, i, n, m, g = z(
    /*group*/
    l[21].outcomes
  ), u = [];
  for (let h = 0; h < g.length; h += 1)
    u[h] = B(U(l, g, h));
  return {
    c() {
      e = p("div"), t = p("div"), r = P(s), o = H(), i = p("div");
      for (let h = 0; h < u.length; h += 1)
        u[h].c();
      m = H(), f(t, "class", "GroupName svelte-1r6yeh4"), f(i, "class", "OutcomesList svelte-1r6yeh4"), f(i, "style", n = /*group*/
      l[21].outcomes.length <= 5 ? "overflow: hidden;" : ""), f(e, "class", "HistoryItem svelte-1r6yeh4");
    },
    m(h, d) {
      k(h, e, d), y(e, t), y(t, r), y(e, o), y(e, i);
      for (let a = 0; a < u.length; a += 1)
        u[a] && u[a].m(i, null);
      y(e, m);
    },
    p(h, d) {
      if (d & /*historyData*/
      4 && s !== (s = /*group*/
      h[21].name + "") && M(r, s), d & /*historyData*/
      4) {
        g = z(
          /*group*/
          h[21].outcomes
        );
        let a;
        for (a = 0; a < g.length; a += 1) {
          const _ = U(h, g, a);
          u[a] ? u[a].p(_, d) : (u[a] = B(_), u[a].c(), u[a].m(i, null));
        }
        for (; a < u.length; a += 1)
          u[a].d(1);
        u.length = g.length;
      }
      d & /*historyData*/
      4 && n !== (n = /*group*/
      h[21].outcomes.length <= 5 ? "overflow: hidden;" : "") && f(i, "style", n);
    },
    d(h) {
      h && L(e), N(u, h);
    }
  };
}
function Ie(l) {
  let e;
  return {
    c() {
      e = p("div"), e.innerHTML = '<div class="LoaderLeft svelte-1r6yeh4"><ui-skeleton class="Dot svelte-1r6yeh4" structure="rectangle" width="16px" height="16px"></ui-skeleton> <ui-skeleton class="Text svelte-1r6yeh4" structure="text" height="16px"></ui-skeleton></div> <ui-skeleton class="Text svelte-1r6yeh4" structure="text" width="50px" height="16px"></ui-skeleton>', f(e, "class", "LoaderBody svelte-1r6yeh4");
    },
    m(t, s) {
      k(t, e, s);
    },
    p: C,
    d(t) {
      t && L(e);
    }
  };
}
function He(l) {
  let e, t, s, r, o = z([1, 2, 3]), i = [];
  for (let n = 0; n < 3; n += 1)
    i[n] = Ie(_e(l, o, n));
  return {
    c() {
      e = p("div"), t = p("ui-skeleton"), s = H();
      for (let n = 0; n < 3; n += 1)
        i[n].c();
      r = H(), E(t, "structure", "text"), E(t, "height", "16px"), f(e, "class", "GroupLoader svelte-1r6yeh4");
    },
    m(n, m) {
      k(n, e, m), y(e, t), y(e, s);
      for (let g = 0; g < 3; g += 1)
        i[g] && i[g].m(e, null);
      y(e, r);
    },
    p: C,
    d(n) {
      n && L(e), N(i, n);
    }
  };
}
function ze(l) {
  let e, t, s;
  function r(n, m) {
    return (
      /*loading*/
      n[1] ? xe : (
        /*historyData*/
        n[2].length > 0 ? we : be
      )
    );
  }
  let o = r(l), i = o(l);
  return {
    c() {
      e = p("div"), t = p("div"), i.c(), f(t, "class", "HistoryList svelte-1r6yeh4"), f(e, "class", "PrizeHistoryContent svelte-1r6yeh4"), J(
        e,
        "Mobile",
        /*mobileView*/
        l[4]
      );
    },
    m(n, m) {
      k(n, e, m), y(e, t), i.m(t, null), l[13](e);
    },
    p(n, [m]) {
      o === (o = r(n)) && i ? i.p(n, m) : (i.d(1), i = o(n), i && (i.c(), i.m(t, null)));
    },
    i(n) {
      n && (s || X(() => {
        s = Y(e, oe, { duration: 300 }), s.start();
      }));
    },
    o: C,
    d(n) {
      n && L(e), i.d(), l[13](null);
    }
  };
}
let Oe = null;
function Se(l, e, t) {
  let s;
  $(l, ue, (c) => t(3, s = c));
  let { endpoint: r = "" } = e, { session: o = "" } = e, { lang: i = "en" } = e, { clientstyling: n = "" } = e, { clientstylingurl: m = "" } = e, { translationurl: g = "" } = e, { mbsource: u = "" } = e, { type: h = "wheelOfFortune" } = e, d;
  const a = he(window.navigator.userAgent);
  let _ = !0, w = [];
  de();
  const x = () => {
    fetch(g).then((O) => O.json()).then((O) => {
      Object.keys(O).forEach((j) => {
        W(j, O[j]);
      });
    });
  }, v = async () => {
    if (!(!r || !o)) {
      t(1, _ = !0);
      try {
        t(2, w = await ve.fetchFullHistory(r, o, i, [h]));
      } catch (c) {
        console.error("[PrizeEngineHistory] Fetch failed", c);
      } finally {
        t(1, _ = !1);
      }
    }
  };
  ee(() => () => {
  });
  function b(c) {
    te[c ? "unshift" : "push"](() => {
      d = c, t(0, d);
    });
  }
  return l.$$set = (c) => {
    "endpoint" in c && t(5, r = c.endpoint), "session" in c && t(6, o = c.session), "lang" in c && t(7, i = c.lang), "clientstyling" in c && t(8, n = c.clientstyling), "clientstylingurl" in c && t(9, m = c.clientstylingurl), "translationurl" in c && t(10, g = c.translationurl), "mbsource" in c && t(11, u = c.mbsource), "type" in c && t(12, h = c.type);
  }, l.$$.update = () => {
    l.$$.dirty & /*lang*/
    128 && i && ye(i), l.$$.dirty & /*translationurl*/
    1024 && g && x(), l.$$.dirty & /*endpoint, session, type*/
    4192 && r && o && h && v(), l.$$.dirty & /*clientstyling, rootContainer*/
    257 && n && d && re(d, n), l.$$.dirty & /*clientstylingurl, rootContainer*/
    513 && m && d && le(d, m), l.$$.dirty & /*mbsource, rootContainer*/
    2049 && u && d && ie(d, `${u}.Style`, Oe);
  }, [
    d,
    _,
    w,
    s,
    a,
    r,
    o,
    i,
    n,
    m,
    g,
    u,
    h,
    b
  ];
}
class Ce extends Z {
  constructor(e) {
    super(), K(
      this,
      e,
      Se,
      ze,
      V,
      {
        endpoint: 5,
        session: 6,
        lang: 7,
        clientstyling: 8,
        clientstylingurl: 9,
        translationurl: 10,
        mbsource: 11,
        type: 12
      },
      ge
    );
  }
  get endpoint() {
    return this.$$.ctx[5];
  }
  set endpoint(e) {
    this.$$set({ endpoint: e }), I();
  }
  get session() {
    return this.$$.ctx[6];
  }
  set session(e) {
    this.$$set({ session: e }), I();
  }
  get lang() {
    return this.$$.ctx[7];
  }
  set lang(e) {
    this.$$set({ lang: e }), I();
  }
  get clientstyling() {
    return this.$$.ctx[8];
  }
  set clientstyling(e) {
    this.$$set({ clientstyling: e }), I();
  }
  get clientstylingurl() {
    return this.$$.ctx[9];
  }
  set clientstylingurl(e) {
    this.$$set({ clientstylingurl: e }), I();
  }
  get translationurl() {
    return this.$$.ctx[10];
  }
  set translationurl(e) {
    this.$$set({ translationurl: e }), I();
  }
  get mbsource() {
    return this.$$.ctx[11];
  }
  set mbsource(e) {
    this.$$set({ mbsource: e }), I();
  }
  get type() {
    return this.$$.ctx[12];
  }
  set type(e) {
    this.$$set({ type: e }), I();
  }
}
customElements.define("prize-engine-history", ne(Ce, { endpoint: {}, session: {}, lang: {}, clientstyling: {}, clientstylingurl: {}, translationurl: {}, mbsource: {}, type: {} }, [], [], !0));
export {
  Ce as default
};
