import { addCollection } from "@iconify/react"
import { icons as cbiCollection } from "@iconify-json/cbi"
import { icons as simpleIconsCollection } from "@iconify-json/simple-icons"
import vcLogos from "@/lib/iconify-logos-vc-subset.json"

let vcLogosRegistered = false

export function ensureVcLogosCollection() {
  if (vcLogosRegistered) return
  addCollection(vcLogos as Parameters<typeof addCollection>[0])

  const iosFaceTime = cbiCollection.icons?.iosfacetime
  if (iosFaceTime) {
    addCollection({
      prefix: "cbi",
      icons: { iosfacetime: iosFaceTime },
      width: cbiCollection.width ?? 24,
      height: cbiCollection.height ?? 24,
    })
  }

  const jitsi = simpleIconsCollection.icons?.jitsi
  if (jitsi) {
    addCollection({
      prefix: "simple-icons",
      icons: { jitsi },
      width: simpleIconsCollection.width ?? 24,
      height: simpleIconsCollection.height ?? 24,
    })
  }

  vcLogosRegistered = true
}
