<?php
/** @var Map $block */
/** @var Escaper $escaper */

use Macopedia\OrlenShipping\Block\Adminhtml\Map;
use Magento\Framework\Escaper;

$token = $block->getToken();
$timestamp = time();
$widgetUrl = "https://mapa.orlenpaczka.pl/widget.js?token={$token}&v=1.0.0&t={$timestamp}";
?>
<?php if ($block->canShow()): ?>
    <script data-src="<?= $escaper->escapeHtmlAttr($widgetUrl) ?>" id="orlen-widget-script"></script>
    <div data-bind="scope: 'orlen-map'"
         data-mage-init='{
        "Magento_Ui/js/core/app": {
                "components": {
                    "orlen-map": {
                        "component": "Macopedia_OrlenShipping/js/map",
                        "saveUrl": "<?= $escaper->escapeUrl($block->getUrl('orlenshipping/point/save')); ?>",
                        "orderId": "<?= $escaper->escapeJs($block->getOrder()->getId()); ?>"
                    }
                }
            }
        }'>
    </div>
<?php endif; ?>
