import { ArrayValue, BooleanValue, NumberValue, RecordValue, Schema, StringValue, } from '@coveo/bueno';
import { facetResultsMustMatch, } from '../../../../../features/facets/facet-api/request.js';
import { facetValueStates } from '../../../../../features/facets/facet-api/value.js';
import { rangeFacetRangeAlgorithm, rangeFacetSortCriteria, } from '../../../../../features/facets/range-facets/generic/interfaces/request.js';
import { validateManualNumericRanges } from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js';
import { validateOptions } from '../../../../../utils/validate-payload.js';
import { facetId, field, filterFacetCount, generateAutomaticRanges, injectionDepth, numberOfValues, } from '../../../../core/facets/_common/facet-option-definitions.js';
const numericRangeRequestDefinition = {
    start: new NumberValue(),
    end: new NumberValue(),
    endInclusive: new BooleanValue(),
    state: new StringValue({ constrainTo: facetValueStates }),
};
export const numericFacetOptionsSchema = new Schema({
    facetId,
    tabs: new RecordValue({
        options: {
            required: false,
        },
        values: {
            included: new ArrayValue({ each: new StringValue() }),
            excluded: new ArrayValue({ each: new StringValue() }),
        },
    }),
    field,
    generateAutomaticRanges,
    filterFacetCount,
    injectionDepth,
    numberOfValues,
    currentValues: new ArrayValue({
        each: new RecordValue({ values: numericRangeRequestDefinition }),
    }),
    sortCriteria: new StringValue({ constrainTo: rangeFacetSortCriteria }),
    resultsMustMatch: new StringValue({ constrainTo: facetResultsMustMatch }),
    rangeAlgorithm: new StringValue({ constrainTo: rangeFacetRangeAlgorithm }),
});
export function validateNumericFacetOptions(engine, options) {
    validateOptions(engine, numericFacetOptionsSchema, options, 'buildNumericFacet');
    validateManualNumericRanges(options);
}
