import { $, $Events } from '../$';
import { Pin, Pin_M } from '../../Pin';
import { PinOpt } from '../../PinOpt';
import { PinOpts } from '../../PinOpts';
import { Pins } from '../../Pins';
import { System } from '../../system';
import { Spec } from '../../types';
import { AllKeys } from '../../types/AllKeys';
import { Dict } from '../../types/Dict';
import { U, U_EE } from '../../types/interface/U';
import { IO } from '../../types/IO';
import { Key } from '../../types/Key';
import { None } from '../../types/None';
import { UnitBundleSpec } from '../../types/UnitBundleSpec';
import { Unlisten } from '../../types/Unlisten';
import { Memory } from './Memory';
export type PinMap<T> = Dict<Pin<T[keyof T]>>;
export interface ION<I, O> {
    i?: string[];
    o?: string[];
}
export interface Opt {
    input?: PinOpts;
    output?: PinOpts;
}
export declare const DEFAULT_PIN_OPT: PinOpt;
export type PinOf<T> = Pin<T[keyof T]>;
export type UnitEvents<_EE extends Dict<any[]>> = $Events<_EE & U_EE> & U_EE;
export interface U_M {
}
export declare class Unit<I extends Dict<any> = any, O extends Dict<any> = any, _EE extends UnitEvents<_EE> & Dict<any[]> = UnitEvents<U_EE>> extends $<_EE> implements U<I, O> {
    __: string[];
    id: string;
    lazy: boolean;
    _parent: Unit | null;
    _input: Partial<AllKeys<I, Pin>>;
    _output: Partial<AllKeys<O, Pin>>;
    _data_input: Partial<AllKeys<I, Pin>>;
    _data_output: Partial<AllKeys<O, Pin>>;
    _ref_input: Partial<AllKeys<I, Pin>>;
    _ref_output: Partial<AllKeys<O, Pin>>;
    protected _i_opt: Partial<Record<keyof I, PinOpt>>;
    protected _o_opt: Partial<Record<keyof O, PinOpt>>;
    protected _i_name_set: Set<keyof I>;
    protected _o_name_set: Set<keyof O>;
    protected _d_i_name: Set<keyof I>;
    protected _d_o_name: Set<keyof O>;
    protected _r_i_name: Set<Key>;
    protected _r_o_name: Set<Key>;
    protected _o_count: number;
    protected _i_count: number;
    protected _d_i_count: number;
    protected _d_o_count: number;
    protected _r_i_count: number;
    protected _r_o_count: number;
    protected _err: string | null;
    protected _selfInput: Pin;
    protected _selfOutput: Pin<any>;
    ref: any | null;
    _paused: boolean;
    _opt: Opt;
    constructor({ i, o }: ION<I, O>, opt: Opt, system: System, id: string);
    isElement(): boolean;
    isPinIgnored<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K): boolean;
    isPinConstant<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K): boolean;
    isPinRef<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K): boolean;
    setParent(parent: Unit | null): void;
    setPinIgnored<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K, ignored: boolean): void;
    setPinConstant<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K, constant: boolean): void;
    private _memSetPinOptData;
    private _memSetInputData;
    private _memSetOutputData;
    private _memSetPinRef;
    private _memSetInputRef;
    private _memSetOutputRef;
    setPinRef<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K, ref: boolean): void;
    setInputRef<K extends keyof I>(pinId: K, ref: boolean): void;
    setOutputRef<K extends keyof O>(pinId: K, ref: boolean): void;
    setInputIgnored<K extends keyof I>(pinId: K, ignore: boolean): boolean;
    setOutputIgnored<K extends keyof O>(pinId: K, ignore: boolean): boolean;
    setInputs(inputs: Pins<I>, opts?: PinOpts): void;
    setPin<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K, pin: Pin<any>, opt?: PinOpt, propagate?: boolean): void;
    setInput<K extends keyof I>(pinId: K, input: Pin<I[K]>, opt?: PinOpt, propagate?: boolean): void;
    _setInput<K extends keyof I>(pinId: K, input: Pin<I[K]>, opt?: PinOpt): void;
    private _memAddDataInput;
    private _memAddRefInput;
    private _validateInputName;
    private _validateOutputName;
    addPin<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, name: K, pin: Pin<any>, opt: PinOpt): void;
    addInput<K extends keyof I>(name: K, input: Pin<any>, opt?: PinOpt): void;
    removeInput<K extends keyof I>(name: K, propagate?: boolean): void;
    private _memRemoveDataInput;
    private _memRemoveRefInput;
    setOutputs(outputs: Pins<O>, opts?: PinOpts): void;
    setOutput<K extends keyof O>(name: K, output: Pin<O[K]>, opt?: PinOpt, propagate?: boolean): void;
    _setOutput<K extends keyof O>(name: K, output: Pin<O[K]>, opt: PinOpt, propagate: boolean): void;
    private _memAddRefOutput;
    private _memSetRefOutput;
    private _memAddDataOutput;
    private _memSetDataOutput;
    addOutput<K extends keyof O>(name: K, output: Pin<any>, opt?: PinOpt): void;
    private _memRemoveRefPin;
    private _memRemoveRefOutput;
    private _memRemoveDataOutput;
    removeOutput<K extends keyof O>(name: K, propagate: boolean): void;
    removePin<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, name: K, propagate: boolean): void;
    getPin<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, pinId: K): Pin<any>;
    getInputs(): Pins<I>;
    getDataInputs(): Pins<Partial<I>>;
    getRefInputs(): Pins<Partial<I>>;
    getInput(name: keyof I): Pin<any>;
    getOutputs(): Pins<O>;
    getDataOutputs(): Pins<Partial<O>>;
    getRefOutputs(): Pins<Partial<O>>;
    getOutput<K extends keyof O>(name: K): Pin<O[K]>;
    push<K extends keyof I>(name: K, data: any): void;
    pushInput<K extends keyof I>(name: K, data: I[K]): void;
    pushAllInput(data: Partial<I>): void;
    pushOutput<K extends keyof O>(name: K, data: O[K]): void;
    pushAllOutput(data: Partial<O>): void;
    pushAll(data: Partial<I>): void;
    pullInput<K extends keyof I>(name: K): I[K];
    pullOutput<K extends keyof O>(name: K): O[K];
    pullPin<T extends IO, P extends T extends 'input' ? I : O, K extends keyof P>(type: T, name: K): P[K];
    takePin<T extends IO, P extends T extends 'input' ? I : O, K extends keyof P>(type: T, name: K): P[K];
    takeInput<K extends keyof I>(name: K): I[K];
    takeOutput<K extends keyof O>(name: K): O[K];
    take<K extends keyof O>(name: K): O[K];
    takeAll(): Dict<any>;
    peakInput<K extends keyof I>(name: K): I[K];
    peakOutput<K extends keyof O>(name: K): O[K];
    peak<K extends keyof O>(name: K): O[K];
    peakAllOutput(): Dict<any>;
    peakAll(): Dict<any>;
    hasPinNamed<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, name: K): boolean;
    hasInputNamed<K extends keyof I>(name: K): boolean;
    hasOutputNamed<K extends keyof O>(name: K): boolean;
    hasDataPinNamed(type: IO, name: string): boolean;
    hasDataInputNamed(name: string): boolean;
    hasDataOutputNamed(name: string): boolean;
    hasRefPinNamed<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, name: K): boolean;
    hasRefInputNamed<K extends keyof I>(name: K): boolean;
    renamePin<T extends IO, K extends T extends 'input' ? keyof I : keyof O>(type: T, name: K, newName: K): void;
    renameInput<K extends keyof I>(name: K, newName: K, propagate?: boolean): void;
    renameOutput<K extends keyof O>(name: K, newName: K, propagate?: boolean): void;
    getInputOpt<K extends keyof I>(name: K): PinOpt;
    getOutputOpt<K extends keyof O>(name: K): PinOpt;
    hasRefOutputNamed<K extends keyof O>(name: K): boolean;
    getInputCount(): number;
    getOutputCount(): number;
    getInputNames(): string[];
    getOutputNames(): string[];
    setPinData(type: IO, pinId: string, data: any): void;
    removePinData(type: IO, pinId: string): void;
    setInputConstant(pinId: string, constant: boolean): void;
    setOutputConstant(pinId: string, constant: boolean): void;
    getCatchErr(): boolean;
    private _catcherCallback;
    private _catcherDoneCount;
    private _catcherDone;
    protected _catchErr: boolean;
    protected _caughtErr: string | null;
    caughtErr(): string | null;
    catch(callback: (err: string) => void): {
        unlisten: Unlisten;
        done: () => void;
    };
    getConfig(): Opt;
    reset(take?: boolean): void;
    pause(): void;
    play(): void;
    paused(): boolean;
    getSelfPin(): Pin<U>;
    err(err?: string | Error | None): string | null;
    hasErr(): boolean;
    getErr(): string | null;
    takeErr(): string | null;
    takeCaughtErr(): string | null;
    destroy(): void;
    getPinData(type: IO, pinId: string): any;
    getPinsData(): {
        input: Partial<I>;
        output: Partial<O>;
    };
    getInputData(): Partial<I>;
    getRefInputData(): Partial<I>;
    getSpec(): Spec;
    getUnitBundleSpec(deep?: boolean): UnitBundleSpec;
    snapshotSelf(): Dict<any>;
    snapshotInput<T extends keyof I>(pinId: T): Pin_M<I[T]>;
    snapshotInputs(): Partial<Record<keyof I, Pin_M>>;
    snapshotOutput<T extends keyof O>(pinId: T): Pin_M<O[T]>;
    snapshotOutputs(): Partial<Record<keyof O, Pin_M>>;
    snapshot(): Memory;
    restoreSelf(state: Dict<any>): void;
    restoreInputs(state: Dict<Pin_M>): void;
    restoreInput(pinId: string, state: Pin_M): void;
    restoreOutputs(state: Dict<Pin_M>): void;
    restoreOutput(pinId: string, state: Pin_M): void;
    restore(state: {
        input?: Dict<any>;
        output?: Dict<any>;
        memory?: Dict<any>;
    }): void;
}
