@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,13 @@
1
+ import { ArcFanRebuildIssue, type ArcFanInput, type ArcFanPart, type ArcFanPlan, type ArcFanRows, type ArcFanRebuildSource, type ArcFanRebuildPlacement } from "./arc-fan.interface.js";
2
+ import type { PhysicalDocumentV1, RowSlot } from "./physical-document.interface.js";
3
+ export declare const arcFanRebuildMessages: Record<ArcFanRebuildIssue, string>;
4
+ export declare const arcFanGeometryEntryMessage = "This fan has manually edited geometry. Edit its rows individually to keep those changes.";
5
+ export declare function arcFanParts(plan: ArcFanPlan): ArcFanPart[];
6
+ /** Compare current physical rows with generation provenance; seat customizations remain independent. */
7
+ export declare function arcFanRebuildSource(group: ArcFanRows): ArcFanRebuildSource | null;
8
+ export declare function arcFanSequenceCustomized(row: RowSlot, part: ArcFanPart): boolean;
9
+ export declare function reviewArcFanRebuild(group: ArcFanRows, plan: ArcFanPlan): ArcFanRebuildIssue | null;
10
+ /** Show the same authored fan in world coordinates, including inherited rotation and reflection. */
11
+ export declare function arcFanWorldInput(document: PhysicalDocumentV1, group: ArcFanRows): ArcFanInput;
12
+ /** Convert the form's world draft back into the bank's single local geometry owner. */
13
+ export declare function arcFanRebuildPlacement(document: PhysicalDocumentV1, group: ArcFanRows, input: ArcFanInput): ArcFanRebuildPlacement;
@@ -0,0 +1,163 @@
1
+ import { planArcFan } from "./arc-fan.js";
2
+ import { ArcFanRebuildIssue, } from "./arc-fan.interface.js";
3
+ import { NumberingScheme, LabelDirection, RowEnds } from "./physical-document.interface.js";
4
+ import { worldMatrices, inverse, project, normalizeAngle } from "./geometry/geometry.js";
5
+ import { resolveRowLayout, rowPlacementOffset } from "./geometry/seating-layout.js";
6
+ import { seatHasOwnSettings } from "./selling.js";
7
+ const coordinateToleranceM = 1e-7;
8
+ const angleToleranceDeg = 1e-7;
9
+ const degrees = 180 / Math.PI;
10
+ const sources = new WeakMap();
11
+ const generatedRowFields = new Set([
12
+ "zIndex",
13
+ "id",
14
+ "seats",
15
+ "layout",
16
+ "fillOrigin",
17
+ "bookingLabel",
18
+ "seatSequenceOverride",
19
+ "aisleSeats",
20
+ "offsetM",
21
+ "labelOverride",
22
+ ]);
23
+ export const arcFanRebuildMessages = {
24
+ [ArcFanRebuildIssue.Geometry]: "This fan can no longer be rebuilt safely. Edit its rows individually.",
25
+ [ArcFanRebuildIssue.CustomizedShape]: "Keep the existing seat layout when resizing a customized fan. Changes to its shape, spacing or aisles need individual row edits.",
26
+ [ArcFanRebuildIssue.RemoveCustomizedRow]: "This would remove a customized row. Keep that row or clear its custom settings first.",
27
+ };
28
+ export const arcFanGeometryEntryMessage = "This fan has manually edited geometry. Edit its rows individually to keep those changes.";
29
+ export function arcFanParts(plan) {
30
+ return plan.rows.flatMap((row, rowIndex) => {
31
+ let startAt = 1;
32
+ return row.parts.map((part, partIndex) => {
33
+ const sequence = { scheme: NumberingScheme.Numeric, startAt, direction: LabelDirection.Forward };
34
+ startAt += part.seats;
35
+ let aisleSeats = RowEnds.None;
36
+ if (row.parts.length > 1) {
37
+ if (partIndex === 0)
38
+ aisleSeats = RowEnds.End;
39
+ else if (partIndex === row.parts.length - 1)
40
+ aisleSeats = RowEnds.Start;
41
+ else
42
+ aisleSeats = RowEnds.Both;
43
+ }
44
+ return { ...part, rowIndex, partIndex, sequence, aisleSeats };
45
+ });
46
+ });
47
+ }
48
+ function sameAngle(a, b) {
49
+ return Math.abs(normalizeAngle(a - b)) <= angleToleranceDeg;
50
+ }
51
+ function samePoint(a, b) {
52
+ return Math.hypot(a.x - b.x, a.y - b.y) <= coordinateToleranceM;
53
+ }
54
+ function sameLayout(a, b) {
55
+ return (samePoint(a.originM, b.originM) &&
56
+ Math.abs(a.seatPitchM - b.seatPitchM) <= coordinateToleranceM &&
57
+ Math.abs(a.curveDeg - b.curveDeg) <= angleToleranceDeg &&
58
+ sameAngle(a.rotationDeg, b.rotationDeg) &&
59
+ sameAngle(a.seatRotationOffsetDeg ?? 0, b.seatRotationOffsetDeg ?? 0));
60
+ }
61
+ /** Compare current physical rows with generation provenance; seat customizations remain independent. */
62
+ export function arcFanRebuildSource(group) {
63
+ if (sources.has(group))
64
+ return sources.get(group);
65
+ const generation = group.arcFan;
66
+ const plan = generation ? planArcFan({ ...generation.recipe, center: { x: 0, y: 0 } }) : null;
67
+ let source = null;
68
+ if (plan && generation) {
69
+ const parts = arcFanParts(plan);
70
+ if (parts.length === group.rows.length && generation.members.length === parts.length) {
71
+ const current = group.rows.every((row, index) => {
72
+ const part = parts[index];
73
+ if (row.id !== generation.members[index].rowId || row.seats.length !== part.seats)
74
+ return false;
75
+ const layout = resolveRowLayout(group, index);
76
+ if (!layout)
77
+ return false;
78
+ const offset = rowPlacementOffset(group, index, row.offsetM);
79
+ return sameLayout({ ...layout, originM: { x: layout.originM.x + offset.x, y: layout.originM.y + offset.y } }, part.layout);
80
+ });
81
+ if (current)
82
+ source = { parts, members: generation.members, rows: group.rows };
83
+ }
84
+ }
85
+ sources.set(group, source);
86
+ return source;
87
+ }
88
+ export function arcFanSequenceCustomized(row, part) {
89
+ const sequence = row.seatSequenceOverride;
90
+ return (!!sequence &&
91
+ (sequence.scheme !== part.sequence.scheme ||
92
+ sequence.startAt !== part.sequence.startAt ||
93
+ sequence.direction !== part.sequence.direction ||
94
+ !!sequence.prefix ||
95
+ !!sequence.suffix));
96
+ }
97
+ function rowCustomized(source, index) {
98
+ const row = source.rows[index], part = source.parts[index];
99
+ return (row.labelOverride !== source.members[index].labelOverride ||
100
+ row.bookingLabel !== source.members[index].bookingLabel ||
101
+ arcFanSequenceCustomized(row, part) ||
102
+ (row.aisleSeats !== undefined && row.aisleSeats !== part.aisleSeats) ||
103
+ Object.entries(row).some(([key, value]) => !generatedRowFields.has(key) && value !== undefined));
104
+ }
105
+ /** Customized fans keep the measured row layout; equivalent truncated arcs are still shape changes in the reference. */
106
+ function retainsSeatLayout(before, after) {
107
+ return sameLayout(before.layout, after.layout);
108
+ }
109
+ export function reviewArcFanRebuild(group, plan) {
110
+ const source = arcFanRebuildSource(group);
111
+ if (!source)
112
+ return ArcFanRebuildIssue.Geometry;
113
+ const nextParts = arcFanParts(plan);
114
+ const next = new Map(nextParts.map((part) => [part.rowIndex + ":" + part.partIndex, part]));
115
+ for (let index = 0; index < source.rows.length; index++) {
116
+ const row = source.rows[index], part = source.parts[index];
117
+ const after = next.get(part.rowIndex + ":" + part.partIndex);
118
+ const custom = rowCustomized(source, index) || row.seats.some(seatHasOwnSettings);
119
+ if (!after) {
120
+ if (custom)
121
+ return ArcFanRebuildIssue.RemoveCustomizedRow;
122
+ continue;
123
+ }
124
+ if (row.seats.slice(after.seats).some(seatHasOwnSettings))
125
+ return ArcFanRebuildIssue.CustomizedShape;
126
+ if (custom && !retainsSeatLayout(part, after))
127
+ return ArcFanRebuildIssue.CustomizedShape;
128
+ }
129
+ return null;
130
+ }
131
+ /** Show the same authored fan in world coordinates, including inherited rotation and reflection. */
132
+ export function arcFanWorldInput(document, group) {
133
+ const matrix = worldMatrices(document).get(group.id);
134
+ const direction = matrix.a * matrix.d - matrix.b * matrix.c < 0 ? -1 : 1;
135
+ const angle = Math.atan2(matrix.c, matrix.d) * degrees;
136
+ const recipe = group.arcFan.recipe;
137
+ return {
138
+ ...recipe,
139
+ center: { x: matrix.tx, y: matrix.ty },
140
+ startAngleDeg: direction * recipe.startAngleDeg + angle,
141
+ endAngleDeg: direction * recipe.endAngleDeg + angle,
142
+ skewDeg: direction * recipe.skewDeg,
143
+ };
144
+ }
145
+ /** Convert the form's world draft back into the bank's single local geometry owner. */
146
+ export function arcFanRebuildPlacement(document, group, input) {
147
+ const matrices = worldMatrices(document), matrix = matrices.get(group.id);
148
+ const direction = matrix.a * matrix.d - matrix.b * matrix.c < 0 ? -1 : 1;
149
+ const angle = Math.atan2(matrix.c, matrix.d) * degrees;
150
+ return {
151
+ input: {
152
+ ...input,
153
+ center: { x: 0, y: 0 },
154
+ startAngleDeg: direction * (input.startAngleDeg - angle),
155
+ endAngleDeg: direction * (input.endAngleDeg - angle),
156
+ skewDeg: direction * input.skewDeg,
157
+ },
158
+ transform: {
159
+ ...group.transform,
160
+ positionM: group.parentId ? project(inverse(matrices.get(group.parentId)), input.center) : input.center,
161
+ },
162
+ };
163
+ }
@@ -0,0 +1,27 @@
1
+ import { type PointM } from "./physical-document.interface.js";
2
+ import { ArcFanFacing, ArcFanFit, type ArcFanInput, type ArcFanPlan } from "./arc-fan.interface.js";
3
+ export declare const arcFanLimits: {
4
+ readonly rows: 100;
5
+ };
6
+ export declare const arcFanDefaults: {
7
+ readonly rowCount: 8;
8
+ readonly innerRadiusM: number;
9
+ readonly rowPitchM: number;
10
+ readonly seatPitchM: number;
11
+ readonly startAngleDeg: -50;
12
+ readonly endAngleDeg: 50;
13
+ readonly taperDeg: 0;
14
+ readonly skewDeg: 0;
15
+ readonly fit: ArcFanFit.Spacing;
16
+ readonly facing: ArcFanFacing.Inward;
17
+ readonly aisles: {
18
+ readonly left: 0;
19
+ readonly center: number;
20
+ readonly right: 0;
21
+ };
22
+ };
23
+ export declare function arcFanPoint(center: PointM, radiusM: number, angleDeg: number): PointM;
24
+ /** Emit current RowLayout geometry; preview, command creation and both renderers share these rows. */
25
+ export declare function planArcFan(input: ArcFanInput): ArcFanPlan | null;
26
+ /** Sample flattened physical seat order without calculating skipped geometry; stride1 retains every seat. */
27
+ export declare function arcFanSeats(plan: ArcFanPlan, stride?: number): PointM[];
@@ -0,0 +1,83 @@
1
+ import type { PointM, UUID, RowLayout, RowSlot, StraightRows, CurvedRows, LabelSequence, RowEnds, Transform } from "./physical-document.interface.js";
2
+ import type { SectionFillPlan } from "./section-fill.interface.js";
3
+ export declare enum ArcFanFit {
4
+ Spacing = "spacing",
5
+ SameCount = "sameCount"
6
+ }
7
+ export declare enum ArcFanFacing {
8
+ Inward = "inward",
9
+ Outward = "outward"
10
+ }
11
+ export declare enum ArcFanAisle {
12
+ Left = "left",
13
+ Center = "center",
14
+ Right = "right"
15
+ }
16
+ export declare const ArcFanMaximumRows = 100;
17
+ export declare const ArcFanMaximumSpanDeg = 320;
18
+ export declare const ArcFanMaximumPartsPerRow = 4;
19
+ export declare enum ArcFanSectionOrigin {
20
+ Generated = "generated",
21
+ Existing = "existing"
22
+ }
23
+ export declare enum ArcFanRebuildIssue {
24
+ Geometry = "geometry",
25
+ CustomizedShape = "customizedShape",
26
+ RemoveCustomizedRow = "removeCustomizedRow"
27
+ }
28
+ /** Generation membership is provenance, not a second editable row model. Missing members disable rebuilding. */
29
+ export type ArcFanMember = {
30
+ rowId: UUID;
31
+ bookingLabel: string;
32
+ labelOverride?: string;
33
+ };
34
+ export type ArcFanRows = StraightRows | CurvedRows;
35
+ export type ArcFanPart = {
36
+ rowIndex: number;
37
+ partIndex: number;
38
+ seats: number;
39
+ layout: RowLayout;
40
+ sequence: LabelSequence;
41
+ aisleSeats: RowEnds;
42
+ };
43
+ export type ArcFanRebuildSource = {
44
+ parts: ArcFanPart[];
45
+ members: ArcFanMember[];
46
+ rows: RowSlot[];
47
+ };
48
+ export type ArcFanRebuildPlacement = {
49
+ input: ArcFanInput;
50
+ transform: Transform;
51
+ };
52
+ /** Geometry is local to the current row bank; its transform owns the centre and orientation. */
53
+ export type ArcFanRecipe = {
54
+ rowCount: number;
55
+ innerRadiusM: number;
56
+ rowPitchM: number;
57
+ seatPitchM: number;
58
+ startAngleDeg: number;
59
+ endAngleDeg: number;
60
+ taperDeg: number;
61
+ skewDeg: number;
62
+ fit: ArcFanFit;
63
+ facing: ArcFanFacing;
64
+ seatsPerRow?: number;
65
+ aisles: Record<ArcFanAisle, number>;
66
+ };
67
+ export type ArcFanInput = ArcFanRecipe & {
68
+ center: PointM;
69
+ };
70
+ /** One recipe per generated bank; physical rows remain independent, without connected-row joins. */
71
+ export type ArcFanGeneration = {
72
+ recipe: ArcFanRecipe;
73
+ sectionId: UUID | null;
74
+ sectionOrigin: ArcFanSectionOrigin;
75
+ members: ArcFanMember[];
76
+ };
77
+ export type ArcFanPlan = Pick<SectionFillPlan, "rows" | "recipe"> & {
78
+ seats: number;
79
+ segments: number;
80
+ minimumPitchM: number;
81
+ maximumPitchM: number;
82
+ aisles: number;
83
+ };
@@ -0,0 +1,30 @@
1
+ export var ArcFanFit;
2
+ (function (ArcFanFit) {
3
+ ArcFanFit["Spacing"] = "spacing";
4
+ ArcFanFit["SameCount"] = "sameCount";
5
+ })(ArcFanFit || (ArcFanFit = {}));
6
+ export var ArcFanFacing;
7
+ (function (ArcFanFacing) {
8
+ ArcFanFacing["Inward"] = "inward";
9
+ ArcFanFacing["Outward"] = "outward";
10
+ })(ArcFanFacing || (ArcFanFacing = {}));
11
+ export var ArcFanAisle;
12
+ (function (ArcFanAisle) {
13
+ ArcFanAisle["Left"] = "left";
14
+ ArcFanAisle["Center"] = "center";
15
+ ArcFanAisle["Right"] = "right";
16
+ })(ArcFanAisle || (ArcFanAisle = {}));
17
+ export const ArcFanMaximumRows = 100;
18
+ export const ArcFanMaximumSpanDeg = 320;
19
+ export const ArcFanMaximumPartsPerRow = 4;
20
+ export var ArcFanSectionOrigin;
21
+ (function (ArcFanSectionOrigin) {
22
+ ArcFanSectionOrigin["Generated"] = "generated";
23
+ ArcFanSectionOrigin["Existing"] = "existing";
24
+ })(ArcFanSectionOrigin || (ArcFanSectionOrigin = {}));
25
+ export var ArcFanRebuildIssue;
26
+ (function (ArcFanRebuildIssue) {
27
+ ArcFanRebuildIssue["Geometry"] = "geometry";
28
+ ArcFanRebuildIssue["CustomizedShape"] = "customizedShape";
29
+ ArcFanRebuildIssue["RemoveCustomizedRow"] = "removeCustomizedRow";
30
+ })(ArcFanRebuildIssue || (ArcFanRebuildIssue = {}));
@@ -0,0 +1,182 @@
1
+ import { LayoutUnitM, toLayoutUnits } from "./geometry/units.js";
2
+ import { rowSeatGeometry } from "./geometry/seating-layout.js";
3
+ import { DocumentLimits, LabelDirection, SeatingKind } from "./physical-document.interface.js";
4
+ import { ArcFanMaximumRows, ArcFanMaximumSpanDeg, ArcFanAisle, ArcFanFacing, ArcFanFit, } from "./arc-fan.interface.js";
5
+ import { normalizeAngle } from "./geometry/geometry.js";
6
+ const radians = Math.PI / 180;
7
+ const aislePositions = [
8
+ { aisle: ArcFanAisle.Left, fraction: 0.25 },
9
+ { aisle: ArcFanAisle.Center, fraction: 0.5 },
10
+ { aisle: ArcFanAisle.Right, fraction: 0.75 },
11
+ ];
12
+ export const arcFanLimits = { rows: ArcFanMaximumRows };
13
+ export const arcFanDefaults = {
14
+ rowCount: 8,
15
+ innerRadiusM: 240 * LayoutUnitM,
16
+ rowPitchM: 28 * LayoutUnitM,
17
+ seatPitchM: 24 * LayoutUnitM,
18
+ startAngleDeg: -50,
19
+ endAngleDeg: 50,
20
+ taperDeg: 0,
21
+ skewDeg: 0,
22
+ fit: ArcFanFit.Spacing,
23
+ facing: ArcFanFacing.Inward,
24
+ aisles: { left: 0, center: 32 * LayoutUnitM, right: 0 },
25
+ };
26
+ export function arcFanPoint(center, radiusM, angleDeg) {
27
+ return { x: center.x + radiusM * Math.sin(angleDeg * radians), y: center.y + radiusM * Math.cos(angleDeg * radians) };
28
+ }
29
+ const minimumSeatsPerPart = 2;
30
+ const minimumPartPitchRatio = 0.75;
31
+ /** Reserve each segment’s minimum, then distribute the largest fractional remainders in segment order. */
32
+ function distributeSeats(total, spans) {
33
+ const remaining = total - spans.length * minimumSeatsPerPart;
34
+ if (remaining < 0)
35
+ return null;
36
+ const length = spans.reduce((sum, span) => sum + span, 0);
37
+ const quotas = spans.map((span) => (remaining * span) / length);
38
+ const counts = quotas.map((quota) => minimumSeatsPerPart + Math.floor(quota));
39
+ const order = quotas
40
+ .map((quota, index) => ({ index, remainder: quota - Math.floor(quota) }))
41
+ .sort((a, b) => b.remainder - a.remainder || a.index - b.index);
42
+ let left = total - counts.reduce((sum, count) => sum + count, 0);
43
+ for (const { index } of order) {
44
+ if (!left)
45
+ break;
46
+ counts[index]++;
47
+ left--;
48
+ }
49
+ return counts;
50
+ }
51
+ /** Emit current RowLayout geometry; preview, command creation and both renderers share these rows. */
52
+ export function planArcFan(input) {
53
+ const { rowCount, innerRadiusM, rowPitchM, seatPitchM, startAngleDeg, endAngleDeg, taperDeg, skewDeg } = input;
54
+ if (!Number.isInteger(rowCount) ||
55
+ rowCount < 1 ||
56
+ rowCount > arcFanLimits.rows ||
57
+ innerRadiusM <= 0 ||
58
+ rowPitchM <= 0 ||
59
+ seatPitchM <= 0)
60
+ return null;
61
+ if (![
62
+ innerRadiusM,
63
+ rowPitchM,
64
+ seatPitchM,
65
+ startAngleDeg,
66
+ endAngleDeg,
67
+ taperDeg,
68
+ skewDeg,
69
+ input.center.x,
70
+ input.center.y,
71
+ ...Object.values(input.aisles),
72
+ ].every(Number.isFinite))
73
+ return null;
74
+ if (input.fit === ArcFanFit.SameCount && (!Number.isInteger(input.seatsPerRow) || input.seatsPerRow < 1))
75
+ return null;
76
+ const direction = Math.sign(endAngleDeg - startAngleDeg);
77
+ const outward = input.facing === ArcFanFacing.Outward;
78
+ const partDirection = outward ? -direction : direction;
79
+ if (!direction || Math.abs(endAngleDeg - startAngleDeg) > ArcFanMaximumSpanDeg)
80
+ return null;
81
+ const plan = {
82
+ rows: [],
83
+ recipe: { seatPitchM, rowPitchM },
84
+ seats: 0,
85
+ segments: 0,
86
+ minimumPitchM: Infinity,
87
+ maximumPitchM: 0,
88
+ aisles: aislePositions.filter(({ aisle }) => input.aisles[aisle] > 0).length,
89
+ };
90
+ const innerRadiusUnits = toLayoutUnits(innerRadiusM);
91
+ const rowPitchUnits = toLayoutUnits(rowPitchM);
92
+ const seatPitchUnits = toLayoutUnits(seatPitchM);
93
+ for (let index = 0; index < rowCount; index++) {
94
+ const fraction = rowCount === 1 ? 0 : index / (rowCount - 1);
95
+ const start = startAngleDeg + (direction * taperDeg + skewDeg) * fraction;
96
+ const end = endAngleDeg + (-direction * taperDeg + skewDeg) * fraction;
97
+ if (!Number.isFinite(end - start) || (end - start) * direction <= 0)
98
+ return null;
99
+ const radiusM = innerRadiusM + index * rowPitchM;
100
+ const radiusUnits = innerRadiusUnits + index * rowPitchUnits;
101
+ const sweepDeg = end - start;
102
+ const sweepRadians = Math.abs(sweepDeg) * radians;
103
+ const arcLengthUnits = radiusUnits * sweepRadians;
104
+ const aisleSpans = [];
105
+ for (const { aisle, fraction: position } of aislePositions) {
106
+ const widthM = input.aisles[aisle];
107
+ if (widthM < 0)
108
+ return null;
109
+ if (!widthM)
110
+ continue;
111
+ const half = toLayoutUnits(widthM) / radiusUnits / sweepRadians / 2;
112
+ aisleSpans.push({ start: position - half, end: position + half });
113
+ }
114
+ aisleSpans.sort((a, b) => a.start - b.start);
115
+ const intervals = [];
116
+ let previous = 0;
117
+ for (const span of aisleSpans) {
118
+ if (input.fit === ArcFanFit.SameCount && (span.start <= previous || span.end >= 1))
119
+ return null;
120
+ if (span.start > previous)
121
+ intervals.push({ start: previous, end: span.start });
122
+ previous = Math.max(previous, span.end);
123
+ }
124
+ if (previous < 1)
125
+ intervals.push({ start: previous, end: 1 });
126
+ if (!intervals.length)
127
+ return null;
128
+ const nominalPitchUnits = input.fit === ArcFanFit.SameCount ? arcLengthUnits / input.seatsPerRow : seatPitchUnits;
129
+ const minimumPartLength = nominalPitchUnits * minimumPartPitchRatio;
130
+ const usable = intervals.filter((part) => (part.end - part.start) * arcLengthUnits >= minimumPartLength);
131
+ if (!usable.length || (input.fit === ArcFanFit.SameCount && usable.length !== intervals.length))
132
+ return null;
133
+ const lengthsUnits = usable.map((part) => (part.end - part.start) * arcLengthUnits);
134
+ const counts = input.fit === ArcFanFit.SameCount
135
+ ? distributeSeats(input.seatsPerRow, lengthsUnits)
136
+ : lengthsUnits.map((length) => Math.round(length / seatPitchUnits) + 1);
137
+ if (!counts || counts.some((count) => count < minimumSeatsPerPart))
138
+ return null;
139
+ const parts = usable.map((part, partIndex) => {
140
+ const seats = counts[partIndex];
141
+ const partStart = start + sweepDeg * (outward ? part.end : part.start);
142
+ const curveDeg = (part.end - part.start) * sweepDeg * (outward ? -1 : 1);
143
+ const pitch = 2 * radiusM * Math.sin((Math.abs(curveDeg) * radians) / (2 * (seats - 1)));
144
+ plan.minimumPitchM = Math.min(plan.minimumPitchM, pitch);
145
+ plan.maximumPitchM = Math.max(plan.maximumPitchM, pitch);
146
+ plan.seats += seats;
147
+ plan.segments++;
148
+ return {
149
+ seats,
150
+ layout: {
151
+ originM: arcFanPoint(input.center, radiusM, partStart),
152
+ seatPitchM: pitch,
153
+ curveDeg,
154
+ rotationDeg: normalizeAngle(-partStart + (partDirection < 0 ? 180 : 0)),
155
+ seatRotationOffsetDeg: (partDirection < 0 ? -180 : 0) + (outward ? 180 : 0),
156
+ },
157
+ };
158
+ });
159
+ if (plan.seats > DocumentLimits.PhysicalSeats)
160
+ return null;
161
+ plan.rows.push({ parts: outward ? parts.reverse() : parts, numbering: LabelDirection.Forward });
162
+ }
163
+ return plan;
164
+ }
165
+ /** Sample flattened physical seat order without calculating skipped geometry; stride1 retains every seat. */
166
+ export function arcFanSeats(plan, stride = 1) {
167
+ if (!Number.isInteger(stride) || stride < 1)
168
+ throw new RangeError("Seat stride must be a positive integer.");
169
+ const geometry = { kind: SeatingKind.Straight, recipe: plan.recipe };
170
+ const points = [];
171
+ let offset = 0;
172
+ for (const row of plan.rows) {
173
+ for (const part of row.parts) {
174
+ const first = (stride - (offset % stride)) % stride;
175
+ for (let seat = first; seat < part.seats; seat += stride) {
176
+ points.push(rowSeatGeometry(geometry, 0, seat, part.seats, part.seats, part.layout).position);
177
+ }
178
+ offset += part.seats;
179
+ }
180
+ }
181
+ return points;
182
+ }
package/dist/catalog.d.ts CHANGED
@@ -1,15 +1,17 @@
1
- import type { PhysicalDocumentV1, SeatingGroup, InventoryArea, UUID } from "./types.js";
1
+ import type { PhysicalDocumentV1, SeatingGroup, InventoryArea, UUID } from "./physical-document.interface.js";
2
2
  import { type SegmentedRowEntry } from "./row-segments.js";
3
3
  import { type GeneratedSeat } from "./geometry/geometry.js";
4
- export declare function generatedSeats(group: SeatingGroup): readonly GeneratedSeat[];
4
+ export type DocumentSeat = GeneratedSeat & {
5
+ sectionId: UUID | null;
6
+ };
5
7
  /** Geometry remains shared; logical addresses are projected from the current document. */
6
- export declare function documentGroupSeats(document: PhysicalDocumentV1, group: SeatingGroup): readonly GeneratedSeat[];
8
+ export declare function documentGroupSeats(document: PhysicalDocumentV1, group: SeatingGroup): readonly DocumentSeat[];
7
9
  export type DocumentCatalog = {
8
10
  groups: ReadonlyMap<UUID, SeatingGroup>;
9
11
  areas: ReadonlyMap<UUID, InventoryArea>;
10
12
  seats: ReadonlyMap<UUID, {
11
13
  group: SeatingGroup;
12
- seat: GeneratedSeat;
14
+ seat: DocumentSeat;
13
15
  }>;
14
16
  rows: ReadonlyMap<UUID, SeatingGroup>;
15
17
  segmentedRows: ReadonlyMap<UUID, SegmentedRowEntry>;
package/dist/catalog.js CHANGED
@@ -1,15 +1,7 @@
1
+ import { sectionCatalog } from "./sections.js";
1
2
  import { rowSegments } from "./row-segments.js";
2
- import { sequenceLabel } from "./labels.js";
3
- import { generateGroup } from "./geometry/geometry.js";
4
- const generated = new WeakMap();
5
- export function generatedSeats(group) {
6
- let cached = generated.get(group);
7
- if (!cached) {
8
- cached = Object.freeze([...generateGroup(group)]);
9
- generated.set(group, cached);
10
- }
11
- return cached;
12
- }
3
+ import { sequenceLabel, rowDisplayLabel } from "./labels.js";
4
+ import { generatedSeats } from "./geometry/geometry.js";
13
5
  const documentSeats = new WeakMap();
14
6
  /** Geometry remains shared; logical addresses are projected from the current document. */
15
7
  export function documentGroupSeats(document, group) {
@@ -22,19 +14,39 @@ export function documentGroupSeats(document, group) {
22
14
  if (cached)
23
15
  return cached;
24
16
  const segments = rowSegments(document);
25
- const ordinals = new Map();
26
- const result = generatedSeats(group).map((seat) => {
17
+ const owners = sectionCatalog(document).owners;
18
+ const parts = new Map();
19
+ const result = generatedSeats(group).map((geometry) => {
20
+ const seat = { ...geometry, sectionId: owners.get(geometry.rowId ?? group.id) ?? null };
27
21
  const segment = seat.rowId ? segments.get(seat.rowId) : undefined;
28
22
  if (!segment)
29
23
  return seat;
30
- const ordinal = ordinals.get(segment.part.id) ?? 0;
31
- ordinals.set(segment.part.id, ordinal + 1);
24
+ let part = parts.get(segment.part.id);
25
+ if (!part) {
26
+ part = {
27
+ ordinal: 0,
28
+ addressRowLabel: !segment.coherent || segment.row.qualifySeatLabels
29
+ ? rowDisplayLabel(segment.group, segment.group.rows.indexOf(segment.part))
30
+ : undefined,
31
+ };
32
+ parts.set(segment.part.id, part);
33
+ }
34
+ if (!segment.coherent)
35
+ return {
36
+ ...seat,
37
+ ownerLabel: segment.displayLabel,
38
+ addressRowLabel: part.addressRowLabel,
39
+ logicalPartIndex: segment.partIndex,
40
+ };
41
+ const ordinal = part.ordinal++;
32
42
  return {
33
43
  ...seat,
34
44
  label: seat.slot.labelOverride ??
35
45
  sequenceLabel(segment.row.sequence, segment.firstIndex + ordinal, segment.totalSeats),
46
+ bookingLabel: sequenceLabel(segment.row.sequence, segment.firstIndex + ordinal, segment.totalSeats),
47
+ addressRowLabel: part.addressRowLabel,
36
48
  logicalRowId: segment.row.id,
37
- logicalRowLabel: segment.row.label,
49
+ logicalRowLabel: segment.displayLabel,
38
50
  logicalPartIndex: segment.partIndex,
39
51
  logicalSequence: segment.row.sequence,
40
52
  };
@@ -64,6 +76,8 @@ export function documentCatalog(document) {
64
76
  row.id,
65
77
  {
66
78
  row,
79
+ displayLabel: rowSegments(document).get(row.parts[0].rowId).displayLabel,
80
+ coherent: rowSegments(document).get(row.parts[0].rowId).coherent,
67
81
  parts: row.parts.map((part) => rowSegments(document).get(part.rowId)),
68
82
  },
69
83
  ])),
@@ -73,5 +87,5 @@ export function documentCatalog(document) {
73
87
  return catalog;
74
88
  }
75
89
  export function inventoryAddress(document, seat) {
76
- return `${documentCatalog(document).sections.get(seat.sectionId ?? "") ?? "Unsectioned"}, ${seat.rowId ? "row" : "table"} ${seat.logicalRowLabel ?? seat.ownerLabel}, seat ${seat.label}`;
90
+ return `${documentCatalog(document).sections.get(sectionCatalog(document).owners.get(seat.rowId ?? seat.groupId) ?? "") ?? "Unsectioned"}, ${seat.rowId ? "row" : "table"} ${seat.addressRowLabel ?? seat.logicalRowLabel ?? seat.ownerLabel}, seat ${seat.bookingLabel}`;
77
91
  }
@@ -1,5 +1,5 @@
1
- import type { MapCategory, PhysicalDocumentV1, RowSlot, SeatingGroup, SeatSlot, UUID } from "./types.js";
2
- import { SeatShape } from "./types.js";
1
+ import type { MapCategory, PhysicalDocumentV1, RowSlot, SeatingGroup, SeatSlot, UUID } from "./physical-document.interface.js";
2
+ import { SeatShape } from "./physical-document.interface.js";
3
3
  import { type DomainIssue } from "./issues.js";
4
4
  export declare function categoryCatalog(document: PhysicalDocumentV1): ReadonlyMap<UUID, MapCategory>;
5
5
  /** Absence inherits; explicit null records an unassigned child. */
@@ -8,7 +8,9 @@ export declare function categoryReferences(groups: readonly SeatingGroup[]): Gen
8
8
  id: UUID;
9
9
  categoryId: UUID;
10
10
  }>;
11
- export declare function categoryIssues(document: PhysicalDocumentV1): DomainIssue[];
11
+ export declare function missingCategoryLabel(places: number): string;
12
+ /** Unresolved catalogue references are repairable draft findings, not invalid physical structure. */
13
+ export declare function categoryIssues(document: PhysicalDocumentV1): readonly DomainIssue[];
12
14
  /** Fragment paste reuses catalogue identity; whole-map copy remaps it with the map. */
13
15
  export declare function remapGroupCategories(group: SeatingGroup, ids: ReadonlyMap<UUID, UUID>): SeatingGroup;
14
16
  export declare function categoryUsage(document: PhysicalDocumentV1): ReadonlyMap<UUID, number>;