postcss-merge-rules 9.0.0 → 9.0.2

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.
@@ -0,0 +1,146 @@
1
+ import { isConflictingProp } from './propertyRelations.js';
2
+
3
+ /** @import {Declaration} from 'postcss' */
4
+
5
+ /**
6
+ * @param {Declaration} a
7
+ * @param {Declaration} b
8
+ * @return {boolean}
9
+ */
10
+ function declarationIsEqual(a, b) {
11
+ return (
12
+ a.important === b.important && a.prop === b.prop && a.value === b.value
13
+ );
14
+ }
15
+
16
+ /**
17
+ * @param {Declaration[]} array
18
+ * @param {Declaration} decl
19
+ * @return {number}
20
+ */
21
+ export function indexOfDeclaration(array, decl) {
22
+ return array.findIndex((d) => declarationIsEqual(d, decl));
23
+ }
24
+
25
+ /**
26
+ * @param {Declaration[]} a
27
+ * @param {Declaration[]} b
28
+ * @param {boolean} [not=false]
29
+ * @return {Declaration[]}
30
+ */
31
+ export function intersect(a, b, not) {
32
+ return a.filter((c) => {
33
+ const index = indexOfDeclaration(b, c) !== -1;
34
+ return not ? !index : index;
35
+ });
36
+ }
37
+
38
+ /**
39
+ * @param {Declaration[]} a
40
+ * @param {Declaration[]} b
41
+ * @return {boolean}
42
+ */
43
+ export function sameDeclarationsAndOrder(a, b) {
44
+ if (a.length !== b.length) {
45
+ return false;
46
+ }
47
+ return a.every((d, index) => declarationIsEqual(d, b[index]));
48
+ }
49
+
50
+ /**
51
+ * @param {Declaration} candidate
52
+ * @param {number} candidateIndex
53
+ * @param {Declaration[]} hoistCandidates
54
+ * @param {Declaration[]} earlierRuleDeclarations
55
+ * @return {boolean}
56
+ */
57
+ function hoistingPreservesOverrideOrder(
58
+ candidate,
59
+ candidateIndex,
60
+ hoistCandidates,
61
+ earlierRuleDeclarations
62
+ ) {
63
+ const indexInEarlierRule = indexOfDeclaration(
64
+ earlierRuleDeclarations,
65
+ candidate
66
+ );
67
+ const overridesInEarlierRule = earlierRuleDeclarations
68
+ .slice(indexInEarlierRule + 1)
69
+ .filter((d) => isConflictingProp(d.prop, candidate.prop));
70
+ if (overridesInEarlierRule.length === 0) {
71
+ return true;
72
+ }
73
+ const overridesAmongCandidates = hoistCandidates
74
+ .slice(candidateIndex + 1)
75
+ .filter((d) => isConflictingProp(d.prop, candidate.prop));
76
+ if (overridesInEarlierRule.length !== overridesAmongCandidates.length) {
77
+ return false;
78
+ }
79
+ return overridesInEarlierRule.every((d, index) =>
80
+ declarationIsEqual(d, overridesAmongCandidates[index])
81
+ );
82
+ }
83
+
84
+ /**
85
+ * @param {Declaration} candidate
86
+ * @param {Declaration[]} laterDeclarations
87
+ * @param {Set<number>} claimedIndices
88
+ * @return {boolean}
89
+ */
90
+ function claimMatchInLaterRule(candidate, laterDeclarations, claimedIndices) {
91
+ const matchIndex = laterDeclarations.findIndex(
92
+ (d, index) =>
93
+ !claimedIndices.has(index) && isConflictingProp(d.prop, candidate.prop)
94
+ );
95
+ if (matchIndex === -1) {
96
+ return false;
97
+ }
98
+ if (!declarationIsEqual(laterDeclarations[matchIndex], candidate)) {
99
+ return false;
100
+ }
101
+ if (
102
+ candidate.prop.toLowerCase() !== 'direction' &&
103
+ candidate.prop.toLowerCase() !== 'unicode-bidi' &&
104
+ laterDeclarations.some(
105
+ (declaration) => declaration.prop.toLowerCase() === 'all'
106
+ )
107
+ ) {
108
+ return false;
109
+ }
110
+ claimedIndices.add(matchIndex);
111
+ return true;
112
+ }
113
+
114
+ /**
115
+ * @param {Declaration[]} hoistCandidates
116
+ * @param {Declaration[]} earlierRuleDeclarations
117
+ * @param {Declaration[]} laterRuleDeclarations
118
+ * @return {{intersection: Declaration[], claimedIndices: Set<number>}}
119
+ */
120
+ export function filterRuleIntersections(
121
+ hoistCandidates,
122
+ earlierRuleDeclarations,
123
+ laterRuleDeclarations
124
+ ) {
125
+ let remainingCandidates = hoistCandidates;
126
+ for (;;) {
127
+ const claimedIndices = new Set();
128
+ const survivors = remainingCandidates.filter(
129
+ (candidate, candidateIndex) =>
130
+ hoistingPreservesOverrideOrder(
131
+ candidate,
132
+ candidateIndex,
133
+ remainingCandidates,
134
+ earlierRuleDeclarations
135
+ ) &&
136
+ claimMatchInLaterRule(candidate, laterRuleDeclarations, claimedIndices)
137
+ );
138
+ if (
139
+ survivors.length === remainingCandidates.length ||
140
+ survivors.length === 0
141
+ ) {
142
+ return { intersection: survivors, claimedIndices };
143
+ }
144
+ remainingCandidates = survivors;
145
+ }
146
+ }
@@ -0,0 +1,58 @@
1
+ /** @import {Declaration, Rule} from 'postcss' */
2
+
3
+ /**
4
+ * @typedef {Object} RuleMeta
5
+ * @property {string[]} selectors
6
+ * @property {Declaration[]} declarations
7
+ * @property {boolean} dirty
8
+ */
9
+
10
+ /**
11
+ * @param {import('postcss').ChildNode} node
12
+ * @return {node is Declaration}
13
+ */
14
+ function isDeclaration(node) {
15
+ return node.type === 'decl';
16
+ }
17
+
18
+ /**
19
+ * @param {Rule} rule
20
+ * @param {WeakMap<Rule, RuleMeta>} [ruleMeta]
21
+ * @return {RuleMeta}
22
+ */
23
+ export function getMeta(rule, ruleMeta) {
24
+ if (ruleMeta && rule) {
25
+ let meta = ruleMeta.get(rule);
26
+ if (!meta && rule.nodes) {
27
+ meta = {
28
+ selectors: rule.selectors,
29
+ declarations: rule.nodes.filter(isDeclaration),
30
+ dirty: false,
31
+ };
32
+ ruleMeta.set(rule, meta);
33
+ }
34
+ return meta ?? { selectors: [], declarations: [], dirty: false };
35
+ }
36
+ return {
37
+ selectors: rule?.selectors ?? [],
38
+ declarations: rule?.nodes?.filter(isDeclaration) ?? [],
39
+ dirty: false,
40
+ };
41
+ }
42
+
43
+ /**
44
+ * @param {Rule} rule
45
+ * @param {WeakMap<Rule, RuleMeta>} ruleMeta
46
+ */
47
+ export function flush(rule, ruleMeta) {
48
+ const meta = ruleMeta.get(rule);
49
+ if (meta && meta.dirty) {
50
+ rule.selector = meta.selectors.join(',');
51
+ meta.dirty = false;
52
+ }
53
+ }
54
+
55
+ /** @param {Rule} rule @return {Declaration[]} */
56
+ export function getDecls(rule) {
57
+ return rule.nodes.filter(isDeclaration);
58
+ }
@@ -0,0 +1,170 @@
1
+ import { intersect, indexOfDeclaration } from './declarations.js';
2
+ import { flush, getMeta } from './rule-meta.js';
3
+
4
+ /** @import {Declaration, Rule} from 'postcss' */
5
+
6
+ /**
7
+ * @param {Rule} first
8
+ * @param {Rule} second
9
+ * @return {boolean}
10
+ */
11
+ export function mergeParents(first, second) {
12
+ if (!first.parent || !second.parent || first.parent === second.parent) {
13
+ return false;
14
+ }
15
+ second.remove();
16
+ first.parent.append(second);
17
+ return true;
18
+ }
19
+
20
+ /** @param {Rule} second @return {Rule | null} */
21
+ function getNextRule(second) {
22
+ let nextRule = second.next();
23
+ if (!nextRule) {
24
+ const parentSibling =
25
+ /** @type {import('postcss').Container | undefined} */ (
26
+ /** @type {import('postcss').Container<import('postcss').ChildNode>} */ (
27
+ second.parent
28
+ ).next()
29
+ );
30
+ nextRule = parentSibling && parentSibling.nodes && parentSibling.nodes[0];
31
+ }
32
+ return nextRule?.type === 'rule' ? nextRule : null;
33
+ }
34
+
35
+ /**
36
+ * @param {...Rule} rules
37
+ * @return {number}
38
+ */
39
+ function ruleLength(...rules) {
40
+ return rules.map((r) => (r.nodes.length ? String(r) : '')).join('').length;
41
+ }
42
+
43
+ /**
44
+ * @param {Rule} first
45
+ * @param {Rule} second
46
+ * @param {Declaration[]} intersection
47
+ * @param {string[]} browsers
48
+ * @param {Map<string, boolean>} compatibilityCache
49
+ * @param {WeakSet<Rule>} ruleCache
50
+ * @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
51
+ * @param {(a: Rule, b: Rule, browsers: string[], compatibilityCache: Map<string, boolean>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>) => boolean} canMerge
52
+ * @param {(rule: Rule, oldParent: import('postcss').Container, newParent: import('postcss').Container) => void} [onMove]
53
+ * @return {{first: Rule, second: Rule, intersection: Declaration[], moved: boolean}}
54
+ */
55
+ export function mergeWithNextRule(
56
+ first,
57
+ second,
58
+ intersection,
59
+ browsers,
60
+ compatibilityCache,
61
+ ruleCache,
62
+ ruleMeta,
63
+ canMerge,
64
+ onMove
65
+ ) {
66
+ const nextRule = getNextRule(second);
67
+ if (
68
+ !nextRule ||
69
+ !canMerge(
70
+ second,
71
+ nextRule,
72
+ browsers,
73
+ compatibilityCache,
74
+ ruleCache,
75
+ ruleMeta
76
+ )
77
+ ) {
78
+ return { first, second, intersection, moved: false };
79
+ }
80
+ const nextIntersection = intersect(
81
+ getMeta(second, ruleMeta).declarations,
82
+ getMeta(nextRule, ruleMeta).declarations
83
+ );
84
+ if (nextIntersection.length <= intersection.length) {
85
+ return { first, second, intersection, moved: false };
86
+ }
87
+ const oldParent = nextRule.parent;
88
+ const newParent = second.parent;
89
+ const moved = mergeParents(second, nextRule);
90
+ if (moved && oldParent && newParent) onMove?.(nextRule, oldParent, newParent);
91
+ return {
92
+ first: second,
93
+ second: nextRule,
94
+ intersection: nextIntersection,
95
+ moved,
96
+ };
97
+ }
98
+
99
+ /**
100
+ * @param {Rule} first
101
+ * @param {Rule} second
102
+ * @param {Declaration[]} intersection
103
+ * @param {Set<number>} claimedIndices
104
+ * @param {WeakSet<Rule>} ruleCache
105
+ * @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
106
+ * @return {{rule: Rule, replacements: Rule[]}}
107
+ */
108
+ export function buildMergedRule(
109
+ first,
110
+ second,
111
+ intersection,
112
+ claimedIndices,
113
+ ruleCache,
114
+ ruleMeta
115
+ ) {
116
+ const receivingBlock = second.clone();
117
+ const firstSelectors = getMeta(first, ruleMeta).selectors;
118
+ const secondSelectors = getMeta(second, ruleMeta).selectors;
119
+ receivingBlock.selector = [...firstSelectors, ...secondSelectors].join();
120
+ receivingBlock.nodes = [];
121
+ /** @type {import('postcss').Container<import('postcss').ChildNode>} */ (
122
+ second.parent
123
+ ).insertBefore(second, receivingBlock);
124
+ const firstClone = first.clone({ selectors: firstSelectors });
125
+ const secondClone = second.clone({ selectors: secondSelectors });
126
+ firstClone.walkDecls((decl) => {
127
+ if (indexOfDeclaration(intersection, decl) !== -1) {
128
+ decl.remove();
129
+ receivingBlock.append(decl);
130
+ }
131
+ });
132
+ let laterIndex = 0;
133
+ secondClone.walkDecls((decl) => {
134
+ if (claimedIndices.has(laterIndex++)) {
135
+ decl.remove();
136
+ }
137
+ });
138
+ flush(first, ruleMeta);
139
+ flush(second, ruleMeta);
140
+ const merged = ruleLength(firstClone, receivingBlock, secondClone);
141
+ const original = ruleLength(first, second);
142
+ if (merged < original) {
143
+ first.replaceWith(firstClone);
144
+ second.replaceWith(secondClone);
145
+ for (const rule of [firstClone, receivingBlock, secondClone]) {
146
+ if (rule.nodes.length === 0) rule.remove();
147
+ }
148
+ if (!secondClone.parent) {
149
+ ruleCache?.add(receivingBlock);
150
+ return {
151
+ rule: receivingBlock,
152
+ replacements: [firstClone, receivingBlock].filter((rule) =>
153
+ Boolean(rule.parent)
154
+ ),
155
+ };
156
+ }
157
+ ruleCache?.add(receivingBlock);
158
+ ruleCache?.add(secondClone);
159
+ ruleMeta?.delete(first);
160
+ ruleMeta?.delete(second);
161
+ return {
162
+ rule: secondClone,
163
+ replacements: [firstClone, receivingBlock, secondClone].filter((rule) =>
164
+ Boolean(rule.parent)
165
+ ),
166
+ };
167
+ }
168
+ receivingBlock.remove();
169
+ return { rule: second, replacements: [] };
170
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AASI,OAAQ,KAAA,YAAY,MAAM,cAAc,CAAA;AAExC,OAAQ,KAAA,EAAC,WAAW,EAAO,MAAM,SAAS,CAAA;AAmD3C,YAAkB,QAAQ,GAC1B;;;;IAAqB,SAAS,EAAnB,MAAM,EAAE,CACnB;;;;IAA0B,YAAY,EAA3B,WAAW,EAAE,CACxB;;;;IAAoB,KAAK,EAAd,OA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AS,EAAE,MAAM,CAmCnC;kBAjCQ,aAAa;iBAkCX,IAAI;;AAEf,QAAA,MAAM,aAAa,sBAAgB,CAAC;AAEpC,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Declaration } from 'postcss';
2
+ /**
3
+ * @param {Declaration[]} array
4
+ * @param {Declaration} decl
5
+ * @return {number}
6
+ */
7
+ export declare function indexOfDeclaration(array: Declaration[], decl: Declaration): number;
8
+ /**
9
+ * @param {Declaration[]} a
10
+ * @param {Declaration[]} b
11
+ * @param {boolean} [not=false]
12
+ * @return {Declaration[]}
13
+ */
14
+ export declare function intersect(a: Declaration[], b: Declaration[], not?: boolean): Declaration[];
15
+ /**
16
+ * @param {Declaration[]} a
17
+ * @param {Declaration[]} b
18
+ * @return {boolean}
19
+ */
20
+ export declare function sameDeclarationsAndOrder(a: Declaration[], b: Declaration[]): boolean;
21
+ /**
22
+ * @param {Declaration[]} hoistCandidates
23
+ * @param {Declaration[]} earlierRuleDeclarations
24
+ * @param {Declaration[]} laterRuleDeclarations
25
+ * @return {{intersection: Declaration[], claimedIndices: Set<number>}}
26
+ */
27
+ export declare function filterRuleIntersections(hoistCandidates: Declaration[], earlierRuleDeclarations: Declaration[], laterRuleDeclarations: Declaration[]): {
28
+ intersection: Declaration[];
29
+ claimedIndices: Set<number>;
30
+ };
31
+ //# sourceMappingURL=declarations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/lib/declarations.js"],"names":[],"mappings":"AAEI,OAAQ,KAAA,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AAaxC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAJ7B,WAAW,EAIkB,EAAE,IAAI,EAHnC,WAGmC,GAFlC,MAAM,CAIjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EALhB,WAAW,EAKK,EAAE,CAAC,EAJnB,WAAW,EAIQ,EAAE,GAAG,AAHhC,CACA,EADQ,OAGwB,GAFvB,WAAW,EAAE,CAOxB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAJ/B,WAAW,EAIoB,EAAE,CAAC,EAHlC,WAAW,EAGuB,GAFjC,OAAO,CAOlB;AAkED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EANN,WAAW,EAML,EACf,uBAAuB,EANd,WAAW,EAMG,EACvB,qBAAqB,EANZ,WAAW,EAMC,GALX;IAAC,YAAY,EAAE,WAAW,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAC,CA4BrE"}
@@ -0,0 +1,21 @@
1
+ /** @import {Declaration, Rule} from 'postcss' */
2
+ import type { Declaration, Rule } from 'postcss';
3
+ export type RuleMeta = {
4
+ selectors: string[];
5
+ declarations: Declaration[];
6
+ dirty: boolean;
7
+ };
8
+ /**
9
+ * @param {Rule} rule
10
+ * @param {WeakMap<Rule, RuleMeta>} [ruleMeta]
11
+ * @return {RuleMeta}
12
+ */
13
+ export declare function getMeta(rule: Rule, ruleMeta?: WeakMap<Rule, RuleMeta>): RuleMeta;
14
+ /**
15
+ * @param {Rule} rule
16
+ * @param {WeakMap<Rule, RuleMeta>} ruleMeta
17
+ */
18
+ export declare function flush(rule: Rule, ruleMeta: WeakMap<Rule, RuleMeta>): void;
19
+ /** @param {Rule} rule @return {Declaration[]} */
20
+ export declare function getDecls(rule: Rule): Declaration[];
21
+ //# sourceMappingURL=rule-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-meta.d.ts","sourceRoot":"","sources":["../../src/lib/rule-meta.js"],"names":[],"mappings":"AAAA,iDAAiD;AAA7C,OAAQ,KAAA,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,SAAS,CAAA;AAG3C,YAAkB,QAAQ,GAC1B;IAAqB,SAAS,EAAnB,MAAM,EAAE,CACnB;IAA0B,YAAY,EAA3B,WAAW,EAAE,CACxB;IAAoB,KAAK,EAAd,OAAO,CACpB;CAAA,CAAA;AAUD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAJjB,IAIiB,EAAE,QAAQ,AAHnC,CACA,EADQ,OAAO,CAAC,IAAI,EAAE,QAAQ,CAGK,GAF1B,QAAQ,CAoBnB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAHf,IAGe,EAAE,QAAQ,EAFzB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAEG,QAMnC;AAED,iDAAiD;AACjD,wBAAgB,QAAQ,CAAC,IAAI,EADjB,IACiB,GADG,WAAW,EAAE,CAG5C"}
@@ -0,0 +1,40 @@
1
+ import type { Declaration, Rule } from 'postcss';
2
+ /** @import {Declaration, Rule} from 'postcss' */
3
+ /**
4
+ * @param {Rule} first
5
+ * @param {Rule} second
6
+ * @return {boolean}
7
+ */
8
+ export declare function mergeParents(first: Rule, second: Rule): boolean;
9
+ /**
10
+ * @param {Rule} first
11
+ * @param {Rule} second
12
+ * @param {Declaration[]} intersection
13
+ * @param {string[]} browsers
14
+ * @param {Map<string, boolean>} compatibilityCache
15
+ * @param {WeakSet<Rule>} ruleCache
16
+ * @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
17
+ * @param {(a: Rule, b: Rule, browsers: string[], compatibilityCache: Map<string, boolean>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>) => boolean} canMerge
18
+ * @param {(rule: Rule, oldParent: import('postcss').Container, newParent: import('postcss').Container) => void} [onMove]
19
+ * @return {{first: Rule, second: Rule, intersection: Declaration[], moved: boolean}}
20
+ */
21
+ export declare function mergeWithNextRule(first: Rule, second: Rule, intersection: Declaration[], browsers: string[], compatibilityCache: Map<string, boolean>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>, canMerge: (a: Rule, b: Rule, browsers: string[], compatibilityCache: Map<string, boolean>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>) => boolean, onMove?: (rule: Rule, oldParent: import('postcss').Container, newParent: import('postcss').Container) => void): {
22
+ first: Rule;
23
+ second: Rule;
24
+ intersection: Declaration[];
25
+ moved: boolean;
26
+ };
27
+ /**
28
+ * @param {Rule} first
29
+ * @param {Rule} second
30
+ * @param {Declaration[]} intersection
31
+ * @param {Set<number>} claimedIndices
32
+ * @param {WeakSet<Rule>} ruleCache
33
+ * @param {WeakMap<Rule, import('./rule-meta.js').RuleMeta>} ruleMeta
34
+ * @return {{rule: Rule, replacements: Rule[]}}
35
+ */
36
+ export declare function buildMergedRule(first: Rule, second: Rule, intersection: Declaration[], claimedIndices: Set<number>, ruleCache: WeakSet<Rule>, ruleMeta: WeakMap<Rule, import('./rule-meta.js').RuleMeta>): {
37
+ rule: Rule;
38
+ replacements: Rule[];
39
+ };
40
+ //# sourceMappingURL=rule-rewrite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-rewrite.d.ts","sourceRoot":"","sources":["../../src/lib/rule-rewrite.js"],"names":[],"mappings":"AAGI,OAAQ,KAAA,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,SAAS,CAAA;AAA9C,iDAAiD;AAEjD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAJvB,IAIuB,EAAE,MAAM,EAH/B,IAG+B,GAF9B,OAAO,CASlB;AAyBD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAZI,IAYJ,EACL,MAAM,EAZG,IAYH,EACN,YAAY,EAZH,WAAW,EAYR,EACZ,QAAQ,EAZC,MAAM,EAYP,EACR,kBAAkB,EAZT,GAAG,CAAC,MAAM,EAAE,OAAO,CAYV,EAClB,SAAS,EAZA,OAAO,CAAC,IAAI,CAYZ,EACT,QAAQ,EAZC,OAAO,CAA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