import * as O from 'fp-ts/Option';
import { assertSome } from '../../../../../utils';
export class AccountBenefitWithIdDto {
  static toCustomBenefitsListEntry(dto) {
    return {
      id: dto.benefitId,
      title: dto.benefit.title,
      category: dto.benefit.category,
      lastModifiedDate: O.some(dto.metadata.updatedAt),
      visibility: dto.visibility
    };
  }
  static toBenefit(dto) {
    const firstAttachment = dto.benefit.attachments !== null && dto.benefit.attachments.length > 0
      ? O.some(dto.benefit.attachments[0])
      : O.none;
    return {
      id: assertSome(dto.benefitId),
      title: assertSome(dto.benefit.title),
      subtitle: assertSome(dto.benefit.subtitle),
      category: assertSome(dto.benefit.category),
      description: O.fromNullable(dto.benefit.description),
      url: O.fromNullable(dto.benefit.url),
      attachment: firstAttachment,
      icon: O.fromNullable(dto.benefit.icon)
    };
  }
}
export class ManageBenefitsPageStateDto {
  static toDomain(dto) {
    return {
      enabledBenefits: dto.activeAccountBenefits.map(AccountBenefitWithIdDto.toCustomBenefitsListEntry),
      disabledBenefits: dto.inactiveAccountBenefits.map(AccountBenefitWithIdDto.toCustomBenefitsListEntry)
    };
  }
}
