<script setup lang="ts">
import type { ToolbarType } from './types';

import { computed } from 'vue';

import { preferences } from '@easyflow/preferences';

import {
  AuthenticationColorToggle,
  AuthenticationLayoutToggle,
  LanguageToggle,
  ThemeToggle,
} from '../widgets';

interface Props {
  toolbarList?: ToolbarType[];
}

defineOptions({
  name: 'AuthenticationToolbar',
});

const props = withDefaults(defineProps<Props>(), {
  toolbarList: () => ['language', 'theme'],
});

const showColor = computed(() => props.toolbarList.includes('color'));
const showLayout = computed(() => props.toolbarList.includes('layout'));
const showLanguage = computed(() => props.toolbarList.includes('language'));
const showTheme = computed(() => props.toolbarList.includes('theme'));
</script>

<template>
  <div
    :class="{
      'auth-toolbar': toolbarList.length > 1,
    }"
    class="flex-center absolute right-4 top-4 z-20 sm:right-6 sm:top-6"
  >
    <div class="hidden md:flex">
      <AuthenticationColorToggle v-if="showColor" />
      <AuthenticationLayoutToggle v-if="showLayout" />
    </div>
    <LanguageToggle v-if="showLanguage && preferences.widget.languageToggle" />
    <ThemeToggle v-if="showTheme && preferences.widget.themeToggle" />
  </div>
</template>

<style scoped>
.auth-toolbar {
  padding: 0.25rem 0.58rem;
  background: rgb(255 255 255 / 72%);
  border: 1px solid rgb(255 255 255 / 78%);
  border-radius: 9999px;
  box-shadow: 0 20px 42px -30px rgb(14 55 124 / 28%);
  backdrop-filter: blur(10px);
}

:deep(.dark) .auth-toolbar {
  background: rgb(11 19 34 / 66%);
  border-color: rgb(122 167 255 / 18%);
  box-shadow: 0 20px 40px -28px rgb(0 0 0 / 46%);
}
</style>
