import { jsx as e, jsxs as v, Fragment as po } from "react/jsx-runtime";
import { useRef as F, useState as R, useCallback as Mo, useEffect as L } from "react";
import { e as M, s as n, f as Po, g as mo, i as D, Y as ko, a as uo, L as Lo, u as Oo, j as _o, b as Bo, S as T, h as xo } from "./provider.js";
import { N, a as vo, b as Ao, C as go, c as ho, P as k, d as S, A as Ro, e as Do, S as qo } from "./useStreamLayerApp2.js";
const wo = /* @__PURE__ */ n("div")({
  name: "Container",
  class: "c5b6wdg",
  propsAsIs: !1
}), Vo = "a1rlj479", jo = "s35f1di", Uo = "sj4471g", Fo = "b12050d8", zo = "b1d5ybek", Go = (o) => o === "left" || o === "right" ? jo : Fo, Wo = (o) => o === "left" || o === "right" ? Uo : zo, Ho = (o) => o === "left" ? "avdxyl3" : o === "right" ? "a1bisd08" : o === "top" ? "a1u9y2aj" : "a1qqaks", z = ({
  children: o,
  style: s,
  className: i,
  enabled: t = !0,
  hiding: l,
  direction: r = "left",
  onAnimationEnd: c
}) => /* @__PURE__ */ e(wo, {
  style: s,
  className: M(i, Vo, Ho(r), t && !l && Go(r), t && l && Wo(r)),
  onAnimationEnd: c,
  children: o
}), Ko = /* @__PURE__ */ n("a")({
  name: "Link",
  class: "l1sgte8c",
  propsAsIs: !1
}), Yo = /* @__PURE__ */ n("div")({
  name: "BannerContainer",
  class: "b7yfc72",
  propsAsIs: !1
}), Jo = () => Ko, Zo = /* @__PURE__ */ n(Jo())({
  name: "BannerLink",
  class: "bejjq94",
  propsAsIs: !0
}), Qo = ({ promotion: o, promotionId: s, hiding: i, direction: t = "bottom" }) => {
  var l, r;
  if (!((l = o.additionalBanner) != null && l.imageUrl))
    return null;
  let c = (r = o.additionalBanner) == null ? void 0 : r.url;
  return c && c.indexOf("http") !== 0 && (c = `https://${c}`), /* @__PURE__ */ e(z, { direction: t, hiding: i, children: /* @__PURE__ */ e(Yo, { className: "BannerContainer", children: /* @__PURE__ */ e(
    Zo,
    {
      as: c ? "a" : "span",
      className: "BannerLink",
      href: c,
      style: {
        backgroundImage: `url(${o.additionalBanner.imageUrl})`,
        cursor: c ? "pointer" : "default"
      },
      "data-promo-id": s,
      "data-promo-type": o.type,
      "data-analytics": "banner",
      target: "_blank"
    }
  ) }) });
}, Xo = /* @__PURE__ */ n("div")({
  name: "NotificationContent",
  class: "n18wsqoo",
  propsAsIs: !1
}), oe = /* @__PURE__ */ n("div")({
  name: "Body",
  class: "b1ia90c2",
  propsAsIs: !1
}), ee = /* @__PURE__ */ n("div")({
  name: "Title",
  class: "tg2z08v",
  propsAsIs: !1
}), ne = /* @__PURE__ */ n("div")({
  name: "Text",
  class: "t59zdk1",
  propsAsIs: !1
}), G = /* @__PURE__ */ n("div")({
  name: "MediaImgBottom",
  class: "m1ab9fq",
  propsAsIs: !1
}), se = () => G, te = /* @__PURE__ */ n(se())({
  name: "MediaImgMiddle",
  class: "m9fsr0y",
  propsAsIs: !0
}), ie = /* @__PURE__ */ n("img")({
  name: "CtaIcon",
  class: "cvi9y5q",
  propsAsIs: !1
}), ae = /* @__PURE__ */ n("button")({
  name: "Button",
  class: "bgl6boa",
  propsAsIs: !1
}), re = /* @__PURE__ */ n("div")({
  name: "Logo",
  class: "l5mq0z",
  propsAsIs: !1
}), le = /* @__PURE__ */ n("div")({
  name: "Footer",
  class: "f1mse0ft",
  propsAsIs: !1
}), de = /* @__PURE__ */ n("div")({
  name: "Vector",
  class: "v1hcloah",
  propsAsIs: !1
}), ce = /* @__PURE__ */ n("div")({
  name: "NotificationContainer",
  class: "n3n65jf",
  propsAsIs: !1
}), pe = {
  [N.BOTTOM]: G,
  [N.MIDDLE]: te
}, me = ({ src: o, imagePosition: s }) => {
  const i = pe[s] || G;
  return /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e("img", { src: o, alt: "" }) });
}, ue = ({ notification: o, open: s }) => {
  if (!o || !o.promotion || o.enabled !== vo.NOTIFICATION_ENABLED)
    return null;
  const { title: i, body: t, image: l, promotion: r } = o, { sponsorLogo: c, sponsorLogoMode: m, imagePosition: A, ctaButton: a } = r;
  return /* @__PURE__ */ v(ce, { className: "SL_Lower_Third_Notification", onClick: s, children: [
    /* @__PURE__ */ v(Xo, { children: [
      /* @__PURE__ */ e(me, { src: l, imagePosition: A }),
      /* @__PURE__ */ v(oe, { children: [
        i && /* @__PURE__ */ e(ee, { children: i }),
        t && /* @__PURE__ */ e(ne, { children: t })
      ] })
    ] }),
    /* @__PURE__ */ v(le, { children: [
      m !== Ao.NOTIFICATION_SPONSOR_LOGO_NONE && /* @__PURE__ */ v(po, { children: [
        /* @__PURE__ */ e(re, { children: /* @__PURE__ */ e("img", { src: c, alt: i }) }),
        /* @__PURE__ */ e(de, {})
      ] }),
      /* @__PURE__ */ v(ae, { name: "promo-button", style: { color: a == null ? void 0 : a.textColor, backgroundColor: a == null ? void 0 : a.color }, children: [
        (a == null ? void 0 : a.ctaIcon) && (a == null ? void 0 : a.ctaIconMode) === go.CTA_ICON_TRANSPARENT && /* @__PURE__ */ e(ie, { src: a == null ? void 0 : a.ctaIcon, alt: "cta-icon" }),
        (a == null ? void 0 : a.label) || "Open"
      ] })
    ] })
  ] });
}, ve = /* @__PURE__ */ n("div")({
  name: "NotificationContent",
  class: "n1ku6hz",
  propsAsIs: !1
}), Ae = /* @__PURE__ */ n("div")({
  name: "NotificationContainer",
  class: "nbxqmol",
  propsAsIs: !1
}), ge = /* @__PURE__ */ n("div")({
  name: "Body",
  class: "b1gu3eml",
  propsAsIs: !1
}), he = /* @__PURE__ */ n("div")({
  name: "Title",
  class: "t1u17zva",
  propsAsIs: !1
}), Ie = /* @__PURE__ */ n("div")({
  name: "Text",
  class: "t10ko1g",
  propsAsIs: !1
}), q = /* @__PURE__ */ n("div")({
  name: "Media",
  class: "mntc42e",
  propsAsIs: !1
}), ye = () => q, io = /* @__PURE__ */ n(ye())({
  name: "MediaImgFit",
  class: "ml060eo",
  propsAsIs: !0
}), be = () => q, Io = /* @__PURE__ */ n(be())({
  name: "MediaImgCentered",
  class: "m1vqlvig",
  propsAsIs: !0
}), fe = () => Io, Ne = /* @__PURE__ */ n(fe())({
  name: "MediaImgBottom",
  class: "m1e7tvi5",
  propsAsIs: !0
}), $e = () => q, Ce = /* @__PURE__ */ n($e())({
  name: "MediaImgSolid",
  class: "mqvntt2",
  propsAsIs: !0
}), Te = () => q, Se = /* @__PURE__ */ n(Te())({
  name: "MediaImgMiddle",
  class: "m12jtj3u",
  propsAsIs: !0
}), Ee = /* @__PURE__ */ n("img")({
  name: "CtaIcon",
  class: "ckq1frv",
  propsAsIs: !1
}), Me = /* @__PURE__ */ n("button")({
  name: "Button",
  class: "bis90pl",
  propsAsIs: !1
}), Pe = () => Po, ke = /* @__PURE__ */ n(Pe())({
  name: "StyledChevronRight",
  class: "s9mjmz3",
  propsAsIs: !0
}), Le = /* @__PURE__ */ n("div")({
  name: "Logo",
  class: "l1cf50a7",
  propsAsIs: !1
}), Oe = {
  [N.UNSET]: io,
  [N.FIT]: io,
  [N.CENTERED]: Io,
  [N.BOTTOM]: Ne,
  [N.SOLID]: Ce,
  [N.MIDDLE]: Se
}, _e = ({ src: o, imagePosition: s }) => {
  const i = Oe[s];
  return /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e("img", { src: o, alt: "" }) });
}, Be = ({ notification: o, open: s, promotionId: i, hiding: t, direction: l = "left" }) => {
  if (!o || !o.promotion || o.enabled !== vo.NOTIFICATION_ENABLED)
    return null;
  if (o.promotion.mode === ho.LOWER_THIRD)
    return /* @__PURE__ */ e(ue, { notification: o, open: s });
  const { title: r, body: c, image: m, promotion: A } = o, { sponsorLogo: a, sponsorLogoMode: g, imagePosition: u, ctaButton: p } = A;
  return /* @__PURE__ */ e(z, { className: "SL_Rich_Notification", direction: l, hiding: t, children: /* @__PURE__ */ v(Ae, { onClick: s, children: [
    g !== Ao.NOTIFICATION_SPONSOR_LOGO_NONE && /* @__PURE__ */ e(Le, { children: /* @__PURE__ */ e("img", { src: a, alt: r }) }),
    /* @__PURE__ */ v(ve, { children: [
      /* @__PURE__ */ e(_e, { src: m, imagePosition: u }),
      /* @__PURE__ */ v(ge, { children: [
        r && /* @__PURE__ */ e(he, { children: r }),
        c && /* @__PURE__ */ e(Ie, { children: c })
      ] }),
      /* @__PURE__ */ v(Me, { name: "promo-button", style: { color: p == null ? void 0 : p.textColor, backgroundColor: p == null ? void 0 : p.color }, children: [
        (p == null ? void 0 : p.ctaIcon) && (p == null ? void 0 : p.ctaIconMode) === go.CTA_ICON_TRANSPARENT && /* @__PURE__ */ e(Ee, { src: p == null ? void 0 : p.ctaIcon, alt: "cta-icon" }),
        (p == null ? void 0 : p.label) || "Open"
      ] }),
      /* @__PURE__ */ e(ke, { name: "chevronRight" })
    ] })
  ] }) });
}, xe = /* @__PURE__ */ n("div")({
  name: "OverlayContainer",
  class: "okzhq2w",
  propsAsIs: !1
}), yo = /* @__PURE__ */ n("div")({
  name: "PromoOverlay",
  class: "pmgz5i",
  propsAsIs: !1
}), bo = /* @__PURE__ */ n("div")({
  name: "Header",
  class: "hyxi3jt",
  propsAsIs: !1
}), fo = /* @__PURE__ */ n("div")({
  name: "HeaderContent",
  class: "h149e3gp",
  propsAsIs: !1
}), No = "h10toh7", ao = /* @__PURE__ */ n("img")({
  name: "SponsorLogo",
  class: "s1jyea6t",
  propsAsIs: !1
}), Re = /* @__PURE__ */ n("div")({
  name: "SponsorName",
  class: "szpfa3h",
  propsAsIs: !1
}), $o = /* @__PURE__ */ n("div")({
  name: "Media",
  class: "m1crmu01",
  propsAsIs: !1
}), De = /* @__PURE__ */ n("img")({
  name: "PromoImg",
  class: "p1l37r8s",
  propsAsIs: !1
}), qe = "s1nmch9k", ro = /* @__PURE__ */ n("div")({
  name: "Content",
  class: "c1er0ljd",
  propsAsIs: !1
}), we = /* @__PURE__ */ n("div")({
  name: "Description",
  class: "dydopmr",
  propsAsIs: !1
}), Ve = /* @__PURE__ */ n("div")({
  name: "Sponsor",
  class: "s1w6nt04",
  propsAsIs: !1
}), je = /* @__PURE__ */ n("div")({
  name: "SponsorText",
  class: "s1evcmtq",
  propsAsIs: !1
}), Co = /* @__PURE__ */ n("div")({
  name: "ADLogo",
  class: "awodx0x",
  propsAsIs: !1
}), Ue = /* @__PURE__ */ n("span")({
  name: "SponsoredText",
  class: "s1q3n6oi",
  propsAsIs: !1
}), Fe = /* @__PURE__ */ n("div")({
  name: "ActionBtnWrap",
  class: "a8d4xfk",
  propsAsIs: !1
}), ze = /* @__PURE__ */ n("a")({
  name: "ActionButton",
  class: "at6oobh",
  propsAsIs: !1
}), Ge = /* @__PURE__ */ n("div")({
  name: "Title",
  class: "t1gyg7tt",
  propsAsIs: !1
}), We = "h17rwbtk", He = /* @__PURE__ */ n("div")({
  name: "Container",
  class: "c10m2bce",
  propsAsIs: !1
}), lo = /* @__PURE__ */ n("div")({
  name: "Item",
  class: "ig23yq5",
  propsAsIs: !1
}), Ke = /* @__PURE__ */ n("div")({
  name: "Dot",
  class: "d1f6aqua",
  propsAsIs: !1
}), Ye = ({
  time: o,
  adCount: s,
  adPosition: i
}) => {
  const t = Math.floor(o / 60), l = o - t * 60;
  return t === 0 && l === 0 && s === i ? null : /* @__PURE__ */ v(He, {
    children: [s > 1 && /* @__PURE__ */ v(po, {
      children: [/* @__PURE__ */ v(lo, {
        children: [i, " of ", s]
      }), /* @__PURE__ */ e(Ke, {})]
    }), /* @__PURE__ */ v(lo, {
      children: [t, ":", l < 10 ? `0${l}` : l]
    })]
  });
}, Je = (o, s, { onPlay: i, onStop: t, onProgress: l }) => {
  const r = google.ima;
  let c = new r.AdDisplayContainer(o), m = new r.AdsLoader(c), A = new r.AdsRequest(), a;
  m.addEventListener(
    r.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
    (u) => {
      a = u.getAdsManager(o), i && a.addEventListener(r.AdEvent.Type.STARTED, i), t && a.addEventListener(r.AdEvent.Type.COMPLETE, t), l && a.addEventListener(r.AdEvent.Type.AD_PROGRESS, (p) => l(p.getAdData())), a.init(o.clientWidth, o.clientHeight, r.ViewMode.NORMAL), a.start();
    },
    !1
  ), m.addEventListener(
    r.AdErrorEvent.Type.AD_ERROR,
    () => {
      console.log("ad error"), t == null || t();
    },
    !1
  ), A.linearAdSlotWidth = o.clientWidth, A.linearAdSlotHeight = o.clientHeight, A.adTagUrl = s, m.requestAds(A);
  const g = () => {
    a == null || a.destroy(), m == null || m.destroy(), c == null || c.destroy(), c = void 0, m = void 0, A = void 0, a = void 0;
  };
  return () => {
    try {
      c.initialize();
    } catch (u) {
      t == null || t(), console.log("AdsManager could not be started", u);
    }
    return g;
  };
}, Ze = /* @__PURE__ */ n("div")({
  name: "Container",
  class: "c4q6dw1",
  propsAsIs: !1
}), Qe = /* @__PURE__ */ n("div")({
  name: "ControlsContainer",
  class: "c1la67r",
  propsAsIs: !1
}), Xe = "m3guev", on = "m7099mt", en = "mmm6o5s", nn = ({
  promotion: o,
  controlVideo: s,
  promotionId: i,
  onClose: t,
  externalAd: l,
  skipAutoClose: r
}) => {
  var c;
  const m = F(null), [A, a] = R(!1), [g, u] = R(0), [p, I] = R(0), [$, h] = R(0), y = F(), b = Mo(() => {
    u(0), I(0), h(0), a(!1), s == null || s({
      muted: !1
    });
  }, [s]);
  L(() => {
    if (l != null && l.url && m.current) {
      b();
      const f = Je(m.current, l.url, {
        onPlay: () => {
          D.emit("advertisement", {
            action: "videoPlay",
            payload: {
              id: i,
              type: o.type
            }
          }), s == null || s({
            muted: !0
          }), a(!0);
        },
        onStop: () => {
          t == null || t(), b();
        },
        onProgress: (C) => {
          u(Math.round(C.duration - C.currentTime)), I(C.totalAds), h(C.adPosition);
        }
      })();
      return y.current = f, () => {
        y.current = void 0, f();
      };
    }
  }, [l == null ? void 0 : l.url, s, b, i, o.type, t]);
  const O = ((c = o.sponsor) == null ? void 0 : c.logo) && o.logoMode === k.CENTER;
  return /* @__PURE__ */ v(yo, {
    className: "PromoOverlay",
    children: [/* @__PURE__ */ v(bo, {
      children: [/* @__PURE__ */ e(fo, {
        className: M(!O && No),
        children: /* @__PURE__ */ e(Co, {
          style: {
            transform: "scale(1.5)"
          },
          children: "Ad"
        })
      }), /* @__PURE__ */ v(Qe, {
        children: [/* @__PURE__ */ e(Ye, {
          time: g,
          adCount: p,
          adPosition: $
        }), r && /* @__PURE__ */ e(mo, {
          className: "ClosePromoIcon",
          close: () => {
            var f;
            (f = y.current) == null || f.call(y), t == null || t(), b();
          }
        })]
      })]
    }), /* @__PURE__ */ e($o, {
      className: M(Xe, A && on, !A && en),
      children: /* @__PURE__ */ e(Ze, {
        ref: m
      })
    })]
  });
}, co = (o) => {
  var s, i, t, l, r, c, m, A, a, g, u, p, I, $, h, y, b, O, f, C, W, H, K, Y, J, Z, Q, X, oo, eo;
  const {
    promotion: d,
    open: no,
    advertisementPaused: To,
    togglePause: E,
    controlVideo: _,
    skipAutoClose: So,
    promotionId: B,
    onClose: Eo,
    markAsViewed: w,
    externalAd: so
  } = o, V = d.type === S.INGAME_IAB11_LBAR || d.type === S.INGAME_IAB11, j = ((s = d.sponsor) == null ? void 0 : s.logo) && d.logoMode === k.CENTER, to = !!((t = (i = d.banner) == null ? void 0 : i.video) != null && t.url), x = d.autoPlayVideo === Ro.ENABLED;
  if (L(() => {
    E == null || E(to || x), no == null || no();
  }, []), L(() => {
    B && d.type && w && w();
  }, [B, d.type, w]), L(() => () => {
    _ == null || _({ muted: !1 });
  }, [_]), so)
    return /* @__PURE__ */ e(nn, { ...o, externalAd: so });
  let P = (l = d.banner) == null ? void 0 : l.url;
  P && P.indexOf("http") !== 0 && (P = `https://${P}`);
  let U = !0;
  return to && (!To || !x ? U = !0 : U = !1), /* @__PURE__ */ v(yo, { className: "PromoOverlay", children: [
    /* @__PURE__ */ v(bo, { children: [
      /* @__PURE__ */ v(fo, { className: M(!j && No), children: [
        ((r = d.sponsor) == null ? void 0 : r.logo) && d.logoMode === k.LEFT && /* @__PURE__ */ e(ao, { className: "PromoSponsorLogo", src: (c = d.sponsor) == null ? void 0 : c.logo, alt: "promo" }),
        /* @__PURE__ */ v(
          Ve,
          {
            style: {
              paddingLeft: (m = d.sponsor) != null && m.logo && d.logoMode === k.LEFT ? "0px" : "8px"
            },
            children: [
              ((A = d.sponsor) == null ? void 0 : A.logo) && d.logoMode === k.LEFT && /* @__PURE__ */ e(Re, { children: (a = d.sponsor) == null ? void 0 : a.name }),
              /* @__PURE__ */ v(je, { className: "SponsorText", children: [
                /* @__PURE__ */ e(Co, { children: "AD" }),
                /* @__PURE__ */ e(Ue, { children: "SPONSORED" })
              ] })
            ]
          }
        )
      ] }),
      /* @__PURE__ */ e(
        mo,
        {
          className: "ClosePromoIcon",
          close: Eo,
          autoClose: (g = d.closeTimer) == null ? void 0 : g.auto,
          duration: So ? 0 : (u = d.closeTimer) == null ? void 0 : u.seconds,
          isPlaying: U
        }
      )
    ] }),
    /* @__PURE__ */ v($o, { children: [
      j && /* @__PURE__ */ e(ao, { className: qe, src: (p = d.sponsor) == null ? void 0 : p.logo, alt: "promo" }),
      /* @__PURE__ */ e(ro, { children: ($ = (I = d.banner) == null ? void 0 : I.video) != null && $.url ? /* @__PURE__ */ e(
        ko,
        {
          source: (y = (h = d.banner) == null ? void 0 : h.video) == null ? void 0 : y.url,
          poster: (O = (b = d.banner) == null ? void 0 : b.video) == null ? void 0 : O.thumbnailUrl,
          aspectRatio: V ? "1/1" : "16/9",
          onPause: () => {
            x && (E == null || E(!0));
          },
          onPlay: () => {
            D.emit("advertisement", {
              action: "videoPlay",
              payload: {
                id: B,
                type: d.type
              }
            }), E == null || E(!1);
          },
          controlVideo: _,
          autoPlay: x
        }
      ) : (f = d.banner) != null && f.imageUrl ? /* @__PURE__ */ e(De, { style: V ? { aspectRatio: "1/1" } : {}, src: (C = d.banner) == null ? void 0 : C.imageUrl, alt: "promo" }) : null }),
      !V && /* @__PURE__ */ v(ro, { children: [
        ((W = d.banner) == null ? void 0 : W.title) && /* @__PURE__ */ e(Ge, { className: M("AdvTitle", j && We), children: (H = d.banner) == null ? void 0 : H.title }),
        ((K = d.banner) == null ? void 0 : K.body) && /* @__PURE__ */ e(we, { className: "AdvDescription", children: (Y = d.banner) == null ? void 0 : Y.body })
      ] })
    ] }),
    d.buttonType !== Do.NO_BUTTON && /* @__PURE__ */ e(Fe, { children: /* @__PURE__ */ e(
      ze,
      {
        href: P,
        style: {
          backgroundColor: ((Z = (J = d.banner) == null ? void 0 : J.ctaButton) == null ? void 0 : Z.color) || "#009dc4",
          color: ((X = (Q = d.banner) == null ? void 0 : Q.ctaButton) == null ? void 0 : X.textColor) || "#fff"
        },
        "data-analytics": "button",
        "data-promo-id": B,
        "data-promo-type": d.type,
        target: "_blank",
        children: (eo = (oo = d.banner) == null ? void 0 : oo.ctaButton) == null ? void 0 : eo.label
      }
    ) })
  ] });
}, sn = /* @__PURE__ */ n("div")({
  name: "SidebarContainer",
  class: "s1abskp8",
  propsAsIs: !1
}), tn = ({
  children: o,
  direction: s,
  style: i,
  className: t,
  hiding: l
}) => /* @__PURE__ */ e(z, {
  direction: s,
  style: i,
  hiding: l,
  className: t,
  children: /* @__PURE__ */ e(sn, {
    children: o
  })
}), an = (o) => (o == null ? void 0 : o.type) === S.INGAME_IAB11_LBAR || (o == null ? void 0 : o.type) === S.INGAME_IAB21_LBAR, rn = (o) => (o == null ? void 0 : o.type) === S.INGAME_IAB11 || (o == null ? void 0 : o.type) === S.INGAME_IAB21, ln = ({
  advertisement: o,
  close: s,
  skipTypeCheck: i,
  skipAutoClose: t,
  layoutMode: l = "side-by-side",
  sidebar: r,
  isNotification: c,
  banner: m,
  markAsViewed: A,
  open: a,
  externalAd: g,
  controlVideo: u,
  advertisementPaused: p,
  togglePause: I
}) => o.promotion ? c && o.notification ? /* @__PURE__ */ e(
  Be,
  {
    open: () => a == null ? void 0 : a({ fromNotification: !0 }),
    notification: o.notification,
    promotionId: o.question.id
  }
) : !r && !m && (i || rn(o.promotion)) ? /* @__PURE__ */ e(xe, { className: "PromoOverlayContainer", children: /* @__PURE__ */ e(
  co,
  {
    markAsViewed: A,
    promotionId: o.question.id,
    promotion: o.promotion,
    onClose: s,
    open: a,
    skipAutoClose: t,
    externalAd: g,
    controlVideo: u,
    advertisementPaused: p,
    togglePause: I
  }
) }) : r && (i || an(o.promotion)) ? /* @__PURE__ */ e(tn, { className: "PromoSidebarContainer", direction: r, hiding: !1, children: /* @__PURE__ */ e(
  co,
  {
    markAsViewed: A,
    promotionId: o.question.id,
    promotion: o.promotion,
    externalAd: g,
    onClose: s,
    open: a,
    controlVideo: u,
    skipAutoClose: t,
    advertisementPaused: p,
    togglePause: I
  }
) }) : m ? /* @__PURE__ */ e(
  Qo,
  {
    promotionId: o.question.id,
    hiding: !1,
    promotion: o.promotion,
    direction: m
  }
) : null : null, dn = /* @__PURE__ */ n("div")({
  name: "AdvertisementUIWrap",
  class: "aa6pjif",
  propsAsIs: !1
}), cn = (o) => {
  const s = o.target;
  if (s instanceof HTMLAnchorElement && s.target === "_blank") {
    const i = s.getAttribute("data-promo-id") || "", t = s.getAttribute("data-promo-type") || S.UNSET;
    s.getAttribute("data-analytics") === "button" && D.emit("advertisement", {
      action: "buttonSelect",
      payload: {
        id: i,
        type: t
      }
    }), s.getAttribute("data-analytics") === "banner" && D.emit("advertisement", {
      action: "bannerSelect",
      payload: {
        id: i,
        type: t
      }
    });
  }
}, pn = ({
  gamification: o,
  layoutMode: s,
  skipAutoClose: i,
  skipTypeCheck: t,
  sidebar: l,
  banner: r,
  notification: c,
  isMobileScreen: m,
  persistent: A,
  externalAd: a,
  controlVideo: g
}) => {
  var u, p, I;
  const $ = F(null), h = uo(o.advertisement.$store);
  Lo($, {
    enabled: !!h.data,
    event: "click",
    listener: cn
  });
  const y = !r && !l;
  if (h.data === void 0 || !A && h.isViewed)
    return null;
  const b = ((I = (p = (u = h == null ? void 0 : h.data) == null ? void 0 : u.notification) == null ? void 0 : p.promotion) == null ? void 0 : I.mode) === ho.LOWER_THIRD;
  return /* @__PURE__ */ e(dn, {
    ref: $,
    style: {
      height: y ? "auto" : "100%"
    },
    className: M("SL-AdvertisementUIWrap", m && "mobile-view", b && "SL-AdvertisementUIWrap--lower-third"),
    children: /* @__PURE__ */ e(ln, {
      skipTypeCheck: t,
      sidebar: l,
      banner: r,
      advertisement: h.data,
      advertisementPaused: h.isPaused,
      togglePause: h.togglePause,
      close: h.close,
      externalAd: a ? h.externalAd : void 0,
      markAsViewed: o.advertisement.markAsViewed,
      open: o.advertisement.open,
      layoutMode: s,
      isNotification: c,
      skipAutoClose: i,
      controlVideo: g
    })
  });
}, mn = ({
  sdk: o,
  sidebar: s,
  externalAd: i,
  banner: t,
  skipAutoClose: l,
  skipTypeCheck: r,
  layoutMode: c,
  isMobileScreen: m,
  persistent: A,
  notification: a
}) => {
  const g = uo(o.featuresList.getStore());
  if (L(() => {
    if (i) {
      const p = document.createElement("script");
      p.async = !0, p.src = "https://imasdk.googleapis.com/js/sdkloader/ima3.js", document.body.appendChild(p);
    }
  }, [i]), s && t)
    return /* @__PURE__ */ e("div", {
      style: {
        color: "red"
      },
      children: "define either sidebar or banner, not both."
    });
  if (t && i)
    return /* @__PURE__ */ e("div", {
      style: {
        color: "red"
      },
      children: "externalAd is not supported with banner"
    });
  if (!g)
    return null;
  const u = o.getFeature(qo.GAMES);
  return u ? /* @__PURE__ */ e(pn, {
    gamification: u,
    sidebar: s,
    banner: t,
    layoutMode: c,
    isMobileScreen: m,
    persistent: A,
    notification: a,
    skipTypeCheck: r,
    skipAutoClose: l,
    externalAd: i,
    controlVideo: o.controlVideoPlayer
  }) : null;
}, hn = ({
  event: o,
  sidebar: s,
  banner: i,
  isMobileScreen: t,
  skipAutoClose: l,
  persistent: r,
  theme: c,
  notification: m,
  skipTypeCheck: A,
  externalAd: a
}) => {
  const g = Oo(), u = _o(), p = Bo();
  return g ? a && !u.promotionExternalAd ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : !a && u.promotionExternalAd ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : s && !u.promotionSidebar ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : i && !u.promotionBanner ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : m && !u.promotionNotification ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : !i && !s && !m && !u.promotionOverlay ? o !== void 0 && /* @__PURE__ */ e(T, { event: o }) : /* @__PURE__ */ v("div", { className: "StreamLayerSDK", children: [
    /* @__PURE__ */ e(xo, { customTheme: c ?? p.theme, themeMode: p.themeMode, children: /* @__PURE__ */ e(
      mn,
      {
        sdk: g,
        sidebar: s,
        banner: i,
        isMobileScreen: t,
        persistent: r,
        notification: m,
        skipTypeCheck: A,
        skipAutoClose: l,
        layoutMode: "side-by-side",
        externalAd: a
      }
    ) }),
    o !== void 0 && /* @__PURE__ */ e(T, { event: o })
  ] }) : null;
};
export {
  hn as StreamLayerSDKAdvertisement,
  mn as StreamLayerSDKAdvertisementUI
};
