"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const isElement = require("../../core/utils/is-element/is-element.cjs");
const getSize = require("../../core/utils/get-size/get-size.cjs");
const createVarsResolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
require("clsx");
const useProps = require("../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../core/styles-api/use-styles/use-styles.cjs");
const Box = require("../../core/Box/Box.cjs");
const factory = require("../../core/factory/factory.cjs");
const Breadcrumbs_module_css = require("./Breadcrumbs.module.css.cjs");
const defaultProps = {
  separator: "/"
};
const varsResolver = createVarsResolver.createVarsResolver((_, { separatorMargin }) => ({
  root: {
    "--bc-separator-margin": getSize.getSpacing(separatorMargin)
  }
}));
const Breadcrumbs = factory.factory((_props, ref) => {
  const props = useProps.useProps("Breadcrumbs", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    children,
    separator,
    separatorMargin,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "Breadcrumbs",
    classes: Breadcrumbs_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  const items = React.Children.toArray(children).reduce((acc, child, index, array) => {
    var _a;
    const item = isElement.isElement(child) ? React.cloneElement(child, {
      ...getStyles("breadcrumb", { className: (_a = child.props) == null ? void 0 : _a.className }),
      key: index
    }) : /* @__PURE__ */ React.createElement("div", { ...getStyles("breadcrumb"), key: index }, child);
    acc.push(item);
    if (index !== array.length - 1) {
      acc.push(
        /* @__PURE__ */ React.createElement(Box.Box, { ...getStyles("separator"), key: `separator-${index}` }, separator)
      );
    }
    return acc;
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref, ...getStyles("root"), ...others, children: items });
});
Breadcrumbs.classes = Breadcrumbs_module_css.default;
Breadcrumbs.displayName = "@mantine/core/Breadcrumbs";
exports.Breadcrumbs = Breadcrumbs;
