export default {
  methods: {
    getMuscleRefPics(count) {
      let muscles = [];

      for (let i = 0; i < count; i++) {
        let imgNum = (i + 1).toString().padStart(2, "0");
        muscles.push(`/img/muscle-ref/muscle-ref${imgNum}.JPG`);
      }

      return muscles;
    },

    getClothesPics() {
      const warm = [
        "/img/clothes-ref/warm/tank-top.jpg",
        "/img/clothes-ref/warm/shorts.jpg",
        "/img/clothes-ref/warm/hoodie.jpg",
        "/img/clothes-ref/warm/sneakers.jpg"
      ];

      const cold = [
        "/img/clothes-ref/cold/coat.jpg",
        "/img/clothes-ref/cold/scarf.jpg",
        "/img/clothes-ref/cold/hoodie.jpg",
        "/img/clothes-ref/cold/jeans.jpg",
        "/img/clothes-ref/cold/boots.jpg"
      ];

      const workout = [
        "/img/clothes-ref/workout/hoodie.jpg",
        "/img/clothes-ref/workout/tank-top.jpg",
        "/img/clothes-ref/workout/gloves.jpg",
        "/img/clothes-ref/workout/shorts.jpg"
      ];

      const lazy = [
        "/img/clothes-ref/lazy/pants.jpg",
        "/img/clothes-ref/lazy/undies.jpg"
      ];

      return [warm, cold, workout, lazy];
    },

    getKittens(count) {
      let kittens = [];

      for (let i = 0; i < count; i++) {
        let width = this.getRandomInt(300, 600);
        let height = this.getRandomInt(300, 600);
        kittens.push(`https://placekitten.com/${width}/${height}`);
      }

      return kittens;
    },

    getRandomInt(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      max++; // make it inclusive
      return Math.floor(Math.random() * (max - min)) + min;
    },

    getClientLocale() {
      if (navigator.language) {
        return navigator.languages[0];
      } else if (navigator.userLanguage) {
        return navigator.userLanguage; // IE < 11
      } else if (navigator.browserLanguage) {
        return navigator.userLanguage;
      } else if (navigator.systemLanguage) {
        return navigator.systemLanguage;
      }
      // return navigator.language ? navigator.languages[0] : navigator.language;
    },

    toImperial(cm) {
      const realFeet = (cm * 0.3937) / 12;
      const feet = Math.floor(realFeet);
      const inches = Math.round((realFeet - feet) * 12);

      return `${feet}'${inches}"`;
    },

    toInch(cm) {
      return `${Math.round(cm / 2.45)} in`;
    },

    toLbs(kg) {
      const nearExact = kg / 0.45359237;
      const lbs = Math.floor(nearExact);

      return lbs;
    }
  }
};
