import { filterUndefined } from "../utils/object.js";
import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import styled from "../core/styled.js";
import vui from "../core/vui.js";
import Box from "../box/box.js";
import T from "../t/t.js";
import { spinnerPositionMapping, spinnerSpeedMapping } from "./consts.js";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/spinner/spinner.tsx
const SpinnerCircle = styled.divBox`
  border-radius: round;
  display: flex;
  flex-shrink: 0;
`;
/**
* Displays a spinning circular element with optional text to signify loading content.
*
* Handles different positioning scenarios, speeds and coloring of the circle.
*/
const Spinner = vui((props, ref) => {
	const { className, emptyColor, size, speed: speedProp = "normal", text, textPosition = "bottom", thickness, ...rest } = props;
	const styles = useStyleConfig("Spinner", props);
	const isCustomSize = typeof size === "number";
	const positionProps = spinnerPositionMapping[textPosition];
	const speed = spinnerSpeedMapping[speedProp] ?? speedProp;
	const circleProps = filterUndefined({
		borderColor: emptyColor,
		borderWidth: isCustomSize ? thickness ?? 4 : thickness,
		h: isCustomSize ? size : void 0,
		w: isCustomSize ? size : void 0
	});
	return /* @__PURE__ */ jsxs(Box, {
		center: true,
		className: cs("vui-spinner", className),
		gap: 1,
		ref,
		transitionDuration: "fast",
		...positionProps.container,
		...styles.container,
		...rest,
		children: [/* @__PURE__ */ jsx(SpinnerCircle, {
			animation: `vui-spin ${speed} linear infinite`,
			className: "vui-spinnerCircle",
			...styles.circle,
			...circleProps
		}), !!text && /* @__PURE__ */ jsx(T, {
			className: "vui-spinnerText",
			...styles.text,
			children: text
		})]
	});
});
Spinner.displayName = "Spinner";

//#endregion
export { SpinnerCircle, Spinner as default };
globalThis.__vuiVersion__ = "4.0.1"
//# sourceMappingURL=spinner.js.map