function restoreImageReferences(data, imageMap) {
    if ('string' == typeof data) return data;
    if (Array.isArray(data)) return data.map((item)=>restoreImageReferences(item, imageMap));
    if ('object' == typeof data && null !== data) {
        if ('$screenshot' in data) {
            const id = data.$screenshot;
            if ('string' == typeof id) {
                if (imageMap[id]) return {
                    base64: imageMap[id]
                };
                if (id.startsWith('data:image/') || id.startsWith('./') || id.startsWith('/')) return {
                    base64: id
                };
                return {
                    base64: `./screenshots/${id}.png`
                };
            }
            console.warn('Invalid $screenshot value type:', typeof id);
            return {
                base64: ''
            };
        }
        const result = {};
        for (const [key, value] of Object.entries(data))result[key] = restoreImageReferences(value, imageMap);
        return result;
    }
    return data;
}
export { restoreImageReferences };

//# sourceMappingURL=image-restoration.mjs.map