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-what-is-toju',
  standalone: true,
  imports: [
    RouterLink,
    AdSlotComponent,
    TranslateModule
  ],
  templateUrl: './what-is-toju.component.html'
})
export class WhatIsTojuComponent 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.whatIsToju.seo', {
      url: 'https://toju.app/what-is-toju'
    });
  }

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

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