export enum KycLevelEnum {
  L0 = 0,
  L1 = 1,
  L2 = 2,
  L3 = 3,
}

export class KycLevel {
  private constructor(private readonly level: KycLevelEnum) {}

  static create(level: number): KycLevel {
    if (!Number.isInteger(level) || level < 0 || level > 3) {
      throw new Error('KYC level must be an integer between 0 and 3');
    }
    return new KycLevel(level as KycLevelEnum);
  }

  static fromNumber(level: number): KycLevel {
    return new KycLevel(level as KycLevelEnum);
  }

  static L0(): KycLevel {
    return new KycLevel(KycLevelEnum.L0);
  }

  static L1(): KycLevel {
    return new KycLevel(KycLevelEnum.L1);
  }

  static L2(): KycLevel {
    return new KycLevel(KycLevelEnum.L2);
  }

  static L3(): KycLevel {
    return new KycLevel(KycLevelEnum.L3);
  }

  get value(): number {
    return this.level;
  }

  get label(): string {
    return `L${this.level}`;
  }

  isHigherThan(other: KycLevel): boolean {
    return this.level > other.level;
  }

  isLowerThan(other: KycLevel): boolean {
    return this.level < other.level;
  }

  equals(other: KycLevel): boolean {
    return this.level === other.level;
  }

  get dailyLimit(): string {
    switch (this.level) {
      case KycLevelEnum.L0:
        return '1000';
      case KycLevelEnum.L1:
        return '10000';
      case KycLevelEnum.L2:
        return '100000';
      case KycLevelEnum.L3:
        return 'unlimited';
      default:
        return '0';
    }
  }

  toString(): string {
    return this.label;
  }
}
