@alfadocs/ui-kit-debug 1.81.0 → 1.82.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 (136) hide show
  1. package/dist/_chunks/{anamnesis-summary-rows-BYtpwCyn.js → anamnesis-summary-rows-6gMuu0ZK.js} +2 -2
  2. package/dist/_chunks/{anamnesis-summary-rows-BYtpwCyn.js.map → anamnesis-summary-rows-6gMuu0ZK.js.map} +1 -1
  3. package/dist/_chunks/{balance-badge-cell-NoEPeFdj.js → balance-badge-cell-BHXJS8Ga.js} +2 -2
  4. package/dist/_chunks/{balance-badge-cell-NoEPeFdj.js.map → balance-badge-cell-BHXJS8Ga.js.map} +1 -1
  5. package/dist/_chunks/booking-dsgiuhKg.js +4304 -0
  6. package/dist/_chunks/booking-dsgiuhKg.js.map +1 -0
  7. package/dist/_chunks/{link-cell-renderer-Dwp_DCYT.js → link-cell-renderer-C0ynDik7.js} +2 -2
  8. package/dist/_chunks/{link-cell-renderer-Dwp_DCYT.js.map → link-cell-renderer-C0ynDik7.js.map} +1 -1
  9. package/dist/_chunks/{multi-select-IOVnOGlP.js → multi-select-i5MFRpXg.js} +153 -146
  10. package/dist/_chunks/multi-select-i5MFRpXg.js.map +1 -0
  11. package/dist/_chunks/{otp-input-BgEZi0py.js → otp-input-gV1446Dw.js} +70 -70
  12. package/dist/_chunks/otp-input-gV1446Dw.js.map +1 -0
  13. package/dist/_chunks/{registration-form-e9oYscB7.js → registration-form-DmP3YUfp.js} +2 -2
  14. package/dist/_chunks/{registration-form-e9oYscB7.js.map → registration-form-DmP3YUfp.js.map} +1 -1
  15. package/dist/agent-catalog.json +4 -4
  16. package/dist/agent-i18n/en.json +1 -1
  17. package/dist/components/booking/booking-types.d.ts +35 -2
  18. package/dist/components/booking/booking-types.d.ts.map +1 -1
  19. package/dist/components/booking/booking.d.ts.map +1 -1
  20. package/dist/components/booking/code-step.d.ts +4 -2
  21. package/dist/components/booking/code-step.d.ts.map +1 -1
  22. package/dist/components/booking/details-form.d.ts +2 -0
  23. package/dist/components/booking/details-form.d.ts.map +1 -1
  24. package/dist/components/booking/handover.d.ts +12 -0
  25. package/dist/components/booking/handover.d.ts.map +1 -0
  26. package/dist/components/booking/index.js +1 -1
  27. package/dist/components/booking/reserved.d.ts +24 -0
  28. package/dist/components/booking/reserved.d.ts.map +1 -0
  29. package/dist/components/booking/use-booking-payment.d.ts +3 -1
  30. package/dist/components/booking/use-booking-payment.d.ts.map +1 -1
  31. package/dist/components/data-table/index.js +1 -1
  32. package/dist/components/multi-select/index.js +1 -1
  33. package/dist/components/multi-select/multi-select.d.ts.map +1 -1
  34. package/dist/components/otp-input/index.js +1 -1
  35. package/dist/components/otp-input/otp-input.d.ts +1 -1
  36. package/dist/components/otp-input/otp-input.d.ts.map +1 -1
  37. package/dist/components/patient-table/index.js +1 -1
  38. package/dist/i18n/locales/ar.d.ts +8 -0
  39. package/dist/i18n/locales/ar.d.ts.map +1 -1
  40. package/dist/i18n/locales/ar.js +8 -0
  41. package/dist/i18n/locales/ar.js.map +1 -1
  42. package/dist/i18n/locales/de.d.ts +8 -0
  43. package/dist/i18n/locales/de.d.ts.map +1 -1
  44. package/dist/i18n/locales/de.js +8 -0
  45. package/dist/i18n/locales/de.js.map +1 -1
  46. package/dist/i18n/locales/el.d.ts +8 -0
  47. package/dist/i18n/locales/el.d.ts.map +1 -1
  48. package/dist/i18n/locales/el.js +8 -0
  49. package/dist/i18n/locales/el.js.map +1 -1
  50. package/dist/i18n/locales/en.d.ts +8 -0
  51. package/dist/i18n/locales/en.d.ts.map +1 -1
  52. package/dist/i18n/locales/en.js +8 -0
  53. package/dist/i18n/locales/en.js.map +1 -1
  54. package/dist/i18n/locales/es.d.ts +8 -0
  55. package/dist/i18n/locales/es.d.ts.map +1 -1
  56. package/dist/i18n/locales/es.js +8 -0
  57. package/dist/i18n/locales/es.js.map +1 -1
  58. package/dist/i18n/locales/fr.d.ts +8 -0
  59. package/dist/i18n/locales/fr.d.ts.map +1 -1
  60. package/dist/i18n/locales/fr.js +8 -0
  61. package/dist/i18n/locales/fr.js.map +1 -1
  62. package/dist/i18n/locales/hi.d.ts +8 -0
  63. package/dist/i18n/locales/hi.d.ts.map +1 -1
  64. package/dist/i18n/locales/hi.js +8 -0
  65. package/dist/i18n/locales/hi.js.map +1 -1
  66. package/dist/i18n/locales/it.d.ts +8 -0
  67. package/dist/i18n/locales/it.d.ts.map +1 -1
  68. package/dist/i18n/locales/it.js +8 -0
  69. package/dist/i18n/locales/it.js.map +1 -1
  70. package/dist/i18n/locales/ja.d.ts +8 -0
  71. package/dist/i18n/locales/ja.d.ts.map +1 -1
  72. package/dist/i18n/locales/ja.js +8 -0
  73. package/dist/i18n/locales/ja.js.map +1 -1
  74. package/dist/i18n/locales/nl.d.ts +8 -0
  75. package/dist/i18n/locales/nl.d.ts.map +1 -1
  76. package/dist/i18n/locales/nl.js +8 -0
  77. package/dist/i18n/locales/nl.js.map +1 -1
  78. package/dist/i18n/locales/pl.d.ts +8 -0
  79. package/dist/i18n/locales/pl.d.ts.map +1 -1
  80. package/dist/i18n/locales/pl.js +8 -0
  81. package/dist/i18n/locales/pl.js.map +1 -1
  82. package/dist/i18n/locales/pt.d.ts +8 -0
  83. package/dist/i18n/locales/pt.d.ts.map +1 -1
  84. package/dist/i18n/locales/pt.js +8 -0
  85. package/dist/i18n/locales/pt.js.map +1 -1
  86. package/dist/i18n/locales/ro.d.ts +8 -0
  87. package/dist/i18n/locales/ro.d.ts.map +1 -1
  88. package/dist/i18n/locales/ro.js +8 -0
  89. package/dist/i18n/locales/ro.js.map +1 -1
  90. package/dist/i18n/locales/ru.d.ts +8 -0
  91. package/dist/i18n/locales/ru.d.ts.map +1 -1
  92. package/dist/i18n/locales/ru.js +8 -0
  93. package/dist/i18n/locales/ru.js.map +1 -1
  94. package/dist/i18n/locales/sq.d.ts +8 -0
  95. package/dist/i18n/locales/sq.d.ts.map +1 -1
  96. package/dist/i18n/locales/sq.js +8 -0
  97. package/dist/i18n/locales/sq.js.map +1 -1
  98. package/dist/i18n/locales/sv.d.ts +8 -0
  99. package/dist/i18n/locales/sv.d.ts.map +1 -1
  100. package/dist/i18n/locales/sv.js +8 -0
  101. package/dist/i18n/locales/sv.js.map +1 -1
  102. package/dist/i18n/locales/tr.d.ts +8 -0
  103. package/dist/i18n/locales/tr.d.ts.map +1 -1
  104. package/dist/i18n/locales/tr.js +8 -0
  105. package/dist/i18n/locales/tr.js.map +1 -1
  106. package/dist/i18n/locales/zh.d.ts +8 -0
  107. package/dist/i18n/locales/zh.d.ts.map +1 -1
  108. package/dist/i18n/locales/zh.js +8 -0
  109. package/dist/i18n/locales/zh.js.map +1 -1
  110. package/dist/index.js +7 -7
  111. package/dist/locales/ar.json +8 -0
  112. package/dist/locales/de.json +8 -0
  113. package/dist/locales/el.json +8 -0
  114. package/dist/locales/en.json +8 -0
  115. package/dist/locales/es.json +8 -0
  116. package/dist/locales/fr.json +8 -0
  117. package/dist/locales/hi.json +8 -0
  118. package/dist/locales/it.json +8 -0
  119. package/dist/locales/ja.json +8 -0
  120. package/dist/locales/nl.json +8 -0
  121. package/dist/locales/pl.json +8 -0
  122. package/dist/locales/pt.json +8 -0
  123. package/dist/locales/ro.json +8 -0
  124. package/dist/locales/ru.json +8 -0
  125. package/dist/locales/sq.json +8 -0
  126. package/dist/locales/sv.json +8 -0
  127. package/dist/locales/tr.json +8 -0
  128. package/dist/locales/zh.json +8 -0
  129. package/dist/patterns/anamnesis/index.js +1 -1
  130. package/dist/patterns/registration-form/index.js +1 -1
  131. package/dist/tokens.css +1 -1
  132. package/package.json +1 -1
  133. package/dist/_chunks/booking-CxrB0e6d.js +0 -4079
  134. package/dist/_chunks/booking-CxrB0e6d.js.map +0 -1
  135. package/dist/_chunks/multi-select-IOVnOGlP.js.map +0 -1
  136. package/dist/_chunks/otp-input-BgEZi0py.js.map +0 -1
@@ -1,4079 +0,0 @@
1
- import { jsx as n, jsxs as k, Fragment as me } from "react/jsx-runtime";
2
- import { forwardRef as Sn, useId as bt, useRef as F, useCallback as Ne, useState as G, useEffect as K, useMemo as R, Fragment as Yn, useImperativeHandle as Zn } from "react";
3
- import { c as Ft } from "./index-D2ZczOXr.js";
4
- import { useTranslation as Y, Trans as xn } from "react-i18next";
5
- import { u as Qn } from "./registry-DvAUVLHh.js";
6
- import { A as ne } from "./alert-9kEwDza3.js";
7
- import { B as tt } from "./button-DohK_Ak_.js";
8
- import { C as gt } from "./checkbox-BjDv-r3o.js";
9
- import { C as Xn } from "./checkbox-group-Cw2H5qaq.js";
10
- import { R as es } from "./radio-BZQs6_36.js";
11
- import { R as ts } from "./radio-group-ChIKyeSJ.js";
12
- import { D as ns } from "./date-picker-CdhXlgVI.js";
13
- import { E as ss } from "./email-input-C7THAwh2.js";
14
- import { F as je } from "./form-field-CyHfOVKF.js";
15
- import { P as is } from "./phone-input-DJ4BN8tG.js";
16
- import { T as rs } from "./text-area-COMVJ1yE.js";
17
- import { T as Pt } from "./text-input-CaG9ApoE.js";
18
- import { A as os } from "./address-fields-CfnXK8RT.js";
19
- import { S as In } from "./spinner-CoflYlEx.js";
20
- import { a as Gt } from "./format-price-BcFBa-WP.js";
21
- import { C as as } from "./credit-card-D9XZsHGA.js";
22
- import { O as cs } from "./otp-input-BgEZi0py.js";
23
- import { B as Nn } from "./badge-BUk4RjTS.js";
24
- import { I as pn } from "./icon-button-S8_weU3g.js";
25
- import { S as Ht } from "./select-4S-eYZUf.js";
26
- import { C as on } from "./combobox-CDPm_n0p.js";
27
- import { M as an } from "./multi-select-IOVnOGlP.js";
28
- import { c as ds } from "./option-row-Dc7BrbK8.js";
29
- import { S as Ut } from "./skeleton-tTWJpvAq.js";
30
- import { E as wn } from "./empty-state-DwJ5YNzz.js";
31
- import { S as ls } from "./stepper-accordion-DDTSOUHc.js";
32
- import { S as us } from "./stepper-progress-D6H8wQiV.js";
33
- import { S as ps } from "./slot-grid-Bb13H9Rl.js";
34
- import { p as Ie } from "./parseISO-DZZ5a-zK.js";
35
- import { C as ms } from "./chevron-down-DWE7GSq9.js";
36
- import { s as ht, f as jt, d as mn } from "./format--x5jypvH.js";
37
- import { x as Cn, a as vt, b as Xt, i as fs, s as Ot, m as gs, y as Vt } from "./date-picker-variants-Dt6UbonG.js";
38
- import { s as hs } from "./subDays-DKISP2nE.js";
39
- import { C as vs } from "./chevron-left-B8cOyH-V.js";
40
- import { C as bs } from "./chevron-right-I9AeSxH2.js";
41
- import { c as Me } from "./createLucideIcon-DhHxpK9K.js";
42
- import { M as ys, S as ks } from "./sun-Bj9Mr553.js";
43
- import { S as Ss } from "./stethoscope-sZXGC43m.js";
44
- import { H as xs } from "./heart-pulse-BCppJyN2.js";
45
- import { E as Is } from "./eye-BjhN2nYf.js";
46
- import { B as Ns } from "./baby-Dku-Xvg9.js";
47
- import { S as ws } from "./scan-line-CNseIHQ0.js";
48
- import { A as Cs } from "./astroid-BN4f5VXU.js";
49
- import { C as As } from "./clipboard-check-BeAGxDVT.js";
50
- /**
51
- * @license lucide-react v1.22.0 - ISC
52
- *
53
- * This source code is licensed under the ISC license.
54
- * See the LICENSE file in the root directory of this source tree.
55
- */
56
- const Ts = [
57
- [
58
- "path",
59
- {
60
- 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",
61
- key: "169zse"
62
- }
63
- ]
64
- ], Ds = Me("activity", Ts);
65
- /**
66
- * @license lucide-react v1.22.0 - ISC
67
- *
68
- * This source code is licensed under the ISC license.
69
- * See the LICENSE file in the root directory of this source tree.
70
- */
71
- const Os = [
72
- [
73
- "path",
74
- {
75
- 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",
76
- key: "w610uw"
77
- }
78
- ]
79
- ], Ms = Me("bone", Os);
80
- /**
81
- * @license lucide-react v1.22.0 - ISC
82
- *
83
- * This source code is licensed under the ISC license.
84
- * See the LICENSE file in the root directory of this source tree.
85
- */
86
- const Fs = [
87
- ["path", { d: "M12 18V5", key: "adv99a" }],
88
- ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
89
- ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
90
- ["path", { d: "M17.997 5.125a4 4 0 0 1 2.526 5.77", key: "iwvgf7" }],
91
- ["path", { d: "M18 18a4 4 0 0 0 2-7.464", key: "efp6ie" }],
92
- ["path", { d: "M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517", key: "1gq6am" }],
93
- ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
94
- ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
95
- ], Es = Me("brain", Fs);
96
- /**
97
- * @license lucide-react v1.22.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */
102
- const Bs = [
103
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
104
- ["path", { d: "M16 2v4", key: "4m81vk" }],
105
- ["path", { d: "M3 10h18", key: "8toen8" }],
106
- ["path", { d: "M8 2v4", key: "1cmpym" }],
107
- ["path", { d: "M17 14h-6", key: "bkmgh3" }],
108
- ["path", { d: "M13 18H7", key: "bb0bb7" }],
109
- ["path", { d: "M7 14h.01", key: "1qa3f1" }],
110
- ["path", { d: "M17 18h.01", key: "1bdyru" }]
111
- ], Ls = Me("calendar-range", Bs);
112
- /**
113
- * @license lucide-react v1.22.0 - ISC
114
- *
115
- * This source code is licensed under the ISC license.
116
- * See the LICENSE file in the root directory of this source tree.
117
- */
118
- const Rs = [
119
- ["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" }],
120
- ["path", { d: "M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4", key: "1qnva7" }]
121
- ], _s = Me("ear", Rs);
122
- /**
123
- * @license lucide-react v1.22.0 - ISC
124
- *
125
- * This source code is licensed under the ISC license.
126
- * See the LICENSE file in the root directory of this source tree.
127
- */
128
- const Ps = [
129
- ["path", { d: "M6 18h8", key: "1borvv" }],
130
- ["path", { d: "M3 22h18", key: "8prr45" }],
131
- ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
132
- ["path", { d: "M9 14h2", key: "197e7h" }],
133
- ["path", { d: "M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z", key: "1bmzmy" }],
134
- ["path", { d: "M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3", key: "1drr47" }]
135
- ], Vs = Me("microscope", Ps);
136
- /**
137
- * @license lucide-react v1.22.0 - ISC
138
- *
139
- * This source code is licensed under the ISC license.
140
- * See the LICENSE file in the root directory of this source tree.
141
- */
142
- const $s = [
143
- [
144
- "path",
145
- { 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" }
146
- ],
147
- ["path", { d: "m8.5 8.5 7 7", key: "rvfmvr" }]
148
- ], qs = Me("pill", $s);
149
- /**
150
- * @license lucide-react v1.22.0 - ISC
151
- *
152
- * This source code is licensed under the ISC license.
153
- * See the LICENSE file in the root directory of this source tree.
154
- */
155
- const Ks = [
156
- ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
157
- ["path", { d: "M8.12 8.12 12 12", key: "1alkpv" }],
158
- ["path", { d: "M20 4 8.12 15.88", key: "xgtan2" }],
159
- ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
160
- ["path", { d: "M14.8 14.8 20 20", key: "ptml3r" }]
161
- ], zs = Me("scissors", Ks);
162
- /**
163
- * @license lucide-react v1.22.0 - ISC
164
- *
165
- * This source code is licensed under the ISC license.
166
- * See the LICENSE file in the root directory of this source tree.
167
- */
168
- const js = [
169
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
170
- ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
171
- ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
172
- ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
173
- ], Us = Me("smile", js);
174
- /**
175
- * @license lucide-react v1.22.0 - ISC
176
- *
177
- * This source code is licensed under the ISC license.
178
- * See the LICENSE file in the root directory of this source tree.
179
- */
180
- const Gs = [
181
- ["path", { d: "M12 10V2", key: "16sf7g" }],
182
- ["path", { d: "m4.93 10.93 1.41 1.41", key: "2a7f42" }],
183
- ["path", { d: "M2 18h2", key: "j10viu" }],
184
- ["path", { d: "M20 18h2", key: "wocana" }],
185
- ["path", { d: "m19.07 10.93-1.41 1.41", key: "15zs5n" }],
186
- ["path", { d: "M22 22H2", key: "19qnx5" }],
187
- ["path", { d: "m16 6-4 4-4-4", key: "6wukr" }],
188
- ["path", { d: "M16 18a4 4 0 0 0-8 0", key: "1lzouq" }]
189
- ], Hs = Me("sunset", Gs);
190
- /**
191
- * @license lucide-react v1.22.0 - ISC
192
- *
193
- * This source code is licensed under the ISC license.
194
- * See the LICENSE file in the root directory of this source tree.
195
- */
196
- const Js = [
197
- ["path", { d: "m18 2 4 4", key: "22kx64" }],
198
- ["path", { d: "m17 7 3-3", key: "1w1zoj" }],
199
- ["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" }],
200
- ["path", { d: "m9 11 4 4", key: "rovt3i" }],
201
- ["path", { d: "m5 19-3 3", key: "59f2uf" }],
202
- ["path", { d: "m14 4 6 6", key: "yqp9t2" }]
203
- ], fn = Me("syringe", Js);
204
- function Ws(e, t, s) {
205
- return Cn(e, -1, s);
206
- }
207
- const Ys = {
208
- id: "booking",
209
- // `view_change` removed (0.69): the layout `variant` is a fixed prop — the
210
- // handle exposes only `getVariant` (state), no action mutates it. The flow's
211
- // only navigation is step-to-step (`goto_step` → `navigate`).
212
- capabilities: ["navigate"],
213
- state: {
214
- variant: {
215
- type: "string",
216
- descriptionKey: "ui.agent.booking.state.variant",
217
- description: "Active variant — one of `inline-list`, `accordion`, `calendar`, `flexible`, `progress`.",
218
- read: (e) => e.getVariant()
219
- },
220
- currentStep: {
221
- type: "number",
222
- descriptionKey: "ui.agent.booking.state.currentStep",
223
- description: "The step the flow is on: 1 insurance, 2 specialty, 3 service, 4 provider, 5 date, 6 time, 7 patient details, payment or optional SMS code verification, 8 confirmation after all required steps succeed. Read this back after `goto_step` to see where the clamp landed.",
224
- read: (e) => e.getCurrentStep()
225
- }
226
- },
227
- actions: {
228
- reset: {
229
- // destructive: clears the whole in-progress booking value (patient
230
- // identity, contact, slot choice) — irreversibly loses user input.
231
- safety: "destructive",
232
- idempotent: !0,
233
- descriptionKey: "ui.agent.booking.actions.reset",
234
- description: "Clear the booking value back to an empty state. Use to abandon an in-progress flow.",
235
- errors: [
236
- "Refused while a payment session is open (step 7): the consumer must cancel the hold first.",
237
- "Refused while SMS code verification is pending (step 7): the submitted booking remains active. The host owns cancellation."
238
- ],
239
- invoke: (e) => {
240
- e.reset();
241
- }
242
- },
243
- goto_step: {
244
- safety: "read",
245
- argsType: "{ step: 1 | 2 | 3 | 4 | 5 | 6 | 7 }",
246
- argsSchema: {
247
- type: "object",
248
- properties: {
249
- step: {
250
- type: "integer",
251
- enum: [1, 2, 3, 4, 5, 6, 7],
252
- description: "Target step (1-7)."
253
- }
254
- },
255
- required: ["step"]
256
- },
257
- idempotent: !0,
258
- descriptionKey: "ui.agent.booking.actions.gotoStep",
259
- description: "Jump to the given step. A step that is hidden for this practice, or that sits ahead of the first incomplete step, clamps to that first incomplete step — read `currentStep` back to see where it landed.",
260
- errors: [
261
- "Navigation stays on step 7 while payment or SMS code verification is pending.",
262
- "Requested step is not yet reachable — clamped to the first incomplete step.",
263
- "Requested step is hidden for this practice (e.g. insurance outside Germany, or provider choice turned off) — clamped to the first incomplete step."
264
- ],
265
- examples: [{ args: { step: 1 }, note: "Return to the first step." }],
266
- invoke: (e, t) => {
267
- e.goToStep(t.step);
268
- }
269
- }
270
- },
271
- domHooks: {
272
- root: {
273
- attr: "data-component",
274
- value: "booking",
275
- description: 'Marks the Booking root region. The host prop hideEmail (boolean, default false) hides the email field, skips its validation and omits email from submission. The host prop emailOptional (boolean, default false) keeps email visible and optional unless used for confirmation. Email is marked and validated as required when selected in the channel picker or singleConfirmationChannel radio, or when the effective confirmation channel is email. With a hidden picker, the form and success screen use the sole enabled channel, or email when multiple channels are enabled. This includes payment and blocked-payment flows, which omit stored selections from submission. Omitting confirmationChannels also defaults to email. Selecting SMS without email makes the field optional again. The optional/required marker updates visually when the channel changes, with no announcement of that change. Validation updates immediately using the existing email error. With emailOptional, surrounding spaces are trimmed before validation, even when email is required for confirmation. Optional blank values are omitted from submission; filled values are sent trimmed. hideEmail takes precedence over emailOptional. Neither prop changes confirmation channels; pair with confirmationChannels ["sms"] for SMS-only confirmation with no channel picker. The optional codeStep prop adds SMS verification after submission and payment; the step remains 7 until verification succeeds, then becomes 8. Patient contact details and verification codes are never exposed through this adapter.'
276
- },
277
- instanceId: {
278
- attr: "data-component-id",
279
- sourceProp: "id",
280
- description: "Sourced from the id prop."
281
- }
282
- }
283
- }, nn = [
284
- "email",
285
- "whatsapp",
286
- "sms"
287
- ], _e = "all", Zs = "de";
288
- function Qs(e) {
289
- const t = e.lockedOperatorId;
290
- return [...t ? e.operatorsByService ? e.specialties.filter(
291
- (i) => e.services.some(
292
- (r) => {
293
- var a;
294
- return r.specialtyId === i.id && ((a = r.operatorIds) == null ? void 0 : a.includes(t));
295
- }
296
- )
297
- ) : e.specialties.filter((i) => {
298
- var r;
299
- return (r = i.operatorIds) == null ? void 0 : r.includes(t);
300
- }) : e.specialties].sort((i, r) => {
301
- const a = i.sequenceNumber ?? Number.POSITIVE_INFINITY, c = r.sequenceNumber ?? Number.POSITIVE_INFINITY;
302
- return a - c;
303
- });
304
- }
305
- function Xs(e) {
306
- let t = e.services;
307
- if (e.lockedOperatorId && (t = t.filter(
308
- (i) => {
309
- var r;
310
- return (r = i.operatorIds) == null ? void 0 : r.includes(e.lockedOperatorId);
311
- }
312
- )), e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) {
313
- const i = nt(e.value);
314
- i.length > 0 && (t = t.filter(
315
- (r) => r.specialtyId !== void 0 && i.includes(r.specialtyId)
316
- ));
317
- }
318
- return t;
319
- }
320
- function ei(e) {
321
- const t = e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties, s = Ge(e.value);
322
- if ((!t || e.operatorsByService) && s.length > 0)
323
- return e.operators.filter(
324
- (i) => {
325
- var r;
326
- return (r = i.appointmentBookingReasonIds) == null ? void 0 : r.some((a) => s.includes(a));
327
- }
328
- );
329
- if (t) {
330
- const i = nt(e.value);
331
- if (i.length > 0)
332
- return e.operators.filter(
333
- (r) => {
334
- var a;
335
- return (a = r.specialtyIds) == null ? void 0 : a.some((c) => i.includes(c));
336
- }
337
- );
338
- }
339
- return [];
340
- }
341
- function ti(e, t) {
342
- const s = e.country === Zs, i = !s || e.value.insuranceType !== void 0, a = (e.useSpecialties === void 0 ? e.specialties.length > 0 : e.useSpecialties) && i, c = nt(e.value).length > 0, u = !a || c, m = Ge(e.value).length > 0, v = !u || m, b = t.operators, g = !!e.allowOperatorSelection && v && m && !e.lockedOperatorId && b.length > 1, o = v && m, I = (!o || e.value.date !== void 0) && e.value.date !== void 0, B = (!I || e.value.slotKey !== void 0) && e.value.slotKey !== void 0, N = m && b.length === 0;
343
- return {
344
- insurance: s,
345
- specialty: a,
346
- service: u,
347
- operator: g,
348
- date: o,
349
- slot: I,
350
- details: B,
351
- onboardingIncomplete: N
352
- };
353
- }
354
- function ni(e, t) {
355
- const s = [];
356
- return t.insurance && s.push(1), t.specialty && s.push(2), s.push(3), t.operator && s.push(4), s.push(5), s.push(6), s.push(7), {
357
- currentStep: s.find(
358
- (r) => !Ue(r, e.value)
359
- ) ?? 7,
360
- visibleSteps: s
361
- };
362
- }
363
- function Ue(e, t) {
364
- switch (e) {
365
- case 1:
366
- return t.insuranceType !== void 0;
367
- // 0.34.0: array-or-single — satisfied when EITHER form is present.
368
- case 2:
369
- return nt(t).length > 0;
370
- case 3:
371
- return Ge(t).length > 0;
372
- // Always satisfied, like its gate: "no preference" is a valid answer,
373
- // whether it is the `'all'` sentinel or an empty multi-select.
374
- case 4:
375
- return !0;
376
- case 5:
377
- return t.date !== void 0;
378
- case 6:
379
- return t.slotKey !== void 0;
380
- // Details fulfilment is owned by the form's own validation.
381
- case 7:
382
- return !1;
383
- }
384
- }
385
- function si(e) {
386
- const t = {
387
- specialties: Qs(e),
388
- services: Xs(e),
389
- operators: ei(e)
390
- }, s = ti(e, t), { currentStep: i, visibleSteps: r } = ni(e, s);
391
- let a;
392
- if (e.value.date && e.value.slotKey) {
393
- const v = e.availableSlots[e.value.date];
394
- v && (a = v.find((b) => b.key === e.value.slotKey));
395
- }
396
- const c = Ge(e.value), p = c.length > 0 ? e.services.find((v) => v.id === c[0]) : void 0, u = nt(e.value).length > 0, m = c.length > 0 && e.value.date !== void 0 && e.value.slotKey !== void 0 && (!s.insurance || e.value.insuranceType !== void 0) && (!s.specialty || u);
397
- return {
398
- gates: s,
399
- filtered: t,
400
- currentStep: i,
401
- totalSteps: r.length,
402
- visibleSteps: r,
403
- isReadyToSubmit: m,
404
- durationMin: p == null ? void 0 : p.durationMin,
405
- selectedSlot: a
406
- };
407
- }
408
- function An(e, t) {
409
- return {
410
- ...e,
411
- insuranceType: t,
412
- specialtyId: void 0,
413
- serviceId: void 0,
414
- operatorId: void 0,
415
- date: void 0,
416
- slotKey: void 0,
417
- details: void 0
418
- };
419
- }
420
- function Tn(e, t) {
421
- return {
422
- ...e,
423
- specialtyId: t,
424
- specialtyIds: void 0,
425
- serviceId: void 0,
426
- serviceIds: void 0,
427
- operatorId: void 0,
428
- operatorIds: void 0,
429
- date: void 0,
430
- slotKey: void 0,
431
- details: void 0
432
- };
433
- }
434
- function Dn(e, t) {
435
- return {
436
- ...e,
437
- specialtyId: void 0,
438
- specialtyIds: t,
439
- serviceId: void 0,
440
- serviceIds: void 0,
441
- operatorId: void 0,
442
- operatorIds: void 0,
443
- date: void 0,
444
- slotKey: void 0,
445
- details: void 0
446
- };
447
- }
448
- function On(e, t) {
449
- return {
450
- ...e,
451
- serviceId: t,
452
- serviceIds: void 0,
453
- // Default the operator to the "All operators" sentinel so a patient
454
- // who doesn't care about picking lands on a satisfied step 4 without
455
- // any further input.
456
- operatorId: t ? _e : void 0,
457
- operatorIds: void 0,
458
- date: void 0,
459
- slotKey: void 0,
460
- details: void 0
461
- };
462
- }
463
- function Mn(e, t) {
464
- const s = !!t && t.length > 0;
465
- return {
466
- ...e,
467
- serviceId: void 0,
468
- serviceIds: t,
469
- operatorId: s ? _e : void 0,
470
- operatorIds: void 0,
471
- date: void 0,
472
- slotKey: void 0,
473
- details: void 0
474
- };
475
- }
476
- function Fn(e, t) {
477
- return {
478
- ...e,
479
- operatorId: t,
480
- operatorIds: void 0,
481
- date: void 0,
482
- slotKey: void 0,
483
- details: void 0
484
- };
485
- }
486
- function En(e, t) {
487
- return {
488
- ...e,
489
- operatorId: void 0,
490
- operatorIds: t,
491
- date: void 0,
492
- slotKey: void 0,
493
- details: void 0
494
- };
495
- }
496
- function nt(e) {
497
- return e.specialtyIds && e.specialtyIds.length > 0 ? e.specialtyIds : e.specialtyId ? [e.specialtyId] : [];
498
- }
499
- function Ge(e) {
500
- return e.serviceIds && e.serviceIds.length > 0 ? e.serviceIds : e.serviceId ? [e.serviceId] : [];
501
- }
502
- function sn(e) {
503
- return e.operatorIds && e.operatorIds.length > 0 ? e.operatorIds : e.operatorId ? [e.operatorId] : [];
504
- }
505
- function Jt(e, t) {
506
- return {
507
- ...e,
508
- date: t,
509
- slotKey: void 0
510
- // Keep details — date/slot changes shouldn't wipe the patient form
511
- // since the user has already filled some fields.
512
- };
513
- }
514
- function Bn(e, t) {
515
- return {
516
- ...e,
517
- slotKey: t
518
- };
519
- }
520
- function ii(e, t) {
521
- let s = e;
522
- if (t.lockedOperatorId && s.operatorId !== t.lockedOperatorId && (s = { ...s, operatorId: t.lockedOperatorId }), (t.useSpecialties === void 0 ? t.specialties.length > 0 : t.useSpecialties) && t.specialties.length === 1 && s.specialtyId === void 0 && s.specialtyIds === void 0 && (s = { ...s, specialtyId: t.specialties[0].id }), t.autoSelectSingleService) {
523
- const r = nt(s), a = r.length > 0 ? t.services.filter(
524
- (c) => c.specialtyId && r.includes(c.specialtyId)
525
- ) : t.services;
526
- a.length === 1 && s.serviceId === void 0 && s.serviceIds === void 0 && (s = { ...s, serviceId: a[0].id }, s.operatorId === void 0 && s.operatorIds === void 0 && (s = { ...s, operatorId: _e }));
527
- }
528
- return s;
529
- }
530
- function Ln(e) {
531
- if (e.operatorId && e.operatorId !== _e)
532
- return e.operatorId;
533
- }
534
- function ri(e) {
535
- if (!e) return !1;
536
- const t = e.trim();
537
- return /^\+?\d[\d\s\-()]{6,}$/.test(t);
538
- }
539
- function cn(e) {
540
- const t = e && e.length > 0 ? e : ["email"], s = new Set(t);
541
- return nn.filter((i) => s.has(i));
542
- }
543
- function Rn(e, t) {
544
- return t ?? (e.length === 1 ? e : ["email"]);
545
- }
546
- function oi(e, t, s) {
547
- const i = cn(e), r = new Set(i);
548
- if (s)
549
- return nn.filter(
550
- (m) => s.includes(m) && r.has(m)
551
- );
552
- const a = [];
553
- r.has("email") && a.push("email");
554
- const c = ri(t), p = r.has("whatsapp");
555
- p && c && a.push("whatsapp"), !p && r.has("sms") && a.push("sms");
556
- const u = new Set(a);
557
- return nn.filter((m) => u.has(m));
558
- }
559
- const ai = /https?:\/\/(?:(?![.,;:!?'»›]https?:\/\/)[^\s<>"\u060C\u061B\u061F\u06D4\u2000-\u206F\u3000-\u303F\uFF00-\uFFEF])+/gi, ci = /* @__PURE__ */ new Set([
560
- ".",
561
- ",",
562
- ";",
563
- ":",
564
- "!",
565
- "?",
566
- "'",
567
- "»",
568
- "›"
569
- ]), di = { ")": "(", "]": "[", "}": "{" }, gn = (e, t) => e.split(t).length - 1;
570
- function li(e) {
571
- const t = {};
572
- for (const [i, r] of Object.entries(di))
573
- t[i] = gn(e, i) - gn(e, r);
574
- let s = e.length;
575
- for (; s > 0; ) {
576
- const i = e[s - 1];
577
- if (ci.has(i))
578
- s -= 1;
579
- else if (i in t && t[i] > 0)
580
- t[i] -= 1, s -= 1;
581
- else
582
- break;
583
- }
584
- return e.slice(0, s);
585
- }
586
- const ui = /[\u0600-\u06FF\u3040-\u30FF\u3400-\u9FFF\uAC00-\uD7AF]/, pi = /[A-Za-z0-9]/;
587
- function mi(e) {
588
- const t = e.search(ui);
589
- return t > 0 && pi.test(e[t - 1]) ? e.slice(0, t) : e;
590
- }
591
- function fi(e) {
592
- try {
593
- const { protocol: t, hostname: s } = new URL(e);
594
- return (t === "http:" || t === "https:") && s !== "";
595
- } catch {
596
- return !1;
597
- }
598
- }
599
- function gi(e) {
600
- const t = [];
601
- let s = 0;
602
- const i = (r) => {
603
- if (r === "") return;
604
- const a = t[t.length - 1];
605
- (a == null ? void 0 : a.kind) === "text" ? a.text += r : t.push({ kind: "text", text: r });
606
- };
607
- for (const r of e.matchAll(ai)) {
608
- const a = r.index ?? 0, c = li(mi(r[0]));
609
- fi(c) && (i(e.slice(s, a)), t.push({ kind: "link", text: c, href: c }), s = a + c.length);
610
- }
611
- return i(e.slice(s)), t;
612
- }
613
- const hn = 500, hi = /^[A-Z0-9]{16}$/, vi = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, vn = 300, en = "ds:rounded-[var(--radius-sm)] ds:underline ds:text-[var(--foreground)] ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]", $t = (e) => e && /^https?:\/\//i.test(e) ? e : void 0, bi = (e, t) => ({
614
- street: (e == null ? void 0 : e.address.line1) ?? "",
615
- city: (e == null ? void 0 : e.address.city) ?? "",
616
- postcode: (e == null ? void 0 : e.address.postalCode) ?? "",
617
- province: (e == null ? void 0 : e.address.state) ?? "",
618
- // The practice's country only until the patient has an address at all.
619
- country: (e ? e.address.country : t).toLowerCase(),
620
- formatted: ""
621
- }), yi = (e, t, s = null) => ({
622
- name: t,
623
- address: {
624
- line1: e.street,
625
- line2: s,
626
- city: e.city,
627
- state: e.province,
628
- postalCode: e.postcode,
629
- country: e.country.toUpperCase()
630
- }
631
- }), ki = Ft("ds:flex ds:flex-col ds:border", {
632
- variants: {
633
- noticeStyle: {
634
- plain: "ds:gap-[var(--spacing-xs)] ds:rounded-[var(--radius-md)] ds:border-[var(--border)] ds:bg-[var(--muted)] ds:p-[var(--spacing-sm)]",
635
- highlighted: "ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-lg)] ds:border-[color-mix(in_srgb,var(--primary)_30%,var(--border))] ds:bg-[color-mix(in_srgb,var(--primary)_8%,var(--card))] ds:p-[var(--spacing-md)]"
636
- }
637
- },
638
- defaultVariants: { noticeStyle: "highlighted" }
639
- }), Si = ["it", "ch", "de", "at", "fr", "sm"], z = {
640
- country: "billing.country",
641
- street: "billing.street",
642
- city: "billing.city",
643
- postcode: "billing.postcode",
644
- province: "billing.province"
645
- }, _n = /^\d{5}$/, xi = (e) => {
646
- if (!e) return !1;
647
- const { line1: t, city: s, postalCode: i, country: r, state: a } = e.address;
648
- return !t.trim() || !s.trim() || !i.trim() || !r.trim() ? !1 : r.toUpperCase() !== "IT" ? !0 : !!a.trim() && _n.test(i.trim());
649
- }, Ii = (e, t) => {
650
- var s;
651
- return {
652
- name: t,
653
- address: {
654
- line1: e.address.line1.trim(),
655
- line2: ((s = e.address.line2) == null ? void 0 : s.trim()) || null,
656
- city: e.address.city.trim(),
657
- state: e.address.state.trim(),
658
- postalCode: e.address.postalCode.trim(),
659
- country: e.address.country.trim().toUpperCase()
660
- }
661
- };
662
- }, qt = { state: "idle" }, bn = [
663
- "firstName",
664
- "lastName",
665
- "email",
666
- "mobilePhone",
667
- "codiceFiscale",
668
- "dateOfBirth",
669
- "insuranceNumber",
670
- z.country,
671
- z.street,
672
- z.city,
673
- z.postcode,
674
- z.province
675
- ], Ni = /* @__PURE__ */ new Set(), dn = Sn(
676
- ({
677
- value: e,
678
- onChange: t,
679
- onSubmit: s,
680
- hideEmail: i = !1,
681
- emailOptional: r = !1,
682
- requireCodiceFiscale: a = !1,
683
- requireDateOfBirth: c = !1,
684
- requireInsuranceNumber: p = !1,
685
- insuranceType: u,
686
- showNote: m = !1,
687
- showReturningPatientFlag: v = !1,
688
- privacyPolicyUrl: b,
689
- termsUrl: g,
690
- practiceConsent: o,
691
- payment: f,
692
- paymentTermsUrl: I,
693
- paymentBlocked: y = !1,
694
- billingInDetails: B = !1,
695
- paymentNoticeStyle: N = "highlighted",
696
- criticalInformationToAccept: x,
697
- validateCodiceFiscale: S,
698
- validateInsuranceNumber: D,
699
- submitting: T = !1,
700
- summarySlot: E,
701
- defaultPhoneCountry: l,
702
- confirmationChannels: w,
703
- defaultConfirmationChannels: O,
704
- singleConfirmationChannel: V = !1,
705
- submitError: j
706
- }, Z) => {
707
- var C, L, P, Q, ae;
708
- const { t: h, i18n: ee } = Y("ui"), H = bt(), Pe = F(null), M = Ne(
709
- (d) => {
710
- Pe.current = d, typeof Z == "function" ? Z(d) : Z && (Z.current = d);
711
- },
712
- [Z]
713
- ), [J, we] = G(0);
714
- K(() => {
715
- var A;
716
- if (J === 0) return;
717
- const d = (A = Pe.current) == null ? void 0 : A.querySelectorAll(
718
- '[aria-invalid="true"], [role="checkbox"][aria-required="true"][aria-checked="false"], [data-unanswered] [role="checkbox"]'
719
- );
720
- for (const te of d ?? [])
721
- if (te.focus(), document.activeElement === te) return;
722
- }, [J]);
723
- const fe = F(!1), [W, Ve] = G(!1), [ct, ge] = G(!1), se = T || W, [ce, Ce] = G(qt), [Ae, Fe] = G(qt), [re, Ee] = G({}), de = Ne(
724
- (d) => Ee((A) => ({ ...A, [d]: !0 })),
725
- []
726
- ), [he, Te] = G(Ni), $e = F(null), He = F(
727
- null
728
- );
729
- K(
730
- () => () => {
731
- $e.current && clearTimeout($e.current), He.current && clearTimeout(He.current);
732
- },
733
- []
734
- );
735
- const q = Ne(
736
- (d) => {
737
- ge(!1), t({ ...e, ...d });
738
- },
739
- [e, t]
740
- ), qe = f ? JSON.stringify([
741
- f.serviceId,
742
- f.kind,
743
- f.amountCents,
744
- f.currencyCode,
745
- I
746
- ]) : void 0, [st, Et] = G(
747
- () => e.paymentAccepted ? qe : void 0
748
- ), dt = F(qe), lt = !!(f && e.paymentAccepted && st === qe);
749
- K(() => {
750
- dt.current !== qe && (dt.current = qe, Et(void 0), e.paymentAccepted !== void 0 && q({ paymentAccepted: f ? !1 : void 0 }));
751
- }, [qe, f, q, e.paymentAccepted]);
752
- const ut = typeof (o == null ? void 0 : o.label) == "string" && o.label.trim() !== "", Be = o && ut ? JSON.stringify([
753
- o.label,
754
- o.url ?? null,
755
- o.required
756
- ]) : void 0, [le, Bt] = G(
757
- () => e.practiceConsentAccepted ? Be : void 0
758
- ), ve = F(Be), Je = !!(Be !== void 0 && e.practiceConsentAccepted && le === Be);
759
- K(() => {
760
- ve.current !== Be && (ve.current = Be, Bt(void 0), e.practiceConsentAccepted !== void 0 && q({ practiceConsentAccepted: void 0 }));
761
- }, [Be, q, e.practiceConsentAccepted]);
762
- const ke = f ? Gt(f.amountCents, f.currencyCode, ee.language) : "", We = $t(I), _ = B && !!f && !y, Se = a, pt = (l || "it").toLowerCase(), kt = !_ || xi(e.billing), oe = bi(e.billing, pt), xe = oe.country === "it", St = F(null), Ye = F(
763
- null
764
- ), ue = (C = e.billing) == null ? void 0 : C.address.line1.trim(), it = ((P = (L = e.billing) == null ? void 0 : L.address.line2) == null ? void 0 : P.trim()) || null;
765
- K(() => {
766
- var d;
767
- ue !== void 0 && it ? Ye.current = { street: ue, line2: it } : (ue === void 0 || ue === ((d = Ye.current) == null ? void 0 : d.street)) && (Ye.current = null);
768
- }, [ue, it]);
769
- const Ze = (d) => (
770
- // Nothing for a block not shown, nor for a province outside Italy.
771
- !_ || !re[z[d]] || d === "province" && !xe ? void 0 : oe[d].trim() ? (
772
- // The one format the block itself checks: an Italian CAP.
773
- d === "postcode" && xe && !_n.test(oe.postcode.trim()) ? h("inputs.postalCode.invalid") : void 0
774
- ) : h("booking.details.fieldRequired")
775
- ), Yt = Ne(
776
- () => Ee(
777
- (d) => d[z.province] ? d : {
778
- ...d,
779
- codiceFiscale: !0,
780
- ...Object.fromEntries(
781
- Object.values(z).map((A) => [A, !0])
782
- )
783
- }
784
- ),
785
- []
786
- ), Le = R(
787
- () => cn(w),
788
- [w]
789
- ), be = !f && !y && Le.length >= 2, rt = F(!1);
790
- K(() => {
791
- if (f || y) return;
792
- if (!be) {
793
- e.confirmationChannels !== void 0 && q({ confirmationChannels: void 0 });
794
- return;
795
- }
796
- if (e.confirmationChannels !== void 0) {
797
- rt.current = !0, V && e.confirmationChannels.length > 1 && q({
798
- confirmationChannels: e.confirmationChannels.slice(0, 1)
799
- });
800
- return;
801
- }
802
- const d = V ? [
803
- (O == null ? void 0 : O.find(
804
- (A) => Le.includes(A)
805
- )) ?? Le[0]
806
- ] : oi(
807
- Le,
808
- e.mobilePhone,
809
- O
810
- );
811
- rt.current = !0, q({ confirmationChannels: d });
812
- }, [
813
- be,
814
- f,
815
- y,
816
- Le,
817
- e.mobilePhone,
818
- O,
819
- V
820
- ]);
821
- const $ = R(
822
- () => e.confirmationChannels ?? [],
823
- [e.confirmationChannels]
824
- ), U = be && $.length === 0, Lt = Rn(
825
- Le,
826
- be ? $ : void 0
827
- ), ot = !r || Lt.includes("email"), xt = F(S), It = F(D);
828
- K(() => {
829
- xt.current = S, It.current = D;
830
- }, [S, D]);
831
- const Nt = !!S, wt = !!D;
832
- K(() => {
833
- const d = e.codiceFiscale;
834
- if (!Se || !Nt || !d) {
835
- Ce(qt);
836
- return;
837
- }
838
- if (!hi.test(d)) {
839
- Ce({
840
- state: "invalid",
841
- hint: h("booking.details.codiceFiscale.invalidFormat")
842
- });
843
- return;
844
- }
845
- Ce({ state: "pending" });
846
- let A = !0;
847
- return $e.current && clearTimeout($e.current), $e.current = setTimeout(async () => {
848
- try {
849
- const te = xt.current;
850
- if (!te) return;
851
- const ze = await te(d);
852
- A && Ce({
853
- state: ze.valid ? "valid" : "invalid",
854
- hint: ze.hint,
855
- value: d
856
- });
857
- } catch {
858
- A && Ce({
859
- state: "invalid",
860
- hint: h("booking.details.codiceFiscale.unavailable"),
861
- value: d
862
- });
863
- }
864
- }, vn), () => {
865
- A = !1, $e.current && clearTimeout($e.current);
866
- };
867
- }, [Se, Nt, e.codiceFiscale, h]);
868
- const Qe = p && u === "public";
869
- K(() => {
870
- const d = e.insuranceNumber;
871
- if (!Qe || !wt || !d) {
872
- Fe(qt);
873
- return;
874
- }
875
- Fe({ state: "pending" }), He.current && clearTimeout(He.current), He.current = setTimeout(() => {
876
- const A = It.current;
877
- A && A(d).then(
878
- (te) => Fe(
879
- te.valid ? { state: "valid" } : { state: "invalid", hint: te.hint }
880
- )
881
- ).catch(
882
- () => Fe({
883
- state: "invalid",
884
- hint: h("booking.details.insuranceNumber.unavailable")
885
- })
886
- );
887
- }, vn);
888
- }, [Qe, wt, e.insuranceNumber, h]);
889
- const Ke = R(() => {
890
- var A;
891
- if (i) return !0;
892
- const d = r ? (A = e.email) == null ? void 0 : A.trim() : e.email;
893
- return !ot && !d ? !0 : !!(d && vi.test(d));
894
- }, [i, r, ot, e.email]), mt = R(
895
- () => !!(e.mobilePhone && e.mobilePhone.length >= 6),
896
- [e.mobilePhone]
897
- ), Xe = R(() => {
898
- var d, A;
899
- return !(!((d = e.firstName) != null && d.trim()) || !((A = e.lastName) != null && A.trim()) || !Ke || !mt || Se && (ce.state !== "valid" || ce.value !== e.codiceFiscale) || !kt || c && !e.dateOfBirth || Qe && Ae.state !== "valid");
900
- }, [
901
- e.firstName,
902
- e.lastName,
903
- Ke,
904
- mt,
905
- Se,
906
- kt,
907
- ce.state,
908
- ce.value,
909
- e.codiceFiscale,
910
- c,
911
- e.dateOfBirth,
912
- Qe,
913
- Ae.state
914
- ]), ft = x != null && x.trim() ? x : void 0, Rt = ft !== void 0, De = !Rt || !!e.criticalInformationAccepted, Zt = !ut || !(o != null && o.required) || Je, Qt = !!(e.privacyConsent && e.termsConsent && De && Zt), Ct = !be || $.length > 0, Re = Xe && Qt && Ct && (!f || lt) && !y && !se, ye = !Re && !se && !y, et = `${H}-submit-hint`, ie = {
915
- firstName: re.firstName && !((Q = e.firstName) != null && Q.trim()) ? h("booking.details.firstName.required") : void 0,
916
- lastName: re.lastName && !((ae = e.lastName) != null && ae.trim()) ? h("booking.details.lastName.required") : void 0,
917
- email: !i && re.email && !Ke ? h("booking.details.email.invalid") : void 0,
918
- mobilePhone: re.mobilePhone && !mt ? h("booking.details.mobilePhone.invalid") : void 0,
919
- codiceFiscale: re.codiceFiscale && ce.state === "invalid" ? ce.hint ?? h("booking.details.codiceFiscale.invalid") : re.codiceFiscale && !e.codiceFiscale ? h("booking.details.fieldRequired") : void 0,
920
- dateOfBirth: re.dateOfBirth && !e.dateOfBirth ? h("booking.details.dateOfBirth.required") : void 0,
921
- insuranceNumber: re.insuranceNumber && Ae.state === "invalid" ? Ae.hint ?? h("booking.details.insuranceNumber.invalid") : void 0,
922
- [z.country]: Ze("country"),
923
- [z.street]: Ze("street"),
924
- [z.city]: Ze("city"),
925
- [z.postcode]: Ze("postcode"),
926
- [z.province]: Ze("province")
927
- }, At = bn.filter(
928
- (d) => he.has(d) && ie[d] !== void 0
929
- );
930
- At.length !== he.size && Te(new Set(At));
931
- const pe = (d) => !he.has(d), _t = async (d) => {
932
- var te;
933
- if (d.preventDefault(), !se && !fe.current && !Re && Te(
934
- new Set(
935
- bn.filter(
936
- (ze) => he.has(ze) || !ie[ze]
937
- )
938
- )
939
- ), Ee({
940
- firstName: !0,
941
- lastName: !0,
942
- email: !i,
943
- mobilePhone: !0,
944
- codiceFiscale: !0,
945
- dateOfBirth: !0,
946
- insuranceNumber: !0,
947
- ...Object.fromEntries(
948
- Object.values(z).map((ze) => [ze, !0])
949
- )
950
- }), se || fe.current) return;
951
- if (!Re) {
952
- we((ze) => ze + 1);
953
- return;
954
- }
955
- const A = {
956
- firstName: e.firstName.trim(),
957
- lastName: e.lastName.trim(),
958
- ...!i && ((te = e.email) != null && te.trim()) ? { email: e.email.trim() } : {},
959
- mobilePhone: e.mobilePhone,
960
- privacyConsent: !0,
961
- termsConsent: !0,
962
- // Only present when the service carried text to accept — a
963
- // reason without it leaves the key out of the payload entirely.
964
- ...Rt ? { criticalInformationAccepted: !0 } : {},
965
- // Sent whenever the practice's box is shown, ticked or not, so the
966
- // server can record the answer; left out when there is no box.
967
- ...ut ? { practiceConsentAccepted: Je } : {},
968
- ...f ? { paymentAccepted: !0 } : {},
969
- codiceFiscale: e.codiceFiscale,
970
- dateOfBirth: e.dateOfBirth,
971
- insuranceNumber: e.insuranceNumber,
972
- note: e.note,
973
- returningPatient: e.returningPatient,
974
- // Only include when the picker was visible; otherwise the single
975
- // implicit channel is inferred backend-side from the practice
976
- // config.
977
- confirmationChannels: be ? $ : void 0,
978
- ..._ && e.billing ? {
979
- billing: Ii(
980
- e.billing,
981
- `${e.firstName.trim()} ${e.lastName.trim()}`
982
- )
983
- } : {}
984
- };
985
- fe.current = !0, Ve(!0), ge(!1);
986
- try {
987
- await s(A);
988
- } catch {
989
- ge(!0);
990
- } finally {
991
- fe.current = !1, Ve(!1);
992
- }
993
- }, Tt = /* @__PURE__ */ n(
994
- je,
995
- {
996
- label: h("booking.details.codiceFiscale.label"),
997
- required: !0,
998
- description: ce.state === "pending" ? h("booking.details.codiceFiscale.checking") : h("booking.details.codiceFiscale.helper"),
999
- error: ie.codiceFiscale,
1000
- announceError: pe("codiceFiscale"),
1001
- children: /* @__PURE__ */ n(
1002
- Pt,
1003
- {
1004
- value: e.codiceFiscale ?? "",
1005
- maxLength: 16,
1006
- onChange: (d) => q({
1007
- codiceFiscale: d.target.value.slice(0, 16).toUpperCase()
1008
- }),
1009
- onBlur: () => de("codiceFiscale")
1010
- }
1011
- )
1012
- }
1013
- ), Dt = (d, A) => {
1014
- const te = $t(A);
1015
- return te ? /* @__PURE__ */ n(
1016
- xn,
1017
- {
1018
- ns: "ui",
1019
- i18nKey: d,
1020
- components: {
1021
- // The `<Trans>` runtime injects link text from the i18n
1022
- // string. The anchor renders empty at static-analysis time,
1023
- // so `jsx-a11y/anchor-has-content` would false-flag — silence
1024
- // it; the runtime content is the localised policy / terms
1025
- // label.
1026
- policyLink: (
1027
- // eslint-disable-next-line jsx-a11y/anchor-has-content
1028
- /* @__PURE__ */ n(
1029
- "a",
1030
- {
1031
- href: te,
1032
- target: "_blank",
1033
- rel: "noopener noreferrer",
1034
- className: en
1035
- }
1036
- )
1037
- )
1038
- }
1039
- }
1040
- ) : h(d);
1041
- };
1042
- return /* @__PURE__ */ k(
1043
- "form",
1044
- {
1045
- ref: M,
1046
- id: H,
1047
- noValidate: !0,
1048
- onSubmit: _t,
1049
- onFocus: (d) => {
1050
- const A = St.current;
1051
- !A || !d.currentTarget.contains(d.target) || !A.contains(d.target) && A.compareDocumentPosition(d.target) & Node.DOCUMENT_POSITION_FOLLOWING && Yt();
1052
- },
1053
- "aria-busy": se || void 0,
1054
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
1055
- children: [
1056
- E,
1057
- /* @__PURE__ */ k("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
1058
- /* @__PURE__ */ n(
1059
- je,
1060
- {
1061
- label: h("booking.details.firstName.label"),
1062
- required: !0,
1063
- error: ie.firstName,
1064
- announceError: pe("firstName"),
1065
- children: /* @__PURE__ */ n(
1066
- Pt,
1067
- {
1068
- autoComplete: "given-name",
1069
- value: e.firstName ?? "",
1070
- onChange: (d) => q({ firstName: d.target.value }),
1071
- onBlur: () => de("firstName")
1072
- }
1073
- )
1074
- }
1075
- ),
1076
- /* @__PURE__ */ n(
1077
- je,
1078
- {
1079
- label: h("booking.details.lastName.label"),
1080
- required: !0,
1081
- error: ie.lastName,
1082
- announceError: pe("lastName"),
1083
- children: /* @__PURE__ */ n(
1084
- Pt,
1085
- {
1086
- autoComplete: "family-name",
1087
- value: e.lastName ?? "",
1088
- onChange: (d) => q({ lastName: d.target.value }),
1089
- onBlur: () => de("lastName")
1090
- }
1091
- )
1092
- }
1093
- )
1094
- ] }),
1095
- /* @__PURE__ */ k(
1096
- "div",
1097
- {
1098
- className: `ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)]${i ? "" : " ds:sm:grid-cols-2"}`,
1099
- children: [
1100
- !i && /* @__PURE__ */ n(
1101
- je,
1102
- {
1103
- label: h("booking.details.email.label"),
1104
- ...ot ? { required: !0 } : { optional: !0 },
1105
- error: ie.email,
1106
- announceError: pe("email"),
1107
- children: /* @__PURE__ */ n(
1108
- ss,
1109
- {
1110
- disableBuiltInValidation: r,
1111
- value: e.email ?? "",
1112
- onChange: (d) => q({ email: d.target.value }),
1113
- onBlur: () => de("email")
1114
- }
1115
- )
1116
- }
1117
- ),
1118
- /* @__PURE__ */ n(
1119
- je,
1120
- {
1121
- label: h("booking.details.mobilePhone.label"),
1122
- required: !0,
1123
- error: ie.mobilePhone,
1124
- announceError: pe("mobilePhone"),
1125
- children: /* @__PURE__ */ n(
1126
- is,
1127
- {
1128
- value: e.mobilePhone ?? "",
1129
- defaultCountry: l == null ? void 0 : l.toUpperCase(),
1130
- onChange: (d) => {
1131
- q({ mobilePhone: d }), de("mobilePhone");
1132
- }
1133
- }
1134
- )
1135
- }
1136
- )
1137
- ]
1138
- }
1139
- ),
1140
- Se && !_ || c ? /* @__PURE__ */ k("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2", children: [
1141
- Se && !_ ? Tt : null,
1142
- c ? /* @__PURE__ */ n(
1143
- je,
1144
- {
1145
- label: h("booking.details.dateOfBirth.label"),
1146
- required: !0,
1147
- error: ie.dateOfBirth,
1148
- announceError: pe("dateOfBirth"),
1149
- children: /* @__PURE__ */ n(
1150
- ns,
1151
- {
1152
- value: e.dateOfBirth ? new Date(e.dateOfBirth) : void 0,
1153
- onChange: (d) => {
1154
- q({
1155
- dateOfBirth: d ? d.toISOString().slice(0, 10) : void 0
1156
- }), de("dateOfBirth");
1157
- }
1158
- }
1159
- )
1160
- }
1161
- ) : null
1162
- ] }) : null,
1163
- Qe ? /* @__PURE__ */ n(
1164
- je,
1165
- {
1166
- label: h("booking.details.insuranceNumber.label"),
1167
- required: !0,
1168
- description: Ae.state === "pending" ? h("booking.details.insuranceNumber.checking") : void 0,
1169
- error: ie.insuranceNumber,
1170
- announceError: pe("insuranceNumber"),
1171
- children: /* @__PURE__ */ n(
1172
- Pt,
1173
- {
1174
- value: e.insuranceNumber ?? "",
1175
- onChange: (d) => q({ insuranceNumber: d.target.value }),
1176
- onBlur: () => de("insuranceNumber")
1177
- }
1178
- )
1179
- }
1180
- ) : null,
1181
- _ ? /* @__PURE__ */ k(
1182
- "div",
1183
- {
1184
- ref: St,
1185
- "data-component": "booking-billing",
1186
- role: "group",
1187
- "aria-labelledby": `${H}-billing-heading`,
1188
- "aria-describedby": `${H}-billing-intro`,
1189
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-md)] ds:border ds:border-[var(--border)] ds:p-[var(--spacing-sm)]",
1190
- onBlur: (d) => {
1191
- var te;
1192
- const A = (te = d.target.closest("[data-address-field]")) == null ? void 0 : te.getAttribute("data-address-field");
1193
- (A === "street" || A === "city" || A === "postcode") && de(z[A]);
1194
- },
1195
- children: [
1196
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
1197
- /* @__PURE__ */ n(
1198
- "h3",
1199
- {
1200
- id: `${H}-billing-heading`,
1201
- className: "type-label ds:m-0 ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]",
1202
- children: h("booking.details.billing.heading")
1203
- }
1204
- ),
1205
- /* @__PURE__ */ n(
1206
- "p",
1207
- {
1208
- id: `${H}-billing-intro`,
1209
- className: "type-body-sm ds:m-0 ds:text-[color:var(--muted-foreground)]",
1210
- children: h("booking.details.billing.intro")
1211
- }
1212
- )
1213
- ] }),
1214
- Se ? Tt : null,
1215
- /* @__PURE__ */ n(
1216
- os,
1217
- {
1218
- value: oe,
1219
- onChange: (d) => {
1220
- var A;
1221
- return (
1222
- // The name is set from the patient's own on submit.
1223
- q({
1224
- billing: yi(
1225
- d,
1226
- "",
1227
- // A second line belongs to its street: it goes when the
1228
- // patient writes another, and returns with the first.
1229
- d.street.trim() === ((A = Ye.current) == null ? void 0 : A.street) ? Ye.current.line2 : null
1230
- )
1231
- })
1232
- );
1233
- },
1234
- popularCountries: Si,
1235
- layout: "grid",
1236
- fields: xe ? void 0 : ["street", "city", "postcode"],
1237
- required: xe ? ["country", "street", "city", "postcode", "province"] : ["country", "street", "city", "postcode"],
1238
- errors: {
1239
- country: ie[z.country],
1240
- street: ie[z.street],
1241
- city: ie[z.city],
1242
- postcode: ie[z.postcode],
1243
- province: ie[z.province]
1244
- },
1245
- announceErrors: {
1246
- country: pe(z.country),
1247
- street: pe(z.street),
1248
- city: pe(z.city),
1249
- postcode: pe(z.postcode),
1250
- province: pe(z.province)
1251
- }
1252
- }
1253
- )
1254
- ]
1255
- }
1256
- ) : null,
1257
- m ? /* @__PURE__ */ n(
1258
- je,
1259
- {
1260
- label: h("booking.details.note.label"),
1261
- description: h("booking.details.note.helper", {
1262
- max: hn
1263
- }),
1264
- children: /* @__PURE__ */ n(
1265
- rs,
1266
- {
1267
- value: e.note ?? "",
1268
- maxLength: hn,
1269
- rows: 3,
1270
- onChange: (d) => q({ note: d.target.value })
1271
- }
1272
- )
1273
- }
1274
- ) : null,
1275
- v ? /* @__PURE__ */ n(
1276
- gt,
1277
- {
1278
- checked: !!e.returningPatient,
1279
- onCheckedChange: (d) => q({ returningPatient: d === !0 }),
1280
- label: h("booking.details.returningPatient.label")
1281
- }
1282
- ) : null,
1283
- ft !== void 0 ? /* @__PURE__ */ k(
1284
- "div",
1285
- {
1286
- "data-component": "booking-critical-information",
1287
- role: "group",
1288
- "aria-labelledby": `${H}-critical-information-heading`,
1289
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:rounded-[var(--radius-md)] ds:border ds:border-[var(--border)] ds:bg-[var(--muted)] ds:p-[var(--spacing-sm)]",
1290
- children: [
1291
- /* @__PURE__ */ n(
1292
- "h3",
1293
- {
1294
- id: `${H}-critical-information-heading`,
1295
- className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0",
1296
- children: h("booking.details.criticalInformation.heading")
1297
- }
1298
- ),
1299
- /* @__PURE__ */ n(
1300
- "p",
1301
- {
1302
- dir: "auto",
1303
- className: "type-body-sm ds:m-0 ds:whitespace-pre-wrap ds:break-words ds:text-[var(--foreground)]",
1304
- children: gi(ft).map(
1305
- (d, A) => d.kind === "link" ? /* @__PURE__ */ n(
1306
- "a",
1307
- {
1308
- href: d.href,
1309
- target: "_blank",
1310
- rel: "noopener noreferrer",
1311
- dir: "ltr",
1312
- className: en,
1313
- children: d.text
1314
- },
1315
- A
1316
- ) : /* @__PURE__ */ n(Yn, { children: d.text }, A)
1317
- )
1318
- }
1319
- ),
1320
- /* @__PURE__ */ n(
1321
- gt,
1322
- {
1323
- checked: !!e.criticalInformationAccepted,
1324
- onCheckedChange: (d) => q({ criticalInformationAccepted: d === !0 }),
1325
- "aria-required": !0,
1326
- label: /* @__PURE__ */ k(me, { children: [
1327
- h("booking.details.criticalInformation.accept"),
1328
- /* @__PURE__ */ n(
1329
- "span",
1330
- {
1331
- "aria-hidden": "true",
1332
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1333
- children: "*"
1334
- }
1335
- )
1336
- ] })
1337
- }
1338
- )
1339
- ]
1340
- }
1341
- ) : null,
1342
- f ? /* @__PURE__ */ k(
1343
- "div",
1344
- {
1345
- "data-component": "booking-payment-notice",
1346
- role: "group",
1347
- "aria-labelledby": `${H}-payment-heading`,
1348
- "data-notice-style": N,
1349
- className: ki({
1350
- noticeStyle: N
1351
- }),
1352
- children: [
1353
- N === "highlighted" ? /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
1354
- /* @__PURE__ */ n("span", { className: "ds:flex ds:size-9 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-full ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]", children: /* @__PURE__ */ n(as, { "aria-hidden": "true", className: "ds:size-5" }) }),
1355
- /* @__PURE__ */ n(
1356
- "h3",
1357
- {
1358
- id: `${H}-payment-heading`,
1359
- className: "type-title-item ds:m-0 ds:flex-1",
1360
- children: h("booking.payment.noticeTitle")
1361
- }
1362
- ),
1363
- /* @__PURE__ */ n(
1364
- "span",
1365
- {
1366
- "aria-hidden": "true",
1367
- className: "type-title-card ds:shrink-0 ds:text-[var(--foreground)]",
1368
- children: ke
1369
- }
1370
- )
1371
- ] }) : /* @__PURE__ */ n(
1372
- "h3",
1373
- {
1374
- id: `${H}-payment-heading`,
1375
- className: "type-label ds:m-0",
1376
- children: h("booking.payment.noticeTitle")
1377
- }
1378
- ),
1379
- /* @__PURE__ */ n("p", { className: "type-body-sm ds:m-0", children: h("booking.payment.noticeBody", { amount: ke }) }),
1380
- We ? /* @__PURE__ */ n(
1381
- "a",
1382
- {
1383
- href: We,
1384
- target: "_blank",
1385
- rel: "noopener noreferrer",
1386
- className: "type-body-sm ds:inline-flex ds:items-center ds:self-start ds:min-h-[var(--min-target-size)] ds:rounded-[var(--radius-sm)] ds:underline ds:text-[var(--foreground)] ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1387
- children: h("booking.payment.terms")
1388
- }
1389
- ) : null,
1390
- /* @__PURE__ */ n(
1391
- gt,
1392
- {
1393
- checked: lt,
1394
- onCheckedChange: (d) => {
1395
- Et(
1396
- d === !0 ? qe : void 0
1397
- ), q({ paymentAccepted: d === !0 });
1398
- },
1399
- "aria-required": !0,
1400
- label: /* @__PURE__ */ k(me, { children: [
1401
- h("booking.payment.accept", { amount: ke }),
1402
- /* @__PURE__ */ n(
1403
- "span",
1404
- {
1405
- "aria-hidden": "true",
1406
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1407
- children: "*"
1408
- }
1409
- )
1410
- ] })
1411
- }
1412
- )
1413
- ]
1414
- }
1415
- ) : null,
1416
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1417
- /* @__PURE__ */ n(
1418
- gt,
1419
- {
1420
- checked: !!e.privacyConsent,
1421
- onCheckedChange: (d) => q({ privacyConsent: d === !0 }),
1422
- "aria-required": !0,
1423
- label: /* @__PURE__ */ k(me, { children: [
1424
- Dt(
1425
- "booking.details.consent.privacy.label",
1426
- b
1427
- ),
1428
- /* @__PURE__ */ n(
1429
- "span",
1430
- {
1431
- "aria-hidden": "true",
1432
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1433
- children: "*"
1434
- }
1435
- )
1436
- ] })
1437
- }
1438
- ),
1439
- /* @__PURE__ */ n(
1440
- gt,
1441
- {
1442
- checked: !!e.termsConsent,
1443
- onCheckedChange: (d) => q({ termsConsent: d === !0 }),
1444
- "aria-required": !0,
1445
- label: /* @__PURE__ */ k(me, { children: [
1446
- Dt(
1447
- "booking.details.consent.terms.label",
1448
- g
1449
- ),
1450
- /* @__PURE__ */ n(
1451
- "span",
1452
- {
1453
- "aria-hidden": "true",
1454
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1455
- children: "*"
1456
- }
1457
- )
1458
- ] })
1459
- }
1460
- ),
1461
- o && ut ? /* @__PURE__ */ n(
1462
- gt,
1463
- {
1464
- checked: Je,
1465
- onCheckedChange: (d) => {
1466
- Bt(
1467
- d === !0 ? Be : void 0
1468
- ), q({ practiceConsentAccepted: d === !0 });
1469
- },
1470
- "aria-required": o.required || void 0,
1471
- label: /* @__PURE__ */ k(me, { children: [
1472
- $t(o.url) ? /* @__PURE__ */ n(
1473
- "a",
1474
- {
1475
- dir: "auto",
1476
- href: $t(o.url),
1477
- target: "_blank",
1478
- rel: "noopener noreferrer",
1479
- className: en,
1480
- children: o.label
1481
- }
1482
- ) : /* @__PURE__ */ n("span", { dir: "auto", children: o.label }),
1483
- o.required ? /* @__PURE__ */ n(
1484
- "span",
1485
- {
1486
- "aria-hidden": "true",
1487
- className: "ds:text-[var(--destructive)] ds:ms-[var(--spacing-2xs)]",
1488
- children: "*"
1489
- }
1490
- ) : null
1491
- ] })
1492
- }
1493
- ) : null
1494
- ] }),
1495
- be ? /* @__PURE__ */ n(
1496
- "div",
1497
- {
1498
- "data-component": "booking-confirmation-channels",
1499
- "data-unanswered": U || void 0,
1500
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
1501
- children: V ? /* @__PURE__ */ n(
1502
- ts,
1503
- {
1504
- variant: "horizontal",
1505
- label: h("booking.confirmation.heading"),
1506
- value: $[0] ?? "",
1507
- onValueChange: (d) => q({
1508
- confirmationChannels: [d]
1509
- }),
1510
- error: U ? h("booking.confirmation.atLeastOne") : void 0,
1511
- children: Le.map((d) => /* @__PURE__ */ n(
1512
- es,
1513
- {
1514
- value: d,
1515
- label: h(`booking.confirmation.channel.${d}`)
1516
- },
1517
- d
1518
- ))
1519
- }
1520
- ) : /* @__PURE__ */ n(
1521
- Xn,
1522
- {
1523
- label: h("booking.confirmation.heading"),
1524
- helperText: h("booking.confirmation.helper"),
1525
- value: $,
1526
- onChange: (d) => q({
1527
- confirmationChannels: d
1528
- }),
1529
- orientation: "vertical",
1530
- options: Le.map((d) => ({
1531
- value: d,
1532
- label: h(`booking.confirmation.channel.${d}`)
1533
- })),
1534
- error: U ? h("booking.confirmation.atLeastOne") : void 0
1535
- }
1536
- )
1537
- }
1538
- ) : null,
1539
- j || ct || y ? /* @__PURE__ */ n(ne, { variant: "error", children: /* @__PURE__ */ n(ne.Description, { children: j ?? h(
1540
- y ? "booking.payment.unavailable" : "booking.payment.submitFailed"
1541
- ) }) }) : null,
1542
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
1543
- ye ? /* @__PURE__ */ n(
1544
- "p",
1545
- {
1546
- id: et,
1547
- "data-slot": "submit-hint",
1548
- className: "type-body-sm ds:m-0 ds:text-[var(--muted-foreground)]",
1549
- children: h("booking.details.submitHint")
1550
- }
1551
- ) : null,
1552
- /* @__PURE__ */ n(
1553
- tt,
1554
- {
1555
- intent: "primary",
1556
- size: "md",
1557
- type: "submit",
1558
- disabled: se || y,
1559
- "aria-disabled": !Re || void 0,
1560
- "aria-describedby": ye ? et : void 0,
1561
- startIcon: se ? /* @__PURE__ */ n(In, { variant: "pulse", size: "sm" }) : void 0,
1562
- children: f ? h("booking.payment.submit", { amount: ke }) : h("booking.details.submit")
1563
- }
1564
- )
1565
- ] })
1566
- ]
1567
- }
1568
- );
1569
- }
1570
- );
1571
- dn.displayName = "BookingDetailsForm";
1572
- const Mt = [
1573
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
1574
- "ds:focus-visible:outline-solid",
1575
- "ds:focus-visible:outline-[var(--ring)]",
1576
- "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1577
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
1578
- ].join(" ");
1579
- function wi({
1580
- length: e = 5,
1581
- onVerify: t,
1582
- onResend: s,
1583
- resendSeconds: i = 60,
1584
- phoneHint: r,
1585
- onVerified: a
1586
- }) {
1587
- const { t: c, i18n: p } = Y("ui"), u = bt(), m = bt(), v = F(null), b = F(null), g = F(null), o = F(!1), f = F(!1), [I, y] = G(null), [B, N] = G(!1), [x, S] = G(null), [D, T] = G(
1588
- null
1589
- ), [E, l] = G(0), w = Number.isFinite(i) ? Math.max(0, Math.ceil(i)) : 60, [O, V] = G(
1590
- () => Date.now() + w * 1e3
1591
- ), [j, Z] = G(w), h = x === "too-many-attempts";
1592
- K(() => (o.current = !0, () => {
1593
- o.current = !1;
1594
- }), []), K(() => {
1595
- var M;
1596
- (M = b.current) == null || M.focus();
1597
- }, [E]), K(() => {
1598
- var we, fe;
1599
- if (I || !h && D !== "resend") return;
1600
- const M = document.activeElement, J = (we = v.current) == null ? void 0 : we.closest("section");
1601
- M && M !== document.body && !(J != null && J.contains(M)) || (g.current && !g.current.disabled ? g.current.focus() : (fe = v.current) == null || fe.focus());
1602
- }, [I, h, D]), K(() => {
1603
- if (j === 0) return;
1604
- const M = setTimeout(() => {
1605
- Z(Math.max(0, Math.ceil((O - Date.now()) / 1e3)));
1606
- }, 1e3);
1607
- return () => clearTimeout(M);
1608
- }, [O, j]);
1609
- const ee = async (M) => {
1610
- if (!(f.current || h)) {
1611
- f.current = !0, y("verify"), N(!1), S(null), T(null);
1612
- try {
1613
- const J = await t(M);
1614
- if (!o.current) return;
1615
- J.ok ? a() : (S(J.reason), J.reason !== "too-many-attempts" && l((we) => we + 1));
1616
- } catch {
1617
- if (!o.current) return;
1618
- T("verify"), l((J) => J + 1);
1619
- } finally {
1620
- f.current = !1, o.current && y(null);
1621
- }
1622
- }
1623
- }, H = async () => {
1624
- if (!(f.current || Date.now() < O)) {
1625
- f.current = !0, y("resend"), N(!1), T(null);
1626
- try {
1627
- if (await s(), !o.current) return;
1628
- V(Date.now() + w * 1e3), Z(w), S(null), N(!0), l((M) => M + 1);
1629
- } catch {
1630
- o.current && T("resend");
1631
- } finally {
1632
- f.current = !1, o.current && y(null);
1633
- }
1634
- }
1635
- }, Pe = x === "wrong" ? c("booking.code.wrong") : x === "expired" ? c("booking.code.expired") : h ? c("booking.code.tooManyAttempts") : void 0;
1636
- return /* @__PURE__ */ k(
1637
- "section",
1638
- {
1639
- "aria-labelledby": u,
1640
- "data-component": "booking-code-step",
1641
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
1642
- children: [
1643
- /* @__PURE__ */ n(
1644
- "h3",
1645
- {
1646
- ref: v,
1647
- id: u,
1648
- tabIndex: -1,
1649
- className: `type-title-card ds:m-0 ${Mt}`,
1650
- children: c("booking.code.heading")
1651
- }
1652
- ),
1653
- /* @__PURE__ */ n("p", { id: m, className: "type-body ds:m-0", children: r ? /* @__PURE__ */ n(
1654
- xn,
1655
- {
1656
- t: c,
1657
- ns: "ui",
1658
- i18nKey: "booking.code.instructionWithPhone",
1659
- values: { phone: r },
1660
- components: { phone: /* @__PURE__ */ n("bdi", {}) }
1661
- }
1662
- ) : c("booking.code.instruction") }),
1663
- /* @__PURE__ */ n(je, { label: c("booking.code.label"), error: Pe, children: /* @__PURE__ */ n("div", { dir: "ltr", children: /* @__PURE__ */ n(
1664
- cs,
1665
- {
1666
- ref: b,
1667
- length: e,
1668
- mode: "alphanumeric",
1669
- "aria-describedby": m,
1670
- disabled: !!I || h,
1671
- onComplete: ee
1672
- },
1673
- E
1674
- ) }) }),
1675
- D ? /* @__PURE__ */ n(ne, { variant: "error", children: /* @__PURE__ */ n(ne.Description, { children: c(D === "verify" ? "booking.code.verifyFailed" : "booking.code.resendFailed") }) }) : null,
1676
- /* @__PURE__ */ n("p", { role: "status", className: "type-body ds:m-0", children: I === "verify" ? c("booking.code.verifying") : B ? c("booking.code.resent") : null }),
1677
- /* @__PURE__ */ n(
1678
- tt,
1679
- {
1680
- ref: g,
1681
- type: "button",
1682
- intent: "secondary",
1683
- className: "ds:self-start",
1684
- disabled: j > 0 || !!I,
1685
- loading: I === "resend",
1686
- onClick: H,
1687
- children: j > 0 ? c("booking.code.resendCountdown", {
1688
- seconds: new Intl.NumberFormat(p.language).format(j)
1689
- }) : c("booking.code.resend")
1690
- }
1691
- )
1692
- ]
1693
- }
1694
- );
1695
- }
1696
- function Pn(e) {
1697
- const t = e.payment;
1698
- if (!t) return;
1699
- const s = (t.currencyCode ?? "EUR").toUpperCase();
1700
- if (!(!Number.isSafeInteger(t.amountCents) || t.amountCents <= 0 || !["full", "deposit"].includes(t.kind) || !/^[A-Z]{3}$/.test(s)))
1701
- return {
1702
- serviceId: e.id,
1703
- kind: t.kind,
1704
- amountCents: t.amountCents,
1705
- currencyCode: s
1706
- };
1707
- }
1708
- function Ci(e) {
1709
- var r;
1710
- const t = (r = e.priceLabel) != null && r.trim() ? e.priceLabel : void 0, s = t ? { label: t } : void 0;
1711
- if (!e.payment) return { price: s };
1712
- const i = Pn(e);
1713
- return i ? {
1714
- price: s ?? (i.kind === "full" ? { amount: i } : void 0),
1715
- payment: i
1716
- } : { price: s, payment: "unavailable" };
1717
- }
1718
- function Ai(e, t, s) {
1719
- const i = e.filter(
1720
- (a) => t.includes(a.id)
1721
- ), r = (s == null ? void 0 : s.serviceId) ?? (t.length === 1 ? t[0] : void 0);
1722
- if (r) {
1723
- const a = i.find((p) => p.id === r);
1724
- if (!a) return { blocked: !0 };
1725
- const c = Pn(a);
1726
- return { payment: c, blocked: !!(a.payment && !c) };
1727
- }
1728
- return { blocked: i.some((a) => !!a.payment) };
1729
- }
1730
- function Kt(e) {
1731
- return e ? JSON.stringify([
1732
- e.serviceId,
1733
- e.kind,
1734
- e.amountCents,
1735
- e.currencyCode
1736
- ]) : "";
1737
- }
1738
- function Ti({
1739
- services: e,
1740
- value: t,
1741
- availableSlots: s,
1742
- onSubmit: i,
1743
- onChange: r,
1744
- paymentState: a,
1745
- submitting: c,
1746
- paymentTermsUrl: p,
1747
- renderPayment: u,
1748
- codeStep: m
1749
- }) {
1750
- var J, we, fe;
1751
- const v = JSON.stringify([
1752
- t.insuranceType,
1753
- t.specialtyId,
1754
- t.specialtyIds,
1755
- Ge(t),
1756
- t.operatorId,
1757
- t.operatorIds,
1758
- t.date,
1759
- t.slotKey
1760
- ]), b = F(
1761
- void 0
1762
- ), o = (t.date ? (J = s[t.date]) == null ? void 0 : J.find((W) => W.key === t.slotKey) : void 0) ?? (((we = b.current) == null ? void 0 : we.selection) === v ? b.current.slot : void 0), f = Ai(
1763
- e,
1764
- Ge(t),
1765
- o
1766
- ), I = f.blocked || !!(f.payment && !u), y = JSON.stringify([
1767
- v,
1768
- o == null ? void 0 : o.serviceId,
1769
- Kt(f.payment),
1770
- p,
1771
- I
1772
- ]), B = f.payment ? JSON.stringify([Kt(f.payment), p]) : "", N = F(void 0), x = !!((fe = t.details) != null && fe.paymentAccepted);
1773
- K(() => {
1774
- if (!x) N.current = void 0;
1775
- else if (B) N.current === void 0 ? N.current = B : N.current !== B && (N.current = void 0, r({
1776
- ...t,
1777
- details: { ...t.details, paymentAccepted: !1 }
1778
- }));
1779
- else return;
1780
- }, [x, B, r, t]);
1781
- const S = F(y);
1782
- S.current = y;
1783
- const [D, T] = G({ status: "idle" }), E = F(0), l = F(!1), w = F(!0), O = F(!1), V = F(void 0), j = F(y);
1784
- K(() => (w.current = !0, () => {
1785
- w.current = !1, E.current += 1;
1786
- }), []);
1787
- const Z = D.status === "payment" || D.status === "code" || D.status === "success";
1788
- K(() => {
1789
- j.current === y || O.current || Z || (j.current = y, E.current += 1, l.current = !1, T({ status: "idle" }));
1790
- }, [y, Z]);
1791
- const h = Z || j.current === y ? D.session : void 0, ee = R(
1792
- () => h && (a == null ? void 0 : a.sessionId) === h.id ? a : h ? { sessionId: h.id, status: "ready" } : void 0,
1793
- [h, a]
1794
- );
1795
- h && ee && "phase" in ee && ee.phase === "completion" && (V.current = h.id);
1796
- const H = R(
1797
- () => h && V.current === h.id && ee && ee.status !== "paid" && (!("phase" in ee) || ee.phase !== "completion") ? {
1798
- sessionId: h.id,
1799
- status: "processing",
1800
- phase: "completion"
1801
- } : ee,
1802
- [h, ee]
1803
- );
1804
- K(() => {
1805
- !h || !H || O.current || (H.status === "paid" ? (O.current = !0, T((W) => ({
1806
- ...W,
1807
- status: W.codeStep ? "code" : "success"
1808
- }))) : H.status === "cancelled" && (E.current += 1, l.current = !1, b.current = void 0, r({
1809
- ...t,
1810
- details: { ...t.details, paymentAccepted: !1 }
1811
- }), T({ status: "idle", cancelled: !0 })));
1812
- }, [h, H, r, t]);
1813
- const Pe = () => {
1814
- E.current += 1, l.current = !1, O.current = !1, V.current = void 0, b.current = void 0, j.current = S.current, T({ status: "idle" });
1815
- }, M = async (W) => {
1816
- var Ae, Fe, re, Ee, de;
1817
- if (!(o != null && o.available) || I || c || l.current || D.status === "payment" || O.current || f.payment && !W.paymentAccepted) return;
1818
- l.current = !0;
1819
- const Ve = m ? { ...m } : void 0;
1820
- b.current = { selection: v, slot: { ...o } };
1821
- const ct = ++E.current, ge = y;
1822
- j.current = ge;
1823
- const se = {
1824
- slot: { ...o, meta: o.meta ? { ...o.meta } : void 0 },
1825
- value: {
1826
- ...t,
1827
- serviceIds: (Ae = t.serviceIds) == null ? void 0 : Ae.slice(),
1828
- specialtyIds: (Fe = t.specialtyIds) == null ? void 0 : Fe.slice(),
1829
- operatorIds: (re = t.operatorIds) == null ? void 0 : re.slice(),
1830
- operatorId: Ln(t) ?? t.operatorId,
1831
- details: { ...W }
1832
- },
1833
- details: {
1834
- ...W,
1835
- confirmationChannels: (Ee = W.confirmationChannels) == null ? void 0 : Ee.slice()
1836
- },
1837
- ...f.payment ? { payment: { ...f.payment } } : {}
1838
- }, ce = () => w.current && E.current === ct && S.current === ge;
1839
- T({ status: "submitting" });
1840
- let Ce = !1;
1841
- try {
1842
- const he = await i(se);
1843
- if (!ce()) return;
1844
- if (se.payment) {
1845
- const Te = he == null ? void 0 : he.paymentSession;
1846
- if (!((de = Te == null ? void 0 : Te.id) != null && de.trim()) || Kt(Te.payment) !== Kt(se.payment)) {
1847
- T({ status: "error" });
1848
- return;
1849
- }
1850
- Ce = !0, T({
1851
- status: "payment",
1852
- snapshot: se,
1853
- session: { id: Te.id, payment: { ...Te.payment } },
1854
- codeStep: Ve
1855
- });
1856
- } else he != null && he.paymentSession ? T({ status: "error" }) : (O.current = !0, T({
1857
- status: Ve ? "code" : "success",
1858
- snapshot: se,
1859
- codeStep: Ve
1860
- }));
1861
- } catch {
1862
- ce() && T({ status: "error" });
1863
- } finally {
1864
- ce() && !Ce && (l.current = !1);
1865
- }
1866
- };
1867
- return {
1868
- ...D,
1869
- payment: f.payment,
1870
- blocked: I,
1871
- state: H,
1872
- activeSession: h,
1873
- submit: M,
1874
- reset: Pe,
1875
- completeCode: () => {
1876
- T(
1877
- (W) => W.status === "code" ? { ...W, status: "success", codeVerified: !0 } : W
1878
- );
1879
- }
1880
- };
1881
- }
1882
- const Di = Ft(
1883
- "ds:flex ds:w-full ds:flex-col ds:text-[var(--foreground)]",
1884
- {
1885
- variants: {
1886
- variant: {
1887
- "inline-list": "ds:gap-[var(--spacing-md)]",
1888
- accordion: "ds:gap-[var(--spacing-md)]",
1889
- calendar: "ds:gap-[var(--spacing-md)]",
1890
- flexible: "ds:gap-[var(--spacing-lg)]",
1891
- progress: "ds:gap-[var(--spacing-sm)]"
1892
- },
1893
- // `surface="elevated"` matches `Card variant="elevated"` — same
1894
- // tokens, same padding, same boundary behaviour — so consumers can
1895
- // drop their own Card wraps without a double-card look. Default
1896
- // `'flat'` preserves 0.30.x rendering.
1897
- surface: {
1898
- flat: "",
1899
- elevated: [
1900
- "ds:rounded-[var(--radius-lg)]",
1901
- "ds:bg-[var(--card)] ds:text-[var(--card-foreground)]",
1902
- "ds:border ds:border-[color:var(--card-border)]",
1903
- "ds:shadow-[var(--shadow-card)]",
1904
- "ds:p-[var(--spacing-md)]"
1905
- ].join(" ")
1906
- }
1907
- },
1908
- defaultVariants: { variant: "inline-list", surface: "flat" }
1909
- }
1910
- ), Oi = [
1911
- [
1912
- /\b(estetic|aesthetic|botox|filler|mesoterap|chirurgia\s*plastic)/i,
1913
- fn
1914
- ],
1915
- [/\b(cardio|ecg|elettrocardio|ecocardio|cuore|heart)/i, xs],
1916
- [/\b(dent|odonto|tooth|teeth|pulizia|igien|smile)/i, Us],
1917
- [/\b(oftalmo|ocul|ophthal|vision|occhi|eye)/i, Is],
1918
- [/\b(otorin|udito|orecchi|hearing|ear)/i, _s],
1919
- [/\b(neuro|brain|cervello)/i, Es],
1920
- [/\b(pediatr|child|bambin)/i, Ns],
1921
- [/\b(ortop|ortho|osteo|skeleton|ossa|bone)/i, Ms],
1922
- [/\b(lab|analis|test|sang|esami)/i, Vs],
1923
- [/\b(farmaco|pharm|pillol|refill)/i, qs],
1924
- [/\b(chirurg|surg|intervent|operat)/i, zs],
1925
- [/\b(scan|rx|x-?ray|raggi|imag|radio|risonan|ecograf|ultras)/i, ws],
1926
- [/\b(vacc|inject|inie|punto)/i, fn],
1927
- [/\b(derma|skin|pelle)/i, Cs],
1928
- [/\b(prima\s*visit|first\s*visit|consult|consulto|valutaz)/i, As],
1929
- [/\b(general|medicin|family|control|check[-\s]?up)/i, Ds]
1930
- ];
1931
- function Mi(e) {
1932
- for (const [t, s] of Oi)
1933
- if (t.test(e)) return s;
1934
- return null;
1935
- }
1936
- function Fi(e) {
1937
- const t = Mi(e.label) ?? Ss;
1938
- return /* @__PURE__ */ n(t, { "aria-hidden": "true", className: "ds:size-5" });
1939
- }
1940
- function Vn() {
1941
- const { t: e, i18n: t } = Y("ui");
1942
- return (s) => {
1943
- const i = Ci(s), r = (c) => Gt(c.amountCents, c.currencyCode, t.language), a = i.price ? "label" in i.price ? i.price.label : r(i.price.amount) : void 0;
1944
- return i.payment === "unavailable" ? {
1945
- price: a,
1946
- payment: e("booking.payment.unavailable"),
1947
- paymentTone: "error"
1948
- } : {
1949
- price: a,
1950
- payment: i.payment ? e(`booking.payment.${i.payment.kind}`, {
1951
- amount: r(i.payment)
1952
- }) : void 0,
1953
- paymentTone: "default"
1954
- };
1955
- };
1956
- }
1957
- function at(e) {
1958
- return jt(e, "yyyy-MM-dd");
1959
- }
1960
- const Ei = [
1961
- "ds:relative ds:flex ds:items-center ds:justify-center",
1962
- "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]",
1963
- "ds:rounded-[var(--radius-sm)]",
1964
- "ds:text-[length:var(--font-size-sm)]",
1965
- "ds:transition-colors ds:duration-[var(--animation-duration)]",
1966
- "ds:motion-reduce:transition-none",
1967
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
1968
- "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
1969
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
1970
- ].join(" "), Bi = Ft(Ei, {
1971
- variants: {
1972
- state: {
1973
- available: "ds:cursor-pointer ds:text-[var(--foreground)] ds:hover:bg-[var(--muted)]/30",
1974
- unavailable: "ds:cursor-not-allowed ds:text-[var(--muted-foreground)]/60",
1975
- selected: "ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)] ds:font-[var(--font-weight-semibold)]",
1976
- outside: "ds:text-[var(--muted-foreground)]/40"
1977
- }
1978
- },
1979
- defaultVariants: { state: "unavailable" }
1980
- });
1981
- function Li({
1982
- availableDates: e,
1983
- selectedDate: t,
1984
- onSelectDate: s,
1985
- locale: i,
1986
- loading: r
1987
- }) {
1988
- const { t: a } = Y("ui"), c = R(() => t ? Ot(Ie(t)) : e.length > 0 ? Ot(Ie(e[0])) : Ot(/* @__PURE__ */ new Date()), [t, e]), [p, u] = G(c), [m, v] = G(null), b = R(() => {
1989
- const N = Ot(p), x = gs(p), S = N.getDay(), D = x.getDate(), T = [];
1990
- for (let E = S; E > 0; E -= 1) {
1991
- const l = new Date(N);
1992
- l.setDate(N.getDate() - E), T.push(l);
1993
- }
1994
- for (let E = 0; E < D; E += 1) {
1995
- const l = new Date(N);
1996
- l.setDate(N.getDate() + E), T.push(l);
1997
- }
1998
- for (; T.length < 42; ) {
1999
- const E = T[T.length - 1], l = new Date(E);
2000
- l.setDate(E.getDate() + 1), T.push(l);
2001
- }
2002
- return T;
2003
- }, [p]), g = R(() => {
2004
- try {
2005
- return new Intl.DateTimeFormat(i, {
2006
- month: "long",
2007
- year: "numeric"
2008
- }).format(p);
2009
- } catch {
2010
- return jt(p, "MMMM yyyy");
2011
- }
2012
- }, [p, i]), o = R(() => {
2013
- const N = new Date(2024, 0, 7);
2014
- return Array.from({ length: 7 }, (x, S) => {
2015
- const D = new Date(N);
2016
- D.setDate(N.getDate() + S);
2017
- try {
2018
- return new Intl.DateTimeFormat(i, { weekday: "short" }).format(D);
2019
- } catch {
2020
- return jt(D, "EEE");
2021
- }
2022
- });
2023
- }, [i]), f = R(() => new Set(e), [e]), I = Ne(
2024
- (N) => f.has(at(N)),
2025
- [f]
2026
- ), y = R(() => {
2027
- if (m) return m;
2028
- if (t) return Ie(t);
2029
- const N = b.find(
2030
- (x) => Vt(x, p) && I(x)
2031
- );
2032
- return N || (b.find((x) => Vt(x, p)) ?? null);
2033
- }, [m, t, b, p, I]), B = Ne(
2034
- (N, x) => {
2035
- let S = null;
2036
- switch (N.key) {
2037
- case "ArrowLeft":
2038
- S = new Date(x), S.setDate(x.getDate() - 1);
2039
- break;
2040
- case "ArrowRight":
2041
- S = new Date(x), S.setDate(x.getDate() + 1);
2042
- break;
2043
- case "ArrowUp":
2044
- S = new Date(x), S.setDate(x.getDate() - 7);
2045
- break;
2046
- case "ArrowDown":
2047
- S = new Date(x), S.setDate(x.getDate() + 7);
2048
- break;
2049
- case "Home":
2050
- S = new Date(x), S.setDate(x.getDate() - x.getDay());
2051
- break;
2052
- case "End":
2053
- S = new Date(x), S.setDate(x.getDate() + (6 - x.getDay()));
2054
- break;
2055
- case "Enter":
2056
- case " ": {
2057
- N.preventDefault(), I(x) && s(at(x));
2058
- return;
2059
- }
2060
- default:
2061
- return;
2062
- }
2063
- S && (N.preventDefault(), Vt(S, p) || u(Ot(S)), v(S));
2064
- },
2065
- [I, s, p]
2066
- );
2067
- return r ? /* @__PURE__ */ k(
2068
- "div",
2069
- {
2070
- role: "status",
2071
- "aria-live": "polite",
2072
- "aria-label": a("common.loading"),
2073
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
2074
- children: [
2075
- /* @__PURE__ */ n(Ut, { variant: "text", width: "40%" }),
2076
- /* @__PURE__ */ n("div", { className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]", children: Array.from({ length: 42 }, (N, x) => /* @__PURE__ */ n(Ut, { variant: "rounded", height: "2.5rem" }, `mg-skel-${x}`)) })
2077
- ]
2078
- }
2079
- ) : /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2080
- /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
2081
- /* @__PURE__ */ n(
2082
- pn,
2083
- {
2084
- icon: /* @__PURE__ */ n(vs, {}),
2085
- "aria-label": a("booking.previousMonth"),
2086
- size: "sm",
2087
- intent: "ghost",
2088
- flipIconInRtl: !0,
2089
- onClick: () => {
2090
- u((N) => Ws(N)), v(null);
2091
- }
2092
- }
2093
- ),
2094
- /* @__PURE__ */ n(
2095
- "span",
2096
- {
2097
- className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)]",
2098
- "aria-live": "polite",
2099
- children: g
2100
- }
2101
- ),
2102
- /* @__PURE__ */ n(
2103
- pn,
2104
- {
2105
- icon: /* @__PURE__ */ n(bs, {}),
2106
- "aria-label": a("booking.nextMonth"),
2107
- size: "sm",
2108
- intent: "ghost",
2109
- flipIconInRtl: !0,
2110
- onClick: () => {
2111
- u((N) => Cn(N, 1)), v(null);
2112
- }
2113
- }
2114
- )
2115
- ] }),
2116
- /* @__PURE__ */ k(
2117
- "div",
2118
- {
2119
- role: "grid",
2120
- "aria-label": a("booking.monthGridLabel"),
2121
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
2122
- children: [
2123
- /* @__PURE__ */ n(
2124
- "div",
2125
- {
2126
- role: "row",
2127
- className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
2128
- children: o.map((N, x) => /* @__PURE__ */ n(
2129
- "div",
2130
- {
2131
- role: "columnheader",
2132
- className: "type-meta ds:text-center ds:text-[var(--muted-foreground)] ds:font-[var(--font-weight-medium)]",
2133
- children: N
2134
- },
2135
- `wd-${x}`
2136
- ))
2137
- }
2138
- ),
2139
- Array.from({ length: 6 }, (N, x) => /* @__PURE__ */ n(
2140
- "div",
2141
- {
2142
- role: "row",
2143
- className: "ds:grid ds:grid-cols-7 ds:gap-[var(--spacing-2xs)]",
2144
- children: b.slice(x * 7, x * 7 + 7).map((S, D) => {
2145
- const T = x * 7 + D, E = Vt(S, p), l = E && I(S), w = t ? mn(S, Ie(t)) : !1, O = E ? w ? "selected" : l ? "available" : "unavailable" : "outside", V = y ? mn(y, S) : !1, j = (() => {
2146
- try {
2147
- return new Intl.DateTimeFormat(i, {
2148
- dateStyle: "full"
2149
- }).format(S);
2150
- } catch {
2151
- return jt(S, "PPP");
2152
- }
2153
- })();
2154
- return /* @__PURE__ */ n(
2155
- "button",
2156
- {
2157
- type: "button",
2158
- role: "gridcell",
2159
- "aria-label": j,
2160
- "aria-selected": w || void 0,
2161
- "aria-disabled": !l || void 0,
2162
- tabIndex: V ? 0 : -1,
2163
- disabled: !l,
2164
- onClick: () => {
2165
- l && s(at(S));
2166
- },
2167
- onKeyDown: (Z) => B(Z, S),
2168
- className: Bi({ state: O }),
2169
- children: /* @__PURE__ */ n("span", { "aria-hidden": "true", children: S.getDate() })
2170
- },
2171
- `mg-cell-${T}`
2172
- );
2173
- })
2174
- },
2175
- `mg-row-${x}`
2176
- ))
2177
- ]
2178
- }
2179
- )
2180
- ] });
2181
- }
2182
- const Ri = Ft(
2183
- [
2184
- "ds:relative ds:flex ds:w-full ds:items-center ds:gap-[var(--spacing-md)]",
2185
- "ds:min-h-[var(--min-target-size)]",
2186
- "ds:rounded-[var(--radius-md)]",
2187
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
2188
- "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]",
2189
- "ds:text-start",
2190
- "ds:transition-[background-color,box-shadow]",
2191
- "ds:duration-[var(--animation-duration)]",
2192
- "ds:motion-reduce:transition-none",
2193
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
2194
- "ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2195
- "ds:forced-colors:[outline:1px_solid_CanvasText]",
2196
- "ds:cursor-pointer"
2197
- ].join(" "),
2198
- {
2199
- variants: {
2200
- state: {
2201
- idle: "ds:bg-[var(--card)] ds:shadow-[var(--shadow-sm)] ds:hover:shadow-[var(--shadow-md)]",
2202
- selected: "ds:bg-[color-mix(in_srgb,var(--primary)_8%,var(--card))] ds:shadow-[var(--shadow-sm)]"
2203
- }
2204
- },
2205
- defaultVariants: { state: "idle" }
2206
- }
2207
- );
2208
- function _i({
2209
- services: e,
2210
- selectedServiceId: t,
2211
- onSelect: s,
2212
- showDuration: i
2213
- }) {
2214
- const { t: r } = Y("ui"), a = Vn(), c = bt(), [p, u] = G(() => {
2215
- if (t) {
2216
- const g = e.findIndex((o) => o.id === t);
2217
- if (g >= 0) return g;
2218
- }
2219
- return 0;
2220
- }), m = F(/* @__PURE__ */ new Map()), v = Ne((g) => {
2221
- var o;
2222
- (o = m.current.get(g)) == null || o.focus();
2223
- }, []), b = Ne(
2224
- (g, o, f) => {
2225
- const I = e.length;
2226
- if (I !== 0)
2227
- switch (g.key) {
2228
- case "ArrowDown":
2229
- case "ArrowRight": {
2230
- g.preventDefault();
2231
- const y = (o + 1) % I;
2232
- u(y), v(y);
2233
- break;
2234
- }
2235
- case "ArrowUp":
2236
- case "ArrowLeft": {
2237
- g.preventDefault();
2238
- const y = (o - 1 + I) % I;
2239
- u(y), v(y);
2240
- break;
2241
- }
2242
- case "Home": {
2243
- g.preventDefault(), u(0), v(0);
2244
- break;
2245
- }
2246
- case "End": {
2247
- g.preventDefault();
2248
- const y = I - 1;
2249
- u(y), v(y);
2250
- break;
2251
- }
2252
- case "Enter":
2253
- case " ": {
2254
- g.preventDefault(), s(f);
2255
- break;
2256
- }
2257
- }
2258
- },
2259
- [e.length, v, s]
2260
- );
2261
- return e.length === 0 ? null : /* @__PURE__ */ n(
2262
- "div",
2263
- {
2264
- role: "radiogroup",
2265
- "aria-label": r("booking.serviceListLabel"),
2266
- id: c,
2267
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
2268
- children: e.map((g, o) => {
2269
- const f = t === g.id, I = p === o, { price: y, payment: B, paymentTone: N } = a(g), x = y ? B ? r("booking.serviceCardLabelPayment", {
2270
- label: g.label,
2271
- price: y,
2272
- payment: B
2273
- }) : r("booking.serviceCardLabelPrice", {
2274
- label: g.label,
2275
- price: y
2276
- }) : B ? r("booking.serviceCardLabelPaymentNoPrice", {
2277
- label: g.label,
2278
- payment: B
2279
- }) : i ? r("booking.serviceCardLabel", {
2280
- label: g.label,
2281
- duration: g.durationMin
2282
- }) : g.label, S = Fi(g);
2283
- return /* @__PURE__ */ k(
2284
- "button",
2285
- {
2286
- ref: (D) => {
2287
- D ? m.current.set(o, D) : m.current.delete(o);
2288
- },
2289
- type: "button",
2290
- role: "radio",
2291
- "aria-checked": f,
2292
- "aria-label": x,
2293
- tabIndex: I ? 0 : -1,
2294
- onClick: () => s(g.id),
2295
- onFocus: () => u(o),
2296
- onKeyDown: (D) => b(D, o, g.id),
2297
- className: Ri({
2298
- state: f ? "selected" : "idle"
2299
- }),
2300
- children: [
2301
- /* @__PURE__ */ n(
2302
- "span",
2303
- {
2304
- "aria-hidden": "true",
2305
- 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)]",
2306
- children: S
2307
- }
2308
- ),
2309
- /* @__PURE__ */ k("span", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
2310
- /* @__PURE__ */ n(
2311
- "span",
2312
- {
2313
- dir: "auto",
2314
- className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:break-words",
2315
- children: g.label
2316
- }
2317
- ),
2318
- B ? /* @__PURE__ */ n(
2319
- "span",
2320
- {
2321
- className: ds({ tone: N }),
2322
- children: B
2323
- }
2324
- ) : y || !i ? null : /* @__PURE__ */ n("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: r("booking.serviceSummary", {
2325
- minutes: g.durationMin
2326
- }) })
2327
- ] }),
2328
- y ? /* @__PURE__ */ n(
2329
- "span",
2330
- {
2331
- "aria-hidden": "true",
2332
- className: "ds:inline-flex ds:shrink-0 ds:items-center ds:ms-auto",
2333
- children: /* @__PURE__ */ n(Nn, { variant: "accentSoft", size: "lg", children: y })
2334
- }
2335
- ) : null
2336
- ]
2337
- },
2338
- g.id
2339
- );
2340
- })
2341
- }
2342
- );
2343
- }
2344
- const Pi = Ft(
2345
- [
2346
- "ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-2xs)]",
2347
- "ds:min-h-[var(--min-target-size)]",
2348
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
2349
- "ds:pt-[var(--spacing-2xs)] ds:pb-[var(--spacing-2xs)]",
2350
- "ds:rounded-[var(--radius-md)]",
2351
- "ds:text-[length:var(--font-size-sm)] ds:font-[var(--font-weight-medium)]",
2352
- "ds:transition-[background-color,color,box-shadow] ds:duration-[var(--animation-duration)]",
2353
- "ds:motion-reduce:transition-none",
2354
- "ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
2355
- "ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
2356
- "ds:disabled:cursor-not-allowed ds:disabled:opacity-50",
2357
- "ds:forced-colors:[border:1px_solid_ButtonText] ds:forced-colors:text-[ButtonText]"
2358
- ].join(" "),
2359
- {
2360
- variants: {
2361
- state: {
2362
- 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)]",
2363
- selected: "ds:bg-[color:var(--primary)] ds:text-[color:var(--primary-foreground)] ds:shadow-[var(--shadow-sm)]",
2364
- unavailable: "ds:[outline:1px_dashed_color:var(--border)] ds:[outline-offset:-1px] ds:bg-transparent ds:text-[color:var(--muted-foreground)]"
2365
- }
2366
- },
2367
- defaultVariants: { state: "idle" }
2368
- }
2369
- );
2370
- function Vi(e) {
2371
- const [t] = e.split(":").map((i) => parseInt(i, 10)), s = Number.isFinite(t) ? t : 0;
2372
- return s < 12 ? "morning" : s < 17 ? "afternoon" : "evening";
2373
- }
2374
- function rn(e, t, s) {
2375
- if (!e) return t;
2376
- try {
2377
- return new Intl.DateTimeFormat(s, {
2378
- hour: "numeric",
2379
- minute: "2-digit"
2380
- }).format(/* @__PURE__ */ new Date(`${e}T${t}:00`));
2381
- } catch {
2382
- return t;
2383
- }
2384
- }
2385
- const $i = {
2386
- morning: ks,
2387
- afternoon: Hs,
2388
- evening: ys
2389
- };
2390
- function qi({
2391
- date: e,
2392
- slots: t,
2393
- selectedSlotKey: s,
2394
- onSelect: i,
2395
- loading: r,
2396
- locale: a
2397
- }) {
2398
- const { t: c } = Y("ui"), p = R(() => {
2399
- try {
2400
- return new Intl.DateTimeFormat(a, {
2401
- weekday: "long",
2402
- day: "numeric",
2403
- month: "long"
2404
- }).format(Ie(e));
2405
- } catch {
2406
- return e;
2407
- }
2408
- }, [e, a]), u = R(() => {
2409
- const b = {
2410
- morning: [],
2411
- afternoon: [],
2412
- evening: []
2413
- };
2414
- for (const g of t)
2415
- b[Vi(g.time)].push(g);
2416
- return b;
2417
- }, [t]), m = t.filter((b) => b.available).length, v = ["morning", "afternoon", "evening"];
2418
- return r ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2419
- /* @__PURE__ */ n(Ut, { variant: "text", width: "60%" }),
2420
- [0, 1].map((b) => /* @__PURE__ */ n(
2421
- "div",
2422
- {
2423
- className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)]",
2424
- children: [0, 1, 2].map((g) => /* @__PURE__ */ n(Ut, { variant: "rounded", height: "44px" }, g))
2425
- },
2426
- b
2427
- ))
2428
- ] }) : m === 0 ? /* @__PURE__ */ n(wn, { variant: "no-results", title: c("booking.noSlotsForDate") }) : /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
2429
- /* @__PURE__ */ k("div", { className: "ds:flex ds:items-baseline ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
2430
- /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
2431
- /* @__PURE__ */ n(
2432
- Ls,
2433
- {
2434
- "aria-hidden": "true",
2435
- className: "ds:size-4 ds:text-[color:var(--accent)]"
2436
- }
2437
- ),
2438
- /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: p })
2439
- ] }),
2440
- /* @__PURE__ */ n("span", { className: "type-meta ds:text-[var(--muted-foreground)]", children: c("booking.slotsAvailable", { count: m }) })
2441
- ] }),
2442
- v.map((b) => {
2443
- const g = u[b];
2444
- if (g.length === 0) return null;
2445
- const o = $i[b];
2446
- return /* @__PURE__ */ k(
2447
- "div",
2448
- {
2449
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
2450
- children: [
2451
- /* @__PURE__ */ k("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[color:var(--muted-foreground)]", children: [
2452
- /* @__PURE__ */ n(o, { "aria-hidden": "true", className: "ds:size-3.5" }),
2453
- /* @__PURE__ */ n("span", { className: "type-meta ds:font-[var(--font-weight-semibold)] ds:uppercase", children: c(`booking.timeOfDay.${b}`) })
2454
- ] }),
2455
- /* @__PURE__ */ n(
2456
- "div",
2457
- {
2458
- role: "group",
2459
- "aria-label": c(`booking.timeOfDay.${b}`),
2460
- className: "ds:grid ds:grid-cols-3 ds:gap-[var(--spacing-xs)] ds:sm:grid-cols-4",
2461
- children: g.map((f) => {
2462
- const I = f.key === s, y = f.available ? I ? "selected" : "idle" : "unavailable";
2463
- return /* @__PURE__ */ n(
2464
- "button",
2465
- {
2466
- type: "button",
2467
- "data-slot-id": f.key,
2468
- disabled: !f.available,
2469
- "aria-pressed": I,
2470
- "aria-label": c("booking.slotAvailableLabel", {
2471
- time: rn(e, f.time, a)
2472
- }),
2473
- onClick: () => f.available && i(f),
2474
- className: Pi({ state: y }),
2475
- children: rn(e, f.time, a)
2476
- },
2477
- f.key
2478
- );
2479
- })
2480
- }
2481
- )
2482
- ]
2483
- },
2484
- b
2485
- );
2486
- })
2487
- ] });
2488
- }
2489
- const zt = 4;
2490
- function Ki({
2491
- availableDates: e,
2492
- availableSlots: t,
2493
- value: s,
2494
- onChange: i,
2495
- onDateSelect: r,
2496
- onWindowChange: a,
2497
- loadingDates: c,
2498
- loadingSlots: p,
2499
- locale: u,
2500
- agentIdBase: m
2501
- }) {
2502
- const v = R(() => ht(/* @__PURE__ */ new Date()), []), [b, g] = G(() => {
2503
- if (s.date) {
2504
- const l = ht(Ie(s.date));
2505
- if (!vt(v, l)) return l;
2506
- }
2507
- if (e.length > 0) {
2508
- const l = ht(Ie(e[0]));
2509
- if (vt(l, v)) return l;
2510
- }
2511
- return v;
2512
- }), o = R(
2513
- () => Xt(b, zt - 1),
2514
- [b]
2515
- ), f = R(() => Array.from({ length: zt }, (l, w) => {
2516
- const O = Xt(b, w), V = at(O), Z = (t[V] ?? []).map((h) => ({
2517
- id: h.key,
2518
- // SlotGrid formats `start` as a time via Intl.DateTimeFormat —
2519
- // compose a full ISO from the column's date + the slot's HH:mm
2520
- // so the locale-formatter has a real timestamp to work with.
2521
- start: `${V}T${h.time}:00`,
2522
- available: h.available
2523
- }));
2524
- return { date: V, slots: Z };
2525
- }), [b, t]), I = vt(b, v), y = !0, B = Ne(() => {
2526
- g((l) => {
2527
- const w = hs(l, zt);
2528
- return vt(v, w) ? v : w;
2529
- });
2530
- }, [v]), N = Ne(() => {
2531
- g((l) => Xt(l, zt));
2532
- }, []);
2533
- K(() => {
2534
- if (e.length === 0) return;
2535
- const l = ht(Ie(e[0]));
2536
- !vt(l, v) || e.some((O) => {
2537
- const V = ht(Ie(O));
2538
- return !vt(V, o) && !fs(V, b);
2539
- }) || g(l);
2540
- }, [e]), K(() => {
2541
- a == null || a(at(b), at(o));
2542
- }, [b, o, a]);
2543
- const x = Ne(
2544
- (l, w) => {
2545
- const O = typeof w.date == "string" ? w.date : at(w.date);
2546
- i({
2547
- ...Bn(Jt(s, O), l.id)
2548
- }), r == null || r(O);
2549
- },
2550
- [i, r, s]
2551
- ), S = c || p ? "loading" : "default", D = f.some((l) => l.slots.length > 0), T = e[0];
2552
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2553
- S !== "loading" && !D && !!T ? /* @__PURE__ */ n(
2554
- ln,
2555
- {
2556
- nextAvailableDate: T,
2557
- onJump: () => g(ht(Ie(T))),
2558
- locale: u
2559
- }
2560
- ) : null,
2561
- /* @__PURE__ */ n(
2562
- ps,
2563
- {
2564
- id: m ? `${m}-slots` : void 0,
2565
- days: f,
2566
- state: S,
2567
- selectedSlotId: s.slotKey,
2568
- maxInitialSlotsPerDay: 6,
2569
- locale: u,
2570
- hasPrevious: I,
2571
- hasNext: y,
2572
- onSlotSelect: x,
2573
- onPreviousDays: B,
2574
- onNextDays: N
2575
- }
2576
- )
2577
- ] });
2578
- }
2579
- function $n(e) {
2580
- const {
2581
- inputs: t,
2582
- value: s,
2583
- onChange: i,
2584
- onDateSelect: r,
2585
- onWindowChange: a,
2586
- loadingDates: c,
2587
- loadingSlots: p,
2588
- locale: u,
2589
- datePickerStyle: m,
2590
- agentIdBase: v
2591
- } = e;
2592
- return m === "four-day-grid" ? /* @__PURE__ */ n(
2593
- Ki,
2594
- {
2595
- availableDates: t.availableDates,
2596
- availableSlots: t.availableSlots,
2597
- value: s,
2598
- onChange: i,
2599
- onDateSelect: r,
2600
- onWindowChange: a,
2601
- loadingDates: c,
2602
- loadingSlots: p,
2603
- locale: u,
2604
- agentIdBase: v
2605
- }
2606
- ) : /* @__PURE__ */ n(
2607
- Li,
2608
- {
2609
- availableDates: t.availableDates,
2610
- selectedDate: s.date,
2611
- onSelectDate: (b) => {
2612
- i(Jt(s, b)), r == null || r(b);
2613
- },
2614
- locale: u,
2615
- loading: c ?? p
2616
- }
2617
- );
2618
- }
2619
- function qn(e) {
2620
- const { inputs: t, value: s, onChange: i, loadingSlots: r, locale: a, datePickerStyle: c } = e;
2621
- return c === "four-day-grid" || !s.date ? null : /* @__PURE__ */ n(
2622
- qi,
2623
- {
2624
- date: s.date,
2625
- slots: t.availableSlots[s.date] ?? [],
2626
- selectedSlotKey: s.slotKey,
2627
- onSelect: (p) => i(Bn(s, p.key)),
2628
- loading: r,
2629
- locale: a
2630
- }
2631
- );
2632
- }
2633
- function Kn({ value: e, onChange: t }) {
2634
- const { t: s } = Y("ui"), i = [
2635
- { value: "private", label: s("booking.insurance.private") },
2636
- { value: "public", label: s("booking.insurance.public") }
2637
- ];
2638
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2639
- /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: s("booking.insurance.heading") }),
2640
- /* @__PURE__ */ n(
2641
- Ht,
2642
- {
2643
- options: i,
2644
- value: e ?? "",
2645
- onValueChange: (r) => {
2646
- (r === "private" || r === "public") && t(r);
2647
- },
2648
- placeholder: s("booking.insurance.placeholder"),
2649
- "aria-label": s("booking.insurance.heading")
2650
- }
2651
- )
2652
- ] });
2653
- }
2654
- function zn({
2655
- specialties: e,
2656
- value: t,
2657
- valueIds: s,
2658
- onChange: i,
2659
- onChangeIds: r,
2660
- pickerStyle: a = "select"
2661
- }) {
2662
- const { t: c } = Y("ui"), p = e.map((m) => ({
2663
- value: m.id,
2664
- label: m.label,
2665
- dir: "auto"
2666
- })), u = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: c("booking.specialty.heading") });
2667
- return a === "multi-select" && r ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2668
- u,
2669
- /* @__PURE__ */ n(
2670
- an,
2671
- {
2672
- options: p,
2673
- value: s ?? [],
2674
- onChange: r,
2675
- placeholder: c("booking.specialty.placeholder"),
2676
- "aria-label": c("booking.specialty.heading"),
2677
- allowClear: !0
2678
- }
2679
- )
2680
- ] }) : a === "combobox" ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2681
- u,
2682
- /* @__PURE__ */ n(
2683
- on,
2684
- {
2685
- options: p,
2686
- value: t ?? "",
2687
- onValueChange: (m) => i(m === "" ? "" : m),
2688
- placeholder: c("booking.specialty.placeholder"),
2689
- "aria-label": c("booking.specialty.heading"),
2690
- clearable: !0
2691
- }
2692
- )
2693
- ] }) : /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2694
- u,
2695
- /* @__PURE__ */ n(
2696
- Ht,
2697
- {
2698
- options: p,
2699
- value: t ?? "",
2700
- onValueChange: (m) => i(m),
2701
- placeholder: c("booking.specialty.placeholder"),
2702
- "aria-label": c("booking.specialty.heading")
2703
- }
2704
- )
2705
- ] });
2706
- }
2707
- function jn({
2708
- services: e,
2709
- value: t,
2710
- valueIds: s,
2711
- onChange: i,
2712
- onChangeIds: r,
2713
- pickerStyle: a,
2714
- compact: c,
2715
- showDuration: p
2716
- }) {
2717
- const { t: u } = Y("ui"), m = Vn(), v = a ?? (c ? "select" : "cards"), b = e.map((o) => {
2718
- const { price: f, payment: I, paymentTone: y } = m(o);
2719
- return {
2720
- value: o.id,
2721
- // The practice's service name leads the label, so it decides the
2722
- // direction, even when the kit's duration is appended after it.
2723
- dir: "auto",
2724
- label: f || I || !p ? o.label : `${o.label} · ${u("booking.serviceSummary", {
2725
- minutes: o.durationMin
2726
- })}`,
2727
- ...f ? {
2728
- endContent: /* @__PURE__ */ n(Nn, { variant: "accentSoft", size: "lg", children: f })
2729
- } : {},
2730
- ...I ? { description: I, descriptionTone: y } : {}
2731
- };
2732
- }), g = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: u("booking.service.heading") });
2733
- return v === "multi-select" && r ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2734
- g,
2735
- /* @__PURE__ */ n(
2736
- an,
2737
- {
2738
- options: b,
2739
- value: s ?? [],
2740
- onChange: r,
2741
- placeholder: u("booking.service.placeholder"),
2742
- "aria-label": u("booking.service.heading"),
2743
- allowClear: !0,
2744
- wrapOptionLabels: !0
2745
- }
2746
- )
2747
- ] }) : v === "combobox" ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2748
- g,
2749
- /* @__PURE__ */ n(
2750
- on,
2751
- {
2752
- options: b,
2753
- value: t ?? "",
2754
- onValueChange: (o) => i(o === "" ? "" : o),
2755
- placeholder: u("booking.service.placeholder"),
2756
- "aria-label": u("booking.service.heading"),
2757
- clearable: !0,
2758
- wrapOptionLabels: !0
2759
- }
2760
- )
2761
- ] }) : v === "select" ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2762
- g,
2763
- /* @__PURE__ */ n(
2764
- Ht,
2765
- {
2766
- options: b,
2767
- value: t ?? "",
2768
- onValueChange: (o) => i(o),
2769
- placeholder: u("booking.service.placeholder"),
2770
- "aria-label": u("booking.service.heading"),
2771
- showDescriptions: !0,
2772
- descriptionInName: !0,
2773
- wrapOptionLabels: !0
2774
- }
2775
- )
2776
- ] }) : /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2777
- g,
2778
- /* @__PURE__ */ n(
2779
- _i,
2780
- {
2781
- services: e,
2782
- selectedServiceId: t,
2783
- onSelect: i,
2784
- showDuration: p
2785
- }
2786
- )
2787
- ] });
2788
- }
2789
- function Un({
2790
- operators: e,
2791
- value: t,
2792
- valueIds: s,
2793
- onChange: i,
2794
- onChangeIds: r,
2795
- pickerStyle: a = "select"
2796
- }) {
2797
- const { t: c } = Y("ui"), p = /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: c("booking.operator.heading") });
2798
- if (a === "multi-select" && r) {
2799
- const m = e.map((v) => ({
2800
- value: v.id,
2801
- label: v.name,
2802
- dir: "auto"
2803
- }));
2804
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2805
- p,
2806
- /* @__PURE__ */ n(
2807
- an,
2808
- {
2809
- options: m,
2810
- value: s ?? [],
2811
- onChange: r,
2812
- placeholder: c("booking.operator.all"),
2813
- "aria-label": c("booking.operator.heading"),
2814
- allowClear: !0
2815
- }
2816
- )
2817
- ] });
2818
- }
2819
- const u = [
2820
- { value: _e, label: c("booking.operator.all") },
2821
- ...e.map(
2822
- (m) => ({ value: m.id, label: m.name, dir: "auto" })
2823
- )
2824
- ];
2825
- return a === "combobox" ? /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2826
- p,
2827
- /* @__PURE__ */ n(
2828
- on,
2829
- {
2830
- options: u,
2831
- value: t ?? _e,
2832
- onValueChange: (m) => i(m === "" ? _e : m),
2833
- placeholder: c("booking.operator.placeholder"),
2834
- "aria-label": c("booking.operator.heading"),
2835
- clearable: !0
2836
- }
2837
- )
2838
- ] }) : /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
2839
- p,
2840
- /* @__PURE__ */ n(
2841
- Ht,
2842
- {
2843
- options: u,
2844
- value: t ?? _e,
2845
- onValueChange: (m) => i(m),
2846
- placeholder: c("booking.operator.placeholder"),
2847
- "aria-label": c("booking.operator.heading")
2848
- }
2849
- )
2850
- ] });
2851
- }
2852
- function Gn({
2853
- customSlot: e
2854
- }) {
2855
- const { t } = Y("ui");
2856
- return e ? /* @__PURE__ */ n(me, { children: e }) : /* @__PURE__ */ k(ne, { variant: "warning", children: [
2857
- /* @__PURE__ */ n(ne.Title, { as: "h4", children: t("booking.onboardingIncomplete.title") }),
2858
- /* @__PURE__ */ n(ne.Description, { children: t("booking.onboardingIncomplete.description") })
2859
- ] });
2860
- }
2861
- function ln({
2862
- nextAvailableDate: e,
2863
- onJump: t,
2864
- locale: s
2865
- }) {
2866
- const { t: i } = Y("ui"), r = R(() => {
2867
- try {
2868
- return new Intl.DateTimeFormat(s, { dateStyle: "long" }).format(
2869
- Ie(e)
2870
- );
2871
- } catch {
2872
- return e;
2873
- }
2874
- }, [e, s]);
2875
- return /* @__PURE__ */ k(ne, { variant: "info", children: [
2876
- /* @__PURE__ */ n(ne.Description, { children: i("booking.nextAvailable.description", { date: r }) }),
2877
- /* @__PURE__ */ n(ne.Action, { children: /* @__PURE__ */ n(tt, { intent: "secondary", size: "sm", onClick: t, children: i("booking.nextAvailable.cta") }) })
2878
- ] });
2879
- }
2880
- function zi({
2881
- codeVerified: e = !1,
2882
- payment: t,
2883
- confirmationChannels: s,
2884
- snapshot: i,
2885
- operators: r,
2886
- specialties: a,
2887
- services: c,
2888
- locale: p,
2889
- mode: u,
2890
- showModify: m,
2891
- onReset: v,
2892
- onModify: b,
2893
- focusWasLost: g
2894
- }) {
2895
- const { t: o } = Y("ui"), f = F(null);
2896
- K(() => {
2897
- const l = f.current, w = document.activeElement, O = l == null ? void 0 : l.closest('[data-component="booking"]');
2898
- !t && !e || !l || (w && (O != null && O.contains(w)) || g()) && l.focus();
2899
- }, []);
2900
- const I = cn(s), B = Rn(
2901
- I,
2902
- i.details.confirmationChannels
2903
- ).map(
2904
- (l) => o(`booking.confirmation.channel.${l}`)
2905
- ), N = t ? Gt(t.amountCents, t.currencyCode, p) : "", x = t ? o(
2906
- u === "demo" ? "booking.payment.paidDemo" : "booking.payment.paidBody",
2907
- { amount: N }
2908
- ) : e ? o(u === "demo" ? "booking.code.confirmedDemo" : "booking.code.confirmedBody") : u === "demo" ? o("booking.success.descriptionDemo") : B.length > 1 ? o("booking.success.descriptionMultiple", {
2909
- channels: B.join(" · ")
2910
- }) : o("booking.success.descriptionSingle", {
2911
- channel: B[0]
2912
- }), S = R(() => {
2913
- if (i.date)
2914
- try {
2915
- return new Intl.DateTimeFormat(p, {
2916
- weekday: "long",
2917
- day: "numeric",
2918
- month: "long"
2919
- }).format(Ie(i.date));
2920
- } catch {
2921
- return i.date;
2922
- }
2923
- }, [i.date, p]), D = R(() => {
2924
- const w = (i.operatorIds && i.operatorIds.length > 0 ? i.operatorIds : i.operatorId ? [i.operatorId] : []).filter((O) => O !== _e).map((O) => {
2925
- var V;
2926
- return (V = r.find((j) => j.id === O)) == null ? void 0 : V.name;
2927
- }).filter((O) => O !== void 0);
2928
- if (w.length === 0) return [];
2929
- try {
2930
- return new Intl.ListFormat(p === "en" ? "en-GB" : p, {
2931
- style: "long",
2932
- type: "conjunction"
2933
- }).formatToParts(w);
2934
- } catch {
2935
- return w.flatMap((O, V) => [
2936
- ...V > 0 ? [{ type: "literal", value: ", " }] : [],
2937
- { type: "element", value: O }
2938
- ]);
2939
- }
2940
- }, [i.operatorIds, i.operatorId, r, p]), T = i.specialtyId ? a.find((l) => l.id === i.specialtyId) : void 0, E = i.serviceId ? c.find((l) => l.id === i.serviceId) : void 0;
2941
- return /* @__PURE__ */ k(
2942
- "div",
2943
- {
2944
- "data-component": "booking-success",
2945
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
2946
- children: [
2947
- /* @__PURE__ */ k(ne, { variant: "success", children: [
2948
- /* @__PURE__ */ n(
2949
- ne.Title,
2950
- {
2951
- as: "h3",
2952
- ref: f,
2953
- tabIndex: t || e ? -1 : void 0,
2954
- className: t || e ? Mt : void 0,
2955
- children: o(
2956
- t ? u === "demo" ? "booking.payment.paidDemoTitle" : "booking.payment.paidTitle" : e ? "booking.code.confirmedHeading" : "booking.success.heading"
2957
- )
2958
- }
2959
- ),
2960
- /* @__PURE__ */ n(ne.Description, { children: x })
2961
- ] }),
2962
- /* @__PURE__ */ n("div", { className: "ds:rounded-[var(--radius-md)] ds:bg-[var(--secondary)] ds:p-[var(--spacing-md)]", children: /* @__PURE__ */ k("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: [
2963
- t && u !== "demo" ? /* @__PURE__ */ k(me, { children: [
2964
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.payment.summaryPaid") }),
2965
- /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: N })
2966
- ] }) : null,
2967
- T ? /* @__PURE__ */ k(me, { children: [
2968
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summarySpecialty") }),
2969
- /* @__PURE__ */ n(
2970
- "dd",
2971
- {
2972
- dir: "auto",
2973
- className: "type-body ds:m-0 ds:text-[var(--foreground)]",
2974
- children: T.label
2975
- }
2976
- )
2977
- ] }) : null,
2978
- E ? /* @__PURE__ */ k(me, { children: [
2979
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryService") }),
2980
- /* @__PURE__ */ n(
2981
- "dd",
2982
- {
2983
- dir: "auto",
2984
- className: "type-body ds:m-0 ds:text-[var(--foreground)]",
2985
- children: E.label
2986
- }
2987
- )
2988
- ] }) : null,
2989
- S ? /* @__PURE__ */ k(me, { children: [
2990
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryDate") }),
2991
- /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: S })
2992
- ] }) : null,
2993
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryTime") }),
2994
- /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: rn(i.date, i.slot.time, p) }),
2995
- D.length > 0 ? /* @__PURE__ */ k(me, { children: [
2996
- /* @__PURE__ */ n("dt", { className: "type-label ds:text-[var(--muted-foreground)]", children: o("booking.success.summaryProvider") }),
2997
- /* @__PURE__ */ n("dd", { className: "type-body ds:m-0 ds:text-[var(--foreground)]", children: D.map(
2998
- (l, w) => l.type === "element" ? /* @__PURE__ */ n("bdi", { children: l.value }, w) : l.value
2999
- ) })
3000
- ] }) : null
3001
- ] }) }),
3002
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
3003
- /* @__PURE__ */ n(tt, { intent: "secondary", size: "md", onClick: v, children: o("booking.success.bookAnother") }),
3004
- m ? /* @__PURE__ */ n(tt, { intent: "ghost", size: "md", onClick: b, children: o("booking.success.modifyBooking") }) : null
3005
- ] })
3006
- ]
3007
- }
3008
- );
3009
- }
3010
- function Hn({ customSlot: e }) {
3011
- const { t } = Y("ui");
3012
- return e ? /* @__PURE__ */ n(me, { children: e }) : /* @__PURE__ */ n(
3013
- wn,
3014
- {
3015
- variant: "no-results",
3016
- title: t("booking.emptyServices.title"),
3017
- description: t("booking.emptyServices.description")
3018
- }
3019
- );
3020
- }
3021
- const Jn = "data-booking-step-active", ji = `[${Jn}]`;
3022
- function X({
3023
- step: e,
3024
- active: t,
3025
- className: s,
3026
- id: i,
3027
- children: r
3028
- }) {
3029
- return /* @__PURE__ */ n(
3030
- "div",
3031
- {
3032
- id: i,
3033
- "data-booking-step": String(e),
3034
- ...t ? { [Jn]: "" } : null,
3035
- tabIndex: -1,
3036
- className: s ? `${s} ${Mt}` : Mt,
3037
- children: r
3038
- }
3039
- );
3040
- }
3041
- function un(e, t) {
3042
- return t === "four-day-grid" ? e.filter((s) => s !== 6) : e;
3043
- }
3044
- function Ui(e) {
3045
- const {
3046
- cascade: t,
3047
- inputs: s,
3048
- value: i,
3049
- onChange: r,
3050
- onSubmit: a,
3051
- emptyServicesSlot: c,
3052
- onboardingIncompleteSlot: p,
3053
- loadingDates: u,
3054
- loadingSlots: m,
3055
- onDateSelect: v,
3056
- onWindowChange: b,
3057
- datePickerStyle: g,
3058
- specialtyPickerStyle: o,
3059
- servicePickerStyle: f,
3060
- showServiceDuration: I,
3061
- operatorPickerStyle: y,
3062
- submitting: B,
3063
- locale: N,
3064
- detailsProps: x,
3065
- agentIdBase: S,
3066
- activeStep: D
3067
- } = e, { t: T } = Y("ui"), E = yt(D, g), l = (w, O) => ({
3068
- step: w,
3069
- active: w === E,
3070
- className: O
3071
- });
3072
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3073
- t.gates.insurance ? /* @__PURE__ */ n(X, { ...l(1), children: /* @__PURE__ */ n(
3074
- Kn,
3075
- {
3076
- value: i.insuranceType,
3077
- onChange: (w) => r(An(i, w))
3078
- }
3079
- ) }) : null,
3080
- t.gates.specialty ? /* @__PURE__ */ n(X, { ...l(2), children: /* @__PURE__ */ n(
3081
- zn,
3082
- {
3083
- specialties: t.filtered.specialties,
3084
- value: i.specialtyId,
3085
- valueIds: i.specialtyIds,
3086
- onChange: (w) => r(Tn(i, w)),
3087
- onChangeIds: (w) => r(Dn(i, w)),
3088
- pickerStyle: o
3089
- }
3090
- ) }) : null,
3091
- t.gates.service ? /* @__PURE__ */ n(X, { ...l(3), children: t.filtered.services.length === 0 ? /* @__PURE__ */ n(Hn, { customSlot: c }) : /* @__PURE__ */ n(
3092
- jn,
3093
- {
3094
- services: t.filtered.services,
3095
- value: i.serviceId,
3096
- valueIds: i.serviceIds,
3097
- onChange: (w) => r(On(i, w)),
3098
- onChangeIds: (w) => r(Mn(i, w)),
3099
- pickerStyle: f,
3100
- showDuration: I
3101
- }
3102
- ) }) : null,
3103
- t.gates.onboardingIncomplete ? /* @__PURE__ */ n(Gn, { customSlot: p }) : null,
3104
- t.gates.operator ? /* @__PURE__ */ n(X, { ...l(4), children: /* @__PURE__ */ n(
3105
- Un,
3106
- {
3107
- operators: t.filtered.operators,
3108
- value: i.operatorId,
3109
- valueIds: i.operatorIds,
3110
- onChange: (w) => r(Fn(i, w)),
3111
- onChangeIds: (w) => r(En(i, w)),
3112
- pickerStyle: y
3113
- }
3114
- ) }) : null,
3115
- t.gates.date ? /* @__PURE__ */ k(
3116
- X,
3117
- {
3118
- ...l(5, "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"),
3119
- children: [
3120
- /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: T("booking.date.heading") }),
3121
- s.availableDates.length === 0 && s.nextAvailableDate ? /* @__PURE__ */ n(
3122
- ln,
3123
- {
3124
- nextAvailableDate: s.nextAvailableDate,
3125
- onJump: () => r(Jt(i, s.nextAvailableDate)),
3126
- locale: N
3127
- }
3128
- ) : $n({
3129
- inputs: s,
3130
- value: i,
3131
- onChange: r,
3132
- onDateSelect: v,
3133
- onWindowChange: b,
3134
- loadingDates: u,
3135
- loadingSlots: m,
3136
- locale: N,
3137
- datePickerStyle: g,
3138
- agentIdBase: S
3139
- })
3140
- ]
3141
- }
3142
- ) : null,
3143
- t.gates.slot && i.date && g === "month-calendar" ? /* @__PURE__ */ k(
3144
- X,
3145
- {
3146
- ...l(6, "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"),
3147
- children: [
3148
- /* @__PURE__ */ n("h3", { className: "type-label ds:font-[var(--font-weight-semibold)] ds:text-[var(--foreground)] ds:m-0", children: T("booking.slot.heading") }),
3149
- qn({
3150
- inputs: s,
3151
- value: i,
3152
- onChange: r,
3153
- loadingSlots: m,
3154
- locale: N,
3155
- datePickerStyle: g
3156
- })
3157
- ]
3158
- }
3159
- ) : null,
3160
- t.gates.details && t.selectedSlot ? /* @__PURE__ */ n(X, { ...l(7), children: /* @__PURE__ */ n(
3161
- dn,
3162
- {
3163
- ...x,
3164
- value: i.details ?? {},
3165
- onChange: (w) => r({ ...i, details: w }),
3166
- onSubmit: a,
3167
- submitting: B,
3168
- defaultPhoneCountry: e.policy.country
3169
- }
3170
- ) }) : null
3171
- ] });
3172
- }
3173
- function Oe(e, t, s = {}) {
3174
- const {
3175
- cascade: i,
3176
- inputs: r,
3177
- value: a,
3178
- onChange: c,
3179
- onSubmit: p,
3180
- emptyServicesSlot: u,
3181
- onboardingIncompleteSlot: m,
3182
- loadingDates: v,
3183
- loadingSlots: b,
3184
- onDateSelect: g,
3185
- onWindowChange: o,
3186
- datePickerStyle: f,
3187
- specialtyPickerStyle: I,
3188
- servicePickerStyle: y,
3189
- showServiceDuration: B,
3190
- operatorPickerStyle: N,
3191
- submitting: x,
3192
- locale: S,
3193
- detailsProps: D,
3194
- policy: T,
3195
- agentIdBase: E
3196
- } = t;
3197
- switch (e) {
3198
- case 1:
3199
- return /* @__PURE__ */ n(
3200
- Kn,
3201
- {
3202
- value: a.insuranceType,
3203
- onChange: (l) => c(An(a, l))
3204
- }
3205
- );
3206
- case 2:
3207
- return /* @__PURE__ */ n(
3208
- zn,
3209
- {
3210
- specialties: i.filtered.specialties,
3211
- value: a.specialtyId,
3212
- valueIds: a.specialtyIds,
3213
- onChange: (l) => c(Tn(a, l)),
3214
- onChangeIds: (l) => c(Dn(a, l)),
3215
- pickerStyle: I
3216
- }
3217
- );
3218
- case 3:
3219
- return i.filtered.services.length === 0 ? /* @__PURE__ */ n(Hn, { customSlot: u }) : i.gates.onboardingIncomplete ? /* @__PURE__ */ n(Gn, { customSlot: m }) : /* @__PURE__ */ n(
3220
- jn,
3221
- {
3222
- services: i.filtered.services,
3223
- value: a.serviceId,
3224
- valueIds: a.serviceIds,
3225
- onChange: (l) => c(On(a, l)),
3226
- onChangeIds: (l) => c(Mn(a, l)),
3227
- pickerStyle: y,
3228
- compact: s.compactService,
3229
- showDuration: B
3230
- }
3231
- );
3232
- case 4:
3233
- return /* @__PURE__ */ n(
3234
- Un,
3235
- {
3236
- operators: i.filtered.operators,
3237
- value: a.operatorId,
3238
- valueIds: a.operatorIds,
3239
- onChange: (l) => c(Fn(a, l)),
3240
- onChangeIds: (l) => c(En(a, l)),
3241
- pickerStyle: N
3242
- }
3243
- );
3244
- case 5:
3245
- return r.availableDates.length === 0 && r.nextAvailableDate ? /* @__PURE__ */ n(
3246
- ln,
3247
- {
3248
- nextAvailableDate: r.nextAvailableDate,
3249
- onJump: () => c(Jt(a, r.nextAvailableDate)),
3250
- locale: S
3251
- }
3252
- ) : $n({
3253
- inputs: r,
3254
- value: a,
3255
- onChange: c,
3256
- onDateSelect: g,
3257
- onWindowChange: o,
3258
- loadingDates: v,
3259
- loadingSlots: b,
3260
- locale: S,
3261
- datePickerStyle: f,
3262
- agentIdBase: E
3263
- });
3264
- case 6:
3265
- return qn({
3266
- inputs: r,
3267
- value: a,
3268
- onChange: c,
3269
- loadingSlots: b,
3270
- locale: S,
3271
- datePickerStyle: f
3272
- });
3273
- case 7:
3274
- return i.selectedSlot ? /* @__PURE__ */ n(
3275
- dn,
3276
- {
3277
- ...D,
3278
- value: a.details ?? {},
3279
- onChange: (l) => c({ ...a, details: l }),
3280
- onSubmit: p,
3281
- submitting: x,
3282
- defaultPhoneCountry: T.country
3283
- }
3284
- ) : null;
3285
- /* c8 ignore next 2 */
3286
- default:
3287
- return null;
3288
- }
3289
- }
3290
- function Wt() {
3291
- const { t: e } = Y("ui");
3292
- return R(
3293
- () => ({
3294
- 1: e("booking.insurance.heading"),
3295
- 2: e("booking.specialty.heading"),
3296
- 3: e("booking.service.heading"),
3297
- 4: e("booking.operator.heading"),
3298
- 5: e("booking.date.heading"),
3299
- 6: e("booking.slot.heading"),
3300
- 7: e("booking.details.heading")
3301
- }),
3302
- [e]
3303
- );
3304
- }
3305
- function yt(e, t) {
3306
- return t === "four-day-grid" && e === 6 ? 5 : e;
3307
- }
3308
- function Gi(e) {
3309
- const { cascade: t, value: s, activeStep: i, setActiveStep: r, datePickerStyle: a } = e, c = Wt(), { t: p } = Y("ui"), u = p("booking.operator.all"), m = R(
3310
- () => un(t.visibleSteps, a),
3311
- [t.visibleSteps, a]
3312
- ), v = yt(i, a), b = Math.max(0, m.indexOf(v)), g = R(
3313
- () => m.map((o) => ({
3314
- label: c[o],
3315
- summary: Wn(o, s, t, u),
3316
- status: Hi(o, s, t),
3317
- content: /* @__PURE__ */ n(X, { step: o, active: o === v, children: Oe(o, e, { compactService: !0 }) })
3318
- })),
3319
- [
3320
- m,
3321
- s,
3322
- c,
3323
- t,
3324
- e,
3325
- v,
3326
- u
3327
- ]
3328
- );
3329
- return /* @__PURE__ */ n(
3330
- ls,
3331
- {
3332
- activeStep: b,
3333
- steps: g,
3334
- onStepChange: (o) => {
3335
- const f = m[o];
3336
- f && r(f);
3337
- }
3338
- }
3339
- );
3340
- }
3341
- function Hi(e, t, s) {
3342
- return Ue(e, t) && e < s.currentStep ? "completed" : e <= s.currentStep ? "unlocked" : void 0;
3343
- }
3344
- function yn(e, t) {
3345
- return e !== 4 ? Ue(e, t) : t.operatorIds && t.operatorIds.length > 0 ? !0 : Ln(t) !== void 0;
3346
- }
3347
- function tn(e, t) {
3348
- const s = e.map((i) => {
3349
- var r;
3350
- return (r = t.find((a) => a.id === i)) == null ? void 0 : r.label;
3351
- }).filter((i) => i !== void 0);
3352
- return s.length > 0 ? s.join(", ") : void 0;
3353
- }
3354
- function Wn(e, t, s, i) {
3355
- var r;
3356
- if (Ue(e, t))
3357
- switch (e) {
3358
- case 1:
3359
- return t.insuranceType;
3360
- case 2:
3361
- return tn(
3362
- nt(t),
3363
- s.filtered.specialties
3364
- );
3365
- case 3:
3366
- return tn(Ge(t), s.filtered.services);
3367
- case 4: {
3368
- const c = sn(t).filter((u) => u !== _e), p = tn(
3369
- c,
3370
- s.filtered.operators.map((u) => ({
3371
- id: u.id,
3372
- label: u.name
3373
- }))
3374
- );
3375
- return p !== void 0 ? p : c.length === 0 ? i : void 0;
3376
- }
3377
- case 5:
3378
- return t.date;
3379
- case 6:
3380
- return (r = s.selectedSlot) == null ? void 0 : r.time;
3381
- case 7:
3382
- return;
3383
- }
3384
- }
3385
- function Ji(e) {
3386
- const { cascade: t, value: s, activeStep: i, setActiveStep: r } = e, { t: a } = Y("ui"), c = Wt(), p = a("booking.operator.all"), u = `${bt()}-filter`, m = yt(i, e.datePickerStyle), v = t.visibleSteps.filter(
3387
- (o) => o === 1 || o === 2 || o === 3 || o === 4
3388
- ), b = v.some(
3389
- (o) => !Ue(o, s)
3390
- ), g = v.some(
3391
- (o) => o === i
3392
- ) ? i : v.find((o) => !Ue(o, s));
3393
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3394
- v.length > 0 ? /* @__PURE__ */ n(
3395
- "div",
3396
- {
3397
- role: "group",
3398
- "aria-label": a("booking.filtersLabel"),
3399
- className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
3400
- children: v.map((o) => {
3401
- const f = Wn(
3402
- o,
3403
- s,
3404
- t,
3405
- p
3406
- ), I = o === g, y = Ue(o, s);
3407
- return /* @__PURE__ */ n(
3408
- tt,
3409
- {
3410
- intent: I ? "primary" : "outline",
3411
- size: "sm",
3412
- endIcon: /* @__PURE__ */ n(
3413
- ms,
3414
- {
3415
- "aria-hidden": "true",
3416
- className: I ? "ds:rotate-180" : void 0
3417
- }
3418
- ),
3419
- "aria-expanded": y ? I : void 0,
3420
- "aria-controls": y && I ? u : void 0,
3421
- "aria-current": !y && I ? "step" : void 0,
3422
- onClick: () => r(
3423
- y && I ? t.currentStep : o
3424
- ),
3425
- children: f ? /* @__PURE__ */ k(me, { children: [
3426
- c[o],
3427
- ": ",
3428
- f
3429
- ] }) : c[o]
3430
- },
3431
- `csc-${o}`
3432
- );
3433
- })
3434
- }
3435
- ) : null,
3436
- g !== void 0 ? /* @__PURE__ */ n(
3437
- X,
3438
- {
3439
- step: g,
3440
- active: g === m,
3441
- id: u,
3442
- children: Oe(g, e, { compactService: !0 })
3443
- }
3444
- ) : null,
3445
- !b && t.gates.date ? (
3446
- // four-day-grid embeds slots inline with the day strip — the
3447
- // historic 2-col date|slot split collapses to a single column
3448
- // so the picker spans the full width instead of orphaning an
3449
- // empty right cell.
3450
- e.datePickerStyle === "four-day-grid" ? /* @__PURE__ */ n(X, { step: 5, active: m === 5, children: Oe(5, e) }) : /* @__PURE__ */ k("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:md:grid-cols-2", children: [
3451
- /* @__PURE__ */ n(
3452
- X,
3453
- {
3454
- step: 5,
3455
- active: m === 5,
3456
- className: "ds:min-w-0",
3457
- children: Oe(5, e)
3458
- }
3459
- ),
3460
- s.date ? /* @__PURE__ */ n(
3461
- X,
3462
- {
3463
- step: 6,
3464
- active: m === 6,
3465
- className: "ds:min-w-0",
3466
- children: Oe(6, e)
3467
- }
3468
- ) : /* @__PURE__ */ n("div", { className: "ds:min-w-0" })
3469
- ] })
3470
- ) : null,
3471
- t.gates.details ? /* @__PURE__ */ n(X, { step: 7, active: m === 7, children: Oe(7, e) }) : null
3472
- ] });
3473
- }
3474
- function Wi(e) {
3475
- const { cascade: t, datePickerStyle: s, activeStep: i } = e, r = yt(i, s), a = t.visibleSteps.filter(
3476
- (p) => p === 1 || p === 2 || p === 3 || p === 4
3477
- );
3478
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3479
- /* @__PURE__ */ k(
3480
- "div",
3481
- {
3482
- className: s === "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",
3483
- children: [
3484
- /* @__PURE__ */ n("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: a.map((p) => /* @__PURE__ */ n(X, { step: p, active: p === r, children: Oe(p, e, { compactService: !0 }) }, `fbf-${p}`)) }),
3485
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3486
- t.gates.date ? /* @__PURE__ */ n(X, { step: 5, active: r === 5, children: Oe(5, e) }) : null,
3487
- t.gates.slot && e.value.date && s === "month-calendar" ? /* @__PURE__ */ n(X, { step: 6, active: r === 6, children: Oe(6, e) }) : null
3488
- ] })
3489
- ]
3490
- }
3491
- ),
3492
- t.gates.details ? /* @__PURE__ */ n(X, { step: 7, active: r === 7, children: Oe(7, e) }) : null
3493
- ] });
3494
- }
3495
- function Yi(e) {
3496
- const { cascade: t, value: s, activeStep: i, setActiveStep: r, datePickerStyle: a } = e, { t: c } = Y("ui"), p = Wt(), u = R(
3497
- () => un(t.visibleSteps, a),
3498
- [t.visibleSteps, a]
3499
- ), m = yt(i, a), v = Math.max(0, u.indexOf(m)), b = u.length, g = R(
3500
- () => u.map((y) => ({ label: p[y] })),
3501
- [u, p]
3502
- ), o = v > 0, f = m === 5 && a === "four-day-grid", I = v < b - 1 && Ue(m, s) && (!f || Ue(6, s));
3503
- return /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
3504
- /* @__PURE__ */ n(us, { activeStep: v, steps: g }),
3505
- /* @__PURE__ */ n(X, { step: m, active: !0, children: Oe(m, e, { compactService: !0 }) }),
3506
- /* @__PURE__ */ k("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]", children: [
3507
- /* @__PURE__ */ n(
3508
- tt,
3509
- {
3510
- intent: "ghost",
3511
- size: "md",
3512
- disabled: !o,
3513
- onClick: () => {
3514
- const y = u[v - 1];
3515
- y && r(y);
3516
- },
3517
- children: c("booking.actions.back")
3518
- }
3519
- ),
3520
- m < 7 ? /* @__PURE__ */ n(
3521
- tt,
3522
- {
3523
- intent: "primary",
3524
- size: "md",
3525
- disabled: !I,
3526
- onClick: () => {
3527
- const y = u[v + 1];
3528
- y && r(y);
3529
- },
3530
- children: c("booking.actions.next")
3531
- }
3532
- ) : null
3533
- ] })
3534
- ] });
3535
- }
3536
- const Zi = [], Qi = [];
3537
- function kn() {
3538
- return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
3539
- }
3540
- const Xi = Sn(
3541
- ({
3542
- variant: e = "inline-list",
3543
- country: t,
3544
- // No default — the cascade engine treats `undefined` as "auto-on
3545
- // when `specialties` has items" so consumers who pass specialty
3546
- // data without the explicit flag still get the step.
3547
- useSpecialties: s,
3548
- allowOperatorSelection: i = !1,
3549
- lockedOperatorId: r,
3550
- operatorsByService: a = !1,
3551
- autoSelectSingleService: c = !1,
3552
- specialties: p,
3553
- services: u,
3554
- operators: m,
3555
- availableDates: v,
3556
- availableSlots: b,
3557
- nextAvailableDate: g,
3558
- hideEmail: o = !1,
3559
- emailOptional: f = !1,
3560
- requireCodiceFiscale: I,
3561
- requireDateOfBirth: y,
3562
- requireInsuranceNumber: B,
3563
- billingInDetails: N = !1,
3564
- paymentNoticeStyle: x = "highlighted",
3565
- showNote: S,
3566
- showReturningPatientFlag: D,
3567
- privacyPolicyUrl: T,
3568
- termsUrl: E,
3569
- practiceConsent: l,
3570
- paymentTermsUrl: w,
3571
- paymentState: O,
3572
- renderPayment: V,
3573
- renderPaymentCompletion: j,
3574
- validateCodiceFiscale: Z,
3575
- validateInsuranceNumber: h,
3576
- confirmationChannels: ee,
3577
- defaultConfirmationChannels: H,
3578
- singleConfirmationChannel: Pe,
3579
- value: M,
3580
- onChange: J,
3581
- onSubmit: we,
3582
- codeStep: fe,
3583
- onStepChange: W,
3584
- onDateSelect: Ve,
3585
- onWindowChange: ct,
3586
- datePickerStyle: ge = "month-calendar",
3587
- specialtyPickerStyle: se,
3588
- servicePickerStyle: ce,
3589
- showServiceDuration: Ce = !0,
3590
- operatorPickerStyle: Ae,
3591
- loadingDates: Fe,
3592
- loadingSlots: re,
3593
- submitting: Ee,
3594
- submitError: de,
3595
- mode: he = "live",
3596
- showModifyOnSuccess: Te = !0,
3597
- surface: $e = "flat",
3598
- emptyServicesSlot: He,
3599
- onboardingIncompleteSlot: q,
3600
- "aria-label": qe,
3601
- id: st,
3602
- className: Et,
3603
- onFocus: dt,
3604
- onBlur: lt,
3605
- ...ut
3606
- }, Be) => {
3607
- var _t, Tt, Dt;
3608
- const { t: le, i18n: Bt } = Y("ui"), ve = e ?? "inline-list", Je = Bt.language ?? "en", ke = p ?? Zi, We = m ?? Qi;
3609
- K(() => {
3610
- const C = ii(M, {
3611
- useSpecialties: s,
3612
- lockedOperatorId: r,
3613
- autoSelectSingleService: c,
3614
- specialties: ke,
3615
- services: u
3616
- });
3617
- (C.specialtyId !== M.specialtyId || C.operatorId !== M.operatorId || C.serviceId !== M.serviceId) && J(C);
3618
- }, [
3619
- r,
3620
- s,
3621
- c,
3622
- ke,
3623
- u
3624
- ]);
3625
- const _ = R(
3626
- () => si({
3627
- country: t,
3628
- useSpecialties: s,
3629
- allowOperatorSelection: i,
3630
- lockedOperatorId: r,
3631
- operatorsByService: a,
3632
- specialties: ke,
3633
- services: u,
3634
- operators: We,
3635
- availableSlots: b,
3636
- value: M
3637
- }),
3638
- [
3639
- t,
3640
- s,
3641
- i,
3642
- r,
3643
- a,
3644
- c,
3645
- ke,
3646
- u,
3647
- We,
3648
- v,
3649
- b,
3650
- M
3651
- ]
3652
- ), Se = R(
3653
- () => [
3654
- JSON.stringify(M.insuranceType),
3655
- JSON.stringify(nt(M)),
3656
- JSON.stringify(Ge(M)),
3657
- JSON.stringify(sn(M)),
3658
- JSON.stringify(M.date),
3659
- JSON.stringify(M.slotKey)
3660
- ],
3661
- [M]
3662
- ), pt = ve === "progress", kt = Ne(
3663
- (C) => {
3664
- if (C === 4 && _.visibleSteps.includes(4) && sn(M).length === 0)
3665
- return Math.min(4, _.currentStep);
3666
- if (!pt) return _.currentStep;
3667
- const L = _.visibleSteps.find(
3668
- (P) => P > C && !yn(P, M)
3669
- );
3670
- return L === void 0 ? _.currentStep : Math.min(L, _.currentStep);
3671
- },
3672
- [pt, _.visibleSteps, _.currentStep, M]
3673
- ), [oe, xe] = G(
3674
- _.currentStep
3675
- ), St = F(Se), Ye = F(_.visibleSteps);
3676
- K(() => {
3677
- const C = St.current, L = Ye.current;
3678
- St.current = Se, Ye.current = _.visibleSteps;
3679
- const P = Se.findIndex(
3680
- (ae, d) => ae !== C[d]
3681
- );
3682
- if (P !== -1) {
3683
- xe(kt(P + 1));
3684
- return;
3685
- }
3686
- const Q = pt ? _.visibleSteps.find(
3687
- (ae) => ae < oe && !L.includes(ae) && !yn(ae, M)
3688
- ) : void 0;
3689
- if (Q !== void 0) {
3690
- xe(Q);
3691
- return;
3692
- }
3693
- _.visibleSteps.includes(oe) || xe(_.currentStep);
3694
- }, [
3695
- Se,
3696
- kt,
3697
- pt,
3698
- _.currentStep,
3699
- _.visibleSteps,
3700
- oe,
3701
- M
3702
- ]);
3703
- const ue = F(null), it = R(
3704
- () => un(_.visibleSteps, ge),
3705
- [_.visibleSteps, ge]
3706
- ), Ze = Wt(), [Yt, Le] = G(""), be = F(null), rt = F(null);
3707
- K(() => {
3708
- const C = yt(oe, ge);
3709
- if (rt.current === null) {
3710
- rt.current = C;
3711
- return;
3712
- }
3713
- if (rt.current === C) return;
3714
- rt.current = C;
3715
- const L = it.indexOf(C);
3716
- Le(
3717
- L === -1 ? "" : le("booking.stepAnnouncement", {
3718
- current: L + 1,
3719
- total: it.length,
3720
- label: Ze[C]
3721
- })
3722
- );
3723
- const P = be.current;
3724
- if (!P || P.isConnected) return;
3725
- const Q = ue.current;
3726
- if (!Q) return;
3727
- const ae = document.activeElement;
3728
- if (!(ae === null || ae === document.body || !Q.contains(ae))) return;
3729
- const A = Q.querySelector(ji) ?? Q;
3730
- if (A.focus({ preventScroll: !0 }), typeof A.scrollIntoView == "function")
3731
- try {
3732
- A.scrollIntoView({
3733
- behavior: kn() ? "auto" : "smooth",
3734
- block: "nearest"
3735
- });
3736
- } catch {
3737
- A.scrollIntoView();
3738
- }
3739
- }, [oe, ge, it, Ze, le]);
3740
- const $ = Ti({
3741
- services: u,
3742
- value: M,
3743
- availableSlots: b,
3744
- onSubmit: we,
3745
- onChange: J,
3746
- paymentState: O,
3747
- submitting: Ee,
3748
- paymentTermsUrl: w,
3749
- renderPayment: V,
3750
- codeStep: fe
3751
- }), U = $.status, Lt = $.submit, ot = F($.reset);
3752
- ot.current = $.reset;
3753
- const xt = bt(), It = F(null), Nt = F(null), wt = ((_t = $.state) == null ? void 0 : _t.status) === "failed", Qe = $.state && "phase" in $.state && $.state.phase === "completion";
3754
- K(() => {
3755
- var C, L;
3756
- if (U === "payment") {
3757
- const P = document.activeElement;
3758
- (!Qe || !P || P === document.body || !((C = ue.current) != null && C.contains(P))) && ((L = It.current) == null || L.focus());
3759
- }
3760
- }, [U, Qe]), K(() => {
3761
- var C;
3762
- U === "payment" && wt && ((C = Nt.current) == null || C.focus());
3763
- }, [U, wt]), Zn(Be, () => ue.current, []);
3764
- const Ke = U === "success" ? 8 : U === "payment" || U === "code" ? 7 : _.currentStep, mt = F(null);
3765
- K(() => {
3766
- if (Ke !== mt.current && (mt.current = Ke, W == null || W(Ke), Ke === 8 && ue.current))
3767
- try {
3768
- ue.current.scrollIntoView({
3769
- behavior: kn() ? "auto" : "smooth",
3770
- block: "start"
3771
- });
3772
- } catch {
3773
- ue.current.scrollIntoView();
3774
- }
3775
- }, [Ke, W]);
3776
- const Xe = F({ activeStep: oe, cascade: _, submitState: U });
3777
- K(() => {
3778
- Xe.current = { activeStep: oe, cascade: _, submitState: U };
3779
- }, [oe, _, U]);
3780
- const ft = R(
3781
- () => ({
3782
- getVariant: () => ve,
3783
- getCurrentStep: () => {
3784
- const C = Xe.current;
3785
- return C.submitState === "success" ? 8 : C.submitState === "payment" || C.submitState === "code" ? 7 : C.activeStep;
3786
- },
3787
- reset: () => {
3788
- Xe.current.submitState === "payment" || Xe.current.submitState === "code" || (J({}), ot.current(), xe(1));
3789
- },
3790
- goToStep: (C) => {
3791
- const L = Xe.current, P = L.cascade.visibleSteps.includes(C), Q = L.cascade.currentStep, ae = L.submitState === "payment" || L.submitState === "code" ? 7 : !P || C > Q ? Q : C;
3792
- Xe.current = { ...L, activeStep: ae }, xe(ae);
3793
- }
3794
- }),
3795
- [ve, J]
3796
- );
3797
- Qn(Ys, ft, st);
3798
- const Rt = qe ?? le("booking.regionLabel"), De = $.snapshot, Zt = U === "success" && De ? /* @__PURE__ */ n(
3799
- zi,
3800
- {
3801
- codeVerified: $.codeVerified,
3802
- payment: De.payment,
3803
- confirmationChannels: ee,
3804
- snapshot: {
3805
- ...De.value,
3806
- slot: De.slot,
3807
- details: De.details,
3808
- serviceId: ((Tt = De.payment) == null ? void 0 : Tt.serviceId) ?? De.slot.serviceId ?? De.value.serviceId
3809
- },
3810
- operators: We,
3811
- specialties: ke,
3812
- services: u,
3813
- locale: Je,
3814
- mode: he,
3815
- showModify: Te && !De.payment && !$.codeVerified,
3816
- onReset: () => ft.reset(),
3817
- focusWasLost: () => {
3818
- const C = be.current, L = document.activeElement;
3819
- return !!(C && !C.isConnected) && (!L || L === document.body);
3820
- },
3821
- onModify: () => {
3822
- ot.current(), xe(7);
3823
- }
3824
- }
3825
- ) : null, Qt = U === "code" && $.codeStep ? /* @__PURE__ */ n(
3826
- wi,
3827
- {
3828
- ...$.codeStep,
3829
- ...fe,
3830
- onVerified: $.completeCode
3831
- }
3832
- ) : null, Ct = $.activeSession, Re = $.state, ye = Ct && Re ? {
3833
- session: Ct,
3834
- payment: Ct.payment,
3835
- state: Re,
3836
- billing: (Dt = $.snapshot) == null ? void 0 : Dt.details.billing
3837
- } : void 0, et = Re && "phase" in Re && Re.phase === "completion", ie = U === "payment" && ye ? /* @__PURE__ */ k(
3838
- "section",
3839
- {
3840
- "aria-labelledby": xt,
3841
- "data-component": "booking-payment",
3842
- "data-payment-status": ye.state.status,
3843
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
3844
- children: [
3845
- /* @__PURE__ */ n(
3846
- "h3",
3847
- {
3848
- ref: It,
3849
- id: xt,
3850
- tabIndex: -1,
3851
- className: "type-title-card ds:m-0",
3852
- children: le(
3853
- et ? "booking.payment.confirming" : "booking.payment.heading"
3854
- )
3855
- }
3856
- ),
3857
- et ? null : /* @__PURE__ */ n("p", { className: "type-body ds:m-0", children: le("booking.payment.noticeBody", {
3858
- amount: Gt(
3859
- ye.payment.amountCents,
3860
- ye.payment.currencyCode,
3861
- Je
3862
- )
3863
- }) }),
3864
- /* @__PURE__ */ n(
3865
- "p",
3866
- {
3867
- role: "status",
3868
- className: ye.state.status === "processing" ? "type-body ds:m-0 ds:flex ds:items-center ds:gap-[var(--spacing-sm)]" : "ds:sr-only",
3869
- children: ye.state.status === "processing" ? /* @__PURE__ */ k(me, { children: [
3870
- /* @__PURE__ */ n(In, { variant: "pulse", size: "lg", "aria-hidden": "true" }),
3871
- /* @__PURE__ */ n("span", { children: le(
3872
- et ? "booking.payment.confirming" : "booking.payment.processing"
3873
- ) })
3874
- ] }) : null
3875
- }
3876
- ),
3877
- ye.state.status === "failed" ? /* @__PURE__ */ n(
3878
- ne,
3879
- {
3880
- ref: Nt,
3881
- variant: "error",
3882
- tabIndex: -1,
3883
- className: Mt,
3884
- children: /* @__PURE__ */ n(ne.Description, { children: ye.state.error ?? le(
3885
- et ? "booking.payment.completionFailed" : "booking.payment.failed"
3886
- ) })
3887
- }
3888
- ) : null,
3889
- et ? j == null ? void 0 : j(ye) : V == null ? void 0 : V(ye)
3890
- ]
3891
- }
3892
- ) : null, At = R(() => {
3893
- const C = new Set(Ge(M)), L = u.filter((P) => C.has(P.id)).map((P) => {
3894
- var Q;
3895
- return {
3896
- label: P.label,
3897
- text: ((Q = P.criticalInformationToAccept) == null ? void 0 : Q.trim()) ?? ""
3898
- };
3899
- }).filter((P) => P.text.length > 0);
3900
- if (L.length !== 0)
3901
- return L.length === 1 ? L[0].text : L.map((P) => `${P.label}: ${P.text}`).join(`
3902
-
3903
- `);
3904
- }, [u, M]), pe = R(() => {
3905
- if (U === "success" || U === "payment" || U === "code")
3906
- return null;
3907
- const C = ve === "accordion" ? Gi : ve === "calendar" ? Ji : ve === "flexible" ? Wi : ve === "progress" ? Yi : Ui, L = {
3908
- cascade: _,
3909
- inputs: {
3910
- specialties: ke,
3911
- services: u,
3912
- operators: We,
3913
- availableDates: v,
3914
- availableSlots: b,
3915
- nextAvailableDate: g
3916
- },
3917
- value: M,
3918
- onChange: J,
3919
- onSubmit: Lt,
3920
- policy: { country: t, lockedOperatorId: r },
3921
- detailsProps: {
3922
- hideEmail: o,
3923
- emailOptional: f,
3924
- requireCodiceFiscale: I,
3925
- requireDateOfBirth: y,
3926
- requireInsuranceNumber: B,
3927
- insuranceType: M.insuranceType,
3928
- showNote: S,
3929
- showReturningPatientFlag: D,
3930
- privacyPolicyUrl: T,
3931
- termsUrl: E,
3932
- practiceConsent: l,
3933
- criticalInformationToAccept: At,
3934
- payment: $.payment,
3935
- paymentTermsUrl: w,
3936
- paymentBlocked: $.blocked,
3937
- billingInDetails: N,
3938
- paymentNoticeStyle: x,
3939
- validateCodiceFiscale: Z,
3940
- validateInsuranceNumber: h,
3941
- confirmationChannels: ee,
3942
- defaultConfirmationChannels: H,
3943
- singleConfirmationChannel: Pe,
3944
- submitError: de ?? (U === "error" ? le("booking.payment.submitFailed") : void 0)
3945
- },
3946
- emptyServicesSlot: He,
3947
- onboardingIncompleteSlot: q,
3948
- loadingDates: Fe,
3949
- loadingSlots: re,
3950
- onDateSelect: Ve,
3951
- onWindowChange: ct,
3952
- datePickerStyle: ge,
3953
- specialtyPickerStyle: se,
3954
- servicePickerStyle: ce,
3955
- showServiceDuration: Ce,
3956
- operatorPickerStyle: Ae,
3957
- submitting: Ee || U === "submitting",
3958
- locale: Je,
3959
- activeStep: oe,
3960
- setActiveStep: xe,
3961
- agentIdBase: st
3962
- };
3963
- return /* @__PURE__ */ n(C, { ...L });
3964
- }, [
3965
- U,
3966
- $.payment,
3967
- $.blocked,
3968
- w,
3969
- le,
3970
- ve,
3971
- _,
3972
- ke,
3973
- u,
3974
- We,
3975
- v,
3976
- b,
3977
- g,
3978
- M,
3979
- J,
3980
- Lt,
3981
- t,
3982
- r,
3983
- o,
3984
- f,
3985
- I,
3986
- y,
3987
- B,
3988
- N,
3989
- x,
3990
- de,
3991
- S,
3992
- D,
3993
- T,
3994
- E,
3995
- l,
3996
- At,
3997
- Z,
3998
- h,
3999
- ee,
4000
- H,
4001
- Pe,
4002
- He,
4003
- q,
4004
- Fe,
4005
- re,
4006
- Ve,
4007
- ct,
4008
- ge,
4009
- se,
4010
- ce,
4011
- Ce,
4012
- Ae,
4013
- Ee,
4014
- Je,
4015
- oe,
4016
- st
4017
- ]);
4018
- return /* @__PURE__ */ k(
4019
- "div",
4020
- {
4021
- ref: ue,
4022
- role: "region",
4023
- "aria-label": Rt,
4024
- id: st,
4025
- "data-component": "booking",
4026
- "data-component-id": st,
4027
- "data-variant": ve,
4028
- className: Di({
4029
- variant: ve,
4030
- surface: $e,
4031
- className: Et
4032
- }),
4033
- tabIndex: -1,
4034
- onFocus: (C) => {
4035
- be.current = C.target, dt == null || dt(C);
4036
- },
4037
- onBlur: (C) => {
4038
- const L = C.target;
4039
- window.setTimeout(() => {
4040
- var Q;
4041
- const P = document.activeElement;
4042
- be.current === L && L.isConnected && !(P && ((Q = ue.current) != null && Q.contains(P))) && (be.current = null);
4043
- }), lt == null || lt(C);
4044
- },
4045
- ...ut,
4046
- children: [
4047
- /* @__PURE__ */ n("div", { role: "status", className: "ds:sr-only", children: Yt }),
4048
- /* @__PURE__ */ k(
4049
- "div",
4050
- {
4051
- className: [
4052
- "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
4053
- "ds:rounded-[var(--radius-md)]",
4054
- "ds:bg-[color-mix(in_srgb,var(--primary)_35%,var(--background))]",
4055
- "ds:bg-[image:var(--gradient-hero-brand)]",
4056
- "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
4057
- "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]"
4058
- ].join(" "),
4059
- children: [
4060
- /* @__PURE__ */ n("h2", { className: "type-title-card ds:text-[var(--foreground)] ds:m-0", children: le("booking.regionLabel") }),
4061
- /* @__PURE__ */ n("p", { className: "type-body-sm ds:text-[var(--foreground)] ds:m-0", children: le("booking.headingSubtitle") })
4062
- ]
4063
- }
4064
- ),
4065
- $.cancelled ? /* @__PURE__ */ n(ne, { variant: "info", children: /* @__PURE__ */ n(ne.Description, { children: le("booking.payment.cancelled") }) }) : null,
4066
- Zt ?? Qt ?? ie ?? pe
4067
- ]
4068
- }
4069
- );
4070
- }
4071
- );
4072
- Xi.displayName = "Booking";
4073
- export {
4074
- Xi as B,
4075
- nn as C,
4076
- _e as O,
4077
- Ys as b
4078
- };
4079
- //# sourceMappingURL=booking-CxrB0e6d.js.map