import { H as k } from "./use-page-data.BYLN5MSa.js";
import D from "react";
function M(c, n) {
  for (var p = 0; p < n.length; p++) {
    const i = n[p];
    if (typeof i != "string" && !Array.isArray(i)) {
      for (const s in i)
        if (s !== "default" && !(s in c)) {
          const u = Object.getOwnPropertyDescriptor(i, s);
          u && Object.defineProperty(c, s, u.get ? u : {
            enumerable: !0,
            get: () => i[s]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(c, Symbol.toStringTag, { value: "Module" }));
}
var v, O;
function A() {
  if (O) return v;
  O = 1;
  var c = Object.create, n = Object.defineProperty, p = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, s = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, I = (r, e, t) => e in r ? n(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, j = (r, e) => {
    for (var t in e)
      n(r, t, { get: e[t], enumerable: !0 });
  }, b = (r, e, t, o) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let a of i(e))
        !u.call(r, a) && a !== t && n(r, a, { get: () => e[a], enumerable: !(o = p(e, a)) || o.enumerable });
    return r;
  }, E = (r, e, t) => (t = r != null ? c(s(r)) : {}, b(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    !r || !r.__esModule ? n(t, "default", { value: r, enumerable: !0 }) : t,
    r
  )), S = (r) => b(n({}, "__esModule", { value: !0 }), r), f = (r, e, t) => (I(r, typeof e != "symbol" ? e + "" : e, t), t), y = {};
  j(y, {
    default: () => C
  }), v = S(y);
  var l = E(D);
  const h = "64px", _ = {};
  class C extends l.Component {
    constructor() {
      super(...arguments), f(this, "mounted", !1), f(this, "state", {
        image: null
      }), f(this, "handleKeyPress", (e) => {
        (e.key === "Enter" || e.key === " ") && this.props.onClick();
      });
    }
    componentDidMount() {
      this.mounted = !0, this.fetchImage(this.props);
    }
    componentDidUpdate(e) {
      const { url: t, light: o } = this.props;
      (e.url !== t || e.light !== o) && this.fetchImage(this.props);
    }
    componentWillUnmount() {
      this.mounted = !1;
    }
    fetchImage({ url: e, light: t, oEmbedUrl: o }) {
      if (!l.default.isValidElement(t)) {
        if (typeof t == "string") {
          this.setState({ image: t });
          return;
        }
        if (_[e]) {
          this.setState({ image: _[e] });
          return;
        }
        return this.setState({ image: null }), window.fetch(o.replace("{url}", e)).then((a) => a.json()).then((a) => {
          if (a.thumbnail_url && this.mounted) {
            const d = a.thumbnail_url.replace("height=100", "height=480").replace("-d_295x166", "-d_640");
            this.setState({ image: d }), _[e] = d;
          }
        });
      }
    }
    render() {
      const { light: e, onClick: t, playIcon: o, previewTabIndex: a, previewAriaLabel: d } = this.props, { image: w } = this.state, g = l.default.isValidElement(e), P = {
        display: "flex",
        alignItems: "center",
        justifyContent: "center"
      }, m = {
        preview: {
          width: "100%",
          height: "100%",
          backgroundImage: w && !g ? `url(${w})` : void 0,
          backgroundSize: "cover",
          backgroundPosition: "center",
          cursor: "pointer",
          ...P
        },
        shadow: {
          background: "radial-gradient(rgb(0, 0, 0, 0.3), rgba(0, 0, 0, 0) 60%)",
          borderRadius: h,
          width: h,
          height: h,
          position: g ? "absolute" : void 0,
          ...P
        },
        playIcon: {
          borderStyle: "solid",
          borderWidth: "16px 0 16px 26px",
          borderColor: "transparent transparent transparent white",
          marginLeft: "7px"
        }
      }, N = /* @__PURE__ */ l.default.createElement("div", { style: m.shadow, className: "react-player__shadow" }, /* @__PURE__ */ l.default.createElement("div", { style: m.playIcon, className: "react-player__play-icon" }));
      return /* @__PURE__ */ l.default.createElement(
        "div",
        {
          style: m.preview,
          className: "react-player__preview",
          onClick: t,
          tabIndex: a,
          onKeyPress: this.handleKeyPress,
          ...d ? { "aria-label": d } : {}
        },
        g ? e : null,
        o || N
      );
    }
  }
  return v;
}
var x = /* @__PURE__ */ A();
const K = /* @__PURE__ */ k(x), z = /* @__PURE__ */ M({
  __proto__: null,
  default: K
}, [x]);
export {
  z as P
};
