function variantFor(position) {
    switch(position){
        case 'left':
        case 'right':
            return 'card';
        case 'wide':
            return 'desktop';
        default:
            return 'tablet';
    }
}
function getPreferredSize(position, image) {
    if (image?.storageUrl == null) return null;
    if ('image/svg+xml' === image.mimeType) return {
        url: image.storageUrl,
        width: image.imageWidth,
        height: image.imageHeight
    };
    const wanted = variantFor(position);
    const match = image.variants?.find((v)=>v.name === wanted);
    if (match?.storageUrl) return {
        url: match.storageUrl,
        width: match.width ?? image.imageWidth,
        height: match.height ?? image.imageHeight
    };
    return {
        url: image.storageUrl,
        width: image.imageWidth,
        height: image.imageHeight
    };
}
function deriveImageSizes(image) {
    if (!image?.storageUrl) return [];
    if ('image/svg+xml' === image.mimeType) return [];
    if (!image.variants || 0 === image.variants.length) return [];
    const out = [];
    for (const variant of image.variants)if (variant.storageUrl) out.push({
        name: variant.name,
        url: variant.storageUrl,
        width: variant.width,
        height: variant.height,
        format: variant.format ?? 'avif'
    });
    return out;
}
export { deriveImageSizes, getPreferredSize };
