import{a as j}from"./chunk-D6DJ2X6M.js";import{ba as y,ja as v}from"./chunk-RTOZFW5D.js";import{h as U}from"./chunk-E56JCP42.js";import{C as h,D as f,b as L}from"./chunk-3T7NQNCJ.js";import{D as l,l as w}from"./chunk-SBF3UK4I.js";import{a as I}from"./chunk-K7QH4WSQ.js";import{Ba as n,Ia as c,Qb as d,ka as m,lb as u}from"./chunk-SGK554CS.js";import{e as s,hc as C,j as o,k as b}from"./chunk-YR2ZOLW3.js";import{Y as g}from"./chunk-VI2VOVRS.js";var k=(()=>{class i{constructor(){this.analyticsService=b(v)}sendAnalyticsCustomEventTrack(t,e){this.analyticsService.sendAnalyticsCustomEventTrack(t,e)}static{this.\u0275fac=function(e){return new(e||i)}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var O=(()=>{class i{constructor(t,e,r,a,S,Z){this.configService=t,this.translateService=e,this.analyticsService=r,this.geoDataService=a,this.loggingService=S,this.analyticsUserPanelService=Z,this.labelBaseContactWithUs="headerStandard.rightMenu.contactWithUs",this.getChatBot=()=>this.configService.getChatbotType(),this.getContactWithUsList=()=>this.configService.getContactWithUsList()}getSupportItemList(t={}){return this.translateService.onLangChange.pipe(g()).subscribe(()=>this.getSupportItemList(t)),I.emptyArray(this.getContactWithUsList())?[]:w(this.mapSupportList(t))}getLabel(t){return this.translateService.instant(`${this.labelBaseContactWithUs}.${t}.label`)??""}getPhoneValue(t){return this.geoDataService.getSnapshot()?.organization?.contactPoint?.telephone||this.getValue(t.keyLabel)}getValue(t){return this.translateService.instant(`${this.labelBaseContactWithUs}.${t}.value`)??""}mapChatbot(t,e={}){let r=this.getChatBot();return{name:t.type,type:r===n.ECI?n.ECI:u.LINK,icon:t.icon,label:this.getLabel(t.keyLabel),url:this.getValue(t.keyLabel),showOnHeaderMenu:t.showOnHeaderMenu,showOnUserMenu:t.showOnUserMenu,showOnSupportMenu:t.showOnSupportMenu,action:()=>{if(!l(e)&&e.emitter&&e.emitter?.emit(),!e.service.openConsumChatBot())try{e.service.openChatBot()}catch{this.loggingService.error("Chat support is not setting")}this.analyticsService.sendAnalyticsContact(d.Chat),this.analyticsUserPanelService.sendAnalyticsCustomEventTrack(y.ContactChat)}}}mapPhone(t,e={}){let r=`tel:${this.getPhoneValue(t)}`;return{name:t.type,type:u.LINK,icon:t.icon,label:this.getLabel(t.keyLabel),url:r,showOnHeaderMenu:t.showOnHeaderMenu,showOnUserMenu:t.showOnUserMenu,showOnSupportMenu:t.showOnSupportMenu,action:()=>{!l(e)&&e.emitter&&e.emitter?.emit(),document.location.href=r,this.analyticsService.sendAnalyticsContact(d.Phone),this.analyticsUserPanelService.sendAnalyticsCustomEventTrack(y.ContactPhone)}}}mapSupportList(t){return this.getContactWithUsList().map(e=>{let r={};return e.type===c.URL&&(r=this.mapUrl(e,t)),e.type===c.Chatbot&&(r=this.mapChatbot(e,t)),e.type===c.Phone&&(r=this.mapPhone(e,t)),r})}mapUrl(t,e={}){let r=this.getValue(t.keyLabel);return{name:t.type,type:u.LINK,icon:t.icon,label:this.getLabel(t.keyLabel),url:r,showOnHeaderMenu:t.showOnHeaderMenu,showOnUserMenu:t.showOnUserMenu,showOnSupportMenu:t.showOnSupportMenu,action:()=>{!l(e)&&e.emitter&&e.emitter?.emit(),window.open(r),this.analyticsService.sendAnalyticsContact(d.Url),this.analyticsUserPanelService.sendAnalyticsCustomEventTrack(y.ContactWithUs)}}}static{this.\u0275fac=function(e){return new(e||i)(o(h),o(L),o(v),o(j),o(f),o(k))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var M=(()=>{class i{initializeChatbot(){throw new Error("Method not implemented for Zendesk chatbot.")}openChatbot(){window.zE.activate()}static{this.\u0275fac=function(e){return new(e||i)}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var T=(()=>{class i{initializeChatbot(){throw new Error("Method not implemented for Zopim chatbot.")}openChatbot(){window.$zopim.livechat.window.show()}static{this.\u0275fac=function(e){return new(e||i)}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var A=(()=>{class i{constructor(t){this.configService=t}initializeChatbot(){let t={app_id:this.configService.getIntercomAppId()};window.Intercom("reattach_activator"),window.Intercom("boot",t),window.Intercom("update",t)}openChatbot(){window.Intercom("show")}static{this.\u0275fac=function(e){return new(e||i)(o(h))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var E=(()=>{class i{constructor(t,e,r,a){this.configService=t,this.zendesk=e,this.zopim=r,this.intercom=a,this.chatbotType=this.configService.getChatbotType()}createChatbotObject(){switch(this.chatbotType){case n.Zopim:return this.zopim;case n.Zendesk:return this.zendesk;case n.Intercom:return this.intercom;default:break}}createChatbotURL(){switch(this.chatbotType){case n.Ces:return this.configService.getCesURL();case n.Zopim:return this.configService.getZopimURL()+this.configService.getZopimAppId();case n.Zendesk:return this.configService.getZendeskURL()+this.configService.getZendeskAppId();case n.Intercom:return this.configService.getIntercomURL()+this.configService.getIntercomAppId();default:break}}getIdScript(){switch(this.chatbotType){case n.Ces:return m.Ces;case n.Zopim:return m.Chatbot;case n.Zendesk:return m.Zendesk;case n.Intercom:return m.Chatbot;default:break}}static{this.\u0275fac=function(e){return new(e||i)(o(h),o(M),o(T),o(A))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var rt=(()=>{class i{constructor(t,e,r,a,S){this.chatBotFactory=t,this.externalSystemsService=e,this._document=r,this.loggingService=a,this.contactService=S}openConsumChatBot(){let t=this._document.querySelector("destygo-webchat");if(t){let e=t.querySelectorAll("#mindsay-widget-app > div");return e.length>0?(e[0].click(),!0):!1}return!!t}setupChatBot(t=!1){this.contactService.getSupportItemList().filter(r=>r.name===c.Chatbot).forEach(r=>{let a=this.isChatbotLoaded();this.isChatbotLoadNeeded(t,r.name,a)?this.loadChatBot(t):a&&this.chatBot&&this.initAndOpenChatbot(t)})}initAndOpenChatbot(t){this.chatBot.initializeChatbot(),t||setTimeout(()=>this.chatBot.openChatbot(),0)}isChatbotLoadNeeded(t,e,r){return(t||e===c.Chatbot)&&!r}isChatbotLoaded(){let t=this._document.getElementById("ang-chatbot");return t??=this._document.getElementById("ze-snippet"),t??=this._document.getElementById("tolito-chat"),!!t}loadChatBot(t){this.contactService.getChatBot()!==n.Default&&this.externalSystemsService.loadScript(this.contactService.getChatBot(),this.chatBotFactory.createChatbotURL(),this.chatBotFactory.getIdScript(),[],!1).then(e=>{e.load&&(this.chatBot=this.chatBotFactory.createChatbotObject(),this.chatBot&&this.initAndOpenChatbot(t))}).catch(e=>{this.loggingService.error(e)})}static{this.\u0275fac=function(e){return new(e||i)(o(E),o(U),o(C),o(f),o(O))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();export{k as a,O as b,rt as c};