let parentPopup = $('{{$container}}').closest('.stag-popup');
if(parentPopup.length) {
    <?php $rel = $point->relevanceToNote($note); ?>
    parentPopup.find('.toggle-relevance-ui').remove();
    let relUI = $('<div/>')
        .addClass('toggle-relevance-ui border p-2 mb-3 mr-3 mr-md-auto {{ !!$rel ? 'bg-aliceblue border-info' : 'bg-light' }}')
        .html('Relevant to visit: <b>{{ !!$rel ? 'Yes' : 'No' }}</b>');
    let toggleBtn = $('<a/>')
        .attr('href', '#')
        .addClass('ml-2')
        .text('Toggle')
        .on('click', function() {
            @if(!!$rel)
            $.post('/api/visitPoint/undoMarkPointRelevantToNote', {
                'uid': '{{$rel->uid}}'
            }, _data => {
                if(!hasResponseError(_data)) {
                    refreshDynamicStagPopup();
                    refreshSegment('omega_subjective_system');
                    refreshSegment('omega_plan_system');
                    @if(@$segmentName)
                    refreshSegment('{{$segmentName}}');
                    @endif
                }
            }, 'json');
            @else
            $.post('/api/visitPoint/markPointRelevantToNote', {
                'noteUid': '{{$note->uid}}',
                'pointUid': '{{$point->uid}}'
            }, _data => {
                if(!hasResponseError(_data)) {
                    refreshDynamicStagPopup();
                    refreshSegment('omega_subjective_system');
                    refreshSegment('omega_plan_system');
                    @if(@$segmentName)
                    refreshSegment('{{$segmentName}}');
                    @endif
                }
            }, 'json');
            @endif
            return false;
        })
        .appendTo(relUI);
    relUI.prependTo($('{{$container}}').closest('.stag-popup').find('[visit-moe]').first());
}