<commit_before>import getState from '../redux/get-state';
import SOURCES from '../layers/overlays.constant';

class ActiveOverlays {
  constructor() {
    this.allOverlays = [];
  }

  getOverlays() {
    return this.allOverlays
      .filter((overlay) => ActiveOverlays.isAuthorised(overlay));
  }

  static isVisibleAtCurrentZoom(overlay, zoomLevel) {
    if (!SOURCES[overlay]) {
      return false;
    }
    const zoom = zoomLevel || getState().map.zoom;
    return zoom >= SOURCES[overlay].minZoom && zoom <= SOURCES[overlay].maxZoom;
  }

  static isAuthorised(overlay) {
    const state = getState();
    const user = state.user;
    const layer = state.mapLayers.find((item) => item.id === overlay.id);
    const authScope = layer && layer.authScope;

    return SOURCES[overlay.id] && layer && (
      !authScope || (user.authenticated && user.scopes.includes(authScope))
    );
  }
<commit_msg>Hotfix sublayers not shown because of check on auth scope<commit_after>import getState from '../redux/get-state';
import SOURCES from '../layers/overlays.constant';

class ActiveOverlays {
  constructor() {
    this.allOverlays = [];
  }

  getOverlays() {
    return this.allOverlays
      .filter((overlay) => ActiveOverlays.isAuthorised(overlay));
  }

  static isVisibleAtCurrentZoom(overlay, zoomLevel) {
    if (!SOURCES[overlay]) {
      return false;
    }
    const zoom = zoomLevel || getState().map.zoom;
    return zoom >= SOURCES[overlay].minZoom && zoom <= SOURCES[overlay].maxZoom;
  }

  static isAuthorised(overlay) {
    const state = getState();
    const user = state.user;
    const layer = state.mapLayers.find((item) => (
      (item.id && item.id === overlay.id) ||
      (!item.id && item.legendItems && item.legendItems.length &&
        item.legendItems.some((legendItem) => (
          legendItem.id === overlay.id
        ))
      )
    ));
    const authScope = layer && layer.authScope;

    return SOURCES[overlay.id] && layer && (
      !authScope || (user.authenticated && user.scopes.includes(authScope))
    );
  }

{'fraction_non_alphanumeric': 0.14640077821011674, 'fraction_numerical': 0.0, 'mean_word_length': 3.180894308943089, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '132733', 'n_tokens_mistral': 672, 'n_tokens_neox': 632, 'n_words': 128}