<script lang="ts">
	import type { MediaTitle } from '$lib/AniList/media';
	import settings from '../../stores/settings';
	import * as wanakana from 'wanakana';

	export let title: MediaTitle;
</script>

{#if $settings.displayNativeTitles}
	{#if $settings.displayFurigana}
		<span title={title.english || title.romaji || title.native}>
			<ruby>
				{title.native}
				<rt>
					{wanakana.toKana(title.romaji)}
				</rt>
			</ruby>
		</span>
	{:else}
		<span title={title.english || title.romaji || title.native}>
			{title.native}
		</span>
	{/if}
{:else}
	<span title={title.native}>
		{title.english || title.romaji || title.native}
	</span>
{/if}
