{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/unblu-api-error.ts","webpack:///./src/internal/module/module.ts","webpack:///./src/internal/util/event-emitter.ts","webpack:///./src/unblu-api.ts","webpack:///./src/conversation.ts","webpack:///./src/unblu-util.ts","webpack:///./src/index.ts","webpack:///./src/unblu-static-api.ts","webpack:///./src/unblu-api-ui.ts","webpack:///./src/internal/api-bridge.ts","webpack:///./src/internal/java-error-codes.ts","webpack:///./src/internal/internal-api.ts","webpack:///./src/internal/module/meta-module.ts","webpack:///./src/internal/module/general-module.ts","webpack:///./src/internal/module/general-lazy-module.ts","webpack:///./src/internal/module/conversation-module.ts","webpack:///./src/internal/module/agent-availability-module.ts","webpack:///./src/model/call-state.ts","webpack:///./src/model/connection-state.ts","webpack:///./src/model/conversation-type.ts","webpack:///./src/model/agent-availability-state.ts","webpack:///./src/model/conversation-state.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","UnbluErrorType","UnbluApiError","_super","type","detail","_this","this","__extends","Error","InternalModule","bridge","moduleName","callApiFunction","functionName","args","on","eventName","listener","off","EventEmitter","listeners","reset","event","indexOf","push","index","splice","offAll","hasListeners","length","getEventsWithListeners","events","event_1","emit","data","forEach","e","console","warn","conversation_1","event_emitter_1","unblu_api_error_1","unblu_api_ui_1","UnbluApi","internalApi","internalListeners","eventEmitter","meta","onUpgraded","ui","UnbluUiApi","needsInternalSubscription","onInternal","catch","removed","offInternal","AGENT_AVAILABILITY_CHANGE","internalListener","internalModule","agentAvailability","needsUpgrade","ACTIVE_CONVERSATION_CHANGE","Conversation","general","CONVERSATIONS_CHANGE","NOTIFICATION_COUNT_CHANGE","PERSON_CHANGE","INVALID_FUNCTION_ARGUMENTS","_a","isUpgraded","_b","sent","e_1","getPersonInfo","requireUpgrade","setPersonNickname","nickname","getNotificationCount","generalLazy","startConversation","visitorName","visitorData","conversationId","setNewConversationInterceptor","callback","joinConversation","pin","openConversation","getActiveConversation","getConversations","isAgentAvailable","getAgentAvailabilityState","upgrade","_i","destroyed","CLOSE","destroy","checkNotDestroyed","CONNECTION_STATE_CHANGE","connectionState","CONVERSATION_STATE_CHANGE","conversationState","CALL_STATE_CHANGE","callState","INVITATIONS_CHANGE","invitations","conversation","getConversationId","getConnectionState","getConversationState","getCallState","createAnonymousPinInvitation","createAnonymousEmailInvitation","email","revokeInvitation","invitationId","renewInvitationPin","setVisitorData","getInvitations","startAudioCall","startVideoCall","endConversation","leaveConversation","closeConversation","ILLEGAL_STATE","isDestroyed","END","UnbluUtil","loadScript","uri","timeout","timeoutTime","script","document","createElement","setAttribute","toString","src","Promise","resolve","reject","timeoutId","cleanup","onerror","onload","window","clearTimeout","onError","error","setTimeout","getElementsByTagName","appendChild","setNamedArea","namedArea","metaTag","querySelector","parentElement","head","setLocale","locale","getUnbluObject","isUnbluLoaded","APIKEY","unblu","createUnbluObject","unblu_static_api_1","unblu_util_1","call_state_1","connection_state_1","conversation_type_1","agent_availability_state_1","conversation_state_1","unblu_api_1","AgentAvailabilityState","CallState","ConnectionState","ConversationState","ConversationType","api","UnbluStaticApi","api_bridge_1","internal_api_1","state","ERROR","handleError","initializeApi","READY","initializedApi","isConfigurationNeeded","getApiState","isInitialized","configure","config","configuration","initialize","CONFIGURATION_MISSING","injectUnblu","apiBridge","ApiBridge","waitUntilLoaded","initTimeout","InternalApi","checkCompatibility","waitUntilInitialized","serverUrl","apiKey","unbluPath","entryPath","unbluUrl","ERROR_LOADING_UNBLU","e_2","UI_STATE_CHANGE","toggleIndividualUi","openPinEntryUi","popoutIndividualUi","popinIndividualUi","maximizeIndividualUi","minimizeIndividualUi","openIndividualUi","collapseIndividualUi","getIndividualUiState","java_error_codes_1","mountPoint","promise","timeoutTimestamp","Date","now","waitForLoaded","checkLoaded","INITIALIZATION_TIMEOUT","internal","INCOMPATIBLE_UNBLU_VERSION","getApiVersion","version","execute","CATEGORY_INVALID_FUNCTION_CALL","INVALID_FUNCTION_CALL","message","CATEGORY_INVALID_FUNCTION_ARGUMENTS","CATEGORY_ACTION_NOT_GRANTED","ACTION_NOT_GRANTED","CATEGORY_EXECUTION_EXCEPTION","EXECUTION_EXCEPTION","registerEventListener","removeEventListener","meta_module_1","general_module_1","general_lazy_module_1","conversation_module_1","agent_availability_module_1","MetaModule","GeneralModule","GeneralLazyModule","ConversationModule","AgentAvailabilityModule","openUi"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAArB,EAAAqB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFA1B,EAAAkB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAArB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YnN,EAAAmN,mBAAAnN,EAAAmN,iBAAgB,oFCA5B,SAAYJ,GAIRA,EAAA,sBAMAA,EAAA,YAMAA,EAAA,0BAMAA,EAAA,kBAtBJ,CAAY/M,EAAA+M,yBAAA/M,EAAA+M,uBAAsB,oFCAlC,SAAYG,GAIRA,EAAA,kBAMAA,EAAA,wBAMAA,EAAA,wBAKAA,EAAA,gBAKAA,EAAA,gBAMAA,EAAA,wBAKAA,EAAA,0BAKAA,EAAA,cA1CJ,CAAYlN,EAAAkN,oBAAAlN,EAAAkN,kBAAiB","file":"visitor-api.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n","/**\r\n * Type of an unblu error. This can be used to check what kind of error occurred.\r\n */\r\nexport enum UnbluErrorType {\r\n /**\r\n * Thrown if the browser is not supported by unblu.\r\n */\r\n UNSUPPORTED_BROWSER = 'UNSUPPORTED_BROWSER',\r\n /**\r\n * Thrown if the initialization of the unblu API failed due to a timeout.\r\n */\r\n INITIALIZATION_TIMEOUT = 'INITIALIZATION_TIMEOUT',\r\n /**\r\n * Thrown if the initialization is called with no existing snippet and no configuration.\r\n */\r\n CONFIGURATION_MISSING = 'CONFIGURATION_MISSING',\r\n /**\r\n * Thrown during initialization if the snippet can't be loaded or unblu can't be initialized from the snippet.\r\n */\r\n ERROR_LOADING_UNBLU = 'ERROR_LOADING_UNBLU',\r\n /**\r\n * Thrown if the unblu JS API is not compatible with the unblu collaboration server.\r\n */\r\n INCOMPATIBLE_UNBLU_VERSION = 'INCOMPATIBLE_UNBLU_VERSION',\r\n /**\r\n * Thrown if a function call was invalid.\r\n * This is usually do to an incompatibility between the unblu JS API and the unblu collaboration server.\r\n */\r\n INVALID_FUNCTION_CALL = 'INVALID_FUNCTION_CALL',\r\n /**\r\n * Thrown if the arguments passed to a function where invalid.\r\n */\r\n INVALID_FUNCTION_ARGUMENTS = 'INVALID_FUNCTION_ARGUMENTS',\r\n /**\r\n * Thrown if a called action is not permitted for the local person.\r\n * The details message usually has more information about the required permissions.\r\n */\r\n ACTION_NOT_GRANTED = 'ACTION_NOT_GRANTED',\r\n /**\r\n * Thrown if an unexpected exception occurrs during a function execution.\r\n */\r\n EXECUTION_EXCEPTION = 'EXECUTION_EXCEPTION',\r\n /**\r\n * Thrown if a method is called in an invalid context. E.g. if the Object called upon was already destroyed.\r\n */\r\n ILLEGAL_STATE = 'ILLEGAL_STATE'\r\n}\r\n\r\n/**\r\n * General unblu JS API error class that will be thrown whenever something goes wrong.\r\n *\r\n * - Use the [[UnbluApiError.type]] to check what kind of error occurred.\r\n * - Use the [[UnbluApiError.detail]] for human readable details.\r\n *\r\n * Check the documentation of [[UnbluErrorType]] for more details on the different error types.\r\n *\r\n * Example:\r\n * ```ts\r\n * unblu.api.initialize().then(api => {\r\n * // use the api\r\n * }).catch(e => {\r\n * if(e.type === 'INITIALIZATION_TIMEOUT') {\r\n * //retry\r\n * } else if(e.type === 'UNSUPPORTED_BROWSER') {\r\n * // display unsupported browser dialog\r\n * } else {\r\n * // show generic error message\r\n * }\r\n * });\r\n * ```\r\n *\r\n * or using async / await:\r\n *\r\n * ```ts\r\n * try {\r\n * const api = await unblu.api.initialize();\r\n * // use the api\r\n * } catch(e) {\r\n * if(e.type === 'INITIALIZATION_TIMEOUT') {\r\n * //retry\r\n * } else if(e.type === 'UNSUPPORTED_BROWSER') {\r\n * // display unsupported browser dialog\r\n * } else {\r\n * // show generic error message\r\n * }\r\n * }\r\n * ```\r\n *\r\n *\r\n * The error types may either be checked via their constant string values or via the UnbluErrorType enum:\r\n *\r\n * ```ts\r\n * // using string constant\r\n * function isTimeout(e: UnbluApiError) {\r\n * return e.type === 'INITIALIZATION_TIMEOUT';\r\n * }\r\n * ```\r\n * ```ts\r\n * // using the enum\r\n * function isTimeout(e: UnbluApiError) {\r\n * return e.type === window.unblu.UnbluErrorType.INITIALIZATION_TIMEOUT;\r\n * }\r\n * ```\r\n *\r\n */\r\nexport class UnbluApiError extends Error {\r\n\r\n constructor(public type: UnbluErrorType, public detail: string) {\r\n super(`type: ${type}, detail: ${detail}`);\r\n this.name = 'UnbluApiError';\r\n }\r\n\r\n}","import {ApiBridge} from '../api-bridge';\r\nimport {EventCallback} from '../event';\r\n\r\nexport class InternalModule {\r\n constructor(private bridge: ApiBridge, public moduleName: string) {\r\n\r\n }\r\n\r\n protected callApiFunction(functionName: T, args: any[]): Promise {\r\n return this.bridge.callApiFunction(this.moduleName, functionName, args);\r\n }\r\n\r\n public on(eventName: E, listener: EventCallback): Promise {\r\n return this.bridge.on(this.moduleName, eventName, listener);\r\n }\r\n\r\n public off(eventName: E, listener: EventCallback): Promise {\r\n return this.bridge.off(this.moduleName, eventName, listener);\r\n }\r\n\r\n}","export type Listener = (data?: any) => void;\r\n\r\nexport class EventEmitter {\r\n private listeners: { [key: string]: EventListener[] } = {};\r\n\r\n /**\r\n * Resets the emitter by removing all registered listeners.\r\n */\r\n public reset(): void {\r\n this.listeners = {};\r\n }\r\n\r\n /**\r\n * Adds an event listeners\r\n * @param event the event to listen to\r\n * @param listener the listener to be called.\r\n */\r\n public on(event: string, listener: Listener) {\r\n this.listeners[event] = this.listeners[event] || [];\r\n if (this.listeners[event].indexOf(listener) === -1)\r\n this.listeners[event].push(listener);\r\n }\r\n\r\n /**\r\n * removes a previously registered listener\r\n * @param event the event\r\n * @param listener the listener that should be removed.\r\n * @return `true` if the listener was removed, `false` otherwise.\r\n */\r\n off(event: string, listener: any): boolean {\r\n const listeners = this.listeners[event] || [];\r\n const index = listeners.indexOf(listener);\r\n if (index > -1) {\r\n listeners.splice(index, 1);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * removes all listeners for the given event.\r\n * @param event the event for which all listeners will be removed.\r\n */\r\n offAll(event: string) {\r\n delete this.listeners[event];\r\n }\r\n\r\n /**\r\n * Checks weather at least one listener exists for a given event.\r\n * @param event the event to check for\r\n * @return weather or not any listeners for the given event are registered.\r\n */\r\n hasListeners(event: string): boolean {\r\n return this.listeners[event] != null && this.listeners[event].length > 0;\r\n }\r\n\r\n /**\r\n * Returns all events that have at least one listeners registered to them.\r\n * @return An array containing all events that have at least one listener.\r\n * If no listeners are registered at all, an empty array will be returned.\r\n */\r\n getEventsWithListeners(): string[] {\r\n const events: string[] = [];\r\n for (let event in this.listeners) {\r\n if (this.listeners[event].length)\r\n events.push(event);\r\n }\r\n return events;\r\n }\r\n\r\n /**\r\n * Emits an event dispatching it to all listeners registered for it.\r\n * @param event the event name.\r\n * @param data the event data.\r\n */\r\n emit(event: string, data?: any) {\r\n const listeners = this.listeners[event];\r\n if (listeners) {\r\n listeners.forEach(l => {\r\n try {\r\n l(data);\r\n } catch (e) {\r\n console.warn('Error dispatching event:', event, 'in listener:', l, e);\r\n }\r\n });\r\n }\r\n }\r\n\r\n}","import {InternalApi} from './internal/internal-api';\r\nimport {GeneralEventType} from './internal/module/general-module';\r\nimport {Conversation} from './conversation';\r\nimport {PersonInfo} from './model/person-info';\r\nimport {Event, EventCallback} from './internal/event';\r\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\r\nimport {ConversationType} from './model/conversation-type';\r\nimport {AgentAvailabilityState} from './model/agent-availability-state';\r\nimport {AgentAvailabilityEventType} from './internal/module/agent-availability-module';\r\nimport {InternalModule} from './internal/module/module';\r\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\r\nimport {UnbluUiApi} from './unblu-api-ui';\r\nimport {ConversationInfo} from \"./model/conversation-info\";\r\n\r\n/**\r\n * Listener called whenever the active conversation changes.\r\n *\r\n * **Note:** If no conversation is currently active the passed conversation object will be `null`\r\n * @param conversation API object for the active conversation or `null` if no conversation is active.\r\n */\r\nexport type ConversationChangeListener = (conversation?: Conversation) => void;\r\n\r\n/**\r\n * Listener called whenever a conversation changed, added or removed from all conversations.\r\n * @param conversations All conversations of the current visitor.\r\n */\r\nexport type ConversationsChangeListener = (conversations: ConversationInfo[]) => void;\r\n\r\n/**\r\n * Listener called whenever the notification count of a person (i.e. unread messages) changes.\r\n * @param count The number of unseen notifications.\r\n */\r\nexport type NotificationCountChangeListener = (count: number) => void;\r\n/**\r\n * Listener called whenever the local person changes.\r\n * @param person Info about the person.\r\n */\r\nexport type PersonChangeListener = (person: PersonInfo) => void;\r\n/**\r\n * Listener called whenever the agent availability changes.\r\n * @param availability The new availability.\r\n */\r\nexport type AgentAvailabilityChangeListener = (availability: AgentAvailabilityState) => void;\r\n/**\r\n * Interceptor function which is called every time a new conversation is started from the UI or JS API.\r\n *\r\n * The starting of the conversation will be deferred until the Promis returned by this interceptor resolves:\r\n * If the interceptor rejects the Promise, the starting of the conversation will be canceled.\r\n * If the interceptor resolves the Promise with a String, its value will be used and set as \"visitorData\" for the created conversation.\r\n * If the interceptor resolves the Promise without any value or something else then a String the conversation will be started without any visitorData.\r\n * If visitorData was passed to the [startConversation]{@link startConversation} it will be passed to this callback as second argument.\r\n @param conversationType The type of the conversation being started.\r\n @param visitorData Optional visitorData, only present if passed to the [startConversation]{@link startConversation} method\r\n @return A Promise deferring the start of the conversation until it resolves.\r\n */\r\nexport type NewConversationInterceptor = (conversationType: ConversationType, visitorData?: String, ) => Promise;\r\n\r\n/**\r\n * #### This class represents the initialized Unblu Visitor JS API.\r\n *\r\n * There is only ever one instance of this api which can be retrieved via `unblu.api.initialize()`,\r\n * see [[UnbluStaticApi]] for more details on configuring and initializing the UnbluApi.\r\n *\r\n * The API connects to the integrated version of Unblu. All actions performed via the UnbluApi are executed in\r\n * the name of and with the rights of current visitor and may have direct effect on the displayed Unblu UI.\r\n *\r\n * For example if a conversation is started from the UnbluApi, the Unblu UI will navigate to it.\r\n * If a conversation is closed via the API, it will also be closed on the Unblu UI of the visitor.\r\n * For more information on UI side effects please check the documentation for each method call.\r\n *\r\n * For programmatic administrator access and configuration of Unblu please use the Unblu WebAPI.\r\n */\r\nexport class UnbluApi {\r\n\r\n /**\r\n * Event emitted every time the active conversation changed.\r\n *\r\n * This may happen due to a UI-navigation or an API-call.\r\n *\r\n * @event activeConversationChange\r\n * @see [[on]] for listener registration\r\n * @see [[ConversationChangeListener]]\r\n */\r\n public static readonly ACTIVE_CONVERSATION_CHANGE: 'activeConversationChange' = 'activeConversationChange';\r\n\r\n /**\r\n * Event emitted every time when a conversation is changed, added or removed.\r\n *\r\n * @event conversationsChanged\r\n * @see [[on]] for listener registration\r\n * @see [[ConversationsChangeListener]]\r\n */\r\n public static readonly CONVERSATIONS_CHANGE: 'conversationsChange' = 'conversationsChange';\r\n\r\n /**\r\n * Event emitted every time the notification count (unread messages) changes.\r\n *\r\n * @event notificationCountChange\r\n * @see [[on]] for listener registration\r\n * @see [[NotificationCountChangeListener]]\r\n */\r\n public static readonly NOTIFICATION_COUNT_CHANGE: 'notificationCountChange' = 'notificationCountChange';\r\n\r\n /**\r\n * Event emitted every time the local person changes. This may be i.e. due to the person setting its name.\r\n *\r\n * @event personChange\r\n * @see [[on]] for listener registration\r\n * @see [[PersonChangeListener]]\r\n */\r\n public static readonly PERSON_CHANGE: 'personChange' = 'personChange';\r\n\r\n /**\r\n * Event emitted every time the agent availability changes for the current named area and locale.\r\n *\r\n * @event availabilityChange\r\n * @see [[on]] for listener registration\r\n * @see [[AgentAvailabilityChangeListener]]\r\n */\r\n public static readonly AGENT_AVAILABILITY_CHANGE: 'availabilityChange' = 'availabilityChange';\r\n\r\n\r\n /**\r\n * Access the UI functionality over the UI property.\r\n */\r\n public ui: UnbluUiApi;\r\n\r\n private internalListeners: { [key: string]: EventCallback } = {};\r\n private eventEmitter = new EventEmitter();\r\n\r\n /**\r\n * @hidden\r\n */\r\n constructor(private internalApi: InternalApi) {\r\n internalApi.meta.on('upgraded', () => this.onUpgraded());\r\n // All UI functionality is provided with the ui namespace\r\n this.ui = new UnbluUiApi(internalApi);\r\n }\r\n\r\n // Event\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The activeConversationChange event.\r\n * @param listener The listener to be called.\r\n * @see [[ACTIVE_CONVERSATION_CHANGE]]\r\n */\r\n public on(event: typeof UnbluApi.ACTIVE_CONVERSATION_CHANGE, listener: ConversationChangeListener): void;\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The notificationCountChange event.\r\n * @param listener The listener to be called.\r\n * @see [[NOTIFICATION_COUNT_CHANGE]]\r\n */\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The conversationsChanged event.\r\n * @param listener The listener to be called.\r\n * @see [[CONVERSATIONS_CHANGE]]\r\n */\r\n public on(event: typeof UnbluApi.CONVERSATIONS_CHANGE, listener: ConversationsChangeListener): void;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The notificationCountChanged event.\r\n * @param listener The listener to be called.\r\n * @see [[NOTIFICATION_COUNT_CHANGE]]\r\n */\r\n public on(event: typeof UnbluApi.NOTIFICATION_COUNT_CHANGE, listener: NotificationCountChangeListener): void;\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The personChange event.\r\n * @param listener The listener to be called.\r\n * @see [[PERSON_CHANGE]]\r\n */\r\n public on(event: typeof UnbluApi.PERSON_CHANGE, listener: PersonChangeListener): void;\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The personChange event.\r\n * @param listener The listener to be called.\r\n * @see [[PERSON_CHANGE]]\r\n */\r\n public on(event: typeof UnbluApi.AGENT_AVAILABILITY_CHANGE, listener: AgentAvailabilityChangeListener): void;\r\n\r\n public on(event: GeneralEventType | AgentAvailabilityEventType, listener: Listener): void {\r\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\r\n this.eventEmitter.on(event, listener);\r\n if (needsInternalSubscription)\r\n this.onInternal(event).catch(e => console.warn('Error registering internal listener for event:', event, 'error:' + e, e));\r\n }\r\n\r\n /**\r\n * Removes a previously registered listener\r\n * @param event The event to unregister from.\r\n * @param listener The listener to remove.\r\n */\r\n public off(event: GeneralEventType | AgentAvailabilityEventType, listener: Listener): boolean {\r\n const removed = this.eventEmitter.off(event, listener);\r\n if (!this.eventEmitter.hasListeners(event))\r\n this.offInternal(event).catch(e => console.warn('Error removing internal listener for event:', event, 'error:' + e, e));\r\n return removed;\r\n }\r\n\r\n private async onInternal(eventName: GeneralEventType | AgentAvailabilityEventType) {\r\n let internalListener: EventCallback;\r\n let internalModule: InternalModule;\r\n let needsUpgrade: boolean;\r\n switch (eventName) {\r\n case UnbluApi.AGENT_AVAILABILITY_CHANGE:\r\n internalListener = (event: Event) => {\r\n this.eventEmitter.emit(event.name, event.data);\r\n };\r\n internalModule = this.internalApi.agentAvailability;\r\n needsUpgrade = false;\r\n break;\r\n case UnbluApi.ACTIVE_CONVERSATION_CHANGE:\r\n internalListener = (event: Event) => {\r\n this.eventEmitter.emit(event.name, event.data ? new Conversation(this.internalApi, event.data) : null);\r\n };\r\n internalModule = this.internalApi.general;\r\n needsUpgrade = true;\r\n break;\r\n case UnbluApi.CONVERSATIONS_CHANGE:\r\n internalListener = (event: Event) => {\r\n this.eventEmitter.emit(event.name, event.data);\r\n };\r\n internalModule = this.internalApi.general;\r\n needsUpgrade = true;\r\n break;\r\n case UnbluApi.NOTIFICATION_COUNT_CHANGE:\r\n case UnbluApi.PERSON_CHANGE:\r\n internalListener = (event: Event) => {\r\n this.eventEmitter.emit(event.name, event.data);\r\n };\r\n internalModule = this.internalApi.general;\r\n needsUpgrade = true;\r\n break;\r\n default:\r\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, 'Registration to unknown event:' + eventName);\r\n }\r\n\r\n if (!needsUpgrade || await this.internalApi.meta.isUpgraded()) {\r\n this.internalListeners[eventName] = internalListener;\r\n try {\r\n await internalModule.on(eventName, internalListener);\r\n } catch (e) {\r\n delete this.internalListeners[eventName];\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n private async offInternal(eventName: GeneralEventType | AgentAvailabilityEventType) {\r\n const listener = this.internalListeners[eventName];\r\n if (listener == null) {\r\n return;\r\n }\r\n delete this.internalListeners[eventName];\r\n\r\n let internalModule: InternalModule;\r\n switch (eventName) {\r\n case UnbluApi.AGENT_AVAILABILITY_CHANGE:\r\n internalModule = this.internalApi.agentAvailability;\r\n break;\r\n default:\r\n internalModule = this.internalApi.general;\r\n break;\r\n }\r\n await internalModule.off(eventName, listener);\r\n }\r\n\r\n // General\r\n\r\n /**\r\n * Returns information about the visitor.\r\n * @return A promise that resolves to the current visitors person info.\r\n */\r\n public async getPersonInfo(): Promise {\r\n await this.requireUpgrade();\r\n return this.internalApi.general.getPersonInfo();\r\n }\r\n\r\n /**\r\n * Set the nickname of the current visitor.\r\n * This could be set before or during a conversation.\r\n * @return A empty promise when operation is done.\r\n */\r\n public async setPersonNickname(nickname: string): Promise {\r\n await this.requireUpgrade();\r\n return this.internalApi.general.setPersonNickname(nickname);\r\n }\r\n\r\n /**\r\n * Returns the number of unread messages.\r\n * @return A promise that resolves to the current number of unread messages.\r\n */\r\n public async getNotificationCount(): Promise {\r\n if (await this.internalApi.meta.isUpgraded()) {\r\n return this.internalApi.general.getNotificationCount();\r\n } else {\r\n return this.internalApi.generalLazy.getNotificationCount();\r\n }\r\n }\r\n\r\n // Conversation\r\n\r\n\r\n /**\r\n * Starts a new Conversation and places it into the inbound conversation queue.\r\n *\r\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\r\n *\r\n * @param type The conversation type that shall be started.\r\n * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.\r\n * @param visitorData Custom data for the visitor in any format. **NOTE:** The data which is passed here could be used in [NewConversationCallback]{@link NewConversationInterceptor}\r\n * @return A promise that resolves to the conversation object giving API access to the started conversation.\r\n */\r\n public async startConversation(type: ConversationType, visitorName?: string, visitorData?: string): Promise {\r\n await this.requireUpgrade();\r\n const conversationId = await this.internalApi.general.startConversation(type, visitorName, visitorData);\r\n return new Conversation(this.internalApi, conversationId);\r\n }\r\n\r\n /**\r\n * Set a custom interceptor which will be triggered when a new conversation is started (initiated from UI or JavaScript).\r\n * @param callback The interceptor which is called before a new conversation is started. The Callback is of type [NewConversationCallback]{@link NewConversationInterceptor}\r\n * @return A promise that resolves when the interceptor is successfully applied and active.\r\n */\r\n public async setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\r\n if (!await this.internalApi.meta.isUpgraded()) {\r\n return await this.internalApi.generalLazy.setNewConversationInterceptor(callback);\r\n } else {\r\n return await this.internalApi.general.setNewConversationInterceptor(callback);\r\n }\r\n }\r\n\r\n /**\r\n * Joins an existing conversation with a given PIN.\r\n *\r\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\r\n *\r\n * @param pin The PIN retrieved from the Unblu Agent Desk.\r\n * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.\r\n * @return A promise that resolves to the conversation object giving API access to the joined conversation.\r\n */\r\n public async joinConversation(pin: string, visitorName?: string): Promise {\r\n await this.requireUpgrade();\r\n const conversationId = await this.internalApi.general.joinConversation(pin, visitorName);\r\n return new Conversation(this.internalApi, conversationId);\r\n }\r\n\r\n /**\r\n * Opens the existing conversation with the given conversation ID.\r\n *\r\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\r\n *\r\n * @param conversationId The id of the conversation to be opened.\r\n * @return A promise that resolves to the conversation object giving API access to the opened conversation.\r\n */\r\n public async openConversation(conversationId: string): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.openConversation(conversationId);\r\n return new Conversation(this.internalApi, conversationId);\r\n }\r\n\r\n /**\r\n * Returns the currently active conversation or `null` if no conversation is active.\r\n *\r\n * **NOTE:** calling this method twice while the same conversation is active, will result in two individual conversation API instances being returned.\r\n * destroying one of them will not cause the other one to also be destroyed. If however the active conversation is closed, all returned Conversation instances will be destroyed.\r\n *\r\n * @return A promise that either resolves to the currently active conversation or `null` if no conversation is open.\r\n * @see [[ACTIVE_CONVERSATION_CHANGE]]\r\n */\r\n public async getActiveConversation(): Promise {\r\n if (await this.internalApi.meta.isUpgraded()) {\r\n const conversationId = await this.internalApi.general.getActiveConversation();\r\n return conversationId != null ? new Conversation(this.internalApi, conversationId) : null;\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Returns all conversations of the current visitor. If no conversation is present, an empty array is returned.\r\n *\r\n * @return A promise that resolves to an array of [ConversationInfo]{@link ConversationInfo}.\r\n */\r\n public async getConversations(): Promise {\r\n if (await this.internalApi.meta.isUpgraded()) {\r\n const conversations = await this.internalApi.general.getConversations();\r\n return conversations\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if an agent is available for the current named area and language.\r\n *\r\n * @return Promise that resolves to `true` if the availability state is [AVAILABLE]{@link AgentAvailabilityState.AVAILABLE} or [BUSY]{@link AgentAvailabilityState.BUSY}, `false` otherwise.\r\n * @see [[getAgentAvailabilityState]] for a more detailed check.\r\n */\r\n public async isAgentAvailable(): Promise {\r\n return this.internalApi.agentAvailability.isAgentAvailable();\r\n }\r\n\r\n /**\r\n * Returns the current availability state for the current named area and language.\r\n * @return Promise that resolves to the current availability state.\r\n * @see [[isAgentAvailable]] for a simpler check.\r\n */\r\n public async getAgentAvailabilityState(): Promise {\r\n return this.internalApi.agentAvailability.getAgentAvailabilityState();\r\n }\r\n\r\n private async requireUpgrade(): Promise {\r\n await this.internalApi.meta.upgrade(false);\r\n }\r\n\r\n private onUpgraded() {\r\n for (let event of this.eventEmitter.getEventsWithListeners()) {\r\n // register internal listeners for all events that need upgrade.\r\n if (!this.internalListeners[event])\r\n this.onInternal(event as GeneralEventType);\r\n }\r\n }\r\n\r\n}","import {InternalApi} from './internal/internal-api';\r\nimport {CallState} from './model/call-state';\r\nimport {Event, EventCallback} from './internal/event';\r\nimport {\r\n ConversationCallState,\r\n ConversationConnectionState,\r\n ConversationEventType, ConversationInvitations, ConversationWithState\r\n} from './internal/module/conversation-module';\r\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\r\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\r\nimport {ConversationState} from './model/conversation-state';\r\nimport {ConnectionState} from './model/connection-state';\r\nimport {Invitation} from \"./model/invitation\";\r\n\r\nexport type ConnectionStateListener = (connectionState: ConnectionState) => void;\r\nexport type ConversationStateListener = (conversationState: ConversationState) => void;\r\nexport type CallStateListener = (callState: CallState) => void;\r\nexport type InvitationsListener = (invitations: Invitation[]) => void;\r\n\r\n/**\r\n * #### This class gives API access to the currently active conversation.\r\n *\r\n * As long as a conversation is active one can register and receive the events provided by this class and call the methods.\r\n * Once the conversation is closed this API object will be destroyed and no more event callbacks will be called.\r\n * Any subsequent calls will fail.\r\n *\r\n * Use the [[CLOSE]] event to de-init any code connected to this conversation.\r\n */\r\nexport class Conversation {\r\n\r\n /**\r\n * Event emitted when the [[ConnectionState]] of this conversation changes.\r\n * @event connectionStateChange\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly CONNECTION_STATE_CHANGE: 'connectionStateChange' = 'connectionStateChange';\r\n\r\n /**\r\n * Event emitted when the [[ConversationState]] of this conversation changes.\r\n * @event conversationStateChange\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly CONVERSATION_STATE_CHANGE: 'conversationStateChange' = 'conversationStateChange';\r\n\r\n /**\r\n * Event emitted when the [[CallState]] of this conversation changes.\r\n * @event callStateChange\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly CALL_STATE_CHANGE: 'callStateChange' = 'callStateChange';\r\n\r\n /**\r\n * Event emitted when the conversation ends.\r\n * @deprecated The end event is not always available, depending on the configuration. Use instead [[CONVERSATION_STATE_CHANGE]] event.\r\n * @event end\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly END: 'end' = 'end';\r\n\r\n /**\r\n * Event emitted when the conversation is closed.\r\n *\r\n * This may happen due to a UI-navigation or an API-call.\r\n *\r\n * @event close\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly CLOSE: 'close' = 'close';\r\n\r\n /**\r\n * Event emitted when an [[Invitation]] is added to or removed from this conversation or if an existing one changes.\r\n * The event emits an array of all visitor invitations created by the local person, all other invitations will not be present.\r\n * @event invitationsChange\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly INVITATIONS_CHANGE: 'invitationsChange' = 'invitationsChange';\r\n\r\n private eventEmitter = new EventEmitter();\r\n private internalListeners: { [key: string]: EventCallback } = {};\r\n private destroyed = false;\r\n\r\n /**\r\n * @hidden\r\n */\r\n constructor(private internalApi: InternalApi, private conversationId: string) {\r\n // clean up all listeners when the conversation disconnects.\r\n this.on(Conversation.CLOSE, () => this.destroy());\r\n }\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The call state change event.\r\n * @param listener The listener to be called.\r\n * @see [[CONNECTION_STATE_CHANGE]]\r\n */\r\n public on(event: typeof Conversation.CONNECTION_STATE_CHANGE, listener: ConnectionStateListener): void ;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The conversation state change event.\r\n * @param listener The listener to be called.\r\n * @see [[CONVERSATION_STATE_CHANGE]]\r\n */\r\n public on(event: typeof Conversation.CONVERSATION_STATE_CHANGE, listener: ConversationStateListener): void ;\r\n\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The call state change event.\r\n * @param listener The listener to be called.\r\n * @see [[CALL_STATE_CHANGE]]\r\n */\r\n public on(event: typeof Conversation.CALL_STATE_CHANGE, listener: CallStateListener): void ;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @deprecated The end event is not always available, depending on the configuration. Use instead [[CONVERSATION_STATE_CHANGE]] event.\r\n * @param event The end event.\r\n * @param listener The listener to be called.\r\n * @see [[END]]\r\n */\r\n public on(event: typeof Conversation.END, listener: () => void): void ;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The close event.\r\n * @param listener The listener to be called.\r\n * @see [[CLOSE]]\r\n */\r\n public on(event: typeof Conversation.CLOSE, listener: () => void): void;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The invitations change event.\r\n * @param listener The listener to be called.\r\n * @see [[INVITATIONS_CHANGE]]\r\n */\r\n public on(event: typeof Conversation.INVITATIONS_CHANGE, listener: InvitationsListener): void ;\r\n\r\n /**\r\n * Adds a listener.\r\n * @param event The event to register.\r\n * @param listener The listener to register.\r\n */\r\n public on(event: ConversationEventType, listener: Listener): void {\r\n this.checkNotDestroyed();\r\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\r\n this.eventEmitter.on(event, listener);\r\n if (needsInternalSubscription)\r\n this.onInternal(event);\r\n }\r\n\r\n /**\r\n * Removes a previously registered listener.\r\n * @param event The event to unregister from.\r\n * @param listener The listener to remove.\r\n */\r\n public off(event: ConversationEventType, listener: Listener): boolean {\r\n this.checkNotDestroyed();\r\n const removed = this.eventEmitter.off(event, listener);\r\n if (!this.eventEmitter.hasListeners(event))\r\n this.offInternal(event);\r\n return removed;\r\n }\r\n\r\n private onInternal(eventName: ConversationEventType) {\r\n let internalListener: EventCallback;\r\n switch (eventName) {\r\n case Conversation.CONNECTION_STATE_CHANGE:\r\n internalListener = (event: Event) => {\r\n if (event.data.conversationId == this.conversationId)\r\n this.eventEmitter.emit(event.name, event.data.connectionState);\r\n };\r\n break;\r\n case Conversation.CONVERSATION_STATE_CHANGE:\r\n internalListener = (event: Event) => {\r\n if (event.data.conversationId == this.conversationId)\r\n this.eventEmitter.emit(event.name, event.data.conversationState);\r\n };\r\n break;\r\n case Conversation.CALL_STATE_CHANGE:\r\n internalListener = (event: Event) => {\r\n if (event.data.conversationId == this.conversationId)\r\n this.eventEmitter.emit(event.name, event.data.callState);\r\n };\r\n break;\r\n case Conversation.INVITATIONS_CHANGE:\r\n internalListener = (event: Event) => {\r\n if (event.data.conversationId == this.conversationId)\r\n this.eventEmitter.emit(event.name, event.data.invitations);\r\n };\r\n break;\r\n default:\r\n internalListener = (event: Event) => {\r\n if (event.data == this.conversationId) {\r\n this.eventEmitter.emit(event.name);\r\n }\r\n };\r\n break;\r\n }\r\n this.internalListeners[eventName] = internalListener;\r\n this.internalApi.conversation.on(eventName, internalListener).catch(e => console.warn('Error registering internal listener for event:', eventName, 'error:' + e, e));\r\n }\r\n\r\n private offInternal(eventName: ConversationEventType) {\r\n const listener = this.internalListeners[eventName];\r\n if (listener == null)\r\n return;\r\n delete this.internalListeners[eventName];\r\n this.internalApi.conversation.off(eventName, listener).catch(e => console.warn('Error removing internal listener for event:', eventName, 'error:' + e, e));\r\n }\r\n\r\n /**\r\n * Returns the ID of this conversation.\r\n */\r\n public getConversationId(): string {\r\n return this.conversationId;\r\n }\r\n\r\n /**\r\n * Returns the current connection state the conversation is in.\r\n *\r\n * If the connection is lost, the conversation will automatically try to reconnect using an exponential back-off strategy.\r\n * If a fatal error is detected, the state will change to [[ConnectionState.ERROR]].\r\n *\r\n * If this happens, the conversation is in it's terminal state. A dialog or other UI will be displayed to the user with details on the failure.\r\n * The conversation is not automatically closed in this case.\r\n * It may either be closed through a manual action by the visitor (confirming the error) or via the API.\r\n *\r\n * @see [[CONNECTION_STATE_CHANGE]] If you need to listen to changes.\r\n * @return A promise that resolves to the current connection state of the conversation\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async getConnectionState(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.getConnectionState(this.conversationId);\r\n }\r\n\r\n /**\r\n * Returns the current state the conversation is in.\r\n * @return A promise that resolves to the current state of the conversation\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async getConversationState(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.getConversationState(this.conversationId);\r\n }\r\n\r\n /**\r\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\r\n * @return A promise that resolves to the current call state of the local user\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async getCallState(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.getCallState(this.conversationId);\r\n }\r\n\r\n /**\r\n * Creates a new PIN invitation for this conversation.\r\n *\r\n * - If the local person doesn't have the right to invite a visitor,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @see [[INVITATIONS_CHANGE]] If you need to listen to changes for new invitations on this conversation.\r\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async createAnonymousPinInvitation(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.createAnonymousPinInvitation(this.conversationId);\r\n }\r\n\r\n /**\r\n * Creates a new EMail invitation for this conversation.\r\n *\r\n * - If the local person doesn't have the right to invite a visitor,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * - If a non valid email address is provided,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.INVALID_FUNCTION_ARGUMENTS]].\r\n * @param email The email which the invitation should be send. It must be a valid email address.\r\n * @see [[INVITATIONS_CHANGE]] If you need to listen to changes for new invitations on this conversation.\r\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async createAnonymousEmailInvitation(email: String) : Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.createAnonymousEmailInvitation(this.conversationId, email);\r\n }\r\n\r\n /**\r\n * Revoke an invitation.\r\n *\r\n * - If the local person doesn't have the right to invite a visitor,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @param invitationId The invitation id.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async revokeInvitation(invitationId: String) : Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.revokeInvitation(this.conversationId, invitationId);\r\n }\r\n\r\n /**\r\n * Renews an invitation PIN if the invitation is expired.\r\n *\r\n * - If the local person doesn't have the right to invite a visitor,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @param invitationId The invitation id.\r\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\r\n */\r\n public async renewInvitationPin(invitationId: String) : Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.renewInvitationPin(this.conversationId, invitationId);\r\n }\r\n\r\n /**\r\n * Set custom visitor data on the conversation.\r\n *\r\n * @param visitorData Custom data for the visitor in any format.\r\n */\r\n public async setVisitorData(visitorData: String) : Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.setVisitorData(visitorData);\r\n }\r\n\r\n /**\r\n * Get all visitor invitations created by the local person for this conversation.\r\n * @return A promise that resolves to a new [[Invitation]] array with all relevant metadata.\r\n * or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async getInvitations(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.getInvitations(this.conversationId);\r\n }\r\n\r\n /**\r\n * Starts a voice call in this conversation.\r\n *\r\n * - If a call is already active, this call will be ignored.\r\n * - If the local person doesn't have the right to start a voice call,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async startAudioCall(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.startAudioCall(this.conversationId);\r\n }\r\n\r\n /**\r\n * Starts a video call in this conversation.\r\n *\r\n * - If a call is already active, this call will be ignored.\r\n * - If the local person doesn't have the right to start a video call,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async startVideoCall(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.startVideoCall(this.conversationId);\r\n }\r\n\r\n /**\r\n * Ends and closes this conversation.\r\n *\r\n * If the local person doesn't have the right to end the conversation,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @see [[END]] fired after this call.\r\n * @see [[closeConversation]] for details on closing a conversation.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async endConversation(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.endConversation(this.conversationId);\r\n }\r\n\r\n /**\r\n * Leaves and closes this conversation.\r\n *\r\n * By leaving, the visitor is removed from the active participant list of the conversation.\r\n * Once a conversation is left, the visitor can not re-open it. It will not be visible in the conversation history either.\r\n *\r\n * If the local person doesn't have the right to leave the conversation,\r\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\r\n * @see [[CLOSE]] fired after this call.\r\n * @see [[closeConversation]] for details on closing a conversation without leaving.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async leaveConversation(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.leaveConversation(this.conversationId);\r\n }\r\n\r\n /**\r\n * Closes this conversation locally.\r\n *\r\n * When called, the connection to this conversation is closed and the overview is displayed.\r\n *\r\n * **Note that:**\r\n * - Closing does NOT end the conversation.\r\n * - The person does NOT leave the conversation.\r\n * - All Conversation api instances for this conversation will be destroyed.\r\n *\r\n * The conversation can be joined again either via the UI or using [[UnbluApi.openConversation]].\r\n * @see [[CLOSE]] fired after this call.\r\n * @see [[endConversation]] for details on ending a conversation.\r\n * @see [[leavingConversation]] for details on leaving a conversation.\r\n * @see [[destroy]] for details on destroying a conversation.\r\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\r\n */\r\n public async closeConversation(): Promise {\r\n this.checkNotDestroyed();\r\n return this.internalApi.conversation.closeConversation(this.conversationId);\r\n }\r\n\r\n private checkNotDestroyed(): void {\r\n if (this.destroyed) throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error: trying to execute method on destroyed conversation object.')\r\n }\r\n\r\n /**\r\n * Returns weather this conversation is destroyed or not.\r\n *\r\n * Conversations are either destroyed if [[destroy]] is called or the conversation is closed.\r\n * This usually happens when the user navigates back to an overview or into an other conversation.\r\n * @see [[destroy]]\r\n * @see [[CLOSE]]\r\n * @return Weather this conversation is destroyed or not.\r\n */\r\n public isDestroyed(): boolean {\r\n return this.destroyed;\r\n }\r\n\r\n /**\r\n * Destroys this conversation API instance.\r\n *\r\n * Calling destroy will unregister all event listeners and prohibit any further calls to this object.\r\n * Once the conversation is destroyed, any subsequent calls will reject the returned promise with [[UnbluErrorType.ILLEGAL_STATE]] as reason.\r\n *\r\n * **Note that:**\r\n * - Destroying does NOT close the conversation .\r\n * - Destroying does NOT end the conversation.\r\n * - Destroying does NOT leave the conversation.\r\n * - Other instances of the same Conversation will NOT be destroyed.\r\n *\r\n * This call simply destroys this local API instance to the conversation.\r\n *\r\n * A destroyed but still open conversation can be accessed again using [[UnbluApi.getActiveConversation]].\r\n *\r\n * @see [[isDestroyed]]\r\n * @see [[closeConversation]] for details on how to close a conversation\r\n * @see [[endConversation]] for details on how to end a conversation\r\n */\r\n public destroy(): void {\r\n if (this.destroyed) return;\r\n this.destroyed = true;\r\n this.eventEmitter.reset();\r\n for (let event in this.internalListeners) {\r\n this.offInternal(event as ConversationEventType);\r\n }\r\n }\r\n}","// Typedef Helpers\r\n\r\n\r\n/**\r\n * Internal type definition of the unblu object.\r\n * @hidden\r\n */\r\nexport interface UnbluObject {\r\n api?: any,\r\n\r\n /**\r\n * internal unblu field\r\n * @hidden\r\n */\r\n APIKEY?: string,\r\n /**\r\n * internal unblu field\r\n * @hidden\r\n */\r\n SERVER?: string,\r\n /**\r\n * internal unblu field\r\n * @hidden\r\n */\r\n l?: string\r\n}\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class UnbluUtil {\r\n static async loadScript(uri: string, timeout: number): Promise {\r\n const timeoutTime = timeout || 30000;\r\n const script = document.createElement('script');\r\n script.setAttribute('charset', 'UTF-8');\r\n script.setAttribute('type', 'text/javascript');\r\n script.setAttribute('async', 'true');\r\n script.setAttribute('timeout', timeoutTime.toString());\r\n script.src = uri;\r\n\r\n return new Promise(function (resolve, reject) {\r\n let timeoutId: number;\r\n\r\n const cleanup = () => {\r\n // avoid mem leaks in IE.\r\n script.onerror = script.onload = null;\r\n window.clearTimeout(timeoutId);\r\n };\r\n\r\n const onError = (error: string | Event) => {\r\n cleanup();\r\n console.error('Failed to load script! Uri:', uri, 'Error:', error);\r\n reject(error);\r\n };\r\n\r\n script.onload = () => {\r\n cleanup();\r\n resolve();\r\n };\r\n script.onerror = onError;\r\n timeoutId = window.setTimeout(() => onError('Timeout'), timeoutTime);\r\n\r\n const head = document.getElementsByTagName('HEAD')[0];\r\n head.appendChild(script);\r\n });\r\n }\r\n\r\n static setNamedArea(namedArea: string): void {\r\n const metaTag = window.document.querySelector('meta[name=\"unblu:named-area\"]') || window.document.createElement('meta');\r\n metaTag.setAttribute('name', 'unblu:named-area');\r\n metaTag.setAttribute('content', namedArea);\r\n if (!metaTag.parentElement) {\r\n window.document.head.appendChild(metaTag);\r\n }\r\n }\r\n\r\n static setLocale(locale: string): void {\r\n // unblu.l will be read in user-locale-util.js\r\n UnbluUtil.getUnbluObject().l = locale;\r\n }\r\n\r\n static isUnbluLoaded(): boolean {\r\n return UnbluUtil.getUnbluObject() && !!UnbluUtil.getUnbluObject().APIKEY;\r\n }\r\n\r\n static getUnbluObject(): UnbluObject {\r\n return window.unblu;\r\n }\r\n\r\n static createUnbluObject(): UnbluObject {\r\n return window.unblu = {};\r\n }\r\n\r\n}","import {UnbluApi} from './unblu-api';\r\nimport {Conversation} from './conversation';\r\nimport {UnbluStaticApi} from './unblu-static-api';\r\nimport {UnbluUtil} from './unblu-util';\r\nimport {CallState} from './model/call-state';\r\nimport {ConnectionState} from './model/connection-state';\r\nimport {ConversationType} from './model/conversation-type';\r\nimport {AgentAvailabilityState} from './model/agent-availability-state';\r\nimport {ConversationState} from './model/conversation-state';\r\nimport {UnbluErrorType} from './unblu-api-error';\r\n\r\nexport {UnbluApi} from './unblu-api';\r\nexport {Conversation} from './conversation';\r\n\r\n\r\n/**\r\n * The main unblu namespace which gives access to the unblu api.\r\n *\r\n * Access:\r\n * ```javascript\r\n * window.unblu.api;\r\n * ```\r\n *\r\n * **Note:** all fields inside the unblu namespace except for the [[api]] are not public and may change without any notice.\r\n */\r\nexport interface Unblu {\r\n /**\r\n * Access to the unblu API.\r\n *\r\n * This field will be available as soon as the unblu API has been loaded.\r\n */\r\n api?: UnbluStaticApi,\r\n\r\n AgentAvailabilityState?: typeof AgentAvailabilityState,\r\n\r\n CallState?: typeof CallState,\r\n\r\n ConnectionState?: typeof ConnectionState,\r\n\r\n ConversationState?: typeof ConversationState,\r\n\r\n ConversationType?: typeof ConversationType,\r\n\r\n UnbluErrorType?: typeof UnbluErrorType\r\n}\r\n\r\n/**\r\n * Global window scope definition of the unblu namespace on the window.\r\n * Access:\r\n * ```javascript\r\n * window.unblu.api;\r\n * ```\r\n */\r\ndeclare global {\r\n interface Window {\r\n /**\r\n * The main unblu namespace\r\n */\r\n unblu: Unblu;\r\n }\r\n}\r\n\r\nconst unblu = (UnbluUtil.getUnbluObject() || UnbluUtil.createUnbluObject()) as Unblu;\r\nunblu.AgentAvailabilityState = AgentAvailabilityState;\r\nunblu.CallState = CallState;\r\nunblu.ConnectionState = ConnectionState;\r\nunblu.ConversationState = ConversationState;\r\nunblu.ConversationType = ConversationType;\r\nunblu.UnbluErrorType = UnbluErrorType;\r\n\r\n\r\n/**\r\n * The central access point to the unblu JS API.\r\n * This api object gives static access to configure and initialize the full unblu `UnbluApi`.\r\n * When loaded in the global space use `Unblu.Api` to access it.\r\n * @hidden\r\n */\r\nexport const api = new UnbluStaticApi();\r\n\r\n","import {UnbluApi} from './unblu-api';\r\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\r\nimport {UnbluUtil} from './unblu-util';\r\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\r\nimport {ApiBridge} from './internal/api-bridge';\r\nimport {InternalApi} from './internal/internal-api';\r\n\r\nexport interface Configuration {\r\n /**\r\n * An API-Key of the account to be used.\r\n * This is a mandatory configuration.\r\n *\r\n * API keys can be retrieved from the Unblu Agent Desk in the settings section.\r\n * Keep in mind, that an Admin role is needed.\r\n */\r\n apiKey: string,\r\n\r\n /**\r\n * The url of the Unblu server to connect to.\r\n *\r\n * @default If not set, the domain of the current page will be used.\r\n */\r\n serverUrl?: string,\r\n\r\n /**\r\n * The public path to Unblu which will be used in combination with [[serverUrl]] to connect to Unblu.\r\n *\r\n * @default If not set, '/unblu' will be used.\r\n */\r\n entryPath?: string,\r\n\r\n /**\r\n * The locale to be used for all Unblu translation texts.\r\n *\r\n * @default If not set, the browsers locale will be used.\r\n */\r\n locale?: string\r\n\r\n /**\r\n * The named area to be used. The named area determines the agent availability, the queue that conversation requests go to, and the configuration.\r\n *\r\n * @default If not set, if the `\"/>` will be used if present and if not, the domain will be used.\r\n */\r\n namedArea?: string\r\n\r\n /**\r\n * The timeout im milliseconds that should be waited for the Unblu integration to load.\r\n *\r\n * @default 30'000 (30 seconds).\r\n */\r\n initTimeout?: number\r\n}\r\n\r\nexport const enum ApiState {\r\n INITIAL = 'INITIAL',\r\n INITIALIZING = 'INITIALIZING',\r\n INITIALIZED = 'INITIALIZED',\r\n ERROR = 'ERROR'\r\n}\r\n\r\nexport type ReadyListener = (api: UnbluApi) => void;\r\nexport type ErrorListener = (e: Error) => void;\r\n\r\n\r\n/**\r\n * #### The central entry point that allows to configure an initialize the Unblu Visitor JS API.\r\n * The static Unblu API works without actually loading the rest of Unblu.\r\n * It can do some general checks and load Unblu or connect the API to a loaded version of Unblu.\r\n * The JS API is an optional add-on to the Unblu visitor site integration.\r\n *\r\n * Depending on how Unblu is integrated into the local website the API has to be initialized differently.\r\n *\r\n * **a.) API-only integration**\r\n * If no unblu-snippet is loaded into the page, Unblu can be fully initialized with the API.\r\n * In this case, both the `configure` and the `initialize` methods have to be called.\r\n * Example:\r\n * ```ts\r\n * const api = await unblu.api\r\n * // configure the unblu server\r\n * .configure({\r\n * apiKey: \"\",\r\n * serverUrl: \"\"\r\n * })\r\n * // initialize the api.\r\n * .initialize();\r\n * ```\r\n * This implementation will load the Unblu snippet and initialize both Unblu and the JS API.\r\n *\r\n * **b.) Snippet and JS API integration**\r\n * If the Unblu snippet is already present in the local website, Unblu doesn't have to be loaded\r\n * and only the API has to be initialized.\r\n * Example:\r\n * ```ts\r\n * // directly initialize the api without configuring.\r\n * const api = await unblu.api.initialize();\r\n *\r\n * ```\r\n */\r\nexport class UnbluStaticApi {\r\n private state: ApiState = ApiState.INITIAL;\r\n private error: UnbluApiError;\r\n private eventEmitter = new EventEmitter();\r\n\r\n private configuration: Configuration;\r\n private initializedApi: UnbluApi;\r\n\r\n /**\r\n * Event emitted as soon as the API is initialized.\r\n *\r\n * It usually makes sense to use this event if there is some general action that has to be triggered when the API is initialized,\r\n * but there are several places in the integration code that may trigger the initialization.\r\n *\r\n * In most cases however, it is better to use\r\n * ```ts\r\n * unblu.api.initialize().then(api => { //use api here });\r\n * ```\r\n * or\r\n * ```ts\r\n * let api = await unblu.api.initialize();\r\n * // use api here\r\n * ```\r\n *\r\n * @event ready\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly READY: 'ready' = 'ready';\r\n /**\r\n * Event emitted if the API initialization fails.\r\n *\r\n * It usually makes sense to use this event if there is some general action that has to be triggered when the API initialization fails,\r\n * but there are several places in the integration code that may trigger the initialization.\r\n *\r\n * In most cases however, it is better to use\r\n * ```ts\r\n * unblu.api.initialize().catch(error=> { //handle error here });\r\n * ```\r\n * or\r\n * ```ts\r\n * try{\r\n * let api = await unblu.api.initialize();\r\n * }catch(e){\r\n * // handle error here\r\n * }\r\n *\r\n * ```\r\n *\r\n * @event error\r\n * @see [[on]] for listener registration\r\n */\r\n public static readonly ERROR: 'error' = 'error';\r\n\r\n /**\r\n * @hidden\r\n */\r\n constructor() {\r\n //TODO: detect browser support;\r\n\r\n // store the error\r\n this.eventEmitter.on(UnbluStaticApi.ERROR, e => this.error = e);\r\n\r\n // install globally\r\n const unblu = UnbluUtil.getUnbluObject();\r\n if (unblu.api) {\r\n this.handleError(new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Unblu API has already been loaded.'));\r\n } else {\r\n unblu.api = this;\r\n }\r\n if (UnbluUtil.isUnbluLoaded()) {\r\n // Auto init if snippet is already loaded.\r\n this.initializeApi().catch(e => console.warn('Error during auto initialization', e));\r\n }\r\n }\r\n\r\n //TODO: Add version\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n *\r\n * **Note** If the API is already initialized, this listener will be called directly.\r\n * @param event The ready event\r\n * @param listener The listener to be called.\r\n * @see [[READY]]\r\n */\r\n on(event: typeof UnbluStaticApi.READY, listener: ReadyListener): void;\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n *\r\n * **Note** If the API has already failed, this listener will be called directly.\r\n * @param event The error event\r\n * @param listener The listener to be called.\r\n * @see [[ERROR]]\r\n */\r\n on(event: typeof UnbluStaticApi.ERROR, listener: ErrorListener): void;\r\n\r\n on(event: string, listener: Listener): void {\r\n if (event == UnbluStaticApi.READY && this.state == ApiState.INITIALIZED)\r\n listener(this.initializedApi);\r\n else if (event == UnbluStaticApi.ERROR && this.state == ApiState.ERROR)\r\n listener(this.error);\r\n else\r\n this.eventEmitter.on(event, listener)\r\n }\r\n\r\n /**\r\n * Removes a previously registered listener.\r\n * @param event The event unregister.\r\n * @param listener The listener to be removed.\r\n * @return `true` if the listener was removed, `false` otherwise.\r\n */\r\n off(event: string, listener: Listener): boolean {\r\n return this.eventEmitter.off(event, listener);\r\n }\r\n\r\n\r\n /**\r\n * Checks whether the API has to be configured or not.\r\n *\r\n * - If no snippet is present and the API state is still [INITIAL]{@link ApiState.INITIAL} a configuration is necessary.\r\n * - If a snippet is present or the API is already loaded, configuration is not necessary.\r\n *\r\n * @return `true` if a configuration is needed to initialize the API, `false` otherwise.\r\n * @see [[configure]] to configure the API\r\n * @see [[initialize]] to initialize the API\r\n */\r\n public isConfigurationNeeded(): boolean {\r\n return this.state === ApiState.INITIAL && !UnbluUtil.isUnbluLoaded();\r\n }\r\n\r\n\r\n /**\r\n * Returns the current state of the API\r\n * @return the current API state.\r\n * @see [[isInitialized]] for a simpler check\r\n */\r\n public getApiState(): ApiState {\r\n return this.state;\r\n }\r\n\r\n /**\r\n * Checks whether the API is initialized or not.\r\n * @return `true` if the API is initialized, `false` for any other state.\r\n * @see [[getApiState]] for the full state\r\n */\r\n public isInitialized(): boolean {\r\n return this.state === ApiState.INITIALIZED;\r\n }\r\n\r\n /**\r\n * Configures the way that Unblu should be initialized.\r\n *\r\n * The configuration of the Unblu API is needed when, and only when no Unblu snippet is already present in the website.\r\n *\r\n * **Note:**\r\n * - Calling this method when there already is an unblu-snippet will result in an [[UnbluApiError]].\r\n * - This method must be called BEFORE [[initialize]]. If it is called afterwards an [[UnbluApiError]] will be thrown.\r\n *\r\n * @param config The configuration to be set.\r\n * @return an instance of `this` allowing chaining like `unblu.api.configure({...}).initialize();`\r\n * @see [[isConfigurationNeeded]] to check if configuration is needed or not.\r\n */\r\n configure(config: Configuration): UnbluStaticApi {\r\n if (UnbluUtil.isUnbluLoaded()) {\r\n throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Configure called when Unblu was already loaded.')\r\n } else if (this.state !== ApiState.INITIAL) {\r\n throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error configure called after API was already initialized.');\r\n }\r\n this.configuration = config;\r\n return this;\r\n }\r\n\r\n /**\r\n * Initializes the API and resolves to the fully initialized API.\r\n *\r\n * If the API has already been initialized or is already in the initializing process, the existing API will be returned.\r\n * There is only ever one instance of the API which will be returned by any call of this method which makes it safe to call this multiple times.\r\n *\r\n * *The initialization may fail with a [[UnbluApiError]] for the following reasons*\r\n * - A configuration is needed but none was provided: [CONFIGURATION_MISSING]{@link UnbluErrorType.CONFIGURATION_MISSING}\r\n * - Loading Unblu encounters a problem: [ERROR_LOADING_UNBLU]{@link UnbluErrorType.ERROR_LOADING_UNBLU}\r\n * - The initialization timed out: [INITIALIZATION_TIMEOUT]{@link UnbluErrorType.INITIALIZATION_TIMEOUT}\r\n * - The Unblu API is incompatible with the Unblu server: [INCOMPATIBLE_UNBLU_VERSION]{@link UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION}\r\n * - The browser is unsupported: [UNSUPPORTED_BROWSER]{@link UnbluErrorType.UNSUPPORTED_BROWSER}\r\n */\r\n public async initialize(): Promise {\r\n if (this.state === ApiState.INITIALIZED) {\r\n return this.initializedApi;\r\n } else if (this.state === ApiState.INITIALIZING) {\r\n return new Promise((resolve, reject) => {\r\n this.on(UnbluStaticApi.READY, resolve);\r\n this.on(UnbluStaticApi.ERROR, reject);\r\n });\r\n } else {\r\n return this.initializeApi();\r\n }\r\n }\r\n\r\n private async initializeApi(): Promise {\r\n this.state = ApiState.INITIALIZING;\r\n try {\r\n if (!UnbluUtil.isUnbluLoaded()) {\r\n if (!this.configuration) {\r\n throw new UnbluApiError(UnbluErrorType.CONFIGURATION_MISSING, 'No Unblu snippet present and no configuration provided. Use configure if you want to initialize Unblu without having the Unblu snippet loaded.')\r\n }\r\n if (this.configuration.namedArea) {\r\n UnbluUtil.setNamedArea(this.configuration.namedArea);\r\n }\r\n if (this.configuration.locale) {\r\n UnbluUtil.setLocale(this.configuration.locale);\r\n }\r\n await this.injectUnblu(this.configuration);\r\n }\r\n let apiBridge = new ApiBridge(UnbluUtil.getUnbluObject());\r\n await apiBridge.waitUntilLoaded(this.configuration ? this.configuration.initTimeout || 30000 : 30000);\r\n\r\n let internalApi = new InternalApi(apiBridge);\r\n internalApi.checkCompatibility();\r\n\r\n // Check internalApi waitUntilInitialized\r\n await internalApi.meta.waitUntilInitialized();\r\n\r\n this.initializedApi = new UnbluApi(internalApi);\r\n this.state = ApiState.INITIALIZED;\r\n } catch (e) {\r\n this.handleError(e);\r\n }\r\n\r\n this.eventEmitter.emit(UnbluStaticApi.READY, this.initializedApi);\r\n\r\n return this.initializedApi;\r\n }\r\n\r\n private async injectUnblu(config: Configuration): Promise {\r\n const serverUrl = config.serverUrl || '';\r\n const apiKey = config.apiKey || '';\r\n const unbluPath = config.entryPath || '/unblu';\r\n let unbluUrl = `${serverUrl}${unbluPath}/visitor.js?x-unblu-apikey=${apiKey}`;\r\n try {\r\n await UnbluUtil.loadScript(unbluUrl, config.initTimeout);\r\n } catch (e) {\r\n throw new UnbluApiError(UnbluErrorType.ERROR_LOADING_UNBLU, 'Error loading unblu snippet: ' + e + ' check the configuration: ' + config);\r\n }\r\n }\r\n\r\n private handleError(error: UnbluApiError) {\r\n this.state = ApiState.ERROR;\r\n this.eventEmitter.emit(UnbluStaticApi.ERROR, error);\r\n console.error(error);\r\n throw error;\r\n }\r\n\r\n\r\n}","import {InternalApi} from './internal/internal-api';\r\nimport {GeneralEventType} from './internal/module/general-module';\r\nimport {Event, EventCallback} from './internal/event';\r\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\r\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\r\nimport {IndividualUiState} from './model/individualui_state';\r\n\r\n/**\r\n * Listener called whenever the UI state changes.\r\n * @param uistate The new UI state.\r\n */\r\nexport type UiStateChangeListener = (uistate: IndividualUiState) => void;\r\n\r\n/**\r\n * This class allows controlling of the UI state and the Unblu individual UI.\r\n */\r\nexport class UnbluUiApi {\r\n\r\n private internalListeners: { [key: string]: EventCallback } = {};\r\n private eventEmitter = new EventEmitter();\r\n\r\n /**\r\n * Event emitted every time the state of the individual UI is changed.\r\n *\r\n * @event uiStateChange\r\n * @see [[on]] for listener registration\r\n * @see [[UiStateChangeListener]]\r\n */\r\n public static readonly UI_STATE_CHANGE: 'uiStateChange' = 'uiStateChange';\r\n\r\n\r\n /**\r\n * @hidden\r\n */\r\n constructor(private internalApi: InternalApi) {\r\n internalApi.meta.on('upgraded', () => this.onUpgraded());\r\n }\r\n\r\n /**\r\n * Registers an event listener for the given event.\r\n * @param event The uistateChange event.\r\n * @param listener The listener to be called.\r\n * @see [[UI_STATE_CHANGE]]\r\n */\r\n public on(event: typeof UnbluUiApi.UI_STATE_CHANGE, listener: UiStateChangeListener): void;\r\n\r\n public on(event: GeneralEventType, listener: Listener): void {\r\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\r\n this.eventEmitter.on(event, listener);\r\n if (needsInternalSubscription)\r\n this.onInternal(event).catch(e => console.warn('Error registering internal listener for event:', event, 'error:' + e, e));\r\n }\r\n\r\n /**\r\n * Removes a previously registered listener\r\n * @param event The event to unregister from.\r\n * @param listener The listener to remove.\r\n */\r\n public off(event: GeneralEventType, listener: Listener): boolean {\r\n const removed = this.eventEmitter.off(event, listener);\r\n if (!this.eventEmitter.hasListeners(event))\r\n this.offInternal(event).catch(e => console.warn('Error removing internal listener for event:', event, 'error:' + e, e));\r\n return removed;\r\n }\r\n\r\n\r\n private async onInternal(eventName: GeneralEventType) {\r\n let internalListener: EventCallback;\r\n switch (eventName) {\r\n case UnbluUiApi.UI_STATE_CHANGE:\r\n internalListener = (event: Event) => {\r\n this.eventEmitter.emit(event.name, event.data);\r\n };\r\n break;\r\n default:\r\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, 'Registration to unknown event:' + eventName);\r\n }\r\n\r\n if (await this.internalApi.meta.isUpgraded()) {\r\n this.internalListeners[eventName] = internalListener;\r\n try {\r\n await this.internalApi.general.on(eventName, internalListener);\r\n } catch (e) {\r\n delete this.internalListeners[eventName];\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n private async offInternal(eventName: GeneralEventType) {\r\n const listener = this.internalListeners[eventName];\r\n if (listener == null) {\r\n return;\r\n }\r\n delete this.internalListeners[eventName];\r\n await this.internalApi.general.off(eventName, listener);\r\n }\r\n\r\n\r\n /**\r\n * Opens the individual UI if it is collapsed and collapses it if it is open.\r\n */\r\n public async toggleIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.toggleIndividualUi();\r\n }\r\n\r\n /**\r\n * Navigates the individual UI to the PIN entry UI.\r\n *\r\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [[openIndividualUi]] if this is needed.\r\n */\r\n public async openPinEntryUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.openPinEntryUi();\r\n }\r\n\r\n\r\n /**\r\n * Pop-out the individual UI into a separate window.\r\n *\r\n * **NOTE:** this has to be called in a click-event in order to be able to open the pop-up window without being blocked by the browser!\r\n */\r\n public async popoutIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.popoutIndividualUi();\r\n }\r\n\r\n /**\r\n * Pop-in the individual UI when it is in [POPPED_OUT]{@link IndividualUiState.POPPED_OUT} state.\r\n *\r\n * The pop-out window will automatically close and the individual UI will be displayed in the original window again.\r\n */\r\n public async popinIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.popinIndividualUi();\r\n }\r\n\r\n /**\r\n * Maximize the individual UI - Does nothing if it is already maximized or popped out.\r\n */\r\n public async maximizeIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.maximizeIndividualUi();\r\n }\r\n\r\n /**\r\n * Minimize the individual UI - Does nothing if it is already minimized.\r\n */\r\n public async minimizeIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.minimizeIndividualUi();\r\n }\r\n\r\n /**\r\n * Opens the individual UI if it was collapsed. - Does nothing if it was already open.\r\n */\r\n public async openIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.openIndividualUi();\r\n }\r\n\r\n /**\r\n * Collapses the individual UI if it was open. - Does nothing if it was already collapsed.\r\n */\r\n public async collapseIndividualUi(): Promise {\r\n await this.requireUpgrade();\r\n await this.internalApi.general.collapseIndividualUi();\r\n }\r\n\r\n /**\r\n * Get the state of the individual UI.\r\n * @return A promise that resolves to the [[IndividualUiState]] of the individual UI.\r\n */\r\n public async getIndividualUiState(): Promise {\r\n if (!await this.internalApi.meta.isUpgraded()) {\r\n return IndividualUiState.COLLAPSED;\r\n }\r\n return await this.internalApi.general.getIndividualUiState();\r\n }\r\n\r\n private async requireUpgrade(): Promise {\r\n await this.internalApi.meta.upgrade(false);\r\n }\r\n\r\n private onUpgraded() {\r\n for (let event of this.eventEmitter.getEventsWithListeners()) {\r\n // register internal listeners for all events that need upgrade.\r\n if (!this.internalListeners[event])\r\n this.onInternal(event as GeneralEventType);\r\n }\r\n }\r\n}","import {EventCallback} from './event';\r\nimport {UnbluApiError, UnbluErrorType} from '../unblu-api-error';\r\nimport {\r\n CATEGORY_ACTION_NOT_GRANTED,\r\n CATEGORY_EXECUTION_EXCEPTION,\r\n CATEGORY_INVALID_FUNCTION_ARGUMENTS,\r\n CATEGORY_INVALID_FUNCTION_CALL\r\n} from './java-error-codes';\r\n\r\n\r\nconst SUPPORTED_MAJOR_VERSION = 2;\r\n\r\ninterface ApiConsumer {\r\n onUnbluEvent(event: Event): Promise;\r\n}\r\n\r\ninterface CollabServerInternalApi {\r\n getApiVersion(): string;\r\n\r\n execute(moduleName: string, functionName: string, args: any[]): Promise;\r\n\r\n registerEventListener(moduleName: string, eventName: string, listener: EventCallback): Promise;\r\n\r\n removeEventListener(moduleName: string, eventName: string, listener: EventCallback): Promise;\r\n}\r\n\r\nexport class ApiBridge {\r\n private internal: CollabServerInternalApi;\r\n private readonly eventHandler: ApiConsumer;\r\n\r\n /**\r\n * instantiates the bridge that links the UNBLU internal API provided by the collaboration server with the UNBLU JS-API\r\n * @param mountPoint the global unblu object under which the internal API is registered.\r\n */\r\n constructor(private mountPoint: any) {\r\n }\r\n\r\n public async waitUntilLoaded(timeout: number, promise?: Promise): Promise {\r\n const timeoutTimestamp = Date.now() + timeout;\r\n return new Promise((resolve, reject) => {\r\n const waitForLoaded = () => {\r\n if (timeoutTimestamp - Date.now() > 0) {\r\n if (this.checkLoaded()) return resolve();\r\n setTimeout(waitForLoaded, 50);\r\n } else {\r\n reject(new UnbluApiError(UnbluErrorType.INITIALIZATION_TIMEOUT, 'Timeout while waiting for collaboration server API to be loaded.'));\r\n }\r\n };\r\n waitForLoaded();\r\n });\r\n }\r\n\r\n private checkLoaded(): boolean {\r\n this.internal = this.mountPoint['internal'];\r\n return this.internal != null;\r\n }\r\n\r\n\r\n public checkCompatibility(): void {\r\n if (!this.internal) {\r\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, no API bridge provided.');\r\n } else if (typeof this.internal.getApiVersion !== 'function') {\r\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, incompatible API bridge.');\r\n }\r\n const version = this.internal.getApiVersion();\r\n if (+version[0] != SUPPORTED_MAJOR_VERSION) {\r\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, `Incompatible collaboration server version. \r\n Supported API version: ${SUPPORTED_MAJOR_VERSION}.x.x.\r\n collaboration server API version: ${version}.`);\r\n }\r\n }\r\n\r\n\r\n /**\r\n * Calls an API function of the internal unblu collaboration server API.\r\n * @param moduleName The module to which the function belongs.\r\n * @param functionName The function to call.\r\n * @param args The arguments to pass to the function.\r\n */\r\n public async callApiFunction(moduleName: string, functionName: string, args: any[]): Promise {\r\n try {\r\n return await this.internal.execute(moduleName, functionName, args);\r\n } catch (e) {\r\n switch (e.type) {\r\n case CATEGORY_INVALID_FUNCTION_CALL:\r\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_CALL, e.message);\r\n case CATEGORY_INVALID_FUNCTION_ARGUMENTS:\r\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, e.message);\r\n case CATEGORY_ACTION_NOT_GRANTED:\r\n throw new UnbluApiError(UnbluErrorType.ACTION_NOT_GRANTED, e.message);\r\n case CATEGORY_EXECUTION_EXCEPTION:\r\n throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, e.message);\r\n default:\r\n throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, '' + e);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Registers a callback for an event emitted by the internal unblu collaboration server API.\r\n * @param module The module that emits the event.\r\n * @param event The event name.\r\n * @param callback The callback which will be called every time the event is emitted.\r\n */\r\n public on(module: string, event: string, callback: EventCallback): Promise {\r\n return this.internal.registerEventListener(module, event, callback);\r\n }\r\n\r\n /**\r\n * Unregisters a callback for an event emitted by the internal unblu collaboration server API.\r\n * @param module The module that emits the event.\r\n * @param event The event name.\r\n * @param callback Optionally callback which will be removed, if none is provided all listeners of the event will be removed.\r\n */\r\n public off(module: string, event: string, callback?: EventCallback): Promise {\r\n return this.internal.removeEventListener(module, event, callback);\r\n }\r\n\r\n}","export const CATEGORY_INVALID_FUNCTION_CALL = 1;\r\nexport const CATEGORY_INVALID_FUNCTION_ARGUMENTS = 2;\r\nexport const CATEGORY_EXECUTION_EXCEPTION = 3;\r\nexport const CATEGORY_ACTION_NOT_GRANTED = 4;","import {ApiBridge} from './api-bridge';\r\nimport {MetaModule} from './module/meta-module';\r\nimport {GeneralModule} from './module/general-module';\r\nimport {GeneralLazyModule} from './module/general-lazy-module';\r\nimport {ConversationModule} from './module/conversation-module';\r\nimport {AgentAvailabilityModule} from './module/agent-availability-module';\r\n\r\nexport class InternalApi {\r\n public meta: MetaModule;\r\n public general: GeneralModule;\r\n public generalLazy: GeneralLazyModule;\r\n public conversation: ConversationModule;\r\n public agentAvailability: AgentAvailabilityModule;\r\n\r\n constructor(private bridge: ApiBridge) {\r\n this.meta = new MetaModule(bridge);\r\n this.general = new GeneralModule(bridge);\r\n this.generalLazy = new GeneralLazyModule(bridge);\r\n this.conversation = new ConversationModule(bridge);\r\n this.agentAvailability = new AgentAvailabilityModule(bridge);\r\n }\r\n\r\n public checkCompatibility(): void {\r\n this.bridge.checkCompatibility();\r\n }\r\n}","import {InternalModule} from './module';\r\nimport {ApiBridge} from '../api-bridge';\r\n\r\nexport type MetaEventType = 'upgraded';\r\n\r\nconst enum MetaFunction {\r\n isUpgraded = 'isUpgraded',\r\n upgrade = 'upgrade',\r\n waitUntilInitialized = 'waitUntilInitialized'\r\n}\r\n\r\nexport class MetaModule extends InternalModule {\r\n constructor(bridge: ApiBridge) {\r\n super(bridge, 'meta');\r\n }\r\n\r\n public isUpgraded(): Promise {\r\n return this.callApiFunction(MetaFunction.isUpgraded, []);\r\n }\r\n\r\n public upgrade(openUi?: boolean): Promise {\r\n return this.callApiFunction(MetaFunction.upgrade, [openUi]);\r\n }\r\n\r\n public waitUntilInitialized(): Promise {\r\n return this.callApiFunction(MetaFunction.waitUntilInitialized, []);\r\n }\r\n}","import {InternalModule} from './module';\r\nimport {ApiBridge} from '../api-bridge';\r\nimport {PersonInfo} from '../../model/person-info';\r\nimport {ConversationType} from '../../model/conversation-type';\r\nimport {IndividualUiState} from '../../model/individualui_state';\r\nimport {NewConversationInterceptor} from \"../../unblu-api\";\r\nimport {ConversationInfo} from \"../../model/conversation-info\";\r\n\r\nexport type GeneralEventType =\r\n 'activeConversationChange' |\r\n 'conversationsChange' |\r\n 'notificationCountChange' |\r\n 'personChange' |\r\n 'uiStateChange';\r\n\r\nconst enum GeneralFunction {\r\n startConversation = 'startConversation',\r\n setNewConversationInterceptor = 'setNewConversationInterceptor',\r\n joinConversation = 'joinConversation',\r\n openConversation = 'openConversation',\r\n toggleIndividualUi = 'toggleIndividualUi',\r\n popoutIndividualUi = 'popoutIndividualUi',\r\n popinIndividualUi = 'popinIndividualUi',\r\n maximizeIndividualUi = 'maximizeIndividualUi',\r\n minimizeIndividualUi = 'minimizeIndividualUi',\r\n openIndividualUi = 'openIndividualUi',\r\n openPinEntryUi = 'openPinEntryUi',\r\n collapseIndividualUi = 'collapseIndividualUi',\r\n getIndividualUiState = 'getIndividualUiState',\r\n getActiveConversation = 'getActiveConversation',\r\n getConversations = 'getConversations',\r\n getNotificationCount = 'getNotificationCount',\r\n getPersonInfo = 'getPersonInfo',\r\n setPersonNickname = 'setPersonNickname'\r\n}\r\n\r\nexport class GeneralModule extends InternalModule {\r\n constructor(bridge: ApiBridge) {\r\n super(bridge, 'general');\r\n }\r\n\r\n public startConversation(type: ConversationType, visitorName?: string, visitorData?: string): Promise {\r\n return this.callApiFunction(GeneralFunction.startConversation, [type, visitorName, visitorData]);\r\n }\r\n\r\n public setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\r\n return this.callApiFunction(GeneralFunction.setNewConversationInterceptor, [callback]);\r\n }\r\n\r\n public joinConversation(pin: string, visitorName?: string): Promise {\r\n return this.callApiFunction(GeneralFunction.joinConversation, [pin, visitorName]);\r\n }\r\n\r\n public openConversation(conversationId: string): Promise {\r\n return this.callApiFunction(GeneralFunction.openConversation, [conversationId]);\r\n }\r\n\r\n public toggleIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.toggleIndividualUi, []);\r\n }\r\n\r\n public openPinEntryUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.openPinEntryUi, []);\r\n }\r\n\r\n public popoutIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.popoutIndividualUi, []);\r\n }\r\n\r\n public popinIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.popinIndividualUi, []);\r\n }\r\n\r\n public maximizeIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.maximizeIndividualUi, []);\r\n }\r\n\r\n public minimizeIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.minimizeIndividualUi, []);\r\n }\r\n\r\n public openIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.openIndividualUi, []);\r\n }\r\n\r\n public collapseIndividualUi(): Promise {\r\n return this.callApiFunction(GeneralFunction.collapseIndividualUi, []);\r\n }\r\n\r\n public getIndividualUiState(): Promise {\r\n return this.callApiFunction(GeneralFunction.getIndividualUiState, []); \r\n }\r\n\r\n public getActiveConversation(): Promise {\r\n return this.callApiFunction(GeneralFunction.getActiveConversation, []);\r\n }\r\n\r\n public getConversations(): Promise {\r\n return this.callApiFunction(GeneralFunction.getConversations, []);\r\n }\r\n\r\n public getNotificationCount(): Promise {\r\n return this.callApiFunction(GeneralFunction.getNotificationCount, []);\r\n }\r\n\r\n public getPersonInfo(): Promise {\r\n return this.callApiFunction(GeneralFunction.getPersonInfo, []);\r\n }\r\n\r\n public setPersonNickname(nickname: string): Promise {\r\n return this.callApiFunction(GeneralFunction.setPersonNickname, [nickname]);\r\n }\r\n}","import {InternalModule} from './module';\r\nimport {ApiBridge} from '../api-bridge';\r\nimport {PersonInfo} from '../../model/person-info';\r\nimport {NewConversationInterceptor} from \"../../unblu-api\";\r\n\r\n\r\nexport type GeneralLazyEventType = '';\r\n\r\nconst enum GeneralLazyFunction {\r\n getNotificationCount = 'getNotificationCount',\r\n getPersonInfo = 'getPersonInfo',\r\n setNewConversationInterceptor = 'setNewConversationInterceptor',\r\n}\r\n\r\nexport class GeneralLazyModule extends InternalModule {\r\n constructor(bridge: ApiBridge) {\r\n super(bridge, 'generallazy');\r\n }\r\n\r\n public getNotificationCount(): Promise {\r\n return this.callApiFunction(GeneralLazyFunction.getNotificationCount, []);\r\n }\r\n\r\n public getPersonInfo(): Promise {\r\n return this.callApiFunction(GeneralLazyFunction.getPersonInfo, []);\r\n }\r\n\r\n public setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\r\n return this.callApiFunction(GeneralLazyFunction.setNewConversationInterceptor, [callback]);\r\n }\r\n}","import {InternalModule} from './module';\r\nimport {ApiBridge} from '../api-bridge';\r\nimport {CallState} from '../../model/call-state';\r\nimport {ConversationState} from '../../model/conversation-state';\r\nimport {ConnectionState} from '../../model/connection-state';\r\nimport {Invitation} from \"../../model/invitation\";\r\n\r\n\r\nexport interface ConversationCallState {\r\n conversationId: string\r\n callState: CallState\r\n}\r\n\r\nexport interface ConversationConnectionState {\r\n conversationId: string\r\n connectionState: ConnectionState\r\n}\r\n\r\nexport interface ConversationWithState {\r\n conversationId: string\r\n conversationState: ConversationState\r\n}\r\n\r\nexport interface ConversationInvitations {\r\n conversationId: string\r\n invitations: Invitation[]\r\n}\r\n\r\nexport type ConversationEventType =\r\n 'connectionStateChange' |\r\n 'conversationStateChange' |\r\n 'end' |\r\n 'close' |\r\n 'personChange' |\r\n 'callStateChange' |\r\n 'invitationsChange'\r\n\r\nconst enum ConversationFunction {\r\n getConnectionState = 'getConnectionState',\r\n getConversationState = 'getConversationState',\r\n getCallState = 'getCallState',\r\n startAudioCall = 'startAudioCall',\r\n startVideoCall = 'startVideoCall',\r\n endConversation = 'endConversation',\r\n leaveConversation = 'leaveConversation',\r\n closeConversation = 'closeConversation',\r\n createAnonymousPinInvitation = 'createAnonymousPinInvitation',\r\n createAnonymousEmailInvitation = 'createAnonymousEmailInvitation',\r\n getInvitations = 'getInvitations',\r\n revokeInvitation = 'revokeInvitation',\r\n renewInvitationPin = 'renewInvitationPin',\r\n setVisitorData = 'setVisitorData'\r\n}\r\n\r\nexport class ConversationModule extends InternalModule {\r\n constructor(bridge: ApiBridge) {\r\n super(bridge, 'conversation');\r\n }\r\n\r\n public getConnectionState(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.getConnectionState, [conversationId]);\r\n }\r\n\r\n public getConversationState(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.getConversationState, [conversationId]);\r\n }\r\n\r\n public getCallState(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.getCallState, [conversationId]);\r\n }\r\n\r\n public startAudioCall(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.startAudioCall, [conversationId]);\r\n }\r\n\r\n public startVideoCall(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.startVideoCall, [conversationId]);\r\n }\r\n\r\n public endConversation(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.endConversation, [conversationId]);\r\n }\r\n\r\n public leaveConversation(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.leaveConversation, [conversationId]);\r\n }\r\n\r\n public closeConversation(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.closeConversation, [conversationId]);\r\n }\r\n\r\n public createAnonymousPinInvitation(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.createAnonymousPinInvitation, [conversationId]);\r\n }\r\n\r\n public createAnonymousEmailInvitation(conversationId: string, email: String) : Promise {\r\n return this.callApiFunction(ConversationFunction.createAnonymousEmailInvitation, [conversationId, email]);\r\n }\r\n\r\n public async getInvitations(conversationId: string): Promise {\r\n return this.callApiFunction(ConversationFunction.getInvitations, [conversationId]);\r\n }\r\n\r\n public async revokeInvitation(conversationId: string, invitationId: String) : Promise {\r\n return this.callApiFunction(ConversationFunction.revokeInvitation, [conversationId, invitationId]);\r\n }\r\n\r\n public async renewInvitationPin(conversationId: string, invitationId: String) : Promise {\r\n return this.callApiFunction(ConversationFunction.renewInvitationPin, [conversationId, invitationId]);\r\n }\r\n\r\n public async setVisitorData(visitorData: String) : Promise {\r\n return this.callApiFunction(ConversationFunction.setVisitorData, [visitorData]);\r\n }\r\n}","import {InternalModule} from './module';\r\nimport {ApiBridge} from '../api-bridge';\r\nimport {AgentAvailabilityState} from '../../model/agent-availability-state';\r\n\r\n\r\nexport type AgentAvailabilityEventType = 'availabilityChange';\r\n\r\nconst enum AgentAvailabilityFunction {\r\n isAgentAvailable = 'isAgentAvailable',\r\n getAgentAvailabilityState = 'getAgentAvailabilityState'\r\n}\r\n\r\nexport class AgentAvailabilityModule extends InternalModule {\r\n constructor(bridge: ApiBridge) {\r\n super(bridge, 'agentavailability');\r\n }\r\n\r\n public isAgentAvailable(): Promise {\r\n return this.callApiFunction(AgentAvailabilityFunction.isAgentAvailable, []);\r\n }\r\n\r\n public getAgentAvailabilityState(): Promise {\r\n return this.callApiFunction(AgentAvailabilityFunction.getAgentAvailabilityState, []);\r\n }\r\n}","export enum CallState {\r\n /**\r\n * A some one is trying to call, the phone is ringing\r\n */\r\n INBOUND = 'INBOUND',\r\n /**\r\n * You are trying to call someone\r\n */\r\n OUTBOUND = 'OUTBOUND',\r\n /**\r\n * A call is active and the local tab is connected to the call.\r\n */\r\n ACTIVE_JOINED = 'ACTIVE_JOINED',\r\n /**\r\n * A call is active but the local person has declined it.\r\n */\r\n ACTIVE_NOT_JOINED = 'ACTIVE_NOT_JOINED',\r\n /**\r\n * A call is active and the local person has joined it on an other device.\r\n */\r\n ACTIVE_JOINED_ELSEWHERE = 'ACTIVE_JOINED_ELSEWHERE',\r\n /**\r\n * No inbound, outgoing or active call.\r\n */\r\n NONE = 'NONE'\r\n}\r\n\r\n","export enum ConnectionState {\r\n /**\r\n * Initial state before connection establishment has started\r\n */\r\n INITIAL = 'INITIAL',\r\n\r\n /**\r\n * State during the first connection to the server\r\n */\r\n CONNECTING = 'CONNECTING',\r\n\r\n /**\r\n * The connection has been successfully established.\r\n */\r\n CONNECTED = 'CONNECTED',\r\n\r\n /**\r\n * The connection has been lost, reconnect is active.\r\n */\r\n RECONNECTING = 'RECONNECTING',\r\n\r\n /**\r\n * The connection has been successfully closed.\r\n *\r\n */\r\n CLOSED = 'CLOSED',\r\n\r\n /**\r\n * A fatal error has occurred. The connection has been permanently lost. No reconnect will be be possible.\r\n */\r\n ERROR = 'ERROR'\r\n}\r\n\r\n","export enum ConversationType {\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming chat conversation.\r\n */\r\n CHAT_REQUEST = 'CHAT_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming chat conversation while all agents are offline.\r\n */\r\n OFFLINE_CHAT_REQUEST = 'OFFLINE_CHAT_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming video conversation.\r\n */\r\n VIDEO_REQUEST = 'VIDEO_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming audio conversation.\r\n */\r\n AUDIO_REQUEST = 'AUDIO_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming universal co-browsing conversation.\r\n */\r\n HEADLESS_BROWSER_REQUEST = 'HEADLESS_BROWSER_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming embedded co-browsing conversation.\r\n */\r\n DOMCAP_BROWSER_REQUEST = 'DOMCAP_BROWSER_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming mobile co-browsing conversation.\r\n */\r\n MOBILE_COBROWSING_REQUEST = 'MOBILE_COBROWSING_REQUEST',\r\n /**\r\n * (Visitor initiated, visitor centered) A visitor creates an incoming screen sharing conversation.\r\n */\r\n SCREEN_SHARING_REQUEST = 'SCREEN_SHARING_REQUEST',\r\n\t/**\r\n\t * (Api initiated, visitor centered) A visitor creates a conversation via API which is not added to the queue and where he can invite other visitor to do\r\n\t * embedded\r\n\t */\r\n\tVISITOR_COBROWSING = 'VISITOR_COBROWSING'\r\n}","export enum AgentAvailabilityState {\r\n /**\r\n * There is at least one agent available for the specified named area and language.\r\n */\r\n AVAILABLE = 'AVAILABLE',\r\n /**\r\n * There is at least one agent watching the inbound queue for the specified named area and language but the max capacity of parallel conversations is reached.\r\n *\r\n * It is very likely, that an agent will be available in a short time.\r\n */\r\n BUSY = 'BUSY',\r\n /**\r\n * There is no agent watching the inbound queue for the specified named area and language.\r\n *\r\n * It is unlikely, that an agent will be available in a short time.\r\n */\r\n UNAVAILABLE = 'UNAVAILABLE',\r\n /**\r\n * There is currently no agent handling any inbound queue items.\r\n *\r\n * It is very unlikely, that an agent will be available in a short time.\r\n */\r\n OFFLINE = 'OFFLINE'\r\n}","export enum ConversationState {\r\n /**\r\n * Initial state of a conversation\r\n */\r\n CREATED = 'CREATED',\r\n\r\n /**\r\n * Depending of the engagement type of the conversation, the conversation stays in the onboarding state as long as the person in the center of the conversation\r\n * is doing his onboarding\r\n */\r\n ONBOARDING = 'ONBOARDING',\r\n\r\n /**\r\n * When a message is send to an unassigned conversation, the conversation first is put into the reboarding state as long as the person in the center of the\r\n * conversation is doing the reboarding.\r\n */\r\n REBOARDING = 'REBOARDING',\r\n\r\n /**\r\n * Depending of the engagement type of the conversation, the conversation is put in the queued state when it is inside the queue.\r\n */\r\n QUEUED = 'QUEUED',\r\n\r\n /**\r\n * Conversation is active\r\n */\r\n ACTIVE = 'ACTIVE',\r\n\r\n /**\r\n * After there is no assignee of a conversation anymore, the conversation goes to unassigned state until a message from a visitor is written to start reboarding\r\n * again.\r\n */\r\n UNASSIGNED = 'UNASSIGNED',\r\n\r\n /**\r\n * Conversation is being ended\r\n */\r\n OFFBOARDING = 'OFFBOARDING',\r\n\r\n /**\r\n * Conversation is ended\r\n */\r\n ENDED = 'ENDED'\r\n}"],"sourceRoot":""}