@zonetrix/viewer 2.10.0 → 2.10.1

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