/**
 * CommonTestAndPreview Constants
 *
 * All Redux action types, channel constants, and other constants
 * used across the CommonTestAndPreview component system
 */

// ============================================
// REDUX ACTION TYPE CONSTANTS
// ============================================

// Search Customers
export const SEARCH_CUSTOMERS_REQUESTED = 'app/CommonTestAndPreview/SEARCH_CUSTOMERS_REQUESTED';
export const SEARCH_CUSTOMERS_SUCCESS = 'app/CommonTestAndPreview/SEARCH_CUSTOMERS_SUCCESS';
export const SEARCH_CUSTOMERS_FAILURE = 'app/CommonTestAndPreview/SEARCH_CUSTOMERS_FAILURE';

// Extract Tags
export const EXTRACT_TAGS_REQUESTED = 'app/CommonTestAndPreview/EXTRACT_TAGS_REQUESTED';
export const EXTRACT_TAGS_SUCCESS = 'app/CommonTestAndPreview/EXTRACT_TAGS_SUCCESS';
export const EXTRACT_TAGS_FAILURE = 'app/CommonTestAndPreview/EXTRACT_TAGS_FAILURE';

// Update Preview
export const UPDATE_PREVIEW_REQUESTED = 'app/CommonTestAndPreview/UPDATE_PREVIEW_REQUESTED';
export const UPDATE_PREVIEW_SUCCESS = 'app/CommonTestAndPreview/UPDATE_PREVIEW_SUCCESS';
export const UPDATE_PREVIEW_FAILURE = 'app/CommonTestAndPreview/UPDATE_PREVIEW_FAILURE';

// Send Test Message
export const SEND_TEST_MESSAGE_REQUESTED = 'app/CommonTestAndPreview/SEND_TEST_MESSAGE_REQUESTED';
export const SEND_TEST_MESSAGE_SUCCESS = 'app/CommonTestAndPreview/SEND_TEST_MESSAGE_SUCCESS';
export const SEND_TEST_MESSAGE_FAILURE = 'app/CommonTestAndPreview/SEND_TEST_MESSAGE_FAILURE';

// Test Customers
export const GET_TEST_CUSTOMERS_REQUESTED = 'app/CommonTestAndPreview/GET_TEST_CUSTOMERS_REQUESTED';
export const GET_TEST_CUSTOMERS_SUCCESS = 'app/CommonTestAndPreview/GET_TEST_CUSTOMERS_SUCCESS';
export const GET_TEST_CUSTOMERS_FAILURE = 'app/CommonTestAndPreview/GET_TEST_CUSTOMERS_FAILURE';
export const ADD_TEST_CUSTOMER = 'app/CommonTestAndPreview/ADD_TEST_CUSTOMER';

// Test Groups
export const GET_TEST_GROUPS_REQUESTED = 'app/CommonTestAndPreview/GET_TEST_GROUPS_REQUESTED';
export const GET_TEST_GROUPS_SUCCESS = 'app/CommonTestAndPreview/GET_TEST_GROUPS_SUCCESS';
export const GET_TEST_GROUPS_FAILURE = 'app/CommonTestAndPreview/GET_TEST_GROUPS_FAILURE';

// Create Message Meta
export const CREATE_MESSAGE_META_REQUESTED = 'app/CommonTestAndPreview/CREATE_MESSAGE_META_REQUESTED';
export const CREATE_MESSAGE_META_SUCCESS = 'app/CommonTestAndPreview/CREATE_MESSAGE_META_SUCCESS';
export const CREATE_MESSAGE_META_FAILURE = 'app/CommonTestAndPreview/CREATE_MESSAGE_META_FAILURE';

// Get Prefilled Values
export const GET_PREFILLED_VALUES_REQUESTED = 'app/CommonTestAndPreview/GET_PREFILLED_VALUES_REQUESTED';
export const GET_PREFILLED_VALUES_SUCCESS = 'app/CommonTestAndPreview/GET_PREFILLED_VALUES_SUCCESS';
export const GET_PREFILLED_VALUES_FAILURE = 'app/CommonTestAndPreview/GET_PREFILLED_VALUES_FAILURE';

// Clear Actions
export const CLEAR_CUSTOMER_SEARCH_STATE = 'app/CommonTestAndPreview/CLEAR_CUSTOMER_SEARCH_STATE';
export const CLEAR_SEARCH_RESULTS = 'app/CommonTestAndPreview/CLEAR_SEARCH_RESULTS';
export const CLEAR_PREFILLED_VALUES = 'app/CommonTestAndPreview/CLEAR_PREFILLED_VALUES';
export const CLEAR_PREVIEW_ERRORS = 'app/CommonTestAndPreview/CLEAR_PREVIEW_ERRORS';

// Get Sender Details (delivery settings for Test and Preview)
export const GET_SENDER_DETAILS_REQUESTED = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_REQUESTED';
export const GET_SENDER_DETAILS_SUCCESS = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_SUCCESS';
export const GET_SENDER_DETAILS_FAILURE = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_FAILURE';

// Get WeCRM Accounts (WhatsApp account list)
export const GET_WECRM_ACCOUNTS_REQUESTED = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_REQUESTED';
export const GET_WECRM_ACCOUNTS_SUCCESS = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_SUCCESS';
export const GET_WECRM_ACCOUNTS_FAILURE = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_FAILURE';


// ============================================
// CUSTOMER MODAL TYPE (test customer addition)
// ============================================
export const CUSTOMER_MODAL_NEW = 'new';
export const CUSTOMER_MODAL_EXISTING = 'existing';

// ============================================
// CHANNEL CONSTANTS
// ============================================
export const CHANNELS = {
  EMAIL: 'EMAIL',
  SMS: 'SMS',
  RCS: 'RCS',
  WHATSAPP: 'WHATSAPP',
  INAPP: 'INAPP',
  MOBILEPUSH: 'MOBILEPUSH',
  VIBER: 'VIBER',
  ZALO: 'ZALO',
  WEBPUSH: 'WEBPUSH',
};
export const CHANNELS_USING_ANDROID_PREVIEW_DEVICE = [CHANNELS.SMS, CHANNELS.RCS, CHANNELS.WHATSAPP, CHANNELS.VIBER, CHANNELS.ZALO, CHANNELS.INAPP, CHANNELS.MOBILEPUSH];

// ============================================
// DEVICE CONSTANTS
// ============================================
export const DESKTOP = 'desktop';
export const MOBILE = 'mobile';
export const TABLET = 'tablet';
export const ANDROID = 'android';
export const IOS = 'ios';

// ============================================
// MODULE AND CLIENT CONSTANTS
// ============================================
export const MODULE_CREATIVES = 'CREATIVES';
export const CLIENT_NAME_CREATIVES = 'CREATIVES';

// ============================================
// API CHANNEL CONSTANTS
// ============================================
// Note: API uses "PUSH" instead of "MOBILEPUSH" for MobilePush channel
export const API_CHANNEL_PUSH = 'PUSH';

// ============================================
// VALIDATION REGEX (shared with commonUtils for email/mobile validation)
// ============================================
export const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
export const PHONE_REGEX = /^[1-9]\d{7,14}$/;

// ============================================
// IDENTIFIER TYPE CONSTANTS
// ============================================
export const IDENTIFIER_TYPE_EMAIL = 'email';
export const IDENTIFIER_TYPE_MOBILE = 'mobile';
export const IDENTIFIER_TYPE_PHONE = 'phone';

// Customer creation modal – input error state class suffix (used with customer-creation-modal-input)
export const INPUT_HAS_ERROR_CLASS = ' has-input-error';

// ============================================
// CHANNEL NAME CONSTANTS (for CDN and other utilities)
// ============================================
export const CHANNEL_NAME_INAPP = 'INAPP';

// ============================================
// CHANNEL MAPPING CONSTANTS
// ============================================
export const CHANNEL_MAPPING_EMAIL = 'email';

// ============================================
// MEDIA TYPE CONSTANTS
// ============================================
export const MEDIA_TYPE_IMAGE = 'IMAGE';
export const MEDIA_TYPE_TEXT = 'TEXT';
export const MEDIA_TYPE_VIDEO = 'VIDEO';
export const MEDIA_TYPE_CAROUSEL = 'CAROUSEL';
export const MEDIA_TYPE_DOCUMENT = 'DOCUMENT';

// ============================================
// LAYOUT TYPE CONSTANTS
// ============================================
export const LAYOUT_TYPE_POPUP = 'POPUP';
export const LAYOUT_TYPE_FULLSCREEN = 'FULLSCREEN';
export const LAYOUT_TYPE_HEADER = 'HEADER';
export const LAYOUT_TYPE_FOOTER = 'FOOTER';
export const LAYOUT_TYPE_MODAL = 'MODAL';
export const LAYOUT_TYPE_BANNER = 'BANNER';

// ============================================
// CTA TYPE CONSTANTS
// ============================================
export const CTA_TYPE_DEEP_LINK = 'DEEP_LINK';
export const CTA_TYPE_EXTERNAL_URL = 'EXTERNAL_URL';

// ============================================
// STYLE TYPE CONSTANTS
// ============================================
export const STYLE_TYPE_BIG_PICTURE = 'BIG_PICTURE';
export const STYLE_TYPE_BIG_TEXT = 'BIG_TEXT';

// ============================================
// DEVICE TYPE CONSTANTS (for API payloads)
// ============================================
export const DEVICE_TYPE_ANDROID = 'ANDROID';
export const DEVICE_TYPE_IOS = 'IOS';

// ============================================
// BUTTON TYPE CONSTANTS
// ============================================
export const BUTTON_TYPE_NONE = 'NONE';
export const BUTTON_TYPE_PHONE_NUMBER = 'PHONE_NUMBER';
export const BUTTON_TYPE_DYNAMIC_URL = 'DYNAMIC_URL';

// ============================================
// OTHER CONSTANTS
// ============================================
export const TEST = 'TEST';
export const ACTIVE = 'active';

export const ANDROID_DEVICE_NAME = 'Android';
export const IOS_DEVICE_NAME = 'iOS';
export const VIBER_ACCOUNT_NAME = 'Viber';
export const DEFAULT_INAPP_SUBJECT = 'inApp test subject';
export const DEEPLINK_TYPE = 'deeplink';
export const CHANNEL_NAME_MOBILE_PUSH = 'MOBILE_PUSH';
export const DEFAULT_SENDER = 'test1';
export const VIBER_API_SCENARIO_KEY = 'viber-api';
export const VIBER_USER_ID_PATTERN = '{{viber_user_id}}';
export const UNSUBSCRIBE_TAG_NAME = 'unsubscribe';
export const IN_APP_CHANNEL_NAME = 'in-app';
export const MOBILE_PUSH_CHANNEL_NAME = 'mobile push';
export const CHANNEL = 'channel';
export const PHONE_NUMBER = 'PHONE_NUMBER';
export const DYNAMIC_URL = 'DYNAMIC_URL';
export const IMAGE = 'IMAGE';
export const VIDEO = 'VIDEO';
export const URL = 'URL';
export const DAYS = 'DAYS';

// Initial Payload Template (for reference)
export const INITIAL_PAYLOAD = {
  ouId: -1,
  sourceEntityId: "creatives_ui_76de58db-f70b-40d0-85a5-d014bda6e751",
  channel: "EMAIL",
  module: "CREATIVES",
  emailDeliverySettings: {
    additionalSettings: {
      encryptUrl: false,
      linkTrackingEnabled: false,
      useTinyUrl: false,
      skipRateLimit: false,
      bypassControlUser: false,
    },
    channelSettings: {
      channel: "EMAIL",
      senderLabel: "",
      senderId: "",
      replyToId: "",
    },
  },
  executionParams: {},
  clientName: "CREATIVES",
};

export const deviceAspectRatio = {
  desktop: () => ({
    height: '500',
    width: '1024',
  }),
  tablet: (emailSubject) => ({
    height: emailSubject ? '570' : '600',
    width: '450',
  }),
  mobile: (emailSubject) => ({
    height: emailSubject ? '570' : '600',
    width: '310',
  }),
};

// ============================================
// ERROR MESSAGE CONSTANTS
// ============================================
export const ERROR_MESSAGES = {
  NETWORK_ERROR: 'Network error occurred',
  FAILED_TO_SEARCH_CUSTOMERS: 'Failed to search customers',
  FAILED_TO_EXTRACT_TAGS: 'Failed to extract tags',
  FAILED_TO_UPDATE_PREVIEW: 'Failed to update preview',
  FAILED_TO_SEND_TEST_EMAIL: 'Failed to send test email',
  PROFILE_IS_EMPTY: 'Profile is empty',
  NO_TEST_CUSTOMERS_FOUND: 'No test customers found',
  FAILED_TO_FETCH_TEST_CUSTOMERS: 'Failed to fetch test customers',
  FAILED_TO_FETCH_TEST_GROUPS: 'Failed to fetch test groups',
  FAILED_TO_CREATE_MESSAGE_META: 'Failed to create message meta',
  FAILED_TO_FETCH_PREFILLED_VALUES: 'Failed to fetch prefilled values',
};

export const GLOBAL_CONVERT_OPTIONS = {
  wordwrap: false,
  preserveNewlines: false,
  uppercaseHeadings: false,
};

export const UUID_PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';

// ============================================
// TIME FORMAT CONSTANTS
// ============================================
export const TIME_FORMAT_HOUR_MODULO = 12;
export const TIME_FORMAT_MINUTE_PADDING_THRESHOLD = 10;
export const TIME_FORMAT_AM = 'AM';
export const TIME_FORMAT_PM = 'PM';
