



    
    
        
        window.__lpEnvSite = "21991129";
        
        window.__watchDogURL = "https://va-healthcheck-service.public.openaiplatform.telstra.com/codi_consumer_health";
        window.__businessWatchDogURL = "https://va-healthcheck-service.public.openaiplatform.telstra.com/codi_business_health";
        Object.defineProperty(window,"__loadLivePersonSrc",{value:function(){
window.lpTag=window.lpTag||{},'undefined'==typeof window.lpTag._tagCount?(window.lpTag={wl:lpTag.wl||null,scp:lpTag.scp||null,site:window.__lpEnvSite||'81478844',section:lpTag.section||'',tagletSection:lpTag.tagletSection||null,autoStart:lpTag.autoStart!==!1,ovr:lpTag.ovr||{},_v:'1.10.0',_tagCount:1,protocol:'https:',events:{bind:function(t,e,i){lpTag.defer(function(){lpTag.events.bind(t,e,i)},0)},trigger:function(t,e,i){lpTag.defer(function(){lpTag.events.trigger(t,e,i)},1)}},defer:function(t,e){0===e?(this._defB=this._defB||[],this._defB.push(t)):1===e?(this._defT=this._defT||[],this._defT.push(t)):(this._defL=this._defL||[],this._defL.push(t))},load:function(t,e,i){var n=this;setTimeout(function(){n._load(t,e,i)},0)},_load:function(t,e,i){var n=t;t||(n=this.protocol+'//'+(this.ovr&&this.ovr.domain?this.ovr.domain:'lptag.liveperson.net')+'/tag/tag.js?site='+this.site);var o=document.createElement('script');o.setAttribute('charset',e?e:'UTF-8'),i&&o.setAttribute('id',i),o.setAttribute('src',n),document.getElementsByTagName('head').item(0).appendChild(o)},init:function(){this._timing=this._timing||{},this._timing.start=(new Date).getTime();var t=this;window.attachEvent?window.attachEvent('onload',function(){t._domReady('domReady')}):(window.addEventListener('DOMContentLoaded',function(){t._domReady('contReady')},!1),window.addEventListener('load',function(){t._domReady('domReady')},!1)),'undefined'===typeof window._lptStop&&this.load()},start:function(){this.autoStart=!0},_domReady:function(t){this.isDom||(this.isDom=!0,this.events.trigger('LPT','DOM_READY',{t:t})),this._timing[t]=(new Date).getTime()},vars:lpTag.vars||[],dbs:lpTag.dbs||[],ctn:lpTag.ctn||[],sdes:lpTag.sdes||[],hooks:lpTag.hooks||[],identities:lpTag.identities||[],ev:lpTag.ev||[]},lpTag.init()):window.lpTag._tagCount+=1;        }});
        window.__disableVA = false;
        window.__disableBusinessVA = false;
        window.dtcDisabledPages = "https://www.telstra.com.au/chatnow/landing";
        window.lpSettings = window.lpSettings || {
          "heading": "Need help?",
          "description": "Please tell us what you'd like to message us about",
          "persistentChat": true,
          "options": {"route0": {"label": "Mobile & Tablet Plans","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-mobile,virtualassistant","lead": "MOB-bill-plan-addon","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/support/category/account-billing/understand-bill' target='_blank'>I need to understand my bill</a><br><a href='https://say.telstra.com.au/customer/general/forms/Advise-Telstra-of-a-payment' target='_blank'>Report a payment or reconnect my service</a><br><a href='https://www.my.telstra.com.au/myaccount/payment-extension' target='_blank'>Request a payment extension</a><br><a href='https://www.telstra.com.au/setupdirectdebit' target='_blank'>Arrange or update direct debit</a><br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my upgrade and recontracting fees</a><br>"}, "route1": {"label": "Buy Online","isActive": "true","section": "sales-mobile","lead": "MOB-buy-online","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/mobile-phones/mobiles-on-a-plan#!/filter/brand//os//features//plan/s/sort/featured' target='_blank'>Order a new mobile</a><br><a href='https://www.telstra.com.au/mobile-phones/sim-only-plans' target='_blank'>Get a SIM only plan</a><br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my upgrade date and fees</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a><br><a href='https://crowdsupport.telstra.com.au/t5/Accounts-Plans/Orders-and-Backorders-FAQ/ta-p/546953' target='_blank'>Get help with a back order</a>"}, "route2": {"label": "Existing Order","isActive": "true","section": "service-general,virtualassistant","lead": "MOB-existing-order","help": "<b>Delays to some order deliveries</b><br><br>COVID-19 impacts are causing delays on some orders. Your order should arrive within 7 days in metro locations, while some regional orders may take longer. We're doing everything we can to get your order to you quickly and apologise for the inconvenience..<br><br><b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a><br><a href='https://crowdsupport.telstra.com.au/t5/Accounts-Plans/Orders-and-Backorders-FAQ/ta-p/546953' target='_blank'>Cancel or change my order</a><br><a href='https://www.telstra.com.au/help/critical-information-summaries/personal' target='_blank'>Confirm my plan details</a><br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my contract termination fees</a><br><a href='https://crowdsupport.telstra.com.au/t5/Accounts-Plans/Orders-and-Backorders-FAQ/ta-p/546953' target='_blank'>Get help with a back order</a>"}, "route3": {"label": "Fault","isActive": "true","section": "fault-mobile,virtualassistant","lead": "MOB-fault","help": "<b>Help &amp; Support</b> <br><a href='http://mobilesupport.telstra.com.au/' target='_blank'>View our interactive mobile help guides</a><br><a href='https://outages.telstra.com.au/' target='_blank'>Check for outages</a>"}, "route4": {"label": "SIM Replacement","isActive": "true","section": "mobile-sim-deflect","lead": "MOB-sim-rep"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "MOB-disconnection"}, "route6": {"label": "Other","isActive": "true","section": "service-general,mob-other,virtualassistant","lead": "MOB-other","help": "<b>Help &amp; Support</b> <br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my contract termination fees</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a><br><a href='https://www.telstra.com.au/support/category/account-billing/understand-bill' target='_blank'>I need to understand my bill</a><br><a href='http://support.telstra.com.au/t5/Support/ct-p/Support' target='_blank'>Try our online support articles</a>"}}}, "route1": {"label": "Pre-Paid","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Activate & Recharge","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-activate-recharge","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/how-to-activate-your-pre-paid-service' target='_blank'>How to activate my Pre-Paid service</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/how-to-recharge-your-pre-paid-service' target='_blank'>How to recharge my Pre-Paid service</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/new-payment-options' target='_blank'>Payment options</a><br><a href='https://www.my.telstra.com.au/myaccount/track-my-order' target='_blank'>Check my activation status</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid' target='_blank'>Check out our Pre-Paid support articles</a>"}, "route1": {"label": "Existing Order","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-existing-order","help": "<b>Delays to some order deliveries</b><br><br>COVID-19 impacts are causing delays on some orders. Your order should arrive within 7 days in metro locations, while some regional orders may take longer. We're doing everything we can to get your order to you quickly and apologise for the inconvenience.<br><br><b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/how-to-activate-your-pre-paid-service' target='_blank'>How to activate my Pre-Paid service</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/check-or-change-your-pre-paid-offer' target='_blank'>How to change my plan</a><br><a href='https://www.my.telstra.com.au/myaccount/track-my-order' target='_blank'>Check my activation status</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid' target='_blank'>Check out our Pre-Paid support articles</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a>"}, "route2": {"label": "Offers & Plans","isActive": "true","section": "prepaid,virtualassistant","lead": "PPM-my-offer-plan","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/check-or-change-your-pre-paid-offer' target='_blank'>View or change my plan</a><br><a href='https://www.telstra.com.au/mobile-phones/prepaid-mobiles/offers-and-rates?ti=TR:TR:Prepaidmobile:prepaidplans' target='_blank'>Explore available plans</a><br><a href='https://www.telstra.com.au/mobile-phones/prepaid-mobiles/plus-packs' target='_blank'>Pre-Paid Plus packs</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/pre-paid-expiry-periods' target='_blank'>Pre-Paid expiry period</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/other/international-roaming-with-your-prepaid-service' target='_blank'>International roaming</a>"}, "route3": {"label": "Fault","isActive": "true","section": "fault-prepaid,virtualassistant","lead": "PPM-fault","help": "<b>Help &amp; Support</b> <br><a href='https://outages.telstra.com.au/' target='_blank'>Check for outages</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/unlocking-your-telstra-mobile-device' target='_blank'>Unlock my Telstra mobile</a><br><a href='http://support.telstra.com.au/t5/Pre-Paid/Pre-Paid-troubleshooting-tips/ta-p/398341' target='_blank'>Pre-Paid troubleshooting tips</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid' target='_blank'>Pre-Paid support articles</a>"}, "route4": {"label": "SIM Replacement","isActive": "true","section": "prepaid-sim-deflect","lead": "PPM-sim-rep","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid/unlocking-your-telstra-mobile-device' target='_blank'>Unlock my Telstra mobile</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a><br><a href='https://crowdsupport.telstra.com.au/t5/Accounts-Plans/Orders-and-Backorders-FAQ/ta-p/546953' target='_blank'>Cancel or change my order</a><br><a href='https://www.telstra.com.au/support/category/mobiles-tablets/pre-paid' target='_blank'>Pre-Paid support articles</a>"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "PPM-disconnection"}}}, "route2": {"label": "NBN & Bundles","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Buy Online","isActive": "true","section": "sales-nbn","lead": "NBN-buy-online","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/internet' target='_blank'>Order a new service</a><br><a href='https://www.telstra.com.au/deals' target='_blank'>See latest offers</a><br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my upgrade date and fees</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a>"}, "route1": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-nbn,virtualassistant","lead": "NBN-bill-plan-addon","help": "<b>Help &amp; Support</b><br><a href='https://www.my.telstra.com.au/myaccount/payment-extension' target='_blank'>Request a payment extension</a><br><a href='https://say.telstra.com.au/customer/general/forms/Advise-Telstra-of-a-payment' target='_blank'>Report a payment or reconnect my service</a><br><a href='https://www.my.telstra.com.au/myaccount/paybill#/empty' target='_blank'>I want to pay my bill</a><br><a href='https://www.telstra.com.au/support/category/account-billing/understand-bill' target='_blank'>I need to understand my bill</a><br><a href='https://www.telstra.com.au/setupdirectdebit' target='_blank'>Arrange or update direct debit</a>"}, "route2": {"label": "Existing Order","isActive": "true","section": "nbn-orders,virtualassistant","lead": "NBN-existing-order","help": "<b>Delays to some order deliveries</b><br><br>COVID-19 impacts are causing delays on some orders. Your order should arrive within 7 days in metro locations, while some regional orders may take longer. We're doing everything we can to get your order to you quickly and apologise for the inconvenience.<br><br><b>Help &amp; Support</b><br><a href='https://www.ordertracker.telstra.com.au/' target='_blank'>Track my order</a><br><a href='https://www.telstra.com.au/appointments' target='_blank'>Reschedule my appointment</a>"}, "route3": {"label": "Moving Home","isActive": "true","section": "nbn-moves,virtualassistant","lead": "NBN-moving-home","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/moving-house' target='_blank'>Move my service to another address</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a>"}, "route4": {"label": "Fault","isActive": "true","section": "fault-nbn,virtualassistant","lead": "NBN-fault","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/support/category/broadband/nbn/getting-nbn-ready.html' target='_blank'>Connecting my new service</a><br><a href='https://outages.telstra.com.au/' target='_blank'>Check for outages</a><br><a href='https://www.telstra.com.au/support/category/broadband/nbn/faq.html' target='_blank'>Troubleshooting and tech support</a><br><a href='https://www.telstra.com.au/support/category/broadband/nbn/using-nbn.html' target='_blank'>How to use my service</a><br><a href='https://www.telstra.com.au/support/category/broadband/nbn/speeds-and-usage' target='_blank'>Connection speed</a>"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "NBN-disconnection"}}}, "route3": {"label": "Broadband, Bundles & Home Phone","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "Buy Online","isActive": "true","section": "sales-home,virtualassistant","lead": "BBHP-buy-online","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/internet' target='_blank'>Order a new service</a><br><a href='https://www.telstra.com.au/deals' target='_blank'>See latest offers</a><br><a href='https://www.my.telstra.com.au/myaccount/contract-details' target='_blank'>Check my upgrade date and fees</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a>"}, "route1": {"label": "Bill & Plan Enquiries","isActive": "true","section": "service-home,virtualassistant","lead": "BBHP-bill-plan-addon","help": "<b>Help &amp; Support</b><br><a href='https://www.my.telstra.com.au/myaccount/payment-extension' target='_blank'>Request a payment extension</a><br><a href='https://say.telstra.com.au/customer/general/forms/Advise-Telstra-of-a-payment' target='_blank'>Report a payment or reconnect my service</a><br><a href='https://www.telstra.com.au/support/category/account-billing/understand-bill' target='_blank'>I need to understand my bill</a><br><a href='https://www.telstra.com.au/setupdirectdebit' target='_blank'>Arrange or update direct debit</a><br><a href='https://say.telstra.com.au/customer/forms/request-a-credit' target='_blank'>I want to query a charge on my bill</a>"}, "route2": {"label": "Existing Order","isActive": "true","section": "service-bundles-home,virtualassistant","lead": "BBHP-existing-order","help": "<b>Delays to some order deliveries</b><br><br>COVID-19 impacts are causing delays on some orders. Your order should arrive within 7 days in metro locations, while some regional orders may take longer. We're doing everything we can to get your order to you quickly and apologise for the inconvenience.<br><br><b>Help &amp; Support</b><br><a href='https://www.ordertracker.telstra.com.au/' target='_blank'>Track my order</a><br><a href='https://www.telstra.com.au/appointments' target='_blank'>Reschedule my appointment</a>"}, "route3": {"label": "Moving Home","isActive": "true","section": "copper-moves,virtualassistant","lead": "BBHP-moving-home","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/moving-house' target='_blank'>Move my service to another address</a><br><a href='https://www.telstra.com.au/support/category/account-billing/manage-account/how-to-track-your-order' target='_blank'>Track my order</a>"}, "route4": {"label": "Fault","isActive": "true","section": "fault-adsl,virtualassistant","lead": "BBHP-fault","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/support/category/broadband/adsl-cable-velocity/connecting.html' target='_blank'>Connecting my new service</a><br><a href='https://outages.telstra.com.au/' target='_blank'>Check for outages</a><br><a href='https://www.telstra.com.au/support/category/broadband/adsl-cable-velocity/fix' target='_blank'>Troubleshooting and tech support</a><br><a href='https://www.telstra.com.au/support/category/broadband/mobile-broadband' target='_blank'>Mobile broadband tech support</a><br><a href='https://www.telstra.com.au/support/category/broadband/adsl-cable-velocity/speeds-and-usage' target='_blank'>Connection speed</a>"}, "route5": {"label": "Disconnection","isActive": "true","section": "saves","lead": "BBHP-disconnection"}}}, "route4": {"label": "Entertainment & Apps","isActive": "true","section": "telstra,service,aem,consumer","childs": {"route0": {"label": "My Telstra","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-247-app","help": "<b>Help &amp; Support</b><br><a href='https://id.telstra.com.au/register' target='_blank'>Register for a Telstra ID</a><br><a href='https://myacct.telstra.com/forgottenUsername?execution=e2s1' target='_blank'>Retrieve my Telstra ID username</a><br><a href='https://myacct.telstra.com/forgottenPassword?execution=e1s1' target='_blank'>Retrieve my Telstra ID password</a>"}, "route1": {"label": "Telstra Plus","isActive": "true","section": "telstra-plus,virtualassistant","lead": "EAA-telstraplus","help": "<b>Help &amp; Support</b><br/><a href='https://telstra.com.au/plus' target='_blank'>Join Telstra Plus</a><br><a href='https://telstra.com.au/plus' target='_blank'>Find out more about Telstra Plus</a><br><a href='https://www.telstra.com.au/plus/frequently-asked-questions' target='_blank'>View Telstra Plus FAQ</a><br><a href='https://id.telstra.com.au/register' target='_blank'>Register for a Telstra ID</a><br><a href='https://myacct.telstra.com/forgottenUsername?execution=e2s1' target='_blank'>Retrieve my Telstra ID username</a><br><a href='https://myacct.telstra.com/forgottenPassword?execution=e1s1' target='_blank'>Retrieve my Telstra ID password</a>"}, "route2": {"label": "Email","isActive": "true","section": "fault-email,virtualassistant","lead": "EAA-email","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/webforms/cares' target='_blank'>Troubleshoot email for PC</a><br><a href='http://mobilesupport.telstra.com.au/' target='_blank'>Troubleshoot email for mobile device</a><br><a href='https://www.telstra.com.au/support/category/email/manage/change-a-mailbox-password' target='_blank'>Forgot my username or password</a>"}, "route3": {"label": "Foxtel","isActive": "true","section": "foxtel,virtualassistant","lead": "EAA-foxtel","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/support/category/entertainment/foxtel-from-telstra/faq' target='_blank'>Foxtel FAQs</a><br><a href='https://www.telstra.com.au/support/category/entertainment/foxtel-from-telstra/how-to' target='_blank'>Foxtel from Telstra – Set up and configure</a><br><a href='https://www.telstra.com.au/support/category/entertainment/foxtel-from-telstra/apps' target='_blank'>Foxtel Go</a>"}, "route4": {"label": "Telstra TV & Telstra TV Box Office","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-telstra-tv-box-office","help": "<b>Help &amp; Support</b> <br><a href='https://www.telstra.com.au/entertainment/tv-movies/telstra-tv' target='_blank'>Find out more about Telstra TV</a><br><a href='https://www.telstratv.com/boxoffice/' target='_blank'>Sign in to Telstra Box Office</a><br><a href='https://www.telstratv.com/boxoffice/support' target='_blank'>Telstra Box Office FAQs</a><br>"}, "route5": {"label": "Telstra Air","isActive": "true","section": "service-apps,virtualassistant","lead": "EAA-telstra-air","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/telstra-air' target='_blank'>Telstra Air – all you need to know</a>"}, "route6": {"label": "Platinum","isActive": "true","section": "platinum","lead": "EAA-platinum","help": "<b>Help &amp; Support</b><br><a href='https://www.telstra.com.au/platinum-technical-support' target='_blank'>Telstra Platinum</a>"}}}, "route5": {"label": "Business Accounts & Products","isActive": "true","section": "telstra,service,aem,consumer,business,businessva","lead": "BAAP-none","childs": {}}},
          "enableDTC": true,
          "enableBusinessDTC": false,
          "dtcSection": "tcom,non-auth,telstra,service,aem,consumer,dtc,virtualassistant",
          "dtcBusinessSection": "",
          "chatEverywhereLabel": "Message us",
          "dtcLabel": "Message us",
          "abcEnabled": false,
          "abcBusinessId": "5658cef3-b53e-11e7-847d-7b88b04daa8e",
          "bizIntentId": "ios_general",
          "bizGroupId": "",
          "body": "",
          "abcButtonDelay": "10000",
          "contactUsABCEnabled": false,
          "authEnabled": true,
          "v2AuthEnabled": true,
          "allowedPages": "www.myservices.telstra.com.au/*,fix.telstra.com/*,plus.telstra.com.au/*,checkout.telstra.com.au/*,www.telstra.com.au/*,www.my.telstra.com.au/myaccount/*,prepaid.activate.telstra.com.au/*,recharge.telstra.com.au/*,www.ordertracker.telstra.com.au/*,say.telstra.com.au/customer/forms/request-a-credit-form,shop.telstra.com.au/*",
          "v2AllowedPages": "fix.telstra.com/*,www.myservices.telstra.com.au/*,www.telstra.com.au/*,plus.telstra.com.au/*",
          "engCollectTimeout": "1500",
          "ssoUrl": "https://chat-messaging.public.openaiplatform.telstra.com",
          "retrieveUrl": "https://tapi.telstra.com/presentation/v1/va-chatservices/retrieve-lp-auth-objects",
          "retrieveV2Url": "https://tapi.telstra.com/presentation/v1/va-chatservices/lp-auth-objects",
          "ssoTimeout": "4500",
          "retrieveTimeout": "5000",
          "tacticalAbcEnabled": false,
          "disableDragDropFileUpload": false,
          "enableMTRedirection": false,
          "minIOSAppVerForMTRedirect": "70.0",
          "minAndroidAppVerForMTRedirect": "70.0",
          "mtwIOSHostName": "https://www.myservices.telstra.com.au",
          "mtwAndroidHostName": "https://www.myservices.telstra.com.au",
          "tacticalTCOMAuthEnabled": false,
          "tcomPrefix": "www",
          "tcomLightBoxCssSelector": ""
        };
try {
  if (window.TelstraLivePerson) {
    // prevent redeclaration of the class
    throw new Error('Can not redefine this object');
  }
  Object.defineProperty(window, 'TelstraLivePerson', {
    value: function (__config) {
      const _config = JSON.parse(JSON.stringify(__config));
      const _instance = this;
      const _tcomPrefix = _config.tcomPrefix || 'www';
      const _mtwIOSHostName = _config.mtwIOSHostName;
      const _mtwAndroidHostName = _config.mtwAndroidHostName;
      const disableDragDropFileUpload = _config.disableDragDropFileUpload;
      let _dragDropOverridden = false;
      let defaultSignInUrl = {
        msg: "Looks like this session has timed out. Sign back in to continue your conversation, or go to My Telstra and select 'Message us' to reply.",
        url: 'https://open.mytelstra.app/BJRB/804999cc',
        label: 'Go to My Telstra',
        action: 'navigate'
      };
      let defaultAuthDisabledUrl = {
        msg: "This is a secure conversation which can only be continued on specific Telstra pages. If you wish to continue this conversation, please go to My Telstra and select 'Message us' to reply.",
        action: 'navigate',
        label: 'Go to My Telstra',
        url: 'https://open.mytelstra.app/BJRB/804999cc'
      };
      const signInUrls = { '*': defaultSignInUrl };
      signInUrls[document.location.origin] = defaultSignInUrl;
      let _mySignInUrl = signInUrls['*'];
      const siuXhr = new XMLHttpRequest();
      siuXhr.onreadystatechange = function () {
        if (siuXhr.readyState === siuXhr.DONE) {
          if (siuXhr.status === 200) {
            try {
              Object.assign(signInUrls, JSON.parse(siuXhr.responseText));
              _mySignInUrl = signInUrls[document.location.origin];
              if (signInUrls['*']) {
                defaultSignInUrl = signInUrls['*'];
              }
              if (signInUrls['defaultAuthDisabled']) {
                defaultAuthDisabledUrl = signInUrls['defaultAuthDisabled'];
              }
            } catch (e) {}
          }
        }
      };
      siuXhr.open(
        'GET',
        'https://' +
          _tcomPrefix +
          '.telstra.com.au/content/dam/tcom/virtualassistant/config/t-lp-err-msg' +
          (window.__lpEnvSite === '21991129' ? '-pr' : '-np') +
          '.json'
      );
      siuXhr.send();
      const checkPageAllowedForAuth = function (thisPage, allowedPages) {
        let allowedList = allowedPages.split(',');
        let allowed = false;
        let listItem;
        for (let i = 0; i < allowedList.length; i++) {
          listItem = 'https://' + allowedList[i];
          let lastChar = listItem.substr(listItem.length - 1, 1);
          if (lastChar === '*') {
            allowed =
              thisPage.substr(0, listItem.length - 1) ===
              listItem.substr(0, listItem.length - 1);
          } else {
            allowed = thisPage === listItem;
          }
          if (allowed) {
            break;
          }
        }
        return allowed;
      };
      const isAllowedOriginForAuth = checkPageAllowedForAuth(
        document.location.origin + document.location.pathname,
        _config.allowedPages
      );
      let authIsEnabled =
        _config.authEnabled &&
        isAllowedOriginForAuth &&
        (typeof window.addEventListener === 'function' ||
          window.attachEvent === 'function');
      const isAllowedOriginForV2Auth = checkPageAllowedForAuth(
        document.location.origin + document.location.pathname,
        _config.v2AllowedPages
      );
      let authV2IsEnabled = _config.v2AuthEnabled && isAllowedOriginForV2Auth;
      const ssoUrl = _config.ssoUrl;
      let cid;
      const retrieveUrl = _config.retrieveUrl;
      const retrieveV2Url = _config.retrieveV2Url;
      let engCollectTimeout = parseInt(_config.engCollectTimeout);
      if (isNaN(engCollectTimeout)) {
        engCollectTimeout = 500;
      }
      let ssoTimeout = parseInt(_config.ssoTimeout);
      if (isNaN(ssoTimeout)) {
        ssoTimeout = 5000;
      }
      let retrieveTimeout = parseInt(_config.retrieveTimeout);
      if (isNaN(retrieveTimeout)) {
        retrieveTimeout = 2000;
      }
      const minAndroidAppVerForMTRedirect =
        _config.minAndroidAppVerForMTRedirect;
      const minIOSAppVerForMTRedirect = _config.minIOSAppVerForMTRedirect;
      let _globalMTRedirectEnabled;
      //
      const generateCorrelationId = function () {
        let id = '';
        try {
          id = encodeURIComponent(
            btoa(
              window.crypto
                .getRandomValues(new Uint8Array(32))
                .reduce(function (prev, curr) {
                  return prev + String.fromCharCode(curr);
                }, '')
            )
          );
        } catch (e) {
          for (let i = 0; i < 4; i++) {
            id =
              id +
              parseInt(((1 + Math.random()) * 0x10000).toFixed(0))
                .toString(32)
                .substring(1);
          }
        }
        return id;
      };
      const initConfig = JSON.parse(JSON.stringify(_config));
      Object.defineProperty(_instance, 'data', { value: initConfig });
      if (initConfig.abcButtonDelay) {
        // convert to number
        try {
          initConfig.abcButtonDelay = parseInt(initConfig.abcButtonDelay);
        } catch (e) {
          initConfig.abcButtonDelay = 100;
        }
      }
      let isChatEverywhereClick = false;
      _instance.persistentChatContainer = false;
      _instance.appleDeviceType = 'UNIDENTIFIED';
      _instance.backMask = false;
      _instance.container = false;
      _instance.containerBox = false;
      _instance.closeBT = false;
      _instance.childElements = {};
      _instance.siteId = false;
      _instance.section = [];
      _instance.sourceSection = [];
      _instance.isDirect = false;
      _instance.lead = false;
      _instance.urlMap = window.__lpUrlMap || false;
      _instance.callBack = false;
      _instance.callBackInterval = 1; // in second
      _instance.callBackTread = false;
      _instance.chatWindowOpen = false;
      // load jabuka.json using absolute url to ensure no errors if import.htm injected on page in any other domain
      Object.defineProperty(_instance, 'jabukaUrl', {
        value:
          'https://' +
          _tcomPrefix +
          '.telstra.com.au/content/dam/tcom/virtualassistant/config/jabuka.json'
      });
      let initParams = {};
      const _businessVaSection = 'businessvas';
      let _initCalled = false;
      let engagementName;
      let proactiveSuppressionCheck = false;
      let tacticalAbcEnabled = _config.tacticalAbcEnabled || false;
      let onChatWindowMinimized = null;
      let onChatWindowClosed = null;
      let minimizedFocusQuerySelector = null;
      let closedFocusQuerySelector = null;
      let _defaultMinimizedCallback = null;
      let _defaultClosedCallback = null;
      let _defaultMinimizedSelector = null;
      let _defaultClosedSelector = null;
      let _appVersion = -1;
      let _appPlatform = '';
      let calculatedMTRedirect = false;
      let preferMTRForMessageUs = false;
      const chatEverywhereSelector = 'button.msg-us-btn';
      const APP_VER_REGEX = /^\d+\.\d+(\.\d+)?$/;
      const triggers = [];
      let lpTagInitialized = false;
      let proactiveAutoClick = false;
      let trComponentInfo = null;
      let reactiveTRComponentInfo = null;
      let agentCtxInfo = [];
      let reactiveAgentCtxInfo = [];
      let processingTrigger = false;
      let _proactiveButtonLoad;
      // auth specific stuff
      let authInProgress = false;
      let ssoFrame = null;
      let ssoFrameContentWindow = null;
      let _token = null;
      let _id = null;
      let retrievalXHR = null;
      let retrievalV2XHR = null;
      let lpCallback = null;
      let ssoTimeoutHandle = null;
      let retrievalTimeoutHandle = null;
      let authForClick = false;
      let messageMonitorHandle = null;
      let messageUpdated = false;
      let cBlocking = false;
      let statType = 'NOT_AVAILABLE';
      let clicked = false;
      let _inputBoxFocus = false;
      let startStatSent = false;
      let impressionStatSent = false;
      let declinedStatSent = false;
      let statConvoId = 'n/a';
      let isProactive = false;
      let isReactive = false;
      var ignoreOffer = false;
      let engagementId;
      let stopCollectingEngagements = false;
      window.engagementsOffered = [];
      let impressionsTimeoutHandle = null;
      let previousEngagementType = 0;
      let convoStartedOnPage = false;
      let convoTriggerStartTime = 0;
      let monitorId = generateCorrelationId();
      let windowOpenMonitorHandle = null;
      let previousElement = null;
      let loadingIndicator = null,
        loadingSpinner,
        loadingMessage,
        loadingErrorIcon,
        loadingErrorMessage,
        loadingIndicatorCloseButton,
        loadingSpacer;
      let loadingIndicatorTimer = null;
      let dontShowLoadingIndicator = false;
      let loadingIndicatorAttached = false;
      let v3CtaCollapsed = false;
      let v3CtaTOHandle2, v3CtaTOHandle3;
      const MESSAGING_ACTION = '__messaging';
      const _businessWatchDogURL =
        window.__businessWatchDogURL || 'virtual-assistant-status';
      let _businessWatchDog = {
        'virtual-assistant-status': {
          orchestrator: false,
          'watson-virtual-agent': false,
          'liveperson-agent-api': false,
          'watson-tone-analyzer': false
        }
      };
      var loadedVA = [];
      var totalVA = 1; // update this if more VA are added on the page
      var postVALoadDone = false;
      let abcConfigLoaded = false;
      let _loadedAbcConfig = null;
      let _intent_id, _group_id;
      let abcUrlPrefix =
        'https://bcrw.apple.com/urn:biz:' + _instance.data.abcBusinessId;
      const _osExtractRegex =
        /\((Macintosh|iPhone|iPad|(?:iPod(?:\stouch)?));.*\s((?:\d[_.]{0,1})+)[^)]*\)\s/i;
      const _minSupportedMacOS = [10, 13, 4];
      const _minSupportedIOS = [11, 3];
      // calculate some of the dtc params here so that they are not re-calculated unnecessarily
      // do not consider query params or anchor tags when checking for current page url
      const _dtcDisabledPage = window.dtcDisabledPages.split(',');
      const thisPage = window.location.href.split(/[?#]/)[0];
      const isDTCDisabledPage = _dtcDisabledPage.indexOf(thisPage) != -1;
      const smlBusIndx = thisPage.indexOf('/small-business');
      const _isUnderSmallBusiness =
        thisPage.indexOf('/small-business/') != -1 ||
        (smlBusIndx != -1 &&
          thisPage.substring(smlBusIndx) == '/small-business');

      //
      const injectCss = function () {
        const messagingCss = document.createElement('link');
        messagingCss.setAttribute('rel', 'stylesheet');
        messagingCss.setAttribute(
          'href',
          'https://' +
            _tcomPrefix +
            '.telstra.com.au/content/dam/tcom/virtualassistant/css/lp-override-v2.css'
        );
        messagingCss.addEventListener('load', () => {
          document
            .querySelector('button#persistentChatBtnId')
            ?.removeAttribute('style');
        });
        document.head.appendChild(messagingCss);
      };
      try {
        injectCss();
      } catch (e) {
        sendNRPageAction(MESSAGING_ACTION, {
          err: e.message || 'css-inject-error',
          stack: e.stack || 'N/A'
        });
      }
      //
      const compareVersion = function (a, b) {
        let i, diff;
        let _a = '' + a,
          _b = '' + b;
        const regExStrip0 = /(\.0+)+$/;
        const v1Parts = _a.replace(regExStrip0, '').split('.');
        const v2Parts = _b.replace(regExStrip0, '').split('.');
        const minLength = Math.min(v1Parts.length, v2Parts.length);

        for (i = 0; i < minLength; i++) {
          diff = parseInt(v1Parts[i], 10) - parseInt(v2Parts[i], 10);
          if (diff) {
            return diff;
          }
        }
        return v1Parts.length - v2Parts.length;
      };
      //
      const sendNRPageAction = function (actionName, actionPayload) {
        try {
          if (newrelic && newrelic.addPageAction) {
            newrelic.addPageAction(
              actionName,
              Object.assign(actionPayload, { _monitorId: monitorId })
            );
          }
        } catch (e) {}
      };
      //
      const doInputBoxFocus = function () {
        if (_inputBoxFocus) {
          return;
        }
        _inputBoxFocus = true;
        setTimeout(function () {
          try {
            document
              .querySelector('textarea.lpview_form_textarea')
              .focus({ focusVisible: true });
          } catch (e) {}
        }, 2000);
      };
      //
      const doAssetFocus = function (
        op,
        handlerFn,
        querySelector,
        isChatEverywhereClick
      ) {
        setTimeout(function () {
          let focusElement, defaultFocusElement;
          let defaultSelector =
            op === 'minimized'
              ? _defaultMinimizedSelector
              : isChatEverywhereClick
              ? chatEverywhereSelector
              : _defaultClosedSelector;
          let defaultHandlerFn =
            op === 'minimized'
              ? _defaultMinimizedCallback
              : _defaultClosedCallback;
          try {
            defaultFocusElement = document.querySelector(defaultSelector);
          } catch (e) {
            defaultFocusElement = null;
          }
          try {
            focusElement = document.querySelector(
              isChatEverywhereClick && op === 'closed'
                ? chatEverywhereSelector
                : querySelector
            );
          } catch (e) {
            focusElement = null;
          }
          try {
            if (typeof handlerFn === 'function') {
              handlerFn();
            } else if (
              focusElement &&
              typeof focusElement.focus === 'function'
            ) {
              focusElement.focus({ focusVisible: true });
            } else if (typeof defaultHandlerFn === 'function') {
              defaultHandlerFn();
            } else if (
              defaultFocusElement &&
              typeof defaultFocusElement.focus === 'function'
            ) {
              defaultFocusElement.focus({ focusVisible: true });
            } else if (
              previousElement &&
              typeof previousElement.focus === 'function'
            ) {
              previousElement.focus({ focusVisible: true });
              previousElement = null;
            }
          } catch (e) {
            sendNRPageAction(
              ('__lp__' + handlerFn && handlerFn.name) ||
                (defaultHandlerFn && defaultHandlerFn.name) ||
                'generic_error',
              {
                err: e.message || JSON.stringify(e),
                stack: e.stack || 'N/A',
                selector: querySelector,
                defaultSelector: defaultSelector
              }
            );
          }
        }, 1000);
      };
      // extract device type and os version

      function _isMinSupportedVersion(referenceVersion, versionUnderTest) {
        for (var i = 0; i < referenceVersion.length; i++) {
          if (versionUnderTest[i] < referenceVersion[i]) {
            // most significant version at this point is lower than reference so we can mark unsupported
            return false;
          }
          if (versionUnderTest[i] > referenceVersion[i]) {
            // most significant version at this point is greater than reference so we can mark supported
            return true;
          }
          // most significant version at this point is equal to reference. continue loop to check next version element
        }
        // all version elements equal reference so we can mark supported
        return true;
      }
      const checkABCCompatibleDevice = function () {
        var isCompatibleDevice = false;
        try {
          var ua = (window.navigator && window.navigator.userAgent) || '';
          var extracted = _osExtractRegex.exec(ua);
          if (extracted) {
            var deviceType = extracted[1].toLowerCase();
            var extractedOSVersion = extracted[2]
              .replace(/_/g, '.')
              .split('.')
              .map(function (ver) {
                var intVer = 0;
                try {
                  intVer = parseInt(ver);
                } catch (e) {
                  // ignore parsing errors and just set it to 0
                  // that way, it will always be lesser than supported version
                }
                return intVer;
              });
            if (deviceType == 'macintosh') {
              // this could be iPad since iPadOS returns same UA string as Mac
              // as of Nov 2019, no touch enabled mac laptop/desktop exists. so if this browser has touch events available, it is iPad
              // this is the only way at the moment to identify if this is iPad or not
              if (window.navigator.maxTouchPoints > 1) {
                // desktop/laptop won't have touch points. if touch points exists, it is a touch screen device, which at the moment implies iPadOS
                // all iPadOS versions will support ABC so no further checks required
                isCompatibleDevice = true;
                _instance.appleDeviceType = 'tablet';
              }
            } else {
              isCompatibleDevice = _isMinSupportedVersion(
                _minSupportedIOS,
                extractedOSVersion
              );
              _instance.appleDeviceType = 'mobile';
            }
          }
        } catch (e) {
          // wrapped in try catch so that if any of the expressions fail in older browser, it doesn't cause issues with rest of the script
        }
        return isCompatibleDevice;
      };
      Object.defineProperty(_instance, 'isABCCompatibleDevice', {
        value: checkABCCompatibleDevice()
      });

      //
      function convertChatButtonToMessaging() {
        if (
          !_instance.data.abcEnabled ||
          !_instance.isABCCompatibleDevice ||
          !_instance.data.contactUsABCEnabled
        ) {
          // don't bother if abc disabled or not abc compatible device or contact us pages are not supposed to be converted to
          return;
        }
        try {
          var originalOnLoad = window.onload;
          window.onload = function () {
            var buttons = Array.from(document.getElementsByTagName('a'))
              .filter(function (tag) {
                return tag && /#lp:2way$/.test(tag.href);
              })
              .filter(function (tag) {
                return (
                  tag &&
                  tag.classList &&
                  tag.innerText &&
                  tag.classList.contains('btn') &&
                  tag.classList.contains('primary') &&
                  tag.innerText == 'Chat now'
                );
              });
            if (buttons && buttons.length > 0) {
              buttons[0].href = abcUrlPrefix;
              buttons[0].text = 'Message Us';
            }
            if (originalOnLoad && typeof originalOnLoad === 'function') {
              originalOnLoad();
            }
          };
        } catch (e) {
          // wrapping in try catch so that no other functionality gets impacted
        }
      }
      const isDTCApplicableOnPage = function () {
        // not applicable if relevant DTC flag is off or if relevant VA is not active
        if (
          (_isUnderSmallBusiness &&
            (!_config.enableBusinessDTC || !_instance.isBusinessVAActive())) ||
          (!_isUnderSmallBusiness && !_config.enableDTC)
        ) {
          return false;
        }
        // return false if this is a DTC disabled page
        return !isDTCDisabledPage;
      };
      Object.defineProperty(_instance, 'isBusinessVAActive', {
        value: function () {
          return true;
        }
      });

      /**
       * All Function Definitions follow
       */
      //
      const sendUrlSDE = function () {
        window.lpTag.sdes.push({
          type: 'lead',
          lead: {
            topic: document.location.href,
            leadId: 'siteUrl'
          }
        });
      };
      //
      const sendAgentCtxInfo = function () {
        let ctxInfo = null;
        if (isProactive) {
          if (!agentCtxInfo || agentCtxInfo.length === 0) {
            return;
          } else {
            ctxInfo = agentCtxInfo;
          }
        } else if (isReactive) {
          if (!reactiveAgentCtxInfo || reactiveAgentCtxInfo.length === 0) {
            return;
          } else {
            ctxInfo = reactiveAgentCtxInfo;
          }
        }
        if (ctxInfo === null) {
          return;
        }
        try {
          ctxInfo.map((info) => {
            lpTag.sdes.push({
              type: 'error',
              error: { contextId: info.label, message: info.value }
            });
          });
        } catch (e) {}
      };
      //
      const _asyncLoad = setTimeout(function () {
        if (document.getElementsByTagName('body').length != 0) {
          _instance.backMask = document.createElement('DIV');
          _instance.backMask.setAttribute(
            'class',
            'telstra_live_person_back hide'
          );
          _instance.container = document.createElement('DIV');
          _instance.container.setAttribute(
            'class',
            'telstra_live_person_container modal-content'
          );
          _instance.containerBox = document.createElement('DIV');
          _instance.containerBox.setAttribute(
            'class',
            'telstra_live_person_containerBox hide'
          );
          _instance.containerBox.appendChild(_instance.container);

          _instance.closeBT = document.createElement('BUTTON');
          _instance.closeBT.setAttribute('class', 'close');
          _instance.closeBT.onclick = function () {
            _instance.hide();
          };
          _instance.container.appendChild(_instance.closeBT);

          document
            .getElementsByTagName('body')[0]
            .appendChild(_instance.backMask);
          document
            .getElementsByTagName('body')[0]
            .appendChild(_instance.containerBox);
          _instance.render();
          clearTimeout(_asyncLoad);
        }
      }, 15000);
      //
      const getInitPersistentSection = function (_initSetting) {
        return (
          _instance.data.persistentSection ||
          (_initSetting && _initSetting.persistentSection)
        );
      };
      //
      Object.defineProperty(_instance, 'getPersistentSection', {
        value: function (_initSetting) {
          return getInitPersistentSection(_initSetting);
        }
      });
      //
      const getInitPersistentChatLabel = function (_initSetting) {
        return _instance.data.chatEverywhereLabel;
      };
      //
      Object.defineProperty(_instance, 'getPersistentChatLabel', {
        value: function (_initSetting) {
          if (isDTCApplicableOnPage()) {
            return _instance.data.dtcLabel;
          } else {
            return getInitPersistentChatLabel(_initSetting);
          }
        }
      });
      //
      const stateMap = {
        offered: 'chatImpression',
        clicked: 'chatClicked',
        declined: 'chatDeclined',
        started: 'chatStarted',
        ended: 'chatEnded',
        suppressed: 'chatCampaignSuppression'
      };
      //
      const setupStats = function () {
        if (
          window.omnitureData &&
          window.omnitureData.dl &&
          window.omnitureData.dl.trackingInfo
        ) {
          if (
            window.omnitureData.dl.trackingInfo.launchMigrationTrafficPercentage
          ) {
            statType = 'STRATEGIC';
          } else {
            statType = 'LEGACY';
          }
        }
      };
      //
      const sendLegacyStats = function (statParams) {
        switch (statParams.provider) {
          case 'abc':
            omnitureData.dl.chatCoreInfo = {
              intId: statParams['biz-intent-id'],
              grpId: statParams['biz-group-id']
            };
            break;
          default:
            omnitureData.dl.chatCoreInfo = {
              engName: statParams.engagementName,
              convType: statParams.isProactive
                ? 'Proactive Web Messaging'
                : /^(auth-)?web-msg/.test(statParams.engagementName)
                ? 'Web Messaging'
                : 'Live Chat',
              convId: statParams.conversationId
            };
            let state = stateMap[statParams.state];
            window.analyticsToolkit.common.beacon('link', {
              linkTrackEvents: state,
              linkName: state
            });
            break;
        }
      };
      //
      const sendStrategicStats = function (statParams) {
        switch (statParams.provider) {
          case 'abc':
            window.digitalData.event.push({
              eventInfo: {
                eventAction: stateMap[statParams.state],
                eventType: 'chatCore',
                eventCategory: '',
                eventName: ''
              },
              attributes: {
                intId: statParams['biz-intent-id'],
                grpId: statParams['biz-group-id']
              }
            });
            break;
          default:
            let event = {
              eventInfo: {
                eventAction: stateMap[statParams.state],
                eventType:
                  cBlocking && statParams.state === 'clicked'
                    ? 'chatCore - cookie blocked'
                    : 'chatCore',
                eventCategory: '',
                eventName: ''
              },
              attributes: {
                engName: statParams.engagementName,
                convType: statParams.isProactive
                  ? 'Proactive Web Messaging'
                  : /^(auth-)?web-msg/.test(statParams.engagementName)
                  ? 'Web Messaging'
                  : 'Live Chat',
                convId: statParams.conversationId
              }
            };
            if (statParams.isProactive && trComponentInfo) {
              event.attributes.component = [
                {
                  category: {
                    primaryCategory: 'proactive-messaging'
                  },
                  componentInfo: trComponentInfo
                }
              ];
            } else if (statParams.isReactive && reactiveTRComponentInfo) {
              event.attributes.component = [
                {
                  category: {
                    primaryCategory: 'reactive-messaging'
                  },
                  componentInfo: reactiveTRComponentInfo
                }
              ];
            }
            window.digitalData.event.push(event);
        }
      };
      //
      const sendStats = function (statParams) {
        try {
          setupStats();
          switch (statType) {
            case 'STRATEGIC':
              sendStrategicStats(statParams);
              break;
            case 'LEGACY':
              sendLegacyStats(statParams);
              break;
          }
        } catch (e) {
          sendNRPageAction('__lp__stats', {
            _err: e.message || JSON.stringify(e),
            _stack: e.stack || 'N/A'
          });
        }
      };
      //
      const getInitPersistentChatToggle = function (_initSetting) {
        return (
          _instance.data.persistentChat &&
          _initSetting &&
          _initSetting.persistentChat &&
          _instance.data.persistentSection &&
          _instance.data.persistentSection.length > 0
        );
      };
      //
      Object.defineProperty(_instance, 'isInitialized', {
        value: function () {
          return _initCalled;
        }
      });
      //
      const calculateMTRedirectFlag = function (preferAppLinks) {
        if (!_globalMTRedirectEnabled) {
          return false;
        }
        if (preferAppLinks === false) {
          return false;
        }
        if (_appVersion) {
          if (
            _appPlatform === 'ios' &&
            compareVersion(_appVersion, minIOSAppVerForMTRedirect) >= 0
          ) {
            return true;
          }
          if (
            _appPlatform === 'android' &&
            compareVersion(_appVersion, minAndroidAppVerForMTRedirect) >= 0
          ) {
            return true;
          }
        }
        return false;
      };
      //
      Object.defineProperty(_instance, 'setPreferAppLinks', {
        value: function (flag) {
          calculatedMTRedirect = calculateMTRedirectFlag(flag === true);
        }
      });
      //
      Object.defineProperty(_instance, 'setMinimizedFocusQuerySelector', {
        value: function (querySelector) {
          if (!_initCalled) {
            return;
          }
          minimizedFocusQuerySelector = querySelector;
        }
      });
      //
      Object.defineProperty(_instance, 'setClosedFocusQuerySelector', {
        value: function (querySelector) {
          if (!_initCalled) {
            return;
          }
          closedFocusQuerySelector = querySelector;
        }
      });
      //
      Object.defineProperty(_instance, 'setOnChatWindowClosed', {
        value: function (handler) {
          if (!_initCalled) {
            return;
          }
          onChatWindowClosed = handler;
        }
      });
      //
      Object.defineProperty(_instance, 'setOnChatWindowMinimized', {
        value: function (handler) {
          if (!_initCalled) {
            return;
          }
          onChatWindowMinimized = handler;
        }
      });
      //
      const getABCPageConfig = function (jabuka, defaultEnabled) {
        let _abcConfig = { enabled: defaultEnabled };
        if (jabuka.pageRules[thisPage]) {
          _abcConfig = jabuka.pageRules[thisPage];
        } else {
          var patternList = Object.keys(jabuka.patternRules);
          for (var i = 0; i < patternList.length; i++) {
            var r = new RegExp(patternList[i]);
            if (r.test(thisPage)) {
              _abcConfig = jabuka.patternRules[patternList[i]];
              break;
            }
          }
        }
        return _abcConfig;
      };
      //
      const getABCConfig = function (callback) {
        if (abcConfigLoaded) {
          if (_loadedAbcConfig) {
            callback(null, _loadedAbcConfig);
            return;
          }
        }
        var abcXHR = new XMLHttpRequest();
        abcXHR.onreadystatechange = function () {
          if (this.readyState == 4) {
            abcConfigLoaded = true;
            if (this.status == 200) {
              try {
                var _resp = JSON.parse(this.responseText);
                _loadedAbcConfig = _resp;
                callback(null, _resp);
              } catch (e) {
                callback(new Error('failed to parse jabuka response'));
              }
            } else {
              callback(new Error('could not load ABC Config'));
            }
          }
        };
        abcXHR.open('GET', _instance.jabukaUrl, true);
        abcXHR.send();
      };
      //
      const constructABCUrl = function (pageABCConfig) {
        if (!pageABCConfig.queryParams) {
          // if no query params available, use all defaults
          pageABCConfig.queryParams = {
            'biz-intent-id': _instance.data.bizIntentId,
            'biz-group-id': _instance.data.bizGroupId,
            body: _instance.data.body
          };
        } else {
          // use defaults for params that are not available
          if (!pageABCConfig.queryParams['biz-intent-id']) {
            pageABCConfig.queryParams['biz-intent-id'] =
              _instance.data.bizIntentId;
          }
          if (!pageABCConfig.queryParams['biz-group-id']) {
            pageABCConfig.queryParams['biz-group-id'] =
              _instance.data.bizGroupId;
          }
          if (!pageABCConfig.queryParams['body']) {
            pageABCConfig.queryParams['body'] = _instance.data.body;
          }
        }

        let _abcUrl = abcUrlPrefix + '?';
        Object.keys(pageABCConfig.queryParams).forEach(function (queryParam) {
          _abcUrl +=
            queryParam + '=' + pageABCConfig.queryParams[queryParam] + '&';
        });
        if (_abcUrl.substring(_abcUrl.length - 1) == '&') {
          _abcUrl = _abcUrl.substring(0, _abcUrl.length - 1);
        }
        if (_abcUrl.substring(_abcUrl.length - 1) == '?') {
          _abcUrl = _abcUrl.substring(0, _abcUrl.length - 1);
        }
        if (pageABCConfig['biz-intent-id']) {
          _intent_id = pageABCConfig['biz-intent-id'];
        }
        if (pageABCConfig['biz-group-id']) {
          _group_id = pageABCConfig['biz-group-id'];
        }
        return _abcUrl;
      };
      //
      const constructABCButton = function (pageABCConfig) {
        let _abcUrl = constructABCUrl(pageABCConfig);
        // create abc button only if it doesn't exist
        if (!_instance.abcButtonLink) {
          _instance.abcButtonLink = document.createElement('div');
          _instance.abcButtonLink.setAttribute('class', 'abcButtonLink');
          _instance.abcButtonLink.setAttribute('id', 'abcButtonLink');
          _instance.abcButtonLink.setAttribute('role', 'navigation');
          _instance.abcButtonLink.setAttribute(
            'aria-label',
            'Message Us via Apple iMessage'
          );
          _instance.abcButtonLink.setAttribute('tabindex', '0');
          _instance.abcButtonLink.onclick = function () {
            window.open(_abcUrl);
            let statParams = {
              provider: 'abc',
              state: 'started',
              'biz-intent-id': _intent_id || 'N/A',
              'biz-group-id': _group_id || ''
            };
            sendStats(statParams);
          };
          _instance.abcButtonImage = document.createElement('img');
          _instance.abcButtonImage.setAttribute(
            'src',
            'https://www.telstra.com.au/content/dam/tcom/virtualassistant/abc/abc-floating-button.png'
          );
          _instance.abcButtonImage.setAttribute(
            'alt',
            'apple business chat icon'
          );
          if (_instance.appleDeviceType === 'tablet') {
            _instance.persistentChatContainer.classList.add(
              'abcChatContainerTablet'
            );
            _instance.abcButtonImage.classList.add('abcIconTablet');
          } else {
            _instance.persistentChatContainer.classList.add(
              'abcChatContainerMobile'
            );
            _instance.abcButtonImage.classList.add('abcIconMobile');
          }
          _instance.abcButtonLink.appendChild(_instance.abcButtonImage);
          _instance.persistentChatContainer.classList.add('fadein');
          _instance.persistentChatContainer.appendChild(
            _instance.abcButtonLink
          );
          _instance.abcTimeoutHandle = setTimeout(function () {
            if (!proactiveExists()) {
              showPersistentChatButton();
            }
          }, pageABCConfig.delay || _instance.data.abcButtonDelay);
        }
      };
      //
      const getTacticalABCURL = function () {
        if (!abcConfigLoaded) {
          return null;
        }
        let _cfg = getABCPageConfig(_loadedAbcConfig, false);
        if (_cfg.enabled) {
          return constructABCUrl(_cfg);
        }
        return null;
      };
      //
      const updateSection = function (tag) {
        const s = new Set(_instance.section);
        s.add(tag);
        _instance.section = Array.from(s);
      };
      //
      const removeSection = function (tag) {
        const s = new Set(_instance.section);
        s.delete(tag);
        _instance.section = Array.from(s);
      };
      //
      const updateLPSection = function (tag) {
        const s = new Set(window.lpTag.section);
        s.add(tag);
        window.lpTag.section = Array.from(s);
      };
      //
      const removeLPSection = function (tag) {
        const s = new Set(window.lpTag.section);
        s.delete(tag);
        window.lpTag.section = Array.from(s);
      };
      //
      const hideLoadingIndicator = function () {
        if (loadingIndicator) {
          clearTimeout(loadingIndicatorTimer);
          loadingIndicator.classList.add('t-lp-hide');
        }
      };

      //

      const showLoadingIndicator = function () {
        clearTimeout(loadingIndicatorTimer);
        if (dontShowLoadingIndicator) {
          dontShowLoadingIndicator = false;
          return;
        }
        if (loadingIndicator) {
          if (!loadingIndicatorAttached) {
            document.body.appendChild(loadingIndicator);
            loadingIndicatorAttached = true;
          }
          [
            loadingErrorIcon,
            loadingErrorMessage,
            loadingIndicatorCloseButton
          ].forEach((e) => e.classList.add('t-lp-hide'));
          [
            loadingSpinner,
            loadingMessage,
            loadingSpacer,
            loadingIndicator
          ].forEach((e) => e.classList.remove('t-lp-hide'));
          loadingIndicatorTimer = setTimeout(() => {
            if (_instance.chatWindowOpen) {
              hideLoadingIndicator();
              return;
            }
            showLoadingFailure();
          }, 15000);
        }
      };
      //
      const constructLoadingIndicator = function () {
        loadingIndicator = document.createElement('div');
        loadingIndicator.classList.add(
          't-lp-loading-indicator-wrapper',
          't-lp-hide'
        );
        loadingIndicator.innerHTML = `<div class="t-lp-loading-spinner t-lp-hide"></div>
        <svg focusable="false" aria-hidden="true" role="img" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" class="t-lp-loading-error-icon t-lp-hide">
          <path d="M29.75 25.25L18.28 4.46a2.51 2.51 0 00-4.56 0L2.25 25.24A2.63 2.63 0 004.55 29h22.91a2.62 2.62 0 002.29-3.75zM16 25a1.5 1.5 0 111.5-1.5A1.5 1.5 0 0116 25zm1.5-6.5a1.5 1.5 0 01-3 0v-6a1.5 1.5 0 013 0z"/>
        </svg>
        <div class="t-lp-loading-message t-lp-hide">Loading messaging window</div>
        <div class="t-lp-loading-error-message t-lp-hide">Unable to load messaging. Please try again after a few minutes.</div>
        <button type="button" class="t-lp-loading-close-button t-lp-hide" aria-label="Hide messaging window connection error message.">
          <svg focusable="false" aria-hidden="true" role="img" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" class="t-lp-loading-close-button-icon">
            <path d="M17.41 16L24 9.41A1 1 0 1022.59 8L16 14.59 9.41 8A1 1 0 008 9.41L14.59 16 8 22.59A1 1 0 109.41 24L16 17.41 22.59 24A1 1 0 1024 22.59z"/>
          </svg>
        </button>
        <div class="t-lp-loading-spacer t-lp-hide"></div>`;
        loadingSpinner = loadingIndicator.querySelector(
          'div.t-lp-loading-spinner'
        );
        loadingMessage = loadingIndicator.querySelector(
          'div.t-lp-loading-message'
        );
        loadingErrorIcon = loadingIndicator.querySelector(
          'svg.t-lp-loading-error-icon'
        );
        loadingErrorMessage = loadingIndicator.querySelector(
          'div.t-lp-loading-error-message'
        );
        loadingIndicatorCloseButton = loadingIndicator.querySelector(
          'button.t-lp-loading-close-button'
        );
        loadingIndicatorCloseButton.addEventListener('click', () => {
          hideLoadingIndicator();
          const _ceClick = isChatEverywhereClick;
          setTimeout(function () {
            if (proactiveExists()) {
              showLPM();
              hidePersistentChatButton();
            } else {
              hideLPM();
              showPersistentChatButton();
            }
            doAssetFocus(
              'closed',
              onChatWindowClosed,
              closedFocusQuerySelector,
              _ceClick
            );
          }, 1000);
          isChatEverywhereClick = false;
        });
        loadingSpacer = loadingIndicator.querySelector(
          'div.t-lp-loading-spacer'
        );
      };
      //
      const showLoadingFailure = function () {
        [loadingSpinner, loadingMessage, loadingSpacer].forEach((e) =>
          e.classList.add('t-lp-hide')
        );
        [
          loadingErrorIcon,
          loadingErrorMessage,
          loadingIndicatorCloseButton,
          loadingIndicator
        ].forEach((e) => e.classList.remove('t-lp-hide'));
      };
      //
      const hidePersistentChatButton = function () {
        if (_instance.persistentChatToggle) {
          if (!_instance.persistentChatContainer.classList.contains('hide')) {
            sendNRPageAction(MESSAGING_ACTION, { _action: 'HideButton' });
          }
          _instance.persistentChatContainer.classList.add('hide');
        }
      };
      //
      const appendPersistentChatContainer = function () {
        try {
          document.body.removeChild(_instance.persistentChatContainer);
        } catch (e) {}
        const footers=[...document.querySelectorAll('footer')];
        const btt = document.querySelector('div.parsys>div.backtoTop') || document.querySelector('div.tcom-footer-react-back-to-top-wrapper');
        const preferredLocation = (btt && btt.parentElement) || document.querySelector('div#tcom-footer-react') || (footers.length>0 ? footers[footers.length-1] : null) || document.querySelector('div.mytelstra-container div.footer-container') || document.querySelector('div.globalFooter');
        if (preferredLocation) {
          preferredLocation.insertAdjacentElement(
            'beforeBegin',
            _instance.persistentChatContainer
          );
        } else {
          document
            .getElementsByTagName('body')[0]
            .appendChild(_instance.persistentChatContainer);
        }
      };
      //
      const showPersistentChatButton = function () {
        appendPersistentChatContainer();
        hideLoadingIndicator();
        if (_instance.persistentChatToggle) {
          if (_instance.persistentChatContainer.classList.contains('hide')) {
            sendNRPageAction(MESSAGING_ACTION, { _action: 'ShowButton' });
          }
          _instance.persistentChatContainer.classList.remove('hide');
        }
      };
      //
      const hideLPM = function () {
        Array.from(document.getElementsByClassName('LPMcontainer')).forEach(
          function (e) {
            e.style.display = 'none';
          }
        );
      };
      //
      const showLPM = function () {
        const c = document.getElementsByClassName('LPMcontainer');
        if (c.length > 0) {
          hideLoadingIndicator();
          const lpm = c[0];
          try {
            document.body.removeChild(lpm);
          } catch (e) {
            lpm.style.display = 'block';
            return;
          }
          const footers=[...document.querySelectorAll('footer')];
          const btt = document.querySelector('div.parsys>div.backtoTop') || document.querySelector('div.tcom-footer-react-back-to-top-wrapper');
          const preferredLocation = (btt && btt.parentElement) || document.querySelector('div#tcom-footer-react') || (footers.length>0 ? footers[footers.length-1] : null) || document.querySelector('div.mytelstra-container div.footer-container') || document.querySelector('div.globalFooter');
          if (preferredLocation) {
            preferredLocation.insertAdjacentElement('beforeBegin', lpm);
          } else {
            document.getElementsByTagName('body')[0].appendChild(lpm);
          }
          lpm.style.display = 'block';
        }
      };
      //
      const proactiveExists = function () {
        var c = document.getElementsByClassName('proactive-msg-container');
        return c.length > 0;
      };
      //
      const clearv3CtaTimers = function () {
        clearTimeout(v3CtaTOHandle2);
        clearTimeout(v3CtaTOHandle3);
      };
      //
      const hideV3Cta = function (ctaType) {
        v3CtaCollapsed = true;
        const textBox = document.querySelector(
          'div.cta-' + ctaType + ' div.text-box'
        );
        textBox.classList.remove('width-hidden');
        textBox.classList.add('cta-' + ctaType + '-disappear');
        document
          .querySelector('div.proactive-cta-v3-wrapper button.close-button')
          ?.setAttribute('aria-expanded', 'false');
      };
      //
      const setupV3Cta = function () {
        clearv3CtaTimers();
        const v3Cta = document.querySelector('div.proactive-cta-v3-wrapper');
        if (!v3Cta) {
          return;
        }
        const ctaType = v3Cta.getAttribute('data-cta-type');
        const imageHeight = v3Cta.getAttribute('data-image-height');
        const unfurlDelay = parseInt(
          v3Cta.getAttribute('data-unfurl-delay-seconds')
        );
        let skipAutoHide = v3Cta.getAttribute('data-skip-autohide');
        if (!skipAutoHide || skipAutoHide === 'false') {
          skipAutoHide = false;
        }
        let autoHideDelay = parseInt(
          v3Cta.getAttribute('data-hide-delay-seconds')
        );
        const autoHideRequested = !isNaN(autoHideDelay);
        if (isNaN(autoHideDelay)) {
          autoHideDelay = 10;
        }
        const doAutoHide =
          !skipAutoHide &&
          (autoHideRequested ||
            window.matchMedia('(max-width: 599px)')?.matches);
        const textBox = document.querySelector(
          'div.cta-' + ctaType + ' div.text-box'
        );
        const ctaText = document.querySelector(
          'div.cta-' + ctaType + ' div.cta-text'
        );
        document
          .querySelector(`button.close-button`)
          .addEventListener('click', (e) => {
            e.currentTarget.disabled = true;
            hideV3Cta(ctaType);
          });
        if (v3CtaCollapsed) {
          textBox.style.display = 'none';
        }
        textBox.style.height = textBox.offsetHeight + 'px';
        ctaText.style.height = ctaText.offsetHeight + 'px';
        if (imageHeight) {
          const wrapper = v3Cta.querySelector('div.image-wrapper');
          if (wrapper) {
            wrapper.style.height = imageHeight;
            wrapper.querySelector('img').style.height = imageHeight;
          }
        }
        v3Cta.style.opacity = '1';
        if (isNaN(unfurlDelay)) {
          textBox.classList.add('width-hidden');
        } else {
          try {
            v3CtaTOHandle2 = setTimeout(() => {
              textBox.classList.add('width-hidden');
            }, unfurlDelay * 1000);
          } catch (e) {}
        }
        if (doAutoHide && !v3CtaCollapsed) {
          const delay = isNaN(unfurlDelay)
            ? autoHideDelay
            : autoHideDelay + unfurlDelay;
          v3CtaTOHandle3 = setTimeout(() => {
            hideV3Cta(ctaType);
          }, delay * 1000);
        }
        v3Cta.style.display = 'block';
      };
      //
      const bindProactiveCTAEvents = function () {
        if (proactiveExists()) {
          try {
            const declineButton = document.querySelector(
              'button[data-proactive-decline]'
            );
            const proactiveText = document.querySelector(
              'p[data-proactive-decline]'
            );
            const proactiveCtaV2Wrapper = document.querySelector(
              'div.proactive-cta-v2-wrapper'
            );

            // If proactive button doesnt have the close event tagged. Update with custom close
            if (declineButton && !declineButton.getAttribute('data-LP-event')) {
              declineButton.addEventListener('click', function () {
                declineButton.style.display = 'none';
                proactiveText.style.display = 'none';
              });
            }
            const e3 = Array.from(
              document.querySelectorAll('button[data-proactive-decline-v2]')
            ).filter((e) => !e.getAttribute('data-LP-event'))[0];
            e3 &&
              e3.addEventListener('click', () => {
                let e1 = document.querySelector(
                  'button.proactive-msg-button-v2'
                );
                let e2 = document.querySelector('div.proactive-cta-v2-wrapper');
                e3.style.display = 'none';
                e2.style.maxHeight = '20px';
                e2.style.visibility = 'hidden';
                setTimeout(() => {
                  e2.style.display = 'none';
                  e1.style.marginTop = '0px';
                }, 1000);
              });
            // proactive cta v3 handler
            setupV3Cta();
          } catch (e) {}
        }
      };
      //
      const constructChatEverywhereButton = function (persistentChatLabel) {
        // create elements only if they don't exist
        // append only if not already appended
        // can rely on outermost parent check
        if (
          _instance.persistentChatContainer.childElementCount === 0 ||
          _instance.persistentChatContainer.children.length === 0
        ) {
          _instance.persistentChatContainer.addEventListener(
            'click',
            function () {
              isChatEverywhereClick = true;
              isReactive = false;
              if (
                !_instance.data.persistentSection ||
                _instance.data.persistentSection.length === 0
              ) {
                _instance.show();
              } else {
                _instance.show({
                  isDirect: true,
                  section: _instance.data.persistentSection
                });
              }
              //}
            }
          );
          _instance.persistentChatContainer.innerHTML =
            '<svg class="chat-icon" aria-hidden="true" alt="' +
            persistentChatLabel +
            '"><path d="M16 4C8.84 4 3 8.94 3 15a10.24 10.24 0 003.9 7.88L4.86 27.2c-.34.71-.22 1.13.24 1.13a1.8 1.8 0 00.7-.2l5.66-2.75a15 15 0 004.55.7c7.18 0 13-4.95 13-11S23.19 4 16 4zm0 20.08a12.68 12.68 0 01-3.94-.61l-.76-.24-.72.35-2.3 1.12.44-.91.68-1.41-1.2-1A8.26 8.26 0 015 15c0-5 4.93-9 11-9s11 4.05 11 9-4.93 9.08-11 9.08z"></path><circle cx="12" cy="15" r="1"></circle><circle cx="16.01" cy="15" r="1"></circle><circle cx="20" cy="15" r="1"></circle></svg><span id="msg-us-label">' +
            persistentChatLabel +
            '</span>';
          _instance.persistentChatLabel =
            document.querySelector('#msg-us-label');
        }
        appendPersistentChatContainer();
      };

      //
      const stopMonitorForMessage = function () {
        clearInterval(messageMonitorHandle);
      };
      //
      const monitorForMessage = function () {
        if (messageUpdated) {
          stopMonitorForMessage();
          return;
        }
        const msgDiv = document.getElementById('lp_alert_message');
        if (
          msgDiv &&
          msgDiv.innerText ===
            'Go back to the previous page or log in to continue your conversation.'
        ) {
          msgDiv.classList.forEach(function (cls) {
            msgDiv.classList.remove(cls);
          });
          stopMonitorForMessage();
          messageUpdated = true;
          const count = msgDiv.childElementCount;
          let i;
          for (i = 0; i < count; i++) {
            try {
              msgDiv.firstElementChild.remove();
            } catch (e) {}
          }
          msgDiv.innerHTML = '';
          let linkData;
          if (authIsEnabled) {
            linkData = _mySignInUrl || defaultSignInUrl;
          } else {
            linkData = defaultAuthDisabledUrl;
          }
          const errMsgDiv = document.createElement('div');
          errMsgDiv.setAttribute('class', 'tlpErrMsg');
          errMsgDiv.innerHTML = linkData.msg;
          msgDiv.appendChild(errMsgDiv);
          msgDiv.appendChild(document.createElement('br'));
          if (linkData.action && linkData.action !== 'none') {
            const linkButtonWrapper = document.createElement('div');
            const link = document.createElement('a');
            linkButtonWrapper.setAttribute('class', 'tlpLinkWrapper');
            link.setAttribute('class', 'tlpLink');
            if (linkData.action === 'navigate') {
              link.setAttribute('href', linkData.url);
            } else if (linkData.action === 'refresh') {
              link.addEventListener('click', function () {
                try {
                  window.location.reload(true);
                } catch (e) {}
                return false;
              });
            }
            link.innerText = linkData.label;
            linkButtonWrapper.appendChild(link);
            msgDiv.appendChild(linkButtonWrapper);
          }
        }
      };
      //
      const startMonitorForMessage = function () {
        stopMonitorForMessage();
        messageUpdated = false;
        messageMonitorHandle = setInterval(monitorForMessage, 500);
      };
      //
      const _triggerLiveChat = function () {
        authForClick = false;

        if (_instance.lead) {
          lpTag.sdes.push({
            type: 'lead', //MANDATORY
            lead: {
              topic: _instance.lead + ''
            }
          });
        }
        if (window.__disableBusinessVA || !_instance.isBusinessVAActive()) {
          // remove VA section
          removeSection(_businessVaSection);
        }
        window.engagementsOffered = [];
        clicked = true;
        if (proactiveSuppressionCheck) {
          setTimeout(function () {
            if (proactiveSuppressionCheck && !_instance.chatWindowOpen) {
              sendStats({
                conversationId: '',
                state: 'suppressed',
                engagementName: '',
                isProactive: true
              });
            }
            proactiveSuppressionCheck = false;
          }, 10000);
        }
        convoTriggerStartTime = new Date().getTime();
        monitorId = generateCorrelationId();
        window.lpTag.newPage(document.URL, {
          section: _instance.section //REFER TO TAB3 COLUMN I
        });
        _instance.section = JSON.parse(JSON.stringify(_instance.sourceSection));
        if (isChatEverywhereClick) {
          sendNRPageAction(MESSAGING_ACTION, {
            _action: 'MessageUsButtonClick'
          });
        } else {
          sendNRPageAction(MESSAGING_ACTION, { _action: 'MessageUsCTAClick' });
        }
        clearTimeout(windowOpenMonitorHandle);
        windowOpenMonitorHandle = setTimeout(() => {
          if (!_instance.chatWindowOpen && convoTriggerStartTime > 0) {
            sendNRPageAction(MESSAGING_ACTION, {
              _action: 'WindowNotOpened',
              section: (lpTag.section && lpTag.section.join(',')) || '--n/a--'
            });
          }
        }, 10000);
      };
      //
      const callLPGATCallback = function () {
        if (authForClick) {
          authForClick = false;
        }
        if (lpCallback) {
          if (!_token) {
            startMonitorForMessage();
            lpCallback(null, 'Error');
          } else {
            stopMonitorForMessage();
            lpCallback(_token);
            _token = null;
          }
        }
      };
      //

      const nextStepAfterAuth = function () {
        authInProgress = false;
        if (authForClick) {
          _triggerLiveChat();
        } else {
          callLPGATCallback();
        }
      };
      //
      const retrieveObjects = function () {
        if (retrievalXHR) {
          retrievalXHR.abort();
        }
        retrievalXHR = new XMLHttpRequest();
        retrievalXHR.onreadystatechange = function () {
          if (retrievalXHR.readyState === retrievalXHR.DONE) {
            clearTimeout(retrievalTimeoutHandle);
            retrievalTimeoutHandle = null;
            if (retrievalXHR.status === 200) {
              let o = JSON.parse(
                atob(decodeURIComponent(retrievalXHR.responseText))
              );
              _token = o.lpJWE;
              _id = o.lpIdentity;
            } else {
              _id = _token = null;
            }
            nextStepAfterAuth();
          }
        };
        retrievalXHR.open('GET', retrieveUrl + '?cid=' + cid, true);
        retrievalXHR.withCredentials = true;
        retrievalXHR.send();
        retrievalTimeoutHandle = setTimeout(function () {
          retrievalTimeoutHandle = null;
          retrievalXHR.abort();
          _id = _token = null;
          nextStepAfterAuth();
        }, retrieveTimeout);
      };
      //
      const retrieveV2Objects = function (at) {
        if (retrievalV2XHR) {
          retrievalV2XHR.abort();
        }
        retrievalV2XHR = new XMLHttpRequest();
        retrievalV2XHR.onreadystatechange = function () {
          if (retrievalV2XHR.readyState === retrievalV2XHR.DONE) {
            clearTimeout(retrievalTimeoutHandle);
            retrievalTimeoutHandle = null;
            if (retrievalV2XHR.status === 200) {
              const o = JSON.parse(retrievalV2XHR.responseText);
              _token = o.lpJWE;
              _id = o.lpIdentity;
            } else {
              _id = _token = null;
            }
            nextStepAfterAuth();
          }
        };
        retrievalV2XHR.open(
          'GET',
          retrieveV2Url + '?cid=' + generateCorrelationId(),
          true
        );
        retrievalV2XHR.withCredentials = true;
        retrievalV2XHR.setRequestHeader('Authorization', 'Bearer ' + at);
        retrievalV2XHR.send();
        retrievalTimeoutHandle = setTimeout(function () {
          retrievalTimeoutHandle = null;
          retrievalV2XHR.abort();
          _id = _token = null;
          nextStepAfterAuth();
        }, retrieveTimeout);
      };
      //
      const clearSSOTimer = function () {
        if (ssoTimeoutHandle) {
          clearTimeout(ssoTimeoutHandle);
        }
        ssoTimeoutHandle = null;
      };
      //
      const removeSSOFrame = function () {
        if (ssoFrame && document.body.contains(ssoFrame)) {
          document.body.removeChild(ssoFrame);
        }
        ssoFrame = null;
        ssoFrameContentWindow = null;
      };
      //
      const onAuthMessage = function (event) {
        if (event.source !== ssoFrameContentWindow) {
          return;
        }
        clearSSOTimer();
        removeSSOFrame();
        if (event.data && event.data.errCode === 'e5') {
          cBlocking = true;
        }
        if (event.data && event.data.status === 'success') {
          retrieveObjects();
        } else {
          _id = _token = null;
          nextStepAfterAuth();
        }
      };
      //
      const triggerAuth = function () {
        if (authInProgress) {
          return;
        }
        authInProgress = true;
        removeSSOFrame();
        cid = generateCorrelationId();
        ssoFrame = document.createElement('iframe');
        ssoFrame.src =
          ssoUrl + '?cid=' + cid + '&m=' + (authForClick ? 'c' : 'f');
        ssoFrame.style.display = 'none';
        document.body.appendChild(ssoFrame);
        ssoFrameContentWindow = ssoFrame.contentWindow;
        ssoTimeoutHandle = setTimeout(function () {
          ssoTimeoutHandle = null;

          removeSSOFrame();
          nextStepAfterAuth();
        }, ssoTimeout);
      };
      //
      const lpGAT = function (callback) {
        lpCallback = callback;
        if (!authIsEnabled || cBlocking) {
          _token = null;
          callLPGATCallback();
        } else if (_token) {
          callLPGATCallback();
        } else {
          cid = '';
          _getToken();
        }
      };
      //
      const lpIdFn = function (callback) {
        if (!authIsEnabled || cBlocking) {
          _id = null;
        }
        return callback(_id);
      };
      //
      const setupAuthSupport = function () {
        if (authIsEnabled) {
          if (window.addEventListener) {
            window.addEventListener('message', onAuthMessage);
          } else {
            window.attachEvent('onmessage', onAuthMessage);
          }
          window.lpTag.identities = window.lpTag.identities || [];
          window.lpTag.identities.push(lpIdFn);
          window.lpMethods = window.lpMethods || {};
          Object.defineProperty(window.lpMethods, 'lpGetAuthenticationToken', {
            value: lpGAT
          });
        }
      };
      let _getToken = function () {
        triggerAuth();
      };
      // run live chat wrapper
      const _runLiveChat = function () {
        // closeLightBox();
        hidePersistentChatButton();
        showLoadingIndicator();
        cid = '';
        if (authIsEnabled && !cBlocking) {
          authForClick = true;
          _getToken();
        } else {
          _triggerLiveChat();
        }
      };
      // _instance.show
      Object.defineProperty(_instance, 'show', {
        value: function (_showConfig) {
          clearv3CtaTimers();
          if (
            !isChatEverywhereClick &&
            !processingTrigger &&
            !_instance.data.abcEnabled &&
            tacticalAbcEnabled &&
            _instance.isABCCompatibleDevice
          ) {
            let _tacticalAbcUrl = getTacticalABCURL();
            if (_tacticalAbcUrl) {
              window.open(_tacticalAbcUrl);
              let statParams = {
                provider: 'abc',
                state: 'started',
                'biz-intent-id': _intent_id || 'N/A',
                'biz-group-id': _group_id || ''
              };
              sendStats(statParams);
              return;
            }
          }
          if (processingTrigger) {
            dontShowLoadingIndicator = true;
          }
          processingTrigger = false;
          var _computedShowConfig = _showConfig || {};
          if (
            _computedShowConfig.section &&
            _computedShowConfig.section.length &&
            _computedShowConfig.section.length > 0
          ) {
            _computedShowConfig.section.forEach((s) => updateSection(s));
          }
          if (_computedShowConfig.authToken) {
            updateSection('auth-tdi');
            removeSection('non-auth');
          } else {
            updateSection('non-auth');
            removeSection('auth-tdi');
          }
          if (_computedShowConfig.lead) {
            _instance.lead = _computedShowConfig.lead;
          }

          // DTC override
          if (!_computedShowConfig.isDirect && isDTCApplicableOnPage()) {
            // for 2way routing link, convert it to DTCC/DTCB
            _computedShowConfig.isDirect = true;
            if (
              _isUnderSmallBusiness &&
              _instance.data.dtcBusinessSection != ''
            ) {
              _instance.section = _instance.data.dtcBusinessSection.split(',');
            } else if (
              !_isUnderSmallBusiness &&
              _instance.data.dtcSection != ''
            ) {
              _instance.section = _instance.data.dtcSection.split(',');
            } else {
              _computedShowConfig.isDirect = _showConfig.isDirect;
            }
          }

          if (_instance.isDirect || _computedShowConfig.isDirect) {
            let mtrRedirect = isChatEverywhereClick
              ? preferMTRForMessageUs
              : calculatedMTRedirect;
            let opened = false;
            if (mtrRedirect) {
              if (_appPlatform === 'ios') {
                opened = window.open(
                  _mtwIOSHostName +
                    '/messaging?tags=' +
                    _instance.section.join(',')
                );
              } else {
                opened = window.open(
                  _mtwAndroidHostName +
                    '/messaging?tags=' +
                    _instance.section.join(',')
                );
              }
              sendNRPageAction(MESSAGING_ACTION, {
                _action: 'MTRedirectInitiated',
                _appPlatform: _appPlatform,
                _appVersion: _appVersion
              });
              if (!opened) {
                _runLiveChat();
                sendNRPageAction(MESSAGING_ACTION, {
                  _action: 'MTRedirectFailed',
                  _appPlatform: _appPlatform,
                  _appVersion: _appVersion
                });
              }
            } else {
              _runLiveChat();
            }
          } else {
            //add exclude
            updateLPSection('exclude');

            _instance.backMask.classList.remove('hide');
            _instance.containerBox.classList.remove('hide');
            hidePersistentChatButton();
          }
        }
      });
      //
      const processTriggers = function () {
        if (triggers.length === 0) {
          return;
        }
        let trigger;
        do {
          trigger = triggers.shift();
          if (trigger.type === 'proactive') {
            proactiveAutoClick =
              trigger.features && trigger.features.autoClick === true;
            trComponentInfo = trigger.componentInfo;
            agentCtxInfo = trigger.agentCtxInfo;
            proactiveSuppressionCheck = true;
            processingTrigger = true;
            impressionStatSent = false;
            declinedStatSent = false;
            _instance.show({ isDirect: true, section: trigger.section });
          }
        } while (triggers.length > 0);
      };
      //
      Object.defineProperty(_instance, 'triggerReactive', {
        value: function (settings) {
          if (settings && settings.section && settings.section.length > 0) {
            isReactive = true;
            reactiveAgentCtxInfo = settings.agentCtxInfo || [];
            reactiveTRComponentInfo = settings.componentInfo || null;
            processingTrigger = true;
            _instance.show({ isDirect: true, section: settings.section });
          }
        }
      });
      //
      Object.defineProperty(_instance, 'triggerProactive', {
        value: function (settings) {
          if (settings && settings.section && settings.section.length > 0) {
            triggers.push({
              type: 'proactive',
              section: settings.section,
              componentInfo: settings.componentInfo,
              features: settings.features,
              agentCtxInfo: settings.agentCtxInfo || []
            });
          }
          if (lpTagInitialized) {
            processTriggers();
          }
        }
      });
      //
      Object.defineProperty(_instance, 'hide', {
        value: function () {
          //Remove exclude
          removeLPSection('exclude');

          _instance.backMask.classList.add('hide');
          _instance.containerBox.classList.add('hide');
          _instance.childElements['routeLevel1Select'].value = '0';
          _instance.onSelectRouter1(
            _instance.childElements['routeLevel1Select'].value
          );
          hideLPM();
          showPersistentChatButton();
        }
      });
      //
      Object.defineProperty(_instance, 'initChat', {
        value: function (args) {
          for (var _i = 0; _i < args.length; _i++) {
            if (args[_i].indexOf(',') === -1) {
              updateSection(args[_i]);
            } else {
              var _localArgs = args[_i].split(',');
              for (var _j = 0; _j < _localArgs.length; _j++) {
                updateSection(_localArgs[_j]);
              }
            }
          }
          _runLiveChat();
          _instance.hide();
        }
      });
      //
      Object.defineProperty(_instance, 'showChatNow', {
        value: function (_parentObject, _childObject) {
          var _showableObj = _childObject || _parentObject;
          //clear child
          while (_instance.childElements['chatNow'].firstChild) {
            _instance.childElements['chatNow'].removeChild(
              _instance.childElements['chatNow'].firstChild
            );
          }
          if (!_showableObj) {
            return;
          }

          if (_showableObj.lead) {
            _instance.lead = _showableObj.lead;
          } else {
            _instance.lead = false;
          }

          var _infoArray = [];
          _infoArray[0] = _parentObject.section;
          if (_childObject) {
            _infoArray[1] = _childObject.section;
          }

          _instance.childElements['chatNowDesc'] =
            document.createElement('DIV');
          _instance.childElements['chatNowDesc'].setAttribute(
            'class',
            'telstra_live_person_container_chatNow_desc'
          );
          _instance.childElements['chatNow'].appendChild(
            _instance.childElements['chatNowDesc']
          );
          if (_showableObj.help && _showableObj.help != '') {
            _instance.childElements['chatNowDesc'].innerHTML =
              _showableObj.help;
          }
          _instance.childElements['chatNowBt'] = document.createElement('A');
          _instance.childElements['chatNowBt'].setAttribute(
            'class',
            'telstra_live_person_container_chatNow_bt btn primary'
          );
          _instance.childElements['chatNowBt'].innerHTML = 'Chat now';
          _instance.childElements['chatNowBt'].setAttribute(
            'href',
            'javascript:void(0);'
          );
          // Adding Chat initialisation
          _instance.childElements['chatNowBt'].onclick = function () {
            _instance.initChat(_infoArray);
          };
          _instance.childElements['chatNow'].appendChild(
            _instance.childElements['chatNowBt']
          );
          var _clearDiv = document.createElement('DIV');
          _clearDiv.style.clear = 'both';
          _instance.childElements['chatNow'].appendChild(_clearDiv);
        }
      });
      //

      Object.defineProperty(_instance, 'render', {
        value: function () {
          _instance.childElements['header'] = document.createElement('DIV');
          _instance.childElements['header'].setAttribute(
            'class',
            'telstra_live_person_container_header'
          );
          _instance.childElements['header'].setAttribute('role', 'region');
          _instance.childElements['header'].setAttribute(
            'aria-labelledby',
            'telstra_lp_container_description'
          );
          _instance.childElements['header'].innerHTML = _instance.data.heading;
          _instance.container.appendChild(_instance.childElements['header']);

          _instance.childElements['description'] =
            document.createElement('DIV');
          _instance.childElements['description'].setAttribute(
            'id',
            'telstra_lp_container_description'
          );
          _instance.childElements['description'].setAttribute(
            'class',
            'telstra_live_person_container_description'
          );
          _instance.childElements['description'].setAttribute('role', 'region');
          _instance.childElements['description'].setAttribute(
            'aria-labelledby',
            'telstra_lp_container_description'
          );
          _instance.childElements['description'].innerHTML =
            _instance.data.description;
          _instance.container.appendChild(
            _instance.childElements['description']
          );

          _instance.childElements['routeLevel1'] =
            document.createElement('DIV');
          _instance.childElements['routeLevel1'].setAttribute(
            'id',
            'category_selection'
          );
          _instance.childElements['routeLevel1'].setAttribute(
            'role',
            'navigation'
          );
          _instance.childElements['routeLevel1'].setAttribute(
            'aria-label',
            'Product Selection'
          );
          _instance.childElements['routeLevel1Select'] =
            document.createElement('SELECT');
          _instance.childElements['routeLevel1Select'].setAttribute(
            'id',
            'routeLevel1Select'
          );
          _instance.childElements['routeLevel1Select'].setAttribute(
            'title',
            'Category Selection'
          );
          const _defaultOption = document.createElement('OPTION');
          _defaultOption.value = '0';
          _defaultOption.innerHTML = 'Choose a category';
          _instance.childElements['routeLevel1Select'].appendChild(
            _defaultOption
          );
          for (var _option in _instance.data.options) {
            var _localOption = document.createElement('OPTION');
            _localOption.value = _option;
            _localOption.innerHTML = _instance.data.options[_option].label;
            _instance.childElements['routeLevel1Select'].appendChild(
              _localOption
            );
          }
          _instance.childElements['routeLevel1Select'].onchange = function (e) {
            _instance.onSelectRouter1(e.target.value);
          };
          _instance.childElements['routeLevel1'].setAttribute(
            'class',
            'telstra_live_person_container_routeLevel1'
          );
          _instance.childElements['routeLevel1'].appendChild(
            _instance.childElements['routeLevel1Select']
          );
          _instance.container.appendChild(
            _instance.childElements['routeLevel1']
          );
          //_instance.container.innerHTML = "Popup";

          _instance.childElements['routeLevel2'] =
            document.createElement('DIV');
          _instance.childElements['routeLevel2'].setAttribute(
            'class',
            'telstra_live_person_container_routeLevel2'
          );
          _instance.childElements['routeLevel2'].setAttribute(
            'id',
            'subcategory_selection'
          );
          _instance.childElements['routeLevel2'].setAttribute(
            'role',
            'navigation'
          );
          _instance.childElements['routeLevel2'].setAttribute(
            'aria-label',
            'Area of Inquiry'
          );

          _instance.container.appendChild(
            _instance.childElements['routeLevel2']
          );

          // Chat now component
          _instance.childElements['chatNow'] = document.createElement('DIV');
          _instance.childElements['chatNow'].setAttribute(
            'class',
            'telstra_live_person_container_chatNow'
          );
          _instance.container.appendChild(_instance.childElements['chatNow']);
        }
      });
      //

      Object.defineProperty(_instance, 'onSelectRouter1', {
        value: function (_id) {
          //clear child
          while (_instance.childElements['routeLevel2'].firstChild) {
            _instance.childElements['routeLevel2'].removeChild(
              _instance.childElements['routeLevel2'].firstChild
            );
          }
          if (_id + '' != '0') {
            if (
              _instance.data.options[_id].childs &&
              JSON.stringify(_instance.data.options[_id].childs) !=
                JSON.stringify({})
            ) {
              var _dataOptions = _instance.data.options[_id].childs;
              _instance.childElements['routeLevel2Select'] =
                document.createElement('SELECT');
              _instance.childElements['routeLevel2Select'].setAttribute(
                'title',
                'Subcategory Selection'
              );
              _instance.childElements['routeLevel2Select'].setAttribute(
                'id',
                'routeLevel2Select'
              );
              _instance.childElements['routeLevel2'].appendChild(
                _instance.childElements['routeLevel2Select']
              );
              var _defaultOption = document.createElement('OPTION');
              _defaultOption.value = '0';
              _defaultOption.innerHTML = 'Choose a category';
              _instance.childElements['routeLevel2Select'].appendChild(
                _defaultOption
              );
              for (let _option in _dataOptions) {
                var _localOption = document.createElement('OPTION');
                _localOption.value = _option;
                _localOption.innerHTML = _dataOptions[_option].label;
                _instance.childElements['routeLevel2Select'].appendChild(
                  _localOption
                );
              }
              _instance.childElements['routeLevel2Select'].onchange = function (
                e
              ) {
                _instance.onSelectRouter2(e.target.value);
              };
              _instance.showChatNow(false, false);
            } else {
              _instance.childElements['routeLevel2Select'] = false;
              var _parentObject = false;
              for (let _option in _instance.data.options) {
                if (_option === _id) {
                  _parentObject = _instance.data.options[_option];
                  _parentObject.id = _id;
                }
              }
              _instance.showChatNow(_parentObject, false);
            }
          } else {
            _instance.showChatNow(false, false);
          }
        }
      });
      //

      Object.defineProperty(_instance, 'onSelectRouter2', {
        value: function (_id) {
          var _ParentRouteId =
            _instance.childElements['routeLevel1Select'].value;
          var _ChildRouteId = _instance.childElements['routeLevel2Select'];
          if (_ChildRouteId) {
            _ChildRouteId = _ChildRouteId.value;
          }
          var _parentObject = false;
          var _childObject = false;
          for (var _option in _instance.data.options) {
            if (_option === _ParentRouteId) {
              _parentObject = _instance.data.options[_option];
              _parentObject.id = _ParentRouteId;
              for (var _childOption in _instance.data.options[_option].childs) {
                if (_childOption === _ChildRouteId) {
                  _childObject =
                    _instance.data.options[_option].childs[_childOption];
                  _childObject.id = _ChildRouteId;
                }
              }
            }
          }
          if (_id + '' == '0') {
            _instance.showChatNow(false, false);
          } else {
            _instance.showChatNow(_parentObject, _childObject);
          }
        }
      });
      //
      const closeLightBox = function () {
        previousElement = null;
        try {
          previousElement = window.tcom.core.utils.closeModal(true);
        } catch (e) {}
      };
      //
      const handleOfferImpression = function () {
        stopCollectingEngagements = true;
        impressionsTimeoutHandle = null;

        let authEngagements = window.engagementsOffered.filter(function (v) {
          return v.engagementName.indexOf('auth-web-msg') === 0;
        });
        if (proactiveSuppressionCheck && proactiveExists()) {
          proactiveSuppressionCheck = false;
        }
        let data;
        if (authEngagements.length > 0) {
          data = authEngagements[0];
        } else {
          data = window.engagementsOffered[0];
        }
        if (data) {
          if (!_instance.chatWindowOpen && proactiveExists()) {
            showLPM();
          } else {
            hideLPM();
          }
          hideLoadingIndicator();
          if (data.engagementType === 1) {
            stopCollectingEngagements = false;
            setTimeout(bindProactiveCTAEvents, 1000);
            hidePersistentChatButton();
            if (!impressionStatSent) {
              impressionStatSent = true;
              isProactive = true;
              sendStats({
                state: 'offered',
                engagementName: data.engagementName,
                isProactive: isProactive,
                isReactive: isReactive
              });
            }
            if (proactiveAutoClick) {
              proactiveAutoClick = false;
              try {
                // closeLightBox();
                window.lpTag.taglets.rendererStub.click(data.engagementId);
              } catch (e) {}
            }
          } else if (data.engagementType === 6) {
            isProactive = false;
            if (!clicked) {
              stopCollectingEngagements = false;
              window.engagementsOffered = [];
              return;
            }

            // The ignoreOffer flag is added for the workaround, if it's true we don't execute the auto click code
            if (!ignoreOffer) {
              engagementId = data.engagementId;
              let checkForChat = null;
              //
              function checkRendererStubReady() {
                if (
                  window.lpTag &&
                  window.lpTag.taglets &&
                  window.lpTag.taglets.rendererStub
                ) {
                  let info =
                    window.lpTag.taglets.rendererStub.getEngagementInfo(
                      engagementId
                    );
                  if (
                    info.state !== 'undefined' &&
                    (info.state === 1 || info.state === 2)
                  ) {
                    sendUrlSDE();
                    // closeLightBox();
                    window.lpTag.taglets.rendererStub.click(engagementId);
                    clearInterval(checkForChat);
                  }
                }
              }
              checkForChat = setInterval(checkRendererStubReady, 500);
            } else {
              // Turn the flag off for the next engagement impression
              ignoreOffer = false;
              stopCollectingEngagements = false;
              window.engagementsOffered = [];
            }
          }
        } else {
          stopCollectingEngagements = false;
        }
      };
      //
      const disableEvent = function (event) {
        event.stopPropagation();
        event.preventDefault();
      };
      //
      const bindWebTagEvents = function () {
        window.lpTag.events.bind({
          appName: 'lp_SMT',
          eventName: 'MONITORING_STATE',
          func: function (data) {
            if (data.active === true && !lpTagInitialized) {
              lpTagInitialized = true;
              processTriggers();
            }
          }
        });
        window.lpTag.events.bind(
          'lpUnifiedWindow',
          'conversationInfo',
          function (data) {
            if (
              convoStartedOnPage &&
              data.conversationId &&
              data.conversationId !== statConvoId &&
              !startStatSent
            ) {
              statConvoId = data.conversationId;
              sendStats({
                engagementName: engagementName,
                state: 'started',
                conversationId: statConvoId,
                isProactive: isProactive,
                isReactive: isReactive
              });
              startStatSent = true;
              sendNRPageAction(MESSAGING_ACTION, {
                _action: 'ConversationStarted',
                _conversationId: data.conversationId,
                duration: new Date().getTime() - convoTriggerStartTime
              });
            }
          }
        );
        window.lpTag.events.bind(
          'lpUnifiedWindow',
          'minimized',
          function (_data) {
            doAssetFocus(
              'minimized',
              onChatWindowMinimized,
              minimizedFocusQuerySelector
            );
          }
        );
        window.lpTag.events.bind(
          'lpUnifiedWindow',
          'windowClosed',
          function (_data) {
            _instance.chatWindowOpen = false;
            sendNRPageAction(MESSAGING_ACTION, { _action: 'ChatWindowClosed' });
            convoTriggerStartTime = 0;
            _inputBoxFocus = false;
            window.engagementsOffered = [];
            reactiveTRComponentInfo = null;
            reactiveAgentCtxInfo = [];
            stopCollectingEngagements = false;
            convoStartedOnPage = false;
            isProactive = false;
            isReactive = false;
            const _ceClick = isChatEverywhereClick;
            setTimeout(function () {
              if (proactiveExists()) {
                showLPM();
                hidePersistentChatButton();
              } else {
                hideLPM();
                showPersistentChatButton();
              }
              doAssetFocus(
                'closed',
                onChatWindowClosed,
                closedFocusQuerySelector,
                _ceClick
              );
            }, 1000);
            isChatEverywhereClick = false;
          }
        );
        window.lpTag.events.bind(
          'LP_OFFERS',
          'OFFER_IMPRESSION',
          function (data) {
            //This is triggered when the engagement has been displayed on the page.

            if (
              window.engagementsOffered.length === 0 &&
              !impressionsTimeoutHandle
            ) {
              impressionsTimeoutHandle = setTimeout(
                handleOfferImpression,
                engCollectTimeout
              );
            }
            if (!stopCollectingEngagements) {
              window.engagementsOffered.push(data);
            }
          }
        );
        // Bind to another event which triggers when the chat window state changes
        window.lpTag.events.bind({
          appName: 'API',
          eventName: 'state',
          func: function (data) {
            // If received window init state, which means chat window is going to open
            // We set the flag to true to ignore next impress which will be delivered immediately after window close.
            // Adding 'ended' and 'applicationEnded' state for fallback
            if (
              data === 'init' ||
              data === 'ended' ||
              data === 'applicationEnded'
            ) {
              if (previousEngagementType === 6) {
                ignoreOffer = true;
              }
              if (data === 'init') {
                hideLPM();
                hidePersistentChatButton();
                if (!_instance.chatWindowOpen && convoTriggerStartTime > 0) {
                  sendNRPageAction(MESSAGING_ACTION, {
                    _action: 'ChatWindowOpen',
                    _duration: new Date().getTime() - convoTriggerStartTime
                  });
                }
                _instance.chatWindowOpen = true;
                hideLoadingIndicator();
                if (!_inputBoxFocus) {
                  doInputBoxFocus();
                }
                if (_instance.abcTimeoutHandle) {
                  clearTimeout(_instance.abcTimeoutHandle);
                }
              } else {
                setTimeout(function () {
                  if (proactiveExists()) {
                    showLPM();
                    hidePersistentChatButton();
                  } else {
                    hideLPM();
                    showPersistentChatButton();
                  }
                }, 1000);
                _instance.chatWindowOpen = false;

                _inputBoxFocus = false;
                window.engagementsOffered = [];
                if (startStatSent && convoStartedOnPage) {
                  sendStats({
                    engagementName: engagementName,
                    state: 'ended',
                    conversationId: statConvoId,
                    isProactive: isProactive,
                    isReactive: isReactive
                  });
                  startStatSent = false;
                  sendNRPageAction(MESSAGING_ACTION, {
                    _action: 'ConversationEnded',
                    _conversationId: statConvoId,
                    duration: new Date().getTime() - convoTriggerStartTime
                  });
                  convoTriggerStartTime = 0;
                }
              }
            } else if (data === 'postChat') {
              if (!_instance.chatWindowOpen && convoTriggerStartTime > 0) {
                sendNRPageAction(MESSAGING_ACTION, {
                  _action: 'ChatWindowOpen',
                  _conversationId: statConvoId,
                  _duration: new Date().getTime() - convoTriggerStartTime
                });
              }
              _instance.chatWindowOpen = true;
              hideLoadingIndicator();
              if (!_inputBoxFocus) {
                doInputBoxFocus();
              }
              if (_instance.abcTimeoutHandle) {
                clearTimeout(_instance.abcTimeoutHandle);
              }
              // ignore postChat event for persistentChat Container show/hide to avoid flickering
            } else {
              hideLPM();
              hidePersistentChatButton();
              if (!_instance.chatWindowOpen && convoTriggerStartTime > 0) {
                sendNRPageAction(MESSAGING_ACTION, {
                  _action: 'ChatWindowOpen',
                  _conversationId: statConvoId,
                  _duration: new Date().getTime() - convoTriggerStartTime
                });
              }
              _instance.chatWindowOpen = true;
              hideLoadingIndicator();
              if (!_inputBoxFocus) {
                doInputBoxFocus();
              }
              if (_instance.abcTimeoutHandle) {
                clearTimeout(_instance.abcTimeoutHandle);
              }
            }
          }
        });
        window.lpTag.events.bind('LP_OFFERS', 'OFFER_CLICK', function (data) {
          _dragDropOverridden = false;
          convoStartedOnPage = true;
          statConvoId = '';
          previousEngagementType = data.engagementType;
          engagementName = data.engagementName;
          stopMonitorForMessage();
          hideLoadingIndicator();
          closeLightBox();
          if (data.engagementType === 1) {
            sendUrlSDE();
            isReactive = false;
            isProactive = true;
          } else {
            isProactive = false;
            isReactive = true;
          }
          sendAgentCtxInfo();
          if (!isChatEverywhereClick) {
            sendStats({
              state: 'clicked',
              engagementName: engagementName,
              isProactive: isProactive,
              isReactive: isReactive
            });
          }
        });
        window.lpTag.events.bind(
          'LP_OFFERS',
          'OFFER_DECLINED',
          function (data) {
            if (data.engagementType === 1) {
              hideLPM();
              showPersistentChatButton();
              if (!declinedStatSent) {
                declinedStatSent = true;
                sendStats({
                  state: 'declined',
                  engagementName: engagementName,
                  isProactive: true
                });
              }
            }
          }
        );
        window.lpTag.events.bind('lpUnifiedWindow', 'state', function (_data) {
          // when resume;
          if (
            _data &&
            (_data.state === 'waiting' || _data.state === 'resume')
          ) {
            if (_instance.callBackTread) {
              clearInterval(_instance.callBackTread);
              _instance.callBackTread = false;
            } else if (_instance.callBack) {
              _instance.callBackTread = setInterval(function () {
                _instance.callBack();
              }, _instance.callBackInterval * 1000);
            }
          } else if (_data && _data.state === 'ended') {
            stopCollectingEngagements = false;
            // when ended;
            if (_instance.callBackTread) {
              clearInterval(_instance.callBackTread);
              _instance.callBackTread = false;
            }
          }
          if (
            _data &&
            (_data.state === 'init' ||
              _data.state === 'waiting' ||
              _data.state === 'preChat' ||
              _data.state === 'chatting' ||
              _data.state === 'offline')
          ) {
            if (!_instance.chatWindowOpen && convoTriggerStartTime > 0) {
              sendNRPageAction(MESSAGING_ACTION, {
                _action: 'ChatWindowOpen',
                _conversationId: statConvoId,
                _duration: new Date().getTime() - convoTriggerStartTime
              });
            }
            _instance.chatWindowOpen = true;
            hideLoadingIndicator();
            if (!_inputBoxFocus) {
              doInputBoxFocus();
            }
            hideLPM();
            hidePersistentChatButton();
            if (_instance.abcTimeoutHandle) {
              clearTimeout(_instance.abcTimeoutHandle);
            }
          }
          if (
            disableDragDropFileUpload &&
            !_dragDropOverridden &&
            _data &&
            _data.state === 'waiting'
          ) {
            let e = document.querySelector('div.lp_main.lpc_body.lpc_desktop');
            if (e) {
              e.addEventListener('drop', disableEvent, true);
              e.addEventListener('dragover', disableEvent, true);
              e.addEventListener('dragenter', disableEvent, true);
              e.addEventListener('dragleave', disableEvent, true);
              _dragDropOverridden = true;
            }
          }
        });
      };
      //
      Object.defineProperty(_instance, 'init', {
        value: function (_initSetting={}) {
          // store initSettings so we can use them later
          initParams = _initSetting || {};
          if (document.location.pathname.indexOf('/messaging-forms/') !== -1) {
            _initCalled = true;
            return;
          }
          if (
            authV2IsEnabled &&
            _config.tacticalTCOMAuthEnabled &&
            !_initSetting.getToken &&
            document.location.hostname === _tcomPrefix + '.telstra.com.au'
          ) {
            _getToken = function () {
              const u =
                (window.authCaiman &&
                  window.authCaiman.getUser &&
                  window.authCaiman.getUser()) ||
                {};
              if (
                window.authCaiman &&
                window.authCaiman.isLoggedIn &&
                window.authCaiman.isLoggedIn() &&
                u.access_token
              ) {
                retrieveV2Objects(u.access_token);
              } else {
                _id = _token = null;
                nextStepAfterAuth();
              }
            };
          }
          if (
            authV2IsEnabled &&
            initParams && initParams.getToken &&
            typeof initParams.getToken === 'function'
          ) {
            _getToken = function () {
              const token = initParams.getToken();
              if (token) {
                retrieveV2Objects(token);
              } else {
                _id = _token = null;
                nextStepAfterAuth();
              }
            };
          }
          _instance.data.persistentSection =
            getInitPersistentSection(_initSetting);
          _instance.persistentChatToggle =
            getInitPersistentChatToggle(_initSetting);

          _instance.setupPersistentChat(
            _instance.persistentChatToggle,
            getInitPersistentChatLabel(_initSetting)
          );
          constructLoadingIndicator();
          setupStats();

          _instance.section = _initSetting.section || [];

          _instance.sourceSection = _initSetting.sourceSection || [];

          _instance.callBack = _initSetting.callBack || false;
          _instance.callBackInterval =
            _initSetting.callBackInterval || _instance.callBackInterval;

          /*Initializing TP TAG*/
          window.lpTag = window.lpTag || {};
          window.lpTag.section = _instance.section;
          setupAuthSupport();
          if (window.__loadLivePersonSrc) {
            window.__loadLivePersonSrc();
            // incase if lp overwrite sections
            window.lpTag.section = _instance.section;
          }
          _instance.section = JSON.parse(
            JSON.stringify(_instance.sourceSection)
          );
          window.lpTag.sdes = lpTag.sdes || [];
          _instance.isDirect = _initSetting.isDirect;
          var _styleLocal = '';
          if (!_initSetting.onlyTcomCSS) {
            _styleLocal +=
              '.telstra_live_person_container>.close {float: right;display: block;height: 26px;width: 26px;border: 0;padding: 0;cursor: pointer;background-color: #00aaf3;}';
            _styleLocal +=
              '.close:after {display: inline-block;content: "x";font-size: 18px !important;color: #fff !important;font-weight: normal !important;line-height: 26px;}';
            if (_initSetting.forceButtonCss) {
              _styleLocal +=
                '.button,.btn {padding: 14px 20px 14px 20px;border: none;text-decoration: none;display: inline-block;white-space: nowrap;position: relative;outline: none;line-height: normal;max-width: 100%;background-color: #1964c8;color: #fff;}';
            }
          } else {
            //Tcom Specific css
          }
          var _styleLocalElement = document.createElement('STYLE');
          _styleLocalElement.innerHTML = _styleLocal;
          document
            .getElementsByTagName('head')[0]
            .appendChild(_styleLocalElement);
          // Add event Listener
          bindWebTagEvents();
          _appPlatform =
            (_initSetting.appPlatform &&
              _initSetting.appPlatform.toLowerCase()) ||
            '';
          _appVersion = _initSetting.appVersion;
          if (_appPlatform === 'ios') {
            _globalMTRedirectEnabled =
              _config.enableMTRedirection &&
              APP_VER_REGEX.test(minIOSAppVerForMTRedirect);
          } else if (_appPlatform === 'android') {
            _globalMTRedirectEnabled =
              _config.enableMTRedirection &&
              APP_VER_REGEX.test(minAndroidAppVerForMTRedirect);
          } else {
            _globalMTRedirectEnabled = false;
          }
          calculatedMTRedirect = calculateMTRedirectFlag(
            _initSetting.preferAppLinks
          );
          preferMTRForMessageUs =
            calculatedMTRedirect && _initSetting.preferAppLinks === true;
          if (typeof _initSetting.onChatWindowClosed === 'function') {
            _defaultClosedCallback = _initSetting.onChatWindowClosed;
            onChatWindowClosed = _initSetting.onChatWindowClosed;
          }
          if (typeof _initSetting.onChatWindowMinimized === 'function') {
            _defaultMinimizedCallback = _initSetting.onChatWindowMinimized;
            onChatWindowMinimized = _initSetting.onChatWindowMinimized;
          }
          closedFocusQuerySelector = _initSetting.closedFocusQuerySelector;
          minimizedFocusQuerySelector =
            _initSetting.minimizedFocusQuerySelector;
          _defaultClosedSelector = _initSetting.closedFocusQuerySelector;
          _defaultMinimizedSelector = _initSetting.minimizedFocusQuerySelector;
          _initCalled = true;
        }
      });
      //
      const constructPersistentChatContainer = function (persistentChatLabel) {
        const b = document.createElement('BUTTON');
        b.setAttribute('type', 'button');
        b.setAttribute('class', 'msg-us-btn hide');
        b.setAttribute('id', 'persistentChatBtnId');
        b.setAttribute('style', 'display: none');
        b.setAttribute('aria-labelledby', 'msg-us-label');
        b.setAttribute('aria-label', persistentChatLabel);
        return b;
      };
      //
      Object.defineProperty(_instance, 'setupPersistentChat', {
        value: function (persistentChatToggle, persistentChatLabel) {
          if (_instance.persistentChatContainer === false) {
            // create container only if not already created

            _instance.persistentChatContainer =
              constructPersistentChatContainer(persistentChatLabel);

            // delay showing chat everywhere button until either:
            // abc chat button delay amount of time has elapsed for ABC Compatible pages
            // or
            // VA health check has completed
            hidePersistentChatButton();
            appendPersistentChatContainer();
          }
          if (persistentChatToggle) {
            if (_instance.isABCCompatibleDevice && _instance.data.abcEnabled) {
              // for ABC, get config and use that config to determine what needs to be done for that specific page
              getABCConfig(function (err, jabuka) {
                let _abcConfig = { enabled: true };
                if (err) {
                  // assume abc enabled with defaults. if required, special error handling can be done in future
                } else {
                  // got abc config. check this page specific config
                  _abcConfig = getABCPageConfig(jabuka, true);
                }
                if (_abcConfig.enabled) {
                  constructABCButton(_abcConfig);
                } else {
                  constructChatEverywhereButton(persistentChatLabel);
                  showPersistentChatButton();
                }
              });
            } else {
              constructChatEverywhereButton(persistentChatLabel);
              showPersistentChatButton();
            }
          }
        }
      });
      // Set Persistent Parameters
      Object.defineProperty(_instance, 'setPersistentParameters', {
        value: function (persistentSection, persistentChat) {
          _instance.data.persistentSection = persistentSection || [];
          if (!persistentChat) {
            persistentChat = false;
          }
          if (
            _instance.persistentChatContainer !== false &&
            persistentChat === false
          ) {
            hidePersistentChatButton();
          }
          _instance.persistentChatToggle = persistentChat;
          if (persistentChat === true) {
            if (
              !_initCalled ||
              (_instance.persistentChatContainer !== false &&
                (_instance.persistentChatContainer.childElementCount === 0 ||
                  _instance.persistentChatContainer.children.length === 0))
            ) {
              // if init method was not called or if it was called but persistentChatContainer and its children were not created due to toggle being false, create the container again
              _instance.setupPersistentChat(
                persistentChat,
                _instance.getPersistentChatLabel(initParams)
              );
            } else {
              _instance.persistentChatToggle = persistentChat;
              if (!_instance.chatWindowOpen) {
                hideLPM();
                showPersistentChatButton();
              }
            }
          }
        }
      });
      //
      const updateDtcChatEverywhere = function () {
        // show chat everywhere button based on DTC, bot availability and global persistent chat toggle
        if (_instance.persistentChatLabel) {
          _instance.persistentChatLabel.innerText =
            _instance.getPersistentChatLabel(initParams);
        }
        _instance.setPersistentParameters(
          _instance.getPersistentSection(initParams),
          getInitPersistentChatToggle(initParams)
        );
      };
      //

      setTimeout(updateDtcChatEverywhere, 5000);
      convertChatButtonToMessaging();
      if (tacticalAbcEnabled && !_instance.data.abcEnabled) {
        getABCConfig(function (err, data) {
          if (err) {
            sendNRPageAction('__lp__abc', {
              _err: e.message || JSON.stringify(e),
              _stack: e.stack || 'N/A'
            });
          }
        });
      }
      //
      const handleFormMessage = (event) => {
        if (
          event.data === 'msg-form-close' &&
          event.origin.match(/\.telstra\.com(\.au)?$/)
        ) {
          try {
            document
              .querySelector('button[data-lp-point="minimize-slider"]')
              .click();
          } catch (e) {}
        }
      };
      if (window.attachEvent) {
        window.attachEvent('onmessage', handleFormMessage);
      } else {
        window.addEventListener('message', handleFormMessage);
      }
      // END OF TELSTRA LIVEPERSON CLASS CONSTRUCTOR
    }
  });
  Object.freeze(window.TelstraLivePerson);
  if (window.livePerson) {
    throw new Error('Can not redefine this object');
  } else {
    window.lpSettings = window.lpSettings || {};
    Object.defineProperty(window, 'livePerson', {
      value: new window.TelstraLivePerson(window.lpSettings)
    });
    Object.defineProperty(window,'webMessaging', {
      value:  window.livePerson
    });
  }
} catch (e) {
  Object.defineProperty(window, 'disableAuthConversations', { value: true });
  if (newrelic && newrelic.addPageAction) {
    newrelic.addPageAction('__lp__init__error', {
      _error: e.message || e,
      _stack: e.stack || 'N/A'
    });
  }
}    

