function restoreImageReferences(data, resolveImage) {
    if ('string' == typeof data) return data;
    if (Array.isArray(data)) return data.map((item)=>restoreImageReferences(item, resolveImage));
    if ('object' == typeof data && null !== data) {
        if ('$screenshot' in data) {
            const screenshotData = data;
            const id = screenshotData.$screenshot;
            const capturedAt = 'number' == typeof screenshotData.capturedAt ? screenshotData.capturedAt : void 0;
            if ('string' == typeof id) {
                if (id.startsWith('data:image/') || id.startsWith('./') || id.startsWith('/')) return {
                    base64: id,
                    capturedAt
                };
                let resolved = null;
                const lazy = Object.defineProperties({}, {
                    base64: {
                        get () {
                            if (null === resolved) resolved = resolveImage(id);
                            return resolved;
                        },
                        enumerable: true
                    },
                    capturedAt: {
                        value: capturedAt,
                        enumerable: true
                    }
                });
                return lazy;
            }
            console.warn('Invalid $screenshot value type:', typeof id);
            return {
                base64: ''
            };
        }
        const result = {};
        for (const [key, value] of Object.entries(data))result[key] = restoreImageReferences(value, resolveImage);
        return result;
    }
    return data;
}
export { restoreImageReferences };

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