@cfxjs/sirius-next-common 0.1.29 → 0.1.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/chunk-3A4LE5OK.js +49 -0
- package/dist/chunk-3A4LE5OK.js.map +1 -0
- package/dist/chunk-3D63CPYB.js +2324 -0
- package/dist/chunk-3D63CPYB.js.map +1 -0
- package/dist/chunk-477HNUQM.js +63 -0
- package/dist/chunk-477HNUQM.js.map +1 -0
- package/dist/chunk-47CQDRI6.js +63 -0
- package/dist/chunk-47CQDRI6.js.map +1 -0
- package/dist/chunk-4QV2QZUP.js +212 -0
- package/dist/chunk-4QV2QZUP.js.map +1 -0
- package/dist/chunk-562J5LFF.js +246 -0
- package/dist/chunk-562J5LFF.js.map +1 -0
- package/dist/chunk-5ET2WT43.js +108 -0
- package/dist/chunk-5ET2WT43.js.map +1 -0
- package/dist/chunk-5FMESSK6.js +745 -0
- package/dist/chunk-5FMESSK6.js.map +1 -0
- package/dist/chunk-5IJQNIWM.js +2324 -0
- package/dist/chunk-5IJQNIWM.js.map +1 -0
- package/dist/chunk-5KR5M3LI.js +212 -0
- package/dist/chunk-5KR5M3LI.js.map +1 -0
- package/dist/chunk-5PC6ZUSP.js +49 -0
- package/dist/chunk-5PC6ZUSP.js.map +1 -0
- package/dist/chunk-5TBPQWGO.js +63 -0
- package/dist/chunk-5TBPQWGO.js.map +1 -0
- package/dist/chunk-62QRMHTS.js +244 -0
- package/dist/chunk-62QRMHTS.js.map +1 -0
- package/dist/chunk-7BBDDNFI.js +3629 -0
- package/dist/chunk-7BBDDNFI.js.map +1 -0
- package/dist/chunk-7WYVSPSJ.js +745 -0
- package/dist/chunk-7WYVSPSJ.js.map +1 -0
- package/dist/chunk-AS7RCHEU.js +212 -0
- package/dist/chunk-AS7RCHEU.js.map +1 -0
- package/dist/chunk-AYFDTOKM.js +127 -0
- package/dist/chunk-AYFDTOKM.js.map +1 -0
- package/dist/chunk-B2BIAMGC.js +2324 -0
- package/dist/chunk-B2BIAMGC.js.map +1 -0
- package/dist/chunk-BAXJ65FV.js +141 -0
- package/dist/chunk-BAXJ65FV.js.map +1 -0
- package/dist/chunk-BIXKB2BM.js +127 -0
- package/dist/chunk-BIXKB2BM.js.map +1 -0
- package/dist/chunk-BMC7K6XL.js +108 -0
- package/dist/chunk-BMC7K6XL.js.map +1 -0
- package/dist/chunk-BTGKYV55.js +244 -0
- package/dist/chunk-BTGKYV55.js.map +1 -0
- package/dist/chunk-CAZ6T2TX.js +745 -0
- package/dist/chunk-CAZ6T2TX.js.map +1 -0
- package/dist/chunk-D2WT6AUU.js +2324 -0
- package/dist/chunk-D2WT6AUU.js.map +1 -0
- package/dist/chunk-DDAGQ2JK.js +150 -0
- package/dist/chunk-DDAGQ2JK.js.map +1 -0
- package/dist/chunk-DSMBYGOR.js +141 -0
- package/dist/chunk-DSMBYGOR.js.map +1 -0
- package/dist/chunk-DVJSOTHM.js +141 -0
- package/dist/chunk-DVJSOTHM.js.map +1 -0
- package/dist/chunk-FJE2PVRA.js +745 -0
- package/dist/chunk-FJE2PVRA.js.map +1 -0
- package/dist/chunk-GG35SV7M.js +2324 -0
- package/dist/chunk-GG35SV7M.js.map +1 -0
- package/dist/chunk-GJCF27KI.js +105 -0
- package/dist/chunk-GJCF27KI.js.map +1 -0
- package/dist/chunk-GSS7YAQU.js +3629 -0
- package/dist/chunk-GSS7YAQU.js.map +1 -0
- package/dist/chunk-GTOQ3FIN.js +49 -0
- package/dist/chunk-GTOQ3FIN.js.map +1 -0
- package/dist/chunk-HFSZYAU2.js +141 -0
- package/dist/chunk-HFSZYAU2.js.map +1 -0
- package/dist/chunk-HZ4M5LY2.js +3629 -0
- package/dist/chunk-HZ4M5LY2.js.map +1 -0
- package/dist/chunk-INIJGBG4.js +212 -0
- package/dist/chunk-INIJGBG4.js.map +1 -0
- package/dist/chunk-ISMLXDGF.js +150 -0
- package/dist/chunk-ISMLXDGF.js.map +1 -0
- package/dist/chunk-JEDBRDNZ.js +150 -0
- package/dist/chunk-JEDBRDNZ.js.map +1 -0
- package/dist/chunk-JVUY3R5I.js +244 -0
- package/dist/chunk-JVUY3R5I.js.map +1 -0
- package/dist/chunk-L65TAZGA.js +2324 -0
- package/dist/chunk-L65TAZGA.js.map +1 -0
- package/dist/chunk-LEGITSAD.js +105 -0
- package/dist/chunk-LEGITSAD.js.map +1 -0
- package/dist/chunk-LLTRCE44.js +127 -0
- package/dist/chunk-LLTRCE44.js.map +1 -0
- package/dist/chunk-MDJJ2N7B.js +49 -0
- package/dist/chunk-MDJJ2N7B.js.map +1 -0
- package/dist/chunk-MO6EWADQ.js +63 -0
- package/dist/chunk-MO6EWADQ.js.map +1 -0
- package/dist/chunk-MT5ZPVBD.js +212 -0
- package/dist/chunk-MT5ZPVBD.js.map +1 -0
- package/dist/chunk-NCKPYRTE.js +105 -0
- package/dist/chunk-NCKPYRTE.js.map +1 -0
- package/dist/chunk-NHXG5FKK.js +108 -0
- package/dist/chunk-NHXG5FKK.js.map +1 -0
- package/dist/chunk-NQ5QNBNM.js +105 -0
- package/dist/chunk-NQ5QNBNM.js.map +1 -0
- package/dist/chunk-NVSEXPAT.js +3629 -0
- package/dist/chunk-NVSEXPAT.js.map +1 -0
- package/dist/chunk-NXGS5QEO.js +141 -0
- package/dist/chunk-NXGS5QEO.js.map +1 -0
- package/dist/chunk-NXXSUIXY.js +150 -0
- package/dist/chunk-NXXSUIXY.js.map +1 -0
- package/dist/chunk-PXXEFNOE.js +3629 -0
- package/dist/chunk-PXXEFNOE.js.map +1 -0
- package/dist/chunk-Q3MMY6EU.js +244 -0
- package/dist/chunk-Q3MMY6EU.js.map +1 -0
- package/dist/chunk-Q5D5FHO7.js +212 -0
- package/dist/chunk-Q5D5FHO7.js.map +1 -0
- package/dist/chunk-QCVM6HOF.js +3629 -0
- package/dist/chunk-QCVM6HOF.js.map +1 -0
- package/dist/chunk-QFAWAODA.js +150 -0
- package/dist/chunk-QFAWAODA.js.map +1 -0
- package/dist/chunk-QUOMAXP4.js +2324 -0
- package/dist/chunk-QUOMAXP4.js.map +1 -0
- package/dist/chunk-QY5G7QYB.js +150 -0
- package/dist/chunk-QY5G7QYB.js.map +1 -0
- package/dist/chunk-RLQ7WP5W.js +127 -0
- package/dist/chunk-RLQ7WP5W.js.map +1 -0
- package/dist/chunk-RP27EARH.js +49 -0
- package/dist/chunk-RP27EARH.js.map +1 -0
- package/dist/chunk-RVL3W5DP.js +105 -0
- package/dist/chunk-RVL3W5DP.js.map +1 -0
- package/dist/chunk-S335KQ5D.js +49 -0
- package/dist/chunk-S335KQ5D.js.map +1 -0
- package/dist/chunk-SN6AMUVZ.js +108 -0
- package/dist/chunk-SN6AMUVZ.js.map +1 -0
- package/dist/chunk-SOL2SFT2.js +246 -0
- package/dist/chunk-SOL2SFT2.js.map +1 -0
- package/dist/chunk-T54ODLMI.js +49 -0
- package/dist/chunk-T54ODLMI.js.map +1 -0
- package/dist/chunk-T7FNENEU.js +150 -0
- package/dist/chunk-T7FNENEU.js.map +1 -0
- package/dist/chunk-TGW2NDL5.js +108 -0
- package/dist/chunk-TGW2NDL5.js.map +1 -0
- package/dist/chunk-TIAC33MC.js +745 -0
- package/dist/chunk-TIAC33MC.js.map +1 -0
- package/dist/chunk-TLIOHXCZ.js +63 -0
- package/dist/chunk-TLIOHXCZ.js.map +1 -0
- package/dist/chunk-UCDEIGII.js +141 -0
- package/dist/chunk-UCDEIGII.js.map +1 -0
- package/dist/chunk-UGV7LSWR.js +745 -0
- package/dist/chunk-UGV7LSWR.js.map +1 -0
- package/dist/chunk-UVTOU2ZP.js +127 -0
- package/dist/chunk-UVTOU2ZP.js.map +1 -0
- package/dist/chunk-V7FEY5O4.js +127 -0
- package/dist/chunk-V7FEY5O4.js.map +1 -0
- package/dist/chunk-VMQBNQNS.js +141 -0
- package/dist/chunk-VMQBNQNS.js.map +1 -0
- package/dist/chunk-W5TV463S.js +127 -0
- package/dist/chunk-W5TV463S.js.map +1 -0
- package/dist/chunk-WEOKDVJD.js +108 -0
- package/dist/chunk-WEOKDVJD.js.map +1 -0
- package/dist/chunk-XC53X56K.js +108 -0
- package/dist/chunk-XC53X56K.js.map +1 -0
- package/dist/chunk-XCPB27SN.js +745 -0
- package/dist/chunk-XCPB27SN.js.map +1 -0
- package/dist/chunk-XYR4GKBH.js +63 -0
- package/dist/chunk-XYR4GKBH.js.map +1 -0
- package/dist/chunk-Y7TGANWP.js +212 -0
- package/dist/chunk-Y7TGANWP.js.map +1 -0
- package/dist/chunk-YKN5WWYP.js +63 -0
- package/dist/chunk-YKN5WWYP.js.map +1 -0
- package/dist/chunk-YVVEURB7.js +3629 -0
- package/dist/chunk-YVVEURB7.js.map +1 -0
- package/dist/chunk-YXISQECP.js +244 -0
- package/dist/chunk-YXISQECP.js.map +1 -0
- package/dist/chunk-Z2WEOQ72.js +105 -0
- package/dist/chunk-Z2WEOQ72.js.map +1 -0
- package/dist/chunk-ZKPSSERO.js +105 -0
- package/dist/chunk-ZKPSSERO.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +9 -9
- package/dist/components/AddressContainer/EVMAddressContainer.js +8 -8
- package/dist/components/AddressContainer/addressSwitcher.js +6 -6
- package/dist/components/AddressContainer/addressView.js +5 -5
- package/dist/components/AddressContainer/label.js +4 -4
- package/dist/components/Age/index.js +4 -4
- package/dist/components/Charts/PreviewChartTemplate.js +1 -1
- package/dist/components/Charts/StockChartTemplate.js +1 -1
- package/dist/components/CopyButton/index.js +3 -3
- package/dist/components/DownloadCSV/index.js +5 -9
- package/dist/components/DownloadCSV/index.js.map +1 -1
- package/dist/components/Dropdown/index.js +7 -13
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/GasPriceDropdown/index.js +2 -2
- package/dist/components/IncreasePercent/index.js +2 -2
- package/dist/components/InfoIconWithTooltip/index.js +3 -3
- package/dist/components/Modal/index.js +3 -3
- package/dist/components/PhishingAddressContainer/index.js +3 -3
- package/dist/components/Price/index.js +3 -3
- package/dist/components/Radio/index.js +2 -2
- package/dist/components/Select/index.js +3 -3
- package/dist/components/Select/select.js +3 -3
- package/dist/components/Text/index.js +4 -4
- package/dist/components/Tooltip/index.js +3 -3
- package/dist/components/TransactionAction/coreTransactionAction.js +9 -9
- package/dist/components/TransactionAction/evmTransactionAction.js +8 -8
- package/dist/utils/hooks/useENS.js +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/request.d.ts +2 -2
- package/dist/utils/request.js +3 -3
- package/package.json +4 -4
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Spin
|
|
3
|
+
} from "./chunk-XCKMXAL2.js";
|
|
4
|
+
import {
|
|
5
|
+
cn
|
|
6
|
+
} from "./chunk-CAZ6T2TX.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Modal/index.tsx
|
|
9
|
+
import { useEffect, useCallback, useMemo } from "react";
|
|
10
|
+
import ReactDOM from "react-dom";
|
|
11
|
+
import { X } from "lucide-react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
var Backdrop = ({
|
|
14
|
+
onClick,
|
|
15
|
+
children,
|
|
16
|
+
className
|
|
17
|
+
}) => /* @__PURE__ */ jsx("div", { className, onClick, children });
|
|
18
|
+
var ModalContent = ({
|
|
19
|
+
containerClassName,
|
|
20
|
+
closable,
|
|
21
|
+
onClose,
|
|
22
|
+
children,
|
|
23
|
+
loading,
|
|
24
|
+
modalStyles
|
|
25
|
+
}) => /* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: cn("relative bg-[#FFF] rounded shadow-lg", containerClassName),
|
|
29
|
+
tabIndex: -1,
|
|
30
|
+
style: modalStyles,
|
|
31
|
+
children: /* @__PURE__ */ jsxs(Spin, { spinning: loading, children: [
|
|
32
|
+
closable && /* @__PURE__ */ jsx(X, { className: "h-4 w-4 absolute right-5 top-5", onClick: onClose }),
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "p-4", children })
|
|
34
|
+
] })
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
var useEventListener = (eventName, handler, active) => {
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (active) {
|
|
40
|
+
const eventListener = (event) => handler(event);
|
|
41
|
+
document.addEventListener(eventName, eventListener);
|
|
42
|
+
return () => {
|
|
43
|
+
document.removeEventListener(eventName, eventListener);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}, [eventName, handler, active]);
|
|
47
|
+
};
|
|
48
|
+
var Modal = ({
|
|
49
|
+
open,
|
|
50
|
+
closeOnEsc = true,
|
|
51
|
+
closable = true,
|
|
52
|
+
preventScroll = true,
|
|
53
|
+
backdropClassName = "",
|
|
54
|
+
containerClassName = "",
|
|
55
|
+
onOpen = () => {
|
|
56
|
+
},
|
|
57
|
+
onClose,
|
|
58
|
+
children,
|
|
59
|
+
width = "600px",
|
|
60
|
+
maskClosable = true,
|
|
61
|
+
centered = true,
|
|
62
|
+
loading = false
|
|
63
|
+
}) => {
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (open) {
|
|
66
|
+
onOpen?.();
|
|
67
|
+
if (preventScroll) {
|
|
68
|
+
document.body.style.overflow = "hidden";
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
if (preventScroll) {
|
|
72
|
+
document.body.style.overflow = "";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
if (preventScroll) {
|
|
77
|
+
document.body.style.overflow = "";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [open, onOpen, preventScroll]);
|
|
81
|
+
const handleKeyDown = useCallback(
|
|
82
|
+
(event) => {
|
|
83
|
+
if (event.key === "Escape" && closeOnEsc && onClose) {
|
|
84
|
+
onClose?.();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[closeOnEsc, onClose]
|
|
88
|
+
);
|
|
89
|
+
const handleClickOutside = useCallback(() => {
|
|
90
|
+
if (onClose && maskClosable) {
|
|
91
|
+
onClose?.();
|
|
92
|
+
}
|
|
93
|
+
}, [onClose, maskClosable]);
|
|
94
|
+
const handleBackdropClick = useCallback(
|
|
95
|
+
(event) => {
|
|
96
|
+
if (maskClosable && event.target === event.currentTarget && onClose) {
|
|
97
|
+
onClose?.();
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[maskClosable, onClose]
|
|
101
|
+
);
|
|
102
|
+
const modalStyles = useMemo(
|
|
103
|
+
() => ({
|
|
104
|
+
width: typeof width === "string" ? width : `${width}px`,
|
|
105
|
+
margin: centered ? "auto" : void 0
|
|
106
|
+
}),
|
|
107
|
+
[width, centered]
|
|
108
|
+
);
|
|
109
|
+
useEventListener(
|
|
110
|
+
"keydown",
|
|
111
|
+
handleKeyDown,
|
|
112
|
+
open && closeOnEsc
|
|
113
|
+
);
|
|
114
|
+
useEventListener(
|
|
115
|
+
"mousedown",
|
|
116
|
+
handleClickOutside,
|
|
117
|
+
open && maskClosable
|
|
118
|
+
);
|
|
119
|
+
if (!open)
|
|
120
|
+
return null;
|
|
121
|
+
return ReactDOM.createPortal(
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
Backdrop,
|
|
124
|
+
{
|
|
125
|
+
onClick: handleBackdropClick,
|
|
126
|
+
className: cn(
|
|
127
|
+
"fixed inset-0 bg-[#000] bg-opacity-25 flex items-center justify-center z-10000",
|
|
128
|
+
backdropClassName
|
|
129
|
+
),
|
|
130
|
+
children: /* @__PURE__ */ jsx(
|
|
131
|
+
ModalContent,
|
|
132
|
+
{
|
|
133
|
+
containerClassName,
|
|
134
|
+
closable,
|
|
135
|
+
onClose,
|
|
136
|
+
children,
|
|
137
|
+
loading,
|
|
138
|
+
modalStyles
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
document.body
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
Modal
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=chunk-DDAGQ2JK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Modal/index.tsx"],"sourcesContent":["import React, { useEffect, useCallback, useMemo } from 'react';\nimport ReactDOM from 'react-dom';\nimport { X } from 'lucide-react';\nimport { Spin } from '../Spin';\nimport { cn } from '../../utils';\n\ninterface ModalProps {\n open: boolean;\n closeOnEsc?: boolean;\n closable?: boolean;\n preventScroll?: boolean;\n backdropClassName?: string;\n containerClassName?: string;\n onOpen?: () => void;\n onClose?: () => void;\n children?: React.ReactNode;\n width?: string | number;\n maskClosable?: boolean;\n centered?: boolean;\n loading?: boolean;\n}\n\ninterface ModalContentProps {\n containerClassName: string;\n closable: boolean;\n onClose?: VoidFunction;\n children?: React.ReactNode;\n loading?: boolean;\n modalStyles: React.CSSProperties;\n}\n\ninterface BackdropProps {\n onClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n className: string;\n children?: React.ReactNode;\n}\n\nconst Backdrop: React.FC<BackdropProps> = ({\n onClick,\n children,\n className,\n}) => (\n <div className={className} onClick={onClick}>\n {children}\n </div>\n);\n\nconst ModalContent = ({\n containerClassName,\n closable,\n onClose,\n children,\n loading,\n modalStyles,\n}: ModalContentProps) => (\n <div\n className={cn('relative bg-[#FFF] rounded shadow-lg', containerClassName)}\n tabIndex={-1}\n style={modalStyles}\n >\n <Spin spinning={loading}>\n {closable && (\n <X className=\"h-4 w-4 absolute right-5 top-5\" onClick={onClose} />\n )}\n <div className=\"p-4\">{children}</div>\n </Spin>\n </div>\n);\n\nconst useEventListener = (\n eventName: string,\n handler: (event: Event) => void,\n active: boolean,\n) => {\n useEffect(() => {\n if (active) {\n const eventListener = (event: Event) => handler(event);\n\n document.addEventListener(eventName, eventListener);\n return () => {\n document.removeEventListener(eventName, eventListener);\n };\n }\n }, [eventName, handler, active]);\n};\n\nconst Modal: React.FC<ModalProps> = ({\n open,\n closeOnEsc = true,\n closable = true,\n preventScroll = true,\n backdropClassName = '',\n containerClassName = '',\n onOpen = () => {},\n onClose,\n children,\n width = '600px',\n maskClosable = true,\n centered = true,\n loading = false,\n}) => {\n useEffect(() => {\n if (open) {\n onOpen?.();\n if (preventScroll) {\n document.body.style.overflow = 'hidden';\n }\n } else {\n if (preventScroll) {\n document.body.style.overflow = '';\n }\n }\n return () => {\n if (preventScroll) {\n document.body.style.overflow = '';\n }\n };\n }, [open, onOpen, preventScroll]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape' && closeOnEsc && onClose) {\n onClose?.();\n }\n },\n [closeOnEsc, onClose],\n );\n\n const handleClickOutside = useCallback(() => {\n if (onClose && maskClosable) {\n onClose?.();\n }\n }, [onClose, maskClosable]);\n\n const handleBackdropClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (maskClosable && event.target === event.currentTarget && onClose) {\n onClose?.();\n }\n },\n [maskClosable, onClose],\n );\n\n const modalStyles: React.CSSProperties = useMemo(\n () => ({\n width: typeof width === 'string' ? width : `${width}px`,\n margin: centered ? 'auto' : undefined,\n }),\n [width, centered],\n );\n\n useEventListener(\n 'keydown',\n handleKeyDown as (event: Event) => void,\n open && closeOnEsc,\n );\n useEventListener(\n 'mousedown',\n handleClickOutside as (event: Event) => void,\n open && maskClosable,\n );\n\n if (!open) return null;\n\n return ReactDOM.createPortal(\n <Backdrop\n onClick={handleBackdropClick}\n className={cn(\n 'fixed inset-0 bg-[#000] bg-opacity-25 flex items-center justify-center z-10000',\n backdropClassName,\n )}\n >\n <ModalContent\n containerClassName={containerClassName}\n closable={closable}\n onClose={onClose}\n children={children}\n loading={loading}\n modalStyles={modalStyles}\n />\n </Backdrop>,\n document.body,\n );\n};\n\nexport { Modal };\n"],"mappings":";;;;;;;;AAAA,SAAgB,WAAW,aAAa,eAAe;AACvD,OAAO,cAAc;AACrB,SAAS,SAAS;AAwChB,cAkBE,YAlBF;AALF,I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chunk-XYR4GKBH.js";
|
|
4
|
+
import {
|
|
5
|
+
ContractAddress,
|
|
6
|
+
ContractCreatedAddress,
|
|
7
|
+
CoreHexAddress,
|
|
8
|
+
InvalidAddress,
|
|
9
|
+
MyAddress,
|
|
10
|
+
PosAddress
|
|
11
|
+
} from "./chunk-INIJGBG4.js";
|
|
12
|
+
import {
|
|
13
|
+
RenderAddress
|
|
14
|
+
} from "./chunk-W5TV463S.js";
|
|
15
|
+
import {
|
|
16
|
+
formatAddress,
|
|
17
|
+
isCoreAddress,
|
|
18
|
+
isCoreContractAddress,
|
|
19
|
+
isZeroAddress
|
|
20
|
+
} from "./chunk-BVWWK2EL.js";
|
|
21
|
+
import {
|
|
22
|
+
getLabelInfo
|
|
23
|
+
} from "./chunk-RP27EARH.js";
|
|
24
|
+
import {
|
|
25
|
+
getTranslations,
|
|
26
|
+
useGlobalData
|
|
27
|
+
} from "./chunk-DQGLZCIG.js";
|
|
28
|
+
|
|
29
|
+
// src/components/AddressContainer/CoreAddressContainer.tsx
|
|
30
|
+
import { memo } from "react";
|
|
31
|
+
import { withTranslation } from "react-i18next";
|
|
32
|
+
import _ from "lodash";
|
|
33
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
34
|
+
var parseProps = (props, globalData) => {
|
|
35
|
+
const {
|
|
36
|
+
alias,
|
|
37
|
+
ensInfo,
|
|
38
|
+
t,
|
|
39
|
+
showAddressLabel,
|
|
40
|
+
showNametag,
|
|
41
|
+
nametagInfo,
|
|
42
|
+
showENSLabel
|
|
43
|
+
} = props;
|
|
44
|
+
const value = props.value || "";
|
|
45
|
+
const cfxAddress = formatAddress(value, "base32");
|
|
46
|
+
let ENSMap = ensInfo || {};
|
|
47
|
+
const translations = getTranslations();
|
|
48
|
+
let aliasLabel = alias;
|
|
49
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
50
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
51
|
+
}
|
|
52
|
+
let prefixIcon = null;
|
|
53
|
+
let officalNametag = null;
|
|
54
|
+
let addressLabel = null;
|
|
55
|
+
let ENSLabel = null;
|
|
56
|
+
const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;
|
|
57
|
+
if (cfxAddress && showAddressLabel) {
|
|
58
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
59
|
+
const gAddressLabel = addressLabels?.[cfxAddress];
|
|
60
|
+
if (gAddressLabel) {
|
|
61
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
62
|
+
addressLabel = label;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (cfxAddress && showNametag) {
|
|
66
|
+
const nametags = nametagInfo?.[cfxAddress];
|
|
67
|
+
if (nametags) {
|
|
68
|
+
const nametag = nametags?.nametag ?? "";
|
|
69
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
70
|
+
officalNametag = label;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (showENSLabel && gENSLabel) {
|
|
74
|
+
const { label, icon } = getLabelInfo(gENSLabel, "ens");
|
|
75
|
+
ENSLabel = label;
|
|
76
|
+
prefixIcon = icon;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
alias: aliasLabel,
|
|
80
|
+
prefix: prefixIcon,
|
|
81
|
+
nametag: officalNametag,
|
|
82
|
+
addressLabel,
|
|
83
|
+
ENSLabel,
|
|
84
|
+
cfxAddress
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var CoreAddressContainer = withTranslation()(
|
|
88
|
+
memo((props) => {
|
|
89
|
+
const { globalData } = useGlobalData();
|
|
90
|
+
const unnecessaryEns = props.ensInfo || props.showENSLabel === false;
|
|
91
|
+
const { ens } = useENS(unnecessaryEns ? null : props.value);
|
|
92
|
+
if (!props.value && !props.contractCreated) {
|
|
93
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
94
|
+
}
|
|
95
|
+
const defaultProps = {
|
|
96
|
+
isFull: false,
|
|
97
|
+
isFullNameTag: false,
|
|
98
|
+
link: true,
|
|
99
|
+
isMe: false,
|
|
100
|
+
showIcon: true,
|
|
101
|
+
verify: false,
|
|
102
|
+
showAddressLabel: true,
|
|
103
|
+
showENSLabel: true,
|
|
104
|
+
showNametag: true,
|
|
105
|
+
ensInfo: ens
|
|
106
|
+
};
|
|
107
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
108
|
+
const mergeParseProps = _.merge(
|
|
109
|
+
{},
|
|
110
|
+
mergeDefaultProps,
|
|
111
|
+
parseProps(mergeDefaultProps, globalData)
|
|
112
|
+
);
|
|
113
|
+
if (mergeParseProps.isPosAddress) {
|
|
114
|
+
return PosAddress(mergeParseProps);
|
|
115
|
+
}
|
|
116
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
117
|
+
return ContractCreatedAddress({
|
|
118
|
+
...mergeParseProps,
|
|
119
|
+
outputType: "base32"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (mergeParseProps.isEspaceAddress) {
|
|
123
|
+
return CoreHexAddress(mergeParseProps);
|
|
124
|
+
}
|
|
125
|
+
if (!isCoreAddress(mergeParseProps.value)) {
|
|
126
|
+
return InvalidAddress(mergeParseProps);
|
|
127
|
+
}
|
|
128
|
+
if (isCoreContractAddress(mergeParseProps.cfxAddress)) {
|
|
129
|
+
return ContractAddress(mergeParseProps);
|
|
130
|
+
}
|
|
131
|
+
if (mergeParseProps.isMe) {
|
|
132
|
+
return MyAddress(mergeParseProps);
|
|
133
|
+
}
|
|
134
|
+
return RenderAddress(mergeParseProps);
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
CoreAddressContainer
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=chunk-DSMBYGOR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/CoreAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isCoreAddress,\n isCoreContractAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\nimport { useENS } from '../../utils/hooks/useENS';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n CoreHexAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n PosAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { CoreAddressContainerProps } from './types';\n\nconst parseProps = (\n props: CoreAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n alias,\n ensInfo,\n t,\n showAddressLabel,\n showNametag,\n nametagInfo,\n showENSLabel,\n } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'base32');\n\n let ENSMap = ensInfo || {};\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n let prefixIcon: React.ReactNode = null;\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n // ens name tag\n let ENSLabel: React.ReactNode = null;\n // global ens name tag\n const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel = addressLabels?.[cfxAddress];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags = nametagInfo?.[cfxAddress];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n if (showENSLabel && gENSLabel) {\n const { label, icon } = getLabelInfo(gENSLabel, 'ens');\n ENSLabel = label;\n prefixIcon = icon;\n }\n\n return {\n alias: aliasLabel,\n prefix: prefixIcon,\n nametag: officalNametag,\n addressLabel,\n ENSLabel,\n cfxAddress,\n };\n};\n\nexport const CoreAddressContainer = withTranslation()(\n memo((props: CoreAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If the interface returns Ens content, there is no need to obtain it separately, or disable the display of Ens content (in most cases on the list page).\n const unnecessaryEns = props.ensInfo || props.showENSLabel === false;\n const { ens } = useENS(unnecessaryEns ? null : props.value);\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n ensInfo: ens,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (mergeParseProps.isPosAddress) {\n return PosAddress(mergeParseProps);\n }\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'base32',\n });\n }\n\n if (mergeParseProps.isEspaceAddress) {\n return CoreHexAddress(mergeParseProps);\n }\n\n if (!isCoreAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (isCoreContractAddress(mergeParseProps.cfxAddress)) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAddress(mergeParseProps);\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAA0B,uBAAuB;AACjD,OAAO,OAAO;AA2GD;AAlFb,IA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,
|
|
7
|
+
CoreHexAddress,
|
|
8
|
+
InvalidAddress,
|
|
9
|
+
MyAddress,
|
|
10
|
+
PosAddress
|
|
11
|
+
} from "./chunk-AS7RCHEU.js";
|
|
12
|
+
import {
|
|
13
|
+
RenderAddress
|
|
14
|
+
} from "./chunk-UVTOU2ZP.js";
|
|
15
|
+
import {
|
|
16
|
+
formatAddress,
|
|
17
|
+
isCoreAddress,
|
|
18
|
+
isCoreContractAddress,
|
|
19
|
+
isZeroAddress
|
|
20
|
+
} from "./chunk-BVWWK2EL.js";
|
|
21
|
+
import {
|
|
22
|
+
getLabelInfo
|
|
23
|
+
} from "./chunk-5PC6ZUSP.js";
|
|
24
|
+
import {
|
|
25
|
+
getTranslations,
|
|
26
|
+
useGlobalData
|
|
27
|
+
} from "./chunk-DQGLZCIG.js";
|
|
28
|
+
|
|
29
|
+
// src/components/AddressContainer/CoreAddressContainer.tsx
|
|
30
|
+
import { memo } from "react";
|
|
31
|
+
import { withTranslation } from "react-i18next";
|
|
32
|
+
import _ from "lodash";
|
|
33
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
34
|
+
var parseProps = (props, globalData) => {
|
|
35
|
+
const {
|
|
36
|
+
alias,
|
|
37
|
+
ensInfo,
|
|
38
|
+
t,
|
|
39
|
+
showAddressLabel,
|
|
40
|
+
showNametag,
|
|
41
|
+
nametagInfo,
|
|
42
|
+
showENSLabel
|
|
43
|
+
} = props;
|
|
44
|
+
const value = props.value || "";
|
|
45
|
+
const cfxAddress = formatAddress(value, "base32");
|
|
46
|
+
let ENSMap = ensInfo || {};
|
|
47
|
+
const translations = getTranslations();
|
|
48
|
+
let aliasLabel = alias;
|
|
49
|
+
if (!alias && isZeroAddress(cfxAddress)) {
|
|
50
|
+
aliasLabel = t(translations.general.zeroAddress);
|
|
51
|
+
}
|
|
52
|
+
let prefixIcon = null;
|
|
53
|
+
let officalNametag = null;
|
|
54
|
+
let addressLabel = null;
|
|
55
|
+
let ENSLabel = null;
|
|
56
|
+
const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;
|
|
57
|
+
if (cfxAddress && showAddressLabel) {
|
|
58
|
+
const addressLabels = globalData?.["CONFLUX_SCAN_ADDRESS_LABELS" /* addressLabel */];
|
|
59
|
+
const gAddressLabel = addressLabels?.[cfxAddress];
|
|
60
|
+
if (gAddressLabel) {
|
|
61
|
+
const { label } = getLabelInfo(gAddressLabel, "tag");
|
|
62
|
+
addressLabel = label;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (cfxAddress && showNametag) {
|
|
66
|
+
const nametags = nametagInfo?.[cfxAddress];
|
|
67
|
+
if (nametags) {
|
|
68
|
+
const nametag = nametags?.nametag ?? "";
|
|
69
|
+
const { label } = getLabelInfo(nametag, "nametag");
|
|
70
|
+
officalNametag = label;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (showENSLabel && gENSLabel) {
|
|
74
|
+
const { label, icon } = getLabelInfo(gENSLabel, "ens");
|
|
75
|
+
ENSLabel = label;
|
|
76
|
+
prefixIcon = icon;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
alias: aliasLabel,
|
|
80
|
+
prefix: prefixIcon,
|
|
81
|
+
nametag: officalNametag,
|
|
82
|
+
addressLabel,
|
|
83
|
+
ENSLabel,
|
|
84
|
+
cfxAddress
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var CoreAddressContainer = withTranslation()(
|
|
88
|
+
memo((props) => {
|
|
89
|
+
const { globalData } = useGlobalData();
|
|
90
|
+
const unnecessaryEns = props.ensInfo || props.showENSLabel === false;
|
|
91
|
+
const { ens } = useENS(unnecessaryEns ? null : props.value);
|
|
92
|
+
if (!props.value && !props.contractCreated) {
|
|
93
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "--" });
|
|
94
|
+
}
|
|
95
|
+
const defaultProps = {
|
|
96
|
+
isFull: false,
|
|
97
|
+
isFullNameTag: false,
|
|
98
|
+
link: true,
|
|
99
|
+
isMe: false,
|
|
100
|
+
showIcon: true,
|
|
101
|
+
verify: false,
|
|
102
|
+
showAddressLabel: true,
|
|
103
|
+
showENSLabel: true,
|
|
104
|
+
showNametag: true,
|
|
105
|
+
ensInfo: ens
|
|
106
|
+
};
|
|
107
|
+
const mergeDefaultProps = _.assign({}, defaultProps, props);
|
|
108
|
+
const mergeParseProps = _.merge(
|
|
109
|
+
{},
|
|
110
|
+
mergeDefaultProps,
|
|
111
|
+
parseProps(mergeDefaultProps, globalData)
|
|
112
|
+
);
|
|
113
|
+
if (mergeParseProps.isPosAddress) {
|
|
114
|
+
return PosAddress(mergeParseProps);
|
|
115
|
+
}
|
|
116
|
+
if (!mergeParseProps.value && mergeParseProps.contractCreated) {
|
|
117
|
+
return ContractCreatedAddress({
|
|
118
|
+
...mergeParseProps,
|
|
119
|
+
outputType: "base32"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (mergeParseProps.isEspaceAddress) {
|
|
123
|
+
return CoreHexAddress(mergeParseProps);
|
|
124
|
+
}
|
|
125
|
+
if (!isCoreAddress(mergeParseProps.value)) {
|
|
126
|
+
return InvalidAddress(mergeParseProps);
|
|
127
|
+
}
|
|
128
|
+
if (isCoreContractAddress(mergeParseProps.cfxAddress)) {
|
|
129
|
+
return ContractAddress(mergeParseProps);
|
|
130
|
+
}
|
|
131
|
+
if (mergeParseProps.isMe) {
|
|
132
|
+
return MyAddress(mergeParseProps);
|
|
133
|
+
}
|
|
134
|
+
return RenderAddress(mergeParseProps);
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
CoreAddressContainer
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=chunk-DVJSOTHM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/AddressContainer/CoreAddressContainer.tsx"],"sourcesContent":["import { memo } from 'react';\nimport { WithTranslation, withTranslation } from 'react-i18next';\nimport _ from 'lodash';\nimport {\n formatAddress,\n isCoreAddress,\n isCoreContractAddress,\n isZeroAddress,\n convertCheckSum,\n} from '../../utils/address';\nimport { useGlobalData, getTranslations } from '../../store';\nimport { LOCALSTORAGE_KEYS_MAP } from '../../utils/constants';\nimport { getLabelInfo } from './label';\nimport { useENS } from '../../utils/hooks/useENS';\n\nimport { RenderAddress } from './addressView';\nimport {\n ContractCreatedAddress,\n CoreHexAddress,\n InvalidAddress,\n ContractAddress,\n MyAddress,\n PosAddress,\n} from './addressSwitcher';\nimport { GlobalDataType } from 'src/store/types';\nimport { CoreAddressContainerProps } from './types';\n\nconst parseProps = (\n props: CoreAddressContainerProps & WithTranslation,\n globalData: GlobalDataType,\n) => {\n const {\n alias,\n ensInfo,\n t,\n showAddressLabel,\n showNametag,\n nametagInfo,\n showENSLabel,\n } = props;\n const value: string = props.value || '';\n const cfxAddress = formatAddress(value, 'base32');\n\n let ENSMap = ensInfo || {};\n\n const translations = getTranslations();\n\n let aliasLabel = alias;\n if (!alias && isZeroAddress(cfxAddress)) {\n aliasLabel = t(translations.general.zeroAddress);\n }\n\n let prefixIcon: React.ReactNode = null;\n // official name tag\n let officalNametag: React.ReactNode = null;\n // private name tag\n let addressLabel: React.ReactNode = null;\n // ens name tag\n let ENSLabel: React.ReactNode = null;\n // global ens name tag\n const gENSLabel = cfxAddress && ENSMap[cfxAddress]?.name;\n\n if (cfxAddress && showAddressLabel) {\n // global private name tag\n const addressLabels = globalData?.[LOCALSTORAGE_KEYS_MAP.addressLabel];\n const gAddressLabel = addressLabels?.[cfxAddress];\n\n if (gAddressLabel) {\n const { label } = getLabelInfo(gAddressLabel, 'tag');\n addressLabel = label;\n }\n }\n\n if (cfxAddress && showNametag) {\n const nametags = nametagInfo?.[cfxAddress];\n\n if (nametags) {\n const nametag = nametags?.nametag ?? '';\n const { label } = getLabelInfo(nametag, 'nametag');\n officalNametag = label;\n }\n }\n\n if (showENSLabel && gENSLabel) {\n const { label, icon } = getLabelInfo(gENSLabel, 'ens');\n ENSLabel = label;\n prefixIcon = icon;\n }\n\n return {\n alias: aliasLabel,\n prefix: prefixIcon,\n nametag: officalNametag,\n addressLabel,\n ENSLabel,\n cfxAddress,\n };\n};\n\nexport const CoreAddressContainer = withTranslation()(\n memo((props: CoreAddressContainerProps & WithTranslation) => {\n const { globalData } = useGlobalData();\n\n // If the interface returns Ens content, there is no need to obtain it separately, or disable the display of Ens content (in most cases on the list page).\n const unnecessaryEns = props.ensInfo || props.showENSLabel === false;\n const { ens } = useENS(unnecessaryEns ? null : props.value);\n\n // If a txn receipt has no 'to' address or 'contractCreated', show -- for temp\n if (!props.value && !props.contractCreated) {\n return <>--</>;\n }\n\n const defaultProps = {\n isFull: false,\n isFullNameTag: false,\n link: true,\n isMe: false,\n showIcon: true,\n verify: false,\n showAddressLabel: true,\n showENSLabel: true,\n showNametag: true,\n ensInfo: ens,\n };\n\n const mergeDefaultProps = _.assign({}, defaultProps, props);\n\n const mergeParseProps = _.merge(\n {},\n mergeDefaultProps,\n parseProps(mergeDefaultProps, globalData),\n );\n\n if (mergeParseProps.isPosAddress) {\n return PosAddress(mergeParseProps);\n }\n\n if (!mergeParseProps.value && mergeParseProps.contractCreated) {\n return ContractCreatedAddress({\n ...mergeParseProps,\n outputType: 'base32',\n });\n }\n\n if (mergeParseProps.isEspaceAddress) {\n return CoreHexAddress(mergeParseProps);\n }\n\n if (!isCoreAddress(mergeParseProps.value)) {\n return InvalidAddress(mergeParseProps);\n }\n\n if (isCoreContractAddress(mergeParseProps.cfxAddress)) {\n return ContractAddress(mergeParseProps);\n }\n\n if (mergeParseProps.isMe) {\n return MyAddress(mergeParseProps);\n }\n\n return RenderAddress(mergeParseProps);\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AACrB,SAA0B,uBAAuB;AACjD,OAAO,OAAO;AA2GD;AAlFb,IAAM,aAAa,CACjB,OACA,eACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AA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