from django import template

register = template.Library()


@register.inclusion_tag('apps/tooltips/_tooltip.html')
def tooltip(data):
    """Render the unified tooltip partial from a data dict.

    Minimum required key: 'title'.
    All other keys are optional; missing keys render nothing.
    extras (dict) may contain: dignities, aspects, keywords_up,
    keywords_rev, cautions, nav.
    """
    extras = data.get('extras', {}) or {}
    return {
        'title':       data.get('title', ''),
        'type_label':  data.get('type_label', ''),
        'symbol':      data.get('symbol', ''),
        'degree_str':  data.get('degree_str', ''),
        'description': data.get('description', ''),
        'shoptalk':    data.get('shoptalk', ''),
        'expiry':      data.get('expiry', ''),
        'effect':      data.get('effect', ''),
        'dignities':   extras.get('dignities'),
        'aspects':     extras.get('aspects'),
        'keywords_up': extras.get('keywords_up'),
        'keywords_rev':extras.get('keywords_rev'),
        'cautions':    extras.get('cautions'),
        'nav':         extras.get('nav'),
        'equippable':  data.get('equippable'),
    }
