export type TgEventType =
  | 'visit.new'
  | 'cart.add'
  | 'cart.remove'
  | 'checkout.start'
  | 'order.new'
  | 'payment.update';

export interface VisitNewEvent {
  type: 'visit.new';
  visitorId: string;
  ip: string;
  country?: string;
  countryName?: string;
  city?: string;
  flag?: string;
  geoSource?: string;
  userAgent?: string;
  referer?: string;
  landingUrl: string;
  at: string;
}

export interface CartAddEvent {
  type: 'cart.add';
  visitorId: string;
  ip?: string;
  country?: string;
  countryName?: string;
  city?: string;
  flag?: string;
  device?: string;
  userAgent?: string;
  referer?: string;
  sourceUrl?: string;
  productId: string;
  productName: string;
  price: number;
  currency: string;
  quantity: number;
  size?: string;
  imageUrl?: string;
  cartTotal: number;
  cartItemsCount: number;
  at: string;
}

export interface CartRemoveEvent {
  type: 'cart.remove';
  visitorId: string;
  ip?: string;
  country?: string;
  countryName?: string;
  city?: string;
  flag?: string;
  device?: string;
  productId: string;
  productName: string;
  quantity?: number;
  cartTotal?: number;
  cartItemsCount?: number;
  currency?: string;
  at: string;
}

export interface CheckoutStartEvent {
  type: 'checkout.start';
  visitorId: string;
  ip?: string;
  country?: string;
  countryName?: string;
  city?: string;
  device?: string;
  userAgent?: string;
  referer?: string;
  cartTotal: number;
  cartItemsCount: number;
  currency: string;
  items: Array<{ name: string; qty: number; price: number; size?: string }>;
  at: string;
}

export interface OrderNewEvent {
  type: 'order.new';
  orderId: number;
  reference: string;
  paymentMethod: string;
  visitorId?: string;
  visitorIp?: string;
  visitorCountry?: string;
  visitorCountryName?: string;
  visitorCity?: string;
  visitorFlag?: string;
  visitorDevice?: string;
  landingUrl?: string;
  referer?: string;
  name: string;
  phone: string;
  email?: string;
  city: string;
  address: string;
  total: number;
  currency: string;
  itemsCount: number;
  items: Array<{ name: string; qty: number; price: number; size?: string }>;
  at: string;
}

export interface PaymentUpdateEvent {
  type: 'payment.update';
  orderId: number;
  reference: string;
  status: string;
  paymentMethod: string;
  visitorId?: string;
  visitorIp?: string;
  visitorCountry?: string;
  visitorCountryName?: string;
  visitorCity?: string;
  visitorFlag?: string;
  total: number;
  currency: string;
  at: string;
}

export type TgEvent =
  | VisitNewEvent
  | CartAddEvent
  | CartRemoveEvent
  | CheckoutStartEvent
  | OrderNewEvent
  | PaymentUpdateEvent;
