"use client";
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { useBottomSheetStoreInternal } from "./useBottomSheetStoreInternal.js";
import { useStoreState } from "@ariakit/react";

//#region src/components/client/BottomSheet/useBottomSheetStore.ts
/** @internal */
const BOTTOM_SHEET_INTERNAL_STORE_KEY = "__bottomSheetInternal";
/** @internal */
function getBottomSheetInternal(controller) {
	const internal = controller[BOTTOM_SHEET_INTERNAL_STORE_KEY];
	if (!internal) throw new Error("Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.");
	return internal;
}
const useBottomSheetStore = ({ animated = true, defaultOpen = false, open: openProp } = {}) => {
	const bottomSheetInternal = useBottomSheetStoreInternal({
		animated,
		open: openProp,
		defaultOpen
	});
	const isOpen = useStoreState(bottomSheetInternal, (state) => state.open);
	return {
		open: bottomSheetInternal.show,
		close: bottomSheetInternal.hide,
		isOpen,
		[BOTTOM_SHEET_INTERNAL_STORE_KEY]: bottomSheetInternal
	};
};

//#endregion
export { getBottomSheetInternal, useBottomSheetStore };