<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Adminhtml_Block_Notification_Window $this */
?>
<?php if ($this->canShow()): ?>
<script type="text/javascript">
    let messagePopupClosed = false;
    function openMessagePopup() {
        const height = document.documentElement.scrollHeight;
        const mask = document.getElementById('message-popup-window-mask');
        mask.style.height = `${height}px`;
        mask.style.display = 'block';
        document.getElementById('message-popup-window').classList.add('show');
    }

    function closeMessagePopup() {
        document.getElementById('message-popup-window-mask').style.display = 'none';
        document.getElementById('message-popup-window').classList.remove('show');
        messagePopupClosed = true;
    }

    window.addEventListener('load', openMessagePopup);
    window.addEventListener('keyup', (event) => {
        if (messagePopupClosed) return;
        if (event.key === 'Escape') {
            closeMessagePopup();
        }
    });
</script>
<div id="message-popup-window-mask" style="display:none;"></div>
<div id="message-popup-window" class="message-popup">
    <div class="message-popup-head">
        <a href="#" onclick="closeMessagePopup(); return false;" title="<?= $this->getCloseText() ?>"><span><?= $this->getCloseText() ?></span></a>
        <h2><?= $this->getHeaderText() ?></h2>
    </div>
    <div class="message-popup-content">
        <div class="message">
            <span class="message-icon message-<?= $this->getSeverityText() ?>">
                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>
                <br />
                <?= $this->getSeverityText() ?>
            </span>
            <p class="message-text"><?= $this->getNoticeMessageText() ?></p>
        </div>
        <p class="read-more"><a href="<?= $this->getNoticeMessageUrl() ?>" onclick="this.target='_blank';"><?= $this->getReadDetailsText() ?></a></p>
    </div>
</div>
<?php endif ?>
