import { ISidekickMenuItem } from "../types"; type ItemVisibilityMap = { [key: string]: "VISIBLE" | "HIDDEN" | "PENDING"; }; export interface LastPosition { /** Ids of the sections (from the root) containing the last activated item. */ path: string[]; /** The item that was activated, highlighted again on reopen. */ itemId: string; /** Location key (see `locationKey`) of the page the user ended up on, so a later open can tell * whether they've since moved to another page by some other route (link, bookmark, back button). */ url?: string; } /** Pathname plus hash route (when it looks like one, e.g. "#/settings"), ignoring query string. */ export declare const locationKey: (href: string, base?: string) => string | null; /** * Finds the leaf item whose `path` best matches the given location key: an exact match wins, * otherwise the longest item path that is a whole-segment prefix of it (so "/orders/42" matches * an "/orders" item, but "/ordersx" does not). "/" only ever matches exactly. Hidden items, and * items inside hidden sections, are skipped. */ export declare const findItemForLocation: (items: ISidekickMenuItem[], currentKey: string, itemVisibility: ItemVisibilityMap) => ISidekickMenuItem | null; /** * Decides where the menu should open. The stored position wins while the user is still on the * page they reached through it; once they've moved (via a link, bookmark, back button or router * call), the item matching the current URL wins; failing that, the stored position is the best guess. */ export declare const resolveOpenPosition: (items: ISidekickMenuItem[], stored: LastPosition | null, currentKey: string | null, itemVisibility: ItemVisibilityMap) => { path: string[]; itemId: string; } | null; export declare const readLastPosition: (storageNamespace?: string) => LastPosition | null; export declare const writeLastPosition: (items: ISidekickMenuItem[], item: ISidekickMenuItem, storageNamespace?: string) => void; /** * Returns the longest prefix of `path` that is still navigable: every id must exist as a child of * the previous section, have children, and not be hidden. Items get removed or permissioned away * between visits, so a path must never leave the user on a missing section. With `requireNonEmpty` * (used when restoring a stored path) sections with no visible children are also rejected, so a * restore never opens onto an empty panel. */ export declare const getValidPathPrefix: (items: ISidekickMenuItem[], path: string[], itemVisibility: ItemVisibilityMap, requireNonEmpty?: boolean) => string[]; export {};