"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UvLockfileSchema = exports.PdmLockfileSchema = exports.PyProjectSchema = void 0;
const zod_1 = require("zod");
const schema_utils_1 = require("../../../util/schema-utils");
const DependencyListSchema = zod_1.z.array(zod_1.z.string()).optional();
const DependencyRecordSchema = zod_1.z
    .record(zod_1.z.string(), zod_1.z.array(zod_1.z.string()))
    .optional();
exports.PyProjectSchema = zod_1.z.object({
    project: zod_1.z
        .object({
        version: zod_1.z.string().optional().catch(undefined),
        'requires-python': zod_1.z.string().optional(),
        dependencies: DependencyListSchema,
        'optional-dependencies': DependencyRecordSchema,
    })
        .optional(),
    'build-system': zod_1.z
        .object({
        requires: DependencyListSchema,
        'build-backend': zod_1.z.string().optional(),
    })
        .optional(),
    tool: zod_1.z
        .object({
        pdm: zod_1.z
            .object({
            'dev-dependencies': DependencyRecordSchema,
            source: zod_1.z
                .array(zod_1.z.object({
                url: zod_1.z.string(),
                name: zod_1.z.string(),
                verify_ssl: zod_1.z.boolean().optional(),
            }))
                .optional(),
        })
            .optional(),
        hatch: zod_1.z
            .object({
            envs: zod_1.z
                .record(zod_1.z.string(), zod_1.z
                .object({
                dependencies: DependencyListSchema,
                'extra-dependencies': DependencyListSchema,
            })
                .optional())
                .optional(),
        })
            .optional(),
        uv: zod_1.z
            .object({
            'dev-dependencies': DependencyListSchema,
        })
            .optional(),
    })
        .optional(),
});
exports.PdmLockfileSchema = schema_utils_1.Toml.pipe(zod_1.z.object({
    package: (0, schema_utils_1.LooseArray)(zod_1.z.object({
        name: zod_1.z.string(),
        version: zod_1.z.string(),
    })),
}))
    .transform(({ package: pkg }) => Object.fromEntries(pkg.map(({ name, version }) => [name, version])))
    .transform((lock) => ({ lock }));
exports.UvLockfileSchema = schema_utils_1.Toml.pipe(zod_1.z.object({
    package: (0, schema_utils_1.LooseArray)(zod_1.z.object({
        name: zod_1.z.string(),
        version: zod_1.z.string(),
    })),
})).transform(({ package: pkg }) => Object.fromEntries(pkg.map(({ name, version }) => [name, version])));
//# sourceMappingURL=schema.js.map