@aglyn/plugins-commerce 1.10.0 → 1.12.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 (93) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/host-quotes-card.component.js +20 -11
  3. package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
  4. package/src/lib/components/console/invoice-send.component.d.ts +9 -2
  5. package/src/lib/components/console/invoice-send.component.js +58 -30
  6. package/src/lib/components/console/invoice-send.component.js.map +1 -1
  7. package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +84 -0
  8. package/src/lib/components/console/pay-link-readiness-notice.component.js +164 -0
  9. package/src/lib/components/console/pay-link-readiness-notice.component.js.map +1 -0
  10. package/src/lib/components/console/pos-kiosk/kiosk-menu.d.ts +10 -3
  11. package/src/lib/components/console/pos-kiosk/kiosk-menu.js +29 -8
  12. package/src/lib/components/console/pos-kiosk/kiosk-menu.js.map +1 -1
  13. package/src/lib/components/console/pos-kiosk/pos-kiosk-api.d.ts +2 -0
  14. package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js +7 -0
  15. package/src/lib/components/console/pos-kiosk/pos-kiosk-api.js.map +1 -1
  16. package/src/lib/components/console/pos-kiosk-page.component.d.ts +2 -0
  17. package/src/lib/components/console/pos-kiosk-page.component.js +54 -3
  18. package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -1
  19. package/src/lib/components/console/product-add-ons-fields.component.d.ts +0 -2
  20. package/src/lib/components/console/product-add-ons-fields.component.js +1 -6
  21. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  22. package/src/lib/components/console/quote-editor-dialog.component.d.ts +2 -0
  23. package/src/lib/components/console/quote-editor-dialog.component.js +35 -27
  24. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  25. package/src/lib/components/console/quote-pay-link.component.d.ts +3 -0
  26. package/src/lib/components/console/quote-pay-link.component.js +9 -0
  27. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  28. package/src/lib/components/console/quote-send.component.d.ts +3 -0
  29. package/src/lib/components/console/quote-send.component.js +9 -0
  30. package/src/lib/components/console/quote-send.component.js.map +1 -1
  31. package/src/lib/components/product-detail.js +1 -1
  32. package/src/lib/components/product-detail.js.map +1 -1
  33. package/src/lib/components/product-grid.js +5 -3
  34. package/src/lib/components/product-grid.js.map +1 -1
  35. package/src/lib/components/product-reviews.js +17 -12
  36. package/src/lib/components/product-reviews.js.map +1 -1
  37. package/src/lib/components/quote-page-body.js +5 -3
  38. package/src/lib/components/quote-page-body.js.map +1 -1
  39. package/src/lib/components/related-products.js +2 -1
  40. package/src/lib/components/related-products.js.map +1 -1
  41. package/src/lib/model/commerce-invoices.d.ts +45 -5
  42. package/src/lib/model/commerce-invoices.js +46 -9
  43. package/src/lib/model/commerce-invoices.js.map +1 -1
  44. package/src/lib/model/commerce-kiosk-search.d.ts +22 -0
  45. package/src/lib/model/commerce-kiosk-search.js +32 -0
  46. package/src/lib/model/commerce-kiosk-search.js.map +1 -0
  47. package/src/lib/model/commerce-pos-kiosk.d.ts +7 -1
  48. package/src/lib/model/commerce-pos-kiosk.js +1 -1
  49. package/src/lib/model/commerce-pos-kiosk.js.map +1 -1
  50. package/src/lib/model/commerce-quote-pay.d.ts +110 -6
  51. package/src/lib/model/commerce-quote-pay.js +182 -23
  52. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  53. package/src/lib/model/product-modifiers.d.ts +4 -0
  54. package/src/lib/model/product-modifiers.js +5 -0
  55. package/src/lib/model/product-modifiers.js.map +1 -1
  56. package/src/lib/server/billing-webhook.js +4 -1
  57. package/src/lib/server/billing-webhook.js.map +1 -1
  58. package/src/lib/server/commerce-pdf.js +2 -1
  59. package/src/lib/server/commerce-pdf.js.map +1 -1
  60. package/src/lib/server/invoice-email.js +2 -1
  61. package/src/lib/server/invoice-email.js.map +1 -1
  62. package/src/lib/server/order-invoice-send.js +1 -1
  63. package/src/lib/server/order-invoice-send.js.map +1 -1
  64. package/src/lib/server/order-status.d.ts +5 -1
  65. package/src/lib/server/order-status.js +19 -5
  66. package/src/lib/server/order-status.js.map +1 -1
  67. package/src/lib/server/pos-kiosk.js +70 -15
  68. package/src/lib/server/pos-kiosk.js.map +1 -1
  69. package/src/lib/server/quote-email.js +2 -1
  70. package/src/lib/server/quote-email.js.map +1 -1
  71. package/src/lib/server/quote-pay.d.ts +39 -0
  72. package/src/lib/server/quote-pay.js +103 -43
  73. package/src/lib/server/quote-pay.js.map +1 -1
  74. package/src/lib/server/quote-proofs.js +20 -11
  75. package/src/lib/server/quote-proofs.js.map +1 -1
  76. package/src/lib/server/site-page-enricher.js +5 -1
  77. package/src/lib/server/site-page-enricher.js.map +1 -1
  78. package/src/lib/testing/fake-firestore.js +34 -5
  79. package/src/lib/testing/fake-firestore.js.map +1 -1
  80. package/src/lib/transfer/product-register-cells.d.ts +75 -0
  81. package/src/lib/transfer/product-register-cells.js +487 -0
  82. package/src/lib/transfer/product-register-cells.js.map +1 -0
  83. package/src/lib/transfer/product-transfer.d.ts +12 -0
  84. package/src/lib/transfer/product-transfer.js +174 -10
  85. package/src/lib/transfer/product-transfer.js.map +1 -1
  86. package/src/lib/transfer/products.server.js +24 -9
  87. package/src/lib/transfer/products.server.js.map +1 -1
  88. package/src/lib/utils/invoice-email-content.d.ts +3 -1
  89. package/src/lib/utils/invoice-email-content.js +1 -1
  90. package/src/lib/utils/invoice-email-content.js.map +1 -1
  91. package/src/lib/utils/quote-email-content.d.ts +3 -1
  92. package/src/lib/utils/quote-email-content.js +3 -3
  93. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
19
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
+ import * as CommerceModel from "../../model/index.js";
21
+ import { AppLink } from "@aglyn/shared-ui-jsx/components/app-link";
22
+ import { PrerequisiteNotice } from "@aglyn/shared-ui-jsx/components/prerequisite-notice.component";
23
+ import { firestoreDocPhase, useFirestore, useFirestoreDoc, useMerchantPayments, useStoreSettingsHref } from "@aglyn/tenant-feature-instance";
24
+ import { AlertTitle, Stack } from "@mui/material";
25
+ import { doc } from "firebase/firestore";
26
+ /**
27
+ * Whether customers can pay an order's pay link, for the console's notice
28
+ * (AGL-4162): the workspace owner's payment account (`useMerchantPayments`,
29
+ * the client's copy of the check the page and Pay make) and the store's
30
+ * sales tax choice, read live. Without a site nothing is read and nothing is
31
+ * answered, so a form can hold its reads until it opens.
32
+ */ export function usePayLinkReadiness(hostId, order) {
33
+ const firestore = useFirestore();
34
+ const payments = useMerchantPayments(hostId);
35
+ const taxesHref = useStoreSettingsHref(hostId, 'taxes');
36
+ const read = useFirestoreDoc(()=>hostId ? doc(firestore, 'hosts', hostId, 'settings', 'store') : null, [
37
+ firestore,
38
+ hostId
39
+ ]);
40
+ const phase = firestoreDocPhase(read);
41
+ const store = phase === 'ready' ? CommerceModel.payLinkStoreOf(read.data) : phase === 'missing' ? CommerceModel.payLinkStoreOf(null) : undefined;
42
+ const gaps = hostId ? CommerceModel.payLinkGaps({
43
+ order,
44
+ paymentsReady: payments.settled ? payments.ready : null,
45
+ store
46
+ }) : null;
47
+ return {
48
+ gaps,
49
+ store,
50
+ storeLoading: !hostId || phase === 'loading',
51
+ paymentsReason: payments.reason,
52
+ paymentsHref: payments.href,
53
+ taxesHref
54
+ };
55
+ }
56
+ /** The notice's first line: `Customers can’t pay this quote online yet.` */ export function payLinkNoticeTitle(noun) {
57
+ return `Customers can’t pay this ${noun} online yet.`;
58
+ }
59
+ /** What the notice says about one gap, and the button that fixes it where a page does. */ export function payLinkGapLine(gap, input) {
60
+ switch(gap){
61
+ case 'payments':
62
+ var _input_paymentsReason;
63
+ return {
64
+ text: (_input_paymentsReason = input.paymentsReason) != null ? _input_paymentsReason : 'Connect a payment account to take card payments.',
65
+ action: 'Open Payments',
66
+ href: input.paymentsHref
67
+ };
68
+ case 'tax-undecided':
69
+ return {
70
+ text: 'Choose how this store handles sales tax.',
71
+ action: 'Open Taxes',
72
+ href: input.taxesHref
73
+ };
74
+ case 'tax-save':
75
+ return {
76
+ text: `${input.noun === 'quote' ? 'Save this quote' : 'Save the quote'} again to apply the store’s sales tax setting.`,
77
+ action: null,
78
+ href: null
79
+ };
80
+ }
81
+ }
82
+ /**
83
+ * "Customers can't pay this quote online yet." (AGL-4162), naming each setup
84
+ * step a customer's Pay waits on, with a button to the page that fixes it.
85
+ * Drawn only once both answers are in, and only when something is missing.
86
+ * The notice holds nothing back itself: the quote can still be sent and its
87
+ * link copied, for a business that takes the payment another way.
88
+ */ export function PayLinkReadinessNotice(props) {
89
+ var _readiness_gaps;
90
+ const { readiness, noun, sx } = props;
91
+ if (!((_readiness_gaps = readiness.gaps) == null ? void 0 : _readiness_gaps.length)) return null;
92
+ return /*#__PURE__*/ _jsxs(PrerequisiteNotice, {
93
+ severity: "warning",
94
+ sx: sx,
95
+ children: [
96
+ /*#__PURE__*/ _jsx(AlertTitle, {
97
+ children: payLinkNoticeTitle(noun)
98
+ }),
99
+ /*#__PURE__*/ _jsx(Stack, {
100
+ component: "ul",
101
+ spacing: 1,
102
+ sx: {
103
+ m: 0,
104
+ p: 0,
105
+ listStyle: 'none'
106
+ },
107
+ children: readiness.gaps.map((gap)=>{
108
+ const line = payLinkGapLine(gap, _extends({}, readiness, {
109
+ noun
110
+ }));
111
+ return /*#__PURE__*/ _jsxs(Stack, {
112
+ component: "li",
113
+ direction: {
114
+ xs: 'column',
115
+ sm: 'row'
116
+ },
117
+ spacing: 1,
118
+ sx: {
119
+ alignItems: {
120
+ xs: 'flex-start',
121
+ sm: 'center'
122
+ },
123
+ justifyContent: 'space-between'
124
+ },
125
+ children: [
126
+ /*#__PURE__*/ _jsx("span", {
127
+ children: line.text
128
+ }),
129
+ line.action && line.href ? /*#__PURE__*/ _jsx(AppLink, {
130
+ componentVariant: "button",
131
+ color: "inherit",
132
+ size: "small",
133
+ href: line.href,
134
+ sx: {
135
+ flexShrink: 0
136
+ },
137
+ children: line.action
138
+ }) : null
139
+ ]
140
+ }, gap);
141
+ })
142
+ })
143
+ ]
144
+ });
145
+ }
146
+ PayLinkReadinessNotice.displayName = 'PayLinkReadinessNotice';
147
+ /**
148
+ * The notice with its own reads ({@link usePayLinkReadiness}), for a surface
149
+ * that mounts it only while it is on screen: a form's body, or a section
150
+ * drawn only for an unpaid quote.
151
+ */ export function PayLinkReadinessNoticeFor(props) {
152
+ const { hostId, order } = props, rest = _object_without_properties_loose(props, [
153
+ "hostId",
154
+ "order"
155
+ ]);
156
+ const readiness = usePayLinkReadiness(hostId, order);
157
+ return /*#__PURE__*/ _jsx(PayLinkReadinessNotice, _extends({
158
+ readiness: readiness
159
+ }, rest));
160
+ }
161
+ PayLinkReadinessNoticeFor.displayName = 'PayLinkReadinessNoticeFor';
162
+ export default PayLinkReadinessNotice;
163
+
164
+ //# sourceMappingURL=pay-link-readiness-notice.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/pay-link-readiness-notice.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\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { AppLink } from '@aglyn/shared-ui-jsx/components/app-link'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport {\n firestoreDocPhase,\n useFirestore,\n useFirestoreDoc,\n useMerchantPayments,\n useStoreSettingsHref,\n} from '@aglyn/tenant-feature-instance'\nimport { AlertTitle, Stack, type AlertProps } from '@mui/material'\nimport { doc } from 'firebase/firestore'\n\n/** An order the pay link may charge: a quote or a draft order; null for a quote not saved yet. */\nexport type PayLinkNoticeOrder =\n | (Pick<CommerceModel.HostOrder, 'status' | 'channel'> & Partial<Pick<CommerceModel.HostOrder, 'quote'>>)\n | null\n\n/** Where a pay link stands with the business's setup, as the console reads it. */\nexport interface PayLinkReadiness {\n /** What the notice names (`payLinkGaps`); null while anything is still being read. */\n gaps: CommerceModel.PayLinkGap[] | null\n /** The store's sales tax choice; undefined while it is read, or when it can't be. */\n store: CommerceModel.PayLinkStore | undefined\n /** The store's settings are still being read. */\n storeLoading: boolean\n /** Why the workspace can't take card payments, in `useMerchantPayments`'s words. */\n paymentsReason: string | null\n /** The site's Payments settings page. */\n paymentsHref: string | null\n /** The site's Taxes settings page. */\n taxesHref: string | null\n}\n\n/**\n * Whether customers can pay an order's pay link, for the console's notice\n * (AGL-4162): the workspace owner's payment account (`useMerchantPayments`,\n * the client's copy of the check the page and Pay make) and the store's\n * sales tax choice, read live. Without a site nothing is read and nothing is\n * answered, so a form can hold its reads until it opens.\n */\nexport function usePayLinkReadiness(hostId: string | undefined, order: PayLinkNoticeOrder): PayLinkReadiness {\n const firestore = useFirestore()\n const payments = useMerchantPayments(hostId)\n const taxesHref = useStoreSettingsHref(hostId, 'taxes')\n const read = useFirestoreDoc<{ tax?: unknown }>(\n () => (hostId ? doc(firestore, 'hosts', hostId, 'settings', 'store') : null),\n [firestore, hostId],\n )\n const phase = firestoreDocPhase(read)\n const store =\n phase === 'ready'\n ? CommerceModel.payLinkStoreOf(read.data)\n : phase === 'missing'\n ? CommerceModel.payLinkStoreOf(null)\n : undefined\n const gaps = hostId\n ? CommerceModel.payLinkGaps({ order, paymentsReady: payments.settled ? payments.ready : null, store })\n : null\n return {\n gaps,\n store,\n storeLoading: !hostId || phase === 'loading',\n paymentsReason: payments.reason,\n paymentsHref: payments.href,\n taxesHref,\n }\n}\n\n/** The notice's first line: `Customers can’t pay this quote online yet.` */\nexport function payLinkNoticeTitle(noun: 'quote' | 'invoice'): string {\n return `Customers can’t pay this ${noun} online yet.`\n}\n\n/** What the notice says about one gap, and the button that fixes it where a page does. */\nexport function payLinkGapLine(\n gap: CommerceModel.PayLinkGap,\n input: Pick<PayLinkReadiness, 'paymentsReason' | 'paymentsHref' | 'taxesHref'> & { noun: 'quote' | 'invoice' },\n): { text: string; action: string | null; href: string | null } {\n switch (gap) {\n case 'payments':\n return {\n text: input.paymentsReason ?? 'Connect a payment account to take card payments.',\n action: 'Open Payments',\n href: input.paymentsHref,\n }\n case 'tax-undecided':\n return { text: 'Choose how this store handles sales tax.', action: 'Open Taxes', href: input.taxesHref }\n case 'tax-save':\n return {\n text: `${input.noun === 'quote' ? 'Save this quote' : 'Save the quote'} again to apply the store’s sales tax setting.`,\n action: null,\n href: null,\n }\n }\n}\n\nexport interface PayLinkReadinessNoticeProps {\n readiness: PayLinkReadiness\n /** What the customer's page calls it: a quote, or an invoice in the Send invoice form. */\n noun: 'quote' | 'invoice'\n sx?: AlertProps['sx']\n}\n\n/**\n * \"Customers can't pay this quote online yet.\" (AGL-4162), naming each setup\n * step a customer's Pay waits on, with a button to the page that fixes it.\n * Drawn only once both answers are in, and only when something is missing.\n * The notice holds nothing back itself: the quote can still be sent and its\n * link copied, for a business that takes the payment another way.\n */\nexport function PayLinkReadinessNotice(props: PayLinkReadinessNoticeProps) {\n const { readiness, noun, sx } = props\n if (!readiness.gaps?.length) return null\n return (\n <PrerequisiteNotice severity=\"warning\" sx={sx}>\n <AlertTitle>{payLinkNoticeTitle(noun)}</AlertTitle>\n <Stack component=\"ul\" spacing={1} sx={{ m: 0, p: 0, listStyle: 'none' }}>\n {readiness.gaps.map((gap) => {\n const line = payLinkGapLine(gap, { ...readiness, noun })\n return (\n <Stack\n key={gap}\n component=\"li\"\n direction={{ xs: 'column', sm: 'row' }}\n spacing={1}\n sx={{ alignItems: { xs: 'flex-start', sm: 'center' }, justifyContent: 'space-between' }}\n >\n <span>{line.text}</span>\n {line.action && line.href ? (\n <AppLink componentVariant=\"button\" color=\"inherit\" size=\"small\" href={line.href} sx={{ flexShrink: 0 }}>\n {line.action}\n </AppLink>\n ) : null}\n </Stack>\n )\n })}\n </Stack>\n </PrerequisiteNotice>\n )\n}\nPayLinkReadinessNotice.displayName = 'PayLinkReadinessNotice'\n\nexport interface PayLinkReadinessNoticeForProps extends Omit<PayLinkReadinessNoticeProps, 'readiness'> {\n hostId: string\n order: PayLinkNoticeOrder\n}\n\n/**\n * The notice with its own reads ({@link usePayLinkReadiness}), for a surface\n * that mounts it only while it is on screen: a form's body, or a section\n * drawn only for an unpaid quote.\n */\nexport function PayLinkReadinessNoticeFor(props: PayLinkReadinessNoticeForProps) {\n const { hostId, order, ...rest } = props\n const readiness = usePayLinkReadiness(hostId, order)\n return <PayLinkReadinessNotice readiness={readiness} {...rest} />\n}\nPayLinkReadinessNoticeFor.displayName = 'PayLinkReadinessNoticeFor'\n\nexport default PayLinkReadinessNotice\n"],"names":["CommerceModel","AppLink","PrerequisiteNotice","firestoreDocPhase","useFirestore","useFirestoreDoc","useMerchantPayments","useStoreSettingsHref","AlertTitle","Stack","doc","usePayLinkReadiness","hostId","order","firestore","payments","taxesHref","read","phase","store","payLinkStoreOf","data","undefined","gaps","payLinkGaps","paymentsReady","settled","ready","storeLoading","paymentsReason","reason","paymentsHref","href","payLinkNoticeTitle","noun","payLinkGapLine","gap","input","text","action","PayLinkReadinessNotice","props","readiness","sx","length","severity","component","spacing","m","p","listStyle","map","line","direction","xs","sm","alignItems","justifyContent","span","componentVariant","color","size","flexShrink","displayName","PayLinkReadinessNoticeFor","rest"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,OAAO,QAAQ,2CAA0C;AAClE,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SACEC,iBAAiB,EACjBC,YAAY,EACZC,eAAe,EACfC,mBAAmB,EACnBC,oBAAoB,QACf,iCAAgC;AACvC,SAASC,UAAU,EAAEC,KAAK,QAAyB,gBAAe;AAClE,SAASC,GAAG,QAAQ,qBAAoB;AAuBxC;;;;;;CAMC,GACD,OAAO,SAASC,oBAAoBC,MAA0B,EAAEC,KAAyB;IACvF,MAAMC,YAAYV;IAClB,MAAMW,WAAWT,oBAAoBM;IACrC,MAAMI,YAAYT,qBAAqBK,QAAQ;IAC/C,MAAMK,OAAOZ,gBACX,IAAOO,SAASF,IAAII,WAAW,SAASF,QAAQ,YAAY,WAAW,MACvE;QAACE;QAAWF;KAAO;IAErB,MAAMM,QAAQf,kBAAkBc;IAChC,MAAME,QACJD,UAAU,UACNlB,cAAcoB,cAAc,CAACH,KAAKI,IAAI,IACtCH,UAAU,YACRlB,cAAcoB,cAAc,CAAC,QAC7BE;IACR,MAAMC,OAAOX,SACTZ,cAAcwB,WAAW,CAAC;QAAEX;QAAOY,eAAeV,SAASW,OAAO,GAAGX,SAASY,KAAK,GAAG;QAAMR;IAAM,KAClG;IACJ,OAAO;QACLI;QACAJ;QACAS,cAAc,CAAChB,UAAUM,UAAU;QACnCW,gBAAgBd,SAASe,MAAM;QAC/BC,cAAchB,SAASiB,IAAI;QAC3BhB;IACF;AACF;AAEA,0EAA0E,GAC1E,OAAO,SAASiB,mBAAmBC,IAAyB;IAC1D,OAAO,CAAC,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AM,IAAIa,KAAKpB,IAAI,iBACvB,KAAC/B;gCAAQ0D,kBAAiB;gCAASC,OAAM;gCAAUC,MAAK;gCAAQ7B,MAAMoB,KAAKpB,IAAI;gCAAEW,IAAI;oCAAEmB,YAAY;gCAAE;0CAClGV,KAAKb,MAAM;iCAEZ;;uBAXCH;gBAcX;;;;AAIR;AACAI,uBAAuBuB,WAAW,GAAG;AAOrC;;;;CAIC,GACD,OAAO,SAASC,0BAA0BvB,KAAqC;IAC7E,MAAM,EAAE7B,MAAM,EAAEC,KAAK,EAAW,GAAG4B,OAATwB,wCAASxB;;;;IACnC,MAAMC,YAAY/B,oBAAoBC,QAAQC;IAC9C,qBAAO,KAAC2B;QAAuBE,WAAWA;OAAeuB;AAC3D;AACAD,0BAA0BD,WAAW,GAAG;AAExC,eAAevB,uBAAsB"}
@@ -13,12 +13,19 @@ export declare function kioskFromCents(product: CommerceModel.PosKioskProduct):
13
13
  export declare function kioskProductSoldOut(product: CommerceModel.PosKioskProduct): boolean;
14
14
  /**
15
15
  * The menu (AGL-3623): category chips, the product tiles, and the cart bar.
16
- * A category chip asks the server for that category; nothing is filtered
17
- * out of a list already loaded.
16
+ * A category chip asks the server for that category, and a word typed in the
17
+ * search asks the server for that word across the whole catalog. The search
18
+ * shows only when the catalog is longer than the menu can list.
18
19
  */
19
- export declare function KioskMenu({ catalog, loading, categoryId, onCategory, onProduct, lines, currency, onReview, onQuantity, cartOpen, onCartOpen, busy, }: {
20
+ export declare function KioskMenu({ catalog, products, loading, search, onSearch, searching, categoryId, onCategory, onProduct, lines, currency, onReview, onQuantity, cartOpen, onCartOpen, busy, }: {
20
21
  catalog: CommerceModel.PosKioskCatalog | null;
22
+ /** What to list: the catalog, or what answers the word typed. */
23
+ products: CommerceModel.PosKioskProduct[];
21
24
  loading: boolean;
25
+ search: string;
26
+ onSearch: (search: string) => void;
27
+ /** The server hasn't answered the word typed yet. */
28
+ searching: boolean;
22
29
  categoryId: string | null;
23
30
  onCategory: (categoryId: string | null) => void;
24
31
  onProduct: (product: CommerceModel.PosKioskProduct) => void;
@@ -27,6 +27,7 @@ import Divider from "@mui/material/Divider";
27
27
  import Drawer from "@mui/material/Drawer";
28
28
  import IconButton from "@mui/material/IconButton";
29
29
  import Stack from "@mui/material/Stack";
30
+ import TextField from "@mui/material/TextField";
30
31
  import Typography from "@mui/material/Typography";
31
32
  import * as CommerceModel from "../../../model/index.js";
32
33
  import { displayMoney } from "../pos-display/pos-display-api.js";
@@ -40,14 +41,14 @@ export function kioskProductSoldOut(product) {
40
41
  }
41
42
  /**
42
43
  * The menu (AGL-3623): category chips, the product tiles, and the cart bar.
43
- * A category chip asks the server for that category; nothing is filtered
44
- * out of a list already loaded.
45
- */ export function KioskMenu({ catalog, loading, categoryId, onCategory, onProduct, lines, currency, onReview, onQuantity, cartOpen, onCartOpen, busy }) {
46
- var _ref, _ref1;
44
+ * A category chip asks the server for that category, and a word typed in the
45
+ * search asks the server for that word across the whole catalog. The search
46
+ * shows only when the catalog is longer than the menu can list.
47
+ */ export function KioskMenu({ catalog, products, loading, search, onSearch, searching, categoryId, onCategory, onProduct, lines, currency, onReview, onQuantity, cartOpen, onCartOpen, busy }) {
48
+ var _ref;
47
49
  const count = lines.reduce((sum, line)=>sum + line.quantity, 0);
48
50
  const estimate = lines.reduce((sum, line)=>sum + line.unitCents * line.quantity, 0);
49
51
  const money = (cents)=>displayMoney(cents, currency);
50
- const products = (_ref = catalog == null ? void 0 : catalog.products) != null ? _ref : [];
51
52
  return /*#__PURE__*/ _jsxs(Box, {
52
53
  sx: {
53
54
  minHeight: '100dvh',
@@ -55,6 +56,26 @@ export function kioskProductSoldOut(product) {
55
56
  flexDirection: 'column'
56
57
  },
57
58
  children: [
59
+ search || (catalog == null ? void 0 : catalog.truncated) ? /*#__PURE__*/ _jsx(Box, {
60
+ sx: {
61
+ px: 2,
62
+ pt: 2
63
+ },
64
+ children: /*#__PURE__*/ _jsx(TextField, {
65
+ fullWidth: true,
66
+ type: "search",
67
+ label: "Search the menu",
68
+ value: search,
69
+ onChange: (event)=>onSearch(event.target.value),
70
+ slotProps: {
71
+ htmlInput: {
72
+ autoComplete: 'off',
73
+ spellCheck: false,
74
+ maxLength: 120
75
+ }
76
+ }
77
+ })
78
+ }) : null,
58
79
  /*#__PURE__*/ _jsxs(Box, {
59
80
  component: "nav",
60
81
  "aria-label": "Categories",
@@ -78,7 +99,7 @@ export function kioskProductSoldOut(product) {
78
99
  px: 1
79
100
  }, theme.typography.subtitle1)
80
101
  }),
81
- ((_ref1 = catalog == null ? void 0 : catalog.categories) != null ? _ref1 : []).map((category)=>/*#__PURE__*/ _jsx(Chip, {
102
+ ((_ref = catalog == null ? void 0 : catalog.categories) != null ? _ref : []).map((category)=>/*#__PURE__*/ _jsx(Chip, {
82
103
  label: category.name,
83
104
  color: categoryId === category.id ? 'primary' : 'default',
84
105
  variant: categoryId === category.id ? 'filled' : 'outlined',
@@ -97,7 +118,7 @@ export function kioskProductSoldOut(product) {
97
118
  p: 2,
98
119
  pb: 14
99
120
  },
100
- children: loading ? /*#__PURE__*/ _jsx(Box, {
121
+ children: loading || searching && products.length === 0 ? /*#__PURE__*/ _jsx(Box, {
101
122
  sx: {
102
123
  display: 'grid',
103
124
  placeItems: 'center',
@@ -113,7 +134,7 @@ export function kioskProductSoldOut(product) {
113
134
  textAlign: 'center',
114
135
  py: 8
115
136
  },
116
- children: 'Nothing here yet. Try another category.'
137
+ children: search.trim() ? 'Nothing on the menu matches that.' : 'Nothing here yet. Try another category.'
117
138
  }) : /*#__PURE__*/ _jsx(Box, {
118
139
  sx: (theme)=>({
119
140
  display: 'grid',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-kiosk/kiosk-menu.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 Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport Chip from '@mui/material/Chip'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport Divider from '@mui/material/Divider'\nimport Drawer from '@mui/material/Drawer'\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport * as CommerceModel from '../../../model'\nimport { displayMoney } from '../pos-display/pos-display-api'\n\n/** A cart line on the kiosk: what is sent, plus what the screen shows. */\nexport interface KioskCartLine extends CommerceModel.PosKioskLine {\n /** Merges the same item with the same choices. */\n key: string\n name: string\n label?: string\n /** The catalog's price per unit, modifiers included: an estimate until checkout. */\n unitCents: number\n}\n\n/** The lowest price a product sells at, for its tile. */\nexport function kioskFromCents(product: CommerceModel.PosKioskProduct): number {\n return product.variants.reduce(\n (low, variant) => Math.min(low, variant.priceCents),\n product.variants[0]?.priceCents ?? 0,\n )\n}\n\nexport function kioskProductSoldOut(product: CommerceModel.PosKioskProduct): boolean {\n return product.variants.length > 0 && product.variants.every((variant) => variant.soldOut)\n}\n\n/**\n * The menu (AGL-3623): category chips, the product tiles, and the cart bar.\n * A category chip asks the server for that category; nothing is filtered\n * out of a list already loaded.\n */\nexport function KioskMenu({\n catalog,\n loading,\n categoryId,\n onCategory,\n onProduct,\n lines,\n currency,\n onReview,\n onQuantity,\n cartOpen,\n onCartOpen,\n busy,\n}: {\n catalog: CommerceModel.PosKioskCatalog | null\n loading: boolean\n categoryId: string | null\n onCategory: (categoryId: string | null) => void\n onProduct: (product: CommerceModel.PosKioskProduct) => void\n lines: KioskCartLine[]\n currency: string\n onReview: () => void\n onQuantity: (key: string, quantity: number) => void\n cartOpen: boolean\n onCartOpen: (open: boolean) => void\n busy: boolean\n}) {\n const count = lines.reduce((sum, line) => sum + line.quantity, 0)\n const estimate = lines.reduce((sum, line) => sum + line.unitCents * line.quantity, 0)\n const money = (cents: number) => displayMoney(cents, currency)\n const products = catalog?.products ?? []\n return (\n <Box sx={{ minHeight: '100dvh', display: 'flex', flexDirection: 'column' }}>\n <Box\n component=\"nav\"\n aria-label=\"Categories\"\n sx={{ display: 'flex', gap: 1, overflowX: 'auto', p: 2, borderBottom: 1, borderColor: 'divider' }}\n >\n <Chip\n label=\"All\"\n color={categoryId ? 'default' : 'primary'}\n variant={categoryId ? 'outlined' : 'filled'}\n aria-pressed={!categoryId}\n onClick={() => onCategory(null)}\n sx={(theme) => ({ minHeight: theme.spacing(6), px: 1, ...theme.typography.subtitle1 })}\n />\n {(catalog?.categories ?? []).map((category) => (\n <Chip\n key={category.id}\n label={category.name}\n color={categoryId === category.id ? 'primary' : 'default'}\n variant={categoryId === category.id ? 'filled' : 'outlined'}\n aria-pressed={categoryId === category.id}\n onClick={() => onCategory(category.id)}\n sx={(theme) => ({ minHeight: theme.spacing(6), px: 1, ...theme.typography.subtitle1 })}\n />\n ))}\n </Box>\n <Box sx={{ flex: 1, p: 2, pb: 14 }}>\n {loading ? (\n <Box sx={{ display: 'grid', placeItems: 'center', py: 8 }}>\n <CircularProgress aria-label=\"Loading the menu\" />\n </Box>\n ) : products.length === 0 ? (\n <Typography variant=\"h6\" color=\"text.secondary\" sx={{ textAlign: 'center', py: 8 }}>\n {'Nothing here yet. Try another category.'}\n </Typography>\n ) : (\n <Box\n sx={(theme) => ({\n display: 'grid',\n gap: 2,\n gridTemplateColumns: `repeat(auto-fill, minmax(${theme.spacing(22)}, 1fr))`,\n })}\n >\n {products.map((product) => {\n const soldOut = kioskProductSoldOut(product)\n const several = product.variants.length > 1\n return (\n <Card key={product.id} variant=\"outlined\">\n <CardActionArea\n disabled={soldOut}\n onClick={() => onProduct(product)}\n sx={{ height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'stretch' }}\n >\n {product.imageUrl ? (\n <Box\n component=\"img\"\n src={product.imageUrl}\n alt=\"\"\n loading=\"lazy\"\n sx={{ width: '100%', aspectRatio: '4 / 3', objectFit: 'cover', display: 'block' }}\n />\n ) : null}\n <CardContent sx={{ flex: 1 }}>\n <Typography variant=\"subtitle1\" component=\"h2\">\n {product.name}\n </Typography>\n <Typography variant=\"body2\" color={soldOut ? 'text.disabled' : 'text.secondary'}>\n {soldOut\n ? 'Sold out'\n : `${several ? 'From ' : ''}${money(kioskFromCents(product))}`}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n )\n })}\n </Box>\n )}\n </Box>\n {count > 0 ? (\n <Box\n sx={(theme) => ({\n position: 'fixed',\n left: 0,\n right: 0,\n bottom: 0,\n p: 2,\n bgcolor: 'background.paper',\n borderTop: 1,\n borderColor: 'divider',\n display: 'flex',\n gap: 2,\n zIndex: theme.zIndex.appBar,\n })}\n >\n <Button\n variant=\"outlined\"\n size=\"large\"\n onClick={() => onCartOpen(true)}\n sx={(theme) => ({ minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {`Cart (${count})`}\n </Button>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy}\n onClick={onReview}\n sx={(theme) => ({ flex: 1, minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {busy ? 'Getting your total…' : `Checkout · ${money(estimate)}`}\n </Button>\n </Box>\n ) : null}\n <Drawer\n anchor=\"right\"\n open={cartOpen}\n onClose={() => onCartOpen(false)}\n slotProps={{ paper: { sx: (theme) => ({ width: `min(100vw, ${theme.spacing(60)})`, p: 2 }) } }}\n >\n <Stack spacing={2} sx={{ height: '100%' }}>\n <Typography variant=\"h5\" component=\"h2\">\n {'Your order'}\n </Typography>\n <Stack spacing={1} divider={<Divider flexItem />} sx={{ flex: 1, overflowY: 'auto' }}>\n {lines.map((line) => (\n <Stack key={line.key} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"subtitle1\">{line.name}</Typography>\n {line.label ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {line.label}\n </Typography>\n ) : null}\n <Typography variant=\"body2\">{money(line.unitCents * line.quantity)}</Typography>\n </Box>\n <IconButton\n aria-label={`One fewer ${line.name}`}\n onClick={() => onQuantity(line.key, line.quantity - 1)}\n sx={(theme) => ({ width: theme.spacing(7), height: theme.spacing(7), border: 1, borderColor: 'divider' })}\n >\n {'−'}\n </IconButton>\n <Typography variant=\"h6\" component=\"span\" aria-label=\"Quantity\" sx={{ minWidth: (theme) => theme.spacing(4), textAlign: 'center' }}>\n {line.quantity}\n </Typography>\n <IconButton\n aria-label={`One more ${line.name}`}\n disabled={line.quantity >= CommerceModel.POS_KIOSK_MAX_QUANTITY}\n onClick={() => onQuantity(line.key, line.quantity + 1)}\n sx={(theme) => ({ width: theme.spacing(7), height: theme.spacing(7), border: 1, borderColor: 'divider' })}\n >\n {'+'}\n </IconButton>\n </Stack>\n ))}\n {lines.length === 0 ? (\n <Typography color=\"text.secondary\">{'Your cart is empty.'}</Typography>\n ) : null}\n </Stack>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tax is added at checkout.'}\n </Typography>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy || lines.length === 0}\n onClick={() => {\n onCartOpen(false)\n onReview()\n }}\n sx={(theme) => ({ minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {`Checkout · ${money(estimate)}`}\n </Button>\n <Button onClick={() => onCartOpen(false)} sx={(theme) => ({ minHeight: theme.spacing(7) })}>\n {'Keep ordering'}\n </Button>\n </Stack>\n </Drawer>\n </Box>\n )\n}\n"],"names":["Box","Button","Card","CardActionArea","CardContent","Chip","CircularProgress","Divider","Drawer","IconButton","Stack","Typography","CommerceModel","displayMoney","kioskFromCents","product","variants","reduce","low","variant","Math","min","priceCents","kioskProductSoldOut","length","every","soldOut","KioskMenu","catalog","loading","categoryId","onCategory","onProduct","lines","currency","onReview","onQuantity","cartOpen","onCartOpen","busy","count","sum","line","quantity","estimate","unitCents","money","cents","products","sx","minHeight","display","flexDirection","component","aria-label","gap","overflowX","p","borderBottom","borderColor","label","color","aria-pressed","onClick","theme","spacing","px","typography","subtitle1","categories","map","category","name","id","flex","pb","placeItems","py","textAlign","gridTemplateColumns","several","disabled","height","alignItems","imageUrl","src","alt","width","aspectRatio","objectFit","position","left","right","bottom","bgcolor","borderTop","zIndex","appBar","size","h6","anchor","open","onClose","slotProps","paper","divider","flexItem","overflowY","direction","minWidth","key","border","POS_KIOSK_MAX_QUANTITY"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,OAAOA,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,YAAYC,mBAAmB,0BAAgB;AAC/C,SAASC,YAAY,QAAQ,oCAAgC;AAY7D,uDAAuD,GACvD,OAAO,SAASC,eAAeC,OAAsC;;QAGjEA;IAFF,OAAOA,QAAQC,QAAQ,CAACC,MAAM,CAC5B,CAACC,KAAKC,UAAYC,KAAKC,GAAG,CAACH,KAAKC,QAAQG,UAAU,YAClDP,qBAAAA,QAAQC,QAAQ,CAAC,EAAE,qBAAnBD,mBAAqBO,UAAU,mBAAI;AAEvC;AAEA,OAAO,SAASC,oBAAoBR,OAAsC;IACxE,OAAOA,QAAQC,QAAQ,CAACQ,M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oDAAE4D,UAAU,CAAC7C,QAAUA,MAAMC,OAAO,CAAC;oDAAIa,WAAW;gDAAS;0DAC9HpC,KAAKC,QAAQ;;0DAEhB,KAAClC;gDACC6C,cAAY,CAAC,SAAS,EAAEZ,KAAK8B,IAAI,EAAE;gDACnCS,UAAUvC,KAAKC,QAAQ,IAAI/B,cAAcoG,sBAAsB;gDAC/DjD,SAAS,IAAM3B,WAAWM,KAAKoE,GAAG,EAAEpE,KAAKC,QAAQ,GAAG;gDACpDM,IAAI,CAACe,QAAW,CAAA;wDAAEuB,OAAOvB,MAAMC,OAAO,CAAC;wDAAIiB,QAAQlB,MAAMC,OAAO,CAAC;wDAAI8C,QAAQ;wDAAGpD,aAAa;oDAAU,CAAA;0DAEtG;;;uCA1BOjB,KAAKoE,GAAG;gCA8BrB7E,MAAMT,MAAM,KAAK,kBAChB,KAACb;oCAAWkD,OAAM;8CAAkB;qCAClC;;;sCAEN,KAAClD;4BAAWQ,SAAQ;4BAAQ0C,OAAM;sCAC/B;;sCAEH,KAAC5D;4BACCkB,SAAQ;4BACR+E,MAAK;4BACLjB,UAAU1C,QAAQN,MAAMT,MAAM,KAAK;4BACnCuC,SAAS;gCACPzB,WAAW;gCACXH;4BACF;4BACAc,IAAI,CAACe,QAAW;oCAAEd,WAAWc,MAAMC,OAAO,CAAC;mCAAOD,MAAMG,UAAU,CAACgC,EAAE;sCAEpE,CAAC,WAAW,EAAErD,MAAMF,WAAW;;sCAElC,KAAC3C;4BAAO8D,SAAS,IAAMzB,WAAW;4BAAQW,IAAI,CAACe,QAAW,CAAA;oCAAEd,WAAWc,MAAMC,OAAO,CAAC;gCAAG,CAAA;sCACrF;;;;;;;AAMb"}
1
+ {"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-kiosk/kiosk-menu.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 Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport CardActionArea from '@mui/material/CardActionArea'\nimport CardContent from '@mui/material/CardContent'\nimport Chip from '@mui/material/Chip'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport Divider from '@mui/material/Divider'\nimport Drawer from '@mui/material/Drawer'\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport * as CommerceModel from '../../../model'\nimport { displayMoney } from '../pos-display/pos-display-api'\n\n/** A cart line on the kiosk: what is sent, plus what the screen shows. */\nexport interface KioskCartLine extends CommerceModel.PosKioskLine {\n /** Merges the same item with the same choices. */\n key: string\n name: string\n label?: string\n /** The catalog's price per unit, modifiers included: an estimate until checkout. */\n unitCents: number\n}\n\n/** The lowest price a product sells at, for its tile. */\nexport function kioskFromCents(product: CommerceModel.PosKioskProduct): number {\n return product.variants.reduce(\n (low, variant) => Math.min(low, variant.priceCents),\n product.variants[0]?.priceCents ?? 0,\n )\n}\n\nexport function kioskProductSoldOut(product: CommerceModel.PosKioskProduct): boolean {\n return product.variants.length > 0 && product.variants.every((variant) => variant.soldOut)\n}\n\n/**\n * The menu (AGL-3623): category chips, the product tiles, and the cart bar.\n * A category chip asks the server for that category, and a word typed in the\n * search asks the server for that word across the whole catalog. The search\n * shows only when the catalog is longer than the menu can list.\n */\nexport function KioskMenu({\n catalog,\n products,\n loading,\n search,\n onSearch,\n searching,\n categoryId,\n onCategory,\n onProduct,\n lines,\n currency,\n onReview,\n onQuantity,\n cartOpen,\n onCartOpen,\n busy,\n}: {\n catalog: CommerceModel.PosKioskCatalog | null\n /** What to list: the catalog, or what answers the word typed. */\n products: CommerceModel.PosKioskProduct[]\n loading: boolean\n search: string\n onSearch: (search: string) => void\n /** The server hasn't answered the word typed yet. */\n searching: boolean\n categoryId: string | null\n onCategory: (categoryId: string | null) => void\n onProduct: (product: CommerceModel.PosKioskProduct) => void\n lines: KioskCartLine[]\n currency: string\n onReview: () => void\n onQuantity: (key: string, quantity: number) => void\n cartOpen: boolean\n onCartOpen: (open: boolean) => void\n busy: boolean\n}) {\n const count = lines.reduce((sum, line) => sum + line.quantity, 0)\n const estimate = lines.reduce((sum, line) => sum + line.unitCents * line.quantity, 0)\n const money = (cents: number) => displayMoney(cents, currency)\n return (\n <Box sx={{ minHeight: '100dvh', display: 'flex', flexDirection: 'column' }}>\n {search || catalog?.truncated ? (\n <Box sx={{ px: 2, pt: 2 }}>\n <TextField\n fullWidth\n type=\"search\"\n label=\"Search the menu\"\n value={search}\n onChange={(event) => onSearch(event.target.value)}\n slotProps={{ htmlInput: { autoComplete: 'off', spellCheck: false, maxLength: 120 } }}\n />\n </Box>\n ) : null}\n <Box\n component=\"nav\"\n aria-label=\"Categories\"\n sx={{ display: 'flex', gap: 1, overflowX: 'auto', p: 2, borderBottom: 1, borderColor: 'divider' }}\n >\n <Chip\n label=\"All\"\n color={categoryId ? 'default' : 'primary'}\n variant={categoryId ? 'outlined' : 'filled'}\n aria-pressed={!categoryId}\n onClick={() => onCategory(null)}\n sx={(theme) => ({ minHeight: theme.spacing(6), px: 1, ...theme.typography.subtitle1 })}\n />\n {(catalog?.categories ?? []).map((category) => (\n <Chip\n key={category.id}\n label={category.name}\n color={categoryId === category.id ? 'primary' : 'default'}\n variant={categoryId === category.id ? 'filled' : 'outlined'}\n aria-pressed={categoryId === category.id}\n onClick={() => onCategory(category.id)}\n sx={(theme) => ({ minHeight: theme.spacing(6), px: 1, ...theme.typography.subtitle1 })}\n />\n ))}\n </Box>\n <Box sx={{ flex: 1, p: 2, pb: 14 }}>\n {loading || (searching && products.length === 0) ? (\n <Box sx={{ display: 'grid', placeItems: 'center', py: 8 }}>\n <CircularProgress aria-label=\"Loading the menu\" />\n </Box>\n ) : products.length === 0 ? (\n <Typography variant=\"h6\" color=\"text.secondary\" sx={{ textAlign: 'center', py: 8 }}>\n {search.trim() ? 'Nothing on the menu matches that.' : 'Nothing here yet. Try another category.'}\n </Typography>\n ) : (\n <Box\n sx={(theme) => ({\n display: 'grid',\n gap: 2,\n gridTemplateColumns: `repeat(auto-fill, minmax(${theme.spacing(22)}, 1fr))`,\n })}\n >\n {products.map((product) => {\n const soldOut = kioskProductSoldOut(product)\n const several = product.variants.length > 1\n return (\n <Card key={product.id} variant=\"outlined\">\n <CardActionArea\n disabled={soldOut}\n onClick={() => onProduct(product)}\n sx={{ height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'stretch' }}\n >\n {product.imageUrl ? (\n <Box\n component=\"img\"\n src={product.imageUrl}\n alt=\"\"\n loading=\"lazy\"\n sx={{ width: '100%', aspectRatio: '4 / 3', objectFit: 'cover', display: 'block' }}\n />\n ) : null}\n <CardContent sx={{ flex: 1 }}>\n <Typography variant=\"subtitle1\" component=\"h2\">\n {product.name}\n </Typography>\n <Typography variant=\"body2\" color={soldOut ? 'text.disabled' : 'text.secondary'}>\n {soldOut\n ? 'Sold out'\n : `${several ? 'From ' : ''}${money(kioskFromCents(product))}`}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n )\n })}\n </Box>\n )}\n </Box>\n {count > 0 ? (\n <Box\n sx={(theme) => ({\n position: 'fixed',\n left: 0,\n right: 0,\n bottom: 0,\n p: 2,\n bgcolor: 'background.paper',\n borderTop: 1,\n borderColor: 'divider',\n display: 'flex',\n gap: 2,\n zIndex: theme.zIndex.appBar,\n })}\n >\n <Button\n variant=\"outlined\"\n size=\"large\"\n onClick={() => onCartOpen(true)}\n sx={(theme) => ({ minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {`Cart (${count})`}\n </Button>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy}\n onClick={onReview}\n sx={(theme) => ({ flex: 1, minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {busy ? 'Getting your total…' : `Checkout · ${money(estimate)}`}\n </Button>\n </Box>\n ) : null}\n <Drawer\n anchor=\"right\"\n open={cartOpen}\n onClose={() => onCartOpen(false)}\n slotProps={{ paper: { sx: (theme) => ({ width: `min(100vw, ${theme.spacing(60)})`, p: 2 }) } }}\n >\n <Stack spacing={2} sx={{ height: '100%' }}>\n <Typography variant=\"h5\" component=\"h2\">\n {'Your order'}\n </Typography>\n <Stack spacing={1} divider={<Divider flexItem />} sx={{ flex: 1, overflowY: 'auto' }}>\n {lines.map((line) => (\n <Stack key={line.key} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"subtitle1\">{line.name}</Typography>\n {line.label ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {line.label}\n </Typography>\n ) : null}\n <Typography variant=\"body2\">{money(line.unitCents * line.quantity)}</Typography>\n </Box>\n <IconButton\n aria-label={`One fewer ${line.name}`}\n onClick={() => onQuantity(line.key, line.quantity - 1)}\n sx={(theme) => ({ width: theme.spacing(7), height: theme.spacing(7), border: 1, borderColor: 'divider' })}\n >\n {'−'}\n </IconButton>\n <Typography variant=\"h6\" component=\"span\" aria-label=\"Quantity\" sx={{ minWidth: (theme) => theme.spacing(4), textAlign: 'center' }}>\n {line.quantity}\n </Typography>\n <IconButton\n aria-label={`One more ${line.name}`}\n disabled={line.quantity >= CommerceModel.POS_KIOSK_MAX_QUANTITY}\n onClick={() => onQuantity(line.key, line.quantity + 1)}\n sx={(theme) => ({ width: theme.spacing(7), height: theme.spacing(7), border: 1, borderColor: 'divider' })}\n >\n {'+'}\n </IconButton>\n </Stack>\n ))}\n {lines.length === 0 ? (\n <Typography color=\"text.secondary\">{'Your cart is empty.'}</Typography>\n ) : null}\n </Stack>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Tax is added at checkout.'}\n </Typography>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy || lines.length === 0}\n onClick={() => {\n onCartOpen(false)\n onReview()\n }}\n sx={(theme) => ({ minHeight: theme.spacing(8), ...theme.typography.h6 })}\n >\n {`Checkout · ${money(estimate)}`}\n </Button>\n <Button onClick={() => onCartOpen(false)} sx={(theme) => ({ minHeight: theme.spacing(7) })}>\n {'Keep ordering'}\n </Button>\n </Stack>\n </Drawer>\n </Box>\n )\n}\n"],"names":["Box","Button","Card","CardActionArea","CardContent","Chip","CircularProgress","Divider","Drawer","IconButton","Stack","TextField","Typography","CommerceModel","displayMoney","kioskFromCents","product","variants","reduce","low","variant","Math","min","priceCents","kioskProductSoldOut","length","every","soldOut","KioskMenu","catalog","products","loading","search","onSearch","searching","categoryId","onCategory","onProduct","lines","currency","onReview","onQuantity","cartOpen","onCartOpen","busy","count","sum","line","quantity","estimate","unitCents","money","cents","sx","minHeight","display","flexDirection","truncated","px","pt","fullWidth","type","label","value","onChange","event","target","slotProps","htmlInput","autoComplete","spellCheck","maxLength","component","aria-label","gap","overflowX","p","borderBottom","borderColor","color","aria-pressed","onClick","theme","spacing","typography","subtitle1","categories","map","category","name","id","flex","pb","placeItems","py","textAlign","trim","gridTemplateColumns","several","disabled","height","alignItems","imageUrl","src","alt","width","aspectRatio","objectFit","position","left","right","bottom","bgcolor","borderTop","zIndex","appBar","size","h6","anchor","open","onClose","paper","divider","flexItem","overflowY","direction","minWidth","key","border","POS_KIOSK_MAX_QUANTITY"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,OAAOA,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,oBAAoB,+BAA8B;AACzD,OAAOC,iBAAiB,4BAA2B;AACnD,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,sBAAsB,iCAAgC;AAC7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S,IAAMxC,WAAWM,KAAKgF,GAAG,EAAEhF,KAAKC,QAAQ,GAAG;gDACpDK,IAAI,CAAC6B,QAAW,CAAA;wDAAEuB,OAAOvB,MAAMC,OAAO,CAAC;wDAAIiB,QAAQlB,MAAMC,OAAO,CAAC;wDAAI6C,QAAQ;wDAAGlD,aAAa;oDAAU,CAAA;0DAEtG;;;uCA1BO/B,KAAKgF,GAAG;gCA8BrBzF,MAAMb,MAAM,KAAK,kBAChB,KAACb;oCAAWmE,OAAM;8CAAkB;qCAClC;;;sCAEN,KAACnE;4BAAWQ,SAAQ;4BAAQ2D,OAAM;sCAC/B;;sCAEH,KAAC9E;4BACCmB,SAAQ;4BACRgG,MAAK;4BACLjB,UAAUvD,QAAQN,MAAMb,MAAM,KAAK;4BACnCwD,SAAS;gCACPtC,WAAW;gCACXH;4BACF;4BACAa,IAAI,CAAC6B,QAAW;oCAAE5B,WAAW4B,MAAMC,OAAO,CAAC;mCAAOD,MAAME,UAAU,CAACiC,EAAE;sCAEpE,CAAC,WAAW,EAAElE,MAAMF,WAAW;;sCAElC,KAAChD;4BAAOgF,SAAS,IAAMtC,WAAW;4BAAQU,IAAI,CAAC6B,QAAW,CAAA;oCAAE5B,WAAW4B,MAAMC,OAAO,CAAC;gCAAG,CAAA;sCACrF;;;;;;;AAMb"}
@@ -52,6 +52,8 @@ export declare function clearKioskCustomerStorage(): void;
52
52
  export declare const kioskApi: {
53
53
  context: (token: string) => Promise<PosKioskResult<CommerceModel.PosKioskContext>>;
54
54
  catalog: (token: string, categoryId: string | null) => Promise<PosKioskResult<CommerceModel.PosKioskCatalog>>;
55
+ /** A word typed at the menu, asked of the whole catalog. */
56
+ search: (token: string, search: string) => Promise<PosKioskResult<CommerceModel.PosKioskCatalog>>;
55
57
  sale: (token: string, orderId: string) => Promise<PosKioskResult<{
56
58
  sale: CommerceModel.PosKioskSale;
57
59
  }>>;
@@ -127,6 +127,13 @@ export const kioskApi = {
127
127
  categoryId
128
128
  } : {})
129
129
  }),
130
+ /** A word typed at the menu, asked of the whole catalog. */ search: (token, search)=>call(token, {
131
+ method: 'GET',
132
+ query: {
133
+ action: 'catalog',
134
+ search
135
+ }
136
+ }),
130
137
  sale: (token, orderId)=>call(token, {
131
138
  method: 'GET',
132
139
  query: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-kiosk/pos-kiosk-api.ts"],"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 type * as CommerceModel from '../../../model'\nimport { POS_DISPLAY_TOKEN_HEADER } from '../pos-display/pos-display-api'\n\n/**\n * The self-service kiosk's half of `/api/commerce/pos-kiosk` (AGL-3623).\n *\n * Every call carries the kiosk's device token — the customer display's\n * header, because a kiosk is paired exactly like one — and never a staff\n * session. 401 means the kiosk was unpaired (or its register removed), which\n * the page reads as \"pair again\".\n */\nexport const POS_KIOSK_ENDPOINT = '/api/commerce/pos-kiosk'\n\n/**\n * Where the kiosk's token lives on the device: the ONE thing it stores.\n * Nothing a customer chooses or types is ever written to storage.\n */\nexport const POS_KIOSK_TOKEN_KEY = 'aglyn.posKioskToken'\n\nexport interface PosKioskResult<T> {\n ok: boolean\n /** The HTTP status, or 0 when the request never landed. */\n status: number\n value?: T\n error?: string\n}\n\nexport function readKioskToken(): string | null {\n try {\n return window.localStorage.getItem(POS_KIOSK_TOKEN_KEY) || null\n } catch {\n return null\n }\n}\n\nexport function storeKioskToken(token: string | null): void {\n try {\n if (token) window.localStorage.setItem(POS_KIOSK_TOKEN_KEY, token)\n else window.localStorage.removeItem(POS_KIOSK_TOKEN_KEY)\n } catch {\n // Storage blocked: the kiosk works until it reloads, then asks for a code.\n }\n}\n\n/** Every key the kiosk could own on this origin starts with this. */\nexport const POS_KIOSK_STORAGE_PREFIX = 'aglyn.posKiosk'\n\n/**\n * The idle reset's storage sweep: every kiosk key in local and session\n * storage but the device token. The kiosk keeps a customer's cart, email and\n * phone in memory only, so on a working kiosk this finds nothing; it is the\n * guarantee that nothing a customer chose outlives their turn should a later\n * change ever persist some of it. Other pages' keys on the console origin\n * are not the kiosk's to touch.\n */\nexport function clearKioskCustomerStorage(): void {\n for (const pick of [() => window.localStorage, () => window.sessionStorage]) {\n try {\n const storage = pick()\n const keys: string[] = []\n for (let index = 0; index < storage.length; index++) {\n const key = storage.key(index)\n if (key && key.startsWith(POS_KIOSK_STORAGE_PREFIX) && key !== POS_KIOSK_TOKEN_KEY) keys.push(key)\n }\n for (const key of keys) storage.removeItem(key)\n } catch {\n // Blocked storage holds nothing to clear.\n }\n }\n}\n\nasync function call<T>(\n token: string,\n init: { method: 'GET'; query: Record<string, string> } | { method: 'POST'; body: Record<string, unknown>; attemptKey?: string },\n): Promise<PosKioskResult<T>> {\n const headers: Record<string, string> = { [POS_DISPLAY_TOKEN_HEADER]: token }\n if (init.method === 'POST') {\n headers['Content-Type'] = 'application/json'\n if (init.attemptKey) headers['Idempotency-Key'] = init.attemptKey\n }\n try {\n const response = await fetch(\n init.method === 'GET'\n ? `${POS_KIOSK_ENDPOINT}?${new URLSearchParams(init.query).toString()}`\n : POS_KIOSK_ENDPOINT,\n {\n method: init.method,\n headers,\n cache: 'no-store',\n ...(init.method === 'POST' ? { body: JSON.stringify(init.body) } : {}),\n },\n )\n const payload = (await response.json().catch(() => null)) as Record<string, unknown> | null\n if (!response.ok) {\n return {\n ok: false,\n status: response.status,\n error: String(payload?.['error'] ?? 'Something went wrong. Try again.'),\n }\n }\n return { ok: true, status: response.status, value: (payload ?? {}) as T }\n } catch {\n return { ok: false, status: 0, error: 'No connection. Try again.' }\n }\n}\n\nconst post = <T>(token: string, body: Record<string, unknown>, attemptKey?: string) =>\n call<T>(token, { method: 'POST', body, ...(attemptKey ? { attemptKey } : {}) })\n\nexport const kioskApi = {\n context: (token: string) => call<CommerceModel.PosKioskContext>(token, { method: 'GET', query: { action: 'context' } }),\n catalog: (token: string, categoryId: string | null) =>\n call<CommerceModel.PosKioskCatalog>(token, {\n method: 'GET',\n query: { action: 'catalog', ...(categoryId ? { categoryId } : {}) },\n }),\n sale: (token: string, orderId: string) =>\n call<{ sale: CommerceModel.PosKioskSale }>(token, { method: 'GET', query: { action: 'sale', orderId } }),\n checkout: (token: string, lines: CommerceModel.PosKioskLine[], attemptKey: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'checkout', lines }, attemptKey),\n pay: (\n token: string,\n input: {\n orderId: string\n method: 'reader' | 'tap'\n tipChoice: 'percent' | 'custom' | 'none'\n tipPercent?: number\n tipCents?: number\n },\n attemptKey: string,\n ) =>\n post<{ sale: CommerceModel.PosKioskSale; paymentId?: string; clientSecret?: string; paymentIntentId?: string }>(\n token,\n { action: 'pay', ...input },\n attemptKey,\n ),\n paymentStatus: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'payment-status', orderId, paymentId }),\n cancelPayment: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'cancel-payment', orderId, paymentId }),\n simulate: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'simulate', orderId, paymentId }),\n counter: (token: string, orderId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'counter', orderId }),\n receipt: (\n token: string,\n input: { orderId: string; channel: CommerceModel.PosReceiptChannel; to?: string; marketingOptIn?: boolean },\n ) => post<{ ok: true }>(token, { action: 'receipt', ...input }),\n abandon: (token: string, orderId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'abandon', orderId }),\n unlock: (token: string, pin: string) => post<{ unlock: string; expiresAtMs: number }>(token, { action: 'unlock', pin }),\n settings: (token: string, unlock: string) =>\n post<PosKioskSettingsView>(token, { action: 'settings', unlock }),\n setReader: (token: string, unlock: string, readerId: string) =>\n post<PosKioskSettingsView>(token, { action: 'set-reader', unlock, readerId }),\n exit: (token: string, unlock: string) => post<{ ok: true }>(token, { action: 'exit', unlock }),\n}\n\nexport interface PosKioskSettingsView {\n readers: Array<{ id: string; label: string; status: string }>\n readerId: string | null\n label: string\n}\n"],"names":["POS_DISPLAY_TOKEN_HEADER","POS_KIOSK_ENDPOINT","POS_KIOSK_TOKEN_KEY","readKioskToken","window","localStorage","getItem","storeKioskToken","token","setItem","removeItem","POS_KIOSK_STORAGE_PREFIX","clearKioskCustomerStorage","pick","sessionStorage","storage","keys","index","length","key","startsWith","push","call","init","headers","method","attemptKey","response","fetch","URLSearchParams","query","toString","cache","body","JSON","stringify","payload","json","catch","ok","status","error","String","value","post","kioskApi","context","action","catalog","categoryId","sale","orderId","checkout","lines","pay","input","paymentStatus","paymentId","cancelPayment","simulate","counter","receipt","abandon","unlock","pin","settings","setReader","readerId","exit"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,wBAAwB,QAAQ,oCAAgC;AAEzE;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,0BAAyB;AAE3D;;;CAGC,GACD,OAAO,MAAMC,sBAAsB,sBAAqB;AAUxD,OAAO,SAASC;IACd,IAAI;QACF,OAAOC,OAAOC,YAAY,CAACC,OAAO,CAACJ,wBAAwB;IAC7D,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,SAASK,gBAAgBC,KAAoB;IAClD,IAAI;QACF,IAAIA,OAAOJ,OAAOC,YAAY,CAACI,OAAO,CAACP,qBAAqBM;aACvDJ,OAAOC,YAAY,CAACK,UAAU,CAACR;IACtC,EAAE,eAAM;IACN,2EAA2E;IAC7E;AACF;AAEA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AA2CpC,OAAO;YAAEuC,QAAQ;YAAYI;YAASM;QAAU;IAC7FG,SAAS,CAACpD,OAAe2C,UACvBP,KAA2CpC,OAAO;YAAEuC,QAAQ;YAAWI;QAAQ;IACjFU,SAAS,CACPrD,OACA+C,QACGX,KAAmBpC,OAAO;YAAEuC,QAAQ;WAAcQ;IACvDO,SAAS,CAACtD,OAAe2C,UACvBP,KAA2CpC,OAAO;YAAEuC,QAAQ;YAAWI;QAAQ;IACjFY,QAAQ,CAACvD,OAAewD,MAAgBpB,KAA8CpC,OAAO;YAAEuC,QAAQ;YAAUiB;QAAI;IACrHC,UAAU,CAACzD,OAAeuD,SACxBnB,KAA2BpC,OAAO;YAAEuC,QAAQ;YAAYgB;QAAO;IACjEG,WAAW,CAAC1D,OAAeuD,QAAgBI,WACzCvB,KAA2BpC,OAAO;YAAEuC,QAAQ;YAAcgB;YAAQI;QAAS;IAC7EC,MAAM,CAAC5D,OAAeuD,SAAmBnB,KAAmBpC,OAAO;YAAEuC,QAAQ;YAAQgB;QAAO;AAC9F,EAAC"}
1
+ {"version":3,"sources":["../../../../../../../../../libs/plugins/commerce/src/lib/components/console/pos-kiosk/pos-kiosk-api.ts"],"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 type * as CommerceModel from '../../../model'\nimport { POS_DISPLAY_TOKEN_HEADER } from '../pos-display/pos-display-api'\n\n/**\n * The self-service kiosk's half of `/api/commerce/pos-kiosk` (AGL-3623).\n *\n * Every call carries the kiosk's device token — the customer display's\n * header, because a kiosk is paired exactly like one — and never a staff\n * session. 401 means the kiosk was unpaired (or its register removed), which\n * the page reads as \"pair again\".\n */\nexport const POS_KIOSK_ENDPOINT = '/api/commerce/pos-kiosk'\n\n/**\n * Where the kiosk's token lives on the device: the ONE thing it stores.\n * Nothing a customer chooses or types is ever written to storage.\n */\nexport const POS_KIOSK_TOKEN_KEY = 'aglyn.posKioskToken'\n\nexport interface PosKioskResult<T> {\n ok: boolean\n /** The HTTP status, or 0 when the request never landed. */\n status: number\n value?: T\n error?: string\n}\n\nexport function readKioskToken(): string | null {\n try {\n return window.localStorage.getItem(POS_KIOSK_TOKEN_KEY) || null\n } catch {\n return null\n }\n}\n\nexport function storeKioskToken(token: string | null): void {\n try {\n if (token) window.localStorage.setItem(POS_KIOSK_TOKEN_KEY, token)\n else window.localStorage.removeItem(POS_KIOSK_TOKEN_KEY)\n } catch {\n // Storage blocked: the kiosk works until it reloads, then asks for a code.\n }\n}\n\n/** Every key the kiosk could own on this origin starts with this. */\nexport const POS_KIOSK_STORAGE_PREFIX = 'aglyn.posKiosk'\n\n/**\n * The idle reset's storage sweep: every kiosk key in local and session\n * storage but the device token. The kiosk keeps a customer's cart, email and\n * phone in memory only, so on a working kiosk this finds nothing; it is the\n * guarantee that nothing a customer chose outlives their turn should a later\n * change ever persist some of it. Other pages' keys on the console origin\n * are not the kiosk's to touch.\n */\nexport function clearKioskCustomerStorage(): void {\n for (const pick of [() => window.localStorage, () => window.sessionStorage]) {\n try {\n const storage = pick()\n const keys: string[] = []\n for (let index = 0; index < storage.length; index++) {\n const key = storage.key(index)\n if (key && key.startsWith(POS_KIOSK_STORAGE_PREFIX) && key !== POS_KIOSK_TOKEN_KEY) keys.push(key)\n }\n for (const key of keys) storage.removeItem(key)\n } catch {\n // Blocked storage holds nothing to clear.\n }\n }\n}\n\nasync function call<T>(\n token: string,\n init: { method: 'GET'; query: Record<string, string> } | { method: 'POST'; body: Record<string, unknown>; attemptKey?: string },\n): Promise<PosKioskResult<T>> {\n const headers: Record<string, string> = { [POS_DISPLAY_TOKEN_HEADER]: token }\n if (init.method === 'POST') {\n headers['Content-Type'] = 'application/json'\n if (init.attemptKey) headers['Idempotency-Key'] = init.attemptKey\n }\n try {\n const response = await fetch(\n init.method === 'GET'\n ? `${POS_KIOSK_ENDPOINT}?${new URLSearchParams(init.query).toString()}`\n : POS_KIOSK_ENDPOINT,\n {\n method: init.method,\n headers,\n cache: 'no-store',\n ...(init.method === 'POST' ? { body: JSON.stringify(init.body) } : {}),\n },\n )\n const payload = (await response.json().catch(() => null)) as Record<string, unknown> | null\n if (!response.ok) {\n return {\n ok: false,\n status: response.status,\n error: String(payload?.['error'] ?? 'Something went wrong. Try again.'),\n }\n }\n return { ok: true, status: response.status, value: (payload ?? {}) as T }\n } catch {\n return { ok: false, status: 0, error: 'No connection. Try again.' }\n }\n}\n\nconst post = <T>(token: string, body: Record<string, unknown>, attemptKey?: string) =>\n call<T>(token, { method: 'POST', body, ...(attemptKey ? { attemptKey } : {}) })\n\nexport const kioskApi = {\n context: (token: string) => call<CommerceModel.PosKioskContext>(token, { method: 'GET', query: { action: 'context' } }),\n catalog: (token: string, categoryId: string | null) =>\n call<CommerceModel.PosKioskCatalog>(token, {\n method: 'GET',\n query: { action: 'catalog', ...(categoryId ? { categoryId } : {}) },\n }),\n /** A word typed at the menu, asked of the whole catalog. */\n search: (token: string, search: string) =>\n call<CommerceModel.PosKioskCatalog>(token, { method: 'GET', query: { action: 'catalog', search } }),\n sale: (token: string, orderId: string) =>\n call<{ sale: CommerceModel.PosKioskSale }>(token, { method: 'GET', query: { action: 'sale', orderId } }),\n checkout: (token: string, lines: CommerceModel.PosKioskLine[], attemptKey: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'checkout', lines }, attemptKey),\n pay: (\n token: string,\n input: {\n orderId: string\n method: 'reader' | 'tap'\n tipChoice: 'percent' | 'custom' | 'none'\n tipPercent?: number\n tipCents?: number\n },\n attemptKey: string,\n ) =>\n post<{ sale: CommerceModel.PosKioskSale; paymentId?: string; clientSecret?: string; paymentIntentId?: string }>(\n token,\n { action: 'pay', ...input },\n attemptKey,\n ),\n paymentStatus: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'payment-status', orderId, paymentId }),\n cancelPayment: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'cancel-payment', orderId, paymentId }),\n simulate: (token: string, orderId: string, paymentId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'simulate', orderId, paymentId }),\n counter: (token: string, orderId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'counter', orderId }),\n receipt: (\n token: string,\n input: { orderId: string; channel: CommerceModel.PosReceiptChannel; to?: string; marketingOptIn?: boolean },\n ) => post<{ ok: true }>(token, { action: 'receipt', ...input }),\n abandon: (token: string, orderId: string) =>\n post<{ sale: CommerceModel.PosKioskSale }>(token, { action: 'abandon', orderId }),\n unlock: (token: string, pin: string) => post<{ unlock: string; expiresAtMs: number }>(token, { action: 'unlock', pin }),\n settings: (token: string, unlock: string) =>\n post<PosKioskSettingsView>(token, { action: 'settings', unlock }),\n setReader: (token: string, unlock: string, readerId: string) =>\n post<PosKioskSettingsView>(token, { action: 'set-reader', unlock, readerId }),\n exit: (token: string, unlock: string) => post<{ ok: true }>(token, { action: 'exit', unlock }),\n}\n\nexport interface PosKioskSettingsView {\n readers: Array<{ id: string; label: string; status: string }>\n readerId: string | null\n label: string\n}\n"],"names":["POS_DISPLAY_TOKEN_HEADER","POS_KIOSK_ENDPOINT","POS_KIOSK_TOKEN_KEY","readKioskToken","window","localStorage","getItem","storeKioskToken","token","setItem","removeItem","POS_KIOSK_STORAGE_PREFIX","clearKioskCustomerStorage","pick","sessionStorage","storage","keys","index","length","key","startsWith","push","call","init","headers","method","attemptKey","response","fetch","URLSearchParams","query","toString","cache","body","JSON","stringify","payload","json","catch","ok","status","error","String","value","post","kioskApi","context","action","catalog","categoryId","search","sale","orderId","checkout","lines","pay","input","paymentStatus","paymentId","cancelPayment","simulate","counter","receipt","abandon","unlock","pin","settings","setReader","readerId","exit"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,wBAAwB,QAAQ,oCAAgC;AAEzE;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,0BAAyB;AAE3D;;;CAGC,GACD,OAAO,MAAMC,sBAAsB,sBAAqB;AAUxD,OAAO,SAASC;IACd,IAAI;QACF,OAAOC,OAAOC,YAAY,CAACC,OAAO,CAACJ,wBAAwB;IAC7D,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,SAASK,gBAAgBC,KAAoB;IAClD,IAAI;QACF,IAAIA,OAAOJ,OAAOC,YAAY,CAACI,OAAO,CAACP,qBAAqBM;aACvDJ,OAAOC,YAAY,CAACK,UAAU,CAACR;IACtC,EAAE,eAAM;IACN,2EAA2E;IAC7E;AACF;AAEA,mEAAmE,GACnE,OAAO,MAAMS,2BAA2B,iBAAgB;AAExD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,KAAK,MAAMC,QAAQ;QAAC,IAAMT,OAAOC,YAAY;QAAE,IAAMD,OAAOU,cAAc;KAAC,CAAE;QAC3E,IAAI;YACF,MAAMC,UAAUF;YAChB,MAAMG,OAAiB,EAAE;YACzB,IAAK,IAAIC,QAAQ,GAAGA,QAAQF,QAAQG,MAAM,EAAED,QAAS;gBACnD,MAAME,MAAMJ,QAAQI,GAAG,CAACF;gBACxB,IAAIE,OAAOA,IAAIC,UAAU,CAACT,6BAA6BQ,QAAQjB,qBAAqBc,KAAKK,IAAI,CAACF;YAChG;YACA,KAAK,MAAMA,OAAOH,KAAMD,QAAQL,UAAU,CAACS;QAC7C,EAAE,eAAM;QACN,0CAA0C;QAC5C;IACF;AACF;AAEA,eAAeG,KACbd,KAAa,EACbe,IAA+H;IAE/H,MAAMC,UAAkC;QAAE,CAACxB,yBAAyB,EAAEQ;IAAM;IAC5E,IAAIe,KAAKE,M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AAEuC,QAAQ;YAAciB;YAAQI;QAAS;IAC7EC,MAAM,CAAC7D,OAAewD,SAAmBpB,KAAmBpC,OAAO;YAAEuC,QAAQ;YAAQiB;QAAO;AAC9F,EAAC"}
@@ -4,6 +4,8 @@ import { type PosItemChoice } from './pos/pos-item-dialog.component';
4
4
  import { type KioskCartLine } from './pos-kiosk/kiosk-menu';
5
5
  /** How often the kiosk asks after a card payment in flight. */
6
6
  export declare const POS_KIOSK_PAYMENT_POLL_MS = 1500;
7
+ /** How long the typing rests before the word is asked of the catalog. */
8
+ export declare const POS_KIOSK_SEARCH_DEBOUNCE_MS = 400;
7
9
  /** A product as the register's item sheet takes it, from the kiosk's catalog. */
8
10
  export declare function kioskItemProduct(product: CommerceModel.PosKioskProduct): CommerceModel.HostProduct & {
9
11
  $id: string;
@@ -29,6 +29,7 @@ import DialogTitle from "@mui/material/DialogTitle";
29
29
  import Stack from "@mui/material/Stack";
30
30
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
31
31
  import * as CommerceModel from "../../model/index.js";
32
+ import { posKioskNameMatches } from "../../model/commerce-kiosk-search.js";
32
33
  import { newAttemptKey, posNativeBridge } from "./pos/pos-api.js";
33
34
  import { PosItemDialog, posItemNeedsChoice } from "./pos/pos-item-dialog.component.js";
34
35
  import { PosDisplayBrandMark, PosDisplayBrandScreen } from "./pos-display/brand-screen.js";
@@ -42,6 +43,7 @@ import { KioskStaffControl } from "./pos-kiosk/kiosk-staff.js";
42
43
  import { clearKioskCustomerStorage, kioskApi, readKioskToken, storeKioskToken } from "./pos-kiosk/pos-kiosk-api.js";
43
44
  import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
44
45
  /** How often the kiosk asks after a card payment in flight. */ export const POS_KIOSK_PAYMENT_POLL_MS = 1500;
46
+ /** How long the typing rests before the word is asked of the catalog. */ export const POS_KIOSK_SEARCH_DEBOUNCE_MS = 400;
45
47
  /** A product as the register's item sheet takes it, from the kiosk's catalog. */ export function kioskItemProduct(product) {
46
48
  return {
47
49
  $id: product.id,
@@ -104,6 +106,10 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
104
106
  const [catalog, setCatalog] = useState(null);
105
107
  const [catalogLoading, setCatalogLoading] = useState(false);
106
108
  const [categoryId, setCategoryId] = useState(null);
109
+ const [search, setSearch] = useState('');
110
+ // The server's answer to a word typed; `products: null` when it couldn't
111
+ // answer, which leaves the customer narrowing the menu already loaded.
112
+ const [found, setFound] = useState(null);
107
113
  const [phase, setPhase] = useState({
108
114
  kind: 'start'
109
115
  });
@@ -135,6 +141,7 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
135
141
  setToken(null);
136
142
  setContext(null);
137
143
  setCatalog(null);
144
+ setSearch('');
138
145
  setSale(null);
139
146
  setLines([]);
140
147
  setPhase({
@@ -179,8 +186,8 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
179
186
  if (!active) return;
180
187
  setCatalogLoading(false);
181
188
  if (lost(result.status)) return;
189
+ setOffline(result.status === 0);
182
190
  if (result.ok && result.value) setCatalog(result.value);
183
- else setOffline(result.status === 0);
184
191
  });
185
192
  return ()=>{
186
193
  active = false;
@@ -191,6 +198,42 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
191
198
  turn,
192
199
  lost
193
200
  ]);
201
+ // A word typed, once the typing rests, asked of the whole catalog.
202
+ const typed = search.trim();
203
+ useEffect(()=>{
204
+ if (!token || !typed) {
205
+ setFound(null);
206
+ return undefined;
207
+ }
208
+ let active = true;
209
+ const timer = setTimeout(()=>{
210
+ void kioskApi.search(token, typed).then((result)=>{
211
+ if (!active || lost(result.status)) return;
212
+ setOffline(result.status === 0);
213
+ setFound({
214
+ typed,
215
+ products: result.ok && result.value ? result.value.products : null
216
+ });
217
+ });
218
+ }, POS_KIOSK_SEARCH_DEBOUNCE_MS);
219
+ return ()=>{
220
+ active = false;
221
+ clearTimeout(timer);
222
+ };
223
+ }, [
224
+ token,
225
+ typed,
226
+ lost
227
+ ]);
228
+ const menuProducts = useMemo(()=>{
229
+ var _ref, _ref1;
230
+ const listed = (_ref = (_ref1 = typed ? found == null ? void 0 : found.products : null) != null ? _ref1 : catalog == null ? void 0 : catalog.products) != null ? _ref : [];
231
+ return typed ? listed.filter((product)=>posKioskNameMatches(product.name, typed)) : listed;
232
+ }, [
233
+ typed,
234
+ found,
235
+ catalog
236
+ ]);
194
237
  const currency = (_ref = (_ref1 = context == null ? void 0 : context.currency) != null ? _ref1 : catalog == null ? void 0 : catalog.currency) != null ? _ref : 'usd';
195
238
  const money = useCallback((cents)=>displayMoney(cents, currency), [
196
239
  currency
@@ -210,6 +253,7 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
210
253
  setCartOpen(false);
211
254
  setNotice(null);
212
255
  setCategoryId(null);
256
+ setSearch('');
213
257
  checkoutKey.current = null;
214
258
  payKey.current = null;
215
259
  clearKioskCustomerStorage();
@@ -591,9 +635,16 @@ import { useKioskIdle } from "./pos-kiosk/use-kiosk-idle.js";
591
635
  }) : null,
592
636
  /*#__PURE__*/ _jsx(KioskMenu, {
593
637
  catalog: catalog,
638
+ products: menuProducts,
594
639
  loading: catalogLoading && !catalog,
595
- categoryId: categoryId,
596
- onCategory: setCategoryId,
640
+ search: search,
641
+ onSearch: setSearch,
642
+ searching: Boolean(typed) && (found == null ? void 0 : found.typed) !== typed,
643
+ categoryId: typed ? null : categoryId,
644
+ onCategory: (next)=>{
645
+ setSearch('');
646
+ setCategoryId(next);
647
+ },
597
648
  onProduct: tapProduct,
598
649
  lines: lines,
599
650
  currency: currency,