{# Copyright 2022, Red Hat, Inc. #}
{# SPDX-License-Identifier: LGPL-2.1-or-later #}
<div class="pf-c-expandable-section__content">
    <table class="pf-c-table pf-m-compact pf-m-grid-md" role="grid">
        <thead>
            <tr role="row"><td role="cell" colspan="2"></td></tr>
        </thead>
        <tbody role="rowgroup">
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Rule ID:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                        <div class="pf-c-clipboard-copy pf-m-inline">
                            <span class="pf-c-clipboard-copy__text">{{ rule.rule_id }}</span>
                            <span class="pf-c-clipboard-copy__actions">
                                <span class="pf-c-clipboard-copy__actions-item">
                                    <button id="copy" class="pf-c-button pf-m-plain" type="button" aria-label="Copy to clipboard">
                                        <i class="fas fa-copy" aria-hidden="true"></i>
                                    </button>
                                </span>
                            </span>
                        </div>
                    </p></div></div>
                </td>
            </tr>
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Result:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                    {% if rule.result in ("pass", "fixed") %}
                    <span class="pf-c-label pf-m-green">
                        <span class="pf-c-label__content">
                            <span class="pf-c-label__icon">
                                <i class="fas fa-fw fa-check" aria-hidden="true"></i>
                            </span>
                            {{ rule.result -}}
                        </span>
                    </span>
                    {% elif rule.result in ("fail", "error", "fix unsuccessful", "fix failed") %}
                    <span class="pf-c-label pf-m-red">
                        <span class="pf-c-label__content">
                            <span class="pf-c-label__icon">
                                <i class="fas fa-fw fa-times" aria-hidden="true"></i>
                            </span>
                            {{- rule.result -}}
                        </span>
                    </span>
                    {% else %}
                    <span class="pf-c-label">
                        <span class="pf-c-label__content">
                            <span class="pf-c-label__icon">
                                <i class="fas fa-fw fa-question-circle" aria-hidden="true"></i>
                            </span>
                        {{- rule.result -}}
                        </span>
                    </span>
                    {% endif %}
                    </p>
                    </div></div>
                </td>
            </tr>
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><b>Time:</b></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">{{ rule.time }}</p>
                    </div></div>
                </td>
            </tr>
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><b>Description:</b></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <div class="text_block pf-c-table__text">{{- rule.description | set_css_for_list -}}</div></div></div>
                </td>
            </tr>
            {% if rule.rationale %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><b>Rationale:</b></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">{{- rule.rationale | set_css_for_list -}}</p></div></div>
                </td>
            </tr>
            {% endif %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Severity:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                    {% if rule.result != "pass" and rule.severity == "low" %}
                    <span class="pf-c-label pf-m-blue">
                        <span class="pf-c-label__content">{{ rule.severity }}</span>
                    </span>
                    {% elif rule.result != "pass" and rule.severity == "medium" %}
                    <span class="pf-c-label pf-m-orange">
                        <span class="pf-c-label__content">{{ rule.severity }}</span>
                    </span>
                    {% elif rule.result != "pass" and rule.severity == "high" %}
                    <span class="pf-c-label pf-m-red">
                        <span class="pf-c-label__content">{{ rule.severity }}</span>
                    </span>
                    {% else %}
                    <span class="pf-c-label">
                        <span class="pf-c-label__content">{{ rule.severity }}</span>
                    </span>
                    {% endif %}
                    </p>
                    </div></div>
                </td>
            </tr>
            {% if rule.identifiers %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Identifiers:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                    <div>
                        {%- for identifier in rule.identifiers -%}
                        {%- if identifier.href -%}
                            <a href="{{ identifier.href | replace('&', ';') }}">{{ identifier.text }}</a>
                        {%- else -%}
                            <span>{{ identifier.text }}</span>
                        {%- endif -%}
                        {{- ", " if not loop.last else "" -}}
                        {%- endfor %}
                    </div>
                    </p>
                    </div></div>
                </td>
            </tr>
            {% endif %}
            {% if rule.references %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>References:</b></p></th>
                <td role="cell">
                    <table class="pf-c-table pf-m-grid-md" role="grid">
                        {%- for reference in rule.references -%}
                            <tr>
                                <td>
                                    {% if reference.href == "UNKNOWN" %}
                                        Unknown:
                                    {% else %}
                                        <a href="{{ reference.href | replace('&', ';') }}">{{ reference.name }}</a>:
                                    {% endif %}
                                </td>
                                <td>
                                    {%- for ref_id in reference.ref_ids -%}
                                    {{ ref_id }}
                                    {{- ", " if not loop.last else "" -}}
                                    {%- endfor -%}
                                </td>
                            </tr>
                        {%- endfor -%}
                    </table>
                </td>
            </tr>
            {% endif %}
            {% if rule.multi_check %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Multi-check rule:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                        <p class="pf-c-table__text">yes</p>
                    </div></div>
                </td>
            </tr>
            {% endif %}
            {% if rule.weight | string != "1.0" %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><b>Weight:</b></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
                    <p class="pf-c-table__text">{{ rule.weight }}</p>
                    </div></div>
                </td>
            </tr>
            {% endif %}
            {% if rule.warnings %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Warnings:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column">
                    {% for warning in rule.warnings %}
                    <div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                    <div class="pf-c-alert pf-m-warning pf-m-inline">
                        <div class="pf-c-alert__icon">
                            <i class="fas fa-fw fa-exclamation-triangle" aria-hidden="true"></i>
                        </div>
                        <div class="pf-c-alert__title">
                            {{- warning.category | capitalize -}}&nbsp;warning
                        </div>
                        <div class="pf-c-alert__description">
                            {{- warning.text | set_css_for_list -}}
                        </div>
                    </div>
                    <br>
                    </p>
                    </div>
                    {% endfor %}
                    </div>
                </td>
            </tr>
            {% endif %}
            {% if rule.messages %}
            <tr role="row">
                <th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Messages:</b></p></th>
                <td role="cell">
                    <div class="pf-l-flex pf-m-column">
                    {% for message in rule.messages %}
                    <div class="pf-l-flex__item">
                    <p class="pf-c-table__text">
                    <div class="pf-c-alert pf-m-info pf-m-inline">
                        <div class="pf-c-alert__icon">
                            <i class="fas fa-fw fa-info-circle" aria-hidden="true"></i>
                        </div>
                        <p class="pf-c-alert__title">
                            <span class="pf-screen-reader">Message:</span>
                            Message:
                        </p>
                        <div class="pf-c-alert__description">
                            <pre>{{- message | e -}}</pre>
                        </div>
                    </div>
                    <br>
                    </p>
                    </div>
                    {% endfor %}
                    </div>
                </td>
            </tr>
            {% endif %}
            {% include "remedations.html" %}
            {% include "oval_definition_detail.html" %}
            <tr role="row">
                <td colspan="2" role="cell">
                    {%- include "oval_graph.html" %}
                </td>
            </tr>
            {% if rule.cpe_tree -%}
                <tr role="row">
                    <th class="pf-m-fit-content" role="rowheader" scope="row"><b>CPE check:</b></th>
                </tr>
            {% endif %}
            <tr role="row">
                <td colspan="2" role="cell">
                    {%- include "cpe_graph.html" %}
                </td>
            </tr>
        </tbody>
    </table>
</div>
