import Break from './break';

export interface IContent {
  url: string;
  position: number;
  contentType: string;
  breaks: Break[];
  addBreak(value: Break): any;
}

export class Content implements IContent {
  private _url: string;
  private _position: number;
  private _contentType: string;
  private _breaks: Break[];
  private _currentPosition: number;
  private _trackingData: any;
  private _manualScheduling: boolean;

  
({url = '', position = 0, contentType = '', breaks = [], trackingData = null, manualScheduling = false}: {
    url: string,
    position: number,
    contentType: string,
    breaks: Break[],
    trackingData: any,
    manualScheduling: boolean
  } = {
    url: '',
    position: 0,
    contentType: '',
    breaks: [],
    trackingData: null,
    manualScheduling: false
  }) {
    this.url = url;
    this.position = position;
    this.contentType = contentType;
    this.breaks = breaks;
    this.currentPosition = position;
    this.trackingData = trackingData;
    this.manualScheduling = manualScheduling;
    }

  get manualScheduling(): boolean {
    return this._manualScheduling;
  }

  set manualScheduling(value: boolean) {
    this._manualScheduling = value;
  }

  get url(): string {
    return this._url;
  }

  set url(value: string) {
    this._url = value;
  }

  public addBreak(value: Break): any {
    this.breaks.push(value);
  }

  get position(): number {
    return this._position;
  }

  set position(value: number) {
    this._position = value;
  }

  get contentType(): string {
    return this._contentType;
  }

  set contentType(value: string) {
    this._contentType = value;
  }

  get breaks(): Break[] {
    return this._breaks;
  }

  set breaks(value: Break[]) {
    this._breaks = value;
  }

  get currentPosition(): number {
    return this._currentPosition;
  }

  set currentPosition(value: number) {
    this._currentPosition = value;
  }

  get trackingData(): any {
    return this._trackingData;
  }

  set trackingData(value: any) {
    this._trackingData = value;
  }

  public getBreakIndexById(id: string): number {
    for (let i = 0; i < this.breaks.length; i++) {
      if (this.breaks[i].id === id) {
        return i;
      }
    }
    return -1;
  }
}

export default Content;

constructor