{"version":3,"sources":["blocks/m-notification-badge.js"],"names":["define","utility","cookie","mNotificationBadgeFn","notificationHeight","init","elm","cookieNameAttr","cookieName","mNotificationBadge","get","remove","wrapperElm","contains","classList","document","querySelector","getAttribute","elmId","setAttribute","setupResizeObserver","setupApiFunctions","close","showHide","setupCloseButton","closeElm","htmlStringToElement","FRAMEWORK","locale","settings","closeText","append","preventDefault","addEventListener","e","location","secureCookie","enabled","announceClose","secure","path","sameSite","slideToggle","t350ms","variant","window","callback","removeEventListener","showNotification","windowResizeListener","newDisplayType","fromResize","ariaHidden","display","style","siteSwitcherBtn","singleRow","debounce","fontSize","getComputedStyle","barElm","countrySelectorBtn","removeMeasurementSuffix","ResizeObserver","entries","elmResizeObserver","entry","contentBoxSize","blockSize","add","cookieMessageText","cookieMessage","success","createTextNode","failed","initInstance","createElement","el","body","setTimeout"],"mappings":"aAAAA,OAAQ,CAAE,UAAW,iBAAmB,SAAcC,EAASC,GAG9D,IAFAC,EAAA,CAEAC,mBAAID,OAIHE,KAAO,SAAUC,GAChB,IAGCC,EADAC,EAFD,mBAiDA,OAjDAF,EAGCC,qBAGAD,EAAIG,mBAAqB,IACzB,SAAAP,EAAAA,OAAAQ,IAAAF,IAGAF,EAAIK,UACJC,EAFWV,SAAOQ,cAAd,6CAIHE,EAFDA,UACKA,EAAAA,UAAaC,SAAA,6BAMlBP,EATDQ,UAMYR,IAAIQ,2BAKfR,EAFAA,mBAAmBM,WAAAG,SAAAC,cAAnB,2CAKAT,EAAAA,EAAiBD,aAAIW,oBAMoB,SAApCf,EAAOA,OAAOQ,IAJlBF,EADuB,OAAnBD,GAA8C,KAAnBA,EAA3BA,EAKmBC,IACvBF,EADDK,SACCL,EAAIK,mBAAJC,YAECN,EAAIG,mBAAmBG,WAAWD,YAGnCO,EAFCZ,EAAAW,aAAA,SAIAC,EAFDA,EAAYD,OAAAA,yBAGXX,EAAIa,aAAc,KAAMD,IAGzBf,EAHKgB,iBAAJb,EAAAY,EAAAV,GAKDL,E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,SAAAC,GACAA,EAAAC,eAAA,GAAAC,UAAAjE,EAAAC,mBAAAsD,EA3LwBpD,EAAAQ,UAAAH,OAAA,iCA+LzBL,EAAAQ,UAAAuD,IAAA,qCAOCC,QAAoBvD,IARtBuB,cAaEiC,SAAAC,GAXD,IAAID,EAiBFC,IAjNJF,EAAAvD,SAAA0D,eAAA9C,UAAAC,OAAAC,SAAApB,mBAAAiE,SAuNCC,EAAe5D,SAAA6D,cAAe,MACtBzE,aAAAA,OAA2B0E,SAClCN,EAAAzD,UAAAuD,IAAA,sBAHFE,EAAAxC,OAAAuC,GAzNDvD,SAAA+D,KAAA/C,OAAAwC,GAkNIQ,WAAY,WACXR,EAAc5D,UACZ,QAKN,MAAO,CACNgE,aAAe,SAAUE,GACxB,OAAO1E,EAAqBE,KAAMwE","file":"blocks/m-notification-badge.js","sourcesContent":["define( [ 'utility', 'vendor/cookie' ], function run( utility, cookie ) {\n\t'use strict';\n\n\tvar mNotificationBadgeFn = {\n\n\t\tnotificationHeight : 2.1875, /* 35px / 16px */\n\n\t\tinit : function( elm ) {\n\t\t\tvar elmId,\n\t\t\t\twrapperElm,\n\t\t\t\tcookieName = 'ion_notification',\n\t\t\t\tcookieNameAttr;\n\n\t\t\tif ( !elm.mNotificationBadge ) {\n\t\t\t\telm.mNotificationBadge = {}; // Setup mNotificationBadge object\n\t\t\t}\n\n\t\t\tif ( cookie.cookie.get( cookieName ) === 'True' ) {\n\t\t\t\telm.remove();\n\t\t\t\twrapperElm = document.querySelector( '.m-site-country-selection__notification' );\n\t\t\t\tif ( wrapperElm ) {\n\t\t\t\t\twrapperElm.remove();\n\t\t\t\t}\n\t\t\t} else if ( elm.classList.contains( 'js-m-notification-badge' ) ) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\telm.classList.add( 'js-m-notification-badge' );\n\n\t\t\t\telm.mNotificationBadge.wrapperElm = document.querySelector( '.m-site-country-selection__notification' );\n\n\t\t\t\t// Set the cookie name to custom name if provided\n\t\t\t\tcookieNameAttr = elm.getAttribute( 'data-cookie-name' );\n\t\t\t\tif ( cookieNameAttr !== null && cookieNameAttr !== '' ) {\n\t\t\t\t\tcookieName = cookieNameAttr;\n\t\t\t\t}\n\n\t\t\t\t// If the cookie has already been set remove the notification straight away\n\t\t\t\tif ( cookie.cookie.get( cookieName ) === 'True' ) {\n\t\t\t\t\telm.remove();\n\t\t\t\t\tif ( elm.mNotificationBadge.wrapperElm ) {\n\t\t\t\t\t\telm.mNotificationBadge.wrapperElm.remove();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\telmId = elm.getAttribute( 'id' );\n\t\t\t\t\tif ( !elmId ) {\n\t\t\t\t\t\telmId = utility.makeId( 'm-notification-badge-' );\n\t\t\t\t\t\telm.setAttribute( 'id', elmId );\n\t\t\t\t\t}\n\n\t\t\t\t\tmNotificationBadgeFn.setupCloseButton( elm, elmId, cookieName );\n\n\t\t\t\t\tmNotificationBadgeFn.setupResizeObserver( elm );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmNotificationBadgeFn.setupApiFunctions( elm, cookieName );\n\n\t\t\treturn elm.mNotificationBadge;\n\t\t},\n\n\t\tsetupApiFunctions : function( elm, cookieName ) {\n\t\t\telm.mNotificationBadge.close = function close() {\n\t\t\t\tif ( elm.classList.contains( 'js-m-notification-badge' ) ) {\n\t\t\t\t\tmNotificationBadgeFn.close( elm, cookieName );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\telm.mNotificationBadge.show = function show() {\n\t\t\t\tif ( elm.classList.contains( 'js-m-notification-badge' ) && elm.mNotificationBadge.wrapperElm ) {\n\t\t\t\t\tmNotificationBadgeFn.showHide( elm, true );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\telm.mNotificationBadge.hide = function hide() {\n\t\t\t\tif ( elm.classList.contains( 'js-m-notification-badge' ) && elm.mNotificationBadge.wrapperElm ) {\n\t\t\t\t\tmNotificationBadgeFn.showHide( elm, false );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\n\t\tsetupCloseButton : function( elm, elmId, cookieName ) {\n\t\t\tvar closeElm = elm.querySelector( '.m-notification-badge__close' );\n\n\t\t\t// If there is no close button already create one\n\t\t\tif ( !closeElm ) {\n\t\t\t\tcloseElm = utility.htmlStringToElement( '' );\n\t\t\t\telm.append( closeElm );\n\t\t\t}\n\n\t\t\tcloseElm.setAttribute( 'aria-controls', elmId );\n\n\t\t\tcloseElm.addEventListener( 'click', function listener( e ) {\n\t\t\t\te.preventDefault();\n\n\t\t\t\tmNotificationBadgeFn.close( elm, cookieName );\n\t\t\t});\n\t\t},\n\n\t\tclose : function( elm, cookieName ) {\n\t\t\tvar secureCookie = true;\n\n\t\t\tif ( cookie.cookie.enabled() ) {\n\t\t\t\t// If cookies are enabled set a cookie so this message no longer appears\n\t\t\t\tif ( document.location.protocol === 'http:' ) {\n\t\t\t\t\tsecureCookie = false;\n\t\t\t\t}\n\n\t\t\t\tcookie.cookie.set( cookieName, 'True', {\n\t\t\t\t\tsecure : secureCookie,\n\t\t\t\t\tpath : '/',\n\t\t\t\t\tsameSite : 'Strict',\n\t\t\t\t});\n\n\t\t\t\tmNotificationBadgeFn.announceClose( true );\n\t\t\t} else {\n\t\t\t\tmNotificationBadgeFn.announceClose( false );\n\t\t\t}\n\n\t\t\tutility.slideToggle( elm, FRAMEWORK.timings.current.t350ms, {\n\t\t\t\tvariant : 'up',\n\t\t\t\tcallback : function() {\n\t\t\t\t\telm.remove();\n\t\t\t\t\tif ( elm.mNotificationBadge.wrapperElm ) {\n\t\t\t\t\t\telm.mNotificationBadge.wrapperElm.remove();\n\t\t\t\t\t\twindow.removeEventListener( 'resize', elm.mNotificationBadge.windowResizeListener );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\n\t\tshowHide : function( elm, showNotification, fromResize ) {\n\t\t\tvar ariaHidden = 'true',\n\t\t\t\tnewDisplayType = 'none';\n\n\t\t\tif ( showNotification || elm.mNotificationBadge.singleRow ) {\n\t\t\t\tariaHidden = 'false';\n\t\t\t\tnewDisplayType = 'flex';\n\t\t\t}\n\t\t\telm.mNotificationBadge.wrapperElm.setAttribute( 'aria-hidden', ariaHidden );\n\t\t\telm.mNotificationBadge.wrapperElm.style.display = newDisplayType;\n\n\t\t\tif ( showNotification && !fromResize ) {\n\t\t\t\telm.mNotificationBadge.windowResizeListener();\n\t\t\t}\n\t\t},\n\n\t\tsetupResizeObserver : function( elm ) {\n\t\t\tvar elmResizeObserver;\n\n\t\t\tif ( elm.mNotificationBadge.wrapperElm ) {\n\t\t\t\telm.mNotificationBadge.barElm = document.querySelector( '.m-site-country-selection' );\n\t\t\t\telm.mNotificationBadge.countrySelectorBtn = document.querySelector( '.js-m-site-country-selection__country' );\n\t\t\t\telm.mNotificationBadge.siteSwitcherBtn = document.querySelector( '.m-site-country-selection__site-switcher a' );\n\n\t\t\t\telm.mNotificationBadge.windowResizeListener = utility.debounce( function debounceFunc() {\n\t\t\t\t\tvar fontSize = utility.removeMeasurementSuffix( window.getComputedStyle( elm.mNotificationBadge.barElm ).fontSize );\n\n\t\t\t\t\telm.mNotificationBadge.barElm.classList.add( 'm-site-country-selection--single-row' );\n\t\t\t\t\telm.mNotificationBadge.singleRow = true;\n\t\t\t\t\tmNotificationBadgeFn.showHide( elm, true, true );\n\t\t\t\t\tif ( elm.offsetHeight > ( mNotificationBadgeFn.notificationHeight * fontSize ) ) {\n\t\t\t\t\t\telm.mNotificationBadge.barElm.classList.remove( 'm-site-country-selection--single-row' );\n\t\t\t\t\t\telm.mNotificationBadge.singleRow = false;\n\t\t\t\t\t\tif ( elm.mNotificationBadge.countrySelectorBtn && elm.mNotificationBadge.countrySelectorBtn.classList.contains( 'is-open' ) ) {\n\t\t\t\t\t\t\tmNotificationBadgeFn.showHide( elm, false, true );\n\t\t\t\t\t\t} else if ( elm.mNotificationBadge.siteSwitcherBtn && elm.mNotificationBadge.siteSwitcherBtn.classList.contains( 'is-open' ) ) {\n\t\t\t\t\t\t\tmNotificationBadgeFn.showHide( elm, false, true );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 10 );\n\n\t\t\t\twindow.addEventListener( 'resize', elm.mNotificationBadge.windowResizeListener );\n\t\t\t\telm.mNotificationBadge.windowResizeListener();\n\t\t\t}\n\n\t\t\tif ( 'ResizeObserver' in window ) {\n\t\t\t\t// Check if the notification is a single line. If so apply alternative styling.\n\t\t\t\telmResizeObserver = new ResizeObserver( function listener( entries ) {\n\t\t\t\t\tvar fontSize = utility.removeMeasurementSuffix( window.getComputedStyle( elm.mNotificationBadge.barElm ).fontSize );\n\n\t\t\t\t\tentries.forEach( function loop( entry ) {\n\t\t\t\t\t\tif ( entry.contentBoxSize[ 0 ].blockSize > ( mNotificationBadgeFn.notificationHeight * fontSize ) ) {\n\t\t\t\t\t\t\telm.classList.remove( 'm-notification-badge--shallow' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\telm.classList.add( 'm-notification-badge--shallow' );\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\telmResizeObserver.observe( elm );\n\t\t\t}\n\t\t},\n\n\t\tannounceClose : function( success ) {\n\t\t\t// Enable aria alert that cookie policy settings successfully saved\n\t\t\tvar cookieMessage,\n\t\t\t\tcookieMessageText;\n\n\t\t\tif ( success ) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\tcookieMessageText = document.createTextNode( FRAMEWORK.locale.settings.mNotificationBadge.failed );\n\n\t\t\t\tcookieMessage = document.createElement( 'p' );\n\t\t\t\tcookieMessage.setAttribute( 'role', 'alert' );\n\t\t\t\tcookieMessage.classList.add( 'u-hidden--visually' );\n\t\t\t\tcookieMessage.append( cookieMessageText );\n\t\t\t\tdocument.body.append( cookieMessage );\n\n\t\t\t\t// Time out to remove cookie successfully saved message\n\t\t\t\tsetTimeout( function timeoutFn() {\n\t\t\t\t\tcookieMessage.remove();\n\t\t\t\t}, 5000 );\n\t\t\t}\n\t\t},\n\t};\n\n\treturn {\n\t\tinitInstance : function( el ) {\n\t\t\treturn mNotificationBadgeFn.init( el );\n\t\t},\n\t};\n});\n"]}