@zonetrix/viewer 2.8.1 → 2.10.0

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