import a from "classnames";
import t from "react";
import n from "react-tooltip";
import { Popover as h } from "./accelbyte-widgets434.mjs";
import { InputLabel as m } from "./accelbyte-widgets435.mjs";
import i from "./accelbyte-widgets436.mjs";
class S extends t.Component {
  constructor() {
    super(...arguments), this.tooltipRef = t.createRef(), this.state = {
      isFocused: !1
    }, this.onShow = () => {
      this.tooltipRef.current && n.show(this.tooltipRef.current);
    }, this.onHide = () => {
      this.tooltipRef.current && n.hide(this.tooltipRef.current);
    }, this.onFocus = (o) => {
      const { onFocus: e } = this.props;
      e && e(o), this.onShow(), this.setState({ isFocused: !0 });
    }, this.onBlur = (o) => {
      const { onBlur: e } = this.props;
      e && e(o), this.onHide(), this.setState({ isFocused: !1 });
    }, this.onMouseEnter = () => {
      this.state.isFocused && this.onShow();
    };
  }
  componentDidMount() {
    window.addEventListener("scroll", this.onHide, !0);
  }
  componentWillUnmount() {
    window.addEventListener("scroll", this.onHide, !0);
  }
  render() {
    const {
      className: o,
      dataQa: e,
      beforeElement: p,
      afterElement: c,
      popoverContent: d,
      popoverId: r,
      maxLength: l,
      onBlur: E,
      onFocus: F,
      label: u,
      ...s
    } = this.props;
    return /* @__PURE__ */ t.createElement(t.Fragment, null, u && /* @__PURE__ */ t.createElement(m, { value: s.value, maxLength: l }, u), /* @__PURE__ */ t.createElement(
      "div",
      {
        className: a(
          o,
          "inputGroup",
          i.inputGroup,
          this.state.isFocused && i.focused,
          s.disabled && i.disabled
        )
      },
      p || null,
      /* @__PURE__ */ t.createElement(
        "input",
        {
          ...s,
          "data-qa-id": e,
          onFocus: this.onFocus,
          onBlur: this.onBlur,
          onMouseEnter: this.onMouseEnter,
          className: a(s.disabled && i.isDisabled),
          maxLength: l
        }
      ),
      c || null,
      /* @__PURE__ */ t.createElement(h, { tooltipRef: this.tooltipRef, id: r, hideMobile: !0 }, d),
      /* @__PURE__ */ t.createElement(n, { id: r })
    ));
  }
}
export {
  S as InputGroup
};
