<template>

<div :style="pointStyle" class="event-dot">

  <div v-if="EVENT_TYPES[point.eventType]" class="chip">
    <div class="text">{{ EVENT_TYPES[point.eventType].name || '' }}</div>
    <div :class="['type-icon', `type-${point.eventType}`]"></div>
  </div>
  
  <img :src="EVENT_DOT" />

</div>

</template>

<script lang='ts' setup>

import { defineProps, computed } from 'vue'
import { EVENT_TYPES } from '@/config/dict'
import EVENT_DOT from '@/assets/images/event/event.png'

const props = defineProps<{
  point: any,
  direction: number
}>()

const pointStyle = computed(() => {

  const temp = {
    top: props.point.y + 'px',
    transform: props.point.transform
  }

  temp[props.direction ? 'left' : 'right'] = props.point.x + 'px'

  return temp

})


</script>

<style lang='scss' scoped>

$base-event: '@/assets/images/event/';

.event-dot {
  width: 90px;
  height: 90px;
  position: absolute;
  z-index: 3;
  cursor: pointer;

  img {
    display: block;
    width: 100%;
    height: 100%;
  }
  .chip {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation-name: wave;
    animation-duration: 1.85s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;

    .text {
      font-size: 12px;
      background: #772727;
      border: 1px solid rgba(238, 89, 97, 0.8);
      padding: 2px 4px;
      border-radius: 2px;
      white-space: nowrap;
      color: white;
      margin-bottom: 4px;
    }

    .type-icon {
      width: 24px;
      height: 24px;
    }

    .type-0,
    .type-1,
    .type-2,
    .type-3,
    .type-4,
    .type-8 {
      background: url($base-event + 'event_01.png') no-repeat;
      background-size: cover;
    }
  }
  
  
  
}

@keyframes wave {
  0% {
    transform: translate(-50%, 0px);
  }
  25% {
    transform: translate(-50%, 5px);
  }
  50% {
    transform: translate(-50%, 0px);
  }
  75% {
    transform: translate(-50%, 5px);
  }
  100% {
    transform: translate(-50%, 0px);
  }
}

</style>