import { filter, filterOr } from './filter.js';
import { convertFilter } from './convertFilter.js';
export class FilterBranch {
    constructor(db, filterBranch, def) {
        this.def = def;
        this.filterBranch = filterBranch;
        this.db = db;
    }
    db;
    filterBranch;
    def;
    or(field, operator, value, opts) {
        if (typeof field === 'function') {
            const f = new FilterBranch(this.db, filterOr(this.db, this.def, [], this.filterBranch), this.def);
            field(f);
            this.def.filter.size += f.filterBranch.size;
        }
        else {
            const f = convertFilter(this.def, field, operator, value, opts);
            if (f) {
                filterOr(this.db, this.def, f, this.filterBranch);
            }
        }
        return this;
    }
    filter(field, operator, value) {
        const f = convertFilter(this.def, field, operator, value);
        if (f) {
            filter(this.db, this.def, f, this.filterBranch);
        }
        return this;
    }
}
//# sourceMappingURL=FilterBranch.js.map