{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template core_message/message_drawer_view_conversation_body_message

    This template will render a single message for the body of the conversation page
    in the message drawer.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * All data attributes are required

    Context variables required for this template:
    * userid The logged in user id
    * urls The URLs for the popover

    Example context (json):
    {}

}}
<div
    class="message clickable d-flex flex-column position-relative {{#fromloggedinuser}}send {{/fromloggedinuser}}{{^fromloggedinuser}}received{{/fromloggedinuser}} my-3"
    data-region="message"
    data-message-id="{{id}}"
    role="checkbox"
    aria-checked="false"
    tabindex="0"
>
    <div class="tail position-absolute"></div>
    <div class="d-flex align-items-center {{^fromloggedinuser}}pb-2{{/fromloggedinuser}}">
        {{^fromloggedinuser}}
        <div style="flex-shrink: 0">
            <img
                class="rounded mr-2"
                src="{{{userfrom.profileimageurl}}}"
                alt="{{userfrom.fullname}}"
                aria-hidden="true"
                style="height: 30px"
            >
        </div>
        <div class="text-truncate">
            <h5 class="text-truncate m-0 font-weight-bold">{{userfrom.fullname}}</h5>
        </div>
        {{/fromloggedinuser}}

        <div
            class="rui-last-message-date ml-auto mr-0 align-items-center text-right time {{^formattedtime}}hidden{{/formattedtime}}"
            style="flex-shrink: 0"
            data-region="time-created"
        >
            <span class="rui-last-message-date-icon">
                <svg width="14" height="14" fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="12" r="7.25" stroke="currentColor" stroke-width="2"></circle>
                    <path stroke="currentColor" stroke-width="2" d="M12 8V12L14 14"></path>
                </svg>
            </span>
            <span class="rui-last-message-date-text">
                {{formattedtime}}
            </span>
        </div>
        <div
            class="ml-1 {{#formattedtime}}hidden{{/formattedtime}}"
            {{#formattedtime}}aria-hidden="true"{{/formattedtime}}
            {{^formattedtime}}aria-hidden="false"{{/formattedtime}}
            data-region="loading-icon-container"
        >
            {{> core/loading }}
        </div>
        <div role="alert" class="text-danger hidden small" aria-hidden="true" data-region="error-message-container">
            <div class="d-flex align-items-center">
                <svg width="24" height="24" fill="none" viewBox="0 0 24 24">
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4.9522 16.3536L10.2152 5.85658C10.9531 4.38481 13.0539 4.3852 13.7913 5.85723L19.0495 16.3543C19.7156 17.6841 18.7487 19.25 17.2613 19.25H6.74007C5.25234 19.25 4.2854 17.6835 4.9522 16.3536Z"></path>
                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10V12"></path>
                    <circle cx="12" cy="16" r="1" fill="currentColor"></circle>
                </svg>
                <span class="ml-1" data-region="error-message"></span>
            </div>
        </div>
        <button
            class="ml-auto btn btn-sm btn-danger hidden"
            aria-hidden="true"
            data-region="retry-send"
            title="{{#str}} retry, core {{/str}}"
        >
            <svg class="mr-2" width="14" height="14" fill="none" viewBox="0 0 24 24">
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.25 4.75L8.75 7L11.25 9.25"></path>
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12.75 19.25L15.25 17L12.75 14.75"></path>
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 7H13.25C16.5637 7 19.25 9.68629 19.25 13V13.25"></path>
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.25 17H10.75C7.43629 17 4.75 14.3137 4.75 11V10.75"></path>
            </svg>
            <span>{{#str}} retry, core {{/str}}</span>
        </button>
        <span class="hidden ml-2 small" data-region="not-selected-icon">{{#pix}} i/uncheckedcircle, core {{/pix}}</span>
        <span class="hidden ml-2 small" data-region="selected-icon">{{#pix}} i/checkedcircle, core {{/pix}}</span>
    </div>
    <div class="rui-message-text" dir="auto" align="initial" data-region="text-container">{{{text}}}</div>
</div>
