fsaocts.my.salesforce.com Open in urlscan Pro
18.253.163.201  Public Scan

URL: https://fsaocts.my.salesforce.com/embeddedservice/5.0/frame/chasitor.esw.min.js
Submission Tags: falconsandbox
Submission: On November 21 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

/*
 Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations. 
*/
window.esw.defineFeature("Chasitor",function(c){function e(){this.esw=c;this.receiveIsTabPrimaryFunction=this.isTabPrimary=this.chatKey=this.chatWindowStateName=this.prechatEntities=this.prechatFormDetails=this.chasitorSettings=this.events=this.liveAgentChasitor=void 0;this.registerMessageHandlers();"mobile"!==c.getSafariType()&&this.registerBroadcastHandlers();c.loadFeatureScript("FileTransfer");window.addEventListener("pagehide",function(){this.chasitorSettings&&this.chasitorSettings.deploymentId&&
this.decrementActiveChatSession(this.chasitorSettings.deploymentId)}.bind(this),{capture:!0})}function m(a){var b="";if(a&&"string"===typeof a)return a;"ChatWindowButton"===a.type?b+="Button Selections:":"ChatWindowMenu"===a.type&&(b+="Menu Options:");a.items&&a.items.forEach(function(d){b+="\n\t"+d.text});return b}var l=/get[A-Z][A-Za-z0-9_]*/,k=".soma.salesforce.com .salesforceliveagent.com .internal.salesforce.com .eng.sfdc.net .gus.salesforce.com .salesforcescrt.com .stm.salesforce.com .salesforce.ms .salesforce.mil".split(" ");
e.prototype.sendBroadcastEventToSecondaryTabs=function(a,b){b=b||{};b.domain||(b.domain=this.domain);b.chatKey||(b.chatKey=this.chatKey);c.broadcastAPI.send(a,b)};e.prototype.getChatKeyFromSessionStorage=function(a){if((a=JSON.parse(c.sessionAPI.getSessionData(a,["CHASITOR_SERIALIZED_KEY"]).CHASITOR_SERIALIZED_KEY))&&a.chasitorData)return a.chasitorData.chatKey};e.prototype.isChatKeyValid=function(a){a||c.log("Chat key was not defined on receiving broadcast event.");return this.chatKey===a};e.prototype.registerMessageHandlers=
function(){c.addMessageHandler("chasitor.load",this.loadChasitor.bind(this));c.addMessageHandler("chasitor.sendMessage",function(a,b){this.sendMessage(b)}.bind(this));c.addMessageHandler("chasitor.sendRichMessage",function(a,b){this.sendRichMessage(b)}.bind(this));c.addMessageHandler("chasitor.cancelChat",function(){this.cancelChat()}.bind(this));c.addMessageHandler("chasitor.endChat",function(){this.endChat()}.bind(this));c.addMessageHandler("chasitor.abortConnection",function(){this.abortConnection()}.bind(this));
c.addMessageHandler("chasitor.sendSneakPeekOrTypingUpdate",function(a,b){this.sendSneakPeekOrTypingUpdate(b)}.bind(this));c.addMessageHandler("chasitor.saveChat",function(){this.saveChat()}.bind(this));c.addMessageHandler("chasitor.updateChatWindowState",function(a,b){this.updateChatWindowState(b)}.bind(this));c.addMessageHandler("chasitor.removeEventListeners",function(){this.removeEventListeners()}.bind(this));c.addMessageHandler("chasitor.stopChasitorIdleTimeout",function(){this.stopChasitorIdleTimeout()}.bind(this));
c.addMessageHandler("chasitor.sendCustomEvent",function(a,b){this.sendCustomEvent(b)}.bind(this));c.addMessageHandler("chasitor.getCustomEvents",function(){this.getCustomEvents()}.bind(this));c.addMessageHandler("chasitor.addCustomEventListener",function(a,b){this.addCustomEventListener(b)}.bind(this));c.addMessageHandler("chasitor.decrementActiveChatSession",function(a,b){this.decrementActiveChatSession(a,b)}.bind(this))};e.prototype.registerBroadcastHandlers=function(){c.broadcastAPI.on("incrementActiveChatSession",
function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.incrementActiveChatSession()}.bind(this));c.broadcastAPI.on("decrementActiveChatSession",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.decrementActiveChatSession()}.bind(this));c.broadcastAPI.on("liveAgentChasitorEvent",function(a){this.isChatKeyValid(a.chatKey)&&!this.isTabPrimary&&parent.postMessage({method:"liveagent.event",data:a},c.parentOrigin)}.bind(this));c.broadcastAPI.on("gatherChasitorSessionData",
function(a){this.liveAgentChasitor&&this.gatherChasitorSessionData(a)}.bind(this));c.broadcastAPI.on("sendMessage",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.sendMessage(a.message)}.bind(this));c.broadcastAPI.on("sendRichMessage",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.sendRichMessage(a.message)}.bind(this));c.broadcastAPI.on("serializeChat",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.serializeChat()}.bind(this));
c.broadcastAPI.on("cancelChat",function(a){this.isChatKeyValid(a.chatKey)&&(parent.postMessage({method:"liveagent.chatCanceledOnDifferentTab"},c.parentOrigin),this.liveAgentChasitor&&this.cancelChat())}.bind(this));c.broadcastAPI.on("endChat",function(a){this.isChatKeyValid(a.chatKey)&&(parent.postMessage({method:"liveagent.chatCanceledOnDifferentTab"},c.parentOrigin),this.liveAgentChasitor&&this.endChat())}.bind(this));c.broadcastAPI.on("abortConnection",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&
this.abortConnection()}.bind(this));c.broadcastAPI.on("sendCustomEvent",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.sendCustomEvent(a)}.bind(this));c.broadcastAPI.on("addCustomEventListener",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.addCustomEventListener()}.bind(this));c.broadcastAPI.on("sendSneakPeekOrTypingUpdate",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.sendSneakPeekOrTypingUpdate(a.message)}.bind(this));
c.broadcastAPI.on("saveChat",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.saveChat()}.bind(this));c.broadcastAPI.on("removeEventListeners",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.removeEventListeners()}.bind(this));c.broadcastAPI.on("stopChasitorIdleTimeout",function(a){this.liveAgentChasitor&&this.isChatKeyValid(a.chatKey)&&this.stopChasitorIdleTimeout()}.bind(this));c.broadcastAPI.on("getQueuePosition",function(a){this.liveAgentChasitor&&
this.isChatKeyValid(a.chatKey)&&this.getQueuePosition()}.bind(this));c.broadcastAPI.on("getIsTabPrimary",function(a){a.domain===this.domain&&a.deploymentId===this.chasitorSettings.deploymentId&&c.broadcastAPI.send("receiveIsTabPrimary",{isPrimary:this.isTabPrimary,domain:this.domain,deploymentId:this.chasitorSettings.deploymentId})}.bind(this));c.broadcastAPI.on("receiveIsTabPrimary",function(a){a.domain===this.domain&&a.deploymentId===this.chasitorSettings.deploymentId&&this.receiveIsTabPrimaryFunction&&
"undefined"===typeof this.isTabPrimary&&this.receiveIsTabPrimaryFunction(a.isPrimary)}.bind(this))};e.prototype.setChasitorData=function(a,b){this.verifyScriptUrl(b.settingsObj.chasitorSrc);this.verifyScriptUrl(b.settingsObj.endpointURL,"Invalid chat endpoint; valid choices are: "+k.join(", "));this.domain=a;this.chasitorSettings=b.settingsObj;this.hasOnlyExtraPrechatInfo=b.hasOnlyExtraPrechatInfo;this.prechatFormDetails=[];this.prechatEntities=[];Array.isArray(b.prechatFormDetails)&&b.prechatFormDetails.length?
(this.prechatFormDetails=b.prechatFormDetails,c.sessionAPI.setSessionData(this.domain,{PRECHAT_FORM_DETAILS:JSON.stringify(this.prechatFormDetails)})):c.sessionAPI.getSessionData(this.domain,["PRECHAT_FORM_DETAILS"])&&c.sessionAPI.getSessionData(this.domain,["PRECHAT_FORM_DETAILS"]).PRECHAT_FORM_DETAILS&&(this.prechatFormDetails=JSON.parse(c.sessionAPI.getSessionData(this.domain,["PRECHAT_FORM_DETAILS"]).PRECHAT_FORM_DETAILS));Array.isArray(b.prechatEntities)&&b.prechatEntities.length?(this.prechatEntities=
b.prechatEntities,c.sessionAPI.setSessionData(this.domain,{PRECHAT_ENTITIES:JSON.stringify(this.prechatEntities)})):c.sessionAPI.getSessionData(this.domain,["PRECHAT_ENTITIES"])&&c.sessionAPI.getSessionData(this.domain,["PRECHAT_ENTITIES"]).PRECHAT_ENTITIES&&(this.prechatEntities=JSON.parse(c.sessionAPI.getSessionData(this.domain,["PRECHAT_ENTITIES"]).PRECHAT_ENTITIES))};e.prototype.createScriptElement=function(){var a=document.createElement("script");a.id="chasitorScript";a.type="text/javascript";
a.onload=function(){this.chasitorInit()}.bind(this);a.onerror=function(){throw Error("Loading chasitor script from SCRT threw an error.");};a.src=this.chasitorSettings.chasitorSrc;document.getElementsByTagName("head")[0].appendChild(a)};e.prototype.serializeChat=function(){if(this.liveAgentChasitor&&!this.liveAgentChasitor.isChatEnded()&&(this.liveAgentChasitor.isChatRequestSuccessful()||this.liveAgentChasitor.isChatEngaged())){var a=this.liveAgentChasitor.serialize();a=JSON.parse(a);a.chasitorData.isChatEstablished=
"Chat"===this.chatWindowStateName;c.sessionAPI.setSessionData(this.domain,{CHASITOR_SERIALIZED_KEY:JSON.stringify(a)})}};e.prototype.handleLiveAgentChasitorEvent=function(a,b){var d=b;0<="chasitorAgentChatEnded chasitorAgentDisconnected chasitorChasitorChatCanceled chasitorChatRequestFailed chasitorConnectionError chatbotEndedChat postChat".split(" ").indexOf(a)&&(this.esw.sessionAPI.deleteSessionData(this.domain,["MASTER_DEPLOYMENT_ID"]),this.removeActiveChatSession(this.domain,this.chasitorSettings.deploymentId));
a===this.liveAgentChasitor.Events.CHAT_REQUEST_SUCCESSFUL&&(this.chatKey=this.liveAgentChasitor.getChatKey());"object"===typeof b?(d={},Object.getOwnPropertyNames(b).forEach(function(g){"function"===typeof b[g]&&l.test(g)?d[g]=b[g]():d[g]=b[g]})):d=b;var f={event:a,params:d,chasitorData:this.gatherChasitorSessionData()};"chasitorChatRequestSuccessful"!==a&&this.sendBroadcastEventToSecondaryTabs("liveAgentChasitorEvent",f);parent.postMessage({method:"liveagent.event",data:f},c.parentOrigin)};e.prototype.registerEvents=
function(){this.events&&Object.keys(this.events).forEach(function(a){a=this.events[a];this.liveAgentChasitor.addEventListener(a,this.handleLiveAgentChasitorEvent.bind(this,a),"ESW_"+a)}.bind(this))};e.prototype.passPrechatDataToLiveAgent=function(){void 0!==this.prechatFormDetails&&this.prechatFormDetails.length&&(this.prechatFormDetails.forEach(function(a){var b=a.value,d=a.transcriptFields;"string"===typeof b&&(b=a.value.trim());var f=this.liveAgentChasitor.addCustomDetail(a.label,b,a.displayToAgent);
d&&d.forEach(f.addTranscriptField);"FirstName"===a.name&&(this.liveAgentChasitor.setName(b),this.liveAgentChasitor.setLocalName(b))}.bind(this)),this.liveAgentChasitor.addCustomDetail("eswLiveAgentDevName",this.chasitorSettings.eswLiveAgentDevName,!1),this.liveAgentChasitor.addCustomDetail("hasOnlyExtraPrechatInfo",this.hasOnlyExtraPrechatInfo,!1),this.prechatEntities.forEach(function(a){this.liveAgentChasitor.addEntity(a.entityName,a.showOnCreate,a.linkToEntityName,a.linkToEntityField,a.saveToTranscript);
a.entityFieldMaps.forEach(function(b){this.liveAgentChasitor.addEntityFieldsMap(a.entityName,b.fieldName,b.label,b.doFind,b.isExactMatch,b.doCreate)}.bind(this))}.bind(this)))};e.prototype.passCustomDetailsToLiveAgent=function(){this.chasitorSettings.hasOwnProperty("chatbotVersion")&&this.chasitorSettings.chatbotVersion&&this.liveAgentChasitor.addCustomDetail("chatbotVersion",this.chasitorSettings.chatbotVersion,!1)};e.prototype.isNewChatSession=function(){return!c.sessionAPI.getSessionData(this.domain,
["CHASITOR_SERIALIZED_KEY"]).CHASITOR_SERIALIZED_KEY};e.prototype.gatherChasitorSessionData=function(a){var b={chasitorSettings:this.chasitorSettings,acceptTime:this.liveAgentChasitor.getAcceptTime(),requestTime:this.liveAgentChasitor.getRequestTime(),oref:this.liveAgentChasitor.getOref(),chatKey:this.liveAgentChasitor.getChatKey(),connectionSessionId:this.liveAgentChasitor.getConnectionSessionId(),details:this.liveAgentChasitor.getDetails(),name:this.liveAgentChasitor.getName(),chatMessages:this.getChatMessages(),
isSneakPeekEnabled:this.liveAgentChasitor.isSneakPeekEnabled(),isAgentTyping:this.liveAgentChasitor.isAgentTyping(),isFileRequested:this.liveAgentChasitor.isFileRequested(),isChatEstablished:this.liveAgentChasitor.isChatEstablished(),isChatEngaged:this.liveAgentChasitor.isChatEngaged(),isChatEnded:this.liveAgentChasitor.isChatEnded(),isChatRequestSuccessful:this.liveAgentChasitor.isChatRequestSuccessful(),isChatTransferredToBot:this.liveAgentChasitor.isChatTransferredToBot(),isChatTransferredToQueue:this.liveAgentChasitor.isChatTransferredToQueue(),
isChatTransferredToSbrSkill:this.liveAgentChasitor.isChatTransferredToSbrSkill(),queuePosition:this.liveAgentChasitor.getQueuePosition(),orgId:this.liveAgentChasitor.getOrgId(),language:this.liveAgentChasitor.getLanguage(),lastUrl:this.liveAgentChasitor.getLastUrl(),transcriptSaveEnabled:this.liveAgentChasitor.getTranscriptSaveEnabled()};a&&(b.isSnapinsSecondaryTab=!0,this.sendBroadcastEventToSecondaryTabs("chasitorSessionDataRefreshed",b));return b};e.prototype.getChatMessages=function(){var a=[];
this.liveAgentChasitor.getChatMessages().forEach(function(b){var d={};Object.getOwnPropertyNames(b).forEach(function(f){"function"===typeof b[f]&&l.test(f)&&(d[f]=b[f]())});a.push(d)});return a};e.prototype.initializeChasitor=function(){var a=this.chasitorSettings.endpointURL,b=this.chasitorSettings.contentServerURL,d=this.chasitorSettings.visitorInfo;this.liveAgentChasitor.resetChasitorState();this.liveAgentChasitor.setOrgId(this.chasitorSettings.orgId);this.liveAgentChasitor.setDeploymentId(this.chasitorSettings.deploymentId);
this.liveAgentChasitor.setButtonId(this.chasitorSettings.buttonId);this.passPrechatDataToLiveAgent();this.passCustomDetailsToLiveAgent();this.liveAgentChasitor.setReceiveQueueUpdates(this.chasitorSettings.isQueuePositionEnabled||!1);this.liveAgentChasitor.setVisitorInfo(d.visitCount,d.originalReferrer,d.pages);this.liveAgentChasitor.init(a,b,this.chasitorSettings.fallbackRouting,!1);this.liveAgentChasitor.startChat("snapins");parent.postMessage({method:"liveagent.initialized",data:{chasitorEvents:this.events,
chasitorSessionData:this.gatherChasitorSessionData()}},c.parentOrigin)};e.prototype.restoreSession=function(){var a=!1;if(this.liveAgentChasitor)this.liveAgentChasitor.deserialize(c.sessionAPI.getSessionData(this.domain,["CHASITOR_SERIALIZED_KEY"]).CHASITOR_SERIALIZED_KEY),this.liveAgentChasitor.setReceiveQueueUpdates(this.chasitorSettings.isQueuePositionEnabled),this.liveAgentChasitor.init(this.chasitorSettings.endpointURL,this.chasitorSettings.contentServerURL,this.chasitorSettings.fallbackRouting,
!1),this.liveAgentChasitor.reinitializeSession(),this.liveAgentChasitor.restoreChasitorIdleTimeout(),this.chatKey=this.liveAgentChasitor.getChatKey(),parent.postMessage({method:"liveagent.restored",data:{chasitorEvents:this.events,chasitorSessionData:this.gatherChasitorSessionData()}},c.parentOrigin);else{var b=JSON.parse(c.sessionAPI.getSessionData(this.domain,["CHASITOR_EVENTS"]).CHASITOR_EVENTS);this.chatKey=this.getChatKeyFromSessionStorage(this.domain);c.broadcastAPI.on("chasitorSessionDataRefreshed",
function(d){a||(parent.postMessage({method:"liveagent.restored",data:{chasitorEvents:b,chasitorSessionData:d}},c.parentOrigin),a=!0)});c.broadcastAPI.send("gatherChasitorSessionData","secondaryTabRestore")}};e.prototype.chasitorInit=function(){this.liveAgentChasitor=window.liveagent.chasitor;Object.defineProperty(this,"events",{get:function(){return this.liveAgentChasitor.Events}.bind(this)});c.sessionAPI.setSessionData(this.domain,{CHASITOR_EVENTS:JSON.stringify(this.liveAgentChasitor.Events)});
this.registerEvents();this.liveAgentChasitor.onMutate=function(){this.serializeChat()}.bind(this);this.startChatSession()};e.prototype.startChatSession=function(){this.isNewChatSession()?this.initializeChasitor():this.restoreSession()};e.prototype.sendMessage=function(a){var b={};this.liveAgentChasitor?this.liveAgentChasitor.sendMessage(a):document.hidden||(b.message=a,this.sendBroadcastEventToSecondaryTabs("sendMessage",b))};e.prototype.sendRichMessage=function(a){var b={};this.liveAgentChasitor?
this.liveAgentChasitor.sendSnapInRichMessage(a):document.hidden||(b.message=a,this.sendBroadcastEventToSecondaryTabs("sendRichMessage",b))};e.prototype.cancelChat=function(){this.liveAgentChasitor&&(this.liveAgentChasitor.cancelChat(),this.removeActiveChatSession(this.domain,this.chasitorSettings.deploymentId));this.esw.sessionAPI.deleteSessionData(this.domain,["CHASITOR_SERIALIZED_KEY","MASTER_DEPLOYMENT_ID","PRECHAT_FORM_DETAILS","PRECHAT_ENTITIES"]);this.sendBroadcastEventToSecondaryTabs("cancelChat")};
e.prototype.endChat=function(){if(this.liveAgentChasitor)try{this.liveAgentChasitor.endChat(),this.removeActiveChatSession(this.domain,this.chasitorSettings.deploymentId)}catch(a){console.error(a)}this.esw.sessionAPI.deleteSessionData(this.domain,["CHASITOR_SERIALIZED_KEY","MASTER_DEPLOYMENT_ID","PRECHAT_FORM_DETAILS","PRECHAT_ENTITIES"]);this.sendBroadcastEventToSecondaryTabs("endChat")};e.prototype.getQueuePosition=function(){if(this.liveAgentChasitor&&this.chasitorSettings.isQueuePositionEnabled)return this.liveAgentChasitor.getQueuePosition();
this.sendBroadcastEventToSecondaryTabs("getQueuePosition")};e.prototype.removeActiveChatSession=function(a,b){var d=JSON.parse(c.sessionAPI.getSessionData(a,["ACTIVE_CHAT_SESSIONS"],!0).ACTIVE_CHAT_SESSIONS||"{}");delete d[b];c.sessionAPI.setSessionData(a,{ACTIVE_CHAT_SESSIONS:JSON.stringify(d)},!0);this.updatePrimary(!1,0)};e.prototype.incrementActiveChatSession=function(){var a=this.domain?JSON.parse(c.sessionAPI.getSessionData(this.domain,["ACTIVE_CHAT_SESSIONS"],!0).ACTIVE_CHAT_SESSIONS||"{}"):
"{}",b=this.chasitorSettings.deploymentId;this.liveAgentChasitor?(a[b]||(a[b]=0),a[b]+=1,c.sessionAPI.setSessionData(this.domain,{ACTIVE_CHAT_SESSIONS:JSON.stringify(a)},!0),c.log("Setting number of tabs for deploymentId "+b+" to: "+a[b]),this.updatePrimary(!0,a[b])):(this.updatePrimary(!1,a[b]+1),this.sendBroadcastEventToSecondaryTabs("incrementActiveChatSession"))};e.prototype.decrementActiveChatSession=function(){var a=this.domain?JSON.parse(c.sessionAPI.getSessionData(this.domain,["ACTIVE_CHAT_SESSIONS"],
!0).ACTIVE_CHAT_SESSIONS||"{}"):"{}",b=this.chasitorSettings?this.chasitorSettings.deploymentId:void 0;this.liveAgentChasitor?(a=this.domain?JSON.parse(c.sessionAPI.getSessionData(this.domain,["ACTIVE_CHAT_SESSIONS"],!0).ACTIVE_CHAT_SESSIONS||"{}"):"{}",a[b]?--a[b]:c.log("Decrement active chat sessions : Local Storage item ACTIVE_CHAT_SESSIONS not found for deployment id :"+b),c.sessionAPI.setSessionData(this.domain,{ACTIVE_CHAT_SESSIONS:JSON.stringify(a)},!0),c.log("Setting number of tabs for deploymentId "+
b+" to: "+a[b]),this.updatePrimary(!0,a[b])):(this.updatePrimary(!1,a[b]-1),this.sendBroadcastEventToSecondaryTabs("decrementActiveChatSession"))};e.prototype.updatePrimary=function(a,b){a={};a.isPrimary=this.isTabPrimary;a.activeChatSessions=b;c.postMessage("session.updatePrimary",a)};e.prototype.loadChasitorSecondaryTab=function(){this.restoreSession();this.incrementActiveChatSession()};e.prototype.loadChasitorPrimaryTab=function(a,b){b=b.settingsObj.deploymentId;var d=JSON.parse(c.sessionAPI.getSessionData(a,
["ACTIVE_CHAT_SESSIONS"],!0).ACTIVE_CHAT_SESSIONS||"{}"),f=document.getElementById("chasitorScript");f&&(f.parentNode.removeChild(f),[].slice.apply(document.querySelectorAll("iframe")).forEach(function(g){var h=g.getAttribute("src");h&&-1!==h.indexOf("cdm")&&g.parentNode.removeChild(g)}),this.removeEventListeners());this.verifyScriptUrl(this.chasitorSettings.chasitorSrc);this.verifyScriptUrl(this.chasitorSettings.endpointURL,"Invalid chat endpoint; valid choices are: "+k.join(", "));this.createScriptElement();
c.sessionAPI.setSessionData(a,{MASTER_DEPLOYMENT_ID:b});"mobile"!==c.getSafariType()&&(d[b]?d[b]+=1:d[b]=1,c.sessionAPI.setSessionData(a,{ACTIVE_CHAT_SESSIONS:JSON.stringify(d)},!0));this.updatePrimary(!0,1)};e.prototype.loadChasitor=function(a,b){var d=b.settingsObj.deploymentId,f=JSON.parse(c.sessionAPI.getSessionData(a,["ACTIVE_CHAT_SESSIONS"],!0).ACTIVE_CHAT_SESSIONS||"{}")[d]||0;this.setChasitorData(a,b);this.receiveIsTabPrimaryFunction=function(g){g?(this.isTabPrimary=!1,this.loadChasitorSecondaryTab(),
c.broadcastAPI.off("receiveIsTabPrimary")):1!==f||g?--f:(this.isTabPrimary=!0,this.loadChasitorPrimaryTab(a,b),c.broadcastAPI.off("receiveIsTabPrimary"))}.bind(this);0===f||c.isInternetExplorer()||c.isEdge()?(this.isTabPrimary=!0,this.loadChasitorPrimaryTab(a,b)):c.broadcastAPI.send("getIsTabPrimary",{domain:this.domain,deploymentId:d})};e.prototype.verifyScriptUrl=function(a,b){if(window.URL&&"function"===typeof window.URL){var d=new URL(a);protocol=d.protocol;d=d.hostname}else-1<a.indexOf("//")&&
(d=a.split("/"),protocol=d[0],d=d[2]),d=d.split(":")[0],d=d.split("?")[0];if("https:"!==protocol||!this.isValidHostname(d))throw Error(b||"Chasitor script served from invalid host! Chasitor script must use https: protocol and come from one of the following domains: "+k.join(", "));if(/[%?&]/.test(a)||a.includes(".."))throw Error(b||"Script URL has invalid content");};e.prototype.isValidHostname=function(a){return k.some(function(b){return 0<a.indexOf(b,a.length-b.length)})};e.prototype.sendSneakPeekOrTypingUpdate=
function(a){var b={};this.liveAgentChasitor?this.liveAgentChasitor.isSneakPeekEnabled()?this.liveAgentChasitor.sendSneakPeek(a):this.liveAgentChasitor.sendTypingUpdate(a.length):(b.message=a,this.sendBroadcastEventToSecondaryTabs("sendSneakPeekOrTypingUpdate",b))};e.prototype.saveChat=function(){var a="",b=[],d=[],f=[];this.liveAgentChasitor?this.isIOS()&&14>this.getOSVersion()?(this.liveAgentChasitor.getChatMessages().forEach(function(g){var h=g.getContent();"string"!==typeof h&&(h=m(h));h&&(b.push(g.getName()),
d.push(g.getTimestamp()),f.push(h))}),a=JSON.stringify({names:b,timestamps:d,messages:f}),c.postMessage("liveagent.saveChatIOSCallback",{chasitorData:this.gatherChasitorSessionData(),textLog:a})):this.liveAgentChasitor.saveChat():document.hidden||this.sendBroadcastEventToSecondaryTabs("saveChat")};e.prototype.isIOS=function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream};e.prototype.getOSVersion=function(){var a=navigator.userAgent.match(/OS (\d+)(_\d+)+/);return a?parseInt(a[1]):
-1};e.prototype.abortConnection=function(){this.liveAgentChasitor?(this.liveAgentChasitor.abortConnection(),this.serializeChat()):this.sendBroadcastEventToSecondaryTabs("abortConnection")};e.prototype.serialize=function(){this.liveAgentChasitor.serialize()};e.prototype.sendCustomEvent=function(a){this.liveAgentChasitor?this.liveAgentChasitor.sendCustomEvent(a.type,a.data):this.sendBroadcastEventToSecondaryTabs("sendCustomEvent",a)};e.prototype.getCustomEvents=function(){var a=this.liveAgentChasitor.getCustomEvents().map(function(b){return{source:b.getSource(),
type:b.getType(),data:b.getData(),date:b.getDate()}});a=JSON.stringify(a);parent.postMessage({method:"liveagent.getCustomEventsResult",data:{customEvents:a}},c.parentOrigin)};e.prototype.addCustomEventListener=function(a){var b=function(d){parent.postMessage({method:"liveagent.customEventReceived",data:{type:d.getType(),data:d.getData()}},c.parentOrigin)};this.liveAgentChasitor?this.liveAgentChasitor.addCustomEventListener(a,b):this.sendBroadcastEventToSecondaryTabs("addCustomEventListener",a)};e.prototype.removeEventListeners=
function(){this.liveAgentChasitor?window.liveagent.removeEventListeners():this.sendBroadcastEventToSecondaryTabs("removeEventListeners")};e.prototype.updateChatWindowState=function(a){this.chatWindowStateName=a;this.liveAgentChasitor?this.serializeChat():this.sendBroadcastEventToSecondaryTabs("serializeChat")};e.prototype.stopChasitorIdleTimeout=function(){this.liveAgentChasitor?this.liveAgentChasitor.stopChasitorIdleTimeout():this.sendBroadcastEventToSecondaryTabs("stopChasitorIdleTimeout")};c.chasitorAPI=
new e});