@payloadcms/richtext-lexical 3.24.0 → 3.25.0-canary.9728d80
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/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.js.map +2 -2
- package/dist/exports/react/components/RichText/converter/converters/upload.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/upload.js +14 -13
- package/dist/exports/react/components/RichText/converter/converters/upload.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +16 -16
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js +4 -2
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js.map +1 -1
- package/dist/utilities/jsx/jsx.spec.js +6 -0
- package/dist/utilities/jsx/jsx.spec.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,oBAAoB,CA0ElE,CAAA"}
|
|
@@ -5,29 +5,30 @@ export const UploadJSXConverter = {
|
|
|
5
5
|
}) => {
|
|
6
6
|
// TO-DO (v4): SerializedUploadNode should use UploadData_P4
|
|
7
7
|
const uploadDocument = node;
|
|
8
|
-
if (typeof uploadDocument
|
|
8
|
+
if (typeof uploadDocument?.value !== 'object') {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const value = uploadDocument.value;
|
|
12
|
+
const url = value.url;
|
|
12
13
|
/**
|
|
13
14
|
* If the upload is not an image, return a link to the upload
|
|
14
15
|
*/
|
|
15
|
-
if (!
|
|
16
|
+
if (!value.mimeType.startsWith('image')) {
|
|
16
17
|
return /*#__PURE__*/_jsx("a", {
|
|
17
18
|
href: url,
|
|
18
19
|
rel: "noopener noreferrer",
|
|
19
|
-
children:
|
|
20
|
+
children: value.filename
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* If the upload is a simple image with no different sizes, return a simple img tag
|
|
24
25
|
*/
|
|
25
|
-
if (!Object.keys(
|
|
26
|
+
if (!Object.keys(value.sizes).length) {
|
|
26
27
|
return /*#__PURE__*/_jsx("img", {
|
|
27
|
-
alt:
|
|
28
|
-
height:
|
|
28
|
+
alt: value.filename,
|
|
29
|
+
height: value.height,
|
|
29
30
|
src: url,
|
|
30
|
-
width:
|
|
31
|
+
width: value.width
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -35,8 +36,8 @@ export const UploadJSXConverter = {
|
|
|
35
36
|
*/
|
|
36
37
|
const pictureJSX = [];
|
|
37
38
|
// Iterate through each size in the data.sizes object
|
|
38
|
-
for (const size in
|
|
39
|
-
const imageSize =
|
|
39
|
+
for (const size in value.sizes) {
|
|
40
|
+
const imageSize = value.sizes[size];
|
|
40
41
|
// Skip if any property of the size object is null
|
|
41
42
|
if (!imageSize || !imageSize.width || !imageSize.height || !imageSize.mimeType || !imageSize.filesize || !imageSize.filename || !imageSize.url) {
|
|
42
43
|
continue;
|
|
@@ -50,10 +51,10 @@ export const UploadJSXConverter = {
|
|
|
50
51
|
}
|
|
51
52
|
// Add the default img tag
|
|
52
53
|
pictureJSX.push(/*#__PURE__*/_jsx("img", {
|
|
53
|
-
alt:
|
|
54
|
-
height:
|
|
54
|
+
alt: value?.filename,
|
|
55
|
+
height: value?.height,
|
|
55
56
|
src: url,
|
|
56
|
-
width:
|
|
57
|
+
width: value?.width
|
|
57
58
|
}, 'image'));
|
|
58
59
|
return /*#__PURE__*/_jsx("picture", {
|
|
59
60
|
children: pictureJSX
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","value","url","mimeType","startsWith","_jsx","href","rel","filename","Object","keys","sizes","length","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","media","srcSet","type"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"sourcesContent":["import type { FileSizeImproved } from 'payload'\n\nimport type { UploadDataImproved } from '../../../../../../features/upload/server/nodes/UploadNode.js'\nimport type { SerializedUploadNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n // TO-DO (v4): SerializedUploadNode should use UploadData_P4\n const uploadDocument = node as UploadDataImproved\n if (typeof uploadDocument
|
|
1
|
+
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","value","url","mimeType","startsWith","_jsx","href","rel","filename","Object","keys","sizes","length","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","media","srcSet","type"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"sourcesContent":["import type { FileSizeImproved } from 'payload'\n\nimport type { UploadDataImproved } from '../../../../../../features/upload/server/nodes/UploadNode.js'\nimport type { SerializedUploadNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n // TO-DO (v4): SerializedUploadNode should use UploadData_P4\n const uploadDocument = node as UploadDataImproved\n if (typeof uploadDocument?.value !== 'object') {\n return null\n }\n\n const value = uploadDocument.value\n const url = value.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!value.mimeType.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {value.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!Object.keys(value.sizes).length) {\n return <img alt={value.filename} height={value.height} src={url} width={value.width} />\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in value.sizes) {\n const imageSize = value.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media={`(max-width: ${imageSize.width}px)`}\n srcSet={imageSizeURL}\n type={imageSize.mimeType}\n ></source>,\n )\n }\n\n // Add the default img tag\n pictureJSX.push(\n <img\n alt={value?.filename}\n height={value?.height}\n key={'image'}\n src={url}\n width={value?.width}\n />,\n )\n return <picture>{pictureJSX}</picture>\n },\n}\n"],"mappings":";AAMA,OAAO,MAAMA,kBAAA,GAA0D;EACrEC,MAAA,EAAQA,CAAC;IAAEC;EAAI,CAAE;IACf;IACA,MAAMC,cAAA,GAAiBD,IAAA;IACvB,IAAI,OAAOC,cAAA,EAAgBC,KAAA,KAAU,UAAU;MAC7C,OAAO;IACT;IAEA,MAAMA,KAAA,GAAQD,cAAA,CAAeC,KAAK;IAClC,MAAMC,GAAA,GAAMD,KAAA,CAAMC,GAAG;IAErB;;;IAGA,IAAI,CAACD,KAAA,CAAME,QAAQ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BAAOX,IAAA,CAAC;gBAASY;;EACnB;AACF","ignoreList":[]}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
2
|
import type { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionSlug, DataFromCollectionSlug, JsonObject, TypedUploadCollection, UploadCollectionSlug } from 'payload';
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
6
6
|
export type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
7
|
+
[TCollectionSlug in CollectionSlug]: {
|
|
8
|
+
fields: TUploadExtraFieldsData;
|
|
9
|
+
id: string;
|
|
10
|
+
relationTo: TCollectionSlug;
|
|
11
|
+
value: DataFromCollectionSlug<TCollectionSlug> | number | string;
|
|
12
|
+
};
|
|
13
|
+
}[CollectionSlug];
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* This type is for internal use only as it will be deprecated in the future.
|
|
17
|
-
* @internal
|
|
15
|
+
* @todo Replace UploadData with UploadDataImproved
|
|
18
16
|
*/
|
|
19
17
|
export type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
[TCollectionSlug in UploadCollectionSlug]: {
|
|
19
|
+
fields: TUploadExtraFieldsData;
|
|
20
|
+
id: string;
|
|
21
|
+
relationTo: TCollectionSlug;
|
|
22
|
+
value: number | string | TypedUploadCollection[TCollectionSlug];
|
|
23
|
+
};
|
|
24
|
+
}[UploadCollectionSlug];
|
|
25
25
|
export declare function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean;
|
|
26
26
|
export type SerializedUploadNode = {
|
|
27
27
|
children?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAKhF,MAAM,MAAM,UAAU,CAAC,sBAAsB,SAAS,UAAU,GAAG,UAAU,IAAI;KAC9E,eAAe,IAAI,cAAc,GAAG;QACnC,MAAM,EAAE,sBAAsB,CAAA;QAE9B,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,eAAe,CAAA;QAE3B,KAAK,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;KACjE;CACF,CAAC,cAAc,CAAC,CAAA;AAEjB;;GAEG;AACH,MAAM,MAAM,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AAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAA;CAC/D,GAAG,gBAAgB,CAKnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,gBAAgB,CAE1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","React","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadServerElement","domNode","hasAttribute","id","relationTo","node","$createUploadServerNode","data","fields","value","src","startsWith","UploadServerNode","__data","constructor","format","key","clone","__format","__key","getType","importDOM","conversion","priority","importJSON","serializedNode","version","default","toHexString","importedData","setFormat","isInline","decorate","_jsx","RawUploadComponent","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type {
|
|
1
|
+
{"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","React","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadServerElement","domNode","hasAttribute","id","relationTo","node","$createUploadServerNode","data","fields","value","src","startsWith","UploadServerNode","__data","constructor","format","key","clone","__format","__key","getType","importDOM","conversion","priority","importJSON","serializedNode","version","default","toHexString","importedData","setFormat","isInline","decorate","_jsx","RawUploadComponent","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n // Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n id: string\n relationTo: TCollectionSlug\n // Value can be just the document ID, or the full, populated document\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * @todo Replace UploadData with UploadDataImproved\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n // Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n id: string\n relationTo: TCollectionSlug\n // Value can be just the document ID, or the full, populated document\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nfunction $convertUploadServerElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadServerNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: $convertUploadServerElement,\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":";AAmBA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AACtC,YAAYC,KAAA,MAAW;AA2BvB,OAAO,SAASC,uBAAuBC,GAAqB;EAC1D,OACEA,GAAA,CAAIC,aAAa,IAAI,QACrBD,GAAA,CAAIC,aAAa,CAACC,OAAO,KAAK,QAC9BF,GAAA,CAAIG,eAAe,KAAK,QACxBH,GAAA,CAAII,YAAY,CAAC,4BAA4B;AAEjD;AAEA,SAASC,4BAA4BC,OAAyB;EAC5D,IACEA,OAAA,CAAQC,YAAY,CAAC,sCACrBD,OAAA,CAAQC,YAAY,CAAC,2BACrB;IACA,MAAMC,EAAA,GAAKF,OAAA,CAAQF,YAAY,CAAC;IAChC,MAAMK,UAAA,GAAaH,OAAA,CAAQF,YAAY,CAAC;IAExC,IAAII,EAAA,IAAM,QAAQC,UAAA,IAAc,MAAM;MACpC,MAAMC,IAAA,GAAOC,uBAAA,CAAwB;QACnCC,IAAA,EAAM;UACJC,MAAA,EAAQ,CAAC;UACTJ,UA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