@mark1russell7/room-view 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -51,7 +51,7 @@ roomSolids(room); // => the floor, and the parts of each wall around the door
51
51
  - A **wall** is a straight line in the plan, with a thickness and a height. The field `side` tells which side of the line has the wall.
52
52
  - An **opening** is a door, a window or a gap in a wall.
53
53
  - A **floor** is one area of the plan.
54
- - An **outlet** is a point on a face of a wall. A **circuit** gives power to outlets, and it has a limit in watts.
54
+ - An **outlet** is a point on a face of a wall. A **circuit** gives power to outlets, and it has a limit in watts. A circuit can also keep the rating of its breaker in amperes and its voltage. The limit does not change with them.
55
55
 
56
56
  A scene is one room with its placed objects and the loads of its circuits. A placed object is a box: a desk, a rack, a computer. An object can have a parent, and then its position is relative to the parent.
57
57
 
package/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as lengthsInRange, S as LengthUnit, T as unitsPer, _ as WallFace, a as Opening, b as LARGEST_LENGTH, c as PlacedObject, d as Room, f as SCENE_SCHEMA, g as Wall, h as WALL_SIDES, i as OPENING_KINDS, l as PlanPoint, m as WALL_FACES, n as CircuitLoad, o as OpeningKind, p as Scene, r as Floor, s as Outlet, t as Circuit, u as ROOM_SCHEMA, v as WallSide, w as metersPer, x as LENGTH_UNITS, y as isLayerName } from "./room-x9FxGjGi.js";
2
- import { A as solidVolume, B as wallTransform, C as SolidShape, D as roomSolids, E as objectTransforms, F as wallFootprints, I as WallFrame, L as wallFrames, M as JoinOptions, N as MITER_LIMIT, O as sceneSolids, P as WallFootprint, R as wallHasOutline, S as SolidOptions, T as boundsOfSolids, _ as PlacedBox, a as LoadLevel, b as Solid, c as SHAPE_OUTLINES, d as levelShape, f as outletLevels, g as OUTLET_PLATE, h as GLASS_THICKNESS, i as LevelShape, j as JOIN_TOLERANCE, k as solidCorners, l as ShapeOutline, m as FLOOR_DEPTH, n as LEVEL_SHAPES, o as LoadOptions, p as shapeRing, r as LOAD_LEVELS, s as NEAR_LIMIT, t as CircuitState, u as circuitStates, v as Prism, w as TO_Y_UP, x as SolidKind, y as SOLID_KINDS, z as wallPoint } from "./loads-spBbQkb0.js";
3
- import { A as SurveyTurn, C as SurveyCheckResult, D as SurveyOutlet, E as SurveyOptions, M as expandSurvey, O as SurveyResult, S as SurveyCheck, T as SurveyObject, _ as expandLevel, a as ConnectionFault, b as SURVEY_SCHEMA, c as Level, d as LevelOptions, f as LevelResult, g as RoomPlace, h as ROOM_PLACES, i as ConnectionEnd, j as convertSurvey, k as SurveySide, l as LevelConnection, m as LevelRoomResult, n as CONNECTION_TURN_LIMIT, o as ConnectionUse, p as LevelRoom, r as CONNECTION_USES, s as LEVEL_SCHEMA, t as CONNECTION_FAULTS, u as LevelConnectionResult, v as CLOSURE_LIMIT, w as SurveyClosure, x as Survey, y as SQUARE_TURNS } from "./level-Cgja5fXb.js";
1
+ import { C as lengthsInRange, S as LengthUnit, T as unitsPer, _ as WallFace, a as Opening, b as LARGEST_LENGTH, c as PlacedObject, d as Room, f as SCENE_SCHEMA, g as Wall, h as WALL_SIDES, i as OPENING_KINDS, l as PlanPoint, m as WALL_FACES, n as CircuitLoad, o as OpeningKind, p as Scene, r as Floor, s as Outlet, t as Circuit, u as ROOM_SCHEMA, v as WallSide, w as metersPer, x as LENGTH_UNITS, y as isLayerName } from "./room-NREa6vXr.js";
2
+ import { A as solidVolume, B as wallTransform, C as SolidShape, D as roomSolids, E as objectTransforms, F as wallFootprints, I as WallFrame, L as wallFrames, M as JoinOptions, N as MITER_LIMIT, O as sceneSolids, P as WallFootprint, R as wallHasOutline, S as SolidOptions, T as boundsOfSolids, _ as PlacedBox, a as LoadLevel, b as Solid, c as SHAPE_OUTLINES, d as levelShape, f as outletLevels, g as OUTLET_PLATE, h as GLASS_THICKNESS, i as LevelShape, j as JOIN_TOLERANCE, k as solidCorners, l as ShapeOutline, m as FLOOR_DEPTH, n as LEVEL_SHAPES, o as LoadOptions, p as shapeRing, r as LOAD_LEVELS, s as NEAR_LIMIT, t as CircuitState, u as circuitStates, v as Prism, w as TO_Y_UP, x as SolidKind, y as SOLID_KINDS, z as wallPoint } from "./loads-C3Nrj3Gd.js";
3
+ import { A as SurveyTurn, C as SurveyCheckResult, D as SurveyOutlet, E as SurveyOptions, M as expandSurvey, O as SurveyResult, S as SurveyCheck, T as SurveyObject, _ as expandLevel, a as ConnectionFault, b as SURVEY_SCHEMA, c as Level, d as LevelOptions, f as LevelResult, g as RoomPlace, h as ROOM_PLACES, i as ConnectionEnd, j as convertSurvey, k as SurveySide, l as LevelConnection, m as LevelRoomResult, n as CONNECTION_TURN_LIMIT, o as ConnectionUse, p as LevelRoom, r as CONNECTION_USES, s as LEVEL_SCHEMA, t as CONNECTION_FAULTS, u as LevelConnectionResult, v as CLOSURE_LIMIT, w as SurveyClosure, x as Survey, y as SQUARE_TURNS } from "./level-Bmz-H5iH.js";
4
4
  import { Point3, Ring, Transform3 } from "@mark1russell7/layout-contract";
5
5
  /** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */
6
6
  export interface PlanShape {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plan.ts","../src/anchors.ts","../src/check.ts","../src/layers.ts"],"mappings":";;;;;iBAKiB;;WAEN;WACA,MAAM;;WAEN;;WAEA,MAAM;;WAEN;;WAEA;;;;;;wBAOK,UAAU,OAAO,QAAQ;;iBAgBxB,oBAAoB;;;;;WAK1B;;;;;;;wBAQK,WAAW,OAAO,OAAO,UAAS,uBAA4B;;qBC1CjE;;YAGD,wBAAwB;;iBAGnB;WACN;;WAEA;WACA,MAAM;;WAEN;;WAEA;;;iBAIM;WACN;WACA,IAAI;;WAEJ;;;iBAIM;WACN;WACA,IAAI;;WAEJ;;;;;;iBAOM;WACN;;WAEA;;WAEA;;WAEA;;;YAIC,SAAS,aAAa,cAAc,gBAAgB;;iBAG/C;;WAEN,IAAI;;WAEJ,KAAK;;;;;;iB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BAItC;;iBAGI;WACN,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;wBAgBK,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,SAAS,WAAW;;;;;;;;;wBAahE,YAAY,OAAO,OAAO,iBAAiB,4BAA4B"}
package/build/index.js CHANGED
@@ -284,7 +284,11 @@ function checkRoom(room, options = {}) {
284
284
  kind: "polygon",
285
285
  points: floor.ring
286
286
  }) * scale * scale > SMALL * SMALL)) error("floor-ring", "floor", floor.id, `The floor "${floor.id}" has no area. Its ring must have 3 or more corners that are not on one line.`);
287
- for (const circuit of circuits) if (!(circuit.limit > 0)) error("circuit-limit", "circuit", circuit.id, `The limit of the circuit "${circuit.id}" is ${show(circuit.limit)} W. It must be above 0.`);
287
+ for (const circuit of circuits) {
288
+ if (!(circuit.limit > 0)) error("circuit-limit", "circuit", circuit.id, `The limit of the circuit "${circuit.id}" is ${show(circuit.limit)} W. It must be above 0.`);
289
+ if (circuit.breaker !== void 0 && !(circuit.breaker > 0)) error("circuit-limit", "circuit", circuit.id, `The breaker of the circuit "${circuit.id}" is ${show(circuit.breaker)} A. It must be above 0.`);
290
+ if (circuit.voltage !== void 0 && !(circuit.voltage > 0)) error("circuit-limit", "circuit", circuit.id, `The voltage of the circuit "${circuit.id}" is ${show(circuit.voltage)} V. It must be above 0.`);
291
+ }
288
292
  return findings;
289
293
  }
290
294
  /** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts","../src/check.ts","../src/anchors.ts","../src/layers.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b.shape.top || a.index - b.index)\n .map(({ shape }) => shape);\n}\n","import { convexOverlap, length3, pointInRing, regionArea, transformPoint3, type Ring, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Anchor, SceneSpace } from \"./anchors.ts\";\nimport { wallFrames, wallHasOutline } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions } from \"./joins.ts\";\nimport type { PlacedObject, Room, Scene } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */\nexport const FINDING_LEVELS: readonly [\"error\", \"warning\"] = [\"error\", \"warning\"];\n\n/** A level of a finding. */\nexport type FindingLevel = (typeof FINDING_LEVELS)[number];\n\n/** These are the kinds of the records that a finding can name. */\nexport const RECORD_KINDS: readonly [\"room\", \"wall\", \"opening\", \"floor\", \"outlet\", \"circuit\", \"object\", \"load\"] = [\n \"room\",\n \"wall\",\n \"opening\",\n \"floor\",\n \"outlet\",\n \"circuit\",\n \"object\",\n \"load\",\n];\n\n/** A kind of record. */\nexport type RecordKind = (typeof RECORD_KINDS)[number];\n\n/**\n * This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.\n * The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.\n */\nexport function recordName(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n\n/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */\nexport function parseRecordName(name: string): { readonly kind: string; readonly id: string } | undefined {\n const colon = name.indexOf(\":\");\n return colon < 1 ? undefined : { kind: name.slice(0, colon), id: name.slice(colon + 1) };\n}\n\n/** These are the codes of the findings. */\nexport const FINDING_CODES: readonly [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n] = [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n];\n\n/** A code of a finding. */\nexport type FindingCode = (typeof FINDING_CODES)[number];\n\n/** A finding: one fault of a room record or a scene record. */\nexport interface Finding {\n readonly level: FindingLevel;\n readonly code: FindingCode;\n /** The kind of the record with the fault. */\n readonly record: RecordKind;\n /** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /**\n * The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.\n * It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.\n */\n readonly other?: string | undefined;\n}\n\n/** The options of the checks. Give the options that the model gets. */\nexport interface CheckOptions {\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** A length in meters at this value or less is 0 for the checks: a size must be above it. */\nconst SMALL = 1e-6;\n\n/** This function gives a number with 3 decimals at most. */\nfunction show(value: number): string {\n return String(Math.round(value * 1000) / 1000);\n}\n\n/** This function tells if a value is a number that is not finite, or if it holds such a number. */\nfunction holdsBadNumber(value: unknown): boolean {\n if (typeof value === \"number\") return !Number.isFinite(value);\n if (Array.isArray(value)) return value.some((item) => holdsBadNumber(item));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsBadNumber(item));\n return false;\n}\n\n/** This function tells if a value is a finite number with a size above a limit, or if it holds such a number. */\nfunction holdsLargeNumber(value: unknown, limit: number): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && Math.abs(value) > limit;\n if (Array.isArray(value)) return value.some((item) => holdsLargeNumber(item, limit));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsLargeNumber(item, limit));\n return false;\n}\n\n/** This function gives each value that a list has two or more times. */\nfunction repeated(ids: readonly string[]): readonly string[] {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) twice.add(id);\n seen.add(id);\n }\n return [...twice];\n}\n\n/**\n * This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.\n *\n * The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.\n */\nexport function checkRoom(room: Room, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const scale = metersPer(room.unit);\n /** The largest length of the model, in the unit of the room. */\n const largest = LARGEST_LENGTH / scale;\n /** This function tells if a size of the record is 0 for the checks. */\n const none = (size: number): boolean => !(size * scale > SMALL);\n const openings = room.openings ?? [];\n const outlets = room.outlets ?? [];\n const circuits = room.circuits ?? [];\n const floors = room.floors ?? [];\n\n if (holdsBadNumber([room.height, room.wallThickness])) error(\"number-not-finite\", \"room\", \"\", \"The height or the wall thickness of the room is not a finite number.\");\n if (holdsLargeNumber([room.height, room.wallThickness], largest)) error(\"number-too-large\", \"room\", \"\", `The height or the wall thickness of the room is above 1 000 km, the largest length of the model.`);\n const lists: readonly (readonly [RecordKind, readonly { readonly id: string }[]])[] = [\n [\"wall\", room.walls],\n [\"opening\", openings],\n [\"floor\", floors],\n [\"outlet\", outlets],\n [\"circuit\", circuits],\n ];\n for (const [record, list] of lists) {\n for (const item of list) {\n if (holdsBadNumber(item)) error(\"number-not-finite\", record, item.id, `A number of the ${record} \"${item.id}\" is not finite.`);\n // The limit of a circuit is a power, not a length.\n if (record !== \"circuit\" && holdsLargeNumber(item, largest)) error(\"number-too-large\", record, item.id, `A length of the ${record} \"${item.id}\" is above 1 000 km, the largest length of the model.`);\n }\n for (const id of repeated(list.map((item) => item.id))) error(\"id-duplicate\", record, id, `Two or more records of the kind ${record} have the id \"${id}\".`);\n }\n\n if (none(room.height)) error(\"size-not-positive\", \"room\", \"\", `The height of the room is ${show(room.height)}. It must be above 0.`);\n if (none(room.wallThickness)) error(\"size-not-positive\", \"room\", \"\", `The wall thickness of the room is ${show(room.wallThickness)}. It must be above 0.`);\n\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n frames.forEach((frame, index) => {\n const wall = room.walls[index]!;\n if (wall.thickness !== undefined && none(wall.thickness)) error(\"size-not-positive\", \"wall\", wall.id, `The thickness of the wall \"${wall.id}\" is ${show(wall.thickness)}. It must be above 0.`);\n if (wall.height !== undefined && none(wall.height)) error(\"size-not-positive\", \"wall\", wall.id, `The height of the wall \"${wall.id}\" is ${show(wall.height)}. It must be above 0.`);\n const [clearFrom, clearTo] = footprints[index]!.clear;\n if (!(frame.length > SMALL)) error(\"wall-length\", \"wall\", wall.id, `The wall \"${wall.id}\" has the length 0: its two ends are one point.`);\n else if (wallHasOutline(frame) && !(clearTo - clearFrom > SMALL)) warning(\"wall-short\", \"wall\", wall.id, `The wall \"${wall.id}\" is too short for the corners at its ends: no part of it has its full thickness.`);\n });\n for (let i = 0; i < footprints.length; i++) {\n for (let j = i + 1; j < footprints.length; j++) {\n const a = footprints[i]!;\n const b = footprints[j]!;\n if (a.ring.length < 3 || b.ring.length < 3 || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"wall-overlap\", \"wall\", a.wall, `The walls \"${a.wall}\" and \"${b.wall}\" overlap. Walls connect only at their ends: divide a wall at the point where a different wall crosses it.`);\n }\n }\n\n const frameOf = new Map(frames.map((frame, index) => [frame.id, { frame, footprint: footprints[index]! }] as const));\n const holes = new Map<string, { id: string; from: number; to: number; sill: number; top: number }[]>();\n for (const opening of openings) {\n const found = frameOf.get(opening.wall);\n if (found === undefined) {\n error(\"opening-wall\", \"opening\", opening.id, `The opening \"${opening.id}\" is on the wall \"${opening.wall}\", which the room does not have.`);\n continue;\n }\n if (none(opening.width)) error(\"size-not-positive\", \"opening\", opening.id, `The width of the opening \"${opening.id}\" is ${show(opening.width)}. It must be above 0.`);\n if (none(opening.height)) error(\"size-not-positive\", \"opening\", opening.id, `The height of the opening \"${opening.id}\" is ${show(opening.height)}. It must be above 0.`);\n if (none(opening.width) || none(opening.height)) continue;\n const from = opening.offset * scale;\n const to = (opening.offset + opening.width) * scale;\n const sill = (opening.sill ?? 0) * scale;\n const top = sill + opening.height * scale;\n const [clearFrom, clearTo] = found.footprint.clear;\n if (from < clearFrom - SMALL || to > clearTo + SMALL) {\n error(\n \"opening-range\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from ${show(opening.offset)} to ${show(opening.offset + opening.width)} along the wall \"${opening.wall}\". The straight part of that wall is from ${show(clearFrom / scale)} to ${show(clearTo / scale)}.`,\n );\n }\n if (sill < 0 || top > found.frame.height + SMALL) {\n error(\n \"opening-height\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from the height ${show(sill / scale)} to ${show(top / scale)}. The wall \"${opening.wall}\" is from 0 to ${show(found.frame.height / scale)}.`,\n );\n }\n const list = holes.get(opening.wall) ?? [];\n list.push({ id: opening.id, from, to, sill, top });\n holes.set(opening.wall, list);\n }\n for (const [wall, list] of holes) {\n list.sort((a, b) => a.from - b.from);\n for (let i = 1; i < list.length; i++) {\n const before = list[i - 1]!;\n const hole = list[i]!;\n if (hole.from < before.to - SMALL) error(\"opening-overlap\", \"opening\", hole.id, `The openings \"${before.id}\" and \"${hole.id}\" of the wall \"${wall}\" overlap.`, before.id);\n }\n }\n\n const circuitIds = new Set(circuits.map((circuit) => circuit.id));\n for (const outlet of outlets) {\n if (outlet.circuit !== undefined && !circuitIds.has(outlet.circuit)) error(\"outlet-circuit\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the circuit \"${outlet.circuit}\", which the room does not have.`);\n const found = frameOf.get(outlet.wall);\n if (found === undefined) {\n error(\"outlet-wall\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the wall \"${outlet.wall}\", which the room does not have.`);\n continue;\n }\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!(along >= 0 && along <= found.frame.length + SMALL && height >= 0 && height <= found.frame.height + SMALL)) {\n error(\n \"outlet-range\",\n \"outlet\",\n outlet.id,\n `The outlet \"${outlet.id}\" is at ${show(outlet.offset)} along the wall \"${outlet.wall}\" and at the height ${show(outlet.height)}. The wall has the length ${show(found.frame.length / scale)} and the height ${show(found.frame.height / scale)}.`,\n );\n continue;\n }\n const hole = (holes.get(outlet.wall) ?? []).find((item) => along > item.from && along < item.to && height > item.sill && height < item.top);\n if (hole !== undefined) warning(\"outlet-in-opening\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is in the opening \"${hole.id}\" of the wall \"${outlet.wall}\".`, hole.id);\n }\n\n for (const floor of floors) {\n if (floor.ring.length < 3 || !(regionArea({ kind: \"polygon\", points: floor.ring }) * scale * scale > SMALL * SMALL)) {\n error(\"floor-ring\", \"floor\", floor.id, `The floor \"${floor.id}\" has no area. Its ring must have 3 or more corners that are not on one line.`);\n }\n }\n for (const circuit of circuits) {\n if (!(circuit.limit > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The limit of the circuit \"${circuit.id}\" is ${show(circuit.limit)} W. It must be above 0.`);\n }\n return findings;\n}\n\n/** The outline in the plan and the range of heights of a placed object, in meters. */\ninterface Extent {\n readonly object: PlacedObject;\n readonly ring: Ring;\n readonly z: number;\n readonly top: number;\n}\n\n/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */\nfunction extentOf(object: PlacedObject, transform: Transform3, scale: number): Extent {\n const w = (object.size[0] * scale) / 2;\n const h = (object.size[1] * scale) / 2;\n const corners: readonly (readonly [number, number])[] = [\n [0 - w, 0 - h],\n [w, 0 - h],\n [w, h],\n [0 - w, h],\n ];\n const ring = corners.map(([x, y]) => {\n const point = transformPoint3(transform, { x, y, z: 0 });\n return [point.x, point.y] as const;\n });\n return { object, ring, z: transform.position.z, top: transform.position.z + object.size[2] * scale };\n}\n\n/**\n * This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.\n * A scene with no finding of the level `error` gives a full model.\n */\nexport function checkScene(scene: Scene, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [...checkRoom(scene.room, options)];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const room = scene.room;\n const scale = metersPer(room.unit);\n const objects = scene.objects ?? [];\n const byId = new Map(objects.map((object) => [object.id, object] as const));\n const outletIds = new Set((room.outlets ?? []).map((outlet) => outlet.id));\n const circuitIds = new Set((room.circuits ?? []).map((circuit) => circuit.id));\n /** This function tells if each size of an object is above 0 for the checks. */\n const hasSize = (object: PlacedObject): boolean => object.size.every((size) => size * scale > SMALL);\n\n for (const id of repeated(objects.map((object) => object.id))) error(\"id-duplicate\", \"object\", id, `Two or more records of the kind object have the id \"${id}\".`);\n\n /** The objects that hold an object, from its parent up. A loop of parents gives `undefined`. */\n const holders = (object: PlacedObject): ReadonlySet<string> | undefined => {\n const seen = new Set<string>([object.id]);\n const above = new Set<string>();\n let parent = object.parent === undefined ? undefined : byId.get(object.parent);\n while (parent !== undefined) {\n if (seen.has(parent.id)) return undefined;\n seen.add(parent.id);\n above.add(parent.id);\n parent = parent.parent === undefined ? undefined : byId.get(parent.parent);\n }\n return above;\n };\n\n for (const object of objects) {\n if (holdsBadNumber(object)) error(\"number-not-finite\", \"object\", object.id, `A number of the object \"${object.id}\" is not finite.`);\n // The turn of an object is an angle, so it has no such limit.\n if (holdsLargeNumber([object.size, object.at, object.lift], LARGEST_LENGTH / scale)) error(\"number-too-large\", \"object\", object.id, `A length of the object \"${object.id}\" is above 1 000 km, the largest length of the model.`);\n if (!hasSize(object)) error(\"size-not-positive\", \"object\", object.id, `The size of the object \"${object.id}\" is ${object.size.map(show).join(\" by \")}. Each number must be above 0.`);\n if (object.parent !== undefined && !byId.has(object.parent)) error(\"object-parent\", \"object\", object.id, `The object \"${object.id}\" is on the object \"${object.parent}\", which the scene does not have.`, object.parent);\n else if (holders(object) === undefined) error(\"object-cycle\", \"object\", object.id, `The parents of the object \"${object.id}\" make a loop.`);\n if (object.outlet !== undefined && !outletIds.has(object.outlet)) error(\"object-outlet\", \"object\", object.id, `The object \"${object.id}\" uses the outlet \"${object.outlet}\", which the room does not have.`, object.outlet);\n }\n\n const transforms = objectTransforms(scene);\n const extents: Extent[] = [];\n for (const object of objects) {\n const transform = transforms.get(object.id);\n if (transform !== undefined && hasSize(object)) extents.push(extentOf(object, transform, scale));\n }\n\n const floors = (room.floors ?? []).filter((floor) => floor.ring.length >= 3).map((floor) => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n for (const extent of extents) {\n const { object } = extent;\n const transform = transforms.get(object.id)!;\n if (object.parent === undefined && floors.length > 0 && !floors.some((ring) => pointInRing(transform.position.x, transform.position.y, ring))) {\n warning(\"object-outside\", \"object\", object.id, `The center of the object \"${object.id}\" is not on a floor of the room.`);\n }\n footprints.forEach((footprint, index) => {\n if (footprint.ring.length < 3 || !(extent.z < frames[index]!.height - SMALL) || !(convexOverlap(footprint.ring, extent.ring) > SMALL)) return;\n warning(\"object-in-wall\", \"object\", object.id, `The object \"${object.id}\" overlaps the wall \"${footprint.wall}\".`, footprint.wall);\n });\n }\n for (let i = 0; i < extents.length; i++) {\n for (let j = i + 1; j < extents.length; j++) {\n const a = extents[i]!;\n const b = extents[j]!;\n if (holders(a.object)?.has(b.object.id) === true || holders(b.object)?.has(a.object.id) === true) continue;\n if (!(Math.min(a.top, b.top) - Math.max(a.z, b.z) > SMALL) || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"object-overlap\", \"object\", a.object.id, `The objects \"${a.object.id}\" and \"${b.object.id}\" overlap.`, b.object.id);\n }\n }\n\n for (const load of scene.loads ?? []) {\n if (!circuitIds.has(load.circuit)) error(\"load-circuit\", \"load\", load.circuit, `A load is on the circuit \"${load.circuit}\", which the room does not have.`);\n if (!(load.watts >= 0 && Number.isFinite(load.watts))) error(\"load-watts\", \"load\", load.circuit, `A load of the circuit \"${load.circuit}\" is ${show(load.watts)} W. It must be a finite number, 0 or more.`);\n }\n return findings;\n}\n\n/** These are the codes of the faults of an anchor. */\nexport const ANCHOR_CODES: readonly [\n \"anchor-not-finite\",\n \"anchor-wall\",\n \"anchor-object\",\n \"anchor-floor\",\n \"anchor-range\",\n \"anchor-direction\",\n \"anchor-in-opening\",\n \"anchor-outside\",\n] = [\"anchor-not-finite\", \"anchor-wall\", \"anchor-object\", \"anchor-floor\", \"anchor-range\", \"anchor-direction\", \"anchor-in-opening\", \"anchor-outside\"];\n\n/** A code of a fault of an anchor. */\nexport type AnchorCode = (typeof ANCHOR_CODES)[number];\n\n/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */\nexport interface AnchorFault {\n readonly level: FindingLevel;\n readonly code: AnchorCode;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * This function gives the faults of an anchor in the space of a scene. `name` starts each message.\n * An error tells that the anchor has no position. A warning tells a fault that the model can show.\n */\nexport function checkAnchor(anchor: Anchor, space: SceneSpace, name: string = \"The anchor\"): readonly AnchorFault[] {\n const error = (code: AnchorCode, message: string): readonly AnchorFault[] => [{ level: \"error\", code, message: `${name} ${message}` }];\n const { scene, scale } = space;\n if (holdsBadNumber(anchor)) return error(\"anchor-not-finite\", \"has a number that is not finite.\");\n if (anchor.on === \"wall\") {\n const wall = space.wall(anchor.wall);\n if (wall === undefined) return error(\"anchor-wall\", `is on the wall \"${anchor.wall}\", which the room does not have.`);\n const along = anchor.offset * scale;\n const height = anchor.height * scale;\n if (!(along >= 0 && along <= wall.length + SMALL && height >= 0 && height <= wall.height + SMALL)) {\n return error(\n \"anchor-range\",\n `is at ${show(anchor.offset)} along the wall \"${anchor.wall}\" and at the height ${show(anchor.height)}. The wall has the length ${show(wall.length / scale)} and the height ${show(wall.height / scale)}.`,\n );\n }\n const hole = (scene.room.openings ?? []).find((opening) => {\n const sill = (opening.sill ?? 0) * scale;\n return opening.wall === anchor.wall && along > opening.offset * scale && along < (opening.offset + opening.width) * scale && height > sill && height < sill + opening.height * scale;\n });\n return hole === undefined ? [] : [{ level: \"warning\", code: \"anchor-in-opening\", message: `${name} is in the opening \"${hole.id}\" of the wall \"${anchor.wall}\".`, other: hole.id }];\n }\n if (anchor.on === \"object\") {\n const object = space.object(anchor.object);\n if (object === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which the scene does not have.`);\n // An object with no place has a fault of its own, which `checkScene` tells. Here, the anchor tells that it has no position.\n if (space.transform(anchor.object) === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which has no place in the room.`);\n const small = SMALL / scale;\n if (anchor.at !== undefined) {\n const [x, y, z] = anchor.at;\n const [width, depth, height] = object.size;\n if (!(Math.abs(x) <= width / 2 + small && Math.abs(y) <= depth / 2 + small && z >= -small && z <= height + small)) {\n return error(\"anchor-range\", `is at (${anchor.at.map(show).join(\", \")}) in the frame of the object \"${anchor.object}\". The object has the size ${object.size.map(show).join(\" by \")}.`);\n }\n }\n if (anchor.out !== undefined) {\n const [x, y, z] = anchor.out;\n if (!(length3({ x, y, z }) > 0)) return error(\"anchor-direction\", \"has a direction with the length 0. A direction must have a length above 0.\");\n }\n return [];\n }\n const [x, y] = anchor.at;\n if (!lengthsInRange(x * scale, y * scale)) return error(\"anchor-range\", \"is at a point above 1 000 km, the largest length of the model.\");\n const word = anchor.on === \"floor\" ? \"on\" : \"above\";\n const floors = scene.room.floors ?? [];\n if (anchor.floor !== undefined) {\n const floor = floors.find((item) => item.id === anchor.floor);\n if (floor === undefined) return error(\"anchor-floor\", `is ${word} the floor \"${anchor.floor}\", which the room does not have.`);\n return pointInRing(x, y, floor.ring) ? [] : [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} the floor \"${anchor.floor}\".` }];\n }\n if (floors.length === 0 || floors.some((floor) => pointInRing(x, y, floor.ring))) return [];\n return [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} a floor of the room.` }];\n}\n","import { length3, rotatePoint3, scalePoint3, transformPoint3, type Point3, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallPoint, type WallFrame } from \"./frames.ts\";\nimport type { PlacedObject, PlanPoint, Scene, WallFace } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n// The anchors of the core: the places where an add-on puts its records. The core gives each anchor its position.\n// An anchor names no topic. An outlet, a tap and a lamp are records of add-ons, and each one is on an anchor.\n\n/** These are the surfaces that an anchor can be on. */\nexport const ANCHOR_SURFACES: readonly [\"wall\", \"floor\", \"ceiling\", \"object\"] = [\"wall\", \"floor\", \"ceiling\", \"object\"];\n\n/** A surface of an anchor. */\nexport type AnchorSurface = (typeof ANCHOR_SURFACES)[number];\n\n/** An anchor on a face of a wall. The lengths are in the unit of the room. */\nexport interface WallAnchor {\n readonly on: \"wall\";\n /** The `id` of the wall. */\n readonly wall: string;\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the anchor. */\n readonly offset: number;\n /** The height of the anchor above the floor. */\n readonly height: number;\n}\n\n/** An anchor on the floor, at a point of the plan. */\nexport interface FloorAnchor {\n readonly on: \"floor\";\n readonly at: PlanPoint;\n /** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */\nexport interface CeilingAnchor {\n readonly on: \"ceiling\";\n readonly at: PlanPoint;\n /** The `id` of the floor below the point. Without it, the point is above any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/**\n * An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.\n * The origin of that frame is the center of the bottom of the object.\n */\nexport interface ObjectAnchor {\n readonly on: \"object\";\n /** The `id` of the placed object. */\n readonly object: string;\n /** The point in the frame of the object. The default is the center of its top. */\n readonly at?: readonly [number, number, number] | undefined;\n /** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */\n readonly out?: readonly [number, number, number] | undefined;\n}\n\n/** An anchor: a place in the space of the core, for a record of an add-on. */\nexport type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;\n\n/** The position of an anchor in the room, in meters. */\nexport interface AnchorFrame {\n /** The point of the anchor. */\n readonly at: Point3;\n /** The unit vector out of the surface, into the space of the room. */\n readonly out: Point3;\n}\n\n/**\n * The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.\n * Make it once with `sceneSpace`, and give it to each add-on.\n */\nexport interface SceneSpace {\n readonly scene: Scene;\n /** The length of the unit of the room, in meters. */\n readonly scale: number;\n /** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */\n readonly wall: (id: string) => WallFrame | undefined;\n /** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */\n readonly object: (id: string) => PlacedObject | undefined;\n /** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */\n readonly transform: (id: string) => Transform3 | undefined;\n /** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */\n readonly frame: (anchor: Anchor) => AnchorFrame | undefined;\n}\n\nconst UP: Point3 = { x: 0, y: 0, z: 1 };\nconst DOWN: Point3 = { x: 0, y: 0, z: -1 };\n\n/** This function tells if each value of a point is a length in the range of the model. */\nfunction inRange(point: Point3): boolean {\n return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z) && lengthsInRange(point.x, point.y, point.z);\n}\n\n/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */\nexport function sceneSpace(scene: Scene): SceneSpace {\n const scale = metersPer(scene.room.unit);\n const walls = new Map(wallFrames(scene.room).map((frame) => [frame.id, frame] as const));\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n let transforms: ReadonlyMap<string, Transform3> | undefined;\n const transform = (id: string): Transform3 | undefined => {\n transforms ??= objectTransforms(scene);\n return transforms.get(id);\n };\n const frame = (anchor: Anchor): AnchorFrame | undefined => {\n let found: AnchorFrame | undefined;\n if (anchor.on === \"wall\") {\n const wall = walls.get(anchor.wall);\n if (wall === undefined) return undefined;\n const point = wallPoint(wall, anchor.offset * scale, anchor.face === \"left\" ? wall.leftOffset : wall.rightOffset);\n const sign = anchor.face === \"left\" ? 1 : -1;\n found = { at: { x: point.x, y: point.y, z: anchor.height * scale }, out: { x: wall.left.x * sign, y: wall.left.y * sign, z: 0 } };\n } else if (anchor.on === \"floor\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: 0 }, out: UP };\n } else if (anchor.on === \"ceiling\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: scene.room.height * scale }, out: DOWN };\n } else {\n const object = objects.get(anchor.object);\n const place = transform(anchor.object);\n if (object === undefined || place === undefined) return undefined;\n const [x, y, z] = anchor.at ?? [0, 0, object.size[2]];\n const [ox, oy, oz] = anchor.out ?? [0, 0, 1];\n const out = { x: ox, y: oy, z: oz };\n const size = length3(out);\n if (!(size > 0) || !Number.isFinite(size)) return undefined;\n found = { at: transformPoint3(place, { x: x * scale, y: y * scale, z: z * scale }), out: rotatePoint3(place.rotation, scalePoint3(out, 1 / size)) };\n }\n return inRange(found.at) && inRange(found.out) ? found : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n","import { sceneSpace, type Anchor, type SceneSpace } from \"./anchors.ts\";\nimport { checkAnchor, type FindingLevel } from \"./check.ts\";\nimport { isLayerName, type Scene } from \"./room.ts\";\n\n// The layers of a scene: the records of the add-ons. The core keeps each layer, and it does not read one.\n// An add-on reads its layer, gives the anchors of its records, and examines the meaning of its records.\n// The core examines the anchors. Thus each add-on composes on the core, and the add-ons do not know each other.\n\n/** The result of the read of a layer: the layer, or the faults of its form. */\nexport type LayerParse<Layer> = { readonly ok: true; readonly layer: Layer } | { readonly ok: false; readonly errors: readonly string[] };\n\n/** A fault that an add-on finds in its layer. */\nexport interface AddOnFault {\n readonly level: FindingLevel;\n /** The code of the fault. The add-on gives its own codes. */\n readonly code: string;\n /** The `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * An add-on: one topic on the core, for example electrical, plumbing or light.\n * A host gives a list of add-ons to `checkLayers`. The core knows only this type.\n */\nexport interface AddOn<Layer> {\n /** The name of the format of the layer, for example `electrical/1`. It is the key of the layer in `Scene.layers`. */\n readonly schema: string;\n /** This function reads the JSON of a layer. */\n parse(value: unknown): LayerParse<Layer>;\n /**\n * This function gives the anchors of the records of a layer, by a key.\n * The key is the `id` of a record, or the `id` and a position for a record with many anchors.\n */\n anchors(layer: Layer): ReadonlyMap<string, Anchor>;\n /** This function gives the layer with new anchors, by the keys of `anchors`. The core uses it when it moves the records of a room. */\n withAnchors(layer: Layer, anchors: ReadonlyMap<string, Anchor>): Layer;\n /** This function gives the faults of the meaning of a layer. The core examines the anchors, so this function does not. */\n check(layer: Layer, space: SceneSpace): readonly AddOnFault[];\n}\n\n/** These are the codes of the faults of a layer that the core finds. */\nexport const LAYER_CODES: readonly [\"layer-name\", \"layer-unknown\", \"layer-form\"] = [\"layer-name\", \"layer-unknown\", \"layer-form\"];\n\n/** A finding of a layer: a fault of its form, of an anchor or of the meaning of its records. */\nexport interface LayerFinding {\n readonly level: FindingLevel;\n /** A code of `LAYER_CODES` or `ANCHOR_CODES`, or a code of the add-on. */\n readonly code: string;\n /** The key of the layer in `Scene.layers`. */\n readonly layer: string;\n /** The key of the anchor, or the `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/** This function compares two texts by their code points, so the order does not change with the language of a computer. */\nfunction compareText(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** This function gives the add-on of each schema name. The first add-on of a name is used. */\nfunction addOnsByName(addOns: readonly AddOn<unknown>[]): ReadonlyMap<string, AddOn<unknown>> {\n const byName = new Map<string, AddOn<unknown>>();\n for (const addOn of addOns) if (!byName.has(addOn.schema)) byName.set(addOn.schema, addOn);\n return byName;\n}\n\n/** This function reads the layer of an add-on in a scene. It gives `undefined` when the scene has no layer of the add-on. */\nexport function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): LayerParse<Layer> | undefined {\n const layers = scene.layers ?? {};\n return Object.hasOwn(layers, addOn.schema) ? addOn.parse(layers[addOn.schema]) : undefined;\n}\n\n/**\n * This function gives the findings of the layers of a scene, with a list of add-ons.\n * Each layer gets the faults of its form, of each anchor and of the meaning of its records. A layer of no add-on of the list gets a warning.\n * The findings are in the order of the layer keys, then of the record keys. Thus equal inputs give equal findings.\n *\n * The name of the record of a finding is `recordName(finding.layer, finding.at)`, so a finding selects its mark.\n * `checkScene` examines the core, and this function examines the layers.\n */\nexport function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[] {\n const byName = addOnsByName(addOns);\n const layers = scene.layers ?? {};\n const findings: LayerFinding[] = [];\n let space: SceneSpace | undefined;\n for (const name of Object.keys(layers).sort(compareText)) {\n if (!isLayerName(name)) {\n findings.push({ level: \"error\", code: \"layer-name\", layer: name, at: \"\", message: `The layer \"${name}\" has a name that is not a word, a slash and a version, for example \"electrical/1\".` });\n continue;\n }\n const addOn = byName.get(name);\n if (addOn === undefined) {\n findings.push({ level: \"warning\", code: \"layer-unknown\", layer: name, at: \"\", message: `The scene has the layer \"${name}\", and no add-on of the check reads it. The scene keeps the layer.` });\n continue;\n }\n const read = addOn.parse(layers[name]);\n if (!read.ok) {\n for (const message of read.errors) findings.push({ level: \"error\", code: \"layer-form\", layer: name, at: \"\", message });\n continue;\n }\n space ??= sceneSpace(scene);\n const own: LayerFinding[] = [];\n for (const [key, anchor] of addOn.anchors(read.layer)) {\n for (const fault of checkAnchor(anchor, space, `The anchor \"${key}\" of the layer \"${name}\"`)) own.push({ ...fault, layer: name, at: key });\n }\n for (const fault of addOn.check(read.layer, space)) own.push({ ...fault, layer: name });\n // The sort is stable, so the faults of one record keep their order.\n own.sort((a, b) => compareText(a.at, b.at));\n findings.push(...own);\n }\n return findings;\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,UAAU,OAAyB;CACjD,MAAM,EAAE,IAAI,MAAM,QAAQ,UAAU;CACpC,IAAI,MAAM,SAAS,SAAS,OAAO;EAAE,OAAO;EAAI;EAAM;EAAQ,MAAM,MAAM;EAAM,QAAQ,MAAM;EAAG,KAAK,MAAM,IAAI,MAAM;CAAE;CACxH,MAAM,EAAE,KAAK,cAAc;CAC3B,MAAM,OAAO;EACX;GAAE,GAAG,IAAI;GAAG,GAAG,IAAI;GAAG,GAAG,IAAI;EAAE;EAC/B;GAAE,GAAG,IAAI,IAAI,IAAI;GAAG,GAAG,IAAI;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IAAE,OAAO;IAAS,MAAM;IAAc,OAAO;IAAM,IAAI;IAAI,SAAS,cAAc,KAAK;GAAqF,CAAC;GAC3L;EACF;EACA,MAAM,QAAQ,OAAO,IAAI,IAAI;EAC7B,IAAI,UAAU,KAAA,GAAW;GACvB,SAAS,KAAK;IAAE,OAAO;IAAW,MAAM;IAAiB,OAAO;IAAM,IAAI;IAAI,SAAS,4BAA4B,KAAK;GAAoE,CAAC;GAC7L;EACF;EACA,MAAM,OAAO,MAAM,MAAM,OAAO,KAAK;EACrC,IAAI,CAAC,KAAK,IAAI;GACZ,KAAK,MAAM,WAAW,KAAK,QAAQ,SAAS,KAAK;IAAE,OAAO;IAAS,MAAM;IAAc,OAAO;IAAM,IAAI;IAAI;GAAQ,CAAC;GACrH;EACF;EACA,UAAU,WAAW,KAAK;EAC1B,MAAM,MAAsB,CAAC;EAC7B,KAAK,MAAM,CAAC,KAAK,WAAW,MAAM,QAAQ,KAAK,KAAK,GAClD,KAAK,MAAM,SAAS,YAAY,QAAQ,OAAO,eAAe,IAAI,kBAAkB,KAAK,EAAE,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;GAAM,IAAI;EAAI,CAAC;EAE3I,KAAK,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;EAAK,CAAC;EAEtF,IAAI,MAAM,GAAG,MAAM,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC;EAC1C,SAAS,KAAK,GAAG,GAAG;CACtB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts","../src/check.ts","../src/anchors.ts","../src/layers.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b.shape.top || a.index - b.index)\n .map(({ shape }) => shape);\n}\n","import { convexOverlap, length3, pointInRing, regionArea, transformPoint3, type Ring, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport type { Anchor, SceneSpace } from \"./anchors.ts\";\nimport { wallFrames, wallHasOutline } from \"./frames.ts\";\nimport { wallFootprints, type JoinOptions } from \"./joins.ts\";\nimport type { PlacedObject, Room, Scene } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { LARGEST_LENGTH, lengthsInRange, metersPer } from \"./units.ts\";\n\n/** These are the levels of a finding. An error is a fault that the model cannot show. A warning is a fault that the model can show. */\nexport const FINDING_LEVELS: readonly [\"error\", \"warning\"] = [\"error\", \"warning\"];\n\n/** A level of a finding. */\nexport type FindingLevel = (typeof FINDING_LEVELS)[number];\n\n/** These are the kinds of the records that a finding can name. */\nexport const RECORD_KINDS: readonly [\"room\", \"wall\", \"opening\", \"floor\", \"outlet\", \"circuit\", \"object\", \"load\"] = [\n \"room\",\n \"wall\",\n \"opening\",\n \"floor\",\n \"outlet\",\n \"circuit\",\n \"object\",\n \"load\",\n];\n\n/** A kind of record. */\nexport type RecordKind = (typeof RECORD_KINDS)[number];\n\n/**\n * This function gives the name of a record: its kind, a colon and its `id`, for example `object:desk`.\n * The kind of a record of a layer is the name of the layer, for example `electrical/1`. A finding, a mark and the selection use this name.\n */\nexport function recordName(kind: string, id: string): string {\n return `${kind}:${id}`;\n}\n\n/** This function gives the kind and the `id` of a record name, or `undefined` for a text with no kind. A kind has no colon, so the first colon ends it. */\nexport function parseRecordName(name: string): { readonly kind: string; readonly id: string } | undefined {\n const colon = name.indexOf(\":\");\n return colon < 1 ? undefined : { kind: name.slice(0, colon), id: name.slice(colon + 1) };\n}\n\n/** These are the codes of the findings. */\nexport const FINDING_CODES: readonly [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n] = [\n \"number-not-finite\",\n \"number-too-large\",\n \"id-duplicate\",\n \"size-not-positive\",\n \"wall-length\",\n \"wall-short\",\n \"wall-overlap\",\n \"opening-wall\",\n \"opening-range\",\n \"opening-height\",\n \"opening-overlap\",\n \"outlet-wall\",\n \"outlet-circuit\",\n \"outlet-range\",\n \"outlet-in-opening\",\n \"floor-ring\",\n \"circuit-limit\",\n \"object-parent\",\n \"object-cycle\",\n \"object-outlet\",\n \"object-outside\",\n \"object-overlap\",\n \"object-in-wall\",\n \"load-circuit\",\n \"load-watts\",\n];\n\n/** A code of a finding. */\nexport type FindingCode = (typeof FINDING_CODES)[number];\n\n/** A finding: one fault of a room record or a scene record. */\nexport interface Finding {\n readonly level: FindingLevel;\n readonly code: FindingCode;\n /** The kind of the record with the fault. */\n readonly record: RecordKind;\n /** The `id` of the record with the fault. For a load, it is the `id` of the circuit. For the room record, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /**\n * The `id` of the second record of the fault. It is the other opening or the other object of an overlap, or the opening that an outlet is in.\n * It is also the wall that an object overlaps, or the parent or the outlet that an object names. A fault of one record has none.\n */\n readonly other?: string | undefined;\n}\n\n/** The options of the checks. Give the options that the model gets. */\nexport interface CheckOptions {\n /** The options of the corners of the walls. */\n readonly joins?: JoinOptions | undefined;\n}\n\n/** A length in meters at this value or less is 0 for the checks: a size must be above it. */\nconst SMALL = 1e-6;\n\n/** This function gives a number with 3 decimals at most. */\nfunction show(value: number): string {\n return String(Math.round(value * 1000) / 1000);\n}\n\n/** This function tells if a value is a number that is not finite, or if it holds such a number. */\nfunction holdsBadNumber(value: unknown): boolean {\n if (typeof value === \"number\") return !Number.isFinite(value);\n if (Array.isArray(value)) return value.some((item) => holdsBadNumber(item));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsBadNumber(item));\n return false;\n}\n\n/** This function tells if a value is a finite number with a size above a limit, or if it holds such a number. */\nfunction holdsLargeNumber(value: unknown, limit: number): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && Math.abs(value) > limit;\n if (Array.isArray(value)) return value.some((item) => holdsLargeNumber(item, limit));\n if (typeof value === \"object\" && value !== null) return Object.values(value).some((item) => holdsLargeNumber(item, limit));\n return false;\n}\n\n/** This function gives each value that a list has two or more times. */\nfunction repeated(ids: readonly string[]): readonly string[] {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) twice.add(id);\n seen.add(id);\n }\n return [...twice];\n}\n\n/**\n * This function gives each fault of a room record. A room with no finding of the level `error` gives a full model.\n *\n * The function examines the meaning of the record: for example, an opening must be in its wall. The schema examines the form of the record.\n */\nexport function checkRoom(room: Room, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const scale = metersPer(room.unit);\n /** The largest length of the model, in the unit of the room. */\n const largest = LARGEST_LENGTH / scale;\n /** This function tells if a size of the record is 0 for the checks. */\n const none = (size: number): boolean => !(size * scale > SMALL);\n const openings = room.openings ?? [];\n const outlets = room.outlets ?? [];\n const circuits = room.circuits ?? [];\n const floors = room.floors ?? [];\n\n if (holdsBadNumber([room.height, room.wallThickness])) error(\"number-not-finite\", \"room\", \"\", \"The height or the wall thickness of the room is not a finite number.\");\n if (holdsLargeNumber([room.height, room.wallThickness], largest)) error(\"number-too-large\", \"room\", \"\", `The height or the wall thickness of the room is above 1 000 km, the largest length of the model.`);\n const lists: readonly (readonly [RecordKind, readonly { readonly id: string }[]])[] = [\n [\"wall\", room.walls],\n [\"opening\", openings],\n [\"floor\", floors],\n [\"outlet\", outlets],\n [\"circuit\", circuits],\n ];\n for (const [record, list] of lists) {\n for (const item of list) {\n if (holdsBadNumber(item)) error(\"number-not-finite\", record, item.id, `A number of the ${record} \"${item.id}\" is not finite.`);\n // The limit of a circuit is a power, not a length.\n if (record !== \"circuit\" && holdsLargeNumber(item, largest)) error(\"number-too-large\", record, item.id, `A length of the ${record} \"${item.id}\" is above 1 000 km, the largest length of the model.`);\n }\n for (const id of repeated(list.map((item) => item.id))) error(\"id-duplicate\", record, id, `Two or more records of the kind ${record} have the id \"${id}\".`);\n }\n\n if (none(room.height)) error(\"size-not-positive\", \"room\", \"\", `The height of the room is ${show(room.height)}. It must be above 0.`);\n if (none(room.wallThickness)) error(\"size-not-positive\", \"room\", \"\", `The wall thickness of the room is ${show(room.wallThickness)}. It must be above 0.`);\n\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n frames.forEach((frame, index) => {\n const wall = room.walls[index]!;\n if (wall.thickness !== undefined && none(wall.thickness)) error(\"size-not-positive\", \"wall\", wall.id, `The thickness of the wall \"${wall.id}\" is ${show(wall.thickness)}. It must be above 0.`);\n if (wall.height !== undefined && none(wall.height)) error(\"size-not-positive\", \"wall\", wall.id, `The height of the wall \"${wall.id}\" is ${show(wall.height)}. It must be above 0.`);\n const [clearFrom, clearTo] = footprints[index]!.clear;\n if (!(frame.length > SMALL)) error(\"wall-length\", \"wall\", wall.id, `The wall \"${wall.id}\" has the length 0: its two ends are one point.`);\n else if (wallHasOutline(frame) && !(clearTo - clearFrom > SMALL)) warning(\"wall-short\", \"wall\", wall.id, `The wall \"${wall.id}\" is too short for the corners at its ends: no part of it has its full thickness.`);\n });\n for (let i = 0; i < footprints.length; i++) {\n for (let j = i + 1; j < footprints.length; j++) {\n const a = footprints[i]!;\n const b = footprints[j]!;\n if (a.ring.length < 3 || b.ring.length < 3 || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"wall-overlap\", \"wall\", a.wall, `The walls \"${a.wall}\" and \"${b.wall}\" overlap. Walls connect only at their ends: divide a wall at the point where a different wall crosses it.`);\n }\n }\n\n const frameOf = new Map(frames.map((frame, index) => [frame.id, { frame, footprint: footprints[index]! }] as const));\n const holes = new Map<string, { id: string; from: number; to: number; sill: number; top: number }[]>();\n for (const opening of openings) {\n const found = frameOf.get(opening.wall);\n if (found === undefined) {\n error(\"opening-wall\", \"opening\", opening.id, `The opening \"${opening.id}\" is on the wall \"${opening.wall}\", which the room does not have.`);\n continue;\n }\n if (none(opening.width)) error(\"size-not-positive\", \"opening\", opening.id, `The width of the opening \"${opening.id}\" is ${show(opening.width)}. It must be above 0.`);\n if (none(opening.height)) error(\"size-not-positive\", \"opening\", opening.id, `The height of the opening \"${opening.id}\" is ${show(opening.height)}. It must be above 0.`);\n if (none(opening.width) || none(opening.height)) continue;\n const from = opening.offset * scale;\n const to = (opening.offset + opening.width) * scale;\n const sill = (opening.sill ?? 0) * scale;\n const top = sill + opening.height * scale;\n const [clearFrom, clearTo] = found.footprint.clear;\n if (from < clearFrom - SMALL || to > clearTo + SMALL) {\n error(\n \"opening-range\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from ${show(opening.offset)} to ${show(opening.offset + opening.width)} along the wall \"${opening.wall}\". The straight part of that wall is from ${show(clearFrom / scale)} to ${show(clearTo / scale)}.`,\n );\n }\n if (sill < 0 || top > found.frame.height + SMALL) {\n error(\n \"opening-height\",\n \"opening\",\n opening.id,\n `The opening \"${opening.id}\" is from the height ${show(sill / scale)} to ${show(top / scale)}. The wall \"${opening.wall}\" is from 0 to ${show(found.frame.height / scale)}.`,\n );\n }\n const list = holes.get(opening.wall) ?? [];\n list.push({ id: opening.id, from, to, sill, top });\n holes.set(opening.wall, list);\n }\n for (const [wall, list] of holes) {\n list.sort((a, b) => a.from - b.from);\n for (let i = 1; i < list.length; i++) {\n const before = list[i - 1]!;\n const hole = list[i]!;\n if (hole.from < before.to - SMALL) error(\"opening-overlap\", \"opening\", hole.id, `The openings \"${before.id}\" and \"${hole.id}\" of the wall \"${wall}\" overlap.`, before.id);\n }\n }\n\n const circuitIds = new Set(circuits.map((circuit) => circuit.id));\n for (const outlet of outlets) {\n if (outlet.circuit !== undefined && !circuitIds.has(outlet.circuit)) error(\"outlet-circuit\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the circuit \"${outlet.circuit}\", which the room does not have.`);\n const found = frameOf.get(outlet.wall);\n if (found === undefined) {\n error(\"outlet-wall\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is on the wall \"${outlet.wall}\", which the room does not have.`);\n continue;\n }\n const along = outlet.offset * scale;\n const height = outlet.height * scale;\n if (!(along >= 0 && along <= found.frame.length + SMALL && height >= 0 && height <= found.frame.height + SMALL)) {\n error(\n \"outlet-range\",\n \"outlet\",\n outlet.id,\n `The outlet \"${outlet.id}\" is at ${show(outlet.offset)} along the wall \"${outlet.wall}\" and at the height ${show(outlet.height)}. The wall has the length ${show(found.frame.length / scale)} and the height ${show(found.frame.height / scale)}.`,\n );\n continue;\n }\n const hole = (holes.get(outlet.wall) ?? []).find((item) => along > item.from && along < item.to && height > item.sill && height < item.top);\n if (hole !== undefined) warning(\"outlet-in-opening\", \"outlet\", outlet.id, `The outlet \"${outlet.id}\" is in the opening \"${hole.id}\" of the wall \"${outlet.wall}\".`, hole.id);\n }\n\n for (const floor of floors) {\n if (floor.ring.length < 3 || !(regionArea({ kind: \"polygon\", points: floor.ring }) * scale * scale > SMALL * SMALL)) {\n error(\"floor-ring\", \"floor\", floor.id, `The floor \"${floor.id}\" has no area. Its ring must have 3 or more corners that are not on one line.`);\n }\n }\n for (const circuit of circuits) {\n if (!(circuit.limit > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The limit of the circuit \"${circuit.id}\" is ${show(circuit.limit)} W. It must be above 0.`);\n if (circuit.breaker !== undefined && !(circuit.breaker > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The breaker of the circuit \"${circuit.id}\" is ${show(circuit.breaker)} A. It must be above 0.`);\n if (circuit.voltage !== undefined && !(circuit.voltage > 0)) error(\"circuit-limit\", \"circuit\", circuit.id, `The voltage of the circuit \"${circuit.id}\" is ${show(circuit.voltage)} V. It must be above 0.`);\n }\n return findings;\n}\n\n/** The outline in the plan and the range of heights of a placed object, in meters. */\ninterface Extent {\n readonly object: PlacedObject;\n readonly ring: Ring;\n readonly z: number;\n readonly top: number;\n}\n\n/** This function gives the extent of a placed object from its transform. The turn of each object is about the vertical axis, so the outline is a rectangle. */\nfunction extentOf(object: PlacedObject, transform: Transform3, scale: number): Extent {\n const w = (object.size[0] * scale) / 2;\n const h = (object.size[1] * scale) / 2;\n const corners: readonly (readonly [number, number])[] = [\n [0 - w, 0 - h],\n [w, 0 - h],\n [w, h],\n [0 - w, h],\n ];\n const ring = corners.map(([x, y]) => {\n const point = transformPoint3(transform, { x, y, z: 0 });\n return [point.x, point.y] as const;\n });\n return { object, ring, z: transform.position.z, top: transform.position.z + object.size[2] * scale };\n}\n\n/**\n * This function gives each fault of a scene record: the faults of its room, then the faults of its placed objects and its loads.\n * A scene with no finding of the level `error` gives a full model.\n */\nexport function checkScene(scene: Scene, options: CheckOptions = {}): readonly Finding[] {\n const findings: Finding[] = [...checkRoom(scene.room, options)];\n const error = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"error\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const warning = (code: FindingCode, record: RecordKind, at: string, message: string, other?: string): void => {\n findings.push({ level: \"warning\", code, record, at, message, ...(other === undefined ? {} : { other }) });\n };\n const room = scene.room;\n const scale = metersPer(room.unit);\n const objects = scene.objects ?? [];\n const byId = new Map(objects.map((object) => [object.id, object] as const));\n const outletIds = new Set((room.outlets ?? []).map((outlet) => outlet.id));\n const circuitIds = new Set((room.circuits ?? []).map((circuit) => circuit.id));\n /** This function tells if each size of an object is above 0 for the checks. */\n const hasSize = (object: PlacedObject): boolean => object.size.every((size) => size * scale > SMALL);\n\n for (const id of repeated(objects.map((object) => object.id))) error(\"id-duplicate\", \"object\", id, `Two or more records of the kind object have the id \"${id}\".`);\n\n /** The objects that hold an object, from its parent up. A loop of parents gives `undefined`. */\n const holders = (object: PlacedObject): ReadonlySet<string> | undefined => {\n const seen = new Set<string>([object.id]);\n const above = new Set<string>();\n let parent = object.parent === undefined ? undefined : byId.get(object.parent);\n while (parent !== undefined) {\n if (seen.has(parent.id)) return undefined;\n seen.add(parent.id);\n above.add(parent.id);\n parent = parent.parent === undefined ? undefined : byId.get(parent.parent);\n }\n return above;\n };\n\n for (const object of objects) {\n if (holdsBadNumber(object)) error(\"number-not-finite\", \"object\", object.id, `A number of the object \"${object.id}\" is not finite.`);\n // The turn of an object is an angle, so it has no such limit.\n if (holdsLargeNumber([object.size, object.at, object.lift], LARGEST_LENGTH / scale)) error(\"number-too-large\", \"object\", object.id, `A length of the object \"${object.id}\" is above 1 000 km, the largest length of the model.`);\n if (!hasSize(object)) error(\"size-not-positive\", \"object\", object.id, `The size of the object \"${object.id}\" is ${object.size.map(show).join(\" by \")}. Each number must be above 0.`);\n if (object.parent !== undefined && !byId.has(object.parent)) error(\"object-parent\", \"object\", object.id, `The object \"${object.id}\" is on the object \"${object.parent}\", which the scene does not have.`, object.parent);\n else if (holders(object) === undefined) error(\"object-cycle\", \"object\", object.id, `The parents of the object \"${object.id}\" make a loop.`);\n if (object.outlet !== undefined && !outletIds.has(object.outlet)) error(\"object-outlet\", \"object\", object.id, `The object \"${object.id}\" uses the outlet \"${object.outlet}\", which the room does not have.`, object.outlet);\n }\n\n const transforms = objectTransforms(scene);\n const extents: Extent[] = [];\n for (const object of objects) {\n const transform = transforms.get(object.id);\n if (transform !== undefined && hasSize(object)) extents.push(extentOf(object, transform, scale));\n }\n\n const floors = (room.floors ?? []).filter((floor) => floor.ring.length >= 3).map((floor) => floor.ring.map(([x, y]) => [x * scale, y * scale] as const));\n const frames = wallFrames(room);\n const footprints = wallFootprints(frames, options.joins);\n for (const extent of extents) {\n const { object } = extent;\n const transform = transforms.get(object.id)!;\n if (object.parent === undefined && floors.length > 0 && !floors.some((ring) => pointInRing(transform.position.x, transform.position.y, ring))) {\n warning(\"object-outside\", \"object\", object.id, `The center of the object \"${object.id}\" is not on a floor of the room.`);\n }\n footprints.forEach((footprint, index) => {\n if (footprint.ring.length < 3 || !(extent.z < frames[index]!.height - SMALL) || !(convexOverlap(footprint.ring, extent.ring) > SMALL)) return;\n warning(\"object-in-wall\", \"object\", object.id, `The object \"${object.id}\" overlaps the wall \"${footprint.wall}\".`, footprint.wall);\n });\n }\n for (let i = 0; i < extents.length; i++) {\n for (let j = i + 1; j < extents.length; j++) {\n const a = extents[i]!;\n const b = extents[j]!;\n if (holders(a.object)?.has(b.object.id) === true || holders(b.object)?.has(a.object.id) === true) continue;\n if (!(Math.min(a.top, b.top) - Math.max(a.z, b.z) > SMALL) || !(convexOverlap(a.ring, b.ring) > SMALL)) continue;\n warning(\"object-overlap\", \"object\", a.object.id, `The objects \"${a.object.id}\" and \"${b.object.id}\" overlap.`, b.object.id);\n }\n }\n\n for (const load of scene.loads ?? []) {\n if (!circuitIds.has(load.circuit)) error(\"load-circuit\", \"load\", load.circuit, `A load is on the circuit \"${load.circuit}\", which the room does not have.`);\n if (!(load.watts >= 0 && Number.isFinite(load.watts))) error(\"load-watts\", \"load\", load.circuit, `A load of the circuit \"${load.circuit}\" is ${show(load.watts)} W. It must be a finite number, 0 or more.`);\n }\n return findings;\n}\n\n/** These are the codes of the faults of an anchor. */\nexport const ANCHOR_CODES: readonly [\n \"anchor-not-finite\",\n \"anchor-wall\",\n \"anchor-object\",\n \"anchor-floor\",\n \"anchor-range\",\n \"anchor-direction\",\n \"anchor-in-opening\",\n \"anchor-outside\",\n] = [\"anchor-not-finite\", \"anchor-wall\", \"anchor-object\", \"anchor-floor\", \"anchor-range\", \"anchor-direction\", \"anchor-in-opening\", \"anchor-outside\"];\n\n/** A code of a fault of an anchor. */\nexport type AnchorCode = (typeof ANCHOR_CODES)[number];\n\n/** A fault of an anchor. `checkLayers` gives it the layer and the key of the anchor. */\nexport interface AnchorFault {\n readonly level: FindingLevel;\n readonly code: AnchorCode;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault: the opening that the anchor is in. A different fault has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * This function gives the faults of an anchor in the space of a scene. `name` starts each message.\n * An error tells that the anchor has no position. A warning tells a fault that the model can show.\n */\nexport function checkAnchor(anchor: Anchor, space: SceneSpace, name: string = \"The anchor\"): readonly AnchorFault[] {\n const error = (code: AnchorCode, message: string): readonly AnchorFault[] => [{ level: \"error\", code, message: `${name} ${message}` }];\n const { scene, scale } = space;\n if (holdsBadNumber(anchor)) return error(\"anchor-not-finite\", \"has a number that is not finite.\");\n if (anchor.on === \"wall\") {\n const wall = space.wall(anchor.wall);\n if (wall === undefined) return error(\"anchor-wall\", `is on the wall \"${anchor.wall}\", which the room does not have.`);\n const along = anchor.offset * scale;\n const height = anchor.height * scale;\n if (!(along >= 0 && along <= wall.length + SMALL && height >= 0 && height <= wall.height + SMALL)) {\n return error(\n \"anchor-range\",\n `is at ${show(anchor.offset)} along the wall \"${anchor.wall}\" and at the height ${show(anchor.height)}. The wall has the length ${show(wall.length / scale)} and the height ${show(wall.height / scale)}.`,\n );\n }\n const hole = (scene.room.openings ?? []).find((opening) => {\n const sill = (opening.sill ?? 0) * scale;\n return opening.wall === anchor.wall && along > opening.offset * scale && along < (opening.offset + opening.width) * scale && height > sill && height < sill + opening.height * scale;\n });\n return hole === undefined ? [] : [{ level: \"warning\", code: \"anchor-in-opening\", message: `${name} is in the opening \"${hole.id}\" of the wall \"${anchor.wall}\".`, other: hole.id }];\n }\n if (anchor.on === \"object\") {\n const object = space.object(anchor.object);\n if (object === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which the scene does not have.`);\n // An object with no place has a fault of its own, which `checkScene` tells. Here, the anchor tells that it has no position.\n if (space.transform(anchor.object) === undefined) return error(\"anchor-object\", `is on the object \"${anchor.object}\", which has no place in the room.`);\n const small = SMALL / scale;\n if (anchor.at !== undefined) {\n const [x, y, z] = anchor.at;\n const [width, depth, height] = object.size;\n if (!(Math.abs(x) <= width / 2 + small && Math.abs(y) <= depth / 2 + small && z >= -small && z <= height + small)) {\n return error(\"anchor-range\", `is at (${anchor.at.map(show).join(\", \")}) in the frame of the object \"${anchor.object}\". The object has the size ${object.size.map(show).join(\" by \")}.`);\n }\n }\n if (anchor.out !== undefined) {\n const [x, y, z] = anchor.out;\n if (!(length3({ x, y, z }) > 0)) return error(\"anchor-direction\", \"has a direction with the length 0. A direction must have a length above 0.\");\n }\n return [];\n }\n const [x, y] = anchor.at;\n if (!lengthsInRange(x * scale, y * scale)) return error(\"anchor-range\", \"is at a point above 1 000 km, the largest length of the model.\");\n const word = anchor.on === \"floor\" ? \"on\" : \"above\";\n const floors = scene.room.floors ?? [];\n if (anchor.floor !== undefined) {\n const floor = floors.find((item) => item.id === anchor.floor);\n if (floor === undefined) return error(\"anchor-floor\", `is ${word} the floor \"${anchor.floor}\", which the room does not have.`);\n return pointInRing(x, y, floor.ring) ? [] : [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} the floor \"${anchor.floor}\".` }];\n }\n if (floors.length === 0 || floors.some((floor) => pointInRing(x, y, floor.ring))) return [];\n return [{ level: \"warning\", code: \"anchor-outside\", message: `${name} is not ${word} a floor of the room.` }];\n}\n","import { length3, rotatePoint3, scalePoint3, transformPoint3, type Point3, type Transform3 } from \"@mark1russell7/layout-contract\";\nimport { wallFrames, wallPoint, type WallFrame } from \"./frames.ts\";\nimport type { PlacedObject, PlanPoint, Scene, WallFace } from \"./room.ts\";\nimport { objectTransforms } from \"./solids.ts\";\nimport { lengthsInRange, metersPer } from \"./units.ts\";\n\n// The anchors of the core: the places where an add-on puts its records. The core gives each anchor its position.\n// An anchor names no topic. An outlet, a tap and a lamp are records of add-ons, and each one is on an anchor.\n\n/** These are the surfaces that an anchor can be on. */\nexport const ANCHOR_SURFACES: readonly [\"wall\", \"floor\", \"ceiling\", \"object\"] = [\"wall\", \"floor\", \"ceiling\", \"object\"];\n\n/** A surface of an anchor. */\nexport type AnchorSurface = (typeof ANCHOR_SURFACES)[number];\n\n/** An anchor on a face of a wall. The lengths are in the unit of the room. */\nexport interface WallAnchor {\n readonly on: \"wall\";\n /** The `id` of the wall. */\n readonly wall: string;\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the anchor. */\n readonly offset: number;\n /** The height of the anchor above the floor. */\n readonly height: number;\n}\n\n/** An anchor on the floor, at a point of the plan. */\nexport interface FloorAnchor {\n readonly on: \"floor\";\n readonly at: PlanPoint;\n /** The `id` of the floor that has the point. Without it, the point is on any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/** An anchor on the ceiling, above a point of the plan. The ceiling is at the height of the room. */\nexport interface CeilingAnchor {\n readonly on: \"ceiling\";\n readonly at: PlanPoint;\n /** The `id` of the floor below the point. Without it, the point is above any floor of the room. */\n readonly floor?: string | undefined;\n}\n\n/**\n * An anchor on a placed object. The point and the direction are in the frame of the object, before its turn.\n * The origin of that frame is the center of the bottom of the object.\n */\nexport interface ObjectAnchor {\n readonly on: \"object\";\n /** The `id` of the placed object. */\n readonly object: string;\n /** The point in the frame of the object. The default is the center of its top. */\n readonly at?: readonly [number, number, number] | undefined;\n /** The direction out of the surface, in the frame of the object. The default is up: `[0, 0, 1]`. */\n readonly out?: readonly [number, number, number] | undefined;\n}\n\n/** An anchor: a place in the space of the core, for a record of an add-on. */\nexport type Anchor = WallAnchor | FloorAnchor | CeilingAnchor | ObjectAnchor;\n\n/** The position of an anchor in the room, in meters. */\nexport interface AnchorFrame {\n /** The point of the anchor. */\n readonly at: Point3;\n /** The unit vector out of the surface, into the space of the room. */\n readonly out: Point3;\n}\n\n/**\n * The space of a scene, for the add-ons. It reads each wall, object and anchor of the scene.\n * Make it once with `sceneSpace`, and give it to each add-on.\n */\nexport interface SceneSpace {\n readonly scene: Scene;\n /** The length of the unit of the room, in meters. */\n readonly scale: number;\n /** This function gives the frame of a wall in meters, or `undefined` when the room does not have the wall. */\n readonly wall: (id: string) => WallFrame | undefined;\n /** This function gives a placed object of the scene, or `undefined` when the scene does not have it. */\n readonly object: (id: string) => PlacedObject | undefined;\n /** This function gives the transform of a placed object in meters, or `undefined` when the object has no place. */\n readonly transform: (id: string) => Transform3 | undefined;\n /** This function gives the position of an anchor, or `undefined` when the anchor has no position. `checkAnchor` tells the reason. */\n readonly frame: (anchor: Anchor) => AnchorFrame | undefined;\n}\n\nconst UP: Point3 = { x: 0, y: 0, z: 1 };\nconst DOWN: Point3 = { x: 0, y: 0, z: -1 };\n\n/** This function tells if each value of a point is a length in the range of the model. */\nfunction inRange(point: Point3): boolean {\n return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z) && lengthsInRange(point.x, point.y, point.z);\n}\n\n/** This function gives the space of a scene. The transforms of the objects are calculated one time, at the first use. */\nexport function sceneSpace(scene: Scene): SceneSpace {\n const scale = metersPer(scene.room.unit);\n const walls = new Map(wallFrames(scene.room).map((frame) => [frame.id, frame] as const));\n const objects = new Map((scene.objects ?? []).map((object) => [object.id, object] as const));\n let transforms: ReadonlyMap<string, Transform3> | undefined;\n const transform = (id: string): Transform3 | undefined => {\n transforms ??= objectTransforms(scene);\n return transforms.get(id);\n };\n const frame = (anchor: Anchor): AnchorFrame | undefined => {\n let found: AnchorFrame | undefined;\n if (anchor.on === \"wall\") {\n const wall = walls.get(anchor.wall);\n if (wall === undefined) return undefined;\n const point = wallPoint(wall, anchor.offset * scale, anchor.face === \"left\" ? wall.leftOffset : wall.rightOffset);\n const sign = anchor.face === \"left\" ? 1 : -1;\n found = { at: { x: point.x, y: point.y, z: anchor.height * scale }, out: { x: wall.left.x * sign, y: wall.left.y * sign, z: 0 } };\n } else if (anchor.on === \"floor\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: 0 }, out: UP };\n } else if (anchor.on === \"ceiling\") {\n found = { at: { x: anchor.at[0] * scale, y: anchor.at[1] * scale, z: scene.room.height * scale }, out: DOWN };\n } else {\n const object = objects.get(anchor.object);\n const place = transform(anchor.object);\n if (object === undefined || place === undefined) return undefined;\n const [x, y, z] = anchor.at ?? [0, 0, object.size[2]];\n const [ox, oy, oz] = anchor.out ?? [0, 0, 1];\n const out = { x: ox, y: oy, z: oz };\n const size = length3(out);\n if (!(size > 0) || !Number.isFinite(size)) return undefined;\n found = { at: transformPoint3(place, { x: x * scale, y: y * scale, z: z * scale }), out: rotatePoint3(place.rotation, scalePoint3(out, 1 / size)) };\n }\n return inRange(found.at) && inRange(found.out) ? found : undefined;\n };\n return { scene, scale, wall: (id) => walls.get(id), object: (id) => objects.get(id), transform, frame };\n}\n","import { sceneSpace, type Anchor, type SceneSpace } from \"./anchors.ts\";\nimport { checkAnchor, type FindingLevel } from \"./check.ts\";\nimport { isLayerName, type Scene } from \"./room.ts\";\n\n// The layers of a scene: the records of the add-ons. The core keeps each layer, and it does not read one.\n// An add-on reads its layer, gives the anchors of its records, and examines the meaning of its records.\n// The core examines the anchors. Thus each add-on composes on the core, and the add-ons do not know each other.\n\n/** The result of the read of a layer: the layer, or the faults of its form. */\nexport type LayerParse<Layer> = { readonly ok: true; readonly layer: Layer } | { readonly ok: false; readonly errors: readonly string[] };\n\n/** A fault that an add-on finds in its layer. */\nexport interface AddOnFault {\n readonly level: FindingLevel;\n /** The code of the fault. The add-on gives its own codes. */\n readonly code: string;\n /** The `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/**\n * An add-on: one topic on the core, for example electrical, plumbing or light.\n * A host gives a list of add-ons to `checkLayers`. The core knows only this type.\n */\nexport interface AddOn<Layer> {\n /** The name of the format of the layer, for example `electrical/1`. It is the key of the layer in `Scene.layers`. */\n readonly schema: string;\n /** This function reads the JSON of a layer. */\n parse(value: unknown): LayerParse<Layer>;\n /**\n * This function gives the anchors of the records of a layer, by a key.\n * The key is the `id` of a record, or the `id` and a position for a record with many anchors.\n */\n anchors(layer: Layer): ReadonlyMap<string, Anchor>;\n /** This function gives the layer with new anchors, by the keys of `anchors`. The core uses it when it moves the records of a room. */\n withAnchors(layer: Layer, anchors: ReadonlyMap<string, Anchor>): Layer;\n /** This function gives the faults of the meaning of a layer. The core examines the anchors, so this function does not. */\n check(layer: Layer, space: SceneSpace): readonly AddOnFault[];\n}\n\n/** These are the codes of the faults of a layer that the core finds. */\nexport const LAYER_CODES: readonly [\"layer-name\", \"layer-unknown\", \"layer-form\"] = [\"layer-name\", \"layer-unknown\", \"layer-form\"];\n\n/** A finding of a layer: a fault of its form, of an anchor or of the meaning of its records. */\nexport interface LayerFinding {\n readonly level: FindingLevel;\n /** A code of `LAYER_CODES` or `ANCHOR_CODES`, or a code of the add-on. */\n readonly code: string;\n /** The key of the layer in `Scene.layers`. */\n readonly layer: string;\n /** The key of the anchor, or the `id` of the record with the fault. For the layer, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n /** The `id` of the second record of the fault. A fault of one record has none. */\n readonly other?: string | undefined;\n}\n\n/** This function compares two texts by their code points, so the order does not change with the language of a computer. */\nfunction compareText(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** This function gives the add-on of each schema name. The first add-on of a name is used. */\nfunction addOnsByName(addOns: readonly AddOn<unknown>[]): ReadonlyMap<string, AddOn<unknown>> {\n const byName = new Map<string, AddOn<unknown>>();\n for (const addOn of addOns) if (!byName.has(addOn.schema)) byName.set(addOn.schema, addOn);\n return byName;\n}\n\n/** This function reads the layer of an add-on in a scene. It gives `undefined` when the scene has no layer of the add-on. */\nexport function readLayer<Layer>(scene: Scene, addOn: AddOn<Layer>): LayerParse<Layer> | undefined {\n const layers = scene.layers ?? {};\n return Object.hasOwn(layers, addOn.schema) ? addOn.parse(layers[addOn.schema]) : undefined;\n}\n\n/**\n * This function gives the findings of the layers of a scene, with a list of add-ons.\n * Each layer gets the faults of its form, of each anchor and of the meaning of its records. A layer of no add-on of the list gets a warning.\n * The findings are in the order of the layer keys, then of the record keys. Thus equal inputs give equal findings.\n *\n * The name of the record of a finding is `recordName(finding.layer, finding.at)`, so a finding selects its mark.\n * `checkScene` examines the core, and this function examines the layers.\n */\nexport function checkLayers(scene: Scene, addOns: readonly AddOn<unknown>[]): readonly LayerFinding[] {\n const byName = addOnsByName(addOns);\n const layers = scene.layers ?? {};\n const findings: LayerFinding[] = [];\n let space: SceneSpace | undefined;\n for (const name of Object.keys(layers).sort(compareText)) {\n if (!isLayerName(name)) {\n findings.push({ level: \"error\", code: \"layer-name\", layer: name, at: \"\", message: `The layer \"${name}\" has a name that is not a word, a slash and a version, for example \"electrical/1\".` });\n continue;\n }\n const addOn = byName.get(name);\n if (addOn === undefined) {\n findings.push({ level: \"warning\", code: \"layer-unknown\", layer: name, at: \"\", message: `The scene has the layer \"${name}\", and no add-on of the check reads it. The scene keeps the layer.` });\n continue;\n }\n const read = addOn.parse(layers[name]);\n if (!read.ok) {\n for (const message of read.errors) findings.push({ level: \"error\", code: \"layer-form\", layer: name, at: \"\", message });\n continue;\n }\n space ??= sceneSpace(scene);\n const own: LayerFinding[] = [];\n for (const [key, anchor] of addOn.anchors(read.layer)) {\n for (const fault of checkAnchor(anchor, space, `The anchor \"${key}\" of the layer \"${name}\"`)) own.push({ ...fault, layer: name, at: key });\n }\n for (const fault of addOn.check(read.layer, space)) own.push({ ...fault, layer: name });\n // The sort is stable, so the faults of one record keep their order.\n own.sort((a, b) => compareText(a.at, b.at));\n findings.push(...own);\n }\n return findings;\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,UAAU,OAAyB;CACjD,MAAM,EAAE,IAAI,MAAM,QAAQ,UAAU;CACpC,IAAI,MAAM,SA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AAY,QAAQ,OAAO,eAAe,IAAI,kBAAkB,KAAK,EAAE,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;GAAM,IAAI;EAAI,CAAC;EAE3I,KAAK,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,IAAI,KAAK;GAAE,GAAG;GAAO,OAAO;EAAK,CAAC;EAEtF,IAAI,MAAM,GAAG,MAAM,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC;EAC1C,SAAS,KAAK,GAAG,GAAG;CACtB;CACA,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { S as LengthUnit, a as Opening, c as PlacedObject, d as Room, l as PlanPoint, s as Outlet, t as Circuit } from "./room-x9FxGjGi.js";
1
+ import { S as LengthUnit, a as Opening, c as PlacedObject, d as Room, l as PlanPoint, s as Outlet, t as Circuit } from "./room-NREa6vXr.js";
2
2
  /** The name of the format of a survey record. */
3
3
  declare const SURVEY_SCHEMA = "survey/1";
4
4
  /** These are the names of the turns at a square corner. */
@@ -341,4 +341,4 @@ declare const CONNECTION_TURN_LIMIT = 2;
341
341
  */
342
342
  declare function expandLevel(level: Level, options?: LevelOptions): LevelResult;
343
343
  export { SurveyTurn as A, SurveyCheckResult as C, SurveyOutlet as D, SurveyOptions as E, expandSurvey as M, SurveyResult as O, SurveyCheck as S, SurveyObject as T, expandLevel as _, ConnectionFault as a, SURVEY_SCHEMA as b, Level as c, LevelOptions as d, LevelResult as f, RoomPlace as g, ROOM_PLACES as h, ConnectionEnd as i, convertSurvey as j, SurveySide as k, LevelConnection as l, LevelRoomResult as m, CONNECTION_TURN_LIMIT as n, ConnectionUse as o, LevelRoom as p, CONNECTION_USES as r, LEVEL_SCHEMA as s, CONNECTION_FAULTS as t, LevelConnectionResult as u, CLOSURE_LIMIT as v, SurveyClosure as w, Survey as x, SQUARE_TURNS as y };
344
- //# sourceMappingURL=level-Cgja5fXb.d.ts.map
344
+ //# sourceMappingURL=level-Bmz-H5iH.d.ts.map
@@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;;KAGD,oBAAoB;;UAGf;;WAEN;WACA,OAAO;;WAEP;;WAEA,QAAQ;;WAER,QAAQ;;;;;;;;;cAUN;;KAGD,wBAAwB;;;;;;;;cASvB;;KAGD,0BAA0B;;UAGrB;;WAEN;WACA,KAAK;WACL,QAAQ;;;;;WAKR;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;;;;;WAMN,MAAM;;WAEN,gBAAgB;;WAEhB,sBAAsB;;;;;WAKtB,kBAAkB;;;UAIZ,qBAAqB;;WAE3B;;;cAIE;;;;;;;;;;;;;;;;;;;iBA4IG,YAAY,OAAO,OAAO,UAAS,eAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"level-Cu8vgrwN.js","names":[],"sources":["../src/room.ts","../src/direction.ts","../src/survey.ts","../src/level.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\nimport type { LengthUnit } from \"./units.ts\";\n\n/** A point of the plan: `[x, y]`. The plan is the view from above, and the z axis points up. */\nexport type PlanPoint = readonly [number, number];\n\n/** The name of the format of a room record. */\nexport const ROOM_SCHEMA = \"room/1\";\n\n/** The name of the format of a scene record. */\nexport const SCENE_SCHEMA = \"scene/1\";\n\n/**\n * This function tells if a text is the name of a layer: a word, a slash and a version, for example `electrical/1`.\n * The word has lowercase letters, digits and hyphens. Thus a layer name has no colon, and `recordName` gives each record one name.\n */\nexport function isLayerName(text: string): boolean {\n return /^[a-z][a-z0-9-]*\\/[0-9]+$/.test(text);\n}\n\n/** These are the sides of the line of a wall that can have the wall. */\nexport const WALL_SIDES: readonly [\"center\", \"left\", \"right\"] = [\"center\", \"left\", \"right\"];\n\n/**\n * The side of the line of a wall that has the wall, for a person who looks from `from` to `to`.\n * With `center`, the line is the middle of the wall. With `left` or `right`, the line is one face of the wall.\n */\nexport type WallSide = (typeof WALL_SIDES)[number];\n\n/** These are the faces of a wall, for a person who looks from `from` to `to`. */\nexport const WALL_FACES: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/** A face of a wall. */\nexport type WallFace = (typeof WALL_FACES)[number];\n\n/**\n * A wall: a straight line in the plan, with a thickness and a height.\n * A tape measure gives the faces of a wall, so `side` lets the line be a face. Two walls with a common end make a corner.\n */\nexport interface Wall {\n readonly id: string;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n /** The thickness of the wall. The default is `wallThickness` of the room. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the room. */\n readonly height?: number | undefined;\n /** The side of the line that has the wall. The default is `center`. */\n readonly side?: WallSide | undefined;\n}\n\n/** These are the kinds of an opening. A window has glass. A door and a gap are empty. */\nexport const OPENING_KINDS: readonly [\"door\", \"window\", \"gap\"] = [\"door\", \"window\", \"gap\"];\n\n/** A kind of opening. */\nexport type OpeningKind = (typeof OPENING_KINDS)[number];\n\n/** An opening: a hole through a wall. */\nexport interface Opening {\n readonly id: string;\n /** The `id` of the wall. */\n readonly wall: string;\n readonly kind: OpeningKind;\n /** The distance along the line of the wall, from `from` to the near edge of the opening. */\n readonly offset: number;\n readonly width: number;\n /** The height of the bottom of the opening above the floor. The default is 0. */\n readonly sill?: number | undefined;\n readonly height: number;\n}\n\n/** A floor: one area of the plan, for example one room of an apartment. The ring is the line where the floor touches the walls. */\nexport interface Floor {\n readonly id: string;\n readonly name?: string | undefined;\n readonly ring: Ring;\n}\n\n/** An outlet: a point on a face of a wall. */\nexport interface Outlet {\n readonly id: string;\n /** The `id` of the wall. */\n readonly wall: string;\n /** The face of the wall that has the outlet. */\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the center of the outlet. */\n readonly offset: number;\n /** The height of the center of the outlet above the floor. */\n readonly height: number;\n /** The `id` of the circuit of the outlet. */\n readonly circuit?: string | undefined;\n}\n\n/** A circuit: it gives power to outlets, and it has a limit. */\nexport interface Circuit {\n readonly id: string;\n readonly name?: string | undefined;\n /**\n * The largest continuous load, in watts.\n * For example, a breaker of 15 A at 120 V carries 1800 W, and 80% of that for a continuous load is 1440 W.\n */\n readonly limit: number;\n}\n\n/** A room: the walls, the openings, the floors, the outlets and the circuits of one room or one apartment. */\nexport interface Room {\n readonly schema: typeof ROOM_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n readonly walls: readonly Wall[];\n readonly openings?: readonly Opening[] | undefined;\n readonly floors?: readonly Floor[] | undefined;\n readonly outlets?: readonly Outlet[] | undefined;\n readonly circuits?: readonly Circuit[] | undefined;\n}\n\n/**\n * A placed object: a box in the room, for example a desk, a rack or a computer.\n * With a `parent`, the position and the turn are relative to that object, whose origin is the center of its bottom.\n */\nexport interface PlacedObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The size before the turn: along x, along y, and the height. */\n readonly size: readonly [number, number, number];\n /** The point of the plan below the center of the object. */\n readonly at: PlanPoint;\n /** The height of the bottom of the object above the floor, or above the bottom of its parent. The default is 0. */\n readonly lift?: number | undefined;\n /** The turn about the vertical axis in degrees, counter-clockwise from above. The default is 0. */\n readonly turn?: number | undefined;\n /** The `id` of the object that holds this object. */\n readonly parent?: string | undefined;\n /** The `id` of the outlet that gives power to the object. */\n readonly outlet?: string | undefined;\n}\n\n/** A load on a circuit, in watts. A circuit can have many loads: their sum is the load of the circuit. */\nexport interface CircuitLoad {\n /** The `id` of the circuit. */\n readonly circuit: string;\n readonly watts: number;\n}\n\n/** A scene: one room with its placed objects and the loads of its circuits. Two scenes of one room can be compared. */\nexport interface Scene {\n readonly schema: typeof SCENE_SCHEMA;\n readonly name?: string | undefined;\n readonly room: Room;\n readonly objects?: readonly PlacedObject[] | undefined;\n readonly loads?: readonly CircuitLoad[] | undefined;\n /**\n * The records of each add-on, by the name of its layer, for example `electrical/1`. `isLayerName` tells the form of a name.\n * The core keeps each layer and does not read it. `checkLayers` examines the layers with a list of add-ons.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n","import type { PlanPoint } from \"./room.ts\";\n\n/** The turn at a square corner, in degrees. */\nexport const SQUARE = 90;\n\n/** One full turn, in degrees. */\nexport const FULL = 360;\n\n/** An angle with an error below this value is exact for the model, in degrees. The value is larger than the error of a sum of numbers. */\nexport const TURN_NOISE = 1e-9;\n\n/** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */\nexport function directionOf(degrees: number): PlanPoint {\n const turn = ((degrees % FULL) + FULL) % FULL;\n if (turn === 0) return [1, 0];\n if (turn === SQUARE) return [0, 1];\n if (turn === 2 * SQUARE) return [-1, 0];\n if (turn === 3 * SQUARE) return [0, -1];\n const angle = (turn * Math.PI) / 180;\n return [Math.cos(angle), Math.sin(angle)];\n}\n\n/** This function turns a vector of the plan by an angle in degrees, counter-clockwise. A turn by 90, 180 or 270 degrees is exact. */\nexport function turned([x, y]: PlanPoint, degrees: number): PlanPoint {\n const [cos, sin] = directionOf(degrees);\n return [x * cos - y * sin, x * sin + y * cos];\n}\n\n/**\n * This function gives the direction of a vector in degrees, from 0 to 360, counter-clockwise from the x axis.\n * A direction near 0, 90, 180 or 270 degrees becomes that value, so a room with square corners keeps exact numbers.\n */\nexport function headingOf([x, y]: PlanPoint): number {\n return squared((Math.atan2(y, x) * 180) / Math.PI);\n}\n\n/** This function gives an angle in degrees from 0 to 360. An angle near 0, 90, 180 or 270 degrees becomes that value. */\nexport function squared(degrees: number): number {\n const turn = ((degrees % FULL) + FULL) % FULL;\n const near = Math.round(turn / SQUARE) * SQUARE;\n return Math.abs(turn - near) < TURN_NOISE ? near % FULL : turn;\n}\n","import { directionOf, FULL, headingOf, SQUARE, TURN_NOISE } from \"./direction.ts\";\nimport { ROOM_SCHEMA, type Circuit, type Opening, type Outlet, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a survey record. */\nexport const SURVEY_SCHEMA = \"survey/1\";\n\n/** These are the names of the turns at a square corner. */\nexport const SQUARE_TURNS: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/**\n * The turn of the person at the end of a side, to the direction of the next side.\n *\n * `left` and `right` are the turns at a square corner: 90 degrees. They are exact.\n * A number is a measured angle in degrees, from -360 to 360, and a turn to the left is positive.\n */\nexport type SurveyTurn = (typeof SQUARE_TURNS)[number] | number;\n\n/** One side of a survey: the inner face of one wall, from a corner to the next corner. */\nexport interface SurveySide {\n /** The `id` of the wall of the side. */\n readonly id: string;\n /** The length of the inner face, from corner to corner. */\n readonly length: number;\n /** The turn at the end of the side. */\n readonly turn: SurveyTurn;\n /** The thickness of the wall. The default is `wallThickness` of the survey. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the survey. */\n readonly height?: number | undefined;\n}\n\n/** A measured distance between two corners of a survey, for example a diagonal of the room. It examines the walk. */\nexport interface SurveyCheck {\n readonly id: string;\n /** The `id` of a side. The first corner is the corner at the start of that side. */\n readonly from: string;\n /** The `id` of a side. The second corner is the corner at the start of that side. */\n readonly to: string;\n /** The measured distance between the two corners. */\n readonly length: number;\n}\n\n/** An outlet of a survey. It is on the inner face of its wall, so it has no field `face`. */\nexport type SurveyOutlet = Omit<Outlet, \"face\">;\n\n/**\n * An object of a survey: a box that a person measures from a side, for example a desk, a shelf or a rack.\n *\n * The back of the object is parallel to the inner face of the side. The person measures along the face to the near edge of the object,\n * and out from the face to its back. The near edge is the edge that is nearest to the first corner of the side.\n * Thus the record has no coordinate.\n *\n * An object with `on` is on a different object or in it, for example a display on a desk or a computer in a rack.\n * Then the person measures from the near edge and from the back of that object, which is the holder.\n * An object has `wall` or `on`. When it has the two, `on` applies.\n */\nexport interface SurveyObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The `id` of the side. */\n readonly wall?: string | undefined;\n /** The `id` of the holder. The first object with the `id` applies. */\n readonly on?: string | undefined;\n /**\n * The distance along the inner face, from the first corner of the side to the near edge of the object.\n * With `on`, this is the distance from the near edge of the holder to the near edge of the object.\n */\n readonly offset: number;\n /** The size of the object along the wall. */\n readonly width: number;\n /** The size of the object out from the wall. */\n readonly depth: number;\n readonly height: number;\n /**\n * The distance from the inner face to the back of the object. With `on`, this is the distance from the back of the holder.\n * The default is 0: the object touches the wall, or its back is level with the back of the holder.\n */\n readonly gap?: number | undefined;\n /**\n * The height of the bottom of the object above the floor. The default is 0.\n * With `on`, this is the height above the bottom of the holder. Then the default is the height of the holder: the object is on its top.\n */\n readonly lift?: number | undefined;\n /** The `id` of the outlet that gives power to the object. */\n readonly outlet?: string | undefined;\n}\n\n/**\n * A survey: the measurements of one room by a person with a tape measure.\n *\n * The person goes around the room along the inner faces of the walls, in one direction.\n * Each side has the length of one face, and the turn at its end. The last turn gives the direction of the first side again.\n * An opening, an outlet and an object name their side in `wall`. Their `offset` starts at the first corner of that side.\n */\nexport interface Survey {\n readonly schema: typeof SURVEY_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n /** The sides, in the sequence of the walk. */\n readonly sides: readonly SurveySide[];\n /** The place of the first corner in the plan. The default is the origin. */\n readonly start?: PlanPoint | undefined;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. The default is 0. */\n readonly heading?: number | undefined;\n readonly checks?: readonly SurveyCheck[] | undefined;\n readonly openings?: readonly Opening[] | undefined;\n readonly outlets?: readonly SurveyOutlet[] | undefined;\n readonly circuits?: readonly Circuit[] | undefined;\n readonly objects?: readonly SurveyObject[] | undefined;\n}\n\n/** The closure of a survey: the difference between the end of the walk and its start. */\nexport interface SurveyClosure {\n /** The distance from the end of the last side to the first corner, in the unit of the survey. */\n readonly gap: number;\n /** The gap as a part of the length of the walk. A walk with no length has 0. */\n readonly ratio: number;\n /** The sum of the turns minus one full turn in the direction of the walk, in degrees. */\n readonly turn: number;\n /** This value is true when the walk has 3 sides or more, its turns make one full turn, and its gap is in the limit. */\n readonly closed: boolean;\n}\n\n/** The result of one check of a survey. */\nexport interface SurveyCheckResult {\n /** The `id` of the check. */\n readonly id: string;\n /** The measured distance, in the unit of the survey. */\n readonly measured: number;\n /** The distance between the two corners in the room record. A check with a side that the survey does not have gets `undefined`. */\n readonly model: number | undefined;\n /** The measured distance minus the distance in the room record. */\n readonly difference: number | undefined;\n}\n\n/** The result of the expansion of a survey. */\nexport interface SurveyResult {\n /** The room record of the survey. */\n readonly room: Room;\n /** The corner at the start of each side, as the room record has it. */\n readonly corners: readonly PlanPoint[];\n /** The points of the walk before the correction of the gap. The walk has one point more than the survey has sides. */\n readonly walk: readonly PlanPoint[];\n readonly closure: SurveyClosure;\n /** The result of each check, in the sequence of the checks. */\n readonly checks: readonly SurveyCheckResult[];\n /**\n * The placed object of each object of the survey that has a place, in the sequence of the survey.\n * A scene record with the room record and these objects gives the model of the room with its objects.\n */\n readonly objects: readonly PlacedObject[];\n}\n\n/** The default limit of the gap of a closed walk, as a part of the length of the walk. */\nexport const CLOSURE_LIMIT = 0.01;\n\n/** The options of the expansion of a survey. */\nexport interface SurveyOptions {\n /** The largest gap of a closed walk, as a part of the length of the walk. The default is `CLOSURE_LIMIT`. */\n readonly limit?: number | undefined;\n}\n\n/** This function tells if a turn is a measured angle: an angle from -360 degrees to 360 degrees. */\nfunction isMeasured(turn: SurveyTurn): turn is number {\n return typeof turn === \"number\" && Math.abs(turn) <= FULL;\n}\n\n/** This function gives a turn in degrees. A turn that is not a square turn or a measured angle is 0. */\nfunction degreesOf(turn: SurveyTurn): number {\n if (turn === \"left\") return SQUARE;\n if (turn === \"right\") return 0 - SQUARE;\n return isMeasured(turn) ? turn : 0;\n}\n\n/**\n * This function gives a survey in a different unit. Each length of the record changes, and each angle stays.\n * A survey that has the unit already is the result.\n */\nexport function convertSurvey(survey: Survey, unit: LengthUnit): Survey {\n if (survey.unit === unit) return survey;\n const factor = unitsPer(survey.unit, unit);\n const to = (value: number): number => value * factor;\n const start: PlanPoint | undefined = survey.start === undefined ? undefined : [to(survey.start[0]), to(survey.start[1])];\n return {\n ...survey,\n unit,\n height: to(survey.height),\n wallThickness: to(survey.wallThickness),\n sides: survey.sides.map((side) => ({\n ...side,\n length: to(side.length),\n ...(side.thickness === undefined ? {} : { thickness: to(side.thickness) }),\n ...(side.height === undefined ? {} : { height: to(side.height) }),\n })),\n ...(start === undefined ? {} : { start }),\n ...(survey.checks === undefined ? {} : { checks: survey.checks.map((check) => ({ ...check, length: to(check.length) })) }),\n ...(survey.openings === undefined\n ? {}\n : {\n openings: survey.openings.map((opening) => ({\n ...opening,\n offset: to(opening.offset),\n width: to(opening.width),\n ...(opening.sill === undefined ? {} : { sill: to(opening.sill) }),\n height: to(opening.height),\n })),\n }),\n ...(survey.outlets === undefined ? {} : { outlets: survey.outlets.map((outlet) => ({ ...outlet, offset: to(outlet.offset), height: to(outlet.height) })) }),\n ...(survey.objects === undefined\n ? {}\n : {\n objects: survey.objects.map((object) => ({\n ...object,\n offset: to(object.offset),\n width: to(object.width),\n depth: to(object.depth),\n height: to(object.height),\n ...(object.gap === undefined ? {} : { gap: to(object.gap) }),\n ...(object.lift === undefined ? {} : { lift: to(object.lift) }),\n })),\n }),\n };\n}\n\n/**\n * This function makes the room record of a survey.\n *\n * The walk starts at `start` in the direction `heading`. Each side adds its length, and then the person turns.\n * A length that is not a finite number above 0, or is not in the range of the model, counts as 0.\n * A turn that is not a number from -360 to 360 counts as 0. Thus each number of the result is finite.\n *\n * A measured length has an error, so the walk does not end exactly at its start. The function corrects the two errors of a walk:\n *\n * 1. When the sum of the turns has an error below 45 degrees, each measured turn gets an equal part of the error.\n * The turns `left` and `right` are exact, so they do not change. A larger error is a mistake, for example a wrong turn.\n * 2. When the walk is closed, the sides share the gap. Along each axis of the first side, each side changes in proportion to its length along that axis.\n * This is the transit rule of land survey. A side along an axis stays along that axis, so a room with square corners keeps them.\n * Then the last wall ends exactly at the first corner, and the room gets a floor.\n *\n * An opening and an outlet keep their place on a side that changes its length: each `offset` and each `width` changes in the same proportion.\n * Thus an opening that fits in its measured side fits in its wall, and two openings that do not overlap stay apart.\n *\n * An object keeps its size on a side that changes its length. It moves by a part of that change: its place in the free length of the side.\n * Thus an object that touches a corner continues to touch it. The x axis of a placed object goes along its wall,\n * and its y axis points into the room. An object with a holder has the holder as its parent, and its place is relative to the holder.\n *\n * Some objects have no place, and the result does not have them. A side that is not in the survey or has no length gives no place.\n * A holder with no place gives no place. A size that is not a finite number above 0 gives no place.\n * A distance that is not in the range of the model gives no place.\n *\n * A walk that is not closed gets no correction of the gap: its walls follow the walk, and the room has no floor.\n * Thus the record of a survey in progress shows the walls that the person measured.\n *\n * The wall of each side is on the outer side of its line. Thus each `offset` of the survey is a distance along the inner face.\n * `checkRoom` examines the room record.\n */\nexport function expandSurvey(survey: Survey, options: SurveyOptions = {}): SurveyResult {\n const scale = metersPer(survey.unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const sides = survey.sides;\n const count = sides.length;\n const lengths = sides.map((side) => (side.length > 0 && inRange(side.length) ? side.length : 0));\n const turns = sides.map((side) => degreesOf(side.turn));\n const total = lengths.reduce((sum, length) => sum + length, 0);\n\n const sum = turns.reduce((all, turn) => all + turn, 0);\n const toLeft = sum >= 0;\n const error = sum - (toLeft ? FULL : 0 - FULL);\n const measured = sides.filter((side) => isMeasured(side.turn)).length;\n const corrected = measured > 0 && Math.abs(error) < SQUARE / 2;\n const share = corrected ? error / measured : 0;\n\n // The walk in its own frame: the first corner is the origin, and the first side goes along the x axis.\n let direction = 0;\n const steps = sides.map((side, index): PlanPoint => {\n const [dx, dy] = directionOf(direction);\n direction += turns[index]! - (isMeasured(side.turn) ? share : 0);\n return [dx * lengths[index]!, dy * lengths[index]!];\n });\n const points: PlanPoint[] = [[0, 0]];\n steps.forEach(([dx, dy], index) => {\n const [x, y] = points[index]!;\n points.push([x + dx, y + dy]);\n });\n\n const [gapX, gapY] = points[count]!;\n const gap = Math.hypot(gapX, gapY);\n const ratio = total > 0 ? gap / total : 0;\n const given = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(given) && given >= 0 ? given : CLOSURE_LIMIT;\n const closed = count >= 3 && total > 0 && (corrected || Math.abs(error) < TURN_NOISE) && ratio <= limit;\n\n // The transit rule: along each axis, a corner moves against the gap by the part of the movement before it.\n const moveX = steps.reduce((all, [dx]) => all + Math.abs(dx), 0);\n const moveY = steps.reduce((all, [, dy]) => all + Math.abs(dy), 0);\n let beforeX = 0;\n let beforeY = 0;\n const adjusted = steps.map(([dx, dy], index): PlanPoint => {\n const [x, y] = points[index]!;\n const partX = closed && moveX > 0 ? beforeX / moveX : 0;\n const partY = closed && moveY > 0 ? beforeY / moveY : 0;\n beforeX += Math.abs(dx);\n beforeY += Math.abs(dy);\n return [x - partX * gapX, y - partY * gapY];\n });\n\n // The frame of the walk goes to its place in the plan.\n const start: PlanPoint = survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n const [cos, sin] = directionOf(survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0);\n const place = ([x, y]: PlanPoint): PlanPoint => [start[0] + (x * cos - y * sin), start[1] + (x * sin + y * cos)];\n const walk = points.map(place);\n const corners = adjusted.map(place);\n\n const walls = sides.map((side, index): Wall => {\n const to = closed ? corners[(index + 1) % count]! : walk[index + 1]!;\n return {\n id: side.id,\n from: corners[index]!,\n to,\n side: toLeft ? \"right\" : \"left\",\n ...(side.thickness === undefined ? {} : { thickness: side.thickness }),\n ...(side.height === undefined ? {} : { height: side.height }),\n };\n });\n\n const cornerOf = new Map<string, PlanPoint>();\n sides.forEach((side, index) => {\n if (!cornerOf.has(side.id)) cornerOf.set(side.id, corners[index]!);\n });\n const checks = (survey.checks ?? []).map((check): SurveyCheckResult => {\n const from = cornerOf.get(check.from);\n const to = cornerOf.get(check.to);\n const model = from === undefined || to === undefined ? undefined : Math.hypot(to[0] - from[0], to[1] - from[1]);\n return { id: check.id, measured: check.length, model, difference: model === undefined ? undefined : check.length - model };\n });\n\n // A side that shares the gap changes its length. The length of its wall, as a part of the measured length, is the factor of the side.\n const shared = closed && gap > 0;\n const factorOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!shared || factorOf.has(side.id) || !(lengths[index]! > 0)) return;\n const { from, to } = walls[index]!;\n factorOf.set(side.id, Math.hypot(to[0] - from[0], to[1] - from[1]) / lengths[index]!);\n });\n const openings = survey.openings?.map((opening): Opening => {\n const factor = factorOf.get(opening.wall) ?? 1;\n return factor === 1 ? opening : { ...opening, offset: opening.offset * factor, width: opening.width * factor };\n });\n\n const face = toLeft ? \"left\" : \"right\";\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(survey.name === undefined ? {} : { name: survey.name }),\n unit: survey.unit,\n height: survey.height,\n wallThickness: survey.wallThickness,\n walls,\n // A walk with no shared gap keeps the list of the survey.\n ...(survey.openings === undefined || openings === undefined ? {} : { openings: shared ? openings : survey.openings }),\n // A floor has a counter-clockwise outline.\n ...(closed ? { floors: [{ id: \"floor\", ...(survey.name === undefined ? {} : { name: survey.name }), ring: toLeft ? corners : [...corners].reverse() }] } : {}),\n ...(survey.outlets === undefined ? {} : { outlets: survey.outlets.map((outlet): Outlet => ({ ...outlet, offset: outlet.offset * (factorOf.get(outlet.wall) ?? 1), face })) }),\n ...(survey.circuits === undefined ? {} : { circuits: survey.circuits }),\n };\n\n const sideOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!sideOf.has(side.id)) sideOf.set(side.id, index);\n });\n const listed = new Map<string, SurveyObject>();\n for (const object of survey.objects ?? []) if (!listed.has(object.id)) listed.set(object.id, object);\n const places = new Map<SurveyObject, PlacedObject | undefined>();\n const placeOf = (object: SurveyObject): PlacedObject | undefined => {\n if (places.has(object)) return places.get(object);\n // An object in a ring of objects that hold one another finds itself here. Thus it has no place.\n places.set(object, undefined);\n const made = placed(object);\n places.set(object, made);\n return made;\n };\n const placed = (object: SurveyObject): PlacedObject | undefined => {\n const out = object.gap ?? 0;\n if (![object.width, object.depth, object.height].every((size) => size > 0 && inRange(size))) return undefined;\n if (![object.offset, out, object.lift ?? 0].every(inRange)) return undefined;\n const record = {\n id: object.id,\n kind: object.kind,\n ...(object.name === undefined ? {} : { name: object.name }),\n size: [object.width, object.depth, object.height] as const,\n };\n const power = object.outlet === undefined ? {} : { outlet: object.outlet };\n if (object.on !== undefined) {\n const holder = listed.get(object.on);\n if (holder === undefined || placeOf(holder) === undefined) return undefined;\n // The x axis of the holder goes along its side for a walk to the left, and against its side for a walk to the right.\n const x = object.offset + object.width / 2 - holder.width / 2;\n return { ...record, at: [toLeft ? x : 0 - x, out + object.depth / 2 - holder.depth / 2], lift: object.lift ?? holder.height, parent: holder.id, ...power };\n }\n const index = object.wall === undefined ? undefined : sideOf.get(object.wall);\n if (index === undefined) return undefined;\n const { from, to } = walls[index]!;\n const measure = lengths[index]!;\n const line = Math.hypot(to[0] - from[0], to[1] - from[1]);\n if (!(line > 0) || !(measure > 0)) return undefined;\n // The object keeps its size, so it moves by a part of the change of the length of its side.\n // The part is the place of the object in the free length of the side. An object that is longer than its side has no free length,\n // so the part is its place in the full length, as for an opening.\n const free = measure - object.width;\n const part = Math.min(1, Math.max(0, object.offset / (free > 0 ? free : measure)));\n const near = shared ? object.offset + (line - measure) * part : object.offset;\n const along: PlanPoint = [(to[0] - from[0]) / line, (to[1] - from[1]) / line];\n // The room is on the left of each side of a walk to the left, and on the right of each side of a walk to the right.\n const inward: PlanPoint = toLeft ? [0 - along[1], along[0]] : [along[1], 0 - along[0]];\n const a = near + object.width / 2;\n const b = out + object.depth / 2;\n // The y axis of the object is on the left of its x axis, so the x axis of a walk to the right goes against the side.\n const turn = headingOf(toLeft ? along : [0 - along[0], 0 - along[1]]);\n return {\n ...record,\n at: [from[0] + along[0] * a + inward[0] * b, from[1] + along[1] * a + inward[1] * b],\n ...(object.lift === undefined ? {} : { lift: object.lift }),\n ...(turn === 0 ? {} : { turn }),\n ...power,\n };\n };\n const objects = (survey.objects ?? []).flatMap((object) => {\n const made = placeOf(object);\n return made === undefined ? [] : [made];\n });\n return { room, corners, walk, closure: { gap, ratio, turn: error, closed }, checks, objects };\n}\n","import { headingOf, squared, turned } from \"./direction.ts\";\nimport { ROOM_SCHEMA, type Circuit, type Floor, type Opening, type Outlet, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { CLOSURE_LIMIT, convertSurvey, expandSurvey, type Survey, type SurveyOptions, type SurveyResult } from \"./survey.ts\";\nimport { LARGEST_LENGTH, metersPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a level record. */\nexport const LEVEL_SCHEMA = \"level/1\";\n\n/** One room of a level: the survey of the room, with an `id`. */\nexport interface LevelRoom {\n readonly id: string;\n readonly survey: Survey;\n}\n\n/** One end of a connection: an opening of a room of the level. */\nexport interface ConnectionEnd {\n /** The `id` of the room. */\n readonly room: string;\n /** The `id` of the opening in the survey of that room. */\n readonly opening: string;\n}\n\n/**\n * A connection: one hole through the wall between two rooms, for example a door.\n * A person measures the hole in each room, so the survey of each room has it as an opening.\n */\nexport interface LevelConnection {\n readonly id: string;\n readonly from: ConnectionEnd;\n readonly to: ConnectionEnd;\n /**\n * The thickness of the wall at the hole: the distance between the faces of the wall in the two rooms.\n * A person measures it in the frame of a door. The default is the thickness of the wall of `from`.\n */\n readonly thickness?: number | undefined;\n}\n\n/**\n * A level: the rooms of one level of a building, for example the rooms of an apartment.\n *\n * Each room has its own survey, so each room has its own first corner and its own first direction.\n * A connection gives the place of a room: its two openings are one hole, so the two walls are back to back.\n */\nexport interface Level {\n readonly schema: typeof LEVEL_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the room record of the level. A survey can have a different unit. */\n readonly unit: LengthUnit;\n readonly rooms: readonly LevelRoom[];\n readonly connections?: readonly LevelConnection[] | undefined;\n /** The circuits of the level. A survey can also have circuits. Two circuits with one `id` are one circuit, and the first one stays. */\n readonly circuits?: readonly Circuit[] | undefined;\n}\n\n/**\n * These are the sources of the place of a room.\n *\n * - `first`: the room is the first room of the level. It keeps the `start` and the `heading` of its survey.\n * - `connection`: a connection gives the place.\n * - `apart`: the room has no path of connections to a room before it, so its place is not known.\n */\nexport const ROOM_PLACES: readonly [\"first\", \"connection\", \"apart\"] = [\"first\", \"connection\", \"apart\"];\n\n/** A source of the place of a room. */\nexport type RoomPlace = (typeof ROOM_PLACES)[number];\n\n/** The result of one room of a level. */\nexport interface LevelRoomResult {\n /** The `id` of the room. */\n readonly id: string;\n readonly place: RoomPlace;\n /** The number of the group of the room, from 0. The rooms of one group have a path of connections between them. */\n readonly group: number;\n /** The survey of the room in the unit of the level. Its `start` and its `heading` are the place of the room in the level. */\n readonly survey: Survey;\n /** The expansion of that survey. */\n readonly result: SurveyResult;\n}\n\n/**\n * These are the uses of a connection.\n *\n * - `place`: the connection gives the place of a room.\n * - `check`: its two rooms have a place from other connections, so the connection examines the measurements.\n * - `none`: the connection has a fault, so the level does not use it.\n */\nexport const CONNECTION_USES: readonly [\"place\", \"check\", \"none\"] = [\"place\", \"check\", \"none\"];\n\n/** A use of a connection. */\nexport type ConnectionUse = (typeof CONNECTION_USES)[number];\n\n/**\n * These are the faults of a connection.\n *\n * - `room`: an end names a room that the level does not have.\n * - `opening`: an end names an opening that its room does not have, or the wall of the opening has no length.\n * - `one-room`: the two ends are in one room.\n */\nexport const CONNECTION_FAULTS: readonly [\"room\", \"opening\", \"one-room\"] = [\"room\", \"opening\", \"one-room\"];\n\n/** A fault of a connection. */\nexport type ConnectionFault = (typeof CONNECTION_FAULTS)[number];\n\n/** The result of one connection of a level. A connection with a fault has no numbers. */\nexport interface LevelConnectionResult {\n /** The `id` of the connection. */\n readonly id: string;\n readonly use: ConnectionUse;\n readonly fault?: ConnectionFault | undefined;\n /**\n * The distance between the two openings along the wall and through it, minus the thickness of the wall, in the unit of the level.\n * It is 0 for a connection that gives a place.\n */\n readonly gap: number | undefined;\n /** The gap as a part of the lengths of the walks of the two rooms. */\n readonly ratio: number | undefined;\n /** The angle between the two walls in degrees, from -180 to 180. Two walls that are back to back have 0. */\n readonly turn: number | undefined;\n /** The width of the opening of `to` minus the width of the opening of `from`, in the unit of the level. */\n readonly width: number | undefined;\n /** This value is true when the connection has no fault, its gap is in the limit, and its angle is `CONNECTION_TURN_LIMIT` or less. */\n readonly fits: boolean;\n}\n\n/** The result of the expansion of a level. */\nexport interface LevelResult {\n /**\n * One room record with each room of the level, in the unit of the level.\n * The `id` of a wall, an opening or an outlet is the `id` of its room, then `/`, then its `id` in the survey.\n * Each closed room gives one floor with the `id` and the name of the room.\n */\n readonly room: Room;\n /** The result of each room, in the sequence of the rooms. */\n readonly rooms: readonly LevelRoomResult[];\n /** The result of each connection, in the sequence of the connections. */\n readonly connections: readonly LevelConnectionResult[];\n /**\n * The placed objects of each room, in the sequence of the rooms. The `id` of an object, of its parent and of its outlet\n * has the same form as the `id` of a wall. A scene record with the room record and these objects gives the model of the level.\n */\n readonly objects: readonly PlacedObject[];\n}\n\n/** The options of the expansion of a level. */\nexport interface LevelOptions extends SurveyOptions {\n /** The distance between two groups of rooms, in the unit of the level. The default is 1 m. A value that is not a length of 0 or more gives the default. */\n readonly groupGap?: number | undefined;\n}\n\n/** The largest angle between the two walls of a connection that fits, in degrees. */\nexport const CONNECTION_TURN_LIMIT = 2;\n\n/** A length in meters at this value or less is 0 for the level. */\nconst SMALL = 1e-6;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-6;\n\n/** The number of steps of the grid of calculated lengths in one unit. The noise of float arithmetic is much smaller than one step. */\nconst GRID = 1e9;\n\n/** The place of a room in the level: the first corner of its walk, and the direction of its first side in degrees. */\ninterface Place {\n readonly start: PlanPoint;\n readonly heading: number;\n}\n\n/** An opening of a room, in the frame of its survey. The first corner is the origin, and the first side goes along the x axis. */\ninterface Hole {\n /** The position of the wall of the opening in the room record. */\n readonly wall: number;\n /** The center of the opening on the inner face of its wall. */\n readonly center: PlanPoint;\n /** The unit vector from the room through the wall. */\n readonly out: PlanPoint;\n readonly width: number;\n /** The thickness of the wall of the opening. */\n readonly thickness: number;\n}\n\n/** A connection with no fault: its two rooms as positions in the list of the rooms, and its two openings. */\ninterface Link {\n readonly from: number;\n readonly to: number;\n readonly fromHole: Hole;\n readonly toHole: Hole;\n /** The thickness of the wall at the hole. */\n readonly depth: number;\n}\n\n/** One wall of a room of the level, at its place. */\ninterface Face {\n readonly room: number;\n readonly wall: number;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n readonly along: PlanPoint;\n readonly out: PlanPoint;\n readonly length: number;\n readonly thickness: number;\n}\n\n/** This function gives the sum of two vectors of the plan. The second vector has a factor. */\nfunction plus(a: PlanPoint, b: PlanPoint, factor = 1): PlanPoint {\n return [a[0] + b[0] * factor, a[1] + b[1] * factor];\n}\n\n/** This function gives the dot product of two vectors of the plan. */\nfunction dot(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/** This function gives the cross product of two vectors of the plan. */\nfunction cross(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[1] - a[1] * b[0];\n}\n\n/**\n * This function gives a calculated length on the grid. It removes the noise of float arithmetic,\n * so a place of 0.1 does not become 0.10000000000000009 in a file.\n */\nfunction tidy(value: number): number {\n const steps = Math.round(value * GRID);\n // The sum with 0 changes -0 to 0.\n return Number.isSafeInteger(steps) ? steps / GRID + 0 : value;\n}\n\n/** This function gives a point of the frame of a room as a point of the level. */\nfunction placed(place: Place, point: PlanPoint): PlanPoint {\n return plus(place.start, turned(point, place.heading));\n}\n\n/** This function gives the unit vector along a wall and the unit vector from the room through the wall. A wall with no length has no vectors. */\nfunction vectorsOf(wall: Wall): { readonly along: PlanPoint; readonly out: PlanPoint; readonly length: number } | undefined {\n const dx = wall.to[0] - wall.from[0];\n const dy = wall.to[1] - wall.from[1];\n const length = Math.hypot(dx, dy);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const along: PlanPoint = [dx / length, dy / length];\n // The wall of a survey is on the outer side of its line.\n return { along, out: wall.side === \"left\" ? [0 - along[1], along[0]] : [along[1], 0 - along[0]], length };\n}\n\n/** This function gives an opening of a room in the frame of its survey. `own` is the expansion of the survey with no `start` and no `heading`. */\nfunction holeOf(own: SurveyResult, id: string, inRange: (value: number) => boolean): Hole | undefined {\n const opening = own.room.openings?.find((item) => item.id === id);\n if (opening === undefined || !inRange(opening.offset) || !inRange(opening.width)) return undefined;\n const wall = own.room.walls.findIndex((item) => item.id === opening.wall);\n const record = own.room.walls[wall];\n const vectors = record === undefined ? undefined : vectorsOf(record);\n if (record === undefined || vectors === undefined) return undefined;\n return {\n wall,\n center: plus(record.from, vectors.along, opening.offset + opening.width / 2),\n out: vectors.out,\n width: opening.width,\n thickness: record.thickness ?? own.room.wallThickness,\n };\n}\n\n/**\n * This function gives the place of a room from a connection to a room that has a place.\n * The two walls are back to back, and the centers of the two openings are opposite, at the distance `depth`.\n */\nfunction placeFrom(known: Place, knownHole: Hole, hole: Hole, depth: number): Place {\n const out = turned(knownHole.out, known.heading);\n const heading = squared(headingOf([0 - out[0], 0 - out[1]]) - headingOf(hole.out));\n const center = turned(hole.center, heading);\n const start = plus(plus(placed(known, knownHole.center), out, depth), center, -1);\n return { start: [tidy(start[0]), tidy(start[1])], heading };\n}\n\n/**\n * This function makes one room record from the rooms of a level.\n *\n * The first room keeps the `start` and the `heading` of its survey. The function goes from that room along the connections.\n * A connection to a room with no place gives the place of that room. The two walls are back to back, and the centers of the\n * two openings are opposite. The faces of the two walls are at the distance `thickness`.\n * A connection between two rooms that have a place examines the measurements: its `gap` and its `turn` tell a mistake.\n *\n * A room with no path of connections to a room before it starts a new group. Its place is not known,\n * so its group goes to the right of the groups before it. Thus a drawing of a level in progress shows each room.\n *\n * The survey of a room gives the thickness of each wall. Two rooms have one wall between them, so two walls that are\n * back to back share it. Each wall gets one half of the distance between the two faces.\n * This applies to the two walls of a connection, and to two walls that overlap.\n * A wall that is in part an outer wall gets the same thickness along its full length.\n *\n * `checkRoom` examines the room record. It tells when two rooms overlap.\n */\nexport function expandLevel(level: Level, options: LevelOptions = {}): LevelResult {\n const unit = level.unit;\n const scale = metersPer(unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const size = (value: number | undefined): number | undefined => (value !== undefined && inRange(value) && value * scale > SMALL ? value : undefined);\n const count = level.rooms.length;\n const surveys = level.rooms.map((room) => convertSurvey(room.survey, unit));\n // Each room in the frame of its survey: the first corner is the origin, and the first side goes along the x axis.\n const owns = surveys.map((survey) => expandSurvey({ ...survey, start: undefined, heading: undefined }, options));\n\n const positionOf = new Map<string, number>();\n level.rooms.forEach((room, index) => {\n if (!positionOf.has(room.id)) positionOf.set(room.id, index);\n });\n\n const connections = level.connections ?? [];\n const faults: (ConnectionFault | undefined)[] = [];\n const links = connections.map((connection, index): Link | undefined => {\n const from = positionOf.get(connection.from.room);\n const to = positionOf.get(connection.to.room);\n if (from === undefined || to === undefined) {\n faults[index] = \"room\";\n return undefined;\n }\n if (from === to) {\n faults[index] = \"one-room\";\n return undefined;\n }\n const fromHole = holeOf(owns[from]!, connection.from.opening, inRange);\n const toHole = holeOf(owns[to]!, connection.to.opening, inRange);\n if (fromHole === undefined || toHole === undefined) {\n faults[index] = \"opening\";\n return undefined;\n }\n return { from, to, fromHole, toHole, depth: size(connection.thickness) ?? size(fromHole.thickness) ?? 0 };\n });\n\n // The place of each room: the function goes from the first room of each group along the connections.\n const places: Place[] = [];\n const sources: RoomPlace[] = [];\n const groups: number[] = [];\n const members: number[][] = [];\n const gives = new Set<number>();\n for (let root = 0; root < count; root++) {\n if (places[root] !== undefined) continue;\n const group = members.length;\n const survey = surveys[root]!;\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const start: PlanPoint = group === 0 && survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n places[root] = { start, heading };\n sources[root] = group === 0 ? \"first\" : \"apart\";\n groups[root] = group;\n const queue = [root];\n for (let next = 0; next < queue.length; next++) {\n const known = queue[next]!;\n links.forEach((link, index) => {\n if (link === undefined) return;\n const forward = link.from === known;\n if (!forward && link.to !== known) return;\n const room = forward ? link.to : link.from;\n if (places[room] !== undefined) return;\n places[room] = placeFrom(places[known]!, forward ? link.fromHole : link.toHole, forward ? link.toHole : link.fromHole, link.depth);\n sources[room] = \"connection\";\n groups[room] = group;\n gives.add(index);\n queue.push(room);\n });\n }\n members.push(queue);\n }\n\n // A group with no known place goes to the right of the groups before it. The bottoms of the groups are on one line.\n const givenGap = options.groupGap;\n const groupGap = givenGap !== undefined && inRange(givenGap) && givenGap >= 0 ? givenGap : 1 / scale;\n let right: number | undefined;\n let base = 0;\n for (const [number, group] of members.entries()) {\n let low: PlanPoint | undefined;\n let high: PlanPoint | undefined;\n for (const room of group) {\n const survey = surveys[room]!;\n const margin = Math.max(0, ...[survey.wallThickness, ...survey.sides.map((side) => side.thickness)].map((value) => size(value) ?? 0));\n for (const point of [...owns[room]!.walk, ...owns[room]!.corners]) {\n const [x, y] = placed(places[room]!, point);\n low = low === undefined ? [x - margin, y - margin] : [Math.min(low[0], x - margin), Math.min(low[1], y - margin)];\n high = high === undefined ? [x + margin, y + margin] : [Math.max(high[0], x + margin), Math.max(high[1], y + margin)];\n }\n }\n if (low === undefined || high === undefined) continue;\n if (number === 0 || right === undefined) {\n right = right === undefined ? high[0] : Math.max(right, high[0]);\n if (number === 0) base = low[1];\n continue;\n }\n const move: PlanPoint = [right + groupGap - low[0], base - low[1]];\n for (const room of group) {\n const [x, y] = plus(places[room]!.start, move);\n places[room] = { start: [tidy(x), tidy(y)], heading: places[room]!.heading };\n }\n right = Math.max(right, high[0] + move[0]);\n }\n\n const rooms = level.rooms.map((room, index): LevelRoomResult => {\n const survey: Survey = { ...surveys[index]!, start: places[index]!.start, heading: places[index]!.heading };\n return { id: room.id, place: sources[index]!, group: groups[index]!, survey, result: expandSurvey(survey, options) };\n });\n\n // The measure of each connection, from the places of its two rooms.\n const givenLimit = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(givenLimit) && givenLimit >= 0 ? givenLimit : CLOSURE_LIMIT;\n const walkOf = (room: number): number => {\n const walk = owns[room]!.walk;\n return walk.reduce((sum, point, index) => (index === 0 ? 0 : sum + Math.hypot(point[0] - walk[index - 1]![0], point[1] - walk[index - 1]![1])), 0);\n };\n const results = connections.map((connection, index): LevelConnectionResult => {\n const link = links[index];\n if (link === undefined) return { id: connection.id, use: \"none\", fault: faults[index], gap: undefined, ratio: undefined, turn: undefined, width: undefined, fits: false };\n const width = link.toHole.width - link.fromHole.width;\n if (gives.has(index)) return { id: connection.id, use: \"place\", gap: 0, ratio: 0, turn: 0, width, fits: true };\n const from = places[link.from]!;\n const to = places[link.to]!;\n const out = turned(link.fromHole.out, from.heading);\n const back = turned(link.toHole.out, to.heading);\n const target = plus(placed(from, link.fromHole.center), out, link.depth);\n const center = placed(to, link.toHole.center);\n const miss = Math.hypot(center[0] - target[0], center[1] - target[1]);\n const walk = walkOf(link.from) + walkOf(link.to);\n const ratio = walk > 0 ? miss / walk : 0;\n const against: PlanPoint = [0 - out[0], 0 - out[1]];\n // The sum with 0 changes -0 to 0.\n const turn = (Math.atan2(cross(against, back), dot(against, back)) * 180) / Math.PI + 0;\n return { id: connection.id, use: \"check\", gap: miss, ratio, turn, width, fits: ratio <= limit && Math.abs(turn) <= CONNECTION_TURN_LIMIT };\n });\n\n // Each wall at its place. Two walls that are back to back share the wall between their rooms.\n const faces: Face[] = [];\n rooms.forEach(({ result }, room) => {\n result.room.walls.forEach((wall, index) => {\n const vectors = vectorsOf(wall);\n const thickness = size(wall.thickness ?? result.room.wallThickness);\n if (vectors === undefined || thickness === undefined) return;\n faces.push({ room, wall: index, from: wall.from, to: wall.to, along: vectors.along, out: vectors.out, length: vectors.length, thickness });\n });\n });\n const joined = new Set<string>();\n links.forEach((link, index) => {\n if (link === undefined || !results[index]!.fits) return;\n joined.add(`${link.from}:${link.fromHole.wall}:${link.to}:${link.toHole.wall}`);\n joined.add(`${link.to}:${link.toHole.wall}:${link.from}:${link.fromHole.wall}`);\n });\n const shared = new Map<string, number>();\n for (let i = 0; i < faces.length; i++) {\n for (let j = i + 1; j < faces.length; j++) {\n const a = faces[i]!;\n const b = faces[j]!;\n if (a.room === b.room || Math.abs(cross(a.along, b.along)) > PARALLEL || !(dot(a.out, b.out) < 0)) continue;\n const first: PlanPoint = [b.from[0] - a.from[0], b.from[1] - a.from[1]];\n const second: PlanPoint = [b.to[0] - a.from[0], b.to[1] - a.from[1]];\n const between = dot(first, a.out);\n const common = Math.min(a.length, Math.max(dot(first, a.along), dot(second, a.along))) - Math.max(0, Math.min(dot(first, a.along), dot(second, a.along)));\n if (!(between * scale > SMALL) || !(common * scale > SMALL)) continue;\n // The two walls of a connection are one wall. Two other walls are one wall when they overlap.\n if (!joined.has(`${a.room}:${a.wall}:${b.room}:${b.wall}`) && !((a.thickness + b.thickness - between) * scale > SMALL)) continue;\n const half = tidy(between / 2);\n for (const face of [a, b]) {\n const key = `${face.room}:${face.wall}`;\n shared.set(key, Math.min(shared.get(key) ?? Infinity, half));\n }\n }\n }\n\n const first = rooms[0]?.result.room;\n const height = first?.height ?? 1;\n const wallThickness = first?.wallThickness ?? 1;\n const walls: Wall[] = [];\n const openings: Opening[] = [];\n const floors: Floor[] = [];\n const outlets: Outlet[] = [];\n const objects: PlacedObject[] = [];\n const circuits = new Map<string, Circuit>();\n for (const circuit of level.circuits ?? []) if (!circuits.has(circuit.id)) circuits.set(circuit.id, circuit);\n rooms.forEach(({ id, survey, result }, room) => {\n const record = result.room;\n record.walls.forEach((wall, index) => {\n const thickness = shared.get(`${room}:${index}`) ?? wall.thickness ?? (record.wallThickness === wallThickness ? undefined : record.wallThickness);\n const tall = wall.height ?? (record.height === height ? undefined : record.height);\n walls.push({\n id: `${id}/${wall.id}`,\n from: wall.from,\n to: wall.to,\n ...(wall.side === undefined ? {} : { side: wall.side }),\n ...(thickness === undefined ? {} : { thickness }),\n ...(tall === undefined ? {} : { height: tall }),\n });\n });\n for (const opening of record.openings ?? []) openings.push({ ...opening, id: `${id}/${opening.id}`, wall: `${id}/${opening.wall}` });\n for (const floor of record.floors ?? []) floors.push({ id, ...(survey.name === undefined ? {} : { name: survey.name }), ring: floor.ring });\n for (const outlet of record.outlets ?? []) outlets.push({ ...outlet, id: `${id}/${outlet.id}`, wall: `${id}/${outlet.wall}` });\n for (const circuit of record.circuits ?? []) if (!circuits.has(circuit.id)) circuits.set(circuit.id, circuit);\n for (const object of result.objects) {\n objects.push({\n ...object,\n id: `${id}/${object.id}`,\n ...(object.parent === undefined ? {} : { parent: `${id}/${object.parent}` }),\n ...(object.outlet === undefined ? {} : { outlet: `${id}/${object.outlet}` }),\n });\n }\n });\n\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(level.name === undefined ? {} : { name: level.name }),\n unit,\n height,\n wallThickness,\n walls,\n ...(openings.length === 0 ? {} : { openings }),\n ...(floors.length === 0 ? {} : { floors }),\n ...(outlets.length === 0 ? {} : { outlets }),\n ...(circuits.size === 0 ? {} : { circuits: [...circuits.values()] }),\n };\n return { room, rooms, connections: results, objects };\n}\n"],"mappings":";;;AAOA,MAAa,cAAc;;AAG3B,MAAa,eAAe;;;;;AAM5B,SAAgB,YAAY,MAAuB;CACjD,OAAO,4BAA4B,KAAK,IAAI;AAC9C;;AAGA,MAAa,aAAmD;CAAC;CAAU;CAAQ;AAAO;;AAS1F,MAAa,aAAyC,CAAC,QAAQ,OAAO;;AAsBtE,MAAa,gBAAoD;CAAC;CAAQ;CAAU;AAAK;;ACxCzF,SAAgB,YAAY,SAA4B;CACtD,MAAM,QAAS,UAAA,MAAA,OAAA;CACf,IAAI,SAAS,GA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,IAAI,GAAG,GAAG,GAAG,OAAO;GACpB,GAAI,OAAO,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,OAAO,SAAS;GAC1E,GAAI,OAAO,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,OAAO,SAAS;EAC5E,CAAC;CAEL,CAAC;CAcD,OAAO;EAAE,MAAA;GAXP,QAAQ;GACR,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;GACvD;GACA;GACA;GACA;GACA,GAAI,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE,SAAS;GAC5C,GAAI,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,OAAO;GACxC,GAAI,QAAQ,WAAW,IAAI,CAAC,IAAI,EAAE,QAAQ;GAC1C,GAAI,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE;EAExD;EAAG;EAAO,aAAa;EAAS;CAAQ;AACtD"}
1
+ {"version":3,"file":"level-Cu8vgrwN.js","names":[],"sources":["../src/room.ts","../src/direction.ts","../src/survey.ts","../src/level.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\nimport type { LengthUnit } from \"./units.ts\";\n\n/** A point of the plan: `[x, y]`. The plan is the view from above, and the z axis points up. */\nexport type PlanPoint = readonly [number, number];\n\n/** The name of the format of a room record. */\nexport const ROOM_SCHEMA = \"room/1\";\n\n/** The name of the format of a scene record. */\nexport const SCENE_SCHEMA = \"scene/1\";\n\n/**\n * This function tells if a text is the name of a layer: a word, a slash and a version, for example `electrical/1`.\n * The word has lowercase letters, digits and hyphens. Thus a layer name has no colon, and `recordName` gives each record one name.\n */\nexport function isLayerName(text: string): boolean {\n return /^[a-z][a-z0-9-]*\\/[0-9]+$/.test(text);\n}\n\n/** These are the sides of the line of a wall that can have the wall. */\nexport const WALL_SIDES: readonly [\"center\", \"left\", \"right\"] = [\"center\", \"left\", \"right\"];\n\n/**\n * The side of the line of a wall that has the wall, for a person who looks from `from` to `to`.\n * With `center`, the line is the middle of the wall. With `left` or `right`, the line is one face of the wall.\n */\nexport type WallSide = (typeof WALL_SIDES)[number];\n\n/** These are the faces of a wall, for a person who looks from `from` to `to`. */\nexport const WALL_FACES: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/** A face of a wall. */\nexport type WallFace = (typeof WALL_FACES)[number];\n\n/**\n * A wall: a straight line in the plan, with a thickness and a height.\n * A tape measure gives the faces of a wall, so `side` lets the line be a face. Two walls with a common end make a corner.\n */\nexport interface Wall {\n readonly id: string;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n /** The thickness of the wall. The default is `wallThickness` of the room. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the room. */\n readonly height?: number | undefined;\n /** The side of the line that has the wall. The default is `center`. */\n readonly side?: WallSide | undefined;\n}\n\n/** These are the kinds of an opening. A window has glass. A door and a gap are empty. */\nexport const OPENING_KINDS: readonly [\"door\", \"window\", \"gap\"] = [\"door\", \"window\", \"gap\"];\n\n/** A kind of opening. */\nexport type OpeningKind = (typeof OPENING_KINDS)[number];\n\n/** An opening: a hole through a wall. */\nexport interface Opening {\n readonly id: string;\n /** The `id` of the wall. */\n readonly wall: string;\n readonly kind: OpeningKind;\n /** The distance along the line of the wall, from `from` to the near edge of the opening. */\n readonly offset: number;\n readonly width: number;\n /** The height of the bottom of the opening above the floor. The default is 0. */\n readonly sill?: number | undefined;\n readonly height: number;\n}\n\n/** A floor: one area of the plan, for example one room of an apartment. The ring is the line where the floor touches the walls. */\nexport interface Floor {\n readonly id: string;\n readonly name?: string | undefined;\n readonly ring: Ring;\n}\n\n/** An outlet: a point on a face of a wall. */\nexport interface Outlet {\n readonly id: string;\n /** The `id` of the wall. */\n readonly wall: string;\n /** The face of the wall that has the outlet. */\n readonly face: WallFace;\n /** The distance along the line of the wall, from `from` to the center of the outlet. */\n readonly offset: number;\n /** The height of the center of the outlet above the floor. */\n readonly height: number;\n /** The `id` of the circuit of the outlet. */\n readonly circuit?: string | undefined;\n}\n\n/** A circuit: it gives power to outlets, and it has a limit. */\nexport interface Circuit {\n readonly id: string;\n readonly name?: string | undefined;\n /** The rating of the breaker of the circuit, in amperes, for example 15. The record keeps it as a fact. The limit does not change with it. */\n readonly breaker?: number | undefined;\n /** The voltage of the circuit, in volts, for example 120. The record keeps it as a fact. The limit does not change with it. */\n readonly voltage?: number | undefined;\n /**\n * The largest continuous load, in watts.\n * For example, a breaker of 15 A at 120 V carries 1800 W, and 80% of that for a continuous load is 1440 W.\n */\n readonly limit: number;\n}\n\n/** A room: the walls, the openings, the floors, the outlets and the circuits of one room or one apartment. */\nexport interface Room {\n readonly schema: typeof ROOM_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n readonly walls: readonly Wall[];\n readonly openings?: readonly Opening[] | undefined;\n readonly floors?: readonly Floor[] | undefined;\n readonly outlets?: readonly Outlet[] | undefined;\n readonly circuits?: readonly Circuit[] | undefined;\n}\n\n/**\n * A placed object: a box in the room, for example a desk, a rack or a computer.\n * With a `parent`, the position and the turn are relative to that object, whose origin is the center of its bottom.\n */\nexport interface PlacedObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The size before the turn: along x, along y, and the height. */\n readonly size: readonly [number, number, number];\n /** The point of the plan below the center of the object. */\n readonly at: PlanPoint;\n /** The height of the bottom of the object above the floor, or above the bottom of its parent. The default is 0. */\n readonly lift?: number | undefined;\n /** The turn about the vertical axis in degrees, counter-clockwise from above. The default is 0. */\n readonly turn?: number | undefined;\n /** The `id` of the object that holds this object. */\n readonly parent?: string | undefined;\n /** The `id` of the outlet that gives power to the object. */\n readonly outlet?: string | undefined;\n}\n\n/** A load on a circuit, in watts. A circuit can have many loads: their sum is the load of the circuit. */\nexport interface CircuitLoad {\n /** The `id` of the circuit. */\n readonly circuit: string;\n readonly watts: number;\n}\n\n/** A scene: one room with its placed objects and the loads of its circuits. Two scenes of one room can be compared. */\nexport interface Scene {\n readonly schema: typeof SCENE_SCHEMA;\n readonly name?: string | undefined;\n readonly room: Room;\n readonly objects?: readonly PlacedObject[] | undefined;\n readonly loads?: readonly CircuitLoad[] | undefined;\n /**\n * The records of each add-on, by the name of its layer, for example `electrical/1`. `isLayerName` tells the form of a name.\n * The core keeps each layer and does not read it. `checkLayers` examines the layers with a list of add-ons.\n */\n readonly layers?: Readonly<Record<string, unknown>> | undefined;\n}\n","import type { PlanPoint } from \"./room.ts\";\n\n/** The turn at a square corner, in degrees. */\nexport const SQUARE = 90;\n\n/** One full turn, in degrees. */\nexport const FULL = 360;\n\n/** An angle with an error below this value is exact for the model, in degrees. The value is larger than the error of a sum of numbers. */\nexport const TURN_NOISE = 1e-9;\n\n/** This function gives the unit vector of a direction in degrees. A direction along an axis gives an exact vector. */\nexport function directionOf(degrees: number): PlanPoint {\n const turn = ((degrees % FULL) + FULL) % FULL;\n if (turn === 0) return [1, 0];\n if (turn === SQUARE) return [0, 1];\n if (turn === 2 * SQUARE) return [-1, 0];\n if (turn === 3 * SQUARE) return [0, -1];\n const angle = (turn * Math.PI) / 180;\n return [Math.cos(angle), Math.sin(angle)];\n}\n\n/** This function turns a vector of the plan by an angle in degrees, counter-clockwise. A turn by 90, 180 or 270 degrees is exact. */\nexport function turned([x, y]: PlanPoint, degrees: number): PlanPoint {\n const [cos, sin] = directionOf(degrees);\n return [x * cos - y * sin, x * sin + y * cos];\n}\n\n/**\n * This function gives the direction of a vector in degrees, from 0 to 360, counter-clockwise from the x axis.\n * A direction near 0, 90, 180 or 270 degrees becomes that value, so a room with square corners keeps exact numbers.\n */\nexport function headingOf([x, y]: PlanPoint): number {\n return squared((Math.atan2(y, x) * 180) / Math.PI);\n}\n\n/** This function gives an angle in degrees from 0 to 360. An angle near 0, 90, 180 or 270 degrees becomes that value. */\nexport function squared(degrees: number): number {\n const turn = ((degrees % FULL) + FULL) % FULL;\n const near = Math.round(turn / SQUARE) * SQUARE;\n return Math.abs(turn - near) < TURN_NOISE ? near % FULL : turn;\n}\n","import { directionOf, FULL, headingOf, SQUARE, TURN_NOISE } from \"./direction.ts\";\nimport { ROOM_SCHEMA, type Circuit, type Opening, type Outlet, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { LARGEST_LENGTH, metersPer, unitsPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a survey record. */\nexport const SURVEY_SCHEMA = \"survey/1\";\n\n/** These are the names of the turns at a square corner. */\nexport const SQUARE_TURNS: readonly [\"left\", \"right\"] = [\"left\", \"right\"];\n\n/**\n * The turn of the person at the end of a side, to the direction of the next side.\n *\n * `left` and `right` are the turns at a square corner: 90 degrees. They are exact.\n * A number is a measured angle in degrees, from -360 to 360, and a turn to the left is positive.\n */\nexport type SurveyTurn = (typeof SQUARE_TURNS)[number] | number;\n\n/** One side of a survey: the inner face of one wall, from a corner to the next corner. */\nexport interface SurveySide {\n /** The `id` of the wall of the side. */\n readonly id: string;\n /** The length of the inner face, from corner to corner. */\n readonly length: number;\n /** The turn at the end of the side. */\n readonly turn: SurveyTurn;\n /** The thickness of the wall. The default is `wallThickness` of the survey. */\n readonly thickness?: number | undefined;\n /** The height of the wall. The default is `height` of the survey. */\n readonly height?: number | undefined;\n}\n\n/** A measured distance between two corners of a survey, for example a diagonal of the room. It examines the walk. */\nexport interface SurveyCheck {\n readonly id: string;\n /** The `id` of a side. The first corner is the corner at the start of that side. */\n readonly from: string;\n /** The `id` of a side. The second corner is the corner at the start of that side. */\n readonly to: string;\n /** The measured distance between the two corners. */\n readonly length: number;\n}\n\n/** An outlet of a survey. It is on the inner face of its wall, so it has no field `face`. */\nexport type SurveyOutlet = Omit<Outlet, \"face\">;\n\n/**\n * An object of a survey: a box that a person measures from a side, for example a desk, a shelf or a rack.\n *\n * The back of the object is parallel to the inner face of the side. The person measures along the face to the near edge of the object,\n * and out from the face to its back. The near edge is the edge that is nearest to the first corner of the side.\n * Thus the record has no coordinate.\n *\n * An object with `on` is on a different object or in it, for example a display on a desk or a computer in a rack.\n * Then the person measures from the near edge and from the back of that object, which is the holder.\n * An object has `wall` or `on`. When it has the two, `on` applies.\n */\nexport interface SurveyObject {\n readonly id: string;\n /** The class of the object, for example `desk`, `rack` or `computer`. A viewer gives each class a color. */\n readonly kind: string;\n readonly name?: string | undefined;\n /** The `id` of the side. */\n readonly wall?: string | undefined;\n /** The `id` of the holder. The first object with the `id` applies. */\n readonly on?: string | undefined;\n /**\n * The distance along the inner face, from the first corner of the side to the near edge of the object.\n * With `on`, this is the distance from the near edge of the holder to the near edge of the object.\n */\n readonly offset: number;\n /** The size of the object along the wall. */\n readonly width: number;\n /** The size of the object out from the wall. */\n readonly depth: number;\n readonly height: number;\n /**\n * The distance from the inner face to the back of the object. With `on`, this is the distance from the back of the holder.\n * The default is 0: the object touches the wall, or its back is level with the back of the holder.\n */\n readonly gap?: number | undefined;\n /**\n * The height of the bottom of the object above the floor. The default is 0.\n * With `on`, this is the height above the bottom of the holder. Then the default is the height of the holder: the object is on its top.\n */\n readonly lift?: number | undefined;\n /** The `id` of the outlet that gives power to the object. */\n readonly outlet?: string | undefined;\n}\n\n/**\n * A survey: the measurements of one room by a person with a tape measure.\n *\n * The person goes around the room along the inner faces of the walls, in one direction.\n * Each side has the length of one face, and the turn at its end. The last turn gives the direction of the first side again.\n * An opening, an outlet and an object name their side in `wall`. Their `offset` starts at the first corner of that side.\n */\nexport interface Survey {\n readonly schema: typeof SURVEY_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the record. */\n readonly unit: LengthUnit;\n /** The height of each wall that has no height of its own. */\n readonly height: number;\n /** The thickness of each wall that has no thickness of its own. */\n readonly wallThickness: number;\n /** The sides, in the sequence of the walk. */\n readonly sides: readonly SurveySide[];\n /** The place of the first corner in the plan. The default is the origin. */\n readonly start?: PlanPoint | undefined;\n /** The direction of the first side, in degrees counter-clockwise from the x axis. The default is 0. */\n readonly heading?: number | undefined;\n readonly checks?: readonly SurveyCheck[] | undefined;\n readonly openings?: readonly Opening[] | undefined;\n readonly outlets?: readonly SurveyOutlet[] | undefined;\n readonly circuits?: readonly Circuit[] | undefined;\n readonly objects?: readonly SurveyObject[] | undefined;\n}\n\n/** The closure of a survey: the difference between the end of the walk and its start. */\nexport interface SurveyClosure {\n /** The distance from the end of the last side to the first corner, in the unit of the survey. */\n readonly gap: number;\n /** The gap as a part of the length of the walk. A walk with no length has 0. */\n readonly ratio: number;\n /** The sum of the turns minus one full turn in the direction of the walk, in degrees. */\n readonly turn: number;\n /** This value is true when the walk has 3 sides or more, its turns make one full turn, and its gap is in the limit. */\n readonly closed: boolean;\n}\n\n/** The result of one check of a survey. */\nexport interface SurveyCheckResult {\n /** The `id` of the check. */\n readonly id: string;\n /** The measured distance, in the unit of the survey. */\n readonly measured: number;\n /** The distance between the two corners in the room record. A check with a side that the survey does not have gets `undefined`. */\n readonly model: number | undefined;\n /** The measured distance minus the distance in the room record. */\n readonly difference: number | undefined;\n}\n\n/** The result of the expansion of a survey. */\nexport interface SurveyResult {\n /** The room record of the survey. */\n readonly room: Room;\n /** The corner at the start of each side, as the room record has it. */\n readonly corners: readonly PlanPoint[];\n /** The points of the walk before the correction of the gap. The walk has one point more than the survey has sides. */\n readonly walk: readonly PlanPoint[];\n readonly closure: SurveyClosure;\n /** The result of each check, in the sequence of the checks. */\n readonly checks: readonly SurveyCheckResult[];\n /**\n * The placed object of each object of the survey that has a place, in the sequence of the survey.\n * A scene record with the room record and these objects gives the model of the room with its objects.\n */\n readonly objects: readonly PlacedObject[];\n}\n\n/** The default limit of the gap of a closed walk, as a part of the length of the walk. */\nexport const CLOSURE_LIMIT = 0.01;\n\n/** The options of the expansion of a survey. */\nexport interface SurveyOptions {\n /** The largest gap of a closed walk, as a part of the length of the walk. The default is `CLOSURE_LIMIT`. */\n readonly limit?: number | undefined;\n}\n\n/** This function tells if a turn is a measured angle: an angle from -360 degrees to 360 degrees. */\nfunction isMeasured(turn: SurveyTurn): turn is number {\n return typeof turn === \"number\" && Math.abs(turn) <= FULL;\n}\n\n/** This function gives a turn in degrees. A turn that is not a square turn or a measured angle is 0. */\nfunction degreesOf(turn: SurveyTurn): number {\n if (turn === \"left\") return SQUARE;\n if (turn === \"right\") return 0 - SQUARE;\n return isMeasured(turn) ? turn : 0;\n}\n\n/**\n * This function gives a survey in a different unit. Each length of the record changes, and each angle stays.\n * A survey that has the unit already is the result.\n */\nexport function convertSurvey(survey: Survey, unit: LengthUnit): Survey {\n if (survey.unit === unit) return survey;\n const factor = unitsPer(survey.unit, unit);\n const to = (value: number): number => value * factor;\n const start: PlanPoint | undefined = survey.start === undefined ? undefined : [to(survey.start[0]), to(survey.start[1])];\n return {\n ...survey,\n unit,\n height: to(survey.height),\n wallThickness: to(survey.wallThickness),\n sides: survey.sides.map((side) => ({\n ...side,\n length: to(side.length),\n ...(side.thickness === undefined ? {} : { thickness: to(side.thickness) }),\n ...(side.height === undefined ? {} : { height: to(side.height) }),\n })),\n ...(start === undefined ? {} : { start }),\n ...(survey.checks === undefined ? {} : { checks: survey.checks.map((check) => ({ ...check, length: to(check.length) })) }),\n ...(survey.openings === undefined\n ? {}\n : {\n openings: survey.openings.map((opening) => ({\n ...opening,\n offset: to(opening.offset),\n width: to(opening.width),\n ...(opening.sill === undefined ? {} : { sill: to(opening.sill) }),\n height: to(opening.height),\n })),\n }),\n ...(survey.outlets === undefined ? {} : { outlets: survey.outlets.map((outlet) => ({ ...outlet, offset: to(outlet.offset), height: to(outlet.height) })) }),\n ...(survey.objects === undefined\n ? {}\n : {\n objects: survey.objects.map((object) => ({\n ...object,\n offset: to(object.offset),\n width: to(object.width),\n depth: to(object.depth),\n height: to(object.height),\n ...(object.gap === undefined ? {} : { gap: to(object.gap) }),\n ...(object.lift === undefined ? {} : { lift: to(object.lift) }),\n })),\n }),\n };\n}\n\n/**\n * This function makes the room record of a survey.\n *\n * The walk starts at `start` in the direction `heading`. Each side adds its length, and then the person turns.\n * A length that is not a finite number above 0, or is not in the range of the model, counts as 0.\n * A turn that is not a number from -360 to 360 counts as 0. Thus each number of the result is finite.\n *\n * A measured length has an error, so the walk does not end exactly at its start. The function corrects the two errors of a walk:\n *\n * 1. When the sum of the turns has an error below 45 degrees, each measured turn gets an equal part of the error.\n * The turns `left` and `right` are exact, so they do not change. A larger error is a mistake, for example a wrong turn.\n * 2. When the walk is closed, the sides share the gap. Along each axis of the first side, each side changes in proportion to its length along that axis.\n * This is the transit rule of land survey. A side along an axis stays along that axis, so a room with square corners keeps them.\n * Then the last wall ends exactly at the first corner, and the room gets a floor.\n *\n * An opening and an outlet keep their place on a side that changes its length: each `offset` and each `width` changes in the same proportion.\n * Thus an opening that fits in its measured side fits in its wall, and two openings that do not overlap stay apart.\n *\n * An object keeps its size on a side that changes its length. It moves by a part of that change: its place in the free length of the side.\n * Thus an object that touches a corner continues to touch it. The x axis of a placed object goes along its wall,\n * and its y axis points into the room. An object with a holder has the holder as its parent, and its place is relative to the holder.\n *\n * Some objects have no place, and the result does not have them. A side that is not in the survey or has no length gives no place.\n * A holder with no place gives no place. A size that is not a finite number above 0 gives no place.\n * A distance that is not in the range of the model gives no place.\n *\n * A walk that is not closed gets no correction of the gap: its walls follow the walk, and the room has no floor.\n * Thus the record of a survey in progress shows the walls that the person measured.\n *\n * The wall of each side is on the outer side of its line. Thus each `offset` of the survey is a distance along the inner face.\n * `checkRoom` examines the room record.\n */\nexport function expandSurvey(survey: Survey, options: SurveyOptions = {}): SurveyResult {\n const scale = metersPer(survey.unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const sides = survey.sides;\n const count = sides.length;\n const lengths = sides.map((side) => (side.length > 0 && inRange(side.length) ? side.length : 0));\n const turns = sides.map((side) => degreesOf(side.turn));\n const total = lengths.reduce((sum, length) => sum + length, 0);\n\n const sum = turns.reduce((all, turn) => all + turn, 0);\n const toLeft = sum >= 0;\n const error = sum - (toLeft ? FULL : 0 - FULL);\n const measured = sides.filter((side) => isMeasured(side.turn)).length;\n const corrected = measured > 0 && Math.abs(error) < SQUARE / 2;\n const share = corrected ? error / measured : 0;\n\n // The walk in its own frame: the first corner is the origin, and the first side goes along the x axis.\n let direction = 0;\n const steps = sides.map((side, index): PlanPoint => {\n const [dx, dy] = directionOf(direction);\n direction += turns[index]! - (isMeasured(side.turn) ? share : 0);\n return [dx * lengths[index]!, dy * lengths[index]!];\n });\n const points: PlanPoint[] = [[0, 0]];\n steps.forEach(([dx, dy], index) => {\n const [x, y] = points[index]!;\n points.push([x + dx, y + dy]);\n });\n\n const [gapX, gapY] = points[count]!;\n const gap = Math.hypot(gapX, gapY);\n const ratio = total > 0 ? gap / total : 0;\n const given = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(given) && given >= 0 ? given : CLOSURE_LIMIT;\n const closed = count >= 3 && total > 0 && (corrected || Math.abs(error) < TURN_NOISE) && ratio <= limit;\n\n // The transit rule: along each axis, a corner moves against the gap by the part of the movement before it.\n const moveX = steps.reduce((all, [dx]) => all + Math.abs(dx), 0);\n const moveY = steps.reduce((all, [, dy]) => all + Math.abs(dy), 0);\n let beforeX = 0;\n let beforeY = 0;\n const adjusted = steps.map(([dx, dy], index): PlanPoint => {\n const [x, y] = points[index]!;\n const partX = closed && moveX > 0 ? beforeX / moveX : 0;\n const partY = closed && moveY > 0 ? beforeY / moveY : 0;\n beforeX += Math.abs(dx);\n beforeY += Math.abs(dy);\n return [x - partX * gapX, y - partY * gapY];\n });\n\n // The frame of the walk goes to its place in the plan.\n const start: PlanPoint = survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n const [cos, sin] = directionOf(survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0);\n const place = ([x, y]: PlanPoint): PlanPoint => [start[0] + (x * cos - y * sin), start[1] + (x * sin + y * cos)];\n const walk = points.map(place);\n const corners = adjusted.map(place);\n\n const walls = sides.map((side, index): Wall => {\n const to = closed ? corners[(index + 1) % count]! : walk[index + 1]!;\n return {\n id: side.id,\n from: corners[index]!,\n to,\n side: toLeft ? \"right\" : \"left\",\n ...(side.thickness === undefined ? {} : { thickness: side.thickness }),\n ...(side.height === undefined ? {} : { height: side.height }),\n };\n });\n\n const cornerOf = new Map<string, PlanPoint>();\n sides.forEach((side, index) => {\n if (!cornerOf.has(side.id)) cornerOf.set(side.id, corners[index]!);\n });\n const checks = (survey.checks ?? []).map((check): SurveyCheckResult => {\n const from = cornerOf.get(check.from);\n const to = cornerOf.get(check.to);\n const model = from === undefined || to === undefined ? undefined : Math.hypot(to[0] - from[0], to[1] - from[1]);\n return { id: check.id, measured: check.length, model, difference: model === undefined ? undefined : check.length - model };\n });\n\n // A side that shares the gap changes its length. The length of its wall, as a part of the measured length, is the factor of the side.\n const shared = closed && gap > 0;\n const factorOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!shared || factorOf.has(side.id) || !(lengths[index]! > 0)) return;\n const { from, to } = walls[index]!;\n factorOf.set(side.id, Math.hypot(to[0] - from[0], to[1] - from[1]) / lengths[index]!);\n });\n const openings = survey.openings?.map((opening): Opening => {\n const factor = factorOf.get(opening.wall) ?? 1;\n return factor === 1 ? opening : { ...opening, offset: opening.offset * factor, width: opening.width * factor };\n });\n\n const face = toLeft ? \"left\" : \"right\";\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(survey.name === undefined ? {} : { name: survey.name }),\n unit: survey.unit,\n height: survey.height,\n wallThickness: survey.wallThickness,\n walls,\n // A walk with no shared gap keeps the list of the survey.\n ...(survey.openings === undefined || openings === undefined ? {} : { openings: shared ? openings : survey.openings }),\n // A floor has a counter-clockwise outline.\n ...(closed ? { floors: [{ id: \"floor\", ...(survey.name === undefined ? {} : { name: survey.name }), ring: toLeft ? corners : [...corners].reverse() }] } : {}),\n ...(survey.outlets === undefined ? {} : { outlets: survey.outlets.map((outlet): Outlet => ({ ...outlet, offset: outlet.offset * (factorOf.get(outlet.wall) ?? 1), face })) }),\n ...(survey.circuits === undefined ? {} : { circuits: survey.circuits }),\n };\n\n const sideOf = new Map<string, number>();\n sides.forEach((side, index) => {\n if (!sideOf.has(side.id)) sideOf.set(side.id, index);\n });\n const listed = new Map<string, SurveyObject>();\n for (const object of survey.objects ?? []) if (!listed.has(object.id)) listed.set(object.id, object);\n const places = new Map<SurveyObject, PlacedObject | undefined>();\n const placeOf = (object: SurveyObject): PlacedObject | undefined => {\n if (places.has(object)) return places.get(object);\n // An object in a ring of objects that hold one another finds itself here. Thus it has no place.\n places.set(object, undefined);\n const made = placed(object);\n places.set(object, made);\n return made;\n };\n const placed = (object: SurveyObject): PlacedObject | undefined => {\n const out = object.gap ?? 0;\n if (![object.width, object.depth, object.height].every((size) => size > 0 && inRange(size))) return undefined;\n if (![object.offset, out, object.lift ?? 0].every(inRange)) return undefined;\n const record = {\n id: object.id,\n kind: object.kind,\n ...(object.name === undefined ? {} : { name: object.name }),\n size: [object.width, object.depth, object.height] as const,\n };\n const power = object.outlet === undefined ? {} : { outlet: object.outlet };\n if (object.on !== undefined) {\n const holder = listed.get(object.on);\n if (holder === undefined || placeOf(holder) === undefined) return undefined;\n // The x axis of the holder goes along its side for a walk to the left, and against its side for a walk to the right.\n const x = object.offset + object.width / 2 - holder.width / 2;\n return { ...record, at: [toLeft ? x : 0 - x, out + object.depth / 2 - holder.depth / 2], lift: object.lift ?? holder.height, parent: holder.id, ...power };\n }\n const index = object.wall === undefined ? undefined : sideOf.get(object.wall);\n if (index === undefined) return undefined;\n const { from, to } = walls[index]!;\n const measure = lengths[index]!;\n const line = Math.hypot(to[0] - from[0], to[1] - from[1]);\n if (!(line > 0) || !(measure > 0)) return undefined;\n // The object keeps its size, so it moves by a part of the change of the length of its side.\n // The part is the place of the object in the free length of the side. An object that is longer than its side has no free length,\n // so the part is its place in the full length, as for an opening.\n const free = measure - object.width;\n const part = Math.min(1, Math.max(0, object.offset / (free > 0 ? free : measure)));\n const near = shared ? object.offset + (line - measure) * part : object.offset;\n const along: PlanPoint = [(to[0] - from[0]) / line, (to[1] - from[1]) / line];\n // The room is on the left of each side of a walk to the left, and on the right of each side of a walk to the right.\n const inward: PlanPoint = toLeft ? [0 - along[1], along[0]] : [along[1], 0 - along[0]];\n const a = near + object.width / 2;\n const b = out + object.depth / 2;\n // The y axis of the object is on the left of its x axis, so the x axis of a walk to the right goes against the side.\n const turn = headingOf(toLeft ? along : [0 - along[0], 0 - along[1]]);\n return {\n ...record,\n at: [from[0] + along[0] * a + inward[0] * b, from[1] + along[1] * a + inward[1] * b],\n ...(object.lift === undefined ? {} : { lift: object.lift }),\n ...(turn === 0 ? {} : { turn }),\n ...power,\n };\n };\n const objects = (survey.objects ?? []).flatMap((object) => {\n const made = placeOf(object);\n return made === undefined ? [] : [made];\n });\n return { room, corners, walk, closure: { gap, ratio, turn: error, closed }, checks, objects };\n}\n","import { headingOf, squared, turned } from \"./direction.ts\";\nimport { ROOM_SCHEMA, type Circuit, type Floor, type Opening, type Outlet, type PlacedObject, type PlanPoint, type Room, type Wall } from \"./room.ts\";\nimport { CLOSURE_LIMIT, convertSurvey, expandSurvey, type Survey, type SurveyOptions, type SurveyResult } from \"./survey.ts\";\nimport { LARGEST_LENGTH, metersPer, type LengthUnit } from \"./units.ts\";\n\n/** The name of the format of a level record. */\nexport const LEVEL_SCHEMA = \"level/1\";\n\n/** One room of a level: the survey of the room, with an `id`. */\nexport interface LevelRoom {\n readonly id: string;\n readonly survey: Survey;\n}\n\n/** One end of a connection: an opening of a room of the level. */\nexport interface ConnectionEnd {\n /** The `id` of the room. */\n readonly room: string;\n /** The `id` of the opening in the survey of that room. */\n readonly opening: string;\n}\n\n/**\n * A connection: one hole through the wall between two rooms, for example a door.\n * A person measures the hole in each room, so the survey of each room has it as an opening.\n */\nexport interface LevelConnection {\n readonly id: string;\n readonly from: ConnectionEnd;\n readonly to: ConnectionEnd;\n /**\n * The thickness of the wall at the hole: the distance between the faces of the wall in the two rooms.\n * A person measures it in the frame of a door. The default is the thickness of the wall of `from`.\n */\n readonly thickness?: number | undefined;\n}\n\n/**\n * A level: the rooms of one level of a building, for example the rooms of an apartment.\n *\n * Each room has its own survey, so each room has its own first corner and its own first direction.\n * A connection gives the place of a room: its two openings are one hole, so the two walls are back to back.\n */\nexport interface Level {\n readonly schema: typeof LEVEL_SCHEMA;\n readonly name?: string | undefined;\n /** The unit of each length of the room record of the level. A survey can have a different unit. */\n readonly unit: LengthUnit;\n readonly rooms: readonly LevelRoom[];\n readonly connections?: readonly LevelConnection[] | undefined;\n /** The circuits of the level. A survey can also have circuits. Two circuits with one `id` are one circuit, and the first one stays. */\n readonly circuits?: readonly Circuit[] | undefined;\n}\n\n/**\n * These are the sources of the place of a room.\n *\n * - `first`: the room is the first room of the level. It keeps the `start` and the `heading` of its survey.\n * - `connection`: a connection gives the place.\n * - `apart`: the room has no path of connections to a room before it, so its place is not known.\n */\nexport const ROOM_PLACES: readonly [\"first\", \"connection\", \"apart\"] = [\"first\", \"connection\", \"apart\"];\n\n/** A source of the place of a room. */\nexport type RoomPlace = (typeof ROOM_PLACES)[number];\n\n/** The result of one room of a level. */\nexport interface LevelRoomResult {\n /** The `id` of the room. */\n readonly id: string;\n readonly place: RoomPlace;\n /** The number of the group of the room, from 0. The rooms of one group have a path of connections between them. */\n readonly group: number;\n /** The survey of the room in the unit of the level. Its `start` and its `heading` are the place of the room in the level. */\n readonly survey: Survey;\n /** The expansion of that survey. */\n readonly result: SurveyResult;\n}\n\n/**\n * These are the uses of a connection.\n *\n * - `place`: the connection gives the place of a room.\n * - `check`: its two rooms have a place from other connections, so the connection examines the measurements.\n * - `none`: the connection has a fault, so the level does not use it.\n */\nexport const CONNECTION_USES: readonly [\"place\", \"check\", \"none\"] = [\"place\", \"check\", \"none\"];\n\n/** A use of a connection. */\nexport type ConnectionUse = (typeof CONNECTION_USES)[number];\n\n/**\n * These are the faults of a connection.\n *\n * - `room`: an end names a room that the level does not have.\n * - `opening`: an end names an opening that its room does not have, or the wall of the opening has no length.\n * - `one-room`: the two ends are in one room.\n */\nexport const CONNECTION_FAULTS: readonly [\"room\", \"opening\", \"one-room\"] = [\"room\", \"opening\", \"one-room\"];\n\n/** A fault of a connection. */\nexport type ConnectionFault = (typeof CONNECTION_FAULTS)[number];\n\n/** The result of one connection of a level. A connection with a fault has no numbers. */\nexport interface LevelConnectionResult {\n /** The `id` of the connection. */\n readonly id: string;\n readonly use: ConnectionUse;\n readonly fault?: ConnectionFault | undefined;\n /**\n * The distance between the two openings along the wall and through it, minus the thickness of the wall, in the unit of the level.\n * It is 0 for a connection that gives a place.\n */\n readonly gap: number | undefined;\n /** The gap as a part of the lengths of the walks of the two rooms. */\n readonly ratio: number | undefined;\n /** The angle between the two walls in degrees, from -180 to 180. Two walls that are back to back have 0. */\n readonly turn: number | undefined;\n /** The width of the opening of `to` minus the width of the opening of `from`, in the unit of the level. */\n readonly width: number | undefined;\n /** This value is true when the connection has no fault, its gap is in the limit, and its angle is `CONNECTION_TURN_LIMIT` or less. */\n readonly fits: boolean;\n}\n\n/** The result of the expansion of a level. */\nexport interface LevelResult {\n /**\n * One room record with each room of the level, in the unit of the level.\n * The `id` of a wall, an opening or an outlet is the `id` of its room, then `/`, then its `id` in the survey.\n * Each closed room gives one floor with the `id` and the name of the room.\n */\n readonly room: Room;\n /** The result of each room, in the sequence of the rooms. */\n readonly rooms: readonly LevelRoomResult[];\n /** The result of each connection, in the sequence of the connections. */\n readonly connections: readonly LevelConnectionResult[];\n /**\n * The placed objects of each room, in the sequence of the rooms. The `id` of an object, of its parent and of its outlet\n * has the same form as the `id` of a wall. A scene record with the room record and these objects gives the model of the level.\n */\n readonly objects: readonly PlacedObject[];\n}\n\n/** The options of the expansion of a level. */\nexport interface LevelOptions extends SurveyOptions {\n /** The distance between two groups of rooms, in the unit of the level. The default is 1 m. A value that is not a length of 0 or more gives the default. */\n readonly groupGap?: number | undefined;\n}\n\n/** The largest angle between the two walls of a connection that fits, in degrees. */\nexport const CONNECTION_TURN_LIMIT = 2;\n\n/** A length in meters at this value or less is 0 for the level. */\nconst SMALL = 1e-6;\n\n/** Two unit vectors with a cross product below this value are parallel. */\nconst PARALLEL = 1e-6;\n\n/** The number of steps of the grid of calculated lengths in one unit. The noise of float arithmetic is much smaller than one step. */\nconst GRID = 1e9;\n\n/** The place of a room in the level: the first corner of its walk, and the direction of its first side in degrees. */\ninterface Place {\n readonly start: PlanPoint;\n readonly heading: number;\n}\n\n/** An opening of a room, in the frame of its survey. The first corner is the origin, and the first side goes along the x axis. */\ninterface Hole {\n /** The position of the wall of the opening in the room record. */\n readonly wall: number;\n /** The center of the opening on the inner face of its wall. */\n readonly center: PlanPoint;\n /** The unit vector from the room through the wall. */\n readonly out: PlanPoint;\n readonly width: number;\n /** The thickness of the wall of the opening. */\n readonly thickness: number;\n}\n\n/** A connection with no fault: its two rooms as positions in the list of the rooms, and its two openings. */\ninterface Link {\n readonly from: number;\n readonly to: number;\n readonly fromHole: Hole;\n readonly toHole: Hole;\n /** The thickness of the wall at the hole. */\n readonly depth: number;\n}\n\n/** One wall of a room of the level, at its place. */\ninterface Face {\n readonly room: number;\n readonly wall: number;\n readonly from: PlanPoint;\n readonly to: PlanPoint;\n readonly along: PlanPoint;\n readonly out: PlanPoint;\n readonly length: number;\n readonly thickness: number;\n}\n\n/** This function gives the sum of two vectors of the plan. The second vector has a factor. */\nfunction plus(a: PlanPoint, b: PlanPoint, factor = 1): PlanPoint {\n return [a[0] + b[0] * factor, a[1] + b[1] * factor];\n}\n\n/** This function gives the dot product of two vectors of the plan. */\nfunction dot(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[0] + a[1] * b[1];\n}\n\n/** This function gives the cross product of two vectors of the plan. */\nfunction cross(a: PlanPoint, b: PlanPoint): number {\n return a[0] * b[1] - a[1] * b[0];\n}\n\n/**\n * This function gives a calculated length on the grid. It removes the noise of float arithmetic,\n * so a place of 0.1 does not become 0.10000000000000009 in a file.\n */\nfunction tidy(value: number): number {\n const steps = Math.round(value * GRID);\n // The sum with 0 changes -0 to 0.\n return Number.isSafeInteger(steps) ? steps / GRID + 0 : value;\n}\n\n/** This function gives a point of the frame of a room as a point of the level. */\nfunction placed(place: Place, point: PlanPoint): PlanPoint {\n return plus(place.start, turned(point, place.heading));\n}\n\n/** This function gives the unit vector along a wall and the unit vector from the room through the wall. A wall with no length has no vectors. */\nfunction vectorsOf(wall: Wall): { readonly along: PlanPoint; readonly out: PlanPoint; readonly length: number } | undefined {\n const dx = wall.to[0] - wall.from[0];\n const dy = wall.to[1] - wall.from[1];\n const length = Math.hypot(dx, dy);\n if (!(length > 0) || !Number.isFinite(length)) return undefined;\n const along: PlanPoint = [dx / length, dy / length];\n // The wall of a survey is on the outer side of its line.\n return { along, out: wall.side === \"left\" ? [0 - along[1], along[0]] : [along[1], 0 - along[0]], length };\n}\n\n/** This function gives an opening of a room in the frame of its survey. `own` is the expansion of the survey with no `start` and no `heading`. */\nfunction holeOf(own: SurveyResult, id: string, inRange: (value: number) => boolean): Hole | undefined {\n const opening = own.room.openings?.find((item) => item.id === id);\n if (opening === undefined || !inRange(opening.offset) || !inRange(opening.width)) return undefined;\n const wall = own.room.walls.findIndex((item) => item.id === opening.wall);\n const record = own.room.walls[wall];\n const vectors = record === undefined ? undefined : vectorsOf(record);\n if (record === undefined || vectors === undefined) return undefined;\n return {\n wall,\n center: plus(record.from, vectors.along, opening.offset + opening.width / 2),\n out: vectors.out,\n width: opening.width,\n thickness: record.thickness ?? own.room.wallThickness,\n };\n}\n\n/**\n * This function gives the place of a room from a connection to a room that has a place.\n * The two walls are back to back, and the centers of the two openings are opposite, at the distance `depth`.\n */\nfunction placeFrom(known: Place, knownHole: Hole, hole: Hole, depth: number): Place {\n const out = turned(knownHole.out, known.heading);\n const heading = squared(headingOf([0 - out[0], 0 - out[1]]) - headingOf(hole.out));\n const center = turned(hole.center, heading);\n const start = plus(plus(placed(known, knownHole.center), out, depth), center, -1);\n return { start: [tidy(start[0]), tidy(start[1])], heading };\n}\n\n/**\n * This function makes one room record from the rooms of a level.\n *\n * The first room keeps the `start` and the `heading` of its survey. The function goes from that room along the connections.\n * A connection to a room with no place gives the place of that room. The two walls are back to back, and the centers of the\n * two openings are opposite. The faces of the two walls are at the distance `thickness`.\n * A connection between two rooms that have a place examines the measurements: its `gap` and its `turn` tell a mistake.\n *\n * A room with no path of connections to a room before it starts a new group. Its place is not known,\n * so its group goes to the right of the groups before it. Thus a drawing of a level in progress shows each room.\n *\n * The survey of a room gives the thickness of each wall. Two rooms have one wall between them, so two walls that are\n * back to back share it. Each wall gets one half of the distance between the two faces.\n * This applies to the two walls of a connection, and to two walls that overlap.\n * A wall that is in part an outer wall gets the same thickness along its full length.\n *\n * `checkRoom` examines the room record. It tells when two rooms overlap.\n */\nexport function expandLevel(level: Level, options: LevelOptions = {}): LevelResult {\n const unit = level.unit;\n const scale = metersPer(unit);\n const inRange = (value: number): boolean => Number.isFinite(value) && Math.abs(value) * scale <= LARGEST_LENGTH;\n const size = (value: number | undefined): number | undefined => (value !== undefined && inRange(value) && value * scale > SMALL ? value : undefined);\n const count = level.rooms.length;\n const surveys = level.rooms.map((room) => convertSurvey(room.survey, unit));\n // Each room in the frame of its survey: the first corner is the origin, and the first side goes along the x axis.\n const owns = surveys.map((survey) => expandSurvey({ ...survey, start: undefined, heading: undefined }, options));\n\n const positionOf = new Map<string, number>();\n level.rooms.forEach((room, index) => {\n if (!positionOf.has(room.id)) positionOf.set(room.id, index);\n });\n\n const connections = level.connections ?? [];\n const faults: (ConnectionFault | undefined)[] = [];\n const links = connections.map((connection, index): Link | undefined => {\n const from = positionOf.get(connection.from.room);\n const to = positionOf.get(connection.to.room);\n if (from === undefined || to === undefined) {\n faults[index] = \"room\";\n return undefined;\n }\n if (from === to) {\n faults[index] = \"one-room\";\n return undefined;\n }\n const fromHole = holeOf(owns[from]!, connection.from.opening, inRange);\n const toHole = holeOf(owns[to]!, connection.to.opening, inRange);\n if (fromHole === undefined || toHole === undefined) {\n faults[index] = \"opening\";\n return undefined;\n }\n return { from, to, fromHole, toHole, depth: size(connection.thickness) ?? size(fromHole.thickness) ?? 0 };\n });\n\n // The place of each room: the function goes from the first room of each group along the connections.\n const places: Place[] = [];\n const sources: RoomPlace[] = [];\n const groups: number[] = [];\n const members: number[][] = [];\n const gives = new Set<number>();\n for (let root = 0; root < count; root++) {\n if (places[root] !== undefined) continue;\n const group = members.length;\n const survey = surveys[root]!;\n const heading = survey.heading !== undefined && Number.isFinite(survey.heading) ? survey.heading : 0;\n const start: PlanPoint = group === 0 && survey.start !== undefined && inRange(survey.start[0]) && inRange(survey.start[1]) ? survey.start : [0, 0];\n places[root] = { start, heading };\n sources[root] = group === 0 ? \"first\" : \"apart\";\n groups[root] = group;\n const queue = [root];\n for (let next = 0; next < queue.length; next++) {\n const known = queue[next]!;\n links.forEach((link, index) => {\n if (link === undefined) return;\n const forward = link.from === known;\n if (!forward && link.to !== known) return;\n const room = forward ? link.to : link.from;\n if (places[room] !== undefined) return;\n places[room] = placeFrom(places[known]!, forward ? link.fromHole : link.toHole, forward ? link.toHole : link.fromHole, link.depth);\n sources[room] = \"connection\";\n groups[room] = group;\n gives.add(index);\n queue.push(room);\n });\n }\n members.push(queue);\n }\n\n // A group with no known place goes to the right of the groups before it. The bottoms of the groups are on one line.\n const givenGap = options.groupGap;\n const groupGap = givenGap !== undefined && inRange(givenGap) && givenGap >= 0 ? givenGap : 1 / scale;\n let right: number | undefined;\n let base = 0;\n for (const [number, group] of members.entries()) {\n let low: PlanPoint | undefined;\n let high: PlanPoint | undefined;\n for (const room of group) {\n const survey = surveys[room]!;\n const margin = Math.max(0, ...[survey.wallThickness, ...survey.sides.map((side) => side.thickness)].map((value) => size(value) ?? 0));\n for (const point of [...owns[room]!.walk, ...owns[room]!.corners]) {\n const [x, y] = placed(places[room]!, point);\n low = low === undefined ? [x - margin, y - margin] : [Math.min(low[0], x - margin), Math.min(low[1], y - margin)];\n high = high === undefined ? [x + margin, y + margin] : [Math.max(high[0], x + margin), Math.max(high[1], y + margin)];\n }\n }\n if (low === undefined || high === undefined) continue;\n if (number === 0 || right === undefined) {\n right = right === undefined ? high[0] : Math.max(right, high[0]);\n if (number === 0) base = low[1];\n continue;\n }\n const move: PlanPoint = [right + groupGap - low[0], base - low[1]];\n for (const room of group) {\n const [x, y] = plus(places[room]!.start, move);\n places[room] = { start: [tidy(x), tidy(y)], heading: places[room]!.heading };\n }\n right = Math.max(right, high[0] + move[0]);\n }\n\n const rooms = level.rooms.map((room, index): LevelRoomResult => {\n const survey: Survey = { ...surveys[index]!, start: places[index]!.start, heading: places[index]!.heading };\n return { id: room.id, place: sources[index]!, group: groups[index]!, survey, result: expandSurvey(survey, options) };\n });\n\n // The measure of each connection, from the places of its two rooms.\n const givenLimit = options.limit ?? CLOSURE_LIMIT;\n const limit = Number.isFinite(givenLimit) && givenLimit >= 0 ? givenLimit : CLOSURE_LIMIT;\n const walkOf = (room: number): number => {\n const walk = owns[room]!.walk;\n return walk.reduce((sum, point, index) => (index === 0 ? 0 : sum + Math.hypot(point[0] - walk[index - 1]![0], point[1] - walk[index - 1]![1])), 0);\n };\n const results = connections.map((connection, index): LevelConnectionResult => {\n const link = links[index];\n if (link === undefined) return { id: connection.id, use: \"none\", fault: faults[index], gap: undefined, ratio: undefined, turn: undefined, width: undefined, fits: false };\n const width = link.toHole.width - link.fromHole.width;\n if (gives.has(index)) return { id: connection.id, use: \"place\", gap: 0, ratio: 0, turn: 0, width, fits: true };\n const from = places[link.from]!;\n const to = places[link.to]!;\n const out = turned(link.fromHole.out, from.heading);\n const back = turned(link.toHole.out, to.heading);\n const target = plus(placed(from, link.fromHole.center), out, link.depth);\n const center = placed(to, link.toHole.center);\n const miss = Math.hypot(center[0] - target[0], center[1] - target[1]);\n const walk = walkOf(link.from) + walkOf(link.to);\n const ratio = walk > 0 ? miss / walk : 0;\n const against: PlanPoint = [0 - out[0], 0 - out[1]];\n // The sum with 0 changes -0 to 0.\n const turn = (Math.atan2(cross(against, back), dot(against, back)) * 180) / Math.PI + 0;\n return { id: connection.id, use: \"check\", gap: miss, ratio, turn, width, fits: ratio <= limit && Math.abs(turn) <= CONNECTION_TURN_LIMIT };\n });\n\n // Each wall at its place. Two walls that are back to back share the wall between their rooms.\n const faces: Face[] = [];\n rooms.forEach(({ result }, room) => {\n result.room.walls.forEach((wall, index) => {\n const vectors = vectorsOf(wall);\n const thickness = size(wall.thickness ?? result.room.wallThickness);\n if (vectors === undefined || thickness === undefined) return;\n faces.push({ room, wall: index, from: wall.from, to: wall.to, along: vectors.along, out: vectors.out, length: vectors.length, thickness });\n });\n });\n const joined = new Set<string>();\n links.forEach((link, index) => {\n if (link === undefined || !results[index]!.fits) return;\n joined.add(`${link.from}:${link.fromHole.wall}:${link.to}:${link.toHole.wall}`);\n joined.add(`${link.to}:${link.toHole.wall}:${link.from}:${link.fromHole.wall}`);\n });\n const shared = new Map<string, number>();\n for (let i = 0; i < faces.length; i++) {\n for (let j = i + 1; j < faces.length; j++) {\n const a = faces[i]!;\n const b = faces[j]!;\n if (a.room === b.room || Math.abs(cross(a.along, b.along)) > PARALLEL || !(dot(a.out, b.out) < 0)) continue;\n const first: PlanPoint = [b.from[0] - a.from[0], b.from[1] - a.from[1]];\n const second: PlanPoint = [b.to[0] - a.from[0], b.to[1] - a.from[1]];\n const between = dot(first, a.out);\n const common = Math.min(a.length, Math.max(dot(first, a.along), dot(second, a.along))) - Math.max(0, Math.min(dot(first, a.along), dot(second, a.along)));\n if (!(between * scale > SMALL) || !(common * scale > SMALL)) continue;\n // The two walls of a connection are one wall. Two other walls are one wall when they overlap.\n if (!joined.has(`${a.room}:${a.wall}:${b.room}:${b.wall}`) && !((a.thickness + b.thickness - between) * scale > SMALL)) continue;\n const half = tidy(between / 2);\n for (const face of [a, b]) {\n const key = `${face.room}:${face.wall}`;\n shared.set(key, Math.min(shared.get(key) ?? Infinity, half));\n }\n }\n }\n\n const first = rooms[0]?.result.room;\n const height = first?.height ?? 1;\n const wallThickness = first?.wallThickness ?? 1;\n const walls: Wall[] = [];\n const openings: Opening[] = [];\n const floors: Floor[] = [];\n const outlets: Outlet[] = [];\n const objects: PlacedObject[] = [];\n const circuits = new Map<string, Circuit>();\n for (const circuit of level.circuits ?? []) if (!circuits.has(circuit.id)) circuits.set(circuit.id, circuit);\n rooms.forEach(({ id, survey, result }, room) => {\n const record = result.room;\n record.walls.forEach((wall, index) => {\n const thickness = shared.get(`${room}:${index}`) ?? wall.thickness ?? (record.wallThickness === wallThickness ? undefined : record.wallThickness);\n const tall = wall.height ?? (record.height === height ? undefined : record.height);\n walls.push({\n id: `${id}/${wall.id}`,\n from: wall.from,\n to: wall.to,\n ...(wall.side === undefined ? {} : { side: wall.side }),\n ...(thickness === undefined ? {} : { thickness }),\n ...(tall === undefined ? {} : { height: tall }),\n });\n });\n for (const opening of record.openings ?? []) openings.push({ ...opening, id: `${id}/${opening.id}`, wall: `${id}/${opening.wall}` });\n for (const floor of record.floors ?? []) floors.push({ id, ...(survey.name === undefined ? {} : { name: survey.name }), ring: floor.ring });\n for (const outlet of record.outlets ?? []) outlets.push({ ...outlet, id: `${id}/${outlet.id}`, wall: `${id}/${outlet.wall}` });\n for (const circuit of record.circuits ?? []) if (!circuits.has(circuit.id)) circuits.set(circuit.id, circuit);\n for (const object of result.objects) {\n objects.push({\n ...object,\n id: `${id}/${object.id}`,\n ...(object.parent === undefined ? {} : { parent: `${id}/${object.parent}` }),\n ...(object.outlet === undefined ? {} : { outlet: `${id}/${object.outlet}` }),\n });\n }\n });\n\n const room: Room = {\n schema: ROOM_SCHEMA,\n ...(level.name === undefined ? {} : { name: level.name }),\n unit,\n height,\n wallThickness,\n walls,\n ...(openings.length === 0 ? {} : { openings }),\n ...(floors.length === 0 ? {} : { floors }),\n ...(outlets.length === 0 ? {} : { outlets }),\n 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AC,IAAI,EAAE,MAAM,OAAO,KAAK;GAAI,MAAM,MAAM;EAAK,CAAC;EAC1I,KAAK,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG,QAAQ,KAAK;GAAE,GAAG;GAAQ,IAAI,GAAG,GAAG,GAAG,OAAO;GAAM,MAAM,GAAG,GAAG,GAAG,OAAO;EAAO,CAAC;EAC7H,KAAK,MAAM,WAAW,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,QAAQ,EAAE,GAAG,SAAS,IAAI,QAAQ,IAAI,OAAO;EAC5G,KAAK,MAAM,UAAU,OAAO,SAC1B,QAAQ,KAAK;GACX,GAAG;GACH,IAAI,GAAG,GAAG,GAAG,OAAO;GACpB,GAAI,OAAO,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,OAAO,SAAS;GAC1E,GAAI,OAAO,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,GAAG,OAAO,SAAS;EAC5E,CAAC;CAEL,CAAC;CAcD,OAAO;EAAE,MAAA;GAXP,QAAQ;GACR,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;GACvD;GACA;GACA;GACA;GACA,GAAI,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE,SAAS;GAC5C,GAAI,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,OAAO;GACxC,GAAI,QAAQ,WAAW,IAAI,CAAC,IAAI,EAAE,QAAQ;GAC1C,GAAI,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE;EAExD;EAAG;EAAO,aAAa;EAAS;CAAQ;AACtD"}
@@ -1,4 +1,4 @@
1
- import { d as Room, p as Scene } from "./room-x9FxGjGi.js";
1
+ import { d as Room, p as Scene } from "./room-NREa6vXr.js";
2
2
  import { Box3, Point, Point3, Ring, Transform3 } from "@mark1russell7/layout-contract";
3
3
  /**
4
4
  * The frame of a wall, in meters. A point of the wall has a distance along the line and a distance across it.
@@ -220,4 +220,4 @@ declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
220
220
  */
221
221
  declare function shapeRing(shape: LevelShape, radius?: number): Ring;
222
222
  export { solidVolume as A, wallTransform as B, SolidShape as C, roomSolids as D, objectTransforms as E, wallFootprints as F, WallFrame as I, wallFrames as L, JoinOptions as M, MITER_LIMIT as N, sceneSolids as O, WallFootprint as P, wallHasOutline as R, SolidOptions as S, boundsOfSolids as T, PlacedBox as _, LoadLevel as a, Solid as b, SHAPE_OUTLINES as c, levelShape as d, outletLevels as f, OUTLET_PLATE as g, GLASS_THICKNESS as h, LevelShape as i, JOIN_TOLERANCE as j, solidCorners as k, ShapeOutline as l, FLOOR_DEPTH as m, LEVEL_SHAPES as n, LoadOptions as o, shapeRing as p, LOAD_LEVELS as r, NEAR_LIMIT as s, CircuitState as t, circuitStates as u, Prism as v, TO_Y_UP as w, SolidKind as x, SOLID_KINDS as y, wallPoint as z };
223
- //# sourceMappingURL=loads-spBbQkb0.d.ts.map
223
+ //# sourceMappingURL=loads-C3Nrj3Gd.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loads-spBbQkb0.d.ts","names":[],"sources":["../src/frames.ts","../src/joins.ts","../src/solids.ts","../src/loads.ts"],"mappings":";;;;;;UAQiB;;WAEN;WACA,OAAO;WACP,KAAK;;WAEL,OAAO;;WAEP,MAAM;WACN;WACA;WACA;;WAEA;;WAEA;;;iBA2BK,WAAW,MAAM,gBAAgB;;;;;iBASjC,eAAe,OAAO;;iBAKtB,UAAU,OAAO,WAAW,eAAe,iBAAiB;;;;;iBAW5D,cAAc,OAAO,YAAY;;UCvEhC;;WAEN;;WAEA,MAAM;;;;;WAKN;;;UAIM;;WAEN;;;;;WAKA;;;cAIE;;cAGA;;;;;;;;;iBA8IG,eAAe,iBAAiB,aAAa,UAAS,uBAA4B;;cCzJrF;;KAGD,o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AEN;;;;;WAKA;;;cAIE;;cAGA;;;;;;;;;iBA8IG,eAAe,iBAAiB,aAAa,UAAS,uBAA4B;;cCzJrF;;KAGD,oBAAoB;;UAGf;WACN;WACA,MAAM;WACN;WACA;;;UAIM;WACN;WACA,KAAK;WACL,WAAW;;;KAIV,aAAa,QAAQ;;;;;UAMhB;;WAEN;WACA,MAAM;;WAEN;WACA,OAAO;;;UAID;;WAEN;;WAEA,QAAQ;;;cAIN;;cAGA;;cAGA;WAAyB;WAAwB;WAAyB;;;;;;cAM1E,SAAS;;;;;;;;;iBA4HN,WAAW,MAAM,MAAM,UAAS,wBAA6B;;;;;;;iBAiD7D,iBAAiB,OAAO,QAAQ,oBAAoB;;;;;iBAiCpD,YAAY,OAAO,OAAO,UAAS,wBAA6B;;iBAqBhE,aAAa,OAAO,iBAAiB;;iBAUrC,eAAe,iBAAiB,UAAU;;iBAK1C,YAAY,OAAO;;cC3TtB;;KAGD,oBAAoB;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,OAAO;;WAEP;;WAEA;;;UAIM;;WAEN;;;cAIE;;;;;;;iBAQG,cAAc,OAAO,OAAO,UAAS,uBAA4B;;;;;iBAyBjE,aAAa,OAAO,OAAO,UAAS,cAAmB,oBAAoB;;cAS9E;;KAGD,qBAAqB;;;;;iBAMjB,WAAW,OAAO,wBAAwB;;UAKzC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;cAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;iBAWzC,UAAU,OAAO,YAAY,kBAAqB"}
@@ -92,6 +92,10 @@ interface Outlet {
92
92
  interface Circuit {
93
93
  readonly id: string;
94
94
  readonly name?: string | undefined;
95
+ /** The rating of the breaker of the circuit, in amperes, for example 15. The record keeps it as a fact. The limit does not change with it. */
96
+ readonly breaker?: number | undefined;
97
+ /** The voltage of the circuit, in volts, for example 120. The record keeps it as a fact. The limit does not change with it. */
98
+ readonly voltage?: number | undefined;
95
99
  /**
96
100
  * The largest continuous load, in watts.
97
101
  * For example, a breaker of 15 A at 120 V carries 1800 W, and 80% of that for a continuous load is 1440 W.
@@ -156,4 +160,4 @@ interface Scene {
156
160
  readonly layers?: Readonly<Record<string, unknown>> | undefined;
157
161
  }
158
162
  export { lengthsInRange as C, LengthUnit as S, unitsPer as T, WallFace as _, Opening as a, LARGEST_LENGTH as b, PlacedObject as c, Room as d, SCENE_SCHEMA as f, Wall as g, WALL_SIDES as h, OPENING_KINDS as i, PlanPoint as l, WALL_FACES as m, CircuitLoad as n, OpeningKind as o, Scene as p, Floor as r, Outlet as s, Circuit as t, ROOM_SCHEMA as u, WallSide as v, metersPer as w, LENGTH_UNITS as x, isLayerName as y };
159
- //# sourceMappingURL=room-x9FxGjGi.d.ts.map
163
+ //# sourceMappingURL=room-NREa6vXr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room-NREa6vXr.d.ts","names":[],"sources":["../src/units.ts","../src/room.ts"],"mappings":";;cAGa;;KAGD,qBAAqB;;iBAGjB,UAAU,MAAM;;iBAKhB,SAAS,MAAM,YAAY,OAAO;;;;;cAQrC;;iBAGG,kBAAkB;;KCrBtB;;cAGC;;cAGA;;;;;iBAMG,YAAY;;cAKf;;;;;KAMD,mBAAmB;;cAGlB;;KAGD,mBAAmB;;;;;UAMd;WACN;WACA,MAAM;WACN,IAAI;;WAEJ;;WAEA;;WAEA,OAAO;;;cAIL;;KAGD,sBAAsB;;UAGjB;WACN;;WAEA;WACA,MAAM;;WAEN;WACA;;WAEA;WACA;;;UAIM;WACN;WACA;WACA,MAAM;;;UAIA;WACN;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;WAEA;;;;;WAKA;;;UAIM;WACN,eAAe;WACf;;WAEA,MAAM;;WAEN;;WAEA;WACA,gBAAgB;WAChB,oBAAoB;WACpB,kBAAkB;WAClB,mBAAmB;WACnB,oBAAoB;;;;;;UAOd;WACN;;WAEA;WACA;;WAEA;;WAEA,IAAI;;WAEJ;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;WACA;;;UAIM;WACN,eAAe;WACf;WACA,MAAM;WACN,mBAAmB;WACnB,iBAAiB;;;;;WAKjB,SAAS,SAAS"}
package/build/sample.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as Level, x as Survey } from "./level-Cgja5fXb.js";
2
- import { d as Room, p as Scene } from "./room-x9FxGjGi.js";
1
+ import { c as Level, x as Survey } from "./level-Bmz-H5iH.js";
2
+ import { d as Room, p as Scene } from "./room-NREa6vXr.js";
3
3
  /**
4
4
  * A sample room in meters. It is not a real room.
5
5
  *
package/build/sample.js CHANGED
@@ -160,10 +160,14 @@ const SAMPLE_ROOM = {
160
160
  circuits: [{
161
161
  id: "a",
162
162
  name: "Circuit A",
163
+ breaker: 15,
164
+ voltage: 120,
163
165
  limit: 1440
164
166
  }, {
165
167
  id: "b",
166
168
  name: "Circuit B",
169
+ breaker: 15,
170
+ voltage: 120,
167
171
  limit: 1440
168
172
  }]
169
173
  };
@@ -427,10 +431,14 @@ const SAMPLE_SURVEY = {
427
431
  circuits: [{
428
432
  id: "a",
429
433
  name: "Circuit A",
434
+ breaker: 15,
435
+ voltage: 120,
430
436
  limit: 1440
431
437
  }, {
432
438
  id: "b",
433
439
  name: "Circuit B",
440
+ breaker: 15,
441
+ voltage: 120,
434
442
  limit: 1440
435
443
  }],
436
444
  objects: [
@@ -855,6 +863,8 @@ const SAMPLE_LEVEL = {
855
863
  circuits: [{
856
864
  id: "c",
857
865
  name: "Circuit C",
866
+ breaker: 15,
867
+ voltage: 120,
858
868
  limit: 1440
859
869
  }]
860
870
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sample.js","names":[],"sources":["../src/sample.ts"],"sourcesContent":["import type { Level } from \"./level.ts\";\nimport type { Room, Scene } from \"./room.ts\";\nimport type { Survey } from \"./survey.ts\";\n\n/**\n * A sample room in meters. It is not a real room.\n *\n * The outline is an L shape. Each outer wall has its line on the inner face: `side` is `right` on a counter-clockwise outline.\n * A short wall makes a nook at the top. The floor goes around that wall.\n */\nexport const SAMPLE_ROOM: Room = {\n schema: \"room/1\",\n name: \"Sample room\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n walls: [\n { id: \"south\", from: [0, 0], to: [6, 0], side: \"right\" },\n { id: \"east\", from: [6, 0], to: [6, 3], side: \"right\" },\n { id: \"inset-north\", from: [6, 3], to: [4, 3], side: \"right\" },\n { id: \"inset-east\", from: [4, 3], to: [4, 5], side: \"right\" },\n { id: \"north\", from: [4, 5], to: [0, 5], side: \"right\" },\n { id: \"west\", from: [0, 5], to: [0, 0], side: \"right\" },\n { id: \"nook\", from: [2.5, 5], to: [2.5, 3.6], thickness: 0.1 },\n ],\n openings: [\n { id: \"door\", wall: \"south\", kind: \"door\", offset: 0.6, width: 0.9, height: 2.05 },\n { id: \"window-east\", wall: \"east\", kind: \"window\", offset: 0.8, width: 1.4, sill: 0.9, height: 1.2 },\n { id: \"window-west\", wall: \"west\", kind: \"window\", offset: 1.5, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n floors: [\n {\n id: \"floor\",\n name: \"Room\",\n ring: [\n [0, 0],\n [6, 0],\n [6, 3],\n [4, 3],\n [4, 5],\n [2.55, 5],\n [2.55, 3.6],\n [2.45, 3.6],\n [2.45, 5],\n [0, 5],\n ],\n },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", face: \"left\", offset: 2.4, height: 0.3, circuit: \"a\" },\n { id: \"south-2\", wall: \"south\", face: \"left\", offset: 4.6, height: 0.3, circuit: \"a\" },\n { id: \"east-1\", wall: \"east\", face: \"left\", offset: 0.4, height: 0.3, circuit: \"a\" },\n { id: \"west-1\", wall: \"west\", face: \"left\", offset: 4.2, height: 0.3, circuit: \"a\" },\n { id: \"north-1\", wall: \"north\", face: \"left\", offset: 2.8, height: 0.3, circuit: \"a\" },\n { id: \"nook-1\", wall: \"north\", face: \"left\", offset: 0.7, height: 0.3, circuit: \"b\" },\n { id: \"nook-2\", wall: \"inset-east\", face: \"left\", offset: 1.2, height: 0.3, circuit: \"b\" },\n ],\n circuits: [\n { id: \"a\", name: \"Circuit A\", limit: 1440 },\n { id: \"b\", name: \"Circuit B\", limit: 1440 },\n ],\n};\n\n/** A sample scene of the sample room: a desk, a sofa, and a rack of four computers in the nook. Circuit B is near its limit. */\nexport const SAMPLE_SCENE: Scene = {\n schema: \"scene/1\",\n name: \"Sample scene\",\n room: SAMPLE_ROOM,\n objects: [\n { id: \"desk\", kind: \"desk\", name: \"Desk\", size: [1.6, 0.75, 0.74], at: [1.2, 4.55] },\n { id: \"display\", kind: \"display\", name: \"Display\", size: [0.6, 0.2, 0.4], at: [0, 0.2], lift: 0.74, parent: \"desk\" },\n { id: \"tower\", kind: \"computer\", name: \"Tower\", size: [0.22, 0.45, 0.45], at: [2.2, 4.6], outlet: \"north-1\" },\n { id: \"sofa\", kind: \"sofa\", name: \"Sofa\", size: [2, 0.9, 0.8], at: [4.4, 0.6] },\n { id: \"rack\", kind: \"rack\", name: \"Rack\", size: [0.6, 0.8, 1.2], at: [3.3, 4.5] },\n { id: \"node-1\", kind: \"computer\", name: \"Node 1\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.08, parent: \"rack\", outlet: \"nook-1\" },\n { id: \"node-2\", kind: \"computer\", name: \"Node 2\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.34, parent: \"rack\", outlet: \"nook-1\" },\n { id: \"node-3\", kind: \"computer\", name: \"Node 3\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.6, parent: \"rack\", outlet: \"nook-2\" },\n { id: \"node-4\", kind: \"computer\", name: \"Node 4\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.86, parent: \"rack\", outlet: \"nook-2\" },\n ],\n loads: [\n { circuit: \"a\", watts: 420 },\n { circuit: \"b\", watts: 1260 },\n ],\n};\n\n/**\n * The survey of the sample room: its six outer walls as a walk along their inner faces. The diagonal of the large part is a check.\n * It does not have the short wall of the nook, because that wall is not a side of the walk.\n * Its objects are the objects of the sample scene, each with its measurements from a wall, from the desk or from the rack.\n */\nexport const SAMPLE_SURVEY: Survey = {\n schema: \"survey/1\",\n name: \"Sample room\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 6, turn: \"left\" },\n { id: \"east\", length: 3, turn: \"left\" },\n { id: \"inset-north\", length: 2, turn: \"right\" },\n { id: \"inset-east\", length: 2, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 5, turn: \"left\" },\n ],\n checks: [{ id: \"diagonal\", from: \"south\", to: \"inset-east\", length: 5 }],\n openings: [\n { id: \"door\", wall: \"south\", kind: \"door\", offset: 0.6, width: 0.9, height: 2.05 },\n { id: \"window-east\", wall: \"east\", kind: \"window\", offset: 0.8, width: 1.4, sill: 0.9, height: 1.2 },\n { id: \"window-west\", wall: \"west\", kind: \"window\", offset: 1.5, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", offset: 2.4, height: 0.3, circuit: \"a\" },\n { id: \"south-2\", wall: \"south\", offset: 4.6, height: 0.3, circuit: \"a\" },\n { id: \"east-1\", wall: \"east\", offset: 0.4, height: 0.3, circuit: \"a\" },\n { id: \"west-1\", wall: \"west\", offset: 4.2, height: 0.3, circuit: \"a\" },\n { id: \"north-1\", wall: \"north\", offset: 2.8, height: 0.3, circuit: \"a\" },\n { id: \"nook-1\", wall: \"north\", offset: 0.7, height: 0.3, circuit: \"b\" },\n { id: \"nook-2\", wall: \"inset-east\", offset: 1.2, height: 0.3, circuit: \"b\" },\n ],\n circuits: [\n { id: \"a\", name: \"Circuit A\", limit: 1440 },\n { id: \"b\", name: \"Circuit B\", limit: 1440 },\n ],\n objects: [\n { id: \"desk\", kind: \"desk\", name: \"Desk\", wall: \"north\", offset: 2, width: 1.6, depth: 0.75, height: 0.74, gap: 0.075 },\n { id: \"display\", kind: \"display\", name: \"Display\", on: \"desk\", offset: 0.5, width: 0.6, depth: 0.2, height: 0.4, gap: 0.075 },\n { id: \"tower\", kind: \"computer\", name: \"Tower\", wall: \"north\", offset: 1.69, width: 0.22, depth: 0.45, height: 0.45, gap: 0.175, outlet: \"north-1\" },\n { id: \"sofa\", kind: \"sofa\", name: \"Sofa\", wall: \"south\", offset: 3.4, width: 2, depth: 0.9, height: 0.8, gap: 0.15 },\n { id: \"rack\", kind: \"rack\", name: \"Rack\", wall: \"north\", offset: 0.4, width: 0.6, depth: 0.8, height: 1.2, gap: 0.1 },\n { id: \"node-1\", kind: \"computer\", name: \"Node 1\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.08, outlet: \"nook-1\" },\n { id: \"node-2\", kind: \"computer\", name: \"Node 2\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.34, outlet: \"nook-1\" },\n { id: \"node-3\", kind: \"computer\", name: \"Node 3\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.6, outlet: \"nook-2\" },\n { id: \"node-4\", kind: \"computer\", name: \"Node 4\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.86, outlet: \"nook-2\" },\n ],\n};\n\n/**\n * A sample apartment in meters. It is not a real apartment.\n *\n * The living room is the sample room. A hall is below it in the plan, with a bathroom on its right. A bedroom is below the hall and the bathroom.\n * Each survey starts at its own corner, and the three doors give the places of the rooms.\n * The walk of the bathroom starts along its west wall, so the bathroom turns. A wall between two rooms has a thickness of 0.1 m.\n *\n * Each room has objects: the hall has a shelf, the bathroom has a vanity, and the bedroom has a bed and a wardrobe.\n */\nexport const SAMPLE_LEVEL: Level = {\n schema: \"level/1\",\n name: \"Sample apartment\",\n unit: \"m\",\n rooms: [\n { id: \"living\", survey: { ...SAMPLE_SURVEY, name: \"Living room\" } },\n {\n id: \"hall\",\n survey: {\n schema: \"survey/1\",\n name: \"Hall\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 4, turn: \"left\" },\n { id: \"east\", length: 1.2, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 1.2, turn: \"left\" },\n ],\n openings: [\n { id: \"bedroom\", wall: \"south\", kind: \"door\", offset: 0.4, width: 0.8, height: 2.05 },\n { id: \"bathroom\", wall: \"east\", kind: \"door\", offset: 0.2, width: 0.75, height: 2.05 },\n { id: \"living\", wall: \"north\", kind: \"door\", offset: 2.5, width: 0.9, height: 2.05 },\n { id: \"entry\", wall: \"west\", kind: \"door\", offset: 0.15, width: 0.9, height: 2.05 },\n ],\n outlets: [{ id: \"south-1\", wall: \"south\", offset: 2.6, height: 0.3, circuit: \"c\" }],\n objects: [{ id: \"shelf\", kind: \"shelf\", name: \"Shoe shelf\", wall: \"south\", offset: 1.6, width: 1.2, depth: 0.3, height: 0.9 }],\n },\n },\n {\n id: \"bathroom\",\n survey: {\n schema: \"survey/1\",\n name: \"Bathroom\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"west\", length: 2.5, turn: \"left\" },\n { id: \"south\", length: 1.9, turn: \"left\" },\n { id: \"east\", length: 2.5, turn: \"left\" },\n { id: \"north\", length: 1.9, turn: \"left\" },\n ],\n openings: [\n { id: \"door\", wall: \"west\", kind: \"door\", offset: 0.25, width: 0.75, height: 2.05 },\n { id: \"window\", wall: \"east\", kind: \"window\", offset: 0.9, width: 0.7, sill: 1.3, height: 0.8 },\n ],\n outlets: [{ id: \"east-1\", wall: \"east\", offset: 2.1, height: 1.1, circuit: \"c\" }],\n objects: [{ id: \"vanity\", kind: \"cabinet\", name: \"Vanity\", wall: \"east\", offset: 1.7, width: 0.7, depth: 0.45, height: 0.85 }],\n },\n },\n {\n id: \"bedroom\",\n survey: {\n schema: \"survey/1\",\n name: \"Bedroom\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 6, turn: \"left\" },\n { id: \"east\", length: 2.3, turn: \"left\" },\n { id: \"inset-north\", length: 2, turn: \"right\" },\n { id: \"inset-east\", length: 1.3, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 3.6, turn: \"left\" },\n ],\n openings: [\n { id: \"door\", wall: \"north\", kind: \"door\", offset: 2.8, width: 0.8, height: 2.05 },\n { id: \"window\", wall: \"south\", kind: \"window\", offset: 2.2, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", offset: 1, height: 0.3, circuit: \"c\" },\n { id: \"south-2\", wall: \"south\", offset: 5, height: 0.3, circuit: \"c\" },\n { id: \"west-1\", wall: \"west\", offset: 1.8, height: 0.3, circuit: \"c\" },\n ],\n objects: [\n { id: \"bed\", kind: \"bed\", name: \"Bed\", wall: \"west\", offset: 1, width: 1.6, depth: 2, height: 0.5 },\n { id: \"wardrobe\", kind: \"cabinet\", name: \"Wardrobe\", wall: \"east\", offset: 0.3, width: 1.8, depth: 0.6, height: 2 },\n ],\n },\n },\n ],\n connections: [\n { id: \"living-hall\", from: { room: \"living\", opening: \"door\" }, to: { room: \"hall\", opening: \"living\" }, thickness: 0.1 },\n { id: \"hall-bathroom\", from: { room: \"hall\", opening: \"bathroom\" }, to: { room: \"bathroom\", opening: \"door\" }, thickness: 0.1 },\n { id: \"hall-bedroom\", from: { room: \"hall\", opening: \"bedroom\" }, to: { room: \"bedroom\", opening: \"door\" }, thickness: 0.1 },\n ],\n circuits: [{ id: \"c\", name: \"Circuit C\", limit: 1440 }],\n};\n"],"mappings":";;;;;;;AAUA,MAAa,cAAoB;CAC/B,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;CACR,eAAe;CACf,OAAO;EACL;GAAE,IAAI;GAAS,MAAM,CAAC,GAAG,CAAC;GAAG,IAAI,CAAC,GAAG,CAAC;GAAG,MAAM;EAAQ;EAC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,IAAI;MAAU,MAAM;MAAQ,QAAQ;MAAK,QAAQ;MAAK,SAAS;KAAI;IACvE;IACA,SAAS,CACP;KAAE,IAAI;KAAO,MAAM;KAAO,MAAM;KAAO,MAAM;KAAQ,QAAQ;KAAG,OAAO;KAAK,OAAO;KAAG,QAAQ;IAAI,GAClG;KAAE,IAAI;KAAY,MAAM;KAAW,MAAM;KAAY,MAAM;KAAQ,QAAQ;KAAK,OAAO;KAAK,OAAO;KAAK,QAAQ;IAAE,CACpH;GACF;EACF;CACF;CACA,aAAa;EACX;GAAE,IAAI;GAAe,MAAM;IAAE,MAAM;IAAU,SAAS;GAAO;GAAG,IAAI;IAAE,MAAM;IAAQ,SAAS;GAAS;GAAG,WAAW;EAAI;EACxH;GAAE,IAAI;GAAiB,MAAM;IAAE,MAAM;IAAQ,SAAS;GAAW;GAAG,IAAI;IAAE,MAAM;IAAY,SAAS;GAAO;GAAG,WAAW;EAAI;EAC9H;GAAE,IAAI;GAAgB,MAAM;IAAE,MAAM;IAAQ,SAAS;GAAU;GAAG,IAAI;IAAE,MAAM;IAAW,SAAS;GAAO;GAAG,WAAW;EAAI;CAC7H;CACA,UAAU,CAAC;EAAE,IAAI;EAAK,MAAM;EAAa,OAAO;CAAK,CAAC;AACxD"}
1
+ {"version":3,"file":"sample.js","names":[],"sources":["../src/sample.ts"],"sourcesContent":["import type { Level } from \"./level.ts\";\nimport type { Room, Scene } from \"./room.ts\";\nimport type { Survey } from \"./survey.ts\";\n\n/**\n * A sample room in meters. It is not a real room.\n *\n * The outline is an L shape. Each outer wall has its line on the inner face: `side` is `right` on a counter-clockwise outline.\n * A short wall makes a nook at the top. The floor goes around that wall.\n */\nexport const SAMPLE_ROOM: Room = {\n schema: \"room/1\",\n name: \"Sample room\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n walls: [\n { id: \"south\", from: [0, 0], to: [6, 0], side: \"right\" },\n { id: \"east\", from: [6, 0], to: [6, 3], side: \"right\" },\n { id: \"inset-north\", from: [6, 3], to: [4, 3], side: \"right\" },\n { id: \"inset-east\", from: [4, 3], to: [4, 5], side: \"right\" },\n { id: \"north\", from: [4, 5], to: [0, 5], side: \"right\" },\n { id: \"west\", from: [0, 5], to: [0, 0], side: \"right\" },\n { id: \"nook\", from: [2.5, 5], to: [2.5, 3.6], thickness: 0.1 },\n ],\n openings: [\n { id: \"door\", wall: \"south\", kind: \"door\", offset: 0.6, width: 0.9, height: 2.05 },\n { id: \"window-east\", wall: \"east\", kind: \"window\", offset: 0.8, width: 1.4, sill: 0.9, height: 1.2 },\n { id: \"window-west\", wall: \"west\", kind: \"window\", offset: 1.5, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n floors: [\n {\n id: \"floor\",\n name: \"Room\",\n ring: [\n [0, 0],\n [6, 0],\n [6, 3],\n [4, 3],\n [4, 5],\n [2.55, 5],\n [2.55, 3.6],\n [2.45, 3.6],\n [2.45, 5],\n [0, 5],\n ],\n },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", face: \"left\", offset: 2.4, height: 0.3, circuit: \"a\" },\n { id: \"south-2\", wall: \"south\", face: \"left\", offset: 4.6, height: 0.3, circuit: \"a\" },\n { id: \"east-1\", wall: \"east\", face: \"left\", offset: 0.4, height: 0.3, circuit: \"a\" },\n { id: \"west-1\", wall: \"west\", face: \"left\", offset: 4.2, height: 0.3, circuit: \"a\" },\n { id: \"north-1\", wall: \"north\", face: \"left\", offset: 2.8, height: 0.3, circuit: \"a\" },\n { id: \"nook-1\", wall: \"north\", face: \"left\", offset: 0.7, height: 0.3, circuit: \"b\" },\n { id: \"nook-2\", wall: \"inset-east\", face: \"left\", offset: 1.2, height: 0.3, circuit: \"b\" },\n ],\n circuits: [\n { id: \"a\", name: \"Circuit A\", breaker: 15, voltage: 120, limit: 1440 },\n { id: \"b\", name: \"Circuit B\", breaker: 15, voltage: 120, limit: 1440 },\n ],\n};\n\n/** A sample scene of the sample room: a desk, a sofa, and a rack of four computers in the nook. Circuit B is near its limit. */\nexport const SAMPLE_SCENE: Scene = {\n schema: \"scene/1\",\n name: \"Sample scene\",\n room: SAMPLE_ROOM,\n objects: [\n { id: \"desk\", kind: \"desk\", name: \"Desk\", size: [1.6, 0.75, 0.74], at: [1.2, 4.55] },\n { id: \"display\", kind: \"display\", name: \"Display\", size: [0.6, 0.2, 0.4], at: [0, 0.2], lift: 0.74, parent: \"desk\" },\n { id: \"tower\", kind: \"computer\", name: \"Tower\", size: [0.22, 0.45, 0.45], at: [2.2, 4.6], outlet: \"north-1\" },\n { id: \"sofa\", kind: \"sofa\", name: \"Sofa\", size: [2, 0.9, 0.8], at: [4.4, 0.6] },\n { id: \"rack\", kind: \"rack\", name: \"Rack\", size: [0.6, 0.8, 1.2], at: [3.3, 4.5] },\n { id: \"node-1\", kind: \"computer\", name: \"Node 1\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.08, parent: \"rack\", outlet: \"nook-1\" },\n { id: \"node-2\", kind: \"computer\", name: \"Node 2\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.34, parent: \"rack\", outlet: \"nook-1\" },\n { id: \"node-3\", kind: \"computer\", name: \"Node 3\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.6, parent: \"rack\", outlet: \"nook-2\" },\n { id: \"node-4\", kind: \"computer\", name: \"Node 4\", size: [0.48, 0.6, 0.18], at: [0, 0], lift: 0.86, parent: \"rack\", outlet: \"nook-2\" },\n ],\n loads: [\n { circuit: \"a\", watts: 420 },\n { circuit: \"b\", watts: 1260 },\n ],\n};\n\n/**\n * The survey of the sample room: its six outer walls as a walk along their inner faces. The diagonal of the large part is a check.\n * It does not have the short wall of the nook, because that wall is not a side of the walk.\n * Its objects are the objects of the sample scene, each with its measurements from a wall, from the desk or from the rack.\n */\nexport const SAMPLE_SURVEY: Survey = {\n schema: \"survey/1\",\n name: \"Sample room\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 6, turn: \"left\" },\n { id: \"east\", length: 3, turn: \"left\" },\n { id: \"inset-north\", length: 2, turn: \"right\" },\n { id: \"inset-east\", length: 2, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 5, turn: \"left\" },\n ],\n checks: [{ id: \"diagonal\", from: \"south\", to: \"inset-east\", length: 5 }],\n openings: [\n { id: \"door\", wall: \"south\", kind: \"door\", offset: 0.6, width: 0.9, height: 2.05 },\n { id: \"window-east\", wall: \"east\", kind: \"window\", offset: 0.8, width: 1.4, sill: 0.9, height: 1.2 },\n { id: \"window-west\", wall: \"west\", kind: \"window\", offset: 1.5, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", offset: 2.4, height: 0.3, circuit: \"a\" },\n { id: \"south-2\", wall: \"south\", offset: 4.6, height: 0.3, circuit: \"a\" },\n { id: \"east-1\", wall: \"east\", offset: 0.4, height: 0.3, circuit: \"a\" },\n { id: \"west-1\", wall: \"west\", offset: 4.2, height: 0.3, circuit: \"a\" },\n { id: \"north-1\", wall: \"north\", offset: 2.8, height: 0.3, circuit: \"a\" },\n { id: \"nook-1\", wall: \"north\", offset: 0.7, height: 0.3, circuit: \"b\" },\n { id: \"nook-2\", wall: \"inset-east\", offset: 1.2, height: 0.3, circuit: \"b\" },\n ],\n circuits: [\n { id: \"a\", name: \"Circuit A\", breaker: 15, voltage: 120, limit: 1440 },\n { id: \"b\", name: \"Circuit B\", breaker: 15, voltage: 120, limit: 1440 },\n ],\n objects: [\n { id: \"desk\", kind: \"desk\", name: \"Desk\", wall: \"north\", offset: 2, width: 1.6, depth: 0.75, height: 0.74, gap: 0.075 },\n { id: \"display\", kind: \"display\", name: \"Display\", on: \"desk\", offset: 0.5, width: 0.6, depth: 0.2, height: 0.4, gap: 0.075 },\n { id: \"tower\", kind: \"computer\", name: \"Tower\", wall: \"north\", offset: 1.69, width: 0.22, depth: 0.45, height: 0.45, gap: 0.175, outlet: \"north-1\" },\n { id: \"sofa\", kind: \"sofa\", name: \"Sofa\", wall: \"south\", offset: 3.4, width: 2, depth: 0.9, height: 0.8, gap: 0.15 },\n { id: \"rack\", kind: \"rack\", name: \"Rack\", wall: \"north\", offset: 0.4, width: 0.6, depth: 0.8, height: 1.2, gap: 0.1 },\n { id: \"node-1\", kind: \"computer\", name: \"Node 1\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.08, outlet: \"nook-1\" },\n { id: \"node-2\", kind: \"computer\", name: \"Node 2\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.34, outlet: \"nook-1\" },\n { id: \"node-3\", kind: \"computer\", name: \"Node 3\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.6, outlet: \"nook-2\" },\n { id: \"node-4\", kind: \"computer\", name: \"Node 4\", on: \"rack\", offset: 0.06, width: 0.48, depth: 0.6, height: 0.18, gap: 0.1, lift: 0.86, outlet: \"nook-2\" },\n ],\n};\n\n/**\n * A sample apartment in meters. It is not a real apartment.\n *\n * The living room is the sample room. A hall is below it in the plan, with a bathroom on its right. A bedroom is below the hall and the bathroom.\n * Each survey starts at its own corner, and the three doors give the places of the rooms.\n * The walk of the bathroom starts along its west wall, so the bathroom turns. A wall between two rooms has a thickness of 0.1 m.\n *\n * Each room has objects: the hall has a shelf, the bathroom has a vanity, and the bedroom has a bed and a wardrobe.\n */\nexport const SAMPLE_LEVEL: Level = {\n schema: \"level/1\",\n name: \"Sample apartment\",\n unit: \"m\",\n rooms: [\n { id: \"living\", survey: { ...SAMPLE_SURVEY, name: \"Living room\" } },\n {\n id: \"hall\",\n survey: {\n schema: \"survey/1\",\n name: \"Hall\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 4, turn: \"left\" },\n { id: \"east\", length: 1.2, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 1.2, turn: \"left\" },\n ],\n openings: [\n { id: \"bedroom\", wall: \"south\", kind: \"door\", offset: 0.4, width: 0.8, height: 2.05 },\n { id: \"bathroom\", wall: \"east\", kind: \"door\", offset: 0.2, width: 0.75, height: 2.05 },\n { id: \"living\", wall: \"north\", kind: \"door\", offset: 2.5, width: 0.9, height: 2.05 },\n { id: \"entry\", wall: \"west\", kind: \"door\", offset: 0.15, width: 0.9, height: 2.05 },\n ],\n outlets: [{ id: \"south-1\", wall: \"south\", offset: 2.6, height: 0.3, circuit: \"c\" }],\n objects: [{ id: \"shelf\", kind: \"shelf\", name: \"Shoe shelf\", wall: \"south\", offset: 1.6, width: 1.2, depth: 0.3, height: 0.9 }],\n },\n },\n {\n id: \"bathroom\",\n survey: {\n schema: \"survey/1\",\n name: \"Bathroom\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"west\", length: 2.5, turn: \"left\" },\n { id: \"south\", length: 1.9, turn: \"left\" },\n { id: \"east\", length: 2.5, turn: \"left\" },\n { id: \"north\", length: 1.9, turn: \"left\" },\n ],\n openings: [\n { id: \"door\", wall: \"west\", kind: \"door\", offset: 0.25, width: 0.75, height: 2.05 },\n { id: \"window\", wall: \"east\", kind: \"window\", offset: 0.9, width: 0.7, sill: 1.3, height: 0.8 },\n ],\n outlets: [{ id: \"east-1\", wall: \"east\", offset: 2.1, height: 1.1, circuit: \"c\" }],\n objects: [{ id: \"vanity\", kind: \"cabinet\", name: \"Vanity\", wall: \"east\", offset: 1.7, width: 0.7, depth: 0.45, height: 0.85 }],\n },\n },\n {\n id: \"bedroom\",\n survey: {\n schema: \"survey/1\",\n name: \"Bedroom\",\n unit: \"m\",\n height: 2.5,\n wallThickness: 0.15,\n sides: [\n { id: \"south\", length: 6, turn: \"left\" },\n { id: \"east\", length: 2.3, turn: \"left\" },\n { id: \"inset-north\", length: 2, turn: \"right\" },\n { id: \"inset-east\", length: 1.3, turn: \"left\" },\n { id: \"north\", length: 4, turn: \"left\" },\n { id: \"west\", length: 3.6, turn: \"left\" },\n ],\n openings: [\n { id: \"door\", wall: \"north\", kind: \"door\", offset: 2.8, width: 0.8, height: 2.05 },\n { id: \"window\", wall: \"south\", kind: \"window\", offset: 2.2, width: 1.6, sill: 0.9, height: 1.2 },\n ],\n outlets: [\n { id: \"south-1\", wall: \"south\", offset: 1, height: 0.3, circuit: \"c\" },\n { id: \"south-2\", wall: \"south\", offset: 5, height: 0.3, circuit: \"c\" },\n { id: \"west-1\", wall: \"west\", offset: 1.8, height: 0.3, circuit: \"c\" },\n ],\n objects: [\n { id: \"bed\", kind: \"bed\", name: \"Bed\", wall: \"west\", offset: 1, width: 1.6, depth: 2, height: 0.5 },\n { id: \"wardrobe\", kind: \"cabinet\", name: \"Wardrobe\", wall: \"east\", offset: 0.3, width: 1.8, depth: 0.6, height: 2 },\n ],\n },\n },\n ],\n connections: [\n { id: \"living-hall\", from: { room: \"living\", opening: \"door\" }, to: { room: \"hall\", opening: \"living\" }, thickness: 0.1 },\n { id: \"hall-bathroom\", from: { room: \"hall\", opening: \"bathroom\" }, to: { room: \"bathroom\", opening: \"door\" }, thickness: 0.1 },\n { id: \"hall-bedroom\", from: { room: \"hall\", opening: \"bedroom\" }, to: { room: \"bedroom\", opening: \"door\" }, thickness: 0.1 },\n ],\n circuits: [{ id: \"c\", name: \"Circuit C\", breaker: 15, voltage: 120, limit: 1440 }],\n};\n"],"mappings":";;;;;;;AAUA,MAAa,cAAoB;CAC/B,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;CACR,eAAe;CACf,OAAO;EACL;GAAE,IAAI;GAAS,MAAM,CAAC,GAAG,CAAC;GAAG,IAAI,CAAC,GAAG,CAAC;GAAG,MAAM;EAAQ;EACvD;GAAE,IAAI;GAAQ,MAAM,CAAC,GAAG,CAAC;GAAG,IAAI,CAAC,GAAG,CAAC;GAAG,MAAM;EAAQ;EACtD;GAAE,IAAI;GAAe,MAAM,CAAC,GAAG,CAAC;GAAG,IAAI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;IACvE;IACA,SAAS,CACP;KAAE,IAAI;KAAO,MAAM;KAAO,MAAM;KAAO,MAAM;KAAQ,QAAQ;KAAG,OAAO;KAAK,OAAO;KAAG,QAAQ;IAAI,GAClG;KAAE,IAAI;KAAY,MAAM;KAAW,MAAM;KAAY,MAAM;KAAQ,QAAQ;KAAK,OAAO;KAAK,OAAO;KAAK,QAAQ;IAAE,CACpH;GACF;EACF;CACF;CACA,aAAa;EACX;GAAE,IAAI;GAAe,MAAM;IAAE,MAAM;IAAU,SAAS;GAAO;GAAG,IAAI;IAAE,MAAM;IAAQ,SAAS;GAAS;GAAG,WAAW;EAAI;EACxH;GAAE,IAAI;GAAiB,MAAM;IAAE,MAAM;IAAQ,SAAS;GAAW;GAAG,IAAI;IAAE,MAAM;IAAY,SAAS;GAAO;GAAG,WAAW;EAAI;EAC9H;GAAE,IAAI;GAAgB,MAAM;IAAE,MAAM;IAAQ,SAAS;GAAU;GAAG,IAAI;IAAE,MAAM;IAAW,SAAS;GAAO;GAAG,WAAW;EAAI;CAC7H;CACA,UAAU,CAAC;EAAE,IAAI;EAAK,MAAM;EAAa,SAAS;EAAI,SAAS;EAAK,OAAO;CAAK,CAAC;AACnF"}
package/build/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as Level, x as Survey } from "./level-Cgja5fXb.js";
2
- import { d as Room, p as Scene } from "./room-x9FxGjGi.js";
1
+ import { c as Level, x as Survey } from "./level-Bmz-H5iH.js";
2
+ import { d as Room, p as Scene } from "./room-NREa6vXr.js";
3
3
  import { z } from "zod";
4
4
  /**
5
5
  * The schema of a room record. It examines the form of the record: the fields, their types and the finite numbers.
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":[],"sources":["../src/schema.ts"],"mappings":";;;;;;;qBAqDa,YAAY,EAAE,QAAQ;;;;;qBAkCtB,aAAa,EAAE,QAAQ;;;;;qBAoDvB,cAAc,EAAE,QAAQ;;;;;qBAyBxB,aAAa,EAAE,QAAQ"}
1
+ {"version":3,"file":"schema.d.ts","names":[],"sources":["../src/schema.ts"],"mappings":";;;;;;;qBAuDa,YAAY,EAAE,QAAQ;;;;;qBAkCtB,aAAa,EAAE,QAAQ;;;;;qBAoDvB,cAAc,EAAE,QAAQ;;;;;qBAyBxB,aAAa,EAAE,QAAQ"}
package/build/schema.js CHANGED
@@ -37,6 +37,8 @@ const outlet = z.strictObject({
37
37
  const circuit = z.strictObject({
38
38
  id,
39
39
  name: z.string().optional(),
40
+ breaker: z.number().optional(),
41
+ voltage: z.number().optional(),
40
42
  limit: z.number()
41
43
  });
42
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { LEVEL_SCHEMA, type Level } from \"./level.ts\";\nimport { isLayerName, OPENING_KINDS, ROOM_SCHEMA, SCENE_SCHEMA, WALL_FACES, WALL_SIDES, type Room, type Scene } from \"./room.ts\";\nimport { SQUARE_TURNS, SURVEY_SCHEMA, type Survey } from \"./survey.ts\";\nimport { LENGTH_UNITS } from \"./units.ts\";\n\nconst id = z.string().min(1);\nconst planPoint = z.tuple([z.number(), z.number()]).readonly();\n\nconst wall = z.strictObject({\n id,\n from: planPoint,\n to: planPoint,\n thickness: z.number().optional(),\n height: z.number().optional(),\n side: z.enum(WALL_SIDES).optional(),\n});\n\nconst opening = z.strictObject({\n id,\n wall: id,\n kind: z.enum(OPENING_KINDS),\n offset: z.number(),\n width: z.number(),\n sill: z.number().optional(),\n height: z.number(),\n});\n\nconst floor = z.strictObject({\n id,\n name: z.string().optional(),\n ring: z.array(planPoint).readonly(),\n});\n\nconst outlet = z.strictObject({\n id,\n wall: id,\n face: z.enum(WALL_FACES),\n offset: z.number(),\n height: z.number(),\n circuit: id.optional(),\n});\n\nconst circuit = z.strictObject({\n id,\n name: z.string().optional(),\n limit: z.number(),\n});\n\n/**\n * The schema of a room record. It examines the form of the record: the fields, their types and the finite numbers.\n * It refuses a field that the format does not have. `checkRoom` examines the meaning of a record with a correct form.\n */\nexport const roomSchema: z.ZodType<Room> = z.strictObject({\n schema: z.literal(ROOM_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n height: z.number(),\n wallThickness: z.number(),\n walls: z.array(wall).readonly(),\n openings: z.array(opening).readonly().optional(),\n floors: z.array(floor).readonly().optional(),\n outlets: z.array(outlet).readonly().optional(),\n circuits: z.array(circuit).readonly().optional(),\n});\n\nconst placedObject = z.strictObject({\n id,\n kind: z.string().min(1),\n name: z.string().optional(),\n size: z.tuple([z.number(), z.number(), z.number()]).readonly(),\n at: planPoint,\n lift: z.number().optional(),\n turn: z.number().optional(),\n parent: id.optional(),\n outlet: id.optional(),\n});\n\nconst circuitLoad = z.strictObject({\n circuit: id,\n watts: z.number(),\n});\n\n/**\n * The schema of a scene record. It examines the form of the record, and it refuses a field that the format does not have.\n * `checkScene` examines the meaning of a record with a correct form.\n */\nexport const sceneSchema: z.ZodType<Scene> = z.strictObject({\n schema: z.literal(SCENE_SCHEMA),\n name: z.string().optional(),\n room: roomSchema,\n objects: z.array(placedObject).readonly().optional(),\n loads: z.array(circuitLoad).readonly().optional(),\n // The core does not read a layer, so it keeps each value. The add-on of a layer examines its form.\n layers: z.record(z.string().refine(isLayerName, \"A layer name is a word, a slash and a version, for example electrical/1.\"), z.unknown()).readonly().optional(),\n});\n\nconst surveySide = z.strictObject({\n id,\n length: z.number(),\n turn: z.union([z.enum(SQUARE_TURNS), z.number()]),\n thickness: z.number().optional(),\n height: z.number().optional(),\n});\n\nconst surveyCheck = z.strictObject({\n id,\n from: id,\n to: id,\n length: z.number(),\n});\n\nconst surveyOutlet = z.strictObject({\n id,\n wall: id,\n offset: z.number(),\n height: z.number(),\n circuit: id.optional(),\n});\n\nconst surveyObject = z.strictObject({\n id,\n kind: z.string().min(1),\n name: z.string().optional(),\n wall: id.optional(),\n on: id.optional(),\n offset: z.number(),\n width: z.number(),\n depth: z.number(),\n height: z.number(),\n gap: z.number().optional(),\n lift: z.number().optional(),\n outlet: id.optional(),\n});\n\n/**\n * The schema of a survey record. It examines the form of the record, and it refuses a field that the format does not have.\n * `expandSurvey` makes the room record of a survey with a correct form, and `checkRoom` examines that room record.\n */\nexport const surveySchema: z.ZodType<Survey> = z.strictObject({\n schema: z.literal(SURVEY_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n height: z.number(),\n wallThickness: z.number(),\n sides: z.array(surveySide).readonly(),\n start: planPoint.optional(),\n heading: z.number().optional(),\n checks: z.array(surveyCheck).readonly().optional(),\n openings: z.array(opening).readonly().optional(),\n outlets: z.array(surveyOutlet).readonly().optional(),\n circuits: z.array(circuit).readonly().optional(),\n objects: z.array(surveyObject).readonly().optional(),\n});\n\nconst connectionEnd = z.strictObject({\n room: id,\n opening: id,\n});\n\n/**\n * The schema of a level record. It examines the form of the record and of each survey, and it refuses a field that the format does not have.\n * `expandLevel` makes the room record of a level with a correct form, and `checkRoom` examines that room record.\n */\nexport const levelSchema: z.ZodType<Level> = z.strictObject({\n schema: z.literal(LEVEL_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n rooms: z.array(z.strictObject({ id, survey: surveySchema })).readonly(),\n connections: z\n .array(z.strictObject({ id, from: connectionEnd, to: connectionEnd, thickness: z.number().optional() }))\n .readonly()\n .optional(),\n circuits: z.array(circuit).readonly().optional(),\n});\n"],"mappings":";;;;AAMA,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC3B,MAAM,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;AAE7D,MAAM,OAAO,EAAE,aAAa;CAC1B;CACA,MAAM;CACN,IAAI;CACJ,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,MAAM,EAAE,KAAK,UAAU,CAAC,CAAC,SAAS;AACpC,C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O,CAAC,CAAC,SAAS;CAC1B,MAAM,EAAE,KAAK,YAAY;CACzB,OAAO,EAAE,MAAM,EAAE,aAAa;EAAE;EAAI,QAAQ;CAAa,CAAC,CAAC,CAAC,CAAC,SAAS;CACtE,aAAa,EACV,MAAM,EAAE,aAAa;EAAE;EAAI,MAAM;EAAe,IAAI;EAAe,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC,CAAC,CAAC,CACvG,SAAS,CAAC,CACV,SAAS;CACZ,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AACjD,CAAC"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { LEVEL_SCHEMA, type Level } from \"./level.ts\";\nimport { isLayerName, OPENING_KINDS, ROOM_SCHEMA, SCENE_SCHEMA, WALL_FACES, WALL_SIDES, type Room, type Scene } from \"./room.ts\";\nimport { SQUARE_TURNS, SURVEY_SCHEMA, type Survey } from \"./survey.ts\";\nimport { LENGTH_UNITS } from \"./units.ts\";\n\nconst id = z.string().min(1);\nconst planPoint = z.tuple([z.number(), z.number()]).readonly();\n\nconst wall = z.strictObject({\n id,\n from: planPoint,\n to: planPoint,\n thickness: z.number().optional(),\n height: z.number().optional(),\n side: z.enum(WALL_SIDES).optional(),\n});\n\nconst opening = z.strictObject({\n id,\n wall: id,\n kind: z.enum(OPENING_KINDS),\n offset: z.number(),\n width: z.number(),\n sill: z.number().optional(),\n height: z.number(),\n});\n\nconst floor = z.strictObject({\n id,\n name: z.string().optional(),\n ring: z.array(planPoint).readonly(),\n});\n\nconst outlet = z.strictObject({\n id,\n wall: id,\n face: z.enum(WALL_FACES),\n offset: z.number(),\n height: z.number(),\n circuit: id.optional(),\n});\n\nconst circuit = z.strictObject({\n id,\n name: z.string().optional(),\n breaker: z.number().optional(),\n voltage: z.number().optional(),\n limit: z.number(),\n});\n\n/**\n * The schema of a room record. It examines the form of the record: the fields, their types and the finite numbers.\n * It refuses a field that the format does not have. `checkRoom` examines the meaning of a record with a correct form.\n */\nexport const roomSchema: z.ZodType<Room> = z.strictObject({\n schema: z.literal(ROOM_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n height: z.number(),\n wallThickness: z.number(),\n walls: z.array(wall).readonly(),\n openings: z.array(opening).readonly().optional(),\n floors: z.array(floor).readonly().optional(),\n outlets: z.array(outlet).readonly().optional(),\n circuits: z.array(circuit).readonly().optional(),\n});\n\nconst placedObject = z.strictObject({\n id,\n kind: z.string().min(1),\n name: z.string().optional(),\n size: z.tuple([z.number(), z.number(), z.number()]).readonly(),\n at: planPoint,\n lift: z.number().optional(),\n turn: z.number().optional(),\n parent: id.optional(),\n outlet: id.optional(),\n});\n\nconst circuitLoad = z.strictObject({\n circuit: id,\n watts: z.number(),\n});\n\n/**\n * The schema of a scene record. It examines the form of the record, and it refuses a field that the format does not have.\n * `checkScene` examines the meaning of a record with a correct form.\n */\nexport const sceneSchema: z.ZodType<Scene> = z.strictObject({\n schema: z.literal(SCENE_SCHEMA),\n name: z.string().optional(),\n room: roomSchema,\n objects: z.array(placedObject).readonly().optional(),\n loads: z.array(circuitLoad).readonly().optional(),\n // The core does not read a layer, so it keeps each value. The add-on of a layer examines its form.\n layers: z.record(z.string().refine(isLayerName, \"A layer name is a word, a slash and a version, for example electrical/1.\"), z.unknown()).readonly().optional(),\n});\n\nconst surveySide = z.strictObject({\n id,\n length: z.number(),\n turn: z.union([z.enum(SQUARE_TURNS), z.number()]),\n thickness: z.number().optional(),\n height: z.number().optional(),\n});\n\nconst surveyCheck = z.strictObject({\n id,\n from: id,\n to: id,\n length: z.number(),\n});\n\nconst surveyOutlet = z.strictObject({\n id,\n wall: id,\n offset: z.number(),\n height: z.number(),\n circuit: id.optional(),\n});\n\nconst surveyObject = z.strictObject({\n id,\n kind: z.string().min(1),\n name: z.string().optional(),\n wall: id.optional(),\n on: id.optional(),\n offset: z.number(),\n width: z.number(),\n depth: z.number(),\n height: z.number(),\n gap: z.number().optional(),\n lift: z.number().optional(),\n outlet: id.optional(),\n});\n\n/**\n * The schema of a survey record. It examines the form of the record, and it refuses a field that the format does not have.\n * `expandSurvey` makes the room record of a survey with a correct form, and `checkRoom` examines that room record.\n */\nexport const surveySchema: z.ZodType<Survey> = z.strictObject({\n schema: z.literal(SURVEY_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n height: z.number(),\n wallThickness: z.number(),\n sides: z.array(surveySide).readonly(),\n start: planPoint.optional(),\n heading: z.number().optional(),\n checks: z.array(surveyCheck).readonly().optional(),\n openings: z.array(opening).readonly().optional(),\n outlets: z.array(surveyOutlet).readonly().optional(),\n circuits: z.array(circuit).readonly().optional(),\n objects: z.array(surveyObject).readonly().optional(),\n});\n\nconst connectionEnd = z.strictObject({\n room: id,\n opening: id,\n});\n\n/**\n * The schema of a level record. It examines the form of the record and of each survey, and it refuses a field that the format does not have.\n * `expandLevel` makes the room record of a level with a correct form, and `checkRoom` examines that room record.\n */\nexport const levelSchema: z.ZodType<Level> = z.strictObject({\n schema: z.literal(LEVEL_SCHEMA),\n name: z.string().optional(),\n unit: z.enum(LENGTH_UNITS),\n rooms: z.array(z.strictObject({ id, survey: surveySchema })).readonly(),\n connections: z\n .array(z.strictObject({ id, from: connectionEnd, to: connectionEnd, thickness: z.number().optional() }))\n .readonly()\n .optional(),\n circuits: z.array(circuit).readonly().optional(),\n});\n"],"mappings":";;;;AAMA,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC3B,MAAM,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;AAE7D,MAAM,OAAO,EAAE,aAAa;CAC1B;CACA,MAAM;CACN,IAAI;CACJ,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAC/B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,MAAM,EAAE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ACnC,MAAM;CACN,SAAS;AACX,CAAC;;;;;AAMD,MAAa,cAAgC,EAAE,aAAa;CAC1D,QAAQ,EAAE,QAAQ,YAAY;CAC9B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAM,EAAE,KAAK,YAAY;CACzB,OAAO,EAAE,MAAM,EAAE,aAAa;EAAE;EAAI,QAAQ;CAAa,CAAC,CAAC,CAAC,CAAC,SAAS;CACtE,aAAa,EACV,MAAM,EAAE,aAAa;EAAE;EAAI,MAAM;EAAe,IAAI;EAAe,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC,CAAC,CAAC,CACvG,SAAS,CAAC,CACV,SAAS;CACZ,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AACjD,CAAC"}
package/build/three.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SolidOptions, a as LoadLevel, b as Solid, o as LoadOptions, x as SolidKind } from "./loads-spBbQkb0.js";
2
- import { p as Scene$1 } from "./room-x9FxGjGi.js";
1
+ import { S as SolidOptions, a as LoadLevel, b as Solid, o as LoadOptions, x as SolidKind } from "./loads-C3Nrj3Gd.js";
2
+ import { p as Scene$1 } from "./room-NREa6vXr.js";
3
3
  import { Point3, Rotation3 } from "@mark1russell7/layout-contract";
4
4
  import { BufferGeometry } from "three";
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/room-view",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "description": "A room as data, and its 3D model from that data: walls with openings, floors, outlets, circuits and placed objects.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"room-x9FxGjGi.d.ts","names":[],"sources":["../src/units.ts","../src/room.ts"],"mappings":";;cAGa;;KAGD,qBAAqB;;iBAGjB,UAAU,MAAM;;iBAKhB,SAAS,MAAM,YAAY,OAAO;;;;;cAQrC;;iBAGG,kBAAkB;;KCrBtB;;cAGC;;cAGA;;;;;iBAMG,YAAY;;cAKf;;;;;KAMD,mBAAmB;;cAGlB;;KAGD,mBAAmB;;;;;UAMd;WACN;WACA,MAAM;WACN,IAAI;;WAEJ;;WAEA;;WAEA,OAAO;;;cAIL;;KAGD,sBAAsB;;UAGjB;WACN;;WAEA;WACA,MAAM;;WAEN;WACA;;WAEA;WACA;;;UAIM;WACN;WACA;WACA,MAAM;;;UAIA;WACN;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;;;;WAKA;;;UAIM;WACN,eAAe;WACf;;WAEA,MAAM;;WAEN;;WAEA;WACA,gBAAgB;WAChB,oBAAoB;WACpB,kBAAkB;WAClB,mBAAmB;WACnB,oBAAoB;;;;;;UAOd;WACN;;WAEA;WACA;;WAEA;;WAEA,IAAI;;WAEJ;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;WACA;;;UAIM;WACN,eAAe;WACf;WACA,MAAM;WACN,mBAAmB;WACnB,iBAAiB;;;;;WAKjB,SAAS,SAAS"}