export function handleRegisterQuerySuggest(state, payload) {
    const id = payload.id;
    if (id in state) {
        return;
    }
    state[id] = buildQuerySuggest(payload);
}
export function handleFetchPending(state, action) {
    const querySuggest = state[action.meta.arg.id];
    if (!querySuggest) {
        return;
    }
    querySuggest.currentRequestId = action.meta.requestId;
    querySuggest.isLoading = true;
}
export function handleFetchRejected(state, action) {
    const querySuggest = state[action.meta.arg.id];
    if (!querySuggest) {
        return;
    }
    querySuggest.error = action.payload || null;
    querySuggest.isLoading = false;
}
export function handleClearQuerySuggest(state, payload) {
    const querySuggest = state[payload.id];
    if (!querySuggest) {
        return;
    }
    querySuggest.responseId = '';
    querySuggest.completions = [];
    querySuggest.partialQueries = [];
}
function buildQuerySuggest(config) {
    return {
        id: '',
        completions: [],
        responseId: '',
        count: 5,
        currentRequestId: '',
        error: null,
        partialQueries: [],
        isLoading: false,
        ...config,
    };
}
