import a from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import K from "../../../rc-util/es/hooks/useEvent.mjs";
import o from "../../../rc-util/es/hooks/useMergedState.mjs";
import * as v from "react";
import "../../../rc-util/node_modules/react-is/index.mjs";
import "../../../rc-util/es/warning.mjs";
import L from "../../../rc-util/es/raf.mjs";
function Z(c, g, T, k, q, A, E, P, b, w, s) {
  var F = v.useState(!1), m = a(F, 2), I = m[0], l = m[1], h = o(c || !1, {
    value: g
  }), S = a(h, 2), j = S[0], z = S[1], B = o(c || !1, {
    value: g,
    onChange: function(e) {
      s == null || s(e);
    }
  }), d = a(B, 2), f = d[0], u = d[1], C = o(0, {
    value: T
  }), p = a(C, 2), D = p[0], _ = p[1], G = v.useState(null), M = a(G, 2), R = M[0], i = M[1];
  v.useEffect(function() {
    f && l(!0);
  }, [f]);
  var $ = function(e) {
    return e === 0 ? 1 : 0;
  }, H = K(function(r, e, y) {
    if (e === !1)
      u(r);
    else if (r) {
      _(e), u(r);
      var O = $(e);
      !f || // Also set next index if next is empty
      ![P, b][O] ? i(O) : (l(!1), R !== null && i(null));
    } else if (y === "confirm" || y === "blur" && k) {
      var t = j && !q ? $(e) : R;
      t !== null && (l(!1), _(t)), i(null), t !== null && !w[t] ? L(function() {
        var n, J = [A, E][t];
        (n = J.current) === null || n === void 0 || n.focus();
      }) : u(!1);
    } else
      u(!1), z(!1);
  });
  return [f, D, I, H];
}
export {
  Z as default
};
