@bigbinary/neetoui 8.3.20 → 8.3.21
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/Switch.js +3 -1
- package/dist/Switch.js.map +1 -1
- package/dist/cjs/Switch.js +3 -1
- package/dist/cjs/Switch.js.map +1 -1
- package/package.json +1 -1
package/dist/Switch.js
CHANGED
|
@@ -53,10 +53,12 @@ var Switch = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
53
|
var renderLabel = label || children;
|
|
54
54
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
55
55
|
ref: ref,
|
|
56
|
-
className: classnames(["neeto-ui-switch__wrapper", className])
|
|
56
|
+
className: classnames(["neeto-ui-switch__wrapper", className]),
|
|
57
|
+
"data-cy": "nui-switch-wrapper"
|
|
57
58
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
58
59
|
className: "neeto-ui-switch__container"
|
|
59
60
|
}, /*#__PURE__*/React__default.createElement("label", {
|
|
61
|
+
"data-cy": "nui-switch-item",
|
|
60
62
|
tabIndex: 0,
|
|
61
63
|
className: classnames("neeto-ui-switch__item", {
|
|
62
64
|
"neeto-ui-switch__item--checked": !!checked,
|
package/dist/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../src/components/Switch.jsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { Check, Close } from \"neetoicons\";\nimport PropTypes from \"prop-types\";\n\nimport { useId } from \"hooks\";\nimport { hyphenize, noop } from \"utils\";\n\nimport Label from \"./Label\";\n\nconst Switch = forwardRef(\n (\n {\n label = \"\",\n required = false,\n className = \"\",\n error = \"\",\n onChange = noop,\n labelProps,\n children,\n ...otherProps\n },\n ref\n ) => {\n const id = useId(otherProps.id);\n const errorId = `error_${id}`;\n const { checked, disabled } = otherProps;\n const renderLabel = label || children;\n\n return (\n <div\n {...{ ref }}\n className={classnames([\"neeto-ui-switch__wrapper\", className])}\n >\n <div className=\"neeto-ui-switch__container\">\n <label\n tabIndex={0}\n className={classnames(\"neeto-ui-switch__item\", {\n \"neeto-ui-switch__item--checked\": !!checked,\n \"neeto-ui-switch__item--disabled\": disabled,\n })}\n >\n <input {...{ id, onChange }} type=\"checkbox\" {...otherProps} />\n <span\n aria-hidden=\"true\"\n data-cy={`${hyphenize(renderLabel)}-switch`}\n className={classnames(\"neeto-ui-switch\", {\n \"neeto-ui-switch--checked\": !!checked,\n })}\n >\n {checked ? (\n <Check\n data-cy=\"check-icon\"\n data-testid=\"check-icon\"\n size=\"12\"\n strokeWidth={4}\n />\n ) : (\n <Close\n data-cy=\"close-icon\"\n data-testid=\"close-icon\"\n size=\"12\"\n strokeWidth={3}\n />\n )}\n </span>\n </label>\n {renderLabel && (\n <Label\n {...{ required }}\n data-cy={`${hyphenize(renderLabel)}-switch-label`}\n htmlFor={id}\n {...labelProps}\n >\n {renderLabel}\n </Label>\n )}\n </div>\n {!!error && (\n <p\n className=\"neeto-ui-input__error\"\n data-cy={`${hyphenize(renderLabel)}-switch-error`}\n id={errorId}\n >\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n\nSwitch.displayName = \"Switch\";\n\nSwitch.propTypes = {\n /**\n * Text to be displayed above the component\n */\n label: PropTypes.string,\n /**\n * To specify the label props to be passed to the Label component.\n */\n labelProps: PropTypes.object,\n /**\n * To specify whether to show the required asterisk.\n */\n required: PropTypes.bool,\n /**\n * Provide external classnames to spinner component.\n */\n className: PropTypes.string,\n /**\n * To specify the error message to be shown.\n */\n error: PropTypes.string,\n /**\n * Checks whether the Switch is checked or not\n */\n checked: PropTypes.bool,\n /**\n * To disable the component\n */\n disabled: PropTypes.bool,\n /**\n * To specify the children label to be rendered inside the Checkbox.\n */\n children: PropTypes.string,\n};\n\nexport default Switch;\n"],"names":["Switch","forwardRef","_ref","ref","_ref$label","label","_ref$required","required","_ref$className","className","_ref$error","error","_ref$onChange","onChange","noop","labelProps","children","otherProps","_objectWithoutProperties","_excluded","id","useId","errorId","concat","checked","disabled","renderLabel","React","createElement","classnames","tabIndex","_extends","type","hyphenize","Check","size","strokeWidth","Close","Label","htmlFor","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWMA,IAAAA,MAAM,gBAAGC,UAAU,CACvB,UAAAC,IAAA,EAWEC,GAAG,EACA;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CAVDG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAJ,IAAA,CACVK,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA;IAAAE,cAAA,GAAAN,IAAA,CAChBO,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,cAAA;IAAAE,UAAA,GAAAR,IAAA,CACdS,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAV,IAAA,CACVW,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAGE,KAAAA,CAAAA,GAAAA,IAAI,GAAAF,aAAA;IACfG,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;AACLC,IAAAA,UAAU,GAAAC,wBAAA,CAAAhB,IAAA,EAAAiB,SAAA,CAAA,CAAA;AAIf,EAAA,IAAMC,EAAE,GAAGC,KAAK,CAACJ,UAAU,CAACG,EAAE,CAAC,CAAA;AAC/B,EAAA,IAAME,OAAO,GAAA,QAAA,CAAAC,MAAA,CAAYH,EAAE,CAAE,CAAA;AAC7B,EAAA,IAAQI,OAAO,GAAeP,UAAU,CAAhCO,OAAO;IAAEC,QAAQ,GAAKR,UAAU,CAAvBQ,QAAQ,CAAA;AACzB,EAAA,IAAMC,WAAW,GAAGrB,KAAK,IAAIW,QAAQ,CAAA;EAErC,oBACEW,cAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACQzB,IAAAA,GAAG,EAAHA,GAAG;
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../src/components/Switch.jsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { Check, Close } from \"neetoicons\";\nimport PropTypes from \"prop-types\";\n\nimport { useId } from \"hooks\";\nimport { hyphenize, noop } from \"utils\";\n\nimport Label from \"./Label\";\n\nconst Switch = forwardRef(\n (\n {\n label = \"\",\n required = false,\n className = \"\",\n error = \"\",\n onChange = noop,\n labelProps,\n children,\n ...otherProps\n },\n ref\n ) => {\n const id = useId(otherProps.id);\n const errorId = `error_${id}`;\n const { checked, disabled } = otherProps;\n const renderLabel = label || children;\n\n return (\n <div\n {...{ ref }}\n className={classnames([\"neeto-ui-switch__wrapper\", className])}\n data-cy=\"nui-switch-wrapper\"\n >\n <div className=\"neeto-ui-switch__container\">\n <label\n data-cy=\"nui-switch-item\"\n tabIndex={0}\n className={classnames(\"neeto-ui-switch__item\", {\n \"neeto-ui-switch__item--checked\": !!checked,\n \"neeto-ui-switch__item--disabled\": disabled,\n })}\n >\n <input {...{ id, onChange }} type=\"checkbox\" {...otherProps} />\n <span\n aria-hidden=\"true\"\n data-cy={`${hyphenize(renderLabel)}-switch`}\n className={classnames(\"neeto-ui-switch\", {\n \"neeto-ui-switch--checked\": !!checked,\n })}\n >\n {checked ? (\n <Check\n data-cy=\"check-icon\"\n data-testid=\"check-icon\"\n size=\"12\"\n strokeWidth={4}\n />\n ) : (\n <Close\n data-cy=\"close-icon\"\n data-testid=\"close-icon\"\n size=\"12\"\n strokeWidth={3}\n />\n )}\n </span>\n </label>\n {renderLabel && (\n <Label\n {...{ required }}\n data-cy={`${hyphenize(renderLabel)}-switch-label`}\n htmlFor={id}\n {...labelProps}\n >\n {renderLabel}\n </Label>\n )}\n </div>\n {!!error && (\n <p\n className=\"neeto-ui-input__error\"\n data-cy={`${hyphenize(renderLabel)}-switch-error`}\n id={errorId}\n >\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n\nSwitch.displayName = \"Switch\";\n\nSwitch.propTypes = {\n /**\n * Text to be displayed above the component\n */\n label: PropTypes.string,\n /**\n * To specify the label props to be passed to the Label component.\n */\n labelProps: PropTypes.object,\n /**\n * To specify whether to show the required asterisk.\n */\n required: PropTypes.bool,\n /**\n * Provide external classnames to spinner component.\n */\n className: PropTypes.string,\n /**\n * To specify the error message to be shown.\n */\n error: PropTypes.string,\n /**\n * Checks whether the Switch is checked or not\n */\n checked: PropTypes.bool,\n /**\n * To disable the component\n */\n disabled: PropTypes.bool,\n /**\n * To specify the children label to be rendered inside the Checkbox.\n */\n children: PropTypes.string,\n};\n\nexport default Switch;\n"],"names":["Switch","forwardRef","_ref","ref","_ref$label","label","_ref$required","required","_ref$className","className","_ref$error","error","_ref$onChange","onChange","noop","labelProps","children","otherProps","_objectWithoutProperties","_excluded","id","useId","errorId","concat","checked","disabled","renderLabel","React","createElement","classnames","tabIndex","_extends","type","hyphenize","Check","size","strokeWidth","Close","Label","htmlFor","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWMA,IAAAA,MAAM,gBAAGC,UAAU,CACvB,UAAAC,IAAA,EAWEC,GAAG,EACA;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CAVDG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAJ,IAAA,CACVK,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA;IAAAE,cAAA,GAAAN,IAAA,CAChBO,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAA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AK,iBACNgB,cAAA,CAAAC,aAAA,CAAA,GAAA,EAAA;AACEnB,IAAAA,SAAS,EAAC,uBAAuB;AACjC,IAAA,SAAA,EAAA,EAAA,CAAAc,MAAA,CAAYU,SAAS,CAACP,WAAW,CAAC,EAAgB,eAAA,CAAA;AAClDN,IAAAA,EAAE,EAAEE,OAAAA;GAEHX,EAAAA,KAAK,CAET,CACG,CAAA;AAEV,CAAC,EACF;AAEDX,MAAM,CAACwC,WAAW,GAAG,QAAQ;;;;"}
|
package/dist/cjs/Switch.js
CHANGED
|
@@ -55,10 +55,12 @@ var Switch = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
55
55
|
var renderLabel = label || children;
|
|
56
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
57
|
ref: ref,
|
|
58
|
-
className: classnames(["neeto-ui-switch__wrapper", className])
|
|
58
|
+
className: classnames(["neeto-ui-switch__wrapper", className]),
|
|
59
|
+
"data-cy": "nui-switch-wrapper"
|
|
59
60
|
}, /*#__PURE__*/React.createElement("div", {
|
|
60
61
|
className: "neeto-ui-switch__container"
|
|
61
62
|
}, /*#__PURE__*/React.createElement("label", {
|
|
63
|
+
"data-cy": "nui-switch-item",
|
|
62
64
|
tabIndex: 0,
|
|
63
65
|
className: classnames("neeto-ui-switch__item", {
|
|
64
66
|
"neeto-ui-switch__item--checked": !!checked,
|
package/dist/cjs/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../src/components/Switch.jsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { Check, Close } from \"neetoicons\";\nimport PropTypes from \"prop-types\";\n\nimport { useId } from \"hooks\";\nimport { hyphenize, noop } from \"utils\";\n\nimport Label from \"./Label\";\n\nconst Switch = forwardRef(\n (\n {\n label = \"\",\n required = false,\n className = \"\",\n error = \"\",\n onChange = noop,\n labelProps,\n children,\n ...otherProps\n },\n ref\n ) => {\n const id = useId(otherProps.id);\n const errorId = `error_${id}`;\n const { checked, disabled } = otherProps;\n const renderLabel = label || children;\n\n return (\n <div\n {...{ ref }}\n className={classnames([\"neeto-ui-switch__wrapper\", className])}\n >\n <div className=\"neeto-ui-switch__container\">\n <label\n tabIndex={0}\n className={classnames(\"neeto-ui-switch__item\", {\n \"neeto-ui-switch__item--checked\": !!checked,\n \"neeto-ui-switch__item--disabled\": disabled,\n })}\n >\n <input {...{ id, onChange }} type=\"checkbox\" {...otherProps} />\n <span\n aria-hidden=\"true\"\n data-cy={`${hyphenize(renderLabel)}-switch`}\n className={classnames(\"neeto-ui-switch\", {\n \"neeto-ui-switch--checked\": !!checked,\n })}\n >\n {checked ? (\n <Check\n data-cy=\"check-icon\"\n data-testid=\"check-icon\"\n size=\"12\"\n strokeWidth={4}\n />\n ) : (\n <Close\n data-cy=\"close-icon\"\n data-testid=\"close-icon\"\n size=\"12\"\n strokeWidth={3}\n />\n )}\n </span>\n </label>\n {renderLabel && (\n <Label\n {...{ required }}\n data-cy={`${hyphenize(renderLabel)}-switch-label`}\n htmlFor={id}\n {...labelProps}\n >\n {renderLabel}\n </Label>\n )}\n </div>\n {!!error && (\n <p\n className=\"neeto-ui-input__error\"\n data-cy={`${hyphenize(renderLabel)}-switch-error`}\n id={errorId}\n >\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n\nSwitch.displayName = \"Switch\";\n\nSwitch.propTypes = {\n /**\n * Text to be displayed above the component\n */\n label: PropTypes.string,\n /**\n * To specify the label props to be passed to the Label component.\n */\n labelProps: PropTypes.object,\n /**\n * To specify whether to show the required asterisk.\n */\n required: PropTypes.bool,\n /**\n * Provide external classnames to spinner component.\n */\n className: PropTypes.string,\n /**\n * To specify the error message to be shown.\n */\n error: PropTypes.string,\n /**\n * Checks whether the Switch is checked or not\n */\n checked: PropTypes.bool,\n /**\n * To disable the component\n */\n disabled: PropTypes.bool,\n /**\n * To specify the children label to be rendered inside the Checkbox.\n */\n children: PropTypes.string,\n};\n\nexport default Switch;\n"],"names":["Switch","forwardRef","_ref","ref","_ref$label","label","_ref$required","required","_ref$className","className","_ref$error","error","_ref$onChange","onChange","noop","labelProps","children","otherProps","_objectWithoutProperties","_excluded","id","useId","errorId","concat","checked","disabled","renderLabel","React","createElement","classnames","tabIndex","_extends","type","hyphenize","Check","size","strokeWidth","Close","Label","htmlFor","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWMA,IAAAA,MAAM,gBAAGC,gBAAU,CACvB,UAAAC,IAAA,EAWEC,GAAG,EACA;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CAVDG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAJ,IAAA,CACVK,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA;IAAAE,cAAA,GAAAN,IAAA,CAChBO,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,cAAA;IAAAE,UAAA,GAAAR,IAAA,CACdS,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAV,IAAA,CACVW,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAGE,KAAAA,CAAAA,GAAAA,UAAI,GAAAF,aAAA;IACfG,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;AACLC,IAAAA,UAAU,GAAAC,wBAAA,CAAAhB,IAAA,EAAAiB,SAAA,CAAA,CAAA;AAIf,EAAA,IAAMC,EAAE,GAAGC,WAAK,CAACJ,UAAU,CAACG,EAAE,CAAC,CAAA;AAC/B,EAAA,IAAME,OAAO,GAAA,QAAA,CAAAC,MAAA,CAAYH,EAAE,CAAE,CAAA;AAC7B,EAAA,IAAQI,OAAO,GAAeP,UAAU,CAAhCO,OAAO;IAAEC,QAAQ,GAAKR,UAAU,CAAvBQ,QAAQ,CAAA;AACzB,EAAA,IAAMC,WAAW,GAAGrB,KAAK,IAAIW,QAAQ,CAAA;EAErC,oBACEW,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACQzB,IAAAA,GAAG,EAAHA,GAAG;
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../src/components/Switch.jsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { Check, Close } from \"neetoicons\";\nimport PropTypes from \"prop-types\";\n\nimport { useId } from \"hooks\";\nimport { hyphenize, noop } from \"utils\";\n\nimport Label from \"./Label\";\n\nconst Switch = forwardRef(\n (\n {\n label = \"\",\n required = false,\n className = \"\",\n error = \"\",\n onChange = noop,\n labelProps,\n children,\n ...otherProps\n },\n ref\n ) => {\n const id = useId(otherProps.id);\n const errorId = `error_${id}`;\n const { checked, disabled } = otherProps;\n const renderLabel = label || children;\n\n return (\n <div\n {...{ ref }}\n className={classnames([\"neeto-ui-switch__wrapper\", className])}\n data-cy=\"nui-switch-wrapper\"\n >\n <div className=\"neeto-ui-switch__container\">\n <label\n data-cy=\"nui-switch-item\"\n tabIndex={0}\n className={classnames(\"neeto-ui-switch__item\", {\n \"neeto-ui-switch__item--checked\": !!checked,\n \"neeto-ui-switch__item--disabled\": disabled,\n })}\n >\n <input {...{ id, onChange }} type=\"checkbox\" {...otherProps} />\n <span\n aria-hidden=\"true\"\n data-cy={`${hyphenize(renderLabel)}-switch`}\n className={classnames(\"neeto-ui-switch\", {\n \"neeto-ui-switch--checked\": !!checked,\n })}\n >\n {checked ? (\n <Check\n data-cy=\"check-icon\"\n data-testid=\"check-icon\"\n size=\"12\"\n strokeWidth={4}\n />\n ) : (\n <Close\n data-cy=\"close-icon\"\n data-testid=\"close-icon\"\n size=\"12\"\n strokeWidth={3}\n />\n )}\n </span>\n </label>\n {renderLabel && (\n <Label\n {...{ required }}\n data-cy={`${hyphenize(renderLabel)}-switch-label`}\n htmlFor={id}\n {...labelProps}\n >\n {renderLabel}\n </Label>\n )}\n </div>\n {!!error && (\n <p\n className=\"neeto-ui-input__error\"\n data-cy={`${hyphenize(renderLabel)}-switch-error`}\n id={errorId}\n >\n {error}\n </p>\n )}\n </div>\n );\n }\n);\n\nSwitch.displayName = \"Switch\";\n\nSwitch.propTypes = {\n /**\n * Text to be displayed above the component\n */\n label: PropTypes.string,\n /**\n * To specify the label props to be passed to the Label component.\n */\n labelProps: PropTypes.object,\n /**\n * To specify whether to show the required asterisk.\n */\n required: PropTypes.bool,\n /**\n * Provide external classnames to spinner component.\n */\n className: PropTypes.string,\n /**\n * To specify the error message to be shown.\n */\n error: PropTypes.string,\n /**\n * Checks whether the Switch is checked or not\n */\n checked: PropTypes.bool,\n /**\n * To disable the component\n */\n disabled: PropTypes.bool,\n /**\n * To specify the children label to be rendered inside the Checkbox.\n */\n children: PropTypes.string,\n};\n\nexport default Switch;\n"],"names":["Switch","forwardRef","_ref","ref","_ref$label","label","_ref$required","required","_ref$className","className","_ref$error","error","_ref$onChange","onChange","noop","labelProps","children","otherProps","_objectWithoutProperties","_excluded","id","useId","errorId","concat","checked","disabled","renderLabel","React","createElement","classnames","tabIndex","_extends","type","hyphenize","Check","size","strokeWidth","Close","Label","htmlFor","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWMA,IAAAA,MAAM,gBAAGC,gBAAU,CACvB,UAAAC,IAAA,EAWEC,GAAG,EACA;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CAVDG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,UAAA;IAAAE,aAAA,GAAAJ,IAAA,CACVK,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KA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