import { NgZone } from '@angular/core';
import { Platform, ToastController } from '@ionic/angular';
import { NdefTag } from '@iotize/device-com-nfc.cordova';
import { Tap } from '@iotize/tap';
import { TapAuth } from '@iotize/tap/auth';
import { TapConfiguratorConfig } from '@iotize/tap/config/schema/v1';
import { KeepAliveEngine } from '@iotize/tap/keep-alive';
import { ComProtocol, ConnectionStateChangeEvent } from '@iotize/tap/protocol/api';
import { Observable, Subject } from 'rxjs';
import { OnTapEvent } from './definitions';
import './extensions';
import { DataManagerIonic } from './extensions/data-manager';
import { ProtocolMeta } from './extensions/protocol-info';
import { ProtocolFactoryService } from './protocol-factory.service';
import { TapSelectedEvent } from './tap-connect/api';
import * as i0 from "@angular/core";
export declare function LONG_RANGE_PROTOCOL_FILTER(meta: ProtocolMeta): boolean;
export declare class TapServiceError extends Error {
    static illegalArgument(msg: string): void;
    static illegalStateNoTap(): TapServiceError;
}
export declare class CurrentDeviceService {
    private platform;
    private toastCtrl;
    protected protocolFactory: ProtocolFactoryService;
    private ngZone;
    /**
     * Hack to prevent angular treeshaking from removing loaded extension.
     */
    private _loadedTapExtensions;
    private _tapOrUndefined;
    private _tap?;
    /**
     * Only connection lost event
     */
    private _connectionLost$;
    private _sessionState$;
    listeners: OnTapEvent[];
    keepAlivePeriod: number;
    meta: {
        isClientConfigured?: boolean;
    };
    /**
     * @deprecated
     */
    private _dataManager?;
    /**
     * @deprecated
     */
    private _tapConfig$;
    /**
     * Event trigger when currrent Tap changed (set or unset)
     * If tap is removed, value will be undefined
     * Immediatly triggered the current value when subscribing
     */
    tapOrUndefinedChangedWithLastValue: Observable<Tap | undefined>;
    /**
     * Event trigger when currrent Tap changed (set or unset)
     * If tap is removed, value will be undefined
     */
    tapOrUndefinedChanged: Observable<Tap | undefined>;
    /**
     * Event trigger when a new Tap is selected (no event when tap is removed)
     */
    tapChanged: Observable<Tap>;
    /**
     * Event trigger when a new Tap is selected (no event when tap is removed)
     * Immediatly triggered the current value when subscribing
     */
    tapChangedWithLastValue: Observable<Tap>;
    /**
     * Event triggered when tap is removed
     */
    tapRemoved: Subject<Tap>;
    private _protocolMeta;
    private _availableProtocols;
    _isManualDisconnection: boolean;
    private _sessionStateSnapshot;
    get sessionStateSnapshot(): TapAuth.SessionState;
    get sessionState(): Observable<TapAuth.SessionState>;
    get protocolMeta$(): Observable<ProtocolMeta | undefined>;
    get availableProtocols$(): Observable<ProtocolMeta[]>;
    get protocolMeta(): ProtocolMeta | undefined;
    set protocolMeta(meta: ProtocolMeta | undefined);
    get connectionLost(): Observable<any>;
    get availableProtocols(): ProtocolMeta[];
    get tap(): Tap;
    get tapOrUndefined(): Tap | undefined;
    get hasTap(): boolean;
    set tapConfig(schema: TapConfiguratorConfig | undefined);
    get tapConfig(): TapConfiguratorConfig | undefined;
    get tapConfig$(): Observable<TapConfiguratorConfig | undefined>;
    isSameTag(tag: NdefTag): boolean;
    /**
     * Use another communicaiton protocol
     * May be rejected
     * @param meta: ProtocolMeta
     * @param disonnectCurrentProtocol if set to true and if tap is already connected with
     * a communication protocol, it will disconnect from it first
     * @param connectToNew: boolean
     */
    useProtocol(meta: ProtocolMeta, disonnectCurrentProtocol?: boolean, connectToNew?: boolean): Promise<void>;
    executeFactoryReset(): Promise<void>;
    set tap(t: Tap);
    constructor(platform: Platform, toastCtrl: ToastController, protocolFactory: ProtocolFactoryService, ngZone: NgZone);
    addProtocolMeta(meta: ProtocolMeta): void;
    /**
     * Parse NDefTag and try to create a ProtocolMeta thanks to record
     * @returns undefined if there is no other protocol in the tag
     */
    registerProtocolsFromTag(tag: NdefTag): Promise<ProtocolMeta | undefined>;
    /**
     * Will register available communication protocols on current tap
     * by asking LWM2M resources.
     * @returns the list of new ProtocolMeta found
     */
    registerProtocolsFromTap(): Promise<ProtocolMeta[]>;
    useProtocolFromMeta(newProtocolMeta: ProtocolMeta, disonnectCurrentProtocol?: boolean, connectToNew?: boolean): Promise<void>;
    /**
     * Switch from NFC communication protocol to a long range communication
     * @warning this is only available when we are in NFC
     *
     * @return the new protocol meta used or undefined if it does not have a long range protocol to use
     */
    useLongRangeProtocol(): Promise<ProtocolMeta | undefined>;
    /**
     * Connection state events.
     * It works even when tap is changed
     */
    get connectionState(): Observable<ConnectionStateChangeEvent>;
    /**
     * Connection state events with replay.
     * It works even when tap is changed
     */
    connectionStateReplay: Observable<ConnectionStateChangeEvent>;
    /**
     * Any connection state change
     */
    private _connectionState$;
    /**
     * @returns true if user is connected as given username or one of the given usernames
     */
    isLoggedInAsUserOrProfileName(userOrProfileNames: string | string[]): Promise<boolean>;
    login(username: string, password: string, refreshSessionState?: boolean): Promise<import("@iotize/tap/auth").ScramAuth.SessionData>;
    logout(throwErr?: boolean): Promise<boolean>;
    setTap(newTap: Tap, options?: {
        emit: boolean;
    }): void;
    notifyNewTap(): void;
    setTapFromEvent(event: TapSelectedEvent, options?: {
        emit: boolean;
    }): void;
    /**
     * Connect to the Tap and refresh session state
     * Throw error if it fails
     */
    connect(
    /**
     * @deprecated
     */
    throwErr?: boolean): Promise<boolean>;
    /**
     *  Disconnect Tap
     */
    disconnect(): Promise<void>;
    /**
     * Remove currently used Tap
     * If no Tap was set, do nothing
     */
    remove(disconnect?: boolean): Promise<void>;
    private notifyTapRemoved;
    /**
     * @deprecated
     */
    configureClientIfRequired(): Promise<void>;
    /**
     * Rebuild tap configuration according to data on the Tap
     *
     * @deprecated
     */
    loadConfigFromDevice(): Promise<void>;
    set dataManager(v: DataManagerIonic | undefined);
    get dataManager(): DataManagerIonic | undefined;
    /**
     * Configure client by reading tap device configuration
     *
     * @deprecated will be moved to a separate service
     *
     * @throws
     */
    configureClient(refresh?: boolean): Promise<void>;
    getCurrentProtocol(): ComProtocol | undefined;
    get keepAliveEngine(): KeepAliveEngine | undefined;
    hasProtocol(): boolean;
    registerEventListerner(listener: OnTapEvent): void;
    unregisterEventListener(listener: OnTapEvent): void;
    /**
     * @deprecated refractor: remove on error from this service to use a global handler
     *
     * @param err
     */
    private onError;
    reboot(): Promise<void>;
    clearAuth(): Promise<void>;
    refreshSessionState(): Promise<TapAuth.SessionState>;
    static ɵfac: i0.ɵɵFactoryDeclaration<CurrentDeviceService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<CurrentDeviceService>;
}
