@webiny/app-admin 6.5.1-beta.0 → 6.5.1-beta.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-admin",
|
|
3
|
-
"version": "6.5.1-beta.
|
|
3
|
+
"version": "6.5.1-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -16,34 +16,34 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@apollo/react-components": "3.1.5",
|
|
18
18
|
"@apollo/react-hooks": "3.1.5",
|
|
19
|
-
"@atlaskit/pragmatic-drag-and-drop": "
|
|
20
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "
|
|
19
|
+
"@atlaskit/pragmatic-drag-and-drop": "4.0.0",
|
|
20
|
+
"@atlaskit/pragmatic-drag-and-drop-hitbox": "3.0.0",
|
|
21
21
|
"@emotion/css": "11.13.5",
|
|
22
22
|
"@emotion/react": "11.14.0",
|
|
23
23
|
"@emotion/styled": "11.14.1",
|
|
24
24
|
"@fortawesome/fontawesome-svg-core": "7.3.1",
|
|
25
25
|
"@fortawesome/react-fontawesome": "3.5.0",
|
|
26
|
-
"@iconify/json": "2.2.
|
|
26
|
+
"@iconify/json": "2.2.547",
|
|
27
27
|
"@lexical/utils": "0.52.0",
|
|
28
28
|
"@types/react": "18.3.31",
|
|
29
|
-
"@webiny/admin-ui": "6.5.1-beta.
|
|
30
|
-
"@webiny/app": "6.5.1-beta.
|
|
29
|
+
"@webiny/admin-ui": "6.5.1-beta.1",
|
|
30
|
+
"@webiny/app": "6.5.1-beta.1",
|
|
31
31
|
"@webiny/di": "1.1.0",
|
|
32
|
-
"@webiny/feature": "6.5.1-beta.
|
|
33
|
-
"@webiny/form": "6.5.1-beta.
|
|
34
|
-
"@webiny/icons": "6.5.1-beta.
|
|
35
|
-
"@webiny/lexical-converter": "6.5.1-beta.
|
|
36
|
-
"@webiny/lexical-editor": "6.5.1-beta.
|
|
37
|
-
"@webiny/lexical-nodes": "6.5.1-beta.
|
|
38
|
-
"@webiny/lexical-theme": "6.5.1-beta.
|
|
39
|
-
"@webiny/plugins": "6.5.1-beta.
|
|
40
|
-
"@webiny/react-composition": "6.5.1-beta.
|
|
41
|
-
"@webiny/react-properties": "6.5.1-beta.
|
|
42
|
-
"@webiny/sdk": "6.5.1-beta.
|
|
43
|
-
"@webiny/telemetry": "6.5.1-beta.
|
|
44
|
-
"@webiny/utils": "6.5.1-beta.
|
|
45
|
-
"@webiny/validation": "6.5.1-beta.
|
|
46
|
-
"@webiny/wcp": "6.5.1-beta.
|
|
32
|
+
"@webiny/feature": "6.5.1-beta.1",
|
|
33
|
+
"@webiny/form": "6.5.1-beta.1",
|
|
34
|
+
"@webiny/icons": "6.5.1-beta.1",
|
|
35
|
+
"@webiny/lexical-converter": "6.5.1-beta.1",
|
|
36
|
+
"@webiny/lexical-editor": "6.5.1-beta.1",
|
|
37
|
+
"@webiny/lexical-nodes": "6.5.1-beta.1",
|
|
38
|
+
"@webiny/lexical-theme": "6.5.1-beta.1",
|
|
39
|
+
"@webiny/plugins": "6.5.1-beta.1",
|
|
40
|
+
"@webiny/react-composition": "6.5.1-beta.1",
|
|
41
|
+
"@webiny/react-properties": "6.5.1-beta.1",
|
|
42
|
+
"@webiny/sdk": "6.5.1-beta.1",
|
|
43
|
+
"@webiny/telemetry": "6.5.1-beta.1",
|
|
44
|
+
"@webiny/utils": "6.5.1-beta.1",
|
|
45
|
+
"@webiny/validation": "6.5.1-beta.1",
|
|
46
|
+
"@webiny/wcp": "6.5.1-beta.1",
|
|
47
47
|
"apollo-cache": "1.3.5",
|
|
48
48
|
"apollo-client": "2.6.10",
|
|
49
49
|
"apollo-link": "1.2.14",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"markdown-to-jsx": "9.10.3",
|
|
61
61
|
"mime": "4.1.1",
|
|
62
62
|
"minimatch": "10.2.6",
|
|
63
|
-
"mobx": "7.
|
|
63
|
+
"mobx": "7.1.1",
|
|
64
64
|
"mobx-react-lite": "5.1.0",
|
|
65
65
|
"monaco-editor": "0.53.0",
|
|
66
66
|
"react": "18.3.1",
|
|
67
67
|
"react-dom": "18.3.1",
|
|
68
|
-
"react-resizable-panels": "4.
|
|
68
|
+
"react-resizable-panels": "4.15.0",
|
|
69
69
|
"react-transition-group": "4.4.5",
|
|
70
70
|
"react-virtualized": "9.22.6",
|
|
71
71
|
"reset-css": "5.0.2",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/react-transition-group": "4.4.12",
|
|
84
84
|
"@types/store": "2.0.5",
|
|
85
85
|
"@types/tinycolor2": "1.4.6",
|
|
86
|
-
"@webiny/build-tools": "6.5.1-beta.
|
|
86
|
+
"@webiny/build-tools": "6.5.1-beta.1",
|
|
87
87
|
"rimraf": "6.1.3",
|
|
88
88
|
"typescript": "7.0.2",
|
|
89
89
|
"vitest": "5.0.5"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
-
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element
|
|
3
|
-
import { attachClosestEdge
|
|
2
|
+
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter";
|
|
3
|
+
import { attachClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/attach-closest-edge";
|
|
4
|
+
import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/extract-closest-edge";
|
|
4
5
|
import { SortablePresenter } from "./abstractions.js";
|
|
5
6
|
function toSortableEdge(edge) {
|
|
6
7
|
if ("top" === edge || "bottom" === edge) return edge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/sortable/SortablePresenter.js","sources":["../../../src/presentation/sortable/SortablePresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport {\n draggable,\n dropTargetForElements\n} from \"@atlaskit/pragmatic-drag-and-drop/element/adapter\";\nimport {\n attachClosestEdge,\n extractClosestEdge\n} from \"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge\";\nimport { SortablePresenter as Abstraction } from \"./abstractions.js\";\n\nfunction toSortableEdge(edge: string | null): Abstraction.Edge | null {\n if (edge === \"top\" || edge === \"bottom\") {\n return edge;\n }\n return null;\n}\n\nfunction getIndex(data: Record<string | symbol, unknown>): number | null {\n const index = data[\"index\"];\n if (typeof index === \"number\") {\n return index;\n }\n return null;\n}\n\nfunction getType(data: Record<string | symbol, unknown>): string | null {\n const type = data[\"type\"];\n if (typeof type === \"string\") {\n return type;\n }\n return null;\n}\n\nclass SortablePresenterImpl implements Abstraction.Interface {\n private draggingIndex: number | null = null;\n private overIndex: number | null = null;\n private closestEdge: Abstraction.Edge | null = null;\n private cleanups = new Map<number, () => void>();\n private config: Abstraction.Config | null = null;\n\n constructor() {\n makeAutoObservable<SortablePresenterImpl, \"cleanups\" | \"config\">(this, {\n cleanups: false,\n config: false\n });\n }\n\n init(config: Abstraction.Config): void {\n this.config = config;\n }\n\n getItemProps(index: number): Abstraction.ItemProps {\n return {\n ref: (element: HTMLElement | null) => {\n this.registerDropTarget(index, element);\n },\n handleRef: (element: HTMLElement | null) => {\n this.registerDraggable(index, element);\n },\n isDragging: this.draggingIndex === index,\n isOver: this.overIndex === index && this.draggingIndex !== index,\n closestEdge: this.getVisibleEdge(index)\n };\n }\n\n dispose(): void {\n for (const cleanup of this.cleanups.values()) {\n cleanup();\n }\n this.cleanups.clear();\n this.draggingIndex = null;\n this.overIndex = null;\n this.closestEdge = null;\n }\n\n private get type(): string {\n return this.config!.type;\n }\n\n private isOwnDrag(data: Record<string | symbol, unknown>): boolean {\n return getType(data) === this.type;\n }\n\n private getVisibleEdge(index: number): Abstraction.Edge | null {\n if (\n this.overIndex !== index ||\n this.draggingIndex === index ||\n this.draggingIndex === null\n ) {\n return null;\n }\n const edge = this.closestEdge;\n if (edge === \"top\" && this.draggingIndex === index - 1) {\n return null;\n }\n if (edge === \"bottom\" && this.draggingIndex === index + 1) {\n return null;\n }\n return edge;\n }\n\n private clearDropState(): void {\n this.draggingIndex = null;\n this.overIndex = null;\n this.closestEdge = null;\n }\n\n private computeDestination(\n fromIndex: number,\n toIndex: number,\n edge: Abstraction.Edge | null\n ): number {\n let destinationIndex = toIndex;\n if (edge === \"bottom\") {\n destinationIndex = fromIndex < toIndex ? toIndex : toIndex + 1;\n } else if (edge === \"top\") {\n destinationIndex = fromIndex > toIndex ? toIndex : toIndex - 1;\n }\n return destinationIndex;\n }\n\n private registerDropTarget(index: number, element: HTMLElement | null): void {\n const key = index * 2;\n const existing = this.cleanups.get(key);\n if (existing) {\n existing();\n this.cleanups.delete(key);\n }\n\n if (!element) {\n return;\n }\n\n const cleanup = dropTargetForElements({\n element,\n canDrop: ({ source }) => {\n return this.isOwnDrag(source.data) && getIndex(source.data) !== index;\n },\n getData: ({ input }) => {\n return attachClosestEdge(\n { index, type: this.type },\n { element, input, allowedEdges: [\"top\", \"bottom\"] }\n );\n },\n onDragEnter: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n this.overIndex = index;\n this.closestEdge = toSortableEdge(extractClosestEdge(self.data));\n });\n },\n onDrag: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n this.overIndex = index;\n this.closestEdge = toSortableEdge(extractClosestEdge(self.data));\n });\n },\n onDragLeave: ({ source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n if (this.overIndex === index) {\n this.overIndex = null;\n this.closestEdge = null;\n }\n });\n },\n onDrop: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n\n const fromIndex = getIndex(source.data);\n const toIndex = getIndex(self.data);\n const edge = toSortableEdge(extractClosestEdge(self.data));\n\n runInAction(() => {\n this.clearDropState();\n });\n\n if (fromIndex === null || toIndex === null || !this.config) {\n return;\n }\n\n const destinationIndex = this.computeDestination(fromIndex, toIndex, edge);\n if (destinationIndex !== fromIndex) {\n this.config.onReorder(fromIndex, destinationIndex);\n }\n }\n });\n\n this.cleanups.set(key, cleanup);\n }\n\n private registerDraggable(index: number, element: HTMLElement | null): void {\n const key = index * 2 + 1;\n const existing = this.cleanups.get(key);\n if (existing) {\n existing();\n this.cleanups.delete(key);\n }\n\n if (!element) {\n return;\n }\n\n const container = element.closest(\"[data-sortable-item]\") as HTMLElement | null;\n if (!container) {\n return;\n }\n\n const cleanup = draggable({\n element: container,\n dragHandle: element,\n getInitialData: () => ({ index, type: this.type }),\n onDragStart: () => {\n runInAction(() => {\n this.draggingIndex = index;\n });\n },\n onDrop: () => {\n runInAction(() => {\n this.clearDropState();\n });\n }\n });\n\n this.cleanups.set(key, cleanup);\n }\n}\n\nexport const SortablePresenter = Abstraction.createImplementation({\n implementation: SortablePresenterImpl,\n dependencies: []\n});\n"],"names":["toSortableEdge","edge","getIndex","data","index","getType","type","SortablePresenterImpl","Map","makeAutoObservable","config","element","cleanup","fromIndex","toIndex","destinationIndex","key","existing","dropTargetForElements","source","input","attachClosestEdge","self","runInAction","extractClosestEdge","container","draggable","SortablePresenter","Abstraction"],"mappings":";;;;AAWA,SAASA,eAAeC,IAAmB;IACvC,IAAIA,AAAS,UAATA,QAAkBA,AAAS,aAATA,MAClB,OAAOA;IAEX,OAAO;AACX;AAEA,SAASC,SAASC,IAAsC;IACpD,MAAMC,QAAQD,IAAI,CAAC,QAAQ;IAC3B,IAAI,AAAiB,YAAjB,OAAOC,OACP,OAAOA;IAEX,OAAO;AACX;AAEA,SAASC,QAAQF,IAAsC;IACnD,MAAMG,OAAOH,IAAI,CAAC,OAAO;IACzB,IAAI,AAAgB,YAAhB,OAAOG,MACP,OAAOA;IAEX,OAAO;AACX;AAEA,MAAMC;IAOF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A,IAAI,CAACL,SACD;QAGJ,MAAMc,YAAYd,QAAQ,OAAO,CAAC;QAClC,IAAI,CAACc,WACD;QAGJ,MAAMb,UAAUc,UAAU;YACtB,SAASD;YACT,YAAYd;YACZ,gBAAgB,IAAO;oBAAEP;oBAAO,MAAM,IAAI,CAAC,IAAI;gBAAC;YAChD,aAAa;gBACTmB,YAAY;oBACR,IAAI,CAAC,aAAa,GAAGnB;gBACzB;YACJ;YACA,QAAQ;gBACJmB,YAAY;oBACR,IAAI,CAAC,cAAc;gBACvB;YACJ;QACJ;QAEA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACP,KAAKJ;IAC3B;AACJ;AAEO,MAAMe,sCAAoBC,kBAAAA,oBAAgC,CAAC;IAC9D,gBAAgBrB;IAChB,cAAc,EAAE;AACpB"}
|
|
1
|
+
{"version":3,"file":"presentation/sortable/SortablePresenter.js","sources":["../../../src/presentation/sortable/SortablePresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport {\n draggable,\n dropTargetForElements\n} from \"@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter\";\nimport { attachClosestEdge } from \"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/attach-closest-edge\";\nimport { extractClosestEdge } from \"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge/extract-closest-edge\";\nimport { SortablePresenter as Abstraction } from \"./abstractions.js\";\n\nfunction toSortableEdge(edge: string | null): Abstraction.Edge | null {\n if (edge === \"top\" || edge === \"bottom\") {\n return edge;\n }\n return null;\n}\n\nfunction getIndex(data: Record<string | symbol, unknown>): number | null {\n const index = data[\"index\"];\n if (typeof index === \"number\") {\n return index;\n }\n return null;\n}\n\nfunction getType(data: Record<string | symbol, unknown>): string | null {\n const type = data[\"type\"];\n if (typeof type === \"string\") {\n return type;\n }\n return null;\n}\n\nclass SortablePresenterImpl implements Abstraction.Interface {\n private draggingIndex: number | null = null;\n private overIndex: number | null = null;\n private closestEdge: Abstraction.Edge | null = null;\n private cleanups = new Map<number, () => void>();\n private config: Abstraction.Config | null = null;\n\n constructor() {\n makeAutoObservable<SortablePresenterImpl, \"cleanups\" | \"config\">(this, {\n cleanups: false,\n config: false\n });\n }\n\n init(config: Abstraction.Config): void {\n this.config = config;\n }\n\n getItemProps(index: number): Abstraction.ItemProps {\n return {\n ref: (element: HTMLElement | null) => {\n this.registerDropTarget(index, element);\n },\n handleRef: (element: HTMLElement | null) => {\n this.registerDraggable(index, element);\n },\n isDragging: this.draggingIndex === index,\n isOver: this.overIndex === index && this.draggingIndex !== index,\n closestEdge: this.getVisibleEdge(index)\n };\n }\n\n dispose(): void {\n for (const cleanup of this.cleanups.values()) {\n cleanup();\n }\n this.cleanups.clear();\n this.draggingIndex = null;\n this.overIndex = null;\n this.closestEdge = null;\n }\n\n private get type(): string {\n return this.config!.type;\n }\n\n private isOwnDrag(data: Record<string | symbol, unknown>): boolean {\n return getType(data) === this.type;\n }\n\n private getVisibleEdge(index: number): Abstraction.Edge | null {\n if (\n this.overIndex !== index ||\n this.draggingIndex === index ||\n this.draggingIndex === null\n ) {\n return null;\n }\n const edge = this.closestEdge;\n if (edge === \"top\" && this.draggingIndex === index - 1) {\n return null;\n }\n if (edge === \"bottom\" && this.draggingIndex === index + 1) {\n return null;\n }\n return edge;\n }\n\n private clearDropState(): void {\n this.draggingIndex = null;\n this.overIndex = null;\n this.closestEdge = null;\n }\n\n private computeDestination(\n fromIndex: number,\n toIndex: number,\n edge: Abstraction.Edge | null\n ): number {\n let destinationIndex = toIndex;\n if (edge === \"bottom\") {\n destinationIndex = fromIndex < toIndex ? toIndex : toIndex + 1;\n } else if (edge === \"top\") {\n destinationIndex = fromIndex > toIndex ? toIndex : toIndex - 1;\n }\n return destinationIndex;\n }\n\n private registerDropTarget(index: number, element: HTMLElement | null): void {\n const key = index * 2;\n const existing = this.cleanups.get(key);\n if (existing) {\n existing();\n this.cleanups.delete(key);\n }\n\n if (!element) {\n return;\n }\n\n const cleanup = dropTargetForElements({\n element,\n canDrop: ({ source }) => {\n return this.isOwnDrag(source.data) && getIndex(source.data) !== index;\n },\n getData: ({ input }) => {\n return attachClosestEdge(\n { index, type: this.type },\n { element, input, allowedEdges: [\"top\", \"bottom\"] }\n );\n },\n onDragEnter: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n this.overIndex = index;\n this.closestEdge = toSortableEdge(extractClosestEdge(self.data));\n });\n },\n onDrag: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n this.overIndex = index;\n this.closestEdge = toSortableEdge(extractClosestEdge(self.data));\n });\n },\n onDragLeave: ({ source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n runInAction(() => {\n if (this.overIndex === index) {\n this.overIndex = null;\n this.closestEdge = null;\n }\n });\n },\n onDrop: ({ self, source }) => {\n if (!this.isOwnDrag(source.data)) {\n return;\n }\n\n const fromIndex = getIndex(source.data);\n const toIndex = getIndex(self.data);\n const edge = toSortableEdge(extractClosestEdge(self.data));\n\n runInAction(() => {\n this.clearDropState();\n });\n\n if (fromIndex === null || toIndex === null || !this.config) {\n return;\n }\n\n const destinationIndex = this.computeDestination(fromIndex, toIndex, edge);\n if (destinationIndex !== fromIndex) {\n this.config.onReorder(fromIndex, destinationIndex);\n }\n }\n });\n\n this.cleanups.set(key, cleanup);\n }\n\n private registerDraggable(index: number, element: HTMLElement | null): void {\n const key = index * 2 + 1;\n const existing = this.cleanups.get(key);\n if (existing) {\n existing();\n this.cleanups.delete(key);\n }\n\n if (!element) {\n return;\n }\n\n const container = element.closest(\"[data-sortable-item]\") as HTMLElement | null;\n if (!container) {\n return;\n }\n\n const cleanup = draggable({\n element: container,\n dragHandle: element,\n getInitialData: () => ({ index, type: this.type }),\n onDragStart: () => {\n runInAction(() => {\n this.draggingIndex = index;\n });\n },\n onDrop: () => {\n runInAction(() => {\n this.clearDropState();\n });\n }\n });\n\n this.cleanups.set(key, cleanup);\n }\n}\n\nexport const SortablePresenter = Abstraction.createImplementation({\n implementation: SortablePresenterImpl,\n dependencies: []\n});\n"],"names":["toSortableEdge","edge","getIndex","data","index","getType","type","SortablePresenterImpl","Map","makeAutoObservable","config","element","cleanup","fromIndex","toIndex","destinationIndex","key","existing","dropTargetForElements","source","input","attachClosestEdge","self","runInAction","extractClosestEdge","container","draggable","SortablePresenter","Abstraction"],"mappings":";;;;;AASA,SAASA,eAAeC,IAAmB;IACvC,IAAIA,AAAS,UAATA,QAAkBA,AAAS,aAATA,MAClB,OAAOA;IAEX,OAAO;AACX;AAEA,SAASC,SAASC,IAAsC;IACpD,MAAMC,QAAQD,IAAI,CAAC,QAAQ;IAC3B,IAAI,AAAiB,YAAjB,OAAOC,OACP,OAAOA;IAEX,OAAO;AACX;AAEA,SAASC,QAAQF,IAAsC;IACnD,MAAMG,OAAOH,IAAI,CAAC,OAAO;IACzB,IAAI,AAAgB,YAAhB,OAAOG,MACP,OAAOA;IAEX,OAAO;AACX;AAEA,MAAMC;IAOF,aAAc;aANN,aAAa,GAAkB;aAC/B,SAAS,GAAkB;aAC3B,WAAW,GAA4B;aACvC,QAAQ,GAAG,IAAIC;aACf,MAAM,GAA8B;QAGxCC,mBAAiE,IAAI,EAAE;YACnE,UAAU;YACV,QAAQ;QACZ;IACJ;IAEA,KAAKC,MAA0B,EAAQ;QACnC,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,aAAaN,KAAa,EAAyB;QAC/C,OAAO;YACH,KAAK,CAACO;gBACF,IAAI,CAAC,kBAAkB,CAACP,OAAOO;YACnC;YACA,WAAW,CAACA;gBACR,IAAI,CAAC,iBAAiB,CAACP,OAAOO;YAClC;YACA,YAAY,IAAI,CAAC,aAAa,KAAKP;YACnC,QAAQ,IAAI,CAAC,SAAS,KAAKA,SAAS,IAAI,CAAC,aAAa,KAAKA;YAC3D,aAAa,IAAI,CAAC,cAAc,CAACA;QACrC;IACJ;IAEA,UAAgB;QACZ,KAAK,MAAMQ,WAAW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