"use client";
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
let lodash_clamp_js = require("lodash/clamp.js");
lodash_clamp_js = require_runtime.__toESM(lodash_clamp_js);

//#region src/components/client/BottomSheet/utils.ts
/**
* Check if an element is an input-like element.
* @param el - The element to check.
* @returns True if the element is an input-like element, false otherwise.
*/
function isInputLike(el) {
	if (!el) return false;
	const tagName = el.tagName.toLowerCase();
	if (tagName === "input" || tagName === "textarea" || tagName === "select") return true;
	if (el instanceof HTMLElement && el.isContentEditable) return true;
	return false;
}
/**
* Get the viewport height in pixels.
* @returns The viewport height in pixels.
*/
function getViewportHeightPx() {
	if (typeof window === "undefined") return 0;
	return window.visualViewport?.height ?? window.innerHeight;
}
/**
* Clamp an index into the valid range for an array-like collection.
*
* @param index - The candidate index (may be negative or out of bounds).
* @param length - The collection length.
* @returns A valid index in the range [0, length - 1]. Returns 0 if length <= 0.
*
* @example
* clampIndex(12, 10) // 9
* clampIndex(-3, 10) // 0
* clampIndex(5, 0)   // 0
*/
function clampIndex(index, length) {
	if (length <= 0) return 0;
	return (0, lodash_clamp_js.default)(index, 0, length - 1);
}
/**
* Resolve a height value to a pixel value.
* @param height - The height value to resolve.
* @param viewportHeightPx - The viewport height in pixels.
* @returns The resolved height in pixels.
*/
function resolveHeightToPx(height, viewportHeightPx) {
	if (typeof height === "number") return height;
	const trimmed = height.trim();
	if (trimmed.endsWith("%")) {
		const pct = Number.parseFloat(trimmed.slice(0, -1));
		if (Number.isFinite(pct)) return pct / 100 * viewportHeightPx;
	}
	if (trimmed.endsWith("px")) {
		const px = Number.parseFloat(trimmed.slice(0, -2));
		if (Number.isFinite(px)) return px;
	}
	const fallback = Number.parseFloat(trimmed);
	return Number.isFinite(fallback) ? fallback : 0;
}
/**
* Check if an element is scrollable.
* @param el - The element to check.
* @returns True if the element is scrollable, false otherwise.
*/
function isScrollable(el) {
	return el.scrollHeight > el.clientHeight;
}
/**
* Check if a drag event should be prevented from the target element.
* @param target - The target element.
* @returns True if the drag event should be prevented, false otherwise.
*/
function shouldPreventDragFromTarget(target) {
	const element = target instanceof Element ? target : null;
	if (!element) return false;
	if (element.tagName.toUpperCase() === "SELECT") return true;
	return !!element.closest("[data-bottomsheet-no-drag]");
}
/**
* Get the translateY value of an element's transform.
* @param el - The element to get the translateY value of.
* @returns The translateY value in pixels.
*/
function getTranslateY(el) {
	if (!el) return 0;
	const style = window.getComputedStyle(el);
	const transform = style.getPropertyValue("transform") || style.getPropertyValue("-webkit-transform") || style.getPropertyValue("-moz-transform");
	if (!transform || transform === "none") return 0;
	const mat3d = transform.match(/^matrix3d\((.+)\)$/);
	if (mat3d) {
		const parts = mat3d[1].split(",").map((p) => p.trim());
		return Number.parseFloat(parts[13] ?? "0") || 0;
	}
	const mat2d = transform.match(/^matrix\((.+)\)$/);
	if (mat2d) {
		const parts = mat2d[1].split(",").map((p) => p.trim());
		return Number.parseFloat(parts[5] ?? "0") || 0;
	}
	return 0;
}
/**
* Parse a max snap point ratio from a string.
* @param rawValue - The raw value to parse.
* @returns The parsed max snap point ratio.
*/
function parseMaxSnapPointRatio(rawValue) {
	const trimmed = rawValue.trim();
	if (!trimmed) return 1;
	const value = trimmed.endsWith("%") ? trimmed.slice(0, -1) : trimmed;
	const parsed = Number.parseFloat(value);
	if (!Number.isFinite(parsed)) return 1;
	return Math.min(Math.max(parsed / 100, 0), 1);
}

//#endregion
exports.clampIndex = clampIndex;
exports.getTranslateY = getTranslateY;
exports.getViewportHeightPx = getViewportHeightPx;
exports.isInputLike = isInputLike;
exports.isScrollable = isScrollable;
exports.parseMaxSnapPointRatio = parseMaxSnapPointRatio;
exports.resolveHeightToPx = resolveHeightToPx;
exports.shouldPreventDragFromTarget = shouldPreventDragFromTarget;