import Quickshell
import Quickshell.Io
import QtQuick

import qs.services

ShellRoot {
    IpcHandler {
        target: "settings-search-test"

        function find(query: string): string {
            const hits = SettingsSearch.search(query);
            return JSON.stringify({
                count: hits.length,
                top: hits.length > 0 ? hits[0].label : "",
                topPage: hits.length > 0 ? hits[0].page : "",
                labels: hits.slice(0, 6).map(hit => hit.label)
            });
        }
    }
}
