import {ThemeMode} from './appVar';

export type EMail = string;

export type langCode = 'en' | string;

export type timestamp = number;

export type AccountName = string;
export type Username = string | undefined;
export type Password = string;
export type UserAgent = string;
export type XToken = string;
export type verifyId = string;

export type XAuthorization = string;
export type UserId = string;
export type WebSocketSessionId = string;

export const accountNameOptions = {
  minLength: 4,
  maxLength: 24,
  isAllowed: (text: string): boolean => {
    return text.match('^[a-zA-Z0-9_.]+$') !== null;
  },
};

export const userNameOptions = {
  minLength: 2,
  maxLength: 24,
  isAllowed: (text: string): boolean => {
    return true;
  },
};

export const passwordOptions = {
  minLength: 6,
  maxLength: 64,
  minBits: 50,
  isAllowed: (text: string): boolean => {
    return /\W/.test(text) && /[a-zA-Z]/.test(text) && /[a-zA-Z]/.test(text);
  },
};

export const emailOptions = {
  maxLength: 48,
  isAllowed: (email: string) => {
    return String(email).match(
      /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
    );
  },
};
