Date range – flatpickr – disable past dates

<?php

// Add this hook to functions.php
add_action( 'wp_footer', function() {
?>
    <script>
    (function($) {
        if ( 'undefined' !== typeof FWP ) {
            wp.hooks.addFilter('facetwp/set_options/date_range', function(flatpickr_opts, extras) {
                flatpickr_opts['disable'] = function(selectedDate) {
                    var today = new Date();
                    today.setHours(0,0,0,0);
                    return (selectedDate < today); // return true to disable
                };
                return flatpickr_opts;
            });
        }
    })(jQuery);
    </script>
<?php
}, 100 );