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

import type {
	AttrVal,
	BorderValue,
	SpacingValue,
	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 = {
	fieldColor?: FormatBreakpointStateAttr<AttrVal>;
	fieldTypography?: FormatBreakpointStateAttr<TypographyValue>;
	fieldWidth?: FormatBreakpointStateAttr<AttrVal>;
	fieldAlignment?: FormatBreakpointStateAttr<AttrVal>;
	contentAlignment?: FormatBreakpointStateAttr<AttrVal>;
	fieldBg?: FormatBreakpointStateAttr<AttrVal>;
	fieldSpacing?: FormatBreakpointStateAttr<SpacingValue>;
	fieldBorder?: FormatBreakpointStateAttr<BorderValue>;
	iconColor?: FormatBreakpointStateAttr<AttrVal>;
	iconSize?: FormatBreakpointStateAttr<AttrVal>;
	iconGap?: FormatBreakpointStateAttr<AttrVal>;
	iconVerticalGap?: FormatBreakpointStateAttr<AttrVal>;
};

export interface DynamicFieldAttrs 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 DynamicFieldEditProps = ModuleEditProps<DynamicFieldAttrs>;
