export declare function resolveItemContextSource(element: HTMLElement): HTMLElement | Location; export declare function resolvePlacementItemContextSource(mountEl: HTMLElement, targetEl: HTMLElement): HTMLElement | Location; /** * Which node a PLACED save button should read its product from. * * `resolveItemContextSource` only understands two things: `data-product-*` on * the element, or an ``. A placement's target is whatever * CSS selector the merchant chose — usually neither, since a card's image * wrapper or a PDP's button row carry no product reference — and the button then * mounts with `product-id=""` and does nothing when clicked (SWI-2240). * * `context` is the placement's own `props.context`, injected per surface by the * customiser, and it decides the order of the two fallbacks. It has to: on a * product page, `findNearestElement` climbs to a shared ancestor and takes the * first product link in that whole subtree, which on a page with a * recommendations rail is a *recommended* product, not the page's. So a "pdp" * placement asks the page first. A "product-card" placement does the opposite — * the card's own link is the answer, and the page URL means nothing on a * collection page. */ export declare function resolveSaveButtonContextSource(mountEl: HTMLElement, targetEl: HTMLElement, context?: string): HTMLElement | Location; /** * Where a save element reads its product from. Three shapes because the three * ways a save button reaches a storefront genuinely differ: a PDP button reads * the page, a card button reads the card's link, and an explicit `product="123"` * carries ids and is neither a node nor a page. */ export type ProductRef = { kind: "location"; location: Location; } | { kind: "element"; el: HTMLElement; } | { kind: "ids"; productId: string; variantId?: string; }; /** * The branch order `SwishSaveElement.resolveContext` has always used, extracted * so the element and any reader of an EXISTING button on the page resolve that * button's product identically. * * Do not re-implement this order elsewhere. A hand-mirrored copy of it read the * `data-product-*` attributes first and fell through to "nearest product link" * for a `context="pdp"` button, which on a page carrying a recommendations rail * returns a RECOMMENDED product rather than the page's (see the note on * `resolveSaveButtonContextSource` below). The copy was confidently wrong and * silent, which is why there is one function now. * * Note the asymmetry with `resolveSaveButtonContextSource`, which is deliberate: * that one resolves a target a placement is about to mount on and DOES climb for * `pdp` (`productPage() ?? findProductLink(...)`), because a target selector * points at arbitrary markup. This one resolves an element that already declared * its own context, so `context="pdp"` means the page, full stop. */ export declare function resolveSaveElementRef(el: HTMLElement): ProductRef;