{"version":3,"file":"fixed.mjs","names":[],"sources":["../../../../../../../../ai/src/rag/chunk/fixed.ts"],"sourcesContent":["import type { Chunk } from \"../contracts/chunk-options.type\";\n\n/**\n * Fixed-window character splitter.\n *\n * The simplest strategy: slices the text into back-to-back windows of\n * `size` characters, stepping forward by `size - overlap` so adjacent\n * windows share `overlap` characters. Boundary-unaware — it will cut\n * mid-word — but deterministic and dep-free. Spans are exact by\n * construction.\n */\nexport function fixedChunk(text: string, size: number, overlap: number): Chunk[] {\n  if (text.length === 0) {\n    return [];\n  }\n\n  const step = Math.max(1, size - overlap);\n  const chunks: Chunk[] = [];\n  let index = 0;\n\n  for (let cursor = 0; cursor < text.length; cursor += step) {\n    const start = cursor;\n    const end = Math.min(cursor + size, text.length);\n\n    chunks.push({ text: text.slice(start, end), index, span: [start, end] });\n    index += 1;\n\n    if (end >= text.length) {\n      break;\n    }\n  }\n\n  return chunks;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,WAAW,MAAc,MAAc,SAA0B;CAC/E,IAAI,KAAK,WAAW,GAClB,OAAO,CAAC;CAGV,MAAM,OAAO,KAAK,IAAI,GAAG,OAAO,OAAO;CACvC,MAAM,SAAkB,CAAC;CACzB,IAAI,QAAQ;CAEZ,KAAK,IAAI,SAAS,GAAG,SAAS,KAAK,QAAQ,UAAU,MAAM;EACzD,MAAM,QAAQ;EACd,MAAM,MAAM,KAAK,IAAI,SAAS,MAAM,KAAK,MAAM;EAE/C,OAAO,KAAK;GAAE,MAAM,KAAK,MAAM,OAAO,GAAG;GAAG;GAAO,MAAM,CAAC,OAAO,GAAG;EAAE,CAAC;EACvE,SAAS;EAET,IAAI,OAAO,KAAK,QACd;CAEJ;CAEA,OAAO;AACT"}