@oneclick.dev/cms-core-modules 0.0.114 → 0.0.116

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 (87) hide show
  1. package/dist/{ContentEditor-MctMvN7D.js → ContentEditor-CsbOFg3a.js} +52 -52
  2. package/dist/{ContentEditor-C5yNNLeV.mjs → ContentEditor-Df5uWpVC.mjs} +10337 -8677
  3. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-gozJKXvM.js +1 -0
  4. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-pDO9b4Pv.mjs +77 -0
  5. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-BHeMJ6nr.mjs +1476 -0
  6. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-C2zwt5UF.js +1 -0
  7. package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-BYSeUW_V.js +925 -0
  8. package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs +5021 -0
  9. package/dist/Overview-CBahJviK.js +1 -0
  10. package/dist/Overview-CVQ1pkuD.mjs +527 -0
  11. package/dist/TableView-Csv5Lycy.mjs +6234 -0
  12. package/dist/TableView-Cwal0BPW.js +4 -0
  13. package/dist/agenda-BSdlrfxv.mjs +1253 -0
  14. package/dist/agenda-Bev1mO7E.js +1 -0
  15. package/dist/availability-ClBGVgE9.js +1 -0
  16. package/dist/availability-D8JdA4rP.mjs +274 -0
  17. package/dist/booking-data-Px7XCIfU.mjs +1024 -0
  18. package/dist/booking-data-aMS1p_3g.js +1 -0
  19. package/dist/cms-core-modules.css +1 -1
  20. package/dist/exceptions-CqityDo9.mjs +651 -0
  21. package/dist/exceptions-DXqc0Nza.js +1 -0
  22. package/dist/index-CM4eaK5T.mjs +1245 -0
  23. package/dist/index-DliTZzwI.js +35 -0
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.mjs +12 -11
  26. package/dist/orders-1swJVKw2.js +1 -0
  27. package/dist/orders-D41GbzIa.mjs +624 -0
  28. package/dist/payment-BJHgpaeT.js +1 -0
  29. package/dist/payment-D5j-68Ig.mjs +1278 -0
  30. package/dist/refunds-D9nTeD2d.mjs +436 -0
  31. package/dist/refunds-oVB2Opib.js +1 -0
  32. package/dist/resources-8WouFvJe.js +1 -0
  33. package/dist/resources-B-D5MUhV.mjs +975 -0
  34. package/dist/server-handlers.cjs.js +1 -1
  35. package/dist/server-handlers.mjs +626 -515
  36. package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +146 -5
  37. package/dist/src/appointments/components/edit/EventDialog/CancelRefundReservationDialog.vue.d.ts +33 -0
  38. package/dist/src/appointments/components/edit/EventDialog/OrderDetailDialog.vue.d.ts +26 -8
  39. package/dist/src/appointments/components/edit/EventDialog/RefundDetailsDisplay.vue.d.ts +8 -0
  40. package/dist/src/appointments/components/edit/EventDialog/ReservationDetailDialog.vue.d.ts +91 -5
  41. package/dist/src/appointments/components/edit/EventDialog/TransferReservationDialog.vue.d.ts +20 -3
  42. package/dist/src/appointments/components/edit/NewReservationDialog/ReservationLines.vue.d.ts +5 -0
  43. package/dist/src/appointments/components/edit/OrderMetadataDisplay.vue.d.ts +20 -2
  44. package/dist/src/appointments/components/edit/dashboard/BookingsList.vue.d.ts +240 -0
  45. package/dist/src/appointments/composables/useAgendaMetadataSchema.d.ts +37 -0
  46. package/dist/src/appointments/pages/edit/orders.vue.d.ts +225 -0
  47. package/dist/src/appointments/pages/edit/refunds.vue.d.ts +2 -0
  48. package/dist/src/appointments/server.d.ts +2 -0
  49. package/dist/src/appointments/types.d.ts +6 -0
  50. package/dist/src/appointments/utils/printReservation.d.ts +65 -3
  51. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/Table.d.ts +36 -0
  52. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/Table.vue.d.ts +95 -0
  53. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/TableCell.d.ts +13 -0
  54. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/TableHeader.d.ts +6 -0
  55. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/TableRow.d.ts +6 -0
  56. package/dist/src/contentManager/components/content-editor/tiptap-extensions/table/index.d.ts +4 -0
  57. package/dist/src/contentManager/components/content-editor/tiptap-menus/element-editor-views/TableMenu.vue.d.ts +13 -0
  58. package/dist/src/contentManager/components/content-editor/tiptap-menus/element-editor-views/index.d.ts +14 -0
  59. package/package.json +2 -2
  60. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-DWMqQvHl.mjs +0 -76
  61. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-kpjbVSXg.js +0 -1
  62. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Baqy-rTT.js +0 -1
  63. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Dx4Bpa2m.mjs +0 -1263
  64. package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-COrK1j0S.js +0 -1
  65. package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-Vb3q8EVv.mjs +0 -330
  66. package/dist/Overview-98nkJUWN.mjs +0 -481
  67. package/dist/Overview-Dl8cMlsr.js +0 -1
  68. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-CuwREvXD.js +0 -349
  69. package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-GYNZ_yhD.mjs +0 -3077
  70. package/dist/TableView-CVfkyj1k.js +0 -4
  71. package/dist/TableView-zDx0IegJ.mjs +0 -6096
  72. package/dist/agenda-BaJu3-1c.js +0 -1
  73. package/dist/agenda-BwVY_8oM.mjs +0 -1165
  74. package/dist/availability-CMrRa5y2.mjs +0 -269
  75. package/dist/availability-Cf2YfMwM.js +0 -1
  76. package/dist/booking-data-DgJd0BcM.mjs +0 -889
  77. package/dist/booking-data-Di5GmH_8.js +0 -1
  78. package/dist/exceptions-B6P9UiCj.js +0 -1
  79. package/dist/exceptions-De9-FvdP.mjs +0 -646
  80. package/dist/index-DL6orwdK.js +0 -35
  81. package/dist/index-hH3e-IYz.mjs +0 -1187
  82. package/dist/orders-C65SlpJy.mjs +0 -618
  83. package/dist/orders-XVzWAgG1.js +0 -1
  84. package/dist/payment-C3ohkehF.mjs +0 -1080
  85. package/dist/payment-Dfr-Ro-a.js +0 -1
  86. package/dist/resources-CxeFd57z.js +0 -1
  87. package/dist/resources-DwYxn2Vi.mjs +0 -811
@@ -0,0 +1,1476 @@
1
+ import { defineComponent as we, ref as j, reactive as Ue, computed as oe, watch as Re, resolveComponent as b, openBlock as i, createElementBlock as c, createElementVNode as f, Fragment as K, renderList as me, normalizeClass as _e, createVNode as r, withCtx as d, createTextVNode as w, toDisplayString as k, createCommentVNode as W, createBlock as he, onMounted as Fe, onBeforeUnmount as ze, nextTick as Le, unref as m, isRef as Ne, markRaw as Be, inject as qe } from "vue";
2
+ import { CalendarIcon as je, ChevronLeft as He, Check as Qe, ChevronRight as Ye, X as We, Zap as Ge, Plus as Pe, Pencil as Xe, Users as Ze, Tag as Je, Trash2 as Me } from "lucide-vue-next";
3
+ import { useModuleRoute as Ke, useModule as et, useFirebaseIntegration as tt } from "@oneclick.dev/cms-kit";
4
+ import { c as Oe } from "./utils-CanmrIWO.mjs";
5
+ import { e as nt, a as Ae, $ as Ve } from "./DateFormatter-qbhRYxI_.mjs";
6
+ import { _ as st } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
7
+ const at = { class: "space-y-3" }, ot = { class: "grid gap-4 @md/modal:grid-cols-2 @2xl/modal:grid-cols-3 @4xl/modal:grid-cols-4 overflow-hidden p-1" }, rt = {
8
+ key: 0,
9
+ class: "flex items-center gap-3 min-h-9"
10
+ }, it = {
11
+ key: 0,
12
+ class: "italic text-xs opacity-50"
13
+ }, lt = {
14
+ key: 0,
15
+ class: "italic text-xs opacity-50"
16
+ }, ut = {
17
+ key: 0,
18
+ class: "italic text-xs opacity-50"
19
+ }, dt = {
20
+ key: 0,
21
+ class: "italic text-xs opacity-50"
22
+ }, ct = {
23
+ key: 0,
24
+ class: "text-red-400"
25
+ }, pt = { class: "list-disc pl-4" }, mt = /* @__PURE__ */ we({
26
+ __name: "CustomerInformation",
27
+ props: {
28
+ agendaData: {}
29
+ },
30
+ setup(U, { expose: Z }) {
31
+ const E = [
32
+ {
33
+ id: "firstName",
34
+ fieldName: "First Name",
35
+ fieldType: "text",
36
+ required: !0,
37
+ visible: !0
38
+ },
39
+ {
40
+ id: "lastName",
41
+ fieldName: "Last Name",
42
+ fieldType: "text",
43
+ required: !0,
44
+ visible: !0
45
+ },
46
+ {
47
+ id: "phone",
48
+ fieldName: "Phone No",
49
+ fieldType: "tel",
50
+ required: !0,
51
+ visible: !0
52
+ },
53
+ {
54
+ id: "email",
55
+ fieldName: "Email",
56
+ fieldType: "email",
57
+ required: !0,
58
+ visible: !0
59
+ },
60
+ {
61
+ id: "birthDate",
62
+ fieldName: "Birth date",
63
+ fieldType: "date",
64
+ required: !0,
65
+ visible: !0
66
+ }
67
+ ], Q = /* @__PURE__ */ new Set(["firstName", "email"]), ue = U, z = j([]), O = Ue({}), F = oe(() => {
68
+ const g = ue.agendaData?.customerInformationFields, x = (Array.isArray(g) && g.length > 0 ? g : E).filter((C) => C?.id && (C.visible !== !1 || Q.has(C.id))).map((C) => ({
69
+ ...C,
70
+ required: Q.has(C.id),
71
+ visible: !0
72
+ })), I = E.filter((C) => Q.has(C.id) && !x.some((le) => le.id === C.id)).map((C) => ({
73
+ ...C,
74
+ required: !0,
75
+ visible: !0
76
+ }));
77
+ return [...x, ...I];
78
+ }), L = (g) => g.fieldName || g.id, B = (g) => g.replace(/[^A-Za-z0-9_-]/g, "-"), $ = (g, D) => ["new-res-customer-info", g.id, D].filter(Boolean).map((I) => B(I)).join("-"), A = (g) => g.fieldType === "email" || g.fieldType === "tel" || g.fieldType === "date" ? g.fieldType : "text", Y = (g) => Array.isArray(g.options) ? g.options.filter(Boolean) : [], G = (g) => g.fieldType === "checkbox" ? !1 : "", P = (g = !1) => {
79
+ const D = new Set(F.value.map((x) => x.id));
80
+ Object.keys(O).forEach((x) => {
81
+ D.has(x) || delete O[x];
82
+ }), F.value.forEach((x) => {
83
+ const I = G(x);
84
+ (g || O[x.id] === void 0 || typeof O[x.id] != typeof I) && (O[x.id] = I);
85
+ });
86
+ }, re = () => {
87
+ const g = F.value.reduce((D, x) => {
88
+ const I = O[x.id];
89
+ return D[x.id] = typeof I == "string" ? I.trim() : !!I, D;
90
+ }, {});
91
+ return Object.entries(g).forEach(([D, x]) => {
92
+ O[D] = x;
93
+ }), g;
94
+ }, T = (g, D) => g.fieldType === "checkbox" ? D === !0 : typeof D == "string" ? D.trim().length > 0 : D != null, ie = () => {
95
+ z.value = [], P(!0);
96
+ }, J = () => {
97
+ const g = [], D = re();
98
+ return F.value.forEach((x) => {
99
+ const I = D[x.id], C = L(x);
100
+ x.required && !T(x, I) && g.push(`Please fill in ${C}.`), x.fieldType === "email" && T(x, I) && typeof I == "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I) === !1 && g.push(`Please fill in a correct ${C}.`);
101
+ }), z.value = g, g.length === 0;
102
+ };
103
+ return Re(F, () => {
104
+ P();
105
+ }, { immediate: !0 }), Z({
106
+ getCustomerInfo: re,
107
+ reset: ie,
108
+ validateForm: J
109
+ }), (g, D) => {
110
+ const x = b("Checkbox"), I = b("Label"), C = b("SelectValue"), le = b("SelectTrigger"), ge = b("SelectItem"), be = b("SelectGroup"), fe = b("SelectContent"), te = b("Select"), ye = b("RadioGroupItem"), ne = b("RadioGroup"), de = b("Input");
111
+ return i(), c("div", at, [
112
+ D[0] || (D[0] = f("h2", { class: "text-sm font-medium" }, "Customer Information", -1)),
113
+ f("div", ot, [
114
+ (i(!0), c(K, null, me(F.value, (v) => (i(), c("div", {
115
+ key: v.id,
116
+ class: _e(["grid gap-2", v.fieldType === "checkbox" ? "@md/modal:col-span-2" : ""])
117
+ }, [
118
+ v.fieldType === "checkbox" ? (i(), c("div", rt, [
119
+ r(x, {
120
+ id: $(v),
121
+ modelValue: O[v.id],
122
+ "onUpdate:modelValue": (V) => O[v.id] = V
123
+ }, null, 8, ["id", "modelValue", "onUpdate:modelValue"]),
124
+ r(I, {
125
+ for: $(v),
126
+ class: "font-normal cursor-pointer"
127
+ }, {
128
+ default: d(() => [
129
+ w(k(L(v)) + " ", 1),
130
+ v.required ? W("", !0) : (i(), c("span", it, "optional"))
131
+ ]),
132
+ _: 2
133
+ }, 1032, ["for"])
134
+ ])) : v.fieldType === "select" ? (i(), c(K, { key: 1 }, [
135
+ r(I, {
136
+ for: $(v)
137
+ }, {
138
+ default: d(() => [
139
+ w(k(L(v)) + " ", 1),
140
+ v.required ? W("", !0) : (i(), c("span", lt, "optional"))
141
+ ]),
142
+ _: 2
143
+ }, 1032, ["for"]),
144
+ r(te, {
145
+ modelValue: O[v.id],
146
+ "onUpdate:modelValue": (V) => O[v.id] = V
147
+ }, {
148
+ default: d(() => [
149
+ r(le, {
150
+ id: $(v),
151
+ class: "w-full"
152
+ }, {
153
+ default: d(() => [
154
+ r(C, {
155
+ placeholder: `Select ${L(v)}`
156
+ }, null, 8, ["placeholder"])
157
+ ]),
158
+ _: 2
159
+ }, 1032, ["id"]),
160
+ r(fe, null, {
161
+ default: d(() => [
162
+ r(be, null, {
163
+ default: d(() => [
164
+ (i(!0), c(K, null, me(Y(v), (V) => (i(), he(ge, {
165
+ key: V,
166
+ value: V
167
+ }, {
168
+ default: d(() => [
169
+ w(k(V), 1)
170
+ ]),
171
+ _: 2
172
+ }, 1032, ["value"]))), 128))
173
+ ]),
174
+ _: 2
175
+ }, 1024)
176
+ ]),
177
+ _: 2
178
+ }, 1024)
179
+ ]),
180
+ _: 2
181
+ }, 1032, ["modelValue", "onUpdate:modelValue"])
182
+ ], 64)) : v.fieldType === "radio" ? (i(), c(K, { key: 2 }, [
183
+ r(I, null, {
184
+ default: d(() => [
185
+ w(k(L(v)) + " ", 1),
186
+ v.required ? W("", !0) : (i(), c("span", ut, "optional"))
187
+ ]),
188
+ _: 2
189
+ }, 1024),
190
+ r(ne, {
191
+ modelValue: O[v.id],
192
+ "onUpdate:modelValue": (V) => O[v.id] = V,
193
+ class: "grid gap-2"
194
+ }, {
195
+ default: d(() => [
196
+ (i(!0), c(K, null, me(Y(v), (V) => (i(), c("div", {
197
+ key: V,
198
+ class: "flex items-center gap-2"
199
+ }, [
200
+ r(ye, {
201
+ id: $(v, V),
202
+ value: V
203
+ }, null, 8, ["id", "value"]),
204
+ r(I, {
205
+ for: $(v, V),
206
+ class: "font-normal cursor-pointer"
207
+ }, {
208
+ default: d(() => [
209
+ w(k(V), 1)
210
+ ]),
211
+ _: 2
212
+ }, 1032, ["for"])
213
+ ]))), 128))
214
+ ]),
215
+ _: 2
216
+ }, 1032, ["modelValue", "onUpdate:modelValue"])
217
+ ], 64)) : (i(), c(K, { key: 3 }, [
218
+ r(I, {
219
+ for: $(v)
220
+ }, {
221
+ default: d(() => [
222
+ w(k(L(v)) + " ", 1),
223
+ v.required ? W("", !0) : (i(), c("span", dt, "optional"))
224
+ ]),
225
+ _: 2
226
+ }, 1032, ["for"]),
227
+ r(de, {
228
+ modelValue: O[v.id],
229
+ "onUpdate:modelValue": (V) => O[v.id] = V,
230
+ id: $(v),
231
+ type: A(v),
232
+ autocomplete: "off"
233
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "id", "type"])
234
+ ], 64))
235
+ ], 2))), 128))
236
+ ]),
237
+ z.value.length > 0 ? (i(), c("div", ct, [
238
+ f("ul", pt, [
239
+ (i(!0), c(K, null, me(z.value, (v) => (i(), c("li", { key: v }, k(v), 1))), 128))
240
+ ])
241
+ ])) : W("", !0)
242
+ ]);
243
+ };
244
+ }
245
+ });
246
+ function ft(U = {}) {
247
+ const Z = j(null), E = j(!1), Q = j(!1), ue = j(!1), z = j(!1), O = U.dragSpeed ?? 1.1, F = U.dragThreshold ?? 10, L = U.edgeThreshold ?? 10, B = U.ignoreDragSelector ?? 'input, select, textarea, [contenteditable="true"], [data-horizontal-scroll-ignore-drag]';
248
+ let $ = null, A = 0, Y = 0, G = !1, P = null, re = null, T = null;
249
+ const ie = () => {
250
+ P === null || typeof window > "u" || (window.clearTimeout(P), P = null);
251
+ }, J = () => {
252
+ const n = Z.value;
253
+ if (!n) {
254
+ Q.value = !1, ue.value = !1, z.value = !1;
255
+ return;
256
+ }
257
+ const _ = Math.max(n.scrollWidth - n.clientWidth, 0);
258
+ Q.value = _ > L, ue.value = Q.value && n.scrollLeft > L, z.value = Q.value && n.scrollLeft < _ - L;
259
+ }, g = () => {
260
+ Le(() => {
261
+ if (typeof window > "u") {
262
+ J();
263
+ return;
264
+ }
265
+ window.requestAnimationFrame(() => J());
266
+ });
267
+ }, D = () => {
268
+ if (typeof U.scrollStep == "number") return U.scrollStep;
269
+ const n = Z.value;
270
+ return n ? Math.max(Math.floor(n.clientWidth * 0.72), 180) : 240;
271
+ }, x = (n, _ = "smooth") => {
272
+ const H = Z.value;
273
+ if (H) {
274
+ if (H.scrollBy({ left: n, behavior: _ }), _ === "auto") {
275
+ J();
276
+ return;
277
+ }
278
+ g();
279
+ }
280
+ }, I = () => {
281
+ x(-D());
282
+ }, C = () => {
283
+ x(D());
284
+ }, le = () => {
285
+ const n = Z.value;
286
+ $ !== null && n?.hasPointerCapture?.($) && n.releasePointerCapture($), E.value && (G = !0, ie(), typeof window < "u" && (P = window.setTimeout(() => {
287
+ G = !1, P = null;
288
+ }, 0))), $ = null, E.value = !1, n && (n.style.userSelect = "", n.style.cursor = ""), J();
289
+ }, ge = () => {
290
+ J();
291
+ }, be = (n) => {
292
+ const _ = Z.value;
293
+ if (!_ || !Q.value || Math.abs(n.deltaY) <= Math.abs(n.deltaX)) return;
294
+ const H = n.deltaY < 0, ce = n.deltaY > 0;
295
+ H && !ue.value || ce && !z.value || (n.preventDefault(), _.scrollLeft += n.deltaY, J());
296
+ }, fe = (n) => n instanceof Element ? !!n.closest(B) : !1, te = (n) => {
297
+ const _ = Z.value;
298
+ !_ || !Q.value || n.pointerType !== "touch" && n.button === 0 && (fe(n.target) || ($ = n.pointerId, A = n.clientX, Y = _.scrollLeft, G = !1));
299
+ }, ye = (n) => {
300
+ const _ = Z.value;
301
+ if (!_ || $ !== n.pointerId) return;
302
+ const H = n.clientX - A;
303
+ !E.value && Math.abs(H) < F || (E.value || (E.value = !0, _.style.userSelect = "none", _.style.cursor = "grabbing", _.setPointerCapture?.(n.pointerId)), n.preventDefault(), _.scrollLeft = Y - H * O, J());
304
+ }, ne = (n) => {
305
+ $ === n.pointerId && le();
306
+ }, de = () => {
307
+ $ !== null && le();
308
+ }, v = (n) => {
309
+ G && (n.preventDefault(), n.stopPropagation(), G = !1);
310
+ }, V = (n) => {
311
+ typeof ResizeObserver < "u" && (re = new ResizeObserver(() => J()), re.observe(n)), U.observeMutations !== !1 && typeof MutationObserver < "u" && (T = new MutationObserver(() => g()), T.observe(n, {
312
+ childList: !0,
313
+ subtree: !0,
314
+ characterData: !0
315
+ }));
316
+ }, se = () => {
317
+ re?.disconnect(), T?.disconnect(), re = null, T = null;
318
+ }, ke = (n) => {
319
+ n.addEventListener("scroll", ge), n.addEventListener("wheel", be, { passive: !1 }), n.addEventListener("pointerdown", te), n.addEventListener("pointermove", ye), n.addEventListener("pointerup", ne), n.addEventListener("pointercancel", de), n.addEventListener("lostpointercapture", de), n.addEventListener("click", v, !0), V(n), g();
320
+ }, N = (n) => {
321
+ n.removeEventListener("scroll", ge), n.removeEventListener("wheel", be), n.removeEventListener("pointerdown", te), n.removeEventListener("pointermove", ye), n.removeEventListener("pointerup", ne), n.removeEventListener("pointercancel", de), n.removeEventListener("lostpointercapture", de), n.removeEventListener("click", v, !0), se();
322
+ };
323
+ return Re(Z, (n, _) => {
324
+ _ && N(_), n ? ke(n) : J();
325
+ }), Fe(() => {
326
+ g();
327
+ }), ze(() => {
328
+ ie(), Z.value && N(Z.value), G = !1, le();
329
+ }), {
330
+ canScrollLeft: oe(() => ue.value),
331
+ canScrollRight: oe(() => z.value),
332
+ containerRef: Z,
333
+ isDragging: E,
334
+ isScrollable: Q,
335
+ refresh: g,
336
+ scrollNext: C,
337
+ scrollPrev: I,
338
+ showLeftShadow: ue,
339
+ showRightShadow: z
340
+ };
341
+ }
342
+ const gt = { class: "flex items-start justify-between gap-3" }, vt = { class: "text-sm font-medium" }, _t = {
343
+ key: 0,
344
+ class: "mt-1 text-xs text-muted-foreground"
345
+ }, ht = { class: "grid gap-4 @md/quick-adder:grid-cols-2 @2xl/quick-adder:grid-cols-3 @4xl/quick-adder:grid-cols-4" }, bt = { class: "grid gap-2" }, yt = {
346
+ key: 0,
347
+ class: "grid gap-2"
348
+ }, xt = {
349
+ key: 1,
350
+ class: "grid gap-2"
351
+ }, St = {
352
+ key: 2,
353
+ class: "grid gap-2"
354
+ }, kt = { class: "grid gap-2" }, $t = {
355
+ key: 0,
356
+ class: "rounded-md border border-dashed bg-muted/20 px-4 py-4 text-sm text-muted-foreground"
357
+ }, Tt = {
358
+ key: 1,
359
+ class: "relative flex items-center gap-2 overflow-hidden"
360
+ }, It = { class: "relative min-w-0 flex-1 overflow-hidden" }, Rt = {
361
+ key: 0,
362
+ class: "pointer-events-none absolute inset-y-0 left-0 z-10 w-10 md:w-20 bg-gradient-to-r from-background via-background/95 to-transparent"
363
+ }, wt = {
364
+ key: 1,
365
+ class: "pointer-events-none absolute inset-y-0 right-0 z-10 w-10 md:w-20 bg-gradient-to-l from-background via-background/95 to-transparent"
366
+ }, Dt = {
367
+ key: 0,
368
+ class: "absolute -top-1 -right-1 flex items-center justify-center bg-primary rounded-full text-background size-4"
369
+ }, Ct = { class: "flex flex-wrap gap-2" }, Nt = ["onClick"], Ot = { key: 0 }, Vt = { key: 1 }, Mt = { key: 2 }, At = /* @__PURE__ */ we({
370
+ __name: "QuickReservationAdder",
371
+ props: {
372
+ agendaData: {},
373
+ surface: { default: "card" }
374
+ },
375
+ emits: ["add"],
376
+ setup(U, { emit: Z }) {
377
+ const E = U, Q = Z, ue = new nt("en-US", {
378
+ dateStyle: "long"
379
+ }), z = Ae(Ve()), O = oe(() => E.surface === "popover"), F = j(""), L = j(void 0), B = j(""), $ = j(""), A = j([]), Y = j(1), G = oe(() => E.agendaData?.resources?.find((N) => N.id === B.value)), P = (N) => {
380
+ const [n, _] = N.split(":").map(Number);
381
+ return n * 60 + _;
382
+ }, re = (N) => {
383
+ const n = Math.floor(N / 60), _ = N % 60;
384
+ return `${n.toString().padStart(2, "0")}:${_.toString().padStart(2, "0")}`;
385
+ }, T = () => {
386
+ if (!G.value) return [];
387
+ const N = G.value.interval || 60;
388
+ let n = null, _ = null;
389
+ for (const ce of Object.values(G.value.openingHours || {}))
390
+ for (const a of ce) {
391
+ const s = P(a.start), p = P(a.end);
392
+ (n === null || s < n) && (n = s), (_ === null || p > _) && (_ = p);
393
+ }
394
+ if (n === null || _ === null) return [];
395
+ const H = [];
396
+ for (let ce = n; ce < _; ce += N)
397
+ H.push(re(ce));
398
+ return H;
399
+ }, ie = oe(() => L.value && B.value && $.value && A.value.length > 0), J = oe(() => T()), {
400
+ canScrollLeft: g,
401
+ canScrollRight: D,
402
+ containerRef: x,
403
+ isDragging: I,
404
+ isScrollable: C,
405
+ scrollNext: le,
406
+ scrollPrev: ge,
407
+ showLeftShadow: be,
408
+ showRightShadow: fe
409
+ } = ft(), te = (N) => A.value.includes(N), ye = (N) => {
410
+ if (te(N)) {
411
+ A.value = A.value.filter((n) => n !== N);
412
+ return;
413
+ }
414
+ A.value = [...A.value, N].sort((n, _) => P(n) - P(_));
415
+ }, ne = (N, n) => {
416
+ L.value = N ? Be(N) : void 0, F.value = N ? `${N}` : "", n();
417
+ }, de = j(""), v = j(""), V = j([]), se = () => {
418
+ Q("add", {
419
+ date: L.value,
420
+ resourceId: B.value,
421
+ pricingOptionId: $.value,
422
+ startTimes: A.value,
423
+ spots: Y.value
424
+ }), A.value = [], V.value = [], v.value = "", de.value = "";
425
+ }, ke = () => {
426
+ F.value = z.toString(), L.value = z, B.value = E.agendaData?.resources?.[0]?.id || "", $.value = E.agendaData?.pricingOptions?.find((N) => N.isDefault)?.id || E.agendaData?.pricingOptions?.[0]?.id || "", A.value = [], Y.value = 1, de.value = "";
427
+ };
428
+ return Fe(() => {
429
+ ke();
430
+ }), (N, n) => {
431
+ const _ = b("Label"), H = b("Button"), ce = b("PopoverTrigger"), a = b("Calendar"), s = b("PopoverContent"), p = b("Popover"), S = b("DynamicSelectOption"), M = b("DynamicSelect"), ae = b("Input");
432
+ return i(), c("div", {
433
+ class: _e(m(Oe)(
434
+ "@container/quick-adder grid gap-4 overflow-hidden bg-background",
435
+ m(O) ? "p-5 sm:p-6" : "rounded-md border p-4"
436
+ ))
437
+ }, [
438
+ f("div", gt, [
439
+ f("div", null, [
440
+ f("h3", vt, k(m(O) ? "Quick add reservations" : "Add reservations"), 1),
441
+ m(O) ? (i(), c("p", _t, " Choose one date and add multiple timeslots in one pass. ")) : W("", !0)
442
+ ])
443
+ ]),
444
+ f("div", ht, [
445
+ f("div", bt, [
446
+ r(_, null, {
447
+ default: d(() => [...n[3] || (n[3] = [
448
+ w("Date", -1)
449
+ ])]),
450
+ _: 1
451
+ }),
452
+ r(p, null, {
453
+ default: d(({ close: h }) => [
454
+ r(ce, { "as-child": "" }, {
455
+ default: d(() => [
456
+ r(H, {
457
+ type: "button",
458
+ variant: "outline",
459
+ class: _e(m(Oe)("w-full justify-start text-left font-normal", !m(L) && "text-muted-foreground"))
460
+ }, {
461
+ default: d(() => [
462
+ r(m(je)),
463
+ w(" " + k(m(L) ? m(ue).format(m(L).toDate(m(Ve)())) : "Pick a date"), 1)
464
+ ]),
465
+ _: 1
466
+ }, 8, ["class"])
467
+ ]),
468
+ _: 1
469
+ }),
470
+ r(s, {
471
+ class: "w-auto p-0",
472
+ align: "start"
473
+ }, {
474
+ default: d(() => [
475
+ r(a, {
476
+ "model-value": m(L),
477
+ "default-placeholder": m(z),
478
+ layout: "month-and-year",
479
+ "initial-focus": "",
480
+ "onUpdate:modelValue": (pe) => ne(pe, h),
481
+ minValue: m(Ae)(m(Ve)())
482
+ }, null, 8, ["model-value", "default-placeholder", "onUpdate:modelValue", "minValue"])
483
+ ]),
484
+ _: 2
485
+ }, 1024)
486
+ ]),
487
+ _: 1
488
+ })
489
+ ]),
490
+ U.agendaData.resources?.length > 1 ? (i(), c("div", yt, [
491
+ r(_, null, {
492
+ default: d(() => [...n[4] || (n[4] = [
493
+ w("Resource", -1)
494
+ ])]),
495
+ _: 1
496
+ }),
497
+ r(M, {
498
+ modelValue: m(B),
499
+ "onUpdate:modelValue": n[0] || (n[0] = (h) => Ne(B) ? B.value = h : null),
500
+ "wrapper-class": "w-full",
501
+ class: "w-full",
502
+ placeholder: "Select resource"
503
+ }, {
504
+ default: d(() => [
505
+ (i(!0), c(K, null, me(U.agendaData.resources || [], (h) => (i(), he(S, {
506
+ key: h.id,
507
+ value: h.id
508
+ }, {
509
+ default: d(() => [
510
+ w(k(h.name), 1)
511
+ ]),
512
+ _: 2
513
+ }, 1032, ["value"]))), 128))
514
+ ]),
515
+ _: 1
516
+ }, 8, ["modelValue"])
517
+ ])) : W("", !0),
518
+ U.agendaData.pricingOptions?.length > 1 ? (i(), c("div", xt, [
519
+ r(_, null, {
520
+ default: d(() => [...n[5] || (n[5] = [
521
+ w("Type", -1)
522
+ ])]),
523
+ _: 1
524
+ }),
525
+ r(M, {
526
+ modelValue: m($),
527
+ "onUpdate:modelValue": n[1] || (n[1] = (h) => Ne($) ? $.value = h : null),
528
+ "wrapper-class": "w-full",
529
+ class: "w-full",
530
+ placeholder: "Select type"
531
+ }, {
532
+ default: d(() => [
533
+ (i(!0), c(K, null, me(U.agendaData.pricingOptions || [], (h) => (i(), he(S, {
534
+ key: h.id,
535
+ value: h.id
536
+ }, {
537
+ default: d(() => [
538
+ w(k(h.name) + " (" + k(h.duration) + "min) ", 1)
539
+ ]),
540
+ _: 2
541
+ }, 1032, ["value"]))), 128))
542
+ ]),
543
+ _: 1
544
+ }, 8, ["modelValue"])
545
+ ])) : W("", !0),
546
+ U.agendaData?.maxTicketsPerReservation > 1 ? (i(), c("div", St, [
547
+ r(_, null, {
548
+ default: d(() => [...n[6] || (n[6] = [
549
+ w("Spots/tickets", -1)
550
+ ])]),
551
+ _: 1
552
+ }),
553
+ r(ae, {
554
+ modelValue: m(Y),
555
+ "onUpdate:modelValue": n[2] || (n[2] = (h) => Ne(Y) ? Y.value = h : null),
556
+ modelModifiers: { number: !0 },
557
+ type: "number",
558
+ min: "1",
559
+ class: "no-spinner",
560
+ autocomplete: "off"
561
+ }, null, 8, ["modelValue"])
562
+ ])) : W("", !0)
563
+ ]),
564
+ f("div", kt, [
565
+ r(_, null, {
566
+ default: d(() => [...n[7] || (n[7] = [
567
+ w("Available hours", -1)
568
+ ])]),
569
+ _: 1
570
+ }),
571
+ m(J).length === 0 ? (i(), c("div", $t, " No preset hours are available for this resource. You can still add a custom time below. ")) : (i(), c("div", Tt, [
572
+ m(g) ? (i(), he(H, {
573
+ key: 0,
574
+ type: "button",
575
+ size: "icon",
576
+ variant: "outline",
577
+ class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] left-0.5",
578
+ onClick: m(ge)
579
+ }, {
580
+ default: d(() => [
581
+ r(m(He), { class: "size-4" })
582
+ ]),
583
+ _: 1
584
+ }, 8, ["onClick"])) : W("", !0),
585
+ f("div", It, [
586
+ m(be) ? (i(), c("div", Rt)) : W("", !0),
587
+ m(fe) ? (i(), c("div", wt)) : W("", !0),
588
+ f("div", {
589
+ ref_key: "hourScrollContainer",
590
+ ref: x,
591
+ class: _e(m(Oe)(
592
+ "hour-scroll-track flex w-full min-w-0 gap-2 overflow-x-auto overscroll-contain py-2",
593
+ m(C) && !m(I) && "cursor-grab",
594
+ m(I) && "cursor-grabbing select-none"
595
+ ))
596
+ }, [
597
+ (i(!0), c(K, null, me(m(J), (h) => (i(), he(H, {
598
+ key: h,
599
+ type: "button",
600
+ variant: "outline",
601
+ class: _e(["relative h-12 shrink-0", te(h) ? "border-primary!" : ""]),
602
+ onClick: (pe) => ye(h)
603
+ }, {
604
+ default: d(() => [
605
+ w(k(h) + " ", 1),
606
+ te(h) ? (i(), c("div", Dt, [
607
+ r(m(Qe), { class: "size-3" })
608
+ ])) : W("", !0)
609
+ ]),
610
+ _: 2
611
+ }, 1032, ["class", "onClick"]))), 128))
612
+ ], 2)
613
+ ]),
614
+ m(D) ? (i(), he(H, {
615
+ key: 1,
616
+ type: "button",
617
+ size: "icon",
618
+ variant: "outline",
619
+ class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] right-0.5",
620
+ onClick: m(le)
621
+ }, {
622
+ default: d(() => [
623
+ r(m(Ye), { class: "size-4" })
624
+ ]),
625
+ _: 1
626
+ }, 8, ["onClick"])) : W("", !0)
627
+ ])),
628
+ f("div", Ct, [
629
+ (i(!0), c(K, null, me(m(V), (h) => (i(), c("div", {
630
+ key: h,
631
+ class: "relative"
632
+ }, [
633
+ r(H, {
634
+ type: "button",
635
+ variant: "outline",
636
+ class: "h-12 px-4 py-2"
637
+ }, {
638
+ default: d(() => [
639
+ w(k(h), 1)
640
+ ]),
641
+ _: 2
642
+ }, 1024),
643
+ f("div", {
644
+ class: "absolute -top-1 -right-1 flex items-center justify-center bg-red-500 rounded-full text-white size-4 cursor-pointer",
645
+ onClick: (pe) => {
646
+ V.value = m(V).filter((ve) => ve !== h), A.value = m(A).filter((ve) => ve !== h);
647
+ }
648
+ }, [
649
+ r(m(We), { class: "size-3" })
650
+ ], 8, Nt)
651
+ ]))), 128))
652
+ ])
653
+ ]),
654
+ f("div", null, [
655
+ r(H, {
656
+ disabled: !m(ie),
657
+ onClick: se
658
+ }, {
659
+ default: d(() => [
660
+ m(A).length === 0 ? (i(), c("span", Ot, "Select at least one timeslot")) : m(A).length === 1 ? (i(), c("span", Vt, "Add 1 reservation")) : (i(), c("span", Mt, "Add " + k(m(A).length) + " reservations", 1))
661
+ ]),
662
+ _: 1
663
+ }, 8, ["disabled"])
664
+ ])
665
+ ], 2);
666
+ };
667
+ }
668
+ }), Et = /* @__PURE__ */ st(At, [["__scopeId", "data-v-c7529556"]]), Ft = { class: "space-y-3" }, Lt = { class: "flex flex-wrap items-center justify-between gap-3" }, Pt = { class: "text-xs text-muted-foreground" }, Ut = { class: "flex flex-wrap items-center gap-2" }, zt = {
669
+ key: 0,
670
+ class: "rounded-md border border-dashed bg-muted/20 px-4 py-6 text-sm text-muted-foreground"
671
+ }, Bt = {
672
+ key: 1,
673
+ class: "space-y-3"
674
+ }, qt = { class: "flex items-start gap-2 p-3 md:hidden" }, jt = ["aria-expanded", "onClick"], Ht = { class: "mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground" }, Qt = { class: "min-w-0 flex-1" }, Yt = { class: "flex items-start justify-between gap-3" }, Wt = { class: "min-w-0" }, Gt = { class: "block truncate text-base font-semibold" }, Xt = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Zt = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Jt = { class: "flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 text-muted-foreground" }, Kt = { class: "mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground" }, en = { class: "inline-flex items-center gap-1.5" }, tn = { class: "inline-flex items-center gap-1.5" }, nn = { class: "hidden items-start justify-between gap-3 p-4 pb-0 md:flex" }, sn = { class: "text-sm font-medium" }, an = { class: "text-xs text-muted-foreground" }, on = { class: "grid gap-4 border-t pt-3 md:grid-cols-2 md:border-0 md:pt-4 xl:grid-cols-5" }, rn = { class: "grid gap-2" }, ln = { class: "grid gap-2" }, un = {
675
+ key: 0,
676
+ class: "text-xs text-orange-500"
677
+ }, dn = { class: "grid gap-2" }, cn = {
678
+ key: 0,
679
+ class: "text-xs text-muted-foreground"
680
+ }, pn = {
681
+ key: 1,
682
+ class: "flex items-center h-[36px] text-sm"
683
+ }, mn = { key: 0 }, fn = { key: 1 }, gn = { key: 2 }, vn = {
684
+ key: 0,
685
+ class: "grid gap-2"
686
+ }, _n = /* @__PURE__ */ we({
687
+ __name: "ReservationLines",
688
+ props: {
689
+ modelValue: {},
690
+ agendaData: {},
691
+ availabilityByReservation: {}
692
+ },
693
+ emits: ["add", "quick-add", "update:modelValue"],
694
+ setup(U, { emit: Z }) {
695
+ const E = U, Q = Z, ue = /^([01]\d|2[0-3]):[0-5]\d$/, z = oe(() => E.modelValue ?? []), O = oe(() => Number(E.agendaData?.maxTicketsPerReservation) > 1), F = j(null), L = j(!1), B = oe(() => String(E.agendaData?.currency || "EUR").toUpperCase()), $ = oe(() => {
696
+ try {
697
+ return new Intl.NumberFormat("en-US", {
698
+ style: "currency",
699
+ currency: B.value,
700
+ minimumFractionDigits: 2,
701
+ maximumFractionDigits: 2
702
+ });
703
+ } catch {
704
+ return new Intl.NumberFormat("en-US", {
705
+ minimumFractionDigits: 2,
706
+ maximumFractionDigits: 2
707
+ });
708
+ }
709
+ }), A = (a) => {
710
+ Q("update:modelValue", a);
711
+ }, Y = (a) => ["date", "resourceId", "pricingOption"].includes(a), G = (a) => {
712
+ if (!a.date || !a.resourceId || !a.pricingOption) return a;
713
+ const s = ne(a);
714
+ return s.length === 0 ? {
715
+ ...a,
716
+ startTime: ""
717
+ } : s.includes(a.startTime) ? a : {
718
+ ...a,
719
+ startTime: s[0]
720
+ };
721
+ }, P = (a, s, p) => {
722
+ A(z.value.map((S) => {
723
+ if (S.id !== a) return S;
724
+ if (s === "date") {
725
+ const ae = {
726
+ ...S,
727
+ date: String(p ?? ""),
728
+ dateValue: p || void 0
729
+ };
730
+ return G(ae);
731
+ }
732
+ const M = {
733
+ ...S,
734
+ [s]: p
735
+ };
736
+ return Y(s) ? G(M) : M;
737
+ }));
738
+ }, re = (a, s) => {
739
+ const p = Number(s);
740
+ P(a, "paid", Number.isFinite(p) ? p : 0);
741
+ }, T = (a, s) => {
742
+ const p = Number(s);
743
+ P(a, "spots", Number.isFinite(p) && p > 0 ? p : 1);
744
+ }, ie = (a) => {
745
+ A(z.value.filter((s) => s.id !== a));
746
+ }, J = (a) => {
747
+ Q("quick-add", a), L.value = !1;
748
+ }, g = (a) => E.agendaData?.pricingOptions?.find((s) => s.id === a.pricingOption), D = (a) => {
749
+ const s = g(a);
750
+ return s ? s.duration ? `${s.name} (${s.duration}min)` : s.name : "Reservation";
751
+ }, x = (a) => E.agendaData?.resources?.find((s) => s.id === a.resourceId), I = (a) => x(a)?.name || "Unknown resource", C = (a) => {
752
+ if (!a || !ue.test(a)) return null;
753
+ const [s, p] = a.split(":").map(Number);
754
+ return s * 60 + p;
755
+ }, le = (a) => {
756
+ const s = (a % 1440 + 1440) % 1440, p = Math.floor(s / 60), S = s % 60;
757
+ return `${p.toString().padStart(2, "0")}:${S.toString().padStart(2, "0")}`;
758
+ }, ge = (a) => {
759
+ const s = Number(g(a)?.duration);
760
+ return Number.isFinite(s) && s > 0 ? s : 0;
761
+ }, be = (a) => {
762
+ if (!a.startTime) return "";
763
+ const s = ge(a);
764
+ if (s <= 0) return "";
765
+ const p = C(a.startTime);
766
+ return p === null ? "" : le(p + s);
767
+ }, fe = (a) => {
768
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(a)) return null;
769
+ const [s, p, S] = a.split("-").map(Number), M = new Date(s, p - 1, S);
770
+ return Number.isNaN(M.getTime()) || M.getFullYear() !== s || M.getMonth() !== p - 1 || M.getDate() !== S ? null : M;
771
+ }, te = (a, s) => (E.agendaData?.exceptions || []).find((S) => s >= S.startDate && s <= S.endDate ? !S.resourceIds || S.resourceIds.length === 0 ? !0 : S.resourceIds.includes(a) : !1) || null, ye = (a) => {
772
+ const s = x(a), p = fe(a.date);
773
+ if (!s || !p) return [];
774
+ const S = te(s.id, a.date);
775
+ if (S)
776
+ return S.isClosed ? [] : (S.timeslots || []).map((ae) => ({
777
+ start: ae.startTime,
778
+ end: ae.endTime
779
+ }));
780
+ const M = p.getDay();
781
+ return s.openingHours?.[M] || [];
782
+ }, ne = (a) => {
783
+ const s = x(a);
784
+ if (!s) return [];
785
+ const p = Number(s.interval) > 0 ? Number(s.interval) : 60, S = ge(a), M = /* @__PURE__ */ new Set();
786
+ for (const ae of ye(a)) {
787
+ const h = C(ae.start), pe = C(ae.end);
788
+ if (h === null || pe === null || pe <= h) continue;
789
+ const ve = S > 0 ? pe - S : pe - p;
790
+ for (let xe = h; xe <= ve; xe += p)
791
+ M.add(le(xe));
792
+ }
793
+ return Array.from(M).sort((ae, h) => (C(ae) ?? 0) - (C(h) ?? 0));
794
+ }, de = (a) => {
795
+ if (!a.startTime) return "Select time";
796
+ const s = be(a);
797
+ return s ? `${a.startTime} - ${s}` : a.startTime;
798
+ }, v = (a) => {
799
+ const s = Number(a);
800
+ if (!Number.isFinite(s)) return B.value === "EUR" ? "€0.00" : "0.00";
801
+ try {
802
+ return $.value.format(s);
803
+ } catch {
804
+ return `${s.toFixed(2)}`;
805
+ }
806
+ }, V = (a) => {
807
+ const s = Number(a.spots), p = Number.isFinite(s) && s > 0 ? s : 1;
808
+ return p === 1 ? "1 spot" : `${p} spots`;
809
+ }, se = (a) => E.availabilityByReservation?.[a.id] ?? null, ke = (a) => {
810
+ const s = se(a);
811
+ return !s || s.status === "checking" ? "text-muted-foreground" : s.status === "available" ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400";
812
+ }, N = (a) => {
813
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(a)) return null;
814
+ const [s, p, S] = a.split("-").map(Number), M = new Date(s, p - 1, S);
815
+ return Number.isNaN(M.getTime()) || M.getFullYear() !== s || M.getMonth() !== p - 1 || M.getDate() !== S ? null : (M.setHours(0, 0, 0, 0), M);
816
+ }, n = (a) => {
817
+ const s = N(String(a.date || "").trim());
818
+ if (!s) return "";
819
+ const p = /* @__PURE__ */ new Date();
820
+ if (p.setHours(0, 0, 0, 0), s < p)
821
+ return "This date is in the past. Double-check it before saving.";
822
+ const S = new Date(p);
823
+ return S.setFullYear(S.getFullYear() + 1), s > S ? "This date is more than a year ahead. Double-check it before saving." : "";
824
+ }, _ = (a) => !a.date || !a.startTime || !a.resourceId || !a.pricingOption, H = (a) => F.value === a, ce = (a) => {
825
+ F.value = F.value === a ? null : a;
826
+ };
827
+ return Re(z, (a) => {
828
+ const s = new Set(a.map((p) => p.id));
829
+ if (F.value && !s.has(F.value) && (F.value = null), !F.value) {
830
+ const p = a.find(_);
831
+ p && (F.value = p.id);
832
+ }
833
+ }, { immediate: !0 }), (a, s) => {
834
+ const p = b("Button"), S = b("PopoverTrigger"), M = b("PopoverContent"), ae = b("Popover"), h = b("Label"), pe = b("DynamicSelectOption"), ve = b("DynamicSelect"), xe = b("Input"), De = b("SelectValue"), Ce = b("SelectTrigger"), e = b("SelectItem"), o = b("SelectContent"), u = b("Select");
835
+ return i(), c("div", Ft, [
836
+ f("div", Lt, [
837
+ f("p", Pt, k(z.value.length === 1 ? "1 reservation line" : `${z.value.length} reservation lines`), 1),
838
+ f("div", Ut, [
839
+ r(ae, {
840
+ open: L.value,
841
+ "onUpdate:open": s[0] || (s[0] = (t) => L.value = t)
842
+ }, {
843
+ default: d(() => [
844
+ r(S, { "as-child": "" }, {
845
+ default: d(() => [
846
+ r(p, {
847
+ type: "button",
848
+ variant: "outline",
849
+ size: "sm",
850
+ class: "gap-2"
851
+ }, {
852
+ default: d(() => [
853
+ r(m(Ge), { class: "size-4 text-primary" }),
854
+ s[2] || (s[2] = w(" Quick add ", -1))
855
+ ]),
856
+ _: 1
857
+ })
858
+ ]),
859
+ _: 1
860
+ }),
861
+ r(M, {
862
+ align: "end",
863
+ class: "max-h-[80vh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto p-0"
864
+ }, {
865
+ default: d(() => [
866
+ L.value ? (i(), he(Et, {
867
+ key: 0,
868
+ surface: "popover",
869
+ agendaData: U.agendaData,
870
+ onAdd: J
871
+ }, null, 8, ["agendaData"])) : W("", !0)
872
+ ]),
873
+ _: 1
874
+ })
875
+ ]),
876
+ _: 1
877
+ }, 8, ["open"]),
878
+ r(p, {
879
+ type: "button",
880
+ variant: "outline",
881
+ size: "sm",
882
+ onClick: s[1] || (s[1] = (t) => Q("add"))
883
+ }, {
884
+ default: d(() => [
885
+ r(m(Pe), { class: "size-4" }),
886
+ s[3] || (s[3] = w(" Add line ", -1))
887
+ ]),
888
+ _: 1
889
+ })
890
+ ])
891
+ ]),
892
+ z.value.length === 0 ? (i(), c("div", zt, " Use Quick add to create filled reservation lines, or add an empty line manually. ")) : (i(), c("div", Bt, [
893
+ (i(!0), c(K, null, me(z.value, (t, y) => (i(), c("div", {
894
+ key: t.id,
895
+ class: "rounded-xl border bg-background"
896
+ }, [
897
+ f("div", qt, [
898
+ f("button", {
899
+ type: "button",
900
+ class: "flex min-w-0 flex-1 items-start gap-3 rounded-lg px-1 py-1 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",
901
+ "aria-expanded": H(t.id),
902
+ onClick: (l) => ce(t.id)
903
+ }, [
904
+ f("span", Ht, k(y + 1), 1),
905
+ f("span", Qt, [
906
+ f("span", Yt, [
907
+ f("span", Wt, [
908
+ f("span", Gt, k(de(t)), 1),
909
+ f("span", Xt, k(t.date || "No date selected"), 1),
910
+ f("span", Zt, k(I(t)) + " · " + k(D(t)), 1),
911
+ se(t)?.message ? (i(), c("span", {
912
+ key: 0,
913
+ class: _e(["mt-1 block text-xs font-medium", ke(t)])
914
+ }, k(se(t)?.message), 3)) : W("", !0)
915
+ ]),
916
+ f("span", Jt, [
917
+ r(m(Xe), { class: "size-4" })
918
+ ])
919
+ ]),
920
+ f("span", Kt, [
921
+ f("span", en, [
922
+ r(m(Ze), { class: "size-4" }),
923
+ w(" " + k(V(t)), 1)
924
+ ]),
925
+ f("span", tn, [
926
+ r(m(Je), { class: "size-4" }),
927
+ w(" " + k(v(t.paid)), 1)
928
+ ])
929
+ ])
930
+ ])
931
+ ], 8, jt),
932
+ r(p, {
933
+ type: "button",
934
+ variant: "ghost",
935
+ size: "icon",
936
+ class: "mt-1 shrink-0",
937
+ onClick: (l) => ie(t.id)
938
+ }, {
939
+ default: d(() => [
940
+ r(m(Me), { class: "size-4" })
941
+ ]),
942
+ _: 1
943
+ }, 8, ["onClick"])
944
+ ]),
945
+ f("div", nn, [
946
+ f("div", null, [
947
+ f("p", sn, "Reservation " + k(y + 1), 1),
948
+ f("p", an, k(I(t)) + " · " + k(D(t)), 1),
949
+ se(t)?.message ? (i(), c("p", {
950
+ key: 0,
951
+ class: _e(["mt-1 text-xs font-medium", ke(t)])
952
+ }, k(se(t)?.message), 3)) : W("", !0)
953
+ ]),
954
+ r(p, {
955
+ type: "button",
956
+ variant: "ghost",
957
+ size: "icon",
958
+ class: "shrink-0",
959
+ onClick: (l) => ie(t.id)
960
+ }, {
961
+ default: d(() => [
962
+ r(m(Me), { class: "size-4" })
963
+ ]),
964
+ _: 1
965
+ }, 8, ["onClick"])
966
+ ]),
967
+ f("div", {
968
+ class: _e(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden", H(t.id) ? "block" : "hidden md:block"])
969
+ }, [
970
+ f("div", on, [
971
+ f("div", rn, [
972
+ r(h, null, {
973
+ default: d(() => [...s[4] || (s[4] = [
974
+ w("Resource", -1)
975
+ ])]),
976
+ _: 1
977
+ }),
978
+ r(ve, {
979
+ "model-value": t.resourceId,
980
+ "wrapper-class": "w-full",
981
+ class: "w-full",
982
+ placeholder: "Select resource",
983
+ "onUpdate:modelValue": (l) => P(t.id, "resourceId", String(l ?? ""))
984
+ }, {
985
+ default: d(() => [
986
+ (i(!0), c(K, null, me(U.agendaData?.resources || [], (l) => (i(), he(pe, {
987
+ key: l.id,
988
+ value: l.id
989
+ }, {
990
+ default: d(() => [
991
+ w(k(l.name), 1)
992
+ ]),
993
+ _: 2
994
+ }, 1032, ["value"]))), 128))
995
+ ]),
996
+ _: 1
997
+ }, 8, ["model-value", "onUpdate:modelValue"])
998
+ ]),
999
+ f("div", ln, [
1000
+ r(h, null, {
1001
+ default: d(() => [...s[5] || (s[5] = [
1002
+ w("Date", -1)
1003
+ ])]),
1004
+ _: 1
1005
+ }),
1006
+ r(xe, {
1007
+ "model-value": t.date,
1008
+ type: "date",
1009
+ "onUpdate:modelValue": (l) => P(t.id, "date", String(l ?? ""))
1010
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1011
+ n(t) ? (i(), c("p", un, k(n(t)), 1)) : W("", !0)
1012
+ ]),
1013
+ f("div", dn, [
1014
+ r(h, {
1015
+ for: `new_reservation_res_line_${y}_time`
1016
+ }, {
1017
+ default: d(() => [...s[6] || (s[6] = [
1018
+ w("Time", -1)
1019
+ ])]),
1020
+ _: 1
1021
+ }, 8, ["for"]),
1022
+ t.resourceId && t.date ? (i(), c(K, { key: 0 }, [
1023
+ r(u, {
1024
+ "model-value": t.startTime,
1025
+ "onUpdate:modelValue": (l) => P(t.id, "startTime", String(l ?? ""))
1026
+ }, {
1027
+ default: d(() => [
1028
+ r(Ce, {
1029
+ id: `new_reservation_res_line_${y}_time`,
1030
+ class: "w-full"
1031
+ }, {
1032
+ default: d(() => [
1033
+ r(De, { placeholder: "Select an hour" })
1034
+ ]),
1035
+ _: 1
1036
+ }, 8, ["id"]),
1037
+ r(o, null, {
1038
+ default: d(() => [
1039
+ (i(!0), c(K, null, me(ne(t), (l) => (i(), he(e, {
1040
+ key: l,
1041
+ value: l
1042
+ }, {
1043
+ default: d(() => [
1044
+ w(k(l), 1)
1045
+ ]),
1046
+ _: 2
1047
+ }, 1032, ["value"]))), 128))
1048
+ ]),
1049
+ _: 2
1050
+ }, 1024)
1051
+ ]),
1052
+ _: 2
1053
+ }, 1032, ["model-value", "onUpdate:modelValue"]),
1054
+ t.resourceId && t.date && ne(t).length === 0 ? (i(), c("p", cn, " No times are available for this resource on the selected date. ")) : W("", !0)
1055
+ ], 64)) : (i(), c("p", pn, [
1056
+ !t.resourceId && !t.date ? (i(), c("span", mn, "Please select a resource and date.")) : t.resourceId ? t.date ? W("", !0) : (i(), c("span", gn, "Please select a date.")) : (i(), c("span", fn, "Please select a resource."))
1057
+ ]))
1058
+ ]),
1059
+ f("div", {
1060
+ class: _e(["grid gap-2", { hidden: U.agendaData?.pricingOptions?.length < 2 }])
1061
+ }, [
1062
+ r(h, null, {
1063
+ default: d(() => [...s[7] || (s[7] = [
1064
+ w("Type", -1)
1065
+ ])]),
1066
+ _: 1
1067
+ }),
1068
+ r(ve, {
1069
+ "model-value": t.pricingOption,
1070
+ "wrapper-class": "w-full",
1071
+ class: "w-full",
1072
+ placeholder: "Select type",
1073
+ "onUpdate:modelValue": (l) => P(t.id, "pricingOption", String(l ?? ""))
1074
+ }, {
1075
+ default: d(() => [
1076
+ (i(!0), c(K, null, me(U.agendaData?.pricingOptions || [], (l) => (i(), he(pe, {
1077
+ key: l.id,
1078
+ value: l.id
1079
+ }, {
1080
+ default: d(() => [
1081
+ w(k(l.name), 1)
1082
+ ]),
1083
+ _: 2
1084
+ }, 1032, ["value"]))), 128))
1085
+ ]),
1086
+ _: 1
1087
+ }, 8, ["model-value", "onUpdate:modelValue"])
1088
+ ], 2),
1089
+ f("div", {
1090
+ class: _e(["grid gap-4", O.value ? "md:grid-cols-2 xl:grid-cols-2 xl:col-span-1" : ""])
1091
+ }, [
1092
+ O.value ? (i(), c("div", vn, [
1093
+ r(h, null, {
1094
+ default: d(() => [...s[8] || (s[8] = [
1095
+ w("Spots", -1)
1096
+ ])]),
1097
+ _: 1
1098
+ }),
1099
+ r(xe, {
1100
+ "model-value": t.spots,
1101
+ type: "number",
1102
+ min: "1",
1103
+ class: "no-spinner",
1104
+ "onUpdate:modelValue": (l) => T(t.id, l)
1105
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
1106
+ ])) : W("", !0),
1107
+ f("div", {
1108
+ class: _e(["grid gap-2", O.value ? "" : "md:col-span-2 xl:col-span-1"])
1109
+ }, [
1110
+ r(h, null, {
1111
+ default: d(() => [...s[9] || (s[9] = [
1112
+ w("Paid", -1)
1113
+ ])]),
1114
+ _: 1
1115
+ }),
1116
+ r(xe, {
1117
+ "model-value": t.paid,
1118
+ type: "number",
1119
+ min: "0",
1120
+ step: "1",
1121
+ class: "no-spinner",
1122
+ "onUpdate:modelValue": (l) => re(t.id, l)
1123
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
1124
+ ], 2)
1125
+ ], 2)
1126
+ ])
1127
+ ], 2)
1128
+ ]))), 128))
1129
+ ]))
1130
+ ]);
1131
+ };
1132
+ }
1133
+ }), hn = { class: "space-y-5 md:mt-5" }, bn = { class: "space-y-3" }, yn = { class: "mt-4 text-red-400" }, xn = { class: "list-disc pl-4" }, Sn = { key: 0 }, kn = { key: 1 }, $n = { key: 2 }, Ee = "", Nn = /* @__PURE__ */ we({
1134
+ __name: "NewReservationDialog",
1135
+ props: {
1136
+ agendaData: {}
1137
+ },
1138
+ setup(U) {
1139
+ const Z = U, { params: E } = Ke(), { config: Q } = et(), { log: ue, logError: z } = useLogs(), O = tt(Q.project), F = oe(() => E.value?.id ?? E.id ?? ""), L = qe("agendaData", j({})), B = oe(() => Z.agendaData ?? L.value ?? {}), $ = j(!1), A = j(!1), Y = j({});
1140
+ let G = 0;
1141
+ const P = j([]), re = /^([01]\d|2[0-3]):[0-5]\d$/, T = j([]), ie = j(null), J = oe(() => Object.values(Y.value).some((e) => e.status === "checking")), g = oe(() => Object.values(Y.value).some((e) => e.status === "unavailable")), D = () => B.value?.resources?.[0]?.id ?? "", x = () => B.value?.pricingOptions?.find((e) => e.isDefault === !0)?.id ?? B.value?.pricingOptions?.[0]?.id ?? "", I = () => {
1142
+ const e = /* @__PURE__ */ new Date(), o = e.getFullYear(), u = `${e.getMonth() + 1}`.padStart(2, "0"), t = `${e.getDate()}`.padStart(2, "0");
1143
+ return `${o}-${u}-${t}`;
1144
+ }, C = (e) => {
1145
+ let o = e?.pricingOption ?? x(), u = B.value?.pricingOptions?.find((y) => y.id === o)?.price ?? 0;
1146
+ typeof u == "string" && (u = Number(u));
1147
+ let t = e?.paid ?? u;
1148
+ return typeof t == "string" && (t = Number(t)), {
1149
+ id: `reservation_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1150
+ spots: Number(e?.spots) || 1,
1151
+ paid: Number.isFinite(t) ? t : 0,
1152
+ resourceId: e?.resourceId ?? D(),
1153
+ pricingOption: o,
1154
+ date: e?.date ?? I(),
1155
+ dateValue: e?.dateValue,
1156
+ startTime: e?.startTime ?? Ee
1157
+ };
1158
+ }, le = () => {
1159
+ T.value = [C()];
1160
+ }, ge = (e) => (!e.date || e.date === I()) && e.startTime === Ee, be = () => {
1161
+ const e = T.value[T.value.length - 1];
1162
+ T.value = [...T.value, C(e ? { ...e } : void 0)];
1163
+ }, fe = (e) => B.value?.pricingOptions?.find((o) => o.id === e.pricingOption), te = (e) => B.value?.resources?.find((o) => o.id === e.resourceId), ye = () => {
1164
+ const e = Number(B.value?.maxTicketsPerReservation);
1165
+ return Number.isFinite(e) && e > 0 ? e : null;
1166
+ }, ne = (e) => `Reservation ${e + 1}`, de = (e) => {
1167
+ const o = String(e.date || "").trim(), u = String(e.startTime || "").trim(), t = String(e.resourceId || "").trim();
1168
+ return !o || !u || !t ? "" : `${t}_${o}_${u}`;
1169
+ }, v = () => {
1170
+ const e = [], o = /* @__PURE__ */ new Map(), u = ye();
1171
+ return T.value.forEach((t, y) => {
1172
+ const l = ne(y), q = String(t.date || "").trim(), X = String(t.startTime || "").trim(), R = String(t.resourceId || "").trim(), ee = String(t.pricingOption || "").trim(), Te = Number(t.spots), $e = Number(t.paid);
1173
+ q || e.push(`${l}: please select a date.`), X ? re.test(X) || e.push(`${l}: please enter a valid time.`) : e.push(`${l}: please select a time.`), R ? te(t) || e.push(`${l}: the selected resource is no longer available.`) : e.push(`${l}: please select a resource.`), ee ? fe(t) || e.push(`${l}: the selected type is no longer available.`) : e.push(`${l}: please select a type.`), !Number.isFinite(Te) || Te <= 0 ? e.push(`${l}: spots must be at least 1.`) : u !== null && Te > u && e.push(`${l}: spots cannot be more than ${u}.`), (!Number.isFinite($e) || $e < 0) && e.push(`${l}: paid amount must be 0 or higher.`);
1174
+ const Se = de(t);
1175
+ if (Se) {
1176
+ const Ie = o.get(Se);
1177
+ Ie !== void 0 ? e.push(`${l}: duplicate of ${ne(Ie).toLowerCase()}.`) : o.set(Se, y);
1178
+ }
1179
+ }), e;
1180
+ }, V = (e) => {
1181
+ const o = e.startTimes.map((u) => C({
1182
+ date: e.date ? `${e.date}` : "",
1183
+ dateValue: e.date,
1184
+ pricingOption: e.pricingOptionId,
1185
+ resourceId: e.resourceId,
1186
+ spots: e.spots,
1187
+ startTime: u
1188
+ }));
1189
+ if (o.length !== 0) {
1190
+ if (T.value.length === 1 && ge(T.value[0])) {
1191
+ T.value = o;
1192
+ return;
1193
+ }
1194
+ T.value = [...T.value, ...o];
1195
+ }
1196
+ }, se = (e) => {
1197
+ if (!e || !re.test(e)) return null;
1198
+ const [o, u] = e.split(":").map(Number);
1199
+ return o * 60 + u;
1200
+ }, ke = (e) => {
1201
+ const o = (e % 1440 + 1440) % 1440, u = Math.floor(o / 60), t = o % 60;
1202
+ return `${u.toString().padStart(2, "0")}:${t.toString().padStart(2, "0")}`;
1203
+ }, N = (e) => {
1204
+ if (!e.startTime || !e.pricingOption) return "";
1205
+ const o = fe(e), u = Number(o?.duration);
1206
+ if (!Number.isFinite(u) || u <= 0) return e.startTime;
1207
+ const t = se(e.startTime);
1208
+ return t === null ? "" : ke(t + u);
1209
+ }, n = (e) => {
1210
+ const o = Number(e.spots);
1211
+ return Number.isFinite(o) && o > 0 ? o : 1;
1212
+ }, _ = (e) => {
1213
+ const o = Number(te(e)?.capacity);
1214
+ return Number.isFinite(o) && o > 0 ? o : 1;
1215
+ }, H = (e) => {
1216
+ const o = String(e.date || "").trim(), u = String(e.resourceId || "").trim(), t = se(e.startTime), y = se(N(e));
1217
+ return !o || !u || !te(e) || !fe(e) || t === null || y === null || y <= t ? null : {
1218
+ reservation: e,
1219
+ date: o,
1220
+ resourceId: u,
1221
+ startMinutes: t,
1222
+ endMinutes: y,
1223
+ capacity: _(e),
1224
+ requestedSpots: n(e)
1225
+ };
1226
+ }, ce = (e) => ["approved", "needs_approval"].includes(e?.status), a = (e, o, u, t) => e < t && o > u, s = (e) => `${e} ${e === 1 ? "spot" : "spots"}`, p = (e, o, u) => e < u ? {
1227
+ status: "unavailable",
1228
+ message: `Not enough spots: ${s(Math.max(e, 0))} open, needs ${s(u)}.`
1229
+ } : {
1230
+ status: "available",
1231
+ message: `Available: ${e} of ${o} ${o === 1 ? "spot" : "spots"} open, ${s(e - u)} will remain.`
1232
+ }, S = (e) => e?.id || e?.orderId || "", M = (e, o) => {
1233
+ const u = [];
1234
+ for (let t = 0; t < e.length; t += o)
1235
+ u.push(e.slice(t, t + o));
1236
+ return u;
1237
+ }, ae = async (e) => {
1238
+ const o = /* @__PURE__ */ new Map(), u = [];
1239
+ for (const t of M(e, 10)) {
1240
+ const y = [
1241
+ { field: "status", operator: "==", value: "confirmed" },
1242
+ { field: "flattenedReservationDates", operator: "array-contains-any", value: t }
1243
+ ];
1244
+ F.value && y.unshift({ field: "agendaId", operator: "==", value: F.value });
1245
+ const l = await O.find(Q.reservationsCollection, { filters: y });
1246
+ for (const q of l || []) {
1247
+ const X = S(q);
1248
+ X ? o.set(X, q) : u.push(q);
1249
+ }
1250
+ }
1251
+ return [...o.values(), ...u];
1252
+ }, h = (e, o) => {
1253
+ let u = 0;
1254
+ for (const t of e)
1255
+ for (const y of t?.reservations || []) {
1256
+ if (!ce(y) || y?.date !== o.date || y?.resourceId !== o.resourceId) continue;
1257
+ const l = se(y?.timeslot?.startTime), q = se(y?.timeslot?.endTime);
1258
+ if (l === null || q === null || q <= l || !a(o.startMinutes, o.endMinutes, l, q)) continue;
1259
+ const X = Number(y?.spots);
1260
+ u += Number.isFinite(X) && X > 0 ? X : 1;
1261
+ }
1262
+ return u;
1263
+ }, pe = (e) => {
1264
+ let o = 0;
1265
+ for (const u of T.value) {
1266
+ if (u.id === e.reservation.id) continue;
1267
+ const t = H(u);
1268
+ t && t.date === e.date && t.resourceId === e.resourceId && a(e.startMinutes, e.endMinutes, t.startMinutes, t.endMinutes) && (o += t.requestedSpots);
1269
+ }
1270
+ return o;
1271
+ }, ve = async () => {
1272
+ const e = ++G, o = T.value.map(H).filter((t) => !!t), u = o.reduce((t, y) => (t[y.reservation.id] = {
1273
+ status: "checking",
1274
+ message: "Checking availability..."
1275
+ }, t), {});
1276
+ if (Y.value = u, !$.value || o.length === 0)
1277
+ return u;
1278
+ try {
1279
+ const t = Array.from(new Set(o.map((q) => `${q.resourceId}_${q.date}`))), y = await ae(t);
1280
+ if (e !== G) return null;
1281
+ const l = o.reduce((q, X) => {
1282
+ const R = h(y, X) + pe(X), ee = X.capacity - R;
1283
+ return q[X.reservation.id] = p(
1284
+ ee,
1285
+ X.capacity,
1286
+ X.requestedSpots
1287
+ ), q;
1288
+ }, {});
1289
+ return Y.value = l, l;
1290
+ } catch (t) {
1291
+ if (e !== G) return null;
1292
+ console.error("Error checking new reservation availability:", t);
1293
+ const y = o.reduce((l, q) => (l[q.reservation.id] = {
1294
+ status: "error",
1295
+ message: "Could not check availability for this reservation."
1296
+ }, l), {});
1297
+ return Y.value = y, y;
1298
+ }
1299
+ }, xe = (e) => e ? T.value.flatMap((o, u) => {
1300
+ const t = e[o.id];
1301
+ return t ? t.status === "unavailable" ? [`${ne(u)}: ${t.message}`] : t.status === "error" ? [`${ne(u)}: availability could not be checked.`] : [] : [];
1302
+ }) : ["Could not check availability before creating the reservation."];
1303
+ Re($, async (e) => {
1304
+ e ? (P.value = [], le(), await Le(), ie.value?.reset()) : (G += 1, Y.value = {});
1305
+ }), Re(T, () => {
1306
+ $.value && ve();
1307
+ }, { deep: !0 });
1308
+ const De = () => {
1309
+ const e = [];
1310
+ P.value = [];
1311
+ const o = ie.value, u = o ? o.validateForm() : !1;
1312
+ return o || e.push("Customer information form is unavailable."), T.value.length === 0 && e.push("Please add at least one reservation."), e.push(...v()), P.value = e, e.length === 0 && u;
1313
+ }, Ce = async () => {
1314
+ const e = ie.value;
1315
+ if (!e || !De()) return;
1316
+ const o = await ve(), u = xe(o);
1317
+ if (u.length > 0) {
1318
+ P.value = u;
1319
+ return;
1320
+ }
1321
+ let t = !1;
1322
+ try {
1323
+ A.value = !0;
1324
+ const y = e.getCustomerInfo(), l = T.value.map((R) => {
1325
+ const ee = Number(R.paid) || 0, Te = Number(R.spots) || 1, $e = fe(R), Se = te(R), Ie = R.date;
1326
+ return {
1327
+ paidAmount: ee,
1328
+ flattenedReservationDate: `${R.resourceId}_${Ie}`,
1329
+ flattenedReservation: `${R.resourceId}_${Ie}_${R.startTime.replace(":", "")}`,
1330
+ reservation: {
1331
+ status: "approved",
1332
+ totalPrice: Number(ee.toFixed(2)),
1333
+ basePrice: Number((ee / Te).toFixed(2)),
1334
+ addOnsPrice: 0,
1335
+ addOns: [],
1336
+ date: Ie,
1337
+ id: `res_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1338
+ pricingOption: {
1339
+ duration: $e?.duration || "",
1340
+ id: $e?.id || "",
1341
+ name: $e?.name || "",
1342
+ price: $e?.price || ""
1343
+ },
1344
+ pricingOptionId: R.pricingOption,
1345
+ resource: {
1346
+ avatarLabel: Se?.avatarLabel || "",
1347
+ color: Se?.color || "",
1348
+ description: Se?.description || "",
1349
+ id: Se?.id || "",
1350
+ name: Se?.name || ""
1351
+ },
1352
+ resourceId: R.resourceId,
1353
+ spots: Te,
1354
+ timeslot: {
1355
+ startTime: R.startTime,
1356
+ endTime: N(R)
1357
+ }
1358
+ }
1359
+ };
1360
+ }), q = Number(l.reduce((R, ee) => R + ee.paidAmount, 0).toFixed(2)), X = {
1361
+ agendaId: F.value,
1362
+ customerInfo: y,
1363
+ metadata: {},
1364
+ amountPaid: q,
1365
+ amountDue: 0,
1366
+ subtotal: q,
1367
+ total: q,
1368
+ createdAt: /* @__PURE__ */ new Date(),
1369
+ updatedAt: /* @__PURE__ */ new Date(),
1370
+ discount: 0,
1371
+ flattenedReservationDates: Array.from(new Set(l.map((R) => R.flattenedReservationDate))),
1372
+ flattenedReservations: l.map((R) => R.flattenedReservation),
1373
+ paymentStatus: "paid",
1374
+ paymentType: "full",
1375
+ reservations: l.map((R) => R.reservation),
1376
+ status: "confirmed"
1377
+ };
1378
+ await O.add(Q.reservationsCollection, X), t = !0, ue(`${l.length} ${l.length > 1 ? "reservations" : "reservation"} created in Studio`, {
1379
+ agendaId: F.value,
1380
+ reservationIds: l.map((R) => R.reservation.id),
1381
+ amountPaid: q,
1382
+ reservations: l.map((R) => `${R.reservation.resource.name}: ${R.reservation.date} ${R.reservation.timeslot.startTime}`)
1383
+ });
1384
+ } catch (y) {
1385
+ z("Failed to create reservation in Studio", {
1386
+ error: y instanceof Error ? y.message : String(y),
1387
+ agendaId: F.value
1388
+ }), console.error("Error creating reservation:", y);
1389
+ } finally {
1390
+ A.value = !1, t && ($.value = !1);
1391
+ }
1392
+ };
1393
+ return (e, o) => {
1394
+ const u = b("Button"), t = b("ResponsiveModalTrigger"), y = b("ResponsiveModalTitle"), l = b("ResponsiveModalHeader"), q = b("ResponsiveModalFooter"), X = b("ResponsiveModalScrollContent"), R = b("ResponsiveModal");
1395
+ return i(), he(R, {
1396
+ open: $.value,
1397
+ "onUpdate:open": o[1] || (o[1] = (ee) => $.value = ee)
1398
+ }, {
1399
+ default: d(() => [
1400
+ r(t, { "as-child": "" }, {
1401
+ default: d(() => [
1402
+ r(u, null, {
1403
+ default: d(() => [
1404
+ r(m(Pe), { class: "size-4" }),
1405
+ o[2] || (o[2] = w(" Add Reservation ", -1))
1406
+ ]),
1407
+ _: 1
1408
+ })
1409
+ ]),
1410
+ _: 1
1411
+ }),
1412
+ r(X, { class: "@container/modal sm:max-w-7xl" }, {
1413
+ default: d(() => [
1414
+ r(l, null, {
1415
+ default: d(() => [
1416
+ r(y, null, {
1417
+ default: d(() => [...o[3] || (o[3] = [
1418
+ w("Create new reservation", -1)
1419
+ ])]),
1420
+ _: 1
1421
+ })
1422
+ ]),
1423
+ _: 1
1424
+ }),
1425
+ f("div", hn, [
1426
+ r(mt, {
1427
+ ref_key: "customerInformationRef",
1428
+ ref: ie,
1429
+ agendaData: B.value
1430
+ }, null, 8, ["agendaData"]),
1431
+ o[5] || (o[5] = f("div", { class: "w-full h-[1px] bg-border my-8" }, null, -1)),
1432
+ f("div", bn, [
1433
+ o[4] || (o[4] = f("div", { class: "flex items-center justify-between gap-3" }, [
1434
+ f("h2", { class: "text-sm font-medium" }, "Reservations")
1435
+ ], -1)),
1436
+ r(_n, {
1437
+ modelValue: T.value,
1438
+ "onUpdate:modelValue": o[0] || (o[0] = (ee) => T.value = ee),
1439
+ agendaData: B.value,
1440
+ "availability-by-reservation": Y.value,
1441
+ onAdd: be,
1442
+ onQuickAdd: V
1443
+ }, null, 8, ["modelValue", "agendaData", "availability-by-reservation"])
1444
+ ]),
1445
+ f("div", yn, [
1446
+ f("ul", xn, [
1447
+ (i(!0), c(K, null, me(P.value, (ee) => (i(), c("li", { key: ee }, k(ee), 1))), 128))
1448
+ ])
1449
+ ])
1450
+ ]),
1451
+ r(q, { class: "gap-2" }, {
1452
+ default: d(() => [
1453
+ r(u, {
1454
+ onClick: Ce,
1455
+ disabled: A.value || J.value || g.value
1456
+ }, {
1457
+ default: d(() => [
1458
+ A.value ? (i(), c("span", Sn, "Creating...")) : J.value ? (i(), c("span", kn, "Checking availability...")) : (i(), c("span", $n, k(T.value.length > 1 ? `Create ${T.value.length} reservations` : "Create reservation"), 1))
1459
+ ]),
1460
+ _: 1
1461
+ }, 8, ["disabled"])
1462
+ ]),
1463
+ _: 1
1464
+ })
1465
+ ]),
1466
+ _: 1
1467
+ })
1468
+ ]),
1469
+ _: 1
1470
+ }, 8, ["open"]);
1471
+ };
1472
+ }
1473
+ });
1474
+ export {
1475
+ Nn as _
1476
+ };