{%- macro render_fragment(fragment) -%}
{%- if fragment.path -%}
<autoref identifier="{{ fragment.path }}">{{ fragment.text }}</autoref>
{%- else -%}
{{- fragment -}}
{%- endif -%}
{%- endmacro -%}

{%- macro render_fragments(fragments) -%}
{%- if fragments is iterable and not fragments is string and fragments.path is not defined -%}
{%- for fragment in fragments -%}
{{- render_fragment(fragment) -}}
{%- endfor -%}
{%- else -%}
{{- render_fragment(fragments) -}}
{%- endif -%}
{%- endmacro -%}

{%- macro show_wikidata(obj) -%}
{%- if obj.extra.mkdocstrings.isqx and obj.extra.mkdocstrings.isqx.wikidata -%}
<div class="isqx-wikidata">
    <b>Wikidata: </b>
    {%- for wd in obj.extra.mkdocstrings.isqx.wikidata -%}
    <a href="https://www.wikidata.org/wiki/{{ wd.qcode }}" target="_blank" rel="noopener">{{ wd.qcode }}</a>
    {%- if not loop.last %}, {% endif -%}
    {%- endfor -%}
</div>
{%- endif -%}
{%- endmacro -%}

{%- macro show_symbols(obj) -%}
{%- if obj.extra.mkdocstrings.isqx and obj.extra.mkdocstrings.isqx.symbols -%}
<div class="isqx-symbols">
    <b>Symbol{% if obj.extra.mkdocstrings.isqx.symbols|length > 1 %}s{% endif %}: </b>
    {%- for symbol in obj.extra.mkdocstrings.isqx.symbols -%}
    <span class="isqx-symbol">${{ symbol.katex }}$</span>
    {%- if symbol.where -%}
    <span class="isqx-symbol-where">
        ({%- for w in symbol.where -%}
        $ {{w.symbol}} $ = {{ render_fragments(w.description) }}
        {%- if w.unit %} ({{ render_fragments(w.unit) }}){% endif -%}
        {%- if not loop.last %}, {%- endif -%}
        {%- endfor -%})
    </span>
    {%- endif -%}
    {%- if symbol.remarks -%}
    <span class="isqx-symbol-remarks"> ({{ symbol.remarks }})</span>
    {%- endif -%}
    {%- if not loop.last %}, {% endif -%}
    {%- endfor -%}
</div>
{%- endif -%}
{%- endmacro -%}



{%- macro show_details(obj) -%}
{%- if obj.extra.mkdocstrings.isqx and obj.extra.mkdocstrings.isqx.details -%}
{%- for definition in obj.extra.mkdocstrings.isqx.details -%}
<div class="isqx-detail">
    {%- if definition.assumptions -%}<b>Assumptions: </b>
    {%- for assumption in definition.assumptions -%}
    {{ render_fragments(assumption) }}
    {%- if not loop.last %}, {% endif %}
    {%- endfor -%}
    {%- endif -%}
    $${{ definition.katex }}$$
    <div class="isqx-where">
        {%- for w in definition.where -%}
        <div class="isqx-where-row">
            <div class="isqx-symbol">$ {{w.symbol}} $</div>
            <div class="isqx-equals">=</div>
            <div class="isqx-description">
                {{ render_fragments(w.description) }}
                {%- if w.unit %} ({{ render_fragments(w.unit) }}){% endif -%}
            </div>
        </div>
        {%- endfor -%}
    </div>
</div>
{%- endfor -%}
{%- endif -%}
{%- endmacro -%}