import {Component} from '@angular/core';
import {MatButton, MatIconButton} from "@angular/material/button";
import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card";
import {MatTab, MatTabGroup} from "@angular/material/tabs";

import {ParticleData} from '../../models/particle.model';
import {MatIcon} from '@angular/material/icon';
import {ParticleManagerService} from '../../services/particle-manager.service';
import {FrameManagerService} from '../../services/frame-manager.service';

@Component({
  selector: 'app-frames',
  imports: [
    MatButton,
    MatCard,
    MatCardContent,
    MatCardHeader,
    MatCardTitle,
    MatIcon,
    MatIconButton,
    MatTab,
    MatTabGroup
],
  templateUrl: './frames.component.html',
  styleUrl: './frames.component.scss'
})
export class FramesComponent {

  constructor(
    private particleManagerService: ParticleManagerService,
    private frameManagerService: FrameManagerService) {
  }

  /**
   * Get the particle data
   */
  public get particleData(): ParticleData {
    return this.particleManagerService.getParticleData();
  }

  /**
   * Get the current frame
   */
  public get currentFrame(): string {
    return this.particleManagerService.getCurrentFrame();
  }

  /**
   * Get all frames
   */
  public get frames(): string[] {
    return this.particleManagerService.getFrames();
  }

  /**
   * Add a new frame
   */
  public addFrame(): void {
    this.frameManagerService.addFrame();
  }

  /**
   * Switch to a different frame
   */
  public switchFrame(frameId: string): void {
    this.frameManagerService.switchFrame(frameId);
  }

  /**
   * Remove a particle
   */
  public removeParticle(frameId: string, index: number): void {
    this.particleManagerService.removeParticle(frameId, index);
  }

  /**
   * Remove a frame
   */
  public removeFrame(frameId: string): void {
    this.frameManagerService.removeFrame(frameId);
  }


  public highlightParticle(frameId: string, i: number) {
    this.particleManagerService.highlightParticle(frameId, i);
  }
}
