package tv.pluto.mongo.entities.episodes;

import com.google.gson.annotations.JsonAdapter;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.BsonType;
import org.bson.codecs.pojo.annotations.BsonRepresentation;
import org.bson.types.ObjectId;
import tv.pluto.mongo.entities.common.EpisodesQueue;
import tv.pluto.mongo.entities.common.Image;
import tv.pluto.mongo.entities.common.PrivateChannel;
import tv.pluto.mongo.entities.common.RegionFilter;
import tv.pluto.mongo.entities.common.ScheduledPublishing;
import tv.pluto.mongo.utils.json.LocalDateTimeAdapter;
import tv.pluto.mongo.utils.json.ObjectIdAdapter;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Channel {
  @BsonRepresentation(BsonType.OBJECT_ID)
  private String id;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime createdAt;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime updatedAt;

  private String name = "";

  @JsonAdapter(ObjectIdAdapter.class)
  private ObjectId author;

  @JsonAdapter(ObjectIdAdapter.class)
  private ObjectId parent;

  private String hash = "";
  private Integer number;
  private Integer cohortMask;
  private Integer accessCode;
  private Boolean published;
  private String description = "";
  private String category = "";
  private List<Category> categories = Collections.emptyList();
  private Boolean autoSchedule;
  private Integer autoScheduleDays;
  private String summary = "";
  private List<String> tags = Collections.emptyList();
  private List<String> geoTargets = Collections.emptyList();
  private Boolean kidsMode;
  private Integer featured;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime created;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime updated;

  private String visibility = "";
  private Image thumbnail = new Image();
  private Image featuredImage = new Image();
  private Image partnerLogo = new Image();
  private Image logo = new Image();
  private Image tile = new Image();
  private Image tileGrayscale = new Image();
  private Image browse = new Image();
  private Image background = new Image();
  private String notes = "";
  private String type = "";

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime start;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime stop;

  private Integer redirect;
  private Boolean onDemand;
  private String onDemandDescription = "";
  private Boolean archived;
  private String slug = "";
  private RegionFilter regionFilter = new RegionFilter();
  private List<Integer> dmaDistribution = Collections.emptyList();
  private RegionFilter distribution = new RegionFilter();
  private List<EpisodesQueue> episodesQueue = Collections.emptyList();
  private List<String> overlays = Collections.emptyList();
  private Boolean directOnly;
  private Boolean liveBroadcast;
  private Boolean hasSubClips;
  private Boolean is_stitched;
  private Boolean renderInterstitials;
  private Boolean plutoOfficeOnly;
  private PrivateChannel privateChannel = new PrivateChannel();
  private ScheduledPublishing scheduledPublishing = new ScheduledPublishing();
  private Image solidLogoPNG = new Image();
  private Image colorLogoPNG = new Image();
  private Image solidLogoSVG = new Image();
  private Image colorLogoSVG = new Image();
  private List<String> supportedChannelCaptionLanguages = Collections.emptyList();
  private String tmsid = "";
  private String activeRegion = "";
  private Integer categoryMask;
  private String metadataLanguage = "";
  private List<String> seoAliases = Collections.emptyList();

  public Integer getAccessCode() {
    return accessCode == null ? 0 : accessCode;
  }

  public Integer getAutoScheduleDays() {
    return autoScheduleDays == null ? 0 : autoScheduleDays;
  }

  public Integer getRedirect() {
    return redirect == null ? 0 : redirect;
  }

  public Integer getNumber() {
    return number == null ? 0 : number;
  }

  public Integer getCohortMask() {
    return cohortMask == null ? 0 : cohortMask;
  }

  public Integer getFeatured() {
    return featured == null ? 0 : featured;
  }

  public Integer getCategoryMask() {
    return categoryMask == null ? 0 : categoryMask;
  }

  public Boolean getPublished() {
    return published != null && published;
  }

  public Boolean getAutoSchedule() {
    return autoSchedule != null && autoSchedule;
  }

  public Boolean getKidsMode() {
    return kidsMode != null && kidsMode;
  }

  public Boolean getOnDemand() {
    return onDemand != null && onDemand;
  }

  public Boolean getArchived() {
    return archived != null && archived;
  }

  public Boolean getDirectOnly() {
    return directOnly != null && directOnly;
  }

  public Boolean getLiveBroadcast() {
    return liveBroadcast != null && liveBroadcast;
  }

  public Boolean getHasSubClips() {
    return hasSubClips != null && hasSubClips;
  }

  public Boolean isStitched() {
    return is_stitched != null && is_stitched;
  }

  public Boolean getRenderInterstitials() {
    return renderInterstitials != null && renderInterstitials;
  }

  public Boolean getPlutoOfficeOnly() {
    return plutoOfficeOnly != null && plutoOfficeOnly;
  }

  public String getName() {
    return name == null ? "" : name;
  }

  public String getHash() {
    return hash == null ? "" : hash;
  }

  public String getDescription() {
    return description == null ? "" : description;
  }

  public String getCategory() {
    return category == null ? "" : category;
  }

  public String getSummary() {
    return summary == null ? "" : summary;
  }

  public String getVisibility() {
    return visibility == null ? "" : visibility;
  }

  public String getNotes() {
    return notes == null ? "" : notes;
  }

  public String getType() {
    return type == null ? "" : type;
  }

  public String getOnDemandDescription() {
    return onDemandDescription == null ? "" : onDemandDescription;
  }

  public String getSlug() {
    return slug == null ? "" : slug;
  }

  public String getTmsid() {
    return tmsid == null ? "" : tmsid;
  }

  public String getActiveRegion() {
    return activeRegion == null ? "" : activeRegion;
  }

  public String getMetadataLanguage() {
    return metadataLanguage == null ? "" : metadataLanguage;
  }

  public Boolean getStitched() {
    return is_stitched != null && is_stitched;
  }
}
