from typing import Any

from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models import Field
from django.db.models.expressions import Expression, Value
from django.db.models.sql.compiler import SQLCompiler

class LexemeCombinable(Expression):
    BITAND: str
    BITOR: str
    def bitand(self, other: LexemeCombinable) -> CombinedLexeme: ...
    def bitor(self, other: LexemeCombinable) -> CombinedLexeme: ...
    def __or__(self, other: LexemeCombinable) -> CombinedLexeme: ...
    def __and__(self, other: LexemeCombinable) -> CombinedLexeme: ...

class Lexeme(LexemeCombinable, Value):
    def __init__(
        self,
        value: str,
        output_field: Field[Any, Any] | None = None,
        *,
        invert: bool = False,
        prefix: bool = False,
        weight: str | None = None,
    ) -> None: ...
    def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> tuple[str, list[str]]: ...

class CombinedLexeme(LexemeCombinable):
    def __init__(
        self, lhs: LexemeCombinable, connector: str, rhs: LexemeCombinable, output_field: Field[Any, Any] | None = None
    ) -> None: ...
    def as_sql(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> tuple[str, list[str]]: ...
