"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CatalogSchema = exports.CollectionSchema = exports.QuerySchema = exports.FilterSchema = exports.PredicateSchema = exports.GalleryDisplayConfigSchema = void 0;
const IHubCatalog_1 = require("../../../search/types/IHubCatalog");
const cardTitleTags_1 = require("./enums/cardTitleTags");
const corners_1 = require("./enums/corners");
const dropShadows_1 = require("./enums/dropShadows");
/**
 * JSON schema for the appearance of a gallery display
 * This can be for a catalog, a collection, a gallery card, etc
 */
exports.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(cardTitleTags_1.CARD_TITLE_TAGS),
            default: cardTitleTags_1.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_1.CORNERS),
            default: corners_1.CORNERS.square,
        },
        shadow: {
            type: "string",
            enum: Object.keys(dropShadows_1.DROP_SHADOWS),
            default: dropShadows_1.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 */
exports.PredicateSchema = {
    type: "object",
    minProperties: 1,
};
/** JSON schema for an IFilter */
exports.FilterSchema = {
    type: "object",
    minProperties: 1,
    properties: {
        operation: {
            type: "string",
            enum: ["AND", "OR"],
        },
        predicates: {
            type: "array",
            items: exports.PredicateSchema,
            minItems: 1,
        },
    },
};
/** JSON schema for an IQuery */
exports.QuerySchema = {
    type: "object",
    required: ["targetEntity"],
    properties: {
        targetEntity: {
            type: "string",
            enum: [...IHubCatalog_1.targetEntities],
        },
        filters: {
            type: "array",
            items: exports.FilterSchema,
            minItems: 1,
        },
    },
};
/** JSON schema for an IHubCollection */
exports.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: exports.QuerySchema,
        displayConfig: exports.GalleryDisplayConfigSchema,
    },
};
/** JSON schema for an IHubCatalog */
exports.CatalogSchema = {
    type: "object",
    properties: {
        title: {
            type: "string",
        },
        scopes: {
            type: "object",
            properties: IHubCatalog_1.targetEntities.reduce((acc, targetEntity) => {
                acc[targetEntity] = exports.QuerySchema;
                return acc;
            }, {}),
        },
        collections: {
            type: "array",
            items: exports.CollectionSchema,
        },
        displayConfig: {
            type: "object",
            properties: IHubCatalog_1.targetEntities.reduce((acc, targetEntity) => {
                acc[targetEntity] = exports.GalleryDisplayConfigSchema;
                return acc;
            }, {}),
        },
    },
};
//# sourceMappingURL=CatalogSchema.js.map