import type { Event } from '@difizen/mana-common';
import { Syringe } from '@difizen/mana-syringe';
export declare enum ContextKeyExprType {
    False = 0,
    True = 1,
    Defined = 2,
    Not = 3,
    Equals = 4,
    NotEquals = 5,
    And = 6,
    Regex = 7,
    NotRegex = 8,
    Or = 9,
    In = 10,
    NotIn = 11,
    Greater = 12,
    GreaterEquals = 13,
    Smaller = 14,
    SmallerEquals = 15
}
export interface IContextKeyExprMapper {
    mapDefined: (key: string) => ContextKeyExpression;
    mapNot: (key: string) => ContextKeyExpression;
    mapEquals: (key: string, value: any) => ContextKeyExpression;
    mapNotEquals: (key: string, value: any) => ContextKeyExpression;
    mapGreater: (key: string, value: any) => ContextKeyExpression;
    mapGreaterEquals: (key: string, value: any) => ContextKeyExpression;
    mapSmaller: (key: string, value: any) => ContextKeyExpression;
    mapSmallerEquals: (key: string, value: any) => ContextKeyExpression;
    mapRegex: (key: string, regexp: RegExp | null) => ContextKeyRegexExpr;
    mapIn: (key: string, valueKey: string) => ContextKeyInExpr;
}
export interface IContextKeyExpression {
    cmp: (other: ContextKeyExpression) => number;
    equals: (other: ContextKeyExpression) => boolean;
    evaluate: (context: IContext) => boolean;
    serialize: () => string;
    keys: () => string[];
    map: (mapFnc: IContextKeyExprMapper) => ContextKeyExpression;
    negate: () => ContextKeyExpression;
}
export type ContextKeyExpression = ContextKeyFalseExpr | ContextKeyTrueExpr | ContextKeyDefinedExpr | ContextKeyNotExpr | ContextKeyEqualsExpr | ContextKeyNotEqualsExpr | ContextKeyRegexExpr | ContextKeyNotRegexExpr | ContextKeyAndExpr | ContextKeyOrExpr | ContextKeyInExpr | ContextKeyNotInExpr | ContextKeyGreaterExpr | ContextKeyGreaterEqualsExpr | ContextKeySmallerExpr | ContextKeySmallerEqualsExpr;
export declare abstract class ContextKeyExpr {
    static false(): ContextKeyExpression;
    static true(): ContextKeyExpression;
    static has(key: string): ContextKeyExpression;
    static equals(key: string, value: any): ContextKeyExpression;
    static notEquals(key: string, value: any): ContextKeyExpression;
    static regex(key: string, value: RegExp): ContextKeyExpression;
    static in(key: string, value: string): ContextKeyExpression;
    static not(key: string): ContextKeyExpression;
    static and(...expr: (ContextKeyExpression | undefined | null)[]): ContextKeyExpression | undefined;
    static or(...expr: (ContextKeyExpression | undefined | null)[]): ContextKeyExpression | undefined;
    static greater(key: string, value: any): ContextKeyExpression;
    static less(key: string, value: any): ContextKeyExpression;
    static deserialize(serialized: string | null | undefined, strict?: boolean): ContextKeyExpression | undefined;
    private static _deserializeOrExpression;
    private static _deserializeAndExpression;
    private static _deserializeOne;
    private static _deserializeValue;
    private static _deserializeRegexValue;
}
export declare class ContextKeyFalseExpr implements IContextKeyExpression {
    static INSTANCE: ContextKeyFalseExpr;
    readonly type = ContextKeyExprType.False;
    protected constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(_context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(_mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyTrueExpr implements IContextKeyExpression {
    static INSTANCE: ContextKeyTrueExpr;
    readonly type = ContextKeyExprType.True;
    protected constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(_context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(_mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyDefinedExpr implements IContextKeyExpression {
    static create(key: string): ContextKeyExpression;
    readonly type = ContextKeyExprType.Defined;
    protected readonly key: string;
    protected constructor(key: string);
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyEqualsExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.Equals;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyInExpr implements IContextKeyExpression {
    static create(key: string, valueKey: string): ContextKeyInExpr;
    readonly type = ContextKeyExprType.In;
    private readonly key;
    private readonly valueKey;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyInExpr;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyNotInExpr implements IContextKeyExpression {
    static create(actual: ContextKeyInExpr): ContextKeyNotInExpr;
    readonly type = ContextKeyExprType.NotIn;
    private readonly _actual;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyNotEqualsExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.NotEquals;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyNotExpr implements IContextKeyExpression {
    static create(key: string): ContextKeyExpression;
    readonly type = ContextKeyExprType.Not;
    private readonly key;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyGreaterExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.Greater;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyGreaterEqualsExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.GreaterEquals;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeySmallerExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.Smaller;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeySmallerEqualsExpr implements IContextKeyExpression {
    static create(key: string, value: any): ContextKeyExpression;
    readonly type = ContextKeyExprType.SmallerEquals;
    private readonly key;
    private readonly value;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyRegexExpr implements IContextKeyExpression {
    static create(key: string, regexp: RegExp | null): ContextKeyRegexExpr;
    readonly type = ContextKeyExprType.Regex;
    private readonly key;
    private readonly regexp;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyRegexExpr;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyNotRegexExpr implements IContextKeyExpression {
    static create(actual: ContextKeyRegexExpr): ContextKeyExpression;
    readonly type = ContextKeyExprType.NotRegex;
    private readonly _actual;
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyAndExpr implements IContextKeyExpression {
    static create(_expr: readonly (ContextKeyExpression | null | undefined)[]): ContextKeyExpression | undefined;
    readonly type = ContextKeyExprType.And;
    readonly expr: ContextKeyExpression[];
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    private static _normalizeArr;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export declare class ContextKeyOrExpr implements IContextKeyExpression {
    static create(_expr: readonly (ContextKeyExpression | null | undefined)[]): ContextKeyExpression | undefined;
    readonly type = ContextKeyExprType.Or;
    readonly expr: ContextKeyExpression[];
    private constructor();
    cmp(other: ContextKeyExpression): number;
    equals(other: ContextKeyExpression): boolean;
    evaluate(context: IContext): boolean;
    private static _normalizeArr;
    serialize(): string;
    keys(): string[];
    map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
    negate(): ContextKeyExpression;
}
export interface ContextKeyInfo {
    readonly key: string;
    readonly type?: string | undefined;
    readonly description?: string | undefined;
}
export declare class RawContextKey<T> extends ContextKeyDefinedExpr {
    private static _info;
    static all(): IterableIterator<ContextKeyInfo>;
    private readonly _defaultValue;
    readonly key: string;
    constructor(key: string, defaultValue: T | undefined, metaOrHide?: string | true | {
        type: string;
        description: string;
    });
    bindTo(target: IContextKeyService): IContextKey<T>;
    getValue(target: IContextKeyService): T | undefined;
    toNegated(): ContextKeyExpression;
    isEqualTo(value: any): ContextKeyExpression;
    notEqualsTo(value: any): ContextKeyExpression;
}
export interface IContext {
    getValue: <T>(key: string) => T | undefined;
}
export interface IContextKey<T> {
    set: (value: T) => void;
    reset: () => void;
    get: () => T | undefined;
}
export declare namespace IContextKey {
    const None: IContextKey<any>;
}
export interface IContextKeyServiceTarget {
    parentElement: IContextKeyServiceTarget | null;
    setAttribute: (attr: string, value: string) => void;
    removeAttribute: (attr: string) => void;
    hasAttribute: (attr: string) => boolean;
    getAttribute: (attr: string) => string | null;
}
export declare const IContextKeyService: Syringe.DefinedToken;
export interface IReadableSet<T> {
    has: (value: T) => boolean;
}
export interface IContextKeyChangeEvent {
    affectsSome: (keys: IReadableSet<string>) => boolean;
}
export interface IContextKeyService {
    readonly _serviceBrand: undefined;
    dispose: () => void;
    onDidChangeContext: Event<IContextKeyChangeEvent>;
    bufferChangeEvents: (callback: () => void) => void;
    createKey: <T>(key: string, defaultValue: T | undefined) => IContextKey<T>;
    contextMatchesRules: (rules: ContextKeyExpression | undefined) => boolean;
    getContextKeyValue: <T>(key: string) => T | undefined;
    createScoped: (target: IContextKeyServiceTarget) => IContextKeyService;
    createOverlay: (overlay: Iterable<[string, any]>) => IContextKeyService;
    getContext: (target: IContextKeyServiceTarget | null) => IContext;
    updateParent: (parentContextKeyService: IContextKeyService) => void;
}
export declare const SET_CONTEXT_COMMAND_ID = "setContext";
//# sourceMappingURL=contextkey.d.ts.map