/**
 * Returns the matched range for a substring query against an item's name,
 * or undefined if there is no match.
 */
function substringMatch(item, query) {
    const index = item.name.toLowerCase().indexOf(query.toLowerCase());
    if (index === -1) {
        return undefined;
    }
    return [index, index + query.length];
}
/**
 * Filters items by substring match on name and attaches the matched range.
 */
export function basicSearch(items, query) {
    const results = [];
    for (const item of items) {
        const range = substringMatch(item, query);
        if (range) {
            results.push({ ...item, matched: [range] });
        }
    }
    return results;
}
//# sourceMappingURL=basic-search.js.map