@aglyn/plugins-commerce 1.31.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +4 -0
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +35 -15
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/commerce-console-page.js +6 -0
  6. package/src/lib/components/commerce-console-page.js.map +1 -1
  7. package/src/lib/components/console/currencies-card.component.d.ts +21 -0
  8. package/src/lib/components/console/currencies-card.component.js +408 -0
  9. package/src/lib/components/console/currencies-card.component.js.map +1 -0
  10. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  11. package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
  12. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  13. package/src/lib/components/console/product-editor-dialog.component.js +42 -1
  14. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  15. package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
  16. package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
  17. package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
  18. package/src/lib/components/console/reservations-card.component.js +32 -15
  19. package/src/lib/components/console/reservations-card.component.js.map +1 -1
  20. package/src/lib/components/console/shipping-settings-card.component.js +337 -10
  21. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  22. package/src/lib/components/console/store-settings-card.component.js +1 -1
  23. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  24. package/src/lib/components/console/use-currency-setup.d.ts +20 -0
  25. package/src/lib/components/console/use-currency-setup.js +61 -0
  26. package/src/lib/components/console/use-currency-setup.js.map +1 -0
  27. package/src/lib/components/currency-selector.d.ts +36 -0
  28. package/src/lib/components/currency-selector.js +157 -0
  29. package/src/lib/components/currency-selector.js.map +1 -0
  30. package/src/lib/components/product-add-ons.d.ts +9 -1
  31. package/src/lib/components/product-add-ons.js +8 -4
  32. package/src/lib/components/product-add-ons.js.map +1 -1
  33. package/src/lib/components/product-choice-cards.d.ts +13 -1
  34. package/src/lib/components/product-choice-cards.js +5 -4
  35. package/src/lib/components/product-choice-cards.js.map +1 -1
  36. package/src/lib/components/product-detail.d.ts +8 -0
  37. package/src/lib/components/product-detail.js +38 -11
  38. package/src/lib/components/product-detail.js.map +1 -1
  39. package/src/lib/components/product-grid.d.ts +2 -0
  40. package/src/lib/components/product-grid.js +22 -9
  41. package/src/lib/components/product-grid.js.map +1 -1
  42. package/src/lib/components/related-products.js +6 -2
  43. package/src/lib/components/related-products.js.map +1 -1
  44. package/src/lib/components/shopper-currency.d.ts +108 -0
  45. package/src/lib/components/shopper-currency.js +262 -0
  46. package/src/lib/components/shopper-currency.js.map +1 -0
  47. package/src/lib/components/wishlist.js +7 -1
  48. package/src/lib/components/wishlist.js.map +1 -1
  49. package/src/lib/declarations.server.js +39 -0
  50. package/src/lib/declarations.server.js.map +1 -1
  51. package/src/lib/model/commerce-currency-setup.d.ts +79 -0
  52. package/src/lib/model/commerce-currency-setup.js +124 -0
  53. package/src/lib/model/commerce-currency-setup.js.map +1 -0
  54. package/src/lib/model/commerce-currency.d.ts +215 -0
  55. package/src/lib/model/commerce-currency.js +511 -0
  56. package/src/lib/model/commerce-currency.js.map +1 -0
  57. package/src/lib/model/commerce-orders.d.ts +17 -0
  58. package/src/lib/model/commerce-orders.js +10 -5
  59. package/src/lib/model/commerce-orders.js.map +1 -1
  60. package/src/lib/model/commerce-record-routes.js +26 -1
  61. package/src/lib/model/commerce-record-routes.js.map +1 -1
  62. package/src/lib/model/commerce-reservations.d.ts +6 -0
  63. package/src/lib/model/commerce-reservations.js.map +1 -1
  64. package/src/lib/model/commerce-shipping.d.ts +66 -11
  65. package/src/lib/model/commerce-shipping.js +91 -7
  66. package/src/lib/model/commerce-shipping.js.map +1 -1
  67. package/src/lib/model/commerce.d.ts +6 -0
  68. package/src/lib/model/commerce.js.map +1 -1
  69. package/src/lib/model/index.d.ts +2 -0
  70. package/src/lib/model/index.js +2 -0
  71. package/src/lib/model/index.js.map +1 -1
  72. package/src/lib/model/order-figures.js +9 -2
  73. package/src/lib/model/order-figures.js.map +1 -1
  74. package/src/lib/model/product-modifiers.d.ts +5 -0
  75. package/src/lib/model/product-modifiers.js.map +1 -1
  76. package/src/lib/model/store-setup-content.js +23 -2
  77. package/src/lib/model/store-setup-content.js.map +1 -1
  78. package/src/lib/server/billing-webhook.js +37 -24
  79. package/src/lib/server/billing-webhook.js.map +1 -1
  80. package/src/lib/server/carrier-shipping.d.ts +2 -0
  81. package/src/lib/server/carrier-shipping.js +8 -4
  82. package/src/lib/server/carrier-shipping.js.map +1 -1
  83. package/src/lib/server/cart-checkout.js +74 -13
  84. package/src/lib/server/cart-checkout.js.map +1 -1
  85. package/src/lib/server/cart.d.ts +12 -0
  86. package/src/lib/server/cart.js +50 -4
  87. package/src/lib/server/cart.js.map +1 -1
  88. package/src/lib/server/catalog.d.ts +5 -0
  89. package/src/lib/server/catalog.js +7 -0
  90. package/src/lib/server/catalog.js.map +1 -1
  91. package/src/lib/server/checkout.js +53 -12
  92. package/src/lib/server/checkout.js.map +1 -1
  93. package/src/lib/server/currency.d.ts +93 -0
  94. package/src/lib/server/currency.js +182 -0
  95. package/src/lib/server/currency.js.map +1 -0
  96. package/src/lib/server/order-notifications.js +4 -2
  97. package/src/lib/server/order-notifications.js.map +1 -1
  98. package/src/lib/server/product.d.ts +9 -0
  99. package/src/lib/server/product.js +12 -0
  100. package/src/lib/server/product.js.map +1 -1
  101. package/src/lib/server/refund.js +3 -3
  102. package/src/lib/server/refund.js.map +1 -1
  103. package/src/lib/server/site-chat-tools.d.ts +22 -0
  104. package/src/lib/server/site-chat-tools.js +369 -0
  105. package/src/lib/server/site-chat-tools.js.map +1 -0
  106. package/src/lib/server/site-chat-visitor.d.ts +24 -0
  107. package/src/lib/server/site-chat-visitor.js +39 -0
  108. package/src/lib/server/site-chat-visitor.js.map +1 -0
  109. package/src/lib/server/site-offers.d.ts +31 -0
  110. package/src/lib/server/site-offers.js +91 -0
  111. package/src/lib/server/site-offers.js.map +1 -0
  112. package/src/lib/server/stays-site-search.d.ts +20 -0
  113. package/src/lib/server/stays-site-search.js +78 -0
  114. package/src/lib/server/stays-site-search.js.map +1 -0
  115. package/src/lib/server.js +20 -0
  116. package/src/lib/server.js.map +1 -1
  117. package/src/lib/site-chat-tool-definitions.d.ts +26 -0
  118. package/src/lib/site-chat-tool-definitions.js +141 -0
  119. package/src/lib/site-chat-tool-definitions.js.map +1 -0
  120. package/src/lib/site.js +8 -0
  121. package/src/lib/site.js.map +1 -1
  122. package/src/lib/subprocessors.js +7 -0
  123. package/src/lib/subprocessors.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-detail.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { advertisingConsentField } from '@aglyn/aglyn/app-utils/advertising-consent'\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n buildBeginCheckoutParams,\n trackEvent,\n trackEventBeforeNavigation,\n type AnalyticsItem,\n} from '@aglyn/aglyn/app-utils/analytics-events'\nimport { isPaymentsNotConfigured } from '@aglyn/aglyn/app-utils/payments-configured'\nimport { storefrontPaymentsNotConfiguredText } from '../constants/storefront-payments'\nimport * as CommerceModel from '../model'\nimport { mdiTagOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Chip from '@mui/material/Chip'\nimport MenuItem from '@mui/material/MenuItem'\nimport Skeleton from '@mui/material/Skeleton'\nimport TextField from '@mui/material/TextField'\nimport ToggleButton from '@mui/material/ToggleButton'\nimport ToggleButtonGroup from '@mui/material/ToggleButtonGroup'\nimport Typography from '@mui/material/Typography'\nimport {\n Children,\n Suspense,\n forwardRef,\n lazy,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { useStorefrontPurchaseEvent } from '../utils/use-storefront-purchase-event'\nimport { addToCart } from '../utils/add-to-cart'\nimport { CartFulfillmentChoice, useCartFulfillment } from './cart-fulfillment'\nimport {\n HardwareTermsConsent,\n hardwareTermsAnswered,\n NO_HARDWARE_TERMS_ANSWER,\n type HardwareTermsAnswer,\n} from './hardware-terms-consent'\nimport { ID as PRODUCT_REVIEWS_ID } from './product-reviews'\nimport { ID as RELATED_PRODUCTS_ID } from './related-products'\nimport { readLocalWishlist, toggleWishlist } from './wishlist'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\nimport { CheckoutReturnNotice } from './checkout-return-notice'\nimport { zonedDayKey } from '@aglyn/shared-util-timestamp/zoned-time'\n\n/**\n * The Payment Element (AGL-1944), behind a lazy boundary rather than a plain\n * import. Stripe.js and its React wrapper are a large dependency, the flag is\n * OFF, and a static import would put the whole SDK into the bundle of every\n * product page on every published site to serve a code path no shopper reaches.\n * Split, it is fetched by the shoppers who actually get the in-page form.\n */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'product-detail'\n\nexport interface ProductDetailProps {\n /** Product slug; blank resolves from /products/{slug} in the URL. */\n slug?: string\n buyLabel?: string\n /** Hide the description block (design it separately with tokens). */\n hideDescription?: boolean\n /** Offer a discount/coupon code field before the buy button. */\n showCoupon?: boolean\n /**\n * A \"Details\" panel under the description: the facts the product record\n * holds — its kind (digital, service), the choices it comes in, the\n * selected variant's SKU, its tags. Never a fact the record does not hold.\n * Off by default, so a page that already places this block keeps its shape.\n */\n showDetails?: boolean\n /**\n * A \"Shipping & returns\" panel: how it is delivered (shipping priced at\n * checkout, or delivered digitally), and the store's own return window\n * when the store takes returns of this kind of product. Off by default.\n */\n showShipping?: boolean\n /**\n * How the shopper picks options and add-ons (AGL-4205): `menus`, the\n * drop-downs and check boxes every page had, or `cards`, the product\n * builder — a picture card per choice with its price and note, combos that\n * fold out what they include, and a running total. Absent reads as menus,\n * so no existing page changes shape.\n */\n choiceStyle?: 'menus' | 'cards'\n /** The free-mockup button's words (AGL-4205); \"Get a free mockup\" when blank. */\n mockupLabel?: string\n /**\n * What the site builder dropped into the block (AGL-4205): the request\n * form a free mockup opens. Shown only for a product that offers mockups.\n */\n children?: ReactNode\n}\n\ninterface DetailVariant {\n id: string\n options?: Record<string, string>\n /** `null` while the product is listed before it has a price (AGL-3676). */\n priceUsd: number | null\n compareAtPriceUsd?: number\n soldOut: boolean\n imageUrl?: string\n sku?: string\n /** The buyer may choose the day they will use it (AGL-4043). */\n asksUseDate?: true\n /** A short line on the variant's picture card (AGL-4205). */\n note?: string\n}\n\n/** What the page says where a variant with no price yet would show one (AGL-3676). */\nconst PRICE_COMING_SOON_LABEL = 'Price coming soon'\n\ninterface Detail {\n id: string\n name: string\n slug: string\n description?: string\n type?: CommerceModel.ProductType\n tags?: string[]\n mediaUrls: string[]\n options: CommerceModel.ProductOption[]\n variants: DetailVariant[]\n /** Recurring billing (AGL-303); framing + buyer choice on the PDP. */\n subscription?: { interval: 'month' | 'year'; trialDays?: number }\n /** Buyer picks one-time or subscribe at the same price (AGL-545). */\n subscriptionOptional?: boolean\n /** The store's time zone, when a variant asks for a use day (AGL-4043). */\n useDayTimeZone?: string\n /**\n * The add-ons the page offers (AGL-4100): only groups shown on the\n * website ever arrive here.\n */\n modifierGroups?: CommerceModel.ProductModifierGroup[]\n /** The page offers \"Get a free mockup\" (AGL-4205). */\n mockupRequests?: true\n}\n\n/**\n * The use-day picker (AGL-4043), in its own chunk: only a product whose\n * variant asks for a day downloads the date picker.\n */\nconst UseDayPicker = lazy(() => import('./use-day-picker'))\n\n/**\n * The add-on pickers (AGL-4100), in their own chunk: only a product with\n * add-ons on the website downloads them.\n */\nconst ProductAddOns = lazy(() => import('./product-add-ons'))\n\n/**\n * The picture cards (AGL-4205), in their own chunk: only a page set to show\n * its choices as cards downloads them.\n */\nconst ProductChoiceCards = lazy(() => import('./product-choice-cards'))\n\n/**\n * The free mockup's button and the request form it opens (AGL-4205), in their\n * own chunk: only a product that offers one, or the canvas, downloads it.\n */\nconst ProductBuilderMockup = lazy(() => import('./product-builder-mockup'))\n\n/** The back-in-stock alert, only on a sold-out variant (split out for AGL-4205). */\nconst ProductRestockNotify = lazy(() => import('./product-restock-notify'))\n\n/** The Details and Shipping & returns folds (AGL-4205: split out), only where switched on. */\nconst ProductDetailPanels = lazy(() => import('./product-detail-panels'))\n\n/** Money on the product page, in the store's currency: `$1,250.00`, never `$1250`. */\nconst money = (cents: number) => CommerceModel.formatOrderMoney(cents)\n\n/** A price in dollars as the page prints it. */\nconst moneyFromUsd = (priceUsd: number) => money(Math.round(priceUsd * 100))\n\nconst SAMPLE: Detail = {\n id: 'sample',\n name: 'Sample product',\n slug: '#',\n description: 'Drop this block on your product page template.',\n mediaUrls: [],\n options: [{ name: 'Size', values: ['S', 'M', 'L'] }],\n variants: [\n { id: 'a', options: { Size: 'S' }, priceUsd: 29, soldOut: false },\n { id: 'b', options: { Size: 'M' }, priceUsd: 29, soldOut: false },\n { id: 'c', options: { Size: 'L' }, priceUsd: 32, soldOut: true },\n ],\n}\n\n/**\n * The GA4 `items` entry for one line of this product.\n *\n * `item_id` is the PRODUCT id and never the variant's, matching the\n * `view_item` above and the cart's lines below: GA joins the funnel on that\n * id, and a `begin_checkout` keyed on a variant would report a product nothing\n * else on the storefront had ever mentioned.\n *\n * `price` is the resolved variant's, which arrived from the server's product\n * payload — the same figure `checkout` prices the charge from, so the reported\n * value and the amount Stripe collects come from one source.\n */\nfunction buyItem(\n product: Detail,\n variant: DetailVariant | undefined,\n quantity: number,\n /** What one unit costs with its add-ons (AGL-4100), when the page has some. */\n unitCents?: number,\n): AnalyticsItem {\n return {\n item_id: product.id,\n item_name: product.name,\n price:\n unitCents !== undefined && typeof variant?.priceUsd === 'number'\n ? unitCents / 100\n : (variant?.priceUsd ?? undefined),\n quantity,\n }\n}\n\n/**\n * The page's add-ons for the variant picked (AGL-4100): whether every\n * required group is answered — the server's own check, run on the groups the\n * page was sent — and what the picks so far add to one unit, for the live\n * price. Display only; every sale door prices them again from the product.\n */\nexport function productPageAddOns(\n product: Pick<Detail, 'name' | 'modifierGroups'>,\n picks: readonly CommerceModel.ModifierSelection[],\n variantId: string | undefined,\n): { ready: boolean; extraCents: number; error?: string } {\n const groups = product.modifierGroups ?? []\n if (!groups.length) return { ready: true, extraCents: 0 }\n const source = { name: product.name, modifierGroups: groups }\n const checked = CommerceModel.resolveLineModifiers(source, picks, variantId)\n const extraCents = CommerceModel.soldLineModifiers(source, picks, variantId).reduce(\n (sum, modifier) => sum + modifier.priceCents,\n 0,\n )\n return checked.ok\n ? { ready: true, extraCents }\n : { ready: false, extraCents, ...(checked.error ? { error: checked.error } : {}) }\n}\n\n/** How one option is offered on the page. */\nexport interface OptionPresentation {\n name: string\n /** The values a shopper can actually get, in the option's own order. */\n values: string[]\n /**\n * `select` only when there is a real choice — two or more values that\n * variants carry; `text` for the one value every variant has (\"Scent:\n * Lavender\"); `hidden` for an option with no value at all.\n */\n mode: 'select' | 'text' | 'hidden'\n}\n\n/**\n * Which options are a CHOICE (AGL-3676 follow-up). A select with one entry —\n * or with entries no variant carries — is not a choice, and on a live store\n * it read as a broken control: an AI-built candle listed a \"Scent\" select\n * that offered nothing to pick. Decided from the variants, which are what is\n * sold: an option's values count only where a variant carries them, and only\n * when no variant names the option at all do its listed values stand in —\n * and then as a choice only when there are several variants to choose among.\n */\nexport function optionPresentation(\n options: readonly CommerceModel.ProductOption[],\n variants: ReadonlyArray<Pick<DetailVariant, 'options'>>,\n): OptionPresentation[] {\n return options.map((option) => {\n const listed = [\n ...new Set(\n (option.values ?? []).map((value) => String(value).trim()).filter(Boolean),\n ),\n ]\n const carried = new Set(\n variants\n .map((variant) => variant.options?.[option.name])\n .filter(\n (value): value is string => typeof value === 'string' && value.trim() !== '',\n ),\n )\n const values = carried.size\n ? [\n ...listed.filter((value) => carried.has(value)),\n ...[...carried].filter((value) => !listed.includes(value)),\n ]\n : variants.length > 1 || listed.length === 1\n ? listed\n : []\n return {\n name: option.name,\n values,\n mode: values.length >= 2 ? 'select' : values.length === 1 ? 'text' : 'hidden',\n }\n })\n}\n\n/** The selections a page opens on: the first variant on sale, else the first. */\nfunction initialSelections(\n product: Pick<Detail, 'variants'> | undefined,\n): Record<string, string> {\n const first =\n product?.variants.find((variant) => !variant.soldOut) ?? product?.variants[0]\n return { ...(first?.options ?? {}) }\n}\n\nfunction slugFromLocation(): string {\n if (typeof window === 'undefined') return ''\n const match = window.location.pathname.match(/\\/products\\/([^/?#]+)/)\n return match ? decodeURIComponent(match[1]) : ''\n}\n\n/**\n * Product detail block (AGL-292): gallery, option pickers that resolve\n * the variant (price/media/stock follow), quantity, and a buy button\n * that charges through the server-priced checkout with the selected\n * variant. Resolves its product from the /products/{slug} URL unless a\n * slug prop pins it; sample data on the inert canvas.\n */\nconst ProductDetail = forwardRef<HTMLDivElement, ProductDetailProps>(\n (props, ref) => {\n const {\n slug: slugProp,\n buyLabel,\n hideDescription,\n showCoupon,\n showDetails,\n showShipping,\n choiceStyle,\n mockupLabel,\n children,\n ...rest\n } = props\n /** The product builder (AGL-4205): choices as picture cards. */\n const cards = choiceStyle === 'cards'\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const site = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const { hostId } = site\n\n // The single-product (\"buy now\") path returns the shopper to this page\n // rather than to the cart, so the PDP is the second of the two surfaces\n // that has to be able to report `purchase` (AGL-1641). Both mount points\n // share one guard, so a page carrying a cart AND a PDP still sends one.\n useStorefrontPurchaseEvent(hostId, siteFetch)\n // Seeded from the server-resolved page data (AGL-659) so the PDP renders\n // its real content in the SSR HTML. Starting at null meant the server\n // emitted a <Skeleton> and the crawler got a product page with no\n // product in it. Absent in the besigner/preview, where the effect below\n // still fetches — so this is an optimisation, not a new requirement.\n const seededCommerce = (\n site.pageData as\n | { commerce?: { product?: Detail; returns?: { windowDays: number } } }\n | undefined\n )?.commerce\n const seededProduct = seededCommerce?.product\n // The store's return window, seeded with the built-in product page only\n // when the store takes returns of this product's kind.\n const seededReturns = seededCommerce?.returns\n const [detail, setDetail] = useState<Detail | null | 'missing'>(\n seededProduct ?? null,\n )\n // Opened on the first variant on sale. A seeded page skips the fetch that\n // used to set this, so it opened with nothing selected — an empty select.\n const [selections, setSelections] = useState<Record<string, string>>(() =>\n initialSelections(seededProduct),\n )\n const [quantity, setQuantity] = useState(1)\n /** The add-ons picked (AGL-4100), ids only. */\n const [addOns, setAddOns] = useState<CommerceModel.ModifierSelection[]>([])\n /** Why the cart refused the line, when it did. */\n const [addRefusal, setAddRefusal] = useState('')\n /**\n * The day the buyer chose to use a pass (AGL-4043), `YYYY-MM-DD` on the\n * store's calendar; '' is the day they buy, which is also the default.\n */\n const [useDay, setUseDay] = useState('')\n /** A discount or coupon code typed on the product page. */\n const [coupon, setCoupon] = useState('')\n // A thumbnail the shopper picked; null follows the variant's own photo.\n const [activeImage, setActiveImage] = useState<number | null>(null)\n /** The canvas's builder sample (AGL-4205), loaded only there, only for picture cards. */\n const [sampleBuilder, setSampleBuilder] = useState<Detail | null>(null)\n useEffect(() => {\n if (hostId || !cards || sampleBuilder) return\n let active = true\n void import('./product-builder-sample').then((module) => {\n if (active) setSampleBuilder(module.SAMPLE_BUILDER as Detail)\n })\n return () => {\n active = false\n }\n }, [hostId, cards, sampleBuilder])\n // `unconfigured` is not an `error` with softer words (AGL-2019). A store\n // with no Stripe key answers 501, and rendering that at `severity=\"error\"`\n // tells a shopper their payment failed when nothing was ever attempted —\n // the same distinction `ask` already makes, and the same one the cart's\n // 423 lockdown branch makes. It is the terminal one: it latches Buy off,\n // because every further click gets the identical refusal.\n const [status, setStatus] = useState<\n 'idle' | 'sending' | 'error' | 'ask' | 'unconfigured'\n >('idle')\n const [message, setMessage] = useState('')\n // The terms of sale and business use, once a checkout of card reader\n // hardware asked for them (AGL-4038).\n const [hardwareTerms, setHardwareTerms] = useState<HardwareTermsAnswer>(NO_HARDWARE_TERMS_ANSWER)\n const [hardwareTermsAsked, setHardwareTermsAsked] = useState(false)\n // Buy-now's half of AGL-1721: asked only when the server refuses to price\n // shipping without a destination, so a digital product, a subscription, or\n // a merchant whose rates are the same everywhere never shows it. `null` is\n // \"not asked\" — the field appearing is the server's answer, not a guess.\n const [shipTo, setShipTo] = useState('')\n const [shipCountries, setShipCountries] = useState<string[] | null>(null)\n // Live carrier rates price by postal code (AGL-3612): asked only when the\n // store prices that way and the server says so.\n const [shipPostal, setShipPostal] = useState('')\n const [askPostal, setAskPostal] = useState(false)\n const [added, setAdded] = useState(false)\n const [wishlisted, setWishlisted] = useState(false)\n // Buyer-chosen billing (AGL-545): only meaningful when the product\n // is subscriptionOptional; defaults to a one-time purchase.\n const [billing, setBilling] = useState<CommerceModel.CheckoutBillingChoice>(\n 'once',\n )\n /**\n * The in-page checkout session (AGL-1944), null on every store until the\n * flag AND a publishable key say otherwise. A `clientSecret` is Stripe's\n * instruction to the browser; holding it says nothing about money having\n * moved, and nothing in this component ever claims it has.\n */\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n /** The seller's account for a direct-charge session. */\n stripeAccount?: string\n /** The wallets the merchant hid (AGL-3629). */\n wallets?: CommerceModel.StorefrontCheckoutWallets\n } | null>(null)\n\n // A product-page template in Preview (AGL-4211): no product pinned and no\n // `/products/{slug}` address, so it shows the store's first listed product\n // (the sample when it lists none). The lookup is its own chunk.\n const template = Boolean(site.preview && hostId && !slugProp && !slugFromLocation())\n const [previewSlug, setPreviewSlug] = useState<string | null>(null)\n useEffect(() => {\n if (!template) return\n let active = true\n void import('./product-preview-slug')\n .then((module) => module.firstListedProductSlug(String(hostId)))\n .then((found) => active && setPreviewSlug(found))\n return () => {\n active = false\n }\n }, [template, hostId])\n const slug = slugProp || slugFromLocation() || previewSlug || ''\n\n useEffect(() => {\n if (hostId && resolvedId) {\n setWishlisted(readLocalWishlist(hostId).includes(resolvedId))\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hostId, detail])\n\n useEffect(() => {\n if (!hostId || !slug) return\n // Already delivered with the page (AGL-659) — refetching the identical\n // payload on hydrate would just be a wasted round trip per visitor.\n if (seededProduct && seededProduct.slug === slug) return\n let active = true\n void fetch(\n `/api/commerce/product?hostId=${encodeURIComponent(hostId)}` +\n `&slug=${encodeURIComponent(slug)}`,\n )\n .then((response) => (response.ok ? response.json() : null))\n .then((payload) => {\n if (!active) return\n const product = payload?.product as Detail | undefined\n setDetail(product ?? 'missing')\n if (product) {\n // GA4 ecommerce mirror (AGL-327), through the shared taxonomy\n // since AGL-1591 rather than raw gtag — same consent gate, same\n // sanitizer, and the name is now checked by the compiler.\n trackEvent('view_item', {\n items: [{ item_id: product.id, item_name: product.name }],\n })\n setSelections(initialSelections(product))\n setAddOns([])\n }\n })\n .catch(() => {\n if (active) setDetail('missing')\n })\n return () => {\n active = false\n }\n }, [hostId, slug])\n\n const resolvedId =\n hostId && detail && detail !== 'missing' ? detail.id : null\n // The template in Preview of a store with no listed product: the sample.\n const previewSample = template && previewSlug === ''\n const resolved: Detail | null = hostId && !previewSample\n ? detail === 'missing'\n ? null\n : detail\n : cards\n ? (sampleBuilder ?? SAMPLE)\n : SAMPLE\n\n const variant = useMemo(() => {\n if (!resolved) return undefined\n return (\n CommerceModel.findVariant(\n { variants: resolved.variants as any },\n selections,\n ) as DetailVariant | undefined\n ) ?? resolved.variants[0]\n }, [resolved, selections])\n\n // The add-ons picked, checked and priced on this variant (AGL-4100).\n const addOnGroups = resolved?.modifierGroups ?? []\n const pageAddOns = resolved\n ? productPageAddOns(resolved, addOns, variant?.id)\n : { ready: true, extraCents: 0 }\n const unitCents =\n typeof variant?.priceUsd === 'number'\n ? Math.round(variant.priceUsd * 100) + pageAddOns.extraCents\n : 0\n const addOnsKey = CommerceModel.modifierSelectionKey(addOns)\n\n // The day to send with this variant: only when it asks for one and the\n // buyer chose a day (AGL-4043).\n const chosenUseDay = variant?.asksUseDate && useDay ? useDay : ''\n // Today on the store's calendar, the first day the picker offers.\n const storeTodayKey = resolved?.useDayTimeZone\n ? zonedDayKey(Date.now(), resolved.useDayTimeZone)\n : ''\n\n // Add to cart (AGL-293) beside instant buy; badge refresh via event.\n const handleAddToCart = async () => {\n // A required add-on unanswered is refused here, before any request\n // (AGL-4100); the button says so too.\n if (!hostId || !resolved || !variant || !pageAddOns.ready) return\n setAdded(false)\n setAddRefusal('')\n // Priced (AGL-1591's shape, completed): the resolved variant's price\n // and the chosen quantity both come from the server's product payload,\n // so GA4's \"value added to cart\" is a real number. The funnel step\n // (AGL-3605) and the badge refresh ride the same shared helper the\n // product grid's quick add uses.\n const ok = await addToCart({\n hostId,\n siteFetch,\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n ...(chosenUseDay ? { useDayKey: chosenUseDay } : {}),\n ...(addOns.length ? { modifiers: addOns } : {}),\n item: buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined),\n onRefused: setAddRefusal,\n })\n if (ok) setAdded(true)\n }\n\n /**\n * Idempotency key for ONE buy-now attempt (AGL-1697).\n *\n * Minted lazily on the first buy click, retired whenever the purchase\n * changes shape — a different product, variant, quantity, billing choice\n * or destination is a different attempt. A retry of THIS attempt presents\n * the same key, so the server replays the original session instead of\n * opening a second one (for a subscription product, a second RECURRING\n * subscription).\n */\n // Pickup or the store's own delivery (AGL-3624), for a one-time sale; the\n // server offers nothing for a product with nothing physical to collect.\n const fulfillment = useCartFulfillment(\n hostId,\n resolved?.id ?? '[]',\n resolved &&\n variant &&\n !(resolved.subscription && (!resolved.subscriptionOptional || billing === 'subscribe'))\n ? {\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n ...(addOns.length ? { modifiers: addOns } : {}),\n }\n : null,\n )\n const attemptKey = useRef('')\n useEffect(() => {\n attemptKey.current = ''\n // `coupon` is in here because it CHANGES THE PRICE. Without it a shopper\n // who buys, comes back, types a code and buys again presents the same\n // key, and the server replays the original full-price session — a quoted\n // number that is not the number charged, which is the whole defect class\n // this path has been cleared of.\n // `addOnsKey` too: different add-ons are a different price (AGL-4100).\n }, [resolved?.id, variant?.id, quantity, billing, shipTo, shipPostal, coupon, fulfillment.signature, chosenUseDay, addOnsKey])\n\n const handleBuy = async () => {\n if (!hostId || !resolved || !variant || status === 'sending' || !pageAddOns.ready) return\n setStatus('sending')\n setMessage('')\n if (!attemptKey.current) {\n attemptKey.current =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n try {\n const response = await siteFetch('/api/commerce/checkout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Idempotency-Key': attemptKey.current,\n },\n body: JSON.stringify({\n hostId,\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n // The day the buyer will use it (AGL-4043); the server checks it\n // against the product and the store's calendar.\n ...(chosenUseDay ? { useDayKey: chosenUseDay } : {}),\n // The add-ons picked (AGL-4100), ids only: the server checks every\n // required one is answered and prices them from the product.\n ...(addOns.length ? { modifiers: addOns } : {}),\n // Billing choice (AGL-545): the server re-validates against\n // the product doc, so this is a request, not an instruction.\n ...(resolved.subscriptionOptional ? { billing } : {}),\n // Likewise a request (AGL-1721): the server resolves this\n // country's rates AND restricts the session to addresses in it,\n // so naming a cheap zone here cannot ship a parcel anywhere else.\n ...(shipTo && !fulfillment.request ? { shippingCountry: shipTo } : {}),\n ...(shipPostal.trim() && !fulfillment.request ? { shippingPostalCode: shipPostal.trim() } : {}),\n // Where and when, never the fee (AGL-3624).\n ...(fulfillment.request ? { fulfillment: fulfillment.request } : {}),\n // The server resolves this against the discounts hub first and the\n // legacy coupons second, and refuses a code it cannot apply with a\n // reason — never a silent full-price charge.\n ...(coupon.trim() ? { couponCode: coupon.trim() } : {}),\n // The buyer's answers for card reader hardware (AGL-4038), once asked.\n ...(hardwareTermsAsked ? { hardwareTerms } : {}),\n // The visitor's advertising consent and the vendors' browser ids, only\n // where that consent grants advertising (AGL-3694); absent otherwise.\n ...advertisingConsentField(hostId),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // In-page payment (AGL-1944). A native session returns a client secret\n // and NO url — the two are mutually exclusive by construction, so the\n // redirect branch below is unreachable in native mode and vice versa.\n // Checked FIRST so a server that somehow sent both cannot silently\n // navigate the shopper away from the form we just decided to show.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n // Buy-now's `begin_checkout`. The cart path has reported this since\n // AGL-1591 and this one never did, so a storefront whose shoppers\n // skip the cart showed `view_item` → `add_to_cart` → nothing →\n // `purchase`: GA4's shopping funnel put every single-product sale in\n // the \"abandoned checkout\" bucket, and the merchant's checkout rate\n // read as a collapse rather than as an unmeasured path.\n //\n // Reported on BOTH branches, and from the same place, for the reason\n // the cart states: a count that halved the day the in-page payment\n // flag flipped would look like a conversion collapse.\n trackEvent(\n 'begin_checkout',\n buildBeginCheckoutParams({\n items: [buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined)],\n }),\n )\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n ...(payload.stripeAccount\n ? { stripeAccount: String(payload.stripeAccount) }\n : {}),\n wallets: CommerceModel.readStorefrontCheckoutWallets(payload.wallets),\n })\n setStatus('idle')\n return\n }\n if (response.ok && payload?.url) {\n // Awaited before the redirect (AGL-1580), for the reason spelled out\n // on the cart's matching branch: delivery here is a synchronous\n // `window.gtag` call today and the await costs nothing, but the\n // property that makes a bare call safe is invisible from this file.\n await trackEventBeforeNavigation(\n 'begin_checkout',\n buildBeginCheckoutParams({\n items: [buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined)],\n }),\n )\n window.location.assign(payload.url)\n return\n }\n // Card reader hardware needs the terms of sale ticked (AGL-4038).\n if (payload?.needsHardwareTerms) {\n setHardwareTermsAsked(true)\n setMessage(String(payload?.error ?? ''))\n setStatus('ask')\n return\n }\n // Buy-now's half of AGL-2019. The server's own 501 wording is not\n // rendered to a visitor; this surface is public.\n if (payload?.fulfillmentChanged) {\n fulfillment.reload()\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n return\n }\n if (isPaymentsNotConfigured(response.status)) {\n setMessage(storefrontPaymentsNotConfiguredText())\n setStatus('unconfigured')\n return\n }\n if (payload?.needsShippingCountry) {\n if (payload?.needsShippingPostalCode) setAskPostal(true)\n setShipCountries(\n (payload.shippingCountries as string[] | undefined)?.length\n ? (payload.shippingCountries as string[])\n : [...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES],\n )\n setMessage(String(payload?.error ?? ''))\n // An unserved destination is a refusal and reads as one; being\n // asked the first time is not.\n setStatus(shipTo ? 'error' : 'ask')\n return\n }\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n } catch {\n setStatus('error')\n }\n }\n\n if (hostId && !previewSample && detail === null) {\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'flex', gap: 3 }, ...nodeSx]}>\n <Skeleton variant=\"rectangular\" width={320} height={320} />\n <Box sx={{ flex: 1 }}>\n <Skeleton width=\"60%\" height={36} />\n <Skeleton width=\"25%\" />\n <Skeleton width=\"90%\" />\n </Box>\n </Box>\n )\n }\n if (!resolved) {\n return (\n <Box ref={ref} {...rest} sx={[{ p: 3 }, ...nodeSx]}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Product not found.'}\n </Typography>\n </Box>\n )\n }\n\n // Every rendered `<img src>` on this page goes through\n // `siteRelativeMediaSrc` (AGL-1726). Commerce called NO resolver at all,\n // which cost it two things at once: a `media:` reference — writable via\n // the resources API and the CSV importer — would have reached an `<img>`\n // as the literal string, and a stored absolute\n // `https://{subdomain}.aglyn.app/api/media/cdn/…` stayed absolute, so a\n // white-label storefront on the customer's own domain served product\n // photos naming OUR platform, cross-origin, in page source and in every\n // visitor's request. Production carried exactly one such document; the\n // resolver fixes it at READ time, so no backfill stands between the\n // defect and the fix.\n //\n // Deliberately NOT applied to `resolved.mediaUrls` wholesale: the\n // schema.org `image` array below is read out of band by a crawler, where\n // an absolute URL is the point. That one wants `absoluteMediaSrc` with\n // the site's own origin, which is the tenant page's job (AGL-1725).\n const galleryImage = Aglyn.siteRelativeMediaSrc(\n (activeImage !== null ? resolved.mediaUrls[activeImage] : undefined) ??\n variant?.imageUrl ??\n resolved.mediaUrls[0],\n { hostId },\n )\n const presentedOptions = optionPresentation(resolved.options, resolved.variants)\n\n // Subscription framing (AGL-545): subscription-only products price as\n // $X/mo|/yr with a \"Subscribe\" button; subscriptionOptional products\n // surface the one-time/subscribe toggle instead. Same price either way\n // — the server re-prices from the product doc regardless.\n const subscription = resolved.subscription\n const intervalSuffix = subscription?.interval === 'year' ? '/yr' : '/mo'\n const subscribing =\n Boolean(subscription) &&\n (!resolved.subscriptionOptional || billing === 'subscribe')\n // Listed before it has a price (AGL-3676): no price to show and nothing\n // to buy; every sale door would refuse it anyway.\n const priced = typeof variant?.priceUsd === 'number'\n // The add-ons are offered where they can be priced, and on a product that\n // offers a free mockup, whose request carries them (AGL-4205).\n // Live, the button shows only where the block holds a request form to\n // open; on the canvas the block shows the space to drop one in.\n const hasRequestForm = Children.toArray(children).length > 0\n const offersMockup = hostId\n ? resolved.mockupRequests === true && hasRequestForm\n : resolved.mockupRequests === true || hasRequestForm\n const showAddOns = addOnGroups.length > 0 && (priced || offersMockup)\n\n // schema.org Product/Offer (AGL-299). Kept ONLY for the case where this\n // block renders without server-seeded page data — the besigner preview,\n // or a page whose resolver didn't supply it. When the tenant page seeds\n // us it emits the same Product node server-side (AGL-660), and two\n // Product nodes for one item is worse than one, so we stand down.\n const structuredData =\n hostId && resolvedId && !seededProduct\n ? {\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: resolved.name,\n ...(resolved.description\n ? { description: resolved.description }\n : {}),\n ...(resolved.mediaUrls.length\n ? { image: resolved.mediaUrls }\n : {}),\n // No offer without a price: a price of 0 would read as free.\n ...(priced\n ? {\n offers: {\n '@type': 'Offer',\n priceCurrency: 'USD',\n price: String(variant?.priceUsd),\n availability: variant?.soldOut\n ? 'https://schema.org/OutOfStock'\n : 'https://schema.org/InStock',\n },\n }\n : {}),\n }\n : null\n\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n display: 'flex',\n gap: 3,\n flexDirection: { xs: 'column', md: 'row' },\n },\n ...nodeSx,\n ]}\n >\n <CheckoutReturnNotice hostId={hostId} siteFetch={siteFetch} />\n <Box sx={{ flex: 1, minWidth: 0 }}>\n {galleryImage ? (\n <Box\n component=\"img\"\n src={galleryImage}\n alt={resolved.name}\n // DELIBERATELY NOT DEFERRED (AGL-2486). This is the gallery\n // hero at the top of a product page — the one image on this\n // surface that really is the LCP candidate, and the browser\n // default here is already `eager`. Spreading\n // `DEFERRED_IMAGE_ATTRIBUTES` over it to \"finish the job\" is\n // the obvious next edit and it re-introduces the bug this\n // issue opened with: an LCP image not discovered until after\n // layout has run. The thumbnail strip below it IS deferred.\n //\n // No `fetchpriority` either, for the reason written out at\n // `image.tsx`: `high` is a claim about every other request in\n // flight, and a page whose real LCP is the product NAME would\n // pay for that claim.\n sx={{\n width: '100%',\n aspectRatio: '1 / 1',\n objectFit: 'cover',\n borderRadius: 1,\n }}\n />\n ) : (\n <Box\n sx={{\n width: '100%',\n aspectRatio: '1 / 1',\n bgcolor: 'action.hover',\n borderRadius: 1,\n }}\n />\n )}\n {resolved.mediaUrls.length > 1 ? (\n <Box sx={{ display: 'flex', gap: 1, mt: 1, flexWrap: 'wrap' }}>\n {resolved.mediaUrls.map((url, index) => (\n <Box\n key={`${url}-${index}`}\n component=\"img\"\n // Same resolver as the hero (AGL-1726) — a thumbnail is an\n // `<img>` on the customer's page and leaks exactly as much.\n src={Aglyn.siteRelativeMediaSrc(url, { hostId })}\n alt=\"\"\n onClick={() => setActiveImage(index)}\n sx={{\n width: 64,\n height: 64,\n objectFit: 'cover',\n borderRadius: 1,\n cursor: 'pointer',\n border: 2,\n borderColor:\n index === (activeImage ?? 0) ? 'primary.main' : 'transparent',\n }}\n // Deferred (AGL-2486): 56px thumbnails that exist to swap\n // the hero above. They were fetching eagerly ALONGSIDE\n // that hero, so a five-image gallery had the hero\n // competing with four thumbnails nobody had asked for yet.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ))}\n </Box>\n ) : null}\n </Box>\n {structuredData ? (\n <script\n type=\"application/ld+json\"\n dangerouslySetInnerHTML={{ __html: Aglyn.safeJsonLd(structuredData) }}\n />\n ) : null}\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"h4\" component=\"h1\" gutterBottom>\n {resolved.name}\n </Typography>\n <Box sx={{ display: 'flex', gap: 1, alignItems: 'center', mb: 2 }}>\n <Typography variant=\"h6\">\n {/* The configured unit (AGL-4100): the variant and its add-ons, formatted. */}\n {priced\n ? `${money(unitCents)}${subscribing ? intervalSuffix : ''}`\n : PRICE_COMING_SOON_LABEL}\n </Typography>\n {subscribing && subscription?.trialDays ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${subscription.trialDays}-day free trial`}\n </Typography>\n ) : null}\n {variant?.compareAtPriceUsd ? (\n <>\n <Typography\n variant=\"body1\"\n color=\"text.secondary\"\n sx={{ textDecoration: 'line-through' }}\n >\n {moneyFromUsd(variant.compareAtPriceUsd)}\n </Typography>\n <Chip label=\"Sale\" size=\"small\" color=\"primary\" />\n </>\n ) : null}\n {variant?.soldOut ? (\n <Chip label=\"Sold out\" size=\"small\" variant=\"outlined\" />\n ) : null}\n <Button\n size=\"small\"\n onClick={async () => {\n if (hostId && resolved.id !== 'sample') {\n setWishlisted(await toggleWishlist(hostId, resolved.id, siteFetch))\n }\n }}\n >\n {wishlisted ? '♥ Saved' : '♡ Save'}\n </Button>\n </Box>\n {subscription && resolved.subscriptionOptional ? (\n <ToggleButtonGroup\n value={billing}\n exclusive\n size=\"small\"\n onChange={(_event, value) => {\n if (value === 'once' || value === 'subscribe') {\n setBilling(value)\n }\n }}\n sx={{ mb: 2 }}\n >\n <ToggleButton value=\"once\">\n {priced ? `One-time ${money(unitCents)}` : 'One-time'}\n </ToggleButton>\n <ToggleButton value=\"subscribe\">\n {priced ? `Subscribe ${money(unitCents)}${intervalSuffix}` : 'Subscribe'}\n </ToggleButton>\n </ToggleButtonGroup>\n ) : null}\n {cards ? (\n // The product builder (AGL-4205): every choice a picture card.\n <Suspense fallback={null}>\n <ProductChoiceCards\n options={presentedOptions.filter((option) => option.mode === 'select')}\n variants={resolved.variants}\n selections={variant?.options ?? selections}\n onSelect={(name, value) => {\n setActiveImage(null)\n setSelections((prev) => ({ ...(variant?.options ?? {}), ...prev, [name]: value }))\n }}\n groups={showAddOns ? addOnGroups : []}\n variantId={variant?.id}\n value={addOns}\n onChange={setAddOns}\n formatCents={money}\n unpricedLabel={PRICE_COMING_SOON_LABEL}\n disabled={Boolean(variant?.soldOut)}\n />\n </Suspense>\n ) : null}\n {presentedOptions.map((option) =>\n cards && option.mode === 'select' ? null : option.mode === 'hidden' ? null : option.mode === 'text' ? (\n <Typography\n key={option.name}\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ mb: 1.5 }}\n >\n {`${option.name}: ${option.values[0]}`}\n </Typography>\n ) : (\n <TextField\n key={option.name}\n label={option.name}\n value={\n option.values.includes(selections[option.name] ?? '')\n ? selections[option.name]\n : ''\n }\n onChange={(event) => {\n // A new variant shows its own photo, not the last thumbnail.\n setActiveImage(null)\n setSelections((prev) => ({\n ...prev,\n [option.name]: event.target.value,\n }))\n }}\n size=\"small\"\n select\n fullWidth\n sx={{ mb: 1.5 }}\n >\n {option.values.map((value) => (\n <MenuItem key={value} value={value}>\n {value}\n </MenuItem>\n ))}\n </TextField>\n ),\n )}\n {showAddOns && !cards ? (\n <Suspense fallback={null}>\n <ProductAddOns\n groups={addOnGroups}\n variantId={variant?.id}\n value={addOns}\n onChange={setAddOns}\n formatCents={money}\n disabled={Boolean(variant?.soldOut)}\n />\n </Suspense>\n ) : null}\n {showCoupon ? (\n <TextField\n label=\"Discount code\"\n value={coupon}\n onChange={(event) => setCoupon(event.target.value)}\n size=\"small\"\n sx={{ mb: 2, display: 'block' }}\n />\n ) : null}\n {!priced ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mb: 2 }}>\n {'Not on sale yet — check back soon.'}\n </Typography>\n ) : null}\n {priced && variant?.asksUseDate && storeTodayKey ? (\n <Box sx={{ mb: 2 }}>\n <Suspense fallback={null}>\n <UseDayPicker\n value={useDay}\n onChange={setUseDay}\n todayKey={storeTodayKey}\n label=\"Day you will use it (optional)\"\n helperText=\"Leave it blank to use it the day you buy.\"\n />\n </Suspense>\n </Box>\n ) : null}\n <Box sx={{ display: priced ? 'flex' : 'none', gap: 1.5, alignItems: 'center', mb: 2 }}>\n <TextField\n label=\"Qty\"\n value={quantity}\n onChange={(event) =>\n setQuantity(\n Math.max(\n 1,\n Math.min(CommerceModel.CART_MAX_QUANTITY, Math.round(Number(event.target.value)) || 1),\n ),\n )\n }\n size=\"small\"\n // Four digits fit (AGL-4205): a line goes up to 9,999.\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n variant=\"outlined\"\n color=\"primary\"\n size=\"large\"\n disabled={!hostId || !priced || variant?.soldOut || !pageAddOns.ready}\n onClick={handleAddToCart}\n >\n {added ? 'Added ✓' : 'Add to cart'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n size=\"large\"\n disabled={\n !hostId ||\n !priced ||\n status === 'sending' ||\n variant?.soldOut ||\n // A required add-on unanswered (AGL-4100).\n !pageAddOns.ready ||\n // No payments on this deployment: the same 501 every time, so\n // the control latches off rather than inviting a retry that\n // cannot succeed (AGL-2019).\n status === 'unconfigured' ||\n // Asked but unanswered: the server would only refuse again.\n (fulfillment.method === 'shipping' && shipCountries !== null && !shipTo) ||\n (fulfillment.method === 'shipping' && askPostal && !shipPostal.trim()) ||\n !fulfillment.ready ||\n // Card reader hardware: both boxes ticked (AGL-4038).\n (hardwareTermsAsked && !hardwareTermsAnswered(hardwareTerms))\n }\n onClick={handleBuy}\n sx={{ flex: 1 }}\n >\n {variant?.soldOut\n ? 'Sold out'\n : status === 'sending'\n ? // \"Redirecting\" is a lie once the form opens in place, and\n // it is the shopper's only clue about what is about to\n // happen to their page (AGL-1944).\n nativeCheckout\n ? 'Opening…'\n : 'Redirecting…'\n : buyLabel || (subscribing ? 'Subscribe' : 'Buy now')}\n </Button>\n </Box>\n {/*\n The live price with add-ons (AGL-4100): one configured unit\n times the quantity, and what is still to choose.\n */}\n {(addOnGroups.length || cards) && priced ? (\n <Box sx={{ mb: 2 }} aria-live=\"polite\">\n <Typography variant=\"subtitle1\" component=\"p\">\n {quantity > 1\n ? `Total for ${quantity}: ${money(unitCents * quantity)}`\n : `Total: ${money(unitCents)}`}\n </Typography>\n {!pageAddOns.ready && pageAddOns.error && !variant?.soldOut ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pageAddOns.error}\n </Typography>\n ) : null}\n </Box>\n ) : null}\n {/*\n The free mockup (AGL-4205): on a product that offers one, the\n button opens what the site builder dropped into this block — a\n request form whose Product and options field reads the picks from\n the context below. On the canvas the form stays open to design.\n */}\n {offersMockup ? (\n <Suspense fallback={null}>\n <ProductBuilderMockup\n picks={{\n product: resolved,\n variant,\n addOns,\n quantity,\n ready: pageAddOns.ready,\n problem: pageAddOns.ready ? undefined : pageAddOns.error,\n total: priced ? money(unitCents * quantity) : undefined,\n }}\n label={mockupLabel}\n priced={priced}\n canvas={!hostId}\n hasRequestForm={hasRequestForm}\n >\n {children}\n </ProductBuilderMockup>\n </Suspense>\n ) : null}\n {addRefusal ? (\n <Alert severity=\"warning\" sx={{ mb: 2 }}>\n {addRefusal}\n </Alert>\n ) : null}\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n stripeAccount={nativeCheckout.stripeAccount}\n wallets={nativeCheckout.wallets}\n payLabel={buyLabel || (subscribing ? 'Subscribe' : 'Pay now')}\n // An expired or unloadable session is replaced, never\n // replayed: the old attempt key would hand back the dead one.\n onRestart={() => {\n attemptKey.current = ''\n setNativeCheckout(null)\n void handleBuy()\n }}\n // Cancelling drops the form and leaves the session open —\n // deliberately. The shopper may come back to the same\n // attempt key, and an abandoned session is what the AGL-323\n // recovery emails are built on. Nothing is expired from the\n // browser: that is a write against the merchant's account.\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : null}\n {fulfillment.offered && priced ? (\n <Box sx={{ mb: 2 }}>\n <CartFulfillmentChoice\n state={fulfillment}\n formatCents={money}\n />\n </Box>\n ) : null}\n {shipCountries && fulfillment.method === 'shipping' && priced ? (\n <TextField\n select\n label=\"Ship to\"\n value={shipTo}\n onChange={(event) => setShipTo(event.target.value)}\n size=\"small\"\n fullWidth\n helperText=\"Shipping rates depend on where this is going\"\n sx={{ mb: 2 }}\n >\n {shipCountries.map((code) => (\n <MenuItem key={code} value={code}>\n {CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code] ?? code}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {askPostal && fulfillment.method === 'shipping' && priced ? (\n <TextField\n label=\"Postal code\"\n value={shipPostal}\n onChange={(event) => setShipPostal(event.target.value)}\n size=\"small\"\n fullWidth\n helperText=\"Carrier rates depend on the postal code\"\n slotProps={{ htmlInput: { autoComplete: 'shipping postal-code', maxLength: 12 } }}\n sx={{ mb: 2 }}\n />\n ) : null}\n {hardwareTermsAsked ? <HardwareTermsConsent answer={hardwareTerms} onChange={setHardwareTerms} /> : null}\n {status === 'ask' || status === 'unconfigured' ? (\n <Alert severity=\"info\" sx={{ mb: 2 }}>\n {message}\n </Alert>\n ) : null}\n {status === 'error' ? (\n <Alert severity=\"error\" sx={{ mb: 2 }}>\n {message || 'Checkout is unavailable right now.'}\n </Alert>\n ) : null}\n {variant?.soldOut && hostId ? (\n // The back-in-stock alert, only on a sold-out variant (its own chunk, AGL-4205).\n <Suspense fallback={null}>\n <ProductRestockNotify hostId={hostId} productId={resolved.id} siteFetch={siteFetch} />\n </Suspense>\n ) : null}\n {!hideDescription && resolved.description ? (\n <Typography\n variant=\"body1\"\n color=\"text.secondary\"\n sx={{ whiteSpace: 'pre-line' }}\n >\n {resolved.description}\n </Typography>\n ) : null}\n {/*\n The Details and Shipping & returns folds, off by default, in\n their own chunk (AGL-4205): a page that shows neither loads none.\n */}\n {showDetails || showShipping ? (\n <Suspense fallback={null}>\n <ProductDetailPanels\n product={resolved}\n variant={variant}\n presented={presentedOptions}\n returns={seededProduct?.id === resolved.id ? seededReturns : undefined}\n showDetails={Boolean(showDetails)}\n showShipping={Boolean(showShipping)}\n />\n </Suspense>\n ) : null}\n </Box>\n </Box>\n )\n },\n)\nProductDetail.displayName = 'AglynProductDetail'\n\nexport const schema: Aglyn.ComponentSchema<ProductDetailProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Product detail',\n description: \"One product's gallery, options and buy button.\",\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n // Not self-closing since AGL-4205: what is dropped in is the request form\n // \"Get a free mockup\" opens, shown only for a product that offers one.\n attributes: [\n {\n name: 'slug',\n label: 'Product slug',\n description:\n 'Pin to one product; blank follows the /products/{slug} URL ' +\n '(product page template).',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'buyLabel',\n label: 'Buy button label',\n description: 'Defaults to \"Buy now\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'hideDescription',\n label: 'Hide description',\n description: 'Design the description separately with tokens.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // Off by default, so no existing page changes shape on deploy. The cart\n // has carried this field all along and the product page had none, so a\n // shopper buying the same goods through Buy now had nowhere to enter a\n // code the merchant had advertised.\n name: 'showCoupon',\n label: 'Show discount code field',\n description: 'Lets a buyer enter a discount or coupon code before buying.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // Off by default, so no existing page changes shape on deploy.\n name: 'showDetails',\n label: 'Show details panel',\n description:\n 'A Details fold under the description with the facts the product ' +\n 'holds: its options, SKU, tags, and whether it is digital or a service.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n name: 'showShipping',\n label: 'Show shipping & returns panel',\n description:\n 'A Shipping & returns fold: shipping priced at checkout (or digital ' +\n 'delivery), and your return window when your store takes returns.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // AGL-4205. Absent reads as menus, so no existing page changes shape.\n name: 'choiceStyle',\n label: 'Show choices as',\n description:\n 'Menus, or picture cards: a card per choice with its picture, price and note, and a running total.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { label: 'Menus', value: 'menus' },\n { label: 'Picture cards', value: 'cards' },\n ],\n },\n {\n name: 'mockupLabel',\n label: 'Free mockup button label',\n description:\n 'Shown when the product offers a free mockup and this block holds a request form.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product detail',\n pluginId: BUNDLE_ID,\n description: 'Gallery, variant picker, and buy button for one product',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n {\n // Product page (AGL-561): the commerce-standard PDP subtree —\n // breadcrumb, detail, related products, reviews — for the product\n // page template screen. `{{product.name}}` resolves there via the\n // site page resolver's token pass (AGL-292); node shapes follow\n // the Sections & Blocks convention (AGL-539) and reference only\n // persisted component ids.\n $id: generatePresetId(ID, 'page'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product page',\n pluginId: BUNDLE_ID,\n description:\n 'Breadcrumb, product detail, related products, and reviews',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: 'muiStack',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { spacing: 4 },\n // Styling on the node's own sx, never in props (AGL-1346): both\n // records render, but only `node.sx` is the one the Styles panel can\n // read, edit or clear.\n sx: { paddingTop: 2, paddingBottom: 2 },\n nodes: [\n {\n $id: null,\n componentId: 'muiStack',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { direction: 'row', spacing: 1 },\n sx: { alignItems: 'center' },\n nodes: [\n {\n $id: null,\n componentId: 'muiScreenLink',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { children: 'Shop', size: 'small', color: 'inherit' },\n },\n {\n $id: null,\n componentId: 'muiTypography',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { variant: 'body2', children: '/ {{product.name}}' },\n },\n ],\n },\n {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n {\n $id: null,\n componentId: RELATED_PRODUCTS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n {\n $id: null,\n componentId: PRODUCT_REVIEWS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n ],\n },\n },\n]\n\nexport default ProductDetail\n"],"names":["advertisingConsentField","Aglyn","buildBeginCheckoutParams","trackEvent","trackEventBeforeNavigation","isPaymentsNotConfigured","storefrontPaymentsNotConfiguredText","CommerceModel","mdiTagOutline","Alert","Box","Button","Chip","MenuItem","Skeleton","TextField","ToggleButton","ToggleButtonGroup","Typography","Children","Suspense","forwardRef","lazy","useEffect","useMemo","useRef","useState","BUNDLE_ID","generatePresetId","useStorefrontPurchaseEvent","addToCart","CartFulfillmentChoice","useCartFulfillment","HardwareTermsConsent","hardwareTermsAnswered","NO_HARDWARE_TERMS_ANSWER","ID","PRODUCT_REVIEWS_ID","RELATED_PRODUCTS_ID","readLocalWishlist","toggleWishlist","StorefrontPaymentElementFallback","CheckoutReturnNotice","zonedDayKey","StorefrontPaymentElement","then","module","default","PRICE_COMING_SOON_LABEL","UseDayPicker","ProductAddOns","ProductChoiceCards","ProductBuilderMockup","ProductRestockNotify","ProductDetailPanels","money","cents","formatOrderMoney","moneyFromUsd","priceUsd","Math","round","SAMPLE","id","name","slug","description","mediaUrls","options","values","variants","Size","soldOut","buyItem","product","variant","quantity","unitCents","item_id","item_name","price","undefined","productPageAddOns","picks","variantId","groups","modifierGroups","length","ready","extraCents","source","checked","resolveLineModifiers","soldLineModifiers","reduce","sum","modifier","priceCents","ok","error","optionPresentation","map","option","listed","Set","value","String","trim","filter","Boolean","carried","size","has","includes","mode","initialSelections","first","find","slugFromLocation","window","match","location","pathname","decodeURIComponent","ProductDetail","props","ref","activeImage","site","slugProp","buyLabel","hideDescription","showCoupon","showDetails","showShipping","choiceStyle","mockupLabel","children","rest","cards","nodeSx","Array","isArray","useSite","siteFetch","useSiteFetch","hostId","seededCommerce","pageData","commerce","seededProduct","seededReturns","returns","detail","setDetail","selections","setSelections","setQuantity","addOns","setAddOns","addRefusal","setAddRefusal","useDay","setUseDay","coupon","setCoupon","setActiveImage","sampleBuilder","setSampleBuilder","active","SAMPLE_BUILDER","status","setStatus","message","setMessage","hardwareTerms","setHardwareTerms","hardwareTermsAsked","setHardwareTermsAsked","shipTo","setShipTo","shipCountries","setShipCountries","shipPostal","setShipPostal","askPostal","setAskPostal","added","setAdded","wishlisted","setWishlisted","billing","setBilling","nativeCheckout","setNativeCheckout","template","preview","previewSlug","setPreviewSlug","firstListedProductSlug","found","resolvedId","fetch","encodeURIComponent","response","json","payload","items","catch","previewSample","resolved","findVariant","addOnGroups","pageAddOns","addOnsKey","modifierSelectionKey","chosenUseDay","asksUseDate","storeTodayKey","useDayTimeZone","Date","now","handleAddToCart","productId","useDayKey","modifiers","item","onRefused","fulfillment","subscription","subscriptionOptional","attemptKey","current","signature","handleBuy","globalThis","crypto","randomUUID","random","toString","slice","method","headers","body","JSON","stringify","request","shippingCountry","shippingPostalCode","couponCode","clientSecret","publishableKey","stripeAccount","wallets","readStorefrontCheckoutWallets","url","assign","needsHardwareTerms","fulfillmentChanged","reload","needsShippingCountry","needsShippingPostalCode","shippingCountries","CHECKOUT_SHIPPING_COUNTRIES","sx","display","gap","width","height","flex","p","color","galleryImage","siteRelativeMediaSrc","imageUrl","presentedOptions","intervalSuffix","interval","subscribing","priced","hasRequestForm","toArray","offersMockup","mockupRequests","showAddOns","structuredData","image","offers","priceCurrency","availability","flexDirection","xs","md","minWidth","component","src","alt","aspectRatio","objectFit","borderRadius","bgcolor","mt","flexWrap","index","onClick","cursor","border","borderColor","DEFERRED_IMAGE_ATTRIBUTES","script","type","dangerouslySetInnerHTML","__html","safeJsonLd","gutterBottom","alignItems","mb","trialDays","compareAtPriceUsd","textDecoration","label","exclusive","onChange","_event","fallback","onSelect","prev","formatCents","unpricedLabel","disabled","event","target","select","fullWidth","todayKey","helperText","max","min","CART_MAX_QUANTITY","Number","theme","spacing","slotProps","htmlInput","inputMode","aria-live","problem","total","canvas","severity","payLabel","onRestart","onCancel","offered","state","code","CHECKOUT_SHIPPING_COUNTRY_NAMES","autoComplete","maxLength","answer","whiteSpace","presented","displayName","schema","$id","pluginId","category","ComponentCategory","COMMERCE","icon","path","attributes","FieldComponentType","TEXT_FIELD","CHECKBOX","SELECT","presets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gBACA;oBACE+O,KAAK;oBACLgB,aAAavV;oBACbwU,UAAUlV;oBACVkG,OAAO,CAAC;gBACV;aACD;QACH;IACF;CACD,CAAA;AAED,eAAeD,cAAa"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/product-detail.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { advertisingConsentField } from '@aglyn/aglyn/app-utils/advertising-consent'\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n buildBeginCheckoutParams,\n trackEvent,\n trackEventBeforeNavigation,\n type AnalyticsItem,\n} from '@aglyn/aglyn/app-utils/analytics-events'\nimport { isPaymentsNotConfigured } from '@aglyn/aglyn/app-utils/payments-configured'\nimport { storefrontPaymentsNotConfiguredText } from '../constants/storefront-payments'\nimport * as CommerceModel from '../model'\nimport { mdiTagOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Chip from '@mui/material/Chip'\nimport MenuItem from '@mui/material/MenuItem'\nimport Skeleton from '@mui/material/Skeleton'\nimport TextField from '@mui/material/TextField'\nimport ToggleButton from '@mui/material/ToggleButton'\nimport ToggleButtonGroup from '@mui/material/ToggleButtonGroup'\nimport Typography from '@mui/material/Typography'\nimport {\n Children,\n Suspense,\n forwardRef,\n lazy,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { useStorefrontPurchaseEvent } from '../utils/use-storefront-purchase-event'\nimport { addToCart } from '../utils/add-to-cart'\nimport { CartFulfillmentChoice, useCartFulfillment } from './cart-fulfillment'\nimport {\n HardwareTermsConsent,\n hardwareTermsAnswered,\n NO_HARDWARE_TERMS_ANSWER,\n type HardwareTermsAnswer,\n} from './hardware-terms-consent'\nimport { ID as PRODUCT_REVIEWS_ID } from './product-reviews'\nimport { ID as RELATED_PRODUCTS_ID } from './related-products'\nimport { readLocalWishlist, toggleWishlist } from './wishlist'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\nimport { CheckoutReturnNotice } from './checkout-return-notice'\nimport { useShopperCurrency } from './shopper-currency'\nimport { zonedDayKey } from '@aglyn/shared-util-timestamp/zoned-time'\n\n/**\n * The Payment Element (AGL-1944), behind a lazy boundary rather than a plain\n * import. Stripe.js and its React wrapper are a large dependency, the flag is\n * OFF, and a static import would put the whole SDK into the bundle of every\n * product page on every published site to serve a code path no shopper reaches.\n * Split, it is fetched by the shoppers who actually get the in-page form.\n */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'product-detail'\n\nexport interface ProductDetailProps {\n /** Product slug; blank resolves from /products/{slug} in the URL. */\n slug?: string\n buyLabel?: string\n /** Hide the description block (design it separately with tokens). */\n hideDescription?: boolean\n /** Offer a discount/coupon code field before the buy button. */\n showCoupon?: boolean\n /**\n * A \"Details\" panel under the description: the facts the product record\n * holds — its kind (digital, service), the choices it comes in, the\n * selected variant's SKU, its tags. Never a fact the record does not hold.\n * Off by default, so a page that already places this block keeps its shape.\n */\n showDetails?: boolean\n /**\n * A \"Shipping & returns\" panel: how it is delivered (shipping priced at\n * checkout, or delivered digitally), and the store's own return window\n * when the store takes returns of this kind of product. Off by default.\n */\n showShipping?: boolean\n /**\n * How the shopper picks options and add-ons (AGL-4205): `menus`, the\n * drop-downs and check boxes every page had, or `cards`, the product\n * builder — a picture card per choice with its price and note, combos that\n * fold out what they include, and a running total. Absent reads as menus,\n * so no existing page changes shape.\n */\n choiceStyle?: 'menus' | 'cards'\n /** The free-mockup button's words (AGL-4205); \"Get a free mockup\" when blank. */\n mockupLabel?: string\n /**\n * What the site builder dropped into the block (AGL-4205): the request\n * form a free mockup opens. Shown only for a product that offers mockups.\n */\n children?: ReactNode\n}\n\ninterface DetailVariant {\n id: string\n options?: Record<string, string>\n /** `null` while the product is listed before it has a price (AGL-3676). */\n priceUsd: number | null\n compareAtPriceUsd?: number\n /** The merchant's own price per currency (AGL-4248), major units. */\n fixedPrices?: Record<string, number>\n soldOut: boolean\n imageUrl?: string\n sku?: string\n /** The buyer may choose the day they will use it (AGL-4043). */\n asksUseDate?: true\n /** A short line on the variant's picture card (AGL-4205). */\n note?: string\n}\n\n/** What the page says where a variant with no price yet would show one (AGL-3676). */\nconst PRICE_COMING_SOON_LABEL = 'Price coming soon'\n\ninterface Detail {\n id: string\n name: string\n slug: string\n description?: string\n type?: CommerceModel.ProductType\n tags?: string[]\n mediaUrls: string[]\n options: CommerceModel.ProductOption[]\n variants: DetailVariant[]\n /** Recurring billing (AGL-303); framing + buyer choice on the PDP. */\n subscription?: { interval: 'month' | 'year'; trialDays?: number }\n /** Buyer picks one-time or subscribe at the same price (AGL-545). */\n subscriptionOptional?: boolean\n /** The store's time zone, when a variant asks for a use day (AGL-4043). */\n useDayTimeZone?: string\n /**\n * The add-ons the page offers (AGL-4100): only groups shown on the\n * website ever arrive here.\n */\n modifierGroups?: CommerceModel.ProductModifierGroup[]\n /** The page offers \"Get a free mockup\" (AGL-4205). */\n mockupRequests?: true\n}\n\n/**\n * The use-day picker (AGL-4043), in its own chunk: only a product whose\n * variant asks for a day downloads the date picker.\n */\nconst UseDayPicker = lazy(() => import('./use-day-picker'))\n\n/**\n * The add-on pickers (AGL-4100), in their own chunk: only a product with\n * add-ons on the website downloads them.\n */\nconst ProductAddOns = lazy(() => import('./product-add-ons'))\n\n/**\n * The picture cards (AGL-4205), in their own chunk: only a page set to show\n * its choices as cards downloads them.\n */\nconst ProductChoiceCards = lazy(() => import('./product-choice-cards'))\n\n/**\n * The free mockup's button and the request form it opens (AGL-4205), in their\n * own chunk: only a product that offers one, or the canvas, downloads it.\n */\nconst ProductBuilderMockup = lazy(() => import('./product-builder-mockup'))\n\n/** The back-in-stock alert, only on a sold-out variant (split out for AGL-4205). */\nconst ProductRestockNotify = lazy(() => import('./product-restock-notify'))\n\n/** The Details and Shipping & returns folds (AGL-4205: split out), only where switched on. */\nconst ProductDetailPanels = lazy(() => import('./product-detail-panels'))\n\n\nconst SAMPLE: Detail = {\n id: 'sample',\n name: 'Sample product',\n slug: '#',\n description: 'Drop this block on your product page template.',\n mediaUrls: [],\n options: [{ name: 'Size', values: ['S', 'M', 'L'] }],\n variants: [\n { id: 'a', options: { Size: 'S' }, priceUsd: 29, soldOut: false },\n { id: 'b', options: { Size: 'M' }, priceUsd: 29, soldOut: false },\n { id: 'c', options: { Size: 'L' }, priceUsd: 32, soldOut: true },\n ],\n}\n\n/**\n * The GA4 `items` entry for one line of this product.\n *\n * `item_id` is the PRODUCT id and never the variant's, matching the\n * `view_item` above and the cart's lines below: GA joins the funnel on that\n * id, and a `begin_checkout` keyed on a variant would report a product nothing\n * else on the storefront had ever mentioned.\n *\n * `price` is the resolved variant's, which arrived from the server's product\n * payload — the same figure `checkout` prices the charge from, so the reported\n * value and the amount Stripe collects come from one source.\n */\nfunction buyItem(\n product: Detail,\n variant: DetailVariant | undefined,\n quantity: number,\n /** What one unit costs with its add-ons (AGL-4100), when the page has some. */\n unitCents?: number,\n): AnalyticsItem {\n return {\n item_id: product.id,\n item_name: product.name,\n price:\n unitCents !== undefined && typeof variant?.priceUsd === 'number'\n ? unitCents / 100\n : (variant?.priceUsd ?? undefined),\n quantity,\n }\n}\n\n/**\n * The page's add-ons for the variant picked (AGL-4100): whether every\n * required group is answered — the server's own check, run on the groups the\n * page was sent — and what the picks so far add to one unit, for the live\n * price. Display only; every sale door prices them again from the product.\n */\nexport function productPageAddOns(\n product: Pick<Detail, 'name' | 'modifierGroups'>,\n picks: readonly CommerceModel.ModifierSelection[],\n variantId: string | undefined,\n): { ready: boolean; extraCents: number; error?: string } {\n const groups = product.modifierGroups ?? []\n if (!groups.length) return { ready: true, extraCents: 0 }\n const source = { name: product.name, modifierGroups: groups }\n const checked = CommerceModel.resolveLineModifiers(source, picks, variantId)\n const extraCents = CommerceModel.soldLineModifiers(source, picks, variantId).reduce(\n (sum, modifier) => sum + modifier.priceCents,\n 0,\n )\n return checked.ok\n ? { ready: true, extraCents }\n : { ready: false, extraCents, ...(checked.error ? { error: checked.error } : {}) }\n}\n\n/**\n * What the picks add to one unit in the shopper's currency (AGL-4248): each\n * add-on converted on its own, its fixed amount winning, as the cart and\n * checkout price it.\n */\nexport function productPageAddOnsMinor(\n product: Pick<Detail, 'name' | 'modifierGroups'>,\n picks: readonly CommerceModel.ModifierSelection[],\n variantId: string | undefined,\n amountMinor: (baseCents: number, fixedMinor?: Record<string, number>) => number,\n): number {\n const groups = product.modifierGroups ?? []\n if (!groups.length) return 0\n return CommerceModel.soldLineModifiers({ modifierGroups: groups }, picks, variantId).reduce(\n (sum, modifier) => {\n const option = groups\n .find((group) => group.id === modifier.groupId)\n ?.options.find((entry) => entry.id === modifier.optionId)\n return sum + amountMinor(modifier.priceCents, option?.fixedPriceCents)\n },\n 0,\n )\n}\n\n/** How one option is offered on the page. */\nexport interface OptionPresentation {\n name: string\n /** The values a shopper can actually get, in the option's own order. */\n values: string[]\n /**\n * `select` only when there is a real choice — two or more values that\n * variants carry; `text` for the one value every variant has (\"Scent:\n * Lavender\"); `hidden` for an option with no value at all.\n */\n mode: 'select' | 'text' | 'hidden'\n}\n\n/**\n * Which options are a CHOICE (AGL-3676 follow-up). A select with one entry —\n * or with entries no variant carries — is not a choice, and on a live store\n * it read as a broken control: an AI-built candle listed a \"Scent\" select\n * that offered nothing to pick. Decided from the variants, which are what is\n * sold: an option's values count only where a variant carries them, and only\n * when no variant names the option at all do its listed values stand in —\n * and then as a choice only when there are several variants to choose among.\n */\nexport function optionPresentation(\n options: readonly CommerceModel.ProductOption[],\n variants: ReadonlyArray<Pick<DetailVariant, 'options'>>,\n): OptionPresentation[] {\n return options.map((option) => {\n const listed = [\n ...new Set(\n (option.values ?? []).map((value) => String(value).trim()).filter(Boolean),\n ),\n ]\n const carried = new Set(\n variants\n .map((variant) => variant.options?.[option.name])\n .filter(\n (value): value is string => typeof value === 'string' && value.trim() !== '',\n ),\n )\n const values = carried.size\n ? [\n ...listed.filter((value) => carried.has(value)),\n ...[...carried].filter((value) => !listed.includes(value)),\n ]\n : variants.length > 1 || listed.length === 1\n ? listed\n : []\n return {\n name: option.name,\n values,\n mode: values.length >= 2 ? 'select' : values.length === 1 ? 'text' : 'hidden',\n }\n })\n}\n\n/** The selections a page opens on: the first variant on sale, else the first. */\nfunction initialSelections(\n product: Pick<Detail, 'variants'> | undefined,\n): Record<string, string> {\n const first =\n product?.variants.find((variant) => !variant.soldOut) ?? product?.variants[0]\n return { ...(first?.options ?? {}) }\n}\n\nfunction slugFromLocation(): string {\n if (typeof window === 'undefined') return ''\n const match = window.location.pathname.match(/\\/products\\/([^/?#]+)/)\n return match ? decodeURIComponent(match[1]) : ''\n}\n\n/**\n * Product detail block (AGL-292): gallery, option pickers that resolve\n * the variant (price/media/stock follow), quantity, and a buy button\n * that charges through the server-priced checkout with the selected\n * variant. Resolves its product from the /products/{slug} URL unless a\n * slug prop pins it; sample data on the inert canvas.\n */\nconst ProductDetail = forwardRef<HTMLDivElement, ProductDetailProps>(\n (props, ref) => {\n const {\n slug: slugProp,\n buyLabel,\n hideDescription,\n showCoupon,\n showDetails,\n showShipping,\n choiceStyle,\n mockupLabel,\n children,\n ...rest\n } = props\n /** The product builder (AGL-4205): choices as picture cards. */\n const cards = choiceStyle === 'cards'\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const site = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const { hostId } = site\n // Prices in the shopper's currency (AGL-4248), once the store answers;\n // the cached page and its structured data stay in the store currency.\n const shopper = useShopperCurrency()\n\n // The single-product (\"buy now\") path returns the shopper to this page\n // rather than to the cart, so the PDP is the second of the two surfaces\n // that has to be able to report `purchase` (AGL-1641). Both mount points\n // share one guard, so a page carrying a cart AND a PDP still sends one.\n useStorefrontPurchaseEvent(hostId, siteFetch)\n // Seeded from the server-resolved page data (AGL-659) so the PDP renders\n // its real content in the SSR HTML. Starting at null meant the server\n // emitted a <Skeleton> and the crawler got a product page with no\n // product in it. Absent in the besigner/preview, where the effect below\n // still fetches — so this is an optimisation, not a new requirement.\n const seededCommerce = (\n site.pageData as\n | { commerce?: { product?: Detail; returns?: { windowDays: number } } }\n | undefined\n )?.commerce\n const seededProduct = seededCommerce?.product\n // The store's return window, seeded with the built-in product page only\n // when the store takes returns of this product's kind.\n const seededReturns = seededCommerce?.returns\n const [detail, setDetail] = useState<Detail | null | 'missing'>(\n seededProduct ?? null,\n )\n // Opened on the first variant on sale. A seeded page skips the fetch that\n // used to set this, so it opened with nothing selected — an empty select.\n const [selections, setSelections] = useState<Record<string, string>>(() =>\n initialSelections(seededProduct),\n )\n const [quantity, setQuantity] = useState(1)\n /** The add-ons picked (AGL-4100), ids only. */\n const [addOns, setAddOns] = useState<CommerceModel.ModifierSelection[]>([])\n /** Why the cart refused the line, when it did. */\n const [addRefusal, setAddRefusal] = useState('')\n /**\n * The day the buyer chose to use a pass (AGL-4043), `YYYY-MM-DD` on the\n * store's calendar; '' is the day they buy, which is also the default.\n */\n const [useDay, setUseDay] = useState('')\n /** A discount or coupon code typed on the product page. */\n const [coupon, setCoupon] = useState('')\n // A thumbnail the shopper picked; null follows the variant's own photo.\n const [activeImage, setActiveImage] = useState<number | null>(null)\n /** The canvas's builder sample (AGL-4205), loaded only there, only for picture cards. */\n const [sampleBuilder, setSampleBuilder] = useState<Detail | null>(null)\n useEffect(() => {\n if (hostId || !cards || sampleBuilder) return\n let active = true\n void import('./product-builder-sample').then((module) => {\n if (active) setSampleBuilder(module.SAMPLE_BUILDER as Detail)\n })\n return () => {\n active = false\n }\n }, [hostId, cards, sampleBuilder])\n // `unconfigured` is not an `error` with softer words (AGL-2019). A store\n // with no Stripe key answers 501, and rendering that at `severity=\"error\"`\n // tells a shopper their payment failed when nothing was ever attempted —\n // the same distinction `ask` already makes, and the same one the cart's\n // 423 lockdown branch makes. It is the terminal one: it latches Buy off,\n // because every further click gets the identical refusal.\n const [status, setStatus] = useState<\n 'idle' | 'sending' | 'error' | 'ask' | 'unconfigured'\n >('idle')\n const [message, setMessage] = useState('')\n // The terms of sale and business use, once a checkout of card reader\n // hardware asked for them (AGL-4038).\n const [hardwareTerms, setHardwareTerms] = useState<HardwareTermsAnswer>(NO_HARDWARE_TERMS_ANSWER)\n const [hardwareTermsAsked, setHardwareTermsAsked] = useState(false)\n // Buy-now's half of AGL-1721: asked only when the server refuses to price\n // shipping without a destination, so a digital product, a subscription, or\n // a merchant whose rates are the same everywhere never shows it. `null` is\n // \"not asked\" — the field appearing is the server's answer, not a guess.\n const [shipTo, setShipTo] = useState('')\n const [shipCountries, setShipCountries] = useState<string[] | null>(null)\n // Live carrier rates price by postal code (AGL-3612): asked only when the\n // store prices that way and the server says so.\n const [shipPostal, setShipPostal] = useState('')\n const [askPostal, setAskPostal] = useState(false)\n const [added, setAdded] = useState(false)\n const [wishlisted, setWishlisted] = useState(false)\n // Buyer-chosen billing (AGL-545): only meaningful when the product\n // is subscriptionOptional; defaults to a one-time purchase.\n const [billing, setBilling] = useState<CommerceModel.CheckoutBillingChoice>(\n 'once',\n )\n /**\n * The in-page checkout session (AGL-1944), null on every store until the\n * flag AND a publishable key say otherwise. A `clientSecret` is Stripe's\n * instruction to the browser; holding it says nothing about money having\n * moved, and nothing in this component ever claims it has.\n */\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n /** The seller's account for a direct-charge session. */\n stripeAccount?: string\n /** The wallets the merchant hid (AGL-3629). */\n wallets?: CommerceModel.StorefrontCheckoutWallets\n } | null>(null)\n\n // A product-page template in Preview (AGL-4211): no product pinned and no\n // `/products/{slug}` address, so it shows the store's first listed product\n // (the sample when it lists none). The lookup is its own chunk.\n const template = Boolean(site.preview && hostId && !slugProp && !slugFromLocation())\n const [previewSlug, setPreviewSlug] = useState<string | null>(null)\n useEffect(() => {\n if (!template) return\n let active = true\n void import('./product-preview-slug')\n .then((module) => module.firstListedProductSlug(String(hostId)))\n .then((found) => active && setPreviewSlug(found))\n return () => {\n active = false\n }\n }, [template, hostId])\n const slug = slugProp || slugFromLocation() || previewSlug || ''\n\n useEffect(() => {\n if (hostId && resolvedId) {\n setWishlisted(readLocalWishlist(hostId).includes(resolvedId))\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hostId, detail])\n\n useEffect(() => {\n if (!hostId || !slug) return\n // Already delivered with the page (AGL-659) — refetching the identical\n // payload on hydrate would just be a wasted round trip per visitor.\n if (seededProduct && seededProduct.slug === slug) return\n let active = true\n void fetch(\n `/api/commerce/product?hostId=${encodeURIComponent(hostId)}` +\n `&slug=${encodeURIComponent(slug)}`,\n )\n .then((response) => (response.ok ? response.json() : null))\n .then((payload) => {\n if (!active) return\n const product = payload?.product as Detail | undefined\n setDetail(product ?? 'missing')\n if (product) {\n // GA4 ecommerce mirror (AGL-327), through the shared taxonomy\n // since AGL-1591 rather than raw gtag — same consent gate, same\n // sanitizer, and the name is now checked by the compiler.\n trackEvent('view_item', {\n items: [{ item_id: product.id, item_name: product.name }],\n })\n setSelections(initialSelections(product))\n setAddOns([])\n }\n })\n .catch(() => {\n if (active) setDetail('missing')\n })\n return () => {\n active = false\n }\n }, [hostId, slug])\n\n const resolvedId =\n hostId && detail && detail !== 'missing' ? detail.id : null\n // The template in Preview of a store with no listed product: the sample.\n const previewSample = template && previewSlug === ''\n const resolved: Detail | null = hostId && !previewSample\n ? detail === 'missing'\n ? null\n : detail\n : cards\n ? (sampleBuilder ?? SAMPLE)\n : SAMPLE\n\n const variant = useMemo(() => {\n if (!resolved) return undefined\n return (\n CommerceModel.findVariant(\n { variants: resolved.variants as any },\n selections,\n ) as DetailVariant | undefined\n ) ?? resolved.variants[0]\n }, [resolved, selections])\n\n // The add-ons picked, checked and priced on this variant (AGL-4100).\n const addOnGroups = resolved?.modifierGroups ?? []\n const pageAddOns = resolved\n ? productPageAddOns(resolved, addOns, variant?.id)\n : { ready: true, extraCents: 0 }\n const unitCents =\n typeof variant?.priceUsd === 'number'\n ? Math.round(variant.priceUsd * 100) + pageAddOns.extraCents\n : 0\n // The same unit in the shopper's currency, as the cart and checkout price it.\n const shopperUnitMinor =\n resolved && typeof variant?.priceUsd === 'number'\n ? shopper.variantMinor(variant) +\n productPageAddOnsMinor(resolved, addOns, variant.id, shopper.amountMinor)\n : 0\n const addOnsKey = CommerceModel.modifierSelectionKey(addOns)\n\n // The day to send with this variant: only when it asks for one and the\n // buyer chose a day (AGL-4043).\n const chosenUseDay = variant?.asksUseDate && useDay ? useDay : ''\n // Today on the store's calendar, the first day the picker offers.\n const storeTodayKey = resolved?.useDayTimeZone\n ? zonedDayKey(Date.now(), resolved.useDayTimeZone)\n : ''\n\n // Add to cart (AGL-293) beside instant buy; badge refresh via event.\n const handleAddToCart = async () => {\n // A required add-on unanswered is refused here, before any request\n // (AGL-4100); the button says so too.\n if (!hostId || !resolved || !variant || !pageAddOns.ready) return\n setAdded(false)\n setAddRefusal('')\n // Priced (AGL-1591's shape, completed): the resolved variant's price\n // and the chosen quantity both come from the server's product payload,\n // so GA4's \"value added to cart\" is a real number. The funnel step\n // (AGL-3605) and the badge refresh ride the same shared helper the\n // product grid's quick add uses.\n const ok = await addToCart({\n hostId,\n siteFetch,\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n ...(chosenUseDay ? { useDayKey: chosenUseDay } : {}),\n ...(addOns.length ? { modifiers: addOns } : {}),\n item: buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined),\n onRefused: setAddRefusal,\n })\n if (ok) setAdded(true)\n }\n\n /**\n * Idempotency key for ONE buy-now attempt (AGL-1697).\n *\n * Minted lazily on the first buy click, retired whenever the purchase\n * changes shape — a different product, variant, quantity, billing choice\n * or destination is a different attempt. A retry of THIS attempt presents\n * the same key, so the server replays the original session instead of\n * opening a second one (for a subscription product, a second RECURRING\n * subscription).\n */\n // Pickup or the store's own delivery (AGL-3624), for a one-time sale; the\n // server offers nothing for a product with nothing physical to collect.\n const fulfillment = useCartFulfillment(\n hostId,\n resolved?.id ?? '[]',\n resolved &&\n variant &&\n !(resolved.subscription && (!resolved.subscriptionOptional || billing === 'subscribe'))\n ? {\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n ...(addOns.length ? { modifiers: addOns } : {}),\n }\n : null,\n )\n const attemptKey = useRef('')\n useEffect(() => {\n attemptKey.current = ''\n // `coupon` is in here because it CHANGES THE PRICE. Without it a shopper\n // who buys, comes back, types a code and buys again presents the same\n // key, and the server replays the original full-price session — a quoted\n // number that is not the number charged, which is the whole defect class\n // this path has been cleared of.\n // `addOnsKey` too: different add-ons are a different price (AGL-4100).\n }, [resolved?.id, variant?.id, quantity, billing, shipTo, shipPostal, coupon, fulfillment.signature, chosenUseDay, addOnsKey])\n\n const handleBuy = async () => {\n if (!hostId || !resolved || !variant || status === 'sending' || !pageAddOns.ready) return\n setStatus('sending')\n setMessage('')\n if (!attemptKey.current) {\n attemptKey.current =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n try {\n const response = await siteFetch('/api/commerce/checkout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Idempotency-Key': attemptKey.current,\n },\n body: JSON.stringify({\n hostId,\n productId: resolved.id,\n variantId: variant.id,\n quantity,\n // The day the buyer will use it (AGL-4043); the server checks it\n // against the product and the store's calendar.\n ...(chosenUseDay ? { useDayKey: chosenUseDay } : {}),\n // The add-ons picked (AGL-4100), ids only: the server checks every\n // required one is answered and prices them from the product.\n ...(addOns.length ? { modifiers: addOns } : {}),\n // Billing choice (AGL-545): the server re-validates against\n // the product doc, so this is a request, not an instruction.\n ...(resolved.subscriptionOptional ? { billing } : {}),\n // Likewise a request (AGL-1721): the server resolves this\n // country's rates AND restricts the session to addresses in it,\n // so naming a cheap zone here cannot ship a parcel anywhere else.\n ...(shipTo && !fulfillment.request ? { shippingCountry: shipTo } : {}),\n ...(shipPostal.trim() && !fulfillment.request ? { shippingPostalCode: shipPostal.trim() } : {}),\n // Where and when, never the fee (AGL-3624).\n ...(fulfillment.request ? { fulfillment: fulfillment.request } : {}),\n // The currency the shopper sees (AGL-4248), a request: the server\n // charges in it only where the store sells in it.\n ...(shopper.ready ? { currency: shopper.code } : {}),\n // The server resolves this against the discounts hub first and the\n // legacy coupons second, and refuses a code it cannot apply with a\n // reason — never a silent full-price charge.\n ...(coupon.trim() ? { couponCode: coupon.trim() } : {}),\n // The buyer's answers for card reader hardware (AGL-4038), once asked.\n ...(hardwareTermsAsked ? { hardwareTerms } : {}),\n // The visitor's advertising consent and the vendors' browser ids, only\n // where that consent grants advertising (AGL-3694); absent otherwise.\n ...advertisingConsentField(hostId),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // In-page payment (AGL-1944). A native session returns a client secret\n // and NO url — the two are mutually exclusive by construction, so the\n // redirect branch below is unreachable in native mode and vice versa.\n // Checked FIRST so a server that somehow sent both cannot silently\n // navigate the shopper away from the form we just decided to show.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n // Buy-now's `begin_checkout`. The cart path has reported this since\n // AGL-1591 and this one never did, so a storefront whose shoppers\n // skip the cart showed `view_item` → `add_to_cart` → nothing →\n // `purchase`: GA4's shopping funnel put every single-product sale in\n // the \"abandoned checkout\" bucket, and the merchant's checkout rate\n // read as a collapse rather than as an unmeasured path.\n //\n // Reported on BOTH branches, and from the same place, for the reason\n // the cart states: a count that halved the day the in-page payment\n // flag flipped would look like a conversion collapse.\n trackEvent(\n 'begin_checkout',\n buildBeginCheckoutParams({\n items: [buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined)],\n }),\n )\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n ...(payload.stripeAccount\n ? { stripeAccount: String(payload.stripeAccount) }\n : {}),\n wallets: CommerceModel.readStorefrontCheckoutWallets(payload.wallets),\n })\n setStatus('idle')\n return\n }\n if (response.ok && payload?.url) {\n // Awaited before the redirect (AGL-1580), for the reason spelled out\n // on the cart's matching branch: delivery here is a synchronous\n // `window.gtag` call today and the await costs nothing, but the\n // property that makes a bare call safe is invisible from this file.\n await trackEventBeforeNavigation(\n 'begin_checkout',\n buildBeginCheckoutParams({\n items: [buyItem(resolved, variant, quantity, addOnGroups.length ? unitCents : undefined)],\n }),\n )\n window.location.assign(payload.url)\n return\n }\n // Card reader hardware needs the terms of sale ticked (AGL-4038).\n if (payload?.needsHardwareTerms) {\n setHardwareTermsAsked(true)\n setMessage(String(payload?.error ?? ''))\n setStatus('ask')\n return\n }\n // Buy-now's half of AGL-2019. The server's own 501 wording is not\n // rendered to a visitor; this surface is public.\n if (payload?.fulfillmentChanged) {\n fulfillment.reload()\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n return\n }\n if (isPaymentsNotConfigured(response.status)) {\n setMessage(storefrontPaymentsNotConfiguredText())\n setStatus('unconfigured')\n return\n }\n if (payload?.needsShippingCountry) {\n if (payload?.needsShippingPostalCode) setAskPostal(true)\n setShipCountries(\n (payload.shippingCountries as string[] | undefined)?.length\n ? (payload.shippingCountries as string[])\n : [...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES],\n )\n setMessage(String(payload?.error ?? ''))\n // An unserved destination is a refusal and reads as one; being\n // asked the first time is not.\n setStatus(shipTo ? 'error' : 'ask')\n return\n }\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n } catch {\n setStatus('error')\n }\n }\n\n if (hostId && !previewSample && detail === null) {\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'flex', gap: 3 }, ...nodeSx]}>\n <Skeleton variant=\"rectangular\" width={320} height={320} />\n <Box sx={{ flex: 1 }}>\n <Skeleton width=\"60%\" height={36} />\n <Skeleton width=\"25%\" />\n <Skeleton width=\"90%\" />\n </Box>\n </Box>\n )\n }\n if (!resolved) {\n return (\n <Box ref={ref} {...rest} sx={[{ p: 3 }, ...nodeSx]}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Product not found.'}\n </Typography>\n </Box>\n )\n }\n\n // Every rendered `<img src>` on this page goes through\n // `siteRelativeMediaSrc` (AGL-1726). Commerce called NO resolver at all,\n // which cost it two things at once: a `media:` reference — writable via\n // the resources API and the CSV importer — would have reached an `<img>`\n // as the literal string, and a stored absolute\n // `https://{subdomain}.aglyn.app/api/media/cdn/…` stayed absolute, so a\n // white-label storefront on the customer's own domain served product\n // photos naming OUR platform, cross-origin, in page source and in every\n // visitor's request. Production carried exactly one such document; the\n // resolver fixes it at READ time, so no backfill stands between the\n // defect and the fix.\n //\n // Deliberately NOT applied to `resolved.mediaUrls` wholesale: the\n // schema.org `image` array below is read out of band by a crawler, where\n // an absolute URL is the point. That one wants `absoluteMediaSrc` with\n // the site's own origin, which is the tenant page's job (AGL-1725).\n const galleryImage = Aglyn.siteRelativeMediaSrc(\n (activeImage !== null ? resolved.mediaUrls[activeImage] : undefined) ??\n variant?.imageUrl ??\n resolved.mediaUrls[0],\n { hostId },\n )\n const presentedOptions = optionPresentation(resolved.options, resolved.variants)\n\n // Subscription framing (AGL-545): subscription-only products price as\n // $X/mo|/yr with a \"Subscribe\" button; subscriptionOptional products\n // surface the one-time/subscribe toggle instead. Same price either way\n // — the server re-prices from the product doc regardless.\n const subscription = resolved.subscription\n const intervalSuffix = subscription?.interval === 'year' ? '/yr' : '/mo'\n const subscribing =\n Boolean(subscription) &&\n (!resolved.subscriptionOptional || billing === 'subscribe')\n // Listed before it has a price (AGL-3676): no price to show and nothing\n // to buy; every sale door would refuse it anyway.\n const priced = typeof variant?.priceUsd === 'number'\n // The add-ons are offered where they can be priced, and on a product that\n // offers a free mockup, whose request carries them (AGL-4205).\n // Live, the button shows only where the block holds a request form to\n // open; on the canvas the block shows the space to drop one in.\n const hasRequestForm = Children.toArray(children).length > 0\n const offersMockup = hostId\n ? resolved.mockupRequests === true && hasRequestForm\n : resolved.mockupRequests === true || hasRequestForm\n const showAddOns = addOnGroups.length > 0 && (priced || offersMockup)\n\n // schema.org Product/Offer (AGL-299). Kept ONLY for the case where this\n // block renders without server-seeded page data — the besigner preview,\n // or a page whose resolver didn't supply it. When the tenant page seeds\n // us it emits the same Product node server-side (AGL-660), and two\n // Product nodes for one item is worse than one, so we stand down.\n const structuredData =\n hostId && resolvedId && !seededProduct\n ? {\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: resolved.name,\n ...(resolved.description\n ? { description: resolved.description }\n : {}),\n ...(resolved.mediaUrls.length\n ? { image: resolved.mediaUrls }\n : {}),\n // No offer without a price: a price of 0 would read as free.\n ...(priced\n ? {\n offers: {\n '@type': 'Offer',\n priceCurrency: 'USD',\n price: String(variant?.priceUsd),\n availability: variant?.soldOut\n ? 'https://schema.org/OutOfStock'\n : 'https://schema.org/InStock',\n },\n }\n : {}),\n }\n : null\n\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n display: 'flex',\n gap: 3,\n flexDirection: { xs: 'column', md: 'row' },\n },\n ...nodeSx,\n ]}\n >\n <CheckoutReturnNotice hostId={hostId} siteFetch={siteFetch} />\n <Box sx={{ flex: 1, minWidth: 0 }}>\n {galleryImage ? (\n <Box\n component=\"img\"\n src={galleryImage}\n alt={resolved.name}\n // DELIBERATELY NOT DEFERRED (AGL-2486). This is the gallery\n // hero at the top of a product page — the one image on this\n // surface that really is the LCP candidate, and the browser\n // default here is already `eager`. Spreading\n // `DEFERRED_IMAGE_ATTRIBUTES` over it to \"finish the job\" is\n // the obvious next edit and it re-introduces the bug this\n // issue opened with: an LCP image not discovered until after\n // layout has run. The thumbnail strip below it IS deferred.\n //\n // No `fetchpriority` either, for the reason written out at\n // `image.tsx`: `high` is a claim about every other request in\n // flight, and a page whose real LCP is the product NAME would\n // pay for that claim.\n sx={{\n width: '100%',\n aspectRatio: '1 / 1',\n objectFit: 'cover',\n borderRadius: 1,\n }}\n />\n ) : (\n <Box\n sx={{\n width: '100%',\n aspectRatio: '1 / 1',\n bgcolor: 'action.hover',\n borderRadius: 1,\n }}\n />\n )}\n {resolved.mediaUrls.length > 1 ? (\n <Box sx={{ display: 'flex', gap: 1, mt: 1, flexWrap: 'wrap' }}>\n {resolved.mediaUrls.map((url, index) => (\n <Box\n key={`${url}-${index}`}\n component=\"img\"\n // Same resolver as the hero (AGL-1726) — a thumbnail is an\n // `<img>` on the customer's page and leaks exactly as much.\n src={Aglyn.siteRelativeMediaSrc(url, { hostId })}\n alt=\"\"\n onClick={() => setActiveImage(index)}\n sx={{\n width: 64,\n height: 64,\n objectFit: 'cover',\n borderRadius: 1,\n cursor: 'pointer',\n border: 2,\n borderColor:\n index === (activeImage ?? 0) ? 'primary.main' : 'transparent',\n }}\n // Deferred (AGL-2486): 56px thumbnails that exist to swap\n // the hero above. They were fetching eagerly ALONGSIDE\n // that hero, so a five-image gallery had the hero\n // competing with four thumbnails nobody had asked for yet.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ))}\n </Box>\n ) : null}\n </Box>\n {structuredData ? (\n <script\n type=\"application/ld+json\"\n dangerouslySetInnerHTML={{ __html: Aglyn.safeJsonLd(structuredData) }}\n />\n ) : null}\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"h4\" component=\"h1\" gutterBottom>\n {resolved.name}\n </Typography>\n <Box sx={{ display: 'flex', gap: 1, alignItems: 'center', mb: 2 }}>\n <Typography variant=\"h6\">\n {/* The configured unit (AGL-4100): the variant and its add-ons, formatted. */}\n {priced\n ? `${shopper.format(shopperUnitMinor)}${subscribing ? intervalSuffix : ''}`\n : PRICE_COMING_SOON_LABEL}\n </Typography>\n {subscribing && subscription?.trialDays ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${subscription.trialDays}-day free trial`}\n </Typography>\n ) : null}\n {variant?.compareAtPriceUsd ? (\n <>\n <Typography\n variant=\"body1\"\n color=\"text.secondary\"\n sx={{ textDecoration: 'line-through' }}\n >\n {shopper.formatVariant({ priceUsd: variant.compareAtPriceUsd })}\n </Typography>\n <Chip label=\"Sale\" size=\"small\" color=\"primary\" />\n </>\n ) : null}\n {variant?.soldOut ? (\n <Chip label=\"Sold out\" size=\"small\" variant=\"outlined\" />\n ) : null}\n <Button\n size=\"small\"\n onClick={async () => {\n if (hostId && resolved.id !== 'sample') {\n setWishlisted(await toggleWishlist(hostId, resolved.id, siteFetch))\n }\n }}\n >\n {wishlisted ? '♥ Saved' : '♡ Save'}\n </Button>\n </Box>\n {subscription && resolved.subscriptionOptional ? (\n <ToggleButtonGroup\n value={billing}\n exclusive\n size=\"small\"\n onChange={(_event, value) => {\n if (value === 'once' || value === 'subscribe') {\n setBilling(value)\n }\n }}\n sx={{ mb: 2 }}\n >\n <ToggleButton value=\"once\">\n {priced ? `One-time ${shopper.format(shopperUnitMinor)}` : 'One-time'}\n </ToggleButton>\n <ToggleButton value=\"subscribe\">\n {priced ? `Subscribe ${shopper.format(shopperUnitMinor)}${intervalSuffix}` : 'Subscribe'}\n </ToggleButton>\n </ToggleButtonGroup>\n ) : null}\n {cards ? (\n // The product builder (AGL-4205): every choice a picture card.\n <Suspense fallback={null}>\n <ProductChoiceCards\n options={presentedOptions.filter((option) => option.mode === 'select')}\n variants={resolved.variants}\n selections={variant?.options ?? selections}\n onSelect={(name, value) => {\n setActiveImage(null)\n setSelections((prev) => ({ ...(variant?.options ?? {}), ...prev, [name]: value }))\n }}\n groups={showAddOns ? addOnGroups : []}\n variantId={variant?.id}\n value={addOns}\n onChange={setAddOns}\n formatCents={shopper.formatBaseCents}\n formatAddOn={shopper.formatAddOn}\n formatVariant={shopper.formatVariant}\n unpricedLabel={PRICE_COMING_SOON_LABEL}\n disabled={Boolean(variant?.soldOut)}\n />\n </Suspense>\n ) : null}\n {presentedOptions.map((option) =>\n cards && option.mode === 'select' ? null : option.mode === 'hidden' ? null : option.mode === 'text' ? (\n <Typography\n key={option.name}\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ mb: 1.5 }}\n >\n {`${option.name}: ${option.values[0]}`}\n </Typography>\n ) : (\n <TextField\n key={option.name}\n label={option.name}\n value={\n option.values.includes(selections[option.name] ?? '')\n ? selections[option.name]\n : ''\n }\n onChange={(event) => {\n // A new variant shows its own photo, not the last thumbnail.\n setActiveImage(null)\n setSelections((prev) => ({\n ...prev,\n [option.name]: event.target.value,\n }))\n }}\n size=\"small\"\n select\n fullWidth\n sx={{ mb: 1.5 }}\n >\n {option.values.map((value) => (\n <MenuItem key={value} value={value}>\n {value}\n </MenuItem>\n ))}\n </TextField>\n ),\n )}\n {showAddOns && !cards ? (\n <Suspense fallback={null}>\n <ProductAddOns\n groups={addOnGroups}\n variantId={variant?.id}\n value={addOns}\n onChange={setAddOns}\n formatCents={shopper.formatBaseCents}\n formatAddOn={shopper.formatAddOn}\n disabled={Boolean(variant?.soldOut)}\n />\n </Suspense>\n ) : null}\n {showCoupon ? (\n <TextField\n label=\"Discount code\"\n value={coupon}\n onChange={(event) => setCoupon(event.target.value)}\n size=\"small\"\n sx={{ mb: 2, display: 'block' }}\n />\n ) : null}\n {!priced ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mb: 2 }}>\n {'Not on sale yet — check back soon.'}\n </Typography>\n ) : null}\n {priced && variant?.asksUseDate && storeTodayKey ? (\n <Box sx={{ mb: 2 }}>\n <Suspense fallback={null}>\n <UseDayPicker\n value={useDay}\n onChange={setUseDay}\n todayKey={storeTodayKey}\n label=\"Day you will use it (optional)\"\n helperText=\"Leave it blank to use it the day you buy.\"\n />\n </Suspense>\n </Box>\n ) : null}\n <Box sx={{ display: priced ? 'flex' : 'none', gap: 1.5, alignItems: 'center', mb: 2 }}>\n <TextField\n label=\"Qty\"\n value={quantity}\n onChange={(event) =>\n setQuantity(\n Math.max(\n 1,\n Math.min(CommerceModel.CART_MAX_QUANTITY, Math.round(Number(event.target.value)) || 1),\n ),\n )\n }\n size=\"small\"\n // Four digits fit (AGL-4205): a line goes up to 9,999.\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n variant=\"outlined\"\n color=\"primary\"\n size=\"large\"\n disabled={!hostId || !priced || variant?.soldOut || !pageAddOns.ready}\n onClick={handleAddToCart}\n >\n {added ? 'Added ✓' : 'Add to cart'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n size=\"large\"\n disabled={\n !hostId ||\n !priced ||\n status === 'sending' ||\n variant?.soldOut ||\n // A required add-on unanswered (AGL-4100).\n !pageAddOns.ready ||\n // No payments on this deployment: the same 501 every time, so\n // the control latches off rather than inviting a retry that\n // cannot succeed (AGL-2019).\n status === 'unconfigured' ||\n // Asked but unanswered: the server would only refuse again.\n (fulfillment.method === 'shipping' && shipCountries !== null && !shipTo) ||\n (fulfillment.method === 'shipping' && askPostal && !shipPostal.trim()) ||\n !fulfillment.ready ||\n // Card reader hardware: both boxes ticked (AGL-4038).\n (hardwareTermsAsked && !hardwareTermsAnswered(hardwareTerms))\n }\n onClick={handleBuy}\n sx={{ flex: 1 }}\n >\n {variant?.soldOut\n ? 'Sold out'\n : status === 'sending'\n ? // \"Redirecting\" is a lie once the form opens in place, and\n // it is the shopper's only clue about what is about to\n // happen to their page (AGL-1944).\n nativeCheckout\n ? 'Opening…'\n : 'Redirecting…'\n : buyLabel || (subscribing ? 'Subscribe' : 'Buy now')}\n </Button>\n </Box>\n {/*\n The live price with add-ons (AGL-4100): one configured unit\n times the quantity, and what is still to choose.\n */}\n {(addOnGroups.length || cards) && priced ? (\n <Box sx={{ mb: 2 }} aria-live=\"polite\">\n <Typography variant=\"subtitle1\" component=\"p\">\n {quantity > 1\n ? `Total for ${quantity}: ${shopper.format(shopperUnitMinor * quantity)}`\n : `Total: ${shopper.format(shopperUnitMinor)}`}\n </Typography>\n {!pageAddOns.ready && pageAddOns.error && !variant?.soldOut ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pageAddOns.error}\n </Typography>\n ) : null}\n </Box>\n ) : null}\n {/*\n The free mockup (AGL-4205): on a product that offers one, the\n button opens what the site builder dropped into this block — a\n request form whose Product and options field reads the picks from\n the context below. On the canvas the form stays open to design.\n */}\n {offersMockup ? (\n <Suspense fallback={null}>\n <ProductBuilderMockup\n picks={{\n product: resolved,\n variant,\n addOns,\n quantity,\n ready: pageAddOns.ready,\n problem: pageAddOns.ready ? undefined : pageAddOns.error,\n total: priced ? shopper.format(shopperUnitMinor * quantity) : undefined,\n }}\n label={mockupLabel}\n priced={priced}\n canvas={!hostId}\n hasRequestForm={hasRequestForm}\n >\n {children}\n </ProductBuilderMockup>\n </Suspense>\n ) : null}\n {addRefusal ? (\n <Alert severity=\"warning\" sx={{ mb: 2 }}>\n {addRefusal}\n </Alert>\n ) : null}\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n stripeAccount={nativeCheckout.stripeAccount}\n wallets={nativeCheckout.wallets}\n payLabel={buyLabel || (subscribing ? 'Subscribe' : 'Pay now')}\n // An expired or unloadable session is replaced, never\n // replayed: the old attempt key would hand back the dead one.\n onRestart={() => {\n attemptKey.current = ''\n setNativeCheckout(null)\n void handleBuy()\n }}\n // Cancelling drops the form and leaves the session open —\n // deliberately. The shopper may come back to the same\n // attempt key, and an abandoned session is what the AGL-323\n // recovery emails are built on. Nothing is expired from the\n // browser: that is a write against the merchant's account.\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : null}\n {fulfillment.offered && priced ? (\n <Box sx={{ mb: 2 }}>\n <CartFulfillmentChoice\n state={fulfillment}\n formatCents={shopper.formatBaseCents}\n />\n </Box>\n ) : null}\n {shipCountries && fulfillment.method === 'shipping' && priced ? (\n <TextField\n select\n label=\"Ship to\"\n value={shipTo}\n onChange={(event) => setShipTo(event.target.value)}\n size=\"small\"\n fullWidth\n helperText=\"Shipping rates depend on where this is going\"\n sx={{ mb: 2 }}\n >\n {shipCountries.map((code) => (\n <MenuItem key={code} value={code}>\n {CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code] ?? code}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {askPostal && fulfillment.method === 'shipping' && priced ? (\n <TextField\n label=\"Postal code\"\n value={shipPostal}\n onChange={(event) => setShipPostal(event.target.value)}\n size=\"small\"\n fullWidth\n helperText=\"Carrier rates depend on the postal code\"\n slotProps={{ htmlInput: { autoComplete: 'shipping postal-code', maxLength: 12 } }}\n sx={{ mb: 2 }}\n />\n ) : null}\n {hardwareTermsAsked ? <HardwareTermsConsent answer={hardwareTerms} onChange={setHardwareTerms} /> : null}\n {status === 'ask' || status === 'unconfigured' ? (\n <Alert severity=\"info\" sx={{ mb: 2 }}>\n {message}\n </Alert>\n ) : null}\n {status === 'error' ? (\n <Alert severity=\"error\" sx={{ mb: 2 }}>\n {message || 'Checkout is unavailable right now.'}\n </Alert>\n ) : null}\n {variant?.soldOut && hostId ? (\n // The back-in-stock alert, only on a sold-out variant (its own chunk, AGL-4205).\n <Suspense fallback={null}>\n <ProductRestockNotify hostId={hostId} productId={resolved.id} siteFetch={siteFetch} />\n </Suspense>\n ) : null}\n {!hideDescription && resolved.description ? (\n <Typography\n variant=\"body1\"\n color=\"text.secondary\"\n sx={{ whiteSpace: 'pre-line' }}\n >\n {resolved.description}\n </Typography>\n ) : null}\n {/*\n The Details and Shipping & returns folds, off by default, in\n their own chunk (AGL-4205): a page that shows neither loads none.\n */}\n {showDetails || showShipping ? (\n <Suspense fallback={null}>\n <ProductDetailPanels\n product={resolved}\n variant={variant}\n presented={presentedOptions}\n returns={seededProduct?.id === resolved.id ? seededReturns : undefined}\n showDetails={Boolean(showDetails)}\n showShipping={Boolean(showShipping)}\n />\n </Suspense>\n ) : null}\n </Box>\n </Box>\n )\n },\n)\nProductDetail.displayName = 'AglynProductDetail'\n\nexport const schema: Aglyn.ComponentSchema<ProductDetailProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Product detail',\n description: \"One product's gallery, options and buy button.\",\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n // Not self-closing since AGL-4205: what is dropped in is the request form\n // \"Get a free mockup\" opens, shown only for a product that offers one.\n attributes: [\n {\n name: 'slug',\n label: 'Product slug',\n description:\n 'Pin to one product; blank follows the /products/{slug} URL ' +\n '(product page template).',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'buyLabel',\n label: 'Buy button label',\n description: 'Defaults to \"Buy now\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'hideDescription',\n label: 'Hide description',\n description: 'Design the description separately with tokens.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // Off by default, so no existing page changes shape on deploy. The cart\n // has carried this field all along and the product page had none, so a\n // shopper buying the same goods through Buy now had nowhere to enter a\n // code the merchant had advertised.\n name: 'showCoupon',\n label: 'Show discount code field',\n description: 'Lets a buyer enter a discount or coupon code before buying.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // Off by default, so no existing page changes shape on deploy.\n name: 'showDetails',\n label: 'Show details panel',\n description:\n 'A Details fold under the description with the facts the product ' +\n 'holds: its options, SKU, tags, and whether it is digital or a service.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n name: 'showShipping',\n label: 'Show shipping & returns panel',\n description:\n 'A Shipping & returns fold: shipping priced at checkout (or digital ' +\n 'delivery), and your return window when your store takes returns.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n // AGL-4205. Absent reads as menus, so no existing page changes shape.\n name: 'choiceStyle',\n label: 'Show choices as',\n description:\n 'Menus, or picture cards: a card per choice with its picture, price and note, and a running total.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { label: 'Menus', value: 'menus' },\n { label: 'Picture cards', value: 'cards' },\n ],\n },\n {\n name: 'mockupLabel',\n label: 'Free mockup button label',\n description:\n 'Shown when the product offers a free mockup and this block holds a request form.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product detail',\n pluginId: BUNDLE_ID,\n description: 'Gallery, variant picker, and buy button for one product',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n {\n // Product page (AGL-561): the commerce-standard PDP subtree —\n // breadcrumb, detail, related products, reviews — for the product\n // page template screen. `{{product.name}}` resolves there via the\n // site page resolver's token pass (AGL-292); node shapes follow\n // the Sections & Blocks convention (AGL-539) and reference only\n // persisted component ids.\n $id: generatePresetId(ID, 'page'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Product page',\n pluginId: BUNDLE_ID,\n description:\n 'Breadcrumb, product detail, related products, and reviews',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiTagOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: 'muiStack',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { spacing: 4 },\n // Styling on the node's own sx, never in props (AGL-1346): both\n // records render, but only `node.sx` is the one the Styles panel can\n // read, edit or clear.\n sx: { paddingTop: 2, paddingBottom: 2 },\n nodes: [\n {\n $id: null,\n componentId: 'muiStack',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { direction: 'row', spacing: 1 },\n sx: { alignItems: 'center' },\n nodes: [\n {\n $id: null,\n componentId: 'muiScreenLink',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { children: 'Shop', size: 'small', color: 'inherit' },\n },\n {\n $id: null,\n componentId: 'muiTypography',\n pluginId: Aglyn.MUI_BUNDLE_ID,\n props: { variant: 'body2', children: '/ {{product.name}}' },\n },\n ],\n },\n {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n {\n $id: null,\n componentId: RELATED_PRODUCTS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n {\n $id: null,\n componentId: PRODUCT_REVIEWS_ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n ],\n },\n },\n]\n\nexport default ProductDetail\n"],"names":["advertisingConsentField","Aglyn","buildBeginCheckoutParams","trackEvent","trackEventBeforeNavigation","isPaymentsNotConfigured","storefrontPaymentsNotConfiguredText","CommerceModel","mdiTagOutline","Alert","Box","Button","Chip","MenuItem","Skeleton","TextField","ToggleButton","ToggleButtonGroup","Typography","Children","Suspense","forwardRef","lazy","useEffect","useMemo","useRef","useState","BUNDLE_ID","generatePresetId","useStorefrontPurchaseEvent","addToCart","CartFulfillmentChoice","useCartFulfillment","HardwareTermsConsent","hardwareTermsAnswered","NO_HARDWARE_TERMS_ANSWER","ID","PRODUCT_REVIEWS_ID","RELATED_PRODUCTS_ID","readLocalWishlist","toggleWishlist","StorefrontPaymentElementFallback","CheckoutReturnNotice","useShopperCurrency","zonedDayKey","StorefrontPaymentElement","then","module","default","PRICE_COMING_SOON_LABEL","UseDayPicker","ProductAddOns","ProductChoiceCards","ProductBuilderMockup","ProductRestockNotify","ProductDetailPanels","SAMPLE","id","name","slug","description","mediaUrls","options","values","variants","Size","priceUsd","soldOut","buyItem","product","variant","quantity","unitCents","item_id","item_name","price","undefined","productPageAddOns","picks","variantId","groups","modifierGroups","length","ready","extraCents","source","checked","resolveLineModifiers","soldLineModifiers","reduce","sum","modifier","priceCents","ok","error","productPageAddOnsMinor","amountMinor","option","find","group","groupId","entry","optionId","fixedPriceCents","optionPresentation","map","listed","Set","value","String","trim","filter","Boolean","carried","size","has","includes","mode","initialSelections","first","slugFromLocation","window","match","location","pathname","decodeURIComponent","ProductDetail","props","ref","activeImage","site","slugProp","buyLabel","hideDescription","showCoupon","showDetails","showShipping","choiceStyle","mockupLabel","children","rest","cards","nodeSx","Array","isArray","useSite","siteFetch","useSiteFetch","hostId","shopper","seededCommerce","pageData","commerce","seededProduct","seededReturns","returns","detail","setDetail","selections","setSelections","setQuantity","addOns","setAddOns","addRefusal","setAddRefusal","useDay","setUseDay","coupon","setCoupon","setActiveImage","sampleBuilder","setSampleBuilder","active","SAMPLE_BUILDER","status","setStatus","message","setMessage","hardwareTerms","setHardwareTerms","hardwareTermsAsked","setHardwareTermsAsked","shipTo","setShipTo","shipCountries","setShipCountries","shipPostal","setShipPostal","askPostal","setAskPostal","added","setAdded","wishlisted","setWishlisted","billing","setBilling","nativeCheckout","setNativeCheckout","template","preview","previewSlug","setPreviewSlug","firstListedProductSlug","found","resolvedId","fetch","encodeURIComponent","response","json","payload","items","catch","previewSample","resolved","findVariant","addOnGroups","pageAddOns","Math","round","shopperUnitMinor","variantMinor","addOnsKey","modifierSelectionKey","chosenUseDay","asksUseDate","storeTodayKey","useDayTimeZone","Date","now","handleAddToCart","productId","useDayKey","modifiers","item","onRefused","fulfillment","subscription","subscriptionOptional","attemptKey","current","signature","handleBuy","globalThis","crypto","randomUUID","random","toString","slice","method","headers","body","JSON","stringify","request","shippingCountry","shippingPostalCode","currency","code","couponCode","clientSecret","publishableKey","stripeAccount","wallets","readStorefrontCheckoutWallets","url","assign","needsHardwareTerms","fulfillmentChanged","reload","needsShippingCountry","needsShippingPostalCode","shippingCountries","CHECKOUT_SHIPPING_COUNTRIES","sx","display","gap","width","height","flex","p","color","galleryImage","siteRelativeMediaSrc","imageUrl","presentedOptions","intervalSuffix","interval","subscribing","priced","hasRequestForm","toArray","offersMockup","mockupRequests","showAddOns","structuredData","image","offers","priceCurrency","availability","flexDirection","xs","md","minWidth","component","src","alt","aspectRatio","objectFit","borderRadius","bgcolor","mt","flexWrap","index","onClick","cursor","border","borderColor","DEFERRED_IMAGE_ATTRIBUTES","script","type","dangerouslySetInnerHTML","__html","safeJsonLd","gutterBottom","alignItems","mb","format","trialDays","compareAtPriceUsd","textDecoration","formatVariant","label","exclusive","onChange","_event","fallback","onSelect","prev","formatCents","formatBaseCents","formatAddOn","unpricedLabel","disabled","event","target","select","fullWidth","todayKey","helperText","max","min","CART_MAX_QUANTITY","Number","theme","spacing","slotProps","htmlInput","inputMode","aria-live","problem","total","canvas","severity","payLabel","onRestart","onCancel","offered","state","CHECKOUT_SHIPPING_COUNTRY_NAMES","autoComplete","maxLength","answer","whiteSpace","presented","displayName","schema","$id","pluginId","category","ComponentCategory","COMMERCE","icon","path","attributes","FieldComponentType","TEXT_FIELD","CHECKBOX","SELECT","presets","NodeType","PRESET","data","componentId","MUI_BUNDLE_ID","paddingTop","paddingBottom","nodes","direction"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,uBAAuB,QAAQ,6CAA4C;AACpF,YAAYC,WAAW,eAAc;AACrC,SACEC,wBAAwB,EACxBC,UAAU,EACVC,0BAA0B,QAErB,0CAAyC;AAChD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,mCAAmC,QAAQ,sCAAkC;AACtF,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,aAAa,QAAQ,yBAAwB;AACtD,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,kBAAkB,6BAA4B;AACrD,OAAOC,uBAAuB,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AAE8Q,WAAW;wBAAO3C,SAAS;oBAAE;oBACtCjF,IAAI;wBAAEmD,YAAY;oBAAS;oBAC3BwE,OAAO;wBACL;4BACEpB,KAAK;4BACLgB,aAAa;4BACbf,UAAUxX,MAAMwY,aAAa;4BAC7B1Q,OAAO;gCAAEY,UAAU;gCAAQzB,MAAM;gCAASsK,OAAO;4BAAU;wBAC7D;wBACA;4BACEgG,KAAK;4BACLgB,aAAa;4BACbf,UAAUxX,MAAMwY,aAAa;4BAC7B1Q,OAAO;gCAAEzD,SAAS;gCAASqE,UAAU;4BAAqB;wBAC5D;qBACD;gBACH;gBACA;oBACE6O,KAAK;oBACLgB,aAAapW;oBACbqV,UAAU9V;oBACVoG,OAAO,CAAC;gBACV;gBACA;oBACEyP,KAAK;oBACLgB,aAAalW;oBACbmV,UAAU9V;oBACVoG,OAAO,CAAC;gBACV;gBACA;oBACEyP,KAAK;oBACLgB,aAAanW;oBACboV,UAAU9V;oBACVoG,OAAO,CAAC;gBACV;aACD;QACH;IACF;CACD,CAAA;AAED,eAAeD,cAAa"}
@@ -90,6 +90,8 @@ interface CatalogItem {
90
90
  priceUsd: number;
91
91
  maxPriceUsd: number;
92
92
  compareAtPriceUsd?: number;
93
+ /** The cheapest variant's own prices per currency (AGL-4248). */
94
+ fixedPrices?: Record<string, number>;
93
95
  imageUrl?: string;
94
96
  soldOut: boolean;
95
97
  tags?: string[];
@@ -38,7 +38,7 @@ import { BUNDLE_ID } from "../constants/bundle-common.js";
38
38
  import { STOREFRONT_CATALOG_DECLARATION, STOREFRONT_CATALOG_HEADERS, STOREFRONT_CATALOG_OPTIONS } from "../constants/storefront-catalog-query.js";
39
39
  import { generatePresetId } from "../utils/generate-preset-id.js";
40
40
  import { addToCart } from "../utils/add-to-cart.js";
41
- import { formatOrderMoney } from "../model/buyer-notifications.js";
41
+ import { useShopperCurrency } from "./shopper-currency.js";
42
42
  import { ProductImagePlaceholder } from "./product-image-placeholder.js";
43
43
  import { PRODUCT_PHOTO_FIT_ATTRIBUTE, productPhotoFit, productPhotoFitSx } from "./product-photo-fit.js";
44
44
  import { PRODUCT_NAME_SX } from "./product-name-lines.js";
@@ -149,10 +149,17 @@ function collectionSlugFromLocation() {
149
149
  const match = window.location.pathname.match(/\/collections\/([^/?#]+)/);
150
150
  return match ? decodeURIComponent(match[1]) : '';
151
151
  }
152
- /** A catalog price as the product page prints it: `$3.50`, never `$3.5`. */ const usdLabel = (priceUsd)=>formatOrderMoney(Math.round(priceUsd * 100));
153
- function priceLabel(item) {
152
+ /**
153
+ * A catalog price as the product page prints it (`$3.50`, never `$3.5`), in
154
+ * the shopper's currency (AGL-4248): the card's fixed price there when the
155
+ * merchant set one.
156
+ */ function priceLabel(item, shopper) {
154
157
  if (item.priceComingSoon) return PRICE_COMING_SOON_LABEL;
155
- return item.priceUsd === item.maxPriceUsd ? usdLabel(item.priceUsd) : `From ${usdLabel(item.priceUsd)}`;
158
+ const price = shopper.formatVariant({
159
+ priceUsd: item.priceUsd,
160
+ fixedPrices: item.fixedPrices
161
+ });
162
+ return item.priceUsd === item.maxPriceUsd ? price : `From ${price}`;
156
163
  }
157
164
  /**
158
165
  * Product grid / PLP block (AGL-291): active catalog items from the
@@ -205,6 +212,10 @@ function priceLabel(item) {
205
212
  const site = Aglyn.useSite();
206
213
  const siteFetch = Aglyn.useSiteFetch();
207
214
  const { hostId } = site;
215
+ const shopper = useShopperCurrency();
216
+ // The price filter stays in the store currency (the catalog filters on
217
+ // stored prices), and says so where the store sells in more than one.
218
+ const sliderMoney = (value)=>shopper.currencies.length > 1 ? `${shopper.base} ${value}` : `$${value}`;
208
219
  // Quick add (AGL-3676 follow-up): which card is adding, which just did.
209
220
  const [quickAdding, setQuickAdding] = useState('');
210
221
  const [quickAdded, setQuickAdded] = useState('');
@@ -582,7 +593,7 @@ function priceLabel(item) {
582
593
  sx: {
583
594
  whiteSpace: 'nowrap'
584
595
  },
585
- children: `$${sliderMin}`
596
+ children: sliderMoney(sliderMin)
586
597
  }),
587
598
  /*#__PURE__*/ _jsx(Slider, {
588
599
  size: "small",
@@ -600,7 +611,7 @@ function priceLabel(item) {
600
611
  value
601
612
  ]),
602
613
  valueLabelDisplay: "auto",
603
- valueLabelFormat: (value)=>`$${value}`,
614
+ valueLabelFormat: (value)=>sliderMoney(value),
604
615
  getAriaLabel: (index)=>index === 0 ? 'Minimum price' : 'Maximum price'
605
616
  }),
606
617
  /*#__PURE__*/ _jsx(Typography, {
@@ -609,7 +620,7 @@ function priceLabel(item) {
609
620
  sx: {
610
621
  whiteSpace: 'nowrap'
611
622
  },
612
- children: `$${sliderMax}`
623
+ children: sliderMoney(sliderMax)
613
624
  })
614
625
  ]
615
626
  }) : null
@@ -790,7 +801,7 @@ function priceLabel(item) {
790
801
  /*#__PURE__*/ _jsx(Typography, {
791
802
  variant: "body2",
792
803
  color: "text.secondary",
793
- children: priceLabel(item)
804
+ children: priceLabel(item, shopper)
794
805
  }),
795
806
  item.compareAtPriceUsd ? /*#__PURE__*/ _jsx(Typography, {
796
807
  variant: "caption",
@@ -798,7 +809,9 @@ function priceLabel(item) {
798
809
  sx: {
799
810
  textDecoration: 'line-through'
800
811
  },
801
- children: usdLabel(item.compareAtPriceUsd)
812
+ children: shopper.formatVariant({
813
+ priceUsd: item.compareAtPriceUsd
814
+ })
802
815
  }) : null,
803
816
  item.soldOut ? /*#__PURE__*/ _jsx(Chip, {
804
817
  label: "Sold out",