{"version":3,"file":"utils.BX5Fg8C4.mjs","names":[],"sources":["../../../../../../../../../../node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js"],"sourcesContent":["import { getSafeTimers } from '@vitest/utils/timers';\n\nconst NAME_WORKER_STATE = \"__vitest_worker__\";\nclass EnvironmentTeardownError extends Error {\n\tname = \"EnvironmentTeardownError\";\n}\nfunction getWorkerState() {\n\t// @ts-expect-error untyped global\n\tconst workerState = globalThis[NAME_WORKER_STATE];\n\tif (!workerState) throw new Error(\"Vitest failed to access its internal state.\\n\\nOne of the following is possible:\\n- \\\"vitest\\\" is imported directly without running \\\"vitest\\\" command\\n- \\\"vitest\\\" is imported inside \\\"globalSetup\\\" (to fix this, use \\\"setupFiles\\\" instead, because \\\"globalSetup\\\" runs in a different context)\\n- \\\"vitest\\\" is imported inside Vite / Vitest config file\\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\\n\");\n\treturn workerState;\n}\nfunction getSafeWorkerState() {\n\t// @ts-expect-error untyped global\n\treturn globalThis[NAME_WORKER_STATE];\n}\nfunction provideWorkerState(context, state) {\n\tObject.defineProperty(context, NAME_WORKER_STATE, {\n\t\tvalue: state,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t\tenumerable: false\n\t});\n\treturn state;\n}\nfunction isChildProcess() {\n\treturn typeof process !== \"undefined\" && !!process.send;\n}\nfunction resetModules(modules, resetMocks = false) {\n\tconst skipPaths = [\n\t\t/\\/vitest\\/dist\\//,\n\t\t/vitest-virtual-\\w+\\/dist/,\n\t\t/@vitest\\/dist/,\n\t\t...!resetMocks ? [/^mock:/] : []\n\t];\n\tmodules.idToModuleMap.forEach((node, path) => {\n\t\tif (skipPaths.some((re) => re.test(path))) return;\n\t\tnode.promise = void 0;\n\t\tnode.exports = void 0;\n\t\tnode.evaluated = false;\n\t\tnode.importers.clear();\n\t});\n}\nfunction waitNextTick() {\n\tconst { setTimeout } = getSafeTimers();\n\treturn new Promise((resolve) => setTimeout(resolve, 0));\n}\nasync function waitForImportsToResolve() {\n\tawait waitNextTick();\n\tconst state = getWorkerState();\n\tconst promises = [];\n\tconst resolvingCount = state.resolvingModules.size;\n\tfor (const [_, mod] of state.evaluatedModules.idToModuleMap) if (mod.promise && !mod.evaluated) promises.push(mod.promise);\n\tif (!promises.length && !resolvingCount) return;\n\tawait Promise.allSettled(promises);\n\tawait waitForImportsToResolve();\n}\n\nexport { EnvironmentTeardownError as E, getSafeWorkerState as a, getWorkerState as g, isChildProcess as i, provideWorkerState as p, resetModules as r, waitForImportsToResolve as w };\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,MAAM,oBAAoB;AAI1B,SAAS,iBAAiB;CAEzB,MAAM,cAAc,WAAW;CAC/B,IAAI,CAAC,aAAa,MAAM,IAAI,MAAM,6cAA6c;CAC/e,OAAO;AACR;AAcA,SAAS,iBAAiB;CACzB,OAAO,OAAO,YAAY,eAAe,CAAC,CAAC,QAAQ;AACpD;AACA,SAAS,aAAa,SAAS,aAAa,OAAO;CAClD,MAAM,YAAY;EACjB;EACA;EACA;EACA,GAAG,CAAC,aAAa,CAAC,QAAQ,IAAI,CAAC;CAChC;CACA,QAAQ,cAAc,SAAS,MAAM,SAAS;EAC7C,IAAI,UAAU,MAAM,OAAO,GAAG,KAAK,IAAI,CAAC,GAAG;EAC3C,KAAK,UAAU,KAAK;EACpB,KAAK,UAAU,KAAK;EACpB,KAAK,YAAY;EACjB,KAAK,UAAU,MAAM;CACtB,CAAC;AACF;AACA,SAAS,eAAe;CACvB,MAAM,EAAE,eAAe,cAAc;CACrC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,CAAC,CAAC;AACvD;AACA,eAAe,0BAA0B;CACxC,MAAM,aAAa;CACnB,MAAM,QAAQ,eAAe;CAC7B,MAAM,WAAW,CAAC;CAClB,MAAM,iBAAiB,MAAM,iBAAiB;CAC9C,KAAK,MAAM,CAAC,GAAG,QAAQ,MAAM,iBAAiB,eAAe,IAAI,IAAI,WAAW,CAAC,IAAI,WAAW,SAAS,KAAK,IAAI,OAAO;CACzH,IAAI,CAAC,SAAS,UAAU,CAAC,gBAAgB;CACzC,MAAM,QAAQ,WAAW,QAAQ;CACjC,MAAM,wBAAwB;AAC/B"}