<commit_before>/* global google, customDistribution */
import mapStyles from './mapStyles.json';

import * as polygonStyles from './polygonStyles.json';

import * as panel from './customInfoPanel';

import drawPolygon from './drawPolygon';

import apiSources from '../apiSources.json';

import { gradientSteps } from '../helpers';

let map;

export default function initMap() {
	const mapElement = document.getElementById('map');

	if (mapElement === null) {
		return false;
	}

	map = new google.maps.Map(mapElement, {
		center: { lat: -23.55, lng: -46.633333 },
		zoom: 10,
		styles: mapStyles,
		mapTypeControl: false,
		streetViewControl: false,
		fullscreenControlOptions: {
			position: google.maps.ControlPosition.TOP_LEFT,
		},
	});

	function getArrayBounds(polyArray) {
		const bounds = new google.maps.LatLngBounds();
		let path;
		let paths;

		for (let polys = 0; polys < polyArray.length; polys += 1) {
			paths = polyArray[polys].getPaths();
			for (let l = 0; l < paths.getLength(); l += 1) {
				path = paths.getAt(l);

				for (let ii = 0; ii < path.getLength(); ii += 1) {
					bounds.extend(path.getAt(ii));
				}
			}
		}
		return bounds;
	}

	if (mapElement.hasAttribute('data-to-draw')) {
		const toDraw = mapElement.getAttribute('data-to-draw').split(' ');

		const polygonsBounds = apiSources
			.filter(endPoint => toDraw.indexOf(endPoint.jsonRootElement) !== -1)
			.map((endPointData) => {
				const rootElement = endPointData.jsonRootElement;

				const myHeaders = new Headers();

				myHeaders.append('Content-Type', 'application/json');

				const myInit = {
					method: 'GET',
					headers: myHeaders,
					mode: 'cors',
					cache: 'default',
				};

				let panelTemplate = null;

				if (mapElement.hasAttribute('data-info-panel-for')) {
					const infoPanelFor = mapElement.getAttribute('data-info-panel-for').split(' ');
					if (infoPanelFor.indexOf(rootElement) !== -1) {
						panelTemplate = mapElement.hasAttribute(`data-info-panel-for-${rootElement}`)
							? document.getElementById(mapElement.getAttribute(`data-info-panel-for-${rootElement}`))
							: document.getElementById(`info-panel__${rootElement}`) || null;
					}
				}

				let previousSegments = null;

				if (mapElement.hasAttribute('data-link-for')) {
					const linkFor = mapElement.getAttribute('data-link-for').split(' ');
					if (linkFor.indexOf(rootElement) !== -1) {
						if (endPointData.contentFolder != null) {
							previousSegments = `${endPointData.contentFolder.replace('./content', '')}`;
						}
					}
				}

				const myRequest = new Request(endPointData.dataDest.replace('./static', ''));

				return fetch(myRequest, myInit)
					.then((response) => {
						const contentType = response.headers.get('content-type');

						if (contentType && contentType.includes('application/json')) {
							return response.json();
						}

						throw new TypeError("Oops, we haven't got JSON!");
					})
					.then((areasList) => {
						let polygonsToDraw = areasList[rootElement];

						if (mapElement.hasAttribute(`data-${rootElement}-to-draw`)) {
							const areasToDraw = mapElement.getAttribute(`data-${rootElement}-to-draw`).split(' ')
								.map(item => parseInt(item, 10));
							polygonsToDraw = polygonsToDraw.filter(x => areasToDraw.indexOf(x.id) !== -1);
						}

						let fills;
<commit_msg>Define `fills` variable type<commit_after>/* global google, customDistribution */
import mapStyles from './mapStyles.json';

import * as polygonStyles from './polygonStyles.json';

import * as panel from './customInfoPanel';

import drawPolygon from './drawPolygon';

import apiSources from '../apiSources.json';

import { gradientSteps } from '../helpers';

let map;

export default function initMap() {
	const mapElement = document.getElementById('map');

	if (mapElement === null) {
		return false;
	}

	map = new google.maps.Map(mapElement, {
		center: { lat: -23.55, lng: -46.633333 },
		zoom: 10,
		styles: mapStyles,
		mapTypeControl: false,
		streetViewControl: false,
		fullscreenControlOptions: {
			position: google.maps.ControlPosition.TOP_LEFT,
		},
	});

	function getArrayBounds(polyArray) {
		const bounds = new google.maps.LatLngBounds();
		let path;
		let paths;

		for (let polys = 0; polys < polyArray.length; polys += 1) {
			paths = polyArray[polys].getPaths();
			for (let l = 0; l < paths.getLength(); l += 1) {
				path = paths.getAt(l);

				for (let ii = 0; ii < path.getLength(); ii += 1) {
					bounds.extend(path.getAt(ii));
				}
			}
		}
		return bounds;
	}

	if (mapElement.hasAttribute('data-to-draw')) {
		const toDraw = mapElement.getAttribute('data-to-draw').split(' ');

		const polygonsBounds = apiSources
			.filter(endPoint => toDraw.indexOf(endPoint.jsonRootElement) !== -1)
			.map((endPointData) => {
				const rootElement = endPointData.jsonRootElement;

				const myHeaders = new Headers();

				myHeaders.append('Content-Type', 'application/json');

				const myInit = {
					method: 'GET',
					headers: myHeaders,
					mode: 'cors',
					cache: 'default',
				};

				let panelTemplate = null;

				if (mapElement.hasAttribute('data-info-panel-for')) {
					const infoPanelFor = mapElement.getAttribute('data-info-panel-for').split(' ');
					if (infoPanelFor.indexOf(rootElement) !== -1) {
						panelTemplate = mapElement.hasAttribute(`data-info-panel-for-${rootElement}`)
							? document.getElementById(mapElement.getAttribute(`data-info-panel-for-${rootElement}`))
							: document.getElementById(`info-panel__${rootElement}`) || null;
					}
				}

				let previousSegments = null;

				if (mapElement.hasAttribute('data-link-for')) {
					const linkFor = mapElement.getAttribute('data-link-for').split(' ');
					if (linkFor.indexOf(rootElement) !== -1) {
						if (endPointData.contentFolder != null) {
							previousSegments = `${endPointData.contentFolder.replace('./content', '')}`;
						}
					}
				}

				const myRequest = new Request(endPointData.dataDest.replace('./static', ''));

				return fetch(myRequest, myInit)
					.then((response) => {
						const contentType = response.headers.get('content-type');

						if (contentType && contentType.includes('application/json')) {
							return response.json();
						}

						throw new TypeError("Oops, we haven't got JSON!");
					})
					.then((areasList) => {
						let polygonsToDraw = areasList[rootElement];

						if (mapElement.hasAttribute(`data-${rootElement}-to-draw`)) {
							const areasToDraw = mapElement.getAttribute(`data-${rootElement}-to-draw`).split(' ')
								.map(item => parseInt(item, 10));
							polygonsToDraw = polygonsToDraw.filter(x => areasToDraw.indexOf(x.id) !== -1);
						}

						let fills = [];

{'fraction_non_alphanumeric': 0.15809153454980557, 'fraction_numerical': 0.007777445408315884, 'mean_word_length': 3.4051383399209487, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '2108084', 'n_tokens_mistral': 2609, 'n_tokens_neox': 2088, 'n_words': 419}