import { type Instrumentation } from "@synnaxlabs/alamos";
import { channel, type Synnax, framer, Authority } from "@synnaxlabs/client";
import { z } from "zod";
import { aether } from '../../../aether/aether';
import { type theming } from '../../../ether';
import { status } from '../../../status/aether';
import { telem } from '../../aether';
import { AbstractSink } from '../../aether/telem';
import { StateProvider } from './state';
export declare const STATUSES: readonly ["acquired", "released", "overridden", "failed"];
export declare const statusZ: z.ZodEnum<["acquired", "released", "overridden", "failed"]>;
export type Status = z.infer<typeof statusZ>;
export declare const controllerStateZ: z.ZodObject<{
    name: z.ZodString;
    authority: z.ZodDefault<z.ZodNumber>;
    acquireTrigger: z.ZodNumber;
    status: z.ZodOptional<z.ZodEnum<["acquired", "released", "overridden", "failed"]>>;
    needsControlOf: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>;
}, "strip", z.ZodTypeAny, {
    name: string;
    authority: number;
    acquireTrigger: number;
    needsControlOf: number[];
    status?: "failed" | "acquired" | "released" | "overridden" | undefined;
}, {
    name: string;
    acquireTrigger: number;
    authority?: number | undefined;
    status?: "failed" | "acquired" | "released" | "overridden" | undefined;
    needsControlOf?: number[] | undefined;
}>;
interface InternalState {
    client: Synnax | null;
    instrumentation: Instrumentation;
    stateProv: StateProvider;
    addStatus: status.Aggregate;
    theme: theming.Theme;
    prevTrigger: number;
}
interface AetherControllerTelem extends telem.Telem {
    needsControlOf: (client: Synnax) => Promise<channel.Keys>;
}
/**
 * @summary Acquires control over a set of channels by opening a writer to a Synnax
 * cluster, and then acts as a factory for telemetry that can be used to send commands
 * to that writer.
 */
export declare class Controller extends aether.Composite<typeof controllerStateZ, InternalState> implements telem.Factory {
    static readonly TYPE = "Controller";
    schema: z.ZodObject<{
        name: z.ZodString;
        authority: z.ZodDefault<z.ZodNumber>;
        acquireTrigger: z.ZodNumber;
        status: z.ZodOptional<z.ZodEnum<["acquired", "released", "overridden", "failed"]>>;
        needsControlOf: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        authority: number;
        acquireTrigger: number;
        needsControlOf: number[];
        status?: "failed" | "acquired" | "released" | "overridden" | undefined;
    }, {
        name: string;
        acquireTrigger: number;
        authority?: number | undefined;
        status?: "failed" | "acquired" | "released" | "overridden" | undefined;
        needsControlOf?: number[] | undefined;
    }>;
    private readonly registry;
    private writer?;
    afterUpdate(): Promise<void>;
    afterDelete(): Promise<void>;
    private updateNeedsControlOf;
    private acquire;
    private release;
    set(frame: framer.CrudeFrame): Promise<void>;
    setAuthority(channels: channel.Keys, value: Authority): Promise<void>;
    releaseAuthority(keys: channel.Keys): Promise<void>;
    deleteTelem(t: AetherControllerTelem): void;
    /** @implements telem.Factory to create telemetry that is bound to this controller. */
    create<T>(spec: telem.Spec): T | null;
}
export declare const setChannelValuePropsZ: z.ZodObject<{
    channel: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    channel: number;
}, {
    channel: number;
}>;
export type SetChannelValueProps = z.infer<typeof setChannelValuePropsZ>;
export declare class SetChannelValue extends AbstractSink<typeof setChannelValuePropsZ> implements telem.NumberSink, AetherControllerTelem {
    static readonly TYPE = "controlled-numeric-telem-sink";
    private readonly controller;
    schema: z.ZodObject<{
        channel: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        channel: number;
    }, {
        channel: number;
    }>;
    constructor(controller: Controller, props: unknown);
    invalidate(): void;
    cleanup(): Promise<void>;
    needsControlOf(client: Synnax): Promise<channel.Keys>;
    set(value: number): Promise<void>;
}
export declare const setChannelValue: (props: SetChannelValueProps) => telem.NumberSinkSpec;
export declare const acquireChannelControlPropsZ: z.ZodObject<{
    authority: z.ZodDefault<z.ZodNumber>;
    channel: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    channel: number;
    authority: number;
}, {
    channel: number;
    authority?: number | undefined;
}>;
export type AcquireChannelControlProps = z.infer<typeof acquireChannelControlPropsZ>;
export declare class AcquireChannelControl extends AbstractSink<typeof acquireChannelControlPropsZ> implements telem.BooleanSink, AetherControllerTelem {
    static readonly TYPE = "acquire-channel-control";
    private readonly controller;
    schema: z.ZodObject<{
        authority: z.ZodDefault<z.ZodNumber>;
        channel: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        channel: number;
        authority: number;
    }, {
        channel: number;
        authority?: number | undefined;
    }>;
    constructor(controller: Controller, props: unknown);
    cleanup(): Promise<void>;
    needsControlOf(client: Synnax): Promise<channel.Keys>;
    set(acquire: boolean): Promise<void>;
}
export declare const acquireChannelControl: (props: AcquireChannelControlProps) => telem.BooleanSinkSpec;
export declare const authoritySourceProps: z.ZodObject<{
    channel: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
    channel: number;
}, {
    channel: number;
}>;
export type AuthoritySourceProps = z.infer<typeof authoritySourceProps>;
export declare class AuthoritySource extends telem.AbstractSource<typeof authoritySourceProps> implements telem.StatusSource, AetherControllerTelem {
    static readonly TYPE = "controlled-status-source";
    private readonly prov;
    private valid;
    private stopListening?;
    private readonly controller;
    schema: z.ZodObject<{
        channel: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        channel: number;
    }, {
        channel: number;
    }>;
    constructor(controller: Controller, prov: StateProvider, props: unknown);
    needsControlOf(): Promise<channel.Keys>;
    private maybeRevalidate;
    value(): Promise<status.Spec>;
    cleanup(): Promise<void>;
}
export declare const authoritySource: (props: AuthoritySourceProps) => telem.StatusSourceSpec;
export {};
