import {
  Component,
  OnInit,
  AfterViewInit,
  OnDestroy,
  inject,
  PLATFORM_ID
} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { RouterLink } from '@angular/router';
import { SeoService } from '../../services/seo.service';
import { ScrollAnimationService } from '../../services/scroll-animation.service';
import { AdSlotComponent } from '../../components/ad-slot/ad-slot.component';

@Component({
  selector: 'app-philosophy',
  standalone: true,
  imports: [
    RouterLink,
    AdSlotComponent,
    TranslateModule
  ],
  templateUrl: './philosophy.component.html'
})
export class PhilosophyComponent implements OnInit, AfterViewInit, OnDestroy {
  private readonly seoService = inject(SeoService);
  private readonly scrollAnimation = inject(ScrollAnimationService);
  private readonly platformId = inject(PLATFORM_ID);

  ngOnInit(): void {
    this.seoService.updateFromTranslations('pages.philosophy.seo', {
      url: 'https://toju.app/philosophy'
    });
  }

  ngAfterViewInit(): void {
    if (isPlatformBrowser(this.platformId)) {
      setTimeout(() => this.scrollAnimation.init(), 100);
    }
  }

  ngOnDestroy(): void {
    this.scrollAnimation.destroy();
  }
}
