@chayns-components/gallery 5.0.0-beta.117 → 5.0.0-beta.1170
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/README.md +4 -15
- package/lib/cjs/components/Gallery.js +316 -0
- package/lib/cjs/components/Gallery.js.map +1 -0
- package/lib/cjs/components/Gallery.styles.js +91 -0
- package/lib/cjs/components/Gallery.styles.js.map +1 -0
- package/lib/cjs/components/add-file/AddFile.js +32 -0
- package/lib/cjs/components/add-file/AddFile.js.map +1 -0
- package/lib/cjs/components/add-file/AddFile.styles.js +23 -0
- package/lib/cjs/components/add-file/AddFile.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/GalleryItem.js +44 -0
- package/lib/cjs/components/gallery-item/GalleryItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js +51 -0
- package/lib/cjs/components/gallery-item/GalleryItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js +52 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js +62 -0
- package/lib/cjs/components/gallery-item/media-item/MediaItem.styles.js.map +1 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js +45 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.js.map +1 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js +43 -0
- package/lib/cjs/components/gallery-item/preview-item/PreviewItem.styles.js.map +1 -0
- package/lib/cjs/index.js +21 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/gallery.js +12 -0
- package/lib/cjs/types/gallery.js.map +1 -0
- package/lib/cjs/utils/file.js +51 -0
- package/lib/cjs/utils/file.js.map +1 -0
- package/lib/esm/components/Gallery.js +303 -0
- package/lib/esm/components/Gallery.js.map +1 -0
- package/lib/esm/components/Gallery.styles.js +84 -0
- package/lib/esm/components/Gallery.styles.js.map +1 -0
- package/lib/esm/components/add-file/AddFile.js +25 -0
- package/lib/esm/components/add-file/AddFile.js.map +1 -0
- package/lib/esm/components/add-file/AddFile.styles.js +16 -0
- package/lib/esm/components/add-file/AddFile.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/GalleryItem.js +36 -0
- package/lib/esm/components/gallery-item/GalleryItem.js.map +1 -0
- package/lib/esm/components/gallery-item/GalleryItem.styles.js +44 -0
- package/lib/esm/components/gallery-item/GalleryItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.js +42 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.js.map +1 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js +55 -0
- package/lib/esm/components/gallery-item/media-item/MediaItem.styles.js.map +1 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js +38 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.js.map +1 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.styles.js +36 -0
- package/lib/esm/components/gallery-item/preview-item/PreviewItem.styles.js.map +1 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/gallery.js +6 -0
- package/lib/esm/types/gallery.js.map +1 -0
- package/lib/esm/utils/file.js +41 -0
- package/lib/esm/utils/file.js.map +1 -0
- package/lib/types/components/Gallery.d.ts +47 -0
- package/lib/types/components/Gallery.styles.d.ts +10 -0
- package/lib/types/components/add-file/AddFile.d.ts +9 -0
- package/lib/types/components/add-file/AddFile.styles.d.ts +4 -0
- package/lib/{components → types/components}/gallery-item/GalleryItem.d.ts +10 -6
- package/lib/types/components/gallery-item/GalleryItem.styles.d.ts +5 -0
- package/lib/types/components/gallery-item/media-item/MediaItem.d.ts +22 -0
- package/lib/types/components/gallery-item/media-item/MediaItem.styles.d.ts +16 -0
- package/lib/types/components/gallery-item/preview-item/PreviewItem.d.ts +14 -0
- package/lib/types/components/gallery-item/preview-item/PreviewItem.styles.d.ts +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/types/gallery.d.ts +4 -0
- package/lib/types/utils/file.d.ts +17 -0
- package/package.json +48 -29
- package/lib/api/image/imageUpload.d.ts +0 -14
- package/lib/api/image/imageUpload.js +0 -60
- package/lib/api/image/imageUpload.js.map +0 -1
- package/lib/api/video/videoUpload.d.ts +0 -16
- package/lib/api/video/videoUpload.js +0 -35
- package/lib/api/video/videoUpload.js.map +0 -1
- package/lib/components/Gallery.d.ts +0 -34
- package/lib/components/Gallery.js +0 -162
- package/lib/components/Gallery.js.map +0 -1
- package/lib/components/Gallery.styles.d.ts +0 -6
- package/lib/components/Gallery.styles.js +0 -40
- package/lib/components/Gallery.styles.js.map +0 -1
- package/lib/components/add-file/AddFile.d.ts +0 -26
- package/lib/components/add-file/AddFile.js +0 -82
- package/lib/components/add-file/AddFile.js.map +0 -1
- package/lib/components/add-file/AddFile.styles.d.ts +0 -4
- package/lib/components/add-file/AddFile.styles.js +0 -31
- package/lib/components/add-file/AddFile.styles.js.map +0 -1
- package/lib/components/gallery-item/GalleryItem.js +0 -60
- package/lib/components/gallery-item/GalleryItem.js.map +0 -1
- package/lib/components/gallery-item/GalleryItem.styles.d.ts +0 -17
- package/lib/components/gallery-item/GalleryItem.styles.js +0 -107
- package/lib/components/gallery-item/GalleryItem.styles.js.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -28
- package/lib/index.js.map +0 -1
- package/lib/types/files.d.ts +0 -20
- package/lib/types/files.js +0 -6
- package/lib/types/files.js.map +0 -1
- package/lib/utils/file.d.ts +0 -30
- package/lib/utils/file.js +0 -130
- package/lib/utils/file.js.map +0 -1
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = require("@chayns-components/core");
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _GalleryItem = require("./GalleryItem.styles");
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
-
const GalleryItem = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
uploadedFile,
|
|
15
|
-
handleDeleteFile,
|
|
16
|
-
isEditMode,
|
|
17
|
-
ratio,
|
|
18
|
-
remainingItemsLength
|
|
19
|
-
} = _ref;
|
|
20
|
-
/**
|
|
21
|
-
* This function opens a selected file
|
|
22
|
-
*/
|
|
23
|
-
const openSelectedFile = (0, _react.useCallback)(file => {
|
|
24
|
-
if ('thumbnailUrl' in file) {
|
|
25
|
-
// @ts-expect-error: Type is correct here
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
27
|
-
void chayns.openVideo(file.url);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// @ts-expect-error: Type is correct here
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
33
|
-
void chayns.openImage([file.url], 0);
|
|
34
|
-
}, []);
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItem, null, isEditMode && /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemDeleteButton, {
|
|
36
|
-
onClick: () => handleDeleteFile(uploadedFile.url)
|
|
37
|
-
}, /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
38
|
-
size: 20,
|
|
39
|
-
icons: ['ts-wrong']
|
|
40
|
-
})), 'thumbnailUrl' in uploadedFile ? /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemVideoWrapper, {
|
|
41
|
-
onClick: () => openSelectedFile(uploadedFile)
|
|
42
|
-
}, /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemPlayIcon, null, /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
43
|
-
size: 30,
|
|
44
|
-
icons: ['fa fa-play']
|
|
45
|
-
})), /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemVideo, {
|
|
46
|
-
ratio: ratio
|
|
47
|
-
}, /*#__PURE__*/_react.default.createElement("source", {
|
|
48
|
-
src: uploadedFile.url,
|
|
49
|
-
type: "video/mp4"
|
|
50
|
-
}))) : /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemImage, {
|
|
51
|
-
ratio: ratio,
|
|
52
|
-
onClick: () => openSelectedFile(uploadedFile),
|
|
53
|
-
draggable: false,
|
|
54
|
-
src: uploadedFile.url
|
|
55
|
-
}), remainingItemsLength && /*#__PURE__*/_react.default.createElement(_GalleryItem.StyledGalleryItemMoreItemsIndicator, null, /*#__PURE__*/_react.default.createElement("p", null, `+ ${remainingItemsLength - 3}`)));
|
|
56
|
-
};
|
|
57
|
-
GalleryItem.displayName = 'GalleryItem';
|
|
58
|
-
var _default = GalleryItem;
|
|
59
|
-
exports.default = _default;
|
|
60
|
-
//# sourceMappingURL=GalleryItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryItem.js","names":["_core","require","_react","_interopRequireWildcard","_GalleryItem","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","GalleryItem","_ref","uploadedFile","handleDeleteFile","isEditMode","ratio","remainingItemsLength","openSelectedFile","useCallback","file","chayns","openVideo","url","openImage","createElement","StyledGalleryItem","StyledGalleryItemDeleteButton","onClick","Icon","size","icons","StyledGalleryItemVideoWrapper","StyledGalleryItemPlayIcon","StyledGalleryItemVideo","src","type","StyledGalleryItemImage","draggable","StyledGalleryItemMoreItemsIndicator","displayName","_default","exports"],"sources":["../../../src/components/gallery-item/GalleryItem.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport React, { FC, useCallback } from 'react';\nimport type { UploadedFile } from '../../types/files';\nimport {\n StyledGalleryItem,\n StyledGalleryItemDeleteButton,\n StyledGalleryItemImage,\n StyledGalleryItemMoreItemsIndicator,\n StyledGalleryItemPlayIcon,\n StyledGalleryItemVideo,\n StyledGalleryItemVideoWrapper,\n} from './GalleryItem.styles';\n\nexport type GalleryItemProps = {\n /**\n * Images and videos which should be displayed\n */\n uploadedFile: UploadedFile;\n /**\n * Whether images and videos can be edited\n */\n isEditMode: boolean;\n /**\n * Ratio of the images and videos\n */\n ratio: number;\n /**\n * Function to be executed wehen a file is deleted\n */\n handleDeleteFile: (url: string) => void;\n /**\n * Length of the uploaded files\n */\n remainingItemsLength?: number;\n};\n\nconst GalleryItem: FC<GalleryItemProps> = ({\n uploadedFile,\n handleDeleteFile,\n isEditMode,\n ratio,\n remainingItemsLength,\n}) => {\n /**\n * This function opens a selected file\n */\n const openSelectedFile = useCallback((file: UploadedFile) => {\n if ('thumbnailUrl' in file) {\n // @ts-expect-error: Type is correct here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n void chayns.openVideo(file.url);\n\n return;\n }\n\n // @ts-expect-error: Type is correct here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n void chayns.openImage([file.url], 0);\n }, []);\n\n return (\n <StyledGalleryItem>\n {isEditMode && (\n <StyledGalleryItemDeleteButton onClick={() => handleDeleteFile(uploadedFile.url)}>\n <Icon size={20} icons={['ts-wrong']} />\n </StyledGalleryItemDeleteButton>\n )}\n {'thumbnailUrl' in uploadedFile ? (\n <StyledGalleryItemVideoWrapper onClick={() => openSelectedFile(uploadedFile)}>\n <StyledGalleryItemPlayIcon>\n <Icon size={30} icons={['fa fa-play']} />\n </StyledGalleryItemPlayIcon>\n <StyledGalleryItemVideo ratio={ratio}>\n <source src={uploadedFile.url} type=\"video/mp4\" />\n </StyledGalleryItemVideo>\n </StyledGalleryItemVideoWrapper>\n ) : (\n <StyledGalleryItemImage\n ratio={ratio}\n onClick={() => openSelectedFile(uploadedFile)}\n draggable={false}\n src={uploadedFile.url}\n />\n )}\n {remainingItemsLength && (\n <StyledGalleryItemMoreItemsIndicator>\n <p>{`+ ${remainingItemsLength - 3}`}</p>\n </StyledGalleryItemMoreItemsIndicator>\n )}\n </StyledGalleryItem>\n );\n};\n\nGalleryItem.displayName = 'GalleryItem';\n\nexport default GalleryItem;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAQ8B,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAA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IAC9CyB,SAAS,EAAE,KAAM;IACjBH,GAAG,EAAEtB,YAAY,CAACU;EAAI,EAE7B,EACAN,oBAAoB,iBACjB/B,MAAA,CAAAU,OAAA,CAAA6B,aAAA,CAACrC,YAAA,CAAAmD,mCAAmC,qBAChCrD,MAAA,CAAAU,OAAA,CAAA6B,aAAA,YAAK,KAAIR,oBAAoB,GAAG,CAAE,EAAC,CAAK,CAE/C,CACe;AAE5B,CAAC;AAEDN,WAAW,CAAC6B,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAEzB9B,WAAW;AAAA+B,OAAA,CAAA9C,OAAA,GAAA6C,QAAA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const StyledGalleryItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const StyledGalleryItemDeleteButton: import("styled-components").StyledComponent<"button", any, {
|
|
3
|
-
theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
4
|
-
}, never>;
|
|
5
|
-
export declare const StyledGalleryItemVideoWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
-
export declare const StyledGalleryItemImage: import("styled-components").StyledComponent<"img", any, {
|
|
7
|
-
ratio: number;
|
|
8
|
-
} & {
|
|
9
|
-
theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
10
|
-
}, never>;
|
|
11
|
-
export declare const StyledGalleryItemVideo: import("styled-components").StyledComponent<"video", any, {
|
|
12
|
-
ratio: number;
|
|
13
|
-
} & {
|
|
14
|
-
theme: import("@chayns-components/core/lib/components/color-scheme-provider/ColorSchemeProvider").Theme;
|
|
15
|
-
}, never>;
|
|
16
|
-
export declare const StyledGalleryItemPlayIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
|
-
export declare const StyledGalleryItemMoreItemsIndicator: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledGalleryItemVideoWrapper = exports.StyledGalleryItemVideo = exports.StyledGalleryItemPlayIcon = exports.StyledGalleryItemMoreItemsIndicator = exports.StyledGalleryItemImage = exports.StyledGalleryItemDeleteButton = exports.StyledGalleryItem = void 0;
|
|
7
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
const StyledGalleryItem = _styledComponents.default.div`
|
|
10
|
-
display: flex;
|
|
11
|
-
position: relative;
|
|
12
|
-
`;
|
|
13
|
-
exports.StyledGalleryItem = StyledGalleryItem;
|
|
14
|
-
const StyledGalleryItemDeleteButton = _styledComponents.default.button`
|
|
15
|
-
background-color: rgba(
|
|
16
|
-
${_ref => {
|
|
17
|
-
let {
|
|
18
|
-
theme
|
|
19
|
-
} = _ref;
|
|
20
|
-
return theme['000-rgb'];
|
|
21
|
-
}},
|
|
22
|
-
0.75
|
|
23
|
-
);
|
|
24
|
-
box-shadow: 0 0 0 1px
|
|
25
|
-
rgba(${_ref2 => {
|
|
26
|
-
let {
|
|
27
|
-
theme
|
|
28
|
-
} = _ref2;
|
|
29
|
-
return theme['009-rgb'];
|
|
30
|
-
}}, 0.08) inset;
|
|
31
|
-
position: absolute;
|
|
32
|
-
top: 0;
|
|
33
|
-
right: 0;
|
|
34
|
-
z-index: 2;
|
|
35
|
-
height: 30px;
|
|
36
|
-
width: 30px;
|
|
37
|
-
display: flex;
|
|
38
|
-
justify-content: center;
|
|
39
|
-
align-items: center;
|
|
40
|
-
`;
|
|
41
|
-
exports.StyledGalleryItemDeleteButton = StyledGalleryItemDeleteButton;
|
|
42
|
-
const StyledGalleryItemVideoWrapper = _styledComponents.default.div``;
|
|
43
|
-
exports.StyledGalleryItemVideoWrapper = StyledGalleryItemVideoWrapper;
|
|
44
|
-
const StyledGalleryItemImage = _styledComponents.default.img`
|
|
45
|
-
background-color: ${_ref3 => {
|
|
46
|
-
let {
|
|
47
|
-
theme
|
|
48
|
-
} = _ref3;
|
|
49
|
-
return theme['101'];
|
|
50
|
-
}};
|
|
51
|
-
box-shadow: 0 0 0 1px
|
|
52
|
-
rgba(${_ref4 => {
|
|
53
|
-
let {
|
|
54
|
-
theme
|
|
55
|
-
} = _ref4;
|
|
56
|
-
return theme['009-rgb'];
|
|
57
|
-
}}, 0.08) inset;
|
|
58
|
-
z-index: 1;
|
|
59
|
-
width: 100%;
|
|
60
|
-
aspect-ratio: ${props => props.ratio};
|
|
61
|
-
object-fit: cover;
|
|
62
|
-
`;
|
|
63
|
-
exports.StyledGalleryItemImage = StyledGalleryItemImage;
|
|
64
|
-
const StyledGalleryItemVideo = _styledComponents.default.video`
|
|
65
|
-
background-color: ${_ref5 => {
|
|
66
|
-
let {
|
|
67
|
-
theme
|
|
68
|
-
} = _ref5;
|
|
69
|
-
return theme['101'];
|
|
70
|
-
}};
|
|
71
|
-
box-shadow: 0 0 0 1px
|
|
72
|
-
rgba(${_ref6 => {
|
|
73
|
-
let {
|
|
74
|
-
theme
|
|
75
|
-
} = _ref6;
|
|
76
|
-
return theme['009-rgb'];
|
|
77
|
-
}}, 0.08) inset;
|
|
78
|
-
width: 100%;
|
|
79
|
-
aspect-ratio: ${props => props.ratio};
|
|
80
|
-
object-fit: cover;
|
|
81
|
-
`;
|
|
82
|
-
exports.StyledGalleryItemVideo = StyledGalleryItemVideo;
|
|
83
|
-
const StyledGalleryItemPlayIcon = _styledComponents.default.div`
|
|
84
|
-
position: absolute;
|
|
85
|
-
z-index: 2;
|
|
86
|
-
top: 50%;
|
|
87
|
-
left: 50%;
|
|
88
|
-
transform: translate(-50%, -50%);
|
|
89
|
-
`;
|
|
90
|
-
exports.StyledGalleryItemPlayIcon = StyledGalleryItemPlayIcon;
|
|
91
|
-
const StyledGalleryItemMoreItemsIndicator = _styledComponents.default.div`
|
|
92
|
-
position: absolute;
|
|
93
|
-
z-index: 2;
|
|
94
|
-
height: 100%;
|
|
95
|
-
width: 100%;
|
|
96
|
-
display: flex;
|
|
97
|
-
justify-content: center;
|
|
98
|
-
align-items: center;
|
|
99
|
-
backdrop-filter: brightness(40%);
|
|
100
|
-
|
|
101
|
-
p {
|
|
102
|
-
font-size: 40px;
|
|
103
|
-
color: white;
|
|
104
|
-
}
|
|
105
|
-
`;
|
|
106
|
-
exports.StyledGalleryItemMoreItemsIndicator = StyledGalleryItemMoreItemsIndicator;
|
|
107
|
-
//# sourceMappingURL=GalleryItem.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryItem.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledGalleryItem","styled","div","exports","StyledGalleryItemDeleteButton","button","_ref","theme","_ref2","StyledGalleryItemVideoWrapper","StyledGalleryItemImage","img","_ref3","_ref4","props","ratio","StyledGalleryItemVideo","video","_ref5","_ref6","StyledGalleryItemPlayIcon","StyledGalleryItemMoreItemsIndicator"],"sources":["../../../src/components/gallery-item/GalleryItem.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledGalleryItem = styled.div`\n display: flex;\n position: relative;\n`;\n\ntype StyledGalleryItemDeleteButtonProps = WithTheme<unknown>;\n\nexport const StyledGalleryItemDeleteButton = styled.button<StyledGalleryItemDeleteButtonProps>`\n background-color: rgba(\n ${({ theme }: StyledGalleryItemDeleteButtonProps) => theme['000-rgb']},\n 0.75\n );\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledGalleryItemDeleteButtonProps) => theme['009-rgb']}, 0.08) inset;\n position: absolute;\n top: 0;\n right: 0;\n z-index: 2;\n height: 30px;\n width: 30px;\n display: flex;\n justify-content: center;\n align-items: center;\n`;\n\nexport const StyledGalleryItemVideoWrapper = styled.div``;\n\ntype StyledGalleryItemVideoProps = WithTheme<{\n ratio: number;\n}>;\n\ntype StyledGalleryItemImageProps = WithTheme<{\n ratio: number;\n}>;\n\nexport const StyledGalleryItemImage = styled.img<StyledGalleryItemImageProps>`\n background-color: ${({ theme }: StyledGalleryItemImageProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledGalleryItemImageProps) => theme['009-rgb']}, 0.08) inset;\n z-index: 1;\n width: 100%;\n aspect-ratio: ${(props) => props.ratio};\n object-fit: cover;\n`;\n\nexport const StyledGalleryItemVideo = styled.video<StyledGalleryItemVideoProps>`\n background-color: ${({ theme }: StyledGalleryItemVideoProps) => theme['101']};\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledGalleryItemVideoProps) => theme['009-rgb']}, 0.08) inset;\n width: 100%;\n aspect-ratio: ${(props) => props.ratio};\n object-fit: cover;\n`;\n\nexport const StyledGalleryItemPlayIcon = styled.div`\n position: absolute;\n z-index: 2;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n\nexport const StyledGalleryItemMoreItemsIndicator = styled.div`\n position: absolute;\n z-index: 2;\n height: 100%;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n backdrop-filter: brightness(40%);\n\n p {\n font-size: 40px;\n color: white;\n }\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,iBAAiB,GAAGC,yBAAM,CAACC,GAAI;AAC5C;AACA;AACA,CAAC;AAACC,OAAA,CAAAH,iBAAA,GAAAA,iBAAA;AAIK,MAAMI,6BAA6B,GAAGH,yBAAM,CAACI,MAA2C;AAC/F;AACA,UAAUC,IAAA;EAAA,IAAC;IAAEC;EAA0C,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAAC,SAAS,CAAC;AAAA,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CAAAiB,yBAAA,GAAAA,yBAAA;AAEK,MAAMC,mCAAmC,GAAGpB,yBAAM,CAACC,GAAI;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAACC,OAAA,CAAAkB,mCAAA,GAAAA,mCAAA"}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Gallery", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Gallery.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "imageUpload", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _imageUpload.imageUpload;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "videoUpload", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _videoUpload.videoUpload;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _imageUpload = require("./api/image/imageUpload");
|
|
25
|
-
var _videoUpload = require("./api/video/videoUpload");
|
|
26
|
-
var _Gallery = _interopRequireDefault(require("./components/Gallery"));
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_imageUpload","require","_videoUpload","_Gallery","_interopRequireDefault","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { imageUpload } from './api/image/imageUpload';\nexport { videoUpload } from './api/video/videoUpload';\nexport { default as Gallery } from './components/Gallery';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA0D,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|
package/lib/types/files.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface Video {
|
|
2
|
-
id: number;
|
|
3
|
-
originalVideoQuality?: string;
|
|
4
|
-
thumbnailUrl: string;
|
|
5
|
-
url: string;
|
|
6
|
-
ratio?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface Image {
|
|
9
|
-
id?: string;
|
|
10
|
-
url: string;
|
|
11
|
-
meta?: Meta;
|
|
12
|
-
ratio?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface Meta {
|
|
15
|
-
preview: string;
|
|
16
|
-
width: string;
|
|
17
|
-
height: string;
|
|
18
|
-
}
|
|
19
|
-
export type ExternalFile = Omit<Video, 'originalVideoQuality'> | Image;
|
|
20
|
-
export type UploadedFile = Video | Image;
|
package/lib/types/files.js
DELETED
package/lib/types/files.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","names":[],"sources":["../../src/types/files.ts"],"sourcesContent":["export interface Video {\n id: number;\n originalVideoQuality?: string;\n thumbnailUrl: string;\n url: string;\n ratio?: number;\n}\n\nexport interface Image {\n id?: string;\n url: string;\n meta?: Meta;\n ratio?: number;\n}\n\nexport interface Meta {\n preview: string;\n width: string;\n height: string;\n}\n\nexport type ExternalFile = Omit<Video, 'originalVideoQuality'> | Image;\n\nexport type UploadedFile = Video | Image;\n"],"mappings":""}
|
package/lib/utils/file.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Meta, UploadedFile } from '../types/files';
|
|
2
|
-
interface SelectFilesOptions {
|
|
3
|
-
type: string;
|
|
4
|
-
multiple: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const selectFiles: ({ type, multiple }: SelectFilesOptions) => Promise<null | FileList>;
|
|
7
|
-
export declare const convertFileListToArray: (fileList: FileList) => File[];
|
|
8
|
-
interface FilterDuplicateFilesOptions {
|
|
9
|
-
oldFiles: UploadedFile[];
|
|
10
|
-
newFiles: UploadedFile[];
|
|
11
|
-
}
|
|
12
|
-
export declare const filterDuplicateFiles: ({ oldFiles, newFiles }: FilterDuplicateFilesOptions) => {
|
|
13
|
-
filteredFiles: UploadedFile[];
|
|
14
|
-
newUniqueFiles: UploadedFile[];
|
|
15
|
-
};
|
|
16
|
-
export interface UploadedImage {
|
|
17
|
-
key: string;
|
|
18
|
-
base: string;
|
|
19
|
-
meta?: Meta;
|
|
20
|
-
}
|
|
21
|
-
interface UploadFilesOptions {
|
|
22
|
-
filesToUpload: File[];
|
|
23
|
-
accessToken: string;
|
|
24
|
-
personId: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Upload files
|
|
28
|
-
*/
|
|
29
|
-
export declare const uploadFiles: ({ filesToUpload, personId, accessToken, }: UploadFilesOptions) => Promise<UploadedFile[]>;
|
|
30
|
-
export {};
|
package/lib/utils/file.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.uploadFiles = exports.selectFiles = exports.filterDuplicateFiles = exports.convertFileListToArray = void 0;
|
|
7
|
-
var _imageUpload = require("../api/image/imageUpload");
|
|
8
|
-
var _videoUpload = require("../api/video/videoUpload");
|
|
9
|
-
const selectFiles = _ref => {
|
|
10
|
-
let {
|
|
11
|
-
type,
|
|
12
|
-
multiple
|
|
13
|
-
} = _ref;
|
|
14
|
-
return new Promise(resolve => {
|
|
15
|
-
const input = document.createElement('input');
|
|
16
|
-
input.type = 'file';
|
|
17
|
-
if (type !== '*/*' && type) {
|
|
18
|
-
input.accept = type;
|
|
19
|
-
}
|
|
20
|
-
if (multiple) {
|
|
21
|
-
input.multiple = true;
|
|
22
|
-
}
|
|
23
|
-
input.style.visibility = 'none';
|
|
24
|
-
input.style.width = '0';
|
|
25
|
-
input.style.height = '0';
|
|
26
|
-
input.style.display = 'none';
|
|
27
|
-
document.body.appendChild(input);
|
|
28
|
-
input.addEventListener('change', event => {
|
|
29
|
-
document.body.removeChild(input);
|
|
30
|
-
const target = event.target;
|
|
31
|
-
const {
|
|
32
|
-
files
|
|
33
|
-
} = target;
|
|
34
|
-
resolve(files);
|
|
35
|
-
});
|
|
36
|
-
input.click();
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
exports.selectFiles = selectFiles;
|
|
40
|
-
const convertFileListToArray = fileList => {
|
|
41
|
-
const filesArray = [];
|
|
42
|
-
for (let i = 0; i < fileList.length; i++) {
|
|
43
|
-
const file = fileList.item(i);
|
|
44
|
-
if (file) {
|
|
45
|
-
filesArray.push(file);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return filesArray;
|
|
49
|
-
};
|
|
50
|
-
exports.convertFileListToArray = convertFileListToArray;
|
|
51
|
-
const filterDuplicateFiles = _ref2 => {
|
|
52
|
-
let {
|
|
53
|
-
oldFiles,
|
|
54
|
-
newFiles
|
|
55
|
-
} = _ref2;
|
|
56
|
-
const seenKeys = new Set();
|
|
57
|
-
const filteredFiles = [];
|
|
58
|
-
oldFiles.forEach(file => {
|
|
59
|
-
var _file$id$toString, _file$id;
|
|
60
|
-
seenKeys.add((_file$id$toString = (_file$id = file.id) === null || _file$id === void 0 ? void 0 : _file$id.toString()) !== null && _file$id$toString !== void 0 ? _file$id$toString : file.url);
|
|
61
|
-
filteredFiles.push(file);
|
|
62
|
-
});
|
|
63
|
-
const newUniqueFiles = [];
|
|
64
|
-
newFiles.forEach(file => {
|
|
65
|
-
var _file$id$toString2, _file$id2;
|
|
66
|
-
const key = (_file$id$toString2 = (_file$id2 = file.id) === null || _file$id2 === void 0 ? void 0 : _file$id2.toString()) !== null && _file$id$toString2 !== void 0 ? _file$id$toString2 : file.url;
|
|
67
|
-
const oldFile = oldFiles.find(f => f.id === file.id);
|
|
68
|
-
const alreadyAdded = newUniqueFiles.find(f => f.id === file.id);
|
|
69
|
-
if (!oldFile && !alreadyAdded) {
|
|
70
|
-
seenKeys.add(key);
|
|
71
|
-
newUniqueFiles.push(file);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
filteredFiles,
|
|
76
|
-
newUniqueFiles
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.filterDuplicateFiles = filterDuplicateFiles;
|
|
80
|
-
/**
|
|
81
|
-
* Upload files
|
|
82
|
-
*/
|
|
83
|
-
const uploadFiles = async _ref3 => {
|
|
84
|
-
let {
|
|
85
|
-
filesToUpload,
|
|
86
|
-
personId,
|
|
87
|
-
accessToken
|
|
88
|
-
} = _ref3;
|
|
89
|
-
if (!filesToUpload) {
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
const videos = filesToUpload.filter(_ref4 => {
|
|
93
|
-
let {
|
|
94
|
-
type
|
|
95
|
-
} = _ref4;
|
|
96
|
-
return type.includes('video/');
|
|
97
|
-
});
|
|
98
|
-
const images = filesToUpload.filter(_ref5 => {
|
|
99
|
-
let {
|
|
100
|
-
type
|
|
101
|
-
} = _ref5;
|
|
102
|
-
return type.includes('image/');
|
|
103
|
-
});
|
|
104
|
-
let newUploadedFiles = [];
|
|
105
|
-
|
|
106
|
-
// Upload videos
|
|
107
|
-
const videoUploadPromises = videos.map(video => (0, _videoUpload.videoUpload)({
|
|
108
|
-
accessToken,
|
|
109
|
-
file: video
|
|
110
|
-
}));
|
|
111
|
-
newUploadedFiles = newUploadedFiles.concat(await Promise.all(videoUploadPromises));
|
|
112
|
-
newUploadedFiles = newUploadedFiles.flat();
|
|
113
|
-
|
|
114
|
-
// Upload images
|
|
115
|
-
const imageUploadPromises = images.map(image => (0, _imageUpload.imageUpload)({
|
|
116
|
-
accessToken,
|
|
117
|
-
file: image,
|
|
118
|
-
personId
|
|
119
|
-
}));
|
|
120
|
-
const uploadedImages = await Promise.all(imageUploadPromises);
|
|
121
|
-
const newImages = uploadedImages.map(file => ({
|
|
122
|
-
url: `${file.base}/${file.key}`,
|
|
123
|
-
id: file.key,
|
|
124
|
-
meta: file.meta
|
|
125
|
-
}));
|
|
126
|
-
newUploadedFiles = newUploadedFiles.concat(newImages);
|
|
127
|
-
return newUploadedFiles;
|
|
128
|
-
};
|
|
129
|
-
exports.uploadFiles = uploadFiles;
|
|
130
|
-
//# sourceMappingURL=file.js.map
|
package/lib/utils/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":["_imageUpload","require","_videoUpload","selectFiles","_ref","type","multiple","Promise","resolve","input","document","createElement","accept","style","visibility","width","height","display","body","appendChild","addEventListener","event","removeChild","target","files","click","exports","convertFileListToArray","fileList","filesArray","i","length","file","item","push","filterDuplicateFiles","_ref2","oldFiles","newFiles","seenKeys","Set","filteredFiles","forEach","_file$id$toString","_file$id","add","id","toString","url","newUniqueFiles","_file$id$toString2","_file$id2","key","oldFile","find","f","alreadyAdded","uploadFiles","_ref3","filesToUpload","personId","accessToken","videos","filter","_ref4","includes","images","_ref5","newUploadedFiles","videoUploadPromises","map","video","videoUpload","concat","all","flat","imageUploadPromises","image","imageUpload","uploadedImages","newImages","base","meta"],"sources":["../../src/utils/file.ts"],"sourcesContent":["import { imageUpload } from '../api/image/imageUpload';\nimport { videoUpload } from '../api/video/videoUpload';\nimport type { Meta, UploadedFile, Video } from '../types/files';\n\ninterface SelectFilesOptions {\n type: string;\n multiple: boolean;\n}\n\nexport const selectFiles = ({ type, multiple }: SelectFilesOptions): Promise<null | FileList> =>\n new Promise((resolve) => {\n const input = document.createElement('input');\n input.type = 'file';\n\n if (type !== '*/*' && type) {\n input.accept = type;\n }\n\n if (multiple) {\n input.multiple = true;\n }\n\n input.style.visibility = 'none';\n input.style.width = '0';\n input.style.height = '0';\n input.style.display = 'none';\n\n document.body.appendChild(input);\n\n input.addEventListener('change', (event) => {\n document.body.removeChild(input);\n\n const target = event.target as HTMLInputElement;\n const { files } = target;\n\n resolve(files);\n });\n\n input.click();\n });\n\nexport const convertFileListToArray = (fileList: FileList): File[] => {\n const filesArray = [];\n for (let i = 0; i < fileList.length; i++) {\n const file = fileList.item(i);\n\n if (file) {\n filesArray.push(file);\n }\n }\n\n return filesArray;\n};\n\ninterface FilterDuplicateFilesOptions {\n oldFiles: UploadedFile[];\n newFiles: UploadedFile[];\n}\n\nexport const filterDuplicateFiles = ({ oldFiles, newFiles }: FilterDuplicateFilesOptions) => {\n const seenKeys = new Set<string>();\n const filteredFiles: UploadedFile[] = [];\n\n oldFiles.forEach((file) => {\n seenKeys.add(file.id?.toString() ?? file.url);\n filteredFiles.push(file);\n });\n\n const newUniqueFiles: UploadedFile[] = [];\n\n newFiles.forEach((file) => {\n const key = file.id?.toString() ?? file.url;\n\n const oldFile = oldFiles.find((f) => f.id === file.id);\n\n const alreadyAdded = newUniqueFiles.find((f) => f.id === file.id);\n\n if (!oldFile && !alreadyAdded) {\n seenKeys.add(key);\n newUniqueFiles.push(file);\n }\n });\n\n return { filteredFiles, newUniqueFiles };\n};\n\nexport interface UploadedImage {\n key: string;\n base: string;\n meta?: Meta;\n}\n\ninterface UploadFilesOptions {\n filesToUpload: File[];\n accessToken: string;\n personId: string;\n}\n\n/**\n * Upload files\n */\nexport const uploadFiles = async ({\n filesToUpload,\n personId,\n accessToken,\n}: UploadFilesOptions): Promise<UploadedFile[]> => {\n if (!filesToUpload) {\n return [];\n }\n\n const videos = filesToUpload.filter(({ type }) => type.includes('video/'));\n const images = filesToUpload.filter(({ type }) => type.includes('image/'));\n let newUploadedFiles: UploadedFile[] = [];\n\n // Upload videos\n const videoUploadPromises: Promise<Video>[] = videos.map((video) =>\n videoUpload({ accessToken, file: video })\n );\n\n newUploadedFiles = newUploadedFiles.concat(await Promise.all(videoUploadPromises));\n newUploadedFiles = newUploadedFiles.flat();\n\n // Upload images\n const imageUploadPromises: Promise<UploadedImage>[] = images.map((image) =>\n imageUpload({\n accessToken,\n file: image,\n personId,\n })\n );\n\n const uploadedImages: UploadedImage[] = await Promise.all(imageUploadPromises);\n const newImages: UploadedFile[] = uploadedImages.map((file) => ({\n url: `${file.base}/${file.key}`,\n id: file.key,\n meta: file.meta,\n }));\n\n newUploadedFiles = newUploadedFiles.concat(newImages);\n\n return newUploadedFiles;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQO,MAAME,WAAW,GAAGC,IAAA;EAAA,IAAC;IAAEC,IAAI;IAAEC;EAA6B,CAAC,GAAAF,IAAA;EAAA,OAC9D,IAAIG,OAAO,CAAEC,OAAO,IAAK;IACrB,MAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;IAC7CF,KAAK,CAACJ,IAAI,GAAG,MAAM;IAEnB,IAAIA,IAAI,KAAK,KAAK,IAAIA,IAAI,EAAE;MACxBI,KAAK,CAACG,MAAM,GAAGP,IAAI;IACvB;IAEA,IAAIC,QAAQ,EAAE;MACVG,KAAK,CAACH,QAAQ,GAAG,IAAI;IACzB;IAEAG,KAAK,CAACI,KAAK,CAACC,UAAU,GAAG,MAAM;IAC/BL,KAAK,CAACI,KAAK,CAACE,KAAK,GAAG,GAAG;IACvBN,KAAK,CAACI,KAAK,CAACG,MAAM,GAAG,GAAG;IACxBP,KAAK,CAACI,KAAK,CAACI,OAAO,GAAG,MAAM;IAE5BP,QAAQ,CAACQ,IAAI,CAACC,WAAW,CAACV,KAAK,CAAC;IAEhCA,KAAK,CAACW,gBAAgB,CAAC,QAAQ,EAAGC,KAAK,IAAK;MACxCX,QAAQ,CAACQ,IAAI,CAACI,WAAW,CAACb,KAAK,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