export interface IKnokImage {
    url: string;
    fileName: string;
    contentType: string;
    content: string; // number[];
}

export interface IAnalysisTag {
    analysisTagId: number;
    name: string;
}

export interface IAnalysisTags {
    items: IAnalysisTag[];
}

export interface IKnokAnalysis {
    analysisId: number;
    header: string;
    description: string;
    image: IKnokImage;
    references: string;
    tags: IAnalysisTag[];
}

export interface IDiscoverKnok {
    knokId: number;
    userName: string;
    avatarUrl: string;
    followers: number;
    raiting: number;
    currencyPair: string;
    exchangeName: string;
    timeLeft: Date;
    purchases: number;
    priceUSD: number;
    price: number;
    isEntryPriceTouched: boolean;
    value: number;
    potentialProfit: number;
    hasTechnical: boolean;
    hasFundamental: boolean;
}

export interface IDiscoverKnoks {
    items: IDiscoverKnok[];
}

export class DiscoverKnok implements IDiscoverKnok {
    knokId: number;
    userName: string;
    avatarUrl: string;
    followers: number;
    raiting: number;
    currencyPair: string;
    exchangeName: string;
    timeLeft: Date;
    purchases: number;
    priceUSD: number;
    price: number;
    isEntryPriceTouched: boolean;
    value: number;
    potentialProfit: number;
    hasTechnical: boolean;
    hasFundamental: boolean;
    constructor() {
        this.knokId = null;
        this.userName = '';
        this.avatarUrl = null;
        this.followers = 0;
        this.raiting = 0;
        this.currencyPair = '';
        this.exchangeName = '';
        this.timeLeft = new Date();
        this.purchases = null;
        this.priceUSD = null;
        this.price = null;
        this.isEntryPriceTouched = false;
        this.value = null;
        this.potentialProfit = 1;
        this.hasTechnical = false;
        this.hasFundamental = false;
    }
}

export interface IKnokFeedArgs {
    sortOrderAsc: boolean;
    sortField: number;
    raitings?: number;
    knoksersIFollow: boolean;
    containsTA: boolean;
    containsFA: boolean;
    knokPriceMax: number;
    knokPriceMin: number;
    exchangesIds: number[];
    tradingPairs: string[];
}

export interface IKnokOngoingArgs {
    sortOrderAsc: boolean;
    published: boolean;
    gaining: boolean;
    losing: boolean;
    loseStatus?: number;
    knokser: string;
    sortField: number;
    exchangesIds: number[];
    tradingPairs: string[];
 }

export interface IFeedUser {
    userId: number;
    href: string;
    userName: string;
    firstName: string;
    lastName: string;
    hasAvatar: boolean;
    userFollowers: number;
    knokerRatingPoints: number;
    knokserRank: number;
}

export interface IKnokserProfile {
    userId: number;
    href: string;
    userName: string;
    firstName: string;
    lastName: string;
    hasAvatar: boolean;
    userFollowers: number;
    knokerRatingPoints: number;
    knokserRank: number;
    registrationDate: Date;
    boughtBy: number;
    distanceFromTarget: number;
    successRate: number;
    publishedKnoks: number;
    successSequence: number;
}

/**
 * @deprecated Use `IKnoker` instead.
 */
export interface IKnokser {
    userId: number;
    href: string;
    userName: string;
    firstName: string;
    lastName: string;
    hasAvatar: boolean;
    userFollowers: number;
    rank: number;
    // pricePool: number;
}

export interface IKnoker {
  userId: number;
  avatarUrl: string;
  userName: string;
  firstName: string;
  lastName: string;
  hasAvatar: boolean;
  userFollowers?: number;
  rank?: number;
  countFollowers?: number;
}

export class Knoker implements IKnoker {
  userId: number;
  avatarUrl: string;
  userName: string;
  firstName: string;
  lastName: string;
  hasAvatar: boolean;
  userFollowers: number;
  rank: number;
  countFollowers: number;

  constructor() {
    this.avatarUrl = null;
    this.firstName = '';
    this.lastName = '';
    this.hasAvatar = false;
    this.userFollowers = 0;
    this.rank = 0;
    this.countFollowers = 0;
  }
}

export interface IKnokStartvalues {
  entryFrom: number;
  entryTo: number;
  exitFrom: number;
  exitTo: number;
  stopLoss: number;
  precision: number;
}

export interface IKnokFullData {
  knoker: IKnoker;
  knok: IKnok;
  status: IFeedStatus;
  chartData: Array<{x: Date, y: number}>;
}

export interface IOngoingKnok {
    knokId: number;
    currency1: string;
    currency2: string;
    currency: string;
    marketDisplayName: string;
    exchangeId: number;
    exchangeName: string;
    createDate: Date;
    duration: number;
    entryPriceFrom: number;
    entryPriceTo: number;
    exitPriceFrom: number;
    exitPriceTo: number;
    stopLoss: number;
    currentPrice: number;
    // currentPricePercent: number;
    currentProfit: number;
    potentialProfit: number;
    chartData: Array<{x: Date, y: number}>;
    precision?: number;
    userReview?: number;
    userReviewMax?: number;
    endedStatus?: KnokEndedStatus;
    pricePool?: number;
    feedbackExists: boolean;
    minutesLeftOnFeed: number;
}

export interface IFeedKnok {
    knokId: number;
    currency1: string;
    currency2: string;
    currency: string;
    marketDisplayName: string;
    exchangeId: number;
    potentialProfitValue: number;
    potentialProfit: number;
    hasTechnical: boolean;
    hasFundamental: boolean;
    publishedDate: Date;
    createDate: Date;
    finishTime: Date;
    price: number;
    dollarPrice: number;
    entryPriceTouched: boolean;
    exchangeName: string;
    isBought: boolean;
    minutesLeftOnFeed: number;
}

export interface IFeedStatus {
    userActiveKnoks: number;
    purchases: number;
}

export interface IKnokFeedData {
    knoker: IFeedUser;
    knok: IFeedKnok;
    status: IFeedStatus;
}

export interface IOngoingStatus {
    userActiveKnoks: number;
    purchases: number;
}

export interface IKnokOngoingData {
    knokser: IKnokser;
    knok: IOngoingKnok;
    status: IOngoingStatus;
    chartData: Array<{x: Date, y: number}>;
}

export interface  IKnokFeedDataList {
    items: IKnokFeedData[];
}

export interface  IKnokOngoingDataList {
    items: IKnokOngoingData[];
}

export interface  IKnokEndedDataList {
    items: IKnokEndedData[];
}

export interface IKnokEndedData {
    knokser: IKnokser;
    knok: IEndedKnok;
    status: IOngoingStatus;
    chartData: Array<{x: Date, y: number}>;
}

export interface IEndedKnok {
    knokId: number;
    currency1: string;
    currency2: string;
    currency: string;
    marketDisplayName: string;
    exchangeId: number;
    exchangeName: string;
    createDate: Date;
    closeDate: Date;
    duration: number;
    entryPriceFrom: number;
    entryPriceTo: number;
    exitPriceFrom: number;
    exitPriceTo: number;
    stopLoss: number;
    currentPrice: number;
    // currentPricePercent: number;
    currentProfit: number;
    potentialProfit: number;
    chartData: Array<{x: Date, y: number}>;
    precision?: number;
    userReview?: number;
    userReviewMax?: number;
    endedStatus?: KnokEndedStatus;
    distanceFromTarget?: number;
    feedbackExists: boolean;
}

export interface IKnok {
  knokId: number;
  currency1: string;
  currency2: string;
  exchangeId: number;
  exchangeName?: string;
  tickerId: number;
  entryPriceFrom: number;
  entryPriceTo: number;
  exitPriceFrom: number;
  exitPriceTo: number;
  stopLoss: number;
  duration: number;
  potentialProfit: number;
  potentialProfitValue?: number;
  currentPrice: number;
  currentProfitPercent: number;
  hasTechnical: boolean;
  hasFundamental: boolean;
  buyDate?: Date;
  createDate?: Date;
  publishedDate?: Date | string;
  technical: IKnokAnalysis;
  fundamental: IKnokAnalysis;
  precision: number;
  ratesGranularityHours: number;
  endedStatus: number;
  pricePool: number;
  userReview: number;
  userReviewClarity: number;
  userReviewUsefulness: number;
  userReviewProfitability: number;
  purchases: number;
  buyerReviews: number;
  minutesLeftOnFeed: number;
}

export class Knok implements IKnok {
    knokId: number;
    currency1: string;
    currency2: string;
    exchangeId: number;
    exchangeName?: string;
    tickerId: number;
    entryPriceFrom: number;
    entryPriceTo: number;
    exitPriceFrom: number;
    exitPriceTo: number;
    stopLoss: number;
    duration: number;
    currentPrice: number;
    currentProfitPercent: number;
    potentialProfit: number;
    hasTechnical: boolean;
    hasFundamental: boolean;
    createDate?: Date;
    technical: IKnokAnalysis;
    fundamental: IKnokAnalysis;
    precision: number;
    ratesGranularityHours: number;
    endedStatus: number;
    pricePool: number;
    userReview: number;
    userReviewClarity: number;
    userReviewUsefulness: number;
    userReviewProfitability: number;
    purchases: number;
    buyerReviews: number;
    minutesLeftOnFeed: number;

    constructor() {
        // this.knokId = -1;
        this.currency1 = '';
        this.currency2 = '';
        this.exchangeId = -1;
        this.exchangeName = '';
        // this.tickerId: number;
        this.endedStatus = 0;
        this.entryPriceFrom = 0;
        this.entryPriceTo = 0;
        this.exitPriceFrom = 0;
        this.exitPriceTo = 0;
        this.stopLoss = 0;
        this.duration = 0;
        this.ratesGranularityHours = 1;
        this.currentPrice = 0;
        this.currentProfitPercent = 0;
        this.precision = 8;
        this.hasTechnical = false;
        this.hasFundamental = false;
        this.technical = {
            analysisId: null,
            header: '',
            description: '',
            image: { url: '',
                fileName: '',
                contentType: '',
                content: null
            },
            references: null,
            tags: []
        };
        this.fundamental = {
            analysisId: null,
            header: '',
            description: '',
            image: null,
            references: '',
            tags: []
        };
    }
}

export interface IPurchaseKnok {
    value: boolean;
}

export interface IReference {
    header: string;
    description: string;
    url: string;
    image: string;
    publishedBy: string;
    published: Date;
}

export interface IReferenceArg {
    url: string;
}

export interface IKnokRate {
    potentialProfit: number;
    potentialProfitValue: number;
    entry: number;
    exit: number;
    // entryToExit: number;
    entryToSL: number;
    duration: number;
    total: number;
    price: number;
    priceUSD: number;
}

export interface IKnokRaiting {
    id: number;
    name: string;
    count?: number;
}

export interface IKnokSort {
  id: number;
  name: string;
}

export interface IKnokLosing {
  id: number;
  name: string;
  count?: number;
}

export enum KnokEndedStatus {
  Unknown = 0,
  ExitProceMissed = 1,
  StopLossReached = 2,
  ClosedByKnokser = 3,
  Succeessful = 4
}

export interface IOngoingKnokFeedback {
  knokId: number;
  comment: string;
  clear?: number;
  educational?: number;
  comprehensive?: number;
}

export interface IEndedKnokFeedback {
  knokId: number;
  comment: string;
  KnokBenefit?: number;
}
