{"version":3,"file":"readProblemMarkdownFrontMatter.cjs","names":["fs","path","parseFrontMatter","problemMarkdownFrontMatterSchema"],"sources":["../../src/helpers/readProblemMarkdownFrontMatter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport parseFrontMatter from 'front-matter';\n\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport { problemMarkdownFrontMatterSchema } from '../types/problem.js';\n\n/**\n * Whether a standard stdio problem is judgeable without test cases: static-analysis rules still\n * judge the submitted code, and manual scoring intentionally accepts every submission.\n */\nexport function judgesWithoutTestCases(frontMatter: ProblemMarkdownFrontMatter): boolean {\n  return (\n    frontMatter.isManualScoringRequired === true ||\n    (frontMatter.requiredRegExpsInCode?.length ?? 0) > 0 ||\n    (frontMatter.forbiddenRegExpsInCode?.length ?? 0) > 0 ||\n    (frontMatter.forbiddenTextsInCode?.length ?? 0) > 0 ||\n    (frontMatter.requiredSubmissionFilePaths?.length ?? 0) > 0\n  );\n}\n\nexport async function readProblemMarkdownFrontMatter(problemDir: string): Promise<ProblemMarkdownFrontMatter> {\n  for (const dirent of await fs.promises.readdir(problemDir, { withFileTypes: true })) {\n    if (!dirent.isFile()) continue;\n    if (!(dirent.name === 'problem.md' || dirent.name.endsWith('.problem.md'))) continue;\n\n    const markdown = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n    const { attributes } = (parseFrontMatter as unknown as (markdown: string) => { attributes: unknown })(markdown);\n\n    return problemMarkdownFrontMatterSchema.parse(attributes);\n  }\n\n  throw new Error(`problem markdown not found: ${problemDir}`);\n}\n"],"mappings":"yOAYA,SAAgB,EAAuB,EAAkD,CACvF,OACE,EAAY,0BAA4B,KACvC,EAAY,uBAAuB,QAAU,GAAK,IAClD,EAAY,wBAAwB,QAAU,GAAK,IACnD,EAAY,sBAAsB,QAAU,GAAK,IACjD,EAAY,6BAA6B,QAAU,GAAK,CAE7D,CAEA,eAAsB,EAA+B,EAAyD,CAC5G,IAAK,IAAM,KAAU,MAAMA,EAAAA,QAAG,SAAS,QAAQ,EAAY,CAAE,cAAe,EAAK,CAAC,EAAG,CAEnF,GADI,CAAC,EAAO,OAAO,GACf,EAAE,EAAO,OAAS,cAAgB,EAAO,KAAK,SAAS,aAAa,GAAI,SAE5E,IAAM,EAAW,MAAMA,EAAAA,QAAG,SAAS,SAASC,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,EAEvF,CAAE,eAAA,EAAgBC,EAAAA,QAAAA,CAA8E,CAAQ,EAE9G,OAAOC,EAAAA,iCAAiC,MAAM,CAAU,CAC1D,CAEA,MAAU,MAAM,+BAA+B,GAAY,CAC7D"}