import { targetEntities } from "../../../search/types/IHubCatalog";
import { CARD_TITLE_TAGS } from "./enums/cardTitleTags";
import { CORNERS } from "./enums/corners";
import { DROP_SHADOWS } from "./enums/dropShadows";
/**
 * JSON schema for the appearance of a gallery display
 * This can be for a catalog, a collection, a gallery card, etc
 */
export const GalleryDisplayConfigSchema = {
    type: "object",
    properties: {
        hidden: { type: "boolean", default: false },
        layout: {
            type: "string",
            enum: ["grid", "list", "map", "compact", "table", "calendar"],
            default: "list",
        },
        layouts: {
            type: "array",
            items: {
                type: "string",
                enum: ["grid", "list", "map", "compact", "table", "calendar"],
            },
            default: [],
        },
        cardTitleTag: {
            type: "string",
            enum: Object.keys(CARD_TITLE_TAGS),
            default: CARD_TITLE_TAGS.h3,
        },
        imageType: {
            type: "string",
            enum: ["thumbnail", "icon"],
            default: "thumbnail",
        },
        showThumbnail: {
            type: "string",
            enum: ["show", "hide", "grid"],
            default: "show",
        },
        corners: {
            type: "string",
            enum: Object.keys(CORNERS),
            default: CORNERS.square,
        },
        shadow: {
            type: "string",
            enum: Object.keys(DROP_SHADOWS),
            default: DROP_SHADOWS.none,
        },
        showLinkButton: { type: "boolean", default: false },
        linkButtonStyle: {
            type: "string",
            enum: ["outline", "outline-filled"],
            default: "outline-filled",
        },
        linkButtonText: { type: "string", default: "Explore" },
        sort: {
            type: "string",
            enum: ["relevance", "title", "created", "modified"],
            default: "relevance",
        },
        customFiltersEnabled: { type: "boolean", default: false },
        filters: {
            type: "array",
            items: {
                type: "object",
                properties: {
                    key: {
                        type: "string",
                        enum: [
                            "location",
                            "type",
                            "source",
                            "event-occurrence",
                            "event-from",
                            "event-attendance",
                            "tags",
                            "categories",
                            "license",
                            "modified",
                            "access",
                            "group-role",
                            "group-type",
                            "group-access",
                            "event-access",
                            "event-date",
                        ],
                    },
                    hidden: { type: "boolean" },
                    label: { type: "string" },
                },
            },
        },
    },
};
/** JSON schema for an IPredicate */
export const PredicateSchema = {
    type: "object",
    minProperties: 1,
};
/** JSON schema for an IFilter */
export const FilterSchema = {
    type: "object",
    minProperties: 1,
    properties: {
        operation: {
            type: "string",
            enum: ["AND", "OR"],
        },
        predicates: {
            type: "array",
            items: PredicateSchema,
            minItems: 1,
        },
    },
};
/** JSON schema for an IQuery */
export const QuerySchema = {
    type: "object",
    required: ["targetEntity"],
    properties: {
        targetEntity: {
            type: "string",
            enum: [...targetEntities],
        },
        filters: {
            type: "array",
            items: FilterSchema,
            minItems: 1,
        },
    },
};
/** JSON schema for an IHubCollection */
export const CollectionSchema = {
    type: "object",
    required: ["label"],
    properties: {
        label: {
            type: "string",
            // eslint-disable-next-line @typescript-eslint/ban-ts-comment
            // @ts-ignore
            format: "isNotWhitespace",
            maxLength: 64,
        },
        scope: QuerySchema,
        displayConfig: GalleryDisplayConfigSchema,
    },
};
/** JSON schema for an IHubCatalog */
export const CatalogSchema = {
    type: "object",
    properties: {
        title: {
            type: "string",
        },
        scopes: {
            type: "object",
            properties: targetEntities.reduce((acc, targetEntity) => {
                acc[targetEntity] = QuerySchema;
                return acc;
            }, {}),
        },
        collections: {
            type: "array",
            items: CollectionSchema,
        },
        displayConfig: {
            type: "object",
            properties: targetEntities.reduce((acc, targetEntity) => {
                acc[targetEntity] = GalleryDisplayConfigSchema;
                return acc;
            }, {}),
        },
    },
};
//# sourceMappingURL=CatalogSchema.js.map