{#
  Copyright DB InfraGO AG and contributors
  SPDX-License-Identifier: Apache-2.0
#}
{%
  from 'common_macros.html.j2' import
  description,
  display_property_label,
  linked_name_with_icon,
  render_allocated_functions,
  render_capability_section,
  render_exchange_items_catalog,
  render_involved_components_section,
  render_interfaces_section,
  show_other_attributes
%}

<h1>Definition of {{ object.name }}</h1>
{{ description(object) | safe }}

<h2>Capabilities</h2>
{% set capabilities = object.involved_capabilities %}
{{ render_capability_section(object, capabilities) | safe }}

<h2>Component Boundary</h2>
<p>
  The figure below provides an overview of <i>{{ object.name }}</i>'s boundary
  and depicts all the actors that it interacts with.
</p>
{{ render_diagram(object, "context_diagram", display_derived_interfaces=True) }}
{% set actors = object.context_diagram.nodes.by_class("LogicalComponent") -%}
{% set actors = actors - model.search(below=object) - [object] -%}
{{ render_involved_components_section(object, actors, capabilities) | safe }}

<h2>Allocated Functions</h2>
{{ render_allocated_functions(object) | safe }}

<h2>Interfaces</h2>
{% set interfaces = object.related_exchanges %}
{% set exchange_items_catalog = [] %}
{{ render_interfaces_section(object, interfaces, exchange_items_catalog) | safe }}

{% if exchange_items_catalog %}
  <h2>Appendix A: Exchange Items Catalogue</h2>
  <p>
    The following items (e.g. energy, material, information) are exchanged
    through the interactions with its interface partners.
  </p>
  {{ render_exchange_items_catalog(exchange_items_catalog) | safe }}
{% endif %}

<h2>Other Properties</h2>
{%-
  set excluded = [
    "allocated_functions",
    "context_diagram",
    "description",
    "diagrams",
    "name",
    "owner",
    "parent",
    "parts",
    "ports",
    "realizing_components",
    "related_exchanges",
    "state_machines",
    "xtype",
  ]
-%}
{{ show_other_attributes(object, excluded=excluded) | safe }}
