<commit_before>import store from '../store'

function calcCoords (distance, angle, parentSize) {
  let X = 0
  let Y = 0
  let Xi = 0
  let Yi = 0
  if (distance !== 0) {
    X = ((store.actions.getComponentWidth(parentSize) / 2) * distance / 100) * Math.cos(angle * (Math.PI / 180))
    Y = ((store.actions.getComponentWidth(parentSize) / 2) * distance / 100) * Math.sin(angle * (Math.PI / 180))
    Xi = X > 0 ? -Math.abs(Number(X)) : Math.abs(Number(X))
    Yi = Y > 0 ? -Math.abs(Number(Y)) : Math.abs(Number(Y))
  }
  return {
    X,
    Y,
    Xi,
    Yi
  }
}

function determinePosition (pos) {
  if (store.state.history[store.state.history.length - pos]) {
    return store.state.history[store.state.history.length - pos].position
  } else {
    return {
      X: 0, Y: 0, Xi: 0, Yi: 0, scale: 0, scalei: 0
    }
  }
}

const position = {
  getCurrentPosition () {
    return store.state.history[store.state.history.length - 1].position
  },
  getPreviousPosition () {
    return determinePosition(2)
  },
  getPastPosition () {
    return determinePosition(3)
  },
  calcViewPosition (viewName) {
    store.actions.setLog('calcViewPosition() ' + viewName)
    return store.actions.getCurrentViewName() === viewName ? store.actions.getCurrentPosition() : store.actions.getPastPosition()
  },
  calcPosition (component) {
    const parentPosition =
      ['z-view', 'z-list', 'z-spot'].includes(component.$parent.componentType)<commit_msg>refactor(position): simplify Xi and Yi calculation in calcCoords method and use determinePosition() in getCurrentPosition method<commit_after>import store from '../store'

function calcCoords (distance, angle, parentSize) {
  let X = 0
  let Y = 0
  let Xi = 0
  let Yi = 0
  if (distance !== 0) {
    X = ((store.actions.getComponentWidth(parentSize) / 2) * distance / 100) * Math.cos(angle * (Math.PI / 180))
    Y = ((store.actions.getComponentWidth(parentSize) / 2) * distance / 100) * Math.sin(angle * (Math.PI / 180))
    Xi = -X
    Yi = -Y
  }
  return {
    X,
    Y,
    Xi,
    Yi
  }
}

function determinePosition (pos) {
  if (store.state.history[store.state.history.length - pos]) {
    return store.state.history[store.state.history.length - pos].position
  } else {
    return {
      X: 0, Y: 0, Xi: 0, Yi: 0, scale: 0, scalei: 0
    }
  }
}

const position = {
  getCurrentPosition () {
    return determinePosition(1)
  },
  getPreviousPosition () {
    return determinePosition(2)
  },
  getPastPosition () {
    return determinePosition(3)
  },
  calcViewPosition (viewName) {
    store.actions.setLog('calcViewPosition() ' + viewName)
    return store.actions.getCurrentViewName() === viewName ? store.actions.getCurrentPosition() : store.actions.getPastPosition()
  },
  calcPosition (component) {
    const parentPosition =
      ['z-view', 'z-list', 'z-spot'].includes(component.$parent.componentType)
{'fraction_non_alphanumeric': 0.14758092586146884, 'fraction_numerical': 0.02018795683954055, 'mean_word_length': 3.177325581395349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '98548', 'n_tokens_mistral': 1017, 'n_tokens_neox': 952, 'n_words': 218}