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,IAAItB,GAC3B8B,EAASI,UAAUH,EAAME,QAEjC,GACJ,GACA,CAAEE,UAAW,KAECC,QAAQT,EAC9B,CAAE,MAAOU,GACLC,QAAQC,KAAKF,GACbV,EAAkBT,UAAUI,IAAItB,EACpC,CAE4BP,EAAUa,iBAClC,mCAEgBd,SAAQ,SAAAgD,GACxBA,EAAmB/B,iBAAiB,SAAS,WACzC,IAAMgC,EACFD,EAAmB7B,QAAQ+B,sBAC3BD,IACAE,EAAAA,EAAAA,UAA2B,CACvBC,aAAc,sBACdC,cAAeJ,IAEnB5B,EAAAA,EAAAA,kBAAsB4B,GAAc3B,UAChC,kCAGZ,GACJ,IAGA,IAAMgC,EAAqBC,SAASzC,iBAChC,kCAEE0C,EAAK,IAAIC,EAAAA,EACfH,EAAmBtD,SAAQ,SAAA0D,GACvBA,EAAkBzC,iBAAiB,SAAS,WACxCuC,EAAGG,YAAY,kBACfxD,OAAOyD,aAAaC,WAAW,mBACnC,GACJ,GACJ,GAMZ,C","sources":["webpack:///./html/wp-content/themes/ls/src/js/main/components/acfModules/businessTypeSelectionModule.js"],"sourcesContent":["import { gtm } from 'root/utils/tracking/googleTagManagerDeprecated';\nimport { CookieMonster } from 'root/utils/cookies/cookieMonster';\nimport { GoogleTagManager } from 'root/utils/tracking/GA4/googleTagManager';\n\nexport default function businessTypeSelectionModule(btsModules) {\n return (function () {\n const init = () => {\n btsModules.forEach(btsModule => {\n const isMobile = window.innerWidth < 600;\n const productPanel = btsModule.querySelector(\n '[data-module-bts=\"panel-product\"]'\n );\n const panelShowClass = 'js-business-type-selection-module__panel--show';\n const panelAnimateClass =\n 'js-business-type-selection-module__panel--animate';\n if (productPanel) {\n const productPanelHeight = productPanel.scrollHeight;\n const productButtons = Array.from(\n productPanel.querySelectorAll('[data-module-bts-product]')\n );\n const backButtons = btsModule.querySelectorAll(\n '[data-module-bts=\"back-button\"]'\n );\n\n /**\n * This hides the product panel and shows the business type panel associated with the selected product\n * @param {*} productButton\n */\n const showAssociatedBTPanel = product => {\n const associatedPanel = btsModule.querySelector(\n `[data-module-bts=\"panel-${product}\"]`\n );\n productPanel.classList.remove(panelShowClass);\n if (associatedPanel) {\n isMobile &&\n (btsModule.style.minHeight = `${associatedPanel.scrollHeight}px`);\n associatedPanel.classList.add(\n panelShowClass,\n panelAnimateClass\n );\n }\n };\n\n /**\n * This hides the current business type panel and shows the product panel\n * @param {*} backButton\n */\n const hideBTPanel = backButton => {\n backButton\n .closest('[data-module-bts*=\"panel\"]')\n .classList.remove(panelShowClass, panelAnimateClass);\n productPanel.classList.add(panelShowClass);\n };\n\n productButtons.forEach(productButton => {\n productButton.addEventListener('click', () => {\n const product = productButton.dataset.moduleBtsProduct;\n if (product) {\n gtm.btSelectionModule(product).sendEvent(\n 'business-type-selection-module'\n );\n if (productButton.tagName === 'BUTTON') {\n showAssociatedBTPanel(product);\n }\n }\n });\n });\n backButtons.forEach(backButton => {\n backButton.addEventListener('click', () => {\n hideBTPanel(backButton);\n isMobile &&\n (btsModule.style.minHeight = `${productPanelHeight}px`);\n gtm.btSelectionModule('back').sendEvent(\n 'business-type-selection-module'\n );\n });\n });\n }\n // This shows and animates the first panel of the Business Type Selection Module content when it scrolls into the viewport. On the two-step version, it's the Product panel, while on the one-step, it's the Retail or Resto panel.\n const initialShownPanel = btsModule.querySelector(`.${panelShowClass}`);\n try {\n /* this is a fix for \"ReferenceError: IntersectionObserver is not defined\" in case on an Android devices where the IntersectionObserver won't be defined - recurrent error in DD */\n const btsModuleObserver = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n entry.target.classList.add(panelAnimateClass);\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 0.5 }\n );\n btsModuleObserver.observe(initialShownPanel);\n } catch (e) {\n console.warn(e); /* @todo Send a DD custom event */\n initialShownPanel.classList.add(panelAnimateClass);\n }\n // Fire Tracking event when a business type is clicked on\n const businessTypeButtons = btsModule.querySelectorAll(\n '[data-module-bts-business-type]'\n );\n businessTypeButtons.forEach(businessTypeButton => {\n businessTypeButton.addEventListener('click', () => {\n const businessType =\n businessTypeButton.dataset.moduleBtsBusinessType;\n if (businessType) {\n GoogleTagManager.sendEvent({\n event_action: 'click_business_type',\n business_type: businessType,\n });\n gtm.btSelectionModule(businessType).sendEvent(\n 'business-type-selection-module'\n );\n }\n });\n });\n\n // Clear BT cookie when \"Other\" business type is clicked on\n const clearCookieButtons = document.querySelectorAll(\n '[data-module-bts-clear-cookie]'\n );\n const cm = new CookieMonster();\n clearCookieButtons.forEach(clearCookieButton => {\n clearCookieButton.addEventListener('click', () => {\n cm.unsetCookie('ls_vertical_bt');\n window.localStorage.removeItem('btf.businessType');\n });\n });\n });\n };\n return {\n init,\n };\n })().init();\n}\n"],"names":["businessTypeSelectionModule","btsModules","forEach","btsModule","isMobile","window","innerWidth","productPanel","querySelector","panelShowClass","panelAnimateClass","productPanelHeight","scrollHeight","productButtons","Array","from","querySelectorAll","backButtons","productButton","addEventListener","product","dataset","moduleBtsProduct","gtm","sendEvent","tagName","associatedPanel","concat","classList","remove","style","minHeight","add","showAssociatedBTPanel","backButton","closest","hideBTPanel","initialShownPanel","IntersectionObserver","entries","observer","entry","isIntersecting","target","unobserve","threshold","observe","e","console","warn","businessTypeButton","businessType","moduleBtsBusinessType","GoogleTagManager","event_action","business_type","clearCookieButtons","document","cm","CookieMonster","clearCookieButton","unsetCookie","localStorage","removeItem"],"sourceRoot":""}