@transferwise/components 46.67.2 → 46.69.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/build/button/Button.js +22 -6
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +22 -6
- package/build/button/Button.mjs.map +1 -1
- package/build/main.css +212 -210
- package/build/styles/button/Button.css +3 -0
- package/build/styles/main.css +212 -210
- package/build/styles/uploadInput/UploadInput.css +13 -81
- package/build/styles/uploadInput/uploadButton/UploadButton.css +77 -31
- package/build/styles/uploadInput/uploadItem/UploadItem.css +130 -109
- package/build/typeahead/Typeahead.js +22 -8
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +22 -9
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.js +5 -2
- package/build/typeahead/typeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs +5 -2
- package/build/typeahead/typeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/typeahead/typeaheadOption/TypeaheadOption.js +9 -6
- package/build/typeahead/typeaheadOption/TypeaheadOption.js.map +1 -1
- package/build/typeahead/typeaheadOption/TypeaheadOption.mjs +9 -6
- package/build/typeahead/typeaheadOption/TypeaheadOption.mjs.map +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +1 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +2 -0
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts +2 -1
- package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +5 -0
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/build/uploadInput/UploadInput.js +30 -20
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +30 -20
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.js +25 -32
- package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +25 -32
- package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
- package/build/uploadInput/uploadItem/UploadItem.js +32 -38
- package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
- package/build/uploadInput/uploadItem/UploadItem.mjs +33 -39
- package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
- package/build/uploadInput/uploadItem/UploadItemLink.js +2 -1
- package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -1
- package/build/uploadInput/uploadItem/UploadItemLink.mjs +2 -1
- package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -1
- package/package.json +4 -4
- package/src/button/Button.css +3 -0
- package/src/button/Button.less +6 -0
- package/src/button/Button.spec.js +81 -45
- package/src/button/Button.story.tsx +54 -20
- package/src/button/Button.tsx +32 -7
- package/src/button/__snapshots__/Button.spec.js.snap +56 -12
- package/src/flowNavigation/FlowNavigation.story.js +1 -1
- package/src/main.css +212 -210
- package/src/typeahead/Typeahead.spec.js +8 -0
- package/src/typeahead/Typeahead.tsx +29 -13
- package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +9 -0
- package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +8 -0
- package/src/typeahead/typeaheadOption/TypeaheadOption.tsx +9 -6
- package/src/uploadInput/UploadInput.css +13 -81
- package/src/uploadInput/UploadInput.less +18 -80
- package/src/uploadInput/UploadInput.tests.story.tsx +5 -5
- package/src/uploadInput/UploadInput.tsx +43 -32
- package/src/uploadInput/uploadButton/UploadButton.css +77 -31
- package/src/uploadInput/uploadButton/UploadButton.less +77 -35
- package/src/uploadInput/uploadButton/UploadButton.tsx +37 -26
- package/src/uploadInput/uploadItem/UploadItem.css +130 -109
- package/src/uploadInput/uploadItem/UploadItem.less +130 -118
- package/src/uploadInput/uploadItem/UploadItem.tsx +26 -28
- package/src/uploadInput/uploadItem/UploadItemLink.tsx +3 -3
package/build/button/Button.js
CHANGED
|
@@ -21,6 +21,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
21
21
|
priority = control.Priority.PRIMARY,
|
|
22
22
|
size: size$1 = size.Size.MEDIUM,
|
|
23
23
|
type = control.ControlType.ACCENT,
|
|
24
|
+
onClick,
|
|
24
25
|
...rest
|
|
25
26
|
}, reference) => {
|
|
26
27
|
const intl = reactIntl.useIntl();
|
|
@@ -35,9 +36,8 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
35
36
|
const newPriority = legacyUtils.establishNewPriority(priority, type);
|
|
36
37
|
const classes = clsx.clsx(`btn btn-${size$1}`, `np-btn np-btn-${size$1}`, {
|
|
37
38
|
'btn-loading': loading,
|
|
38
|
-
'btn-block np-btn-block': block
|
|
39
|
-
|
|
40
|
-
disabled: disabled || loading
|
|
39
|
+
'btn-block np-btn-block': block,
|
|
40
|
+
disabled
|
|
41
41
|
},
|
|
42
42
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -57,23 +57,39 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
57
57
|
} = rest;
|
|
58
58
|
props = {
|
|
59
59
|
...restProps,
|
|
60
|
-
disabled
|
|
60
|
+
disabled,
|
|
61
|
+
'aria-disabled': loading,
|
|
61
62
|
type: htmlType
|
|
62
63
|
};
|
|
63
64
|
} else {
|
|
64
65
|
props = {
|
|
65
|
-
...rest
|
|
66
|
+
...rest,
|
|
67
|
+
'aria-disabled': loading
|
|
66
68
|
};
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Ensures that the button cannot be activated in loading or disabled mode,
|
|
72
|
+
* when `aria-disabled` might be used over the `disabled` HTML attribute
|
|
73
|
+
*/
|
|
74
|
+
const handleClick = handler => event => {
|
|
75
|
+
if (disabled || loading) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
} else if (typeof handler === 'function') {
|
|
78
|
+
handler(event);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
68
81
|
return /*#__PURE__*/jsxRuntime.jsxs(Element, {
|
|
69
82
|
ref: reference,
|
|
70
83
|
className: classes,
|
|
84
|
+
onClick: handleClick(onClick),
|
|
71
85
|
...props,
|
|
72
86
|
"aria-live": loading ? 'polite' : 'off',
|
|
87
|
+
"aria-busy": loading,
|
|
73
88
|
"aria-label": loading ? intl.formatMessage(Button_messages.loadingAriaLabel) : rest['aria-label'],
|
|
74
89
|
children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
75
90
|
size: processIndicatorSize(),
|
|
76
|
-
className: "btn-loader"
|
|
91
|
+
className: "btn-loader",
|
|
92
|
+
"data-testid": "ButtonProgressIndicator"
|
|
77
93
|
})]
|
|
78
94
|
});
|
|
79
95
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n React.ComponentPropsWithRef<'a'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\ntype ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n logDeprecationNotices({ size, type });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const newType = establishNewType(type);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ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const Button = /*#__PURE__*/forwardRef(({
|
|
|
19
19
|
priority = Priority.PRIMARY,
|
|
20
20
|
size = Size.MEDIUM,
|
|
21
21
|
type = ControlType.ACCENT,
|
|
22
|
+
onClick,
|
|
22
23
|
...rest
|
|
23
24
|
}, reference) => {
|
|
24
25
|
const intl = useIntl();
|
|
@@ -33,9 +34,8 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
33
34
|
const newPriority = establishNewPriority(priority, type);
|
|
34
35
|
const classes = clsx(`btn btn-${size}`, `np-btn np-btn-${size}`, {
|
|
35
36
|
'btn-loading': loading,
|
|
36
|
-
'btn-block np-btn-block': block
|
|
37
|
-
|
|
38
|
-
disabled: disabled || loading
|
|
37
|
+
'btn-block np-btn-block': block,
|
|
38
|
+
disabled
|
|
39
39
|
},
|
|
40
40
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -55,23 +55,39 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
55
55
|
} = rest;
|
|
56
56
|
props = {
|
|
57
57
|
...restProps,
|
|
58
|
-
disabled
|
|
58
|
+
disabled,
|
|
59
|
+
'aria-disabled': loading,
|
|
59
60
|
type: htmlType
|
|
60
61
|
};
|
|
61
62
|
} else {
|
|
62
63
|
props = {
|
|
63
|
-
...rest
|
|
64
|
+
...rest,
|
|
65
|
+
'aria-disabled': loading
|
|
64
66
|
};
|
|
65
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Ensures that the button cannot be activated in loading or disabled mode,
|
|
70
|
+
* when `aria-disabled` might be used over the `disabled` HTML attribute
|
|
71
|
+
*/
|
|
72
|
+
const handleClick = handler => event => {
|
|
73
|
+
if (disabled || loading) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
} else if (typeof handler === 'function') {
|
|
76
|
+
handler(event);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
66
79
|
return /*#__PURE__*/jsxs(Element, {
|
|
67
80
|
ref: reference,
|
|
68
81
|
className: classes,
|
|
82
|
+
onClick: handleClick(onClick),
|
|
69
83
|
...props,
|
|
70
84
|
"aria-live": loading ? 'polite' : 'off',
|
|
85
|
+
"aria-busy": loading,
|
|
71
86
|
"aria-label": loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label'],
|
|
72
87
|
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator, {
|
|
73
88
|
size: processIndicatorSize(),
|
|
74
|
-
className: "btn-loader"
|
|
89
|
+
className: "btn-loader",
|
|
90
|
+
"data-testid": "ButtonProgressIndicator"
|
|
75
91
|
})]
|
|
76
92
|
});
|
|
77
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport {
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from './Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n React.ComponentPropsWithRef<'a'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\ntype ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n logDeprecationNotices({ size, type });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const newType = establishNewType(type);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,WAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACG,CAAA,EACRC,SAAS,KACP;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE,CAAA;AAEtB;AACAC,EAAAA,qBAAqB,CAAC;IAAEX,IAAI;AAAEG,IAAAA,IAAAA;AAAI,GA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