{"version":3,"file":"index.js","sources":["../../../../src/packages/core/property/components/unsupported-property/utils.ts","../../../../src/packages/core/property/controllers/property-value-clone.controller.ts"],"sourcesContent":["import type { UmbUnsupportedEditorSchemaAliases } from '../../types/index.js';\r\n\r\nexport const UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES: UmbUnsupportedEditorSchemaAliases = {\r\n\tblock: ['Umbraco.ImageCropper', 'Umbraco.UploadField'],\r\n};\r\n","import type { UmbPropertyValueDataPotentiallyWithEditorAlias } from '../index.js';\r\nimport { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';\r\nimport { createExtensionApi } from '@umbraco-cms/backoffice/extension-api';\r\nimport { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';\r\n\r\nexport class UmbPropertyValueCloneController extends UmbControllerBase {\r\n\t/**\r\n\t * Clones the property data.\r\n\t * @param {UmbPropertyValueDataPotentiallyWithEditorAlias} property - The property data.\r\n\t * @returns {Promise} - A promise that resolves to the cloned property data.\r\n\t */\r\n\tasync clone(\r\n\t\tproperty: UmbPropertyValueDataPotentiallyWithEditorAlias,\r\n\t): Promise> {\r\n\t\tconst result = await this.#cloneProperty(property);\r\n\r\n\t\tthis.destroy();\r\n\r\n\t\treturn result ?? property;\r\n\t}\r\n\r\n\tasync #cloneProperty(\r\n\t\tproperty: UmbPropertyValueDataPotentiallyWithEditorAlias,\r\n\t): Promise> {\r\n\t\tconst clonedProperty = await this.#cloneValue(property);\r\n\t\treturn await this.#cloneInnerValues(clonedProperty);\r\n\t}\r\n\r\n\tasync #cloneValue(\r\n\t\tincomingProperty: UmbPropertyValueDataPotentiallyWithEditorAlias,\r\n\t): Promise> {\r\n\t\tconst editorAlias = (incomingProperty as any).editorAlias as string | undefined;\r\n\t\tif (!editorAlias) {\r\n\t\t\tconsole.error(`Editor alias not found for ${incomingProperty.alias}`);\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\t// Find the cloner for this editor alias:\r\n\t\tconst manifest = umbExtensionsRegistry.getByTypeAndFilter(\r\n\t\t\t'propertyValueCloner',\r\n\t\t\t(x) => x.forEditorAlias === editorAlias,\r\n\t\t)[0];\r\n\r\n\t\tif (!manifest) {\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\tconst api = await createExtensionApi(this, manifest);\r\n\t\tif (!api) {\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\tlet clonedProperty = incomingProperty;\r\n\r\n\t\tif (api.cloneValue) {\r\n\t\t\tconst clonedValue = await api.cloneValue(incomingProperty.value);\r\n\t\t\tif (clonedValue) {\r\n\t\t\t\tclonedProperty = { ...incomingProperty, value: clonedValue };\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn clonedProperty;\r\n\t}\r\n\r\n\tasync #cloneInnerValues(\r\n\t\tincomingProperty: UmbPropertyValueDataPotentiallyWithEditorAlias,\r\n\t): Promise> {\r\n\t\tconst editorAlias = (incomingProperty as any).editorAlias as string | undefined;\r\n\t\tif (!editorAlias) {\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\t// Find the resolver for this editor alias:\r\n\t\tconst manifest = umbExtensionsRegistry.getByTypeAndFilter(\r\n\t\t\t'propertyValueResolver',\r\n\t\t\t// TODO: Remove depcrated filter option in v.17 [NL]\r\n\t\t\t(x) => x.forEditorAlias === editorAlias || x.meta?.editorAlias === editorAlias,\r\n\t\t)[0];\r\n\r\n\t\tif (!manifest) {\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\tconst api = await createExtensionApi(this, manifest);\r\n\t\tif (!api) {\r\n\t\t\treturn incomingProperty;\r\n\t\t}\r\n\r\n\t\tif (api.processValues) {\r\n\t\t\treturn (\r\n\t\t\t\t(await api.processValues(incomingProperty, async (properties) => {\r\n\t\t\t\t\t// Transform the values:\r\n\t\t\t\t\tconst clonedValues = await Promise.all(\r\n\t\t\t\t\t\tproperties.map(async (value) => {\r\n\t\t\t\t\t\t\treturn (await this.#cloneProperty(value)) ?? value;\r\n\t\t\t\t\t\t}),\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\treturn clonedValues;\r\n\t\t\t\t})) ?? incomingProperty\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t// the api did not provide a value processor, so we will return the incoming property:\r\n\t\treturn incomingProperty;\r\n\t}\r\n}\r\n"],"names":["UMB_UNSUPPORTED_EDITOR_SCHEMA_ALIASES","UmbPropertyValueCloneController","UmbControllerBase","property","result","#cloneProperty","clonedProperty","#cloneValue","#cloneInnerValues","incomingProperty","editorAlias","manifest","umbExtensionsRegistry","x","api","createExtensionApi","clonedValue","properties","value"],"mappings":";;;;;AAEO,MAAMA,IAA2E;AAAA,EACvF,OAAO,CAAC,wBAAwB,qBAAqB;AACtD;ACCO,MAAMC,UAAwCC,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtE,MAAM,MACLC,GACqE;AACrE,UAAMC,IAAS,MAAM,KAAKC,GAA0BF,CAAQ;AAE5D,gBAAK,QAAQ,GAENC,KAAUD;AAAA,EAAA;AAAA,EAGlB,MAAME,GACLF,GACqE;AACrE,UAAMG,IAAiB,MAAM,KAAKC,GAAYJ,CAAQ;AAC/C,WAAA,MAAM,KAAKK,GAA6BF,CAAc;AAAA,EAAA;AAAA,EAG9D,MAAMC,GACLE,GACqE;AACrE,UAAMC,IAAeD,EAAyB;AAC9C,QAAI,CAACC;AACJ,qBAAQ,MAAM,8BAA8BD,EAAiB,KAAK,EAAE,GAC7DA;AAIR,UAAME,IAAWC,EAAsB;AAAA,MACtC;AAAA,MACA,CAACC,MAAMA,EAAE,mBAAmBH;AAAA,MAC3B,CAAC;AAEH,QAAI,CAACC;AACG,aAAAF;AAGR,UAAMK,IAAM,MAAMC,EAAmB,MAAMJ,CAAQ;AACnD,QAAI,CAACG;AACG,aAAAL;AAGR,QAAIH,IAAiBG;AAErB,QAAIK,EAAI,YAAY;AACnB,YAAME,IAAc,MAAMF,EAAI,WAAWL,EAA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