// Divi dependencies.
import { ModuleEditProps } from '@divi/module-library';
import {
	type FormatBreakpointStateAttr,
	InternalAttrs,
	type Element,
} from '@divi/types';

import type {
	AttrVal,
	BorderValue,
	TypographyValue,
} from '../custom-types';

type BaseDecoration = Element.Decoration.PickedAttributes<
	| 'animation'
	| 'background'
	| 'border'
	| 'boxShadow'
	| 'disabledOn'
	| 'filters'
	| 'overflow'
	| 'position'
	| 'scroll'
	| 'sizing'
	| 'spacing'
	| 'sticky'
	| 'transform'
	| 'transition'
	| 'zIndex'
>;

type DecorationExtras = {
	imageAlignment?: FormatBreakpointStateAttr<AttrVal>;
	imageWidth?: FormatBreakpointStateAttr<AttrVal>;
	imageMaxWidth?: FormatBreakpointStateAttr<AttrVal>;
	imageHeight?: FormatBreakpointStateAttr<AttrVal>;
	imageObjectFit?: FormatBreakpointStateAttr<AttrVal>;
	imageBorder?: FormatBreakpointStateAttr<BorderValue>;
	captionColor?: FormatBreakpointStateAttr<AttrVal>;
	captionTypography?: FormatBreakpointStateAttr<TypographyValue>;
	captionMaxWidth?: FormatBreakpointStateAttr<AttrVal>;
	captionAlignment?: FormatBreakpointStateAttr<AttrVal>;
	captionTextAlignment?: FormatBreakpointStateAttr<AttrVal>;
};

export interface DynamicImageAttrs extends InternalAttrs {
	module?: {
		meta?: Element.Meta.Attributes;
		advanced?: {
			link?: Element.Advanced.Link.Attributes;
			htmlAttributes?: Element.Advanced.IdClasses.Attributes;
			text?: Element.Advanced.Text.Attributes;
		};
		decoration?: BaseDecoration & DecorationExtras;
	};

	[key: string]: any;
}

export type DynamicImageEditProps = ModuleEditProps<DynamicImageAttrs>;
