/*!
 * Copyright © 2024 Splunk Inc.
 * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
 * in part without a valid written license from Splunk Inc. is PROHIBITED.
 */
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 57);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

module.exports = require("@splunk/ui-utils/i18n");

/***/ }),
/* 1 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/toConsumableArray");

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VizBehavior = void 0;
var VizBehavior;

(function (VizBehavior) {
  /**
   * Dynamic Options Behavior.
   * This allows visualization options to be powered by data
   *
   * **Example**
   *
   * sparklineValues: ">primary|seriesByIndex(0)"
   * would configure sparklineValues with an array of data points
   * coming from the first series in the primary datasource
   *
   */
  VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
  VizBehavior["EVENTS"] = "events";
  VizBehavior["DOWNSAMPLING"] = "downsampling";
  /**
   * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
   * missing.
   * @type {string}
   */

  VizBehavior["PLACEHOLDER"] = "placeholder";
  VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
  VizBehavior["TRELLIS"] = "trellis";
})(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/schemaUtils");

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _toConsumableArray = __webpack_require__(1);

var _defineProperty = __webpack_require__(7);

var __rest = this && this.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;

var lodash_1 = __webpack_require__(6);

var schemaUtils_1 = __webpack_require__(3);

var VizBehavior_1 = __webpack_require__(2);

var dynamicOptionsDSLType = {
  type: 'string',
  pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
};
/**
 * Helper function to extend an options schema with dynamic options DSL
 * @param optionsSchema a visualization's options schema
 * @returns an updated options schema that additionally allows strings starting with > for each option
 */

function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
  var enhancedOptionsSchema = {};
  Object.keys(optionsSchema).forEach(function (key) {
    var _a = optionsSchema[key],
        title = _a.title,
        description = _a.description,
        readOnly = _a.readOnly,
        writeOnly = _a.writeOnly,
        examples = _a.examples,
        defaultValue = _a.default,
        type = _a.type,
        properties = _a.properties,
        patternProperties = _a.patternProperties,
        remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);

    var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
      title: title
    }), description !== undefined && {
      description: description
    }), readOnly !== undefined && {
      readOnly: readOnly
    }), writeOnly !== undefined && {
      writeOnly: writeOnly
    }), examples !== undefined && {
      examples: examples
    }), defaultValue !== undefined && {
      default: defaultValue
    });

    if (type === 'object') {
      enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
        type: type
      }), properties && {
        properties: enhanceOptionsSchemaWithDynamicOptions(properties)
      });

      if (patternProperties) {
        var enhancedPatternProperties = {};
        Object.keys(patternProperties).forEach(function (opt) {
          enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
        });
        enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
      }
    } else {
      enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
        anyOf: [Object.assign(Object.assign({}, type !== undefined && {
          type: type
        }), remainingSchemaEntry), dynamicOptionsDSLType]
      });
    }
  });
  return enhancedOptionsSchema;
}

exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
/**
 * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
 * this function also collapse all editor panels
 * @param vizConfig a Visualization Config
 * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
 * and containing `open: false` for all editor panels in editorConfig
 */

function enhanceConfig(vizConfig) {
  var enhancedConfig = Object.assign({}, vizConfig);

  if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
    enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
  }

  enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
    return Object.assign(Object.assign({}, config), {
      open: config.open || false
    });
  });
  return enhancedConfig;
}

exports.enhanceConfig = enhanceConfig;
/**
 * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
 * Created for editor unit tests
 * @param vizConfig a Visualization Config
 * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
 */

function uncollapseEditorConfig(vizConfig) {
  var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
  editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
    return Object.assign(Object.assign({}, config), {
      open: true
    });
  });
  return editorPanelUncollapsedConfig;
}

exports.uncollapseEditorConfig = uncollapseEditorConfig;

function isDynamicOption(option) {
  return option && typeof option === 'string' && option.trim().startsWith('>') || false;
}

exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
// this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset

/**
 * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
 * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
 * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
 * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
 *
 * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
 */

function hasCompatibleContexts(vizContext, presetContext) {
  var presetContextKeys = Object.keys(presetContext);
  return presetContextKeys.every(function (contextKey) {
    return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
  });
}
/**
 * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
 */


function hasCompatibleOptions(vizOptions, presetOptions) {
  var presetOptionKeys = Object.keys(presetOptions);
  return presetOptionKeys.every(function (optionKey) {
    return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
  });
}
/**
 * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
 * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
 *
 * @param {Object} vizContext - the current vizContext definition
 * @param {Object} vizOptions - the current vizOptions definition
 * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
 */


function getInitialPreset(vizContext, vizOptions, presets) {
  return presets.find(function (preset) {
    var presetContext = (0, lodash_1.get)(preset, ['value', 'context'], {});
    var presetOptions = (0, lodash_1.get)(preset, ['value', 'options'], {});
    var presetContextKeys = Object.keys(presetContext);
    var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
    // if not, then the preset is invalid in config.ts

    if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
    return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
  });
}

exports.getInitialPreset = getInitialPreset;
/**
 * generates number precision values for a Select editor
 *
 * @param {Number} numPrecisionValues - number of integer precision values to generate
 * @returns {{ label: string; value; string  }[]} array of { label, value } tuples
 */

function generatePrecisionValues(numPrecisionValues) {
  return (0, lodash_1.range)(0, numPrecisionValues + 1).map(function (i) {
    return {
      label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
      value: i
    };
  });
}

exports.generatePrecisionValues = generatePrecisionValues;
/**
 * insert layout in layout array, return a new layout array instead of updating the original
 *
 * @param {EditorLayoutConfig[][]} layout - editor layout
 * @param {Number} index - the index to insert layout item(s)
 * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
 * @returns {EditorLayoutConfig[][]} new editor layout with insertion
 */

var insertLayout = function insertLayout(layout, index) {
  for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
    layoutItems[_key - 2] = arguments[_key];
  }

  return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
};

exports.insertLayout = insertLayout;

/***/ }),
/* 5 */,
/* 6 */
/***/ (function(module, exports) {

module.exports = require("lodash");

/***/ }),
/* 7 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/defineProperty");

/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VizCategory = void 0;
var VizCategory;

(function (VizCategory) {
  VizCategory["SINGLE_VALUE"] = "Single Value";
  VizCategory["TRENDS"] = "Trends";
  VizCategory["COMPARISONS"] = "Comparisons";
  VizCategory["TABLE"] = "Table";
  VizCategory["GAUGE"] = "Gauge";
  VizCategory["DISTRIBUTIONS"] = "Distributions";
  VizCategory["CHOROPLETH"] = "Choropleth Maps";
  VizCategory["SHAPES"] = "Shapes";
  VizCategory["MISC"] = "misc";
  VizCategory["FLOW"] = "Flow";
  VizCategory["CORRELATION"] = "Correlation";
  VizCategory["SPATIAL"] = "Spatial";
})(VizCategory = exports.VizCategory || (exports.VizCategory = {}));

/***/ }),
/* 9 */,
/* 10 */,
/* 11 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-icons/placeholders");

/***/ }),
/* 12 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-icons");

/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var i18n_1 = __webpack_require__(0);

var background = function background(_ref) {
  var label = _ref.label,
      themes = _ref.themes,
      labelPosition = _ref.labelPosition;
  return [{
    label: (0, i18n_1._)(label || 'Background'),
    option: 'backgroundColor',
    editor: 'editor.color',
    editorProps: {
      labelPosition: labelPosition || 'top',
      themes: themes
    }
  }];
};

exports.default = background;

/***/ }),
/* 14 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-color-palettes");

/***/ }),
/* 15 */,
/* 16 */,
/* 17 */,
/* 18 */,
/* 19 */,
/* 20 */,
/* 21 */
/***/ (function(module, exports) {

module.exports = require("@splunk/themes");

/***/ }),
/* 22 */,
/* 23 */,
/* 24 */,
/* 25 */,
/* 26 */,
/* 27 */,
/* 28 */,
/* 29 */,
/* 30 */,
/* 31 */,
/* 32 */,
/* 33 */,
/* 34 */,
/* 35 */,
/* 36 */,
/* 37 */,
/* 38 */,
/* 39 */,
/* 40 */,
/* 41 */,
/* 42 */,
/* 43 */,
/* 44 */,
/* 45 */,
/* 46 */,
/* 47 */,
/* 48 */,
/* 49 */,
/* 50 */,
/* 51 */,
/* 52 */,
/* 53 */,
/* 54 */,
/* 55 */,
/* 56 */,
/* 57 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var visualization_icons_1 = __webpack_require__(12);

var placeholders_1 = __webpack_require__(11);

var schemaUtils_1 = __webpack_require__(3);

var visualization_color_palettes_1 = __webpack_require__(14);

var themes_1 = __webpack_require__(21);

var i18n_1 = __webpack_require__(0);

var VizBehavior_1 = __webpack_require__(2);

var VizCategory_1 = __webpack_require__(8);

var configUtils_1 = __webpack_require__(4);

var MapUtils_1 = __webpack_require__(58);

var BackgroundColor_1 = __webpack_require__(13);

var defaultContext = {
  colorRangeConfig: [{
    to: 20,
    value: '#D41F1F'
  }, {
    from: 20,
    to: 40,
    value: '#D94E17'
  }, {
    from: 40,
    to: 60,
    value: '#CBA700'
  }, {
    from: 60,
    to: 80,
    value: '#669922'
  }, {
    from: 80,
    value: '#118832'
  }]
};
var dataContract = {
  requiredDataSources: [],
  optionalDataSources: [{
    name: 'primary',
    description: 'DataSource that powers the visualization.'
  }],
  initialRequestParams: {
    primary: {
      offset: 0,
      count: 10000
    }
  }
};
var size = {
  initialWidth: 800,
  initialHeight: 600
};
var optionsSchema = {
  backgroundColor: {
    default: '> themes.defaultBackgroundColor',
    description: 'Specify a color for the background. You might use a dataSource to apply the color. The default for enterprise light is "#FFFFFF". The default for enterprise dark is "#000000". The default for prisma dark is "#0B0C0E".',
    pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
    type: 'string'
  },
  baseLayerTileServer: {
    type: 'string',
    description: 'Specify the URL for the set of tiles that make up the base map.'
  },
  baseLayerTileServerType: {
    type: 'string',
    description: 'Specify the type of tile set for the base map.',
    pattern: (0, schemaUtils_1.getPattern)(['vector', 'raster'])
  },
  center: {
    type: 'array',
    description: 'Specify the center of the map in coordinates, in the form of [latitude, longitude]. If you don’t provide coordinates, the map automatically centers, based on available location data. If there is no available location data, the center of the map defaults to [37.7749, -122.4194].',
    items: {
      type: 'number'
    }
  },
  layers: {
    // The option merging of defaults and data binding with editing UI happens with the default defined below.
    // The inner defaults for properties within anyOf objects is used only for code intellisense in UDF to populate options.
    default: [{
      type: MapUtils_1.LAYER_TYPE.Bubble,
      latitude: '> primary | seriesByName("latitude")',
      longitude: '> primary | seriesByName("longitude")',
      seriesColors: visualization_color_palettes_1.VIZ_CATEGORICAL,
      bubbleSize: '> primary | frameWithoutSeriesNames("geobin", "latitude", "longitude") | frameBySeriesTypes("number")',
      additionalTooltipFields: [],
      resultLimit: 1000
    }, {
      type: MapUtils_1.LAYER_TYPE.Marker,
      latitude: '> primary | seriesByName("latitude")',
      longitude: '> primary | seriesByName("longitude")',
      seriesColors: visualization_color_palettes_1.VIZ_CATEGORICAL,
      additionalTooltipFields: [],
      resultLimit: 1000
    }, {
      type: MapUtils_1.LAYER_TYPE.Choropleth,
      areaIds: '> primary | seriesByType("string")',
      areaValues: '> primary | seriesByType("number")',
      dataColors: '> areaValues | gradient()',
      additionalTooltipFields: [],
      resultLimit: 1000,
      choroplethEmptyAreaColor: '> themes.defaultChoroplethEmptyAreaColor',
      choroplethStrokeColor: 'transparent',
      choroplethOpacity: 0.8
    }],
    type: 'array',
    description: 'Specify the optional data visualization layers over the base map. If empty, only the base map appears.',
    items: {
      anyOf: [{
        type: 'object',
        properties: {
          type: {
            description: 'Specify the type of data layer method to display points on the map. For example, “bubble”, “marker”, or "choropleth".',
            type: 'string',
            pattern: (0, schemaUtils_1.getPattern)([MapUtils_1.LAYER_TYPE.Marker, MapUtils_1.LAYER_TYPE.Bubble, MapUtils_1.LAYER_TYPE.Choropleth]),
            default: MapUtils_1.LAYER_TYPE.Marker
          },
          latitude: {
            description: 'Specify a dataSource series to apply latitude coordinates for data points displayed on the map. This applies to layers where type: "bubble" or type: "marker".',
            type: ['string', 'array'],
            items: {
              type: 'number'
            },
            default: '> primary | seriesByName("latitude")'
          },
          longitude: {
            description: 'Specify a dataSource series to apply longitude coordinates for data points displayed on the map. This applies to layers where type: "bubble" or type: "marker".',
            type: ['string', 'array'],
            items: {
              type: 'number'
            },
            default: '> primary | seriesByName("longitude")'
          },
          seriesColors: {
            description: 'Specify the colors to use for data points. If the dataColors option is specified, the seriesColors option is ignored. The seriesColors option applies to layers where type: "bubble" or type: "marker".',
            type: 'array',
            items: {
              type: 'string',
              pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA
            },
            default: visualization_color_palettes_1.VIZ_CATEGORICAL
          },
          dataColors: {
            description: 'Specify the colors to use for data points. You can use an array of colors to be picked from, or you can use a dataSource to apply dynamic coloring. For example, “> primary | seriesByName("status") | matchValue(colorMatchConfig)”. When type: "choropleth", dataColors is defined by default, and the opacities are shown at 80% of maximum to allow textual information to be visible in the map. By default, the dataColors option is not defined for type "bubble" or "marker". If type: "bubble", dataColors requires bubbleSize to have only a single series configured.',
            type: ['string', 'array'],
            items: {
              type: 'string'
            }
          },
          additionalTooltipFields: {
            description: 'Specify the fields to add to the default set of tooltips. Tooltips appear when you hover over data points. These fields and their corresponding values are shown in addition to the ones displayed by default.',
            type: 'array',
            items: {
              type: 'string'
            },
            default: []
          },
          resultLimit: {
            description: 'Specify the maximum number of data points to render on the map. Adjust the value to improve performance.',
            type: 'number',
            default: 1000
          }
        }
      }, {
        type: 'object',
        properties: {
          type: {
            description: 'Specify the type of data layer method to display points on the map. For example, “bubble”, “marker”, or "choropleth".',
            type: 'string',
            pattern: (0, schemaUtils_1.getPattern)([MapUtils_1.LAYER_TYPE.Marker, MapUtils_1.LAYER_TYPE.Bubble, MapUtils_1.LAYER_TYPE.Choropleth]),
            default: MapUtils_1.LAYER_TYPE.Choropleth
          },
          areaIds: {
            description: 'Specify a dataSource series to identify each area in the choropleth map layer. This applies to layers where type: "choropleth".',
            type: 'array',
            items: {
              type: 'string'
            },
            default: '> primary | seriesByType("string")'
          },
          areaValues: {
            description: 'Specify a dataSource series that indicates the values for the choropleth map areas. This applies to layers where type: "choropleth".',
            type: 'array',
            items: {
              type: 'number'
            },
            default: '> primary | seriesByType("number")'
          },
          dataColors: {
            description: 'Specify the colors to use for data points. You can use an array of colors to be picked from, or you can use a dataSource to apply dynamic coloring. For example, “> primary | seriesByName("status") | matchValue(colorMatchConfig)”. When type: "choropleth", dataColors is defined by default. By default, the dataColors option is not defined for type "bubble" or "marker".',
            type: ['string', 'array'],
            items: {
              type: 'string'
            },
            default: '> areaValues | gradient()'
          },
          additionalTooltipFields: {
            description: 'Specify the fields to add to the default set of tooltips. Tooltips appear when you hover over data points. These fields and their corresponding values are shown in addition to the ones displayed by default.',
            type: 'array',
            items: {
              type: 'string'
            },
            default: []
          },
          resultLimit: {
            description: 'Specify the maximum number of data points to render on the map. Adjust the value to improve performance.',
            type: 'number',
            default: 1000
          },
          source: {
            description: 'Source for the geodata for choropleth layer: "us" or "world", and will override data specified in the SPL geom command.',
            pattern: (0, schemaUtils_1.getPattern)(['geo://default/us', 'geo://default/world']),
            type: 'string'
          },
          choroplethEmptyAreaColor: {
            description: 'Specify the color used for empty choropleth areas when "type": "choropleth", and will only work when "source" option is correctly configured.',
            pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
            type: 'string',
            default: '> themes.defaultChoroplethEmptyAreaColor'
          },
          choroplethStrokeColor: {
            description: 'Specify the stroke color for choropleth area outlines. The hex value format should be "#FFFFFF".',
            pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
            type: 'string',
            default: 'transparent'
          },
          choroplethOpacity: {
            description: 'Specify the opacity of choropleth areas. Choose a number in the range of 0 - 1 (inclusive). You can also express the value as a percentage. For example, "0.8" in code or "80%" in UI.',
            type: 'number',
            default: 0.8
          }
        }
      }, {
        type: 'object',
        properties: {
          type: {
            description: 'Specify the type of data layer method to display points on the map. For example, “bubble”, “marker”, or "choropleth".',
            type: 'string',
            pattern: (0, schemaUtils_1.getPattern)([MapUtils_1.LAYER_TYPE.Marker, MapUtils_1.LAYER_TYPE.Bubble, MapUtils_1.LAYER_TYPE.Choropleth]),
            default: MapUtils_1.LAYER_TYPE.Bubble
          },
          bubbleSize: {
            description: 'Specify the data column to encode bubble size. This applies to layers where type: "bubble".',
            type: ['string', 'array'],
            items: {
              type: 'number'
            },
            default: '> primary | frameWithoutSeriesNames("geobin", "latitude", "longitude") | frameBySeriesTypes("number")'
          },
          latitude: {
            description: 'Specify a dataSource series to apply latitude coordinates for data points displayed on the map. This applies to layers where type: "bubble" or type: "marker".',
            type: ['string', 'array'],
            items: {
              type: 'number'
            },
            default: '> primary | seriesByName("latitude")'
          },
          longitude: {
            description: 'Specify a dataSource series to apply longitude coordinates for data points displayed on the map. This applies to layers where type: "bubble" or type: "marker".',
            type: ['string', 'array'],
            items: {
              type: 'number'
            },
            default: '> primary | seriesByName("longitude")'
          },
          seriesColors: {
            description: 'Specify the colors to use for data points. If the dataColors option is specified, the seriesColors option is ignored. The seriesColors option applies to layers where type: "bubble" or type: "marker".',
            type: 'array',
            items: {
              type: 'string',
              pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA
            },
            default: visualization_color_palettes_1.VIZ_CATEGORICAL
          },
          dataColors: {
            description: 'Specify the colors to use for data points. You can use an array of colors to be picked from, or you can use a dataSource to apply dynamic coloring. For example, “> primary | seriesByName("status") | matchValue(colorMatchConfig)”. When type: "choropleth", dataColors is defined by default, and the opacities are shown at 80% of maximum to allow textual information to be visible in the map. By default, the dataColors option is not defined for type "bubble" or "marker". If type: "bubble", dataColors requires bubbleSize to have only a single series configured.',
            type: ['string', 'array'],
            items: {
              type: 'string'
            }
          },
          additionalTooltipFields: {
            description: 'Specify the fields to add to the default set of tooltips. Tooltips appear when you hover over data points. These fields and their corresponding values are shown in addition to the ones displayed by default.',
            type: 'array',
            items: {
              type: 'string'
            },
            default: []
          },
          resultLimit: {
            description: 'Specify the maximum number of data points to render on the map. Adjust the value to improve performance.',
            type: 'number',
            default: 1000
          }
        }
      }]
    }
  },
  scaleUnit: {
    default: 'metric',
    type: 'string',
    description: 'Specify the scale unit to use.',
    pattern: (0, schemaUtils_1.getPattern)(['metric', 'imperial'])
  },
  showBaseLayer: {
    default: true,
    type: 'boolean',
    description: 'Specify if showing the base map.'
  },
  showScale: {
    default: true,
    type: 'boolean',
    description: 'Specify whether to display the scale on the bottom left.'
  },
  showZoomControls: {
    default: true,
    type: 'boolean',
    description: 'Specify whether to display the control panel of zoom on the top left.'
  },
  zoom: {
    description: 'Specify the zoom level of the map.',
    type: 'number'
  }
};
var themes = {
  defaultBackgroundColor: function defaultBackgroundColor(props) {
    return (0, themes_1.pick)({
      enterprise: {
        dark: themes_1.variables.black(props),
        light: themes_1.variables.backgroundColor(props)
      },
      prisma: themes_1.variables.backgroundColorSidebar(props)
    })(props);
  },
  controlBackgroundColor: function controlBackgroundColor(props) {
    return (0, themes_1.pick)({
      enterprise: {
        dark: themes_1.variables.gray22(props),
        light: themes_1.variables.white(props)
      },
      prisma: themes_1.variables.backgroundColorPopup(props)
    })(props);
  },
  controlForegroundColor: function controlForegroundColor(props) {
    return (0, themes_1.pick)({
      enterprise: themes_1.variables.textColor(props),
      prisma: themes_1.variables.contentColorDefault(props)
    })(props);
  },
  defaultChoroplethEmptyAreaColor: function defaultChoroplethEmptyAreaColor(props) {
    return (0, themes_1.pick)({
      enterprise: {
        dark: themes_1.variables.gray22(props),
        light: themes_1.variables.gray92(props)
      },
      prisma: {
        dark: themes_1.variables.interactiveColorBackground(props),
        light: themes_1.variables.neutral300(props)
      }
    })(props);
  },
  defaultGradientMigrationConfig: function defaultGradientMigrationConfig(props) {
    return (0, themes_1.pick)({
      enterprise: {
        dark: ['#4D4A5D', themes_1.variables.syntaxPurple(props)],
        light: ['#D2CFDC', themes_1.variables.syntaxPurple(props)]
      },
      prisma: {
        dark: ['#484558', themes_1.variables.syntaxPurple(props)],
        light: ['#D8D4E1', themes_1.variables.syntaxPurple(props)]
      }
    })(props);
  }
};

var checkTypeIsChoropleth = function checkTypeIsChoropleth(options) {
  return options.layers && options.layers.length && options.layers[0].type === MapUtils_1.LAYER_TYPE.Choropleth;
};

var checkTypeIsLocalChoropleth = function checkTypeIsLocalChoropleth(options) {
  return options.layers && options.layers.length && options.layers[0].type === MapUtils_1.LAYER_TYPE.Choropleth && (options.layers[0].source === 'geo://default/us' || options.layers[0].source === 'geo://default/world');
};

var EDITOR_LABEL_WIDTH = 140;
var editorConfig = [{
  label: (0, i18n_1._)('Data configurations'),
  layout: [[{
    label: (0, i18n_1._)('Layer type'),
    option: 'layers[0].type',
    editor: 'editor.select',
    editorProps: {
      values: [{
        label: (0, i18n_1._)('Bubble'),
        value: MapUtils_1.LAYER_TYPE.Bubble
      }, {
        label: (0, i18n_1._)('Marker'),
        value: MapUtils_1.LAYER_TYPE.Marker
      }, {
        label: (0, i18n_1._)('Choropleth'),
        value: MapUtils_1.LAYER_TYPE.Choropleth
      }]
    }
  }], [{
    label: (0, i18n_1._)('Area IDs'),
    option: 'layers[0].areaIds',
    editor: 'editor.columnSelector',
    showEditor: function showEditor(_ref) {
      var options = _ref.options;
      return checkTypeIsChoropleth(options);
    },
    editorProps: {
      dataSourceKey: 'primary',
      shouldShowInternalFields: false,
      filterByTypes: ['string']
    }
  }], [{
    label: (0, i18n_1._)('Area values'),
    option: 'layers[0].areaValues',
    editor: 'editor.columnSelector',
    showEditor: function showEditor(_ref2) {
      var options = _ref2.options;
      return checkTypeIsChoropleth(options);
    },
    editorProps: {
      dataSourceKey: 'primary',
      shouldShowInternalFields: false,
      filterByTypes: ['number']
    }
  }], [{
    label: (0, i18n_1._)('Latitude'),
    option: 'layers[0].latitude',
    editor: 'editor.columnSelector',
    showEditor: function showEditor(_ref3) {
      var options = _ref3.options;
      return !(options.layers && options.layers.length && options.layers[0].type === 'choropleth');
    },
    editorProps: {
      dataSourceKey: 'primary',
      shouldShowInternalFields: false
    }
  }], [{
    label: (0, i18n_1._)('Longitude'),
    option: 'layers[0].longitude',
    editor: 'editor.columnSelector',
    showEditor: function showEditor(_ref4) {
      var options = _ref4.options;
      return !(options.layers && options.layers.length && options.layers[0].type === 'choropleth');
    },
    editorProps: {
      dataSourceKey: 'primary',
      shouldShowInternalFields: false
    }
  }], [{
    label: (0, i18n_1._)('Bubble size'),
    option: 'layers[0].bubbleSize',
    editor: 'editor.columnMultiSelector',
    showEditor: function showEditor(_ref5) {
      var options = _ref5.options;
      return !(options.layers && options.layers.length && (options.layers[0].type === 'marker' || options.layers[0].type === 'choropleth'));
    },
    editorProps: {
      dataSourceKey: 'primary',
      shouldShowInternalFields: false,
      excludeByNames: ['latitude', 'longitude', 'geobin']
    }
  }], [{
    label: (0, i18n_1._)('Additional tooltip fields'),
    option: 'layers[0].additionalTooltipFields',
    editor: 'editor.columnMultiSelectionByFieldNameEditor'
  }], [{
    label: (0, i18n_1._)('Result limit'),
    option: 'layers[0].resultLimit',
    editor: 'editor.number',
    showEditor: function showEditor(_ref6) {
      var options = _ref6.options;
      return !checkTypeIsLocalChoropleth(options);
    },
    editorProps: {
      themes: themes,
      labelPosition: 'top',
      min: 0
    }
  }]]
}, {
  label: (0, i18n_1._)('Data display'),
  layout: [[{
    label: (0, i18n_1._)('Latitude (initial map location)'),
    option: 'center[0]',
    editor: 'editor.number',
    editorProps: {
      themes: themes,
      labelPosition: 'top',
      min: -90,
      max: 90
    }
  }], [{
    label: (0, i18n_1._)('Longitude (initial map location)'),
    option: 'center[1]',
    editor: 'editor.number',
    editorProps: {
      themes: themes,
      labelPosition: 'top',
      min: -180,
      max: 180
    }
  }], [{
    label: (0, i18n_1._)('Zoom (initial map location)'),
    option: 'zoom',
    editor: 'editor.number',
    editorProps: {
      themes: themes,
      labelPosition: 'top',
      min: 0
    }
  }], [{
    label: (0, i18n_1._)('Show zoom controls'),
    option: 'showZoomControls',
    editor: 'editor.checkbox',
    editorProps: {
      labelPosition: 'right',
      labelWidth: EDITOR_LABEL_WIDTH
    }
  }], [{
    label: (0, i18n_1._)('Show scale'),
    option: 'showScale',
    editor: 'editor.toggle',
    editorProps: {
      labelPosition: 'right',
      labelWidth: EDITOR_LABEL_WIDTH
    }
  }], [{
    label: (0, i18n_1._)('Scale unit'),
    option: 'scaleUnit',
    editor: 'editor.radioBar',
    showEditor: function showEditor(_ref7) {
      var options = _ref7.options;
      return options.showScale !== false;
    },
    editorProps: {
      values: [{
        label: (0, i18n_1._)('Metric'),
        value: 'metric'
      }, {
        label: (0, i18n_1._)('Imperial'),
        value: 'imperial'
      }]
    }
  }]]
}, {
  label: (0, i18n_1._)('Color and style'),
  layout: [// TODO: add support for color mode option and its corresponding editor
  // [
  //     {
  //         label: _('Color mode'),
  //         option: 'colorMode',
  //         editor: 'editor.radioBar',
  //         editorProps: {
  //             values: [
  //                 { label: _('Static'), value: 'static' },
  //                 { label: _('Dynamic'), value: 'dynamic' },
  //             ],
  //         },
  //     },
  // ],
  [{
    label: (0, i18n_1._)('Series colors'),
    option: 'layers[0].seriesColors',
    editor: 'editor.seriesColors',
    showEditor: function showEditor(_ref8) {
      var options = _ref8.options;
      return !(options.layers && options.layers.length && options.layers[0].type === 'choropleth');
    }
  }], // TODO: add editor for data colors
  // [
  //     {
  //         label: _('Data colors'),
  //         option: 'layers[0].dataColors',
  //         editor: 'editor.text',
  //         editorProps: {
  //             themes,
  //             labelPosition: 'top',
  //         },
  //     },
  // ],
  [{
    label: (0, i18n_1._)('Choropleth empty area'),
    option: 'layers[0].choroplethEmptyAreaColor',
    editor: 'editor.color',
    showEditor: function showEditor(_ref9) {
      var options = _ref9.options;
      return checkTypeIsLocalChoropleth(options);
    },
    editorProps: {
      themes: themes
    }
  }], [{
    label: (0, i18n_1._)('Choropleth stroke'),
    option: 'layers[0].choroplethStrokeColor',
    editor: 'editor.color',
    showEditor: function showEditor(_ref10) {
      var options = _ref10.options;
      return checkTypeIsChoropleth(options);
    },
    editorProps: {
      themes: themes
    }
  }], [{
    label: (0, i18n_1._)('Choropleth opacity (%)'),
    option: 'layers[0].choroplethOpacity',
    editor: 'editor.percent',
    showEditor: function showEditor(_ref11) {
      var options = _ref11.options;
      return checkTypeIsChoropleth(options);
    },
    editorProps: {
      themes: themes,
      min: 0
    }
  }], // TODO: add support for seriesColorsByField option
  // [
  //     {
  //         label: _('Series colors by field name'),
  //         option: 'seriesColorsByField',
  //         editor: 'editor.seriesColorsByField',
  //     },
  // ],
  (0, BackgroundColor_1.default)({
    themes: themes
  }), [{
    label: (0, i18n_1._)('Show base layer'),
    option: 'showBaseLayer',
    editor: 'editor.toggle'
  }], [{
    label: (0, i18n_1._)('Base layer tile server'),
    option: 'baseLayerTileServer',
    editor: 'editor.text',
    showEditor: function showEditor(_ref12) {
      var options = _ref12.options;
      return options.showBaseLayer !== false;
    }
  }], [{
    label: (0, i18n_1._)('Base layer tile server type'),
    option: 'baseLayerTileServerType',
    editor: 'editor.radioBar',
    showEditor: function showEditor(_ref13) {
      var options = _ref13.options;
      return options.showBaseLayer === false ? false : !(typeof options.baseLayerTileServer === 'undefined' || options.baseLayerTileServer === '');
    },
    editorProps: {
      values: [{
        label: (0, i18n_1._)('Vector'),
        value: 'vector'
      }, {
        label: (0, i18n_1._)('Raster'),
        value: 'raster'
      }]
    }
  }]]
}];
/**
 * visualization configuration
 */

var config = {
  /**
   * unique viz key
   */
  key: 'splunk.map',

  /**
   * viz name
   */
  name: (0, i18n_1._)('Map'),
  category: VizCategory_1.VizCategory.SPATIAL,
  status: 'preview',

  /**
   * viz icon
   */
  icon: visualization_icons_1.Map,
  placeholderIcon: placeholders_1.Map,
  dataContract: dataContract,
  size: size,
  defaultContext: defaultContext,
  optionsSchema: optionsSchema,
  editorConfig: editorConfig,
  events: {
    'map.load': {
      description: 'triggered when map is fully loaded',
      parentKeys: ['exec']
    },
    'map.click': {
      description: 'trigger when user clicks map layer'
    }
  },
  supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.EVENTS, VizBehavior_1.VizBehavior.PLACEHOLDER],
  themes: themes,
  requiredProps: []
};
exports.default = (0, configUtils_1.enhanceConfig)(config);

/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _defineProperty = __webpack_require__(7);

var _slicedToArray = __webpack_require__(59);

var _toConsumableArray = __webpack_require__(1);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.formatMetadata = exports.compareBaseStyles = exports.getScaledOpacities = exports.getGlobalLayerBoundaries = exports.isValidLatLon = exports.bakeBubbleData = exports.sanitizeValues = exports.transposeArray = exports.matchBubbleSize = exports.getStaticColors = exports.getZoomLevelFromGeobin = exports.getZoomConstraintsFromTileConfig = exports.getMapStyle = exports.getTilePreset = exports.LAYER_TYPE = exports.DEFAULT_OPACITY = exports.MAX_BUBBLE_RADIUS = exports.MIN_BUBBLE_RADIUS = exports.MAP_STYLE_VERSION_NUMBER = exports.DEFAULT_SERIES_COLORS = exports.DEFAULT_CLUSTER_COLOR = exports.DEFAULT_RESULT_LIMIT = exports.MIN_LONGITUDE = exports.MAX_LONGITUDE = exports.MIN_LATITUDE = exports.MAX_LATITUDE = void 0;

var lodash_1 = __webpack_require__(6);

var d3_scale_1 = __webpack_require__(60);

var chroma = __webpack_require__(61);

var colorUtils_1 = __webpack_require__(62);

var visualization_color_palettes_1 = __webpack_require__(14);

var types_1 = __webpack_require__(63);

exports.MAX_LATITUDE = 90;
exports.MIN_LATITUDE = -90;
exports.MAX_LONGITUDE = 180;
exports.MIN_LONGITUDE = -180;
exports.DEFAULT_RESULT_LIMIT = 1000;
exports.DEFAULT_CLUSTER_COLOR = '#909090';
exports.DEFAULT_SERIES_COLORS = visualization_color_palettes_1.VIZ_CATEGORICAL; // MapLibre requires a map style specification number which is always 8

exports.MAP_STYLE_VERSION_NUMBER = 8; // currently using one [min, max] value set for bubbles across all zoom levels
// TODO: design choices on [min, max] bubble size for different zoom levels

exports.MIN_BUBBLE_RADIUS = 7.11; // 10px

exports.MAX_BUBBLE_RADIUS = 45.26; // 85px

exports.DEFAULT_OPACITY = 0.8;
var LONGITUDE = 'longitude';
var LATITUDE = 'latitude';
var LAYER_TYPE;

(function (LAYER_TYPE) {
  LAYER_TYPE["Marker"] = "marker";
  LAYER_TYPE["Bubble"] = "bubble";
  LAYER_TYPE["Choropleth"] = "choropleth";
})(LAYER_TYPE = exports.LAYER_TYPE || (exports.LAYER_TYPE = {}));
/**
 * Construct a tile preset {key: config} by combining the default + custom tile configs
 * Also returns the default tile config for each theme - light/dark
 * @param {MapContextInterface} args
 * @param {BaseTileConfig[]} args.defaultTileConfig
 * @param {BaseTileConfig[]} args.customTileConfig
 * @returns {Object} tile preset
 */


var getTilePreset = function getTilePreset(_ref) {
  var _ref$defaultTileConfi = _ref.defaultTileConfig,
      defaultTileConfig = _ref$defaultTileConfi === void 0 ? [] : _ref$defaultTileConfi,
      _ref$customTileConfig = _ref.customTileConfig,
      customTileConfig = _ref$customTileConfig === void 0 ? [] : _ref$customTileConfig;

  var _a, _b;

  var tilePreset = {};
  var defaultTileLight = {};
  var defaultTileDark = {};
  var tileConfigs = [].concat(defaultTileConfig).concat(customTileConfig);
  (0, lodash_1.forEach)(tileConfigs, function (tileConfig) {
    var key = tileConfig === null || tileConfig === void 0 ? void 0 : tileConfig.key;
    var updatedConfig = Object.assign(Object.assign({
      theme: 'all'
    }, tileConfig), {
      version: exports.MAP_STYLE_VERSION_NUMBER
    });
    tilePreset[key] = updatedConfig;
  });

  if (defaultTileConfig.length > 0) {
    defaultTileLight = (_a = defaultTileConfig.find(function (config) {
      return config.theme === 'light';
    })) !== null && _a !== void 0 ? _a : defaultTileConfig.find(function (config) {
      return config.theme === undefined;
    });
    defaultTileDark = (_b = defaultTileConfig.find(function (config) {
      return config.theme === 'dark';
    })) !== null && _b !== void 0 ? _b : defaultTileConfig.find(function (config) {
      return config.theme === undefined;
    });
  }

  return {
    tilePreset: tilePreset,
    defaultTileLight: defaultTileLight,
    defaultTileDark: defaultTileDark
  };
};

exports.getTilePreset = getTilePreset;
/**
 * Check if baseLayerTileServer is in tilePreset and config matches current theme, if yes, return.
 * If no, construct a mapStyle with baseLayerTilerServer and baseLayerTileServerType
 * Else return default tile config based on current theme
 * @param {Object} args
 * @param {BaseTileConfig[]} args.tilePreset
 * @param {String} args.baseLayerTilerServer
 * @param {String} args.baseLayerTileServerType
 * @param {String} args.colorScheme
 * @param {BaseTileConfig} args.defaultTileDark
 * @param {BaseTileConfig} args.defaultTileLight
 * @returns {BaseTileConfig} mapStyle
 */

var getMapStyle = function getMapStyle(_ref2) {
  var showBaseLayer = _ref2.showBaseLayer,
      _ref2$baseLayerTileSe = _ref2.baseLayerTileServer,
      baseLayerTileServer = _ref2$baseLayerTileSe === void 0 ? '' : _ref2$baseLayerTileSe,
      _ref2$baseLayerTileSe2 = _ref2.baseLayerTileServerType,
      baseLayerTileServerType = _ref2$baseLayerTileSe2 === void 0 ? '' : _ref2$baseLayerTileSe2,
      _ref2$tilePreset = _ref2.tilePreset,
      tilePreset = _ref2$tilePreset === void 0 ? {} : _ref2$tilePreset,
      _ref2$colorScheme = _ref2.colorScheme,
      colorScheme = _ref2$colorScheme === void 0 ? 'light' : _ref2$colorScheme,
      _ref2$defaultTileLigh = _ref2.defaultTileLight,
      defaultTileLight = _ref2$defaultTileLigh === void 0 ? {} : _ref2$defaultTileLigh,
      _ref2$defaultTileDark = _ref2.defaultTileDark,
      defaultTileDark = _ref2$defaultTileDark === void 0 ? {} : _ref2$defaultTileDark;

  if (!showBaseLayer) {
    return {
      version: exports.MAP_STYLE_VERSION_NUMBER,
      sources: {
        'base-tiles': {
          type: 'raster',
          tiles: ['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='],
          tileSize: 256
        }
      },
      layers: [{
        id: 'base-layer',
        type: 'raster',
        source: 'base-tiles',
        minzoom: 0,
        maxzoom: 22
      }]
    };
  }

  if (baseLayerTileServer && tilePreset[baseLayerTileServer] && (tilePreset[baseLayerTileServer].theme === colorScheme || tilePreset[baseLayerTileServer].theme === 'all')) {
    return tilePreset[baseLayerTileServer];
  }

  if (baseLayerTileServer && baseLayerTileServerType) {
    var tiles = [];
    /**
     * Tile Server URLs (eg: http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png) can specify the variable {s} which refers to a subdomain
     * Subdomains are used to help with browser parallel requests per domain limitation. These subdomains are typically single letters 'a', 'b' and 'c'
     * Refer to https://leafletjs.com/SlavaUkraini/reference.html#tilelayer and https://wiki.openstreetmap.org/wiki/Tile_servers
     */

    if (baseLayerTileServer.match(/^(https?):\/\/{(s|S)}\../)) {
      /**
       * sXML (Leaflet) allows users to define their own tile server URLs + list of available subdomains
       * In order to preserve this behavior during conversion to splunk.map,
       * if the variable {s} or {S} is detected, replace it with 'a', 'b' and 'c' - default values for subdomains
       * TODO: in the future, add an additional prop - baseLayerTileServerSubdomains: ['x', 'y', 'z'], default being ['a', 'b', 'c']
       */
      tiles = [baseLayerTileServer.replace(/{(s|S)}/, 'a'), baseLayerTileServer.replace(/{(s|S)}/, 'b'), baseLayerTileServer.replace(/{(s|S)}/, 'c')];
    } else {
      tiles = [baseLayerTileServer];
    } // TODO: remove hardcoded style when we allow users to pass in layer style through Viz options


    var mapStyle = {
      version: exports.MAP_STYLE_VERSION_NUMBER,
      sources: {
        'base-tiles': {
          type: baseLayerTileServerType,
          tiles: tiles,
          tileSize: 256
        }
      },
      layers: [{
        id: 'base-layer',
        type: 'raster',
        source: 'base-tiles',
        minzoom: 0,
        maxzoom: 24 // https://maplibre.org/maplibre-gl-js-docs/api/map/

      }]
    };
    return mapStyle;
  } // if tile server is not present in the preset AND we can't construct a mapStyle, fall back on defaults


  return colorScheme === 'light' ? defaultTileLight : defaultTileDark;
};

exports.getMapStyle = getMapStyle;

var getZoomConstraintsFromTileConfig = function getZoomConstraintsFromTileConfig(tileConfig, baseLayerTileServer) {
  var sources = tileConfig.sources,
      layers = tileConfig.layers;
  var matchedBaseLayerTileServer = false; // check sources for minzoom maxzoom first

  var sourceKeys = Object.keys(sources);

  for (var i = 0; i < sourceKeys.length; i += 1) {
    var _sources$sourceKeys$i = sources[sourceKeys[i]],
        minzoom = _sources$sourceKeys$i.minzoom,
        maxzoom = _sources$sourceKeys$i.maxzoom;

    if (baseLayerTileServer && sources[sourceKeys[i]].tiles.indexOf(baseLayerTileServer) !== -1) {
      matchedBaseLayerTileServer = true;
    }

    if ((baseLayerTileServer && matchedBaseLayerTileServer || !baseLayerTileServer) && (0, lodash_1.isNumber)(minzoom) && (0, lodash_1.isNumber)(maxzoom)) {
      return {
        minZoom: minzoom,
        maxZoom: maxzoom
      };
    }
  } // then check layers


  for (var _i = 0; _i < layers.length; _i += 1) {
    var _layers$_i = layers[_i],
        _minzoom = _layers$_i.minzoom,
        _maxzoom = _layers$_i.maxzoom;

    if ((baseLayerTileServer && matchedBaseLayerTileServer || !baseLayerTileServer) && (0, lodash_1.isNumber)(_minzoom) && (0, lodash_1.isNumber)(_maxzoom)) {
      return {
        minZoom: _minzoom,
        maxZoom: _maxzoom
      };
    }
  } // Maplibre default - would reset previous min/maxZoom https://maplibre.org/maplibre-gl-js-docs/api/map/


  return {
    minZoom: 0,
    maxZoom: 24
  };
};

exports.getZoomConstraintsFromTileConfig = getZoomConstraintsFromTileConfig;

var getZoomLevelFromGeobin = function getZoomLevelFromGeobin(geobinStr) {
  var _a;

  if (!geobinStr) {
    return null;
  } // geostats cmds return geobin with zoom level 0-18, 0-99 in the geobinPattern covers the range


  var geobinPattern = /bin_id_zl_([0-9]{0,2})?_y_/g;
  var match = geobinPattern.exec(geobinStr);
  return (_a = (match === null || match === void 0 ? void 0 : match.length) && parseInt(match[1], 10)) !== null && _a !== void 0 ? _a : null;
};

exports.getZoomLevelFromGeobin = getZoomLevelFromGeobin; // Bubble colors - static

var getStaticColors = function getStaticColors(colorCount, colorArray) {
  if (colorCount < 0 || !colorCount) {
    return [exports.DEFAULT_CLUSTER_COLOR];
  }

  if (!colorArray || !colorArray.length) {
    return _toConsumableArray(Array(colorCount).keys()).map(function (i) {
      return exports.DEFAULT_SERIES_COLORS[i];
    });
  } // loop through colorArray to pick the first $colorCount colors
  // start from begining again if colorCount > colorArray.length


  return _toConsumableArray(Array(colorCount).keys()).map(function (i) {
    return (0, colorUtils_1.isColor)(colorArray[i % colorArray.length]) ? colorArray[i % colorArray.length] : exports.DEFAULT_CLUSTER_COLOR;
  });
};

exports.getStaticColors = getStaticColors; // Bubble size

var matchBubbleSize = function matchBubbleSize(dataRange, data) {
  var size = (0, d3_scale_1.scalePow)().exponent(0.2).domain(dataRange).range([exports.MIN_BUBBLE_RADIUS, exports.MAX_BUBBLE_RADIUS])(data);

  if (size > exports.MAX_BUBBLE_RADIUS) {
    return exports.MAX_BUBBLE_RADIUS;
  }

  if (size < exports.MIN_BUBBLE_RADIUS) {
    return exports.MIN_BUBBLE_RADIUS;
  }

  return size;
};

exports.matchBubbleSize = matchBubbleSize;

var transposeArray = function transposeArray(array) {
  if (!array || !array.length || !array[0] || !array[0].length) {
    return [];
  }

  return array[0].map(function (_, i) {
    return array.map(function (row) {
      return row[i];
    });
  });
};

exports.transposeArray = transposeArray; // sanitize values: update all null, undefined, or negative values to 0

var sanitizeValues = function sanitizeValues(values) {
  // null / undefined
  if (!values) {
    return 0;
  } // number


  if (!Array.isArray(values)) {
    return values > 0 ? values : 0;
  } // array


  return values.map(function (arr) {
    return (0, exports.sanitizeValues)(arr);
  });
};

exports.sanitizeValues = sanitizeValues;

var bakeBubbleData = function bakeBubbleData(layer) {
  var _a;

  if (!layer || !((_a = layer.bubbleSize) === null || _a === void 0 ? void 0 : _a.length) || !layer.geobin || !layer.geobin.length || !layer.latitude || !layer.latitude.length || !layer.longitude || !layer.longitude.length) {
    return null;
  } // if bubbleSize is passed as an array of single number array (data series)
  // e.g. [value0, value1, ...]
  // format each value as an array to unify data operations for data series and frames


  var sanitizedBubbleSize = (0, exports.sanitizeValues)(layer.bubbleSize);
  var transposedBubbleSize;
  var transposedSanitizedBubbleSize;
  var isPie = false; // format array if bubbleSize is passed as an array of array (data frame)

  if (Array.isArray(layer.bubbleSize[0])) {
    // one-time array transpose,
    // e.g. from [column0data, column0data] (multi series)
    // to [[column0datum0, column1datum0], [column0datum1, column1data1], ...]
    // or e.g. from [column0data] (single series)
    // to [[column0data]]
    // for easy access of values at each geo location,
    // and min max pie size computation
    transposedBubbleSize = (0, exports.transposeArray)(layer.bubbleSize);
    transposedSanitizedBubbleSize = (0, exports.transposeArray)(sanitizedBubbleSize); // if multiple series in the dataframe, set isPie to true

    if (layer.bubbleSize.length > 1) {
      isPie = true;
    }
  } else {
    transposedBubbleSize = layer.bubbleSize.map(function (n) {
      return [n];
    });
    transposedSanitizedBubbleSize = sanitizedBubbleSize.map(function (n) {
      return [n];
    });
  }

  if (!transposedBubbleSize || !transposedBubbleSize.length) {
    return null;
  }

  var data = layer.latitude.map(function (lat, i) {
    return {
      zoom: (0, exports.getZoomLevelFromGeobin)(layer.geobin[i]),
      values: transposedBubbleSize[i],
      sanitizedValues: transposedSanitizedBubbleSize[i],
      coordinates: [layer.longitude[i], lat],
      metadata: layer.metadata ? layer.metadata[i] : {}
    };
  }).filter(function (d) {
    return Boolean(d.values);
  }); // compute the min/max value to encode min/max pie or bubble size

  var min = (0, lodash_1.sum)(transposedSanitizedBubbleSize[0]);
  var max = (0, lodash_1.sum)(transposedSanitizedBubbleSize[1]);
  transposedSanitizedBubbleSize.forEach(function (row) {
    var bubbleSize = (0, lodash_1.sum)(row);
    max = bubbleSize > max ? bubbleSize : max;
    min = bubbleSize < min ? bubbleSize : min;
  });
  return {
    data: data,
    dataRange: [min, max],
    isPie: isPie,
    resultLimit: layer.resultLimit,
    bubbleSizeFields: layer.bubbleSizeFields
  };
};

exports.bakeBubbleData = bakeBubbleData;

var isValidLatLon = function isValidLatLon(latlon) {
  if (!latlon || !Array.isArray(latlon) || latlon.length !== 2) {
    return false;
  }

  var _latlon = _slicedToArray(latlon, 2),
      lat = _latlon[0],
      lon = _latlon[1];

  if (!(0, types_1.isNumber)(lat) || !(lat >= exports.MIN_LATITUDE && lat <= exports.MAX_LATITUDE)) {
    return false;
  }

  if (!(0, types_1.isNumber)(lon) || !(lon >= exports.MIN_LONGITUDE && lon <= exports.MAX_LONGITUDE)) {
    return false;
  }

  return true;
};

exports.isValidLatLon = isValidLatLon;
/**
 * Returns a list of all lat or lon coordinates used in a specified layer
 * @param {LayerType[]} layer
 * @param {string} field
 * @returns {number[]} list of lat coordinates or lon coordinates
 */

var getLatOrLonCoordinates = function getLatOrLonCoordinates(layer, field) {
  var getClusterValues = function getClusterValues(clusterLayer) {
    return (0, lodash_1.get)(clusterLayer, field, []).slice(0, clusterLayer.type === LAYER_TYPE.Marker && clusterLayer.resultLimit ? clusterLayer.resultLimit : exports.DEFAULT_RESULT_LIMIT);
  };

  var getChoroplethValues = function getChoroplethValues(choroplethLayer) {
    var slicedGeomList = choroplethLayer.geom.slice(0, choroplethLayer.resultLimit);
    var flatCoordinates = slicedGeomList.flatMap(function (geomObject) {
      return geomObject.coordinates.flat(2);
    });
    return flatCoordinates.map(function (coord) {
      return coord[field === LONGITUDE ? 0 : 1];
    });
  };

  return layer.type === LAYER_TYPE.Choropleth ? getChoroplethValues(layer) : getClusterValues(layer);
};
/**
 * Returns the min and max LongLat pairs to determine the layer boundaries to fit all markers/bubbles
 * @param {LayerType[]} layers
 * @returns {LngLatBoundsLike}
 */


var getGlobalLayerBoundaries = function getGlobalLayerBoundaries(layers) {
  var isLayerValid = function isLayerValid(field) {
    return layers.every(function (layer) {
      return layer[field] || layer.geom;
    });
  };

  var getDefaultMax = function getDefaultMax(field) {
    return field === LONGITUDE ? exports.MAX_LONGITUDE : exports.MAX_LATITUDE;
  };

  var getDefaultMin = function getDefaultMin(field) {
    return field === LONGITUDE ? exports.MIN_LONGITUDE : exports.MIN_LATITUDE;
  };

  if (!layers || !Array.isArray(layers) || !layers.length) {
    return null;
  }

  var getMin = function getMin(field) {
    if (!isLayerValid(field)) {
      return getDefaultMin(field);
    }

    return layers.reduce(function (prevVal, layer) {
      var coordinatesNumArr = getLatOrLonCoordinates(layer, field).map(function (x) {
        return +x;
      });
      return (0, lodash_1.min)([prevVal].concat(_toConsumableArray(coordinatesNumArr)));
    }, getDefaultMax(field));
  };

  var getMax = function getMax(field) {
    if (!isLayerValid(field)) {
      return getDefaultMax(field);
    }

    return layers.reduce(function (prevVal, layer) {
      var coordinatesNumArr = getLatOrLonCoordinates(layer, field).map(Number);
      return (0, lodash_1.max)([prevVal].concat(_toConsumableArray(coordinatesNumArr)));
    }, getDefaultMin(field));
  };

  return [[getMin(LONGITUDE), getMin(LATITUDE)], [getMax(LONGITUDE), getMax(LATITUDE)]];
};

exports.getGlobalLayerBoundaries = getGlobalLayerBoundaries;

var getScaledOpacities = function getScaledOpacities(colors, cfgOpacity) {
  // extract opacity information from 8 digit hex codes
  var opacities = colors === null || colors === void 0 ? void 0 : colors.map(function (color) {
    var _a;

    return (color === null || color === void 0 ? void 0 : color.length) === 9 ? (_a = chroma(color).alpha()) !== null && _a !== void 0 ? _a : 1 : 1;
  }); // opacity cannot be greater than configured opacity

  return opacities === null || opacities === void 0 ? void 0 : opacities.map(function (opacity) {
    return opacity * cfgOpacity;
  });
};

exports.getScaledOpacities = getScaledOpacities;

var compareBaseStyles = function compareBaseStyles(curr, next) {
  var _a, _b, _c, _d;

  var currBaseLayer = (_a = curr === null || curr === void 0 ? void 0 : curr.layers) === null || _a === void 0 ? void 0 : _a.find(function (layer) {
    return (layer === null || layer === void 0 ? void 0 : layer.id) === 'base-layer';
  });
  var nextBaseLayer = (_b = next === null || next === void 0 ? void 0 : next.layers) === null || _b === void 0 ? void 0 : _b.find(function (layer) {
    return (layer === null || layer === void 0 ? void 0 : layer.id) === 'base-layer';
  });
  var currBaseSource = (0, lodash_1.get)(curr === null || curr === void 0 ? void 0 : curr.sources, (_c = currBaseLayer === null || currBaseLayer === void 0 ? void 0 : currBaseLayer.source) !== null && _c !== void 0 ? _c : '');
  var nextBaseSource = (0, lodash_1.get)(next === null || next === void 0 ? void 0 : next.sources, (_d = nextBaseLayer === null || nextBaseLayer === void 0 ? void 0 : nextBaseLayer.source) !== null && _d !== void 0 ? _d : '');

  if (!currBaseLayer || !nextBaseLayer || !currBaseSource || !nextBaseSource) {
    return false;
  }

  return (0, lodash_1.isEqual)(currBaseLayer, nextBaseLayer) && (0, lodash_1.isEqual)(currBaseSource, nextBaseSource);
};

exports.compareBaseStyles = compareBaseStyles;

var formatMetadata = function formatMetadata(choroplethLayer, i) {
  if (!choroplethLayer || !choroplethLayer.areaIds || !choroplethLayer.areaValues) return {};
  if (i >= choroplethLayer.areaIds.length) return {};
  var metadata = choroplethLayer.metadata ? choroplethLayer.metadata[i] : {};
  var name = choroplethLayer.areaIds[i];
  var value = choroplethLayer.areaValues[i];
  var base = {
    name: name,
    value: String(value)
  };
  return Object.keys(metadata).reduce(function (result, curr) {
    var key = "row.".concat(curr, ".value");
    var val = (0, lodash_1.isObject)(metadata[curr]) ? JSON.stringify(metadata[curr]) : String(metadata[curr]);
    return Object.assign(Object.assign({}, result), _defineProperty({}, key, val));
  }, base);
};

exports.formatMetadata = formatMetadata;

/***/ }),
/* 59 */
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/slicedToArray");

/***/ }),
/* 60 */
/***/ (function(module, exports) {

module.exports = require("d3-scale");

/***/ }),
/* 61 */
/***/ (function(module, exports) {

module.exports = require("chroma-js");

/***/ }),
/* 62 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualizations-shared/colorUtils");

/***/ }),
/* 63 */
/***/ (function(module, exports) {

module.exports = require("@splunk/visualization-encoding/utils/types");

/***/ })
/******/ ]);
//# sourceMappingURL=Map.config.js.map