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,483 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { createElement as _createElement } from "react";
4
+ import { isEmpty, omit } from "lodash";
5
+ import { arcByDirection, distributeWithSpacing, rectToPolygonNodes, rectToPolygonPoints, } from "./utils";
6
+ import { useAppSelector } from "../../hooks/use-redux";
7
+ const Layers = ({ components, selectedComponent, activeTool, selectionLines, }) => {
8
+ var _a;
9
+ const hasPoints = selectionLines && !isEmpty(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.points);
10
+ const lockBackground = useAppSelector((state) => state.tool.lockBackground);
11
+ const renderShape = (item) => {
12
+ var _a, _b, _c, _d, _e, _f;
13
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, } = item;
14
+ const commonProps = {
15
+ fill,
16
+ opacity,
17
+ stroke,
18
+ strokeWidth,
19
+ };
20
+ switch (shape) {
21
+ case "square":
22
+ return (_jsx("g", { "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("rect", Object.assign({}, commonProps, { key: id, width: width, height: height, rx: radius })), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
25
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
26
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
27
+ "opacity",
28
+ "stroke",
29
+ "strokeWidth",
30
+ ]), { 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));
31
+ }) })] }) }, id));
32
+ case "polygon":
33
+ function isPolygonClosed(points) {
34
+ if (points.length < 3)
35
+ return false;
36
+ const first = points[0];
37
+ const last = points[points.length - 1];
38
+ return first.x === last.x && first.y === last.y;
39
+ }
40
+ const finalPoint = points.map((p) => `${p.x},${p.y}`).join(" ");
41
+ const isClosed = isPolygonClosed(points);
42
+ const showPoints = (selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.id) == id;
43
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: finalPoint, x: "0", y: "0" })), (showPoints || !isClosed) &&
44
+ points.map((_, index) => {
45
+ return (_jsxs(_Fragment, { children: [_jsx("rect", { "data-point": JSON.stringify(_), id: `${index}`, x: (_ === null || _ === void 0 ? void 0 : _.x) - 5, y: (_ === null || _ === void 0 ? void 0 : _.y) - 5, width: 10, height: 10, fill: "#4a90e2", cursor: "pointer" }, `${id}-point-${index}`), _jsx("circle", { "data-point": JSON.stringify(_), id: `${index}`, cx: _ === null || _ === void 0 ? void 0 : _.x, cy: _ === null || _ === void 0 ? void 0 : _.y, r: 15, fill: "transparent", cursor: "pointer" }, `${id}-point-${index}`)] }));
46
+ })] }) }, id));
47
+ case "selection-box":
48
+ const pointsFormat = rectToPolygonPoints(x, y, width, height);
49
+ return (_jsx("g", { "data-table": JSON.stringify(item), "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: pointsFormat })), points.map((_, index) => {
50
+ return (_jsx("rect", { x: (_ === null || _ === void 0 ? void 0 : _.x) - 5, y: (_ === null || _ === void 0 ? void 0 : _.y) - 5, width: 10, height: 10, fill: "blue" }, `${id}-point-${index}`));
51
+ }), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
52
+ var _a, _b, _c, _d;
53
+ return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { key: `${id}-label-${index}`, 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: `rotate(${rotation} ${x + width / 2} ${y + height / 2})` }), _ === null || _ === void 0 ? void 0 : _.label));
54
+ })] }) }, id));
55
+ case "circle":
56
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, 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), id), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
57
+ var _a, _b, _c, _d, _e, _f, _g;
58
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
59
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
60
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
61
+ "opacity",
62
+ "stroke",
63
+ "strokeWidth",
64
+ ]), { 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));
65
+ }) })] }) }, id));
66
+ case "diamond":
67
+ return (_jsxs("g", { "data-table": JSON.stringify(item), children: [_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, transform: `rotate(${rotation}, ${x}, ${y})` }, commonProps, { fill: fill }), id), _jsx("text", { x: x + width / 2, y: y + height / 2, fill: fontColor !== null && fontColor !== void 0 ? fontColor : "black", fontSize: `${fontSize !== null && fontSize !== void 0 ? fontSize : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", children: label })] }, id));
68
+ case "table-seat-circle": {
69
+ const seatCount = item.seatCount;
70
+ const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
71
+ // LOCAL SPACE (tanpa x,y)
72
+ const centerX = width / 2;
73
+ const centerY = height / 2;
74
+ // meja
75
+ const tableRadius = Math.min(width, height) / 2;
76
+ // seat statis
77
+ const seatRadius = 10;
78
+ const fullAngle = Math.PI * 2;
79
+ const availableAngle = fullAngle * (1 - openSpace);
80
+ const angleStart = (fullAngle - availableAngle) / 2;
81
+ const angleStep = availableAngle / seatCount;
82
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
83
+ const angle = angleStart + i * angleStep;
84
+ const cx = centerX + (tableRadius + seatRadius) * Math.cos(angle);
85
+ const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
86
+ return { cx, cy };
87
+ });
88
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: fill }, commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius, fill: seatFill }, `${id}-seat-${i}`))) }), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
89
+ var _a, _b, _c, _d, _e, _f, _g;
90
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
91
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
92
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
93
+ "opacity",
94
+ "stroke",
95
+ "strokeWidth",
96
+ ]), { 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));
97
+ }) })] }) }, id));
98
+ }
99
+ case "table-seat-rect-circle": {
100
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
101
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
102
+ const tableRadius = Math.min(width, height) / 2;
103
+ const seatSizeTB = {
104
+ w: base * 1.8, // lebih panjang
105
+ h: base * 0.9, // lebih tipis
106
+ };
107
+ const seatSizeLR = {
108
+ w: base * 0.9, // lebih tipis
109
+ h: base * 1.8, // lebih panjang
110
+ };
111
+ const openSpace = item.openSpace || 0;
112
+ const seatRadius = Math.min(width, height) * 0.2;
113
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
114
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
115
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
116
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
117
+ // split seats evenly on top and bottom
118
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
119
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
120
+ const availableWidth = width * (1 - openSpace);
121
+ const availableHeight = height * (1 - openSpace);
122
+ const spacingWidth = availableWidth / seatCountTopBottom;
123
+ const spacingHeight = availableHeight / seatCountLeftRight;
124
+ const topSeats = distributeWithSpacing({
125
+ start: 0,
126
+ length: width,
127
+ count: top,
128
+ radius: seatRadius,
129
+ spacing: spacingWidth,
130
+ }).map((cx) => ({
131
+ x: cx - seatSizeTB.w / 2,
132
+ y: -seatSizeTB.h,
133
+ width: seatSizeTB.w,
134
+ height: seatSizeTB.h,
135
+ id: "top",
136
+ }));
137
+ const bottomSeats = distributeWithSpacing({
138
+ start: 0,
139
+ length: width,
140
+ count: bottom,
141
+ radius: seatRadius,
142
+ spacing: spacingWidth,
143
+ }).map((cx) => ({
144
+ x: cx - seatSizeTB.w / 2,
145
+ y: height,
146
+ width: seatSizeTB.w,
147
+ height: seatSizeTB.h,
148
+ id: "bottom",
149
+ }));
150
+ const leftSeats = distributeWithSpacing({
151
+ start: 0,
152
+ length: height,
153
+ count: left,
154
+ radius: seatRadius,
155
+ spacing: spacingHeight,
156
+ }).map((cy) => ({
157
+ x: -seatSizeLR.w,
158
+ y: cy - seatSizeLR.h / 2,
159
+ width: seatSizeLR.w,
160
+ height: seatSizeLR.h,
161
+ id: "left",
162
+ }));
163
+ const rightSeats = distributeWithSpacing({
164
+ start: 0,
165
+ length: height,
166
+ count: right,
167
+ radius: seatRadius,
168
+ spacing: spacingHeight,
169
+ }).map((cy) => ({
170
+ x: width,
171
+ y: cy - seatSizeLR.h / 2,
172
+ width: seatSizeLR.w,
173
+ height: seatSizeLR.h,
174
+ id: "right",
175
+ }));
176
+ const seats = [
177
+ ...topSeats,
178
+ ...bottomSeats,
179
+ ...leftSeats,
180
+ ...rightSeats,
181
+ ];
182
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius }, commonProps, { fill: fill })), _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 }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
183
+ var _a, _b, _c, _d, _e, _f, _g;
184
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
185
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
186
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
187
+ "opacity",
188
+ "stroke",
189
+ "strokeWidth",
190
+ ]), { 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));
191
+ }) })] }) }, id));
192
+ }
193
+ case "table-seat-square": {
194
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
195
+ const r = 10;
196
+ const seatPositions = item.seatPositions;
197
+ const topCount = (_b = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) !== null && _b !== void 0 ? _b : 0;
198
+ const bottomCount = (_c = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) !== null && _c !== void 0 ? _c : 0;
199
+ const leftCount = (_d = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) !== null && _d !== void 0 ? _d : 0;
200
+ const rightCount = (_e = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) !== null && _e !== void 0 ? _e : 0;
201
+ // split seats evenly on top and bottom
202
+ const seatCountTopBottom = Math.ceil(Math.max(topCount, bottomCount) / 2);
203
+ const seatCountLeftRight = Math.ceil(Math.max(leftCount, rightCount) / 2);
204
+ const availableWidth = width * (1 - openSpace);
205
+ const availableHeight = height * (1 - openSpace);
206
+ const spacingWidth = availableWidth / seatCountTopBottom;
207
+ const spacingHeight = availableHeight / seatCountLeftRight;
208
+ const topXs = distributeWithSpacing({
209
+ start: x,
210
+ length: width,
211
+ count: topCount,
212
+ radius: r,
213
+ spacing: spacingWidth,
214
+ });
215
+ const topSeats = topXs.map((cx) => ({ cx, cy: y - r, id: "top" }));
216
+ // TOP
217
+ const bottomSeats = distributeWithSpacing({
218
+ start: x,
219
+ length: width,
220
+ count: bottomCount,
221
+ radius: r,
222
+ spacing: spacingWidth,
223
+ }).map((cx) => ({
224
+ cx: cx,
225
+ cy: y + height + r,
226
+ id: "bottom",
227
+ }));
228
+ const leftYs = distributeWithSpacing({
229
+ start: y,
230
+ length: height,
231
+ count: leftCount,
232
+ radius: r,
233
+ spacing: spacingHeight,
234
+ });
235
+ const leftSeats = leftYs.map((cy) => ({ cx: x - r, cy, id: "left" }));
236
+ const rightSeats = distributeWithSpacing({
237
+ start: y,
238
+ length: height,
239
+ count: rightCount,
240
+ radius: r,
241
+ spacing: spacingHeight,
242
+ }).map((cy) => ({
243
+ cx: x + width + r,
244
+ cy,
245
+ id: "right",
246
+ }));
247
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height }, commonProps, { rx: radius, fill: fill })), _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 }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
248
+ var _a, _b, _c, _d, _e, _f, _g;
249
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
250
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
251
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
252
+ "opacity",
253
+ "stroke",
254
+ "strokeWidth",
255
+ ]), { 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));
256
+ }) })] }) }, id));
257
+ }
258
+ case "table-seat-half-square": {
259
+ const openSpace = item.openSpace || 0;
260
+ const seatRadius = Math.min(width, height) * 0.15;
261
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
262
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
263
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
264
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
265
+ // split seats evenly on top and bottom
266
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
267
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
268
+ const availableWidth = width * (1 - openSpace);
269
+ const availableHeight = height * (1 - openSpace);
270
+ const spacingWidth = availableWidth / seatCountTopBottom;
271
+ const spacingHeight = availableHeight / seatCountLeftRight;
272
+ const topSeats = distributeWithSpacing({
273
+ start: 0,
274
+ length: width,
275
+ count: top,
276
+ radius: seatRadius,
277
+ spacing: spacingWidth,
278
+ }).map((cx) => ({ cx, cy: seatRadius * 0.1, id: "top" }));
279
+ const bottomSeats = distributeWithSpacing({
280
+ start: 0,
281
+ length: width,
282
+ count: bottom,
283
+ radius: seatRadius,
284
+ spacing: spacingWidth,
285
+ }).map((cx) => ({
286
+ cx,
287
+ cy: height - seatRadius * 0.1,
288
+ id: "bottom",
289
+ }));
290
+ const leftSeats = distributeWithSpacing({
291
+ start: 0,
292
+ length: height,
293
+ count: left,
294
+ radius: seatRadius,
295
+ spacing: spacingHeight,
296
+ }).map((cy) => ({ cx: seatRadius * 0.1, cy, id: "left" }));
297
+ const rightSeats = distributeWithSpacing({
298
+ start: 0,
299
+ length: height,
300
+ count: right,
301
+ radius: seatRadius,
302
+ spacing: spacingHeight,
303
+ }).map((cy) => ({ cx: width - seatRadius * 0.1, cy, id: "right" }));
304
+ const seats = (_f = [
305
+ ...topSeats,
306
+ ...bottomSeats,
307
+ ...leftSeats,
308
+ ...rightSeats,
309
+ ]) === null || _f === void 0 ? void 0 : _f.map((seat) => (Object.assign(Object.assign({}, seat), { d: arcByDirection({
310
+ cx: seat.cx,
311
+ cy: seat.cy,
312
+ r: seatRadius,
313
+ direction: seat.id,
314
+ fraction: 0.4,
315
+ }) })));
316
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _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 }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
317
+ var _a, _b, _c, _d, _e, _f, _g;
318
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
319
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
320
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
321
+ "opacity",
322
+ "stroke",
323
+ "strokeWidth",
324
+ ]), { 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));
325
+ }) })] }) }, id));
326
+ }
327
+ case "table-seat-rect-square": {
328
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
329
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
330
+ const seatSizeTB = {
331
+ w: base * 1.8, // lebih panjang
332
+ h: base * 0.9, // lebih tipis
333
+ };
334
+ const seatSizeLR = {
335
+ w: base * 0.9, // lebih tipis
336
+ h: base * 1.8, // lebih panjang
337
+ };
338
+ const openSpace = item.openSpace || 0;
339
+ const seatRadius = Math.min(width, height) * 0.2;
340
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
341
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
342
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
343
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
344
+ // split seats evenly on top and bottom
345
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
346
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
347
+ const availableWidth = width * (1 - openSpace);
348
+ const availableHeight = height * (1 - openSpace);
349
+ const spacingWidth = availableWidth / seatCountTopBottom;
350
+ const spacingHeight = availableHeight / seatCountLeftRight;
351
+ const topSeats = distributeWithSpacing({
352
+ start: x,
353
+ length: width,
354
+ count: top,
355
+ radius: seatRadius,
356
+ spacing: spacingWidth,
357
+ }).map((cx) => ({
358
+ x: cx - seatSizeTB.w / 2,
359
+ y: y - seatSizeTB.h,
360
+ width: seatSizeTB.w,
361
+ height: seatSizeTB.h,
362
+ id: "top",
363
+ }));
364
+ const bottomSeats = distributeWithSpacing({
365
+ start: x,
366
+ length: width,
367
+ count: bottom,
368
+ radius: seatRadius,
369
+ spacing: spacingWidth,
370
+ }).map((cx) => ({
371
+ x: cx - seatSizeTB.w / 2,
372
+ y: y + height,
373
+ width: seatSizeTB.w,
374
+ height: seatSizeTB.h,
375
+ id: "bottom",
376
+ }));
377
+ const leftSeats = distributeWithSpacing({
378
+ start: 0,
379
+ length: height,
380
+ count: left,
381
+ radius: seatRadius,
382
+ spacing: spacingHeight,
383
+ }).map((cy) => ({
384
+ x: x - seatSizeLR.w,
385
+ y: y + cy - seatSizeLR.h / 2,
386
+ width: seatSizeLR.w,
387
+ height: seatSizeLR.h,
388
+ id: "left",
389
+ }));
390
+ const rightSeats = distributeWithSpacing({
391
+ start: 0,
392
+ length: height,
393
+ count: right,
394
+ radius: seatRadius,
395
+ spacing: spacingHeight,
396
+ }).map((cy) => ({
397
+ x: x + width,
398
+ y: y + cy - seatSizeLR.h / 2,
399
+ width: seatSizeLR.w,
400
+ height: seatSizeLR.h,
401
+ id: "right",
402
+ }));
403
+ const seats = [
404
+ ...topSeats,
405
+ ...bottomSeats,
406
+ ...leftSeats,
407
+ ...rightSeats,
408
+ ];
409
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _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`), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
410
+ var _a, _b, _c, _d, _e, _f, _g;
411
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
412
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
413
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
414
+ "opacity",
415
+ "stroke",
416
+ "strokeWidth",
417
+ ]), { 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));
418
+ }) })] }) }, id));
419
+ }
420
+ case "text":
421
+ return (_jsx("g", { "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));
422
+ case "image-table":
423
+ case "background":
424
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: {
425
+ pointerEvents: lockBackground ? "none" : "auto",
426
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", Object.assign({ href: src, width: width, height: height }, commonProps)), _jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
427
+ var _a, _b, _c, _d, _e, _f, _g;
428
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
429
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
430
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
431
+ "opacity",
432
+ "stroke",
433
+ "strokeWidth",
434
+ ]), { 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));
435
+ }) })] }) }, id));
436
+ case "bounding-box": {
437
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-bounding-box": id, children: _jsx("rect", { width: width, height: height, fill: "none", stroke: "#3b82f6", strokeWidth: 1, strokeDasharray: "6 4", pointerEvents: "none" }) }, id));
438
+ }
439
+ default:
440
+ return _jsx("g", {}, id);
441
+ }
442
+ };
443
+ let date = new Date();
444
+ const nodesRaw = rectToPolygonNodes(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.width, selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.height);
445
+ return (_jsxs("g", { id: "selection-layer", children: [components === null || components === void 0 ? void 0 : components.map(renderShape), !isEmpty(selectionLines) && activeTool === "select" && (_jsxs(_Fragment, { children: [nodesRaw.map((p1, index) => {
446
+ const p2 = nodesRaw[(index + 2) % nodesRaw.length];
447
+ const side = index === 0
448
+ ? "top"
449
+ : index === 1
450
+ ? "right"
451
+ : index === 2
452
+ ? "bottom"
453
+ : "left";
454
+ const mx = (p1.x + p2.x) / 2;
455
+ const my = (p1.y + p2.y) / 2;
456
+ if (side === "top")
457
+ return (_jsx("g", { id: "help-group-0", "data-selection": `selection-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`, transform: `translate(${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.x},${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.y})`, children: _jsx("g", { transform: `rotate(${0}, 0,0)`, children: side === "top" && (_jsxs("g", { id: "help-group-1", children: [_jsx("line", { x1: mx, y1: my + selectionLines.height / 2, x2: mx, y2: my - selectionLines.height / 3 - 10, stroke: "#4a90e2", strokeWidth: 2, id: "line-help" }), _jsx("circle", { id: "circle-help", "data-role": "rotate", cx: mx, cy: my - selectionLines.height / 3 - 10, r: 8, fill: "#4a90e2" })] })) }) }, `selection-${date}`));
458
+ }), _jsx("g", { id: "selection-lines", "data-selection": `selection-${(_a = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) !== null && _a !== void 0 ? _a : selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.id}`, transform: `translate(${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.x},${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.y})`, children: _jsxs("g", { transform: `rotate(${0}, 0,0)`, children: [!hasPoints && (_jsx("rect", { width: selectionLines.width, height: selectionLines.height, fill: "none", stroke: "#4a90e2", strokeWidth: 1, id: "rect-box-selection" })), !hasPoints &&
459
+ (nodesRaw === null || nodesRaw === void 0 ? void 0 : nodesRaw.map((node, index) => {
460
+ const corner = (index) => {
461
+ switch (index) {
462
+ case 0:
463
+ return "top-left";
464
+ case 1:
465
+ return "top";
466
+ case 2:
467
+ return "top-right";
468
+ case 3:
469
+ return "right";
470
+ case 4:
471
+ return "bottom-right";
472
+ case 5:
473
+ return "bottom";
474
+ case 6:
475
+ return "bottom-left";
476
+ case 7:
477
+ return "left";
478
+ }
479
+ };
480
+ return (_jsxs(_Fragment, { children: [_jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "transparent", style: { cursor: "pointer" } }, index), _jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "#4a90e2", id: `circle-corner-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`, style: { cursor: "pointer" } }, index)] }));
481
+ }))] }) }, `selection-${date}`)] }))] }, `${date}`));
482
+ };
483
+ export default Layers;
@@ -20,5 +20,5 @@ interface LayersProps {
20
20
  items: string[];
21
21
  }[];
22
22
  }
23
- declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags, }: LayersProps) => import("react").JSX.Element;
23
+ declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags, }: LayersProps) => import("react/jsx-runtime").JSX.Element;
24
24
  export default Layers;