{"version":3,"file":"blocks.legacy.js","sources":["../../resources/modern-javascript/blocks.js"],"sourcesContent":["import { initialiseSwiper } from './swiper/swiper.js';\nimport { initShowroomFinders } from './showrooms/showroomFinder.js';\nimport { RecentSwatches } from './swatch/RecentSwatches.js';\nimport { handleFragmentInit } from './pdp/fragments';\nimport { replaceElementHTML } from './pdp/replace';\n\ninitShowroomFinders();\n\nconst initRecentSwatches = () => {\n  const recentSwatchContainer = document.querySelector(\n    '[data-recent-swatches]',\n  );\n\n  if (!recentSwatchContainer) {\n    return;\n  }\n\n  const recentSwatches = new RecentSwatches();\n  const swatchGridModifierClasses = ['swiper-wrapper', 'swatch-grid--block'];\n\n  recentSwatches.renderRecentSwatches(swatchGridModifierClasses);\n};\n\ninitRecentSwatches();\n\nhandleFragmentInit(({ replace }) => {\n  if (replace?.crossSell) {\n    replaceElementHTML('.block--cross-sells', replace.crossSell);\n  }\n\n  const carousels = document.querySelectorAll('.block .swiper');\n  // This is reasonable as we exit out if a swpier alreaddy exists. Though perhaps not ideal.\n  for (const carousel of carousels ?? []) {\n    initialiseSwiper(carousel);\n  }\n});\n\nconst initReadMore = () => {\n  const readMoreContainers = document.querySelectorAll('.block__content .read-more');\n\n  if (!readMoreContainers) {\n    return;\n  }\n\n  readMoreContainers.forEach((container) => {\n    const button = container.querySelector('.js-read_more');\n\n    if (!button) {\n      return;\n    }\n\n    button.addEventListener('click', () => {\n      container.classList.toggle('read-more--active');\n      \n      if (container.classList.contains('read-more--active')) {\n        button.textContent = 'Read less';\n      } else {\n        button.textContent = '... Read more';\n      }\n    });\n  });\n}\n\ninitReadMore();\n"],"names":["initShowroomFinders","document","querySelector","RecentSwatches","renderRecentSwatches","initRecentSwatches","handleFragmentInit","h","_ref","replace","crossSell","replaceElementHTML","_step","carousels","querySelectorAll","_iterator","_createForOfIteratorHelper","s","n","done","carousel","value","initialiseSwiper","err","e","f","readMoreContainers","forEach","container","button","addEventListener","classList","toggle","contains","textContent"],"mappings":"4oHAMA,EAAAA,EAAAA,MAE2B,WAKzB,GAJ8BC,SAASC,cACrC,0BAGF,EAIuB,IAAIC,EAAAA,GAGZC,qBAFmB,CAAC,iBAAkB,sBAHpD,CAMH,CAEAC,IAEA,EAAAC,EAAkBC,IAAC,SAAAC,GAAiB,IAAdC,EAAOD,EAAPC,QAChBA,SAAAA,EAASC,YACX,EAAAC,KAAmB,sBAAuBF,EAAQC,WAGpD,IAEsCE,EAFhCC,EAAYZ,SAASa,iBAAiB,kBAC9CC,EAAAC,EACyBH,QAAAA,EAAa,IAAE,IAAtC,IAAAE,EAAAE,MAAAL,EAAAG,EAAAG,KAAAC,MAAwC,CAAA,IAA7BC,EAAQR,EAAAS,OACjB,EAAAC,EAAAA,GAAiBF,EAClB,CAAA,CAAA,MAAAG,GAAAR,EAAAS,EAAAD,EAAA,CAAA,QAAAR,EAAAU,GAAA,CACH,IAEA,IACQC,KAAqBzB,SAASa,iBAAiB,gCAMrDY,EAAmBC,SAAQ,SAACC,GAC1B,IAAMC,EAASD,EAAU1B,cAAc,iBAElC2B,GAILA,EAAOC,iBAAiB,SAAS,WAC/BF,EAAUG,UAAUC,OAAO,qBAEvBJ,EAAUG,UAAUE,SAAS,qBAC/BJ,EAAOK,YAAc,YAErBL,EAAOK,YAAc,eAE7B,GACA,GAGc"}