import i from "./index-extends.js";
import u from "./index-objectWithoutPropertiesLoose.js";
import c from "./index-defaultSxConfig.js";
import { isPlainObject as m } from "./index-deepmerge.js";
const x = ["sx"], a = (t) => {
  var s, r;
  const o = {
    systemProps: {},
    otherProps: {}
  }, n = (s = t == null || (r = t.theme) == null ? void 0 : r.unstable_sxConfig) != null ? s : c;
  return Object.keys(t).forEach((e) => {
    n[e] ? o.systemProps[e] = t[e] : o.otherProps[e] = t[e];
  }), o;
};
function _(t) {
  const {
    sx: s
  } = t, r = u(t, x), {
    systemProps: o,
    otherProps: n
  } = a(r);
  let e;
  return Array.isArray(s) ? e = [o, ...s] : typeof s == "function" ? e = (...f) => {
    const l = s(...f);
    return m(l) ? i({}, o, l) : o;
  } : e = i({}, o, s), i({}, n, {
    sx: e
  });
}
export {
  _ as default
};
