@tamagui/z-index-stack 2.0.0-rc.3 → 2.0.0-rc.30
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 +13 -10
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -6
- package/package.json +5 -8
- package/dist/cjs/StackZIndex.js +0 -29
- package/dist/cjs/StackZIndex.js.map +0 -6
- package/dist/cjs/context.js +0 -23
- package/dist/cjs/context.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useStackedZIndex.js +0 -61
- package/dist/cjs/useStackedZIndex.js.map +0 -6
- package/dist/esm/StackZIndex.js +0 -15
- package/dist/esm/StackZIndex.js.map +0 -6
- package/dist/esm/context.js +0 -7
- package/dist/esm/context.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useStackedZIndex.js +0 -46
- package/dist/esm/useStackedZIndex.js.map +0 -6
package/dist/cjs/index.js
CHANGED
|
@@ -3,15 +3,18 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
12
16
|
var index_exports = {};
|
|
13
17
|
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
__reExport(index_exports, require("./useStackedZIndex"), module.exports);
|
|
15
|
-
__reExport(index_exports, require("./StackZIndex"), module.exports);
|
|
16
|
-
__reExport(index_exports, require("./context"), module.exports);
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
18
|
+
__reExport(index_exports, require("./useStackedZIndex.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./StackZIndex.cjs"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./context.cjs"), module.exports);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./useStackedZIndex";
|
|
2
|
-
export * from "./StackZIndex";
|
|
3
|
-
export * from "./context";
|
|
1
|
+
export * from "./useStackedZIndex.mjs";
|
|
2
|
+
export * from "./StackZIndex.mjs";
|
|
3
|
+
export * from "./context.mjs";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/z-index-stack",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.30",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -18,15 +18,12 @@
|
|
|
18
18
|
"./package.json": "./package.json",
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./types/index.d.ts",
|
|
21
|
-
"react-native":
|
|
22
|
-
|
|
23
|
-
"import": "./dist/esm/index.native.js",
|
|
24
|
-
"require": "./dist/cjs/index.native.js"
|
|
25
|
-
},
|
|
21
|
+
"react-native": "./dist/esm/index.native.js",
|
|
22
|
+
"browser": "./dist/esm/index.mjs",
|
|
26
23
|
"module": "./dist/esm/index.mjs",
|
|
27
24
|
"import": "./dist/esm/index.mjs",
|
|
28
25
|
"require": "./dist/cjs/index.cjs",
|
|
29
|
-
"default": "./dist/
|
|
26
|
+
"default": "./dist/esm/index.mjs"
|
|
30
27
|
}
|
|
31
28
|
},
|
|
32
29
|
"publishConfig": {
|
|
@@ -39,7 +36,7 @@
|
|
|
39
36
|
"clean:build": "tamagui-build clean:build"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "2.0.0-rc.
|
|
39
|
+
"@tamagui/build": "2.0.0-rc.30",
|
|
43
40
|
"react": ">=19"
|
|
44
41
|
},
|
|
45
42
|
"peerDependencies": {
|
package/dist/cjs/StackZIndex.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var StackZIndex_exports = {};
|
|
16
|
-
__export(StackZIndex_exports, {
|
|
17
|
-
StackZIndexContext: () => StackZIndexContext
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(StackZIndex_exports);
|
|
20
|
-
var import_react = require("react"), import_context = require("./context"), import_jsx_runtime = require("react/jsx-runtime");
|
|
21
|
-
const StackZIndexContext = ({
|
|
22
|
-
children,
|
|
23
|
-
zIndex
|
|
24
|
-
}) => {
|
|
25
|
-
const existing = (0, import_react.useContext)(import_context.ZIndexStackContext);
|
|
26
|
-
let content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ZIndexStackContext.Provider, { value: existing + 1, children });
|
|
27
|
-
return typeof zIndex < "u" && (content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ZIndexHardcodedContext.Provider, { value: zIndex, children: content })), content;
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=StackZIndex.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/StackZIndex.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B,kBAC3B,iBAA2D,sBAYvD;AAVG,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,eAAW,yBAAW,iCAAkB;AAE9C,MAAI,UACF,4CAAC,kCAAmB,UAAnB,EAA4B,OAAO,WAAW,GAC5C,UACH;AAGF,SAAI,OAAO,SAAW,QACpB,UACE,4CAAC,sCAAuB,UAAvB,EAAgC,OAAO,QACrC,mBACH,IAIG;AACT;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/cjs/context.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var context_exports = {};
|
|
16
|
-
__export(context_exports, {
|
|
17
|
-
ZIndexHardcodedContext: () => ZIndexHardcodedContext,
|
|
18
|
-
ZIndexStackContext: () => ZIndexStackContext
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(context_exports);
|
|
21
|
-
var import_react = require("react");
|
|
22
|
-
const ZIndexStackContext = (0, import_react.createContext)(1), ZIndexHardcodedContext = (0, import_react.createContext)(void 0);
|
|
23
|
-
//# sourceMappingURL=context.js.map
|
package/dist/cjs/context.js.map
DELETED
package/dist/cjs/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
};
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var types_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(types_exports);
|
|
14
|
-
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var useStackedZIndex_exports = {};
|
|
16
|
-
__export(useStackedZIndex_exports, {
|
|
17
|
-
useStackedZIndex: () => useStackedZIndex
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(useStackedZIndex_exports);
|
|
20
|
-
var import_react = require("react"), import_context = require("./context");
|
|
21
|
-
const ZIndicesByContext = {}, CurrentPortalZIndices = {}, useStackedZIndex = (props) => {
|
|
22
|
-
if (process.env.TAMAGUI_STACK_Z_INDEX_GLOBAL) {
|
|
23
|
-
const { stackZIndex, zIndex: zIndexProp } = props, id = (0, import_react.useId)(), zIndex = (0, import_react.useMemo)(() => {
|
|
24
|
-
if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
|
|
25
|
-
const highest = Object.values(CurrentPortalZIndices).reduce(
|
|
26
|
-
(acc, cur) => Math.max(acc, cur),
|
|
27
|
-
0
|
|
28
|
-
);
|
|
29
|
-
return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
|
|
30
|
-
}
|
|
31
|
-
return zIndexProp ?? 1e3;
|
|
32
|
-
}, [stackZIndex]);
|
|
33
|
-
return (0, import_react.useEffect)(() => {
|
|
34
|
-
if (typeof stackZIndex == "number")
|
|
35
|
-
return CurrentPortalZIndices[id] = stackZIndex, () => {
|
|
36
|
-
delete CurrentPortalZIndices[id];
|
|
37
|
-
};
|
|
38
|
-
}, [stackZIndex]), zIndex;
|
|
39
|
-
} else {
|
|
40
|
-
const { stackZIndex, zIndex: zIndexProp } = props, id = (0, import_react.useId)(), stackingContextLevel = (0, import_react.useContext)(import_context.ZIndexStackContext), stackLayer = stackZIndex === "global" ? 0 : stackingContextLevel, hardcoded = (0, import_react.useContext)(import_context.ZIndexHardcodedContext);
|
|
41
|
-
ZIndicesByContext[stackLayer] ||= {};
|
|
42
|
-
const stackContext = ZIndicesByContext[stackLayer], zIndex = (0, import_react.useMemo)(() => {
|
|
43
|
-
if (typeof zIndexProp == "number")
|
|
44
|
-
return zIndexProp;
|
|
45
|
-
if (stackZIndex) {
|
|
46
|
-
if (hardcoded)
|
|
47
|
-
return hardcoded + 1;
|
|
48
|
-
const entries = Object.values(stackContext), baseForLayer = stackLayer * 5e3, nextLayerBase = (stackLayer + 1) * 5e3, validEntries = entries.filter((z) => z < nextLayerBase), highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer, nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
|
|
49
|
-
return typeof stackZIndex == "number" ? stackZIndex + nextZIndex : nextZIndex;
|
|
50
|
-
}
|
|
51
|
-
return 1;
|
|
52
|
-
}, [stackLayer, zIndexProp, stackZIndex]);
|
|
53
|
-
return (0, import_react.useEffect)(() => {
|
|
54
|
-
if (stackZIndex)
|
|
55
|
-
return stackContext[id] = zIndex, () => {
|
|
56
|
-
delete stackContext[id];
|
|
57
|
-
};
|
|
58
|
-
}, [zIndex]), zIndex;
|
|
59
|
-
}
|
|
60
|
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YAAI;AACF,iBAAO,YAAY;AAGrB,cAAM,UAAU,OAAO,OAAO,YAAY,GACpC,eAAe,aAAa,KAC5B,iBAAiB,aAAa,KAAK,KAInC,eAAe,QAAQ,OAAO,CAAC,MAAM,IAAI,aAAa,GAEtD,UAAU,aAAa,SAAS,IAAI,KAAK,IAAI,GAAG,YAAY,IAAI,cAGhE,aAAa,YAAY,eAAe,eAAe,IAAI,UAAU;AAG3E,eAAO,OAAO,eAAgB,WAAW,cAAc,aAAa;AAAA,MACtE;AAEA,aAAO;AAAA,IACT,GAAG,CAAC,YAAY,YAAY,WAAW,CAAC;AAExC,uCAAU,MAAM;AACd,UAAI;AACF,4BAAa,EAAE,IAAI,QACZ,MAAM;AACX,iBAAO,aAAa,EAAE;AAAA,QACxB;AAAA,IAEJ,GAAG,CAAC,MAAM,CAAC,GAEJ;AAAA,EACT;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/StackZIndex.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { ZIndexHardcodedContext, ZIndexStackContext } from "./context";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
const StackZIndexContext = ({
|
|
5
|
-
children,
|
|
6
|
-
zIndex
|
|
7
|
-
}) => {
|
|
8
|
-
const existing = useContext(ZIndexStackContext);
|
|
9
|
-
let content = /* @__PURE__ */ jsx(ZIndexStackContext.Provider, { value: existing + 1, children });
|
|
10
|
-
return typeof zIndex < "u" && (content = /* @__PURE__ */ jsx(ZIndexHardcodedContext.Provider, { value: zIndex, children: content })), content;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
StackZIndexContext
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=StackZIndex.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/StackZIndex.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB,0BAA0B;AAYvD;AAVG,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,WAAW,WAAW,kBAAkB;AAE9C,MAAI,UACF,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,WAAW,GAC5C,UACH;AAGF,SAAI,OAAO,SAAW,QACpB,UACE,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,QACrC,mBACH,IAIG;AACT;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/context.js
DELETED
package/dist/esm/context.js.map
DELETED
package/dist/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/dist/esm/types.js.map
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useId, useMemo } from "react";
|
|
2
|
-
import { ZIndexHardcodedContext, ZIndexStackContext } from "./context";
|
|
3
|
-
const ZIndicesByContext = {}, CurrentPortalZIndices = {}, useStackedZIndex = (props) => {
|
|
4
|
-
if (process.env.TAMAGUI_STACK_Z_INDEX_GLOBAL) {
|
|
5
|
-
const { stackZIndex, zIndex: zIndexProp } = props, id = useId(), zIndex = useMemo(() => {
|
|
6
|
-
if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
|
|
7
|
-
const highest = Object.values(CurrentPortalZIndices).reduce(
|
|
8
|
-
(acc, cur) => Math.max(acc, cur),
|
|
9
|
-
0
|
|
10
|
-
);
|
|
11
|
-
return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
|
|
12
|
-
}
|
|
13
|
-
return zIndexProp ?? 1e3;
|
|
14
|
-
}, [stackZIndex]);
|
|
15
|
-
return useEffect(() => {
|
|
16
|
-
if (typeof stackZIndex == "number")
|
|
17
|
-
return CurrentPortalZIndices[id] = stackZIndex, () => {
|
|
18
|
-
delete CurrentPortalZIndices[id];
|
|
19
|
-
};
|
|
20
|
-
}, [stackZIndex]), zIndex;
|
|
21
|
-
} else {
|
|
22
|
-
const { stackZIndex, zIndex: zIndexProp } = props, id = useId(), stackingContextLevel = useContext(ZIndexStackContext), stackLayer = stackZIndex === "global" ? 0 : stackingContextLevel, hardcoded = useContext(ZIndexHardcodedContext);
|
|
23
|
-
ZIndicesByContext[stackLayer] ||= {};
|
|
24
|
-
const stackContext = ZIndicesByContext[stackLayer], zIndex = useMemo(() => {
|
|
25
|
-
if (typeof zIndexProp == "number")
|
|
26
|
-
return zIndexProp;
|
|
27
|
-
if (stackZIndex) {
|
|
28
|
-
if (hardcoded)
|
|
29
|
-
return hardcoded + 1;
|
|
30
|
-
const entries = Object.values(stackContext), baseForLayer = stackLayer * 5e3, nextLayerBase = (stackLayer + 1) * 5e3, validEntries = entries.filter((z) => z < nextLayerBase), highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer, nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
|
|
31
|
-
return typeof stackZIndex == "number" ? stackZIndex + nextZIndex : nextZIndex;
|
|
32
|
-
}
|
|
33
|
-
return 1;
|
|
34
|
-
}, [stackLayer, zIndexProp, stackZIndex]);
|
|
35
|
-
return useEffect(() => {
|
|
36
|
-
if (stackZIndex)
|
|
37
|
-
return stackContext[id] = zIndex, () => {
|
|
38
|
-
delete stackContext[id];
|
|
39
|
-
};
|
|
40
|
-
}, [zIndex]), zIndex;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
export {
|
|
44
|
-
useStackedZIndex
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=useStackedZIndex.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useStackedZIndex.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,YAAY,WAAW,OAAO,eAAe;AACtD,SAAS,wBAAwB,0BAA0B;AAI3D,MAAM,oBAA4D,CAAC,GAG7D,w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