def includeme(config):
    config.add_static_view("static", "static", cache_max_age=3600)
    config.add_route("favicon", "/favicon.ico")
    config.add_route("robots", "/robots.txt")
    config.add_route("version", "/version")

    # Sitemap and feed routes
    config.add_route("sitemap", "/sitemap.xml")
    config.add_route("rss", "/rss.xml")
    config.add_route("atom", "/atom.xml")
    config.add_route("feed_xml", "/feed.xml")
    config.add_route("feed_rss", "/feed.rss")
    config.add_route("feed_atom", "/feed.atom")

    # Subscription routes
    config.add_route("subscribe", "/subscribe")
    config.add_route("subscribe_verify", "/subscribe/verify/{token}")
    config.add_route("unsubscribe", "/unsubscribe/{token}")

    config.add_route("markup-editor-preview", "/markup-editor-preview")

    config.add_route("ask-for-on-demand-tls", "/ask-for-on-demand-tls")

    config.add_route("styleguide", "/styleguide")

    config.add_route("home", "/")
    config.add_route("search", "/search")

    config.add_route("log-out", "/log-out")
    config.add_route("join-or-log-in", "/join-or-log-in")
    config.add_route("verification-challenge", "/verification-challenge")

    # views with just a bunch of buttons to other pages.
    config.add_route("actions_view", "/actions/view")
    config.add_route("actions_new", "/actions/new")

    # billing routes.
    config.add_route("billing", "/billing")
    config.add_route("add-card", "/billing/add-card")
    config.add_route(
        "confirm-update-card", "/billing/confirm-update-card/{action}/{card_id}"
    )
    config.add_route("update-card", "/billing/update-card")
    config.add_route("disconnect-paypal", "/billing/disconnect-paypal")

    # PayPal routes
    config.add_route("paypal_create_order", "/paypal/create-order/{cart_id}")
    config.add_route("paypal_complete_checkout", "/paypal/complete-checkout/{cart_id}")

    # Adyen routes
    config.add_route("adyen_create_session", "/adyen/create-session/{cart_id}")
    config.add_route("adyen_complete_checkout", "/adyen/complete-checkout/{cart_id}")

    # Webhook routes
    config.add_route("paypal_webhook", "/webhooks/paypal")
    config.add_route("stripe_webhook", "/webhooks/stripe")
    config.add_route("adyen_webhook", "/webhooks/adyen")

    # user routes.
    config.add_route("user_settings", "/u/settings")
    config.add_route("user_crypto_settings", "/u/settings/crypto")
    config.add_route("user_crypto_settings_update", "/u/settings/crypto/{coin_type}")
    config.add_route("user_storage_settings", "/u/settings/storage")
    config.add_route("user_sandbox_upload", "/u/sandbox/upload")
    config.add_route("user_purchases", "/u/purchases")
    config.add_route("user_offers", "/u/offers")
    config.add_route("user_bids", "/u/bids")
    config.add_route("user_addresses", "/u/addresses")
    config.add_route("user_address_save", "/u/addresses/save")
    config.add_route("user_address_delete", "/u/addresses/{address_id}/delete")
    config.add_route("user_address_activate", "/u/addresses/{address_id}/activate")

    config.add_route("user_shops", "/u/shops")

    config.add_route("user_shop_activate", "/u/shop/{shop_id}/activate")

    config.add_route("user_cart_save", "/u/cart/save")
    config.add_route("user_carts", "/u/carts")
    config.add_route("user_cart_delete", "/u/cart/{cart_id}/delete")
    config.add_route("user_cart_activate", "/u/cart/{cart_id}/activate")

    config.add_route(
        "user_cart_complete_checkout", "/u/cart/{cart_id}/complete/checkout"
    )
    config.add_route("user_cart_checkout", "/u/cart/{cart_id}/checkout")

    config.add_route("user_cart_public", "/u/cart/{cart_id}/public")
    config.add_route("user_cart_unpublic", "/u/cart/{cart_id}/unpublic")

    # cart routes.
    config.add_route("cart", "/cart")
    config.add_route("cart_checkout", "/cart/checkout")

    config.add_route("cart_add_product", "/cart/add")
    config.add_route("cart_by_id", "/cart/{cart_id}")
    config.add_route("cart_remove_product", "/cart/{cart_id}/remove")
    config.add_route("cart_quantity_product", "/cart/{cart_id}/quantity")

    config.add_route("cart_handling_option", "/cart/{cart_id}/handling-option")

    config.add_route("view_invoice", "/invoice/{invoice_id}")
    config.add_route("view_invoice2", "/i/{invoice_id}")

    # coupon routes.
    config.add_route("coupon_new1", "/coupon/new")
    config.add_route("coupon_new2", "/s/{shop_id}/coupon/new")

    config.add_route("coupon_apply_to_cart", "/coupon/apply")
    config.add_route("coupon_remove_from_cart", "/coupon/remove")

    # gift card routes.
    config.add_route("gift_card_page", "/s/{shop_id}/gift-card")
    config.add_route("gift_card_add_to_cart", "/gift-card/add-to-cart")
    config.add_route("gift_card_apply_to_cart", "/gift-card/apply")
    config.add_route("gift_card_remove_from_cart", "/gift-card/remove")
    config.add_route("gift_card_manage", "/s/{shop_id}/gift-cards/manage")
    config.add_route("gift_card_detail", "/s/{shop_id}/gift-cards/{gift_card_id}")
    config.add_route("gift_card_toggle", "/s/{shop_id}/gift-cards/{gift_card_id}/toggle")

    config.add_route("coupons", "/s/{shop_id}/coupons")
    config.add_route("coupon1", "/s/{shop_id}/coupon/{coupon_id}")
    config.add_route("coupon2", "/s/{shop_id}/coupon/{coupon_id}/{slug:.*}")

    # shop_location routes.
    config.add_route("shop_location_new", "/s/locations/new")
    config.add_route("shop_location_edit", "/s/{shop_id}/locations/{location_id}/edit")
    config.add_route("shop_locations", "/s/locations")
    config.add_route(
        "shop_location_switch", "/s/{shop_id}/location/{location_id}/switch"
    )

    # shop routes.
    config.add_route("shop_new", "/s/new")

    config.add_route("shop", "/s/{shop_id}")
    config.add_route("shop_products", "/s/{shop_id}/products")

    config.add_route("shop_sales", "/s/{shop_id}/sales")
    config.add_route("shop_offers", "/s/{shop_id}/offers")
    config.add_route("shop_comments", "/s/{shop_id}/comments")
    config.add_route("shop_analytics", "/s/{shop_id}/analytics")
    config.add_route("product_analytics", "/s/{shop_id}/analytics/{product_id}")

    config.add_route("shop_settings", "/s/{shop_id}/settings")
    config.add_route(
        "crypto_processor_settings", "/s/{shop_id}/crypto-processor/{coin_type}"
    )

    config.add_route("shop_users", "/s/{shop_id}/users")
    config.add_route("shop_user_remove", "/s/{shop_id}/remove-user")

    config.add_route("shop_terms_of_service", "/s/terms")
    config.add_route("shop_terms_of_service2", "/s/{shop_id}/terms")
    config.add_route("shop_edit_terms_of_service", "/s/{shop_id}/terms/edit")

    config.add_route("shop_privacy_policy", "/s/privacy-policy")
    config.add_route("shop_privacy_policy2", "/s/{shop_id}/privacy-policy")
    config.add_route("shop_edit_privacy_policy", "/s/{shop_id}/privacy-policy/edit")

    config.add_route("shop_about", "/s/{shop_id}/about")
    config.add_route("shop_about_slug", "/s/{shop_id}/{slug:.*}/about")

    config.add_route("discovery_ring_json", "/s/{shop_id}/ring.json")
    config.add_route("discovery_ring_health", "/s/{shop_id}/ring/health.json")
    config.add_route("shop_slug", "/s/{shop_id}/{slug:.*}")

    # content routes.
    config.add_route("content_new", "/c/new")
    config.add_route("content", "/c/{content_id}")
    config.add_route("content_edit", "/c/{product_id}/edit")
    config.add_route("content_description_edit", "/c/{product_id}/description/edit")
    config.add_route("content_edit2", "/c/{product_id}/{slug:.*}/edit")
    config.add_route("content_slug", "/c/{product_id}/{slug:.*}")

    # product routes.
    config.add_route("product_new", "/p/new")
    config.add_route("product", "/p/{product_id}")
    config.add_route("product_description_edit", "/p/{product_id}/description/edit")
    config.add_route("product_inventory_edit", "/p/{product_id}/inventory/edit")
    config.add_route("product_bundle_edit", "/p/{product_id}/bundle/edit")
    config.add_route("product_bundle_edit2", "/p/{product_id}/{slug:.*}/bundle/edit")
    config.add_route(
        "product_remove_bundled_product",
        "/p/{product_id}/bundle/remove/{bundled_product_id}",
    )

    config.add_route("product_edit", "/p/{product_id}/edit")
    config.add_route("product_edit2", "/p/{product_id}/{slug:.*}/edit")
    # Offer entry point — must register before product_slug catch-all (MPS-21).
    config.add_route("offer_open",   "/p/{product_id}/offer")
    config.add_route("product_slug", "/p/{product_id}/{slug:.*}")

    # media player routes
    config.add_route("player", "/player/{product_id}")
    config.add_route("player_json", "/player/{product_id}/json")
    config.add_route("watch_json", "/watch/{product_id}/json")
    config.add_route("karaoke_process", "/karaoke/{product_id}")
    config.add_route("random", "/random")
    config.add_route("tv", "/tv")

    # signal routes.
    config.add_route("signals_beacon", "/signals/beacon")

    # comment routes.
    config.add_route("comment_new", "/comments/new")
    config.add_route("comment_reply", "/comments/{comment_id}/reply")
    config.add_route("comment_edit", "/comments/{comment_id}/edit")
    config.add_route("comment_delete", "/comments/{comment_id}/delete")
    config.add_route("comment_undelete", "/comments/{comment_id}/undelete")
    config.add_route("comment_approve", "/comments/{comment_id}/approve")
    config.add_route("comment_unapprove", "/comments/{comment_id}/unapprove")

    # cryptocurrency payment routes.
    config.add_route("crypto_xmr_start", "/crypto/xmr/start")
    config.add_route("crypto_xmr_status", "/crypto/xmr/status/{payment_id}")
    config.add_route("crypto_doge_start", "/crypto/doge/start")
    config.add_route("crypto_doge_status", "/crypto/doge/status/{payment_id}")
    config.add_route("crypto_quote", "/crypto/quote/{payment_id}")
    config.add_route("crypto_cancel", "/crypto/cancel/{payment_id}")
    config.add_route("crypto_quotes_history", "/u/crypto-quotes")
    config.add_route("crypto_debug_wallet_scan", "/crypto/debug/wallet-scan")

    # REST API v1 — HMAC-signed
    config.add_route("api_v1_products",              "/api/v1/products")
    config.add_route("api_v1_product",               "/api/v1/products/{product_id}")
    config.add_route("api_v1_product_upload_url",    "/api/v1/products/{product_id}/upload-url")
    config.add_route("api_v1_product_confirm",       "/api/v1/products/{product_id}/files/confirm")
    config.add_route("api_v1_content",               "/api/v1/content")
    config.add_route("api_v1_content_item",          "/api/v1/content/{content_id}")
    config.add_route("api_v1_content_upload_url",    "/api/v1/content/{content_id}/upload-url")
    config.add_route("api_v1_content_confirm",       "/api/v1/content/{content_id}/files/confirm")

    # Shop API key management
    config.add_route("shop_api_keys_generate",         "/s/{shop_id}/api-keys/generate")
    config.add_route("shop_api_key_revoke",            "/s/{shop_id}/api-keys/{key_id}/revoke")

    # Torrent backfill progress
    config.add_route("shop_torrent_backfill_status",   "/s/{shop_id}/torrent-backfill-status")

    # Checksum backfill
    config.add_route("shop_checksum_backfill",         "/s/{shop_id}/checksum-backfill")
    config.add_route("shop_checksum_backfill_status",  "/s/{shop_id}/checksum-backfill-status")

    # Auctions (MPS-20). Register .json route BEFORE the bare-id route so
    # /a/{id}.json matches the JSON view; otherwise {auction_id} would
    # greedily match "abc.json" and shadow the JSON endpoint.
    config.add_route("auction_json",     "/a/{auction_id}.json")
    config.add_route("auction_events",   "/a/{auction_id}/events")
    config.add_route("auction_bid",      "/a/{auction_id}/bid")
    config.add_route("auction_buy_now",  "/a/{auction_id}/buy-now")
    config.add_route("auction_watch",    "/a/{auction_id}/watch")
    config.add_route("auction_checkout", "/a/{auction_id}/checkout")
    config.add_route("auction_page",     "/a/{auction_id}")

    # Offers (MPS-21). offer_open is registered earlier near product routes
    # to avoid shadow by product_slug. /o/{id}/* sub-paths first, bare last.
    config.add_route("offer_events",     "/o/{offer_id}/events")
    config.add_route("offer_counter",    "/o/{offer_id}/counter")
    config.add_route("offer_accept",     "/o/{offer_id}/accept")
    config.add_route("offer_decline",    "/o/{offer_id}/decline")
    config.add_route("offer_withdraw",   "/o/{offer_id}/withdraw")
    config.add_route("offer_cancel_after_accept", "/o/{offer_id}/cancel")
    config.add_route("offer_checkout",   "/o/{offer_id}/checkout")
    config.add_route("offer_page",       "/o/{offer_id}")

    # Public user profile. Lives under /profile/{name} (not /u/{name}) so it
    # can never shadow the many specific /u/... routes. The email address is
    # only revealed to a shop owner/editor viewing in that shop's context
    # (?shop={shop_id}) when the profile user has actually transacted there.
    config.add_route("user_profile",     "/profile/{user_name}")
