import { H as q } from "./use-page-data.BYLN5MSa.js";
import K from "react";
import { r as V, a as W } from "./video.Ctm1aA2_.js";
function Y(l, a) {
  for (var p = 0; p < a.length; p++) {
    const s = a[p];
    if (typeof s != "string" && !Array.isArray(s)) {
      for (const i in s)
        if (i !== "default" && !(i in l)) {
          const c = Object.getOwnPropertyDescriptor(s, i);
          c && Object.defineProperty(l, i, c.get ? c : {
            enumerable: !0,
            get: () => s[i]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(l, Symbol.toStringTag, { value: "Module" }));
}
var P, O;
function $() {
  if (O) return P;
  O = 1;
  var l = Object.create, a = Object.defineProperty, p = Object.getOwnPropertyDescriptor, s = Object.getOwnPropertyNames, i = Object.getPrototypeOf, c = Object.prototype.hasOwnProperty, w = (t, e, r) => e in t ? a(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, L = (t, e) => {
    for (var r in e)
      a(t, r, { get: e[r], enumerable: !0 });
  }, v = (t, e, r, _) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let n of s(e))
        !c.call(t, n) && n !== r && a(t, n, { get: () => e[n], enumerable: !(_ = p(e, n)) || _.enumerable });
    return t;
  }, b = (t, e, r) => (r = t != null ? l(i(t)) : {}, v(
    // 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.
    !t || !t.__esModule ? a(r, "default", { value: t, enumerable: !0 }) : r,
    t
  )), D = (t) => v(a({}, "__esModule", { value: !0 }), t), o = (t, e, r) => (w(t, typeof e != "symbol" ? e + "" : e, r), r), m = {};
  L(m, {
    default: () => y
  }), P = D(m);
  var g = b(K), h = /* @__PURE__ */ V(), d = /* @__PURE__ */ W();
  const C = "https://player.twitch.tv/js/embed/v1.js", N = "Twitch", I = "twitch-player-";
  class y extends g.Component {
    constructor() {
      super(...arguments), o(this, "callPlayer", h.callPlayer), o(this, "playerID", this.props.config.playerId || `${I}${(0, h.randomString)()}`), o(this, "mute", () => {
        this.callPlayer("setMuted", !0);
      }), o(this, "unmute", () => {
        this.callPlayer("setMuted", !1);
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e, r) {
      const { playsinline: _, onError: n, config: M, controls: S } = this.props, u = d.MATCH_URL_TWITCH_CHANNEL.test(e), f = u ? e.match(d.MATCH_URL_TWITCH_CHANNEL)[1] : e.match(d.MATCH_URL_TWITCH_VIDEO)[1];
      if (r) {
        u ? this.player.setChannel(f) : this.player.setVideo("v" + f);
        return;
      }
      (0, h.getSDK)(C, N).then((E) => {
        this.player = new E.Player(this.playerID, {
          video: u ? "" : f,
          channel: u ? f : "",
          height: "100%",
          width: "100%",
          playsinline: _,
          autoplay: this.props.playing,
          muted: this.props.muted,
          // https://github.com/CookPete/react-player/issues/733#issuecomment-549085859
          controls: u ? !0 : S,
          time: (0, h.parseStartTime)(e),
          ...M.options
        });
        const { READY: j, PLAYING: A, PAUSE: R, ENDED: H, ONLINE: x, OFFLINE: U, SEEK: F } = E.Player;
        this.player.addEventListener(j, this.props.onReady), this.player.addEventListener(A, this.props.onPlay), this.player.addEventListener(R, this.props.onPause), this.player.addEventListener(H, this.props.onEnded), this.player.addEventListener(F, this.props.onSeek), this.player.addEventListener(x, this.props.onLoaded), this.player.addEventListener(U, this.props.onLoaded);
      }, n);
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
      this.callPlayer("pause");
    }
    seekTo(e, r = !0) {
      this.callPlayer("seek", e), r || this.pause();
    }
    setVolume(e) {
      this.callPlayer("setVolume", e);
    }
    getDuration() {
      return this.callPlayer("getDuration");
    }
    getCurrentTime() {
      return this.callPlayer("getCurrentTime");
    }
    getSecondsLoaded() {
      return null;
    }
    render() {
      const e = {
        width: "100%",
        height: "100%"
      };
      return /* @__PURE__ */ g.default.createElement("div", { style: e, id: this.playerID });
    }
  }
  return o(y, "displayName", "Twitch"), o(y, "canPlay", d.canPlay.twitch), o(y, "loopOnEnded", !0), P;
}
var T = /* @__PURE__ */ $();
const G = /* @__PURE__ */ q(T), J = /* @__PURE__ */ Y({
  __proto__: null,
  default: G
}, [T]);
export {
  J as T
};
