window.dataLayer=window.dataLayer||[];window.wawGtmPush=function(p){window.dataLayer.push(p)};(function(w,d,s,l){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'?l='+l:'';j.async=true;j.src= 'https://metricsatwork.woolworths.com.au/y0A3/'+dl;f.parentNode.insertBefore(j,f);}) (window,document,'script','dataLayer'); (function () { // The auth-aware LWC resolves this promise after skipping guests or storing // the authenticated shopper JWT. Chat still starts after the timeout if the // component is unavailable. var JWT_WAIT_MS = 5000; var releaseJwtWait; var jwtReady = new Promise(function (resolve) { releaseJwtWait = resolve; }); window.wawBeaChat = { jwtReady: jwtReady, markJwtReady: releaseJwtWait }; window.setTimeout(releaseJwtWait, JWT_WAIT_MS); window.chatWidget = window.chatWidget || {}; window.chatWidget.vaHeaderScript = function () { try { var host = (window.location && window.location.hostname || '').toLowerCase(); var origin = 'https://chatwidget.woolworths.com.au'; if (host.indexOf('wawdev') > -1) { origin = 'https://chatwidget-dev.woolworths.com.au'; } else if ( host.indexOf('sandbox') > -1 || host.indexOf('uat') > -1 || host.indexOf('sit') > -1 || host.indexOf('test') > -1 ) { origin = 'https://chatwidget-test.woolworths.com.au'; } var widgetSrc = origin + '/bootstrap/chatWidgetBootstrap.js'; if (document.querySelector('script[src="' + widgetSrc + '"]')) { return; } var script = document.createElement('script'); script.type = 'text/javascript'; script.src = widgetSrc; script.async = false; script.defer = true; script.onload = function () { if ( !window.chatWidget || window.chatWidget.unsupportedBrowserDetected || typeof window.chatWidget.bootstrapWithClean !== 'function' || typeof window.chatWidget.onStartChat !== 'function' ) { return; } jwtReady.then(function () { window.chatWidget.bootstrapWithClean(); window.chatWidget.onStartChat({ startMinimised: true, setCornerMode: true }); }); }; document.head.appendChild(script); } catch (err) { // Chat must never block storefront rendering. } }; if (document.readyState === 'complete') { window.chatWidget.vaHeaderScript(); } else { window.addEventListener('load', window.chatWidget.vaHeaderScript, false); } })();