<script lang="ts">
	// import { _ } from '../../services/i18n'
	import type { NDKEvent } from '@nostr-dev-kit/ndk';
	import Calendar from '@lucide/svelte/icons/calendar';
	import Clock from '@lucide/svelte/icons/clock';
	import MapPin from '@lucide/svelte/icons/map-pin';
	import Separator from '$lib/components/ui/separator/separator.svelte';

	export let event: NDKEvent;

	function getTagValue(tags: string[][], name: string, position: number = 0): string | null {
		const found = tags.find((v) => v[0] === name);
		if (!found) return null;
		const [, ...values] = found;
		return values[position];
	}
</script>

<div class="flex items-center">
	<Calendar class="h-4" />
	{new Date(Number(event.tagValue('start')) * 1000).toLocaleDateString('es-ES', {
		weekday: 'short',
		day: 'numeric',
		month: '2-digit',
		year: '2-digit'
	})}
</div>
<Separator orientation="vertical" />
<div class="flex items-center">
	<Clock class="h-4" />
	{new Date(Number(event.tagValue('start')) * 1000).toLocaleTimeString([], {
		hour: '2-digit',
		minute: '2-digit'
	})}-{new Date(Number(event.tagValue('end')) * 1000).toLocaleTimeString([], {
		hour: '2-digit',
		minute: '2-digit'
	})}
</div>
<Separator orientation="vertical" />
<div class="flex items-center">
	<MapPin class="h-4" />
	{#if event.tagValue('location')}
		{getTagValue(event.tags, 'location', 1)
			? getTagValue(event.tags, 'location', 1)
			: getTagValue(event.tags, 'location')}
	{/if}
</div>
