@pcg/dynamic-components 1.0.0-alpha.0 → 1.0.0-alpha.3

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.
@@ -0,0 +1,16 @@
1
+
2
+ 
3
+ > @pcg/dynamic-components@1.0.0-alpha.0 build /Users/vangolenko/node/pcg/packages/dynamic-components
4
+ > tsdown
5
+
6
+ ℹ tsdown v0.15.12 powered by rolldown v1.0.0-beta.45
7
+ ℹ Using tsdown config: /Users/vangolenko/node/pcg/packages/dynamic-components/tsdown.config.ts
8
+ ℹ entry: src/index.ts
9
+ ℹ tsconfig: tsconfig.lib.json
10
+ ℹ Build start
11
+ ℹ Cleaning 3 files
12
+ ℹ dist/index.js  57.84 kB │ gzip: 12.05 kB
13
+ ℹ dist/index.js.map 120.49 kB │ gzip: 25.12 kB
14
+ ℹ dist/index.d.ts  60.94 kB │ gzip: 11.28 kB
15
+ ℹ 3 files, total: 239.28 kB
16
+ ✔ Build complete in 1141ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @pcg/dynamic-components
2
2
 
3
+ ## 1.0.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - refactor(types): 🔄 rename FormDynamicComponent to UiKitFormDynamicComponent
8
+
9
+ ## 1.0.0-alpha.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @pcg/predicates@1.0.0-alpha.1
15
+
16
+ ## 1.0.0-alpha.1
17
+
18
+ ### Patch Changes
19
+
20
+ - 72f7749: feat(ui): 🔄 make repeatable collection heading optional and add draggability
21
+
22
+ - Makes the `heading` prop optional in `DRepeatableCollection` interface
23
+ - Adds new `draggable` boolean prop to support drag-and-drop functionality
24
+ - Improves component flexibility for different use cases
25
+
3
26
  ## 1.0.0
4
27
 
5
28
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1,115 +1,9 @@
1
+ import { entriesOf, isCallable, isContainerValue, isEmptyArray, isEmptyContainer, isIndex, isNullOrUndefined, isNumber, isObject, isString, keysOf } from "@pcg/predicates";
1
2
  import * as Y from "yjs";
2
- import { Entries } from "type-fest";
3
3
  import { JSONContent } from "@tiptap/core";
4
4
 
5
- //#region src/assertions/basic.d.ts
6
-
7
- /**
8
- * Checks if the given parameter is callable (a function).
9
- * @param {unknown} fn - The function to check.
10
- * @returns {boolean} Returns true if `fn` is a function, false otherwise.
11
- * @example
12
- * isCallable(() => {}); // Returns true
13
- * isCallable('Hello'); // Returns false
14
- */
15
- declare const isCallable: (fn: unknown) => fn is (...args: any[]) => any;
16
- /**
17
- * Checks if the given value is a string.
18
- * @param {unknown} val - The value to check.
19
- * @returns {boolean} Returns true if `val` is a string, false otherwise.
20
- * @example
21
- * isString('Hello'); // Returns true
22
- * isString(123); // Returns false
23
- */
24
- declare const isString: (val: unknown) => val is string;
25
- /**
26
- * Checks if the given value is a number.
27
- * @param {unknown} val - The value to check.
28
- * @returns {boolean} Returns true if `val` is a number, false otherwise.
29
- * @example
30
- * isNumber(123); // Returns true
31
- * isNumber('Hello'); // Returns false
32
- */
33
- declare const isNumber: (val: unknown) => val is number;
34
- /**
35
- * Checks if a given value can be used as an index (a non-negative integer).
36
- * @param {unknown} value - The value to check.
37
- * @returns {boolean} Returns true if `value` can be used as an index, false otherwise.
38
- * @example
39
- * isIndex(2); // Returns true
40
- * isIndex('2'); // Returns true
41
- * isIndex(-1); // Returns false
42
- */
43
- declare const isIndex: (value: unknown) => value is number;
44
- /**
45
- * Checks if the given value is null or undefined.
46
- * @param {unknown} value - The value to check.
47
- * @returns {boolean} Returns true if `value` is null or undefined, false otherwise.
48
- * @example
49
- * isNullOrUndefined(null); // Returns true
50
- * isNullOrUndefined(undefined); // Returns true
51
- * isNullOrUndefined('Hello'); // Returns false
52
- */
53
- declare const isNullOrUndefined: (value: unknown) => value is undefined | null;
54
- //#endregion
55
- //#region src/assertions/containers.d.ts
56
- /**
57
- * Checks if the given value is an empty array.
58
- * @param {unknown} arr - The array to check.
59
- * @returns {boolean} Returns true if `arr` is an empty array, false otherwise.
60
- * @example
61
- * isEmptyArray([]); // Returns true
62
- * isEmptyArray([1, 2, 3]); // Returns false
63
- */
64
- declare const isEmptyArray: (arr: unknown) => boolean;
65
- /**
66
- * Gets the keys of the given object.
67
- * @param {T} arr - The object to get the keys from.
68
- * @returns {Array<keyof T>} Returns an array of keys of the given object.
69
- * @example
70
- * keysOf({ a: 1, b: 2 }); // Returns ['a', 'b']
71
- */
72
- declare const keysOf: <T>(arr: T) => (keyof T)[];
73
- /**
74
- * Gets the entries of the given object.
75
- * @param {T} arr - The object to get the entries from.
76
- * @returns {Entries<T>} Returns an array of entries of the given object.
77
- * @example
78
- * entriesOf({ a: 1, b: 2 }); // Returns [['a', 1], ['b', 2]]
79
- */
80
- declare const entriesOf: <T>(arr: T) => Entries<T>;
81
- /**
82
- * Checks if the given value is an object (not an array).
83
- * @param {unknown} obj - The value to check.
84
- * @returns {boolean} Returns true if `obj` is an object, false otherwise.
85
- * @example
86
- * isObject({ a: 1 }); // Returns true
87
- * isObject([1, 2, 3]); // Returns false
88
- */
89
- declare const isObject: (obj: unknown) => obj is Record<string, unknown>;
90
- /**
91
- * Checks if the given value is a container (an object or an array).
92
- * @param {unknown} value - The value to check.
93
- * @returns {boolean} Returns true if `value` is a container, false otherwise.
94
- * @example
95
- * isContainerValue({ a: 1 }); // Returns true
96
- * isContainerValue([1, 2, 3]); // Returns true
97
- * isContainerValue('Hello'); // Returns false
98
- */
99
- declare const isContainerValue: (value: unknown) => value is Record<string, unknown>;
100
- /**
101
- * Checks if the given value is an empty container (an empty object or array).
102
- * @param {unknown} value - The value to check.
103
- * @returns {boolean} Returns true if `value` is an empty container, false otherwise.
104
- * @example
105
- * isEmptyContainer({}); // Returns true
106
- * isEmptyContainer([]); // Returns true
107
- * isEmptyContainer({ a: 1 }); // Returns false
108
- * isEmptyContainer([1, 2, 3]); // Returns false
109
- */
110
- declare const isEmptyContainer: (value: unknown) => boolean;
111
- //#endregion
112
5
  //#region src/assertions/paths.d.ts
6
+
113
7
  /**
114
8
  * Checks if two paths are equal.
115
9
  * @param {(string | number)[]} path - The first path to compare.
@@ -1073,7 +967,7 @@ interface DRepeatableCollection extends DynamicComponent {
1073
967
  component: 'repeatable-collection';
1074
968
  props: {
1075
969
  name?: string;
1076
- heading: string;
970
+ heading?: string;
1077
971
  collectionTitle?: string;
1078
972
  useTabs?: boolean;
1079
973
  cols?: number;
@@ -1081,6 +975,7 @@ interface DRepeatableCollection extends DynamicComponent {
1081
975
  confirmDeletion?: boolean;
1082
976
  addButtonText?: string;
1083
977
  readonly?: boolean;
978
+ draggable?: boolean;
1084
979
  components: DynamicComponent[];
1085
980
  visible?: string;
1086
981
  rules?: {
@@ -1098,11 +993,11 @@ interface DRowSettings extends DynamicComponent {
1098
993
  declare const isRowSettingsComponent: (component: DynamicComponent) => component is DRowSettings;
1099
994
  //#endregion
1100
995
  //#region src/dynamic-components/registry/uikit-dynamic-component.d.ts
1101
- type FormDynamicComponent = DTextInput | DCheckbox | DTextarea | DSelect | DEntitySelect | DRadioGroup | DCheckboxGroup | DFileUploader | DImageUploader | DSimpleImageUploader | DRawImageUploader | DSlug | DEmbedCode | DRichTextEditor | DNumberInput | DSwitch | DHeading | DRawImagesUploader | DDateTimePicker | DComputedValue | DHiddenInput | DConfirmDeletionInput;
996
+ type UiKitFormDynamicComponent = DTextInput | DCheckbox | DTextarea | DSelect | DEntitySelect | DRadioGroup | DCheckboxGroup | DFileUploader | DImageUploader | DSimpleImageUploader | DRawImageUploader | DSlug | DEmbedCode | DRichTextEditor | DNumberInput | DSwitch | DHeading | DRawImagesUploader | DDateTimePicker | DComputedValue | DHiddenInput | DConfirmDeletionInput;
1102
997
  type UiKitContentDynamicComponent = DRichText | DEmbedCode | DImage | DBibleQuote | DBiblePassage;
1103
998
  type UiKitLayoutDynamicComponent = DRow | DColumn | DRowSettings | DCollection | DRepeatableCollection;
1104
999
  type UiKitChatDynamicComponent = DChatTextMessage;
1105
- type UiKitDynamicComponent = FormDynamicComponent | UiKitContentDynamicComponent | UiKitLayoutDynamicComponent | UiKitChatDynamicComponent;
1000
+ type UiKitDynamicComponent = UiKitFormDynamicComponent | UiKitContentDynamicComponent | UiKitLayoutDynamicComponent | UiKitChatDynamicComponent;
1106
1001
  //#endregion
1107
1002
  //#region src/dynamic-components/tools.d.ts
1108
1003
  declare const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
@@ -1812,5 +1707,5 @@ interface AwarenessState {
1812
1707
  */
1813
1708
  declare const getYArrayIndexByArrayKey: (yArray: unknown, key: string) => number;
1814
1709
  //#endregion
1815
- export { AwarenessState, AwarenessStateChange, BaseDataObject, ComponentStyles, DBiblePassage, DBibleQuote, DChatMessageDelay, DChatTextMessage, DCheckbox, DCheckboxGroup, DCollection, DColumn, DComputedValue, DConfirmDeletionInput, DDateTimePicker, DEmbedCode, DEntitySelect, DFileUploader, DHeading, DHiddenInput, DImage, DImageUploader, DLegacyContent, DNumberInput, DPractice, DRadioGroup, DRawImageUploader, DRawImagesUploader, DRepeatableCollection, DRichText, DRichTextEditor, DRow, DRowSettings, DSelect, DSimpleImageUploader, DSlug, DStatement, DSwitch, DTest, DTextInput, DTextarea, DynamicComponent, DynamicComponentIO, DynamicComponentLink, DynamicComponentWithPosition, FormDynamicComponent, ID_PATH_KEY_PREFIX, IImageRenditionType, IRenditionOptions, ISizeType, InsertYMapAfterOptions, InsertYMapBeforeOptions, InsertYMapToEndOptions, MovePayload, MoveYMapAfterOptions, MoveYMapBeforeOptions, MoveYMapToEndOptions, MoveYMapToStartOptions, NestedRecord, PATH_REGEXP, POSITION_ARRAY_KEY_PREFIX, Point, PullPayload, PushPayload, RichText, SetPayload, TestItem, TestItemVariant, UiKitChatDynamicComponent, UiKitContentDynamicComponent, UiKitDynamicComponent, UiKitLayoutDynamicComponent, UnsetPayload, ValidationRules, YComponent, YComponentProps, YComponentsArray, arrayToYArray, copyDynamicComponent, createIdArrayKey, createPositionArrayKey, customAlphabet, defineDynamicComponent, defineDynamicComponents, dynamicComponentPropsToYComponentProps, dynamicComponentToYComponent, dynamicComponentToYMap, dynamicComponentsToYArray, entriesOf, existsInPath, extractIdFromArrayKey, extractPositionFromArrayKey, findInYArray, findIndexInYArray, findYComponentInArray, generateKeyBetween, getComponentPropertyPath, getComponentsSubtreeByPath, getComponentsSubtreeByRPath, getDataObjectKey, getFromPath, getFromYPath, getIndexByArrayKey, getRelativePoint, getSortedYArray, getYArrayIndexByArrayKey, getYArrayRefsByPosition, getYComponentComponentsArray, getYComponentProps, getYComponentsArrayParentComponent, insertInPath, insertYMapAfter, insertYMapBefore, insertYMapToEnd, isArrayKey, isBiblePassageComponent, isBibleQuoteComponent, isCallable, isChatMessageDelayComponent, isChatTextMessageComponent, isCheckboxComponent, isCheckboxGroupComponent, isCollectionComponent, isColumnComponent, isComputedValueComponent, isConfirmDeletionInputComponent, isContainerValue, isDateTimePickerComponent, isEmbedCodeComponent, isEmptyArray, isEmptyContainer, isEntitySelectComponent, isEqualPath, isFileUploaderComponent, isHeadingComponent, isIdArrayKey, isImageComponent, isImageUploaderComponent, isIndex, isLegacyContentComponent, isNullOrUndefined, isNumber, isNumberInputComponent, isObject, isPositionArrayKey, isPracticeComponent, isRadioGroupComponent, isRawImageUploaderComponent, isRawImagesUploaderComponent, isRepeatableCollectionComponent, isRichText, isRichTextComponent, isRichTextEditorComponent, isRowComponent, isRowSettingsComponent, isSamePath, isSelectComponent, isSimpleImageUploaderComponent, isSlugComponent, isStatementComponent, isString, isSwitchComponent, isTestComponent, isTextInputComponent, isTextareaComponent, isYArray, isYComponent, isYMap, joinPath, keysOf, makeDynamicComponentsWithPosition, moveInPath, moveInYPath, moveYMapAfter, moveYMapBefore, moveYMapToEnd, moveYMapToStart, objectToYMap, pullFromPath, pullFromYPath, pushInPath, pushInYPath, searchDynamicComponentInTree, setInPath, setInYPath, sortByPosition, sortDynamicComponents, uid, unsetPath, unsetYPath, urlAlphabet, yComponentHasComponentsYArray, yComponentToDynamicComponent };
1710
+ export { AwarenessState, AwarenessStateChange, BaseDataObject, ComponentStyles, DBiblePassage, DBibleQuote, DChatMessageDelay, DChatTextMessage, DCheckbox, DCheckboxGroup, DCollection, DColumn, DComputedValue, DConfirmDeletionInput, DDateTimePicker, DEmbedCode, DEntitySelect, DFileUploader, DHeading, DHiddenInput, DImage, DImageUploader, DLegacyContent, DNumberInput, DPractice, DRadioGroup, DRawImageUploader, DRawImagesUploader, DRepeatableCollection, DRichText, DRichTextEditor, DRow, DRowSettings, DSelect, DSimpleImageUploader, DSlug, DStatement, DSwitch, DTest, DTextInput, DTextarea, DynamicComponent, DynamicComponentIO, DynamicComponentLink, DynamicComponentWithPosition, ID_PATH_KEY_PREFIX, IImageRenditionType, IRenditionOptions, ISizeType, InsertYMapAfterOptions, InsertYMapBeforeOptions, InsertYMapToEndOptions, MovePayload, MoveYMapAfterOptions, MoveYMapBeforeOptions, MoveYMapToEndOptions, MoveYMapToStartOptions, NestedRecord, PATH_REGEXP, POSITION_ARRAY_KEY_PREFIX, Point, PullPayload, PushPayload, RichText, SetPayload, TestItem, TestItemVariant, UiKitChatDynamicComponent, UiKitContentDynamicComponent, UiKitDynamicComponent, UiKitFormDynamicComponent, UiKitLayoutDynamicComponent, UnsetPayload, ValidationRules, YComponent, YComponentProps, YComponentsArray, arrayToYArray, copyDynamicComponent, createIdArrayKey, createPositionArrayKey, customAlphabet, defineDynamicComponent, defineDynamicComponents, dynamicComponentPropsToYComponentProps, dynamicComponentToYComponent, dynamicComponentToYMap, dynamicComponentsToYArray, entriesOf, existsInPath, extractIdFromArrayKey, extractPositionFromArrayKey, findInYArray, findIndexInYArray, findYComponentInArray, generateKeyBetween, getComponentPropertyPath, getComponentsSubtreeByPath, getComponentsSubtreeByRPath, getDataObjectKey, getFromPath, getFromYPath, getIndexByArrayKey, getRelativePoint, getSortedYArray, getYArrayIndexByArrayKey, getYArrayRefsByPosition, getYComponentComponentsArray, getYComponentProps, getYComponentsArrayParentComponent, insertInPath, insertYMapAfter, insertYMapBefore, insertYMapToEnd, isArrayKey, isBiblePassageComponent, isBibleQuoteComponent, isCallable, isChatMessageDelayComponent, isChatTextMessageComponent, isCheckboxComponent, isCheckboxGroupComponent, isCollectionComponent, isColumnComponent, isComputedValueComponent, isConfirmDeletionInputComponent, isContainerValue, isDateTimePickerComponent, isEmbedCodeComponent, isEmptyArray, isEmptyContainer, isEntitySelectComponent, isEqualPath, isFileUploaderComponent, isHeadingComponent, isIdArrayKey, isImageComponent, isImageUploaderComponent, isIndex, isLegacyContentComponent, isNullOrUndefined, isNumber, isNumberInputComponent, isObject, isPositionArrayKey, isPracticeComponent, isRadioGroupComponent, isRawImageUploaderComponent, isRawImagesUploaderComponent, isRepeatableCollectionComponent, isRichText, isRichTextComponent, isRichTextEditorComponent, isRowComponent, isRowSettingsComponent, isSamePath, isSelectComponent, isSimpleImageUploaderComponent, isSlugComponent, isStatementComponent, isString, isSwitchComponent, isTestComponent, isTextInputComponent, isTextareaComponent, isYArray, isYComponent, isYMap, joinPath, keysOf, makeDynamicComponentsWithPosition, moveInPath, moveInYPath, moveYMapAfter, moveYMapBefore, moveYMapToEnd, moveYMapToStart, objectToYMap, pullFromPath, pullFromYPath, pushInPath, pushInYPath, searchDynamicComponentInTree, setInPath, setInYPath, sortByPosition, sortDynamicComponents, uid, unsetPath, unsetYPath, urlAlphabet, yComponentHasComponentsYArray, yComponentToDynamicComponent };
1816
1711
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,127 +1,7 @@
1
+ import { entriesOf, isCallable, isContainerValue, isEmptyArray, isEmptyContainer, isIndex, isNullOrUndefined, isNumber, isObject, isString, keysOf } from "@pcg/predicates";
1
2
  import * as Y from "yjs";
2
3
  import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
3
4
 
4
- //#region src/assertions/basic.ts
5
- /**
6
- * Checks if the given parameter is callable (a function).
7
- * @param {unknown} fn - The function to check.
8
- * @returns {boolean} Returns true if `fn` is a function, false otherwise.
9
- * @example
10
- * isCallable(() => {}); // Returns true
11
- * isCallable('Hello'); // Returns false
12
- */
13
- const isCallable = (fn) => {
14
- return typeof fn === "function";
15
- };
16
- /**
17
- * Checks if the given value is a string.
18
- * @param {unknown} val - The value to check.
19
- * @returns {boolean} Returns true if `val` is a string, false otherwise.
20
- * @example
21
- * isString('Hello'); // Returns true
22
- * isString(123); // Returns false
23
- */
24
- const isString = (val) => typeof val === "string";
25
- /**
26
- * Checks if the given value is a number.
27
- * @param {unknown} val - The value to check.
28
- * @returns {boolean} Returns true if `val` is a number, false otherwise.
29
- * @example
30
- * isNumber(123); // Returns true
31
- * isNumber('Hello'); // Returns false
32
- */
33
- const isNumber = (val) => typeof val === "number";
34
- /**
35
- * Checks if a given value can be used as an index (a non-negative integer).
36
- * @param {unknown} value - The value to check.
37
- * @returns {boolean} Returns true if `value` can be used as an index, false otherwise.
38
- * @example
39
- * isIndex(2); // Returns true
40
- * isIndex('2'); // Returns true
41
- * isIndex(-1); // Returns false
42
- */
43
- const isIndex = (value) => {
44
- return (isNumber(value) || isString(value)) && Number(value) >= 0;
45
- };
46
- /**
47
- * Checks if the given value is null or undefined.
48
- * @param {unknown} value - The value to check.
49
- * @returns {boolean} Returns true if `value` is null or undefined, false otherwise.
50
- * @example
51
- * isNullOrUndefined(null); // Returns true
52
- * isNullOrUndefined(undefined); // Returns true
53
- * isNullOrUndefined('Hello'); // Returns false
54
- */
55
- const isNullOrUndefined = (value) => {
56
- return value === null || value === void 0;
57
- };
58
-
59
- //#endregion
60
- //#region src/assertions/containers.ts
61
- /**
62
- * Checks if the given value is an empty array.
63
- * @param {unknown} arr - The array to check.
64
- * @returns {boolean} Returns true if `arr` is an empty array, false otherwise.
65
- * @example
66
- * isEmptyArray([]); // Returns true
67
- * isEmptyArray([1, 2, 3]); // Returns false
68
- */
69
- const isEmptyArray = (arr) => {
70
- return Array.isArray(arr) && arr.length === 0;
71
- };
72
- /**
73
- * Gets the keys of the given object.
74
- * @param {T} arr - The object to get the keys from.
75
- * @returns {Array<keyof T>} Returns an array of keys of the given object.
76
- * @example
77
- * keysOf({ a: 1, b: 2 }); // Returns ['a', 'b']
78
- */
79
- const keysOf = (arr) => Object.keys(arr);
80
- /**
81
- * Gets the entries of the given object.
82
- * @param {T} arr - The object to get the entries from.
83
- * @returns {Entries<T>} Returns an array of entries of the given object.
84
- * @example
85
- * entriesOf({ a: 1, b: 2 }); // Returns [['a', 1], ['b', 2]]
86
- */
87
- const entriesOf = (arr) => Object.entries(arr);
88
- /**
89
- * Checks if the given value is an object (not an array).
90
- * @param {unknown} obj - The value to check.
91
- * @returns {boolean} Returns true if `obj` is an object, false otherwise.
92
- * @example
93
- * isObject({ a: 1 }); // Returns true
94
- * isObject([1, 2, 3]); // Returns false
95
- */
96
- const isObject = (obj) => obj !== null && !!obj && typeof obj === "object" && !Array.isArray(obj);
97
- /**
98
- * Checks if the given value is a container (an object or an array).
99
- * @param {unknown} value - The value to check.
100
- * @returns {boolean} Returns true if `value` is a container, false otherwise.
101
- * @example
102
- * isContainerValue({ a: 1 }); // Returns true
103
- * isContainerValue([1, 2, 3]); // Returns true
104
- * isContainerValue('Hello'); // Returns false
105
- */
106
- const isContainerValue = (value) => {
107
- return isObject(value) || Array.isArray(value);
108
- };
109
- /**
110
- * Checks if the given value is an empty container (an empty object or array).
111
- * @param {unknown} value - The value to check.
112
- * @returns {boolean} Returns true if `value` is an empty container, false otherwise.
113
- * @example
114
- * isEmptyContainer({}); // Returns true
115
- * isEmptyContainer([]); // Returns true
116
- * isEmptyContainer({ a: 1 }); // Returns false
117
- * isEmptyContainer([1, 2, 3]); // Returns false
118
- */
119
- const isEmptyContainer = (value) => {
120
- if (Array.isArray(value)) return value.length === 0;
121
- return isObject(value) && Object.keys(value).length === 0;
122
- };
123
-
124
- //#endregion
125
5
  //#region src/assertions/paths.ts
126
6
  /**
127
7
  * Checks if two paths are equal.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ib","fb","ia","fa","i","printPosition","newPosition","pathWithComponents: DynamicComponent[]","componentCopy: DynamicComponent","clones: (Y.XmlElement | Y.XmlText)[]","props: DynamicComponentWithPosition['props']","components","acc: Y.Map<unknown> | Y.Array<unknown>","entries: [string, unknown][]","newPosition","entries: [string, unknown][]","component: Record<string, unknown>","props: Record<string, unknown>","value"],"sources":["../src/assertions/basic.ts","../src/assertions/containers.ts","../src/assertions/paths.ts","../src/assertions/rich-text.ts","../src/assertions/yjs.ts","../src/data-objects/data-object.ts","../src/dynamic-components/fractional-indexing.ts","../src/paths/array-keys.ts","../src/paths/basic-ops.ts","../src/paths/array-ops.ts","../src/paths/constants.ts","../src/paths/tools.ts","../src/dynamic-components/registry/chats.ts","../src/dynamic-components/registry/content.ts","../src/dynamic-components/registry/forms.ts","../src/dynamic-components/registry/layout.ts","../src/dynamic-components/paths.ts","../src/dynamic-components/tools.ts","../src/dynamic-components/types.ts","../src/y-tools/y-array-keys.ts","../src/y-tools/basic-path-ops.ts","../src/y-tools/tools.ts","../src/y-tools/array-path-ops.ts","../src/y-components/tools.ts"],"sourcesContent":["/**\n * Checks if the given parameter is callable (a function).\n * @param {unknown} fn - The function to check.\n * @returns {boolean} Returns true if `fn` is a function, false otherwise.\n * @example\n * isCallable(() => {}); // Returns true\n * isCallable('Hello'); // Returns false\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isCallable = (fn: unknown): fn is (...args: any[]) => any => {\n return typeof fn === 'function';\n};\n\n/**\n * Checks if the given value is a string.\n * @param {unknown} val - The value to check.\n * @returns {boolean} Returns true if `val` is a string, false otherwise.\n * @example\n * isString('Hello'); // Returns true\n * isString(123); // Returns false\n */\nexport const isString = (val: unknown): val is string => typeof val === 'string';\n\n/**\n * Checks if the given value is a number.\n * @param {unknown} val - The value to check.\n * @returns {boolean} Returns true if `val` is a number, false otherwise.\n * @example\n * isNumber(123); // Returns true\n * isNumber('Hello'); // Returns false\n */\nexport const isNumber = (val: unknown): val is number => typeof val === 'number';\n\n/**\n * Checks if a given value can be used as an index (a non-negative integer).\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` can be used as an index, false otherwise.\n * @example\n * isIndex(2); // Returns true\n * isIndex('2'); // Returns true\n * isIndex(-1); // Returns false\n */\nexport const isIndex = (value: unknown): value is number => {\n return (isNumber(value) || isString(value)) && Number(value) >= 0;\n};\n\n/**\n * Checks if the given value is null or undefined.\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` is null or undefined, false otherwise.\n * @example\n * isNullOrUndefined(null); // Returns true\n * isNullOrUndefined(undefined); // Returns true\n * isNullOrUndefined('Hello'); // Returns false\n */\nexport const isNullOrUndefined = (value: unknown): value is undefined | null => {\n return value === null || value === undefined;\n};\n","// https://github.com/logaretm/vee-validate/blob/main/packages/shared/utils.ts\n// https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/utils/assertions.ts\n\nimport type { Entries } from 'type-fest';\n\n/**\n * Checks if the given value is an empty array.\n * @param {unknown} arr - The array to check.\n * @returns {boolean} Returns true if `arr` is an empty array, false otherwise.\n * @example\n * isEmptyArray([]); // Returns true\n * isEmptyArray([1, 2, 3]); // Returns false\n */\nexport const isEmptyArray = (arr: unknown): boolean => {\n return Array.isArray(arr) && arr.length === 0;\n};\n\n/**\n * Gets the keys of the given object.\n * @param {T} arr - The object to get the keys from.\n * @returns {Array<keyof T>} Returns an array of keys of the given object.\n * @example\n * keysOf({ a: 1, b: 2 }); // Returns ['a', 'b']\n */\nexport const keysOf = <T>(arr: T) => Object.keys(arr as unknown[]) as (keyof T)[];\n\n/**\n * Gets the entries of the given object.\n * @param {T} arr - The object to get the entries from.\n * @returns {Entries<T>} Returns an array of entries of the given object.\n * @example\n * entriesOf({ a: 1, b: 2 }); // Returns [['a', 1], ['b', 2]]\n */\nexport const entriesOf = <T>(arr: T) => Object.entries(arr as unknown[]) as Entries<T>;\n\n/**\n * Checks if the given value is an object (not an array).\n * @param {unknown} obj - The value to check.\n * @returns {boolean} Returns true if `obj` is an object, false otherwise.\n * @example\n * isObject({ a: 1 }); // Returns true\n * isObject([1, 2, 3]); // Returns false\n */\nexport const isObject = (obj: unknown): obj is Record<string, unknown> =>\n obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj);\n\n/**\n * Checks if the given value is a container (an object or an array).\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` is a container, false otherwise.\n * @example\n * isContainerValue({ a: 1 }); // Returns true\n * isContainerValue([1, 2, 3]); // Returns true\n * isContainerValue('Hello'); // Returns false\n */\nexport const isContainerValue = (value: unknown): value is Record<string, unknown> => {\n return isObject(value) || Array.isArray(value);\n};\n\n/**\n * Checks if the given value is an empty container (an empty object or array).\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` is an empty container, false otherwise.\n * @example\n * isEmptyContainer({}); // Returns true\n * isEmptyContainer([]); // Returns true\n * isEmptyContainer({ a: 1 }); // Returns false\n * isEmptyContainer([1, 2, 3]); // Returns false\n */\nexport const isEmptyContainer = (value: unknown): boolean => {\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n return isObject(value) && Object.keys(value).length === 0;\n};\n","/**\n * Checks if two paths are equal.\n * @param {(string | number)[]} path - The first path to compare.\n * @param {(string | number)[]} toPath - The second path to compare.\n * @returns {boolean} Returns true if both paths are of the same length and all corresponding elements are equal, false otherwise.\n * @example\n * isEqualPath(['items', 'id:xxx', 'name'], ['items', 'id:xxx', 'name']); // Returns true\n * isEqualPath(['items', 'id:yyy', 'name'], ['items', 'id:xxx', 'name']); // Returns false\n */\nexport const isEqualPath = (path: (string | number)[], toPath: (string | number)[]) => {\n return path.length === toPath.length && path.every((v, index) => v === toPath[index]);\n};\n","import { RichText } from '@/data-objects/rich-text.js';\n\n/**\n * Checks if the given value is a RichText object.\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` is a RichText object, false otherwise.\n * @example\n * isRichText({ id: 'xx', ... type: 'RichText' }); // Returns true\n */\nexport const isRichText = (value: unknown): value is RichText => {\n if (typeof value === 'object' && value !== null) {\n return 'type' in value && value.type === 'RichText';\n }\n\n return false;\n};\n","import * as Y from 'yjs';\n\n/**\n * Checks if the given value is a Yjs Map.\n * @param {unknown} yMap - The value to check.\n * @returns {boolean} Returns true if `yMap` is a Yjs Map, false otherwise.\n * @example\n * const yMap = new Y.Map();\n * isYMap(yMap); // Returns true\n */\nexport const isYMap = <T = unknown>(yMap: unknown): yMap is Y.Map<T> => {\n return yMap instanceof Y.Map;\n};\n\n/**\n * Checks if the given value is a Yjs Array.\n * @param {unknown} yArray - The value to check.\n * @returns {boolean} Returns true if `yArray` is a Yjs Array, false otherwise.\n * @example\n * const yArray = new Y.Array();\n * isYArray(yArray); // Returns true\n */\nexport const isYArray = <T = unknown>(yArray: unknown): yArray is Y.Array<T> => {\n return yArray instanceof Y.Array;\n};\n","/**\n * The BaseDataObject interface represents a basic structure of a data object.\n * It includes an `id` and a `type` string.\n *\n * @interface\n * @example\n * {\n * id: 'xxx',\n * tiptap: { ... },\n * type: 'RichText'\n * }\n */\nexport interface BaseDataObject {\n /**\n * The unique identifier for the data object.\n */\n id: string;\n\n /**\n * The type of the data object. It's used for differentiating different types of data objects.\n */\n type: string;\n}\n\n/**\n * Gets the key of the data object. The key is a string combining `type` and `id` of the data object, separated by a colon.\n * @param {BaseDataObject} dataObject - The data object to get the key from.\n * @returns {string} Returns the key of the data object.\n * @example\n * getDataObjectKey({ id: 'xxx', type: 'RichText' }); // Returns 'RichText:xxx'\n */\nexport const getDataObjectKey = (dataObject: BaseDataObject): string => {\n return `${dataObject.type}:${dataObject.id}`;\n};\n","// License: CC0 (no rights reserved).\n\n// This is based on https://observablehq.com/@dgreensp/implementing-fractional-indexing\n\nexport const BASE_62_DIGITS =\n '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\nconst SMALLEST_INTEGER = 'A00000000000000000000000000';\n\nconst INTEGER_ZERO = 'a0';\n\n// `a` may be empty string, `b` is null or non-empty string.\n// `a < b` lexicographically if `b` is non-null.\n// no trailing zeros allowed.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string} a\n * @param {string | null} b\n * @param {string} digits\n * @returns {string}\n */\nconst midpoint = (a: string, b: string | null, digits: string): string => {\n if (b !== null && a >= b) {\n throw new Error(a + ' >= ' + b);\n }\n if (a.slice(-1) === '0' || (b && b.slice(-1) === '0')) {\n throw new Error('trailing zero');\n }\n if (b) {\n // remove longest common prefix. pad `a` with 0s as we\n // go. note that we don't need to pad `b`, because it can't\n // end before `a` while traversing the common prefix.\n let n = 0;\n while ((a[n] || '0') === b[n]) {\n n++;\n }\n if (n > 0) {\n return b.slice(0, n) + midpoint(a.slice(n), b.slice(n), digits);\n }\n }\n // first digits (or lack of digit) are different\n const digitA = a ? digits.indexOf(a[0]) : 0;\n const digitB = b !== null ? digits.indexOf(b[0]) : digits.length;\n if (digitB - digitA > 1) {\n const midDigit = Math.round(0.5 * (digitA + digitB));\n\n return digits[midDigit];\n } else {\n // first digits are consecutive\n if (b && b.length > 1) {\n return b.slice(0, 1);\n }\n\n // `b` is null or has length 1 (a single digit).\n // the first digit of `a` is the previous digit to `b`,\n // or 9 if `b` is null.\n // given, for example, midpoint('49', '5'), return\n // '4' + midpoint('9', null), which will become\n // '4' + '9' + midpoint('', null), which is '495'\n return digits[digitA] + midpoint(a.slice(1), null, digits);\n }\n};\n\n/**\n * @param {string} int\n * @return {void}\n */\n\nconst validateInteger = (int: string) => {\n if (int.length !== getIntegerLength(int[0])) {\n throw new Error('invalid integer part of order key: ' + int);\n }\n};\n\n/**\n * @param {string} head\n * @return {number}\n */\n\nconst getIntegerLength = (head: string): number => {\n if (head >= 'a' && head <= 'z') {\n return head.charCodeAt(0) - 'a'.charCodeAt(0) + 2;\n } else if (head >= 'A' && head <= 'Z') {\n return 'Z'.charCodeAt(0) - head.charCodeAt(0) + 2;\n } else {\n throw new Error('invalid order key head: ' + head);\n }\n};\n\n/**\n * @param {string} key\n * @return {string}\n */\n\nconst getIntegerPart = (key: string) => {\n const integerPartLength = getIntegerLength(key[0]);\n if (integerPartLength > key.length) {\n throw new Error('invalid order key: ' + key);\n }\n\n return key.slice(0, integerPartLength);\n};\n\n/**\n * @param {string} key\n * @return {void}\n */\n\nconst validateOrderKey = (key: string) => {\n if (key === SMALLEST_INTEGER) {\n throw new Error('invalid order key: ' + key);\n }\n // getIntegerPart will throw if the first character is bad,\n // or the key is too short. we'd call it to check these things\n // even if we didn't need the result\n const i = getIntegerPart(key);\n const f = key.slice(i.length);\n if (f.slice(-1) === '0') {\n throw new Error('invalid order key: ' + key);\n }\n};\n\n// note that this may return null, as there is a largest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\nconst incrementInteger = (x: string, digits: string) => {\n validateInteger(x);\n const [head, ...digs] = x.split('');\n let carry = true;\n for (let i = digs.length - 1; carry && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) + 1;\n if (d === digits.length) {\n digs[i] = '0';\n } else {\n digs[i] = digits[d];\n carry = false;\n }\n }\n if (carry) {\n if (head === 'Z') {\n return 'a0';\n }\n if (head === 'z') {\n return null;\n }\n const h = String.fromCharCode(head.charCodeAt(0) + 1);\n if (h > 'a') {\n digs.push('0');\n } else {\n digs.pop();\n }\n\n return h + digs.join('');\n } else {\n return head + digs.join('');\n }\n};\n\n// note that this may return null, as there is a smallest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\n\nconst decrementInteger = (x: string, digits: string) => {\n validateInteger(x);\n const [head, ...digs] = x.split('');\n let borrow = true;\n for (let i = digs.length - 1; borrow && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) - 1;\n if (d === -1) {\n digs[i] = digits.slice(-1);\n } else {\n digs[i] = digits[d];\n borrow = false;\n }\n }\n if (borrow) {\n if (head === 'a') {\n return 'Z' + digits.slice(-1);\n }\n if (head === 'A') {\n return null;\n }\n const h = String.fromCharCode(head.charCodeAt(0) - 1);\n if (h < 'Z') {\n digs.push(digits.slice(-1));\n } else {\n digs.pop();\n }\n\n return h + digs.join('');\n } else {\n return head + digs.join('');\n }\n};\n\n// `a` is an order key or null (START).\n// `b` is an order key or null (END).\n// `a < b` lexicographically if both are non-null.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string | null} a\n * @param {string | null} b\n * @param {string=} digits\n * @return {string}\n */\nexport const generateKeyBetween = (a: string | null, b: string | null, digits = BASE_62_DIGITS) => {\n if (a !== null) {\n validateOrderKey(a);\n }\n if (b !== null) {\n validateOrderKey(b);\n }\n if (a !== null && b !== null && a >= b) {\n throw new Error(a + ' >= ' + b);\n }\n if (a === null) {\n if (b === null) {\n return INTEGER_ZERO;\n }\n\n const ib = getIntegerPart(b);\n const fb = b.slice(ib.length);\n if (ib === SMALLEST_INTEGER) {\n return ib + midpoint('', fb, digits);\n }\n if (ib < b) {\n return ib;\n }\n const res = decrementInteger(ib, digits);\n if (res === null) {\n throw new Error('cannot decrement any more');\n }\n\n return res;\n }\n\n if (b === null) {\n const ia = getIntegerPart(a);\n const fa = a.slice(ia.length);\n const i = incrementInteger(ia, digits);\n\n return i === null ? ia + midpoint(fa, null, digits) : i;\n }\n\n const ia = getIntegerPart(a);\n const fa = a.slice(ia.length);\n const ib = getIntegerPart(b);\n const fb = b.slice(ib.length);\n if (ia === ib) {\n return ia + midpoint(fa, fb, digits);\n }\n const i = incrementInteger(ia, digits);\n if (i === null) {\n throw new Error('cannot increment any more');\n }\n if (i < b) {\n return i;\n }\n\n return ia + midpoint(fa, null, digits);\n};\n\n/**\n * same preconditions as generateKeysBetween.\n * n >= 0.\n * Returns an array of n distinct keys in sorted order.\n * If a and b are both null, returns [a0, a1, ...]\n * If one or the other is null, returns consecutive \"integer\"\n * keys. Otherwise, returns relatively short keys between\n * a and b.\n * @param {string | null} a\n * @param {string | null} b\n * @param {number} n\n * @param {string} digits\n * @return {string[]}\n */\nexport const generateNKeysBetween = (a: string | null, b: string | null, n: number, digits = BASE_62_DIGITS): string[] => {\n if (n === 0) {\n return [];\n }\n if (n === 1) {\n return [generateKeyBetween(a, b, digits)];\n }\n if (b === null) {\n let c = generateKeyBetween(a, b, digits);\n const result = [c];\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(c, b, digits);\n result.push(c);\n }\n\n return result;\n }\n if (a === null) {\n let c = generateKeyBetween(a, b, digits);\n const result = [c];\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(a, c, digits);\n result.push(c);\n }\n result.reverse();\n\n return result;\n }\n const mid = Math.floor(n / 2);\n const c = generateKeyBetween(a, b, digits);\n\n return [\n ...generateNKeysBetween(a, c, mid, digits),\n c,\n ...generateNKeysBetween(c, b, n - mid - 1, digits),\n ];\n};\n","import { isObject, isString } from '@/assertions/index.js';\n\n/**\n * In the system you are using, two types of keys are used to identify elements in an array: ID keys and position keys.\n * These keys provide a flexible and robust way to refer to specific elements in an array, particularly when dealing with arrays of objects.\n *\n * 1. **ID Keys:**\n * These keys have a prefix of 'id:' and are followed by the unique identifier of an object in the array.\n * For example, in your array `items: [{ id: 'xxx', name: 'John' }]`, you can refer to the object with `id: 'xxx'` using the ID key 'id:xxx'.\n * This is particularly useful when you have a unique identifier for each object in your array.\n * With this, even if objects move around in the array, you can always accurately refer to a specific object using its unique ID.\n *\n * 2. **Position Keys:**\n * These keys have a prefix of 'pos:' and are followed by a position indicator.\n * Position keys provide a way to refer to an object in an array based on its position rather than its content.\n * This can be useful when the position of an object in an array is significant and you want to refer to an object based on where it is in the array.\n *\n * In your path system, you can use either type of key as part of the path to refer to specific elements in an array.\n * For example, if you have an object like `{ items: [{ id: 'xxx', name: 'John' }] }`,\n * you can refer to the name of the first item in the array using either an ID key or a position key in the path:\n *\n * - Using an ID key: `['items', 'id:xxx', 'name']`\n * - Using a position key: `['items', 'pos:0', 'name']`\n *\n * This system of using ID and position keys in paths gives you a powerful and flexible way to refer to specific elements in complex, nested objects.\n */\n\nexport const POSITION_ARRAY_KEY_PREFIX = 'pos:';\n\n/**\n * Checks if the given key is a position array key.\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is a position array key, false otherwise.\n * @example\n * isPositionArrayKey('pos:0'); // Returns true\n * isPositionArrayKey('id:0'); // Returns false\n */\nexport const isPositionArrayKey = (key: unknown): key is string => {\n return isString(key) && key.startsWith(POSITION_ARRAY_KEY_PREFIX);\n};\n\n/**\n * Creates a position array key.\n * @param {string} position - The position to create the key for.\n * @returns {string} Returns the created position array key.\n * @example\n * createPositionArrayKey('0'); // Returns 'pos:0'\n */\nexport const createPositionArrayKey = (position: string) => {\n return `${POSITION_ARRAY_KEY_PREFIX}${position}`;\n};\n\n/**\n * Extracts the position from a position array key.\n * @param {string} key - The position array key to extract the position from.\n * @returns {string} Returns the extracted position.\n * @example\n * extractPositionFromArrayKey('pos:0'); // Returns '0'\n */\nexport const extractPositionFromArrayKey = (key: string): string => {\n if (!isPositionArrayKey(key)) {\n throw new Error(`Invalid array key ${key}. Must be \"pos:xxxxx\"`);\n }\n\n return key.split(POSITION_ARRAY_KEY_PREFIX)[1];\n};\n\n/* ID KEY */\nexport const ID_PATH_KEY_PREFIX = 'id:';\n\n/**\n * Checks if the given key is an ID array key.\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is an ID array key, false otherwise.\n * @example\n * isIdArrayKey('id:123'); // Returns true\n * isIdArrayKey('pos:0'); // Returns false\n */\nexport const isIdArrayKey = (key: unknown): key is string => {\n return isString(key) && key.startsWith(ID_PATH_KEY_PREFIX);\n};\n\n/**\n * Creates an ID array key.\n * @param {string} id - The ID to create the key for.\n * @returns {string} Returns the created ID array key.\n * @example\n * createIdArrayKey('123'); // Returns 'id:123'\n */\nexport const createIdArrayKey = (id: string) => {\n return `${ID_PATH_KEY_PREFIX}${id}`;\n};\n\n/**\n * Extracts the ID from an ID array key.\n * @param {string} key - The ID array key to extract the ID from.\n * @returns {string} Returns the extracted ID.\n * @example\n * extractIdFromArrayKey('id:123'); // Returns '123'\n */\nexport const extractIdFromArrayKey = (key: string): string => {\n if (!isIdArrayKey(key)) {\n throw new Error(`Invalid array key ${key}. Must be \"id:xxxxx\"`);\n }\n\n return key.split(ID_PATH_KEY_PREFIX)[1];\n};\n\n/* ARRAY KEYS */\n\n/**\n * Checks if the given key is an array key (either a position array key or an ID array key).\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is an array key, false otherwise.\n * @example\n * isArrayKey('id:123'); // Returns true\n * isArrayKey('pos:0'); // Returns true\n * isArrayKey('abc'); // Returns false\n */\nexport const isArrayKey = (key: unknown): key is string => isString(key) && (isPositionArrayKey(key) || isIdArrayKey(key));\n\n/**\n * Extracts the index from an array key in a given array.\n * @param {unknown} array - The array to extract the index from.\n * @param {string} key - The array key to extract the index from.\n * @returns {number} Returns the extracted index.\n * @example\n * getIndexByArrayKey(['a', 'b', 'c'], 'pos:1'); // Returns 1\n */\nexport const getIndexByArrayKey = (array: unknown, key: string): number => {\n if (!Array.isArray(array)) {\n console.error(`Non-array type`, array);\n\n throw new Error(`Can't use array key in non array type (${key})`);\n }\n\n if (!isArrayKey(key)) {\n throw new Error(`Unknown array key type (${key})`);\n }\n\n if (array.length === 0) {\n return 0;\n }\n\n if (isIdArrayKey(key)) {\n const id = extractIdFromArrayKey(key);\n const index = array.findIndex((it) => isObject(it) && it.id === id);\n if (index === -1) {\n throw new Error(`Can't find index by id ${id} (${key})`);\n }\n\n return index;\n } else if (isPositionArrayKey(key)) {\n const position = extractPositionFromArrayKey(key);\n const index = array.findIndex((it) => it.position === position);\n if (index === -1) {\n throw new Error(`Can't find index by position ${position} (${key})`);\n }\n\n return index;\n }\n\n return 0;\n};\n","// Paths is an array with keys and indexes that represent a path to a value in a deep object.\n// For example, for the object { items: [{ name: 'John' }]} the path to the first item name is ['items', 0, 'name'].\n\nimport {\n isContainerValue, isIndex, isNullOrUndefined, isObject,\n} from '@/assertions/index.js';\n\nimport { getIndexByArrayKey, isArrayKey } from './array-keys.js';\nimport { NestedRecord } from './types.js';\n\n/**\n * Gets a nested property value from an object using a path.\n * @param {NestedRecord | undefined} object - The object to get the value from.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @returns {TValue | undefined} Returns the value at the specified path in the object.\n * @example\n * getFromPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns 'John'\n */\nexport const getFromPath = <TValue = unknown>(object: NestedRecord | undefined, path: (string | number)[]): TValue | undefined => {\n if (!object) {\n return;\n }\n\n if (path.length === 0) {\n return object as TValue;\n }\n\n const resolvedValue = path\n .reduce((acc, propKey) => {\n const key = isArrayKey(propKey) ? getIndexByArrayKey(acc, propKey) : propKey;\n\n if (isContainerValue(acc) && key in acc) {\n return acc[key];\n }\n\n return;\n }, object as unknown);\n\n return resolvedValue as TValue | undefined;\n};\n\n/**\n * Sets a nested property value in a path, creates the path properties if they don't exist.\n * @param {NestedRecord} object - The object to set the value in.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @param {unknown} value - The value to set.\n * @example\n * let obj = { items: [{ name: 'John' }] };\n * setInPath(obj, ['items', 0, 'name'], 'Jane'); // obj is now { items: [{ name: 'Jane' }] }\n */\nexport const setInPath = (object: NestedRecord, path: (string | number)[], value: unknown): void => {\n let acc = object;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getIndexByArrayKey(acc, rawKey) : rawKey;\n\n if (Array.isArray(acc)) {\n const index = Number(key);\n\n // Last key, set it\n if (i === path.length - 1) {\n acc[index] = value;\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!(index in acc) || isNullOrUndefined(acc[index])) {\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n // container can be either an object or an array depending on the next key if it exists\n acc[index] = isIndex(nextKey) ? [] : {\n };\n }\n\n acc = acc[index] as Record<string, unknown>;\n } else {\n // Last key, set it\n if (i === path.length - 1) {\n acc[key] = value;\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!(key in acc) || isNullOrUndefined(acc[key])) {\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n // container can be either an object or an array depending on the next key if it exists\n acc[key] = isIndex(nextKey) ? [] : {\n };\n }\n\n acc = acc[key] as Record<string, unknown>;\n }\n }\n};\n\nconst unset = (object: Record<string, unknown> | unknown[], key: string | number) => {\n if (Array.isArray(object) && isIndex(key)) {\n object.splice(Number(key), 1);\n\n return;\n }\n\n if (isObject(object)) {\n delete object[key];\n }\n};\n\n/**\n * Removes a nested property from an object using a path.\n * @param {NestedRecord} object - The object to remove the value from.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @example\n * let obj = { items: [{ name: 'John' }] };\n * unsetPath(obj, ['items', 0, 'name']); // obj is now { items: [{}] }\n */\nexport const unsetPath = (object: NestedRecord, path: (string | number)[]): void => {\n let acc = object;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getIndexByArrayKey(acc, rawKey) : rawKey;\n\n // Last key, unset it\n if (i === path.length - 1) {\n unset(acc, key);\n break;\n }\n\n if (Array.isArray(acc)) {\n const index = Number(key);\n\n // Key does not exist, exit\n if (!(key in acc) || isNullOrUndefined(acc[index])) {\n break;\n }\n\n acc = acc[index] as Record<string, unknown>;\n } else {\n // Key does not exist, exit\n if (!(key in acc) || isNullOrUndefined(acc[key])) {\n break;\n }\n\n acc = acc[key] as Record<string, unknown>;\n }\n }\n};\n\n/** Checks if a nested property exists in an object using a path.\n * @param {NestedRecord | undefined} object - The object to check the value in.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @returns {boolean} Returns true if the value exists at the specified path, false otherwise.\n * @example\n * existsInPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns true\n * existsInPath({ items: [{ name: 'John' }] }, ['items', 1, 'name']); // Returns false\n */\nexport const existsInPath = (object: NestedRecord | undefined, path: (string | number)[]): boolean => {\n return getFromPath(object, path) !== undefined;\n};\n\n/** * Compares two paths for equality.\n * @param {(string | number)[]} pathA - The first path to compare.\n * @param {(string | number)[]} pathB - The second path to compare.\n * @returns {boolean} Returns true if the paths are equal, false otherwise.\n * @example\n * isSamePath(['items', 0, 'name'], ['items', 0, 'name']); // Returns true\n * isSamePath(['items', 0, 'name'], ['items', 1, 'name']); // Returns false\n */\nexport const isSamePath = (pathA: (string | number)[], pathB: (string | number)[]): boolean => {\n if (pathA.length !== pathB.length) {\n return false;\n }\n\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] !== pathB[i]) {\n return false;\n }\n }\n\n return true;\n};\n","import { isIndex, isObject } from '@/assertions/index.js';\nimport { generateKeyBetween } from '@/dynamic-components/fractional-indexing.js';\n\nimport { getIndexByArrayKey, isArrayKey } from './array-keys.js';\nimport { getFromPath, setInPath } from './basic-ops.js';\nimport { NestedRecord } from './types.js';\n\n/**\n * Pushes a value into a nested array in an object using a path.\n * @param {NestedRecord} object - The object to push the value into.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {unknown} value - The value to push.\n * @example\n * let obj = { items: ['John'] };\n * pushInPath(obj, ['items'], 'Jane'); // obj is now { items: ['John', 'Jane'] }\n */\nexport const pushInPath = (object: NestedRecord, path: (string | number)[], value: unknown) => {\n const array = getFromPath(object, path);\n if (!Array.isArray(array)) {\n setInPath(object, path, [value]);\n } else {\n array.push(value);\n }\n};\n\n/**\n * Inserts values into a nested array in an object at a specified index or key using a path.\n * @param {NestedRecord} object - The object to insert the values into.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {string | number} keyOrIndex - The index or key at which to insert the values.\n * @param {unknown[]} values - The values to insert.\n * @example\n * let obj = { items: ['John', 'Jane'] };\n * insertInPath(obj, ['items'], 1, ['Joe']); // obj is now { items: ['John', 'Joe', 'Jane'] }\n */\nexport const insertInPath = (object: NestedRecord, path: (string | number)[], keyOrIndex: string | number, values: unknown[]) => {\n const array = getFromPath(object, path) as unknown[];\n\n if (Array.isArray(array)) {\n if (isIndex(keyOrIndex)) {\n array.splice(keyOrIndex, 0, ...values);\n } else if (isArrayKey(keyOrIndex)) {\n const index = getIndexByArrayKey(array, keyOrIndex);\n array.splice(index, 0, ...values);\n }\n }\n};\n\n/**\n * Removes a value from a nested array in an object at a specified index or array key using a path.\n * @param {NestedRecord} object - The object to remove the value from.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {string | number} key - The index or key at which to remove the value.\n * @example\n * let obj = { items: ['John', 'Joe', 'Jane'] };\n * pullFromPath(obj, ['items'], 1); // obj is now { items: ['John', 'Jane'] }\n */\nexport const pullFromPath = (object: NestedRecord, path: (string | number)[], key: string | number) => {\n const array = getFromPath(object, path) as unknown[];\n\n if (Array.isArray(array)) {\n if (isIndex(key)) {\n array.splice(key, 1);\n } else if (isArrayKey(key)) {\n const index = getIndexByArrayKey(array, key);\n array.splice(index, 1);\n }\n }\n};\n\nconst printPosition = (array: { position?: string }[]) => array.map((it) => isObject(it) ? it.position ?? 'no-position' : 'not-object');\n\n/**\n * Moves an item to a new position relative to another item in the array or object at the specified path.\n *\n * @example\n * moveInYPath(values, ['components'], 'a0', 'b1', 'after');\n */\nexport const moveInPath = (\n object: NestedRecord,\n path: (string | number)[],\n oldPosition: string,\n relativePosition: string,\n insert: 'before' | 'after',\n) => {\n const array = getFromPath(object, path);\n if (!Array.isArray(array)) {\n throw new Error(`Can't move. Target item is not array in path ${JSON.stringify(path)}`);\n }\n\n const item = array.find((it) => isObject(it) && it.position === oldPosition);\n const relativeItemIndex = array.findIndex((it) => isObject(it) && it.position === relativePosition);\n\n if (!isObject(item)) {\n throw new Error(`Can't move. Item in position ${oldPosition} not found. ${printPosition(array)}`);\n }\n\n if (relativeItemIndex === -1) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} not found. ${printPosition(array)}`);\n }\n\n const relativeItem = array[relativeItemIndex];\n if (!isObject(relativeItem)) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} must be an object. ${printPosition(array)}`);\n }\n\n if (insert === 'before') {\n const left = array[relativeItemIndex - 1];\n const leftPosition = isObject(left) ? left.position as string ?? null : null;\n\n const newPosition = generateKeyBetween(leftPosition, relativeItem.position as string);\n item.position = newPosition;\n\n return newPosition;\n }\n\n const right = array[relativeItemIndex + 1];\n const rightPosition = isObject(right) ? right.position as string ?? null : null;\n\n const newPosition = generateKeyBetween(relativeItem.position as string, rightPosition);\n item.position = newPosition;\n\n return newPosition;\n};\n","export const PATH_REGEXP = /\\.|\\[(\\d+)\\]/;\n","import { isString } from '@/assertions/index.js';\n\n/**\n * Joins a path with additional items.\n * @param {(string | number)[]} path - The initial path.\n * @param {...(string | number)[]} items - The items to add to the path.\n * @returns {(string | number)[]} Returns the joined path.\n * @throws {Error} If `path` is not an array or if any of `items` are not a string or an integer.\n * @example\n * joinPath(['items', 'id:xxx'], 'name'); // Returns ['items', 'id:xxx', 'name']\n */\nexport const joinPath = (path: (string | number)[], ...items: (string | number)[]) => {\n if (!Array.isArray(path)) {\n throw new Error(`path must be array: ${path}`);\n }\n\n for (const item of items) {\n if (!isString(item) && !Number.isInteger(item)) {\n throw new Error(`Invalid path item: ${item}`);\n }\n }\n\n return path.concat(items);\n};\n\n/**\n * Compares two fractional-based position strings for sorting.\n * @param {string} aPosition - The first fractional-based position string.\n * @param {string} bPosition - The second fractional-based position string.\n * @returns {number} Returns -1 if `aPosition` comes before `bPosition`, 1 if `aPosition` comes after `bPosition`, or 0 if they are equal.\n * @example\n * sortByPosition('a1', 'a2'); // Returns -1\n */\nexport const sortByPosition = (aPosition: string, bPosition: string) => {\n if (aPosition < bPosition) {\n return -1;\n } else if (aPosition > bPosition) {\n return 1;\n }\n\n return 0;\n};\n","import { RichText } from '../../data-objects/rich-text.js';\nimport { DynamicComponent } from '../types.js';\n\n/* Text Message */\nexport interface DChatTextMessage extends DynamicComponent {\n component: 'chat-text-message';\n props: {\n content: RichText;\n };\n}\n\nexport const isChatTextMessageComponent = (component: DynamicComponent): component is DChatTextMessage => component.component === 'chat-text-message';\n\n/* Message Delay */\nexport interface DChatMessageDelay extends DynamicComponent {\n component: 'chat-message-delay';\n props: {\n delay: number;\n typing: boolean;\n };\n}\n\n// eslint-disable-next-line max-len\nexport const isChatMessageDelayComponent = (component: DynamicComponent): component is DChatMessageDelay => component.component === 'chat-message-delay';\n","import { RichText } from '../../data-objects/rich-text.js';\nimport { DynamicComponent } from '../types.js';\n\n/* TEXT INPUT */\nexport interface DRichText extends DynamicComponent {\n component: 'rich-text';\n props: {\n content: RichText;\n };\n}\n\nexport const isRichTextComponent = (component: DynamicComponent): component is DRichText => component.component === 'rich-text';\n\n/* RowSettings */\nexport interface DEmbedCode extends DynamicComponent {\n component: 'embed-code';\n props: {\n js?: string;\n css?: string;\n html?: string;\n visible?: string;\n };\n}\n\nexport const isEmbedCodeComponent = (component: DynamicComponent): component is DEmbedCode => {\n return component.component === 'embed-code';\n};\n\n/* Image */\nexport interface DImage extends DynamicComponent {\n component: 'embed-code';\n props: {\n imageId: string;\n };\n}\n\nexport const isImageComponent = (component: DynamicComponent): component is DImage => component.component === 'image';\n\n/* Legacy Content */\nexport interface DLegacyContent extends DynamicComponent {\n component: 'legacy-content';\n props: {\n html: string;\n };\n}\n\nexport const isLegacyContentComponent = (component: DynamicComponent): component is DLegacyContent => component.component === 'legacy-content';\n\n/* Bible Quote */\nexport interface DBibleQuote extends DynamicComponent {\n component: 'bible-quote';\n props: {\n verseId: string;\n };\n}\n\nexport const isBibleQuoteComponent = (component: DynamicComponent): component is DBibleQuote => component.component === 'bible-quote';\n\n/* Bible Passage */\nexport interface DBiblePassage extends DynamicComponent {\n component: 'bible-passage';\n props: {\n passage: string;\n };\n}\n\nexport const isBiblePassageComponent = (component: DynamicComponent): component is DBiblePassage => component.component === 'bible-passage';\n\n/* TESTS */\n\nexport interface TestItemVariant {\n id: string;\n content: RichText;\n feedback?: RichText;\n correct?: boolean;\n}\n\nexport interface TestItem {\n id: string;\n content: RichText;\n variants: TestItemVariant[];\n}\n\nexport interface DTest extends DynamicComponent {\n component: 'test';\n props: {\n title?: string;\n items: TestItem[];\n milestone?: string;\n };\n}\n\nexport const isTestComponent = (component: DynamicComponent): component is DTest => component.component === 'test';\n\nexport interface DStatement extends DynamicComponent {\n component: 'statement';\n props: {\n content: RichText;\n };\n}\n\nexport const isStatementComponent = (component: DynamicComponent): component is DStatement => component.component === 'statement';\n\nexport interface DPractice extends DynamicComponent {\n component: 'practice';\n props: {\n title?: string;\n content: RichText;\n\n /**\n * Date when the practice should be checked in ISO 8601 format\n * @example '2023-10-01T00:08:00Z'\n */\n checkAt?: string;\n };\n}\n\nexport const isPracticeComponent = (component: DynamicComponent): component is DPractice => component.component === 'practice';\n","import { DynamicComponent, ValidationRules } from '../types.js';\n\nexport type ISizeType = 'middle' | 'large';\n\nexport enum IImageRenditionType {\n ORIGINAL = 'ORIGINAL',\n MAIN_2X = 'MAIN_2X',\n MAIN = 'MAIN',\n SMALL = 'SMALL',\n MAIN_LEGACY = 'MAIN_LEGACY',\n}\n\nexport interface IRenditionOptions {\n width: number;\n height: number;\n type: IImageRenditionType;\n mimeType?: string;\n quality?: number;\n}\n\n/* HIDDEN INPUT */\nexport interface DHiddenInput extends DynamicComponent {\n component: 'hidden-input';\n props: {\n name?: string;\n rules?: ValidationRules;\n testId?: string;\n };\n}\n\n/* COMPUTED VALUE */\nexport interface DComputedValue extends DynamicComponent {\n component: 'computed-value';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n type: 'string' | 'number';\n expression: string;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isComputedValueComponent = (component: DynamicComponent): component is DComputedValue => component.component === 'computed-value';\n\n/* TEXT INPUT */\nexport interface DTextInput extends DynamicComponent {\n component: 'text-input';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n clearable?: boolean;\n maska?: string;\n disabled?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isTextInputComponent = (component: DynamicComponent): component is DTextInput => component.component === 'text-input';\n\n/* CONFIRM DELATION INPUT */\nexport interface DConfirmDeletionInput extends DynamicComponent {\n component: 'confirm-deletion-input';\n props: {\n title?: string;\n text?: string;\n keyWord: string;\n testId?: string;\n };\n}\n\nexport const isConfirmDeletionInputComponent = (component: DynamicComponent):\n component is DConfirmDeletionInput => component.component === 'confirm-deletion-input';\n\n/* TEXTAREA */\nexport interface DTextarea extends DynamicComponent {\n component: 'textarea';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n rows?: number;\n autosize?: boolean;\n lineBreak?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isTextareaComponent = (component: DynamicComponent): component is DTextarea => component.component === 'textarea';\n\n/* HEADING */\nexport interface DHeading extends DynamicComponent {\n component: 'heading';\n props: {\n text: string;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isHeadingComponent = (component: DynamicComponent): component is DHeading => component.component === 'heading';\n\n/* RICH TEXT EDITOR */\nexport interface DRichTextEditor extends DynamicComponent {\n component: 'rich-text-editor';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n minHeight?: number;\n maxLength?: number;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isRichTextEditorComponent = (component: DynamicComponent): component is DRichTextEditor => component.component === 'rich-text-editor';\n\n/* DATE */\nexport interface DDateTimePicker extends DynamicComponent {\n component: 'date-time-picker';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n type?: 'year' | 'month' | 'date' | 'dates' | 'week' | 'datetime' | 'datetimerange' | 'daterange' | 'monthrange';\n readonly?: boolean;\n format?: string;\n clearable?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isDateTimePickerComponent = (component: DynamicComponent): component is DDateTimePicker => {\n return component.component === 'date-time-picker';\n};\n\n/* NUMBER */\nexport interface DNumberInput extends DynamicComponent {\n component: 'number-input';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n autosize?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isNumberInputComponent = (component: DynamicComponent): component is DNumberInput => {\n return component.component === 'number-input';\n};\n\n/* SLUG */\nexport interface DSlug extends DynamicComponent {\n component: 'slug';\n props: {\n name?: string;\n source?: string;\n maxLength?: number;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isSlugComponent = (component: DynamicComponent): component is DSlug => {\n return component.component === 'slug';\n};\n\n/* Image Uploader DynamicComponent */\nexport interface DImageUploader extends DynamicComponent {\n component: 'image-uploader';\n props: {\n name?: string;\n label?: string;\n renditions: {\n id: string;\n position: string;\n width: number;\n height: number;\n type: IImageRenditionType;\n }[];\n btnText?: string;\n size?: ISizeType;\n rounded?: ISizeType;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n tooltipContent?: string;\n hideTooltip?: boolean;\n maxFileSize?: number;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isImageUploaderComponent = (component: DynamicComponent): component is DImageUploader => {\n return component.component === 'image-uploader';\n};\n\nexport interface DRawImageUploader extends DynamicComponent {\n component: 'raw-image-uploader';\n props: {\n name?: string;\n label?: string;\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n hideTooltip?: boolean;\n tooltipContent?: string;\n maxFileSize?: number;\n visible?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isRawImageUploaderComponent = (component: DynamicComponent): component is DRawImageUploader => {\n return component.component === 'raw-image-uploader';\n};\nexport interface DRawImagesUploader extends DynamicComponent {\n component: 'raw-images-uploader';\n props: {\n name?: string;\n label?: string;\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n tooltipContent?: string;\n hideTooltip?: boolean;\n maxFileSize?: number;\n visible?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n max?: number;\n };\n testId?: string;\n };\n}\n\nexport const isRawImagesUploaderComponent = (component: DynamicComponent): component is DRawImagesUploader => {\n return component.component === 'raw-images-uploader';\n};\n\nexport interface DSimpleImageUploader extends DynamicComponent {\n component: 'simple-image-uploader';\n props: {\n name?: string;\n label?: string;\n rendition: {\n width: number;\n height: number;\n type: IImageRenditionType;\n };\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n width: number;\n height: number;\n hideTooltip?: boolean;\n tooltipContent?: string;\n maxFileSize?: number;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isSimpleImageUploaderComponent = (component: DynamicComponent): component is DSimpleImageUploader => {\n return component.component === 'simple-image-uploader';\n};\n\n/* UPLOAD */\n// export interface DUpload extends DynamicComponent {\n// component: 'upload';\n// props: {\n// fileType: string;\n// listType?: 'text' | 'picture' | 'picture-card';\n// limit?: number;\n// multiple?: boolean;\n// rules?: {\n// required?: boolean;\n// };\n// };\n// }\n\n/* MONACO */\n// export interface DMonaco extends DynamicComponent {\n// component: 'monaco';\n// props: {\n// height?: number;\n// rules?: {\n// required?: boolean;\n// };\n// };\n// }\n\n/* CONTENTFLOW */\n// export interface DDesigner extends DynamicComponent {\n// component: 'designer';\n// props: {\n// name?: string;\n// };\n// }\n\n/* RADIO GROUP */\nexport interface DRadioGroup extends DynamicComponent {\n component: 'radio-group';\n props: {\n name?: string;\n label?: string;\n cols?: number;\n direction?: 'col' | 'row';\n items: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n }[];\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isRadioGroupComponent = (component: DynamicComponent): component is DRadioGroup => {\n return component.component === 'radio-group';\n};\n\n/* SELECT */\nexport interface DSelect extends DynamicComponent {\n component: 'select';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n clearable?: boolean;\n options: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n imageUrl?: string;\n disabled?: boolean;\n }[];\n readonly?: boolean;\n multiple?: boolean;\n rules?: {\n required?: boolean;\n max?: number;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isSelectComponent = (cmp: DynamicComponent): cmp is DSelect => cmp.component === 'select';\n\n/* ENTITY */\nexport interface DEntitySelect extends DynamicComponent {\n component: 'entity-select';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n entityType: string;\n labelKey?: string;\n idKey?: string;\n filter?: Record<string, unknown>;\n limit?: number;\n multiple?: boolean;\n visible?: string;\n clearable?: boolean;\n rules?: {\n required?: boolean;\n };\n readonly?: boolean;\n excludeIds?: string[];\n imageUrlKey?: string;\n defaultImageUrl?: string;\n testId?: string;\n };\n}\n\nexport const isEntitySelectComponent = (cmp: DynamicComponent): cmp is DEntitySelect => cmp.component === 'entity-select';\n\n/* CHECKBOX */\nexport interface DCheckbox extends DynamicComponent {\n component: 'checkbox';\n props: {\n name?: string;\n label?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isCheckboxComponent = (component: DynamicComponent): component is DCheckbox => {\n return component.component === 'checkbox';\n};\n\n/* CHECKBOX GROUP */\nexport interface DCheckboxGroup extends DynamicComponent {\n component: 'checkbox-group';\n props: {\n name?: string;\n label?: string;\n orientation?: 'horizontal' | 'vertical';\n items: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n }[];\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isCheckboxGroupComponent = (component: DynamicComponent): component is DCheckboxGroup => {\n return component.component === 'checkbox';\n};\n\n/* SWITCH */\nexport interface DSwitch extends DynamicComponent {\n component: 'switch';\n props: {\n name?: string;\n label?: string;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isSwitchComponent = (component: DynamicComponent): component is DSwitch => {\n return component.component === 'switch';\n};\n\n/* File Uploader */\nexport interface DFileUploader extends DynamicComponent {\n component: 'file-uploader';\n props: {\n name?: string;\n label?: string;\n accept?: string;\n placeholder?: string;\n maxFileSize?: number;\n downloadable?: boolean;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isFileUploaderComponent = (component: DynamicComponent): component is DFileUploader => {\n return component.component === 'file-uploader';\n};\n","import { DynamicComponent, ValidationRules } from '../types.js';\n\n/* ROW & COLUMS */\nexport interface DColumn extends DynamicComponent {\n component: 'column';\n props: {\n size: number;\n visible?: string;\n justifySelf?: 'start' | 'center' | 'end' | 'stretch';\n placeSelf?: 'start' | 'center' | 'end' | 'stretch';\n components: DynamicComponent[];\n };\n}\n\nexport const isColumnComponent = (component: DynamicComponent): component is DColumn => {\n return component.component === 'column';\n};\n\nexport interface DRow extends DynamicComponent {\n component: 'row';\n props: {\n components: DColumn[];\n visible?: string;\n placeItems?: 'start' | 'center' | 'end' | 'stretch';\n justifyItems?: 'start' | 'center' | 'end' | 'stretch';\n };\n}\n\nexport const isRowComponent = (component: DynamicComponent): component is DRow => {\n return component.component === 'row';\n};\n\n/* COLLECTION */\nexport interface DCollection extends DynamicComponent {\n component: 'collection';\n props: {\n name?: string;\n heading: string;\n components: DynamicComponent[];\n rules?: ValidationRules;\n readonly?: boolean;\n visible?: string;\n };\n}\n\nexport const isCollectionComponent = (component: DynamicComponent): component is DCollection => {\n return component.component === 'collection';\n};\n\n/* REPEATABLE COLLECTION */\nexport interface DRepeatableCollection extends DynamicComponent {\n component: 'repeatable-collection';\n props: {\n name?: string;\n heading: string;\n collectionTitle?: string;\n\n useTabs?: boolean;\n cols?: number;\n tabName?: string;\n confirmDeletion?: boolean;\n addButtonText?: string;\n readonly?: boolean;\n components: DynamicComponent[];\n visible?: string;\n rules?: {\n required?: boolean;\n };\n };\n}\n\nexport const isRepeatableCollectionComponent = (component: DynamicComponent): component is DRepeatableCollection => {\n return component.component === 'repeatable-collection';\n};\n\n/* RowSettings */\nexport interface DRowSettings extends DynamicComponent {\n component: 'row-settings';\n props: {\n label?: string;\n };\n}\n\nexport const isRowSettingsComponent = (component: DynamicComponent): component is DRowSettings => {\n return component.component === 'row-settings';\n};\n","import { isString } from '@/assertions/index.js';\nimport { isArrayKey } from '@/paths/index.js';\n\nimport {\n isCollectionComponent,\n isColumnComponent, isRepeatableCollectionComponent, isRowComponent,\n} from './registry/index.js';\nimport { DynamicComponent } from './types.js';\n\n/**\n * Get array with components founded by rpath\n *\n * @example\n * const components = [\n * {\n * id: \"xxx\",\n * component: \"collection\",\n * props: {\n * components: [\n * {\n * id: \"yyy\",\n * component: \"text-input\",\n * props: {\n * label: \"Title\"\n * }\n * }\n * ]\n * }\n * }\n * ]\n *\n * const { pathWithComponents } = getComponentsSubtreeByRPath(components, ['xxx', 'yyy']);\n *\n * // pathWithComponents\n * // [\n * // {\n * // id: \"xxx\",\n * // component: \"collection\",\n * // ...\n * // },\n * // {\n * // id: \"yyy\",\n * // component: \"text-input\",\n * // ...\n * // }\n * // ]\n *\n */\nexport const getComponentsSubtreeByRPath = (components: DynamicComponent[], rpath: string[]) => {\n const pathWithComponents: DynamicComponent[] = [];\n\n deepGetComponentsSubtreeByRPath(components, rpath, pathWithComponents);\n\n return {\n pathWithComponents,\n complete: pathWithComponents.length === rpath.length,\n };\n};\n\nconst deepGetComponentsSubtreeByRPath = (components: DynamicComponent[], rpath: string[], pathWithComponents: DynamicComponent[]) => {\n const id = rpath[0];\n\n const component = components.find((cmp) => cmp.id === id);\n\n if (!component) {\n return;\n }\n\n pathWithComponents.push(component);\n\n if (!Array.isArray(component.props.components)) {\n return;\n }\n\n deepGetComponentsSubtreeByRPath(component.props.components, rpath.slice(1), pathWithComponents);\n};\n\n/**\n * Get array with components founded by values path.\n *\n * @example\n * const components = [\n * {\n * id: \"xxx\",\n * component: \"collection\",\n * props: {\n * name: \"seo\",\n * components: [\n * {\n * id: \"yyy\",\n * component: \"text-input\",\n * props: {\n * label: \"Title\",\n * name: \"title\",\n * }\n * }\n * ]\n * }\n * }\n * ]\n *\n * const { pathWithComponents } = getComponentsSubtreeByPath(components, ['seo', 'title']);\n *\n * // pathWithComponents\n * // [\n * // {\n * // id: \"xxx\",\n * // component: \"collection\",\n * // ...\n * // },\n * // {\n * // id: \"yyy\",\n * // component: \"text-input\",\n * // ...\n * // }\n * // ]\n *\n */\nexport const getComponentsSubtreeByPath = (components: DynamicComponent[], path: (string | number)[]) => {\n const pathWithComponents: DynamicComponent[] = [];\n const complete = true;\n\n deepGetComponentsSubtreeByPath(components, path, pathWithComponents, complete);\n\n return {\n pathWithComponents,\n complete,\n };\n};\n\nconst deepFindComponentPathKey = (components: DynamicComponent[], key: string): DynamicComponent | null => {\n for (const component of components) {\n if ((component.props.name && component.props.name === key) || component.id === key) {\n return component;\n }\n\n if (isRowComponent(component) || isColumnComponent(component)) {\n const result = deepFindComponentPathKey(component.props.components, key);\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n};\n\nconst deepGetComponentsSubtreeByPath = (\n components: DynamicComponent[],\n path: (string | number)[],\n pathWithComponents: DynamicComponent[],\n complete: boolean,\n) => {\n const key = path[0];\n\n if (!isString(key)) {\n complete = false;\n\n return;\n }\n\n const component = deepFindComponentPathKey(components, key);\n\n if (!component) {\n complete = false;\n\n return;\n }\n\n pathWithComponents.push(component);\n\n /**\n * Deep dive if repeatable collection.\n *\n * If next key is array key find in props.components next key after array key\n *\n * @example\n * path = ['fields', 'id:xxx', 'title']\n *\n * cpnst key = 'fields';\n * const nextKey = 'id:xxx', // array key\n * const nextKeyAfterArrayKey = 'title';\n */\n if (isRepeatableCollectionComponent(component)) {\n const nextKey = path[1];\n if (isArrayKey(nextKey) && path[2]) {\n deepGetComponentsSubtreeByPath(component.props.components, path.slice(2), pathWithComponents, complete);\n }\n }\n\n if (isCollectionComponent(component)) {\n deepGetComponentsSubtreeByPath(component.props.components, path.slice(1), pathWithComponents, complete);\n }\n};\n","import * as Y from 'yjs';\n\nimport { isRichText } from '../assertions/rich-text.js';\nimport { generateKeyBetween } from './fractional-indexing.js';\nimport {\n DynamicComponent, DynamicComponentWithPosition, Point,\n} from './types.js';\n\n// This alphabet uses `A-Za-z0-9_-` symbols.\n// The order of characters is optimized for better gzip and brotli compression.\n// References to the same file (works both for gzip and brotli):\n// `'use`, `andom`, and `rict'`\n// References to the brotli default dictionary:\n// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`\nexport const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';\n\nexport const customAlphabet = (alphabet: string, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = '';\n // A compact alternative for `for (var i = 0; i < step; i++)`.\n let i = size;\n while (i--) {\n // `| 0` is more compact and faster than `Math.floor()`.\n // eslint-disable-next-line no-bitwise\n id += alphabet[(Math.random() * alphabet.length) | 0];\n }\n\n return id;\n };\n};\n\nexport const uid = customAlphabet('1234567890abcdefg', 5);\n\n/**\n * Gets the path to a property in a component.\n * @param {(string | number)[]} componentPath - The path to the component.\n * @param {string} name - The name of the property.\n * @returns {(string | number)[]} Returns the path to the property.\n * @example\n * getComponentPropertyPath(['components', 0], 'name'); // Returns ['components', 0, 'props', 'name']\n */\nexport const getComponentPropertyPath = (componentPath: (string | number)[], name: string) => [...componentPath, 'props', name];\n\n/**\n * Creates a copy of a dynamic component.\n * @param {DynamicComponent} component - The component to copy.\n * @param {Y.Doc} yDoc - The Yjs document to update with the copied component.\n * @returns {DynamicComponent} Returns the copied component.\n */\nexport const copyDynamicComponent = (component: DynamicComponent, yDoc?: Y.Doc): DynamicComponent => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id,\n\n props,\n coordinates,\n inputs,\n outputs,\n ...extras\n } = component;\n\n const componentCopy: DynamicComponent = {\n ...extras,\n id: uid(),\n props: {\n },\n };\n\n if (coordinates) {\n componentCopy.coordinates = [\n coordinates[0] + 10,\n coordinates[1] + 10,\n ];\n }\n\n if (inputs) {\n componentCopy.inputs = inputs.map((input) => ({\n ...input,\n id: uid(),\n }));\n }\n\n if (outputs) {\n componentCopy.outputs = outputs.map((output) => ({\n ...output,\n id: uid(),\n }));\n }\n\n for (const [key, value] of Object.entries(props)) {\n if (key === 'components' && Array.isArray(value)) {\n componentCopy.props.components = value.map((cmp) => copyDynamicComponent(cmp));\n } else if (isRichText(value)) {\n const oldKey = `${value.type}:${value.id}`;\n\n const newRichText = {\n ...value,\n id: uid(),\n };\n\n const newKey = `${value.type}:${newRichText.id}`;\n\n if (yDoc) {\n const yXmlFragment = yDoc.getXmlFragment(oldKey);\n const newYXmlFragment = yDoc.getXmlFragment(newKey);\n\n const clones: (Y.XmlElement | Y.XmlText)[] = [];\n for (const item of yXmlFragment.toArray()) {\n if (item instanceof Y.XmlElement || item instanceof Y.XmlText) {\n clones.push(item.clone());\n }\n }\n\n newYXmlFragment.insert(0, clones);\n }\n\n componentCopy.props[key] = newRichText;\n } else {\n componentCopy.props[key] = value;\n }\n }\n\n return componentCopy;\n};\n\n/**\n * Sorts an array of dynamic components and generates a position for each one.\n * @param {DynamicComponent[]} components - The components to sort.\n * @returns {DynamicComponentWithPosition[]} Returns the sorted components with positions.\n */\nexport const sortDynamicComponents = (components: DynamicComponent[]): DynamicComponentWithPosition[] => {\n return components.reduce((acc, component, i) => {\n const prev = acc[i - 1];\n\n const {\n position,\n props: {\n components,\n ...baseProps\n },\n ...baseFields\n } = component;\n\n const props: DynamicComponentWithPosition['props'] = baseProps;\n\n if (components) {\n props.components = sortDynamicComponents(components);\n }\n\n acc.push({\n ...baseFields,\n position: position ?? generateKeyBetween(prev?.position ?? null, null),\n props,\n });\n\n return acc;\n }, [] as DynamicComponentWithPosition[]);\n};\n\n/**\n * Searches for a dynamic component in a tree that matches a condition.\n * @param {DynamicComponent[]} components - The tree of components to search.\n * @param {(cmp: DynamicComponent) => boolean} isMatches - The condition to match.\n * @returns {DynamicComponent | null} Returns the matching component, or null if no match was found.\n */\nexport const searchDynamicComponentInTree = (\n components: DynamicComponent[],\n isMatches: (cmp: DynamicComponent) => boolean,\n): DynamicComponent | null => {\n for (const component of components) {\n if (isMatches(component)) {\n return component;\n }\n\n if (Array.isArray(component.props.components)) {\n const result = searchDynamicComponentInTree(component.props.components, isMatches);\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n};\n\nexport const getRelativePoint = (point: Point, relative: Point): Point => [point[0] - relative[0], point[1] - relative[1]];\n\n/**\n * Creates a copy of a dynamic component and set its position (fractional-index) rely on the index of the component.\n * @param components - The components without positions.\n */\nexport const makeDynamicComponentsWithPosition = (components: DynamicComponent[]): DynamicComponentWithPosition[] => {\n return sortDynamicComponents(components.slice(0));\n};\n","export type Point = [number, number]; // [x, y]\n\nexport interface DynamicComponentIO {\n id: string;\n name: string;\n}\n\n/**\n * Represents a link between two dynamic components.\n */\nexport interface DynamicComponentLink {\n /** The unique identifier of the link. */\n id: string;\n /** The input of the link. */\n input: string;\n /** The output of the link. */\n output: string;\n}\n\n/**\n\n/**\n * ValidationRules interface is used for defining the set of\n * validation constraints for a field in a form or component.\n *\n * @example\n * let rules: ValidationRules = {\n * required: true,\n * min: 1,\n * max: 100,\n * pattern: 'email'\n * };\n */\nexport interface ValidationRules {\n /**\n * Indicates whether the field is required or not.\n */\n required?: boolean;\n\n /**\n * Specifies the minimum value for the field.\n */\n min?: number;\n\n /**\n * Specifies the maximum value for the field.\n */\n max?: number;\n\n /**\n * Specifies a pattern that the field value should match.\n */\n pattern?: 'email' | 'url' | 'hh:mm:ss' | 'phone';\n\n /**\n *Specifies whether to trim spaces.\n */\n trim?: boolean;\n}\n\nexport interface ComponentStyles {\n /**\n * Specifies the top padding of the component.\n */\n paddingTop?: string;\n\n /**\n * Specifies the bottom padding of the component.\n */\n paddingBottom?: string;\n}\n\n/**\n * DynamicComponent is a key feature of the component designer.\n * It is a data structure used to describe dynamic components,\n * which can be added to the content by the component designer and their properties can be edited on the fly.\n * The output of the designer is a tree of dynamic components.\n *\n * For example, a text input component can be described as follows:\n * ```typescript\n * export interface DTextInput extends DynamicComponent {\n * component: 'text-input';\n * props: {\n * name?: string;\n * label?: string;\n * placeholder?: string;\n * maska?: string;\n * disabled?: boolean;\n * readonly?: boolean;\n * rules?: ValidationRules;\n * visible?: string;\n * };\n * }\n * ```\n */\nexport interface DynamicComponent {\n /**\n * The unique identifier of the component.\n */\n id: string;\n\n /**\n * The type of the component.\n */\n component: string;\n\n /**\n * The variant of the component.\n * For example, a button component can have variants like 'primary', 'secondary', etc.\n */\n variant?: string;\n\n /**\n * The position of the component.\n */\n position?: string;\n\n /**\n * A flag indicating whether the component is enabled or not.\n */\n enabled?: boolean;\n\n /**\n * The coordinated of the component in the canvas.\n */\n coordinates?: Point;\n\n /**\n * The inputs of the component.\n * Input ports are used to connect the component to other components.\n */\n inputs?: DynamicComponentIO[];\n\n /**\n * The outputs of the component.\n * Output ports are used to connect the component to other components.\n */\n outputs?: DynamicComponentIO[];\n\n /**\n * The properties of the component.\n */\n props: {\n /**\n * The name of the component.\n */\n name?: string;\n\n /**\n * The visibility of the component.\n */\n visible?: string;\n\n /**\n * The readonly status of the component.\n */\n readonly?: boolean;\n\n /**\n * The child components of the component.\n */\n components?: DynamicComponent[];\n\n /**\n * The validation rules for the component.\n */\n rules?: ValidationRules;\n\n /**\n * The styles for the component.\n */\n styles?: ComponentStyles;\n\n /**\n * Any other properties of the component.\n */\n [key: string]: unknown;\n };\n}\n\n/**\n * DynamicComponent is a key feature of the component designer.\n * It is a data structure used to describe dynamic components ,\n * which can be added to the content by the component designer and their properties can be edited on the fly.\n * The output of the designer is a tree of dynamic components.\n *\n * DynamicComponentWithPosition is a DynamicComponent with defind fractional-indexed position.\n *\n * For example, a text input component can be described as follows:\n * ```typescript\n * {\n * component: 'text-input';\n * props: {\n * name: 'email';\n * label:: string;\n * placeholder?: string;\n * maska?: string;\n * disabled?: boolean;\n * readonly?: boolean;\n * rules?: ValidationRules;\n * visible?: string;\n * };\n * }\n * ```\n */\nexport interface DynamicComponentWithPosition extends DynamicComponent {\n /**\n * The position of the component. This is required for DynamicComponentWithPosition.\n */\n position: string;\n\n /**\n * The properties of the component.\n */\n props: DynamicComponent['props'] & {\n /**\n * The child components of the component.\n */\n components?: DynamicComponentWithPosition[];\n };\n}\n\n/**\n * Defines a DynamicComponent.\n * @param {T} component - The component to define.\n * @returns {T} Returns the defined component.\n */\nexport const defineDynamicComponent = <T extends DynamicComponent>(component: T): T => component;\n\n/**\n * Defines an array of DynamicComponents.\n * @param {T[]} components - The components to define.\n * @returns {T[]} Returns the defined components.\n */\nexport const defineDynamicComponents = <T extends DynamicComponent>(components: T[]): T[] =>\n components.map((component) => defineDynamicComponent<T>(component));\n\n","import * as Y from 'yjs';\n\nimport { isYArray, isYMap } from '@/assertions/index.js';\nimport {\n extractIdFromArrayKey, extractPositionFromArrayKey, isIdArrayKey, isPositionArrayKey,\n} from '@/paths/index.js';\n\n/**\n * Returns the index of an item in a Y.Array based on its key.\n * The key can represent either the id or the position of the item in the array.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap = new Y.Map();\n * yMap.set('id', '123');\n * yMap.set('position', 'a0');\n * yArray.push([yMap]);\n * const index = getYArrayIndexByArrayKey(yArray, 'id:123');\n * const index = getYArrayIndexByArrayKey(yArray, 'pos:a0');\n * // index is now: 0\n */\nexport const getYArrayIndexByArrayKey = (yArray: unknown, key: string): number => {\n if (!isYArray<Y.Map<unknown>>(yArray)) {\n console.error(`Non-YArray type`, yArray);\n throw new Error(`Can't use array key in non YArray type (${key})`);\n }\n\n if (isIdArrayKey(key)) {\n const id = extractIdFromArrayKey(key);\n const index = yArray.toArray().findIndex((it) => isYMap(it) && it.get('id') === id);\n if (index === -1) {\n throw new Error(`Can't find index by id ${id} (${key})`);\n }\n\n return index;\n } else if (isPositionArrayKey(key)) {\n const position = extractPositionFromArrayKey(key);\n const index = yArray.toArray().findIndex((it) => isYMap(it) && it.get('position') === position);\n if (index === -1) {\n throw new Error(`Can't find index by position ${position} (${key})`);\n }\n\n return index;\n }\n\n throw new Error(`Unknown array key type (${key})`);\n};\n","import * as Y from 'yjs';\n\nimport {\n isIndex, isNullOrUndefined, isString, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { isArrayKey } from '@/paths/index.js';\n\nimport { getYArrayIndexByArrayKey } from './y-array-keys.js';\n\n/**\n * Sets a value at a given path within a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * setInYPath(ymap, ['key'], 'value');\n * // ymap now looks like: { key: 'value' }\n */\nexport const setInYPath = (ymap: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[], value: unknown): void => {\n let acc: Y.Map<unknown> | Y.Array<unknown> = ymap;\n\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(acc, rawKey) : rawKey;\n\n if (isYArray(acc) && isIndex(key)) {\n const index = key;\n\n // Last key, set it\n if (i === path.length - 1) {\n acc.delete(index);\n acc.push([value]);\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (isNullOrUndefined(acc.get(index))) {\n // container can be either an object or an array depending on the next key if it exists\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getYArrayIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n\n // if (isArrayKey(nextKey)) {\n // throw Error(`Can't create empty array in \"${key}\" with next position key (path: ${JSON.stringify(path)})`);\n // }\n\n acc.delete(index);\n acc.insert(index, [isIndex(nextKey) ? new Y.Array() : new Y.Map()]);\n }\n\n acc = acc.get(index) as Y.Map<unknown> | Y.Array<unknown>;\n } else if (isYMap(acc) && isString(key)) {\n // Last key, set it\n if (i === path.length - 1) {\n acc.set(key, value);\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!acc.has(key) || isNullOrUndefined(acc.get(key))) {\n // container can be either an object or an array depending on the next key if it exists\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getYArrayIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n\n // if (isArrayKey(nextKey)) {\n // throw Error(`Can't create empty array in \"${key}\" with next position key \"${nextKey}\" (path: ${JSON.stringify(path)})`);\n // }\n\n acc.set(key, isIndex(nextKey) ? new Y.Array() : new Y.Map());\n }\n\n acc = acc.get(key) as Y.Map<unknown> | Y.Array<unknown>;\n }\n }\n};\n\nconst yUnset = (yType: Y.Map<unknown> | Y.Array<unknown>, key: string | number) => {\n if (yType instanceof Y.Array && isIndex(key)) {\n yType.delete(Number(key));\n } else if (yType instanceof Y.Map && isString(key)) {\n yType.delete(key);\n }\n};\n\n/**\n * Removes a nested property from a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * ymap.set('key', 'value');\n * unsetYPath(ymap, ['key']);\n * // ymap now looks like: {}\n */\nexport const unsetYPath = (yType: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[]): void => {\n let acc: Y.Map<unknown> | Y.Array<unknown> = yType;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(acc, rawKey) : rawKey;\n\n // Last key, unset it\n if (i === path.length - 1) {\n yUnset(acc, key);\n break;\n }\n\n if (acc instanceof Y.Array && isIndex(key)) {\n const index = Number(key);\n\n // Key does not exist, exit\n if (isNullOrUndefined(acc.get(index))) {\n break;\n }\n\n acc = acc.get(index) as Y.Map<unknown> | Y.Array<unknown>;\n } else if (acc instanceof Y.Map && isString(key)) {\n // Key does not exist, exit\n if (!acc.has(key) || isNullOrUndefined(acc.get(key))) {\n break;\n }\n\n acc = acc.get(key) as Y.Map<unknown> | Y.Array<unknown>;\n }\n }\n\n // const pathValues: (unknown | Record<string, unknown>)[] = keys.map((_, idx) => {\n // return getFromPath(object, keys.slice(0, idx).join('.'));\n // });\n\n // for (let i = pathValues.length - 1; i >= 0; i--) {\n // if (!isEmptyContainer(pathValues[i])) {\n // continue;\n // }\n\n // if (i === 0) {\n // unset(object, keys[0]);\n // continue;\n // }\n\n // unset(pathValues[i - 1] as Record<string, unknown>, keys[i - 1]);\n // }\n};\n\n/**\n * Retrieves a nested property value from a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * ymap.set('key', 'value');\n * const value = getFromYPath(ymap, ['key']);\n * // value is now: 'value'\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getFromYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[]): unknown | null => {\n if (!entry) {\n return;\n }\n\n if (path.length === 0) {\n return entry;\n }\n\n let ref = entry as unknown;\n for (const rawKey of path) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(ref, rawKey) : rawKey;\n\n if (isYArray(ref)) {\n if (!isIndex(key)) {\n console.warn(`Can't use non index key in YArray ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n\n ref = ref.get(key);\n continue;\n } else if (isYMap(ref)) {\n if (!isString(key)) {\n console.warn(`Can't use non string key in YMap ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n\n ref = ref.get(key);\n } else {\n console.warn(`Non supported YType on ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n }\n\n return ref;\n};\n","import * as Y from 'yjs';\n\nimport { isObject } from '@/assertions/index.js';\nimport { sortByPosition } from '@/paths/index.js';\n\n/**\n * Returns the index of the first item in a Y.Array that matches a condition.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * const index = findIndexInYArray(yArray, (item) => item === 'item2');\n * // index is now: 1\n */\nexport const findIndexInYArray = <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean): number => {\n return yArray.toArray().findIndex(isMatches);\n};\n\n/**\n * Returns the first item in a Y.Array that matches a condition.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * const item = findInYArray(yArray, (item) => item === 'item2');\n * // item is now: 'item2'\n */\nexport const findInYArray = <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean): T | null => {\n const index = findIndexInYArray(yArray, isMatches);\n if (index === -1) {\n return null;\n }\n\n return yArray.get(index);\n};\n\n/**\n * Converts an object to a Y.Map.\n *\n * @example\n * const object = { key: 'value' };\n * const yMap = objectToYMap(object);\n * // yMap now looks like: { key: 'value' }\n */\nexport const objectToYMap = (values: object) => {\n const entries: [string, unknown][] = Object.entries(values).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [key, arrayToYArray(value)];\n } else if (isObject(value)) {\n return [key, objectToYMap(value)];\n } else {\n return [key, value];\n }\n });\n\n return new Y.Map(entries);\n};\n\n/**\n * Converts an array to a Y.Array.\n *\n * @example\n * const array = ['item1', 'item2', 'item3'];\n * const yArray = arrayToYArray(array);\n * // yArray now looks like: ['item1', 'item2', 'item3']\n */\nexport const arrayToYArray = (array: unknown[], yArray: Y.Array<unknown> = new Y.Array()) => {\n const items = array.map((it) => isObject(it) ? objectToYMap(it) : it);\n yArray.insert(0, items);\n\n return yArray;\n};\n\n/**\n * Returns a sorted Y.Array based on the position of each Y.Map in it.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap1 = new Y.Map();\n * let yMap2 = new Y.Map();\n * yMap1.set('position', 'a0');\n * yMap2.set('position', 'b0');\n * yArray.push([yMap2, yMap1]);\n * const sortedYArray = getSortedYArray(yArray);\n * // sortedYArray now looks like: [ yMap1, yMap2 ]\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getSortedYArray = <T extends Y.Map<any>>(yArray: Y.Array<T>) => yArray\n .toArray()\n .sort((a, b) => sortByPosition((a.get('position') as string), (b.get('position') as string)));\n\n/**\n * Returns references to a Y.Map and its neighbors in a Y.Array based on its position.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap1 = new Y.Map();\n * let yMap2 = new Y.Map();\n * yMap1.set('position', 'a0');\n * yMap2.set('position', 'b0');\n * yArray.push([yMap2, yMap1]);\n * const refs = getYArrayRefsByPosition(yArray, 'a0');\n * // refs now looks like: { index: 0, ref: yMap1, right: yMap2, left: undefined, sortedArray: [yMap1, yMap2] }\n */\nexport const getYArrayRefsByPosition = <T extends Y.Map<unknown>>(yArray: Y.Array<T>, position: string) => {\n const sortedArray = getSortedYArray(yArray);\n // const currentYArrayIndex = sortedArray.findIndex((it) => it === yComponent);\n const index = sortedArray.findIndex((it) => it.get('position') === position);\n if (index === -1) {\n console.error('sortedArray', sortedArray);\n throw new Error(`Relative item with position ${position} not found`);\n }\n\n return {\n index,\n ref: sortedArray[index],\n right: sortedArray[index + 1],\n left: sortedArray[index - 1],\n sortedArray,\n };\n};\n\n","import * as Y from 'yjs';\n\nimport {\n isIndex, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { generateKeyBetween } from '@/dynamic-components/index.js';\n\nimport { getFromYPath, setInYPath } from './basic-path-ops.js';\nimport { getSortedYArray, getYArrayRefsByPosition } from './tools.js';\nimport { getYArrayIndexByArrayKey } from './y-array-keys.js';\n\n/**\n * Pushes a value to the end of the Y.Array at the specified path.\n *\n * @example\n * let yMap = new Y.Map();\n * yMap.set('names', new Y.Array());\n * pushInYPath(yMap, ['names'], 'John');\n * // yMap now looks like: { names: ['John'] }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const pushInYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], value: any) => {\n const yArray = getFromYPath(entry, path);\n if (!isYArray(yArray)) {\n setInYPath(entry, path, Y.Array.from([value]));\n } else {\n yArray.push([value]);\n }\n};\n\nconst printPosition = (array: unknown[]) => array.map((it) => isYMap(it) ? it.get('position') ?? 'no-position' : 'not-ymap');\n\n/**\n * Moves an item to a new position relative to another item in the Y.Array or Y.Map at the specified path.\n *\n * @example\n * moveInYPath(yMap, ['components'], 'a0', 'b1', 'after');\n */\nexport const moveInYPath = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n entry: Y.Array<any> | Y.Map<any>,\n path: (string | number)[],\n oldPosition: string,\n relativePosition: string,\n insert: 'before' | 'after',\n) => {\n const yArray = getFromYPath(entry, path);\n if (!isYArray(yArray)) {\n throw new Error(`Can't move. Target item is not yArray in path ${JSON.stringify(path)}`);\n }\n\n const array = yArray.toArray();\n\n const item = array.find((it) => isYMap(it) && it.get('position') === oldPosition);\n const relativeItemIndex = array.findIndex((it) => isYMap(it) && it.get('position') === relativePosition);\n\n if (!isYMap(item)) {\n throw new Error(`Can't move. Item in position ${oldPosition} not found. ${printPosition(array)}`);\n }\n\n if (relativeItemIndex === -1) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} not found. ${printPosition(array)}`);\n }\n\n const relativeItem = array[relativeItemIndex];\n if (!isYMap(relativeItem)) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} must be YMap. ${printPosition(array)}`);\n }\n\n if (insert === 'before') {\n const left = array[relativeItemIndex - 1];\n const leftPosition = isYMap(left) ? left.get('position') as string ?? null : null;\n\n const newPosition = generateKeyBetween(leftPosition, relativeItem.get('position') as string);\n item.set('position', newPosition);\n\n return newPosition;\n }\n\n const right = array[relativeItemIndex + 1];\n const rightPosition = isYMap(right) ? right.get('position') as string ?? null : null;\n\n const newPosition = generateKeyBetween(relativeItem.get('position') as string, rightPosition);\n item.set('position', newPosition);\n\n return newPosition;\n};\n\n/**\n * Removes an item from the Y.Array or Y.Map at the specified path.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * pullFromYPath(yArray, [1]);\n * // yArray now looks like: ['item1', 'item3']\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const pullFromYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], key: string | number) => {\n const yArray = getFromYPath(entry, path) as unknown[];\n if (isYArray(yArray)) {\n if (isIndex(key)) {\n yArray.delete(key);\n\n return;\n }\n\n const index = getYArrayIndexByArrayKey(yArray, key);\n yArray.delete(index);\n }\n};\n\nexport interface MoveYMapToStartOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Moves a Y.Map to the start of a Y.Array.\n * */\nexport const moveYMapToStart = ({ yArray, yMap }: MoveYMapToEndOptions) => {\n const sortedArray = getSortedYArray(yArray);\n const first = sortedArray[0];\n\n const rightIndex = first ? (first.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(null, rightIndex));\n};\n\nexport interface MoveYMapToEndOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Moves a Y.Map to the end of a Y.Array.\n * */\nexport const moveYMapToEnd = ({ yArray, yMap }: MoveYMapToEndOptions) => {\n const sortedArray = getSortedYArray(yArray);\n const last = sortedArray[sortedArray.length - 1];\n\n const leftIndex = last ? (last.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, null));\n};\n\nexport interface MoveYMapBeforeOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Moves a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const moveYMapBefore = ({\n yArray,\n yMap,\n relativePosition,\n}: MoveYMapBeforeOptions) => {\n const { ref: relative, left } = getYArrayRefsByPosition(yArray, relativePosition);\n\n const right = relative; // left - x - relative\n\n const rightIndex = right ? (right.get('position') as string) : null;\n const leftIndex = left ? (left.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, rightIndex));\n};\n\nexport interface MoveYMapAfterOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Moves a Y.Map after another Y.Map in a Y.Array.\n * */\nexport const moveYMapAfter = ({\n yArray,\n yMap,\n relativePosition,\n}: MoveYMapAfterOptions) => {\n const { ref: relative, right } = getYArrayRefsByPosition(yArray, relativePosition);\n\n const left = relative; // relative - x - right\n\n const rightIndex = right ? (right.get('position') as string) : null;\n const leftIndex = left ? (left.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, rightIndex));\n};\n\nexport interface InsertYMapToEndOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Inserts a Y.Map to the end of a Y.Array.\n * */\nexport const insertYMapToEnd = (opts: InsertYMapToEndOptions) => {\n moveYMapToEnd(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n\nexport interface InsertYMapBeforeOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Inserts a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const insertYMapBefore = (opts: InsertYMapBeforeOptions) => {\n moveYMapBefore(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n\nexport interface InsertYMapAfterOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Inserts a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const insertYMapAfter = (opts: InsertYMapAfterOptions) => {\n moveYMapAfter(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n","import { JSONContent } from '@tiptap/core';\nimport { yXmlFragmentToProsemirrorJSON } from 'y-prosemirror';\nimport * as Y from 'yjs';\n\nimport {\n isObject, isString, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { RichText } from '@/data-objects/index.js';\nimport {\n DynamicComponent, DynamicComponentWithPosition,\n sortDynamicComponents,\n} from '@/dynamic-components/index.js';\nimport {\n arrayToYArray,\n objectToYMap,\n} from '@/y-tools/index.js';\n\nimport { YComponent } from './types.js';\n\n/**\n * This function converts dynamic component properties to Y.Map representation.\n */\nexport const dynamicComponentPropsToYComponentProps = (props: Record<string, unknown>) => {\n const entries: [string, unknown][] = Object.entries(props).map(([key, value]) => {\n if (key === 'content' && isObject(value) && (value.content as JSONContent)?.type === 'doc') {\n // sae value content as is\n return [key, value.content];\n } else if (Array.isArray(value)) {\n return [key, arrayToYArray(value)];\n } else if (isObject(value)) {\n return [key, objectToYMap(value)];\n } else {\n return [key, value];\n }\n });\n\n return new Y.Map(entries);\n};\n\n/**\n * This function converts a dynamic component to Y.Map representation.\n */\nexport const dynamicComponentToYMap = (component: DynamicComponent, yMap = new Y.Map()): YComponent => {\n const {\n props: propsWithComponents,\n ...fields\n } = component;\n\n const {\n components,\n ...props\n } = propsWithComponents ?? {\n };\n\n for (const [key, value] of Object.entries(fields)) {\n yMap.set(key, value);\n }\n\n const yProps = props ? objectToYMap(props) : new Y.Map();\n\n if (Array.isArray(components)) {\n yProps.set('components', dynamicComponentsToYArray(components));\n }\n\n yMap.set('props', yProps);\n\n return yMap;\n};\n\n/**\n * This function converts an array of dynamic components to Y.Array representation.\n */\nexport const dynamicComponentsToYArray = (components: DynamicComponent[], yArray = new Y.Array()) => {\n yArray.push(sortDynamicComponents(components).map((cmp) => dynamicComponentToYMap(cmp)));\n\n return yArray;\n};\n\n/**\n * This function checks if a given Y.Map object is a YComponent.\n */\nexport const isYComponent = (yComponent: unknown): yComponent is YComponent => {\n return isYMap(yComponent) && isString(yComponent.get('component')) && isString(yComponent.get('id'));\n};\n\n/**\n * This function converts a YComponent to a dynamic component.\n */\nexport const yComponentToDynamicComponent = (yComponent: YComponent, extractContent = false): DynamicComponentWithPosition => {\n const component: Record<string, unknown> = {\n props: {\n },\n };\n\n for (const [key, value] of yComponent.entries()) {\n if (key === 'props') {\n if (!isYMap(value)) {\n throw new Error('Component props must be YMap');\n }\n\n const yComponentProps = value;\n\n const props: Record<string, unknown> = {\n };\n\n for (const [prop, value] of yComponentProps.entries()) {\n if (prop === 'components') {\n if (!isYArray<YComponent>(value)) {\n throw new Error('Component props.components array must be YArray');\n }\n\n props.components = value.toArray().map((it) => yComponentToDynamicComponent(it));\n } else if (\n extractContent &&\n yComponent.doc &&\n isYMap(value) &&\n value.get('type') === 'RichText' &&\n typeof value.get('id') === 'string'\n ) {\n const id = value.get('id') as string;\n const rawRichText = value.toJSON() as RichText;\n\n const richText: RichText = {\n ...rawRichText,\n tiptap: yXmlFragmentToProsemirrorJSON(yComponent.doc.getXmlFragment(`RichText:${id}`)),\n };\n\n props[prop] = richText;\n } else if (value instanceof Y.AbstractType) {\n props[prop] = value.toJSON();\n } else {\n props[prop] = value;\n }\n }\n\n component.props = props;\n } else if (isYArray(value)) {\n component[key] = value.toArray();\n } else if (isYMap(value)) {\n component[key] = value.toJSON();\n } else {\n component[key] = value;\n }\n }\n\n return component as unknown as DynamicComponentWithPosition;\n};\n\n/**\n * This function converts a dynamic component to YComponent.\n */\nexport const dynamicComponentToYComponent = (component: DynamicComponent): YComponent => {\n // return yComponent.toJSON() as DynamicComponentWithPosition;\n return dynamicComponentToYMap(component) as YComponent;\n};\n\n/**\n * This function retrieves the properties of a YComponent.\n */\nexport const getYComponentProps = (yComponent: YComponent): Y.Map<unknown> => {\n const props = yComponent.get('props');\n if (!isYMap(props)) {\n throw new Error(`Component hasn't \"props\" property. It must have to be defined as Y.Map (component: ${yComponent.get('id')})`);\n }\n\n return props;\n};\n\n/**\n * This function retrieves the array of components of a YComponent.\n */\nexport const getYComponentComponentsArray = (yComponent: YComponent): Y.Array<YComponent> => {\n const props = getYComponentProps(yComponent);\n\n const yComponents = props.get('components');\n\n if (!isYArray<YComponent>(yComponents)) {\n throw new Error(`Component hasn't \"props.components\" property. It must be defined as Y.Array (component: ${yComponent.get('id')})`);\n }\n\n return yComponents;\n};\n\n/**\n * This function checks if a YComponent has a components array.\n * @example\n * // component\n * {\n * id: \"column\",\n * component: \"column\",\n * props: {\n * components: [...] <= has components array\n * }\n * }\n */\nexport const yComponentHasComponentsYArray = (yComponent: YComponent): boolean => {\n const props = getYComponentProps(yComponent);\n\n const yComponents = props.get('components');\n\n return isYArray<YComponent>(yComponents);\n};\n\n/**\n * This function retrieves the parent component of a YArray of YComponents.\n * @example\n * // parent component\n * {\n * id: \"column\",\n * component: \"column\",\n * props: {\n * components: [...] <= components array\n * }\n * }\n */\nexport const getYComponentsArrayParentComponent = (yArray: Y.Array<YComponent>): YComponent | null => {\n // yarray => parent (props) => parent (YIndexedDynamicComponents)\n\n return yArray.parent?.parent as YComponent ?? null;\n};\n\n/**\n * This function finds a Y.Component in a Y.Array by its ID.\n */\nexport const findYComponentInArray = (yArray: Y.Array<YComponent>, componentId: string) => {\n const yComponent = yArray.toArray().find((it) => it.get('id') === componentId);\n\n if (!yComponent) {\n throw new Error(`Component with id ${componentId} not found in yArray`);\n }\n\n return yComponent;\n};\n\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,cAAc,OAA+C;AACxE,QAAO,OAAO,OAAO;;;;;;;;;;AAWvB,MAAa,YAAY,QAAgC,OAAO,QAAQ;;;;;;;;;AAUxE,MAAa,YAAY,QAAgC,OAAO,QAAQ;;;;;;;;;;AAWxE,MAAa,WAAW,UAAoC;AAC1D,SAAQ,SAAS,MAAM,IAAI,SAAS,MAAM,KAAK,OAAO,MAAM,IAAI;;;;;;;;;;;AAYlE,MAAa,qBAAqB,UAA8C;AAC9E,QAAO,UAAU,QAAQ,UAAU;;;;;;;;;;;;;AC3CrC,MAAa,gBAAgB,QAA0B;AACrD,QAAO,MAAM,QAAQ,IAAI,IAAI,IAAI,WAAW;;;;;;;;;AAU9C,MAAa,UAAa,QAAW,OAAO,KAAK,IAAiB;;;;;;;;AASlE,MAAa,aAAgB,QAAW,OAAO,QAAQ,IAAiB;;;;;;;;;AAUxE,MAAa,YAAY,QACvB,QAAQ,QAAQ,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI;;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,OAAM,IAAI,MAAM,sFAAsF,WAAW,IAAI,KAAK,CAAC,GAAG;AAGhI,QAAO;;;;;AAMT,MAAa,gCAAgC,eAAgD;CAG3F,MAAM,cAFQ,mBAAmB,WAAW,CAElB,IAAI,aAAa;AAE3C,KAAI,CAAC,SAAqB,YAAY,CACpC,OAAM,IAAI,MAAM,2FAA2F,WAAW,IAAI,KAAK,CAAC,GAAG;AAGrI,QAAO;;;;;;;;;;;;;;AAeT,MAAa,iCAAiC,eAAoC;AAKhF,QAAO,SAJO,mBAAmB,WAAW,CAElB,IAAI,aAAa,CAEH;;;;;;;;;;;;;;AAe1C,MAAa,sCAAsC,WAAmD;AAGpG,QAAO,OAAO,QAAQ,UAAwB;;;;;AAMhD,MAAa,yBAAyB,QAA6B,gBAAwB;CACzF,MAAM,aAAa,OAAO,SAAS,CAAC,MAAM,OAAO,GAAG,IAAI,KAAK,KAAK,YAAY;AAE9E,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,qBAAqB,YAAY,sBAAsB;AAGzE,QAAO"}
1
+ {"version":3,"file":"index.js","names":["ib","fb","ia","fa","i","printPosition","newPosition","pathWithComponents: DynamicComponent[]","componentCopy: DynamicComponent","clones: (Y.XmlElement | Y.XmlText)[]","props: DynamicComponentWithPosition['props']","components","acc: Y.Map<unknown> | Y.Array<unknown>","entries: [string, unknown][]","newPosition","entries: [string, unknown][]","component: Record<string, unknown>","props: Record<string, unknown>","value"],"sources":["../src/assertions/paths.ts","../src/assertions/rich-text.ts","../src/assertions/yjs.ts","../src/data-objects/data-object.ts","../src/dynamic-components/fractional-indexing.ts","../src/paths/array-keys.ts","../src/paths/basic-ops.ts","../src/paths/array-ops.ts","../src/paths/constants.ts","../src/paths/tools.ts","../src/dynamic-components/registry/chats.ts","../src/dynamic-components/registry/content.ts","../src/dynamic-components/registry/forms.ts","../src/dynamic-components/registry/layout.ts","../src/dynamic-components/paths.ts","../src/dynamic-components/tools.ts","../src/dynamic-components/types.ts","../src/y-tools/y-array-keys.ts","../src/y-tools/basic-path-ops.ts","../src/y-tools/tools.ts","../src/y-tools/array-path-ops.ts","../src/y-components/tools.ts"],"sourcesContent":["/**\n * Checks if two paths are equal.\n * @param {(string | number)[]} path - The first path to compare.\n * @param {(string | number)[]} toPath - The second path to compare.\n * @returns {boolean} Returns true if both paths are of the same length and all corresponding elements are equal, false otherwise.\n * @example\n * isEqualPath(['items', 'id:xxx', 'name'], ['items', 'id:xxx', 'name']); // Returns true\n * isEqualPath(['items', 'id:yyy', 'name'], ['items', 'id:xxx', 'name']); // Returns false\n */\nexport const isEqualPath = (path: (string | number)[], toPath: (string | number)[]) => {\n return path.length === toPath.length && path.every((v, index) => v === toPath[index]);\n};\n","import { RichText } from '@/data-objects/rich-text.js';\n\n/**\n * Checks if the given value is a RichText object.\n * @param {unknown} value - The value to check.\n * @returns {boolean} Returns true if `value` is a RichText object, false otherwise.\n * @example\n * isRichText({ id: 'xx', ... type: 'RichText' }); // Returns true\n */\nexport const isRichText = (value: unknown): value is RichText => {\n if (typeof value === 'object' && value !== null) {\n return 'type' in value && value.type === 'RichText';\n }\n\n return false;\n};\n","import * as Y from 'yjs';\n\n/**\n * Checks if the given value is a Yjs Map.\n * @param {unknown} yMap - The value to check.\n * @returns {boolean} Returns true if `yMap` is a Yjs Map, false otherwise.\n * @example\n * const yMap = new Y.Map();\n * isYMap(yMap); // Returns true\n */\nexport const isYMap = <T = unknown>(yMap: unknown): yMap is Y.Map<T> => {\n return yMap instanceof Y.Map;\n};\n\n/**\n * Checks if the given value is a Yjs Array.\n * @param {unknown} yArray - The value to check.\n * @returns {boolean} Returns true if `yArray` is a Yjs Array, false otherwise.\n * @example\n * const yArray = new Y.Array();\n * isYArray(yArray); // Returns true\n */\nexport const isYArray = <T = unknown>(yArray: unknown): yArray is Y.Array<T> => {\n return yArray instanceof Y.Array;\n};\n","/**\n * The BaseDataObject interface represents a basic structure of a data object.\n * It includes an `id` and a `type` string.\n *\n * @interface\n * @example\n * {\n * id: 'xxx',\n * tiptap: { ... },\n * type: 'RichText'\n * }\n */\nexport interface BaseDataObject {\n /**\n * The unique identifier for the data object.\n */\n id: string;\n\n /**\n * The type of the data object. It's used for differentiating different types of data objects.\n */\n type: string;\n}\n\n/**\n * Gets the key of the data object. The key is a string combining `type` and `id` of the data object, separated by a colon.\n * @param {BaseDataObject} dataObject - The data object to get the key from.\n * @returns {string} Returns the key of the data object.\n * @example\n * getDataObjectKey({ id: 'xxx', type: 'RichText' }); // Returns 'RichText:xxx'\n */\nexport const getDataObjectKey = (dataObject: BaseDataObject): string => {\n return `${dataObject.type}:${dataObject.id}`;\n};\n","// License: CC0 (no rights reserved).\n\n// This is based on https://observablehq.com/@dgreensp/implementing-fractional-indexing\n\nexport const BASE_62_DIGITS =\n '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\n\nconst SMALLEST_INTEGER = 'A00000000000000000000000000';\n\nconst INTEGER_ZERO = 'a0';\n\n// `a` may be empty string, `b` is null or non-empty string.\n// `a < b` lexicographically if `b` is non-null.\n// no trailing zeros allowed.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string} a\n * @param {string | null} b\n * @param {string} digits\n * @returns {string}\n */\nconst midpoint = (a: string, b: string | null, digits: string): string => {\n if (b !== null && a >= b) {\n throw new Error(a + ' >= ' + b);\n }\n if (a.slice(-1) === '0' || (b && b.slice(-1) === '0')) {\n throw new Error('trailing zero');\n }\n if (b) {\n // remove longest common prefix. pad `a` with 0s as we\n // go. note that we don't need to pad `b`, because it can't\n // end before `a` while traversing the common prefix.\n let n = 0;\n while ((a[n] || '0') === b[n]) {\n n++;\n }\n if (n > 0) {\n return b.slice(0, n) + midpoint(a.slice(n), b.slice(n), digits);\n }\n }\n // first digits (or lack of digit) are different\n const digitA = a ? digits.indexOf(a[0]) : 0;\n const digitB = b !== null ? digits.indexOf(b[0]) : digits.length;\n if (digitB - digitA > 1) {\n const midDigit = Math.round(0.5 * (digitA + digitB));\n\n return digits[midDigit];\n } else {\n // first digits are consecutive\n if (b && b.length > 1) {\n return b.slice(0, 1);\n }\n\n // `b` is null or has length 1 (a single digit).\n // the first digit of `a` is the previous digit to `b`,\n // or 9 if `b` is null.\n // given, for example, midpoint('49', '5'), return\n // '4' + midpoint('9', null), which will become\n // '4' + '9' + midpoint('', null), which is '495'\n return digits[digitA] + midpoint(a.slice(1), null, digits);\n }\n};\n\n/**\n * @param {string} int\n * @return {void}\n */\n\nconst validateInteger = (int: string) => {\n if (int.length !== getIntegerLength(int[0])) {\n throw new Error('invalid integer part of order key: ' + int);\n }\n};\n\n/**\n * @param {string} head\n * @return {number}\n */\n\nconst getIntegerLength = (head: string): number => {\n if (head >= 'a' && head <= 'z') {\n return head.charCodeAt(0) - 'a'.charCodeAt(0) + 2;\n } else if (head >= 'A' && head <= 'Z') {\n return 'Z'.charCodeAt(0) - head.charCodeAt(0) + 2;\n } else {\n throw new Error('invalid order key head: ' + head);\n }\n};\n\n/**\n * @param {string} key\n * @return {string}\n */\n\nconst getIntegerPart = (key: string) => {\n const integerPartLength = getIntegerLength(key[0]);\n if (integerPartLength > key.length) {\n throw new Error('invalid order key: ' + key);\n }\n\n return key.slice(0, integerPartLength);\n};\n\n/**\n * @param {string} key\n * @return {void}\n */\n\nconst validateOrderKey = (key: string) => {\n if (key === SMALLEST_INTEGER) {\n throw new Error('invalid order key: ' + key);\n }\n // getIntegerPart will throw if the first character is bad,\n // or the key is too short. we'd call it to check these things\n // even if we didn't need the result\n const i = getIntegerPart(key);\n const f = key.slice(i.length);\n if (f.slice(-1) === '0') {\n throw new Error('invalid order key: ' + key);\n }\n};\n\n// note that this may return null, as there is a largest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\nconst incrementInteger = (x: string, digits: string) => {\n validateInteger(x);\n const [head, ...digs] = x.split('');\n let carry = true;\n for (let i = digs.length - 1; carry && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) + 1;\n if (d === digits.length) {\n digs[i] = '0';\n } else {\n digs[i] = digits[d];\n carry = false;\n }\n }\n if (carry) {\n if (head === 'Z') {\n return 'a0';\n }\n if (head === 'z') {\n return null;\n }\n const h = String.fromCharCode(head.charCodeAt(0) + 1);\n if (h > 'a') {\n digs.push('0');\n } else {\n digs.pop();\n }\n\n return h + digs.join('');\n } else {\n return head + digs.join('');\n }\n};\n\n// note that this may return null, as there is a smallest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\n\nconst decrementInteger = (x: string, digits: string) => {\n validateInteger(x);\n const [head, ...digs] = x.split('');\n let borrow = true;\n for (let i = digs.length - 1; borrow && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) - 1;\n if (d === -1) {\n digs[i] = digits.slice(-1);\n } else {\n digs[i] = digits[d];\n borrow = false;\n }\n }\n if (borrow) {\n if (head === 'a') {\n return 'Z' + digits.slice(-1);\n }\n if (head === 'A') {\n return null;\n }\n const h = String.fromCharCode(head.charCodeAt(0) - 1);\n if (h < 'Z') {\n digs.push(digits.slice(-1));\n } else {\n digs.pop();\n }\n\n return h + digs.join('');\n } else {\n return head + digs.join('');\n }\n};\n\n// `a` is an order key or null (START).\n// `b` is an order key or null (END).\n// `a < b` lexicographically if both are non-null.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string | null} a\n * @param {string | null} b\n * @param {string=} digits\n * @return {string}\n */\nexport const generateKeyBetween = (a: string | null, b: string | null, digits = BASE_62_DIGITS) => {\n if (a !== null) {\n validateOrderKey(a);\n }\n if (b !== null) {\n validateOrderKey(b);\n }\n if (a !== null && b !== null && a >= b) {\n throw new Error(a + ' >= ' + b);\n }\n if (a === null) {\n if (b === null) {\n return INTEGER_ZERO;\n }\n\n const ib = getIntegerPart(b);\n const fb = b.slice(ib.length);\n if (ib === SMALLEST_INTEGER) {\n return ib + midpoint('', fb, digits);\n }\n if (ib < b) {\n return ib;\n }\n const res = decrementInteger(ib, digits);\n if (res === null) {\n throw new Error('cannot decrement any more');\n }\n\n return res;\n }\n\n if (b === null) {\n const ia = getIntegerPart(a);\n const fa = a.slice(ia.length);\n const i = incrementInteger(ia, digits);\n\n return i === null ? ia + midpoint(fa, null, digits) : i;\n }\n\n const ia = getIntegerPart(a);\n const fa = a.slice(ia.length);\n const ib = getIntegerPart(b);\n const fb = b.slice(ib.length);\n if (ia === ib) {\n return ia + midpoint(fa, fb, digits);\n }\n const i = incrementInteger(ia, digits);\n if (i === null) {\n throw new Error('cannot increment any more');\n }\n if (i < b) {\n return i;\n }\n\n return ia + midpoint(fa, null, digits);\n};\n\n/**\n * same preconditions as generateKeysBetween.\n * n >= 0.\n * Returns an array of n distinct keys in sorted order.\n * If a and b are both null, returns [a0, a1, ...]\n * If one or the other is null, returns consecutive \"integer\"\n * keys. Otherwise, returns relatively short keys between\n * a and b.\n * @param {string | null} a\n * @param {string | null} b\n * @param {number} n\n * @param {string} digits\n * @return {string[]}\n */\nexport const generateNKeysBetween = (a: string | null, b: string | null, n: number, digits = BASE_62_DIGITS): string[] => {\n if (n === 0) {\n return [];\n }\n if (n === 1) {\n return [generateKeyBetween(a, b, digits)];\n }\n if (b === null) {\n let c = generateKeyBetween(a, b, digits);\n const result = [c];\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(c, b, digits);\n result.push(c);\n }\n\n return result;\n }\n if (a === null) {\n let c = generateKeyBetween(a, b, digits);\n const result = [c];\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(a, c, digits);\n result.push(c);\n }\n result.reverse();\n\n return result;\n }\n const mid = Math.floor(n / 2);\n const c = generateKeyBetween(a, b, digits);\n\n return [\n ...generateNKeysBetween(a, c, mid, digits),\n c,\n ...generateNKeysBetween(c, b, n - mid - 1, digits),\n ];\n};\n","import { isObject, isString } from '@/assertions/index.js';\n\n/**\n * In the system you are using, two types of keys are used to identify elements in an array: ID keys and position keys.\n * These keys provide a flexible and robust way to refer to specific elements in an array, particularly when dealing with arrays of objects.\n *\n * 1. **ID Keys:**\n * These keys have a prefix of 'id:' and are followed by the unique identifier of an object in the array.\n * For example, in your array `items: [{ id: 'xxx', name: 'John' }]`, you can refer to the object with `id: 'xxx'` using the ID key 'id:xxx'.\n * This is particularly useful when you have a unique identifier for each object in your array.\n * With this, even if objects move around in the array, you can always accurately refer to a specific object using its unique ID.\n *\n * 2. **Position Keys:**\n * These keys have a prefix of 'pos:' and are followed by a position indicator.\n * Position keys provide a way to refer to an object in an array based on its position rather than its content.\n * This can be useful when the position of an object in an array is significant and you want to refer to an object based on where it is in the array.\n *\n * In your path system, you can use either type of key as part of the path to refer to specific elements in an array.\n * For example, if you have an object like `{ items: [{ id: 'xxx', name: 'John' }] }`,\n * you can refer to the name of the first item in the array using either an ID key or a position key in the path:\n *\n * - Using an ID key: `['items', 'id:xxx', 'name']`\n * - Using a position key: `['items', 'pos:0', 'name']`\n *\n * This system of using ID and position keys in paths gives you a powerful and flexible way to refer to specific elements in complex, nested objects.\n */\n\nexport const POSITION_ARRAY_KEY_PREFIX = 'pos:';\n\n/**\n * Checks if the given key is a position array key.\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is a position array key, false otherwise.\n * @example\n * isPositionArrayKey('pos:0'); // Returns true\n * isPositionArrayKey('id:0'); // Returns false\n */\nexport const isPositionArrayKey = (key: unknown): key is string => {\n return isString(key) && key.startsWith(POSITION_ARRAY_KEY_PREFIX);\n};\n\n/**\n * Creates a position array key.\n * @param {string} position - The position to create the key for.\n * @returns {string} Returns the created position array key.\n * @example\n * createPositionArrayKey('0'); // Returns 'pos:0'\n */\nexport const createPositionArrayKey = (position: string) => {\n return `${POSITION_ARRAY_KEY_PREFIX}${position}`;\n};\n\n/**\n * Extracts the position from a position array key.\n * @param {string} key - The position array key to extract the position from.\n * @returns {string} Returns the extracted position.\n * @example\n * extractPositionFromArrayKey('pos:0'); // Returns '0'\n */\nexport const extractPositionFromArrayKey = (key: string): string => {\n if (!isPositionArrayKey(key)) {\n throw new Error(`Invalid array key ${key}. Must be \"pos:xxxxx\"`);\n }\n\n return key.split(POSITION_ARRAY_KEY_PREFIX)[1];\n};\n\n/* ID KEY */\nexport const ID_PATH_KEY_PREFIX = 'id:';\n\n/**\n * Checks if the given key is an ID array key.\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is an ID array key, false otherwise.\n * @example\n * isIdArrayKey('id:123'); // Returns true\n * isIdArrayKey('pos:0'); // Returns false\n */\nexport const isIdArrayKey = (key: unknown): key is string => {\n return isString(key) && key.startsWith(ID_PATH_KEY_PREFIX);\n};\n\n/**\n * Creates an ID array key.\n * @param {string} id - The ID to create the key for.\n * @returns {string} Returns the created ID array key.\n * @example\n * createIdArrayKey('123'); // Returns 'id:123'\n */\nexport const createIdArrayKey = (id: string) => {\n return `${ID_PATH_KEY_PREFIX}${id}`;\n};\n\n/**\n * Extracts the ID from an ID array key.\n * @param {string} key - The ID array key to extract the ID from.\n * @returns {string} Returns the extracted ID.\n * @example\n * extractIdFromArrayKey('id:123'); // Returns '123'\n */\nexport const extractIdFromArrayKey = (key: string): string => {\n if (!isIdArrayKey(key)) {\n throw new Error(`Invalid array key ${key}. Must be \"id:xxxxx\"`);\n }\n\n return key.split(ID_PATH_KEY_PREFIX)[1];\n};\n\n/* ARRAY KEYS */\n\n/**\n * Checks if the given key is an array key (either a position array key or an ID array key).\n * @param {unknown} key - The key to check.\n * @returns {boolean} Returns true if `key` is an array key, false otherwise.\n * @example\n * isArrayKey('id:123'); // Returns true\n * isArrayKey('pos:0'); // Returns true\n * isArrayKey('abc'); // Returns false\n */\nexport const isArrayKey = (key: unknown): key is string => isString(key) && (isPositionArrayKey(key) || isIdArrayKey(key));\n\n/**\n * Extracts the index from an array key in a given array.\n * @param {unknown} array - The array to extract the index from.\n * @param {string} key - The array key to extract the index from.\n * @returns {number} Returns the extracted index.\n * @example\n * getIndexByArrayKey(['a', 'b', 'c'], 'pos:1'); // Returns 1\n */\nexport const getIndexByArrayKey = (array: unknown, key: string): number => {\n if (!Array.isArray(array)) {\n console.error(`Non-array type`, array);\n\n throw new Error(`Can't use array key in non array type (${key})`);\n }\n\n if (!isArrayKey(key)) {\n throw new Error(`Unknown array key type (${key})`);\n }\n\n if (array.length === 0) {\n return 0;\n }\n\n if (isIdArrayKey(key)) {\n const id = extractIdFromArrayKey(key);\n const index = array.findIndex((it) => isObject(it) && it.id === id);\n if (index === -1) {\n throw new Error(`Can't find index by id ${id} (${key})`);\n }\n\n return index;\n } else if (isPositionArrayKey(key)) {\n const position = extractPositionFromArrayKey(key);\n const index = array.findIndex((it) => it.position === position);\n if (index === -1) {\n throw new Error(`Can't find index by position ${position} (${key})`);\n }\n\n return index;\n }\n\n return 0;\n};\n","// Paths is an array with keys and indexes that represent a path to a value in a deep object.\n// For example, for the object { items: [{ name: 'John' }]} the path to the first item name is ['items', 0, 'name'].\n\nimport {\n isContainerValue, isIndex, isNullOrUndefined, isObject,\n} from '@/assertions/index.js';\n\nimport { getIndexByArrayKey, isArrayKey } from './array-keys.js';\nimport { NestedRecord } from './types.js';\n\n/**\n * Gets a nested property value from an object using a path.\n * @param {NestedRecord | undefined} object - The object to get the value from.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @returns {TValue | undefined} Returns the value at the specified path in the object.\n * @example\n * getFromPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns 'John'\n */\nexport const getFromPath = <TValue = unknown>(object: NestedRecord | undefined, path: (string | number)[]): TValue | undefined => {\n if (!object) {\n return;\n }\n\n if (path.length === 0) {\n return object as TValue;\n }\n\n const resolvedValue = path\n .reduce((acc, propKey) => {\n const key = isArrayKey(propKey) ? getIndexByArrayKey(acc, propKey) : propKey;\n\n if (isContainerValue(acc) && key in acc) {\n return acc[key];\n }\n\n return;\n }, object as unknown);\n\n return resolvedValue as TValue | undefined;\n};\n\n/**\n * Sets a nested property value in a path, creates the path properties if they don't exist.\n * @param {NestedRecord} object - The object to set the value in.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @param {unknown} value - The value to set.\n * @example\n * let obj = { items: [{ name: 'John' }] };\n * setInPath(obj, ['items', 0, 'name'], 'Jane'); // obj is now { items: [{ name: 'Jane' }] }\n */\nexport const setInPath = (object: NestedRecord, path: (string | number)[], value: unknown): void => {\n let acc = object;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getIndexByArrayKey(acc, rawKey) : rawKey;\n\n if (Array.isArray(acc)) {\n const index = Number(key);\n\n // Last key, set it\n if (i === path.length - 1) {\n acc[index] = value;\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!(index in acc) || isNullOrUndefined(acc[index])) {\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n // container can be either an object or an array depending on the next key if it exists\n acc[index] = isIndex(nextKey) ? [] : {\n };\n }\n\n acc = acc[index] as Record<string, unknown>;\n } else {\n // Last key, set it\n if (i === path.length - 1) {\n acc[key] = value;\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!(key in acc) || isNullOrUndefined(acc[key])) {\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n // container can be either an object or an array depending on the next key if it exists\n acc[key] = isIndex(nextKey) ? [] : {\n };\n }\n\n acc = acc[key] as Record<string, unknown>;\n }\n }\n};\n\nconst unset = (object: Record<string, unknown> | unknown[], key: string | number) => {\n if (Array.isArray(object) && isIndex(key)) {\n object.splice(Number(key), 1);\n\n return;\n }\n\n if (isObject(object)) {\n delete object[key];\n }\n};\n\n/**\n * Removes a nested property from an object using a path.\n * @param {NestedRecord} object - The object to remove the value from.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @example\n * let obj = { items: [{ name: 'John' }] };\n * unsetPath(obj, ['items', 0, 'name']); // obj is now { items: [{}] }\n */\nexport const unsetPath = (object: NestedRecord, path: (string | number)[]): void => {\n let acc = object;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getIndexByArrayKey(acc, rawKey) : rawKey;\n\n // Last key, unset it\n if (i === path.length - 1) {\n unset(acc, key);\n break;\n }\n\n if (Array.isArray(acc)) {\n const index = Number(key);\n\n // Key does not exist, exit\n if (!(key in acc) || isNullOrUndefined(acc[index])) {\n break;\n }\n\n acc = acc[index] as Record<string, unknown>;\n } else {\n // Key does not exist, exit\n if (!(key in acc) || isNullOrUndefined(acc[key])) {\n break;\n }\n\n acc = acc[key] as Record<string, unknown>;\n }\n }\n};\n\n/** Checks if a nested property exists in an object using a path.\n * @param {NestedRecord | undefined} object - The object to check the value in.\n * @param {(string | number)[]} path - The path to the value in the object.\n * @returns {boolean} Returns true if the value exists at the specified path, false otherwise.\n * @example\n * existsInPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns true\n * existsInPath({ items: [{ name: 'John' }] }, ['items', 1, 'name']); // Returns false\n */\nexport const existsInPath = (object: NestedRecord | undefined, path: (string | number)[]): boolean => {\n return getFromPath(object, path) !== undefined;\n};\n\n/** * Compares two paths for equality.\n * @param {(string | number)[]} pathA - The first path to compare.\n * @param {(string | number)[]} pathB - The second path to compare.\n * @returns {boolean} Returns true if the paths are equal, false otherwise.\n * @example\n * isSamePath(['items', 0, 'name'], ['items', 0, 'name']); // Returns true\n * isSamePath(['items', 0, 'name'], ['items', 1, 'name']); // Returns false\n */\nexport const isSamePath = (pathA: (string | number)[], pathB: (string | number)[]): boolean => {\n if (pathA.length !== pathB.length) {\n return false;\n }\n\n for (let i = 0; i < pathA.length; i++) {\n if (pathA[i] !== pathB[i]) {\n return false;\n }\n }\n\n return true;\n};\n","import { isIndex, isObject } from '@/assertions/index.js';\nimport { generateKeyBetween } from '@/dynamic-components/fractional-indexing.js';\n\nimport { getIndexByArrayKey, isArrayKey } from './array-keys.js';\nimport { getFromPath, setInPath } from './basic-ops.js';\nimport { NestedRecord } from './types.js';\n\n/**\n * Pushes a value into a nested array in an object using a path.\n * @param {NestedRecord} object - The object to push the value into.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {unknown} value - The value to push.\n * @example\n * let obj = { items: ['John'] };\n * pushInPath(obj, ['items'], 'Jane'); // obj is now { items: ['John', 'Jane'] }\n */\nexport const pushInPath = (object: NestedRecord, path: (string | number)[], value: unknown) => {\n const array = getFromPath(object, path);\n if (!Array.isArray(array)) {\n setInPath(object, path, [value]);\n } else {\n array.push(value);\n }\n};\n\n/**\n * Inserts values into a nested array in an object at a specified index or key using a path.\n * @param {NestedRecord} object - The object to insert the values into.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {string | number} keyOrIndex - The index or key at which to insert the values.\n * @param {unknown[]} values - The values to insert.\n * @example\n * let obj = { items: ['John', 'Jane'] };\n * insertInPath(obj, ['items'], 1, ['Joe']); // obj is now { items: ['John', 'Joe', 'Jane'] }\n */\nexport const insertInPath = (object: NestedRecord, path: (string | number)[], keyOrIndex: string | number, values: unknown[]) => {\n const array = getFromPath(object, path) as unknown[];\n\n if (Array.isArray(array)) {\n if (isIndex(keyOrIndex)) {\n array.splice(keyOrIndex, 0, ...values);\n } else if (isArrayKey(keyOrIndex)) {\n const index = getIndexByArrayKey(array, keyOrIndex);\n array.splice(index, 0, ...values);\n }\n }\n};\n\n/**\n * Removes a value from a nested array in an object at a specified index or array key using a path.\n * @param {NestedRecord} object - The object to remove the value from.\n * @param {(string | number)[]} path - The path to the array in the object.\n * @param {string | number} key - The index or key at which to remove the value.\n * @example\n * let obj = { items: ['John', 'Joe', 'Jane'] };\n * pullFromPath(obj, ['items'], 1); // obj is now { items: ['John', 'Jane'] }\n */\nexport const pullFromPath = (object: NestedRecord, path: (string | number)[], key: string | number) => {\n const array = getFromPath(object, path) as unknown[];\n\n if (Array.isArray(array)) {\n if (isIndex(key)) {\n array.splice(key, 1);\n } else if (isArrayKey(key)) {\n const index = getIndexByArrayKey(array, key);\n array.splice(index, 1);\n }\n }\n};\n\nconst printPosition = (array: { position?: string }[]) => array.map((it) => isObject(it) ? it.position ?? 'no-position' : 'not-object');\n\n/**\n * Moves an item to a new position relative to another item in the array or object at the specified path.\n *\n * @example\n * moveInYPath(values, ['components'], 'a0', 'b1', 'after');\n */\nexport const moveInPath = (\n object: NestedRecord,\n path: (string | number)[],\n oldPosition: string,\n relativePosition: string,\n insert: 'before' | 'after',\n) => {\n const array = getFromPath(object, path);\n if (!Array.isArray(array)) {\n throw new Error(`Can't move. Target item is not array in path ${JSON.stringify(path)}`);\n }\n\n const item = array.find((it) => isObject(it) && it.position === oldPosition);\n const relativeItemIndex = array.findIndex((it) => isObject(it) && it.position === relativePosition);\n\n if (!isObject(item)) {\n throw new Error(`Can't move. Item in position ${oldPosition} not found. ${printPosition(array)}`);\n }\n\n if (relativeItemIndex === -1) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} not found. ${printPosition(array)}`);\n }\n\n const relativeItem = array[relativeItemIndex];\n if (!isObject(relativeItem)) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} must be an object. ${printPosition(array)}`);\n }\n\n if (insert === 'before') {\n const left = array[relativeItemIndex - 1];\n const leftPosition = isObject(left) ? left.position as string ?? null : null;\n\n const newPosition = generateKeyBetween(leftPosition, relativeItem.position as string);\n item.position = newPosition;\n\n return newPosition;\n }\n\n const right = array[relativeItemIndex + 1];\n const rightPosition = isObject(right) ? right.position as string ?? null : null;\n\n const newPosition = generateKeyBetween(relativeItem.position as string, rightPosition);\n item.position = newPosition;\n\n return newPosition;\n};\n","export const PATH_REGEXP = /\\.|\\[(\\d+)\\]/;\n","import { isString } from '@/assertions/index.js';\n\n/**\n * Joins a path with additional items.\n * @param {(string | number)[]} path - The initial path.\n * @param {...(string | number)[]} items - The items to add to the path.\n * @returns {(string | number)[]} Returns the joined path.\n * @throws {Error} If `path` is not an array or if any of `items` are not a string or an integer.\n * @example\n * joinPath(['items', 'id:xxx'], 'name'); // Returns ['items', 'id:xxx', 'name']\n */\nexport const joinPath = (path: (string | number)[], ...items: (string | number)[]) => {\n if (!Array.isArray(path)) {\n throw new Error(`path must be array: ${path}`);\n }\n\n for (const item of items) {\n if (!isString(item) && !Number.isInteger(item)) {\n throw new Error(`Invalid path item: ${item}`);\n }\n }\n\n return path.concat(items);\n};\n\n/**\n * Compares two fractional-based position strings for sorting.\n * @param {string} aPosition - The first fractional-based position string.\n * @param {string} bPosition - The second fractional-based position string.\n * @returns {number} Returns -1 if `aPosition` comes before `bPosition`, 1 if `aPosition` comes after `bPosition`, or 0 if they are equal.\n * @example\n * sortByPosition('a1', 'a2'); // Returns -1\n */\nexport const sortByPosition = (aPosition: string, bPosition: string) => {\n if (aPosition < bPosition) {\n return -1;\n } else if (aPosition > bPosition) {\n return 1;\n }\n\n return 0;\n};\n","import { RichText } from '../../data-objects/rich-text.js';\nimport { DynamicComponent } from '../types.js';\n\n/* Text Message */\nexport interface DChatTextMessage extends DynamicComponent {\n component: 'chat-text-message';\n props: {\n content: RichText;\n };\n}\n\nexport const isChatTextMessageComponent = (component: DynamicComponent): component is DChatTextMessage => component.component === 'chat-text-message';\n\n/* Message Delay */\nexport interface DChatMessageDelay extends DynamicComponent {\n component: 'chat-message-delay';\n props: {\n delay: number;\n typing: boolean;\n };\n}\n\n// eslint-disable-next-line max-len\nexport const isChatMessageDelayComponent = (component: DynamicComponent): component is DChatMessageDelay => component.component === 'chat-message-delay';\n","import { RichText } from '../../data-objects/rich-text.js';\nimport { DynamicComponent } from '../types.js';\n\n/* TEXT INPUT */\nexport interface DRichText extends DynamicComponent {\n component: 'rich-text';\n props: {\n content: RichText;\n };\n}\n\nexport const isRichTextComponent = (component: DynamicComponent): component is DRichText => component.component === 'rich-text';\n\n/* RowSettings */\nexport interface DEmbedCode extends DynamicComponent {\n component: 'embed-code';\n props: {\n js?: string;\n css?: string;\n html?: string;\n visible?: string;\n };\n}\n\nexport const isEmbedCodeComponent = (component: DynamicComponent): component is DEmbedCode => {\n return component.component === 'embed-code';\n};\n\n/* Image */\nexport interface DImage extends DynamicComponent {\n component: 'embed-code';\n props: {\n imageId: string;\n };\n}\n\nexport const isImageComponent = (component: DynamicComponent): component is DImage => component.component === 'image';\n\n/* Legacy Content */\nexport interface DLegacyContent extends DynamicComponent {\n component: 'legacy-content';\n props: {\n html: string;\n };\n}\n\nexport const isLegacyContentComponent = (component: DynamicComponent): component is DLegacyContent => component.component === 'legacy-content';\n\n/* Bible Quote */\nexport interface DBibleQuote extends DynamicComponent {\n component: 'bible-quote';\n props: {\n verseId: string;\n };\n}\n\nexport const isBibleQuoteComponent = (component: DynamicComponent): component is DBibleQuote => component.component === 'bible-quote';\n\n/* Bible Passage */\nexport interface DBiblePassage extends DynamicComponent {\n component: 'bible-passage';\n props: {\n passage: string;\n };\n}\n\nexport const isBiblePassageComponent = (component: DynamicComponent): component is DBiblePassage => component.component === 'bible-passage';\n\n/* TESTS */\n\nexport interface TestItemVariant {\n id: string;\n content: RichText;\n feedback?: RichText;\n correct?: boolean;\n}\n\nexport interface TestItem {\n id: string;\n content: RichText;\n variants: TestItemVariant[];\n}\n\nexport interface DTest extends DynamicComponent {\n component: 'test';\n props: {\n title?: string;\n items: TestItem[];\n milestone?: string;\n };\n}\n\nexport const isTestComponent = (component: DynamicComponent): component is DTest => component.component === 'test';\n\nexport interface DStatement extends DynamicComponent {\n component: 'statement';\n props: {\n content: RichText;\n };\n}\n\nexport const isStatementComponent = (component: DynamicComponent): component is DStatement => component.component === 'statement';\n\nexport interface DPractice extends DynamicComponent {\n component: 'practice';\n props: {\n title?: string;\n content: RichText;\n\n /**\n * Date when the practice should be checked in ISO 8601 format\n * @example '2023-10-01T00:08:00Z'\n */\n checkAt?: string;\n };\n}\n\nexport const isPracticeComponent = (component: DynamicComponent): component is DPractice => component.component === 'practice';\n","import { DynamicComponent, ValidationRules } from '../types.js';\n\nexport type ISizeType = 'middle' | 'large';\n\nexport enum IImageRenditionType {\n ORIGINAL = 'ORIGINAL',\n MAIN_2X = 'MAIN_2X',\n MAIN = 'MAIN',\n SMALL = 'SMALL',\n MAIN_LEGACY = 'MAIN_LEGACY',\n}\n\nexport interface IRenditionOptions {\n width: number;\n height: number;\n type: IImageRenditionType;\n mimeType?: string;\n quality?: number;\n}\n\n/* HIDDEN INPUT */\nexport interface DHiddenInput extends DynamicComponent {\n component: 'hidden-input';\n props: {\n name?: string;\n rules?: ValidationRules;\n testId?: string;\n };\n}\n\n/* COMPUTED VALUE */\nexport interface DComputedValue extends DynamicComponent {\n component: 'computed-value';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n type: 'string' | 'number';\n expression: string;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isComputedValueComponent = (component: DynamicComponent): component is DComputedValue => component.component === 'computed-value';\n\n/* TEXT INPUT */\nexport interface DTextInput extends DynamicComponent {\n component: 'text-input';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n clearable?: boolean;\n maska?: string;\n disabled?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isTextInputComponent = (component: DynamicComponent): component is DTextInput => component.component === 'text-input';\n\n/* CONFIRM DELATION INPUT */\nexport interface DConfirmDeletionInput extends DynamicComponent {\n component: 'confirm-deletion-input';\n props: {\n title?: string;\n text?: string;\n keyWord: string;\n testId?: string;\n };\n}\n\nexport const isConfirmDeletionInputComponent = (component: DynamicComponent):\n component is DConfirmDeletionInput => component.component === 'confirm-deletion-input';\n\n/* TEXTAREA */\nexport interface DTextarea extends DynamicComponent {\n component: 'textarea';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n rows?: number;\n autosize?: boolean;\n lineBreak?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isTextareaComponent = (component: DynamicComponent): component is DTextarea => component.component === 'textarea';\n\n/* HEADING */\nexport interface DHeading extends DynamicComponent {\n component: 'heading';\n props: {\n text: string;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isHeadingComponent = (component: DynamicComponent): component is DHeading => component.component === 'heading';\n\n/* RICH TEXT EDITOR */\nexport interface DRichTextEditor extends DynamicComponent {\n component: 'rich-text-editor';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n minHeight?: number;\n maxLength?: number;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isRichTextEditorComponent = (component: DynamicComponent): component is DRichTextEditor => component.component === 'rich-text-editor';\n\n/* DATE */\nexport interface DDateTimePicker extends DynamicComponent {\n component: 'date-time-picker';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n type?: 'year' | 'month' | 'date' | 'dates' | 'week' | 'datetime' | 'datetimerange' | 'daterange' | 'monthrange';\n readonly?: boolean;\n format?: string;\n clearable?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isDateTimePickerComponent = (component: DynamicComponent): component is DDateTimePicker => {\n return component.component === 'date-time-picker';\n};\n\n/* NUMBER */\nexport interface DNumberInput extends DynamicComponent {\n component: 'number-input';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n autosize?: boolean;\n readonly?: boolean;\n rules?: ValidationRules;\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isNumberInputComponent = (component: DynamicComponent): component is DNumberInput => {\n return component.component === 'number-input';\n};\n\n/* SLUG */\nexport interface DSlug extends DynamicComponent {\n component: 'slug';\n props: {\n name?: string;\n source?: string;\n maxLength?: number;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isSlugComponent = (component: DynamicComponent): component is DSlug => {\n return component.component === 'slug';\n};\n\n/* Image Uploader DynamicComponent */\nexport interface DImageUploader extends DynamicComponent {\n component: 'image-uploader';\n props: {\n name?: string;\n label?: string;\n renditions: {\n id: string;\n position: string;\n width: number;\n height: number;\n type: IImageRenditionType;\n }[];\n btnText?: string;\n size?: ISizeType;\n rounded?: ISizeType;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n tooltipContent?: string;\n hideTooltip?: boolean;\n maxFileSize?: number;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isImageUploaderComponent = (component: DynamicComponent): component is DImageUploader => {\n return component.component === 'image-uploader';\n};\n\nexport interface DRawImageUploader extends DynamicComponent {\n component: 'raw-image-uploader';\n props: {\n name?: string;\n label?: string;\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n hideTooltip?: boolean;\n tooltipContent?: string;\n maxFileSize?: number;\n visible?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isRawImageUploaderComponent = (component: DynamicComponent): component is DRawImageUploader => {\n return component.component === 'raw-image-uploader';\n};\nexport interface DRawImagesUploader extends DynamicComponent {\n component: 'raw-images-uploader';\n props: {\n name?: string;\n label?: string;\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n height?: number;\n width?: number;\n tooltipContent?: string;\n hideTooltip?: boolean;\n maxFileSize?: number;\n visible?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n max?: number;\n };\n testId?: string;\n };\n}\n\nexport const isRawImagesUploaderComponent = (component: DynamicComponent): component is DRawImagesUploader => {\n return component.component === 'raw-images-uploader';\n};\n\nexport interface DSimpleImageUploader extends DynamicComponent {\n component: 'simple-image-uploader';\n props: {\n name?: string;\n label?: string;\n rendition: {\n width: number;\n height: number;\n type: IImageRenditionType;\n };\n btnText?: string;\n size?: ISizeType;\n rounded?: boolean;\n zoomable?: boolean;\n downloadable?: boolean;\n width: number;\n height: number;\n hideTooltip?: boolean;\n tooltipContent?: string;\n maxFileSize?: number;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isSimpleImageUploaderComponent = (component: DynamicComponent): component is DSimpleImageUploader => {\n return component.component === 'simple-image-uploader';\n};\n\n/* UPLOAD */\n// export interface DUpload extends DynamicComponent {\n// component: 'upload';\n// props: {\n// fileType: string;\n// listType?: 'text' | 'picture' | 'picture-card';\n// limit?: number;\n// multiple?: boolean;\n// rules?: {\n// required?: boolean;\n// };\n// };\n// }\n\n/* MONACO */\n// export interface DMonaco extends DynamicComponent {\n// component: 'monaco';\n// props: {\n// height?: number;\n// rules?: {\n// required?: boolean;\n// };\n// };\n// }\n\n/* CONTENTFLOW */\n// export interface DDesigner extends DynamicComponent {\n// component: 'designer';\n// props: {\n// name?: string;\n// };\n// }\n\n/* RADIO GROUP */\nexport interface DRadioGroup extends DynamicComponent {\n component: 'radio-group';\n props: {\n name?: string;\n label?: string;\n cols?: number;\n direction?: 'col' | 'row';\n items: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n }[];\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isRadioGroupComponent = (component: DynamicComponent): component is DRadioGroup => {\n return component.component === 'radio-group';\n};\n\n/* SELECT */\nexport interface DSelect extends DynamicComponent {\n component: 'select';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n clearable?: boolean;\n options: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n imageUrl?: string;\n disabled?: boolean;\n }[];\n readonly?: boolean;\n multiple?: boolean;\n rules?: {\n required?: boolean;\n max?: number;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isSelectComponent = (cmp: DynamicComponent): cmp is DSelect => cmp.component === 'select';\n\n/* ENTITY */\nexport interface DEntitySelect extends DynamicComponent {\n component: 'entity-select';\n props: {\n name?: string;\n label?: string;\n placeholder?: string;\n hint?: string;\n entityType: string;\n labelKey?: string;\n idKey?: string;\n filter?: Record<string, unknown>;\n limit?: number;\n multiple?: boolean;\n visible?: string;\n clearable?: boolean;\n rules?: {\n required?: boolean;\n };\n readonly?: boolean;\n excludeIds?: string[];\n imageUrlKey?: string;\n defaultImageUrl?: string;\n testId?: string;\n };\n}\n\nexport const isEntitySelectComponent = (cmp: DynamicComponent): cmp is DEntitySelect => cmp.component === 'entity-select';\n\n/* CHECKBOX */\nexport interface DCheckbox extends DynamicComponent {\n component: 'checkbox';\n props: {\n name?: string;\n label?: string;\n readonly?: boolean;\n rules?: {\n required?: boolean;\n };\n visible?: string;\n testId?: string;\n };\n}\n\nexport const isCheckboxComponent = (component: DynamicComponent): component is DCheckbox => {\n return component.component === 'checkbox';\n};\n\n/* CHECKBOX GROUP */\nexport interface DCheckboxGroup extends DynamicComponent {\n component: 'checkbox-group';\n props: {\n name?: string;\n label?: string;\n orientation?: 'horizontal' | 'vertical';\n items: {\n id: string;\n position: string;\n value: unknown;\n label: string;\n }[];\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isCheckboxGroupComponent = (component: DynamicComponent): component is DCheckboxGroup => {\n return component.component === 'checkbox';\n};\n\n/* SWITCH */\nexport interface DSwitch extends DynamicComponent {\n component: 'switch';\n props: {\n name?: string;\n label?: string;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isSwitchComponent = (component: DynamicComponent): component is DSwitch => {\n return component.component === 'switch';\n};\n\n/* File Uploader */\nexport interface DFileUploader extends DynamicComponent {\n component: 'file-uploader';\n props: {\n name?: string;\n label?: string;\n accept?: string;\n placeholder?: string;\n maxFileSize?: number;\n downloadable?: boolean;\n readonly?: boolean;\n visible?: string;\n rules?: {\n required?: boolean;\n };\n testId?: string;\n };\n}\n\nexport const isFileUploaderComponent = (component: DynamicComponent): component is DFileUploader => {\n return component.component === 'file-uploader';\n};\n","import { DynamicComponent, ValidationRules } from '../types.js';\n\n/* ROW & COLUMS */\nexport interface DColumn extends DynamicComponent {\n component: 'column';\n props: {\n size: number;\n visible?: string;\n justifySelf?: 'start' | 'center' | 'end' | 'stretch';\n placeSelf?: 'start' | 'center' | 'end' | 'stretch';\n components: DynamicComponent[];\n };\n}\n\nexport const isColumnComponent = (component: DynamicComponent): component is DColumn => {\n return component.component === 'column';\n};\n\nexport interface DRow extends DynamicComponent {\n component: 'row';\n props: {\n components: DColumn[];\n visible?: string;\n placeItems?: 'start' | 'center' | 'end' | 'stretch';\n justifyItems?: 'start' | 'center' | 'end' | 'stretch';\n };\n}\n\nexport const isRowComponent = (component: DynamicComponent): component is DRow => {\n return component.component === 'row';\n};\n\n/* COLLECTION */\nexport interface DCollection extends DynamicComponent {\n component: 'collection';\n props: {\n name?: string;\n heading: string;\n components: DynamicComponent[];\n rules?: ValidationRules;\n readonly?: boolean;\n visible?: string;\n };\n}\n\nexport const isCollectionComponent = (component: DynamicComponent): component is DCollection => {\n return component.component === 'collection';\n};\n\n/* REPEATABLE COLLECTION */\nexport interface DRepeatableCollection extends DynamicComponent {\n component: 'repeatable-collection';\n props: {\n name?: string;\n heading?: string;\n collectionTitle?: string;\n useTabs?: boolean;\n cols?: number;\n tabName?: string;\n confirmDeletion?: boolean;\n addButtonText?: string;\n readonly?: boolean;\n draggable?: boolean;\n components: DynamicComponent[];\n visible?: string;\n rules?: {\n required?: boolean;\n };\n };\n}\n\nexport const isRepeatableCollectionComponent = (component: DynamicComponent): component is DRepeatableCollection => {\n return component.component === 'repeatable-collection';\n};\n\n/* RowSettings */\nexport interface DRowSettings extends DynamicComponent {\n component: 'row-settings';\n props: {\n label?: string;\n };\n}\n\nexport const isRowSettingsComponent = (component: DynamicComponent): component is DRowSettings => {\n return component.component === 'row-settings';\n};\n","import { isString } from '@/assertions/index.js';\nimport { isArrayKey } from '@/paths/index.js';\n\nimport {\n isCollectionComponent,\n isColumnComponent, isRepeatableCollectionComponent, isRowComponent,\n} from './registry/index.js';\nimport { DynamicComponent } from './types.js';\n\n/**\n * Get array with components founded by rpath\n *\n * @example\n * const components = [\n * {\n * id: \"xxx\",\n * component: \"collection\",\n * props: {\n * components: [\n * {\n * id: \"yyy\",\n * component: \"text-input\",\n * props: {\n * label: \"Title\"\n * }\n * }\n * ]\n * }\n * }\n * ]\n *\n * const { pathWithComponents } = getComponentsSubtreeByRPath(components, ['xxx', 'yyy']);\n *\n * // pathWithComponents\n * // [\n * // {\n * // id: \"xxx\",\n * // component: \"collection\",\n * // ...\n * // },\n * // {\n * // id: \"yyy\",\n * // component: \"text-input\",\n * // ...\n * // }\n * // ]\n *\n */\nexport const getComponentsSubtreeByRPath = (components: DynamicComponent[], rpath: string[]) => {\n const pathWithComponents: DynamicComponent[] = [];\n\n deepGetComponentsSubtreeByRPath(components, rpath, pathWithComponents);\n\n return {\n pathWithComponents,\n complete: pathWithComponents.length === rpath.length,\n };\n};\n\nconst deepGetComponentsSubtreeByRPath = (components: DynamicComponent[], rpath: string[], pathWithComponents: DynamicComponent[]) => {\n const id = rpath[0];\n\n const component = components.find((cmp) => cmp.id === id);\n\n if (!component) {\n return;\n }\n\n pathWithComponents.push(component);\n\n if (!Array.isArray(component.props.components)) {\n return;\n }\n\n deepGetComponentsSubtreeByRPath(component.props.components, rpath.slice(1), pathWithComponents);\n};\n\n/**\n * Get array with components founded by values path.\n *\n * @example\n * const components = [\n * {\n * id: \"xxx\",\n * component: \"collection\",\n * props: {\n * name: \"seo\",\n * components: [\n * {\n * id: \"yyy\",\n * component: \"text-input\",\n * props: {\n * label: \"Title\",\n * name: \"title\",\n * }\n * }\n * ]\n * }\n * }\n * ]\n *\n * const { pathWithComponents } = getComponentsSubtreeByPath(components, ['seo', 'title']);\n *\n * // pathWithComponents\n * // [\n * // {\n * // id: \"xxx\",\n * // component: \"collection\",\n * // ...\n * // },\n * // {\n * // id: \"yyy\",\n * // component: \"text-input\",\n * // ...\n * // }\n * // ]\n *\n */\nexport const getComponentsSubtreeByPath = (components: DynamicComponent[], path: (string | number)[]) => {\n const pathWithComponents: DynamicComponent[] = [];\n const complete = true;\n\n deepGetComponentsSubtreeByPath(components, path, pathWithComponents, complete);\n\n return {\n pathWithComponents,\n complete,\n };\n};\n\nconst deepFindComponentPathKey = (components: DynamicComponent[], key: string): DynamicComponent | null => {\n for (const component of components) {\n if ((component.props.name && component.props.name === key) || component.id === key) {\n return component;\n }\n\n if (isRowComponent(component) || isColumnComponent(component)) {\n const result = deepFindComponentPathKey(component.props.components, key);\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n};\n\nconst deepGetComponentsSubtreeByPath = (\n components: DynamicComponent[],\n path: (string | number)[],\n pathWithComponents: DynamicComponent[],\n complete: boolean,\n) => {\n const key = path[0];\n\n if (!isString(key)) {\n complete = false;\n\n return;\n }\n\n const component = deepFindComponentPathKey(components, key);\n\n if (!component) {\n complete = false;\n\n return;\n }\n\n pathWithComponents.push(component);\n\n /**\n * Deep dive if repeatable collection.\n *\n * If next key is array key find in props.components next key after array key\n *\n * @example\n * path = ['fields', 'id:xxx', 'title']\n *\n * cpnst key = 'fields';\n * const nextKey = 'id:xxx', // array key\n * const nextKeyAfterArrayKey = 'title';\n */\n if (isRepeatableCollectionComponent(component)) {\n const nextKey = path[1];\n if (isArrayKey(nextKey) && path[2]) {\n deepGetComponentsSubtreeByPath(component.props.components, path.slice(2), pathWithComponents, complete);\n }\n }\n\n if (isCollectionComponent(component)) {\n deepGetComponentsSubtreeByPath(component.props.components, path.slice(1), pathWithComponents, complete);\n }\n};\n","import * as Y from 'yjs';\n\nimport { isRichText } from '../assertions/rich-text.js';\nimport { generateKeyBetween } from './fractional-indexing.js';\nimport {\n DynamicComponent, DynamicComponentWithPosition, Point,\n} from './types.js';\n\n// This alphabet uses `A-Za-z0-9_-` symbols.\n// The order of characters is optimized for better gzip and brotli compression.\n// References to the same file (works both for gzip and brotli):\n// `'use`, `andom`, and `rict'`\n// References to the brotli default dictionary:\n// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`\nexport const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';\n\nexport const customAlphabet = (alphabet: string, defaultSize = 21) => {\n return (size = defaultSize) => {\n let id = '';\n // A compact alternative for `for (var i = 0; i < step; i++)`.\n let i = size;\n while (i--) {\n // `| 0` is more compact and faster than `Math.floor()`.\n // eslint-disable-next-line no-bitwise\n id += alphabet[(Math.random() * alphabet.length) | 0];\n }\n\n return id;\n };\n};\n\nexport const uid = customAlphabet('1234567890abcdefg', 5);\n\n/**\n * Gets the path to a property in a component.\n * @param {(string | number)[]} componentPath - The path to the component.\n * @param {string} name - The name of the property.\n * @returns {(string | number)[]} Returns the path to the property.\n * @example\n * getComponentPropertyPath(['components', 0], 'name'); // Returns ['components', 0, 'props', 'name']\n */\nexport const getComponentPropertyPath = (componentPath: (string | number)[], name: string) => [...componentPath, 'props', name];\n\n/**\n * Creates a copy of a dynamic component.\n * @param {DynamicComponent} component - The component to copy.\n * @param {Y.Doc} yDoc - The Yjs document to update with the copied component.\n * @returns {DynamicComponent} Returns the copied component.\n */\nexport const copyDynamicComponent = (component: DynamicComponent, yDoc?: Y.Doc): DynamicComponent => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n id,\n\n props,\n coordinates,\n inputs,\n outputs,\n ...extras\n } = component;\n\n const componentCopy: DynamicComponent = {\n ...extras,\n id: uid(),\n props: {\n },\n };\n\n if (coordinates) {\n componentCopy.coordinates = [\n coordinates[0] + 10,\n coordinates[1] + 10,\n ];\n }\n\n if (inputs) {\n componentCopy.inputs = inputs.map((input) => ({\n ...input,\n id: uid(),\n }));\n }\n\n if (outputs) {\n componentCopy.outputs = outputs.map((output) => ({\n ...output,\n id: uid(),\n }));\n }\n\n for (const [key, value] of Object.entries(props)) {\n if (key === 'components' && Array.isArray(value)) {\n componentCopy.props.components = value.map((cmp) => copyDynamicComponent(cmp));\n } else if (isRichText(value)) {\n const oldKey = `${value.type}:${value.id}`;\n\n const newRichText = {\n ...value,\n id: uid(),\n };\n\n const newKey = `${value.type}:${newRichText.id}`;\n\n if (yDoc) {\n const yXmlFragment = yDoc.getXmlFragment(oldKey);\n const newYXmlFragment = yDoc.getXmlFragment(newKey);\n\n const clones: (Y.XmlElement | Y.XmlText)[] = [];\n for (const item of yXmlFragment.toArray()) {\n if (item instanceof Y.XmlElement || item instanceof Y.XmlText) {\n clones.push(item.clone());\n }\n }\n\n newYXmlFragment.insert(0, clones);\n }\n\n componentCopy.props[key] = newRichText;\n } else {\n componentCopy.props[key] = value;\n }\n }\n\n return componentCopy;\n};\n\n/**\n * Sorts an array of dynamic components and generates a position for each one.\n * @param {DynamicComponent[]} components - The components to sort.\n * @returns {DynamicComponentWithPosition[]} Returns the sorted components with positions.\n */\nexport const sortDynamicComponents = (components: DynamicComponent[]): DynamicComponentWithPosition[] => {\n return components.reduce((acc, component, i) => {\n const prev = acc[i - 1];\n\n const {\n position,\n props: {\n components,\n ...baseProps\n },\n ...baseFields\n } = component;\n\n const props: DynamicComponentWithPosition['props'] = baseProps;\n\n if (components) {\n props.components = sortDynamicComponents(components);\n }\n\n acc.push({\n ...baseFields,\n position: position ?? generateKeyBetween(prev?.position ?? null, null),\n props,\n });\n\n return acc;\n }, [] as DynamicComponentWithPosition[]);\n};\n\n/**\n * Searches for a dynamic component in a tree that matches a condition.\n * @param {DynamicComponent[]} components - The tree of components to search.\n * @param {(cmp: DynamicComponent) => boolean} isMatches - The condition to match.\n * @returns {DynamicComponent | null} Returns the matching component, or null if no match was found.\n */\nexport const searchDynamicComponentInTree = (\n components: DynamicComponent[],\n isMatches: (cmp: DynamicComponent) => boolean,\n): DynamicComponent | null => {\n for (const component of components) {\n if (isMatches(component)) {\n return component;\n }\n\n if (Array.isArray(component.props.components)) {\n const result = searchDynamicComponentInTree(component.props.components, isMatches);\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n};\n\nexport const getRelativePoint = (point: Point, relative: Point): Point => [point[0] - relative[0], point[1] - relative[1]];\n\n/**\n * Creates a copy of a dynamic component and set its position (fractional-index) rely on the index of the component.\n * @param components - The components without positions.\n */\nexport const makeDynamicComponentsWithPosition = (components: DynamicComponent[]): DynamicComponentWithPosition[] => {\n return sortDynamicComponents(components.slice(0));\n};\n","export type Point = [number, number]; // [x, y]\n\nexport interface DynamicComponentIO {\n id: string;\n name: string;\n}\n\n/**\n * Represents a link between two dynamic components.\n */\nexport interface DynamicComponentLink {\n /** The unique identifier of the link. */\n id: string;\n /** The input of the link. */\n input: string;\n /** The output of the link. */\n output: string;\n}\n\n/**\n\n/**\n * ValidationRules interface is used for defining the set of\n * validation constraints for a field in a form or component.\n *\n * @example\n * let rules: ValidationRules = {\n * required: true,\n * min: 1,\n * max: 100,\n * pattern: 'email'\n * };\n */\nexport interface ValidationRules {\n /**\n * Indicates whether the field is required or not.\n */\n required?: boolean;\n\n /**\n * Specifies the minimum value for the field.\n */\n min?: number;\n\n /**\n * Specifies the maximum value for the field.\n */\n max?: number;\n\n /**\n * Specifies a pattern that the field value should match.\n */\n pattern?: 'email' | 'url' | 'hh:mm:ss' | 'phone';\n\n /**\n *Specifies whether to trim spaces.\n */\n trim?: boolean;\n}\n\nexport interface ComponentStyles {\n /**\n * Specifies the top padding of the component.\n */\n paddingTop?: string;\n\n /**\n * Specifies the bottom padding of the component.\n */\n paddingBottom?: string;\n}\n\n/**\n * DynamicComponent is a key feature of the component designer.\n * It is a data structure used to describe dynamic components,\n * which can be added to the content by the component designer and their properties can be edited on the fly.\n * The output of the designer is a tree of dynamic components.\n *\n * For example, a text input component can be described as follows:\n * ```typescript\n * export interface DTextInput extends DynamicComponent {\n * component: 'text-input';\n * props: {\n * name?: string;\n * label?: string;\n * placeholder?: string;\n * maska?: string;\n * disabled?: boolean;\n * readonly?: boolean;\n * rules?: ValidationRules;\n * visible?: string;\n * };\n * }\n * ```\n */\nexport interface DynamicComponent {\n /**\n * The unique identifier of the component.\n */\n id: string;\n\n /**\n * The type of the component.\n */\n component: string;\n\n /**\n * The variant of the component.\n * For example, a button component can have variants like 'primary', 'secondary', etc.\n */\n variant?: string;\n\n /**\n * The position of the component.\n */\n position?: string;\n\n /**\n * A flag indicating whether the component is enabled or not.\n */\n enabled?: boolean;\n\n /**\n * The coordinated of the component in the canvas.\n */\n coordinates?: Point;\n\n /**\n * The inputs of the component.\n * Input ports are used to connect the component to other components.\n */\n inputs?: DynamicComponentIO[];\n\n /**\n * The outputs of the component.\n * Output ports are used to connect the component to other components.\n */\n outputs?: DynamicComponentIO[];\n\n /**\n * The properties of the component.\n */\n props: {\n /**\n * The name of the component.\n */\n name?: string;\n\n /**\n * The visibility of the component.\n */\n visible?: string;\n\n /**\n * The readonly status of the component.\n */\n readonly?: boolean;\n\n /**\n * The child components of the component.\n */\n components?: DynamicComponent[];\n\n /**\n * The validation rules for the component.\n */\n rules?: ValidationRules;\n\n /**\n * The styles for the component.\n */\n styles?: ComponentStyles;\n\n /**\n * Any other properties of the component.\n */\n [key: string]: unknown;\n };\n}\n\n/**\n * DynamicComponent is a key feature of the component designer.\n * It is a data structure used to describe dynamic components ,\n * which can be added to the content by the component designer and their properties can be edited on the fly.\n * The output of the designer is a tree of dynamic components.\n *\n * DynamicComponentWithPosition is a DynamicComponent with defind fractional-indexed position.\n *\n * For example, a text input component can be described as follows:\n * ```typescript\n * {\n * component: 'text-input';\n * props: {\n * name: 'email';\n * label:: string;\n * placeholder?: string;\n * maska?: string;\n * disabled?: boolean;\n * readonly?: boolean;\n * rules?: ValidationRules;\n * visible?: string;\n * };\n * }\n * ```\n */\nexport interface DynamicComponentWithPosition extends DynamicComponent {\n /**\n * The position of the component. This is required for DynamicComponentWithPosition.\n */\n position: string;\n\n /**\n * The properties of the component.\n */\n props: DynamicComponent['props'] & {\n /**\n * The child components of the component.\n */\n components?: DynamicComponentWithPosition[];\n };\n}\n\n/**\n * Defines a DynamicComponent.\n * @param {T} component - The component to define.\n * @returns {T} Returns the defined component.\n */\nexport const defineDynamicComponent = <T extends DynamicComponent>(component: T): T => component;\n\n/**\n * Defines an array of DynamicComponents.\n * @param {T[]} components - The components to define.\n * @returns {T[]} Returns the defined components.\n */\nexport const defineDynamicComponents = <T extends DynamicComponent>(components: T[]): T[] =>\n components.map((component) => defineDynamicComponent<T>(component));\n\n","import * as Y from 'yjs';\n\nimport { isYArray, isYMap } from '@/assertions/index.js';\nimport {\n extractIdFromArrayKey, extractPositionFromArrayKey, isIdArrayKey, isPositionArrayKey,\n} from '@/paths/index.js';\n\n/**\n * Returns the index of an item in a Y.Array based on its key.\n * The key can represent either the id or the position of the item in the array.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap = new Y.Map();\n * yMap.set('id', '123');\n * yMap.set('position', 'a0');\n * yArray.push([yMap]);\n * const index = getYArrayIndexByArrayKey(yArray, 'id:123');\n * const index = getYArrayIndexByArrayKey(yArray, 'pos:a0');\n * // index is now: 0\n */\nexport const getYArrayIndexByArrayKey = (yArray: unknown, key: string): number => {\n if (!isYArray<Y.Map<unknown>>(yArray)) {\n console.error(`Non-YArray type`, yArray);\n throw new Error(`Can't use array key in non YArray type (${key})`);\n }\n\n if (isIdArrayKey(key)) {\n const id = extractIdFromArrayKey(key);\n const index = yArray.toArray().findIndex((it) => isYMap(it) && it.get('id') === id);\n if (index === -1) {\n throw new Error(`Can't find index by id ${id} (${key})`);\n }\n\n return index;\n } else if (isPositionArrayKey(key)) {\n const position = extractPositionFromArrayKey(key);\n const index = yArray.toArray().findIndex((it) => isYMap(it) && it.get('position') === position);\n if (index === -1) {\n throw new Error(`Can't find index by position ${position} (${key})`);\n }\n\n return index;\n }\n\n throw new Error(`Unknown array key type (${key})`);\n};\n","import * as Y from 'yjs';\n\nimport {\n isIndex, isNullOrUndefined, isString, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { isArrayKey } from '@/paths/index.js';\n\nimport { getYArrayIndexByArrayKey } from './y-array-keys.js';\n\n/**\n * Sets a value at a given path within a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * setInYPath(ymap, ['key'], 'value');\n * // ymap now looks like: { key: 'value' }\n */\nexport const setInYPath = (ymap: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[], value: unknown): void => {\n let acc: Y.Map<unknown> | Y.Array<unknown> = ymap;\n\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(acc, rawKey) : rawKey;\n\n if (isYArray(acc) && isIndex(key)) {\n const index = key;\n\n // Last key, set it\n if (i === path.length - 1) {\n acc.delete(index);\n acc.push([value]);\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (isNullOrUndefined(acc.get(index))) {\n // container can be either an object or an array depending on the next key if it exists\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getYArrayIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n\n // if (isArrayKey(nextKey)) {\n // throw Error(`Can't create empty array in \"${key}\" with next position key (path: ${JSON.stringify(path)})`);\n // }\n\n acc.delete(index);\n acc.insert(index, [isIndex(nextKey) ? new Y.Array() : new Y.Map()]);\n }\n\n acc = acc.get(index) as Y.Map<unknown> | Y.Array<unknown>;\n } else if (isYMap(acc) && isString(key)) {\n // Last key, set it\n if (i === path.length - 1) {\n acc.set(key, value);\n\n return;\n }\n\n // Key does not exist, create a container for it\n if (!acc.has(key) || isNullOrUndefined(acc.get(key))) {\n // container can be either an object or an array depending on the next key if it exists\n const nextRawKey = path[i + 1];\n const nextKey = isArrayKey(nextRawKey) ? getYArrayIndexByArrayKey(acc, nextRawKey) : nextRawKey;\n\n // if (isArrayKey(nextKey)) {\n // throw Error(`Can't create empty array in \"${key}\" with next position key \"${nextKey}\" (path: ${JSON.stringify(path)})`);\n // }\n\n acc.set(key, isIndex(nextKey) ? new Y.Array() : new Y.Map());\n }\n\n acc = acc.get(key) as Y.Map<unknown> | Y.Array<unknown>;\n }\n }\n};\n\nconst yUnset = (yType: Y.Map<unknown> | Y.Array<unknown>, key: string | number) => {\n if (yType instanceof Y.Array && isIndex(key)) {\n yType.delete(Number(key));\n } else if (yType instanceof Y.Map && isString(key)) {\n yType.delete(key);\n }\n};\n\n/**\n * Removes a nested property from a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * ymap.set('key', 'value');\n * unsetYPath(ymap, ['key']);\n * // ymap now looks like: {}\n */\nexport const unsetYPath = (yType: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[]): void => {\n let acc: Y.Map<unknown> | Y.Array<unknown> = yType;\n for (const [i, rawKey] of path.entries()) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(acc, rawKey) : rawKey;\n\n // Last key, unset it\n if (i === path.length - 1) {\n yUnset(acc, key);\n break;\n }\n\n if (acc instanceof Y.Array && isIndex(key)) {\n const index = Number(key);\n\n // Key does not exist, exit\n if (isNullOrUndefined(acc.get(index))) {\n break;\n }\n\n acc = acc.get(index) as Y.Map<unknown> | Y.Array<unknown>;\n } else if (acc instanceof Y.Map && isString(key)) {\n // Key does not exist, exit\n if (!acc.has(key) || isNullOrUndefined(acc.get(key))) {\n break;\n }\n\n acc = acc.get(key) as Y.Map<unknown> | Y.Array<unknown>;\n }\n }\n\n // const pathValues: (unknown | Record<string, unknown>)[] = keys.map((_, idx) => {\n // return getFromPath(object, keys.slice(0, idx).join('.'));\n // });\n\n // for (let i = pathValues.length - 1; i >= 0; i--) {\n // if (!isEmptyContainer(pathValues[i])) {\n // continue;\n // }\n\n // if (i === 0) {\n // unset(object, keys[0]);\n // continue;\n // }\n\n // unset(pathValues[i - 1] as Record<string, unknown>, keys[i - 1]);\n // }\n};\n\n/**\n * Retrieves a nested property value from a Y.Map or Y.Array.\n *\n * @example\n * let ymap = new Y.Map();\n * ymap.set('key', 'value');\n * const value = getFromYPath(ymap, ['key']);\n * // value is now: 'value'\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getFromYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[]): unknown | null => {\n if (!entry) {\n return;\n }\n\n if (path.length === 0) {\n return entry;\n }\n\n let ref = entry as unknown;\n for (const rawKey of path) {\n const key = isArrayKey(rawKey) ? getYArrayIndexByArrayKey(ref, rawKey) : rawKey;\n\n if (isYArray(ref)) {\n if (!isIndex(key)) {\n console.warn(`Can't use non index key in YArray ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n\n ref = ref.get(key);\n continue;\n } else if (isYMap(ref)) {\n if (!isString(key)) {\n console.warn(`Can't use non string key in YMap ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n\n ref = ref.get(key);\n } else {\n console.warn(`Non supported YType on ${key}: ${JSON.stringify(path)}`);\n\n return null;\n }\n }\n\n return ref;\n};\n","import * as Y from 'yjs';\n\nimport { isObject } from '@/assertions/index.js';\nimport { sortByPosition } from '@/paths/index.js';\n\n/**\n * Returns the index of the first item in a Y.Array that matches a condition.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * const index = findIndexInYArray(yArray, (item) => item === 'item2');\n * // index is now: 1\n */\nexport const findIndexInYArray = <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean): number => {\n return yArray.toArray().findIndex(isMatches);\n};\n\n/**\n * Returns the first item in a Y.Array that matches a condition.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * const item = findInYArray(yArray, (item) => item === 'item2');\n * // item is now: 'item2'\n */\nexport const findInYArray = <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean): T | null => {\n const index = findIndexInYArray(yArray, isMatches);\n if (index === -1) {\n return null;\n }\n\n return yArray.get(index);\n};\n\n/**\n * Converts an object to a Y.Map.\n *\n * @example\n * const object = { key: 'value' };\n * const yMap = objectToYMap(object);\n * // yMap now looks like: { key: 'value' }\n */\nexport const objectToYMap = (values: object) => {\n const entries: [string, unknown][] = Object.entries(values).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [key, arrayToYArray(value)];\n } else if (isObject(value)) {\n return [key, objectToYMap(value)];\n } else {\n return [key, value];\n }\n });\n\n return new Y.Map(entries);\n};\n\n/**\n * Converts an array to a Y.Array.\n *\n * @example\n * const array = ['item1', 'item2', 'item3'];\n * const yArray = arrayToYArray(array);\n * // yArray now looks like: ['item1', 'item2', 'item3']\n */\nexport const arrayToYArray = (array: unknown[], yArray: Y.Array<unknown> = new Y.Array()) => {\n const items = array.map((it) => isObject(it) ? objectToYMap(it) : it);\n yArray.insert(0, items);\n\n return yArray;\n};\n\n/**\n * Returns a sorted Y.Array based on the position of each Y.Map in it.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap1 = new Y.Map();\n * let yMap2 = new Y.Map();\n * yMap1.set('position', 'a0');\n * yMap2.set('position', 'b0');\n * yArray.push([yMap2, yMap1]);\n * const sortedYArray = getSortedYArray(yArray);\n * // sortedYArray now looks like: [ yMap1, yMap2 ]\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getSortedYArray = <T extends Y.Map<any>>(yArray: Y.Array<T>) => yArray\n .toArray()\n .sort((a, b) => sortByPosition((a.get('position') as string), (b.get('position') as string)));\n\n/**\n * Returns references to a Y.Map and its neighbors in a Y.Array based on its position.\n *\n * @example\n * let yArray = new Y.Array();\n * let yMap1 = new Y.Map();\n * let yMap2 = new Y.Map();\n * yMap1.set('position', 'a0');\n * yMap2.set('position', 'b0');\n * yArray.push([yMap2, yMap1]);\n * const refs = getYArrayRefsByPosition(yArray, 'a0');\n * // refs now looks like: { index: 0, ref: yMap1, right: yMap2, left: undefined, sortedArray: [yMap1, yMap2] }\n */\nexport const getYArrayRefsByPosition = <T extends Y.Map<unknown>>(yArray: Y.Array<T>, position: string) => {\n const sortedArray = getSortedYArray(yArray);\n // const currentYArrayIndex = sortedArray.findIndex((it) => it === yComponent);\n const index = sortedArray.findIndex((it) => it.get('position') === position);\n if (index === -1) {\n console.error('sortedArray', sortedArray);\n throw new Error(`Relative item with position ${position} not found`);\n }\n\n return {\n index,\n ref: sortedArray[index],\n right: sortedArray[index + 1],\n left: sortedArray[index - 1],\n sortedArray,\n };\n};\n\n","import * as Y from 'yjs';\n\nimport {\n isIndex, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { generateKeyBetween } from '@/dynamic-components/index.js';\n\nimport { getFromYPath, setInYPath } from './basic-path-ops.js';\nimport { getSortedYArray, getYArrayRefsByPosition } from './tools.js';\nimport { getYArrayIndexByArrayKey } from './y-array-keys.js';\n\n/**\n * Pushes a value to the end of the Y.Array at the specified path.\n *\n * @example\n * let yMap = new Y.Map();\n * yMap.set('names', new Y.Array());\n * pushInYPath(yMap, ['names'], 'John');\n * // yMap now looks like: { names: ['John'] }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const pushInYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], value: any) => {\n const yArray = getFromYPath(entry, path);\n if (!isYArray(yArray)) {\n setInYPath(entry, path, Y.Array.from([value]));\n } else {\n yArray.push([value]);\n }\n};\n\nconst printPosition = (array: unknown[]) => array.map((it) => isYMap(it) ? it.get('position') ?? 'no-position' : 'not-ymap');\n\n/**\n * Moves an item to a new position relative to another item in the Y.Array or Y.Map at the specified path.\n *\n * @example\n * moveInYPath(yMap, ['components'], 'a0', 'b1', 'after');\n */\nexport const moveInYPath = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n entry: Y.Array<any> | Y.Map<any>,\n path: (string | number)[],\n oldPosition: string,\n relativePosition: string,\n insert: 'before' | 'after',\n) => {\n const yArray = getFromYPath(entry, path);\n if (!isYArray(yArray)) {\n throw new Error(`Can't move. Target item is not yArray in path ${JSON.stringify(path)}`);\n }\n\n const array = yArray.toArray();\n\n const item = array.find((it) => isYMap(it) && it.get('position') === oldPosition);\n const relativeItemIndex = array.findIndex((it) => isYMap(it) && it.get('position') === relativePosition);\n\n if (!isYMap(item)) {\n throw new Error(`Can't move. Item in position ${oldPosition} not found. ${printPosition(array)}`);\n }\n\n if (relativeItemIndex === -1) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} not found. ${printPosition(array)}`);\n }\n\n const relativeItem = array[relativeItemIndex];\n if (!isYMap(relativeItem)) {\n throw new Error(`Can't move. Relative item in position ${relativePosition} must be YMap. ${printPosition(array)}`);\n }\n\n if (insert === 'before') {\n const left = array[relativeItemIndex - 1];\n const leftPosition = isYMap(left) ? left.get('position') as string ?? null : null;\n\n const newPosition = generateKeyBetween(leftPosition, relativeItem.get('position') as string);\n item.set('position', newPosition);\n\n return newPosition;\n }\n\n const right = array[relativeItemIndex + 1];\n const rightPosition = isYMap(right) ? right.get('position') as string ?? null : null;\n\n const newPosition = generateKeyBetween(relativeItem.get('position') as string, rightPosition);\n item.set('position', newPosition);\n\n return newPosition;\n};\n\n/**\n * Removes an item from the Y.Array or Y.Map at the specified path.\n *\n * @example\n * let yArray = new Y.Array();\n * yArray.push(['item1', 'item2', 'item3']);\n * pullFromYPath(yArray, [1]);\n * // yArray now looks like: ['item1', 'item3']\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const pullFromYPath = (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], key: string | number) => {\n const yArray = getFromYPath(entry, path) as unknown[];\n if (isYArray(yArray)) {\n if (isIndex(key)) {\n yArray.delete(key);\n\n return;\n }\n\n const index = getYArrayIndexByArrayKey(yArray, key);\n yArray.delete(index);\n }\n};\n\nexport interface MoveYMapToStartOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Moves a Y.Map to the start of a Y.Array.\n * */\nexport const moveYMapToStart = ({ yArray, yMap }: MoveYMapToEndOptions) => {\n const sortedArray = getSortedYArray(yArray);\n const first = sortedArray[0];\n\n const rightIndex = first ? (first.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(null, rightIndex));\n};\n\nexport interface MoveYMapToEndOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Moves a Y.Map to the end of a Y.Array.\n * */\nexport const moveYMapToEnd = ({ yArray, yMap }: MoveYMapToEndOptions) => {\n const sortedArray = getSortedYArray(yArray);\n const last = sortedArray[sortedArray.length - 1];\n\n const leftIndex = last ? (last.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, null));\n};\n\nexport interface MoveYMapBeforeOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Moves a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const moveYMapBefore = ({\n yArray,\n yMap,\n relativePosition,\n}: MoveYMapBeforeOptions) => {\n const { ref: relative, left } = getYArrayRefsByPosition(yArray, relativePosition);\n\n const right = relative; // left - x - relative\n\n const rightIndex = right ? (right.get('position') as string) : null;\n const leftIndex = left ? (left.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, rightIndex));\n};\n\nexport interface MoveYMapAfterOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Moves a Y.Map after another Y.Map in a Y.Array.\n * */\nexport const moveYMapAfter = ({\n yArray,\n yMap,\n relativePosition,\n}: MoveYMapAfterOptions) => {\n const { ref: relative, right } = getYArrayRefsByPosition(yArray, relativePosition);\n\n const left = relative; // relative - x - right\n\n const rightIndex = right ? (right.get('position') as string) : null;\n const leftIndex = left ? (left.get('position') as string) : null;\n\n yMap.set('position', generateKeyBetween(leftIndex, rightIndex));\n};\n\nexport interface InsertYMapToEndOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n}\n\n/**\n * Inserts a Y.Map to the end of a Y.Array.\n * */\nexport const insertYMapToEnd = (opts: InsertYMapToEndOptions) => {\n moveYMapToEnd(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n\nexport interface InsertYMapBeforeOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Inserts a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const insertYMapBefore = (opts: InsertYMapBeforeOptions) => {\n moveYMapBefore(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n\nexport interface InsertYMapAfterOptions {\n yArray: Y.Array<Y.Map<unknown>>;\n yMap: Y.Map<unknown>;\n relativePosition: string;\n}\n\n/**\n * Inserts a Y.Map before another Y.Map in a Y.Array.\n * */\nexport const insertYMapAfter = (opts: InsertYMapAfterOptions) => {\n moveYMapAfter(opts);\n\n // always appended, since sort order is not reliant on array order\n opts.yArray.push([opts.yMap]);\n};\n","import { JSONContent } from '@tiptap/core';\nimport { yXmlFragmentToProsemirrorJSON } from 'y-prosemirror';\nimport * as Y from 'yjs';\n\nimport {\n isObject, isString, isYArray, isYMap,\n} from '@/assertions/index.js';\nimport { RichText } from '@/data-objects/index.js';\nimport {\n DynamicComponent, DynamicComponentWithPosition,\n sortDynamicComponents,\n} from '@/dynamic-components/index.js';\nimport {\n arrayToYArray,\n objectToYMap,\n} from '@/y-tools/index.js';\n\nimport { YComponent } from './types.js';\n\n/**\n * This function converts dynamic component properties to Y.Map representation.\n */\nexport const dynamicComponentPropsToYComponentProps = (props: Record<string, unknown>) => {\n const entries: [string, unknown][] = Object.entries(props).map(([key, value]) => {\n if (key === 'content' && isObject(value) && (value.content as JSONContent)?.type === 'doc') {\n // sae value content as is\n return [key, value.content];\n } else if (Array.isArray(value)) {\n return [key, arrayToYArray(value)];\n } else if (isObject(value)) {\n return [key, objectToYMap(value)];\n } else {\n return [key, value];\n }\n });\n\n return new Y.Map(entries);\n};\n\n/**\n * This function converts a dynamic component to Y.Map representation.\n */\nexport const dynamicComponentToYMap = (component: DynamicComponent, yMap = new Y.Map()): YComponent => {\n const {\n props: propsWithComponents,\n ...fields\n } = component;\n\n const {\n components,\n ...props\n } = propsWithComponents ?? {\n };\n\n for (const [key, value] of Object.entries(fields)) {\n yMap.set(key, value);\n }\n\n const yProps = props ? objectToYMap(props) : new Y.Map();\n\n if (Array.isArray(components)) {\n yProps.set('components', dynamicComponentsToYArray(components));\n }\n\n yMap.set('props', yProps);\n\n return yMap;\n};\n\n/**\n * This function converts an array of dynamic components to Y.Array representation.\n */\nexport const dynamicComponentsToYArray = (components: DynamicComponent[], yArray = new Y.Array()) => {\n yArray.push(sortDynamicComponents(components).map((cmp) => dynamicComponentToYMap(cmp)));\n\n return yArray;\n};\n\n/**\n * This function checks if a given Y.Map object is a YComponent.\n */\nexport const isYComponent = (yComponent: unknown): yComponent is YComponent => {\n return isYMap(yComponent) && isString(yComponent.get('component')) && isString(yComponent.get('id'));\n};\n\n/**\n * This function converts a YComponent to a dynamic component.\n */\nexport const yComponentToDynamicComponent = (yComponent: YComponent, extractContent = false): DynamicComponentWithPosition => {\n const component: Record<string, unknown> = {\n props: {\n },\n };\n\n for (const [key, value] of yComponent.entries()) {\n if (key === 'props') {\n if (!isYMap(value)) {\n throw new Error('Component props must be YMap');\n }\n\n const yComponentProps = value;\n\n const props: Record<string, unknown> = {\n };\n\n for (const [prop, value] of yComponentProps.entries()) {\n if (prop === 'components') {\n if (!isYArray<YComponent>(value)) {\n throw new Error('Component props.components array must be YArray');\n }\n\n props.components = value.toArray().map((it) => yComponentToDynamicComponent(it));\n } else if (\n extractContent &&\n yComponent.doc &&\n isYMap(value) &&\n value.get('type') === 'RichText' &&\n typeof value.get('id') === 'string'\n ) {\n const id = value.get('id') as string;\n const rawRichText = value.toJSON() as RichText;\n\n const richText: RichText = {\n ...rawRichText,\n tiptap: yXmlFragmentToProsemirrorJSON(yComponent.doc.getXmlFragment(`RichText:${id}`)),\n };\n\n props[prop] = richText;\n } else if (value instanceof Y.AbstractType) {\n props[prop] = value.toJSON();\n } else {\n props[prop] = value;\n }\n }\n\n component.props = props;\n } else if (isYArray(value)) {\n component[key] = value.toArray();\n } else if (isYMap(value)) {\n component[key] = value.toJSON();\n } else {\n component[key] = value;\n }\n }\n\n return component as unknown as DynamicComponentWithPosition;\n};\n\n/**\n * This function converts a dynamic component to YComponent.\n */\nexport const dynamicComponentToYComponent = (component: DynamicComponent): YComponent => {\n // return yComponent.toJSON() as DynamicComponentWithPosition;\n return dynamicComponentToYMap(component) as YComponent;\n};\n\n/**\n * This function retrieves the properties of a YComponent.\n */\nexport const getYComponentProps = (yComponent: YComponent): Y.Map<unknown> => {\n const props = yComponent.get('props');\n if (!isYMap(props)) {\n throw new Error(`Component hasn't \"props\" property. It must have to be defined as Y.Map (component: ${yComponent.get('id')})`);\n }\n\n return props;\n};\n\n/**\n * This function retrieves the array of components of a YComponent.\n */\nexport const getYComponentComponentsArray = (yComponent: YComponent): Y.Array<YComponent> => {\n const props = getYComponentProps(yComponent);\n\n const yComponents = props.get('components');\n\n if (!isYArray<YComponent>(yComponents)) {\n throw new Error(`Component hasn't \"props.components\" property. It must be defined as Y.Array (component: ${yComponent.get('id')})`);\n }\n\n return yComponents;\n};\n\n/**\n * This function checks if a YComponent has a components array.\n * @example\n * // component\n * {\n * id: \"column\",\n * component: \"column\",\n * props: {\n * components: [...] <= has components array\n * }\n * }\n */\nexport const yComponentHasComponentsYArray = (yComponent: YComponent): boolean => {\n const props = getYComponentProps(yComponent);\n\n const yComponents = props.get('components');\n\n return isYArray<YComponent>(yComponents);\n};\n\n/**\n * This function retrieves the parent component of a YArray of YComponents.\n * @example\n * // parent component\n * {\n * id: \"column\",\n * component: \"column\",\n * props: {\n * components: [...] <= components array\n * }\n * }\n */\nexport const getYComponentsArrayParentComponent = (yArray: Y.Array<YComponent>): YComponent | null => {\n // yarray => parent (props) => parent (YIndexedDynamicComponents)\n\n return yArray.parent?.parent as YComponent ?? null;\n};\n\n/**\n * This function finds a Y.Component in a Y.Array by its ID.\n */\nexport const findYComponentInArray = (yArray: Y.Array<YComponent>, componentId: string) => {\n const yComponent = yArray.toArray().find((it) => it.get('id') === componentId);\n\n if (!yComponent) {\n throw new Error(`Component with id ${componentId} not found in yArray`);\n }\n\n return yComponent;\n};\n\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,eAAe,MAA2B,WAAgC;AACrF,QAAO,KAAK,WAAW,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SAJO,mBAAmB,WAAW,CAElB,IAAI,aAAa,CAEH;;;;;;;;;;;;;;AAe1C,MAAa,sCAAsC,WAAmD;AAGpG,QAAO,OAAO,QAAQ,UAAwB;;;;;AAMhD,MAAa,yBAAyB,QAA6B,gBAAwB;CACzF,MAAM,aAAa,OAAO,SAAS,CAAC,MAAM,OAAO,GAAG,IAAI,KAAK,KAAK,YAAY;AAE9E,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,qBAAqB,YAAY,sBAAsB;AAGzE,QAAO"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@pcg/dynamic-components",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Dynamic components with Yjs integration for collaborative editing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "dependencies": {
9
9
  "@tiptap/core": "^2.12.0",
10
- "type-fest": "^4.41.0",
11
10
  "y-prosemirror": "^1.3.4",
12
- "yjs": "^13.6.27"
11
+ "yjs": "^13.6.27",
12
+ "@pcg/predicates": "1.0.0-alpha.1"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@tiptap/pm": "^2.12.0",
@@ -1,58 +1,7 @@
1
- /**
2
- * Checks if the given parameter is callable (a function).
3
- * @param {unknown} fn - The function to check.
4
- * @returns {boolean} Returns true if `fn` is a function, false otherwise.
5
- * @example
6
- * isCallable(() => {}); // Returns true
7
- * isCallable('Hello'); // Returns false
8
- */
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- export const isCallable = (fn: unknown): fn is (...args: any[]) => any => {
11
- return typeof fn === 'function';
12
- };
13
-
14
- /**
15
- * Checks if the given value is a string.
16
- * @param {unknown} val - The value to check.
17
- * @returns {boolean} Returns true if `val` is a string, false otherwise.
18
- * @example
19
- * isString('Hello'); // Returns true
20
- * isString(123); // Returns false
21
- */
22
- export const isString = (val: unknown): val is string => typeof val === 'string';
23
-
24
- /**
25
- * Checks if the given value is a number.
26
- * @param {unknown} val - The value to check.
27
- * @returns {boolean} Returns true if `val` is a number, false otherwise.
28
- * @example
29
- * isNumber(123); // Returns true
30
- * isNumber('Hello'); // Returns false
31
- */
32
- export const isNumber = (val: unknown): val is number => typeof val === 'number';
33
-
34
- /**
35
- * Checks if a given value can be used as an index (a non-negative integer).
36
- * @param {unknown} value - The value to check.
37
- * @returns {boolean} Returns true if `value` can be used as an index, false otherwise.
38
- * @example
39
- * isIndex(2); // Returns true
40
- * isIndex('2'); // Returns true
41
- * isIndex(-1); // Returns false
42
- */
43
- export const isIndex = (value: unknown): value is number => {
44
- return (isNumber(value) || isString(value)) && Number(value) >= 0;
45
- };
46
-
47
- /**
48
- * Checks if the given value is null or undefined.
49
- * @param {unknown} value - The value to check.
50
- * @returns {boolean} Returns true if `value` is null or undefined, false otherwise.
51
- * @example
52
- * isNullOrUndefined(null); // Returns true
53
- * isNullOrUndefined(undefined); // Returns true
54
- * isNullOrUndefined('Hello'); // Returns false
55
- */
56
- export const isNullOrUndefined = (value: unknown): value is undefined | null => {
57
- return value === null || value === undefined;
58
- };
1
+ export {
2
+ isCallable,
3
+ isIndex,
4
+ isNullOrUndefined,
5
+ isNumber,
6
+ isString,
7
+ } from '@pcg/predicates';
@@ -1,76 +1,8 @@
1
- // https://github.com/logaretm/vee-validate/blob/main/packages/shared/utils.ts
2
- // https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/utils/assertions.ts
3
-
4
- import type { Entries } from 'type-fest';
5
-
6
- /**
7
- * Checks if the given value is an empty array.
8
- * @param {unknown} arr - The array to check.
9
- * @returns {boolean} Returns true if `arr` is an empty array, false otherwise.
10
- * @example
11
- * isEmptyArray([]); // Returns true
12
- * isEmptyArray([1, 2, 3]); // Returns false
13
- */
14
- export const isEmptyArray = (arr: unknown): boolean => {
15
- return Array.isArray(arr) && arr.length === 0;
16
- };
17
-
18
- /**
19
- * Gets the keys of the given object.
20
- * @param {T} arr - The object to get the keys from.
21
- * @returns {Array<keyof T>} Returns an array of keys of the given object.
22
- * @example
23
- * keysOf({ a: 1, b: 2 }); // Returns ['a', 'b']
24
- */
25
- export const keysOf = <T>(arr: T) => Object.keys(arr as unknown[]) as (keyof T)[];
26
-
27
- /**
28
- * Gets the entries of the given object.
29
- * @param {T} arr - The object to get the entries from.
30
- * @returns {Entries<T>} Returns an array of entries of the given object.
31
- * @example
32
- * entriesOf({ a: 1, b: 2 }); // Returns [['a', 1], ['b', 2]]
33
- */
34
- export const entriesOf = <T>(arr: T) => Object.entries(arr as unknown[]) as Entries<T>;
35
-
36
- /**
37
- * Checks if the given value is an object (not an array).
38
- * @param {unknown} obj - The value to check.
39
- * @returns {boolean} Returns true if `obj` is an object, false otherwise.
40
- * @example
41
- * isObject({ a: 1 }); // Returns true
42
- * isObject([1, 2, 3]); // Returns false
43
- */
44
- export const isObject = (obj: unknown): obj is Record<string, unknown> =>
45
- obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj);
46
-
47
- /**
48
- * Checks if the given value is a container (an object or an array).
49
- * @param {unknown} value - The value to check.
50
- * @returns {boolean} Returns true if `value` is a container, false otherwise.
51
- * @example
52
- * isContainerValue({ a: 1 }); // Returns true
53
- * isContainerValue([1, 2, 3]); // Returns true
54
- * isContainerValue('Hello'); // Returns false
55
- */
56
- export const isContainerValue = (value: unknown): value is Record<string, unknown> => {
57
- return isObject(value) || Array.isArray(value);
58
- };
59
-
60
- /**
61
- * Checks if the given value is an empty container (an empty object or array).
62
- * @param {unknown} value - The value to check.
63
- * @returns {boolean} Returns true if `value` is an empty container, false otherwise.
64
- * @example
65
- * isEmptyContainer({}); // Returns true
66
- * isEmptyContainer([]); // Returns true
67
- * isEmptyContainer({ a: 1 }); // Returns false
68
- * isEmptyContainer([1, 2, 3]); // Returns false
69
- */
70
- export const isEmptyContainer = (value: unknown): boolean => {
71
- if (Array.isArray(value)) {
72
- return value.length === 0;
73
- }
74
-
75
- return isObject(value) && Object.keys(value).length === 0;
76
- };
1
+ export {
2
+ entriesOf,
3
+ isContainerValue,
4
+ isEmptyArray,
5
+ isEmptyContainer,
6
+ isObject,
7
+ keysOf,
8
+ } from '@pcg/predicates';
@@ -52,15 +52,15 @@ export interface DRepeatableCollection extends DynamicComponent {
52
52
  component: 'repeatable-collection';
53
53
  props: {
54
54
  name?: string;
55
- heading: string;
55
+ heading?: string;
56
56
  collectionTitle?: string;
57
-
58
57
  useTabs?: boolean;
59
58
  cols?: number;
60
59
  tabName?: string;
61
60
  confirmDeletion?: boolean;
62
61
  addButtonText?: string;
63
62
  readonly?: boolean;
63
+ draggable?: boolean;
64
64
  components: DynamicComponent[];
65
65
  visible?: string;
66
66
  rules?: {
@@ -37,7 +37,7 @@ import {
37
37
  DRowSettings,
38
38
  } from './layout.js';
39
39
 
40
- export type FormDynamicComponent =
40
+ export type UiKitFormDynamicComponent =
41
41
  DTextInput
42
42
  | DCheckbox
43
43
  | DTextarea
@@ -78,7 +78,7 @@ DRow
78
78
  export type UiKitChatDynamicComponent =
79
79
  DChatTextMessage;
80
80
 
81
- export type UiKitDynamicComponent = FormDynamicComponent
81
+ export type UiKitDynamicComponent = UiKitFormDynamicComponent
82
82
  | UiKitContentDynamicComponent
83
83
  | UiKitLayoutDynamicComponent
84
84
  | UiKitChatDynamicComponent;