<commit_before>const {
  BrowserWindow,
  Menu,
  app,
  dialog,
  TouchBar,
  shell,
  ipcMain
} = require('electron')
const {
  TouchBarLabel,
  TouchBarButton,
  TouchBarSpacer,
  TouchBarPopover,
  TouchBarGroup,
  TouchBarSlider,
  TouchBarSegmentedControl
} = TouchBar
const path = require('path')
const url = require('url')
const pjson = require('./package.json')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
global.__basedir = __dirname;
let filePath = "";
let win;
let isDev = false;
const template = [{
  label: 'File',
  submenu: [{
      label: 'About Mercury'
    }, {
      type: 'separator'
    }, {
      label: 'Settings',
      accelerator: 'CmdOrCtrl+,',
      click() {
        exports.openSettingWindow()
      }
    }, {
      type: 'separator'
    }, {
      label: 'New file',
      accelerator: 'CmdOrCtrl+N',
      click() { newfile() }
    }, {
      label: 'Open',
      accelerator: 'CmdOrCtrl+O',
      click() { openfile(() => {}) }
    }, {
      label: 'Save',
      accelerator: "CmdOrCtrl+S",
      click() {
        if(filePath === "") {
          saveAs();
        } else {
          console.log('Saving in '+filePath);
          win.webContents.send('saved-file', filePath)
        }
      }
    }, {
      label: 'Save As',
      accelerator: 'CmdOrCtrl+Shift+S',
      click() { saveAs()}
    }, {
      type: 'separator'
    }, {
      label: 'Quit',
      role: 'quit'
    }]
  }, {
    label: 'About',
    submenu: [{
      label: 'Version ' + pjson.version,
      type: 'checkbox',
      checked: true,
      enabled: false
    }, {
      label: 'ChartJS',
      submenu: [{
        label: 'Samples',
        click() {
          shell.openExternal("http://www.chartjs.org/samples/latest/")
        }
      }, {
        label: 'Doc',
        click() {
          shell.openExternal("http://www.chartjs.org/docs/latest/")
        }
      }]
    }, {
      label: 'Bulma',
      submenu: [{
        label: 'Doc',
        click() {
          shell.openExternal("http://bulma.io/documentation/overview/start/")
        }
      }]
    }, {
      label: 'Font Awesome',
      submenu: [{
        label: 'Icons',
        click() {
          shell.openExternal("http://fontawesome.io/icons/")
        }
      }]
    }, {
      type: 'separator'
    }, {
      label: 'Enable DevTools',
      type: 'checkbox',
      checked: isDev,
      role: 'toggledevtools',
      click() {
        isDev = !isDev
      }
    }]
  } ,{
    label: 'Reports',
    submenu:[{
        label: 'Time Report',
        accelerator: 'Alt+T',
        icon: path.join(__dirname,'/assets/img/fa-area-chart_16.png'),
        click() {
          exports.openChronoWindow();
        }
      },{
        label: 'Statistic Report',
        accelerator: 'Alt+S',
        icon: path.join(__dirname,'/assets/img/fa-pie-chart_16.png'),
        click() {
          exports.openStatisticWindow();
        }
      },{
        label: 'Balance Report',
        accelerator: 'Alt+B',
        icon: path.join(__dirname,'/assets/img/fa-line-chart_16.png'),
        click() {
          exports.openBalanceWindow();
        }
      }
    ]
  },{
    label: 'Windows',
    submenu: [{
      label: 'Minimize',
      accelerator: 'CmdOrCtrl+M',
      role: 'minimize'
    }, {
      label: 'Toggle fullscreen',
      accelerator: 'CmdOrCtrl+F',
      role: 'togglefullscreen'
    }, {
      label: 'Close Window',
      accelerator: 'CmdOrCtrl+W',
      role: 'close'
    }]
  }]


const settingTBButton = new TouchBarButton({
  backgroundColor: '#3272dd',
  icon: path.join(__dirname,'/assets/img/fa-sliders_16.png'),
  click() {
    exports.openSettingWindow();
  }
})

const chronoTBButton = new TouchBarButton({<commit_msg>:lipstick: more natural menu<commit_after>const {
  BrowserWindow,
  Menu,
  app,
  dialog,
  TouchBar,
  shell,
  ipcMain
} = require('electron')
const {
  TouchBarLabel,
  TouchBarButton,
  TouchBarSpacer,
  TouchBarPopover,
  TouchBarGroup,
  TouchBarSlider,
  TouchBarSegmentedControl
} = TouchBar
const path = require('path')
const url = require('url')
const pjson = require('./package.json')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
global.__basedir = __dirname;
let filePath = "";
let win;
let isDev = false;
let authorizeDev = true;
const template = [{
  label: 'File',
  submenu: [{
      label: 'New file',
      accelerator: 'CmdOrCtrl+N',
      click() { newfile() }
    }, {
      label: 'Open',
      accelerator: 'CmdOrCtrl+O',
      click() { openfile(() => {}) }
    }, {
      label: 'Save',
      accelerator: "CmdOrCtrl+S",
      click() {
        if(filePath === "") {
          saveAs();
        } else {
          console.log('Saving in '+filePath);
          win.webContents.send('saved-file', filePath)
        }
      }
    }, {
      label: 'Save As',
      accelerator: 'CmdOrCtrl+Shift+S',
      click() { saveAs()}
    }, {
      type: 'separator'
    }, {
        label: 'Settings',
        accelerator: 'CmdOrCtrl+,',
        click() {
          exports.openSettingWindow()
        }
      }, {
        type: 'separator'
      }, {
      role: 'quit'
    }]
  },{
    role: 'editMenu'
  },{
    label: 'Reports',
    submenu:[{
        label: 'Time Report',
        accelerator: 'Alt+T',
        icon: path.join(__dirname,'/assets/img/fa-area-chart_16.png'),
        click() {
          exports.openChronoWindow();
        }
      },{
        label: 'Statistic Report',
        accelerator: 'Alt+S',
        icon: path.join(__dirname,'/assets/img/fa-pie-chart_16.png'),
        click() {
          exports.openStatisticWindow();
        }
      },{
        label: 'Balance Report',
        accelerator: 'Alt+B',
        icon: path.join(__dirname,'/assets/img/fa-line-chart_16.png'),
        click() {
          exports.openBalanceWindow();
        }
      }
    ]
  },{
    label: 'Windows',
    role: 'window',
    submenu: [{
      role: 'reload'
    },{
      role: 'minimize'
    }, {
      role: 'togglefullscreen'
    }, {
      role: 'close'
    }]
  },{
    role: 'help',
    submenu: [
      {
        label: 'Learn More',
        click () { require('electron').shell.openExternal('https://electron.atom.io') }
      }],
  }]

if (authorizeDev) {
  template.push({
    label: 'About',
    submenu: [{
      label: 'Version ' + pjson.version,
      type: 'checkbox',
      checked: true,
      enabled: false
    }, {
      type: 'separator'
    }, {
      label: 'Enable DevTools',
      type: 'checkbox',
      checked: isDev,
      role: 'toggledevtools',
      click() {
        isDev = !isDev
      }
    }]
  });
}
if (process.platform === 'darwin') {
  template.unshift({
    label: app.getName(),
    submenu: [
      {role: 'about'},
      {type: 'separator'},
      {
          label: 'Settings',
          accelerator: 'CmdOrCtrl+,',
          click() {
            exports.openSettingWindow()
          }
        },
      {type: 'separator'},
      {role: 'services', submenu: []},
      {type: 'separator'},
      {role: 'hide'},
      {role: 'hideothers'},
      {role: 'unhide'},
      {type: 'separator'},
      {role: 'quit'}
    ]
  });
  template[1].submenu.pop();
  template[1].submenu.pop();
  template[1].submenu.pop();
}


const settingTBButton = new TouchBarButton({
  backgroundColor: '#3272dd',
  icon: path.join(__dirname,'/assets/img/fa-sliders_16.png'),
  click() {
    exports.openSettingWindow();
  }
})

const chronoTBButton = new TouchBarButton({
{'fraction_non_alphanumeric': 0.16174934725848564, 'fraction_numerical': 0.003524804177545692, 'mean_word_length': 2.0582834331337327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4770082', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2474, 'n_words': 484}