{% from "./partials/schema.html" import schema %}
{% from "./partials/tags.html" import tags %}

{% macro message(msg, showIndex=false, index=0, open=false) %}
<div class="bg-grey-lighter rounded p-4 mt-2">
  <div class="text-sm text-grey-darker mb-2">
    {% if showIndex %}
    <span class="text-grey-darker font-bold mr-2">#{{index}}</span>
    {% endif %}
    {% if msg.title() %}
      {{msg.title()}}
      <span class="border text-orange rounded text-xs ml-3 py-0 px-2">{{msg.uid()}}</span>
    {% else %}
      <span class="border text-orange rounded text-s py-0 px-2">{{msg.uid()}}</span>
    {% endif %}
  </div>

  {% if msg.summary() is not none %}
    <p class="text-grey-dark text-sm">{{msg.summary()}}</p>
  {% endif %}
  
  {% if msg.tags() is not none %}
    {{ tags(msg.tags()) }}
  {% endif %}

  {% if msg.description() is not none %}
    <div class="mt-4 mb-4 markdown">{{ msg.description() | markdown2html | safe }}</div>
  {% endif %}

  {{ schema(msg.payload(), 'Payload', open=open) }}
  {% if msg.headers() %}
    <div class="mt-4">
      {{ schema(msg.headers(), 'Headers', open=open) }}
    </div>
  {% endif %}
</div>

{% endmacro %}
