/**
 * @author: Multiqos
 * File: commonVariables.ts
 * Purpose: This file contains constants and variables used throughout the application.
 *          It includes regular expressions for validation, strength levels, and API URLs.
 *          custom icons for success and error notifications, and a function to display SweetAlert notifications,
 *          storing the encryption key and HMAC secret, and a function to encrypt and decrypt data.
 *          It also includes variables for storing API keys.
 *          It also includes variables for storing the default language and default currency.
*/

const REGEX = {
  NAME: /^(?!\s+$)[a-zA-Z0-9 \-.'`]*$/,
  // EMAIL: /^\w+([\.+]*?\w+[\+]*)@\w+(\w+)(\.\w{2,3})+$/,
  EMAIL: /^[\w.+-]+@[\w-]+\.[\w.-]{2,}$/,
  UPPERCASE: /[A-Z]/,
  LOWERCASE: /[a-z]/,
  NUMBERS: /[0-9]/,
  PASSWORD_SPECIAL_CHARACTERS: /^(?=.*[~`!@#$%^&*()--+={}\[\]|\\:;"'<>,.?/_]).{8,}$/,
  PASSWORD: /^(?!.*\s)(?=.*[a-z])(?=.*[0-9])(?=.*[A-Z]|.*[^a-zA-Z0-9]).{8,}$/,
  USER_NAME: /^[a-zA-Z0-9._]*$/,
  SPEED: /^\d{0,4}$/,
}
/* Strength levels List */
const STRENGTH_LEVELS = [
  { text: "Weak!", color: "#F04438", className: "weak" },
  { text: "Medium!", color: "#F79009", className: "medium" },
  { text: "Ultimate!", color: "#17B26A", className: "ultimate" },
];

/* Common variables */
const COMMON_VARS = {
  MIN_PASSOWRD_LENGTH: 8,
  OTP_LENGTH: 4,
  RESEND_OTP_TIME: 59,
  REMEMBER_ME_EXPIRY: 30,
  USER_TYPE: {
    GUEST: 'guest',
    HOST: 'host',
  },
  DELAY_DEBOUNCE: 500,
}

const AUTH_COOKIES = {
  USER_TOKEN: 'webAccessToken',
  REMEMBERME: 'rememeberMeUserData'
}

const DATE_FORMAT = 'dd MMM, yyyy'

// API Endpoints
const API_ENDPOINTS = {
  VIEW_CMS: '/user/master/view-cms',
  LIST_FAQ: '/master/list-faq',
  LIST_BLOG: '/master/list-blog',
  CONTACT_US: '/user/master/contact-us',
  BLOG_DETAILS: '/master/view-blog',
  LIST_COUNTRY: '/master/list-country',
  // LRF API URLs
  SIGNUP: '/user/register',
  LOGIN: '/user/login',
  VERIFY_OTP: '/user/verify-otp',
  RESEND_OTP: '/user/resend-otp',
  FORGOT_PASSWORD: '/user/forgot-password',
  RESET_PASSWORD: '/user/reset-password',
  CHECK_USERNAME: '/user/check-username',
  VIEW_PROFILE: '/user/view-profile',

  //Property API URLs
  LIST_PROPERTY: '/property/list',
  PROPERTY_DETAILS: '/property/view',
  LIST_LOCATION: "/property/list-location",

  //Booking flow API URLs
  BOOKING_SUMMARY: "/booking/booking-summary",
  BOOKING_VIEW_PROPERTY_AVAILABILITY: "/booking/view-property-availability",
  LIST_FILTERS: "/property/list-filters",
  CREATE_BOOKING: "/booking/create",
  VIEW_BOOKING: "/booking/view",
  PAYMENT_DETAILS_LIST: "/user/payment-details/list",
  PAYMENT_DETAILS_ADD_EDIT: "/user/payment-details/add-edit",
  CANCEL_BOOKING: "/booking/cancel",
  RAISE_DISPUTE: "/booking/raise-dispute",

  // Media Upload API URLs
  MEDIA_UPLOAD: "/media/upload",
  DELETE_MEDIA: "/media/delete",
}

const SVG_COLORS = {
  PRIMARY_COLOR: '#FF7E67',
  SECONDARY_COLOR: '#006A71',
}

const SEARCHBAR_TYPE = {
  STANDARD: 'standard',
  FLEX: 'flex',
  SURPRISE: 'surprise'
}

const PROPERTY_VIEW = {
  MAP: 'map',
  LIST: 'list'
}


function generateArrivalTimeOptions() {
  const options = [{ value: "", label: "Not decided yet" }];
  const pad = (num: any) => num.toString().padStart(2, '0');

  for (let h = 0; h < 24; h++) {
    for (let m = 0; m < 60; m += 30) {
      const hour12 = h % 12 === 0 ? 12 : h % 12;
      const period = h < 12 ? 'AM' : 'PM';
      const minutes = pad(m);
      const label = `${pad(hour12)}:${minutes} ${period}`;
      options.push({ value: label, label });
    }
  }

  return options;
}


const ARRIVAL_TIME_OPTIONS = generateArrivalTimeOptions();


export { REGEX, STRENGTH_LEVELS, COMMON_VARS, AUTH_COOKIES, DATE_FORMAT, API_ENDPOINTS, SVG_COLORS, SEARCHBAR_TYPE, PROPERTY_VIEW, ARRIVAL_TIME_OPTIONS }
