const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_auto_text_size_standalone = require("./auto-text-size-standalone.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region ../materials/src/components/auto-resize-text/index.tsx
const _excluded = [
	"mode",
	"minFontSizePx",
	"maxFontSizePx",
	"fontSizePrecisionPx",
	"scrollToEnd",
	"as",
	"children"
];
function AutoResizeText(_ref) {
	let { mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd, as: Comp = "div", children } = _ref, rest = require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
	const updateTextSizeRef = (0, react.useRef)();
	(0, react.useEffect)(() => {
		var _updateTextSizeRef$cu;
		(_updateTextSizeRef$cu = updateTextSizeRef.current) === null || _updateTextSizeRef$cu === void 0 || _updateTextSizeRef$cu.call(updateTextSizeRef);
	}, [children]);
	const refCallback = (0, react.useCallback)((innerEl) => {
		var _updateTextSizeRef$cu2;
		(_updateTextSizeRef$cu2 = updateTextSizeRef.current) === null || _updateTextSizeRef$cu2 === void 0 || _updateTextSizeRef$cu2.disconnect();
		const containerEl = innerEl === null || innerEl === void 0 ? void 0 : innerEl.parentElement;
		if (!innerEl || !containerEl) return;
		updateTextSizeRef.current = require_auto_text_size_standalone.autoTextSize({
			innerEl,
			containerEl,
			mode,
			minFontSizePx,
			maxFontSizePx,
			fontSizePrecisionPx,
			scrollToEnd
		});
	}, [
		mode,
		minFontSizePx,
		maxFontSizePx,
		fontSizePrecisionPx,
		scrollToEnd
	]);
	return /* @__PURE__ */ react.default.createElement(Comp, require_objectSpread2._objectSpread2({ ref: refCallback }, rest), children);
}
//#endregion
exports.default = AutoResizeText;
