import {Component, inject} from '@angular/core';
import {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';
import {MatTooltipModule} from '@angular/material/tooltip';

@Component({
  selector: 'app-frames',
  imports: [
    MatCard,
    MatCardContent,
    MatCardHeader,
    MatCardTitle,
    MatIcon,
    MatIconButton,
    MatTab,
    MatTabGroup,
    MatTooltipModule,
  ],
  templateUrl: './frames.component.html',
  styleUrl: './frames.component.scss'
})
export class FramesComponent {
  private particleManagerService = inject(ParticleManagerService);
  private frameManagerService = inject(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);
  }
}
