{"version":3,"file":"HeaderPersistentBar-CUl33apM-chunk.js","sources":["../../../src/components/header/HeaderPersistentBar.jsx"],"sourcesContent":["import React, { Component, Fragment } from \"react\";\nimport PropTypes from \"prop-types\";\nimport ImageX from \"components/utility/images/ImageX\";\nimport { getDecodedHtml } from \"utils/getDecodedHtml\";\n\nclass HeaderPersistentBar extends Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\tclosed: false,\n\t\t\tsubmitting: false\n\t\t};\n\t\tthis.containerRef = React.createRef();\n\t}\n\n\tcomponentDidMount() {\n\t\tif (this.props.data && this.props.type === \"bottom\") {\n\t\t\tthis.onResize();\n\t\t\twindow.addEventListener(\"resize\", this.onResize);\n\t\t}\n\n\t\tif (this.props.data !== undefined && this.props.data !== null) {\n\t\t\twindow.dataLayer = window.dataLayer || [];\n\t\t\twindow.dataLayer.push({\n\t\t\t\t\"data-a-lbl\": \"Banner Initiated\",\n\t\t\t\t\"data-a-cat\": \"Redirect Banner\",\n\t\t\t\t\"data-a-act\":\n\t\t\t\t\t\"Visiting \" +\n\t\t\t\t\tthis.props.data.visitingCountryCode +\n\t\t\t\t\t\", Previously \" +\n\t\t\t\t\tthis.props.data.currentCountryCode\n\t\t\t});\n\t\t}\n\t}\n\n\tonResize() {\n\t\tconst bottomPersistentBar = document.querySelector(\".header-persistent-bar-bottom\");\n\t\tconst topPersistentBar = document.querySelector(\".header-persistent-bar-top\");\n\t\tconst firstLogin = document.querySelector(\".header-persistent-bar-without-line\");\n\t\tif (window.innerWidth < 768) {\n\t\t\tif (topPersistentBar && bottomPersistentBar) {\n\t\t\t\tbottomPersistentBar.style.top = \"auto\";\n\t\t\t}\n\t\t} else {\n\t\t\tconst placeholder = document.querySelector(\".header-persistent-bar-bottom-placeholder\");\n\t\t\tplaceholder.insertAdjacentElement(\"afterend\", bottomPersistentBar);\n\t\t\tif (topPersistentBar && bottomPersistentBar && firstLogin) {\n\t\t\t\tbottomPersistentBar.style.top = topPersistentBar.clientHeight + \"px\";\n\t\t\t}\n\t\t}\n\t}\n\tonClose = (e) => {\n\t\te.preventDefault();\n\t\tthis.post(\n\t\t\t\"SESSION\",\n\t\t\t() => {\n\t\t\t\tthis.setState({\n\t\t\t\t\tclosed: true,\n\t\t\t\t\tsubmitting: false\n\t\t\t\t});\n\t\t\t\tthis.adjustStickyHeader(false);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.setState({\n\t\t\t\t\tclosed: true,\n\t\t\t\t\tsubmitting: false\n\t\t\t\t});\n\t\t\t\tthis.adjustStickyHeader(false);\n\t\t\t}\n\t\t);\n\t};\n\tonCta = (e) => {\n\t\te.preventDefault();\n\t\tthis.post(\n\t\t\t\"PERMANENT\",\n\t\t\t() => {\n\t\t\t\tthis.setState({\n\t\t\t\t\tclosed: true,\n\t\t\t\t\tsubmitting: false\n\t\t\t\t});\n\t\t\t\tthis.adjustStickyHeader(true);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.setState({\n\t\t\t\t\tclosed: true,\n\t\t\t\t\tsubmitting: false\n\t\t\t\t});\n\t\t\t\tthis.adjustStickyHeader(true);\n\t\t\t}\n\t\t);\n\t};\n\tsetCountryCookie = (e) => {\n\t\tthis.onClose(e);\n\t\tfetch(this.props.data.countryAPIEndpoint, {\n\t\t\tcredentials: \"same-origin\",\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t},\n\t\t\tbody: JSON.stringify({ countryValue: this.props.data.countryValue })\n\t\t})\n\t\t\t.then((res) => res.json())\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.log(error);\n\t\t\t});\n\t};\n\tadjustStickyHeader(redirect) {\n\t\tconst persistentBar = this.containerRef.current;\n\t\tconst hardHeight = persistentBar.offsetHeight + \"px\";\n\t\tpersistentBar.style.height = hardHeight;\n\t\tsetTimeout(() => {\n\t\t\tif (persistentBar.classList.contains(\"header-persistent-bar-top\")) {\n\t\t\t\tconst firstPlaceholder = document.querySelector(\".sticky-header-placeholder\");\n\t\t\t\tconst firstStickyEl = document.querySelector(\".sticky-header-el\");\n\t\t\t\tif (firstPlaceholder) {\n\t\t\t\t\tfirstPlaceholder.style.height =\n\t\t\t\t\t\tfirstStickyEl.offsetHeight - persistentBar.offsetHeight + \"px\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpersistentBar.style.height = \"0px\";\n\n\t\t\tif (redirect) {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tif (this.props.data.ctaUrl && this.props.data.ctaUrl.length) {\n\t\t\t\t\t\tif (this.props.data.ctaTarget && this.props.data.ctaTarget.length) {\n\t\t\t\t\t\t\twindow.open(this.props.data.ctaUrl, this.props.data.ctaTarget);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.location = this.props.data.ctaUrl;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 400);\n\t\t\t}\n\t\t}, 50);\n\t}\n\tpost(acceptanceType, success, error) {\n\t\tif (!this.state.submitting) {\n\t\t\tthis.setState({ submitting: true });\n\t\t\tfetch(this.props.data.url, {\n\t\t\t\tcredentials: \"same-origin\",\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({ notificationId: this.props.data.notificationId, acceptanceType })\n\t\t\t})\n\t\t\t\t.then((res) => res.json())\n\t\t\t\t.then(success)\n\t\t\t\t.catch(error);\n\t\t}\n\t}\n\trender() {\n\t\tif (!this.props.data) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tconst { color, type, data, dataset } = this.props;\n\t\tconst {\n\t\t\tcountryFlag = false,\n\t\t\tsetCountryCookieText,\n\t\t\tctaText,\n\t\t\tctaUrl,\n\t\t\tvisitingCountryCode,\n\t\t\tcurrentCountryCode\n\t\t} = data;\n\t\tconst { withoutLine = false, publicSite = false } = dataset;\n\t\tlet button = null,\n\t\t\tcloseButton = null,\n\t\t\tbottomPlaceholder = null;\n\t\tif (ctaText && ctaUrl) {\n\t\t\tbutton = data.countryFlag ? (\n\t\t\t\t
\n\t\t\t\t\t this.setCountryCookie(e)}\n\t\t\t\t\t\tdata-a=\"true\"\n\t\t\t\t\t\tdata-a-lbl={setCountryCookieText}\n\t\t\t\t\t\tdata-a-cat=\"Banner\"\n\t\t\t\t\t\tdata-a-act={\"Visiting \" + visitingCountryCode + \", Previously \" + currentCountryCode}\n\t\t\t\t\t>\n\t\t\t\t\t\t{setCountryCookieText}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t{ctaText}\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t) : (\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t{ctaText}\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t);\n\t\t}\n\t\tif (data.showCloseButton) {\n\t\t\tcloseButton = (\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t);\n\t\t}\n\t\tif (type === \"bottom\") {\n\t\t\tbottomPlaceholder =
;\n\t\t}\n\t\treturn (\n\t\t\t\n\t\t\t\t{bottomPlaceholder}\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{button}\n\t\t\t\t\t\t\t{closeButton}\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t);\n\t}\n}\n\nHeaderPersistentBar.propTypes = {\n\tcolor: PropTypes.string.isRequired,\n\ttype: PropTypes.string.isRequired,\n\tdataset: PropTypes.object\n};\n\nexport default HeaderPersistentBar;\n"],"names":["HeaderPersistentBar","Component","props","__publicField","e","res","error","React","bottomPersistentBar","topPersistentBar","firstLogin","redirect","persistentBar","hardHeight","firstPlaceholder","firstStickyEl","acceptanceType","success","color","type","data","dataset","countryFlag","setCountryCookieText","ctaText","ctaUrl","visitingCountryCode","currentCountryCode","withoutLine","publicSite","button","closeButton","bottomPlaceholder","jsxs","jsx","ImageX","Fragment","getDecodedHtml","PropTypes"],"mappings":"sUAKA,MAAMA,UAA4BC,EAAAA,SAAU,CAC3C,YAAYC,EAAO,CAClB,MAAMA,CAAK,EA4CZC,EAAA,eAAWC,GAAM,CAChBA,EAAE,eAAe,EACZ,KAAA,KACJ,UACA,IAAM,CACL,KAAK,SAAS,CACb,OAAQ,GACR,WAAY,EAAA,CACZ,EACD,KAAK,mBAAmB,EAAK,CAC9B,EACA,IAAM,CACL,KAAK,SAAS,CACb,OAAQ,GACR,WAAY,EAAA,CACZ,EACD,KAAK,mBAAmB,EAAK,CAAA,CAE/B,CACD,GACAD,EAAA,aAASC,GAAM,CACdA,EAAE,eAAe,EACZ,KAAA,KACJ,YACA,IAAM,CACL,KAAK,SAAS,CACb,OAAQ,GACR,WAAY,EAAA,CACZ,EACD,KAAK,mBAAmB,EAAI,CAC7B,EACA,IAAM,CACL,KAAK,SAAS,CACb,OAAQ,GACR,WAAY,EAAA,CACZ,EACD,KAAK,mBAAmB,EAAI,CAAA,CAE9B,CACD,GACAD,EAAA,wBAAoBC,GAAM,CACzB,KAAK,QAAQA,CAAC,EACR,MAAA,KAAK,MAAM,KAAK,mBAAoB,CACzC,YAAa,cACb,OAAQ,OACR,QAAS,CACR,OAAQ,mBACR,eAAgB,kBACjB,EACA,KAAM,KAAK,UAAU,CAAE,aAAc,KAAK,MAAM,KAAK,YAAc,CAAA,CAAA,CACnE,EACC,KAAMC,GAAQA,EAAI,MAAM,EACxB,MAAOC,GAAU,CACjB,QAAQ,IAAIA,CAAK,CAAA,CACjB,CACH,GAlGC,KAAK,MAAQ,CACZ,OAAQ,GACR,WAAY,EACb,EACK,KAAA,aAAeC,EAAM,UAAU,CAAA,CAGrC,mBAAoB,CACf,KAAK,MAAM,MAAQ,KAAK,MAAM,OAAS,WAC1C,KAAK,SAAS,EACP,OAAA,iBA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