<script lang="ts" setup>
import type { TreeNodeType } from '#/utils/database-tree/types';

import { DatabaseTypeIcon } from '#/components/database-type-icon';
import { getNodeIcon, getNodeIconClass } from '#/utils/database-tree/icons';

defineOptions({ name: 'DatabaseTreeNodeIcon' });

const props = withDefaults(
  defineProps<{
    dbType?: string;
    size?: number;
    type: string | TreeNodeType;
  }>(),
  {
    dbType: '',
    size: 16,
  },
);
</script>

<template>
  <DatabaseTypeIcon
    v-if="type === 'connection'"
    :db-type="dbType"
    :size="size"
  />
  <component
    v-else
    :is="getNodeIcon(type)"
    :size="size"
    :class="getNodeIconClass(type)"
  />
</template>
