@aglyn/plugins-commerce 1.15.2 → 1.17.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 (220) hide show
  1. package/README.md +1 -1
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +2 -1
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/console/payments-settings-card.component.js +6 -1
  6. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  7. package/src/lib/components/console/pos/pos-api.d.ts +5 -0
  8. package/src/lib/components/console/pos/pos-api.js.map +1 -1
  9. package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
  10. package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
  11. package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
  12. package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
  13. package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
  14. package/src/lib/components/console/pos-cellular-control.component.d.ts +5 -0
  15. package/src/lib/components/console/pos-cellular-control.component.js +29 -15
  16. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
  17. package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
  18. package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
  19. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  20. package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
  21. package/src/lib/components/console/product-builder-fields.component.js +195 -0
  22. package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
  23. package/src/lib/components/console/product-editor-dialog.component.js +35 -2
  24. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  25. package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
  26. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  27. package/src/lib/components/console/quote-messages.component.d.ts +21 -0
  28. package/src/lib/components/console/quote-messages.component.js +185 -0
  29. package/src/lib/components/console/quote-messages.component.js.map +1 -0
  30. package/src/lib/components/console/quote-pay-link.component.js +1 -1
  31. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  32. package/src/lib/components/console/quote-proofs.component.js +30 -3
  33. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  34. package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
  35. package/src/lib/components/console/quote-settings-card.component.js +154 -24
  36. package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
  37. package/src/lib/components/product-builder-context.d.ts +22 -0
  38. package/src/lib/components/product-builder-context.js +21 -0
  39. package/src/lib/components/product-builder-context.js.map +1 -0
  40. package/src/lib/components/product-builder-mockup.d.ts +42 -0
  41. package/src/lib/components/product-builder-mockup.js +120 -0
  42. package/src/lib/components/product-builder-mockup.js.map +1 -0
  43. package/src/lib/components/product-builder-sample.d.ts +63 -0
  44. package/src/lib/components/product-builder-sample.js +96 -0
  45. package/src/lib/components/product-builder-sample.js.map +1 -0
  46. package/src/lib/components/product-choice-cards.d.ts +51 -0
  47. package/src/lib/components/product-choice-cards.js +311 -0
  48. package/src/lib/components/product-choice-cards.js.map +1 -0
  49. package/src/lib/components/product-detail-panels.d.ts +42 -0
  50. package/src/lib/components/product-detail-panels.js +185 -0
  51. package/src/lib/components/product-detail-panels.js.map +1 -0
  52. package/src/lib/components/product-detail.d.ts +20 -12
  53. package/src/lib/components/product-detail.js +136 -221
  54. package/src/lib/components/product-detail.js.map +1 -1
  55. package/src/lib/components/product-grid.d.ts +7 -0
  56. package/src/lib/components/product-grid.js +13 -9
  57. package/src/lib/components/product-grid.js.map +1 -1
  58. package/src/lib/components/product-name-lines.d.ts +37 -0
  59. package/src/lib/components/product-name-lines.js +36 -0
  60. package/src/lib/components/product-name-lines.js.map +1 -0
  61. package/src/lib/components/product-options-field-body.d.ts +9 -8
  62. package/src/lib/components/product-options-field-body.js +152 -3
  63. package/src/lib/components/product-options-field-body.js.map +1 -1
  64. package/src/lib/components/product-options-field.js +1 -1
  65. package/src/lib/components/product-options-field.js.map +1 -1
  66. package/src/lib/components/product-photo-fit.d.ts +49 -0
  67. package/src/lib/components/product-photo-fit.js +58 -0
  68. package/src/lib/components/product-photo-fit.js.map +1 -0
  69. package/src/lib/components/product-restock-notify.d.ts +12 -0
  70. package/src/lib/components/product-restock-notify.js +86 -0
  71. package/src/lib/components/product-restock-notify.js.map +1 -0
  72. package/src/lib/components/quote-messages-panel.d.ts +21 -0
  73. package/src/lib/components/quote-messages-panel.js +191 -0
  74. package/src/lib/components/quote-messages-panel.js.map +1 -0
  75. package/src/lib/components/quote-page-body.js +15 -1
  76. package/src/lib/components/quote-page-body.js.map +1 -1
  77. package/src/lib/components/quote-proof-panel.d.ts +6 -3
  78. package/src/lib/components/quote-proof-panel.js +139 -14
  79. package/src/lib/components/quote-proof-panel.js.map +1 -1
  80. package/src/lib/components/related-products.d.ts +7 -0
  81. package/src/lib/components/related-products.js +10 -7
  82. package/src/lib/components/related-products.js.map +1 -1
  83. package/src/lib/constants/quote-page.d.ts +8 -0
  84. package/src/lib/constants/quote-page.js +11 -0
  85. package/src/lib/constants/quote-page.js.map +1 -1
  86. package/src/lib/model/commerce-cart.d.ts +6 -1
  87. package/src/lib/model/commerce-cart.js +5 -1
  88. package/src/lib/model/commerce-cart.js.map +1 -1
  89. package/src/lib/model/commerce-invoices.js +5 -1
  90. package/src/lib/model/commerce-invoices.js.map +1 -1
  91. package/src/lib/model/commerce-pos-ops.d.ts +3 -0
  92. package/src/lib/model/commerce-pos-ops.js +3 -0
  93. package/src/lib/model/commerce-pos-ops.js.map +1 -1
  94. package/src/lib/model/commerce-pos.d.ts +8 -0
  95. package/src/lib/model/commerce-pos.js.map +1 -1
  96. package/src/lib/model/commerce-quote-messages.d.ts +106 -0
  97. package/src/lib/model/commerce-quote-messages.js +146 -0
  98. package/src/lib/model/commerce-quote-messages.js.map +1 -0
  99. package/src/lib/model/commerce-quote-pay.d.ts +31 -2
  100. package/src/lib/model/commerce-quote-pay.js +31 -7
  101. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  102. package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
  103. package/src/lib/model/commerce-quote-proofs.js +73 -18
  104. package/src/lib/model/commerce-quote-proofs.js.map +1 -1
  105. package/src/lib/model/commerce-quote-request.d.ts +14 -4
  106. package/src/lib/model/commerce-quote-request.js +25 -2
  107. package/src/lib/model/commerce-quote-request.js.map +1 -1
  108. package/src/lib/model/commerce-quotes.d.ts +56 -3
  109. package/src/lib/model/commerce-quotes.js +47 -2
  110. package/src/lib/model/commerce-quotes.js.map +1 -1
  111. package/src/lib/model/commerce.d.ts +12 -1
  112. package/src/lib/model/commerce.js.map +1 -1
  113. package/src/lib/model/index.d.ts +1 -0
  114. package/src/lib/model/index.js +1 -0
  115. package/src/lib/model/index.js.map +1 -1
  116. package/src/lib/model/pos-cellular.d.ts +36 -4
  117. package/src/lib/model/pos-cellular.js +39 -4
  118. package/src/lib/model/pos-cellular.js.map +1 -1
  119. package/src/lib/model/product-card-rules.d.ts +41 -0
  120. package/src/lib/model/product-card-rules.js +90 -0
  121. package/src/lib/model/product-card-rules.js.map +1 -0
  122. package/src/lib/model/product-modifiers.d.ts +11 -0
  123. package/src/lib/model/product-modifiers.js +10 -0
  124. package/src/lib/model/product-modifiers.js.map +1 -1
  125. package/src/lib/model/product-write.d.ts +3 -0
  126. package/src/lib/server/billing-webhook.js +6 -2
  127. package/src/lib/server/billing-webhook.js.map +1 -1
  128. package/src/lib/server/cancel-order.js +15 -0
  129. package/src/lib/server/cancel-order.js.map +1 -1
  130. package/src/lib/server/channel-order-updates.js +15 -1
  131. package/src/lib/server/channel-order-updates.js.map +1 -1
  132. package/src/lib/server/channel-orders.js +20 -0
  133. package/src/lib/server/channel-orders.js.map +1 -1
  134. package/src/lib/server/checkout.js +1 -1
  135. package/src/lib/server/checkout.js.map +1 -1
  136. package/src/lib/server/local-fulfillment.js +1 -1
  137. package/src/lib/server/local-fulfillment.js.map +1 -1
  138. package/src/lib/server/pos-cellular-billing.d.ts +5 -4
  139. package/src/lib/server/pos-cellular-billing.js +24 -12
  140. package/src/lib/server/pos-cellular-billing.js.map +1 -1
  141. package/src/lib/server/pos-cellular.d.ts +3 -1
  142. package/src/lib/server/pos-cellular.js +55 -33
  143. package/src/lib/server/pos-cellular.js.map +1 -1
  144. package/src/lib/server/pos-offline-sync.d.ts +3 -3
  145. package/src/lib/server/pos-offline-sync.js +17 -4
  146. package/src/lib/server/pos-offline-sync.js.map +1 -1
  147. package/src/lib/server/pos-order.js +17 -6
  148. package/src/lib/server/pos-order.js.map +1 -1
  149. package/src/lib/server/pos-payment.js +27 -11
  150. package/src/lib/server/pos-payment.js.map +1 -1
  151. package/src/lib/server/pos-reader-splash.js +10 -5
  152. package/src/lib/server/pos-reader-splash.js.map +1 -1
  153. package/src/lib/server/pos-readers.js +42 -12
  154. package/src/lib/server/pos-readers.js.map +1 -1
  155. package/src/lib/server/pos-return.js +19 -3
  156. package/src/lib/server/pos-return.js.map +1 -1
  157. package/src/lib/server/pos-stripe.d.ts +14 -0
  158. package/src/lib/server/pos-stripe.js +6 -2
  159. package/src/lib/server/pos-stripe.js.map +1 -1
  160. package/src/lib/server/pos-terminal-connection-token.js +23 -9
  161. package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
  162. package/src/lib/server/pos-terminal.d.ts +80 -14
  163. package/src/lib/server/pos-terminal.js +393 -123
  164. package/src/lib/server/pos-terminal.js.map +1 -1
  165. package/src/lib/server/product-drafts.d.ts +1 -1
  166. package/src/lib/server/product-drafts.js +4 -3
  167. package/src/lib/server/product-drafts.js.map +1 -1
  168. package/src/lib/server/product-writer.js +5 -4
  169. package/src/lib/server/product-writer.js.map +1 -1
  170. package/src/lib/server/product.d.ts +11 -0
  171. package/src/lib/server/product.js +18 -3
  172. package/src/lib/server/product.js.map +1 -1
  173. package/src/lib/server/products-write.js +4 -3
  174. package/src/lib/server/products-write.js.map +1 -1
  175. package/src/lib/server/quote-email.d.ts +26 -0
  176. package/src/lib/server/quote-email.js +73 -7
  177. package/src/lib/server/quote-email.js.map +1 -1
  178. package/src/lib/server/quote-messages.d.ts +72 -0
  179. package/src/lib/server/quote-messages.js +356 -0
  180. package/src/lib/server/quote-messages.js.map +1 -0
  181. package/src/lib/server/quote-pay.d.ts +42 -0
  182. package/src/lib/server/quote-pay.js +81 -4
  183. package/src/lib/server/quote-pay.js.map +1 -1
  184. package/src/lib/server/quote-proofs.d.ts +1 -1
  185. package/src/lib/server/quote-proofs.js +63 -19
  186. package/src/lib/server/quote-proofs.js.map +1 -1
  187. package/src/lib/server/quote.d.ts +12 -0
  188. package/src/lib/server/quote.js +69 -16
  189. package/src/lib/server/quote.js.map +1 -1
  190. package/src/lib/server/refund.js +3 -1
  191. package/src/lib/server/refund.js.map +1 -1
  192. package/src/lib/server/reserve-stock.js +9 -0
  193. package/src/lib/server/reserve-stock.js.map +1 -1
  194. package/src/lib/server/returns.js +15 -1
  195. package/src/lib/server/returns.js.map +1 -1
  196. package/src/lib/server/reviews.js +15 -0
  197. package/src/lib/server/reviews.js.map +1 -1
  198. package/src/lib/server/sold-out-drop.d.ts +58 -0
  199. package/src/lib/server/sold-out-drop.js +81 -0
  200. package/src/lib/server/sold-out-drop.js.map +1 -0
  201. package/src/lib/server/stock-levels.js +9 -0
  202. package/src/lib/server/stock-levels.js.map +1 -1
  203. package/src/lib/server/stripe-refund.d.ts +7 -0
  204. package/src/lib/server/stripe-refund.js +26 -7
  205. package/src/lib/server/stripe-refund.js.map +1 -1
  206. package/src/lib/server.d.ts +15 -0
  207. package/src/lib/server.js +30 -1
  208. package/src/lib/server.js.map +1 -1
  209. package/src/lib/tenant-emails.js +85 -2
  210. package/src/lib/tenant-emails.js.map +1 -1
  211. package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
  212. package/src/lib/testing/fake-seller-payment-account.js +40 -0
  213. package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
  214. package/src/lib/transfer/product-transfer.js +6 -5
  215. package/src/lib/transfer/product-transfer.js.map +1 -1
  216. package/src/lib/transfer/products.server.js +4 -3
  217. package/src/lib/transfer/products.server.js.map +1 -1
  218. package/src/lib/utils/quote-email-content.d.ts +6 -0
  219. package/src/lib/utils/quote-email-content.js +6 -3
  220. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -20,12 +20,16 @@ import { sendVisitorUpload } from "@aglyn/aglyn/app-utils/visitor-upload-client"
20
20
  import Alert from "@mui/material/Alert";
21
21
  import Box from "@mui/material/Box";
22
22
  import Button from "@mui/material/Button";
23
+ import Checkbox from "@mui/material/Checkbox";
23
24
  import Chip from "@mui/material/Chip";
25
+ import FormControlLabel from "@mui/material/FormControlLabel";
26
+ import FormGroup from "@mui/material/FormGroup";
24
27
  import Paper from "@mui/material/Paper";
25
28
  import Stack from "@mui/material/Stack";
26
29
  import TextField from "@mui/material/TextField";
27
30
  import Typography from "@mui/material/Typography";
28
31
  import { useCallback, useRef, useState } from "react";
32
+ import { quoteSignInHref } from "../constants/quote-page.js";
29
33
  function dateLabel(atMs) {
30
34
  return new Date(atMs).toLocaleDateString(undefined, {
31
35
  month: 'short',
@@ -38,17 +42,28 @@ const newKey = ()=>{
38
42
  var _globalThis_crypto_randomUUID, _globalThis_crypto;
39
43
  return (_ref = (_globalThis_crypto = globalThis.crypto) == null ? void 0 : (_globalThis_crypto_randomUUID = _globalThis_crypto.randomUUID) == null ? void 0 : _globalThis_crypto_randomUUID.call(_globalThis_crypto)) != null ? _ref : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
40
44
  };
45
+ /** The sign-in page, back to this very page once signed in. */ function signInHref() {
46
+ if (typeof window === 'undefined') return quoteSignInHref('');
47
+ return quoteSignInHref(`${window.location.pathname}${window.location.search}`);
48
+ }
41
49
  /**
42
50
  * The quote's proofs on the customer's page (AGL-4096): each image shown,
43
51
  * every other file a download, and while the quote is open for an answer,
44
- * "Approve this proof" (under a typed name) and "Request changes" (a comment
45
- * and any artwork). The latest answer is the one that counts, so a customer
46
- * who asked for changes can still approve, and the panel says what they last
52
+ * "Approve this proof" (every statement ticked and a typed name, AGL-4206)
53
+ * and "Reject with changes" (what to change under a typed name, and any
54
+ * artwork, AGL-4206). A quote that asks a
55
+ * customer with a site account to sign in shows a sign-in button instead of
56
+ * the proof until they do. The latest answer is the one that counts, so a customer
57
+ * who rejected it with changes can still approve, and the panel says what they last
47
58
  * said. A paid quote shows its proofs and nothing to press.
48
59
  */ export function QuoteProofPanel(props) {
60
+ var _view_approvalStatements;
61
+ var _response_confirmed;
49
62
  const { view, hostId, quoteId, token, siteFetch, onView, onReload, onReplaced } = props;
50
63
  const [mode, setMode] = useState('idle');
51
64
  const [name, setName] = useState('');
65
+ // The statements ticked, by their words: a reworded statement is a new box.
66
+ const [ticked, setTicked] = useState([]);
52
67
  const [comment, setComment] = useState('');
53
68
  const [files, setFiles] = useState([]);
54
69
  const [uploading, setUploading] = useState(null);
@@ -141,10 +156,16 @@ const newKey = ()=>{
141
156
  honeypot
142
157
  ]);
143
158
  const respond = useCallback(async ()=>{
159
+ var _view_approvalStatements;
144
160
  if (sending) return;
145
161
  setError('');
162
+ const statements = (_view_approvalStatements = view.approvalStatements) != null ? _view_approvalStatements : [];
163
+ if (mode === 'approve' && statements.some((statement)=>!ticked.includes(statement))) {
164
+ return void setError('Tick each box to confirm you checked the proof.');
165
+ }
146
166
  if (mode === 'approve' && name.trim().length < 2) return void setError('Type your name to approve the proof.');
147
167
  if (mode === 'changes' && !comment.trim()) return void setError('Tell us what to change.');
168
+ if (mode === 'changes' && name.trim().length < 2) return void setError('Type your name to reject the proof.');
148
169
  setSending(true);
149
170
  // One key per answer: a retry of the same press is answered from the first.
150
171
  if (!attempt.current) attempt.current = newKey();
@@ -154,9 +175,11 @@ const newKey = ()=>{
154
175
  v: view.version,
155
176
  action: mode === 'approve' ? 'approve' : 'changes'
156
177
  }, mode === 'approve' ? {
157
- name: name.trim()
178
+ name: name.trim(),
179
+ confirmed: statements.filter((statement)=>ticked.includes(statement))
158
180
  } : {
159
181
  comment: comment.trim(),
182
+ name: name.trim(),
160
183
  fileIds: files.map((file)=>file.id)
161
184
  }, {
162
185
  [VISITOR_UPLOAD_HONEYPOT_FIELD]: honeypot
@@ -167,6 +190,7 @@ const newKey = ()=>{
167
190
  if (response.ok && payload['view']) {
168
191
  setMode('idle');
169
192
  setName('');
193
+ setTicked([]);
170
194
  setComment('');
171
195
  setFiles([]);
172
196
  onView(payload['view']);
@@ -184,17 +208,59 @@ const newKey = ()=>{
184
208
  sending,
185
209
  mode,
186
210
  name,
211
+ ticked,
187
212
  comment,
188
213
  files,
189
214
  view.version,
215
+ view.approvalStatements,
190
216
  honeypot,
191
217
  post,
192
218
  onView,
193
219
  onReload,
194
220
  onReplaced
195
221
  ]);
222
+ // The quote asks this customer to sign in to their account first (AGL-4206).
223
+ if (view.proofAccess && view.proofAccess !== 'open') {
224
+ return /*#__PURE__*/ _jsx(Paper, {
225
+ variant: "outlined",
226
+ sx: {
227
+ p: {
228
+ xs: 2,
229
+ sm: 3
230
+ }
231
+ },
232
+ "data-quote-proof-sign-in": "",
233
+ children: /*#__PURE__*/ _jsxs(Stack, {
234
+ spacing: 2,
235
+ children: [
236
+ /*#__PURE__*/ _jsx(Typography, {
237
+ variant: "h6",
238
+ component: "h2",
239
+ children: 'Your proof'
240
+ }),
241
+ /*#__PURE__*/ _jsx(Alert, {
242
+ severity: "info",
243
+ children: view.proofAccessMessage
244
+ }),
245
+ /*#__PURE__*/ _jsx(Box, {
246
+ children: /*#__PURE__*/ _jsx(Button, {
247
+ variant: "contained",
248
+ href: signInHref(),
249
+ children: 'Sign in'
250
+ })
251
+ })
252
+ ]
253
+ })
254
+ });
255
+ }
196
256
  if (!view.proofs.length) return null;
197
257
  const response = view.response;
258
+ const statements = (_view_approvalStatements = view.approvalStatements) != null ? _view_approvalStatements : [];
259
+ const allTicked = statements.every((statement)=>ticked.includes(statement));
260
+ const toggle = (statement, on)=>setTicked((prev)=>on ? [
261
+ ...prev.filter((entry)=>entry !== statement),
262
+ statement
263
+ ] : prev.filter((entry)=>entry !== statement));
198
264
  return /*#__PURE__*/ _jsx(Paper, {
199
265
  variant: "outlined",
200
266
  sx: {
@@ -217,7 +283,7 @@ const newKey = ()=>{
217
283
  /*#__PURE__*/ _jsx(Typography, {
218
284
  variant: "body2",
219
285
  color: "text.secondary",
220
- children: view.status === 'unpaid' ? `Revision ${view.revision}. Look it over, then approve it or tell ${business} what to change.` : `Revision ${view.revision}.`
286
+ children: view.status === 'unpaid' ? `Revision ${view.revision}. Look it over, then approve it or reject it and tell ${business} what to change.` : `Revision ${view.revision}.`
221
287
  })
222
288
  ]
223
289
  }),
@@ -256,12 +322,27 @@ const newKey = ()=>{
256
322
  })
257
323
  }, proof.id))
258
324
  }),
259
- response ? response.action === 'approve' ? /*#__PURE__*/ _jsx(Alert, {
325
+ response ? response.action === 'approve' ? /*#__PURE__*/ _jsxs(Alert, {
260
326
  severity: "success",
261
- children: `You approved this proof on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}.`
327
+ children: [
328
+ `You approved this proof on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}.`,
329
+ ((_response_confirmed = response.confirmed) == null ? void 0 : _response_confirmed.length) ? /*#__PURE__*/ _jsx(Box, {
330
+ component: "ul",
331
+ sx: {
332
+ m: 0,
333
+ mt: 0.5,
334
+ pl: 2.5
335
+ },
336
+ children: response.confirmed.map((statement)=>/*#__PURE__*/ _jsx(Typography, {
337
+ component: "li",
338
+ variant: "body2",
339
+ children: statement
340
+ }, statement))
341
+ }) : null
342
+ ]
262
343
  }) : /*#__PURE__*/ _jsx(Alert, {
263
344
  severity: "info",
264
- children: `You asked for changes on ${dateLabel(response.atMs)}. ${business.charAt(0).toUpperCase()}${business.slice(1)} will send you a new proof.`
345
+ children: `You rejected this proof with changes on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}. ${business.charAt(0).toUpperCase()}${business.slice(1)} will send you a new proof.`
265
346
  }) : null,
266
347
  view.respondable ? /*#__PURE__*/ _jsxs(Stack, {
267
348
  spacing: 2,
@@ -296,9 +377,10 @@ const newKey = ()=>{
296
377
  children: 'Approve this proof'
297
378
  }) : null,
298
379
  /*#__PURE__*/ _jsx(Button, {
299
- variant: (response == null ? void 0 : response.action) === 'approve' ? 'outlined' : 'text',
380
+ variant: "outlined",
381
+ color: "primary",
300
382
  onClick: ()=>setMode('changes'),
301
- children: 'Request changes'
383
+ children: 'Reject with changes'
302
384
  })
303
385
  ]
304
386
  }) : mode === 'approve' ? /*#__PURE__*/ _jsxs(Stack, {
@@ -306,7 +388,31 @@ const newKey = ()=>{
306
388
  children: [
307
389
  /*#__PURE__*/ _jsx(Typography, {
308
390
  variant: "body2",
309
- children: `Type your name to approve revision ${view.revision}. ${business.charAt(0).toUpperCase()}${business.slice(1)} keeps your name and the time as the record of your approval.`
391
+ children: `Before you approve revision ${view.revision}, confirm each of these.`
392
+ }),
393
+ /*#__PURE__*/ _jsx(FormGroup, {
394
+ children: statements.map((statement)=>/*#__PURE__*/ _jsx(FormControlLabel, {
395
+ sx: {
396
+ alignItems: 'flex-start',
397
+ mb: 0.5
398
+ },
399
+ control: /*#__PURE__*/ _jsx(Checkbox, {
400
+ checked: ticked.includes(statement),
401
+ disabled: sending,
402
+ onChange: (event)=>toggle(statement, event.target.checked),
403
+ sx: {
404
+ pt: 0.25
405
+ }
406
+ }),
407
+ label: /*#__PURE__*/ _jsx(Typography, {
408
+ variant: "body2",
409
+ children: statement
410
+ })
411
+ }, statement))
412
+ }),
413
+ /*#__PURE__*/ _jsx(Typography, {
414
+ variant: "body2",
415
+ children: `Then type your name. ${business.charAt(0).toUpperCase()}${business.slice(1)} keeps your name, what you confirmed and the time as the record of your approval.`
310
416
  }),
311
417
  /*#__PURE__*/ _jsx(TextField, {
312
418
  label: "Your name",
@@ -325,13 +431,16 @@ const newKey = ()=>{
325
431
  children: [
326
432
  /*#__PURE__*/ _jsx(Button, {
327
433
  variant: "contained",
328
- disabled: sending,
434
+ disabled: sending || !allTicked || name.trim().length < 2,
329
435
  onClick: ()=>void respond(),
330
436
  children: sending ? 'Approving…' : 'Approve'
331
437
  }),
332
438
  /*#__PURE__*/ _jsx(Button, {
333
439
  disabled: sending,
334
- onClick: ()=>setMode('idle'),
440
+ onClick: ()=>{
441
+ setMode('idle');
442
+ setTicked([]);
443
+ },
335
444
  children: 'Cancel'
336
445
  })
337
446
  ]
@@ -340,6 +449,10 @@ const newKey = ()=>{
340
449
  }) : /*#__PURE__*/ _jsxs(Stack, {
341
450
  spacing: 1.5,
342
451
  children: [
452
+ /*#__PURE__*/ _jsx(Typography, {
453
+ variant: "body2",
454
+ children: `Tell ${business} what to change on revision ${view.revision}. They keep your note, your name and the time with the quote, and send you a new proof.`
455
+ }),
343
456
  /*#__PURE__*/ _jsx(TextField, {
344
457
  label: "What should change?",
345
458
  value: comment,
@@ -353,6 +466,18 @@ const newKey = ()=>{
353
466
  }
354
467
  }
355
468
  }),
469
+ /*#__PURE__*/ _jsx(TextField, {
470
+ label: "Your name",
471
+ value: name,
472
+ required: true,
473
+ autoComplete: "name",
474
+ onChange: (event)=>setName(event.target.value),
475
+ slotProps: {
476
+ htmlInput: {
477
+ maxLength: 120
478
+ }
479
+ }
480
+ }),
356
481
  /*#__PURE__*/ _jsx("input", {
357
482
  ref: picker,
358
483
  type: "file",
@@ -410,7 +535,7 @@ const newKey = ()=>{
410
535
  variant: "contained",
411
536
  disabled: sending || Boolean(uploading),
412
537
  onClick: ()=>void respond(),
413
- children: sending ? 'Sending…' : 'Send changes'
538
+ children: sending ? 'Sending…' : 'Reject with changes'
414
539
  }),
415
540
  /*#__PURE__*/ _jsx(Button, {
416
541
  disabled: sending,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/quote-proof-panel.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 {\n checkVisitorUploadSelection,\n describeVisitorUploadTypes,\n formatVisitorUploadBytes,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_HONEYPOT_FIELD,\n VISITOR_UPLOAD_MAX_BYTES,\n VISITOR_UPLOAD_MAX_FILES,\n type VisitorUploadFileView,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\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 Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { useCallback, useRef, useState, type ChangeEvent } from 'react'\nimport type { QuotePageView } from '../model'\n\n/** The page's own fetch: the site's API, with the site's preview rules. */\ntype SiteFetch = (input: string, init?: RequestInit) => Promise<Response>\n\nexport interface QuoteProofPanelProps {\n view: QuotePageView\n hostId: string\n quoteId: string\n token: string\n siteFetch: SiteFetch\n /** The quote as the server answered after a response, or after it changed. */\n onView: (view: QuotePageView) => void\n /** Reload the quote: it changed since the page loaded. */\n onReload: () => void\n /** The link was replaced. */\n onReplaced: () => void\n}\n\nfunction dateLabel(atMs: number): string {\n return new Date(atMs).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\nconst newKey = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n\n/**\n * The quote's proofs on the customer's page (AGL-4096): each image shown,\n * every other file a download, and while the quote is open for an answer,\n * \"Approve this proof\" (under a typed name) and \"Request changes\" (a comment\n * and any artwork). The latest answer is the one that counts, so a customer\n * who asked for changes can still approve, and the panel says what they last\n * said. A paid quote shows its proofs and nothing to press.\n */\nexport function QuoteProofPanel(props: QuoteProofPanelProps) {\n const { view, hostId, quoteId, token, siteFetch, onView, onReload, onReplaced } = props\n const [mode, setMode] = useState<'idle' | 'approve' | 'changes'>('idle')\n const [name, setName] = useState('')\n const [comment, setComment] = useState('')\n const [files, setFiles] = useState<VisitorUploadFileView[]>([])\n const [uploading, setUploading] = useState<{ done: number; total: number } | null>(null)\n const [sending, setSending] = useState(false)\n const [error, setError] = useState('')\n // Whatever a bot types into the hidden field, sent as typed.\n const [honeypot, setHoneypot] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n const attempt = useRef('')\n\n const link = `hostId=${encodeURIComponent(hostId)}&q=${encodeURIComponent(quoteId)}&t=${encodeURIComponent(token)}`\n const proofHref = (id: string) => `/api/commerce/quote-proof?${link}&file=${encodeURIComponent(id)}`\n const business = view.storeName || 'the business'\n\n const post = useCallback(\n async (path: string, body: Record<string, unknown>, headers: Record<string, string> = {}) => {\n const response = await siteFetch(path, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body: JSON.stringify({ hostId, q: quoteId, t: token, ...body }),\n })\n return { response, payload: (await response.json().catch(() => ({}))) as Record<string, any> }\n },\n [siteFetch, hostId, quoteId, token],\n )\n\n const attach = useCallback(\n async (picked: File[]) => {\n setError('')\n const problem = checkVisitorUploadSelection(picked, files.length)\n if (problem) return void setError(problem)\n setUploading({ done: 0, total: picked.length })\n try {\n for (const [index, file] of picked.entries()) {\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const { response, payload } = await post('/api/commerce/quote-upload', {\n action: 'ticket',\n file: request,\n [VISITOR_UPLOAD_HONEYPOT_FIELD]: honeypot,\n })\n return response.ok && payload['ticket']\n ? (payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(payload['error'] ?? 'The file could not be sent. Try again.') }\n },\n finalize: async (ticket) => {\n const { response, payload } = await post('/api/commerce/quote-upload', { action: 'finalize', ticket })\n return response.ok && payload['file']\n ? { file: payload['file'] as VisitorUploadFileView }\n : { error: String(payload['error'] ?? 'The file could not be sent. Try again.') }\n },\n })\n if ('error' in sent) {\n setError(sent.error)\n break\n }\n setFiles((prev) => [...prev, sent.file])\n setUploading({ done: index + 1, total: picked.length })\n }\n } finally {\n setUploading(null)\n }\n },\n [files.length, post, honeypot],\n )\n\n const respond = useCallback(async () => {\n if (sending) return\n setError('')\n if (mode === 'approve' && name.trim().length < 2) return void setError('Type your name to approve the proof.')\n if (mode === 'changes' && !comment.trim()) return void setError('Tell us what to change.')\n setSending(true)\n // One key per answer: a retry of the same press is answered from the first.\n if (!attempt.current) attempt.current = newKey()\n try {\n const { response, payload } = await post(\n '/api/commerce/quote-respond',\n {\n v: view.version,\n action: mode === 'approve' ? 'approve' : 'changes',\n ...(mode === 'approve' ? { name: name.trim() } : { comment: comment.trim(), fileIds: files.map((file) => file.id) }),\n [VISITOR_UPLOAD_HONEYPOT_FIELD]: honeypot,\n },\n { 'Idempotency-Key': attempt.current },\n )\n attempt.current = ''\n if (response.ok && payload['view']) {\n setMode('idle')\n setName('')\n setComment('')\n setFiles([])\n onView(payload['view'] as QuotePageView)\n return\n }\n if (payload['replaced']) return onReplaced()\n if (payload['reason'] === 'updated' || payload['reason'] === 'paid') onReload()\n setError(String(payload['error'] ?? 'Your answer could not be sent. Try again.'))\n } catch {\n setError('Your answer could not be sent. Check your connection and try again.')\n } finally {\n setSending(false)\n }\n }, [sending, mode, name, comment, files, view.version, honeypot, post, onView, onReload, onReplaced])\n\n if (!view.proofs.length) return null\n const response = view.response\n\n return (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {view.proofs.length === 1 ? 'Your proof' : 'Your proofs'}\n </Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {view.status === 'unpaid'\n ? `Revision ${view.revision}. Look it over, then approve it or tell ${business} what to change.`\n : `Revision ${view.revision}.`}\n </Typography>\n </Stack>\n\n <Stack spacing={1.5}>\n {view.proofs.map((proof) =>\n proof.inline ? (\n <Stack key={proof.id} spacing={0.5}>\n <Box\n component=\"img\"\n src={proofHref(proof.id)}\n alt={proof.name}\n loading=\"lazy\"\n sx={{ display: 'block', maxWidth: 1, height: 'auto', borderRadius: 1, border: 1, borderColor: 'divider' }}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {proof.name}\n </Typography>\n </Stack>\n ) : (\n <Box key={proof.id}>\n <Button variant=\"outlined\" size=\"small\" href={proofHref(proof.id)} download={proof.name}>\n {`Download ${proof.name} (${formatVisitorUploadBytes(proof.size)})`}\n </Button>\n </Box>\n ),\n )}\n </Stack>\n\n {response ? (\n response.action === 'approve' ? (\n <Alert severity=\"success\">\n {`You approved this proof on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}.`}\n </Alert>\n ) : (\n <Alert severity=\"info\">\n {`You asked for changes on ${dateLabel(response.atMs)}. ${business.charAt(0).toUpperCase()}${business.slice(1)} will send you a new proof.`}\n </Alert>\n )\n ) : null}\n\n {view.respondable ? (\n <Stack spacing={2}>\n {/* Honeypot: people never see or fill this. */}\n <Box\n component=\"input\"\n type=\"text\"\n name={VISITOR_UPLOAD_HONEYPOT_FIELD}\n tabIndex={-1}\n autoComplete=\"off\"\n aria-hidden=\"true\"\n value={honeypot}\n onChange={(event: ChangeEvent<HTMLInputElement>) => setHoneypot(event.target.value)}\n sx={{ position: 'absolute', left: '-100vw', width: 0, height: 0, opacity: 0 }}\n />\n {mode === 'idle' ? (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n {response?.action !== 'approve' ? (\n <Button variant=\"contained\" onClick={() => setMode('approve')}>\n {'Approve this proof'}\n </Button>\n ) : null}\n <Button variant={response?.action === 'approve' ? 'outlined' : 'text'} onClick={() => setMode('changes')}>\n {'Request changes'}\n </Button>\n </Stack>\n ) : mode === 'approve' ? (\n <Stack spacing={1.5}>\n <Typography variant=\"body2\">\n {`Type your name to approve revision ${view.revision}. ${business.charAt(0).toUpperCase()}${business.slice(1)} keeps your name and the time as the record of your approval.`}\n </Typography>\n <TextField\n label=\"Your name\"\n value={name}\n autoComplete=\"name\"\n onChange={(event) => setName(event.target.value)}\n slotProps={{ htmlInput: { maxLength: 120 } }}\n />\n <Stack direction=\"row\" spacing={1}>\n <Button variant=\"contained\" disabled={sending} onClick={() => void respond()}>\n {sending ? 'Approving…' : 'Approve'}\n </Button>\n <Button disabled={sending} onClick={() => setMode('idle')}>\n {'Cancel'}\n </Button>\n </Stack>\n </Stack>\n ) : (\n <Stack spacing={1.5}>\n <TextField\n label=\"What should change?\"\n value={comment}\n multiline\n minRows={3}\n required\n onChange={(event) => setComment(event.target.value)}\n slotProps={{ htmlInput: { maxLength: 5000 } }}\n />\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-artwork-picker\"\n onChange={(event) => {\n const picked = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (picked.length) void attach(picked)\n }}\n />\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <Chip\n key={file.id}\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onDelete={sending ? undefined : () => setFiles((prev) => prev.filter((entry) => entry.id !== file.id))}\n />\n ))}\n </Stack>\n ) : null}\n <Box>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={sending || Boolean(uploading) || files.length >= VISITOR_UPLOAD_MAX_FILES}\n onClick={() => picker.current?.click()}\n >\n {uploading ? `Sending ${uploading.done + 1} of ${uploading.total}…` : 'Attach artwork'}\n </Button>\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ mt: 0.5 }}>\n {`Optional. ${describeVisitorUploadTypes()}, up to ${VISITOR_UPLOAD_MAX_FILES} files of ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Box>\n <Stack direction=\"row\" spacing={1}>\n <Button variant=\"contained\" disabled={sending || Boolean(uploading)} onClick={() => void respond()}>\n {sending ? 'Sending…' : 'Send changes'}\n </Button>\n <Button disabled={sending} onClick={() => setMode('idle')}>\n {'Cancel'}\n </Button>\n </Stack>\n </Stack>\n )}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n </Stack>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\nexport default QuoteProofPanel\n"],"names":["checkVisitorUploadSelection","describeVisitorUploadTypes","formatVisitorUploadBytes","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_HONEYPOT_FIELD","VISITOR_UPLOAD_MAX_BYTES","VISITOR_UPLOAD_MAX_FILES","sendVisitorUpload","Alert","Box","Button","Chip","Paper","Stack","TextField","Typography","useCallback","useRef","useState","dateLabel","atMs","Date","toLocaleDateString","undefined","month","day","year","newKey","globalThis","crypto","randomUUID","now","Math","random","toString","slice","QuoteProofPanel","props","view","hostId","quoteId","token","siteFetch","onView","onReload","onReplaced","mode","setMode","name","setName","comment","setComment","files","setFiles","uploading","setUploading","sending","setSending","error","setError","honeypot","setHoneypot","picker","attempt","link","encodeURIComponent","proofHref","id","business","storeName","post","path","body","headers","response","method","JSON","stringify","q","t","payload","json","catch","attach","picked","problem","length","done","total","index","file","entries","sent","requestTicket","request","action","ok","String","finalize","ticket","prev","respond","trim","current","v","version","fileIds","map","proofs","variant","sx","p","xs","sm","spacing","component","color","status","revision","proof","inline","src","alt","loading","display","maxWidth","height","borderRadius","border","borderColor","size","href","download","severity","charAt","toUpperCase","respondable","type","tabIndex","autoComplete","aria-hidden","value","onChange","event","target","position","left","width","opacity","direction","onClick","label","slotProps","htmlInput","maxLength","disabled","multiline","minRows","required","input","ref","multiple","hidden","accept","data-testid","Array","from","useFlexGap","flexWrap","onDelete","filter","entry","Boolean","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AY,IAAM8B,SAAS,CAAC+C,OAASA,KAAKsE,MAAM,CAAC,CAACC,QAAUA,MAAMxG,EAAE,KAAKuB,KAAKvB,EAAE;2CAF/FuB,KAAKvB,EAAE;qCAMhB;8CACJ,MAAC1D;;sDACC,KAACC;4CACCwH,MAAK;4CACLrB,SAAQ;4CACR8C,UAAUnG,WAAWoH,QAAQtH,cAAcF,MAAMkC,MAAM,IAAIhF;4CAC3DgJ,SAAS;oDAAMxF;wDAAAA,kBAAAA,OAAOyC,OAAO,qBAAdzC,gBAAgB+G,KAAK;;sDAEnCvH,YAAY,CAAC,QAAQ,EAAEA,UAAUiC,IAAI,GAAG,EAAE,IAAI,EAAEjC,UAAUkC,KAAK,CAAC,CAAC,CAAC,GAAG;;sDAExE,KAACzE;4CAAW8F,SAAQ;4CAAUO,OAAM;4CAAiBD,WAAU;4CAAIL,IAAI;gDAAEgE,IAAI;4CAAI;sDAC9E,CAAC,UAAU,EAAE7K,6BAA6B,QAAQ,EAAEK,yBAAyB,UAAU,EAAEJ,yBAAyBG,0BAA0B,MAAM,CAAC;;;;8CAGxJ,MAACQ;oCAAMwI,WAAU;oCAAMnC,SAAS;;sDAC9B,KAACxG;4CAAOmG,SAAQ;4CAAY8C,UAAUnG,WAAWoH,QAAQtH;4CAAYgG,SAAS,IAAM,KAAKjD;sDACtF7C,UAAU,aAAa;;sDAE1B,KAAC9C;4CAAOiJ,UAAUnG;4CAAS8F,SAAS,IAAMvG,QAAQ;sDAC/C;;;;;;wBAKRW,sBAAQ,KAAClD;4BAAM6H,UAAS;sCAAS3E;6BAAiB;;qBAEnD;;;;AAIZ;AAEA,eAAetB,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/quote-proof-panel.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 {\n checkVisitorUploadSelection,\n describeVisitorUploadTypes,\n formatVisitorUploadBytes,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_HONEYPOT_FIELD,\n VISITOR_UPLOAD_MAX_BYTES,\n VISITOR_UPLOAD_MAX_FILES,\n type VisitorUploadFileView,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Checkbox from '@mui/material/Checkbox'\nimport Chip from '@mui/material/Chip'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport FormGroup from '@mui/material/FormGroup'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { useCallback, useRef, useState, type ChangeEvent } from 'react'\nimport { quoteSignInHref } from '../constants/quote-page'\nimport type { QuotePageView } from '../model'\n\n/** The page's own fetch: the site's API, with the site's preview rules. */\ntype SiteFetch = (input: string, init?: RequestInit) => Promise<Response>\n\nexport interface QuoteProofPanelProps {\n view: QuotePageView\n hostId: string\n quoteId: string\n token: string\n siteFetch: SiteFetch\n /** The quote as the server answered after a response, or after it changed. */\n onView: (view: QuotePageView) => void\n /** Reload the quote: it changed since the page loaded. */\n onReload: () => void\n /** The link was replaced. */\n onReplaced: () => void\n}\n\nfunction dateLabel(atMs: number): string {\n return new Date(atMs).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\nconst newKey = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n\n/** The sign-in page, back to this very page once signed in. */\nfunction signInHref(): string {\n if (typeof window === 'undefined') return quoteSignInHref('')\n return quoteSignInHref(`${window.location.pathname}${window.location.search}`)\n}\n\n/**\n * The quote's proofs on the customer's page (AGL-4096): each image shown,\n * every other file a download, and while the quote is open for an answer,\n * \"Approve this proof\" (every statement ticked and a typed name, AGL-4206)\n * and \"Reject with changes\" (what to change under a typed name, and any\n * artwork, AGL-4206). A quote that asks a\n * customer with a site account to sign in shows a sign-in button instead of\n * the proof until they do. The latest answer is the one that counts, so a customer\n * who rejected it with changes can still approve, and the panel says what they last\n * said. A paid quote shows its proofs and nothing to press.\n */\nexport function QuoteProofPanel(props: QuoteProofPanelProps) {\n const { view, hostId, quoteId, token, siteFetch, onView, onReload, onReplaced } = props\n const [mode, setMode] = useState<'idle' | 'approve' | 'changes'>('idle')\n const [name, setName] = useState('')\n // The statements ticked, by their words: a reworded statement is a new box.\n const [ticked, setTicked] = useState<string[]>([])\n const [comment, setComment] = useState('')\n const [files, setFiles] = useState<VisitorUploadFileView[]>([])\n const [uploading, setUploading] = useState<{ done: number; total: number } | null>(null)\n const [sending, setSending] = useState(false)\n const [error, setError] = useState('')\n // Whatever a bot types into the hidden field, sent as typed.\n const [honeypot, setHoneypot] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n const attempt = useRef('')\n\n const link = `hostId=${encodeURIComponent(hostId)}&q=${encodeURIComponent(quoteId)}&t=${encodeURIComponent(token)}`\n const proofHref = (id: string) => `/api/commerce/quote-proof?${link}&file=${encodeURIComponent(id)}`\n const business = view.storeName || 'the business'\n\n const post = useCallback(\n async (path: string, body: Record<string, unknown>, headers: Record<string, string> = {}) => {\n const response = await siteFetch(path, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body: JSON.stringify({ hostId, q: quoteId, t: token, ...body }),\n })\n return { response, payload: (await response.json().catch(() => ({}))) as Record<string, any> }\n },\n [siteFetch, hostId, quoteId, token],\n )\n\n const attach = useCallback(\n async (picked: File[]) => {\n setError('')\n const problem = checkVisitorUploadSelection(picked, files.length)\n if (problem) return void setError(problem)\n setUploading({ done: 0, total: picked.length })\n try {\n for (const [index, file] of picked.entries()) {\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const { response, payload } = await post('/api/commerce/quote-upload', {\n action: 'ticket',\n file: request,\n [VISITOR_UPLOAD_HONEYPOT_FIELD]: honeypot,\n })\n return response.ok && payload['ticket']\n ? (payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(payload['error'] ?? 'The file could not be sent. Try again.') }\n },\n finalize: async (ticket) => {\n const { response, payload } = await post('/api/commerce/quote-upload', { action: 'finalize', ticket })\n return response.ok && payload['file']\n ? { file: payload['file'] as VisitorUploadFileView }\n : { error: String(payload['error'] ?? 'The file could not be sent. Try again.') }\n },\n })\n if ('error' in sent) {\n setError(sent.error)\n break\n }\n setFiles((prev) => [...prev, sent.file])\n setUploading({ done: index + 1, total: picked.length })\n }\n } finally {\n setUploading(null)\n }\n },\n [files.length, post, honeypot],\n )\n\n const respond = useCallback(async () => {\n if (sending) return\n setError('')\n const statements = view.approvalStatements ?? []\n if (mode === 'approve' && statements.some((statement) => !ticked.includes(statement))) {\n return void setError('Tick each box to confirm you checked the proof.')\n }\n if (mode === 'approve' && name.trim().length < 2) return void setError('Type your name to approve the proof.')\n if (mode === 'changes' && !comment.trim()) return void setError('Tell us what to change.')\n if (mode === 'changes' && name.trim().length < 2) return void setError('Type your name to reject the proof.')\n setSending(true)\n // One key per answer: a retry of the same press is answered from the first.\n if (!attempt.current) attempt.current = newKey()\n try {\n const { response, payload } = await post(\n '/api/commerce/quote-respond',\n {\n v: view.version,\n action: mode === 'approve' ? 'approve' : 'changes',\n ...(mode === 'approve'\n ? { name: name.trim(), confirmed: statements.filter((statement) => ticked.includes(statement)) }\n : { comment: comment.trim(), name: name.trim(), fileIds: files.map((file) => file.id) }),\n [VISITOR_UPLOAD_HONEYPOT_FIELD]: honeypot,\n },\n { 'Idempotency-Key': attempt.current },\n )\n attempt.current = ''\n if (response.ok && payload['view']) {\n setMode('idle')\n setName('')\n setTicked([])\n setComment('')\n setFiles([])\n onView(payload['view'] as QuotePageView)\n return\n }\n if (payload['replaced']) return onReplaced()\n if (payload['reason'] === 'updated' || payload['reason'] === 'paid') onReload()\n setError(String(payload['error'] ?? 'Your answer could not be sent. Try again.'))\n } catch {\n setError('Your answer could not be sent. Check your connection and try again.')\n } finally {\n setSending(false)\n }\n }, [sending, mode, name, ticked, comment, files, view.version, view.approvalStatements, honeypot, post, onView, onReload, onReplaced])\n\n // The quote asks this customer to sign in to their account first (AGL-4206).\n if (view.proofAccess && view.proofAccess !== 'open') {\n return (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }} data-quote-proof-sign-in=\"\">\n <Stack spacing={2}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Your proof'}\n </Typography>\n <Alert severity=\"info\">{view.proofAccessMessage}</Alert>\n <Box>\n <Button variant=\"contained\" href={signInHref()}>\n {'Sign in'}\n </Button>\n </Box>\n </Stack>\n </Paper>\n )\n }\n\n if (!view.proofs.length) return null\n const response = view.response\n const statements = view.approvalStatements ?? []\n const allTicked = statements.every((statement) => ticked.includes(statement))\n const toggle = (statement: string, on: boolean) =>\n setTicked((prev) => (on ? [...prev.filter((entry) => entry !== statement), statement] : prev.filter((entry) => entry !== statement)))\n\n return (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {view.proofs.length === 1 ? 'Your proof' : 'Your proofs'}\n </Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {view.status === 'unpaid'\n ? `Revision ${view.revision}. Look it over, then approve it or reject it and tell ${business} what to change.`\n : `Revision ${view.revision}.`}\n </Typography>\n </Stack>\n\n <Stack spacing={1.5}>\n {view.proofs.map((proof) =>\n proof.inline ? (\n <Stack key={proof.id} spacing={0.5}>\n <Box\n component=\"img\"\n src={proofHref(proof.id)}\n alt={proof.name}\n loading=\"lazy\"\n sx={{ display: 'block', maxWidth: 1, height: 'auto', borderRadius: 1, border: 1, borderColor: 'divider' }}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {proof.name}\n </Typography>\n </Stack>\n ) : (\n <Box key={proof.id}>\n <Button variant=\"outlined\" size=\"small\" href={proofHref(proof.id)} download={proof.name}>\n {`Download ${proof.name} (${formatVisitorUploadBytes(proof.size)})`}\n </Button>\n </Box>\n ),\n )}\n </Stack>\n\n {response ? (\n response.action === 'approve' ? (\n <Alert severity=\"success\">\n {`You approved this proof on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}.`}\n {response.confirmed?.length ? (\n <Box component=\"ul\" sx={{ m: 0, mt: 0.5, pl: 2.5 }}>\n {response.confirmed.map((statement) => (\n <Typography key={statement} component=\"li\" variant=\"body2\">\n {statement}\n </Typography>\n ))}\n </Box>\n ) : null}\n </Alert>\n ) : (\n <Alert severity=\"info\">\n {`You rejected this proof with changes on ${dateLabel(response.atMs)}${response.name ? ` as ${response.name}` : ''}. ${business.charAt(0).toUpperCase()}${business.slice(1)} will send you a new proof.`}\n </Alert>\n )\n ) : null}\n\n {view.respondable ? (\n <Stack spacing={2}>\n {/* Honeypot: people never see or fill this. */}\n <Box\n component=\"input\"\n type=\"text\"\n name={VISITOR_UPLOAD_HONEYPOT_FIELD}\n tabIndex={-1}\n autoComplete=\"off\"\n aria-hidden=\"true\"\n value={honeypot}\n onChange={(event: ChangeEvent<HTMLInputElement>) => setHoneypot(event.target.value)}\n sx={{ position: 'absolute', left: '-100vw', width: 0, height: 0, opacity: 0 }}\n />\n {mode === 'idle' ? (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n {response?.action !== 'approve' ? (\n <Button variant=\"contained\" onClick={() => setMode('approve')}>\n {'Approve this proof'}\n </Button>\n ) : null}\n <Button variant=\"outlined\" color=\"primary\" onClick={() => setMode('changes')}>\n {'Reject with changes'}\n </Button>\n </Stack>\n ) : mode === 'approve' ? (\n <Stack spacing={1.5}>\n <Typography variant=\"body2\">\n {`Before you approve revision ${view.revision}, confirm each of these.`}\n </Typography>\n <FormGroup>\n {statements.map((statement) => (\n <FormControlLabel\n key={statement}\n sx={{ alignItems: 'flex-start', mb: 0.5 }}\n control={\n <Checkbox\n checked={ticked.includes(statement)}\n disabled={sending}\n onChange={(event) => toggle(statement, event.target.checked)}\n sx={{ pt: 0.25 }}\n />\n }\n label={<Typography variant=\"body2\">{statement}</Typography>}\n />\n ))}\n </FormGroup>\n <Typography variant=\"body2\">\n {`Then type your name. ${business.charAt(0).toUpperCase()}${business.slice(1)} keeps your name, what you confirmed and the time as the record of your approval.`}\n </Typography>\n <TextField\n label=\"Your name\"\n value={name}\n autoComplete=\"name\"\n onChange={(event) => setName(event.target.value)}\n slotProps={{ htmlInput: { maxLength: 120 } }}\n />\n <Stack direction=\"row\" spacing={1}>\n <Button\n variant=\"contained\"\n disabled={sending || !allTicked || name.trim().length < 2}\n onClick={() => void respond()}\n >\n {sending ? 'Approving…' : 'Approve'}\n </Button>\n <Button\n disabled={sending}\n onClick={() => {\n setMode('idle')\n setTicked([])\n }}\n >\n {'Cancel'}\n </Button>\n </Stack>\n </Stack>\n ) : (\n <Stack spacing={1.5}>\n <Typography variant=\"body2\">\n {`Tell ${business} what to change on revision ${view.revision}. They keep your note, your name and the time with the quote, and send you a new proof.`}\n </Typography>\n <TextField\n label=\"What should change?\"\n value={comment}\n multiline\n minRows={3}\n required\n onChange={(event) => setComment(event.target.value)}\n slotProps={{ htmlInput: { maxLength: 5000 } }}\n />\n <TextField\n label=\"Your name\"\n value={name}\n required\n autoComplete=\"name\"\n onChange={(event) => setName(event.target.value)}\n slotProps={{ htmlInput: { maxLength: 120 } }}\n />\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-artwork-picker\"\n onChange={(event) => {\n const picked = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (picked.length) void attach(picked)\n }}\n />\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <Chip\n key={file.id}\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onDelete={sending ? undefined : () => setFiles((prev) => prev.filter((entry) => entry.id !== file.id))}\n />\n ))}\n </Stack>\n ) : null}\n <Box>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={sending || Boolean(uploading) || files.length >= VISITOR_UPLOAD_MAX_FILES}\n onClick={() => picker.current?.click()}\n >\n {uploading ? `Sending ${uploading.done + 1} of ${uploading.total}…` : 'Attach artwork'}\n </Button>\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ mt: 0.5 }}>\n {`Optional. ${describeVisitorUploadTypes()}, up to ${VISITOR_UPLOAD_MAX_FILES} files of ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Box>\n <Stack direction=\"row\" spacing={1}>\n <Button variant=\"contained\" disabled={sending || Boolean(uploading)} onClick={() => void respond()}>\n {sending ? 'Sending…' : 'Reject with changes'}\n </Button>\n <Button disabled={sending} onClick={() => setMode('idle')}>\n {'Cancel'}\n </Button>\n </Stack>\n </Stack>\n )}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n </Stack>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\nexport default QuoteProofPanel\n"],"names":["checkVisitorUploadSelection","describeVisitorUploadTypes","formatVisitorUploadBytes","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_HONEYPOT_FIELD","VISITOR_UPLOAD_MAX_BYTES","VISITOR_UPLOAD_MAX_FILES","sendVisitorUpload","Alert","Box","Button","Checkbox","Chip","FormControlLabel","FormGroup","Paper","Stack","TextField","Typography","useCallback","useRef","useState","quoteSignInHref","dateLabel","atMs","Date","toLocaleDateString","undefined","month","day","year","newKey","globalThis","crypto","randomUUID","now","Math","random","toString","slice","signInHref","window","location","pathname","search","QuoteProofPanel","props","view","response","hostId","quoteId","token","siteFetch","onView","onReload","onReplaced","mode","setMode","name","setName","ticked","setTicked","comment","setComment","files","setFiles","uploading","setUploading","sending","setSending","error","setError","honeypot","setHoneypot","picker","attempt","link","encodeURIComponent","proofHref","id","business","storeName","post","path","body","headers","method","JSON","stringify","q","t","payload","json","catch","attach","picked","problem","length","done","total","index","file","entries","sent","requestTicket","request","action","ok","String","finalize","ticket","prev","respond","statements","approvalStatements","some","statement","includes","trim","current","v","version","confirmed","filter","fileIds","map","proofAccess","variant","sx","p","xs","sm","data-quote-proof-sign-in","spacing","component","severity","proofAccessMessage","href","proofs","allTicked","every","toggle","on","entry","color","status","revision","proof","inline","src","alt","loading","display","maxWidth","height","borderRadius","border","borderColor","size","download","m","mt","pl","charAt","toUpperCase","respondable","type","tabIndex","autoComplete","aria-hidden","value","onChange","event","target","position","left","width","opacity","direction","onClick","alignItems","mb","control","checked","disabled","pt","label","slotProps","htmlInput","maxLength","multiline","minRows","required","input","ref","multiple","hidden","accept","data-testid","Array","from","useFlexGap","flexWrap","onDelete","Boolean","click"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,2BAA2B,EAC3BC,0BAA0B,EAC1BC,wBAAwB,EACxBC,qBAAqB,EACrBC,6BAA6B,EAC7BC,wBAAwB,EACxBC,wBAAwB,QAEnB,wCAAuC;AAC9C,SAASC,iBAAiB,QAAQ,+CAA8C;AAChF,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gB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oJ,MAAK;4CACL/B,SAAQ;4CACRyD,UAAUpH,WAAWwI,QAAQ1I,cAAcF,MAAMiC,MAAM,IAAI3F;4CAC3D6K,SAAS;oDAAMzG;wDAAAA,kBAAAA,OAAO6C,OAAO,qBAAd7C,gBAAgBmI,KAAK;;sDAEnC3I,YAAY,CAAC,QAAQ,EAAEA,UAAUgC,IAAI,GAAG,EAAE,IAAI,EAAEhC,UAAUiC,KAAK,CAAC,CAAC,CAAC,GAAG;;sDAExE,KAACjF;4CAAW6G,SAAQ;4CAAUiB,OAAM;4CAAiBV,WAAU;4CAAIN,IAAI;gDAAEiC,IAAI;4CAAI;sDAC9E,CAAC,UAAU,EAAEhK,6BAA6B,QAAQ,EAAEK,yBAAyB,UAAU,EAAEJ,yBAAyBG,0BAA0B,MAAM,CAAC;;;;8CAGxJ,MAACW;oCAAMkK,WAAU;oCAAM7C,SAAS;;sDAC9B,KAAC3H;4CAAOqH,SAAQ;4CAAYyD,UAAUpH,WAAWwI,QAAQ1I;4CAAYiH,SAAS,IAAM,KAAKnE;sDACtF5C,UAAU,aAAa;;sDAE1B,KAAC1D;4CAAO8K,UAAUpH;4CAAS+G,SAAS,IAAM1H,QAAQ;sDAC/C;;;;;;wBAKRa,sBAAQ,KAAC9D;4BAAM+H,UAAS;sCAASjE;6BAAiB;;qBAEnD;;;;AAIZ;AAEA,eAAezB,gBAAe"}
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import * as Aglyn from '@aglyn/aglyn';
18
+ import { type ProductPhotoFit } from './product-photo-fit';
18
19
  export declare const ID: Aglyn.ComponentId;
19
20
  export interface RelatedProductsProps {
20
21
  /** Anchor product id; blank follows the /products/{slug} page. */
@@ -27,6 +28,12 @@ export interface RelatedProductsProps {
27
28
  * them in a grid of up to four across — the product grid's photo look.
28
29
  */
29
30
  layout?: 'strip' | 'grid';
31
+ /**
32
+ * How each card draws its photo: `cover`, the default, fills the frame and
33
+ * crops what does not fit; `contain` shows the whole photo inside the same
34
+ * frame. Blank or unknown is `cover`.
35
+ */
36
+ photoFit?: ProductPhotoFit;
30
37
  }
31
38
  /**
32
39
  * Related products / upsell strip (AGL-325): the product's manual list,
@@ -29,6 +29,8 @@ import { BUNDLE_ID } from "../constants/bundle-common.js";
29
29
  import { generatePresetId } from "../utils/generate-preset-id.js";
30
30
  import { formatOrderMoney } from "../model/buyer-notifications.js";
31
31
  import { ProductImagePlaceholder } from "./product-image-placeholder.js";
32
+ import { PRODUCT_PHOTO_FIT_ATTRIBUTE, productPhotoFit, productPhotoFitSx } from "./product-photo-fit.js";
33
+ import { PRODUCT_NAME_SX } from "./product-name-lines.js";
32
34
  // Component ids are persisted in screen documents; never rename.
33
35
  export const ID = 'related-products';
34
36
  /**
@@ -37,11 +39,12 @@ export const ID = 'related-products';
37
39
  * category neighbors — resolved server-side, rendered as cards.
38
40
  */ const RelatedProducts = /*#__PURE__*/ forwardRef((props, ref)=>{
39
41
  var _site_pageData_commerce_product, _site_pageData_commerce, _site_pageData;
40
- const { productId: productIdProp, heading, maxItems, layout } = props, rest = _object_without_properties_loose(props, [
42
+ const { productId: productIdProp, heading, maxItems, layout, photoFit } = props, rest = _object_without_properties_loose(props, [
41
43
  "productId",
42
44
  "heading",
43
45
  "maxItems",
44
- "layout"
46
+ "layout",
47
+ "photoFit"
45
48
  ]);
46
49
  // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).
47
50
  const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [
@@ -111,6 +114,7 @@ export const ID = 'related-products';
111
114
  ref: ref
112
115
  }, rest));
113
116
  const grid = layout === 'grid';
117
+ const photoFitSx = productPhotoFitSx(productPhotoFit(photoFit));
114
118
  return /*#__PURE__*/ _jsxs(Box, _extends({
115
119
  ref: ref
116
120
  }, rest, {
@@ -170,9 +174,7 @@ export const ID = 'related-products';
170
174
  component: "img",
171
175
  image: imageUrl,
172
176
  alt: item.name,
173
- sx: _extends({}, mediaSx, {
174
- objectFit: 'cover'
175
- })
177
+ sx: _extends({}, mediaSx, photoFitSx)
176
178
  }, Aglyn.DEFERRED_IMAGE_ATTRIBUTES)) : // Never a blank tile: a product with no photo yet says
177
179
  // so, in the theme's colours (AGL-3676 follow-up).
178
180
  /*#__PURE__*/ _jsx(ProductImagePlaceholder, {
@@ -190,7 +192,7 @@ export const ID = 'related-products';
190
192
  children: [
191
193
  /*#__PURE__*/ _jsx(Typography, {
192
194
  variant: grid ? 'subtitle1' : 'body2',
193
- noWrap: true,
195
+ sx: PRODUCT_NAME_SX,
194
196
  children: item.name
195
197
  }),
196
198
  /*#__PURE__*/ _jsx(Typography, {
@@ -260,7 +262,8 @@ export const schema = {
260
262
  value: 'grid'
261
263
  }
262
264
  ]
263
- }
265
+ },
266
+ PRODUCT_PHOTO_FIT_ATTRIBUTE
264
267
  ]
265
268
  };
266
269
  export const presets = [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/related-products.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 * as Aglyn from '@aglyn/aglyn'\nimport { mdiShapePlus } from '@aglyn/shared-data-mdi'\nimport Box from '@mui/material/Box'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport CardMedia from '@mui/material/CardMedia'\nimport Typography from '@mui/material/Typography'\nimport { forwardRef, useEffect, useState } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { formatOrderMoney } from '../model/buyer-notifications'\nimport { ProductImagePlaceholder } from './product-image-placeholder'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'related-products'\n\nexport interface RelatedProductsProps {\n /** Anchor product id; blank follows the /products/{slug} page. */\n productId?: string\n heading?: string\n maxItems?: number\n /**\n * How the items are drawn: `strip`, the default, a scrolling row of small\n * cards; `grid`, tall photo cards (4:5) with the name and price under\n * them in a grid of up to four across — the product grid's photo look.\n */\n layout?: 'strip' | 'grid'\n}\n\ninterface CatalogItem {\n id: string\n name: string\n slug: string\n priceUsd: number\n imageUrl?: string\n /** Listed before it has a price (AGL-3676). */\n priceComingSoon?: boolean\n}\n\n/**\n * Related products / upsell strip (AGL-325): the product's manual list,\n * else \"frequently bought together\" from recent orders, else tag and\n * category neighbors — resolved server-side, rendered as cards.\n */\nconst RelatedProducts = forwardRef<HTMLDivElement, RelatedProductsProps>(\n (props, ref) => {\n const { productId: productIdProp, heading, maxItems, layout, ...rest } = props\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 { hostId } = site\n // The page's product, when the server seeded it (AGL-659): its id is the\n // anchor, so the rail skips a product lookup the page already made.\n const seededProductId = (\n site.pageData as { commerce?: { product?: { id?: string } } } | undefined\n )?.commerce?.product?.id\n const [items, setItems] = useState<CatalogItem[] | null>(null)\n // The catalog counts the cap over products on sale (AGL-4038).\n const cap = Number(maxItems) > 0 ? Math.floor(Number(maxItems)) : 6\n\n useEffect(() => {\n if (!hostId) return\n let active = true\n void (async () => {\n let anchor = productIdProp || seededProductId || ''\n if (!anchor) {\n const match = window.location.pathname.match(/\\/products\\/([^/?#]+)/)\n if (!match) return\n const response = await fetch(\n `/api/commerce/product?hostId=${encodeURIComponent(hostId)}` +\n `&slug=${encodeURIComponent(decodeURIComponent(match[1]))}`,\n ).catch(() => null)\n const payload = await response?.json().catch(() => ({}))\n anchor = String(payload?.product?.id ?? '')\n }\n if (!active || !anchor) return\n const relatedResponse = await fetch(\n `/api/commerce/related?hostId=${encodeURIComponent(hostId)}` +\n `&productId=${encodeURIComponent(anchor)}`,\n ).catch(() => null)\n const related = await relatedResponse?.json().catch(() => ({}))\n const ids: string[] = related?.productIds ?? []\n if (!active || ids.length === 0) return setItems([])\n const catalogResponse = await fetch(\n `/api/commerce/catalog?hostId=${encodeURIComponent(hostId)}` +\n `&ids=${encodeURIComponent(ids.join(','))}&limit=${cap}`,\n ).catch(() => null)\n const catalog = await catalogResponse?.json().catch(() => ({}))\n if (active) setItems(catalog?.items ?? [])\n })()\n return () => {\n active = false\n }\n }, [hostId, productIdProp, seededProductId, cap])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 3,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n },\n ...nodeSx,\n ]}\n >\n {'Related products render here'}\n </Box>\n )\n }\n if (!items || items.length === 0) return <Box ref={ref} {...rest} />\n\n const grid = layout === 'grid'\n return (\n <Box ref={ref} {...rest}>\n <Typography variant={grid ? 'h5' : 'h6'} component=\"h2\" gutterBottom sx={grid ? { mb: 2 } : undefined}>\n {heading || 'You may also like'}\n </Typography>\n <Box\n sx={\n grid\n ? {\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: 'repeat(2, minmax(0, 1fr))', md: 'repeat(4, minmax(0, 1fr))' },\n }\n : { display: 'flex', gap: 1.5, overflowX: 'auto', pb: 1 }\n }\n >\n {items\n .slice(0, cap)\n .map((item) => {\n // AGL-1726: resolved BEFORE the guard — see the note in\n // `product-detail.tsx`.\n const imageUrl = Aglyn.siteRelativeMediaSrc(item.imageUrl, {\n hostId,\n })\n const mediaSx = grid\n ? { aspectRatio: '4 / 5', borderRadius: 2 }\n : { height: 110 }\n return (\n <Card\n key={item.id}\n variant={grid ? 'elevation' : 'outlined'}\n elevation={0}\n sx={grid ? { bgcolor: 'transparent', overflow: 'visible', minWidth: 0 } : { minWidth: 160 }}\n >\n <CardActionArea\n href={`/products/${item.slug}`}\n sx={grid ? { borderRadius: 2 } : undefined}\n >\n {imageUrl ? (\n <CardMedia\n component=\"img\"\n image={imageUrl}\n alt={item.name}\n sx={{ ...mediaSx, objectFit: 'cover' }}\n // Deferred (AGL-2486). A related-products rail sits at\n // the BOTTOM of a product page by construction, and it\n // was fetching eagerly against the gallery hero above\n // it — the one image on that page that is the LCP.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : (\n // Never a blank tile: a product with no photo yet says\n // so, in the theme's colours (AGL-3676 follow-up).\n <ProductImagePlaceholder name={item.name} sx={mediaSx} />\n )}\n <CardContent sx={grid ? { px: 0.5, pt: 1.5, pb: 1 } : { py: 1 }}>\n <Typography variant={grid ? 'subtitle1' : 'body2'} noWrap>\n {item.name}\n </Typography>\n <Typography variant={grid ? 'body2' : 'caption'} color=\"text.secondary\">\n {item.priceComingSoon\n ? 'Price coming soon'\n : formatOrderMoney(Math.round(item.priceUsd * 100))}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n )\n })}\n </Box>\n </Box>\n )\n },\n)\nRelatedProducts.displayName = 'AglynRelatedProducts'\n\nexport const schema: Aglyn.ComponentSchema<RelatedProductsProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Related products',\n description:\n 'An upsell strip — your manual picks, or what people buy together.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiShapePlus.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'productId',\n label: 'Product id',\n description:\n 'The product to find relatives OF. Blank reads it from the URL, so ' +\n 'a product template shows each product’s own related items; naming ' +\n 'one pins the rail to that product’s relatives everywhere.',\n component: Aglyn.FieldComponentType.PRODUCT_SELECT,\n },\n {\n name: 'heading',\n label: 'Heading',\n description: 'Defaults to \"You may also like\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'maxItems',\n label: 'Max items',\n description: 'Cap the strip (default 6).',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n type: 'number',\n },\n {\n // Default `strip`, so a page that already places this block keeps it.\n name: 'layout',\n label: 'Layout',\n description: 'A scrolling strip of small cards, or a grid of tall photo cards.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { label: 'Strip', value: 'strip' },\n { label: 'Photo grid', value: 'grid' },\n ],\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Related products',\n pluginId: BUNDLE_ID,\n description: 'Manual picks or frequently-bought-together',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiShapePlus.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n]\n\nexport default RelatedProducts\n"],"names":["Aglyn","mdiShapePlus","Box","Card","CardActionArea","CardContent","CardMedia","Typography","forwardRef","useEffect","useState","BUNDLE_ID","generatePresetId","formatOrderMoney","ProductImagePlaceholder","ID","RelatedProducts","props","ref","site","productId","productIdProp","heading","maxItems","layout","rest","nodeSx","Array","isArray","useSite","hostId","seededProductId","pageData","commerce","product","id","items","setItems","cap","Number","Math","floor","active","anchor","payload","match","window","location","pathname","response","fetch","encodeURIComponent","decodeURIComponent","catch","json","String","relatedResponse","related","ids","productIds","length","catalogResponse","join","catalog","sx","p","border","borderColor","borderRadius","color","fontSize","fontFamily","grid","variant","component","gutterBottom","mb","undefined","display","gap","gridTemplateColumns","xs","md","overflowX","pb","slice","map","item","imageUrl","siteRelativeMediaSrc","mediaSx","aspectRatio","height","elevation","bgcolor","overflow","minWidth","href","slug","image","alt","name","objectFit","DEFERRED_IMAGE_ATTRIBUTES","px","pt","py","noWrap","priceComingSoon","round","priceUsd","displayName","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","path","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","label","FieldComponentType","PRODUCT_SELECT","TEXT_FIELD","type","SELECT","options","value","presets","NodeType","PRESET","data","componentId"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACvD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,QAAQ,kCAA8B;AAC/D,SAASC,uBAAuB,QAAQ,iCAA6B;AAErE,iEAAiE;AACjE,OAAO,MAAMC,KAAwB,mBAAkB;AAyBvD;;;;CAIC,GACD,MAAMC,gCAAkBR,WACtB,CAACS,OAAOC;QAQkB,iCAAA,yBACtBC;IARF,MAAM,EAAEC,WAAWC,aAAa,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAW,GAAGP,OAATQ,wCAASR;;;;;;IACzE,yEAAyE;IACzE,MAAMS,SAASC,MAAMC,OAAO,CAACX,KAAK,CAAC,KAAK,IAAIA,KAAK,CAAC,KAAK,GAAG;QAACA,KAAK,CAAC,KAAK;KAAC;IACvE,MAAME,OAAOnB,MAAM6B,OAAO;IAC1B,MAAM,EAAEC,MAAM,EAAE,GAAGX;IACnB,yEAAyE;IACzE,oEAAoE;IACpE,MAAMY,mBACJZ,iBAAAA,KAAKa,QAAQ,sBADS,0BAAA,AACtBb,eACCc,QAAQ,sBAFa,kCAAA,wBAEXC,OAAO,qBAFI,gCAEFC,EAAE;IACxB,MAAM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ExD,IAAI;YAAEK,OAAO;QAAU;IAAE;IAC1DoD,OAAO;QAAEC,aAAa1H,MAAM2H,YAAY,CAACC,OAAO;IAAC;IACjDC,YAAY;QACV;YACExB,MAAM;YACNyB,OAAO;YACPX,aACE,uEACA,uEACA;YACFzC,WAAW1E,MAAM+H,kBAAkB,CAACC,cAAc;QACpD;QACA;YACE3B,MAAM;YACNyB,OAAO;YACPX,aAAa;YACbzC,WAAW1E,MAAM+H,kBAAkB,CAACE,UAAU;QAChD;QACA;YACE5B,MAAM;YACNyB,OAAO;YACPX,aAAa;YACbzC,WAAW1E,MAAM+H,kBAAkB,CAACE,UAAU;YAC9CC,MAAM;QACR;QACA;YACE,sEAAsE;YACtE7B,MAAM;YACNyB,OAAO;YACPX,aAAa;YACbzC,WAAW1E,MAAM+H,kBAAkB,CAACI,MAAM;YAC1CC,SAAS;gBACP;oBAAEN,OAAO;oBAASO,OAAO;gBAAQ;gBACjC;oBAAEP,OAAO;oBAAcO,OAAO;gBAAO;aACtC;QACH;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACErB,KAAKrG,iBAAiBG;QACtBmH,MAAMlI,MAAMuI,QAAQ,CAACC,MAAM;QAC3BzB,aAAa;QACbG,UAAUvG;QACVwG,aAAa;QACbC,UAAUpH,MAAMqH,iBAAiB,CAACC,QAAQ;QAC1CC,MAAM;YAAEC,MAAMvH,aAAauH,IAAI;YAAExD,IAAI;gBAAEK,OAAO;YAAU;QAAE;QAC1DoE,MAAM;YACJxB,KAAK;YACLyB,aAAa3H;YACbmG,UAAUvG;YACVM,OAAO,CAAC;QACV;IACF;CACD,CAAA;AAED,eAAeD,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/related-products.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 * as Aglyn from '@aglyn/aglyn'\nimport { mdiShapePlus } from '@aglyn/shared-data-mdi'\nimport Box from '@mui/material/Box'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport CardMedia from '@mui/material/CardMedia'\nimport Typography from '@mui/material/Typography'\nimport { forwardRef, useEffect, useState } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { formatOrderMoney } from '../model/buyer-notifications'\nimport { ProductImagePlaceholder } from './product-image-placeholder'\nimport {\n PRODUCT_PHOTO_FIT_ATTRIBUTE,\n productPhotoFit,\n productPhotoFitSx,\n type ProductPhotoFit,\n} from './product-photo-fit'\nimport { PRODUCT_NAME_SX } from './product-name-lines'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'related-products'\n\nexport interface RelatedProductsProps {\n /** Anchor product id; blank follows the /products/{slug} page. */\n productId?: string\n heading?: string\n maxItems?: number\n /**\n * How the items are drawn: `strip`, the default, a scrolling row of small\n * cards; `grid`, tall photo cards (4:5) with the name and price under\n * them in a grid of up to four across — the product grid's photo look.\n */\n layout?: 'strip' | 'grid'\n /**\n * How each card draws its photo: `cover`, the default, fills the frame and\n * crops what does not fit; `contain` shows the whole photo inside the same\n * frame. Blank or unknown is `cover`.\n */\n photoFit?: ProductPhotoFit\n}\n\ninterface CatalogItem {\n id: string\n name: string\n slug: string\n priceUsd: number\n imageUrl?: string\n /** Listed before it has a price (AGL-3676). */\n priceComingSoon?: boolean\n}\n\n/**\n * Related products / upsell strip (AGL-325): the product's manual list,\n * else \"frequently bought together\" from recent orders, else tag and\n * category neighbors — resolved server-side, rendered as cards.\n */\nconst RelatedProducts = forwardRef<HTMLDivElement, RelatedProductsProps>(\n (props, ref) => {\n const { productId: productIdProp, heading, maxItems, layout, photoFit, ...rest } = props\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 { hostId } = site\n // The page's product, when the server seeded it (AGL-659): its id is the\n // anchor, so the rail skips a product lookup the page already made.\n const seededProductId = (\n site.pageData as { commerce?: { product?: { id?: string } } } | undefined\n )?.commerce?.product?.id\n const [items, setItems] = useState<CatalogItem[] | null>(null)\n // The catalog counts the cap over products on sale (AGL-4038).\n const cap = Number(maxItems) > 0 ? Math.floor(Number(maxItems)) : 6\n\n useEffect(() => {\n if (!hostId) return\n let active = true\n void (async () => {\n let anchor = productIdProp || seededProductId || ''\n if (!anchor) {\n const match = window.location.pathname.match(/\\/products\\/([^/?#]+)/)\n if (!match) return\n const response = await fetch(\n `/api/commerce/product?hostId=${encodeURIComponent(hostId)}` +\n `&slug=${encodeURIComponent(decodeURIComponent(match[1]))}`,\n ).catch(() => null)\n const payload = await response?.json().catch(() => ({}))\n anchor = String(payload?.product?.id ?? '')\n }\n if (!active || !anchor) return\n const relatedResponse = await fetch(\n `/api/commerce/related?hostId=${encodeURIComponent(hostId)}` +\n `&productId=${encodeURIComponent(anchor)}`,\n ).catch(() => null)\n const related = await relatedResponse?.json().catch(() => ({}))\n const ids: string[] = related?.productIds ?? []\n if (!active || ids.length === 0) return setItems([])\n const catalogResponse = await fetch(\n `/api/commerce/catalog?hostId=${encodeURIComponent(hostId)}` +\n `&ids=${encodeURIComponent(ids.join(','))}&limit=${cap}`,\n ).catch(() => null)\n const catalog = await catalogResponse?.json().catch(() => ({}))\n if (active) setItems(catalog?.items ?? [])\n })()\n return () => {\n active = false\n }\n }, [hostId, productIdProp, seededProductId, cap])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 3,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n },\n ...nodeSx,\n ]}\n >\n {'Related products render here'}\n </Box>\n )\n }\n if (!items || items.length === 0) return <Box ref={ref} {...rest} />\n\n const grid = layout === 'grid'\n const photoFitSx = productPhotoFitSx(productPhotoFit(photoFit))\n return (\n <Box ref={ref} {...rest}>\n <Typography variant={grid ? 'h5' : 'h6'} component=\"h2\" gutterBottom sx={grid ? { mb: 2 } : undefined}>\n {heading || 'You may also like'}\n </Typography>\n <Box\n sx={\n grid\n ? {\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: 'repeat(2, minmax(0, 1fr))', md: 'repeat(4, minmax(0, 1fr))' },\n }\n : { display: 'flex', gap: 1.5, overflowX: 'auto', pb: 1 }\n }\n >\n {items\n .slice(0, cap)\n .map((item) => {\n // AGL-1726: resolved BEFORE the guard — see the note in\n // `product-detail.tsx`.\n const imageUrl = Aglyn.siteRelativeMediaSrc(item.imageUrl, {\n hostId,\n })\n const mediaSx = grid\n ? { aspectRatio: '4 / 5', borderRadius: 2 }\n : { height: 110 }\n return (\n <Card\n key={item.id}\n variant={grid ? 'elevation' : 'outlined'}\n elevation={0}\n sx={grid ? { bgcolor: 'transparent', overflow: 'visible', minWidth: 0 } : { minWidth: 160 }}\n >\n <CardActionArea\n href={`/products/${item.slug}`}\n sx={grid ? { borderRadius: 2 } : undefined}\n >\n {imageUrl ? (\n <CardMedia\n component=\"img\"\n image={imageUrl}\n alt={item.name}\n sx={{ ...mediaSx, ...photoFitSx }}\n // Deferred (AGL-2486). A related-products rail sits at\n // the BOTTOM of a product page by construction, and it\n // was fetching eagerly against the gallery hero above\n // it — the one image on that page that is the LCP.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : (\n // Never a blank tile: a product with no photo yet says\n // so, in the theme's colours (AGL-3676 follow-up).\n <ProductImagePlaceholder name={item.name} sx={mediaSx} />\n )}\n <CardContent sx={grid ? { px: 0.5, pt: 1.5, pb: 1 } : { py: 1 }}>\n <Typography variant={grid ? 'subtitle1' : 'body2'} sx={PRODUCT_NAME_SX}>\n {item.name}\n </Typography>\n <Typography variant={grid ? 'body2' : 'caption'} color=\"text.secondary\">\n {item.priceComingSoon\n ? 'Price coming soon'\n : formatOrderMoney(Math.round(item.priceUsd * 100))}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n )\n })}\n </Box>\n </Box>\n )\n },\n)\nRelatedProducts.displayName = 'AglynRelatedProducts'\n\nexport const schema: Aglyn.ComponentSchema<RelatedProductsProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Related products',\n description:\n 'An upsell strip — your manual picks, or what people buy together.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiShapePlus.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'productId',\n label: 'Product id',\n description:\n 'The product to find relatives OF. Blank reads it from the URL, so ' +\n 'a product template shows each product’s own related items; naming ' +\n 'one pins the rail to that product’s relatives everywhere.',\n component: Aglyn.FieldComponentType.PRODUCT_SELECT,\n },\n {\n name: 'heading',\n label: 'Heading',\n description: 'Defaults to \"You may also like\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n name: 'maxItems',\n label: 'Max items',\n description: 'Cap the strip (default 6).',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n type: 'number',\n },\n {\n // Default `strip`, so a page that already places this block keeps it.\n name: 'layout',\n label: 'Layout',\n description: 'A scrolling strip of small cards, or a grid of tall photo cards.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { label: 'Strip', value: 'strip' },\n { label: 'Photo grid', value: 'grid' },\n ],\n },\n PRODUCT_PHOTO_FIT_ATTRIBUTE,\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Related products',\n pluginId: BUNDLE_ID,\n description: 'Manual picks or frequently-bought-together',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiShapePlus.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n]\n\nexport default RelatedProducts\n"],"names":["Aglyn","mdiShapePlus","Box","Card","CardActionArea","CardContent","CardMedia","Typography","forwardRef","useEffect","useState","BUNDLE_ID","generatePresetId","formatOrderMoney","ProductImagePlaceholder","PRODUCT_PHOTO_FIT_ATTRIBUTE","productPhotoFit","productPhotoFitSx","PRODUCT_NAME_SX","ID","RelatedProducts","props","ref","site","productId","productIdProp","heading","maxItems","layout","photoFit","rest","nodeSx","Array","isArray","useSite","hostId","seededProductId","pageData","commerce","product","id","items","setItems","cap","Number","Math","floor","active","anchor","payload","match","window","location","pathname","response","fetch","encodeURIComponent","decodeURIComponent","catch","json","String","relatedResponse","related","ids","productIds","length","catalogResponse","join","catalog","sx","p","border","borderColor","borderRadius","color","fontSize","fontFamily","grid","photoFitSx","variant","component","gutterBottom","mb","undefined","display","gap","gridTemplateColumns","xs","md","overflowX","pb","slice","map","item","imageUrl","siteRelativeMediaSrc","mediaSx","aspectRatio","height","elevation","bgcolor","overflow","minWidth","href","slug","image","alt","name","DEFERRED_IMAGE_ATTRIBUTES","px","pt","py","priceComingSoon","round","priceUsd","displayName","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","path","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","label","FieldComponentType","PRODUCT_SELECT","TEXT_FIELD","type","SELECT","options","value","presets","NodeType","PRESET","data","componentId"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,oBAAoB,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