"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricSchema = void 0;
const dropShadows_1 = require("../../shared/enums/dropShadows");
const alignments_1 = require("../../shared/enums/alignments");
const source_1 = require("./enums/source");
const unitPositions_1 = require("./enums/unitPositions");
const layouts_1 = require("./enums/layouts");
const icons_1 = require("./enums/icons");
const visualInterest_1 = require("./enums/visualInterest");
exports.MetricSchema = {
    type: "object",
    required: [],
    properties: {
        type: {
            type: "string",
            enum: Object.keys(source_1.SOURCE),
            default: source_1.SOURCE.dynamic,
        },
        cardTitle: {
            type: "string",
        },
        value: {},
        valueType: {
            type: "string",
            default: "string",
            enum: ["string", "number", "date"],
        },
        dynamicMetric: {
            type: "object",
        },
        allowUnitFormatting: {
            type: "boolean",
            default: false,
        },
        unit: {
            type: "string",
        },
        unitPosition: {
            type: "string",
            default: unitPositions_1.UNIT_POSITIONS.after,
            enum: Object.keys(unitPositions_1.UNIT_POSITIONS),
        },
        serverTimeout: {
            type: "number",
            maximum: 95,
            minimum: 5,
            default: 10,
        },
        subtitle: {
            type: "string",
        },
        trailingText: {
            type: "string",
        },
        textAlign: {
            type: "string",
            default: alignments_1.ALIGNMENTS.start,
        },
        allowLink: {
            type: "boolean",
            default: false,
        },
        allowDynamicLink: {
            type: "boolean",
            default: true,
        },
        sourceLink: {
            type: "string",
        },
        sourceTitle: {
            type: "string",
        },
        valueColor: {
            type: "string",
        },
        layout: {
            type: "string",
            default: layouts_1.LAYOUTS.simple,
            enum: Object.keys(layouts_1.LAYOUTS),
        },
        dropShadow: {
            type: "string",
            default: dropShadows_1.DROP_SHADOWS.none,
            enum: Object.keys(dropShadows_1.DROP_SHADOWS),
        },
        icon: {
            type: "string",
            default: icons_1.ICONS.caretUp,
            enum: Object.values(icons_1.ICONS),
        },
        visualInterest: {
            type: "string",
            default: visualInterest_1.VISUAL_INTEREST.none,
            enum: Object.keys(visualInterest_1.VISUAL_INTEREST),
        },
        shareable: {
            type: "boolean",
            default: false,
        },
        shareableByValue: {
            type: "boolean",
            default: false,
        },
        shareableOnHover: {
            type: "boolean",
            default: true,
        },
        popoverText: {
            type: "string",
        },
        publisherText: {
            type: "string",
        },
    },
    allOf: [
        { $ref: "#/definitions/if-source-title-then-source-link" },
        { $ref: "#/definitions/value-type-value-mapping" },
        { $ref: "#/definitions/if-static-then-url-format" },
    ],
    definitions: {
        // TODO: reimplement popover with layouts release
        "if-source-title-then-source-link": {
            if: {
                type: "object",
                properties: { sourceTitle: { not: { const: "" } } },
                required: ["sourceTitle"],
            },
            then: {
                required: ["sourceLink"],
            },
        },
        "value-type-value-mapping": {
            if: {
                type: "object",
                properties: {
                    valueType: { enum: ["string", "date"] },
                },
            },
            then: {
                type: "object",
                properties: { value: { type: "string" } },
            },
            else: {
                type: "object",
                properties: { value: { type: "number" } },
            },
        },
        "if-static-then-url-format": {
            if: {
                type: "object",
                properties: {
                    type: { const: source_1.SOURCE.static },
                },
            },
            then: {
                type: "object",
                properties: {
                    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
                    // @ts-ignore
                    sourceLink: { format: "url" },
                },
            },
        },
    },
};
//# sourceMappingURL=MetricSchema.js.map