@oneclick.dev/cms-core-modules 0.0.117 → 0.0.119

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 (26) hide show
  1. package/dist/{ContentEditor-DWoXc0T_.js → ContentEditor-BnOVpmsQ.js} +36 -36
  2. package/dist/{ContentEditor-CUe6-NwF.mjs → ContentEditor-Cm28u_14.mjs} +3289 -3251
  3. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-BXTkYCm_.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-CcMEKZzd.mjs} +95 -95
  4. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-C2zwt5UF.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-CkFsdcvP.js} +1 -1
  5. package/dist/{TableView-BQI3CWll.mjs → TableView-Ctnep-Qu.mjs} +1174 -1161
  6. package/dist/TableView-DJqyJL9L.js +4 -0
  7. package/dist/agenda-BtmnpFmi.js +1 -0
  8. package/dist/agenda-D0QBOJUy.mjs +1258 -0
  9. package/dist/cms-core-modules.css +1 -1
  10. package/dist/index-BnFWz40Q.mjs +1261 -0
  11. package/dist/index-DcGPR_vt.js +35 -0
  12. package/dist/index.cjs.js +1 -1
  13. package/dist/index.mjs +5 -5
  14. package/dist/{orders-D41GbzIa.mjs → orders-C5NT99Fy.mjs} +82 -82
  15. package/dist/orders-lO3dZ5un.js +1 -0
  16. package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +1 -0
  17. package/dist/src/shims-vue.d.ts +6 -0
  18. package/dist/src/table/components/DataTableAction.vue.d.ts +1 -0
  19. package/dist/src/table/flow-builder-extensions/row-item.d.ts +5 -5
  20. package/package.json +2 -2
  21. package/dist/TableView-Cwal0BPW.js +0 -4
  22. package/dist/agenda-B3nj388v.mjs +0 -1253
  23. package/dist/agenda-Bev1mO7E.js +0 -1
  24. package/dist/index-Djp4EBb0.mjs +0 -1245
  25. package/dist/index-DliTZzwI.js +0 -35
  26. package/dist/orders-1swJVKw2.js +0 -1
@@ -1,1253 +0,0 @@
1
- import { defineComponent as ae, resolveComponent as H, openBlock as s, createElementBlock as i, createElementVNode as e, Fragment as Z, renderList as te, toDisplayString as v, normalizeStyle as se, normalizeClass as q, createVNode as l, withCtx as z, unref as S, createTextVNode as le, createCommentVNode as j, computed as R, ref as C, createBlock as ee, nextTick as ve, provide as ne, onMounted as $e, onUnmounted as Te, inject as de, onBeforeUnmount as ze, watch as ue, useTemplateRef as Ae } from "vue";
2
- import { a as ce, b as me } from "./DateFormatter-BkKoSf_l.mjs";
3
- import { X as De, Search as Ee, Clock as he, Users as xe, ChevronLeft as ge, ChevronRight as fe, Asterisk as Be, CalendarDays as je } from "lucide-vue-next";
4
- import { _ as Pe } from "./EditLayout.vue_vue_type_script_setup_true_lang-pDO9b4Pv.mjs";
5
- import { useModuleRoute as ye, useModule as be, useFirebaseIntegration as _e, useModulePermissions as Oe } from "@oneclick.dev/cms-kit";
6
- import { u as Le, _ as Re, a as Ue, b as Ne, F as Fe } from "./OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs";
7
- import { _ as Ve } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
8
- import { _ as He } from "./NewReservationDialog.vue_vue_type_script_setup_true_lang-BXTkYCm_.mjs";
9
- import { a as Qe } from "./index-hMp4p5qA.mjs";
10
- const We = { class: "mb-6" }, qe = { class: "flex items-end gap-px h-24 bg-muted/30 rounded-lg p-2 overflow-visible" }, Xe = ["onClick"], Ye = { class: "absolute -top-8 left-1/2 -translate-x-1/2 bg-popover border shadow-md rounded px-2 py-1 text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10" }, Je = { class: "font-medium" }, Ke = { class: "text-muted-foreground" }, Ge = { class: "w-full flex-1 flex items-end justify-center" }, Ze = {
11
- key: 1,
12
- class: "text-[10px] mt-1"
13
- }, et = {
14
- key: 0,
15
- class: "mt-2 text-sm text-muted-foreground flex items-center gap-2"
16
- }, tt = { class: "font-medium text-foreground" }, st = { class: "font-medium text-foreground" }, ot = /* @__PURE__ */ ae({
17
- __name: "TimelineChart",
18
- props: {
19
- timeSlots: {},
20
- slotStats: {},
21
- selectedTimeSlot: {},
22
- maxSpots: {}
23
- },
24
- emits: ["select", "clear"],
25
- setup(f, { emit: T }) {
26
- const k = T, A = (o) => {
27
- k("select", o);
28
- }, U = () => {
29
- k("clear");
30
- };
31
- return (o, u) => {
32
- const d = H("Button");
33
- return s(), i("div", We, [
34
- u[2] || (u[2] = e("h3", { class: "font-semibold text-sm mb-2" }, "Timeline", -1)),
35
- e("div", qe, [
36
- (s(!0), i(Z, null, te(f.timeSlots, (a) => (s(), i("div", {
37
- key: a.startTime,
38
- class: "flex-1 min-w-0 flex flex-col items-center cursor-pointer group h-full relative",
39
- onClick: (w) => A(a.startTime)
40
- }, [
41
- e("div", Ye, [
42
- e("div", Je, v(a.startTime), 1),
43
- e("div", Ke, v(f.slotStats[a.startTime]?.spots || 0) + " spots", 1)
44
- ]),
45
- e("div", Ge, [
46
- e("div", {
47
- class: q(["w-full transition-all duration-200", [
48
- f.selectedTimeSlot === a.startTime ? "bg-primary" : f.slotStats[a.startTime]?.spots > 0 ? "bg-primary/60 group-hover:bg-primary/80" : "bg-muted-foreground/20 group-hover:bg-muted-foreground/30"
49
- ]]),
50
- style: se({
51
- height: f.slotStats[a.startTime]?.spots > 0 ? `${f.slotStats[a.startTime].spots / f.maxSpots * 100}%` : "2px",
52
- minHeight: f.slotStats[a.startTime]?.spots > 0 ? "4px" : "2px"
53
- })
54
- }, null, 6)
55
- ]),
56
- a.startTime.endsWith(":00") ? (s(), i("span", {
57
- key: 0,
58
- class: q(["text-[10px] text-muted-foreground mt-1 transition-colors truncate", { "text-primary font-medium": f.selectedTimeSlot === a.startTime }])
59
- }, v(a.label), 3)) : (s(), i("span", Ze, " "))
60
- ], 8, Xe))), 128))
61
- ]),
62
- f.selectedTimeSlot ? (s(), i("div", et, [
63
- l(d, {
64
- variant: "ghost",
65
- size: "icon",
66
- class: "h-6 w-6 p-0",
67
- onClick: U
68
- }, {
69
- default: z(() => [
70
- l(S(De), { size: 14 })
71
- ]),
72
- _: 1
73
- }),
74
- e("span", null, [
75
- u[0] || (u[0] = le(" Showing ", -1)),
76
- e("span", tt, v(f.slotStats[f.selectedTimeSlot]?.bookings || 0), 1),
77
- u[1] || (u[1] = le(" bookings at ", -1)),
78
- e("span", st, v(f.selectedTimeSlot), 1)
79
- ])
80
- ])) : j("", !0)
81
- ]);
82
- };
83
- }
84
- }), at = { class: "flex items-center justify-between mb-3" }, nt = { class: "font-semibold" }, rt = {
85
- key: 0,
86
- class: "text-muted-foreground font-normal"
87
- }, lt = { class: "relative mb-3" }, it = {
88
- key: 0,
89
- class: "flex items-center justify-center py-8"
90
- }, ut = {
91
- key: 1,
92
- class: "text-center py-8 text-muted-foreground"
93
- }, dt = {
94
- key: 2,
95
- class: "space-y-2 max-h-80 overflow-y-auto"
96
- }, ct = ["onClick"], mt = { class: "flex items-start justify-between" }, ft = { class: "flex-1" }, pt = { class: "font-medium" }, vt = { class: "text-sm text-muted-foreground" }, gt = { class: "text-sm text-muted-foreground" }, ht = { class: "flex items-center gap-4" }, xt = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, yt = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, bt = { class: "text-right" }, _t = {
97
- key: 0,
98
- class: "inline-block px-2 py-1 text-xs rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"
99
- }, kt = {
100
- key: 1,
101
- class: "inline-block px-2 py-1 text-xs rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"
102
- }, wt = {
103
- key: 2,
104
- class: "inline-block px-2 py-1 text-xs rounded-full bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
105
- }, St = {
106
- key: 3,
107
- class: "inline-block px-2 py-1 text-xs rounded-full bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
108
- }, $t = {
109
- key: 4,
110
- class: "inline-block px-2 py-1 text-xs rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"
111
- }, Tt = {
112
- key: 5,
113
- class: "text-sm font-medium mt-1"
114
- }, Dt = /* @__PURE__ */ ae({
115
- __name: "BookingsList",
116
- props: {
117
- agendaData: {},
118
- resources: {},
119
- orders: {},
120
- filteredOrders: {},
121
- isLoading: { type: Boolean },
122
- selectedTimeSlot: {},
123
- searchQuery: {}
124
- },
125
- emits: ["update:searchQuery", "refresh"],
126
- setup(f, { emit: T }) {
127
- const k = f, { params: A } = ye(), U = R(() => A.value?.id ?? A.id ?? k.agendaData?.id ?? ""), { metadataSchema: o } = Le(U), u = R(() => {
128
- const y = Array.isArray(k.resources) ? k.resources : [], p = Array.isArray(k.agendaData?.resources) ? k.agendaData.resources : [], E = [...y, ...p], V = /* @__PURE__ */ new Set();
129
- return E.filter((h) => {
130
- const c = h?.id;
131
- return !c || V.has(String(c)) ? !1 : (V.add(String(c)), !0);
132
- });
133
- }), d = T, { config: a } = be(), w = _e(a.project), x = C(null), F = C(null), P = (y) => {
134
- d("update:searchQuery", y);
135
- }, I = () => {
136
- d("update:searchQuery", "");
137
- }, Q = () => {
138
- d("refresh");
139
- }, O = (y, p) => {
140
- const E = y.id || y.orderId || p.orderId || "", V = u.value.find((h) => String(h.id) === String(p.resourceId));
141
- return {
142
- customerInfo: y.customerInfo,
143
- amountDue: y.amountDue,
144
- amountPaid: y.amountPaid,
145
- status: y.status,
146
- reservationStatus: p.status,
147
- subtotal: y.subtotal,
148
- total: y.total,
149
- discount: y.discount,
150
- id: E,
151
- res_id: p.id,
152
- resourceId: p.resourceId,
153
- spots: p.spots,
154
- date: p.date,
155
- createdAt: y.createdAt,
156
- startTime: p.timeslot?.startTime,
157
- endTime: p.timeslot?.endTime,
158
- reservationPrice: p.totalPrice,
159
- reservationBasePrice: p.basePrice,
160
- reservationAddOnsPrice: p.addOnsPrice,
161
- adjustments: y.adjustments || [],
162
- reservationAdjustments: p.adjustments || [],
163
- pricingOptionId: p.pricingOptionId,
164
- pricingOption: p.pricingOption,
165
- resourceName: V?.name,
166
- resourceColor: V?.color,
167
- metadata: y.metadata || {},
168
- reservationMetadata: p.metadata || {},
169
- refundStatus: p.refundStatus,
170
- refundedAt: p.refundedAt,
171
- refundedAmount: p.refundedAmount,
172
- refunds: Array.isArray(p.refunds) ? p.refunds : []
173
- };
174
- }, L = async () => {
175
- await ve(), await new Promise((y) => {
176
- if (typeof requestAnimationFrame == "function") {
177
- requestAnimationFrame(() => y());
178
- return;
179
- }
180
- y();
181
- });
182
- }, W = async (y) => {
183
- if (!y) return;
184
- const p = await w.get(a.reservationsCollection, y);
185
- if (!p) return;
186
- const E = { ...p, id: p.id || y }, V = (E.reservations || []).map((h) => O(E, h));
187
- V.length && (await L(), F.value?.openDialog({
188
- id: E.id,
189
- customerInfo: E.customerInfo,
190
- status: E.status,
191
- createdAt: E.createdAt,
192
- metadata: E.metadata || {},
193
- reservations: V,
194
- adjustments: E.adjustments || [],
195
- totalPrice: typeof E.total == "number" ? E.total : V.reduce((h, c) => h + (c.reservationPrice || 0), 0),
196
- totalSpots: V.reduce((h, c) => h + (c.spots || 0), 0)
197
- }));
198
- }, oe = async (y) => {
199
- await L(), x.value?.openDialog(y);
200
- };
201
- return (y, p) => {
202
- const E = H("Input"), V = H("Button");
203
- return s(), i("div", null, [
204
- e("div", at, [
205
- e("h3", nt, [
206
- p[2] || (p[2] = le(" Bookings ", -1)),
207
- f.selectedTimeSlot || f.searchQuery ? (s(), i("span", rt, " (" + v(f.filteredOrders.length) + " of " + v(f.orders.length) + ") ", 1)) : j("", !0)
208
- ])
209
- ]),
210
- e("div", lt, [
211
- l(S(Ee), {
212
- size: 16,
213
- class: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
214
- }),
215
- l(E, {
216
- "model-value": f.searchQuery,
217
- placeholder: "Search by name, email, or phone...",
218
- class: "pl-9 pr-9",
219
- "onUpdate:modelValue": P
220
- }, null, 8, ["model-value"]),
221
- f.searchQuery ? (s(), ee(V, {
222
- key: 0,
223
- variant: "ghost",
224
- size: "icon",
225
- class: "absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7",
226
- onClick: I
227
- }, {
228
- default: z(() => [
229
- l(S(De), { size: 14 })
230
- ]),
231
- _: 1
232
- })) : j("", !0)
233
- ]),
234
- f.isLoading ? (s(), i("div", it, [...p[3] || (p[3] = [
235
- e("div", { class: "animate-spin rounded-full h-8 w-8 border-b-2 border-primary" }, null, -1)
236
- ])])) : f.filteredOrders.length === 0 ? (s(), i("div", ut, v(f.selectedTimeSlot ? "No bookings for this time slot" : "No bookings for this event"), 1)) : (s(), i("div", dt, [
237
- (s(!0), i(Z, null, te(f.filteredOrders, (h) => (s(), i("div", {
238
- key: h.res_id || h.id,
239
- class: "p-3 border rounded-lg hover:bg-muted/50 transition-colors",
240
- onClick: (c) => x.value?.openDialog(h)
241
- }, [
242
- e("div", mt, [
243
- e("div", ft, [
244
- e("div", pt, v(h.customerInfo.firstName + " " + h.customerInfo.lastName || "Unknown Customer"), 1),
245
- e("div", vt, v(h.customerInfo.email), 1),
246
- e("div", gt, v(h.customerInfo.phone), 1),
247
- e("div", ht, [
248
- e("div", xt, [
249
- l(S(he), { size: 12 }),
250
- e("span", null, v(h.startTime) + " - " + v(h.endTime), 1)
251
- ]),
252
- e("div", yt, [
253
- l(S(xe), { size: 12 }),
254
- e("span", null, v(h.spots), 1)
255
- ])
256
- ]),
257
- l(Re, {
258
- metadata: { ...h.metadata, ...h.reservationMetadata },
259
- schema: S(o),
260
- "display-filter": ["highlight", "badge"],
261
- compact: "",
262
- class: "mt-1"
263
- }, null, 8, ["metadata", "schema"])
264
- ]),
265
- e("div", bt, [
266
- h.reservationStatus === "needs_approval" ? (s(), i("span", _t, "Needs Approval")) : h.reservationStatus === "approved" ? (s(), i("span", kt, "Approved")) : h.reservationStatus === "rejected" ? (s(), i("span", wt, "Rejected")) : h.reservationStatus === "cancelled" ? (s(), i("span", St, "Cancelled")) : (s(), i("span", $t, "Pending")),
267
- h.reservationPrice || h.reservationPrice === 0 ? (s(), i("div", Tt, " €" + v(h.reservationPrice.toFixed(2)), 1)) : j("", !0)
268
- ])
269
- ])
270
- ], 8, ct))), 128))
271
- ])),
272
- l(Ue, {
273
- ref_key: "reservationDetailDialog",
274
- ref: x,
275
- "agenda-data": f.agendaData,
276
- resources: f.resources,
277
- "show-order-link": "",
278
- onCancelled: Q,
279
- onConfirmed: Q,
280
- onRejected: Q,
281
- onTransferred: Q,
282
- onOpenOrder: p[0] || (p[0] = (h) => W(h))
283
- }, null, 8, ["agenda-data", "resources"]),
284
- l(Ne, {
285
- ref_key: "orderDetailDialog",
286
- ref: F,
287
- "agenda-data": f.agendaData,
288
- resources: f.resources,
289
- onOpenReservation: p[1] || (p[1] = (h) => oe(h))
290
- }, null, 8, ["agenda-data", "resources"])
291
- ]);
292
- };
293
- }
294
- }), Ct = { class: "flex items-center gap-4 mt-2 text-sm" }, It = { class: "flex items-center gap-1" }, Mt = {
295
- key: 0,
296
- class: "flex items-center gap-1"
297
- }, zt = { class: "flex items-center gap-1" }, At = { class: "py-4" }, Et = /* @__PURE__ */ ae({
298
- __name: "EventDialog",
299
- props: {
300
- agendaData: {},
301
- resources: { default: () => [] }
302
- },
303
- setup(f, { expose: T }) {
304
- const k = f, { config: A } = be(), { params: U } = ye(), o = _e(A.project), u = C(!1), d = C(null), a = C([]), w = C(!1), x = C(null), F = C("");
305
- ne("event", d);
306
- const P = R(() => {
307
- if (!d.value) return [];
308
- const c = d.value.resource?.interval || 60, t = [], [m, M] = d.value.startTime.split(":").map(Number), [J, Y] = d.value.endTime.split(":").map(Number), D = m * 60 + M, $ = J * 60 + Y;
309
- for (let b = D; b < $; b += c) {
310
- const r = Math.floor(b / 60), g = b % 60, B = Math.min(b + c, $), _ = Math.floor(B / 60), N = B % 60, X = `${r.toString().padStart(2, "0")}:${g.toString().padStart(2, "0")}`, n = `${_.toString().padStart(2, "0")}:${N.toString().padStart(2, "0")}`;
311
- t.push({
312
- startTime: X,
313
- endTime: n,
314
- label: X
315
- });
316
- }
317
- return t;
318
- }), I = (c) => {
319
- const t = c.getFullYear(), m = String(c.getMonth() + 1).padStart(2, "0"), M = String(c.getDate()).padStart(2, "0");
320
- return `${t}-${m}-${M}`;
321
- }, Q = R(() => {
322
- const c = {};
323
- return P.value.forEach((t) => {
324
- c[t.startTime] = { bookings: 0, spots: 0, orders: [] };
325
- }), a.value.forEach((t) => {
326
- P.value.forEach((m) => {
327
- t.startTime < m.endTime && t.endTime > m.startTime && (c[m.startTime].bookings++, c[m.startTime].spots += t.spots || 0, c[m.startTime].orders.push(t));
328
- });
329
- }), c;
330
- }), O = R(() => Math.max(1, ...Object.values(Q.value).map((c) => c.spots))), L = R(() => {
331
- let c = a.value;
332
- return x.value && (c = Q.value[x.value]?.orders || []), F.value.trim() && (c = new Fe(c, {
333
- keys: [
334
- "customerInfo.firstName",
335
- "customerInfo.lastName",
336
- "customerInfo.email",
337
- "customerInfo.phone"
338
- ],
339
- threshold: 0.3,
340
- ignoreLocation: !0
341
- }).search(F.value).map((m) => m.item)), c;
342
- }), W = R(() => ({
343
- spots: a.value.reduce((c, t) => c + (t.spots || 0), 0),
344
- bookings: a.value.length
345
- })), oe = (c) => {
346
- x.value === c ? x.value = null : x.value = c;
347
- }, y = () => {
348
- x.value = null;
349
- }, p = async (c) => {
350
- u.value = !0, d.value = c, x.value = null, F.value = "", await E();
351
- }, E = async () => {
352
- if (d.value) {
353
- w.value = !0, a.value = [];
354
- try {
355
- const c = U.value.id, t = I(new Date(d.value.date)), m = d.value.resourceId || d.value.resource?.id, M = /* @__PURE__ */ new Set();
356
- if (m ? M.add(`${m}_${t}`) : k.resources?.forEach((D) => {
357
- M.add(`${D.id}_${t}`);
358
- }), M.size === 0) {
359
- a.value = [];
360
- return;
361
- }
362
- const J = await o.find(A.reservationsCollection, {
363
- filters: [
364
- { field: "agendaId", operator: "==", value: c },
365
- { field: "status", operator: "==", value: "confirmed" },
366
- { field: "flattenedReservationDates", operator: "array-contains-any", value: Array.from(M) }
367
- ]
368
- });
369
- let Y = [];
370
- J.forEach((D) => {
371
- (D.reservations?.filter((b) => b.date !== t ? !1 : m ? b.resourceId === m : !0) || []).forEach((b) => {
372
- const r = k.resources.find((B) => B.id === b.resourceId), g = D.id || D.orderId || b.orderId || "";
373
- (b.status === "approved" || b.status === "needs_approval") && Y.push({
374
- customerInfo: D.customerInfo,
375
- amountDue: D.amountDue,
376
- amountPaid: D.amountPaid,
377
- status: D.status,
378
- reservationStatus: b.status,
379
- subtotal: D.subtotal,
380
- total: D.total,
381
- discount: D.discount,
382
- id: g,
383
- res_id: b.id,
384
- resourceId: b.resourceId,
385
- spots: b.spots,
386
- date: t,
387
- createdAt: D.createdAt,
388
- startTime: b.timeslot?.startTime,
389
- endTime: b.timeslot?.endTime,
390
- reservationPrice: b.totalPrice,
391
- reservationBasePrice: b.basePrice,
392
- reservationAddOnsPrice: b.addOnsPrice,
393
- adjustments: D.adjustments || [],
394
- reservationAdjustments: b.adjustments || [],
395
- pricingOptionId: b.pricingOptionId,
396
- pricingOption: b.pricingOption,
397
- resourceName: r?.name,
398
- resourceColor: r?.color,
399
- metadata: D.metadata || {},
400
- reservationMetadata: b.metadata || {},
401
- refundStatus: b.refundStatus,
402
- refundedAt: b.refundedAt,
403
- refundedAmount: b.refundedAmount,
404
- refunds: Array.isArray(b.refunds) ? b.refunds : []
405
- });
406
- });
407
- }), a.value = Y.sort((D, $) => D.startTime?.localeCompare($.startTime || "") || 0);
408
- } catch (c) {
409
- console.error("Error loading orders:", c), a.value = [];
410
- } finally {
411
- w.value = !1;
412
- }
413
- }
414
- }, V = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], h = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
415
- return T({
416
- openDialog: p
417
- }), (c, t) => {
418
- const m = H("DialogTitle"), M = H("DialogDescription"), J = H("DialogHeader"), Y = H("Button"), D = H("DialogFooter"), $ = H("DialogScrollContent"), b = H("Dialog");
419
- return s(), ee(b, {
420
- open: u.value,
421
- "onUpdate:open": t[2] || (t[2] = (r) => u.value = r)
422
- }, {
423
- default: z(() => [
424
- l($, { class: "sm:max-w-3xl" }, {
425
- default: z(() => [
426
- l(J, null, {
427
- default: z(() => [
428
- d.value?.date ? (s(), ee(m, { key: 0 }, {
429
- default: z(() => [
430
- le(v(V[new Date(d.value.date).getUTCDay()]) + " " + v(h[new Date(d.value.date).getUTCMonth()]) + " " + v(new Date(d.value.date).getUTCDate()) + ", " + v(new Date(d.value.date).getUTCFullYear()), 1)
431
- ]),
432
- _: 1
433
- })) : j("", !0),
434
- l(M, null, {
435
- default: z(() => [
436
- e("div", Ct, [
437
- e("div", It, [
438
- l(S(he), { size: 14 }),
439
- e("span", null, v(d.value?.startTime) + " – " + v(d.value?.endTime), 1)
440
- ]),
441
- d.value?.resource ? (s(), i("div", Mt, [
442
- e("div", {
443
- class: "w-4 h-4 rounded-full",
444
- style: se({ backgroundColor: d.value.resource.color || "#6b7280" })
445
- }, null, 4),
446
- e("span", null, v(d.value.resource.name), 1)
447
- ])) : j("", !0),
448
- e("div", zt, [
449
- l(S(xe), { size: 14 }),
450
- e("span", null, v(W.value.spots) + " spots in " + v(W.value.bookings) + " reservations", 1)
451
- ])
452
- ])
453
- ]),
454
- _: 1
455
- })
456
- ]),
457
- _: 1
458
- }),
459
- e("div", At, [
460
- P.value.length > 1 ? (s(), ee(ot, {
461
- key: 0,
462
- "time-slots": P.value,
463
- "slot-stats": Q.value,
464
- "selected-time-slot": x.value,
465
- "max-spots": O.value,
466
- onSelect: oe,
467
- onClear: y,
468
- tabindex: "0"
469
- }, null, 8, ["time-slots", "slot-stats", "selected-time-slot", "max-spots"])) : j("", !0),
470
- l(Dt, {
471
- "agenda-data": f.agendaData,
472
- resources: f.resources,
473
- orders: a.value,
474
- "filtered-orders": L.value,
475
- "is-loading": w.value,
476
- "selected-time-slot": x.value,
477
- "search-query": F.value,
478
- "onUpdate:searchQuery": t[0] || (t[0] = (r) => F.value = r),
479
- onRefresh: E
480
- }, null, 8, ["agenda-data", "resources", "orders", "filtered-orders", "is-loading", "selected-time-slot", "search-query"])
481
- ]),
482
- l(D, null, {
483
- default: z(() => [
484
- l(Y, {
485
- variant: "outline",
486
- onClick: t[1] || (t[1] = (r) => u.value = !1)
487
- }, {
488
- default: z(() => [...t[3] || (t[3] = [
489
- le("Close", -1)
490
- ])]),
491
- _: 1
492
- })
493
- ]),
494
- _: 1
495
- })
496
- ]),
497
- _: 1
498
- })
499
- ]),
500
- _: 1
501
- }, 8, ["open"]);
502
- };
503
- }
504
- }), Bt = { class: "flex-1 border-r shadow-sm overflow-hidden min-h-[1536px]" }, jt = { class: "relative h-full min-h-[1536px]" }, Pt = { class: "divide-y divide-input/80 h-full flex flex-col min-h-[1536px] border-y border-input/80" }, Ot = { class: "absolute inset-0 pointer-events-none" }, Lt = { class: "relative mr-1 @md:mr-3 h-full ml-0.5 @md:ml-2" }, Rt = ["onClick"], Ut = {
505
- key: 0,
506
- class: "absolute bottom-0 left-0 right-0 h-1 bg-black/20"
507
- }, Nt = { class: "flex items-start justify-between gap-2 mb-1" }, Ft = { class: "font-semibold text-xs @md:text-sm leading-tight line-clamp-1 flex-1" }, Vt = { class: "flex items-center gap-1 shrink-0" }, Ht = ["title"], Qt = { class: "font-medium" }, ke = /* @__PURE__ */ ae({
508
- __name: "EventTimeline",
509
- props: {
510
- agendaData: {},
511
- date: {},
512
- events: {},
513
- firstDay: { type: Boolean, default: !1 },
514
- resources: { default: () => [] }
515
- },
516
- setup(f) {
517
- const T = f, k = C(null), A = (u) => {
518
- const [d, a] = u.split(":").map(Number);
519
- return d * 60 + a;
520
- };
521
- R(() => !T.events || !T.resources ? [] : T.resources.map((u) => {
522
- const a = T.events.filter((w) => w.resourceId === u.id).map((w) => {
523
- const x = A(w.startTime), P = A(w.endTime) - x, I = x / 1440 * 100, Q = P / 1440 * 100, O = (w.bookings ?? 0) > 0, L = w.maxBookings ? (w.bookings ?? 0) / w.maxBookings * 100 : 0;
524
- return {
525
- ...w,
526
- top: `${I}%`,
527
- height: `${Q}%`,
528
- color: w.resource?.color || "#3b82f6",
529
- hasBookings: O,
530
- fillPercentage: L,
531
- isSmall: P < 60
532
- };
533
- });
534
- return {
535
- resource: u,
536
- events: a
537
- };
538
- }));
539
- const U = R(() => T.events ? T.events.map((u) => {
540
- const d = A(u.startTime), w = A(u.endTime) - d, x = d / 1440 * 100, F = w / 1440 * 100, P = (u.bookings ?? 0) > 0, I = u.maxBookings ? (u.bookings ?? 0) / u.maxBookings * 100 : 0;
541
- return {
542
- ...u,
543
- top: `${x}%`,
544
- height: `${F}%`,
545
- color: u.resource?.color || "#3b82f6",
546
- hasBookings: P,
547
- fillPercentage: I,
548
- isSmall: w < 60
549
- };
550
- }) : []), o = Array.from({ length: 24 }, (u, d) => ({
551
- hour: d,
552
- label: `${d.toString().padStart(2, "0")}:00`
553
- }));
554
- return (u, d) => (s(), i(Z, null, [
555
- e("div", Bt, [
556
- e("div", jt, [
557
- e("div", Pt, [
558
- (s(!0), i(Z, null, te(S(o), (a) => (s(), i("div", {
559
- key: a.hour,
560
- class: "flex-1 flex transition-all duration-200"
561
- }, [...d[0] || (d[0] = [
562
- e("div", { class: "flex-1 relative" }, [
563
- e("div", { class: "absolute top-1/2 left-0 right-0 border-t border-dashed border-input/50" })
564
- ], -1)
565
- ])]))), 128))
566
- ]),
567
- e("div", Ot, [
568
- e("div", Lt, [
569
- (s(!0), i(Z, null, te(U.value, (a) => (s(), i("div", {
570
- key: a.id,
571
- style: se({
572
- top: a.top,
573
- height: a.height,
574
- opacity: a.hasBookings ? "1" : "0.5"
575
- }),
576
- class: "event-card absolute left-0.5 right-0.5 @md:left-2 @md:right-2 rounded-lg pointer-events-auto cursor-pointer group/event transition-all duration-200 hover:shadow-xl overflow-hidden",
577
- onClick: (w) => k.value?.openDialog(a)
578
- }, [
579
- e("div", {
580
- style: se({ backgroundColor: a.color }),
581
- class: "absolute inset-0 shadow-lg"
582
- }, [
583
- a.maxBookings ? (s(), i("div", Ut, [
584
- e("div", {
585
- class: "h-full bg-white/40 transition-all duration-300",
586
- style: se({ width: `${a.fillPercentage}%` })
587
- }, null, 4)
588
- ])) : j("", !0)
589
- ], 4),
590
- e("div", {
591
- class: q(["relative h-full p-1.5 @md:p-3 flex flex-col", `${a.hasBookings ? "text-white" : "text-gray-600 dark:text-gray-100"}`])
592
- }, [
593
- e("div", Nt, [
594
- e("h3", Ft, v(a.title), 1),
595
- e("div", Vt, [
596
- a.resource ? (s(), i("div", {
597
- key: 0,
598
- class: "w-5 h-5 @md:w-6 @md:h-6 rounded-full flex items-center justify-center text-[10px] @md:text-xs font-bold bg-white/30 backdrop-blur-sm text-white border border-white/40",
599
- title: a.resource.name
600
- }, v(a.resource.avatarLabel || a.resource.name.charAt(0).toUpperCase()), 9, Ht)) : j("", !0),
601
- e("div", {
602
- class: q([
603
- "flex items-center gap-0.5 @md:gap-1 px-1.5 @md:px-2 py-0.5 rounded-full text-[10px] @md:text-xs font-medium",
604
- a.hasBookings ? "bg-white text-black backdrop-blur-sm" : "bg-black/10 backdrop-blur-sm"
605
- ])
606
- }, [
607
- l(S(xe), { size: 12 }),
608
- e("span", null, v(a.bookings), 1)
609
- ], 2)
610
- ])
611
- ]),
612
- e("div", {
613
- class: q(["flex items-center gap-1 @md:gap-2 text-[10px] @md:text-xs opacity-90 mt-auto", { "-translate-x-1 -translate-y-2 scale-80 origin-[0_0]": a.isSmall }])
614
- }, [
615
- e("div", {
616
- class: q(["flex items-center gap-1 px-1 @md:px-2 py-0.5 rounded backdrop-blur-sm", { "bg-black/10": !a.isSmall }])
617
- }, [
618
- l(S(he), { size: 10 }),
619
- e("span", Qt, v(a.startTime) + " – " + v(a.endTime), 1)
620
- ], 2)
621
- ], 2)
622
- ], 2),
623
- d[1] || (d[1] = e("div", { class: "absolute inset-0 border-2 border-white/0 group-hover/event:border-white/30 rounded-lg transition-colors duration-200 pointer-events-none" }, null, -1))
624
- ], 12, Rt))), 128))
625
- ])
626
- ])
627
- ])
628
- ]),
629
- l(Et, {
630
- "agenda-data": f.agendaData,
631
- resources: f.resources,
632
- ref_key: "eventDialog",
633
- ref: k
634
- }, null, 8, ["agenda-data", "resources"])
635
- ], 64));
636
- }
637
- }), Wt = { class: "sticky left-0 mt-auto z-10 divide-y divide-border/50 h-full flex flex-col min-h-[1536px] bg-input" }, qt = { class: "flex-shrink-0 text-[10px] @md:text-xs font-medium text-muted-foreground px-1.5 @md:px-3 pb-3 border-r border-border/50 w-10 @md:w-14" }, Xt = { class: "flex items-center gap-1.5" }, we = /* @__PURE__ */ ae({
638
- __name: "Event24hSidebar",
639
- setup(f) {
640
- const T = Array.from({ length: 24 }, (k, A) => ({
641
- hour: A,
642
- label: `${A.toString().padStart(2, "0")}:00`
643
- }));
644
- return (k, A) => (s(), i("div", Wt, [
645
- (s(!0), i(Z, null, te(S(T), (U) => (s(), i("div", {
646
- key: U.hour,
647
- class: "flex-1 flex transition-all duration-200"
648
- }, [
649
- e("div", qt, [
650
- e("div", Xt, [
651
- e("span", {
652
- class: q({ "-translate-y-1/2": U.hour !== 0 })
653
- }, v(U.label), 3)
654
- ])
655
- ])
656
- ]))), 128))
657
- ]));
658
- }
659
- }), Yt = { class: "absolute top-0 w-full pointer-events-none" }, Jt = {
660
- key: 0,
661
- class: "absolute -right-2 -top-0.5 px-2 py-0.5 bg-red-500 text-white text-xs font-medium rounded shadow-lg"
662
- }, Se = /* @__PURE__ */ ae({
663
- __name: "EventTimeIndicator",
664
- props: {
665
- currentDate: {
666
- type: Object,
667
- required: !1
668
- }
669
- },
670
- setup(f) {
671
- const T = C(Date.now());
672
- let k;
673
- $e(() => {
674
- k = window.setInterval(() => {
675
- T.value = Date.now();
676
- }, 1e3);
677
- }), Te(() => {
678
- k && clearInterval(k);
679
- });
680
- const A = R(() => {
681
- const o = new Date(T.value);
682
- return `${(o.getHours() * 60 + o.getMinutes() + o.getSeconds() / 60) / 1440 * 100}%`;
683
- }), U = R(() => new Date(T.value).getFullYear() + "-" + (new Date(T.value).getMonth() + 1).toString().padStart(2, "0") + "-" + new Date(T.value).getDate().toString().padStart(2, "0"));
684
- return (o, u) => (s(), i("div", Yt, [
685
- e("div", {
686
- class: "absolute left-0 right-0 h-0.5 bg-red-500 z-30 pointer-events-none transition-[top] duration-300 ease-linear",
687
- style: se({ top: A.value })
688
- }, [
689
- u[0] || (u[0] = e("div", { class: "absolute -left-2 -top-1.5 w-3 h-3 bg-red-500 rounded-full shadow-lg shadow-red-500/50" }, null, -1)),
690
- f.currentDate && f.currentDate == U.value ? (s(), i("div", Jt, " Now ")) : j("", !0)
691
- ], 4)
692
- ]));
693
- }
694
- }), Kt = {
695
- key: 0,
696
- class: "relative flex flex-1 min-w-0"
697
- }, Gt = {
698
- key: 1,
699
- class: "flex-1 min-w-0 relative min-h-[1616px] @md:min-h-[1658px]"
700
- }, Zt = {
701
- key: 0,
702
- class: "absolute top-0 right-0 z-10 px-3 py-1.5 bg-primary/90 text-primary-foreground text-xs font-medium rounded-bl-lg shadow-lg backdrop-blur-sm flex items-center gap-1.5 animate-pulse-subtle"
703
- }, es = { class: "flex pb-4 min-w-[200px]" }, ts = ["onClick"], ss = {
704
- key: 0,
705
- class: "absolute top-2 right-2 flex items-center gap-1 px-2 py-0.5 bg-primary/20 backdrop-blur-sm rounded-full border border-primary/30"
706
- }, os = { class: "text-xs text-muted-foreground font-medium group-hover:text-foreground/70 transition-colors" }, as = {
707
- key: 0,
708
- class: "absolute bottom-0 left-0 w-full h-1 bg-orange-500"
709
- }, ns = /* @__PURE__ */ ae({
710
- __name: "EventView",
711
- props: {
712
- agendaData: { default: () => ({}) }
713
- },
714
- setup(f) {
715
- const T = de("activeDate", C(ce(me()))), k = de("viewMode", C(1)), A = de("events", C([])), U = de("resources", C([])), o = C(null), u = C(!1), d = C(!1);
716
- R(() => U.value.length > 1);
717
- const a = R(() => {
718
- const t = [], m = T.value;
719
- for (let M = 0; M < k.value; M++)
720
- t.push(m.add({ days: M }));
721
- return t;
722
- }), w = (t, m) => {
723
- const M = `${t.year}-${String(t.month).padStart(2, "0")}-${String(t.day).padStart(2, "0")}`;
724
- return A.value?.filter((J) => J.date === M) || [];
725
- }, x = (t) => {
726
- const m = ce(me());
727
- return t.year === m.year && t.month === m.month && t.day === m.day;
728
- }, F = (t) => {
729
- T.value = t, k.value = 1;
730
- };
731
- let P = null, I = null;
732
- const Q = () => {
733
- o.value && (L(), o.value.scrollBy({ left: -300, behavior: "smooth" }), I = window.setTimeout(() => {
734
- P = window.setInterval(() => {
735
- o.value && o.value.scrollBy({ left: -20, behavior: "auto" });
736
- }, 50);
737
- }, 300));
738
- }, O = () => {
739
- o.value && (L(), o.value.scrollBy({ left: 300, behavior: "smooth" }), I = window.setTimeout(() => {
740
- P = window.setInterval(() => {
741
- o.value && o.value.scrollBy({ left: 20, behavior: "auto" });
742
- }, 50);
743
- }, 300));
744
- }, L = () => {
745
- I && (clearTimeout(I), I = null), P && (clearInterval(P), P = null);
746
- }, W = () => {
747
- if (!o.value) return;
748
- const { scrollLeft: t, scrollWidth: m, clientWidth: M } = o.value;
749
- u.value = t > 10, d.value = t < m - M - 10;
750
- }, oe = (t) => {
751
- o.value && Math.abs(t.deltaY) > Math.abs(t.deltaX) && (t.preventDefault(), o.value.scrollBy({ left: t.deltaY, behavior: "auto" }));
752
- }, y = C(!1), p = C(0), E = C(0), V = (t) => {
753
- !o.value || k.value === 1 || t.target.closest(".event-card") || (y.value = !0, p.value = t.pageX, E.value = o.value.scrollLeft, o.value.style.userSelect = "none", t.preventDefault());
754
- }, h = (t) => {
755
- if (!y.value || !o.value) return;
756
- const m = t.pageX, M = (p.value - m) * 1.2;
757
- o.value.scrollLeft = E.value + M;
758
- }, c = () => {
759
- o.value && (y.value = !1, o.value.style.userSelect = "");
760
- };
761
- return $e(() => {
762
- o.value && (o.value.addEventListener("scroll", W), o.value.addEventListener("wheel", oe, { passive: !1 }), ve(() => {
763
- W(), setTimeout(W, 50), setTimeout(W, 150), setTimeout(W, 300), setTimeout(W, 500);
764
- })), document.addEventListener("mousemove", h), document.addEventListener("mouseup", c);
765
- }), ze(() => {
766
- document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
767
- }), ue(k, () => {
768
- k.value > 1 ? ve(() => {
769
- setTimeout(() => {
770
- if (!o.value) return;
771
- const { scrollWidth: t, clientWidth: m } = o.value;
772
- t > m && (d.value = !0, u.value = !1);
773
- }, 100);
774
- }) : o.value && (o.value.style.cursor = "");
775
- }), Te(() => {
776
- L(), o.value && (o.value.removeEventListener("scroll", W), o.value.removeEventListener("wheel", oe));
777
- }), (t, m) => {
778
- const M = H("Button"), J = H("TooltipTrigger"), Y = H("TooltipContent"), D = H("Tooltip");
779
- return S(k) === 1 ? (s(), i("div", Kt, [
780
- l(we),
781
- l(Se, {
782
- class: "h-full",
783
- "current-date": S(T)
784
- }, null, 8, ["current-date"]),
785
- l(ke, {
786
- "agenda-data": f.agendaData,
787
- date: S(T),
788
- events: w(S(T)),
789
- resources: S(U)
790
- }, null, 8, ["agenda-data", "date", "events", "resources"])
791
- ])) : (s(), i("div", Gt, [
792
- S(k) === 7 ? (s(), i("div", Zt, [
793
- l(S(ge), { size: 12 }),
794
- m[0] || (m[0] = e("span", null, "Scroll to view all days", -1)),
795
- l(S(fe), { size: 12 })
796
- ])) : j("", !0),
797
- u.value ? (s(), ee(M, {
798
- key: 1,
799
- variant: "outline",
800
- size: "icon",
801
- onMousedown: Q,
802
- onMouseup: L,
803
- onMouseleave: L,
804
- onTouchstart: Q,
805
- onTouchend: L,
806
- class: "sticky top-1/2 left-2 -translate-y-1/2 z-40 h-10 w-10 rounded-full shadow-lg bg-background/95 backdrop-blur-sm hover:bg-background border-2"
807
- }, {
808
- default: z(() => [
809
- l(S(ge), { size: 20 })
810
- ]),
811
- _: 1
812
- })) : j("", !0),
813
- d.value ? (s(), ee(M, {
814
- key: 2,
815
- variant: "outline",
816
- size: "icon",
817
- onMousedown: O,
818
- onMouseup: L,
819
- onMouseleave: L,
820
- onTouchstart: O,
821
- onTouchend: L,
822
- class: "sticky top-1/2 right-2 -translate-y-1/2 z-40 h-10 w-10 rounded-full shadow-lg bg-background/95 backdrop-blur-sm hover:bg-background border-2 float-right"
823
- }, {
824
- default: z(() => [
825
- l(S(fe), { size: 20 })
826
- ]),
827
- _: 1
828
- })) : j("", !0),
829
- l(Se, { class: "h-[calc(100%-122px)] mt-[80px] @md:h-[calc(100%-164px)] @md:mt-[122px]" }),
830
- e("div", {
831
- class: q(["absolute right-0 top-0 bottom-0 w-8 bg-gradient-to-l from-background to-transparent z-10 pointer-events-none transition-opacity duration-300", d.value ? "opacity-100" : "opacity-0"])
832
- }, null, 2),
833
- e("div", {
834
- ref_key: "scrollContainer",
835
- ref: o,
836
- class: "absolute inset-0 overflow-x-auto overflow-y-hidden",
837
- onScroll: W,
838
- onMousedown: V
839
- }, [
840
- e("div", es, [
841
- l(we),
842
- m[5] || (m[5] = e("div", { class: "absolute w-10 @md:w-14 h-[125px] bg-input" }, null, -1)),
843
- (s(!0), i(Z, null, te(a.value, ($, b) => (s(), i("div", {
844
- key: $.toString(),
845
- class: q(["flex-shrink-0", { "min-w-[200px] w-[33.33%]": S(k) === 3, "min-w-[280px]": S(k) === 7 }])
846
- }, [
847
- e("div", {
848
- onClick: (r) => F($),
849
- class: q([
850
- "relative p-3 border cursor-pointer transition-all duration-200 group relative",
851
- x($) ? "bg-gradient-to-br from-primary/10 to-primary/5 border-primary/30 hover:from-primary/20 hover:to-primary/10 hover:border-primary/50 hover:shadow-md" : "bg-gradient-to-br from-muted/50 to-muted/30 border-border hover:from-accent/50 hover:to-accent/30 hover:border-accent-foreground/20 hover:shadow-md"
852
- ])
853
- }, [
854
- x($) ? (s(), i("div", ss, [...m[1] || (m[1] = [
855
- e("div", { class: "w-1.5 h-1.5 bg-primary rounded-full animate-pulse" }, null, -1),
856
- e("span", { class: "text-[9px] font-bold text-primary uppercase tracking-wide" }, "Today", -1)
857
- ])])) : j("", !0),
858
- e("div", {
859
- class: q([
860
- "text-xs font-semibold uppercase tracking-wider transition-colors",
861
- x($) ? "text-primary group-hover:text-primary/80" : "text-muted-foreground group-hover:text-foreground"
862
- ])
863
- }, v(new Date($.year, $.month - 1, $.day).toLocaleDateString("en-US", { weekday: "short" })), 3),
864
- e("div", {
865
- class: q([
866
- "text-2xl font-bold transition-colors",
867
- x($) ? "text-foreground" : "text-foreground group-hover:text-primary"
868
- ])
869
- }, v($.day), 3),
870
- e("div", os, v(new Date($.year, $.month - 1, $.day).toLocaleDateString("en-US", { month: "long", year: "numeric" })), 1),
871
- m[4] || (m[4] = e("div", { class: "mt-2 pt-2 border-t border-border/0 group-hover:border-border/50 transition-all" }, [
872
- e("div", { class: "text-[10px] text-muted-foreground/0 group-hover:text-muted-foreground/100 uppercase tracking-wide transition-all" }, " Click to view ")
873
- ], -1)),
874
- l(D, null, {
875
- default: z(() => [
876
- l(J, { "as-child": "" }, {
877
- default: z(() => [
878
- w($).filter((r) => r.isException).length > 0 ? (s(), ee(S(Be), {
879
- key: 0,
880
- class: "absolute top-3 right-3 size-4 text-orange-500"
881
- })) : j("", !0)
882
- ]),
883
- _: 2
884
- }, 1024),
885
- l(Y, null, {
886
- default: z(() => [...m[2] || (m[2] = [
887
- e("p", null, " This day has exceptions applied to it. ", -1)
888
- ])]),
889
- _: 1
890
- })
891
- ]),
892
- _: 2
893
- }, 1024),
894
- l(D, null, {
895
- default: z(() => [
896
- l(J, { "as-child": "" }, {
897
- default: z(() => [
898
- w($).filter((r) => r.isException).length > 0 ? (s(), i("div", as)) : j("", !0)
899
- ]),
900
- _: 2
901
- }, 1024),
902
- l(Y, null, {
903
- default: z(() => [...m[3] || (m[3] = [
904
- e("p", null, " This day has exceptions applied to it. ", -1)
905
- ])]),
906
- _: 1
907
- })
908
- ]),
909
- _: 2
910
- }, 1024)
911
- ], 10, ts),
912
- l(ke, {
913
- "agenda-data": f.agendaData,
914
- date: $,
915
- events: w($),
916
- resources: S(U)
917
- }, null, 8, ["agenda-data", "date", "events", "resources"])
918
- ], 2))), 128))
919
- ])
920
- ], 544)
921
- ]));
922
- };
923
- }
924
- }), rs = /* @__PURE__ */ Ve(ns, [["__scopeId", "data-v-f5d39ef7"]]), ls = { class: "flex items-center justify-between @sm:justify-start gap-4" }, is = { class: "flex flex-col" }, us = { class: "flex items-center gap-2" }, ds = { class: "text-lg @sm:text-2xl font-bold tracking-tight truncate" }, cs = { class: "text-xs @sm:text-sm text-muted-foreground ml-7 truncate" }, ms = { class: "flex @sm:items-center justify-between flex-col @sm:flex-row @5xl:justify-end gap-2" }, fs = { class: "flex items-center gap-1 @5xl:mr-2" }, ps = {
925
- key: 0,
926
- class: "flex items-center gap-2 px-1 overflow-x-auto pb-2 -mx-1 scrollbar-hide"
927
- }, vs = ["onClick"], gs = { class: "flex gap-2 @md:gap-4" }, hs = { class: "hidden @md:flex flex-shrink-0 flex-col gap-4" }, xs = {
928
- key: 0,
929
- class: "rounded-md border p-3"
930
- }, ys = { class: "space-y-1" }, bs = ["onClick"], _s = { class: "min-w-0 flex-1" }, ks = { class: "text-sm font-medium truncate" }, ws = {
931
- key: 0,
932
- class: "pt-2 mt-2 border-t"
933
- }, Ss = {
934
- key: 0,
935
- class: "mt-1 space-y-1"
936
- }, $s = { class: "min-w-0 flex-1" }, Ts = { class: "text-sm font-medium truncate text-muted-foreground" }, Ps = /* @__PURE__ */ ae({
937
- __name: "agenda",
938
- setup(f) {
939
- const { hasPermission: T } = Oe(), { params: k } = ye(), { config: A } = be(), U = _e(A.project), o = C(ce(me())), u = C(1), d = Ae("container"), { width: a } = Qe(d), w = R(() => a.value < 640);
940
- ue(w, (r) => {
941
- r && u.value !== 1 && (u.value = 1);
942
- }, { immediate: !0 });
943
- const x = C(null), F = C(/* @__PURE__ */ new Map()), P = R(() => x.value?.resources || []), I = R(() => P.value.filter((r) => r.isActive)), Q = R(() => P.value.filter((r) => !r.isActive)), O = C(null), L = C(!1);
944
- ue(I, (r) => {
945
- r.length > 0 && !O.value && (O.value = r[0].id);
946
- }, { immediate: !0 });
947
- const W = R(() => {
948
- if (!O.value)
949
- return I.value.length > 0 ? [I.value[0]] : [];
950
- const r = I.value.find((g) => g.id === O.value);
951
- return r ? [r] : I.value.length > 0 ? [I.value[0]] : [];
952
- }), oe = R(() => x.value?.pricingOptions?.find((g) => g.isDefault)?.duration || 30), y = (r) => {
953
- O.value = r;
954
- };
955
- ue(o, () => {
956
- $();
957
- });
958
- const p = R(() => {
959
- const r = o.value, g = new Date(r.year, r.month - 1, r.day), B = g.toLocaleDateString("en-US", { weekday: "long" }).toUpperCase(), _ = r.day, N = g.toLocaleDateString("en-US", { month: "short" }).toUpperCase();
960
- return {
961
- dayName: B,
962
- day: _,
963
- monthName: N,
964
- full: `${B} ${_} ${N}`
965
- };
966
- }), E = () => {
967
- o.value = o.value.subtract({ days: u.value });
968
- }, V = () => {
969
- o.value = o.value.add({ days: u.value });
970
- }, h = () => {
971
- o.value = ce(me());
972
- }, c = (r) => {
973
- const [g, B] = r.split(":").map(Number);
974
- return g * 60 + B;
975
- }, t = (r, g) => (x.value?.exceptions || []).find((_) => g >= _.startDate && g <= _.endDate ? _.resourceIds === null ? !0 : _.resourceIds?.includes(r) : !1) || null, m = (r, g, B) => {
976
- const _ = t(r.id, B);
977
- if (_)
978
- return _.isClosed ? [] : _.timeslots.map((n) => ({
979
- startTime: n.startTime,
980
- endTime: n.endTime,
981
- isException: !0
982
- }));
983
- const N = g.getDay(), X = r.openingHours?.[N] || [];
984
- return X.length === 0 ? [] : X.map((n) => ({
985
- startTime: n.start,
986
- endTime: n.end,
987
- isException: !1
988
- }));
989
- }, M = (r, g, B, _) => {
990
- if (!x.value) return 0;
991
- const N = F.value.get(g);
992
- return N ? N.filter((n) => n.resourceId === r).reduce((n, K) => {
993
- const G = c(K.startTime), re = c(K.endTime), ie = c(B), pe = c(_);
994
- return G < pe && re > ie ? n + (K.reserved || 0) : n;
995
- }, 0) : 0;
996
- }, J = R(() => {
997
- if (!x.value) return [];
998
- F.value.size;
999
- let r = [], g = [];
1000
- for (let _ = 0; _ < u.value; _++) {
1001
- const N = o.value.add({ days: _ });
1002
- g.push(N);
1003
- }
1004
- const B = W.value.length > 0 ? W.value : [];
1005
- return B.length === 0 ? [] : (g.forEach((_) => {
1006
- let N = new Date(_.year, _.month - 1, _.day);
1007
- const X = `${_.year}-${String(_.month).padStart(2, "0")}-${String(_.day).padStart(2, "0")}`;
1008
- B.forEach((n) => {
1009
- const K = m(n, N, X);
1010
- r = r.concat(K.map((G, re) => {
1011
- const ie = M(n.id, X, G.startTime, G.endTime);
1012
- return {
1013
- id: `block-${X}-${n.id}-${re}`,
1014
- title: x.value.serviceName,
1015
- date: X,
1016
- startTime: G.startTime,
1017
- endTime: G.endTime,
1018
- theme: n.color || "#3b82f6",
1019
- bookings: ie,
1020
- maxBookings: n.capacity,
1021
- isException: G.isException || !1,
1022
- resourceId: n.id,
1023
- resource: n,
1024
- interval: n.interval || 30,
1025
- serviceDuration: oe.value
1026
- };
1027
- }));
1028
- });
1029
- }), r);
1030
- });
1031
- let Y = null;
1032
- const D = async () => {
1033
- Y || (Y = // @ts-ignore - params is actually a computed ref in the implementation
1034
- U.get(A.agendaCollection, k.value.id).then((r) => {
1035
- x.value = r;
1036
- }).finally(() => {
1037
- Y = null;
1038
- })), await Y;
1039
- }, $ = async () => {
1040
- if (x.value || await D(), !x.value) return;
1041
- const r = k.value.id, g = o.value;
1042
- F.value.clear();
1043
- const B = [];
1044
- for (let _ = 0; _ < u.value; _++) {
1045
- const N = g.add({ days: _ }), X = `${N.year}-${String(N.month).padStart(2, "0")}-${String(N.day).padStart(2, "0")}`, n = `${r}_${X}`;
1046
- B.push(
1047
- U.get(A.reservedSpotsCollection, n).then((K) => {
1048
- if (K) {
1049
- const G = [];
1050
- for (const re of I.value) {
1051
- const ie = K?.[re.id] || {};
1052
- Object.entries(ie).forEach(([pe, Ce]) => {
1053
- const [Ie, Me] = pe.split("-");
1054
- G.push({
1055
- resourceId: re.id,
1056
- startTime: Ie,
1057
- endTime: Me,
1058
- reserved: Ce
1059
- });
1060
- });
1061
- }
1062
- F.value.set(X, G);
1063
- }
1064
- }).catch(() => {
1065
- })
1066
- );
1067
- }
1068
- await Promise.all(B);
1069
- };
1070
- return (async () => (await D(), await $()))(), ue(u, () => {
1071
- $();
1072
- }), ne("agendaData", x), ne("activeDate", o), ne("viewMode", u), ne("events", J), ne("resources", W), ne("allResources", I), (r, g) => {
1073
- const B = H("Button"), _ = H("SegmentedControlButton"), N = H("SegmentedControl"), X = H("Calendar");
1074
- return s(), ee(Pe, null, {
1075
- default: z(() => [
1076
- e("div", {
1077
- ref_key: "container",
1078
- ref: d,
1079
- class: "flex flex-col gap-2 @md:gap-4 w-full"
1080
- }, [
1081
- e("div", {
1082
- class: q(["flex flex-col @5xl:flex-row @5xl:items-center @5xl:justify-between gap-3 px-1", (w.value, "")])
1083
- }, [
1084
- e("div", ls, [
1085
- e("div", is, [
1086
- e("div", us, [
1087
- l(S(je), {
1088
- size: 20,
1089
- class: "text-primary flex-shrink-0"
1090
- }),
1091
- e("h2", ds, v(p.value.full), 1)
1092
- ]),
1093
- e("p", cs, v(x.value?.serviceName), 1)
1094
- ])
1095
- ]),
1096
- e("div", ms, [
1097
- e("div", fs, [
1098
- l(B, {
1099
- variant: "outline",
1100
- size: "icon",
1101
- class: "size-8 @sm:size-9",
1102
- onClick: E
1103
- }, {
1104
- default: z(() => [
1105
- l(S(ge), { size: 16 })
1106
- ]),
1107
- _: 1
1108
- }),
1109
- l(B, {
1110
- variant: "outline",
1111
- size: "sm",
1112
- class: "h-8 @sm:h-9 px-2 @sm:px-3 text-xs @sm:text-sm",
1113
- onClick: h
1114
- }, {
1115
- default: z(() => [...g[3] || (g[3] = [
1116
- le(" Today ", -1)
1117
- ])]),
1118
- _: 1
1119
- }),
1120
- l(B, {
1121
- variant: "outline",
1122
- size: "icon",
1123
- class: "size-8 @sm:size-9",
1124
- onClick: V
1125
- }, {
1126
- default: z(() => [
1127
- l(S(fe), { size: 16 })
1128
- ]),
1129
- _: 1
1130
- })
1131
- ]),
1132
- w.value ? j("", !0) : (s(), ee(N, {
1133
- key: 0,
1134
- modelValue: u.value,
1135
- "onUpdate:modelValue": g[0] || (g[0] = (n) => u.value = n)
1136
- }, {
1137
- default: z(() => [
1138
- l(_, { value: 1 }, {
1139
- default: z(() => [...g[4] || (g[4] = [
1140
- e("span", { class: "whitespace-nowrap" }, "1 Day", -1)
1141
- ])]),
1142
- _: 1
1143
- }),
1144
- l(_, { value: 3 }, {
1145
- default: z(() => [...g[5] || (g[5] = [
1146
- e("span", { class: "whitespace-nowrap" }, "3 Days", -1)
1147
- ])]),
1148
- _: 1
1149
- }),
1150
- l(_, { value: 7 }, {
1151
- default: z(() => [...g[6] || (g[6] = [
1152
- e("span", { class: "whitespace-nowrap" }, "7 Days", -1)
1153
- ])]),
1154
- _: 1
1155
- })
1156
- ]),
1157
- _: 1
1158
- }, 8, ["modelValue"])),
1159
- S(T)("manage-reservations") ? (s(), ee(He, {
1160
- key: 1,
1161
- "agenda-data": x.value
1162
- }, null, 8, ["agenda-data"])) : j("", !0)
1163
- ])
1164
- ], 2),
1165
- w.value && I.value.length > 0 ? (s(), i("div", ps, [
1166
- (s(!0), i(Z, null, te(I.value, (n) => (s(), i("button", {
1167
- key: n.id,
1168
- class: q(["flex items-center gap-2 px-3 py-1.5 rounded-full border text-sm whitespace-nowrap transition-colors flex-shrink-0", {
1169
- "bg-primary text-primary-foreground border-primary": O.value === n.id,
1170
- "bg-background hover:bg-muted": O.value !== n.id
1171
- }]),
1172
- onClick: (K) => y(n.id)
1173
- }, [
1174
- e("div", {
1175
- class: "size-5 rounded-full flex items-center justify-center text-white text-[10px] font-medium",
1176
- style: se({ backgroundColor: O.value === n.id ? "rgba(255,255,255,0.3)" : n.color || "#6b7280" })
1177
- }, v(n.avatarLabel || n.name.charAt(0).toUpperCase()), 5),
1178
- e("span", null, v(n.name), 1)
1179
- ], 10, vs))), 128))
1180
- ])) : j("", !0),
1181
- e("div", gs, [
1182
- e("div", hs, [
1183
- l(X, {
1184
- modelValue: o.value,
1185
- "onUpdate:modelValue": g[1] || (g[1] = (n) => o.value = n),
1186
- "weekday-format": "short",
1187
- class: "rounded-md border"
1188
- }, null, 8, ["modelValue"]),
1189
- P.value.length > 0 ? (s(), i("div", xs, [
1190
- g[7] || (g[7] = e("div", { class: "flex items-center justify-between mb-3" }, [
1191
- e("span", { class: "text-sm font-medium" }, "Resources")
1192
- ], -1)),
1193
- e("div", ys, [
1194
- (s(!0), i(Z, null, te(I.value, (n) => (s(), i("div", {
1195
- key: n.id,
1196
- class: q(["flex items-center gap-2 p-2 rounded-md hover:bg-muted cursor-pointer transition-colors", {
1197
- "bg-muted ring-2 ring-primary/20": O.value === n.id,
1198
- "opacity-50": O.value && O.value !== n.id
1199
- }]),
1200
- onClick: (K) => y(n.id)
1201
- }, [
1202
- e("div", {
1203
- class: "size-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0",
1204
- style: se({ backgroundColor: n.color || "#6b7280" })
1205
- }, v(n.avatarLabel || n.name.charAt(0).toUpperCase()), 5),
1206
- e("div", _s, [
1207
- e("div", ks, v(n.name), 1)
1208
- ]),
1209
- e("div", {
1210
- class: q(["size-2 rounded-full flex-shrink-0", O.value === n.id ? "bg-primary" : "bg-muted-foreground/30"])
1211
- }, null, 2)
1212
- ], 10, bs))), 128)),
1213
- Q.value.length > 0 ? (s(), i("div", ws, [
1214
- e("button", {
1215
- class: "flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground w-full py-1 transition-colors",
1216
- onClick: g[2] || (g[2] = (n) => L.value = !L.value)
1217
- }, [
1218
- l(S(fe), {
1219
- size: 14,
1220
- class: q(["transition-transform", { "rotate-90": L.value }])
1221
- }, null, 8, ["class"]),
1222
- e("span", null, "Inactive (" + v(Q.value.length) + ")", 1)
1223
- ]),
1224
- L.value ? (s(), i("div", Ss, [
1225
- (s(!0), i(Z, null, te(Q.value, (n) => (s(), i("div", {
1226
- key: n.id,
1227
- class: "flex items-center gap-2 p-2 rounded-md opacity-50"
1228
- }, [
1229
- e("div", {
1230
- class: "size-7 rounded-full flex items-center justify-center text-white text-xs font-medium flex-shrink-0 grayscale",
1231
- style: se({ backgroundColor: n.color || "#6b7280" })
1232
- }, v(n.avatarLabel || n.name.charAt(0).toUpperCase()), 5),
1233
- e("div", $s, [
1234
- e("div", Ts, v(n.name), 1)
1235
- ])
1236
- ]))), 128))
1237
- ])) : j("", !0)
1238
- ])) : j("", !0)
1239
- ])
1240
- ])) : j("", !0)
1241
- ]),
1242
- l(rs, { "agenda-data": x.value }, null, 8, ["agenda-data"])
1243
- ])
1244
- ], 512)
1245
- ]),
1246
- _: 1
1247
- });
1248
- };
1249
- }
1250
- });
1251
- export {
1252
- Ps as default
1253
- };