{"version":3,"file":"BackToTop-G-3Z9b1g.js","sources":["../../src/assets/svgs/IconChevron.svg?component","../../src/components/common/BackToTop.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = {\n  xmlns: \"http://www.w3.org/2000/svg\",\n  width: \"20\",\n  height: \"13\",\n  fill: \"none\"\n}\n\nexport function render(_ctx, _cache) {\n  return (_openBlock(), _createElementBlock(\"svg\", _hoisted_1, _cache[0] || (_cache[0] = [\n    _createElementVNode(\"path\", {\n      fill: \"#fff\",\n      d: \"m2.56 12.581 7.471-7.454 7.471 7.454 2.295-2.295L10.03.521.266 10.286l2.295 2.295Z\"\n    }, null, -1)\n  ])))\n}\nexport default { render: render }","<template>\n  <button\n    id=\"back-to-top\"\n    aria-label=\"Back to Top\"\n    :class=\"[\n      $style.back,\n      { [$style.active]: scrolled },\n      { [$style.dark]: overFooter },\n      { [$style.audioPlayerOpen]: tracks.length },\n    ]\"\n    :ga4-event=\"\n      JSON.stringify({\n        click_type: 'back_link',\n        component: 'BackToTop',\n        content_group: `${parent}`,\n        gtm_tag: 'interaction',\n        link_text: 'Top',\n      })\n    \"\n    tabindex=\"1\"\n    type=\"button\"\n    @click.prevent=\"toTop\"\n  >\n    <IconChevron></IconChevron>\n    Top\n  </button>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { nextTick, onBeforeUnmount, onMounted, ref } from 'vue';\nimport { storeToRefs } from 'pinia';\nimport IconChevron from '@/assets/svgs/IconChevron.svg?component';\nimport { useA11y } from '@/composables/Common.js';\nimport { useAudioStore } from '@/stores/audioStore';\nimport { useMainStore } from '@/stores/mainStore';\nimport { useRoute } from 'vue-router';\n\nconst audioStore = useAudioStore();\nconst { focusSkip } = useA11y();\nconst route = useRoute();\nconst store = useMainStore();\nconst { tracks } = storeToRefs(audioStore);\n\nconst overFooter = ref(false);\nconst scrolled = ref(false);\n\nconst parent = computed(() => {\n  return route.matched[route.matched.length - 1].name;\n});\n\nonMounted(() => {\n  nextTick(() => {\n    document.addEventListener('scroll', onScroll);\n  });\n});\n\nonBeforeUnmount(() => {\n  document.removeEventListener('scroll', onScroll);\n});\n\nfunction handleIntersection(entries) {\n  entries.forEach((entry) => {\n    if (entry.isIntersecting) {\n      overFooter.value = true;\n    }\n\n    if (!entry.isIntersecting) {\n      overFooter.value = false;\n    }\n  });\n}\n\nfunction onScroll() {\n  const clearance = document.body.scrollTop > 20 || document.documentElement.scrollTop > 20;\n\n  if (clearance) {\n    // 20px clearance at top until trigger of \"Top\" button\n    scrolled.value = true;\n  }\n\n  if (!clearance) {\n    scrolled.value = false;\n  }\n\n  const footer = document.querySelector('#gugg-footer');\n  const observer = new IntersectionObserver(handleIntersection);\n\n  if (footer) {\n    observer.observe(footer);\n  }\n}\n\nfunction toTop() {\n  document.documentElement.scrollTop = 0;\n\n  if (store.isKeyboardUser) {\n    focusSkip();\n  }\n}\n</script>\n\n<style lang=\"scss\" module>\n[type=button].back {\n  @include info;\n\n  & {\n    background-color: $black;\n    border-radius: 50%;\n    bottom: 1rem;\n    color: $white;\n    cursor: pointer;\n    display: none;\n    height: 50px;\n    line-height: 1rem;\n    margin: 0;\n    padding: px-to-rem(6.25);\n    position: fixed;\n    right: 1rem;\n    width: 50px;\n    z-index: get-zindex(back);\n  }\n\n  svg {\n    display: block;\n    margin: 0 auto;\n  }\n\n  &.active {\n    display: block;\n  }\n\n  &.audio-player-open {\n    bottom: 4rem;\n  }\n\n  &:hover {\n    text-decoration: underline;\n  }\n\n  &:active,\n  &:focus {\n    outline-color: $black;\n\n    svg {\n      path {\n        color: $white;\n      }\n    }\n  }\n}\n</style>\n"],"names":["_hoisted_1","render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","IconChevron","audioStore","useAudioStore","focusSkip","useA11y","route","useRoute","store","useMainStore","tracks","storeToRefs","overFooter","ref","scrolled","parent","computed","onMounted","nextTick","onScroll","onBeforeUnmount","handleInt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