{"version":3,"names":["SoundServiceController","constructor","assetsBaseUrl","prefix","this","Error","controllers","getSoundPath","fileName","SoundService","configurationPrefix","baseUrl","ChatbotTunnel","tunnelPageUrl","_iframe","document","getElementById","tunnelOrigin","getOrigin","window","createElement","id","src","head","appendChild","sessionDataFound","Promise","resolve","resolveSessionDataFound","addEventListener","receiveMessage","bind","chatWindowsOpened","agent","startIntent","welcomeIntent","botName","postMessageWindowOpened","postMessageRetrieveCurrentData","setTimeout","contentWindow","postMessage","type","data","dialogFlowAgent","refreshSessionToken","resolveSessionTokenRefreshed","updateInactivityTimer","timer","updateExtraData","multiSelect","quickReplies","suggestions","chatbotLiveSession","liveChatConnectionBeingEstablished","queuePosition","unreadMessages","chatMinimized","optionButtons","currentLanguage","loginFollowupEvent","notLoginFollowupEvent","hasBeenRedirectedToLogin","uploadFileButton","showAllQuickReplies","caseOverview","datePicker","faqs","enableUploadFileLiveAgent","amountOfFilesUploadedLiveAgent","newMessagesReceived","messages","clearChat","event","origin","url","temp","href"],"sources":["./src/helpers/sound.service.ts","./src/components/pnl-chatbot-trigger/chatbot-tunnel.ts"],"sourcesContent":["// Interface of the soundService because we won't expose the soundServiceController because it has to have a non-public constructor. \nexport interface ISoundService {\n getSoundPath(fileName: string): string;\n}\n\nclass SoundServiceController {\n constructor(private assetsBaseUrl: string, prefix: string) {\n if (!assetsBaseUrl) {\n throw new Error('Could not create new soundService without assetsBaseUrl');\n }\n controllers[prefix] = this;\n }\n\n public getSoundPath(fileName: string): string {\n return this.assetsBaseUrl + 'sounds/' + fileName;\n } \n}\n\nconst controllers = {}\n\n// SoundService is setUp as a Singleton per type. \n// This gives the possibility to create a SoundService for the chatbot and a soundService for the account part. \n// For each type, the SoundService has to be initiated once with a baseUrl and a configurationPrefix (for example 'chatbot' or 'account').\n// After the initialization every component can just get the service by calling SoundService({type});\nexport const SoundService = (configurationPrefix: string, baseUrl = null): ISoundService => {\n return !!controllers[configurationPrefix] ?\n controllers[configurationPrefix] :\n new SoundServiceController(baseUrl, configurationPrefix);\n}\n ","import { ChatbotMessage } from '../pnl-chatbot-container/pnl-chatbot-messages/pnl-chatbot-message/pnl-chatbot-message';\nimport {\n ChatbotCaseOverview,\n ChatbotDatePicker,\n ChatbotFaq,\n ChatbotMultiSelect,\n ChatbotResponseButton,\n ChatbotResponseOptionButtons,\n ChatbotUploadFileButton\n} from '../pnl-chatbot-container/models/chatbot.models';\nimport { ChatbotLiveSession } from '../pnl-chatbot-container/pnl-chatbot-live-session/pnl-chatbot-live-session';\n\nexport class sessionData {\n sessionId: string;\n dialogFlowAgent: string;\n welcomeIntent: string;\n startIntent: string;\n botName: string;\n messages: ChatbotMessage[];\n suggestions: Array;\n multiSelect: ChatbotMultiSelect;\n quickReplies: Array;\n optionButtons: ChatbotResponseOptionButtons;\n chatbotLiveSession: ChatbotLiveSession;\n inactivityTimeout: number;\n chatMinimized: boolean;\n unreadMessages: number;\n liveChatConnectionBeingEstablished: boolean;\n queuePosition: number;\n currentLanguage: string;\n loginFollowupEvent: string;\n notLoginFollowupEvent: string;\n hasBeenRedirectedToLogin: boolean;\n uploadFileButton: string;\n caseOverview: ChatbotCaseOverview;\n showAllQuickReplies: boolean;\n datePicker: ChatbotDatePicker;\n faqs: ChatbotFaq[];\n enableUploadFileLiveAgent: boolean;\n amountOfFilesUploadedLiveAgent: number;\n}\n\nexport class ChatbotTunnel {\n public sessionDataFound: Promise;\n private _iframe?: HTMLIFrameElement;\n private tunnelOrigin: string;\n private resolveSessionDataFound: (value?: sessionData | PromiseLike) => void;\n private resolveSessionTokenRefreshed: (value?: string | PromiseLike) => void;\n\n constructor(\n private tunnelPageUrl: string\n ) {\n this._iframe = document.getElementById('chatbot-tunnel') as HTMLIFrameElement;\n this.tunnelOrigin = this.getOrigin(this.tunnelPageUrl);\n if (!this._iframe) {\n this._iframe = window.document.createElement('iframe');\n this._iframe.id = 'chatbot-tunnel';\n this._iframe.src = this.tunnelPageUrl;\n window.document.head!.appendChild(this._iframe);\n }\n\n this.sessionDataFound = new Promise((resolve) => {\n this.resolveSessionDataFound = resolve;\n });\n\n window.addEventListener('message', this.receiveMessage.bind(this), false);\n }\n\n public chatWindowsOpened(agent: string, startIntent: string, welcomeIntent: string, botName: string) {\n this._iframe.addEventListener('load', () => {\n this.postMessageWindowOpened(agent, startIntent, welcomeIntent, botName);\n });\n this.postMessageWindowOpened(agent, startIntent, welcomeIntent, botName);\n }\n\n public postMessageRetrieveCurrentData() {\n // we need to let the page render the iframe before sending request\n setTimeout(() => {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:retrieve-current-data'\n }, this.tunnelOrigin);\n }, 500);\n }\n\n private postMessageWindowOpened(agent: string, startIntent: string, welcomeIntent: string, botName: string ) {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:chat-window-opened',\n data: {\n startIntent: startIntent,\n welcomeIntent: welcomeIntent,\n dialogFlowAgent: agent,\n botName: botName\n }\n }, this.tunnelOrigin);\n }\n\n public refreshSessionToken(): Promise {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:refresh-session-token',\n }, this.tunnelOrigin)\n\n return new Promise((resolve) => this.resolveSessionTokenRefreshed = resolve );\n }\n\n public updateInactivityTimer(timer: number) {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:inactivity-timer-changed',\n data: timer\n }, this.tunnelOrigin);\n }\n\n public updateExtraData(\n multiSelect: ChatbotMultiSelect,\n quickReplies: Array,\n suggestions: Array,\n chatbotLiveSession: ChatbotLiveSession,\n liveChatConnectionBeingEstablished: boolean,\n queuePosition: number,\n unreadMessages: number,\n chatMinimized: boolean,\n optionButtons: ChatbotResponseOptionButtons,\n currentLanguage: string,\n loginFollowupEvent: string,\n notLoginFollowupEvent: string,\n hasBeenRedirectedToLogin: boolean,\n uploadFileButton: ChatbotUploadFileButton,\n showAllQuickReplies: boolean,\n caseOverview: ChatbotCaseOverview,\n datePicker: ChatbotDatePicker,\n faqs: ChatbotFaq[],\n enableUploadFileLiveAgent: boolean,\n amountOfFilesUploadedLiveAgent: number) {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:extra-data-update',\n data: {\n multiSelect: multiSelect,\n suggestions: suggestions,\n quickReplies: quickReplies,\n chatbotLiveSession: chatbotLiveSession,\n liveChatConnectionBeingEstablished: liveChatConnectionBeingEstablished,\n queuePosition: queuePosition,\n unreadMessages: unreadMessages,\n chatMinimized: chatMinimized,\n optionButtons: optionButtons,\n currentLanguage: currentLanguage,\n loginFollowupEvent: loginFollowupEvent,\n notLoginFollowupEvent: notLoginFollowupEvent,\n hasBeenRedirectedToLogin: hasBeenRedirectedToLogin,\n uploadFileButton: uploadFileButton,\n caseOverview: caseOverview,\n showAllQuickReplies: showAllQuickReplies,\n datePicker: datePicker,\n faqs: faqs,\n enableUploadFileLiveAgent: enableUploadFileLiveAgent,\n amountOfFilesUploadedLiveAgent: amountOfFilesUploadedLiveAgent\n }\n }, this.tunnelOrigin);\n }\n\n public newMessagesReceived(messages: Array) {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:new-chat-messages',\n data: messages\n }, this.tunnelOrigin);\n }\n\n public clearChat() {\n this._iframe.contentWindow.postMessage({\n type: 'postnl:chatbot:clear-chat',\n }, this.tunnelOrigin);\n }\n\n private receiveMessage(event: MessageEvent) {\n const origin = event.origin;\n if (origin !== this.tunnelOrigin) {\n return;\n }\n\n if (!event.data || !event.data.type) {\n return;\n }\n\n switch (event.data.type) {\n case 'postnl:chatbot:existing-chat-converstion-found':\n case 'postnl:chatbot:chat-conversation-started':\n this.resolveSessionDataFound(event.data.data);\n break;\n case 'postnl:chatbot:session-token-refreshed':\n if(this.resolveSessionTokenRefreshed){\n this.resolveSessionTokenRefreshed(event.data.data)\n }\n break;\n }\n }\n\n private getOrigin(url: string) {\n var temp = document.createElement('a');\n temp.href = url;\n return temp.origin;\n }\n}\n"],"mappings":"AAKA,MAAMA,EACFC,YAAoBC,EAAuBC,GAAvBC,KAAAF,gBAChB,IAAKA,EAAe,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