{"version":3,"file":"chunks/8848d73efa3456.js","mappings":"6xBAEA,IAAMA,EAAY,qBA6BlB,QA1B6B,WAC3B,WAAaC,EAAe,GAAiB,IAAfC,EAAW,EAAXA,a,4FAAW,SACvCC,KAAKC,KAAKH,EAAeC,EAC3B,C,QAoBC,O,EApBA,G,EAAA,mBAED,SAAKD,EAAeC,GAClB,IAAMG,EAAuBC,EAAAA,EAAAA,aAAiBC,OAAOC,SAASC,MAIxDC,EADoBL,GAAwBM,OAAOC,KAAKP,GAAsBQ,SAASX,IAChDG,EAAqBH,GAG5DY,EAAmBJ,GACvBK,MAAMC,KAAKf,EAAcgB,iBAhBN,6DAgB0CC,KAC3D,YAAa,SAAVC,WAA4BC,aAAapB,GAAWqB,KAAK,IAM1DC,EAHyBZ,GAAmBI,GAAoBA,EAAiBD,SAASH,GAG3D,IAAH,OAAOV,EAAS,YAAIU,EAAe,KAAM,WAC3ET,EAAcgB,iBAAiBK,GAAKC,SAAQ,SAAAC,GAAI,OAAIA,EAAKL,WAAWC,aAAa,SAASC,OAAS,QAAQ,GAC7G,M,oEAAC,EAvB0B,E","sources":["webpack:///./resources/js/components/generic/conditional-url-container.ts"],"sourcesContent":["import url from '../../utils/url';\n\nconst DATA_ATTR = 'data-urlparamvalue';\nconst CONDITIONALS_SEL = '.conditional .component--conditional-url-child-container';\n\nclass ConditionalURLContainer {\n constructor (componentRoot, { urlParamKey }) {\n this.init(componentRoot, urlParamKey);\n }\n\n init(componentRoot, urlParamKey) {\n const queryParamsAndValues = url.getUrlParams(window.location.href);\n\n // check whether our query param is present and has a value\n const queryParamMatches = queryParamsAndValues && Object.keys(queryParamsAndValues).includes(urlParamKey);\n const queryParamValue = queryParamMatches && queryParamsAndValues[urlParamKey];\n\n // get all the possible values to check against\n const queryParamValues = queryParamValue &&\n Array.from(componentRoot.querySelectorAll(CONDITIONALS_SEL)).map(\n ({ attributes }) => attributes.getNamedItem(DATA_ATTR).value\n );\n\n const queryParamValueMatches = queryParamValue && queryParamValues && queryParamValues.includes(queryParamValue);\n\n // if there's a match show the matched child(ren) otherwise show the default content\n const sel = queryParamValueMatches ? `[${DATA_ATTR}=${queryParamValue}]` : '.default';\n componentRoot.querySelectorAll(sel).forEach(node => node.attributes.getNamedItem('class').value += ' shown');\n }\n}\n\nexport default ConditionalURLContainer;"],"names":["DATA_ATTR","componentRoot","urlParamKey","this","init","queryParamsAndValues","url","window","location","href","queryParamValue","Object","keys","includes","queryParamValues","Array","from","querySelectorAll","map","attributes","getNamedItem","value","sel","forEach","node"],"sourceRoot":""}