(function () {
  document.addEventListener('change', function (event) {
    var select = event.target.closest('[name="embed_mode"]');
    if (!select) return;
    var form = select.closest('form');
    if (!form) return;
    var cta = form.querySelector('[name="cta_label"]');
    if (cta && cta.closest('.sg-field')) cta.closest('.sg-field').hidden = select.value !== 'cta-modal';
  });
})();
