import { jsxs as m, jsx as t } from "react/jsx-runtime";
import { s as p, u as v } from "./sl-types.js";
import { createContext as z, useContext as F, useRef as Y, useEffect as _, useState as G } from "react";
import { y as J, d as K, u as M, a as W } from "./index10.js";
import { e as X, t as Z } from "./index11.js";
import { y as oo } from "./utils.js";
import { Q as L, A as eo } from "./useStreamLayerApp2.js";
const to = z({
  sdk: null,
  topNavigation: !1
}), so = () => F(to), no = /* @__PURE__ */ p("div")({
  name: "QuestionAdvertisementContainer",
  class: "qwludgs",
  propsAsIs: !1
}), io = /* @__PURE__ */ p("div")({
  name: "QuestionAdvertisementText",
  class: "qvce6pv",
  propsAsIs: !1
}), lo = /* @__PURE__ */ p("div")({
  name: "QuestionAdvertisementImage",
  class: "qsid7hx",
  propsAsIs: !1
}), ao = ({
  sponsorLogo: o,
  id: l,
  hasBanner: r,
  setAdShowed: n
}) => {
  const i = Y();
  return _(() => (i.current = setTimeout(() => {
    n(!0);
  }, 5e3), () => {
    clearTimeout(i.current);
  }), [n, l, r]), /* @__PURE__ */ m(no, {
    children: [/* @__PURE__ */ t(io, {
      children: "PRESENTED BY"
    }), /* @__PURE__ */ t(lo, {
      children: /* @__PURE__ */ t("img", {
        src: o,
        alt: "ad-sponsor-logo"
      })
    })]
  });
}, V = /* @__PURE__ */ p("div")({
  name: "QuestionContainer",
  class: "q14ckf9e",
  propsAsIs: !1
}), ro = ({
  openedQuestion: o,
  muted: l,
  webos: r
}) => {
  var n, i;
  const {
    sdk: s
  } = so();
  return ((n = o == null ? void 0 : o.attributes) == null ? void 0 : n.attributes.case) === "insight" ? /* @__PURE__ */ t(M, {
    ...o.attributes.attributes.value,
    muted: l,
    controlVideo: s == null ? void 0 : s.controlVideoPlayer,
    webos: r
  }) : ((i = o == null ? void 0 : o.attributes) == null ? void 0 : i.attributes.case) === "tweet" ? /* @__PURE__ */ t(W, {
    ...o.attributes.attributes.value,
    muted: l,
    controlVideo: s == null ? void 0 : s.controlVideoPlayer
  }) : null;
}, uo = ({
  extendedQuestion: o,
  vote: l,
  close: r,
  webos: n
}) => {
  const {
    loading: i,
    data: s
  } = o;
  return s ? /* @__PURE__ */ t(X, {
    webos: n,
    vote: l,
    close: r,
    openedQuestion: s,
    isLoading: !!i
  }) : /* @__PURE__ */ t(Z, {});
}, Ao = ({
  gamification: o,
  sdk: l,
  muted: r,
  skipAutoClose: n,
  hideSponsor: i,
  className: s,
  hideHeader: B,
  webos: c
}) => {
  var b, g, h, A, f, Q, w, y, T, x, U, I, S, N, $, k;
  const a = v(o.openedQuestion.$store), e = v(o.openedQuestion.$extendedStore), [D, R] = G(!1), j = v(l.options), q = ((b = a == null ? void 0 : a.attributes) == null ? void 0 : b.type) === L.FACTOID, d = (g = a == null ? void 0 : a.attributes) == null ? void 0 : g.backgroundImage, u = (h = e.data) == null ? void 0 : h.backgroundImage, P = q ? d == null ? void 0 : d.landscapeUrl : u == null ? void 0 : u.landscapeUrl, H = q ? d == null ? void 0 : d.portraitUrl : u == null ? void 0 : u.portraitUrl, C = oo({
    containerId: j.containerId,
    landscapeUrl: P,
    portraitUrl: H
  });
  if (!a)
    return null;
  const E = a.type, O = ((f = (A = e.data) == null ? void 0 : A.options) == null ? void 0 : f.options.case) === "factoid" ? e.data.options.options.value.closeTimer : void 0;
  return e.data && e.data.adUnit === eo.STANDART && !D ? /* @__PURE__ */ m(V, {
    className: s,
    children: [C, /* @__PURE__ */ t(ao, {
      id: e.data.id,
      hasBanner: !!((w = (Q = e.data.promotion) == null ? void 0 : Q.banner) != null && w.imageUrl),
      setAdShowed: R,
      sponsorLogo: ((T = (y = e.data.promotion) == null ? void 0 : y.sponsor) == null ? void 0 : T.logo) || ((x = e.data.sponsorship) == null ? void 0 : x.logo) || ""
    })]
  }) : /* @__PURE__ */ m(V, {
    className: s,
    children: [C, !B && /* @__PURE__ */ t(J, {
      closeTimer: n ? void 0 : O,
      close: o.closeQuestion,
      type: ((U = a.attributes) == null ? void 0 : U.type) || L.UNSET,
      webos: c
    }), E === "question" && /* @__PURE__ */ t(uo, {
      webos: c,
      vote: o.submitAnswer,
      close: o.closeQuestion,
      extendedQuestion: e
    }), E !== "question" && /* @__PURE__ */ t(ro, {
      muted: r,
      openedQuestion: a,
      webos: c
    }), !i && /* @__PURE__ */ t(K, {
      sponsorLogo: ((N = (S = (I = e.data) == null ? void 0 : I.promotion) == null ? void 0 : S.sponsor) == null ? void 0 : N.logo) || ((k = ($ = e.data) == null ? void 0 : $.sponsorship) == null ? void 0 : k.logo)
    })]
  });
};
export {
  to as e,
  Ao as h,
  so as p
};
