@seatmap-fyi/map-domain 0.1.0-alpha.4 → 0.1.0-alpha.48

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 (107) hide show
  1. package/dist/arc-fan-rebuild.d.ts +13 -0
  2. package/dist/arc-fan-rebuild.js +163 -0
  3. package/dist/arc-fan.d.ts +27 -0
  4. package/dist/arc-fan.interface.d.ts +83 -0
  5. package/dist/arc-fan.interface.js +30 -0
  6. package/dist/arc-fan.js +182 -0
  7. package/dist/catalog.d.ts +6 -4
  8. package/dist/catalog.js +31 -17
  9. package/dist/categories.d.ts +5 -3
  10. package/dist/categories.js +104 -25
  11. package/dist/editor-state.d.ts +4 -1
  12. package/dist/editor-state.js +53 -30
  13. package/dist/floors.d.ts +22 -0
  14. package/dist/floors.js +77 -0
  15. package/dist/geometry/boundary.d.ts +1 -1
  16. package/dist/geometry/boundary.js +16 -12
  17. package/dist/geometry/curve-warnings.d.ts +1 -1
  18. package/dist/geometry/curve-warnings.js +3 -5
  19. package/dist/geometry/decoration-bounds.d.ts +4 -0
  20. package/dist/geometry/decoration-bounds.js +42 -0
  21. package/dist/geometry/ellipse.js +4 -12
  22. package/dist/geometry/geometry.d.ts +6 -3
  23. package/dist/geometry/geometry.js +28 -30
  24. package/dist/geometry/layout-transform.d.ts +10 -0
  25. package/dist/geometry/layout-transform.interface.d.ts +6 -0
  26. package/dist/geometry/layout-transform.interface.js +1 -0
  27. package/dist/geometry/layout-transform.js +206 -0
  28. package/dist/geometry/polygon-curves.d.ts +17 -0
  29. package/dist/geometry/polygon-curves.interface.d.ts +21 -0
  30. package/dist/geometry/polygon-curves.interface.js +5 -0
  31. package/dist/geometry/polygon-curves.js +169 -0
  32. package/dist/geometry/primitives.d.ts +1 -1
  33. package/dist/geometry/primitives.js +2 -3
  34. package/dist/geometry/seat-shape.d.ts +1 -1
  35. package/dist/geometry/seat-shape.js +1 -1
  36. package/dist/geometry/seating-layout.d.ts +9 -1
  37. package/dist/geometry/seating-layout.js +66 -57
  38. package/dist/geometry/units.d.ts +8 -0
  39. package/dist/geometry/units.js +13 -0
  40. package/dist/geometry/venue-outline.d.ts +4 -18
  41. package/dist/geometry/venue-outline.interface.d.ts +23 -0
  42. package/dist/geometry/venue-outline.interface.js +7 -0
  43. package/dist/geometry/venue-outline.js +107 -49
  44. package/dist/identity.d.ts +3 -1
  45. package/dist/identity.js +32 -17
  46. package/dist/issues.d.ts +15 -2
  47. package/dist/issues.js +16 -6
  48. package/dist/labels.d.ts +6 -1
  49. package/dist/labels.js +20 -18
  50. package/dist/layers.d.ts +26 -0
  51. package/dist/layers.js +86 -0
  52. package/dist/media.d.ts +27 -0
  53. package/dist/media.js +89 -0
  54. package/dist/{types.d.ts → physical-document.interface.d.ts} +117 -4
  55. package/dist/{types.js → physical-document.interface.js} +17 -0
  56. package/dist/preview.d.ts +1 -1
  57. package/dist/preview.js +39 -29
  58. package/dist/reference.js +1 -1
  59. package/dist/row-segments.d.ts +5 -1
  60. package/dist/row-segments.js +10 -9
  61. package/dist/schema.d.ts +591 -14
  62. package/dist/schema.js +238 -102
  63. package/dist/seat-proximity.d.ts +4 -0
  64. package/dist/seat-proximity.js +119 -0
  65. package/dist/section-elevation.d.ts +5 -0
  66. package/dist/section-elevation.interface.d.ts +26 -0
  67. package/dist/section-elevation.interface.js +8 -0
  68. package/dist/section-elevation.js +53 -0
  69. package/dist/section-fill-rebuild.d.ts +10 -0
  70. package/dist/section-fill-rebuild.js +64 -0
  71. package/dist/section-fill.d.ts +84 -0
  72. package/dist/section-fill.interface.d.ts +94 -0
  73. package/dist/section-fill.interface.js +22 -0
  74. package/dist/section-fill.js +306 -0
  75. package/dist/section-growth.d.ts +11 -0
  76. package/dist/section-growth.interface.d.ts +12 -0
  77. package/dist/section-growth.interface.js +1 -0
  78. package/dist/section-growth.js +198 -0
  79. package/dist/section-layout.d.ts +95 -0
  80. package/dist/section-layout.interface.d.ts +8 -0
  81. package/dist/section-layout.interface.js +5 -0
  82. package/dist/section-layout.js +70 -0
  83. package/dist/section-outline-refit.d.ts +8 -0
  84. package/dist/section-outline-refit.js +246 -0
  85. package/dist/section-refit.d.ts +22 -0
  86. package/dist/section-refit.interface.d.ts +49 -0
  87. package/dist/section-refit.interface.js +6 -0
  88. package/dist/section-refit.js +179 -0
  89. package/dist/section-scale.d.ts +2 -0
  90. package/dist/section-scale.js +128 -0
  91. package/dist/sections.d.ts +23 -0
  92. package/dist/sections.js +144 -0
  93. package/dist/selling.d.ts +1 -1
  94. package/dist/selling.js +11 -26
  95. package/dist/spacing-repairs.d.ts +31 -0
  96. package/dist/spacing-repairs.js +168 -0
  97. package/dist/table-layout.d.ts +1 -2
  98. package/dist/table-layout.js +14 -22
  99. package/dist/validation.d.ts +7 -2
  100. package/dist/validation.interface.d.ts +20 -0
  101. package/dist/validation.interface.js +9 -0
  102. package/dist/validation.js +221 -85
  103. package/dist/wayfinding.d.ts +10 -0
  104. package/dist/wayfinding.interface.d.ts +52 -0
  105. package/dist/wayfinding.interface.js +28 -0
  106. package/dist/wayfinding.js +63 -0
  107. package/package.json +89 -4
@@ -0,0 +1,128 @@
1
+ import { generatedSeats, inverse, project, worldMatrices } from "./geometry/geometry.js";
2
+ import { rowPlacementOffset, resolveRowLayout } from "./geometry/seating-layout.js";
3
+ import { LayoutUnitM } from "./geometry/units.js";
4
+ import { AreaKind, DecorationKind, SeatingKind, ShapeKind, } from "./physical-document.interface.js";
5
+ const SectionPitchUnits = { min: 14, max: 80 };
6
+ const SectionRoundRadiusUnitsMin = 18;
7
+ export function scaleSectionLayout(document, sectionId, targets, pivot, scalePercent, factor) {
8
+ const scalePoint = (point, origin = pivot) => ({
9
+ x: origin.x + (point.x - origin.x) * factor,
10
+ y: origin.y + (point.y - origin.y) * factor,
11
+ });
12
+ const scaleLocalPoint = ({ x, y }) => ({ x: x * factor, y: y * factor });
13
+ const scalePolygon = (polygon, mapPoint) => ({
14
+ ...polygon,
15
+ outer: polygon.outer.map(mapPoint),
16
+ holes: polygon.holes.map((ring) => ring.map(mapPoint)),
17
+ });
18
+ const matrices = worldMatrices(document);
19
+ const moveDrawable = (entity) => {
20
+ const world = matrices.get(entity.id);
21
+ const center = scalePoint({ x: world.tx, y: world.ty });
22
+ const positionM = entity.parentId ? project(inverse(matrices.get(entity.parentId)), center) : center;
23
+ return { ...entity, transform: { ...entity.transform, positionM } };
24
+ };
25
+ const scaleArea = (area) => {
26
+ if (!targets.has(area.id))
27
+ return area;
28
+ const moved = moveDrawable(area);
29
+ if (moved.kind !== AreaKind.GeneralAdmission)
30
+ return moved;
31
+ const { shape } = moved;
32
+ return {
33
+ ...moved,
34
+ shape: shape.kind === ShapeKind.Polygon
35
+ ? { ...shape, boundary: scalePolygon(shape.boundary, scaleLocalPoint) }
36
+ : { ...shape, widthM: shape.widthM * factor, heightM: shape.heightM * factor },
37
+ };
38
+ };
39
+ const scaleArtwork = (art) => {
40
+ if (!targets.has(art.id))
41
+ return art;
42
+ const moved = moveDrawable(art);
43
+ if (moved.kind === DecorationKind.Line)
44
+ return { ...moved, pointsM: moved.pointsM.map(scaleLocalPoint) };
45
+ if (moved.kind === DecorationKind.Polygon)
46
+ return { ...moved, boundary: scalePolygon(moved.boundary, scaleLocalPoint) };
47
+ return moved;
48
+ };
49
+ const scaleGroup = (group) => {
50
+ if (group.kind === SeatingKind.Round || group.kind === SeatingKind.Rectangular) {
51
+ if (!targets.has(group.id))
52
+ return group;
53
+ if (group.kind === SeatingKind.Rectangular)
54
+ return moveDrawable(group);
55
+ const radiusUnits = Math.round((group.recipe.diameterM / (2 * LayoutUnitM)) * factor);
56
+ const diameterM = 2 * Math.max(SectionRoundRadiusUnitsMin, radiusUnits) * LayoutUnitM;
57
+ return moveDrawable({ ...group, recipe: { ...group.recipe, diameterM } });
58
+ }
59
+ if (!group.rows.some(({ id }) => targets.has(id)))
60
+ return group;
61
+ const localPivot = project(inverse(matrices.get(group.id)), pivot);
62
+ let positions;
63
+ return {
64
+ ...group,
65
+ rows: group.rows.map((row, index) => {
66
+ if (!targets.has(row.id))
67
+ return row;
68
+ const layout = resolveRowLayout(group, index);
69
+ if (!layout) {
70
+ // A partial ellipse has no independent circular row recipe. Retain its exact positions.
71
+ const currentPositions = (positions ??= new Map(generatedSeats(group).map(({ id, position }) => [id, position])));
72
+ return {
73
+ ...row,
74
+ seats: row.seats.map((seat) => {
75
+ const current = currentPositions.get(seat.id);
76
+ const scaled = scalePoint(current, localPivot);
77
+ return {
78
+ ...seat,
79
+ override: {
80
+ ...seat.override,
81
+ offsetM: {
82
+ x: (seat.override?.offsetM?.x ?? 0) + scaled.x - current.x,
83
+ y: (seat.override?.offsetM?.y ?? 0) + scaled.y - current.y,
84
+ },
85
+ },
86
+ };
87
+ }),
88
+ };
89
+ }
90
+ const offset = rowPlacementOffset(group, index, row.offsetM);
91
+ const origin = scalePoint({ x: layout.originM.x + offset.x, y: layout.originM.y + offset.y }, localPivot);
92
+ const pitchUnits = Math.round((layout.seatPitchM / LayoutUnitM) * factor);
93
+ const seatPitchM = Math.min(SectionPitchUnits.max, Math.max(SectionPitchUnits.min, pitchUnits)) * LayoutUnitM;
94
+ return {
95
+ ...row,
96
+ layout: { ...layout, originM: { x: origin.x - offset.x, y: origin.y - offset.y }, seatPitchM },
97
+ seats: row.seats.map((seat) => seat.override?.offsetM
98
+ ? {
99
+ ...seat,
100
+ override: {
101
+ ...seat.override,
102
+ offsetM: { x: seat.override.offsetM.x * factor, y: seat.override.offsetM.y * factor },
103
+ },
104
+ }
105
+ : seat),
106
+ };
107
+ }),
108
+ };
109
+ };
110
+ return {
111
+ ...document,
112
+ sections: document.sections.map((section) => {
113
+ if (section.id !== sectionId || !section.outline)
114
+ return section;
115
+ return {
116
+ ...section,
117
+ scalePercent,
118
+ outline: scalePolygon(section.outline, (point) => scalePoint(point)),
119
+ ...(section.labelPlacement
120
+ ? { labelPlacement: { ...section.labelPlacement, positionM: scalePoint(section.labelPlacement.positionM) } }
121
+ : {}),
122
+ };
123
+ }),
124
+ seatingGroups: document.seatingGroups.map(scaleGroup),
125
+ areas: document.areas.map(scaleArea),
126
+ decorations: document.decorations.map(scaleArtwork),
127
+ };
128
+ }
@@ -0,0 +1,23 @@
1
+ import { type PhysicalDocumentV1, type UUID } from "./physical-document.interface.js";
2
+ export type SectionEntry = {
3
+ /** Physical rows, tables, areas and artwork editable in this workspace. */
4
+ editableObjects: ReadonlySet<UUID>;
5
+ /** Also includes bank and collection ancestors needed to render those objects. */
6
+ renderMembers: ReadonlySet<UUID>;
7
+ /** Primary inventory only; overlapping workspaces do not count it twice. */
8
+ inventory: ReadonlySet<UUID>;
9
+ capacity: {
10
+ physicalSeats: number;
11
+ gaQuantity: number;
12
+ };
13
+ };
14
+ export type SectionCatalog = {
15
+ entries: ReadonlyMap<UUID, SectionEntry>;
16
+ /** Physical inventory owners; complete banks also expose their common owner. */
17
+ owners: ReadonlyMap<UUID, UUID>;
18
+ };
19
+ /**
20
+ * Spatial inventory boundaries own their first-contained anchors. Overview-only and
21
+ * outline-free sections retain their explicit inventory grouping, independently of artwork geometry.
22
+ */
23
+ export declare function sectionCatalog(document: PhysicalDocumentV1): SectionCatalog;
@@ -0,0 +1,144 @@
1
+ import { polygonContour } from "./geometry/polygon-curves.js";
2
+ import { BoundaryLocation, classifyBoundary, prepareBoundary } from "./geometry/boundary.js";
3
+ import { decorationBounds } from "./geometry/decoration-bounds.js";
4
+ import { generatedSeats, pointsBounds, project, worldMatrices } from "./geometry/geometry.js";
5
+ import { AreaKind, ShapeKind, SectionOutlineRole, DecorationKind, } from "./physical-document.interface.js";
6
+ const catalogs = new WeakMap();
7
+ /**
8
+ * Spatial inventory boundaries own their first-contained anchors. Overview-only and
9
+ * outline-free sections retain their explicit inventory grouping, independently of artwork geometry.
10
+ */
11
+ export function sectionCatalog(document) {
12
+ const cached = catalogs.get(document);
13
+ if (cached)
14
+ return cached;
15
+ const entries = new Map();
16
+ const owners = new Map();
17
+ const catalog = { entries, owners };
18
+ if (!document.sections.length) {
19
+ catalogs.set(document, catalog);
20
+ return catalog;
21
+ }
22
+ const matrices = worldMatrices(document);
23
+ const anchors = [];
24
+ for (const group of document.seatingGroups) {
25
+ const matrix = matrices.get(group.id);
26
+ const seats = generatedSeats(group);
27
+ if (!("rows" in group)) {
28
+ anchors.push({
29
+ id: group.id,
30
+ floorId: group.floorId ?? null,
31
+ point: project(matrix, { x: 0, y: 0 }),
32
+ parentId: group.parentId,
33
+ declaredSectionId: group.sectionId,
34
+ capacity: { physicalSeats: seats.filter((seat) => !seat.slot.gap).length, gaQuantity: 0 },
35
+ });
36
+ continue;
37
+ }
38
+ const rows = new Map();
39
+ for (const seat of seats) {
40
+ const rowId = seat.rowId;
41
+ const row = rows.get(rowId) ?? { x: 0, y: 0, slots: 0, seats: 0 };
42
+ row.x += seat.position.x;
43
+ row.y += seat.position.y;
44
+ row.slots++;
45
+ if (!seat.slot.gap)
46
+ row.seats++;
47
+ rows.set(rowId, row);
48
+ }
49
+ for (const row of group.rows) {
50
+ const geometry = rows.get(row.id);
51
+ anchors.push({
52
+ id: row.id,
53
+ floorId: group.floorId ?? null,
54
+ point: project(matrix, { x: geometry.x / geometry.slots, y: geometry.y / geometry.slots }),
55
+ groupId: group.id,
56
+ parentId: group.parentId,
57
+ declaredSectionId: group.sectionId,
58
+ capacity: { physicalSeats: geometry.seats, gaQuantity: 0 },
59
+ });
60
+ }
61
+ }
62
+ for (const area of document.areas) {
63
+ const matrix = matrices.get(area.id);
64
+ const point = area.shape.kind === ShapeKind.Polygon
65
+ ? center(pointsBounds(polygonContour(area.shape.boundary).outer.map((point) => project(matrix, point))))
66
+ : project(matrix, { x: 0, y: 0 });
67
+ anchors.push({
68
+ id: area.id,
69
+ floorId: area.floorId ?? null,
70
+ point,
71
+ parentId: area.parentId,
72
+ declaredSectionId: area.sectionId,
73
+ capacity: {
74
+ physicalSeats: area.kind === AreaKind.Booth ? 1 : 0,
75
+ gaQuantity: area.kind === AreaKind.GeneralAdmission ? area.capacity : 0,
76
+ },
77
+ });
78
+ }
79
+ for (const art of document.decorations) {
80
+ const matrix = matrices.get(art.id);
81
+ const point = art.kind === DecorationKind.Line
82
+ ? project(matrix, art.pointsM.reduce((sum, point) => ({
83
+ x: sum.x + point.x / art.pointsM.length,
84
+ y: sum.y + point.y / art.pointsM.length,
85
+ }), { x: 0, y: 0 }))
86
+ : center(decorationBounds(art, matrix));
87
+ anchors.push({
88
+ id: art.id,
89
+ floorId: art.floorId ?? null,
90
+ point,
91
+ parentId: art.parentId,
92
+ });
93
+ }
94
+ const collections = new Map(document.collections.map((collection) => [collection.id, collection]));
95
+ for (const section of document.sections) {
96
+ const editableObjects = new Set();
97
+ const renderMembers = new Set([section.id]);
98
+ const inventory = new Set();
99
+ const capacity = { physicalSeats: 0, gaQuantity: 0 };
100
+ entries.set(section.id, { editableObjects, renderMembers, inventory, capacity });
101
+ const spatial = section.outline && (section.outlineRole ?? SectionOutlineRole.Boundary) === SectionOutlineRole.Boundary;
102
+ const boundary = spatial ? prepareBoundary(section.outline) : null;
103
+ for (const anchor of anchors) {
104
+ if (anchor.floorId !== (section.floorId ?? null))
105
+ continue;
106
+ if (boundary) {
107
+ if (classifyBoundary(boundary, anchor.point) === BoundaryLocation.Outside)
108
+ continue;
109
+ }
110
+ else if (anchor.declaredSectionId !== section.id)
111
+ continue;
112
+ editableObjects.add(anchor.id);
113
+ renderMembers.add(anchor.id);
114
+ if (anchor.groupId)
115
+ renderMembers.add(anchor.groupId);
116
+ addCollectionAncestors(renderMembers, anchor.parentId, collections);
117
+ if (anchor.capacity && !owners.has(anchor.id)) {
118
+ owners.set(anchor.id, section.id);
119
+ inventory.add(anchor.id);
120
+ capacity.physicalSeats += anchor.capacity.physicalSeats;
121
+ capacity.gaQuantity += anchor.capacity.gaQuantity;
122
+ }
123
+ }
124
+ }
125
+ for (const group of document.seatingGroups) {
126
+ if (!("rows" in group))
127
+ continue;
128
+ const owner = owners.get(group.rows[0].id);
129
+ if (owner && group.rows.every((row) => owners.get(row.id) === owner))
130
+ owners.set(group.id, owner);
131
+ }
132
+ catalogs.set(document, catalog);
133
+ return catalog;
134
+ }
135
+ function center(bounds) {
136
+ return { x: (bounds.minX + bounds.maxX) / 2, y: (bounds.minY + bounds.maxY) / 2 };
137
+ }
138
+ function addCollectionAncestors(members, parentId, collections) {
139
+ let id = parentId;
140
+ while (id) {
141
+ members.add(id);
142
+ id = collections.get(id).parentId;
143
+ }
144
+ }
package/dist/selling.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, type SeatingGroup, type InventoryArea, type SeatSlot } from "./types.js";
1
+ import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, type SeatingGroup, type InventoryArea, type SeatSlot } from "./physical-document.interface.js";
2
2
  export type TableInventory = Extract<SeatingGroup, {
3
3
  kind: SeatingKind.Round | SeatingKind.Rectangular;
4
4
  }>;
package/dist/selling.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, } from "./types.js";
1
+ import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, } from "./physical-document.interface.js";
2
2
  export const StandingPartyLimit = 100;
3
3
  export const StandingCapacityLimit = 100_000;
4
4
  /** An explicitly cleared tag still owns settings until Reset, as in the reference editor. */
@@ -10,9 +10,7 @@ export function tableSellingState(table) {
10
10
  const cached = tableStates.get(table);
11
11
  if (cached)
12
12
  return cached;
13
- const sides = table.kind === SeatingKind.Round
14
- ? [table.chairs]
15
- : Object.values(table.chairsBySide);
13
+ const sides = table.kind === SeatingKind.Round ? [table.chairs] : Object.values(table.chairsBySide);
16
14
  let chairCount = 0, hasPersonalSettings = false;
17
15
  for (const chairs of sides) {
18
16
  chairCount += chairs.length;
@@ -50,14 +48,11 @@ export function tableSellingValid(table) {
50
48
  const state = tableSellingState(table);
51
49
  if (state.mode !== TableBookingMode.Individual && state.hasPersonalSettings)
52
50
  return false;
53
- return (state.minGuests >= 1 &&
54
- state.minGuests <= state.maxGuests &&
55
- state.maxGuests <= state.chairCount);
51
+ return state.minGuests >= 1 && state.minGuests <= state.maxGuests && state.maxGuests <= state.chairCount;
56
52
  }
57
53
  export function setTableBookingMode(table, mode) {
58
54
  const state = tableSellingState(table);
59
- if (state.mode === mode ||
60
- (mode !== TableBookingMode.Individual && state.hasPersonalSettings))
55
+ if (state.mode === mode || (mode !== TableBookingMode.Individual && state.hasPersonalSettings))
61
56
  return table;
62
57
  const selling = mode === TableBookingMode.Individual
63
58
  ? undefined
@@ -70,8 +65,7 @@ export function resizeTableSelling(table) {
70
65
  if (table.selling?.mode !== TableBookingMode.Party)
71
66
  return table;
72
67
  const range = resizedRange(table.selling, tableSellingState(table).chairCount);
73
- if (range.minGuests === table.selling.minGuests &&
74
- range.maxGuests === table.selling.maxGuests)
68
+ if (range.minGuests === table.selling.minGuests && range.maxGuests === table.selling.maxGuests)
75
69
  return table;
76
70
  return { ...table, selling: { ...table.selling, ...range } };
77
71
  }
@@ -79,8 +73,7 @@ export function setTablePartySize(table, field, value) {
79
73
  if (table.selling?.mode !== TableBookingMode.Party)
80
74
  return table;
81
75
  const range = editedRange(table.selling, tableSellingState(table).chairCount, field, value);
82
- if (range.minGuests === table.selling.minGuests &&
83
- range.maxGuests === table.selling.maxGuests)
76
+ if (range.minGuests === table.selling.minGuests && range.maxGuests === table.selling.maxGuests)
84
77
  return table;
85
78
  return { ...table, selling: { ...table.selling, ...range } };
86
79
  }
@@ -101,8 +94,7 @@ export function standingSellingState(area) {
101
94
  export function standingSellingValid(area) {
102
95
  const state = standingSellingState(area);
103
96
  return (state.wheelchairPlaces <= area.capacity &&
104
- (state.mode === StandingBookingMode.Standing ||
105
- area.capacity <= StandingPartyLimit) &&
97
+ (state.mode === StandingBookingMode.Standing || area.capacity <= StandingPartyLimit) &&
106
98
  state.minGuests >= 1 &&
107
99
  state.minGuests <= state.maxGuests &&
108
100
  state.maxGuests <= area.capacity);
@@ -110,15 +102,11 @@ export function standingSellingValid(area) {
110
102
  function standingConfiguration(mode, wheelchairPlaces, range) {
111
103
  if (mode === StandingBookingMode.Standing && wheelchairPlaces === 0)
112
104
  return undefined;
113
- return mode === StandingBookingMode.Party
114
- ? { mode, wheelchairPlaces, ...range }
115
- : { mode, wheelchairPlaces };
105
+ return mode === StandingBookingMode.Party ? { mode, wheelchairPlaces, ...range } : { mode, wheelchairPlaces };
116
106
  }
117
107
  export function setStandingBookingMode(area, mode) {
118
108
  const state = standingSellingState(area);
119
- if (state.mode === mode ||
120
- (mode !== StandingBookingMode.Standing &&
121
- area.capacity > StandingPartyLimit))
109
+ if (state.mode === mode || (mode !== StandingBookingMode.Standing && area.capacity > StandingPartyLimit))
122
110
  return area;
123
111
  return {
124
112
  ...area,
@@ -130,9 +118,7 @@ export function setStandingBookingMode(area, mode) {
130
118
  }
131
119
  export function setStandingCapacity(area, requested) {
132
120
  const state = standingSellingState(area);
133
- const limit = state.mode === StandingBookingMode.Standing
134
- ? StandingCapacityLimit
135
- : StandingPartyLimit;
121
+ const limit = state.mode === StandingBookingMode.Standing ? StandingCapacityLimit : StandingPartyLimit;
136
122
  const capacity = Math.min(limit, Math.max(1, Math.round(requested)));
137
123
  if (capacity === area.capacity)
138
124
  return area;
@@ -146,8 +132,7 @@ export function setStandingPartySize(area, field, value) {
146
132
  if (area.selling?.mode !== StandingBookingMode.Party)
147
133
  return area;
148
134
  const range = editedRange(area.selling, area.capacity, field, value);
149
- if (range.minGuests === area.selling.minGuests &&
150
- range.maxGuests === area.selling.maxGuests)
135
+ if (range.minGuests === area.selling.minGuests && range.maxGuests === area.selling.maxGuests)
151
136
  return area;
152
137
  return { ...area, selling: { ...area.selling, ...range } };
153
138
  }
@@ -0,0 +1,31 @@
1
+ import { type PhysicalDocumentV1, type RectangularTableRecipe, type RoundTableRecipe, type RowLayout, type UUID } from "./physical-document.interface.js";
2
+ export declare enum SpacingRepairKind {
3
+ Row = "row",
4
+ LongTable = "longTable",
5
+ RoundTable = "roundTable"
6
+ }
7
+ export type SpacingRepair = {
8
+ groupId: UUID;
9
+ entityId: UUID;
10
+ description: string;
11
+ } & ({
12
+ kind: SpacingRepairKind.Row;
13
+ layout: RowLayout;
14
+ } | {
15
+ kind: SpacingRepairKind.LongTable;
16
+ recipe: RectangularTableRecipe;
17
+ } | {
18
+ kind: SpacingRepairKind.RoundTable;
19
+ recipe: RoundTableRecipe;
20
+ });
21
+ /** Spacing-only proposals retain inventory/metadata and the mean of remaining row seats. */
22
+ export declare function spacingRepairs(document: PhysicalDocumentV1): readonly SpacingRepair[];
23
+ export type SpacingRepairQuality = {
24
+ before: number;
25
+ after: number;
26
+ };
27
+ /** Preview only the reviewed proposals, with structural sharing and no editable/history state. */
28
+ export declare function spacingRepairReview(document: PhysicalDocumentV1, repairs: readonly SpacingRepair[]): {
29
+ quality: SpacingRepairQuality | null;
30
+ blocked: boolean;
31
+ };
@@ -0,0 +1,168 @@
1
+ import { resizeRoundTable } from "./table-layout.js";
2
+ import { IssueCode, IssueSeverity, issueKey } from "./issues.js";
3
+ import { validatePhysicalDocument } from "./validation.js";
4
+ import { seatProximityIssues } from "./seat-proximity.js";
5
+ import { resolveRowLayout, rowSeatGeometry } from "./geometry/seating-layout.js";
6
+ import { LayoutUnitM } from "./geometry/units.js";
7
+ import { SeatingKind, TableChairDistribution, } from "./physical-document.interface.js";
8
+ export var SpacingRepairKind;
9
+ (function (SpacingRepairKind) {
10
+ SpacingRepairKind["Row"] = "row";
11
+ SpacingRepairKind["LongTable"] = "longTable";
12
+ SpacingRepairKind["RoundTable"] = "roundTable";
13
+ })(SpacingRepairKind || (SpacingRepairKind = {}));
14
+ const targetPitchM = 22.5 * LayoutUnitM;
15
+ const proposals = new WeakMap();
16
+ /** Spacing-only proposals retain inventory/metadata and the mean of remaining row seats. */
17
+ export function spacingRepairs(document) {
18
+ const cached = proposals.get(document);
19
+ if (cached)
20
+ return cached;
21
+ const result = [];
22
+ const crowded = new Set(seatProximityIssues(document)
23
+ .filter((finding) => finding.entityIds.length === 1)
24
+ .map((finding) => finding.entityIds[0]));
25
+ for (const group of document.seatingGroups) {
26
+ if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved) {
27
+ for (const [index, row] of group.rows.entries()) {
28
+ if (!crowded.has(row.id) || row.seats.length < 2)
29
+ continue;
30
+ const layout = resolveRowLayout(group, index);
31
+ if (!layout || layout.seatPitchM >= targetPitchM)
32
+ continue;
33
+ let remaining = 0;
34
+ let indexSum = 0;
35
+ let centreX = 0;
36
+ let centreY = 0;
37
+ for (const [seat, slot] of row.seats.entries()) {
38
+ if (slot.gap)
39
+ continue;
40
+ remaining++;
41
+ if (layout.curveDeg === 0)
42
+ indexSum += seat;
43
+ else {
44
+ const position = rowSeatGeometry(group, index, seat, row.seats.length, row.seats.length, layout).position;
45
+ centreX += position.x - layout.originM.x;
46
+ centreY += position.y - layout.originM.y;
47
+ }
48
+ }
49
+ let shiftX;
50
+ let shiftY;
51
+ if (layout.curveDeg === 0) {
52
+ const shiftM = (targetPitchM - layout.seatPitchM) * (indexSum / remaining);
53
+ const angle = (layout.rotationDeg * Math.PI) / 180;
54
+ shiftX = shiftM * Math.cos(angle);
55
+ shiftY = shiftM * Math.sin(angle);
56
+ }
57
+ else {
58
+ const expansion = targetPitchM / layout.seatPitchM - 1;
59
+ shiftX = (centreX / remaining) * expansion;
60
+ shiftY = (centreY / remaining) * expansion;
61
+ }
62
+ result.push({
63
+ kind: SpacingRepairKind.Row,
64
+ groupId: group.id,
65
+ entityId: row.id,
66
+ description: `Expanded ${row.id} to the 22.5u target pitch while preserving its centre`,
67
+ layout: {
68
+ ...layout,
69
+ seatPitchM: targetPitchM,
70
+ originM: {
71
+ x: layout.originM.x - shiftX,
72
+ y: layout.originM.y - shiftY,
73
+ },
74
+ },
75
+ });
76
+ }
77
+ }
78
+ else if (group.kind === SeatingKind.Round && crowded.has(group.id) && group.chairs.length > 1) {
79
+ const arc = group.recipe.seatArcDeg ?? 360;
80
+ const intervals = arc === 360 ? group.chairs.length : group.chairs.length - 1;
81
+ const step = (arc * Math.PI) / (180 * intervals);
82
+ const orbitM = targetPitchM / (2 * Math.sin(step / 2));
83
+ const diameterM = 2 * (orbitM - group.recipe.chairGapM - group.seatSizeM.height / 2);
84
+ if (diameterM <= group.recipe.diameterM)
85
+ continue;
86
+ result.push({
87
+ kind: SpacingRepairKind.RoundTable,
88
+ groupId: group.id,
89
+ entityId: group.id,
90
+ description: `Expanded ${group.id} so its perimeter seats meet the 22.5u target pitch`,
91
+ recipe: { ...group.recipe, diameterM },
92
+ });
93
+ }
94
+ else if (group.kind === SeatingKind.Rectangular &&
95
+ crowded.has(group.id) &&
96
+ group.recipe.chairDistribution === TableChairDistribution.EqualSegments) {
97
+ const widthM = Math.max(group.recipe.widthM, Math.max(group.chairsBySide.top.length, group.chairsBySide.bottom.length) * targetPitchM);
98
+ const depthM = Math.max(group.recipe.depthM, Math.max(group.chairsBySide.left.length, group.chairsBySide.right.length) * targetPitchM);
99
+ if (widthM === group.recipe.widthM && depthM === group.recipe.depthM)
100
+ continue;
101
+ result.push({
102
+ kind: SpacingRepairKind.LongTable,
103
+ groupId: group.id,
104
+ entityId: group.id,
105
+ description: `Expanded ${group.id} so its perimeter seats meet the 22.5u target pitch`,
106
+ recipe: { ...group.recipe, widthM, depthM },
107
+ });
108
+ }
109
+ }
110
+ proposals.set(document, result);
111
+ return result;
112
+ }
113
+ const qualityCodes = new Set([IssueCode.SeatOverlap, IssueCode.SeatCramped, IssueCode.MissingCategoryPrice]);
114
+ /** Only the qualified geometry/pricing families produce a score; other quality rules remain open. */
115
+ function qualityScore(findings) {
116
+ if (findings.some((finding) => !qualityCodes.has(finding.code)))
117
+ return null;
118
+ let geometry = 0;
119
+ let pricing = 0;
120
+ for (const finding of findings) {
121
+ if (finding.code === IssueCode.MissingCategoryPrice)
122
+ pricing += 2;
123
+ else
124
+ geometry += finding.code === IssueCode.SeatOverlap ? 15 : 4;
125
+ }
126
+ return Math.max(0, 100 - Math.min(30, geometry) - pricing);
127
+ }
128
+ /** Preview only the reviewed proposals, with structural sharing and no editable/history state. */
129
+ export function spacingRepairReview(document, repairs) {
130
+ const beforeFindings = validatePhysicalDocument(document);
131
+ const before = qualityScore(beforeFindings);
132
+ const rows = new Map(repairs.flatMap((repair) => repair.kind === SpacingRepairKind.Row ? [[repair.entityId, repair.layout]] : []));
133
+ const longTables = new Map(repairs.flatMap((repair) => repair.kind === SpacingRepairKind.LongTable ? [[repair.groupId, repair.recipe]] : []));
134
+ const roundTables = new Map(repairs.flatMap((repair) => repair.kind === SpacingRepairKind.RoundTable ? [[repair.groupId, repair.recipe]] : []));
135
+ let automaticSizeConflict = false;
136
+ const seatingGroups = document.seatingGroups.map((group) => {
137
+ if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved) {
138
+ if (!group.rows.some((row) => rows.has(row.id)))
139
+ return group;
140
+ return {
141
+ ...group,
142
+ rows: group.rows.map((row) => {
143
+ const layout = rows.get(row.id);
144
+ return layout ? { ...row, layout } : row;
145
+ }),
146
+ };
147
+ }
148
+ if (group.kind === SeatingKind.Round) {
149
+ const recipe = roundTables.get(group.id);
150
+ if (!recipe)
151
+ return group;
152
+ const projected = resizeRoundTable({ ...group, recipe });
153
+ if (projected.recipe.diameterM !== recipe.diameterM)
154
+ automaticSizeConflict = true;
155
+ return projected;
156
+ }
157
+ const recipe = longTables.get(group.id);
158
+ return recipe ? { ...group, recipe } : group;
159
+ });
160
+ const afterFindings = validatePhysicalDocument({ ...document, seatingGroups });
161
+ const after = qualityScore(afterFindings);
162
+ const existingErrors = new Set(beforeFindings.filter((finding) => finding.severity === IssueSeverity.Error).map(issueKey));
163
+ return {
164
+ quality: before === null || after === null ? null : { before, after },
165
+ blocked: automaticSizeConflict ||
166
+ afterFindings.some((finding) => finding.severity === IssueSeverity.Error && !existingErrors.has(issueKey(finding))),
167
+ };
168
+ }
@@ -1,6 +1,5 @@
1
- import { SeatingKind, type RoundTable, type RectangularTable, type LongTableLayout, type RoundTableRecipe } from "./types.js";
1
+ import { SeatingKind, type RoundTable, type RectangularTable, type LongTableLayout, type RoundTableRecipe } from "./physical-document.interface.js";
2
2
  import type { TableInventory } from "./selling.js";
3
- export declare const TableLayoutUnitM: number;
4
3
  export declare const TableLayoutDefaults: {
5
4
  readonly chairSizeM: number;
6
5
  readonly chairGapM: number;