import Fuse from 'fuse.js'
import { enroll_sitemap } from './enrollx'
import { square_sitemap } from './square'
import { exams_sitemap } from './exams_sitemap'
import { payments_sitemap } from './payments'

const withAppKey = (arr, key) => {
  return arr?.map((i) => ({
    ...i,
    appKey: key,
  }))
}

export const sitemap_directory = [
  ...withAppKey(square_sitemap, 'ums'),
  ...withAppKey(exams_sitemap, 'exams'),
  ...withAppKey(enroll_sitemap, 'enroll'),
  ...withAppKey(payments_sitemap, 'payments'),
]

export const Sitemap = new Fuse(sitemap_directory, {
  keys: ['title', 'keywords'],
  minMatchCharLength: 3,
  threshold: 0.35,
  includeScore: true,
})
