import { S as O, d as T, s as B, f as g, e as I, h as R, Q as M, R as z, T as J, j as G, k as L, m as P, t as Q, o as X, q as F, U as H, u as K, V as Y, W as Z, x as W, X as $, A as ee, B as te, C as ne, D as ie } from "./PrizeEngineDetails-D8O-TJ37.js";
import { s as se, a as le, W as re, b as ae } from "./WheelSVG-R6v1RaFO.js";
function oe(i) {
  I(i, "svelte-12d9sfg", '.PrizeLuckywheelContainer.svelte-12d9sfg{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;padding:20px;box-sizing:border-box;font-family:var(--emw--font-family-primary, "Ubuntu", sans-serif)}.PrizeLuckywheelContainer.Mobile.svelte-12d9sfg{padding:10px}.MainSection.svelte-12d9sfg{flex-grow:1;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;position:relative}.WheelWrapper.svelte-12d9sfg{flex-grow:1;display:flex;align-items:center;justify-content:center;min-height:0;width:100%}');
}
function E(i) {
  let e, s, t, r, c = {
    lang: (
      /*lang*/
      i[0]
    ),
    contentdirection: (
      /*contentdirection*/
      i[1]
    ),
    bonus: (
      /*activeGame*/
      i[4]
    ),
    size: (
      /*_internalSize*/
      i[3]
    ),
    radius: (
      /*radius*/
      i[7]
    )
  };
  return t = new re({ props: c }), i[17](t), t.$on(
    "spinning",
    /*spinning_handler*/
    i[18]
  ), t.$on(
    "spinning-request",
    /*spinning_request_handler*/
    i[19]
  ), t.$on(
    "success",
    /*success_handler*/
    i[20]
  ), {
    c() {
      e = L("div"), s = L("div"), Z(t.$$.fragment), P(s, "class", "WheelWrapper svelte-12d9sfg"), P(e, "class", "MainSection svelte-12d9sfg");
    },
    m(l, a) {
      G(l, e, a), K(e, s), Y(t, s, null), r = !0;
    },
    p(l, a) {
      const o = {};
      a & /*lang*/
      1 && (o.lang = /*lang*/
      l[0]), a & /*contentdirection*/
      2 && (o.contentdirection = /*contentdirection*/
      l[1]), a & /*activeGame*/
      16 && (o.bonus = /*activeGame*/
      l[4]), a & /*_internalSize*/
      8 && (o.size = /*_internalSize*/
      l[3]), a & /*radius*/
      128 && (o.radius = /*radius*/
      l[7]), t.$set(o);
    },
    i(l) {
      r || (z(t.$$.fragment, l), r = !0);
    },
    o(l) {
      M(t.$$.fragment, l), r = !1;
    },
    d(l) {
      l && R(e), i[17](null), H(t);
    }
  };
}
function ce(i) {
  let e, s, t = (
    /*activeGame*/
    i[4] && E(i)
  );
  return {
    c() {
      e = L("div"), t && t.c(), P(e, "class", "PrizeLuckywheelContainer svelte-12d9sfg"), Q(
        e,
        "Mobile",
        /*mobileView*/
        i[8]
      );
    },
    m(r, c) {
      G(r, e, c), t && t.m(e, null), i[21](e), s = !0;
    },
    p(r, [c]) {
      /*activeGame*/
      r[4] ? t ? (t.p(r, c), c & /*activeGame*/
      16 && z(t, 1)) : (t = E(r), t.c(), z(t, 1), t.m(e, null)) : t && ($(), M(t, 1, 1, () => {
        t = null;
      }), J());
    },
    i(r) {
      s || (z(t), s = !0);
    },
    o(r) {
      M(t), s = !1;
    },
    d(r) {
      r && R(e), t && t.d(), i[21](null);
    }
  };
}
let ue = null;
function fe(i, e, s) {
  let t, r, c, { data: l = null } = e, { lang: a = "en" } = e, { clientstyling: o = "" } = e, { clientstylingurl: y = "" } = e, { translationurl: w = "" } = e, { mbsource: b = "" } = e, { size: S = 324 } = e, { mobilesize: _ = 240 } = e, { contentdirection: C = "anticlockwise" } = e, k = null, u;
  const v = X(window.navigator.userAgent);
  let f, m = !1;
  se();
  const j = () => {
    fetch(w).then((d) => d.json()).then((d) => {
      Object.keys(d).forEach((h) => {
        ae(h, d[h]);
      });
    });
  }, q = (n) => {
    f && f.setDrawResult(n);
  }, D = () => {
    m || (s(6, m = !0), f && f.eventSpin());
  };
  F(() => {
    const n = (d) => {
      const { type: h, data: N } = d.data;
      h === "PrizeGameResult" ? q(N) : h === "PrizeResultClose" ? (s(6, m = !1), f && f.closeMessage()) : h === "PrizeGameStartAnimation" && D();
    };
    return window.addEventListener("message", n), () => {
      window.removeEventListener("message", n);
    };
  });
  function x(n) {
    W[n ? "unshift" : "push"](() => {
      f = n, s(5, f);
    });
  }
  const U = () => s(6, m = !0), p = () => window.postMessage({ type: "PrizeGameRequestDraw" }, "*"), A = () => window.postMessage({ type: "PrizeGameSpinEnd" }, "*");
  function V(n) {
    W[n ? "unshift" : "push"](() => {
      u = n, s(2, u);
    });
  }
  return i.$$set = (n) => {
    "data" in n && s(9, l = n.data), "lang" in n && s(0, a = n.lang), "clientstyling" in n && s(10, o = n.clientstyling), "clientstylingurl" in n && s(11, y = n.clientstylingurl), "translationurl" in n && s(12, w = n.translationurl), "mbsource" in n && s(13, b = n.mbsource), "size" in n && s(14, S = n.size), "mobilesize" in n && s(15, _ = n.mobilesize), "contentdirection" in n && s(1, C = n.contentdirection);
  }, i.$$.update = () => {
    if (i.$$.dirty & /*data*/
    512)
      if (typeof l == "string")
        try {
          s(4, k = JSON.parse(l));
        } catch (n) {
          console.error("[Luckywheel] Parse failed", n);
        }
      else
        s(4, k = l);
    i.$$.dirty & /*lang*/
    1 && a && le(a), i.$$.dirty & /*translationurl*/
    4096 && w && j(), i.$$.dirty & /*clientstyling, rootContainer*/
    1028 && o && u && ee(u, o), i.$$.dirty & /*clientstylingurl, rootContainer*/
    2052 && y && u && te(u, y), i.$$.dirty & /*mbsource, rootContainer*/
    8196 && b && u && ne(u, `${b}.Style`, ue), i.$$.dirty & /*mobilesize, size*/
    49152 && s(16, t = v && _ ? _ : S), i.$$.dirty & /*_size*/
    65536 && s(3, r = t / 0.6875), i.$$.dirty & /*_internalSize*/
    8 && s(7, c = 0.62 * r / 2);
  }, [
    a,
    C,
    u,
    r,
    k,
    f,
    m,
    c,
    v,
    l,
    o,
    y,
    w,
    b,
    S,
    _,
    t,
    x,
    U,
    p,
    A,
    V
  ];
}
class ge extends O {
  constructor(e) {
    super(), T(
      this,
      e,
      fe,
      ce,
      B,
      {
        data: 9,
        lang: 0,
        clientstyling: 10,
        clientstylingurl: 11,
        translationurl: 12,
        mbsource: 13,
        size: 14,
        mobilesize: 15,
        contentdirection: 1
      },
      oe
    );
  }
  get data() {
    return this.$$.ctx[9];
  }
  set data(e) {
    this.$$set({ data: e }), g();
  }
  get lang() {
    return this.$$.ctx[0];
  }
  set lang(e) {
    this.$$set({ lang: e }), g();
  }
  get clientstyling() {
    return this.$$.ctx[10];
  }
  set clientstyling(e) {
    this.$$set({ clientstyling: e }), g();
  }
  get clientstylingurl() {
    return this.$$.ctx[11];
  }
  set clientstylingurl(e) {
    this.$$set({ clientstylingurl: e }), g();
  }
  get translationurl() {
    return this.$$.ctx[12];
  }
  set translationurl(e) {
    this.$$set({ translationurl: e }), g();
  }
  get mbsource() {
    return this.$$.ctx[13];
  }
  set mbsource(e) {
    this.$$set({ mbsource: e }), g();
  }
  get size() {
    return this.$$.ctx[14];
  }
  set size(e) {
    this.$$set({ size: e }), g();
  }
  get mobilesize() {
    return this.$$.ctx[15];
  }
  set mobilesize(e) {
    this.$$set({ mobilesize: e }), g();
  }
  get contentdirection() {
    return this.$$.ctx[1];
  }
  set contentdirection(e) {
    this.$$set({ contentdirection: e }), g();
  }
}
customElements.define("prize-engine-luckywheel", ie(ge, { data: {}, lang: {}, clientstyling: {}, clientstylingurl: {}, translationurl: {}, mbsource: {}, size: {}, mobilesize: {}, contentdirection: {} }, [], [], !0));
export {
  ge as default
};
