@case-framework/survey-core 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/editor/colors.d.mts +12 -0
- package/build/editor/colors.d.mts.map +1 -0
- package/build/editor/colors.mjs +25 -0
- package/build/editor/colors.mjs.map +1 -0
- package/build/editor.d.mts +5 -1
- package/build/editor.d.mts.map +1 -1
- package/build/editor.mjs +14 -1
- package/build/editor.mjs.map +1 -1
- package/build/index.d.mts +3 -2
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs +3 -2
- package/build/index.mjs.map +1 -1
- package/build/package.json +5 -1
- package/build/{survey-Dxt6iolo.mjs → survey-BKblV5rN.mjs} +11 -1
- package/build/survey-BKblV5rN.mjs.map +1 -0
- package/build/{survey-DZ3RHkd2.d.mts → survey-CwWxsuRb.d.mts} +6 -1
- package/build/{survey-DZ3RHkd2.d.mts.map → survey-CwWxsuRb.d.mts.map} +1 -1
- package/package.json +5 -1
- package/build/survey-Dxt6iolo.mjs.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/editor/item-colors.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Editor-only item-color swatches persisted in `metadata.editorItemColor`.
|
|
4
|
+
*
|
|
5
|
+
* This is shared survey-editor configuration: hosts may render the editor
|
|
6
|
+
* without enabling the assistant, while assistant proposals must validate
|
|
7
|
+
* against the same values.
|
|
8
|
+
*/
|
|
9
|
+
declare const SURVEY_EDITOR_ITEM_COLORS: readonly ["#404040", "#b91c1c", "#c2410c", "#a16207", "#4d7c0f", "#047857", "#0369a1", "#4338ca", "#7e22ce", "#86198f", "#be123c"];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SURVEY_EDITOR_ITEM_COLORS };
|
|
12
|
+
//# sourceMappingURL=colors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.mts","names":[],"sources":["../../src/editor/item-colors.ts"],"mappings":";;AAOA;;;;;;cAAa,yBAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/editor/item-colors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Editor-only item-color swatches persisted in `metadata.editorItemColor`.
|
|
4
|
+
*
|
|
5
|
+
* This is shared survey-editor configuration: hosts may render the editor
|
|
6
|
+
* without enabling the assistant, while assistant proposals must validate
|
|
7
|
+
* against the same values.
|
|
8
|
+
*/
|
|
9
|
+
const SURVEY_EDITOR_ITEM_COLORS = [
|
|
10
|
+
"#404040",
|
|
11
|
+
"#b91c1c",
|
|
12
|
+
"#c2410c",
|
|
13
|
+
"#a16207",
|
|
14
|
+
"#4d7c0f",
|
|
15
|
+
"#047857",
|
|
16
|
+
"#0369a1",
|
|
17
|
+
"#4338ca",
|
|
18
|
+
"#7e22ce",
|
|
19
|
+
"#86198f",
|
|
20
|
+
"#be123c"
|
|
21
|
+
];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SURVEY_EDITOR_ITEM_COLORS };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=colors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.mjs","names":[],"sources":["../../src/editor/item-colors.ts"],"sourcesContent":["/**\n * Editor-only item-color swatches persisted in `metadata.editorItemColor`.\n *\n * This is shared survey-editor configuration: hosts may render the editor\n * without enabling the assistant, while assistant proposals must validate\n * against the same values.\n */\nexport const SURVEY_EDITOR_ITEM_COLORS = [\n \"#404040\",\n \"#b91c1c\",\n \"#c2410c\",\n \"#a16207\",\n \"#4d7c0f\",\n \"#047857\",\n \"#0369a1\",\n \"#4338ca\",\n \"#7e22ce\",\n \"#86198f\",\n \"#be123c\",\n] as const;\n"],"mappings":";;;;;;;;AAOA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/build/editor.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as SurveyCardContent, E as NavigationContent, Gt as SurveyItemCore, Jt as RawSurveyItem, M as Content, S as RawSurveyAsset, k as SurveyItemTranslations, m as ItemTypeRegistry, t as Survey, vt as TemplateValueDefinition, w as JsonComponentContent, x as RawSurvey } from "./survey-
|
|
1
|
+
import { D as SurveyCardContent, E as NavigationContent, Gt as SurveyItemCore, Jt as RawSurveyItem, M as Content, S as RawSurveyAsset, k as SurveyItemTranslations, m as ItemTypeRegistry, t as Survey, vt as TemplateValueDefinition, w as JsonComponentContent, x as RawSurvey } from "./survey-CwWxsuRb.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/editor/types.d.ts
|
|
4
4
|
interface Target {
|
|
@@ -316,6 +316,10 @@ declare class SurveyEditor {
|
|
|
316
316
|
};
|
|
317
317
|
};
|
|
318
318
|
}): void;
|
|
319
|
+
/** Add an empty survey locale so it can be authored before translated content exists. */
|
|
320
|
+
addLocale(locale: string): boolean;
|
|
321
|
+
/** Remove a locale and every survey- and item-level translation stored for it. */
|
|
322
|
+
removeLocale(locale: string): boolean;
|
|
319
323
|
/**
|
|
320
324
|
* Get maxItemsPerPage immutably (returns a copy).
|
|
321
325
|
*/
|
package/build/editor.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;UAAiB,MAAA;EACf,QAAA;EACA,KAAA;AAAA;;;KCQU,sBAAA;EAAA,CACT,MAAA,WAAiB,oBAAA;AAAA;AAAA,UAIH,uBAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;IACL,MAAA;IACA,QAAA,EAAU,aAAA;EAAA;EAEZ,YAAA;IAAA,CAAiB,MAAA,WAAiB,sBAAA;EAAA;EAClC,UAAA;EACA,SAAA;AAAA;AAAA,cAGW,aAAA;EAAA,QACH,MAAA;cAEI,MAAA,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IA,yBAAA;EAYR,OAAA,CAAQ,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,cAAA,EAAgB,OAAA,GAAU,sBAAA;EAmFxD,UAAA,CAAW,MAAA,UAAgB,MAAA;EAkC3B,QAAA,CAAS,MAAA,UAAgB,SAAA,EAAW,MAAA;EFvEgB;;;;;;ACxVtD;;;EC+eE,eAAA,CAAgB,MAAA,WAAiB,aAAA;ED9ejC;;;;;AAKF;;;;;;;EC6fE,UAAA,CAAW,MAAA,UAAgB,WAAA,EAAa,aAAA,GAAgB,OAAA,CAAQ,aAAA;EA2ChE,sBAAA,CAAuB,MAAA,UAAgB,cAAA,GAAiB,sBAAA;EDniB9C;;;;ECojBV,wBAAA,CAAyB,OAAA;IACvB,UAAA;MAAe,MAAA;MAAgB,OAAA,GAAU,iBAAA;IAAA;IACzC,UAAA;MAAe,MAAA;MAAgB,OAAA,GAAU,iBAAA;IAAA;IACzC,kBAAA;MAAuB,MAAA;MAAgB,OAAA;QAAY,eAAA,GAAkB,OAAA;MAAA;IAAA;EAAA;ED9iBhE
|
|
1
|
+
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;UAAiB,MAAA;EACf,QAAA;EACA,KAAA;AAAA;;;KCQU,sBAAA;EAAA,CACT,MAAA,WAAiB,oBAAA;AAAA;AAAA,UAIH,uBAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;IACL,MAAA;IACA,QAAA,EAAU,aAAA;EAAA;EAEZ,YAAA;IAAA,CAAiB,MAAA,WAAiB,sBAAA;EAAA;EAClC,UAAA;EACA,SAAA;AAAA;AAAA,cAGW,aAAA;EAAA,QACH,MAAA;cAEI,MAAA,EAAQ,MAAA;EARoC;;;;;;EAkBxD,QAAA,CAAS,MAAA,WAAiB,uBAAA;EApBd;;;;;EAAA,QA4EJ,mBAAA;EAxEC;;AAGX;;;;E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,OAAA,UAAiB,KAAA,EAAO,cAAA;ED9oB/B;;;ECmqBF,WAAA,CAAY,OAAA;EDlqB6B;;;;;EC2rBzC,QAAA,CAAS,MAAA,WAAiB,uBAAA;ED3rBe;;AAgE3C;;;;ECsoBE,SAAA,CAAU,aAAA,EAAe,uBAAA,EAAyB,MAAA,EAAQ,MAAA;AAAA"}
|
package/build/editor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as generateId, nt as structuredCloneMethod, t as Survey, u as SurveyItemTranslations, v as GroupItemCore } from "./survey-
|
|
1
|
+
import { $ as generateId, nt as structuredCloneMethod, t as Survey, u as SurveyItemTranslations, v as GroupItemCore } from "./survey-BKblV5rN.mjs";
|
|
2
2
|
//#region src/editor/item-copy-paste.ts
|
|
3
3
|
var ItemCopyPaste = class ItemCopyPaste {
|
|
4
4
|
survey;
|
|
@@ -839,6 +839,19 @@ var SurveyEditor = class SurveyEditor {
|
|
|
839
839
|
if (updates.navigation) this._survey.translations.setNavigationContent(updates.navigation.locale, updates.navigation.content);
|
|
840
840
|
if (updates.validationMessages) this._survey.translations.setValidationMessages(updates.validationMessages.locale, updates.validationMessages.content);
|
|
841
841
|
}
|
|
842
|
+
/** Add an empty survey locale so it can be authored before translated content exists. */
|
|
843
|
+
addLocale(locale) {
|
|
844
|
+
const added = this._survey.translations.addLocale(locale);
|
|
845
|
+
if (added) this.markAsModified();
|
|
846
|
+
return added;
|
|
847
|
+
}
|
|
848
|
+
/** Remove a locale and every survey- and item-level translation stored for it. */
|
|
849
|
+
removeLocale(locale) {
|
|
850
|
+
if (!this._survey.locales.includes(locale)) return false;
|
|
851
|
+
this._survey.translations.removeLocale(locale);
|
|
852
|
+
this.markAsModified();
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
842
855
|
/**
|
|
843
856
|
* Get maxItemsPerPage immutably (returns a copy).
|
|
844
857
|
*/
|
package/build/editor.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.mjs","names":[],"sources":["../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"sourcesContent":["import { Survey } from \"../survey/survey\";\nimport { SurveyItemCore } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport { ReservedSurveyItemTypes } from \"../survey/items/types\";\nimport { SurveyItemTranslations, JsonComponentContent } from \"../survey/utils\";\nimport { RawSurveyItem } from \"../survey/items/survey-item-json\";\nimport { Target } from \"./types\";\nimport { generateId } from \"../utils\";\n\n// Serialized translation data format for clipboard\nexport type SerializedTranslations = {\n [locale: string]: JsonComponentContent;\n};\n\n// Clipboard data structure for copy-paste functionality\nexport interface SurveyItemClipboardData {\n type: \"survey-item\";\n version: string;\n items: Array<{\n itemId: string;\n itemData: RawSurveyItem;\n }>;\n translations: { [itemId: string]: SerializedTranslations };\n rootItemId: string; // The id of the main item being copied\n timestamp: number;\n}\n\nexport class ItemCopyPaste {\n private survey: Survey;\n\n constructor(survey: Survey) {\n this.survey = survey;\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * When copying a group, automatically includes all items in the subtree\n * @param itemId - The id of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const item = this.survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Collect all items to copy (including subtree for groups)\n const itemsToCopy = this.collectItemsForCopy(itemId);\n\n // Create items array with their data\n const items = itemsToCopy.map((id) => {\n const item = this.survey.surveyItems.get(id);\n if (!item) throw new Error(`Item with id '${id}' not found during copy`);\n return { itemId: id, itemData: item.rawItem };\n });\n\n // Collect translations for all items\n const translations: { [itemId: string]: SerializedTranslations } = {};\n itemsToCopy.forEach((id) => {\n try {\n const itemTranslations = this.survey.getItemTranslations(id);\n if (itemTranslations?.locales?.length) {\n const serializedTranslations: SerializedTranslations = {};\n itemTranslations.locales.forEach((locale) => {\n const localeContent = itemTranslations.getAllForLocale(locale);\n if (localeContent) {\n serializedTranslations[locale] = localeContent;\n }\n });\n translations[id] = serializedTranslations;\n } else {\n translations[id] = {};\n }\n } catch {\n translations[id] = {};\n }\n });\n\n // Create clipboard data\n const clipboardData: SurveyItemClipboardData = {\n type: \"survey-item\",\n version: \"1.0.0\",\n items: items,\n translations: translations,\n rootItemId: itemId,\n timestamp: Date.now(),\n };\n\n return clipboardData;\n }\n\n /**\n * Collect all items that should be copied, including subtree for groups\n * @param itemId - The root item id\n * @returns Array of item keys to copy\n */\n private collectItemsForCopy(itemId: string): string[] {\n const itemsToCopy: string[] = [itemId];\n const item = this.survey.surveyItems.get(itemId);\n\n if (!item) {\n return [];\n }\n\n // If this is a group item, collect all child items recursively\n if (item instanceof GroupItemCore) {\n const childIds = item.items;\n if (childIds.length > 0) {\n childIds.forEach((childId) => {\n const childItems = this.collectItemsForCopy(childId);\n itemsToCopy.push(...childItems);\n });\n }\n }\n\n return itemsToCopy;\n }\n\n /**\n * Add an item to its parent group.\n * Ensures key uniqueness among siblings.\n * @param target - Target location information\n * @param item - The item to add (may have key adjusted for uniqueness)\n */\n private addItemToParentGroup(target: Target, item: SurveyItemCore): void {\n const parentGroup = this.survey.surveyItems.get(target.parentId);\n\n if (!parentGroup) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(parentGroup instanceof GroupItemCore)) {\n throw new Error(`Parent item '${target.parentId}' is not a group item`);\n }\n\n const siblingIds = parentGroup.items;\n const siblings = siblingIds\n .map((id) => this.survey.surveyItems.get(id))\n .filter((s): s is SurveyItemCore => s !== undefined);\n const siblingKeys = new Set(siblings.map((s) => s.key));\n\n let uniqueKey = item.key;\n if (siblingKeys.has(uniqueKey)) {\n let counter = 1;\n const originalKey = item.key;\n while (siblingKeys.has(uniqueKey)) {\n uniqueKey = originalKey + `_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n const updatedRawItem = { ...item.rawItem, key: uniqueKey };\n const newItem = this.survey.createItemFromRaw(updatedRawItem);\n this.survey.surveyItems.delete(item.id);\n this.survey.surveyItems.set(newItem.id, newItem);\n item = newItem;\n }\n }\n\n const insertIndex =\n target.index !== undefined\n ? Math.min(target.index, parentGroup.items.length)\n : parentGroup.items.length;\n\n parentGroup.addChild(item.id, insertIndex);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * Handles multiple items and subtrees from the clipboard data\n * @param clipboardData - The clipboard data containing the item(s) to paste\n * @param target - Target location where to paste the item\n * @returns The id of the pasted root item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n // Validate clipboard data\n if (!ItemCopyPaste.isValidClipboardData(clipboardData)) {\n throw new Error(\"Invalid clipboard data format\");\n }\n\n // Create id mapping for all items in the subtree\n const idMapping: { [oldId: string]: string } = {};\n clipboardData.items.forEach(({ itemId }) => {\n idMapping[itemId] = generateId();\n });\n\n // Create all items with updated ids\n clipboardData.items.forEach(({ itemId, itemData }) => {\n const newId = idMapping[itemId];\n if (newId) {\n const updatedItemData = this.updateItemIdsInData(itemData, idMapping);\n updatedItemData.id = newId;\n\n const newItem = this.survey.createItemFromRaw(updatedItemData);\n this.survey.surveyItems.set(newItem.id, newItem);\n\n if (itemId === clipboardData.rootItemId) {\n this.addItemToParentGroup(target, newItem);\n }\n }\n });\n\n // Update translations with new IDs\n const updatedTranslations = this.updateTranslations(clipboardData.translations, idMapping);\n Object.keys(updatedTranslations).forEach((itemId) => {\n // Convert serialized translations back to SurveyItemTranslations instance\n const itemTranslations = new SurveyItemTranslations();\n const serializedData = updatedTranslations[itemId];\n Object.keys(serializedData).forEach((locale) => {\n itemTranslations.setAllForLocale(locale, serializedData[locale]);\n });\n this.survey.translations.setItemTranslations(itemId, itemTranslations);\n });\n\n return idMapping[clipboardData.rootItemId];\n }\n\n // PRIVATE HELPER METHODS\n /**\n * Update all item ids in the raw item data recursively\n */\n private updateItemIdsInData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): RawSurveyItem {\n const updatedData = JSON.parse(JSON.stringify(itemData));\n\n if (updatedData.itemType === ReservedSurveyItemTypes.Group && updatedData.config) {\n const config = updatedData.config as { items?: string[] };\n if (config.items) {\n config.items = config.items.map((childId: string) => idMapping[childId] ?? childId);\n }\n }\n\n this.updateExpressionsInItemData(updatedData, idMapping);\n return updatedData;\n }\n\n /**\n * Update expressions in item data that reference the old ids\n */\n private updateExpressionsInItemData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): void {\n // Update display conditions\n if (itemData.displayConditions?.root) {\n this.updateExpressionReferences(itemData.displayConditions.root, idMapping);\n }\n if (itemData.displayConditions?.components) {\n Object.values(itemData.displayConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update disabled conditions\n if (itemData.disabledConditions?.components) {\n Object.values(itemData.disabledConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update validations\n if (itemData.validations) {\n Object.values(itemData.validations).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n if (itemData.prefills) {\n itemData.prefills.forEach((prefill) => {\n if (prefill.when) {\n this.updateExpressionReferences(prefill.when, idMapping);\n }\n\n if (prefill.source.type === \"expression\") {\n this.updateExpressionReferences(prefill.source.expression, idMapping);\n }\n\n if (prefill.source.type === \"previousResponse\") {\n prefill.source.ref.itemId =\n idMapping[prefill.source.ref.itemId] ?? prefill.source.ref.itemId;\n }\n });\n }\n }\n\n /**\n * Update references in a single expression (recursive)\n */\n private updateExpressionReferences(\n expression: unknown,\n idMapping: { [oldId: string]: string },\n ): void {\n if (!expression || typeof expression !== \"object\") {\n return;\n }\n\n const expr = expression as Record<string, unknown>;\n if (Array.isArray(expr.data)) {\n expr.data.forEach((arg: unknown) => {\n if (arg && typeof arg === \"object\" && arg !== null && \"str\" in arg) {\n const argObj = arg as { str?: string };\n if (\n typeof argObj.str === \"string\" &&\n Object.prototype.hasOwnProperty.call(idMapping, argObj.str)\n ) {\n argObj.str = idMapping[argObj.str];\n }\n this.updateExpressionReferences(arg, idMapping);\n }\n });\n }\n\n Object.keys(expr).forEach((key) => {\n const val = expr[key];\n if (val && typeof val === \"object\") {\n this.updateExpressionReferences(val, idMapping);\n }\n });\n }\n\n /**\n * Update translation keys for the pasted item\n */\n private updateTranslations(\n translations: { [itemId: string]: SerializedTranslations },\n idMapping: { [oldId: string]: string },\n ): { [itemId: string]: SerializedTranslations } {\n const newTranslations: { [itemId: string]: SerializedTranslations } = {};\n\n // Update ids for all items in the translation data\n Object.keys(translations).forEach((itemId) => {\n const itemTranslations = translations[itemId];\n\n // Determine the new key for this item (update the key mapping)\n const newItemId = idMapping[itemId];\n\n // Copy the serialized translations as-is (content is preserved, only keys change)\n newTranslations[newItemId] = itemTranslations;\n });\n\n return newTranslations;\n }\n\n /**\n * Validate clipboard data format\n */\n static isValidClipboardData(data: unknown): data is SurveyItemClipboardData {\n if (typeof data !== \"object\" || data === null || data === undefined) return false;\n const clipboardData = data as SurveyItemClipboardData;\n\n if (\n clipboardData.rootItemId === undefined ||\n typeof clipboardData.rootItemId !== \"string\" ||\n !Array.isArray(clipboardData.items) ||\n clipboardData.items.length === 0 ||\n typeof clipboardData.translations !== \"object\" ||\n clipboardData.translations === null ||\n Array.isArray(clipboardData.translations)\n ) {\n return false;\n }\n\n return (\n clipboardData.type === \"survey-item\" &&\n clipboardData.version === \"1.0.0\" &&\n clipboardData.items.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n typeof item.itemId === \"string\" &&\n item.itemId.length > 0 &&\n typeof item.itemData === \"object\" &&\n item.itemData !== null &&\n !Array.isArray(item.itemData) &&\n typeof item.itemData.itemType === \"string\",\n ) &&\n clipboardData.items.some((item) => item.itemId === clipboardData.rootItemId)\n );\n }\n}\n","import { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { structuredCloneMethod } from \"../utils\";\n\nexport interface UndoRedoConfig {\n maxTotalMemoryMB: number;\n minHistorySize: number;\n maxHistorySize: number;\n}\n\nexport const CommitSource = {\n USER: \"user\",\n SYSTEM: \"system\",\n ASSISTANT: \"assistant\",\n} as const;\nexport type CommitSource = (typeof CommitSource)[keyof typeof CommitSource];\n\nexport interface CommitMeta {\n label: string;\n source?: CommitSource;\n}\n\nexport interface AssetPatch {\n assetId: string;\n prev?: RawSurveyAsset;\n next?: RawSurveyAsset;\n}\n\ninterface BaseHistoryEntry {\n timestamp: number;\n meta: CommitMeta;\n memorySize: number;\n}\n\ninterface SurveySnapshotHistoryEntry extends BaseHistoryEntry {\n kind: \"survey-snapshot\";\n survey: RawSurvey;\n}\n\ninterface AssetChangeHistoryEntry extends BaseHistoryEntry {\n kind: \"asset-change\";\n changes: AssetPatch[];\n}\n\ntype HistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry;\ntype PendingHistoryEntry =\n | Omit<SurveySnapshotHistoryEntry, \"timestamp\" | \"memorySize\">\n | Omit<AssetChangeHistoryEntry, \"timestamp\" | \"memorySize\">;\n\nexport interface SurveyEditorHistoryCommit {\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n}\n\ntype SerializedHistoryEntry =\n | SurveySnapshotHistoryEntry\n | AssetChangeHistoryEntry\n | (BaseHistoryEntry & { survey: RawSurvey });\n\n// Memory calculation utilities\nclass MemoryCalculator {\n private static encoder = new TextEncoder();\n\n static calculateSize(obj: object): number {\n const jsonString = JSON.stringify(obj);\n return this.encoder.encode(jsonString).length;\n }\n\n static formatBytes(bytes: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n let size = bytes;\n let unitIndex = 0;\n\n while (size >= 1024 && unitIndex < units.length - 1) {\n size /= 1024;\n unitIndex++;\n }\n\n return `${size.toFixed(1)} ${units[unitIndex]}`;\n }\n}\n\nfunction cloneAssets(\n assets?: Record<string, RawSurveyAsset>,\n): Record<string, RawSurveyAsset> | undefined {\n if (!assets || Object.keys(assets).length === 0) {\n return undefined;\n }\n return structuredCloneMethod(assets);\n}\n\nfunction normalizeHistoryEntry(entry: SerializedHistoryEntry): HistoryEntry {\n if (\"kind\" in entry) {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: structuredCloneMethod(entry.changes),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n}\n\nexport class SurveyEditorUndoRedo {\n private history: HistoryEntry[] = [];\n private currentIndex: number = -1;\n private _config: UndoRedoConfig;\n private _initialAssets?: Record<string, RawSurveyAsset>;\n\n constructor(\n initialSurvey: RawSurvey,\n config: Partial<UndoRedoConfig> = {},\n meta: CommitMeta = { label: \"Initial state\", source: CommitSource.SYSTEM },\n initialAssets?: Record<string, RawSurveyAsset>,\n ) {\n this._config = {\n maxTotalMemoryMB: 50,\n minHistorySize: 10,\n maxHistorySize: 200,\n ...config,\n };\n this._initialAssets = cloneAssets(initialAssets);\n\n this.saveSnapshot(initialSurvey, meta);\n }\n\n private saveEntry(entry: PendingHistoryEntry): void {\n const payload =\n entry.kind === \"survey-snapshot\"\n ? { kind: entry.kind, survey: entry.survey }\n : { kind: entry.kind, changes: entry.changes };\n\n const memorySize = MemoryCalculator.calculateSize(payload);\n\n // Remove any history after current index\n this.history = this.history.slice(0, this.currentIndex + 1);\n\n this.history.push({\n ...structuredCloneMethod(entry),\n timestamp: Date.now(),\n memorySize,\n } as HistoryEntry);\n\n this.currentIndex++;\n\n // Clean up history based on memory usage\n this.cleanupHistory();\n }\n\n private saveSnapshot(survey: RawSurvey, meta: CommitMeta): void {\n this.saveEntry({\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(survey),\n meta,\n });\n }\n\n private getBaseAssetsSize(): number {\n return this._initialAssets ? MemoryCalculator.calculateSize(this._initialAssets) : 0;\n }\n\n private cleanupHistory(): void {\n const maxMemoryBytes = this._config.maxTotalMemoryMB * 1024 * 1024;\n\n // Remove oldest states while preserving minimum.\n while (\n this.history.length > this._config.minHistorySize &&\n (this.getTotalMemoryUsage() > maxMemoryBytes ||\n this.history.length > this._config.maxHistorySize)\n ) {\n if (this.dropOldestState() <= 0) {\n break;\n }\n }\n }\n\n private dropOldestState(): number {\n if (this.history.length <= 1) {\n return 0;\n }\n\n const nextStateIndex = 1;\n const nextStateSurvey = this.getStateAtIndex(nextStateIndex);\n const nextStateAssets = this.getAssetsAtIndex(nextStateIndex);\n const nextEntry = this.history[nextStateIndex];\n\n const newFirstEntry: SurveySnapshotHistoryEntry = {\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n meta: nextEntry.meta,\n timestamp: nextEntry.timestamp,\n memorySize: MemoryCalculator.calculateSize({\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n }),\n };\n\n const removedBytes = this.history[0].memorySize;\n\n this._initialAssets = cloneAssets(nextStateAssets);\n this.history = [newFirstEntry, ...this.history.slice(nextStateIndex + 1)];\n this.currentIndex--;\n\n return removedBytes;\n }\n\n private getTotalMemoryUsage(): number {\n return (\n this.getBaseAssetsSize() + this.history.reduce((total, entry) => total + entry.memorySize, 0)\n );\n }\n\n private getStateAtIndex(index: number): RawSurvey {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n for (let i = index; i >= 0; i--) {\n const entry = this.history[i];\n if (entry.kind === \"survey-snapshot\") {\n return structuredCloneMethod(entry.survey);\n }\n }\n\n throw new Error(\"Invalid history state\");\n }\n\n private applyAssetPatch(\n assets: Record<string, RawSurveyAsset>,\n patch: AssetPatch,\n ): Record<string, RawSurveyAsset> {\n const nextAssets = structuredCloneMethod(assets);\n if (patch.next) {\n nextAssets[patch.assetId] = structuredCloneMethod(patch.next);\n } else {\n delete nextAssets[patch.assetId];\n }\n return nextAssets;\n }\n\n private getAssetsAtIndex(index: number): Record<string, RawSurveyAsset> | undefined {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n let assets = cloneAssets(this._initialAssets) ?? {};\n\n for (let i = 1; i <= index; i++) {\n const entry = this.history[i];\n if (entry.kind !== \"asset-change\") {\n continue;\n }\n\n for (const patch of entry.changes) {\n assets = this.applyAssetPatch(assets, patch);\n }\n }\n\n return Object.keys(assets).length > 0 ? assets : undefined;\n }\n\n // Commit a change to history\n commit(survey: RawSurvey, meta: CommitMeta): void {\n this.saveSnapshot(survey, meta);\n }\n\n commitAssetChange(changes: AssetPatch[], meta: CommitMeta): void {\n if (changes.length === 0) {\n return;\n }\n\n this.saveEntry({\n kind: \"asset-change\",\n changes: structuredCloneMethod(changes),\n meta,\n });\n }\n\n // Get current committed state\n getCurrentState(): RawSurvey {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getStateAtIndex(this.currentIndex);\n }\n\n getCurrentAssets(): Record<string, RawSurveyAsset> | undefined {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getAssetsAtIndex(this.currentIndex);\n }\n\n undo(): RawSurvey | null {\n if (!this.canUndo()) return null;\n\n this.currentIndex--;\n return this.getCurrentState();\n }\n\n redo(): RawSurvey | null {\n if (!this.canRedo()) return null;\n\n this.currentIndex++;\n return this.getCurrentState();\n }\n\n canUndo(): boolean {\n return this.currentIndex > 0;\n }\n\n canRedo(): boolean {\n return this.currentIndex < this.history.length - 1;\n }\n\n getUndoMeta(): CommitMeta | null {\n if (!this.canUndo()) return null;\n return this.history[this.currentIndex].meta;\n }\n\n getRedoMeta(): CommitMeta | null {\n if (!this.canRedo()) return null;\n return this.history[this.currentIndex + 1].meta;\n }\n\n getMemoryUsage(): { totalMB: number; entries: number } {\n return {\n totalMB: this.getTotalMemoryUsage() / (1024 * 1024),\n entries: this.history.length,\n };\n }\n\n getConfig(): UndoRedoConfig {\n return { ...this._config };\n }\n\n /**\n * Get the full history list with metadata\n */\n getHistory(): Array<{\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n }> {\n return this.history.map((entry, index) => ({\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n }));\n }\n\n /**\n * Get committed history entries after the initial state up to the current index.\n *\n * Redo-only future entries are intentionally omitted so the returned list describes the active\n * change chain from the initial state to the current editor state.\n */\n getCommitsSinceInitial(): SurveyEditorHistoryCommit[] {\n return this.history.slice(1, this.currentIndex + 1).map((entry, offset) => {\n const index = offset + 1;\n return {\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n };\n });\n }\n\n /**\n * Get the current index in the history\n */\n getCurrentIndex(): number {\n return this.currentIndex;\n }\n\n /**\n * Get the total number of history entries\n */\n getHistoryLength(): number {\n return this.history.length;\n }\n\n /**\n * Jump to a specific index in the history (can go forward or backward)\n * @param targetIndex The index to jump to\n * @returns The survey state at the target index, or null if invalid\n */\n jumpToIndex(targetIndex: number): RawSurvey | null {\n if (\n targetIndex < 0 ||\n targetIndex >= this.history.length ||\n targetIndex === this.currentIndex\n ) {\n return null;\n }\n\n this.currentIndex = targetIndex;\n return this.getCurrentState();\n }\n\n /**\n * Check if we can jump to a specific index\n */\n canJumpToIndex(targetIndex: number): boolean {\n return (\n targetIndex >= 0 && targetIndex < this.history.length && targetIndex !== this.currentIndex\n );\n }\n\n /**\n * Serialize the undo/redo state to JSON\n * @returns A JSON-serializable object containing the complete state\n */\n serialize(): {\n history: Array<HistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n } {\n return {\n history: this.history.map((entry) => {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: entry.survey,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: entry.changes,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }),\n currentIndex: this.currentIndex,\n config: { ...this._config },\n initialAssets: cloneAssets(this._initialAssets),\n };\n }\n\n /**\n * Create a new SurveyEditorUndoRedo instance from JSON data\n * @param jsonData The serialized undo/redo state\n * @returns A new SurveyEditorUndoRedo instance with the restored state\n */\n static deserialize(\n jsonData: {\n history: Array<SerializedHistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n },\n initialAssetsOverride?: Record<string, RawSurveyAsset>,\n ): SurveyEditorUndoRedo {\n if (!jsonData.history || !Array.isArray(jsonData.history) || jsonData.history.length === 0) {\n throw new Error(\"Invalid object: history must be an array and must not be empty\");\n }\n\n if (\n typeof jsonData.currentIndex !== \"number\" ||\n jsonData.currentIndex < 0 ||\n jsonData.currentIndex >= jsonData.history.length\n ) {\n throw new Error(\n \"Invalid object: currentIndex must be a valid index within the history array\",\n );\n }\n\n if (!jsonData.config) {\n throw new Error(\"Invalid object: config is required\");\n }\n\n const normalizedHistory = jsonData.history.map(normalizeHistoryEntry);\n\n // Create a new instance with the first survey and config\n const firstEntry = normalizedHistory[0];\n const firstSurvey =\n firstEntry.kind === \"survey-snapshot\"\n ? firstEntry.survey\n : (() => {\n throw new Error(\n \"Invalid object: first history entry must resolve to a survey snapshot\",\n );\n })();\n\n const instance = new SurveyEditorUndoRedo(\n firstSurvey,\n jsonData.config,\n firstEntry.meta,\n initialAssetsOverride ?? jsonData.initialAssets,\n );\n\n // Clear the default initial state and restore the full history\n instance.history = normalizedHistory;\n instance.currentIndex = jsonData.currentIndex;\n instance._initialAssets = cloneAssets(initialAssetsOverride ?? jsonData.initialAssets);\n\n return instance;\n }\n}\n","import { Survey } from \"../survey/survey\";\nimport { CommitMeta, CommitSource, SurveyEditorUndoRedo, type UndoRedoConfig } from \"./undo-redo\";\nimport {\n SurveyItemTranslations,\n SurveyCardContent,\n NavigationContent,\n Content,\n} from \"../survey/utils\";\nimport { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { ItemCopyPaste, SurveyItemClipboardData } from \"./item-copy-paste\";\nimport { Target } from \"./types\";\nimport { SurveyItemCore, RawSurveyItem } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport type { ItemTypeRegistry } from \"../survey/registry/item-registry\";\nimport type { TemplateValueDefinition } from \"../expressions/template-value\";\nimport { structuredCloneMethod } from \"../utils\";\n\n// Interface for serializing SurveyEditor state\nexport interface SerializedSurveyEditor {\n version: string;\n survey: RawSurvey;\n undoRedo: ReturnType<SurveyEditorUndoRedo[\"serialize\"]>;\n hasUncommittedChanges: boolean;\n}\n\nexport interface SurveyEditorConfig extends Partial<UndoRedoConfig> {\n /** Plugin registry for deserializing survey state during undo/redo. Required when survey contains custom item types. */\n pluginRegistry?: ItemTypeRegistry;\n}\n\nfunction stripAssetsFromSurveySnapshot(survey: RawSurvey): RawSurvey {\n const snapshot = structuredCloneMethod(survey);\n delete snapshot.assets;\n return snapshot;\n}\n\nfunction mergeSurveySnapshotWithAssets(\n snapshot: RawSurvey,\n assets?: RawSurvey[\"assets\"],\n): RawSurvey {\n const merged = structuredCloneMethod(snapshot);\n\n if (assets && Object.keys(assets).length > 0) {\n merged.assets = structuredCloneMethod(assets);\n } else {\n delete merged.assets;\n }\n\n return merged;\n}\n\nexport class SurveyEditor {\n private _survey: Survey;\n private _undoRedo: SurveyEditorUndoRedo;\n private _hasUncommittedChanges: boolean = false;\n private _pluginRegistry?: ItemTypeRegistry;\n\n constructor(survey: Survey, config: SurveyEditorConfig = {}, meta?: CommitMeta) {\n this._survey = survey;\n const { pluginRegistry, ...undoRedoConfig } = config;\n this._pluginRegistry = pluginRegistry;\n const serialized = survey.serialize();\n this._undoRedo = new SurveyEditorUndoRedo(\n stripAssetsFromSurveySnapshot(serialized),\n undoRedoConfig,\n meta,\n serialized.assets,\n );\n }\n\n /** Returns an immutable copy of the current survey state. */\n get survey(): Survey {\n const serialized = this._survey.serialize();\n const registry = this._pluginRegistry ?? this._survey.getPluginRegistry();\n return Survey.fromJson(serialized, registry);\n }\n\n get hasUncommittedChanges(): boolean {\n return this._hasUncommittedChanges;\n }\n\n // Expose the undo-redo instance directly\n get undoRedo(): SurveyEditorUndoRedo {\n return this._undoRedo;\n }\n\n // Commit current changes to undo/redo history\n commit(meta: CommitMeta): void {\n if (!this._hasUncommittedChanges) {\n return;\n }\n\n this._undoRedo.commit(stripAssetsFromSurveySnapshot(this._survey.serialize()), meta);\n this._hasUncommittedChanges = false;\n }\n\n private restoreHistoryState(snapshot: RawSurvey, assets?: RawSurvey[\"assets\"]): void {\n this._survey = Survey.fromJson(\n mergeSurveySnapshotWithAssets(snapshot, assets),\n this._pluginRegistry,\n );\n }\n\n commitIfNeeded(): void {\n if (this._hasUncommittedChanges) {\n this.commit({\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n });\n }\n }\n\n // Undo to previous state\n undo(): boolean {\n if (this._hasUncommittedChanges) {\n // If there are uncommitted changes, revert to last committed state\n this.restoreHistoryState(this._undoRedo.getCurrentState(), this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n } else {\n // Normal undo operation\n const previousState = this._undoRedo.undo();\n if (previousState) {\n this.restoreHistoryState(previousState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n }\n\n // Redo to next state\n redo(): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot redo when there are uncommitted changes\n return false;\n }\n\n const nextState = this._undoRedo.redo();\n if (nextState) {\n this.restoreHistoryState(nextState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n // Enhanced undo/redo methods that use the exposed instance\n /**\n * Jump to a specific index in the history (can go forward or backward)\n */\n jumpToIndex(targetIndex: number): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot jump to specific index with uncommitted changes\n return false;\n }\n\n const targetState = this._undoRedo.jumpToIndex(targetIndex);\n if (targetState) {\n this.restoreHistoryState(targetState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n canUndo(): boolean {\n return this._hasUncommittedChanges || this._undoRedo.canUndo();\n }\n\n canRedo(): boolean {\n return !this._hasUncommittedChanges && this._undoRedo.canRedo();\n }\n\n getUndoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return {\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n };\n }\n return this._undoRedo.getUndoMeta();\n }\n\n getRedoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return null;\n }\n return this._undoRedo.getRedoMeta();\n }\n\n // Get memory usage statistics\n getMemoryUsage(): { totalMB: number; entries: number } {\n return this._undoRedo.getMemoryUsage();\n }\n\n // Get undo/redo configuration\n getUndoRedoConfig(): UndoRedoConfig {\n return this._undoRedo.getConfig();\n }\n\n /**\n * Get committed changes after the initial editor state up to the current undo/redo position.\n */\n getCommitsSinceInitial() {\n return this._undoRedo.getCommitsSinceInitial();\n }\n\n /**\n * Serialize the SurveyEditor state to JSON\n * @returns A JSON-serializable object containing the complete editor state\n */\n toJson(): SerializedSurveyEditor {\n return {\n version: \"1.0.0\",\n survey: this._survey.serialize(),\n undoRedo: this._undoRedo.serialize(),\n hasUncommittedChanges: this._hasUncommittedChanges,\n };\n }\n\n /**\n * Create a new SurveyEditor instance from JSON data\n * @param jsonData The serialized editor state\n * @param pluginRegistry Optional plugin registry for deserializing survey state (required when survey contains custom item types)\n * @returns A new SurveyEditor instance with the restored state\n */\n static fromJson(\n jsonData: SerializedSurveyEditor,\n pluginRegistry?: ItemTypeRegistry,\n ): SurveyEditor {\n if (!jsonData.survey) {\n throw new Error(\"Invalid object: survey is required\");\n }\n\n if (!jsonData.undoRedo) {\n throw new Error(\"Invalid object: undoRedo is required\");\n }\n\n if (typeof jsonData.hasUncommittedChanges !== \"boolean\") {\n throw new Error(\"Invalid object: hasUncommittedChanges must be a boolean\");\n }\n\n // Validate version (for future compatibility)\n if (jsonData.version && !jsonData.version.startsWith(\"1.\")) {\n console.warn(\n `Warning: Loading SurveyEditor with version ${jsonData.version}, current version is 1.0.0`,\n );\n }\n\n // Create survey from JSON\n const survey = Survey.fromJson(jsonData.survey, pluginRegistry);\n\n // Create a new editor instance\n const editor = new SurveyEditor(survey, { pluginRegistry });\n\n // Restore undo/redo state\n editor._undoRedo = SurveyEditorUndoRedo.deserialize(\n {\n ...jsonData.undoRedo,\n history: jsonData.undoRedo.history.map((entry) =>\n \"survey\" in entry\n ? {\n ...entry,\n survey: stripAssetsFromSurveySnapshot(entry.survey),\n }\n : entry,\n ),\n },\n jsonData.survey.assets,\n );\n\n // Infer whether the live survey contains uncommitted survey changes by comparing\n // the current survey content to the current history entry, ignoring assets.\n editor._hasUncommittedChanges =\n JSON.stringify(stripAssetsFromSurveySnapshot(jsonData.survey)) !==\n JSON.stringify(editor._undoRedo.getCurrentState());\n\n return editor;\n }\n\n private markAsModified(): void {\n this._hasUncommittedChanges = true;\n }\n\n private createEditorTimestamp(): string {\n return new Date().toISOString();\n }\n\n private touchItemModifiedMetadata(\n itemId: string,\n timestamp = this.createEditorTimestamp(),\n ): void {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return;\n }\n\n item.setModifiedAt(timestamp);\n }\n\n addItem(target: Target, item: SurveyItemCore, content?: SurveyItemTranslations): void {\n // Mark as modified (uncommitted change)\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n\n // Find the parent group item\n let parentGroup: GroupItemCore;\n\n if (!target) {\n // If no target provided, add to root\n\n const rootItem = this._survey.rootItem;\n if (!rootItem) {\n throw new Error(\"No root group found in survey\");\n }\n if (!(rootItem instanceof GroupItemCore)) {\n throw new Error(\"Root item is not a group item\");\n }\n parentGroup = rootItem;\n } else {\n // Find the target parent group\n const targetItem = this._survey.surveyItems.get(target.parentId);\n\n if (!targetItem) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Parent item '${target.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n parentGroup = targetItem;\n }\n\n if (parentGroup.hasChild(item.id)) {\n throw new Error(`Item ${item.id} already in this group`);\n }\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n parentGroup.items?.includes(sItem.id),\n );\n let counter = 1;\n const originalKey = item.key;\n let uniqueKey = originalKey;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${originalKey}_${counter}`;\n counter++;\n }\n\n // Determine insertion index\n let insertIndex: number;\n if (target?.index !== undefined) {\n // Insert at specified index, or at end if index is larger than array length\n insertIndex = Math.min(target.index, parentGroup.items.length);\n } else {\n // Insert at the end\n insertIndex = parentGroup.items.length;\n }\n\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n\n // Add the item to the survey items collection\n this._survey.surveyItems.set(item.id, item);\n\n // Add the item to the parent group (uses addChild for proper persistence)\n parentGroup.addChild(item.id, insertIndex);\n this.touchItemModifiedMetadata(parentGroup.id, timestamp);\n\n // Update translations in the survey\n if (content) {\n this._survey.translations.setItemTranslations(item.id, content);\n }\n }\n\n // Remove an item from the survey\n removeItem(itemId: string, nested: boolean = false): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n // Find parent group and remove from its items array\n const parentItem = this._survey.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Item with id '${itemId}' is the root item`);\n }\n\n if (item instanceof GroupItemCore) {\n for (const childId of item.getChildrenIds()) {\n this.removeItem(childId, true);\n }\n }\n\n // Remove from survey items\n this._survey.surveyItems.delete(itemId);\n\n // Remove translations\n this._survey.translations?.onItemDeleted(itemId);\n\n if (!nested) {\n parentItem.removeChild(itemId);\n this.touchItemModifiedMetadata(parentItem.id, timestamp);\n }\n return true;\n }\n\n // Move an item to a different position\n moveItem(itemId: string, newTarget: Target): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n // Check if item exists\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Check if new target exists and is a group\n const targetItem = this._survey.surveyItems.get(newTarget.parentId);\n if (!targetItem) {\n throw new Error(`Target parent with id '${newTarget.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Target parent '${newTarget.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n // Check if new target is not a child of the current item (prevent circular reference)\n if (this._survey.isDescendantOf(newTarget.parentId, itemId)) {\n throw new Error(`Cannot move item '${itemId}' to its descendant '${newTarget.parentId}'`);\n }\n\n // If the item is already in the target parent\n const currentParentItem = this._survey.getParentItem(itemId);\n if (currentParentItem?.id === newTarget.parentId) {\n throw new Error(`Item '${itemId}' is already in the target parent '${newTarget.parentId}'`);\n }\n\n // Remove item from current parent's items array\n if (currentParentItem) {\n const currentParentGroup = currentParentItem as GroupItemCore;\n currentParentGroup.removeChild(itemId);\n this.touchItemModifiedMetadata(currentParentGroup.id, timestamp);\n }\n\n // Add item to new parent's items array\n const targetGroup = targetItem as GroupItemCore;\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n targetGroup.hasChild(sItem.id),\n );\n let counter = 1;\n let uniqueKey = item.key;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${item.key}_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n }\n\n const insertIndex =\n newTarget.index !== undefined\n ? Math.min(newTarget.index, targetGroup.items.length)\n : targetGroup.items.length;\n\n targetGroup.addChild(itemId, insertIndex);\n this.touchItemModifiedMetadata(targetGroup.id, timestamp);\n this.touchItemModifiedMetadata(itemId, timestamp);\n\n return true;\n }\n\n /**\n * Get a deep copy of an item's raw data.\n * The returned object is independent of the survey—mutating it will not affect the survey.\n * Use this when you need to edit an item in a form or pass it to updateItem after modifications.\n *\n * @param itemId - The ID of the item to copy\n * @returns A deep copy of the item's RawSurveyItem data\n * @throws Error if the item is not found\n */\n getItemDataCopy(itemId: string): RawSurveyItem {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n return JSON.parse(JSON.stringify(item.rawItem)) as RawSurveyItem;\n }\n\n /**\n * Update an item's data in the survey.\n * Can update common attributes (displayConditions, disabledConditions, validations, etc.)\n * as well as type-specific config.\n *\n * Use getItemDataCopy to obtain an editable copy, modify it, then pass it here.\n * Alternatively, pass a Partial to merge specific fields (top-level keys only;\n * e.g. config replaces the entire config object).\n *\n * @param itemId - The ID of the item to update (must match data.id if provided)\n * @param rawItemData - Full RawSurveyItem or Partial to merge. The id cannot be changed.\n */\n updateItem(itemId: string, rawItemData: RawSurveyItem | Partial<RawSurveyItem>): void {\n const existingItem = this._survey.surveyItems.get(itemId);\n if (!existingItem) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n if (\"id\" in rawItemData && rawItemData.id !== undefined && rawItemData.id !== itemId) {\n throw new Error(`Cannot change item id from '${itemId}' to '${rawItemData.id}'`);\n }\n\n const currentRaw = existingItem.rawItem;\n const merged: RawSurveyItem = {\n ...currentRaw,\n ...rawItemData,\n id: itemId, // Ensure id is never changed\n };\n\n // Reject key change if it would collide with a sibling\n const newKey = merged.key ?? existingItem.key;\n const parentGroup = this._survey.getParentItem(itemId);\n if (parentGroup) {\n const siblingWithSameKey = (parentGroup.items ?? [])\n .filter((id) => id !== itemId)\n .map((id) => this._survey.surveyItems.get(id))\n .find((s) => s !== undefined && s.key === newKey);\n if (siblingWithSameKey) {\n throw new Error(\n `Key '${newKey}' is already in use by sibling item '${siblingWithSameKey.id}'`,\n );\n }\n }\n\n const newItem = this._survey.createItemFromRaw({\n ...merged,\n editorMetadata: existingItem.rawItem.editorMetadata,\n });\n newItem.setModifiedAt(this.createEditorTimestamp());\n this._survey.surveyItems.set(itemId, newItem);\n this.markAsModified();\n }\n\n // TODO: add also to update component translations (updating part of the item)\n // Update item translations\n updateItemTranslations(itemId: string, updatedContent?: SurveyItemTranslations): boolean {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n this.markAsModified();\n item.setModifiedAt(this.createEditorTimestamp());\n this._survey.translations.setItemTranslations(itemId, updatedContent);\n\n return true;\n }\n\n /**\n * Update survey-level translations that are not tied to specific items.\n * Use these for survey card, navigation, validation messages, etc.\n */\n updateSurveyTranslations(updates: {\n surveyCard?: { locale: string; content?: SurveyCardContent };\n navigation?: { locale: string; content?: NavigationContent };\n validationMessages?: { locale: string; content?: { invalidResponse?: Content } };\n }): void {\n this.markAsModified();\n if (updates.surveyCard) {\n this._survey.translations.setSurveyCardContent(\n updates.surveyCard.locale,\n updates.surveyCard.content,\n );\n }\n if (updates.navigation) {\n this._survey.translations.setNavigationContent(\n updates.navigation.locale,\n updates.navigation.content,\n );\n }\n if (updates.validationMessages) {\n this._survey.translations.setValidationMessages(\n updates.validationMessages.locale,\n updates.validationMessages.content,\n );\n }\n }\n\n /**\n * Get maxItemsPerPage immutably (returns a copy).\n */\n getMaxItemsPerPage(): { large: number; small: number } | undefined {\n const val = this._survey.maxItemsPerPage;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update maxItemsPerPage.\n */\n updateMaxItemsPerPage(value: { large: number; small: number } | undefined): void {\n this.markAsModified();\n this._survey.maxItemsPerPage = value ? { ...value } : undefined;\n }\n\n /**\n * Get metadata immutably (returns a copy).\n */\n getMetadata(): { [key: string]: string } | undefined {\n const val = this._survey.metadata;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update metadata.\n */\n updateMetadata(metadata: { [key: string]: string } | undefined): void {\n this.markAsModified();\n this._survey.metadata = metadata ? { ...metadata } : undefined;\n }\n\n /**\n * Get a template value immutably (returns a deep copy).\n */\n getTemplateValue(key: string): TemplateValueDefinition | undefined {\n const val = this._survey.getTemplateValue(key);\n return val ? structuredCloneMethod(val) : undefined;\n }\n\n /**\n * Get all template values immutably (returns a new Map with deep-copied values).\n */\n getTemplateValues(): Map<string, TemplateValueDefinition> {\n const keys = this._survey.getTemplateValueKeys();\n const result = new Map<string, TemplateValueDefinition>();\n for (const key of keys) {\n const val = this._survey.getTemplateValue(key);\n if (val) {\n result.set(key, structuredCloneMethod(val));\n }\n }\n return result;\n }\n\n /**\n * Add or replace a template value.\n */\n setTemplateValue(key: string, templateValue: TemplateValueDefinition): void {\n this.markAsModified();\n this._survey.setTemplateValue(key, structuredCloneMethod(templateValue));\n }\n\n /**\n * Remove a template value.\n */\n removeTemplateValue(key: string): void {\n this.markAsModified();\n this._survey.deleteTemplateValue(key);\n }\n\n /**\n * Get a survey asset immutably.\n */\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._survey.getAsset(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n /**\n * Get all survey assets immutably.\n */\n getAssets(): Map<string, RawSurveyAsset> {\n return this._survey.getAssets();\n }\n\n /**\n * Add or replace a survey asset.\n */\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n const previousAsset = this._survey.getAsset(assetId);\n this._survey.setAsset(assetId, structuredCloneMethod(asset));\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n next: structuredCloneMethod(asset),\n },\n ],\n {\n label: `Update asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Remove a survey asset.\n */\n removeAsset(assetId: string): void {\n const previousAsset = this._survey.getAsset(assetId);\n if (!previousAsset) {\n return;\n }\n this._survey.deleteAsset(assetId);\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n },\n ],\n {\n label: `Remove asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * @param itemId - The ID of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const copyPaste = new ItemCopyPaste(this._survey);\n return copyPaste.copyItem(itemId);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * @param clipboardData - The clipboard data containing the item to paste\n * @param target - Target location where to paste the item\n * @returns The ID of the pasted item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const itemIdsBeforePaste = new Set(this._survey.surveyItems.keys());\n const copyPaste = new ItemCopyPaste(this._survey);\n const newItemId = copyPaste.pasteItem(clipboardData, target);\n const pastedItemIds = Array.from(this._survey.surveyItems.keys()).filter(\n (itemId) => !itemIdsBeforePaste.has(itemId),\n );\n\n for (const itemId of pastedItemIds) {\n const item = this._survey.surveyItems.get(itemId);\n if (item) {\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n }\n }\n this.touchItemModifiedMetadata(target.parentId, timestamp);\n\n return newItemId;\n }\n}\n"],"mappings":";;AA2BA,IAAa,gBAAb,MAAa,cAAc;CACzB;CAEA,YAAY,QAAgB;AAC1B,OAAK,SAAS;;;;;;;;CAShB,SAAS,QAAyC;AAEhD,MAAI,CADS,KAAK,OAAO,YAAY,IAAI,OAChC,CACP,OAAM,IAAI,MAAM,iBAAiB,OAAO,aAAa;EAIvD,MAAM,cAAc,KAAK,oBAAoB,OAAO;EAGpD,MAAM,QAAQ,YAAY,KAAK,OAAO;GACpC,MAAM,OAA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cAAc,UAAU;;;AAGjC,OAAK,0BAA0B,OAAO,UAAU,UAAU;AAE1D,SAAO"}
|
|
1
|
+
{"version":3,"file":"editor.mjs","names":[],"sources":["../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"sourcesContent":["import { Survey } from \"../survey/survey\";\nimport { SurveyItemCore } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport { ReservedSurveyItemTypes } from \"../survey/items/types\";\nimport { SurveyItemTranslations, JsonComponentContent } from \"../survey/utils\";\nimport { RawSurveyItem } from \"../survey/items/survey-item-json\";\nimport { Target } from \"./types\";\nimport { generateId } from \"../utils\";\n\n// Serialized translation data format for clipboard\nexport type SerializedTranslations = {\n [locale: string]: JsonComponentContent;\n};\n\n// Clipboard data structure for copy-paste functionality\nexport interface SurveyItemClipboardData {\n type: \"survey-item\";\n version: string;\n items: Array<{\n itemId: string;\n itemData: RawSurveyItem;\n }>;\n translations: { [itemId: string]: SerializedTranslations };\n rootItemId: string; // The id of the main item being copied\n timestamp: number;\n}\n\nexport class ItemCopyPaste {\n private survey: Survey;\n\n constructor(survey: Survey) {\n this.survey = survey;\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * When copying a group, automatically includes all items in the subtree\n * @param itemId - The id of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const item = this.survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Collect all items to copy (including subtree for groups)\n const itemsToCopy = this.collectItemsForCopy(itemId);\n\n // Create items array with their data\n const items = itemsToCopy.map((id) => {\n const item = this.survey.surveyItems.get(id);\n if (!item) throw new Error(`Item with id '${id}' not found during copy`);\n return { itemId: id, itemData: item.rawItem };\n });\n\n // Collect translations for all items\n const translations: { [itemId: string]: SerializedTranslations } = {};\n itemsToCopy.forEach((id) => {\n try {\n const itemTranslations = this.survey.getItemTranslations(id);\n if (itemTranslations?.locales?.length) {\n const serializedTranslations: SerializedTranslations = {};\n itemTranslations.locales.forEach((locale) => {\n const localeContent = itemTranslations.getAllForLocale(locale);\n if (localeContent) {\n serializedTranslations[locale] = localeContent;\n }\n });\n translations[id] = serializedTranslations;\n } else {\n translations[id] = {};\n }\n } catch {\n translations[id] = {};\n }\n });\n\n // Create clipboard data\n const clipboardData: SurveyItemClipboardData = {\n type: \"survey-item\",\n version: \"1.0.0\",\n items: items,\n translations: translations,\n rootItemId: itemId,\n timestamp: Date.now(),\n };\n\n return clipboardData;\n }\n\n /**\n * Collect all items that should be copied, including subtree for groups\n * @param itemId - The root item id\n * @returns Array of item keys to copy\n */\n private collectItemsForCopy(itemId: string): string[] {\n const itemsToCopy: string[] = [itemId];\n const item = this.survey.surveyItems.get(itemId);\n\n if (!item) {\n return [];\n }\n\n // If this is a group item, collect all child items recursively\n if (item instanceof GroupItemCore) {\n const childIds = item.items;\n if (childIds.length > 0) {\n childIds.forEach((childId) => {\n const childItems = this.collectItemsForCopy(childId);\n itemsToCopy.push(...childItems);\n });\n }\n }\n\n return itemsToCopy;\n }\n\n /**\n * Add an item to its parent group.\n * Ensures key uniqueness among siblings.\n * @param target - Target location information\n * @param item - The item to add (may have key adjusted for uniqueness)\n */\n private addItemToParentGroup(target: Target, item: SurveyItemCore): void {\n const parentGroup = this.survey.surveyItems.get(target.parentId);\n\n if (!parentGroup) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(parentGroup instanceof GroupItemCore)) {\n throw new Error(`Parent item '${target.parentId}' is not a group item`);\n }\n\n const siblingIds = parentGroup.items;\n const siblings = siblingIds\n .map((id) => this.survey.surveyItems.get(id))\n .filter((s): s is SurveyItemCore => s !== undefined);\n const siblingKeys = new Set(siblings.map((s) => s.key));\n\n let uniqueKey = item.key;\n if (siblingKeys.has(uniqueKey)) {\n let counter = 1;\n const originalKey = item.key;\n while (siblingKeys.has(uniqueKey)) {\n uniqueKey = originalKey + `_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n const updatedRawItem = { ...item.rawItem, key: uniqueKey };\n const newItem = this.survey.createItemFromRaw(updatedRawItem);\n this.survey.surveyItems.delete(item.id);\n this.survey.surveyItems.set(newItem.id, newItem);\n item = newItem;\n }\n }\n\n const insertIndex =\n target.index !== undefined\n ? Math.min(target.index, parentGroup.items.length)\n : parentGroup.items.length;\n\n parentGroup.addChild(item.id, insertIndex);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * Handles multiple items and subtrees from the clipboard data\n * @param clipboardData - The clipboard data containing the item(s) to paste\n * @param target - Target location where to paste the item\n * @returns The id of the pasted root item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n // Validate clipboard data\n if (!ItemCopyPaste.isValidClipboardData(clipboardData)) {\n throw new Error(\"Invalid clipboard data format\");\n }\n\n // Create id mapping for all items in the subtree\n const idMapping: { [oldId: string]: string } = {};\n clipboardData.items.forEach(({ itemId }) => {\n idMapping[itemId] = generateId();\n });\n\n // Create all items with updated ids\n clipboardData.items.forEach(({ itemId, itemData }) => {\n const newId = idMapping[itemId];\n if (newId) {\n const updatedItemData = this.updateItemIdsInData(itemData, idMapping);\n updatedItemData.id = newId;\n\n const newItem = this.survey.createItemFromRaw(updatedItemData);\n this.survey.surveyItems.set(newItem.id, newItem);\n\n if (itemId === clipboardData.rootItemId) {\n this.addItemToParentGroup(target, newItem);\n }\n }\n });\n\n // Update translations with new IDs\n const updatedTranslations = this.updateTranslations(clipboardData.translations, idMapping);\n Object.keys(updatedTranslations).forEach((itemId) => {\n // Convert serialized translations back to SurveyItemTranslations instance\n const itemTranslations = new SurveyItemTranslations();\n const serializedData = updatedTranslations[itemId];\n Object.keys(serializedData).forEach((locale) => {\n itemTranslations.setAllForLocale(locale, serializedData[locale]);\n });\n this.survey.translations.setItemTranslations(itemId, itemTranslations);\n });\n\n return idMapping[clipboardData.rootItemId];\n }\n\n // PRIVATE HELPER METHODS\n /**\n * Update all item ids in the raw item data recursively\n */\n private updateItemIdsInData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): RawSurveyItem {\n const updatedData = JSON.parse(JSON.stringify(itemData));\n\n if (updatedData.itemType === ReservedSurveyItemTypes.Group && updatedData.config) {\n const config = updatedData.config as { items?: string[] };\n if (config.items) {\n config.items = config.items.map((childId: string) => idMapping[childId] ?? childId);\n }\n }\n\n this.updateExpressionsInItemData(updatedData, idMapping);\n return updatedData;\n }\n\n /**\n * Update expressions in item data that reference the old ids\n */\n private updateExpressionsInItemData(\n itemData: RawSurveyItem,\n idMapping: { [oldId: string]: string },\n ): void {\n // Update display conditions\n if (itemData.displayConditions?.root) {\n this.updateExpressionReferences(itemData.displayConditions.root, idMapping);\n }\n if (itemData.displayConditions?.components) {\n Object.values(itemData.displayConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update disabled conditions\n if (itemData.disabledConditions?.components) {\n Object.values(itemData.disabledConditions.components).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n // Update validations\n if (itemData.validations) {\n Object.values(itemData.validations).forEach((expr) => {\n if (expr) this.updateExpressionReferences(expr, idMapping);\n });\n }\n\n if (itemData.prefills) {\n itemData.prefills.forEach((prefill) => {\n if (prefill.when) {\n this.updateExpressionReferences(prefill.when, idMapping);\n }\n\n if (prefill.source.type === \"expression\") {\n this.updateExpressionReferences(prefill.source.expression, idMapping);\n }\n\n if (prefill.source.type === \"previousResponse\") {\n prefill.source.ref.itemId =\n idMapping[prefill.source.ref.itemId] ?? prefill.source.ref.itemId;\n }\n });\n }\n }\n\n /**\n * Update references in a single expression (recursive)\n */\n private updateExpressionReferences(\n expression: unknown,\n idMapping: { [oldId: string]: string },\n ): void {\n if (!expression || typeof expression !== \"object\") {\n return;\n }\n\n const expr = expression as Record<string, unknown>;\n if (Array.isArray(expr.data)) {\n expr.data.forEach((arg: unknown) => {\n if (arg && typeof arg === \"object\" && arg !== null && \"str\" in arg) {\n const argObj = arg as { str?: string };\n if (\n typeof argObj.str === \"string\" &&\n Object.prototype.hasOwnProperty.call(idMapping, argObj.str)\n ) {\n argObj.str = idMapping[argObj.str];\n }\n this.updateExpressionReferences(arg, idMapping);\n }\n });\n }\n\n Object.keys(expr).forEach((key) => {\n const val = expr[key];\n if (val && typeof val === \"object\") {\n this.updateExpressionReferences(val, idMapping);\n }\n });\n }\n\n /**\n * Update translation keys for the pasted item\n */\n private updateTranslations(\n translations: { [itemId: string]: SerializedTranslations },\n idMapping: { [oldId: string]: string },\n ): { [itemId: string]: SerializedTranslations } {\n const newTranslations: { [itemId: string]: SerializedTranslations } = {};\n\n // Update ids for all items in the translation data\n Object.keys(translations).forEach((itemId) => {\n const itemTranslations = translations[itemId];\n\n // Determine the new key for this item (update the key mapping)\n const newItemId = idMapping[itemId];\n\n // Copy the serialized translations as-is (content is preserved, only keys change)\n newTranslations[newItemId] = itemTranslations;\n });\n\n return newTranslations;\n }\n\n /**\n * Validate clipboard data format\n */\n static isValidClipboardData(data: unknown): data is SurveyItemClipboardData {\n if (typeof data !== \"object\" || data === null || data === undefined) return false;\n const clipboardData = data as SurveyItemClipboardData;\n\n if (\n clipboardData.rootItemId === undefined ||\n typeof clipboardData.rootItemId !== \"string\" ||\n !Array.isArray(clipboardData.items) ||\n clipboardData.items.length === 0 ||\n typeof clipboardData.translations !== \"object\" ||\n clipboardData.translations === null ||\n Array.isArray(clipboardData.translations)\n ) {\n return false;\n }\n\n return (\n clipboardData.type === \"survey-item\" &&\n clipboardData.version === \"1.0.0\" &&\n clipboardData.items.every(\n (item) =>\n typeof item === \"object\" &&\n item !== null &&\n typeof item.itemId === \"string\" &&\n item.itemId.length > 0 &&\n typeof item.itemData === \"object\" &&\n item.itemData !== null &&\n !Array.isArray(item.itemData) &&\n typeof item.itemData.itemType === \"string\",\n ) &&\n clipboardData.items.some((item) => item.itemId === clipboardData.rootItemId)\n );\n }\n}\n","import { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { structuredCloneMethod } from \"../utils\";\n\nexport interface UndoRedoConfig {\n maxTotalMemoryMB: number;\n minHistorySize: number;\n maxHistorySize: number;\n}\n\nexport const CommitSource = {\n USER: \"user\",\n SYSTEM: \"system\",\n ASSISTANT: \"assistant\",\n} as const;\nexport type CommitSource = (typeof CommitSource)[keyof typeof CommitSource];\n\nexport interface CommitMeta {\n label: string;\n source?: CommitSource;\n}\n\nexport interface AssetPatch {\n assetId: string;\n prev?: RawSurveyAsset;\n next?: RawSurveyAsset;\n}\n\ninterface BaseHistoryEntry {\n timestamp: number;\n meta: CommitMeta;\n memorySize: number;\n}\n\ninterface SurveySnapshotHistoryEntry extends BaseHistoryEntry {\n kind: \"survey-snapshot\";\n survey: RawSurvey;\n}\n\ninterface AssetChangeHistoryEntry extends BaseHistoryEntry {\n kind: \"asset-change\";\n changes: AssetPatch[];\n}\n\ntype HistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry;\ntype PendingHistoryEntry =\n | Omit<SurveySnapshotHistoryEntry, \"timestamp\" | \"memorySize\">\n | Omit<AssetChangeHistoryEntry, \"timestamp\" | \"memorySize\">;\n\nexport interface SurveyEditorHistoryCommit {\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n}\n\ntype SerializedHistoryEntry =\n | SurveySnapshotHistoryEntry\n | AssetChangeHistoryEntry\n | (BaseHistoryEntry & { survey: RawSurvey });\n\n// Memory calculation utilities\nclass MemoryCalculator {\n private static encoder = new TextEncoder();\n\n static calculateSize(obj: object): number {\n const jsonString = JSON.stringify(obj);\n return this.encoder.encode(jsonString).length;\n }\n\n static formatBytes(bytes: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\"];\n let size = bytes;\n let unitIndex = 0;\n\n while (size >= 1024 && unitIndex < units.length - 1) {\n size /= 1024;\n unitIndex++;\n }\n\n return `${size.toFixed(1)} ${units[unitIndex]}`;\n }\n}\n\nfunction cloneAssets(\n assets?: Record<string, RawSurveyAsset>,\n): Record<string, RawSurveyAsset> | undefined {\n if (!assets || Object.keys(assets).length === 0) {\n return undefined;\n }\n return structuredCloneMethod(assets);\n}\n\nfunction normalizeHistoryEntry(entry: SerializedHistoryEntry): HistoryEntry {\n if (\"kind\" in entry) {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: structuredCloneMethod(entry.changes),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(entry.survey),\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n}\n\nexport class SurveyEditorUndoRedo {\n private history: HistoryEntry[] = [];\n private currentIndex: number = -1;\n private _config: UndoRedoConfig;\n private _initialAssets?: Record<string, RawSurveyAsset>;\n\n constructor(\n initialSurvey: RawSurvey,\n config: Partial<UndoRedoConfig> = {},\n meta: CommitMeta = { label: \"Initial state\", source: CommitSource.SYSTEM },\n initialAssets?: Record<string, RawSurveyAsset>,\n ) {\n this._config = {\n maxTotalMemoryMB: 50,\n minHistorySize: 10,\n maxHistorySize: 200,\n ...config,\n };\n this._initialAssets = cloneAssets(initialAssets);\n\n this.saveSnapshot(initialSurvey, meta);\n }\n\n private saveEntry(entry: PendingHistoryEntry): void {\n const payload =\n entry.kind === \"survey-snapshot\"\n ? { kind: entry.kind, survey: entry.survey }\n : { kind: entry.kind, changes: entry.changes };\n\n const memorySize = MemoryCalculator.calculateSize(payload);\n\n // Remove any history after current index\n this.history = this.history.slice(0, this.currentIndex + 1);\n\n this.history.push({\n ...structuredCloneMethod(entry),\n timestamp: Date.now(),\n memorySize,\n } as HistoryEntry);\n\n this.currentIndex++;\n\n // Clean up history based on memory usage\n this.cleanupHistory();\n }\n\n private saveSnapshot(survey: RawSurvey, meta: CommitMeta): void {\n this.saveEntry({\n kind: \"survey-snapshot\",\n survey: structuredCloneMethod(survey),\n meta,\n });\n }\n\n private getBaseAssetsSize(): number {\n return this._initialAssets ? MemoryCalculator.calculateSize(this._initialAssets) : 0;\n }\n\n private cleanupHistory(): void {\n const maxMemoryBytes = this._config.maxTotalMemoryMB * 1024 * 1024;\n\n // Remove oldest states while preserving minimum.\n while (\n this.history.length > this._config.minHistorySize &&\n (this.getTotalMemoryUsage() > maxMemoryBytes ||\n this.history.length > this._config.maxHistorySize)\n ) {\n if (this.dropOldestState() <= 0) {\n break;\n }\n }\n }\n\n private dropOldestState(): number {\n if (this.history.length <= 1) {\n return 0;\n }\n\n const nextStateIndex = 1;\n const nextStateSurvey = this.getStateAtIndex(nextStateIndex);\n const nextStateAssets = this.getAssetsAtIndex(nextStateIndex);\n const nextEntry = this.history[nextStateIndex];\n\n const newFirstEntry: SurveySnapshotHistoryEntry = {\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n meta: nextEntry.meta,\n timestamp: nextEntry.timestamp,\n memorySize: MemoryCalculator.calculateSize({\n kind: \"survey-snapshot\",\n survey: nextStateSurvey,\n }),\n };\n\n const removedBytes = this.history[0].memorySize;\n\n this._initialAssets = cloneAssets(nextStateAssets);\n this.history = [newFirstEntry, ...this.history.slice(nextStateIndex + 1)];\n this.currentIndex--;\n\n return removedBytes;\n }\n\n private getTotalMemoryUsage(): number {\n return (\n this.getBaseAssetsSize() + this.history.reduce((total, entry) => total + entry.memorySize, 0)\n );\n }\n\n private getStateAtIndex(index: number): RawSurvey {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n for (let i = index; i >= 0; i--) {\n const entry = this.history[i];\n if (entry.kind === \"survey-snapshot\") {\n return structuredCloneMethod(entry.survey);\n }\n }\n\n throw new Error(\"Invalid history state\");\n }\n\n private applyAssetPatch(\n assets: Record<string, RawSurveyAsset>,\n patch: AssetPatch,\n ): Record<string, RawSurveyAsset> {\n const nextAssets = structuredCloneMethod(assets);\n if (patch.next) {\n nextAssets[patch.assetId] = structuredCloneMethod(patch.next);\n } else {\n delete nextAssets[patch.assetId];\n }\n return nextAssets;\n }\n\n private getAssetsAtIndex(index: number): Record<string, RawSurveyAsset> | undefined {\n if (index < 0 || index >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n\n let assets = cloneAssets(this._initialAssets) ?? {};\n\n for (let i = 1; i <= index; i++) {\n const entry = this.history[i];\n if (entry.kind !== \"asset-change\") {\n continue;\n }\n\n for (const patch of entry.changes) {\n assets = this.applyAssetPatch(assets, patch);\n }\n }\n\n return Object.keys(assets).length > 0 ? assets : undefined;\n }\n\n // Commit a change to history\n commit(survey: RawSurvey, meta: CommitMeta): void {\n this.saveSnapshot(survey, meta);\n }\n\n commitAssetChange(changes: AssetPatch[], meta: CommitMeta): void {\n if (changes.length === 0) {\n return;\n }\n\n this.saveEntry({\n kind: \"asset-change\",\n changes: structuredCloneMethod(changes),\n meta,\n });\n }\n\n // Get current committed state\n getCurrentState(): RawSurvey {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getStateAtIndex(this.currentIndex);\n }\n\n getCurrentAssets(): Record<string, RawSurveyAsset> | undefined {\n if (this.currentIndex < 0 || this.currentIndex >= this.history.length) {\n throw new Error(\"Invalid history state\");\n }\n return this.getAssetsAtIndex(this.currentIndex);\n }\n\n undo(): RawSurvey | null {\n if (!this.canUndo()) return null;\n\n this.currentIndex--;\n return this.getCurrentState();\n }\n\n redo(): RawSurvey | null {\n if (!this.canRedo()) return null;\n\n this.currentIndex++;\n return this.getCurrentState();\n }\n\n canUndo(): boolean {\n return this.currentIndex > 0;\n }\n\n canRedo(): boolean {\n return this.currentIndex < this.history.length - 1;\n }\n\n getUndoMeta(): CommitMeta | null {\n if (!this.canUndo()) return null;\n return this.history[this.currentIndex].meta;\n }\n\n getRedoMeta(): CommitMeta | null {\n if (!this.canRedo()) return null;\n return this.history[this.currentIndex + 1].meta;\n }\n\n getMemoryUsage(): { totalMB: number; entries: number } {\n return {\n totalMB: this.getTotalMemoryUsage() / (1024 * 1024),\n entries: this.history.length,\n };\n }\n\n getConfig(): UndoRedoConfig {\n return { ...this._config };\n }\n\n /**\n * Get the full history list with metadata\n */\n getHistory(): Array<{\n index: number;\n kind: HistoryEntry[\"kind\"];\n meta: CommitMeta;\n timestamp: number;\n memorySize: number;\n isCurrent: boolean;\n }> {\n return this.history.map((entry, index) => ({\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n }));\n }\n\n /**\n * Get committed history entries after the initial state up to the current index.\n *\n * Redo-only future entries are intentionally omitted so the returned list describes the active\n * change chain from the initial state to the current editor state.\n */\n getCommitsSinceInitial(): SurveyEditorHistoryCommit[] {\n return this.history.slice(1, this.currentIndex + 1).map((entry, offset) => {\n const index = offset + 1;\n return {\n index,\n kind: entry.kind,\n meta: entry.meta,\n timestamp: entry.timestamp,\n memorySize: entry.memorySize,\n isCurrent: index === this.currentIndex,\n };\n });\n }\n\n /**\n * Get the current index in the history\n */\n getCurrentIndex(): number {\n return this.currentIndex;\n }\n\n /**\n * Get the total number of history entries\n */\n getHistoryLength(): number {\n return this.history.length;\n }\n\n /**\n * Jump to a specific index in the history (can go forward or backward)\n * @param targetIndex The index to jump to\n * @returns The survey state at the target index, or null if invalid\n */\n jumpToIndex(targetIndex: number): RawSurvey | null {\n if (\n targetIndex < 0 ||\n targetIndex >= this.history.length ||\n targetIndex === this.currentIndex\n ) {\n return null;\n }\n\n this.currentIndex = targetIndex;\n return this.getCurrentState();\n }\n\n /**\n * Check if we can jump to a specific index\n */\n canJumpToIndex(targetIndex: number): boolean {\n return (\n targetIndex >= 0 && targetIndex < this.history.length && targetIndex !== this.currentIndex\n );\n }\n\n /**\n * Serialize the undo/redo state to JSON\n * @returns A JSON-serializable object containing the complete state\n */\n serialize(): {\n history: Array<HistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n } {\n return {\n history: this.history.map((entry) => {\n if (entry.kind === \"survey-snapshot\") {\n return {\n kind: \"survey-snapshot\",\n survey: entry.survey,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }\n\n return {\n kind: \"asset-change\",\n changes: entry.changes,\n timestamp: entry.timestamp,\n meta: entry.meta,\n memorySize: entry.memorySize,\n };\n }),\n currentIndex: this.currentIndex,\n config: { ...this._config },\n initialAssets: cloneAssets(this._initialAssets),\n };\n }\n\n /**\n * Create a new SurveyEditorUndoRedo instance from JSON data\n * @param jsonData The serialized undo/redo state\n * @returns A new SurveyEditorUndoRedo instance with the restored state\n */\n static deserialize(\n jsonData: {\n history: Array<SerializedHistoryEntry>;\n currentIndex: number;\n config: UndoRedoConfig;\n initialAssets?: Record<string, RawSurveyAsset>;\n },\n initialAssetsOverride?: Record<string, RawSurveyAsset>,\n ): SurveyEditorUndoRedo {\n if (!jsonData.history || !Array.isArray(jsonData.history) || jsonData.history.length === 0) {\n throw new Error(\"Invalid object: history must be an array and must not be empty\");\n }\n\n if (\n typeof jsonData.currentIndex !== \"number\" ||\n jsonData.currentIndex < 0 ||\n jsonData.currentIndex >= jsonData.history.length\n ) {\n throw new Error(\n \"Invalid object: currentIndex must be a valid index within the history array\",\n );\n }\n\n if (!jsonData.config) {\n throw new Error(\"Invalid object: config is required\");\n }\n\n const normalizedHistory = jsonData.history.map(normalizeHistoryEntry);\n\n // Create a new instance with the first survey and config\n const firstEntry = normalizedHistory[0];\n const firstSurvey =\n firstEntry.kind === \"survey-snapshot\"\n ? firstEntry.survey\n : (() => {\n throw new Error(\n \"Invalid object: first history entry must resolve to a survey snapshot\",\n );\n })();\n\n const instance = new SurveyEditorUndoRedo(\n firstSurvey,\n jsonData.config,\n firstEntry.meta,\n initialAssetsOverride ?? jsonData.initialAssets,\n );\n\n // Clear the default initial state and restore the full history\n instance.history = normalizedHistory;\n instance.currentIndex = jsonData.currentIndex;\n instance._initialAssets = cloneAssets(initialAssetsOverride ?? jsonData.initialAssets);\n\n return instance;\n }\n}\n","import { Survey } from \"../survey/survey\";\nimport { CommitMeta, CommitSource, SurveyEditorUndoRedo, type UndoRedoConfig } from \"./undo-redo\";\nimport {\n SurveyItemTranslations,\n SurveyCardContent,\n NavigationContent,\n Content,\n} from \"../survey/utils\";\nimport { RawSurvey, RawSurveyAsset } from \"../survey/survey-file-schema\";\nimport { ItemCopyPaste, SurveyItemClipboardData } from \"./item-copy-paste\";\nimport { Target } from \"./types\";\nimport { SurveyItemCore, RawSurveyItem } from \"../survey/items\";\nimport { GroupItemCore } from \"../survey/registry/built-in-items\";\nimport type { ItemTypeRegistry } from \"../survey/registry/item-registry\";\nimport type { TemplateValueDefinition } from \"../expressions/template-value\";\nimport { structuredCloneMethod } from \"../utils\";\n\n// Interface for serializing SurveyEditor state\nexport interface SerializedSurveyEditor {\n version: string;\n survey: RawSurvey;\n undoRedo: ReturnType<SurveyEditorUndoRedo[\"serialize\"]>;\n hasUncommittedChanges: boolean;\n}\n\nexport interface SurveyEditorConfig extends Partial<UndoRedoConfig> {\n /** Plugin registry for deserializing survey state during undo/redo. Required when survey contains custom item types. */\n pluginRegistry?: ItemTypeRegistry;\n}\n\nfunction stripAssetsFromSurveySnapshot(survey: RawSurvey): RawSurvey {\n const snapshot = structuredCloneMethod(survey);\n delete snapshot.assets;\n return snapshot;\n}\n\nfunction mergeSurveySnapshotWithAssets(\n snapshot: RawSurvey,\n assets?: RawSurvey[\"assets\"],\n): RawSurvey {\n const merged = structuredCloneMethod(snapshot);\n\n if (assets && Object.keys(assets).length > 0) {\n merged.assets = structuredCloneMethod(assets);\n } else {\n delete merged.assets;\n }\n\n return merged;\n}\n\nexport class SurveyEditor {\n private _survey: Survey;\n private _undoRedo: SurveyEditorUndoRedo;\n private _hasUncommittedChanges: boolean = false;\n private _pluginRegistry?: ItemTypeRegistry;\n\n constructor(survey: Survey, config: SurveyEditorConfig = {}, meta?: CommitMeta) {\n this._survey = survey;\n const { pluginRegistry, ...undoRedoConfig } = config;\n this._pluginRegistry = pluginRegistry;\n const serialized = survey.serialize();\n this._undoRedo = new SurveyEditorUndoRedo(\n stripAssetsFromSurveySnapshot(serialized),\n undoRedoConfig,\n meta,\n serialized.assets,\n );\n }\n\n /** Returns an immutable copy of the current survey state. */\n get survey(): Survey {\n const serialized = this._survey.serialize();\n const registry = this._pluginRegistry ?? this._survey.getPluginRegistry();\n return Survey.fromJson(serialized, registry);\n }\n\n get hasUncommittedChanges(): boolean {\n return this._hasUncommittedChanges;\n }\n\n // Expose the undo-redo instance directly\n get undoRedo(): SurveyEditorUndoRedo {\n return this._undoRedo;\n }\n\n // Commit current changes to undo/redo history\n commit(meta: CommitMeta): void {\n if (!this._hasUncommittedChanges) {\n return;\n }\n\n this._undoRedo.commit(stripAssetsFromSurveySnapshot(this._survey.serialize()), meta);\n this._hasUncommittedChanges = false;\n }\n\n private restoreHistoryState(snapshot: RawSurvey, assets?: RawSurvey[\"assets\"]): void {\n this._survey = Survey.fromJson(\n mergeSurveySnapshotWithAssets(snapshot, assets),\n this._pluginRegistry,\n );\n }\n\n commitIfNeeded(): void {\n if (this._hasUncommittedChanges) {\n this.commit({\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n });\n }\n }\n\n // Undo to previous state\n undo(): boolean {\n if (this._hasUncommittedChanges) {\n // If there are uncommitted changes, revert to last committed state\n this.restoreHistoryState(this._undoRedo.getCurrentState(), this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n } else {\n // Normal undo operation\n const previousState = this._undoRedo.undo();\n if (previousState) {\n this.restoreHistoryState(previousState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n }\n\n // Redo to next state\n redo(): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot redo when there are uncommitted changes\n return false;\n }\n\n const nextState = this._undoRedo.redo();\n if (nextState) {\n this.restoreHistoryState(nextState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n // Enhanced undo/redo methods that use the exposed instance\n /**\n * Jump to a specific index in the history (can go forward or backward)\n */\n jumpToIndex(targetIndex: number): boolean {\n if (this._hasUncommittedChanges) {\n // Cannot jump to specific index with uncommitted changes\n return false;\n }\n\n const targetState = this._undoRedo.jumpToIndex(targetIndex);\n if (targetState) {\n this.restoreHistoryState(targetState, this._undoRedo.getCurrentAssets());\n this._hasUncommittedChanges = false;\n return true;\n }\n return false;\n }\n\n canUndo(): boolean {\n return this._hasUncommittedChanges || this._undoRedo.canUndo();\n }\n\n canRedo(): boolean {\n return !this._hasUncommittedChanges && this._undoRedo.canRedo();\n }\n\n getUndoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return {\n label: \"Latest content changes\",\n source: CommitSource.SYSTEM,\n };\n }\n return this._undoRedo.getUndoMeta();\n }\n\n getRedoMeta(): CommitMeta | null {\n if (this._hasUncommittedChanges) {\n return null;\n }\n return this._undoRedo.getRedoMeta();\n }\n\n // Get memory usage statistics\n getMemoryUsage(): { totalMB: number; entries: number } {\n return this._undoRedo.getMemoryUsage();\n }\n\n // Get undo/redo configuration\n getUndoRedoConfig(): UndoRedoConfig {\n return this._undoRedo.getConfig();\n }\n\n /**\n * Get committed changes after the initial editor state up to the current undo/redo position.\n */\n getCommitsSinceInitial() {\n return this._undoRedo.getCommitsSinceInitial();\n }\n\n /**\n * Serialize the SurveyEditor state to JSON\n * @returns A JSON-serializable object containing the complete editor state\n */\n toJson(): SerializedSurveyEditor {\n return {\n version: \"1.0.0\",\n survey: this._survey.serialize(),\n undoRedo: this._undoRedo.serialize(),\n hasUncommittedChanges: this._hasUncommittedChanges,\n };\n }\n\n /**\n * Create a new SurveyEditor instance from JSON data\n * @param jsonData The serialized editor state\n * @param pluginRegistry Optional plugin registry for deserializing survey state (required when survey contains custom item types)\n * @returns A new SurveyEditor instance with the restored state\n */\n static fromJson(\n jsonData: SerializedSurveyEditor,\n pluginRegistry?: ItemTypeRegistry,\n ): SurveyEditor {\n if (!jsonData.survey) {\n throw new Error(\"Invalid object: survey is required\");\n }\n\n if (!jsonData.undoRedo) {\n throw new Error(\"Invalid object: undoRedo is required\");\n }\n\n if (typeof jsonData.hasUncommittedChanges !== \"boolean\") {\n throw new Error(\"Invalid object: hasUncommittedChanges must be a boolean\");\n }\n\n // Validate version (for future compatibility)\n if (jsonData.version && !jsonData.version.startsWith(\"1.\")) {\n console.warn(\n `Warning: Loading SurveyEditor with version ${jsonData.version}, current version is 1.0.0`,\n );\n }\n\n // Create survey from JSON\n const survey = Survey.fromJson(jsonData.survey, pluginRegistry);\n\n // Create a new editor instance\n const editor = new SurveyEditor(survey, { pluginRegistry });\n\n // Restore undo/redo state\n editor._undoRedo = SurveyEditorUndoRedo.deserialize(\n {\n ...jsonData.undoRedo,\n history: jsonData.undoRedo.history.map((entry) =>\n \"survey\" in entry\n ? {\n ...entry,\n survey: stripAssetsFromSurveySnapshot(entry.survey),\n }\n : entry,\n ),\n },\n jsonData.survey.assets,\n );\n\n // Infer whether the live survey contains uncommitted survey changes by comparing\n // the current survey content to the current history entry, ignoring assets.\n editor._hasUncommittedChanges =\n JSON.stringify(stripAssetsFromSurveySnapshot(jsonData.survey)) !==\n JSON.stringify(editor._undoRedo.getCurrentState());\n\n return editor;\n }\n\n private markAsModified(): void {\n this._hasUncommittedChanges = true;\n }\n\n private createEditorTimestamp(): string {\n return new Date().toISOString();\n }\n\n private touchItemModifiedMetadata(\n itemId: string,\n timestamp = this.createEditorTimestamp(),\n ): void {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return;\n }\n\n item.setModifiedAt(timestamp);\n }\n\n addItem(target: Target, item: SurveyItemCore, content?: SurveyItemTranslations): void {\n // Mark as modified (uncommitted change)\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n\n // Find the parent group item\n let parentGroup: GroupItemCore;\n\n if (!target) {\n // If no target provided, add to root\n\n const rootItem = this._survey.rootItem;\n if (!rootItem) {\n throw new Error(\"No root group found in survey\");\n }\n if (!(rootItem instanceof GroupItemCore)) {\n throw new Error(\"Root item is not a group item\");\n }\n parentGroup = rootItem;\n } else {\n // Find the target parent group\n const targetItem = this._survey.surveyItems.get(target.parentId);\n\n if (!targetItem) {\n throw new Error(`Parent item with id '${target.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Parent item '${target.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n parentGroup = targetItem;\n }\n\n if (parentGroup.hasChild(item.id)) {\n throw new Error(`Item ${item.id} already in this group`);\n }\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n parentGroup.items?.includes(sItem.id),\n );\n let counter = 1;\n const originalKey = item.key;\n let uniqueKey = originalKey;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${originalKey}_${counter}`;\n counter++;\n }\n\n // Determine insertion index\n let insertIndex: number;\n if (target?.index !== undefined) {\n // Insert at specified index, or at end if index is larger than array length\n insertIndex = Math.min(target.index, parentGroup.items.length);\n } else {\n // Insert at the end\n insertIndex = parentGroup.items.length;\n }\n\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n\n // Add the item to the survey items collection\n this._survey.surveyItems.set(item.id, item);\n\n // Add the item to the parent group (uses addChild for proper persistence)\n parentGroup.addChild(item.id, insertIndex);\n this.touchItemModifiedMetadata(parentGroup.id, timestamp);\n\n // Update translations in the survey\n if (content) {\n this._survey.translations.setItemTranslations(item.id, content);\n }\n }\n\n // Remove an item from the survey\n removeItem(itemId: string, nested: boolean = false): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n // Find parent group and remove from its items array\n const parentItem = this._survey.getParentItem(itemId);\n if (!parentItem) {\n throw new Error(`Item with id '${itemId}' is the root item`);\n }\n\n if (item instanceof GroupItemCore) {\n for (const childId of item.getChildrenIds()) {\n this.removeItem(childId, true);\n }\n }\n\n // Remove from survey items\n this._survey.surveyItems.delete(itemId);\n\n // Remove translations\n this._survey.translations?.onItemDeleted(itemId);\n\n if (!nested) {\n parentItem.removeChild(itemId);\n this.touchItemModifiedMetadata(parentItem.id, timestamp);\n }\n return true;\n }\n\n // Move an item to a different position\n moveItem(itemId: string, newTarget: Target): boolean {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n // Check if item exists\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n // Check if new target exists and is a group\n const targetItem = this._survey.surveyItems.get(newTarget.parentId);\n if (!targetItem) {\n throw new Error(`Target parent with id '${newTarget.parentId}' not found`);\n }\n\n if (!(targetItem instanceof GroupItemCore)) {\n throw new Error(\n `Target parent '${newTarget.parentId}' is not a group item (${targetItem.type})`,\n );\n }\n\n // Check if new target is not a child of the current item (prevent circular reference)\n if (this._survey.isDescendantOf(newTarget.parentId, itemId)) {\n throw new Error(`Cannot move item '${itemId}' to its descendant '${newTarget.parentId}'`);\n }\n\n // If the item is already in the target parent\n const currentParentItem = this._survey.getParentItem(itemId);\n if (currentParentItem?.id === newTarget.parentId) {\n throw new Error(`Item '${itemId}' is already in the target parent '${newTarget.parentId}'`);\n }\n\n // Remove item from current parent's items array\n if (currentParentItem) {\n const currentParentGroup = currentParentItem as GroupItemCore;\n currentParentGroup.removeChild(itemId);\n this.touchItemModifiedMetadata(currentParentGroup.id, timestamp);\n }\n\n // Add item to new parent's items array\n const targetGroup = targetItem as GroupItemCore;\n\n // ensure that item's key not already used within the group\n const siblings = Array.from(this._survey.surveyItems.values()).filter((sItem) =>\n targetGroup.hasChild(sItem.id),\n );\n let counter = 1;\n let uniqueKey = item.key;\n while (siblings.some((sibling) => sibling.key === uniqueKey)) {\n uniqueKey = `${item.key}_${counter}`;\n counter++;\n }\n if (uniqueKey !== item.key) {\n item.updateRawItem({\n ...item.rawItem,\n key: uniqueKey,\n });\n }\n\n const insertIndex =\n newTarget.index !== undefined\n ? Math.min(newTarget.index, targetGroup.items.length)\n : targetGroup.items.length;\n\n targetGroup.addChild(itemId, insertIndex);\n this.touchItemModifiedMetadata(targetGroup.id, timestamp);\n this.touchItemModifiedMetadata(itemId, timestamp);\n\n return true;\n }\n\n /**\n * Get a deep copy of an item's raw data.\n * The returned object is independent of the survey—mutating it will not affect the survey.\n * Use this when you need to edit an item in a form or pass it to updateItem after modifications.\n *\n * @param itemId - The ID of the item to copy\n * @returns A deep copy of the item's RawSurveyItem data\n * @throws Error if the item is not found\n */\n getItemDataCopy(itemId: string): RawSurveyItem {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n return JSON.parse(JSON.stringify(item.rawItem)) as RawSurveyItem;\n }\n\n /**\n * Update an item's data in the survey.\n * Can update common attributes (displayConditions, disabledConditions, validations, etc.)\n * as well as type-specific config.\n *\n * Use getItemDataCopy to obtain an editable copy, modify it, then pass it here.\n * Alternatively, pass a Partial to merge specific fields (top-level keys only;\n * e.g. config replaces the entire config object).\n *\n * @param itemId - The ID of the item to update (must match data.id if provided)\n * @param rawItemData - Full RawSurveyItem or Partial to merge. The id cannot be changed.\n */\n updateItem(itemId: string, rawItemData: RawSurveyItem | Partial<RawSurveyItem>): void {\n const existingItem = this._survey.surveyItems.get(itemId);\n if (!existingItem) {\n throw new Error(`Item with id '${itemId}' not found`);\n }\n\n if (\"id\" in rawItemData && rawItemData.id !== undefined && rawItemData.id !== itemId) {\n throw new Error(`Cannot change item id from '${itemId}' to '${rawItemData.id}'`);\n }\n\n const currentRaw = existingItem.rawItem;\n const merged: RawSurveyItem = {\n ...currentRaw,\n ...rawItemData,\n id: itemId, // Ensure id is never changed\n };\n\n // Reject key change if it would collide with a sibling\n const newKey = merged.key ?? existingItem.key;\n const parentGroup = this._survey.getParentItem(itemId);\n if (parentGroup) {\n const siblingWithSameKey = (parentGroup.items ?? [])\n .filter((id) => id !== itemId)\n .map((id) => this._survey.surveyItems.get(id))\n .find((s) => s !== undefined && s.key === newKey);\n if (siblingWithSameKey) {\n throw new Error(\n `Key '${newKey}' is already in use by sibling item '${siblingWithSameKey.id}'`,\n );\n }\n }\n\n const newItem = this._survey.createItemFromRaw({\n ...merged,\n editorMetadata: existingItem.rawItem.editorMetadata,\n });\n newItem.setModifiedAt(this.createEditorTimestamp());\n this._survey.surveyItems.set(itemId, newItem);\n this.markAsModified();\n }\n\n // TODO: add also to update component translations (updating part of the item)\n // Update item translations\n updateItemTranslations(itemId: string, updatedContent?: SurveyItemTranslations): boolean {\n const item = this._survey.surveyItems.get(itemId);\n if (!item) {\n return false;\n }\n\n this.markAsModified();\n item.setModifiedAt(this.createEditorTimestamp());\n this._survey.translations.setItemTranslations(itemId, updatedContent);\n\n return true;\n }\n\n /**\n * Update survey-level translations that are not tied to specific items.\n * Use these for survey card, navigation, validation messages, etc.\n */\n updateSurveyTranslations(updates: {\n surveyCard?: { locale: string; content?: SurveyCardContent };\n navigation?: { locale: string; content?: NavigationContent };\n validationMessages?: { locale: string; content?: { invalidResponse?: Content } };\n }): void {\n this.markAsModified();\n if (updates.surveyCard) {\n this._survey.translations.setSurveyCardContent(\n updates.surveyCard.locale,\n updates.surveyCard.content,\n );\n }\n if (updates.navigation) {\n this._survey.translations.setNavigationContent(\n updates.navigation.locale,\n updates.navigation.content,\n );\n }\n if (updates.validationMessages) {\n this._survey.translations.setValidationMessages(\n updates.validationMessages.locale,\n updates.validationMessages.content,\n );\n }\n }\n\n /** Add an empty survey locale so it can be authored before translated content exists. */\n addLocale(locale: string): boolean {\n const added = this._survey.translations.addLocale(locale);\n if (added) {\n this.markAsModified();\n }\n return added;\n }\n\n /** Remove a locale and every survey- and item-level translation stored for it. */\n removeLocale(locale: string): boolean {\n if (!this._survey.locales.includes(locale)) {\n return false;\n }\n\n this._survey.translations.removeLocale(locale);\n this.markAsModified();\n return true;\n }\n\n /**\n * Get maxItemsPerPage immutably (returns a copy).\n */\n getMaxItemsPerPage(): { large: number; small: number } | undefined {\n const val = this._survey.maxItemsPerPage;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update maxItemsPerPage.\n */\n updateMaxItemsPerPage(value: { large: number; small: number } | undefined): void {\n this.markAsModified();\n this._survey.maxItemsPerPage = value ? { ...value } : undefined;\n }\n\n /**\n * Get metadata immutably (returns a copy).\n */\n getMetadata(): { [key: string]: string } | undefined {\n const val = this._survey.metadata;\n return val ? { ...val } : undefined;\n }\n\n /**\n * Update metadata.\n */\n updateMetadata(metadata: { [key: string]: string } | undefined): void {\n this.markAsModified();\n this._survey.metadata = metadata ? { ...metadata } : undefined;\n }\n\n /**\n * Get a template value immutably (returns a deep copy).\n */\n getTemplateValue(key: string): TemplateValueDefinition | undefined {\n const val = this._survey.getTemplateValue(key);\n return val ? structuredCloneMethod(val) : undefined;\n }\n\n /**\n * Get all template values immutably (returns a new Map with deep-copied values).\n */\n getTemplateValues(): Map<string, TemplateValueDefinition> {\n const keys = this._survey.getTemplateValueKeys();\n const result = new Map<string, TemplateValueDefinition>();\n for (const key of keys) {\n const val = this._survey.getTemplateValue(key);\n if (val) {\n result.set(key, structuredCloneMethod(val));\n }\n }\n return result;\n }\n\n /**\n * Add or replace a template value.\n */\n setTemplateValue(key: string, templateValue: TemplateValueDefinition): void {\n this.markAsModified();\n this._survey.setTemplateValue(key, structuredCloneMethod(templateValue));\n }\n\n /**\n * Remove a template value.\n */\n removeTemplateValue(key: string): void {\n this.markAsModified();\n this._survey.deleteTemplateValue(key);\n }\n\n /**\n * Get a survey asset immutably.\n */\n getAsset(assetId: string): RawSurveyAsset | undefined {\n const asset = this._survey.getAsset(assetId);\n return asset ? structuredCloneMethod(asset) : undefined;\n }\n\n /**\n * Get all survey assets immutably.\n */\n getAssets(): Map<string, RawSurveyAsset> {\n return this._survey.getAssets();\n }\n\n /**\n * Add or replace a survey asset.\n */\n setAsset(assetId: string, asset: RawSurveyAsset): void {\n const previousAsset = this._survey.getAsset(assetId);\n this._survey.setAsset(assetId, structuredCloneMethod(asset));\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n next: structuredCloneMethod(asset),\n },\n ],\n {\n label: `Update asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Remove a survey asset.\n */\n removeAsset(assetId: string): void {\n const previousAsset = this._survey.getAsset(assetId);\n if (!previousAsset) {\n return;\n }\n this._survey.deleteAsset(assetId);\n this._undoRedo.commitAssetChange(\n [\n {\n assetId,\n prev: previousAsset,\n },\n ],\n {\n label: `Remove asset: ${assetId}`,\n source: CommitSource.USER,\n },\n );\n }\n\n /**\n * Copy a survey item and all its data to clipboard format\n * @param itemId - The ID of the item to copy\n * @returns Clipboard data that can be serialized to JSON for clipboard\n */\n copyItem(itemId: string): SurveyItemClipboardData {\n const copyPaste = new ItemCopyPaste(this._survey);\n return copyPaste.copyItem(itemId);\n }\n\n /**\n * Paste a survey item from clipboard data to a target location\n * @param clipboardData - The clipboard data containing the item to paste\n * @param target - Target location where to paste the item\n * @returns The ID of the pasted item\n */\n pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string {\n this.markAsModified();\n const timestamp = this.createEditorTimestamp();\n const itemIdsBeforePaste = new Set(this._survey.surveyItems.keys());\n const copyPaste = new ItemCopyPaste(this._survey);\n const newItemId = copyPaste.pasteItem(clipboardData, target);\n const pastedItemIds = Array.from(this._survey.surveyItems.keys()).filter(\n (itemId) => !itemIdsBeforePaste.has(itemId),\n );\n\n for (const itemId of pastedItemIds) {\n const item = this._survey.surveyItems.get(itemId);\n if (item) {\n item.setCreatedAt(timestamp);\n item.setModifiedAt(timestamp);\n }\n }\n this.touchItemModifiedMetadata(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CACF,EACD;GACE,OAAO,iBAAiB;GACxB,QAAQ,aAAa;GACtB,CACF;;;;;;;CAQH,SAAS,QAAyC;AAEhD,SAAO,IADe,cAAc,KAAK,QACzB,CAAC,SAAS,OAAO;;;;;;;;CASnC,UAAU,eAAwC,QAAwB;AACxE,OAAK,gBAAgB;EACrB,MAAM,YAAY,KAAK,uBAAuB;EAC9C,MAAM,qBAAqB,IAAI,IAAI,KAAK,QAAQ,YAAY,MAAM,CAAC;EAEnE,MAAM,YAAY,IADI,cAAc,KAAK,QACd,CAAC,UAAU,eAAe,OAAO;EAC5D,MAAM,gBAAgB,MAAM,KAAK,KAAK,QAAQ,YAAY,MAAM,CAAC,CAAC,QAC/D,WAAW,CAAC,mBAAmB,IAAI,OAAO,CAC5C;AAED,OAAK,MAAM,UAAU,eAAe;GAClC,MAAM,OAAO,KAAK,QAAQ,YAAY,IAAI,OAAO;AACjD,OAAI,MAAM;AACR,SAAK,aAAa,UAAU;AAC5B,SAAK,cAAc,UAAU;;;AAGjC,OAAK,0BAA0B,OAAO,UAAU,UAAU;AAE1D,SAAO"}
|
package/build/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $ as RichTextLinkInline, $t as ExpressionEditorConfig, A as SurveyTranslations, An as ValueType, At as SurveyItemPrefillSource, B as RichTextBulletListBlock, Bt as ItemExpressionParameterInput, C as SurveyVersion, Cn as ReferenceArrayResponse, Ct as serializeTemplateValues, D as SurveyCardContent, Dn as StringArrayResponse, Dt as JsonSurveyItemPrefillTarget, E as NavigationContent, En as SlotResponseBase, Et as JsonSurveyItemPrefillSource, F as ContentType, Ft as prefillTargetsEqual, G as RichTextImageDimension, Gt as SurveyItemCore, H as RichTextDocument, Ht as buildItemExpression, I as MDContent, It as serializeSurveyItemPrefill, J as RichTextInline, Jt as RawSurveyItem, K as RichTextImageSize, Kt as SurveyItemCoreType, L as PlainTextContent, Lt as AnyItemExpressionDefinition, M as Content, Mn as isResponseValue, Mt as SurveyItemPrefillTargetType, N as ContentAssetUsage, Nt as SurveyItemPreviousResponseRef, O as SurveyCardTranslations, On as StringResponse, Ot as SurveyItemPrefill, P as ContentAttributes, Pt as deserializeSurveyItemPrefill, Q as RichTextLinkChildInline, Qt as Expression, R as RichTextBlockExtension, Rt as ItemExpressionDefinition, S as RawSurveyAsset, Sn as NumberResponse, St as serializeTemplateValue, T as JsonSurveyTranslations, Tn as ResponseValue, Tt as JsonSurveyItemPrefill, U as RichTextHeadingBlock, Ut as getItemExpressionDefinition, V as RichTextContent, Vt as ItemExpressionParameterOption, W as RichTextImageBlock, Wt as ItemCoreConstructor, X as RichTextInlineNode, Xt as ContextVariableExpression, Y as RichTextInlineExtension, Yt as ConstExpression, Z as RichTextLineBreakInline, Zt as ContextVariableType, _ as createItemTypeDefinitionRegistry, _n as DurationResponse, _t as TemplateValueBase, a as GroupItemCore, an as JsonExpression, at as RichTextTextInline, b as CURRENT_SURVEY_SCHEMA, bn as NumberArrayResponse, bt as deserializeTemplateValue, c as builtInItemCoreRegistry, cn as ResponseVariableExpression, ct as createRichTextContent, d as ItemTypeDefinition, dn as ValueReference, dt as getPlainTextFromRichTextContent, en as ExpressionType, et as RichTextListItemBlock, f as ItemTypeDefinitionRegistry, fn as ValueReferenceMethod, ft as hasRenderableRichTextBlock, g as createItemCore, gn as DurationArrayResponse, gt as TemplateDefTypes, h as createFullRegistry, hn as DateResponse, ht as JsonTemplateValue, i as GroupConfig, in as JsonContextVariableExpression, it as RichTextTemplateInline, j as validateLocale, jn as assertResponseValue, jt as SurveyItemPrefillTarget, k as SurveyItemTranslations, kn as ValueRefTypeLookup, kt as SurveyItemPrefillApplyMode, l as isBuiltInItemType, ln as ReferenceUsage, lt as getAssetUsagesFromContent, m as ItemTypeRegistry, mn as DateArrayResponse, mt as isContentEmpty, n as SurveyAssetUsage, nn as FunctionExpressionNames, nt as RichTextSeparatorBlock, o as PageBreakConfig, on as JsonFunctionExpression, ot as SurveyContentImageSource, p as ItemTypeName, pn as BooleanResponse, pt as hasRenderableRichTextContent, q as RichTextInfoBoxBlock, qt as ReservedSurveyItemTypes, r as BuiltInItemType, rn as JsonConstExpression, rt as RichTextStyle, s as PageBreakItemCore, sn as JsonResponseVariableExpression, st as TextAlignment, t as Survey, tn as FunctionExpression, tt as RichTextParagraphBlock, u as ItemTypeCapabilities, un as ReferenceUsageType, ut as getContentPlainText, v as toItemTypeDefinitionRegistry, vn as DurationUnit, vt as TemplateValueDefinition, w as JsonComponentContent, wn as ReferenceResponse, wt as ResponseSlotDefinition, x as RawSurvey, xn as NumberPrecision, xt as deserializeTemplateValues, y as SurveyItemKey, yn as DurationUnits, yt as TemplateValueFormatDate, z as RichTextBlockNode, zt as ItemExpressionParameterDefinition } from "./survey-
|
|
1
|
+
import { $ as RichTextLinkInline, $t as ExpressionEditorConfig, A as SurveyTranslations, An as ValueType, At as SurveyItemPrefillSource, B as RichTextBulletListBlock, Bt as ItemExpressionParameterInput, C as SurveyVersion, Cn as ReferenceArrayResponse, Ct as serializeTemplateValues, D as SurveyCardContent, Dn as StringArrayResponse, Dt as JsonSurveyItemPrefillTarget, E as NavigationContent, En as SlotResponseBase, Et as JsonSurveyItemPrefillSource, F as ContentType, Ft as prefillTargetsEqual, G as RichTextImageDimension, Gt as SurveyItemCore, H as RichTextDocument, Ht as buildItemExpression, I as MDContent, It as serializeSurveyItemPrefill, J as RichTextInline, Jt as RawSurveyItem, K as RichTextImageSize, Kt as SurveyItemCoreType, L as PlainTextContent, Lt as AnyItemExpressionDefinition, M as Content, Mn as isResponseValue, Mt as SurveyItemPrefillTargetType, N as ContentAssetUsage, Nt as SurveyItemPreviousResponseRef, O as SurveyCardTranslations, On as StringResponse, Ot as SurveyItemPrefill, P as ContentAttributes, Pt as deserializeSurveyItemPrefill, Q as RichTextLinkChildInline, Qt as Expression, R as RichTextBlockExtension, Rt as ItemExpressionDefinition, S as RawSurveyAsset, Sn as NumberResponse, St as serializeTemplateValue, T as JsonSurveyTranslations, Tn as ResponseValue, Tt as JsonSurveyItemPrefill, U as RichTextHeadingBlock, Ut as getItemExpressionDefinition, V as RichTextContent, Vt as ItemExpressionParameterOption, W as RichTextImageBlock, Wt as ItemCoreConstructor, X as RichTextInlineNode, Xt as ContextVariableExpression, Y as RichTextInlineExtension, Yt as ConstExpression, Z as RichTextLineBreakInline, Zt as ContextVariableType, _ as createItemTypeDefinitionRegistry, _n as DurationResponse, _t as TemplateValueBase, a as GroupItemCore, an as JsonExpression, at as RichTextTextInline, b as CURRENT_SURVEY_SCHEMA, bn as NumberArrayResponse, bt as deserializeTemplateValue, c as builtInItemCoreRegistry, cn as ResponseVariableExpression, ct as createRichTextContent, d as ItemTypeDefinition, dn as ValueReference, dt as getPlainTextFromRichTextContent, en as ExpressionType, et as RichTextListItemBlock, f as ItemTypeDefinitionRegistry, fn as ValueReferenceMethod, ft as hasRenderableRichTextBlock, g as createItemCore, gn as DurationArrayResponse, gt as TemplateDefTypes, h as createFullRegistry, hn as DateResponse, ht as JsonTemplateValue, i as GroupConfig, in as JsonContextVariableExpression, it as RichTextTemplateInline, j as validateLocale, jn as assertResponseValue, jt as SurveyItemPrefillTarget, k as SurveyItemTranslations, kn as ValueRefTypeLookup, kt as SurveyItemPrefillApplyMode, l as isBuiltInItemType, ln as ReferenceUsage, lt as getAssetUsagesFromContent, m as ItemTypeRegistry, mn as DateArrayResponse, mt as isContentEmpty, n as SurveyAssetUsage, nn as FunctionExpressionNames, nt as RichTextSeparatorBlock, o as PageBreakConfig, on as JsonFunctionExpression, ot as SurveyContentImageSource, p as ItemTypeName, pn as BooleanResponse, pt as hasRenderableRichTextContent, q as RichTextInfoBoxBlock, qt as ReservedSurveyItemTypes, r as BuiltInItemType, rn as JsonConstExpression, rt as RichTextStyle, s as PageBreakItemCore, sn as JsonResponseVariableExpression, st as TextAlignment, t as Survey, tn as FunctionExpression, tt as RichTextParagraphBlock, u as ItemTypeCapabilities, un as ReferenceUsageType, ut as getContentPlainText, v as toItemTypeDefinitionRegistry, vn as DurationUnit, vt as TemplateValueDefinition, w as JsonComponentContent, wn as ReferenceResponse, wt as ResponseSlotDefinition, x as RawSurvey, xn as NumberPrecision, xt as deserializeTemplateValues, y as SurveyItemKey, yn as DurationUnits, yt as TemplateValueFormatDate, z as RichTextBlockNode, zt as ItemExpressionParameterDefinition } from "./survey-CwWxsuRb.mjs";
|
|
2
|
+
import { SURVEY_EDITOR_ITEM_COLORS } from "./editor/colors.mjs";
|
|
2
3
|
import { Locale } from "date-fns";
|
|
3
4
|
|
|
4
5
|
//#region src/survey/responses/response-meta.d.ts
|
|
@@ -836,5 +837,5 @@ declare function generateCodebook(survey: Survey, options?: {
|
|
|
836
837
|
locales?: string[];
|
|
837
838
|
}): Codebook;
|
|
838
839
|
//#endregion
|
|
839
|
-
export { AndExpressionEditor, AnyItemExpressionDefinition, BooleanResponse, BuiltInItemType, CURRENT_SURVEY_SCHEMA, Codebook, CodebookItem, CodebookSlot, ConstBooleanEditor, ConstDateArrayEditor, ConstDateEditor, ConstExpression, ConstNumberArrayEditor, ConstNumberEditor, ConstStringArrayEditor, ConstStringEditor, Content, ContentAssetUsage, ContentAttributes, ContentType, ContextVariableExpression, ContextVariableType, CsvExportOptions, CtxCustomExpressionEditor, CtxCustomValueEditor, CtxLocaleEditor, CtxPFlagDateEditor, CtxPFlagIsDefinedEditor, CtxPFlagNumEditor, CtxPFlagStringEditor, DEFAULT_TRANSFORM, DateArrayResponse, DateFormatConfig, DateResponse, DurationArrayResponse, DurationResponse, DurationUnit, DurationUnits, EXPORT_COLUMN_SLOT_SEPARATOR, EqExpressionEditor, ExportColumn, ExportColumnSource, ExportRow, ExportSingleSlotParams, ExporterProfile, Expression, ExpressionContext, ExpressionEditor, ExpressionEditorConfig, ExpressionEvaluator, ExpressionType, FunctionExpression, FunctionExpressionNames, GroupConfig, GroupItemCore, GtExpressionEditor, GteExpressionEditor, InRangeExpressionEditor, ItemCoreConstructor, ItemExpressionDefinition, ItemExpressionParameterDefinition, ItemExpressionParameterInput, ItemExpressionParameterOption, ItemResponseMeta, ItemTypeCapabilities, ItemTypeDefinition, ItemTypeDefinitionRegistry, ItemTypeName, ItemTypeRegistry, JsonComponentContent, JsonConstExpression, JsonContextVariableExpression, JsonExpression, JsonFunctionExpression, JsonObject, JsonPatchError, JsonPatchOperation, JsonPrimitive, JsonResponseItem, JsonResponseVariableExpression, JsonSurveyItemPrefill, JsonSurveyItemPrefillSource, JsonSurveyItemPrefillTarget, JsonSurveyItemResponse, JsonSurveyResponse, JsonSurveyTranslations, JsonTemplateValue, JsonValue, LanguageChangedEvent, LegacyComponentProperties, LegacyConfidentialMode, LegacyItemComponent, LegacyItemGroupComponent, LegacyLocalizedObject, LegacyLocalizedObjectBase, LegacyLocalizedString, LegacyResponseComponent, LegacySurvey, LegacySurveyGroupItem, LegacySurveyItem, LegacySurveyItemTypes, LegacySurveyProps, LegacySurveySingleItem, LegacyValidation, LtExpressionEditor, LteExpressionEditor, MDContent, META_COLUMN_ORDER, MaxExpressionEditor, MetaColumnKey, MinExpressionEditor, NavigationContent, NumberArrayResponse, NumberPrecision, NumberResponse, OpenSurveyEvent, OrExpressionEditor, PageBreakConfig, PageBreakItemCore, PageChangedEvent, PlainTextContent, RawSurvey, RawSurveyAsset, RawSurveyItem, ReferenceArrayResponse, ReferenceResponse, ReferenceUsage, ReferenceUsageType, RenderedSurveyItem, ReservedSurveyItemTypes, ResponseChangedEvent, ResponseItem, ResponseSlotDefinition, ResponseValue, ResponseVariableEditor, ResponseVariableExpression, RichTextBlockExtension, RichTextBlockNode, RichTextBulletListBlock, RichTextContent, RichTextDocument, RichTextHeadingBlock, RichTextImageBlock, RichTextImageDimension, RichTextImageSize, RichTextInfoBoxBlock, RichTextInline, RichTextInlineExtension, RichTextInlineNode, RichTextLineBreakInline, RichTextLinkChildInline, RichTextLinkInline, RichTextListItemBlock, RichTextParagraphBlock, RichTextSeparatorBlock, RichTextStyle, RichTextTemplateInline, RichTextTextInline, SURVEY_RESPONSE_SCHEMA_VERSION, ScreenSize, SlotRef, SlotResponseBase, SlotTransformConfig, SlotTransformMode, StrEqExpressionEditor, StrListContainsExpressionEditor, StringArrayResponse, StringResponse, SumExpressionEditor, Survey, SurveyAssetUsage, SurveyCardContent, SurveyCardTranslations, SurveyContentImageSource, SurveyEngineCore, SurveyEngineOptions, SurveyEnginePrefillEnvironment, SurveyEvent, SurveyEventBase, SurveyEventTypes, SurveyItemCore, SurveyItemCoreType, SurveyItemKey, SurveyItemPrefill, SurveyItemPrefillApplyMode, SurveyItemPrefillSource, SurveyItemPrefillTarget, SurveyItemPrefillTargetType, SurveyItemPreviousResponseRef, SurveyItemResponse, SurveyItemTranslations, SurveyResponse, SurveyResponseContext, SurveyResponseExporter, SurveyTranslations, SurveyVersion, SurveyVersionBinding, TemplateDefTypes, TemplateValueBase, TemplateValueDefinition, TemplateValueFormatDate, TextAlignment, ValueRefTypeLookup, ValueReference, ValueReferenceMethod, ValueType, and, applyJsonPatch, assertResponseValue, buildItemExpression, builtInItemCoreRegistry, const_boolean, const_date, const_date_array, const_number, const_number_array, const_string, const_string_array, createFullRegistry, createItemCore, createItemTypeDefinitionRegistry, createRichTextContent, createSeededRandom, ctx_custom_expression, ctx_custom_value, ctx_locale, ctx_pflag_date, ctx_pflag_is_defined, ctx_pflag_num, ctx_pflag_string, decodeJsonPointerSegment, deserializeSurveyItemPrefill, deserializeTemplateValue, deserializeTemplateValues, encodeJsonPointerSegment, eq, escapeCsvCell, exportSingleResponseSlot, flattenTree, generateCodebook, generateCodingKey, generateId, getAssetUsagesFromContent, getContentPlainText, getItemExpressionDefinition, getPlainTextFromRichTextContent, getValueAtJsonPointer, gt, gte, hasRenderableRichTextBlock, hasRenderableRichTextContent, in_range, initValueForType, isBuiltInItemType, isContentEmpty, isLegacyItemGroupComponent, isLegacySurveyGroupItem, isResponseValue, lt, lte, max, min, or, parseJsonPointer, prefillTargetsEqual, response_boolean, response_date, response_date_array, response_number, response_number_array, response_string, response_string_array, serializeSurveyItemPrefill, serializeTemplateValue, serializeTemplateValues, serializeToCsv, shuffleArray, shuffleIndices, str_eq, str_list_contains, structuredCloneMethod, sum, toItemTypeDefinitionRegistry, validateLocale };
|
|
840
|
+
export { AndExpressionEditor, AnyItemExpressionDefinition, BooleanResponse, BuiltInItemType, CURRENT_SURVEY_SCHEMA, Codebook, CodebookItem, CodebookSlot, ConstBooleanEditor, ConstDateArrayEditor, ConstDateEditor, ConstExpression, ConstNumberArrayEditor, ConstNumberEditor, ConstStringArrayEditor, ConstStringEditor, Content, ContentAssetUsage, ContentAttributes, ContentType, ContextVariableExpression, ContextVariableType, CsvExportOptions, CtxCustomExpressionEditor, CtxCustomValueEditor, CtxLocaleEditor, CtxPFlagDateEditor, CtxPFlagIsDefinedEditor, CtxPFlagNumEditor, CtxPFlagStringEditor, DEFAULT_TRANSFORM, DateArrayResponse, DateFormatConfig, DateResponse, DurationArrayResponse, DurationResponse, DurationUnit, DurationUnits, EXPORT_COLUMN_SLOT_SEPARATOR, EqExpressionEditor, ExportColumn, ExportColumnSource, ExportRow, ExportSingleSlotParams, ExporterProfile, Expression, ExpressionContext, ExpressionEditor, ExpressionEditorConfig, ExpressionEvaluator, ExpressionType, FunctionExpression, FunctionExpressionNames, GroupConfig, GroupItemCore, GtExpressionEditor, GteExpressionEditor, InRangeExpressionEditor, ItemCoreConstructor, ItemExpressionDefinition, ItemExpressionParameterDefinition, ItemExpressionParameterInput, ItemExpressionParameterOption, ItemResponseMeta, ItemTypeCapabilities, ItemTypeDefinition, ItemTypeDefinitionRegistry, ItemTypeName, ItemTypeRegistry, JsonComponentContent, JsonConstExpression, JsonContextVariableExpression, JsonExpression, JsonFunctionExpression, JsonObject, JsonPatchError, JsonPatchOperation, JsonPrimitive, JsonResponseItem, JsonResponseVariableExpression, JsonSurveyItemPrefill, JsonSurveyItemPrefillSource, JsonSurveyItemPrefillTarget, JsonSurveyItemResponse, JsonSurveyResponse, JsonSurveyTranslations, JsonTemplateValue, JsonValue, LanguageChangedEvent, LegacyComponentProperties, LegacyConfidentialMode, LegacyItemComponent, LegacyItemGroupComponent, LegacyLocalizedObject, LegacyLocalizedObjectBase, LegacyLocalizedString, LegacyResponseComponent, LegacySurvey, LegacySurveyGroupItem, LegacySurveyItem, LegacySurveyItemTypes, LegacySurveyProps, LegacySurveySingleItem, LegacyValidation, LtExpressionEditor, LteExpressionEditor, MDContent, META_COLUMN_ORDER, MaxExpressionEditor, MetaColumnKey, MinExpressionEditor, NavigationContent, NumberArrayResponse, NumberPrecision, NumberResponse, OpenSurveyEvent, OrExpressionEditor, PageBreakConfig, PageBreakItemCore, PageChangedEvent, PlainTextContent, RawSurvey, RawSurveyAsset, RawSurveyItem, ReferenceArrayResponse, ReferenceResponse, ReferenceUsage, ReferenceUsageType, RenderedSurveyItem, ReservedSurveyItemTypes, ResponseChangedEvent, ResponseItem, ResponseSlotDefinition, ResponseValue, ResponseVariableEditor, ResponseVariableExpression, RichTextBlockExtension, RichTextBlockNode, RichTextBulletListBlock, RichTextContent, RichTextDocument, RichTextHeadingBlock, RichTextImageBlock, RichTextImageDimension, RichTextImageSize, RichTextInfoBoxBlock, RichTextInline, RichTextInlineExtension, RichTextInlineNode, RichTextLineBreakInline, RichTextLinkChildInline, RichTextLinkInline, RichTextListItemBlock, RichTextParagraphBlock, RichTextSeparatorBlock, RichTextStyle, RichTextTemplateInline, RichTextTextInline, SURVEY_EDITOR_ITEM_COLORS, SURVEY_RESPONSE_SCHEMA_VERSION, ScreenSize, SlotRef, SlotResponseBase, SlotTransformConfig, SlotTransformMode, StrEqExpressionEditor, StrListContainsExpressionEditor, StringArrayResponse, StringResponse, SumExpressionEditor, Survey, SurveyAssetUsage, SurveyCardContent, SurveyCardTranslations, SurveyContentImageSource, SurveyEngineCore, SurveyEngineOptions, SurveyEnginePrefillEnvironment, SurveyEvent, SurveyEventBase, SurveyEventTypes, SurveyItemCore, SurveyItemCoreType, SurveyItemKey, SurveyItemPrefill, SurveyItemPrefillApplyMode, SurveyItemPrefillSource, SurveyItemPrefillTarget, SurveyItemPrefillTargetType, SurveyItemPreviousResponseRef, SurveyItemResponse, SurveyItemTranslations, SurveyResponse, SurveyResponseContext, SurveyResponseExporter, SurveyTranslations, SurveyVersion, SurveyVersionBinding, TemplateDefTypes, TemplateValueBase, TemplateValueDefinition, TemplateValueFormatDate, TextAlignment, ValueRefTypeLookup, ValueReference, ValueReferenceMethod, ValueType, and, applyJsonPatch, assertResponseValue, buildItemExpression, builtInItemCoreRegistry, const_boolean, const_date, const_date_array, const_number, const_number_array, const_string, const_string_array, createFullRegistry, createItemCore, createItemTypeDefinitionRegistry, createRichTextContent, createSeededRandom, ctx_custom_expression, ctx_custom_value, ctx_locale, ctx_pflag_date, ctx_pflag_is_defined, ctx_pflag_num, ctx_pflag_string, decodeJsonPointerSegment, deserializeSurveyItemPrefill, deserializeTemplateValue, deserializeTemplateValues, encodeJsonPointerSegment, eq, escapeCsvCell, exportSingleResponseSlot, flattenTree, generateCodebook, generateCodingKey, generateId, getAssetUsagesFromContent, getContentPlainText, getItemExpressionDefinition, getPlainTextFromRichTextContent, getValueAtJsonPointer, gt, gte, hasRenderableRichTextBlock, hasRenderableRichTextContent, in_range, initValueForType, isBuiltInItemType, isContentEmpty, isLegacyItemGroupComponent, isLegacySurveyGroupItem, isResponseValue, lt, lte, max, min, or, parseJsonPointer, prefillTargetsEqual, response_boolean, response_date, response_date_array, response_number, response_number_array, response_string, response_string_array, serializeSurveyItemPrefill, serializeTemplateValue, serializeTemplateValues, serializeToCsv, shuffleArray, shuffleIndices, str_eq, str_list_contains, structuredCloneMethod, sum, toItemTypeDefinitionRegistry, validateLocale };
|
|
840
841
|
//# sourceMappingURL=index.d.mts.map
|