export declare const PRELOAD_SCRIPT = "\n(async (timeoutMs) => {\n // Helper: withTimeout\n const withTimeout = (promise, msg) => {\n let timeoutId;\n const timeoutPromise = new Promise(r => {\n timeoutId = setTimeout(() => {\n console.warn(msg);\n r();\n }, timeoutMs);\n });\n return Promise.race([\n promise.finally(() => clearTimeout(timeoutId)),\n timeoutPromise\n ]);\n };\n\n // 1. Wait for fonts\n await withTimeout(document.fonts.ready, '[Helios Preload] Timeout waiting for fonts');\n\n // 2. Wait for images (IMG tags, Video posters, SVG images)\n \n function findAllImages(root, imagesArray) {\n const images = imagesArray || [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);\n while (walker.nextNode()) {\n const node = walker.currentNode;\n if (node.tagName === 'IMG') {\n images.push(node);\n }\n // Check for VIDEO poster\n if (node.tagName === 'VIDEO' && node.poster) {\n const img = new Image();\n img.src = node.poster;\n images.push(img);\n }\n // Check for SVG IMAGE\n if (node.tagName === 'image' || node.tagName === 'IMAGE') {\n const href = node.getAttribute('href') || node.getAttribute('xlink:href');\n if (href) {\n const img = new Image();\n img.src = href;\n images.push(img);\n }\n }\n if (node.shadowRoot) {\n findAllImages(node.shadowRoot, images);\n }\n }\n return images;\n }\n\n\n const images = findAllImages(document);\n if (images.length > 0) {\n console.log('[Helios Preload] Preloading ' + images.length + ' images...');\n const loadPromise = Promise.all(images.map((img) => {\n if (img.complete) return;\n return new Promise((resolve) => {\n img.onload = resolve;\n img.onerror = resolve; // Don't block on broken images\n });\n }));\n await withTimeout(loadPromise, '[Helios Preload] Timeout waiting for images');\n }\n\n // 3. Wait for CSS background images and masks\n \n function findAllElements(root, elements) {\n elements = elements || [];\n if (root.nodeType === Node.ELEMENT_NODE) {\n elements.push(root);\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);\n while (walker.nextNode()) {\n const node = walker.currentNode;\n elements.push(node);\n if (node.shadowRoot) {\n findAllElements(node.shadowRoot, elements);\n }\n }\n return elements;\n }\n\n\n const allElements = findAllElements(document);\n const backgroundUrls = new Set();\n\n allElements.forEach((el) => {\n const targets = [null, '::before', '::after'];\n\n targets.forEach(pseudo => {\n const style = window.getComputedStyle(el, pseudo);\n const props = ['backgroundImage', 'maskImage', 'webkitMaskImage'];\n\n props.forEach(prop => {\n const val = style[prop];\n if (val && val !== 'none') {\n // Extract URLs from \"url('...'), url(\"...\")\"\n const matches = val.matchAll(/url\\((['\"]?)(.*?)\\1\\)/g);\n for (const match of matches) {\n if (match[2]) {\n backgroundUrls.add(match[2]);\n }\n }\n }\n });\n });\n });\n\n if (backgroundUrls.size > 0) {\n console.log('[Helios Preload] Preloading ' + backgroundUrls.size + ' background images...');\n const loadPromise = Promise.all(Array.from(backgroundUrls).map((url) => {\n return new Promise((resolve) => {\n const img = new Image();\n img.onload = () => resolve(undefined);\n img.onerror = () => {\n console.warn('[Helios Preload] Failed to preload background image: ' + url);\n resolve(undefined); // Don't block\n };\n img.src = url;\n if (img.complete) resolve(undefined);\n });\n }));\n await withTimeout(loadPromise, '[Helios Preload] Timeout waiting for background images');\n }\n})\n";