import { useDevice, useRuntimeConfig } from '#imports' /** * Provides functions for managing live chat interactions. * * @returns {Object} An object with a function to open the live chat. * @namespace */ export function useLiveChat() { const runTimeConfig = useRuntimeConfig() const { isMobile } = useDevice() /** * Opens the live chat interface based on the device type. * * On mobile devices, this function opens a new tab with the live chat URL. * On non-mobile devices, it maximizes the live chat widget if available. * * @returns {void} */ const openLiveChat = (): void => { if (isMobile) { const openNewTab = window.open('about:blank', '_blank') if (openNewTab) { openNewTab.location.href = runTimeConfig.public.LIVE_CHAT_LINK } } else { // eslint-disable-next-line @typescript-eslint/no-explicit-any const newWindow: any = window newWindow.LiveChatWidget.call('maximize') } } return { openLiveChat, } }