@grafana/plugin-ui 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +9 -3
  2. package/dist/cjs/index.cjs +3196 -168
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +102 -39
  5. package/dist/cjs/test-utils.cjs +7880 -61
  6. package/dist/cjs/test-utils.cjs.map +1 -1
  7. package/dist/cjs/test-utils.d.cts +23 -23
  8. package/dist/esm/_virtual/chance.js +6 -0
  9. package/dist/esm/_virtual/chance.js.map +1 -0
  10. package/dist/esm/_virtual/chance2.js +4 -0
  11. package/dist/esm/_virtual/chance2.js.map +1 -0
  12. package/dist/esm/_virtual/index.js +6 -0
  13. package/dist/esm/_virtual/index.js.map +1 -0
  14. package/dist/esm/_virtual/re.js +4 -0
  15. package/dist/esm/_virtual/re.js.map +1 -0
  16. package/dist/esm/async-query-data/DatasourceWithAsyncBackend.js +155 -0
  17. package/dist/esm/async-query-data/DatasourceWithAsyncBackend.js.map +1 -0
  18. package/dist/esm/async-query-data/RunQueryButtons.js +52 -0
  19. package/dist/esm/async-query-data/RunQueryButtons.js.map +1 -0
  20. package/dist/esm/async-query-data/requestLooper.js +74 -0
  21. package/dist/esm/async-query-data/requestLooper.js.map +1 -0
  22. package/dist/esm/components/QueryEditor/InlineSelect.js +1 -1
  23. package/dist/esm/components/QueryEditor/InlineSelect.js.map +1 -1
  24. package/dist/esm/components/QueryEditor/QueryEditor.js +3 -1
  25. package/dist/esm/components/QueryEditor/QueryEditor.js.map +1 -1
  26. package/dist/esm/components/QueryEditor/QueryHeader.js +2 -2
  27. package/dist/esm/components/QueryEditor/QueryHeader.js.map +1 -1
  28. package/dist/esm/components/QueryEditor/TableSelector.js +0 -1
  29. package/dist/esm/components/QueryEditor/TableSelector.js.map +1 -1
  30. package/dist/esm/components/QueryEditor/defaults.js.map +1 -1
  31. package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js +10 -2
  32. package/dist/esm/components/QueryEditor/query-editor-raw/QueryEditorRaw.js.map +1 -1
  33. package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js +6 -1
  34. package/dist/esm/components/QueryEditor/query-editor-raw/QueryToolbox.js.map +1 -1
  35. package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js +11 -1
  36. package/dist/esm/components/QueryEditor/query-editor-raw/RawEditor.js.map +1 -1
  37. package/dist/esm/components/QueryEditor/types.js +0 -1
  38. package/dist/esm/components/QueryEditor/types.js.map +1 -1
  39. package/dist/esm/components/QueryEditor/utils/formatSQL.js +15 -4
  40. package/dist/esm/components/QueryEditor/utils/formatSQL.js.map +1 -1
  41. package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js +2 -2
  42. package/dist/esm/components/QueryEditor/visual-query-builder/Preview.js.map +1 -1
  43. package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js +0 -1
  44. package/dist/esm/components/QueryEditor/visual-query-builder/SQLGroupByRow.js.map +1 -1
  45. package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js +0 -1
  46. package/dist/esm/components/QueryEditor/visual-query-builder/SQLOrderByRow.js.map +1 -1
  47. package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js +0 -1
  48. package/dist/esm/components/QueryEditor/visual-query-builder/SQLSelectRow.js.map +1 -1
  49. package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js +0 -1
  50. package/dist/esm/components/QueryEditor/visual-query-builder/SQLWhereRow.js.map +1 -1
  51. package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js +10 -2
  52. package/dist/esm/components/QueryEditor/visual-query-builder/VisualEditor.js.map +1 -1
  53. package/dist/esm/components/SQLEditor/components/SQLEditor.js.map +1 -1
  54. package/dist/esm/components/SQLEditor/hooks/useLatestCallback.js +1 -1
  55. package/dist/esm/components/SQLEditor/hooks/useLatestCallback.js.map +1 -1
  56. package/dist/esm/components/SQLEditor/standardSql/definition.js +0 -6
  57. package/dist/esm/components/SQLEditor/standardSql/definition.js.map +1 -1
  58. package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js +2 -1
  59. package/dist/esm/components/SQLEditor/standardSql/getStatementPosition.js.map +1 -1
  60. package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js +2 -1
  61. package/dist/esm/components/SQLEditor/standardSql/statementPositionResolversRegistry.js.map +1 -1
  62. package/dist/esm/components/SQLEditor/types.js +1 -17
  63. package/dist/esm/components/SQLEditor/types.js.map +1 -1
  64. package/dist/esm/components/SQLEditor/utils/LinkedToken.js +1 -1
  65. package/dist/esm/components/SQLEditor/utils/LinkedToken.js.map +1 -1
  66. package/dist/esm/components/SQLEditor/utils/linkedTokenBuilder.js +2 -2
  67. package/dist/esm/components/SQLEditor/utils/tokenType.js +18 -0
  68. package/dist/esm/components/SQLEditor/utils/tokenType.js.map +1 -0
  69. package/dist/esm/components/SQLEditor/utils/tokenUtils.js +1 -1
  70. package/dist/esm/components/VisualQueryBuilder/components/OperationEditorBody.js +1 -1
  71. package/dist/esm/components/VisualQueryBuilder/components/OperationList.js +1 -1
  72. package/dist/esm/components/VisualQueryBuilder/components/OperationParamEditor.js +1 -1
  73. package/dist/esm/components/VisualQueryBuilder/components/OperationsEditorRow.js +1 -1
  74. package/dist/esm/components/VisualQueryBuilder/components/QueryHeaderSwitch.js +1 -1
  75. package/dist/esm/components/VisualQueryBuilder/components/QueryOptionGroup.js +1 -1
  76. package/dist/esm/index.d.ts +102 -39
  77. package/dist/esm/index.js +5 -1
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/node_modules/chance/chance.js +7820 -0
  80. package/dist/esm/node_modules/chance/chance.js.map +1 -0
  81. package/dist/esm/node_modules/semver/classes/comparator.js +160 -0
  82. package/dist/esm/node_modules/semver/classes/comparator.js.map +1 -0
  83. package/dist/esm/node_modules/semver/classes/range.js +575 -0
  84. package/dist/esm/node_modules/semver/classes/range.js.map +1 -0
  85. package/dist/esm/node_modules/semver/classes/semver.js +349 -0
  86. package/dist/esm/node_modules/semver/classes/semver.js.map +1 -0
  87. package/dist/esm/node_modules/semver/functions/clean.js +20 -0
  88. package/dist/esm/node_modules/semver/functions/clean.js.map +1 -0
  89. package/dist/esm/node_modules/semver/functions/cmp.js +71 -0
  90. package/dist/esm/node_modules/semver/functions/cmp.js.map +1 -0
  91. package/dist/esm/node_modules/semver/functions/coerce.js +76 -0
  92. package/dist/esm/node_modules/semver/functions/coerce.js.map +1 -0
  93. package/dist/esm/node_modules/semver/functions/compare-build.js +21 -0
  94. package/dist/esm/node_modules/semver/functions/compare-build.js.map +1 -0
  95. package/dist/esm/node_modules/semver/functions/compare-loose.js +17 -0
  96. package/dist/esm/node_modules/semver/functions/compare-loose.js.map +1 -0
  97. package/dist/esm/node_modules/semver/functions/compare.js +19 -0
  98. package/dist/esm/node_modules/semver/functions/compare.js.map +1 -0
  99. package/dist/esm/node_modules/semver/functions/diff.js +72 -0
  100. package/dist/esm/node_modules/semver/functions/diff.js.map +1 -0
  101. package/dist/esm/node_modules/semver/functions/eq.js +17 -0
  102. package/dist/esm/node_modules/semver/functions/eq.js.map +1 -0
  103. package/dist/esm/node_modules/semver/functions/gt.js +17 -0
  104. package/dist/esm/node_modules/semver/functions/gt.js.map +1 -0
  105. package/dist/esm/node_modules/semver/functions/gte.js +17 -0
  106. package/dist/esm/node_modules/semver/functions/gte.js.map +1 -0
  107. package/dist/esm/node_modules/semver/functions/inc.js +33 -0
  108. package/dist/esm/node_modules/semver/functions/inc.js.map +1 -0
  109. package/dist/esm/node_modules/semver/functions/lt.js +17 -0
  110. package/dist/esm/node_modules/semver/functions/lt.js.map +1 -0
  111. package/dist/esm/node_modules/semver/functions/lte.js +17 -0
  112. package/dist/esm/node_modules/semver/functions/lte.js.map +1 -0
  113. package/dist/esm/node_modules/semver/functions/major.js +17 -0
  114. package/dist/esm/node_modules/semver/functions/major.js.map +1 -0
  115. package/dist/esm/node_modules/semver/functions/minor.js +17 -0
  116. package/dist/esm/node_modules/semver/functions/minor.js.map +1 -0
  117. package/dist/esm/node_modules/semver/functions/neq.js +17 -0
  118. package/dist/esm/node_modules/semver/functions/neq.js.map +1 -0
  119. package/dist/esm/node_modules/semver/functions/parse.js +30 -0
  120. package/dist/esm/node_modules/semver/functions/parse.js.map +1 -0
  121. package/dist/esm/node_modules/semver/functions/patch.js +17 -0
  122. package/dist/esm/node_modules/semver/functions/patch.js.map +1 -0
  123. package/dist/esm/node_modules/semver/functions/prerelease.js +20 -0
  124. package/dist/esm/node_modules/semver/functions/prerelease.js.map +1 -0
  125. package/dist/esm/node_modules/semver/functions/rcompare.js +17 -0
  126. package/dist/esm/node_modules/semver/functions/rcompare.js.map +1 -0
  127. package/dist/esm/node_modules/semver/functions/rsort.js +17 -0
  128. package/dist/esm/node_modules/semver/functions/rsort.js.map +1 -0
  129. package/dist/esm/node_modules/semver/functions/satisfies.js +24 -0
  130. package/dist/esm/node_modules/semver/functions/satisfies.js.map +1 -0
  131. package/dist/esm/node_modules/semver/functions/sort.js +17 -0
  132. package/dist/esm/node_modules/semver/functions/sort.js.map +1 -0
  133. package/dist/esm/node_modules/semver/functions/valid.js +20 -0
  134. package/dist/esm/node_modules/semver/functions/valid.js.map +1 -0
  135. package/dist/esm/node_modules/semver/index.js +143 -0
  136. package/dist/esm/node_modules/semver/index.js.map +1 -0
  137. package/dist/esm/node_modules/semver/internal/constants.js +47 -0
  138. package/dist/esm/node_modules/semver/internal/constants.js.map +1 -0
  139. package/dist/esm/node_modules/semver/internal/debug.js +21 -0
  140. package/dist/esm/node_modules/semver/internal/debug.js.map +1 -0
  141. package/dist/esm/node_modules/semver/internal/identifiers.js +39 -0
  142. package/dist/esm/node_modules/semver/internal/identifiers.js.map +1 -0
  143. package/dist/esm/node_modules/semver/internal/lrucache.js +52 -0
  144. package/dist/esm/node_modules/semver/internal/lrucache.js.map +1 -0
  145. package/dist/esm/node_modules/semver/internal/parse-options.js +27 -0
  146. package/dist/esm/node_modules/semver/internal/parse-options.js.map +1 -0
  147. package/dist/esm/node_modules/semver/internal/re.js +238 -0
  148. package/dist/esm/node_modules/semver/internal/re.js.map +1 -0
  149. package/dist/esm/node_modules/semver/ranges/gtr.js +18 -0
  150. package/dist/esm/node_modules/semver/ranges/gtr.js.map +1 -0
  151. package/dist/esm/node_modules/semver/ranges/intersects.js +21 -0
  152. package/dist/esm/node_modules/semver/ranges/intersects.js.map +1 -0
  153. package/dist/esm/node_modules/semver/ranges/ltr.js +18 -0
  154. package/dist/esm/node_modules/semver/ranges/ltr.js.map +1 -0
  155. package/dist/esm/node_modules/semver/ranges/max-satisfying.js +40 -0
  156. package/dist/esm/node_modules/semver/ranges/max-satisfying.js.map +1 -0
  157. package/dist/esm/node_modules/semver/ranges/min-satisfying.js +39 -0
  158. package/dist/esm/node_modules/semver/ranges/min-satisfying.js.map +1 -0
  159. package/dist/esm/node_modules/semver/ranges/min-version.js +77 -0
  160. package/dist/esm/node_modules/semver/ranges/min-version.js.map +1 -0
  161. package/dist/esm/node_modules/semver/ranges/outside.js +101 -0
  162. package/dist/esm/node_modules/semver/ranges/outside.js.map +1 -0
  163. package/dist/esm/node_modules/semver/ranges/simplify.js +62 -0
  164. package/dist/esm/node_modules/semver/ranges/simplify.js.map +1 -0
  165. package/dist/esm/node_modules/semver/ranges/subset.js +264 -0
  166. package/dist/esm/node_modules/semver/ranges/subset.js.map +1 -0
  167. package/dist/esm/node_modules/semver/ranges/to-comparators.js +22 -0
  168. package/dist/esm/node_modules/semver/ranges/to-comparators.js.map +1 -0
  169. package/dist/esm/node_modules/semver/ranges/valid.js +25 -0
  170. package/dist/esm/node_modules/semver/ranges/valid.js.map +1 -0
  171. package/dist/esm/test/mocks/DataQuery.js +5 -5
  172. package/dist/esm/test/mocks/DataQuery.js.map +1 -1
  173. package/dist/esm/test/mocks/Datasource.js +21 -21
  174. package/dist/esm/test/mocks/Datasource.js.map +1 -1
  175. package/dist/esm/test/mocks/Plugin.js +29 -29
  176. package/dist/esm/test/mocks/Plugin.js.map +1 -1
  177. package/dist/esm/test/mocks/QueryEditorProps.js +6 -6
  178. package/dist/esm/test/mocks/QueryEditorProps.js.map +1 -1
  179. package/dist/esm/test/mocks/utils.js +4 -4
  180. package/dist/esm/test/mocks/utils.js.map +1 -1
  181. package/dist/esm/test-utils.d.ts +23 -23
  182. package/package.json +80 -87
@@ -11,10 +11,10 @@ var e2eSelectors = require('@grafana/e2e-selectors');
11
11
  var runtime = require('@grafana/runtime');
12
12
  var reactUse = require('react-use');
13
13
  var ui$1 = require('@react-awesome-query-builder/ui');
14
- var lodash = require('lodash');
15
14
  var uuid = require('uuid');
15
+ var lodash = require('lodash');
16
16
  var AutoSizer = require('react-virtualized-auto-sizer');
17
- var sqlFormatter = require('sql-formatter-plus');
17
+ var sqlFormatter = require('sql-formatter');
18
18
  var rxjs = require('rxjs');
19
19
  var operators$1 = require('rxjs/operators');
20
20
  var dnd = require('@hello-pangea/dnd');
@@ -26,7 +26,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
26
26
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
27
27
  var Calendar__default = /*#__PURE__*/_interopDefaultCompat(Calendar);
28
28
  var AutoSizer__default = /*#__PURE__*/_interopDefaultCompat(AutoSizer);
29
- var sqlFormatter__default = /*#__PURE__*/_interopDefaultCompat(sqlFormatter);
30
29
  var Prism__default = /*#__PURE__*/_interopDefaultCompat(Prism);
31
30
 
32
31
  const QueryEditorRow = (props) => {
@@ -339,15 +338,15 @@ function getSignatureDisplayModel(signature) {
339
338
  }
340
339
  PluginSignatureBadge.displayName = "PluginSignatureBadge";
341
340
 
342
- var __defProp$3 = Object.defineProperty;
343
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
344
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
341
+ var __defProp$4 = Object.defineProperty;
342
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
343
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
345
344
  class DataSourcePicker extends React.PureComponent {
346
345
  constructor(props) {
347
346
  super(props);
348
- __publicField$3(this, "dataSourceSrv", runtime.getDataSourceSrv());
349
- __publicField$3(this, "state", {});
350
- __publicField$3(this, "onChange", (item) => {
347
+ __publicField$4(this, "dataSourceSrv", runtime.getDataSourceSrv());
348
+ __publicField$4(this, "state", {});
349
+ __publicField$4(this, "onChange", (item) => {
351
350
  const dsSettings = this.dataSourceSrv.getInstanceSettings(item.value);
352
351
  if (dsSettings) {
353
352
  this.props.onChange(dsSettings);
@@ -427,7 +426,7 @@ class DataSourcePicker extends React.PureComponent {
427
426
  ));
428
427
  }
429
428
  }
430
- __publicField$3(DataSourcePicker, "defaultProps", {
429
+ __publicField$4(DataSourcePicker, "defaultProps", {
431
430
  autoFocus: false,
432
431
  openMenuOnFocus: false,
433
432
  placeholder: "Select datasource"
@@ -641,110 +640,21 @@ var QueryEditorExpressionType = /* @__PURE__ */ ((QueryEditorExpressionType2) =>
641
640
  return QueryEditorExpressionType2;
642
641
  })(QueryEditorExpressionType || {});
643
642
 
644
- function getRawSqlFn(db) {
645
- return db.toRawSql ? db.toRawSql : (query) => toRawSql(query, Boolean(db.disableDatasets));
646
- }
647
- function toRawSql({ sql, dataset, catalog, table }, disableDatasets) {
648
- var _a, _b, _c, _d;
649
- let rawQuery = "";
650
- if (!sql || !haveColumns(sql.columns)) {
651
- return rawQuery;
652
- }
653
- rawQuery += createSelectClause(sql.columns);
654
- if (catalog && dataset && table) {
655
- rawQuery += `FROM ${catalog}.${dataset}.${table} `;
656
- } else if (!disableDatasets && dataset && table) {
657
- rawQuery += `FROM ${dataset}.${table} `;
658
- } else if (table) {
659
- rawQuery += `FROM ${table} `;
660
- }
661
- if (sql.whereString) {
662
- rawQuery += `WHERE ${sql.whereString} `;
663
- }
664
- if ((_b = (_a = sql.groupBy) == null ? undefined : _a[0]) == null ? undefined : _b.property.name) {
665
- const groupBy = sql.groupBy.map((g) => g.property.name).filter((g) => !lodash.isEmpty(g));
666
- rawQuery += `GROUP BY ${groupBy.join(", ")} `;
667
- }
668
- if ((_c = sql.orderBy) == null ? undefined : _c.property.name) {
669
- rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
670
- }
671
- if (((_d = sql.orderBy) == null ? undefined : _d.property.name) && sql.orderByDirection) {
672
- rawQuery += `${sql.orderByDirection} `;
673
- }
674
- if (sql.limit !== undefined && sql.limit >= 0) {
675
- rawQuery += `LIMIT ${sql.limit} `;
676
- }
677
- return rawQuery;
678
- }
679
- function createSelectClause(sqlColumns) {
680
- const columns = sqlColumns.map((c) => {
681
- var _a, _b;
682
- let rawColumn = "";
683
- if (c.name) {
684
- rawColumn += `${c.name}(${(_a = c.parameters) == null ? undefined : _a.map((p) => `${p.name}`)})`;
685
- } else {
686
- rawColumn += `${(_b = c.parameters) == null ? undefined : _b.map((p) => `${p.name}`)}`;
687
- }
688
- return rawColumn;
689
- });
690
- return `SELECT ${columns.join(", ")} `;
691
- }
692
- function haveColumns(columns) {
693
- if (!columns) {
694
- return false;
695
- }
696
- const haveColumn = columns.some((c) => {
697
- var _a, _b;
698
- return ((_a = c.parameters) == null ? undefined : _a.length) || ((_b = c.parameters) == null ? undefined : _b.some((p) => p.name));
699
- });
700
- const haveFunction = columns.some((c) => c.name);
701
- return haveColumn || haveFunction;
702
- }
703
- function setGroupByField(field) {
704
- return {
705
- type: QueryEditorExpressionType.GroupBy,
706
- property: {
707
- type: QueryEditorPropertyType.String,
708
- name: field
709
- }
710
- };
711
- }
712
- function setPropertyField(field) {
713
- return {
714
- type: QueryEditorExpressionType.Property,
715
- property: {
716
- type: QueryEditorPropertyType.String,
717
- name: field
718
- }
719
- };
720
- }
721
- function createFunctionField(functionName) {
722
- return {
723
- type: QueryEditorExpressionType.Function,
724
- name: functionName,
725
- parameters: []
726
- };
727
- }
728
-
729
- function applyQueryDefaults(q) {
730
- let editorMode = (q == null ? undefined : q.editorMode) || EditorMode.Builder;
731
- if ((q == null ? undefined : q.editorMode) === undefined && (q == null ? undefined : q.rawSql) !== undefined) {
732
- editorMode = EditorMode.Code;
733
- }
734
- const result = {
735
- ...q,
736
- refId: (q == null ? undefined : q.refId) || "A",
737
- format: (q == null ? undefined : q.format) !== undefined ? q.format : QueryFormat.Table,
738
- rawSql: (q == null ? undefined : q.rawSql) || "",
739
- editorMode,
740
- sql: (q == null ? undefined : q.sql) || {
741
- columns: [createFunctionField()],
742
- groupBy: [setGroupByField()],
743
- limit: 50
744
- }
745
- };
746
- return result;
747
- }
643
+ var TokenType = /* @__PURE__ */ ((TokenType2) => {
644
+ TokenType2["Parenthesis"] = "delimiter.parenthesis.sql";
645
+ TokenType2["Whitespace"] = "white.sql";
646
+ TokenType2["Keyword"] = "keyword.sql";
647
+ TokenType2["Delimiter"] = "delimiter.sql";
648
+ TokenType2["Operator"] = "operator.sql";
649
+ TokenType2["Identifier"] = "identifier.sql";
650
+ TokenType2["IdentifierQuote"] = "identifier.quote.sql";
651
+ TokenType2["Type"] = "type.sql";
652
+ TokenType2["Function"] = "predefined.sql";
653
+ TokenType2["Number"] = "number.sql";
654
+ TokenType2["String"] = "string.sql";
655
+ TokenType2["Variable"] = "variable.sql";
656
+ return TokenType2;
657
+ })(TokenType || {});
748
658
 
749
659
  class LinkedToken {
750
660
  constructor(type, value, range, previous, next) {
@@ -899,21 +809,6 @@ var MacroType = /* @__PURE__ */ ((MacroType2) => {
899
809
  MacroType2[MacroType2["Table"] = 4] = "Table";
900
810
  return MacroType2;
901
811
  })(MacroType || {});
902
- var TokenType = /* @__PURE__ */ ((TokenType2) => {
903
- TokenType2["Parenthesis"] = "delimiter.parenthesis.sql";
904
- TokenType2["Whitespace"] = "white.sql";
905
- TokenType2["Keyword"] = "keyword.sql";
906
- TokenType2["Delimiter"] = "delimiter.sql";
907
- TokenType2["Operator"] = "operator.sql";
908
- TokenType2["Identifier"] = "identifier.sql";
909
- TokenType2["IdentifierQuote"] = "identifier.quote.sql";
910
- TokenType2["Type"] = "type.sql";
911
- TokenType2["Function"] = "predefined.sql";
912
- TokenType2["Number"] = "number.sql";
913
- TokenType2["String"] = "string.sql";
914
- TokenType2["Variable"] = "variable.sql";
915
- return TokenType2;
916
- })(TokenType || {});
917
812
  var StatementPosition = /* @__PURE__ */ ((StatementPosition2) => {
918
813
  StatementPosition2["Unknown"] = "unknown";
919
814
  StatementPosition2["SelectKeyword"] = "selectKeyword";
@@ -2865,7 +2760,7 @@ function useLatestCallback(callback) {
2865
2760
  });
2866
2761
  const hasCallback = Boolean(callback);
2867
2762
  return React.useMemo(
2868
- () => hasCallback ? ((...args) => ref.current(...args)) : undefined,
2763
+ () => hasCallback ? (...args) => ref.current(...args) : undefined,
2869
2764
  [hasCallback]
2870
2765
  );
2871
2766
  }
@@ -5456,6 +5351,91 @@ const QUERY_FORMAT_OPTIONS = [
5456
5351
  const backWardToOption = (value) => ({ label: value, value });
5457
5352
  const toOption = (_a = data.toOption) != null ? _a : backWardToOption;
5458
5353
 
5354
+ function getRawSqlFn(db) {
5355
+ return db.toRawSql ? db.toRawSql : (query) => toRawSql(query, Boolean(db.disableDatasets));
5356
+ }
5357
+ function toRawSql({ sql, dataset, catalog, table }, disableDatasets) {
5358
+ var _a, _b, _c, _d;
5359
+ let rawQuery = "";
5360
+ if (!sql || !haveColumns(sql.columns)) {
5361
+ return rawQuery;
5362
+ }
5363
+ rawQuery += createSelectClause(sql.columns);
5364
+ if (catalog && dataset && table) {
5365
+ rawQuery += `FROM ${catalog}.${dataset}.${table} `;
5366
+ } else if (!disableDatasets && dataset && table) {
5367
+ rawQuery += `FROM ${dataset}.${table} `;
5368
+ } else if (table) {
5369
+ rawQuery += `FROM ${table} `;
5370
+ }
5371
+ if (sql.whereString) {
5372
+ rawQuery += `WHERE ${sql.whereString} `;
5373
+ }
5374
+ if ((_b = (_a = sql.groupBy) == null ? undefined : _a[0]) == null ? undefined : _b.property.name) {
5375
+ const groupBy = sql.groupBy.map((g) => g.property.name).filter((g) => !lodash.isEmpty(g));
5376
+ rawQuery += `GROUP BY ${groupBy.join(", ")} `;
5377
+ }
5378
+ if ((_c = sql.orderBy) == null ? undefined : _c.property.name) {
5379
+ rawQuery += `ORDER BY ${sql.orderBy.property.name} `;
5380
+ }
5381
+ if (((_d = sql.orderBy) == null ? undefined : _d.property.name) && sql.orderByDirection) {
5382
+ rawQuery += `${sql.orderByDirection} `;
5383
+ }
5384
+ if (sql.limit !== undefined && sql.limit >= 0) {
5385
+ rawQuery += `LIMIT ${sql.limit} `;
5386
+ }
5387
+ return rawQuery;
5388
+ }
5389
+ function createSelectClause(sqlColumns) {
5390
+ const columns = sqlColumns.map((c) => {
5391
+ var _a, _b;
5392
+ let rawColumn = "";
5393
+ if (c.name) {
5394
+ rawColumn += `${c.name}(${(_a = c.parameters) == null ? undefined : _a.map((p) => `${p.name}`)})`;
5395
+ } else {
5396
+ rawColumn += `${(_b = c.parameters) == null ? undefined : _b.map((p) => `${p.name}`)}`;
5397
+ }
5398
+ return rawColumn;
5399
+ });
5400
+ return `SELECT ${columns.join(", ")} `;
5401
+ }
5402
+ function haveColumns(columns) {
5403
+ if (!columns) {
5404
+ return false;
5405
+ }
5406
+ const haveColumn = columns.some((c) => {
5407
+ var _a, _b;
5408
+ return ((_a = c.parameters) == null ? undefined : _a.length) || ((_b = c.parameters) == null ? undefined : _b.some((p) => p.name));
5409
+ });
5410
+ const haveFunction = columns.some((c) => c.name);
5411
+ return haveColumn || haveFunction;
5412
+ }
5413
+ function setGroupByField(field) {
5414
+ return {
5415
+ type: QueryEditorExpressionType.GroupBy,
5416
+ property: {
5417
+ type: QueryEditorPropertyType.String,
5418
+ name: field
5419
+ }
5420
+ };
5421
+ }
5422
+ function setPropertyField(field) {
5423
+ return {
5424
+ type: QueryEditorExpressionType.Property,
5425
+ property: {
5426
+ type: QueryEditorPropertyType.String,
5427
+ name: field
5428
+ }
5429
+ };
5430
+ }
5431
+ function createFunctionField(functionName) {
5432
+ return {
5433
+ type: QueryEditorExpressionType.Function,
5434
+ name: functionName,
5435
+ parameters: []
5436
+ };
5437
+ }
5438
+
5459
5439
  const EditorStack = ({ children, wrap: wrapItems = true, ...props }) => {
5460
5440
  var _a, _b;
5461
5441
  return /* @__PURE__ */ React__default.default.createElement(ui.Stack, { wrap: wrapItems ? "wrap" : undefined, direction: (_a = props.direction) != null ? _a : "row", gap: (_b = props.gap) != null ? _b : 2, ...props }, children);
@@ -5688,7 +5668,7 @@ function InlineSelect({ label: labelProp, ...props }) {
5688
5668
  ValueContainer,
5689
5669
  SingleValue: ValueContainer
5690
5670
  };
5691
- return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, labelProp && /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: id }, labelProp, ":", "\xA0"), /* @__PURE__ */ React__default.default.createElement(ui.Select, { openMenuOnFocus: true, inputId: id, ...props, components }));
5671
+ return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.root }, labelProp && /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label, htmlFor: id }, labelProp, ":", "\xA0"), /* @__PURE__ */ React__default.default.createElement(ui.Select, { inputId: id, ...props, components }));
5692
5672
  }
5693
5673
  const SelectContainer = (props) => {
5694
5674
  const { children } = props;
@@ -5742,6 +5722,26 @@ const getStyles$i = (theme, v, h, layout) => ({
5742
5722
  ])
5743
5723
  });
5744
5724
 
5725
+ function applyQueryDefaults(q) {
5726
+ let editorMode = (q == null ? undefined : q.editorMode) || EditorMode.Builder;
5727
+ if ((q == null ? undefined : q.editorMode) === undefined && (q == null ? undefined : q.rawSql) !== undefined) {
5728
+ editorMode = EditorMode.Code;
5729
+ }
5730
+ const result = {
5731
+ ...q,
5732
+ refId: (q == null ? undefined : q.refId) || "A",
5733
+ format: (q == null ? undefined : q.format) !== undefined ? q.format : QueryFormat.Table,
5734
+ rawSql: (q == null ? undefined : q.rawSql) || "",
5735
+ editorMode,
5736
+ sql: (q == null ? undefined : q.sql) || {
5737
+ columns: [createFunctionField()],
5738
+ groupBy: [setGroupByField()],
5739
+ limit: 50
5740
+ }
5741
+ };
5742
+ return result;
5743
+ }
5744
+
5745
5745
  function ConfirmModal({ isOpen, onCancel, onDiscard, onCopy }) {
5746
5746
  const buttonRef = React.useRef(null);
5747
5747
  React.useEffect(() => {
@@ -6131,13 +6131,32 @@ function QueryHeader({
6131
6131
  )))));
6132
6132
  }
6133
6133
 
6134
- function formatSQL(q) {
6135
- return sqlFormatter__default.default.format(q).replace(/(\$ \{ .* \})|(\$ __)|(\$ \w+)/g, (m) => {
6136
- return m.replace(/\s/g, "");
6134
+ function formatSQL(q, language = "sql") {
6135
+ const formatted = sqlFormatter.format(q, {
6136
+ language,
6137
+ paramTypes: {
6138
+ custom: [
6139
+ {
6140
+ regex: "\\$\\s*\\{[^}]*\\}|\\$\\s*__\\w+(?:\\([^)]*\\))?|\\$\\s*\\w+"
6141
+ }
6142
+ ]
6143
+ }
6137
6144
  });
6145
+ return formatted.replace(
6146
+ /(\$\s*\{[^}]*\})|(\$\s*__\w+(?:\([^)]*\))?)|(\$\s*\w+)/g,
6147
+ (m) => m.replace(/\s/g, "")
6148
+ );
6138
6149
  }
6139
6150
 
6140
- function QueryEditorRaw({ children, onChange, query, width, height, completionProvider }) {
6151
+ function QueryEditorRaw({
6152
+ children,
6153
+ onChange,
6154
+ query,
6155
+ width,
6156
+ height,
6157
+ completionProvider,
6158
+ language = "sql"
6159
+ }) {
6141
6160
  const queryRef = React.useRef(query);
6142
6161
  React.useEffect(() => {
6143
6162
  queryRef.current = query;
@@ -6160,7 +6179,7 @@ function QueryEditorRaw({ children, onChange, query, width, height, completionPr
6160
6179
  height,
6161
6180
  query: query.rawSql,
6162
6181
  onChange: onRawQueryChange,
6163
- language: { id: "sql", completionProvider, formatter: formatSQL }
6182
+ language: { id: "sql", completionProvider, formatter: (q) => formatSQL(q, language) }
6164
6183
  },
6165
6184
  children
6166
6185
  );
@@ -6265,6 +6284,10 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
6265
6284
  if (!showTools && validationResult === undefined) {
6266
6285
  style = { height: 0, padding: 0, visibility: "hidden" };
6267
6286
  }
6287
+ const onFormatClick = () => {
6288
+ runtime.reportInteraction("grafana_sql_query_editor_format_click");
6289
+ onFormatCode == null ? undefined : onFormatCode();
6290
+ };
6268
6291
  return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container, style }, /* @__PURE__ */ React__default.default.createElement("div", null, validatorProps.onValidate && /* @__PURE__ */ React__default.default.createElement(
6269
6292
  QueryValidator,
6270
6293
  {
@@ -6274,7 +6297,7 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
6274
6297
  validatorProps.onValidate(result);
6275
6298
  }
6276
6299
  }
6277
- )), showTools && /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.HorizontalGroup, { spacing: "sm" }, onFormatCode && /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { onClick: onFormatCode, name: "brackets-curly", size: "xs", tooltip: "Format query" }), onExpand && /* @__PURE__ */ React__default.default.createElement(
6300
+ )), showTools && /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(ui.HorizontalGroup, { spacing: "sm" }, onFormatCode && /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { onClick: onFormatClick, name: "brackets-curly", size: "xs", tooltip: "Format query" }), onExpand && /* @__PURE__ */ React__default.default.createElement(
6278
6301
  ui.IconButton,
6279
6302
  {
6280
6303
  onClick: () => onExpand(!isExpanded),
@@ -6285,7 +6308,16 @@ function QueryToolbox({ showTools, onFormatCode, onExpand, isExpanded, ...valida
6285
6308
  ), /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: "Hit CTRL/CMD+Return to run query" }, /* @__PURE__ */ React__default.default.createElement(ui.Icon, { className: styles.hint, name: "keyboard" })))));
6286
6309
  }
6287
6310
 
6288
- function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryToValidate, range }) {
6311
+ function RawEditor({
6312
+ db,
6313
+ query,
6314
+ onChange,
6315
+ onRunQuery,
6316
+ onValidate,
6317
+ queryToValidate,
6318
+ range,
6319
+ language = "sql"
6320
+ }) {
6289
6321
  const theme = ui.useTheme2();
6290
6322
  const styles = ui.useStyles2(getStyles$h);
6291
6323
  const [isExpanded, setIsExpanded] = React.useState(false);
@@ -6299,6 +6331,7 @@ function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryToValidat
6299
6331
  completionProvider,
6300
6332
  query,
6301
6333
  width,
6334
+ language,
6302
6335
  height: height ? height - toolboxMeasure.height : undefined,
6303
6336
  onChange
6304
6337
  },
@@ -6369,7 +6402,7 @@ function getStyles$h(theme) {
6369
6402
  };
6370
6403
  }
6371
6404
 
6372
- function Preview({ rawSql }) {
6405
+ function Preview({ rawSql, language = "sql" }) {
6373
6406
  const [_, copyToClipboard] = reactUse.useCopyToClipboard();
6374
6407
  const styles = ui.useStyles2(getStyles$g);
6375
6408
  const labelElement = /* @__PURE__ */ React__default.default.createElement("div", { className: styles.labelWrapper }, /* @__PURE__ */ React__default.default.createElement("label", { className: styles.label }, "Preview"), /* @__PURE__ */ React__default.default.createElement(ui.IconButton, { tooltip: "Copy to clipboard", onClick: () => copyToClipboard(rawSql), name: "copy" }));
@@ -6378,7 +6411,7 @@ function Preview({ rawSql }) {
6378
6411
  {
6379
6412
  language: "sql",
6380
6413
  height: 80,
6381
- value: formatSQL(rawSql),
6414
+ value: formatSQL(rawSql, language),
6382
6415
  monacoOptions: { scrollbar: { vertical: "hidden" }, scrollBeyondLastLine: false },
6383
6416
  readOnly: true,
6384
6417
  showMiniMap: false
@@ -7000,12 +7033,20 @@ const EditorRows = ({ children }) => {
7000
7033
  return /* @__PURE__ */ React__default.default.createElement(EditorStack, { gap: 0.5, direction: "column" }, children);
7001
7034
  };
7002
7035
 
7003
- const VisualEditor = ({ query, db, queryRowFilter, onChange, onValidate, range }) => {
7036
+ const VisualEditor = ({
7037
+ query,
7038
+ db,
7039
+ queryRowFilter,
7040
+ onChange,
7041
+ onValidate,
7042
+ language = "sql",
7043
+ range
7044
+ }) => {
7004
7045
  const state = reactUse.useAsync(async () => {
7005
7046
  const fields = await db.fields(query);
7006
7047
  return fields;
7007
7048
  }, [db, query.dataset, query.table]);
7008
- return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(EditorRows, null, /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLSelectRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.filter && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Filter by column value", optional: true }, /* @__PURE__ */ React__default.default.createElement(SQLWhereRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.group && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Group by column" }, /* @__PURE__ */ React__default.default.createElement(SQLGroupByRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.order && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLOrderByRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.preview && query.rawSql && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(Preview, { rawSql: query.rawSql }))), /* @__PURE__ */ React__default.default.createElement(QueryToolbox, { db, query, onValidate, range }));
7049
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(EditorRows, null, /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLSelectRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.filter && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Filter by column value", optional: true }, /* @__PURE__ */ React__default.default.createElement(SQLWhereRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.group && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(EditorField, { label: "Group by column" }, /* @__PURE__ */ React__default.default.createElement(SQLGroupByRow, { fields: state.value || [], query, onQueryChange: onChange, db }))), queryRowFilter.order && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(SQLOrderByRow, { fields: state.value || [], query, onQueryChange: onChange, db })), queryRowFilter.preview && query.rawSql && /* @__PURE__ */ React__default.default.createElement(EditorRow, null, /* @__PURE__ */ React__default.default.createElement(Preview, { rawSql: query.rawSql, language }))), /* @__PURE__ */ React__default.default.createElement(QueryToolbox, { db, query, onValidate, range }));
7009
7050
  };
7010
7051
 
7011
7052
  const MACRO_NAMES = [
@@ -7024,20 +7065,20 @@ const MACRO_NAMES = [
7024
7065
  "$__unixEpochGroupAlias"
7025
7066
  ];
7026
7067
 
7027
- var __defProp$2 = Object.defineProperty;
7028
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7029
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
7068
+ var __defProp$3 = Object.defineProperty;
7069
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7070
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
7030
7071
  class SqlDatasource extends runtime.DataSourceWithBackend {
7031
7072
  constructor(instanceSettings, templateSrv = runtime.getTemplateSrv()) {
7032
7073
  super(instanceSettings);
7033
7074
  this.templateSrv = templateSrv;
7034
- __publicField$2(this, "id");
7035
- __publicField$2(this, "name");
7036
- __publicField$2(this, "interval");
7037
- __publicField$2(this, "db");
7038
- __publicField$2(this, "dataset");
7039
- __publicField$2(this, "annotations", {});
7040
- __publicField$2(this, "interpolateVariable", (value, variable) => {
7075
+ __publicField$3(this, "id");
7076
+ __publicField$3(this, "name");
7077
+ __publicField$3(this, "interval");
7078
+ __publicField$3(this, "db");
7079
+ __publicField$3(this, "dataset");
7080
+ __publicField$3(this, "annotations", {});
7081
+ __publicField$3(this, "interpolateVariable", (value, variable) => {
7041
7082
  if (typeof value === "string") {
7042
7083
  if (variable.multi || variable.includeAll) {
7043
7084
  const result = this.getQueryModel().quoteLiteral(value);
@@ -7187,7 +7228,7 @@ const getSearchFilterScopedVar = (args) => {
7187
7228
  };
7188
7229
  };
7189
7230
 
7190
- function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
7231
+ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range, language = "sql" }) {
7191
7232
  var _a, _b, _c, _d, _e, _f, _g;
7192
7233
  const [isQueryRunnable, setIsQueryRunnable] = React.useState(true);
7193
7234
  const db = datasource.getDB();
@@ -7263,6 +7304,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
7263
7304
  {
7264
7305
  db,
7265
7306
  query: queryWithDefaults,
7307
+ language,
7266
7308
  onChange: (q) => onQueryChange(q, false),
7267
7309
  queryRowFilter,
7268
7310
  onValidate: setIsQueryRunnable,
@@ -7272,6 +7314,7 @@ function SqlQueryEditor({ datasource, query, onChange, onRunQuery, range }) {
7272
7314
  RawEditor,
7273
7315
  {
7274
7316
  db,
7317
+ language,
7275
7318
  query: queryWithDefaults,
7276
7319
  queryToValidate,
7277
7320
  onChange: onQueryChange,
@@ -8390,9 +8433,9 @@ const AdvancedHttpSettings = ({
8390
8433
  ));
8391
8434
  };
8392
8435
 
8393
- var __defProp$1 = Object.defineProperty;
8394
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8395
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
8436
+ var __defProp$2 = Object.defineProperty;
8437
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8438
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
8396
8439
  const getCustomHeaderRowStyles = ui.stylesFactory(() => {
8397
8440
  return {
8398
8441
  layout: css.css`
@@ -8455,10 +8498,10 @@ CustomHeaderRow.displayName = "CustomHeaderRow";
8455
8498
  class CustomHeadersSettings extends React.PureComponent {
8456
8499
  constructor(props) {
8457
8500
  super(props);
8458
- __publicField$1(this, "state", {
8501
+ __publicField$2(this, "state", {
8459
8502
  headers: []
8460
8503
  });
8461
- __publicField$1(this, "updateSettings", () => {
8504
+ __publicField$2(this, "updateSettings", () => {
8462
8505
  const { headers } = this.state;
8463
8506
  const newJsonData = Object.fromEntries(
8464
8507
  Object.entries(this.props.dataSourceConfig.jsonData).filter(([key, val]) => !key.startsWith("httpHeaderName"))
@@ -8480,14 +8523,14 @@ class CustomHeadersSettings extends React.PureComponent {
8480
8523
  secureJsonData: newSecureJsonData
8481
8524
  });
8482
8525
  });
8483
- __publicField$1(this, "onHeaderAdd", () => {
8526
+ __publicField$2(this, "onHeaderAdd", () => {
8484
8527
  this.setState((prevState) => {
8485
8528
  return {
8486
8529
  headers: [...prevState.headers, { id: lodash.uniqueId(), name: "", value: "", configured: false }]
8487
8530
  };
8488
8531
  });
8489
8532
  });
8490
- __publicField$1(this, "onHeaderChange", (headerIndex, value) => {
8533
+ __publicField$2(this, "onHeaderChange", (headerIndex, value) => {
8491
8534
  this.setState(({ headers }) => {
8492
8535
  return {
8493
8536
  headers: headers.map((item, index) => {
@@ -8499,7 +8542,7 @@ class CustomHeadersSettings extends React.PureComponent {
8499
8542
  };
8500
8543
  });
8501
8544
  });
8502
- __publicField$1(this, "onHeaderReset", (headerId) => {
8545
+ __publicField$2(this, "onHeaderReset", (headerId) => {
8503
8546
  this.setState(({ headers }) => {
8504
8547
  return {
8505
8548
  headers: headers.map((h, i) => {
@@ -8515,7 +8558,7 @@ class CustomHeadersSettings extends React.PureComponent {
8515
8558
  };
8516
8559
  });
8517
8560
  });
8518
- __publicField$1(this, "onHeaderRemove", (headerId) => {
8561
+ __publicField$2(this, "onHeaderRemove", (headerId) => {
8519
8562
  this.setState(
8520
8563
  ({ headers }) => ({
8521
8564
  headers: headers.filter((h) => h.id !== headerId)
@@ -8571,14 +8614,14 @@ var QueryEditorMode = /* @__PURE__ */ ((QueryEditorMode2) => {
8571
8614
  })(QueryEditorMode || {});
8572
8615
  const BINARY_OPERATIONS_KEY = "Binary operations";
8573
8616
 
8574
- var __defProp = Object.defineProperty;
8575
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8576
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8617
+ var __defProp$1 = Object.defineProperty;
8618
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8619
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
8577
8620
  class QueryModellerBase {
8578
8621
  constructor(operationDefinitions, innerQueryPlaceholder) {
8579
- __publicField(this, "operationsRegistry");
8580
- __publicField(this, "categories", []);
8581
- __publicField(this, "innerQueryPlaceholder");
8622
+ __publicField$1(this, "operationsRegistry");
8623
+ __publicField$1(this, "categories", []);
8624
+ __publicField$1(this, "innerQueryPlaceholder");
8582
8625
  this.operationsRegistry = new data.Registry(() => operationDefinitions);
8583
8626
  this.innerQueryPlaceholder = innerQueryPlaceholder || "<query>";
8584
8627
  }
@@ -9843,6 +9886,2988 @@ const convertUnits = (queryStats) => {
9843
9886
  return text + suffix;
9844
9887
  };
9845
9888
 
9889
+ var re = {exports: {}};
9890
+
9891
+ var constants;
9892
+ var hasRequiredConstants;
9893
+
9894
+ function requireConstants () {
9895
+ if (hasRequiredConstants) return constants;
9896
+ hasRequiredConstants = 1;
9897
+
9898
+ // Note: this is the semver.org version of the spec that it implements
9899
+ // Not necessarily the package version of this code.
9900
+ const SEMVER_SPEC_VERSION = '2.0.0';
9901
+
9902
+ const MAX_LENGTH = 256;
9903
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
9904
+ /* istanbul ignore next */ 9007199254740991;
9905
+
9906
+ // Max safe segment length for coercion.
9907
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
9908
+
9909
+ // Max safe length for a build identifier. The max length minus 6 characters for
9910
+ // the shortest version with a build 0.0.0+BUILD.
9911
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
9912
+
9913
+ const RELEASE_TYPES = [
9914
+ 'major',
9915
+ 'premajor',
9916
+ 'minor',
9917
+ 'preminor',
9918
+ 'patch',
9919
+ 'prepatch',
9920
+ 'prerelease',
9921
+ ];
9922
+
9923
+ constants = {
9924
+ MAX_LENGTH,
9925
+ MAX_SAFE_COMPONENT_LENGTH,
9926
+ MAX_SAFE_BUILD_LENGTH,
9927
+ MAX_SAFE_INTEGER,
9928
+ RELEASE_TYPES,
9929
+ SEMVER_SPEC_VERSION,
9930
+ FLAG_INCLUDE_PRERELEASE: 0b001,
9931
+ FLAG_LOOSE: 0b010,
9932
+ };
9933
+ return constants;
9934
+ }
9935
+
9936
+ var debug_1;
9937
+ var hasRequiredDebug;
9938
+
9939
+ function requireDebug () {
9940
+ if (hasRequiredDebug) return debug_1;
9941
+ hasRequiredDebug = 1;
9942
+
9943
+ const debug = (
9944
+ typeof process === 'object' &&
9945
+ process.env &&
9946
+ process.env.NODE_DEBUG &&
9947
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
9948
+ ) ? (...args) => console.error('SEMVER', ...args)
9949
+ : () => {};
9950
+
9951
+ debug_1 = debug;
9952
+ return debug_1;
9953
+ }
9954
+
9955
+ var hasRequiredRe;
9956
+
9957
+ function requireRe () {
9958
+ if (hasRequiredRe) return re.exports;
9959
+ hasRequiredRe = 1;
9960
+ (function (module, exports) {
9961
+
9962
+ const {
9963
+ MAX_SAFE_COMPONENT_LENGTH,
9964
+ MAX_SAFE_BUILD_LENGTH,
9965
+ MAX_LENGTH,
9966
+ } = requireConstants();
9967
+ const debug = requireDebug();
9968
+ exports = module.exports = {};
9969
+
9970
+ // The actual regexps go on exports.re
9971
+ const re = exports.re = [];
9972
+ const safeRe = exports.safeRe = [];
9973
+ const src = exports.src = [];
9974
+ const safeSrc = exports.safeSrc = [];
9975
+ const t = exports.t = {};
9976
+ let R = 0;
9977
+
9978
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
9979
+
9980
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
9981
+ // used internally via the safeRe object since all inputs in this library get
9982
+ // normalized first to trim and collapse all extra whitespace. The original
9983
+ // regexes are exported for userland consumption and lower level usage. A
9984
+ // future breaking change could export the safer regex only with a note that
9985
+ // all input should have extra whitespace removed.
9986
+ const safeRegexReplacements = [
9987
+ ['\\s', 1],
9988
+ ['\\d', MAX_LENGTH],
9989
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
9990
+ ];
9991
+
9992
+ const makeSafeRegex = (value) => {
9993
+ for (const [token, max] of safeRegexReplacements) {
9994
+ value = value
9995
+ .split(`${token}*`).join(`${token}{0,${max}}`)
9996
+ .split(`${token}+`).join(`${token}{1,${max}}`);
9997
+ }
9998
+ return value
9999
+ };
10000
+
10001
+ const createToken = (name, value, isGlobal) => {
10002
+ const safe = makeSafeRegex(value);
10003
+ const index = R++;
10004
+ debug(name, index, value);
10005
+ t[name] = index;
10006
+ src[index] = value;
10007
+ safeSrc[index] = safe;
10008
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
10009
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
10010
+ };
10011
+
10012
+ // The following Regular Expressions can be used for tokenizing,
10013
+ // validating, and parsing SemVer version strings.
10014
+
10015
+ // ## Numeric Identifier
10016
+ // A single `0`, or a non-zero digit followed by zero or more digits.
10017
+
10018
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
10019
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
10020
+
10021
+ // ## Non-numeric Identifier
10022
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
10023
+ // more letters, digits, or hyphens.
10024
+
10025
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
10026
+
10027
+ // ## Main Version
10028
+ // Three dot-separated numeric identifiers.
10029
+
10030
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
10031
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
10032
+ `(${src[t.NUMERICIDENTIFIER]})`);
10033
+
10034
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
10035
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
10036
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
10037
+
10038
+ // ## Pre-release Version Identifier
10039
+ // A numeric identifier, or a non-numeric identifier.
10040
+ // Non-numberic identifiers include numberic identifiers but can be longer.
10041
+ // Therefore non-numberic identifiers must go first.
10042
+
10043
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
10044
+ }|${src[t.NUMERICIDENTIFIER]})`);
10045
+
10046
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
10047
+ }|${src[t.NUMERICIDENTIFIERLOOSE]})`);
10048
+
10049
+ // ## Pre-release Version
10050
+ // Hyphen, followed by one or more dot-separated pre-release version
10051
+ // identifiers.
10052
+
10053
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
10054
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
10055
+
10056
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
10057
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
10058
+
10059
+ // ## Build Metadata Identifier
10060
+ // Any combination of digits, letters, or hyphens.
10061
+
10062
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
10063
+
10064
+ // ## Build Metadata
10065
+ // Plus sign, followed by one or more period-separated build metadata
10066
+ // identifiers.
10067
+
10068
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
10069
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
10070
+
10071
+ // ## Full Version String
10072
+ // A main version, followed optionally by a pre-release version and
10073
+ // build metadata.
10074
+
10075
+ // Note that the only major, minor, patch, and pre-release sections of
10076
+ // the version string are capturing groups. The build metadata is not a
10077
+ // capturing group, because it should not ever be used in version
10078
+ // comparison.
10079
+
10080
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
10081
+ }${src[t.PRERELEASE]}?${
10082
+ src[t.BUILD]}?`);
10083
+
10084
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
10085
+
10086
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
10087
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
10088
+ // common in the npm registry.
10089
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
10090
+ }${src[t.PRERELEASELOOSE]}?${
10091
+ src[t.BUILD]}?`);
10092
+
10093
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
10094
+
10095
+ createToken('GTLT', '((?:<|>)?=?)');
10096
+
10097
+ // Something like "2.*" or "1.2.x".
10098
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
10099
+ // Only the first item is strictly required.
10100
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
10101
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
10102
+
10103
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
10104
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
10105
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
10106
+ `(?:${src[t.PRERELEASE]})?${
10107
+ src[t.BUILD]}?` +
10108
+ `)?)?`);
10109
+
10110
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
10111
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
10112
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
10113
+ `(?:${src[t.PRERELEASELOOSE]})?${
10114
+ src[t.BUILD]}?` +
10115
+ `)?)?`);
10116
+
10117
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
10118
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
10119
+
10120
+ // Coercion.
10121
+ // Extract anything that could conceivably be a part of a valid semver
10122
+ createToken('COERCEPLAIN', `${'(^|[^\\d])' +
10123
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
10124
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
10125
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
10126
+ createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
10127
+ createToken('COERCEFULL', src[t.COERCEPLAIN] +
10128
+ `(?:${src[t.PRERELEASE]})?` +
10129
+ `(?:${src[t.BUILD]})?` +
10130
+ `(?:$|[^\\d])`);
10131
+ createToken('COERCERTL', src[t.COERCE], true);
10132
+ createToken('COERCERTLFULL', src[t.COERCEFULL], true);
10133
+
10134
+ // Tilde ranges.
10135
+ // Meaning is "reasonably at or greater than"
10136
+ createToken('LONETILDE', '(?:~>?)');
10137
+
10138
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
10139
+ exports.tildeTrimReplace = '$1~';
10140
+
10141
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
10142
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
10143
+
10144
+ // Caret ranges.
10145
+ // Meaning is "at least and backwards compatible with"
10146
+ createToken('LONECARET', '(?:\\^)');
10147
+
10148
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
10149
+ exports.caretTrimReplace = '$1^';
10150
+
10151
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
10152
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
10153
+
10154
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
10155
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
10156
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
10157
+
10158
+ // An expression to strip any whitespace between the gtlt and the thing
10159
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
10160
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
10161
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
10162
+ exports.comparatorTrimReplace = '$1$2$3';
10163
+
10164
+ // Something like `1.2.3 - 1.2.4`
10165
+ // Note that these all use the loose form, because they'll be
10166
+ // checked against either the strict or loose comparator form
10167
+ // later.
10168
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
10169
+ `\\s+-\\s+` +
10170
+ `(${src[t.XRANGEPLAIN]})` +
10171
+ `\\s*$`);
10172
+
10173
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
10174
+ `\\s+-\\s+` +
10175
+ `(${src[t.XRANGEPLAINLOOSE]})` +
10176
+ `\\s*$`);
10177
+
10178
+ // Star ranges basically just allow anything at all.
10179
+ createToken('STAR', '(<|>)?=?\\s*\\*');
10180
+ // >=0.0.0 is like a star
10181
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
10182
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
10183
+ } (re, re.exports));
10184
+ return re.exports;
10185
+ }
10186
+
10187
+ var parseOptions_1;
10188
+ var hasRequiredParseOptions;
10189
+
10190
+ function requireParseOptions () {
10191
+ if (hasRequiredParseOptions) return parseOptions_1;
10192
+ hasRequiredParseOptions = 1;
10193
+
10194
+ // parse out just the options we care about
10195
+ const looseOption = Object.freeze({ loose: true });
10196
+ const emptyOpts = Object.freeze({ });
10197
+ const parseOptions = options => {
10198
+ if (!options) {
10199
+ return emptyOpts
10200
+ }
10201
+
10202
+ if (typeof options !== 'object') {
10203
+ return looseOption
10204
+ }
10205
+
10206
+ return options
10207
+ };
10208
+ parseOptions_1 = parseOptions;
10209
+ return parseOptions_1;
10210
+ }
10211
+
10212
+ var identifiers;
10213
+ var hasRequiredIdentifiers;
10214
+
10215
+ function requireIdentifiers () {
10216
+ if (hasRequiredIdentifiers) return identifiers;
10217
+ hasRequiredIdentifiers = 1;
10218
+
10219
+ const numeric = /^[0-9]+$/;
10220
+ const compareIdentifiers = (a, b) => {
10221
+ if (typeof a === 'number' && typeof b === 'number') {
10222
+ return a === b ? 0 : a < b ? -1 : 1
10223
+ }
10224
+
10225
+ const anum = numeric.test(a);
10226
+ const bnum = numeric.test(b);
10227
+
10228
+ if (anum && bnum) {
10229
+ a = +a;
10230
+ b = +b;
10231
+ }
10232
+
10233
+ return a === b ? 0
10234
+ : (anum && !bnum) ? -1
10235
+ : (bnum && !anum) ? 1
10236
+ : a < b ? -1
10237
+ : 1
10238
+ };
10239
+
10240
+ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
10241
+
10242
+ identifiers = {
10243
+ compareIdentifiers,
10244
+ rcompareIdentifiers,
10245
+ };
10246
+ return identifiers;
10247
+ }
10248
+
10249
+ var semver$1;
10250
+ var hasRequiredSemver$1;
10251
+
10252
+ function requireSemver$1 () {
10253
+ if (hasRequiredSemver$1) return semver$1;
10254
+ hasRequiredSemver$1 = 1;
10255
+
10256
+ const debug = requireDebug();
10257
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
10258
+ const { safeRe: re, t } = requireRe();
10259
+
10260
+ const parseOptions = requireParseOptions();
10261
+ const { compareIdentifiers } = requireIdentifiers();
10262
+ class SemVer {
10263
+ constructor (version, options) {
10264
+ options = parseOptions(options);
10265
+
10266
+ if (version instanceof SemVer) {
10267
+ if (version.loose === !!options.loose &&
10268
+ version.includePrerelease === !!options.includePrerelease) {
10269
+ return version
10270
+ } else {
10271
+ version = version.version;
10272
+ }
10273
+ } else if (typeof version !== 'string') {
10274
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
10275
+ }
10276
+
10277
+ if (version.length > MAX_LENGTH) {
10278
+ throw new TypeError(
10279
+ `version is longer than ${MAX_LENGTH} characters`
10280
+ )
10281
+ }
10282
+
10283
+ debug('SemVer', version, options);
10284
+ this.options = options;
10285
+ this.loose = !!options.loose;
10286
+ // this isn't actually relevant for versions, but keep it so that we
10287
+ // don't run into trouble passing this.options around.
10288
+ this.includePrerelease = !!options.includePrerelease;
10289
+
10290
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
10291
+
10292
+ if (!m) {
10293
+ throw new TypeError(`Invalid Version: ${version}`)
10294
+ }
10295
+
10296
+ this.raw = version;
10297
+
10298
+ // these are actually numbers
10299
+ this.major = +m[1];
10300
+ this.minor = +m[2];
10301
+ this.patch = +m[3];
10302
+
10303
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
10304
+ throw new TypeError('Invalid major version')
10305
+ }
10306
+
10307
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
10308
+ throw new TypeError('Invalid minor version')
10309
+ }
10310
+
10311
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
10312
+ throw new TypeError('Invalid patch version')
10313
+ }
10314
+
10315
+ // numberify any prerelease numeric ids
10316
+ if (!m[4]) {
10317
+ this.prerelease = [];
10318
+ } else {
10319
+ this.prerelease = m[4].split('.').map((id) => {
10320
+ if (/^[0-9]+$/.test(id)) {
10321
+ const num = +id;
10322
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
10323
+ return num
10324
+ }
10325
+ }
10326
+ return id
10327
+ });
10328
+ }
10329
+
10330
+ this.build = m[5] ? m[5].split('.') : [];
10331
+ this.format();
10332
+ }
10333
+
10334
+ format () {
10335
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
10336
+ if (this.prerelease.length) {
10337
+ this.version += `-${this.prerelease.join('.')}`;
10338
+ }
10339
+ return this.version
10340
+ }
10341
+
10342
+ toString () {
10343
+ return this.version
10344
+ }
10345
+
10346
+ compare (other) {
10347
+ debug('SemVer.compare', this.version, this.options, other);
10348
+ if (!(other instanceof SemVer)) {
10349
+ if (typeof other === 'string' && other === this.version) {
10350
+ return 0
10351
+ }
10352
+ other = new SemVer(other, this.options);
10353
+ }
10354
+
10355
+ if (other.version === this.version) {
10356
+ return 0
10357
+ }
10358
+
10359
+ return this.compareMain(other) || this.comparePre(other)
10360
+ }
10361
+
10362
+ compareMain (other) {
10363
+ if (!(other instanceof SemVer)) {
10364
+ other = new SemVer(other, this.options);
10365
+ }
10366
+
10367
+ if (this.major < other.major) {
10368
+ return -1
10369
+ }
10370
+ if (this.major > other.major) {
10371
+ return 1
10372
+ }
10373
+ if (this.minor < other.minor) {
10374
+ return -1
10375
+ }
10376
+ if (this.minor > other.minor) {
10377
+ return 1
10378
+ }
10379
+ if (this.patch < other.patch) {
10380
+ return -1
10381
+ }
10382
+ if (this.patch > other.patch) {
10383
+ return 1
10384
+ }
10385
+ return 0
10386
+ }
10387
+
10388
+ comparePre (other) {
10389
+ if (!(other instanceof SemVer)) {
10390
+ other = new SemVer(other, this.options);
10391
+ }
10392
+
10393
+ // NOT having a prerelease is > having one
10394
+ if (this.prerelease.length && !other.prerelease.length) {
10395
+ return -1
10396
+ } else if (!this.prerelease.length && other.prerelease.length) {
10397
+ return 1
10398
+ } else if (!this.prerelease.length && !other.prerelease.length) {
10399
+ return 0
10400
+ }
10401
+
10402
+ let i = 0;
10403
+ do {
10404
+ const a = this.prerelease[i];
10405
+ const b = other.prerelease[i];
10406
+ debug('prerelease compare', i, a, b);
10407
+ if (a === undefined && b === undefined) {
10408
+ return 0
10409
+ } else if (b === undefined) {
10410
+ return 1
10411
+ } else if (a === undefined) {
10412
+ return -1
10413
+ } else if (a === b) {
10414
+ continue
10415
+ } else {
10416
+ return compareIdentifiers(a, b)
10417
+ }
10418
+ } while (++i)
10419
+ }
10420
+
10421
+ compareBuild (other) {
10422
+ if (!(other instanceof SemVer)) {
10423
+ other = new SemVer(other, this.options);
10424
+ }
10425
+
10426
+ let i = 0;
10427
+ do {
10428
+ const a = this.build[i];
10429
+ const b = other.build[i];
10430
+ debug('build compare', i, a, b);
10431
+ if (a === undefined && b === undefined) {
10432
+ return 0
10433
+ } else if (b === undefined) {
10434
+ return 1
10435
+ } else if (a === undefined) {
10436
+ return -1
10437
+ } else if (a === b) {
10438
+ continue
10439
+ } else {
10440
+ return compareIdentifiers(a, b)
10441
+ }
10442
+ } while (++i)
10443
+ }
10444
+
10445
+ // preminor will bump the version up to the next minor release, and immediately
10446
+ // down to pre-release. premajor and prepatch work the same way.
10447
+ inc (release, identifier, identifierBase) {
10448
+ if (release.startsWith('pre')) {
10449
+ if (!identifier && identifierBase === false) {
10450
+ throw new Error('invalid increment argument: identifier is empty')
10451
+ }
10452
+ // Avoid an invalid semver results
10453
+ if (identifier) {
10454
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
10455
+ if (!match || match[1] !== identifier) {
10456
+ throw new Error(`invalid identifier: ${identifier}`)
10457
+ }
10458
+ }
10459
+ }
10460
+
10461
+ switch (release) {
10462
+ case 'premajor':
10463
+ this.prerelease.length = 0;
10464
+ this.patch = 0;
10465
+ this.minor = 0;
10466
+ this.major++;
10467
+ this.inc('pre', identifier, identifierBase);
10468
+ break
10469
+ case 'preminor':
10470
+ this.prerelease.length = 0;
10471
+ this.patch = 0;
10472
+ this.minor++;
10473
+ this.inc('pre', identifier, identifierBase);
10474
+ break
10475
+ case 'prepatch':
10476
+ // If this is already a prerelease, it will bump to the next version
10477
+ // drop any prereleases that might already exist, since they are not
10478
+ // relevant at this point.
10479
+ this.prerelease.length = 0;
10480
+ this.inc('patch', identifier, identifierBase);
10481
+ this.inc('pre', identifier, identifierBase);
10482
+ break
10483
+ // If the input is a non-prerelease version, this acts the same as
10484
+ // prepatch.
10485
+ case 'prerelease':
10486
+ if (this.prerelease.length === 0) {
10487
+ this.inc('patch', identifier, identifierBase);
10488
+ }
10489
+ this.inc('pre', identifier, identifierBase);
10490
+ break
10491
+ case 'release':
10492
+ if (this.prerelease.length === 0) {
10493
+ throw new Error(`version ${this.raw} is not a prerelease`)
10494
+ }
10495
+ this.prerelease.length = 0;
10496
+ break
10497
+
10498
+ case 'major':
10499
+ // If this is a pre-major version, bump up to the same major version.
10500
+ // Otherwise increment major.
10501
+ // 1.0.0-5 bumps to 1.0.0
10502
+ // 1.1.0 bumps to 2.0.0
10503
+ if (
10504
+ this.minor !== 0 ||
10505
+ this.patch !== 0 ||
10506
+ this.prerelease.length === 0
10507
+ ) {
10508
+ this.major++;
10509
+ }
10510
+ this.minor = 0;
10511
+ this.patch = 0;
10512
+ this.prerelease = [];
10513
+ break
10514
+ case 'minor':
10515
+ // If this is a pre-minor version, bump up to the same minor version.
10516
+ // Otherwise increment minor.
10517
+ // 1.2.0-5 bumps to 1.2.0
10518
+ // 1.2.1 bumps to 1.3.0
10519
+ if (this.patch !== 0 || this.prerelease.length === 0) {
10520
+ this.minor++;
10521
+ }
10522
+ this.patch = 0;
10523
+ this.prerelease = [];
10524
+ break
10525
+ case 'patch':
10526
+ // If this is not a pre-release version, it will increment the patch.
10527
+ // If it is a pre-release it will bump up to the same patch version.
10528
+ // 1.2.0-5 patches to 1.2.0
10529
+ // 1.2.0 patches to 1.2.1
10530
+ if (this.prerelease.length === 0) {
10531
+ this.patch++;
10532
+ }
10533
+ this.prerelease = [];
10534
+ break
10535
+ // This probably shouldn't be used publicly.
10536
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
10537
+ case 'pre': {
10538
+ const base = Number(identifierBase) ? 1 : 0;
10539
+
10540
+ if (this.prerelease.length === 0) {
10541
+ this.prerelease = [base];
10542
+ } else {
10543
+ let i = this.prerelease.length;
10544
+ while (--i >= 0) {
10545
+ if (typeof this.prerelease[i] === 'number') {
10546
+ this.prerelease[i]++;
10547
+ i = -2;
10548
+ }
10549
+ }
10550
+ if (i === -1) {
10551
+ // didn't increment anything
10552
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
10553
+ throw new Error('invalid increment argument: identifier already exists')
10554
+ }
10555
+ this.prerelease.push(base);
10556
+ }
10557
+ }
10558
+ if (identifier) {
10559
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
10560
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
10561
+ let prerelease = [identifier, base];
10562
+ if (identifierBase === false) {
10563
+ prerelease = [identifier];
10564
+ }
10565
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
10566
+ if (isNaN(this.prerelease[1])) {
10567
+ this.prerelease = prerelease;
10568
+ }
10569
+ } else {
10570
+ this.prerelease = prerelease;
10571
+ }
10572
+ }
10573
+ break
10574
+ }
10575
+ default:
10576
+ throw new Error(`invalid increment argument: ${release}`)
10577
+ }
10578
+ this.raw = this.format();
10579
+ if (this.build.length) {
10580
+ this.raw += `+${this.build.join('.')}`;
10581
+ }
10582
+ return this
10583
+ }
10584
+ }
10585
+
10586
+ semver$1 = SemVer;
10587
+ return semver$1;
10588
+ }
10589
+
10590
+ var parse_1;
10591
+ var hasRequiredParse;
10592
+
10593
+ function requireParse () {
10594
+ if (hasRequiredParse) return parse_1;
10595
+ hasRequiredParse = 1;
10596
+
10597
+ const SemVer = requireSemver$1();
10598
+ const parse = (version, options, throwErrors = false) => {
10599
+ if (version instanceof SemVer) {
10600
+ return version
10601
+ }
10602
+ try {
10603
+ return new SemVer(version, options)
10604
+ } catch (er) {
10605
+ if (!throwErrors) {
10606
+ return null
10607
+ }
10608
+ throw er
10609
+ }
10610
+ };
10611
+
10612
+ parse_1 = parse;
10613
+ return parse_1;
10614
+ }
10615
+
10616
+ var valid_1;
10617
+ var hasRequiredValid$1;
10618
+
10619
+ function requireValid$1 () {
10620
+ if (hasRequiredValid$1) return valid_1;
10621
+ hasRequiredValid$1 = 1;
10622
+
10623
+ const parse = requireParse();
10624
+ const valid = (version, options) => {
10625
+ const v = parse(version, options);
10626
+ return v ? v.version : null
10627
+ };
10628
+ valid_1 = valid;
10629
+ return valid_1;
10630
+ }
10631
+
10632
+ var clean_1;
10633
+ var hasRequiredClean;
10634
+
10635
+ function requireClean () {
10636
+ if (hasRequiredClean) return clean_1;
10637
+ hasRequiredClean = 1;
10638
+
10639
+ const parse = requireParse();
10640
+ const clean = (version, options) => {
10641
+ const s = parse(version.trim().replace(/^[=v]+/, ''), options);
10642
+ return s ? s.version : null
10643
+ };
10644
+ clean_1 = clean;
10645
+ return clean_1;
10646
+ }
10647
+
10648
+ var inc_1;
10649
+ var hasRequiredInc;
10650
+
10651
+ function requireInc () {
10652
+ if (hasRequiredInc) return inc_1;
10653
+ hasRequiredInc = 1;
10654
+
10655
+ const SemVer = requireSemver$1();
10656
+
10657
+ const inc = (version, release, options, identifier, identifierBase) => {
10658
+ if (typeof (options) === 'string') {
10659
+ identifierBase = identifier;
10660
+ identifier = options;
10661
+ options = undefined;
10662
+ }
10663
+
10664
+ try {
10665
+ return new SemVer(
10666
+ version instanceof SemVer ? version.version : version,
10667
+ options
10668
+ ).inc(release, identifier, identifierBase).version
10669
+ } catch (er) {
10670
+ return null
10671
+ }
10672
+ };
10673
+ inc_1 = inc;
10674
+ return inc_1;
10675
+ }
10676
+
10677
+ var diff_1;
10678
+ var hasRequiredDiff;
10679
+
10680
+ function requireDiff () {
10681
+ if (hasRequiredDiff) return diff_1;
10682
+ hasRequiredDiff = 1;
10683
+
10684
+ const parse = requireParse();
10685
+
10686
+ const diff = (version1, version2) => {
10687
+ const v1 = parse(version1, null, true);
10688
+ const v2 = parse(version2, null, true);
10689
+ const comparison = v1.compare(v2);
10690
+
10691
+ if (comparison === 0) {
10692
+ return null
10693
+ }
10694
+
10695
+ const v1Higher = comparison > 0;
10696
+ const highVersion = v1Higher ? v1 : v2;
10697
+ const lowVersion = v1Higher ? v2 : v1;
10698
+ const highHasPre = !!highVersion.prerelease.length;
10699
+ const lowHasPre = !!lowVersion.prerelease.length;
10700
+
10701
+ if (lowHasPre && !highHasPre) {
10702
+ // Going from prerelease -> no prerelease requires some special casing
10703
+
10704
+ // If the low version has only a major, then it will always be a major
10705
+ // Some examples:
10706
+ // 1.0.0-1 -> 1.0.0
10707
+ // 1.0.0-1 -> 1.1.1
10708
+ // 1.0.0-1 -> 2.0.0
10709
+ if (!lowVersion.patch && !lowVersion.minor) {
10710
+ return 'major'
10711
+ }
10712
+
10713
+ // If the main part has no difference
10714
+ if (lowVersion.compareMain(highVersion) === 0) {
10715
+ if (lowVersion.minor && !lowVersion.patch) {
10716
+ return 'minor'
10717
+ }
10718
+ return 'patch'
10719
+ }
10720
+ }
10721
+
10722
+ // add the `pre` prefix if we are going to a prerelease version
10723
+ const prefix = highHasPre ? 'pre' : '';
10724
+
10725
+ if (v1.major !== v2.major) {
10726
+ return prefix + 'major'
10727
+ }
10728
+
10729
+ if (v1.minor !== v2.minor) {
10730
+ return prefix + 'minor'
10731
+ }
10732
+
10733
+ if (v1.patch !== v2.patch) {
10734
+ return prefix + 'patch'
10735
+ }
10736
+
10737
+ // high and low are preleases
10738
+ return 'prerelease'
10739
+ };
10740
+
10741
+ diff_1 = diff;
10742
+ return diff_1;
10743
+ }
10744
+
10745
+ var major_1;
10746
+ var hasRequiredMajor;
10747
+
10748
+ function requireMajor () {
10749
+ if (hasRequiredMajor) return major_1;
10750
+ hasRequiredMajor = 1;
10751
+
10752
+ const SemVer = requireSemver$1();
10753
+ const major = (a, loose) => new SemVer(a, loose).major;
10754
+ major_1 = major;
10755
+ return major_1;
10756
+ }
10757
+
10758
+ var minor_1;
10759
+ var hasRequiredMinor;
10760
+
10761
+ function requireMinor () {
10762
+ if (hasRequiredMinor) return minor_1;
10763
+ hasRequiredMinor = 1;
10764
+
10765
+ const SemVer = requireSemver$1();
10766
+ const minor = (a, loose) => new SemVer(a, loose).minor;
10767
+ minor_1 = minor;
10768
+ return minor_1;
10769
+ }
10770
+
10771
+ var patch_1;
10772
+ var hasRequiredPatch;
10773
+
10774
+ function requirePatch () {
10775
+ if (hasRequiredPatch) return patch_1;
10776
+ hasRequiredPatch = 1;
10777
+
10778
+ const SemVer = requireSemver$1();
10779
+ const patch = (a, loose) => new SemVer(a, loose).patch;
10780
+ patch_1 = patch;
10781
+ return patch_1;
10782
+ }
10783
+
10784
+ var prerelease_1;
10785
+ var hasRequiredPrerelease;
10786
+
10787
+ function requirePrerelease () {
10788
+ if (hasRequiredPrerelease) return prerelease_1;
10789
+ hasRequiredPrerelease = 1;
10790
+
10791
+ const parse = requireParse();
10792
+ const prerelease = (version, options) => {
10793
+ const parsed = parse(version, options);
10794
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
10795
+ };
10796
+ prerelease_1 = prerelease;
10797
+ return prerelease_1;
10798
+ }
10799
+
10800
+ var compare_1;
10801
+ var hasRequiredCompare;
10802
+
10803
+ function requireCompare () {
10804
+ if (hasRequiredCompare) return compare_1;
10805
+ hasRequiredCompare = 1;
10806
+
10807
+ const SemVer = requireSemver$1();
10808
+ const compare = (a, b, loose) =>
10809
+ new SemVer(a, loose).compare(new SemVer(b, loose));
10810
+
10811
+ compare_1 = compare;
10812
+ return compare_1;
10813
+ }
10814
+
10815
+ var rcompare_1;
10816
+ var hasRequiredRcompare;
10817
+
10818
+ function requireRcompare () {
10819
+ if (hasRequiredRcompare) return rcompare_1;
10820
+ hasRequiredRcompare = 1;
10821
+
10822
+ const compare = requireCompare();
10823
+ const rcompare = (a, b, loose) => compare(b, a, loose);
10824
+ rcompare_1 = rcompare;
10825
+ return rcompare_1;
10826
+ }
10827
+
10828
+ var compareLoose_1;
10829
+ var hasRequiredCompareLoose;
10830
+
10831
+ function requireCompareLoose () {
10832
+ if (hasRequiredCompareLoose) return compareLoose_1;
10833
+ hasRequiredCompareLoose = 1;
10834
+
10835
+ const compare = requireCompare();
10836
+ const compareLoose = (a, b) => compare(a, b, true);
10837
+ compareLoose_1 = compareLoose;
10838
+ return compareLoose_1;
10839
+ }
10840
+
10841
+ var compareBuild_1;
10842
+ var hasRequiredCompareBuild;
10843
+
10844
+ function requireCompareBuild () {
10845
+ if (hasRequiredCompareBuild) return compareBuild_1;
10846
+ hasRequiredCompareBuild = 1;
10847
+
10848
+ const SemVer = requireSemver$1();
10849
+ const compareBuild = (a, b, loose) => {
10850
+ const versionA = new SemVer(a, loose);
10851
+ const versionB = new SemVer(b, loose);
10852
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
10853
+ };
10854
+ compareBuild_1 = compareBuild;
10855
+ return compareBuild_1;
10856
+ }
10857
+
10858
+ var sort_1;
10859
+ var hasRequiredSort;
10860
+
10861
+ function requireSort () {
10862
+ if (hasRequiredSort) return sort_1;
10863
+ hasRequiredSort = 1;
10864
+
10865
+ const compareBuild = requireCompareBuild();
10866
+ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
10867
+ sort_1 = sort;
10868
+ return sort_1;
10869
+ }
10870
+
10871
+ var rsort_1;
10872
+ var hasRequiredRsort;
10873
+
10874
+ function requireRsort () {
10875
+ if (hasRequiredRsort) return rsort_1;
10876
+ hasRequiredRsort = 1;
10877
+
10878
+ const compareBuild = requireCompareBuild();
10879
+ const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
10880
+ rsort_1 = rsort;
10881
+ return rsort_1;
10882
+ }
10883
+
10884
+ var gt_1;
10885
+ var hasRequiredGt;
10886
+
10887
+ function requireGt () {
10888
+ if (hasRequiredGt) return gt_1;
10889
+ hasRequiredGt = 1;
10890
+
10891
+ const compare = requireCompare();
10892
+ const gt = (a, b, loose) => compare(a, b, loose) > 0;
10893
+ gt_1 = gt;
10894
+ return gt_1;
10895
+ }
10896
+
10897
+ var lt_1;
10898
+ var hasRequiredLt;
10899
+
10900
+ function requireLt () {
10901
+ if (hasRequiredLt) return lt_1;
10902
+ hasRequiredLt = 1;
10903
+
10904
+ const compare = requireCompare();
10905
+ const lt = (a, b, loose) => compare(a, b, loose) < 0;
10906
+ lt_1 = lt;
10907
+ return lt_1;
10908
+ }
10909
+
10910
+ var eq_1;
10911
+ var hasRequiredEq;
10912
+
10913
+ function requireEq () {
10914
+ if (hasRequiredEq) return eq_1;
10915
+ hasRequiredEq = 1;
10916
+
10917
+ const compare = requireCompare();
10918
+ const eq = (a, b, loose) => compare(a, b, loose) === 0;
10919
+ eq_1 = eq;
10920
+ return eq_1;
10921
+ }
10922
+
10923
+ var neq_1;
10924
+ var hasRequiredNeq;
10925
+
10926
+ function requireNeq () {
10927
+ if (hasRequiredNeq) return neq_1;
10928
+ hasRequiredNeq = 1;
10929
+
10930
+ const compare = requireCompare();
10931
+ const neq = (a, b, loose) => compare(a, b, loose) !== 0;
10932
+ neq_1 = neq;
10933
+ return neq_1;
10934
+ }
10935
+
10936
+ var gte_1;
10937
+ var hasRequiredGte;
10938
+
10939
+ function requireGte () {
10940
+ if (hasRequiredGte) return gte_1;
10941
+ hasRequiredGte = 1;
10942
+
10943
+ const compare = requireCompare();
10944
+ const gte = (a, b, loose) => compare(a, b, loose) >= 0;
10945
+ gte_1 = gte;
10946
+ return gte_1;
10947
+ }
10948
+
10949
+ var lte_1;
10950
+ var hasRequiredLte;
10951
+
10952
+ function requireLte () {
10953
+ if (hasRequiredLte) return lte_1;
10954
+ hasRequiredLte = 1;
10955
+
10956
+ const compare = requireCompare();
10957
+ const lte = (a, b, loose) => compare(a, b, loose) <= 0;
10958
+ lte_1 = lte;
10959
+ return lte_1;
10960
+ }
10961
+
10962
+ var cmp_1;
10963
+ var hasRequiredCmp;
10964
+
10965
+ function requireCmp () {
10966
+ if (hasRequiredCmp) return cmp_1;
10967
+ hasRequiredCmp = 1;
10968
+
10969
+ const eq = requireEq();
10970
+ const neq = requireNeq();
10971
+ const gt = requireGt();
10972
+ const gte = requireGte();
10973
+ const lt = requireLt();
10974
+ const lte = requireLte();
10975
+
10976
+ const cmp = (a, op, b, loose) => {
10977
+ switch (op) {
10978
+ case '===':
10979
+ if (typeof a === 'object') {
10980
+ a = a.version;
10981
+ }
10982
+ if (typeof b === 'object') {
10983
+ b = b.version;
10984
+ }
10985
+ return a === b
10986
+
10987
+ case '!==':
10988
+ if (typeof a === 'object') {
10989
+ a = a.version;
10990
+ }
10991
+ if (typeof b === 'object') {
10992
+ b = b.version;
10993
+ }
10994
+ return a !== b
10995
+
10996
+ case '':
10997
+ case '=':
10998
+ case '==':
10999
+ return eq(a, b, loose)
11000
+
11001
+ case '!=':
11002
+ return neq(a, b, loose)
11003
+
11004
+ case '>':
11005
+ return gt(a, b, loose)
11006
+
11007
+ case '>=':
11008
+ return gte(a, b, loose)
11009
+
11010
+ case '<':
11011
+ return lt(a, b, loose)
11012
+
11013
+ case '<=':
11014
+ return lte(a, b, loose)
11015
+
11016
+ default:
11017
+ throw new TypeError(`Invalid operator: ${op}`)
11018
+ }
11019
+ };
11020
+ cmp_1 = cmp;
11021
+ return cmp_1;
11022
+ }
11023
+
11024
+ var coerce_1;
11025
+ var hasRequiredCoerce;
11026
+
11027
+ function requireCoerce () {
11028
+ if (hasRequiredCoerce) return coerce_1;
11029
+ hasRequiredCoerce = 1;
11030
+
11031
+ const SemVer = requireSemver$1();
11032
+ const parse = requireParse();
11033
+ const { safeRe: re, t } = requireRe();
11034
+
11035
+ const coerce = (version, options) => {
11036
+ if (version instanceof SemVer) {
11037
+ return version
11038
+ }
11039
+
11040
+ if (typeof version === 'number') {
11041
+ version = String(version);
11042
+ }
11043
+
11044
+ if (typeof version !== 'string') {
11045
+ return null
11046
+ }
11047
+
11048
+ options = options || {};
11049
+
11050
+ let match = null;
11051
+ if (!options.rtl) {
11052
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
11053
+ } else {
11054
+ // Find the right-most coercible string that does not share
11055
+ // a terminus with a more left-ward coercible string.
11056
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
11057
+ // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
11058
+ //
11059
+ // Walk through the string checking with a /g regexp
11060
+ // Manually set the index so as to pick up overlapping matches.
11061
+ // Stop when we get a match that ends at the string end, since no
11062
+ // coercible string can be more right-ward without the same terminus.
11063
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
11064
+ let next;
11065
+ while ((next = coerceRtlRegex.exec(version)) &&
11066
+ (!match || match.index + match[0].length !== version.length)
11067
+ ) {
11068
+ if (!match ||
11069
+ next.index + next[0].length !== match.index + match[0].length) {
11070
+ match = next;
11071
+ }
11072
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
11073
+ }
11074
+ // leave it in a clean state
11075
+ coerceRtlRegex.lastIndex = -1;
11076
+ }
11077
+
11078
+ if (match === null) {
11079
+ return null
11080
+ }
11081
+
11082
+ const major = match[2];
11083
+ const minor = match[3] || '0';
11084
+ const patch = match[4] || '0';
11085
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
11086
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
11087
+
11088
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
11089
+ };
11090
+ coerce_1 = coerce;
11091
+ return coerce_1;
11092
+ }
11093
+
11094
+ var lrucache;
11095
+ var hasRequiredLrucache;
11096
+
11097
+ function requireLrucache () {
11098
+ if (hasRequiredLrucache) return lrucache;
11099
+ hasRequiredLrucache = 1;
11100
+
11101
+ class LRUCache {
11102
+ constructor () {
11103
+ this.max = 1000;
11104
+ this.map = new Map();
11105
+ }
11106
+
11107
+ get (key) {
11108
+ const value = this.map.get(key);
11109
+ if (value === undefined) {
11110
+ return undefined
11111
+ } else {
11112
+ // Remove the key from the map and add it to the end
11113
+ this.map.delete(key);
11114
+ this.map.set(key, value);
11115
+ return value
11116
+ }
11117
+ }
11118
+
11119
+ delete (key) {
11120
+ return this.map.delete(key)
11121
+ }
11122
+
11123
+ set (key, value) {
11124
+ const deleted = this.delete(key);
11125
+
11126
+ if (!deleted && value !== undefined) {
11127
+ // If cache is full, delete the least recently used item
11128
+ if (this.map.size >= this.max) {
11129
+ const firstKey = this.map.keys().next().value;
11130
+ this.delete(firstKey);
11131
+ }
11132
+
11133
+ this.map.set(key, value);
11134
+ }
11135
+
11136
+ return this
11137
+ }
11138
+ }
11139
+
11140
+ lrucache = LRUCache;
11141
+ return lrucache;
11142
+ }
11143
+
11144
+ var range;
11145
+ var hasRequiredRange;
11146
+
11147
+ function requireRange () {
11148
+ if (hasRequiredRange) return range;
11149
+ hasRequiredRange = 1;
11150
+
11151
+ const SPACE_CHARACTERS = /\s+/g;
11152
+
11153
+ // hoisted class for cyclic dependency
11154
+ class Range {
11155
+ constructor (range, options) {
11156
+ options = parseOptions(options);
11157
+
11158
+ if (range instanceof Range) {
11159
+ if (
11160
+ range.loose === !!options.loose &&
11161
+ range.includePrerelease === !!options.includePrerelease
11162
+ ) {
11163
+ return range
11164
+ } else {
11165
+ return new Range(range.raw, options)
11166
+ }
11167
+ }
11168
+
11169
+ if (range instanceof Comparator) {
11170
+ // just put it in the set and return
11171
+ this.raw = range.value;
11172
+ this.set = [[range]];
11173
+ this.formatted = undefined;
11174
+ return this
11175
+ }
11176
+
11177
+ this.options = options;
11178
+ this.loose = !!options.loose;
11179
+ this.includePrerelease = !!options.includePrerelease;
11180
+
11181
+ // First reduce all whitespace as much as possible so we do not have to rely
11182
+ // on potentially slow regexes like \s*. This is then stored and used for
11183
+ // future error messages as well.
11184
+ this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
11185
+
11186
+ // First, split on ||
11187
+ this.set = this.raw
11188
+ .split('||')
11189
+ // map the range to a 2d array of comparators
11190
+ .map(r => this.parseRange(r.trim()))
11191
+ // throw out any comparator lists that are empty
11192
+ // this generally means that it was not a valid range, which is allowed
11193
+ // in loose mode, but will still throw if the WHOLE range is invalid.
11194
+ .filter(c => c.length);
11195
+
11196
+ if (!this.set.length) {
11197
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
11198
+ }
11199
+
11200
+ // if we have any that are not the null set, throw out null sets.
11201
+ if (this.set.length > 1) {
11202
+ // keep the first one, in case they're all null sets
11203
+ const first = this.set[0];
11204
+ this.set = this.set.filter(c => !isNullSet(c[0]));
11205
+ if (this.set.length === 0) {
11206
+ this.set = [first];
11207
+ } else if (this.set.length > 1) {
11208
+ // if we have any that are *, then the range is just *
11209
+ for (const c of this.set) {
11210
+ if (c.length === 1 && isAny(c[0])) {
11211
+ this.set = [c];
11212
+ break
11213
+ }
11214
+ }
11215
+ }
11216
+ }
11217
+
11218
+ this.formatted = undefined;
11219
+ }
11220
+
11221
+ get range () {
11222
+ if (this.formatted === undefined) {
11223
+ this.formatted = '';
11224
+ for (let i = 0; i < this.set.length; i++) {
11225
+ if (i > 0) {
11226
+ this.formatted += '||';
11227
+ }
11228
+ const comps = this.set[i];
11229
+ for (let k = 0; k < comps.length; k++) {
11230
+ if (k > 0) {
11231
+ this.formatted += ' ';
11232
+ }
11233
+ this.formatted += comps[k].toString().trim();
11234
+ }
11235
+ }
11236
+ }
11237
+ return this.formatted
11238
+ }
11239
+
11240
+ format () {
11241
+ return this.range
11242
+ }
11243
+
11244
+ toString () {
11245
+ return this.range
11246
+ }
11247
+
11248
+ parseRange (range) {
11249
+ // memoize range parsing for performance.
11250
+ // this is a very hot path, and fully deterministic.
11251
+ const memoOpts =
11252
+ (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
11253
+ (this.options.loose && FLAG_LOOSE);
11254
+ const memoKey = memoOpts + ':' + range;
11255
+ const cached = cache.get(memoKey);
11256
+ if (cached) {
11257
+ return cached
11258
+ }
11259
+
11260
+ const loose = this.options.loose;
11261
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
11262
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
11263
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
11264
+ debug('hyphen replace', range);
11265
+
11266
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
11267
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
11268
+ debug('comparator trim', range);
11269
+
11270
+ // `~ 1.2.3` => `~1.2.3`
11271
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
11272
+ debug('tilde trim', range);
11273
+
11274
+ // `^ 1.2.3` => `^1.2.3`
11275
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
11276
+ debug('caret trim', range);
11277
+
11278
+ // At this point, the range is completely trimmed and
11279
+ // ready to be split into comparators.
11280
+
11281
+ let rangeList = range
11282
+ .split(' ')
11283
+ .map(comp => parseComparator(comp, this.options))
11284
+ .join(' ')
11285
+ .split(/\s+/)
11286
+ // >=0.0.0 is equivalent to *
11287
+ .map(comp => replaceGTE0(comp, this.options));
11288
+
11289
+ if (loose) {
11290
+ // in loose mode, throw out any that are not valid comparators
11291
+ rangeList = rangeList.filter(comp => {
11292
+ debug('loose invalid filter', comp, this.options);
11293
+ return !!comp.match(re[t.COMPARATORLOOSE])
11294
+ });
11295
+ }
11296
+ debug('range list', rangeList);
11297
+
11298
+ // if any comparators are the null set, then replace with JUST null set
11299
+ // if more than one comparator, remove any * comparators
11300
+ // also, don't include the same comparator more than once
11301
+ const rangeMap = new Map();
11302
+ const comparators = rangeList.map(comp => new Comparator(comp, this.options));
11303
+ for (const comp of comparators) {
11304
+ if (isNullSet(comp)) {
11305
+ return [comp]
11306
+ }
11307
+ rangeMap.set(comp.value, comp);
11308
+ }
11309
+ if (rangeMap.size > 1 && rangeMap.has('')) {
11310
+ rangeMap.delete('');
11311
+ }
11312
+
11313
+ const result = [...rangeMap.values()];
11314
+ cache.set(memoKey, result);
11315
+ return result
11316
+ }
11317
+
11318
+ intersects (range, options) {
11319
+ if (!(range instanceof Range)) {
11320
+ throw new TypeError('a Range is required')
11321
+ }
11322
+
11323
+ return this.set.some((thisComparators) => {
11324
+ return (
11325
+ isSatisfiable(thisComparators, options) &&
11326
+ range.set.some((rangeComparators) => {
11327
+ return (
11328
+ isSatisfiable(rangeComparators, options) &&
11329
+ thisComparators.every((thisComparator) => {
11330
+ return rangeComparators.every((rangeComparator) => {
11331
+ return thisComparator.intersects(rangeComparator, options)
11332
+ })
11333
+ })
11334
+ )
11335
+ })
11336
+ )
11337
+ })
11338
+ }
11339
+
11340
+ // if ANY of the sets match ALL of its comparators, then pass
11341
+ test (version) {
11342
+ if (!version) {
11343
+ return false
11344
+ }
11345
+
11346
+ if (typeof version === 'string') {
11347
+ try {
11348
+ version = new SemVer(version, this.options);
11349
+ } catch (er) {
11350
+ return false
11351
+ }
11352
+ }
11353
+
11354
+ for (let i = 0; i < this.set.length; i++) {
11355
+ if (testSet(this.set[i], version, this.options)) {
11356
+ return true
11357
+ }
11358
+ }
11359
+ return false
11360
+ }
11361
+ }
11362
+
11363
+ range = Range;
11364
+
11365
+ const LRU = requireLrucache();
11366
+ const cache = new LRU();
11367
+
11368
+ const parseOptions = requireParseOptions();
11369
+ const Comparator = requireComparator();
11370
+ const debug = requireDebug();
11371
+ const SemVer = requireSemver$1();
11372
+ const {
11373
+ safeRe: re,
11374
+ t,
11375
+ comparatorTrimReplace,
11376
+ tildeTrimReplace,
11377
+ caretTrimReplace,
11378
+ } = requireRe();
11379
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = requireConstants();
11380
+
11381
+ const isNullSet = c => c.value === '<0.0.0-0';
11382
+ const isAny = c => c.value === '';
11383
+
11384
+ // take a set of comparators and determine whether there
11385
+ // exists a version which can satisfy it
11386
+ const isSatisfiable = (comparators, options) => {
11387
+ let result = true;
11388
+ const remainingComparators = comparators.slice();
11389
+ let testComparator = remainingComparators.pop();
11390
+
11391
+ while (result && remainingComparators.length) {
11392
+ result = remainingComparators.every((otherComparator) => {
11393
+ return testComparator.intersects(otherComparator, options)
11394
+ });
11395
+
11396
+ testComparator = remainingComparators.pop();
11397
+ }
11398
+
11399
+ return result
11400
+ };
11401
+
11402
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
11403
+ // already replaced the hyphen ranges
11404
+ // turn into a set of JUST comparators.
11405
+ const parseComparator = (comp, options) => {
11406
+ comp = comp.replace(re[t.BUILD], '');
11407
+ debug('comp', comp, options);
11408
+ comp = replaceCarets(comp, options);
11409
+ debug('caret', comp);
11410
+ comp = replaceTildes(comp, options);
11411
+ debug('tildes', comp);
11412
+ comp = replaceXRanges(comp, options);
11413
+ debug('xrange', comp);
11414
+ comp = replaceStars(comp, options);
11415
+ debug('stars', comp);
11416
+ return comp
11417
+ };
11418
+
11419
+ const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
11420
+
11421
+ // ~, ~> --> * (any, kinda silly)
11422
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
11423
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
11424
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
11425
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
11426
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
11427
+ // ~0.0.1 --> >=0.0.1 <0.1.0-0
11428
+ const replaceTildes = (comp, options) => {
11429
+ return comp
11430
+ .trim()
11431
+ .split(/\s+/)
11432
+ .map((c) => replaceTilde(c, options))
11433
+ .join(' ')
11434
+ };
11435
+
11436
+ const replaceTilde = (comp, options) => {
11437
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
11438
+ return comp.replace(r, (_, M, m, p, pr) => {
11439
+ debug('tilde', comp, _, M, m, p, pr);
11440
+ let ret;
11441
+
11442
+ if (isX(M)) {
11443
+ ret = '';
11444
+ } else if (isX(m)) {
11445
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
11446
+ } else if (isX(p)) {
11447
+ // ~1.2 == >=1.2.0 <1.3.0-0
11448
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
11449
+ } else if (pr) {
11450
+ debug('replaceTilde pr', pr);
11451
+ ret = `>=${M}.${m}.${p}-${pr
11452
+ } <${M}.${+m + 1}.0-0`;
11453
+ } else {
11454
+ // ~1.2.3 == >=1.2.3 <1.3.0-0
11455
+ ret = `>=${M}.${m}.${p
11456
+ } <${M}.${+m + 1}.0-0`;
11457
+ }
11458
+
11459
+ debug('tilde return', ret);
11460
+ return ret
11461
+ })
11462
+ };
11463
+
11464
+ // ^ --> * (any, kinda silly)
11465
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
11466
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
11467
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
11468
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
11469
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
11470
+ // ^0.0.1 --> >=0.0.1 <0.0.2-0
11471
+ // ^0.1.0 --> >=0.1.0 <0.2.0-0
11472
+ const replaceCarets = (comp, options) => {
11473
+ return comp
11474
+ .trim()
11475
+ .split(/\s+/)
11476
+ .map((c) => replaceCaret(c, options))
11477
+ .join(' ')
11478
+ };
11479
+
11480
+ const replaceCaret = (comp, options) => {
11481
+ debug('caret', comp, options);
11482
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
11483
+ const z = options.includePrerelease ? '-0' : '';
11484
+ return comp.replace(r, (_, M, m, p, pr) => {
11485
+ debug('caret', comp, _, M, m, p, pr);
11486
+ let ret;
11487
+
11488
+ if (isX(M)) {
11489
+ ret = '';
11490
+ } else if (isX(m)) {
11491
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
11492
+ } else if (isX(p)) {
11493
+ if (M === '0') {
11494
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
11495
+ } else {
11496
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
11497
+ }
11498
+ } else if (pr) {
11499
+ debug('replaceCaret pr', pr);
11500
+ if (M === '0') {
11501
+ if (m === '0') {
11502
+ ret = `>=${M}.${m}.${p}-${pr
11503
+ } <${M}.${m}.${+p + 1}-0`;
11504
+ } else {
11505
+ ret = `>=${M}.${m}.${p}-${pr
11506
+ } <${M}.${+m + 1}.0-0`;
11507
+ }
11508
+ } else {
11509
+ ret = `>=${M}.${m}.${p}-${pr
11510
+ } <${+M + 1}.0.0-0`;
11511
+ }
11512
+ } else {
11513
+ debug('no pr');
11514
+ if (M === '0') {
11515
+ if (m === '0') {
11516
+ ret = `>=${M}.${m}.${p
11517
+ }${z} <${M}.${m}.${+p + 1}-0`;
11518
+ } else {
11519
+ ret = `>=${M}.${m}.${p
11520
+ }${z} <${M}.${+m + 1}.0-0`;
11521
+ }
11522
+ } else {
11523
+ ret = `>=${M}.${m}.${p
11524
+ } <${+M + 1}.0.0-0`;
11525
+ }
11526
+ }
11527
+
11528
+ debug('caret return', ret);
11529
+ return ret
11530
+ })
11531
+ };
11532
+
11533
+ const replaceXRanges = (comp, options) => {
11534
+ debug('replaceXRanges', comp, options);
11535
+ return comp
11536
+ .split(/\s+/)
11537
+ .map((c) => replaceXRange(c, options))
11538
+ .join(' ')
11539
+ };
11540
+
11541
+ const replaceXRange = (comp, options) => {
11542
+ comp = comp.trim();
11543
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
11544
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
11545
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
11546
+ const xM = isX(M);
11547
+ const xm = xM || isX(m);
11548
+ const xp = xm || isX(p);
11549
+ const anyX = xp;
11550
+
11551
+ if (gtlt === '=' && anyX) {
11552
+ gtlt = '';
11553
+ }
11554
+
11555
+ // if we're including prereleases in the match, then we need
11556
+ // to fix this to -0, the lowest possible prerelease value
11557
+ pr = options.includePrerelease ? '-0' : '';
11558
+
11559
+ if (xM) {
11560
+ if (gtlt === '>' || gtlt === '<') {
11561
+ // nothing is allowed
11562
+ ret = '<0.0.0-0';
11563
+ } else {
11564
+ // nothing is forbidden
11565
+ ret = '*';
11566
+ }
11567
+ } else if (gtlt && anyX) {
11568
+ // we know patch is an x, because we have any x at all.
11569
+ // replace X with 0
11570
+ if (xm) {
11571
+ m = 0;
11572
+ }
11573
+ p = 0;
11574
+
11575
+ if (gtlt === '>') {
11576
+ // >1 => >=2.0.0
11577
+ // >1.2 => >=1.3.0
11578
+ gtlt = '>=';
11579
+ if (xm) {
11580
+ M = +M + 1;
11581
+ m = 0;
11582
+ p = 0;
11583
+ } else {
11584
+ m = +m + 1;
11585
+ p = 0;
11586
+ }
11587
+ } else if (gtlt === '<=') {
11588
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
11589
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
11590
+ gtlt = '<';
11591
+ if (xm) {
11592
+ M = +M + 1;
11593
+ } else {
11594
+ m = +m + 1;
11595
+ }
11596
+ }
11597
+
11598
+ if (gtlt === '<') {
11599
+ pr = '-0';
11600
+ }
11601
+
11602
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
11603
+ } else if (xm) {
11604
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
11605
+ } else if (xp) {
11606
+ ret = `>=${M}.${m}.0${pr
11607
+ } <${M}.${+m + 1}.0-0`;
11608
+ }
11609
+
11610
+ debug('xRange return', ret);
11611
+
11612
+ return ret
11613
+ })
11614
+ };
11615
+
11616
+ // Because * is AND-ed with everything else in the comparator,
11617
+ // and '' means "any version", just remove the *s entirely.
11618
+ const replaceStars = (comp, options) => {
11619
+ debug('replaceStars', comp, options);
11620
+ // Looseness is ignored here. star is always as loose as it gets!
11621
+ return comp
11622
+ .trim()
11623
+ .replace(re[t.STAR], '')
11624
+ };
11625
+
11626
+ const replaceGTE0 = (comp, options) => {
11627
+ debug('replaceGTE0', comp, options);
11628
+ return comp
11629
+ .trim()
11630
+ .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
11631
+ };
11632
+
11633
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
11634
+ // M, m, patch, prerelease, build
11635
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
11636
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
11637
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
11638
+ // TODO build?
11639
+ const hyphenReplace = incPr => ($0,
11640
+ from, fM, fm, fp, fpr, fb,
11641
+ to, tM, tm, tp, tpr) => {
11642
+ if (isX(fM)) {
11643
+ from = '';
11644
+ } else if (isX(fm)) {
11645
+ from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
11646
+ } else if (isX(fp)) {
11647
+ from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
11648
+ } else if (fpr) {
11649
+ from = `>=${from}`;
11650
+ } else {
11651
+ from = `>=${from}${incPr ? '-0' : ''}`;
11652
+ }
11653
+
11654
+ if (isX(tM)) {
11655
+ to = '';
11656
+ } else if (isX(tm)) {
11657
+ to = `<${+tM + 1}.0.0-0`;
11658
+ } else if (isX(tp)) {
11659
+ to = `<${tM}.${+tm + 1}.0-0`;
11660
+ } else if (tpr) {
11661
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
11662
+ } else if (incPr) {
11663
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
11664
+ } else {
11665
+ to = `<=${to}`;
11666
+ }
11667
+
11668
+ return `${from} ${to}`.trim()
11669
+ };
11670
+
11671
+ const testSet = (set, version, options) => {
11672
+ for (let i = 0; i < set.length; i++) {
11673
+ if (!set[i].test(version)) {
11674
+ return false
11675
+ }
11676
+ }
11677
+
11678
+ if (version.prerelease.length && !options.includePrerelease) {
11679
+ // Find the set of versions that are allowed to have prereleases
11680
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
11681
+ // That should allow `1.2.3-pr.2` to pass.
11682
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
11683
+ // even though it's within the range set by the comparators.
11684
+ for (let i = 0; i < set.length; i++) {
11685
+ debug(set[i].semver);
11686
+ if (set[i].semver === Comparator.ANY) {
11687
+ continue
11688
+ }
11689
+
11690
+ if (set[i].semver.prerelease.length > 0) {
11691
+ const allowed = set[i].semver;
11692
+ if (allowed.major === version.major &&
11693
+ allowed.minor === version.minor &&
11694
+ allowed.patch === version.patch) {
11695
+ return true
11696
+ }
11697
+ }
11698
+ }
11699
+
11700
+ // Version has a -pre, but it's not one of the ones we like.
11701
+ return false
11702
+ }
11703
+
11704
+ return true
11705
+ };
11706
+ return range;
11707
+ }
11708
+
11709
+ var comparator;
11710
+ var hasRequiredComparator;
11711
+
11712
+ function requireComparator () {
11713
+ if (hasRequiredComparator) return comparator;
11714
+ hasRequiredComparator = 1;
11715
+
11716
+ const ANY = Symbol('SemVer ANY');
11717
+ // hoisted class for cyclic dependency
11718
+ class Comparator {
11719
+ static get ANY () {
11720
+ return ANY
11721
+ }
11722
+
11723
+ constructor (comp, options) {
11724
+ options = parseOptions(options);
11725
+
11726
+ if (comp instanceof Comparator) {
11727
+ if (comp.loose === !!options.loose) {
11728
+ return comp
11729
+ } else {
11730
+ comp = comp.value;
11731
+ }
11732
+ }
11733
+
11734
+ comp = comp.trim().split(/\s+/).join(' ');
11735
+ debug('comparator', comp, options);
11736
+ this.options = options;
11737
+ this.loose = !!options.loose;
11738
+ this.parse(comp);
11739
+
11740
+ if (this.semver === ANY) {
11741
+ this.value = '';
11742
+ } else {
11743
+ this.value = this.operator + this.semver.version;
11744
+ }
11745
+
11746
+ debug('comp', this);
11747
+ }
11748
+
11749
+ parse (comp) {
11750
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
11751
+ const m = comp.match(r);
11752
+
11753
+ if (!m) {
11754
+ throw new TypeError(`Invalid comparator: ${comp}`)
11755
+ }
11756
+
11757
+ this.operator = m[1] !== undefined ? m[1] : '';
11758
+ if (this.operator === '=') {
11759
+ this.operator = '';
11760
+ }
11761
+
11762
+ // if it literally is just '>' or '' then allow anything.
11763
+ if (!m[2]) {
11764
+ this.semver = ANY;
11765
+ } else {
11766
+ this.semver = new SemVer(m[2], this.options.loose);
11767
+ }
11768
+ }
11769
+
11770
+ toString () {
11771
+ return this.value
11772
+ }
11773
+
11774
+ test (version) {
11775
+ debug('Comparator.test', version, this.options.loose);
11776
+
11777
+ if (this.semver === ANY || version === ANY) {
11778
+ return true
11779
+ }
11780
+
11781
+ if (typeof version === 'string') {
11782
+ try {
11783
+ version = new SemVer(version, this.options);
11784
+ } catch (er) {
11785
+ return false
11786
+ }
11787
+ }
11788
+
11789
+ return cmp(version, this.operator, this.semver, this.options)
11790
+ }
11791
+
11792
+ intersects (comp, options) {
11793
+ if (!(comp instanceof Comparator)) {
11794
+ throw new TypeError('a Comparator is required')
11795
+ }
11796
+
11797
+ if (this.operator === '') {
11798
+ if (this.value === '') {
11799
+ return true
11800
+ }
11801
+ return new Range(comp.value, options).test(this.value)
11802
+ } else if (comp.operator === '') {
11803
+ if (comp.value === '') {
11804
+ return true
11805
+ }
11806
+ return new Range(this.value, options).test(comp.semver)
11807
+ }
11808
+
11809
+ options = parseOptions(options);
11810
+
11811
+ // Special cases where nothing can possibly be lower
11812
+ if (options.includePrerelease &&
11813
+ (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
11814
+ return false
11815
+ }
11816
+ if (!options.includePrerelease &&
11817
+ (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
11818
+ return false
11819
+ }
11820
+
11821
+ // Same direction increasing (> or >=)
11822
+ if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
11823
+ return true
11824
+ }
11825
+ // Same direction decreasing (< or <=)
11826
+ if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
11827
+ return true
11828
+ }
11829
+ // same SemVer and both sides are inclusive (<= or >=)
11830
+ if (
11831
+ (this.semver.version === comp.semver.version) &&
11832
+ this.operator.includes('=') && comp.operator.includes('=')) {
11833
+ return true
11834
+ }
11835
+ // opposite directions less than
11836
+ if (cmp(this.semver, '<', comp.semver, options) &&
11837
+ this.operator.startsWith('>') && comp.operator.startsWith('<')) {
11838
+ return true
11839
+ }
11840
+ // opposite directions greater than
11841
+ if (cmp(this.semver, '>', comp.semver, options) &&
11842
+ this.operator.startsWith('<') && comp.operator.startsWith('>')) {
11843
+ return true
11844
+ }
11845
+ return false
11846
+ }
11847
+ }
11848
+
11849
+ comparator = Comparator;
11850
+
11851
+ const parseOptions = requireParseOptions();
11852
+ const { safeRe: re, t } = requireRe();
11853
+ const cmp = requireCmp();
11854
+ const debug = requireDebug();
11855
+ const SemVer = requireSemver$1();
11856
+ const Range = requireRange();
11857
+ return comparator;
11858
+ }
11859
+
11860
+ var satisfies_1;
11861
+ var hasRequiredSatisfies;
11862
+
11863
+ function requireSatisfies () {
11864
+ if (hasRequiredSatisfies) return satisfies_1;
11865
+ hasRequiredSatisfies = 1;
11866
+
11867
+ const Range = requireRange();
11868
+ const satisfies = (version, range, options) => {
11869
+ try {
11870
+ range = new Range(range, options);
11871
+ } catch (er) {
11872
+ return false
11873
+ }
11874
+ return range.test(version)
11875
+ };
11876
+ satisfies_1 = satisfies;
11877
+ return satisfies_1;
11878
+ }
11879
+
11880
+ var toComparators_1;
11881
+ var hasRequiredToComparators;
11882
+
11883
+ function requireToComparators () {
11884
+ if (hasRequiredToComparators) return toComparators_1;
11885
+ hasRequiredToComparators = 1;
11886
+
11887
+ const Range = requireRange();
11888
+
11889
+ // Mostly just for testing and legacy API reasons
11890
+ const toComparators = (range, options) =>
11891
+ new Range(range, options).set
11892
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
11893
+
11894
+ toComparators_1 = toComparators;
11895
+ return toComparators_1;
11896
+ }
11897
+
11898
+ var maxSatisfying_1;
11899
+ var hasRequiredMaxSatisfying;
11900
+
11901
+ function requireMaxSatisfying () {
11902
+ if (hasRequiredMaxSatisfying) return maxSatisfying_1;
11903
+ hasRequiredMaxSatisfying = 1;
11904
+
11905
+ const SemVer = requireSemver$1();
11906
+ const Range = requireRange();
11907
+
11908
+ const maxSatisfying = (versions, range, options) => {
11909
+ let max = null;
11910
+ let maxSV = null;
11911
+ let rangeObj = null;
11912
+ try {
11913
+ rangeObj = new Range(range, options);
11914
+ } catch (er) {
11915
+ return null
11916
+ }
11917
+ versions.forEach((v) => {
11918
+ if (rangeObj.test(v)) {
11919
+ // satisfies(v, range, options)
11920
+ if (!max || maxSV.compare(v) === -1) {
11921
+ // compare(max, v, true)
11922
+ max = v;
11923
+ maxSV = new SemVer(max, options);
11924
+ }
11925
+ }
11926
+ });
11927
+ return max
11928
+ };
11929
+ maxSatisfying_1 = maxSatisfying;
11930
+ return maxSatisfying_1;
11931
+ }
11932
+
11933
+ var minSatisfying_1;
11934
+ var hasRequiredMinSatisfying;
11935
+
11936
+ function requireMinSatisfying () {
11937
+ if (hasRequiredMinSatisfying) return minSatisfying_1;
11938
+ hasRequiredMinSatisfying = 1;
11939
+
11940
+ const SemVer = requireSemver$1();
11941
+ const Range = requireRange();
11942
+ const minSatisfying = (versions, range, options) => {
11943
+ let min = null;
11944
+ let minSV = null;
11945
+ let rangeObj = null;
11946
+ try {
11947
+ rangeObj = new Range(range, options);
11948
+ } catch (er) {
11949
+ return null
11950
+ }
11951
+ versions.forEach((v) => {
11952
+ if (rangeObj.test(v)) {
11953
+ // satisfies(v, range, options)
11954
+ if (!min || minSV.compare(v) === 1) {
11955
+ // compare(min, v, true)
11956
+ min = v;
11957
+ minSV = new SemVer(min, options);
11958
+ }
11959
+ }
11960
+ });
11961
+ return min
11962
+ };
11963
+ minSatisfying_1 = minSatisfying;
11964
+ return minSatisfying_1;
11965
+ }
11966
+
11967
+ var minVersion_1;
11968
+ var hasRequiredMinVersion;
11969
+
11970
+ function requireMinVersion () {
11971
+ if (hasRequiredMinVersion) return minVersion_1;
11972
+ hasRequiredMinVersion = 1;
11973
+
11974
+ const SemVer = requireSemver$1();
11975
+ const Range = requireRange();
11976
+ const gt = requireGt();
11977
+
11978
+ const minVersion = (range, loose) => {
11979
+ range = new Range(range, loose);
11980
+
11981
+ let minver = new SemVer('0.0.0');
11982
+ if (range.test(minver)) {
11983
+ return minver
11984
+ }
11985
+
11986
+ minver = new SemVer('0.0.0-0');
11987
+ if (range.test(minver)) {
11988
+ return minver
11989
+ }
11990
+
11991
+ minver = null;
11992
+ for (let i = 0; i < range.set.length; ++i) {
11993
+ const comparators = range.set[i];
11994
+
11995
+ let setMin = null;
11996
+ comparators.forEach((comparator) => {
11997
+ // Clone to avoid manipulating the comparator's semver object.
11998
+ const compver = new SemVer(comparator.semver.version);
11999
+ switch (comparator.operator) {
12000
+ case '>':
12001
+ if (compver.prerelease.length === 0) {
12002
+ compver.patch++;
12003
+ } else {
12004
+ compver.prerelease.push(0);
12005
+ }
12006
+ compver.raw = compver.format();
12007
+ /* fallthrough */
12008
+ case '':
12009
+ case '>=':
12010
+ if (!setMin || gt(compver, setMin)) {
12011
+ setMin = compver;
12012
+ }
12013
+ break
12014
+ case '<':
12015
+ case '<=':
12016
+ /* Ignore maximum versions */
12017
+ break
12018
+ /* istanbul ignore next */
12019
+ default:
12020
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
12021
+ }
12022
+ });
12023
+ if (setMin && (!minver || gt(minver, setMin))) {
12024
+ minver = setMin;
12025
+ }
12026
+ }
12027
+
12028
+ if (minver && range.test(minver)) {
12029
+ return minver
12030
+ }
12031
+
12032
+ return null
12033
+ };
12034
+ minVersion_1 = minVersion;
12035
+ return minVersion_1;
12036
+ }
12037
+
12038
+ var valid;
12039
+ var hasRequiredValid;
12040
+
12041
+ function requireValid () {
12042
+ if (hasRequiredValid) return valid;
12043
+ hasRequiredValid = 1;
12044
+
12045
+ const Range = requireRange();
12046
+ const validRange = (range, options) => {
12047
+ try {
12048
+ // Return '*' instead of '' so that truthiness works.
12049
+ // This will throw if it's invalid anyway
12050
+ return new Range(range, options).range || '*'
12051
+ } catch (er) {
12052
+ return null
12053
+ }
12054
+ };
12055
+ valid = validRange;
12056
+ return valid;
12057
+ }
12058
+
12059
+ var outside_1;
12060
+ var hasRequiredOutside;
12061
+
12062
+ function requireOutside () {
12063
+ if (hasRequiredOutside) return outside_1;
12064
+ hasRequiredOutside = 1;
12065
+
12066
+ const SemVer = requireSemver$1();
12067
+ const Comparator = requireComparator();
12068
+ const { ANY } = Comparator;
12069
+ const Range = requireRange();
12070
+ const satisfies = requireSatisfies();
12071
+ const gt = requireGt();
12072
+ const lt = requireLt();
12073
+ const lte = requireLte();
12074
+ const gte = requireGte();
12075
+
12076
+ const outside = (version, range, hilo, options) => {
12077
+ version = new SemVer(version, options);
12078
+ range = new Range(range, options);
12079
+
12080
+ let gtfn, ltefn, ltfn, comp, ecomp;
12081
+ switch (hilo) {
12082
+ case '>':
12083
+ gtfn = gt;
12084
+ ltefn = lte;
12085
+ ltfn = lt;
12086
+ comp = '>';
12087
+ ecomp = '>=';
12088
+ break
12089
+ case '<':
12090
+ gtfn = lt;
12091
+ ltefn = gte;
12092
+ ltfn = gt;
12093
+ comp = '<';
12094
+ ecomp = '<=';
12095
+ break
12096
+ default:
12097
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
12098
+ }
12099
+
12100
+ // If it satisfies the range it is not outside
12101
+ if (satisfies(version, range, options)) {
12102
+ return false
12103
+ }
12104
+
12105
+ // From now on, variable terms are as if we're in "gtr" mode.
12106
+ // but note that everything is flipped for the "ltr" function.
12107
+
12108
+ for (let i = 0; i < range.set.length; ++i) {
12109
+ const comparators = range.set[i];
12110
+
12111
+ let high = null;
12112
+ let low = null;
12113
+
12114
+ comparators.forEach((comparator) => {
12115
+ if (comparator.semver === ANY) {
12116
+ comparator = new Comparator('>=0.0.0');
12117
+ }
12118
+ high = high || comparator;
12119
+ low = low || comparator;
12120
+ if (gtfn(comparator.semver, high.semver, options)) {
12121
+ high = comparator;
12122
+ } else if (ltfn(comparator.semver, low.semver, options)) {
12123
+ low = comparator;
12124
+ }
12125
+ });
12126
+
12127
+ // If the edge version comparator has a operator then our version
12128
+ // isn't outside it
12129
+ if (high.operator === comp || high.operator === ecomp) {
12130
+ return false
12131
+ }
12132
+
12133
+ // If the lowest version comparator has an operator and our version
12134
+ // is less than it then it isn't higher than the range
12135
+ if ((!low.operator || low.operator === comp) &&
12136
+ ltefn(version, low.semver)) {
12137
+ return false
12138
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
12139
+ return false
12140
+ }
12141
+ }
12142
+ return true
12143
+ };
12144
+
12145
+ outside_1 = outside;
12146
+ return outside_1;
12147
+ }
12148
+
12149
+ var gtr_1;
12150
+ var hasRequiredGtr;
12151
+
12152
+ function requireGtr () {
12153
+ if (hasRequiredGtr) return gtr_1;
12154
+ hasRequiredGtr = 1;
12155
+
12156
+ // Determine if version is greater than all the versions possible in the range.
12157
+ const outside = requireOutside();
12158
+ const gtr = (version, range, options) => outside(version, range, '>', options);
12159
+ gtr_1 = gtr;
12160
+ return gtr_1;
12161
+ }
12162
+
12163
+ var ltr_1;
12164
+ var hasRequiredLtr;
12165
+
12166
+ function requireLtr () {
12167
+ if (hasRequiredLtr) return ltr_1;
12168
+ hasRequiredLtr = 1;
12169
+
12170
+ const outside = requireOutside();
12171
+ // Determine if version is less than all the versions possible in the range
12172
+ const ltr = (version, range, options) => outside(version, range, '<', options);
12173
+ ltr_1 = ltr;
12174
+ return ltr_1;
12175
+ }
12176
+
12177
+ var intersects_1;
12178
+ var hasRequiredIntersects;
12179
+
12180
+ function requireIntersects () {
12181
+ if (hasRequiredIntersects) return intersects_1;
12182
+ hasRequiredIntersects = 1;
12183
+
12184
+ const Range = requireRange();
12185
+ const intersects = (r1, r2, options) => {
12186
+ r1 = new Range(r1, options);
12187
+ r2 = new Range(r2, options);
12188
+ return r1.intersects(r2, options)
12189
+ };
12190
+ intersects_1 = intersects;
12191
+ return intersects_1;
12192
+ }
12193
+
12194
+ var simplify;
12195
+ var hasRequiredSimplify;
12196
+
12197
+ function requireSimplify () {
12198
+ if (hasRequiredSimplify) return simplify;
12199
+ hasRequiredSimplify = 1;
12200
+
12201
+ // given a set of versions and a range, create a "simplified" range
12202
+ // that includes the same versions that the original range does
12203
+ // If the original range is shorter than the simplified one, return that.
12204
+ const satisfies = requireSatisfies();
12205
+ const compare = requireCompare();
12206
+ simplify = (versions, range, options) => {
12207
+ const set = [];
12208
+ let first = null;
12209
+ let prev = null;
12210
+ const v = versions.sort((a, b) => compare(a, b, options));
12211
+ for (const version of v) {
12212
+ const included = satisfies(version, range, options);
12213
+ if (included) {
12214
+ prev = version;
12215
+ if (!first) {
12216
+ first = version;
12217
+ }
12218
+ } else {
12219
+ if (prev) {
12220
+ set.push([first, prev]);
12221
+ }
12222
+ prev = null;
12223
+ first = null;
12224
+ }
12225
+ }
12226
+ if (first) {
12227
+ set.push([first, null]);
12228
+ }
12229
+
12230
+ const ranges = [];
12231
+ for (const [min, max] of set) {
12232
+ if (min === max) {
12233
+ ranges.push(min);
12234
+ } else if (!max && min === v[0]) {
12235
+ ranges.push('*');
12236
+ } else if (!max) {
12237
+ ranges.push(`>=${min}`);
12238
+ } else if (min === v[0]) {
12239
+ ranges.push(`<=${max}`);
12240
+ } else {
12241
+ ranges.push(`${min} - ${max}`);
12242
+ }
12243
+ }
12244
+ const simplified = ranges.join(' || ');
12245
+ const original = typeof range.raw === 'string' ? range.raw : String(range);
12246
+ return simplified.length < original.length ? simplified : range
12247
+ };
12248
+ return simplify;
12249
+ }
12250
+
12251
+ var subset_1;
12252
+ var hasRequiredSubset;
12253
+
12254
+ function requireSubset () {
12255
+ if (hasRequiredSubset) return subset_1;
12256
+ hasRequiredSubset = 1;
12257
+
12258
+ const Range = requireRange();
12259
+ const Comparator = requireComparator();
12260
+ const { ANY } = Comparator;
12261
+ const satisfies = requireSatisfies();
12262
+ const compare = requireCompare();
12263
+
12264
+ // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
12265
+ // - Every simple range `r1, r2, ...` is a null set, OR
12266
+ // - Every simple range `r1, r2, ...` which is not a null set is a subset of
12267
+ // some `R1, R2, ...`
12268
+ //
12269
+ // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
12270
+ // - If c is only the ANY comparator
12271
+ // - If C is only the ANY comparator, return true
12272
+ // - Else if in prerelease mode, return false
12273
+ // - else replace c with `[>=0.0.0]`
12274
+ // - If C is only the ANY comparator
12275
+ // - if in prerelease mode, return true
12276
+ // - else replace C with `[>=0.0.0]`
12277
+ // - Let EQ be the set of = comparators in c
12278
+ // - If EQ is more than one, return true (null set)
12279
+ // - Let GT be the highest > or >= comparator in c
12280
+ // - Let LT be the lowest < or <= comparator in c
12281
+ // - If GT and LT, and GT.semver > LT.semver, return true (null set)
12282
+ // - If any C is a = range, and GT or LT are set, return false
12283
+ // - If EQ
12284
+ // - If GT, and EQ does not satisfy GT, return true (null set)
12285
+ // - If LT, and EQ does not satisfy LT, return true (null set)
12286
+ // - If EQ satisfies every C, return true
12287
+ // - Else return false
12288
+ // - If GT
12289
+ // - If GT.semver is lower than any > or >= comp in C, return false
12290
+ // - If GT is >=, and GT.semver does not satisfy every C, return false
12291
+ // - If GT.semver has a prerelease, and not in prerelease mode
12292
+ // - If no C has a prerelease and the GT.semver tuple, return false
12293
+ // - If LT
12294
+ // - If LT.semver is greater than any < or <= comp in C, return false
12295
+ // - If LT is <=, and LT.semver does not satisfy every C, return false
12296
+ // - If GT.semver has a prerelease, and not in prerelease mode
12297
+ // - If no C has a prerelease and the LT.semver tuple, return false
12298
+ // - Else return true
12299
+
12300
+ const subset = (sub, dom, options = {}) => {
12301
+ if (sub === dom) {
12302
+ return true
12303
+ }
12304
+
12305
+ sub = new Range(sub, options);
12306
+ dom = new Range(dom, options);
12307
+ let sawNonNull = false;
12308
+
12309
+ OUTER: for (const simpleSub of sub.set) {
12310
+ for (const simpleDom of dom.set) {
12311
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
12312
+ sawNonNull = sawNonNull || isSub !== null;
12313
+ if (isSub) {
12314
+ continue OUTER
12315
+ }
12316
+ }
12317
+ // the null set is a subset of everything, but null simple ranges in
12318
+ // a complex range should be ignored. so if we saw a non-null range,
12319
+ // then we know this isn't a subset, but if EVERY simple range was null,
12320
+ // then it is a subset.
12321
+ if (sawNonNull) {
12322
+ return false
12323
+ }
12324
+ }
12325
+ return true
12326
+ };
12327
+
12328
+ const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')];
12329
+ const minimumVersion = [new Comparator('>=0.0.0')];
12330
+
12331
+ const simpleSubset = (sub, dom, options) => {
12332
+ if (sub === dom) {
12333
+ return true
12334
+ }
12335
+
12336
+ if (sub.length === 1 && sub[0].semver === ANY) {
12337
+ if (dom.length === 1 && dom[0].semver === ANY) {
12338
+ return true
12339
+ } else if (options.includePrerelease) {
12340
+ sub = minimumVersionWithPreRelease;
12341
+ } else {
12342
+ sub = minimumVersion;
12343
+ }
12344
+ }
12345
+
12346
+ if (dom.length === 1 && dom[0].semver === ANY) {
12347
+ if (options.includePrerelease) {
12348
+ return true
12349
+ } else {
12350
+ dom = minimumVersion;
12351
+ }
12352
+ }
12353
+
12354
+ const eqSet = new Set();
12355
+ let gt, lt;
12356
+ for (const c of sub) {
12357
+ if (c.operator === '>' || c.operator === '>=') {
12358
+ gt = higherGT(gt, c, options);
12359
+ } else if (c.operator === '<' || c.operator === '<=') {
12360
+ lt = lowerLT(lt, c, options);
12361
+ } else {
12362
+ eqSet.add(c.semver);
12363
+ }
12364
+ }
12365
+
12366
+ if (eqSet.size > 1) {
12367
+ return null
12368
+ }
12369
+
12370
+ let gtltComp;
12371
+ if (gt && lt) {
12372
+ gtltComp = compare(gt.semver, lt.semver, options);
12373
+ if (gtltComp > 0) {
12374
+ return null
12375
+ } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
12376
+ return null
12377
+ }
12378
+ }
12379
+
12380
+ // will iterate one or zero times
12381
+ for (const eq of eqSet) {
12382
+ if (gt && !satisfies(eq, String(gt), options)) {
12383
+ return null
12384
+ }
12385
+
12386
+ if (lt && !satisfies(eq, String(lt), options)) {
12387
+ return null
12388
+ }
12389
+
12390
+ for (const c of dom) {
12391
+ if (!satisfies(eq, String(c), options)) {
12392
+ return false
12393
+ }
12394
+ }
12395
+
12396
+ return true
12397
+ }
12398
+
12399
+ let higher, lower;
12400
+ let hasDomLT, hasDomGT;
12401
+ // if the subset has a prerelease, we need a comparator in the superset
12402
+ // with the same tuple and a prerelease, or it's not a subset
12403
+ let needDomLTPre = lt &&
12404
+ !options.includePrerelease &&
12405
+ lt.semver.prerelease.length ? lt.semver : false;
12406
+ let needDomGTPre = gt &&
12407
+ !options.includePrerelease &&
12408
+ gt.semver.prerelease.length ? gt.semver : false;
12409
+ // exception: <1.2.3-0 is the same as <1.2.3
12410
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
12411
+ lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
12412
+ needDomLTPre = false;
12413
+ }
12414
+
12415
+ for (const c of dom) {
12416
+ hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
12417
+ hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
12418
+ if (gt) {
12419
+ if (needDomGTPre) {
12420
+ if (c.semver.prerelease && c.semver.prerelease.length &&
12421
+ c.semver.major === needDomGTPre.major &&
12422
+ c.semver.minor === needDomGTPre.minor &&
12423
+ c.semver.patch === needDomGTPre.patch) {
12424
+ needDomGTPre = false;
12425
+ }
12426
+ }
12427
+ if (c.operator === '>' || c.operator === '>=') {
12428
+ higher = higherGT(gt, c, options);
12429
+ if (higher === c && higher !== gt) {
12430
+ return false
12431
+ }
12432
+ } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
12433
+ return false
12434
+ }
12435
+ }
12436
+ if (lt) {
12437
+ if (needDomLTPre) {
12438
+ if (c.semver.prerelease && c.semver.prerelease.length &&
12439
+ c.semver.major === needDomLTPre.major &&
12440
+ c.semver.minor === needDomLTPre.minor &&
12441
+ c.semver.patch === needDomLTPre.patch) {
12442
+ needDomLTPre = false;
12443
+ }
12444
+ }
12445
+ if (c.operator === '<' || c.operator === '<=') {
12446
+ lower = lowerLT(lt, c, options);
12447
+ if (lower === c && lower !== lt) {
12448
+ return false
12449
+ }
12450
+ } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
12451
+ return false
12452
+ }
12453
+ }
12454
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
12455
+ return false
12456
+ }
12457
+ }
12458
+
12459
+ // if there was a < or >, and nothing in the dom, then must be false
12460
+ // UNLESS it was limited by another range in the other direction.
12461
+ // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
12462
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
12463
+ return false
12464
+ }
12465
+
12466
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
12467
+ return false
12468
+ }
12469
+
12470
+ // we needed a prerelease range in a specific tuple, but didn't get one
12471
+ // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
12472
+ // because it includes prereleases in the 1.2.3 tuple
12473
+ if (needDomGTPre || needDomLTPre) {
12474
+ return false
12475
+ }
12476
+
12477
+ return true
12478
+ };
12479
+
12480
+ // >=1.2.3 is lower than >1.2.3
12481
+ const higherGT = (a, b, options) => {
12482
+ if (!a) {
12483
+ return b
12484
+ }
12485
+ const comp = compare(a.semver, b.semver, options);
12486
+ return comp > 0 ? a
12487
+ : comp < 0 ? b
12488
+ : b.operator === '>' && a.operator === '>=' ? b
12489
+ : a
12490
+ };
12491
+
12492
+ // <=1.2.3 is higher than <1.2.3
12493
+ const lowerLT = (a, b, options) => {
12494
+ if (!a) {
12495
+ return b
12496
+ }
12497
+ const comp = compare(a.semver, b.semver, options);
12498
+ return comp < 0 ? a
12499
+ : comp > 0 ? b
12500
+ : b.operator === '<' && a.operator === '<=' ? b
12501
+ : a
12502
+ };
12503
+
12504
+ subset_1 = subset;
12505
+ return subset_1;
12506
+ }
12507
+
12508
+ var semver;
12509
+ var hasRequiredSemver;
12510
+
12511
+ function requireSemver () {
12512
+ if (hasRequiredSemver) return semver;
12513
+ hasRequiredSemver = 1;
12514
+
12515
+ // just pre-load all the stuff that index.js lazily exports
12516
+ const internalRe = requireRe();
12517
+ const constants = requireConstants();
12518
+ const SemVer = requireSemver$1();
12519
+ const identifiers = requireIdentifiers();
12520
+ const parse = requireParse();
12521
+ const valid = requireValid$1();
12522
+ const clean = requireClean();
12523
+ const inc = requireInc();
12524
+ const diff = requireDiff();
12525
+ const major = requireMajor();
12526
+ const minor = requireMinor();
12527
+ const patch = requirePatch();
12528
+ const prerelease = requirePrerelease();
12529
+ const compare = requireCompare();
12530
+ const rcompare = requireRcompare();
12531
+ const compareLoose = requireCompareLoose();
12532
+ const compareBuild = requireCompareBuild();
12533
+ const sort = requireSort();
12534
+ const rsort = requireRsort();
12535
+ const gt = requireGt();
12536
+ const lt = requireLt();
12537
+ const eq = requireEq();
12538
+ const neq = requireNeq();
12539
+ const gte = requireGte();
12540
+ const lte = requireLte();
12541
+ const cmp = requireCmp();
12542
+ const coerce = requireCoerce();
12543
+ const Comparator = requireComparator();
12544
+ const Range = requireRange();
12545
+ const satisfies = requireSatisfies();
12546
+ const toComparators = requireToComparators();
12547
+ const maxSatisfying = requireMaxSatisfying();
12548
+ const minSatisfying = requireMinSatisfying();
12549
+ const minVersion = requireMinVersion();
12550
+ const validRange = requireValid();
12551
+ const outside = requireOutside();
12552
+ const gtr = requireGtr();
12553
+ const ltr = requireLtr();
12554
+ const intersects = requireIntersects();
12555
+ const simplifyRange = requireSimplify();
12556
+ const subset = requireSubset();
12557
+ semver = {
12558
+ parse,
12559
+ valid,
12560
+ clean,
12561
+ inc,
12562
+ diff,
12563
+ major,
12564
+ minor,
12565
+ patch,
12566
+ prerelease,
12567
+ compare,
12568
+ rcompare,
12569
+ compareLoose,
12570
+ compareBuild,
12571
+ sort,
12572
+ rsort,
12573
+ gt,
12574
+ lt,
12575
+ eq,
12576
+ neq,
12577
+ gte,
12578
+ lte,
12579
+ cmp,
12580
+ coerce,
12581
+ Comparator,
12582
+ Range,
12583
+ satisfies,
12584
+ toComparators,
12585
+ maxSatisfying,
12586
+ minSatisfying,
12587
+ minVersion,
12588
+ validRange,
12589
+ outside,
12590
+ gtr,
12591
+ ltr,
12592
+ intersects,
12593
+ simplifyRange,
12594
+ subset,
12595
+ SemVer,
12596
+ re: internalRe.re,
12597
+ src: internalRe.src,
12598
+ tokens: internalRe.t,
12599
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
12600
+ RELEASE_TYPES: constants.RELEASE_TYPES,
12601
+ compareIdentifiers: identifiers.compareIdentifiers,
12602
+ rcompareIdentifiers: identifiers.rcompareIdentifiers,
12603
+ };
12604
+ return semver;
12605
+ }
12606
+
12607
+ var semverExports = requireSemver();
12608
+
12609
+ const DELAY_INTERVAL_MS = 10;
12610
+ const MAX_NEXT_REQUEST_DELAY = 1e4 / DELAY_INTERVAL_MS;
12611
+ function getRequestLooper(req, options) {
12612
+ return new rxjs.Observable((subscriber) => {
12613
+ let nextQuery = undefined;
12614
+ let subscription = undefined;
12615
+ let loadingState = data.LoadingState.Loading;
12616
+ let nextRequestDelay = 1;
12617
+ let count = 1;
12618
+ let shouldCancel = false;
12619
+ const observer = {
12620
+ next: (rsp) => {
12621
+ loadingState = rsp.state;
12622
+ let checkstate = false;
12623
+ if (loadingState !== data.LoadingState.Error) {
12624
+ nextQuery = options.getNextQuery(rsp);
12625
+ const _shouldCancel = options.shouldCancel();
12626
+ if (nextQuery && _shouldCancel) {
12627
+ shouldCancel = _shouldCancel;
12628
+ nextQuery = undefined;
12629
+ }
12630
+ checkstate = true;
12631
+ }
12632
+ const data$1 = options.process(rsp.data);
12633
+ if (checkstate) {
12634
+ if (nextQuery) {
12635
+ if (data$1.length && data$1[0].length) {
12636
+ loadingState = data.LoadingState.Streaming;
12637
+ } else {
12638
+ loadingState = data.LoadingState.Loading;
12639
+ }
12640
+ nextRequestDelay = nextRequestDelay * 2 > MAX_NEXT_REQUEST_DELAY ? MAX_NEXT_REQUEST_DELAY : nextRequestDelay * 2;
12641
+ } else {
12642
+ loadingState = data.LoadingState.Done;
12643
+ nextRequestDelay = 0;
12644
+ }
12645
+ }
12646
+ subscriber.next({ ...rsp, data: data$1, state: loadingState, key: req.requestId });
12647
+ },
12648
+ error: (err) => {
12649
+ subscriber.error(err);
12650
+ },
12651
+ complete: () => {
12652
+ if (subscription) {
12653
+ subscription.unsubscribe();
12654
+ subscription = undefined;
12655
+ }
12656
+ if (nextQuery) {
12657
+ const next = nextQuery;
12658
+ setTimeout(() => {
12659
+ subscription = options.query({ ...req, requestId: `${req.requestId}.${++count}`, targets: [next] }).subscribe(observer);
12660
+ nextQuery = undefined;
12661
+ }, nextRequestDelay * DELAY_INTERVAL_MS);
12662
+ } else {
12663
+ subscriber.complete();
12664
+ }
12665
+ }
12666
+ };
12667
+ subscription = options.query(req).subscribe(observer);
12668
+ return function unsubscribe() {
12669
+ observer.complete();
12670
+ if (nextQuery || shouldCancel) {
12671
+ options.onCancel();
12672
+ }
12673
+ nextQuery = undefined;
12674
+ };
12675
+ });
12676
+ }
12677
+
12678
+ var __defProp = Object.defineProperty;
12679
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12680
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12681
+ const RUNNING_STATUSES = ["started", "submitted", "running"];
12682
+ const isRunning = (status = "") => RUNNING_STATUSES.includes(status);
12683
+ const isCustomMeta = (meta) => {
12684
+ return !!(typeof meta === "object" && (meta == null ? undefined : meta.hasOwnProperty("queryID")) && (meta == null ? undefined : meta.hasOwnProperty("status")));
12685
+ };
12686
+ class DatasourceWithAsyncBackend extends runtime.DataSourceWithBackend {
12687
+ constructor(instanceSettings) {
12688
+ var _a;
12689
+ super(instanceSettings);
12690
+ __publicField(this, "runningQueries", {});
12691
+ __publicField(this, "requestCounter", 100);
12692
+ __publicField(this, "requestIdPrefix");
12693
+ // cancel sets shouldCancel to tell requestLooper to cancel the query
12694
+ __publicField(this, "cancel", (target) => {
12695
+ this.storeQuery(target, { shouldCancel: true });
12696
+ });
12697
+ this.requestIdPrefix = (_a = instanceSettings.uid) != null ? _a : instanceSettings.id;
12698
+ }
12699
+ query(request) {
12700
+ const targets = this.filterQuery ? request.targets.filter(this.filterQuery) : request.targets;
12701
+ if (!targets.length) {
12702
+ return rxjs.of({ data: [] });
12703
+ }
12704
+ const all = [];
12705
+ for (let target of targets) {
12706
+ if (target.hide) {
12707
+ continue;
12708
+ }
12709
+ all.push(this.doSingle(target, request));
12710
+ }
12711
+ return rxjs.merge(...all);
12712
+ }
12713
+ storeQuery(target, queryInfo) {
12714
+ const key = JSON.stringify(target);
12715
+ const existingQueryInfo = this.runningQueries[key] || {};
12716
+ this.runningQueries[key] = { ...existingQueryInfo, ...queryInfo };
12717
+ }
12718
+ getQuery(target) {
12719
+ const key = JSON.stringify(target);
12720
+ return this.runningQueries[key] || {};
12721
+ }
12722
+ removeQuery(target) {
12723
+ const key = JSON.stringify(target);
12724
+ delete this.runningQueries[key];
12725
+ }
12726
+ doSingle(target, request) {
12727
+ let queryID = undefined;
12728
+ let status = undefined;
12729
+ let allData = [];
12730
+ return getRequestLooper(
12731
+ { ...request, targets: [target], requestId: `${this.requestIdPrefix}_${this.requestCounter++}` },
12732
+ {
12733
+ /**
12734
+ * Additional query to execute if the current query is still in a running state
12735
+ */
12736
+ getNextQuery: (rsp) => {
12737
+ var _a, _b;
12738
+ if ((_a = rsp.data) == null ? undefined : _a.length) {
12739
+ const first = rsp.data[0];
12740
+ const meta = (_b = first.meta) == null ? undefined : _b.custom;
12741
+ if (isCustomMeta(meta) && isRunning(meta.status)) {
12742
+ queryID = meta.queryID;
12743
+ status = meta.status;
12744
+ this.storeQuery(target, { queryID });
12745
+ return { ...target, queryID };
12746
+ }
12747
+ }
12748
+ this.removeQuery(target);
12749
+ return undefined;
12750
+ },
12751
+ /**
12752
+ * The original request
12753
+ */
12754
+ query: (request2) => {
12755
+ const { range, targets, requestId, intervalMs, maxDataPoints } = request2;
12756
+ const [_query] = targets;
12757
+ const query = {
12758
+ ..._query,
12759
+ meta: { queryFlow: "async" },
12760
+ intervalMs,
12761
+ maxDataPoints,
12762
+ // getRef optionally chained to support < v8.3.x of Grafana
12763
+ datasource: this == null ? undefined : this.getRef(),
12764
+ datasourceId: this.id,
12765
+ ...this.applyTemplateVariables(_query, request2.scopedVars)
12766
+ };
12767
+ const cachingDisabled = !runtime.config.featureToggles.awsAsyncQueryCaching;
12768
+ if (cachingDisabled && isRunning(status)) {
12769
+ const requestSkipQueryCacheUnsupported = semverExports.lt(runtime.config.buildInfo.version, "10.2.3");
12770
+ if (requestSkipQueryCacheUnsupported) {
12771
+ return runtime.getBackendSrv().fetch({
12772
+ method: "POST",
12773
+ url: "/api/ds/query",
12774
+ headers: { "X-Cache-Skip": true },
12775
+ requestId,
12776
+ data: {
12777
+ queries: [query],
12778
+ range,
12779
+ from: range.from.valueOf().toString(),
12780
+ to: range.to.valueOf().toString()
12781
+ }
12782
+ }).pipe(
12783
+ operators$1.map((result) => ({ data: runtime.toDataQueryResponse(result).data })),
12784
+ operators$1.catchError((err) => rxjs.of(runtime.toDataQueryResponse(err)))
12785
+ );
12786
+ }
12787
+ return super.query({ ...request2, targets: [query], skipQueryCache: true });
12788
+ }
12789
+ return super.query({ ...request2, targets: [query] });
12790
+ },
12791
+ /**
12792
+ * Process the results
12793
+ */
12794
+ process: (data) => {
12795
+ for (const frame of data) {
12796
+ if (frame.fields.length > 0) {
12797
+ allData.push(frame);
12798
+ }
12799
+ }
12800
+ return allData;
12801
+ },
12802
+ shouldCancel: () => {
12803
+ const { shouldCancel } = this.getQuery(target);
12804
+ return !!shouldCancel;
12805
+ },
12806
+ /**
12807
+ * Callback that gets executed when unsubscribed
12808
+ */
12809
+ onCancel: () => {
12810
+ if (queryID) {
12811
+ this.removeQuery(target);
12812
+ this.postResource("cancel", {
12813
+ queryId: queryID
12814
+ }).catch((err) => {
12815
+ err.isHandled = true;
12816
+ console.error(`error cancelling query ID: ${queryID}`, err);
12817
+ });
12818
+ }
12819
+ }
12820
+ }
12821
+ );
12822
+ }
12823
+ }
12824
+
12825
+ const RunQueryButtons = (props) => {
12826
+ const { state } = props;
12827
+ const [running, setRunning] = React.useState(false);
12828
+ const [stopping, setStopping] = React.useState(false);
12829
+ const [prevState, setPrevState] = React.useState(state);
12830
+ const [lastQuery, setLastQuery] = React.useState(props.query);
12831
+ if (state !== prevState) {
12832
+ setPrevState(state);
12833
+ if (state && state !== data.LoadingState.Loading) {
12834
+ setRunning(false);
12835
+ setStopping(false);
12836
+ }
12837
+ }
12838
+ const onRunQuery = () => {
12839
+ setRunning(true);
12840
+ setLastQuery(props.query);
12841
+ props.onRunQuery();
12842
+ };
12843
+ const onCancelQuery = props.onCancelQuery ? () => {
12844
+ var _a;
12845
+ (_a = props.onCancelQuery) == null ? undefined : _a.call(props, lastQuery);
12846
+ setStopping(true);
12847
+ } : undefined;
12848
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
12849
+ ui.Button,
12850
+ {
12851
+ variant: props.enableRun ? "primary" : "secondary",
12852
+ size: "sm",
12853
+ onClick: onRunQuery,
12854
+ icon: running && !stopping ? "fa fa-spinner" : undefined,
12855
+ disabled: state === data.LoadingState.Loading || !props.enableRun
12856
+ },
12857
+ "Run query"
12858
+ ), /* @__PURE__ */ React__default.default.createElement(
12859
+ ui.Button,
12860
+ {
12861
+ variant: running && !stopping ? "primary" : "secondary",
12862
+ size: "sm",
12863
+ disabled: !running || stopping,
12864
+ icon: stopping ? "fa fa-spinner" : undefined,
12865
+ onClick: onCancelQuery
12866
+ },
12867
+ "Stop query"
12868
+ ));
12869
+ };
12870
+
9846
12871
  exports.AccessoryButton = AccessoryButton;
9847
12872
  exports.AdvancedHttpSettings = AdvancedHttpSettings;
9848
12873
  exports.Auth = Auth;
@@ -9862,6 +12887,7 @@ exports.DataLinks = DataLinks;
9862
12887
  exports.DataSourceDescription = DataSourceDescription;
9863
12888
  exports.DataSourcePicker = DataSourcePicker;
9864
12889
  exports.DatasetSelector = DatasetSelector;
12890
+ exports.DatasourceWithAsyncBackend = DatasourceWithAsyncBackend;
9865
12891
  exports.DatePicker = DatePicker;
9866
12892
  exports.DatePickerWithInput = DatePickerWithInput;
9867
12893
  exports.DebounceInput = DebounceInput;
@@ -9897,6 +12923,7 @@ exports.QueryModellerBase = QueryModellerBase;
9897
12923
  exports.QueryOptionGroup = QueryOptionGroup;
9898
12924
  exports.RawQuery = RawQuery;
9899
12925
  exports.RunQueryButton = RunQueryButton;
12926
+ exports.RunQueryButtons = RunQueryButtons;
9900
12927
  exports.SQLEditor = SQLEditor;
9901
12928
  exports.SQLEditorMode = SQLEditorMode;
9902
12929
  exports.SQLEditorTestUtils = SQLEditorTestUtils;
@@ -9912,6 +12939,7 @@ exports.TableSelector = TableSelector;
9912
12939
  exports.TokenType = TokenType;
9913
12940
  exports.convertLegacyAuthProps = convertLegacyAuthProps;
9914
12941
  exports.formatDate = formatDate;
12942
+ exports.getRequestLooper = getRequestLooper;
9915
12943
  exports.getStandardSQLCompletionProvider = getStandardSQLCompletionProvider;
9916
12944
  exports.grafanaStandardSQLLanguage = language;
9917
12945
  exports.grafanaStandardSQLLanguageConf = conf;