<template>
  <div class="facility-location-card bg-white rounded-[24px] overflow-hidden w-full">
    <img class="facility-location-card__image block w-full" :src="data.image" mode="aspectFill" />

    <div class="facility-location-card__body px-24 pb-24">
      <div class="facility-location-card__title-row flex items-center">
        <div class="facility-location-card__badge color-2563EB bg-EFF6FF text-[12px] font-bold">
          {{ type.text }}
        </div>
        <div class="facility-location-card__title text-[#1e293b] text-[18px] font-bold truncate">
          {{ data.title }}
        </div>
      </div>

      <div class="facility-location-card__distance flex items-center text-[#94A3B8] text-[14px] font-bold">
        <span class="facility-location-card__distance-icon">{{ distance.icon }}</span>
        <span>{{ distance.text }}</span>
      </div>

      <div class="facility-location-card__location bg-[#f8fafc] rounded-[20px]">
        <div class="facility-location-card__location-label flex items-center text-[#64748B] text-[13px] font-bold">
          <span class="facility-location-card__location-dot">{{ location.icon }}</span>
          <span>{{ location.label }}</span>
        </div>
        <div class="facility-location-card__location-text text-[#1e293b] text-[16px] font-bold">
          {{ location.text }}
        </div>
      </div>

      <div
        class="facility-location-card__button flex items-center justify-center bg-0F172A text-white text-[18px] font-bold"
        :class="{ 'is-disabled': disabled }" @click="handleAction">
        <span class="facility-location-card__button-icon">{{ action.icon }}</span>
        <span>{{ action.text }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
  data: {
    type: Object,
    default: () => ({}),
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});

const emit = defineEmits(["action", "select"]);

const type = computed(() => props.data.type || {});
const distance = computed(() => props.data.distance || {});
const location = computed(() => props.data.location || {});
const action = computed(() => props.data.action || {});

const handleAction = () => {
  if (props.disabled) return;
  emit("action", props.data);
  emit("select", props.data);
};
</script>

<style scoped lang="scss">
@import "./styles/index.scss";
</style>
