@salt-ds/styles 0.1.2 → 0.2.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/dist-cjs/index.js +3 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/style-injection-provider/index.js +13 -0
- package/dist-cjs/style-injection-provider/index.js.map +1 -0
- package/dist-cjs/use-style-injection/useStyleInjection.js +3 -1
- package/dist-cjs/use-style-injection/useStyleInjection.js.map +1 -1
- package/dist-es/index.js +1 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/style-injection-provider/index.js +8 -0
- package/dist-es/style-injection-provider/index.js.map +1 -0
- package/dist-es/use-style-injection/useStyleInjection.js +3 -1
- package/dist-es/use-style-injection/useStyleInjection.js.map +1 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/style-injection-provider/index.d.ts +2 -0
- package/package.json +1 -1
package/dist-cjs/index.js
CHANGED
|
@@ -4,10 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var useStyleInjection = require('./use-style-injection/useStyleInjection.js');
|
|
6
6
|
var InsertionPointProvider = require('./use-style-injection/InsertionPointProvider.js');
|
|
7
|
+
var index = require('./style-injection-provider/index.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
exports.useComponentCssInjection = useStyleInjection.useComponentCssInjection;
|
|
11
12
|
exports.InsertionPointProvider = InsertionPointProvider.InsertionPointProvider;
|
|
12
13
|
exports.useInsertionPoint = InsertionPointProvider.useInsertionPoint;
|
|
14
|
+
exports.StyleInjectionProvider = index.StyleInjectionProvider;
|
|
15
|
+
exports.useStyleInjection = index.useStyleInjection;
|
|
13
16
|
//# sourceMappingURL=index.js.map
|
package/dist-cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const StyleInjectionContext = React.createContext(true);
|
|
8
|
+
const useStyleInjection = () => React.useContext(StyleInjectionContext);
|
|
9
|
+
const StyleInjectionProvider = StyleInjectionContext.Provider;
|
|
10
|
+
|
|
11
|
+
exports.StyleInjectionProvider = StyleInjectionProvider;
|
|
12
|
+
exports.useStyleInjection = useStyleInjection;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/style-injection-provider/index.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nconst StyleInjectionContext = createContext(true);\n\nexport const useStyleInjection = () => useContext(StyleInjectionContext);\nexport const StyleInjectionProvider = StyleInjectionContext.Provider;\n"],"names":["createContext","useContext"],"mappings":";;;;;;AAEA,MAAM,qBAAA,GAAwBA,oBAAc,IAAI,CAAA,CAAA;AAEnC,MAAA,iBAAA,GAAoB,MAAMC,gBAAA,CAAW,qBAAqB,EAAA;AAChE,MAAM,yBAAyB,qBAAsB,CAAA;;;;;"}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var InsertionPointProvider = require('./InsertionPointProvider.js');
|
|
7
|
+
var index = require('../style-injection-provider/index.js');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -33,10 +34,11 @@ function useComponentCssInjection({
|
|
|
33
34
|
css,
|
|
34
35
|
window: targetWindow
|
|
35
36
|
}) {
|
|
37
|
+
const styleInjectionEnabled = index.useStyleInjection();
|
|
36
38
|
const insertionPoint = InsertionPointProvider.useInsertionPoint();
|
|
37
39
|
maybeUseInsertionEffect(() => {
|
|
38
40
|
var _a2, _b;
|
|
39
|
-
if (!targetWindow) {
|
|
41
|
+
if (!targetWindow || !styleInjectionEnabled) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
const sheetsMap = (_a2 = windowSheetsMap.get(targetWindow)) != null ? _a2 : /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleInjection.js","sources":["../src/use-style-injection/useStyleInjection.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useInsertionPoint } from \"./InsertionPointProvider\";\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985 */\nconst maybeUseInsertionEffect: typeof React.useLayoutEffect =\n (React as any)[\"useInsertionEffect\".toString()] ?? React.useLayoutEffect;\n/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n\nexport interface UseComponentCssInjection {\n testId?: string;\n css: string;\n window?: Window | null;\n}\n\ntype StyleElementMap = Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n>;\n\n// windowSheetsMap maps window objects to StyleElementMaps\n// A StyleElementMap maps css strings to style element tags\nconst windowSheetsMap = new WeakMap<Window, StyleElementMap>();\n\nexport function useComponentCssInjection({\n testId,\n css,\n window: targetWindow,\n}: UseComponentCssInjection): void {\n const insertionPoint = useInsertionPoint();\n\n maybeUseInsertionEffect(() => {\n if (!targetWindow) {\n return;\n }\n\n const sheetsMap =\n windowSheetsMap.get(targetWindow) ??\n new Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n >();\n const styleMap = sheetsMap.get(css) ?? { styleElement: null, count: 0 };\n\n if (styleMap.styleElement == null) {\n styleMap.styleElement = targetWindow.document.createElement(\"style\");\n styleMap.styleElement.setAttribute(\"type\", \"text/css\");\n styleMap.styleElement.setAttribute(\"data-salt-style\", testId || \"\");\n styleMap.styleElement.textContent = css;\n\n styleMap.count = 1;\n\n targetWindow.document.head.insertBefore(\n styleMap.styleElement,\n insertionPoint || targetWindow.document.head.firstChild\n );\n } else {\n styleMap.styleElement.textContent = css;\n styleMap.count++;\n }\n sheetsMap.set(css, styleMap);\n windowSheetsMap.set(targetWindow, sheetsMap);\n\n return () => {\n const sheetsMap = windowSheetsMap.get(targetWindow);\n const styleMap = sheetsMap?.get(css);\n if (styleMap?.styleElement) {\n styleMap.count--;\n if (styleMap.count < 1) {\n targetWindow.document.head.removeChild(styleMap.styleElement);\n styleMap.styleElement = null;\n sheetsMap?.delete(css);\n }\n }\n };\n }, [testId, css, targetWindow]);\n}\n"],"names":["React","useInsertionPoint","_a","sheetsMap","styleMap"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStyleInjection.js","sources":["../src/use-style-injection/useStyleInjection.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useInsertionPoint } from \"./InsertionPointProvider\";\nimport { useStyleInjection } from \"../style-injection-provider\";\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985 */\nconst maybeUseInsertionEffect: typeof React.useLayoutEffect =\n (React as any)[\"useInsertionEffect\".toString()] ?? React.useLayoutEffect;\n/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n\nexport interface UseComponentCssInjection {\n testId?: string;\n css: string;\n window?: Window | null;\n}\n\ntype StyleElementMap = Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n>;\n\n// windowSheetsMap maps window objects to StyleElementMaps\n// A StyleElementMap maps css strings to style element tags\nconst windowSheetsMap = new WeakMap<Window, StyleElementMap>();\n\nexport function useComponentCssInjection({\n testId,\n css,\n window: targetWindow,\n}: UseComponentCssInjection): void {\n const styleInjectionEnabled = useStyleInjection();\n const insertionPoint = useInsertionPoint();\n\n maybeUseInsertionEffect(() => {\n if (!targetWindow || !styleInjectionEnabled) {\n return;\n }\n\n const sheetsMap =\n windowSheetsMap.get(targetWindow) ??\n new Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n >();\n const styleMap = sheetsMap.get(css) ?? { styleElement: null, count: 0 };\n\n if (styleMap.styleElement == null) {\n styleMap.styleElement = targetWindow.document.createElement(\"style\");\n styleMap.styleElement.setAttribute(\"type\", \"text/css\");\n styleMap.styleElement.setAttribute(\"data-salt-style\", testId || \"\");\n styleMap.styleElement.textContent = css;\n\n styleMap.count = 1;\n\n targetWindow.document.head.insertBefore(\n styleMap.styleElement,\n insertionPoint || targetWindow.document.head.firstChild\n );\n } else {\n styleMap.styleElement.textContent = css;\n styleMap.count++;\n }\n sheetsMap.set(css, styleMap);\n windowSheetsMap.set(targetWindow, sheetsMap);\n\n return () => {\n const sheetsMap = windowSheetsMap.get(targetWindow);\n const styleMap = sheetsMap?.get(css);\n if (styleMap?.styleElement) {\n styleMap.count--;\n if (styleMap.count < 1) {\n targetWindow.document.head.removeChild(styleMap.styleElement);\n styleMap.styleElement = null;\n sheetsMap?.delete(css);\n }\n }\n };\n }, [testId, css, targetWindow]);\n}\n"],"names":["React","useStyleInjection","useInsertionPoint","_a","sheetsMap","styleMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA,CAAA;AAKA,MAAM,2BACH,EAAc,GAAAA,gBAAA,CAAA,oBAAA,CAAqB,QAAS,EAAA,CAAA,KAA5C,YAAkDA,gBAAM,CAAA,eAAA,CAAA;AAgB3D,MAAM,eAAA,uBAAsB,OAAiC,EAAA,CAAA;AAEtD,SAAS,wBAAyB,CAAA;AAAA,EACvC,MAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAQ,EAAA,YAAA;AACV,CAAmC,EAAA;AACjC,EAAA,MAAM,wBAAwBC,uBAAkB,EAAA,C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SAAA,CAAA,GAAA,CAAI,KAAK,QAAQ,CAAA,CAAA;AAC3B,IAAgB,eAAA,CAAA,GAAA,CAAI,cAAc,SAAS,CAAA,CAAA;AAE3C,IAAA,OAAO,MAAM;AACX,MAAMC,MAAAA,UAAAA,GAAY,eAAgB,CAAA,GAAA,CAAI,YAAY,CAAA,CAAA;AAClD,MAAA,MAAMC,SAAWD,GAAAA,UAAAA,IAAA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,UAAAA,CAAW,GAAI,CAAA,GAAA,CAAA,CAAA;AAChC,MAAIC,IAAAA,SAAAA,IAAA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,SAAAA,CAAU,YAAc,EAAA;AAC1B,QAAAA,SAAS,CAAA,KAAA,EAAA,CAAA;AACT,QAAIA,IAAAA,SAAAA,CAAS,QAAQ,CAAG,EAAA;AACtB,UAAA,YAAA,CAAa,QAAS,CAAA,IAAA,CAAK,WAAYA,CAAAA,SAAAA,CAAS,YAAY,CAAA,CAAA;AAC5D,UAAAA,UAAS,YAAe,GAAA,IAAA,CAAA;AACxB,UAAAD,UAAAA,IAAA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,UAAAA,CAAW,MAAO,CAAA,GAAA,CAAA,CAAA;AAAA,SACpB;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACC,EAAA,CAAC,MAAQ,EAAA,GAAA,EAAK,YAAY,CAAC,CAAA,CAAA;AAChC;;;;"}
|
package/dist-es/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { useComponentCssInjection } from './use-style-injection/useStyleInjection.js';
|
|
2
2
|
export { InsertionPointProvider, useInsertionPoint } from './use-style-injection/InsertionPointProvider.js';
|
|
3
|
+
export { StyleInjectionProvider, useStyleInjection } from './style-injection-provider/index.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const StyleInjectionContext = createContext(true);
|
|
4
|
+
const useStyleInjection = () => useContext(StyleInjectionContext);
|
|
5
|
+
const StyleInjectionProvider = StyleInjectionContext.Provider;
|
|
6
|
+
|
|
7
|
+
export { StyleInjectionProvider, useStyleInjection };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/style-injection-provider/index.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nconst StyleInjectionContext = createContext(true);\n\nexport const useStyleInjection = () => useContext(StyleInjectionContext);\nexport const StyleInjectionProvider = StyleInjectionContext.Provider;\n"],"names":[],"mappings":";;AAEA,MAAM,qBAAA,GAAwB,cAAc,IAAI,CAAA,CAAA;AAEnC,MAAA,iBAAA,GAAoB,MAAM,UAAA,CAAW,qBAAqB,EAAA;AAChE,MAAM,yBAAyB,qBAAsB,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useInsertionPoint } from './InsertionPointProvider.js';
|
|
3
|
+
import { useStyleInjection } from '../style-injection-provider/index.js';
|
|
3
4
|
|
|
4
5
|
var _a;
|
|
5
6
|
const maybeUseInsertionEffect = (_a = React["useInsertionEffect".toString()]) != null ? _a : React.useLayoutEffect;
|
|
@@ -9,10 +10,11 @@ function useComponentCssInjection({
|
|
|
9
10
|
css,
|
|
10
11
|
window: targetWindow
|
|
11
12
|
}) {
|
|
13
|
+
const styleInjectionEnabled = useStyleInjection();
|
|
12
14
|
const insertionPoint = useInsertionPoint();
|
|
13
15
|
maybeUseInsertionEffect(() => {
|
|
14
16
|
var _a2, _b;
|
|
15
|
-
if (!targetWindow) {
|
|
17
|
+
if (!targetWindow || !styleInjectionEnabled) {
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
const sheetsMap = (_a2 = windowSheetsMap.get(targetWindow)) != null ? _a2 : /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleInjection.js","sources":["../src/use-style-injection/useStyleInjection.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useInsertionPoint } from \"./InsertionPointProvider\";\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985 */\nconst maybeUseInsertionEffect: typeof React.useLayoutEffect =\n (React as any)[\"useInsertionEffect\".toString()] ?? React.useLayoutEffect;\n/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n\nexport interface UseComponentCssInjection {\n testId?: string;\n css: string;\n window?: Window | null;\n}\n\ntype StyleElementMap = Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n>;\n\n// windowSheetsMap maps window objects to StyleElementMaps\n// A StyleElementMap maps css strings to style element tags\nconst windowSheetsMap = new WeakMap<Window, StyleElementMap>();\n\nexport function useComponentCssInjection({\n testId,\n css,\n window: targetWindow,\n}: UseComponentCssInjection): void {\n const insertionPoint = useInsertionPoint();\n\n maybeUseInsertionEffect(() => {\n if (!targetWindow) {\n return;\n }\n\n const sheetsMap =\n windowSheetsMap.get(targetWindow) ??\n new Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n >();\n const styleMap = sheetsMap.get(css) ?? { styleElement: null, count: 0 };\n\n if (styleMap.styleElement == null) {\n styleMap.styleElement = targetWindow.document.createElement(\"style\");\n styleMap.styleElement.setAttribute(\"type\", \"text/css\");\n styleMap.styleElement.setAttribute(\"data-salt-style\", testId || \"\");\n styleMap.styleElement.textContent = css;\n\n styleMap.count = 1;\n\n targetWindow.document.head.insertBefore(\n styleMap.styleElement,\n insertionPoint || targetWindow.document.head.firstChild\n );\n } else {\n styleMap.styleElement.textContent = css;\n styleMap.count++;\n }\n sheetsMap.set(css, styleMap);\n windowSheetsMap.set(targetWindow, sheetsMap);\n\n return () => {\n const sheetsMap = windowSheetsMap.get(targetWindow);\n const styleMap = sheetsMap?.get(css);\n if (styleMap?.styleElement) {\n styleMap.count--;\n if (styleMap.count < 1) {\n targetWindow.document.head.removeChild(styleMap.styleElement);\n styleMap.styleElement = null;\n sheetsMap?.delete(css);\n }\n }\n };\n }, [testId, css, targetWindow]);\n}\n"],"names":["_a","sheetsMap","styleMap"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStyleInjection.js","sources":["../src/use-style-injection/useStyleInjection.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useInsertionPoint } from \"./InsertionPointProvider\";\nimport { useStyleInjection } from \"../style-injection-provider\";\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985 */\nconst maybeUseInsertionEffect: typeof React.useLayoutEffect =\n (React as any)[\"useInsertionEffect\".toString()] ?? React.useLayoutEffect;\n/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n\nexport interface UseComponentCssInjection {\n testId?: string;\n css: string;\n window?: Window | null;\n}\n\ntype StyleElementMap = Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n>;\n\n// windowSheetsMap maps window objects to StyleElementMaps\n// A StyleElementMap maps css strings to style element tags\nconst windowSheetsMap = new WeakMap<Window, StyleElementMap>();\n\nexport function useComponentCssInjection({\n testId,\n css,\n window: targetWindow,\n}: UseComponentCssInjection): void {\n const styleInjectionEnabled = useStyleInjection();\n const insertionPoint = useInsertionPoint();\n\n maybeUseInsertionEffect(() => {\n if (!targetWindow || !styleInjectionEnabled) {\n return;\n }\n\n const sheetsMap =\n windowSheetsMap.get(targetWindow) ??\n new Map<\n string,\n { styleElement: HTMLStyleElement | null; count: number }\n >();\n const styleMap = sheetsMap.get(css) ?? { styleElement: null, count: 0 };\n\n if (styleMap.styleElement == null) {\n styleMap.styleElement = targetWindow.document.createElement(\"style\");\n styleMap.styleElement.setAttribute(\"type\", \"text/css\");\n styleMap.styleElement.setAttribute(\"data-salt-style\", testId || \"\");\n styleMap.styleElement.textContent = css;\n\n styleMap.count = 1;\n\n targetWindow.document.head.insertBefore(\n styleMap.styleElement,\n insertionPoint || targetWindow.document.head.firstChild\n );\n } else {\n styleMap.styleElement.textContent = css;\n styleMap.count++;\n }\n sheetsMap.set(css, styleMap);\n windowSheetsMap.set(targetWindow, sheetsMap);\n\n return () => {\n const sheetsMap = windowSheetsMap.get(targetWindow);\n const styleMap = sheetsMap?.get(css);\n if (styleMap?.styleElement) {\n styleMap.count--;\n if (styleMap.count < 1) {\n targetWindow.document.head.removeChild(styleMap.styleElement);\n styleMap.styleElement = null;\n sheetsMap?.delete(css);\n }\n }\n };\n }, [testId, css, targetWindow]);\n}\n"],"names":["_a","sheetsMap","styleMap"],"mappings":";;;;AAAA,IAAA,EAAA,CAAA;AAKA,MAAM,2BACH,EAAc,GAAA,KAAA,CAAA,oBAAA,CAAqB,QAAS,EAAA,CAAA,KAA5C,YAAkD,KAAM,CAAA,eAAA,CAAA;AAgB3D,MAAM,eAAA,uBAAsB,OAAiC,EAAA,CAAA;AAEtD,SAAS,wBAAyB,CAAA;AAAA,EACvC,MAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAQ,EAAA,YAAA;AACV,CAAmC,EAAA;AACjC,EAAA,MAAM,wBAAwB,iBAAkB,EAAA,CAAA;AAChD,EAAA,MAAM,iBAAiB,iBAAkB,EAAA,CAAA;AAEzC,EAAA,uBAAA,CAAwB,MAAM;AAhChC,IAAA,IAAAA,GAAA,EAAA,EAAA,CAAA;AAiCI,IAAI,IAAA,CAAC,YAAgB,IAAA,CAAC,qBAA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