@react-querybuilder/core 8.20.1 → 8.21.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.
- package/README.md +4 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2261 -2113
- package/dist/cjs/react-querybuilder_core.cjs.development.js +323 -26
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2261 -2113
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-BJKNgecE.js → convertQuery-Cw76XFIn.js} +8 -8
- package/dist/{convertQuery-BJKNgecE.js.map → convertQuery-Cw76XFIn.js.map} +1 -1
- package/dist/{convertQuery-J1CaoDxe.mjs → convertQuery-D_4J7E-Z.mjs} +2 -2
- package/dist/{convertQuery-J1CaoDxe.mjs.map → convertQuery-D_4J7E-Z.mjs.map} +1 -1
- package/dist/formatQuery.d.mts +499 -459
- package/dist/formatQuery.d.ts +499 -459
- package/dist/formatQuery.js +173 -91
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +100 -23
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/import-BVdxeIBO.d.mts +26 -0
- package/dist/import-Ddc3d_8q.d.ts +26 -0
- package/dist/{index-DlVg-QXo.d.mts → index-BSwFvkeI.d.mts} +679 -648
- package/dist/{index-DlVg-QXo.d.ts → index-BSwFvkeI.d.ts} +679 -648
- package/dist/{objectUtils-DBJI82bl.js → isRuleGroup-0JNiQgLg.js} +1 -26
- package/dist/isRuleGroup-0JNiQgLg.js.map +1 -0
- package/dist/{objectUtils-ZvPkF6u6.mjs → isRuleGroup-CqLThsbu.mjs} +2 -15
- package/dist/isRuleGroup-CqLThsbu.mjs.map +1 -0
- package/dist/objectUtils-Cr02aGxb.js +27 -0
- package/dist/objectUtils-Cr02aGxb.js.map +1 -0
- package/dist/objectUtils-DBlmJgBf.mjs +16 -0
- package/dist/objectUtils-DBlmJgBf.mjs.map +1 -0
- package/dist/parseCEL.d.mts +64 -30
- package/dist/parseCEL.d.ts +64 -30
- package/dist/parseCEL.js +91 -12
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +85 -8
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +24 -25
- package/dist/parseCypher.d.ts +24 -25
- package/dist/parseGremlin.d.mts +18 -19
- package/dist/parseGremlin.d.ts +18 -19
- package/dist/parseJSONata.d.mts +207 -20
- package/dist/parseJSONata.d.ts +207 -20
- package/dist/parseJSONata.js +92 -7
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +80 -4
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +51 -18
- package/dist/parseJsonLogic.d.ts +51 -18
- package/dist/parseJsonLogic.js +95 -34
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +65 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +89 -58
- package/dist/parseMongoDB.d.ts +89 -58
- package/dist/parseMongoDB.js +140 -15
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +128 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSPARQL.d.mts +17 -18
- package/dist/parseSPARQL.d.ts +17 -18
- package/dist/parseSPARQL.js.map +1 -1
- package/dist/parseSPARQL.mjs.map +1 -1
- package/dist/parseSQL.d.mts +266 -18
- package/dist/parseSQL.d.ts +266 -18
- package/dist/parseSQL.js +163 -10
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +149 -7
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +193 -19
- package/dist/parseSpEL.d.ts +193 -19
- package/dist/parseSpEL.js +166 -7
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +142 -6
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-DaAXX792.js → prepareQueryObjects-C2-kTZvR.js} +6 -6
- package/dist/prepareQueryObjects-C2-kTZvR.js.map +1 -0
- package/dist/{prepareQueryObjects-Cd_tt4oy.mjs → prepareQueryObjects-Q18lHCKl.mjs} +4 -4
- package/dist/prepareQueryObjects-Q18lHCKl.mjs.map +1 -0
- package/dist/query-builder-layout.css.map +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +2261 -2113
- package/dist/react-querybuilder_core.legacy-esm.d.ts +2261 -2113
- package/dist/react-querybuilder_core.legacy-esm.js +339 -44
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +313 -27
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +2261 -2113
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_layout.scss +4 -10
- package/dist/transformQuery.d.mts +91 -92
- package/dist/transformQuery.d.ts +91 -92
- package/dist/transformQuery.js +4 -3
- package/dist/transformQuery.js.map +1 -1
- package/dist/transformQuery.mjs +2 -1
- package/dist/transformQuery.mjs.map +1 -1
- package/dist/{utils-BpaOtylk.js → utils-DEwV7F6B.js} +108 -12
- package/dist/utils-DEwV7F6B.js.map +1 -0
- package/dist/{utils-CJRGiPb-.mjs → utils-Dt0D_DMV.mjs} +69 -3
- package/dist/utils-Dt0D_DMV.mjs.map +1 -0
- package/package.json +15 -14
- package/dist/import-Qs1-kgv5.d.ts +0 -27
- package/dist/import-ShTj5IdB.d.mts +0 -27
- package/dist/objectUtils-DBJI82bl.js.map +0 -1
- package/dist/objectUtils-ZvPkF6u6.mjs.map +0 -1
- package/dist/prepareQueryObjects-Cd_tt4oy.mjs.map +0 -1
- package/dist/prepareQueryObjects-DaAXX792.js.map +0 -1
- package/dist/utils-BpaOtylk.js.map +0 -1
- package/dist/utils-CJRGiPb-.mjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
|
|
2
2
|
//#region src/utils/convertQuery.ts
|
|
3
3
|
const combinatorLevels = [
|
|
4
4
|
"or",
|
|
5
5
|
"xor",
|
|
6
6
|
"and"
|
|
7
7
|
];
|
|
8
|
-
const isSameString = (a, b) =>
|
|
8
|
+
const isSameString = (a, b) => require_isRuleGroup.lc(a) === b;
|
|
9
9
|
const generateRuleGroupICWithConsistentCombinators = (rg, baseCombinatorLevel = 0) => {
|
|
10
10
|
const baseCombinator = combinatorLevels[baseCombinatorLevel];
|
|
11
11
|
if (!rg.rules.includes(baseCombinator)) return baseCombinatorLevel < combinatorLevels.length - 2 ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1) : rg;
|
|
@@ -17,7 +17,7 @@ const generateRuleGroupICWithConsistentCombinators = (rg, baseCombinatorLevel =
|
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
let nextBaseCombinatorIndex = -1;
|
|
20
|
-
for (let i = cursor + 2; i < newRules.length; i++) if (typeof newRules[i] === "string" &&
|
|
20
|
+
for (let i = cursor + 2; i < newRules.length; i++) if (typeof newRules[i] === "string" && require_isRuleGroup.lc(newRules[i]) === baseCombinator) {
|
|
21
21
|
nextBaseCombinatorIndex = i;
|
|
22
22
|
break;
|
|
23
23
|
}
|
|
@@ -40,13 +40,13 @@ const generateRuleGroupICWithConsistentCombinators = (rg, baseCombinatorLevel =
|
|
|
40
40
|
* @group Query Tools
|
|
41
41
|
*/
|
|
42
42
|
const convertFromIC = (rg) => {
|
|
43
|
-
if (
|
|
43
|
+
if (require_isRuleGroup.isRuleGroupType(rg)) return rg;
|
|
44
44
|
const processedRG = generateRuleGroupICWithConsistentCombinators(rg);
|
|
45
45
|
const rules = [];
|
|
46
46
|
let combinator = "and";
|
|
47
47
|
for (const [idx, r] of processedRG.rules.entries()) if (typeof r === "string") {
|
|
48
48
|
if (idx === 1) combinator = r;
|
|
49
|
-
} else rules.push(
|
|
49
|
+
} else rules.push(require_isRuleGroup.isRuleGroup(r) ? convertFromIC(r) : r);
|
|
50
50
|
return {
|
|
51
51
|
...processedRG,
|
|
52
52
|
combinator,
|
|
@@ -62,13 +62,13 @@ const convertFromIC = (rg) => {
|
|
|
62
62
|
* @group Query Tools
|
|
63
63
|
*/
|
|
64
64
|
const convertToIC = (rg) => {
|
|
65
|
-
if (
|
|
65
|
+
if (require_isRuleGroup.isRuleGroupTypeIC(rg)) return rg;
|
|
66
66
|
const { combinator, ...queryWithoutCombinator } = rg;
|
|
67
67
|
const rules = [];
|
|
68
68
|
const { length } = rg.rules;
|
|
69
69
|
for (let idx = 0; idx < length; idx++) {
|
|
70
70
|
const r = rg.rules[idx];
|
|
71
|
-
if (
|
|
71
|
+
if (require_isRuleGroup.isRuleGroup(r)) rules.push(convertToIC(r));
|
|
72
72
|
else rules.push(r);
|
|
73
73
|
if (combinator && idx < length - 1) rules.push(combinator);
|
|
74
74
|
}
|
|
@@ -91,4 +91,4 @@ Object.defineProperty(exports, "convertToIC", {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=convertQuery-
|
|
94
|
+
//# sourceMappingURL=convertQuery-Cw76XFIn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertQuery-
|
|
1
|
+
{"version":3,"file":"convertQuery-Cw76XFIn.js","names":["lc","isRuleGroupType","isRuleGroup","isRuleGroupTypeIC"],"sources":["../src/utils/convertQuery.ts"],"sourcesContent":["import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n ToRuleGroupType,\n ToRuleGroupTypeIC,\n} from '../types';\nimport { isRuleGroup, isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { lc } from './misc';\n\nconst combinatorLevels = ['or', 'xor', 'and'] as const;\n\nconst isSameString = (a: unknown, b: string) => lc(a) === b;\n\nconst generateRuleGroupICWithConsistentCombinators = (\n rg: RuleGroupTypeIC,\n baseCombinatorLevel: number = 0\n): RuleGroupTypeIC => {\n const baseCombinator = combinatorLevels[baseCombinatorLevel];\n\n // oxlint-disable-next-line typescript/no-explicit-any\n if (!rg.rules.includes(baseCombinator as any)) {\n // No instances of this combinator, so group based on the next\n // combinator level if at least two levels remain\n return baseCombinatorLevel < combinatorLevels.length - 2\n ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1)\n : rg;\n }\n\n const newRules = [...rg.rules] as RuleGroupICArray;\n let cursor = 0;\n\n // Group all chains of combinators in the rule array that are not the base combinator\n while (cursor < newRules.length - 2) {\n if (isSameString(newRules[cursor + 1], baseCombinator)) {\n cursor += 2;\n continue;\n }\n\n let nextBaseCombinatorIndex = -1;\n for (let i = cursor + 2; i < newRules.length; i++) {\n if (typeof newRules[i] === 'string' && lc(newRules[i]) === baseCombinator) {\n nextBaseCombinatorIndex = i;\n break;\n }\n }\n\n if (nextBaseCombinatorIndex === -1) {\n // No more instances of this combinator, so group all remaining rules and exit the loop\n newRules.splice(\n cursor,\n newRules.length,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: newRules.slice(cursor) as any },\n baseCombinatorLevel + 1\n )\n );\n break;\n } else {\n // Group all rules between the current cursor and the next instance of the base combinator\n newRules.splice(\n cursor,\n nextBaseCombinatorIndex - cursor,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: newRules.slice(cursor, nextBaseCombinatorIndex) as any },\n baseCombinatorLevel + 1\n )\n );\n }\n }\n\n return { ...rg, rules: newRules };\n};\n\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.\n *\n * This function is idempotent: {@link RuleGroupType} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertFromIC = <RG extends RuleGroupTypeAny>(rg: RG): ToRuleGroupType<RG> => {\n if (isRuleGroupType(rg)) {\n return rg as ToRuleGroupType<RG>;\n }\n const processedRG = generateRuleGroupICWithConsistentCombinators(rg);\n const rules: RuleGroupArray = [];\n let combinator = 'and';\n for (const [idx, r] of processedRG.rules.entries()) {\n if (typeof r === 'string') {\n if (idx === 1) combinator = r;\n } else {\n rules.push(isRuleGroup(r) ? convertFromIC(r) : r);\n }\n }\n return { ...processedRG, combinator, rules } as ToRuleGroupType<RG>;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.\n *\n * This function is idempotent: {@link RuleGroupTypeIC} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertToIC = <RG extends RuleGroupTypeAny>(rg: RG): ToRuleGroupTypeIC<RG> => {\n if (isRuleGroupTypeIC(rg)) {\n return rg as ToRuleGroupTypeIC<RG>;\n }\n const { combinator, ...queryWithoutCombinator } = rg;\n const rules: (RuleGroupTypeIC | RuleType | string)[] = [];\n const { length } = rg.rules;\n for (let idx = 0; idx < length; idx++) {\n const r = rg.rules[idx];\n if (isRuleGroup(r)) {\n rules.push(convertToIC(r));\n } else {\n rules.push(r);\n }\n if (combinator && idx < length - 1) {\n rules.push(combinator);\n }\n }\n return { ...queryWithoutCombinator, rules } as ToRuleGroupTypeIC<RG>;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}. For a more explicit\n * operation, use {@link convertToIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupType): RuleGroupTypeIC;\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}. For a more explicit\n * operation, use {@link convertFromIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupTypeIC): RuleGroupType;\nfunction convertQuery(query: RuleGroupType | RuleGroupTypeIC): RuleGroupType | RuleGroupTypeIC {\n return isRuleGroupTypeIC(query) ?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AAI,OAAO,MAAM,UACX;MAAA,QAAQ,GAAG,aAAa;CAAA,OAE5B,MAAM,KAAKC,oBAAAA,YAAY,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC;CAGpD,OAAO;EAAE,GAAG;EAAa;EAAY;CAAM;AAC7C;;;;;;;;;AAUA,MAAa,eAA4C,OAAkC;CACzF,IAAIC,oBAAAA,kBAAkB,EAAE,GACtB,OAAO;CAET,MAAM,EAAE,YAAY,GAAG,2BAA2B;CAClD,MAAM,QAAiD,CAAC;CACxD,MAAM,EAAE,WAAW,GAAG;CACtB,KAAK,IAAI,MAAM,GAAG,MAAM,QAAQ,OAAO;EACrC,MAAM,IAAI,GAAG,MAAM;EACnB,IAAID,oBAAAA,YAAY,CAAC,GACf,MAAM,KAAK,YAAY,CAAC,CAAC;OAEzB,MAAM,KAAK,CAAC;EAEd,IAAI,cAAc,MAAM,SAAS,GAC/B,MAAM,KAAK,UAAU;CAEzB;CACA,OAAO;EAAE,GAAG;EAAwB;CAAM;AAC5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as lc, n as isRuleGroupType, r as isRuleGroupTypeIC, t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
|
|
2
2
|
//#region src/utils/convertQuery.ts
|
|
3
3
|
const combinatorLevels = [
|
|
4
4
|
"or",
|
|
@@ -80,4 +80,4 @@ const convertToIC = (rg) => {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { convertToIC as n, convertFromIC as t };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=convertQuery-
|
|
83
|
+
//# sourceMappingURL=convertQuery-D_4J7E-Z.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertQuery-
|
|
1
|
+
{"version":3,"file":"convertQuery-D_4J7E-Z.mjs","names":[],"sources":["../src/utils/convertQuery.ts"],"sourcesContent":["import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n ToRuleGroupType,\n ToRuleGroupTypeIC,\n} from '../types';\nimport { isRuleGroup, isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { lc } from './misc';\n\nconst combinatorLevels = ['or', 'xor', 'and'] as const;\n\nconst isSameString = (a: unknown, b: string) => lc(a) === b;\n\nconst generateRuleGroupICWithConsistentCombinators = (\n rg: RuleGroupTypeIC,\n baseCombinatorLevel: number = 0\n): RuleGroupTypeIC => {\n const baseCombinator = combinatorLevels[baseCombinatorLevel];\n\n // oxlint-disable-next-line typescript/no-explicit-any\n if (!rg.rules.includes(baseCombinator as any)) {\n // No instances of this combinator, so group based on the next\n // combinator level if at least two levels remain\n return baseCombinatorLevel < combinatorLevels.length - 2\n ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1)\n : rg;\n }\n\n const newRules = [...rg.rules] as RuleGroupICArray;\n let cursor = 0;\n\n // Group all chains of combinators in the rule array that are not the base combinator\n while (cursor < newRules.length - 2) {\n if (isSameString(newRules[cursor + 1], baseCombinator)) {\n cursor += 2;\n continue;\n }\n\n let nextBaseCombinatorIndex = -1;\n for (let i = cursor + 2; i < newRules.length; i++) {\n if (typeof newRules[i] === 'string' && lc(newRules[i]) === baseCombinator) {\n nextBaseCombinatorIndex = i;\n break;\n }\n }\n\n if (nextBaseCombinatorIndex === -1) {\n // No more instances of this combinator, so group all remaining rules and exit the loop\n newRules.splice(\n cursor,\n newRules.length,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: newRules.slice(cursor) as any },\n baseCombinatorLevel + 1\n )\n );\n break;\n } else {\n // Group all rules between the current cursor and the next instance of the base combinator\n newRules.splice(\n cursor,\n nextBaseCombinatorIndex - cursor,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: newRules.slice(cursor, nextBaseCombinatorIndex) as any },\n baseCombinatorLevel + 1\n )\n );\n }\n }\n\n return { ...rg, rules: newRules };\n};\n\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.\n *\n * This function is idempotent: {@link RuleGroupType} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertFromIC = <RG extends RuleGroupTypeAny>(rg: RG): ToRuleGroupType<RG> => {\n if (isRuleGroupType(rg)) {\n return rg as ToRuleGroupType<RG>;\n }\n const processedRG = generateRuleGroupICWithConsistentCombinators(rg);\n const rules: RuleGroupArray = [];\n let combinator = 'and';\n for (const [idx, r] of processedRG.rules.entries()) {\n if (typeof r === 'string') {\n if (idx === 1) combinator = r;\n } else {\n rules.push(isRuleGroup(r) ? convertFromIC(r) : r);\n }\n }\n return { ...processedRG, combinator, rules } as ToRuleGroupType<RG>;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.\n *\n * This function is idempotent: {@link RuleGroupTypeIC} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertToIC = <RG extends RuleGroupTypeAny>(rg: RG): ToRuleGroupTypeIC<RG> => {\n if (isRuleGroupTypeIC(rg)) {\n return rg as ToRuleGroupTypeIC<RG>;\n }\n const { combinator, ...queryWithoutCombinator } = rg;\n const rules: (RuleGroupTypeIC | RuleType | string)[] = [];\n const { length } = rg.rules;\n for (let idx = 0; idx < length; idx++) {\n const r = rg.rules[idx];\n if (isRuleGroup(r)) {\n rules.push(convertToIC(r));\n } else {\n rules.push(r);\n }\n if (combinator && idx < length - 1) {\n rules.push(combinator);\n }\n }\n return { ...queryWithoutCombinator, rules } as ToRuleGroupTypeIC<RG>;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}. For a more explicit\n * operation, use {@link convertToIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupType): RuleGroupTypeIC;\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}. For a more explicit\n * operation, use {@link convertFromIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupTypeIC): RuleGroupType;\nfunction convertQuery(query: RuleGroupType | RuleGroupTypeIC): RuleGroupType | RuleGroupTypeIC {\n return isRuleGroupTypeIC(query) ? convertFromIC(query) : convertToIC(query);\n}\n\nexport { convertQuery };\n"],"mappings":";;AAaA,MAAM,mBAAmB;CAAC;CAAM;CAAO;AAAK;AAE5C,MAAM,gBAAgB,GAAY,MAAc,GAAG,CAAC,MAAM;AAE1D,MAAM,gDACJ,IACA,sBAA8B,MACV;CACpB,MAAM,iBAAiB,iBAAiB;CAGxC,IAAI,CAAC,GAAG,MAAM,SAAS,cAAqB,GAG1C,OAAO,sBAAsB,iBAAiB,SAAS,IACnD,6CAA6C,IAAI,sBAAsB,CAAC,IACxE;CAGN,MAAM,WAAW,CAAC,GAAG,GAAG,KAAK;CAC7B,IAAI,SAAS;CAGb,OAAO,SAAS,SAAS,SAAS,GAAG;EACnC,IAAI,aAAa,SAAS,SAAS,IAAI,cAAc,GAAG;GACtD,UAAU;GACV;EACF;EAEA,IAAI,0BAA0B;EAC9B,KAAK,IAAI,IAAI,SAAS,GAAG,IAAI,SAAS,QAAQ,KAC5C,IAAI,OAAO,SAAS,OAAO,YAAY,GAAG,SAAS,EAAE,MAAM,gBAAgB;GACzE,0BAA0B;GAC1B;EACF;EAGF,IAAI,4BAA4B,IAAI;GAElC,SAAS,OACP,QACA,SAAS,QACT,6CAEE,EAAE,OAAO,SAAS,MAAM,MAAM,EAAS,GACvC,sBAAsB,CACxB,CACF;GACA;EACF,OAEE,SAAS,OACP,QACA,0BAA0B,QAC1B,6CAEE,EAAE,OAAO,SAAS,MAAM,QAAQ,uBAAuB,EAAS,GAChE,sBAAsB,CACxB,CACF;CAEJ;CAEA,OAAO;EAAE,GAAG;EAAI,OAAO;CAAS;AAClC;;;;;;;;;AAUA,MAAa,iBAA8C,OAAgC;CACzF,IAAI,gBAAgB,EAAE,GACpB,OAAO;CAET,MAAM,cAAc,6CAA6C,EAAE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