WooCommerce – re-initialize a quantity input field’s minimum quantity value after FacetWP refresh

<?php

/**
 * Product quantity <input> fields for add to cart forms, 
 * generated with the woocommerce_quantity_input() function,
 * need re-initializing their minimum value (set in the 'min' attribute) after a FacetWP refresh:
 **/

add_action( 'facetwp_scripts', function() {
  ?>
  <script>
    document.addEventListener('facetwp-loaded', function() {
      jQuery(function($) {
        $('input.qty').each(function() {
          var min = parseFloat($(this).attr('min'));
          if (min >= 0 && parseFloat($(this).val()) < min) {
            $(this).val(min);
          }
        });
      });
    });
  </script>
  <?php
}, 100 );