import a from "./index-asyncToGenerator.js";
import r from "./index-defineProperty.js";
import i, { Component as h } from "react";
import p from "./index-Initialize.js";
class d extends h {
  constructor(...e) {
    var t;
    super(...e), t = this, r(this, "state", {}), r(
      this,
      "handleReady",
      /* @__PURE__ */ (function() {
        var s = a(function* (n) {
          const {
            event: o
          } = t.props;
          t.setState({
            api: n
          }), yield n.subscribe(o, t.handleChange);
        });
        return function(n) {
          return s.apply(this, arguments);
        };
      })()
    ), r(this, "handleChange", (...s) => {
      const {
        onChange: n
      } = this.props;
      n && n(...s);
    });
  }
  componentWillUnmount() {
    const {
      state: {
        api: e
      },
      props: {
        event: t
      }
    } = this;
    e && e.unsubscribe(t, this.handleChange);
  }
  render() {
    const {
      children: e
    } = this.props;
    return i.createElement(p, {
      onReady: this.handleReady
    }, e);
  }
}
r(d, "defaultProps", {
  onChange: void 0
});
export {
  d as default
};
