import { format } from 'date-fns';
export function slugify(text) {
  return text.toLowerCase().replace(/[^\w]+/g, '-');
}
export const sample = (array) => array[Math.floor(Math.random() * array.length)];
export const keyBy = (array, keyMap, valMap) => array.reduce((obj, item) => {
  obj[keyMap(item)] = valMap ? valMap(item) : item;
  return obj;
}, {});
export const debounce = (fn, wait) => {
  let scheduled = null;
  return (...args) => {
    clearTimeout(scheduled);
    scheduled = setTimeout(fn, wait, ...args);
  };
};
export function GetGoalAppData(title, description, category, percentage, goalText) {
  return {
    Name: title,
    Description: description,
    Category: category,
    Percentage: percentage,
    GoalText: goalText,
  };
}
export function MyMoodTemplate(feeling, intensity, location) {
  return `Mood : ${feeling} and Level: ${intensity} <img src="${location}" />`;
}
export function MyMoodTemplateJSON(feeling, intensity, location) {
  return JSON.stringify({ Mood: feeling, Level: intensity, MoodImage: location });
}
export function MyHealthTemplate(heartRate) {
  return `Heart rate  ${heartRate} bpm`;
}
export function MyHealthTemplateJSON(heartRate) {
  return JSON.stringify({ HearthRate: heartRate });
}
export function MyGoalTemplate(goalName, text, progress) {
  return `Goal update: ${goalName} ${text} Progress: ${progress}`;
}
export function MyGoalTemplateJSON(goalName, goalUpdateText, progress) {
  return JSON.stringify({ GoalTitle: goalName, GoalText: goalUpdateText, GoalProgress: progress });
}
export function FeedPostJSON(postText) {
  return JSON.stringify({ PostText: postText });
}
export class SparkleGlobal {
}
SparkleGlobal.MY_GOALS_APP_ID = 1;
SparkleGlobal.MY_HEALTH_APP_ID = 2;
SparkleGlobal.MY_MOOD_APP_ID = 3;
SparkleGlobal.LOCALSTORAGE_CLASSROOM_MODE = 'SPARKLE_CLASSROOM_MODE';
export function date(date) {
  return format(new Date(date), 'DD MMM YYYY');
}
