export const glideValueList = ( value ) => (
	Array.isArray( value ) ? value : value == null || value === '' ? [] : [ value ]
).map( String );

/** True when Glide can resolve every controlled value against its current options. */
export const canApplyGlideValue = ( options, value ) => {
	const desired = glideValueList( value );
	if ( desired.length === 0 ) return true;
	const available = new Set( ( options || [] ).map( ( option ) => String( option.value ) ) );
	return desired.every( ( selected ) => available.has( selected ) );
};
