<commit_before>(function(factory, window) {
  // module loaders support for LeafletJS plugins, see:
  // https://github.com/Leaflet/Leaflet/blob/master/PLUGIN-GUIDE.md#module-loaders

  // AMD module that relies on "leaflet"
  if (typeof define === 'function' && define.amd) {
    define(['leaflet'], factory);

    // Common JS module that relies on "leaflet"
  } else if (typeof exports === 'object') {
    module.exports = factory(require('leaflet'));
  }

  // attach plugin to the global leaflet "L" variable
  if (typeof window !== 'undefined' && window.L) {
    window.L.CanvasFlowmapLayer = factory(L);

    window.L.canvasFlowmapLayer = function(originAndDestinationGeoJsonPoints, opts) {
      return new window.L.CanvasFlowmapLayer(originAndDestinationGeoJsonPoints, opts);
    };
  }
}(function(L) {
  // layer source code
  var canvasRenderer = L.canvas();

  var CanvasFlowmapLayer = L.GeoJSON.extend({
    options: {
      // this is only a default option example,
      // developers will most likely need to provide this
      // options object with values unique to their data
      originAndDestinationFieldIds: {
        originUniqueIdField: 'origin_id',
        originGeometry: {
          x: 'origin_lon',
          y: 'origin_lat'
        },
        destinationUniqueIdField: 'destination_id',
        destinationGeometry: {
          x: 'destination_lon',
          y: 'destination_lat'
        }
      },

      canvasBezierStyle: {
        type: 'simple',
        symbol: {
          // use canvas styling options (compare to CircleMarker styling below)
          strokeStyle: 'rgba(255, 0, 51, 0.8)',
          lineWidth: 0.75,
          lineCap: 'round',
          shadowColor: 'rgb(255, 0, 51)',
          shadowBlur: 1.5
        }
      },

      animatedCanvasBezierStyle: {
        type: 'simple',
        symbol: {
          // use canvas styling options (compare to CircleMarker styling below)
          strokeStyle: 'rgb(255, 46, 88)',
          lineWidth: 1.25,
          lineDashOffsetSize: 4, // custom property used with animation sprite sizes
          lineCap: 'round',
          shadowColor: 'rgb(255, 0, 51)',
          shadowBlur: 2
        }
      },

      // valid values: 'selection' or 'all'
      // use 'all' to display all Bezier paths immediately
      // use 'selection' if Bezier paths will be drawn with user interactions
      pathDisplayMode: 'all',

      wrapAroundCanvas: true,

      animationStarted: false,

      animationEasingFamily: 'Cubic',

      animationEasingType: 'In',

      animationDuration: 2000,

      pointToLayer: function(geoJsonPoint, latlng) {
        return L.circleMarker(latlng);
      },

      style: function(geoJsonFeature) {
        // use leaflet's path styling options

        // since the GeoJSON feature properties are modified by the layer,
        // developers can rely on the "isOrigin" property to set different
        // symbols for origin vs destination CircleMarker stylings

        if (geoJsonFeature.properties.isOrigin) {
          return {
            renderer: canvasRenderer, // recommended to use L.canvas()
            radius: 5,
            weight: 1,
            color: 'rgb(195, 255, 62)',
            fillColor: 'rgba(195, 255, 62, 0.6)',
            fillOpacity: 0.6
          };
        } else {
          return {
            renderer: canvasRenderer,
            radius: 2.5,
            weight: 0.25,
            color: 'rgb(17, 142, 170)',
            fillColor: 'rgb(17, 142, 170)',
            fillOpacity: 0.7
          };
        }
      }
    },

    _customCanvases: [],

    _animationPropertiesStatic: {
      offset: 0,
      resetOffset: 200,
      repeat: Infinity,
      yoyo: false
    },

    _animationPropertiesDynamic: {
      duration: null,
      easingInfo: null
    },

    initialize: function(geoJson, options) {
      // same as L.GeoJSON intialize method, but first performs custom GeoJSON
      // data parsing and reformatting before finally calling L.GeoJSON addData method
      L.setOptions(this, options);

      this._layers = {};

      // beginning of customized initialize method
      if (geoJson && this.options.originAndDestinationFieldIds) {
        this.setOriginAndDestinationGeoJsonPoints(geoJson);
      }

      // establish animation properties using Tween.js library
      // currently requires the developer to add it to their own app index.html
      // TODO: find better way to wrap it up in this layer source code
      if (window.hasOwnProperty('TWEEN')) {
        // set this._animationPropertiesDynamic.duration value
        this.setAnimationDuration(this.options.animationDuration);
        // set this._animationPropertiesDynamic.easingInfo value
        this.setAnimationEasing(this.options.animationEasingFamily, this.options.animationEasingType);

        // initiate the active animation tween
        this._animationTween = new TWEEN.Tween(this._animationPropertiesStatic)
          .to({
            offset: this._animationPropertiesStatic.resetOffset
          }, this._animationPropertiesDynamic.duration)
          .easing(this._animationPropertiesDynamic.easingInfo.tweenEasingFunction)
          .repeat(this._animationPropertiesStatic.repeat)
          .yoyo(this._animationPropertiesStatic.yoyo)
          .start();
      } else {
        // Tween.js lib isn't available,<commit_msg>moved some internal animation properties into initialize method<commit_after>(function(factory, window) {
  // module loaders support for LeafletJS plugins, see:
  // https://github.com/Leaflet/Leaflet/blob/master/PLUGIN-GUIDE.md#module-loaders

  // AMD module that relies on "leaflet"
  if (typeof define === 'function' && define.amd) {
    define(['leaflet'], factory);

    // Common JS module that relies on "leaflet"
  } else if (typeof exports === 'object') {
    module.exports = factory(require('leaflet'));
  }

  // attach plugin to the global leaflet "L" variable
  if (typeof window !== 'undefined' && window.L) {
    window.L.CanvasFlowmapLayer = factory(L);

    window.L.canvasFlowmapLayer = function(originAndDestinationGeoJsonPoints, opts) {
      return new window.L.CanvasFlowmapLayer(originAndDestinationGeoJsonPoints, opts);
    };
  }
}(function(L) {
  // layer source code
  var canvasRenderer = L.canvas();

  var CanvasFlowmapLayer = L.GeoJSON.extend({
    options: {
      // this is only a default option example,
      // developers will most likely need to provide this
      // options object with values unique to their data
      originAndDestinationFieldIds: {
        originUniqueIdField: 'origin_id',
        originGeometry: {
          x: 'origin_lon',
          y: 'origin_lat'
        },
        destinationUniqueIdField: 'destination_id',
        destinationGeometry: {
          x: 'destination_lon',
          y: 'destination_lat'
        }
      },

      canvasBezierStyle: {
        type: 'simple',
        symbol: {
          // use canvas styling options (compare to CircleMarker styling below)
          strokeStyle: 'rgba(255, 0, 51, 0.8)',
          lineWidth: 0.75,
          lineCap: 'round',
          shadowColor: 'rgb(255, 0, 51)',
          shadowBlur: 1.5
        }
      },

      animatedCanvasBezierStyle: {
        type: 'simple',
        symbol: {
          // use canvas styling options (compare to CircleMarker styling below)
          strokeStyle: 'rgb(255, 46, 88)',
          lineWidth: 1.25,
          lineDashOffsetSize: 4, // custom property used with animation sprite sizes
          lineCap: 'round',
          shadowColor: 'rgb(255, 0, 51)',
          shadowBlur: 2
        }
      },

      // valid values: 'selection' or 'all'
      // use 'all' to display all Bezier paths immediately
      // use 'selection' if Bezier paths will be drawn with user interactions
      pathDisplayMode: 'all',

      wrapAroundCanvas: true,

      animationStarted: false,

      animationEasingFamily: 'Cubic',

      animationEasingType: 'In',

      animationDuration: 2000,

      pointToLayer: function(geoJsonPoint, latlng) {
        return L.circleMarker(latlng);
      },

      style: function(geoJsonFeature) {
        // use leaflet's path styling options

        // since the GeoJSON feature properties are modified by the layer,
        // developers can rely on the "isOrigin" property to set different
        // symbols for origin vs destination CircleMarker stylings

        if (geoJsonFeature.properties.isOrigin) {
          return {
            renderer: canvasRenderer, // recommended to use L.canvas()
            radius: 5,
            weight: 1,
            color: 'rgb(195, 255, 62)',
            fillColor: 'rgba(195, 255, 62, 0.6)',
            fillOpacity: 0.6
          };
        } else {
          return {
            renderer: canvasRenderer,
            radius: 2.5,
            weight: 0.25,
            color: 'rgb(17, 142, 170)',
            fillColor: 'rgb(17, 142, 170)',
            fillOpacity: 0.7
          };
        }
      }
    },

    _customCanvases: [],

    initialize: function(geoJson, options) {
      // same as L.GeoJSON intialize method, but first performs custom GeoJSON
      // data parsing and reformatting before finally calling L.GeoJSON addData method
      L.setOptions(this, options);

      this._animationPropertiesStatic = {
        offset: 0,
        resetOffset: 200,
        repeat: Infinity,
        yoyo: false
      };

      this._animationPropertiesDynamic = {
        duration: null,
        easingInfo: null
      };

      this._layers = {};

      // beginning of customized initialize method
      if (geoJson && this.options.originAndDestinationFieldIds) {
        this.setOriginAndDestinationGeoJsonPoints(geoJson);
      }

      // establish animation properties using Tween.js library
      // currently requires the developer to add it to their own app index.html
      // TODO: find better way to wrap it up in this layer source code
      if (window.hasOwnProperty('TWEEN')) {
        // set this._animationPropertiesDynamic.duration value
        this.setAnimationDuration(this.options.animationDuration);
        // set this._animationPropertiesDynamic.easingInfo value
        this.setAnimationEasing(this.options.animationEasingFamily, this.options.animationEasingType);

        // initiate the active animation tween
        this._animationTween = new TWEEN.Tween(this._animationPropertiesStatic)
          .to({
            offset: this._animationPropertiesStatic.resetOffset
          }, this._animationPropertiesDynamic.duration)
          .easing(this._animationPropertiesDynamic.easingInfo.tweenEasingFunction)
          .repeat(this._animationPropertiesStatic.repeat)
          .yoyo(this._animationPropertiesStatic.yoyo)
          .start();
      } else {
        // Tween.js lib isn't available,
{'fraction_non_alphanumeric': 0.09833948339483395, 'fraction_numerical': 0.016605166051660517, 'mean_word_length': 2.285151515151515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2328410', 'n_tokens_mistral': 3111, 'n_tokens_neox': 2884, 'n_words': 810}