package data

const (
	EVENT_CAMPAIGN_SCHEDULED        = "campaign_scheduled"
	EVENT_CAMPAIGN_ACTIVE           = "campaign_active"
	EVENT_CAMPAIGN_SELF_MANAGED     = "campaign_self_managed"
	EVENT_CAMPAIGN_PENDING_SCHEDULE = "campaign_pending_schedule"
	EVENT_CAMPAIGN_CLOSED           = "campaign_closed"

	EVENT_CAMPAIGN_RECIPIENT_SCHEDULED            = "campaign_recipient_scheduled"
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_SENT         = "campaign_recipient_message_sent"
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_FAILED       = "campaign_recipient_message_failed"
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_READ         = "campaign_recipient_message_read"
	EVENT_CAMPAIGN_RECIPIENT_EVASION_PAGE_VISITED = "campaign_recipient_evasion_page_visited"
	EVENT_CAMPAIGN_RECIPIENT_BEFORE_PAGE_VISITED  = "campaign_recipient_before_page_visited"
	EVENT_CAMPAIGN_RECIPIENT_PAGE_VISITED         = "campaign_recipient_page_visited"
	EVENT_CAMPAIGN_RECIPIENT_AFTER_PAGE_VISITED   = "campaign_recipient_after_page_visited"
	EVENT_CAMPAIGN_RECIPIENT_DENY_PAGE_VISITED    = "campaign_recipient_deny_page_visited"
	EVENT_CAMPAIGN_RECIPIENT_SUBMITTED_DATA       = "campaign_recipient_submitted_data"
	EVENT_CAMPAIGN_RECIPIENT_REPORTED             = "campaign_recipient_reported"
	EVENT_CAMPAIGN_RECIPIENT_CANCELLED            = "campaign_recipient_cancelled"
	EVENT_CAMPAIGN_RECIPIENT_INFO                 = "campaign_recipient_info"
)

var Events = []string{
	// campaign events
	EVENT_CAMPAIGN_SCHEDULED,
	EVENT_CAMPAIGN_ACTIVE,
	EVENT_CAMPAIGN_SELF_MANAGED,
	EVENT_CAMPAIGN_PENDING_SCHEDULE,
	EVENT_CAMPAIGN_CLOSED,
	// campaign recipient events
	EVENT_CAMPAIGN_RECIPIENT_SCHEDULED,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_SENT,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_FAILED,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_READ,
	EVENT_CAMPAIGN_RECIPIENT_EVASION_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_BEFORE_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_AFTER_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_DENY_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_SUBMITTED_DATA,
	EVENT_CAMPAIGN_RECIPIENT_REPORTED,
	EVENT_CAMPAIGN_RECIPIENT_CANCELLED,
	EVENT_CAMPAIGN_RECIPIENT_INFO,
}

// webhook event bit flags for storing selected events as int
// includes all events that call HandleWebhook (campaign.go + proxy.go)
const (
	WEBHOOK_EVENT_BIT_CAMPAIGN_CLOSED                         = 1 << 0 // 1
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_SENT         = 1 << 1 // 2
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_FAILED       = 1 << 2 // 4
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_READ         = 1 << 3 // 8
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_SUBMITTED_DATA       = 1 << 4 // 16
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_EVASION_PAGE_VISITED = 1 << 5 // 32
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_BEFORE_PAGE_VISITED  = 1 << 6 // 64
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_PAGE_VISITED         = 1 << 7 // 128
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_AFTER_PAGE_VISITED   = 1 << 8 // 256
	WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_DENY_PAGE_VISITED    = 1 << 9 // 512
)

// WEBHOOK_EVENT_ALL_BITS represents all events selected
const WEBHOOK_EVENT_ALL_BITS = 1023 // 2^10 - 1

// map event names to their bit positions
var WebhookEventToBit = map[string]int{
	EVENT_CAMPAIGN_CLOSED:                         WEBHOOK_EVENT_BIT_CAMPAIGN_CLOSED,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_SENT:         WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_SENT,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_FAILED:       WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_FAILED,
	EVENT_CAMPAIGN_RECIPIENT_MESSAGE_READ:         WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_MESSAGE_READ,
	EVENT_CAMPAIGN_RECIPIENT_SUBMITTED_DATA:       WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_SUBMITTED_DATA,
	EVENT_CAMPAIGN_RECIPIENT_EVASION_PAGE_VISITED: WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_EVASION_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_BEFORE_PAGE_VISITED:  WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_BEFORE_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_PAGE_VISITED:         WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_AFTER_PAGE_VISITED:   WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_AFTER_PAGE_VISITED,
	EVENT_CAMPAIGN_RECIPIENT_DENY_PAGE_VISITED:    WEBHOOK_EVENT_BIT_CAMPAIGN_RECIPIENT_DENY_PAGE_VISITED,
}
