class Sim {
  allImages; // array of all images
  availableImages; // array of still available images (images in the future)

  htmlContent;
  product;

  isOpen;

  clockTickObservable;
  newTimeObservable;

  showDate;

  constructor(product, showDate) {
    this.product = product;
    this.showDate = showDate;
    this.isOpen = false;
    this.allImages = [];
    this.availableImages = [];
  }

  subscribe(timerObervable, newTimeObservable) {
    const { throttleTime } = rxjs;

    this.clockTickObservable = timerObervable
      .pipe(throttleTime(1000))
      .subscribe((currentTime) => {
        this.onTick(currentTime);
      });

    this.newTimeObservable = newTimeObservable.subscribe((currentTime) => {
      this.populateImageQueue(currentTime);
    });
  }

  unsubscribe() {
    this.clockTickObservable.unsubscribe();
    this.newTimeObservable.unsubscribe();
  }

  reset() {
    this.availableImages = this.allImages;
  }

  open() {
    this.isOpen = true;
  }

  close() {
    this.isOpen = false;
  }
}
