{% load static %}

{% load django_glue %}

<!-- This is required to force a csrf_token to be used -->
{% csrf_token %}

<script type="application/javascript">
    const DJANGO_GLUE_AJAX_URL = '{% url 'django_glue:django_glue_data_handler' %}'
    const DJANGO_DEBUG = {% if debug %}true{% else %}false{% endif %}
    const DJANGO_GLUE_DATA = JSON.parse('{% glue_context_data_str %}')
    const DJANGO_GLUE_KEYS = JSON.parse('{% glue_context_keys_str %}')
    const DJANGO_KEEP_LIVE_URL = '{% url 'django_glue:django_glue_keep_live_handler' %}?keep_live_path={{ request.path|urlencode }}'

    fetch(DJANGO_KEEP_LIVE_URL)

    setInterval(() => {
        fetch(DJANGO_KEEP_LIVE_URL)
    }, 30000)
</script>

<script type="module" src="{% static 'django_glue/js/django_glue.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

{% block django_glue_required_inludes %}

{% endblock %}