import { b9 as B, w as s, cv as k, ba as h, f0 as H, bd as V, bf as M, bP as R, a0 as C, U as N, f1 as l, V as a, bg as r, cy as U, bh as b, P as u, bi as c, bj as g, bl as j, bn as D, bo as O, bp as F } from "./684d2f28.js";
import { useRef as S, useState as v, useEffect as z, useContext as f } from "react";
import { ButtonStyleControl as J } from "./9f282d74.js";
import "react-dom";
import "./d6402597.js";
const $ = B.video`
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
`, q = {
  autoHeight: s(k, "fixed"),
  profilePadding: s(h, "0px"),
  profileBorderRadius: s(h, "0px"),
  videoAspectRatio: s(h, ""),
  onEvent: H,
  disabled: V,
  loading: V,
  style: J,
  viewRef: M,
  userId: s(R(""), "{{meeting1.localUser}}"),
  noVideoText: R(C("meeting.noVideo"))
};
let y = function() {
  return new N(q, (e) => {
    const d = S(null), p = S(null), [x, I] = v(), [G, E] = v(""), [P, A] = v(!0);
    return z(() => {
      var m;
      if (e.userId.value !== "") {
        let i = JSON.parse((m = e.userId) == null ? void 0 : m.value);
        l.on("user-published", async (t, o) => {
          if (o === "video") {
            const n = await l.subscribe(t, o);
            let w = t.uid + "";
            t.hasVideo && t.uid + "" !== i.user && i.user !== "" && e.onEvent("videoOn"), document.getElementById(w) && n.play(w);
          }
          if (o === "audio") {
            const n = await l.subscribe(t, o);
            t.hasAudio && t.uid + "" !== i.user && i.user !== "" && (i.audiostatus = t.hasVideo, e.onEvent("audioUnmuted")), n.play();
          }
        }), l.on("user-unpublished", (t, o) => {
          var n;
          o === "audio" && !t.hasAudio && t.uid + "" !== i.user && i.user !== "" && (i.audiostatus = t.hasVideo, e.onEvent("audioMuted")), o === "video" && (d.current && ((n = d.current) == null ? void 0 : n.id) === t.uid + "" && (d.current.srcObject = null), !t.hasVideo && t.uid + "" !== i.user && i.user !== "" && e.onEvent("videoOff"));
        }), I(i.user), E(i.userName), A(i.streamingSharing);
      }
    }, [e.userId.value]), /* @__PURE__ */ a(r.Consumer, {
      children: (m) => /* @__PURE__ */ a(U, {
        children: /* @__PURE__ */ a("div", {
          ref: p,
          style: {
            display: "flex",
            alignItems: "center",
            height: "100%",
            overflow: "hidden",
            borderRadius: e.style.radius,
            aspectRatio: e.videoAspectRatio,
            backgroundColor: e.style.background,
            padding: e.style.padding,
            margin: e.style.margin
          },
          children: x ? /* @__PURE__ */ a($, {
            onClick: () => e.onEvent("videoClicked"),
            ref: d,
            style: {
              display: `${P ? "flex" : "none"}`,
              aspectRatio: e.videoAspectRatio,
              borderRadius: e.style.radius,
              width: "auto"
            },
            id: "share-screen"
          }) : /* @__PURE__ */ a(b, {})
        })
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ u(b, {
    children: [/* @__PURE__ */ a(c, {
      name: g.basic,
      children: e.userId.propertyView({
        label: C("meeting.videoId")
      })
    }), (f(r).editorModeStatus === "logic" || f(r).editorModeStatus === "both") && /* @__PURE__ */ u(c, {
      name: g.interaction,
      children: [e.onEvent.getPropertyView(), j(e)]
    }), (f(r).editorModeStatus === "layout" || f(r).editorModeStatus === "both") && /* @__PURE__ */ u(b, {
      children: [/* @__PURE__ */ a(c, {
        name: g.layout,
        children: e.autoHeight.getPropertyView()
      }), /* @__PURE__ */ u(c, {
        name: g.style,
        children: [e.profilePadding.propertyView({
          label: "Profile Image Padding"
        }), e.profileBorderRadius.propertyView({
          label: "Profile Image Border Radius"
        }), e.videoAspectRatio.propertyView({
          label: "Video Aspect Ratio"
        }), e.style.getPropertyView()]
      })]
    })]
  })).build();
}();
y = class extends y {
  autoHeight() {
    return this.children.autoHeight.getView();
  }
};
const Z = D(y, [new O("loading", C("button.loadingDesc")), ...F]);
export {
  Z as VideoSharingStreamComp
};
