{"version":3,"file":"js/newsletter_module-newsletter_module-js-62e8710afa0780ef9576.chunk.js","mappings":"0LAEO,SAASA,KACdC,EAAAA,EAAAA,IAAc,CACZC,KAAM,CACJC,WAAY,oBACZC,UAAW,aACXC,UAAW,iBACXC,UAAW,GACXC,gBAAiB,OACjBC,cAAe,gBAGrB,CACO,SAASC,EAAkBC,IAChCT,EAAAA,EAAAA,IAAc,CACZC,KAAM,CACJC,WAAY,oBACZC,UAAW,aACXC,UAAW,uBACXC,UAAWI,EACXH,gBAAiB,OACjBC,cAAe,gBAGrB,C,wCCLeG,SAASC,cAAc,+BAE/BC,iBAAiB,UAAUC,IAC9BA,EAAMC,iBACN,MAAMC,EAAYF,EAAMG,OAAOC,OACzBhB,EAAOiB,OAAOC,YAAY,IAAIC,SAASP,EAAMG,SAEnDK,MAAMN,EAAW,CACfF,MAAOA,EAAMC,iBACbQ,OAAQ,OACRC,QAAS,CACP,eAAgB,oBAElBC,KAAMC,KAAKC,UAAUzB,KAEpB0B,MAAKC,GACGA,EAASC,SAEjBF,MAAK1B,IACgB,OAAhBA,EAAK6B,QArCjB,WACE,MAAMC,EAA0BrB,SAASC,cAAc,uBACvDoB,EAAwBC,UAAUC,OAAO,6BACzCC,YAAW,KACTH,EAAwBC,UAAUG,IAAI,4BAA4B,GACjE,IACL,CAgCUC,IACArC,EAAAA,EAAAA,yBA/BV,SAA0BU,GACxB,MAAM4B,EAAiB3B,SAASC,cAAc,6BAC9C0B,EAAeC,YAAc7B,EAC7B4B,EAAeL,UAAUC,OAAO,aAChCC,YAAW,KACTG,EAAeL,UAAUG,IAAI,YAAY,GACxC,IACL,CA0BUI,CAAiBtC,EAAKQ,UACtBD,EAAAA,EAAAA,mBAAkBP,EAAKQ,SACzB,IAED+B,OAAMC,IACLC,QAAQD,MAAM,kBAAmBA,IACjCjC,EAAAA,EAAAA,mBAAkBiC,EAAM,GACxB,G","sources":["webpack://cms-web/./app/frontend/src/blocks/newsletter_module/newsletter_module.analytics.js","webpack://cms-web/./app/frontend/src/blocks/newsletter_module/newsletter_module.js"],"sourcesContent":["import { sendUtagEvent } from '../../core/analytics/utag_events'\n\nexport function subscriptionSuccess() {\n sendUtagEvent({\n data: {\n event_name: 'newsletter_module',\n event_cat: 'newsletter',\n event_act: 'user suscribed',\n event_lbl: '',\n event_structure: 'body',\n event_purpose: 'inspiration',\n },\n })\n}\nexport function subscriptionError(message) {\n sendUtagEvent({\n data: {\n event_name: 'newsletter_module',\n event_cat: 'newsletter',\n event_act: 'error user suscribed',\n event_lbl: message,\n event_structure: 'body',\n event_purpose: 'inspiration',\n },\n })\n}\n","import { subscriptionError, subscriptionSuccess } from './newsletter_module.analytics.js'\n\nfunction showSuccessMessage() {\n const successMessageContainer = document.querySelector('.newsletter-message')\n successMessageContainer.classList.remove('newsletter-message-hidden')\n setTimeout(() => {\n successMessageContainer.classList.add('newsletter-message-hidden')\n }, 5000)\n}\n\nfunction showErrorMessage(message) {\n const errorContainer = document.querySelector('.newsletter-message-error')\n errorContainer.textContent = message\n errorContainer.classList.remove('is-hidden')\n setTimeout(() => {\n errorContainer.classList.add('is-hidden')\n }, 5000)\n}\n\nfunction init() {\n const form = document.querySelector('.container-newsletter__form')\n\n form.addEventListener('submit', event => {\n event.preventDefault() // Evitar el envĂ­o por defecto del formulario\n const actionUrl = event.target.action\n const data = Object.fromEntries(new FormData(event.target))\n\n fetch(actionUrl, {\n event: event.preventDefault(),\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(data),\n })\n .then(response => {\n return response.json() // Convierte el cuerpo de la respuesta a JSON\n })\n .then(data => {\n if (data.status === 'ok') {\n showSuccessMessage()\n subscriptionSuccess()\n } else {\n showErrorMessage(data.message)\n subscriptionError(data.message)\n }\n })\n .catch(error => {\n console.error('Error en fetch:', error)\n subscriptionError(error)\n })\n })\n}\n\ninit()\n"],"names":["subscriptionSuccess","sendUtagEvent","data","event_name","event_cat","event_act","event_lbl","event_structure","event_purpose","subscriptionError","message","document","querySelector","addEventListener","event","preventDefault","actionUrl","target","action","Object","fromEntries","FormData","fetch","method","headers","body","JSON","stringify","then","response","json","status","successMessageContainer","classList","remove","setTimeout","add","showSuccessMessage","errorContainer","textContent","showErrorMessage","catch","error","console"],"sourceRoot":""}