@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
@@ -0,0 +1,1261 @@
1
+ import { defineComponent as ge, inject as Je, computed as P, ref as j, onMounted as Ke, nextTick as He, onUnmounted as Qe, watch as Q, openBlock as d, createElementBlock as C, resolveComponent as V, withModifiers as Ze, createElementVNode as m, Fragment as ue, createVNode as u, unref as e, normalizeStyle as me, toDisplayString as R, createCommentVNode as Z, createBlock as A, isRef as re, withCtx as b, createTextVNode as q, renderList as _e, normalizeClass as le, withDirectives as et, vModelText as tt, provide as at } from "vue";
2
+ import { useModuleRoute as Me, useModule as Re, useFirebaseIntegration as Ve, useModulePermissions as st } from "@oneclick.dev/cms-kit";
3
+ import { _ as ot } from "./EditLayout.vue_vue_type_script_setup_true_lang-pDO9b4Pv.mjs";
4
+ import { f as Se, q as nt, p as rt, E as pe, Z as Ce, _ as it, B as Ee, Q as ze, u as ve, I as Oe, $ as lt, a0 as ct, a1 as dt, n as ut, h as mt, K as ft, J as pt, P as vt } from "./index-Bnn9LahC.mjs";
5
+ import { componentToString as Pe, ChartTooltipContent as je } from "@oneclick.dev/cms-kit/charts";
6
+ import { Layers as we, ChevronDown as gt, ChevronLeft as ht, ChevronRight as yt, CalendarIcon as xt, Users as Be, RefreshCw as bt, Search as kt, X as Dt, Eye as ye, EyeOff as xe, Clock as _t } from "lucide-vue-next";
7
+ import { u as St } from "./index-hMp4p5qA.mjs";
8
+ import { X as Ct, b as Ue, a as wt, c as $t, r as Mt, D as be, $ as Ne, O as ke, z as We, A as Fe } from "./index-cC_2cw31.mjs";
9
+ import { _ as Rt } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
10
+ import { u as Vt, F as Tt, _ as It, a as At, b as Et } from "./OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs";
11
+ import { _ as zt } from "./NewReservationDialog.vue_vue_type_script_setup_true_lang-CcMEKZzd.mjs";
12
+ function Ot({ x: p, y: h, w: o, h: y, tl: v = !1, tr: x = !1, bl: k = !1, br: l = !1, r: i = 0 }) {
13
+ let c;
14
+ c = `M${p + i},${h}h${o - 2 * i}`;
15
+ let n = x ? i : 0, f = x ? 0 : i;
16
+ return c += `a${n},${n} 0 0 1 ${n},${n}`, c += `h${f}v${f}`, c += `v${y - 2 * i}`, n = l ? i : 0, f = l ? 0 : i, c += `a${n},${n} 0 0 1 ${-n},${n}`, c += `v${f}h${-f}`, c += `h${2 * i - o}`, n = k ? i : 0, f = k ? 0 : i, c += `a${n},${n} 0 0 1 ${-n},${-n}`, c += `h${-f}v${-f}`, c += `v${2 * i - y}`, n = v ? i : 0, f = v ? 0 : i, c += `a${n},${n} 0 0 1 ${n},${-n}`, c += `v${-f}h${f}`, c += "z", c;
17
+ }
18
+ const Pt = Object.assign(Object.assign({}, Ct), { color: void 0, groupMaxWidth: void 0, groupWidth: void 0, dataStep: void 0, groupPadding: 0.05, barPadding: 0, roundedCorners: 2, barMinHeight: 2, cursor: null, orientation: Ue.Vertical }), qe = Se`
19
+ label: grouped-bar-component;
20
+ `, jt = nt`
21
+ :root {
22
+ --vis-grouped-bar-cursor: default;
23
+ --vis-grouped-bar-fill-color: var(--vis-color-main);
24
+ --vis-grouped-bar-stroke-color: none;
25
+ --vis-grouped-bar-stroke-width: 0px;
26
+ --vis-grouped-bar-hover-stroke-width: 1px;
27
+ --vis-grouped-bar-hover-stroke-color: none;
28
+
29
+
30
+ /* Dark Theme */
31
+ --vis-dark-grouped-bar-stroke-color: none;
32
+ }
33
+
34
+ body.theme-dark ${`.${qe}`} {
35
+ --vis-grouped-bar-stroke-color: var(--vis-dark-grouped-bar-stroke-color);
36
+ }
37
+ `, De = Se`
38
+ label: bar;
39
+ fill: var(--vis-grouped-bar-fill-color);
40
+ stroke: var(--vis-grouped-bar-stroke-color);
41
+ stroke-width: var(--vis-grouped-bar-stroke-width);
42
+ cursor: var(--vis-grouped-bar-cursor);
43
+
44
+ &:hover {
45
+ stroke-width: var(--vis-grouped-bar-hover-stroke-width);
46
+ stroke: var(--vis-grouped-bar-hover-stroke-color);
47
+ }
48
+ `, $e = Se`
49
+ label: barGroup;
50
+ `, Ye = Se`
51
+ label: barGroupExit;
52
+ `, Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
53
+ __proto__: null,
54
+ bar: De,
55
+ barGroup: $e,
56
+ barGroupExit: Ye,
57
+ globalStyles: jt,
58
+ root: qe
59
+ }, Symbol.toStringTag, { value: "Module" }));
60
+ class Xe extends wt {
61
+ constructor(h) {
62
+ super(), this._defaultConfig = Pt, this.config = this._defaultConfig, this.getAccessors = () => rt(this.config.y) ? this.config.y : [this.config.y], this.events = {}, this._barData = [], h && this.setConfig(h);
63
+ }
64
+ get bleed() {
65
+ if (this._barData = this._getVisibleData(), this._barData.length === 0)
66
+ return { top: 0, bottom: 0, left: 0, right: 0 };
67
+ const h = !this.isVertical() && this.dataScale.range()[0] > this.dataScale.range()[1], o = this.dataScale.domain(), y = this._getGroupWidth() / 2, v = this._barData.map((_, O) => pe(_, this.config.x, O)), x = Ce(v), k = it(v), l = this.dataScale(x), i = this.dataScale(k), c = this.dataScale.invert(l + (h ? y : -y)), n = this.dataScale.invert(i + (h ? -y : y)), f = c <= o[0] ? this.dataScale(o[0]) - this.dataScale(c) : 0, T = n > o[1] ? this.dataScale(n) - this.dataScale(o[1]) : 0;
68
+ return {
69
+ top: this.isVertical() ? 0 : h ? -T : f,
70
+ bottom: this.isVertical() ? 0 : h ? -f : T,
71
+ left: this.isVertical() ? f : 0,
72
+ right: this.isVertical() ? T : 0
73
+ };
74
+ }
75
+ get dataScale() {
76
+ return this.isVertical() ? this.xScale : this.yScale;
77
+ }
78
+ get valueScale() {
79
+ return this.isVertical() ? this.yScale : this.xScale;
80
+ }
81
+ isVertical() {
82
+ return this.config.orientation === Ue.Vertical;
83
+ }
84
+ _render(h) {
85
+ const { config: o } = this, y = Ee(h) ? h : o.duration, v = this._getGroupWidth(), x = this.getAccessors(), k = [-v / 2, v / 2], l = $t().domain(Mt(x.length)).range(k).paddingInner(o.barPadding).paddingOuter(o.barPadding), i = this.g.selectAll(`.${$e}`).data(this._barData, (B, E) => {
86
+ var L;
87
+ return `${(L = ze(B, o.id, E)) !== null && L !== void 0 ? L : E}`;
88
+ }), c = (B, E) => {
89
+ const L = this.dataScale(pe(B, o.x, E)), z = this.isVertical() ? L : 0, U = this.isVertical() ? 0 : L;
90
+ return `translate(${z},${U})`;
91
+ }, f = i.enter().append("g").attr("class", $e).attr("transform", c).style("opacity", 1).merge(i);
92
+ ve(f, y).attr("transform", c).style("opacity", 1);
93
+ const T = i.exit().attr("class", Ye);
94
+ ve(T, y).style("opacity", 0).remove(), ve(T.selectAll(`.${De}`), y).attr("transform", (B, E, L) => this.isVertical() ? `translate(0,${this.yScale(0)}) scale(1,0)` : `translate(${this.xScale(0)},0) scale(0,1)`);
95
+ const _ = l.bandwidth(), O = f.selectAll(`.${De}`).data((B) => x.map(() => B)), I = this._getValueAxisDirection(), ee = O.enter().append("path").attr("class", De).attr("d", (B, E) => {
96
+ const L = l(E), z = this.valueScale(0), U = _;
97
+ return this._getBarPath(L, z, U, 0, !1, I);
98
+ }).style("fill", (B, E) => Oe(B, o.color, E)).merge(O);
99
+ ve(ee, y).attr("d", (B, E) => {
100
+ const L = l(E), z = _, U = pe(B, x[E]), g = U < 0;
101
+ let N = g ? this.valueScale(0) : this.valueScale(U || 0), ae = Math.abs(this.valueScale(0) - this.valueScale(U)) || 0;
102
+ if (ae < o.barMinHeight) {
103
+ const ce = I === be.North ? -1 : 1;
104
+ N = this.valueScale(0) + ce * o.barMinHeight, ae = o.barMinHeight;
105
+ }
106
+ return this._getBarPath(L, N, z, ae, g, I);
107
+ }).style("fill", (B, E) => Oe(B, o.color, E)).style("cursor", (B, E) => ze(B, o.cursor, E)), ve(O.exit(), y).remove();
108
+ }
109
+ _getValueAxisDirection() {
110
+ return this.valueScale.range()[0] > this.valueScale.range()[1] ? be.North : be.South;
111
+ }
112
+ _getVisibleData() {
113
+ const { config: h, datamodel: { data: o } } = this, y = this._getGroupWidth(), v = o.length < 2 ? 0 : y / 2, x = this.dataScale, k = Math.abs(x.invert(v) - x.invert(0));
114
+ return o?.filter((i, c) => {
115
+ const n = pe(i, h.x, c), f = x.domain(), T = +f[0], _ = +f[1];
116
+ return n >= T - k && n <= _ + k;
117
+ });
118
+ }
119
+ _getBarPath(h, o, y, v, x, k) {
120
+ const { config: l } = this, i = l.roundedCorners ? Ee(l.roundedCorners) ? +l.roundedCorners : y / 2 : 0, c = mt(i, 0, Math.min(v, y) / 2), n = k === be.North, f = this.isVertical() && x !== n, T = this.isVertical() && x === n, _ = !this.isVertical() && x, O = !this.isVertical() && !x;
121
+ return Ot({
122
+ x: this.isVertical() ? h : o + (n ? 0 : -v),
123
+ y: this.isVertical() ? o + (n ? 0 : -v) : h,
124
+ w: this.isVertical() ? y : v,
125
+ h: this.isVertical() ? v : y,
126
+ tl: f || _,
127
+ tr: f || O,
128
+ bl: T || _,
129
+ br: T || O,
130
+ r: c
131
+ });
132
+ }
133
+ _getGroupWidth() {
134
+ const { config: h, datamodel: { data: o } } = this;
135
+ if (lt(o))
136
+ return 0;
137
+ if (h.groupWidth)
138
+ return Ce([h.groupWidth, h.groupMaxWidth]);
139
+ const y = this.dataScale.bandwidth, v = this.dataScale.domain ? this.dataScale.domain() : [];
140
+ let k = 1 + (y ? v.length : v[1] - v[0]) / h.dataStep || !y && o.filter((c, n) => {
141
+ const f = pe(c, h.x, n);
142
+ return f >= v[0] && f <= v[1];
143
+ }).length || o.length;
144
+ !y && k >= 2 && (k += 1);
145
+ const i = (k < 2 ? 1 : 1 - h.groupPadding) * (this.isVertical() ? this._width : this._height) / k;
146
+ return Ce([i, h.groupMaxWidth]);
147
+ }
148
+ getValueScaleExtent(h) {
149
+ const { datamodel: o } = this, y = this.getAccessors(), v = h ? this._getVisibleData() : o.data, x = ct(v, ...y), k = dt(v, ...y);
150
+ return [x > 0 ? 0 : x, k < 0 ? 0 : k];
151
+ }
152
+ getDataScaleExtent() {
153
+ const { config: h, datamodel: o } = this;
154
+ return ut(o.data, h.x);
155
+ }
156
+ getYDataExtent(h) {
157
+ return this.isVertical() ? this.getValueScaleExtent(h) : this.getDataScaleExtent();
158
+ }
159
+ getXDataExtent() {
160
+ return this.isVertical() ? this.getDataScaleExtent() : this.getValueScaleExtent(!1);
161
+ }
162
+ }
163
+ Xe.selectors = Bt;
164
+ const Nt = { "data-vis-component": "" }, Le = /* @__PURE__ */ ge({
165
+ __name: "index",
166
+ props: {
167
+ color: {},
168
+ groupWidth: {},
169
+ groupMaxWidth: {},
170
+ dataStep: {},
171
+ groupPadding: {},
172
+ barPadding: {},
173
+ roundedCorners: { type: [Number, Boolean] },
174
+ barMinHeight: {},
175
+ cursor: {},
176
+ orientation: {},
177
+ x: {},
178
+ y: {},
179
+ id: { type: Function },
180
+ xScale: { type: [Object, Function] },
181
+ yScale: { type: [Object, Function] },
182
+ excludeFromDomainCalculation: { type: Boolean },
183
+ duration: {},
184
+ events: {},
185
+ attributes: {},
186
+ data: {}
187
+ },
188
+ setup(p, { expose: h }) {
189
+ const o = Je(ft), y = p, v = P(() => o.data.value ?? y.data), x = pt(y), k = j();
190
+ return Ke(() => {
191
+ He(() => {
192
+ var l;
193
+ k.value = new Xe(x.value), (l = k.value) == null || l.setData(v.value), o.update(k.value);
194
+ });
195
+ }), Qe(() => {
196
+ var l;
197
+ (l = k.value) == null || l.destroy(), o.destroy();
198
+ }), Q(x, (l, i) => {
199
+ var c;
200
+ vt(l, i) || (c = k.value) == null || c.setConfig(x.value);
201
+ }), Q(v, () => {
202
+ var l;
203
+ (l = k.value) == null || l.setData(v.value);
204
+ }), h({
205
+ component: k
206
+ }), (l, i) => (d(), C("div", Nt));
207
+ }
208
+ }), Wt = { class: "flex flex-col sm:flex-row" }, Ft = ["data-active"], Lt = { class: "flex items-center gap-2" }, Gt = { class: "block text-muted-foreground text-xs mr-2 max-w-[120px] truncate" }, Ht = { class: "block text-lg leading-none font-bold sm:text-3xl" }, Ut = { class: "mx-auto w-full max-w-sm mt-2 mb-8" }, qt = { class: "text-muted-foreground" }, Yt = { class: "text-muted-foreground" }, Xt = { class: "grid" }, Jt = { class: "flex gap-1 overflow-hidden max-w-80" }, Kt = { class: "truncate" }, Qt = /* @__PURE__ */ ge({
209
+ __name: "ResourceSelector",
210
+ props: {
211
+ resources: {
212
+ type: Array,
213
+ required: !0
214
+ },
215
+ totals: {
216
+ type: Object,
217
+ required: !0
218
+ },
219
+ viewMode: {
220
+ type: String,
221
+ required: !0
222
+ },
223
+ activeChart: {
224
+ type: String,
225
+ required: !1
226
+ }
227
+ },
228
+ emits: ["update:viewMode", "update:activeChart"],
229
+ setup(p, { emit: h }) {
230
+ const o = p, y = h, v = P({
231
+ get: () => o.viewMode,
232
+ set: (c) => {
233
+ y("update:viewMode", c);
234
+ }
235
+ }), x = P({
236
+ get: () => o.activeChart,
237
+ set: (c) => {
238
+ y("update:activeChart", c);
239
+ }
240
+ }), { width: k } = St(), l = P(() => k.value < 640), i = j(!1);
241
+ return (c, n) => {
242
+ const f = V("DrawerTitle"), T = V("DrawerDescription"), _ = V("DrawerHeader"), O = V("Button"), I = V("DrawerFooter"), J = V("DrawerContent"), ee = V("Drawer"), B = V("DropdownMenuTrigger"), E = V("DropdownMenuLabel"), L = V("DropdownMenuItem"), z = V("DropdownMenuContent"), U = V("DropdownMenu");
243
+ return d(), C("div", Wt, [
244
+ p.resources.length > 1 ? (d(), C("button", {
245
+ key: 0,
246
+ "data-active": p.viewMode === "stacked",
247
+ class: "hover:bg-muted/50 flex flex-1 flex-col justify-center gap-2 border-t px-4 py-3 text-left sm:border-t-0 sm:border-l sm:px-6 sm:py-6 cursor-pointer select-none",
248
+ onClick: n[0] || (n[0] = (g) => i.value = !0),
249
+ onContextmenu: n[1] || (n[1] = Ze((g) => i.value = !0, ["prevent"]))
250
+ }, [
251
+ m("div", Lt, [
252
+ p.viewMode === "stacked" ? (d(), C(ue, { key: 0 }, [
253
+ u(e(we), { class: "size-3 text-muted-foreground" }),
254
+ n[6] || (n[6] = m("span", { class: "block text-muted-foreground text-xs mr-2 max-w-[120px] truncate" }, "All Resources", -1))
255
+ ], 64)) : (d(), C(ue, { key: 1 }, [
256
+ m("div", {
257
+ class: "size-3 rounded-full mr-2",
258
+ style: me({ backgroundColor: p.resources.find((g) => g.id === p.activeChart)?.color || "#6b7280" })
259
+ }, null, 4),
260
+ m("span", Gt, R(p.resources.find((g) => g.id === p.activeChart)?.name || "Select Resource"), 1)
261
+ ], 64)),
262
+ u(e(gt), { class: "ml-auto size-4" })
263
+ ]),
264
+ m("span", Ht, R(p.viewMode === "stacked" ? Object.values(p.totals).reduce((g, N) => g + N, 0).toLocaleString() : (p.totals[p.activeChart] || 0).toLocaleString()), 1)
265
+ ], 40, Ft)) : Z("", !0),
266
+ e(l) ? (d(), A(ee, {
267
+ key: 1,
268
+ open: e(i),
269
+ "onUpdate:open": n[3] || (n[3] = (g) => re(i) ? i.value = g : null)
270
+ }, {
271
+ default: b(() => [
272
+ u(J, null, {
273
+ default: b(() => [
274
+ m("div", Ut, [
275
+ u(_, null, {
276
+ default: b(() => [
277
+ u(f, null, {
278
+ default: b(() => [...n[7] || (n[7] = [
279
+ q("Resources", -1)
280
+ ])]),
281
+ _: 1
282
+ }),
283
+ u(T, null, {
284
+ default: b(() => [...n[8] || (n[8] = [
285
+ q("Select the resources to display on the timeline.", -1)
286
+ ])]),
287
+ _: 1
288
+ })
289
+ ]),
290
+ _: 1
291
+ }),
292
+ u(I, null, {
293
+ default: b(() => [
294
+ u(O, {
295
+ onClick: n[2] || (n[2] = (g) => {
296
+ v.value = "stacked", x.value = "", i.value = !1;
297
+ }),
298
+ variant: p.viewMode === "stacked" ? "secondary" : "outline"
299
+ }, {
300
+ default: b(() => [
301
+ u(e(we), { class: "size-3 text-muted-foreground" }),
302
+ m("span", qt, " All Resources (" + R(Object.values(p.totals).reduce((g, N) => g + N, 0).toLocaleString()) + ") ", 1)
303
+ ]),
304
+ _: 1
305
+ }, 8, ["variant"]),
306
+ (d(!0), C(ue, null, _e(p.resources, (g) => (d(), A(O, {
307
+ key: g.id,
308
+ onClick: (N) => {
309
+ v.value = "single", x.value = g.id, i.value = !1;
310
+ },
311
+ variant: p.viewMode === "single" && p.activeChart === g.id ? "secondary" : "outline"
312
+ }, {
313
+ default: b(() => [
314
+ m("div", {
315
+ class: "size-3 rounded-full",
316
+ style: me({ backgroundColor: g.color || "#6b7280" })
317
+ }, null, 4),
318
+ m("span", Yt, R(g.name) + " (" + R((p.totals[g.id] || 0).toLocaleString()) + ") ", 1)
319
+ ]),
320
+ _: 2
321
+ }, 1032, ["onClick", "variant"]))), 128))
322
+ ]),
323
+ _: 1
324
+ })
325
+ ])
326
+ ]),
327
+ _: 1
328
+ })
329
+ ]),
330
+ _: 1
331
+ }, 8, ["open"])) : (d(), A(U, {
332
+ key: 2,
333
+ open: e(i),
334
+ "onUpdate:open": n[5] || (n[5] = (g) => re(i) ? i.value = g : null)
335
+ }, {
336
+ default: b(() => [
337
+ u(B, { "as-child": "" }, {
338
+ default: b(() => [...n[9] || (n[9] = [
339
+ m("button", {
340
+ tabindex: "-1",
341
+ class: "size-0 opacity-0 self-end"
342
+ }, null, -1)
343
+ ])]),
344
+ _: 1
345
+ }),
346
+ u(z, { align: "end" }, {
347
+ default: b(() => [
348
+ u(E, null, {
349
+ default: b(() => [...n[10] || (n[10] = [
350
+ q("Resources", -1)
351
+ ])]),
352
+ _: 1
353
+ }),
354
+ m("div", Xt, [
355
+ u(L, {
356
+ onClick: n[4] || (n[4] = (g) => {
357
+ v.value = "stacked", x.value = "", i.value = !1;
358
+ }),
359
+ class: le(p.viewMode === "stacked" ? "bg-input" : "")
360
+ }, {
361
+ default: b(() => [
362
+ u(e(we), { class: "size-3 text-muted-foreground" }),
363
+ m("span", null, " All Resources (" + R(Object.values(p.totals).reduce((g, N) => g + N, 0).toLocaleString()) + ") ", 1)
364
+ ]),
365
+ _: 1
366
+ }, 8, ["class"]),
367
+ (d(!0), C(ue, null, _e(p.resources, (g) => (d(), A(L, {
368
+ key: g.id,
369
+ onClick: (N) => {
370
+ v.value = "single", x.value = g.id, i.value = !1;
371
+ },
372
+ class: le(p.viewMode === "single" && p.activeChart === g.id ? "bg-input" : "")
373
+ }, {
374
+ default: b(() => [
375
+ m("div", {
376
+ class: "size-3 rounded-full",
377
+ style: me({ backgroundColor: g.color || "#6b7280" })
378
+ }, null, 4),
379
+ m("span", Jt, [
380
+ m("span", Kt, R(g.name), 1),
381
+ m("span", null, "(" + R((p.totals[g.id] || 0).toLocaleString()) + ")", 1)
382
+ ])
383
+ ]),
384
+ _: 2
385
+ }, 1032, ["onClick", "class"]))), 128))
386
+ ])
387
+ ]),
388
+ _: 1
389
+ })
390
+ ]),
391
+ _: 1
392
+ }, 8, ["open"]))
393
+ ]);
394
+ };
395
+ }
396
+ }), Zt = { class: "flex flex-1 flex-col justify-center gap-1 px-6 py-5 sm:py-6" }, ea = { class: "flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3" }, ta = { class: "flex items-center gap-1" }, aa = { class: "timeline-date-trigger" }, sa = {
397
+ key: 1,
398
+ class: "flex items-center justify-center px-6 py-4 text-muted-foreground text-sm"
399
+ }, oa = {
400
+ key: 0,
401
+ class: "flex items-center justify-center h-[250px]"
402
+ }, na = {
403
+ key: 1,
404
+ class: "flex items-center justify-center h-[250px]"
405
+ }, ra = {
406
+ key: 2,
407
+ class: "timeline-chart-scroll"
408
+ }, Ge = "#61616180", ia = 36, la = /* @__PURE__ */ ge({
409
+ __name: "Timeline",
410
+ props: {
411
+ modelValue: {},
412
+ selectedResource: {},
413
+ viewMode: {},
414
+ agendaData: {},
415
+ resources: {}
416
+ },
417
+ emits: ["update:modelValue", "update:selectedResource", "update:viewMode"],
418
+ setup(p, { emit: h }) {
419
+ const o = p, y = h, { params: v } = Me(), { config: x } = Re(), k = Ve(x.project), l = j([]), i = j([]), c = j(!0), n = j(o.viewMode || "stacked"), f = j(o.selectedResource || "");
420
+ Q(n, (s) => {
421
+ y("update:viewMode", s);
422
+ }, { immediate: !0 }), Q(f, (s) => {
423
+ y("update:selectedResource", n.value === "single" ? s : null);
424
+ }), Q(n, (s) => {
425
+ y("update:selectedResource", s === "single" ? f.value : null);
426
+ }), Q(() => o.selectedResource, (s) => {
427
+ n.value === "single" && s !== f.value && (f.value = s || "");
428
+ });
429
+ const T = /* @__PURE__ */ new Date(), _ = j(o.modelValue || /* @__PURE__ */ new Date()), O = j(null);
430
+ Q(() => o.modelValue, (s) => {
431
+ s && s.getTime() !== _.value.getTime() && (_.value = s);
432
+ }), Q(_, (s) => {
433
+ y("update:modelValue", s);
434
+ }, { immediate: !0 });
435
+ const I = P({
436
+ get: () => w(_.value),
437
+ set: (s) => {
438
+ if (!s) {
439
+ _.value = /* @__PURE__ */ new Date();
440
+ return;
441
+ }
442
+ _.value = /* @__PURE__ */ new Date(`${s}T00:00:00`);
443
+ }
444
+ }), J = () => {
445
+ const s = O.value;
446
+ if (s) {
447
+ if (typeof s.showPicker == "function") {
448
+ s.showPicker();
449
+ return;
450
+ }
451
+ s.focus(), s.click();
452
+ }
453
+ }, ee = P(() => {
454
+ const s = new Date(T);
455
+ s.setDate(T.getDate() - 1);
456
+ const t = new Date(T);
457
+ return t.setDate(T.getDate() + 1), _.value.toDateString() === T.toDateString() ? "Today" : _.value.toDateString() === s.toDateString() ? "Yesterday" : _.value.toDateString() === t.toDateString() ? "Tomorrow" : _.value.toLocaleDateString("en-US", {
458
+ weekday: "long",
459
+ month: "long",
460
+ day: "numeric",
461
+ year: "numeric"
462
+ });
463
+ }), B = () => {
464
+ const s = new Date(_.value);
465
+ s.setDate(s.getDate() - 1), _.value = s;
466
+ }, E = () => {
467
+ const s = new Date(_.value);
468
+ s.setDate(s.getDate() + 1), _.value = s;
469
+ }, L = () => {
470
+ _.value = /* @__PURE__ */ new Date();
471
+ }, z = P(() => (o.resources?.length || 0) === 0 ? 10 : Math.max(...(o.resources || []).map((s) => s.capacity || 10))), U = P(() => (o.resources?.length || 0) === 0 ? 10 : (o.resources || []).reduce((s, t) => s + (t.capacity || 10), 0)), g = P(() => (o.resources?.length || 0) === 0 ? 60 : Math.min(...(o.resources || []).map((s) => s.interval || 60))), N = P(() => {
472
+ const s = {
473
+ total: {
474
+ label: "Total Reservations",
475
+ color: void 0
476
+ }
477
+ };
478
+ return (o.resources || []).forEach((t, S) => {
479
+ s[t.id] = {
480
+ label: t.name,
481
+ color: t.color || `var(--chart-${S % 5 + 1})`
482
+ };
483
+ }), s;
484
+ });
485
+ Q(() => o.resources, (s) => {
486
+ const t = s?.[0];
487
+ t && !f.value && (f.value = t.id);
488
+ }, { immediate: !0 });
489
+ const ae = P(() => [...o.resources || []].sort((s, t) => {
490
+ const S = fe.value[s.id] || 0;
491
+ return (fe.value[t.id] || 0) - S;
492
+ })), ce = P(() => {
493
+ const s = [];
494
+ return g.value, l.value.forEach((t, S) => {
495
+ t.time.endsWith(":00") && s.push(S);
496
+ }), s;
497
+ }), fe = P(() => {
498
+ const s = {};
499
+ return o.resources?.forEach((t) => {
500
+ s[t.id] = i.value.filter((S) => S.resourceId === t.id).reduce((S, $) => S + ($.reserved || 0), 0);
501
+ }), s;
502
+ }), he = P(() => l.value.reduce((s, t) => Math.max(s, t.total || 0), 0)), te = P(() => ({
503
+ minWidth: `max(100%, ${Math.max(l.value.length, 1) * ia}px)`
504
+ })), Te = P(() => Math.max(U.value, he.value, 1)), r = (s, t) => {
505
+ const S = s[t];
506
+ return typeof S == "number" ? S : 0;
507
+ }, a = (s, t) => {
508
+ const S = ae.value[t];
509
+ return !S || r(s, S.id) <= 0 ? 0 : ae.value.slice(t).reduce(($, G) => $ + r(s, G.id), 0);
510
+ }, w = (s) => {
511
+ const t = s.getFullYear(), S = String(s.getMonth() + 1).padStart(2, "0"), $ = String(s.getDate()).padStart(2, "0");
512
+ return `${t}-${S}-${$}`;
513
+ }, W = (s) => {
514
+ const [t, S] = s.split(":").map(Number);
515
+ return t * 60 + S;
516
+ }, Y = (s, t) => (o.agendaData?.exceptions || []).find(($) => t >= $.startDate && t <= $.endDate ? $.resourceIds === null ? !0 : $.resourceIds?.includes(s) : !1) || null, F = P(() => {
517
+ const s = w(_.value), t = _.value.getDay();
518
+ let S = 1440, $ = 0;
519
+ if ((o.resources || []).forEach((ne) => {
520
+ const H = Y(ne.id, s);
521
+ if (H) {
522
+ if (H.isClosed)
523
+ return;
524
+ H.timeslots.forEach((K) => {
525
+ const D = W(K.startTime), M = W(K.endTime);
526
+ S = Math.min(S, D), $ = Math.max($, M);
527
+ });
528
+ } else
529
+ (ne.openingHours?.[t] || []).forEach((D) => {
530
+ const M = W(D.start), X = W(D.end);
531
+ S = Math.min(S, M), $ = Math.max($, X);
532
+ });
533
+ }), S >= $)
534
+ return { startMinutes: 540, endMinutes: 1020 };
535
+ const G = Math.floor(S / 60) * 60, ie = Math.ceil($ / 60) * 60;
536
+ return { startMinutes: G, endMinutes: ie };
537
+ }), se = () => {
538
+ const s = [], t = g.value, { startMinutes: S, endMinutes: $ } = F.value;
539
+ for (let G = S; G < $; G += t) {
540
+ const ie = Math.floor(G / 60), ne = G % 60, H = `${String(ie).padStart(2, "0")}:${String(ne).padStart(2, "0")}`, K = {
541
+ time: H,
542
+ label: H,
543
+ total: 0
544
+ };
545
+ o.resources?.forEach((D) => {
546
+ K[D.id] = 0;
547
+ }), s.push(K);
548
+ }
549
+ return s;
550
+ }, oe = async () => {
551
+ c.value = !0;
552
+ try {
553
+ const s = v.value.id, t = w(_.value), S = `${s}_${t}`, $ = await k.get(x.reservedSpotsCollection, S);
554
+ i.value = [];
555
+ for (const H of o.resources || []) {
556
+ const K = $?.[H.id] || {};
557
+ Object.entries(K).forEach(([D, M]) => {
558
+ const [X, de] = D.split("-");
559
+ i.value.push({
560
+ resourceId: H.id,
561
+ startTime: X,
562
+ endTime: de,
563
+ reserved: M
564
+ });
565
+ });
566
+ }
567
+ const G = se(), ie = g.value, { startMinutes: ne } = F.value;
568
+ i.value.forEach((H) => {
569
+ const K = W(H.startTime), D = W(H.endTime);
570
+ for (let M = K; M < D; M += ie) {
571
+ const X = Math.floor((M - ne) / ie);
572
+ if (X >= 0 && X < G.length) {
573
+ const de = G[X][H.resourceId];
574
+ if (typeof de == "number") {
575
+ const Ae = Number(H.reserved) || 0;
576
+ G[X][H.resourceId] = de + Ae, G[X].total += Ae;
577
+ }
578
+ }
579
+ }
580
+ }), l.value = G;
581
+ } catch (s) {
582
+ console.error("Error loading reservation data:", s), l.value = se(), i.value = [];
583
+ } finally {
584
+ c.value = !1;
585
+ }
586
+ };
587
+ return (async () => await oe())(), Q(_, () => {
588
+ oe();
589
+ }), Q(() => o.resources, () => {
590
+ (o.resources?.length || 0) > 0 && oe();
591
+ }), (s, t) => {
592
+ const S = V("CardTitle"), $ = V("Button"), G = V("CardDescription"), ie = V("CardHeader"), ne = V("ChartContainer"), H = V("CardContent"), K = V("Card");
593
+ return d(), A(K, { class: "py-4 sm:py-0" }, {
594
+ default: b(() => [
595
+ u(ie, { class: "flex flex-col items-stretch border-b !p-0 sm:flex-row" }, {
596
+ default: b(() => [
597
+ m("div", Zt, [
598
+ m("div", ea, [
599
+ u(S, null, {
600
+ default: b(() => [...t[3] || (t[3] = [
601
+ q("Reservations", -1)
602
+ ])]),
603
+ _: 1
604
+ }),
605
+ m("div", ta, [
606
+ u($, {
607
+ variant: "outline",
608
+ size: "icon",
609
+ class: "size-8",
610
+ onClick: B
611
+ }, {
612
+ default: b(() => [
613
+ u(e(ht), { size: 16 })
614
+ ]),
615
+ _: 1
616
+ }),
617
+ u($, {
618
+ variant: "outline",
619
+ size: "sm",
620
+ class: "h-8 px-3 text-xs",
621
+ onClick: L
622
+ }, {
623
+ default: b(() => [...t[4] || (t[4] = [
624
+ q(" Today ", -1)
625
+ ])]),
626
+ _: 1
627
+ }),
628
+ u($, {
629
+ variant: "outline",
630
+ size: "icon",
631
+ class: "size-8",
632
+ onClick: E
633
+ }, {
634
+ default: b(() => [
635
+ u(e(yt), { size: 16 })
636
+ ]),
637
+ _: 1
638
+ })
639
+ ])
640
+ ]),
641
+ u(G, null, {
642
+ default: b(() => [
643
+ m("div", aa, [
644
+ u($, {
645
+ type: "button",
646
+ variant: "outline",
647
+ onClick: J
648
+ }, {
649
+ default: b(() => [
650
+ u(e(xt), { class: "size-4" }),
651
+ q(" " + R(e(ee)), 1)
652
+ ]),
653
+ _: 1
654
+ }),
655
+ et(m("input", {
656
+ ref_key: "dateInputRef",
657
+ ref: O,
658
+ "onUpdate:modelValue": t[0] || (t[0] = (D) => re(I) ? I.value = D : null),
659
+ type: "date",
660
+ class: "timeline-date-picker",
661
+ "aria-label": "Select reservation date"
662
+ }, null, 512), [
663
+ [tt, e(I)]
664
+ ])
665
+ ])
666
+ ]),
667
+ _: 1
668
+ })
669
+ ]),
670
+ (p.resources?.length || 0) > 0 ? (d(), A(Qt, {
671
+ key: 0,
672
+ resources: p.resources || [],
673
+ totals: e(fe),
674
+ viewMode: e(n),
675
+ "onUpdate:viewMode": t[1] || (t[1] = (D) => re(n) ? n.value = D : null),
676
+ activeChart: e(f),
677
+ "onUpdate:activeChart": t[2] || (t[2] = (D) => re(f) ? f.value = D : null)
678
+ }, null, 8, ["resources", "totals", "viewMode", "activeChart"])) : (d(), C("div", sa, " No resources configured "))
679
+ ]),
680
+ _: 1
681
+ }),
682
+ u(H, { class: "px-2 sm:p-6" }, {
683
+ default: b(() => [
684
+ e(c) ? (d(), C("div", oa, [...t[5] || (t[5] = [
685
+ m("div", { class: "text-muted-foreground" }, "Loading...", -1)
686
+ ])])) : (p.resources?.length || 0) === 0 ? (d(), C("div", na, [...t[6] || (t[6] = [
687
+ m("div", { class: "text-muted-foreground" }, "No resources to display", -1)
688
+ ])])) : (d(), C("div", ra, [
689
+ e(n) === "stacked" ? (d(), A(ne, {
690
+ key: 0,
691
+ config: e(N),
692
+ style: me(e(te)),
693
+ class: "aspect-auto h-[250px] w-full",
694
+ cursor: ""
695
+ }, {
696
+ default: b(() => [
697
+ u(e(Ne), {
698
+ data: e(l),
699
+ margin: { left: -24 },
700
+ "y-domain": [0, e(Te)]
701
+ }, {
702
+ default: b(() => [
703
+ (d(!0), C(ue, null, _e(e(ae), (D, M) => (d(), A(e(Le), {
704
+ key: D.id,
705
+ x: (X, de) => de,
706
+ y: (X) => a(X, M),
707
+ color: (X) => r(X, D.id) > 0 ? e(N)[D.id]?.color : Ge,
708
+ "bar-padding": 0.1,
709
+ "rounded-corners": 2
710
+ }, null, 8, ["x", "y", "color"]))), 128)),
711
+ u(e(ke), {
712
+ type: "x",
713
+ x: (D, M) => M,
714
+ "tick-line": !1,
715
+ "domain-line": !1,
716
+ "grid-line": !1,
717
+ "tick-values": e(ce),
718
+ "tick-format": (D) => e(l)[D]?.time || ""
719
+ }, null, 8, ["x", "tick-values", "tick-format"]),
720
+ u(e(ke), {
721
+ type: "y",
722
+ "num-ticks": 3,
723
+ "tick-line": !1,
724
+ "domain-line": !1
725
+ }),
726
+ u(e(We)),
727
+ u(e(Fe), {
728
+ template: e(Pe)(e(N), e(je), {
729
+ labelFormatter(D) {
730
+ if (D instanceof Date) return "";
731
+ const M = Math.round(D);
732
+ return M >= 0 && M < e(l).length && e(l)[M]?.time || "";
733
+ }
734
+ }),
735
+ color: "#0000"
736
+ }, null, 8, ["template"])
737
+ ]),
738
+ _: 1
739
+ }, 8, ["data", "y-domain"])
740
+ ]),
741
+ _: 1
742
+ }, 8, ["config", "style"])) : (d(), A(ne, {
743
+ key: e(f),
744
+ config: e(N),
745
+ style: me(e(te)),
746
+ class: "aspect-auto h-[250px] w-full",
747
+ cursor: ""
748
+ }, {
749
+ default: b(() => [
750
+ u(e(Ne), {
751
+ data: e(l),
752
+ margin: { left: -24 },
753
+ "y-domain": [0, e(z)]
754
+ }, {
755
+ default: b(() => [
756
+ u(e(Le), {
757
+ x: (D, M) => M,
758
+ y: (D) => D[e(f)] || 0,
759
+ color: (D) => D[e(f)] > 0 ? e(N)[e(f)]?.color : Ge,
760
+ "bar-padding": 0.1,
761
+ "rounded-corners": !1
762
+ }, null, 8, ["x", "y", "color"]),
763
+ u(e(ke), {
764
+ type: "x",
765
+ x: (D, M) => M,
766
+ "tick-line": !1,
767
+ "domain-line": !1,
768
+ "grid-line": !1,
769
+ "tick-values": e(ce),
770
+ "tick-format": (D) => e(l)[D]?.time || ""
771
+ }, null, 8, ["x", "tick-values", "tick-format"]),
772
+ u(e(ke), {
773
+ type: "y",
774
+ "num-ticks": 3,
775
+ "tick-line": !1,
776
+ "domain-line": !1
777
+ }),
778
+ u(e(We)),
779
+ u(e(Fe), {
780
+ template: e(Pe)(e(N), e(je), {
781
+ labelFormatter(D) {
782
+ if (D instanceof Date) return "";
783
+ const M = Math.round(D);
784
+ return M >= 0 && M < e(l).length && e(l)[M]?.time || "";
785
+ }
786
+ }),
787
+ color: "#0000"
788
+ }, null, 8, ["template"])
789
+ ]),
790
+ _: 1
791
+ }, 8, ["data", "y-domain"])
792
+ ]),
793
+ _: 1
794
+ }, 8, ["config", "style"]))
795
+ ]))
796
+ ]),
797
+ _: 1
798
+ })
799
+ ]),
800
+ _: 1
801
+ });
802
+ };
803
+ }
804
+ }), ca = /* @__PURE__ */ Rt(la, [["__scopeId", "data-v-fa0a6ba8"]]), da = { class: "flex flex-row items-center justify-between gap-2" }, ua = { class: "relative mb-4" }, ma = { class: "flex gap-1 mb-4 flex-wrap select-none" }, fa = {
805
+ key: 0,
806
+ class: "mb-3 text-sm text-muted-foreground"
807
+ }, pa = {
808
+ key: 1,
809
+ class: "flex items-center justify-center py-8"
810
+ }, va = {
811
+ key: 2,
812
+ class: "flex flex-col items-center gap-2 text-center py-8 text-muted-foreground"
813
+ }, ga = {
814
+ key: 3,
815
+ class: "text-center py-8 text-muted-foreground"
816
+ }, ha = {
817
+ key: 4,
818
+ class: "space-y-2"
819
+ }, ya = ["onClick"], xa = { class: "flex items-start justify-between" }, ba = { class: "flex-1" }, ka = { class: "font-medium" }, Da = { class: "text-sm text-muted-foreground" }, _a = { class: "text-sm text-muted-foreground" }, Sa = { class: "flex items-center gap-4 flex-wrap" }, Ca = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, wa = { class: "flex items-center gap-2 mt-1 text-xs text-muted-foreground" }, $a = {
820
+ key: 0,
821
+ class: "flex items-center gap-1 mt-1 text-xs text-muted-foreground"
822
+ }, Ma = { class: "text-right" }, Ra = {
823
+ key: 0,
824
+ 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"
825
+ }, Va = {
826
+ key: 1,
827
+ 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"
828
+ }, Ta = {
829
+ key: 2,
830
+ 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"
831
+ }, Ia = {
832
+ key: 3,
833
+ 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"
834
+ }, Aa = {
835
+ key: 4,
836
+ 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"
837
+ }, Ea = {
838
+ key: 5,
839
+ class: "text-sm font-medium mt-1"
840
+ }, za = /* @__PURE__ */ ge({
841
+ __name: "BookingsList",
842
+ props: {
843
+ agendaData: {},
844
+ activeDate: {},
845
+ selectedResource: {},
846
+ resources: {}
847
+ },
848
+ emits: ["resetSelectedResource"],
849
+ setup(p, { emit: h }) {
850
+ const o = p, y = h, { params: v } = Me(), { config: x } = Re(), k = Ve(x.project), l = j([]), i = j(!0), c = j(""), n = j(null), f = j(null), T = P(() => v.value?.id ?? v.id ?? o.agendaData?.id ?? ""), { metadataSchema: _ } = Vt(T), O = P(() => ({
851
+ date: I(o.activeDate),
852
+ resource: null
853
+ }));
854
+ at("event", O);
855
+ const I = (r) => {
856
+ const a = r.getFullYear(), w = String(r.getMonth() + 1).padStart(2, "0"), W = String(r.getDate()).padStart(2, "0");
857
+ return `${a}-${w}-${W}`;
858
+ }, J = P(() => {
859
+ let r = l.value;
860
+ return o.selectedResource && (r = r.filter((a) => a.resourceId === o.selectedResource)), c.value.trim() && (r = new Tt(r, {
861
+ keys: [
862
+ "customerInfo.firstName",
863
+ "customerInfo.lastName",
864
+ "customerInfo.email",
865
+ "customerInfo.phone",
866
+ "resourceName"
867
+ ],
868
+ threshold: 0.3,
869
+ ignoreLocation: !0
870
+ }).search(c.value).map((w) => w.item)), r;
871
+ }), ee = P(() => J.value.filter((r) => z.value.includes(r.reservationStatus))), B = P(() => {
872
+ let r = JSON.parse(JSON.stringify(l.value));
873
+ return o.selectedResource && (r = r.filter((a) => a.resourceId === o.selectedResource)), r.some((a) => a.reservationStatus === "approved" || a.reservationStatus === "needs_approval");
874
+ }), E = P(() => {
875
+ const r = l.value.filter((a) => a.reservationStatus === "approved" || a.reservationStatus === "needs_approval");
876
+ return {
877
+ spots: r.reduce((a, w) => a + (w.spots || 0), 0),
878
+ bookings: r.length
879
+ };
880
+ }), L = () => {
881
+ c.value = "";
882
+ }, z = j(["needs_approval", "approved"]), U = (r) => {
883
+ z.value.includes(r) ? z.value = z.value.filter((a) => a !== r) : z.value.push(r);
884
+ }, g = (r, a, w = a.date) => {
885
+ const W = o.resources.find((F) => F.id === a.resourceId), Y = r.id || r.orderId || a.orderId || "";
886
+ return {
887
+ customerInfo: r.customerInfo,
888
+ amountDue: r.amountDue,
889
+ amountPaid: r.amountPaid,
890
+ status: r.status,
891
+ reservationStatus: a.status,
892
+ subtotal: r.subtotal,
893
+ total: r.total,
894
+ discount: r.discount,
895
+ id: Y,
896
+ res_id: a.id,
897
+ resourceId: a.resourceId,
898
+ spots: a.spots,
899
+ date: w,
900
+ createdAt: r.createdAt,
901
+ startTime: a.timeslot?.startTime,
902
+ endTime: a.timeslot?.endTime,
903
+ reservationPrice: a.totalPrice,
904
+ reservationBasePrice: a.basePrice,
905
+ reservationAddOnsPrice: a.addOnsPrice,
906
+ orderReservationCount: Array.isArray(r.reservations) ? r.reservations.length : void 0,
907
+ pricingOptionId: a.pricingOptionId,
908
+ pricingOption: a.pricingOption,
909
+ resourceName: W?.name,
910
+ resourceColor: W?.color,
911
+ metadata: r.metadata || {},
912
+ reservationMetadata: a.metadata || {},
913
+ refundStatus: a.refundStatus,
914
+ refundedAt: a.refundedAt,
915
+ refundedAmount: a.refundedAmount,
916
+ refunds: Array.isArray(a.refunds) ? a.refunds : [],
917
+ adjustments: r.adjustments || [],
918
+ reservationAdjustments: a.adjustments || []
919
+ };
920
+ }, N = async () => {
921
+ await He(), await new Promise((r) => {
922
+ if (typeof requestAnimationFrame == "function") {
923
+ requestAnimationFrame(() => r());
924
+ return;
925
+ }
926
+ r();
927
+ });
928
+ }, ae = async (r) => {
929
+ const a = await k.get(x.reservationsCollection, r);
930
+ if (!a) return;
931
+ const w = { ...a, id: a.id || r }, W = (w.reservations || []).map((Y) => g(w, Y));
932
+ W.length && (await N(), f.value?.openDialog({
933
+ id: w.id,
934
+ customerInfo: w.customerInfo,
935
+ status: w.status,
936
+ createdAt: w.createdAt,
937
+ metadata: w.metadata || {},
938
+ reservations: W,
939
+ adjustments: w.adjustments || [],
940
+ totalPrice: typeof w.total == "number" ? w.total : W.reduce((Y, F) => Y + (F.reservationPrice || 0), 0),
941
+ totalSpots: W.reduce((Y, F) => Y + (F.spots || 0), 0)
942
+ }));
943
+ }, ce = async (r) => {
944
+ await N(), n.value?.openDialog(r);
945
+ }, fe = (r) => r.orderReservationCount === 1 && typeof r.total == "number" ? r.total : typeof r.reservationPrice == "number" ? r.reservationPrice : null, he = (r) => {
946
+ const a = fe(r);
947
+ return a === null ? null : `€${a.toFixed(2)}`;
948
+ }, te = async () => {
949
+ i.value = !0, l.value = [];
950
+ try {
951
+ const r = v.value.id, a = I(o.activeDate), w = /* @__PURE__ */ new Set();
952
+ o.resources?.forEach((F) => {
953
+ const se = `${F.id}_${a}`;
954
+ w.add(se);
955
+ });
956
+ const W = await k.find(x.reservationsCollection, {
957
+ filters: [
958
+ { field: "agendaId", operator: "==", value: r },
959
+ { field: "status", operator: "==", value: "confirmed" },
960
+ { field: "flattenedReservationDates", operator: "array-contains-any", value: Array.from(w) }
961
+ ]
962
+ });
963
+ let Y = [];
964
+ W.forEach((F) => {
965
+ (F.reservations?.filter((oe) => oe.date === a) || []).forEach((oe) => {
966
+ Y.push(g(F, oe, a));
967
+ });
968
+ }), l.value = Y.sort((F, se) => F.startTime?.localeCompare(se.startTime || "") || 0);
969
+ } catch (r) {
970
+ console.error("Error loading orders:", r), l.value = [];
971
+ } finally {
972
+ i.value = !1;
973
+ }
974
+ };
975
+ return (async () => await te())(), Q(() => o.activeDate, () => {
976
+ te();
977
+ }), (r, a) => {
978
+ const w = V("Badge"), W = V("CardTitle"), Y = V("CardDescription"), F = V("Button"), se = V("CardHeader"), oe = V("Input"), Ie = V("CardContent"), s = V("Card");
979
+ return d(), A(s, null, {
980
+ default: b(() => [
981
+ u(se, null, {
982
+ default: b(() => [
983
+ m("div", da, [
984
+ m("div", null, [
985
+ u(W, { class: "flex items-center gap-2" }, {
986
+ default: b(() => [
987
+ a[9] || (a[9] = q(" Bookings ", -1)),
988
+ e(E).bookings > 0 ? (d(), A(w, {
989
+ key: 0,
990
+ variant: "secondary"
991
+ }, {
992
+ default: b(() => [
993
+ q(R(e(E).bookings), 1)
994
+ ]),
995
+ _: 1
996
+ })) : Z("", !0)
997
+ ]),
998
+ _: 1
999
+ }),
1000
+ u(Y, { class: "flex items-center gap-2 mt-1" }, {
1001
+ default: b(() => [
1002
+ u(e(Be), { size: 14 }),
1003
+ m("span", null, R(e(E).spots) + " total spots", 1)
1004
+ ]),
1005
+ _: 1
1006
+ })
1007
+ ]),
1008
+ u(F, {
1009
+ variant: "ghost",
1010
+ size: "icon",
1011
+ onClick: te,
1012
+ disabled: e(i)
1013
+ }, {
1014
+ default: b(() => [
1015
+ u(e(bt), {
1016
+ size: 16,
1017
+ class: le({ "animate-spin": e(i) })
1018
+ }, null, 8, ["class"])
1019
+ ]),
1020
+ _: 1
1021
+ }, 8, ["disabled"])
1022
+ ])
1023
+ ]),
1024
+ _: 1
1025
+ }),
1026
+ u(Ie, null, {
1027
+ default: b(() => [
1028
+ m("div", ua, [
1029
+ u(e(kt), {
1030
+ size: 16,
1031
+ class: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
1032
+ }),
1033
+ u(oe, {
1034
+ modelValue: e(c),
1035
+ "onUpdate:modelValue": a[0] || (a[0] = (t) => re(c) ? c.value = t : null),
1036
+ placeholder: "Search by name, email, or phone...",
1037
+ class: "pl-9 pr-9"
1038
+ }, null, 8, ["modelValue"]),
1039
+ e(c) ? (d(), A(F, {
1040
+ key: 0,
1041
+ variant: "ghost",
1042
+ size: "icon",
1043
+ class: "absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7",
1044
+ onClick: L
1045
+ }, {
1046
+ default: b(() => [
1047
+ u(e(Dt), { size: 14 })
1048
+ ]),
1049
+ _: 1
1050
+ })) : Z("", !0)
1051
+ ]),
1052
+ m("div", ma, [
1053
+ p.agendaData.needsApproval ? (d(), C("button", {
1054
+ key: 0,
1055
+ onClick: a[1] || (a[1] = (t) => U("needs_approval")),
1056
+ class: le(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !e(z).includes("needs_approval") }])
1057
+ }, [
1058
+ e(z).includes("needs_approval") ? (d(), A(e(ye), {
1059
+ key: 0,
1060
+ size: 12
1061
+ })) : (d(), A(e(xe), {
1062
+ key: 1,
1063
+ size: 12
1064
+ })),
1065
+ q(" Needs Approval (" + R(e(l).filter((t) => t.reservationStatus === "needs_approval").length) + ") ", 1)
1066
+ ], 2)) : Z("", !0),
1067
+ m("button", {
1068
+ onClick: a[2] || (a[2] = (t) => U("approved")),
1069
+ class: le(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !e(z).includes("approved") }])
1070
+ }, [
1071
+ e(z).includes("approved") ? (d(), A(e(ye), {
1072
+ key: 0,
1073
+ size: 12
1074
+ })) : (d(), A(e(xe), {
1075
+ key: 1,
1076
+ size: 12
1077
+ })),
1078
+ q(" Approved (" + R(e(l).filter((t) => t.reservationStatus === "approved").length) + ") ", 1)
1079
+ ], 2),
1080
+ p.agendaData.needsApproval ? (d(), C("button", {
1081
+ key: 1,
1082
+ onClick: a[3] || (a[3] = (t) => U("rejected")),
1083
+ class: le(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !e(z).includes("rejected") }])
1084
+ }, [
1085
+ e(z).includes("rejected") ? (d(), A(e(ye), {
1086
+ key: 0,
1087
+ size: 12
1088
+ })) : (d(), A(e(xe), {
1089
+ key: 1,
1090
+ size: 12
1091
+ })),
1092
+ q(" Rejected (" + R(e(l).filter((t) => t.reservationStatus === "rejected").length) + ") ", 1)
1093
+ ], 2)) : Z("", !0),
1094
+ m("button", {
1095
+ onClick: a[4] || (a[4] = (t) => U("cancelled")),
1096
+ class: le(["flex gap-1.5 items-center px-3 py-1.5 rounded-full text-sm bg-muted", { "opacity-50 hover:opacity-75": !e(z).includes("cancelled") }])
1097
+ }, [
1098
+ e(z).includes("cancelled") ? (d(), A(e(ye), {
1099
+ key: 0,
1100
+ size: 12
1101
+ })) : (d(), A(e(xe), {
1102
+ key: 1,
1103
+ size: 12
1104
+ })),
1105
+ q(" Cancelled (" + R(e(l).filter((t) => t.reservationStatus === "cancelled").length) + ") ", 1)
1106
+ ], 2)
1107
+ ]),
1108
+ e(c) ? (d(), C("div", fa, " Showing " + R(e(ee).length) + " of " + R(e(l).length) + " bookings ", 1)) : Z("", !0),
1109
+ e(i) ? (d(), C("div", pa, [...a[10] || (a[10] = [
1110
+ m("div", { class: "animate-spin rounded-full h-8 w-8 border-b-2 border-primary" }, null, -1)
1111
+ ])])) : e(ee).length === 0 ? (d(), C("div", va, [
1112
+ a[13] || (a[13] = q(" No bookings for this day ", -1)),
1113
+ e(B) ? (d(), A(F, {
1114
+ key: 0,
1115
+ onClick: a[5] || (a[5] = (t) => {
1116
+ z.value = ["needs_approval", "approved"], c.value = "";
1117
+ })
1118
+ }, {
1119
+ default: b(() => [...a[11] || (a[11] = [
1120
+ q("Reset filters", -1)
1121
+ ])]),
1122
+ _: 1
1123
+ })) : Z("", !0),
1124
+ p.selectedResource !== null ? (d(), A(F, {
1125
+ key: 1,
1126
+ onClick: a[6] || (a[6] = (t) => y("resetSelectedResource"))
1127
+ }, {
1128
+ default: b(() => [...a[12] || (a[12] = [
1129
+ q("Reset resource filter", -1)
1130
+ ])]),
1131
+ _: 1
1132
+ })) : Z("", !0)
1133
+ ])) : e(ee).length === 0 ? (d(), C("div", ga, " No bookings match your search ")) : (d(), C("div", ha, [
1134
+ (d(!0), C(ue, null, _e(e(ee), (t) => (d(), C("div", {
1135
+ key: t.res_id || t.id,
1136
+ class: "p-3 border rounded-lg hover:bg-muted/50 transition-colors cursor-pointer",
1137
+ onClick: (S) => e(n)?.openDialog(t)
1138
+ }, [
1139
+ m("div", xa, [
1140
+ m("div", ba, [
1141
+ m("div", ka, R(t.customerInfo.firstName + " " + t.customerInfo.lastName || "Unknown Customer"), 1),
1142
+ m("div", Da, R(t.customerInfo?.email), 1),
1143
+ m("div", _a, R(t.customerInfo?.phone), 1),
1144
+ m("div", Sa, [
1145
+ m("div", Ca, [
1146
+ u(e(_t), { size: 12 }),
1147
+ m("span", null, R(t.startTime) + " - " + R(t.endTime), 1)
1148
+ ]),
1149
+ m("div", wa, [
1150
+ u(e(Be), { size: 12 }),
1151
+ m("span", null, R(t.spots) + " " + R(t.spots === 1 ? "spot" : "spots"), 1)
1152
+ ]),
1153
+ t.resourceName ? (d(), C("div", $a, [
1154
+ m("div", {
1155
+ class: "w-3 h-3 rounded-full",
1156
+ style: me({ backgroundColor: t.resourceColor || "#6b7280" })
1157
+ }, null, 4),
1158
+ m("span", null, R(t.resourceName), 1)
1159
+ ])) : Z("", !0)
1160
+ ]),
1161
+ u(It, {
1162
+ metadata: { ...t.metadata, ...t.reservationMetadata },
1163
+ schema: e(_),
1164
+ "display-filter": ["highlight", "badge"],
1165
+ compact: "",
1166
+ class: "mt-1"
1167
+ }, null, 8, ["metadata", "schema"])
1168
+ ]),
1169
+ m("div", Ma, [
1170
+ t.reservationStatus === "needs_approval" ? (d(), C("span", Ra, "Needs Approval")) : t.reservationStatus === "approved" ? (d(), C("span", Va, "Approved")) : t.reservationStatus === "rejected" ? (d(), C("span", Ta, "Rejected")) : t.reservationStatus === "cancelled" ? (d(), C("span", Ia, "Cancelled")) : (d(), C("span", Aa, "Pending")),
1171
+ he(t) ? (d(), C("div", Ea, R(he(t)), 1)) : Z("", !0)
1172
+ ])
1173
+ ])
1174
+ ], 8, ya))), 128))
1175
+ ]))
1176
+ ]),
1177
+ _: 1
1178
+ }),
1179
+ u(At, {
1180
+ ref_key: "reservationDetailDialog",
1181
+ ref: n,
1182
+ agendaData: p.agendaData,
1183
+ resources: p.resources,
1184
+ "show-order-link": "",
1185
+ onCancelled: te,
1186
+ onConfirmed: te,
1187
+ onRejected: te,
1188
+ onTransferred: te,
1189
+ onOpenOrder: a[7] || (a[7] = (t) => ae(t))
1190
+ }, null, 8, ["agendaData", "resources"]),
1191
+ u(Et, {
1192
+ ref_key: "orderDetailDialog",
1193
+ ref: f,
1194
+ agendaData: p.agendaData,
1195
+ resources: p.resources,
1196
+ onOpenReservation: a[8] || (a[8] = (t) => ce(t))
1197
+ }, null, 8, ["agendaData", "resources"])
1198
+ ]),
1199
+ _: 1
1200
+ });
1201
+ };
1202
+ }
1203
+ }), Oa = { class: "space-y-6" }, Pa = { class: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4" }, ja = { class: "text-2xl font-semibold tracking-tight" }, Ba = { class: "flex flex-col md:flex-row gap-2" }, Na = { class: "grid gap-6 md:grid-cols-2 lg:grid-cols-3" }, Wa = { class: "md:col-span-2 lg:col-span-3" }, Za = /* @__PURE__ */ ge({
1204
+ __name: "index",
1205
+ setup(p) {
1206
+ const { hasPermission: h } = st(), { params: o, resolvePath: y } = Me(), { config: v } = Re(), x = Ve(v.project), k = j(""), l = j(!0), i = j(/* @__PURE__ */ new Date()), c = j(null), n = j("stacked"), f = j(null), T = j([]);
1207
+ return (async () => {
1208
+ try {
1209
+ const O = await x.get(v.agendaCollection, o.value.id);
1210
+ k.value = O?.serviceName || "", f.value = O, T.value = O?.resources?.filter((I) => I.isActive) || [];
1211
+ } catch (O) {
1212
+ console.error("Error loading data:", O);
1213
+ } finally {
1214
+ l.value = !1;
1215
+ }
1216
+ })(), (O, I) => (d(), A(ot, null, {
1217
+ default: b(() => [
1218
+ m("div", Oa, [
1219
+ m("div", Pa, [
1220
+ m("div", null, [
1221
+ m("h1", ja, R(e(k) || "Dashboard"), 1),
1222
+ I[4] || (I[4] = m("p", { class: "text-muted-foreground text-sm mt-1" }, " Overview and analytics for your booking service ", -1))
1223
+ ]),
1224
+ m("div", Ba, [
1225
+ e(h)("manage-reservations") ? (d(), A(zt, {
1226
+ key: 0,
1227
+ "agenda-data": e(f)
1228
+ }, null, 8, ["agenda-data"])) : Z("", !0)
1229
+ ])
1230
+ ]),
1231
+ u(ca, {
1232
+ modelValue: e(i),
1233
+ "onUpdate:modelValue": I[0] || (I[0] = (J) => re(i) ? i.value = J : null),
1234
+ "view-mode": e(n),
1235
+ "onUpdate:viewMode": I[1] || (I[1] = (J) => re(n) ? n.value = J : null),
1236
+ "selected-resource": e(c),
1237
+ "onUpdate:selectedResource": I[2] || (I[2] = (J) => re(c) ? c.value = J : null),
1238
+ "agenda-data": e(f),
1239
+ resources: e(T)
1240
+ }, null, 8, ["modelValue", "view-mode", "selected-resource", "agenda-data", "resources"]),
1241
+ m("div", Na, [
1242
+ m("div", Wa, [
1243
+ e(T).length > 0 ? (d(), A(za, {
1244
+ key: 0,
1245
+ "agenda-data": e(f),
1246
+ "active-date": e(i),
1247
+ "selected-resource": e(c),
1248
+ resources: e(T),
1249
+ onResetSelectedResource: I[3] || (I[3] = (J) => c.value = null)
1250
+ }, null, 8, ["agenda-data", "active-date", "selected-resource", "resources"])) : Z("", !0)
1251
+ ])
1252
+ ])
1253
+ ])
1254
+ ]),
1255
+ _: 1
1256
+ }));
1257
+ }
1258
+ });
1259
+ export {
1260
+ Za as default
1261
+ };