(function () {
    window.addEventListener('room:gate_update', function () {
        const wrapper = document.getElementById('id_gate_wrapper');
        if (!wrapper) return;

        fetch(wrapper.dataset.gateStatusUrl)
            .then(function (r) { return r.text(); })
            .then(function (html) {
                wrapper.outerHTML = html;
            });
    });
}());