content: // Flutter imports:
  import 'package:flutter/material.dart';
  
  // Package imports:
  import 'package:flutter_riverpod/flutter_riverpod.dart';
  
  // Project imports:
  import '../../../core/configs/config.dart';
  import '../../../core/search/suggestions/widgets.dart';
  import '../../../core/tags/autocompletes/types.dart';
  import '../../../core/tags/metatag/providers.dart';
  import '../../../core/tags/tag/providers.dart';
  import '../configs/providers.dart';
  import '../users/user/providers.dart';
  
  class DanbooruTagSuggestionItem extends ConsumerWidget {
    const DanbooruTagSuggestionItem({
      required this.config,
      required this.tag,
      required this.onItemTap,
      required this.currentQuery,
      required this.dense,
      super.key,
    });
  
    final BooruConfigAuth config;
    final AutocompleteData tag;
    final ValueChanged<AutocompleteData> onItemTap;
    final String currentQuery;
    final bool dense;
  
    @override
    Widget build(BuildContext context, WidgetRef ref) {
      final metatagExtractor = ref.watch(metatagExtractorProvider(config));
      final loginDetails = ref.watch(danbooruLoginDetailsProvider(config));
  
      return TagSuggestionItem(
        key: ValueKey(tag.value),
        showCount: tag.hasCount && !loginDetails.hasStrictSFW,
        onItemTap: onItemTap,
        tag: tag,
        dense: dense,
        currentQuery: currentQuery,
        textColor: generateAutocompleteTagColor(
          ref,
          ref.context,
          tag,
          config,
        ),
        metatagExtractor: metatagExtractor,
      );
    }
  }
  
  Color? generateAutocompleteTagColor(
    WidgetRef ref,
    BuildContext context,
    AutocompleteData tag,
    BooruConfigAuth config,
  ) {
    if (tag.hasCategory) {
      return ref.watch(tagColorProvider((config, tag.category!)));
    } else if (tag.hasUserLevel) {
      return DanbooruUserColor.of(context).fromString(tag.level);
    }
  
    return null;
  }
  