/**
 * Prefer the visible builder drawer panel over the Classic Editor metabox.
 * On `post.php?action=elementor` both can exist in the DOM with duplicate IDs.
 */
export function resolveClassicRoot() {
	const builderSelectors = [
		'#flow-ew-elementor-drawer #flow-ew-classic',
		'#flow-ew-bricks-drawer #flow-ew-classic',
		'#flow-ew-breakdance-drawer #flow-ew-classic',
		'#flow-ew-avada-drawer #flow-ew-classic',
		'#flow-ew-beaver-drawer #flow-ew-classic',
		'#flow-ew-divi-drawer #flow-ew-classic',
	];

	for ( let i = 0; i < builderSelectors.length; i++ ) {
		const el = document.querySelector( builderSelectors[ i ] );
		if ( el ) {
			return el;
		}
	}

	return document.getElementById( 'flow-ew-classic' );
}

export function resolveClassicOpenSlot() {
	const builderSelectors = [
		'#flow-ew-elementor-drawer #flow-ew-classic-open-slot',
		'#flow-ew-bricks-drawer #flow-ew-classic-open-slot',
		'#flow-ew-breakdance-drawer #flow-ew-classic-open-slot',
		'#flow-ew-avada-drawer #flow-ew-classic-open-slot',
		'#flow-ew-beaver-drawer #flow-ew-classic-open-slot',
		'#flow-ew-divi-drawer #flow-ew-classic-open-slot',
	];

	for ( let i = 0; i < builderSelectors.length; i++ ) {
		const el = document.querySelector( builderSelectors[ i ] );
		if ( el ) {
			return el;
		}
	}

	return document.getElementById( 'flow-ew-classic-open-slot' );
}
