import { UMB_BLOCK_LIST_PROPERTY_EDITOR_SCHEMA_ALIAS } from '../../../property-editors/block-list-editor/constants.js';
import { UmbControllerBase } from '../../../../../../libs/class-api/index.js';
export class UmbBlockToBlockListClipboardPastePropertyValueTranslator extends UmbControllerBase {
    /**
     * Translates a block clipboard entry value to a block list property value.
     * @param {UmbBlockClipboardEntryValueModel} value - The block clipboard entry value.
     * @returns {Promise<UmbBlockListValueModel>} - The block list property value.
     * @memberof UmbBlockToBlockListClipboardPastePropertyValueTranslator
     */
    async translate(value) {
        if (!value) {
            throw new Error('Value is missing.');
        }
        const valueClone = structuredClone(value);
        const blockListPropertyValue = {
            contentData: valueClone.contentData,
            settingsData: valueClone.settingsData,
            expose: [],
            layout: {
                [UMB_BLOCK_LIST_PROPERTY_EDITOR_SCHEMA_ALIAS]: valueClone.layout ?? undefined,
            },
        };
        return blockListPropertyValue;
    }
    /**
     * Checks if the clipboard entry value is compatible with the config.
     * @param {UmbBlockListValueModel} propertyValue - The property value
     * @param {*} config - The Property Editor config.
     * @returns {Promise<boolean>} - Whether the clipboard entry value is compatible with the config.
     * @memberof UmbBlockToBlockListClipboardPastePropertyValueTranslator
     */
    async isCompatibleValue(propertyValue, 
    // TODO: Replace any with the correct type.
    config) {
        const allowedBlockContentTypes = config.find((c) => c.alias === 'blocks')?.value.map((b) => b.contentElementTypeKey) ?? [];
        const blockContentTypes = propertyValue.contentData.map((c) => c.contentTypeKey);
        return blockContentTypes?.every((b) => allowedBlockContentTypes.includes(b)) ?? false;
    }
}
export { UmbBlockToBlockListClipboardPastePropertyValueTranslator as api };
