import { AmplitudeEventBase } from '../models/amplitude/AmplitudeEventBase';
import { ChoiceCardWatchNonstopSelectedEvent } from '../models/amplitude/ChoiceCardWatchNonstopSelectedEvent';
import { NonstopHomeLearnMoreSelectedEvent } from '../models/amplitude/NonstopHomeLearnMoreSelectedEvent';
import { NonstopHomeLinkItemSelectedEvent } from '../models/amplitude/NonstopHomeLinkItemSelectedEvent';
import { NonstopHomeNonstopVideoCompleteEvent } from '../models/amplitude/NonstopHomeNonstopVideoCompleteEvent';
import { NonstopHomeNonstopVideoEndEvent } from '../models/amplitude/NonstopHomeNonstopVideoEndEvent';
import { NonstopHomeNonstopVideoStartEvent } from '../models/amplitude/NonstopHomeNonstopVideoStartEvent';
import { NonstopHomeRedeemCodeSuccessEvent } from '../models/amplitude/NonstopHomeRedeemCodeSuccessEvent';
import { RewardCardShownEvent } from '../models/amplitude/RewardCardShownEvent';
import { EarnRowItemType } from '../models/nonstophome/earnRowItemType';
import { ChoiceCardShownEvent } from './../models/amplitude/ChoiceCardShownEvent';
import { ChoiceCardWatchAndEarnSelectedEvent } from './../models/amplitude/ChoiceCardWatchAndEarnSelectedEvent';
import { NonstopHomeOtherItemSelectedEvent } from './../models/amplitude/NonstopHomeOtherItemSelectedEvent';
import { NonstopHomeRedeemCodeSelectedEvent } from './../models/amplitude/NonstopHomeRedeemCodeSelectedEvent';
import { NonstopHomeWatchAndEarnItemSelectedEvent } from './../models/amplitude/NonstopHomeWatchAndEarnItemSelectedEvent';
import amplitudeService from './amplitudeService';

class AmplitudeEventHandlers {
    public static sharedInstance = new AmplitudeEventHandlers();

    [eventName: string]: (event: AmplitudeEventBase) => void;

    public RewardCardShownHandler(event: AmplitudeEventBase) {
        const rewardCardEvent = event as RewardCardShownEvent;
        if (rewardCardEvent) {
            const amplitudeTaskName = rewardCardEvent.Task.replace(/-/gi, ' ');
            amplitudeService.sendEventToAmplitude('Nonstop Reward Card - Reward Card Shown', { Points: rewardCardEvent.Points, Task: amplitudeTaskName });
        }
    }

    public ChoiceCardShownHandler(event: AmplitudeEventBase) {
        const choiceCardEvent = event as ChoiceCardShownEvent;
        if (choiceCardEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Choice Card - Choice Card Shown', choiceCardEvent);
        }
    }

    public ChoiceCardWatchAndEarnSelectedHandler(event: AmplitudeEventBase) {
        const choiceCardWatchAndEarnEvent = event as ChoiceCardWatchAndEarnSelectedEvent;
        if (choiceCardWatchAndEarnEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Choice Card - Watch & Earn Selected', choiceCardWatchAndEarnEvent);
        }
    }

    public ChoiceCardWatchNonstopSelectedHandler(event: AmplitudeEventBase) {
        const choiceCardWatchNonstopSelectedEvent = event as ChoiceCardWatchNonstopSelectedEvent;
        if (choiceCardWatchNonstopSelectedEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Choice Card - Watch Nonstop Selected', choiceCardWatchNonstopSelectedEvent);
        }
    }

    public NonstopHomeWatchAndEarnItemSelectedHandler(event: AmplitudeEventBase) {
        const nonstopHomeWatchAndEarnItemEvent = event as NonstopHomeWatchAndEarnItemSelectedEvent;
        if (nonstopHomeWatchAndEarnItemEvent.ContentType === EarnRowItemType.Promo) {
            nonstopHomeWatchAndEarnItemEvent.ContentType = 'Promo';
        }
        if (nonstopHomeWatchAndEarnItemEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Watch & Earn Item Selected', nonstopHomeWatchAndEarnItemEvent);
        }
    }

    public NonstopHomeLinkItemSelectedHandler(event: AmplitudeEventBase) {
        const nonstopHomeLinkItemEvent = event as NonstopHomeLinkItemSelectedEvent;
        if (nonstopHomeLinkItemEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Link Item Selected', nonstopHomeLinkItemEvent);
        }
    }

    public NonstopHomeOtherItemSelectedHandler(event: AmplitudeEventBase) {
        const nonstopHomeOtherItemEvent = event as NonstopHomeOtherItemSelectedEvent;
        if (nonstopHomeOtherItemEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Other Item Selected', nonstopHomeOtherItemEvent);
        }
    }

    public NonstopHomeRedeemCodeSelectedHandler(event: AmplitudeEventBase) {
        const nonstopHomeRedeemCodeEvent = event as NonstopHomeRedeemCodeSelectedEvent;
        if (nonstopHomeRedeemCodeEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Redeem Code Selected', nonstopHomeRedeemCodeEvent);
        }
    }

    public NonstopHomeRedeemCodeSuccessHandler(event: AmplitudeEventBase) {
        const nonstopHomeRedeemCodeSuccessEvent = event as NonstopHomeRedeemCodeSuccessEvent;
        if (nonstopHomeRedeemCodeSuccessEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Redeem Code Success', nonstopHomeRedeemCodeSuccessEvent);
        }
    }

    public NonstopHomeNonstopVideoStartHandler(event: AmplitudeEventBase) {
        const nonstopHomeNonstopVideoStartEvent = event as NonstopHomeNonstopVideoStartEvent;
        if (nonstopHomeNonstopVideoStartEvent.ContentType === EarnRowItemType.Promo) {
            nonstopHomeNonstopVideoStartEvent.ContentType = 'Promo';
        }
        if (nonstopHomeNonstopVideoStartEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Viewing - Nonstop Video Start', nonstopHomeNonstopVideoStartEvent);
        }
    }

    public NonstopHomeNonstopVideoEndHandler(event: AmplitudeEventBase) {
        const nonstopHomeNonstopVideoEndEvent = event as NonstopHomeNonstopVideoEndEvent;
        if (nonstopHomeNonstopVideoEndEvent.ContentType === EarnRowItemType.Promo) {
            nonstopHomeNonstopVideoEndEvent.ContentType = 'Promo';
        }
        if (nonstopHomeNonstopVideoEndEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Viewing - Nonstop Video End', nonstopHomeNonstopVideoEndEvent);
        }
    }

    public NonstopHomeNonstopVideoCompleteHandler(event: AmplitudeEventBase) {
        const nonstopHomeNonstopVideoCompleteEvent = event as NonstopHomeNonstopVideoCompleteEvent;
        if (nonstopHomeNonstopVideoCompleteEvent.ContentType === EarnRowItemType.Promo) {
            nonstopHomeNonstopVideoCompleteEvent.ContentType = 'Promo';
        }
        if (nonstopHomeNonstopVideoCompleteEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Viewing - Nonstop Video Complete', nonstopHomeNonstopVideoCompleteEvent);
        }
    }

    public NonstopHomeLearnMoreSelectedHandler(event: AmplitudeEventBase) {
        const nonstopHomeLearnMoreEvent = event as NonstopHomeLearnMoreSelectedEvent;
        if (nonstopHomeLearnMoreEvent) {
            amplitudeService.sendEventToAmplitude('Nonstop Home - Learn More Selected', nonstopHomeLearnMoreEvent);
        }
    }
}

export default AmplitudeEventHandlers.sharedInstance as AmplitudeEventHandlers;