/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { cx } from "../../styles/styler.js";
import { Box } from "../Box.js";
import { HStack } from "../HStack.js";
import { Text } from "../Text.js";
import { VStack } from "../VStack.js";
import { forwardRef, useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/components/Divider/DividerCore.tsx
const ORIENTATION_WIDTH_MAP = {
	horizontal: "w-full",
	vertical: ""
};
const DividerCore = forwardRef(function Divider({ vertical = false, contentPosition = "center", className, layerClassNames, children, ...boxProps }, ref) {
	const direction = vertical ? "vertical" : "horizontal";
	const InternalComponent = vertical ? VStack : HStack;
	const classNames = useMemo(() => ({
		root: cx(ORIENTATION_WIDTH_MAP[direction], className, layerClassNames?.root),
		label: cx(layerClassNames?.text),
		line: layerClassNames?.line
	}), [
		className,
		direction,
		layerClassNames?.root,
		layerClassNames?.text,
		layerClassNames?.line
	]);
	const lineStyle = useMemo(() => direction === "vertical" ? {
		borderTopWidth: 0,
		borderRightWidth: 0,
		borderBottomWidth: 0
	} : {
		borderLeftWidth: 0,
		borderRightWidth: 0,
		borderBottomWidth: 0
	}, [direction]);
	const Line = () => /* @__PURE__ */ jsx(Box, {
		flex: "1",
		className: classNames.line,
		style: lineStyle
	});
	if (children) return /* @__PURE__ */ jsxs(InternalComponent, {
		flex: "1",
		alignItems: "center",
		className: classNames.root,
		ref,
		...boxProps,
		children: [
			contentPosition !== "start" && /* @__PURE__ */ jsx(Line, {}),
			/* @__PURE__ */ jsx(Box, {
				flex: "none",
				children: /* @__PURE__ */ jsx(Text, {
					as: "span",
					color: "inherit",
					variant: "inherit",
					className: classNames.label,
					children
				})
			}),
			contentPosition !== "end" && /* @__PURE__ */ jsx(Line, {})
		]
	});
	return /* @__PURE__ */ jsx(Box, {
		display: "flex",
		flex: "none",
		className: classNames.root,
		ref,
		...boxProps,
		children: /* @__PURE__ */ jsx(Line, {})
	});
});
DividerCore.displayName = "DividerCore";

//#endregion
export { DividerCore };