(function () {
if (window.__JB_PUB_DOWNLOAD_HOTFIX_APPLIED__) return;
window.__JB_PUB_DOWNLOAD_HOTFIX_APPLIED__ = true;
const el = document.querySelector('jb-publication-download');
if (!el) return;
function formHasMarketingField(form) {
return !!form.querySelector('[name="tx_newsletter[marketing]"]');
}
function applyFix() {
const Proto = customElements.get('jb-publication-download')?.prototype;
if (!Proto || typeof Proto._subscribe !== 'function') return;
const originalSubscribe = Proto._subscribe;
Proto._subscribe = function (e) {
const form = this.shadowRoot?.querySelector('jb-form');
if (!form || !formHasMarketingField(form)) return originalSubscribe.call(this, e);
const result = originalSubscribe.call(this, e);
try {
const inputs = form.querySelectorAll('jb-text-field, jb-checkbox');
const extraInputs = form.shadowRoot?.querySelectorAll('input') || [];
const formData = {};
[...inputs, ...extraInputs].forEach((el) => {
const name = el.getAttribute('name');
if (!name) return;
if (el.tagName === 'JB-CHECKBOX') {
formData[name] = el.checkbox?.checked ? '1' : '';
} else {
formData[name] = el.value;
}
});
this._firstPartyDataProcessing = !!formData[this.agreementFieldName];
} catch (err) {}
return result;
};
}
if (!customElements.get('jb-publication-download')) {
customElements.whenDefined('jb-publication-download').then(applyFix);
} else {
applyFix();
}
})();