import { isEFTemporal } from "./EFTemporal.js";

//#region src/elements/findRootTemporal.ts
/**
* Finds the outermost temporal element in the DOM ancestry of the given element.
*
* Walks up from the element toward the document root, collecting all temporal
* elements (ef-timegroup, ef-video, ef-audio) in the ancestry, and returns
* the outermost one (closest to document root).
*
* This is a pure function - no caching, no stored state. Called fresh whenever
* the root temporal is needed.
*
* @param element - The element to start searching from
* @returns The outermost temporal element, or null if none found
*/
function findRootTemporal(element) {
	if (!element) return null;
	let current = element;
	let outermostTemporal = null;
	while (current && current !== document) {
		if (current instanceof HTMLElement && isEFTemporal(current)) outermostTemporal = current;
		current = current.parentNode;
	}
	return outermostTemporal;
}

//#endregion
export { findRootTemporal };
//# sourceMappingURL=findRootTemporal.js.map