import d from "./index-asyncToGenerator.js";
import i from "./index-defineProperty.js";
import c, { Component as l } from "react";
import h from "./index-Initialize.js";
class _ extends l {
  constructor(...n) {
    var t;
    super(...n), t = this, i(this, "state", {
      api: void 0
    }), i(
      this,
      "handleProcess",
      /* @__PURE__ */ (function() {
        var e = d(function* (a, o = () => {
        }) {
          t.setState({
            data: void 0,
            error: void 0,
            loading: !0
          });
          try {
            const {
              api: r
            } = t.state;
            if (!r)
              throw new Error("Facebook is not initialized. Wait for isReady");
            const s = yield a(r);
            return t.setState({
              data: s,
              loading: !1
            }, o), s;
          } catch (r) {
            throw t.setState({
              error: r,
              loading: !1
            }), r;
          }
        });
        return function(a) {
          return e.apply(this, arguments);
        };
      })()
    ), i(this, "handleReady", (e) => {
      this.setState({
        api: e
      });
    });
  }
  render() {
    const {
      children: n
    } = this.props, {
      api: t,
      loading: e,
      data: a,
      error: o
    } = this.state;
    return c.createElement(h, {
      onReady: this.handleReady
    }, n({
      loading: !t || e,
      handleProcess: this.handleProcess,
      data: a,
      error: o
    }));
  }
}
export {
  _ as default
};
