@aglyn/plugins-commerce 1.14.0 → 1.15.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.
- package/package.json +13 -13
- package/src/lib/components/account-subscriptions.d.ts +51 -0
- package/src/lib/components/account-subscriptions.js +168 -0
- package/src/lib/components/account-subscriptions.js.map +1 -0
- package/src/lib/components/account.js +12 -48
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart.js +30 -6
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +6 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +5 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/paid-media.d.ts +1 -0
- package/src/lib/components/console/paid-media.js +15 -4
- package/src/lib/components/console/paid-media.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +1 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-api.d.ts +10 -1
- package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js +2 -2
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +2 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -1
- package/src/lib/components/console/pos-cellular-control.component.d.ts +1 -1
- package/src/lib/components/console/pos-cellular-control.component.js +5 -5
- package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
- package/src/lib/components/console/pos-devices-card.component.js +2 -2
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-card.component.d.ts +5 -0
- package/src/lib/components/console/pos-hardware-card.component.js +77 -8
- package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +137 -19
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.js +19 -2
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +21 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.d.ts +58 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js +201 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/subscriptions-card.component.d.ts +60 -0
- package/src/lib/components/console/subscriptions-card.component.js +280 -0
- package/src/lib/components/console/subscriptions-card.component.js.map +1 -0
- package/src/lib/components/hardware-terms-consent.d.ts +22 -0
- package/src/lib/components/hardware-terms-consent.js +85 -0
- package/src/lib/components/hardware-terms-consent.js.map +1 -0
- package/src/lib/components/product-detail.js +25 -5
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/constants/operator-alerts.d.ts +1 -1
- package/src/lib/constants/operator-alerts.js +4 -4
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/model/commerce-orders.d.ts +6 -2
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +24 -0
- package/src/lib/model/commerce-payment-methods.js +35 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -1
- package/src/lib/model/commerce.d.ts +6 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/paid-media.d.ts +8 -0
- package/src/lib/model/paid-media.js +13 -0
- package/src/lib/model/paid-media.js.map +1 -1
- package/src/lib/model/pos-hardware-in-person.d.ts +23 -2
- package/src/lib/model/pos-hardware-in-person.js +52 -20
- package/src/lib/model/pos-hardware-in-person.js.map +1 -1
- package/src/lib/model/pos-hardware-tax-summary.d.ts +5 -1
- package/src/lib/model/pos-hardware-tax-summary.js +2 -1
- package/src/lib/model/pos-hardware-tax-summary.js.map +1 -1
- package/src/lib/model/pos-hardware-terms.d.ts +37 -2
- package/src/lib/model/pos-hardware-terms.js +68 -3
- package/src/lib/model/pos-hardware-terms.js.map +1 -1
- package/src/lib/model/pos-hardware.d.ts +101 -15
- package/src/lib/model/pos-hardware.js +128 -18
- package/src/lib/model/pos-hardware.js.map +1 -1
- package/src/lib/model/pos-reader-splash.js +2 -2
- package/src/lib/model/pos-reader-splash.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/model/subscription-view.d.ts +90 -0
- package/src/lib/model/subscription-view.js +176 -0
- package/src/lib/model/subscription-view.js.map +1 -0
- package/src/lib/server/billing-webhook.d.ts +4 -6
- package/src/lib/server/billing-webhook.js +109 -51
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cart-checkout.js +45 -10
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.js +15 -3
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/checkout.js +58 -16
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +7 -3
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/membership-account.d.ts +22 -0
- package/src/lib/server/membership-account.js +52 -8
- package/src/lib/server/membership-account.js.map +1 -1
- package/src/lib/server/pos-auth.d.ts +3 -3
- package/src/lib/server/pos-auth.js +3 -3
- package/src/lib/server/pos-auth.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.js +1 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular-notify.js +1 -1
- package/src/lib/server/pos-cellular-notify.js.map +1 -1
- package/src/lib/server/pos-cellular.js +1 -1
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-hardware-admin.js +86 -13
- package/src/lib/server/pos-hardware-admin.js.map +1 -1
- package/src/lib/server/pos-hardware-attach.js +5 -5
- package/src/lib/server/pos-hardware-attach.js.map +1 -1
- package/src/lib/server/pos-hardware-cancel.js +65 -0
- package/src/lib/server/pos-hardware-cancel.js.map +1 -1
- package/src/lib/server/pos-hardware-closure-notices.js +2 -5
- package/src/lib/server/pos-hardware-closure-notices.js.map +1 -1
- package/src/lib/server/pos-hardware-closure.js +5 -8
- package/src/lib/server/pos-hardware-closure.js.map +1 -1
- package/src/lib/server/pos-hardware-in-person.d.ts +2 -1
- package/src/lib/server/pos-hardware-in-person.js +72 -17
- package/src/lib/server/pos-hardware-in-person.js.map +1 -1
- package/src/lib/server/pos-hardware-notify.d.ts +2 -0
- package/src/lib/server/pos-hardware-notify.js +30 -5
- package/src/lib/server/pos-hardware-notify.js.map +1 -1
- package/src/lib/server/pos-hardware-readers.d.ts +25 -0
- package/src/lib/server/pos-hardware-readers.js +206 -85
- package/src/lib/server/pos-hardware-readers.js.map +1 -1
- package/src/lib/server/pos-hardware-returns.d.ts +8 -3
- package/src/lib/server/pos-hardware-returns.js +39 -7
- package/src/lib/server/pos-hardware-returns.js.map +1 -1
- package/src/lib/server/pos-hardware-sale-fields.d.ts +76 -0
- package/src/lib/server/pos-hardware-sale-fields.js +114 -1
- package/src/lib/server/pos-hardware-sale-fields.js.map +1 -1
- package/src/lib/server/pos-hardware-sale.d.ts +2 -0
- package/src/lib/server/pos-hardware-sale.js +1 -0
- package/src/lib/server/pos-hardware-sale.js.map +1 -1
- package/src/lib/server/pos-hardware-tax-return-source.js +7 -4
- package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -1
- package/src/lib/server/pos-hardware-webhook.js +16 -3
- package/src/lib/server/pos-hardware-webhook.js.map +1 -1
- package/src/lib/server/pos-hardware.d.ts +14 -3
- package/src/lib/server/pos-hardware.js +83 -18
- package/src/lib/server/pos-hardware.js.map +1 -1
- package/src/lib/server/pos-ops-routes.js +2 -10
- package/src/lib/server/pos-ops-routes.js.map +1 -1
- package/src/lib/server/quote-pay.js +8 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/stream.d.ts +2 -0
- package/src/lib/server/stream.js +22 -2
- package/src/lib/server/stream.js.map +1 -1
- package/src/lib/server/tax-return-source.js +5 -1
- package/src/lib/server/tax-return-source.js.map +1 -1
- package/src/lib/server.js +2 -2
- package/src/lib/server.js.map +1 -1
|
@@ -26,6 +26,11 @@ export interface PosHardwareCardProps {
|
|
|
26
26
|
* gate only the platform can lift, so naming it would point at a step nobody
|
|
27
27
|
* on the workspace can take. The route answers `available: false` until
|
|
28
28
|
* every price, the markup and the shipping figures are configured.
|
|
29
|
+
*
|
|
30
|
+
* ANYONE CAN BUY (AGL-4038): the shop is open on every plan. A workspace
|
|
31
|
+
* without the point of sale is prompted to add it, because a reader takes
|
|
32
|
+
* payments at the register: above the shop, and once an order has arrived,
|
|
33
|
+
* naming it. The prompt never switches Check out off.
|
|
29
34
|
*/
|
|
30
35
|
export declare function PosHardwareCard({ hostId, canManagePos, canBuyHardware, }: PosHardwareCardProps): import("react").JSX.Element;
|
|
31
36
|
export declare namespace PosHardwareCard {
|
|
@@ -22,14 +22,17 @@ import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.
|
|
|
22
22
|
import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component";
|
|
23
23
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
24
24
|
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
25
|
-
import { Alert, Box, Button, Card, CardContent, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Link, MenuItem, Stack, TextField, Typography } from "@mui/material";
|
|
25
|
+
import { Alert, Box, Button, Card, CardContent, Checkbox, Chip, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Link, MenuItem, Stack, TextField, Typography } from "@mui/material";
|
|
26
26
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
27
|
-
import { formatPosHardwareCents, POS_HARDWARE_ANCHOR, POS_HARDWARE_MAX_PER_LINE, POS_HARDWARE_STATUS_LABELS } from "../../model/pos-hardware.js";
|
|
27
|
+
import { formatPosHardwareCents, POS_HARDWARE_ANCHOR, POS_HARDWARE_MAX_PER_LINE, POS_HARDWARE_STATUS_LABELS, posPlanPrompt } from "../../model/pos-hardware.js";
|
|
28
|
+
import { POS_HARDWARE_TERMS_SECTIONS, posHardwareTermsUrl } from "../../model/pos-hardware-terms.js";
|
|
29
|
+
import { EntitlementUpsell, useCommerceEntitlement } from "./entitlement-gate.component.js";
|
|
28
30
|
import { newAttemptKey } from "./pos/pos-api.js";
|
|
29
31
|
import { openPosHardwareCheckout, posHardwareCatalog, posHardwareCheckout, posHardwareOrders, posHardwareRequestReturn, PosHardwareRequestError } from "./pos/pos-hardware-api.js";
|
|
30
32
|
export const POS_HARDWARE_STATUS_COLOR = {
|
|
31
33
|
paid: 'info',
|
|
32
34
|
ordered: 'info',
|
|
35
|
+
received: 'info',
|
|
33
36
|
shipped: 'primary',
|
|
34
37
|
delivered: 'success',
|
|
35
38
|
registered: 'success',
|
|
@@ -50,6 +53,7 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
50
53
|
year: 'numeric'
|
|
51
54
|
}) : '—';
|
|
52
55
|
/** Why Check out is not offered to someone who works the register. */ const BUY_KEY_REASON = 'Only a member with the "Buy point of sale hardware" permission can place an order. Ask an organization admin.';
|
|
56
|
+
/** Why Check out waits on the two boxes below the summary (AGL-4038). */ const TERMS_REASON = 'Accept the hardware terms of sale and confirm the hardware is for your business first.';
|
|
53
57
|
/**
|
|
54
58
|
* The Hardware card (AGL-4038): Stripe card readers and accessories sold by
|
|
55
59
|
* the platform and shipped by Stripe straight to the store, with the store's
|
|
@@ -59,6 +63,11 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
59
63
|
* gate only the platform can lift, so naming it would point at a step nobody
|
|
60
64
|
* on the workspace can take. The route answers `available: false` until
|
|
61
65
|
* every price, the markup and the shipping figures are configured.
|
|
66
|
+
*
|
|
67
|
+
* ANYONE CAN BUY (AGL-4038): the shop is open on every plan. A workspace
|
|
68
|
+
* without the point of sale is prompted to add it, because a reader takes
|
|
69
|
+
* payments at the register: above the shop, and once an order has arrived,
|
|
70
|
+
* naming it. The prompt never switches Check out off.
|
|
62
71
|
*/ export function PosHardwareCard({ hostId, canManagePos = false, canBuyHardware = canManagePos }) {
|
|
63
72
|
var _ref, _ref1;
|
|
64
73
|
const { data: user } = useUser();
|
|
@@ -69,9 +78,15 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
69
78
|
const [shippingMethod, setShippingMethod] = useState('');
|
|
70
79
|
const [busy, setBusy] = useState(false);
|
|
71
80
|
const [returned, setReturned] = useState(null);
|
|
81
|
+
// The terms of sale and business use, ticked before checkout (AGL-4038).
|
|
82
|
+
const [termsAccepted, setTermsAccepted] = useState(false);
|
|
83
|
+
const [businessUse, setBusinessUse] = useState(false);
|
|
72
84
|
const uid = (_ref = user == null ? void 0 : user.uid) != null ? _ref : '';
|
|
73
85
|
// The route's own door (AGL-4047): the register, or the key to buy.
|
|
74
86
|
const mayVisit = canManagePos || canBuyHardware;
|
|
87
|
+
// The point of sale, which a reader takes payments with (AGL-4038). Only
|
|
88
|
+
// `locked` prompts: a plan still loading prompts nobody.
|
|
89
|
+
const posPlan = useCommerceEntitlement(hostId, 'pos');
|
|
75
90
|
useEffect(()=>{
|
|
76
91
|
if (!user || !mayVisit) return;
|
|
77
92
|
let active = true;
|
|
@@ -190,13 +205,17 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
190
205
|
basketKey
|
|
191
206
|
]);
|
|
192
207
|
const checkout = async ()=>{
|
|
193
|
-
if (!user || !shippingMethod || !lines.length) return;
|
|
208
|
+
if (!user || !shippingMethod || !lines.length || !termsAccepted || !businessUse) return;
|
|
194
209
|
setBusy(true);
|
|
195
210
|
try {
|
|
196
211
|
const { url } = await posHardwareCheckout(user, attemptKey, {
|
|
197
212
|
hostId,
|
|
198
213
|
lines,
|
|
199
|
-
shippingMethod
|
|
214
|
+
shippingMethod,
|
|
215
|
+
hardwareTerms: {
|
|
216
|
+
accepted: termsAccepted,
|
|
217
|
+
businessUse
|
|
218
|
+
}
|
|
200
219
|
});
|
|
201
220
|
openPosHardwareCheckout(url);
|
|
202
221
|
} catch (error) {
|
|
@@ -288,6 +307,19 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
288
307
|
}
|
|
289
308
|
}
|
|
290
309
|
], []);
|
|
310
|
+
/*
|
|
311
|
+
* Orders shipped from this card that have arrived, for the prompt. A reader
|
|
312
|
+
* bought from the platform's own store, at an event or online, is prompted
|
|
313
|
+
* on the Card readers to set up card instead, so it is not named twice.
|
|
314
|
+
*/ const arrived = posPlan.locked ? (orders != null ? orders : []).filter((order)=>{
|
|
315
|
+
var _order_source;
|
|
316
|
+
return ((_order_source = order.source) != null ? _order_source : 'online') === 'online' && (order.status === 'delivered' || order.status === 'registered');
|
|
317
|
+
}).map((order)=>order.number) : [];
|
|
318
|
+
const planPrompt = (text)=>/*#__PURE__*/ _jsx(EntitlementUpsell, {
|
|
319
|
+
planLabel: posPlan.planLabel,
|
|
320
|
+
upgradeHref: posPlan.upgradeHref,
|
|
321
|
+
children: text
|
|
322
|
+
});
|
|
291
323
|
const ordersSection = /*#__PURE__*/ _jsxs(Stack, {
|
|
292
324
|
spacing: 1,
|
|
293
325
|
children: [
|
|
@@ -295,6 +327,9 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
295
327
|
variant: "subtitle2",
|
|
296
328
|
children: 'Your orders'
|
|
297
329
|
}),
|
|
330
|
+
arrived.length ? planPrompt(posPlanPrompt({
|
|
331
|
+
arrived
|
|
332
|
+
})) : null,
|
|
298
333
|
orders && orders.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
|
|
299
334
|
variant: "body2",
|
|
300
335
|
color: "text.secondary",
|
|
@@ -376,14 +411,14 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
376
411
|
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
377
412
|
id: POS_HARDWARE_ANCHOR,
|
|
378
413
|
header: 'Hardware',
|
|
379
|
-
subheader: 'Card readers
|
|
414
|
+
subheader: 'Card readers and accessories, set up and shipped to you',
|
|
380
415
|
help: pluginDocsHelp('posHardware', {
|
|
381
416
|
anchor: '#buy-a-reader-from-aglyn'
|
|
382
417
|
}),
|
|
383
418
|
HeaderProps: {
|
|
384
419
|
action: /*#__PURE__*/ _jsx(BlockedControl, {
|
|
385
|
-
blocked: !canBuyHardware,
|
|
386
|
-
reason: BUY_KEY_REASON,
|
|
420
|
+
blocked: !canBuyHardware || !termsAccepted || !businessUse,
|
|
421
|
+
reason: !canBuyHardware ? BUY_KEY_REASON : TERMS_REASON,
|
|
387
422
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
388
423
|
size: "small",
|
|
389
424
|
variant: "contained",
|
|
@@ -407,10 +442,11 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
407
442
|
onClose: ()=>setReturned(null),
|
|
408
443
|
children: 'Checkout was canceled. Nothing was charged.'
|
|
409
444
|
}) : null,
|
|
445
|
+
posPlan.locked && !arrived.length ? planPrompt(posPlanPrompt()) : null,
|
|
410
446
|
/*#__PURE__*/ _jsx(Typography, {
|
|
411
447
|
variant: "body2",
|
|
412
448
|
color: "text.secondary",
|
|
413
|
-
children: 'Choose the readers and accessories you need.
|
|
449
|
+
children: 'Choose the readers and accessories you need. We set each reader up and ship your order to the address you enter at checkout. The delivery email says how to start taking payments with it.'
|
|
414
450
|
}),
|
|
415
451
|
/*#__PURE__*/ _jsx(Box, {
|
|
416
452
|
sx: {
|
|
@@ -544,6 +580,39 @@ const placedOn = (ms)=>ms ? new Date(ms).toLocaleDateString([], {
|
|
|
544
580
|
color: "text.secondary",
|
|
545
581
|
children: 'Ships to street addresses in the United States. P.O. boxes and military addresses are not accepted.'
|
|
546
582
|
}),
|
|
583
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
584
|
+
children: [
|
|
585
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
586
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
587
|
+
checked: termsAccepted,
|
|
588
|
+
onChange: (event)=>setTermsAccepted(event.target.checked)
|
|
589
|
+
}),
|
|
590
|
+
label: /*#__PURE__*/ _jsxs(Typography, {
|
|
591
|
+
variant: "body2",
|
|
592
|
+
children: [
|
|
593
|
+
'I accept the ',
|
|
594
|
+
/*#__PURE__*/ _jsx(Link, {
|
|
595
|
+
href: posHardwareTermsUrl(),
|
|
596
|
+
target: "_blank",
|
|
597
|
+
rel: "noopener noreferrer",
|
|
598
|
+
children: `hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS})`
|
|
599
|
+
}),
|
|
600
|
+
'.'
|
|
601
|
+
]
|
|
602
|
+
})
|
|
603
|
+
}),
|
|
604
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
605
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
606
|
+
checked: businessUse,
|
|
607
|
+
onChange: (event)=>setBusinessUse(event.target.checked)
|
|
608
|
+
}),
|
|
609
|
+
label: /*#__PURE__*/ _jsx(Typography, {
|
|
610
|
+
variant: "body2",
|
|
611
|
+
children: 'I am buying this hardware for use in my business.'
|
|
612
|
+
})
|
|
613
|
+
})
|
|
614
|
+
]
|
|
615
|
+
}),
|
|
547
616
|
ordersSection
|
|
548
617
|
]
|
|
549
618
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-hardware-card.component.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'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Card,\n CardContent,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n formatPosHardwareCents,\n POS_HARDWARE_ANCHOR,\n POS_HARDWARE_MAX_PER_LINE,\n POS_HARDWARE_STATUS_LABELS,\n type PosHardwareOrderStatus,\n type PosHardwareShippingMethod,\n} from '../../model/pos-hardware'\nimport { newAttemptKey } from './pos/pos-api'\nimport {\n openPosHardwareCheckout,\n posHardwareCatalog,\n posHardwareCheckout,\n posHardwareOrders,\n posHardwareRequestReturn,\n PosHardwareRequestError,\n type PosHardwareCatalog,\n type PosHardwareOrderRow,\n} from './pos/pos-hardware-api'\n\n\nexport const POS_HARDWARE_STATUS_COLOR: Record<\n PosHardwareOrderStatus,\n 'default' | 'info' | 'primary' | 'success'\n> = {\n paid: 'info',\n ordered: 'info',\n shipped: 'primary',\n delivered: 'success',\n registered: 'success',\n canceled: 'default',\n refunded: 'default',\n}\n\n/** What the buyer reads of their return request. */\nconst RETURN_LABELS: Record<string, string> = {\n requested: 'Return requested',\n declined: 'Return declined',\n refunded: 'Returned',\n}\n\nconst QUANTITIES = Array.from({ length: POS_HARDWARE_MAX_PER_LINE + 1 }, (_, index) => index)\n\nconst placedOn = (ms: number) =>\n ms ? new Date(ms).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' }) : '—'\n\nexport interface PosHardwareCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register (`managePos`). The shop\n * is the register's hardware, so whoever works it is shown the shop.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may start a checkout (AGL-4047): the \"Buy point of\n * sale hardware\" key the route asks of a checkout. It stands on its own,\n * so a member who holds it without the register is shown the shop and\n * their orders too. Someone who works the register without it sees the\n * shop with Check out disabled and the reason. Absent follows\n * `canManagePos`.\n */\n canBuyHardware?: boolean\n}\n\n/** Why Check out is not offered to someone who works the register. */\nconst BUY_KEY_REASON =\n 'Only a member with the \"Buy point of sale hardware\" permission can place an order. Ask an organization admin.'\n\n/**\n * The Hardware card (AGL-4038): Stripe card readers and accessories sold by\n * the platform and shipped by Stripe straight to the store, with the store's\n * orders and their tracking underneath.\n *\n * HIDDEN, NOT DISABLED, while the deployment has not opened the shop: it is a\n * gate only the platform can lift, so naming it would point at a step nobody\n * on the workspace can take. The route answers `available: false` until\n * every price, the markup and the shipping figures are configured.\n */\nexport function PosHardwareCard({\n hostId,\n canManagePos = false,\n canBuyHardware = canManagePos,\n}: PosHardwareCardProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [catalog, setCatalog] = useState<PosHardwareCatalog | null>(null)\n const [orders, setOrders] = useState<PosHardwareOrderRow[] | null>(null)\n const [quantities, setQuantities] = useState<Record<string, number>>({})\n const [shippingMethod, setShippingMethod] = useState<PosHardwareShippingMethod | ''>('')\n const [busy, setBusy] = useState(false)\n const [returned, setReturned] = useState<'placed' | 'canceled' | null>(null)\n const uid = user?.uid ?? ''\n // The route's own door (AGL-4047): the register, or the key to buy.\n const mayVisit = canManagePos || canBuyHardware\n\n useEffect(() => {\n if (!user || !mayVisit) return\n let active = true\n void posHardwareCatalog(user, hostId)\n .then((answer) => {\n if (active) setCatalog(answer)\n })\n .catch(() => {\n if (active) setCatalog({ available: false })\n })\n return () => {\n active = false\n }\n // Keyed on the person, not the session object.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, mayVisit])\n\n const available = catalog?.available === true\n\n const loadOrders = useCallback(async () => {\n if (!user) return\n try {\n setOrders((await posHardwareOrders(user, hostId)).orders)\n } catch {\n setOrders([])\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n // The orders load whether or not the shop is open: a reader bought in\n // person (AGL-4038) is the workspace's purchase history too.\n useEffect(() => {\n if (mayVisit) void loadOrders()\n }, [mayVisit, loadOrders])\n\n /** The order whose return is being asked for, and why (AGL-4038). */\n const [returning, setReturning] = useState<PosHardwareOrderRow | null>(null)\n const [returnReason, setReturnReason] = useState('')\n const requestReturn = async () => {\n if (!user || !returning) return\n setBusy(true)\n try {\n await posHardwareRequestReturn(user, hostId, returning.id, returnReason.trim())\n enqueueSnackbar('Return requested. Our team arranges it with you.', { variant: 'success', persist: false })\n setReturning(null)\n setReturnReason('')\n await loadOrders()\n } catch (error) {\n enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : 'The request did not go through', {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n // The first shipping speed is the default once the catalog answers.\n useEffect(() => {\n if (catalog?.available && !shippingMethod && catalog.shipping.length) {\n setShippingMethod(catalog.shipping[0].method)\n }\n }, [catalog, shippingMethod])\n\n // Back from Checkout: say what happened, then drop the marker from the URL.\n useEffect(() => {\n if (typeof window === 'undefined') return\n const url = new URL(window.location.href)\n const outcome = url.searchParams.get('hardwareOrder')\n if (outcome === 'placed' || outcome === 'canceled') {\n setReturned(outcome)\n url.searchParams.delete('hardwareOrder')\n window.history.replaceState(window.history.state, '', url.toString())\n }\n }, [])\n\n // Arrived by an email's link or Checkout's return: bring the card into view.\n useEffect(() => {\n if (!available || typeof window === 'undefined') return\n if (window.location.hash !== `#${POS_HARDWARE_ANCHOR}`) return\n document.getElementById(POS_HARDWARE_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [available])\n\n const lines = useMemo(\n () =>\n Object.entries(quantities)\n .filter(([, quantity]) => quantity > 0)\n .map(([sku, quantity]) => ({ sku, quantity })),\n [quantities],\n )\n const shipping = catalog?.available ? catalog.shipping.find((option) => option.method === shippingMethod) : undefined\n const subtotalCents = catalog?.available\n ? lines.reduce(\n (sum, line) => sum + (catalog.offers.find((offer) => offer.sku === line.sku)?.unitCents ?? 0) * line.quantity,\n 0,\n )\n : 0\n\n // One attempt per basket: a second press of the same basket reaches the\n // same Checkout Session, and a changed basket is a new one.\n const basketKey = JSON.stringify([lines, shippingMethod])\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const attemptKey = useMemo(() => newAttemptKey(), [basketKey])\n\n const checkout = async () => {\n if (!user || !shippingMethod || !lines.length) return\n setBusy(true)\n try {\n const { url } = await posHardwareCheckout(user, attemptKey, { hostId, lines, shippingMethod })\n openPosHardwareCheckout(url)\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosHardwareRequestError ? error.message : 'Checkout could not be started',\n { variant: 'warning', persist: false },\n )\n setBusy(false)\n }\n }\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'number', headerName: 'Order', minWidth: 110 },\n {\n field: 'createdAtMs',\n headerName: 'Placed',\n type: 'number',\n minWidth: 120,\n align: 'left',\n headerAlign: 'left',\n valueFormatter: (value: number) => placedOn(value),\n },\n {\n field: 'items',\n headerName: 'Items',\n flex: 1,\n minWidth: 200,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) =>\n row.lines.map((line) => `${line.name} × ${line.quantity}`).join(', '),\n },\n {\n field: 'totalCents',\n headerName: 'Total',\n type: 'number',\n minWidth: 100,\n valueFormatter: (value: number) => formatPosHardwareCents(value),\n },\n {\n field: 'status',\n headerName: 'Status',\n minWidth: 130,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => POS_HARDWARE_STATUS_LABELS[row.status],\n renderCell: ({ row }: { row: PosHardwareOrderRow }) => (\n <Chip size=\"small\" color={POS_HARDWARE_STATUS_COLOR[row.status]} label={POS_HARDWARE_STATUS_LABELS[row.status]} />\n ),\n },\n {\n // A reader bought in person, or an order shipped to you once it has\n // shipped (AGL-4038), can be asked back from here.\n field: 'returnRequest',\n headerName: 'Return',\n minWidth: 170,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => RETURN_LABELS[row.returnRequest?.state ?? ''] ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.returnRequest ? (\n RETURN_LABELS[row.returnRequest.state]\n ) : (row.status === 'delivered' || row.status === 'registered' || (row.source !== 'in_person' && row.status === 'shipped')) ? (\n <Button\n size=\"small\"\n onClick={(event) => {\n event.stopPropagation()\n setReturning(row)\n }}\n >\n {'Request a return'}\n </Button>\n ) : (\n '—'\n ),\n },\n {\n field: 'tracking',\n headerName: 'Tracking',\n minWidth: 160,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => row.tracking?.number ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.tracking?.url ? (\n <Link href={row.tracking.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {row.tracking.number}\n </Link>\n ) : (\n row.tracking?.number ?? '—'\n ),\n },\n ],\n [],\n )\n\n const ordersSection = (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Your orders'}</Typography>\n {orders && orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No hardware orders yet.'}\n </Typography>\n ) : (\n <ListTable\n rows={(orders ?? []).map((order) => ({ ...order, $id: order.id }))}\n columns={columns}\n loading={orders === null}\n hideFooter\n quickFilter={false}\n />\n )}\n <Dialog open={Boolean(returning)} onClose={() => setReturning(null)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{returning ? `Return ${returning.number}?` : ''}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tell us why. Our team gets your request and arranges the return with you. Returns follow the hardware terms of sale: the return shipping is yours to pay, the original shipping is not refunded, and any restocking fee charged for the return comes off the refund.'}\n </Typography>\n <TextField\n label=\"Why are you returning it?\"\n value={returnReason}\n onChange={(event) => setReturnReason(event.target.value)}\n multiline\n minRows={2}\n fullWidth\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setReturning(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={busy || returnReason.trim().length < 3} onClick={() => void requestReturn()}>\n {'Request return'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n\n // With the shop closed, the card is the purchase history alone, and only\n // when there is one (AGL-4038): a reader bought in person.\n if (!available || !catalog?.available) {\n if (!orders?.length) return null\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Your card reader orders'}\n help={pluginDocsHelp('posHardware', { anchor: '#bought-from-us-in-person' })}\n contentGutterX\n contentGutterY\n >\n {ordersSection}\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Card readers from Stripe, shipped straight to you'}\n help={pluginDocsHelp('posHardware', { anchor: '#buy-a-reader-from-aglyn' })}\n HeaderProps={{\n action: (\n <BlockedControl blocked={!canBuyHardware} reason={BUY_KEY_REASON}>\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={busy || !lines.length || !shipping}\n onClick={() => void checkout()}\n >\n {'Check out'}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={3}>\n {returned === 'placed' ? (\n <Alert severity=\"success\" onClose={() => setReturned(null)}>\n {'Thanks, your order is in. It shows under Your orders within a minute, and we email you as it ships.'}\n </Alert>\n ) : returned === 'canceled' ? (\n <Alert severity=\"info\" onClose={() => setReturned(null)}>\n {'Checkout was canceled. Nothing was charged.'}\n </Alert>\n ) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Choose the readers and accessories you need. Stripe ships them to the address you enter at checkout, and you add each reader to a register on the POS devices card when it arrives.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(3, 1fr)' },\n }}\n >\n {catalog.offers.map((offer) => (\n <Card key={offer.sku} variant=\"outlined\">\n <CardContent>\n <Stack spacing={1} sx={{ height: '100%' }}>\n <Typography variant=\"subtitle2\">{offer.name}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ flex: 1 }}>\n {offer.use}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"body1\">{formatPosHardwareCents(offer.unitCents)}</Typography>\n <TextField\n select\n size=\"small\"\n label=\"Quantity\"\n value={quantities[offer.sku] ?? 0}\n onChange={(event) =>\n setQuantities((prev) => ({ ...prev, [offer.sku]: Number(event.target.value) }))\n }\n slotProps={{ htmlInput: { 'aria-label': `Quantity of ${offer.name}` } }}\n >\n {QUANTITIES.map((quantity) => (\n <MenuItem key={quantity} value={quantity}>\n {quantity}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n </Stack>\n </CardContent>\n </Card>\n ))}\n </Box>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'flex-start' } }}>\n <TextField\n select\n size=\"small\"\n label=\"Shipping\"\n value={shippingMethod}\n onChange={(event) => setShippingMethod(event.target.value as PosHardwareShippingMethod)}\n sx={{ minWidth: { sm: '40%' } }}\n >\n {catalog.shipping.map((option) => (\n <MenuItem key={option.method} value={option.method}>\n {`${option.label} · ${formatPosHardwareCents(option.cents)}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack spacing={0.5} sx={{ flex: 1 }} aria-label=\"Order summary\">\n <SummaryRow label=\"Items\" value={formatPosHardwareCents(subtotalCents)} />\n <SummaryRow label=\"Shipping\" value={shipping ? formatPosHardwareCents(shipping.cents) : '—'} />\n {catalog.automaticTax ? <SummaryRow label=\"Tax\" value=\"Calculated at checkout\" /> : null}\n <SummaryRow\n label={catalog.automaticTax ? 'Total before tax' : 'Total'}\n value={formatPosHardwareCents(subtotalCents + (shipping?.cents ?? 0))}\n strong\n />\n </Stack>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Ships to street addresses in the United States. P.O. boxes and military addresses are not accepted.'}\n </Typography>\n {ordersSection}\n </Stack>\n </CardDisplay>\n )\n}\nPosHardwareCard.displayName = 'PosHardwareCard'\n\nfunction SummaryRow(props: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Typography variant=\"body2\" color={props.strong ? 'text.primary' : 'text.secondary'}>\n {props.label}\n </Typography>\n <Typography variant=\"body2\" sx={props.strong ? { fontWeight: 'fontWeightMedium' } : undefined}>\n {props.value}\n </Typography>\n </Stack>\n )\n}\n\nexport default PosHardwareCard\n"],"names":["pluginDocsHelp","CardDisplay","BlockedControl","ListTable","useSnackbar","useUser","Alert","Box","Button","Card","CardContent","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","MenuItem","Stack","TextField","Typography","useCallback","useEffect","useMemo","useState","formatPosHardwareCents","POS_HARDWARE_ANCHOR","POS_HARDWARE_MAX_PER_LINE","POS_HARDWARE_STATUS_LABELS","newAttemptKey","openPosHardwareCheckout","posHardwareCatalog","posHardwareCheckout","posHardwareOrders","posHardwareRequestReturn","PosHardwareRequestError","POS_HARDWARE_STATUS_COLOR","paid","ordered","shipped","delivered","registered","canceled","refunded","RETURN_LABELS","requested","declined","QUANTITIES","Array","from","length","_","index","placedOn","ms","Date","toLocaleDateString","month","day","year","BUY_KEY_REASON","PosHardwareCard","hostId","canManagePos","canBuyHardware","data","user","enqueueSnackbar","catalog","setCatalog","orders","setOrders","quantities","setQuantities","shippingMethod","setShippingMethod","busy","setBusy","returned","setReturned","uid","mayVisit","active","then","answer","catch","available","loadOrders","returning","setReturning","returnReason","setReturnReason","requestReturn","id","trim","variant","persist","error","message","shipping","method","window","url","URL","location","href","outcome","searchParams","get","delete","history","replaceState","state","toString","document","hash","getElementById","scrollIntoView","block","lines","Object","entries","filter","quantity","map","sku","find","option","undefined","subtotalCents","reduce","sum","line","offers","offer","unitCents","basketKey","JSON","stringify","attemptKey","checkout","columns","field","headerName","minWidth","type","align","headerAlign","valueFormatter","value","flex","valueGetter","_value","row","name","join","status","renderCell","size","color","label","returnRequest","source","onClick","event","stopPropagation","tracking","number","target","rel","ordersSection","spacing","rows","order","$id","loading","hideFooter","quickFilter","open","Boolean","onClose","maxWidth","fullWidth","sx","display","flexDirection","gap","onChange","multiline","minRows","disabled","header","subheader","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","reason","severity","gridTemplateColumns","xs","sm","md","height","use","direction","alignItems","justifyContent","select","prev","Number","slotProps","htmlInput","cents","aria-label","SummaryRow","automaticTax","strong","displayName","props","fontWeight"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AAEtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,yBAAyB,EACzBC,0BAA0B,QAGrB,8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AAIuC,MAAMF,MAAM,GAAG;oBAAEG,YAAY;gBAAmB,IAAI/F;0BACjF8F,MAAMzE,KAAK;;;;AAIpB;AAEA,eAAexF,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-hardware-card.component.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'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Card,\n CardContent,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n Link,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n formatPosHardwareCents,\n POS_HARDWARE_ANCHOR,\n POS_HARDWARE_MAX_PER_LINE,\n POS_HARDWARE_STATUS_LABELS,\n posPlanPrompt,\n type PosHardwareOrderStatus,\n type PosHardwareShippingMethod,\n} from '../../model/pos-hardware'\nimport { POS_HARDWARE_TERMS_SECTIONS, posHardwareTermsUrl } from '../../model/pos-hardware-terms'\nimport { EntitlementUpsell, useCommerceEntitlement } from './entitlement-gate.component'\nimport { newAttemptKey } from './pos/pos-api'\nimport {\n openPosHardwareCheckout,\n posHardwareCatalog,\n posHardwareCheckout,\n posHardwareOrders,\n posHardwareRequestReturn,\n PosHardwareRequestError,\n type PosHardwareCatalog,\n type PosHardwareOrderRow,\n} from './pos/pos-hardware-api'\n\n\nexport const POS_HARDWARE_STATUS_COLOR: Record<\n PosHardwareOrderStatus,\n 'default' | 'info' | 'primary' | 'success'\n> = {\n paid: 'info',\n ordered: 'info',\n received: 'info',\n shipped: 'primary',\n delivered: 'success',\n registered: 'success',\n canceled: 'default',\n refunded: 'default',\n}\n\n/** What the buyer reads of their return request. */\nconst RETURN_LABELS: Record<string, string> = {\n requested: 'Return requested',\n declined: 'Return declined',\n refunded: 'Returned',\n}\n\nconst QUANTITIES = Array.from({ length: POS_HARDWARE_MAX_PER_LINE + 1 }, (_, index) => index)\n\nconst placedOn = (ms: number) =>\n ms ? new Date(ms).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' }) : '—'\n\nexport interface PosHardwareCardProps {\n hostId: string\n /**\n * Whether the viewer may work this site's register (`managePos`). The shop\n * is the register's hardware, so whoever works it is shown the shop.\n */\n canManagePos?: boolean\n /**\n * Whether the viewer may start a checkout (AGL-4047): the \"Buy point of\n * sale hardware\" key the route asks of a checkout. It stands on its own,\n * so a member who holds it without the register is shown the shop and\n * their orders too. Someone who works the register without it sees the\n * shop with Check out disabled and the reason. Absent follows\n * `canManagePos`.\n */\n canBuyHardware?: boolean\n}\n\n/** Why Check out is not offered to someone who works the register. */\nconst BUY_KEY_REASON =\n 'Only a member with the \"Buy point of sale hardware\" permission can place an order. Ask an organization admin.'\n\n/** Why Check out waits on the two boxes below the summary (AGL-4038). */\nconst TERMS_REASON = 'Accept the hardware terms of sale and confirm the hardware is for your business first.'\n\n/**\n * The Hardware card (AGL-4038): Stripe card readers and accessories sold by\n * the platform and shipped by Stripe straight to the store, with the store's\n * orders and their tracking underneath.\n *\n * HIDDEN, NOT DISABLED, while the deployment has not opened the shop: it is a\n * gate only the platform can lift, so naming it would point at a step nobody\n * on the workspace can take. The route answers `available: false` until\n * every price, the markup and the shipping figures are configured.\n *\n * ANYONE CAN BUY (AGL-4038): the shop is open on every plan. A workspace\n * without the point of sale is prompted to add it, because a reader takes\n * payments at the register: above the shop, and once an order has arrived,\n * naming it. The prompt never switches Check out off.\n */\nexport function PosHardwareCard({\n hostId,\n canManagePos = false,\n canBuyHardware = canManagePos,\n}: PosHardwareCardProps) {\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [catalog, setCatalog] = useState<PosHardwareCatalog | null>(null)\n const [orders, setOrders] = useState<PosHardwareOrderRow[] | null>(null)\n const [quantities, setQuantities] = useState<Record<string, number>>({})\n const [shippingMethod, setShippingMethod] = useState<PosHardwareShippingMethod | ''>('')\n const [busy, setBusy] = useState(false)\n const [returned, setReturned] = useState<'placed' | 'canceled' | null>(null)\n // The terms of sale and business use, ticked before checkout (AGL-4038).\n const [termsAccepted, setTermsAccepted] = useState(false)\n const [businessUse, setBusinessUse] = useState(false)\n const uid = user?.uid ?? ''\n // The route's own door (AGL-4047): the register, or the key to buy.\n const mayVisit = canManagePos || canBuyHardware\n // The point of sale, which a reader takes payments with (AGL-4038). Only\n // `locked` prompts: a plan still loading prompts nobody.\n const posPlan = useCommerceEntitlement(hostId, 'pos')\n\n useEffect(() => {\n if (!user || !mayVisit) return\n let active = true\n void posHardwareCatalog(user, hostId)\n .then((answer) => {\n if (active) setCatalog(answer)\n })\n .catch(() => {\n if (active) setCatalog({ available: false })\n })\n return () => {\n active = false\n }\n // Keyed on the person, not the session object.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId, mayVisit])\n\n const available = catalog?.available === true\n\n const loadOrders = useCallback(async () => {\n if (!user) return\n try {\n setOrders((await posHardwareOrders(user, hostId)).orders)\n } catch {\n setOrders([])\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [uid, hostId])\n\n // The orders load whether or not the shop is open: a reader bought in\n // person (AGL-4038) is the workspace's purchase history too.\n useEffect(() => {\n if (mayVisit) void loadOrders()\n }, [mayVisit, loadOrders])\n\n /** The order whose return is being asked for, and why (AGL-4038). */\n const [returning, setReturning] = useState<PosHardwareOrderRow | null>(null)\n const [returnReason, setReturnReason] = useState('')\n const requestReturn = async () => {\n if (!user || !returning) return\n setBusy(true)\n try {\n await posHardwareRequestReturn(user, hostId, returning.id, returnReason.trim())\n enqueueSnackbar('Return requested. Our team arranges it with you.', { variant: 'success', persist: false })\n setReturning(null)\n setReturnReason('')\n await loadOrders()\n } catch (error) {\n enqueueSnackbar(error instanceof PosHardwareRequestError ? error.message : 'The request did not go through', {\n variant: 'warning',\n persist: false,\n })\n } finally {\n setBusy(false)\n }\n }\n\n // The first shipping speed is the default once the catalog answers.\n useEffect(() => {\n if (catalog?.available && !shippingMethod && catalog.shipping.length) {\n setShippingMethod(catalog.shipping[0].method)\n }\n }, [catalog, shippingMethod])\n\n // Back from Checkout: say what happened, then drop the marker from the URL.\n useEffect(() => {\n if (typeof window === 'undefined') return\n const url = new URL(window.location.href)\n const outcome = url.searchParams.get('hardwareOrder')\n if (outcome === 'placed' || outcome === 'canceled') {\n setReturned(outcome)\n url.searchParams.delete('hardwareOrder')\n window.history.replaceState(window.history.state, '', url.toString())\n }\n }, [])\n\n // Arrived by an email's link or Checkout's return: bring the card into view.\n useEffect(() => {\n if (!available || typeof window === 'undefined') return\n if (window.location.hash !== `#${POS_HARDWARE_ANCHOR}`) return\n document.getElementById(POS_HARDWARE_ANCHOR)?.scrollIntoView?.({ block: 'start' })\n }, [available])\n\n const lines = useMemo(\n () =>\n Object.entries(quantities)\n .filter(([, quantity]) => quantity > 0)\n .map(([sku, quantity]) => ({ sku, quantity })),\n [quantities],\n )\n const shipping = catalog?.available ? catalog.shipping.find((option) => option.method === shippingMethod) : undefined\n const subtotalCents = catalog?.available\n ? lines.reduce(\n (sum, line) => sum + (catalog.offers.find((offer) => offer.sku === line.sku)?.unitCents ?? 0) * line.quantity,\n 0,\n )\n : 0\n\n // One attempt per basket: a second press of the same basket reaches the\n // same Checkout Session, and a changed basket is a new one.\n const basketKey = JSON.stringify([lines, shippingMethod])\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const attemptKey = useMemo(() => newAttemptKey(), [basketKey])\n\n const checkout = async () => {\n if (!user || !shippingMethod || !lines.length || !termsAccepted || !businessUse) return\n setBusy(true)\n try {\n const { url } = await posHardwareCheckout(user, attemptKey, {\n hostId,\n lines,\n shippingMethod,\n hardwareTerms: { accepted: termsAccepted, businessUse },\n })\n openPosHardwareCheckout(url)\n } catch (error) {\n enqueueSnackbar(\n error instanceof PosHardwareRequestError ? error.message : 'Checkout could not be started',\n { variant: 'warning', persist: false },\n )\n setBusy(false)\n }\n }\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'number', headerName: 'Order', minWidth: 110 },\n {\n field: 'createdAtMs',\n headerName: 'Placed',\n type: 'number',\n minWidth: 120,\n align: 'left',\n headerAlign: 'left',\n valueFormatter: (value: number) => placedOn(value),\n },\n {\n field: 'items',\n headerName: 'Items',\n flex: 1,\n minWidth: 200,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) =>\n row.lines.map((line) => `${line.name} × ${line.quantity}`).join(', '),\n },\n {\n field: 'totalCents',\n headerName: 'Total',\n type: 'number',\n minWidth: 100,\n valueFormatter: (value: number) => formatPosHardwareCents(value),\n },\n {\n field: 'status',\n headerName: 'Status',\n minWidth: 130,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => POS_HARDWARE_STATUS_LABELS[row.status],\n renderCell: ({ row }: { row: PosHardwareOrderRow }) => (\n <Chip size=\"small\" color={POS_HARDWARE_STATUS_COLOR[row.status]} label={POS_HARDWARE_STATUS_LABELS[row.status]} />\n ),\n },\n {\n // A reader bought in person, or an order shipped to you once it has\n // shipped (AGL-4038), can be asked back from here.\n field: 'returnRequest',\n headerName: 'Return',\n minWidth: 170,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => RETURN_LABELS[row.returnRequest?.state ?? ''] ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.returnRequest ? (\n RETURN_LABELS[row.returnRequest.state]\n ) : (row.status === 'delivered' || row.status === 'registered' || (row.source !== 'in_person' && row.status === 'shipped')) ? (\n <Button\n size=\"small\"\n onClick={(event) => {\n event.stopPropagation()\n setReturning(row)\n }}\n >\n {'Request a return'}\n </Button>\n ) : (\n '—'\n ),\n },\n {\n field: 'tracking',\n headerName: 'Tracking',\n minWidth: 160,\n valueGetter: (_value: unknown, row: PosHardwareOrderRow) => row.tracking?.number ?? '',\n renderCell: ({ row }: { row: PosHardwareOrderRow }) =>\n row.tracking?.url ? (\n <Link href={row.tracking.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {row.tracking.number}\n </Link>\n ) : (\n row.tracking?.number ?? '—'\n ),\n },\n ],\n [],\n )\n\n /*\n * Orders shipped from this card that have arrived, for the prompt. A reader\n * bought from the platform's own store, at an event or online, is prompted\n * on the Card readers to set up card instead, so it is not named twice.\n */\n const arrived = posPlan.locked\n ? (orders ?? [])\n .filter((order) => (order.source ?? 'online') === 'online' && (order.status === 'delivered' || order.status === 'registered'))\n .map((order) => order.number)\n : []\n const planPrompt = (text: string) => (\n <EntitlementUpsell planLabel={posPlan.planLabel} upgradeHref={posPlan.upgradeHref}>\n {text}\n </EntitlementUpsell>\n )\n\n const ordersSection = (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Your orders'}</Typography>\n {arrived.length ? planPrompt(posPlanPrompt({ arrived })) : null}\n {orders && orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No hardware orders yet.'}\n </Typography>\n ) : (\n <ListTable\n rows={(orders ?? []).map((order) => ({ ...order, $id: order.id }))}\n columns={columns}\n loading={orders === null}\n hideFooter\n quickFilter={false}\n />\n )}\n <Dialog open={Boolean(returning)} onClose={() => setReturning(null)} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{returning ? `Return ${returning.number}?` : ''}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tell us why. Our team gets your request and arranges the return with you. Returns follow the hardware terms of sale: the return shipping is yours to pay, the original shipping is not refunded, and any restocking fee charged for the return comes off the refund.'}\n </Typography>\n <TextField\n label=\"Why are you returning it?\"\n value={returnReason}\n onChange={(event) => setReturnReason(event.target.value)}\n multiline\n minRows={2}\n fullWidth\n />\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setReturning(null)}>{'Cancel'}</Button>\n <Button variant=\"contained\" disabled={busy || returnReason.trim().length < 3} onClick={() => void requestReturn()}>\n {'Request return'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n\n // With the shop closed, the card is the purchase history alone, and only\n // when there is one (AGL-4038): a reader bought in person.\n if (!available || !catalog?.available) {\n if (!orders?.length) return null\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Your card reader orders'}\n help={pluginDocsHelp('posHardware', { anchor: '#bought-from-us-in-person' })}\n contentGutterX\n contentGutterY\n >\n {ordersSection}\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n id={POS_HARDWARE_ANCHOR}\n header={'Hardware'}\n subheader={'Card readers and accessories, set up and shipped to you'}\n help={pluginDocsHelp('posHardware', { anchor: '#buy-a-reader-from-aglyn' })}\n HeaderProps={{\n action: (\n <BlockedControl\n blocked={!canBuyHardware || !termsAccepted || !businessUse}\n reason={!canBuyHardware ? BUY_KEY_REASON : TERMS_REASON}\n >\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={busy || !lines.length || !shipping}\n onClick={() => void checkout()}\n >\n {'Check out'}\n </Button>\n </BlockedControl>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={3}>\n {returned === 'placed' ? (\n <Alert severity=\"success\" onClose={() => setReturned(null)}>\n {'Thanks, your order is in. It shows under Your orders within a minute, and we email you as it ships.'}\n </Alert>\n ) : returned === 'canceled' ? (\n <Alert severity=\"info\" onClose={() => setReturned(null)}>\n {'Checkout was canceled. Nothing was charged.'}\n </Alert>\n ) : null}\n {posPlan.locked && !arrived.length ? planPrompt(posPlanPrompt()) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Choose the readers and accessories you need. We set each reader up and ship your order to the address you enter at checkout. The delivery email says how to start taking payments with it.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gap: 2,\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(3, 1fr)' },\n }}\n >\n {catalog.offers.map((offer) => (\n <Card key={offer.sku} variant=\"outlined\">\n <CardContent>\n <Stack spacing={1} sx={{ height: '100%' }}>\n <Typography variant=\"subtitle2\">{offer.name}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ flex: 1 }}>\n {offer.use}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"body1\">{formatPosHardwareCents(offer.unitCents)}</Typography>\n <TextField\n select\n size=\"small\"\n label=\"Quantity\"\n value={quantities[offer.sku] ?? 0}\n onChange={(event) =>\n setQuantities((prev) => ({ ...prev, [offer.sku]: Number(event.target.value) }))\n }\n slotProps={{ htmlInput: { 'aria-label': `Quantity of ${offer.name}` } }}\n >\n {QUANTITIES.map((quantity) => (\n <MenuItem key={quantity} value={quantity}>\n {quantity}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n </Stack>\n </CardContent>\n </Card>\n ))}\n </Box>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'flex-start' } }}>\n <TextField\n select\n size=\"small\"\n label=\"Shipping\"\n value={shippingMethod}\n onChange={(event) => setShippingMethod(event.target.value as PosHardwareShippingMethod)}\n sx={{ minWidth: { sm: '40%' } }}\n >\n {catalog.shipping.map((option) => (\n <MenuItem key={option.method} value={option.method}>\n {`${option.label} · ${formatPosHardwareCents(option.cents)}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack spacing={0.5} sx={{ flex: 1 }} aria-label=\"Order summary\">\n <SummaryRow label=\"Items\" value={formatPosHardwareCents(subtotalCents)} />\n <SummaryRow label=\"Shipping\" value={shipping ? formatPosHardwareCents(shipping.cents) : '—'} />\n {catalog.automaticTax ? <SummaryRow label=\"Tax\" value=\"Calculated at checkout\" /> : null}\n <SummaryRow\n label={catalog.automaticTax ? 'Total before tax' : 'Total'}\n value={formatPosHardwareCents(subtotalCents + (shipping?.cents ?? 0))}\n strong\n />\n </Stack>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Ships to street addresses in the United States. P.O. boxes and military addresses are not accepted.'}\n </Typography>\n <Stack>\n <FormControlLabel\n control={<Checkbox checked={termsAccepted} onChange={(event) => setTermsAccepted(event.target.checked)} />}\n label={\n <Typography variant=\"body2\">\n {'I accept the '}\n <Link href={posHardwareTermsUrl()} target=\"_blank\" rel=\"noopener noreferrer\">\n {`hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS})`}\n </Link>\n {'.'}\n </Typography>\n }\n />\n <FormControlLabel\n control={<Checkbox checked={businessUse} onChange={(event) => setBusinessUse(event.target.checked)} />}\n label={<Typography variant=\"body2\">{'I am buying this hardware for use in my business.'}</Typography>}\n />\n </Stack>\n {ordersSection}\n </Stack>\n </CardDisplay>\n )\n}\nPosHardwareCard.displayName = 'PosHardwareCard'\n\nfunction SummaryRow(props: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" sx={{ justifyContent: 'space-between' }}>\n <Typography variant=\"body2\" color={props.strong ? 'text.primary' : 'text.secondary'}>\n {props.label}\n </Typography>\n <Typography variant=\"body2\" sx={props.strong ? { fontWeight: 'fontWeightMedium' } : undefined}>\n {props.value}\n </Typography>\n </Stack>\n )\n}\n\nexport default PosHardwareCard\n"],"names":["pluginDocsHelp","CardDisplay","BlockedControl","ListTable","useSnackbar","useUser","Alert","Box","Button","Card","CardContent","Checkbox","Chip","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","Link","MenuItem","Stack","TextField","Typography","useCallback","useEffect","useMemo","useState","formatPosHardwareCents","POS_HARDWARE_ANCHOR","POS_HARDWARE_MAX_PER_LINE","POS_HARDWARE_STATUS_LABELS","posPlanPrompt","POS_HARDWARE_TERMS_SECTIONS","posHardwareTermsUrl","EntitlementUpsell","useCommerceEntitlement","newAttemptKey","openPosHardwareCheckout","posHardwareCatalog","posHardwareCheckout","posHardwareOrders","posHardwareRequestReturn","PosHardwareRequestError","POS_HARDWARE_STATUS_COLOR","paid","ordered","received","shipped","delivered","registered","canceled","refunded","RETURN_LABELS","requested","declined","QUANTITIES","Array","from","length","_","index","placedOn","ms","Date","toLocaleDateString","month","day","year","BUY_KEY_REASON","TERMS_REASON","PosHardwareCard","hostId","canManagePos","canBuyHardware","data","user","enqueueSnackbar","catalog","setCatalog","orders","setOrders","quantities","setQuantities","shippingMethod","setShippingMethod","busy","setBusy","returned","setReturned","termsAccepted","setTermsAccepted","businessUse","setBusinessUse","uid","mayVisit","posPlan","active","then","answer","catch","available","loadOrders","returning","setReturning","returnReason","setReturnReason","requestReturn","id","trim","variant","persist","error","message","shipping","method","window","url","URL","location","href","outcome","searchParams","get","delete","history","replaceState","state","toString","document","hash","getElementById","scrollIntoView","block","lines","Object","entries","filter","quantity","map","sku","find","option","undefined","subtotalCents","reduce","sum","line","offers","offer","unitCents","basketKey","JSON","stringify","attemptKey","checkout","hardwareTerms","accepted","columns","field","headerName","minWidth","type","align","headerAlign","valueFormatter","value","flex","valueGetter","_value","row","name","join","status","renderCell","size","color","label","returnRequest","source","onClick","event","stopPropagation","tracking","number","target","rel","arrived","locked","order","planPrompt","text","planLabel","upgradeHref","ordersSection","spacing","rows","$id","loading","hideFooter","quickFilter","open","Boolean","onClose","maxWidth","fullWidth","sx","display","flexDirection","gap","onChange","multiline","minRows","disabled","header","subheader","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","reason","severity","gridTemplateColumns","xs","sm","md","height","use","direction","alignItems","justifyContent","select","prev","Number","slotProps","htmlInput","cents","aria-label","SummaryRow","automaticTax","strong","control","checked","displayName","props","fontWeight"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AAEtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,yBAAyB,EACzBC,0BAA0B,EAC1BC,aAAa,QAGR,8BAA0B;AACjC,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,oCAAgC;AACjG,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,kCAA8B;AACxF,SAASC,aAAa,QAAQ,mBAAe;AAC7C,SACEC,uBAAuB,EACvBC,kBAAkB,EAClBC,mBAAmB,EACnBC,iBAAiB,EACjBC,wBAAwB,EACxBC,uBAAuB,QAGlB,4BAAwB;AAG/B,OAAO,MAAMC,4BAGT;IACFC,MAAM;IACNC,SAAS;IACTC,UAAU;IACVC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,UAAU;IACVC,UAAU;AACZ,EAAC;AAED,kDAAkD,GAClD,MAAMC,gBAAwC;I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