dist / multiImageArgs.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseMultiImageNames = parseMultiImageNames;
// Only decode an explicitly JSON-encoded list. Never guess separators or paths.
function parseMultiImageNames(value) {
    let decoded = value;
    if (typeof value === "string") {
        if (value.length > 32768)
            return { error: "imageNames exceeds the supported argument size.", receivedType: "string" };
        try {
            decoded = JSON.parse(value);
        }
        catch {
            return { error: "imageNames is a string, not a JSON array. Send an actual array of 2–4 exact image paths. Comma/newline-separated names and single-quoted lists are not interpreted.", receivedType: "string" };
        }
    }
    const receivedType = decoded === null ? "null" : Array.isArray(decoded) ? "array" : typeof decoded;
    if (!Array.isArray(decoded) || decoded.length < 2 || decoded.length > 4 || !decoded.every(item => typeof item === "string" && item.trim().length > 0)) {
        return { error: "imageNames must be a JSON array containing 2–4 nonempty image-path strings. No paths will be added, split or guessed.", receivedType };
    }
    return { images: decoded };
}
//# sourceMappingURL=multiImageArgs.js.map