import {
  Component,
  computed,
  inject,
  input
} from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideGlobe } from '@ng-icons/lucide';
import { AppI18nService } from '../../../core/i18n';
import { presentSignalServerTag } from '../../../domains/server-directory/domain/logic/signal-server-tag.rules';

@Component({
  selector: 'app-profile-signal-server-tag',
  standalone: true,
  imports: [NgIcon],
  viewProviders: [provideIcons({ lucideGlobe })],
  templateUrl: './profile-signal-server-tag.component.html'
})
export class ProfileSignalServerTagComponent {
  readonly tag = input<string | undefined>();

  readonly presentation = computed(() => {
    const value = this.tag()?.trim();

    return value ? presentSignalServerTag(value) : undefined;
  });

  private readonly appI18n = inject(AppI18nService);

  registeredOnLabel(url: string): string {
    return this.appI18n.instant('profile.card.registeredOn', { url });
  }
}
