from __future__ import annotations
from html import escape
from typing import Any
from urllib.parse import urlencode
from render import layout, money, selected_options_markup
WISHLIST_INTRO_PATH = "/hz/wishlist/intro"
WISHLIST_INDEX_PATH = "/hz/wishlist/ls"
WISHLIST_CREATE_PATH = "/hz/wishlist/create"
WISHLIST_RENAME_PATH = "/hz/wishlist/rename"
WISHLIST_DELETE_PATH = "/hz/wishlist/delete"
WISHLIST_ADD_CHOOSER_PATH = "/hz/wishlist/add"
WISHLIST_ADD_ITEM_PATH = "/hz/wishlist/add-item"
WISHLIST_REMOVE_ITEM_PATH = "/hz/wishlist/remove-item"
WISHLIST_MOVE_TO_CART_PATH = "/hz/wishlist/move-to-cart"
WISHLIST_ASSET_ROOT = (
"/static/assets/source-current/2026-07-22/lists-intro"
)
WISHLIST_STYLESHEET = "/static/wishlist.css?v=20260722-1"
def _wishlist_layout(
title: str,
body: str,
cart_count: int,
*,
account_name: str | None = None,
body_class: str = "",
) -> str:
return layout(
title,
body,
cart_count,
account_name=account_name,
body_class=f"wishlist-surface {body_class}".strip(),
extra_head=(
f''
),
)
def _signin_href(return_to: str = WISHLIST_INDEX_PATH) -> str:
query = urlencode({"openid.return_to": return_to})
return f"/ap/signin?{escape(query, quote=True)}"
def _detail_href(list_id: int | str) -> str:
query = urlencode({"listID": str(list_id)})
return f"{WISHLIST_INDEX_PATH}?{escape(query, quote=True)}"
def wishlist_entry_form(
product: dict[str, Any],
selected_options: dict[str, str],
*,
button_label: str = "Add to List",
css_class: str = "add-to-list-form",
) -> str:
"""Build the PDP/search entry form that opens the authenticated chooser.
``data-product-option-field`` lets the existing PDP option controller keep
this form's complete selection synchronized with visible variant controls.
The form deliberately contains no browser-supplied price or offer metadata.
"""
asin = escape(str(product["asin"]), quote=True)
option_fields = "".join(
f''
for label, value in selected_options.items()
)
return f"""
"""
def wishlist_intro_page(cart_count: int) -> str:
"""Render the anonymous Your Lists introduction at desktop and mobile widths."""
signin_href = _signin_href()
desktop_benefits = (
(
"save-money.png",
"Save money",
"Keep products together and check back when prices change.",
),
(
"shop-with-friends.png",
"Shop with friends",
"Keep gift ideas together for birthdays, holidays, and everyday shopping.",
),
(
"stay-organized.png",
"Stay organized",
"Build as many lists as you need and find every saved item quickly.",
),
)
desktop_benefit_markup = "".join(
f"""
{escape(title)}
{escape(copy)}
"""
for image_name, title, copy in desktop_benefits
)
desktop_registries = (
(
"baby-registry.jpg",
"Baby Registry",
"Get ready for your new arrival with everything in one place.",
"/gp/browse.html?node=16115931011",
),
(
"wedding-registry.jpg",
"Wedding Registry",
"Create a registry that makes gifting simple for everyone.",
"/gp/browse.html?node=16115931011",
),
(
"custom-gift.jpg",
"Gift List",
"Save gift ideas for birthdays, holidays, and other celebrations.",
"/gp/browse.html?node=16115931011",
),
)
desktop_registry_markup = "".join(
f"""
{escape(title)}{escape(copy)}
"""
for image_name, title, copy, href in desktop_registries
)
mobile_benefits = (
("Save time", "Add products now and come back whenever you're ready."),
("Give great gifts", "Keep thoughtful gift ideas together in one place."),
("Check price changes", "See the latest offer each time you open your list."),
("Check current deals", "Keep your favorite products together for easy deal checking."),
)
mobile_benefit_markup = "".join(
f"""
✓
{escape(title)}
{escape(copy)}
"""
for title, copy in mobile_benefits
)
body = f"""
Lists & Registries
Save products you love, keep ideas organized, and plan gifts for the people who matter.