const BaseUrl = "https://downloader.lionwebsite.xyz/"; // Remote galleries carry a raw thumbnail path; it only resolves through the // backend proxy once the active auth code is attached. export function ehThumbnailUrl(path, AuthCode) { if (!path) return ""; return BaseUrl + "GalleryManage/ehThumbnail?" + new URLSearchParams({path, AuthCode}).toString(); } const UNIT_SCALE = {b: 1, k: 1024, m: 1024 ** 2, g: 1024 ** 3, t: 1024 ** 4}; function sizeInBytes(text) { const match = String(text).match(/([\d.]+)\s*([kmgt]?)(?:i?b)/i); if (!match) return 0; const scale = UNIT_SCALE[match[2].toLowerCase()] ?? 1; return Number(match[1]) * scale; } // Prefer the original file; otherwise take whichever entry reports the most bytes. export function pickDefaultResolution(availableResolution) { const entries = Object.entries(availableResolution || {}); if (entries.length === 0) return ""; const original = entries.find(([resolution]) => /original/i.test(resolution)); if (original) return original[0]; return entries.reduce((best, current) => sizeInBytes(current[1]) > sizeInBytes(best[1]) ? current : best)[0]; }