<commit_before>import { WindowConfig } from '../types'

type BrowserWindowProps = WindowConfig

export const openBrowserWindow = (config: BrowserWindowProps, onClose: () => void) => {
  const { name, width, height, center, url } = config
  console.log(center)
  const { left, top } = calculatePosition(center, width, height)

  const win = window.open(
    url,
    name,
    toWindowFeatures({
      width,
      height,
      left,
      top,
    }),
  )

  win.addEventListener('beforeunload', onClose)

  return Promise.resolve(win)
}

function calculatePosition(center: string = 'parent', width: number, height: number) {
  let left = 0
  let top = 0
  if (center === 'parent') {
    left = window.top.outerWidth / 2 + window.top.screenX - width / 2<commit_msg>Cleanup window<commit_after>import { WindowConfig } from '../types'

type BrowserWindowProps = WindowConfig

export const openBrowserWindow = (config: BrowserWindowProps, onClose: () => void) => {
  const { name, width, height, center, url } = config
  const { left, top } = calculatePosition(center, width, height)

  const win = window.open(
    url,
    name,
    toWindowFeatures({
      width,
      height,
      left,
      top,
    }),
  )

  if (onClose) {
    win.addEventListener('beforeunload', onClose)
  }

  return Promise.resolve(win)
}

function calculatePosition(center: string = 'parent', width: number, height: number) {
  let left = 0
  let top = 0
  if (center === 'parent') {
    left = window.top.outerWidth / 2 + window.top.screenX - width / 2
{'fraction_non_alphanumeric': 0.1271186440677966, 'fraction_numerical': 0.005215123859191656, 'mean_word_length': 3.2403314917127073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2142655', 'n_tokens_mistral': 480, 'n_tokens_neox': 461, 'n_words': 131}