'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { createContext, use, useCallback, useState } from 'react'; const AlternateLinksContext = /*#__PURE__*/ createContext(null); /** * Holds the current page's per-locale URLs so a LanguageSwitcher links to the * CORRECT localized slug instead of naively swapping the locale prefix * (/pl/uslugi → /en/uslugi, which 404s when the English slug is /en/services). * * Wrap the app once; each page reports its own alternates via * (or useSetAlternateLinks). The switcher reads them * with useAlternateLinks(). * * // layout.tsx * import { AlternateLinksProvider } from '@intecion/ipal-kit/client' * {children} */ export function AlternateLinksProvider({ children }) { const [links, setLinksState] = useState({}); const setLinks = useCallback((next)=>setLinksState(next), []); return /*#__PURE__*/ _jsx(AlternateLinksContext, { value: { links, setLinks }, children: children }); } /** Read the current page's per-locale URLs (for a language switcher). */ export function useAlternateLinks() { const ctx = use(AlternateLinksContext); return ctx?.links ?? {}; } /** Setter for the alternates (used by AlternateLinksUpdater). */ export function useSetAlternateLinks() { const ctx = use(AlternateLinksContext); return ctx?.setLinks ?? (()=>{}); } //# sourceMappingURL=AlternateLinksContext.js.map