@alfadocs/ui-kit 1.10.1 → 1.11.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 (74) hide show
  1. package/dist/_chunks/booking-CBHKdsZl.js +2906 -0
  2. package/dist/_chunks/{contact-profile-card-CE9OJKcl.js → contact-profile-card-BMIBr5s9.js} +104 -125
  3. package/dist/_chunks/format-price-DNqXPa_q.js +61 -0
  4. package/dist/_chunks/{practice-results-BEsAdW-B.js → practice-results-D7ygCj_W.js} +333 -291
  5. package/dist/_chunks/{stepper-accordion-BeVMZPuG.js → stepper-accordion-DmVykr5F.js} +91 -88
  6. package/dist/agent-catalog.json +11 -4
  7. package/dist/agent-i18n/en.json +3 -2
  8. package/dist/components/_shared/format-price.d.ts +21 -0
  9. package/dist/components/_shared/index.d.ts +1 -0
  10. package/dist/components/_shared/stepper.d.ts +28 -2
  11. package/dist/components/booking/booking-types.d.ts +15 -2
  12. package/dist/components/booking/index.js +1 -1
  13. package/dist/components/contact-profile-card/index.js +1 -1
  14. package/dist/components/practice-results/index.js +1 -1
  15. package/dist/components/practice-results/practice-results.d.ts +18 -0
  16. package/dist/components/stepper-accordion/index.js +1 -1
  17. package/dist/i18n/locales/ar.d.ts +4 -0
  18. package/dist/i18n/locales/ar.js +5 -1
  19. package/dist/i18n/locales/de.d.ts +5 -1
  20. package/dist/i18n/locales/de.js +6 -2
  21. package/dist/i18n/locales/el.d.ts +4 -0
  22. package/dist/i18n/locales/el.js +5 -1
  23. package/dist/i18n/locales/en.d.ts +4 -0
  24. package/dist/i18n/locales/en.js +5 -1
  25. package/dist/i18n/locales/es.d.ts +5 -1
  26. package/dist/i18n/locales/es.js +6 -2
  27. package/dist/i18n/locales/fr.d.ts +5 -1
  28. package/dist/i18n/locales/fr.js +6 -2
  29. package/dist/i18n/locales/hi.d.ts +4 -0
  30. package/dist/i18n/locales/hi.js +5 -1
  31. package/dist/i18n/locales/it.d.ts +4 -0
  32. package/dist/i18n/locales/it.js +5 -1
  33. package/dist/i18n/locales/ja.d.ts +4 -0
  34. package/dist/i18n/locales/ja.js +5 -1
  35. package/dist/i18n/locales/nl.d.ts +5 -1
  36. package/dist/i18n/locales/nl.js +6 -2
  37. package/dist/i18n/locales/pl.d.ts +4 -0
  38. package/dist/i18n/locales/pl.js +5 -1
  39. package/dist/i18n/locales/pt.d.ts +5 -1
  40. package/dist/i18n/locales/pt.js +6 -2
  41. package/dist/i18n/locales/ro.d.ts +4 -0
  42. package/dist/i18n/locales/ro.js +5 -1
  43. package/dist/i18n/locales/ru.d.ts +4 -0
  44. package/dist/i18n/locales/ru.js +5 -1
  45. package/dist/i18n/locales/sq.d.ts +4 -0
  46. package/dist/i18n/locales/sq.js +5 -1
  47. package/dist/i18n/locales/sv.d.ts +4 -0
  48. package/dist/i18n/locales/sv.js +5 -1
  49. package/dist/i18n/locales/tr.d.ts +4 -0
  50. package/dist/i18n/locales/tr.js +5 -1
  51. package/dist/i18n/locales/zh.d.ts +4 -0
  52. package/dist/i18n/locales/zh.js +5 -1
  53. package/dist/index.js +4 -4
  54. package/dist/locales/ar.json +5 -1
  55. package/dist/locales/de.json +6 -2
  56. package/dist/locales/el.json +5 -1
  57. package/dist/locales/en.json +5 -1
  58. package/dist/locales/es.json +6 -2
  59. package/dist/locales/fr.json +6 -2
  60. package/dist/locales/hi.json +5 -1
  61. package/dist/locales/it.json +5 -1
  62. package/dist/locales/ja.json +5 -1
  63. package/dist/locales/nl.json +6 -2
  64. package/dist/locales/pl.json +5 -1
  65. package/dist/locales/pt.json +6 -2
  66. package/dist/locales/ro.json +5 -1
  67. package/dist/locales/ru.json +5 -1
  68. package/dist/locales/sq.json +5 -1
  69. package/dist/locales/sv.json +5 -1
  70. package/dist/locales/tr.json +5 -1
  71. package/dist/locales/zh.json +5 -1
  72. package/package.json +1 -1
  73. package/dist/_chunks/booking-DHkKcUIl.js +0 -2713
  74. package/dist/_chunks/languages-CGLX6Qpe.js +0 -19
@@ -1,2713 +0,0 @@
1
- import { jsxs as f, jsx as s, Fragment as X } from "react/jsx-runtime";
2
- import { forwardRef as ot, useId as rt, useState as q, useCallback as H, useRef as ie, useEffect as U, useMemo as C, useImperativeHandle as Pt } from "react";
3
- import { c as Pe } from "./index-D2ZczOXr.js";
4
- import { useTranslation as B, Trans as Bt } from "react-i18next";
5
- import { u as Ot } from "./registry-DvAUVLHh.js";
6
- import { A as j } from "./alert-CiJT540z.js";
7
- import { B as ne } from "./button-nJaPh_HC.js";
8
- import { C as Ke } from "./checkbox-BuZ1u__2.js";
9
- import { C as Et } from "./checkbox-group-CfqMv57d.js";
10
- import { D as Lt } from "./date-picker-CepI_oI2.js";
11
- import { E as Rt } from "./email-input-Dpe63k0K.js";
12
- import { F as W } from "./form-field-CahJzTxp.js";
13
- import { P as Vt } from "./phone-input-BsZIoE36.js";
14
- import { T as Ft } from "./text-area-Bt3p7Pt0.js";
15
- import { T as Ce } from "./text-input-CUvCb6ST.js";
16
- import { S as $t } from "./spinner-hbwuKwMf.js";
17
- import { I as tt } from "./icon-button-DA2CAGHZ.js";
18
- import { S as Be } from "./select-BW5ecXlX.js";
19
- import { C as Ge } from "./combobox-DiMLItyu.js";
20
- import { M as Ue } from "./multi-select-DqL4o0qV.js";
21
- import { S as _e } from "./skeleton-CZbwyJAA.js";
22
- import { E as dt } from "./empty-state-X0sVPfVo.js";
23
- import { S as zt } from "./stepper-accordion-BeVMZPuG.js";
24
- import { S as Kt } from "./stepper-progress-Bv0njx4g.js";
25
- import { S as jt } from "./slot-grid-BuZOKfcd.js";
26
- import { p as $ } from "./parseISO-fOGpHKXm.js";
27
- import { l as le, f as Te, b as at } from "./format-4HNwNGrN.js";
28
- import { w as lt, c as ce, a as je, i as qt, s as ye, l as Ht, x as De } from "./date-picker-variants-DfuooXEK.js";
29
- import { s as Gt } from "./subDays-BLl3y3pd.js";
30
- import { C as Ut } from "./chevron-left-B8cOyH-V.js";
31
- import { C as Yt } from "./chevron-right-I9AeSxH2.js";
32
- import { c as z } from "./createLucideIcon-DhHxpK9K.js";
33
- import { M as Jt, S as Zt } from "./sun-Bj9Mr553.js";
34
- import { S as Wt } from "./stethoscope-sZXGC43m.js";
35
- import { H as Xt } from "./heart-pulse-BCppJyN2.js";
36
- import { E as Qt } from "./eye-BjhN2nYf.js";
37
- import { S as ea } from "./scan-line-CNseIHQ0.js";
38
- import { A as ta } from "./astroid-BN4f5VXU.js";
39
- import { C as aa } from "./clipboard-check-BeAGxDVT.js";
40
- /**
41
- * @license lucide-react v1.22.0 - ISC
42
- *
43
- * This source code is licensed under the ISC license.
44
- * See the LICENSE file in the root directory of this source tree.
45
- */
46
- const sa = [
47
- [
48
- "path",
49
- {
50
- d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
51
- key: "169zse"
52
- }
53
- ]
54
- ], ia = z("activity", sa);
55
- /**
56
- * @license lucide-react v1.22.0 - ISC
57
- *
58
- * This source code is licensed under the ISC license.
59
- * See the LICENSE file in the root directory of this source tree.
60
- */
61
- const na = [
62
- ["path", { d: "M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5", key: "1u7htd" }],
63
- ["path", { d: "M15 12h.01", key: "1k8ypt" }],
64
- [
65
- "path",
66
- {
67
- d: "M19.38 6.813A9 9 0 0 1 20.8 10.2a2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",
68
- key: "11xh7x"
69
- }
70
- ],
71
- ["path", { d: "M9 12h.01", key: "157uk2" }]
72
- ], oa = z("baby", na);
73
- /**
74
- * @license lucide-react v1.22.0 - ISC
75
- *
76
- * This source code is licensed under the ISC license.
77
- * See the LICENSE file in the root directory of this source tree.
78
- */
79
- const ra = [
80
- [
81
- "path",
82
- {
83
- d: "M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",
84
- key: "w610uw"
85
- }
86
- ]
87
- ], da = z("bone", ra);
88
- /**
89
- * @license lucide-react v1.22.0 - ISC
90
- *
91
- * This source code is licensed under the ISC license.
92
- * See the LICENSE file in the root directory of this source tree.
93
- */
94
- const la = [
95
- ["path", { d: "M12 18V5", key: "adv99a" }],
96
- ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
97
- ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
98
- ["path", { d: "M17.997 5.125a4 4 0 0 1 2.526 5.77", key: "iwvgf7" }],
99
- ["path", { d: "M18 18a4 4 0 0 0 2-7.464", key: "efp6ie" }],
100
- ["path", { d: "M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517", key: "1gq6am" }],
101
- ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
102
- ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
103
- ], ca = z("brain", la);
104
- /**
105
- * @license lucide-react v1.22.0 - ISC
106
- *
107
- * This source code is licensed under the ISC license.
108
- * See the LICENSE file in the root directory of this source tree.
109
- */
110
- const ua = [
111
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
112
- ["path", { d: "M16 2v4", key: "4m81vk" }],
113
- ["path", { d: "M3 10h18", key: "8toen8" }],
114
- ["path", { d: "M8 2v4", key: "1cmpym" }],
115
- ["path", { d: "M17 14h-6", key: "bkmgh3" }],
116
- ["path", { d: "M13 18H7", key: "bb0bb7" }],
117
- ["path", { d: "M7 14h.01", key: "1qa3f1" }],
118
- ["path", { d: "M17 18h.01", key: "1bdyru" }]
119
- ], pa = z("calendar-range", ua);
120
- /**
121
- * @license lucide-react v1.22.0 - ISC
122
- *
123
- * This source code is licensed under the ISC license.
124
- * See the LICENSE file in the root directory of this source tree.
125
- */
126
- const ma = [
127
- ["path", { d: "M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0", key: "1dfaln" }],
128
- ["path", { d: "M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4", key: "1qnva7" }]
129
- ], ga = z("ear", ma);
130
- /**
131
- * @license lucide-react v1.22.0 - ISC
132
- *
133
- * This source code is licensed under the ISC license.
134
- * See the LICENSE file in the root directory of this source tree.
135
- */
136
- const fa = [
137
- ["path", { d: "M6 18h8", key: "1borvv" }],
138
- ["path", { d: "M3 22h18", key: "8prr45" }],
139
- ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
140
- ["path", { d: "M9 14h2", key: "197e7h" }],
141
- ["path", { d: "M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z", key: "1bmzmy" }],
142
- ["path", { d: "M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3", key: "1drr47" }]
143
- ], ha = z("microscope", fa);
144
- /**
145
- * @license lucide-react v1.22.0 - ISC
146
- *
147
- * This source code is licensed under the ISC license.
148
- * See the LICENSE file in the root directory of this source tree.
149
- */
150
- const va = [
151
- [
152
- "path",
153
- { d: "m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z", key: "wa1lgi" }
154
- ],
155
- ["path", { d: "m8.5 8.5 7 7", key: "rvfmvr" }]
156
- ], ba = z("pill", va);
157
- /**
158
- * @license lucide-react v1.22.0 - ISC
159
- *
160
- * This source code is licensed under the ISC license.
161
- * See the LICENSE file in the root directory of this source tree.
162
- */
163
- const ya = [
164
- ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
165
- ["path", { d: "M8.12 8.12 12 12", key: "1alkpv" }],
166
- ["path", { d: "M20 4 8.12 15.88", key: "xgtan2" }],
167
- ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
168
- ["path", { d: "M14.8 14.8 20 20", key: "ptml3r" }]
169
- ], ka = z("scissors", ya);
170
- /**
171
- * @license lucide-react v1.22.0 - ISC
172
- *
173
- * This source code is licensed under the ISC license.
174
- * See the LICENSE file in the root directory of this source tree.
175
- */
176
- const xa = [
177
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
178
- ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
179
- ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
180
- ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
181
- ], Sa = z("smile", xa);
182
- /**
183
- * @license lucide-react v1.22.0 - ISC
184
- *
185
- * This source code is licensed under the ISC license.
186
- * See the LICENSE file in the root directory of this source tree.
187
- */
188
- const Ia = [
189
- ["path", { d: "M12 10V2", key: "16sf7g" }],
190
- ["path", { d: "m4.93 10.93 1.41 1.41", key: "2a7f42" }],
191
- ["path", { d: "M2 18h2", key: "j10viu" }],
192
- ["path", { d: "M20 18h2", key: "wocana" }],
193
- ["path", { d: "m19.07 10.93-1.41 1.41", key: "15zs5n" }],
194
- ["path", { d: "M22 22H2", key: "19qnx5" }],
195
- ["path", { d: "m16 6-4 4-4-4", key: "6wukr" }],
196
- ["path", { d: "M16 18a4 4 0 0 0-8 0", key: "1lzouq" }]
197
- ], Na = z("sunset", Ia);
198
- /**
199
- * @license lucide-react v1.22.0 - ISC
200
- *
201
- * This source code is licensed under the ISC license.
202
- * See the LICENSE file in the root directory of this source tree.
203
- */
204
- const wa = [
205
- ["path", { d: "m18 2 4 4", key: "22kx64" }],
206
- ["path", { d: "m17 7 3-3", key: "1w1zoj" }],
207
- ["path", { d: "M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5", key: "1exhtz" }],
208
- ["path", { d: "m9 11 4 4", key: "rovt3i" }],
209
- ["path", { d: "m5 19-3 3", key: "59f2uf" }],
210
- ["path", { d: "m14 4 6 6", key: "yqp9t2" }]
211
- ], st = z("syringe", wa);
212
- function Ca(e, t, a) {
213
- return lt(e, -1, a);
214
- }
215
- const Da = {
216
- id: "booking",
217
- // `view_change` removed (0.69): the layout `variant` is a fixed prop — the
218
- // handle exposes only `getVariant` (state), no action mutates it. The flow's
219
- // only navigation is step-to-step (`goto_step` → `navigate`).
220
- capabilities: ["navigate"],
221
- state: {
222
- variant: {
223
- type: "string",
224
- descriptionKey: "ui.agent.booking.state.variant",
225
- description: "Active variant — one of `inline-list`, `accordion`, `calendar`, `flexible`, `progress`.",
226
- read: (e) => e.getVariant()
227
- }
228
- },
229
- actions: {
230
- reset: {
231
- // destructive: clears the whole in-progress booking value (patient
232
- // identity, contact, slot choice) — irreversibly loses user input.
233
- safety: "destructive",
234
- idempotent: !0,
235
- descriptionKey: "ui.agent.booking.actions.reset",
236
- description: "Clear the booking value back to an empty state. Use to abandon an in-progress flow.",
237
- errors: ["Resetting after submit has no effect — the flow is on step 8."],
238
- invoke: (e) => {
239
- e.reset();
240
- }
241
- },
242
- goto_step: {
243
- safety: "read",
244
- argsType: "{ step: 1 | 2 | 3 | 4 | 5 | 6 | 7 }",
245
- argsSchema: {
246
- type: "object",
247
- properties: {
248
- step: {
249
- type: "integer",
250
- enum: [1, 2, 3, 4, 5, 6, 7],
251
- description: "Target step (1-7)."
252
- }
253
- },
254
- required: ["step"]
255
- },
256
- idempotent: !0,
257
- descriptionKey: "ui.agent.booking.actions.gotoStep",
258
- description: "Jump to the given step. Implementations may clamp to the first incomplete step if the requested one is not reachable yet.",
259
- errors: [
260
- "Requested step is not yet reachable — clamped to the first incomplete step."
261
- ],
262
- examples: [{ args: { step: 1 }, note: "Return to the first step." }],
263
- invoke: (e, t) => {
264
- e.goToStep(t.step);
265
- }
266
- }
267
- },
268
- domHooks: {
269
- root: {
270
- attr: "data-component",
271
- value: "booking",
272
- description: "Marks the Booking root region."
273
- },
274
- instanceId: {
275
- attr: "data-component-id",
276
- sourceProp: "id",
277
- description: "Sourced from the id prop."
278
- }
279
- }
280
- }, qe = [
281
- "email",
282
- "whatsapp",
283
- "sms"
284
- ], Q = "all", Ma = "de";
285
- function Aa(e) {
286
- return [...e.lockedOperatorId ? e.specialties.filter(
287
- (a) => {
288
- var i;
289
- return (i = a.operatorIds) == null ? void 0 : i.includes(e.lockedOperatorId);
290
- }
291
- ) : e.specialties].sort((a, i) => {
292
- const n = a.sequenceNumber ?? Number.POSITIVE_INFINITY, o = i.sequenceNumber ?? Number.POSITIVE_INFINITY;
293
- return n - o;
294
- });
295
- }
296
- function Ta(e) {
297
- let t = e.services;
298
- if (e.lockedOperatorId && (t = t.filter(
299
- (i) => {
300
- var n;
301
- return (n = i.operatorIds) == null ? void 0 : n.includes(e.lockedOperatorId);
302
- }
303
- )), e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) {
304
- const i = ue(e.value);
305
- i.length > 0 && (t = t.filter(
306
- (n) => n.specialtyId !== void 0 && i.includes(n.specialtyId)
307
- ));
308
- }
309
- return t;
310
- }
311
- function _a(e) {
312
- const t = e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties;
313
- if (t) {
314
- const a = ue(e.value);
315
- if (a.length > 0)
316
- return e.operators.filter(
317
- (i) => {
318
- var n;
319
- return (n = i.specialtyIds) == null ? void 0 : n.some((o) => a.includes(o));
320
- }
321
- );
322
- }
323
- if (!t) {
324
- const a = Oe(e.value);
325
- if (a.length > 0)
326
- return e.operators.filter(
327
- (i) => {
328
- var n;
329
- return (n = i.appointmentBookingReasonIds) == null ? void 0 : n.some((o) => a.includes(o));
330
- }
331
- );
332
- }
333
- return [];
334
- }
335
- function Pa(e, t) {
336
- const a = e.country === Ma, i = !a || e.value.insuranceType !== void 0, o = (e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) && i, r = ue(e.value).length > 0, m = !o || r, d = Oe(e.value).length > 0, l = !m || d, c = t.operators, x = !!e.allowOperatorSelection && l && d && !e.lockedOperatorId && c.length > 1, S = l && d, w = (!S || e.value.date !== void 0) && e.value.date !== void 0, N = (!w || e.value.slotKey !== void 0) && e.value.slotKey !== void 0, k = d && c.length === 0;
337
- return {
338
- insurance: a,
339
- specialty: o,
340
- service: m,
341
- operator: x,
342
- date: S,
343
- slot: w,
344
- details: N,
345
- onboardingIncomplete: k
346
- };
347
- }
348
- function Ba(e, t) {
349
- const a = [];
350
- t.insurance && a.push(1), t.specialty && a.push(2), a.push(3), t.operator && a.push(4), a.push(5), a.push(6), a.push(7);
351
- const i = {
352
- 1: e.value.insuranceType !== void 0,
353
- // 0.34.0: array-or-single — satisfied when EITHER form is present.
354
- 2: ue(e.value).length > 0,
355
- 3: Oe(e.value).length > 0,
356
- 4: e.value.operatorId !== void 0 || e.value.operatorIds !== void 0 && e.value.operatorIds.length > 0,
357
- 5: e.value.date !== void 0,
358
- 6: e.value.slotKey !== void 0,
359
- 7: !1
360
- // details fulfilment is owned by the form's own validation
361
- };
362
- return {
363
- currentStep: a.find((o) => !i[o]) ?? 7,
364
- visibleSteps: a
365
- };
366
- }
367
- function Oa(e) {
368
- const t = {
369
- specialties: Aa(e),
370
- services: Ta(e),
371
- operators: _a(e)
372
- }, a = Pa(e, t), { currentStep: i, visibleSteps: n } = Ba(e, a);
373
- let o;
374
- if (e.value.date && e.value.slotKey) {
375
- const l = e.availableSlots[e.value.date];
376
- l && (o = l.find((c) => c.key === e.value.slotKey));
377
- }
378
- const r = Oe(e.value), u = r.length > 0 ? e.services.find((l) => l.id === r[0]) : void 0, m = ue(e.value).length > 0, d = r.length > 0 && e.value.date !== void 0 && e.value.slotKey !== void 0 && (!a.insurance || e.value.insuranceType !== void 0) && (!a.specialty || m);
379
- return {
380
- gates: a,
381
- filtered: t,
382
- currentStep: i,
383
- totalSteps: n.length,
384
- visibleSteps: n,
385
- isReadyToSubmit: d,
386
- durationMin: u == null ? void 0 : u.durationMin,
387
- selectedSlot: o
388
- };
389
- }
390
- function ct(e, t) {
391
- return {
392
- ...e,
393
- insuranceType: t,
394
- specialtyId: void 0,
395
- serviceId: void 0,
396
- operatorId: void 0,
397
- date: void 0,
398
- slotKey: void 0,
399
- details: void 0
400
- };
401
- }
402
- function ut(e, t) {
403
- return {
404
- ...e,
405
- specialtyId: t,
406
- specialtyIds: void 0,
407
- serviceId: void 0,
408
- serviceIds: void 0,
409
- operatorId: void 0,
410
- operatorIds: void 0,
411
- date: void 0,
412
- slotKey: void 0,
413
- details: void 0
414
- };
415
- }
416
- function pt(e, t) {
417
- return {
418
- ...e,
419
- specialtyId: void 0,
420
- specialtyIds: t,
421
- serviceId: void 0,
422
- serviceIds: void 0,
423
- operatorId: void 0,
424
- operatorIds: void 0,
425
- date: void 0,
426
- slotKey: void 0,
427
- details: void 0
428
- };
429
- }
430
- function mt(e, t) {
431
- return {
432
- ...e,
433
- serviceId: t,
434
- serviceIds: void 0,
435
- // Default the operator to the "All operators" sentinel so a patient
436
- // who doesn't care about picking lands on a satisfied step 4 without
437
- // any further input.
438
- operatorId: t ? Q : void 0,
439
- operatorIds: void 0,
440
- date: void 0,
441
- slotKey: void 0,
442
- details: void 0
443
- };
444
- }
445
- function gt(e, t) {
446
- const a = !!t && t.length > 0;
447
- return {
448
- ...e,
449
- serviceId: void 0,
450
- serviceIds: t,
451
- operatorId: a ? Q : void 0,
452
- operatorIds: void 0,
453
- date: void 0,
454
- slotKey: void 0,
455
- details: void 0
456
- };
457
- }
458
- function ft(e, t) {
459
- return {
460
- ...e,
461
- operatorId: t,
462
- operatorIds: void 0,
463
- date: void 0,
464
- slotKey: void 0,
465
- details: void 0
466
- };
467
- }
468
- function ht(e, t) {
469
- return {
470
- ...e,
471
- operatorId: void 0,
472
- operatorIds: t,
473
- date: void 0,
474
- slotKey: void 0,
475
- details: void 0
476
- };
477
- }
478
- function ue(e) {
479
- return e.specialtyIds && e.specialtyIds.length > 0 ? e.specialtyIds : e.specialtyId ? [e.specialtyId] : [];
480
- }
481
- function Oe(e) {
482
- return e.serviceIds && e.serviceIds.length > 0 ? e.serviceIds : e.serviceId ? [e.serviceId] : [];
483
- }
484
- function Ee(e, t) {
485
- return {
486
- ...e,
487
- date: t,
488
- slotKey: void 0
489
- // Keep details — date/slot changes shouldn't wipe the patient form
490
- // since the user has already filled some fields.
491
- };
492
- }
493
- function vt(e, t) {
494
- return {
495
- ...e,
496
- slotKey: t
497
- };
498
- }
499
- function Ea(e, t) {
500
- let a = e;
501
- if (t.lockedOperatorId && a.operatorId !== t.lockedOperatorId && (a = { ...a, operatorId: t.lockedOperatorId }), (t.useSpecialties === void 0 ? t.specialties.length > 0 : t.useSpecialties) && t.specialties.length === 1 && a.specialtyId === void 0 && a.specialtyIds === void 0 && (a = { ...a, specialtyId: t.specialties[0].id }), t.autoSelectSingleService) {
502
- const n = ue(a), o = n.length > 0 ? t.services.filter(
503
- (r) => r.specialtyId && n.includes(r.specialtyId)
504
- ) : t.services;
505
- o.length === 1 && a.serviceId === void 0 && a.serviceIds === void 0 && (a = { ...a, serviceId: o[0].id }, a.operatorId === void 0 && a.operatorIds === void 0 && (a = { ...a, operatorId: Q }));
506
- }
507
- return a;
508
- }
509
- function He(e) {
510
- if (e.operatorId && e.operatorId !== Q)
511
- return e.operatorId;
512
- }
513
- function La(e) {
514
- if (!e) return !1;
515
- const t = e.trim();
516
- return /^\+?\d[\d\s\-()]{6,}$/.test(t);
517
- }
518
- function bt(e) {
519
- const t = e && e.length > 0 ? e : ["email"], a = new Set(t);
520
- return qe.filter((i) => a.has(i));
521
- }
522
- function Ra(e, t, a) {
523
- const i = bt(e), n = new Set(i);
524
- if (a)
525
- return qe.filter(
526
- (d) => a.includes(d) && n.has(d)
527
- );
528
- const o = [];
529
- n.has("email") && o.push("email");
530
- const r = La(t), u = n.has("whatsapp");
531
- u && r && o.push("whatsapp"), !u && n.has("sms") && o.push("sms");
532
- const m = new Set(o);
533
- return qe.filter((d) => m.has(d));
534
- }
535
- const it = 500, Va = /^[A-Z0-9]{16}$/, Fa = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, nt = 300, Me = { state: "idle" }, Ye = ot(
536
- ({
537
- value: e,
538
- onChange: t,
539
- onSubmit: a,
540
- requireCodiceFiscale: i = !1,
541
- requireDateOfBirth: n = !1,
542
- requireInsuranceNumber: o = !1,
543
- insuranceType: r,
544
- showNote: u = !1,
545
- showReturningPatientFlag: m = !1,
546
- privacyPolicyUrl: d,
547
- termsUrl: l,
548
- validateCodiceFiscale: c,
549
- validateInsuranceNumber: x,
550
- submitting: S = !1,
551
- summarySlot: h,
552
- defaultPhoneCountry: w,
553
- confirmationChannels: A,
554
- defaultConfirmationChannels: N,
555
- submitError: k
556
- }, b) => {
557
- var we, re;
558
- const { t: p } = B(), I = rt(), [M, g] = q(Me), [y, _] = q(Me), [T, O] = q({}), E = H(
559
- (v) => O((D) => ({ ...D, [v]: !0 })),
560
- []
561
- ), R = ie(null), V = ie(
562
- null
563
- );
564
- U(
565
- () => () => {
566
- R.current && clearTimeout(R.current), V.current && clearTimeout(V.current);
567
- },
568
- []
569
- );
570
- const P = H(
571
- (v) => t({ ...e, ...v }),
572
- [e, t]
573
- ), ee = C(
574
- () => bt(A),
575
- [A]
576
- ), G = ee.length >= 2, pe = ie(!1);
577
- U(() => {
578
- if (!G) {
579
- e.confirmationChannels !== void 0 && P({ confirmationChannels: void 0 });
580
- return;
581
- }
582
- if (e.confirmationChannels !== void 0) {
583
- pe.current = !0;
584
- return;
585
- }
586
- const v = Ra(
587
- ee,
588
- e.mobilePhone,
589
- N
590
- );
591
- pe.current = !0, P({ confirmationChannels: v });
592
- }, [
593
- G,
594
- ee,
595
- e.mobilePhone,
596
- N
597
- ]);
598
- const te = C(
599
- () => e.confirmationChannels ?? [],
600
- [e.confirmationChannels]
601
- ), xe = G && te.length === 0;
602
- U(() => {
603
- const v = e.codiceFiscale;
604
- if (!i || !c || !v) {
605
- g(Me);
606
- return;
607
- }
608
- if (!Va.test(v)) {
609
- g({
610
- state: "invalid",
611
- hint: p("booking.details.codiceFiscale.invalidFormat")
612
- });
613
- return;
614
- }
615
- g({ state: "pending" }), R.current && clearTimeout(R.current), R.current = setTimeout(() => {
616
- c(v).then(
617
- (D) => g(
618
- D.valid ? { state: "valid" } : { state: "invalid", hint: D.hint }
619
- )
620
- ).catch(
621
- () => g({
622
- state: "invalid",
623
- hint: p("booking.details.codiceFiscale.unavailable")
624
- })
625
- );
626
- }, nt);
627
- }, [i, c, e.codiceFiscale, p]);
628
- const Y = o && r === "public";
629
- U(() => {
630
- const v = e.insuranceNumber;
631
- if (!Y || !x || !v) {
632
- _(Me);
633
- return;
634
- }
635
- _({ state: "pending" }), V.current && clearTimeout(V.current), V.current = setTimeout(() => {
636
- x(v).then(
637
- (D) => _(
638
- D.valid ? { state: "valid" } : { state: "invalid", hint: D.hint }
639
- )
640
- ).catch(
641
- () => _({
642
- state: "invalid",
643
- hint: p("booking.details.insuranceNumber.unavailable")
644
- })
645
- );
646
- }, nt);
647
- }, [Y, x, e.insuranceNumber, p]);
648
- const oe = C(
649
- () => !!(e.email && Fa.test(e.email)),
650
- [e.email]
651
- ), me = C(
652
- () => !!(e.mobilePhone && e.mobilePhone.length >= 6),
653
- [e.mobilePhone]
654
- ), Se = C(() => {
655
- var v, D;
656
- return !(!((v = e.firstName) != null && v.trim()) || !((D = e.lastName) != null && D.trim()) || !oe || !me || i && M.state !== "valid" || n && !e.dateOfBirth || Y && y.state !== "valid");
657
- }, [
658
- e.firstName,
659
- e.lastName,
660
- oe,
661
- me,
662
- i,
663
- M.state,
664
- n,
665
- e.dateOfBirth,
666
- Y,
667
- y.state
668
- ]), Ie = !!(e.privacyConsent && e.termsConsent), Le = !G || te.length > 0, J = Se && Ie && Le && !S, Re = (v) => {
669
- if (v.preventDefault(), O({
670
- firstName: !0,
671
- lastName: !0,
672
- email: !0,
673
- mobilePhone: !0,
674
- codiceFiscale: !0,
675
- dateOfBirth: !0,
676
- insuranceNumber: !0
677
- }), !J) return;
678
- const D = {
679
- firstName: e.firstName.trim(),
680
- lastName: e.lastName.trim(),
681
- email: e.email.trim(),
682
- mobilePhone: e.mobilePhone,
683
- privacyConsent: !0,
684
- termsConsent: !0,
685
- codiceFiscale: e.codiceFiscale,
686
- dateOfBirth: e.dateOfBirth,
687
- insuranceNumber: e.insuranceNumber,
688
- note: e.note,
689
- returningPatient: e.returningPatient,
690
- // Only include when the picker was visible; otherwise the single
691
- // implicit channel is inferred backend-side from the practice
692
- // config.
693
- confirmationChannels: G ? te : void 0
694
- };
695
- a(D);
696
- }, Ne = (v, D) => {
697
- const ae = D && /^https?:\/\//i.test(D) ? D : void 0;
698
- return ae ? /* @__PURE__ */ s(
699
- Bt,
700
- {
701
- i18nKey: v,
702
- components: {
703
- // The `<Trans>` runtime injects link text from the i18n
704
- // string. The anchor renders empty at static-analysis time,
705
- // so `jsx-a11y/anchor-has-content` would false-flag — silence
706
- // it; the runtime content is the localised policy / terms
707
- // label.
708
- policyLink: (
709
- // eslint-disable-next-line jsx-a11y/anchor-has-content
710
- /* @__PURE__ */ s(
711
- "a",
712
- {
713
- href: ae,
714
- target: "_blank",
715
- rel: "noopener noreferrer",
716
- className: "ds:underline ds:text-[var(--primary)]"
717
- }
718
- )
719
- )
720
- }
721
- }
722
- ) : p(v);
723
- };
724
- return /* @__PURE__ */ f(
725
- "form",
726
- {
727
- ref: b,
728
- id: I,
729
- noValidate: !0,
730
- onSubmit: Re,
731
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
732
- children: [
733
- h,
734
- /* @__PURE__ */ f("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
735
- /* @__PURE__ */ s(
736
- W,
737
- {
738
- label: p("booking.details.firstName.label"),
739
- required: !0,
740
- error: T.firstName && !((we = e.firstName) != null && we.trim()) ? p("booking.details.firstName.required") : void 0,
741
- children: /* @__PURE__ */ s(
742
- Ce,
743
- {
744
- autoComplete: "given-name",
745
- value: e.firstName ?? "",
746
- onChange: (v) => P({ firstName: v.target.value }),
747
- onBlur: () => E("firstName")
748
- }
749
- )
750
- }
751
- ),
752
- /* @__PURE__ */ s(
753
- W,
754
- {
755
- label: p("booking.details.lastName.label"),
756
- required: !0,
757
- error: T.lastName && !((re = e.lastName) != null && re.trim()) ? p("booking.details.lastName.required") : void 0,
758
- children: /* @__PURE__ */ s(
759
- Ce,
760
- {
761
- autoComplete: "family-name",
762
- value: e.lastName ?? "",
763
- onChange: (v) => P({ lastName: v.target.value }),
764
- onBlur: () => E("lastName")
765
- }
766
- )
767
- }
768
- )
769
- ] }),
770
- /* @__PURE__ */ f("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
771
- /* @__PURE__ */ s(
772
- W,
773
- {
774
- label: p("booking.details.email.label"),
775
- required: !0,
776
- error: T.email && !oe ? p("booking.details.email.invalid") : void 0,
777
- children: /* @__PURE__ */ s(
778
- Rt,
779
- {
780
- value: e.email ?? "",
781
- onChange: (v) => P({ email: v.target.value }),
782
- onBlur: () => E("email")
783
- }
784
- )
785
- }
786
- ),
787
- /* @__PURE__ */ s(
788
- W,
789
- {
790
- label: p("booking.details.mobilePhone.label"),
791
- required: !0,
792
- error: T.mobilePhone && !me ? p("booking.details.mobilePhone.invalid") : void 0,
793
- children: /* @__PURE__ */ s(
794
- Vt,
795
- {
796
- value: e.mobilePhone ?? "",
797
- defaultCountry: w == null ? void 0 : w.toUpperCase(),
798
- onChange: (v) => {
799
- P({ mobilePhone: v }), E("mobilePhone");
800
- }
801
- }
802
- )
803
- }
804
- )
805
- ] }),
806
- i || n ? /* @__PURE__ */ f("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
807
- i ? /* @__PURE__ */ s(
808
- W,
809
- {
810
- label: p("booking.details.codiceFiscale.label"),
811
- required: !0,
812
- description: M.state === "pending" ? p("booking.details.codiceFiscale.checking") : p("booking.details.codiceFiscale.helper"),
813
- error: T.codiceFiscale && M.state === "invalid" ? M.hint ?? p("booking.details.codiceFiscale.invalid") : void 0,
814
- children: /* @__PURE__ */ s(
815
- Ce,
816
- {
817
- value: e.codiceFiscale ?? "",
818
- maxLength: 16,
819
- onChange: (v) => P({
820
- codiceFiscale: v.target.value.slice(0, 16).toUpperCase()
821
- }),
822
- onBlur: () => E("codiceFiscale")
823
- }
824
- )
825
- }
826
- ) : null,
827
- n ? /* @__PURE__ */ s(
828
- W,
829
- {
830
- label: p("booking.details.dateOfBirth.label"),
831
- required: !0,
832
- error: T.dateOfBirth && !e.dateOfBirth ? p("booking.details.dateOfBirth.required") : void 0,
833
- children: /* @__PURE__ */ s(
834
- Lt,
835
- {
836
- value: e.dateOfBirth ? new Date(e.dateOfBirth) : void 0,
837
- onChange: (v) => {
838
- P({
839
- dateOfBirth: v ? v.toISOString().slice(0, 10) : void 0
840
- }), E("dateOfBirth");
841
- }
842
- }
843
- )
844
- }
845
- ) : null
846
- ] }) : null,
847
- Y ? /* @__PURE__ */ s(
848
- W,
849
- {
850
- label: p("booking.details.insuranceNumber.label"),
851
- required: !0,
852
- description: y.state === "pending" ? p("booking.details.insuranceNumber.checking") : void 0,
853
- error: T.insuranceNumber && y.state === "invalid" ? y.hint ?? p("booking.details.insuranceNumber.invalid") : void 0,
854
- children: /* @__PURE__ */ s(
855
- Ce,
856
- {
857
- value: e.insuranceNumber ?? "",
858
- onChange: (v) => P({ insuranceNumber: v.target.value }),
859
- onBlur: () => E("insuranceNumber")
860
- }
861
- )
862
- }
863
- ) : null,
864
- u ? /* @__PURE__ */ s(
865
- W,
866
- {
867
- label: p("booking.details.note.label"),
868
- description: p("booking.details.note.helper", {
869
- max: it
870
- }),
871
- children: /* @__PURE__ */ s(
872
- Ft,
873
- {
874
- value: e.note ?? "",
875
- maxLength: it,
876
- rows: 3,
877
- onChange: (v) => P({ note: v.target.value })
878
- }
879
- )
880
- }
881
- ) : null,
882
- m ? /* @__PURE__ */ s(
883
- Ke,
884
- {
885
- checked: !!e.returningPatient,
886
- onCheckedChange: (v) => P({ returningPatient: v === !0 }),
887
- label: p("booking.details.returningPatient.label")
888
- }
889
- ) : null,
890
- /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
891
- /* @__PURE__ */ s(
892
- Ke,
893
- {
894
- checked: !!e.privacyConsent,
895
- onCheckedChange: (v) => P({ privacyConsent: v === !0 }),
896
- label: /* @__PURE__ */ f(X, { children: [
897
- Ne(
898
- "booking.details.consent.privacy.label",
899
- d
900
- ),
901
- /* @__PURE__ */ s(
902
- "span",
903
- {
904
- "aria-hidden": "true",
905
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
906
- children: "*"
907
- }
908
- )
909
- ] })
910
- }
911
- ),
912
- /* @__PURE__ */ s(
913
- Ke,
914
- {
915
- checked: !!e.termsConsent,
916
- onCheckedChange: (v) => P({ termsConsent: v === !0 }),
917
- label: /* @__PURE__ */ f(X, { children: [
918
- Ne(
919
- "booking.details.consent.terms.label",
920
- l
921
- ),
922
- /* @__PURE__ */ s(
923
- "span",
924
- {
925
- "aria-hidden": "true",
926
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
927
- children: "*"
928
- }
929
- )
930
- ] })
931
- }
932
- )
933
- ] }),
934
- G ? /* @__PURE__ */ s(
935
- "div",
936
- {
937
- "data-component": "booking-confirmation-channels",
938
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
939
- children: /* @__PURE__ */ s(
940
- Et,
941
- {
942
- label: p("booking.confirmation.heading"),
943
- helperText: p("booking.confirmation.helper"),
944
- value: te,
945
- onChange: (v) => P({
946
- confirmationChannels: v
947
- }),
948
- orientation: "vertical",
949
- options: ee.map((v) => ({
950
- value: v,
951
- label: p(`booking.confirmation.channel.${v}`)
952
- })),
953
- error: xe ? p("booking.confirmation.atLeastOne") : void 0
954
- }
955
- )
956
- }
957
- ) : null,
958
- k ? /* @__PURE__ */ s(j, { variant: "error", children: /* @__PURE__ */ s(j.Description, { children: k }) }) : null,
959
- /* @__PURE__ */ s(
960
- ne,
961
- {
962
- intent: "primary",
963
- size: "md",
964
- type: "submit",
965
- disabled: !J,
966
- startIcon: S ? /* @__PURE__ */ s($t, { variant: "pulse", size: "sm" }) : void 0,
967
- children: p("booking.details.submit")
968
- }
969
- )
970
- ]
971
- }
972
- );
973
- }
974
- );
975
- Ye.displayName = "BookingDetailsForm";
976
- const $a = Pe(
977
- "ds:flex ds:w-full ds:flex-col ds:text-[var(--foreground)]",
978
- {
979
- variants: {
980
- variant: {
981
- "inline-list": "ds:gap-[var(--spacing-md)]",
982
- accordion: "ds:gap-[var(--spacing-md)]",
983
- calendar: "ds:gap-[var(--spacing-md)]",
984
- flexible: "ds:gap-[var(--spacing-lg)]",
985
- progress: "ds:gap-[var(--spacing-sm)]"
986
- },
987
- // `surface="elevated"` matches `Card variant="elevated"` — same
988
- // tokens, same padding, same boundary behaviour — so consumers can
989
- // drop their own Card wraps without a double-card look. Default
990
- // `'flat'` preserves 0.30.x rendering.
991
- surface: {
992
- flat: "",
993
- elevated: [
994
- "ds:rounded-[var(--radius-lg)]",
995
- "ds:bg-[var(--card)] ds:text-[var(--card-foreground)]",
996
- "ds:border ds:border-[color:var(--card-border)]",
997
- "ds:shadow-[var(--shadow-card)]",
998
- "ds:p-[var(--spacing-md)]"
999
- ].join(" ")
1000
- }
1001
- },
1002
- defaultVariants: { variant: "inline-list", surface: "flat" }
1003
- }
1004
- ), za = [
1005
- [
1006
- /\b(estetic|aesthetic|botox|filler|mesoterap|chirurgia\s*plastic)/i,
1007
- st
1008
- ],
1009
- [/\b(cardio|ecg|elettrocardio|ecocardio|cuore|heart)/i, Xt],
1010
- [/\b(dent|odonto|tooth|teeth|pulizia|igien|smile)/i, Sa],
1011
- [/\b(oftalmo|ocul|ophthal|vision|occhi|eye)/i, Qt],
1012
- [/\b(otorin|udito|orecchi|hearing|ear)/i, ga],
1013
- [/\b(neuro|brain|cervello)/i, ca],
1014
- [/\b(pediatr|child|bambin)/i, oa],
1015
- [/\b(ortop|ortho|osteo|skeleton|ossa|bone)/i, da],
1016
- [/\b(lab|analis|test|sang|esami)/i, ha],
1017
- [/\b(farmaco|pharm|pillol|refill)/i, ba],
1018
- [/\b(chirurg|surg|intervent|operat)/i, ka],
1019
- [/\b(scan|rx|x-?ray|raggi|imag|radio|risonan|ecograf|ultras)/i, ea],
1020
- [/\b(vacc|inject|inie|punto)/i, st],
1021
- [/\b(derma|skin|pelle)/i, ta],
1022
- [/\b(prima\s*visit|first\s*visit|consult|consulto|valutaz)/i, aa],
1023
- [/\b(general|medicin|family|control|check[-\s]?up)/i, ia]
1024
- ];
1025
- function Ka(e) {
1026
- for (const [t, a] of za)
1027
- if (t.test(e)) return a;
1028
- return null;
1029
- }
1030
- function ja(e) {
1031
- const t = Ka(e.label) ?? Wt;
1032
- return /* @__PURE__ */ s(t, { "aria-hidden": "true", className: "ds:size-5" });
1033
- }
1034
- function yt(e) {
1035
- var t;
1036
- return (t = e.priceLabel) != null && t.trim() ? e.priceLabel : void 0;
1037
- }
1038
- function se(e) {
1039
- return Te(e, "yyyy-MM-dd");
1040
- }
1041
- const qa = [
1042
- "ds:relative ds:flex ds:items-center ds:justify-center",
1043
- "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]",
1044
- "ds:rounded-[var(--radius-sm)]",
1045
- "ds:text-[length:var(--font-size-sm)]",
1046
- "ds:transition-colors ds:duration-[var(--animation-duration)]",
1047
- "ds:motion-reduce:transition-none",
1048
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
1049
- "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1050
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
1051
- ].join(" "), Ha = Pe(qa, {
1052
- variants: {
1053
- state: {
1054
- available: "ds:cursor-pointer ds:text-[var(--foreground)] ds:hover:bg-[var(--muted)]/30",
1055
- unavailable: "ds:cursor-not-allowed ds:text-[var(--muted-foreground)]/60",
1056
- selected: "ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)] ds:font-[var(--font-weight-semibold)]",
1057
- outside: "ds:text-[var(--muted-foreground)]/40"
1058
- }
1059
- },
1060
- defaultVariants: { state: "unavailable" }
1061
- });
1062
- function Ga({
1063
- availableDates: e,
1064
- selectedDate: t,
1065
- onSelectDate: a,
1066
- locale: i,
1067
- loading: n
1068
- }) {
1069
- const { t: o } = B(), r = C(() => t ? ye($(t)) : e.length > 0 ? ye($(e[0])) : ye(/* @__PURE__ */ new Date()), [t, e]), [u, m] = q(r), [d, l] = q(null), c = C(() => {
1070
- const k = ye(u), b = Ht(u), p = k.getDay(), I = b.getDate(), M = [];
1071
- for (let g = p; g > 0; g -= 1) {
1072
- const y = new Date(k);
1073
- y.setDate(k.getDate() - g), M.push(y);
1074
- }
1075
- for (let g = 0; g < I; g += 1) {
1076
- const y = new Date(k);
1077
- y.setDate(k.getDate() + g), M.push(y);
1078
- }
1079
- for (; M.length < 42; ) {
1080
- const g = M[M.length - 1], y = new Date(g);
1081
- y.setDate(g.getDate() + 1), M.push(y);
1082
- }
1083
- return M;
1084
- }, [u]), x = C(() => {
1085
- try {
1086
- return new Intl.DateTimeFormat(i, {
1087
- month: "long",
1088
- year: "numeric"
1089
- }).format(u);
1090
- } catch {
1091
- return Te(u, "MMMM yyyy");
1092
- }
1093
- }, [u, i]), S = C(() => {
1094
- const k = new Date(2024, 0, 7);
1095
- return Array.from({ length: 7 }, (b, p) => {
1096
- const I = new Date(k);
1097
- I.setDate(k.getDate() + p);
1098
- try {
1099
- return new Intl.DateTimeFormat(i, { weekday: "short" }).format(I);
1100
- } catch {
1101
- return Te(I, "EEE");
1102
- }
1103
- });
1104
- }, [i]), h = C(() => new Set(e), [e]), w = H(
1105
- (k) => h.has(se(k)),
1106
- [h]
1107
- ), A = C(() => {
1108
- if (d) return d;
1109
- if (t) return $(t);
1110
- const k = c.find(
1111
- (b) => De(b, u) && w(b)
1112
- );
1113
- return k || (c.find((b) => De(b, u)) ?? null);
1114
- }, [d, t, c, u, w]), N = H(
1115
- (k, b) => {
1116
- let p = null;
1117
- switch (k.key) {
1118
- case "ArrowLeft":
1119
- p = new Date(b), p.setDate(b.getDate() - 1);
1120
- break;
1121
- case "ArrowRight":
1122
- p = new Date(b), p.setDate(b.getDate() + 1);
1123
- break;
1124
- case "ArrowUp":
1125
- p = new Date(b), p.setDate(b.getDate() - 7);
1126
- break;
1127
- case "ArrowDown":
1128
- p = new Date(b), p.setDate(b.getDate() + 7);
1129
- break;
1130
- case "Home":
1131
- p = new Date(b), p.setDate(b.getDate() - b.getDay());
1132
- break;
1133
- case "End":
1134
- p = new Date(b), p.setDate(b.getDate() + (6 - b.getDay()));
1135
- break;
1136
- case "Enter":
1137
- case " ": {
1138
- k.preventDefault(), w(b) && a(se(b));
1139
- return;
1140
- }
1141
- default:
1142
- return;
1143
- }
1144
- p && (k.preventDefault(), De(p, u) || m(ye(p)), l(p));
1145
- },
1146
- [w, a, u]
1147
- );
1148
- return n ? /* @__PURE__ */ f(
1149
- "div",
1150
- {
1151
- role: "status",
1152
- "aria-live": "polite",
1153
- "aria-label": o("common.loading"),
1154
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1155
- children: [
1156
- /* @__PURE__ */ s(_e, { variant: "text", width: "40%" }),
1157
- /* @__PURE__ */ s("div", { className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]", children: Array.from({ length: 42 }, (k, b) => /* @__PURE__ */ s(_e, { variant: "rounded", height: "2.5rem" }, `mg-skel-${b}`)) })
1158
- ]
1159
- }
1160
- ) : /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1161
- /* @__PURE__ */ f("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
1162
- /* @__PURE__ */ s(
1163
- tt,
1164
- {
1165
- icon: /* @__PURE__ */ s(Ut, {}),
1166
- "aria-label": o("booking.previousMonth"),
1167
- size: "sm",
1168
- intent: "ghost",
1169
- flipIconInRtl: !0,
1170
- onClick: () => {
1171
- m((k) => Ca(k)), l(null);
1172
- }
1173
- }
1174
- ),
1175
- /* @__PURE__ */ s(
1176
- "span",
1177
- {
1178
- className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]",
1179
- "aria-live": "polite",
1180
- children: x
1181
- }
1182
- ),
1183
- /* @__PURE__ */ s(
1184
- tt,
1185
- {
1186
- icon: /* @__PURE__ */ s(Yt, {}),
1187
- "aria-label": o("booking.nextMonth"),
1188
- size: "sm",
1189
- intent: "ghost",
1190
- flipIconInRtl: !0,
1191
- onClick: () => {
1192
- m((k) => lt(k, 1)), l(null);
1193
- }
1194
- }
1195
- )
1196
- ] }),
1197
- /* @__PURE__ */ f(
1198
- "div",
1199
- {
1200
- role: "grid",
1201
- "aria-label": o("booking.monthGridLabel"),
1202
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
1203
- children: [
1204
- /* @__PURE__ */ s(
1205
- "div",
1206
- {
1207
- role: "row",
1208
- className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
1209
- children: S.map((k, b) => /* @__PURE__ */ s(
1210
- "div",
1211
- {
1212
- role: "columnheader",
1213
- className: "type-meta ds:text-center ds:text-[var(--muted-foreground)] ds:font-[var(--font-weight-medium)]",
1214
- children: k
1215
- },
1216
- `wd-${b}`
1217
- ))
1218
- }
1219
- ),
1220
- Array.from({ length: 6 }, (k, b) => /* @__PURE__ */ s(
1221
- "div",
1222
- {
1223
- role: "row",
1224
- className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
1225
- children: c.slice(b * 7, b * 7 + 7).map((p, I) => {
1226
- const M = b * 7 + I, g = De(p, u), y = g && w(p), _ = t ? at(p, $(t)) : !1, T = g ? _ ? "selected" : y ? "available" : "unavailable" : "outside", O = A ? at(A, p) : !1, E = (() => {
1227
- try {
1228
- return new Intl.DateTimeFormat(i, {
1229
- dateStyle: "full"
1230
- }).format(p);
1231
- } catch {
1232
- return Te(p, "PPP");
1233
- }
1234
- })();
1235
- return /* @__PURE__ */ s(
1236
- "button",
1237
- {
1238
- type: "button",
1239
- role: "gridcell",
1240
- "aria-label": E,
1241
- "aria-selected": _ || void 0,
1242
- "aria-disabled": !y || void 0,
1243
- tabIndex: O ? 0 : -1,
1244
- disabled: !y,
1245
- onClick: () => {
1246
- y && a(se(p));
1247
- },
1248
- onKeyDown: (R) => N(R, p),
1249
- className: Ha({ state: T }),
1250
- children: /* @__PURE__ */ s("span", { "aria-hidden": "true", children: p.getDate() })
1251
- },
1252
- `mg-cell-${M}`
1253
- );
1254
- })
1255
- },
1256
- `mg-row-${b}`
1257
- ))
1258
- ]
1259
- }
1260
- )
1261
- ] });
1262
- }
1263
- const Ua = Pe(
1264
- [
1265
- "ds:relative ds:flex ds:w-full ds:items-center ds:gap-[var(--spacing-md)]",
1266
- "ds:min-h-[var(--min-target-size)]",
1267
- "ds:rounded-[var(--radius-md)]",
1268
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
1269
- "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]",
1270
- "ds:text-start",
1271
- "ds:transition-[background-color,box-shadow]",
1272
- "ds:duration-[var(--animation-duration)]",
1273
- "ds:motion-reduce:transition-none",
1274
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
1275
- "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1276
- "ds:forced-colors:[outline:1px_solid_CanvasText]",
1277
- "ds:cursor-pointer"
1278
- ].join(" "),
1279
- {
1280
- variants: {
1281
- state: {
1282
- idle: "ds:bg-[var(--card)] ds:shadow-[var(--shadow-sm)] ds:hover:shadow-[var(--shadow-md)]",
1283
- selected: "ds:bg-[color-mix(in_srgb,var(--primary)_8%,var(--card))] ds:shadow-[var(--shadow-sm)]"
1284
- }
1285
- },
1286
- defaultVariants: { state: "idle" }
1287
- }
1288
- );
1289
- function Ya({
1290
- services: e,
1291
- selectedServiceId: t,
1292
- onSelect: a
1293
- }) {
1294
- const { t: i } = B(), n = rt(), [o, r] = q(() => {
1295
- if (t) {
1296
- const l = e.findIndex((c) => c.id === t);
1297
- if (l >= 0) return l;
1298
- }
1299
- return 0;
1300
- }), u = ie(/* @__PURE__ */ new Map()), m = H((l) => {
1301
- var c;
1302
- (c = u.current.get(l)) == null || c.focus();
1303
- }, []), d = H(
1304
- (l, c, x) => {
1305
- const S = e.length;
1306
- if (S !== 0)
1307
- switch (l.key) {
1308
- case "ArrowDown":
1309
- case "ArrowRight": {
1310
- l.preventDefault();
1311
- const h = (c + 1) % S;
1312
- r(h), m(h);
1313
- break;
1314
- }
1315
- case "ArrowUp":
1316
- case "ArrowLeft": {
1317
- l.preventDefault();
1318
- const h = (c - 1 + S) % S;
1319
- r(h), m(h);
1320
- break;
1321
- }
1322
- case "Home": {
1323
- l.preventDefault(), r(0), m(0);
1324
- break;
1325
- }
1326
- case "End": {
1327
- l.preventDefault();
1328
- const h = S - 1;
1329
- r(h), m(h);
1330
- break;
1331
- }
1332
- case "Enter":
1333
- case " ": {
1334
- l.preventDefault(), a(x);
1335
- break;
1336
- }
1337
- }
1338
- },
1339
- [e.length, m, a]
1340
- );
1341
- return e.length === 0 ? null : /* @__PURE__ */ s(
1342
- "div",
1343
- {
1344
- role: "radiogroup",
1345
- "aria-label": i("booking.serviceListLabel"),
1346
- id: n,
1347
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1348
- children: e.map((l, c) => {
1349
- const x = t === l.id, S = o === c, h = yt(l), w = h ? i("booking.serviceCardLabelPrice", {
1350
- label: l.label,
1351
- price: h
1352
- }) : i("booking.serviceCardLabel", {
1353
- label: l.label,
1354
- duration: l.durationMin
1355
- }), A = ja(l);
1356
- return /* @__PURE__ */ f(
1357
- "button",
1358
- {
1359
- ref: (N) => {
1360
- N ? u.current.set(c, N) : u.current.delete(c);
1361
- },
1362
- type: "button",
1363
- role: "radio",
1364
- "aria-checked": x,
1365
- "aria-label": w,
1366
- tabIndex: S ? 0 : -1,
1367
- onClick: () => a(l.id),
1368
- onFocus: () => r(c),
1369
- onKeyDown: (N) => d(N, c, l.id),
1370
- className: Ua({
1371
- state: x ? "selected" : "idle"
1372
- }),
1373
- children: [
1374
- /* @__PURE__ */ s(
1375
- "span",
1376
- {
1377
- "aria-hidden": "true",
1378
- className: "ds:flex ds:size-10 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-[var(--radius-sm)] ds:bg-[var(--primary)]/10 ds:text-[var(--primary)]",
1379
- children: A
1380
- }
1381
- ),
1382
- /* @__PURE__ */ f("span", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
1383
- /* @__PURE__ */ s("span", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]", children: l.label }),
1384
- /* @__PURE__ */ s("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: h ?? i("booking.serviceSummary", { minutes: l.durationMin }) })
1385
- ] })
1386
- ]
1387
- },
1388
- l.id
1389
- );
1390
- })
1391
- }
1392
- );
1393
- }
1394
- const Ja = Pe(
1395
- [
1396
- "ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-2xs)]",
1397
- "ds:min-h-[var(--min-target-size)]",
1398
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
1399
- "ds:pt-[var(--spacing-2xs)] ds:pb-[var(--spacing-2xs)]",
1400
- "ds:rounded-[var(--radius-md)]",
1401
- "ds:text-[length:var(--font-size-sm)] ds:font-[var(--font-weight-medium)]",
1402
- "ds:transition-[background-color,color,box-shadow] ds:duration-[var(--animation-duration)]",
1403
- "ds:motion-reduce:transition-none",
1404
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
1405
- "ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1406
- "ds:disabled:cursor-not-allowed ds:disabled:opacity-50",
1407
- "ds:forced-colors:[border:1px_solid_ButtonText] ds:forced-colors:text-[ButtonText]"
1408
- ].join(" "),
1409
- {
1410
- variants: {
1411
- state: {
1412
- idle: "ds:bg-[color:var(--card)] ds:text-[color:var(--foreground)] ds:shadow-[var(--shadow-sm)] ds:hover:enabled:bg-[color:var(--muted)]/40 ds:hover:enabled:shadow-[var(--shadow-md)]",
1413
- selected: "ds:bg-[color:var(--primary)] ds:text-[color:var(--primary-foreground)] ds:shadow-[var(--shadow-sm)]",
1414
- unavailable: "ds:[outline:1px_dashed_color:var(--border)] ds:[outline-offset:-1px] ds:bg-transparent ds:text-[color:var(--muted-foreground)]"
1415
- }
1416
- },
1417
- defaultVariants: { state: "idle" }
1418
- }
1419
- );
1420
- function Za(e) {
1421
- const [t] = e.split(":").map((i) => parseInt(i, 10)), a = Number.isFinite(t) ? t : 0;
1422
- return a < 12 ? "morning" : a < 17 ? "afternoon" : "evening";
1423
- }
1424
- const Wa = {
1425
- morning: Zt,
1426
- afternoon: Na,
1427
- evening: Jt
1428
- };
1429
- function Xa({
1430
- date: e,
1431
- slots: t,
1432
- selectedSlotKey: a,
1433
- onSelect: i,
1434
- loading: n,
1435
- locale: o
1436
- }) {
1437
- const { t: r } = B(), u = C(() => {
1438
- try {
1439
- return new Intl.DateTimeFormat(o, {
1440
- weekday: "long",
1441
- day: "numeric",
1442
- month: "long"
1443
- }).format($(e));
1444
- } catch {
1445
- return e;
1446
- }
1447
- }, [e, o]), m = C(() => {
1448
- const c = {
1449
- morning: [],
1450
- afternoon: [],
1451
- evening: []
1452
- };
1453
- for (const x of t)
1454
- c[Za(x.time)].push(x);
1455
- return c;
1456
- }, [t]), d = t.filter((c) => c.available).length, l = ["morning", "afternoon", "evening"];
1457
- return n ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1458
- /* @__PURE__ */ s(_e, { variant: "text", width: "60%" }),
1459
- [0, 1].map((c) => /* @__PURE__ */ s(
1460
- "div",
1461
- {
1462
- className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)]",
1463
- children: [0, 1, 2].map((x) => /* @__PURE__ */ s(_e, { variant: "rounded", height: "44px" }, x))
1464
- },
1465
- c
1466
- ))
1467
- ] }) : d === 0 ? /* @__PURE__ */ s(dt, { variant: "no-results", title: r("booking.noSlotsForDate") }) : /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1468
- /* @__PURE__ */ f("div", { className: "ds:flex ds:items-baseline ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
1469
- /* @__PURE__ */ f("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
1470
- /* @__PURE__ */ s(
1471
- pa,
1472
- {
1473
- "aria-hidden": "true",
1474
- className: "ds:size-4 ds:text-[color:var(--accent)]"
1475
- }
1476
- ),
1477
- /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: u })
1478
- ] }),
1479
- /* @__PURE__ */ s("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: r("booking.slotsAvailable", { count: d }) })
1480
- ] }),
1481
- l.map((c) => {
1482
- const x = m[c];
1483
- if (x.length === 0) return null;
1484
- const S = Wa[c];
1485
- return /* @__PURE__ */ f(
1486
- "div",
1487
- {
1488
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
1489
- children: [
1490
- /* @__PURE__ */ f("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]", children: [
1491
- /* @__PURE__ */ s(S, { "aria-hidden": "true", className: "ds:size-3.5" }),
1492
- /* @__PURE__ */ s("span", { className: "type-meta ds:font-[var(--font-weight-semibold)] ds:uppercase", children: r(`booking.timeOfDay.${c}`) })
1493
- ] }),
1494
- /* @__PURE__ */ s(
1495
- "div",
1496
- {
1497
- role: "group",
1498
- "aria-label": r(`booking.timeOfDay.${c}`),
1499
- className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)] ds:sm:grid-cols-4",
1500
- children: x.map((h) => {
1501
- const w = h.key === a, A = h.available ? w ? "selected" : "idle" : "unavailable";
1502
- return /* @__PURE__ */ s(
1503
- "button",
1504
- {
1505
- type: "button",
1506
- "data-slot-id": h.key,
1507
- disabled: !h.available,
1508
- "aria-pressed": w,
1509
- "aria-label": r("booking.slotAvailableLabel", {
1510
- time: h.time
1511
- }),
1512
- onClick: () => h.available && i(h),
1513
- className: Ja({ state: A }),
1514
- children: h.time
1515
- },
1516
- h.key
1517
- );
1518
- })
1519
- }
1520
- )
1521
- ]
1522
- },
1523
- c
1524
- );
1525
- })
1526
- ] });
1527
- }
1528
- const Ae = 4;
1529
- function Qa({
1530
- availableDates: e,
1531
- availableSlots: t,
1532
- value: a,
1533
- onChange: i,
1534
- onDateSelect: n,
1535
- onWindowChange: o,
1536
- loadingDates: r,
1537
- loadingSlots: u,
1538
- locale: m,
1539
- agentIdBase: d
1540
- }) {
1541
- const l = C(() => le(/* @__PURE__ */ new Date()), []), [c, x] = q(() => {
1542
- if (a.date) {
1543
- const y = le($(a.date));
1544
- if (!ce(l, y)) return y;
1545
- }
1546
- if (e.length > 0) {
1547
- const y = le($(e[0]));
1548
- if (ce(y, l)) return y;
1549
- }
1550
- return l;
1551
- }), S = C(
1552
- () => je(c, Ae - 1),
1553
- [c]
1554
- ), h = C(() => Array.from({ length: Ae }, (y, _) => {
1555
- const T = je(c, _), O = se(T), R = (t[O] ?? []).map((V) => ({
1556
- id: V.key,
1557
- // SlotGrid formats `start` as a time via Intl.DateTimeFormat —
1558
- // compose a full ISO from the column's date + the slot's HH:mm
1559
- // so the locale-formatter has a real timestamp to work with.
1560
- start: `${O}T${V.time}:00`,
1561
- available: V.available
1562
- }));
1563
- return { date: O, slots: R };
1564
- }), [c, t]), w = ce(c, l), A = !0, N = H(() => {
1565
- x((y) => {
1566
- const _ = Gt(y, Ae);
1567
- return ce(l, _) ? l : _;
1568
- });
1569
- }, [l]), k = H(() => {
1570
- x((y) => je(y, Ae));
1571
- }, []);
1572
- U(() => {
1573
- if (e.length === 0) return;
1574
- const y = le($(e[0]));
1575
- !ce(y, l) || e.some((T) => {
1576
- const O = le($(T));
1577
- return !ce(O, S) && !qt(O, c);
1578
- }) || x(y);
1579
- }, [e]), U(() => {
1580
- o == null || o(se(c), se(S));
1581
- }, [c, S, o]);
1582
- const b = H(
1583
- (y, _) => {
1584
- const T = typeof _.date == "string" ? _.date : se(_.date);
1585
- i({
1586
- ...vt(Ee(a, T), y.id)
1587
- }), n == null || n(T);
1588
- },
1589
- [i, n, a]
1590
- ), p = r || u ? "loading" : "default", I = h.some((y) => y.slots.length > 0), M = e[0];
1591
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1592
- !I && !!M ? /* @__PURE__ */ s(
1593
- Je,
1594
- {
1595
- nextAvailableDate: M,
1596
- onJump: () => x(le($(M))),
1597
- locale: m
1598
- }
1599
- ) : null,
1600
- /* @__PURE__ */ s(
1601
- jt,
1602
- {
1603
- id: d ? `${d}-slots` : void 0,
1604
- days: h,
1605
- state: p,
1606
- selectedSlotId: a.slotKey,
1607
- maxInitialSlotsPerDay: 6,
1608
- locale: m,
1609
- hasPrevious: w,
1610
- hasNext: A,
1611
- onSlotSelect: b,
1612
- onPreviousDays: N,
1613
- onNextDays: k
1614
- }
1615
- )
1616
- ] });
1617
- }
1618
- function kt(e) {
1619
- const {
1620
- inputs: t,
1621
- value: a,
1622
- onChange: i,
1623
- onDateSelect: n,
1624
- onWindowChange: o,
1625
- loadingDates: r,
1626
- loadingSlots: u,
1627
- locale: m,
1628
- datePickerStyle: d,
1629
- agentIdBase: l
1630
- } = e;
1631
- return d === "four-day-grid" ? /* @__PURE__ */ s(
1632
- Qa,
1633
- {
1634
- availableDates: t.availableDates,
1635
- availableSlots: t.availableSlots,
1636
- value: a,
1637
- onChange: i,
1638
- onDateSelect: n,
1639
- onWindowChange: o,
1640
- loadingDates: r,
1641
- loadingSlots: u,
1642
- locale: m,
1643
- agentIdBase: l
1644
- }
1645
- ) : /* @__PURE__ */ s(
1646
- Ga,
1647
- {
1648
- availableDates: t.availableDates,
1649
- selectedDate: a.date,
1650
- onSelectDate: (c) => {
1651
- i(Ee(a, c)), n == null || n(c);
1652
- },
1653
- locale: m,
1654
- loading: r ?? u
1655
- }
1656
- );
1657
- }
1658
- function xt(e) {
1659
- const { inputs: t, value: a, onChange: i, loadingSlots: n, locale: o, datePickerStyle: r } = e;
1660
- return r === "four-day-grid" || !a.date ? null : /* @__PURE__ */ s(
1661
- Xa,
1662
- {
1663
- date: a.date,
1664
- slots: t.availableSlots[a.date] ?? [],
1665
- selectedSlotKey: a.slotKey,
1666
- onSelect: (u) => i(vt(a, u.key)),
1667
- loading: n,
1668
- locale: o
1669
- }
1670
- );
1671
- }
1672
- function St({ value: e, onChange: t }) {
1673
- const { t: a } = B(), i = [
1674
- { value: "private", label: a("booking.insurance.private") },
1675
- { value: "public", label: a("booking.insurance.public") }
1676
- ];
1677
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1678
- /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: a("booking.insurance.heading") }),
1679
- /* @__PURE__ */ s(
1680
- Be,
1681
- {
1682
- options: i,
1683
- value: e ?? "",
1684
- onValueChange: (n) => {
1685
- (n === "private" || n === "public") && t(n);
1686
- },
1687
- placeholder: a("booking.insurance.placeholder"),
1688
- "aria-label": a("booking.insurance.heading")
1689
- }
1690
- )
1691
- ] });
1692
- }
1693
- function It({
1694
- specialties: e,
1695
- value: t,
1696
- valueIds: a,
1697
- onChange: i,
1698
- onChangeIds: n,
1699
- pickerStyle: o = "select"
1700
- }) {
1701
- const { t: r } = B(), u = e.map((d) => ({
1702
- value: d.id,
1703
- label: d.label
1704
- })), m = /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: r("booking.specialty.heading") });
1705
- return o === "multi-select" && n ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1706
- m,
1707
- /* @__PURE__ */ s(
1708
- Ue,
1709
- {
1710
- options: u,
1711
- value: a ?? [],
1712
- onChange: n,
1713
- placeholder: r("booking.specialty.placeholder"),
1714
- "aria-label": r("booking.specialty.heading"),
1715
- allowClear: !0
1716
- }
1717
- )
1718
- ] }) : o === "combobox" ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1719
- m,
1720
- /* @__PURE__ */ s(
1721
- Ge,
1722
- {
1723
- options: u,
1724
- value: t ?? "",
1725
- onValueChange: (d) => i(d === "" ? "" : d),
1726
- placeholder: r("booking.specialty.placeholder"),
1727
- "aria-label": r("booking.specialty.heading"),
1728
- clearable: !0
1729
- }
1730
- )
1731
- ] }) : /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1732
- m,
1733
- /* @__PURE__ */ s(
1734
- Be,
1735
- {
1736
- options: u,
1737
- value: t ?? "",
1738
- onValueChange: (d) => i(d),
1739
- placeholder: r("booking.specialty.placeholder"),
1740
- "aria-label": r("booking.specialty.heading")
1741
- }
1742
- )
1743
- ] });
1744
- }
1745
- function Nt({
1746
- services: e,
1747
- value: t,
1748
- valueIds: a,
1749
- onChange: i,
1750
- onChangeIds: n,
1751
- pickerStyle: o,
1752
- compact: r
1753
- }) {
1754
- const { t: u } = B(), m = o ?? (r ? "select" : "cards"), d = e.map((c) => ({
1755
- value: c.id,
1756
- label: `${c.label} · ${yt(c) ?? u("booking.serviceSummary", {
1757
- minutes: c.durationMin
1758
- })}`
1759
- })), l = /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: u("booking.service.heading") });
1760
- return m === "multi-select" && n ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1761
- l,
1762
- /* @__PURE__ */ s(
1763
- Ue,
1764
- {
1765
- options: d,
1766
- value: a ?? [],
1767
- onChange: n,
1768
- placeholder: u("booking.service.placeholder"),
1769
- "aria-label": u("booking.service.heading"),
1770
- allowClear: !0
1771
- }
1772
- )
1773
- ] }) : m === "combobox" ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1774
- l,
1775
- /* @__PURE__ */ s(
1776
- Ge,
1777
- {
1778
- options: d,
1779
- value: t ?? "",
1780
- onValueChange: (c) => i(c === "" ? "" : c),
1781
- placeholder: u("booking.service.placeholder"),
1782
- "aria-label": u("booking.service.heading"),
1783
- clearable: !0
1784
- }
1785
- )
1786
- ] }) : m === "select" ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1787
- l,
1788
- /* @__PURE__ */ s(
1789
- Be,
1790
- {
1791
- options: d,
1792
- value: t ?? "",
1793
- onValueChange: (c) => i(c),
1794
- placeholder: u("booking.service.placeholder"),
1795
- "aria-label": u("booking.service.heading")
1796
- }
1797
- )
1798
- ] }) : /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1799
- l,
1800
- /* @__PURE__ */ s(
1801
- Ya,
1802
- {
1803
- services: e,
1804
- selectedServiceId: t,
1805
- onSelect: i
1806
- }
1807
- )
1808
- ] });
1809
- }
1810
- function wt({
1811
- operators: e,
1812
- value: t,
1813
- valueIds: a,
1814
- onChange: i,
1815
- onChangeIds: n,
1816
- pickerStyle: o = "select"
1817
- }) {
1818
- const { t: r } = B(), u = /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: r("booking.operator.heading") });
1819
- if (o === "multi-select" && n) {
1820
- const d = e.map((l) => ({
1821
- value: l.id,
1822
- label: l.name
1823
- }));
1824
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1825
- u,
1826
- /* @__PURE__ */ s(
1827
- Ue,
1828
- {
1829
- options: d,
1830
- value: a ?? [],
1831
- onChange: n,
1832
- placeholder: r("booking.operator.placeholder"),
1833
- "aria-label": r("booking.operator.heading"),
1834
- allowClear: !0
1835
- }
1836
- )
1837
- ] });
1838
- }
1839
- const m = [
1840
- { value: Q, label: r("booking.operator.all") },
1841
- ...e.map((d) => ({ value: d.id, label: d.name }))
1842
- ];
1843
- return o === "combobox" ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1844
- u,
1845
- /* @__PURE__ */ s(
1846
- Ge,
1847
- {
1848
- options: m,
1849
- value: t ?? Q,
1850
- onValueChange: (d) => i(d === "" ? Q : d),
1851
- placeholder: r("booking.operator.placeholder"),
1852
- "aria-label": r("booking.operator.heading"),
1853
- clearable: !0
1854
- }
1855
- )
1856
- ] }) : /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
1857
- u,
1858
- /* @__PURE__ */ s(
1859
- Be,
1860
- {
1861
- options: m,
1862
- value: t ?? Q,
1863
- onValueChange: (d) => i(d),
1864
- placeholder: r("booking.operator.placeholder"),
1865
- "aria-label": r("booking.operator.heading")
1866
- }
1867
- )
1868
- ] });
1869
- }
1870
- function Ct({
1871
- customSlot: e
1872
- }) {
1873
- const { t } = B();
1874
- return e ? /* @__PURE__ */ s(X, { children: e }) : /* @__PURE__ */ f(j, { variant: "warning", children: [
1875
- /* @__PURE__ */ s(j.Title, { as: "h4", children: t("booking.onboardingIncomplete.title") }),
1876
- /* @__PURE__ */ s(j.Description, { children: t("booking.onboardingIncomplete.description") })
1877
- ] });
1878
- }
1879
- function Je({
1880
- nextAvailableDate: e,
1881
- onJump: t,
1882
- locale: a
1883
- }) {
1884
- const { t: i } = B(), n = C(() => {
1885
- try {
1886
- return new Intl.DateTimeFormat(a, { dateStyle: "long" }).format(
1887
- $(e)
1888
- );
1889
- } catch {
1890
- return e;
1891
- }
1892
- }, [e, a]);
1893
- return /* @__PURE__ */ f(j, { variant: "info", children: [
1894
- /* @__PURE__ */ s(j.Description, { children: i("booking.nextAvailable.description", { date: n }) }),
1895
- /* @__PURE__ */ s(j.Action, { children: /* @__PURE__ */ s(ne, { intent: "secondary", size: "sm", onClick: t, children: i("booking.nextAvailable.cta") }) })
1896
- ] });
1897
- }
1898
- function es({
1899
- snapshot: e,
1900
- operators: t,
1901
- specialties: a,
1902
- services: i,
1903
- locale: n,
1904
- mode: o,
1905
- showModify: r,
1906
- onReset: u,
1907
- onModify: m
1908
- }) {
1909
- const { t: d } = B(), c = (e.details.confirmationChannels ?? ["email"]).map(
1910
- (N) => d(`booking.confirmation.channel.${N}`)
1911
- ), x = o === "demo" ? d("booking.success.descriptionDemo") : c.length > 1 ? d("booking.success.descriptionMultiple", {
1912
- channels: c.join(" · ")
1913
- }) : d("booking.success.descriptionSingle", { channel: c[0] }), S = C(() => {
1914
- if (e.date)
1915
- try {
1916
- return new Intl.DateTimeFormat(n, {
1917
- weekday: "long",
1918
- day: "numeric",
1919
- month: "long"
1920
- }).format($(e.date));
1921
- } catch {
1922
- return e.date;
1923
- }
1924
- }, [e.date, n]), h = e.operatorId ? t.find((N) => N.id === e.operatorId) : void 0, w = e.specialtyId ? a.find((N) => N.id === e.specialtyId) : void 0, A = e.serviceId ? i.find((N) => N.id === e.serviceId) : void 0;
1925
- return /* @__PURE__ */ f(
1926
- "div",
1927
- {
1928
- "data-component": "booking-success",
1929
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
1930
- children: [
1931
- /* @__PURE__ */ f(j, { variant: "success", children: [
1932
- /* @__PURE__ */ s(j.Title, { as: "h3", children: d("booking.success.heading") }),
1933
- /* @__PURE__ */ s(j.Description, { children: x })
1934
- ] }),
1935
- /* @__PURE__ */ s("div", { className: "ds:rounded-[var(--radius-md)] ds:bg-[var(--secondary)] ds:p-[var(--spacing-md)]", children: /* @__PURE__ */ f("dl", { className: "ds:grid ds:grid-cols-[auto_minmax(0,1fr)] ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)] ds:m-0", children: [
1936
- w ? /* @__PURE__ */ f(X, { children: [
1937
- /* @__PURE__ */ s("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: d("booking.success.summarySpecialty") }),
1938
- /* @__PURE__ */ s("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: w.label })
1939
- ] }) : null,
1940
- A ? /* @__PURE__ */ f(X, { children: [
1941
- /* @__PURE__ */ s("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: d("booking.success.summaryService") }),
1942
- /* @__PURE__ */ s("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: A.label })
1943
- ] }) : null,
1944
- S ? /* @__PURE__ */ f(X, { children: [
1945
- /* @__PURE__ */ s("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: d("booking.success.summaryDate") }),
1946
- /* @__PURE__ */ s("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: S })
1947
- ] }) : null,
1948
- /* @__PURE__ */ s("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: d("booking.success.summaryTime") }),
1949
- /* @__PURE__ */ s("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: e.slot.time }),
1950
- h ? /* @__PURE__ */ f(X, { children: [
1951
- /* @__PURE__ */ s("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: d("booking.success.summaryProvider") }),
1952
- /* @__PURE__ */ s("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: h.name })
1953
- ] }) : null
1954
- ] }) }),
1955
- /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
1956
- /* @__PURE__ */ s(ne, { intent: "secondary", size: "md", onClick: u, children: d("booking.success.bookAnother") }),
1957
- r ? /* @__PURE__ */ s(ne, { intent: "ghost", size: "md", onClick: m, children: d("booking.success.modifyBooking") }) : null
1958
- ] })
1959
- ]
1960
- }
1961
- );
1962
- }
1963
- function Dt({ customSlot: e }) {
1964
- const { t } = B();
1965
- return e ? /* @__PURE__ */ s(X, { children: e }) : /* @__PURE__ */ s(
1966
- dt,
1967
- {
1968
- variant: "no-results",
1969
- title: t("booking.emptyServices.title"),
1970
- description: t("booking.emptyServices.description")
1971
- }
1972
- );
1973
- }
1974
- function ts(e) {
1975
- const {
1976
- cascade: t,
1977
- inputs: a,
1978
- value: i,
1979
- onChange: n,
1980
- onSubmit: o,
1981
- emptyServicesSlot: r,
1982
- onboardingIncompleteSlot: u,
1983
- loadingDates: m,
1984
- loadingSlots: d,
1985
- onDateSelect: l,
1986
- onWindowChange: c,
1987
- datePickerStyle: x,
1988
- specialtyPickerStyle: S,
1989
- servicePickerStyle: h,
1990
- operatorPickerStyle: w,
1991
- submitting: A,
1992
- locale: N,
1993
- detailsProps: k,
1994
- agentIdBase: b
1995
- } = e, { t: p } = B();
1996
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
1997
- t.gates.insurance ? /* @__PURE__ */ s(
1998
- St,
1999
- {
2000
- value: i.insuranceType,
2001
- onChange: (I) => n(ct(i, I))
2002
- }
2003
- ) : null,
2004
- t.gates.specialty ? /* @__PURE__ */ s(
2005
- It,
2006
- {
2007
- specialties: t.filtered.specialties,
2008
- value: i.specialtyId,
2009
- valueIds: i.specialtyIds,
2010
- onChange: (I) => n(ut(i, I)),
2011
- onChangeIds: (I) => n(pt(i, I)),
2012
- pickerStyle: S
2013
- }
2014
- ) : null,
2015
- t.gates.service ? t.filtered.services.length === 0 ? /* @__PURE__ */ s(Dt, { customSlot: r }) : /* @__PURE__ */ s(
2016
- Nt,
2017
- {
2018
- services: t.filtered.services,
2019
- value: i.serviceId,
2020
- valueIds: i.serviceIds,
2021
- onChange: (I) => n(mt(i, I)),
2022
- onChangeIds: (I) => n(gt(i, I)),
2023
- pickerStyle: h
2024
- }
2025
- ) : null,
2026
- t.gates.onboardingIncomplete ? /* @__PURE__ */ s(Ct, { customSlot: u }) : null,
2027
- t.gates.operator ? /* @__PURE__ */ s(
2028
- wt,
2029
- {
2030
- operators: t.filtered.operators,
2031
- value: i.operatorId,
2032
- valueIds: i.operatorIds,
2033
- onChange: (I) => n(ft(i, I)),
2034
- onChangeIds: (I) => n(ht(i, I)),
2035
- pickerStyle: w
2036
- }
2037
- ) : null,
2038
- t.gates.date ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2039
- /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: p("booking.date.heading") }),
2040
- a.availableDates.length === 0 && a.nextAvailableDate ? /* @__PURE__ */ s(
2041
- Je,
2042
- {
2043
- nextAvailableDate: a.nextAvailableDate,
2044
- onJump: () => n(Ee(i, a.nextAvailableDate)),
2045
- locale: N
2046
- }
2047
- ) : kt({
2048
- inputs: a,
2049
- value: i,
2050
- onChange: n,
2051
- onDateSelect: l,
2052
- onWindowChange: c,
2053
- loadingDates: m,
2054
- loadingSlots: d,
2055
- locale: N,
2056
- datePickerStyle: x,
2057
- agentIdBase: b
2058
- })
2059
- ] }) : null,
2060
- t.gates.slot && i.date && x === "month-calendar" ? /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2061
- /* @__PURE__ */ s("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: p("booking.slot.heading") }),
2062
- xt({
2063
- inputs: a,
2064
- value: i,
2065
- onChange: n,
2066
- loadingSlots: d,
2067
- locale: N,
2068
- datePickerStyle: x
2069
- })
2070
- ] }) : null,
2071
- t.gates.details && t.selectedSlot ? /* @__PURE__ */ s(
2072
- Ye,
2073
- {
2074
- ...k,
2075
- value: i.details ?? {},
2076
- onChange: (I) => n({ ...i, details: I }),
2077
- onSubmit: o,
2078
- submitting: A,
2079
- defaultPhoneCountry: e.policy.country
2080
- }
2081
- ) : null
2082
- ] });
2083
- }
2084
- function K(e, t, a = {}) {
2085
- const {
2086
- cascade: i,
2087
- inputs: n,
2088
- value: o,
2089
- onChange: r,
2090
- onSubmit: u,
2091
- emptyServicesSlot: m,
2092
- onboardingIncompleteSlot: d,
2093
- loadingDates: l,
2094
- loadingSlots: c,
2095
- onDateSelect: x,
2096
- onWindowChange: S,
2097
- datePickerStyle: h,
2098
- specialtyPickerStyle: w,
2099
- servicePickerStyle: A,
2100
- operatorPickerStyle: N,
2101
- submitting: k,
2102
- locale: b,
2103
- detailsProps: p,
2104
- policy: I,
2105
- agentIdBase: M
2106
- } = t;
2107
- switch (e) {
2108
- case 1:
2109
- return /* @__PURE__ */ s(
2110
- St,
2111
- {
2112
- value: o.insuranceType,
2113
- onChange: (g) => r(ct(o, g))
2114
- }
2115
- );
2116
- case 2:
2117
- return /* @__PURE__ */ s(
2118
- It,
2119
- {
2120
- specialties: i.filtered.specialties,
2121
- value: o.specialtyId,
2122
- valueIds: o.specialtyIds,
2123
- onChange: (g) => r(ut(o, g)),
2124
- onChangeIds: (g) => r(pt(o, g)),
2125
- pickerStyle: w
2126
- }
2127
- );
2128
- case 3:
2129
- return i.filtered.services.length === 0 ? /* @__PURE__ */ s(Dt, { customSlot: m }) : i.gates.onboardingIncomplete ? /* @__PURE__ */ s(Ct, { customSlot: d }) : /* @__PURE__ */ s(
2130
- Nt,
2131
- {
2132
- services: i.filtered.services,
2133
- value: o.serviceId,
2134
- valueIds: o.serviceIds,
2135
- onChange: (g) => r(mt(o, g)),
2136
- onChangeIds: (g) => r(gt(o, g)),
2137
- pickerStyle: A,
2138
- compact: a.compactService
2139
- }
2140
- );
2141
- case 4:
2142
- return /* @__PURE__ */ s(
2143
- wt,
2144
- {
2145
- operators: i.filtered.operators,
2146
- value: o.operatorId,
2147
- valueIds: o.operatorIds,
2148
- onChange: (g) => r(ft(o, g)),
2149
- onChangeIds: (g) => r(ht(o, g)),
2150
- pickerStyle: N
2151
- }
2152
- );
2153
- case 5:
2154
- return n.availableDates.length === 0 && n.nextAvailableDate ? /* @__PURE__ */ s(
2155
- Je,
2156
- {
2157
- nextAvailableDate: n.nextAvailableDate,
2158
- onJump: () => r(Ee(o, n.nextAvailableDate)),
2159
- locale: b
2160
- }
2161
- ) : kt({
2162
- inputs: n,
2163
- value: o,
2164
- onChange: r,
2165
- onDateSelect: x,
2166
- onWindowChange: S,
2167
- loadingDates: l,
2168
- loadingSlots: c,
2169
- locale: b,
2170
- datePickerStyle: h,
2171
- agentIdBase: M
2172
- });
2173
- case 6:
2174
- return xt({
2175
- inputs: n,
2176
- value: o,
2177
- onChange: r,
2178
- loadingSlots: c,
2179
- locale: b,
2180
- datePickerStyle: h
2181
- });
2182
- case 7:
2183
- return i.selectedSlot ? /* @__PURE__ */ s(
2184
- Ye,
2185
- {
2186
- ...p,
2187
- value: o.details ?? {},
2188
- onChange: (g) => r({ ...o, details: g }),
2189
- onSubmit: u,
2190
- submitting: k,
2191
- defaultPhoneCountry: I.country
2192
- }
2193
- ) : null;
2194
- /* c8 ignore next 2 */
2195
- default:
2196
- return null;
2197
- }
2198
- }
2199
- function Ze() {
2200
- const { t: e } = B();
2201
- return C(
2202
- () => ({
2203
- 1: e("booking.insurance.heading"),
2204
- 2: e("booking.specialty.heading"),
2205
- 3: e("booking.service.heading"),
2206
- 4: e("booking.operator.heading"),
2207
- 5: e("booking.date.heading"),
2208
- 6: e("booking.slot.heading"),
2209
- 7: e("booking.details.heading")
2210
- }),
2211
- [e]
2212
- );
2213
- }
2214
- function as(e) {
2215
- const { cascade: t, value: a, activeStep: i, setActiveStep: n, datePickerStyle: o } = e, r = Ze(), u = C(
2216
- () => o === "four-day-grid" ? t.visibleSteps.filter((l) => l !== 6) : t.visibleSteps,
2217
- [t.visibleSteps, o]
2218
- ), m = C(
2219
- () => u.map((l) => ({
2220
- label: r[l],
2221
- summary: Mt(l, a, t),
2222
- status: ke(l, a) && l < t.currentStep ? "completed" : void 0,
2223
- content: K(l, e, { compactService: !0 })
2224
- })),
2225
- [u, a, r, t, e]
2226
- ), d = Math.max(0, t.visibleSteps.indexOf(i));
2227
- return /* @__PURE__ */ s(
2228
- zt,
2229
- {
2230
- activeStep: d,
2231
- steps: m,
2232
- onStepChange: (l) => {
2233
- const c = t.visibleSteps[l];
2234
- c && n(c);
2235
- }
2236
- }
2237
- );
2238
- }
2239
- function ke(e, t) {
2240
- switch (e) {
2241
- case 1:
2242
- return t.insuranceType !== void 0;
2243
- case 2:
2244
- return t.specialtyId !== void 0;
2245
- case 3:
2246
- return t.serviceId !== void 0;
2247
- case 4:
2248
- return t.operatorId !== void 0;
2249
- case 5:
2250
- return t.date !== void 0;
2251
- case 6:
2252
- return t.slotKey !== void 0;
2253
- case 7:
2254
- return !1;
2255
- }
2256
- }
2257
- function Mt(e, t, a) {
2258
- var i;
2259
- if (ke(e, t))
2260
- switch (e) {
2261
- case 1:
2262
- return t.insuranceType;
2263
- case 2: {
2264
- const n = a.filtered.specialties.find(
2265
- (o) => o.id === t.specialtyId
2266
- );
2267
- return n == null ? void 0 : n.label;
2268
- }
2269
- case 3: {
2270
- const n = a.filtered.services.find(
2271
- (o) => o.id === t.serviceId
2272
- );
2273
- return n == null ? void 0 : n.label;
2274
- }
2275
- case 4: {
2276
- const n = He(t);
2277
- if (!n) return;
2278
- const o = a.filtered.operators.find((r) => r.id === n);
2279
- return o == null ? void 0 : o.name;
2280
- }
2281
- case 5:
2282
- return t.date;
2283
- case 6:
2284
- return (i = a.selectedSlot) == null ? void 0 : i.time;
2285
- case 7:
2286
- return;
2287
- }
2288
- }
2289
- function ss(e) {
2290
- const { cascade: t, value: a, setActiveStep: i } = e, { t: n } = B(), o = Ze(), r = t.visibleSteps.filter(
2291
- (m) => m === 1 || m === 2 || m === 3 || m === 4
2292
- ), u = r.some(
2293
- (m) => !ke(m, a)
2294
- );
2295
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2296
- u ? r.filter((m) => !ke(m, a)).slice(0, 1).map((m) => /* @__PURE__ */ s("div", { children: K(m, e, { compactService: !0 }) }, `csf-${m}`)) : /* @__PURE__ */ s(
2297
- "div",
2298
- {
2299
- role: "group",
2300
- "aria-label": n("booking.regionLabel"),
2301
- className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
2302
- children: r.map((m) => {
2303
- const d = Mt(m, a, t);
2304
- return d ? /* @__PURE__ */ f(
2305
- ne,
2306
- {
2307
- intent: "tonal",
2308
- size: "sm",
2309
- onClick: () => i(m),
2310
- children: [
2311
- o[m],
2312
- ": ",
2313
- d
2314
- ]
2315
- },
2316
- `csc-${m}`
2317
- ) : null;
2318
- })
2319
- }
2320
- ),
2321
- !u && t.gates.date ? (
2322
- // four-day-grid embeds slots inline with the day strip — the
2323
- // historic 2-col date|slot split collapses to a single column
2324
- // so the picker spans the full width instead of orphaning an
2325
- // empty right cell.
2326
- e.datePickerStyle === "four-day-grid" ? /* @__PURE__ */ s("div", { children: K(5, e) }) : /* @__PURE__ */ f("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:md:grid-cols-2", children: [
2327
- /* @__PURE__ */ s("div", { className: "ds:min-w-0", children: K(5, e) }),
2328
- /* @__PURE__ */ s("div", { className: "ds:min-w-0", children: a.date ? K(6, e) : null })
2329
- ] })
2330
- ) : null,
2331
- t.gates.details ? /* @__PURE__ */ s("div", { children: K(7, e) }) : null
2332
- ] });
2333
- }
2334
- function is(e) {
2335
- const { cascade: t, datePickerStyle: a } = e, i = t.visibleSteps.filter(
2336
- (o) => o === 1 || o === 2 || o === 3 || o === 4
2337
- );
2338
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2339
- /* @__PURE__ */ f(
2340
- "div",
2341
- {
2342
- className: a === "four-day-grid" ? "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]" : "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:md:grid-cols-2",
2343
- children: [
2344
- /* @__PURE__ */ s("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: i.map((o) => /* @__PURE__ */ s("div", { children: K(o, e, { compactService: !0 }) }, `fbf-${o}`)) }),
2345
- /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2346
- t.gates.date ? K(5, e) : null,
2347
- t.gates.slot && e.value.date ? K(6, e) : null
2348
- ] })
2349
- ]
2350
- }
2351
- ),
2352
- t.gates.details ? K(7, e) : null
2353
- ] });
2354
- }
2355
- function ns(e) {
2356
- const { cascade: t, value: a, activeStep: i, setActiveStep: n, datePickerStyle: o } = e, { t: r } = B(), u = Ze(), m = C(
2357
- () => o === "four-day-grid" ? t.visibleSteps.filter((h) => h !== 6) : t.visibleSteps,
2358
- [t.visibleSteps, o]
2359
- ), d = Math.max(0, m.indexOf(i)), l = m.length, c = C(
2360
- () => m.map((h) => ({ label: u[h] })),
2361
- [m, u]
2362
- ), x = d > 0, S = d < l - 1 && ke(i, a);
2363
- return /* @__PURE__ */ f("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2364
- /* @__PURE__ */ s(Kt, { activeStep: d, steps: c }),
2365
- /* @__PURE__ */ s("div", { children: K(i, e, { compactService: !0 }) }),
2366
- /* @__PURE__ */ f("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
2367
- /* @__PURE__ */ s(
2368
- ne,
2369
- {
2370
- intent: "ghost",
2371
- size: "md",
2372
- disabled: !x,
2373
- onClick: () => {
2374
- const h = m[d - 1];
2375
- h && n(h);
2376
- },
2377
- children: r("booking.actions.back")
2378
- }
2379
- ),
2380
- i < 7 ? /* @__PURE__ */ s(
2381
- ne,
2382
- {
2383
- intent: "primary",
2384
- size: "md",
2385
- disabled: !S,
2386
- onClick: () => {
2387
- const h = m[d + 1];
2388
- h && n(h);
2389
- },
2390
- children: r("booking.actions.next")
2391
- }
2392
- ) : null
2393
- ] })
2394
- ] });
2395
- }
2396
- const os = [], rs = [], ds = ot(
2397
- ({
2398
- variant: e = "inline-list",
2399
- country: t,
2400
- // No default — the cascade engine treats `undefined` as "auto-on
2401
- // when `specialties` has items" so consumers who pass specialty
2402
- // data without the explicit flag still get the step.
2403
- useSpecialties: a,
2404
- allowOperatorSelection: i = !1,
2405
- lockedOperatorId: n,
2406
- autoSelectSingleService: o = !1,
2407
- specialties: r,
2408
- services: u,
2409
- operators: m,
2410
- availableDates: d,
2411
- availableSlots: l,
2412
- nextAvailableDate: c,
2413
- requireCodiceFiscale: x,
2414
- requireDateOfBirth: S,
2415
- requireInsuranceNumber: h,
2416
- showNote: w,
2417
- showReturningPatientFlag: A,
2418
- privacyPolicyUrl: N,
2419
- termsUrl: k,
2420
- validateCodiceFiscale: b,
2421
- validateInsuranceNumber: p,
2422
- confirmationChannels: I,
2423
- defaultConfirmationChannels: M,
2424
- value: g,
2425
- onChange: y,
2426
- onSubmit: _,
2427
- onStepChange: T,
2428
- onDateSelect: O,
2429
- onWindowChange: E,
2430
- datePickerStyle: R = "month-calendar",
2431
- specialtyPickerStyle: V,
2432
- servicePickerStyle: P,
2433
- operatorPickerStyle: ee,
2434
- loadingDates: G,
2435
- loadingSlots: pe,
2436
- submitting: te,
2437
- submitError: xe,
2438
- mode: Y = "live",
2439
- showModifyOnSuccess: oe = !0,
2440
- surface: me = "flat",
2441
- emptyServicesSlot: Se,
2442
- onboardingIncompleteSlot: Ie,
2443
- "aria-label": Le,
2444
- id: J,
2445
- className: Re,
2446
- ...Ne
2447
- }, we) => {
2448
- const { t: re, i18n: v } = B(), D = e ?? "inline-list", ae = v.language ?? "en", Z = r ?? os, de = m ?? rs;
2449
- U(() => {
2450
- const F = Ea(g, {
2451
- useSpecialties: a,
2452
- lockedOperatorId: n,
2453
- autoSelectSingleService: o,
2454
- specialties: Z,
2455
- services: u
2456
- });
2457
- (F.specialtyId !== g.specialtyId || F.operatorId !== g.operatorId || F.serviceId !== g.serviceId) && y(F);
2458
- }, [
2459
- n,
2460
- a,
2461
- o,
2462
- Z,
2463
- u
2464
- ]);
2465
- const L = C(
2466
- () => Oa({
2467
- country: t,
2468
- useSpecialties: a,
2469
- allowOperatorSelection: i,
2470
- lockedOperatorId: n,
2471
- specialties: Z,
2472
- services: u,
2473
- operators: de,
2474
- availableSlots: l,
2475
- value: g
2476
- }),
2477
- [
2478
- t,
2479
- a,
2480
- i,
2481
- n,
2482
- o,
2483
- Z,
2484
- u,
2485
- de,
2486
- d,
2487
- l,
2488
- g
2489
- ]
2490
- ), [We, ge] = q(
2491
- L.currentStep
2492
- ), Xe = ie(L.currentStep);
2493
- U(() => {
2494
- L.currentStep > Xe.current && ge(L.currentStep), Xe.current = L.currentStep;
2495
- }, [L.currentStep]);
2496
- const [fe, he] = q("idle"), [Ve, Fe] = q(null), Qe = H(
2497
- async (F) => {
2498
- if (!L.selectedSlot) return;
2499
- const ze = {
2500
- slot: L.selectedSlot,
2501
- value: {
2502
- ...g,
2503
- details: F,
2504
- operatorId: He(g) ?? g.operatorId
2505
- },
2506
- details: F
2507
- };
2508
- he("submitting");
2509
- try {
2510
- await _(ze), Fe({
2511
- slot: L.selectedSlot,
2512
- details: F,
2513
- specialtyId: g.specialtyId,
2514
- serviceId: g.serviceId,
2515
- insuranceType: g.insuranceType,
2516
- operatorId: He(g),
2517
- date: g.date
2518
- }), he("success");
2519
- } catch {
2520
- throw he("error"), new Error("Booking submission failed");
2521
- }
2522
- },
2523
- [L.selectedSlot, _, g]
2524
- ), ve = ie(null);
2525
- Pt(we, () => ve.current, []);
2526
- const be = fe === "success" ? 8 : L.currentStep, et = ie(null);
2527
- U(() => {
2528
- if (be !== et.current && (et.current = be, T == null || T(be), be === 8 && ve.current))
2529
- try {
2530
- ve.current.scrollIntoView({
2531
- behavior: "smooth",
2532
- block: "start"
2533
- });
2534
- } catch {
2535
- ve.current.scrollIntoView();
2536
- }
2537
- }, [be, T]);
2538
- const $e = C(
2539
- () => ({
2540
- getVariant: () => D,
2541
- reset: () => {
2542
- y({}), Fe(null), he("idle"), ge(1);
2543
- },
2544
- goToStep: (F) => {
2545
- ge(F);
2546
- }
2547
- }),
2548
- [D, y]
2549
- );
2550
- Ot(Da, $e, J);
2551
- const At = Le ?? re("booking.regionLabel"), Tt = C(() => fe !== "success" || !Ve ? null : /* @__PURE__ */ s(
2552
- es,
2553
- {
2554
- snapshot: Ve,
2555
- operators: de,
2556
- specialties: Z,
2557
- services: u,
2558
- locale: ae,
2559
- mode: Y,
2560
- showModify: oe,
2561
- onReset: () => $e.reset(),
2562
- onModify: () => {
2563
- Fe(null), he("idle"), ge(7);
2564
- }
2565
- }
2566
- ), [
2567
- fe,
2568
- Ve,
2569
- de,
2570
- Z,
2571
- u,
2572
- ae,
2573
- Y,
2574
- oe,
2575
- $e
2576
- ]), _t = C(() => {
2577
- if (fe === "success") return null;
2578
- const F = D === "accordion" ? as : D === "calendar" ? ss : D === "flexible" ? is : D === "progress" ? ns : ts, ze = {
2579
- cascade: L,
2580
- inputs: {
2581
- specialties: Z,
2582
- services: u,
2583
- operators: de,
2584
- availableDates: d,
2585
- availableSlots: l,
2586
- nextAvailableDate: c
2587
- },
2588
- value: g,
2589
- onChange: y,
2590
- onSubmit: Qe,
2591
- policy: { country: t, lockedOperatorId: n },
2592
- detailsProps: {
2593
- requireCodiceFiscale: x,
2594
- requireDateOfBirth: S,
2595
- requireInsuranceNumber: h,
2596
- insuranceType: g.insuranceType,
2597
- showNote: w,
2598
- showReturningPatientFlag: A,
2599
- privacyPolicyUrl: N,
2600
- termsUrl: k,
2601
- validateCodiceFiscale: b,
2602
- validateInsuranceNumber: p,
2603
- confirmationChannels: I,
2604
- defaultConfirmationChannels: M,
2605
- submitError: xe
2606
- },
2607
- emptyServicesSlot: Se,
2608
- onboardingIncompleteSlot: Ie,
2609
- loadingDates: G,
2610
- loadingSlots: pe,
2611
- onDateSelect: O,
2612
- onWindowChange: E,
2613
- datePickerStyle: R,
2614
- specialtyPickerStyle: V,
2615
- servicePickerStyle: P,
2616
- operatorPickerStyle: ee,
2617
- submitting: te,
2618
- locale: ae,
2619
- activeStep: We,
2620
- setActiveStep: ge,
2621
- agentIdBase: J
2622
- };
2623
- return /* @__PURE__ */ s(F, { ...ze });
2624
- }, [
2625
- fe,
2626
- D,
2627
- L,
2628
- Z,
2629
- u,
2630
- de,
2631
- d,
2632
- l,
2633
- c,
2634
- g,
2635
- y,
2636
- Qe,
2637
- t,
2638
- n,
2639
- x,
2640
- S,
2641
- h,
2642
- xe,
2643
- w,
2644
- A,
2645
- N,
2646
- k,
2647
- b,
2648
- p,
2649
- I,
2650
- M,
2651
- Se,
2652
- Ie,
2653
- G,
2654
- pe,
2655
- O,
2656
- E,
2657
- R,
2658
- V,
2659
- P,
2660
- ee,
2661
- te,
2662
- ae,
2663
- We,
2664
- J
2665
- ]);
2666
- return /* @__PURE__ */ f(
2667
- "div",
2668
- {
2669
- ref: ve,
2670
- role: "region",
2671
- "aria-label": At,
2672
- id: J,
2673
- "data-component": "booking",
2674
- "data-component-id": J,
2675
- "data-variant": D,
2676
- className: $a({
2677
- variant: D,
2678
- surface: me,
2679
- className: Re
2680
- }),
2681
- ...Ne,
2682
- children: [
2683
- /* @__PURE__ */ f(
2684
- "div",
2685
- {
2686
- className: [
2687
- "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
2688
- "ds:rounded-[var(--radius-md)]",
2689
- "ds:bg-[color-mix(in_srgb,var(--primary)_35%,var(--background))]",
2690
- "ds:bg-[image:var(--gradient-hero-brand)]",
2691
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
2692
- "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]"
2693
- ].join(" "),
2694
- children: [
2695
- /* @__PURE__ */ s("h2", { className: "type-title-card ds:text-[var(--foreground)] ds:m-0", children: re("booking.regionLabel") }),
2696
- /* @__PURE__ */ s("p", { className: "type-body-sm ds:text-[var(--muted-foreground)] ds:m-0", children: re("booking.headingSubtitle") })
2697
- ]
2698
- }
2699
- ),
2700
- Tt ?? _t
2701
- ]
2702
- }
2703
- );
2704
- }
2705
- );
2706
- ds.displayName = "Booking";
2707
- export {
2708
- ds as B,
2709
- qe as C,
2710
- Q as O,
2711
- Da as b
2712
- };
2713
- //# sourceMappingURL=booking-DHkKcUIl.js.map