@things-factory/figure-ui 10.1.104 → 10.1.106

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 (50) hide show
  1. package/client/modeller/canvas.ts +6 -13
  2. package/client/modeller/editor.ts +15 -4
  3. package/client/modeller/fields.ts +7 -1
  4. package/client/modeller/figure-cavity-drawing.ts +80 -18
  5. package/client/modeller/figure-links.ts +49 -35
  6. package/client/modeller/figure-material-panel.ts +0 -1
  7. package/client/modeller/figure-parts.ts +3 -3
  8. package/client/modeller/figure-section-editor.ts +106 -11
  9. package/client/modeller/figure-section-panel.ts +15 -103
  10. package/client/modeller/section-drawing.ts +27 -4
  11. package/dist-client/modeller/canvas.d.ts +0 -2
  12. package/dist-client/modeller/canvas.js +6 -17
  13. package/dist-client/modeller/canvas.js.map +1 -1
  14. package/dist-client/modeller/editor.js +17 -4
  15. package/dist-client/modeller/editor.js.map +1 -1
  16. package/dist-client/modeller/fields.js +7 -1
  17. package/dist-client/modeller/fields.js.map +1 -1
  18. package/dist-client/modeller/figure-cavity-drawing.d.ts +6 -0
  19. package/dist-client/modeller/figure-cavity-drawing.js +81 -16
  20. package/dist-client/modeller/figure-cavity-drawing.js.map +1 -1
  21. package/dist-client/modeller/figure-links.d.ts +2 -2
  22. package/dist-client/modeller/figure-links.js +49 -34
  23. package/dist-client/modeller/figure-links.js.map +1 -1
  24. package/dist-client/modeller/figure-material-panel.js +0 -1
  25. package/dist-client/modeller/figure-material-panel.js.map +1 -1
  26. package/dist-client/modeller/figure-parts.d.ts +2 -1
  27. package/dist-client/modeller/figure-parts.js +2 -2
  28. package/dist-client/modeller/figure-parts.js.map +1 -1
  29. package/dist-client/modeller/figure-section-editor.d.ts +13 -0
  30. package/dist-client/modeller/figure-section-editor.js +109 -9
  31. package/dist-client/modeller/figure-section-editor.js.map +1 -1
  32. package/dist-client/modeller/figure-section-panel.d.ts +0 -1
  33. package/dist-client/modeller/figure-section-panel.js +14 -73
  34. package/dist-client/modeller/figure-section-panel.js.map +1 -1
  35. package/dist-client/modeller/section-drawing.d.ts +12 -1
  36. package/dist-client/modeller/section-drawing.js +23 -3
  37. package/dist-client/modeller/section-drawing.js.map +1 -1
  38. package/dist-client/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +6 -6
  40. package/test/cavity-drawing.test.ts +10 -1
  41. package/test/command-preview.test.ts +11 -4
  42. package/test/first-minute.test.ts +6 -2
  43. package/test/layout.test.ts +11 -0
  44. package/test/section-editor.test.ts +32 -3
  45. package/test/section-panel.test.ts +5 -3
  46. package/translations/en.json +2 -10
  47. package/translations/ja.json +2 -10
  48. package/translations/ko.json +2 -10
  49. package/translations/ms.json +2 -10
  50. package/translations/zh.json +2 -10
@@ -105,7 +105,27 @@ export function workingOf(shape) {
105
105
  : s.kind === 'ellipse'
106
106
  ? { [u]: 2 * s.radius[u], [v]: 2 * s.radius[v] }
107
107
  : {};
108
- return { points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [], across, length: e.end - e.start, apex: e.apex ? { ...e.apex } : null };
108
+ const c = shape.extrusion && shape.cavity;
109
+ return {
110
+ points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [],
111
+ across,
112
+ length: e.end - e.start,
113
+ apex: e.apex ? { ...e.apex } : null,
114
+ cavity: c ? { wall: { ...c.wall }, start: c.start, end: c.end } : null
115
+ };
116
+ }
117
+ /**
118
+ * The part as the working state would make it: its section, its length from the same start, its inside -- what the
119
+ * inside's drawing reads, so its walls are judged against the widths being typed and not the ones the editor opened with.
120
+ */
121
+ export function workingShapeOf(shape, w) {
122
+ const e = shape.extrusion;
123
+ const { cavity: _, ...rest } = shape;
124
+ return {
125
+ ...rest,
126
+ extrusion: { ...e, section: sectionOf(shape, w), end: e.start + w.length },
127
+ ...(w.cavity ? { cavity: { id: shape.cavity?.id ?? 'inside', wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } } : {})
128
+ };
109
129
  }
110
130
  /** The section the working state makes, of the part's own kind: its corners kept, its points or widths the working ones. */
111
131
  export function sectionOf(shape, w) {
@@ -128,8 +148,8 @@ export function workingIssuesOf(shape, w) {
128
148
  words.push({ key: 'figure.text.section-issue-length', params: {} });
129
149
  if (w.apex && !Object.values(w.apex).every(n => Number.isFinite(n)))
130
150
  words.push({ key: 'figure.text.section-issue-number', params: {} });
131
- if (!issues.length && words.length === 0 && shape.cavity) {
132
- const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [shape.cavity]);
151
+ if (!issues.length && words.length === 0 && w.cavity) {
152
+ const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [{ id: 'inside', ...w.cavity }]);
133
153
  if ('refused' in made) {
134
154
  const r = made.refused;
135
155
  words.push({ key: r.code === 'CAVITY_NO_LENGTH' ? 'figure.text.section-issue-cavity-length' : 'figure.text.section-issue-cavity-walls', params: {} });
@@ -1 +1 @@
1
- {"version":3,"file":"section-drawing.js","sourceRoot":"","sources":["../../client/modeller/section-drawing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAa9J,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAExE,kHAAkH;AAClH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA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CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QAC1H,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAA;YACtB,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,wCAAwC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;QACvJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import { FIGURE_SECTION_PLANE, FIGURE_SECTION_POINT_LIMIT, checkFigureSection, figureExtrusionFeaturesOf, figureSectionSidesOf } from '@hatiolab/figure-model'\nimport type { FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionPoint } from '@hatiolab/figure-model'\n\n/*\n * What the section editor does to a drawn section's points, and how it says what is wrong with them (ADR-0100 §3.2).\n * The points are the kernel's own (`{ id, x, z }` for a push along Y), their validity is the kernel's own check, and a\n * point's number on screen is its own name's number (Q9): p3 is 「3」 before and after any edit, and deleting it leaves\n * 1, 2 and 4.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type Points = readonly FigureSectionPoint[]\n\n/** The number a point is shown by: its name's number. */\nexport const pointLabel = (id: string) => /^p(\\d+)$/.exec(id)?.[1] ?? id\n\n/** The next point's name: one past the highest number the loop has, so a new point never takes a gap's number. */\nexport function nextPointId(points: Points): string {\n return `p${Math.max(0, ...points.map(p => Number(/^p(\\d+)$/.exec(p.id)?.[1] ?? 0))) + 1}`\n}\n\n/** A point in the middle of the side from `from` to the point after it, whole millimetres; the new point's id with it. */\nexport function insertAfter(points: Points, from: string, axis: Axis): { points: FigureSectionPoint[]; id: string } {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const i = points.findIndex(p => p.id === from)\n const a = points[i]!,\n b = points[(i + 1) % points.length]!\n const id = nextPointId(points)\n const mid = { id, [u]: Math.round((a[u]! + b[u]!) / 2), [v]: Math.round((a[v]! + b[v]!) / 2) } as FigureSectionPoint\n return { points: [...points.slice(0, i + 1), mid, ...points.slice(i + 1)], id }\n}\n\n/** The points less one, or why not: a section is three points or more. */\nexport function removePoint(points: Points, id: string): FigureSectionPoint[] | { refused: 'too-few' } {\n if (points.length <= 3) return { refused: 'too-few' }\n return points.filter(p => p.id !== id)\n}\n\nexport function movePoint(points: Points, id: string, at: Partial<Record<Axis, number>>): FigureSectionPoint[] {\n return points.map(p => (p.id === id ? { ...p, ...at } : p))\n}\n\n/** What is wrong with the points, by the kernel's own check. */\nexport const issuesOf = (points: Points, axis: Axis) => checkFigureSection({ kind: 'polygon', points: [...points] }, axis)\n\n/** A side said in the loop's order, 3–4 not 4–3: its id is the pair in name order, which a person never sees. */\nfunction sideLabel(points: Points, axis: Axis, side: string): string {\n const s = figureSectionSidesOf({ kind: 'polygon', points: [...points] }, axis).find(x => x.id === side)\n const [a, b] = s?.from ? [s.from, s.to!] : side.split('~')\n return `${pointLabel(a!)}–${pointLabel(b!)}`\n}\n\n/** An issue as the words that say it: an i18n key and its values. */\nexport function issueWords(issue: FigureSectionIssue, points: Points, axis: Axis): { key: string; params: Record<string, string> } {\n const line = (s: string) => sideLabel(points, axis, s)\n switch (issue.code) {\n case 'SIDES_CROSS':\n return { key: 'figure.text.section-issue-cross', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_TOUCH':\n return { key: 'figure.text.section-issue-touch', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_FOLD':\n return { key: 'figure.text.section-issue-fold', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'ZERO_LENGTH_SIDE':\n return { key: 'figure.text.section-issue-zero-length', params: { a: line(issue.side) } }\n case 'ZERO_AREA':\n return { key: 'figure.text.section-issue-zero-area', params: {} }\n case 'TOO_FEW_POINTS':\n return { key: 'figure.text.section-issue-too-few', params: {} }\n case 'TOO_MANY_POINTS':\n return { key: 'figure.text.section-issue-too-many', params: { limit: String(issue.limit) } }\n case 'CORNER_TOO_LARGE':\n return { key: 'figure.text.section-issue-corner', params: { max: String(Math.round(issue.max * 1000) / 1000) } }\n default:\n return { key: 'figure.text.section-issue-number', params: {} }\n }\n}\n\n/** Every side and point an issue names, to mark on the drawing -- by more than colour: the list says them too. */\nexport function markedBy(issues: readonly FigureSectionIssue[]): { sides: Set<string>; points: Set<string> } {\n const sides = new Set<string>(),\n points = new Set<string>()\n for (const i of issues) {\n if ('sides' in i) for (const s of i.sides) sides.add(s)\n if ('side' in i) sides.add(i.side)\n if ('point' in i) points.add(i.point)\n if ('at' in i) points.add(String(i.at).split('.')[0]!)\n }\n for (const s of sides) for (const p of s.split('~')) points.add(p)\n return { sides, points }\n}\n\n/** How far the drawing reaches from the origin: the points' farthest coordinate with room around, in 50 mm steps. */\nexport function extentOf(points: Points, axis: Axis): number {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const far = Math.max(1, ...points.flatMap(p => [Math.abs(p[u] ?? 0), Math.abs(p[v] ?? 0)]))\n return Math.ceil((far * 1.4 + 40) / 50) * 50\n}\n\nexport const POINT_LIMIT = FIGURE_SECTION_POINT_LIMIT\n\n/** What the section editor holds while it is open: the points of a drawn section, the widths across, the length. */\nexport interface SectionWorking {\n points: FigureSectionPoint[]\n /** Along each plane axis: a rectangle's size, an ellipse's diameter. Empty for a drawn section. */\n across: Partial<Record<Axis, number>>\n length: number\n /** A drawn section's end drawn to one point (a pyramid), across the plane axes; null for a push. */\n apex: Partial<Record<Axis, number>> | null\n}\n\n/** A pushed part's section, axis and ends -- or a pyramid's, whose end is its apex (figure-model `loft@1`). */\nexport function drawnOf(shape: FigureEvaluatedShape):\n | { axis: Axis; section: FigureSection; start: number; end: number; apex: Partial<Record<Axis, number>> | null }\n | undefined {\n if (shape.extrusion) return { ...shape.extrusion, apex: null }\n if (shape.loft) return { ...shape.loft, apex: shape.loft.apex }\n return undefined\n}\n\n/** Where a new apex goes: over the middle of the points' span, whole millimetres. */\nexport function apexOver(points: Points, axis: Axis): Partial<Record<Axis, number>> {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const mid = (x: Axis) => Math.round((Math.min(...points.map(p => p[x]!)) + Math.max(...points.map(p => p[x]!))) / 2)\n return { [u]: mid(u), [v]: mid(v) }\n}\n\n/** The working state of a pushed part as it stands. */\nexport function workingOf(shape: FigureEvaluatedShape): SectionWorking {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const across =\n s.kind === 'rectangle'\n ? { [u]: s.size[u]!, [v]: s.size[v]! }\n : s.kind === 'ellipse'\n ? { [u]: 2 * s.radius[u]!, [v]: 2 * s.radius[v]! }\n : {}\n return { points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [], across, length: e.end - e.start, apex: e.apex ? { ...e.apex } : null }\n}\n\n/** The section the working state makes, of the part's own kind: its corners kept, its points or widths the working ones. */\nexport function sectionOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureSection {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n if (s.kind === 'polygon') return { kind: 'polygon', points: w.points }\n if (s.kind === 'ellipse') return { kind: 'ellipse', radius: { [u]: w.across[u]! / 2, [v]: w.across[v]! / 2 } }\n return { kind: 'rectangle', size: { [u]: w.across[u]!, [v]: w.across[v]! }, ...(s.corner ? { corner: s.corner } : {}) }\n}\n\n/** What would be refused, as words, with the section's own issues for marking points and sides. By the kernel's checks. */\nexport function workingIssuesOf(\n shape: FigureEvaluatedShape,\n w: SectionWorking\n): { issues: FigureSectionIssue[]; words: Array<{ key: string; params: Record<string, string> }> } {\n const e = drawnOf(shape)!\n const section = sectionOf(shape, w)\n const issues = checkFigureSection(section, e.axis)\n const words = issues.map(i => issueWords(i, w.points, e.axis))\n if (!(Number.isFinite(w.length) && w.length > 0)) words.push({ key: 'figure.text.section-issue-length', params: {} })\n if (w.apex && !Object.values(w.apex).every(n => Number.isFinite(n))) words.push({ key: 'figure.text.section-issue-number', params: {} })\n if (!issues.length && words.length === 0 && shape.cavity) {\n const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [shape.cavity])\n if ('refused' in made) {\n const r = made.refused\n words.push({ key: r.code === 'CAVITY_NO_LENGTH' ? 'figure.text.section-issue-cavity-length' : 'figure.text.section-issue-cavity-walls', params: {} })\n }\n }\n return { issues, words }\n}\n"]}
1
+ {"version":3,"file":"section-drawing.js","sourceRoot":"","sources":["../../client/modeller/section-drawing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAa9J,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAExE,kHAAkH;AAClH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;AAC3F,CAAC;AAED,0HAA0H;AAC1H,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY,EAAE,IAAU;IAClE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAA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AAC1B,CAAC","sourcesContent":["import { FIGURE_SECTION_PLANE, FIGURE_SECTION_POINT_LIMIT, checkFigureSection, figureExtrusionFeaturesOf, figureSectionSidesOf } from '@hatiolab/figure-model'\nimport type { FigureCavityRequest, FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionPoint } from '@hatiolab/figure-model'\n\n/*\n * What the section editor does to a drawn section's points, and how it says what is wrong with them (ADR-0100 §3.2).\n * The points are the kernel's own (`{ id, x, z }` for a push along Y), their validity is the kernel's own check, and a\n * point's number on screen is its own name's number (Q9): p3 is 「3」 before and after any edit, and deleting it leaves\n * 1, 2 and 4.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type Points = readonly FigureSectionPoint[]\n\n/** The number a point is shown by: its name's number. */\nexport const pointLabel = (id: string) => /^p(\\d+)$/.exec(id)?.[1] ?? id\n\n/** The next point's name: one past the highest number the loop has, so a new point never takes a gap's number. */\nexport function nextPointId(points: Points): string {\n return `p${Math.max(0, ...points.map(p => Number(/^p(\\d+)$/.exec(p.id)?.[1] ?? 0))) + 1}`\n}\n\n/** A point in the middle of the side from `from` to the point after it, whole millimetres; the new point's id with it. */\nexport function insertAfter(points: Points, from: string, axis: Axis): { points: FigureSectionPoint[]; id: string } {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const i = points.findIndex(p => p.id === from)\n const a = points[i]!,\n b = points[(i + 1) % points.length]!\n const id = nextPointId(points)\n const mid = { id, [u]: Math.round((a[u]! + b[u]!) / 2), [v]: Math.round((a[v]! + b[v]!) / 2) } as FigureSectionPoint\n return { points: [...points.slice(0, i + 1), mid, ...points.slice(i + 1)], id }\n}\n\n/** The points less one, or why not: a section is three points or more. */\nexport function removePoint(points: Points, id: string): FigureSectionPoint[] | { refused: 'too-few' } {\n if (points.length <= 3) return { refused: 'too-few' }\n return points.filter(p => p.id !== id)\n}\n\nexport function movePoint(points: Points, id: string, at: Partial<Record<Axis, number>>): FigureSectionPoint[] {\n return points.map(p => (p.id === id ? { ...p, ...at } : p))\n}\n\n/** What is wrong with the points, by the kernel's own check. */\nexport const issuesOf = (points: Points, axis: Axis) => checkFigureSection({ kind: 'polygon', points: [...points] }, axis)\n\n/** A side said in the loop's order, 3–4 not 4–3: its id is the pair in name order, which a person never sees. */\nfunction sideLabel(points: Points, axis: Axis, side: string): string {\n const s = figureSectionSidesOf({ kind: 'polygon', points: [...points] }, axis).find(x => x.id === side)\n const [a, b] = s?.from ? [s.from, s.to!] : side.split('~')\n return `${pointLabel(a!)}–${pointLabel(b!)}`\n}\n\n/** An issue as the words that say it: an i18n key and its values. */\nexport function issueWords(issue: FigureSectionIssue, points: Points, axis: Axis): { key: string; params: Record<string, string> } {\n const line = (s: string) => sideLabel(points, axis, s)\n switch (issue.code) {\n case 'SIDES_CROSS':\n return { key: 'figure.text.section-issue-cross', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_TOUCH':\n return { key: 'figure.text.section-issue-touch', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_FOLD':\n return { key: 'figure.text.section-issue-fold', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'ZERO_LENGTH_SIDE':\n return { key: 'figure.text.section-issue-zero-length', params: { a: line(issue.side) } }\n case 'ZERO_AREA':\n return { key: 'figure.text.section-issue-zero-area', params: {} }\n case 'TOO_FEW_POINTS':\n return { key: 'figure.text.section-issue-too-few', params: {} }\n case 'TOO_MANY_POINTS':\n return { key: 'figure.text.section-issue-too-many', params: { limit: String(issue.limit) } }\n case 'CORNER_TOO_LARGE':\n return { key: 'figure.text.section-issue-corner', params: { max: String(Math.round(issue.max * 1000) / 1000) } }\n default:\n return { key: 'figure.text.section-issue-number', params: {} }\n }\n}\n\n/** Every side and point an issue names, to mark on the drawing -- by more than colour: the list says them too. */\nexport function markedBy(issues: readonly FigureSectionIssue[]): { sides: Set<string>; points: Set<string> } {\n const sides = new Set<string>(),\n points = new Set<string>()\n for (const i of issues) {\n if ('sides' in i) for (const s of i.sides) sides.add(s)\n if ('side' in i) sides.add(i.side)\n if ('point' in i) points.add(i.point)\n if ('at' in i) points.add(String(i.at).split('.')[0]!)\n }\n for (const s of sides) for (const p of s.split('~')) points.add(p)\n return { sides, points }\n}\n\n/** How far the drawing reaches from the origin: the points' farthest coordinate with room around, in 50 mm steps. */\nexport function extentOf(points: Points, axis: Axis): number {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const far = Math.max(1, ...points.flatMap(p => [Math.abs(p[u] ?? 0), Math.abs(p[v] ?? 0)]))\n return Math.ceil((far * 1.4 + 40) / 50) * 50\n}\n\nexport const POINT_LIMIT = FIGURE_SECTION_POINT_LIMIT\n\n/** What the section editor holds while it is open: the points of a drawn section, the widths across, the length. */\nexport interface SectionWorking {\n points: FigureSectionPoint[]\n /** Along each plane axis: a rectangle's size, an ellipse's diameter. Empty for a drawn section. */\n across: Partial<Record<Axis, number>>\n length: number\n /** A drawn section's end drawn to one point (a pyramid), across the plane axes; null for a push. */\n apex: Partial<Record<Axis, number>> | null\n /** A pushed rectangle's or ellipse's inside, every side's wall written out; null for none or a drawn section. */\n cavity: { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] } | null\n}\n\n/** A pushed part's section, axis and ends -- or a pyramid's, whose end is its apex (figure-model `loft@1`). */\nexport function drawnOf(shape: FigureEvaluatedShape):\n | { axis: Axis; section: FigureSection; start: number; end: number; apex: Partial<Record<Axis, number>> | null }\n | undefined {\n if (shape.extrusion) return { ...shape.extrusion, apex: null }\n if (shape.loft) return { ...shape.loft, apex: shape.loft.apex }\n return undefined\n}\n\n/** Where a new apex goes: over the middle of the points' span, whole millimetres. */\nexport function apexOver(points: Points, axis: Axis): Partial<Record<Axis, number>> {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const mid = (x: Axis) => Math.round((Math.min(...points.map(p => p[x]!)) + Math.max(...points.map(p => p[x]!))) / 2)\n return { [u]: mid(u), [v]: mid(v) }\n}\n\n/** The working state of a pushed part as it stands. */\nexport function workingOf(shape: FigureEvaluatedShape): SectionWorking {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const across =\n s.kind === 'rectangle'\n ? { [u]: s.size[u]!, [v]: s.size[v]! }\n : s.kind === 'ellipse'\n ? { [u]: 2 * s.radius[u]!, [v]: 2 * s.radius[v]! }\n : {}\n const c = shape.extrusion && shape.cavity\n return {\n points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [],\n across,\n length: e.end - e.start,\n apex: e.apex ? { ...e.apex } : null,\n cavity: c ? { wall: { ...c.wall }, start: c.start, end: c.end } : null\n }\n}\n\n/**\n * The part as the working state would make it: its section, its length from the same start, its inside -- what the\n * inside's drawing reads, so its walls are judged against the widths being typed and not the ones the editor opened with.\n */\nexport function workingShapeOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureEvaluatedShape {\n const e = shape.extrusion!\n const { cavity: _, ...rest } = shape\n return {\n ...rest,\n extrusion: { ...e, section: sectionOf(shape, w), end: e.start + w.length },\n ...(w.cavity ? { cavity: { id: shape.cavity?.id ?? 'inside', wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } } : {})\n } as FigureEvaluatedShape\n}\n\n/** The section the working state makes, of the part's own kind: its corners kept, its points or widths the working ones. */\nexport function sectionOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureSection {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n if (s.kind === 'polygon') return { kind: 'polygon', points: w.points }\n if (s.kind === 'ellipse') return { kind: 'ellipse', radius: { [u]: w.across[u]! / 2, [v]: w.across[v]! / 2 } }\n return { kind: 'rectangle', size: { [u]: w.across[u]!, [v]: w.across[v]! }, ...(s.corner ? { corner: s.corner } : {}) }\n}\n\n/** What would be refused, as words, with the section's own issues for marking points and sides. By the kernel's checks. */\nexport function workingIssuesOf(\n shape: FigureEvaluatedShape,\n w: SectionWorking\n): { issues: FigureSectionIssue[]; words: Array<{ key: string; params: Record<string, string> }> } {\n const e = drawnOf(shape)!\n const section = sectionOf(shape, w)\n const issues = checkFigureSection(section, e.axis)\n const words = issues.map(i => issueWords(i, w.points, e.axis))\n if (!(Number.isFinite(w.length) && w.length > 0)) words.push({ key: 'figure.text.section-issue-length', params: {} })\n if (w.apex && !Object.values(w.apex).every(n => Number.isFinite(n))) words.push({ key: 'figure.text.section-issue-number', params: {} })\n if (!issues.length && words.length === 0 && w.cavity) {\n const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [{ id: 'inside', ...w.cavity }])\n if ('refused' in made) {\n const r = made.refused\n words.push({ key: r.code === 'CAVITY_NO_LENGTH' ? 'figure.text.section-issue-cavity-length' : 'figure.text.section-issue-cavity-walls', params: {} })\n }\n }\n return { issues, words }\n}\n"]}