/**
 * WordPress Dependencies
 */
import { applyFilters } from '@wordpress/hooks';

// All supported properties of the PersonalizeWP attribute(s).
export const personalizeWPAttributes = {
	blockID: {
		type: 'string',
	},
	rules: {
		type: 'array',
		items: {
			type: 'integer',
		},
	},
	segments: {
		type: 'array',
		items: {
			type: 'integer',
		},
		default: [],
	},
	minScore: {
		type: 'string',
		default: '',
	},
	maxScore: {
		type: 'string',
		default: '',
	},
	profileFields: {
		type: 'array',
		items: {
			type: 'array',
			properties: {
				field: {
					type: 'string'
				},
				operator: {
					type: 'string',
				},
				value: {
					type: [
						'string',
						'integer',
						'array',
					],
				}
			}
		},
		default: [],
	},
	userRoles: {
		type: 'array',
		default: [],
	},
	users: {
		type: 'array',
		default: [],
	},
	integrations: {
		type: 'object',
		// Filter registered PWP integrations to allow additions
		properties: applyFilters(
			'personalizeWP.integrations.attributes',
			{
				plugin: {
					type: 'string',
					default: '',
				},
			}
		),
	},

	// Access Control Block Attributes
	password: {
		type: 'string',
		default: '',
	},
	action: {
		enum: [ 'show', 'hide' ],
		default: 'show',
	},
};
