{"version":3,"file":"async-module-core-shared-i-dn.d.m.'BvW40hB6'.js","sources":["../../../../../../src/utils/vue/useRef.ts","../../../../../../src/modules/core/components/composables/useKeepAliveComponents.ts","../../../../../../src/modules/core/composables/navigation/useCustomHomepageNavigationItems.ts","../../../../../../src/modules/core/views/ThemeSwitcher/ThemeSwitcher.vue","../../../../../../src/modules/core/components/composables/useInitialRequests.ts","../../../../../../src/modules/core/components/composables/useLayoutScroll.ts","../../../../../../src/modules/core/components/composables/usePostponedContentLoad.ts"],"sourcesContent":["import type { Ref } from 'vue';\nimport { watch } from 'vue';\n\nimport { Deferred } from '@leon-hub/utils';\n\n/**\n * Use a ref to be defined or any other condition.\n */\nexport function useRef(ref: T, condition: (ref: U) => boolean = (value: U) => !!value): Promise {\n if (condition(ref.value)) {\n return Promise.resolve();\n }\n const deferred = new Deferred();\n const stop = watch(\n ref,\n (value) => {\n if (condition(value)) {\n stop();\n deferred.resolve();\n }\n },\n );\n return deferred.promise;\n}\n","import type { Ref } from 'vue';\nimport {\n onBeforeUnmount,\n ref,\n toRef,\n watch,\n} from 'vue';\n\nimport { Timer } from '@leon-hub/utils';\n\nimport {\n useKeepAliveStore,\n} from 'web/src/modules/core/store';\n\nexport interface KeepAliveComponentsComposable {\n keepAliveIncludes: Ref;\n}\n\nexport function useKeepAliveComponents(): KeepAliveComponentsComposable {\n const keepAliveComponents = toRef(useKeepAliveStore(), 'keepAliveComponents');\n\n const keepAliveIncludes = ref('none');\n let timeout = 0;\n\n function clearTimer(): void {\n if (timeout) {\n Timer.clearTimeout(timeout);\n timeout = 0;\n }\n }\n\n function updateKeepAliveComponents(components: string[]): void {\n clearTimer();\n timeout = Timer.setTimeout(() => {\n // LEONWEB-9603 KeepAlive includes prop triggers watch while array value given and clean vnodes cache\n keepAliveIncludes.value = components.length > 0 ? components.join(',') : 'none';\n }, 200);\n }\n\n watch(keepAliveComponents, (newValue: string[]) => {\n updateKeepAliveComponents(newValue);\n }, { immediate: true, deep: true });\n\n onBeforeUnmount(clearTimer);\n\n return {\n keepAliveIncludes,\n };\n}\n","import type { Ref } from 'vue';\nimport {\n computed,\n toRef,\n} from 'vue';\n\nimport type { NavigationItem } from '@leon-hub/navigation-config';\nimport { HomePageType } from '@leon-hub/api-sdk';\nimport { RouteName } from '@leon-hub/routing-config-names';\n\nimport { useCustomerBetTypeStore } from '@core/customer';\nimport { useSiteConfigStore } from '@core/site-config';\n\nexport interface CustomHomepageNavigationItemsComposable {\n filteredNavigationItems: Ref;\n}\n\nexport function useCustomHomepageNavigationItems(\n items: Ref,\n): CustomHomepageNavigationItemsComposable {\n const betTypeStore = useCustomerBetTypeStore();\n const betType = toRef(() => betTypeStore.betType);\n\n const scgStore = useSiteConfigStore();\n const homePageType = toRef(() => scgStore.homePageType);\n\n const filteredNavigationItems = computed(() => {\n if (homePageType.value !== HomePageType.CUSTOM || !betType.value) {\n return items.value;\n }\n\n return items.value.filter((item) => (\n item.routeName !== RouteName.HOME\n ));\n });\n\n return {\n filteredNavigationItems,\n };\n}\n","\n\n\n\n\n","import { useBannersStore } from 'web/src/modules/banners/store';\n\nexport interface UseInitialRequestsComposable {\n getInitRequests(): Promise[];\n}\n\nexport default function useInitialRequests(): UseInitialRequestsComposable {\n const { loadBanners } = useBannersStore();\n\n function getInitRequests(): Promise[] {\n return [\n loadBanners(),\n ];\n }\n\n return {\n getInitRequests,\n };\n}\n","import type { Ref } from 'vue';\nimport {\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n toRef,\n watch,\n} from 'vue';\nimport { useRoute } from 'vue-router';\n\nimport { BusEvent, useBusSafeSubscribe, useEventsBus } from '@leon-hub/event-bus';\nimport { nextAnimationFrame } from '@leon-hub/html-utils';\nimport { useLifecycleResizeObserver } from '@leon-hub/vue-utils';\n\nimport { useRootStore } from '@core/root';\n\nimport {\n useScrollStore,\n} from 'web/src/modules/core/store';\n\nconst disableScrollClassName = 'disable-scroll';\nconst phoneFixedStyleClassName = 'fixed-scroll-styles';\n\nexport interface LayoutScrollComposable {\n mainContent: Ref;\n restoreScrollPosition(): Promise;\n}\n\nexport type ScrollTarget = HTMLElement | Window | null | undefined;\n\nexport default function useLayoutScroll(\n content: Ref,\n): LayoutScrollComposable {\n if (process.env.VUE_APP_RENDERING_SSR) {\n return {\n restoreScrollPosition: () => Promise.resolve(),\n mainContent: toRef(undefined),\n };\n }\n\n const mainContent = ref();\n\n const bus = useEventsBus();\n const { setHasScrollableContent, setScrollTop } = useScrollStore();\n\n let lastScrollTop = 0;\n\n function getContentScrollElement(): Exclude {\n return content.value instanceof Window ? window.document.documentElement : content.value;\n }\n\n function handleScroll(): void {\n const target = getContentScrollElement();\n if (!target) {\n return;\n }\n\n setScrollTop(target.scrollTop);\n\n bus.emit(BusEvent.LAYOUT_CONTENT_SCROLL, {\n scrollTop: target.scrollTop,\n offsetHeight: target.offsetHeight,\n scrollHeight: target.scrollHeight,\n });\n }\n\n function scrollContent(top: number, smooth = false): void {\n try {\n content.value?.scrollTo({\n left: 0,\n top: top === 0 ? -1 : top,\n behavior: smooth ? 'smooth' : 'auto',\n });\n } catch {}\n }\n\n const disabledScrollCounters: Record = {};\n\n function fixPhoneScroll(scrollElement: ScrollTarget): void {\n if (scrollElement && scrollElement instanceof HTMLElement) {\n lastScrollTop = scrollElement.scrollTop;\n scrollElement.classList.add(phoneFixedStyleClassName);\n\n scrollElement.style.top = `-${lastScrollTop}px`;\n }\n }\n\n function releasePhoneScroll(scrollElement: ScrollTarget): void {\n if (scrollElement && scrollElement instanceof HTMLElement) {\n scrollElement.classList.remove(phoneFixedStyleClassName);\n scrollElement.style.removeProperty('top');\n scrollElement.scrollTo(0, lastScrollTop);\n }\n }\n\n function disableScroll({ reason }: { reason: string }): void {\n try {\n if (!disabledScrollCounters[reason]) {\n disabledScrollCounters[reason] = 0;\n }\n\n disabledScrollCounters[reason] += 1;\n\n const contentScroll = getContentScrollElement();\n contentScroll?.classList.add(disableScrollClassName);\n if (process.env.VUE_APP_LAYOUT_PHONE) {\n fixPhoneScroll(contentScroll);\n }\n } catch {}\n }\n\n function enableScroll({ reason }: { reason: string }): void {\n try {\n if (disabledScrollCounters[reason]) {\n disabledScrollCounters[reason] -= 1;\n\n if (disabledScrollCounters[reason] <= 0) {\n delete disabledScrollCounters[reason];\n }\n }\n\n const totalCounter = Object.values(disabledScrollCounters).reduce((accumulator, item) => (\n accumulator + item\n ), 0);\n\n if (!totalCounter) {\n const contentScroll = getContentScrollElement();\n contentScroll?.classList.remove(disableScrollClassName);\n if (process.env.VUE_APP_LAYOUT_PHONE) {\n releasePhoneScroll(contentScroll);\n }\n }\n } catch {}\n }\n\n async function restoreScrollPosition(): Promise {\n const nextTopValue = window.history.state?.scrollTop || 0;\n\n // instant setup scroll position for the same layout\n content.value?.scrollTo({ top: nextTopValue });\n\n if (nextTopValue > 0) {\n await nextTick();\n await nextAnimationFrame();\n // await updating position after change layout\n content.value?.scrollTo({ top: nextTopValue });\n }\n\n if (process.env.VUE_APP_LAYOUT_PHONE) {\n lastScrollTop = nextTopValue;\n }\n }\n\n onMounted(() => {\n content.value?.addEventListener('scroll', handleScroll);\n });\n\n onBeforeUnmount(() => {\n content.value?.removeEventListener('scroll', handleScroll);\n });\n\n useBusSafeSubscribe(BusEvent.LAYOUT_CONTENT_SCROLL_TOP, ({ smooth }) => {\n scrollContent(0, smooth);\n });\n\n useBusSafeSubscribe(BusEvent.LAYOUT_CONTENT_SET_SCROLL, ({ scrollTop, smooth }) => {\n scrollContent(scrollTop, smooth);\n });\n\n useBusSafeSubscribe(BusEvent.SCROLL_TO_ELEMENT_ID, ({ id, inModal, smooth }) => {\n if (inModal) {\n return;\n }\n\n const element = document.getElementById(id);\n if (!element) {\n return;\n }\n\n scrollContent(element.offsetTop, smooth);\n });\n\n useBusSafeSubscribe(BusEvent.LAYOUT_CONTENT_SCROLL_DISABLE, disableScroll);\n useBusSafeSubscribe(BusEvent.LAYOUT_CONTENT_SCROLL_ENABLE, enableScroll);\n\n const isAppMainContentLoaded = toRef(useRootStore(), 'isAppMainContentLoaded');\n const route = useRoute();\n async function updateScrollContent(): Promise {\n await nextTick();\n const target = getContentScrollElement();\n\n if (target) {\n setHasScrollableContent(target.offsetHeight < target.scrollHeight);\n }\n }\n\n watch(() => route.path, updateScrollContent);\n\n watch(isAppMainContentLoaded, updateScrollContent, { immediate: true });\n useLifecycleResizeObserver(mainContent, updateScrollContent);\n\n return {\n mainContent,\n restoreScrollPosition,\n };\n}\n","import type { Ref } from 'vue';\nimport {\n nextTick,\n ref,\n} from 'vue';\n\nimport { nextAnimationFrame } from '@leon-hub/html-utils';\n\nexport interface PostponedContentLoadComposable {\n isMainContentLoaded: Ref;\n loadMainContent(): Promise;\n}\n\nexport function usePostponedContentLoad(): PostponedContentLoadComposable {\n const isMainContentLoaded = ref(false);\n\n async function loadMainContent(): Promise {\n await nextTick();\n await nextAnimationFrame();\n isMainContentLoaded.value = true;\n }\n\n return {\n isMainContentLoaded,\n loadMainContent,\n };\n}\n"],"names":["useRef","ref","condition","value","deferred","Deferred","stop","watch","useKeepAliveComponents","keepAliveComponents","toRef","useKeepAliveStore","keepAliveIncludes","timeout","clearTimer","Timer","updateKeepAliveComponents","components","newValue","onBeforeUnmount","useCustomHomepageNavigationItems","items","betTypeStore","useCustomerBetTypeStore","betType","scgStore","useSiteConfigStore","homePageType","computed","HomePageType","item","RouteName","emit","__emit","isDark","useTheme","useInitialRequests","loadBanners","useBannersStore","getInitRequests","disableScrollClassName","useLayoutScroll","content","mainContent","bus","useEventsBus","setHasScrollableContent","setScrollTop","useScrollStore","getContentScrollElement","handleScroll","target","BusEvent","scrollContent","top","smooth","disabledScrollCounters","disableScroll","reason","enableScroll","accumulator","restoreScrollPosition","nextTopValue","nextTick","nextAnimationFrame","onMounted","useBusSafeSubscribe","scrollTop","id","inModal","element","isAppMainContentLoaded","useRootStore","route","useRoute","updateScrollContent","useLifecycleResizeObserver","usePostponedContentLoad","isMainContentLoaded","loadMainContent"],"mappings":"iqBAQO,SAASA,GAAsCC,EAAQC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