1import{D as s}from"./site-TMvbJ_tI.js";class u{constructor(){window.dataLayer=window.dataLayer||[];const t=document.querySelectorAll("form[data-datalayer-event]");t.length&&t.forEach(e=>{new i(e)}),s.onDynamicContent(document.documentElement,"form[data-datalayer-event]",e=>{e.forEach(a=>{new i(a)})})}}class i{constructor(t){this.eventName="filter",this.ignoreFields=[],this.lastPushedData=null,this.form=t,this.initDatalayerEvent()}initDatalayerEvent(){const t=this.form.getAttribute("data-datalayer-event");if(t&&t.length>0){this.eventName=t;const e=this.form.getAttribute("data-datalayer-ignore");e&&e.length>0&&(this.ignoreFields=e.split(",")),this.ignoreFields=e.split(",")}this.form.addEventListener("filterFetchData",e=>{this.pushToDatalayer()})}pushToDatalayer(){const t=new FormData(this.form),e=Array.from(t),a={event:this.eventName};e.forEach(r=>{if(r[1]!=="")if(r[0].indexOf("[]")>=0){const n=this.getKeyForInput(r);if(this.ignoreFields.includes(n))return;a[n]||(a[n]=[]),a[n].push(this.getLabelForInput(r))}else{if(this.ignoreFields.includes(r[0]))return;a[r[0]]=r[1]}}),Object.keys(a).forEach(r=>{Array.isArray(a[r])&&a[r].length===0&&delete a[r]}),Object.keys(a).length>1&&JSON.stringify(this.lastPushedData)!==JSON.stringify(a)&&(window.dataLayer.push(a),this.lastPushedData=a)}getLabelForInput(t){let e=document.querySelector(`[name="${t[0]}"]`);if(e){if(e instanceof HTMLSelectElement)return e.hasAttribute("data-datalayer-value")?e.getAttribute("data-datalayer-value"):e.options[e.selectedIndex].text;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&t[1]!==""&&(e=document.querySelector(`[name="${t[0]}"][value="${t[1]}"]`)||e),e.hasAttribute("data-datalayer-value"))return e.getAttribute("data-datalayer-value");if(e.hasAttribute("id")){const a=document.querySelector(`label[for="${e.getAttribute("id")}"]`);if(a)return a.innerText}else{const a=e.closest("label");if(a)return a.innerText}}return t[0]}getKeyForInput(t){let e=document.querySelector(`[name="${t[0]}"]`);return e&&(e instanceof HTMLSelectElement||(e=document.querySelector(`[name="${t[0]}"][value="${t[1]}"]`))),e&&e.hasAttribute("data-datalayer-name")?e.getAttribute("data-datalayer-name"):t[0].replace("[]","")}}export{u as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.