import { IkasThemePageType } from "../storefront-models/src"; /** * Router class for client-side navigation in ikas storefronts. * Provides methods for programmatic navigation and URL management. * * @ai-category Navigation * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * // Navigate to a URL * Router.navigate("/products/my-product"); * * // Navigate to a specific page type * Router.navigateToPage("CART"); * Router.navigateToPage("PRODUCT", "my-product-slug"); * * // Go back * Router.goBack(); * * // Get current path * const currentPath = Router.getCurrentPath(); * ``` */ export declare class Router { private static currentPath; private static observers; private static pageParams; static isFromBFCache: boolean; static window: Window; static initialize(pageParams: Record, _window?: Window): void; /** * Navigate to a URL path. * * @ai-category Navigation * @ai-related navigateToPage, goBack, getCurrentPath * * @param path - The URL path to navigate to * @param shallow - If true, only update URL without full navigation (default: false) * @param newTab - If true, open in a new browser tab (default: false) * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * // Basic navigation * Router.navigate("/products/my-product"); * * // Shallow navigation (URL change only, no page reload) * Router.navigate("/products/my-product?color=red", true); * * // Open in new tab * Router.navigate("/products/my-product", false, true); * ``` */ static navigate(path: string, shallow?: boolean, newTab?: boolean): void; /** * Navigate to a specific page type with optional slug and query parameters. * * @ai-category Navigation * @ai-related navigate, goBack * * @param pageType - The type of page to navigate to. Typed as `IkasThemePageType`. * @param slug - Optional slug for pages that require it (e.g., product slug, order ID) * @param queryParams - Optional query parameters to add to the URL * @param shallow - If true, only update URL without full navigation (default: false) * @param newTab - If true, open in a new browser tab (default: false) * * Accepted page types (`IkasThemePageType`): INDEX, ACCOUNT, ADDRESSES, FAVORITE_PRODUCTS, * FORGOT_PASSWORD, LOGIN, REGISTER, ORDERS, ORDER_DETAIL, BLOG_INDEX, BLOG, BLOG_CATEGORY, * CART, CHECKOUT, CUSTOM, RAFFLE, RAFFLE_DETAIL, SEARCH, NOT_FOUND. * * TypeScript note: `pageType` is typed as `IkasThemePageType`, not `string`. If you are * passing a value that TypeScript infers as `string` (e.g. from a lookup map keyed by tab * name), cast with `as IkasThemePageType` or type the source map with `Record<..., IkasThemePageType>`. * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * // Go to cart * Router.navigateToPage("CART"); * * // Go to login with redirect * Router.navigateToPage("LOGIN", undefined, { redirect: "/account" }); * * // Go to order detail * Router.navigateToPage("ORDER_DETAIL", "order-123"); * * // Go to search with query * Router.navigateToPage("SEARCH", undefined, { q: "shoes" }); * * // Go to checkout * Router.navigateToPage("CHECKOUT"); * ``` */ static navigateToPage(pageType: IkasThemePageType, slug?: string, queryParams?: Record, shallow?: boolean, newTab?: boolean): void; static addObserver(callback: (path: string) => void): void; static removeObserver(callback: (path: string) => void): void; /** * Navigate back to the previous page in browser history. * * @ai-category Navigation * @ai-related navigate, navigateToPage * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * function BackButton() { * return ( * * ); * } * ``` */ static goBack(): void; /** * Get the current URL path. * * @ai-category Navigation * @ai-related navigate, getPageParams * * @returns The current path string (e.g., "/products/my-product") * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * function CurrentPathDisplay() { * const path = Router.getCurrentPath(); * return Current page: {path}; * } * ``` */ static getCurrentPath(): string; /** * Get the current page parameters (route params). * * @ai-category Navigation * @ai-related getCurrentPath * * @returns Object containing page parameters * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * // On a product page, get the product slug * const params = Router.getPageParams(); * console.log(params.slug); // "my-product-slug" * ``` */ static getPageParams(): Record; /** * Get the current URL query parameters as an object. * * @ai-category Navigation * @ai-related getCurrentPath, getPageParams * * @returns Object containing query parameters parsed from the current URL * * @example * ```typescript * import { Router } from "@ikas/bp-storefront"; * * // URL: /search?q=shoes&color=red * const query = Router.router_getQueryParams(); * console.log(query.q); // "shoes" * console.log(query.color); // "red" * ``` */ static router_getQueryParams(): Record; private static handleRouteChange; private static handlePopState; private static interceptAnchorClicks; private static notifyObservers; private static ensurePathPrefix; } export declare const router: Router; /** * Put the visitor's storefront routing in front of a path you wrote yourself. * * Entity links (`getProductHref`, `getIkasOrderHref`, …) and LINK props already carry the prefix. * A literal path in your own markup does not: `href="/cart"` sends a visitor browsing `/en` to the * default language. Wrap it, and a store with no extra routings gets the path back unchanged. * * Idempotent — a path that already starts with a supported routing segment is returned as-is. * Anything that is not a path on this storefront — an absolute URL, `mailto:`, `tel:` — is returned * untouched, so a merchant-authored prop can be wrapped without checking it first. * * @ai-category Navigation * @ai-related navigate, navigateToPage * * @param path - A path on this storefront, starting with `/` * @returns The path under the current routing (e.g. `/cart` → `/en/cart`) * * @example * ```tsx * import { Router, withRoutePrefix } from "@ikas/bp-storefront"; * * // Correct href for crawlers, middle-click and open-in-new-tab... * { * e.preventDefault(); * Router.navigateToPage("CART"); // ...and this prefixes on its own. * }}>Cart * ``` */ export declare function withRoutePrefix(path: string): string;