<commit_before>/* global PIXI */
/* eslint-disable react/no-danger */
import React, { Component } from 'react';
import classnames from 'classnames';
import AppStyles from 'styles/components/c-app.scss';

const ACCESS_TOKEN_REGEX = /#access_token=([a-zA-Z0-9.\-_]*)(&[a-z=])?/g;

class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      bannerDismissed: false
    };
  }

  componentWillMount() {
    this.props.loadLiterals();
    // TODO move this logic out of a presentational component
    ACCESS_TOKEN_REGEX.lastIndex = 0;
    if (ACCESS_TOKEN_REGEX.test(window.location.hash)) {
      ACCESS_TOKEN_REGEX.lastIndex = 0;
      const parts = ACCESS_TOKEN_REGEX.exec(window.location.hash);
      if (parts && parts.length >= 2) {
        this.props.setToken(parts[1]);
      }
    }
    this.props.getLoggedUser();

    if (!DISABLE_WELCOME_MODAL) this.props.setWelcomeModalUrl();
  }

  componentDidUpdate(nextProps) {
    if (nextProps.welcomeModalUrl !== this.props.welcomeModalUrl && !DISABLE_WELCOME_MODAL) this.getWelcomeModal();
  }

  getWelcomeModal() {
    const storedUrl = localStorage.getItem(WELCOME_MODAL_COOKIE_KEY);
    if (this.props.welcomeModalUrl && storedUrl !== this.props.welcomeModalUrl) {
      localStorage.setItem(WELCOME_MODAL_COOKIE_KEY, this.props.welcomeModalUrl);
      this.props.setWelcomeModalContent();
    }
  }

  dismissBanner() {
    this.setState({
      bannerDismissed: true
    });
  }

  render() {
    const isWebGLSupported = PIXI.utils.isWebGLSupported();
    const showBanner =
      (isWebGLSupported === false || (SHOW_BANNER === true && this.props.banner !== undefined))
      && this.state.bannerDismissed === false
      && window.innerWidth > 768;
    const bannerContent = (SHOW_BANNER === true) ? (<span
      dangerouslySetInnerHTML={{ __html: this.props.banner }}
    />) : (<span>
      ⚠️ There is a problem with your current configuration (WebGL is disabled or unavailable).
      The map will be shown with degraded performance.
    </span>);
<commit_msg>do not show banner in  embedded mode<commit_after>/* global PIXI */
/* eslint-disable react/no-danger */
import React, { Component } from 'react';
import classnames from 'classnames';
import AppStyles from 'styles/components/c-app.scss';
import { getURLParameterByName } from 'lib/getURLParameterByName';

const ACCESS_TOKEN_REGEX = /#access_token=([a-zA-Z0-9.\-_]*)(&[a-z=])?/g;

class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
      bannerDismissed: false
    };
  }

  componentWillMount() {
    this.props.loadLiterals();
    // TODO move this logic out of a presentational component
    ACCESS_TOKEN_REGEX.lastIndex = 0;
    if (ACCESS_TOKEN_REGEX.test(window.location.hash)) {
      ACCESS_TOKEN_REGEX.lastIndex = 0;
      const parts = ACCESS_TOKEN_REGEX.exec(window.location.hash);
      if (parts && parts.length >= 2) {
        this.props.setToken(parts[1]);
      }
    }
    this.props.getLoggedUser();

    if (!DISABLE_WELCOME_MODAL) this.props.setWelcomeModalUrl();
  }

  componentDidUpdate(nextProps) {
    if (nextProps.welcomeModalUrl !== this.props.welcomeModalUrl && !DISABLE_WELCOME_MODAL) this.getWelcomeModal();
  }

  getWelcomeModal() {
    const storedUrl = localStorage.getItem(WELCOME_MODAL_COOKIE_KEY);
    if (this.props.welcomeModalUrl && storedUrl !== this.props.welcomeModalUrl) {
      localStorage.setItem(WELCOME_MODAL_COOKIE_KEY, this.props.welcomeModalUrl);
      this.props.setWelcomeModalContent();
    }
  }

  dismissBanner() {
    this.setState({
      bannerDismissed: true
    });
  }

  render() {
    const isWebGLSupported = PIXI.utils.isWebGLSupported();
    const showBanner =
      (isWebGLSupported === false || (SHOW_BANNER === true && this.props.banner !== undefined))
      && this.state.bannerDismissed === false
      && window.innerWidth > 768
      && getURLParameterByName('embedded') !== 'true';
    const bannerContent = (SHOW_BANNER === true) ? (<span
      dangerouslySetInnerHTML={{ __html: this.props.banner }}
    />) : (<span>
      ⚠️ There is a problem with your current configuration (WebGL is disabled or unavailable).
      The map will be shown with degraded performance.
    </span>);

{'fraction_non_alphanumeric': 0.13109756097560976, 'fraction_numerical': 0.004221388367729831, 'mean_word_length': 3.5227995758218453, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069518', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1404, 'n_words': 268}