import V from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import * as a from "react";
import S from "../../../classnames/index.mjs";
import I from "../../../rc-util/es/omit.mjs";
import "../config-provider/index.mjs";
import { LayoutContext as T } from "./context.mjs";
import $ from "./hooks/useHasSider.mjs";
import b from "./style/index.mjs";
import { ConfigContext as g } from "../config-provider/context.mjs";
var O = globalThis && globalThis.__rest || function(t, o) {
  var r = {};
  for (var e in t)
    Object.prototype.hasOwnProperty.call(t, e) && o.indexOf(e) < 0 && (r[e] = t[e]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, e = Object.getOwnPropertySymbols(t); s < e.length; s++)
      o.indexOf(e[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[s]) && (r[e[s]] = t[e[s]]);
  return r;
};
function d(t) {
  let {
    suffixCls: o,
    tagName: r,
    displayName: e
  } = t;
  return (s) => {
    const l = /* @__PURE__ */ a.forwardRef((c, f) => /* @__PURE__ */ a.createElement(s, Object.assign({
      ref: f,
      suffixCls: o,
      tagName: r
    }, c)));
    return process.env.NODE_ENV !== "production" && (l.displayName = e), l;
  };
}
const h = /* @__PURE__ */ a.forwardRef((t, o) => {
  const {
    prefixCls: r,
    suffixCls: e,
    className: s,
    tagName: l
  } = t, c = O(t, ["prefixCls", "suffixCls", "className", "tagName"]), {
    getPrefixCls: f
  } = a.useContext(g), n = f("layout", r), [u, p, C] = b(n), x = e ? `${n}-${e}` : n;
  return u(/* @__PURE__ */ a.createElement(l, Object.assign({
    className: S(r || x, s, p, C),
    ref: o
  }, c)));
}), z = /* @__PURE__ */ a.forwardRef((t, o) => {
  const {
    direction: r
  } = a.useContext(g), [e, s] = a.useState([]), {
    prefixCls: l,
    className: c,
    rootClassName: f,
    children: n,
    hasSider: u,
    tagName: p,
    style: C
  } = t, x = O(t, ["prefixCls", "className", "rootClassName", "children", "hasSider", "tagName", "style"]), v = I(x, ["suffixCls"]), {
    getPrefixCls: j,
    layout: i
  } = a.useContext(g), m = j("layout", l), P = $(e, n, u), [w, E, _] = b(m), H = S(m, {
    [`${m}-has-sider`]: P,
    [`${m}-rtl`]: r === "rtl"
  }, i == null ? void 0 : i.className, c, f, E, _), L = a.useMemo(() => ({
    siderHook: {
      addSider: (y) => {
        s((N) => [].concat(V(N), [y]));
      },
      removeSider: (y) => {
        s((N) => N.filter((R) => R !== y));
      }
    }
  }), []);
  return w(/* @__PURE__ */ a.createElement(T.Provider, {
    value: L
  }, /* @__PURE__ */ a.createElement(p, Object.assign({
    ref: o,
    className: H,
    style: Object.assign(Object.assign({}, i == null ? void 0 : i.style), C)
  }, v), n)));
}), A = d({
  tagName: "div",
  displayName: "Layout"
})(z), J = d({
  suffixCls: "header",
  tagName: "header",
  displayName: "Header"
})(h), K = d({
  suffixCls: "footer",
  tagName: "footer",
  displayName: "Footer"
})(h), Q = d({
  suffixCls: "content",
  tagName: "main",
  displayName: "Content"
})(h), U = A;
export {
  Q as Content,
  K as Footer,
  J as Header,
  U as default
};
