/*!
 * 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 = 85);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ (function(module, exports) {

module.exports = require("react");

/***/ }),

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

module.exports = require("prop-types");

/***/ }),

/***/ 10:
/***/ (function(module, exports) {

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

/***/ }),

/***/ 12:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _typeof = __webpack_require__(15);

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.componentStoriesToInclude = exports.getStoriesToInclude = exports.flattenVizOptions = exports.getOptionsFromArgTypes = exports.transformOptionType = exports.optionsSchemaToArgTypes = exports.platformOptionArgTypes = exports.getOptionControl = exports.getOptionDisplayType = exports.getPatternOptions = void 0;

var lodash_1 = __webpack_require__(3);

var configUtils_1 = __webpack_require__(86);
/**
 * Returns type options from pattern
 * @example
 * // returns ['fixed', 'absolute', 'off']
 * getPatternOptions('\$(\w+:)?([^$|:]+?)(\|[|\w]+)?\$|^fixed$|^absolute$|^off$')
 * @example
 * // returns []
 * getPatternOptions('^>.*')
 * @param {string} patternString - visualization option type pattern
 * @return {string[]} array of type options
 */


var getPatternOptions = function getPatternOptions(patternString) {
  return patternString.replace(/\$/g, '').split('|^').slice(1);
};

exports.getPatternOptions = getPatternOptions;
/**
 * Returns Storybook display type for an option
 * @param {object} option - visualization option
 * @return {string} Storybook display type
 */

var getOptionDisplayType = function getOptionDisplayType(option) {
  var oneOf = option.oneOf,
      anyOf = option.anyOf,
      type = option.type,
      en = option.enum,
      pattern = option.pattern,
      items = option.items;
  var displayTypes = []; // wrap values in quotes only if enum or pattern is string

  var conditionalQuote = type === 'string' ? '"' : '';

  if (en && Array.isArray(en)) {
    displayTypes = en.map(function (e) {
      var enumQuote = typeof e === 'string' ? '"' : '';
      return "".concat(enumQuote).concat(e).concat(enumQuote);
    });
  } else if (type === 'array' && items) {
    return "".concat((0, exports.getOptionDisplayType)(items), "[]");
  } else if (anyOf && Array.isArray(anyOf)) {
    return (0, exports.getOptionDisplayType)(anyOf[0]);
  } else if (oneOf && Array.isArray(oneOf)) {
    displayTypes = oneOf.map(function (item) {
      return (0, exports.getOptionDisplayType)(item);
    });
  } else if (Array.isArray(type)) {
    displayTypes = type;
  } else if (pattern) {
    displayTypes = (0, exports.getPatternOptions)(pattern).map(function (p) {
      return "".concat(conditionalQuote).concat(p).concat(conditionalQuote);
    });
  }

  if (displayTypes.length > 0) {
    return "(".concat(displayTypes.join(' | '), ")");
  }

  return type;
};

exports.getOptionDisplayType = getOptionDisplayType;
/**
 * Returns Storybook control type for an option
 * @param {object} option - visualization option
 * @param {string} optionKey - visualization option key
 * @return {ArgTypeControl} Storybook control object
 */

var getOptionControl = function getOptionControl(option, optionKey) {
  var anyOf = option.anyOf;
  var schema = Array.isArray(anyOf) && anyOf.length ? anyOf[0] : option;
  var type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
  var maximum = schema.maximum,
      minimum = schema.minimum,
      en = schema.enum;
  var isColorOption = new RegExp(/color/, 'i').test(optionKey) && type !== 'array';

  if (isColorOption) {
    return {
      type: 'color'
    };
  } else if (en && Array.isArray(en)) {
    return {
      type: 'select',
      options: en
    };
  } else if (anyOf && type === 'string' && anyOf[0].pattern) {
    return {
      type: 'select',
      options: (0, exports.getPatternOptions)(anyOf[0].pattern)
    };
  } else if (type === 'number' && (minimum || maximum)) {
    return Object.assign(Object.assign({
      type: 'range'
    }, typeof minimum === 'number' && {
      min: minimum
    }), typeof maximum === 'number' && {
      max: maximum
    });
  } else if (type === 'string') {
    return {
      type: 'text'
    };
  }

  return {
    type: type
  };
};

exports.getOptionControl = getOptionControl;
/**
 * platform specific visualization option argTypes
 */

var objectTableControl = {
  control: {
    type: 'object'
  }
};
var disableTableControl = {
  table: {
    disable: true
  }
};
exports.platformOptionArgTypes = {
  context: objectTableControl,
  dataSources: objectTableControl,
  dataSource: disableTableControl,
  options: disableTableControl,
  onEventTrigger: Object.assign({
    action: 'eventTrigger'
  }, disableTableControl),
  hasEventHandlers: disableTableControl
};
/**
 * Returns formatted Storybook argTypes for a visualization from its options schema
 * @param {OptionsSchema} options - visualization options
 * @param {string[]} requiredProps - required visualization props
 * @param {boolean} isPlatformViz - indicates if pure or platform visualization
 * @param {string} subcategory - nested property parent option name
 * @return {ArgTypes} Storybook argTypes
 */

var optionsSchemaToArgTypes = function optionsSchemaToArgTypes(_ref) {
  var _ref$options = _ref.options,
      options = _ref$options === void 0 ? {} : _ref$options,
      _ref$requiredProps = _ref.requiredProps,
      requiredProps = _ref$requiredProps === void 0 ? [] : _ref$requiredProps,
      _ref$isPlatformViz = _ref.isPlatformViz,
      isPlatformViz = _ref$isPlatformViz === void 0 ? false : _ref$isPlatformViz,
      _ref$subcategory = _ref.subcategory,
      subcategory = _ref$subcategory === void 0 ? null : _ref$subcategory;
  var validObjectTypeOptions = ['lineDashStylesByField', 'seriesColorsByField', 'fieldActions', 'highlightValuesByField'];
  var argTypes = {};
  Object.keys(options).forEach(function (optionKey) {
    var option = (0, lodash_1.get)(options, optionKey);

    if (option.type === 'object' && !validObjectTypeOptions.includes(optionKey)) {
      // do not support controls for patternProperties, only nested properties
      if (option.properties) {
        argTypes = Object.assign(Object.assign({}, argTypes), (0, exports.optionsSchemaToArgTypes)({
          options: option.properties,
          isPlatformViz: isPlatformViz,
          requiredProps: requiredProps,
          subcategory: optionKey
        }));
      }
    } else {
      var description = option.description,
          optionDefault = option.default;
      var optionControl = (0, exports.getOptionControl)(option, optionKey);
      var control = isPlatformViz ? {
        type: 'text'
      } : optionControl;
      var required = requiredProps.includes(optionKey);
      var defaultValue = optionDefault;

      if (!isPlatformViz && (0, configUtils_1.isDynamicOption)(optionDefault)) {
        defaultValue = null;
      }

      argTypes[optionKey] = {
        description: description,
        control: control,
        name: optionKey,
        defaultValue: defaultValue,
        type: {
          required: required
        },
        optionType: optionControl.type,
        table: Object.assign({
          type: {
            summary: (0, exports.getOptionDisplayType)(option)
          },
          defaultValue: {
            summary: defaultValue
          }
        }, subcategory && {
          category: 'Nested Options',
          subcategory: subcategory
        })
      };
    }
  });

  if (isPlatformViz) {
    Object.assign(argTypes, exports.platformOptionArgTypes);
  }

  return argTypes;
};

exports.optionsSchemaToArgTypes = optionsSchemaToArgTypes;
/**
 * Helper which converts string visualization options to their required type
 * @param {any} value - option values
 * @param {string} expectedType - expected option type
 * @return {any} correctly typed option value
 */

var transformOptionType = function transformOptionType(value) {
  var expectedType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'string';
  var isStringValue = !(0, configUtils_1.isDynamicOption)(value) && (0, lodash_1.isString)(value);
  if (isStringValue && expectedType === 'boolean') return value == 'true';else if (isStringValue && expectedType === 'number') return (0, lodash_1.toNumber)(value);
  return value;
};

exports.transformOptionType = transformOptionType; // stringify these fields for storybook controls' support

var FieldsToStringify = ['layers', 'center', 'eventActions', 'fieldActions', 'legendLabels', 'lineDashStylesByField', 'seriesColors', 'seriesColorsByField', 'footerFields', 'highlightValuesByField'];
/**
 * Helper which returns platform visualization options from Storybook controls
 * Utilizes argTypes to determine valid and nested options
 * @param {object} args - visualization story args
 * @param {ArgTypes} argTypes - visualization argTypes
 * @return {object} visualization options
 */

var getOptionsFromArgTypes = function getOptionsFromArgTypes(args, argTypes) {
  return (0, lodash_1.reduce)(argTypes, function (accum, val, option) {
    var subcategory = (0, lodash_1.get)(val, 'table.subcategory');
    var _argTypes$option = argTypes[option],
        optionType = _argTypes$option.optionType,
        defaultValue = _argTypes$option.defaultValue;
    var controlledOption = (0, exports.transformOptionType)((0, lodash_1.get)(args, option), optionType); // filter options from react & json if set to default value or is undefined

    if (optionType && controlledOption != null && controlledOption !== defaultValue) {
      // parse the value if option is stringified as part of flattenVizOptions
      if (FieldsToStringify.includes(option)) {
        try {
          controlledOption = JSON.parse(controlledOption);
        } catch (e) {
          controlledOption = null;
        }
      }

      if (subcategory) {
        if (!accum[subcategory]) accum[subcategory] = {};
        accum[subcategory][option] = controlledOption;
      } else accum[option] = controlledOption;
    }

    return accum;
  }, Object.assign({}, (0, lodash_1.omit)(args.options, Object.keys(argTypes))));
};

exports.getOptionsFromArgTypes = getOptionsFromArgTypes;
/**
 * Helper which flattens objects single depth level
 * @param {object} options - visualization options object
 * @return {object} flattened visualization options
 */

var flattenVizOptions = function flattenVizOptions(options) {
  var nonFlattenOptions = new Set(['y2Fields', 'overlayFields', 'gaugeRanges', 'fieldActions', 'highlightValuesByField', 'headers']);
  return (0, lodash_1.reduce)(options, function (accum, val, option) {
    if (!exports.platformOptionArgTypes[option]) {
      if (_typeof(val) === 'object' && FieldsToStringify.includes(option)) accum[option] = JSON.stringify(val);else if (_typeof(val) === 'object' && !nonFlattenOptions.has(option)) accum = Object.assign(Object.assign({}, accum), val);else accum[option] = val;
    }

    return accum;
  }, {});
};

exports.flattenVizOptions = flattenVizOptions;
/**
 * Returns value based on Storybook publishing status
 * @param {T} publishedStories - stories to include in published Storybook
 * @param {T} localStories - stories to include in local Storybook
 * @return {T} one of the two params
 */

var getStoriesToInclude = function getStoriesToInclude(publishedStories, localStories) {
  return Object({"NODE_ENV":"production"}).STORYBOOK_PUBLISH ? publishedStories : localStories;
};

exports.getStoriesToInclude = getStoriesToInclude;
/**
 * Returns component level stories to include, defaults to innclude all stories
 * @param {StoriesList} stories - stories to include in published Storybook
 * @return {object} CSF includeStories config
 */

var componentStoriesToInclude = function componentStoriesToInclude(stories) {
  return (0, exports.getStoriesToInclude)({
    includeStories: stories
  }, {});
};

exports.componentStoriesToInclude = componentStoriesToInclude;

/***/ }),

/***/ 15:
/***/ (function(module, exports) {

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

/***/ }),

/***/ 17:
/***/ (function(module, exports) {

module.exports = require("@splunk/react-ui/Markdown");

/***/ }),

/***/ 2:
/***/ (function(module, exports) {

module.exports = require("styled-components");

/***/ }),

/***/ 23:
/***/ (function(module, exports) {

module.exports = require("lodash/isEmpty");

/***/ }),

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

module.exports = require("lodash");

/***/ }),

/***/ 5:
/***/ (function(module, exports) {

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

/***/ }),

/***/ 6:
/***/ (function(module, exports) {

module.exports = require("@splunk/react-ui/Heading");

/***/ }),

/***/ 8:
/***/ (function(module, exports) {

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

/***/ }),

/***/ 85:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getType", function() { return getType; });
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(23);
/* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _splunk_react_ui_Heading__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6);
/* harmony import */ var _splunk_react_ui_Heading__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_splunk_react_ui_Heading__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _splunk_react_ui_Markdown__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(17);
/* harmony import */ var _splunk_react_ui_Markdown__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_splunk_react_ui_Markdown__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2);
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_10__);
/* harmony import */ var _storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(12);
/* harmony import */ var _storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__);




function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);

  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    if (enumerableOnly) symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    });
    keys.push.apply(keys, symbols);
  }

  return keys;
}

function _objectSpread(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};

    if (i % 2) {
      ownKeys(Object(source), true).forEach(function (key) {
        _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(target, key, source[key]);
      });
    } else if (Object.getOwnPropertyDescriptors) {
      Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
      ownKeys(Object(source)).forEach(function (key) {
        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
      });
    }
  }

  return target;
}










var Option = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__Option",
  componentId: "sc-1eidk15-0"
})(["margin-top:20px;"]);
var OptionName = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__OptionName",
  componentId: "sc-1eidk15-1"
})(["color:#5ca300;padding-bottom:5px;"]);
var PairContainer = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__PairContainer",
  componentId: "sc-1eidk15-2"
})(["margin-left:40px;margin-top:10px;"]);
var PairTitle = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.span.withConfig({
  displayName: "OptionsDoc__PairTitle",
  componentId: "sc-1eidk15-3"
})(["display:inline-block;color:#8293a7;width:80px;"]);
var PairValue = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.span.withConfig({
  displayName: "OptionsDoc__PairValue",
  componentId: "sc-1eidk15-4"
})(["font-family:'Splunk Platform Mono','monospace';white-space:pre;"]);
var PairValueJSON = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__PairValueJSON",
  componentId: "sc-1eidk15-5"
})(["margin-left:80px;pre{margin:0;}code{font-size:12px;font-family:'Splunk Platform Mono','monospace';}"]);
var PropertiesWrapper = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__PropertiesWrapper",
  componentId: "sc-1eidk15-6"
})(["margin-left:", "px;margin-top:20px;"], function (props) {
  return props.isPatternProperty ? 0 : 40;
});
var PropertiesContainer = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__PropertiesContainer",
  componentId: "sc-1eidk15-7"
})(["margin-left:", "px;margin-top:10px;"], function (props) {
  return props.isPatternProperty ? 40 : 0;
});
var PropertiesContent = styled_components__WEBPACK_IMPORTED_MODULE_9___default.a.div.withConfig({
  displayName: "OptionsDoc__PropertiesContent",
  componentId: "sc-1eidk15-8"
})(["margin-left:", "px;"], function (props) {
  return props.isPatternProperty ? 40 : 0;
});
/**
 * @method isOneOfJsonSchema
 * @param {object} item
 * @returns {boolean}
 */

var isOneOfJsonSchema = function isOneOfJsonSchema(item) {
  return item.oneOf && Array.isArray(item.oneOf);
};
/**
 * get Or type as string
 * @method getOrType
 * @param {object} item
 * @param {string} res
 * @returns {string} res  eg: (string | number)
 */


var getOrType = function getOrType(item) {
  var res = '';

  if (isOneOfJsonSchema(item)) {
    res = item.oneOf.map(function (one) {
      if (one.type !== 'array') {
        return one.type;
      } // eslint-disable-next-line no-use-before-define


      return getArrayType(one, '');
    }).join(' | ');
  } else if (Array.isArray(item.type)) {
    if (lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5___default()(item.default)) {
      return item.type.join(' | ');
    }

    res = item.type.filter(function (itemType) {
      return itemType !== 'string';
    }).join(' | ');
    res += ' | ';
    res += "\"".concat(item.default, "\"");
  }

  return res;
};
/**
 * get the array type as string
 * @method getArrayType
 * @param {object} item
 * @param {string} res
 * @returns {string} res  eg: arrayOf(arrayOf(string | number | arrayOf(string | number)))
 */


var getArrayType = function getArrayType(item) {
  var res = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  if (item.type !== 'array') {
    if (Array.isArray(item.type) || isOneOfJsonSchema(item)) {
      return getOrType(item);
    }

    return item.type;
  }

  if (item.type === 'array') {
    res += 'arrayOf('; // eslint-disable-line no-param-reassign
  }

  res += getArrayType(item.items, ''); // eslint-disable-line no-param-reassign

  res += ')'; // eslint-disable-line no-param-reassign

  return res;
};
/**
 * get the type of this option item
 * @method getType
 * @param {ojbect} item option item
 * @returns {string} type
 */


var getType = function getType(item) {
  if (isOneOfJsonSchema(item)) {
    return "oneOf(".concat(getOrType(item), ")");
  }

  if (item.enum && Array.isArray(item.enum)) {
    var values = !lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5___default()(item.enum) && typeof item.enum[0] === 'string' ? item.enum.map(function (v) {
      return "\"".concat(v, "\"");
    }).join(', ') : item.enum.join(', ');
    return "oneOf([".concat(values, "])");
  }

  if (Array.isArray(item.type)) {
    return getOrType(item);
  }

  if (item.type === 'array') {
    if ('items' in item) {
      return "arrayOf(".concat(getType(item.items), ")");
    }

    return 'array';
  }

  return item.type;
};
/**
 * get the default value as string
 * @method getDefaultValue
 * @param {object | boolean | number | string} defaultValue
 * @returns {string | object[]} default value
 */

var getDefaultValue = function getDefaultValue(defaultValue) {
  if (typeof defaultValue === 'boolean' || typeof defaultValue === 'number') {
    return defaultValue.toString();
  }

  if (Array.isArray(defaultValue)) {
    if (defaultValue.length > 1 && _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2___default()(defaultValue[0]) === 'object') {
      // return the array only if the defaultValue is an object array
      return defaultValue;
    }

    var values = defaultValue.map(function (v) {
      return JSON.stringify(v);
    }).join(', ');
    return "[".concat(values, "]");
  }

  return defaultValue;
};

var Pair = function Pair(_ref) {
  var title = _ref.title,
      content = _ref.content;
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PairContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PairTitle, null, "".concat(title, ":")), Array.isArray(content) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PairValueJSON, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("pre", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("code", null, JSON.stringify(content, null, 2)))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PairValue, null, content));
};

Pair.propTypes = {
  title: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string,
  content: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.object)])
};

var PropertyItems = function PropertyItems(_ref2) {
  var _ref2$isPatternProper = _ref2.isPatternProperty,
      isPatternProperty = _ref2$isPatternProper === void 0 ? false : _ref2$isPatternProper,
      propsItems = _ref2.propsItems;
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PropertiesContainer, {
    isPatternProperty: isPatternProperty
  }, isPatternProperty ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PairTitle, null, Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('[fieldName]:')) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PropertiesContent, {
    isPatternProperty: isPatternProperty
  }, propsItems));
};

PropertyItems.propTypes = {
  isPatternProperty: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.bool,
  propsItems: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.array
};

var OptionItem = function OptionItem(_ref3) {
  var name = _ref3.name,
      type = _ref3.type,
      desc = _ref3.desc,
      defaultValue = _ref3.defaultValue,
      enumerable = _ref3.enumerable,
      PropertiesSection = _ref3.PropertiesSection;
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(Option, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(OptionName, null, name), desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(_splunk_react_ui_Markdown__WEBPACK_IMPORTED_MODULE_8___default.a, {
    style: {
      marginLeft: 40
    },
    text: desc
  }) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(Pair, {
    title: Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('Type'),
    content: type
  }), (enumerable === null || enumerable === void 0 ? void 0 : enumerable.length) > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(Pair, {
    title: Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('oneOf'),
    content: "(".concat(enumerable.map(function (entry) {
      return "".concat(typeof entry === 'string' ? '"' : '').concat(entry).concat(typeof entry === 'string' ? '"' : '');
    }).join(' | '), ")")
  }), defaultValue && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(Pair, {
    title: Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_6__["_"])('Default'),
    content: defaultValue
  }), PropertiesSection);
};

OptionItem.propTypes = {
  name: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string,
  type: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string,
  desc: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string,
  enumerable: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.number])),
  defaultValue: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.object)]),
  PropertiesSection: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.element
};
OptionItem.default = {
  PropertiesItem: null
};

var getPropertiesSection = function getPropertiesSection(properties, patternProperties) {
  var allProperties = [];
  var isPatternProperty = false; // the properties either comes from property field of the option schema item
  // or from the property field of each patternProperties of the option schema item
  // can check table tableFormat and columnFormat as examples

  if (!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5___default()(properties)) {
    allProperties = [properties];
  } else if (!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_5___default()(patternProperties)) {
    Object.keys(patternProperties).forEach(function (patternKey) {
      var propsInPattern = patternProperties[patternKey].properties;

      if (propsInPattern) {
        allProperties.push(propsInPattern);
      }
    });
    isPatternProperty = true;
  }

  if (allProperties.length) {
    var allPropsItems = allProperties.map(function (props) {
      var propsItems = Object.keys(props).map(function (pKey) {
        var _p$anyOf, _p$anyOf2, _p$anyOf3, _p$anyOf3$, _p$anyOf4, _p$anyOf4$, _p$anyOf4$$items, _p$anyOf4$$items$enum, _p$anyOf5, _p$anyOf5$, _p$anyOf5$$items, _p$anyOf5$$items$item, _p$anyOf5$$items$item2, _pEnumerable;

        var p = props[pKey];
        var pType = (_p$anyOf = p.anyOf) !== null && _p$anyOf !== void 0 && _p$anyOf[0] ? Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getOptionDisplayType"])(_objectSpread(_objectSpread({}, (_p$anyOf2 = p.anyOf) === null || _p$anyOf2 === void 0 ? void 0 : _p$anyOf2[0]), {}, {
          enum: p.enum
        })) : Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getOptionDisplayType"])(_objectSpread(_objectSpread({}, p), {}, {
          enum: p.enum
        }));
        var pDefault = getDefaultValue(p.default);
        var pEnumerable; // get nested oneOf property listing

        if (typeof ((_p$anyOf3 = p.anyOf) === null || _p$anyOf3 === void 0 ? void 0 : (_p$anyOf3$ = _p$anyOf3[0]) === null || _p$anyOf3$ === void 0 ? void 0 : _p$anyOf3$.pattern) === 'string') {
          pEnumerable = Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getPatternOptions"])(p.anyOf[0].pattern);
        } else if (((_p$anyOf4 = p.anyOf) === null || _p$anyOf4 === void 0 ? void 0 : (_p$anyOf4$ = _p$anyOf4[0]) === null || _p$anyOf4$ === void 0 ? void 0 : (_p$anyOf4$$items = _p$anyOf4$.items) === null || _p$anyOf4$$items === void 0 ? void 0 : (_p$anyOf4$$items$enum = _p$anyOf4$$items.enum) === null || _p$anyOf4$$items$enum === void 0 ? void 0 : _p$anyOf4$$items$enum.length) > 0) {
          // quick fix for nested `columnFormat` enumerables that replaces enums within brackets with raw JS types
          pType = pType.replace(/\((.+?)\)/g, 'string');
          pEnumerable = p.anyOf[0].items.enum;
        } else if (((_p$anyOf5 = p.anyOf) === null || _p$anyOf5 === void 0 ? void 0 : (_p$anyOf5$ = _p$anyOf5[0]) === null || _p$anyOf5$ === void 0 ? void 0 : (_p$anyOf5$$items = _p$anyOf5$.items) === null || _p$anyOf5$$items === void 0 ? void 0 : (_p$anyOf5$$items$item = _p$anyOf5$$items.items) === null || _p$anyOf5$$items$item === void 0 ? void 0 : (_p$anyOf5$$items$item2 = _p$anyOf5$$items$item.enum) === null || _p$anyOf5$$items$item2 === void 0 ? void 0 : _p$anyOf5$$items$item2.length) > 0) {
          // quick fix for nested `tableFormat` enumerables that replaces enums within brackets with raw JS types
          pType = pType.replace(/\((.+?)\)/g, 'string');
          pEnumerable = p.anyOf[0].items.items.enum;
        } else if (p.enum) {
          pEnumerable = p.enum;
        } // use the JS types (e.g. string, number) of the nested property if the nested property is an enumerable


        if ((_pEnumerable = pEnumerable) !== null && _pEnumerable !== void 0 && _pEnumerable.length) {
          var _p$anyOf6, _p$anyOf6$, _p$anyOf7, _p$anyOf7$;

          pType = ((_p$anyOf6 = p.anyOf) === null || _p$anyOf6 === void 0 ? void 0 : (_p$anyOf6$ = _p$anyOf6[0]) === null || _p$anyOf6$ === void 0 ? void 0 : _p$anyOf6$.type) !== 'array' ? (_p$anyOf7 = p.anyOf) === null || _p$anyOf7 === void 0 ? void 0 : (_p$anyOf7$ = _p$anyOf7[0]) === null || _p$anyOf7$ === void 0 ? void 0 : _p$anyOf7$.type : pType;

          if (Array.isArray(pType)) {
            pType = pType.join(' | ');
          }
        }

        return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(OptionItem, {
          key: pKey,
          name: pKey,
          type: pType,
          enumerable: pEnumerable,
          desc: p.description,
          defaultValue: pDefault
        });
      });
      return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PropertyItems, {
        key: propsItems,
        isPatternProperty: isPatternProperty,
        propsItems: propsItems
      });
    });
    return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(PropertiesWrapper, {
      isPatternProperty: isPatternProperty
    }, allPropsItems);
  }

  return null;
};

var OptionsDoc = function OptionsDoc(_ref4) {
  var options = _ref4.options,
      description = _ref4.description;
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", null, options.length === 0 ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(_splunk_react_ui_Heading__WEBPACK_IMPORTED_MODULE_7___default.a, {
    level: 4
  }, " No Options") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(_splunk_react_ui_Heading__WEBPACK_IMPORTED_MODULE_7___default.a, {
    level: 4
  }, "Options"), description && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", null, description), Object.entries(options).map(function (_ref5) {
    var _item$anyOf, _item$anyOf$, _item$anyOf2, _item$anyOf2$, _item$anyOf4, _item$anyOf4$, _item$anyOf5, _item$anyOf5$, _enumerable;

    var _ref6 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_ref5, 2),
        key = _ref6[0],
        item = _ref6[1];

    var type;
    var enumerable = [];
    var PropertiesSection = null; // get oneOf property listing

    if (typeof ((_item$anyOf = item.anyOf) === null || _item$anyOf === void 0 ? void 0 : (_item$anyOf$ = _item$anyOf[0]) === null || _item$anyOf$ === void 0 ? void 0 : _item$anyOf$.pattern) === 'string') {
      enumerable = Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getPatternOptions"])(item.anyOf[0].pattern);
    } else if ((_item$anyOf2 = item.anyOf) !== null && _item$anyOf2 !== void 0 && (_item$anyOf2$ = _item$anyOf2[0]) !== null && _item$anyOf2$ !== void 0 && _item$anyOf2$.enum) {
      var _item$anyOf3, _item$anyOf3$;

      enumerable = (_item$anyOf3 = item.anyOf) === null || _item$anyOf3 === void 0 ? void 0 : (_item$anyOf3$ = _item$anyOf3[0]) === null || _item$anyOf3$ === void 0 ? void 0 : _item$anyOf3$.enum;
    } else if (item.enum) {
      enumerable = item.enum;
    } // get the nested options inside {option}.items.anyof. e.g. 'layers' in Map


    if (((_item$anyOf4 = item.anyOf) === null || _item$anyOf4 === void 0 ? void 0 : (_item$anyOf4$ = _item$anyOf4[0]) === null || _item$anyOf4$ === void 0 ? void 0 : _item$anyOf4$.type) === 'array' && 'anyOf' in ((_item$anyOf5 = item.anyOf) === null || _item$anyOf5 === void 0 ? void 0 : (_item$anyOf5$ = _item$anyOf5[0]) === null || _item$anyOf5$ === void 0 ? void 0 : _item$anyOf5$.items)) {
      var _item$anyOf6, _item$anyOf6$, _item$anyOf6$$items;

      type = Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getOptionDisplayType"])(item);
      var patternProperties = item.patternProperties; // merge the 3 objects together instead of showing the longest options in the array

      var option = (_item$anyOf6 = item.anyOf) === null || _item$anyOf6 === void 0 ? void 0 : (_item$anyOf6$ = _item$anyOf6[0]) === null || _item$anyOf6$ === void 0 ? void 0 : (_item$anyOf6$$items = _item$anyOf6$.items) === null || _item$anyOf6$$items === void 0 ? void 0 : _item$anyOf6$$items.anyOf;
      var mergedOptions = option.reduce(function (prev, next) {
        return Object(lodash__WEBPACK_IMPORTED_MODULE_10__["merge"])(prev, next);
      }, {});
      var properties = mergedOptions.properties;
      PropertiesSection = getPropertiesSection(properties, patternProperties);
      return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(OptionItem, {
        key: key,
        name: key,
        type: type,
        enumerable: enumerable,
        desc: item.description,
        PropertiesSection: PropertiesSection
      });
    }

    if (item.type === 'object') {
      // get properties for object type
      type = item.type;
      var _properties = item.properties;
      var _patternProperties = item.patternProperties;
      PropertiesSection = getPropertiesSection(_properties, _patternProperties);
    } else if ((_enumerable = enumerable) !== null && _enumerable !== void 0 && _enumerable.length) {
      var _item$anyOf7, _item$anyOf7$; // use the JS types (e.g. string, number) of the property if the property is an enumerable


      type = (_item$anyOf7 = item.anyOf) === null || _item$anyOf7 === void 0 ? void 0 : (_item$anyOf7$ = _item$anyOf7[0]) === null || _item$anyOf7$ === void 0 ? void 0 : _item$anyOf7$.type;

      if (Array.isArray(type)) {
        type = type.join(' | ');
      }
    } else {
      type = Object(_storybook_utils_storybookUtils__WEBPACK_IMPORTED_MODULE_11__["getOptionDisplayType"])(_objectSpread(_objectSpread({}, item.anyOf[0]), {}, {
        enum: item.enum
      }));
    }

    return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(OptionItem, {
      key: key,
      name: key // item.anyOf in the config.ts is a tuple which holds [{ type, pattern, items }, { type, pattern: DYNAMIC_OPTIONS_PATTERN }]
      ,
      type: type,
      enumerable: enumerable,
      desc: item.description,
      defaultValue: getDefaultValue(item.default),
      PropertiesSection: PropertiesSection
    });
  }));
};

OptionsDoc.propTypes = {
  options: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.object.isRequired,
  description: prop_types__WEBPACK_IMPORTED_MODULE_4___default.a.string
};
/* harmony default export */ __webpack_exports__["default"] = (OptionsDoc);

/***/ }),

/***/ 86:
/***/ (function(module, exports) {

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

/***/ })

/******/ });
//# sourceMappingURL=OptionsDoc.js.map