{"version":3,"file":"VoiceGlow.mjs","names":[],"sources":["../../../../../src/plugins/AIComponents/VoiceVisualization/VoiceGlow.tsx"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { glowContains } from './hitArea';\nimport { createGlowWebGLRenderer } from './renderers/glowWebGLRenderer';\nimport type { VoiceGlowRendering, VoiceVisualizationProps } from './types';\nimport { VoiceGlowCss } from './VoiceGlowCss';\nimport { VoiceVisualizationView } from './VoiceVisualizationView';\n\nexport type VoiceGlowProps = VoiceVisualizationProps & {\n  /** How the glow is drawn. See `VoiceGlowRendering`. Defaults to `auto`. */\n  rendering?: VoiceGlowRendering;\n};\n\n/**\n * A voice agent as a soft, airy globe: color masses orbit inside it and swell with speech, and\n * the gaps between them let the background show through. Tapping the globe bounces it; drawn\n * with WebGL, it also ripples from the touch and under a hovering mouse or pen.\n *\n * It has no size of its own and draws in the middle of the box it is given, about half as wide\n * as its shorter side, so give it a square.\n */\nexport const VoiceGlow = ({\n  className,\n  rendering = 'auto',\n  ...props\n}: VoiceGlowProps) => {\n  // Set when WebGL cannot start or its context is lost; the CSS glow takes over from then on.\n  const [webGLFailed, setWebGLFailed] = useState(false);\n\n  const createRenderer = useCallback((canvas: HTMLCanvasElement) => {\n    const renderer = createGlowWebGLRenderer(canvas, () => setWebGLFailed(true));\n    if (!renderer) setWebGLFailed(true);\n    return renderer;\n  }, []);\n\n  if (rendering === 'css' || webGLFailed) {\n    return <VoiceGlowCss className={className} {...props} />;\n  }\n\n  return (\n    <VoiceVisualizationView\n      className={clsx('str-chat__ai-voice-glow', className)}\n      contains={glowContains}\n      createRenderer={createRenderer}\n      data-rendering='webgl'\n      // The glow is all soft gradients: drawn at 1x it looks the same as at 2x, with a quarter\n      // of the pixels to fill every frame.\n      maxPixelRatio={1}\n      rendererKey='webgl'\n      {...props}\n    />\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAa,aAAa,EACxB,WACA,YAAY,QACZ,GAAG,YACiB;CAEpB,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,iBAAiB,aAAa,WAA8B;EAChE,MAAM,WAAW,wBAAwB,cAAc,eAAe,IAAI,CAAC;EAC3E,IAAI,CAAC,UAAU,eAAe,IAAI;EAClC,OAAO;CACT,GAAG,CAAC,CAAC;CAEL,IAAI,cAAc,SAAS,aACzB,OAAO,oBAAC,cAAD;EAAyB;EAAW,GAAI;CAAQ,CAAA;CAGzD,OACE,oBAAC,wBAAD;EACE,WAAW,KAAK,2BAA2B,SAAS;EACpD,UAAU;EACM;EAChB,kBAAe;EAGf,eAAe;EACf,aAAY;EACZ,GAAI;CACL,CAAA;AAEL"}