{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAGtE;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAG/E;AAMD,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC,YAAY,GAAG,IAAI,CA2BrB","sourcesContent":["import type { Contribution } from \"./store.js\";\n\nexport function frontier(contributions: Contribution[]): Contribution[] {\n\tconst parented = new Set(contributions.flatMap((c) => c.parents));\n\treturn contributions.filter((c) => !parented.has(c.id));\n}\n\nexport function unverifiedResults(contributions: Contribution[]): Contribution[] {\n\tconst verified = new Set(contributions.filter((c) => c.type === \"verification\").flatMap((c) => c.parents));\n\treturn contributions.filter((c) => c.type === \"result\" && !verified.has(c.id));\n}\n\nfunction taskTag(contribution: Contribution): string | null {\n\treturn contribution.tags.find((tag) => tag.startsWith(\"task:\")) ?? null;\n}\n\nexport function pickNeglectedTask(\n\tcontributions: Contribution[],\n\toptions: { skipPassed?: boolean } = {},\n): Contribution | null {\n\tconst skipPassed = options.skipPassed ?? true;\n\tconst tasks = contributions.filter((c) => c.type === \"task\");\n\tconst attemptsByTask = new Map<string, number>();\n\tconst passedTasks = new Set<string>();\n\tfor (const contribution of contributions) {\n\t\tconst tag = taskTag(contribution);\n\t\tif (tag && (contribution.type === \"result\" || contribution.type === \"failure\")) {\n\t\t\tattemptsByTask.set(tag, (attemptsByTask.get(tag) ?? 0) + 1);\n\t\t\tif (contribution.type === \"result\" && contribution.metric?.value === 1) {\n\t\t\t\tpassedTasks.add(tag);\n\t\t\t}\n\t\t}\n\t}\n\tconst open = tasks\n\t\t.filter((task) => !skipPassed || !passedTasks.has(taskTag(task) ?? task.description))\n\t\t.map((task) => ({\n\t\t\ttask,\n\t\t\tattempts: attemptsByTask.get(taskTag(task) ?? task.description) ?? 0,\n\t\t}));\n\tif (open.length === 0) {\n\t\treturn null;\n\t}\n\topen.sort((a, b) =>\n\t\ta.attempts === b.attempts ? (a.task.description < b.task.description ? -1 : 1) : a.attempts - b.attempts,\n\t);\n\treturn open[0].task;\n}\n"]}