/**
 * Type-to-filter for DataStream lists: hides rows/cards/items whose text
 * does not contain the query. Pure display filtering — nothing is fetched.
 */
( function () {
	'use strict';

	document.querySelectorAll( '[data-ds-filterable]' ).forEach( function ( container ) {
		const input = container.querySelector( '.datastream-search-input' );

		if ( ! input ) {
			return;
		}

		const items = container.querySelectorAll(
			'.datastream-list-item, .datastream-table tbody tr, .datastream-card, .datastream-grid-item'
		);

		input.addEventListener( 'input', function () {
			const query = input.value.trim().toLowerCase();

			items.forEach( function ( item ) {
				item.hidden = '' !== query && -1 === item.textContent.toLowerCase().indexOf( query );
			} );
		} );
	} );
} )();
