import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { Info, TranslationEventJson } from '@ucap-webmessenger/protocol-event';

@Component({
  selector: 'ucap-chat-message-box-translation',
  templateUrl: './translation.component.html',
  styleUrls: ['./translation.component.scss']
})
export class TranslationComponent implements OnInit {
  @Input()
  message: Info<TranslationEventJson>;

  @Input()
  translationSimpleview: boolean;

  @Input()
  isMe: boolean;

  @Output()
  contextMenu = new EventEmitter<{
    event: MouseEvent;
    type: string;
  }>();

  stickerUrl?: string;

  constructor() {}

  ngOnInit() {
    if (
      !!this.message.sentMessageJson &&
      !!this.message.sentMessageJson.stickerfile &&
      this.message.sentMessageJson.stickerfile.trim().length > 0
    ) {
      this.stickerUrl = `assets/sticker/sticker_s_${this.message.sentMessageJson.stickerfile}.png`;
    }
  }

  onContextMenuMessage(event: MouseEvent, type: string) {
    this.contextMenu.emit({ event, type });
  }
}
