import { jsx, jsxs } from "react/jsx-runtime";
import { q, B, z, h, W, a as anonymous } from "./index2.js";
import { F } from "./index2.js";
import { useRef, useEffect } from "react";
const plugins = /* @__PURE__ */ new Set([anonymous]);
const StreamLayerProvider = (props) => {
  return /* @__PURE__ */ jsx(
    q,
    {
      ...props,
      themeMode: "dark",
      withAd: true,
      skipOnboarding: true,
      withAdNotification: true,
      autoEnable: true,
      plugins,
      friendsTab: "disabled",
      hideFriends: true,
      webOS: true
    }
  );
};
const AnonymousLogin = ({ sdk }) => {
  useEffect(() => {
    sdk.anonymousAuthorization();
  }, [sdk]);
  return null;
};
const StreamLayerSDKTv = ({
  persistent,
  children,
  showPauseAd,
  pauseAdVastUrl,
  videoPlayerController,
  onRenderPauseAd,
  onClosePauseAd,
  options
}) => {
  const sdk = B();
  const baseTheme = z();
  const ref = useRef();
  useEffect(() => {
    if (sdk) {
      if (videoPlayerController) {
        ref.current = videoPlayerController;
        sdk.addVideoPlayerController(ref.current);
      }
      return () => {
        if (ref.current) {
          sdk.removeVideoPlayerController(ref.current);
        }
      };
    }
  }, [sdk]);
  if (!sdk) {
    return null;
  }
  return /* @__PURE__ */ jsx("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ jsxs(h, { customTheme: baseTheme.theme, themeMode: baseTheme.themeMode, children: [
    /* @__PURE__ */ jsx(
      W,
      {
        sdk,
        persistent,
        showPauseAd,
        onRenderPauseAd,
        pauseAdVastUrl,
        onClosePauseAd,
        options,
        children
      }
    ),
    /* @__PURE__ */ jsx(AnonymousLogin, { sdk })
  ] }) });
};
export {
  StreamLayerProvider,
  StreamLayerSDKTv,
  B as useStreamLayer,
  z as useStreamLayerTheme,
  F as useStreamLayerUI
};
