{"version":3,"sources":["../../../../dev/j/v3/components/cmp-comparebox.js"],"names":["switchToggler","chosenItem","items","forEach","item","classList","add","remove","showContent","selectedOption","box","querySelectorAll","el","contains","document","toggler","querySelector","selector","dataset","option","addEventListener","selected","value","this","error","sdl","console","push","system","type","name","message","event"],"mappings":"CAAA,WACC,YAgDC,SAASA,GAAcC,EAAYC,GAClCA,EAAMC,QAAQ,SAASC,GACtBA,GAAQH,EAAaG,EAAKC,UAAUC,IAAI,YAAcF,EAAKC,UAAUE,OAAO,cAM9E,QAASC,GAAYC,EAAgBC,GAEpCA,EAAIC,iBAAiB,wBAAwBR,QAAQ,SAASS,GAC7DA,EAAGP,UAAUQ,SAAS,YAAcJ,GAAkBG,EAAGP,UAAUE,OAAO,QAAUK,EAAGP,UAAUC,IAAI,UA1DxG,IACaQ,SAASH,iBAAiB,gBAEhCR,QAAQ,SAASO,GACtB,GACCK,GAAUL,EAAIM,cAAc,YAC5BC,EAAWP,EAAIM,cAAc,eAG9B,IAAGD,EAAS,CACX,GAAIb,GAAQa,EAAQJ,iBAAiB,gBAErCT,GAAMC,QAAQ,SAASC,GAElBA,EAAKC,UAAUQ,SAAS,aAC3BL,EAAYJ,EAAKc,QAAQC,OAAQT,GAIlCN,EAAKgB,iBAAiB,QAAS,WAC9BpB,EAAcI,EAAMF,GACpBM,EAAYJ,EAAKc,QAAQC,OAAQT,WAO7B,IAAGO,EAAU,CACnB,GAAIf,GAAQe,EAASN,iBAAiB,SAEtCT,GAAMC,QAAQ,SAASC,GAElBA,EAAKiB,UACRb,EAAYJ,EAAKkB,MAAOZ,KAK1BO,EAASG,iBAAiB,SAAU,WACnCZ,EAAYe,KAAKD,MAAOZ,QAwB1B,MAAOc,GAEW,mBAARC,OACVC,QAAQF,MAAMA,GACdC,IAAIE,MACHC,QACCJ,OACCK,KAAML,EAAMM,KACZC,QAASP,EAAMO,UAGjBC,MAAO","file":"cmp-comparebox.js","sourcesContent":["(function() {\n\t'use strict';\n\ttry {\n\t\tvar boxes = document.querySelectorAll('.compare-box');// parents of the toggler/selector in which data are being switched\n\n\t\tboxes.forEach(function(box) {\n\t\t\tvar\n\t\t\t\ttoggler = box.querySelector('.toggler'),\n\t\t\t\tselector = box.querySelector('.form-select');\n\n\t\t\t// detect selected value from TOGGLER\n\t\t\tif(toggler) {\n\t\t\t\tvar items = toggler.querySelectorAll('.toggler-item');\n\n\t\t\t\titems.forEach(function(item) {\n\t\t\t\t\t// lookup for selected option and set up content by this item (for cases where .hide classes are not properly added in the DOM)\n\t\t\t\t\tif (item.classList.contains('selected')) {\n\t\t\t\t\t\tshowContent(item.dataset.option, box);\n\t\t\t\t\t}\n\n\t\t\t\t\t// add listener to monitor changes in toggler\n\t\t\t\t\titem.addEventListener('click', function(){\n\t\t\t\t\t\tswitchToggler(item, items);\n\t\t\t\t\t\tshowContent(item.dataset.option, box);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\n\n\t\t\t// detect selected value from SELECTOR\n\t\t\t} else if(selector) {\n\t\t\t\tvar items = selector.querySelectorAll('option');\n\n\t\t\t\titems.forEach(function(item) {\n\t\t\t\t\t// lookup for selected option and set up content by this item (for cases where .hide classes are not properly added in the DOM)\n\t\t\t\t\tif (item.selected) {\n\t\t\t\t\t\tshowContent(item.value, box);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// add listener to monitor changes in Selector\n\t\t\t\tselector.addEventListener('change', function(){\n\t\t\t\t\tshowContent(this.value, box);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\n\t\t// Switch items in toggler and show content\n\t\tfunction switchToggler(chosenItem, items) {\n\t\t\titems.forEach(function(item) {\n\t\t\t\titem == chosenItem ? item.classList.add('selected') : item.classList.remove('selected');\n\t\t\t});\n\t\t};\n\n\n\t\t// Make selected option content visible\n\t\tfunction showContent(selectedOption, box) {\n\t\t\t// add .hide to all elements with .js-optionN except chosen option\n\t\t\tbox.querySelectorAll(\"[class*='js-option']\").forEach(function(el) {\n\t\t\t\tel.classList.contains('js-option' + selectedOption) ? el.classList.remove('hide') : el.classList.add('hide');\n\t\t\t});\n\t\t};\n\t\t\n\n\n\t} catch (error) {\n\t\t// singe data layer error tracking\n\t\tif (typeof sdl !== 'undefined') {\n\t\t\tconsole.error(error);\n\t\t\tsdl.push({\n\t\t\t\tsystem: {\n\t\t\t\t\terror: {\n\t\t\t\t\t\ttype: error.name,\n\t\t\t\t\t\tmessage: error.message,\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tevent: 'system.error'\n\t\t\t});\n\t\t}\n\t}\n})();\n"]}