import * as path from 'path';
import { BrowserWindowConstructorOptions } from 'electron';

export interface ElectronNotificationOptions {
  width?: number;
  height?: number;
  padding?: number;
  borderRadius?: number;
  displayTime?: number;
  animationSteps?: number;
  animationStepMs?: number;
  animateInParallel?: boolean;
  appIcon?: string;
  pathToModule?: string;
  logging?: boolean;
  defaultStyleContainer?: {
    [attribute: string]: any;
  };
  defaultStyleAppIcon?: {
    [attribute: string]: any;
  };
  defaultStyleImage?: {
    [attribute: string]: any;
  };
  defaultStyleClose?: {
    [attribute: string]: any;
  };
  defaultStyleText?: {
    [attribute: string]: any;
  };
  defaultWindow?: BrowserWindowConstructorOptions;
  templatePath?: string;
  htmlTemplate?: string;
}

export const DefaultElectronNotificationOptions: ElectronNotificationOptions = {
  width: 300,
  height: 65,
  padding: 10,
  borderRadius: 5,
  displayTime: 5000,
  animationSteps: 5,
  animationStepMs: 20,
  appIcon: null,
  pathToModule: '',
  logging: true,

  defaultStyleContainer: {
    backgroundColor: '#f0f0f0',
    overflow: 'hidden',
    padding: 8,
    border: '1px solid #CCC',
    fontFamily: 'Arial',
    fontSize: 12,
    position: 'relative',
    lineHeight: '15px'
  },
  defaultStyleAppIcon: {
    overflow: 'hidden',
    float: 'left',
    height: 40,
    width: 40,
    marginRight: 10
  },
  defaultStyleImage: {
    overflow: 'hidden',
    float: 'right',
    height: 40,
    width: 40,
    marginLeft: 10
  },
  defaultStyleClose: {
    position: 'absolute',
    top: 1,
    right: 3,
    fontSize: 11,
    color: '#CCC'
  },
  defaultStyleText: {
    margin: 0,
    overflow: 'hidden',
    cursor: 'default'
  },
  defaultWindow: {
    alwaysOnTop: true,
    skipTaskbar: true,
    resizable: false,
    show: false,
    frame: false,
    transparent: true,
    acceptFirstMouse: true,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      webSecurity: false,
      allowRunningInsecureContent: true
    }
  },
  htmlTemplate:
    '<html>\n' +
    '<head></head>\n' +
    '<body style="overflow: hidden; -webkit-user-select: none;">\n' +
    '<div id="container">\n' +
    ' <img src="" id="appIcon" />\n' +
    ' <img src="" id="image" />\n' +
    ' <div id="text">\n' +
    '   <b id="title"></b>\n' +
    '   <p id="message"></p>\n' +
    ' </div>\n' +
    ' <div id="close">X</div>\n' +
    '</div>\n' +
    '</body>\n' +
    '</html>'
};
