import s from "./index-extends.js";
import d from "./index-asyncToGenerator.js";
import p from "./index-defineProperty.js";
import i, { forwardRef as f, Component as l } from "react";
import u from "./index-FacebookContext.js";
class a extends l {
  componentDidMount() {
    this.$isMounted = !0, this.prepare();
  }
  componentWillUnmount() {
    this.$isMounted = !1;
  }
  prepare() {
    var e = this;
    return d(function* () {
      const {
        onReady: t,
        handleInit: n
      } = e.props, o = yield n();
      t && e.$isMounted && t(o);
    })();
  }
  render() {
    const {
      children: e,
      isReady: t,
      api: n
    } = this.props, o = {
      isReady: t,
      api: n
    };
    return typeof e == "function" ? e(o) : e;
  }
}
p(a, "defaultProps", {
  onReady: void 0,
  api: void 0
});
const _ = f((r, e) => i.createElement(u.Consumer, null, ({
  handleInit: t,
  isReady: n,
  api: o
}) => i.createElement(a, s({}, r, {
  handleInit: t,
  isReady: n,
  api: o,
  ref: e
}))));
export {
  _ as default
};
