@zonetrix/viewer 2.10.2 → 2.10.4
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.
- package/dist/hooks/useFirebaseSeatStates.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +510 -492
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { jsx as y, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Stage as dt, Layer as
|
|
4
|
-
import { ref as
|
|
1
|
+
import { jsx as y, jsxs as L } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useEffect as W, useRef as A, useCallback as I, useMemo as U, memo as ne, useSyncExternalStore as lt } from "react";
|
|
3
|
+
import { Stage as dt, Layer as Me, Group as ut, Rect as ke, Text as Ee, Circle as ht } from "react-konva";
|
|
4
|
+
import { ref as ve, onValue as Le, off as De, get as ft } from "firebase/database";
|
|
5
5
|
import { fromFirebaseSeatMap as gt } from "@zonetrix/shared";
|
|
6
6
|
function pt(t) {
|
|
7
|
-
const [n,
|
|
7
|
+
const [n, i] = N(null), [r, d] = N(!1), [c, o] = N(null), S = async () => {
|
|
8
8
|
if (t) {
|
|
9
|
-
|
|
9
|
+
d(!0), o(null);
|
|
10
10
|
try {
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
13
|
-
throw new Error(`Failed to fetch config: ${
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
const
|
|
18
|
-
|
|
11
|
+
const h = await fetch(t);
|
|
12
|
+
if (!h.ok)
|
|
13
|
+
throw new Error(`Failed to fetch config: ${h.statusText}`);
|
|
14
|
+
const a = await h.json();
|
|
15
|
+
i(a);
|
|
16
|
+
} catch (h) {
|
|
17
|
+
const a = h instanceof Error ? h : new Error("Unknown error occurred");
|
|
18
|
+
o(a), console.error("Failed to fetch seat map config:", a);
|
|
19
19
|
} finally {
|
|
20
|
-
|
|
20
|
+
d(!1);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
return
|
|
25
|
-
|
|
24
|
+
return W(() => {
|
|
25
|
+
S();
|
|
26
26
|
}, [t]), {
|
|
27
27
|
config: n,
|
|
28
28
|
loading: r,
|
|
29
|
-
error:
|
|
30
|
-
refetch:
|
|
29
|
+
error: c,
|
|
30
|
+
refetch: S
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const [n,
|
|
35
|
-
return
|
|
33
|
+
function bt(t) {
|
|
34
|
+
const [n, i] = N({ width: 0, height: 0 });
|
|
35
|
+
return W(() => {
|
|
36
36
|
const r = t.current;
|
|
37
37
|
if (!r) return;
|
|
38
|
-
const { width:
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
const { width:
|
|
44
|
-
|
|
38
|
+
const { width: d, height: c } = r.getBoundingClientRect();
|
|
39
|
+
d > 0 && c > 0 && i({ width: d, height: c });
|
|
40
|
+
const o = new ResizeObserver((S) => {
|
|
41
|
+
const h = S[0];
|
|
42
|
+
if (!h) return;
|
|
43
|
+
const { width: a, height: s } = h.contentRect;
|
|
44
|
+
a > 0 && s > 0 && i((u) => u.width === a && u.height === s ? u : { width: a, height: s });
|
|
45
45
|
});
|
|
46
|
-
return
|
|
47
|
-
|
|
46
|
+
return o.observe(r), () => {
|
|
47
|
+
o.disconnect();
|
|
48
48
|
};
|
|
49
49
|
}, [t]), n;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function Ie(t, n) {
|
|
52
52
|
return Math.sqrt(Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2));
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function Fe(t, n) {
|
|
55
55
|
return {
|
|
56
56
|
x: (t.x + n.x) / 2,
|
|
57
57
|
y: (t.y + n.y) / 2
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
60
|
+
function yt(t, n) {
|
|
61
|
+
const i = A(null), r = A(null), d = A(1);
|
|
62
|
+
W(() => {
|
|
63
|
+
const c = t.current;
|
|
64
|
+
if (!c || !n.enabled) return;
|
|
65
|
+
const o = c.container(), S = (s) => {
|
|
66
|
+
if (s.touches.length === 2) {
|
|
67
|
+
s.preventDefault();
|
|
68
|
+
const u = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY };
|
|
69
|
+
i.current = Ie(u, f), r.current = Fe(u, f), d.current = n.currentScale;
|
|
70
70
|
}
|
|
71
|
-
},
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const C =
|
|
71
|
+
}, h = (s) => {
|
|
72
|
+
if (s.touches.length !== 2) return;
|
|
73
|
+
s.preventDefault();
|
|
74
|
+
const u = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY }, g = Ie(u, f), x = Fe(u, f);
|
|
75
|
+
if (i.current !== null && r.current !== null) {
|
|
76
|
+
const C = g / i.current, R = Math.min(
|
|
77
77
|
Math.max(n.currentScale * C, n.minScale),
|
|
78
78
|
n.maxScale
|
|
79
|
-
),
|
|
80
|
-
x: (M - n.currentPosition.x) /
|
|
81
|
-
y: (
|
|
82
|
-
},
|
|
83
|
-
x: M -
|
|
84
|
-
y:
|
|
79
|
+
), F = o.getBoundingClientRect(), M = x.x - F.left, k = x.y - F.top, Y = n.currentScale, T = {
|
|
80
|
+
x: (M - n.currentPosition.x) / Y,
|
|
81
|
+
y: (k - n.currentPosition.y) / Y
|
|
82
|
+
}, X = x.x - r.current.x, j = x.y - r.current.y, re = {
|
|
83
|
+
x: M - T.x * R + X,
|
|
84
|
+
y: k - T.y * R + j
|
|
85
85
|
};
|
|
86
|
-
n.onScaleChange(
|
|
86
|
+
n.onScaleChange(R, re), i.current = g, r.current = x;
|
|
87
87
|
}
|
|
88
|
-
},
|
|
89
|
-
|
|
88
|
+
}, a = (s) => {
|
|
89
|
+
s.touches.length < 2 && (i.current = null, r.current = null);
|
|
90
90
|
};
|
|
91
|
-
return
|
|
92
|
-
|
|
91
|
+
return o.addEventListener("touchstart", S, { passive: !1 }), o.addEventListener("touchmove", h, { passive: !1 }), o.addEventListener("touchend", a), () => {
|
|
92
|
+
o.removeEventListener("touchstart", S), o.removeEventListener("touchmove", h), o.removeEventListener("touchend", a);
|
|
93
93
|
};
|
|
94
94
|
}, [t, n]);
|
|
95
95
|
}
|
|
@@ -103,45 +103,45 @@ const vt = {
|
|
|
103
103
|
seatHidden: "#4a4a4a",
|
|
104
104
|
gridLines: "#404040",
|
|
105
105
|
currency: "KD"
|
|
106
|
-
},
|
|
107
|
-
const
|
|
108
|
-
available:
|
|
109
|
-
reserved:
|
|
110
|
-
selected:
|
|
111
|
-
unavailable:
|
|
112
|
-
hidden:
|
|
106
|
+
}, Ne = ne(({ seat: t, state: n, colors: i, onClick: r, onMouseEnter: d, onMouseLeave: c }) => {
|
|
107
|
+
const h = {
|
|
108
|
+
available: i.seatAvailable,
|
|
109
|
+
reserved: i.seatReserved,
|
|
110
|
+
selected: i.seatSelected,
|
|
111
|
+
unavailable: i.seatUnavailable,
|
|
112
|
+
hidden: i.seatHidden
|
|
113
113
|
// Hidden seats are filtered out, but included for type safety
|
|
114
|
-
}[n],
|
|
115
|
-
|
|
116
|
-
}, [t, r,
|
|
117
|
-
|
|
118
|
-
const C =
|
|
119
|
-
C &&
|
|
120
|
-
}, [t,
|
|
121
|
-
|
|
122
|
-
const C =
|
|
114
|
+
}[n], a = n === "available" || n === "selected", s = I(() => {
|
|
115
|
+
a && r(t);
|
|
116
|
+
}, [t, r, a]), u = I((x) => {
|
|
117
|
+
d(t, x);
|
|
118
|
+
const C = x.target.getStage();
|
|
119
|
+
C && a && (C.container().style.cursor = "pointer");
|
|
120
|
+
}, [t, d, a]), f = I((x) => {
|
|
121
|
+
c();
|
|
122
|
+
const C = x.target.getStage();
|
|
123
123
|
C && (C.container().style.cursor = "grab");
|
|
124
|
-
}, [
|
|
124
|
+
}, [c]), g = {
|
|
125
125
|
x: t.position.x,
|
|
126
126
|
y: t.position.y,
|
|
127
|
-
fill:
|
|
127
|
+
fill: h,
|
|
128
128
|
stroke: "#ffffff",
|
|
129
129
|
strokeWidth: 1,
|
|
130
|
-
onClick:
|
|
131
|
-
onTap:
|
|
132
|
-
onMouseEnter:
|
|
133
|
-
onMouseLeave:
|
|
130
|
+
onClick: s,
|
|
131
|
+
onTap: s,
|
|
132
|
+
onMouseEnter: u,
|
|
133
|
+
onMouseLeave: f
|
|
134
134
|
};
|
|
135
135
|
return t.shape === "circle" ? /* @__PURE__ */ y(
|
|
136
136
|
ht,
|
|
137
137
|
{
|
|
138
|
-
...
|
|
138
|
+
...g,
|
|
139
139
|
radius: 12
|
|
140
140
|
}
|
|
141
141
|
) : /* @__PURE__ */ y(
|
|
142
|
-
|
|
142
|
+
ke,
|
|
143
143
|
{
|
|
144
|
-
...
|
|
144
|
+
...g,
|
|
145
145
|
width: 24,
|
|
146
146
|
height: 24,
|
|
147
147
|
offsetX: 12,
|
|
@@ -150,9 +150,9 @@ const vt = {
|
|
|
150
150
|
}
|
|
151
151
|
);
|
|
152
152
|
});
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
const
|
|
153
|
+
Ne.displayName = "ViewerSeat";
|
|
154
|
+
const Te = ne(({ stage: t, stageColor: n }) => {
|
|
155
|
+
const i = (c) => ({
|
|
156
156
|
stage: "🎭",
|
|
157
157
|
table: "⬜",
|
|
158
158
|
wall: "▬",
|
|
@@ -161,10 +161,10 @@ const Ye = ce(({ stage: t, stageColor: n }) => {
|
|
|
161
161
|
bar: "🍷",
|
|
162
162
|
"entry-exit": "🚪",
|
|
163
163
|
custom: "➕"
|
|
164
|
-
})[
|
|
165
|
-
return /* @__PURE__ */
|
|
164
|
+
})[c || "stage"] || "🎭", r = t.config.color || n, d = i(t.config.objectType);
|
|
165
|
+
return /* @__PURE__ */ L(ut, { x: t.position.x, y: t.position.y, rotation: t.config.rotation || 0, children: [
|
|
166
166
|
/* @__PURE__ */ y(
|
|
167
|
-
|
|
167
|
+
ke,
|
|
168
168
|
{
|
|
169
169
|
width: t.config.width,
|
|
170
170
|
height: t.config.height,
|
|
@@ -175,9 +175,9 @@ const Ye = ce(({ stage: t, stageColor: n }) => {
|
|
|
175
175
|
}
|
|
176
176
|
),
|
|
177
177
|
/* @__PURE__ */ y(
|
|
178
|
-
|
|
178
|
+
Ee,
|
|
179
179
|
{
|
|
180
|
-
text:
|
|
180
|
+
text: d,
|
|
181
181
|
x: 0,
|
|
182
182
|
y: 0,
|
|
183
183
|
width: t.config.width,
|
|
@@ -189,7 +189,7 @@ const Ye = ce(({ stage: t, stageColor: n }) => {
|
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
191
|
/* @__PURE__ */ y(
|
|
192
|
-
|
|
192
|
+
Ee,
|
|
193
193
|
{
|
|
194
194
|
text: t.config.label,
|
|
195
195
|
x: 0,
|
|
@@ -205,20 +205,20 @@ const Ye = ce(({ stage: t, stageColor: n }) => {
|
|
|
205
205
|
)
|
|
206
206
|
] });
|
|
207
207
|
});
|
|
208
|
-
|
|
209
|
-
const
|
|
208
|
+
Te.displayName = "ViewerStage";
|
|
209
|
+
const ze = ne(({
|
|
210
210
|
floors: t,
|
|
211
211
|
currentFloorId: n,
|
|
212
|
-
onFloorChange:
|
|
212
|
+
onFloorChange: i,
|
|
213
213
|
showAllOption: r,
|
|
214
|
-
allLabel:
|
|
215
|
-
position:
|
|
216
|
-
className:
|
|
214
|
+
allLabel: d,
|
|
215
|
+
position: c,
|
|
216
|
+
className: o
|
|
217
217
|
}) => {
|
|
218
|
-
const
|
|
219
|
-
() => [...t].sort((
|
|
218
|
+
const S = U(
|
|
219
|
+
() => [...t].sort((f, g) => f.order - g.order),
|
|
220
220
|
[t]
|
|
221
|
-
),
|
|
221
|
+
), a = {
|
|
222
222
|
position: "absolute",
|
|
223
223
|
display: "flex",
|
|
224
224
|
alignItems: "center",
|
|
@@ -233,8 +233,8 @@ const je = ce(({
|
|
|
233
233
|
"top-right": { top: 0, right: 0 },
|
|
234
234
|
"bottom-left": { bottom: 0, left: 0 },
|
|
235
235
|
"bottom-right": { bottom: 0, right: 0 }
|
|
236
|
-
}[
|
|
237
|
-
},
|
|
236
|
+
}[c]
|
|
237
|
+
}, s = {
|
|
238
238
|
padding: "10px 16px",
|
|
239
239
|
fontSize: "14px",
|
|
240
240
|
fontWeight: 500,
|
|
@@ -246,44 +246,44 @@ const je = ce(({
|
|
|
246
246
|
transition: "all 0.2s ease",
|
|
247
247
|
minHeight: "44px",
|
|
248
248
|
touchAction: "manipulation"
|
|
249
|
-
},
|
|
250
|
-
...
|
|
249
|
+
}, u = {
|
|
250
|
+
...s,
|
|
251
251
|
backgroundColor: "#3A7DE5",
|
|
252
252
|
borderColor: "#3A7DE5"
|
|
253
253
|
};
|
|
254
|
-
return /* @__PURE__ */
|
|
254
|
+
return /* @__PURE__ */ L("div", { className: o, style: a, children: [
|
|
255
255
|
r && /* @__PURE__ */ y(
|
|
256
256
|
"button",
|
|
257
257
|
{
|
|
258
258
|
type: "button",
|
|
259
|
-
onClick: () =>
|
|
260
|
-
style: n === null ?
|
|
261
|
-
children:
|
|
259
|
+
onClick: () => i(null),
|
|
260
|
+
style: n === null ? u : s,
|
|
261
|
+
children: d
|
|
262
262
|
}
|
|
263
263
|
),
|
|
264
|
-
|
|
264
|
+
S.map((f) => /* @__PURE__ */ y(
|
|
265
265
|
"button",
|
|
266
266
|
{
|
|
267
267
|
type: "button",
|
|
268
|
-
onClick: () =>
|
|
269
|
-
style: n ===
|
|
270
|
-
children:
|
|
268
|
+
onClick: () => i(f.id),
|
|
269
|
+
style: n === f.id ? u : s,
|
|
270
|
+
children: f.name
|
|
271
271
|
},
|
|
272
|
-
|
|
272
|
+
f.id
|
|
273
273
|
))
|
|
274
274
|
] });
|
|
275
275
|
});
|
|
276
|
-
|
|
277
|
-
const
|
|
276
|
+
ze.displayName = "FloorSelectorBar";
|
|
277
|
+
const Ae = ne(({
|
|
278
278
|
scale: t,
|
|
279
279
|
minScale: n,
|
|
280
|
-
maxScale:
|
|
280
|
+
maxScale: i,
|
|
281
281
|
onZoomIn: r,
|
|
282
|
-
onZoomOut:
|
|
283
|
-
position:
|
|
284
|
-
className:
|
|
282
|
+
onZoomOut: d,
|
|
283
|
+
position: c,
|
|
284
|
+
className: o
|
|
285
285
|
}) => {
|
|
286
|
-
const
|
|
286
|
+
const h = {
|
|
287
287
|
position: "absolute",
|
|
288
288
|
display: "flex",
|
|
289
289
|
flexDirection: "column",
|
|
@@ -298,8 +298,8 @@ const We = ce(({
|
|
|
298
298
|
"top-right": { top: 0, right: 0 },
|
|
299
299
|
"bottom-left": { bottom: 0, left: 0 },
|
|
300
300
|
"bottom-right": { bottom: 0, right: 0 }
|
|
301
|
-
}[
|
|
302
|
-
},
|
|
301
|
+
}[c]
|
|
302
|
+
}, a = {
|
|
303
303
|
width: "44px",
|
|
304
304
|
height: "44px",
|
|
305
305
|
minWidth: "44px",
|
|
@@ -316,19 +316,19 @@ const We = ce(({
|
|
|
316
316
|
justifyContent: "center",
|
|
317
317
|
transition: "all 0.2s ease",
|
|
318
318
|
touchAction: "manipulation"
|
|
319
|
-
},
|
|
320
|
-
...
|
|
319
|
+
}, s = {
|
|
320
|
+
...a,
|
|
321
321
|
opacity: 0.4,
|
|
322
322
|
cursor: "not-allowed"
|
|
323
|
-
},
|
|
324
|
-
return /* @__PURE__ */
|
|
323
|
+
}, u = t < i, f = t > n;
|
|
324
|
+
return /* @__PURE__ */ L("div", { className: o, style: h, children: [
|
|
325
325
|
/* @__PURE__ */ y(
|
|
326
326
|
"button",
|
|
327
327
|
{
|
|
328
328
|
type: "button",
|
|
329
329
|
onClick: r,
|
|
330
|
-
disabled: !
|
|
331
|
-
style:
|
|
330
|
+
disabled: !u,
|
|
331
|
+
style: u ? a : s,
|
|
332
332
|
title: "Zoom In",
|
|
333
333
|
children: "+"
|
|
334
334
|
}
|
|
@@ -337,32 +337,32 @@ const We = ce(({
|
|
|
337
337
|
"button",
|
|
338
338
|
{
|
|
339
339
|
type: "button",
|
|
340
|
-
onClick:
|
|
341
|
-
disabled: !
|
|
342
|
-
style:
|
|
340
|
+
onClick: d,
|
|
341
|
+
disabled: !f,
|
|
342
|
+
style: f ? a : s,
|
|
343
343
|
title: "Zoom Out",
|
|
344
344
|
children: "−"
|
|
345
345
|
}
|
|
346
346
|
)
|
|
347
347
|
] });
|
|
348
348
|
});
|
|
349
|
-
|
|
350
|
-
const
|
|
349
|
+
Ae.displayName = "ZoomControls";
|
|
350
|
+
const Xe = ne(({
|
|
351
351
|
visible: t,
|
|
352
352
|
x: n,
|
|
353
|
-
y:
|
|
353
|
+
y: i,
|
|
354
354
|
seat: r,
|
|
355
|
-
currency:
|
|
356
|
-
state:
|
|
355
|
+
currency: d,
|
|
356
|
+
state: c
|
|
357
357
|
}) => {
|
|
358
358
|
if (!t || !r) return null;
|
|
359
|
-
const
|
|
359
|
+
const o = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), S = {
|
|
360
360
|
position: "fixed",
|
|
361
361
|
left: `${n + 15}px`,
|
|
362
|
-
top: `${
|
|
362
|
+
top: `${i + 15}px`,
|
|
363
363
|
zIndex: 1e3,
|
|
364
364
|
pointerEvents: "none"
|
|
365
|
-
},
|
|
365
|
+
}, h = {
|
|
366
366
|
backgroundColor: "rgba(26, 26, 26, 0.95)",
|
|
367
367
|
color: "#fff",
|
|
368
368
|
border: "1px solid #444",
|
|
@@ -371,512 +371,530 @@ const Pe = ce(({
|
|
|
371
371
|
fontSize: "13px",
|
|
372
372
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
|
|
373
373
|
minWidth: "140px"
|
|
374
|
-
},
|
|
374
|
+
}, a = {
|
|
375
375
|
color: "#9ca3af",
|
|
376
376
|
marginRight: "4px"
|
|
377
|
-
},
|
|
377
|
+
}, s = {
|
|
378
378
|
fontWeight: 600
|
|
379
|
-
},
|
|
379
|
+
}, u = {
|
|
380
380
|
color: "#4ade80",
|
|
381
381
|
fontWeight: 600
|
|
382
|
-
},
|
|
382
|
+
}, f = {
|
|
383
383
|
fontSize: "11px",
|
|
384
384
|
color: "#6b7280",
|
|
385
385
|
textTransform: "capitalize",
|
|
386
386
|
marginTop: "4px"
|
|
387
387
|
};
|
|
388
|
-
return /* @__PURE__ */ y("div", { style:
|
|
389
|
-
r.sectionName && /* @__PURE__ */
|
|
390
|
-
/* @__PURE__ */ y("span", { style:
|
|
391
|
-
/* @__PURE__ */ y("span", { style: { ...
|
|
388
|
+
return /* @__PURE__ */ y("div", { style: S, children: /* @__PURE__ */ L("div", { style: h, children: [
|
|
389
|
+
r.sectionName && /* @__PURE__ */ L("div", { style: { marginBottom: "4px" }, children: [
|
|
390
|
+
/* @__PURE__ */ y("span", { style: a, children: "Section:" }),
|
|
391
|
+
/* @__PURE__ */ y("span", { style: { ...s, color: "#3b82f6" }, children: r.sectionName })
|
|
392
392
|
] }),
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
-
/* @__PURE__ */ y("span", { style:
|
|
395
|
-
/* @__PURE__ */ y("span", { style:
|
|
393
|
+
/* @__PURE__ */ L("div", { style: { marginBottom: "4px" }, children: [
|
|
394
|
+
/* @__PURE__ */ y("span", { style: a, children: "Seat:" }),
|
|
395
|
+
/* @__PURE__ */ y("span", { style: s, children: o })
|
|
396
396
|
] }),
|
|
397
|
-
r.price !== void 0 && r.price > 0 &&
|
|
398
|
-
/* @__PURE__ */ y("span", { style:
|
|
399
|
-
/* @__PURE__ */
|
|
400
|
-
|
|
397
|
+
r.price !== void 0 && r.price > 0 && c === "available" && /* @__PURE__ */ L("div", { style: { marginBottom: "4px" }, children: [
|
|
398
|
+
/* @__PURE__ */ y("span", { style: a, children: "Price:" }),
|
|
399
|
+
/* @__PURE__ */ L("span", { style: u, children: [
|
|
400
|
+
d,
|
|
401
401
|
" ",
|
|
402
402
|
r.price.toFixed(2)
|
|
403
403
|
] })
|
|
404
404
|
] }),
|
|
405
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ L("div", { style: f, children: [
|
|
406
406
|
"Status: ",
|
|
407
|
-
|
|
407
|
+
c
|
|
408
408
|
] })
|
|
409
409
|
] }) });
|
|
410
410
|
});
|
|
411
|
-
|
|
412
|
-
const
|
|
411
|
+
Xe.displayName = "SeatTooltip";
|
|
412
|
+
const It = ({
|
|
413
413
|
config: t,
|
|
414
414
|
configUrl: n,
|
|
415
|
-
floorId:
|
|
415
|
+
floorId: i,
|
|
416
416
|
onFloorChange: r,
|
|
417
|
-
reservedSeats:
|
|
418
|
-
unavailableSeats:
|
|
419
|
-
selectedSeats:
|
|
420
|
-
myReservedSeats:
|
|
421
|
-
onSeatSelect:
|
|
422
|
-
onSeatDeselect:
|
|
423
|
-
onSelectionChange:
|
|
424
|
-
colorOverrides:
|
|
425
|
-
showTooltip:
|
|
426
|
-
zoomEnabled:
|
|
427
|
-
className:
|
|
417
|
+
reservedSeats: d = [],
|
|
418
|
+
unavailableSeats: c = [],
|
|
419
|
+
selectedSeats: o,
|
|
420
|
+
myReservedSeats: S = [],
|
|
421
|
+
onSeatSelect: h,
|
|
422
|
+
onSeatDeselect: a,
|
|
423
|
+
onSelectionChange: s,
|
|
424
|
+
colorOverrides: u,
|
|
425
|
+
showTooltip: f = !0,
|
|
426
|
+
zoomEnabled: g = !0,
|
|
427
|
+
className: x = "",
|
|
428
428
|
onConfigLoad: C,
|
|
429
|
-
onError:
|
|
429
|
+
onError: R,
|
|
430
430
|
// Floor selector props
|
|
431
|
-
showFloorSelector:
|
|
431
|
+
showFloorSelector: F,
|
|
432
432
|
floorSelectorPosition: M = "top-left",
|
|
433
|
-
floorSelectorClassName:
|
|
434
|
-
showAllFloorsOption:
|
|
435
|
-
allFloorsLabel:
|
|
436
|
-
fitToView:
|
|
433
|
+
floorSelectorClassName: k,
|
|
434
|
+
showAllFloorsOption: Y = !0,
|
|
435
|
+
allFloorsLabel: T = "All",
|
|
436
|
+
fitToView: X = !0,
|
|
437
437
|
fitPadding: j = 40,
|
|
438
438
|
// Zoom controls
|
|
439
|
-
showZoomControls:
|
|
440
|
-
zoomControlsPosition:
|
|
441
|
-
zoomControlsClassName:
|
|
442
|
-
minZoom:
|
|
443
|
-
maxZoom:
|
|
444
|
-
zoomStep:
|
|
439
|
+
showZoomControls: re = !0,
|
|
440
|
+
zoomControlsPosition: Ye = "bottom-right",
|
|
441
|
+
zoomControlsClassName: je,
|
|
442
|
+
minZoom: xe,
|
|
443
|
+
maxZoom: B = 3,
|
|
444
|
+
zoomStep: oe = 0.25,
|
|
445
445
|
// Touch gestures
|
|
446
|
-
touchEnabled:
|
|
446
|
+
touchEnabled: Pe = !0
|
|
447
447
|
}) => {
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
}, [
|
|
451
|
-
() =>
|
|
452
|
-
[
|
|
453
|
-
),
|
|
454
|
-
if (!
|
|
455
|
-
let e =
|
|
456
|
-
return
|
|
457
|
-
(
|
|
448
|
+
const he = A(null), we = A(null), E = bt(we), [O, Ce] = N(/* @__PURE__ */ new Set()), [D, G] = N(1), [z, H] = N({ x: 0, y: 0 }), [We, Be] = N(null), [$e, Ue] = N(1), ie = A({ width: 0, height: 0 }), [Z, Re] = N({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: He, loading: Ve, error: K } = pt(n), p = t || He, fe = i !== void 0, P = fe ? i || null : We, se = o !== void 0, Oe = I((e) => {
|
|
449
|
+
fe || Be(e), r?.(e);
|
|
450
|
+
}, [fe, r]), ge = p?.floors || [], _e = F !== void 0 ? F : ge.length > 1, ae = U(
|
|
451
|
+
() => p ? { ...p.colors, ...u } : { ...vt, ...u },
|
|
452
|
+
[p, u]
|
|
453
|
+
), _ = U(() => {
|
|
454
|
+
if (!p) return [];
|
|
455
|
+
let e = p.seats.filter((l) => l.state !== "hidden");
|
|
456
|
+
return P && (e = e.filter(
|
|
457
|
+
(l) => l.floorId === P || !l.floorId && P === "floor_default"
|
|
458
458
|
)), e;
|
|
459
|
-
}, [
|
|
460
|
-
(e) => e.floorId ===
|
|
461
|
-
) :
|
|
462
|
-
if (!
|
|
459
|
+
}, [p, P]), ce = U(() => p?.stages ? P ? p.stages.filter(
|
|
460
|
+
(e) => e.floorId === P || !e.floorId && P === "floor_default"
|
|
461
|
+
) : p.stages : [], [p, P]), $ = U(() => {
|
|
462
|
+
if (!p || _.length === 0 && ce.length === 0)
|
|
463
463
|
return null;
|
|
464
464
|
const e = 12;
|
|
465
|
-
let
|
|
466
|
-
return
|
|
467
|
-
|
|
468
|
-
}),
|
|
469
|
-
|
|
470
|
-
}), { minX:
|
|
471
|
-
}, [
|
|
472
|
-
|
|
473
|
-
if (!
|
|
474
|
-
const e = Math.abs(E.width -
|
|
475
|
-
if (!(
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
}, [
|
|
480
|
-
const
|
|
481
|
-
const e = new Set(
|
|
482
|
-
return { reserved: e, unavailable:
|
|
483
|
-
}, [
|
|
484
|
-
const
|
|
485
|
-
return
|
|
486
|
-
}, [
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}, [
|
|
490
|
-
|
|
491
|
-
}, [
|
|
492
|
-
|
|
493
|
-
}, [
|
|
494
|
-
const
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
465
|
+
let l = 1 / 0, b = 1 / 0, v = -1 / 0, m = -1 / 0;
|
|
466
|
+
return _.forEach((w) => {
|
|
467
|
+
l = Math.min(l, w.position.x - e), b = Math.min(b, w.position.y - e), v = Math.max(v, w.position.x + e), m = Math.max(m, w.position.y + e);
|
|
468
|
+
}), ce.forEach((w) => {
|
|
469
|
+
l = Math.min(l, w.position.x), b = Math.min(b, w.position.y), v = Math.max(v, w.position.x + (w.config?.width || 200)), m = Math.max(m, w.position.y + (w.config?.height || 100));
|
|
470
|
+
}), { minX: l, minY: b, maxX: v, maxY: m, width: v - l, height: m - b };
|
|
471
|
+
}, [p, _, ce]);
|
|
472
|
+
W(() => {
|
|
473
|
+
if (!X || !p || !$ || E.width === 0 || E.height === 0) return;
|
|
474
|
+
const e = Math.abs(E.width - ie.current.width), l = Math.abs(E.height - ie.current.height);
|
|
475
|
+
if (!(ie.current.width === 0) && e < 10 && l < 10) return;
|
|
476
|
+
ie.current = E;
|
|
477
|
+
const v = E.width, m = E.height, w = v - j * 2, ee = m - j * 2, le = w / $.width, be = ee / $.height, de = Math.min(le, be, B), rt = $.minX + $.width / 2, ot = $.minY + $.height / 2, it = v / 2, st = m / 2, at = it - rt * de, ct = st - ot * de;
|
|
478
|
+
G(de), H({ x: at, y: ct }), Ue(de);
|
|
479
|
+
}, [X, p, $, j, B, E, P]);
|
|
480
|
+
const V = U(() => {
|
|
481
|
+
const e = new Set(d), l = new Set(c), b = new Set(S);
|
|
482
|
+
return { reserved: e, unavailable: l, myReserved: b };
|
|
483
|
+
}, [d, c, S]), pe = U(() => o ? new Set(o) : null, [o]), J = I((e) => {
|
|
484
|
+
const l = e.id, b = e.seatNumber || "";
|
|
485
|
+
return V.unavailable.has(l) || V.unavailable.has(b) ? "unavailable" : V.reserved.has(l) || V.reserved.has(b) ? "reserved" : V.myReserved.has(l) || V.myReserved.has(b) || O.has(l) ? "selected" : e.state;
|
|
486
|
+
}, [V, O]);
|
|
487
|
+
W(() => {
|
|
488
|
+
p && C && C(p);
|
|
489
|
+
}, [p, C]), W(() => {
|
|
490
|
+
K && R && R(K);
|
|
491
|
+
}, [K, R]), W(() => {
|
|
492
|
+
se && pe && Ce(pe);
|
|
493
|
+
}, [se, pe]);
|
|
494
|
+
const qe = I((e) => {
|
|
495
|
+
const l = J(e);
|
|
496
|
+
if (l !== "available" && l !== "selected")
|
|
497
497
|
return;
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
return
|
|
502
|
-
}),
|
|
503
|
-
}, [
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}, [
|
|
507
|
-
const
|
|
508
|
-
if (!
|
|
509
|
-
const e = Math.min(
|
|
510
|
-
if (e !==
|
|
511
|
-
const
|
|
512
|
-
x: (
|
|
513
|
-
y: (
|
|
498
|
+
const b = O.has(e.id);
|
|
499
|
+
se || Ce((v) => {
|
|
500
|
+
const m = new Set(v);
|
|
501
|
+
return b ? m.delete(e.id) : m.add(e.id), m;
|
|
502
|
+
}), b ? a?.(e) : (h?.(e), h || console.log("Seat selected:", e));
|
|
503
|
+
}, [J, O, se, h, a]), Q = U(() => p ? _.filter((e) => O.has(e.id)) : [], [_, O]);
|
|
504
|
+
W(() => {
|
|
505
|
+
s?.(Q);
|
|
506
|
+
}, [Q, s]);
|
|
507
|
+
const q = xe !== void 0 ? xe : $e, Ge = I(() => {
|
|
508
|
+
if (!g) return;
|
|
509
|
+
const e = Math.min(D + oe, B);
|
|
510
|
+
if (e !== D) {
|
|
511
|
+
const l = E.width || p?.canvas.width || 800, b = E.height || p?.canvas.height || 600, v = l / 2, m = b / 2, w = {
|
|
512
|
+
x: (v - z.x) / D,
|
|
513
|
+
y: (m - z.y) / D
|
|
514
514
|
};
|
|
515
|
-
|
|
516
|
-
x:
|
|
517
|
-
y:
|
|
515
|
+
G(e), H({
|
|
516
|
+
x: v - w.x * e,
|
|
517
|
+
y: m - w.y * e
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
|
-
}, [
|
|
521
|
-
if (!
|
|
522
|
-
const e = Math.max(
|
|
523
|
-
if (e !==
|
|
524
|
-
const
|
|
525
|
-
x: (
|
|
526
|
-
y: (
|
|
520
|
+
}, [g, D, oe, B, E, p, z]), Ze = I(() => {
|
|
521
|
+
if (!g) return;
|
|
522
|
+
const e = Math.max(D - oe, q);
|
|
523
|
+
if (e !== D) {
|
|
524
|
+
const l = E.width || p?.canvas.width || 800, b = E.height || p?.canvas.height || 600, v = l / 2, m = b / 2, w = {
|
|
525
|
+
x: (v - z.x) / D,
|
|
526
|
+
y: (m - z.y) / D
|
|
527
527
|
};
|
|
528
|
-
|
|
529
|
-
x:
|
|
530
|
-
y:
|
|
528
|
+
G(e), H({
|
|
529
|
+
x: v - w.x * e,
|
|
530
|
+
y: m - w.y * e
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
|
-
}, [
|
|
534
|
-
|
|
533
|
+
}, [g, D, oe, q, E, p, z]), Ke = I((e) => {
|
|
534
|
+
H({
|
|
535
535
|
x: e.target.x(),
|
|
536
536
|
y: e.target.y()
|
|
537
537
|
});
|
|
538
|
-
}, []),
|
|
539
|
-
if (!
|
|
538
|
+
}, []), Je = I((e) => {
|
|
539
|
+
if (!g) return;
|
|
540
540
|
e.evt.preventDefault();
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
543
|
-
const
|
|
544
|
-
if (!
|
|
545
|
-
const
|
|
546
|
-
x: (
|
|
547
|
-
y: (
|
|
548
|
-
},
|
|
549
|
-
x:
|
|
550
|
-
y:
|
|
541
|
+
const l = he.current;
|
|
542
|
+
if (!l) return;
|
|
543
|
+
const b = l.scaleX(), v = l.getPointerPosition();
|
|
544
|
+
if (!v) return;
|
|
545
|
+
const m = 1.1, w = e.evt.deltaY > 0 ? b / m : b * m, ee = Math.min(Math.max(w, q), B), le = {
|
|
546
|
+
x: (v.x - z.x) / b,
|
|
547
|
+
y: (v.y - z.y) / b
|
|
548
|
+
}, be = {
|
|
549
|
+
x: v.x - le.x * ee,
|
|
550
|
+
y: v.y - le.y * ee
|
|
551
551
|
};
|
|
552
|
-
|
|
553
|
-
}, [
|
|
554
|
-
|
|
555
|
-
enabled:
|
|
556
|
-
minScale:
|
|
557
|
-
maxScale:
|
|
558
|
-
currentScale:
|
|
559
|
-
currentPosition:
|
|
560
|
-
onScaleChange: (e,
|
|
561
|
-
|
|
552
|
+
G(ee), H(be);
|
|
553
|
+
}, [g, z, q, B]);
|
|
554
|
+
yt(he, {
|
|
555
|
+
enabled: Pe && g,
|
|
556
|
+
minScale: q,
|
|
557
|
+
maxScale: B,
|
|
558
|
+
currentScale: D,
|
|
559
|
+
currentPosition: z,
|
|
560
|
+
onScaleChange: (e, l) => {
|
|
561
|
+
G(e), H(l);
|
|
562
562
|
},
|
|
563
563
|
onPositionChange: (e) => {
|
|
564
|
-
|
|
564
|
+
H(e);
|
|
565
565
|
}
|
|
566
566
|
});
|
|
567
|
-
const
|
|
568
|
-
if (!
|
|
569
|
-
const
|
|
570
|
-
if (!p) return;
|
|
571
|
-
const b = p.getPointerPosition();
|
|
567
|
+
const Qe = I((e, l) => {
|
|
568
|
+
if (!f) return;
|
|
569
|
+
const b = l.target.getStage();
|
|
572
570
|
if (!b) return;
|
|
573
|
-
const v =
|
|
574
|
-
|
|
571
|
+
const v = b.getPointerPosition();
|
|
572
|
+
if (!v) return;
|
|
573
|
+
const m = b.container().getBoundingClientRect();
|
|
574
|
+
Re({
|
|
575
575
|
visible: !0,
|
|
576
|
-
x:
|
|
577
|
-
y:
|
|
576
|
+
x: m.left + v.x,
|
|
577
|
+
y: m.top + v.y,
|
|
578
578
|
seat: e,
|
|
579
|
-
state:
|
|
579
|
+
state: J(e)
|
|
580
580
|
});
|
|
581
|
-
}, [
|
|
582
|
-
|
|
581
|
+
}, [f, J]), et = I(() => {
|
|
582
|
+
Re((e) => ({ ...e, visible: !1 }));
|
|
583
583
|
}, []);
|
|
584
|
-
if (
|
|
585
|
-
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${
|
|
586
|
-
if (
|
|
587
|
-
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${
|
|
584
|
+
if (Ve)
|
|
585
|
+
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${x}`, children: /* @__PURE__ */ y("p", { children: "Loading seat map..." }) });
|
|
586
|
+
if (K)
|
|
587
|
+
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${x}`, children: /* @__PURE__ */ L("p", { className: "text-red-500", children: [
|
|
588
588
|
"Error loading seat map: ",
|
|
589
|
-
|
|
589
|
+
K.message
|
|
590
590
|
] }) });
|
|
591
|
-
if (!
|
|
592
|
-
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${
|
|
593
|
-
const
|
|
594
|
-
return /* @__PURE__ */
|
|
591
|
+
if (!p)
|
|
592
|
+
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${x}`, children: /* @__PURE__ */ y("p", { children: "No configuration provided" }) });
|
|
593
|
+
const tt = E.width || p.canvas.width, nt = E.height || p.canvas.height;
|
|
594
|
+
return /* @__PURE__ */ L(
|
|
595
595
|
"div",
|
|
596
596
|
{
|
|
597
|
-
ref:
|
|
598
|
-
className: `relative ${
|
|
597
|
+
ref: we,
|
|
598
|
+
className: `relative ${x}`,
|
|
599
599
|
style: { width: "100%", height: "100%" },
|
|
600
600
|
children: [
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
_e && ge.length > 0 && /* @__PURE__ */ y(
|
|
602
|
+
ze,
|
|
603
603
|
{
|
|
604
|
-
floors:
|
|
605
|
-
currentFloorId:
|
|
606
|
-
onFloorChange:
|
|
607
|
-
showAllOption:
|
|
608
|
-
allLabel:
|
|
604
|
+
floors: ge,
|
|
605
|
+
currentFloorId: P,
|
|
606
|
+
onFloorChange: Oe,
|
|
607
|
+
showAllOption: Y,
|
|
608
|
+
allLabel: T,
|
|
609
609
|
position: M,
|
|
610
|
-
className:
|
|
610
|
+
className: k
|
|
611
611
|
}
|
|
612
612
|
),
|
|
613
|
-
/* @__PURE__ */
|
|
613
|
+
/* @__PURE__ */ L(
|
|
614
614
|
dt,
|
|
615
615
|
{
|
|
616
|
-
ref:
|
|
617
|
-
width:
|
|
618
|
-
height:
|
|
619
|
-
scaleX:
|
|
620
|
-
scaleY:
|
|
621
|
-
x:
|
|
622
|
-
y:
|
|
616
|
+
ref: he,
|
|
617
|
+
width: tt,
|
|
618
|
+
height: nt,
|
|
619
|
+
scaleX: D,
|
|
620
|
+
scaleY: D,
|
|
621
|
+
x: z.x,
|
|
622
|
+
y: z.y,
|
|
623
623
|
draggable: !0,
|
|
624
624
|
onDragEnd: Ke,
|
|
625
|
-
onWheel:
|
|
626
|
-
style: { backgroundColor:
|
|
625
|
+
onWheel: Je,
|
|
626
|
+
style: { backgroundColor: p.canvas.backgroundColor, cursor: "grab" },
|
|
627
627
|
children: [
|
|
628
|
-
/* @__PURE__ */ y(
|
|
629
|
-
|
|
628
|
+
/* @__PURE__ */ y(Me, { listening: !1, children: ce.map((e) => /* @__PURE__ */ y(
|
|
629
|
+
Te,
|
|
630
630
|
{
|
|
631
631
|
stage: e,
|
|
632
|
-
stageColor:
|
|
632
|
+
stageColor: ae.stageColor
|
|
633
633
|
},
|
|
634
634
|
e.id
|
|
635
635
|
)) }),
|
|
636
|
-
/* @__PURE__ */ y(
|
|
637
|
-
|
|
636
|
+
/* @__PURE__ */ y(Me, { children: _.map((e) => /* @__PURE__ */ y(
|
|
637
|
+
Ne,
|
|
638
638
|
{
|
|
639
639
|
seat: e,
|
|
640
|
-
state:
|
|
641
|
-
colors:
|
|
642
|
-
onClick:
|
|
643
|
-
onMouseEnter:
|
|
644
|
-
onMouseLeave:
|
|
640
|
+
state: J(e),
|
|
641
|
+
colors: ae,
|
|
642
|
+
onClick: qe,
|
|
643
|
+
onMouseEnter: Qe,
|
|
644
|
+
onMouseLeave: et
|
|
645
645
|
},
|
|
646
646
|
e.id
|
|
647
647
|
)) })
|
|
648
648
|
]
|
|
649
649
|
}
|
|
650
650
|
),
|
|
651
|
-
|
|
652
|
-
|
|
651
|
+
f && /* @__PURE__ */ y(
|
|
652
|
+
Xe,
|
|
653
653
|
{
|
|
654
|
-
visible:
|
|
655
|
-
x:
|
|
656
|
-
y:
|
|
657
|
-
seat:
|
|
658
|
-
currency:
|
|
659
|
-
state:
|
|
654
|
+
visible: Z.visible,
|
|
655
|
+
x: Z.x,
|
|
656
|
+
y: Z.y,
|
|
657
|
+
seat: Z.seat,
|
|
658
|
+
currency: ae.currency,
|
|
659
|
+
state: Z.state
|
|
660
660
|
}
|
|
661
661
|
),
|
|
662
|
-
|
|
663
|
-
|
|
662
|
+
re && g && /* @__PURE__ */ y(
|
|
663
|
+
Ae,
|
|
664
664
|
{
|
|
665
|
-
scale:
|
|
666
|
-
minScale:
|
|
667
|
-
maxScale:
|
|
668
|
-
onZoomIn:
|
|
665
|
+
scale: D,
|
|
666
|
+
minScale: q,
|
|
667
|
+
maxScale: B,
|
|
668
|
+
onZoomIn: Ge,
|
|
669
669
|
onZoomOut: Ze,
|
|
670
|
-
position:
|
|
671
|
-
className:
|
|
670
|
+
position: Ye,
|
|
671
|
+
className: je
|
|
672
672
|
}
|
|
673
673
|
),
|
|
674
|
-
|
|
675
|
-
/* @__PURE__ */
|
|
674
|
+
Q.length > 0 && /* @__PURE__ */ L("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
|
|
675
|
+
/* @__PURE__ */ L("h3", { className: "font-semibold mb-2", children: [
|
|
676
676
|
"Selected Seats (",
|
|
677
|
-
|
|
677
|
+
Q.length,
|
|
678
678
|
")"
|
|
679
679
|
] }),
|
|
680
|
-
/* @__PURE__ */ y("div", { className: "max-h-48 overflow-y-auto space-y-1", children:
|
|
680
|
+
/* @__PURE__ */ y("div", { className: "max-h-48 overflow-y-auto space-y-1", children: Q.map((e) => /* @__PURE__ */ L("div", { className: "text-sm", children: [
|
|
681
681
|
e.seatNumber,
|
|
682
|
-
e.price && ` - ${
|
|
682
|
+
e.price && ` - ${ae.currency} ${e.price.toFixed(2)}`
|
|
683
683
|
] }, e.id)) })
|
|
684
684
|
] })
|
|
685
685
|
]
|
|
686
686
|
}
|
|
687
687
|
);
|
|
688
688
|
};
|
|
689
|
-
let
|
|
689
|
+
let te = null;
|
|
690
690
|
function Ft(t) {
|
|
691
|
-
|
|
691
|
+
te = t;
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
if (!
|
|
693
|
+
function me() {
|
|
694
|
+
if (!te)
|
|
695
695
|
throw new Error(
|
|
696
696
|
"Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
|
|
697
697
|
);
|
|
698
|
-
return
|
|
698
|
+
return te;
|
|
699
699
|
}
|
|
700
|
-
function
|
|
701
|
-
return
|
|
700
|
+
function Se() {
|
|
701
|
+
return te !== null;
|
|
702
702
|
}
|
|
703
|
-
function
|
|
704
|
-
|
|
703
|
+
function kt() {
|
|
704
|
+
te = null;
|
|
705
705
|
}
|
|
706
|
-
function
|
|
706
|
+
function ye(t, n) {
|
|
707
707
|
if (t.length !== n.length) return !1;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return !0;
|
|
708
|
+
const i = [...t].sort(), r = [...n].sort();
|
|
709
|
+
return i.every((d, c) => d === r[c]);
|
|
711
710
|
}
|
|
712
|
-
function
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
711
|
+
function mt(t, n) {
|
|
712
|
+
const i = [], r = [], d = [];
|
|
713
|
+
return Object.entries(t).forEach(([c, o]) => {
|
|
714
|
+
o && typeof o == "object" && o.state && (o.state === "unavailable" ? d.push(c) : o.state === "reserved" && (n && o.userId === n ? i.push(c) : r.push(c)));
|
|
715
|
+
}), {
|
|
716
|
+
myReserved: i.sort(),
|
|
717
|
+
otherReserved: r.sort(),
|
|
718
|
+
unavailable: d.sort()
|
|
719
|
+
};
|
|
720
720
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
721
|
+
const ue = {
|
|
722
|
+
states: null,
|
|
723
|
+
loading: !0,
|
|
724
|
+
error: null,
|
|
725
|
+
lastUpdated: null,
|
|
726
|
+
myReservedSeats: [],
|
|
727
|
+
otherReservedSeats: [],
|
|
728
|
+
unavailableSeats: []
|
|
729
|
+
};
|
|
730
|
+
function St(t) {
|
|
731
|
+
const { seatMapId: n, currentUserId: i, enabled: r = !0, onStateChange: d, onError: c } = t, o = A({ ...ue }), S = A(d), h = A(c), a = A(i);
|
|
732
|
+
S.current = d, h.current = c, a.current = i;
|
|
733
|
+
const s = I(
|
|
734
|
+
(x) => {
|
|
735
|
+
if (!r || !n)
|
|
736
|
+
return o.current = { ...ue, loading: !1 }, () => {
|
|
737
|
+
};
|
|
738
|
+
if (!Se())
|
|
739
|
+
return o.current = {
|
|
740
|
+
...ue,
|
|
741
|
+
loading: !1,
|
|
742
|
+
error: new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")
|
|
743
|
+
}, () => {
|
|
744
|
+
};
|
|
745
|
+
const C = me(), R = ve(C, `seatmaps/${n}/seat_states`);
|
|
746
|
+
return Le(R, (k) => {
|
|
747
|
+
const T = k.val() || {}, X = mt(T, a.current), j = o.current;
|
|
748
|
+
(j.loading || !ye(j.myReservedSeats, X.myReserved) || !ye(j.otherReservedSeats, X.otherReserved) || !ye(j.unavailableSeats, X.unavailable)) && (o.current = {
|
|
749
|
+
states: T,
|
|
750
|
+
loading: !1,
|
|
751
|
+
error: null,
|
|
752
|
+
lastUpdated: Date.now(),
|
|
753
|
+
myReservedSeats: X.myReserved,
|
|
754
|
+
otherReservedSeats: X.otherReserved,
|
|
755
|
+
unavailableSeats: X.unavailable
|
|
756
|
+
}, S.current?.(T), x());
|
|
757
|
+
}, (k) => {
|
|
758
|
+
o.current = {
|
|
759
|
+
...o.current,
|
|
760
|
+
loading: !1,
|
|
761
|
+
error: k
|
|
762
|
+
}, h.current?.(k), x();
|
|
763
|
+
}), () => {
|
|
764
|
+
De(R);
|
|
765
|
+
};
|
|
766
|
+
},
|
|
767
|
+
[n, r, i]
|
|
768
|
+
// Include currentUserId to re-derive on user change
|
|
769
|
+
), u = I(() => o.current, []), f = I(() => ue, []), g = lt(s, u, f);
|
|
770
|
+
return {
|
|
771
|
+
states: g.states,
|
|
772
|
+
loading: g.loading,
|
|
773
|
+
error: g.error,
|
|
774
|
+
lastUpdated: g.lastUpdated,
|
|
775
|
+
myReservedSeats: g.myReservedSeats,
|
|
776
|
+
otherReservedSeats: g.otherReservedSeats,
|
|
777
|
+
unavailableSeats: g.unavailableSeats,
|
|
760
778
|
// Legacy alias
|
|
761
|
-
reservedSeats:
|
|
779
|
+
reservedSeats: g.otherReservedSeats
|
|
762
780
|
};
|
|
763
781
|
}
|
|
764
782
|
function xt(t) {
|
|
765
783
|
const {
|
|
766
784
|
seatMapId: n,
|
|
767
|
-
enabled:
|
|
785
|
+
enabled: i = !0,
|
|
768
786
|
subscribeToChanges: r = !1,
|
|
769
|
-
onConfigLoad:
|
|
770
|
-
onError:
|
|
771
|
-
} = t, [
|
|
772
|
-
|
|
773
|
-
const
|
|
787
|
+
onConfigLoad: d,
|
|
788
|
+
onError: c
|
|
789
|
+
} = t, [o, S] = N(null), [h, a] = N(!0), [s, u] = N(null), f = A(d), g = A(c);
|
|
790
|
+
f.current = d, g.current = c;
|
|
791
|
+
const x = I(async () => {
|
|
774
792
|
if (!n) return;
|
|
775
|
-
if (!
|
|
776
|
-
|
|
793
|
+
if (!Se()) {
|
|
794
|
+
u(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")), a(!1);
|
|
777
795
|
return;
|
|
778
796
|
}
|
|
779
|
-
const C =
|
|
797
|
+
const C = me(), R = ve(C, `seatmaps/${n}`);
|
|
780
798
|
try {
|
|
781
|
-
|
|
782
|
-
const M = (await ft(
|
|
799
|
+
a(!0), u(null);
|
|
800
|
+
const M = (await ft(R)).val();
|
|
783
801
|
if (M) {
|
|
784
|
-
const
|
|
785
|
-
|
|
802
|
+
const k = gt(M);
|
|
803
|
+
S(k), f.current?.(k);
|
|
786
804
|
} else
|
|
787
|
-
|
|
788
|
-
} catch (
|
|
789
|
-
const M =
|
|
790
|
-
|
|
805
|
+
u(new Error(`Seat map ${n} not found in Firebase`));
|
|
806
|
+
} catch (F) {
|
|
807
|
+
const M = F instanceof Error ? F : new Error("Unknown error");
|
|
808
|
+
u(M), g.current?.(M);
|
|
791
809
|
} finally {
|
|
792
|
-
|
|
810
|
+
a(!1);
|
|
793
811
|
}
|
|
794
812
|
}, [n]);
|
|
795
|
-
return
|
|
796
|
-
if (!
|
|
797
|
-
|
|
813
|
+
return W(() => {
|
|
814
|
+
if (!i || !n) {
|
|
815
|
+
a(!1);
|
|
798
816
|
return;
|
|
799
817
|
}
|
|
800
|
-
if (
|
|
801
|
-
const C =
|
|
802
|
-
let
|
|
803
|
-
return
|
|
804
|
-
if (
|
|
805
|
-
|
|
818
|
+
if (x(), r && Se()) {
|
|
819
|
+
const C = me(), R = ve(C, `seatmaps/${n}/meta/updated_at`);
|
|
820
|
+
let F = !0, M = null;
|
|
821
|
+
return Le(R, (Y) => {
|
|
822
|
+
if (F) {
|
|
823
|
+
F = !1, M = Y.val();
|
|
806
824
|
return;
|
|
807
825
|
}
|
|
808
|
-
const
|
|
809
|
-
|
|
826
|
+
const T = Y.val();
|
|
827
|
+
Y.exists() && T !== M && (M = T, x());
|
|
810
828
|
}), () => {
|
|
811
|
-
|
|
829
|
+
De(R);
|
|
812
830
|
};
|
|
813
831
|
}
|
|
814
|
-
}, [n,
|
|
815
|
-
config:
|
|
816
|
-
loading:
|
|
817
|
-
error:
|
|
818
|
-
refetch:
|
|
832
|
+
}, [n, i, r]), {
|
|
833
|
+
config: o,
|
|
834
|
+
loading: h,
|
|
835
|
+
error: s,
|
|
836
|
+
refetch: x
|
|
819
837
|
};
|
|
820
838
|
}
|
|
821
|
-
function
|
|
839
|
+
function Lt(t) {
|
|
822
840
|
const {
|
|
823
841
|
seatMapId: n,
|
|
824
|
-
userId:
|
|
842
|
+
userId: i,
|
|
825
843
|
enabled: r = !0,
|
|
826
|
-
subscribeToDesignChanges:
|
|
827
|
-
onConfigLoad:
|
|
828
|
-
onStateChange:
|
|
829
|
-
onError:
|
|
844
|
+
subscribeToDesignChanges: d = !1,
|
|
845
|
+
onConfigLoad: c,
|
|
846
|
+
onStateChange: o,
|
|
847
|
+
onError: S
|
|
830
848
|
} = t, {
|
|
831
|
-
config:
|
|
832
|
-
loading:
|
|
833
|
-
error:
|
|
834
|
-
refetch:
|
|
849
|
+
config: h,
|
|
850
|
+
loading: a,
|
|
851
|
+
error: s,
|
|
852
|
+
refetch: u
|
|
835
853
|
} = xt({
|
|
836
854
|
seatMapId: n,
|
|
837
855
|
enabled: r,
|
|
838
|
-
subscribeToChanges:
|
|
839
|
-
onConfigLoad:
|
|
840
|
-
onError:
|
|
856
|
+
subscribeToChanges: d,
|
|
857
|
+
onConfigLoad: c,
|
|
858
|
+
onError: S
|
|
841
859
|
}), {
|
|
842
|
-
states:
|
|
843
|
-
loading:
|
|
844
|
-
error:
|
|
860
|
+
states: f,
|
|
861
|
+
loading: g,
|
|
862
|
+
error: x,
|
|
845
863
|
lastUpdated: C,
|
|
846
|
-
myReservedSeats:
|
|
847
|
-
otherReservedSeats:
|
|
864
|
+
myReservedSeats: R,
|
|
865
|
+
otherReservedSeats: F,
|
|
848
866
|
unavailableSeats: M,
|
|
849
|
-
reservedSeats:
|
|
850
|
-
} =
|
|
867
|
+
reservedSeats: k
|
|
868
|
+
} = St({
|
|
851
869
|
seatMapId: n,
|
|
852
|
-
currentUserId:
|
|
870
|
+
currentUserId: i,
|
|
853
871
|
enabled: r,
|
|
854
|
-
onStateChange:
|
|
855
|
-
onError:
|
|
872
|
+
onStateChange: o,
|
|
873
|
+
onError: S
|
|
856
874
|
});
|
|
857
875
|
return {
|
|
858
|
-
config:
|
|
859
|
-
loading:
|
|
860
|
-
error:
|
|
861
|
-
myReservedSeats:
|
|
862
|
-
otherReservedSeats:
|
|
876
|
+
config: h,
|
|
877
|
+
loading: a || g,
|
|
878
|
+
error: s || x,
|
|
879
|
+
myReservedSeats: R,
|
|
880
|
+
otherReservedSeats: F,
|
|
863
881
|
unavailableSeats: M,
|
|
864
|
-
reservedSeats:
|
|
865
|
-
seatStates:
|
|
882
|
+
reservedSeats: k,
|
|
883
|
+
seatStates: f,
|
|
866
884
|
lastUpdated: C,
|
|
867
|
-
refetch:
|
|
885
|
+
refetch: u
|
|
868
886
|
};
|
|
869
887
|
}
|
|
870
888
|
export {
|
|
871
889
|
vt as DEFAULT_COLORS,
|
|
872
|
-
|
|
873
|
-
|
|
890
|
+
It as SeatMapViewer,
|
|
891
|
+
kt as clearFirebaseInstance,
|
|
874
892
|
Ft as initializeFirebaseForViewer,
|
|
875
|
-
|
|
893
|
+
Se as isFirebaseInitialized,
|
|
876
894
|
pt as useConfigFetcher,
|
|
877
|
-
|
|
895
|
+
bt as useContainerSize,
|
|
878
896
|
xt as useFirebaseConfig,
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
897
|
+
St as useFirebaseSeatStates,
|
|
898
|
+
Lt as useRealtimeSeatMap,
|
|
899
|
+
yt as useTouchGestures
|
|
882
900
|
};
|