"use client";

import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { getExpectedRequestStore } from '../../../client/components/request-async-storage.external';
export function PreloadCss(param) {
    let { moduleIds } = param;
    // Early return in client compilation and only load requestStore on server side
    if (typeof window !== 'undefined') {
        return null;
    }
    const requestStore = getExpectedRequestStore('next/dynamic css');
    const allFiles = [];
    // Search the current dynamic call unique key id in react loadable manifest,
    // and find the corresponding CSS files to preload
    if (requestStore.reactLoadableManifest && moduleIds) {
        const manifest = requestStore.reactLoadableManifest;
        for (const key of moduleIds){
            if (!manifest[key]) continue;
            const cssFiles = manifest[key].files.filter((file)=>file.endsWith('.css'));
            allFiles.push(...cssFiles);
        }
    }
    if (allFiles.length === 0) {
        return null;
    }
    return /*#__PURE__*/ _jsx(_Fragment, {
        children: allFiles.map((file)=>{
            return /*#__PURE__*/ _jsx("link", {
                // @ts-ignore
                precedence: 'dynamic',
                rel: "stylesheet",
                href: requestStore.assetPrefix + "/_next/" + encodeURI(file),
                as: "style"
            }, file);
        })
    });
}

//# sourceMappingURL=preload-css.js.map