// @ts-ignore
import * as alertify from "alertifyjs";
import { NotificationService } from "./NotificationService";
import log = require("loglevel");
import bootbox = require("bootbox");
export class AlertifyNotificationService implements NotificationService {
  private readonly _alertify = alertify;
  constructor() {
    this._alertify.set("notifier", "position", "top-center");
  }
  success(message: string): void {
    this._alertify.success(message);
  }
  error(message: string): void {
    this._alertify.error(message);
  }
  errorWithDelay(message: string, delay: number): void {
    const _delay = this._alertify.get("notifier", "delay");
    this._alertify.set("notifier", "delay", delay);
    this._alertify.error(message);
    this._alertify.set("notifier", "delay", _delay);
  }
  warning(message: string): void {
    this._alertify.warning(message);
  }
  message(message: string): void {
    this._alertify.message(message);
  }
  passphrasePrompt(
    cb: (result: string) => void
  ): void {
    bootbox.prompt({
      title: "Please enter the passphrase",
      inputType: "password",
      callback: cb
    });
  }
}
