seat-editor 3.3.35 → 3.3.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/app/constant.d.ts +3 -0
  2. package/dist/app/constant.js +2 -0
  3. package/dist/app/layout.d.ts +1 -1
  4. package/dist/app/layout.js +22 -0
  5. package/dist/app/new-board/page.d.ts +1 -1
  6. package/dist/app/new-board/page.js +58 -0
  7. package/dist/app/old-board/page.d.ts +1 -2
  8. package/dist/app/old-board/page.js +377 -0
  9. package/dist/app/only-view/chair.d.ts +1 -1
  10. package/dist/app/only-view/chair.js +2 -10
  11. package/dist/app/only-view/page.d.ts +1 -1
  12. package/dist/app/only-view/page.js +226 -0
  13. package/dist/app/only-view/user.d.ts +1 -1
  14. package/dist/app/only-view/user.js +2 -10
  15. package/dist/app/page.d.ts +1 -1
  16. package/dist/app/page.js +8 -0
  17. package/dist/app/test/page.d.ts +1 -2
  18. package/dist/app/test/page.js +43 -0
  19. package/dist/app/v2/page.d.ts +1 -1
  20. package/dist/app/v2/page.js +8 -0
  21. package/dist/components/button-tools/index.d.ts +1 -1
  22. package/dist/components/button-tools/index.js +11 -0
  23. package/dist/components/form-tools/label.d.ts +1 -1
  24. package/dist/components/form-tools/label.js +21 -0
  25. package/dist/components/form-tools/shape.d.ts +1 -1
  26. package/dist/components/form-tools/shape.js +69 -0
  27. package/dist/components/input/number-indicator.d.ts +1 -1
  28. package/dist/components/input/number-indicator.js +27 -0
  29. package/dist/components/joystick/index.d.ts +1 -2
  30. package/dist/components/joystick/index.js +48 -0
  31. package/dist/components/layer/index.d.ts +1 -1
  32. package/dist/components/layer/index.js +295 -0
  33. package/dist/components/layer-v2/index.d.ts +1 -1
  34. package/dist/components/layer-v2/index.js +282 -0
  35. package/dist/components/layer-v3/index.d.ts +1 -1
  36. package/dist/components/layer-v3/index.js +483 -0
  37. package/dist/components/layer-v4/index.d.ts +1 -1
  38. package/dist/components/layer-v4/index.js +924 -0
  39. package/dist/components/lib/index.d.ts +1 -1
  40. package/dist/components/lib/index.js +28 -0
  41. package/dist/components/modal-preview/index.d.ts +1 -1
  42. package/dist/components/modal-preview/index.js +10 -0
  43. package/dist/features/board/index.d.ts +1 -1
  44. package/dist/features/board/index.js +666 -0
  45. package/dist/features/board-v2/index.d.ts +1 -2
  46. package/dist/features/board-v2/index.js +807 -0
  47. package/dist/features/board-v3/icons.js +16 -0
  48. package/dist/features/board-v3/index.d.ts +1 -1
  49. package/dist/features/board-v3/index.js +1587 -0
  50. package/dist/features/navbar/index.d.ts +1 -1
  51. package/dist/features/navbar/index.js +6 -0
  52. package/dist/features/package/index.d.ts +1 -1
  53. package/dist/features/package/index.js +166 -0
  54. package/dist/features/panel/index.d.ts +1 -1
  55. package/dist/features/panel/index.js +243 -0
  56. package/dist/features/panel/select-tool.d.ts +1 -1
  57. package/dist/features/panel/select-tool.js +57 -0
  58. package/dist/features/panel/selected-group.d.ts +1 -1
  59. package/dist/features/panel/selected-group.js +35 -0
  60. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  61. package/dist/features/panel/square-circle-tool.js +8 -0
  62. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  63. package/dist/features/panel/table-seat-circle.js +9 -0
  64. package/dist/features/panel/table-seat-square.d.ts +1 -1
  65. package/dist/features/panel/table-seat-square.js +9 -0
  66. package/dist/features/panel/text-tool.d.ts +1 -1
  67. package/dist/features/panel/text-tool.js +22 -0
  68. package/dist/features/panel/upload-tool.d.ts +1 -1
  69. package/dist/features/panel/upload-tool.js +150 -0
  70. package/dist/features/side-tool/index.d.ts +1 -1
  71. package/dist/features/side-tool/index.js +365 -0
  72. package/dist/features/view-only/index.d.ts +1 -1
  73. package/dist/features/view-only/index.js +198 -0
  74. package/dist/features/view-only-2/index.d.ts +84 -14
  75. package/dist/features/view-only-2/index.js +558 -0
  76. package/dist/features/view-only-3/index.d.ts +1 -1
  77. package/dist/features/view-only-3/index.js +577 -0
  78. package/dist/provider/antd-provider.js +43 -0
  79. package/dist/provider/redux-provider.d.ts +1 -1
  80. package/dist/provider/redux-provider.js +7 -0
  81. package/dist/provider/store-provider.d.ts +1 -1
  82. package/dist/provider/store-provider.js +9 -0
  83. package/package.json +1 -1
@@ -0,0 +1,924 @@
1
+ "use client";
2
+ import { createElement as _createElement } from "react";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { isEmpty, omit } from "lodash";
5
+ import { arcByDirection, distributeWithSpacing } from "../layer-v3/utils";
6
+ import { PRIVILEGED_TAGS, tagsDummy } from "./constant";
7
+ import { useAppSelector } from "../../hooks/use-redux";
8
+ import { RsvpIcons } from "../../features/board-v3/icons";
9
+ const toKebabCase = (str) => str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
10
+ const iconNames = [
11
+ "upcoming",
12
+ "late",
13
+ "overtime",
14
+ "overlapping",
15
+ "hold",
16
+ "reserved",
17
+ "armchair",
18
+ "cheque",
19
+ "people",
20
+ ];
21
+ const dummyIconTags = iconNames === null || iconNames === void 0 ? void 0 : iconNames.map((item) => {
22
+ const Icon = RsvpIcons === null || RsvpIcons === void 0 ? void 0 : RsvpIcons[item];
23
+ return {
24
+ key: item,
25
+ icon: _jsx(Icon, {}),
26
+ };
27
+ });
28
+ const getIconFromId = (data) => {
29
+ const id = String(data);
30
+ let hash = 0;
31
+ for (let i = 0; i < id.length; i++) {
32
+ hash += id.charCodeAt(i);
33
+ }
34
+ return iconNames[hash % iconNames.length];
35
+ };
36
+ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags = [], }) => {
37
+ const { isShowTagType } = useAppSelector((state) => state.board);
38
+ const showLabels = !["type-1", "type-2"].includes(isShowTagType) && !iconTags;
39
+ const renderShape = (item) => {
40
+ var _a, _b, _c, _d, _e, _f;
41
+ const { id, x, y, width, height, fill, opacity, rotate = 0, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, seatFill, src, tags, gapTags, label, points, seatPositions, radius, } = item;
42
+ const renderTags = (data) => {
43
+ var _a;
44
+ const tags = data !== null && data !== void 0 ? data : tagsDummy(((_a = labels === null || labels === void 0 ? void 0 : labels[0]) === null || _a === void 0 ? void 0 : _a.label) || "Table", getIconFromId(id));
45
+ const privileged = !isEmpty(privilegedTags)
46
+ ? privilegedTags
47
+ : isShowTagType === "type-1"
48
+ ? PRIVILEGED_TAGS["CURRENT_TIME"]
49
+ : isShowTagType === "type-2"
50
+ ? PRIVILEGED_TAGS["NEXT_3_RESERVATION"]
51
+ : undefined;
52
+ if (tags && (tags === null || tags === void 0 ? void 0 : tags.length) > 0) {
53
+ const gapBetweenTags = Number(gapTags || 20);
54
+ const defaultFontSize = Number(fontSize || 12);
55
+ // Hitung total tinggi semua grup tag (buat center vertikal)
56
+ const totalTagHeight = (tags === null || tags === void 0 ? void 0 : tags.filter((tag) => privileged === null || privileged === void 0 ? void 0 : privileged.find((p) => p.key === tag.key)).reduce((sum, tag) => {
57
+ var _a;
58
+ const items = tag.items || [];
59
+ const isColumn = (_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column");
60
+ const tagHeight = isColumn
61
+ ? items.length * defaultFontSize + 2 * (Number(tag.gap) || 2)
62
+ : defaultFontSize; // horizontal = 1 line
63
+ return sum + tagHeight + gapBetweenTags;
64
+ }, 0)) - gapBetweenTags;
65
+ const startY = Number(height) / 4 - totalTagHeight / 3; // titik awal supaya semua di tengah
66
+ let currentY = startY;
67
+ return tags
68
+ .filter((tag) => privileged === null || privileged === void 0 ? void 0 : privileged.find((p) => p.key === tag.key))
69
+ .map((tag, tagIndex) => {
70
+ var _a;
71
+ const itemsPriv = privileged[tagIndex].items;
72
+ const direction = ((_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column"))
73
+ ? "column"
74
+ : "flex";
75
+ const gap = Number(tag.gap || 2);
76
+ const items = tag.items || [];
77
+ const fontSize = Number(defaultFontSize);
78
+ const isColumn = direction === "column";
79
+ const groupHeight = isColumn
80
+ ? items.length * fontSize + 2 * gap
81
+ : fontSize;
82
+ const centerX = width / 2;
83
+ const centerY = currentY + groupHeight;
84
+ // naikkan posisi Y untuk grup berikutnya
85
+ currentY += groupHeight + gapBetweenTags;
86
+ const elements = items
87
+ .filter((item) => itemsPriv.includes(item.type))
88
+ .map((item, i) => {
89
+ var _a, _b;
90
+ const offsetY = isColumn
91
+ ? i * (fontSize + gap) - groupHeight / 2 + fontSize / 2
92
+ : 0;
93
+ const offsetX = !isColumn
94
+ ? i * (fontSize + gap) - (1 * (fontSize + gap)) / 2
95
+ : 0;
96
+ const posX = centerX + offsetX + Number((_a = tag.offsetX) !== null && _a !== void 0 ? _a : 0);
97
+ const posY = centerY + offsetY + Number((_b = tag.offsetY) !== null && _b !== void 0 ? _b : 0);
98
+ const renderSymbol = (symbol) => {
99
+ if (!symbol)
100
+ return null;
101
+ const { position = "right", size = (item === null || item === void 0 ? void 0 : item.fontSize) || Number(fontSize), gap: symbolGap = 0, } = symbol;
102
+ const sizeFont = (item === null || item === void 0 ? void 0 : item.fontSize) || Number(fontSize) / 3;
103
+ let offsetSymbolX = 0;
104
+ let offsetSymbolY = 0;
105
+ switch (position) {
106
+ case "right":
107
+ offsetSymbolX = size + symbolGap;
108
+ break;
109
+ case "left":
110
+ offsetSymbolX = -(size + symbolGap);
111
+ break;
112
+ case "top":
113
+ offsetSymbolY = -(size + symbolGap);
114
+ break;
115
+ case "bottom":
116
+ offsetSymbolY = size + symbolGap;
117
+ break;
118
+ case "right-top":
119
+ offsetSymbolX = size + symbolGap;
120
+ offsetSymbolY = -(size / 4);
121
+ break;
122
+ case "right-bottom":
123
+ offsetSymbolX = size + symbolGap;
124
+ offsetSymbolY = size / 4;
125
+ break;
126
+ case "left-top":
127
+ offsetSymbolX = -size - symbolGap;
128
+ offsetSymbolY = -(size / 4);
129
+ break;
130
+ case "left-bottom":
131
+ offsetSymbolX = -size - symbolGap;
132
+ offsetSymbolY = size / 4;
133
+ break;
134
+ }
135
+ return (_createElement("tspan", Object.assign({}, symbol, { key: `symbol-${tagIndex}-${i}`, x: posX + offsetSymbolX, y: posY + offsetSymbolY, textAnchor: "middle", dominantBaseline: "middle", fontSize: `${sizeFont}px` }), symbol.value));
136
+ };
137
+ if (item.type === "icon") {
138
+ const icons = iconTags !== null && iconTags !== void 0 ? iconTags : dummyIconTags;
139
+ const iconTag = icons === null || icons === void 0 ? void 0 : icons.find((icon) => icon.key === item.value);
140
+ if (!iconTag)
141
+ return null;
142
+ return (_createElement("g", Object.assign({}, item, { key: `icon-${tagIndex}-${i}`, transform: `translate(${posX - 10}, ${posY - 10})` }), iconTag.icon));
143
+ }
144
+ if (item.type === "text") {
145
+ return (_createElement("text", Object.assign({}, item, { key: `text-${tagIndex}-${i}`, x: posX, y: posY, textAnchor: "middle", dominantBaseline: "middle", fontSize: (Number(defaultFontSize) * 3) / 4 }),
146
+ item.value,
147
+ " ",
148
+ renderSymbol(item === null || item === void 0 ? void 0 : item.symbol)));
149
+ }
150
+ return null;
151
+ });
152
+ return (_jsx("g", { pointerEvents: "none", children: elements }, `group-${tagIndex}`));
153
+ });
154
+ }
155
+ };
156
+ let commonProps = {
157
+ fill,
158
+ opacity,
159
+ stroke,
160
+ strokeWidth,
161
+ };
162
+ const hasSelected = (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.id) === id;
163
+ if (hasSelected) {
164
+ const eventSelectedStyles = eventMatchTable === null || eventMatchTable === void 0 ? void 0 : eventMatchTable.find((style) => style.event === "selected");
165
+ commonProps = Object.assign(Object.assign({}, commonProps), eventSelectedStyles === null || eventSelectedStyles === void 0 ? void 0 : eventSelectedStyles.properties);
166
+ }
167
+ // helper: highlight / unhighlight dengan enter-counter
168
+ let properties = {};
169
+ const highlightGroup = (group, eventType) => {
170
+ if (!group)
171
+ return;
172
+ onHighlightGroup === null || onHighlightGroup === void 0 ? void 0 : onHighlightGroup(group, eventType);
173
+ eventMatchTable === null || eventMatchTable === void 0 ? void 0 : eventMatchTable.forEach((styleConfig) => {
174
+ if (styleConfig.event === eventType) {
175
+ properties = omit(styleConfig.properties || {}, "points");
176
+ const hasStroke = (properties === null || properties === void 0 ? void 0 : properties.stroke) || (commonProps === null || commonProps === void 0 ? void 0 : commonProps.stroke);
177
+ const hasStrokeWidth = properties === null || properties === void 0 ? void 0 : properties.strokeWidth;
178
+ if (hasStrokeWidth && !hasStroke) {
179
+ properties.stroke = "#E1E3EA";
180
+ }
181
+ }
182
+ });
183
+ if (isEmpty(properties))
184
+ return;
185
+ // counter
186
+ const count = Number(group.dataset.dragEnterCount || "0") + 1;
187
+ group.dataset.dragEnterCount = String(count);
188
+ // selalu ubah warna, tapi simpan original hanya sekali
189
+ ["rect", "circle"].forEach((selector) => {
190
+ const el = group.querySelector(selector);
191
+ if (!el)
192
+ return;
193
+ Object.entries(properties).forEach(([key]) => {
194
+ el.dataset[key] = el.getAttribute(key) || "";
195
+ });
196
+ Object.entries(properties).forEach(([key, value]) => {
197
+ el.setAttribute(toKebabCase(key), value);
198
+ });
199
+ });
200
+ };
201
+ const unhighlightGroup = (group) => {
202
+ if (!group)
203
+ return;
204
+ const count = Math.max(0, Number(group.dataset.dragEnterCount || "0") - 1);
205
+ group.dataset.dragEnterCount = String(count);
206
+ // restore hanya saat counter = 0
207
+ if (count === 0) {
208
+ ["rect", "circle"].forEach((selector) => {
209
+ const el = group.querySelector(selector);
210
+ if (!el)
211
+ return;
212
+ // bersihkan data
213
+ const dataset = el.dataset;
214
+ Object.entries(dataset).forEach(([key, value]) => {
215
+ el.setAttribute(toKebabCase(key), value);
216
+ delete el.dataset[key];
217
+ properties = {};
218
+ });
219
+ });
220
+ delete group.dataset.dragEnterCount;
221
+ }
222
+ };
223
+ const forceRestoreGroup = (group, type) => {
224
+ // langsung restore (dipanggil pada drop)
225
+ onForceRestoreGroup === null || onForceRestoreGroup === void 0 ? void 0 : onForceRestoreGroup(group, type);
226
+ ["rect", "circle"].forEach((selector) => {
227
+ const el = group === null || group === void 0 ? void 0 : group.querySelector(selector);
228
+ if (!el)
229
+ return;
230
+ const dataset = el.dataset;
231
+ Object.entries(dataset).forEach(([key, value]) => {
232
+ el.setAttribute(toKebabCase(key), value);
233
+ delete el.dataset[key];
234
+ properties = {};
235
+ });
236
+ });
237
+ delete group.dataset.dragEnterCount;
238
+ };
239
+ const transformRotate = `rotate(${rotate} ${x + width / 2} ${y + height / 2})`;
240
+ switch (shape) {
241
+ case "square":
242
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: { pointerEvents: "all" }, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
243
+ const group = e.currentTarget;
244
+ highlightGroup(group, "dragenter");
245
+ }, onDragOver: (e) => {
246
+ e.preventDefault(); // agar drop diterima
247
+ }, onDragLeave: (e) => {
248
+ const group = e.currentTarget;
249
+ unhighlightGroup(group);
250
+ }, onDrop: (e) => {
251
+ const group = e.currentTarget;
252
+ // restore langsung dan reset
253
+ forceRestoreGroup(group, "drop");
254
+ }, onPointerOver: (e) => {
255
+ // e.preventDefault(); // penting
256
+ const group = e.currentTarget;
257
+ highlightGroup(group, "pointerover");
258
+ }, onPointerOut: (e) => {
259
+ const group = e.currentTarget;
260
+ unhighlightGroup(group);
261
+ }, onPointerUp: (e) => {
262
+ const group = e.currentTarget;
263
+ // restore langsung dan reset
264
+ forceRestoreGroup(group, "pointerup");
265
+ }, onPointerDown: (e) => {
266
+ const group = e.currentTarget;
267
+ highlightGroup(group, "pointerdown");
268
+ },
269
+ // onPointerEnter={(e) => {
270
+ // const group = e.currentTarget as SVGGElement;
271
+ // highlightGroup(group, "pointerenter");
272
+ // }}
273
+ onPointerLeave: (e) => {
274
+ const group = e.currentTarget;
275
+ unhighlightGroup(group);
276
+ }, onMouseEnter: (e) => {
277
+ // e.preventDefault(); // penting
278
+ const group = e.currentTarget;
279
+ highlightGroup(group, "mouseenter");
280
+ }, onMouseLeave: (e) => {
281
+ const group = e.currentTarget;
282
+ unhighlightGroup(group);
283
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0,0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, fill: fill, rx: radius }, omit(item, ["x", "y", "label", "points", "tags"]), commonProps), `${id}-rect`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, pointerEvents: "none", children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
284
+ var _a, _b, _c, _d, _e, _f, _g;
285
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
286
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
287
+ return (_createElement("text", Object.assign({ pointerEvents: "none" }, omit(commonProps, [
288
+ "opacity",
289
+ "stroke",
290
+ "strokeWidth",
291
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
292
+ }) }))] }) }, id));
293
+ case "polygon":
294
+ const finalPoint = points.map((p) => `${p.x},${p.y}`).join(" ");
295
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsx("g", { transform: `rotate(${rotation}, 0, 0)`, children: _createElement("polygon", Object.assign({}, commonProps, { key: id, points: finalPoint, x: "0", y: "0" })) }) }, id));
296
+ case "circle":
297
+ return (_jsxs("g", { style: { pointerEvents: "all" }, "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
298
+ e.preventDefault(); // penting
299
+ const group = e.currentTarget;
300
+ highlightGroup(group, "dragenter");
301
+ }, onDragOver: (e) => {
302
+ e.preventDefault(); // agar drop diterima
303
+ }, onDragLeave: (e) => {
304
+ const group = e.currentTarget;
305
+ unhighlightGroup(group);
306
+ }, onDrop: (e) => {
307
+ e.preventDefault();
308
+ const group = e.currentTarget;
309
+ // restore langsung dan reset
310
+ forceRestoreGroup(group);
311
+ }, onPointerOver: (e) => {
312
+ e.preventDefault(); // penting
313
+ const group = e.currentTarget;
314
+ highlightGroup(group, "pointerover");
315
+ }, onPointerOut: (e) => {
316
+ const group = e.currentTarget;
317
+ unhighlightGroup(group);
318
+ }, onPointerUp: (e) => {
319
+ e.preventDefault();
320
+ const group = e.currentTarget;
321
+ // restore langsung dan reset
322
+ forceRestoreGroup(group);
323
+ }, onMouseDown: (e) => {
324
+ e.preventDefault();
325
+ const group = e.currentTarget;
326
+ highlightGroup(group, "mousedown");
327
+ }, onMouseEnter: (e) => {
328
+ // e.preventDefault(); // penting
329
+ const group = e.currentTarget;
330
+ highlightGroup(group, "mouseenter");
331
+ }, onMouseLeave: (e) => {
332
+ const group = e.currentTarget;
333
+ unhighlightGroup(group);
334
+ }, children: [" ", _jsxs("g", { transform: `rotate(${-rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps, omit(item, ["x", "y", "label", "points", "tags"])), id), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
335
+ var _a, _b, _c, _d, _e, _f, _g;
336
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
337
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
338
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
339
+ "opacity",
340
+ "stroke",
341
+ "strokeWidth",
342
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
343
+ }) }))] })] }, id));
344
+ case "table-seat-circle": {
345
+ const seatCount = item.seatCount;
346
+ const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
347
+ // LOCAL SPACE (tanpa x,y)
348
+ const centerX = width / 2;
349
+ const centerY = height / 2;
350
+ // meja
351
+ const tableRadius = Math.min(width, height) / 2;
352
+ // seat statis
353
+ const seatRadius = 10;
354
+ const fullAngle = Math.PI * 2;
355
+ const availableAngle = fullAngle * (1 - openSpace);
356
+ const angleStart = (fullAngle - availableAngle) / 2;
357
+ const angleStep = availableAngle / seatCount;
358
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
359
+ const angle = angleStart + i * angleStep;
360
+ const cx = centerX + (tableRadius + seatRadius) * Math.cos(angle);
361
+ const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
362
+ return { cx, cy };
363
+ });
364
+ return (_jsx("g", { style: { pointerEvents: "all" }, "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
365
+ e.preventDefault(); // penting
366
+ const group = e.currentTarget;
367
+ highlightGroup(group, "dragenter");
368
+ }, onDragOver: (e) => {
369
+ e.preventDefault(); // agar drop diterima
370
+ }, onDragLeave: (e) => {
371
+ const group = e.currentTarget;
372
+ unhighlightGroup(group);
373
+ }, onDrop: (e) => {
374
+ e.preventDefault();
375
+ const group = e.currentTarget;
376
+ // restore langsung dan reset
377
+ forceRestoreGroup(group);
378
+ }, onPointerOver: (e) => {
379
+ e.preventDefault(); // penting
380
+ const group = e.currentTarget;
381
+ highlightGroup(group, "pointerover");
382
+ }, onPointerOut: (e) => {
383
+ const group = e.currentTarget;
384
+ unhighlightGroup(group);
385
+ }, onPointerUp: (e) => {
386
+ e.preventDefault();
387
+ const group = e.currentTarget;
388
+ // restore langsung dan reset
389
+ forceRestoreGroup(group);
390
+ }, onMouseDown: (e) => {
391
+ e.preventDefault();
392
+ const group = e.currentTarget;
393
+ highlightGroup(group, "mousedown");
394
+ }, onMouseEnter: (e) => {
395
+ // e.preventDefault(); // penting
396
+ const group = e.currentTarget;
397
+ highlightGroup(group, "mouseenter");
398
+ }, onMouseLeave: (e) => {
399
+ const group = e.currentTarget;
400
+ unhighlightGroup(group);
401
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill }, omit(item, ["x", "y", "label", "points", "tags"]), commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
402
+ var _a, _b, _c, _d;
403
+ return (_jsx("text", { x: width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
404
+ }) }))] }) }, id));
405
+ }
406
+ case "table-seat-rect-circle": {
407
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
408
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
409
+ const tableRadius = Math.min(width, height) / 2;
410
+ const seatSizeTB = {
411
+ w: base * 1.8, // lebih panjang
412
+ h: base * 0.9, // lebih tipis
413
+ };
414
+ const seatSizeLR = {
415
+ w: base * 0.9, // lebih tipis
416
+ h: base * 1.8, // lebih panjang
417
+ };
418
+ const openSpace = item.openSpace || 0;
419
+ const seatRadius = Math.min(width, height) * 0.2;
420
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
421
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
422
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
423
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
424
+ // split seats evenly on top and bottom
425
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
426
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
427
+ const availableWidth = width * (1 - openSpace);
428
+ const availableHeight = height * (1 - openSpace);
429
+ const spacingWidth = availableWidth / seatCountTopBottom;
430
+ const spacingHeight = availableHeight / seatCountLeftRight;
431
+ const topSeats = distributeWithSpacing({
432
+ start: 0,
433
+ length: width,
434
+ count: top,
435
+ radius: seatRadius,
436
+ spacing: spacingWidth,
437
+ }).map((cx) => ({
438
+ x: cx - seatSizeTB.w / 2,
439
+ y: -seatSizeTB.h,
440
+ width: seatSizeTB.w,
441
+ height: seatSizeTB.h,
442
+ id: "top",
443
+ }));
444
+ const bottomSeats = distributeWithSpacing({
445
+ start: 0,
446
+ length: width,
447
+ count: bottom,
448
+ radius: seatRadius,
449
+ spacing: spacingWidth,
450
+ }).map((cx) => ({
451
+ x: cx - seatSizeTB.w / 2,
452
+ y: height,
453
+ width: seatSizeTB.w,
454
+ height: seatSizeTB.h,
455
+ id: "bottom",
456
+ }));
457
+ const leftSeats = distributeWithSpacing({
458
+ start: 0,
459
+ length: height,
460
+ count: left,
461
+ radius: seatRadius,
462
+ spacing: spacingHeight,
463
+ }).map((cy) => ({
464
+ x: -seatSizeLR.w,
465
+ y: cy - seatSizeLR.h / 2,
466
+ width: seatSizeLR.w,
467
+ height: seatSizeLR.h,
468
+ id: "left",
469
+ }));
470
+ const rightSeats = distributeWithSpacing({
471
+ start: 0,
472
+ length: height,
473
+ count: right,
474
+ radius: seatRadius,
475
+ spacing: spacingHeight,
476
+ }).map((cy) => ({
477
+ x: width,
478
+ y: cy - seatSizeLR.h / 2,
479
+ width: seatSizeLR.w,
480
+ height: seatSizeLR.h,
481
+ id: "right",
482
+ }));
483
+ const seats = [
484
+ ...topSeats,
485
+ ...bottomSeats,
486
+ ...leftSeats,
487
+ ...rightSeats,
488
+ ];
489
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
490
+ e.preventDefault(); // penting
491
+ const group = e.currentTarget;
492
+ highlightGroup(group, "dragenter");
493
+ }, onDragOver: (e) => {
494
+ e.preventDefault(); // agar drop diterima
495
+ }, onDragLeave: (e) => {
496
+ const group = e.currentTarget;
497
+ unhighlightGroup(group);
498
+ }, onDrop: (e) => {
499
+ e.preventDefault();
500
+ const group = e.currentTarget;
501
+ // restore langsung dan reset
502
+ forceRestoreGroup(group);
503
+ }, onPointerOver: (e) => {
504
+ e.preventDefault(); // penting
505
+ const group = e.currentTarget;
506
+ highlightGroup(group, "pointerover");
507
+ }, onPointerOut: (e) => {
508
+ const group = e.currentTarget;
509
+ unhighlightGroup(group);
510
+ }, onPointerUp: (e) => {
511
+ e.preventDefault();
512
+ const group = e.currentTarget;
513
+ // restore langsung dan reset
514
+ forceRestoreGroup(group);
515
+ }, onMouseDown: (e) => {
516
+ e.preventDefault();
517
+ const group = e.currentTarget;
518
+ highlightGroup(group, "mousedown");
519
+ }, onMouseEnter: (e) => {
520
+ // e.preventDefault(); // penting
521
+ const group = e.currentTarget;
522
+ highlightGroup(group, "mouseenter");
523
+ }, onMouseLeave: (e) => {
524
+ const group = e.currentTarget;
525
+ unhighlightGroup(group);
526
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius, fill: fill }, omit(item, ["x", "y", "label", "points", "tags"]), commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
527
+ var _a, _b, _c, _d, _e, _f, _g;
528
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
529
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
530
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
531
+ "opacity",
532
+ "stroke",
533
+ "strokeWidth",
534
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
535
+ }) }))] }) }, id));
536
+ }
537
+ case "table-seat-square": {
538
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
539
+ const r = 10;
540
+ const seatPositions = item.seatPositions;
541
+ const topCount = (_b = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) !== null && _b !== void 0 ? _b : 0;
542
+ const bottomCount = (_c = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) !== null && _c !== void 0 ? _c : 0;
543
+ const leftCount = (_d = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) !== null && _d !== void 0 ? _d : 0;
544
+ const rightCount = (_e = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) !== null && _e !== void 0 ? _e : 0;
545
+ // split seats evenly on top and bottom
546
+ const seatCountTopBottom = Math.ceil(Math.max(topCount, bottomCount) / 2);
547
+ const seatCountLeftRight = Math.ceil(Math.max(leftCount, rightCount) / 2);
548
+ const availableWidth = width * (1 - openSpace);
549
+ const availableHeight = height * (1 - openSpace);
550
+ const spacingWidth = availableWidth / seatCountTopBottom;
551
+ const spacingHeight = availableHeight / seatCountLeftRight;
552
+ const topXs = distributeWithSpacing({
553
+ start: x,
554
+ length: width,
555
+ count: topCount,
556
+ radius: r,
557
+ spacing: spacingWidth,
558
+ });
559
+ const topSeats = topXs.map((cx) => ({ cx, cy: y - r, id: "top" }));
560
+ // TOP
561
+ const bottomSeats = distributeWithSpacing({
562
+ start: x,
563
+ length: width,
564
+ count: bottomCount,
565
+ radius: r,
566
+ spacing: spacingWidth,
567
+ }).map((cx) => ({
568
+ cx: cx,
569
+ cy: y + height + r,
570
+ id: "bottom",
571
+ }));
572
+ const leftYs = distributeWithSpacing({
573
+ start: y,
574
+ length: height,
575
+ count: leftCount,
576
+ radius: r,
577
+ spacing: spacingHeight,
578
+ });
579
+ const leftSeats = leftYs.map((cy) => ({ cx: x - r, cy, id: "left" }));
580
+ const rightSeats = distributeWithSpacing({
581
+ start: y,
582
+ length: height,
583
+ count: rightCount,
584
+ radius: r,
585
+ spacing: spacingHeight,
586
+ }).map((cy) => ({
587
+ cx: x + width + r,
588
+ cy,
589
+ id: "right",
590
+ }));
591
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
592
+ e.preventDefault(); // penting
593
+ const group = e.currentTarget;
594
+ highlightGroup(group, "dragenter");
595
+ }, onDragOver: (e) => {
596
+ e.preventDefault(); // agar drop diterima
597
+ }, onDragLeave: (e) => {
598
+ const group = e.currentTarget;
599
+ unhighlightGroup(group);
600
+ }, onDrop: (e) => {
601
+ e.preventDefault();
602
+ const group = e.currentTarget;
603
+ // restore langsung dan reset
604
+ forceRestoreGroup(group);
605
+ }, onPointerOver: (e) => {
606
+ e.preventDefault(); // penting
607
+ const group = e.currentTarget;
608
+ highlightGroup(group, "pointerover");
609
+ }, onPointerOut: (e) => {
610
+ const group = e.currentTarget;
611
+ unhighlightGroup(group);
612
+ }, onPointerUp: (e) => {
613
+ e.preventDefault();
614
+ const group = e.currentTarget;
615
+ // restore langsung dan reset
616
+ forceRestoreGroup(group);
617
+ }, onMouseDown: (e) => {
618
+ e.preventDefault();
619
+ const group = e.currentTarget;
620
+ highlightGroup(group, "mousedown");
621
+ }, onMouseEnter: (e) => {
622
+ // e.preventDefault(); // penting
623
+ const group = e.currentTarget;
624
+ highlightGroup(group, "mouseenter");
625
+ }, onMouseLeave: (e) => {
626
+ const group = e.currentTarget;
627
+ unhighlightGroup(group);
628
+ }, children: _jsxs("g", { transform: `rotate(${rotate}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height }, commonProps, { fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill }, omit(item, ["x", "y", "label", "points", "tags"]))), renderTags(tags), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
629
+ var _a, _b, _c, _d, _e, _f, _g;
630
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
631
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
632
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
633
+ "opacity",
634
+ "stroke",
635
+ "strokeWidth",
636
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
637
+ }) }))] }) }, id));
638
+ }
639
+ case "table-seat-half-square": {
640
+ const openSpace = item.openSpace || 0;
641
+ const seatRadius = Math.min(width, height) * 0.15;
642
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
643
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
644
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
645
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
646
+ // split seats evenly on top and bottom
647
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
648
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
649
+ const availableWidth = width * (1 - openSpace);
650
+ const availableHeight = height * (1 - openSpace);
651
+ const spacingWidth = availableWidth / seatCountTopBottom;
652
+ const spacingHeight = availableHeight / seatCountLeftRight;
653
+ const topSeats = distributeWithSpacing({
654
+ start: 0,
655
+ length: width,
656
+ count: top,
657
+ radius: seatRadius,
658
+ spacing: spacingWidth,
659
+ }).map((cx) => ({ cx, cy: seatRadius * 0.1, id: "top" }));
660
+ const bottomSeats = distributeWithSpacing({
661
+ start: 0,
662
+ length: width,
663
+ count: bottom,
664
+ radius: seatRadius,
665
+ spacing: spacingWidth,
666
+ }).map((cx) => ({
667
+ cx,
668
+ cy: height - seatRadius * 0.1,
669
+ id: "bottom",
670
+ }));
671
+ const leftSeats = distributeWithSpacing({
672
+ start: 0,
673
+ length: height,
674
+ count: left,
675
+ radius: seatRadius,
676
+ spacing: spacingHeight,
677
+ }).map((cy) => ({ cx: seatRadius * 0.1, cy, id: "left" }));
678
+ const rightSeats = distributeWithSpacing({
679
+ start: 0,
680
+ length: height,
681
+ count: right,
682
+ radius: seatRadius,
683
+ spacing: spacingHeight,
684
+ }).map((cy) => ({ cx: width - seatRadius * 0.1, cy, id: "right" }));
685
+ const seats = (_f = [
686
+ ...topSeats,
687
+ ...bottomSeats,
688
+ ...leftSeats,
689
+ ...rightSeats,
690
+ ]) === null || _f === void 0 ? void 0 : _f.map((seat) => (Object.assign(Object.assign({}, seat), { d: arcByDirection({
691
+ cx: seat.cx,
692
+ cy: seat.cy,
693
+ r: seatRadius,
694
+ direction: seat.id,
695
+ fraction: 0.4,
696
+ }) })));
697
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
698
+ e.preventDefault(); // penting
699
+ const group = e.currentTarget;
700
+ highlightGroup(group, "dragenter");
701
+ }, onDragOver: (e) => {
702
+ e.preventDefault(); // agar drop diterima
703
+ }, onDragLeave: (e) => {
704
+ const group = e.currentTarget;
705
+ unhighlightGroup(group);
706
+ }, onDrop: (e) => {
707
+ e.preventDefault();
708
+ const group = e.currentTarget;
709
+ // restore langsung dan reset
710
+ forceRestoreGroup(group);
711
+ }, onPointerOver: (e) => {
712
+ e.preventDefault(); // penting
713
+ const group = e.currentTarget;
714
+ highlightGroup(group, "pointerover");
715
+ }, onPointerOut: (e) => {
716
+ const group = e.currentTarget;
717
+ unhighlightGroup(group);
718
+ }, onPointerUp: (e) => {
719
+ e.preventDefault();
720
+ const group = e.currentTarget;
721
+ // restore langsung dan reset
722
+ forceRestoreGroup(group);
723
+ }, onMouseDown: (e) => {
724
+ e.preventDefault();
725
+ const group = e.currentTarget;
726
+ highlightGroup(group, "mousedown");
727
+ }, onMouseEnter: (e) => {
728
+ // e.preventDefault(); // penting
729
+ const group = e.currentTarget;
730
+ highlightGroup(group, "mouseenter");
731
+ }, onMouseLeave: (e) => {
732
+ const group = e.currentTarget;
733
+ unhighlightGroup(group);
734
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill }, omit(item, ["x", "y", "label", "points", "tags"]))), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
735
+ var _a, _b, _c, _d, _e, _f, _g;
736
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
737
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
738
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
739
+ "opacity",
740
+ "stroke",
741
+ "strokeWidth",
742
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
743
+ }) }))] }) }, id));
744
+ }
745
+ case "table-seat-rect-square": {
746
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
747
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
748
+ const seatSizeTB = {
749
+ w: base * 1.8, // lebih panjang
750
+ h: base * 0.9, // lebih tipis
751
+ };
752
+ const seatSizeLR = {
753
+ w: base * 0.9, // lebih tipis
754
+ h: base * 1.8, // lebih panjang
755
+ };
756
+ const openSpace = item.openSpace || 0;
757
+ const seatRadius = Math.min(width, height) * 0.2;
758
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
759
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
760
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
761
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
762
+ // split seats evenly on top and bottom
763
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
764
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
765
+ const availableWidth = width * (1 - openSpace);
766
+ const availableHeight = height * (1 - openSpace);
767
+ const spacingWidth = availableWidth / seatCountTopBottom;
768
+ const spacingHeight = availableHeight / seatCountLeftRight;
769
+ const topSeats = distributeWithSpacing({
770
+ start: x,
771
+ length: width,
772
+ count: top,
773
+ radius: seatRadius,
774
+ spacing: spacingWidth,
775
+ }).map((cx) => ({
776
+ x: cx - seatSizeTB.w / 2,
777
+ y: y - seatSizeTB.h,
778
+ width: seatSizeTB.w,
779
+ height: seatSizeTB.h,
780
+ id: "top",
781
+ }));
782
+ const bottomSeats = distributeWithSpacing({
783
+ start: x,
784
+ length: width,
785
+ count: bottom,
786
+ radius: seatRadius,
787
+ spacing: spacingWidth,
788
+ }).map((cx) => ({
789
+ x: cx - seatSizeTB.w / 2,
790
+ y: y + height,
791
+ width: seatSizeTB.w,
792
+ height: seatSizeTB.h,
793
+ id: "bottom",
794
+ }));
795
+ const leftSeats = distributeWithSpacing({
796
+ start: 0,
797
+ length: height,
798
+ count: left,
799
+ radius: seatRadius,
800
+ spacing: spacingHeight,
801
+ }).map((cy) => ({
802
+ x: x - seatSizeLR.w,
803
+ y: y + cy - seatSizeLR.h / 2,
804
+ width: seatSizeLR.w,
805
+ height: seatSizeLR.h,
806
+ id: "left",
807
+ }));
808
+ const rightSeats = distributeWithSpacing({
809
+ start: 0,
810
+ length: height,
811
+ count: right,
812
+ radius: seatRadius,
813
+ spacing: spacingHeight,
814
+ }).map((cy) => ({
815
+ x: x + width,
816
+ y: y + cy - seatSizeLR.h / 2,
817
+ width: seatSizeLR.w,
818
+ height: seatSizeLR.h,
819
+ id: "right",
820
+ }));
821
+ const seats = [
822
+ ...topSeats,
823
+ ...bottomSeats,
824
+ ...leftSeats,
825
+ ...rightSeats,
826
+ ];
827
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
828
+ e.preventDefault(); // penting
829
+ const group = e.currentTarget;
830
+ highlightGroup(group, "dragenter");
831
+ }, onDragOver: (e) => {
832
+ e.preventDefault(); // agar drop diterima
833
+ }, onDragLeave: (e) => {
834
+ const group = e.currentTarget;
835
+ unhighlightGroup(group);
836
+ }, onDrop: (e) => {
837
+ e.preventDefault();
838
+ const group = e.currentTarget;
839
+ // restore langsung dan reset
840
+ forceRestoreGroup(group);
841
+ }, onPointerOver: (e) => {
842
+ e.preventDefault(); // penting
843
+ const group = e.currentTarget;
844
+ highlightGroup(group, "pointerover");
845
+ }, onPointerOut: (e) => {
846
+ const group = e.currentTarget;
847
+ unhighlightGroup(group);
848
+ }, onPointerUp: (e) => {
849
+ e.preventDefault();
850
+ const group = e.currentTarget;
851
+ // restore langsung dan reset
852
+ forceRestoreGroup(group);
853
+ }, onMouseDown: (e) => {
854
+ e.preventDefault();
855
+ const group = e.currentTarget;
856
+ highlightGroup(group, "mousedown");
857
+ }, onMouseEnter: (e) => {
858
+ // e.preventDefault(); // penting
859
+ const group = e.currentTarget;
860
+ highlightGroup(group, "mouseenter");
861
+ }, onMouseLeave: (e) => {
862
+ const group = e.currentTarget;
863
+ unhighlightGroup(group);
864
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill }, omit(item, ["x", "y", "label", "points", "tags"]))), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
865
+ var _a, _b, _c, _d, _e, _f, _g;
866
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
867
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
868
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
869
+ "opacity",
870
+ "stroke",
871
+ "strokeWidth",
872
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
873
+ }) }))] }) }, id));
874
+ }
875
+ case "text":
876
+ return (_jsx("g", { onContextMenu: (e) => e.preventDefault(), "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", { width: width, height: height, fill: "transparent", opacity: opacity }), _jsx("text", Object.assign({ x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity"]), { children: text }))] }) }, id));
877
+ case "image-table":
878
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
879
+ e.preventDefault(); // penting
880
+ const group = e.currentTarget;
881
+ highlightGroup(group, "dragenter");
882
+ }, onDragOver: (e) => {
883
+ e.preventDefault(); // agar drop diterima
884
+ }, onDragLeave: (e) => {
885
+ const group = e.currentTarget;
886
+ unhighlightGroup(group);
887
+ }, onDrop: (e) => {
888
+ e.preventDefault();
889
+ const group = e.currentTarget;
890
+ // restore langsung dan reset
891
+ forceRestoreGroup(group);
892
+ }, onPointerOver: (e) => {
893
+ e.preventDefault(); // penting
894
+ const group = e.currentTarget;
895
+ highlightGroup(group, "pointerover");
896
+ }, onPointerOut: (e) => {
897
+ const group = e.currentTarget;
898
+ unhighlightGroup(group);
899
+ }, onPointerUp: (e) => {
900
+ e.preventDefault();
901
+ const group = e.currentTarget;
902
+ // restore langsung dan reset
903
+ forceRestoreGroup(group);
904
+ }, onMouseDown: (e) => {
905
+ e.preventDefault();
906
+ const group = e.currentTarget;
907
+ highlightGroup(group, "mousedown");
908
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", Object.assign({ href: src, width: width, height: height, transform: transformRotate }, commonProps)), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
909
+ var _a, _b, _c, _d;
910
+ return (_jsx("text", { x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, index));
911
+ }) }))] }) }, id));
912
+ case "background":
913
+ return (_jsxs("g", { onContextMenu: (e) => e.preventDefault(), children: [_jsx("image", Object.assign({ href: src, x: x, y: y, width: width, height: height, transform: transformRotate }, commonProps)), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
914
+ var _a, _b, _c, _d;
915
+ return (_jsx("text", { x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, index));
916
+ })] }, id));
917
+ default:
918
+ return _jsx("g", {}, id);
919
+ }
920
+ };
921
+ let date = new Date();
922
+ return _jsx("g", { children: components === null || components === void 0 ? void 0 : components.map(renderShape) }, `${date}`);
923
+ };
924
+ export default Layers;