<commit_before>var mapbox = require("./mapbox-common");
var fs = require("file-system");
var imgSrc = require("image-source");
var utils = require("utils/utils");
var http = require("http");

mapbox._markers = [];
mapbox._markerIconDownloadCache = [];

(function() {
  // need to kick this off otherwise offline stuff won't work without first showing a map
  MGLOfflineStorage.sharedOfflineStorage();
})();


/*************** XML definition START ****************/
var Mapbox = (function (_super) {
	global.__extends(Mapbox, _super);

	function Mapbox() {
    _super.call(this);
    this.config = {};
	}

	Mapbox.prototype.onLoaded = function () {
    _super.prototype.onLoaded.call(this);
  };

	Object.defineProperty(Mapbox.prototype, "ios", {
    get: function () {
      if (!this._ios) {
        this._ios = UIView.new();
      }
      if (!this.mapView && this.config.accessToken) {
        var settings = mapbox.merge(this.config, mapbox.defaults);

        MGLAccountManager.setAccessToken(settings.accessToken);

        var that = this;

        var drawMap = function() {
          that.mapView = MGLMapView.alloc().initWithFrameStyleURL(CGRectMake(0, 0, that._ios.frame.size.width, that._ios.frame.size.height), mapbox._getMapStyle(settings.style));
          that.mapView.delegate = that._delegate = MGLMapViewDelegateImpl.new().initWithCallback(function() {});
          mapbox._setMapboxMapOptions(that.mapView, settings);
          that._ios.addSubview(that.mapView);
          that.notifyMapReady();
        };

        setTimeout(drawMap, settings.delay);
      }
      return this._ios;
    },
    enumerable: true,
    configurable: true
	});

	Object.defineProperty(Mapbox.prototype, "native", {
    get: function () {
      return this.mapView;
    },
    enumerable: true,
    configurable: true
	});

	return Mapbox;
}(mapbox.Mapbox));
mapbox.Mapbox = Mapbox;
/*************** XML definition END ****************/


mapbox._setMapboxMapOptions = function (mapView, settings) {
  mapView.logoView.hidden = settings.hideLogo;
  mapView.attributionButton.hidden = settings.hideAttribution;
  mapView.showsUserLocation = settings.showUserLocation;
  mapView.compassView.hidden = settings.hideCompass;
  mapView.rotateEnabled = !settings.disableRotation;
  mapView.scrollEnabled = !settings.disableScroll;
  mapView.zoomEnabled = !settings.disableZoom;
  mapView.allowsTilting = !settings.disableTilt;

  if (settings.center && settings.center.lat && settings.center.lng) {
    var centerCoordinate = CLLocationCoordinate2DMake(settings.center.lat, settings.center.lng);
    mapView.setCenterCoordinateZoomLevelAnimated(centerCoordinate, settings.zoomLevel, false);
  } else {
    mapView.setZoomLevelAnimated(settings.zoomLevel, false);
  }

  // TODO not sure this works as planned.. perhaps better to listen for rotate events ([..didrotate..] and fix the frame
  mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
};

mapbox._getMapStyle = function(input) {
  var version = 9;

  // allow for a style URL to be passed
  if (/^mapbox:\/\/styles/.test(input)) {
    return input;
  }
  if (input === mapbox.MapStyle.LIGHT) {<commit_msg>Convert custom url string to NSURL #69<commit_after>var mapbox = require("./mapbox-common");
var fs = require("file-system");
var imgSrc = require("image-source");
var utils = require("utils/utils");
var http = require("http");

mapbox._markers = [];
mapbox._markerIconDownloadCache = [];

(function() {
  // need to kick this off otherwise offline stuff won't work without first showing a map
  MGLOfflineStorage.sharedOfflineStorage();
})();


/*************** XML definition START ****************/
var Mapbox = (function (_super) {
	global.__extends(Mapbox, _super);

	function Mapbox() {
    _super.call(this);
    this.config = {};
	}

	Mapbox.prototype.onLoaded = function () {
    _super.prototype.onLoaded.call(this);
  };

	Object.defineProperty(Mapbox.prototype, "ios", {
    get: function () {
      if (!this._ios) {
        this._ios = UIView.new();
      }
      if (!this.mapView && this.config.accessToken) {
        var settings = mapbox.merge(this.config, mapbox.defaults);

        MGLAccountManager.setAccessToken(settings.accessToken);

        var that = this;

        var drawMap = function() {
          that.mapView = MGLMapView.alloc().initWithFrameStyleURL(CGRectMake(0, 0, that._ios.frame.size.width, that._ios.frame.size.height), mapbox._getMapStyle(settings.style));
          that.mapView.delegate = that._delegate = MGLMapViewDelegateImpl.new().initWithCallback(function() {});
          mapbox._setMapboxMapOptions(that.mapView, settings);
          that._ios.addSubview(that.mapView);
          that.notifyMapReady();
        };

        setTimeout(drawMap, settings.delay);
      }
      return this._ios;
    },
    enumerable: true,
    configurable: true
	});

	Object.defineProperty(Mapbox.prototype, "native", {
    get: function () {
      return this.mapView;
    },
    enumerable: true,
    configurable: true
	});

	return Mapbox;
}(mapbox.Mapbox));
mapbox.Mapbox = Mapbox;
/*************** XML definition END ****************/


mapbox._setMapboxMapOptions = function (mapView, settings) {
  mapView.logoView.hidden = settings.hideLogo;
  mapView.attributionButton.hidden = settings.hideAttribution;
  mapView.showsUserLocation = settings.showUserLocation;
  mapView.compassView.hidden = settings.hideCompass;
  mapView.rotateEnabled = !settings.disableRotation;
  mapView.scrollEnabled = !settings.disableScroll;
  mapView.zoomEnabled = !settings.disableZoom;
  mapView.allowsTilting = !settings.disableTilt;

  if (settings.center && settings.center.lat && settings.center.lng) {
    var centerCoordinate = CLLocationCoordinate2DMake(settings.center.lat, settings.center.lng);
    mapView.setCenterCoordinateZoomLevelAnimated(centerCoordinate, settings.zoomLevel, false);
  } else {
    mapView.setZoomLevelAnimated(settings.zoomLevel, false);
  }

  // TODO not sure this works as planned.. perhaps better to listen for rotate events ([..didrotate..] and fix the frame
  mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
};

mapbox._getMapStyle = function(input) {
  var version = 9;

  if (/^mapbox:\/\/styles/.test(input)) {
    // allow for a style URL to be passed
    return NSURL.URLWithString(input);
  } else if (input === mapbox.MapStyle.LIGHT) {
{'fraction_non_alphanumeric': 0.1435436366454813, 'fraction_numerical': 0.0015501472639900791, 'mean_word_length': 3.854778028592927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6666300', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1938, 'n_words': 381}