<template>
  <div id="app">

    <div class="env-watermark" v-if="env && env === 'UAT'">
      {{ env }}
    </div>

    <transition name="el-fade-in-linear">
      <router-view />
    </transition>
    <service-worker-update-popup />
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import ServiceWorkerUpdatePopup from "./pwa/components/ServiceWorkerUpdatePopup.vue";
import { env } from "./services/global";


@Component({
  name: "App",
  components: {
    ServiceWorkerUpdatePopup,

  },
})
export default class extends Vue {
  env = env();

  created() {
    window.addEventListener("scroll", this.handleScroll);
  }

  mounted() {
    const recaptcha = this.$recaptchaInstance;
    if (recaptcha) {
      recaptcha.hideBadge();
    }
  }

  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  }

  handleScroll() {
    this.$store.dispatch("page/setCurrentScrollY", window.scrollY);
  }
}
</script>
