File size: 1,321 Bytes
3b780fb
03644bc
3d4392e
3b780fb
 
 
 
8919651
03644bc
3d4392e
6215321
 
3b780fb
6215321
 
 
 
 
 
3d4392e
3b780fb
 
3d4392e
 
09a7c47
 
 
 
 
 
 
03644bc
6215321
 
 
09a7c47
3d4392e
 
6215321
 
3d4392e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 (
    <Main latentMedia={latentMedia} jwtToken={jwtToken} />
  )
}