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3hB,MA2DT,IAEE,EAAQ,MAAR,CAAyB8e,GACzB,MAAOlK","sources":["webpack://grafana/./public/app/plugins/datasource/elasticsearch/hooks/useStatelessReducer.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/query_def.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/actions.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/state.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/state/actions.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/ElasticsearchQueryContext.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/hooks/useNextId.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/IconButton.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/QueryEditorRow.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/aggregations.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/hooks/useFields.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/styles.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/SettingsEditorContainer.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/hooks/useCreatableSelectPersistedBehaviour.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/DateHistogramSettingsEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/AddRemove.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/actions.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/useDescription.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/BucketAggregationEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/MetricPicker.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/SettingField.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/actions.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/MovingAverageSettingsEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/TopMetricsSettingsEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/useDescription.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/styles.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/components/QueryEditor/index.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/DataLink.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/DataLinks.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/utils.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/LogsConfig.tsx","webpack://grafana/./public/app/plugins/datasource/elasticsearch/elastic_response.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/index_pattern.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/language_provider.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/query_builder.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/datasource.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/module.ts","webpack://grafana/./public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx","webpack://grafana/./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/usePrevious.js","webpack://grafana/../../opt/drone/yarncache/@grafana-aws-sdk-npm-0.0.36-8ab4b07904-c243f7c900.zip/node_modules/@grafana/aws-sdk/dist/index.production.js","webpack://grafana/../../opt/drone/yarncache/@grafana-aws-sdk-npm-0.0.36-8ab4b07904-c243f7c900.zip/node_modules/@grafana/aws-sdk/index.js","webpack://grafana/../../opt/drone/yarncache/lru-cache-npm-6.0.0-b4c8668fe1-f97f499f89.zip/node_modules/lru-cache/index.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/classes/comparator.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/classes/range.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/classes/semver.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/clean.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/cmp.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/coerce.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/compare-build.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/compare-loose.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/compare.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/diff.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/eq.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/gt.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/gte.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/inc.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/lt.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/lte.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/major.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/minor.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/neq.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/parse.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/patch.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/prerelease.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/rcompare.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/rsort.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/satisfies.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/sort.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/functions/valid.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/index.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/internal/constants.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/internal/debug.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/internal/identifiers.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/internal/parse-options.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/internal/re.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/gtr.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/intersects.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/ltr.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/max-satisfying.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/min-satisfying.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/min-version.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/outside.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/simplify.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/subset.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/to-comparators.js","webpack://grafana/../../opt/drone/yarncache/semver-npm-7.3.7-3bfe704194-2fa3e87756.zip/node_modules/semver/ranges/valid.js","webpack://grafana/../../opt/drone/yarncache/yallist-npm-4.0.0-b493d9e907-343617202a.zip/node_modules/yallist/iterator.js","webpack://grafana/../../opt/drone/yarncache/yallist-npm-4.0.0-b493d9e907-343617202a.zip/node_modules/yallist/yallist.js"],"sourcesContent":["import { Action } from '@reduxjs/toolkit';\nimport { createContext, useCallback, useContext } from 'react';\n\nexport type Reducer<S, A extends Action> = (state: S, action: A) => S;\n\nexport const combineReducers =\n <S, A extends Action = Action>(reducers: { [P in keyof S]: Reducer<S[P], A> }) =>\n (state: S, action: A): Partial<S> => {\n const newState = {} as S;\n for (const key in reducers) {\n newState[key] = reducers[key](state[key], action);\n }\n return newState;\n };\n\nexport const useStatelessReducer = <State, A = Action>(\n onChange: (value: State) => void,\n state: State,\n reducer: (state: State, action: A) => State\n) => {\n const dispatch = useCallback(\n (action: A) => {\n onChange(reducer(state, action));\n },\n [onChange, state, reducer]\n );\n\n return dispatch;\n};\n\nexport const DispatchContext = createContext<((action: Action) => void) | undefined>(undefined);\n\nexport const useDispatch = <T extends Action = Action>(): ((action: T) => void) => {\n const dispatch = useContext(DispatchContext);\n\n if (!dispatch) {\n throw new Error('Use DispatchContext first.');\n }\n\n return dispatch;\n};\n","import { PipelineVariable } from '../../aggregations';\n\nexport const defaultPipelineVariable = (name: string): PipelineVariable => ({ name, pipelineAgg: '' });\n\n/**\n * Given an array of pipeline variables generates a new unique pipeline variable name in the form of `var{n}`.\n * The value for `n` is calculated based on the variables names in pipelineVars matching `var{n}`.\n */\nexport const generatePipelineVariableName = (pipelineVars: PipelineVariable[]): string =>\n `var${Math.max(0, ...pipelineVars.map((v) => parseInt(v.name.match('^var(\\\\d+)$')?.[1] || '0', 10))) + 1}`;\n","import { metricAggregationConfig } from './utils';\n\nexport type PipelineMetricAggregationType =\n | 'moving_avg'\n | 'moving_fn'\n | 'derivative'\n | 'serial_diff'\n | 'cumulative_sum'\n | 'bucket_script';\n\nexport type MetricAggregationType =\n | 'count'\n | 'avg'\n | 'sum'\n | 'min'\n | 'max'\n | 'extended_stats'\n | 'percentiles'\n | 'cardinality'\n | 'raw_document'\n | 'raw_data'\n | 'logs'\n | 'rate'\n | 'top_metrics'\n | PipelineMetricAggregationType;\n\ninterface BaseMetricAggregation {\n id: string;\n type: MetricAggregationType;\n hide?: boolean;\n}\n\nexport interface PipelineVariable {\n name: string;\n pipelineAgg: string;\n}\n\nexport interface MetricAggregationWithField extends BaseMetricAggregation {\n field?: string;\n}\n\nexport interface MetricAggregationWithMissingSupport extends BaseMetricAggregation {\n settings?: {\n missing?: string;\n };\n}\n\ntype InlineScript = string | { inline?: string };\nexport interface MetricAggregationWithInlineScript extends BaseMetricAggregation {\n settings?: {\n script?: InlineScript;\n };\n}\n\nexport interface Count extends BaseMetricAggregation {\n type: 'count';\n}\n\nexport interface Average\n extends MetricAggregationWithField,\n MetricAggregationWithMissingSupport,\n MetricAggregationWithInlineScript {\n type: 'avg';\n settings?: {\n script?: InlineScript;\n missing?: string;\n };\n}\n\nexport interface Sum extends MetricAggregationWithField, MetricAggregationWithInlineScript {\n type: 'sum';\n settings?: {\n script?: InlineScript;\n missing?: string;\n };\n}\n\nexport interface Max extends MetricAggregationWithField, MetricAggregationWithInlineScript {\n type: 'max';\n settings?: {\n script?: InlineScript;\n missing?: string;\n };\n}\n\nexport interface Min extends MetricAggregationWithField, MetricAggregationWithInlineScript {\n type: 'min';\n settings?: {\n script?: InlineScript;\n missing?: string;\n };\n}\n\nexport type ExtendedStatMetaType =\n | 'avg'\n | 'min'\n | 'max'\n | 'sum'\n | 'count'\n | 'std_deviation'\n | 'std_deviation_bounds_upper'\n | 'std_deviation_bounds_lower';\nexport interface ExtendedStat {\n label: string;\n value: ExtendedStatMetaType;\n}\n\nexport interface ExtendedStats extends MetricAggregationWithField, MetricAggregationWithInlineScript {\n type: 'extended_stats';\n settings?: {\n script?: InlineScript;\n missing?: string;\n sigma?: string;\n };\n meta?: {\n [P in ExtendedStatMetaType]?: boolean;\n };\n}\n\nexport interface Percentiles extends MetricAggregationWithField, MetricAggregationWithInlineScript {\n type: 'percentiles';\n settings?: {\n percents?: string[];\n script?: InlineScript;\n missing?: string;\n };\n}\n\nexport interface UniqueCount extends MetricAggregationWithField {\n type: 'cardinality';\n settings?: {\n precision_threshold?: string;\n missing?: string;\n };\n}\n\nexport interface RawDocument extends BaseMetricAggregation {\n type: 'raw_document';\n settings?: {\n size?: string;\n };\n}\n\nexport interface RawData extends BaseMetricAggregation {\n type: 'raw_data';\n settings?: {\n size?: string;\n };\n}\n\nexport interface Logs extends BaseMetricAggregation {\n type: 'logs';\n settings?: {\n limit?: string;\n };\n}\n\nexport interface Rate extends MetricAggregationWithField {\n type: 'rate';\n settings?: {\n unit?: string;\n mode?: string;\n };\n}\n\nexport interface BasePipelineMetricAggregation extends MetricAggregationWithField {\n type: PipelineMetricAggregationType;\n pipelineAgg?: string;\n}\n\nexport interface PipelineMetricAggregationWithMultipleBucketPaths extends BaseMetricAggregation {\n type: PipelineMetricAggregationType;\n pipelineVariables?: PipelineVariable[];\n}\n\nexport type MovingAverageModel = 'simple' | 'linear' | 'ewma' | 'holt' | 'holt_winters';\n\nexport interface MovingAverageModelOption {\n label: string;\n value: MovingAverageModel;\n}\n\nexport interface BaseMovingAverageModelSettings {\n model: MovingAverageModel;\n window: string;\n predict: string;\n}\n\nexport interface MovingAverageSimpleModelSettings extends BaseMovingAverageModelSettings {\n model: 'simple';\n}\n\nexport interface MovingAverageLinearModelSettings extends BaseMovingAverageModelSettings {\n model: 'linear';\n}\n\nexport interface MovingAverageEWMAModelSettings extends BaseMovingAverageModelSettings {\n model: 'ewma';\n settings?: {\n alpha?: string;\n };\n minimize: boolean;\n}\n\nexport interface MovingAverageHoltModelSettings extends BaseMovingAverageModelSettings {\n model: 'holt';\n settings: {\n alpha?: string;\n beta?: string;\n };\n minimize: boolean;\n}\n\nexport interface MovingAverageHoltWintersModelSettings extends BaseMovingAverageModelSettings {\n model: 'holt_winters';\n settings: {\n alpha?: string;\n beta?: string;\n gamma?: string;\n period?: string;\n pad?: boolean;\n };\n minimize: boolean;\n}\n\nexport type MovingAverageModelSettings<T extends MovingAverageModel = MovingAverageModel> = Partial<\n Extract<\n | MovingAverageSimpleModelSettings\n | MovingAverageLinearModelSettings\n | MovingAverageEWMAModelSettings\n | MovingAverageHoltModelSettings\n | MovingAverageHoltWintersModelSettings,\n { model: T }\n >\n>;\n\nexport interface MovingAverage<T extends MovingAverageModel = MovingAverageModel>\n extends BasePipelineMetricAggregation {\n type: 'moving_avg';\n settings?: MovingAverageModelSettings<T>;\n}\n\nexport const isEWMAMovingAverage = (metric: MovingAverage | MovingAverage<'ewma'>): metric is MovingAverage<'ewma'> =>\n metric.settings?.model === 'ewma';\n\nexport const isHoltMovingAverage = (metric: MovingAverage | MovingAverage<'holt'>): metric is MovingAverage<'holt'> =>\n metric.settings?.model === 'holt';\n\nexport const isHoltWintersMovingAverage = (\n metric: MovingAverage | MovingAverage<'holt_winters'>\n): metric is MovingAverage<'holt_winters'> => metric.settings?.model === 'holt_winters';\n\nexport const isMovingAverageWithModelSettings = (\n metric: MovingAverage\n): metric is MovingAverage<'ewma'> | MovingAverage<'holt'> | MovingAverage<'holt_winters'> =>\n ['holt', 'ewma', 'holt_winters'].includes(metric.settings?.model || '');\n\nexport interface MovingFunction extends BasePipelineMetricAggregation {\n type: 'moving_fn';\n settings?: {\n window?: string;\n script?: InlineScript;\n shift?: string;\n };\n}\n\nexport interface Derivative extends BasePipelineMetricAggregation {\n type: 'derivative';\n settings?: {\n unit?: string;\n };\n}\n\nexport interface SerialDiff extends BasePipelineMetricAggregation {\n type: 'serial_diff';\n settings?: {\n lag?: string;\n };\n}\n\nexport interface CumulativeSum extends BasePipelineMetricAggregation {\n type: 'cumulative_sum';\n settings?: {\n format?: string;\n };\n}\n\nexport interface BucketScript extends PipelineMetricAggregationWithMultipleBucketPaths {\n type: 'bucket_script';\n settings?: {\n script?: InlineScript;\n };\n}\n\nexport interface TopMetrics extends BaseMetricAggregation {\n type: 'top_metrics';\n settings?: {\n order?: string;\n orderBy?: string;\n metrics?: string[];\n };\n}\n\ntype PipelineMetricAggregation = MovingAverage | Derivative | CumulativeSum | BucketScript;\n\nexport type MetricAggregationWithSettings =\n | BucketScript\n | CumulativeSum\n | Derivative\n | SerialDiff\n | RawData\n | RawDocument\n | UniqueCount\n | Percentiles\n | ExtendedStats\n | Min\n | Max\n | Sum\n | Average\n | MovingAverage\n | MovingFunction\n | Logs\n | Rate\n | TopMetrics;\n\nexport type MetricAggregationWithMeta = ExtendedStats;\n\nexport type MetricAggregation = Count | PipelineMetricAggregation | MetricAggregationWithSettings;\n\n// Guards\n// Given the structure of the aggregations (ie. `settings` field being always optional) we cannot\n// determine types based solely on objects' properties, therefore we use `metricAggregationConfig` as the\n// source of truth.\n\n/**\n * Checks if `metric` requires a field (either referring to a document or another aggregation)\n * @param metric\n */\nexport const isMetricAggregationWithField = (\n metric: BaseMetricAggregation | MetricAggregationWithField\n): metric is MetricAggregationWithField => metricAggregationConfig[metric.type].requiresField;\n\nexport const isPipelineAggregation = (\n metric: BaseMetricAggregation | PipelineMetricAggregation\n): metric is PipelineMetricAggregation => metricAggregationConfig[metric.type].isPipelineAgg;\n\nexport const isPipelineAggregationWithMultipleBucketPaths = (\n metric: BaseMetricAggregation | PipelineMetricAggregationWithMultipleBucketPaths\n): metric is PipelineMetricAggregationWithMultipleBucketPaths =>\n metricAggregationConfig[metric.type].supportsMultipleBucketPaths;\n\nexport const isMetricAggregationWithMissingSupport = (\n metric: BaseMetricAggregation | MetricAggregationWithMissingSupport\n): metric is MetricAggregationWithMissingSupport => metricAggregationConfig[metric.type].supportsMissing;\n\nexport const isMetricAggregationWithSettings = (\n metric: BaseMetricAggregation | MetricAggregationWithSettings\n): metric is MetricAggregationWithSettings => metricAggregationConfig[metric.type].hasSettings;\n\nexport const isMetricAggregationWithMeta = (\n metric: BaseMetricAggregation | MetricAggregationWithMeta\n): metric is MetricAggregationWithMeta => metricAggregationConfig[metric.type].hasMeta;\n\nexport const isMetricAggregationWithInlineScript = (\n metric: BaseMetricAggregation | MetricAggregationWithInlineScript\n): metric is MetricAggregationWithInlineScript => metricAggregationConfig[metric.type].supportsInlineScript;\n\nexport const METRIC_AGGREGATION_TYPES: MetricAggregationType[] = [\n 'count',\n 'avg',\n 'sum',\n 'min',\n 'max',\n 'extended_stats',\n 'percentiles',\n 'cardinality',\n 'raw_document',\n 'raw_data',\n 'logs',\n 'moving_avg',\n 'moving_fn',\n 'derivative',\n 'serial_diff',\n 'cumulative_sum',\n 'bucket_script',\n 'rate',\n 'top_metrics',\n];\n\nexport const isMetricAggregationType = (s: MetricAggregationType | string): s is MetricAggregationType =>\n METRIC_AGGREGATION_TYPES.includes(s as MetricAggregationType);\n","import { MetricsConfiguration } from '../../../types';\n\nimport {\n defaultPipelineVariable,\n generatePipelineVariableName,\n} from './SettingsEditor/BucketScriptSettingsEditor/utils';\nimport {\n isMetricAggregationWithField,\n isPipelineAggregationWithMultipleBucketPaths,\n MetricAggregation,\n PipelineMetricAggregationType,\n} from './aggregations';\n\nexport const metricAggregationConfig: MetricsConfiguration = {\n count: {\n label: 'Count',\n requiresField: false,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: false,\n hasMeta: false,\n supportsInlineScript: false,\n defaults: {},\n },\n avg: {\n label: 'Average',\n requiresField: true,\n supportsInlineScript: true,\n supportsMissing: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: false,\n defaults: {},\n },\n sum: {\n label: 'Sum',\n requiresField: true,\n supportsInlineScript: true,\n supportsMissing: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: false,\n defaults: {},\n },\n max: {\n label: 'Max',\n requiresField: true,\n supportsInlineScript: true,\n supportsMissing: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: false,\n defaults: {},\n },\n min: {\n label: 'Min',\n requiresField: true,\n supportsInlineScript: true,\n supportsMissing: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: false,\n defaults: {},\n },\n extended_stats: {\n label: 'Extended Stats',\n requiresField: true,\n supportsMissing: true,\n supportsInlineScript: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: true,\n defaults: {\n meta: {\n std_deviation_bounds_lower: true,\n std_deviation_bounds_upper: true,\n },\n },\n },\n percentiles: {\n label: 'Percentiles',\n requiresField: true,\n supportsMissing: true,\n supportsInlineScript: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n hasMeta: false,\n defaults: {\n settings: {\n percents: ['25', '50', '75', '95', '99'],\n },\n },\n },\n cardinality: {\n label: 'Unique Count',\n requiresField: true,\n supportsMissing: true,\n isPipelineAgg: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {},\n },\n moving_avg: {\n label: 'Moving Average',\n requiresField: true,\n isPipelineAgg: true,\n versionRange: '>=2.0.0 <8.0.0',\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n settings: {\n model: 'simple',\n window: '5',\n },\n },\n },\n moving_fn: {\n // TODO: Check this\n label: 'Moving Function',\n requiresField: true,\n isPipelineAgg: true,\n supportsMultipleBucketPaths: false,\n supportsInlineScript: false,\n supportsMissing: false,\n hasMeta: false,\n hasSettings: true,\n versionRange: '>=7.0.0',\n defaults: {},\n },\n derivative: {\n label: 'Derivative',\n requiresField: true,\n isPipelineAgg: true,\n versionRange: '>=2.0.0',\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {},\n },\n serial_diff: {\n label: 'Serial Difference',\n requiresField: true,\n isPipelineAgg: true,\n versionRange: '>=2.0.0',\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n settings: {\n lag: '1',\n },\n },\n },\n cumulative_sum: {\n label: 'Cumulative Sum',\n requiresField: true,\n isPipelineAgg: true,\n versionRange: '>=2.0.0',\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {},\n },\n bucket_script: {\n label: 'Bucket Script',\n requiresField: false,\n isPipelineAgg: true,\n supportsMissing: false,\n supportsMultipleBucketPaths: true,\n versionRange: '>=2.0.0',\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n pipelineVariables: [defaultPipelineVariable(generatePipelineVariableName([]))],\n },\n },\n raw_document: {\n label: 'Raw Document (legacy)',\n requiresField: false,\n isSingleMetric: true,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n settings: {\n size: '500',\n },\n },\n },\n raw_data: {\n label: 'Raw Data',\n requiresField: false,\n isSingleMetric: true,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n settings: {\n size: '500',\n },\n },\n },\n logs: {\n label: 'Logs',\n requiresField: false,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n isSingleMetric: true,\n supportsInlineScript: false,\n hasMeta: false,\n defaults: {\n settings: {\n limit: '500',\n },\n },\n },\n top_metrics: {\n label: 'Top Metrics',\n xpack: true,\n requiresField: false,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: false,\n versionRange: '>=7.7.0',\n hasMeta: false,\n defaults: {\n settings: {\n order: 'desc',\n },\n },\n },\n rate: {\n label: 'Rate',\n xpack: true,\n versionRange: '>=7.10.0',\n requiresField: true,\n isPipelineAgg: false,\n supportsMissing: false,\n supportsMultipleBucketPaths: false,\n hasSettings: true,\n supportsInlineScript: true,\n hasMeta: false,\n defaults: {},\n },\n};\n\ninterface PipelineOption {\n label: string;\n default?: string | number | boolean;\n}\n\ntype PipelineOptions = {\n [K in PipelineMetricAggregationType]: PipelineOption[];\n};\n\nexport const pipelineOptions: PipelineOptions = {\n moving_avg: [\n { label: 'window', default: 5 },\n { label: 'model', default: 'simple' },\n { label: 'predict' },\n { label: 'minimize', default: false },\n ],\n moving_fn: [{ label: 'window', default: 5 }, { label: 'script' }],\n derivative: [{ label: 'unit' }],\n serial_diff: [{ label: 'lag' }],\n cumulative_sum: [{ label: 'format' }],\n bucket_script: [],\n};\n\n/**\n * Given a metric `MetricA` and an array of metrics, returns all children of `MetricA`.\n * `MetricB` is considered a child of `MetricA` if `MetricA` is referenced by `MetricB` in it's `field` attribute\n * (`MetricA.id === MetricB.field`) or in it's pipeline aggregation variables (for bucket_scripts).\n * @param metric\n * @param metrics\n */\nexport const getChildren = (metric: MetricAggregation, metrics: MetricAggregation[]): MetricAggregation[] => {\n const children = metrics.filter((m) => {\n // TODO: Check this.\n if (isPipelineAggregationWithMultipleBucketPaths(m)) {\n return m.pipelineVariables?.some((pv) => pv.pipelineAgg === metric.id);\n }\n\n return isMetricAggregationWithField(m) && metric.id === m.field;\n });\n\n return [...children, ...children.flatMap((child) => getChildren(child, metrics))];\n};\n","import { DateHistogram } from './components/QueryEditor/BucketAggregationsEditor/aggregations';\nimport {\n ExtendedStat,\n MetricAggregation,\n MovingAverageModelOption,\n MetricAggregationType,\n} from './components/QueryEditor/MetricAggregationsEditor/aggregations';\nimport { metricAggregationConfig, pipelineOptions } from './components/QueryEditor/MetricAggregationsEditor/utils';\nimport { ElasticsearchQuery } from './types';\n\nexport const extendedStats: ExtendedStat[] = [\n { label: 'Avg', value: 'avg' },\n { label: 'Min', value: 'min' },\n { label: 'Max', value: 'max' },\n { label: 'Sum', value: 'sum' },\n { label: 'Count', value: 'count' },\n { label: 'Std Dev', value: 'std_deviation' },\n { label: 'Std Dev Upper', value: 'std_deviation_bounds_upper' },\n { label: 'Std Dev Lower', value: 'std_deviation_bounds_lower' },\n];\n\nexport const movingAvgModelOptions: MovingAverageModelOption[] = [\n { label: 'Simple', value: 'simple' },\n { label: 'Linear', value: 'linear' },\n { label: 'Exponentially Weighted', value: 'ewma' },\n { label: 'Holt Linear', value: 'holt' },\n { label: 'Holt Winters', value: 'holt_winters' },\n];\n\nexport const highlightTags = {\n pre: '@HIGHLIGHT@',\n post: '@/HIGHLIGHT@',\n};\n\nexport function defaultMetricAgg(id = '1'): MetricAggregation {\n return { type: 'count', id };\n}\n\nexport function defaultBucketAgg(id = '1'): DateHistogram {\n return { type: 'date_histogram', id, settings: { interval: 'auto' } };\n}\n\nexport const findMetricById = (metrics: MetricAggregation[], id: MetricAggregation['id']) =>\n metrics.find((metric) => metric.id === id);\n\nexport function hasMetricOfType(target: ElasticsearchQuery, type: MetricAggregationType): boolean {\n return !!target?.metrics?.some((m) => m.type === type);\n}\n\n// Even if we have type guards when building a query, we currently have no way of getting this information from the response.\n// We should try to find a better (type safe) way of doing the following 2.\nexport function isPipelineAgg(metricType: MetricAggregationType) {\n return metricType in pipelineOptions;\n}\n\nexport function isPipelineAggWithMultipleBucketPaths(metricType: MetricAggregationType) {\n return !!metricAggregationConfig[metricType].supportsMultipleBucketPaths;\n}\n","import { valid, gte } from 'semver';\n\nimport {\n isMetricAggregationWithField,\n MetricAggregation,\n MetricAggregationWithInlineScript,\n} from './components/QueryEditor/MetricAggregationsEditor/aggregations';\nimport { metricAggregationConfig } from './components/QueryEditor/MetricAggregationsEditor/utils';\n\nexport const describeMetric = (metric: MetricAggregation) => {\n if (!isMetricAggregationWithField(metric)) {\n return metricAggregationConfig[metric.type].label;\n }\n\n // TODO: field might be undefined\n return `${metricAggregationConfig[metric.type].label} ${metric.field}`;\n};\n\n/**\n * Utility function to clean up aggregations settings objects.\n * It removes nullish values and empty strings, array and objects\n * recursing over nested objects (not arrays).\n * @param obj\n */\nexport const removeEmpty = <T>(obj: T): Partial<T> =>\n Object.entries(obj).reduce((acc, [key, value]) => {\n // Removing nullish values (null & undefined)\n if (value == null) {\n return { ...acc };\n }\n\n // Removing empty arrays (This won't recurse the array)\n if (Array.isArray(value) && value.length === 0) {\n return { ...acc };\n }\n\n // Removing empty strings\n if (value?.length === 0) {\n return { ...acc };\n }\n\n // Recursing over nested objects\n if (!Array.isArray(value) && typeof value === 'object') {\n const cleanObj = removeEmpty(value);\n\n if (Object.keys(cleanObj).length === 0) {\n return { ...acc };\n }\n\n return { ...acc, [key]: cleanObj };\n }\n\n return {\n ...acc,\n [key]: value,\n };\n }, {});\n\n/**\n * This function converts an order by string to the correct metric id For example,\n * if the user uses the standard deviation extended stat for the order by,\n * the value would be \"1[std_deviation]\" and this would return \"1\"\n */\nexport const convertOrderByToMetricId = (orderBy: string): string | undefined => {\n const metricIdMatches = orderBy.match(/^(\\d+)/);\n return metricIdMatches ? metricIdMatches[1] : void 0;\n};\n\n/** Gets the actual script value for metrics that support inline scripts.\n *\n * This is needed because the `script` is a bit polymorphic.\n * when creating a query with Grafana < 7.4 it was stored as:\n * ```json\n * {\n * \"settings\": {\n * \"script\": {\n * \"inline\": \"value\"\n * }\n * }\n * }\n * ```\n *\n * while from 7.4 it's stored as\n * ```json\n * {\n * \"settings\": {\n * \"script\": \"value\"\n * }\n * }\n * ```\n *\n * This allows us to access both formats and support both queries created before 7.4 and after.\n */\nexport const getScriptValue = (metric: MetricAggregationWithInlineScript) =>\n (typeof metric.settings?.script === 'object' ? metric.settings?.script?.inline : metric.settings?.script) || '';\n\n/**\n * Coerces the a version string/number to a valid semver string.\n * It takes care of also converting from the legacy format (numeric) to the new one.\n * @param version\n */\nexport const coerceESVersion = (version: string | number): string => {\n if (typeof version === 'string') {\n return valid(version) || '5.0.0';\n }\n\n switch (version) {\n case 2:\n return '2.0.0';\n case 56:\n return '5.6.0';\n case 60:\n return '6.0.0';\n case 70:\n return '7.0.0';\n case 5:\n default:\n return '5.0.0';\n }\n};\n\nexport const isSupportedVersion = (version: string): boolean => {\n if (gte(version, '7.10.0')) {\n return true;\n }\n\n return false;\n};\n","import { createAction } from '@reduxjs/toolkit';\n\nimport { MetricAggregation, MetricAggregationWithMeta, MetricAggregationWithSettings } from '../aggregations';\n\nexport const addMetric = createAction<MetricAggregation['id']>('@metrics/add');\nexport const removeMetric = createAction<MetricAggregation['id']>('@metrics/remove');\nexport const toggleMetricVisibility = createAction<MetricAggregation['id']>('@metrics/toggle_visibility');\nexport const changeMetricField = createAction<{ id: MetricAggregation['id']; field: string }>('@metrics/change_field');\nexport const changeMetricType = createAction<{ id: MetricAggregation['id']; type: MetricAggregation['type'] }>(\n '@metrics/change_type'\n);\nexport const changeMetricAttribute = createAction<{ metric: MetricAggregation; attribute: string; newValue: any }>(\n '@metrics/change_attr'\n);\nexport const changeMetricSetting = createAction<{\n metric: MetricAggregationWithSettings;\n settingName: string;\n newValue: any;\n}>('@metrics/change_setting');\nexport const changeMetricMeta = createAction<{\n metric: MetricAggregationWithMeta;\n meta: string;\n newValue: any;\n}>('@metrics/change_meta');\n","import { Action, createAction } from '@reduxjs/toolkit';\n\nimport { ElasticsearchQuery } from '../../types';\n\n/**\n * When the `initQuery` Action is dispatched, the query gets populated with default values where values are not present.\n * This means it won't override any existing value in place, but just ensure the query is in a \"runnable\" state.\n */\nexport const initQuery = createAction('init');\n\nexport const changeQuery = createAction<ElasticsearchQuery['query']>('change_query');\n\nexport const changeAliasPattern = createAction<ElasticsearchQuery['alias']>('change_alias_pattern');\n\nexport const queryReducer = (prevQuery: ElasticsearchQuery['query'], action: Action) => {\n if (changeQuery.match(action)) {\n return action.payload;\n }\n\n if (initQuery.match(action)) {\n return prevQuery || '';\n }\n\n return prevQuery;\n};\n\nexport const aliasPatternReducer = (prevAliasPattern: ElasticsearchQuery['alias'], action: Action) => {\n if (changeAliasPattern.match(action)) {\n return action.payload;\n }\n\n if (initQuery.match(action)) {\n return prevAliasPattern || '';\n }\n\n return prevAliasPattern;\n};\n","import { InternalTimeZones, SelectableValue } from '@grafana/data';\n\nimport { BucketsConfiguration } from '../../../types';\n\nimport { defaultFilter } from './SettingsEditor/FiltersSettingsEditor/utils';\n\nexport const bucketAggregationConfig: BucketsConfiguration = {\n terms: {\n label: 'Terms',\n requiresField: true,\n defaultSettings: {\n min_doc_count: '1',\n size: '10',\n order: 'desc',\n orderBy: '_term',\n },\n },\n filters: {\n label: 'Filters',\n requiresField: false,\n defaultSettings: {\n filters: [defaultFilter()],\n },\n },\n geohash_grid: {\n label: 'Geo Hash Grid',\n requiresField: true,\n defaultSettings: {\n precision: '3',\n },\n },\n date_histogram: {\n label: 'Date Histogram',\n requiresField: true,\n defaultSettings: {\n interval: 'auto',\n min_doc_count: '0',\n trimEdges: '0',\n timeZone: InternalTimeZones.utc,\n },\n },\n histogram: {\n label: 'Histogram',\n requiresField: true,\n defaultSettings: {\n interval: '1000',\n min_doc_count: '0',\n },\n },\n};\n\nexport const orderByOptions: Array<SelectableValue<string>> = [\n { label: 'Term value', value: '_term' },\n { label: 'Doc Count', value: '_count' },\n];\n\nexport const orderOptions: Array<SelectableValue<string>> = [\n { label: 'Top', value: 'desc' },\n { label: 'Bottom', value: 'asc' },\n];\n\nexport const sizeOptions = [\n { label: 'No limit', value: '0' },\n { label: '1', value: '1' },\n { label: '2', value: '2' },\n { label: '3', value: '3' },\n { label: '5', value: '5' },\n { label: '10', value: '10' },\n { label: '15', value: '15' },\n { label: '20', value: '20' },\n];\n","import { Filter } from '../../aggregations';\n\nexport const defaultFilter = (): Filter => ({ label: '', query: '*' });\n","import { createAction } from '@reduxjs/toolkit';\n\nimport { BucketAggregation, BucketAggregationType, BucketAggregationWithField } from '../aggregations';\n\nexport const addBucketAggregation = createAction<BucketAggregation['id']>('@bucketAggs/add');\nexport const removeBucketAggregation = createAction<BucketAggregation['id']>('@bucketAggs/remove');\nexport const changeBucketAggregationType = createAction<{\n id: BucketAggregation['id'];\n newType: BucketAggregationType;\n}>('@bucketAggs/change_type');\nexport const changeBucketAggregationField = createAction<{\n id: BucketAggregation['id'];\n newField: BucketAggregationWithField['field'];\n}>('@bucketAggs/change_field');\nexport const changeBucketAggregationSetting = createAction<{\n bucketAgg: BucketAggregation;\n settingName: string;\n newValue: any;\n}>('@bucketAggs/change_setting');\n","import { Action } from '@reduxjs/toolkit';\n\nimport { defaultMetricAgg } from '../../../../query_def';\nimport { ElasticsearchQuery } from '../../../../types';\nimport { removeEmpty } from '../../../../utils';\nimport { initQuery } from '../../state';\nimport {\n isMetricAggregationWithMeta,\n isMetricAggregationWithSettings,\n isPipelineAggregation,\n MetricAggregation,\n} from '../aggregations';\nimport { getChildren, metricAggregationConfig } from '../utils';\n\nimport {\n addMetric,\n changeMetricAttribute,\n changeMetricField,\n changeMetricMeta,\n changeMetricSetting,\n changeMetricType,\n removeMetric,\n toggleMetricVisibility,\n} from './actions';\n\nexport const reducer = (state: ElasticsearchQuery['metrics'], action: Action): ElasticsearchQuery['metrics'] => {\n if (addMetric.match(action)) {\n return [...state!, defaultMetricAgg(action.payload)];\n }\n\n if (removeMetric.match(action)) {\n const metricToRemove = state!.find((m) => m.id === action.payload)!;\n const metricsToRemove = [metricToRemove, ...getChildren(metricToRemove, state!)];\n const resultingMetrics = state!.filter((metric) => !metricsToRemove.some((toRemove) => toRemove.id === metric.id));\n if (resultingMetrics.length === 0) {\n return [defaultMetricAgg('1')];\n }\n return resultingMetrics;\n }\n\n if (changeMetricType.match(action)) {\n return state!\n .filter((metric) =>\n // When the new metric type is `isSingleMetric` we remove all other metrics from the query\n // leaving only the current one.\n !!metricAggregationConfig[action.payload.type].isSingleMetric ? metric.id === action.payload.id : true\n )\n .map((metric) => {\n if (metric.id !== action.payload.id) {\n return metric;\n }\n\n /*\n TODO: The previous version of the query editor was keeping some of the old metric's configurations\n in the new selected one (such as field or some settings).\n It the future would be nice to have the same behavior but it's hard without a proper definition,\n as Elasticsearch will error sometimes if some settings are not compatible.\n */\n return {\n id: metric.id,\n type: action.payload.type,\n ...metricAggregationConfig[action.payload.type].defaults,\n } as MetricAggregation;\n });\n }\n\n if (changeMetricField.match(action)) {\n return state!.map((metric) => {\n if (metric.id !== action.payload.id) {\n return metric;\n }\n\n const newMetric = {\n ...metric,\n field: action.payload.field,\n };\n\n if (isPipelineAggregation(metric)) {\n return { ...newMetric, pipelineAgg: action.payload.field };\n }\n\n return newMetric;\n });\n }\n\n if (toggleMetricVisibility.match(action)) {\n return state!.map((metric) => {\n if (metric.id !== action.payload) {\n return metric;\n }\n\n return {\n ...metric,\n hide: !metric.hide,\n };\n });\n }\n\n if (changeMetricSetting.match(action)) {\n return state!.map((metric) => {\n if (metric.id !== action.payload.metric.id) {\n return metric;\n }\n\n // TODO: Here, instead of this if statement, we should assert that metric is MetricAggregationWithSettings\n if (isMetricAggregationWithSettings(metric)) {\n const newSettings = removeEmpty({\n ...metric.settings,\n [action.payload.settingName]: action.payload.newValue,\n });\n\n return {\n ...metric,\n settings: {\n ...newSettings,\n },\n };\n }\n\n // This should never happen.\n return metric;\n });\n }\n\n if (changeMetricMeta.match(action)) {\n return state!.map((metric) => {\n if (metric.id !== action.payload.metric.id) {\n return metric;\n }\n\n // TODO: Here, instead of this if statement, we should assert that metric is MetricAggregationWithMeta\n if (isMetricAggregationWithMeta(metric)) {\n return {\n ...metric,\n meta: {\n ...metric.meta,\n [action.payload.meta]: action.payload.newValue,\n },\n };\n }\n\n // This should never happen.\n return metric;\n });\n }\n\n if (changeMetricAttribute.match(action)) {\n return state!.map((metric) => {\n if (metric.id !== action.payload.metric.id) {\n return metric;\n }\n\n return {\n ...metric,\n [action.payload.attribute]: action.payload.newValue,\n };\n });\n }\n\n if (initQuery.match(action)) {\n if (state?.length || 0 > 0) {\n return state;\n }\n return [defaultMetricAgg('1')];\n }\n\n return state;\n};\n","import React, { Context, createContext, PropsWithChildren, useCallback, useContext } from 'react';\n\nimport { TimeRange } from '@grafana/data';\n\nimport { ElasticDatasource } from '../../datasource';\nimport { combineReducers, useStatelessReducer, DispatchContext } from '../../hooks/useStatelessReducer';\nimport { ElasticsearchQuery } from '../../types';\n\nimport { createReducer as createBucketAggsReducer } from './BucketAggregationsEditor/state/reducer';\nimport { reducer as metricsReducer } from './MetricAggregationsEditor/state/reducer';\nimport { aliasPatternReducer, queryReducer, initQuery } from './state';\n\nconst DatasourceContext = createContext<ElasticDatasource | undefined>(undefined);\nconst QueryContext = createContext<ElasticsearchQuery | undefined>(undefined);\nconst RangeContext = createContext<TimeRange | undefined>(undefined);\n\ninterface Props {\n query: ElasticsearchQuery;\n onChange: (query: ElasticsearchQuery) => void;\n onRunQuery: () => void;\n datasource: ElasticDatasource;\n range: TimeRange;\n}\n\nexport const ElasticsearchProvider = ({\n children,\n onChange,\n onRunQuery,\n query,\n datasource,\n range,\n}: PropsWithChildren<Props>) => {\n const onStateChange = useCallback(\n (query: ElasticsearchQuery) => {\n onChange(query);\n onRunQuery();\n },\n [onChange, onRunQuery]\n );\n\n const reducer = combineReducers<Pick<ElasticsearchQuery, 'query' | 'alias' | 'metrics' | 'bucketAggs'>>({\n query: queryReducer,\n alias: aliasPatternReducer,\n metrics: metricsReducer,\n bucketAggs: createBucketAggsReducer(datasource.timeField),\n });\n\n const dispatch = useStatelessReducer(\n // timeField is part of the query model, but its value is always set to be the one from datasource settings.\n (newState) => onStateChange({ ...query, ...newState, timeField: datasource.timeField }),\n query,\n reducer\n );\n\n // This initializes the query by dispatching an init action to each reducer.\n // useStatelessReducer will then call `onChange` with the newly generated query\n if (!query.metrics || !query.bucketAggs || query.query === undefined) {\n dispatch(initQuery());\n\n return null;\n }\n\n return (\n <DatasourceContext.Provider value={datasource}>\n <QueryContext.Provider value={query}>\n <RangeContext.Provider value={range}>\n <DispatchContext.Provider value={dispatch}>{children}</DispatchContext.Provider>\n </RangeContext.Provider>\n </QueryContext.Provider>\n </DatasourceContext.Provider>\n );\n};\n\ninterface GetHook {\n <T>(context: Context<T>): () => NonNullable<T>;\n}\n\nconst getHook: GetHook = (c) => () => {\n const contextValue = useContext(c);\n\n if (!contextValue) {\n throw new Error('use ElasticsearchProvider first.');\n }\n\n return contextValue as NonNullable<typeof contextValue>;\n};\n\nexport const useQuery = getHook(QueryContext);\nexport const useDatasource = getHook(DatasourceContext);\nexport const useRange = getHook(RangeContext);\n","import { Action } from '@reduxjs/toolkit';\n\nimport { defaultBucketAgg } from '../../../../query_def';\nimport { ElasticsearchQuery } from '../../../../types';\nimport { removeEmpty } from '../../../../utils';\nimport { changeMetricType } from '../../MetricAggregationsEditor/state/actions';\nimport { metricAggregationConfig } from '../../MetricAggregationsEditor/utils';\nimport { initQuery } from '../../state';\nimport { BucketAggregation, Terms } from '../aggregations';\nimport { bucketAggregationConfig } from '../utils';\n\nimport {\n addBucketAggregation,\n changeBucketAggregationField,\n changeBucketAggregationSetting,\n changeBucketAggregationType,\n removeBucketAggregation,\n} from './actions';\n\nexport const createReducer =\n (defaultTimeField: string) =>\n (state: ElasticsearchQuery['bucketAggs'], action: Action): ElasticsearchQuery['bucketAggs'] => {\n if (addBucketAggregation.match(action)) {\n const newAgg: Terms = {\n id: action.payload,\n type: 'terms',\n settings: bucketAggregationConfig['terms'].defaultSettings,\n };\n\n // If the last bucket aggregation is a `date_histogram` we add the new one before it.\n const lastAgg = state![state!.length - 1];\n if (lastAgg?.type === 'date_histogram') {\n return [...state!.slice(0, state!.length - 1), newAgg, lastAgg];\n }\n\n return [...state!, newAgg];\n }\n\n if (removeBucketAggregation.match(action)) {\n return state!.filter((bucketAgg) => bucketAgg.id !== action.payload);\n }\n\n if (changeBucketAggregationType.match(action)) {\n return state!.map((bucketAgg) => {\n if (bucketAgg.id !== action.payload.id) {\n return bucketAgg;\n }\n\n /*\n TODO: The previous version of the query editor was keeping some of the old bucket aggregation's configurations\n in the new selected one (such as field or some settings).\n It the future would be nice to have the same behavior but it's hard without a proper definition,\n as Elasticsearch will error sometimes if some settings are not compatible.\n */\n return {\n id: bucketAgg.id,\n type: action.payload.newType,\n settings: bucketAggregationConfig[action.payload.newType].defaultSettings,\n } as BucketAggregation;\n });\n }\n\n if (changeBucketAggregationField.match(action)) {\n return state!.map((bucketAgg) => {\n if (bucketAgg.id !== action.payload.id) {\n return bucketAgg;\n }\n\n return {\n ...bucketAgg,\n field: action.payload.newField,\n };\n });\n }\n\n if (changeMetricType.match(action)) {\n // If we are switching to a metric which requires the absence of bucket aggregations\n // we remove all of them.\n if (metricAggregationConfig[action.payload.type].isSingleMetric) {\n return [];\n } else if (state!.length === 0) {\n // Else, if there are no bucket aggregations we restore a default one.\n // This happens when switching from a metric that requires the absence of bucket aggregations to\n // one that requires it.\n return [{ ...defaultBucketAgg('2'), field: defaultTimeField }];\n }\n return state;\n }\n\n if (changeBucketAggregationSetting.match(action)) {\n return state!.map((bucketAgg) => {\n if (bucketAgg.id !== action.payload.bucketAgg.id) {\n return bucketAgg;\n }\n\n const newSettings = removeEmpty({\n ...bucketAgg.settings,\n [action.payload.settingName]: action.payload.newValue,\n });\n\n return {\n ...bucketAgg,\n settings: {\n ...newSettings,\n },\n };\n });\n }\n\n if (initQuery.match(action)) {\n if (state?.length || 0 > 0) {\n return state;\n }\n\n return [{ ...defaultBucketAgg('2'), field: defaultTimeField }];\n }\n\n return state;\n };\n","import { useMemo } from 'react';\n\nimport { BucketAggregation } from '../components/QueryEditor/BucketAggregationsEditor/aggregations';\nimport { useQuery } from '../components/QueryEditor/ElasticsearchQueryContext';\nimport { MetricAggregation } from '../components/QueryEditor/MetricAggregationsEditor/aggregations';\n\nconst toId = <T extends { id: unknown }>(e: T): T['id'] => e.id;\n\nconst toInt = (idString: string) => parseInt(idString, 10);\n\nexport const useNextId = (): MetricAggregation['id'] | BucketAggregation['id'] => {\n const { metrics, bucketAggs } = useQuery();\n\n return useMemo(\n () =>\n (Math.max(...[...(metrics?.map(toId) || ['0']), ...(bucketAggs?.map(toId) || ['0'])].map(toInt)) + 1).toString(),\n [metrics, bucketAggs]\n );\n};\n","import { cx, css } from '@emotion/css';\nimport React, { ComponentProps, ButtonHTMLAttributes } from 'react';\n\nimport { Icon } from '@grafana/ui';\n\nconst SROnly = css`\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n`;\n\ninterface Props {\n iconName: ComponentProps<typeof Icon>['name'];\n onClick: () => void;\n className?: string;\n label: string;\n}\n\nexport const IconButton = ({\n iconName,\n onClick,\n className,\n label,\n ...buttonProps\n}: Props & ButtonHTMLAttributes<HTMLButtonElement>) => (\n <button className={cx('gf-form-label gf-form-label--btn query-part', className)} onClick={onClick} {...buttonProps}>\n <span className={SROnly}>{label}</span>\n <Icon name={iconName} aria-hidden=\"true\" />\n </button>\n);\n","import { css } from '@emotion/css';\nimport { noop } from 'lodash';\nimport React, { PropsWithChildren } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { IconButton, InlineFieldRow, InlineLabel, InlineSegmentGroup, useStyles2 } from '@grafana/ui';\n\ninterface Props {\n label: string;\n onRemoveClick?: false | (() => void);\n onHideClick?: false | (() => void);\n hidden?: boolean;\n}\n\nexport const QueryEditorRow = ({\n children,\n label,\n onRemoveClick,\n onHideClick,\n hidden = false,\n}: PropsWithChildren<Props>) => {\n const styles = useStyles2(getStyles);\n\n return (\n <InlineFieldRow>\n <InlineSegmentGroup>\n <InlineLabel width={17} as=\"div\">\n <span>{label}</span>\n <span className={styles.iconWrapper}>\n {onHideClick && (\n <IconButton\n name={hidden ? 'eye-slash' : 'eye'}\n onClick={onHideClick}\n size=\"sm\"\n aria-pressed={hidden}\n aria-label=\"hide metric\"\n className={styles.icon}\n />\n )}\n <IconButton\n name=\"trash-alt\"\n size=\"sm\"\n className={styles.icon}\n onClick={onRemoveClick || noop}\n disabled={!onRemoveClick}\n aria-label=\"remove metric\"\n />\n </span>\n </InlineLabel>\n </InlineSegmentGroup>\n {children}\n </InlineFieldRow>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n iconWrapper: css`\n display: flex;\n `,\n icon: css`\n color: ${theme.colors.text.secondary};\n margin-left: ${theme.spacing(0.25)};\n `,\n };\n};\n","import { bucketAggregationConfig } from './utils';\n\nexport type BucketAggregationType = 'terms' | 'filters' | 'geohash_grid' | 'date_histogram' | 'histogram';\n\ninterface BaseBucketAggregation {\n id: string;\n type: BucketAggregationType;\n settings?: Record<string, unknown>;\n}\n\nexport interface BucketAggregationWithField extends BaseBucketAggregation {\n field?: string;\n}\n\nexport interface DateHistogram extends BucketAggregationWithField {\n type: 'date_histogram';\n settings?: {\n interval?: string;\n min_doc_count?: string;\n trimEdges?: string;\n offset?: string;\n timeZone?: string;\n };\n}\n\nexport interface Histogram extends BucketAggregationWithField {\n type: 'histogram';\n settings?: {\n interval?: string;\n min_doc_count?: string;\n };\n}\n\ntype TermsOrder = 'desc' | 'asc';\n\nexport interface Terms extends BucketAggregationWithField {\n type: 'terms';\n settings?: {\n order?: TermsOrder;\n size?: string;\n min_doc_count?: string;\n orderBy?: string;\n missing?: string;\n };\n}\n\nexport type Filter = {\n query: string;\n label: string;\n};\nexport interface Filters extends BaseBucketAggregation {\n type: 'filters';\n settings?: {\n filters?: Filter[];\n };\n}\n\ninterface GeoHashGrid extends BucketAggregationWithField {\n type: 'geohash_grid';\n settings?: {\n precision?: string;\n };\n}\n\nexport type BucketAggregation = DateHistogram | Histogram | Terms | Filters | GeoHashGrid;\n\nexport const isBucketAggregationWithField = (\n bucketAgg: BucketAggregation | BucketAggregationWithField\n): bucketAgg is BucketAggregationWithField => bucketAggregationConfig[bucketAgg.type].requiresField;\n\nexport const BUCKET_AGGREGATION_TYPES: BucketAggregationType[] = [\n 'date_histogram',\n 'histogram',\n 'terms',\n 'filters',\n 'geohash_grid',\n];\n\nexport const isBucketAggregationType = (s: BucketAggregationType | string): s is BucketAggregationType =>\n BUCKET_AGGREGATION_TYPES.includes(s as BucketAggregationType);\n","import { lastValueFrom } from 'rxjs';\n\nimport { MetricFindValue, SelectableValue } from '@grafana/data';\n\nimport {\n BucketAggregationType,\n isBucketAggregationType,\n} from '../components/QueryEditor/BucketAggregationsEditor/aggregations';\nimport { useDatasource, useRange } from '../components/QueryEditor/ElasticsearchQueryContext';\nimport {\n isMetricAggregationType,\n MetricAggregationType,\n} from '../components/QueryEditor/MetricAggregationsEditor/aggregations';\n\ntype AggregationType = BucketAggregationType | MetricAggregationType;\n\nconst getFilter = (type: AggregationType) => {\n if (isMetricAggregationType(type)) {\n switch (type) {\n case 'cardinality':\n return [];\n case 'top_metrics':\n // top_metrics was introduced in 7.7 where `metrics` only supported number:\n // https://www.elastic.co/guide/en/elasticsearch/reference/7.7/search-aggregations-metrics-top-metrics.html#_metrics\n // TODO: starting from 7.11 it supports ips and keywords as well:\n // https://www.elastic.co/guide/en/elasticsearch/reference/7.11/search-aggregations-metrics-top-metrics.html#_metrics\n return ['number'];\n default:\n return ['number'];\n }\n }\n\n if (isBucketAggregationType(type)) {\n switch (type) {\n case 'date_histogram':\n return ['date'];\n case 'geohash_grid':\n return ['geo_point'];\n case 'histogram':\n return ['number'];\n default:\n return [];\n }\n }\n\n return [];\n};\n\nconst toSelectableValue = ({ text }: MetricFindValue): SelectableValue<string> => ({\n label: text,\n value: text,\n});\n\n/**\n * Returns a function to query the configured datasource for autocomplete values for the specified aggregation type or data types.\n * Each aggregation can be run on different types, for example avg only operates on numeric fields, geohash_grid only on geo_point fields.\n * If an aggregation type is provided, the promise will resolve with all fields suitable to be used as a field for the given aggregation.\n * If an array of types is providem the promise will resolve with all the fields matching the provided types.\n * @param aggregationType the type of aggregation to get fields for\n */\nexport const useFields = (type: AggregationType | string[]) => {\n const datasource = useDatasource();\n const range = useRange();\n const filter = Array.isArray(type) ? type : getFilter(type);\n let rawFields: MetricFindValue[];\n\n return async (q?: string) => {\n // _mapping doesn't support filtering, we avoid sending a request everytime q changes\n if (!rawFields) {\n rawFields = await lastValueFrom(datasource.getFields(filter, range));\n }\n\n return rawFields.filter(({ text }) => q === undefined || text.includes(q)).map(toSelectableValue);\n };\n};\n","import { css } from '@emotion/css';\n\nexport const segmentStyles = css`\n min-width: 150px;\n`;\n","import { css, cx } from '@emotion/css';\nimport React, { PropsWithChildren, useState } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, InlineSegmentGroup, useTheme2 } from '@grafana/ui';\n\nimport { segmentStyles } from './styles';\n\nconst getStyles = (theme: GrafanaTheme2, hidden: boolean) => {\n return {\n wrapper: css`\n max-width: 500px;\n display: flex;\n flex-direction: column;\n `,\n settingsWrapper: css`\n padding-top: ${theme.spacing(0.5)};\n `,\n icon: css`\n margin-right: ${theme.spacing(0.5)};\n `,\n button: css`\n justify-content: start;\n ${hidden &&\n css`\n color: ${theme.colors.text.disabled};\n `}\n `,\n };\n};\n\ninterface Props {\n label: string;\n hidden?: boolean;\n}\n\nexport const SettingsEditorContainer = ({ label, children, hidden = false }: PropsWithChildren<Props>) => {\n const [open, setOpen] = useState(false);\n\n const theme = useTheme2();\n const styles = getStyles(theme, hidden);\n\n return (\n <InlineSegmentGroup>\n <div className={cx(styles.wrapper)}>\n <button\n className={cx('gf-form-label query-part', styles.button, segmentStyles)}\n onClick={() => setOpen(!open)}\n aria-expanded={open}\n >\n <Icon name={open ? 'angle-down' : 'angle-right'} aria-hidden=\"true\" className={styles.icon} />\n {label}\n </button>\n\n {open && <div className={styles.settingsWrapper}>{children}</div>}\n </div>\n </InlineSegmentGroup>\n );\n};\n","import { useState } from 'react';\n\nimport { SelectableValue } from '@grafana/data';\n\nconst hasValue =\n <T extends SelectableValue>(searchValue: T['value']) =>\n ({ value }: T) =>\n value === searchValue;\n\nconst getInitialState = (initialOptions: SelectableValue[], initialValue?: string): SelectableValue[] => {\n if (initialValue === undefined || initialOptions.some(hasValue(initialValue))) {\n return initialOptions;\n }\n\n return [\n ...initialOptions,\n {\n value: initialValue,\n label: initialValue,\n },\n ];\n};\n\ninterface Params {\n options: SelectableValue[];\n value?: string;\n onChange: (s: SelectableValue<string>) => void;\n}\n\n/**\n * Creates the Props needed by Select to handle custom values and handles custom value creation\n * and the initial value when it is not present in the option array.\n */\nexport const useCreatableSelectPersistedBehaviour = ({ options: initialOptions, value, onChange }: Params) => {\n const [options, setOptions] = useState(getInitialState(initialOptions, value));\n\n const addOption = (newValue: string) => setOptions([...options, { value: newValue, label: newValue }]);\n\n return {\n onCreateOption: (value: string) => {\n addOption(value);\n onChange({ value });\n },\n onChange,\n allowCustomValue: true,\n options,\n value,\n };\n};\n","import { uniqueId } from 'lodash';\nimport React, { useRef } from 'react';\nimport { GroupBase, OptionsOrGroups } from 'react-select';\n\nimport { InternalTimeZones, SelectableValue } from '@grafana/data';\nimport { InlineField, Input, Select, TimeZonePicker } from '@grafana/ui';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { useCreatableSelectPersistedBehaviour } from '../../../hooks/useCreatableSelectPersistedBehaviour';\nimport { DateHistogram } from '../aggregations';\nimport { changeBucketAggregationSetting } from '../state/actions';\nimport { bucketAggregationConfig } from '../utils';\n\nimport { inlineFieldProps } from '.';\n\nconst defaultIntervalOptions: Array<SelectableValue<string>> = [\n { label: 'auto', value: 'auto' },\n { label: '10s', value: '10s' },\n { label: '1m', value: '1m' },\n { label: '5m', value: '5m' },\n { label: '10m', value: '10m' },\n { label: '20m', value: '20m' },\n { label: '1h', value: '1h' },\n { label: '1d', value: '1d' },\n];\n\nconst hasValue =\n (searchValue: string) =>\n ({ value }: SelectableValue<string>) =>\n value === searchValue;\n\nconst isValidNewOption = (\n inputValue: string,\n _: SelectableValue<string> | null,\n options: OptionsOrGroups<unknown, GroupBase<unknown>>\n) => {\n // TODO: would be extremely nice here to allow only template variables and values that are\n // valid date histogram's Interval options\n const valueExists = (options as Array<SelectableValue<string>>).some(hasValue(inputValue));\n // we also don't want users to create \"empty\" values\n return !valueExists && inputValue.trim().length > 0;\n};\n\nconst optionStartsWithValue = (option: SelectableValue<string>, value: string) =>\n option.value?.startsWith(value) || false;\n\ninterface Props {\n bucketAgg: DateHistogram;\n}\n\nexport const DateHistogramSettingsEditor = ({ bucketAgg }: Props) => {\n const dispatch = useDispatch();\n const { current: baseId } = useRef(uniqueId('es-date_histogram-'));\n\n const handleIntervalChange = ({ value }: SelectableValue<string>) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'interval', newValue: value }));\n\n return (\n <>\n <InlineField label=\"Interval\" {...inlineFieldProps}>\n <Select\n inputId={uniqueId('es-date_histogram-interval')}\n isValidNewOption={isValidNewOption}\n filterOption={optionStartsWithValue}\n {...useCreatableSelectPersistedBehaviour({\n options: defaultIntervalOptions,\n value: bucketAgg.settings?.interval || bucketAggregationConfig.date_histogram.defaultSettings?.interval,\n onChange: handleIntervalChange,\n })}\n />\n </InlineField>\n\n <InlineField label=\"Min Doc Count\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-min_doc_count`}\n onBlur={(e) =>\n dispatch(\n changeBucketAggregationSetting({ bucketAgg, settingName: 'min_doc_count', newValue: e.target.value })\n )\n }\n defaultValue={\n bucketAgg.settings?.min_doc_count || bucketAggregationConfig.date_histogram.defaultSettings?.min_doc_count\n }\n />\n </InlineField>\n\n <InlineField label=\"Trim Edges\" {...inlineFieldProps} tooltip=\"Trim the edges on the timeseries datapoints\">\n <Input\n id={`${baseId}-trime_edges`}\n onBlur={(e) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'trimEdges', newValue: e.target.value }))\n }\n defaultValue={\n bucketAgg.settings?.trimEdges || bucketAggregationConfig.date_histogram.defaultSettings?.trimEdges\n }\n />\n </InlineField>\n\n <InlineField\n label=\"Offset\"\n {...inlineFieldProps}\n tooltip=\"Change the start value of each bucket by the specified positive (+) or negative offset (-) duration, such as 1h for an hour, or 1d for a day\"\n >\n <Input\n id={`${baseId}-offset`}\n onBlur={(e) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'offset', newValue: e.target.value }))\n }\n defaultValue={bucketAgg.settings?.offset || bucketAggregationConfig.date_histogram.defaultSettings?.offset}\n />\n </InlineField>\n\n <InlineField label=\"Timezone\" {...inlineFieldProps}>\n <TimeZonePicker\n value={bucketAgg.settings?.timeZone || bucketAggregationConfig.date_histogram.defaultSettings?.timeZone}\n includeInternal={[InternalTimeZones.utc]}\n onChange={(timeZone) => {\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'timeZone', newValue: timeZone }));\n }}\n />\n </InlineField>\n </>\n );\n};\n","import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { IconButton } from './IconButton';\n\ninterface Props {\n index: number;\n elements: any[];\n onAdd: () => void;\n onRemove: () => void;\n}\n\n/**\n * A component used to show add & remove buttons for mutable lists of values. Wether to show or not the add or the remove buttons\n * depends on the `index` and `elements` props. This enforces a consistent experience whenever this pattern is used.\n */\nexport const AddRemove = ({ index, onAdd, onRemove, elements }: Props) => {\n return (\n <div\n className={css`\n display: flex;\n `}\n >\n {index === 0 && <IconButton iconName=\"plus\" onClick={onAdd} label=\"add\" />}\n\n {elements.length >= 2 && <IconButton iconName=\"minus\" onClick={onRemove} label=\"remove\" />}\n </div>\n );\n};\n","import { createAction } from '@reduxjs/toolkit';\n\nimport { Filter } from '../../../aggregations';\n\nexport const addFilter = createAction('@bucketAggregations/filter/add');\nexport const removeFilter = createAction<number>('@bucketAggregations/filter/remove');\nexport const changeFilter = createAction<{ index: number; filter: Filter }>('@bucketAggregations/filter/change');\n","import { Action } from 'redux';\n\nimport { Filter } from '../../../aggregations';\nimport { defaultFilter } from '../utils';\n\nimport { addFilter, changeFilter, removeFilter } from './actions';\n\nexport const reducer = (state: Filter[] = [], action: Action) => {\n if (addFilter.match(action)) {\n return [...state, defaultFilter()];\n }\n\n if (removeFilter.match(action)) {\n return state.slice(0, action.payload).concat(state.slice(action.payload + 1));\n }\n\n if (changeFilter.match(action)) {\n return state.map((filter, index) => {\n if (index !== action.payload.index) {\n return filter;\n }\n\n return action.payload.filter;\n });\n }\n\n return state;\n};\n","import { css } from '@emotion/css';\nimport { uniqueId } from 'lodash';\nimport React, { useEffect, useRef } from 'react';\n\nimport { InlineField, Input, QueryField } from '@grafana/ui';\n\nimport { useDispatch, useStatelessReducer } from '../../../../../hooks/useStatelessReducer';\nimport { AddRemove } from '../../../../AddRemove';\nimport { Filters } from '../../aggregations';\nimport { changeBucketAggregationSetting } from '../../state/actions';\n\nimport { addFilter, changeFilter, removeFilter } from './state/actions';\nimport { reducer as filtersReducer } from './state/reducer';\n\ninterface Props {\n bucketAgg: Filters;\n}\n\nexport const FiltersSettingsEditor = ({ bucketAgg }: Props) => {\n const { current: baseId } = useRef(uniqueId('es-filters-'));\n\n const upperStateDispatch = useDispatch();\n\n const dispatch = useStatelessReducer(\n (newValue) => upperStateDispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'filters', newValue })),\n bucketAgg.settings?.filters,\n filtersReducer\n );\n\n // The model might not have filters (or an empty array of filters) in it because of the way it was built in previous versions of the datasource.\n // If this is the case we add a default one.\n useEffect(() => {\n if (!bucketAgg.settings?.filters?.length) {\n dispatch(addFilter());\n }\n }, [dispatch, bucketAgg.settings?.filters?.length]);\n\n return (\n <>\n <div\n className={css`\n display: flex;\n flex-direction: column;\n `}\n >\n {bucketAgg.settings?.filters!.map((filter, index) => (\n <div\n key={index}\n className={css`\n display: flex;\n `}\n >\n <InlineField label=\"Query\" labelWidth={8}>\n <div\n className={css`\n width: 150px;\n `}\n >\n <QueryField\n placeholder=\"Lucene Query\"\n portalOrigin=\"elasticsearch\"\n onBlur={() => {}}\n onChange={(query) => dispatch(changeFilter({ index, filter: { ...filter, query } }))}\n query={filter.query}\n />\n </div>\n </InlineField>\n <InlineField label=\"Label\" labelWidth={8}>\n <Input\n width={16}\n id={`${baseId}-label-${index}`}\n placeholder=\"Label\"\n onBlur={(e) => dispatch(changeFilter({ index, filter: { ...filter, label: e.target.value } }))}\n defaultValue={filter.label}\n />\n </InlineField>\n <AddRemove\n index={index}\n elements={bucketAgg.settings?.filters || []}\n onAdd={() => dispatch(addFilter())}\n onRemove={() => dispatch(removeFilter(index))}\n />\n </div>\n ))}\n </div>\n </>\n );\n};\n","import { uniqueId } from 'lodash';\nimport React, { useRef } from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { InlineField, Select, Input } from '@grafana/ui';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { describeMetric } from '../../../../utils';\nimport { useCreatableSelectPersistedBehaviour } from '../../../hooks/useCreatableSelectPersistedBehaviour';\nimport { useQuery } from '../../ElasticsearchQueryContext';\nimport {\n ExtendedStatMetaType,\n ExtendedStats,\n isPipelineAggregation,\n MetricAggregation,\n Percentiles,\n} from '../../MetricAggregationsEditor/aggregations';\nimport { Terms } from '../aggregations';\nimport { changeBucketAggregationSetting } from '../state/actions';\nimport { bucketAggregationConfig, orderByOptions, orderOptions, sizeOptions } from '../utils';\n\nimport { inlineFieldProps } from '.';\n\ninterface Props {\n bucketAgg: Terms;\n}\n\nexport const TermsSettingsEditor = ({ bucketAgg }: Props) => {\n const { metrics } = useQuery();\n const orderBy = createOrderByOptions(metrics);\n const { current: baseId } = useRef(uniqueId('es-terms-'));\n\n const dispatch = useDispatch();\n\n return (\n <>\n <InlineField label=\"Order\" {...inlineFieldProps}>\n <Select\n inputId={`${baseId}-order`}\n onChange={(e) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'order', newValue: e.value }))\n }\n options={orderOptions}\n value={bucketAgg.settings?.order || bucketAggregationConfig.terms.defaultSettings?.order}\n />\n </InlineField>\n\n <InlineField label=\"Size\" {...inlineFieldProps}>\n <Select\n inputId={`${baseId}-size`}\n // TODO: isValidNewOption should only allow numbers & template variables\n {...useCreatableSelectPersistedBehaviour({\n options: sizeOptions,\n value: bucketAgg.settings?.size || bucketAggregationConfig.terms.defaultSettings?.size,\n onChange({ value }) {\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'size', newValue: value }));\n },\n })}\n />\n </InlineField>\n\n <InlineField label=\"Min Doc Count\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-min_doc_count`}\n onBlur={(e) =>\n dispatch(\n changeBucketAggregationSetting({ bucketAgg, settingName: 'min_doc_count', newValue: e.target.value })\n )\n }\n defaultValue={\n bucketAgg.settings?.min_doc_count || bucketAggregationConfig.terms.defaultSettings?.min_doc_count\n }\n />\n </InlineField>\n\n <InlineField label=\"Order By\" {...inlineFieldProps}>\n <Select\n inputId={`${baseId}-order_by`}\n onChange={(e) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'orderBy', newValue: e.value }))\n }\n options={orderBy}\n value={bucketAgg.settings?.orderBy || bucketAggregationConfig.terms.defaultSettings?.orderBy}\n />\n </InlineField>\n\n <InlineField label=\"Missing\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-missing`}\n onBlur={(e) =>\n dispatch(changeBucketAggregationSetting({ bucketAgg, settingName: 'missing', newValue: e.target.value }))\n }\n defaultValue={bucketAgg.settings?.missing || bucketAggregationConfig.terms.defaultSettings?.missing}\n />\n </InlineField>\n </>\n );\n};\n\n/**\n * This returns the valid options for each of the enabled extended stat\n */\nfunction createOrderByOptionsForExtendedStats(metric: ExtendedStats): SelectableValue<string> {\n if (!metric.meta) {\n return [];\n }\n const metaKeys = Object.keys(metric.meta) as ExtendedStatMetaType[];\n return metaKeys\n .filter((key) => metric.meta?.[key])\n .map((key) => {\n let method = key as string;\n // The bucket path for std_deviation_bounds.lower and std_deviation_bounds.upper\n // is accessed via std_lower and std_upper, respectively.\n if (key === 'std_deviation_bounds_lower') {\n method = 'std_lower';\n }\n if (key === 'std_deviation_bounds_upper') {\n method = 'std_upper';\n }\n return { label: `${describeMetric(metric)} (${method})`, value: `${metric.id}[${method}]` };\n });\n}\n\n/**\n * This returns the valid options for each of the percents listed in the percentile settings\n */\nfunction createOrderByOptionsForPercentiles(metric: Percentiles): Array<SelectableValue<string>> {\n if (!metric.settings?.percents) {\n return [];\n }\n return metric.settings.percents.map((percent) => {\n // The bucket path for percentile numbers is appended with a `.0` if the number is whole\n // otherwise you have to use the actual value.\n const percentString = /^\\d+\\.\\d+/.test(`${percent}`) ? percent : `${percent}.0`;\n return { label: `${describeMetric(metric)} (${percent})`, value: `${metric.id}[${percentString}]` };\n });\n}\n\nfunction isValidOrderTarget(metric: MetricAggregation) {\n return (\n // top metrics can't be used for ordering\n metric.type !== 'top_metrics' &&\n // pipeline aggregations can't be used for ordering: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order\n !isPipelineAggregation(metric)\n );\n}\n\n/**\n * This creates all the valid order by options based on the metrics\n */\nexport const createOrderByOptions = (metrics: MetricAggregation[] = []): Array<SelectableValue<string>> => {\n const metricOptions = metrics.filter(isValidOrderTarget).flatMap((metric) => {\n if (metric.type === 'extended_stats') {\n return createOrderByOptionsForExtendedStats(metric);\n } else if (metric.type === 'percentiles') {\n return createOrderByOptionsForPercentiles(metric);\n } else {\n return { label: describeMetric(metric), value: metric.id };\n }\n });\n return [...orderByOptions, ...metricOptions];\n};\n","import { describeMetric, convertOrderByToMetricId } from '../../../../utils';\nimport { useQuery } from '../../ElasticsearchQueryContext';\nimport { BucketAggregation } from '../aggregations';\nimport { bucketAggregationConfig, orderByOptions, orderOptions } from '../utils';\n\nconst hasValue = (value: string) => (object: { value?: string }) => object.value === value;\n\n// FIXME: We should apply the same defaults we have in bucketAggregationsConfig here instead of \"custom\" values\n// as they might get out of sync.\n// The reason we need them is that even though after the refactoring each setting is created with its default value,\n// queries created with the old version might not have them.\nexport const useDescription = (bucketAgg: BucketAggregation): string => {\n const { metrics } = useQuery();\n\n switch (bucketAgg.type) {\n case 'terms': {\n const order = bucketAgg.settings?.order || 'desc';\n const size = bucketAgg.settings?.size || '10';\n const minDocCount = parseInt(bucketAgg.settings?.min_doc_count || '0', 10);\n const orderBy = bucketAgg.settings?.orderBy || '_term';\n let description = '';\n\n if (size !== '0') {\n const orderLabel = orderOptions.find(hasValue(order))?.label!;\n description = `${orderLabel} ${size}, `;\n }\n\n if (minDocCount > 0) {\n description += `Min Doc Count: ${minDocCount}, `;\n }\n\n description += 'Order by: ';\n const orderByOption = orderByOptions.find(hasValue(orderBy));\n if (orderByOption) {\n description += orderByOption.label;\n } else {\n const metric = metrics?.find((m) => m.id === convertOrderByToMetricId(orderBy));\n if (metric) {\n description += describeMetric(metric);\n } else {\n description += 'metric not found';\n }\n }\n\n if (size === '0') {\n description += ` (${order})`;\n }\n return description;\n }\n\n case 'histogram': {\n const interval = bucketAgg.settings?.interval || 1000;\n const minDocCount = bucketAgg.settings?.min_doc_count || 1;\n\n return `Interval: ${interval}${minDocCount > 0 ? `, Min Doc Count: ${minDocCount}` : ''}`;\n }\n\n case 'filters': {\n const filters = bucketAgg.settings?.filters || bucketAggregationConfig['filters'].defaultSettings?.filters;\n return `Filter Queries (${filters!.length})`;\n }\n\n case 'geohash_grid': {\n const precision = Math.max(Math.min(parseInt(bucketAgg.settings?.precision || '5', 10), 12), 1);\n return `Precision: ${precision}`;\n }\n\n case 'date_histogram': {\n const interval = bucketAgg.settings?.interval || 'auto';\n const minDocCount = bucketAgg.settings?.min_doc_count || 0;\n const trimEdges = bucketAgg.settings?.trimEdges || 0;\n\n let description = `Interval: ${interval}`;\n\n if (minDocCount > 0) {\n description += `, Min Doc Count: ${minDocCount}`;\n }\n\n if (trimEdges > 0) {\n description += `, Trim edges: ${trimEdges}`;\n }\n\n return description;\n }\n\n default:\n return 'Settings';\n }\n};\n","import { uniqueId } from 'lodash';\nimport React, { ComponentProps, useRef } from 'react';\n\nimport { InlineField, Input } from '@grafana/ui';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { SettingsEditorContainer } from '../../SettingsEditorContainer';\nimport { BucketAggregation } from '../aggregations';\nimport { changeBucketAggregationSetting } from '../state/actions';\nimport { bucketAggregationConfig } from '../utils';\n\nimport { DateHistogramSettingsEditor } from './DateHistogramSettingsEditor';\nimport { FiltersSettingsEditor } from './FiltersSettingsEditor';\nimport { TermsSettingsEditor } from './TermsSettingsEditor';\nimport { useDescription } from './useDescription';\n\nexport const inlineFieldProps: Partial<ComponentProps<typeof InlineField>> = {\n labelWidth: 16,\n};\n\ninterface Props {\n bucketAgg: BucketAggregation;\n}\n\nexport const SettingsEditor = ({ bucketAgg }: Props) => {\n const { current: baseId } = useRef(uniqueId('es-setting-'));\n\n const dispatch = useDispatch();\n\n const settingsDescription = useDescription(bucketAgg);\n\n return (\n <SettingsEditorContainer label={settingsDescription}>\n {bucketAgg.type === 'terms' && <TermsSettingsEditor bucketAgg={bucketAgg} />}\n {bucketAgg.type === 'date_histogram' && <DateHistogramSettingsEditor bucketAgg={bucketAgg} />}\n {bucketAgg.type === 'filters' && <FiltersSettingsEditor bucketAgg={bucketAgg} />}\n\n {bucketAgg.type === 'geohash_grid' && (\n <InlineField label=\"Precision\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-geohash_grid-precision`}\n onBlur={(e) =>\n dispatch(\n changeBucketAggregationSetting({ bucketAgg, settingName: 'precision', newValue: e.target.value })\n )\n }\n defaultValue={\n bucketAgg.settings?.precision || bucketAggregationConfig[bucketAgg.type].defaultSettings?.precision\n }\n />\n </InlineField>\n )}\n\n {bucketAgg.type === 'histogram' && (\n <>\n <InlineField label=\"Interval\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-histogram-interval`}\n onBlur={(e) =>\n dispatch(\n changeBucketAggregationSetting({ bucketAgg, settingName: 'interval', newValue: e.target.value })\n )\n }\n defaultValue={\n bucketAgg.settings?.interval || bucketAggregationConfig[bucketAgg.type].defaultSettings?.interval\n }\n />\n </InlineField>\n\n <InlineField label=\"Min Doc Count\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-histogram-min_doc_count`}\n onBlur={(e) =>\n dispatch(\n changeBucketAggregationSetting({ bucketAgg, settingName: 'min_doc_count', newValue: e.target.value })\n )\n }\n defaultValue={\n bucketAgg.settings?.min_doc_count ||\n bucketAggregationConfig[bucketAgg.type].defaultSettings?.min_doc_count\n }\n />\n </InlineField>\n </>\n )}\n </SettingsEditorContainer>\n );\n};\n","import React from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { InlineSegmentGroup, Segment, SegmentAsync } from '@grafana/ui';\n\nimport { useFields } from '../../../hooks/useFields';\nimport { useDispatch } from '../../../hooks/useStatelessReducer';\nimport { segmentStyles } from '../styles';\n\nimport { SettingsEditor } from './SettingsEditor';\nimport { BucketAggregation, BucketAggregationType, isBucketAggregationWithField } from './aggregations';\nimport { changeBucketAggregationField, changeBucketAggregationType } from './state/actions';\nimport { bucketAggregationConfig } from './utils';\n\nconst bucketAggOptions: Array<SelectableValue<BucketAggregationType>> = Object.entries(bucketAggregationConfig).map(\n ([key, { label }]) => ({\n label,\n value: key as BucketAggregationType,\n })\n);\n\nconst toOption = (bucketAgg: BucketAggregation) => ({\n label: bucketAggregationConfig[bucketAgg.type].label,\n value: bucketAgg.type,\n});\n\ninterface QueryMetricEditorProps {\n value: BucketAggregation;\n}\n\nexport const BucketAggregationEditor = ({ value }: QueryMetricEditorProps) => {\n const dispatch = useDispatch();\n const getFields = useFields(value.type);\n\n return (\n <>\n <InlineSegmentGroup>\n <Segment\n className={segmentStyles}\n options={bucketAggOptions}\n onChange={(e) => dispatch(changeBucketAggregationType({ id: value.id, newType: e.value! }))}\n value={toOption(value)}\n />\n\n {isBucketAggregationWithField(value) && (\n <SegmentAsync\n className={segmentStyles}\n loadOptions={getFields}\n onChange={(e) => dispatch(changeBucketAggregationField({ id: value.id, newField: e.value }))}\n placeholder=\"Select Field\"\n value={value.field}\n />\n )}\n </InlineSegmentGroup>\n\n <SettingsEditor bucketAgg={value} />\n </>\n );\n};\n","import React from 'react';\n\nimport { useDispatch } from '../../../hooks/useStatelessReducer';\nimport { IconButton } from '../../IconButton';\nimport { useQuery } from '../ElasticsearchQueryContext';\nimport { QueryEditorRow } from '../QueryEditorRow';\n\nimport { BucketAggregationEditor } from './BucketAggregationEditor';\nimport { BucketAggregation } from './aggregations';\nimport { addBucketAggregation, removeBucketAggregation } from './state/actions';\n\ninterface Props {\n nextId: BucketAggregation['id'];\n}\n\nexport const BucketAggregationsEditor = ({ nextId }: Props) => {\n const dispatch = useDispatch();\n const { bucketAggs } = useQuery();\n const totalBucketAggs = bucketAggs?.length || 0;\n\n return (\n <>\n {bucketAggs!.map((bucketAgg, index) => (\n <QueryEditorRow\n key={`${bucketAgg.type}-${bucketAgg.id}`}\n label={index === 0 ? 'Group By' : 'Then By'}\n onRemoveClick={totalBucketAggs > 1 && (() => dispatch(removeBucketAggregation(bucketAgg.id)))}\n >\n <BucketAggregationEditor value={bucketAgg} />\n\n {index === 0 && (\n <IconButton iconName=\"plus\" onClick={() => dispatch(addBucketAggregation(nextId))} label=\"add\" />\n )}\n </QueryEditorRow>\n ))}\n </>\n );\n};\n","import { css, cx } from '@emotion/css';\nimport React from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { Segment } from '@grafana/ui';\n\nimport { describeMetric } from '../utils';\n\nimport { MetricAggregation } from './QueryEditor/MetricAggregationsEditor/aggregations';\n\nconst noWrap = css`\n white-space: nowrap;\n`;\n\nconst toOption = (metric: MetricAggregation) => ({\n label: describeMetric(metric),\n value: metric,\n});\n\nconst toOptions = (metrics: MetricAggregation[]): Array<SelectableValue<MetricAggregation>> => metrics.map(toOption);\n\ninterface Props {\n options: MetricAggregation[];\n onChange: (e: SelectableValue<MetricAggregation>) => void;\n className?: string;\n value?: string;\n}\n\nexport const MetricPicker = ({ options, onChange, className, value }: Props) => {\n const selectedOption = options.find((option) => option.id === value);\n\n return (\n <Segment\n className={cx(className, noWrap)}\n options={toOptions(options)}\n onChange={onChange}\n placeholder=\"Select Metric\"\n value={!!selectedOption ? toOption(selectedOption) : undefined}\n />\n );\n};\n","import { uniqueId } from 'lodash';\nimport React, { ComponentProps, useState } from 'react';\n\nimport { InlineField, Input } from '@grafana/ui';\nimport { getScriptValue } from 'app/plugins/datasource/elasticsearch/utils';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { SettingKeyOf } from '../../../types';\nimport { MetricAggregationWithInlineScript, MetricAggregationWithSettings } from '../aggregations';\nimport { changeMetricSetting } from '../state/actions';\n\ninterface Props<T extends MetricAggregationWithSettings, K extends SettingKeyOf<T>> {\n label: string;\n settingName: K;\n metric: T;\n placeholder?: ComponentProps<typeof Input>['placeholder'];\n tooltip?: ComponentProps<typeof InlineField>['tooltip'];\n}\n\nexport function SettingField<T extends MetricAggregationWithSettings, K extends SettingKeyOf<T>>({\n label,\n settingName,\n metric,\n placeholder,\n tooltip,\n}: Props<T, K>) {\n const dispatch = useDispatch();\n const [id] = useState(uniqueId(`es-field-id-`));\n const settings = metric.settings;\n\n let defaultValue = settings?.[settingName as keyof typeof settings] || '';\n\n if (settingName === 'script') {\n defaultValue = getScriptValue(metric as MetricAggregationWithInlineScript);\n }\n\n return (\n <InlineField label={label} labelWidth={16} tooltip={tooltip}>\n <Input\n id={id}\n placeholder={placeholder}\n onBlur={(e) => dispatch(changeMetricSetting({ metric, settingName, newValue: e.target.value }))}\n defaultValue={defaultValue}\n />\n </InlineField>\n );\n}\n","import { createAction } from '@reduxjs/toolkit';\n\nexport const addPipelineVariable = createAction('@pipelineVariables/add');\nexport const removePipelineVariable = createAction<number>('@pipelineVariables/remove');\n\nexport const renamePipelineVariable = createAction<{ index: number; newName: string }>('@pipelineVariables/rename');\n\nexport const changePipelineVariableMetric = createAction<{ index: number; newMetric: string }>(\n '@pipelineVariables/change_metric'\n);\n","import { Action } from '@reduxjs/toolkit';\n\nimport { PipelineVariable } from '../../../aggregations';\nimport { defaultPipelineVariable, generatePipelineVariableName } from '../utils';\n\nimport {\n addPipelineVariable,\n changePipelineVariableMetric,\n removePipelineVariable,\n renamePipelineVariable,\n} from './actions';\n\nexport const reducer = (state: PipelineVariable[] = [], action: Action) => {\n if (addPipelineVariable.match(action)) {\n return [...state, defaultPipelineVariable(generatePipelineVariableName(state))];\n }\n\n if (removePipelineVariable.match(action)) {\n return state.slice(0, action.payload).concat(state.slice(action.payload + 1));\n }\n\n if (renamePipelineVariable.match(action)) {\n return state.map((pipelineVariable, index) => {\n if (index !== action.payload.index) {\n return pipelineVariable;\n }\n\n return {\n ...pipelineVariable,\n name: action.payload.newName,\n };\n });\n }\n\n if (changePipelineVariableMetric.match(action)) {\n return state.map((pipelineVariable, index) => {\n if (index !== action.payload.index) {\n return pipelineVariable;\n }\n\n return {\n ...pipelineVariable,\n pipelineAgg: action.payload.newMetric,\n };\n });\n }\n\n return state;\n};\n","import { css } from '@emotion/css';\nimport { uniqueId } from 'lodash';\nimport React, { Fragment, useEffect } from 'react';\n\nimport { Input, InlineLabel } from '@grafana/ui';\n\nimport { useStatelessReducer, useDispatch } from '../../../../../hooks/useStatelessReducer';\nimport { AddRemove } from '../../../../AddRemove';\nimport { MetricPicker } from '../../../../MetricPicker';\nimport { BucketScript, MetricAggregation } from '../../aggregations';\nimport { changeMetricAttribute } from '../../state/actions';\nimport { SettingField } from '../SettingField';\n\nimport {\n addPipelineVariable,\n removePipelineVariable,\n renamePipelineVariable,\n changePipelineVariableMetric,\n} from './state/actions';\nimport { reducer } from './state/reducer';\n\ninterface Props {\n value: BucketScript;\n previousMetrics: MetricAggregation[];\n}\n\nexport const BucketScriptSettingsEditor = ({ value, previousMetrics }: Props) => {\n const upperStateDispatch = useDispatch();\n\n const dispatch = useStatelessReducer(\n (newValue) =>\n upperStateDispatch(changeMetricAttribute({ metric: value, attribute: 'pipelineVariables', newValue })),\n value.pipelineVariables,\n reducer\n );\n\n // The model might not have pipeline variables (or an empty array of pipeline vars) in it because of the way it was built in previous versions of the datasource.\n // If this is the case we add a default one.\n useEffect(() => {\n if (!value.pipelineVariables?.length) {\n dispatch(addPipelineVariable());\n }\n }, [dispatch, value.pipelineVariables?.length]);\n\n return (\n <>\n <div\n className={css`\n display: flex;\n `}\n >\n <InlineLabel width={16}>Variables</InlineLabel>\n <div\n className={css`\n display: grid;\n grid-template-columns: 1fr auto;\n row-gap: 4px;\n margin-bottom: 4px;\n `}\n >\n {value.pipelineVariables!.map((pipelineVar, index) => (\n // index as a key doesn't work here since removing an element\n // in the middle of the list, will cause the next element to obtain the same key as the removed one.\n // this will cause react to \"drop\" the last element of the list instead of the just removed one,\n // and the default value for the input won't match the model as the DOM won't get updated.\n // using pipelineVar.name is not an option since it might be duplicated by the user.\n // generating a unique key on every render, while is probably not the best solution in terms of performance\n // ensures the UI is in a correct state. We might want to optimize this if we see perf issue in the future.\n <Fragment key={uniqueId('es-bs-')}>\n <div\n className={css`\n display: grid;\n column-gap: 4px;\n grid-template-columns: auto auto;\n `}\n >\n <Input\n aria-label=\"Variable name\"\n defaultValue={pipelineVar.name}\n placeholder=\"Variable Name\"\n onBlur={(e) => dispatch(renamePipelineVariable({ newName: e.target.value, index }))}\n />\n <MetricPicker\n onChange={(e) => dispatch(changePipelineVariableMetric({ newMetric: e.value!.id, index }))}\n options={previousMetrics}\n value={pipelineVar.pipelineAgg}\n />\n </div>\n\n <AddRemove\n index={index}\n elements={value.pipelineVariables || []}\n onAdd={() => dispatch(addPipelineVariable())}\n onRemove={() => dispatch(removePipelineVariable(index))}\n />\n </Fragment>\n ))}\n </div>\n </div>\n\n <SettingField\n label=\"Script\"\n metric={value}\n settingName=\"script\"\n tooltip=\"Elasticsearch v5.0 and above: Scripting language is Painless. Use params.<var> to reference a variable. Elasticsearch pre-v5.0: Scripting language is per default Groovy if not changed. For Groovy use <var> to reference a variable.\"\n placeholder=\"params.var1 / params.var2\"\n />\n </>\n );\n};\n","import { uniqueId } from 'lodash';\nimport React, { useRef } from 'react';\n\nimport { Input, InlineField, Select, InlineSwitch } from '@grafana/ui';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { movingAvgModelOptions } from '../../../../query_def';\nimport { isEWMAMovingAverage, isHoltMovingAverage, isHoltWintersMovingAverage, MovingAverage } from '../aggregations';\nimport { changeMetricSetting } from '../state/actions';\n\nimport { SettingField } from './SettingField';\n\ninterface Props {\n metric: MovingAverage;\n}\n\n// The way we handle changes for those settings is not ideal compared to the other components in the editor\n// FIXME: using `changeMetricSetting` will cause an error when switching from models that have different options\n// as they might be incompatible. We should clear all other options on model change.\nexport const MovingAverageSettingsEditor = ({ metric }: Props) => {\n const dispatch = useDispatch();\n const { current: baseId } = useRef(uniqueId('es-moving-avg-'));\n\n return (\n <>\n <InlineField label=\"Model\" labelWidth={16}>\n <Select\n inputId={`${baseId}-model`}\n onChange={(value) => dispatch(changeMetricSetting({ metric, settingName: 'model', newValue: value.value }))}\n options={movingAvgModelOptions}\n value={metric.settings?.model}\n />\n </InlineField>\n\n <SettingField label=\"Window\" settingName=\"window\" metric={metric} placeholder=\"5\" />\n\n <SettingField label=\"Predict\" settingName=\"predict\" metric={metric} />\n\n {(isEWMAMovingAverage(metric) || isHoltMovingAverage(metric) || isHoltWintersMovingAverage(metric)) && (\n <InlineField label=\"Alpha\" labelWidth={16}>\n <Input\n id={`${baseId}-alpha`}\n onBlur={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'settings',\n newValue: {\n ...metric.settings?.settings,\n alpha: e.target.value,\n },\n })\n )\n }\n defaultValue={metric.settings?.settings?.alpha}\n />\n </InlineField>\n )}\n\n {(isHoltMovingAverage(metric) || isHoltWintersMovingAverage(metric)) && (\n <InlineField label=\"Beta\" labelWidth={16}>\n <Input\n id={`${baseId}-beta`}\n onBlur={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'settings',\n newValue: {\n ...metric.settings?.settings,\n beta: e.target.value,\n },\n })\n )\n }\n defaultValue={metric.settings?.settings?.beta}\n />\n </InlineField>\n )}\n\n {isHoltWintersMovingAverage(metric) && (\n <>\n <InlineField label=\"Gamma\" labelWidth={16}>\n <Input\n id={`${baseId}-gamma`}\n onBlur={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'settings',\n newValue: {\n ...metric.settings?.settings,\n gamma: e.target.value,\n },\n })\n )\n }\n defaultValue={metric.settings?.settings?.gamma}\n />\n </InlineField>\n <InlineField label=\"Period\" labelWidth={16}>\n <Input\n id={`${baseId}-period`}\n onBlur={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'settings',\n newValue: {\n ...metric.settings?.settings,\n period: e.target.value!,\n },\n })\n )\n }\n defaultValue={metric.settings?.settings?.period}\n />\n </InlineField>\n\n <InlineField label=\"Pad\" labelWidth={16}>\n <InlineSwitch\n id={`${baseId}-pad`}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'settings',\n newValue: { ...metric.settings?.settings, pad: e.target.checked },\n })\n )\n }\n checked={!!metric.settings?.settings?.pad}\n />\n </InlineField>\n </>\n )}\n\n {(isEWMAMovingAverage(metric) || isHoltMovingAverage(metric) || isHoltWintersMovingAverage(metric)) && (\n <InlineField label=\"Minimize\" labelWidth={16}>\n <InlineSwitch\n id={`${baseId}-minimize`}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n dispatch(changeMetricSetting({ metric, settingName: 'minimize', newValue: e.target.checked }))\n }\n checked={!!metric.settings?.minimize}\n />\n </InlineField>\n )}\n </>\n );\n};\n","import { css } from '@emotion/css';\nimport React, { FunctionComponent } from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { AsyncMultiSelect, InlineField, SegmentAsync, Select } from '@grafana/ui';\n\nimport { useFields } from '../../../../hooks/useFields';\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { orderOptions } from '../../BucketAggregationsEditor/utils';\nimport { TopMetrics } from '../aggregations';\nimport { changeMetricSetting } from '../state/actions';\n\ninterface Props {\n metric: TopMetrics;\n}\n\nconst toMultiSelectValue = (value: string): SelectableValue<string> => ({ value, label: value });\n\nexport const TopMetricsSettingsEditor: FunctionComponent<Props> = ({ metric }) => {\n const dispatch = useDispatch();\n const getOrderByOptions = useFields(['number', 'date']);\n const getMetricsOptions = useFields(metric.type);\n\n return (\n <>\n <InlineField label=\"Metrics\" labelWidth={16}>\n <AsyncMultiSelect\n onChange={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'metrics',\n newValue: e.map((v) => v.value!),\n })\n )\n }\n loadOptions={getMetricsOptions}\n value={metric.settings?.metrics?.map(toMultiSelectValue)}\n closeMenuOnSelect={false}\n defaultOptions\n />\n </InlineField>\n <InlineField label=\"Order\" labelWidth={16}>\n <Select\n onChange={(e) => dispatch(changeMetricSetting({ metric, settingName: 'order', newValue: e.value }))}\n options={orderOptions}\n value={metric.settings?.order}\n />\n </InlineField>\n <InlineField\n label=\"Order By\"\n labelWidth={16}\n className={css`\n & > div {\n width: 100%;\n }\n `}\n >\n <SegmentAsync\n className={css`\n margin-right: 0;\n `}\n loadOptions={getOrderByOptions}\n onChange={(e) => dispatch(changeMetricSetting({ metric, settingName: 'orderBy', newValue: e.value }))}\n placeholder=\"Select Field\"\n value={metric.settings?.orderBy}\n />\n </InlineField>\n </>\n );\n};\n","import { uniqueId } from 'lodash';\nimport React, { ComponentProps, useRef, useState } from 'react';\n\nimport { InlineField, Input, InlineSwitch, Select } from '@grafana/ui';\n\nimport { useDispatch } from '../../../../hooks/useStatelessReducer';\nimport { extendedStats } from '../../../../query_def';\nimport { useQuery } from '../../ElasticsearchQueryContext';\nimport { SettingsEditorContainer } from '../../SettingsEditorContainer';\nimport {\n MetricAggregation,\n isMetricAggregationWithInlineScript,\n isMetricAggregationWithMissingSupport,\n ExtendedStat,\n} from '../aggregations';\nimport { changeMetricMeta, changeMetricSetting } from '../state/actions';\nimport { metricAggregationConfig } from '../utils';\n\nimport { BucketScriptSettingsEditor } from './BucketScriptSettingsEditor';\nimport { MovingAverageSettingsEditor } from './MovingAverageSettingsEditor';\nimport { SettingField } from './SettingField';\nimport { TopMetricsSettingsEditor } from './TopMetricsSettingsEditor';\nimport { useDescription } from './useDescription';\n\n// TODO: Move this somewhere and share it with BucketsAggregation Editor\nconst inlineFieldProps: Partial<ComponentProps<typeof InlineField>> = {\n labelWidth: 16,\n};\n\ninterface Props {\n metric: MetricAggregation;\n previousMetrics: MetricAggregation[];\n}\n\nexport const SettingsEditor = ({ metric, previousMetrics }: Props) => {\n const { current: baseId } = useRef(uniqueId('es-setting-'));\n\n const dispatch = useDispatch();\n const description = useDescription(metric);\n const query = useQuery();\n\n const rateAggUnitOptions = [\n { value: 'second', label: 'Second' },\n { value: 'minute', label: 'Minute' },\n { value: 'hour', label: 'Hour' },\n { value: 'day', label: 'Day' },\n { value: 'week', label: 'Week' },\n { value: 'month', label: 'Month' },\n { value: 'quarter', label: 'Quarter' },\n { value: 'Year', label: 'Year' },\n ];\n\n const rateAggModeOptions = [\n { value: 'sum', label: 'Sum' },\n { value: 'value_count', label: 'Value count' },\n ];\n\n return (\n <SettingsEditorContainer label={description} hidden={metric.hide}>\n {metric.type === 'derivative' && <SettingField label=\"Unit\" metric={metric} settingName=\"unit\" />}\n\n {metric.type === 'serial_diff' && <SettingField label=\"Lag\" metric={metric} settingName=\"lag\" placeholder=\"1\" />}\n\n {metric.type === 'cumulative_sum' && <SettingField label=\"Format\" metric={metric} settingName=\"format\" />}\n\n {metric.type === 'moving_avg' && <MovingAverageSettingsEditor metric={metric} />}\n\n {metric.type === 'moving_fn' && (\n <>\n <SettingField label=\"Window\" metric={metric} settingName=\"window\" />\n <SettingField label=\"Script\" metric={metric} settingName=\"script\" />\n <SettingField label=\"Shift\" metric={metric} settingName=\"shift\" />\n </>\n )}\n\n {metric.type === 'top_metrics' && <TopMetricsSettingsEditor metric={metric} />}\n\n {metric.type === 'bucket_script' && (\n <BucketScriptSettingsEditor value={metric} previousMetrics={previousMetrics} />\n )}\n\n {(metric.type === 'raw_data' || metric.type === 'raw_document') && (\n <InlineField label=\"Size\" {...inlineFieldProps}>\n <Input\n id={`ES-query-${query.refId}_metric-${metric.id}-size`}\n onBlur={(e) => dispatch(changeMetricSetting({ metric, settingName: 'size', newValue: e.target.value }))}\n defaultValue={metric.settings?.size ?? metricAggregationConfig['raw_data'].defaults.settings?.size}\n />\n </InlineField>\n )}\n\n {metric.type === 'logs' && <SettingField label=\"Limit\" metric={metric} settingName=\"limit\" placeholder=\"500\" />}\n\n {metric.type === 'cardinality' && (\n <SettingField label=\"Precision Threshold\" metric={metric} settingName=\"precision_threshold\" />\n )}\n\n {metric.type === 'extended_stats' && (\n <>\n {extendedStats.map((stat) => (\n <ExtendedStatSetting\n key={stat.value}\n stat={stat}\n onChange={(newValue) => dispatch(changeMetricMeta({ metric, meta: stat.value, newValue }))}\n value={\n metric.meta?.[stat.value] !== undefined\n ? !!metric.meta?.[stat.value]\n : !!metricAggregationConfig['extended_stats'].defaults.meta?.[stat.value]\n }\n />\n ))}\n\n <SettingField label=\"Sigma\" metric={metric} settingName=\"sigma\" placeholder=\"3\" />\n </>\n )}\n\n {metric.type === 'percentiles' && (\n <InlineField label=\"Percentiles\" {...inlineFieldProps}>\n <Input\n id={`${baseId}-percentiles-percents`}\n onBlur={(e) =>\n dispatch(\n changeMetricSetting({\n metric,\n settingName: 'percents',\n newValue: e.target.value.split(',').filter(Boolean),\n })\n )\n }\n defaultValue={\n metric.settings?.percents || metricAggregationConfig['percentiles'].defaults.settings?.percents\n }\n placeholder=\"1,5,25,50,75,95,99\"\n />\n </InlineField>\n )}\n\n {metric.type === 'rate' && (\n <>\n <InlineField label=\"Unit\" {...inlineFieldProps} data-testid=\"unit-select\">\n <Select\n id={`ES-query-${query.refId}_metric-${metric.id}-unit`}\n onChange={(e) => dispatch(changeMetricSetting({ metric, settingName: 'unit', newValue: e.value }))}\n options={rateAggUnitOptions}\n value={metric.settings?.unit}\n />\n </InlineField>\n\n <InlineField label=\"Mode\" {...inlineFieldProps} data-testid=\"mode-select\">\n <Select\n id={`ES-query-${query.refId}_metric-${metric.id}-mode`}\n onChange={(e) => dispatch(changeMetricSetting({ metric, settingName: 'mode', newValue: e.value }))}\n options={rateAggModeOptions}\n value={metric.settings?.unit}\n />\n </InlineField>\n </>\n )}\n\n {isMetricAggregationWithInlineScript(metric) && (\n <SettingField label=\"Script\" metric={metric} settingName=\"script\" placeholder=\"_value * 1\" />\n )}\n\n {isMetricAggregationWithMissingSupport(metric) && (\n <SettingField\n label=\"Missing\"\n metric={metric}\n settingName=\"missing\"\n tooltip=\"The missing parameter defines how documents that are missing a value should be treated. By default\n they will be ignored but it is also possible to treat them as if they had a value\"\n />\n )}\n </SettingsEditorContainer>\n );\n};\n\ninterface ExtendedStatSettingProps {\n stat: ExtendedStat;\n onChange: (checked: boolean) => void;\n value: boolean;\n}\nconst ExtendedStatSetting = ({ stat, onChange, value }: ExtendedStatSettingProps) => {\n // this is needed for the htmlFor prop in the label so that clicking the label will toggle the switch state.\n const [id] = useState(uniqueId(`es-field-id-`));\n\n return (\n <InlineField label={stat.label} {...inlineFieldProps} key={stat.value}>\n <InlineSwitch\n id={id}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.checked)}\n value={value}\n />\n </InlineField>\n );\n};\n","import { extendedStats } from '../../../../query_def';\nimport { MetricAggregation } from '../aggregations';\n\nconst hasValue = (value: string) => (object: { value: string }) => object.value === value;\n\n// FIXME: All the defaults and validations down here should be defined somewhere else\n// as they are also the defaults that are gonna be applied to the query.\n// In the previous version, the same method was taking care of describing the settings and setting defaults.\nexport const useDescription = (metric: MetricAggregation): string => {\n switch (metric.type) {\n case 'cardinality': {\n const precisionThreshold = metric.settings?.precision_threshold || '';\n return `Precision threshold: ${precisionThreshold}`;\n }\n\n case 'percentiles':\n if (metric.settings?.percents && metric.settings?.percents?.length >= 1) {\n return `Values: ${metric.settings?.percents}`;\n }\n\n return 'Percents: Default';\n\n case 'extended_stats': {\n const selectedStats = Object.entries(metric.meta || {})\n .map(([key, value]) => value && extendedStats.find(hasValue(key))?.label)\n .filter(Boolean);\n\n return `Stats: ${selectedStats.length > 0 ? selectedStats.join(', ') : 'None selected'}`;\n }\n\n case 'raw_document':\n case 'raw_data': {\n const size = metric.settings?.size || 500;\n return `Size: ${size}`;\n }\n\n default:\n return 'Options';\n }\n};\n","import { cx } from '@emotion/css';\nimport React, { useCallback } from 'react';\nimport { satisfies } from 'semver';\n\nimport { SelectableValue } from '@grafana/data';\nimport { InlineSegmentGroup, Segment, SegmentAsync, useTheme2 } from '@grafana/ui';\n\nimport { useFields } from '../../../hooks/useFields';\nimport { useDispatch } from '../../../hooks/useStatelessReducer';\nimport { MetricPicker } from '../../MetricPicker';\nimport { useDatasource, useQuery } from '../ElasticsearchQueryContext';\nimport { segmentStyles } from '../styles';\n\nimport { SettingsEditor } from './SettingsEditor';\nimport {\n isMetricAggregationWithField,\n isMetricAggregationWithInlineScript,\n isMetricAggregationWithSettings,\n isPipelineAggregation,\n isPipelineAggregationWithMultipleBucketPaths,\n MetricAggregation,\n MetricAggregationType,\n} from './aggregations';\nimport { changeMetricField, changeMetricType } from './state/actions';\nimport { getStyles } from './styles';\nimport { metricAggregationConfig } from './utils';\n\nconst toOption = (metric: MetricAggregation) => ({\n label: metricAggregationConfig[metric.type].label,\n value: metric.type,\n});\n\ninterface Props {\n value: MetricAggregation;\n}\n\n// If a metric is a Pipeline Aggregation (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html)\n// it doesn't make sense to show it in the type picker when there is no non-pipeline-aggregation previously selected\n// as they work on the outputs produced from other aggregations rather than from documents or fields.\n// This means we should filter them out from the type picker if there's no other \"basic\" aggregation before the current one.\nconst isBasicAggregation = (metric: MetricAggregation) => !metricAggregationConfig[metric.type].isPipelineAgg;\n\nconst getTypeOptions = (\n previousMetrics: MetricAggregation[],\n esVersion: string,\n xpack = false\n): Array<SelectableValue<MetricAggregationType>> => {\n // we'll include Pipeline Aggregations only if at least one previous metric is a \"Basic\" one\n const includePipelineAggregations = previousMetrics.some(isBasicAggregation);\n\n return (\n Object.entries(metricAggregationConfig)\n // Only showing metrics type supported by the configured version of ES\n .filter(([_, { versionRange = '*' }]) => satisfies(esVersion, versionRange))\n // Filtering out Pipeline Aggregations if there's no basic metric selected before\n .filter(([_, config]) => includePipelineAggregations || !config.isPipelineAgg)\n // Filtering out X-Pack plugins if X-Pack is disabled\n .filter(([_, config]) => (config.xpack ? xpack : true))\n .map(([key, { label }]) => ({\n label,\n value: key as MetricAggregationType,\n }))\n );\n};\n\nexport const MetricEditor = ({ value }: Props) => {\n const styles = getStyles(useTheme2(), !!value.hide);\n const datasource = useDatasource();\n const query = useQuery();\n const dispatch = useDispatch();\n const getFields = useFields(value.type);\n\n const loadOptions = useCallback(async () => {\n const remoteFields = await getFields();\n\n // Metric aggregations that have inline script support don't require a field to be set.\n if (isMetricAggregationWithInlineScript(value)) {\n return [{ label: 'None' }, ...remoteFields];\n }\n\n return remoteFields;\n }, [getFields, value]);\n\n const previousMetrics = query.metrics!.slice(\n 0,\n query.metrics!.findIndex((m) => m.id === value.id)\n );\n\n return (\n <>\n <InlineSegmentGroup>\n <Segment\n className={cx(styles.color, segmentStyles)}\n options={getTypeOptions(previousMetrics, datasource.esVersion, datasource.xpack)}\n onChange={(e) => dispatch(changeMetricType({ id: value.id, type: e.value! }))}\n value={toOption(value)}\n />\n\n {isMetricAggregationWithField(value) && !isPipelineAggregation(value) && (\n <SegmentAsync\n className={cx(styles.color, segmentStyles)}\n loadOptions={loadOptions}\n onChange={(e) => dispatch(changeMetricField({ id: value.id, field: e.value! }))}\n placeholder=\"Select Field\"\n value={value.field}\n />\n )}\n\n {isPipelineAggregation(value) && !isPipelineAggregationWithMultipleBucketPaths(value) && (\n <MetricPicker\n className={cx(styles.color, segmentStyles)}\n onChange={(e) => dispatch(changeMetricField({ id: value.id, field: e.value?.id! }))}\n options={previousMetrics}\n value={value.field}\n />\n )}\n </InlineSegmentGroup>\n\n {isMetricAggregationWithSettings(value) && <SettingsEditor metric={value} previousMetrics={previousMetrics} />}\n </>\n );\n};\n","import { css } from '@emotion/css';\n\nimport { GrafanaTheme2 } from '@grafana/data';\n\nexport const getStyles = (theme: GrafanaTheme2, hidden: boolean) => {\n return {\n color:\n hidden &&\n css`\n &,\n &:hover,\n label,\n a {\n color: ${hidden ? theme.colors.text.disabled : theme.colors.text.primary};\n }\n `,\n };\n};\n","import React from 'react';\n\nimport { useDispatch } from '../../../hooks/useStatelessReducer';\nimport { IconButton } from '../../IconButton';\nimport { useQuery } from '../ElasticsearchQueryContext';\nimport { QueryEditorRow } from '../QueryEditorRow';\n\nimport { MetricEditor } from './MetricEditor';\nimport { MetricAggregation } from './aggregations';\nimport { addMetric, removeMetric, toggleMetricVisibility } from './state/actions';\nimport { metricAggregationConfig } from './utils';\n\ninterface Props {\n nextId: MetricAggregation['id'];\n}\n\nexport const MetricAggregationsEditor = ({ nextId }: Props) => {\n const dispatch = useDispatch();\n const { metrics } = useQuery();\n const totalMetrics = metrics?.length || 0;\n\n return (\n <>\n {metrics?.map((metric, index) => (\n <QueryEditorRow\n key={`${metric.type}-${metric.id}`}\n label={`Metric (${metric.id})`}\n hidden={metric.hide}\n onHideClick={() => dispatch(toggleMetricVisibility(metric.id))}\n onRemoveClick={totalMetrics > 1 && (() => dispatch(removeMetric(metric.id)))}\n >\n <MetricEditor value={metric} />\n\n {!metricAggregationConfig[metric.type].isSingleMetric && index === 0 && (\n <IconButton iconName=\"plus\" onClick={() => dispatch(addMetric(nextId))} label=\"add\" />\n )}\n </QueryEditorRow>\n ))}\n </>\n );\n};\n","import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { getDefaultTimeRange, GrafanaTheme2, QueryEditorProps } from '@grafana/data';\nimport { Alert, InlineField, InlineLabel, Input, QueryField, useStyles2 } from '@grafana/ui';\n\nimport { ElasticDatasource } from '../../datasource';\nimport { useNextId } from '../../hooks/useNextId';\nimport { useDispatch } from '../../hooks/useStatelessReducer';\nimport { ElasticsearchOptions, ElasticsearchQuery } from '../../types';\nimport { isSupportedVersion } from '../../utils';\n\nimport { BucketAggregationsEditor } from './BucketAggregationsEditor';\nimport { ElasticsearchProvider } from './ElasticsearchQueryContext';\nimport { MetricAggregationsEditor } from './MetricAggregationsEditor';\nimport { metricAggregationConfig } from './MetricAggregationsEditor/utils';\nimport { changeAliasPattern, changeQuery } from './state';\n\nexport type ElasticQueryEditorProps = QueryEditorProps<ElasticDatasource, ElasticsearchQuery, ElasticsearchOptions>;\n\nexport const QueryEditor = ({ query, onChange, onRunQuery, datasource, range }: ElasticQueryEditorProps) => {\n if (!isSupportedVersion(datasource.esVersion)) {\n return (\n <Alert\n title={`Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed`}\n ></Alert>\n );\n }\n return (\n <ElasticsearchProvider\n datasource={datasource}\n onChange={onChange}\n onRunQuery={onRunQuery}\n query={query}\n range={range || getDefaultTimeRange()}\n >\n <QueryEditorForm value={query} />\n </ElasticsearchProvider>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n root: css`\n display: flex;\n `,\n queryFieldWrapper: css`\n flex-grow: 1;\n margin: 0 ${theme.spacing(0.5)} ${theme.spacing(0.5)} 0;\n `,\n});\n\ninterface Props {\n value: ElasticsearchQuery;\n}\n\nconst QueryEditorForm = ({ value }: Props) => {\n const dispatch = useDispatch();\n const nextId = useNextId();\n const styles = useStyles2(getStyles);\n\n // To be considered a time series query, the last bucked aggregation must be a Date Histogram\n const isTimeSeriesQuery = value.bucketAggs?.slice(-1)[0]?.type === 'date_histogram';\n\n const showBucketAggregationsEditor = value.metrics?.every(\n (metric) => !metricAggregationConfig[metric.type].isSingleMetric\n );\n\n return (\n <>\n <div className={styles.root}>\n <InlineLabel width={17}>Query</InlineLabel>\n <div className={styles.queryFieldWrapper}>\n <QueryField\n query={value.query}\n // By default QueryField calls onChange if onBlur is not defined, this will trigger a rerender\n // And slate will claim the focus, making it impossible to leave the field.\n onBlur={() => {}}\n onChange={(query) => dispatch(changeQuery(query))}\n placeholder=\"Lucene Query\"\n portalOrigin=\"elasticsearch\"\n />\n </div>\n <InlineField\n label=\"Alias\"\n labelWidth={15}\n disabled={!isTimeSeriesQuery}\n tooltip=\"Aliasing only works for timeseries queries (when the last group is 'Date Histogram'). For all other query types this field is ignored.\"\n >\n <Input\n id={`ES-query-${value.refId}_alias`}\n placeholder=\"Alias Pattern\"\n onBlur={(e) => dispatch(changeAliasPattern(e.currentTarget.value))}\n defaultValue={value.alias}\n />\n </InlineField>\n </div>\n\n <MetricAggregationsEditor nextId={nextId} />\n {showBucketAggregationsEditor && <BucketAggregationsEditor nextId={nextId} />}\n </>\n );\n};\n","import { css } from '@emotion/css';\nimport React, { Dispatch, SetStateAction, useEffect, useState } from 'react';\nimport { usePrevious } from 'react-use';\n\nimport { VariableSuggestion } from '@grafana/data';\nimport { DataSourcePicker } from '@grafana/runtime';\nimport { Button, LegacyForms, DataLinkInput, stylesFactory } from '@grafana/ui';\n\nimport { DataLinkConfig } from '../types';\n\nconst { FormField, Switch } = LegacyForms;\n\nconst getStyles = stylesFactory(() => ({\n firstRow: css`\n display: flex;\n `,\n nameField: css`\n flex: 2;\n `,\n regexField: css`\n flex: 3;\n `,\n row: css`\n display: flex;\n align-items: baseline;\n `,\n urlField: css`\n flex: 1;\n `,\n urlDisplayLabelField: css`\n flex: 1;\n `,\n}));\n\ntype Props = {\n value: DataLinkConfig;\n onChange: (value: DataLinkConfig) => void;\n onDelete: () => void;\n suggestions: VariableSuggestion[];\n className?: string;\n};\nexport const DataLink = (props: Props) => {\n const { value, onChange, onDelete, suggestions, className } = props;\n const styles = getStyles();\n const [showInternalLink, setShowInternalLink] = useInternalLink(value.datasourceUid);\n\n const handleChange = (field: keyof typeof value) => (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange({\n ...value,\n [field]: event.currentTarget.value,\n });\n };\n\n return (\n <div className={className}>\n <div className={styles.firstRow + ' gf-form'}>\n <FormField\n className={styles.nameField}\n labelWidth={6}\n // A bit of a hack to prevent using default value for the width from FormField\n inputWidth={null}\n label=\"Field\"\n type=\"text\"\n value={value.field}\n tooltip={'Can be exact field name or a regex pattern that will match on the field name.'}\n onChange={handleChange('field')}\n />\n <Button\n variant={'destructive'}\n title=\"Remove field\"\n icon=\"times\"\n onClick={(event) => {\n event.preventDefault();\n onDelete();\n }}\n />\n </div>\n <div className=\"gf-form\">\n <FormField\n label={showInternalLink ? 'Query' : 'URL'}\n labelWidth={6}\n inputEl={\n <DataLinkInput\n placeholder={showInternalLink ? '${__value.raw}' : 'http://example.com/${__value.raw}'}\n value={value.url || ''}\n onChange={(newValue) =>\n onChange({\n ...value,\n url: newValue,\n })\n }\n suggestions={suggestions}\n />\n }\n className={styles.urlField}\n />\n <FormField\n className={styles.urlDisplayLabelField}\n inputWidth={null}\n label=\"URL Label\"\n type=\"text\"\n value={value.urlDisplayLabel}\n onChange={handleChange('urlDisplayLabel')}\n tooltip={'Use to override the button label.'}\n />\n </div>\n\n <div className={styles.row}>\n <Switch\n labelClass={'width-6'}\n label=\"Internal link\"\n checked={showInternalLink}\n onChange={() => {\n if (showInternalLink) {\n onChange({\n ...value,\n datasourceUid: undefined,\n });\n }\n setShowInternalLink(!showInternalLink);\n }}\n />\n\n {showInternalLink && (\n <DataSourcePicker\n tracing={true}\n // Uid and value should be always set in the db and so in the items.\n onChange={(ds) => {\n onChange({\n ...value,\n datasourceUid: ds.uid,\n });\n }}\n current={value.datasourceUid}\n />\n )}\n </div>\n </div>\n );\n};\n\nfunction useInternalLink(datasourceUid?: string): [boolean, Dispatch<SetStateAction<boolean>>] {\n const [showInternalLink, setShowInternalLink] = useState<boolean>(!!datasourceUid);\n const previousUid = usePrevious(datasourceUid);\n\n // Force internal link visibility change if uid changed outside of this component.\n useEffect(() => {\n if (!previousUid && datasourceUid && !showInternalLink) {\n setShowInternalLink(true);\n }\n if (previousUid && !datasourceUid && showInternalLink) {\n setShowInternalLink(false);\n }\n }, [previousUid, datasourceUid, showInternalLink]);\n\n return [showInternalLink, setShowInternalLink];\n}\n","import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { GrafanaTheme2, VariableOrigin, DataLinkBuiltInVars } from '@grafana/data';\nimport { Button, useStyles2 } from '@grafana/ui';\n\nimport { DataLinkConfig } from '../types';\n\nimport { DataLink } from './DataLink';\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n infoText: css`\n padding-bottom: ${theme.spacing(2)};\n color: ${theme.colors.text.secondary};\n `,\n dataLink: css`\n margin-bottom: ${theme.spacing(1)};\n `,\n };\n};\n\ntype Props = {\n value?: DataLinkConfig[];\n onChange: (value: DataLinkConfig[]) => void;\n};\nexport const DataLinks = (props: Props) => {\n const { value, onChange } = props;\n const styles = useStyles2(getStyles);\n\n return (\n <>\n <h3 className=\"page-heading\">Data links</h3>\n\n <div className={styles.infoText}>\n Add links to existing fields. Links will be shown in log row details next to the field value.\n </div>\n\n {value && value.length > 0 && (\n <div className=\"gf-form-group\">\n {value.map((field, index) => {\n return (\n <DataLink\n className={styles.dataLink}\n key={index}\n value={field}\n onChange={(newField) => {\n const newDataLinks = [...value];\n newDataLinks.splice(index, 1, newField);\n onChange(newDataLinks);\n }}\n onDelete={() => {\n const newDataLinks = [...value];\n newDataLinks.splice(index, 1);\n onChange(newDataLinks);\n }}\n suggestions={[\n {\n value: DataLinkBuiltInVars.valueRaw,\n label: 'Raw value',\n documentation: 'Raw value of the field',\n origin: VariableOrigin.Value,\n },\n ]}\n />\n );\n })}\n </div>\n )}\n\n <Button\n type=\"button\"\n variant={'secondary'}\n className={css`\n margin-right: 10px;\n `}\n icon=\"plus\"\n onClick={(event) => {\n event.preventDefault();\n const newDataLinks = [...(value || []), { field: '', url: '' }];\n onChange(newDataLinks);\n }}\n >\n Add\n </Button>\n </>\n );\n};\n","import { valid } from 'semver';\n\nimport { DataSourceSettings } from '@grafana/data';\n\nimport { ElasticsearchOptions } from '../types';\nimport { coerceESVersion } from '../utils';\n\nimport { defaultMaxConcurrentShardRequests } from './ElasticDetails';\n\nexport const coerceOptions = (\n options: DataSourceSettings<ElasticsearchOptions, {}>\n): DataSourceSettings<ElasticsearchOptions, {}> => {\n const esVersion = coerceESVersion(options.jsonData.esVersion);\n\n return {\n ...options,\n jsonData: {\n ...options.jsonData,\n timeField: options.jsonData.timeField || '@timestamp',\n esVersion,\n maxConcurrentShardRequests:\n options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(esVersion),\n logMessageField: options.jsonData.logMessageField || '',\n logLevelField: options.jsonData.logLevelField || '',\n includeFrozen: options.jsonData.includeFrozen ?? false,\n },\n };\n};\n\nexport const isValidOptions = (options: DataSourceSettings<ElasticsearchOptions, {}>): boolean => {\n return (\n // esVersion should be a valid semver string\n !!valid(options.jsonData.esVersion) &&\n // timeField should not be empty or nullish\n !!options.jsonData.timeField &&\n // maxConcurrentShardRequests should be a number AND greater than 0\n !!options.jsonData.maxConcurrentShardRequests &&\n // message & level fields should be defined\n options.jsonData.logMessageField !== undefined &&\n options.jsonData.logLevelField !== undefined\n );\n};\n\ntype Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;\n\nexport const isTruthy = <T>(value: T): value is Truthy<T> => Boolean(value);\n","import React from 'react';\nimport { gte, lt, valid } from 'semver';\n\nimport { DataSourceSettings, SelectableValue } from '@grafana/data';\nimport { FieldSet, InlineField, Input, Select, InlineSwitch } from '@grafana/ui';\n\nimport { ElasticsearchOptions, Interval } from '../types';\n\nimport { isTruthy } from './utils';\n\nconst indexPatternTypes: Array<SelectableValue<'none' | Interval>> = [\n { label: 'No pattern', value: 'none' },\n { label: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },\n { label: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },\n { label: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },\n { label: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },\n { label: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },\n];\n\nconst esVersions: SelectableValue[] = [\n { label: '7.10+', value: '7.10.0' },\n {\n label: '8.0+',\n value: '8.0.0',\n description: 'support for Elasticsearch 8 is currently experimental',\n },\n];\n\ntype Props = {\n value: DataSourceSettings<ElasticsearchOptions>;\n onChange: (value: DataSourceSettings<ElasticsearchOptions>) => void;\n};\nexport const ElasticDetails = ({ value, onChange }: Props) => {\n const currentVersion = esVersions.find((version) => version.value === value.jsonData.esVersion);\n const customOption =\n !currentVersion && valid(value.jsonData.esVersion)\n ? {\n label: value.jsonData.esVersion,\n value: value.jsonData.esVersion,\n }\n : undefined;\n return (\n <>\n <FieldSet label=\"Elasticsearch details\">\n <InlineField label=\"Index name\" labelWidth={26}>\n <Input\n id=\"es_config_indexName\"\n value={value.database || ''}\n onChange={changeHandler('database', value, onChange)}\n width={24}\n placeholder=\"es-index-name\"\n required\n />\n </InlineField>\n\n <InlineField label=\"Pattern\" labelWidth={26}>\n <Select\n inputId=\"es_config_indexPattern\"\n value={indexPatternTypes.find(\n (pattern) => pattern.value === (value.jsonData.interval === undefined ? 'none' : value.jsonData.interval)\n )}\n options={indexPatternTypes}\n onChange={intervalHandler(value, onChange)}\n width={24}\n />\n </InlineField>\n\n <InlineField label=\"Time field name\" labelWidth={26}>\n <Input\n id=\"es_config_timeField\"\n value={value.jsonData.timeField || ''}\n onChange={jsonDataChangeHandler('timeField', value, onChange)}\n width={24}\n placeholder=\"@timestamp\"\n required\n />\n </InlineField>\n\n <InlineField label=\"ElasticSearch version\" labelWidth={26}>\n <Select\n inputId=\"es_config_version\"\n options={[customOption, ...esVersions].filter(isTruthy)}\n onChange={(option) => {\n const maxConcurrentShardRequests = getMaxConcurrenShardRequestOrDefault(\n value.jsonData.maxConcurrentShardRequests,\n option.value!\n );\n onChange({\n ...value,\n jsonData: {\n ...value.jsonData,\n esVersion: option.value!,\n maxConcurrentShardRequests,\n },\n });\n }}\n value={currentVersion || customOption}\n width={24}\n />\n </InlineField>\n\n {gte(value.jsonData.esVersion, '5.6.0') && (\n <InlineField label=\"Max concurrent Shard Requests\" labelWidth={26}>\n <Input\n id=\"es_config_shardRequests\"\n value={value.jsonData.maxConcurrentShardRequests || ''}\n onChange={jsonDataChangeHandler('maxConcurrentShardRequests', value, onChange)}\n width={24}\n />\n </InlineField>\n )}\n\n <InlineField\n label=\"Min time interval\"\n labelWidth={26}\n tooltip={\n <>\n A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example{' '}\n <code>1m</code> if your data is written every minute.\n </>\n }\n error=\"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s\"\n invalid={!!value.jsonData.timeInterval && !/^\\d+(ms|[Mwdhmsy])$/.test(value.jsonData.timeInterval)}\n >\n <Input\n id=\"es_config_minTimeInterval\"\n value={value.jsonData.timeInterval || ''}\n onChange={jsonDataChangeHandler('timeInterval', value, onChange)}\n width={24}\n placeholder=\"10s\"\n />\n </InlineField>\n\n <InlineField label=\"X-Pack enabled\" labelWidth={26}>\n <InlineSwitch\n id=\"es_config_xpackEnabled\"\n checked={value.jsonData.xpack || false}\n onChange={jsonDataSwitchChangeHandler('xpack', value, onChange)}\n />\n </InlineField>\n\n {gte(value.jsonData.esVersion, '6.6.0') && value.jsonData.xpack && (\n <InlineField label=\"Include Frozen Indices\" labelWidth={26}>\n <InlineSwitch\n id=\"es_config_frozenIndices\"\n checked={value.jsonData.includeFrozen ?? false}\n onChange={jsonDataSwitchChangeHandler('includeFrozen', value, onChange)}\n />\n </InlineField>\n )}\n </FieldSet>\n </>\n );\n};\n\n// TODO: Use change handlers from @grafana/data\nconst changeHandler =\n (key: keyof DataSourceSettings<ElasticsearchOptions>, value: Props['value'], onChange: Props['onChange']) =>\n (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {\n onChange({\n ...value,\n [key]: event.currentTarget.value,\n });\n };\n\n// TODO: Use change handlers from @grafana/data\nconst jsonDataChangeHandler =\n (key: keyof ElasticsearchOptions, value: Props['value'], onChange: Props['onChange']) =>\n (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {\n onChange({\n ...value,\n jsonData: {\n ...value.jsonData,\n [key]: event.currentTarget.value,\n },\n });\n };\n\nconst jsonDataSwitchChangeHandler =\n (key: keyof ElasticsearchOptions, value: Props['value'], onChange: Props['onChange']) =>\n (event: React.SyntheticEvent<HTMLInputElement>) => {\n onChange({\n ...value,\n jsonData: {\n ...value.jsonData,\n [key]: event.currentTarget.checked,\n },\n });\n };\n\nconst intervalHandler =\n (value: Props['value'], onChange: Props['onChange']) => (option: SelectableValue<Interval | 'none'>) => {\n const { database } = value;\n // If option value is undefined it will send its label instead so we have to convert made up value to undefined here.\n const newInterval = option.value === 'none' ? undefined : option.value;\n\n if (!database || database.length === 0 || database.startsWith('[logstash-]')) {\n let newDatabase = '';\n\n if (newInterval !== undefined) {\n const pattern = indexPatternTypes.find((pattern) => pattern.value === newInterval);\n\n if (pattern) {\n newDatabase = pattern.example ?? '';\n }\n }\n\n onChange({\n ...value,\n database: newDatabase,\n jsonData: {\n ...value.jsonData,\n interval: newInterval,\n },\n });\n } else {\n onChange({\n ...value,\n jsonData: {\n ...value.jsonData,\n interval: newInterval,\n },\n });\n }\n };\n\nfunction getMaxConcurrenShardRequestOrDefault(maxConcurrentShardRequests: number | undefined, version: string): number {\n if (maxConcurrentShardRequests === 5 && lt(version, '7.0.0')) {\n return 256;\n }\n\n if (maxConcurrentShardRequests === 256 && gte(version, '7.0.0')) {\n return 5;\n }\n\n return maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(version);\n}\n\nexport function defaultMaxConcurrentShardRequests(version: string) {\n return gte(version, '7.0.0') ? 5 : 256;\n}\n","import React from 'react';\n\nimport { Input, InlineField, FieldSet } from '@grafana/ui';\n\nimport { ElasticsearchOptions } from '../types';\n\ntype Props = {\n value: ElasticsearchOptions;\n onChange: (value: ElasticsearchOptions) => void;\n};\nexport const LogsConfig = (props: Props) => {\n const { value, onChange } = props;\n const changeHandler =\n (key: keyof ElasticsearchOptions) => (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {\n onChange({\n ...value,\n [key]: event.currentTarget.value,\n });\n };\n\n return (\n <FieldSet label=\"Logs\">\n <InlineField label=\"Message field name\" labelWidth={22}>\n <Input\n id=\"es_logs-config_logMessageField\"\n value={value.logMessageField}\n onChange={changeHandler('logMessageField')}\n placeholder=\"_source\"\n width={24}\n />\n </InlineField>\n\n <InlineField label=\"Level field name\" labelWidth={22}>\n <Input\n id=\"es_logs-config_logLevelField\"\n value={value.logLevelField}\n onChange={changeHandler('logLevelField')}\n width={24}\n />\n </InlineField>\n </FieldSet>\n );\n};\n","import { clone, filter, find, identity, isArray, keys, map, uniq, values as _values } from 'lodash';\n\nimport {\n DataQueryResponse,\n DataFrame,\n toDataFrame,\n FieldType,\n MutableDataFrame,\n PreferredVisualisationType,\n} from '@grafana/data';\nimport TableModel from 'app/core/table_model';\nimport flatten from 'app/core/utils/flatten';\n\nimport {\n ExtendedStatMetaType,\n isMetricAggregationWithField,\n TopMetrics,\n} from './components/QueryEditor/MetricAggregationsEditor/aggregations';\nimport { metricAggregationConfig } from './components/QueryEditor/MetricAggregationsEditor/utils';\nimport * as queryDef from './query_def';\nimport { ElasticsearchAggregation, ElasticsearchQuery } from './types';\nimport { describeMetric, getScriptValue } from './utils';\n\nconst HIGHLIGHT_TAGS_EXP = `${queryDef.highlightTags.pre}([^@]+)${queryDef.highlightTags.post}`;\ntype TopMetricMetric = Record<string, number>;\ninterface TopMetricBucket {\n top: Array<{\n metrics: TopMetricMetric;\n }>;\n}\n\nexport class ElasticResponse {\n constructor(private targets: ElasticsearchQuery[], private response: any) {\n this.targets = targets;\n this.response = response;\n }\n\n processMetrics(esAgg: any, target: ElasticsearchQuery, seriesList: any, props: any) {\n let newSeries: any;\n\n for (let y = 0; y < target.metrics!.length; y++) {\n const metric = target.metrics![y];\n if (metric.hide) {\n continue;\n }\n\n switch (metric.type) {\n case 'count': {\n newSeries = { datapoints: [], metric: 'count', props, refId: target.refId };\n for (let i = 0; i < esAgg.buckets.length; i++) {\n const bucket = esAgg.buckets[i];\n const value = bucket.doc_count;\n newSeries.datapoints.push([value, bucket.key]);\n }\n seriesList.push(newSeries);\n break;\n }\n case 'percentiles': {\n if (esAgg.buckets.length === 0) {\n break;\n }\n\n const firstBucket = esAgg.buckets[0];\n const percentiles = firstBucket[metric.id].values;\n\n for (const percentileName in percentiles) {\n newSeries = {\n datapoints: [],\n metric: 'p' + percentileName,\n props: props,\n field: metric.field,\n refId: target.refId,\n };\n\n for (let i = 0; i < esAgg.buckets.length; i++) {\n const bucket = esAgg.buckets[i];\n const values = bucket[metric.id].values;\n newSeries.datapoints.push([values[percentileName], bucket.key]);\n }\n seriesList.push(newSeries);\n }\n\n break;\n }\n case 'extended_stats': {\n for (const statName in metric.meta) {\n if (!metric.meta[statName as ExtendedStatMetaType]) {\n continue;\n }\n\n newSeries = {\n datapoints: [],\n metric: statName,\n props: props,\n field: metric.field,\n refId: target.refId,\n };\n\n for (let i = 0; i < esAgg.buckets.length; i++) {\n const bucket = esAgg.buckets[i];\n const stats = bucket[metric.id];\n\n // add stats that are in nested obj to top level obj\n stats.std_deviation_bounds_upper = stats.std_deviation_bounds.upper;\n stats.std_deviation_bounds_lower = stats.std_deviation_bounds.lower;\n\n newSeries.datapoints.push([stats[statName], bucket.key]);\n }\n\n seriesList.push(newSeries);\n }\n\n break;\n }\n case 'top_metrics': {\n if (metric.settings?.metrics?.length) {\n for (const metricField of metric.settings?.metrics) {\n newSeries = {\n datapoints: [],\n metric: metric.type,\n props: props,\n refId: target.refId,\n field: metricField,\n };\n for (let i = 0; i < esAgg.buckets.length; i++) {\n const bucket = esAgg.buckets[i];\n const stats = bucket[metric.id] as TopMetricBucket;\n const values = stats.top.map((hit) => {\n if (hit.metrics[metricField]) {\n return hit.metrics[metricField];\n }\n return null;\n });\n const point = [values[values.length - 1], bucket.key];\n newSeries.datapoints.push(point);\n }\n seriesList.push(newSeries);\n }\n }\n break;\n }\n default: {\n newSeries = {\n datapoints: [],\n metric: metric.type,\n metricId: metric.id,\n props: props,\n refId: target.refId,\n };\n\n if (isMetricAggregationWithField(metric)) {\n newSeries.field = metric.field;\n }\n\n for (let i = 0; i < esAgg.buckets.length; i++) {\n const bucket = esAgg.buckets[i];\n const value = bucket[metric.id];\n\n if (value !== undefined) {\n if (value.normalized_value) {\n newSeries.datapoints.push([value.normalized_value, bucket.key]);\n } else {\n newSeries.datapoints.push([value.value, bucket.key]);\n }\n }\n }\n seriesList.push(newSeries);\n break;\n }\n }\n }\n }\n\n processAggregationDocs(\n esAgg: any,\n aggDef: ElasticsearchAggregation,\n target: ElasticsearchQuery,\n table: any,\n props: any\n ) {\n // add columns\n if (table.columns.length === 0) {\n for (const propKey of keys(props)) {\n table.addColumn({ text: propKey, filterable: true });\n }\n table.addColumn({ text: aggDef.field, filterable: true });\n }\n\n // helper func to add values to value array\n const addMetricValue = (values: any[], metricName: string, value: any) => {\n table.addColumn({ text: metricName });\n values.push(value);\n };\n const buckets = isArray(esAgg.buckets) ? esAgg.buckets : [esAgg.buckets];\n for (const bucket of buckets) {\n const values = [];\n\n for (const propValues of _values(props)) {\n values.push(propValues);\n }\n\n // add bucket key (value)\n values.push(bucket.key);\n\n for (const metric of target.metrics || []) {\n switch (metric.type) {\n case 'count': {\n addMetricValue(values, this.getMetricName(metric.type), bucket.doc_count);\n break;\n }\n case 'extended_stats': {\n for (const statName in metric.meta) {\n if (!metric.meta[statName as ExtendedStatMetaType]) {\n continue;\n }\n\n const stats = bucket[metric.id];\n // add stats that are in nested obj to top level obj\n stats.std_deviation_bounds_upper = stats.std_deviation_bounds.upper;\n stats.std_deviation_bounds_lower = stats.std_deviation_bounds.lower;\n\n addMetricValue(values, this.getMetricName(statName as ExtendedStatMetaType), stats[statName]);\n }\n break;\n }\n case 'percentiles': {\n const percentiles = bucket[metric.id].values;\n\n for (const percentileName in percentiles) {\n addMetricValue(values, `p${percentileName} ${metric.field}`, percentiles[percentileName]);\n }\n break;\n }\n case 'top_metrics': {\n const baseName = this.getMetricName(metric.type);\n\n if (metric.settings?.metrics) {\n for (const metricField of metric.settings.metrics) {\n // If we selected more than one metric we also add each metric name\n const metricName = metric.settings.metrics.length > 1 ? `${baseName} ${metricField}` : baseName;\n\n const stats = bucket[metric.id] as TopMetricBucket;\n\n // Size of top_metrics is fixed to 1.\n addMetricValue(values, metricName, stats.top[0].metrics[metricField]);\n }\n }\n\n break;\n }\n default: {\n let metricName = this.getMetricName(metric.type);\n const otherMetrics = filter(target.metrics, { type: metric.type });\n\n // if more of the same metric type include field field name in property\n if (otherMetrics.length > 1) {\n if (isMetricAggregationWithField(metric)) {\n metricName += ' ' + metric.field;\n }\n\n if (metric.type === 'bucket_script') {\n //Use the formula in the column name\n metricName = getScriptValue(metric);\n }\n }\n\n addMetricValue(values, metricName, bucket[metric.id].value);\n break;\n }\n }\n }\n\n table.rows.push(values);\n }\n }\n\n // This is quite complex\n // need to recurse down the nested buckets to build series\n processBuckets(aggs: any, target: ElasticsearchQuery, seriesList: any, table: TableModel, props: any, depth: number) {\n let bucket, aggDef: any, esAgg, aggId;\n const maxDepth = target.bucketAggs!.length - 1;\n\n for (aggId in aggs) {\n aggDef = find(target.bucketAggs, { id: aggId });\n esAgg = aggs[aggId];\n\n if (!aggDef) {\n continue;\n }\n\n if (depth === maxDepth) {\n if (aggDef.type === 'date_histogram') {\n this.processMetrics(esAgg, target, seriesList, props);\n } else {\n this.processAggregationDocs(esAgg, aggDef, target, table, props);\n }\n } else {\n for (const nameIndex in esAgg.buckets) {\n bucket = esAgg.buckets[nameIndex];\n props = clone(props);\n if (bucket.key !== void 0) {\n props[aggDef.field] = bucket.key;\n } else {\n props['filter'] = nameIndex;\n }\n if (bucket.key_as_string) {\n props[aggDef.field] = bucket.key_as_string;\n }\n this.processBuckets(bucket, target, seriesList, table, props, depth + 1);\n }\n }\n }\n }\n\n private getMetricName(metric: string): string {\n const metricDef = Object.entries(metricAggregationConfig)\n .filter(([key]) => key === metric)\n .map(([_, value]) => value)[0];\n\n if (metricDef) {\n return metricDef.label;\n }\n\n const extendedStat = queryDef.extendedStats.find((e) => e.value === metric);\n if (extendedStat) {\n return extendedStat.label;\n }\n\n return metric;\n }\n\n private getSeriesName(series: any, target: ElasticsearchQuery, dedup: boolean) {\n let metricName = this.getMetricName(series.metric);\n\n if (target.alias) {\n const regex = /\\{\\{([\\s\\S]+?)\\}\\}/g;\n\n return target.alias.replace(regex, (match: any, g1: any, g2: any) => {\n const group = g1 || g2;\n\n if (group.indexOf('term ') === 0) {\n return series.props[group.substring(5)];\n }\n if (series.props[group] !== void 0) {\n return series.props[group];\n }\n if (group === 'metric') {\n return metricName;\n }\n if (group === 'field') {\n return series.field || '';\n }\n\n return match;\n });\n }\n\n if (queryDef.isPipelineAgg(series.metric)) {\n if (series.metric && queryDef.isPipelineAggWithMultipleBucketPaths(series.metric)) {\n const agg: any = find(target.metrics, { id: series.metricId });\n if (agg && agg.settings.script) {\n metricName = getScriptValue(agg);\n\n for (const pv of agg.pipelineVariables) {\n const appliedAgg: any = find(target.metrics, { id: pv.pipelineAgg });\n if (appliedAgg) {\n metricName = metricName.replace('params.' + pv.name, describeMetric(appliedAgg));\n }\n }\n } else {\n metricName = 'Unset';\n }\n } else {\n const appliedAgg: any = find(target.metrics, { id: series.field });\n if (appliedAgg) {\n metricName += ' ' + describeMetric(appliedAgg);\n } else {\n metricName = 'Unset';\n }\n }\n } else if (series.field) {\n metricName += ' ' + series.field;\n }\n\n const propKeys = keys(series.props);\n if (propKeys.length === 0) {\n return metricName;\n }\n\n let name = '';\n for (const propName in series.props) {\n name += series.props[propName] + ' ';\n }\n\n if (dedup) {\n return name.trim() + ' ' + metricName;\n }\n\n return name.trim();\n }\n\n nameSeries(seriesList: any, target: ElasticsearchQuery) {\n const metricTypeCount = uniq(map(seriesList, 'metric')).length;\n const hasTopMetricWithMultipleMetrics = (\n target.metrics?.filter((m) => m.type === 'top_metrics') as TopMetrics[]\n ).some((m) => (m?.settings?.metrics?.length || 0) > 1);\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n series.target = this.getSeriesName(series, target, metricTypeCount > 1 || hasTopMetricWithMultipleMetrics);\n }\n }\n\n processHits(hits: { total: { value: any }; hits: any[] }, seriesList: any[], target: ElasticsearchQuery) {\n const hitsTotal = typeof hits.total === 'number' ? hits.total : hits.total.value; // <- Works with Elasticsearch 7.0+\n\n const series: any = {\n target: target.refId,\n type: 'docs',\n refId: target.refId,\n datapoints: [],\n total: hitsTotal,\n filterable: true,\n };\n let propName, hit, doc: any, i;\n\n for (i = 0; i < hits.hits.length; i++) {\n hit = hits.hits[i];\n doc = {\n _id: hit._id,\n _type: hit._type,\n _index: hit._index,\n sort: hit.sort,\n highlight: hit.highlight,\n };\n\n if (hit._source) {\n for (propName in hit._source) {\n doc[propName] = hit._source[propName];\n }\n }\n\n for (propName in hit.fields) {\n doc[propName] = hit.fields[propName];\n }\n series.datapoints.push(doc);\n }\n\n seriesList.push(series);\n }\n\n trimDatapoints(aggregations: any, target: ElasticsearchQuery) {\n const histogram: any = find(target.bucketAggs, { type: 'date_histogram' });\n\n const shouldDropFirstAndLast = histogram && histogram.settings && histogram.settings.trimEdges;\n if (shouldDropFirstAndLast) {\n const trim = histogram.settings.trimEdges;\n for (const prop in aggregations) {\n const points = aggregations[prop];\n if (points.datapoints.length > trim * 2) {\n points.datapoints = points.datapoints.slice(trim, points.datapoints.length - trim);\n }\n }\n }\n }\n\n getErrorFromElasticResponse(response: any, err: any) {\n const result: any = {};\n result.data = JSON.stringify(err, null, 4);\n if (err.root_cause && err.root_cause.length > 0 && err.root_cause[0].reason) {\n result.message = err.root_cause[0].reason;\n } else {\n result.message = err.reason || 'Unknown elastic error response';\n }\n\n if (response.$$config) {\n result.config = response.$$config;\n }\n\n return result;\n }\n\n getTimeSeries() {\n if (this.targets.some((target) => queryDef.hasMetricOfType(target, 'raw_data'))) {\n return this.processResponseToDataFrames(false);\n }\n return this.processResponseToSeries();\n }\n\n getLogs(logMessageField?: string, logLevelField?: string): DataQueryResponse {\n return this.processResponseToDataFrames(true, logMessageField, logLevelField);\n }\n\n private processResponseToDataFrames(\n isLogsRequest: boolean,\n logMessageField?: string,\n logLevelField?: string\n ): DataQueryResponse {\n const dataFrame: DataFrame[] = [];\n for (let n = 0; n < this.response.responses.length; n++) {\n const response = this.response.responses[n];\n if (response.error) {\n throw this.getErrorFromElasticResponse(this.response, response.error);\n }\n\n if (response.hits) {\n const { propNames, docs } = flattenHits(response.hits.hits);\n\n const series = docs.length\n ? createEmptyDataFrame(\n propNames.map(toNameTypePair(docs)),\n isLogsRequest,\n this.targets[0].timeField,\n logMessageField,\n logLevelField\n )\n : createEmptyDataFrame([], isLogsRequest);\n\n if (isLogsRequest) {\n addPreferredVisualisationType(series, 'logs');\n }\n\n // Add a row for each document\n for (const doc of docs) {\n if (logLevelField) {\n // Remap level field based on the datasource config. This field is\n // then used in explore to figure out the log level. We may rewrite\n // some actual data in the level field if they are different.\n doc['level'] = doc[logLevelField];\n }\n // When highlighting exists, we need to collect all the highlighted\n // phrases and add them to the DataFrame's meta.searchWords array.\n if (doc.highlight) {\n // There might be multiple words so we need two versions of the\n // regular expression. One to match gobally, when used with part.match,\n // it returns and array of matches. The second one is used to capture the\n // values between the tags.\n const globalHighlightWordRegex = new RegExp(HIGHLIGHT_TAGS_EXP, 'g');\n const highlightWordRegex = new RegExp(HIGHLIGHT_TAGS_EXP);\n const newSearchWords = Object.keys(doc.highlight)\n .flatMap((key) => {\n return doc.highlight[key].flatMap((line: string) => {\n const matchedPhrases = line.match(globalHighlightWordRegex);\n if (!matchedPhrases) {\n return [];\n }\n return matchedPhrases.map((part) => {\n const matches = part.match(highlightWordRegex);\n return (matches && matches[1]) || null;\n });\n });\n })\n .filter(identity);\n // If meta and searchWords already exists, add the words and\n // deduplicate otherwise create a new set of search words.\n const searchWords = series.meta?.searchWords\n ? uniq([...series.meta.searchWords, ...newSearchWords])\n : [...newSearchWords];\n series.meta = series.meta ? { ...series.meta, searchWords } : { searchWords };\n }\n series.add(doc);\n }\n\n const target = this.targets[n];\n series.refId = target.refId;\n dataFrame.push(series);\n }\n\n if (response.aggregations) {\n const aggregations = response.aggregations;\n const target = this.targets[n];\n const tmpSeriesList: any[] = [];\n const table = new TableModel();\n\n this.processBuckets(aggregations, target, tmpSeriesList, table, {}, 0);\n this.trimDatapoints(tmpSeriesList, target);\n this.nameSeries(tmpSeriesList, target);\n\n if (table.rows.length > 0) {\n const series = toDataFrame(table);\n series.refId = target.refId;\n dataFrame.push(series);\n }\n\n for (let y = 0; y < tmpSeriesList.length; y++) {\n let series = toDataFrame(tmpSeriesList[y]);\n\n // When log results, show aggregations only in graph. Log fields are then going to be shown in table.\n if (isLogsRequest) {\n addPreferredVisualisationType(series, 'graph');\n }\n\n series.refId = target.refId;\n dataFrame.push(series);\n }\n }\n }\n\n return { data: dataFrame };\n }\n\n processResponseToSeries = () => {\n const seriesList = [];\n\n for (let i = 0; i < this.response.responses.length; i++) {\n const response = this.response.responses[i];\n const target = this.targets[i];\n\n if (response.error) {\n throw this.getErrorFromElasticResponse(this.response, response.error);\n }\n\n if (response.hits && response.hits.hits.length > 0) {\n this.processHits(response.hits, seriesList, target);\n }\n\n if (response.aggregations) {\n const aggregations = response.aggregations;\n const target = this.targets[i];\n const tmpSeriesList: any[] = [];\n const table = new TableModel();\n table.refId = target.refId;\n\n this.processBuckets(aggregations, target, tmpSeriesList, table, {}, 0);\n this.trimDatapoints(tmpSeriesList, target);\n this.nameSeries(tmpSeriesList, target);\n\n for (let y = 0; y < tmpSeriesList.length; y++) {\n seriesList.push(tmpSeriesList[y]);\n }\n\n if (table.rows.length > 0) {\n seriesList.push(table);\n }\n }\n }\n\n return { data: seriesList };\n };\n}\n\ntype Doc = {\n _id: string;\n _type: string;\n _index: string;\n _source?: any;\n sort?: Array<string | number>;\n highlight?: Record<string, string[]>;\n};\n\n/**\n * Flatten the docs from response mainly the _source part which can be nested. This flattens it so that it is one level\n * deep and the keys are: `level1Name.level2Name...`. Also returns list of all properties from all the docs (not all\n * docs have to have the same keys).\n * @param hits\n */\nconst flattenHits = (hits: Doc[]): { docs: Array<Record<string, any>>; propNames: string[] } => {\n const docs: any[] = [];\n // We keep a list of all props so that we can create all the fields in the dataFrame, this can lead\n // to wide sparse dataframes in case the scheme is different per document.\n let propNames: string[] = [];\n\n for (const hit of hits) {\n const flattened = hit._source ? flatten(hit._source) : {};\n const doc = {\n _id: hit._id,\n _type: hit._type,\n _index: hit._index,\n sort: hit.sort,\n highlight: hit.highlight,\n _source: { ...flattened },\n ...flattened,\n };\n\n for (const propName of Object.keys(doc)) {\n if (propNames.indexOf(propName) === -1) {\n propNames.push(propName);\n }\n }\n\n docs.push(doc);\n }\n\n propNames.sort();\n return { docs, propNames };\n};\n\n/**\n * Create empty dataframe but with created fields. Fields are based from propNames (should be from the response) and\n * also from configuration specified fields for message, time, and level.\n * @param propNames\n * @param timeField\n * @param logMessageField\n * @param logLevelField\n */\nconst createEmptyDataFrame = (\n props: Array<[string, FieldType]>,\n isLogsRequest: boolean,\n timeField?: string,\n logMessageField?: string,\n logLevelField?: string\n): MutableDataFrame => {\n const series = new MutableDataFrame({ fields: [] });\n\n if (timeField) {\n series.addField({\n config: {\n filterable: true,\n },\n name: timeField,\n type: FieldType.time,\n });\n }\n\n if (logMessageField) {\n const f = series.addField({\n name: logMessageField,\n type: FieldType.string,\n });\n series.setParser(f, (v: any) => {\n return v || '';\n });\n }\n\n if (logLevelField) {\n const f = series.addField({\n name: 'level',\n type: FieldType.string,\n });\n series.setParser(f, (v: any) => {\n return v || '';\n });\n }\n\n const fieldNames = series.fields.map((field) => field.name);\n\n for (const [name, type] of props) {\n // Do not duplicate fields. This can mean that we will shadow some fields.\n if (fieldNames.includes(name)) {\n continue;\n }\n // Do not add _source field (besides logs) as we are showing each _source field in table instead.\n if (!isLogsRequest && name === '_source') {\n continue;\n }\n\n const f = series.addField({\n config: {\n filterable: true,\n },\n name,\n type,\n });\n series.setParser(f, (v: any) => {\n return v || '';\n });\n }\n\n return series;\n};\n\nconst addPreferredVisualisationType = (series: any, type: PreferredVisualisationType) => {\n let s = series;\n s.meta\n ? (s.meta.preferredVisualisationType = type)\n : (s.meta = {\n preferredVisualisationType: type,\n });\n};\n\nconst toNameTypePair =\n (docs: Array<Record<string, any>>) =>\n (propName: string): [string, FieldType] =>\n [propName, guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName])];\n\n/**\n * Trying to guess data type from its value. This is far from perfect, as in order to have accurate guess\n * we should have access to the elasticsearch mapping, but it covers the most common use cases for numbers, strings & arrays.\n */\nconst guessType = (value: unknown): FieldType => {\n switch (typeof value) {\n case 'number':\n return FieldType.number;\n case 'string':\n return FieldType.string;\n default:\n return FieldType.other;\n }\n};\n","import { toUtc, dateTime, DateTime, DurationUnit } from '@grafana/data';\n\nimport { Interval } from './types';\n\ntype IntervalMap = Record<\n Interval,\n {\n startOf: DurationUnit;\n amount: DurationUnit;\n }\n>;\n\nconst intervalMap: IntervalMap = {\n Hourly: { startOf: 'hour', amount: 'hours' },\n Daily: { startOf: 'day', amount: 'days' },\n Weekly: { startOf: 'isoWeek', amount: 'weeks' },\n Monthly: { startOf: 'month', amount: 'months' },\n Yearly: { startOf: 'year', amount: 'years' },\n};\n\nexport class IndexPattern {\n private dateLocale = 'en';\n\n constructor(private pattern: string, private interval?: keyof typeof intervalMap) {}\n\n getIndexForToday() {\n if (this.interval) {\n return toUtc().locale(this.dateLocale).format(this.pattern);\n } else {\n return this.pattern;\n }\n }\n\n getIndexList(from?: DateTime, to?: DateTime) {\n // When no `from` or `to` is provided, we request data from 7 subsequent/previous indices\n // for the provided index pattern.\n // This is useful when requesting log context where the only time data we have is the log\n // timestamp.\n const indexOffset = 7;\n if (!this.interval) {\n return this.pattern;\n }\n\n const intervalInfo = intervalMap[this.interval];\n const start = dateTime(from || dateTime(to).add(-indexOffset, intervalInfo.amount))\n .utc()\n .startOf(intervalInfo.startOf);\n const endEpoch = dateTime(to || dateTime(from).add(indexOffset, intervalInfo.amount))\n .utc()\n .startOf(intervalInfo.startOf)\n .valueOf();\n const indexList = [];\n\n while (start.valueOf() <= endEpoch) {\n indexList.push(start.locale(this.dateLocale).format(this.pattern));\n start.add(1, intervalInfo.amount);\n }\n\n return indexList;\n }\n}\n","import { AbstractLabelOperator, AbstractLabelMatcher, LanguageProvider, AbstractQuery } from '@grafana/data';\n\nimport { ElasticDatasource } from './datasource';\nimport { ElasticsearchQuery } from './types';\n\nexport default class ElasticsearchLanguageProvider extends LanguageProvider {\n declare request: (url: string, params?: any) => Promise<any>;\n declare start: () => Promise<any[]>;\n datasource: ElasticDatasource;\n\n constructor(datasource: ElasticDatasource, initialValues?: any) {\n super();\n this.datasource = datasource;\n\n Object.assign(this, initialValues);\n }\n\n /**\n * Queries are transformed to an ES Logs query since it's the behaviour most users expect.\n **/\n importFromAbstractQuery(abstractQuery: AbstractQuery): ElasticsearchQuery {\n return {\n metrics: [\n {\n id: '1',\n type: 'logs',\n },\n ],\n query: this.getElasticsearchQuery(abstractQuery.labelMatchers),\n refId: abstractQuery.refId,\n };\n }\n\n getElasticsearchQuery(labels: AbstractLabelMatcher[]): string {\n return labels\n .map((label) => {\n switch (label.operator) {\n case AbstractLabelOperator.Equal: {\n return label.name + ':\"' + label.value + '\"';\n }\n case AbstractLabelOperator.NotEqual: {\n return 'NOT ' + label.name + ':\"' + label.value + '\"';\n }\n case AbstractLabelOperator.EqualRegEx: {\n return label.name + ':/' + label.value + '/';\n }\n case AbstractLabelOperator.NotEqualRegEx: {\n return 'NOT ' + label.name + ':/' + label.value + '/';\n }\n }\n })\n .join(' AND ');\n }\n}\n","import { gte, lt } from 'semver';\n\nimport { InternalTimeZones } from '@grafana/data';\n\nimport {\n Filters,\n Histogram,\n DateHistogram,\n Terms,\n} from './components/QueryEditor/BucketAggregationsEditor/aggregations';\nimport {\n isMetricAggregationWithField,\n isMetricAggregationWithSettings,\n isMovingAverageWithModelSettings,\n isPipelineAggregation,\n isPipelineAggregationWithMultipleBucketPaths,\n MetricAggregation,\n MetricAggregationWithInlineScript,\n} from './components/QueryEditor/MetricAggregationsEditor/aggregations';\nimport { defaultBucketAgg, defaultMetricAgg, findMetricById, highlightTags } from './query_def';\nimport { ElasticsearchQuery, TermsQuery } from './types';\nimport { convertOrderByToMetricId, getScriptValue } from './utils';\n\nexport class ElasticQueryBuilder {\n timeField: string;\n esVersion: string;\n\n constructor(options: { timeField: string; esVersion: string }) {\n this.timeField = options.timeField;\n this.esVersion = options.esVersion;\n }\n\n getRangeFilter() {\n const filter: any = {};\n filter[this.timeField] = {\n gte: '$timeFrom',\n lte: '$timeTo',\n format: 'epoch_millis',\n };\n\n return filter;\n }\n\n buildTermsAgg(aggDef: Terms, queryNode: { terms?: any; aggs?: any }, target: ElasticsearchQuery) {\n queryNode.terms = { field: aggDef.field };\n\n if (!aggDef.settings) {\n return queryNode;\n }\n\n // TODO: This default should be somewhere else together with the one used in the UI\n const size = aggDef.settings?.size ? parseInt(aggDef.settings.size, 10) : 500;\n queryNode.terms.size = size === 0 ? 500 : size;\n\n if (aggDef.settings.orderBy !== void 0) {\n queryNode.terms.order = {};\n if (aggDef.settings.orderBy === '_term' && gte(this.esVersion, '6.0.0')) {\n queryNode.terms.order['_key'] = aggDef.settings.order;\n } else {\n queryNode.terms.order[aggDef.settings.orderBy] = aggDef.settings.order;\n }\n\n // if metric ref, look it up and add it to this agg level\n const metricId = convertOrderByToMetricId(aggDef.settings.orderBy);\n if (metricId) {\n for (let metric of target.metrics || []) {\n if (metric.id === metricId) {\n if (metric.type === 'count') {\n queryNode.terms.order = { _count: aggDef.settings.order };\n } else if (isMetricAggregationWithField(metric)) {\n queryNode.aggs = {};\n queryNode.aggs[metric.id] = {\n [metric.type]: { field: metric.field },\n };\n }\n break;\n }\n }\n }\n }\n\n if (aggDef.settings.min_doc_count !== void 0) {\n queryNode.terms.min_doc_count = parseInt(aggDef.settings.min_doc_count, 10);\n\n if (isNaN(queryNode.terms.min_doc_count)) {\n queryNode.terms.min_doc_count = aggDef.settings.min_doc_count;\n }\n }\n\n if (aggDef.settings.missing) {\n queryNode.terms.missing = aggDef.settings.missing;\n }\n\n return queryNode;\n }\n\n getDateHistogramAgg(aggDef: DateHistogram) {\n const esAgg: any = {};\n const settings = aggDef.settings || {};\n\n esAgg.field = aggDef.field || this.timeField;\n esAgg.min_doc_count = settings.min_doc_count || 0;\n esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' };\n esAgg.format = 'epoch_millis';\n if (settings.timeZone && settings.timeZone !== InternalTimeZones.utc) {\n esAgg.time_zone = settings.timeZone;\n }\n\n if (settings.offset !== '') {\n esAgg.offset = settings.offset;\n }\n\n const interval = settings.interval === 'auto' ? '$__interval' : settings.interval;\n\n if (gte(this.esVersion, '8.0.0')) {\n // The deprecation was actually introduced in 7.0.0, we might want to use that instead of the removal date,\n // but it woudl be a breaking change on our side.\n esAgg.fixed_interval = interval;\n } else {\n esAgg.interval = interval;\n }\n\n return esAgg;\n }\n\n getHistogramAgg(aggDef: Histogram) {\n const esAgg: any = {};\n const settings = aggDef.settings || {};\n esAgg.interval = settings.interval;\n esAgg.field = aggDef.field;\n esAgg.min_doc_count = settings.min_doc_count || 0;\n\n return esAgg;\n }\n\n getFiltersAgg(aggDef: Filters) {\n const filterObj: Record<string, { query_string: { query: string; analyze_wildcard: boolean } }> = {};\n\n for (let { query, label } of aggDef.settings?.filters || []) {\n filterObj[label || query] = {\n query_string: {\n query: query,\n analyze_wildcard: true,\n },\n };\n }\n\n return filterObj;\n }\n\n documentQuery(query: any, size: number) {\n query.size = size;\n query.sort = [\n {\n [this.timeField]: { order: 'desc', unmapped_type: 'boolean' },\n },\n {\n _doc: { order: 'desc' },\n },\n ];\n\n // fields field not supported on ES 5.x\n if (lt(this.esVersion, '5.0.0')) {\n query.fields = ['*', '_source'];\n }\n\n query.script_fields = {};\n return query;\n }\n\n addAdhocFilters(query: any, adhocFilters: any) {\n if (!adhocFilters) {\n return;\n }\n\n let i, filter, condition: any, queryCondition: any;\n\n for (i = 0; i < adhocFilters.length; i++) {\n filter = adhocFilters[i];\n condition = {};\n condition[filter.key] = filter.value;\n queryCondition = {};\n queryCondition[filter.key] = { query: filter.value };\n\n switch (filter.operator) {\n case '=':\n if (!query.query.bool.must) {\n query.query.bool.must = [];\n }\n query.query.bool.must.push({ match_phrase: queryCondition });\n break;\n case '!=':\n if (!query.query.bool.must_not) {\n query.query.bool.must_not = [];\n }\n query.query.bool.must_not.push({ match_phrase: queryCondition });\n break;\n case '<':\n condition[filter.key] = { lt: filter.value };\n query.query.bool.filter.push({ range: condition });\n break;\n case '>':\n condition[filter.key] = { gt: filter.value };\n query.query.bool.filter.push({ range: condition });\n break;\n case '=~':\n query.query.bool.filter.push({ regexp: condition });\n break;\n case '!~':\n query.query.bool.filter.push({\n bool: { must_not: { regexp: condition } },\n });\n break;\n }\n }\n }\n\n build(target: ElasticsearchQuery, adhocFilters?: any) {\n // make sure query has defaults;\n target.metrics = target.metrics || [defaultMetricAgg()];\n target.bucketAggs = target.bucketAggs || [defaultBucketAgg()];\n target.timeField = this.timeField;\n let metric: MetricAggregation;\n\n let i, j, pv, nestedAggs;\n const query: any = {\n size: 0,\n query: {\n bool: {\n filter: [{ range: this.getRangeFilter() }],\n },\n },\n };\n\n if (target.query && target.query !== '') {\n query.query.bool.filter = [\n ...query.query.bool.filter,\n {\n query_string: {\n analyze_wildcard: true,\n query: target.query,\n },\n },\n ];\n }\n\n this.addAdhocFilters(query, adhocFilters);\n\n // If target doesn't have bucketAggs and type is not raw_document, it is invalid query.\n if (target.bucketAggs.length === 0) {\n metric = target.metrics[0];\n\n if (!metric || !(metric.type === 'raw_document' || metric.type === 'raw_data')) {\n throw { message: 'Invalid query' };\n }\n }\n\n /* Handle document query:\n * Check if metric type is raw_document. If metric doesn't have size (or size is 0), update size to 500.\n * Otherwise it will not be a valid query and error will be thrown.\n */\n if (target.metrics?.[0]?.type === 'raw_document' || target.metrics?.[0]?.type === 'raw_data') {\n metric = target.metrics[0];\n\n // TODO: This default should be somewhere else together with the one used in the UI\n const size = metric.settings?.size ? parseInt(metric.settings.size, 10) : 500;\n\n return this.documentQuery(query, size || 500);\n }\n\n nestedAggs = query;\n\n for (i = 0; i < target.bucketAggs.length; i++) {\n const aggDef = target.bucketAggs[i];\n const esAgg: any = {};\n\n switch (aggDef.type) {\n case 'date_histogram': {\n esAgg['date_histogram'] = this.getDateHistogramAgg(aggDef);\n break;\n }\n case 'histogram': {\n esAgg['histogram'] = this.getHistogramAgg(aggDef);\n break;\n }\n case 'filters': {\n esAgg['filters'] = { filters: this.getFiltersAgg(aggDef) };\n break;\n }\n case 'terms': {\n this.buildTermsAgg(aggDef, esAgg, target);\n break;\n }\n case 'geohash_grid': {\n esAgg['geohash_grid'] = {\n field: aggDef.field,\n precision: aggDef.settings?.precision,\n };\n break;\n }\n }\n\n nestedAggs.aggs = nestedAggs.aggs || {};\n nestedAggs.aggs[aggDef.id] = esAgg;\n nestedAggs = esAgg;\n }\n\n nestedAggs.aggs = {};\n\n for (i = 0; i < target.metrics.length; i++) {\n metric = target.metrics[i];\n if (metric.type === 'count') {\n continue;\n }\n\n const aggField: any = {};\n let metricAgg: any = {};\n\n if (isPipelineAggregation(metric)) {\n if (isPipelineAggregationWithMultipleBucketPaths(metric)) {\n if (metric.pipelineVariables) {\n metricAgg = {\n buckets_path: {},\n };\n\n for (j = 0; j < metric.pipelineVariables.length; j++) {\n pv = metric.pipelineVariables[j];\n\n if (pv.name && pv.pipelineAgg && /^\\d*$/.test(pv.pipelineAgg)) {\n const appliedAgg = findMetricById(target.metrics, pv.pipelineAgg);\n if (appliedAgg) {\n if (appliedAgg.type === 'count') {\n metricAgg.buckets_path[pv.name] = '_count';\n } else {\n metricAgg.buckets_path[pv.name] = pv.pipelineAgg;\n }\n }\n }\n }\n } else {\n continue;\n }\n } else {\n if (metric.field && /^\\d*$/.test(metric.field)) {\n const appliedAgg = findMetricById(target.metrics, metric.field);\n if (appliedAgg) {\n if (appliedAgg.type === 'count') {\n metricAgg = { buckets_path: '_count' };\n } else {\n metricAgg = { buckets_path: metric.field };\n }\n }\n } else {\n continue;\n }\n }\n } else if (isMetricAggregationWithField(metric)) {\n metricAgg = { field: metric.field };\n }\n\n if (isMetricAggregationWithSettings(metric)) {\n Object.entries(metric.settings || {})\n .filter(([_, v]) => v !== null)\n .forEach(([k, v]) => {\n metricAgg[k] =\n k === 'script' ? this.buildScript(getScriptValue(metric as MetricAggregationWithInlineScript)) : v;\n });\n\n // Elasticsearch isn't generally too picky about the data types in the request body,\n // however some fields are required to be numeric.\n // Users might have already created some of those with before, where the values were numbers.\n switch (metric.type) {\n case 'moving_avg':\n metricAgg = {\n ...metricAgg,\n ...(metricAgg?.window !== undefined && { window: this.toNumber(metricAgg.window) }),\n ...(metricAgg?.predict !== undefined && { predict: this.toNumber(metricAgg.predict) }),\n ...(isMovingAverageWithModelSettings(metric) && {\n settings: {\n ...metricAgg.settings,\n ...Object.fromEntries(\n Object.entries(metricAgg.settings || {})\n // Only format properties that are required to be numbers\n .filter(([settingName]) => ['alpha', 'beta', 'gamma', 'period'].includes(settingName))\n // omitting undefined\n .filter(([_, stringValue]) => stringValue !== undefined)\n .map(([_, stringValue]) => [_, this.toNumber(stringValue)])\n ),\n },\n }),\n };\n break;\n\n case 'serial_diff':\n metricAgg = {\n ...metricAgg,\n ...(metricAgg.lag !== undefined && {\n lag: this.toNumber(metricAgg.lag),\n }),\n };\n break;\n\n case 'top_metrics':\n metricAgg = {\n metrics: metric.settings?.metrics?.map((field) => ({ field })),\n size: 1,\n };\n\n if (metric.settings?.orderBy) {\n metricAgg.sort = [{ [metric.settings?.orderBy]: metric.settings?.order }];\n }\n break;\n }\n }\n\n aggField[metric.type] = metricAgg;\n nestedAggs.aggs[metric.id] = aggField;\n }\n\n return query;\n }\n\n private buildScript(script: string) {\n if (gte(this.esVersion, '5.6.0')) {\n return script;\n }\n\n return {\n inline: script,\n };\n }\n\n private toNumber(stringValue: unknown): unknown | number {\n const parsedValue = parseFloat(`${stringValue}`);\n if (isNaN(parsedValue)) {\n return stringValue;\n }\n\n return parsedValue;\n }\n\n getTermsQuery(queryDef: TermsQuery) {\n const query: any = {\n size: 0,\n query: {\n bool: {\n filter: [{ range: this.getRangeFilter() }],\n },\n },\n };\n\n if (queryDef.query) {\n query.query.bool.filter.push({\n query_string: {\n analyze_wildcard: true,\n query: queryDef.query,\n },\n });\n }\n\n let size = 500;\n if (queryDef.size) {\n size = queryDef.size;\n }\n\n query.aggs = {\n '1': {\n terms: {\n field: queryDef.field,\n size: size,\n order: {},\n },\n },\n };\n\n // Default behaviour is to order results by { _key: asc }\n // queryDef.order allows selection of asc/desc\n // queryDef.orderBy allows selection of doc_count ordering (defaults desc)\n\n const { orderBy = 'key', order = orderBy === 'doc_count' ? 'desc' : 'asc' } = queryDef;\n\n if (['asc', 'desc'].indexOf(order) < 0) {\n throw { message: `Invalid query sort order ${order}` };\n }\n\n switch (orderBy) {\n case 'key':\n case 'term':\n const keyname = gte(this.esVersion, '6.0.0') ? '_key' : '_term';\n query.aggs['1'].terms.order[keyname] = order;\n break;\n case 'doc_count':\n query.aggs['1'].terms.order['_count'] = order;\n break;\n default:\n throw { message: `Invalid query sort type ${orderBy}` };\n }\n\n return query;\n }\n\n getLogsQuery(target: ElasticsearchQuery, limit: number, adhocFilters?: any) {\n let query: any = {\n size: 0,\n query: {\n bool: {\n filter: [{ range: this.getRangeFilter() }],\n },\n },\n };\n\n this.addAdhocFilters(query, adhocFilters);\n\n if (target.query) {\n query.query.bool.filter.push({\n query_string: {\n analyze_wildcard: true,\n query: target.query,\n },\n });\n }\n\n query = this.documentQuery(query, limit);\n\n return {\n ...query,\n aggs: this.build(target, null).aggs,\n highlight: {\n fields: {\n '*': {},\n },\n pre_tags: [highlightTags.pre],\n post_tags: [highlightTags.post],\n fragment_size: 2147483647,\n },\n };\n }\n}\n","import { cloneDeep, find, first as _first, isNumber, isObject, isString, map as _map } from 'lodash';\nimport { generate, lastValueFrom, Observable, of, throwError } from 'rxjs';\nimport { catchError, first, map, mergeMap, skipWhile, throwIfEmpty } from 'rxjs/operators';\nimport { gte, lt, satisfies } from 'semver';\n\nimport {\n DataFrame,\n DataLink,\n DataQueryRequest,\n DataQueryResponse,\n DataSourceApi,\n DataSourceInstanceSettings,\n DataSourceWithLogsContextSupport,\n DataSourceWithQueryImportSupport,\n DataSourceWithLogsVolumeSupport,\n DateTime,\n dateTime,\n Field,\n getDefaultTimeRange,\n AbstractQuery,\n getLogLevelFromKey,\n LogLevel,\n LogRowModel,\n MetricFindValue,\n ScopedVars,\n TimeRange,\n toUtc,\n} from '@grafana/data';\nimport { BackendSrvRequest, getBackendSrv, getDataSourceSrv } from '@grafana/runtime';\nimport { RowContextOptions } from '@grafana/ui/src/components/Logs/LogRowContextProvider';\nimport { queryLogsVolume } from 'app/core/logs_model';\nimport { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';\n\nimport {\n BucketAggregation,\n isBucketAggregationWithField,\n} from './components/QueryEditor/BucketAggregationsEditor/aggregations';\nimport { bucketAggregationConfig } from './components/QueryEditor/BucketAggregationsEditor/utils';\nimport {\n isMetricAggregationWithField,\n isPipelineAggregationWithMultipleBucketPaths,\n Logs,\n} from './components/QueryEditor/MetricAggregationsEditor/aggregations';\nimport { metricAggregationConfig } from './components/QueryEditor/MetricAggregationsEditor/utils';\nimport { ElasticResponse } from './elastic_response';\nimport { IndexPattern } from './index_pattern';\nimport LanguageProvider from './language_provider';\nimport { ElasticQueryBuilder } from './query_builder';\nimport { defaultBucketAgg, hasMetricOfType } from './query_def';\nimport { DataLinkConfig, ElasticsearchOptions, ElasticsearchQuery, TermsQuery } from './types';\nimport { coerceESVersion, getScriptValue, isSupportedVersion } from './utils';\n\n// Those are metadata fields as defined in https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-fields.html#_identity_metadata_fields.\n// custom fields can start with underscores, therefore is not safe to exclude anything that starts with one.\nconst ELASTIC_META_FIELDS = [\n '_index',\n '_type',\n '_id',\n '_source',\n '_size',\n '_field_names',\n '_ignored',\n '_routing',\n '_meta',\n];\n\nexport class ElasticDatasource\n extends DataSourceApi<ElasticsearchQuery, ElasticsearchOptions>\n implements\n DataSourceWithLogsContextSupport,\n DataSourceWithQueryImportSupport<ElasticsearchQuery>,\n DataSourceWithLogsVolumeSupport<ElasticsearchQuery>\n{\n basicAuth?: string;\n withCredentials?: boolean;\n url: string;\n name: string;\n index: string;\n timeField: string;\n esVersion: string;\n xpack: boolean;\n interval: string;\n maxConcurrentShardRequests?: number;\n queryBuilder: ElasticQueryBuilder;\n indexPattern: IndexPattern;\n logMessageField?: string;\n logLevelField?: string;\n dataLinks: DataLinkConfig[];\n languageProvider: LanguageProvider;\n includeFrozen: boolean;\n isProxyAccess: boolean;\n\n constructor(\n instanceSettings: DataSourceInstanceSettings<ElasticsearchOptions>,\n private readonly templateSrv: TemplateSrv = getTemplateSrv()\n ) {\n super(instanceSettings);\n this.basicAuth = instanceSettings.basicAuth;\n this.withCredentials = instanceSettings.withCredentials;\n this.url = instanceSettings.url!;\n this.name = instanceSettings.name;\n this.index = instanceSettings.database ?? '';\n this.isProxyAccess = instanceSettings.access === 'proxy';\n const settingsData = instanceSettings.jsonData || ({} as ElasticsearchOptions);\n\n this.timeField = settingsData.timeField;\n this.esVersion = coerceESVersion(settingsData.esVersion);\n this.xpack = Boolean(settingsData.xpack);\n this.indexPattern = new IndexPattern(this.index, settingsData.interval);\n this.interval = settingsData.timeInterval;\n this.maxConcurrentShardRequests = settingsData.maxConcurrentShardRequests;\n this.queryBuilder = new ElasticQueryBuilder({\n timeField: this.timeField,\n esVersion: this.esVersion,\n });\n this.logMessageField = settingsData.logMessageField || '';\n this.logLevelField = settingsData.logLevelField || '';\n this.dataLinks = settingsData.dataLinks || [];\n this.includeFrozen = settingsData.includeFrozen ?? false;\n\n if (this.logMessageField === '') {\n this.logMessageField = undefined;\n }\n\n if (this.logLevelField === '') {\n this.logLevelField = undefined;\n }\n this.languageProvider = new LanguageProvider(this);\n }\n\n private request(\n method: string,\n url: string,\n data?: undefined,\n headers?: BackendSrvRequest['headers']\n ): Observable<any> {\n if (!this.isProxyAccess) {\n const error = new Error(\n 'Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode.'\n );\n return throwError(() => error);\n }\n\n if (!isSupportedVersion(this.esVersion)) {\n const error = new Error(\n 'Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed.'\n );\n return throwError(() => error);\n }\n\n const options: BackendSrvRequest = {\n url: this.url + '/' + url,\n method,\n data,\n headers,\n };\n\n if (this.basicAuth || this.withCredentials) {\n options.withCredentials = true;\n }\n if (this.basicAuth) {\n options.headers = {\n Authorization: this.basicAuth,\n };\n }\n\n return getBackendSrv()\n .fetch<any>(options)\n .pipe(\n map((results) => {\n results.data.$$config = results.config;\n return results.data;\n }),\n catchError((err) => {\n if (err.data) {\n const message = err.data.error?.reason ?? err.data.message ?? 'Unknown error';\n\n return throwError({\n message: 'Elasticsearch error: ' + message,\n error: err.data.error,\n });\n }\n\n return throwError(err);\n })\n );\n }\n\n async importFromAbstractQueries(abstractQueries: AbstractQuery[]): Promise<ElasticsearchQuery[]> {\n return abstractQueries.map((abstractQuery) => this.languageProvider.importFromAbstractQuery(abstractQuery));\n }\n\n /**\n * Sends a GET request to the specified url on the newest matching and available index.\n *\n * When multiple indices span the provided time range, the request is sent starting from the newest index,\n * and then going backwards until an index is found.\n *\n * @param url the url to query the index on, for example `/_mapping`.\n */\n private get(url: string, range = getDefaultTimeRange()): Observable<any> {\n let indexList = this.indexPattern.getIndexList(range.from, range.to);\n if (!Array.isArray(indexList)) {\n indexList = [this.indexPattern.getIndexForToday()];\n }\n\n const indexUrlList = indexList.map((index) => index + url);\n\n return this.requestAllIndices(indexUrlList);\n }\n\n private requestAllIndices(indexList: string[]): Observable<any> {\n const maxTraversals = 7; // do not go beyond one week (for a daily pattern)\n const listLen = indexList.length;\n\n return generate({\n initialState: 0,\n condition: (i) => i < Math.min(listLen, maxTraversals),\n iterate: (i) => i + 1,\n }).pipe(\n mergeMap((index) => {\n // catch all errors and emit an object with an err property to simplify checks later in the pipeline\n return this.request('GET', indexList[listLen - index - 1]).pipe(catchError((err) => of({ err })));\n }),\n skipWhile((resp) => resp?.err?.status === 404), // skip all requests that fail because missing Elastic index\n throwIfEmpty(() => 'Could not find an available index for this time range.'), // when i === Math.min(listLen, maxTraversals) generate will complete but without emitting any values which means we didn't find a valid index\n first(), // take the first value that isn't skipped\n map((resp) => {\n if (resp.err) {\n throw resp.err; // if there is some other error except 404 then we must throw it\n }\n\n return resp;\n })\n );\n }\n\n private post(url: string, data: any): Observable<any> {\n return this.request('POST', url, data, { 'Content-Type': 'application/x-ndjson' });\n }\n\n annotationQuery(options: any): Promise<any> {\n const annotation = options.annotation;\n const timeField = annotation.timeField || '@timestamp';\n const timeEndField = annotation.timeEndField || null;\n const queryString = annotation.query;\n const tagsField = annotation.tagsField || 'tags';\n const textField = annotation.textField || null;\n\n const dateRanges = [];\n const rangeStart: any = {};\n rangeStart[timeField] = {\n from: options.range.from.valueOf(),\n to: options.range.to.valueOf(),\n format: 'epoch_millis',\n };\n dateRanges.push({ range: rangeStart });\n\n if (timeEndField) {\n const rangeEnd: any = {};\n rangeEnd[timeEndField] = {\n from: options.range.from.valueOf(),\n to: options.range.to.valueOf(),\n format: 'epoch_millis',\n };\n dateRanges.push({ range: rangeEnd });\n }\n\n const queryInterpolated = this.interpolateLuceneQuery(queryString);\n const query: any = {\n bool: {\n filter: [\n {\n bool: {\n should: dateRanges,\n minimum_should_match: 1,\n },\n },\n ],\n },\n };\n\n if (queryInterpolated) {\n query.bool.filter.push({\n query_string: {\n query: queryInterpolated,\n },\n });\n }\n const data: any = {\n query,\n size: 10000,\n };\n\n // fields field not supported on ES 5.x\n if (lt(this.esVersion, '5.0.0')) {\n data['fields'] = [timeField, '_source'];\n }\n\n const header: any = {\n search_type: 'query_then_fetch',\n ignore_unavailable: true,\n };\n\n // old elastic annotations had index specified on them\n if (annotation.index) {\n header.index = annotation.index;\n } else {\n header.index = this.indexPattern.getIndexList(options.range.from, options.range.to);\n }\n\n const payload = JSON.stringify(header) + '\\n' + JSON.stringify(data) + '\\n';\n\n return lastValueFrom(\n this.post('_msearch', payload).pipe(\n map((res) => {\n const list = [];\n const hits = res.responses[0].hits.hits;\n\n const getFieldFromSource = (source: any, fieldName: any) => {\n if (!fieldName) {\n return;\n }\n\n const fieldNames = fieldName.split('.');\n let fieldValue = source;\n\n for (let i = 0; i < fieldNames.length; i++) {\n fieldValue = fieldValue[fieldNames[i]];\n if (!fieldValue) {\n console.log('could not find field in annotation: ', fieldName);\n return '';\n }\n }\n\n return fieldValue;\n };\n\n for (let i = 0; i < hits.length; i++) {\n const source = hits[i]._source;\n let time = getFieldFromSource(source, timeField);\n if (typeof hits[i].fields !== 'undefined') {\n const fields = hits[i].fields;\n if (isString(fields[timeField]) || isNumber(fields[timeField])) {\n time = fields[timeField];\n }\n }\n\n const event: {\n annotation: any;\n time: number;\n timeEnd?: number;\n text: string;\n tags: string | string[];\n } = {\n annotation: annotation,\n time: toUtc(time).valueOf(),\n text: getFieldFromSource(source, textField),\n tags: getFieldFromSource(source, tagsField),\n };\n\n if (timeEndField) {\n const timeEnd = getFieldFromSource(source, timeEndField);\n if (timeEnd) {\n event.timeEnd = toUtc(timeEnd).valueOf();\n }\n }\n\n // legacy support for title tield\n if (annotation.titleField) {\n const title = getFieldFromSource(source, annotation.titleField);\n if (title) {\n event.text = title + '\\n' + event.text;\n }\n }\n\n if (typeof event.tags === 'string') {\n event.tags = event.tags.split(',');\n }\n\n list.push(event);\n }\n return list;\n })\n )\n );\n }\n\n private interpolateLuceneQuery(queryString: string, scopedVars?: ScopedVars) {\n return this.templateSrv.replace(queryString, scopedVars, 'lucene');\n }\n\n interpolateVariablesInQueries(queries: ElasticsearchQuery[], scopedVars: ScopedVars): ElasticsearchQuery[] {\n // We need a separate interpolation format for lucene queries, therefore we first interpolate any\n // lucene query string and then everything else\n const interpolateBucketAgg = (bucketAgg: BucketAggregation): BucketAggregation => {\n if (bucketAgg.type === 'filters') {\n return {\n ...bucketAgg,\n settings: {\n ...bucketAgg.settings,\n filters: bucketAgg.settings?.filters?.map((filter) => ({\n ...filter,\n query: this.interpolateLuceneQuery(filter.query, scopedVars) || '*',\n })),\n },\n };\n }\n\n return bucketAgg;\n };\n\n const expandedQueries = queries.map(\n (query): ElasticsearchQuery => ({\n ...query,\n datasource: this.getRef(),\n query: this.interpolateLuceneQuery(query.query || '', scopedVars),\n bucketAggs: query.bucketAggs?.map(interpolateBucketAgg),\n })\n );\n\n const finalQueries: ElasticsearchQuery[] = JSON.parse(\n this.templateSrv.replace(JSON.stringify(expandedQueries), scopedVars)\n );\n\n return finalQueries;\n }\n\n testDatasource() {\n // validate that the index exist and has date field\n return lastValueFrom(\n this.getFields(['date']).pipe(\n mergeMap((dateFields) => {\n const timeField: any = find(dateFields, { text: this.timeField });\n if (!timeField) {\n return of({ status: 'error', message: 'No date field named ' + this.timeField + ' found' });\n }\n return of({ status: 'success', message: 'Index OK. Time field name OK.' });\n }),\n catchError((err) => {\n console.error(err);\n if (err.message) {\n return of({ status: 'error', message: err.message });\n } else {\n return of({ status: 'error', message: err.status });\n }\n })\n )\n );\n }\n\n getQueryHeader(searchType: any, timeFrom?: DateTime, timeTo?: DateTime): string {\n const queryHeader: any = {\n search_type: searchType,\n ignore_unavailable: true,\n index: this.indexPattern.getIndexList(timeFrom, timeTo),\n };\n\n if (satisfies(this.esVersion, '>=5.6.0 <7.0.0')) {\n queryHeader['max_concurrent_shard_requests'] = this.maxConcurrentShardRequests;\n }\n\n return JSON.stringify(queryHeader);\n }\n\n getQueryDisplayText(query: ElasticsearchQuery) {\n // TODO: This might be refactored a bit.\n const metricAggs = query.metrics;\n const bucketAggs = query.bucketAggs;\n let text = '';\n\n if (query.query) {\n text += 'Query: ' + query.query + ', ';\n }\n\n text += 'Metrics: ';\n\n text += metricAggs?.reduce((acc, metric) => {\n const metricConfig = metricAggregationConfig[metric.type];\n\n let text = metricConfig.label + '(';\n\n if (isMetricAggregationWithField(metric)) {\n text += metric.field;\n }\n if (isPipelineAggregationWithMultipleBucketPaths(metric)) {\n text += getScriptValue(metric).replace(new RegExp('params.', 'g'), '');\n }\n text += '), ';\n\n return `${acc} ${text}`;\n }, '');\n\n text += bucketAggs?.reduce((acc, bucketAgg, index) => {\n const bucketConfig = bucketAggregationConfig[bucketAgg.type];\n\n let text = '';\n if (index === 0) {\n text += ' Group by: ';\n }\n\n text += bucketConfig.label + '(';\n if (isBucketAggregationWithField(bucketAgg)) {\n text += bucketAgg.field;\n }\n\n return `${acc} ${text}), `;\n }, '');\n\n if (query.alias) {\n text += 'Alias: ' + query.alias;\n }\n\n return text;\n }\n\n /**\n * This method checks to ensure the user is running a 5.0+ cluster. This is\n * necessary bacause the query being used for the getLogRowContext relies on the\n * search_after feature.\n */\n showContextToggle(): boolean {\n return gte(this.esVersion, '5.0.0');\n }\n\n getLogRowContext = async (row: LogRowModel, options?: RowContextOptions): Promise<{ data: DataFrame[] }> => {\n const sortField = row.dataFrame.fields.find((f) => f.name === 'sort');\n const searchAfter = sortField?.values.get(row.rowIndex) || [row.timeEpochMs];\n const sort = options?.direction === 'FORWARD' ? 'asc' : 'desc';\n\n const header =\n options?.direction === 'FORWARD'\n ? this.getQueryHeader('query_then_fetch', dateTime(row.timeEpochMs))\n : this.getQueryHeader('query_then_fetch', undefined, dateTime(row.timeEpochMs));\n\n const limit = options?.limit ?? 10;\n const esQuery = JSON.stringify({\n size: limit,\n query: {\n bool: {\n filter: [\n {\n range: {\n [this.timeField]: {\n [options?.direction === 'FORWARD' ? 'gte' : 'lte']: row.timeEpochMs,\n format: 'epoch_millis',\n },\n },\n },\n ],\n },\n },\n sort: [{ [this.timeField]: sort }, { _doc: sort }],\n search_after: searchAfter,\n });\n const payload = [header, esQuery].join('\\n') + '\\n';\n const url = this.getMultiSearchUrl();\n const response = await lastValueFrom(this.post(url, payload));\n const targets: ElasticsearchQuery[] = [{ refId: `${row.dataFrame.refId}`, metrics: [{ type: 'logs', id: '1' }] }];\n const elasticResponse = new ElasticResponse(targets, transformHitsBasedOnDirection(response, sort));\n const logResponse = elasticResponse.getLogs(this.logMessageField, this.logLevelField);\n const dataFrame = _first(logResponse.data);\n if (!dataFrame) {\n return { data: [] };\n }\n /**\n * The LogRowContextProvider requires there is a field in the dataFrame.fields\n * named `ts` for timestamp and `line` for the actual log line to display.\n * Unfortunatly these fields are hardcoded and are required for the lines to\n * be properly displayed. This code just copies the fields based on this.timeField\n * and this.logMessageField and recreates the dataFrame so it works.\n */\n const timestampField = dataFrame.fields.find((f: Field) => f.name === this.timeField);\n const lineField = dataFrame.fields.find((f: Field) => f.name === this.logMessageField);\n if (timestampField && lineField) {\n return {\n data: [\n {\n ...dataFrame,\n fields: [...dataFrame.fields, { ...timestampField, name: 'ts' }, { ...lineField, name: 'line' }],\n },\n ],\n };\n }\n return logResponse;\n };\n\n getLogsVolumeDataProvider(request: DataQueryRequest<ElasticsearchQuery>): Observable<DataQueryResponse> | undefined {\n const isLogsVolumeAvailable = request.targets.some((target) => {\n return target.metrics?.length === 1 && target.metrics[0].type === 'logs';\n });\n if (!isLogsVolumeAvailable) {\n return undefined;\n }\n const logsVolumeRequest = cloneDeep(request);\n logsVolumeRequest.targets = logsVolumeRequest.targets.map((target) => {\n const bucketAggs: BucketAggregation[] = [];\n const timeField = this.timeField ?? '@timestamp';\n\n if (this.logLevelField) {\n bucketAggs.push({\n id: '2',\n type: 'terms',\n settings: {\n min_doc_count: '0',\n size: '0',\n order: 'desc',\n orderBy: '_count',\n missing: LogLevel.unknown,\n },\n field: this.logLevelField,\n });\n }\n bucketAggs.push({\n id: '3',\n type: 'date_histogram',\n settings: {\n interval: 'auto',\n min_doc_count: '0',\n trimEdges: '0',\n },\n field: timeField,\n });\n\n const logsVolumeQuery: ElasticsearchQuery = {\n refId: target.refId,\n query: target.query,\n metrics: [{ type: 'count', id: '1' }],\n timeField,\n bucketAggs,\n };\n return logsVolumeQuery;\n });\n\n return queryLogsVolume(this, logsVolumeRequest, {\n range: request.range,\n targets: request.targets,\n extractLevel: (dataFrame) => getLogLevelFromKey(dataFrame.name || ''),\n });\n }\n\n query(options: DataQueryRequest<ElasticsearchQuery>): Observable<DataQueryResponse> {\n let payload = '';\n const targets = this.interpolateVariablesInQueries(cloneDeep(options.targets), options.scopedVars);\n const sentTargets: ElasticsearchQuery[] = [];\n let targetsContainsLogsQuery = targets.some((target) => hasMetricOfType(target, 'logs'));\n\n // add global adhoc filters to timeFilter\n const adhocFilters = this.templateSrv.getAdhocFilters(this.name);\n\n const logLimits: Array<number | undefined> = [];\n\n for (const target of targets) {\n if (target.hide) {\n continue;\n }\n\n let queryObj;\n if (hasMetricOfType(target, 'logs')) {\n // FIXME: All this logic here should be in the query builder.\n // When moving to the BE-only implementation we should remove this and let the BE\n // Handle this.\n // TODO: defaultBucketAgg creates a dete_histogram aggregation without a field, so it fallbacks to\n // the configured timeField. we should allow people to use a different time field here.\n target.bucketAggs = [defaultBucketAgg()];\n\n const log = target.metrics?.find((m) => m.type === 'logs') as Logs;\n const limit = log.settings?.limit ? parseInt(log.settings?.limit, 10) : 500;\n logLimits.push(limit);\n\n target.metrics = [];\n // Setting this for metrics queries that are typed as logs\n queryObj = this.queryBuilder.getLogsQuery(target, limit, adhocFilters);\n } else {\n logLimits.push();\n if (target.alias) {\n target.alias = this.interpolateLuceneQuery(target.alias, options.scopedVars);\n }\n\n queryObj = this.queryBuilder.build(target, adhocFilters);\n }\n\n const esQuery = JSON.stringify(queryObj);\n\n const searchType = queryObj.size === 0 && lt(this.esVersion, '5.0.0') ? 'count' : 'query_then_fetch';\n const header = this.getQueryHeader(searchType, options.range.from, options.range.to);\n payload += header + '\\n';\n\n payload += esQuery + '\\n';\n\n sentTargets.push(target);\n }\n\n if (sentTargets.length === 0) {\n return of({ data: [] });\n }\n\n // We replace the range here for actual values. We need to replace it together with enclosing \"\" so that we replace\n // it as an integer not as string with digits. This is because elastic will convert the string only if the time\n // field is specified as type date (which probably should) but can also be specified as integer (millisecond epoch)\n // and then sending string will error out.\n payload = payload.replace(/\"\\$timeFrom\"/g, options.range.from.valueOf().toString());\n payload = payload.replace(/\"\\$timeTo\"/g, options.range.to.valueOf().toString());\n payload = this.templateSrv.replace(payload, options.scopedVars);\n\n const url = this.getMultiSearchUrl();\n\n return this.post(url, payload).pipe(\n map((res) => {\n const er = new ElasticResponse(sentTargets, res);\n\n // TODO: This needs to be revisited, it seems wrong to process ALL the sent queries as logs if only one of them was a log query\n if (targetsContainsLogsQuery) {\n const response = er.getLogs(this.logMessageField, this.logLevelField);\n\n response.data.forEach((dataFrame, index) => {\n enhanceDataFrame(dataFrame, this.dataLinks, logLimits[index]);\n });\n return response;\n }\n\n return er.getTimeSeries();\n })\n );\n }\n\n isMetadataField(fieldName: string) {\n return ELASTIC_META_FIELDS.includes(fieldName);\n }\n\n // TODO: instead of being a string, this could be a custom type representing all the elastic types\n // FIXME: This doesn't seem to return actual MetricFindValues, we should either change the return type\n // or fix the implementation.\n getFields(type?: string[], range?: TimeRange): Observable<MetricFindValue[]> {\n const typeMap: Record<string, string> = {\n float: 'number',\n double: 'number',\n integer: 'number',\n long: 'number',\n date: 'date',\n date_nanos: 'date',\n string: 'string',\n text: 'string',\n scaled_float: 'number',\n nested: 'nested',\n histogram: 'number',\n };\n return this.get('/_mapping', range).pipe(\n map((result) => {\n const shouldAddField = (obj: any, key: string) => {\n if (this.isMetadataField(key)) {\n return false;\n }\n\n if (!type || type.length === 0) {\n return true;\n }\n\n // equal query type filter, or via typemap translation\n return type.includes(obj.type) || type.includes(typeMap[obj.type]);\n };\n\n // Store subfield names: [system, process, cpu, total] -> system.process.cpu.total\n const fieldNameParts: any = [];\n const fields: any = {};\n\n function getFieldsRecursively(obj: any) {\n for (const key in obj) {\n const subObj = obj[key];\n\n // Check mapping field for nested fields\n if (isObject(subObj.properties)) {\n fieldNameParts.push(key);\n getFieldsRecursively(subObj.properties);\n }\n\n if (isObject(subObj.fields)) {\n fieldNameParts.push(key);\n getFieldsRecursively(subObj.fields);\n }\n\n if (isString(subObj.type)) {\n const fieldName = fieldNameParts.concat(key).join('.');\n\n // Hide meta-fields and check field type\n if (shouldAddField(subObj, key)) {\n fields[fieldName] = {\n text: fieldName,\n type: subObj.type,\n };\n }\n }\n }\n fieldNameParts.pop();\n }\n\n for (const indexName in result) {\n const index = result[indexName];\n if (index && index.mappings) {\n const mappings = index.mappings;\n\n if (lt(this.esVersion, '7.0.0')) {\n for (const typeName in mappings) {\n const properties = mappings[typeName].properties;\n getFieldsRecursively(properties);\n }\n } else {\n const properties = mappings.properties;\n getFieldsRecursively(properties);\n }\n }\n }\n\n // transform to array\n return _map(fields, (value) => {\n return value;\n });\n })\n );\n }\n\n getTerms(queryDef: TermsQuery, range = getDefaultTimeRange()): Observable<MetricFindValue[]> {\n const searchType = gte(this.esVersion, '5.0.0') ? 'query_then_fetch' : 'count';\n const header = this.getQueryHeader(searchType, range.from, range.to);\n let esQuery = JSON.stringify(this.queryBuilder.getTermsQuery(queryDef));\n\n esQuery = esQuery.replace(/\\$timeFrom/g, range.from.valueOf().toString());\n esQuery = esQuery.replace(/\\$timeTo/g, range.to.valueOf().toString());\n esQuery = header + '\\n' + esQuery + '\\n';\n\n const url = this.getMultiSearchUrl();\n\n return this.post(url, esQuery).pipe(\n map((res) => {\n if (!res.responses[0].aggregations) {\n return [];\n }\n\n const buckets = res.responses[0].aggregations['1'].buckets;\n return _map(buckets, (bucket) => {\n return {\n text: bucket.key_as_string || bucket.key,\n value: bucket.key,\n };\n });\n })\n );\n }\n\n getMultiSearchUrl() {\n const searchParams = new URLSearchParams();\n\n if (gte(this.esVersion, '7.0.0') && this.maxConcurrentShardRequests) {\n searchParams.append('max_concurrent_shard_requests', `${this.maxConcurrentShardRequests}`);\n }\n\n if (gte(this.esVersion, '6.6.0') && this.xpack && this.includeFrozen) {\n searchParams.append('ignore_throttled', 'false');\n }\n\n return ('_msearch?' + searchParams.toString()).replace(/\\?$/, '');\n }\n\n metricFindQuery(query: string, options?: any): Promise<MetricFindValue[]> {\n const range = options?.range;\n const parsedQuery = JSON.parse(query);\n if (query) {\n if (parsedQuery.find === 'fields') {\n parsedQuery.type = this.interpolateLuceneQuery(parsedQuery.type);\n return lastValueFrom(this.getFields(parsedQuery.type, range));\n }\n\n if (parsedQuery.find === 'terms') {\n parsedQuery.field = this.interpolateLuceneQuery(parsedQuery.field);\n parsedQuery.query = this.interpolateLuceneQuery(parsedQuery.query);\n return lastValueFrom(this.getTerms(parsedQuery, range));\n }\n }\n\n return Promise.resolve([]);\n }\n\n getTagKeys() {\n return lastValueFrom(this.getFields());\n }\n\n getTagValues(options: any) {\n return lastValueFrom(this.getTerms({ field: options.key }));\n }\n\n targetContainsTemplate(target: any) {\n if (this.templateSrv.containsTemplate(target.query) || this.templateSrv.containsTemplate(target.alias)) {\n return true;\n }\n\n for (const bucketAgg of target.bucketAggs) {\n if (this.templateSrv.containsTemplate(bucketAgg.field) || this.objectContainsTemplate(bucketAgg.settings)) {\n return true;\n }\n }\n\n for (const metric of target.metrics) {\n if (\n this.templateSrv.containsTemplate(metric.field) ||\n this.objectContainsTemplate(metric.settings) ||\n this.objectContainsTemplate(metric.meta)\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n private isPrimitive(obj: any) {\n if (obj === null || obj === undefined) {\n return true;\n }\n if (['string', 'number', 'boolean'].some((type) => type === typeof true)) {\n return true;\n }\n\n return false;\n }\n\n private objectContainsTemplate(obj: any) {\n if (!obj) {\n return false;\n }\n\n for (const key of Object.keys(obj)) {\n if (this.isPrimitive(obj[key])) {\n if (this.templateSrv.containsTemplate(obj[key])) {\n return true;\n }\n } else if (Array.isArray(obj[key])) {\n for (const item of obj[key]) {\n if (this.objectContainsTemplate(item)) {\n return true;\n }\n }\n } else {\n if (this.objectContainsTemplate(obj[key])) {\n return true;\n }\n }\n }\n\n return false;\n }\n}\n\n/**\n * Modifies dataframe and adds dataLinks from the config.\n * Exported for tests.\n */\nexport function enhanceDataFrame(dataFrame: DataFrame, dataLinks: DataLinkConfig[], limit?: number) {\n if (limit) {\n dataFrame.meta = {\n ...dataFrame.meta,\n limit,\n };\n }\n\n if (!dataLinks.length) {\n return;\n }\n\n for (const field of dataFrame.fields) {\n const linksToApply = dataLinks.filter((dataLink) => new RegExp(dataLink.field).test(field.name));\n\n if (linksToApply.length === 0) {\n continue;\n }\n\n field.config = field.config || {};\n field.config.links = [...(field.config.links || [], linksToApply.map(generateDataLink))];\n }\n}\n\nfunction generateDataLink(linkConfig: DataLinkConfig): DataLink {\n const dataSourceSrv = getDataSourceSrv();\n\n if (linkConfig.datasourceUid) {\n const dsSettings = dataSourceSrv.getInstanceSettings(linkConfig.datasourceUid);\n\n return {\n title: linkConfig.urlDisplayLabel || '',\n url: '',\n internal: {\n query: { query: linkConfig.url },\n datasourceUid: linkConfig.datasourceUid,\n datasourceName: dsSettings?.name ?? 'Data source not found',\n },\n };\n } else {\n return {\n title: linkConfig.urlDisplayLabel || '',\n url: linkConfig.url,\n };\n }\n}\n\nfunction transformHitsBasedOnDirection(response: any, direction: 'asc' | 'desc') {\n if (direction === 'desc') {\n return response;\n }\n const actualResponse = response.responses[0];\n return {\n ...response,\n responses: [\n {\n ...actualResponse,\n hits: {\n ...actualResponse.hits,\n hits: actualResponse.hits.hits.reverse(),\n },\n },\n ],\n };\n}\n","import { DataSourcePlugin } from '@grafana/data';\n\nimport { QueryEditor } from './components/QueryEditor';\nimport { ConfigEditor } from './configuration/ConfigEditor';\nimport { ElasticDatasource } from './datasource';\n\nclass ElasticAnnotationsQueryCtrl {\n static templateUrl = 'partials/annotations.editor.html';\n}\n\nexport const plugin = new DataSourcePlugin(ElasticDatasource)\n .setQueryEditor(QueryEditor)\n .setConfigEditor(ConfigEditor)\n .setAnnotationQueryCtrl(ElasticAnnotationsQueryCtrl);\n","import React, { useEffect, useRef } from 'react';\n\nimport { SIGV4ConnectionConfig } from '@grafana/aws-sdk';\nimport { DataSourcePluginOptionsEditorProps } from '@grafana/data';\nimport { Alert, DataSourceHttpSettings } from '@grafana/ui';\nimport { config } from 'app/core/config';\n\nimport { ElasticsearchOptions } from '../types';\nimport { isSupportedVersion } from '../utils';\n\nimport { DataLinks } from './DataLinks';\nimport { ElasticDetails } from './ElasticDetails';\nimport { LogsConfig } from './LogsConfig';\nimport { coerceOptions, isValidOptions } from './utils';\n\nexport type Props = DataSourcePluginOptionsEditorProps<ElasticsearchOptions>;\n\nexport const ConfigEditor = (props: Props) => {\n // we decide on whether to show access options or not at the point when the config page opens.\n // whatever happens while the page is open, this decision does not change.\n // (we do this to avoid situations where you switch access-mode and suddenly\n // the access-mode-select-box vanishes)\n const showAccessOptions = useRef(props.options.access === 'direct');\n\n const { options: originalOptions, onOptionsChange } = props;\n const options = coerceOptions(originalOptions);\n\n useEffect(() => {\n if (!isValidOptions(originalOptions)) {\n onOptionsChange(coerceOptions(originalOptions));\n }\n\n // We can't enforce the eslint rule here because we only want to run this once.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const supportedVersion = isSupportedVersion(options.jsonData.esVersion);\n\n return (\n <>\n {options.access === 'direct' && (\n <Alert title=\"Error\" severity=\"error\">\n Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode.\n </Alert>\n )}\n {!supportedVersion && (\n <Alert title=\"Deprecation notice\" severity=\"error\">\n {`Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed`}\n </Alert>\n )}\n <DataSourceHttpSettings\n defaultUrl=\"http://localhost:9200\"\n dataSourceConfig={options}\n showAccessOptions={showAccessOptions.current}\n onChange={onOptionsChange}\n sigV4AuthToggleEnabled={config.sigV4AuthEnabled}\n renderSigV4Editor={<SIGV4ConnectionConfig {...props}></SIGV4ConnectionConfig>}\n />\n\n <ElasticDetails value={options} onChange={onOptionsChange} />\n\n <LogsConfig\n value={options.jsonData}\n onChange={(newValue) =>\n onOptionsChange({\n ...options,\n jsonData: newValue,\n })\n }\n />\n\n <DataLinks\n value={options.jsonData.dataLinks}\n onChange={(newValue) => {\n onOptionsChange({\n ...options,\n jsonData: {\n ...options.jsonData,\n dataLinks: newValue,\n },\n });\n }}\n />\n </>\n );\n};\n","import { useEffect, useRef } from 'react';\nexport default function usePrevious(state) {\n var ref = useRef();\n useEffect(function () {\n ref.current = state;\n });\n return ref.current;\n}\n","Object.defineProperty(exports,\"__esModule\",{value:!0});var e,t=require(\"react\"),a=(e=t)&&\"object\"==typeof e&&\"default\"in e?e.default:e,n=require(\"@grafana/ui\"),l=require(\"@grafana/data\"),o=require(\"lodash\"),s=function(){return(s=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var l in t=arguments[a])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e}).apply(this,arguments)};function i(e,t,a,n){return new(a||(a=Promise))((function(l,o){function s(e){try{r(n.next(e))}catch(e){o(e)}}function i(e){try{r(n.throw(e))}catch(e){o(e)}}function r(e){var t;e.done?l(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(s,i)}r((n=n.apply(e,t||[])).next())}))}function r(e,t){var a,n,l,o,s={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(a)throw new TypeError(\"Generator is already executing.\");for(;s;)try{if(a=1,n&&(l=2&o[0]?n.return:o[0]?n.throw||((l=n.return)&&l.call(n),0):n.next)&&!(l=l.call(n,o[1])).done)return l;switch(n=0,l&&(o=[2&o[0],l.value]),o[0]){case 0:case 1:l=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(l=s.trys,(l=l.length>0&&l[l.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!l||o[1]>l[0]&&o[1]<l[3])){s.label=o[1];break}if(6===o[0]&&s.label<l[1]){s.label=l[1],l=o;break}if(l&&s.label<l[2]){s.label=l[2],s.ops.push(o);break}l[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{a=l=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function u(e,t){var a=\"function\"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var n,l,o=a.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){l={error:e}}finally{try{n&&!n.done&&(a=o.return)&&a.call(o)}finally{if(l)throw l.error}}return s}var c,d=[\"af-south-1\",\"ap-east-1\",\"ap-northeast-1\",\"ap-northeast-2\",\"ap-northeast-3\",\"ap-south-1\",\"ap-southeast-1\",\"ap-southeast-2\",\"ca-central-1\",\"cn-north-1\",\"cn-northwest-1\",\"eu-central-1\",\"eu-north-1\",\"eu-west-1\",\"eu-west-2\",\"eu-west-3\",\"me-south-1\",\"sa-east-1\",\"us-east-1\",\"us-east-2\",\"us-gov-east-1\",\"us-gov-west-1\",\"us-iso-east-1\",\"us-isob-east-1\",\"us-west-1\",\"us-west-2\"];(c=exports.AwsAuthType||(exports.AwsAuthType={})).Keys=\"keys\",c.Credentials=\"credentials\",c.Default=\"default\",c.EC2IAMRole=\"ec2_iam_role\",c.ARN=\"arn\";var p,h=[{label:\"Workspace IAM Role\",value:exports.AwsAuthType.EC2IAMRole},{label:\"AWS SDK Default\",value:exports.AwsAuthType.Default},{label:\"Access & secret key\",value:exports.AwsAuthType.Keys},{label:\"Credentials file\",value:exports.AwsAuthType.Credentials}],f=function(e){return{value:e,label:e}},v=function(e){var o,i,r,c,p,v,m,g,y,b=u(t.useState((e.standardRegions||d).map(f)),2),D=b[0],w=b[1],E=e.loadRegions,A=e.onOptionsChange,S=e.skipHeader,C=void 0!==S&&S,x=e.skipEndpoint,V=void 0!==x&&x,I=e.options,F=I.jsonData.profile;void 0===F&&(F=I.database);var O=window.grafanaBootData.settings,R=null!==(o=O.awsAllowedAuthProviders)&&void 0!==o?o:[exports.AwsAuthType.Default,exports.AwsAuthType.Keys,exports.AwsAuthType.Credentials],j=null===(i=O.awsAssumeRoleEnabled)||void 0===i||i,K=h.find((function(e){return e.value===I.jsonData.authType}));return t.useEffect((function(){!K&&R.length&&A(s(s({},I),{jsonData:s(s({},I.jsonData),{authType:R[0]})}))}),[K,I,A]),t.useEffect((function(){E&&E().then((function(e){return w(e.map(f))}))}),[E]),a.createElement(n.FieldSet,{label:C?\"\":\"Connection Details\",\"data-testid\":\"connection-config\"},a.createElement(n.InlineField,{label:\"Authentication Provider\",labelWidth:28,tooltip:\"Specify which AWS credentials chain to use.\"},a.createElement(n.Select,{\"aria-label\":\"Authentication Provider\",className:\"width-30\",value:K,options:h.filter((function(e){return R.includes(e.value)})),defaultValue:I.jsonData.authType,onChange:function(t){l.onUpdateDatasourceJsonDataOptionSelect(e,\"authType\")(t)},menuShouldPortal:!0})),\"credentials\"===I.jsonData.authType&&a.createElement(n.InlineField,{label:\"Credentials Profile Name\",labelWidth:28,tooltip:\"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default.\"},a.createElement(n.Input,{\"aria-label\":\"Credentials Profile Name\",className:\"width-30\",placeholder:\"default\",value:F,onChange:l.onUpdateDatasourceJsonDataOption(e,\"profile\")})),\"keys\"===I.jsonData.authType&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:\"Access Key ID\",labelWidth:28},(null===(r=e.options.secureJsonFields)||void 0===r?void 0:r.accessKey)?a.createElement(n.ButtonGroup,{className:\"width-30\"},a.createElement(n.Input,{disabled:!0,placeholder:\"Configured\"}),a.createElement(n.ToolbarButton,{icon:\"edit\",tooltip:\"Edit Access Key ID\",type:\"button\",onClick:l.onUpdateDatasourceResetOption(e,\"accessKey\")})):a.createElement(n.Input,{\"aria-label\":\"Access Key ID\",className:\"width-30\",value:null!==(p=null===(c=I.secureJsonData)||void 0===c?void 0:c.accessKey)&&void 0!==p?p:\"\",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,\"accessKey\")})),a.createElement(n.InlineField,{label:\"Secret Access Key\",labelWidth:28},(null===(v=e.options.secureJsonFields)||void 0===v?void 0:v.secretKey)?a.createElement(n.ButtonGroup,{className:\"width-30\"},a.createElement(n.Input,{disabled:!0,placeholder:\"Configured\"}),a.createElement(n.ToolbarButton,{icon:\"edit\",type:\"button\",tooltip:\"Edit Secret Access Key\",onClick:l.onUpdateDatasourceResetOption(e,\"secretKey\")})):a.createElement(n.Input,{\"aria-label\":\"Secret Access Key\",className:\"width-30\",value:null!==(g=null===(m=I.secureJsonData)||void 0===m?void 0:m.secretKey)&&void 0!==g?g:\"\",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,\"secretKey\")}))),j&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:\"Assume Role ARN\",labelWidth:28,tooltip:\"Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all\"},a.createElement(n.Input,{\"aria-label\":\"Assume Role ARN\",className:\"width-30\",placeholder:\"arn:aws:iam:*\",value:I.jsonData.assumeRoleArn||\"\",onChange:l.onUpdateDatasourceJsonDataOption(e,\"assumeRoleArn\")})),a.createElement(n.InlineField,{label:\"External ID\",labelWidth:28,tooltip:\"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here.\"},a.createElement(n.Input,{\"aria-label\":\"External ID\",className:\"width-30\",placeholder:\"External ID\",value:I.jsonData.externalId||\"\",onChange:l.onUpdateDatasourceJsonDataOption(e,\"externalId\")}))),!V&&a.createElement(n.InlineField,{label:\"Endpoint\",labelWidth:28,tooltip:\"Optionally, specify a custom endpoint for the service\"},a.createElement(n.Input,{\"aria-label\":\"Endpoint\",className:\"width-30\",placeholder:null!==(y=e.defaultEndpoint)&&void 0!==y?y:\"https://{service}.{region}.amazonaws.com\",value:I.jsonData.endpoint||\"\",onChange:l.onUpdateDatasourceJsonDataOption(e,\"endpoint\")})),a.createElement(n.InlineField,{label:\"Default Region\",labelWidth:28,tooltip:\"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region.\"},a.createElement(n.Select,{\"aria-label\":\"Default Region\",className:\"width-30\",value:D.find((function(e){return e.value===I.jsonData.defaultRegion})),options:D,defaultValue:I.jsonData.defaultRegion,allowCustomValue:!0,onChange:l.onUpdateDatasourceJsonDataOptionSelect(e,\"defaultRegion\"),formatCreateLabel:function(e){return\"Use region: \"+e},menuShouldPortal:!0})),e.children)};function m(e){var l=this,c=u(t.useState(e.value||e.default||null),2),d=c[0],p=c[1],h=u(t.useState(d?[d]:[]),2),f=h[0],v=h[1],m=u(t.useState(e.dependencies),2),g=m[0],y=m[1],b=u(t.useState(!1),2),D=b[0],w=b[1],E=u(t.useState(!1),2),A=E[0],S=E[1],C=t.useMemo((function(){var t=[{label:\"default (\"+e.default+\")\",value:\"__default\",description:\"Default value set in the data source\"}];return e.value&&\"__default\"!==e.value&&t.push({label:e.value,value:e.value}),t}),[e.default,e.value]),x=u(t.useState(e.default?C:[]),2),V=x[0],I=x[1];t.useEffect((function(){void 0!==e.resources&&v(e.resources)}),[e.resources]),t.useEffect((function(){var t=e.default?C:[];f.length?(f.forEach((function(e){var a=\"string\"==typeof e?e:e.value;t.find((function(e){return e.value===a}))||(\"string\"==typeof e?t.push({label:e,value:e}):t.push(e))})),I(t)):I([])}),[f,C,e.default]),t.useEffect((function(){o.isEqual(e.dependencies,g)||(S(!1),p(null),e.onChange(null),y(e.dependencies))}),[e,g]);return a.createElement(n.InlineField,{label:e.label,labelWidth:e.labelWidth,tooltip:e.tooltip,hidden:e.hidden},a.createElement(\"div\",{\"data-testid\":e[\"data-testid\"],title:e.title},a.createElement(n.Select,s({},e,{\"aria-label\":e.label,options:V,onChange:function(t){e.onChange(t),t.value&&p(t.value)},isLoading:D,className:e.className||\"min-width-6\",onOpenMenu:function(){return e.fetch&&i(l,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:w(!0),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,i(l,void 0,void 0,(function(){var t;return r(this,(function(a){switch(a.label){case 0:return A?[2]:e.saveOptions?[4,e.saveOptions()]:[3,2];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,,4,5]),[4,e.fetch()];case 3:return t=a.sent(),v(t),[3,5];case 4:return S(!0),[7];case 5:return[2]}}))}))];case 2:return t.sent(),[3,4];case 3:return w(!1),[7];case 4:return[2]}}))}))},menuShouldPortal:!0}))))}(p=exports.FillValueOptions||(exports.FillValueOptions={}))[p.Previous=0]=\"Previous\",p[p.Null=1]=\"Null\",p[p.Value=2]=\"Value\";var g=[{label:\"Previous Value\",value:exports.FillValueOptions.Previous},{label:\"NULL\",value:exports.FillValueOptions.Null},{label:\"Value\",value:exports.FillValueOptions.Value}];function y(e){return\"string\"==typeof e?e:e.map((function(e){return function(e){return\"'\"+String(e).replace(/'/g,\"''\")+\"'\"}(e)})).join(\",\")}exports.ConfigSelect=function(e){var t=e.options.jsonData,n={title:t.defaultRegion?\"\":\"select a default region\",labelWidth:28,className:\"width-30\"},l=[e.options.jsonData.assumeRoleArn,e.options.jsonData.authType,e.options.jsonData.defaultRegion,e.options.jsonData.endpoint,e.options.jsonData.externalId,e.options.jsonData.profile].concat(e.dependencies);return a.createElement(m,s({label:e.label,\"data-testid\":e[\"data-testid\"],onChange:e.onChange,fetch:e.fetch,value:e.value,saveOptions:e.saveOptions,dependencies:l,hidden:e.hidden,disabled:e.disabled||!t.defaultRegion,allowCustomValue:e.allowCustomValue,autoFocus:e.autoFocus,backspaceRemovesValue:e.backspaceRemovesValue,className:e.className,invalid:e.invalid,isClearable:e.isClearable,isMulti:e.isMulti,inputId:e.inputId,showAllSelectedWhenOpen:e.showAllSelectedWhenOpen,maxMenuHeight:e.maxMenuHeight,minMenuHeight:e.minMenuHeight,maxVisibleValues:e.maxVisibleValues,menuPlacement:e.menuPlacement,menuPosition:e.menuPosition,noOptionsMessage:e.noOptionsMessage,onBlur:e.onBlur,onCreateOption:e.onCreateOption,onInputChange:e.onInputChange,placeholder:e.placeholder,width:e.width,isOptionDisabled:e.isOptionDisabled},n))},exports.ConnectionConfig=v,exports.FillValueSelect=function(e){var t,l,o;return a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:\"Fill value\",tooltip:\"value to fill missing points\"},a.createElement(n.Select,{\"aria-label\":\"Fill value\",options:g,value:null!==(l=null===(t=e.query.fillMode)||void 0===t?void 0:t.mode)&&void 0!==l?l:exports.FillValueOptions.Previous,onChange:function(t){var a=t.value;e.onChange(s(s({},e.query),{fillMode:s(s({},e.query.fillMode),{mode:a})})),e.onRunQuery()},className:\"width-12\",menuShouldPortal:!0})),(null===(o=e.query.fillMode)||void 0===o?void 0:o.mode)===exports.FillValueOptions.Value&&a.createElement(n.InlineField,{label:\"Value\",labelWidth:11},a.createElement(n.Input,{type:\"number\",\"aria-label\":\"Value\",value:e.query.fillMode.value,onChange:function(t){var a=t.currentTarget;return e.onChange(s(s({},e.query),{fillMode:{mode:exports.FillValueOptions.Value,value:a.valueAsNumber}}))},onBlur:function(){return e.onRunQuery()}})))},exports.FormatSelect=function(e){return a.createElement(n.InlineField,{label:\"Format as\",labelWidth:11},a.createElement(n.Select,{\"aria-label\":\"Format as\",options:e.options,value:e.query.format,onChange:function(t){e.onChange(s(s({},e.query),{format:t.value||0})),e.onRunQuery()},className:\"width-12\",menuShouldPortal:!0}))},exports.InlineInput=function(e){return a.createElement(n.InlineField,{label:e.label,labelWidth:28,tooltip:e.tooltip,hidden:e.hidden,disabled:e.disabled},a.createElement(n.Input,{\"data-testid\":e[\"data-testid\"],className:\"width-30\",value:e.value,onChange:e.onChange,placeholder:e.placeholder,disabled:e.disabled}))},exports.QueryCodeEditor=function(e){var l=e.getSuggestions,i=e.query,r=o.defaults(e.query,{rawSQL:\"\"}).rawSQL,u=t.useRef([]);return t.useEffect((function(){u.current=l(i)}),[l,i]),a.createElement(n.CodeEditor,s({language:e.language,value:r,onBlur:function(t){var a=s(s({},e.query),{rawSQL:t});e.onChange(a),e.onRunQuery()},showMiniMap:!1,showLineNumbers:!0,getSuggestions:function(){return u.current},height:\"240px\"},e.editorProps))},exports.ResourceSelector=m,exports.SIGV4ConnectionConfig=function(e){var t,n,l,o,i=e.onOptionsChange,r=e.options,u={onOptionsChange:function(e){var t,a,n,l,o=s(s({},r),{jsonData:s(s({},r.jsonData),{sigV4AuthType:e.jsonData.authType,sigV4Profile:e.jsonData.profile,sigV4AssumeRoleArn:e.jsonData.assumeRoleArn,sigV4ExternalId:e.jsonData.externalId,sigV4Region:e.jsonData.defaultRegion,sigV4Endpoint:e.jsonData.endpoint}),secureJsonFields:{sigV4AccessKey:null===(t=e.secureJsonFields)||void 0===t?void 0:t.accessKey,sigV4SecretKey:null===(a=e.secureJsonFields)||void 0===a?void 0:a.secretKey},secureJsonData:{sigV4AccessKey:null===(n=e.secureJsonData)||void 0===n?void 0:n.accessKey,sigV4SecretKey:null===(l=e.secureJsonData)||void 0===l?void 0:l.secretKey}});i(o)},options:s(s({},r),{jsonData:s(s({},r.jsonData),{authType:r.jsonData.sigV4AuthType,profile:r.jsonData.sigV4Profile,assumeRoleArn:r.jsonData.sigV4AssumeRoleArn,externalId:r.jsonData.sigV4ExternalId,defaultRegion:r.jsonData.sigV4Region,endpoint:r.jsonData.sigV4Endpoint}),secureJsonFields:{accessKey:null===(t=r.secureJsonFields)||void 0===t?void 0:t.sigV4AccessKey,secretKey:null===(n=r.secureJsonFields)||void 0===n?void 0:n.sigV4SecretKey},secureJsonData:{accessKey:null===(l=r.secureJsonData)||void 0===l?void 0:l.sigV4AccessKey,secretKey:null===(o=r.secureJsonData)||void 0===o?void 0:o.sigV4SecretKey}})};return a.createElement(a.Fragment,null,a.createElement(\"div\",{className:\"gf-form\"},a.createElement(\"h6\",null,\"SigV4 Auth Details\")),a.createElement(v,s({},u,{skipHeader:!0,skipEndpoint:!0})))},exports.appendTemplateVariablesAsSuggestions=function(e,t){var a=e(),l=[];return a.getVariables().forEach((function(e){var t=\"$\"+e.name,o=a.replace(t);o===t&&(o=\"\"),l.push({label:t,kind:n.CodeEditorSuggestionItemKind.Text,detail:\"(Template Variable) \"+o})})),t.concat(l)},exports.applySQLTemplateVariables=function(e,t,a){var n=a();return s(s({},e),{rawSQL:n.replace(e.rawSQL,t,y)})},exports.awsAuthProviderOptions=h,exports.filterSQLQuery=function(e){return!!e.rawSQL},exports.standardRegions=d;\n//# sourceMappingURL=index.production.js.map\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./dist/index.production.js');\n} else {\n module.exports = require('./dist/index.development.js');\n}\n","'use strict'\n\n// A linked list to keep track of recently-used-ness\nconst Yallist = require('yallist')\n\nconst MAX = Symbol('max')\nconst LENGTH = Symbol('length')\nconst LENGTH_CALCULATOR = Symbol('lengthCalculator')\nconst ALLOW_STALE = Symbol('allowStale')\nconst MAX_AGE = Symbol('maxAge')\nconst DISPOSE = Symbol('dispose')\nconst NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')\nconst LRU_LIST = Symbol('lruList')\nconst CACHE = Symbol('cache')\nconst UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')\n\nconst naiveLength = () => 1\n\n// lruList is a yallist where the head is the youngest\n// item, and the tail is the oldest. the list contains the Hit\n// objects as the entries.\n// Each Hit object has a reference to its Yallist.Node. This\n// never changes.\n//\n// cache is a Map (or PseudoMap) that matches the keys to\n// the Yallist.Node object.\nclass LRUCache {\n constructor (options) {\n if (typeof options === 'number')\n options = { max: options }\n\n if (!options)\n options = {}\n\n if (options.max && (typeof options.max !== 'number' || options.max < 0))\n throw new TypeError('max must be a non-negative number')\n // Kind of weird to have a default max of Infinity, but oh well.\n const max = this[MAX] = options.max || Infinity\n\n const lc = options.length || naiveLength\n this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc\n this[ALLOW_STALE] = options.stale || false\n if (options.maxAge && typeof options.maxAge !== 'number')\n throw new TypeError('maxAge must be a number')\n this[MAX_AGE] = options.maxAge || 0\n this[DISPOSE] = options.dispose\n this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false\n this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false\n this.reset()\n }\n\n // resize the cache when the max changes.\n set max (mL) {\n if (typeof mL !== 'number' || mL < 0)\n throw new TypeError('max must be a non-negative number')\n\n this[MAX] = mL || Infinity\n trim(this)\n }\n get max () {\n return this[MAX]\n }\n\n set allowStale (allowStale) {\n this[ALLOW_STALE] = !!allowStale\n }\n get allowStale () {\n return this[ALLOW_STALE]\n }\n\n set maxAge (mA) {\n if (typeof mA !== 'number')\n throw new TypeError('maxAge must be a non-negative number')\n\n this[MAX_AGE] = mA\n trim(this)\n }\n get maxAge () {\n return this[MAX_AGE]\n }\n\n // resize the cache when the lengthCalculator changes.\n set lengthCalculator (lC) {\n if (typeof lC !== 'function')\n lC = naiveLength\n\n if (lC !== this[LENGTH_CALCULATOR]) {\n this[LENGTH_CALCULATOR] = lC\n this[LENGTH] = 0\n this[LRU_LIST].forEach(hit => {\n hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)\n this[LENGTH] += hit.length\n })\n }\n trim(this)\n }\n get lengthCalculator () { return this[LENGTH_CALCULATOR] }\n\n get length () { return this[LENGTH] }\n get itemCount () { return this[LRU_LIST].length }\n\n rforEach (fn, thisp) {\n thisp = thisp || this\n for (let walker = this[LRU_LIST].tail; walker !== null;) {\n const prev = walker.prev\n forEachStep(this, fn, walker, thisp)\n walker = prev\n }\n }\n\n forEach (fn, thisp) {\n thisp = thisp || this\n for (let walker = this[LRU_LIST].head; walker !== null;) {\n const next = walker.next\n forEachStep(this, fn, walker, thisp)\n walker = next\n }\n }\n\n keys () {\n return this[LRU_LIST].toArray().map(k => k.key)\n }\n\n values () {\n return this[LRU_LIST].toArray().map(k => k.value)\n }\n\n reset () {\n if (this[DISPOSE] &&\n this[LRU_LIST] &&\n this[LRU_LIST].length) {\n this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))\n }\n\n this[CACHE] = new Map() // hash of items by key\n this[LRU_LIST] = new Yallist() // list of items in order of use recency\n this[LENGTH] = 0 // length of items in the list\n }\n\n dump () {\n return this[LRU_LIST].map(hit =>\n isStale(this, hit) ? false : {\n k: hit.key,\n v: hit.value,\n e: hit.now + (hit.maxAge || 0)\n }).toArray().filter(h => h)\n }\n\n dumpLru () {\n return this[LRU_LIST]\n }\n\n set (key, value, maxAge) {\n maxAge = maxAge || this[MAX_AGE]\n\n if (maxAge && typeof maxAge !== 'number')\n throw new TypeError('maxAge must be a number')\n\n const now = maxAge ? Date.now() : 0\n const len = this[LENGTH_CALCULATOR](value, key)\n\n if (this[CACHE].has(key)) {\n if (len > this[MAX]) {\n del(this, this[CACHE].get(key))\n return false\n }\n\n const node = this[CACHE].get(key)\n const item = node.value\n\n // dispose of the old one before overwriting\n // split out into 2 ifs for better coverage tracking\n if (this[DISPOSE]) {\n if (!this[NO_DISPOSE_ON_SET])\n this[DISPOSE](key, item.value)\n }\n\n item.now = now\n item.maxAge = maxAge\n item.value = value\n this[LENGTH] += len - item.length\n item.length = len\n this.get(key)\n trim(this)\n return true\n }\n\n const hit = new Entry(key, value, len, now, maxAge)\n\n // oversized objects fall out of cache automatically.\n if (hit.length > this[MAX]) {\n if (this[DISPOSE])\n this[DISPOSE](key, value)\n\n return false\n }\n\n this[LENGTH] += hit.length\n this[LRU_LIST].unshift(hit)\n this[CACHE].set(key, this[LRU_LIST].head)\n trim(this)\n return true\n }\n\n has (key) {\n if (!this[CACHE].has(key)) return false\n const hit = this[CACHE].get(key).value\n return !isStale(this, hit)\n }\n\n get (key) {\n return get(this, key, true)\n }\n\n peek (key) {\n return get(this, key, false)\n }\n\n pop () {\n const node = this[LRU_LIST].tail\n if (!node)\n return null\n\n del(this, node)\n return node.value\n }\n\n del (key) {\n del(this, this[CACHE].get(key))\n }\n\n load (arr) {\n // reset the cache\n this.reset()\n\n const now = Date.now()\n // A previous serialized cache has the most recent items first\n for (let l = arr.length - 1; l >= 0; l--) {\n const hit = arr[l]\n const expiresAt = hit.e || 0\n if (expiresAt === 0)\n // the item was created without expiration in a non aged cache\n this.set(hit.k, hit.v)\n else {\n const maxAge = expiresAt - now\n // dont add already expired items\n if (maxAge > 0) {\n this.set(hit.k, hit.v, maxAge)\n }\n }\n }\n }\n\n prune () {\n this[CACHE].forEach((value, key) => get(this, key, false))\n }\n}\n\nconst get = (self, key, doUse) => {\n const node = self[CACHE].get(key)\n if (node) {\n const hit = node.value\n if (isStale(self, hit)) {\n del(self, node)\n if (!self[ALLOW_STALE])\n return undefined\n } else {\n if (doUse) {\n if (self[UPDATE_AGE_ON_GET])\n node.value.now = Date.now()\n self[LRU_LIST].unshiftNode(node)\n }\n }\n return hit.value\n }\n}\n\nconst isStale = (self, hit) => {\n if (!hit || (!hit.maxAge && !self[MAX_AGE]))\n return false\n\n const diff = Date.now() - hit.now\n return hit.maxAge ? diff > hit.maxAge\n : self[MAX_AGE] && (diff > self[MAX_AGE])\n}\n\nconst trim = self => {\n if (self[LENGTH] > self[MAX]) {\n for (let walker = self[LRU_LIST].tail;\n self[LENGTH] > self[MAX] && walker !== null;) {\n // We know that we're about to delete this one, and also\n // what the next least recently used key will be, so just\n // go ahead and set it now.\n const prev = walker.prev\n del(self, walker)\n walker = prev\n }\n }\n}\n\nconst del = (self, node) => {\n if (node) {\n const hit = node.value\n if (self[DISPOSE])\n self[DISPOSE](hit.key, hit.value)\n\n self[LENGTH] -= hit.length\n self[CACHE].delete(hit.key)\n self[LRU_LIST].removeNode(node)\n }\n}\n\nclass Entry {\n constructor (key, value, length, now, maxAge) {\n this.key = key\n this.value = value\n this.length = length\n this.now = now\n this.maxAge = maxAge || 0\n }\n}\n\nconst forEachStep = (self, fn, node, thisp) => {\n let hit = node.value\n if (isStale(self, hit)) {\n del(self, node)\n if (!self[ALLOW_STALE])\n hit = undefined\n }\n if (hit)\n fn.call(thisp, hit.value, hit.key, self)\n}\n\nmodule.exports = LRUCache\n","const ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (!options || typeof options !== 'object') {\n options = {\n loose: !!options,\n includePrerelease: false,\n }\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n const sameDirectionIncreasing =\n (this.operator === '>=' || this.operator === '>') &&\n (comp.operator === '>=' || comp.operator === '>')\n const sameDirectionDecreasing =\n (this.operator === '<=' || this.operator === '<') &&\n (comp.operator === '<=' || comp.operator === '<')\n const sameSemVer = this.semver.version === comp.semver.version\n const differentDirectionsInclusive =\n (this.operator === '>=' || this.operator === '<=') &&\n (comp.operator === '>=' || comp.operator === '<=')\n const oppositeDirectionsLessThan =\n cmp(this.semver, '<', comp.semver, options) &&\n (this.operator === '>=' || this.operator === '>') &&\n (comp.operator === '<=' || comp.operator === '<')\n const oppositeDirectionsGreaterThan =\n cmp(this.semver, '>', comp.semver, options) &&\n (this.operator === '<=' || this.operator === '<') &&\n (comp.operator === '>=' || comp.operator === '>')\n\n return (\n sameDirectionIncreasing ||\n sameDirectionDecreasing ||\n (sameSemVer && differentDirectionsInclusive) ||\n oppositeDirectionsLessThan ||\n oppositeDirectionsGreaterThan\n )\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n","// hoisted class for cyclic dependency\nclass Range {\n constructor (range, options) {\n options = parseOptions(options)\n\n if (range instanceof Range) {\n if (\n range.loose === !!options.loose &&\n range.includePrerelease === !!options.includePrerelease\n ) {\n return range\n } else {\n return new Range(range.raw, options)\n }\n }\n\n if (range instanceof Comparator) {\n // just put it in the set and return\n this.raw = range.value\n this.set = [[range]]\n this.format()\n return this\n }\n\n this.options = options\n this.loose = !!options.loose\n this.includePrerelease = !!options.includePrerelease\n\n // First, split based on boolean or ||\n this.raw = range\n this.set = range\n .split('||')\n // map the range to a 2d array of comparators\n .map(r => this.parseRange(r.trim()))\n // throw out any comparator lists that are empty\n // this generally means that it was not a valid range, which is allowed\n // in loose mode, but will still throw if the WHOLE range is invalid.\n .filter(c => c.length)\n\n if (!this.set.length) {\n throw new TypeError(`Invalid SemVer Range: ${range}`)\n }\n\n // if we have any that are not the null set, throw out null sets.\n if (this.set.length > 1) {\n // keep the first one, in case they're all null sets\n const first = this.set[0]\n this.set = this.set.filter(c => !isNullSet(c[0]))\n if (this.set.length === 0) {\n this.set = [first]\n } else if (this.set.length > 1) {\n // if we have any that are *, then the range is just *\n for (const c of this.set) {\n if (c.length === 1 && isAny(c[0])) {\n this.set = [c]\n break\n }\n }\n }\n }\n\n this.format()\n }\n\n format () {\n this.range = this.set\n .map((comps) => {\n return comps.join(' ').trim()\n })\n .join('||')\n .trim()\n return this.range\n }\n\n toString () {\n return this.range\n }\n\n parseRange (range) {\n range = range.trim()\n\n // memoize range parsing for performance.\n // this is a very hot path, and fully deterministic.\n const memoOpts = Object.keys(this.options).join(',')\n const memoKey = `parseRange:${memoOpts}:${range}`\n const cached = cache.get(memoKey)\n if (cached) {\n return cached\n }\n\n const loose = this.options.loose\n // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n range = range.replace(hr, hyphenReplace(this.options.includePrerelease))\n debug('hyphen replace', range)\n // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n debug('comparator trim', range)\n\n // `~ 1.2.3` => `~1.2.3`\n range = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n\n // `^ 1.2.3` => `^1.2.3`\n range = range.replace(re[t.CARETTRIM], caretTrimReplace)\n\n // normalize spaces\n range = range.split(/\\s+/).join(' ')\n\n // At this point, the range is completely trimmed and\n // ready to be split into comparators.\n\n let rangeList = range\n .split(' ')\n .map(comp => parseComparator(comp, this.options))\n .join(' ')\n .split(/\\s+/)\n // >=0.0.0 is equivalent to *\n .map(comp => replaceGTE0(comp, this.options))\n\n if (loose) {\n // in loose mode, throw out any that are not valid comparators\n rangeList = rangeList.filter(comp => {\n debug('loose invalid filter', comp, this.options)\n return !!comp.match(re[t.COMPARATORLOOSE])\n })\n }\n debug('range list', rangeList)\n\n // if any comparators are the null set, then replace with JUST null set\n // if more than one comparator, remove any * comparators\n // also, don't include the same comparator more than once\n const rangeMap = new Map()\n const comparators = rangeList.map(comp => new Comparator(comp, this.options))\n for (const comp of comparators) {\n if (isNullSet(comp)) {\n return [comp]\n }\n rangeMap.set(comp.value, comp)\n }\n if (rangeMap.size > 1 && rangeMap.has('')) {\n rangeMap.delete('')\n }\n\n const result = [...rangeMap.values()]\n cache.set(memoKey, result)\n return result\n }\n\n intersects (range, options) {\n if (!(range instanceof Range)) {\n throw new TypeError('a Range is required')\n }\n\n return this.set.some((thisComparators) => {\n return (\n isSatisfiable(thisComparators, options) &&\n range.set.some((rangeComparators) => {\n return (\n isSatisfiable(rangeComparators, options) &&\n thisComparators.every((thisComparator) => {\n return rangeComparators.every((rangeComparator) => {\n return thisComparator.intersects(rangeComparator, options)\n })\n })\n )\n })\n )\n })\n }\n\n // if ANY of the sets match ALL of its comparators, then pass\n test (version) {\n if (!version) {\n return false\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n for (let i = 0; i < this.set.length; i++) {\n if (testSet(this.set[i], version, this.options)) {\n return true\n }\n }\n return false\n }\n}\nmodule.exports = Range\n\nconst LRU = require('lru-cache')\nconst cache = new LRU({ max: 1000 })\n\nconst parseOptions = require('../internal/parse-options')\nconst Comparator = require('./comparator')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst {\n re,\n t,\n comparatorTrimReplace,\n tildeTrimReplace,\n caretTrimReplace,\n} = require('../internal/re')\n\nconst isNullSet = c => c.value === '<0.0.0-0'\nconst isAny = c => c.value === ''\n\n// take a set of comparators and determine whether there\n// exists a version which can satisfy it\nconst isSatisfiable = (comparators, options) => {\n let result = true\n const remainingComparators = comparators.slice()\n let testComparator = remainingComparators.pop()\n\n while (result && remainingComparators.length) {\n result = remainingComparators.every((otherComparator) => {\n return testComparator.intersects(otherComparator, options)\n })\n\n testComparator = remainingComparators.pop()\n }\n\n return result\n}\n\n// comprised of xranges, tildes, stars, and gtlt's at this point.\n// already replaced the hyphen ranges\n// turn into a set of JUST comparators.\nconst parseComparator = (comp, options) => {\n debug('comp', comp, options)\n comp = replaceCarets(comp, options)\n debug('caret', comp)\n comp = replaceTildes(comp, options)\n debug('tildes', comp)\n comp = replaceXRanges(comp, options)\n debug('xrange', comp)\n comp = replaceStars(comp, options)\n debug('stars', comp)\n return comp\n}\n\nconst isX = id => !id || id.toLowerCase() === 'x' || id === '*'\n\n// ~, ~> --> * (any, kinda silly)\n// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0\n// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0\nconst replaceTildes = (comp, options) =>\n comp.trim().split(/\\s+/).map((c) => {\n return replaceTilde(c, options)\n }).join(' ')\n\nconst replaceTilde = (comp, options) => {\n const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('tilde', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n // ~1.2 == >=1.2.0 <1.3.0-0\n ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n } else if (pr) {\n debug('replaceTilde pr', pr)\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n } else {\n // ~1.2.3 == >=1.2.3 <1.3.0-0\n ret = `>=${M}.${m}.${p\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('tilde return', ret)\n return ret\n })\n}\n\n// ^ --> * (any, kinda silly)\n// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n// ^1.2.3 --> >=1.2.3 <2.0.0-0\n// ^1.2.0 --> >=1.2.0 <2.0.0-0\nconst replaceCarets = (comp, options) =>\n comp.trim().split(/\\s+/).map((c) => {\n return replaceCaret(c, options)\n }).join(' ')\n\nconst replaceCaret = (comp, options) => {\n debug('caret', comp, options)\n const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n const z = options.includePrerelease ? '-0' : ''\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('caret', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n if (M === '0') {\n ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n } else {\n ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n }\n } else if (pr) {\n debug('replaceCaret pr', pr)\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${+M + 1}.0.0-0`\n }\n } else {\n debug('no pr')\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p\n } <${+M + 1}.0.0-0`\n }\n }\n\n debug('caret return', ret)\n return ret\n })\n}\n\nconst replaceXRanges = (comp, options) => {\n debug('replaceXRanges', comp, options)\n return comp.split(/\\s+/).map((c) => {\n return replaceXRange(c, options)\n }).join(' ')\n}\n\nconst replaceXRange = (comp, options) => {\n comp = comp.trim()\n const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n return comp.replace(r, (ret, gtlt, M, m, p, pr) => {\n debug('xRange', comp, ret, gtlt, M, m, p, pr)\n const xM = isX(M)\n const xm = xM || isX(m)\n const xp = xm || isX(p)\n const anyX = xp\n\n if (gtlt === '=' && anyX) {\n gtlt = ''\n }\n\n // if we're including prereleases in the match, then we need\n // to fix this to -0, the lowest possible prerelease value\n pr = options.includePrerelease ? '-0' : ''\n\n if (xM) {\n if (gtlt === '>' || gtlt === '<') {\n // nothing is allowed\n ret = '<0.0.0-0'\n } else {\n // nothing is forbidden\n ret = '*'\n }\n } else if (gtlt && anyX) {\n // we know patch is an x, because we have any x at all.\n // replace X with 0\n if (xm) {\n m = 0\n }\n p = 0\n\n if (gtlt === '>') {\n // >1 => >=2.0.0\n // >1.2 => >=1.3.0\n gtlt = '>='\n if (xm) {\n M = +M + 1\n m = 0\n p = 0\n } else {\n m = +m + 1\n p = 0\n }\n } else if (gtlt === '<=') {\n // <=0.7.x is actually <0.8.0, since any 0.7.x should\n // pass. Similarly, <=7.x is actually <8.0.0, etc.\n gtlt = '<'\n if (xm) {\n M = +M + 1\n } else {\n m = +m + 1\n }\n }\n\n if (gtlt === '<') {\n pr = '-0'\n }\n\n ret = `${gtlt + M}.${m}.${p}${pr}`\n } else if (xm) {\n ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n } else if (xp) {\n ret = `>=${M}.${m}.0${pr\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('xRange return', ret)\n\n return ret\n })\n}\n\n// Because * is AND-ed with everything else in the comparator,\n// and '' means \"any version\", just remove the *s entirely.\nconst replaceStars = (comp, options) => {\n debug('replaceStars', comp, options)\n // Looseness is ignored here. star is always as loose as it gets!\n return comp.trim().replace(re[t.STAR], '')\n}\n\nconst replaceGTE0 = (comp, options) => {\n debug('replaceGTE0', comp, options)\n return comp.trim()\n .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n// This function is passed to string.replace(re[t.HYPHENRANGE])\n// M, m, patch, prerelease, build\n// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n// 1.2 - 3.4 => >=1.2.0 <3.5.0-0\nconst hyphenReplace = incPr => ($0,\n from, fM, fm, fp, fpr, fb,\n to, tM, tm, tp, tpr, tb) => {\n if (isX(fM)) {\n from = ''\n } else if (isX(fm)) {\n from = `>=${fM}.0.0${incPr ? '-0' : ''}`\n } else if (isX(fp)) {\n from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n } else if (fpr) {\n from = `>=${from}`\n } else {\n from = `>=${from}${incPr ? '-0' : ''}`\n }\n\n if (isX(tM)) {\n to = ''\n } else if (isX(tm)) {\n to = `<${+tM + 1}.0.0-0`\n } else if (isX(tp)) {\n to = `<${tM}.${+tm + 1}.0-0`\n } else if (tpr) {\n to = `<=${tM}.${tm}.${tp}-${tpr}`\n } else if (incPr) {\n to = `<${tM}.${tm}.${+tp + 1}-0`\n } else {\n to = `<=${to}`\n }\n\n return (`${from} ${to}`).trim()\n}\n\nconst testSet = (set, version, options) => {\n for (let i = 0; i < set.length; i++) {\n if (!set[i].test(version)) {\n return false\n }\n }\n\n if (version.prerelease.length && !options.includePrerelease) {\n // Find the set of versions that are allowed to have prereleases\n // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0\n // That should allow `1.2.3-pr.2` to pass.\n // However, `1.2.4-alpha.notready` should NOT be allowed,\n // even though it's within the range set by the comparators.\n for (let i = 0; i < set.length; i++) {\n debug(set[i].semver)\n if (set[i].semver === Comparator.ANY) {\n continue\n }\n\n if (set[i].semver.prerelease.length > 0) {\n const allowed = set[i].semver\n if (allowed.major === version.major &&\n allowed.minor === version.minor &&\n allowed.patch === version.patch) {\n return true\n }\n }\n }\n\n // Version has a -pre, but it's not one of the ones we like.\n return false\n }\n\n return true\n}\n","const debug = require('../internal/debug')\nconst { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')\nconst { re, t } = require('../internal/re')\n\nconst parseOptions = require('../internal/parse-options')\nconst { compareIdentifiers } = require('../internal/identifiers')\nclass SemVer {\n constructor (version, options) {\n options = parseOptions(options)\n\n if (version instanceof SemVer) {\n if (version.loose === !!options.loose &&\n version.includePrerelease === !!options.includePrerelease) {\n return version\n } else {\n version = version.version\n }\n } else if (typeof version !== 'string') {\n throw new TypeError(`Invalid Version: ${version}`)\n }\n\n if (version.length > MAX_LENGTH) {\n throw new TypeError(\n `version is longer than ${MAX_LENGTH} characters`\n )\n }\n\n debug('SemVer', version, options)\n this.options = options\n this.loose = !!options.loose\n // this isn't actually relevant for versions, but keep it so that we\n // don't run into trouble passing this.options around.\n this.includePrerelease = !!options.includePrerelease\n\n const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])\n\n if (!m) {\n throw new TypeError(`Invalid Version: ${version}`)\n }\n\n this.raw = version\n\n // these are actually numbers\n this.major = +m[1]\n this.minor = +m[2]\n this.patch = +m[3]\n\n if (this.major > MAX_SAFE_INTEGER || this.major < 0) {\n throw new TypeError('Invalid major version')\n }\n\n if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {\n throw new TypeError('Invalid minor version')\n }\n\n if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {\n throw new TypeError('Invalid patch version')\n }\n\n // numberify any prerelease numeric ids\n if (!m[4]) {\n this.prerelease = []\n } else {\n this.prerelease = m[4].split('.').map((id) => {\n if (/^[0-9]+$/.test(id)) {\n const num = +id\n if (num >= 0 && num < MAX_SAFE_INTEGER) {\n return num\n }\n }\n return id\n })\n }\n\n this.build = m[5] ? m[5].split('.') : []\n this.format()\n }\n\n format () {\n this.version = `${this.major}.${this.minor}.${this.patch}`\n if (this.prerelease.length) {\n this.version += `-${this.prerelease.join('.')}`\n }\n return this.version\n }\n\n toString () {\n return this.version\n }\n\n compare (other) {\n debug('SemVer.compare', this.version, this.options, other)\n if (!(other instanceof SemVer)) {\n if (typeof other === 'string' && other === this.version) {\n return 0\n }\n other = new SemVer(other, this.options)\n }\n\n if (other.version === this.version) {\n return 0\n }\n\n return this.compareMain(other) || this.comparePre(other)\n }\n\n compareMain (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n return (\n compareIdentifiers(this.major, other.major) ||\n compareIdentifiers(this.minor, other.minor) ||\n compareIdentifiers(this.patch, other.patch)\n )\n }\n\n comparePre (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n // NOT having a prerelease is > having one\n if (this.prerelease.length && !other.prerelease.length) {\n return -1\n } else if (!this.prerelease.length && other.prerelease.length) {\n return 1\n } else if (!this.prerelease.length && !other.prerelease.length) {\n return 0\n }\n\n let i = 0\n do {\n const a = this.prerelease[i]\n const b = other.prerelease[i]\n debug('prerelease compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n compareBuild (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n let i = 0\n do {\n const a = this.build[i]\n const b = other.build[i]\n debug('prerelease compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n // preminor will bump the version up to the next minor release, and immediately\n // down to pre-release. premajor and prepatch work the same way.\n inc (release, identifier) {\n switch (release) {\n case 'premajor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', identifier)\n break\n case 'preminor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor++\n this.inc('pre', identifier)\n break\n case 'prepatch':\n // If this is already a prerelease, it will bump to the next version\n // drop any prereleases that might already exist, since they are not\n // relevant at this point.\n this.prerelease.length = 0\n this.inc('patch', identifier)\n this.inc('pre', identifier)\n break\n // If the input is a non-prerelease version, this acts the same as\n // prepatch.\n case 'prerelease':\n if (this.prerelease.length === 0) {\n this.inc('patch', identifier)\n }\n this.inc('pre', identifier)\n break\n\n case 'major':\n // If this is a pre-major version, bump up to the same major version.\n // Otherwise increment major.\n // 1.0.0-5 bumps to 1.0.0\n // 1.1.0 bumps to 2.0.0\n if (\n this.minor !== 0 ||\n this.patch !== 0 ||\n this.prerelease.length === 0\n ) {\n this.major++\n }\n this.minor = 0\n this.patch = 0\n this.prerelease = []\n break\n case 'minor':\n // If this is a pre-minor version, bump up to the same minor version.\n // Otherwise increment minor.\n // 1.2.0-5 bumps to 1.2.0\n // 1.2.1 bumps to 1.3.0\n if (this.patch !== 0 || this.prerelease.length === 0) {\n this.minor++\n }\n this.patch = 0\n this.prerelease = []\n break\n case 'patch':\n // If this is not a pre-release version, it will increment the patch.\n // If it is a pre-release it will bump up to the same patch version.\n // 1.2.0-5 patches to 1.2.0\n // 1.2.0 patches to 1.2.1\n if (this.prerelease.length === 0) {\n this.patch++\n }\n this.prerelease = []\n break\n // This probably shouldn't be used publicly.\n // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.\n case 'pre':\n if (this.prerelease.length === 0) {\n this.prerelease = [0]\n } else {\n let i = this.prerelease.length\n while (--i >= 0) {\n if (typeof this.prerelease[i] === 'number') {\n this.prerelease[i]++\n i = -2\n }\n }\n if (i === -1) {\n // didn't increment anything\n this.prerelease.push(0)\n }\n }\n if (identifier) {\n // 1.2.0-beta.1 bumps to 1.2.0-beta.2,\n // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0\n if (compareIdentifiers(this.prerelease[0], identifier) === 0) {\n if (isNaN(this.prerelease[1])) {\n this.prerelease = [identifier, 0]\n }\n } else {\n this.prerelease = [identifier, 0]\n }\n }\n break\n\n default:\n throw new Error(`invalid increment argument: ${release}`)\n }\n this.format()\n this.raw = this.version\n return this\n }\n}\n\nmodule.exports = SemVer\n","const parse = require('./parse')\nconst clean = (version, options) => {\n const s = parse(version.trim().replace(/^[=v]+/, ''), options)\n return s ? s.version : null\n}\nmodule.exports = clean\n","const eq = require('./eq')\nconst neq = require('./neq')\nconst gt = require('./gt')\nconst gte = require('./gte')\nconst lt = require('./lt')\nconst lte = require('./lte')\n\nconst cmp = (a, op, b, loose) => {\n switch (op) {\n case '===':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a === b\n\n case '!==':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a !== b\n\n case '':\n case '=':\n case '==':\n return eq(a, b, loose)\n\n case '!=':\n return neq(a, b, loose)\n\n case '>':\n return gt(a, b, loose)\n\n case '>=':\n return gte(a, b, loose)\n\n case '<':\n return lt(a, b, loose)\n\n case '<=':\n return lte(a, b, loose)\n\n default:\n throw new TypeError(`Invalid operator: ${op}`)\n }\n}\nmodule.exports = cmp\n","const SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version === 'number') {\n version = String(version)\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n options = options || {}\n\n let match = null\n if (!options.rtl) {\n match = version.match(re[t.COERCE])\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n let next\n while ((next = re[t.COERCERTL].exec(version)) &&\n (!match || match.index + match[0].length !== version.length)\n ) {\n if (!match ||\n next.index + next[0].length !== match.index + match[0].length) {\n match = next\n }\n re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length\n }\n // leave it in a clean state\n re[t.COERCERTL].lastIndex = -1\n }\n\n if (match === null) {\n return null\n }\n\n return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)\n}\nmodule.exports = coerce\n","const SemVer = require('../classes/semver')\nconst compareBuild = (a, b, loose) => {\n const versionA = new SemVer(a, loose)\n const versionB = new SemVer(b, loose)\n return versionA.compare(versionB) || versionA.compareBuild(versionB)\n}\nmodule.exports = compareBuild\n","const compare = require('./compare')\nconst compareLoose = (a, b) => compare(a, b, true)\nmodule.exports = compareLoose\n","const SemVer = require('../classes/semver')\nconst compare = (a, b, loose) =>\n new SemVer(a, loose).compare(new SemVer(b, loose))\n\nmodule.exports = compare\n","const parse = require('./parse')\nconst eq = require('./eq')\n\nconst diff = (version1, version2) => {\n if (eq(version1, version2)) {\n return null\n } else {\n const v1 = parse(version1)\n const v2 = parse(version2)\n const hasPre = v1.prerelease.length || v2.prerelease.length\n const prefix = hasPre ? 'pre' : ''\n const defaultResult = hasPre ? 'prerelease' : ''\n for (const key in v1) {\n if (key === 'major' || key === 'minor' || key === 'patch') {\n if (v1[key] !== v2[key]) {\n return prefix + key\n }\n }\n }\n return defaultResult // may be undefined\n }\n}\nmodule.exports = diff\n","const compare = require('./compare')\nconst eq = (a, b, loose) => compare(a, b, loose) === 0\nmodule.exports = eq\n","const compare = require('./compare')\nconst gt = (a, b, loose) => compare(a, b, loose) > 0\nmodule.exports = gt\n","const compare = require('./compare')\nconst gte = (a, b, loose) => compare(a, b, loose) >= 0\nmodule.exports = gte\n","const SemVer = require('../classes/semver')\n\nconst inc = (version, release, options, identifier) => {\n if (typeof (options) === 'string') {\n identifier = options\n options = undefined\n }\n\n try {\n return new SemVer(\n version instanceof SemVer ? version.version : version,\n options\n ).inc(release, identifier).version\n } catch (er) {\n return null\n }\n}\nmodule.exports = inc\n","const compare = require('./compare')\nconst lt = (a, b, loose) => compare(a, b, loose) < 0\nmodule.exports = lt\n","const compare = require('./compare')\nconst lte = (a, b, loose) => compare(a, b, loose) <= 0\nmodule.exports = lte\n","const SemVer = require('../classes/semver')\nconst major = (a, loose) => new SemVer(a, loose).major\nmodule.exports = major\n","const SemVer = require('../classes/semver')\nconst minor = (a, loose) => new SemVer(a, loose).minor\nmodule.exports = minor\n","const compare = require('./compare')\nconst neq = (a, b, loose) => compare(a, b, loose) !== 0\nmodule.exports = neq\n","const { MAX_LENGTH } = require('../internal/constants')\nconst { re, t } = require('../internal/re')\nconst SemVer = require('../classes/semver')\n\nconst parseOptions = require('../internal/parse-options')\nconst parse = (version, options) => {\n options = parseOptions(options)\n\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n if (version.length > MAX_LENGTH) {\n return null\n }\n\n const r = options.loose ? re[t.LOOSE] : re[t.FULL]\n if (!r.test(version)) {\n return null\n }\n\n try {\n return new SemVer(version, options)\n } catch (er) {\n return null\n }\n}\n\nmodule.exports = parse\n","const SemVer = require('../classes/semver')\nconst patch = (a, loose) => new SemVer(a, loose).patch\nmodule.exports = patch\n","const parse = require('./parse')\nconst prerelease = (version, options) => {\n const parsed = parse(version, options)\n return (parsed && parsed.prerelease.length) ? parsed.prerelease : null\n}\nmodule.exports = prerelease\n","const compare = require('./compare')\nconst rcompare = (a, b, loose) => compare(b, a, loose)\nmodule.exports = rcompare\n","const compareBuild = require('./compare-build')\nconst rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))\nmodule.exports = rsort\n","const Range = require('../classes/range')\nconst satisfies = (version, range, options) => {\n try {\n range = new Range(range, options)\n } catch (er) {\n return false\n }\n return range.test(version)\n}\nmodule.exports = satisfies\n","const compareBuild = require('./compare-build')\nconst sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))\nmodule.exports = sort\n","const parse = require('./parse')\nconst valid = (version, options) => {\n const v = parse(version, options)\n return v ? v.version : null\n}\nmodule.exports = valid\n","// just pre-load all the stuff that index.js lazily exports\nconst internalRe = require('./internal/re')\nmodule.exports = {\n re: internalRe.re,\n src: internalRe.src,\n tokens: internalRe.t,\n SEMVER_SPEC_VERSION: require('./internal/constants').SEMVER_SPEC_VERSION,\n SemVer: require('./classes/semver'),\n compareIdentifiers: require('./internal/identifiers').compareIdentifiers,\n rcompareIdentifiers: require('./internal/identifiers').rcompareIdentifiers,\n parse: require('./functions/parse'),\n valid: require('./functions/valid'),\n clean: require('./functions/clean'),\n inc: require('./functions/inc'),\n diff: require('./functions/diff'),\n major: require('./functions/major'),\n minor: require('./functions/minor'),\n patch: require('./functions/patch'),\n prerelease: require('./functions/prerelease'),\n compare: require('./functions/compare'),\n rcompare: require('./functions/rcompare'),\n compareLoose: require('./functions/compare-loose'),\n compareBuild: require('./functions/compare-build'),\n sort: require('./functions/sort'),\n rsort: require('./functions/rsort'),\n gt: require('./functions/gt'),\n lt: require('./functions/lt'),\n eq: require('./functions/eq'),\n neq: require('./functions/neq'),\n gte: require('./functions/gte'),\n lte: require('./functions/lte'),\n cmp: require('./functions/cmp'),\n coerce: require('./functions/coerce'),\n Comparator: require('./classes/comparator'),\n Range: require('./classes/range'),\n satisfies: require('./functions/satisfies'),\n toComparators: require('./ranges/to-comparators'),\n maxSatisfying: require('./ranges/max-satisfying'),\n minSatisfying: require('./ranges/min-satisfying'),\n minVersion: require('./ranges/min-version'),\n validRange: require('./ranges/valid'),\n outside: require('./ranges/outside'),\n gtr: require('./ranges/gtr'),\n ltr: require('./ranges/ltr'),\n intersects: require('./ranges/intersects'),\n simplifyRange: require('./ranges/simplify'),\n subset: require('./ranges/subset'),\n}\n","// Note: this is the semver.org version of the spec that it implements\n// Not necessarily the package version of this code.\nconst SEMVER_SPEC_VERSION = '2.0.0'\n\nconst MAX_LENGTH = 256\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||\n/* istanbul ignore next */ 9007199254740991\n\n// Max safe segment length for coercion.\nconst MAX_SAFE_COMPONENT_LENGTH = 16\n\nmodule.exports = {\n SEMVER_SPEC_VERSION,\n MAX_LENGTH,\n MAX_SAFE_INTEGER,\n MAX_SAFE_COMPONENT_LENGTH,\n}\n","const debug = (\n typeof process === 'object' &&\n process.env &&\n process.env.NODE_DEBUG &&\n /\\bsemver\\b/i.test(process.env.NODE_DEBUG)\n) ? (...args) => console.error('SEMVER', ...args)\n : () => {}\n\nmodule.exports = debug\n","const numeric = /^[0-9]+$/\nconst compareIdentifiers = (a, b) => {\n const anum = numeric.test(a)\n const bnum = numeric.test(b)\n\n if (anum && bnum) {\n a = +a\n b = +b\n }\n\n return a === b ? 0\n : (anum && !bnum) ? -1\n : (bnum && !anum) ? 1\n : a < b ? -1\n : 1\n}\n\nconst rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)\n\nmodule.exports = {\n compareIdentifiers,\n rcompareIdentifiers,\n}\n","// parse out just the options we care about so we always get a consistent\n// obj with keys in a consistent order.\nconst opts = ['includePrerelease', 'loose', 'rtl']\nconst parseOptions = options =>\n !options ? {}\n : typeof options !== 'object' ? { loose: true }\n : opts.filter(k => options[k]).reduce((o, k) => {\n o[k] = true\n return o\n }, {})\nmodule.exports = parseOptions\n","const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')\nconst debug = require('./debug')\nexports = module.exports = {}\n\n// The actual regexps go on exports.re\nconst re = exports.re = []\nconst src = exports.src = []\nconst t = exports.t = {}\nlet R = 0\n\nconst createToken = (name, value, isGlobal) => {\n const index = R++\n debug(name, index, value)\n t[name] = index\n src[index] = value\n re[index] = new RegExp(value, isGlobal ? 'g' : undefined)\n}\n\n// The following Regular Expressions can be used for tokenizing,\n// validating, and parsing SemVer version strings.\n\n// ## Numeric Identifier\n// A single `0`, or a non-zero digit followed by zero or more digits.\n\ncreateToken('NUMERICIDENTIFIER', '0|[1-9]\\\\d*')\ncreateToken('NUMERICIDENTIFIERLOOSE', '[0-9]+')\n\n// ## Non-numeric Identifier\n// Zero or more digits, followed by a letter or hyphen, and then zero or\n// more letters, digits, or hyphens.\n\ncreateToken('NONNUMERICIDENTIFIER', '\\\\d*[a-zA-Z-][a-zA-Z0-9-]*')\n\n// ## Main Version\n// Three dot-separated numeric identifiers.\n\ncreateToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version Identifier\n// A numeric identifier, or a non-numeric identifier.\n\ncreateToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]\n}|${src[t.NONNUMERICIDENTIFIER]})`)\n\ncreateToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]\n}|${src[t.NONNUMERICIDENTIFIER]})`)\n\n// ## Pre-release Version\n// Hyphen, followed by one or more dot-separated pre-release version\n// identifiers.\n\ncreateToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIER]})*))`)\n\ncreateToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)\n\n// ## Build Metadata Identifier\n// Any combination of digits, letters, or hyphens.\n\ncreateToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+')\n\n// ## Build Metadata\n// Plus sign, followed by one or more period-separated build metadata\n// identifiers.\n\ncreateToken('BUILD', `(?:\\\\+(${src[t.BUILDIDENTIFIER]\n}(?:\\\\.${src[t.BUILDIDENTIFIER]})*))`)\n\n// ## Full Version String\n// A main version, followed optionally by a pre-release version and\n// build metadata.\n\n// Note that the only major, minor, patch, and pre-release sections of\n// the version string are capturing groups. The build metadata is not a\n// capturing group, because it should not ever be used in version\n// comparison.\n\ncreateToken('FULLPLAIN', `v?${src[t.MAINVERSION]\n}${src[t.PRERELEASE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('FULL', `^${src[t.FULLPLAIN]}$`)\n\n// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.\n// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty\n// common in the npm registry.\ncreateToken('LOOSEPLAIN', `[v=\\\\s]*${src[t.MAINVERSIONLOOSE]\n}${src[t.PRERELEASELOOSE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)\n\ncreateToken('GTLT', '((?:<|>)?=?)')\n\n// Something like \"2.*\" or \"1.2.x\".\n// Note that \"x.x\" is a valid xRange identifer, meaning \"any version\"\n// Only the first item is strictly required.\ncreateToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`)\ncreateToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\\\*`)\n\ncreateToken('XRANGEPLAIN', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:${src[t.PRERELEASE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGEPLAINLOOSE', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:${src[t.PRERELEASELOOSE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAIN]}$`)\ncreateToken('XRANGELOOSE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Coercion.\n// Extract anything that could conceivably be a part of a valid semver\ncreateToken('COERCE', `${'(^|[^\\\\d])' +\n '(\\\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +\n `(?:$|[^\\\\d])`)\ncreateToken('COERCERTL', src[t.COERCE], true)\n\n// Tilde ranges.\n// Meaning is \"reasonably at or greater than\"\ncreateToken('LONETILDE', '(?:~>?)')\n\ncreateToken('TILDETRIM', `(\\\\s*)${src[t.LONETILDE]}\\\\s+`, true)\nexports.tildeTrimReplace = '$1~'\n\ncreateToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Caret ranges.\n// Meaning is \"at least and backwards compatible with\"\ncreateToken('LONECARET', '(?:\\\\^)')\n\ncreateToken('CARETTRIM', `(\\\\s*)${src[t.LONECARET]}\\\\s+`, true)\nexports.caretTrimReplace = '$1^'\n\ncreateToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// A simple gt/lt/eq thing, or just \"\" to indicate \"any version\"\ncreateToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\\\s*(${src[t.LOOSEPLAIN]})$|^$`)\ncreateToken('COMPARATOR', `^${src[t.GTLT]}\\\\s*(${src[t.FULLPLAIN]})$|^$`)\n\n// An expression to strip any whitespace between the gtlt and the thing\n// it modifies, so that `> 1.2.3` ==> `>1.2.3`\ncreateToken('COMPARATORTRIM', `(\\\\s*)${src[t.GTLT]\n}\\\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)\nexports.comparatorTrimReplace = '$1$2$3'\n\n// Something like `1.2.3 - 1.2.4`\n// Note that these all use the loose form, because they'll be\n// checked against either the strict or loose comparator form\n// later.\ncreateToken('HYPHENRANGE', `^\\\\s*(${src[t.XRANGEPLAIN]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAIN]})` +\n `\\\\s*$`)\n\ncreateToken('HYPHENRANGELOOSE', `^\\\\s*(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s*$`)\n\n// Star ranges basically just allow anything at all.\ncreateToken('STAR', '(<|>)?=?\\\\s*\\\\*')\n// >=0.0.0 is like a star\ncreateToken('GTE0', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$')\ncreateToken('GTE0PRE', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$')\n","// Determine if version is greater than all the versions possible in the range.\nconst outside = require('./outside')\nconst gtr = (version, range, options) => outside(version, range, '>', options)\nmodule.exports = gtr\n","const Range = require('../classes/range')\nconst intersects = (r1, r2, options) => {\n r1 = new Range(r1, options)\n r2 = new Range(r2, options)\n return r1.intersects(r2)\n}\nmodule.exports = intersects\n","const outside = require('./outside')\n// Determine if version is less than all the versions possible in the range\nconst ltr = (version, range, options) => outside(version, range, '<', options)\nmodule.exports = ltr\n","const SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\n\nconst maxSatisfying = (versions, range, options) => {\n let max = null\n let maxSV = null\n let rangeObj = null\n try {\n rangeObj = new Range(range, options)\n } catch (er) {\n return null\n }\n versions.forEach((v) => {\n if (rangeObj.test(v)) {\n // satisfies(v, range, options)\n if (!max || maxSV.compare(v) === -1) {\n // compare(max, v, true)\n max = v\n maxSV = new SemVer(max, options)\n }\n }\n })\n return max\n}\nmodule.exports = maxSatisfying\n","const SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\nconst minSatisfying = (versions, range, options) => {\n let min = null\n let minSV = null\n let rangeObj = null\n try {\n rangeObj = new Range(range, options)\n } catch (er) {\n return null\n }\n versions.forEach((v) => {\n if (rangeObj.test(v)) {\n // satisfies(v, range, options)\n if (!min || minSV.compare(v) === 1) {\n // compare(min, v, true)\n min = v\n minSV = new SemVer(min, options)\n }\n }\n })\n return min\n}\nmodule.exports = minSatisfying\n","const SemVer = require('../classes/semver')\nconst Range = require('../classes/range')\nconst gt = require('../functions/gt')\n\nconst minVersion = (range, loose) => {\n range = new Range(range, loose)\n\n let minver = new SemVer('0.0.0')\n if (range.test(minver)) {\n return minver\n }\n\n minver = new SemVer('0.0.0-0')\n if (range.test(minver)) {\n return minver\n }\n\n minver = null\n for (let i = 0; i < range.set.length; ++i) {\n const comparators = range.set[i]\n\n let setMin = null\n comparators.forEach((comparator) => {\n // Clone to avoid manipulating the comparator's semver object.\n const compver = new SemVer(comparator.semver.version)\n switch (comparator.operator) {\n case '>':\n if (compver.prerelease.length === 0) {\n compver.patch++\n } else {\n compver.prerelease.push(0)\n }\n compver.raw = compver.format()\n /* fallthrough */\n case '':\n case '>=':\n if (!setMin || gt(compver, setMin)) {\n setMin = compver\n }\n break\n case '<':\n case '<=':\n /* Ignore maximum versions */\n break\n /* istanbul ignore next */\n default:\n throw new Error(`Unexpected operation: ${comparator.operator}`)\n }\n })\n if (setMin && (!minver || gt(minver, setMin))) {\n minver = setMin\n }\n }\n\n if (minver && range.test(minver)) {\n return minver\n }\n\n return null\n}\nmodule.exports = minVersion\n","const SemVer = require('../classes/semver')\nconst Comparator = require('../classes/comparator')\nconst { ANY } = Comparator\nconst Range = require('../classes/range')\nconst satisfies = require('../functions/satisfies')\nconst gt = require('../functions/gt')\nconst lt = require('../functions/lt')\nconst lte = require('../functions/lte')\nconst gte = require('../functions/gte')\n\nconst outside = (version, range, hilo, options) => {\n version = new SemVer(version, options)\n range = new Range(range, options)\n\n let gtfn, ltefn, ltfn, comp, ecomp\n switch (hilo) {\n case '>':\n gtfn = gt\n ltefn = lte\n ltfn = lt\n comp = '>'\n ecomp = '>='\n break\n case '<':\n gtfn = lt\n ltefn = gte\n ltfn = gt\n comp = '<'\n ecomp = '<='\n break\n default:\n throw new TypeError('Must provide a hilo val of \"<\" or \">\"')\n }\n\n // If it satisfies the range it is not outside\n if (satisfies(version, range, options)) {\n return false\n }\n\n // From now on, variable terms are as if we're in \"gtr\" mode.\n // but note that everything is flipped for the \"ltr\" function.\n\n for (let i = 0; i < range.set.length; ++i) {\n const comparators = range.set[i]\n\n let high = null\n let low = null\n\n comparators.forEach((comparator) => {\n if (comparator.semver === ANY) {\n comparator = new Comparator('>=0.0.0')\n }\n high = high || comparator\n low = low || comparator\n if (gtfn(comparator.semver, high.semver, options)) {\n high = comparator\n } else if (ltfn(comparator.semver, low.semver, options)) {\n low = comparator\n }\n })\n\n // If the edge version comparator has a operator then our version\n // isn't outside it\n if (high.operator === comp || high.operator === ecomp) {\n return false\n }\n\n // If the lowest version comparator has an operator and our version\n // is less than it then it isn't higher than the range\n if ((!low.operator || low.operator === comp) &&\n ltefn(version, low.semver)) {\n return false\n } else if (low.operator === ecomp && ltfn(version, low.semver)) {\n return false\n }\n }\n return true\n}\n\nmodule.exports = outside\n","// given a set of versions and a range, create a \"simplified\" range\n// that includes the same versions that the original range does\n// If the original range is shorter than the simplified one, return that.\nconst satisfies = require('../functions/satisfies.js')\nconst compare = require('../functions/compare.js')\nmodule.exports = (versions, range, options) => {\n const set = []\n let first = null\n let prev = null\n const v = versions.sort((a, b) => compare(a, b, options))\n for (const version of v) {\n const included = satisfies(version, range, options)\n if (included) {\n prev = version\n if (!first) {\n first = version\n }\n } else {\n if (prev) {\n set.push([first, prev])\n }\n prev = null\n first = null\n }\n }\n if (first) {\n set.push([first, null])\n }\n\n const ranges = []\n for (const [min, max] of set) {\n if (min === max) {\n ranges.push(min)\n } else if (!max && min === v[0]) {\n ranges.push('*')\n } else if (!max) {\n ranges.push(`>=${min}`)\n } else if (min === v[0]) {\n ranges.push(`<=${max}`)\n } else {\n ranges.push(`${min} - ${max}`)\n }\n }\n const simplified = ranges.join(' || ')\n const original = typeof range.raw === 'string' ? range.raw : String(range)\n return simplified.length < original.length ? simplified : range\n}\n","const Range = require('../classes/range.js')\nconst Comparator = require('../classes/comparator.js')\nconst { ANY } = Comparator\nconst satisfies = require('../functions/satisfies.js')\nconst compare = require('../functions/compare.js')\n\n// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:\n// - Every simple range `r1, r2, ...` is a null set, OR\n// - Every simple range `r1, r2, ...` which is not a null set is a subset of\n// some `R1, R2, ...`\n//\n// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:\n// - If c is only the ANY comparator\n// - If C is only the ANY comparator, return true\n// - Else if in prerelease mode, return false\n// - else replace c with `[>=0.0.0]`\n// - If C is only the ANY comparator\n// - if in prerelease mode, return true\n// - else replace C with `[>=0.0.0]`\n// - Let EQ be the set of = comparators in c\n// - If EQ is more than one, return true (null set)\n// - Let GT be the highest > or >= comparator in c\n// - Let LT be the lowest < or <= comparator in c\n// - If GT and LT, and GT.semver > LT.semver, return true (null set)\n// - If any C is a = range, and GT or LT are set, return false\n// - If EQ\n// - If GT, and EQ does not satisfy GT, return true (null set)\n// - If LT, and EQ does not satisfy LT, return true (null set)\n// - If EQ satisfies every C, return true\n// - Else return false\n// - If GT\n// - If GT.semver is lower than any > or >= comp in C, return false\n// - If GT is >=, and GT.semver does not satisfy every C, return false\n// - If GT.semver has a prerelease, and not in prerelease mode\n// - If no C has a prerelease and the GT.semver tuple, return false\n// - If LT\n// - If LT.semver is greater than any < or <= comp in C, return false\n// - If LT is <=, and LT.semver does not satisfy every C, return false\n// - If GT.semver has a prerelease, and not in prerelease mode\n// - If no C has a prerelease and the LT.semver tuple, return false\n// - Else return true\n\nconst subset = (sub, dom, options = {}) => {\n if (sub === dom) {\n return true\n }\n\n sub = new Range(sub, options)\n dom = new Range(dom, options)\n let sawNonNull = false\n\n OUTER: for (const simpleSub of sub.set) {\n for (const simpleDom of dom.set) {\n const isSub = simpleSubset(simpleSub, simpleDom, options)\n sawNonNull = sawNonNull || isSub !== null\n if (isSub) {\n continue OUTER\n }\n }\n // the null set is a subset of everything, but null simple ranges in\n // a complex range should be ignored. so if we saw a non-null range,\n // then we know this isn't a subset, but if EVERY simple range was null,\n // then it is a subset.\n if (sawNonNull) {\n return false\n }\n }\n return true\n}\n\nconst simpleSubset = (sub, dom, options) => {\n if (sub === dom) {\n return true\n }\n\n if (sub.length === 1 && sub[0].semver === ANY) {\n if (dom.length === 1 && dom[0].semver === ANY) {\n return true\n } else if (options.includePrerelease) {\n sub = [new Comparator('>=0.0.0-0')]\n } else {\n sub = [new Comparator('>=0.0.0')]\n }\n }\n\n if (dom.length === 1 && dom[0].semver === ANY) {\n if (options.includePrerelease) {\n return true\n } else {\n dom = [new Comparator('>=0.0.0')]\n }\n }\n\n const eqSet = new Set()\n let gt, lt\n for (const c of sub) {\n if (c.operator === '>' || c.operator === '>=') {\n gt = higherGT(gt, c, options)\n } else if (c.operator === '<' || c.operator === '<=') {\n lt = lowerLT(lt, c, options)\n } else {\n eqSet.add(c.semver)\n }\n }\n\n if (eqSet.size > 1) {\n return null\n }\n\n let gtltComp\n if (gt && lt) {\n gtltComp = compare(gt.semver, lt.semver, options)\n if (gtltComp > 0) {\n return null\n } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {\n return null\n }\n }\n\n // will iterate one or zero times\n for (const eq of eqSet) {\n if (gt && !satisfies(eq, String(gt), options)) {\n return null\n }\n\n if (lt && !satisfies(eq, String(lt), options)) {\n return null\n }\n\n for (const c of dom) {\n if (!satisfies(eq, String(c), options)) {\n return false\n }\n }\n\n return true\n }\n\n let higher, lower\n let hasDomLT, hasDomGT\n // if the subset has a prerelease, we need a comparator in the superset\n // with the same tuple and a prerelease, or it's not a subset\n let needDomLTPre = lt &&\n !options.includePrerelease &&\n lt.semver.prerelease.length ? lt.semver : false\n let needDomGTPre = gt &&\n !options.includePrerelease &&\n gt.semver.prerelease.length ? gt.semver : false\n // exception: <1.2.3-0 is the same as <1.2.3\n if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&\n lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {\n needDomLTPre = false\n }\n\n for (const c of dom) {\n hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='\n hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='\n if (gt) {\n if (needDomGTPre) {\n if (c.semver.prerelease && c.semver.prerelease.length &&\n c.semver.major === needDomGTPre.major &&\n c.semver.minor === needDomGTPre.minor &&\n c.semver.patch === needDomGTPre.patch) {\n needDomGTPre = false\n }\n }\n if (c.operator === '>' || c.operator === '>=') {\n higher = higherGT(gt, c, options)\n if (higher === c && higher !== gt) {\n return false\n }\n } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {\n return false\n }\n }\n if (lt) {\n if (needDomLTPre) {\n if (c.semver.prerelease && c.semver.prerelease.length &&\n c.semver.major === needDomLTPre.major &&\n c.semver.minor === needDomLTPre.minor &&\n c.semver.patch === needDomLTPre.patch) {\n needDomLTPre = false\n }\n }\n if (c.operator === '<' || c.operator === '<=') {\n lower = lowerLT(lt, c, options)\n if (lower === c && lower !== lt) {\n return false\n }\n } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {\n return false\n }\n }\n if (!c.operator && (lt || gt) && gtltComp !== 0) {\n return false\n }\n }\n\n // if there was a < or >, and nothing in the dom, then must be false\n // UNLESS it was limited by another range in the other direction.\n // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0\n if (gt && hasDomLT && !lt && gtltComp !== 0) {\n return false\n }\n\n if (lt && hasDomGT && !gt && gtltComp !== 0) {\n return false\n }\n\n // we needed a prerelease range in a specific tuple, but didn't get one\n // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,\n // because it includes prereleases in the 1.2.3 tuple\n if (needDomGTPre || needDomLTPre) {\n return false\n }\n\n return true\n}\n\n// >=1.2.3 is lower than >1.2.3\nconst higherGT = (a, b, options) => {\n if (!a) {\n return b\n }\n const comp = compare(a.semver, b.semver, options)\n return comp > 0 ? a\n : comp < 0 ? b\n : b.operator === '>' && a.operator === '>=' ? b\n : a\n}\n\n// <=1.2.3 is higher than <1.2.3\nconst lowerLT = (a, b, options) => {\n if (!a) {\n return b\n }\n const comp = compare(a.semver, b.semver, options)\n return comp < 0 ? a\n : comp > 0 ? b\n : b.operator === '<' && a.operator === '<=' ? b\n : a\n}\n\nmodule.exports = subset\n","const Range = require('../classes/range')\n\n// Mostly just for testing and legacy API reasons\nconst toComparators = (range, options) =>\n new Range(range, options).set\n .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))\n\nmodule.exports = toComparators\n","const Range = require('../classes/range')\nconst validRange = (range, options) => {\n try {\n // Return '*' instead of '' so that truthiness works.\n // This will throw if it's invalid anyway\n return new Range(range, options).range || '*'\n } catch (er) {\n return null\n }\n}\nmodule.exports = validRange\n","'use strict'\nmodule.exports = function (Yallist) {\n Yallist.prototype[Symbol.iterator] = function* () {\n for (let walker = this.head; walker; walker = walker.next) {\n yield walker.value\n }\n }\n}\n","'use strict'\nmodule.exports = Yallist\n\nYallist.Node = Node\nYallist.create = Yallist\n\nfunction Yallist (list) {\n var self = this\n if (!(self instanceof Yallist)) {\n self = new Yallist()\n }\n\n self.tail = null\n self.head = null\n self.length = 0\n\n if (list && typeof list.forEach === 'function') {\n list.forEach(function (item) {\n self.push(item)\n })\n } else if (arguments.length > 0) {\n for (var i = 0, l = arguments.length; i < l; i++) {\n self.push(arguments[i])\n }\n }\n\n return self\n}\n\nYallist.prototype.removeNode = function (node) {\n if (node.list !== this) {\n throw new Error('removing node which does not belong to this list')\n }\n\n var next = node.next\n var prev = node.prev\n\n if (next) {\n next.prev = prev\n }\n\n if (prev) {\n prev.next = next\n }\n\n if (node === this.head) {\n this.head = next\n }\n if (node === this.tail) {\n this.tail = prev\n }\n\n node.list.length--\n node.next = null\n node.prev = null\n node.list = null\n\n return next\n}\n\nYallist.prototype.unshiftNode = function (node) {\n if (node === this.head) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n var head = this.head\n node.list = this\n node.next = head\n if (head) {\n head.prev = node\n }\n\n this.head = node\n if (!this.tail) {\n this.tail = node\n }\n this.length++\n}\n\nYallist.prototype.pushNode = function (node) {\n if (node === this.tail) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n var tail = this.tail\n node.list = this\n node.prev = tail\n if (tail) {\n tail.next = node\n }\n\n this.tail = node\n if (!this.head) {\n this.head = node\n }\n this.length++\n}\n\nYallist.prototype.push = function () {\n for (var i = 0, l = arguments.length; i < l; i++) {\n push(this, arguments[i])\n }\n return this.length\n}\n\nYallist.prototype.unshift = function () {\n for (var i = 0, l = arguments.length; i < l; i++) {\n unshift(this, arguments[i])\n }\n return this.length\n}\n\nYallist.prototype.pop = function () {\n if (!this.tail) {\n return undefined\n }\n\n var res = this.tail.value\n this.tail = this.tail.prev\n if (this.tail) {\n this.tail.next = null\n } else {\n this.head = null\n }\n this.length--\n return res\n}\n\nYallist.prototype.shift = function () {\n if (!this.head) {\n return undefined\n }\n\n var res = this.head.value\n this.head = this.head.next\n if (this.head) {\n this.head.prev = null\n } else {\n this.tail = null\n }\n this.length--\n return res\n}\n\nYallist.prototype.forEach = function (fn, thisp) {\n thisp = thisp || this\n for (var walker = this.head, i = 0; walker !== null; i++) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.next\n }\n}\n\nYallist.prototype.forEachReverse = function (fn, thisp) {\n thisp = thisp || this\n for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.prev\n }\n}\n\nYallist.prototype.get = function (n) {\n for (var i = 0, walker = this.head; walker !== null && i < n; i++) {\n // abort out of the list early if we hit a cycle\n walker = walker.next\n }\n if (i === n && walker !== null) {\n return walker.value\n }\n}\n\nYallist.prototype.getReverse = function (n) {\n for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {\n // abort out of the list early if we hit a cycle\n walker = walker.prev\n }\n if (i === n && walker !== null) {\n return walker.value\n }\n}\n\nYallist.prototype.map = function (fn, thisp) {\n thisp = thisp || this\n var res = new Yallist()\n for (var walker = this.head; walker !== null;) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.next\n }\n return res\n}\n\nYallist.prototype.mapReverse = function (fn, thisp) {\n thisp = thisp || this\n var res = new Yallist()\n for (var walker = this.tail; walker !== null;) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.prev\n }\n return res\n}\n\nYallist.prototype.reduce = function (fn, initial) {\n var acc\n var walker = this.head\n if (arguments.length > 1) {\n acc = initial\n } else if (this.head) {\n walker = this.head.next\n acc = this.head.value\n } else {\n throw new TypeError('Reduce of empty list with no initial value')\n }\n\n for (var i = 0; walker !== null; i++) {\n acc = fn(acc, walker.value, i)\n walker = walker.next\n }\n\n return acc\n}\n\nYallist.prototype.reduceReverse = function (fn, initial) {\n var acc\n var walker = this.tail\n if (arguments.length > 1) {\n acc = initial\n } else if (this.tail) {\n walker = this.tail.prev\n acc = this.tail.value\n } else {\n throw new TypeError('Reduce of empty list with no initial value')\n }\n\n for (var i = this.length - 1; walker !== null; i--) {\n acc = fn(acc, walker.value, i)\n walker = walker.prev\n }\n\n return acc\n}\n\nYallist.prototype.toArray = function () {\n var arr = new Array(this.length)\n for (var i = 0, walker = this.head; walker !== null; i++) {\n arr[i] = walker.value\n walker = walker.next\n }\n return arr\n}\n\nYallist.prototype.toArrayReverse = function () {\n var arr = new Array(this.length)\n for (var i = 0, walker = this.tail; walker !== null; i++) {\n arr[i] = walker.value\n walker = walker.prev\n }\n return arr\n}\n\nYallist.prototype.slice = function (from, to) {\n to = to || this.length\n if (to < 0) {\n to += this.length\n }\n from = from || 0\n if (from < 0) {\n from += this.length\n }\n var ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n for (var i = 0, walker = this.head; walker !== null && i < from; i++) {\n walker = walker.next\n }\n for (; walker !== null && i < to; i++, walker = walker.next) {\n ret.push(walker.value)\n }\n return ret\n}\n\nYallist.prototype.sliceReverse = function (from, to) {\n to = to || this.length\n if (to < 0) {\n to += this.length\n }\n from = from || 0\n if (from < 0) {\n from += this.length\n }\n var ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {\n walker = walker.prev\n }\n for (; walker !== null && i > from; i--, walker = walker.prev) {\n ret.push(walker.value)\n }\n return ret\n}\n\nYallist.prototype.splice = function (start, deleteCount, ...nodes) {\n if (start > this.length) {\n start = this.length - 1\n }\n if (start < 0) {\n start = this.length + start;\n }\n\n for (var i = 0, walker = this.head; walker !== null && i < start; i++) {\n walker = walker.next\n }\n\n var ret = []\n for (var i = 0; walker && i < deleteCount; i++) {\n ret.push(walker.value)\n walker = this.removeNode(walker)\n }\n if (walker === null) {\n walker = this.tail\n }\n\n if (walker !== this.head && walker !== this.tail) {\n walker = walker.prev\n }\n\n for (var i = 0; i < nodes.length; i++) {\n walker = insert(this, walker, nodes[i])\n }\n return ret;\n}\n\nYallist.prototype.reverse = function () {\n var head = this.head\n var tail = this.tail\n for (var walker = head; walker !== null; walker = walker.prev) {\n var p = walker.prev\n walker.prev = walker.next\n walker.next = p\n }\n this.head = tail\n this.tail = head\n return this\n}\n\nfunction insert (self, node, value) {\n var inserted = node === self.head ?\n new Node(value, null, node, self) :\n new Node(value, node, node.next, self)\n\n if (inserted.next === null) {\n self.tail = inserted\n }\n if (inserted.prev === null) {\n self.head = inserted\n }\n\n self.length++\n\n return inserted\n}\n\nfunction push (self, item) {\n self.tail = new Node(item, self.tail, null, self)\n if (!self.head) {\n self.head = self.tail\n }\n self.length++\n}\n\nfunction unshift (self, item) {\n self.head = new Node(item, null, self.head, self)\n if (!self.tail) {\n self.tail = self.head\n }\n self.length++\n}\n\nfunction Node (value, prev, next, list) {\n if (!(this instanceof Node)) {\n return new Node(value, prev, next, list)\n }\n\n this.list = list\n this.value = value\n\n if (prev) {\n prev.next = this\n this.prev = prev\n } else {\n this.prev = null\n }\n\n if (next) {\n next.prev = this\n this.next = next\n } else {\n this.next = null\n }\n}\n\ntry {\n // add if support for Symbol.iterator is present\n require('./iterator.js')(Yallist)\n} catch (er) {}\n"],"names":["useStatelessReducer","onChange","state","reducer","useCallback","action","DispatchContext","createContext","undefined","useDispatch","dispatch","useContext","Error","defaultPipelineVariable","name","pipelineAgg","generatePipelineVariableName","pipelineVars","Math","max","map","v","parseInt","match","isEWMAMovingAverage","metric","settings","model","isHoltMovingAverage","isHoltWintersMovingAverage","isMovingAverageWithModelSettings","includes","isMetricAggregationWithField","metricAggregationConfig","type","requiresField","isPipelineAggregation","isPipelineAgg","isPipelineAggregationWithMultipleBucketPaths","supportsMultipleBucketPaths","isMetricAggregationWithMissingSupport","supportsMissing","isMetricAggregationWithSettings","hasSettings","isMetricAggregationWithInlineScript","supportsInlineScript","METRIC_AGGREGATION_TYPES","count","label","hasMeta","defaults","avg","sum","min","extended_stats","meta","std_deviation_bounds_lower","std_deviation_bounds_upper","percentiles","percents","cardinality","moving_avg","versionRange","window","moving_fn","derivative","serial_diff","lag","cumulative_sum","bucket_script","pipelineVariables","raw_document","isSingleMetric","size","raw_data","logs","limit","top_metrics","xpack","order","rate","pipelineOptions","default","getChildren","metrics","children","filter","m","some","pv","id","field","flatMap","child","extendedStats","value","movingAvgModelOptions","highlightTags","defaultMetricAgg","defaultBucketAgg","interval","findMetricById","find","hasMetricOfType","target","describeMetric","removeEmpty","obj","Object","entries","reduce","acc","key","Array","isArray","length","cleanObj","keys","convertOrderByToMetricId","orderBy","metricIdMatches","getScriptValue","script","inline","coerceESVersion","version","valid","isSupportedVersion","gte","addMetric","createAction","removeMetric","toggleMetricVisibility","changeMetricField","changeMetricType","changeMetricAttribute","changeMetricSetting","changeMetricMeta","initQuery","changeQuery","changeAliasPattern","queryReducer","prevQuery","payload","aliasPatternReducer","prevAliasPattern","bucketAggregationConfig","terms","defaultSettings","min_doc_count","filters","query","geohash_grid","precision","date_histogram","trimEdges","timeZone","InternalTimeZones","histogram","orderByOptions","orderOptions","sizeOptions","addBucketAggregation","removeBucketAggregation","changeBucketAggregationType","changeBucketAggregationField","changeBucketAggregationSetting","metricToRemove","metricsToRemove","resultingMetrics","toRemove","newMetric","hide","newSettings","settingName","newValue","isMetricAggregationWithMeta","attribute","DatasourceContext","QueryContext","RangeContext","ElasticsearchProvider","onRunQuery","datasource","range","onStateChange","reducers","alias","metricsReducer","bucketAggs","defaultTimeField","timeField","newAgg","lastAgg","slice","bucketAgg","newType","newField","newState","Provider","getHook","c","contextValue","useQuery","useDatasource","useRange","toId","e","toInt","idString","SROnly","css","IconButton","iconName","onClick","className","buttonProps","cx","Icon","QueryEditorRow","onRemoveClick","onHideClick","hidden","styles","useStyles2","getStyles","InlineFieldRow","InlineSegmentGroup","InlineLabel","width","as","iconWrapper","icon","noop","disabled","theme","colors","text","secondary","spacing","isBucketAggregationWithField","BUCKET_AGGREGATION_TYPES","getFilter","s","isBucketAggregationType","toSelectableValue","useFields","rawFields","async","lastValueFrom","getFields","q","segmentStyles","SettingsEditorContainer","open","setOpen","useState","wrapper","settingsWrapper","button","useTheme2","useCreatableSelectPersistedBehaviour","options","initialOptions","setOptions","initialValue","searchValue","getInitialState","onCreateOption","allowCustomValue","defaultIntervalOptions","isValidNewOption","inputValue","_","trim","optionStartsWithValue","option","startsWith","DateHistogramSettingsEditor","current","baseId","useRef","uniqueId","InlineField","inlineFieldProps","Select","inputId","filterOption","Input","onBlur","defaultValue","tooltip","offset","TimeZonePicker","includeInternal","AddRemove","index","onAdd","onRemove","elements","addFilter","removeFilter","changeFilter","concat","FiltersSettingsEditor","upperStateDispatch","filtersReducer","useEffect","labelWidth","QueryField","placeholder","portalOrigin","TermsSettingsEditor","createOrderByOptions","missing","createOrderByOptionsForExtendedStats","method","createOrderByOptionsForPercentiles","percent","percentString","test","isValidOrderTarget","metricOptions","hasValue","object","SettingsEditor","settingsDescription","minDocCount","description","orderByOption","useDescription","bucketAggOptions","BucketAggregationEditor","Segment","SegmentAsync","loadOptions","BucketAggregationsEditor","nextId","totalBucketAggs","noWrap","toOption","MetricPicker","selectedOption","SettingField","addPipelineVariable","removePipelineVariable","renamePipelineVariable","changePipelineVariableMetric","pipelineVariable","newName","BucketScriptSettingsEditor","previousMetrics","pipelineVar","Fragment","MovingAverageSettingsEditor","alpha","beta","gamma","period","InlineSwitch","pad","checked","minimize","toMultiSelectValue","TopMetricsSettingsEditor","getOrderByOptions","getMetricsOptions","AsyncMultiSelect","closeMenuOnSelect","defaultOptions","precision_threshold","selectedStats","Boolean","join","refId","stat","ExtendedStatSetting","split","unit","isBasicAggregation","getTypeOptions","esVersion","includePipelineAggregations","satisfies","config","MetricEditor","color","primary","remoteFields","findIndex","MetricAggregationsEditor","totalMetrics","root","queryFieldWrapper","QueryEditorForm","useMemo","toString","useNextId","isTimeSeriesQuery","showBucketAggregationsEditor","every","currentTarget","FormField","Switch","LegacyForms","stylesFactory","firstRow","nameField","regexField","row","urlField","urlDisplayLabelField","DataLink","props","onDelete","suggestions","showInternalLink","setShowInternalLink","datasourceUid","previousUid","usePrevious","useInternalLink","handleChange","event","inputWidth","Button","variant","title","preventDefault","inputEl","DataLinkInput","url","urlDisplayLabel","labelClass","DataSourcePicker","tracing","ds","uid","infoText","dataLink","DataLinks","newDataLinks","splice","DataLinkBuiltInVars","documentation","origin","VariableOrigin","coerceOptions","jsonData","maxConcurrentShardRequests","defaultMaxConcurrentShardRequests","logMessageField","logLevelField","includeFrozen","isTruthy","indexPatternTypes","example","esVersions","ElasticDetails","currentVersion","customOption","FieldSet","database","changeHandler","required","pattern","intervalHandler","jsonDataChangeHandler","lt","getMaxConcurrenShardRequestOrDefault","error","invalid","timeInterval","jsonDataSwitchChangeHandler","newInterval","newDatabase","LogsConfig","HIGHLIGHT_TAGS_EXP","queryDef","ElasticResponse","constructor","targets","response","seriesList","i","this","responses","getErrorFromElasticResponse","hits","processHits","aggregations","tmpSeriesList","table","TableModel","processBuckets","trimDatapoints","nameSeries","y","push","rows","data","processMetrics","esAgg","newSeries","datapoints","buckets","bucket","doc_count","values","percentileName","statName","stats","std_deviation_bounds","upper","lower","metricField","top","hit","point","metricId","normalized_value","processAggregationDocs","aggDef","columns","propKey","addColumn","filterable","addMetricValue","metricName","propValues","_values","getMetricName","baseName","aggs","depth","aggId","maxDepth","nameIndex","clone","key_as_string","metricDef","extendedStat","getSeriesName","series","dedup","regex","replace","g1","g2","group","indexOf","substring","metricType","agg","appliedAgg","propName","metricTypeCount","uniq","hasTopMetricWithMultipleMetrics","hitsTotal","total","doc","_id","_type","_index","sort","highlight","_source","fields","prop","points","err","result","JSON","stringify","root_cause","reason","message","$$config","getTimeSeries","processResponseToDataFrames","processResponseToSeries","getLogs","isLogsRequest","dataFrame","n","propNames","docs","flattenHits","createEmptyDataFrame","toNameTypePair","addPreferredVisualisationType","globalHighlightWordRegex","RegExp","highlightWordRegex","newSearchWords","line","matchedPhrases","part","matches","identity","searchWords","add","toDataFrame","flattened","flatten","MutableDataFrame","addField","FieldType","f","setParser","fieldNames","preferredVisualisationType","guessType","intervalMap","Hourly","startOf","amount","Daily","Weekly","Monthly","Yearly","IndexPattern","getIndexForToday","toUtc","locale","dateLocale","format","getIndexList","from","to","intervalInfo","start","dateTime","utc","endEpoch","valueOf","indexList","ElasticsearchLanguageProvider","LanguageProvider","initialValues","super","assign","importFromAbstractQuery","abstractQuery","getElasticsearchQuery","labelMatchers","labels","operator","AbstractLabelOperator","ElasticQueryBuilder","getRangeFilter","lte","buildTermsAgg","queryNode","_count","isNaN","getDateHistogramAgg","extended_bounds","time_zone","fixed_interval","getHistogramAgg","getFiltersAgg","filterObj","query_string","analyze_wildcard","documentQuery","unmapped_type","_doc","script_fields","addAdhocFilters","adhocFilters","condition","queryCondition","bool","must","match_phrase","must_not","gt","regexp","build","j","nestedAggs","aggField","metricAgg","buckets_path","forEach","k","buildScript","toNumber","predict","fromEntries","stringValue","parsedValue","parseFloat","getTermsQuery","keyname","getLogsQuery","pre_tags","post_tags","fragment_size","ELASTIC_META_FIELDS","ElasticDatasource","DataSourceApi","instanceSettings","templateSrv","getTemplateSrv","sortField","searchAfter","get","rowIndex","timeEpochMs","direction","header","getQueryHeader","search_after","getMultiSearchUrl","post","elasticResponse","actualResponse","reverse","transformHitsBasedOnDirection","logResponse","_first","timestampField","lineField","basicAuth","withCredentials","isProxyAccess","access","settingsData","indexPattern","queryBuilder","dataLinks","languageProvider","request","headers","throwError","Authorization","getBackendSrv","fetch","pipe","results","catchError","abstractQueries","getDefaultTimeRange","indexUrlList","requestAllIndices","listLen","generate","initialState","iterate","mergeMap","of","skipWhile","resp","status","throwIfEmpty","first","annotationQuery","annotation","timeEndField","queryString","tagsField","textField","dateRanges","rangeStart","rangeEnd","queryInterpolated","interpolateLuceneQuery","should","minimum_should_match","search_type","ignore_unavailable","res","list","getFieldFromSource","source","fieldName","fieldValue","console","log","time","isString","isNumber","tags","timeEnd","titleField","scopedVars","interpolateVariablesInQueries","queries","interpolateBucketAgg","expandedQueries","getRef","parse","testDatasource","dateFields","searchType","timeFrom","timeTo","queryHeader","getQueryDisplayText","metricAggs","showContextToggle","getLogsVolumeDataProvider","logsVolumeRequest","cloneDeep","LogLevel","queryLogsVolume","extractLevel","getLogLevelFromKey","sentTargets","targetsContainsLogsQuery","getAdhocFilters","logLimits","queryObj","esQuery","er","linksToApply","links","generateDataLink","enhanceDataFrame","isMetadataField","typeMap","float","double","integer","long","date","date_nanos","string","scaled_float","nested","shouldAddField","fieldNameParts","getFieldsRecursively","subObj","isObject","properties","pop","indexName","mappings","typeName","_map","getTerms","searchParams","URLSearchParams","append","metricFindQuery","parsedQuery","Promise","resolve","getTagKeys","getTagValues","targetContainsTemplate","containsTemplate","objectContainsTemplate","isPrimitive","item","linkConfig","dataSourceSrv","getDataSourceSrv","dsSettings","getInstanceSettings","internal","datasourceName","ElasticAnnotationsQueryCtrl","plugin","DataSourcePlugin","setQueryEditor","Alert","setConfigEditor","showAccessOptions","originalOptions","onOptionsChange","isValidOptions","supportedVersion","severity","DataSourceHttpSettings","defaultUrl","dataSourceConfig","sigV4AuthToggleEnabled","renderSigV4Editor","SIGV4ConnectionConfig","setAnnotationQueryCtrl","ref","t","a","l","o","arguments","prototype","hasOwnProperty","call","apply","r","next","throw","done","then","sent","trys","ops","return","Symbol","iterator","TypeError","u","d","exports","Keys","Credentials","Default","EC2IAMRole","ARN","p","h","g","b","standardRegions","D","w","E","loadRegions","A","S","skipHeader","C","x","skipEndpoint","V","I","F","profile","O","grafanaBootData","R","awsAllowedAuthProviders","awsAssumeRoleEnabled","K","authType","createElement","onUpdateDatasourceJsonDataOptionSelect","menuShouldPortal","onUpdateDatasourceJsonDataOption","secureJsonFields","accessKey","ButtonGroup","ToolbarButton","onUpdateDatasourceResetOption","secureJsonData","onUpdateDatasourceSecureJsonDataOption","secretKey","assumeRoleArn","externalId","defaultEndpoint","endpoint","defaultRegion","formatCreateLabel","dependencies","resources","isEqual","isLoading","onOpenMenu","saveOptions","Previous","Null","Value","String","ConnectionConfig","sigV4AuthType","sigV4Profile","sigV4AssumeRoleArn","sigV4ExternalId","sigV4Region","sigV4Endpoint","sigV4AccessKey","sigV4SecretKey","module","Yallist","MAX","LENGTH","LENGTH_CALCULATOR","ALLOW_STALE","MAX_AGE","DISPOSE","NO_DISPOSE_ON_SET","LRU_LIST","CACHE","UPDATE_AGE_ON_GET","naiveLength","self","doUse","node","isStale","del","now","Date","unshiftNode","maxAge","diff","walker","tail","prev","delete","removeNode","Entry","forEachStep","fn","thisp","Infinity","lc","stale","dispose","noDisposeOnSet","updateAgeOnGet","reset","mL","allowStale","mA","lengthCalculator","lC","itemCount","rforEach","head","toArray","Map","dump","dumpLru","set","len","has","unshift","peek","load","arr","expiresAt","prune","ANY","Comparator","comp","parseOptions","loose","debug","semver","re","COMPARATORLOOSE","COMPARATOR","SemVer","cmp","intersects","includePrerelease","Range","sameDirectionIncreasing","sameDirectionDecreasing","sameSemVer","differentDirectionsInclusive","oppositeDirectionsLessThan","oppositeDirectionsGreaterThan","raw","parseRange","isNullSet","isAny","comps","memoKey","cached","cache","hr","HYPHENRANGELOOSE","HYPHENRANGE","hyphenReplace","COMPARATORTRIM","comparatorTrimReplace","rangeList","TILDETRIM","tildeTrimReplace","CARETTRIM","caretTrimReplace","parseComparator","replaceGTE0","rangeMap","comparators","thisComparators","isSatisfiable","rangeComparators","thisComparator","rangeComparator","testSet","remainingComparators","testComparator","otherComparator","replaceCarets","replaceTildes","replaceXRanges","replaceStars","isX","toLowerCase","replaceTilde","TILDELOOSE","TILDE","M","pr","ret","replaceCaret","CARETLOOSE","CARET","z","replaceXRange","XRANGELOOSE","XRANGE","gtlt","xM","xm","xp","anyX","STAR","GTE0PRE","GTE0","incPr","$0","fM","fm","fp","fpr","fb","tM","tm","tp","tpr","tb","prerelease","allowed","major","minor","patch","MAX_LENGTH","MAX_SAFE_INTEGER","compareIdentifiers","LOOSE","FULL","num","compare","other","compareMain","comparePre","compareBuild","inc","release","identifier","eq","neq","op","rtl","COERCERTL","exec","lastIndex","COERCE","versionA","versionB","version1","version2","v1","v2","hasPre","prefix","defaultResult","parsed","internalRe","src","tokens","SEMVER_SPEC_VERSION","rcompareIdentifiers","clean","rcompare","compareLoose","rsort","coerce","toComparators","maxSatisfying","minSatisfying","minVersion","validRange","outside","gtr","ltr","simplifyRange","subset","Number","MAX_SAFE_COMPONENT_LENGTH","process","env","NODE_DEBUG","args","numeric","anum","bnum","opts","createToken","isGlobal","NUMERICIDENTIFIER","NUMERICIDENTIFIERLOOSE","NONNUMERICIDENTIFIER","PRERELEASEIDENTIFIER","PRERELEASEIDENTIFIERLOOSE","BUILDIDENTIFIER","MAINVERSION","PRERELEASE","BUILD","FULLPLAIN","MAINVERSIONLOOSE","PRERELEASELOOSE","LOOSEPLAIN","XRANGEIDENTIFIER","XRANGEIDENTIFIERLOOSE","GTLT","XRANGEPLAIN","XRANGEPLAINLOOSE","LONETILDE","LONECARET","r1","r2","versions","maxSV","rangeObj","minSV","minver","setMin","comparator","compver","hilo","gtfn","ltefn","ltfn","ecomp","high","low","ranges","simplified","original","simpleSubset","sub","dom","eqSet","Set","gtltComp","higher","hasDomLT","hasDomGT","higherGT","lowerLT","needDomLTPre","needDomGTPre","sawNonNull","OUTER","simpleSub","simpleDom","isSub","insert","inserted","Node","create","pushNode","shift","forEachReverse","getReverse","mapReverse","initial","reduceReverse","toArrayReverse","sliceReverse","deleteCount","nodes"],"sourceRoot":""}