import o from "../../../@babel/runtime/helpers/esm/extends.mjs";
import { supportRef as b } from "../../../rc-util/es/ref.mjs";
import * as e from "react";
function E() {
  var c = /* @__PURE__ */ e.createContext(null);
  function f() {
    return e.useContext(c);
  }
  function v(r, m) {
    var u = b(r), t = function(a, l) {
      var n = u ? {
        ref: l
      } : {}, s = e.useRef(0), i = e.useRef(a), p = f();
      return p !== null ? /* @__PURE__ */ e.createElement(r, o({}, a, n)) : (
        // Always trigger re-render if not provide `notTriggerRender`
        ((!m || m(i.current, a)) && (s.current += 1), i.current = a, /* @__PURE__ */ e.createElement(c.Provider, {
          value: s.current
        }, /* @__PURE__ */ e.createElement(r, o({}, a, n))))
      );
    };
    return process.env.NODE_ENV !== "production" && (t.displayName = "ImmutableRoot(".concat(r.displayName || r.name, ")")), u ? /* @__PURE__ */ e.forwardRef(t) : t;
  }
  function I(r, m) {
    var u = b(r), t = function(a, l) {
      var n = u ? {
        ref: l
      } : {};
      return f(), /* @__PURE__ */ e.createElement(r, o({}, a, n));
    };
    return process.env.NODE_ENV !== "production" && (t.displayName = "ImmutableResponse(".concat(r.displayName || r.name, ")")), u ? /* @__PURE__ */ e.memo(/* @__PURE__ */ e.forwardRef(t), m) : /* @__PURE__ */ e.memo(t, m);
  }
  return {
    makeImmutable: v,
    responseImmutable: I,
    useImmutableMark: f
  };
}
export {
  E as default
};
