import { ComponentPluginFactory } from '@teleporthq/teleport-types'; interface AIChatLocalizedWelcomePluginConfig { /** Output path of the generator using this plugin: `['components']` / `['pages']`. */ basePath: string[]; } /** * Makes the AI chat component's welcome bubble follow the visitor's locale. * * ⛔ Why this is not the ordinary i18n path. Every other translated string in a * generated page is a text NODE, so the locale mapper rewrites it into * `translate.raw('key')` and next-intl resolves it per request. The welcome * message is not a node — it is the first entry of the `chatMessages` STATE, * whose initial value is a literal baked into `useState`. Nothing in the * existing pipeline can reach inside that literal, so the component gets an * explicit `useLocale()` and resolves the greeting through the generated * `lib/ai-chat/localized-messages` module instead. * * Emitted shape: * * const __aiChatLocale = useLocale() * const [chatMessages, setChatMessages] = useState( * localizeAIChatMessages([...], __aiChatLocale) * ) * useEffect(() => { * setChatMessages((prev) => localizeAIChatMessages(prev, __aiChatLocale)) * }, [__aiChatLocale]) * * The declaration is spliced in immediately BEFORE the state hook rather than * unshifted: several plugins unshift their own hooks, and a `useLocale()` that * landed after the `useState` reading it would be a temporal-dead-zone crash on * the first render. Splicing keeps the pair adjacent whatever else is prepended * later. * * The effect exists because a Next.js locale switch is a client-side route * change that keeps the same component mounted, so `useState`'s initializer — * which only ever runs once — would leave the greeting in the previous * language. It is a no-op on mount and whenever the visitor has already sent a * message: `localizeAIChatMessages` only rewrites an untouched `welcome_msg` * entry and returns the SAME array reference otherwise, so the functional * update cannot loop. */ export declare const createAIChatLocalizedWelcomePlugin: ComponentPluginFactory; export {}; //# sourceMappingURL=component-plugin.d.ts.map