@seatmap-fyi/map-domain 0.1.0-alpha.3 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.d.ts +6 -1
- package/dist/catalog.js +44 -2
- package/dist/categories.d.ts +25 -0
- package/dist/categories.js +138 -0
- package/dist/editor-state.js +8 -1
- package/dist/geometry/geometry.d.ts +7 -1
- package/dist/geometry/geometry.js +16 -5
- package/dist/geometry/seat-shape.d.ts +24 -0
- package/dist/geometry/seat-shape.js +101 -0
- package/dist/geometry/seating-layout.d.ts +12 -3
- package/dist/geometry/seating-layout.js +94 -9
- package/dist/identity.js +9 -1
- package/dist/labels.d.ts +6 -0
- package/dist/labels.js +71 -8
- package/dist/preview.js +40 -5
- package/dist/row-segments.d.ts +26 -0
- package/dist/row-segments.js +112 -0
- package/dist/schema.d.ts +994 -61
- package/dist/schema.js +271 -38
- package/dist/selling.d.ts +34 -0
- package/dist/selling.js +163 -0
- package/dist/table-layout.d.ts +30 -0
- package/dist/table-layout.js +142 -0
- package/dist/types.d.ts +193 -27
- package/dist/types.js +71 -0
- package/dist/validation.js +20 -7
- package/package.json +21 -1
package/dist/catalog.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { PhysicalDocumentV1, SeatingGroup, UUID } from "./types.js";
|
|
1
|
+
import type { PhysicalDocumentV1, SeatingGroup, InventoryArea, UUID } from "./types.js";
|
|
2
|
+
import { type SegmentedRowEntry } from "./row-segments.js";
|
|
2
3
|
import { type GeneratedSeat } from "./geometry/geometry.js";
|
|
3
4
|
export declare function generatedSeats(group: SeatingGroup): readonly GeneratedSeat[];
|
|
5
|
+
/** Geometry remains shared; logical addresses are projected from the current document. */
|
|
6
|
+
export declare function documentGroupSeats(document: PhysicalDocumentV1, group: SeatingGroup): readonly GeneratedSeat[];
|
|
4
7
|
export type DocumentCatalog = {
|
|
5
8
|
groups: ReadonlyMap<UUID, SeatingGroup>;
|
|
9
|
+
areas: ReadonlyMap<UUID, InventoryArea>;
|
|
6
10
|
seats: ReadonlyMap<UUID, {
|
|
7
11
|
group: SeatingGroup;
|
|
8
12
|
seat: GeneratedSeat;
|
|
9
13
|
}>;
|
|
10
14
|
rows: ReadonlyMap<UUID, SeatingGroup>;
|
|
15
|
+
segmentedRows: ReadonlyMap<UUID, SegmentedRowEntry>;
|
|
11
16
|
sections: ReadonlyMap<UUID, string>;
|
|
12
17
|
};
|
|
13
18
|
/** Immutable, derived lookup; never an editable store. Untouched group geometry is shared. */
|
package/dist/catalog.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { rowSegments } from "./row-segments.js";
|
|
2
|
+
import { sequenceLabel } from "./labels.js";
|
|
1
3
|
import { generateGroup } from "./geometry/geometry.js";
|
|
2
4
|
const generated = new WeakMap();
|
|
3
5
|
export function generatedSeats(group) {
|
|
@@ -8,6 +10,38 @@ export function generatedSeats(group) {
|
|
|
8
10
|
}
|
|
9
11
|
return cached;
|
|
10
12
|
}
|
|
13
|
+
const documentSeats = new WeakMap();
|
|
14
|
+
/** Geometry remains shared; logical addresses are projected from the current document. */
|
|
15
|
+
export function documentGroupSeats(document, group) {
|
|
16
|
+
let cache = documentSeats.get(document);
|
|
17
|
+
if (!cache) {
|
|
18
|
+
cache = new Map();
|
|
19
|
+
documentSeats.set(document, cache);
|
|
20
|
+
}
|
|
21
|
+
const cached = cache.get(group);
|
|
22
|
+
if (cached)
|
|
23
|
+
return cached;
|
|
24
|
+
const segments = rowSegments(document);
|
|
25
|
+
const ordinals = new Map();
|
|
26
|
+
const result = generatedSeats(group).map((seat) => {
|
|
27
|
+
const segment = seat.rowId ? segments.get(seat.rowId) : undefined;
|
|
28
|
+
if (!segment)
|
|
29
|
+
return seat;
|
|
30
|
+
const ordinal = ordinals.get(segment.part.id) ?? 0;
|
|
31
|
+
ordinals.set(segment.part.id, ordinal + 1);
|
|
32
|
+
return {
|
|
33
|
+
...seat,
|
|
34
|
+
label: seat.slot.labelOverride ??
|
|
35
|
+
sequenceLabel(segment.row.sequence, segment.firstIndex + ordinal, segment.totalSeats),
|
|
36
|
+
logicalRowId: segment.row.id,
|
|
37
|
+
logicalRowLabel: segment.row.label,
|
|
38
|
+
logicalPartIndex: segment.partIndex,
|
|
39
|
+
logicalSequence: segment.row.sequence,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
cache.set(group, result);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
11
45
|
const catalogs = new WeakMap();
|
|
12
46
|
/** Immutable, derived lookup; never an editable store. Untouched group geometry is shared. */
|
|
13
47
|
export function documentCatalog(document) {
|
|
@@ -16,20 +50,28 @@ export function documentCatalog(document) {
|
|
|
16
50
|
return catalog;
|
|
17
51
|
const groups = new Map(document.seatingGroups.map((g) => [g.id, g])), seats = new Map(), rows = new Map();
|
|
18
52
|
for (const group of document.seatingGroups)
|
|
19
|
-
for (const seat of
|
|
53
|
+
for (const seat of documentGroupSeats(document, group)) {
|
|
20
54
|
seats.set(seat.id, { group, seat });
|
|
21
55
|
if (seat.rowId)
|
|
22
56
|
rows.set(seat.rowId, group);
|
|
23
57
|
}
|
|
24
58
|
catalog = {
|
|
25
59
|
groups,
|
|
60
|
+
areas: new Map(document.areas.map((area) => [area.id, area])),
|
|
26
61
|
seats,
|
|
27
62
|
rows,
|
|
63
|
+
segmentedRows: new Map((document.segmentedRows ?? []).map((row) => [
|
|
64
|
+
row.id,
|
|
65
|
+
{
|
|
66
|
+
row,
|
|
67
|
+
parts: row.parts.map((part) => rowSegments(document).get(part.rowId)),
|
|
68
|
+
},
|
|
69
|
+
])),
|
|
28
70
|
sections: new Map(document.sections.map((s) => [s.id, s.label])),
|
|
29
71
|
};
|
|
30
72
|
catalogs.set(document, catalog);
|
|
31
73
|
return catalog;
|
|
32
74
|
}
|
|
33
75
|
export function inventoryAddress(document, seat) {
|
|
34
|
-
return `${documentCatalog(document).sections.get(seat.sectionId ?? "") ?? "Unsectioned"}, ${seat.rowId ? "row" : "table"} ${seat.ownerLabel}, seat ${seat.label}`;
|
|
76
|
+
return `${documentCatalog(document).sections.get(seat.sectionId ?? "") ?? "Unsectioned"}, ${seat.rowId ? "row" : "table"} ${seat.logicalRowLabel ?? seat.ownerLabel}, seat ${seat.label}`;
|
|
35
77
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MapCategory, PhysicalDocumentV1, RowSlot, SeatingGroup, SeatSlot, UUID } from "./types.js";
|
|
2
|
+
import { SeatShape } from "./types.js";
|
|
3
|
+
import { type DomainIssue } from "./issues.js";
|
|
4
|
+
export declare function categoryCatalog(document: PhysicalDocumentV1): ReadonlyMap<UUID, MapCategory>;
|
|
5
|
+
/** Absence inherits; explicit null records an unassigned child. */
|
|
6
|
+
export declare function seatCategoryId(group: SeatingGroup, slot: SeatSlot, row?: RowSlot): UUID | null;
|
|
7
|
+
export declare function categoryReferences(groups: readonly SeatingGroup[]): Generator<{
|
|
8
|
+
id: UUID;
|
|
9
|
+
categoryId: UUID;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function categoryIssues(document: PhysicalDocumentV1): DomainIssue[];
|
|
12
|
+
/** Fragment paste reuses catalogue identity; whole-map copy remaps it with the map. */
|
|
13
|
+
export declare function remapGroupCategories(group: SeatingGroup, ids: ReadonlyMap<UUID, UUID>): SeatingGroup;
|
|
14
|
+
export declare function categoryUsage(document: PhysicalDocumentV1): ReadonlyMap<UUID, number>;
|
|
15
|
+
export declare function ticketOptionNameKey(name: string): string;
|
|
16
|
+
export type CategoryPricing = {
|
|
17
|
+
onSale: boolean;
|
|
18
|
+
optionCount: number;
|
|
19
|
+
minimum: number | null;
|
|
20
|
+
maximum: number | null;
|
|
21
|
+
missing: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function categoryPricing(category: MapCategory): CategoryPricing;
|
|
24
|
+
/** A personal circle remains an override; absence inherits the category shape. */
|
|
25
|
+
export declare function categorySeatShape(category?: MapCategory, slot?: SeatSlot): SeatShape;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { AreaKind, SeatShape, SeatingKind } from "./types.js";
|
|
2
|
+
import { issue, IssueCode } from "./issues.js";
|
|
3
|
+
const catalogs = new WeakMap();
|
|
4
|
+
export function categoryCatalog(document) {
|
|
5
|
+
let catalog = catalogs.get(document);
|
|
6
|
+
if (!catalog) {
|
|
7
|
+
catalog = new Map((document.categories ?? []).map((category) => [category.id, category]));
|
|
8
|
+
catalogs.set(document, catalog);
|
|
9
|
+
}
|
|
10
|
+
return catalog;
|
|
11
|
+
}
|
|
12
|
+
/** Absence inherits; explicit null records an unassigned child. */
|
|
13
|
+
export function seatCategoryId(group, slot, row) {
|
|
14
|
+
if (slot.categoryId !== undefined)
|
|
15
|
+
return slot.categoryId;
|
|
16
|
+
if (row?.categoryId !== undefined)
|
|
17
|
+
return row.categoryId;
|
|
18
|
+
return group.categoryId ?? null;
|
|
19
|
+
}
|
|
20
|
+
export function* categoryReferences(groups) {
|
|
21
|
+
for (const group of groups) {
|
|
22
|
+
if (group.categoryId)
|
|
23
|
+
yield { id: group.id, categoryId: group.categoryId };
|
|
24
|
+
if (group.kind === SeatingKind.Straight ||
|
|
25
|
+
group.kind === SeatingKind.Curved) {
|
|
26
|
+
for (const row of group.rows) {
|
|
27
|
+
if (row.categoryId)
|
|
28
|
+
yield { id: row.id, categoryId: row.categoryId };
|
|
29
|
+
for (const slot of row.seats)
|
|
30
|
+
if (slot.categoryId)
|
|
31
|
+
yield { id: slot.id, categoryId: slot.categoryId };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const seats = group.kind === SeatingKind.Round
|
|
36
|
+
? group.chairs
|
|
37
|
+
: Object.values(group.chairsBySide).flat();
|
|
38
|
+
for (const slot of seats)
|
|
39
|
+
if (slot.categoryId)
|
|
40
|
+
yield { id: slot.id, categoryId: slot.categoryId };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function categoryIssues(document) {
|
|
45
|
+
const categories = new Set((document.categories ?? []).map((category) => category.id));
|
|
46
|
+
return [
|
|
47
|
+
...categoryReferences(document.seatingGroups),
|
|
48
|
+
...[...document.areas, ...document.sections].flatMap((entity) => entity.categoryId
|
|
49
|
+
? [{ id: entity.id, categoryId: entity.categoryId }]
|
|
50
|
+
: []),
|
|
51
|
+
]
|
|
52
|
+
.filter((reference) => !categories.has(reference.categoryId))
|
|
53
|
+
.map((reference) => issue(IssueCode.InvalidStructure, "Category reference does not exist.", [
|
|
54
|
+
reference.id,
|
|
55
|
+
]));
|
|
56
|
+
}
|
|
57
|
+
/** Fragment paste reuses catalogue identity; whole-map copy remaps it with the map. */
|
|
58
|
+
export function remapGroupCategories(group, ids) {
|
|
59
|
+
const remap = (value) => {
|
|
60
|
+
const categoryId = value.categoryId ? ids.get(value.categoryId) : undefined;
|
|
61
|
+
return categoryId && categoryId !== value.categoryId
|
|
62
|
+
? { ...value, categoryId }
|
|
63
|
+
: value;
|
|
64
|
+
};
|
|
65
|
+
if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved)
|
|
66
|
+
return {
|
|
67
|
+
...remap(group),
|
|
68
|
+
rows: group.rows.map((row) => ({
|
|
69
|
+
...remap(row),
|
|
70
|
+
seats: row.seats.map(remap),
|
|
71
|
+
})),
|
|
72
|
+
};
|
|
73
|
+
if (group.kind === SeatingKind.Round)
|
|
74
|
+
return { ...remap(group), chairs: group.chairs.map(remap) };
|
|
75
|
+
return {
|
|
76
|
+
...remap(group),
|
|
77
|
+
chairsBySide: {
|
|
78
|
+
top: group.chairsBySide.top.map(remap),
|
|
79
|
+
right: group.chairsBySide.right.map(remap),
|
|
80
|
+
bottom: group.chairsBySide.bottom.map(remap),
|
|
81
|
+
left: group.chairsBySide.left.map(remap),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const usage = new WeakMap();
|
|
86
|
+
export function categoryUsage(document) {
|
|
87
|
+
const cached = usage.get(document);
|
|
88
|
+
if (cached)
|
|
89
|
+
return cached;
|
|
90
|
+
const counts = new Map();
|
|
91
|
+
const count = (id, quantity = 1) => {
|
|
92
|
+
if (id)
|
|
93
|
+
counts.set(id, (counts.get(id) ?? 0) + quantity);
|
|
94
|
+
};
|
|
95
|
+
for (const group of document.seatingGroups) {
|
|
96
|
+
if (group.kind === SeatingKind.Straight ||
|
|
97
|
+
group.kind === SeatingKind.Curved) {
|
|
98
|
+
for (const row of group.rows)
|
|
99
|
+
for (const slot of row.seats)
|
|
100
|
+
if (!slot.gap)
|
|
101
|
+
count(seatCategoryId(group, slot, row));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const slots = group.kind === SeatingKind.Round
|
|
105
|
+
? group.chairs
|
|
106
|
+
: Object.values(group.chairsBySide).flat();
|
|
107
|
+
for (const slot of slots)
|
|
108
|
+
if (!slot.gap)
|
|
109
|
+
count(seatCategoryId(group, slot));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const area of document.areas)
|
|
113
|
+
count(area.categoryId ?? null, area.kind === AreaKind.Booth ? 1 : area.capacity);
|
|
114
|
+
usage.set(document, counts);
|
|
115
|
+
return counts;
|
|
116
|
+
}
|
|
117
|
+
export function ticketOptionNameKey(name) {
|
|
118
|
+
return name.trim().toLowerCase();
|
|
119
|
+
}
|
|
120
|
+
export function categoryPricing(category) {
|
|
121
|
+
const options = category.ticketOptions ?? [];
|
|
122
|
+
const prices = options.length
|
|
123
|
+
? options.map((option) => option.price)
|
|
124
|
+
: category.defaultPrice == null
|
|
125
|
+
? []
|
|
126
|
+
: [category.defaultPrice];
|
|
127
|
+
return {
|
|
128
|
+
onSale: category.onSale !== false,
|
|
129
|
+
optionCount: options.length,
|
|
130
|
+
minimum: prices.length ? Math.min(...prices) : null,
|
|
131
|
+
maximum: prices.length ? Math.max(...prices) : null,
|
|
132
|
+
missing: category.onSale !== false && !prices.length,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** A personal circle remains an override; absence inherits the category shape. */
|
|
136
|
+
export function categorySeatShape(category, slot) {
|
|
137
|
+
return slot?.seatShape ?? category?.seatShape ?? SeatShape.Circle;
|
|
138
|
+
}
|
package/dist/editor-state.js
CHANGED
|
@@ -71,7 +71,7 @@ export class MapEditorPolicy {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
canLock(id) {
|
|
74
|
-
return this.nodes.has(id)
|
|
74
|
+
return this.nodes.has(id);
|
|
75
75
|
}
|
|
76
76
|
canHide(id) {
|
|
77
77
|
return this.nodes.has(id);
|
|
@@ -197,6 +197,13 @@ const appearanceFields = new Set([
|
|
|
197
197
|
"labels",
|
|
198
198
|
"labelOverride",
|
|
199
199
|
"seatSequenceOverride",
|
|
200
|
+
"aisleSeats",
|
|
201
|
+
"buyerNoun",
|
|
202
|
+
"selling",
|
|
203
|
+
"buyerNote",
|
|
204
|
+
"gap",
|
|
205
|
+
"seatShape",
|
|
206
|
+
"categoryId",
|
|
200
207
|
"attributes",
|
|
201
208
|
"seatLabelStyle",
|
|
202
209
|
"labelStyle",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PhysicalDocumentV1, type PointM, type PolygonM, type SeatingGroup, type SeatSlot, type SizeM, type Transform, type UUID } from "../types.js";
|
|
1
|
+
import { type PhysicalDocumentV1, type PointM, type PolygonM, type SeatingGroup, type SeatSlot, type SizeM, type Transform, type UUID, type LabelSequence } from "../types.js";
|
|
2
2
|
export type Matrix = {
|
|
3
3
|
a: number;
|
|
4
4
|
b: number;
|
|
@@ -16,10 +16,16 @@ export type GeneratedSeat = {
|
|
|
16
16
|
sectionId: UUID | null;
|
|
17
17
|
label: string;
|
|
18
18
|
ownerLabel: string;
|
|
19
|
+
logicalRowLabel?: string;
|
|
20
|
+
logicalRowId?: UUID;
|
|
21
|
+
logicalPartIndex?: number;
|
|
22
|
+
logicalSequence?: LabelSequence;
|
|
19
23
|
position: PointM;
|
|
20
24
|
rotationDeg: number;
|
|
21
25
|
size: SizeM;
|
|
22
26
|
slot: SeatSlot;
|
|
27
|
+
aisle: boolean;
|
|
28
|
+
categoryId: UUID | null;
|
|
23
29
|
};
|
|
24
30
|
export declare const identityMatrix: Matrix;
|
|
25
31
|
export declare const radians: (value: number) => number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { rowSeatGeometry, roundChairGeometry, rectangularChairGeometry, TableSide, } from "./seating-layout.js";
|
|
2
|
-
import { SeatingKind, } from "../types.js";
|
|
2
|
+
import { SeatingKind, TableChairDistribution, RowEnds, } from "../types.js";
|
|
3
3
|
import { sequenceLabel } from "../labels.js";
|
|
4
|
+
import { seatCategoryId } from "../categories.js";
|
|
4
5
|
import { containsPoint, intersects, pointsBounds, } from "./primitives.js";
|
|
5
6
|
export { containsPoint, emptyBounds, extend, intersects, pointsBounds, } from "./primitives.js";
|
|
6
7
|
import { prepareBoundary, footprintInBoundary } from "./boundary.js";
|
|
@@ -89,7 +90,7 @@ export function worldMatrices(document) {
|
|
|
89
90
|
return result;
|
|
90
91
|
}
|
|
91
92
|
export function* generateGroup(group) {
|
|
92
|
-
const emit = (slot, p, rotationDeg, label, ownerLabel, rowId) => ({
|
|
93
|
+
const emit = (slot, p, rotationDeg, label, ownerLabel, rowId, aisle = false, categoryId = seatCategoryId(group, slot)) => ({
|
|
93
94
|
id: slot.id,
|
|
94
95
|
groupId: group.id,
|
|
95
96
|
rowId,
|
|
@@ -103,6 +104,8 @@ export function* generateGroup(group) {
|
|
|
103
104
|
rotationDeg: normalizeAngle(rotationDeg + (slot.override?.rotationDeltaDeg ?? 0)),
|
|
104
105
|
size: slot.override?.sizeM ?? group.seatSizeM,
|
|
105
106
|
slot,
|
|
107
|
+
aisle,
|
|
108
|
+
categoryId,
|
|
106
109
|
});
|
|
107
110
|
if (group.kind === SeatingKind.Straight ||
|
|
108
111
|
group.kind === SeatingKind.Curved) {
|
|
@@ -112,11 +115,17 @@ export function* generateGroup(group) {
|
|
|
112
115
|
const owner = row.labelOverride ??
|
|
113
116
|
sequenceLabel(group.labels.rows, r, group.rows.length);
|
|
114
117
|
for (let i = 0; i < row.seats.length; i++) {
|
|
115
|
-
const geometry = rowSeatGeometry(group, r, i, row.seats.length, longestRow);
|
|
118
|
+
const geometry = rowSeatGeometry(group, r, i, row.seats.length, longestRow, row.layout);
|
|
116
119
|
let p = geometry.position;
|
|
117
120
|
const rotation = geometry.rotationDeg;
|
|
118
121
|
p = { x: p.x + (row.offsetM?.x ?? 0), y: p.y + (row.offsetM?.y ?? 0) };
|
|
119
|
-
|
|
122
|
+
const seat = emit(row.seats[i], p, rotation, sequenceLabel(row.seatSequenceOverride ?? group.labels.seats, i, row.seats.length), owner, row.id, (i === 0 &&
|
|
123
|
+
(row.aisleSeats === RowEnds.Start ||
|
|
124
|
+
row.aisleSeats === RowEnds.Both)) ||
|
|
125
|
+
(i === row.seats.length - 1 &&
|
|
126
|
+
(row.aisleSeats === RowEnds.End ||
|
|
127
|
+
row.aisleSeats === RowEnds.Both)), seatCategoryId(group, row.seats[i], row));
|
|
128
|
+
yield seat;
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
}
|
|
@@ -127,7 +136,9 @@ export function* generateGroup(group) {
|
|
|
127
136
|
}
|
|
128
137
|
}
|
|
129
138
|
else {
|
|
130
|
-
const sides =
|
|
139
|
+
const sides = group.recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
140
|
+
? [TableSide.Top, TableSide.Bottom, TableSide.Left, TableSide.Right]
|
|
141
|
+
: Object.values(TableSide);
|
|
131
142
|
const total = sides.reduce((n, s) => n + group.chairsBySide[s].length, 0);
|
|
132
143
|
let ordinal = 0;
|
|
133
144
|
for (const side of sides) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SeatShape } from "../types.js";
|
|
2
|
+
export declare enum SeatShapePartKind {
|
|
3
|
+
Rectangle = "rectangle",
|
|
4
|
+
Polygon = "polygon"
|
|
5
|
+
}
|
|
6
|
+
export type SeatShapePart = {
|
|
7
|
+
kind: SeatShapePartKind.Rectangle;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
radius: number;
|
|
13
|
+
} | {
|
|
14
|
+
kind: SeatShapePartKind.Polygon;
|
|
15
|
+
points: readonly number[];
|
|
16
|
+
};
|
|
17
|
+
export declare function seatShapeParts(shape: SeatShape): readonly SeatShapePart[];
|
|
18
|
+
/**
|
|
19
|
+
* @method seatShapeContour
|
|
20
|
+
* @description Reuses bounded normalized contours so small furniture corners stay smooth after scaling.
|
|
21
|
+
* @param {SeatShapePart} part Shared normalized furniture primitive.
|
|
22
|
+
* @returns {readonly number[]} Cached polygon coordinates for the primitive.
|
|
23
|
+
*/
|
|
24
|
+
export declare function seatShapeContour(part: SeatShapePart): readonly number[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { SeatShape } from "../types.js";
|
|
2
|
+
export var SeatShapePartKind;
|
|
3
|
+
(function (SeatShapePartKind) {
|
|
4
|
+
SeatShapePartKind["Rectangle"] = "rectangle";
|
|
5
|
+
SeatShapePartKind["Polygon"] = "polygon";
|
|
6
|
+
})(SeatShapePartKind || (SeatShapePartKind = {}));
|
|
7
|
+
const rectangle = (x, y, width, height, radius = 0) => ({
|
|
8
|
+
kind: SeatShapePartKind.Rectangle,
|
|
9
|
+
x,
|
|
10
|
+
y,
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
radius,
|
|
14
|
+
});
|
|
15
|
+
const polygon = (...points) => ({
|
|
16
|
+
kind: SeatShapePartKind.Polygon,
|
|
17
|
+
points,
|
|
18
|
+
});
|
|
19
|
+
// Normalized to the existing physical seat footprint. Category appearance never
|
|
20
|
+
// changes positions, pitch, inventory identity or the personal geometry recipe.
|
|
21
|
+
const furniture = {
|
|
22
|
+
[SeatShape.Theatre]: [
|
|
23
|
+
rectangle(-0.3, -0.42, 0.6, 0.52, 0.06),
|
|
24
|
+
rectangle(-0.42, 0, 0.84, 0.22, 0.06),
|
|
25
|
+
rectangle(-0.42, 0.12, 0.12, 0.3, 0.04),
|
|
26
|
+
rectangle(0.3, 0.12, 0.12, 0.3, 0.04),
|
|
27
|
+
],
|
|
28
|
+
[SeatShape.Dining]: [
|
|
29
|
+
polygon(-0.23, -0.42, 0.23, -0.42, 0.19, -0.055, -0.19, -0.055),
|
|
30
|
+
rectangle(-0.315, -0.055, 0.63, 0.18, 0.025),
|
|
31
|
+
polygon(-0.19, 0.08, -0.08, 0.08, -0.19, 0.42, -0.3, 0.42),
|
|
32
|
+
polygon(0.08, 0.08, 0.19, 0.08, 0.3, 0.42, 0.19, 0.42),
|
|
33
|
+
],
|
|
34
|
+
[SeatShape.Folding]: [
|
|
35
|
+
polygon(-0.3, -0.42, 0.3, -0.42, 0.25, -0.2, -0.25, -0.2),
|
|
36
|
+
polygon(-0.315, -0.14, 0.315, -0.14, 0.26, 0.02, -0.26, 0.02),
|
|
37
|
+
polygon(-0.2, 0.0, -0.1, -0.02, 0.2, 0.42, 0.08, 0.42),
|
|
38
|
+
polygon(0.1, -0.02, 0.2, 0.0, -0.08, 0.42, -0.2, 0.42),
|
|
39
|
+
],
|
|
40
|
+
[SeatShape.Armchair]: [
|
|
41
|
+
rectangle(-0.34, -0.4, 0.68, 0.46, 0.08),
|
|
42
|
+
rectangle(-0.42, -0.08, 0.14, 0.42, 0.07),
|
|
43
|
+
rectangle(0.28, -0.08, 0.14, 0.42, 0.07),
|
|
44
|
+
rectangle(-0.42, 0.08, 0.84, 0.34, 0.07),
|
|
45
|
+
],
|
|
46
|
+
[SeatShape.Recliner]: [
|
|
47
|
+
polygon(-0.18, -0.42, 0.18, -0.42, 0.26, 0.1, -0.26, 0.1),
|
|
48
|
+
rectangle(-0.39, -0.12, 0.15, 0.36, 0.07),
|
|
49
|
+
rectangle(0.24, -0.12, 0.15, 0.36, 0.07),
|
|
50
|
+
rectangle(-0.26, 0.04, 0.52, 0.1, 0.02),
|
|
51
|
+
polygon(-0.21, 0.22, 0.21, 0.22, 0.3, 0.42, -0.3, 0.42),
|
|
52
|
+
],
|
|
53
|
+
[SeatShape.Stool]: [
|
|
54
|
+
rectangle(-0.42, -0.42, 0.84, 0.57, 0.1),
|
|
55
|
+
polygon(-0.18, 0.1, -0.04, 0.1, -0.2, 0.42, -0.36, 0.42),
|
|
56
|
+
polygon(0.04, 0.1, 0.18, 0.1, 0.36, 0.42, 0.2, 0.42),
|
|
57
|
+
],
|
|
58
|
+
[SeatShape.Bench]: [
|
|
59
|
+
rectangle(-0.42, -0.4, 0.84, 0.21, 0.035),
|
|
60
|
+
rectangle(-0.42, -0.12, 0.84, 0.35, 0.025),
|
|
61
|
+
rectangle(-0.23, 0.17, 0.09, 0.25, 0.015),
|
|
62
|
+
rectangle(0.14, 0.17, 0.09, 0.25, 0.015),
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
export function seatShapeParts(shape) {
|
|
66
|
+
return shape === SeatShape.Circle ? [] : furniture[shape];
|
|
67
|
+
}
|
|
68
|
+
const contours = new WeakMap();
|
|
69
|
+
/**
|
|
70
|
+
* @method seatShapeContour
|
|
71
|
+
* @description Reuses bounded normalized contours so small furniture corners stay smooth after scaling.
|
|
72
|
+
* @param {SeatShapePart} part Shared normalized furniture primitive.
|
|
73
|
+
* @returns {readonly number[]} Cached polygon coordinates for the primitive.
|
|
74
|
+
*/
|
|
75
|
+
export function seatShapeContour(part) {
|
|
76
|
+
if (part.kind === SeatShapePartKind.Polygon) {
|
|
77
|
+
return part.points;
|
|
78
|
+
}
|
|
79
|
+
const cached = contours.get(part);
|
|
80
|
+
if (cached) {
|
|
81
|
+
return cached;
|
|
82
|
+
}
|
|
83
|
+
const { x, y, width, height } = part;
|
|
84
|
+
const radius = Math.min(part.radius, width / 2, height / 2);
|
|
85
|
+
const points = [];
|
|
86
|
+
const centers = [
|
|
87
|
+
[x + width - radius, y + radius],
|
|
88
|
+
[x + width - radius, y + height - radius],
|
|
89
|
+
[x + radius, y + height - radius],
|
|
90
|
+
[x + radius, y + radius],
|
|
91
|
+
];
|
|
92
|
+
for (let corner = 0; corner < 4; corner++) {
|
|
93
|
+
const center = centers[corner];
|
|
94
|
+
for (let step = 0; step <= 8; step++) {
|
|
95
|
+
const angle = ((corner - 1) * Math.PI) / 2 + (step * Math.PI) / 16;
|
|
96
|
+
points.push(center[0] + radius * Math.cos(angle), center[1] + radius * Math.sin(angle));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
contours.set(part, points);
|
|
100
|
+
return points;
|
|
101
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SeatingKind, type StraightRows, type CurvedRows, type RoundTable, type RectangularTable, type PointM } from "../types.js";
|
|
1
|
+
import { SeatingKind, type StraightRows, type CurvedRows, type RoundTable, type RectangularTable, type PointM, type RowLayout, type LabelSequence } from "../types.js";
|
|
2
2
|
export type RowsGeometry = Pick<StraightRows, "kind" | "recipe"> | Pick<CurvedRows, "kind" | "recipe">;
|
|
3
3
|
export declare enum TableSide {
|
|
4
4
|
Top = "top",
|
|
@@ -10,13 +10,16 @@ export type SeatGeometry = {
|
|
|
10
10
|
position: PointM;
|
|
11
11
|
rotationDeg: number;
|
|
12
12
|
};
|
|
13
|
-
export declare function rowSeatGeometry(group: RowsGeometry, row: number, seat: number, count: number, longestRow?: number): SeatGeometry;
|
|
13
|
+
export declare function rowSeatGeometry(group: RowsGeometry, row: number, seat: number, count: number, longestRow?: number, layout?: RowLayout): SeatGeometry;
|
|
14
|
+
/** Resolves inherited geometry once when a row becomes independently editable. */
|
|
15
|
+
export declare function resolveRowLayout(group: StraightRows | CurvedRows, rowIndex: number): RowLayout | null;
|
|
14
16
|
export declare function roundChairGeometry(recipe: RoundTable["recipe"], chairHeightM: number, seat: number, count: number): SeatGeometry;
|
|
15
17
|
export declare function rectangularChairGeometry(recipe: RectangularTable["recipe"], chairHeightM: number, side: TableSide, seat: number, count: number): SeatGeometry;
|
|
16
18
|
export type SeatingPreview = (RowsGeometry & {
|
|
17
19
|
rows: number;
|
|
18
20
|
seatsPerRow: number;
|
|
19
21
|
rowCounts?: readonly number[];
|
|
22
|
+
rowLayouts?: readonly (RowLayout | undefined)[];
|
|
20
23
|
seatSizeM: number;
|
|
21
24
|
}) | {
|
|
22
25
|
kind: SeatingKind.Round;
|
|
@@ -30,7 +33,13 @@ export type SeatingPreview = (RowsGeometry & {
|
|
|
30
33
|
seatSizeM: number;
|
|
31
34
|
};
|
|
32
35
|
export type PreviewNumbering = {
|
|
33
|
-
|
|
36
|
+
rowSequence: LabelSequence;
|
|
37
|
+
logicalRow?: {
|
|
38
|
+
label: string;
|
|
39
|
+
sequence: LabelSequence;
|
|
40
|
+
offset: number;
|
|
41
|
+
total: number;
|
|
42
|
+
};
|
|
34
43
|
tableLabel: string;
|
|
35
44
|
seatFontSizeM: number;
|
|
36
45
|
rowFontSizeM: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurveMode, RowAlignment, SeatingKind, } from "../types.js";
|
|
1
|
+
import { CurveMode, TableChairDistribution, RowAlignment, SeatingKind, } from "../types.js";
|
|
2
2
|
import { ellipseAngleAtDistance } from "./ellipse.js";
|
|
3
3
|
export var TableSide;
|
|
4
4
|
(function (TableSide) {
|
|
@@ -7,7 +7,32 @@ export var TableSide;
|
|
|
7
7
|
TableSide["Bottom"] = "bottom";
|
|
8
8
|
TableSide["Left"] = "left";
|
|
9
9
|
})(TableSide || (TableSide = {}));
|
|
10
|
-
export function rowSeatGeometry(group, row, seat, count, longestRow = count) {
|
|
10
|
+
export function rowSeatGeometry(group, row, seat, count, longestRow = count, layout) {
|
|
11
|
+
if (layout) {
|
|
12
|
+
const sweep = (layout.curveDeg * Math.PI) / 180;
|
|
13
|
+
const fraction = count > 1 ? seat / (count - 1) : 0;
|
|
14
|
+
const angle = sweep * fraction;
|
|
15
|
+
const distance = seat * layout.seatPitchM;
|
|
16
|
+
// Stable straight-line limit avoids division by zero and cancellation near zero.
|
|
17
|
+
const sinc = Math.abs(angle) < 1e-6
|
|
18
|
+
? 1 - (angle * angle) / 6
|
|
19
|
+
: Math.sin(angle) / angle;
|
|
20
|
+
const cosc = Math.abs(angle) < 1e-6
|
|
21
|
+
? angle / 2 - (angle * angle * angle) / 24
|
|
22
|
+
: (1 - Math.cos(angle)) / angle;
|
|
23
|
+
const x = distance * sinc;
|
|
24
|
+
const y = -distance * cosc;
|
|
25
|
+
const rotation = (layout.rotationDeg * Math.PI) / 180;
|
|
26
|
+
return {
|
|
27
|
+
position: {
|
|
28
|
+
x: layout.originM.x + x * Math.cos(rotation) - y * Math.sin(rotation),
|
|
29
|
+
y: layout.originM.y + x * Math.sin(rotation) + y * Math.cos(rotation),
|
|
30
|
+
},
|
|
31
|
+
rotationDeg: layout.rotationDeg -
|
|
32
|
+
(angle * 180) / Math.PI +
|
|
33
|
+
(layout.seatRotationOffsetDeg ?? 0),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
11
36
|
if (group.kind === SeatingKind.Straight)
|
|
12
37
|
return {
|
|
13
38
|
position: {
|
|
@@ -45,9 +70,57 @@ export function rowSeatGeometry(group, row, seat, count, longestRow = count) {
|
|
|
45
70
|
Math.PI,
|
|
46
71
|
};
|
|
47
72
|
}
|
|
73
|
+
/** Resolves inherited geometry once when a row becomes independently editable. */
|
|
74
|
+
export function resolveRowLayout(group, rowIndex) {
|
|
75
|
+
const row = group.rows[rowIndex];
|
|
76
|
+
if (row.layout)
|
|
77
|
+
return row.layout;
|
|
78
|
+
if (group.kind === SeatingKind.Curved && (group.recipe.axisRatio ?? 1) !== 1)
|
|
79
|
+
return null;
|
|
80
|
+
const longest = group.rows.reduce((max, item) => Math.max(max, item.seats.length), 0);
|
|
81
|
+
const first = rowSeatGeometry(group, rowIndex, 0, row.seats.length, longest);
|
|
82
|
+
if (group.kind === SeatingKind.Straight)
|
|
83
|
+
return {
|
|
84
|
+
originM: first.position,
|
|
85
|
+
seatPitchM: group.recipe.seatPitchM,
|
|
86
|
+
curveDeg: 0,
|
|
87
|
+
rotationDeg: ((((first.rotationDeg + 180) % 360) + 360) % 360) - 180,
|
|
88
|
+
};
|
|
89
|
+
const radius = group.recipe.innerRadiusM + rowIndex * group.recipe.rowPitchM;
|
|
90
|
+
const placement = group.recipe.placement;
|
|
91
|
+
const intervals = Math.max(0, row.seats.length - 1);
|
|
92
|
+
let sweep;
|
|
93
|
+
let pitch;
|
|
94
|
+
if (placement.kind === CurveMode.Pitch) {
|
|
95
|
+
pitch = placement.seatPitchM;
|
|
96
|
+
sweep = (((intervals * pitch) / radius) * 180) / Math.PI;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
sweep =
|
|
100
|
+
placement.sweepAngleDeg *
|
|
101
|
+
(Math.abs(placement.sweepAngleDeg) === 360
|
|
102
|
+
? intervals / row.seats.length
|
|
103
|
+
: 1);
|
|
104
|
+
pitch = intervals
|
|
105
|
+
? (((Math.abs(sweep) * Math.PI) / 180) * radius) / intervals
|
|
106
|
+
: 0.55;
|
|
107
|
+
}
|
|
108
|
+
const tangent = first.rotationDeg + (sweep < 0 ? 180 : 0);
|
|
109
|
+
return {
|
|
110
|
+
originM: first.position,
|
|
111
|
+
seatPitchM: pitch,
|
|
112
|
+
curveDeg: -sweep,
|
|
113
|
+
rotationDeg: ((((tangent + 180) % 360) + 360) % 360) - 180,
|
|
114
|
+
...(sweep < 0 ? { seatRotationOffsetDeg: -180 } : {}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
48
117
|
export function roundChairGeometry(recipe, chairHeightM, seat, count) {
|
|
49
118
|
const radius = recipe.diameterM / 2 + recipe.chairGapM + chairHeightM / 2;
|
|
50
|
-
const
|
|
119
|
+
const arc = recipe.seatArcDeg ?? 360;
|
|
120
|
+
const angle = recipe.startAngleDeg +
|
|
121
|
+
(count === 1
|
|
122
|
+
? 0
|
|
123
|
+
: (360 - arc) / 2 + (arc * seat) / (arc === 360 ? count : count - 1));
|
|
51
124
|
return {
|
|
52
125
|
position: {
|
|
53
126
|
x: radius * Math.cos((angle * Math.PI) / 180),
|
|
@@ -59,9 +132,11 @@ export function roundChairGeometry(recipe, chairHeightM, seat, count) {
|
|
|
59
132
|
export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count) {
|
|
60
133
|
const horizontal = side === TableSide.Top || side === TableSide.Bottom;
|
|
61
134
|
const length = horizontal ? recipe.widthM : recipe.depthM;
|
|
62
|
-
const along = recipe.
|
|
63
|
-
? -length / 2 + ((seat +
|
|
64
|
-
:
|
|
135
|
+
const along = recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
136
|
+
? -length / 2 + ((seat + 0.5) * length) / count
|
|
137
|
+
: recipe.chairPitchM === undefined
|
|
138
|
+
? -length / 2 + ((seat + 1) * length) / (count + 1)
|
|
139
|
+
: (seat - (count - 1) / 2) * recipe.chairPitchM;
|
|
65
140
|
const gap = recipe.chairGapM + chairHeightM / 2;
|
|
66
141
|
switch (side) {
|
|
67
142
|
case TableSide.Top:
|
|
@@ -76,12 +151,22 @@ export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count
|
|
|
76
151
|
};
|
|
77
152
|
case TableSide.Bottom:
|
|
78
153
|
return {
|
|
79
|
-
position: {
|
|
154
|
+
position: {
|
|
155
|
+
x: recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
156
|
+
? along
|
|
157
|
+
: -along,
|
|
158
|
+
y: recipe.depthM / 2 + gap,
|
|
159
|
+
},
|
|
80
160
|
rotationDeg: -90,
|
|
81
161
|
};
|
|
82
162
|
case TableSide.Left:
|
|
83
163
|
return {
|
|
84
|
-
position: {
|
|
164
|
+
position: {
|
|
165
|
+
x: -recipe.widthM / 2 - gap,
|
|
166
|
+
y: recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
167
|
+
? along
|
|
168
|
+
: -along,
|
|
169
|
+
},
|
|
85
170
|
rotationDeg: 0,
|
|
86
171
|
};
|
|
87
172
|
default: {
|
|
@@ -99,7 +184,7 @@ export function* previewSeats(layout) {
|
|
|
99
184
|
for (let row = 0; row < layout.rows; row++)
|
|
100
185
|
for (let seat = 0; seat < (layout.rowCounts?.[row] ?? layout.seatsPerRow); seat++)
|
|
101
186
|
yield {
|
|
102
|
-
position: rowSeatGeometry(layout, row, seat, layout.rowCounts?.[row] ?? layout.seatsPerRow, longestRow).position,
|
|
187
|
+
position: rowSeatGeometry(layout, row, seat, layout.rowCounts?.[row] ?? layout.seatsPerRow, longestRow, layout.rowLayouts?.[row]).position,
|
|
103
188
|
row,
|
|
104
189
|
ordinal: seat + 1,
|
|
105
190
|
};
|