import { shuffleArray } from "./utils";
import nepaliWords from "./nepali-words";

type LoremOptions = {
  paragraphs?: number;
  sentencesPerParagraph?: number;
  wordsPerSentence?: number;
};

const shuffledWords = shuffleArray(nepaliWords);

export function getSentence(wordCount: number = 15): string {
  const words: string[] = [];
  for (let i = 0; i < wordCount; i++) {
    words.push(shuffledWords[i % shuffledWords.length]); // Cycle through shuffled words
  }
  return words.join(" ") + "।";
}

export function getNepaliLorem(options: LoremOptions = {}): string {
  const {
    paragraphs = 3,
    sentencesPerParagraph = 5,
    wordsPerSentence = 15,
  } = options;

  return Array.from({ length: paragraphs }, () =>
    Array.from({ length: sentencesPerParagraph }, () =>
      getSentence(wordsPerSentence),
    ).join(" "),
  ).join("\n\n");
}
