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iBAAiB,GAAQ,KAAK,GAAK,GAAG,SAAS,IAAM,EAAI,OAC7D,CAAE,MAAO,GACR,EAAK,EACN,CACD,MACC,GAEF,IAGA,EAAO,YAAY,KAAI,SAAgC,EAAK,EAAK,GAChE,GAAI,EAAI,IAAK,CAEZ,GADY,IAAI,IAAI,EAAI,IAAK,oBACrB,WAAa,EAAM,CAC1B,MAAM,EAAO,EAAgB,QAAQ,iCAA4B,qCAAqC,KAAK,UAAU,EAAI,OAAO,IAAI,oBAKpI,OAJA,EAAI,UAAU,gBAAiB,wCAC/B,EAAI,UAAU,eAAgB,4BAC9B,EAAI,MAAM,QACV,EAAI,KAEL,CACD,CACA,GACD,IACA,EAAO,YAAY,IAAI,EAAM,KAAK,EAAY,CAC7C,QAAQ,EACR,KAAK,IAEP,KAIH,SAAS,sBAAsB,GAC9B,MAAM,EAAU,EAAI,OACd,EAAe,EAAQ,KAAK,MAAQ,EAAQ,UAAU,QAAU,QAAQ,EAAQ,SAAS,UAAU,MAAM,GACtF,iBAAb,EACU,SAAb,EAEe,SAAhB,EAAS,UACZ,EACL,IAAK,EACJ,OAGD,MAAM,EAAO,QAAQ,EAAI,QAAQ,MAAQ,EAAQ,MAAQ,QAAQ,MAAO,EAAQ,SAAS,kBAAoB,uBAAuB,kBAC9H,EAAS,MAAM,QAAQ,IAAiB,EAAa,OAAS,GAAK,WAAY,EAAa,GAAK,EAAa,GAAG,YAAS,EAChI,OAAK,GAA4B,iBAAX,EAGf,CAAC,QAAQ,EAAM,GAAS,IAAI,SAAS,MAAS,MAF7C,CAAC,EAAM,IAAI,SAAS,MAG7B,QAES","file":"/npm/@vitest/ui@4.0.17/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@vitest/ui@4.0.17/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { toArray } from '@vitest/utils/helpers';\nimport { resolve, basename } from 'pathe';\nimport sirv from 'sirv';\nimport c from 'tinyrainbow';\nimport { coverageConfigDefaults } from 'vitest/config';\nimport { isValidApiRequest, isFileServingAllowed } from 'vitest/node';\n\nvar version = \"4.0.17\";\n\nvar index = (ctx) => {\n\tif (ctx.version !== version) {\n\t\tctx.logger.warn(c.yellow(`Loaded ${c.inverse(c.yellow(` vitest@${ctx.version} `))} and ${c.inverse(c.yellow(` @vitest/ui@${version} `))}.` + \"\\nRunning mixed versions is not supported and may lead into bugs\" + \"\\nUpdate your dependencies and make sure the versions match.\"));\n\t}\n\treturn {\n\t\tname: \"vitest:ui\",\n\t\tapply: \"serve\",\n\t\tconfigureServer: {\n\t\t\torder: \"post\",\n\t\t\thandler(server) {\n\t\t\t\tconst uiOptions = ctx.config;\n\t\t\t\tconst base = uiOptions.uiBase;\n\t\t\t\tconst coverageFolder = resolveCoverageFolder(ctx);\n\t\t\t\tconst coveragePath = coverageFolder ? coverageFolder[1] : undefined;\n\t\t\t\tif (coveragePath && base === coveragePath) {\n\t\t\t\t\tthrow new Error(`The ui base path and the coverage path cannot be the same: ${base}, change coverage.reportsDirectory`);\n\t\t\t\t}\n\t\t\t\tif (coverageFolder) {\n\t\t\t\t\tserver.middlewares.use(coveragePath, sirv(coverageFolder[0], {\n\t\t\t\t\t\tsingle: true,\n\t\t\t\t\t\tdev: true,\n\t\t\t\t\t\tsetHeaders: (res) => {\n\t\t\t\t\t\t\tres.setHeader(\"Cache-Control\", \"public,max-age=0,must-revalidate\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\tconst clientDist = resolve(fileURLToPath(import.meta.url), \"../client\");\n\t\t\t\tconst clientIndexHtml = fs.readFileSync(resolve(clientDist, \"index.html\"), \"utf-8\");\n\t\t\t\t// eslint-disable-next-line prefer-arrow-callback\n\t\t\t\tserver.middlewares.use(function vitestAttachment(req, res, next) {\n\t\t\t\t\tif (!req.url) {\n\t\t\t\t\t\treturn next();\n\t\t\t\t\t}\n\t\t\t\t\tconst url = new URL(req.url, \"http://localhost\");\n\t\t\t\t\tif (url.pathname === \"/__vitest_attachment__\") {\n\t\t\t\t\t\tconst path = url.searchParams.get(\"path\");\n\t\t\t\t\t\tconst contentType = url.searchParams.get(\"contentType\");\n\t\t\t\t\t\t// ignore invalid requests\n\t\t\t\t\t\tif (!isValidApiRequest(ctx.config, req) || !contentType || !path) {\n\t\t\t\t\t\t\treturn next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst fsPath = decodeURIComponent(path);\n\t\t\t\t\t\tif (!isFileServingAllowed(ctx.vite.config, fsPath)) {\n\t\t\t\t\t\t\treturn next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tres.writeHead(200, { \"content-type\": contentType });\n\t\t\t\t\t\t\tfs.createReadStream(fsPath).pipe(res).on(\"close\", () => res.end());\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tnext(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnext();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t// serve index.html with api token\n\t\t\t\t// eslint-disable-next-line prefer-arrow-callback\n\t\t\t\tserver.middlewares.use(function vitestUiHtmlMiddleware(req, res, next) {\n\t\t\t\t\tif (req.url) {\n\t\t\t\t\t\tconst url = new URL(req.url, \"http://localhost\");\n\t\t\t\t\t\tif (url.pathname === base) {\n\t\t\t\t\t\t\tconst html = clientIndexHtml.replace(\"<!-- !LOAD_METADATA! -->\", `<script>window.VITEST_API_TOKEN = ${JSON.stringify(ctx.config.api.token)}<\\/script>`);\n\t\t\t\t\t\t\tres.setHeader(\"Cache-Control\", \"no-cache, max-age=0, must-revalidate\");\n\t\t\t\t\t\t\tres.setHeader(\"Content-Type\", \"text/html; charset=utf-8\");\n\t\t\t\t\t\t\tres.write(html);\n\t\t\t\t\t\t\tres.end();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnext();\n\t\t\t\t});\n\t\t\t\tserver.middlewares.use(base, sirv(clientDist, {\n\t\t\t\t\tsingle: true,\n\t\t\t\t\tdev: true\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\t};\n};\nfunction resolveCoverageFolder(ctx) {\n\tconst options = ctx.config;\n\tconst htmlReporter = options.api?.port && options.coverage?.enabled ? toArray(options.coverage.reporter).find((reporter) => {\n\t\tif (typeof reporter === \"string\") {\n\t\t\treturn reporter === \"html\";\n\t\t}\n\t\treturn reporter[0] === \"html\";\n\t}) : undefined;\n\tif (!htmlReporter) {\n\t\treturn undefined;\n\t}\n\t// reportsDirectory not resolved yet\n\tconst root = resolve(ctx.config?.root || options.root || process.cwd(), options.coverage.reportsDirectory || coverageConfigDefaults.reportsDirectory);\n\tconst subdir = Array.isArray(htmlReporter) && htmlReporter.length > 1 && \"subdir\" in htmlReporter[1] ? htmlReporter[1].subdir : undefined;\n\tif (!subdir || typeof subdir !== \"string\") {\n\t\treturn [root, `/${basename(root)}/`];\n\t}\n\treturn [resolve(root, subdir), `/${basename(root)}/${subdir}/`];\n}\n\nexport { index as default };\n"]}