"use client";
import { j as m } from "../../../../../node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.mjs";
import { useState as g, useEffect as i, useCallback as y } from "react";
import V from "../../../../../node_modules/.pnpm/react-player@2.16.0_react@19.1.0/node_modules/react-player/lib/index.mjs";
import { Carousel as E } from "@mantine/carousel";
import { useCarousel as M } from "../../index.mjs";
function D({
  slideProps: f,
  reactPlayerProps: v,
  indexInSlides: o,
  onEnd: e
}) {
  const {
    activeIndex: a,
    onVideoPlay: u,
    onVideoPaused: s,
    onVideoEnded: c,
    setTimeUntilSlideFinishedOverride: l,
    isVideoSlidePlaying: p,
    setSlideTimeOverride: d
  } = M(), [t, h] = g(5e3);
  i(() => {
    o !== void 0 && l(o, Number.MAX_SAFE_INTEGER);
  }, []);
  const P = y(() => {
    c(o), e == null || e();
  }, [c, e]);
  return i(() => {
    o === a ? u(o) : s(o);
  }, [a, o]), i(() => {
    o !== void 0 && d(o, t);
  }, [t]), /* @__PURE__ */ m.jsx(
    E.Slide,
    {
      "data-testid": `video-slide-${o}`,
      ...f,
      children: /* @__PURE__ */ m.jsx(
        V,
        {
          onDuration: (r) => h(Math.round(r * 1e3)),
          onProgress: (r) => {
            o !== void 0 && l(
              o,
              Math.round(t - r.playedSeconds * 1e3)
            );
          },
          width: "100%",
          height: "100%",
          onPlay: () => u(o),
          onPause: () => s(o),
          onEnded: P,
          playing: !!p[o],
          onClickPreview: () => console.log("preview clicked"),
          controls: !0,
          muted: !0,
          onError: (...r) => console.error(`Error while loading video: ${JSON.stringify(r)}`),
          ...v
        }
      )
    }
  );
}
export {
  D as SlideVideo
};
//# sourceMappingURL=index.mjs.map
