import b from "./index-asyncToGenerator.js";
import i from "./index-defineProperty.js";
import y, { Component as R } from "react";
import k from "./index-_virtual5.js";
import v from "./index-Facebook.js";
import w from "./index-FacebookContext.js";
let t = null;
class g extends R {
  constructor(...o) {
    var e;
    super(...o), e = this, i(this, "state", {
      isReady: !1
    }), i(
      this,
      "handleInit",
      /* @__PURE__ */ b(function* () {
        if (!k)
          throw new Error("You can not use Facebook without DOM");
        const {
          isReady: s
        } = e.state;
        if (s)
          return t;
        if (!t) {
          const {
            domain: a,
            version: n,
            appId: r,
            cookie: c,
            status: f,
            xfbml: l,
            language: u,
            frictionlessRequests: d,
            wait: p,
            debug: m,
            chatSupport: h
          } = e.props;
          t = new v({
            domain: a,
            appId: r,
            version: n,
            cookie: c,
            status: f,
            xfbml: l,
            language: u,
            frictionlessRequests: d,
            wait: p,
            debug: m,
            chatSupport: h
          });
        }
        return yield t.init(), e.state.isReady || e.setState({
          isReady: !0
        }), t;
      })
    );
  }
  componentDidMount() {
    const {
      wait: o
    } = this.props;
    o || this.handleInit();
  }
  render() {
    const {
      children: o
    } = this.props, {
      isReady: e,
      error: s
    } = this.state, {
      handleInit: a
    } = this, n = {
      isReady: e,
      error: s,
      handleInit: a,
      api: t
    };
    return y.createElement(w.Provider, {
      value: n
    }, o);
  }
}
i(g, "defaultProps", {
  version: "v3.1",
  cookie: !1,
  status: !1,
  xfbml: !1,
  language: "en_US",
  frictionlessRequests: !1,
  domain: "connect.facebook.net",
  children: void 0,
  wait: !1,
  debug: !1,
  chatSupport: !1
});
export {
  g as default
};
