"use strict";
"use client";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Video_exports = {};
__export(Video_exports, {
  default: () => Video_default
});
module.exports = __toCommonJS(Video_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_css = require("@emotion/css");
var import_react = require("react");
var import_react_player = require("../../shared/react-player");
var import_use_style = require("../../../runtimes/react/use-style");
var import_placeholders = require("../../utils/placeholders");
const ASPECT_RATIO = 16 / 9;
const Video = (0, import_react.forwardRef)(function Video2({ id, video, width, margin, borderRadius }, ref) {
  const canPlayUrl = video && video.url != null && import_react_player.ReactPlayer.canPlay(video.url);
  const [shouldRenderReactPlayer, setShouldRenderReactPlayer] = (0, import_react.useState)(false);
  (0, import_react.useEffect)(() => {
    setShouldRenderReactPlayer(true);
  }, []);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    "div",
    {
      ref,
      id,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({ display: "flex", flexDirection: "column", overflow: "hidden" }),
        width,
        margin,
        borderRadius
      ),
      children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { position: "relative", paddingTop: `${100 / ASPECT_RATIO}%` }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, children: shouldRenderReactPlayer && canPlayUrl === true ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import_react_player.ReactPlayer,
        {
          ...video,
          width: "100%",
          height: "100%",
          config: {
            vimeo: { playerOptions: { background: video != null && !video.controls } },
            wistia: {
              options: {
                endVideoBehavior: video != null && video.loop === true ? "loop" : "default"
              }
            }
          }
        }
      ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { width: "100%", src: import_placeholders.placeholders.video.src, alt: "Video Placeholder" }) }) })
    }
  );
});
var Video_default = Video;
//# sourceMappingURL=Video.js.map