import { encode, decode } from 'js-base64' import { clapToDataUri } from "@aitube/clap" import { LatentQueryProps } from "@/types/general" import { Main } from "../../main" import { getNewMediaInfo } from "../../api/generators/search/getNewMediaInfo" import { getToken } from "../../api/v1/auth/getToken" import { generateClapFromPrompt } from '@/components/interface/latent-engine/core/generateClapFromPrompt' // https://jmswrnr.com/blog/protecting-next-js-api-routes-query-parameters export default async function LatentSearchPage({ searchParams: { l: latentContent, }, ...rest }: LatentQueryProps) { const jwtToken = await getToken({ user: "anonymous" }) // const latentSearchResult = JSON.parse(decodee(`${latentContent}`)) as LatentSearchResult // this will hallucinate the thumbnail on the fly - maybe we should cache it // const latentMedia = await searchResultToMediaInfo(latentSearchResult) // TODO: generate the clap from the media info console.log("generating a mock media info and mock clap file") const latentMedia = getNewMediaInfo() latentMedia.clapUrl = await clapToDataUri( generateClapFromPrompt({ showIntroPoweredByEngine: false, showIntroDisclaimerAboutAI: false }) ) return (
) }