{# needs sdoc_entity #}

{#
  This template can be included directly, and it will in turn include an entity.
  In this case you must use it with the variable:
      {%- with sdoc_entity = requirement -%}
      {% include "components/node/index.jinja" %}
      {%- endwith -%}

  This template can also be used as a base template.
  Then the {% block sdoc_entity %} block will overwrite the included entity
  in the extending template.
#}

{% set node_type = sdoc_entity.get_type_string() %}
{% set is_not_standalone = view_object.project_config.is_running_on_server and not view_object.standalone %}
{% set is_included = sdoc_entity.document_is_included() %}
{% set node_type_string = sdoc_entity.get_node_type_string() %}

<turbo-frame
{%- if is_not_standalone %}
  id="article-{{ sdoc_entity.reserved_mid }}"
{% endif -%}
>

  <sdoc-node
    {%- if is_not_standalone %}
      data-editable_node="on"
      data-controller="anchor_controller"
    {%- endif %}
    node-role="{{ node_type }}"
    {% if sdoc_entity.is_requirement() %}
      node-view="{{ sdoc_entity.get_requirement_style_mode() }}"
    {%- endif -%}
    {%- if node_type_string is not none %}{# and node_type_string != 'TEXT' #}
      show-node-type-name="{{ node_type_string }}"
    {%- endif %}
    data-included-document="{{ is_included }}"
    data-testid="node-{{ node_type }}"
  >

    {% if view_object.should_display_stable_link(sdoc_entity) %}
      {% with path = view_object.get_stable_link(sdoc_entity) %}
        {% include "components/node/copy_stable_link_button.jinja" %}
      {% endwith %}
    {%- endif -%}

    {# anchor #}
    {% include "components/anchor/index.jinja" %}

    {#
      copy_to_clipboard must be defined before sdoc_entity block,
      and define them in node components that have editing options:
      node & root
    #}
    {%- set copy_to_clipboard = True -%}

    {# sdoc_entity #}
    {% block sdoc_entity %}
      {# FIXME: This is not reachable from anywhere right now. #}
      {% assert 0, "Must not reach here!" %}
    {% endblock sdoc_entity %}

    {# node_controls #}
    {%- if is_not_standalone -%}
    {% include "components/node/node_controls/index.jinja" %}
    {%- endif -%}

  </sdoc-node>
</turbo-frame>
