<commit_before><template>
  <div :id="container">
    <slot></slot>
  </div>
</template>

<script>
  import M from 'mapbox-gl';
  import bus from '../messageBus';

  import events from '../lib/events';
  import props from '../lib/options';


  export default {
    props,

    data() {
      return {
        initial: true,
        map: undefined,
        mapOptions: {
          minZoom:          this.initMinZoom,
          maxZoom:          this.initMaxZoom,
          maxBounds:        this.initMaxBounds,
          mapStyle:         this.initMapStyle,
          center:           this.initCenter,
          zoom:             this.initZoom,
          bearing:          this.initBearing,
          pitch:            this.initPitch,
          collisionBoxes:   this.initCollisionBoxes,
          titleBoundaries:  this.initTileBoundaries,
          repaint:          this.initRepaint,
          light:            this.initLight
        }
      };
    },

    computed: {
      loaded() { return this.map.loaded(); },
      version() { return this.map.version; },
      bounds() { return this.map.getBounds(); },
      isStyleLoaded() { return this.map.isStyleLoaded(); },
      areTilesLoaded() { return this.map.areTilesLoaded(); },
      isMoving() { return this.map.isMoving(); },
      canvas() { return this.map.getCanvas() },
      canvasContainer() { return this.map.getCanvasContainer(); }
    },

    watch: {
      initMaxBounds(bounds) {
        if (this.initial) return;
        this.map.setMaxBounds(bounds);
        this.mapOptions.maxBounds = bounds;
      },
      initMinZoom(zoom) {
        if (this.initial) return;
        this.map.setMinZoom(zoom);
        this.mapOptions.minZoom = zoom;
      },
      initMaxZoom(zoom) {
        if (this.initial) return;
        this.map.setMaxZoom(zoom);
        this.mapOptions.maxZoom = zoom;
      },
      initMapStyle(style) {
        if (this.initial) return;
        this.map.setStyle(style);
        this.mapOptions.mapStyle = style;
      },
      initCollisionBoxes(val) {
        if (this.initial) return;
        this.map.showCollisionBoxes = val;
        this.mapOptions.showCollisionBoxes = val;
      },
      initTileBoundaries(val) {
        if (this.initial) return;
        this.map.showTileBoundaries = val;
        this.mapOptions.showTileBoundaries = val;
      },
      initRepaint(val) {
        if (this.initial) return;
        this.map.repaint = val;
        this.mapOptions.repaint = val;
      },
      initZoom(val) {
        if (this.initial) return;
        this.map.setZoom(val);
        this.mapOptions.zoom = val;
      },
      initCenter(val) {
        if (this.initial) return;
        this.map.setCenter(val);
        this.mapOptions.center = val;
      },
      initBearing(val) {
        if (this.initial) return;
        this.map.setBearing(val);
        this.mapOptions.bearing = val
      },
      initPitch(val) {
        if (this.initial) return;
        this.map.setPitch(val);
        this.mapOptions.pitch = val
      },
      initLight(val) {
        if (this.initial) return;
        this.map.setLight(val);
        this.mapOptions.light = val;
      }
    },

    mounted() {
      this._loadMap().then(map => {
        this.map = map;
        if (this.RTLTextPluginUrl !== undefined) {
          map.setRTLTextPlugin(this.RTLTextPluginUrl, this._RTLTextPluginError);
        }
        this.$emit('mgl-load', map);
        bus.$emit('mgl-load', map);
        this._bindEvents(this.eventsToListen);
        this.initial = false;
        console.log(this);
      });
    },

    beforeDestroy() {
      if (this.map) this.map.remove();
    },

    methods: {
      // We wait in promise to ensure map is loaded and other components will receive map object
      _loadMap() {
        return new Promise((resolve) => {
          if (this.accessToken) M.accessToken = this.accessToken;
          let map = new M.Map({
            ...this._props,
            ...this.mapOptions,
            style: this.initMapStyle
          });
          map.on('load', () => resolve(map));
        });
      },

      _RTLTextPluginError(error) {
        this.$emit('mgl-rtl-plugin-error', { map: this.map, error: error });
      },

      _bindEvents(events) {<commit_msg>Little cleanup<commit_after><template>
  <div :id="container">
    <slot></slot>
  </div>
</template>

<script>
  import M from 'mapbox-gl';
  import bus from '../messageBus';

  import events from '../lib/events';
  import props from '../lib/options';


  export default {
    props,

    data() {
      return {
        initial: true,
        map: undefined,
        mapOptions: {
          minZoom:          this.initMinZoom,
          maxZoom:          this.initMaxZoom,
          maxBounds:        this.initMaxBounds,
          mapStyle:         this.initMapStyle,
          center:           this.initCenter,
          zoom:             this.initZoom,
          bearing:          this.initBearing,
          pitch:            this.initPitch,
          collisionBoxes:   this.initCollisionBoxes,
          titleBoundaries:  this.initTileBoundaries,
          repaint:          this.initRepaint,
          light:            this.initLight
        }
      };
    },

    computed: {
      loaded() { return this.map.loaded(); },
      version() { return this.map.version; },
      bounds() { return this.map.getBounds(); },
      isStyleLoaded() { return this.map.isStyleLoaded(); },
      areTilesLoaded() { return this.map.areTilesLoaded(); },
      isMoving() { return this.map.isMoving(); },
      canvas() { return this.map.getCanvas() },
      canvasContainer() { return this.map.getCanvasContainer(); }
    },

    watch: {
      initMaxBounds(bounds) {
        if (this.initial) return;
        this.map.setMaxBounds(bounds);
        this.mapOptions.maxBounds = bounds;
      },
      initMinZoom(zoom) {
        if (this.initial) return;
        this.map.setMinZoom(zoom);
        this.mapOptions.minZoom = zoom;
      },
      initMaxZoom(zoom) {
        if (this.initial) return;
        this.map.setMaxZoom(zoom);
        this.mapOptions.maxZoom = zoom;
      },
      initMapStyle(style) {
        if (this.initial) return;
        this.map.setStyle(style);
        this.mapOptions.mapStyle = style;
      },
      initCollisionBoxes(val) {
        if (this.initial) return;
        this.map.showCollisionBoxes = val;
        this.mapOptions.showCollisionBoxes = val;
      },
      initTileBoundaries(val) {
        if (this.initial) return;
        this.map.showTileBoundaries = val;
        this.mapOptions.showTileBoundaries = val;
      },
      initRepaint(val) {
        if (this.initial) return;
        this.map.repaint = val;
        this.mapOptions.repaint = val;
      },
      initZoom(val) {
        if (this.initial) return;
        this.map.setZoom(val);
        this.mapOptions.zoom = val;
      },
      initCenter(val) {
        if (this.initial) return;
        this.map.setCenter(val);
        this.mapOptions.center = val;
      },
      initBearing(val) {
        if (this.initial) return;
        this.map.setBearing(val);
        this.mapOptions.bearing = val
      },
      initPitch(val) {
        if (this.initial) return;
        this.map.setPitch(val);
        this.mapOptions.pitch = val
      },
      initLight(val) {
        if (this.initial) return;
        this.map.setLight(val);
        this.mapOptions.light = val;
      }
    },

    mounted() {
      this._loadMap().then(map => {
        this.map = map;
        if (this.RTLTextPluginUrl !== undefined) {
          map.setRTLTextPlugin(this.RTLTextPluginUrl, this._RTLTextPluginError);
        }
        this.$emit('mgl-load', map);
        bus.$emit('mgl-load', map);
        this._bindEvents(this.eventsToListen);
        this.initial = false;
      });
    },

    beforeDestroy() {
      if (this.map) this.map.remove();
    },

    methods: {
      // We wait in promise to ensure map is loaded and other components will receive map object
      _loadMap() {
        return new Promise((resolve) => {
          if (this.accessToken) M.accessToken = this.accessToken;
          let map = new M.Map({
            ...this._props,
            ...this.mapOptions,
            style: this.initMapStyle
          });
          map.on('load', () => resolve(map));
        });
      },

      _RTLTextPluginError(error) {
        this.$emit('mgl-rtl-plugin-error', { map: this.map, error: error });
      },

      _bindEvents(events) {
{'fraction_non_alphanumeric': 0.1295556078062544, 'fraction_numerical': 0.0, 'mean_word_length': 1.8113020489094513, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '2099224', 'n_tokens_mistral': 2567, 'n_tokens_neox': 2537, 'n_words': 466}