{"version":3,"sources":["../interpreter/output/formatter.ts"],"names":["formatOutput","nodes","options","formatMarkdownNodes","parts","node","type","push","content","fence","lang","language","result","join","shouldNormalize","normalizeBlankLines","normalizeOutput"],"mappings":";;;;AAkBA,eAAsBA,YAAAA,CAAaC,OAAmBC,OAAsB,EAAA;AAK1E,EAAOC,OAAAA,mBAAAA,CAAoBF,OAAOC,OAAAA,CAAAA;AACpC;AANsBF,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;AAWtB,eAAeG,mBAAAA,CAAoBF,OAAmBC,OAAsB,EAAA;AAC1E,EAAA,MAAME,QAAkB,EAAA;AAExB,EAAA,KAAA,MAAWC,QAAQJ,KAAO,EAAA;AACxB,IAAA,QAAQI,KAAKC,IAAI;MACf,KAAK,MAAA;AAEHF,QAAMG,KAAAA,CAAAA,IAAAA,CAAKF,KAAKG,OAAO,CAAA;AACvB,QAAA;MACF,KAAK,SAAA;AACHJ,QAAAA,KAAAA,CAAMG,KAAK,IAAA,CAAA;AACX,QAAA;MACF,KAAK,WAAA;AAEH,QAAA,MAAME,KAAQ,GAAA,KAAA;AACd,QAAMC,MAAAA,IAAAA,GAAQL,KAAaM,QAAY,IAAA,EAAA;AACvC,QAAMH,MAAAA,OAAAA,GAAWH,KAAaG,OAAW,IAAA,EAAA;AACzCJ,QAAAA,KAAAA,CAAMG,IAAK,CAAA,CAAA,EAAGE,KAAAA,CAAAA,EAAQC,IAAAA;EAASF,OAAAA;AAAYC,EAAAA,KAAAA,CAAO,CAAA,CAAA;AAClD,QAAA;AAEJ;AACF;AAEA,EAAIG,IAAAA,MAAAA,GAASR,KAAMS,CAAAA,IAAAA,CAAK,EAAA,CAAA;AAGxB,EAAMC,MAAAA,eAAAA,GAAkBZ,QAAQa,mBAAwB,KAAA,KAAA;AACxD,EAAA,IAAID,eAAiB,EAAA;AACnBF,IAAAA,MAAAA,GAASI,gBAAgBJ,MAAAA,CAAAA;AAC3B;AAEA,EAAOA,OAAAA,MAAAA;AACT;AAhCeT,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"chunk-XHRF2BER.mjs","sourcesContent":["import type { MlldNode } from '@core/types';\nimport type { Variable } from '@core/types/variable';\nimport { normalizeOutput } from './normalizer';\n\n/**\n * Output formatting options\n */\nexport interface FormatOptions {\n  format: 'markdown' | 'xml';\n  variables?: Map<string, Variable>;\n  useMarkdownFormatter?: boolean; // Default: true - use prettier for formatting\n  normalizeBlankLines?: boolean; // Default: true - normalize blank lines\n}\n\n/**\n * Format nodes into final output.\n * This is a simplified version - we can reuse the existing OutputService later.\n */\nexport async function formatOutput(nodes: MlldNode[], options: FormatOptions): Promise<string> {\n  // XML format will be redesigned - for now just return markdown\n  // The @xml transformer in mlld will handle XML conversion\n  \n  // Default to plain markdown (just the content)\n  return formatMarkdownNodes(nodes, options);\n}\n\n/**\n * Format as markdown (process all node types)\n */\nasync function formatMarkdownNodes(nodes: MlldNode[], options: FormatOptions): Promise<string> {\n  const parts: string[] = [];\n  \n  for (const node of nodes) {\n    switch (node.type) {\n      case 'Text':\n        // eslint-disable-next-line mlld/no-ast-string-manipulation\n        parts.push(node.content);\n        break;\n      case 'Newline':\n        parts.push('\\n');\n        break;\n      case 'CodeFence':\n        // Reconstruct code fence with proper formatting\n        const fence = '```';\n        const lang = (node as any).language || '';\n        const content = (node as any).content || '';\n        parts.push(`${fence}${lang}\\n${content}\\n${fence}`);\n        break;\n      // Other node types can be added as needed\n    }\n  }\n  \n  let result = parts.join('');\n\n  // Apply output normalization if enabled (default: true)\n  const shouldNormalize = options.normalizeBlankLines !== false;\n  if (shouldNormalize) {\n    result = normalizeOutput(result);\n  }\n\n  return result;\n}\n\n// XML formatting functions removed - will be redesigned\n// The @xml transformer in mlld will handle XML conversion\n\n"]}