@evlop/commons 1.0.261 → 1.0.262
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/dist/cjs/src/edl/ExpressionHelper.d.ts +8 -0
- package/dist/cjs/src/edl/ExpressionHelper.d.ts.map +1 -0
- package/dist/cjs/src/edl/ExpressionHelper.js +52 -0
- package/dist/cjs/src/edl/ExpressionHelper.js.map +1 -0
- package/dist/cjs/src/edl/parser.d.ts +1 -1
- package/dist/cjs/src/edl/parser.d.ts.map +1 -1
- package/dist/cjs/src/edl/parser.js +103 -64
- package/dist/cjs/src/edl/parser.js.map +1 -1
- package/dist/cjs/src/edl/parser.test.js +280 -206
- package/dist/cjs/src/edl/parser.test.js.map +1 -1
- package/dist/esm/src/edl/ExpressionHelper.d.ts +8 -0
- package/dist/esm/src/edl/ExpressionHelper.d.ts.map +1 -0
- package/dist/esm/src/edl/ExpressionHelper.js +50 -0
- package/dist/esm/src/edl/ExpressionHelper.js.map +1 -0
- package/dist/esm/src/edl/parser.d.ts +1 -1
- package/dist/esm/src/edl/parser.d.ts.map +1 -1
- package/dist/esm/src/edl/parser.js +100 -64
- package/dist/esm/src/edl/parser.js.map +1 -1
- package/dist/esm/src/edl/parser.test.js +280 -206
- package/dist/esm/src/edl/parser.test.js.map +1 -1
- package/dist/types/src/edl/ExpressionHelper.d.ts +8 -0
- package/dist/types/src/edl/ExpressionHelper.d.ts.map +1 -0
- package/dist/types/src/edl/parser.d.ts +1 -1
- package/dist/types/src/edl/parser.d.ts.map +1 -1
- package/package.json +1 -1
@@ -0,0 +1,8 @@
|
|
1
|
+
declare const ExpressionHelper: {
|
2
|
+
breakTemplateStringToExpressionsAndStaticString: (templateString: string) => any[];
|
3
|
+
safelyCompileStringTemplate: (variables: string[]) => (templateString: string) => TimerHandler;
|
4
|
+
safelyCompileExpression: (variables: string[]) => (expression: string) => Function;
|
5
|
+
evaluateExpressionForValue: (expression: string) => any;
|
6
|
+
};
|
7
|
+
export default ExpressionHelper;
|
8
|
+
//# sourceMappingURL=ExpressionHelper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ExpressionHelper.d.ts","sourceRoot":"","sources":["../../../../src/edl/ExpressionHelper.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,gBAAgB;sEAC8C,MAAM;6CAwB/B,MAAM,EAAE,sBAEvB,MAAM;yCAWM,MAAM,EAAE,kBAExB,MAAM;6CAMa,MAAM;CAGhD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
// Regex to match expressions in EDL
|
4
|
+
const expressionRegex = /{(\((?:(?!\)\}).)*\)|[^{}]*)}/g;
|
5
|
+
const ExpressionHelper = {
|
6
|
+
breakTemplateStringToExpressionsAndStaticString: (templateString) => {
|
7
|
+
const parts = [];
|
8
|
+
const regex = new RegExp(expressionRegex);
|
9
|
+
let match;
|
10
|
+
let lastIndex = 0;
|
11
|
+
while ((match = regex.exec(templateString)) !== null) {
|
12
|
+
const startIndex = match.index;
|
13
|
+
const endIndex = startIndex + match[0].length;
|
14
|
+
if (startIndex > lastIndex) {
|
15
|
+
parts.push({ startIndex, endIndex, type: 'string', value: templateString.slice(lastIndex, startIndex) });
|
16
|
+
}
|
17
|
+
parts.push({ startIndex, endIndex, type: 'expression', value: match[1] });
|
18
|
+
lastIndex = endIndex;
|
19
|
+
}
|
20
|
+
if (lastIndex < templateString.length) {
|
21
|
+
parts.push({ startIndex: lastIndex, endIndex: templateString.length, type: 'string', value: templateString.slice(lastIndex) });
|
22
|
+
}
|
23
|
+
return parts;
|
24
|
+
},
|
25
|
+
safelyCompileStringTemplate: (variables) => {
|
26
|
+
const variableNamesString = `{ ${variables.join(', ')} }`;
|
27
|
+
return (templateString) => {
|
28
|
+
try {
|
29
|
+
// replace all the {expression} with ${ expression } and wrap the whole template in a function
|
30
|
+
const processedTemplate = templateString.replace(expressionRegex, "${ $1 }");
|
31
|
+
if (processedTemplate === templateString)
|
32
|
+
return templateString;
|
33
|
+
return new Function(variableNamesString, `return \`${processedTemplate}\`;`);
|
34
|
+
}
|
35
|
+
catch (e) { }
|
36
|
+
};
|
37
|
+
},
|
38
|
+
safelyCompileExpression: (variables) => {
|
39
|
+
const variableNamesString = `{ ${variables.join(', ')} }`;
|
40
|
+
return (expression) => {
|
41
|
+
try {
|
42
|
+
return new Function(variableNamesString, `return ${expression};`);
|
43
|
+
}
|
44
|
+
catch (e) { }
|
45
|
+
};
|
46
|
+
},
|
47
|
+
evaluateExpressionForValue: (expression) => {
|
48
|
+
return eval(`(${expression})`);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
exports.default = ExpressionHelper;
|
52
|
+
//# sourceMappingURL=ExpressionHelper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ExpressionHelper.js","sourceRoot":"","sources":["../../../../src/edl/ExpressionHelper.ts"],"names":[],"mappings":";;AAAA,oCAAoC;AACpC,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAEzD,MAAM,gBAAgB,GAAG;IACvB,+CAA+C,EAAE,CAAC,cAAsB,EAAE,EAAE;QAC1E,MAAM,KAAK,GAAG,EAAE,CAAC;QAEjB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC;QACV,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,IAAI,EAAE;YACpD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;YAC/B,MAAM,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC9C,IAAG,UAAU,GAAG,SAAS,EAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,Q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BACD,OAAO,IAAI,QAAQ,CAAC,mBAAmB,EAAE,UAAU,UAAU,GAAG,CAAC,CAAC;aACnE;YAAC,OAAM,CAAC,EAAC,GAAE;QACd,CAAC,CAAA;IACH,CAAC;IACD,0BAA0B,EAAE,CAAC,UAAkB,EAAE,EAAE;QACjD,OAAO,IAAI,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC;IACjC,CAAC;CACF,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/edl/parser.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../src/edl/parser.ts"],"names":[],"mappings":"AAoIA,iBAAS,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,SAoJnE;AAGD,eAAe,QAAQ,CAAC"}
|
@@ -1,61 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
const lodash_1 = require("lodash");
|
4
7
|
const he_1 = require("he");
|
8
|
+
const ExpressionHelper_1 = __importDefault(require("./ExpressionHelper"));
|
5
9
|
const inbuiltVariables = ['context', 'data', 'setRuntimeData', 'setState', 'setStates', 'state', 'dispatchAction', 'createAction'];
|
6
|
-
// Regex to match expressions in EDL
|
7
|
-
const expressionRegex = /{(\((?:(?!\)\}).)*\)|[^{}]*)}/g;
|
8
10
|
// Regex to match opening tag in EDL
|
9
11
|
const openingTagRegex = /<([a-zA-Z0-9_]+)((?:\s+[a-zA-Z0-9_\-\.\:]+=(?:"[^"]*"|'[^']*'|`[^`]*`|\{\{(?:(?!\}\}).)*\}\}|\{\[(?:(?!\]\}).)*\]\}|\{\((?:(?!\)\}).)*\)\}|\{[^\}]*\}))*)\s*(\/)?>/s;
|
10
12
|
// Regex to match closing tag in EDL
|
11
13
|
const closingTagRegex = /<\/([a-zA-Z0-9_]+)>/;
|
12
14
|
// Regex to match attributes
|
13
|
-
const attributeRegex = /([a-zA-Z0-9_\-\.\:]+)=("[^"]*"|'[^']*'|`[^`]*`|\{
|
15
|
+
const attributeRegex = /([a-zA-Z0-9_\-\.\:]+)=("[^"]*"|'[^']*'|`[^`]*`|\{[^\}]*\})/sg;
|
14
16
|
// Regex to split the JSX string into tokens using opening or closing tag regex pattern
|
15
|
-
const openingOrClosingTagRegex = /(<(?:\/)?(?:[a-zA-Z0-9_]+)(?:(?:\s+[a-zA-Z0-9_\-\.\:]+=(?:"[^"]*"|'[^']*'|`[^`]*`|\{
|
16
|
-
const TemplateCompiler = {
|
17
|
-
breakTemplateStringToExpressionsAndStaticString: (templateString) => {
|
18
|
-
const parts = [];
|
19
|
-
const regex = new RegExp(expressionRegex);
|
20
|
-
let match;
|
21
|
-
let lastIndex = 0;
|
22
|
-
while ((match = regex.exec(templateString)) !== null) {
|
23
|
-
const startIndex = match.index;
|
24
|
-
const endIndex = startIndex + match[0].length;
|
25
|
-
if (startIndex > lastIndex) {
|
26
|
-
parts.push({ startIndex, endIndex, type: 'string', value: templateString.slice(lastIndex, startIndex) });
|
27
|
-
}
|
28
|
-
parts.push({ startIndex, endIndex, type: 'expression', value: match[1] });
|
29
|
-
lastIndex = endIndex;
|
30
|
-
}
|
31
|
-
if (lastIndex < templateString.length) {
|
32
|
-
parts.push({ startIndex: lastIndex, endIndex: templateString.length, type: 'string', value: templateString.slice(lastIndex) });
|
33
|
-
}
|
34
|
-
return parts;
|
35
|
-
},
|
36
|
-
compileStringTemplate: (variables) => {
|
37
|
-
const variableNamesString = `{ ${variables.join(', ')} }`;
|
38
|
-
return (templateString) => {
|
39
|
-
try {
|
40
|
-
// replace all the {expression} with ${ expression } and wrap the whole template in a function
|
41
|
-
const processedTemplate = templateString.replace(expressionRegex, "${ $1 }");
|
42
|
-
if (processedTemplate === templateString)
|
43
|
-
return templateString;
|
44
|
-
return new Function(variableNamesString, `return \`${processedTemplate}\`;`);
|
45
|
-
}
|
46
|
-
catch (e) { }
|
47
|
-
};
|
48
|
-
},
|
49
|
-
compileExpression: variables => {
|
50
|
-
const variableNamesString = `{ ${variables.join(', ')} }`;
|
51
|
-
return (expression) => {
|
52
|
-
try {
|
53
|
-
return new Function(variableNamesString, `return ${expression};`);
|
54
|
-
}
|
55
|
-
catch (e) { }
|
56
|
-
};
|
57
|
-
}
|
58
|
-
};
|
17
|
+
const openingOrClosingTagRegex = /(<(?:\/)?(?:[a-zA-Z0-9_]+)(?:(?:\s+[a-zA-Z0-9_\-\.\:]+=(?:"[^"]*"|'[^']*'|`[^`]*`|\{[^\}]*\}))*)\s*(?:\/)?>)/s;
|
59
18
|
function generateUniqueId() {
|
60
19
|
return lodash_1.random(1000, 9999999999).toString(36);
|
61
20
|
}
|
@@ -83,6 +42,65 @@ function extractScriptsAndVariables(inputString) {
|
|
83
42
|
});
|
84
43
|
return { cleanedString, scriptsById, variables: Array.from(allVariables) };
|
85
44
|
}
|
45
|
+
const expressionBracketOpeningClosingPairs = {
|
46
|
+
'{': '}',
|
47
|
+
'(': ')',
|
48
|
+
'[': ']',
|
49
|
+
'`': '`',
|
50
|
+
'"': '"',
|
51
|
+
"'": "'",
|
52
|
+
};
|
53
|
+
const stringDelimiters = new Set(['`', '"', "'"]);
|
54
|
+
const openingBrackets = new Set(Object.keys(expressionBracketOpeningClosingPairs));
|
55
|
+
const closingBrackets = new Set(Object.values(expressionBracketOpeningClosingPairs));
|
56
|
+
const allBrackets = new Set([...openingBrackets, ...closingBrackets]);
|
57
|
+
// look for { and go untill }, counting all (, {, } and ), untill all opening braces are matched with closing braces
|
58
|
+
function extractExpressions(inputString) {
|
59
|
+
const expressions = {};
|
60
|
+
let cleanedString = inputString;
|
61
|
+
const expressionPositions = [];
|
62
|
+
const stack = [];
|
63
|
+
let expressionStartPosition = -1;
|
64
|
+
for (let i = 0; i < inputString.length; i++) {
|
65
|
+
const char = inputString[i];
|
66
|
+
// Start new expression when we find an opening brace
|
67
|
+
if (char === '{' && stack.length === 0) {
|
68
|
+
expressionStartPosition = i + 1;
|
69
|
+
stack.push(char);
|
70
|
+
continue;
|
71
|
+
}
|
72
|
+
if (stack.length === 0)
|
73
|
+
continue; // if expression has not started yet, skip it
|
74
|
+
if (!allBrackets.has(char))
|
75
|
+
continue; // if the character is not a bracket, skip it
|
76
|
+
if (inputString[i - 1] === '\\')
|
77
|
+
continue; // if the character is escaped, skip it
|
78
|
+
const lastOpenedBracket = stack[stack.length - 1];
|
79
|
+
const requiredClosingBracket = expressionBracketOpeningClosingPairs[lastOpenedBracket];
|
80
|
+
if (char === requiredClosingBracket) {
|
81
|
+
stack.pop();
|
82
|
+
if (stack.length === 0) {
|
83
|
+
expressionPositions.push({ start: expressionStartPosition, end: i - 1 });
|
84
|
+
}
|
85
|
+
}
|
86
|
+
else if (stringDelimiters.has(lastOpenedBracket)) { // if a string delimiter is opened, we dont care obout other opening brackets
|
87
|
+
continue;
|
88
|
+
}
|
89
|
+
else if (openingBrackets.has(char)) {
|
90
|
+
stack.push(char);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
let correctionFactor = 0;
|
94
|
+
for (const { start, end } of expressionPositions) {
|
95
|
+
const expression = inputString.slice(start, end + 1);
|
96
|
+
const uniqueId = generateUniqueId();
|
97
|
+
expressions[uniqueId] = expression;
|
98
|
+
const newString = cleanedString.slice(0, start - correctionFactor) + uniqueId + cleanedString.slice(end - correctionFactor + 1);
|
99
|
+
cleanedString = newString;
|
100
|
+
correctionFactor += expression.length - uniqueId.length;
|
101
|
+
}
|
102
|
+
return { expressions, cleanedString };
|
103
|
+
}
|
86
104
|
const asVariableRegex = /:as="([^"]+)"/g;
|
87
105
|
function extractAsVariables(inputString) {
|
88
106
|
const asVariables = new Set();
|
@@ -93,22 +111,39 @@ function extractAsVariables(inputString) {
|
|
93
111
|
return Array.from(asVariables);
|
94
112
|
}
|
95
113
|
// This function takes a JSX string as input and returns an array of objects representing the parsed JSX structure.
|
96
|
-
function parseEDL(
|
114
|
+
function parseEDL(_edlString, additionalVariables) {
|
115
|
+
let edlString = _edlString;
|
97
116
|
// separate the scripts and extract variables from the edl string
|
98
117
|
const { cleanedString: edlStringWithCodeRemovedFromScript, scriptsById, variables: scriptVariables } = extractScriptsAndVariables(edlString);
|
118
|
+
edlString = edlStringWithCodeRemovedFromScript;
|
119
|
+
// extract expressions from the edl string
|
120
|
+
const { expressions: expressionsById, cleanedString: edlStringWithCodeRemovedFromScriptAndExpressionsRemoved } = extractExpressions(edlString);
|
121
|
+
edlString = edlStringWithCodeRemovedFromScriptAndExpressionsRemoved;
|
99
122
|
// remove unnecessary whitespace from the edl string, after code has been removed from the script tags
|
100
|
-
|
123
|
+
edlString = removeUnnecessaryWhitespace(edlString);
|
101
124
|
// Extract :as variables and include them in the union
|
102
|
-
const asVariables = extractAsVariables(
|
125
|
+
const asVariables = extractAsVariables(edlString);
|
103
126
|
const variables = lodash_1.union(inbuiltVariables, Array.from(additionalVariables), scriptVariables, asVariables);
|
104
|
-
const
|
105
|
-
const
|
106
|
-
const
|
127
|
+
const safelyCompileStringTemplate = ExpressionHelper_1.default.safelyCompileStringTemplate(variables);
|
128
|
+
const safelyCompileExpression = ExpressionHelper_1.default.safelyCompileExpression(variables);
|
129
|
+
const evaluateExpressionForValue = ExpressionHelper_1.default.evaluateExpressionForValue;
|
130
|
+
const breakTemplateStringToExpressionsAndStaticString = ExpressionHelper_1.default.breakTemplateStringToExpressionsAndStaticString;
|
131
|
+
const safelyEvaluateExpressionForValueOrFunction = expression => {
|
132
|
+
try {
|
133
|
+
const evaluatedValue = evaluateExpressionForValue(expression);
|
134
|
+
if (typeof evaluatedValue === 'function')
|
135
|
+
throw new Error("Function cannot ke kept as static prop");
|
136
|
+
return evaluatedValue;
|
137
|
+
}
|
138
|
+
catch (e) {
|
139
|
+
return safelyCompileExpression(expression);
|
140
|
+
}
|
141
|
+
};
|
107
142
|
// Initialize an empty array to store the final JSX objects
|
108
143
|
const jsxObjects = [];
|
109
144
|
// Initialize an empty stack to keep track of the nested JSX elements
|
110
145
|
const jsxStack = [];
|
111
|
-
String(
|
146
|
+
String(edlString).split(openingOrClosingTagRegex).forEach(token => {
|
112
147
|
// If the token is an empty string, skip it
|
113
148
|
if (token.trim() === '') {
|
114
149
|
return;
|
@@ -116,7 +151,7 @@ function parseEDL(edlString, additionalVariables) {
|
|
116
151
|
// If the token is not an opening or closing JSX tag, treat it as plain text
|
117
152
|
if (token[0] !== '<') {
|
118
153
|
const parentNode = jsxStack[jsxStack.length - 1];
|
119
|
-
const parts = breakTemplateStringToExpressionsAndStaticString(he_1.decode(token)).map(({ type, value }) => type == 'expression' ?
|
154
|
+
const parts = breakTemplateStringToExpressionsAndStaticString(he_1.decode(token)).map(({ type, value }) => type == 'expression' ? safelyEvaluateExpressionForValueOrFunction(expressionsById[value]) : value);
|
120
155
|
if (parentNode) {
|
121
156
|
parentNode.children.push(...parts);
|
122
157
|
}
|
@@ -150,19 +185,23 @@ function parseEDL(edlString, additionalVariables) {
|
|
150
185
|
}
|
151
186
|
const value = attributeMatch[2].slice(1, -1);
|
152
187
|
// Check if the attribute value is dynamic (enclosed in curly braces) either variable or js expression
|
153
|
-
const
|
188
|
+
const isJavascriptExpressionProp = attributeMatch[2].startsWith("{");
|
154
189
|
const isTemplateProp = attributeMatch[2].startsWith("`");
|
155
|
-
if (
|
190
|
+
if (isJavascriptExpressionProp) {
|
191
|
+
const expression = expressionsById[value];
|
156
192
|
try {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
193
|
+
const evaluatedValue = safelyEvaluateExpressionForValueOrFunction(expression);
|
194
|
+
if (typeof evaluatedValue === 'function') {
|
195
|
+
variableProps[attributeName] = safelyCompileExpression(expression);
|
196
|
+
}
|
197
|
+
else {
|
198
|
+
lodash_1.set(staticProps, attributeName, evaluatedValue);
|
199
|
+
}
|
162
200
|
}
|
201
|
+
catch (error) { }
|
163
202
|
}
|
164
203
|
else if (isTemplateProp) {
|
165
|
-
variableProps[attributeName] =
|
204
|
+
variableProps[attributeName] = safelyCompileStringTemplate(value);
|
166
205
|
}
|
167
206
|
else {
|
168
207
|
// If the value is not dynamic, assign it directly to the props object
|
@@ -181,7 +220,7 @@ function parseEDL(edlString, additionalVariables) {
|
|
181
220
|
delete newElement.staticProps[':scriptId'];
|
182
221
|
const code = scriptsById[scriptId].code;
|
183
222
|
const exportVariables = scriptsById[scriptId].variables;
|
184
|
-
newElement.variableProps[':function'] =
|
223
|
+
newElement.variableProps[':function'] = safelyCompileExpression(`()=>{ ${code} \n setRuntimeData({ ${exportVariables.join(', ')} }); }`);
|
185
224
|
}
|
186
225
|
// If there's a parent node, add the new element as a child to the parent node
|
187
226
|
if (jsxStack.length > 0) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/edl/parser.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/edl/parser.ts"],"names":[],"mappings":";;;;;AAAA,mCAA2E;AAC3E,2BAAkD;AAClD,0EAAkD;AAElD,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAEnI,oCAAoC;AACpC,MAAM,eAAe,GAAG,qKAAqK,CAAC;AAE9L,oCAAoC;AACpC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAE9C,4BAA4B;AAC5B,MAAM,cAAc,GAAG,8DAA8D,CAAC;AAEtF,uFAAuF;AACvF,MAAM,wBAAwB,GAAG,+GAA+G,CAAA;AAEhJ,SAAS,gBAAgB;IACvB,OAAO,eAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC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