import { g as e } from "./alasql-f60045ee.js";
import t from "react";
import { u as r, p as s } from "./index-abe53b6f.js";
function a(e2, t2) {
  for (var r2 = 0; r2 < t2.length; r2++) {
    const s2 = t2[r2];
    if ("string" != typeof s2 && !Array.isArray(s2)) {
      for (const t3 in s2)
        if ("default" !== t3 && !(t3 in e2)) {
          const r3 = Object.getOwnPropertyDescriptor(s2, t3);
          r3 && Object.defineProperty(e2, t3, r3.get ? r3 : { enumerable: true, get: () => s2[t3] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }));
}
var o = Object.create, l = Object.defineProperty, i = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, p = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, c = (e2, t2, r2, s2) => {
  if (t2 && "object" == typeof t2 || "function" == typeof t2)
    for (let a2 of n(t2))
      u.call(e2, a2) || a2 === r2 || l(e2, a2, { get: () => t2[a2], enumerable: !(s2 = i(t2, a2)) || s2.enumerable });
  return e2;
}, y = (e2, t2, r2) => (((e3, t3, r3) => {
  t3 in e3 ? l(e3, t3, { enumerable: true, configurable: true, writable: true, value: r3 }) : e3[t3] = r3;
})(e2, "symbol" != typeof t2 ? t2 + "" : t2, r2), r2), f = {};
((e2, t2) => {
  for (var r2 in t2)
    l(e2, r2, { get: t2[r2], enumerable: true });
})(f, { default: () => O });
var h, d = (h = f, c(l({}, "__esModule", { value: true }), h)), b = ((e2, t2, r2) => (r2 = null != e2 ? o(p(e2)) : {}, c(!t2 && e2 && e2.__esModule ? r2 : l(r2, "default", { value: e2, enumerable: true }), e2)))(t), m = r, g = s;
const P = "https://connect.facebook.net/en_US/sdk.js", v = "fbAsyncInit";
class O extends b.Component {
  constructor() {
    super(...arguments), y(this, "callPlayer", m.callPlayer), y(this, "playerID", this.props.config.playerId || `facebook-player-${(0, m.randomString)()}`), y(this, "mute", () => {
      this.callPlayer("mute");
    }), y(this, "unmute", () => {
      this.callPlayer("unmute");
    });
  }
  componentDidMount() {
    this.props.onMount && this.props.onMount(this);
  }
  load(e2, t2) {
    t2 ? (0, m.getSDK)(P, "FB", v).then((e3) => e3.XFBML.parse()) : (0, m.getSDK)(P, "FB", v).then((e3) => {
      e3.init({ appId: this.props.config.appId, xfbml: true, version: this.props.config.version }), e3.Event.subscribe("xfbml.render", (e4) => {
        this.props.onLoaded();
      }), e3.Event.subscribe("xfbml.ready", (e4) => {
        "video" === e4.type && e4.id === this.playerID && (this.player = e4.instance, this.player.subscribe("startedPlaying", this.props.onPlay), this.player.subscribe("paused", this.props.onPause), this.player.subscribe("finishedPlaying", this.props.onEnded), this.player.subscribe("startedBuffering", this.props.onBuffer), this.player.subscribe("finishedBuffering", this.props.onBufferEnd), this.player.subscribe("error", this.props.onError), this.props.muted ? this.callPlayer("mute") : this.callPlayer("unmute"), this.props.onReady(), document.getElementById(this.playerID).querySelector("iframe").style.visibility = "visible");
      });
    });
  }
  play() {
    this.callPlayer("play");
  }
  pause() {
    this.callPlayer("pause");
  }
  stop() {
  }
  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("getCurrentPosition");
  }
  getSecondsLoaded() {
    return null;
  }
  render() {
    const { attributes: e2 } = this.props.config;
    return b.default.createElement("div", { style: { width: "100%", height: "100%" }, id: this.playerID, className: "fb-video", "data-href": this.props.url, "data-autoplay": this.props.playing ? "true" : "false", "data-allowfullscreen": "true", "data-controls": this.props.controls ? "true" : "false", ...e2 });
  }
}
y(O, "displayName", "Facebook"), y(O, "canPlay", g.canPlay.facebook), y(O, "loopOnEnded", true);
const j = a({ __proto__: null, default: e(d) }, [d]);
export {
  j as F
};
