{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-SADRZ4YI.cjs","../src/embed-shims/next-navigation.tsx"],"names":[],"mappings":"AAAA,yLAAY;AACZ;AACA;AC4CA,8BAAkE;AAiClE,IAAI,KAAA,EAAgC,CAAC,CAAA;AAO9B,SAAS,kBAAA,CAAmB,GAAA,EAAoC;AACrE,EAAA,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,GAAG,IAAI,CAAA;AAC3B;AAIA,IAAM,WAAA,EAAyB;AAAA,EAC7B,IAAA,EAAM,CAAA,EAAA,GAAM;AAAA,EAAC,CAAA;AAAA,EACb,OAAA,EAAS,CAAA,EAAA,GAAM;AAAA,EAAC,CAAA;AAAA,EAChB,IAAA,EAAM,CAAA,EAAA,GAAM;AAAA,EAAC,CAAA;AAAA,EACb,OAAA,EAAS,CAAA,EAAA,GAAM;AAAA,EAAC,CAAA;AAAA,EAChB,OAAA,EAAS,CAAA,EAAA,GAAM;AAAA,EAAC,CAAA;AAAA,EAChB,QAAA,EAAU,CAAA,EAAA,GAAM;AAAA,EAAC;AACnB,CAAA;AAaA,SAAS,YAAA,CAAa,IAAA,EAAc,IAAA,EAAgC;AAClE,EAAA,GAAA,CAAI,OAAO,OAAA,IAAW,WAAA,EAAa,MAAA;AACnC,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,EAAM,IAAI,GAAA,CAAI,IAAA,EAAM,MAAA,CAAO,QAAA,CAAS,IAAI,CAAA;AAC9C,IAAA,GAAA,CAAI,GAAA,CAAI,OAAA,IAAW,MAAA,CAAO,QAAA,CAAS,MAAA,EAAQ;AAGzC,MAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA;AAAA,MAAA,KAC/C,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAA;AACrC,MAAA,MAAA;AAAA,IACF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CAAA,CAAkB,CAAA;AAC7C;AAGO,IAAM,aAAA,EAAe;AAAA,EAC1B,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAA;AAQO,IAAM,0BAAA,EAA0F,IAAA;ADnIvG;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yYAAC","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-SADRZ4YI.cjs","sourcesContent":[null,"/**\n * `next/navigation` shim — environment-aware app-router hooks.\n *\n * Defaults to lightweight stubs backed by `window.location` and\n * `URLSearchParams` so lib components that read the URL work outside\n * a Next.js router shell. Next.js hosts can opt into the REAL\n * `next/navigation` exports (full client-router integration —\n * `router.replace(href, { scroll: false })`, etc.) by calling\n * {@link registerNavigation} ONCE at app init:\n *\n *   // hub: lib/embed-shim-registration.ts\n *   import {\n *     useRouter, usePathname, useSearchParams, useParams,\n *     redirect, permanentRedirect, notFound,\n *   } from 'next/navigation'\n *   import { registerNavigation } from '@flamingo-stack/openframe-frontend-core/embed-shims'\n *   registerNavigation({\n *     useRouter, usePathname, useSearchParams, useParams,\n *     redirect, permanentRedirect, notFound,\n *   })\n *\n * After registration, every exported hook in this file delegates to\n * the real implementation. Without registration, the stubs run:\n *\n *   - `useRouter()` → push/replace do a same-origin SPA navigation via the\n *     History API (`pushState`/`replaceState` + a synthetic `popstate`), so a\n *     query-param write never reloads the document; cross-origin/malformed\n *     hrefs fall back to `window.location`. back/forward use\n *     `history.back/forward`; refresh reloads; prefetch is a no-op.\n *   - `usePathname()` → returns `window.location.pathname` (popstate-\n *     subscribed so back/forward re-renders).\n *   - `useSearchParams()` → returns `URLSearchParams` view of\n *     `window.location.search` (popstate-subscribed).\n *   - `useParams()` → returns `{}` — embedders that need dynamic\n *     params should parse them from `usePathname()` themselves.\n *   - `notFound()` / `redirect()` / `permanentRedirect()` —\n *     best-effort equivalents using `window.location`.\n *\n * The fallback path subscribes to `popstate`. Native `pushState`/\n * `replaceState` do NOT fire popstate, but the fallback `useRouter`'s\n * push/replace dispatch a synthetic `popstate` so this file's own\n * `usePathname`/`useSearchParams` subscribers re-render. A URL mutated\n * through some OTHER API still won't auto-re-render here — embedders\n * that need that should register a real router or supply their own.\n */\n'use client';\nimport { useEffect, useState, type Context, type ReactNode } from 'react';\n\n// --- Router shape — matches Next's AppRouterInstance surface enough to\n// --- satisfy hub callsites that pass options like `{ scroll: false }`.\ninterface NavigateOptions {\n  scroll?: boolean;\n}\n\ninterface PrefetchOptions {\n  kind?: unknown;\n}\n\ninterface RouterStub {\n  push: (href: string, options?: NavigateOptions) => void;\n  replace: (href: string, options?: NavigateOptions) => void;\n  back: () => void;\n  forward: () => void;\n  refresh: () => void;\n  prefetch: (href: string, options?: PrefetchOptions) => void;\n}\n\n// --- Registration surface — partial so a host can register only the\n// --- hooks it needs (e.g. routes that don't use redirect()).\nexport interface NavigationImpl {\n  useRouter: () => RouterStub;\n  usePathname: () => string;\n  useSearchParams: () => URLSearchParams;\n  useParams: <T extends Record<string, string | string[]>>() => T;\n  redirect: (url: string, type?: unknown) => never;\n  permanentRedirect: (url: string, type?: unknown) => never;\n  notFound: () => never;\n}\n\nlet impl: Partial<NavigationImpl> = {};\n\n/**\n * Register real `next/navigation` exports. Merges with any prior\n * registration so partial-overrides are safe. Call ONCE at app init\n * in a Next.js host.\n */\nexport function registerNavigation(nav: Partial<NavigationImpl>): void {\n  impl = { ...impl, ...nav };\n}\n\n// --- Fallback impls ----------------------------------------------------\n\nconst noopRouter: RouterStub = {\n  push: () => {},\n  replace: () => {},\n  back: () => {},\n  forward: () => {},\n  refresh: () => {},\n  prefetch: () => {},\n};\n\n/**\n * SPA navigation for the unregistered fallback. Uses the History API instead of\n * `window.location.assign/replace` so a same-origin URL change (e.g. a table's\n * `?search=` write via `useApiParams`) never triggers a full document reload —\n * even if a real router was never registered, or the registration landed on a\n * DIFFERENT module instance than this one (duplicate lib copy / ESM-CJS dual\n * package). A synthetic `popstate` is dispatched so this file's own\n * `usePathname`/`useSearchParams` subscribers re-render in response.\n * Cross-origin or malformed hrefs still fall back to a real `window.location`\n * navigation, which is the only correct behavior there.\n */\nfunction softNavigate(href: string, mode: 'push' | 'replace'): void {\n  if (typeof window === 'undefined') return;\n  try {\n    const url = new URL(href, window.location.href);\n    if (url.origin !== window.location.origin) {\n      // Preserve the caller's history semantics: replace() must not leave a\n      // back-button entry, so it uses `location.replace`, not `location.assign`.\n      if (mode === 'push') window.location.assign(url.href);\n      else window.location.replace(url.href);\n      return;\n    }\n    if (mode === 'push') window.history.pushState(null, '', url.href);\n    else window.history.replaceState(null, '', url.href);\n    window.dispatchEvent(new PopStateEvent('popstate'));\n  } catch {\n    // Malformed href — a real navigation is safer than swallowing it, but still\n    // honor push vs replace history semantics.\n    if (mode === 'push') window.location.assign(href);\n    else window.location.replace(href);\n  }\n}\n\n// `useFallback*`, not `fallbackUse*`: two of these call hooks, and the\n// linter identifies a custom hook purely by the `use` PREFIX. Under the old\n// names `useLocationSubscription` looked like a hook called from a plain\n// function, which is the one shape the rules-of-hooks check cannot verify.\n// The whole family is renamed together so the set stays symmetric.\nfunction useFallbackRouter(): RouterStub {\n  if (typeof window === 'undefined') return noopRouter;\n  return {\n    push: (href: string) => softNavigate(href, 'push'),\n    replace: (href: string) => softNavigate(href, 'replace'),\n    back: () => window.history.back(),\n    forward: () => window.history.forward(),\n    refresh: () => window.location.reload(),\n    prefetch: () => {},\n  };\n}\n\nfunction readLocation<T>(read: () => T, fallback: T): T {\n  return typeof window === 'undefined' ? fallback : read();\n}\n\n/** Subscribes to `popstate` only. pushState/replaceState do NOT fire\n *  popstate by design — callers that mutate the URL programmatically\n *  (and want their component to re-render in response) need a real\n *  router. */\nfunction useLocationSubscription(): number {\n  const [tick, setTick] = useState(0);\n  useEffect(() => {\n    if (typeof window === 'undefined') return undefined;\n    const onChange = () => setTick(t => t + 1);\n    window.addEventListener('popstate', onChange);\n    return () => window.removeEventListener('popstate', onChange);\n  }, []);\n  return tick;\n}\n\nfunction useFallbackPathname(): string {\n  useLocationSubscription();\n  return readLocation(() => window.location.pathname, '/');\n}\n\nfunction useFallbackSearchParams(): URLSearchParams {\n  useLocationSubscription();\n  return readLocation(() => new URLSearchParams(window.location.search), new URLSearchParams());\n}\n\nfunction useFallbackParams<T extends Record<string, string | string[]>>(): T {\n  return {} as T;\n}\n\nfunction fallbackRedirect(url: string): never {\n  if (typeof window !== 'undefined') window.location.assign(url);\n  throw new Error(`[next-navigation shim] redirect(${url})`);\n}\n\nfunction fallbackPermanentRedirect(url: string): never {\n  if (typeof window !== 'undefined') window.location.replace(url);\n  throw new Error(`[next-navigation shim] permanentRedirect(${url})`);\n}\n\nfunction fallbackNotFound(): never {\n  throw new Error('[next-navigation shim] notFound()');\n}\n\n// --- Public surface — each export checks the registry and falls\n// --- through to the fallback. Hooks must remain hooks (no early-\n// --- return-before-hook) — the registry lookup is itself synchronous\n// --- and the registered impl is a hook in its own right.\n\nexport function useRouter(): RouterStub {\n  return (impl.useRouter ?? useFallbackRouter)();\n}\n\nexport function usePathname(): string {\n  return (impl.usePathname ?? useFallbackPathname)();\n}\n\nexport function useSearchParams(): URLSearchParams {\n  return (impl.useSearchParams ?? useFallbackSearchParams)();\n}\n\nexport function useParams<T extends Record<string, string | string[]>>(): T {\n  return ((impl.useParams as (() => T) | undefined) ?? useFallbackParams)();\n}\n\nexport function redirect(url: string, type?: unknown): never {\n  return (impl.redirect ?? fallbackRedirect)(url, type);\n}\n\nexport function permanentRedirect(url: string, type?: unknown): never {\n  return (impl.permanentRedirect ?? fallbackPermanentRedirect)(url, type);\n}\n\nexport function notFound(): never {\n  return (impl.notFound ?? fallbackNotFound)();\n}\n\n/** Match Next's RedirectType enum surface for code that imports it. */\nexport const RedirectType = {\n  push: 'push' as const,\n  replace: 'replace' as const,\n};\n\n/** Match Next's ServerInsertedHTMLContext surface — non-functional in\n *  the embed environment but importable so consumers don't crash.\n *\n *  Typed as the context Next exports rather than `any`: the value stays\n *  `null` (nothing to insert outside an SSR shell), and the declared type\n *  documents what a Next host would put here. */\nexport const ServerInsertedHTMLContext: Context<((callback: () => ReactNode) => void) | null> | null = null;\n"]}