{ "version": 3, "sources": ["../../../Vettvangur.Frontend/node_modules/.pnpm/throttle-debounce@5.0.2/node_modules/throttle-debounce/throttle.js", "../../../Vettvangur.Frontend/node_modules/.pnpm/throttle-debounce@5.0.2/node_modules/throttle-debounce/debounce.js", "../../../Vettvangur.Frontend/src/scripts/components/chat.ts"], "sourcesContent": ["/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)\n * are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,\n * as-is, to `callback` when the throttled-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds\n * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed\n * one final time after the last throttled-function call. (After the throttled-function has not been called for\n * `delay` milliseconds, the internal counter is reset).\n * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback\n * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that\n * callback will never executed if both noLeading = true and noTrailing = true.\n * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is\n * false (at end), schedule `callback` to execute after `delay` ms.\n *\n * @returns {Function} A new, throttled, function.\n */\nexport default function (delay, callback, options) {\n\tconst {\n\t\tnoTrailing = false,\n\t\tnoLeading = false,\n\t\tdebounceMode = undefined\n\t} = options || {};\n\t/*\n\t * After wrapper has stopped being called, this timeout ensures that\n\t * `callback` is executed at the proper times in `throttle` and `end`\n\t * debounce modes.\n\t */\n\tlet timeoutID;\n\tlet cancelled = false;\n\n\t// Keep track of the last time `callback` was executed.\n\tlet lastExec = 0;\n\n\t// Function to clear existing timeout\n\tfunction clearExistingTimeout() {\n\t\tif (timeoutID) {\n\t\t\tclearTimeout(timeoutID);\n\t\t}\n\t}\n\n\t// Function to cancel next exec\n\tfunction cancel(options) {\n\t\tconst { upcomingOnly = false } = options || {};\n\t\tclearExistingTimeout();\n\t\tcancelled = !upcomingOnly;\n\t}\n\n\t/*\n\t * The `wrapper` function encapsulates all of the throttling / debouncing\n\t * functionality and when executed will limit the rate at which `callback`\n\t * is executed.\n\t */\n\tfunction wrapper(...arguments_) {\n\t\tlet self = this;\n\t\tlet elapsed = Date.now() - lastExec;\n\n\t\tif (cancelled) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\tfunction exec() {\n\t\t\tlastExec = Date.now();\n\t\t\tcallback.apply(self, arguments_);\n\t\t}\n\n\t\t/*\n\t\t * If `debounceMode` is true (at begin) this is used to clear the flag\n\t\t * to allow future `callback` executions.\n\t\t */\n\t\tfunction clear() {\n\t\t\ttimeoutID = undefined;\n\t\t}\n\n\t\tif (!noLeading && debounceMode && !timeoutID) {\n\t\t\t/*\n\t\t\t * Since `wrapper` is being called for the first time and\n\t\t\t * `debounceMode` is true (at begin), execute `callback`\n\t\t\t * and noLeading != true.\n\t\t\t */\n\t\t\texec();\n\t\t}\n\n\t\tclearExistingTimeout();\n\n\t\tif (debounceMode === undefined && elapsed > delay) {\n\t\t\tif (noLeading) {\n\t\t\t\t/*\n\t\t\t\t * In throttle mode with noLeading, if `delay` time has\n\t\t\t\t * been exceeded, update `lastExec` and schedule `callback`\n\t\t\t\t * to execute after `delay` ms.\n\t\t\t\t */\n\t\t\t\tlastExec = Date.now();\n\t\t\t\tif (!noTrailing) {\n\t\t\t\t\ttimeoutID = setTimeout(debounceMode ? clear : exec, delay);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * In throttle mode without noLeading, if `delay` time has been exceeded, execute\n\t\t\t\t * `callback`.\n\t\t\t\t */\n\t\t\t\texec();\n\t\t\t}\n\t\t} else if (noTrailing !== true) {\n\t\t\t/*\n\t\t\t * In trailing throttle mode, since `delay` time has not been\n\t\t\t * exceeded, schedule `callback` to execute `delay` ms after most\n\t\t\t * recent execution.\n\t\t\t *\n\t\t\t * If `debounceMode` is true (at begin), schedule `clear` to execute\n\t\t\t * after `delay` ms.\n\t\t\t *\n\t\t\t * If `debounceMode` is false (at end), schedule `callback` to\n\t\t\t * execute after `delay` ms.\n\t\t\t */\n\t\t\ttimeoutID = setTimeout(\n\t\t\t\tdebounceMode ? clear : exec,\n\t\t\t\tdebounceMode === undefined ? delay - elapsed : delay\n\t\t\t);\n\t\t}\n\t}\n\n\twrapper.cancel = cancel;\n\n\t// Return the wrapper function.\n\treturn wrapper;\n}\n", "/* eslint-disable no-undefined */\n\nimport throttle from './throttle.js';\n\n/**\n * Debounce execution of a function. Debouncing, unlike throttling,\n * guarantees that a function is only executed a single time, either at the\n * very beginning of a series of calls, or at the very end.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the debounced-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds\n * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.\n * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).\n *\n * @returns {Function} A new, debounced function.\n */\nexport default function (delay, callback, options) {\n\tconst { atBegin = false } = options || {};\n\treturn throttle(delay, callback, { debounceMode: atBegin !== false });\n}\n", "import { throttle } from 'throttle-debounce'\n\nconst chat = {\n el: {\n closeTrigger: document.querySelector('.chat__modal-close'),\n chat: document.querySelector('.chat'),\n footer: document.querySelector('.footer'),\n liveChatTrigger: document.querySelector('.livechat-trigger'),\n modal: document.querySelector('.chat__modal'),\n trigger: document.querySelector('.chat__trigger'),\n },\n\n init(): void {\n if (!this.el.modal) {\n return\n }\n\n this.el.trigger.addEventListener('click', this.toggleModal.bind(this))\n this.el.closeTrigger.addEventListener('click', this.toggleModal.bind(this))\n window.addEventListener('scroll', throttle(60, this.toggleVisibility).bind(this))\n\n this.initLiveChat()\n this.toggleVisibility()\n },\n\n initLiveChat(): void {\n //@ts-ignore\n // LC_API.open_chat_window();\n //@ts-ignore\n LiveChatWidget.on('visibility_changed', onVisibilityChanged)\n\n function onVisibilityChanged(data) {\n switch (data.visibility) {\n case 'maximized':\n document.querySelector('#chat-widget-container').style.visibility = 'visible'\n break\n case 'minimized':\n chat.toggleModal()\n setTimeout(() => {\n document.querySelector('#chat-widget-container').style.visibility = 'hidden'\n chat.el.liveChatTrigger.classList.remove('livechat-trigger--open')\n }, 300)\n break\n case 'hidden':\n break\n }\n }\n\n if (this.el.liveChatTrigger) {\n this.el.liveChatTrigger.addEventListener('click', () => {\n const isLiveChatOpen = this.el.liveChatTrigger.classList.contains('livechat-trigger--open')\n\n if (!isLiveChatOpen) {\n //@ts-ignore\n // LC_API.open_chat_window();\n //@ts-ignore\n if (!LiveChatWidget.init()) {\n //@ts-ignore\n // LC_API.open_chat_window();\n //@ts-ignore\n LiveChatWidget.init()\n }\n }\n\n //@ts-ignore\n // LC_API.open_chat_window();\n //@ts-ignore\n LiveChatWidget.call('maximize')\n\n if (!isLiveChatOpen) {\n this.el.liveChatTrigger.classList.add('livechat-trigger--open')\n }\n })\n }\n },\n\n toggleModal(): void {\n this.el.modal.classList.toggle('chat__modal--open')\n\n const isExpanded = this.el.modal.classList.contains('chat__modal--open')\n\n this.el.trigger.setAttribute('aria-expanded', isExpanded ? 'true' : 'false')\n this.el.closeTrigger.setAttribute('aria-expanded', isExpanded ? 'true' : 'false')\n },\n\n toggleVisibility(): void {\n if (!this.el.footer) {\n return\n }\n\n if (window.innerHeight - this.el.footer.getBoundingClientRect().top > 0) {\n this.el.chat.classList.add('chat--hidden')\n } else {\n this.el.chat.classList.remove('chat--hidden')\n }\n },\n}\n\nexport default chat\n"], "mappings":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AAmB,EAEvE,KAAK,GAAG,QAAQ,aAAa,gBAAiBA,EAAa,OAAS,OAAO,EAC3E,KAAK,GAAG,aAAa,aAAa,gBAAiBA,EAAa,OAAS,OAAO,CAClF,EAEA,kBAAyB,CAClB,KAAK,GAAG,SAIT,OAAO,YAAc,KAAK,GAAG,OAAO,sBAAsB,EAAE,IAAM,EACpE,KAAK,GAAG,KAAK,UAAU,IAAI,cAAc,EAEzC,KAAK,GAAG,KAAK,UAAU,OAAO,cAAc,EAEhD,CACF,EAEOC,EAAQN", "names": ["throttle", "delay", "callback", "options", "_ref", "_ref$noTrailing", "noTrailing", "_ref$noLeading", "noLeading", "_ref$debounceMode", "debounceMode", "undefined", "timeoutID", "cancelled", "lastExec", "clearExistingTimeout", "clearTimeout", "cancel", "_ref2", "_ref2$upcomingOnly", "upcomingOnly", "wrapper", "_len", "arguments", "length", "arguments_", "Array", "_key", "self", "elapsed", "Date", "now", "exec", "apply", "clear", "setTimeout", "chat", "throttle", "onVisibilityChanged", "data", "isLiveChatOpen", "isExpanded", "chat_default"] }