import { g as e } from "./alasql-f59e855e.js";
import t from "react";
import { u as r, p as a } from "./index-037d59a7.js";
function s(e2, t2) {
  for (var r2 = 0; r2 < t2.length; r2++) {
    const a2 = t2[r2];
    if ("string" != typeof a2 && !Array.isArray(a2)) {
      for (const t3 in a2)
        if ("default" !== t3 && !(t3 in e2)) {
          const r3 = Object.getOwnPropertyDescriptor(a2, t3);
          r3 && Object.defineProperty(e2, t3, r3.get ? r3 : { enumerable: true, get: () => a2[t3] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }));
}
var l = Object.create, n = Object.defineProperty, o = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, p = Object.getPrototypeOf, h = Object.prototype.hasOwnProperty, y = (e2, t2, r2, a2) => {
  if (t2 && "object" == typeof t2 || "function" == typeof t2)
    for (let s2 of i(t2))
      h.call(e2, s2) || s2 === r2 || n(e2, s2, { get: () => t2[s2], enumerable: !(a2 = o(t2, s2)) || a2.enumerable });
  return e2;
}, c = (e2, t2, r2) => (((e3, t3, r3) => {
  t3 in e3 ? n(e3, t3, { enumerable: true, configurable: true, writable: true, value: r3 }) : e3[t3] = r3;
})(e2, "symbol" != typeof t2 ? t2 + "" : t2, r2), r2), d = {};
((e2, t2) => {
  for (var r2 in t2)
    n(e2, r2, { get: t2[r2], enumerable: true });
})(d, { default: () => b });
var u, m = (u = d, y(n({}, "__esModule", { value: true }), u)), f = ((e2, t2, r2) => (r2 = null != e2 ? l(p(e2)) : {}, y(!t2 && e2 && e2.__esModule ? r2 : n(r2, "default", { value: e2, enumerable: true }), e2)))(t), P = r, g = a;
class b extends f.Component {
  constructor() {
    super(...arguments), c(this, "callPlayer", P.callPlayer), c(this, "playerID", this.props.config.playerId || `twitch-player-${(0, P.randomString)()}`), c(this, "mute", () => {
      this.callPlayer("setMuted", true);
    }), c(this, "unmute", () => {
      this.callPlayer("setMuted", false);
    });
  }
  componentDidMount() {
    this.props.onMount && this.props.onMount(this);
  }
  load(e2, t2) {
    const { playsinline: r2, onError: a2, config: s2, controls: l2 } = this.props, n2 = g.MATCH_URL_TWITCH_CHANNEL.test(e2), o2 = n2 ? e2.match(g.MATCH_URL_TWITCH_CHANNEL)[1] : e2.match(g.MATCH_URL_TWITCH_VIDEO)[1];
    t2 ? n2 ? this.player.setChannel(o2) : this.player.setVideo("v" + o2) : (0, P.getSDK)("https://player.twitch.tv/js/embed/v1.js", "Twitch").then((t3) => {
      this.player = new t3.Player(this.playerID, { video: n2 ? "" : o2, channel: n2 ? o2 : "", height: "100%", width: "100%", playsinline: r2, autoplay: this.props.playing, muted: this.props.muted, controls: !!n2 || l2, time: (0, P.parseStartTime)(e2), ...s2.options });
      const { READY: a3, PLAYING: i2, PAUSE: p2, ENDED: h2, ONLINE: y2, OFFLINE: c2, SEEK: d2 } = t3.Player;
      this.player.addEventListener(a3, this.props.onReady), this.player.addEventListener(i2, this.props.onPlay), this.player.addEventListener(p2, this.props.onPause), this.player.addEventListener(h2, this.props.onEnded), this.player.addEventListener(d2, this.props.onSeek), this.player.addEventListener(y2, this.props.onLoaded), this.player.addEventListener(c2, this.props.onLoaded);
    }, a2);
  }
  play() {
    this.callPlayer("play");
  }
  pause() {
    this.callPlayer("pause");
  }
  stop() {
    this.callPlayer("pause");
  }
  seekTo(e2, t2 = true) {
    this.callPlayer("seek", e2), t2 || this.pause();
  }
  setVolume(e2) {
    this.callPlayer("setVolume", e2);
  }
  getDuration() {
    return this.callPlayer("getDuration");
  }
  getCurrentTime() {
    return this.callPlayer("getCurrentTime");
  }
  getSecondsLoaded() {
    return null;
  }
  render() {
    return f.default.createElement("div", { style: { width: "100%", height: "100%" }, id: this.playerID });
  }
}
c(b, "displayName", "Twitch"), c(b, "canPlay", g.canPlay.twitch), c(b, "loopOnEnded", true);
const E = s({ __proto__: null, default: e(m) }, [m]);
export {
  E as T
};
