import { Observable } from 'rxjs';

import { WindowState } from '../types/window-state.type';
import { WindowIdle } from '../types/window-idle.type';
import { NotificationRequest } from '../models/notification';
import { TranslateLoader } from '@ngx-translate/core';
import { StatusCode } from '@ucap-webmessenger/core';
import { UpdateInfo, UpdateCheckConfig } from '../models/update-info';
import { NativeType } from '../types/native.type';

export type NativePathName =
  | 'home'
  | 'documents'
  | 'downloads'
  | 'music'
  | 'pictures'
  | 'videos';

export abstract class NativeService {
  abstract type(): NativeType;
  abstract postAppInit(): void;

  abstract logout(): Observable<void>;
  abstract changeStatus(): Observable<StatusCode>;
  abstract showSetting(): Observable<void>;

  abstract getNetworkInfo(): Promise<any>;
  abstract getVersionInfo(): Promise<string>;

  abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>;
  abstract changeStartupHideWindow(
    startupHideWindow: boolean
  ): Promise<boolean>;
  abstract changeDownloadPath(downloadPath: string): Promise<string>;

  abstract notify(noti: NotificationRequest): void;
  abstract closeAllNotify(): void;

  abstract checkForUpdates(currentVersion: string): void;
  abstract checkForInstantUpdates(
    config: UpdateCheckConfig
  ): Observable<UpdateInfo>;
  abstract applyInstantUpdates(): void;

  abstract showImageViewer(): void;

  abstract saveFile(
    buffer: Buffer,
    fileName: string,
    mimeType: string,
    path?: string
  ): Promise<string>;
  abstract readFile(path: string): Promise<Buffer>;
  abstract openDefaultDownloadFolder(): Promise<boolean>;
  abstract openTargetFolder(
    folderPath?: string,
    make?: boolean
  ): Promise<boolean>;
  abstract openTargetItem(filePath?: string): Promise<boolean>;
  abstract getPath(name: NativePathName): Promise<string>;
  abstract selectDirectory(): Promise<string>;
  abstract selectSaveFilePath(
    defaultPath?: string
  ): Promise<{
    canceled: boolean;
    filePath: string;
  }>;

  abstract executeProcess(executableName: string): Promise<number>;

  abstract windowStateChanged(): Observable<WindowState>;
  abstract windowClose(): void;
  abstract windowMinimize(): void;
  abstract windowMaximize(): void;
  abstract zoomTo(factor: number): Promise<number>;
  abstract appExit(): void;

  abstract idleStateChanged(): Observable<WindowIdle>;
  abstract idleStateStop(): void;
  abstract changeLimitOfIdleState(limitTime: number): void;

  abstract chatOpenRoom(): Observable<string>;
  abstract msgOpenMessage(): Observable<string>;

  abstract getTranslateLoader(
    prefix?: string,
    suffix?: string
  ): TranslateLoader;

  abstract openDefaultBrowser(url: string): void;
}
