import { __assign as n } from "../../../../tslib/tslib.es6.es.js";
import * as d from "react";
import { forwardRef as x, useContext as c } from "react";
import { useFeatures as y } from "./features/use-features.es.js";
import { MotionConfigContext as S } from "../context/MotionConfigContext.es.js";
import { MotionContext as j } from "../context/MotionContext/index.es.js";
import { useVisualElement as M } from "./utils/use-visual-element.es.js";
import { useMotionRef as V } from "./utils/use-motion-ref.es.js";
import { useCreateMotionContext as F } from "../context/MotionContext/create.es.js";
import { loadFeatures as R, featureDefinitions as g } from "./features/definitions.es.js";
import { isBrowser as N } from "../utils/is-browser.es.js";
import { useProjectionId as P } from "../projection/node/id.es.js";
import { LayoutGroupContext as w } from "../context/LayoutGroupContext.es.js";
import { useProjection as G } from "./features/use-projection.es.js";
import { VisualElementHandler as L } from "./utils/VisualElementHandler.es.js";
function W(t) {
  var o = t.preloadedFeatures, u = t.createVisualElement, a = t.projectionNodeConstructor, v = t.useRender, C = t.useVisualState, l = t.Component;
  o && R(o);
  function E(e, p) {
    var I = b(e);
    e = n(n({}, e), { layoutId: I });
    var i = c(S), s = null, r = F(e), f = i.isStatic ? void 0 : P(), m = C(e, i.isStatic);
    return !i.isStatic && N && (r.visualElement = M(l, m, n(n({}, i), e), u), G(f, e, r.visualElement, a || g.projectionNodeConstructor), s = y(e, r.visualElement, o)), d.createElement(
      L,
      { visualElement: r.visualElement, props: n(n({}, i), e) },
      s,
      d.createElement(j.Provider, { value: r }, v(l, e, f, V(m, r.visualElement, p), m, i.isStatic, r.visualElement))
    );
  }
  return x(E);
}
function b(t) {
  var o, u = t.layoutId, a = (o = c(w)) === null || o === void 0 ? void 0 : o.id;
  return a && u !== void 0 ? a + "-" + u : u;
}
export {
  W as createMotionComponent
};
//# sourceMappingURL=index.es.js.map
