import { g as e } from "./alasql-f60045ee.js";
import t from "react";
import { u as a, p as n } from "./index-abe53b6f.js";
function o(e2, t2) {
  for (var a2 = 0; a2 < t2.length; a2++) {
    const n2 = t2[a2];
    if ("string" != typeof n2 && !Array.isArray(n2)) {
      for (const t3 in n2)
        if ("default" !== t3 && !(t3 in e2)) {
          const a3 = Object.getOwnPropertyDescriptor(n2, t3);
          a3 && Object.defineProperty(e2, t3, a3.get ? a3 : { enumerable: true, get: () => n2[t3] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }));
}
var s = Object.create, l = Object.defineProperty, r = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, p = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, y = (e2, t2, a2, n2) => {
  if (t2 && "object" == typeof t2 || "function" == typeof t2)
    for (let o2 of i(t2))
      u.call(e2, o2) || o2 === a2 || l(e2, o2, { get: () => t2[o2], enumerable: !(n2 = r(t2, o2)) || n2.enumerable });
  return e2;
}, h = (e2, t2, a2) => (((e3, t3, a3) => {
  t3 in e3 ? l(e3, t3, { enumerable: true, configurable: true, writable: true, value: a3 }) : e3[t3] = a3;
})(e2, "symbol" != typeof t2 ? t2 + "" : t2, a2), a2), c = {};
((e2, t2) => {
  for (var a2 in t2)
    l(e2, a2, { get: t2[a2], enumerable: true });
})(c, { default: () => g });
var d, b = (d = c, y(l({}, "__esModule", { value: true }), d)), m = ((e2, t2, a2) => (a2 = null != e2 ? s(p(e2)) : {}, y(!t2 && e2 && e2.__esModule ? a2 : l(a2, "default", { value: e2, enumerable: true }), e2)))(t), P = a, f = n;
class g extends m.Component {
  constructor() {
    super(...arguments), h(this, "callPlayer", P.callPlayer), h(this, "playerID", this.props.config.playerId || `wistia-player-${(0, P.randomString)()}`), h(this, "onPlay", (...e2) => this.props.onPlay(...e2)), h(this, "onPause", (...e2) => this.props.onPause(...e2)), h(this, "onSeek", (...e2) => this.props.onSeek(...e2)), h(this, "onEnded", (...e2) => this.props.onEnded(...e2)), h(this, "onPlaybackRateChange", (...e2) => this.props.onPlaybackRateChange(...e2)), h(this, "mute", () => {
      this.callPlayer("mute");
    }), h(this, "unmute", () => {
      this.callPlayer("unmute");
    });
  }
  componentDidMount() {
    this.props.onMount && this.props.onMount(this);
  }
  load(e2) {
    const { playing: t2, muted: a2, controls: n2, onReady: o2, config: s2, onError: l2 } = this.props;
    (0, P.getSDK)("https://fast.wistia.com/assets/external/E-v1.js", "Wistia").then((e3) => {
      s2.customControls && s2.customControls.forEach((t3) => e3.defineControl(t3)), window._wq = window._wq || [], window._wq.push({ id: this.playerID, options: { autoPlay: t2, silentAutoPlay: "allow", muted: a2, controlsVisibleOnLoad: n2, fullscreenButton: n2, playbar: n2, playbackRateControl: n2, qualityControl: n2, volumeControl: n2, settingsControl: n2, smallPlayButton: n2, ...s2.options }, onReady: (e4) => {
        this.player = e4, this.unbind(), this.player.bind("play", this.onPlay), this.player.bind("pause", this.onPause), this.player.bind("seek", this.onSeek), this.player.bind("end", this.onEnded), this.player.bind("playbackratechange", this.onPlaybackRateChange), o2();
      } });
    }, l2);
  }
  unbind() {
    this.player.unbind("play", this.onPlay), this.player.unbind("pause", this.onPause), this.player.unbind("seek", this.onSeek), this.player.unbind("end", this.onEnded), this.player.unbind("playbackratechange", this.onPlaybackRateChange);
  }
  play() {
    this.callPlayer("play");
  }
  pause() {
    this.callPlayer("pause");
  }
  stop() {
    this.unbind(), this.callPlayer("remove");
  }
  seekTo(e2, t2 = true) {
    this.callPlayer("time", e2), t2 || this.pause();
  }
  setVolume(e2) {
    this.callPlayer("volume", e2);
  }
  setPlaybackRate(e2) {
    this.callPlayer("playbackRate", e2);
  }
  getDuration() {
    return this.callPlayer("duration");
  }
  getCurrentTime() {
    return this.callPlayer("time");
  }
  getSecondsLoaded() {
    return null;
  }
  render() {
    const { url: e2 } = this.props, t2 = e2 && e2.match(f.MATCH_URL_WISTIA)[1], a2 = `wistia_embed wistia_async_${t2}`;
    return m.default.createElement("div", { id: this.playerID, key: t2, className: a2, style: { width: "100%", height: "100%" } });
  }
}
h(g, "displayName", "Wistia"), h(g, "canPlay", f.canPlay.wistia), h(g, "loopOnEnded", true);
const w = o({ __proto__: null, default: e(b) }, [b]);
export {
  w as W
};
