@mark1russell7/packing 0.1.5 → 0.1.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["rowsOf","boxesOf","rowsOf","shapeOf"],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/shelf.ts","../src/skyline.ts","../src/pack.ts","../src/free.ts","../src/push.ts","../src/contract.ts","../src/sha256.ts","../src/layout-input.ts","../src/measures.ts","../src/metrics.ts","../src/strategy.ts","../src/frame.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/check.ts","../src/generators.ts","../src/corpus.ts"],"sourcesContent":["/** A mutable two-dimensional vector. */\nexport class Vector {\n #x: number;\n #y: number;\n\n constructor(x = 0, y = 0) {\n this.#x = x;\n this.#y = y;\n }\n\n /** The first component: a width or a left position. */\n get x(): number { return this.#x; }\n set x(v: number) { this.#x = v; }\n /** The second component: a height or a top position. */\n get y(): number { return this.#y; }\n set y(v: number) { this.#y = v; }\n\n /** This method sets both components. */\n set(x: number, y: number): void {\n this.#x = x;\n this.#y = y;\n }\n\n /** This method copies the components of another vector. */\n setTo(v: Vector): void {\n this.#x = v.x;\n this.#y = v.y;\n }\n\n /** This method gives a new vector: the sum of this vector and another. */\n add(other: Vector): Vector {\n return new Vector(this.#x + other.x, this.#y + other.y);\n }\n\n /** This method gives the product of the components: the area of a size. */\n area(): number {\n return this.#x * this.#y;\n }\n\n /** This method gives a new vector with the same components. */\n clone(): Vector {\n return new Vector(this.#x, this.#y);\n }\n\n /** This method gives a new vector with each component between the components of `min` and `max`. */\n clamp(min: Vector, max: Vector): Vector {\n return new Vector(\n Math.max(min.x, Math.min(max.x, this.#x)),\n Math.max(min.y, Math.min(max.y, this.#y)),\n );\n }\n\n /** This function gives a vector with the same value in both components. */\n static of(scalar: number): Vector {\n return new Vector(scalar, scalar);\n }\n\n /** This function gives the smallest value of each component, or a zero vector for an empty list. */\n static min(vectors: Vector[]): Vector {\n if (!vectors.length) return new Vector();\n return new Vector(\n Math.min(...vectors.map((v) => v.x)),\n Math.min(...vectors.map((v) => v.y)),\n );\n }\n\n /** This function gives the largest value of each component, or a zero vector for an empty list. */\n static max(vectors: Vector[]): Vector {\n if (!vectors.length) return new Vector();\n return new Vector(\n Math.max(...vectors.map((v) => v.x)),\n Math.max(...vectors.map((v) => v.y)),\n );\n }\n\n /** This getter gives a new infinite vector each time. A shared value is not safe, because a vector is mutable. */\n static get Infinity(): Vector {\n return new Vector(Infinity, Infinity);\n }\n}\n","import { Vector } from \"./vector.ts\";\n\n/** A rectangle of the packer. `id` identifies the item that it measures. The packer sets `position` and `wasPacked`. */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- the parameter types the id of the caller\nexport class Rect<T = unknown> {\n readonly #position = new Vector();\n readonly #size = new Vector();\n\n /** The identity of the item that the rectangle measures. */\n id?: T;\n /** The packer sets this field to `true` when it places the rectangle. */\n wasPacked = false;\n /** For an outer rectangle: the packer keeps its width. */\n fixedWidth = false;\n /** For an outer rectangle: the packer keeps its width and its height, and it skips a rectangle that does not fit. */\n fixedSize = false;\n /**\n * The packer keeps the position of a locked rectangle. `packSkyline` packs the other rectangles around it.\n * `packRows` only keeps its position, and other rectangles can overlap it.\n */\n locked = false;\n\n /** The top left corner. */\n get position(): Vector { return this.#position; }\n /** The width and the height. */\n get size(): Vector { return this.#size; }\n\n /** This method gives the right edge. */\n right(): number { return this.#position.x + this.#size.x; }\n /** This method gives the bottom edge. */\n bottom(): number { return this.#position.y + this.#size.y; }\n\n /** This method moves the left edge to the right by an amount, and the right edge stays. */\n shrinkLeft(amount: number): this {\n this.#position.x += amount;\n this.#size.x -= amount;\n return this;\n }\n\n /** This method moves the rectangle by an offset. */\n translateBy(offset: Vector): this {\n this.#position.set(this.#position.x + offset.x, this.#position.y + offset.y);\n return this;\n }\n\n /** This method gives the area of the size. */\n area(): number { return this.#size.area(); }\n\n /** This function gives the rectangles that the packer placed. */\n static packed<U>(rects: Rect<U>[]): Rect<U>[] {\n return rects.filter((r) => r.wasPacked);\n }\n\n /** This function gives the rectangles that the packer did not place. */\n static unpacked<U>(rects: Rect<U>[]): Rect<U>[] {\n return rects.filter((r) => !r.wasPacked);\n }\n\n /** This function marks each rectangle as not placed. A locked rectangle stays placed. */\n static resetPacked<U>(rects: Rect<U>[]): void {\n for (const r of rects) r.wasPacked = r.locked;\n }\n\n /** This function gives the largest right edge, or 0 for an empty list. */\n static maxRight<U>(rects: Rect<U>[]): number {\n return rects.reduce((acc, r) => Math.max(acc, r.right()), 0);\n }\n\n /** This function gives the largest bottom edge, or 0 for an empty list. */\n static maxBottom<U>(rects: Rect<U>[]): number {\n return rects.reduce((acc, r) => Math.max(acc, r.bottom()), 0);\n }\n}\n","import type { Rect } from \"./rect.ts\";\n\n/**\n * An order of the rectangles before the packing. The order changes the layout much. `input` keeps the order of\n * the array of the caller: the row packing then fills no gaps, so its rows read in that order.\n */\nexport type SortOrder = \"height-desc\" | \"height-asc\" | \"width-desc\" | \"area-desc\" | \"input\";\n\n/** This constant lists each sort order. The first one is the default. */\nexport const SORT_ORDERS: readonly SortOrder[] = [\"height-desc\", \"height-asc\", \"width-desc\", \"area-desc\", \"input\"];\n\n/** This function gives the comparator of a sort order. The sort is stable, so `input` keeps the order. */\nexport function compareRects(order: SortOrder): <T>(a: Rect<T>, b: Rect<T>) => number {\n switch (order) {\n case \"height-desc\":\n return (a, b) => b.size.y - a.size.y;\n case \"height-asc\":\n return (a, b) => a.size.y - b.size.y;\n case \"width-desc\":\n return (a, b) => b.size.x - a.size.x;\n case \"area-desc\":\n return (a, b) => b.area() - a.area();\n case \"input\":\n return () => 0;\n }\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/** The options of `packShelf` */\nexport interface ShelfOptions {\n /** The order of the rectangles before the packing. The default is `height-desc`. */\n sortOrder?: SortOrder;\n}\n\n/** An obstacle in the coordinates of the outer rectangle */\ninterface Box {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\n/**\n * This function gives the first x from `start` where a rectangle of width `w` crosses no obstacle in the band from\n * `top` to `bottom`.\n */\nfunction firstFreeX(obstacles: readonly Box[], start: number, w: number, top: number, bottom: number): number {\n let x = start;\n let moved = true;\n while (moved) {\n moved = false;\n for (const o of obstacles) {\n if (o.top < bottom && top < o.bottom && o.left < x + w && x < o.right) {\n x = o.right;\n moved = true;\n }\n }\n }\n return x;\n}\n\n/** This function gives the lowest bottom edge of the obstacles in the band from `top` to `bottom`, under `top`. */\nfunction nextTop(obstacles: readonly Box[], top: number, bottom: number): number {\n let next = Infinity;\n for (const o of obstacles) if (o.top < bottom && top < o.bottom && o.bottom > top) next = Math.min(next, o.bottom);\n return next;\n}\n\n/**\n * This function packs rectangles into shelves: rows that it fills left to right in the sort order, and does not fill\n * again. It goes around each `locked` rectangle. It sets the position of each rectangle and gives the outer rectangle.\n *\n * - With the sort order `input`, the rows read in the order of the array: left to right, and top to bottom.\n * - With `height-desc` (the default), it is the classic Next-Fit Decreasing Height packing.\n * - A rectangle goes to the first x in the row where it crosses no locked rectangle. If no such x is in the width,\n * a new row starts under the current row.\n * - A rectangle wider than the outer rectangle goes on its own row, at the left edge, and overflows.\n * - It does not change the width. Without `fixedSize`, the height grows to the content. With `fixedSize`, a\n * rectangle that does not fit is not packed: its `wasPacked` stays `false`.\n */\nexport function packShelf<T>(rects: Rect<T>[], outer: Rect<T>, options: ShelfOptions = {}): Rect<T> {\n const width = outer.size.x;\n const obstacles: Box[] = [];\n let contentBottom = 0;\n for (const rect of rects) {\n if (!rect.locked) continue;\n rect.wasPacked = true;\n const left = rect.position.x - outer.position.x;\n const top = rect.position.y - outer.position.y;\n obstacles.push({ left, top, right: left + rect.size.x, bottom: top + rect.size.y });\n contentBottom = Math.max(contentBottom, top + rect.size.y);\n }\n\n let rowTop = 0;\n let rowBottom = 0;\n let cursor = 0;\n let rowEmpty = true;\n\n for (const rect of rects.toSorted(compareRects(options.sortOrder ?? \"height-desc\"))) {\n if (rect.wasPacked) continue;\n const w = rect.size.x;\n const h = rect.size.y;\n if (!(w > 0 && h > 0)) continue;\n const overflows = w > width;\n if (overflows && outer.fixedSize) continue;\n\n // An overflowing rectangle starts a row of its own\n if (overflows && !rowEmpty) {\n rowTop = rowBottom;\n cursor = 0;\n rowEmpty = true;\n }\n\n let x = firstFreeX(obstacles, cursor, w, rowTop, rowTop + h);\n while (!overflows && x + w > width) {\n // Start a new row under the current one, or under the obstacles that block an empty row\n rowTop = rowEmpty ? nextTop(obstacles, rowTop, rowTop + h) : rowBottom;\n rowBottom = rowTop;\n cursor = 0;\n rowEmpty = true;\n x = firstFreeX(obstacles, cursor, w, rowTop, rowTop + h);\n }\n while (overflows && x !== 0) {\n rowTop = nextTop(obstacles, rowTop, rowTop + h);\n rowBottom = rowTop;\n x = firstFreeX(obstacles, 0, w, rowTop, rowTop + h);\n }\n\n if (outer.fixedSize && rowTop + h > outer.size.y) continue;\n\n rect.position.set(x + outer.position.x, rowTop + outer.position.y);\n rect.wasPacked = true;\n rowEmpty = false;\n cursor = x + w;\n rowBottom = Math.max(rowBottom, rowTop + h);\n contentBottom = Math.max(contentBottom, rowTop + h);\n if (overflows) {\n rowTop = rowBottom;\n cursor = 0;\n rowEmpty = true;\n }\n }\n\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, contentBottom);\n return outer;\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/**\n * This function finds the lowest window of width `rw` on a skyline. For each `x` in `[0, width - rw]`, the height\n * of the window is the largest value of `skyline[x, x + rw)`. The first `x` with the smallest height wins. A\n * monotonic deque makes the search O(width) for one rectangle.\n */\nexport function lowestWindow(skyline: ArrayLike<number>, width: number, rw: number): { x: number; y: number } {\n const deque = new Int32Array(width);\n let head = 0;\n let tail = 0;\n let bestX = 0;\n let bestY = Infinity;\n for (let i = 0; i < width; i++) {\n while (tail > head && skyline[deque[tail - 1]!]! <= skyline[i]!) tail--;\n deque[tail++] = i;\n if (deque[head]! <= i - rw) head++;\n if (i >= rw - 1) {\n const max = skyline[deque[head]!]!;\n if (max < bestY) {\n bestY = max;\n bestX = i - rw + 1;\n }\n }\n }\n return { x: bestX, y: bestY };\n}\n\n/**\n * This function packs rectangles into an outer rectangle with a skyline. It puts each rectangle in the lowest place\n * where it fits, and it does not change the width of the outer rectangle.\n *\n * - A `locked` rectangle keeps its position. The skyline starts at its bottom edge across its width, thus the other\n * rectangles go under it. The space above it stays empty, because a skyline has no holes.\n * - The skyline has a cell for each whole unit of the width. A rectangle that needs more cells than the outer\n * rectangle has goes under all other rectangles, at the left edge.\n * - Without `fixedSize`, the height of the outer rectangle grows to the content. With `fixedSize`, a rectangle that\n * does not fit is not packed: its `wasPacked` stays `false`.\n * - The default sort order is `height-desc`. The order of the array of the caller stays.\n */\nexport function packSkyline<T>(rects: Rect<T>[], outer: Rect<T>, options: { sortOrder?: SortOrder } = {}): Rect<T> {\n // a cell for each whole unit of the width: a rectangle never goes past the right edge\n const width = Math.floor(outer.size.x);\n if (width <= 0) return outer;\n const skyline = new Float64Array(width);\n\n for (const rect of rects) {\n if (!rect.locked) continue;\n rect.wasPacked = true;\n const x0 = Math.max(0, Math.floor(rect.position.x - outer.position.x));\n const x1 = Math.min(width, Math.ceil(rect.position.x - outer.position.x + rect.size.x));\n const bottom = rect.position.y - outer.position.y + rect.size.y;\n for (let i = x0; i < x1; i++) skyline[i] = Math.max(skyline[i]!, bottom);\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, bottom);\n }\n\n for (const rect of rects.toSorted(compareRects(options.sortOrder ?? \"height-desc\"))) {\n if (rect.wasPacked) continue;\n const rw = Math.ceil(rect.size.x);\n const rh = rect.size.y;\n if (rw <= 0 || rh <= 0) continue;\n\n let x: number;\n let y: number;\n if (rw > width) {\n if (outer.fixedSize) continue;\n x = 0;\n y = 0;\n for (let i = 0; i < width; i++) if (skyline[i]! > y) y = skyline[i]!;\n } else {\n ({ x, y } = lowestWindow(skyline, width, rw));\n if (outer.fixedSize && y + rh > outer.size.y) continue;\n }\n\n rect.position.set(x + outer.position.x, y + outer.position.y);\n rect.wasPacked = true;\n const top = y + rh;\n for (let i = x; i < Math.min(width, x + rw); i++) skyline[i] = top;\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, top);\n }\n return outer;\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport { Rect } from \"./rect.ts\";\nimport { packShelf } from \"./shelf.ts\";\nimport { packSkyline } from \"./skyline.ts\";\nimport { Vector } from \"./vector.ts\";\n\n/** The options of `pack` and `packRows` */\nexport interface PackOptions {\n /** The order of the rectangles before the packing. The default is `height-desc`. */\n sortOrder?: SortOrder;\n}\n\n/** The options of `pack` */\nexport interface PackLayoutOptions extends PackOptions {\n /**\n * The packing: `rows` (the default), `skyline` or `shelf`. `skyline` and `shelf` pack around locked rectangles.\n * Use `shelf` with the sort order `input` to keep the order of the array around locked rectangles.\n */\n strategy?: \"rows\" | \"skyline\" | \"shelf\";\n}\n\nfunction packInto<T>(rects: Rect<T>[], region: Rect<T>, offset: Vector, order: SortOrder): void {\n const unpacked = Rect.unpacked(rects);\n pack(unpacked, region, { sortOrder: order });\n for (const r of Rect.packed(unpacked)) r.translateBy(offset);\n}\n\nfunction packRow<T>(rects: Rect<T>[], outer: Rect<T>, order: SortOrder): boolean {\n const row: Rect<T>[] = [];\n // toSorted gives a sorted copy, thus the order of the array of the caller stays\n const byHeight = rects.toSorted(compareRects(order));\n // A gap fill puts a later rect before an earlier one, thus the order `input` fills no gaps\n const fillGaps = order !== \"input\";\n\n const rowRect = new Rect<T>();\n rowRect.size.set(outer.size.x, 0);\n\n for (const rect of byHeight) {\n if (rect.wasPacked) continue;\n\n if (rect.size.x > rowRect.size.x) {\n if (outer.fixedSize && rect.size.x > outer.size.x) continue;\n\n const outerLeft = new Rect<T>();\n outerLeft.position.setTo(rowRect.position);\n outerLeft.size.set(outer.size.x - rowRect.position.x, rowRect.size.y);\n outerLeft.fixedSize = true;\n if (fillGaps) packInto(rects, outerLeft, outer.position, order);\n\n rowRect.position.set(0, rowRect.bottom());\n rowRect.size.set(outer.size.x, 0);\n row.length = 0;\n }\n\n if (rowRect.position.y + rect.size.y > outer.size.y) {\n if (outer.fixedSize) continue;\n outer.size.y += rect.size.y;\n if (!outer.fixedWidth && !outer.size.x) outer.size.x = rect.size.x;\n Rect.resetPacked(rects);\n return false;\n }\n\n row.push(rect);\n rect.position.setTo(rowRect.position.add(outer.position));\n rowRect.shrinkLeft(rect.size.x);\n rect.wasPacked = true;\n\n if (rect.size.y > rowRect.size.y) rowRect.size.y = rect.size.y;\n\n if (fillGaps && row.length > 1) {\n const rectInRow = row[row.length - 1]!;\n const outerLeft = new Rect<T>();\n // The position of the region is relative to the outer rectangle, as packInto adds the position of the outer rectangle\n outerLeft.position.set(rectInRow.position.x - outer.position.x, rectInRow.bottom() - outer.position.y);\n outerLeft.size.set(rectInRow.size.x, rowRect.size.y - rectInRow.size.y);\n outerLeft.fixedWidth = true;\n outerLeft.fixedSize = true;\n packInto(rects, outerLeft, outer.position, order);\n }\n }\n return true;\n}\n\n/**\n * This function packs rectangles into an outer rectangle of a given width with a guillotine row packing. It does\n * not change the width. Without `fixedSize`, the height grows until all rectangles fit. A `locked` rectangle keeps\n * its position, but the rows do not go around it. `pack` sets the width first and then uses this function.\n */\nexport function packRows<T>(rects: Rect<T>[], outer: Rect<T>, options: PackOptions = {}): Rect<T> {\n const order = options.sortOrder ?? \"height-desc\";\n for (const r of rects) if (r.locked) r.wasPacked = true;\n while (!packRow(rects, outer, order));\n return outer;\n}\n\n/**\n * This function packs rectangles into an outer rectangle with a guillotine row packing. It sets the position\n * of each rectangle and the size of the outer rectangle, and it gives the outer rectangle.\n *\n * - Without fixed sizes, the outer rectangle starts with a width of 1.5 times the square root of the total area.\n * This width is not less than the width of the widest rectangle. The height grows until all rectangles fit.\n * - With `fixedWidth`, the width stays. A rectangle wider than that width goes on its own row and overflows.\n * - With `fixedSize`, a rectangle that does not fit is not packed: its `wasPacked` stays `false`.\n * - `options.strategy` selects `packRows` (the default), `packSkyline` or `packShelf` after the width is set.\n */\nexport function pack<T>(rects: Rect<T>[], outer: Rect<T> = new Rect(), options: PackLayoutOptions = {}): Rect<T> {\n let totalArea = 0;\n let widest = 0;\n let minX = rects.length > 0 ? Infinity : 0;\n let minY = rects.length > 0 ? Infinity : 0;\n for (const r of rects) {\n totalArea += r.area();\n widest = Math.max(widest, r.size.x);\n minX = Math.min(minX, r.size.x);\n minY = Math.min(minY, r.size.y);\n }\n\n const idealWidth = outer.fixedWidth\n ? outer.size.x\n : Math.max(widest, Math.min(1.5 * Math.sqrt(totalArea), outer.size.x || Infinity));\n\n const ideal = Vector.of(idealWidth).clamp(new Vector(minX, minY), Vector.Infinity);\n\n // A fixed width stays, also when a rectangle is wider: that rectangle overflows\n if (!outer.fixedSize) outer.size.setTo(outer.fixedWidth ? new Vector(outer.size.x, ideal.y) : ideal);\n if (options.strategy === \"skyline\") packSkyline(rects, outer, options);\n else if (options.strategy === \"shelf\") packShelf(rects, outer, options);\n else packRows(rects, outer, options);\n\n if (!outer.fixedSize) {\n const contentRight = Rect.maxRight(rects);\n if (!outer.size.x) outer.size.x = contentRight;\n else if (!outer.fixedWidth) outer.size.x = Math.min(contentRight, outer.size.x);\n outer.size.y = Rect.maxBottom(rects);\n }\n\n return outer;\n}\n","import { pack, type PackLayoutOptions } from \"./pack.ts\";\nimport { Rect } from \"./rect.ts\";\n\n/** The options of `packFree` */\nexport interface FreeWidthOptions extends PackLayoutOptions {\n /** The target aspect: the width divided by the height. The default is 1, a square. */\n aspect?: number;\n /**\n * The weight of the aspect error in the objective. The objective is the area times `1 + aspectWeight * aspectError`.\n * The default is 1. With 0, only the area counts.\n */\n aspectWeight?: number;\n /** The number of widths that the first pass tries. The default is 48. */\n samples?: number;\n}\n\n/** One width that `packFree` tried, and its result */\nexport interface FreeWidthTry {\n /** The width of the container for this try */\n width: number;\n /** The width of the content: the right edge of the rectangles */\n contentWidth: number;\n /** The height of the content */\n contentHeight: number;\n /** The objective of this try. Lower is better. */\n objective: number;\n}\n\n/** The result of `packFree` */\nexport interface FreeWidthResult<T> {\n /** The outer rectangle, with the size of the content */\n outer: Rect<T>;\n /** The area of the bounding box of the content */\n area: number;\n /** The area of the rectangles divided by the area of the bounding box */\n fill: number;\n /** The aspect of the bounding box: the width divided by the height */\n aspect: number;\n /** The distance from the target aspect: the absolute value of `log(aspect) - log(target)` */\n aspectError: number;\n /** The objective of the chosen width. Lower is better. */\n objective: number;\n /** Each width that the search tried, in the order of the search */\n tried: FreeWidthTry[];\n}\n\n/** This function gives the distance between an aspect and a target aspect on a log scale. */\nexport function aspectError(width: number, height: number, target = 1): number {\n if (!(width > 0 && height > 0 && target > 0)) return Infinity;\n return Math.abs(Math.log(width / height) - Math.log(target));\n}\n\n/**\n * This function packs rectangles with a free width. It tries many widths with the strategy of `options`, and keeps\n * the width with the lowest objective: the area of the bounding box times `1 + aspectWeight * aspectError`.\n *\n * - The first pass tries `samples` widths on a log scale, from the widest rectangle to the width of one row.\n * - The second pass tries the widths between the two neighbours of the best width of the first pass.\n * - The search is deterministic: the same input gives the same widths and the same result.\n * - A `locked` rectangle keeps its position. The width is not less than its right edge.\n * - Each strategy of `pack` works with this function, because it only changes the width.\n */\nexport function packFree<T>(rects: Rect<T>[], outer: Rect<T> = new Rect(), options: FreeWidthOptions = {}): FreeWidthResult<T> {\n const target = options.aspect ?? 1;\n const weight = options.aspectWeight ?? 1;\n const samples = Math.max(2, Math.floor(options.samples ?? 48));\n const ox = outer.position.x;\n const oy = outer.position.y;\n\n let itemArea = 0;\n let minWidth = 0;\n let rowWidth = 0;\n for (const r of rects) {\n if (r.locked) {\n minWidth = Math.max(minWidth, r.right() - ox);\n continue;\n }\n if (!(r.size.x > 0 && r.size.y > 0)) continue;\n itemArea += r.area();\n minWidth = Math.max(minWidth, r.size.x);\n rowWidth += r.size.x;\n }\n for (const r of rects) if (r.locked) itemArea += r.area();\n const maxWidth = Math.max(minWidth, rowWidth);\n\n const tried: FreeWidthTry[] = [];\n const run = (width: number): FreeWidthTry => {\n Rect.resetPacked(rects);\n const box = new Rect<T>();\n box.position.setTo(outer.position);\n box.size.set(width, 0);\n box.fixedWidth = true;\n pack(rects, box, options);\n const placed = Rect.packed(rects);\n const contentWidth = Math.max(0, Rect.maxRight(placed) - ox);\n const contentHeight = Math.max(0, Rect.maxBottom(placed) - oy);\n const area = contentWidth * contentHeight;\n const objective = area > 0 ? area * (1 + weight * aspectError(contentWidth, contentHeight, target)) : 0;\n const t = { width, contentWidth, contentHeight, objective };\n tried.push(t);\n return t;\n };\n\n // The first pass: widths on a log scale. Each width is a whole number when the sizes are whole numbers.\n const widths: number[] = [];\n if (maxWidth > 0) {\n const ratio = maxWidth / minWidth;\n for (let i = 0; i < samples; i++) {\n const w = minWidth * ratio ** (i / (samples - 1));\n const rounded = i === samples - 1 ? maxWidth : Math.max(minWidth, Math.round(w));\n if (widths.at(-1) !== rounded) widths.push(rounded);\n }\n }\n let best: FreeWidthTry | undefined = undefined;\n let bestIndex = 0;\n for (const [i, w] of widths.entries()) {\n const t = run(w);\n if (best === undefined || t.objective < best.objective) {\n best = t;\n bestIndex = i;\n }\n }\n\n // The second pass: the widths between the two neighbours of the best width\n if (widths.length > 2) {\n const low = widths[Math.max(0, bestIndex - 1)]!;\n const high = widths[Math.min(widths.length - 1, bestIndex + 1)]!;\n const steps = Math.min(Math.floor(samples / 2), Math.max(0, Math.round(high - low) - 1));\n for (let i = 1; i <= steps; i++) {\n const w = Math.round(low + ((high - low) * i) / (steps + 1));\n if (widths.includes(w)) continue;\n const t = run(w);\n if (best === undefined || t.objective < best.objective) best = t;\n }\n }\n\n // The last run packs with the best width, so the positions of the rectangles are those of the best width\n const chosen = best === undefined ? undefined : run(best.width);\n tried.pop();\n const w = chosen?.contentWidth ?? 0;\n const h = chosen?.contentHeight ?? 0;\n if (!outer.fixedSize) outer.size.set(w, h);\n const area = w * h;\n return {\n outer,\n area,\n fill: area > 0 ? itemArea / area : 0,\n aspect: h > 0 ? w / h : 0,\n aspectError: aspectError(w, h, target),\n objective: chosen?.objective ?? 0,\n tried,\n };\n}\n","import type { Rect } from \"./rect.ts\";\n\n/** The options of `pushCascade`. */\nexport interface PushOptions {\n /** The space between a shoved rectangle and the rectangle that shoves it. The default is 8. */\n gap?: number;\n /** The most shoves. The default is eight for each rectangle. The cascade stops at this limit. */\n maxShoves?: number;\n}\n\n/** A direction of a shove: an axis and a sign. */\ninterface Direction {\n readonly axis: \"x\" | \"y\";\n readonly sign: 1 | -1;\n}\n\n/** This function gives the overlap of two rectangles on each axis. A value of 0 or less is no overlap. */\nfunction overlapOf(a: Rect, b: Rect): { x: number; y: number } {\n return {\n x: Math.min(a.right(), b.right()) - Math.max(a.position.x, b.position.x),\n y: Math.min(a.bottom(), b.bottom()) - Math.max(a.position.y, b.position.y),\n };\n}\n\n/**\n * This function gives the direction of a first shove. The axis has the smaller overlap. The sign points away from the\n * center of the pusher. When that shove crosses 0, the sign is positive.\n */\nfunction firstDirection(pusher: Rect, r: Rect, gap: number): Direction {\n const overlap = overlapOf(pusher, r);\n if (overlap.x < overlap.y) {\n const back = r.position.x + r.size.x / 2 < pusher.position.x + pusher.size.x / 2 && pusher.position.x - r.size.x - gap >= 0;\n return { axis: \"x\", sign: back ? -1 : 1 };\n }\n const back = r.position.y + r.size.y / 2 < pusher.position.y + pusher.size.y / 2 && pusher.position.y - r.size.y - gap >= 0;\n return { axis: \"y\", sign: back ? -1 : 1 };\n}\n\n/** This function puts a rectangle past the pusher, along a direction. The rectangle does not go past 0. */\nfunction shove(pusher: Rect, r: Rect, direction: Direction, gap: number): void {\n if (direction.axis === \"x\") {\n const x = direction.sign > 0 ? pusher.right() + gap : pusher.position.x - r.size.x - gap;\n r.position.set(Math.max(0, x), r.position.y);\n return;\n }\n const y = direction.sign > 0 ? pusher.bottom() + gap : pusher.position.y - r.size.y - gap;\n r.position.set(r.position.x, Math.max(0, y));\n}\n\n/**\n * This function moves each rectangle that a placed rectangle overlaps, and the rectangles that those overlap in turn.\n * A shove takes the axis of the smaller overlap, away from the pusher. A shoved rectangle keeps the direction of its first\n * shove when it shoves the next one, so the cascade goes outward. The placed rectangle and each locked rectangle stay.\n * The function moves the rectangles in place and gives the rectangles that moved.\n *\n * @example\n * ```ts\n * const moved = pushCascade(dropped, cards, { gap: 8 });\n * ```\n */\nexport function pushCascade<T>(placed: Rect<T>, rects: readonly Rect<T>[], options: PushOptions = {}): Rect<T>[] {\n const gap = options.gap ?? 8;\n const maxShoves = options.maxShoves ?? rects.length * 8;\n const moved = new Set<Rect<T>>();\n const queue: { pusher: Rect<T>; direction?: Direction }[] = [{ pusher: placed }];\n let shoves = 0;\n while (shoves < maxShoves) {\n const step = queue.shift();\n if (!step) break;\n const { pusher, direction } = step;\n for (const r of rects) {\n if (r === pusher || r === placed || r.locked) continue;\n const overlap = overlapOf(pusher, r);\n if (overlap.x <= 0 || overlap.y <= 0) continue;\n const next = direction ?? firstDirection(pusher, r, gap);\n shove(pusher, r, next, gap);\n moved.add(r);\n queue.push({ pusher: r, direction: next });\n if (++shoves >= maxShoves) break;\n }\n }\n return [...moved];\n}\n","// The data types of the Packer contract (docs/PACKER.md). They are plain data, with no class and no method.\n// The shared package `@mark1russell7/layout-contract` gets these types later. Until then, this file is a local copy.\n\n/** A region. The forms and the rules are those of `docs/FORMAT.md`. The y axis points down. */\nexport type Region =\n | { kind: \"rect\"; x: number; y: number; w: number; h: number }\n | { kind: \"polygon\"; points: [number, number][]; holes?: [number, number][][] }\n | { kind: \"circle\"; cx: number; cy: number; r: number }\n | { kind: \"ellipse\"; cx: number; cy: number; rx: number; ry: number };\n\n/** The container of a packing. */\nexport interface Container {\n /** The width. Without it, the packer searches the width. */\n w?: number;\n /** The height. Without it, the packer searches the height. */\n h?: number;\n /** The sides that stay: `size` keeps `w` and `h`, `width` keeps `w`, `height` keeps `h`, and `none` searches both. */\n fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect (the width divided by the height) for the value `none` of `fixed`. The default is 1. */\n aspect?: number;\n /** The weight of the aspect error in the objective. The value 0 gives the least area. The default is 1. */\n aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n shape?: Region;\n /** The space between the border and the items with their margins. The default is 0. */\n inset?: number;\n}\n\n/** An obstacle: an area that no item enters. */\nexport interface Obstacle {\n id: string;\n region: Region;\n /** Without it, the obstacle stays. With it, the packer can move the obstacle for `cost` times the distance. */\n move?: { cost: number };\n}\n\n/** The margin of an item on each side. */\nexport interface Margin {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\n/** A port on the border of an item. */\nexport interface Port {\n id: string;\n side: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** The point on the border of the item, relative to its top-left corner. Without it, the router chooses the point. */\n x?: number;\n y?: number;\n}\n\n/** An item to pack. The file format names it a box. */\nexport interface Item {\n id: string;\n w: number;\n h: number;\n /** The reading order. Without it, the index in the array is the rank. */\n rank?: number;\n group?: string;\n parent?: string;\n /** A shape relative to the origin of the item. Without it, the item is the rectangle `w` by `h`. */\n shape?: Region;\n /** A locked item keeps `x` and `y`. The packer reads it as an obstacle. */\n locked?: boolean;\n x?: number;\n y?: number;\n /** The value `true` lets the packer turn the item by 90 degrees. The default is `false`. */\n turnable?: boolean;\n /** A ring around the item that no other item and no route enters. The default is 0. */\n margin?: number | Margin;\n /** The ports. The packer keeps them, and turns them with the item. */\n ports?: Port[];\n}\n\n/** The input of a packing: a `layout-input/1` file without `edges`, with `items` for `boxes`. */\nexport interface PackInput {\n container: Container;\n items: Item[];\n obstacles?: Obstacle[];\n /** The free space between two items with their margins. Routes use this space. The default is 0. */\n gap?: number;\n}\n\n/** The position of one item after the packing. */\nexport interface Placement {\n id: string;\n x: number;\n y: number;\n /** The turn: 0 or 90, only for an item with `turnable` set to `true`. */\n turn?: 0 | 90;\n}\n\n/** The facts of one stage of a packing. */\nexport interface StageTrace {\n /** The id of the stage, for example `skyline` or `log-sweep`. */\n id: string;\n /** The time of the stage in milliseconds. */\n ms: number;\n /** The measures of the stage, by the names of `docs/FORMAT.md`. */\n measures: Record<string, number>;\n}\n\n/** The output of a packing. The output does not change the input. */\nexport interface PackOutput {\n placements: Placement[];\n /** The ids of the items that the packer did not place. */\n overflow: string[];\n /** The size of the container after the packing. For a free size, the size that the search found. */\n size: { w: number; h: number };\n /** The new positions of the obstacles that moved. */\n moved: { id: string; x: number; y: number }[];\n /** The facts of each stage, for the site and the records. */\n trace: StageTrace[];\n}\n\n/** The tolerances of the hard rules. */\nexport interface Tolerance {\n /** The rule `no-overlap`: two boxes overlap only by more than this value. */\n overlap: number;\n /** The router rule that a route does not go through a box. */\n through: number;\n}\n\n/** The tolerance for the comparison of two numbers in an engine. */\nexport const EPS = 1e-6;\n\n/** The tolerance for the comparison of two numbers of a file. The files round to 3 decimals. */\nexport const RECORD_EPS = 1e-3;\n\n/** The default tolerances of the hard rules. Each record writes its tolerances in its top-level field `tolerance`. */\nexport const DEFAULT_TOLERANCE: Readonly<Tolerance> = Object.freeze({ overlap: 0.001, through: 0.5 });\n\n/** This function gives the margin of an item on each side. A number is the same margin on each side. */\nexport function marginOf(item: Pick<Item, \"margin\">): Margin {\n const m = item.margin ?? 0;\n if (typeof m === \"number\") return { top: m, right: m, bottom: m, left: m };\n return { top: m.top, right: m.right, bottom: m.bottom, left: m.left };\n}\n\n/** The side of a port after a turn of 90 degrees clockwise. */\nconst TURNED_SIDE = { top: \"right\", right: \"bottom\", bottom: \"left\", left: \"top\" } as const;\n\n/** This function gives the point `px`, `py` of an item of height `h` after a turn of 90 degrees clockwise. */\nexport function turnPoint(px: number, py: number, h: number): [number, number] {\n return [h - py, px];\n}\n\n/** This function turns a port of an item of height `h` by 90 degrees clockwise. The side turns from top to right. */\nexport function turnPort(port: Port, h: number): Port {\n const turned: Port = { id: port.id, side: TURNED_SIDE[port.side] };\n if (port.x !== undefined && port.y !== undefined) {\n const [x, y] = turnPoint(port.x, port.y, h);\n turned.x = x;\n turned.y = y;\n } else if (port.x !== undefined) {\n // Only x is set: x becomes the new y, and the router chooses the new x\n turned.y = port.x;\n } else if (port.y !== undefined) {\n // Only y is set: h - y becomes the new x, and the router chooses the new y\n turned.x = h - port.y;\n }\n return turned;\n}\n\n/** This function turns a region relative to an item of height `h` by 90 degrees clockwise. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\": {\n const [cx, cy] = turnPoint(region.cx, region.cy, h);\n return { kind: \"circle\", cx, cy, r: region.r };\n }\n case \"ellipse\": {\n const [cx, cy] = turnPoint(region.cx, region.cy, h);\n return { kind: \"ellipse\", cx, cy, rx: region.ry, ry: region.rx };\n }\n case \"polygon\": {\n const turnRing = (ring: [number, number][]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n const turned: Region = { kind: \"polygon\", points: turnRing(region.points) };\n if (region.holes) turned.holes = region.holes.map(turnRing);\n return turned;\n }\n }\n}\n\n/**\n * This function gives an item after a turn of 90 degrees clockwise, with the y axis down (decision 1 of\n * `docs/PACKER.md`). The width and the height change places. The top-left corner, the id and the other fields stay.\n * The ports, the shape and the margin turn with the item. The function does not change its argument.\n */\nexport function turnItem(item: Item): Item {\n const turned: Item = { ...item, w: item.h, h: item.w };\n if (item.ports) turned.ports = item.ports.map((p) => turnPort(p, item.h));\n if (item.shape) turned.shape = turnRegion(item.shape, item.h);\n if (item.margin !== undefined && typeof item.margin !== \"number\") {\n const m = item.margin;\n turned.margin = { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n }\n return turned;\n}\n","// SHA-256 (FIPS 180-4) in plain TypeScript. The hash of a corpus file needs it, and a browser has no synchronous SHA-256.\n\n/** The round constants of SHA-256. */\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be,\n 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa,\n 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85,\n 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,\n 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\n/** The first hash value of SHA-256. */\nconst H0 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n\n/** This function turns a 32-bit word to the right by `n` bits. */\nconst rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));\n\n/**\n * This function gives the UTF-8 bytes of a string. A lone surrogate becomes U+FFFD, as with `TextEncoder`. The\n * package has no `TextEncoder` type, because its code operates on each runtime with no global types.\n */\nexport function utf8(text: string): Uint8Array {\n const out: number[] = [];\n for (let i = 0; i < text.length; i++) {\n let c = text.charCodeAt(i);\n if (c >= 0xd800 && c <= 0xdbff && i + 1 < text.length) {\n const next = text.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) {\n c = 0x10000 + ((c - 0xd800) << 10) + (next - 0xdc00);\n i++;\n }\n }\n if (c >= 0xd800 && c <= 0xdfff) c = 0xfffd;\n if (c < 0x80) out.push(c);\n else if (c < 0x800) out.push(0xc0 | (c >> 6), 0x80 | (c & 63));\n else if (c < 0x10000) out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n else out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n }\n return Uint8Array.from(out);\n}\n\n/** This function gives the SHA-256 of the UTF-8 bytes of a string, as 64 lowercase hex characters. */\nexport function sha256Hex(text: string): string {\n const bytes = utf8(text);\n const length = bytes.length;\n const padded = new Uint8Array((((length + 9 + 63) / 64) | 0) * 64);\n padded.set(bytes);\n padded[length] = 0x80;\n const view = new DataView(padded.buffer);\n const bits = length * 8;\n view.setUint32(padded.length - 8, Math.floor(bits / 0x100000000));\n view.setUint32(padded.length - 4, bits >>> 0);\n\n const hash = [...H0];\n const w = new Uint32Array(64);\n for (let block = 0; block < padded.length; block += 64) {\n for (let t = 0; t < 16; t++) w[t] = view.getUint32(block + t * 4);\n for (let t = 16; t < 64; t++) {\n const a = w[t - 15]!;\n const b = w[t - 2]!;\n const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);\n const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);\n w[t] = (w[t - 16]! + s0 + w[t - 7]! + s1) | 0;\n }\n let [a, b, c, d, e, f, g, h] = hash as [number, number, number, number, number, number, number, number];\n for (let t = 0; t < 64; t++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (h + s1 + ch + K[t]! + w[t]!) | 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (s0 + maj) | 0;\n h = g;\n g = f;\n f = e;\n e = (d + t1) | 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) | 0;\n }\n hash[0] = (hash[0]! + a) | 0;\n hash[1] = (hash[1]! + b) | 0;\n hash[2] = (hash[2]! + c) | 0;\n hash[3] = (hash[3]! + d) | 0;\n hash[4] = (hash[4]! + e) | 0;\n hash[5] = (hash[5]! + f) | 0;\n hash[6] = (hash[6]! + g) | 0;\n hash[7] = (hash[7]! + h) | 0;\n }\n return hash.map((x) => (x >>> 0).toString(16).padStart(8, \"0\")).join(\"\");\n}\n","// The input file `layout-input/1` of `docs/FORMAT.md`: its types, its numbers, its canonical form and its hash.\n\nimport type { Container, Item, Obstacle, PackInput } from \"./contract.ts\";\nimport { sha256Hex, utf8 } from \"./sha256.ts\";\nimport type { Cell } from \"./strategy.ts\";\n\n/** An edge between two boxes. The router reads it, and the packer ignores it. */\nexport interface Edge {\n id: string;\n source: string;\n target: string;\n sourcePort?: string;\n targetPort?: string;\n}\n\n/** The parameters of a generator: a name and a string or a number for each parameter. */\nexport type GeneratorParams = Record<string, string | number>;\n\n/** The stamp of a generated input: the generator, its version, the full parameters and the seed. */\nexport interface GeneratorStamp {\n name: string;\n version: number;\n params: GeneratorParams;\n seed: number;\n}\n\n/** One input file `layout-input/1`. `docs/FORMAT.md` gives each field. */\nexport interface LayoutInput {\n schema: \"layout-input/1\";\n id: string;\n set: string;\n family: string;\n seed: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n source: string;\n /** The generator of a generated input. A hand-made or published input has `null`. */\n generator: GeneratorStamp | null;\n container: Container;\n obstacles?: Obstacle[];\n gap?: number;\n boxes: Item[];\n edges: Edge[];\n base?: string;\n change?: string;\n step?: number;\n /** The first 16 hex characters of the SHA-256 of the canonical form of the other fields. */\n hash: string;\n}\n\n/** The layout of the obstacles (`docs/research/TAXONOMY.md`, dimension 3). */\nexport type ObstacleLayout = \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n\n/** The distribution of the sizes of the items (`docs/research/TAXONOMY.md`, dimension 6). */\nexport type SizeDistribution = \"identical\" | \"nearIdentical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\";\n\n/** The scale of the count of the items (`docs/research/TAXONOMY.md`, dimension 7). */\nexport type CountScale = \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n\n/**\n * The cell of a generated input: one value for each dimension of the packer. The cell of `cellOf` has the dimensions\n * that the input tells. The generator adds the layout of the obstacles, the sizes, the count and the mode.\n */\nexport interface CorpusCell extends Cell {\n obstacles: ObstacleLayout;\n sizes: SizeDistribution;\n count: CountScale;\n mode: \"offline\" | \"online\" | \"incremental\";\n}\n\n/** This function gives the `fnv1a32` hash of the UTF-8 bytes of a string, as `docs/FORMAT.md` gives it. */\nexport function fnv1a32(text: string): number {\n let h = 0x811c9dc5;\n for (const b of utf8(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** This function rounds the numbers of a file to 3 decimals. A half goes up, and the value `-0` becomes 0. */\nexport function round3(x: number): number {\n const v = Math.round(x * 1000) / 1000;\n return Object.is(v, -0) ? 0 : v;\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys, no whitespace and the numbers of `JSON.stringify`\n * after `round3`. A key with the value `undefined` is not in the form.\n */\nexport function canonicalJson(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(\",\")}]`;\n if (value !== null && typeof value === \"object\") {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(\",\")}}`;\n }\n return JSON.stringify(typeof value === \"number\" ? round3(value) : value);\n}\n\n/** This function gives the hash of an input file: the first 16 hex characters of the SHA-256 of its canonical form without `hash`. */\nexport function hashInput(file: Omit<LayoutInput, \"hash\"> | LayoutInput): string {\n const rest: Partial<LayoutInput> = { ...file };\n delete rest.hash;\n return sha256Hex(canonicalJson(rest)).slice(0, 16);\n}\n\n/** This function gives the scale of a count: the nearest of 1, 10, 100, 1000 and 10000 on a log scale. The count 0 gives `1`. */\nexport function countCell(count: number): CountScale {\n if (count <= 3) return \"1\";\n if (count <= 31) return \"10\";\n if (count <= 316) return \"100\";\n if (count <= 3162) return \"1k\";\n return \"10k\";\n}\n\n/** This function gives the packing input of a file. The boxes become the items, and the edges go. */\nexport function toPackInput(file: Pick<LayoutInput, \"container\" | \"boxes\" | \"obstacles\" | \"gap\">): PackInput {\n const input: PackInput = { container: file.container, items: file.boxes };\n if (file.obstacles !== undefined) input.obstacles = file.obstacles;\n if (file.gap !== undefined) input.gap = file.gap;\n return input;\n}\n","// The algebra of measures (roadmap item k8). `docs/MEASURES.md` defines each measure. This file computes them.\n\nimport { RECORD_EPS, type PackInput, type PackOutput } from \"./contract.ts\";\nimport { aspectError } from \"./free.ts\";\nimport { round3 } from \"./layout-input.ts\";\n\n/** The direction of a measure: `lower` when a lower value is better, `higher` when a higher value is better. */\nexport type Direction = \"lower\" | \"higher\";\n\n/** The family of a measure. Each family has a section in `docs/MEASURES.md`. */\nexport type MeasureFamily = \"density\" | \"aspect\" | \"order\" | \"raggedness\" | \"overflow\" | \"stability\" | \"determinism\" | \"speed\";\n\n/** The id of a measure of the packer. The ids are those of `docs/FORMAT.md`, and `highways` uses the same ids. */\nexport type MeasureId = \"pack.area\" | \"pack.fill\" | \"pack.whitespace\" | \"pack.aspect\" | \"pack.aspectError\" | \"pack.order.inversions\" | \"pack.order.breaks\" | \"pack.raggedness\" | \"pack.overflow\" | \"pack.stability.moved\" | \"pack.stability.mean\" | \"pack.stability.q95\" | \"pack.deterministic\" | \"pack.search.widths\" | \"pack.search.ms\";\n\n/** The facts of one measure: its family, its unit, its direction and its range. */\nexport interface MeasureSpec {\n id: MeasureId;\n family: MeasureFamily;\n unit: string;\n direction: Direction;\n /** The lowest value. */\n min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n max: number;\n}\n\n/** The measures of one layout, by id. `measure` gives them. The values are not rounded. */\nexport interface LayoutMeasures {\n \"pack.area\": number;\n \"pack.fill\": number;\n \"pack.whitespace\": number;\n \"pack.aspect\": number;\n \"pack.aspectError\": number;\n \"pack.order.inversions\": number;\n \"pack.order.breaks\": number;\n \"pack.raggedness\": number;\n \"pack.overflow\": number;\n \"pack.search.widths\": number;\n \"pack.search.ms\": number;\n}\n\n/** The stability measures of a change pair, by id. `measureChange` gives them. The values are not rounded. */\nexport interface ChangeMeasures {\n \"pack.stability.moved\": number;\n \"pack.stability.mean\": number;\n \"pack.stability.q95\": number;\n}\n\n/** The options of `measure`. */\nexport interface MeasureOptions {\n /**\n * A box joins a row when its top is this close to the top of the first box of the row. The rows give\n * `pack.raggedness`. The default is half the median height of the boxes.\n */\n rowTolerance?: number;\n}\n\nconst spec = (id: MeasureId, family: MeasureFamily, unit: string, direction: Direction, min: number, max: number): MeasureSpec => ({\n id,\n family,\n unit,\n direction,\n min,\n max,\n});\n\n/** The facts of each measure, by id. `docs/MEASURES.md` gives the full definitions. */\nexport const MEASURE_SPECS: Readonly<Record<MeasureId, MeasureSpec>> = Object.freeze({\n \"pack.area\": spec(\"pack.area\", \"density\", \"square units\", \"lower\", 0, Infinity),\n \"pack.fill\": spec(\"pack.fill\", \"density\", \"share\", \"higher\", 0, 1),\n \"pack.whitespace\": spec(\"pack.whitespace\", \"density\", \"share\", \"lower\", 0, 1),\n \"pack.aspect\": spec(\"pack.aspect\", \"aspect\", \"ratio\", \"lower\", 1, Infinity),\n \"pack.aspectError\": spec(\"pack.aspectError\", \"aspect\", \"natural log\", \"lower\", 0, Infinity),\n \"pack.order.inversions\": spec(\"pack.order.inversions\", \"order\", \"share\", \"lower\", 0, 1),\n \"pack.order.breaks\": spec(\"pack.order.breaks\", \"order\", \"count\", \"lower\", 0, Infinity),\n \"pack.raggedness\": spec(\"pack.raggedness\", \"raggedness\", \"share\", \"lower\", 0, 1),\n \"pack.overflow\": spec(\"pack.overflow\", \"overflow\", \"count\", \"lower\", 0, Infinity),\n \"pack.stability.moved\": spec(\"pack.stability.moved\", \"stability\", \"share\", \"lower\", 0, 1),\n \"pack.stability.mean\": spec(\"pack.stability.mean\", \"stability\", \"container widths\", \"lower\", 0, Infinity),\n \"pack.stability.q95\": spec(\"pack.stability.q95\", \"stability\", \"container widths\", \"lower\", 0, Infinity),\n \"pack.deterministic\": spec(\"pack.deterministic\", \"determinism\", \"boolean\", \"higher\", 0, 1),\n \"pack.search.widths\": spec(\"pack.search.widths\", \"speed\", \"count\", \"lower\", 0, Infinity),\n \"pack.search.ms\": spec(\"pack.search.ms\", \"speed\", \"milliseconds\", \"lower\", 0, Infinity),\n});\n\n/** A placed box: the rectangle of an item at its position, with its rank. */\nexport interface Box {\n x: number;\n y: number;\n w: number;\n h: number;\n rank: number;\n}\n\n/** This function gives the smallest rectangle around the boxes. No box gives a rectangle of size 0 at 0, 0. */\nexport function hullOf(boxes: readonly Pick<Box, \"x\" | \"y\" | \"w\" | \"h\">[]): { x: number; y: number; w: number; h: number } {\n if (boxes.length === 0) return { x: 0, y: 0, w: 0, h: 0 };\n let left = Infinity;\n let top = Infinity;\n let right = -Infinity;\n let bottom = -Infinity;\n for (const b of boxes) {\n left = Math.min(left, b.x);\n top = Math.min(top, b.y);\n right = Math.max(right, b.x + b.w);\n bottom = Math.max(bottom, b.y + b.h);\n }\n return { x: left, y: top, w: right - left, h: bottom - top };\n}\n\n/**\n * This function puts the boxes in rows. It sorts the boxes by their top, and keeps the order of the list for equal tops.\n * A box joins the last row when its top is within `tolerance` of the top of the first box of that row.\n */\nexport function rowsOf(boxes: readonly Pick<Box, \"x\" | \"y\" | \"w\">[], tolerance: number): { top: number; right: number; count: number }[] {\n const rows: { top: number; right: number; count: number }[] = [];\n for (const b of boxes.toSorted((p, q) => p.y - q.y)) {\n const row = rows.at(-1);\n if (row && Math.abs(b.y - row.top) <= tolerance) {\n row.right = Math.max(row.right, b.x + b.w);\n row.count += 1;\n } else {\n rows.push({ top: b.y, right: b.x + b.w, count: 1 });\n }\n }\n return rows;\n}\n\n/**\n * This function gives the placed boxes of an output, in the order of the items of the input. A box has the size of its\n * item after the turn. The list has no item without a placement, and no item with a width or a height of 0.\n */\nexport function boxesOf(input: PackInput, output: PackOutput): Box[] {\n const placements = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (!placements.has(p.id)) placements.set(p.id, p);\n const boxes: Box[] = [];\n for (const [index, item] of input.items.entries()) {\n const p = placements.get(item.id);\n if (p === undefined || !(item.w > 0 && item.h > 0)) continue;\n const turned = p.turn === 90;\n boxes.push({ x: p.x, y: p.y, w: turned ? item.h : item.w, h: turned ? item.w : item.h, rank: item.rank ?? index });\n }\n return boxes;\n}\n\n/**\n * This function tells if box `a` comes before box `b` in the reading order. Two boxes whose heights overlap by more than\n * `RECORD_EPS` are on one line, and the left box comes first. Otherwise the upper box comes first.\n */\nexport function readsBefore(a: Pick<Box, \"x\" | \"y\" | \"h\">, b: Pick<Box, \"x\" | \"y\" | \"h\">): boolean {\n const shared = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);\n if (shared > RECORD_EPS) return a.x + RECORD_EPS < b.x;\n return a.y < b.y;\n}\n\n/** This function sums one measure over the stages of a trace. A trace without the measure gives 0. */\nfunction traceSum(output: PackOutput, id: string): number {\n let sum = 0;\n for (const stage of output.trace) sum += stage.measures[id] ?? 0;\n return sum;\n}\n\n/**\n * This function gives the measures of one layout, by the ids of `docs/MEASURES.md`. The values are not rounded. A\n * record rounds them with `roundMeasures`.\n *\n * - The boxes are the placed items with a width and a height above 0. The hull is the smallest rectangle around them.\n * - An empty layout gives the area 0, the aspect 1 and the aspect error 0. Its fill is 0 and its whitespace is 1.\n * - The time `pack.search.ms` comes from the trace. It is not part of the determinism rule.\n *\n * @example\n * ```ts\n * const m = measure(input, packWith(\"shelf\", input));\n * m[\"pack.fill\"]; // the area of the boxes divided by the area of the hull\n * ```\n */\nexport function measure(input: PackInput, output: PackOutput, options: MeasureOptions = {}): LayoutMeasures {\n const boxes = boxesOf(input, output);\n const hull = hullOf(boxes);\n const hullArea = hull.w * hull.h;\n const boxArea = boxes.reduce((sum, b) => sum + b.w * b.h, 0);\n const fill = hullArea > 0 ? boxArea / hullArea : 0;\n const empty = boxes.length === 0;\n const target = input.container.aspect ?? 1;\n\n // The reading order: each pair of boxes with different ranks, and each step of the rank order\n let pairs = 0;\n let inversions = 0;\n for (let i = 0; i < boxes.length; i++) {\n for (let j = i + 1; j < boxes.length; j++) {\n const a = boxes[i]!;\n const b = boxes[j]!;\n if (a.rank === b.rank) continue;\n pairs += 1;\n const first = a.rank < b.rank ? a : b;\n const second = first === a ? b : a;\n if (readsBefore(second, first)) inversions += 1;\n }\n }\n const byRank = boxes.toSorted((a, b) => a.rank - b.rank);\n let breaks = 0;\n for (let k = 1; k < byRank.length; k++) {\n const prev = byRank[k - 1]!;\n const next = byRank[k]!;\n if (prev.rank !== next.rank && readsBefore(next, prev)) breaks += 1;\n }\n\n const tolerance = options.rowTolerance ?? quantileOrZero(boxes.map((b) => b.h), 0.5) / 2;\n const rights = rowsOf(boxes, tolerance).map((r) => r.right);\n const spread = rights.length > 0 ? Math.max(...rights) - Math.min(...rights) : 0;\n\n return {\n \"pack.area\": hullArea,\n \"pack.fill\": fill,\n \"pack.whitespace\": 1 - fill,\n \"pack.aspect\": empty ? 1 : Math.max(hull.w / hull.h, hull.h / hull.w),\n \"pack.aspectError\": empty ? 0 : aspectError(hull.w, hull.h, target),\n \"pack.order.inversions\": pairs > 0 ? inversions / pairs : 0,\n \"pack.order.breaks\": breaks,\n \"pack.raggedness\": hull.w > 0 ? spread / hull.w : 0,\n \"pack.overflow\": new Set(output.overflow).size,\n \"pack.search.widths\": traceSum(output, \"pack.search.widths\"),\n \"pack.search.ms\": traceSum(output, \"pack.search.ms\"),\n };\n}\n\n/**\n * This function gives the stability measures of a change pair: the run on the base input and the run on the changed\n * input. The items match by id. The values are not rounded.\n *\n * - An item stays when both inputs have it and both outputs place it. The added and the removed items do not count.\n * - A staying item moved when its `x` or its `y` changed by more than `RECORD_EPS`, or when its turn changed.\n * - The distance of an item is the length of the move of its top-left corner. The unit is the width `W`.\n * - `W` is the larger width of the 2 output sizes. A `W` of 0 becomes 1, so the unit is then the unit of the input.\n * - No staying item gives 0 for each measure.\n */\nexport function measureChange(baseInput: PackInput, baseOutput: PackOutput, changeInput: PackInput, changeOutput: PackOutput): ChangeMeasures {\n const placed = (input: PackInput, output: PackOutput): Map<string, PackOutput[\"placements\"][number]> => {\n const ids = new Set(input.items.map((i) => i.id));\n const map = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (ids.has(p.id) && !map.has(p.id)) map.set(p.id, p);\n return map;\n };\n const before = placed(baseInput, baseOutput);\n const after = placed(changeInput, changeOutput);\n const width = Math.max(baseOutput.size.w, changeOutput.size.w);\n const unit = width > 0 ? width : 1;\n\n const distances: number[] = [];\n let moved = 0;\n for (const [id, p] of before) {\n const q = after.get(id);\n if (q === undefined) continue;\n const dx = q.x - p.x;\n const dy = q.y - p.y;\n if (Math.abs(dx) > RECORD_EPS || Math.abs(dy) > RECORD_EPS || (p.turn ?? 0) !== (q.turn ?? 0)) moved += 1;\n distances.push(Math.hypot(dx, dy) / unit);\n }\n if (distances.length === 0) return { \"pack.stability.moved\": 0, \"pack.stability.mean\": 0, \"pack.stability.q95\": 0 };\n return {\n \"pack.stability.moved\": moved / distances.length,\n \"pack.stability.mean\": distances.reduce((sum, d) => sum + d, 0) / distances.length,\n \"pack.stability.q95\": quantile(distances, 0.95),\n };\n}\n\n/**\n * This function gives the measure `pack.deterministic` of two runs with the same input, options and seed. It gives\n * `true` when the runs have the same placements, overflow, size and moved obstacles.\n *\n * - The placements match by id, so their order in the list does not count. The numbers must be equal.\n * - The trace is not part of the rule, because its times change each time.\n */\nexport function isDeterministic(first: PackOutput, second: PackOutput): boolean {\n const key = <T extends { id: string }>(list: readonly T[]): Map<string, T> => new Map(list.map((e) => [e.id, e]));\n const samePlacements = (a: PackOutput[\"placements\"], b: PackOutput[\"placements\"]): boolean => {\n if (a.length !== b.length) return false;\n const other = key(b);\n return a.every((p) => {\n const q = other.get(p.id);\n return q !== undefined && q.x === p.x && q.y === p.y && (q.turn ?? 0) === (p.turn ?? 0);\n });\n };\n const sameMoved = (a: PackOutput[\"moved\"], b: PackOutput[\"moved\"]): boolean => {\n if (a.length !== b.length) return false;\n const other = key(b);\n return a.every((m) => {\n const n = other.get(m.id);\n return n !== undefined && n.x === m.x && n.y === m.y;\n });\n };\n const overflowA = new Set(first.overflow);\n const overflowB = new Set(second.overflow);\n return (\n first.size.w === second.size.w &&\n first.size.h === second.size.h &&\n overflowA.size === overflowB.size &&\n [...overflowA].every((id) => overflowB.has(id)) &&\n samePlacements(first.placements, second.placements) &&\n sameMoved(first.moved, second.moved)\n );\n}\n\n/**\n * This function rounds each number of a record of measures with `round3`, as `docs/FORMAT.md` tells. A half goes up,\n * and `-0` becomes 0. The function keeps the other values, and it does not change its argument.\n */\nexport function roundMeasures<T extends object>(measures: T): T {\n const out: Record<string, unknown> = {};\n for (const [id, value] of Object.entries(measures)) out[id] = typeof value === \"number\" ? round3(value) : value;\n return out as T;\n}\n\n/**\n * This function gives the paired ratio of a measure on one input: the value of the candidate against the value of the\n * current default. A ratio above 1 is worse, in the direction of the measure.\n *\n * - For `lower`, the ratio is `candidate / current`. For `higher`, it is `current / candidate`.\n * - When both values are 0, the ratio is 1. When only the divisor is 0, the ratio is `Infinity`.\n * - The values are 0 or more. A negative value or `NaN` throws a `RangeError`.\n */\nexport function pairedRatio(candidate: number, current: number, direction: Direction): number {\n if (!(candidate >= 0 && current >= 0)) throw new RangeError(\"A paired ratio needs two values of 0 or more.\");\n const top = direction === \"lower\" ? candidate : current;\n const bottom = direction === \"lower\" ? current : candidate;\n if (bottom === 0) return top === 0 ? 1 : Infinity;\n return top / bottom;\n}\n\n/**\n * This function gives the quantile `q` of a list of numbers, with linear interpolation between the sorted values. The\n * position in the sorted list is `(n - 1) * q`. An empty list or a `q` outside 0 to 1 throws a `RangeError`.\n */\nexport function quantile(values: readonly number[], q: number): number {\n if (values.length === 0) throw new RangeError(\"A quantile needs one value or more.\");\n if (!(q >= 0 && q <= 1)) throw new RangeError(\"A quantile needs a q from 0 to 1.\");\n const sorted = values.toSorted((a, b) => a - b);\n const at = (sorted.length - 1) * q;\n const low = Math.floor(at);\n const part = at - low;\n const a = sorted[low]!;\n if (part === 0) return a;\n const b = sorted[low + 1]!;\n if (a === b) return a;\n return a + part * (b - a);\n}\n\n/** This function gives the quantile `q` of a list, and 0 for an empty list. */\nfunction quantileOrZero(values: readonly number[], q: number): number {\n return values.length === 0 ? 0 : quantile(values, q);\n}\n\n/** This function gives the median of the paired ratios of a corpus: the quantile 0.5. It is not a ratio of two medians. */\nexport function medianRatio(ratios: readonly number[]): number {\n return quantile(ratios, 0.5);\n}\n\n/** This function gives the share of the paired ratios above a limit. An empty list throws a `RangeError`. */\nexport function tailShare(ratios: readonly number[], limit: number): number {\n if (ratios.length === 0) throw new RangeError(\"A tail share needs one ratio or more.\");\n return ratios.filter((r) => r > limit).length / ratios.length;\n}\n","import { hullOf, rowsOf } from \"./measures.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/** The measurements of a packing. */\nexport interface PackingMetrics {\n /** The number of rectangles. */\n count: number;\n /** The size of the hull: the smallest box around the rectangles. */\n hull: { width: number; height: number };\n /** The width of the hull divided by its height. A hull without height gives 0. */\n hullAspect: number;\n /** The number of rectangles in each row, from the top. */\n rows: number[];\n /** The largest right edge of a row less the smallest right edge of a row. A straight right side gives 0. */\n raggedness: number;\n /** The part of the hull that the rectangles cover: their area divided by the area of the hull. */\n utilization: number;\n /** The width of the widest rectangle divided by the median width. */\n widestOverMedian: number;\n}\n\n/** The options of `packingMetrics`. */\nexport interface MetricsOptions {\n /** A rectangle joins a row when its top is this close to the top of the first rectangle of the row. The default is 40. */\n rowTolerance?: number;\n}\n\n/**\n * This function measures a packing. It gives the hull and its aspect, the rows and the raggedness of the right side.\n * It also gives the part of the hull that the rectangles cover, and the widest rectangle against the median width.\n *\n * @example\n * ```ts\n * const { utilization, raggedness } = packingMetrics(Rect.packed(cards));\n * ```\n */\nexport function packingMetrics(rects: readonly Rect[], options: MetricsOptions = {}): PackingMetrics {\n const tolerance = options.rowTolerance ?? 40;\n const boxes = rects.filter((r) => r.size.x > 0 && r.size.y > 0).map((r) => ({ x: r.position.x, y: r.position.y, w: r.size.x, h: r.size.y }));\n if (boxes.length === 0) return { count: 0, hull: { width: 0, height: 0 }, hullAspect: 0, rows: [], raggedness: 0, utilization: 0, widestOverMedian: 0 };\n\n // The hull and the rows come from the helpers of `measure`, so the two functions agree\n const box = hullOf(boxes);\n const hull = { width: box.w, height: box.h };\n const rows = rowsOf(boxes, tolerance);\n const rights = rows.map((row) => row.right);\n const widths = boxes.map((r) => r.w).toSorted((a, b) => a - b);\n const median = widths[Math.floor(widths.length / 2)] ?? 0;\n const widest = widths.at(-1) ?? 0;\n const area = boxes.reduce((sum, r) => sum + r.w * r.h, 0);\n return {\n count: boxes.length,\n hull,\n hullAspect: hull.height > 0 ? hull.width / hull.height : 0,\n rows: rows.map((row) => row.count),\n raggedness: Math.max(...rights) - Math.min(...rights),\n utilization: hull.width * hull.height > 0 ? area / (hull.width * hull.height) : 0,\n widestOverMedian: median > 0 ? widest / median : 0,\n };\n}\n","import type { Container, PackInput, PackOutput, Region } from \"./contract.ts\";\n\n/** For each dimension of the taxonomy, the values that a strategy supports. `docs/research/TAXONOMY.md` gives the values. */\nexport interface Supports {\n containerSize: (\"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\")[];\n containerShape: (\"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\")[];\n /** The movement of the obstacles. An empty list supports only an input with no obstacle and no locked item. */\n obstacleMove: (\"fixed\" | \"costly\" | \"free\")[];\n itemShape: (\"rect\" | \"circle\" | \"convex\" | \"polygon\" | \"mixed\")[];\n rotation: (\"none\" | \"quarter\" | \"any\")[];\n order: (\"free\" | \"soft\" | \"hard\")[];\n groups: (\"none\" | \"flat\" | \"nested\")[];\n mode: (\"offline\" | \"online\" | \"incremental\")[];\n}\n\n/** A dimension of `Supports`. */\nexport type Dimension = keyof Supports;\n\n/** A value of a dimension of `Supports`. */\nexport type DimensionValue<D extends Dimension = Dimension> = Supports[D][number];\n\n/**\n * The cell of an input: one value for each packer dimension that the input tells. The input does not tell the mode.\n * Without obstacles and locked items, the cell has no `obstacleMove`.\n */\nexport interface Cell {\n containerSize: DimensionValue<\"containerSize\">;\n containerShape: DimensionValue<\"containerShape\">;\n obstacleMove?: DimensionValue<\"obstacleMove\">;\n itemShape: DimensionValue<\"itemShape\">;\n rotation: DimensionValue<\"rotation\">;\n order: DimensionValue<\"order\">;\n groups: DimensionValue<\"groups\">;\n}\n\n/** The context of one packing. */\nexport interface PackContext {\n /** The seed. A strategy gets each random number from `rng`, not from `Math.random`. */\n seed: number;\n /** The random numbers in `[0, 1)`, from `mulberry32` with `seed`. */\n rng: () => number;\n /** A limit for the strategies that search. The strategy gives its best result at the limit. */\n budget?: { ms?: number; steps?: number };\n /** The previous output, for the mode `incremental`. */\n previous?: PackOutput;\n}\n\n/** A packing strategy behind the Packer interface. */\nexport interface Strategy<O = unknown> {\n /** A stable name, for example `shelf`. The records use it. */\n id: string;\n /** The family of the catalog, for example `shelf` or `skyline`. */\n family: string;\n /** The ids of the catalog rows that this strategy builds. */\n catalog: string[];\n /** The cells that the strategy supports. */\n supports: Supports;\n /** The default options. A record writes the options in full. */\n defaults: O;\n /** The value `true` tells that the result depends only on the input, the options and the seed. */\n deterministic: boolean;\n /** This method packs an input. It throws `UnsupportedCell` for an input outside the cells of `supports`. */\n pack(input: PackInput, options: O, context: PackContext): PackOutput;\n}\n\n/** A size search: it gives a strategy of a fixed width the cells `freeAspect` and `freeArea`. */\nexport interface SizeSearch {\n id: string;\n /** This method searches the size of the container for an input with `fixed` set to `none`. `options` go to `inner`. */\n search(input: PackInput, inner: Strategy, context: PackContext, options?: unknown): PackOutput;\n}\n\n/**\n * The error of a strategy for an input outside its cells. The benchmark records this result. It is not a failure of the\n * strategy.\n */\nexport class UnsupportedCell extends Error {\n /** The dimension of the taxonomy. */\n readonly dimension: Dimension;\n /** The value of the input that the strategy does not support. */\n readonly value: string;\n\n constructor(dimension: Dimension, value: string) {\n super(`The strategy does not support the value \"${value}\" of the dimension \"${dimension}\".`);\n this.name = \"UnsupportedCell\";\n this.dimension = dimension;\n this.value = value;\n }\n}\n\n/** This function gives a generator of random numbers in `[0, 1)`: `mulberry32` of `docs/FORMAT.md`. */\nexport function mulberry32(seed: number): () => number {\n let s = seed >>> 0;\n return () => {\n s = (s + 0x6d2b79f5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** This function makes the context of one packing from a seed. */\nexport function createContext(seed = 0, more: Omit<PackContext, \"seed\" | \"rng\"> = {}): PackContext {\n return { ...more, seed, rng: mulberry32(seed) };\n}\n\n/** This function tells if a polygon ring is convex. A ring with fewer than 3 points is convex. */\nfunction isConvex(points: readonly [number, number][]): boolean {\n let sign = 0;\n const n = points.length;\n for (let i = 0; i < n; i++) {\n const [ax, ay] = points[i]!;\n const [bx, by] = points[(i + 1) % n]!;\n const [cx, cy] = points[(i + 2) % n]!;\n const cross = (bx - ax) * (cy - by) - (by - ay) * (cx - bx);\n if (cross === 0) continue;\n if (sign === 0) sign = Math.sign(cross);\n else if (Math.sign(cross) !== sign) return false;\n }\n return true;\n}\n\n/** This function gives the value of `containerShape` of one region. */\nfunction shapeOf(region: Region): DimensionValue<\"containerShape\"> {\n switch (region.kind) {\n case \"rect\":\n case \"circle\":\n case \"ellipse\":\n return region.kind;\n case \"polygon\":\n if (region.holes && region.holes.length > 0) return \"holes\";\n return isConvex(region.points) ? \"convex\" : \"polygon\";\n }\n}\n\n/** This function gives the value of `itemShape` of one item shape. An ellipse is convex. */\nfunction itemShapeOf(region: Region | undefined): DimensionValue<\"itemShape\"> {\n if (region === undefined) return \"rect\";\n switch (region.kind) {\n case \"rect\":\n case \"circle\":\n return region.kind;\n case \"ellipse\":\n return \"convex\";\n case \"polygon\":\n return !region.holes?.length && isConvex(region.points) ? \"convex\" : \"polygon\";\n }\n}\n\n/**\n * This function gives the cell of an input: the values of the packer dimensions that the input tells.\n *\n * - `containerSize` comes from `fixed`. The value `none` gives `freeArea` when `aspectWeight` is 0, and `freeAspect` if not.\n * - `containerShape` comes from the shape. A rectangle container with an obstacle of another region gives `holes`.\n * - `obstacleMove` is the hardest value of the obstacles and the locked items: `costly`, then `free`, then `fixed`.\n * - `order` is `soft` when an item has a rank, and `free` if not. The input does not tell a hard order.\n * - `groups` is `nested` when an item has a parent, `flat` when an item has a group, and `none` if not.\n */\nexport function cellOf(input: PackInput): Cell {\n const { container, items } = input;\n const obstacles = input.obstacles ?? [];\n\n const sizes: Record<Container[\"fixed\"], DimensionValue<\"containerSize\">> = {\n size: \"fixed\",\n width: \"freeHeight\",\n height: \"freeWidth\",\n none: container.aspectWeight === 0 ? \"freeArea\" : \"freeAspect\",\n };\n const containerSize = sizes[container.fixed];\n\n let containerShape = container.shape ? shapeOf(container.shape) : \"rect\";\n if (containerShape === \"rect\" && obstacles.some((o) => o.region.kind !== \"rect\")) containerShape = \"holes\";\n\n let obstacleMove: DimensionValue<\"obstacleMove\"> | undefined = items.some((i) => i.locked === true) ? \"fixed\" : undefined;\n for (const o of obstacles) {\n const move = o.move === undefined ? \"fixed\" : o.move.cost > 0 ? \"costly\" : \"free\";\n if (move === \"costly\" || obstacleMove === undefined || (move === \"free\" && obstacleMove === \"fixed\")) obstacleMove = move;\n }\n\n const shapes = new Set(items.map((i) => itemShapeOf(i.shape)));\n const itemShape = shapes.size > 1 ? \"mixed\" : ([...shapes][0] ?? \"rect\");\n\n const cell: Cell = {\n containerSize,\n containerShape,\n itemShape,\n rotation: items.some((i) => i.turnable === true) ? \"quarter\" : \"none\",\n order: items.some((i) => i.rank !== undefined) ? \"soft\" : \"free\",\n groups: items.some((i) => i.parent !== undefined) ? \"nested\" : items.some((i) => i.group !== undefined) ? \"flat\" : \"none\",\n };\n if (obstacleMove !== undefined) cell.obstacleMove = obstacleMove;\n return cell;\n}\n\n/** This function gives the first dimension of a cell that `supports` does not hold, or `undefined` when it holds each one. */\nexport function unsupportedOf(supports: Supports, cell: Partial<Record<Dimension, string>>): { dimension: Dimension; value: string } | undefined {\n for (const dimension of Object.keys(supports) as Dimension[]) {\n const value = cell[dimension];\n if (value === undefined) continue;\n if (!(supports[dimension] as readonly string[]).includes(value)) return { dimension, value };\n }\n return undefined;\n}\n\n/** This function tells if `supports` holds each value of a cell. A dimension that the cell does not have is held. */\nexport function supportsCell(supports: Supports, cell: Partial<Record<Dimension, string>>): boolean {\n return unsupportedOf(supports, cell) === undefined;\n}\n\n/** This function throws `UnsupportedCell` for the first value of the cell of an input that `supports` does not hold. */\nexport function assertSupported(supports: Supports, input: PackInput): void {\n const miss = unsupportedOf(supports, cellOf(input));\n if (miss) throw new UnsupportedCell(miss.dimension, miss.value);\n}\n","// The internal frame of the adapters of 0.1: the conversion of a PackInput to the Rect objects of 0.1, and back.\n// Each item grows by its margin and by half the gap on each side. Each obstacle grows by half the gap. Thus two items\n// are `mA + gap + mB` apart. The area of the frame is the container less the inset, grown by half the gap on each side.\n\nimport { EPS, marginOf, type Item, type Obstacle, type PackInput, type PackOutput, type Placement, type Region, type StageTrace } from \"./contract.ts\";\nimport { Rect } from \"./rect.ts\";\n\nconst clock = (globalThis as { performance?: { now(): number } }).performance;\n\n/** This function gives the time in milliseconds. */\nexport function now(): number {\n return clock ? clock.now() : Date.now();\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): { x: number; y: number; w: number; h: number } {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n const xs = region.points.map((p) => p[0]);\n const ys = region.points.map((p) => p[1]);\n const x = Math.min(...xs);\n const y = Math.min(...ys);\n return { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y };\n }\n }\n}\n\n/** The rectangle of a container: its origin and its size. A free side has the size `Infinity`. */\nexport interface Bounds {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** This function gives the rectangle of a container. A rectangle shape gives the origin and the sizes of the fixed sides. */\nexport function containerBounds(input: PackInput): Bounds {\n const { container } = input;\n const shape = container.shape === undefined ? undefined : boundsOf(container.shape);\n const fixedW = container.fixed === \"size\" || container.fixed === \"width\";\n const fixedH = container.fixed === \"size\" || container.fixed === \"height\";\n const w = shape?.w ?? container.w;\n const h = shape?.h ?? container.h;\n if (fixedW && w === undefined) throw new TypeError(`A container with fixed \"${container.fixed}\" needs a width.`);\n if (fixedH && h === undefined) throw new TypeError(`A container with fixed \"${container.fixed}\" needs a height.`);\n return { x: shape?.x ?? 0, y: shape?.y ?? 0, w: fixedW ? w! : Infinity, h: fixedH ? h! : Infinity };\n}\n\n/** One rectangle of the frame, and the item or the obstacle that it measures. */\nexport interface Entry {\n rect: Rect<number>;\n item?: Item;\n obstacle?: Obstacle;\n /** The offset from the corner of the rectangle to the corner of the item or the obstacle. */\n dx: number;\n dy: number;\n}\n\n/** The rectangles of 0.1 for one input. */\nexport interface Frame {\n /** The container coordinates of the origin of the frame. */\n ox: number;\n oy: number;\n /** The size of the area of the frame. A free side has the size `Infinity`. */\n w: number;\n h: number;\n bounds: Bounds;\n inset: number;\n /** The items in the order of their rank, then the obstacles. */\n entries: Entry[];\n /** The ids of the items that are too large for the area. The frame has no rectangle for them. */\n tooLarge: string[];\n}\n\n/** This function gives the items in the order of their rank. The index in the array is the rank of an item without one. */\nexport function byRank(items: readonly Item[]): Item[] {\n return items\n .map((item, index) => ({ item, rank: item.rank ?? index }))\n .toSorted((a, b) => a.rank - b.rank)\n .map((e) => e.item);\n}\n\n/**\n * This function makes the frame of an input. A locked item with a position and an obstacle without `move` are locked\n * rectangles. An obstacle with `move` is a free rectangle only when `movable` is `true`.\n */\nexport function buildFrame(input: PackInput, movable = false): Frame {\n const bounds = containerBounds(input);\n const inset = input.container.inset ?? 0;\n const half = (input.gap ?? 0) / 2;\n const ox = bounds.x + inset - half;\n const oy = bounds.y + inset - half;\n const w = bounds.w - 2 * inset + 2 * half;\n const h = bounds.h - 2 * inset + 2 * half;\n const entries: Entry[] = [];\n const tooLarge: string[] = [];\n\n for (const item of byRank(input.items)) {\n const m = marginOf(item);\n const rect = new Rect<number>();\n rect.size.set(item.w + m.left + m.right + 2 * half, item.h + m.top + m.bottom + 2 * half);\n const dx = m.left + half;\n const dy = m.top + half;\n if (item.locked === true && item.x !== undefined && item.y !== undefined) {\n rect.locked = true;\n rect.position.set(item.x - dx - ox, item.y - dy - oy);\n } else if (rect.size.x > w + EPS || rect.size.y > h + EPS) {\n tooLarge.push(item.id);\n continue;\n }\n entries.push({ rect, item, dx, dy });\n }\n\n for (const obstacle of input.obstacles ?? []) {\n const b = boundsOf(obstacle.region);\n const rect = new Rect<number>();\n rect.size.set(b.w + 2 * half, b.h + 2 * half);\n rect.position.set(b.x - half - ox, b.y - half - oy);\n rect.locked = !(movable && obstacle.move !== undefined);\n entries.push({ rect, obstacle, dx: half, dy: half });\n }\n return { ox, oy, w, h, bounds, inset, entries, tooLarge };\n}\n\n/** This function gives the outer rectangle of 0.1 for a frame. A free height starts at 0 and grows. */\nexport function outerOf(frame: Frame): Rect<number> {\n const outer = new Rect<number>();\n const fixedSize = Number.isFinite(frame.h);\n outer.size.set(frame.w, fixedSize ? frame.h : 0);\n outer.fixedWidth = true;\n outer.fixedSize = fixedSize;\n return outer;\n}\n\n/** This function gives the rectangles of a frame, in the order of the entries. */\nexport function rectsOf(frame: Frame): Rect<number>[] {\n return frame.entries.map((e) => e.rect);\n}\n\n/**\n * This function reads the output from the rectangles of a frame after a packing of 0.1. A locked item keeps its\n * position exactly. Each other item that the packer did not place goes to the overflow.\n */\nexport function readFrame(input: PackInput, frame: Frame, trace: StageTrace[], moved: PackOutput[\"moved\"] = []): PackOutput {\n const placements: Placement[] = [];\n const overflow: string[] = [...frame.tooLarge];\n for (const e of frame.entries) {\n const item = e.item;\n if (item === undefined) continue;\n if (item.locked === true && item.x !== undefined && item.y !== undefined) placements.push({ id: item.id, x: item.x, y: item.y });\n else if (e.rect.wasPacked) placements.push({ id: item.id, x: e.rect.position.x + e.dx + frame.ox, y: e.rect.position.y + e.dy + frame.oy });\n else overflow.push(item.id);\n }\n return { placements, overflow, size: sizeOf(input, frame, placements, moved), moved, trace };\n}\n\n/**\n * This function gives the size of the container after a packing. A fixed side keeps its size. A free side goes to the\n * far edge of the items with their margins and the inset, or of the obstacles.\n */\nfunction sizeOf(input: PackInput, frame: Frame, placements: Placement[], moved: PackOutput[\"moved\"]): { w: number; h: number } {\n const items = new Map(input.items.map((i) => [i.id, i]));\n let right = 0;\n let bottom = 0;\n for (const p of placements) {\n const item = items.get(p.id)!;\n const m = marginOf(item);\n right = Math.max(right, p.x + item.w + m.right + frame.inset - frame.bounds.x);\n bottom = Math.max(bottom, p.y + item.h + m.bottom + frame.inset - frame.bounds.y);\n }\n const movedById = new Map(moved.map((m) => [m.id, m]));\n for (const o of input.obstacles ?? []) {\n const b = boundsOf(o.region);\n const at = movedById.get(o.id) ?? b;\n right = Math.max(right, at.x + b.w - frame.bounds.x);\n bottom = Math.max(bottom, at.y + b.h - frame.bounds.y);\n }\n return {\n w: Number.isFinite(frame.bounds.w) ? frame.bounds.w : right,\n h: Number.isFinite(frame.bounds.h) ? frame.bounds.h : bottom,\n };\n}\n\n/** This function gives a region with the axes changed: x for y, and w for h. */\nexport function transposeRegion(region: Region): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: region.y, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { kind: \"circle\", cx: region.cy, cy: region.cx, r: region.r };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const swap = (ring: [number, number][]): [number, number][] => ring.map(([x, y]) => [y, x]);\n const turned: Region = { kind: \"polygon\", points: swap(region.points) };\n if (region.holes) turned.holes = region.holes.map(swap);\n return turned;\n }\n }\n}\n\n/** This function gives an item with the axes changed. The ports go, because the adapters of 0.1 do not read them. */\nfunction transposeItem(item: Item): Item {\n const { ports: _ports, ...rest } = item;\n const turned: Item = { ...rest, w: item.h, h: item.w };\n delete turned.x;\n delete turned.y;\n if (item.y !== undefined) turned.x = item.y;\n if (item.x !== undefined) turned.y = item.x;\n if (item.shape) turned.shape = transposeRegion(item.shape);\n if (item.margin !== undefined && typeof item.margin !== \"number\") {\n const m = item.margin;\n turned.margin = { top: m.left, right: m.bottom, bottom: m.right, left: m.top };\n }\n return turned;\n}\n\n/** This function gives an input with the axes changed. A fixed height becomes a fixed width. */\nexport function transposeInput(input: PackInput): PackInput {\n const c = input.container;\n const container: PackInput[\"container\"] = { fixed: c.fixed === \"height\" ? \"width\" : c.fixed === \"width\" ? \"height\" : c.fixed };\n if (c.h !== undefined) container.w = c.h;\n if (c.w !== undefined) container.h = c.w;\n if (c.aspect !== undefined) container.aspect = 1 / c.aspect;\n if (c.aspectWeight !== undefined) container.aspectWeight = c.aspectWeight;\n if (c.shape !== undefined) container.shape = transposeRegion(c.shape);\n if (c.inset !== undefined) container.inset = c.inset;\n const turned: PackInput = { container, items: input.items.map(transposeItem) };\n if (input.obstacles) turned.obstacles = input.obstacles.map((o) => ({ ...o, region: transposeRegion(o.region) }));\n if (input.gap !== undefined) turned.gap = input.gap;\n return turned;\n}\n\n/** This function gives an output with the axes changed. */\nexport function transposeOutput(output: PackOutput): PackOutput {\n return {\n placements: output.placements.map((p) => ({ ...p, x: p.y, y: p.x })),\n overflow: [...output.overflow],\n size: { w: output.size.h, h: output.size.w },\n moved: output.moved.map((m) => ({ id: m.id, x: m.y, y: m.x })),\n trace: output.trace,\n };\n}\n\n/**\n * This function packs an input with a fixed height through the turn of the axes. It changes x for y in the input.\n * Then it packs with a fixed width, and changes the axes of the output back.\n */\nexport function viaAxes(input: PackInput, previous: PackOutput | undefined, run: (turned: PackInput, previous: PackOutput | undefined) => PackOutput): PackOutput {\n const start = now();\n const turned = transposeInput(input);\n const inner = run(turned, previous === undefined ? undefined : transposeOutput(previous));\n const output = transposeOutput(inner);\n output.trace = [{ id: \"axes\", ms: now() - start, measures: {} }, ...inner.trace];\n return output;\n}\n","// The adapters of 0.1 (docs/PACKER.md): each function of 0.1 runs behind the Packer interface as a strategy.\n\nimport { EPS, type PackInput, type PackOutput } from \"./contract.ts\";\nimport { boundsOf, buildFrame, now, outerOf, readFrame, rectsOf, viaAxes, type Entry } from \"./frame.ts\";\nimport { packFree } from \"./free.ts\";\nimport type { SortOrder } from \"./order.ts\";\nimport { pack } from \"./pack.ts\";\nimport { pushCascade } from \"./push.ts\";\nimport { Rect } from \"./rect.ts\";\nimport { packSkyline } from \"./skyline.ts\";\nimport { assertSupported, cellOf, UnsupportedCell, type PackContext, type SizeSearch, type Strategy, type Supports } from \"./strategy.ts\";\n\n/** The options of the strategies `rows`, `skyline` and `shelf`. */\nexport interface LayoutStrategyOptions {\n /** The order of the items before the packing. The items are in the order of their rank first. */\n sortOrder: SortOrder;\n /** The number of widths that the first pass of the size search `log-sweep` tries. */\n samples: number;\n}\n\n/** The options of the strategy `push`. */\nexport interface PushStrategyOptions {\n /** The order of the items that the cascade does not place. */\n sortOrder: SortOrder;\n /** The most shoves for each item. The cascade stops at this limit. */\n maxShovesPerItem: number;\n}\n\n/** The cells of `rows`, `skyline` and `shelf`, without the movement of the obstacles. */\nconst LAYOUT_CELLS = {\n containerSize: [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"],\n containerShape: [\"rect\"],\n itemShape: [\"rect\"],\n rotation: [\"none\"],\n groups: [\"none\"],\n mode: [\"offline\"],\n} as const satisfies Partial<Supports>;\n\n/** This function makes the supports of a strategy, with copies of each list. */\nfunction supportsOf(cells: { [D in keyof Supports]: readonly Supports[D][number][] }): Supports {\n return {\n containerSize: [...cells.containerSize],\n containerShape: [...cells.containerShape],\n obstacleMove: [...cells.obstacleMove],\n itemShape: [...cells.itemShape],\n rotation: [...cells.rotation],\n order: [...cells.order],\n groups: [...cells.groups],\n mode: [...cells.mode],\n };\n}\n\n/** This function packs an input with a fixed size or a fixed width with one strategy of `pack`. */\nfunction packFixedWidth(id: \"rows\" | \"skyline\" | \"shelf\", input: PackInput, options: LayoutStrategyOptions): PackOutput {\n const start = now();\n const frame = buildFrame(input);\n const rects = rectsOf(frame);\n if (frame.w > 0) pack(rects, outerOf(frame), { strategy: id, sortOrder: options.sortOrder });\n const output = readFrame(input, frame, []);\n output.trace.push({ id, ms: now() - start, measures: { \"pack.overflow\": output.overflow.length } });\n return output;\n}\n\n/** This function makes the strategy of one function of `pack`. */\nfunction layoutStrategy(\n id: \"rows\" | \"skyline\" | \"shelf\",\n family: string,\n catalog: string[],\n cells: Pick<Supports, \"obstacleMove\" | \"order\">,\n): Strategy<LayoutStrategyOptions> {\n const self: Strategy<LayoutStrategyOptions> = {\n id,\n family,\n catalog,\n supports: supportsOf({ ...LAYOUT_CELLS, ...cells }),\n defaults: { sortOrder: \"height-desc\", samples: 48 },\n deterministic: true,\n pack(input, options, context) {\n assertSupported(self.supports, input);\n const o = { ...self.defaults, ...options };\n switch (input.container.fixed) {\n case \"height\":\n return viaAxes(input, context.previous, (turned) => packFixedWidth(id, turned, o));\n case \"none\":\n return logSweep.search(input, self, context, o);\n default:\n return packFixedWidth(id, input, o);\n }\n },\n };\n return self;\n}\n\n/**\n * The strategy `rows` uses `packRows`: a guillotine row packing with a recursive gap fill. It supports no obstacle and\n * no locked item, because `packRows` does not go around them. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const rows: Strategy<LayoutStrategyOptions> = layoutStrategy(\"rows\", \"shelf\", [\"rows-gap-fill\", \"rows-input\"], {\n obstacleMove: [],\n order: [\"free\", \"soft\", \"hard\"],\n});\n\n/**\n * The strategy `skyline` uses `packSkyline`: each item goes to the lowest place where it fits. It packs around the\n * locked items and the fixed obstacles. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const skyline: Strategy<LayoutStrategyOptions> = layoutStrategy(\"skyline\", \"skyline\", [\"skyline-bl\"], {\n obstacleMove: [\"fixed\"],\n order: [\"free\", \"soft\"],\n});\n\n/**\n * The strategy `shelf` uses `packShelf`: rows filled left to right, around the locked items and the fixed obstacles.\n * With the sort order `input`, the rows keep the rank order. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const shelf: Strategy<LayoutStrategyOptions> = layoutStrategy(\"shelf\", \"shelf\", [\"shelf-nf\", \"shelf-nfdh\"], {\n obstacleMove: [\"fixed\"],\n order: [\"free\", \"soft\", \"hard\"],\n});\n\n/**\n * The size search `log-sweep` uses `packFree` of 0.1.2: widths on a log scale, then the widths near the best width. It\n * wraps `rows`, `skyline` and `shelf`. The objective is the area of the frame times `1 + aspectWeight * aspectError`.\n */\nexport const logSweep: SizeSearch = {\n id: \"log-sweep\",\n search(input: PackInput, inner: Strategy, context: PackContext, options?: unknown): PackOutput {\n if (input.container.fixed !== \"none\") return inner.pack(input, options ?? inner.defaults, context);\n const id = inner.id;\n if (id !== \"rows\" && id !== \"skyline\" && id !== \"shelf\") throw new UnsupportedCell(\"containerSize\", cellOf(input).containerSize);\n const o = { ...(inner.defaults as LayoutStrategyOptions), ...(options as Partial<LayoutStrategyOptions> | undefined) };\n const start = now();\n const frame = buildFrame(input);\n const result = packFree(rectsOf(frame), new Rect<number>(), {\n strategy: id,\n sortOrder: o.sortOrder,\n samples: o.samples,\n aspect: input.container.aspect ?? 1,\n aspectWeight: input.container.aspectWeight ?? 1,\n });\n const ms = now() - start;\n const runs = result.tried.length + 1;\n const output = readFrame(input, frame, []);\n output.trace.push(\n { id: \"log-sweep\", ms, measures: { \"pack.search.widths\": result.tried.length, \"pack.search.ms\": ms } },\n { id, ms: ms / runs, measures: { \"pack.overflow\": output.overflow.length } },\n );\n return output;\n },\n};\n\n/** This function tells if the insides of two rectangles overlap by more than `EPS`. */\nfunction overlaps(a: Rect, b: Rect): boolean {\n return (\n Math.min(a.right(), b.right()) - Math.max(a.position.x, b.position.x) > EPS &&\n Math.min(a.bottom(), b.bottom()) - Math.max(a.position.y, b.position.y) > EPS\n );\n}\n\n/** This function packs an input with a fixed size or a fixed width with a push cascade. */\nfunction pushFixedWidth(input: PackInput, options: PushStrategyOptions, previous: PackOutput | undefined): PackOutput {\n const start = now();\n const frame = buildFrame(input, true);\n const before = new Map(previous?.placements.map((p) => [p.id, p]));\n const positioned: Entry[] = [];\n const pending: Entry[] = [];\n const obstacles = frame.entries.filter((e) => e.obstacle !== undefined);\n const starts = new Map(obstacles.map((e) => [e, { x: e.rect.position.x, y: e.rect.position.y }]));\n const lockedItems = frame.entries.filter((e) => e.item !== undefined && e.rect.locked);\n\n for (const e of frame.entries) {\n const item = e.item;\n if (item === undefined || e.rect.locked) continue;\n const x = item.x ?? before.get(item.id)?.x;\n const y = item.y ?? before.get(item.id)?.y;\n if (x === undefined || y === undefined) {\n pending.push(e);\n continue;\n }\n e.rect.position.set(x - e.dx - frame.ox, y - e.dy - frame.oy);\n positioned.push(e);\n }\n\n // The cascade: each item in the order of its rank pushes the others, and then it stays\n const inPlay = frame.entries.filter((e) => !pending.includes(e)).map((e) => e.rect);\n const maxShoves = options.maxShovesPerItem * Math.max(1, inPlay.length);\n for (const e of positioned) {\n pushCascade(e.rect, inPlay, { gap: 0, maxShoves });\n e.rect.locked = true;\n }\n\n // An obstacle that the cascade pushed out of the container or onto a locked item goes back to its start\n const { bounds } = frame;\n const moved: PackOutput[\"moved\"] = [];\n for (const e of obstacles) {\n const startAt = starts.get(e)!;\n const x = e.rect.position.x + e.dx + frame.ox;\n const y = e.rect.position.y + e.dy + frame.oy;\n const b = boundsOf(e.obstacle!.region);\n const out = x < bounds.x - EPS || y < bounds.y - EPS || x + b.w > bounds.x + bounds.w + EPS || y + b.h > bounds.y + bounds.h + EPS;\n if (out || lockedItems.some((l) => overlaps(l.rect, e.rect))) e.rect.position.set(startAt.x, startAt.y);\n else if (Math.abs(e.rect.position.x - startAt.x) > EPS || Math.abs(e.rect.position.y - startAt.y) > EPS) moved.push({ id: e.obstacle!.id, x, y });\n }\n const pushMs = now() - start;\n\n // Each item that is out of the area or overlaps a kept rectangle goes to the skyline, around the kept rectangles\n const kept = [...obstacles, ...lockedItems].map((e) => e.rect);\n for (const e of positioned) {\n const r = e.rect;\n const inside = r.position.x >= -EPS && r.position.y >= -EPS && r.right() <= frame.w + EPS && r.bottom() <= frame.h + EPS;\n if (inside && !kept.some((k) => overlaps(k, r))) kept.push(r);\n else pending.push(e);\n }\n const skylineStart = now();\n for (const r of kept) {\n r.locked = true;\n r.wasPacked = true;\n }\n if (pending.length > 0 && frame.w > 0) {\n for (const e of pending) {\n e.rect.locked = false;\n e.rect.wasPacked = false;\n }\n packSkyline([...pending.map((e) => e.rect), ...kept], outerOf(frame), { sortOrder: options.sortOrder });\n }\n const output = readFrame(input, frame, [], moved);\n output.trace.push(\n { id: \"push\", ms: pushMs, measures: { \"pack.push.moved\": moved.length } },\n { id: \"skyline\", ms: now() - skylineStart, measures: { \"pack.push.replaced\": pending.length, \"pack.overflow\": output.overflow.length } },\n );\n return output;\n}\n\n/**\n * The strategy `push` uses `pushCascade`. Each item starts at its `x` and `y`, or at its place in `context.previous`.\n * Each item in rank order pushes the items and the movable obstacles that it overlaps. Then `packSkyline` places the\n * items with no start, and the items that still overlap. The output tells each obstacle that moved.\n */\nexport const push: Strategy<PushStrategyOptions> = {\n id: \"push\",\n family: \"incremental\",\n catalog: [\"incremental-push\"],\n supports: supportsOf({\n containerSize: [\"fixed\", \"freeHeight\", \"freeWidth\"],\n containerShape: [\"rect\"],\n obstacleMove: [\"fixed\", \"free\"],\n itemShape: [\"rect\"],\n rotation: [\"none\"],\n order: [\"free\", \"soft\"],\n groups: [\"none\"],\n mode: [\"incremental\"],\n }),\n defaults: { sortOrder: \"height-desc\", maxShovesPerItem: 8 },\n deterministic: true,\n pack(input, options, context) {\n assertSupported(push.supports, input);\n const o = { ...push.defaults, ...options };\n if (input.container.fixed === \"height\") return viaAxes(input, context.previous, (turned, previous) => pushFixedWidth(turned, o, previous));\n return pushFixedWidth(input, o, context.previous);\n },\n};\n","import type { Item, PackInput, PackOutput } from \"./contract.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/**\n * This function makes a `PackInput` from the `Rect` objects of 0.1. The id of each item is the index of its rectangle.\n *\n * - `fixedSize` gives `fixed` set to `size`, `fixedWidth` gives `width`, and an outer rectangle without them gives `none`.\n * - A locked rectangle gives a locked item at its position.\n * - An outer rectangle at a position other than 0, 0 gives a rectangle shape at that position.\n */\nexport function fromRects<T>(rects: readonly Rect<T>[], outer: Rect<T>): PackInput {\n const fixed = outer.fixedSize ? \"size\" : outer.fixedWidth ? \"width\" : \"none\";\n const container: PackInput[\"container\"] = { fixed };\n if (fixed !== \"none\") container.w = outer.size.x;\n if (fixed === \"size\") container.h = outer.size.y;\n if (outer.position.x !== 0 || outer.position.y !== 0) {\n container.shape = { kind: \"rect\", x: outer.position.x, y: outer.position.y, w: outer.size.x, h: outer.size.y };\n }\n const items = rects.map((r, i): Item => {\n const item: Item = { id: String(i), w: r.size.x, h: r.size.y };\n if (r.locked) {\n item.locked = true;\n item.x = r.position.x;\n item.y = r.position.y;\n }\n return item;\n });\n return { container, items };\n}\n\n/**\n * This function writes an output back into the `Rect` objects of `fromRects`. It sets the position and `wasPacked` of\n * each rectangle, and the free sides of the outer rectangle. It gives the outer rectangle.\n */\nexport function toRects<T>(output: PackOutput, rects: Rect<T>[], outer: Rect<T>): Rect<T> {\n const placements = new Map(output.placements.map((p) => [p.id, p]));\n for (const [i, r] of rects.entries()) {\n const p = placements.get(String(i));\n if (p === undefined) {\n r.wasPacked = r.locked;\n continue;\n }\n r.position.set(p.x, p.y);\n r.wasPacked = true;\n }\n if (!outer.fixedSize) {\n if (!outer.fixedWidth) outer.size.x = output.size.w;\n outer.size.y = output.size.h;\n }\n return outer;\n}\n","import { push, rows, shelf, skyline } from \"./adapters.ts\";\nimport type { PackInput, PackOutput } from \"./contract.ts\";\nimport { createContext, type Strategy } from \"./strategy.ts\";\n\n/** Each strategy of the package. The benchmark starts each one on each input of the corpus. */\nexport const strategies: readonly Strategy[] = Object.freeze([rows, skyline, shelf, push] as Strategy[]);\n\n/** This function gives the strategy with an id. It throws a `RangeError` for an id that the registry does not have. */\nexport function strategy(id: string): Strategy {\n const found = strategies.find((s) => s.id === id);\n if (found === undefined) throw new RangeError(`The registry has no strategy \"${id}\".`);\n return found;\n}\n\n/**\n * This function packs an input with the strategy of an id. The options go over the defaults of the strategy. The\n * context gets `mulberry32` with the seed. The default seed is 0.\n */\nexport function packWith(id: string, input: PackInput, options?: unknown, seed = 0): PackOutput {\n const s = strategy(id);\n const merged: unknown = { ...(s.defaults as object), ...(options as object | undefined) };\n return s.pack(input, merged, createContext(seed));\n}\n","import { DEFAULT_TOLERANCE, marginOf, RECORD_EPS, turnItem, type Item, type PackInput, type PackOutput, type Tolerance } from \"./contract.ts\";\nimport { boundsOf } from \"./frame.ts\";\n\n/** The count of the breaks of each hard rule of the packer (`docs/FORMAT.md`). A good run has 0 for each rule. */\nexport interface HardBreaks {\n \"no-overlap\": number;\n \"in-container\": number;\n \"locked-kept\": number;\n complete: number;\n}\n\n/** A box with its margin: the left, top, right and bottom edges. */\ninterface Box {\n l: number;\n t: number;\n r: number;\n b: number;\n}\n\n/** This function tells if the insides of two boxes overlap by more than a tolerance on each axis. */\nfunction overlap(a: Box, b: Box, tolerance: number): boolean {\n return Math.min(a.r, b.r) - Math.max(a.l, b.l) > tolerance && Math.min(a.b, b.b) - Math.max(a.t, b.t) > tolerance;\n}\n\n/**\n * This function counts the breaks of the 4 hard rules of the packer for an output.\n *\n * - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.\n * - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`.\n * - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no position.\n * - `complete`: each item with no position that is not in the overflow.\n *\n * The rules read a shape of the container or of an obstacle as its bounding box. The result has no tolerance in it.\n */\nexport function checkHard(input: PackInput, output: PackOutput, tolerance: Pick<Tolerance, \"overlap\"> = DEFAULT_TOLERANCE): HardBreaks {\n const tol = tolerance.overlap;\n const placements = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (!placements.has(p.id)) placements.set(p.id, p);\n const overflow = new Set(output.overflow);\n const breaks: HardBreaks = { \"no-overlap\": 0, \"in-container\": 0, \"locked-kept\": 0, complete: 0 };\n\n const boxes: Box[] = [];\n for (const item of input.items) {\n const p = placements.get(item.id);\n if (p === undefined) {\n if (item.locked === true && item.x !== undefined && item.y !== undefined) breaks[\"locked-kept\"] += 1;\n if (!overflow.has(item.id)) breaks.complete += 1;\n continue;\n }\n if (item.locked === true && item.x !== undefined && item.y !== undefined) {\n if (Math.abs(p.x - item.x) > RECORD_EPS || Math.abs(p.y - item.y) > RECORD_EPS) breaks[\"locked-kept\"] += 1;\n }\n const placed: Item = p.turn === 90 ? turnItem(item) : item;\n const m = marginOf(placed);\n boxes.push({ l: p.x - m.left, t: p.y - m.top, r: p.x + placed.w + m.right, b: p.y + placed.h + m.bottom });\n }\n\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const obstacles: Box[] = (input.obstacles ?? []).map((o) => {\n const b = boundsOf(o.region);\n const at = moved.get(o.id) ?? b;\n return { l: at.x, t: at.y, r: at.x + b.w, b: at.y + b.h };\n });\n\n for (const [i, a] of boxes.entries()) {\n for (let j = i + 1; j < boxes.length; j++) if (overlap(a, boxes[j]!, tol)) breaks[\"no-overlap\"] += 1;\n for (const o of obstacles) if (overlap(a, o, tol)) breaks[\"no-overlap\"] += 1;\n }\n\n const { container } = input;\n const shape = container.shape === undefined ? undefined : boundsOf(container.shape);\n const x = shape?.x ?? 0;\n const y = shape?.y ?? 0;\n const w = shape?.w ?? container.w ?? Infinity;\n const h = shape?.h ?? container.h ?? Infinity;\n const fixedW = container.fixed === \"size\" || container.fixed === \"width\";\n const fixedH = container.fixed === \"size\" || container.fixed === \"height\";\n for (const box of boxes) {\n const outX = fixedW && (box.l < x - tol || box.r > x + w + tol);\n const outY = fixedH && (box.t < y - tol || box.b > y + h + tol);\n if (outX || outY) breaks[\"in-container\"] += 1;\n }\n return breaks;\n}\n","// The seeded generators of the corpus (`docs/FORMAT.md`, \"The generators\"). Each generator is a pipeline of 3 steps: the\n// container, then the obstacles, then the boxes. Each step has its own random numbers: `mulberry32` of\n// `fnv1a32(\"<seed>:<step>\")`. Thus a packing input and a routing input with the same seed get the same obstacles.\n\nimport type { Container, Item, Obstacle, Region } from \"./contract.ts\";\nimport {\n countCell,\n fnv1a32,\n hashInput,\n round3,\n type CorpusCell,\n type GeneratorParams,\n type LayoutInput,\n type ObstacleLayout,\n type SizeDistribution,\n} from \"./layout-input.ts\";\nimport { mulberry32, type DimensionValue } from \"./strategy.ts\";\n\n/** The largest count of boxes that a generator makes. */\nconst MAX_COUNT = 100_000;\n\n/** A seeded generator of `layout-input/1` files. The same version, parameters and seed give the same file, byte for byte. */\nexport interface CorpusGenerator<P extends GeneratorParams = GeneratorParams> {\n /** The name. The file writes it in `generator.name`. */\n readonly name: string;\n /** The version. A change of the output of a generator needs a new version. */\n readonly version: number;\n /** The default set of an input, when the call gives no set. */\n readonly set: string;\n /** The default parameters. */\n readonly defaults: Readonly<P>;\n /** For each parameter with a list of values, the values that the generator accepts. */\n readonly values: { readonly [K in keyof P]?: readonly P[K][] };\n /** This method gives the full parameters: the defaults with the given parameters over them. It throws a `RangeError` for a bad parameter. */\n withDefaults(params?: Partial<P>): P;\n /** This method gives the cell of each input of the parameters. The cell does not depend on the seed. */\n cell(params?: Partial<P>): CorpusCell;\n /** This method gives the input file of a seed. The `id` is `<set>/<family>/s<seed>`. */\n generate(seed: number, params?: Partial<P>, set?: string): LayoutInput;\n}\n\n/** The parts of a file that a generator makes. */\ntype Parts = Pick<LayoutInput, \"container\" | \"boxes\"> & { obstacles: Obstacle[] };\n\n/** The data of a generator, before `defineGenerator` adds the common steps. */\ninterface GeneratorSpec<P extends GeneratorParams> {\n name: string;\n version: number;\n set: string;\n defaults: P;\n values: { readonly [K in keyof P]?: readonly P[K][] };\n family(params: P): string;\n cell(params: P): CorpusCell;\n build(seed: number, params: P): Parts;\n}\n\n/** A rectangle area in which the obstacles and the sizes of the boxes are made. */\ninterface Frame {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** This function gives the random numbers of one step of a seed. */\nconst stepRandom = (seed: number, step: string): (() => number) => mulberry32(fnv1a32(`${seed}:${step}`));\n\n/** A whole number from lo to hi, both included. */\nconst int = (r: () => number, lo: number, hi: number): number => lo + Math.floor(r() * (hi - lo + 1));\n\n/** A whole number from the floor of lo to the floor of hi, both included. The upper end is not less than the lower end at any time. */\nconst span = (r: () => number, lo: number, hi: number): number => {\n const a = Math.floor(lo);\n return int(r, a, Math.max(a, Math.floor(hi)));\n};\n\n/** A number from lo to hi. */\nconst between = (r: () => number, lo: number, hi: number): number => lo + r() * (hi - lo);\n\n/** This function gives an index with a probability in proportion to its weight. */\nconst pick = (r: () => number, weights: readonly number[]): number => {\n let x = r() * weights.reduce((a, b) => a + b, 0);\n for (const [i, w] of weights.entries()) {\n x -= w;\n if (x < 0) return i;\n }\n return weights.length - 1;\n};\n\n/** This function gives a copy of a value with each number rounded by `round3`. A key with the value `undefined` goes. */\nfunction roundNumbers<T>(value: T): T {\n if (typeof value === \"number\") return round3(value) as T;\n if (Array.isArray(value)) return value.map(roundNumbers) as T;\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) if (v !== undefined) out[k] = roundNumbers(v);\n return out as T;\n }\n return value;\n}\n\n/** This function gives the cell of an input with rectangle items, no rotation, no order and no groups. */\nfunction cellWith(\n containerSize: DimensionValue<\"containerSize\">,\n containerShape: DimensionValue<\"containerShape\">,\n obstacles: ObstacleLayout,\n sizes: SizeDistribution,\n count: number,\n locked = false,\n): CorpusCell {\n const cell: CorpusCell = {\n containerSize,\n containerShape,\n itemShape: \"rect\",\n rotation: \"none\",\n order: \"free\",\n groups: \"none\",\n obstacles,\n sizes,\n count: countCell(count),\n mode: \"offline\",\n };\n if (obstacles !== \"none\" || locked) cell.obstacleMove = \"fixed\";\n return cell;\n}\n\n/** This function makes a generator from its data. It adds the defaults, the checks, the stamp, the rounding and the hash. */\nfunction defineGenerator<P extends GeneratorParams>(spec: GeneratorSpec<P>): CorpusGenerator<P> {\n const withDefaults = (params: Partial<P> = {}): P => {\n const full: GeneratorParams = { ...spec.defaults };\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (!(key in spec.defaults)) throw new RangeError(`The generator \"${spec.name}\" has no parameter \"${key}\".`);\n full[key] = value;\n }\n for (const [key, allowed] of Object.entries(spec.values) as [string, readonly (string | number)[] | undefined][]) {\n if (allowed !== undefined && !allowed.includes(full[key]!)) {\n throw new RangeError(`The parameter \"${key}\" of the generator \"${spec.name}\" has no value \"${String(full[key])}\".`);\n }\n }\n const count = full[\"count\"];\n if (count !== undefined && (typeof count !== \"number\" || !Number.isInteger(count) || count < 0 || count > MAX_COUNT)) {\n throw new RangeError(`The parameter \"count\" of the generator \"${spec.name}\" is a whole number from 0 to ${MAX_COUNT}.`);\n }\n return full as P;\n };\n\n return Object.freeze({\n name: spec.name,\n version: spec.version,\n set: spec.set,\n defaults: Object.freeze({ ...spec.defaults }),\n values: spec.values,\n withDefaults,\n cell: (params?: Partial<P>): CorpusCell => spec.cell(withDefaults(params)),\n generate(seed: number, params?: Partial<P>, set: string = spec.set): LayoutInput {\n if (!Number.isInteger(seed) || seed < 0) throw new RangeError(`The seed is a whole number from 0. It is ${seed}.`);\n const full = withDefaults(params);\n const family = spec.family(full);\n const { container, obstacles, boxes } = spec.build(seed, full);\n const file: Omit<LayoutInput, \"hash\"> = roundNumbers({\n schema: \"layout-input/1\" as const,\n id: `${set}/${family}/s${seed}`,\n set,\n family,\n seed,\n source: \"made-up\",\n generator: { name: spec.name, version: spec.version, params: full, seed },\n container,\n obstacles,\n boxes,\n edges: [],\n });\n return { ...file, hash: hashInput(file) };\n },\n });\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The shared generator `rect-scattered` (version 1). `docs/FORMAT.md` gives it step by step. Do not change its output.\n\n/** The parameters of `rect-scattered`. */\nexport type RectScatteredParams = { count: number };\n\n/** The shared generator `rect-scattered` of `docs/FORMAT.md`, version 1: rectangle obstacles at random places in a fixed rectangle. */\nexport const rectScattered: CorpusGenerator<RectScatteredParams> = defineGenerator<RectScatteredParams>({\n name: \"rect-scattered\",\n version: 1,\n set: \"xcheck-v1\",\n defaults: { count: 40 },\n values: {},\n family: () => \"rect-scattered\",\n cell: (p) => cellWith(\"fixed\", \"rect\", \"scattered\", \"uniform\", p.count),\n build(seed, { count }) {\n let r = stepRandom(seed, \"container\");\n const w = int(r, 600, 1000);\n const h = int(r, 400, 800);\n const container: Container = { w, h, fixed: \"size\" };\n\n r = stepRandom(seed, \"obstacles\");\n const n = int(r, 3, 8);\n const obstacles: Obstacle[] = [];\n for (let i = 0; i < n; i++) {\n const ow = int(r, 40, 160);\n const oh = int(r, 40, 160);\n const x = int(r, 0, w - ow);\n const y = int(r, 0, h - oh);\n obstacles.push({ id: `o${i}`, region: { kind: \"rect\", x, y, w: ow, h: oh } });\n }\n\n r = stepRandom(seed, \"boxes\");\n const boxes: Item[] = [];\n for (let i = 0; i < count; i++) {\n const bw = int(r, 20, 120);\n const bh = int(r, 20, 80);\n boxes.push({ id: `b${i}`, w: bw, h: bh });\n }\n return { container, obstacles, boxes };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The steps of `rect-grid` and of the families of a user interface.\n\n/** The values of `containerSize` that the generators make. */\nconst CONTAINER_SIZES = [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"] as const;\n/** The values of `containerShape`. */\nconst CONTAINER_SHAPES = [\"rect\", \"convex\", \"polygon\", \"circle\", \"ellipse\", \"holes\"] as const;\n/** The values of `obstacles`. */\nconst OBSTACLE_LAYOUTS = [\"none\", \"center\", \"scattered\", \"wall\", \"corridors\", \"touching\", \"edge\"] as const;\n/** The values of `sizes`. */\nconst SIZE_DISTRIBUTIONS = [\"identical\", \"nearIdentical\", \"uniform\", \"heavyTail\", \"bimodal\", \"extremeAspect\"] as const;\n\n/** This function gives the container of a size value for the nominal rectangle `w` by `h`, with an optional shape. */\nfunction containerOf(size: DimensionValue<\"containerSize\">, w: number, h: number, shape?: Region): Container {\n const containers: Record<DimensionValue<\"containerSize\">, Container> = {\n fixed: { w, h, fixed: \"size\" },\n freeHeight: { w, fixed: \"width\" },\n freeWidth: { h, fixed: \"height\" },\n freeAspect: { fixed: \"none\", aspect: round3(w / h) },\n freeArea: { fixed: \"none\", aspectWeight: 0 },\n };\n const container = containers[size];\n if (shape !== undefined) container.shape = shape;\n return container;\n}\n\n/** This function gives the 4 corners of a rectangle, clockwise from the top left. */\nconst corners = (x: number, y: number, w: number, h: number): [number, number][] => [\n [x, y],\n [x + w, y],\n [x + w, y + h],\n [x, y + h],\n];\n\n/**\n * This function gives the shape of a container in the rectangle `w` by `h`, and its frame. The frame is a rectangle in\n * the shape. The obstacles and the sizes of the boxes come from the frame.\n */\nfunction shapeOf(r: () => number, shape: DimensionValue<\"containerShape\">, w: number, h: number): { region?: Region; frame: Frame } {\n const m = Math.min(w, h);\n switch (shape) {\n case \"rect\":\n return { frame: { x: 0, y: 0, w, h } };\n case \"convex\": {\n // A rectangle with its 4 corners cut at 45 degrees\n const [a, b, c, d] = [0, 1, 2, 3].map(() => span(r, m * 0.1, m * 0.25)) as [number, number, number, number];\n const points: [number, number][] = [[a, 0], [w - b, 0], [w, b], [w, h - c], [w - c, h], [d, h], [0, h - d], [0, a]];\n const top = Math.max(a, b);\n const bottom = Math.max(c, d);\n return { region: { kind: \"polygon\", points }, frame: { x: 0, y: top, w, h: h - top - bottom } };\n }\n case \"polygon\": {\n // A rectangle with a notch at the bottom right: an L shape\n const nw = span(r, w * 0.25, w * 0.45);\n const nh = span(r, h * 0.25, h * 0.45);\n const points: [number, number][] = [[0, 0], [w, 0], [w, h - nh], [w - nw, h - nh], [w - nw, h], [0, h]];\n return { region: { kind: \"polygon\", points }, frame: { x: 0, y: 0, w: w - nw, h } };\n }\n case \"circle\": {\n const cx = Math.floor(w / 2);\n const cy = Math.floor(h / 2);\n const radius = Math.min(cx, cy);\n const side = 2 * Math.floor((radius * Math.SQRT2 - 1) / 2);\n return { region: { kind: \"circle\", cx, cy, r: radius }, frame: { x: cx - side / 2, y: cy - side / 2, w: side, h: side } };\n }\n case \"ellipse\": {\n const rx = Math.floor(w / 2);\n const ry = Math.floor(h / 2);\n const a = Math.floor(rx / Math.SQRT2);\n const b = Math.floor(ry / Math.SQRT2);\n return { region: { kind: \"ellipse\", cx: rx, cy: ry, rx, ry }, frame: { x: rx - a, y: ry - b, w: 2 * a, h: 2 * b } };\n }\n case \"holes\": {\n // 1 or 2 rectangle holes, the first in the left half and the second in the right half\n const count = int(r, 1, 2);\n const holes: [number, number][][] = [];\n for (let i = 0; i < count; i++) {\n const hw = span(r, w * 0.08, w * 0.15);\n const hh = span(r, h * 0.1, h * 0.25);\n const x = i === 0 ? span(r, 20, w / 2 - hw - 10) : span(r, w / 2 + 10, w - hw - 20);\n const y = span(r, 20, h - hh - 20);\n holes.push(corners(x, y, hw, hh));\n }\n return { region: { kind: \"polygon\", points: corners(0, 0, w, h), holes }, frame: { x: 0, y: 0, w, h } };\n }\n }\n}\n\n/** This function gives the obstacles of a layout in a frame. Each obstacle is a rectangle with whole-number sides. */\nfunction obstaclesOf(r: () => number, layout: ObstacleLayout, f: Frame): Obstacle[] {\n const m = Math.min(f.w, f.h);\n const rects: { x: number; y: number; w: number; h: number }[] = [];\n switch (layout) {\n case \"none\":\n break;\n case \"center\": {\n const w = span(r, f.w * 0.15, f.w * 0.3);\n const h = span(r, f.h * 0.15, f.h * 0.3);\n const jx = Math.floor(f.w * 0.05);\n const jy = Math.floor(f.h * 0.05);\n rects.push({ x: f.x + Math.floor((f.w - w) / 2) + int(r, -jx, jx), y: f.y + Math.floor((f.h - h) / 2) + int(r, -jy, jy), w, h });\n break;\n }\n case \"scattered\": {\n const n = int(r, 3, 8);\n for (let i = 0; i < n; i++) {\n const w = span(r, m * 0.05, m * 0.2);\n const h = span(r, m * 0.05, m * 0.2);\n rects.push({ x: int(r, f.x, f.x + f.w - w), y: int(r, f.y, f.y + f.h - h), w, h });\n }\n break;\n }\n case \"wall\": {\n // One long, thin obstacle from one side. It leaves a gap at its other end.\n const vertical = r() < 0.5;\n const across = vertical ? f.w : f.h;\n const along = vertical ? f.h : f.w;\n const thick = span(r, Math.max(1, across * 0.03), Math.max(1, across * 0.06));\n const length = span(r, along * 0.7, along * 0.85);\n const at = span(r, across * 0.3, across * 0.7 - thick);\n const from = r() < 0.5 ? 0 : along - length;\n rects.push(vertical ? { x: f.x + at, y: f.y + from, w: thick, h: length } : { x: f.x + from, y: f.y + at, w: length, h: thick });\n break;\n }\n case \"corridors\": {\n // A grid of blocks, with a narrow path between two blocks and between a block and the border\n const cols = int(r, 2, 4);\n const rows = int(r, 2, 3);\n const path = span(r, m * 0.08, m * 0.15);\n const bw = Math.floor((f.w - (cols + 1) * path) / cols);\n const bh = Math.floor((f.h - (rows + 1) * path) / rows);\n for (let j = 0; j < rows; j++) {\n for (let i = 0; i < cols; i++) rects.push({ x: f.x + path + i * (bw + path), y: f.y + path + j * (bh + path), w: bw, h: bh });\n }\n break;\n }\n case \"touching\": {\n // A chain: each obstacle shares a part of a side with the obstacle before it\n const n = int(r, 2, 4);\n let w = span(r, m * 0.08, m * 0.15);\n let h = span(r, m * 0.08, m * 0.15);\n let x = span(r, f.x + f.w * 0.15, f.x + f.w * 0.35);\n let y = span(r, f.y + f.h * 0.15, f.y + f.h * 0.35);\n rects.push({ x, y, w, h });\n for (let i = 1; i < n; i++) {\n const right = r() < 0.5;\n const nw = span(r, m * 0.08, m * 0.15);\n const nh = span(r, m * 0.08, m * 0.15);\n if (right) {\n y = int(r, y, y + Math.floor(h / 2));\n x += w;\n } else {\n x = int(r, x, x + Math.floor(w / 2));\n y += h;\n }\n w = nw;\n h = nh;\n rects.push({ x, y, w, h });\n }\n break;\n }\n case \"edge\": {\n // Each obstacle touches one side of the frame\n const n = int(r, 2, 5);\n for (let i = 0; i < n; i++) {\n const side = int(r, 0, 3);\n const w = span(r, m * 0.06, m * 0.15);\n const h = span(r, m * 0.06, m * 0.15);\n const x = side === 1 ? f.x + f.w - w : side === 3 ? f.x : int(r, f.x, f.x + f.w - w);\n const y = side === 0 ? f.y : side === 2 ? f.y + f.h - h : int(r, f.y, f.y + f.h - h);\n rects.push({ x, y, w, h });\n }\n break;\n }\n }\n return rects.map((rect, i) => ({ id: `o${i}`, region: { kind: \"rect\", ...rect } }));\n}\n\n/**\n * This function gives the boxes of a size distribution for a frame. The mean box has an area of 40 percent of the\n * frame divided by the count. No box is wider or higher than the frame.\n */\nfunction boxesOf(r: () => number, sizes: SizeDistribution, count: number, f: Frame): Item[] {\n const unit = Math.sqrt((f.w * f.h * 0.4) / Math.max(count, 1));\n const fit = (x: number, max: number): number => Math.min(Math.max(round3(x), 0.01), max);\n const boxes: Item[] = new Array<Item>(count);\n const put = (i: number, w: number, h: number): void => {\n boxes[i] = { id: `b${i}`, w: fit(w, f.w), h: fit(h, f.h) };\n };\n switch (sizes) {\n case \"identical\":\n case \"nearIdentical\": {\n const aspect = Math.sqrt(between(r, 0.6, 1.6));\n const bw = unit * aspect;\n const bh = unit / aspect;\n for (let i = 0; i < count; i++) {\n if (sizes === \"identical\") put(i, bw, bh);\n else put(i, bw * (1 + between(r, -0.03, 0.03)), bh * (1 + between(r, -0.03, 0.03)));\n }\n break;\n }\n case \"uniform\":\n for (let i = 0; i < count; i++) put(i, unit * between(r, 0.5, 1.5), unit * between(r, 0.5, 1.5));\n break;\n case \"heavyTail\": {\n // A Pareto distribution with the index 1.6, cut at 60 percent of the frame\n const cap = 0.6 * Math.min(f.w, f.h);\n for (let i = 0; i < count; i++) {\n const s = Math.min(0.6 * unit * (1 - r()) ** (-1 / 1.6), cap);\n put(i, s * between(r, 0.75, 1.33), s * between(r, 0.75, 1.33));\n }\n break;\n }\n case \"bimodal\":\n for (let i = 0; i < count; i++) {\n const s = r() < 0.25 ? 1.8 * unit : 0.6 * unit;\n put(i, s * between(r, 0.85, 1.15), s * between(r, 0.85, 1.15));\n }\n break;\n case \"extremeAspect\":\n for (let i = 0; i < count; i++) {\n const long = unit * between(r, 2.5, 4);\n const short = unit * between(r, 0.15, 0.35);\n if (r() < 0.5) put(i, long, short);\n else put(i, short, long);\n }\n break;\n }\n return boxes;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n// `rect-grid`: one input for each point of the grid of the packer dimensions.\n\n/** The parameters of `rect-grid`: one value for each dimension of the taxonomy that it covers. */\nexport type RectGridParams = {\n containerSize: DimensionValue<\"containerSize\">;\n containerShape: DimensionValue<\"containerShape\">;\n obstacles: ObstacleLayout;\n sizes: SizeDistribution;\n count: number;\n};\n\n/**\n * The generator `rect-grid`, version 1: rectangle boxes for each value of `containerSize`, `containerShape`, `obstacles`\n * and `sizes`, with each count. The container is a nominal rectangle of 600 to 1000 by 400 to 800.\n */\nexport const rectGrid: CorpusGenerator<RectGridParams> = defineGenerator<RectGridParams>({\n name: \"rect-grid\",\n version: 1,\n set: \"corpus-v1\",\n defaults: { containerSize: \"fixed\", containerShape: \"rect\", obstacles: \"none\", sizes: \"uniform\", count: 100 },\n values: { containerSize: CONTAINER_SIZES, containerShape: CONTAINER_SHAPES, obstacles: OBSTACLE_LAYOUTS, sizes: SIZE_DISTRIBUTIONS },\n family: (p) => `rect-grid.${p.containerSize}.${p.containerShape}.${p.obstacles}.${p.sizes}.n${p.count}`,\n cell: (p) => cellWith(p.containerSize, p.containerShape, p.obstacles, p.sizes, p.count),\n build(seed, p) {\n let r = stepRandom(seed, \"container\");\n const w = int(r, 600, 1000);\n const h = int(r, 400, 800);\n const { region, frame } = shapeOf(r, p.containerShape, w, h);\n const container = containerOf(p.containerSize, w, h, region);\n\n r = stepRandom(seed, \"obstacles\");\n const obstacles = obstaclesOf(r, p.obstacles, frame);\n\n r = stepRandom(seed, \"boxes\");\n return { container, obstacles, boxes: boxesOf(r, p.sizes, p.count, frame) };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The families of a user interface: gallery, dashboard, cards and word cloud.\n\n/** The parameters of a family of a user interface. */\nexport type UiParams = {\n containerSize: DimensionValue<\"containerSize\">;\n count: number;\n};\n\n/** This function makes the generator of a family of a user interface. The container is 800 to 1400 by 600 to 1000, with no obstacle. */\nfunction uiGenerator(name: string, sizes: SizeDistribution, count: number, boxes: (r: () => number, count: number) => Item[]): CorpusGenerator<UiParams> {\n return defineGenerator<UiParams>({\n name,\n version: 1,\n set: \"corpus-v1\",\n defaults: { containerSize: \"freeHeight\", count },\n values: { containerSize: CONTAINER_SIZES },\n family: (p) => `${name}.${p.containerSize}.n${p.count}`,\n cell: (p) => cellWith(p.containerSize, \"rect\", \"none\", sizes, p.count),\n build(seed, p) {\n const r = stepRandom(seed, \"container\");\n const w = int(r, 800, 1400);\n const h = int(r, 600, 1000);\n return { container: containerOf(p.containerSize, w, h), obstacles: [], boxes: boxes(stepRandom(seed, \"boxes\"), p.count) };\n },\n });\n}\n\n/** The aspects of the thumbnails of a gallery. */\nconst THUMBNAIL_ASPECTS = [1, 4 / 3, 3 / 2, 16 / 9];\n\n/** The generator `gallery`, version 1: thumbnails with one size and one aspect (1, 4:3, 3:2 or 16:9). The default container has a fixed width. */\nexport const gallery: CorpusGenerator<UiParams> = uiGenerator(\"gallery\", \"identical\", 100, (r, count) => {\n const aspect = THUMBNAIL_ASPECTS[int(r, 0, THUMBNAIL_ASPECTS.length - 1)]!;\n const w = int(r, 120, 240);\n return Array.from({ length: count }, (_, i) => ({ id: `b${i}`, w, h: round3(w / aspect) }));\n});\n\n/** The spans of the dashboard tiles in grid units, and their weights. */\nconst TILE_SPANS: readonly [number, number][] = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 2], [4, 2]];\nconst TILE_WEIGHTS = [4, 3, 2, 3, 1, 1];\n\n/** The generator `dashboard`, version 1: tiles in 6 standard sizes, from 1 by 1 to 4 by 2 grid units of 60 to 100. */\nexport const dashboard: CorpusGenerator<UiParams> = uiGenerator(\"dashboard\", \"bimodal\", 10, (r, count) => {\n const unit = int(r, 60, 100);\n return Array.from({ length: count }, (_, i) => {\n const [cw, ch] = TILE_SPANS[pick(r, TILE_WEIGHTS)]!;\n return { id: `b${i}`, w: cw * unit, h: ch * unit };\n });\n});\n\n/** The generator `cards`, version 1: cards with one width from 200 to 320, and a height from 120 to 420 each. */\nexport const cards: CorpusGenerator<UiParams> = uiGenerator(\"cards\", \"uniform\", 100, (r, count) => {\n const w = int(r, 200, 320);\n return Array.from({ length: count }, (_, i) => ({ id: `b${i}`, w, h: int(r, 120, 420) }));\n});\n\n/** The font sizes of a word cloud, and their weights: many small words and few large words. */\nconst FONT_SIZES = [12, 14, 16, 20, 28, 40];\nconst FONT_WEIGHTS = [30, 25, 20, 12, 8, 5];\n\n/** The generator `word-cloud`, version 1: boxes of text. The height comes from 6 font sizes, the width from 3 to 12 letters. */\nexport const wordCloud: CorpusGenerator<UiParams> = uiGenerator(\"word-cloud\", \"heavyTail\", 100, (r, count) =>\n Array.from({ length: count }, (_, i) => {\n const font = FONT_SIZES[pick(r, FONT_WEIGHTS)]!;\n const letters = int(r, 3, 12);\n return { id: `b${i}`, w: round3(letters * font * 0.6), h: round3(font * 1.25) };\n }),\n);\n\n// ---------------------------------------------------------------------------------------------------------------------\n// `edge-cases`: the inputs at the limits.\n\n/** The cases of `edge-cases`. */\nexport type EdgeCase = \"empty\" | \"one\" | \"oversize\" | \"exactTiling\" | \"touchObstacles\";\n\n/** The parameters of `edge-cases`. The cases `empty` and `one` ignore `count`. */\nexport type EdgeCaseParams = { case: EdgeCase; count: number };\n\n/** The values of `case`. */\nconst EDGE_CASES = [\"empty\", \"one\", \"oversize\", \"exactTiling\", \"touchObstacles\"] as const;\n\n/** This function gives the largest divisor of `n` that is not more than the square root of `n`. */\nconst rowsOf = (n: number): number => {\n for (let d = Math.floor(Math.sqrt(n)); d > 1; d--) if (n % d === 0) return d;\n return 1;\n};\n\n/**\n * The generator `edge-cases`, version 1. Each case has a fixed rectangle container.\n *\n * - `empty`: no box.\n * - `one`: one box.\n * - `oversize`: `count` boxes. One box is wider than the container.\n * - `exactTiling`: `count` identical boxes that fill the container with no free space.\n * - `touchObstacles`: a locked box on the top of an obstacle, and boxes as wide as the path between 2 obstacles.\n */\nexport const edgeCases: CorpusGenerator<EdgeCaseParams> = defineGenerator<EdgeCaseParams>({\n name: \"edge-cases\",\n version: 1,\n set: \"corpus-v1\",\n defaults: { case: \"oversize\", count: 12 },\n values: { case: EDGE_CASES },\n family: (p) => (p.case === \"empty\" || p.case === \"one\" ? `edge-cases.${p.case}` : `edge-cases.${p.case}.n${p.count}`),\n cell: (p) => {\n switch (p.case) {\n case \"empty\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", 0);\n case \"one\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", 1);\n case \"oversize\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"heavyTail\", p.count);\n case \"exactTiling\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", p.count);\n case \"touchObstacles\":\n return cellWith(\"fixed\", \"rect\", \"corridors\", \"uniform\", p.count, true);\n }\n },\n build(seed, p) {\n const needsBoxes = p.case === \"oversize\" || p.case === \"exactTiling\" || p.case === \"touchObstacles\";\n if (needsBoxes && p.count < 1) throw new RangeError(`The case \"${p.case}\" of \"edge-cases\" needs a count of 1 or more.`);\n\n let r = stepRandom(seed, \"container\");\n let w: number;\n let h: number;\n let tile = { w: 0, h: 0, cols: 0, rows: 0 };\n if (p.case === \"exactTiling\") {\n // The container step also picks the size of the tile, because the tiles give the size of the container\n const rows = rowsOf(p.count);\n tile = { w: int(r, 40, 120), h: int(r, 30, 90), cols: p.count / rows, rows };\n w = tile.cols * tile.w;\n h = tile.rows * tile.h;\n } else {\n w = int(r, 600, 1000);\n h = int(r, 400, 800);\n }\n const container: Container = { w, h, fixed: \"size\" };\n\n r = stepRandom(seed, \"obstacles\");\n const obstacles: Obstacle[] = [];\n let path = 0;\n let first = { x: 0, y: 0 };\n if (p.case === \"touchObstacles\") {\n path = int(r, 40, 100);\n const ow = int(r, 60, 150);\n const oh = int(r, 100, 200);\n first = { x: span(r, w * 0.1, w * 0.25), y: span(r, h * 0.2, h * 0.4) };\n obstacles.push({ id: \"o0\", region: { kind: \"rect\", x: first.x, y: first.y, w: ow, h: oh } });\n obstacles.push({ id: \"o1\", region: { kind: \"rect\", x: first.x + ow + path, y: first.y, w: int(r, 60, 150), h: oh } });\n }\n\n r = stepRandom(seed, \"boxes\");\n const boxes: Item[] = [];\n switch (p.case) {\n case \"empty\":\n break;\n case \"one\":\n boxes.push({ id: \"b0\", w: int(r, 40, 200), h: int(r, 30, 150) });\n break;\n case \"oversize\": {\n const big = int(r, 0, p.count - 1);\n for (let i = 0; i < p.count; i++) {\n if (i === big) boxes.push({ id: `b${i}`, w: w + int(r, 10, 200), h: int(r, 40, 100) });\n else boxes.push({ id: `b${i}`, w: int(r, 20, 120), h: int(r, 20, 80) });\n }\n break;\n }\n case \"exactTiling\":\n for (let i = 0; i < p.count; i++) boxes.push({ id: `b${i}`, w: tile.w, h: tile.h });\n break;\n case \"touchObstacles\": {\n const lw = int(r, 30, 80);\n const lh = int(r, 20, 60);\n boxes.push({ id: \"b0\", w: lw, h: lh, x: first.x, y: first.y - lh, locked: true });\n for (let i = 1; i < p.count; i++) boxes.push({ id: `b${i}`, w: path, h: int(r, 20, 80) });\n break;\n }\n }\n return { container, obstacles, boxes };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/** Each generator of the package. */\nexport const generators: readonly CorpusGenerator[] = Object.freeze([rectScattered, rectGrid, gallery, dashboard, cards, wordCloud, edgeCases] as CorpusGenerator[]);\n\n/** This function gives the generator with a name. It throws a `RangeError` for a name that the package does not have. */\nexport function generator(name: string): CorpusGenerator {\n const found = generators.find((g) => g.name === name);\n if (found === undefined) throw new RangeError(`The package has no generator \"${name}\".`);\n return found;\n}\n","// The manifest of a corpus: `layout-corpus/1` of `docs/FORMAT.md`.\n\nimport { generator } from \"./generators.ts\";\nimport type { CorpusCell, GeneratorParams, LayoutInput } from \"./layout-input.ts\";\n\n/** One spec of a corpus: a generator, its parameters and its seeds. */\nexport interface CorpusSpec {\n /** The name of the generator. */\n generator: string;\n /** The version of the generator. Without it, the spec uses the version of the package. A different version is an error. */\n version?: number;\n /** The parameters over the defaults of the generator. */\n params?: GeneratorParams;\n seeds: readonly number[];\n}\n\n/** One input in the index of a manifest. */\nexport interface CorpusEntry {\n id: string;\n hash: string;\n cell: CorpusCell;\n}\n\n/** The manifest `corpus.json` of a corpus. */\nexport interface CorpusManifest {\n schema: \"layout-corpus/1\";\n /** The name of the corpus. Each input has it in `set`. */\n corpus: string;\n /** The specs, each with its version and its full parameters. */\n specs: { generator: string; version: number; params: GeneratorParams; seeds: number[] }[];\n inputs: CorpusEntry[];\n}\n\n/** A corpus: the manifest and the input files, in the order of the specs and the seeds. */\nexport interface Corpus {\n manifest: CorpusManifest;\n inputs: LayoutInput[];\n}\n\n/**\n * This function generates a corpus from specs. Each input gets the name of the corpus as its set. The function throws a\n * `RangeError` for an unknown generator, a different version or 2 inputs with the same id.\n */\nexport function corpus(name: string, specs: readonly CorpusSpec[]): Corpus {\n const manifest: CorpusManifest = { schema: \"layout-corpus/1\", corpus: name, specs: [], inputs: [] };\n const inputs: LayoutInput[] = [];\n const ids = new Set<string>();\n for (const spec of specs) {\n const gen = generator(spec.generator);\n if (spec.version !== undefined && spec.version !== gen.version) {\n throw new RangeError(`The generator \"${gen.name}\" has the version ${gen.version}, not ${spec.version}.`);\n }\n const params = gen.withDefaults(spec.params);\n const cell = gen.cell(params);\n manifest.specs.push({ generator: gen.name, version: gen.version, params, seeds: [...spec.seeds] });\n for (const seed of spec.seeds) {\n const file = gen.generate(seed, params, name);\n if (ids.has(file.id)) throw new RangeError(`The corpus has 2 inputs with the id \"${file.id}\".`);\n ids.add(file.id);\n inputs.push(file);\n manifest.inputs.push({ id: file.id, hash: file.hash, cell });\n }\n }\n return { manifest, inputs };\n}\n"],"mappings":";;AACA,IAAa,SAAb,MAAa,OAAO;CAClB;CACA;CAEA,YAAY,IAAI,GAAG,IAAI,GAAG;EACxB,KAAK,KAAK;EACV,KAAK,KAAK;CACZ;;CAGA,IAAI,IAAY;EAAE,OAAO,KAAK;CAAI;CAClC,IAAI,EAAE,GAAW;EAAE,KAAK,KAAK;CAAG;;CAEhC,IAAI,IAAY;EAAE,OAAO,KAAK;CAAI;CAClC,IAAI,EAAE,GAAW;EAAE,KAAK,KAAK;CAAG;;CAGhC,IAAI,GAAW,GAAiB;EAC9B,KAAK,KAAK;EACV,KAAK,KAAK;CACZ;;CAGA,MAAM,GAAiB;EACrB,KAAK,KAAK,EAAE;EACZ,KAAK,KAAK,EAAE;CACd;;CAGA,IAAI,OAAuB;EACzB,OAAO,IAAI,OAAO,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,CAAC;CACxD;;CAGA,OAAe;EACb,OAAO,KAAK,KAAK,KAAK;CACxB;;CAGA,QAAgB;EACd,OAAO,IAAI,OAAO,KAAK,IAAI,KAAK,EAAE;CACpC;;CAGA,MAAM,KAAa,KAAqB;EACtC,OAAO,IAAI,OACT,KAAK,IA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,OAAO,CAAC;EAAG,QAAQ,CAAC;CAAE;CAClG,MAAM,SAAwB,CAAC;CAC/B,MAAM,sBAAM,IAAI,IAAY;CAC5B,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,UAAU,KAAK,SAAS;EACpC,IAAI,KAAK,YAAY,KAAA,KAAa,KAAK,YAAY,IAAI,SACrD,MAAM,IAAI,WAAW,kBAAkB,IAAI,KAAK,oBAAoB,IAAI,QAAQ,QAAQ,KAAK,QAAQ,EAAE;EAEzG,MAAM,SAAS,IAAI,aAAa,KAAK,MAAM;EAC3C,MAAM,OAAO,IAAI,KAAK,MAAM;EAC5B,SAAS,MAAM,KAAK;GAAE,WAAW,IAAI;GAAM,SAAS,IAAI;GAAS;GAAQ,OAAO,CAAC,GAAG,KAAK,KAAK;EAAE,CAAC;EACjG,KAAK,MAAM,QAAQ,KAAK,OAAO;GAC7B,MAAM,OAAO,IAAI,SAAS,MAAM,QAAQ,IAAI;GAC5C,IAAI,IAAI,IAAI,KAAK,EAAE,GAAG,MAAM,IAAI,WAAW,wCAAwC,KAAK,GAAG,GAAG;GAC9F,IAAI,IAAI,KAAK,EAAE;GACf,OAAO,KAAK,IAAI;GAChB,SAAS,OAAO,KAAK;IAAE,IAAI,KAAK;IAAI,MAAM,KAAK;IAAM;GAAK,CAAC;EAC7D;CACF;CACA,OAAO;EAAE;EAAU;CAAO;AAC5B"}
1
+ {"version":3,"file":"index.js","names":["rowsOf","boxesOf","rowsOf","shapeOf"],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/shelf.ts","../src/skyline.ts","../src/pack.ts","../src/free.ts","../src/push.ts","../src/contract.ts","../src/sha256.ts","../src/layout-input.ts","../src/measures.ts","../src/metrics.ts","../src/strategy.ts","../src/frame.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/check.ts","../src/generators.ts","../src/corpus.ts"],"sourcesContent":["/** A mutable two-dimensional vector. */\nexport class Vector {\n #x: number;\n #y: number;\n\n constructor(x = 0, y = 0) {\n this.#x = x;\n this.#y = y;\n }\n\n /** The first component: a width or a left position. */\n get x(): number { return this.#x; }\n set x(v: number) { this.#x = v; }\n /** The second component: a height or a top position. */\n get y(): number { return this.#y; }\n set y(v: number) { this.#y = v; }\n\n /** This method sets both components. */\n set(x: number, y: number): void {\n this.#x = x;\n this.#y = y;\n }\n\n /** This method copies the components of another vector. */\n setTo(v: Vector): void {\n this.#x = v.x;\n this.#y = v.y;\n }\n\n /** This method gives a new vector: the sum of this vector and another. */\n add(other: Vector): Vector {\n return new Vector(this.#x + other.x, this.#y + other.y);\n }\n\n /** This method gives the product of the components: the area of a size. */\n area(): number {\n return this.#x * this.#y;\n }\n\n /** This method gives a new vector with the same components. */\n clone(): Vector {\n return new Vector(this.#x, this.#y);\n }\n\n /** This method gives a new vector with each component between the components of `min` and `max`. */\n clamp(min: Vector, max: Vector): Vector {\n return new Vector(\n Math.max(min.x, Math.min(max.x, this.#x)),\n Math.max(min.y, Math.min(max.y, this.#y)),\n );\n }\n\n /** This function gives a vector with the same value in both components. */\n static of(scalar: number): Vector {\n return new Vector(scalar, scalar);\n }\n\n /** This function gives the smallest value of each component, or a zero vector for an empty list. */\n static min(vectors: Vector[]): Vector {\n if (!vectors.length) return new Vector();\n return new Vector(\n Math.min(...vectors.map((v) => v.x)),\n Math.min(...vectors.map((v) => v.y)),\n );\n }\n\n /** This function gives the largest value of each component, or a zero vector for an empty list. */\n static max(vectors: Vector[]): Vector {\n if (!vectors.length) return new Vector();\n return new Vector(\n Math.max(...vectors.map((v) => v.x)),\n Math.max(...vectors.map((v) => v.y)),\n );\n }\n\n /** This getter gives a new infinite vector each time. A shared value is not safe, because a vector is mutable. */\n static get Infinity(): Vector {\n return new Vector(Infinity, Infinity);\n }\n}\n","import { Vector } from \"./vector.ts\";\n\n/** A rectangle of the packer. `id` identifies the item that it measures. The packer sets `position` and `wasPacked`. */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- the parameter types the id of the caller\nexport class Rect<T = unknown> {\n readonly #position = new Vector();\n readonly #size = new Vector();\n\n /** The identity of the item that the rectangle measures. */\n id?: T;\n /** The packer sets this field to `true` when it places the rectangle. */\n wasPacked = false;\n /** For an outer rectangle: the packer keeps its width. */\n fixedWidth = false;\n /** For an outer rectangle: the packer keeps its width and its height, and it skips a rectangle that does not fit. */\n fixedSize = false;\n /**\n * The packer keeps the position of a locked rectangle. `packSkyline` packs the other rectangles around it.\n * `packRows` only keeps its position, and other rectangles can overlap it.\n */\n locked = false;\n\n /** The top left corner. */\n get position(): Vector { return this.#position; }\n /** The width and the height. */\n get size(): Vector { return this.#size; }\n\n /** This method gives the right edge. */\n right(): number { return this.#position.x + this.#size.x; }\n /** This method gives the bottom edge. */\n bottom(): number { return this.#position.y + this.#size.y; }\n\n /** This method moves the left edge to the right by an amount, and the right edge stays. */\n shrinkLeft(amount: number): this {\n this.#position.x += amount;\n this.#size.x -= amount;\n return this;\n }\n\n /** This method moves the rectangle by an offset. */\n translateBy(offset: Vector): this {\n this.#position.set(this.#position.x + offset.x, this.#position.y + offset.y);\n return this;\n }\n\n /** This method gives the area of the size. */\n area(): number { return this.#size.area(); }\n\n /** This function gives the rectangles that the packer placed. */\n static packed<U>(rects: Rect<U>[]): Rect<U>[] {\n return rects.filter((r) => r.wasPacked);\n }\n\n /** This function gives the rectangles that the packer did not place. */\n static unpacked<U>(rects: Rect<U>[]): Rect<U>[] {\n return rects.filter((r) => !r.wasPacked);\n }\n\n /** This function marks each rectangle as not placed. A locked rectangle stays placed. */\n static resetPacked<U>(rects: Rect<U>[]): void {\n for (const r of rects) r.wasPacked = r.locked;\n }\n\n /** This function gives the largest right edge, or 0 for an empty list. */\n static maxRight<U>(rects: Rect<U>[]): number {\n return rects.reduce((acc, r) => Math.max(acc, r.right()), 0);\n }\n\n /** This function gives the largest bottom edge, or 0 for an empty list. */\n static maxBottom<U>(rects: Rect<U>[]): number {\n return rects.reduce((acc, r) => Math.max(acc, r.bottom()), 0);\n }\n}\n","import type { Rect } from \"./rect.ts\";\n\n/**\n * An order of the rectangles before the packing. The order changes the layout much. `input` keeps the order of\n * the array of the caller: the row packing then fills no gaps, so its rows read in that order.\n */\nexport type SortOrder = \"height-desc\" | \"height-asc\" | \"width-desc\" | \"area-desc\" | \"input\";\n\n/** This constant lists each sort order. The first one is the default. */\nexport const SORT_ORDERS: readonly SortOrder[] = [\"height-desc\", \"height-asc\", \"width-desc\", \"area-desc\", \"input\"];\n\n/** This function gives the comparator of a sort order. The sort is stable, so `input` keeps the order. */\nexport function compareRects(order: SortOrder): <T>(a: Rect<T>, b: Rect<T>) => number {\n switch (order) {\n case \"height-desc\":\n return (a, b) => b.size.y - a.size.y;\n case \"height-asc\":\n return (a, b) => a.size.y - b.size.y;\n case \"width-desc\":\n return (a, b) => b.size.x - a.size.x;\n case \"area-desc\":\n return (a, b) => b.area() - a.area();\n case \"input\":\n return () => 0;\n }\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/** The options of `packShelf` */\nexport interface ShelfOptions {\n /** The order of the rectangles before the packing. The default is `height-desc`. */\n sortOrder?: SortOrder;\n}\n\n/** An obstacle in the coordinates of the outer rectangle */\ninterface Box {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\n/**\n * This function gives the first x from `start` where a rectangle of width `w` crosses no obstacle in the band from\n * `top` to `bottom`.\n */\nfunction firstFreeX(obstacles: readonly Box[], start: number, w: number, top: number, bottom: number): number {\n let x = start;\n let moved = true;\n while (moved) {\n moved = false;\n for (const o of obstacles) {\n if (o.top < bottom && top < o.bottom && o.left < x + w && x < o.right) {\n x = o.right;\n moved = true;\n }\n }\n }\n return x;\n}\n\n/** This function gives the lowest bottom edge of the obstacles in the band from `top` to `bottom`, under `top`. */\nfunction nextTop(obstacles: readonly Box[], top: number, bottom: number): number {\n let next = Infinity;\n for (const o of obstacles) if (o.top < bottom && top < o.bottom && o.bottom > top) next = Math.min(next, o.bottom);\n return next;\n}\n\n/**\n * This function packs rectangles into shelves: rows that it fills left to right in the sort order, and does not fill\n * again. It goes around each `locked` rectangle. It sets the position of each rectangle and gives the outer rectangle.\n *\n * - With the sort order `input`, the rows read in the order of the array: left to right, and top to bottom.\n * - With `height-desc` (the default), it is the classic Next-Fit Decreasing Height packing.\n * - A rectangle goes to the first x in the row where it crosses no locked rectangle. If no such x is in the width,\n * a new row starts under the current row.\n * - A rectangle wider than the outer rectangle goes on its own row, at the left edge, and overflows.\n * - It does not change the width. Without `fixedSize`, the height grows to the content. With `fixedSize`, a\n * rectangle that does not fit is not packed: its `wasPacked` stays `false`.\n */\nexport function packShelf<T>(rects: Rect<T>[], outer: Rect<T>, options: ShelfOptions = {}): Rect<T> {\n const width = outer.size.x;\n const obstacles: Box[] = [];\n let contentBottom = 0;\n for (const rect of rects) {\n if (!rect.locked) continue;\n rect.wasPacked = true;\n const left = rect.position.x - outer.position.x;\n const top = rect.position.y - outer.position.y;\n obstacles.push({ left, top, right: left + rect.size.x, bottom: top + rect.size.y });\n contentBottom = Math.max(contentBottom, top + rect.size.y);\n }\n\n let rowTop = 0;\n let rowBottom = 0;\n let cursor = 0;\n let rowEmpty = true;\n\n for (const rect of rects.toSorted(compareRects(options.sortOrder ?? \"height-desc\"))) {\n if (rect.wasPacked) continue;\n const w = rect.size.x;\n const h = rect.size.y;\n if (!(w > 0 && h > 0)) continue;\n const overflows = w > width;\n if (overflows && outer.fixedSize) continue;\n\n // An overflowing rectangle starts a row of its own\n if (overflows && !rowEmpty) {\n rowTop = rowBottom;\n cursor = 0;\n rowEmpty = true;\n }\n\n let x = firstFreeX(obstacles, cursor, w, rowTop, rowTop + h);\n while (!overflows && x + w > width) {\n // Start a new row under the current one, or under the obstacles that block an empty row\n rowTop = rowEmpty ? nextTop(obstacles, rowTop, rowTop + h) : rowBottom;\n rowBottom = rowTop;\n cursor = 0;\n rowEmpty = true;\n x = firstFreeX(obstacles, cursor, w, rowTop, rowTop + h);\n }\n while (overflows && x !== 0) {\n rowTop = nextTop(obstacles, rowTop, rowTop + h);\n rowBottom = rowTop;\n x = firstFreeX(obstacles, 0, w, rowTop, rowTop + h);\n }\n\n if (outer.fixedSize && rowTop + h > outer.size.y) continue;\n\n rect.position.set(x + outer.position.x, rowTop + outer.position.y);\n rect.wasPacked = true;\n rowEmpty = false;\n cursor = x + w;\n rowBottom = Math.max(rowBottom, rowTop + h);\n contentBottom = Math.max(contentBottom, rowTop + h);\n if (overflows) {\n rowTop = rowBottom;\n cursor = 0;\n rowEmpty = true;\n }\n }\n\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, contentBottom);\n return outer;\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/**\n * This function finds the lowest window of width `rw` on a skyline. For each `x` in `[0, width - rw]`, the height\n * of the window is the largest value of `skyline[x, x + rw)`. The first `x` with the smallest height wins. A\n * monotonic deque makes the search O(width) for one rectangle.\n */\nexport function lowestWindow(skyline: ArrayLike<number>, width: number, rw: number): { x: number; y: number } {\n const deque = new Int32Array(width);\n let head = 0;\n let tail = 0;\n let bestX = 0;\n let bestY = Infinity;\n for (let i = 0; i < width; i++) {\n while (tail > head && skyline[deque[tail - 1]!]! <= skyline[i]!) tail--;\n deque[tail++] = i;\n if (deque[head]! <= i - rw) head++;\n if (i >= rw - 1) {\n const max = skyline[deque[head]!]!;\n if (max < bestY) {\n bestY = max;\n bestX = i - rw + 1;\n }\n }\n }\n return { x: bestX, y: bestY };\n}\n\n/**\n * This function packs rectangles into an outer rectangle with a skyline. It puts each rectangle in the lowest place\n * where it fits, and it does not change the width of the outer rectangle.\n *\n * - A `locked` rectangle keeps its position. The skyline starts at its bottom edge across its width, thus the other\n * rectangles go under it. The space above it stays empty, because a skyline has no holes.\n * - The skyline has a cell for each whole unit of the width. A rectangle that needs more cells than the outer\n * rectangle has goes under all other rectangles, at the left edge.\n * - Without `fixedSize`, the height of the outer rectangle grows to the content. With `fixedSize`, a rectangle that\n * does not fit is not packed: its `wasPacked` stays `false`.\n * - The default sort order is `height-desc`. The order of the array of the caller stays.\n */\nexport function packSkyline<T>(rects: Rect<T>[], outer: Rect<T>, options: { sortOrder?: SortOrder } = {}): Rect<T> {\n // a cell for each whole unit of the width: a rectangle never goes past the right edge\n const width = Math.floor(outer.size.x);\n if (width <= 0) return outer;\n const skyline = new Float64Array(width);\n\n for (const rect of rects) {\n if (!rect.locked) continue;\n rect.wasPacked = true;\n const x0 = Math.max(0, Math.floor(rect.position.x - outer.position.x));\n const x1 = Math.min(width, Math.ceil(rect.position.x - outer.position.x + rect.size.x));\n const bottom = rect.position.y - outer.position.y + rect.size.y;\n for (let i = x0; i < x1; i++) skyline[i] = Math.max(skyline[i]!, bottom);\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, bottom);\n }\n\n for (const rect of rects.toSorted(compareRects(options.sortOrder ?? \"height-desc\"))) {\n if (rect.wasPacked) continue;\n const rw = Math.ceil(rect.size.x);\n const rh = rect.size.y;\n if (rw <= 0 || rh <= 0) continue;\n\n let x: number;\n let y: number;\n if (rw > width) {\n if (outer.fixedSize) continue;\n x = 0;\n y = 0;\n for (let i = 0; i < width; i++) if (skyline[i]! > y) y = skyline[i]!;\n } else {\n ({ x, y } = lowestWindow(skyline, width, rw));\n if (outer.fixedSize && y + rh > outer.size.y) continue;\n }\n\n rect.position.set(x + outer.position.x, y + outer.position.y);\n rect.wasPacked = true;\n const top = y + rh;\n for (let i = x; i < Math.min(width, x + rw); i++) skyline[i] = top;\n if (!outer.fixedSize) outer.size.y = Math.max(outer.size.y, top);\n }\n return outer;\n}\n","import { compareRects, type SortOrder } from \"./order.ts\";\nimport { Rect } from \"./rect.ts\";\nimport { packShelf } from \"./shelf.ts\";\nimport { packSkyline } from \"./skyline.ts\";\nimport { Vector } from \"./vector.ts\";\n\n/** The options of `pack` and `packRows` */\nexport interface PackOptions {\n /** The order of the rectangles before the packing. The default is `height-desc`. */\n sortOrder?: SortOrder;\n}\n\n/** The options of `pack` */\nexport interface PackLayoutOptions extends PackOptions {\n /**\n * The packing: `rows` (the default), `skyline` or `shelf`. `skyline` and `shelf` pack around locked rectangles.\n * Use `shelf` with the sort order `input` to keep the order of the array around locked rectangles.\n */\n strategy?: \"rows\" | \"skyline\" | \"shelf\";\n}\n\nfunction packInto<T>(rects: Rect<T>[], region: Rect<T>, offset: Vector, order: SortOrder): void {\n const unpacked = Rect.unpacked(rects);\n pack(unpacked, region, { sortOrder: order });\n for (const r of Rect.packed(unpacked)) r.translateBy(offset);\n}\n\nfunction packRow<T>(rects: Rect<T>[], outer: Rect<T>, order: SortOrder): boolean {\n const row: Rect<T>[] = [];\n // toSorted gives a sorted copy, thus the order of the array of the caller stays\n const byHeight = rects.toSorted(compareRects(order));\n // A gap fill puts a later rect before an earlier one, thus the order `input` fills no gaps\n const fillGaps = order !== \"input\";\n\n const rowRect = new Rect<T>();\n rowRect.size.set(outer.size.x, 0);\n\n for (const rect of byHeight) {\n if (rect.wasPacked) continue;\n\n if (rect.size.x > rowRect.size.x) {\n if (outer.fixedSize && rect.size.x > outer.size.x) continue;\n\n const outerLeft = new Rect<T>();\n outerLeft.position.setTo(rowRect.position);\n outerLeft.size.set(outer.size.x - rowRect.position.x, rowRect.size.y);\n outerLeft.fixedSize = true;\n if (fillGaps) packInto(rects, outerLeft, outer.position, order);\n\n rowRect.position.set(0, rowRect.bottom());\n rowRect.size.set(outer.size.x, 0);\n row.length = 0;\n }\n\n if (rowRect.position.y + rect.size.y > outer.size.y) {\n if (outer.fixedSize) continue;\n outer.size.y += rect.size.y;\n if (!outer.fixedWidth && !outer.size.x) outer.size.x = rect.size.x;\n Rect.resetPacked(rects);\n return false;\n }\n\n row.push(rect);\n rect.position.setTo(rowRect.position.add(outer.position));\n rowRect.shrinkLeft(rect.size.x);\n rect.wasPacked = true;\n\n if (rect.size.y > rowRect.size.y) rowRect.size.y = rect.size.y;\n\n if (fillGaps && row.length > 1) {\n const rectInRow = row[row.length - 1]!;\n const outerLeft = new Rect<T>();\n // The position of the region is relative to the outer rectangle, as packInto adds the position of the outer rectangle\n outerLeft.position.set(rectInRow.position.x - outer.position.x, rectInRow.bottom() - outer.position.y);\n outerLeft.size.set(rectInRow.size.x, rowRect.size.y - rectInRow.size.y);\n outerLeft.fixedWidth = true;\n outerLeft.fixedSize = true;\n packInto(rects, outerLeft, outer.position, order);\n }\n }\n return true;\n}\n\n/**\n * This function packs rectangles into an outer rectangle of a given width with a guillotine row packing. It does\n * not change the width. Without `fixedSize`, the height grows until all rectangles fit. A `locked` rectangle keeps\n * its position, but the rows do not go around it. `pack` sets the width first and then uses this function.\n */\nexport function packRows<T>(rects: Rect<T>[], outer: Rect<T>, options: PackOptions = {}): Rect<T> {\n const order = options.sortOrder ?? \"height-desc\";\n for (const r of rects) if (r.locked) r.wasPacked = true;\n while (!packRow(rects, outer, order));\n return outer;\n}\n\n/**\n * This function packs rectangles into an outer rectangle with a guillotine row packing. It sets the position\n * of each rectangle and the size of the outer rectangle, and it gives the outer rectangle.\n *\n * - Without fixed sizes, the outer rectangle starts with a width of 1.5 times the square root of the total area.\n * This width is not less than the width of the widest rectangle. The height grows until all rectangles fit.\n * - With `fixedWidth`, the width stays. A rectangle wider than that width goes on its own row and overflows.\n * - With `fixedSize`, a rectangle that does not fit is not packed: its `wasPacked` stays `false`.\n * - `options.strategy` selects `packRows` (the default), `packSkyline` or `packShelf` after the width is set.\n */\nexport function pack<T>(rects: Rect<T>[], outer: Rect<T> = new Rect(), options: PackLayoutOptions = {}): Rect<T> {\n let totalArea = 0;\n let widest = 0;\n let minX = rects.length > 0 ? Infinity : 0;\n let minY = rects.length > 0 ? Infinity : 0;\n for (const r of rects) {\n totalArea += r.area();\n widest = Math.max(widest, r.size.x);\n minX = Math.min(minX, r.size.x);\n minY = Math.min(minY, r.size.y);\n }\n\n const idealWidth = outer.fixedWidth\n ? outer.size.x\n : Math.max(widest, Math.min(1.5 * Math.sqrt(totalArea), outer.size.x || Infinity));\n\n const ideal = Vector.of(idealWidth).clamp(new Vector(minX, minY), Vector.Infinity);\n\n // A fixed width stays, also when a rectangle is wider: that rectangle overflows\n if (!outer.fixedSize) outer.size.setTo(outer.fixedWidth ? new Vector(outer.size.x, ideal.y) : ideal);\n if (options.strategy === \"skyline\") packSkyline(rects, outer, options);\n else if (options.strategy === \"shelf\") packShelf(rects, outer, options);\n else packRows(rects, outer, options);\n\n if (!outer.fixedSize) {\n const contentRight = Rect.maxRight(rects);\n if (!outer.size.x) outer.size.x = contentRight;\n else if (!outer.fixedWidth) outer.size.x = Math.min(contentRight, outer.size.x);\n outer.size.y = Rect.maxBottom(rects);\n }\n\n return outer;\n}\n","import { pack, type PackLayoutOptions } from \"./pack.ts\";\nimport { Rect } from \"./rect.ts\";\n\n/** The options of `packFree` */\nexport interface FreeWidthOptions extends PackLayoutOptions {\n /** The target aspect: the width divided by the height. The default is 1, a square. */\n aspect?: number;\n /**\n * The weight of the aspect error in the objective. The objective is the area times `1 + aspectWeight * aspectError`.\n * The default is 1. With 0, only the area counts.\n */\n aspectWeight?: number;\n /** The number of widths that the first pass tries. The default is 48. */\n samples?: number;\n}\n\n/** One width that `packFree` tried, and its result */\nexport interface FreeWidthTry {\n /** The width of the container for this try */\n width: number;\n /** The width of the content: the right edge of the rectangles */\n contentWidth: number;\n /** The height of the content */\n contentHeight: number;\n /** The objective of this try. Lower is better. */\n objective: number;\n}\n\n/** The result of `packFree` */\nexport interface FreeWidthResult<T> {\n /** The outer rectangle, with the size of the content */\n outer: Rect<T>;\n /** The area of the bounding box of the content */\n area: number;\n /** The area of the rectangles divided by the area of the bounding box */\n fill: number;\n /** The aspect of the bounding box: the width divided by the height */\n aspect: number;\n /** The distance from the target aspect: the absolute value of `log(aspect) - log(target)` */\n aspectError: number;\n /** The objective of the chosen width. Lower is better. */\n objective: number;\n /** Each width that the search tried, in the order of the search */\n tried: FreeWidthTry[];\n}\n\n/** This function gives the distance between an aspect and a target aspect on a log scale. */\nexport function aspectError(width: number, height: number, target = 1): number {\n if (!(width > 0 && height > 0 && target > 0)) return Infinity;\n return Math.abs(Math.log(width / height) - Math.log(target));\n}\n\n/**\n * This function packs rectangles with a free width. It tries many widths with the strategy of `options`, and keeps\n * the width with the lowest objective: the area of the bounding box times `1 + aspectWeight * aspectError`.\n *\n * - The first pass tries `samples` widths on a log scale, from the widest rectangle to the width of one row.\n * - The second pass tries the widths between the two neighbours of the best width of the first pass.\n * - The search is deterministic: the same input gives the same widths and the same result.\n * - A `locked` rectangle keeps its position. The width is not less than its right edge.\n * - Each strategy of `pack` works with this function, because it only changes the width.\n */\nexport function packFree<T>(rects: Rect<T>[], outer: Rect<T> = new Rect(), options: FreeWidthOptions = {}): FreeWidthResult<T> {\n const target = options.aspect ?? 1;\n const weight = options.aspectWeight ?? 1;\n const samples = Math.max(2, Math.floor(options.samples ?? 48));\n const ox = outer.position.x;\n const oy = outer.position.y;\n\n let itemArea = 0;\n let minWidth = 0;\n let rowWidth = 0;\n for (const r of rects) {\n if (r.locked) {\n minWidth = Math.max(minWidth, r.right() - ox);\n continue;\n }\n if (!(r.size.x > 0 && r.size.y > 0)) continue;\n itemArea += r.area();\n minWidth = Math.max(minWidth, r.size.x);\n rowWidth += r.size.x;\n }\n for (const r of rects) if (r.locked) itemArea += r.area();\n const maxWidth = Math.max(minWidth, rowWidth);\n\n const tried: FreeWidthTry[] = [];\n const run = (width: number): FreeWidthTry => {\n Rect.resetPacked(rects);\n const box = new Rect<T>();\n box.position.setTo(outer.position);\n box.size.set(width, 0);\n box.fixedWidth = true;\n pack(rects, box, options);\n const placed = Rect.packed(rects);\n const contentWidth = Math.max(0, Rect.maxRight(placed) - ox);\n const contentHeight = Math.max(0, Rect.maxBottom(placed) - oy);\n const area = contentWidth * contentHeight;\n const objective = area > 0 ? area * (1 + weight * aspectError(contentWidth, contentHeight, target)) : 0;\n const t = { width, contentWidth, contentHeight, objective };\n tried.push(t);\n return t;\n };\n\n // The first pass: widths on a log scale. Each width is a whole number when the sizes are whole numbers.\n const widths: number[] = [];\n if (maxWidth > 0) {\n const ratio = maxWidth / minWidth;\n for (let i = 0; i < samples; i++) {\n const w = minWidth * ratio ** (i / (samples - 1));\n const rounded = i === samples - 1 ? maxWidth : Math.max(minWidth, Math.round(w));\n if (widths.at(-1) !== rounded) widths.push(rounded);\n }\n }\n let best: FreeWidthTry | undefined = undefined;\n let bestIndex = 0;\n for (const [i, w] of widths.entries()) {\n const t = run(w);\n if (best === undefined || t.objective < best.objective) {\n best = t;\n bestIndex = i;\n }\n }\n\n // The second pass: the widths between the two neighbours of the best width\n if (widths.length > 2) {\n const low = widths[Math.max(0, bestIndex - 1)]!;\n const high = widths[Math.min(widths.length - 1, bestIndex + 1)]!;\n const steps = Math.min(Math.floor(samples / 2), Math.max(0, Math.round(high - low) - 1));\n for (let i = 1; i <= steps; i++) {\n const w = Math.round(low + ((high - low) * i) / (steps + 1));\n if (widths.includes(w)) continue;\n const t = run(w);\n if (best === undefined || t.objective < best.objective) best = t;\n }\n }\n\n // The last run packs with the best width, so the positions of the rectangles are those of the best width\n const chosen = best === undefined ? undefined : run(best.width);\n tried.pop();\n const w = chosen?.contentWidth ?? 0;\n const h = chosen?.contentHeight ?? 0;\n if (!outer.fixedSize) outer.size.set(w, h);\n const area = w * h;\n return {\n outer,\n area,\n fill: area > 0 ? itemArea / area : 0,\n aspect: h > 0 ? w / h : 0,\n aspectError: aspectError(w, h, target),\n objective: chosen?.objective ?? 0,\n tried,\n };\n}\n","import type { Rect } from \"./rect.ts\";\n\n/** The options of `pushCascade`. */\nexport interface PushOptions {\n /** The space between a shoved rectangle and the rectangle that shoves it. The default is 8. */\n gap?: number;\n /** The most shoves. The default is eight for each rectangle. The cascade stops at this limit. */\n maxShoves?: number;\n}\n\n/** A direction of a shove: an axis and a sign. */\ninterface Direction {\n readonly axis: \"x\" | \"y\";\n readonly sign: 1 | -1;\n}\n\n/** This function gives the overlap of two rectangles on each axis. A value of 0 or less is no overlap. */\nfunction overlapOf(a: Rect, b: Rect): { x: number; y: number } {\n return {\n x: Math.min(a.right(), b.right()) - Math.max(a.position.x, b.position.x),\n y: Math.min(a.bottom(), b.bottom()) - Math.max(a.position.y, b.position.y),\n };\n}\n\n/**\n * This function gives the direction of a first shove. The axis has the smaller overlap. The sign points away from the\n * center of the pusher. When that shove crosses 0, the sign is positive.\n */\nfunction firstDirection(pusher: Rect, r: Rect, gap: number): Direction {\n const overlap = overlapOf(pusher, r);\n if (overlap.x < overlap.y) {\n const back = r.position.x + r.size.x / 2 < pusher.position.x + pusher.size.x / 2 && pusher.position.x - r.size.x - gap >= 0;\n return { axis: \"x\", sign: back ? -1 : 1 };\n }\n const back = r.position.y + r.size.y / 2 < pusher.position.y + pusher.size.y / 2 && pusher.position.y - r.size.y - gap >= 0;\n return { axis: \"y\", sign: back ? -1 : 1 };\n}\n\n/** This function puts a rectangle past the pusher, along a direction. The rectangle does not go past 0. */\nfunction shove(pusher: Rect, r: Rect, direction: Direction, gap: number): void {\n if (direction.axis === \"x\") {\n const x = direction.sign > 0 ? pusher.right() + gap : pusher.position.x - r.size.x - gap;\n r.position.set(Math.max(0, x), r.position.y);\n return;\n }\n const y = direction.sign > 0 ? pusher.bottom() + gap : pusher.position.y - r.size.y - gap;\n r.position.set(r.position.x, Math.max(0, y));\n}\n\n/**\n * This function moves each rectangle that a placed rectangle overlaps, and the rectangles that those overlap in turn.\n * A shove takes the axis of the smaller overlap, away from the pusher. A shoved rectangle keeps the direction of its first\n * shove when it shoves the next one, so the cascade goes outward. The placed rectangle and each locked rectangle stay.\n * The function moves the rectangles in place and gives the rectangles that moved.\n *\n * @example\n * ```ts\n * const moved = pushCascade(dropped, cards, { gap: 8 });\n * ```\n */\nexport function pushCascade<T>(placed: Rect<T>, rects: readonly Rect<T>[], options: PushOptions = {}): Rect<T>[] {\n const gap = options.gap ?? 8;\n const maxShoves = options.maxShoves ?? rects.length * 8;\n const moved = new Set<Rect<T>>();\n const queue: { pusher: Rect<T>; direction?: Direction }[] = [{ pusher: placed }];\n let shoves = 0;\n while (shoves < maxShoves) {\n const step = queue.shift();\n if (!step) break;\n const { pusher, direction } = step;\n for (const r of rects) {\n if (r === pusher || r === placed || r.locked) continue;\n const overlap = overlapOf(pusher, r);\n if (overlap.x <= 0 || overlap.y <= 0) continue;\n const next = direction ?? firstDirection(pusher, r, gap);\n shove(pusher, r, next, gap);\n moved.add(r);\n queue.push({ pusher: r, direction: next });\n if (++shoves >= maxShoves) break;\n }\n }\n return [...moved];\n}\n","// The data types of the Packer contract (docs/PACKER.md). They are plain data, with no class and no method.\n// The shared package `@mark1russell7/layout-contract` gets these types later. Until then, this file is a local copy.\n\n/** A region. The forms and the rules are those of `docs/FORMAT.md`. The y axis points down. */\nexport type Region =\n | { kind: \"rect\"; x: number; y: number; w: number; h: number }\n | { kind: \"polygon\"; points: [number, number][]; holes?: [number, number][][] }\n | { kind: \"circle\"; cx: number; cy: number; r: number }\n | { kind: \"ellipse\"; cx: number; cy: number; rx: number; ry: number };\n\n/** The container of a packing. */\nexport interface Container {\n /** The width. Without it, the packer searches the width. */\n w?: number;\n /** The height. Without it, the packer searches the height. */\n h?: number;\n /** The sides that stay: `size` keeps `w` and `h`, `width` keeps `w`, `height` keeps `h`, and `none` searches both. */\n fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect (the width divided by the height) for the value `none` of `fixed`. The default is 1. */\n aspect?: number;\n /** The weight of the aspect error in the objective. The value 0 gives the least area. The default is 1. */\n aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n shape?: Region;\n /** The space between the border and the items with their margins. The default is 0. */\n inset?: number;\n}\n\n/** An obstacle: an area that no item enters. */\nexport interface Obstacle {\n id: string;\n region: Region;\n /** Without it, the obstacle stays. With it, the packer can move the obstacle for `cost` times the distance. */\n move?: { cost: number };\n}\n\n/** The margin of an item on each side. */\nexport interface Margin {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\n/** A port on the border of an item. */\nexport interface Port {\n id: string;\n side: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** The point on the border of the item, relative to its top-left corner. Without it, the router chooses the point. */\n x?: number;\n y?: number;\n}\n\n/** An item to pack. The file format names it a box. */\nexport interface Item {\n id: string;\n w: number;\n h: number;\n /** The reading order. Without it, the index in the array is the rank. */\n rank?: number;\n group?: string;\n parent?: string;\n /** A shape relative to the origin of the item. Without it, the item is the rectangle `w` by `h`. */\n shape?: Region;\n /** A locked item keeps `x` and `y`. The packer reads it as an obstacle. */\n locked?: boolean;\n x?: number;\n y?: number;\n /** The value `true` lets the packer turn the item by 90 degrees. The default is `false`. */\n turnable?: boolean;\n /** A ring around the item that no other item and no route enters. The default is 0. */\n margin?: number | Margin;\n /** The ports. The packer keeps them, and turns them with the item. */\n ports?: Port[];\n}\n\n/** The input of a packing: a `layout-input/1` file without `edges`, with `items` for `boxes`. */\nexport interface PackInput {\n container: Container;\n items: Item[];\n obstacles?: Obstacle[];\n /** The free space between two items with their margins. Routes use this space. The default is 0. */\n gap?: number;\n}\n\n/** The position of one item after the packing. */\nexport interface Placement {\n id: string;\n x: number;\n y: number;\n /** The turn: 0 or 90, only for an item with `turnable` set to `true`. */\n turn?: 0 | 90;\n}\n\n/** The facts of one stage of a packing. */\nexport interface StageTrace {\n /** The id of the stage, for example `skyline` or `log-sweep`. */\n id: string;\n /** The time of the stage in milliseconds. */\n ms: number;\n /** The measures of the stage, by the names of `docs/FORMAT.md`. */\n measures: Record<string, number>;\n}\n\n/** The output of a packing. The output does not change the input. */\nexport interface PackOutput {\n placements: Placement[];\n /** The ids of the items that the packer did not place. */\n overflow: string[];\n /** The size of the container after the packing. For a free size, the size that the search found. */\n size: { w: number; h: number };\n /** The new positions of the obstacles that moved. */\n moved: { id: string; x: number; y: number }[];\n /** The facts of each stage, for the site and the records. */\n trace: StageTrace[];\n}\n\n/** The tolerances of the hard rules. */\nexport interface Tolerance {\n /** The rule `no-overlap`: two boxes overlap only by more than this value. */\n overlap: number;\n /** The router rule that a route does not go through a box. */\n through: number;\n}\n\n/** The tolerance for the comparison of two numbers in an engine. */\nexport const EPS = 1e-6;\n\n/** The tolerance for the comparison of two numbers of a file. The files round to 3 decimals. */\nexport const RECORD_EPS = 1e-3;\n\n/** The default tolerances of the hard rules. Each record writes its tolerances in its top-level field `tolerance`. */\nexport const DEFAULT_TOLERANCE: Readonly<Tolerance> = Object.freeze({ overlap: 0.001, through: 0.5 });\n\n/** This function gives the margin of an item on each side. A number is the same margin on each side. */\nexport function marginOf(item: Pick<Item, \"margin\">): Margin {\n const m = item.margin ?? 0;\n if (typeof m === \"number\") return { top: m, right: m, bottom: m, left: m };\n return { top: m.top, right: m.right, bottom: m.bottom, left: m.left };\n}\n\n/** The side of a port after a turn of 90 degrees clockwise. */\nconst TURNED_SIDE = { top: \"right\", right: \"bottom\", bottom: \"left\", left: \"top\" } as const;\n\n/** This function gives the point `px`, `py` of an item of height `h` after a turn of 90 degrees clockwise. */\nexport function turnPoint(px: number, py: number, h: number): [number, number] {\n return [h - py, px];\n}\n\n/** This function turns a port of an item of height `h` by 90 degrees clockwise. The side turns from top to right. */\nexport function turnPort(port: Port, h: number): Port {\n const turned: Port = { id: port.id, side: TURNED_SIDE[port.side] };\n if (port.x !== undefined && port.y !== undefined) {\n const [x, y] = turnPoint(port.x, port.y, h);\n turned.x = x;\n turned.y = y;\n } else if (port.x !== undefined) {\n // Only x is set: x becomes the new y, and the router chooses the new x\n turned.y = port.x;\n } else if (port.y !== undefined) {\n // Only y is set: h - y becomes the new x, and the router chooses the new y\n turned.x = h - port.y;\n }\n return turned;\n}\n\n/** This function turns a region relative to an item of height `h` by 90 degrees clockwise. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\": {\n const [cx, cy] = turnPoint(region.cx, region.cy, h);\n return { kind: \"circle\", cx, cy, r: region.r };\n }\n case \"ellipse\": {\n const [cx, cy] = turnPoint(region.cx, region.cy, h);\n return { kind: \"ellipse\", cx, cy, rx: region.ry, ry: region.rx };\n }\n case \"polygon\": {\n const turnRing = (ring: [number, number][]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n const turned: Region = { kind: \"polygon\", points: turnRing(region.points) };\n if (region.holes) turned.holes = region.holes.map(turnRing);\n return turned;\n }\n }\n}\n\n/**\n * This function gives an item after a turn of 90 degrees clockwise, with the y axis down (decision 1 of\n * `docs/PACKER.md`). The width and the height change places. The top-left corner, the id and the other fields stay.\n * The ports, the shape and the margin turn with the item. The function does not change its argument.\n */\nexport function turnItem(item: Item): Item {\n const turned: Item = { ...item, w: item.h, h: item.w };\n if (item.ports) turned.ports = item.ports.map((p) => turnPort(p, item.h));\n if (item.shape) turned.shape = turnRegion(item.shape, item.h);\n if (item.margin !== undefined && typeof item.margin !== \"number\") {\n const m = item.margin;\n turned.margin = { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n }\n return turned;\n}\n","// SHA-256 (FIPS 180-4) in plain TypeScript. The hash of a corpus file needs it, and a browser has no synchronous SHA-256.\n\n/** The round constants of SHA-256. */\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be,\n 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa,\n 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85,\n 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,\n 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\n/** The first hash value of SHA-256. */\nconst H0 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n\n/** This function turns a 32-bit word to the right by `n` bits. */\nconst rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));\n\n/**\n * This function gives the UTF-8 bytes of a string. A lone surrogate becomes U+FFFD, as with `TextEncoder`. The\n * package has no `TextEncoder` type, because its code operates on each runtime with no global types.\n */\nexport function utf8(text: string): Uint8Array {\n const out: number[] = [];\n for (let i = 0; i < text.length; i++) {\n let c = text.charCodeAt(i);\n if (c >= 0xd800 && c <= 0xdbff && i + 1 < text.length) {\n const next = text.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) {\n c = 0x10000 + ((c - 0xd800) << 10) + (next - 0xdc00);\n i++;\n }\n }\n if (c >= 0xd800 && c <= 0xdfff) c = 0xfffd;\n if (c < 0x80) out.push(c);\n else if (c < 0x800) out.push(0xc0 | (c >> 6), 0x80 | (c & 63));\n else if (c < 0x10000) out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n else out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n }\n return Uint8Array.from(out);\n}\n\n/** This function gives the SHA-256 of the UTF-8 bytes of a string, as 64 lowercase hex characters. */\nexport function sha256Hex(text: string): string {\n const bytes = utf8(text);\n const length = bytes.length;\n const padded = new Uint8Array((((length + 9 + 63) / 64) | 0) * 64);\n padded.set(bytes);\n padded[length] = 0x80;\n const view = new DataView(padded.buffer);\n const bits = length * 8;\n view.setUint32(padded.length - 8, Math.floor(bits / 0x100000000));\n view.setUint32(padded.length - 4, bits >>> 0);\n\n const hash = [...H0];\n const w = new Uint32Array(64);\n for (let block = 0; block < padded.length; block += 64) {\n for (let t = 0; t < 16; t++) w[t] = view.getUint32(block + t * 4);\n for (let t = 16; t < 64; t++) {\n const a = w[t - 15]!;\n const b = w[t - 2]!;\n const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);\n const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);\n w[t] = (w[t - 16]! + s0 + w[t - 7]! + s1) | 0;\n }\n let [a, b, c, d, e, f, g, h] = hash as [number, number, number, number, number, number, number, number];\n for (let t = 0; t < 64; t++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (h + s1 + ch + K[t]! + w[t]!) | 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (s0 + maj) | 0;\n h = g;\n g = f;\n f = e;\n e = (d + t1) | 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) | 0;\n }\n hash[0] = (hash[0]! + a) | 0;\n hash[1] = (hash[1]! + b) | 0;\n hash[2] = (hash[2]! + c) | 0;\n hash[3] = (hash[3]! + d) | 0;\n hash[4] = (hash[4]! + e) | 0;\n hash[5] = (hash[5]! + f) | 0;\n hash[6] = (hash[6]! + g) | 0;\n hash[7] = (hash[7]! + h) | 0;\n }\n return hash.map((x) => (x >>> 0).toString(16).padStart(8, \"0\")).join(\"\");\n}\n","// The input file `layout-input/1` of `docs/FORMAT.md`: its types, its numbers, its canonical form and its hash.\n\nimport type { Container, Item, Obstacle, PackInput } from \"./contract.ts\";\nimport { sha256Hex, utf8 } from \"./sha256.ts\";\nimport type { Cell } from \"./strategy.ts\";\n\n/** An edge between two boxes. The router reads it, and the packer ignores it. */\nexport interface Edge {\n id: string;\n source: string;\n target: string;\n sourcePort?: string;\n targetPort?: string;\n}\n\n/** The parameters of a generator: a name and a string or a number for each parameter. */\nexport type GeneratorParams = Record<string, string | number>;\n\n/** The stamp of a generated input: the generator, its version, the full parameters and the seed. */\nexport interface GeneratorStamp {\n name: string;\n version: number;\n params: GeneratorParams;\n seed: number;\n}\n\n/** One input file `layout-input/1`. `docs/FORMAT.md` gives each field. */\nexport interface LayoutInput {\n schema: \"layout-input/1\";\n id: string;\n set: string;\n family: string;\n seed: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n source: string;\n /** The generator of a generated input. A hand-made or published input has `null`. */\n generator: GeneratorStamp | null;\n container: Container;\n obstacles?: Obstacle[];\n gap?: number;\n boxes: Item[];\n edges: Edge[];\n base?: string;\n change?: string;\n step?: number;\n /** The first 16 hex characters of the SHA-256 of the canonical form of the other fields. */\n hash: string;\n}\n\n/** The layout of the obstacles (`docs/research/TAXONOMY.md`, dimension 3). */\nexport type ObstacleLayout = \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n\n/** The distribution of the sizes of the items (`docs/research/TAXONOMY.md`, dimension 6). */\nexport type SizeDistribution = \"identical\" | \"nearIdentical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\";\n\n/** The scale of the count of the items (`docs/research/TAXONOMY.md`, dimension 7). */\nexport type CountScale = \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n\n/**\n * The cell of a generated input: one value for each dimension of the packer. The cell of `cellOf` has the dimensions\n * that the input tells. The generator adds the layout of the obstacles, the sizes, the count and the mode.\n */\nexport interface CorpusCell extends Cell {\n obstacles: ObstacleLayout;\n sizes: SizeDistribution;\n count: CountScale;\n mode: \"offline\" | \"online\" | \"incremental\";\n}\n\n/** This function gives the `fnv1a32` hash of the UTF-8 bytes of a string, as `docs/FORMAT.md` gives it. */\nexport function fnv1a32(text: string): number {\n let h = 0x811c9dc5;\n for (const b of utf8(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** This function rounds the numbers of a file to 3 decimals. A half goes up, and the value `-0` becomes 0. */\nexport function round3(x: number): number {\n const v = Math.round(x * 1000) / 1000;\n return Object.is(v, -0) ? 0 : v;\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys, no whitespace and the numbers of `JSON.stringify`\n * after `round3`. A key with the value `undefined` is not in the form.\n */\nexport function canonicalJson(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(\",\")}]`;\n if (value !== null && typeof value === \"object\") {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(\",\")}}`;\n }\n return JSON.stringify(typeof value === \"number\" ? round3(value) : value);\n}\n\n/** This function gives the hash of an input file: the first 16 hex characters of the SHA-256 of its canonical form without `hash`. */\nexport function hashInput(file: Omit<LayoutInput, \"hash\"> | LayoutInput): string {\n const rest: Partial<LayoutInput> = { ...file };\n delete rest.hash;\n return sha256Hex(canonicalJson(rest)).slice(0, 16);\n}\n\n/** This function gives the scale of a count: the nearest of 1, 10, 100, 1000 and 10000 on a log scale. The count 0 gives `1`. */\nexport function countCell(count: number): CountScale {\n if (count <= 3) return \"1\";\n if (count <= 31) return \"10\";\n if (count <= 316) return \"100\";\n if (count <= 3162) return \"1k\";\n return \"10k\";\n}\n\n/** This function gives the packing input of a file. The boxes become the items, and the edges go. */\nexport function toPackInput(file: Pick<LayoutInput, \"container\" | \"boxes\" | \"obstacles\" | \"gap\">): PackInput {\n const input: PackInput = { container: file.container, items: file.boxes };\n if (file.obstacles !== undefined) input.obstacles = file.obstacles;\n if (file.gap !== undefined) input.gap = file.gap;\n return input;\n}\n","// The algebra of measures (roadmap item k8). `docs/MEASURES.md` defines each measure. This file computes them.\n\nimport { RECORD_EPS, type PackInput, type PackOutput } from \"./contract.ts\";\nimport { aspectError } from \"./free.ts\";\nimport { round3 } from \"./layout-input.ts\";\n\n/** The direction of a measure: `lower` when a lower value is better, `higher` when a higher value is better. */\nexport type Direction = \"lower\" | \"higher\";\n\n/** The family of a measure. Each family has a section in `docs/MEASURES.md`. */\nexport type MeasureFamily = \"density\" | \"aspect\" | \"order\" | \"raggedness\" | \"overflow\" | \"stability\" | \"determinism\" | \"speed\";\n\n/** The id of a measure of the packer. The ids are those of `docs/FORMAT.md`, and `highways` uses the same ids. */\nexport type MeasureId = \"pack.area\" | \"pack.fill\" | \"pack.whitespace\" | \"pack.aspect\" | \"pack.aspectError\" | \"pack.order.inversions\" | \"pack.order.breaks\" | \"pack.raggedness\" | \"pack.overflow\" | \"pack.stability.moved\" | \"pack.stability.mean\" | \"pack.stability.q95\" | \"pack.deterministic\" | \"pack.search.widths\" | \"pack.search.ms\";\n\n/** The facts of one measure: its family, its unit, its direction and its range. */\nexport interface MeasureSpec {\n id: MeasureId;\n family: MeasureFamily;\n unit: string;\n direction: Direction;\n /** The lowest value. */\n min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n max: number;\n}\n\n/** The measures of one layout, by id. `measure` gives them. The values are not rounded. */\nexport interface LayoutMeasures {\n \"pack.area\": number;\n \"pack.fill\": number;\n \"pack.whitespace\": number;\n \"pack.aspect\": number;\n \"pack.aspectError\": number;\n \"pack.order.inversions\": number;\n \"pack.order.breaks\": number;\n \"pack.raggedness\": number;\n \"pack.overflow\": number;\n \"pack.search.widths\": number;\n \"pack.search.ms\": number;\n}\n\n/** The stability measures of a change pair, by id. `measureChange` gives them. The values are not rounded. */\nexport interface ChangeMeasures {\n \"pack.stability.moved\": number;\n \"pack.stability.mean\": number;\n \"pack.stability.q95\": number;\n}\n\n/** The options of `measure`. */\nexport interface MeasureOptions {\n /**\n * A box joins a row when its top is this close to the top of the first box of the row. The rows give\n * `pack.raggedness`. The default is half the median height of the boxes.\n */\n rowTolerance?: number;\n}\n\nconst spec = (id: MeasureId, family: MeasureFamily, unit: string, direction: Direction, min: number, max: number): MeasureSpec => ({\n id,\n family,\n unit,\n direction,\n min,\n max,\n});\n\n/** The facts of each measure, by id. `docs/MEASURES.md` gives the full definitions. */\nexport const MEASURE_SPECS: Readonly<Record<MeasureId, MeasureSpec>> = Object.freeze({\n \"pack.area\": spec(\"pack.area\", \"density\", \"square units\", \"lower\", 0, Infinity),\n \"pack.fill\": spec(\"pack.fill\", \"density\", \"share\", \"higher\", 0, 1),\n \"pack.whitespace\": spec(\"pack.whitespace\", \"density\", \"share\", \"lower\", 0, 1),\n \"pack.aspect\": spec(\"pack.aspect\", \"aspect\", \"ratio\", \"lower\", 1, Infinity),\n \"pack.aspectError\": spec(\"pack.aspectError\", \"aspect\", \"natural log\", \"lower\", 0, Infinity),\n \"pack.order.inversions\": spec(\"pack.order.inversions\", \"order\", \"share\", \"lower\", 0, 1),\n \"pack.order.breaks\": spec(\"pack.order.breaks\", \"order\", \"count\", \"lower\", 0, Infinity),\n \"pack.raggedness\": spec(\"pack.raggedness\", \"raggedness\", \"share\", \"lower\", 0, 1),\n \"pack.overflow\": spec(\"pack.overflow\", \"overflow\", \"count\", \"lower\", 0, Infinity),\n \"pack.stability.moved\": spec(\"pack.stability.moved\", \"stability\", \"share\", \"lower\", 0, 1),\n \"pack.stability.mean\": spec(\"pack.stability.mean\", \"stability\", \"container widths\", \"lower\", 0, Infinity),\n \"pack.stability.q95\": spec(\"pack.stability.q95\", \"stability\", \"container widths\", \"lower\", 0, Infinity),\n \"pack.deterministic\": spec(\"pack.deterministic\", \"determinism\", \"boolean\", \"higher\", 0, 1),\n \"pack.search.widths\": spec(\"pack.search.widths\", \"speed\", \"count\", \"lower\", 0, Infinity),\n \"pack.search.ms\": spec(\"pack.search.ms\", \"speed\", \"milliseconds\", \"lower\", 0, Infinity),\n});\n\n/** A placed box: the rectangle of an item at its position, with its rank. */\nexport interface Box {\n x: number;\n y: number;\n w: number;\n h: number;\n rank: number;\n}\n\n/** This function gives the smallest rectangle around the boxes. No box gives a rectangle of size 0 at 0, 0. */\nexport function hullOf(boxes: readonly Pick<Box, \"x\" | \"y\" | \"w\" | \"h\">[]): { x: number; y: number; w: number; h: number } {\n if (boxes.length === 0) return { x: 0, y: 0, w: 0, h: 0 };\n let left = Infinity;\n let top = Infinity;\n let right = -Infinity;\n let bottom = -Infinity;\n for (const b of boxes) {\n left = Math.min(left, b.x);\n top = Math.min(top, b.y);\n right = Math.max(right, b.x + b.w);\n bottom = Math.max(bottom, b.y + b.h);\n }\n return { x: left, y: top, w: right - left, h: bottom - top };\n}\n\n/**\n * This function puts the boxes in rows. It sorts the boxes by their top, and keeps the order of the list for equal tops.\n * A box joins the last row when its top is within `tolerance` of the top of the first box of that row.\n */\nexport function rowsOf(boxes: readonly Pick<Box, \"x\" | \"y\" | \"w\">[], tolerance: number): { top: number; right: number; count: number }[] {\n const rows: { top: number; right: number; count: number }[] = [];\n for (const b of boxes.toSorted((p, q) => p.y - q.y)) {\n const row = rows.at(-1);\n if (row && Math.abs(b.y - row.top) <= tolerance) {\n row.right = Math.max(row.right, b.x + b.w);\n row.count += 1;\n } else {\n rows.push({ top: b.y, right: b.x + b.w, count: 1 });\n }\n }\n return rows;\n}\n\n/**\n * This function gives the placed boxes of an output, in the order of the items of the input. A box has the size of its\n * item after the turn. The list has no item without a placement, and no item with a width or a height of 0.\n */\nexport function boxesOf(input: PackInput, output: PackOutput): Box[] {\n const placements = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (!placements.has(p.id)) placements.set(p.id, p);\n const boxes: Box[] = [];\n for (const [index, item] of input.items.entries()) {\n const p = placements.get(item.id);\n if (p === undefined || !(item.w > 0 && item.h > 0)) continue;\n const turned = p.turn === 90;\n boxes.push({ x: p.x, y: p.y, w: turned ? item.h : item.w, h: turned ? item.w : item.h, rank: item.rank ?? index });\n }\n return boxes;\n}\n\n/**\n * This function tells if box `a` comes before box `b` in the reading order. Two boxes whose heights overlap by more than\n * `RECORD_EPS` are on one line, and the left box comes first. Otherwise the upper box comes first.\n */\nexport function readsBefore(a: Pick<Box, \"x\" | \"y\" | \"h\">, b: Pick<Box, \"x\" | \"y\" | \"h\">): boolean {\n const shared = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);\n if (shared > RECORD_EPS) return a.x + RECORD_EPS < b.x;\n return a.y < b.y;\n}\n\n/** This function sums one measure over the stages of a trace. A trace without the measure gives 0. */\nfunction traceSum(output: PackOutput, id: string): number {\n let sum = 0;\n for (const stage of output.trace) sum += stage.measures[id] ?? 0;\n return sum;\n}\n\n/**\n * This function gives the measures of one layout, by the ids of `docs/MEASURES.md`. The values are not rounded. A\n * record rounds them with `roundMeasures`.\n *\n * - The boxes are the placed items with a width and a height above 0. The hull is the smallest rectangle around them.\n * - An empty layout gives the area 0, the aspect 1 and the aspect error 0. Its fill is 0 and its whitespace is 1.\n * - The time `pack.search.ms` comes from the trace. It is not part of the determinism rule.\n *\n * @example\n * ```ts\n * const m = measure(input, packWith(\"shelf\", input));\n * m[\"pack.fill\"]; // the area of the boxes divided by the area of the hull\n * ```\n */\nexport function measure(input: PackInput, output: PackOutput, options: MeasureOptions = {}): LayoutMeasures {\n const boxes = boxesOf(input, output);\n const hull = hullOf(boxes);\n const hullArea = hull.w * hull.h;\n const boxArea = boxes.reduce((sum, b) => sum + b.w * b.h, 0);\n const fill = hullArea > 0 ? boxArea / hullArea : 0;\n const empty = boxes.length === 0;\n const target = input.container.aspect ?? 1;\n\n // The reading order: each pair of boxes with different ranks, and each step of the rank order\n let pairs = 0;\n let inversions = 0;\n for (let i = 0; i < boxes.length; i++) {\n for (let j = i + 1; j < boxes.length; j++) {\n const a = boxes[i]!;\n const b = boxes[j]!;\n if (a.rank === b.rank) continue;\n pairs += 1;\n const first = a.rank < b.rank ? a : b;\n const second = first === a ? b : a;\n if (readsBefore(second, first)) inversions += 1;\n }\n }\n const byRank = boxes.toSorted((a, b) => a.rank - b.rank);\n let breaks = 0;\n for (let k = 1; k < byRank.length; k++) {\n const prev = byRank[k - 1]!;\n const next = byRank[k]!;\n if (prev.rank !== next.rank && readsBefore(next, prev)) breaks += 1;\n }\n\n const tolerance = options.rowTolerance ?? quantileOrZero(boxes.map((b) => b.h), 0.5) / 2;\n const rights = rowsOf(boxes, tolerance).map((r) => r.right);\n const spread = rights.length > 0 ? Math.max(...rights) - Math.min(...rights) : 0;\n\n return {\n \"pack.area\": hullArea,\n \"pack.fill\": fill,\n \"pack.whitespace\": 1 - fill,\n \"pack.aspect\": empty ? 1 : Math.max(hull.w / hull.h, hull.h / hull.w),\n \"pack.aspectError\": empty ? 0 : aspectError(hull.w, hull.h, target),\n \"pack.order.inversions\": pairs > 0 ? inversions / pairs : 0,\n \"pack.order.breaks\": breaks,\n \"pack.raggedness\": hull.w > 0 ? spread / hull.w : 0,\n \"pack.overflow\": new Set(output.overflow).size,\n \"pack.search.widths\": traceSum(output, \"pack.search.widths\"),\n \"pack.search.ms\": traceSum(output, \"pack.search.ms\"),\n };\n}\n\n/**\n * This function gives the stability measures of a change pair: the run on the base input and the run on the changed\n * input. The items match by id. The values are not rounded.\n *\n * - An item stays when both inputs have it and both outputs place it. The added and the removed items do not count.\n * - A staying item moved when its `x` or its `y` changed by more than `RECORD_EPS`, or when its turn changed.\n * - The distance of an item is the length of the move of its top-left corner. The unit is the width `W`.\n * - `W` is the larger width of the 2 output sizes. A `W` of 0 becomes 1, so the unit is then the unit of the input.\n * - No staying item gives 0 for each measure.\n */\nexport function measureChange(baseInput: PackInput, baseOutput: PackOutput, changeInput: PackInput, changeOutput: PackOutput): ChangeMeasures {\n const placed = (input: PackInput, output: PackOutput): Map<string, PackOutput[\"placements\"][number]> => {\n const ids = new Set(input.items.map((i) => i.id));\n const map = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (ids.has(p.id) && !map.has(p.id)) map.set(p.id, p);\n return map;\n };\n const before = placed(baseInput, baseOutput);\n const after = placed(changeInput, changeOutput);\n const width = Math.max(baseOutput.size.w, changeOutput.size.w);\n const unit = width > 0 ? width : 1;\n\n const distances: number[] = [];\n let moved = 0;\n for (const [id, p] of before) {\n const q = after.get(id);\n if (q === undefined) continue;\n const dx = q.x - p.x;\n const dy = q.y - p.y;\n if (Math.abs(dx) > RECORD_EPS || Math.abs(dy) > RECORD_EPS || (p.turn ?? 0) !== (q.turn ?? 0)) moved += 1;\n distances.push(Math.hypot(dx, dy) / unit);\n }\n if (distances.length === 0) return { \"pack.stability.moved\": 0, \"pack.stability.mean\": 0, \"pack.stability.q95\": 0 };\n return {\n \"pack.stability.moved\": moved / distances.length,\n \"pack.stability.mean\": distances.reduce((sum, d) => sum + d, 0) / distances.length,\n \"pack.stability.q95\": quantile(distances, 0.95),\n };\n}\n\n/**\n * This function gives the measure `pack.deterministic` of two runs with the same input, options and seed. It gives\n * `true` when the runs have the same placements, overflow, size and moved obstacles.\n *\n * - The placements match by id, so their order in the list does not count. The numbers must be equal.\n * - The trace is not part of the rule, because its times change each time.\n */\nexport function isDeterministic(first: PackOutput, second: PackOutput): boolean {\n const key = <T extends { id: string }>(list: readonly T[]): Map<string, T> => new Map(list.map((e) => [e.id, e]));\n const samePlacements = (a: PackOutput[\"placements\"], b: PackOutput[\"placements\"]): boolean => {\n if (a.length !== b.length) return false;\n const other = key(b);\n return a.every((p) => {\n const q = other.get(p.id);\n return q !== undefined && q.x === p.x && q.y === p.y && (q.turn ?? 0) === (p.turn ?? 0);\n });\n };\n const sameMoved = (a: PackOutput[\"moved\"], b: PackOutput[\"moved\"]): boolean => {\n if (a.length !== b.length) return false;\n const other = key(b);\n return a.every((m) => {\n const n = other.get(m.id);\n return n !== undefined && n.x === m.x && n.y === m.y;\n });\n };\n const overflowA = new Set(first.overflow);\n const overflowB = new Set(second.overflow);\n return (\n first.size.w === second.size.w &&\n first.size.h === second.size.h &&\n overflowA.size === overflowB.size &&\n [...overflowA].every((id) => overflowB.has(id)) &&\n samePlacements(first.placements, second.placements) &&\n sameMoved(first.moved, second.moved)\n );\n}\n\n/**\n * This function rounds each number of a record of measures with `round3`, as `docs/FORMAT.md` tells. A half goes up,\n * and `-0` becomes 0. The function keeps the other values, and it does not change its argument.\n */\nexport function roundMeasures<T extends object>(measures: T): T {\n const out: Record<string, unknown> = {};\n for (const [id, value] of Object.entries(measures)) out[id] = typeof value === \"number\" ? round3(value) : value;\n return out as T;\n}\n\n/**\n * This function gives the paired ratio of a measure on one input: the value of the candidate against the value of the\n * current default. A ratio above 1 is worse, in the direction of the measure.\n *\n * - For `lower`, the ratio is `candidate / current`. For `higher`, it is `current / candidate`.\n * - When both values are 0, the ratio is 1. When only the divisor is 0, the ratio is `Infinity`.\n * - The values are 0 or more. A negative value or `NaN` throws a `RangeError`.\n */\nexport function pairedRatio(candidate: number, current: number, direction: Direction): number {\n if (!(candidate >= 0 && current >= 0)) throw new RangeError(\"A paired ratio needs two values of 0 or more.\");\n const top = direction === \"lower\" ? candidate : current;\n const bottom = direction === \"lower\" ? current : candidate;\n if (bottom === 0) return top === 0 ? 1 : Infinity;\n return top / bottom;\n}\n\n/**\n * This function gives the quantile `q` of a list of numbers, with linear interpolation between the sorted values. The\n * position in the sorted list is `(n - 1) * q`. An empty list or a `q` outside 0 to 1 throws a `RangeError`.\n */\nexport function quantile(values: readonly number[], q: number): number {\n if (values.length === 0) throw new RangeError(\"A quantile needs one value or more.\");\n if (!(q >= 0 && q <= 1)) throw new RangeError(\"A quantile needs a q from 0 to 1.\");\n const sorted = values.toSorted((a, b) => a - b);\n const at = (sorted.length - 1) * q;\n const low = Math.floor(at);\n const part = at - low;\n const a = sorted[low]!;\n if (part === 0) return a;\n const b = sorted[low + 1]!;\n if (a === b) return a;\n return a + part * (b - a);\n}\n\n/** This function gives the quantile `q` of a list, and 0 for an empty list. */\nfunction quantileOrZero(values: readonly number[], q: number): number {\n return values.length === 0 ? 0 : quantile(values, q);\n}\n\n/** This function gives the median of the paired ratios of a corpus: the quantile 0.5. It is not a ratio of two medians. */\nexport function medianRatio(ratios: readonly number[]): number {\n return quantile(ratios, 0.5);\n}\n\n/** This function gives the share of the paired ratios above a limit. An empty list throws a `RangeError`. */\nexport function tailShare(ratios: readonly number[], limit: number): number {\n if (ratios.length === 0) throw new RangeError(\"A tail share needs one ratio or more.\");\n return ratios.filter((r) => r > limit).length / ratios.length;\n}\n","import { hullOf, rowsOf } from \"./measures.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/** The measurements of a packing. */\nexport interface PackingMetrics {\n /** The number of rectangles. */\n count: number;\n /** The size of the hull: the smallest box around the rectangles. */\n hull: { width: number; height: number };\n /** The width of the hull divided by its height. A hull without height gives 0. */\n hullAspect: number;\n /** The number of rectangles in each row, from the top. */\n rows: number[];\n /** The largest right edge of a row less the smallest right edge of a row. A straight right side gives 0. */\n raggedness: number;\n /** The part of the hull that the rectangles cover: their area divided by the area of the hull. */\n utilization: number;\n /** The width of the widest rectangle divided by the median width. */\n widestOverMedian: number;\n}\n\n/** The options of `packingMetrics`. */\nexport interface MetricsOptions {\n /** A rectangle joins a row when its top is this close to the top of the first rectangle of the row. The default is 40. */\n rowTolerance?: number;\n}\n\n/**\n * This function measures a packing. It gives the hull and its aspect, the rows and the raggedness of the right side.\n * It also gives the part of the hull that the rectangles cover, and the widest rectangle against the median width.\n *\n * @example\n * ```ts\n * const { utilization, raggedness } = packingMetrics(Rect.packed(cards));\n * ```\n */\nexport function packingMetrics(rects: readonly Rect[], options: MetricsOptions = {}): PackingMetrics {\n const tolerance = options.rowTolerance ?? 40;\n const boxes = rects.filter((r) => r.size.x > 0 && r.size.y > 0).map((r) => ({ x: r.position.x, y: r.position.y, w: r.size.x, h: r.size.y }));\n if (boxes.length === 0) return { count: 0, hull: { width: 0, height: 0 }, hullAspect: 0, rows: [], raggedness: 0, utilization: 0, widestOverMedian: 0 };\n\n // The hull and the rows come from the helpers of `measure`, so the two functions agree\n const box = hullOf(boxes);\n const hull = { width: box.w, height: box.h };\n const rows = rowsOf(boxes, tolerance);\n const rights = rows.map((row) => row.right);\n const widths = boxes.map((r) => r.w).toSorted((a, b) => a - b);\n const median = widths[Math.floor(widths.length / 2)] ?? 0;\n const widest = widths.at(-1) ?? 0;\n const area = boxes.reduce((sum, r) => sum + r.w * r.h, 0);\n return {\n count: boxes.length,\n hull,\n hullAspect: hull.height > 0 ? hull.width / hull.height : 0,\n rows: rows.map((row) => row.count),\n raggedness: Math.max(...rights) - Math.min(...rights),\n utilization: hull.width * hull.height > 0 ? area / (hull.width * hull.height) : 0,\n widestOverMedian: median > 0 ? widest / median : 0,\n };\n}\n","import type { Container, PackInput, PackOutput, Region } from \"./contract.ts\";\n\n/**\n * For each dimension of the taxonomy, the values that a strategy supports. `docs/research/TAXONOMY.md` gives the values.\n * The type is an alias, not an interface. Thus it fits the record `Supports` of the contract.\n */\nexport type Supports = {\n containerSize: (\"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\")[];\n containerShape: (\"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\")[];\n /** The movement of the obstacles. An empty list supports only an input with no obstacle and no locked item. */\n obstacleMove: (\"fixed\" | \"costly\" | \"free\")[];\n itemShape: (\"rect\" | \"circle\" | \"convex\" | \"polygon\" | \"mixed\")[];\n rotation: (\"none\" | \"quarter\" | \"any\")[];\n order: (\"free\" | \"soft\" | \"hard\")[];\n groups: (\"none\" | \"flat\" | \"nested\")[];\n mode: (\"offline\" | \"online\" | \"incremental\")[];\n};\n\n/** A dimension of `Supports`. */\nexport type Dimension = keyof Supports;\n\n/** A value of a dimension of `Supports`. */\nexport type DimensionValue<D extends Dimension = Dimension> = Supports[D][number];\n\n/**\n * The cell of an input: one value for each packer dimension that the input tells. The input does not tell the mode.\n * Without obstacles and locked items, the cell has no `obstacleMove`.\n */\nexport interface Cell {\n containerSize: DimensionValue<\"containerSize\">;\n containerShape: DimensionValue<\"containerShape\">;\n obstacleMove?: DimensionValue<\"obstacleMove\">;\n itemShape: DimensionValue<\"itemShape\">;\n rotation: DimensionValue<\"rotation\">;\n order: DimensionValue<\"order\">;\n groups: DimensionValue<\"groups\">;\n}\n\n/** The context of one packing. */\nexport interface PackContext {\n /** The seed. A strategy gets each random number from `rng`, not from `Math.random`. */\n seed: number;\n /** The random numbers in `[0, 1)`, from `mulberry32` with `seed`. */\n rng: () => number;\n /** A limit for the strategies that search. The strategy gives its best result at the limit. */\n budget?: { ms?: number; steps?: number };\n /** The previous output, for the mode `incremental`. */\n previous?: PackOutput;\n}\n\n/** A packing strategy behind the Packer interface. */\nexport interface Strategy<O = unknown> {\n /** A stable name, for example `shelf`. The records use it. */\n id: string;\n /** The family of the catalog, for example `shelf` or `skyline`. */\n family: string;\n /** The ids of the catalog rows that this strategy builds. */\n catalog: string[];\n /** The cells that the strategy supports. */\n supports: Supports;\n /** The default options. A record writes the options in full. */\n defaults: O;\n /** The value `true` tells that the result depends only on the input, the options and the seed. */\n deterministic: boolean;\n /** This method packs an input. It throws `UnsupportedCell` for an input outside the cells of `supports`. */\n pack(input: PackInput, options: O, context: PackContext): PackOutput;\n}\n\n/** A size search: it gives a strategy of a fixed width the cells `freeAspect` and `freeArea`. */\nexport interface SizeSearch {\n id: string;\n /** This method searches the size of the container for an input with `fixed` set to `none`. `options` go to `inner`. */\n search(input: PackInput, inner: Strategy, context: PackContext, options?: unknown): PackOutput;\n}\n\n/**\n * The error of a strategy for an input outside its cells. The benchmark records this result. It is not a failure of the\n * strategy.\n */\nexport class UnsupportedCell extends Error {\n /** The dimension of the taxonomy. */\n readonly dimension: Dimension;\n /** The value of the input that the strategy does not support. */\n readonly value: string;\n\n constructor(dimension: Dimension, value: string) {\n super(`The strategy does not support the value \"${value}\" of the dimension \"${dimension}\".`);\n this.name = \"UnsupportedCell\";\n this.dimension = dimension;\n this.value = value;\n }\n}\n\n/** This function gives a generator of random numbers in `[0, 1)`: `mulberry32` of `docs/FORMAT.md`. */\nexport function mulberry32(seed: number): () => number {\n let s = seed >>> 0;\n return () => {\n s = (s + 0x6d2b79f5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** This function makes the context of one packing from a seed. */\nexport function createContext(seed = 0, more: Omit<PackContext, \"seed\" | \"rng\"> = {}): PackContext {\n return { ...more, seed, rng: mulberry32(seed) };\n}\n\n/** This function tells if a polygon ring is convex. A ring with fewer than 3 points is convex. */\nfunction isConvex(points: readonly [number, number][]): boolean {\n let sign = 0;\n const n = points.length;\n for (let i = 0; i < n; i++) {\n const [ax, ay] = points[i]!;\n const [bx, by] = points[(i + 1) % n]!;\n const [cx, cy] = points[(i + 2) % n]!;\n const cross = (bx - ax) * (cy - by) - (by - ay) * (cx - bx);\n if (cross === 0) continue;\n if (sign === 0) sign = Math.sign(cross);\n else if (Math.sign(cross) !== sign) return false;\n }\n return true;\n}\n\n/** This function gives the value of `containerShape` of one region. */\nfunction shapeOf(region: Region): DimensionValue<\"containerShape\"> {\n switch (region.kind) {\n case \"rect\":\n case \"circle\":\n case \"ellipse\":\n return region.kind;\n case \"polygon\":\n if (region.holes && region.holes.length > 0) return \"holes\";\n return isConvex(region.points) ? \"convex\" : \"polygon\";\n }\n}\n\n/** This function gives the value of `itemShape` of one item shape. An ellipse is convex. */\nfunction itemShapeOf(region: Region | undefined): DimensionValue<\"itemShape\"> {\n if (region === undefined) return \"rect\";\n switch (region.kind) {\n case \"rect\":\n case \"circle\":\n return region.kind;\n case \"ellipse\":\n return \"convex\";\n case \"polygon\":\n return !region.holes?.length && isConvex(region.points) ? \"convex\" : \"polygon\";\n }\n}\n\n/**\n * This function gives the cell of an input: the values of the packer dimensions that the input tells.\n *\n * - `containerSize` comes from `fixed`. The value `none` gives `freeArea` when `aspectWeight` is 0, and `freeAspect` if not.\n * - `containerShape` comes from the shape. A rectangle container with an obstacle of another region gives `holes`.\n * - `obstacleMove` is the hardest value of the obstacles and the locked items: `costly`, then `free`, then `fixed`.\n * - `order` is `soft` when an item has a rank, and `free` if not. The input does not tell a hard order.\n * - `groups` is `nested` when an item has a parent, `flat` when an item has a group, and `none` if not.\n */\nexport function cellOf(input: PackInput): Cell {\n const { container, items } = input;\n const obstacles = input.obstacles ?? [];\n\n const sizes: Record<Container[\"fixed\"], DimensionValue<\"containerSize\">> = {\n size: \"fixed\",\n width: \"freeHeight\",\n height: \"freeWidth\",\n none: container.aspectWeight === 0 ? \"freeArea\" : \"freeAspect\",\n };\n const containerSize = sizes[container.fixed];\n\n let containerShape = container.shape ? shapeOf(container.shape) : \"rect\";\n if (containerShape === \"rect\" && obstacles.some((o) => o.region.kind !== \"rect\")) containerShape = \"holes\";\n\n let obstacleMove: DimensionValue<\"obstacleMove\"> | undefined = items.some((i) => i.locked === true) ? \"fixed\" : undefined;\n for (const o of obstacles) {\n const move = o.move === undefined ? \"fixed\" : o.move.cost > 0 ? \"costly\" : \"free\";\n if (move === \"costly\" || obstacleMove === undefined || (move === \"free\" && obstacleMove === \"fixed\")) obstacleMove = move;\n }\n\n const shapes = new Set(items.map((i) => itemShapeOf(i.shape)));\n const itemShape = shapes.size > 1 ? \"mixed\" : ([...shapes][0] ?? \"rect\");\n\n const cell: Cell = {\n containerSize,\n containerShape,\n itemShape,\n rotation: items.some((i) => i.turnable === true) ? \"quarter\" : \"none\",\n order: items.some((i) => i.rank !== undefined) ? \"soft\" : \"free\",\n groups: items.some((i) => i.parent !== undefined) ? \"nested\" : items.some((i) => i.group !== undefined) ? \"flat\" : \"none\",\n };\n if (obstacleMove !== undefined) cell.obstacleMove = obstacleMove;\n return cell;\n}\n\n/** This function gives the first dimension of a cell that `supports` does not hold, or `undefined` when it holds each one. */\nexport function unsupportedOf(supports: Supports, cell: Partial<Record<Dimension, string>>): { dimension: Dimension; value: string } | undefined {\n for (const dimension of Object.keys(supports) as Dimension[]) {\n const value = cell[dimension];\n if (value === undefined) continue;\n if (!(supports[dimension] as readonly string[]).includes(value)) return { dimension, value };\n }\n return undefined;\n}\n\n/** This function tells if `supports` holds each value of a cell. A dimension that the cell does not have is held. */\nexport function supportsCell(supports: Supports, cell: Partial<Record<Dimension, string>>): boolean {\n return unsupportedOf(supports, cell) === undefined;\n}\n\n/** This function throws `UnsupportedCell` for the first value of the cell of an input that `supports` does not hold. */\nexport function assertSupported(supports: Supports, input: PackInput): void {\n const miss = unsupportedOf(supports, cellOf(input));\n if (miss) throw new UnsupportedCell(miss.dimension, miss.value);\n}\n","// The internal frame of the adapters of 0.1: the conversion of a PackInput to the Rect objects of 0.1, and back.\n// Each item grows by its margin and by half the gap on each side. Each obstacle grows by half the gap. Thus two items\n// are `mA + gap + mB` apart. The area of the frame is the container less the inset, grown by half the gap on each side.\n\nimport { EPS, marginOf, type Item, type Obstacle, type PackInput, type PackOutput, type Placement, type Region, type StageTrace } from \"./contract.ts\";\nimport { Rect } from \"./rect.ts\";\n\nconst clock = (globalThis as { performance?: { now(): number } }).performance;\n\n/** This function gives the time in milliseconds. */\nexport function now(): number {\n return clock ? clock.now() : Date.now();\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): { x: number; y: number; w: number; h: number } {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n const xs = region.points.map((p) => p[0]);\n const ys = region.points.map((p) => p[1]);\n const x = Math.min(...xs);\n const y = Math.min(...ys);\n return { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y };\n }\n }\n}\n\n/** The rectangle of a container: its origin and its size. A free side has the size `Infinity`. */\nexport interface Bounds {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** This function gives the rectangle of a container. A rectangle shape gives the origin and the sizes of the fixed sides. */\nexport function containerBounds(input: PackInput): Bounds {\n const { container } = input;\n const shape = container.shape === undefined ? undefined : boundsOf(container.shape);\n const fixedW = container.fixed === \"size\" || container.fixed === \"width\";\n const fixedH = container.fixed === \"size\" || container.fixed === \"height\";\n const w = shape?.w ?? container.w;\n const h = shape?.h ?? container.h;\n if (fixedW && w === undefined) throw new TypeError(`A container with fixed \"${container.fixed}\" needs a width.`);\n if (fixedH && h === undefined) throw new TypeError(`A container with fixed \"${container.fixed}\" needs a height.`);\n return { x: shape?.x ?? 0, y: shape?.y ?? 0, w: fixedW ? w! : Infinity, h: fixedH ? h! : Infinity };\n}\n\n/** One rectangle of the frame, and the item or the obstacle that it measures. */\nexport interface Entry {\n rect: Rect<number>;\n item?: Item;\n obstacle?: Obstacle;\n /** The offset from the corner of the rectangle to the corner of the item or the obstacle. */\n dx: number;\n dy: number;\n}\n\n/** The rectangles of 0.1 for one input. */\nexport interface Frame {\n /** The container coordinates of the origin of the frame. */\n ox: number;\n oy: number;\n /** The size of the area of the frame. A free side has the size `Infinity`. */\n w: number;\n h: number;\n bounds: Bounds;\n inset: number;\n /** The items in the order of their rank, then the obstacles. */\n entries: Entry[];\n /** The ids of the items that are too large for the area. The frame has no rectangle for them. */\n tooLarge: string[];\n}\n\n/** This function gives the items in the order of their rank. The index in the array is the rank of an item without one. */\nexport function byRank(items: readonly Item[]): Item[] {\n return items\n .map((item, index) => ({ item, rank: item.rank ?? index }))\n .toSorted((a, b) => a.rank - b.rank)\n .map((e) => e.item);\n}\n\n/**\n * This function makes the frame of an input. A locked item with a position and an obstacle without `move` are locked\n * rectangles. An obstacle with `move` is a free rectangle only when `movable` is `true`.\n */\nexport function buildFrame(input: PackInput, movable = false): Frame {\n const bounds = containerBounds(input);\n const inset = input.container.inset ?? 0;\n const half = (input.gap ?? 0) / 2;\n const ox = bounds.x + inset - half;\n const oy = bounds.y + inset - half;\n const w = bounds.w - 2 * inset + 2 * half;\n const h = bounds.h - 2 * inset + 2 * half;\n const entries: Entry[] = [];\n const tooLarge: string[] = [];\n\n for (const item of byRank(input.items)) {\n const m = marginOf(item);\n const rect = new Rect<number>();\n rect.size.set(item.w + m.left + m.right + 2 * half, item.h + m.top + m.bottom + 2 * half);\n const dx = m.left + half;\n const dy = m.top + half;\n if (item.locked === true && item.x !== undefined && item.y !== undefined) {\n rect.locked = true;\n rect.position.set(item.x - dx - ox, item.y - dy - oy);\n } else if (rect.size.x > w + EPS || rect.size.y > h + EPS) {\n tooLarge.push(item.id);\n continue;\n }\n entries.push({ rect, item, dx, dy });\n }\n\n for (const obstacle of input.obstacles ?? []) {\n const b = boundsOf(obstacle.region);\n const rect = new Rect<number>();\n rect.size.set(b.w + 2 * half, b.h + 2 * half);\n rect.position.set(b.x - half - ox, b.y - half - oy);\n rect.locked = !(movable && obstacle.move !== undefined);\n entries.push({ rect, obstacle, dx: half, dy: half });\n }\n return { ox, oy, w, h, bounds, inset, entries, tooLarge };\n}\n\n/** This function gives the outer rectangle of 0.1 for a frame. A free height starts at 0 and grows. */\nexport function outerOf(frame: Frame): Rect<number> {\n const outer = new Rect<number>();\n const fixedSize = Number.isFinite(frame.h);\n outer.size.set(frame.w, fixedSize ? frame.h : 0);\n outer.fixedWidth = true;\n outer.fixedSize = fixedSize;\n return outer;\n}\n\n/** This function gives the rectangles of a frame, in the order of the entries. */\nexport function rectsOf(frame: Frame): Rect<number>[] {\n return frame.entries.map((e) => e.rect);\n}\n\n/**\n * This function reads the output from the rectangles of a frame after a packing of 0.1. A locked item keeps its\n * position exactly. Each other item that the packer did not place goes to the overflow.\n */\nexport function readFrame(input: PackInput, frame: Frame, trace: StageTrace[], moved: PackOutput[\"moved\"] = []): PackOutput {\n const placements: Placement[] = [];\n const overflow: string[] = [...frame.tooLarge];\n for (const e of frame.entries) {\n const item = e.item;\n if (item === undefined) continue;\n if (item.locked === true && item.x !== undefined && item.y !== undefined) placements.push({ id: item.id, x: item.x, y: item.y });\n else if (e.rect.wasPacked) placements.push({ id: item.id, x: e.rect.position.x + e.dx + frame.ox, y: e.rect.position.y + e.dy + frame.oy });\n else overflow.push(item.id);\n }\n return { placements, overflow, size: sizeOf(input, frame, placements, moved), moved, trace };\n}\n\n/**\n * This function gives the size of the container after a packing. A fixed side keeps its size. A free side goes to the\n * far edge of the items with their margins and the inset, or of the obstacles.\n */\nfunction sizeOf(input: PackInput, frame: Frame, placements: Placement[], moved: PackOutput[\"moved\"]): { w: number; h: number } {\n const items = new Map(input.items.map((i) => [i.id, i]));\n let right = 0;\n let bottom = 0;\n for (const p of placements) {\n const item = items.get(p.id)!;\n const m = marginOf(item);\n right = Math.max(right, p.x + item.w + m.right + frame.inset - frame.bounds.x);\n bottom = Math.max(bottom, p.y + item.h + m.bottom + frame.inset - frame.bounds.y);\n }\n const movedById = new Map(moved.map((m) => [m.id, m]));\n for (const o of input.obstacles ?? []) {\n const b = boundsOf(o.region);\n const at = movedById.get(o.id) ?? b;\n right = Math.max(right, at.x + b.w - frame.bounds.x);\n bottom = Math.max(bottom, at.y + b.h - frame.bounds.y);\n }\n return {\n w: Number.isFinite(frame.bounds.w) ? frame.bounds.w : right,\n h: Number.isFinite(frame.bounds.h) ? frame.bounds.h : bottom,\n };\n}\n\n/** This function gives a region with the axes changed: x for y, and w for h. */\nexport function transposeRegion(region: Region): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: region.y, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { kind: \"circle\", cx: region.cy, cy: region.cx, r: region.r };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const swap = (ring: [number, number][]): [number, number][] => ring.map(([x, y]) => [y, x]);\n const turned: Region = { kind: \"polygon\", points: swap(region.points) };\n if (region.holes) turned.holes = region.holes.map(swap);\n return turned;\n }\n }\n}\n\n/** This function gives an item with the axes changed. The ports go, because the adapters of 0.1 do not read them. */\nfunction transposeItem(item: Item): Item {\n const { ports: _ports, ...rest } = item;\n const turned: Item = { ...rest, w: item.h, h: item.w };\n delete turned.x;\n delete turned.y;\n if (item.y !== undefined) turned.x = item.y;\n if (item.x !== undefined) turned.y = item.x;\n if (item.shape) turned.shape = transposeRegion(item.shape);\n if (item.margin !== undefined && typeof item.margin !== \"number\") {\n const m = item.margin;\n turned.margin = { top: m.left, right: m.bottom, bottom: m.right, left: m.top };\n }\n return turned;\n}\n\n/** This function gives an input with the axes changed. A fixed height becomes a fixed width. */\nexport function transposeInput(input: PackInput): PackInput {\n const c = input.container;\n const container: PackInput[\"container\"] = { fixed: c.fixed === \"height\" ? \"width\" : c.fixed === \"width\" ? \"height\" : c.fixed };\n if (c.h !== undefined) container.w = c.h;\n if (c.w !== undefined) container.h = c.w;\n if (c.aspect !== undefined) container.aspect = 1 / c.aspect;\n if (c.aspectWeight !== undefined) container.aspectWeight = c.aspectWeight;\n if (c.shape !== undefined) container.shape = transposeRegion(c.shape);\n if (c.inset !== undefined) container.inset = c.inset;\n const turned: PackInput = { container, items: input.items.map(transposeItem) };\n if (input.obstacles) turned.obstacles = input.obstacles.map((o) => ({ ...o, region: transposeRegion(o.region) }));\n if (input.gap !== undefined) turned.gap = input.gap;\n return turned;\n}\n\n/** This function gives an output with the axes changed. */\nexport function transposeOutput(output: PackOutput): PackOutput {\n return {\n placements: output.placements.map((p) => ({ ...p, x: p.y, y: p.x })),\n overflow: [...output.overflow],\n size: { w: output.size.h, h: output.size.w },\n moved: output.moved.map((m) => ({ id: m.id, x: m.y, y: m.x })),\n trace: output.trace,\n };\n}\n\n/**\n * This function packs an input with a fixed height through the turn of the axes. It changes x for y in the input.\n * Then it packs with a fixed width, and changes the axes of the output back.\n */\nexport function viaAxes(input: PackInput, previous: PackOutput | undefined, run: (turned: PackInput, previous: PackOutput | undefined) => PackOutput): PackOutput {\n const start = now();\n const turned = transposeInput(input);\n const inner = run(turned, previous === undefined ? undefined : transposeOutput(previous));\n const output = transposeOutput(inner);\n output.trace = [{ id: \"axes\", ms: now() - start, measures: {} }, ...inner.trace];\n return output;\n}\n","// The adapters of 0.1 (docs/PACKER.md): each function of 0.1 runs behind the Packer interface as a strategy.\n\nimport { EPS, type PackInput, type PackOutput } from \"./contract.ts\";\nimport { boundsOf, buildFrame, now, outerOf, readFrame, rectsOf, viaAxes, type Entry } from \"./frame.ts\";\nimport { packFree } from \"./free.ts\";\nimport type { SortOrder } from \"./order.ts\";\nimport { pack } from \"./pack.ts\";\nimport { pushCascade } from \"./push.ts\";\nimport { Rect } from \"./rect.ts\";\nimport { packSkyline } from \"./skyline.ts\";\nimport { assertSupported, cellOf, UnsupportedCell, type PackContext, type SizeSearch, type Strategy, type Supports } from \"./strategy.ts\";\n\n/** The options of the strategies `rows`, `skyline` and `shelf`. */\nexport interface LayoutStrategyOptions {\n /** The order of the items before the packing. The items are in the order of their rank first. */\n sortOrder: SortOrder;\n /** The number of widths that the first pass of the size search `log-sweep` tries. */\n samples: number;\n}\n\n/** The options of the strategy `push`. */\nexport interface PushStrategyOptions {\n /** The order of the items that the cascade does not place. */\n sortOrder: SortOrder;\n /** The most shoves for each item. The cascade stops at this limit. */\n maxShovesPerItem: number;\n}\n\n/** The cells of `rows`, `skyline` and `shelf`, without the movement of the obstacles. */\nconst LAYOUT_CELLS = {\n containerSize: [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"],\n containerShape: [\"rect\"],\n itemShape: [\"rect\"],\n rotation: [\"none\"],\n groups: [\"none\"],\n mode: [\"offline\"],\n} as const satisfies Partial<Supports>;\n\n/** This function makes the supports of a strategy, with copies of each list. */\nfunction supportsOf(cells: { [D in keyof Supports]: readonly Supports[D][number][] }): Supports {\n return {\n containerSize: [...cells.containerSize],\n containerShape: [...cells.containerShape],\n obstacleMove: [...cells.obstacleMove],\n itemShape: [...cells.itemShape],\n rotation: [...cells.rotation],\n order: [...cells.order],\n groups: [...cells.groups],\n mode: [...cells.mode],\n };\n}\n\n/** This function packs an input with a fixed size or a fixed width with one strategy of `pack`. */\nfunction packFixedWidth(id: \"rows\" | \"skyline\" | \"shelf\", input: PackInput, options: LayoutStrategyOptions): PackOutput {\n const start = now();\n const frame = buildFrame(input);\n const rects = rectsOf(frame);\n if (frame.w > 0) pack(rects, outerOf(frame), { strategy: id, sortOrder: options.sortOrder });\n const output = readFrame(input, frame, []);\n output.trace.push({ id, ms: now() - start, measures: { \"pack.overflow\": output.overflow.length } });\n return output;\n}\n\n/** This function makes the strategy of one function of `pack`. */\nfunction layoutStrategy(\n id: \"rows\" | \"skyline\" | \"shelf\",\n family: string,\n catalog: string[],\n cells: Pick<Supports, \"obstacleMove\" | \"order\">,\n): Strategy<LayoutStrategyOptions> {\n const self: Strategy<LayoutStrategyOptions> = {\n id,\n family,\n catalog,\n supports: supportsOf({ ...LAYOUT_CELLS, ...cells }),\n defaults: { sortOrder: \"height-desc\", samples: 48 },\n deterministic: true,\n pack(input, options, context) {\n assertSupported(self.supports, input);\n const o = { ...self.defaults, ...options };\n switch (input.container.fixed) {\n case \"height\":\n return viaAxes(input, context.previous, (turned) => packFixedWidth(id, turned, o));\n case \"none\":\n return logSweep.search(input, self, context, o);\n default:\n return packFixedWidth(id, input, o);\n }\n },\n };\n return self;\n}\n\n/**\n * The strategy `rows` uses `packRows`: a guillotine row packing with a recursive gap fill. It supports no obstacle and\n * no locked item, because `packRows` does not go around them. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const rows: Strategy<LayoutStrategyOptions> = layoutStrategy(\"rows\", \"shelf\", [\"rows-gap-fill\", \"rows-input\"], {\n obstacleMove: [],\n order: [\"free\", \"soft\", \"hard\"],\n});\n\n/**\n * The strategy `skyline` uses `packSkyline`: each item goes to the lowest place where it fits. It packs around the\n * locked items and the fixed obstacles. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const skyline: Strategy<LayoutStrategyOptions> = layoutStrategy(\"skyline\", \"skyline\", [\"skyline-bl\"], {\n obstacleMove: [\"fixed\"],\n order: [\"free\", \"soft\"],\n});\n\n/**\n * The strategy `shelf` uses `packShelf`: rows filled left to right, around the locked items and the fixed obstacles.\n * With the sort order `input`, the rows keep the rank order. Turnable items, groups and shapes throw `UnsupportedCell`.\n */\nexport const shelf: Strategy<LayoutStrategyOptions> = layoutStrategy(\"shelf\", \"shelf\", [\"shelf-nf\", \"shelf-nfdh\"], {\n obstacleMove: [\"fixed\"],\n order: [\"free\", \"soft\", \"hard\"],\n});\n\n/**\n * The size search `log-sweep` uses `packFree` of 0.1.2: widths on a log scale, then the widths near the best width. It\n * wraps `rows`, `skyline` and `shelf`. The objective is the area of the frame times `1 + aspectWeight * aspectError`.\n */\nexport const logSweep: SizeSearch = {\n id: \"log-sweep\",\n search(input: PackInput, inner: Strategy, context: PackContext, options?: unknown): PackOutput {\n if (input.container.fixed !== \"none\") return inner.pack(input, options ?? inner.defaults, context);\n const id = inner.id;\n if (id !== \"rows\" && id !== \"skyline\" && id !== \"shelf\") throw new UnsupportedCell(\"containerSize\", cellOf(input).containerSize);\n const o = { ...(inner.defaults as LayoutStrategyOptions), ...(options as Partial<LayoutStrategyOptions> | undefined) };\n const start = now();\n const frame = buildFrame(input);\n const result = packFree(rectsOf(frame), new Rect<number>(), {\n strategy: id,\n sortOrder: o.sortOrder,\n samples: o.samples,\n aspect: input.container.aspect ?? 1,\n aspectWeight: input.container.aspectWeight ?? 1,\n });\n const ms = now() - start;\n const runs = result.tried.length + 1;\n const output = readFrame(input, frame, []);\n output.trace.push(\n { id: \"log-sweep\", ms, measures: { \"pack.search.widths\": result.tried.length, \"pack.search.ms\": ms } },\n { id, ms: ms / runs, measures: { \"pack.overflow\": output.overflow.length } },\n );\n return output;\n },\n};\n\n/** This function tells if the insides of two rectangles overlap by more than `EPS`. */\nfunction overlaps(a: Rect, b: Rect): boolean {\n return (\n Math.min(a.right(), b.right()) - Math.max(a.position.x, b.position.x) > EPS &&\n Math.min(a.bottom(), b.bottom()) - Math.max(a.position.y, b.position.y) > EPS\n );\n}\n\n/** This function packs an input with a fixed size or a fixed width with a push cascade. */\nfunction pushFixedWidth(input: PackInput, options: PushStrategyOptions, previous: PackOutput | undefined): PackOutput {\n const start = now();\n const frame = buildFrame(input, true);\n const before = new Map(previous?.placements.map((p) => [p.id, p]));\n const positioned: Entry[] = [];\n const pending: Entry[] = [];\n const obstacles = frame.entries.filter((e) => e.obstacle !== undefined);\n const starts = new Map(obstacles.map((e) => [e, { x: e.rect.position.x, y: e.rect.position.y }]));\n const lockedItems = frame.entries.filter((e) => e.item !== undefined && e.rect.locked);\n\n for (const e of frame.entries) {\n const item = e.item;\n if (item === undefined || e.rect.locked) continue;\n const x = item.x ?? before.get(item.id)?.x;\n const y = item.y ?? before.get(item.id)?.y;\n if (x === undefined || y === undefined) {\n pending.push(e);\n continue;\n }\n e.rect.position.set(x - e.dx - frame.ox, y - e.dy - frame.oy);\n positioned.push(e);\n }\n\n // The cascade: each item in the order of its rank pushes the others, and then it stays\n const inPlay = frame.entries.filter((e) => !pending.includes(e)).map((e) => e.rect);\n const maxShoves = options.maxShovesPerItem * Math.max(1, inPlay.length);\n for (const e of positioned) {\n pushCascade(e.rect, inPlay, { gap: 0, maxShoves });\n e.rect.locked = true;\n }\n\n // An obstacle that the cascade pushed out of the container or onto a locked item goes back to its start\n const { bounds } = frame;\n const moved: PackOutput[\"moved\"] = [];\n for (const e of obstacles) {\n const startAt = starts.get(e)!;\n const x = e.rect.position.x + e.dx + frame.ox;\n const y = e.rect.position.y + e.dy + frame.oy;\n const b = boundsOf(e.obstacle!.region);\n const out = x < bounds.x - EPS || y < bounds.y - EPS || x + b.w > bounds.x + bounds.w + EPS || y + b.h > bounds.y + bounds.h + EPS;\n if (out || lockedItems.some((l) => overlaps(l.rect, e.rect))) e.rect.position.set(startAt.x, startAt.y);\n else if (Math.abs(e.rect.position.x - startAt.x) > EPS || Math.abs(e.rect.position.y - startAt.y) > EPS) moved.push({ id: e.obstacle!.id, x, y });\n }\n const pushMs = now() - start;\n\n // Each item that is out of the area or overlaps a kept rectangle goes to the skyline, around the kept rectangles\n const kept = [...obstacles, ...lockedItems].map((e) => e.rect);\n for (const e of positioned) {\n const r = e.rect;\n const inside = r.position.x >= -EPS && r.position.y >= -EPS && r.right() <= frame.w + EPS && r.bottom() <= frame.h + EPS;\n if (inside && !kept.some((k) => overlaps(k, r))) kept.push(r);\n else pending.push(e);\n }\n const skylineStart = now();\n for (const r of kept) {\n r.locked = true;\n r.wasPacked = true;\n }\n if (pending.length > 0 && frame.w > 0) {\n for (const e of pending) {\n e.rect.locked = false;\n e.rect.wasPacked = false;\n }\n packSkyline([...pending.map((e) => e.rect), ...kept], outerOf(frame), { sortOrder: options.sortOrder });\n }\n const output = readFrame(input, frame, [], moved);\n output.trace.push(\n { id: \"push\", ms: pushMs, measures: { \"pack.push.moved\": moved.length } },\n { id: \"skyline\", ms: now() - skylineStart, measures: { \"pack.push.replaced\": pending.length, \"pack.overflow\": output.overflow.length } },\n );\n return output;\n}\n\n/**\n * The strategy `push` uses `pushCascade`. Each item starts at its `x` and `y`, or at its place in `context.previous`.\n * Each item in rank order pushes the items and the movable obstacles that it overlaps. Then `packSkyline` places the\n * items with no start, and the items that still overlap. The output tells each obstacle that moved.\n */\nexport const push: Strategy<PushStrategyOptions> = {\n id: \"push\",\n family: \"incremental\",\n catalog: [\"incremental-push\"],\n supports: supportsOf({\n containerSize: [\"fixed\", \"freeHeight\", \"freeWidth\"],\n containerShape: [\"rect\"],\n obstacleMove: [\"fixed\", \"free\"],\n itemShape: [\"rect\"],\n rotation: [\"none\"],\n order: [\"free\", \"soft\"],\n groups: [\"none\"],\n mode: [\"incremental\"],\n }),\n defaults: { sortOrder: \"height-desc\", maxShovesPerItem: 8 },\n deterministic: true,\n pack(input, options, context) {\n assertSupported(push.supports, input);\n const o = { ...push.defaults, ...options };\n if (input.container.fixed === \"height\") return viaAxes(input, context.previous, (turned, previous) => pushFixedWidth(turned, o, previous));\n return pushFixedWidth(input, o, context.previous);\n },\n};\n","import type { Item, PackInput, PackOutput } from \"./contract.ts\";\nimport type { Rect } from \"./rect.ts\";\n\n/**\n * This function makes a `PackInput` from the `Rect` objects of 0.1. The id of each item is the index of its rectangle.\n *\n * - `fixedSize` gives `fixed` set to `size`, `fixedWidth` gives `width`, and an outer rectangle without them gives `none`.\n * - A locked rectangle gives a locked item at its position.\n * - An outer rectangle at a position other than 0, 0 gives a rectangle shape at that position.\n */\nexport function fromRects<T>(rects: readonly Rect<T>[], outer: Rect<T>): PackInput {\n const fixed = outer.fixedSize ? \"size\" : outer.fixedWidth ? \"width\" : \"none\";\n const container: PackInput[\"container\"] = { fixed };\n if (fixed !== \"none\") container.w = outer.size.x;\n if (fixed === \"size\") container.h = outer.size.y;\n if (outer.position.x !== 0 || outer.position.y !== 0) {\n container.shape = { kind: \"rect\", x: outer.position.x, y: outer.position.y, w: outer.size.x, h: outer.size.y };\n }\n const items = rects.map((r, i): Item => {\n const item: Item = { id: String(i), w: r.size.x, h: r.size.y };\n if (r.locked) {\n item.locked = true;\n item.x = r.position.x;\n item.y = r.position.y;\n }\n return item;\n });\n return { container, items };\n}\n\n/**\n * This function writes an output back into the `Rect` objects of `fromRects`. It sets the position and `wasPacked` of\n * each rectangle, and the free sides of the outer rectangle. It gives the outer rectangle.\n */\nexport function toRects<T>(output: PackOutput, rects: Rect<T>[], outer: Rect<T>): Rect<T> {\n const placements = new Map(output.placements.map((p) => [p.id, p]));\n for (const [i, r] of rects.entries()) {\n const p = placements.get(String(i));\n if (p === undefined) {\n r.wasPacked = r.locked;\n continue;\n }\n r.position.set(p.x, p.y);\n r.wasPacked = true;\n }\n if (!outer.fixedSize) {\n if (!outer.fixedWidth) outer.size.x = output.size.w;\n outer.size.y = output.size.h;\n }\n return outer;\n}\n","import { push, rows, shelf, skyline } from \"./adapters.ts\";\nimport type { PackInput, PackOutput } from \"./contract.ts\";\nimport { createContext, type Strategy } from \"./strategy.ts\";\n\n/** Each strategy of the package. The benchmark starts each one on each input of the corpus. */\nexport const strategies: readonly Strategy[] = Object.freeze([rows, skyline, shelf, push] as Strategy[]);\n\n/** This function gives the strategy with an id. It throws a `RangeError` for an id that the registry does not have. */\nexport function strategy(id: string): Strategy {\n const found = strategies.find((s) => s.id === id);\n if (found === undefined) throw new RangeError(`The registry has no strategy \"${id}\".`);\n return found;\n}\n\n/**\n * This function packs an input with the strategy of an id. The options go over the defaults of the strategy. The\n * context gets `mulberry32` with the seed. The default seed is 0.\n */\nexport function packWith(id: string, input: PackInput, options?: unknown, seed = 0): PackOutput {\n const s = strategy(id);\n const merged: unknown = { ...(s.defaults as object), ...(options as object | undefined) };\n return s.pack(input, merged, createContext(seed));\n}\n","import { DEFAULT_TOLERANCE, marginOf, RECORD_EPS, turnItem, type Item, type PackInput, type PackOutput, type Tolerance } from \"./contract.ts\";\nimport { boundsOf } from \"./frame.ts\";\n\n/** The count of the breaks of each hard rule of the packer (`docs/FORMAT.md`). A good run has 0 for each rule. */\nexport interface HardBreaks {\n \"no-overlap\": number;\n \"in-container\": number;\n \"locked-kept\": number;\n complete: number;\n}\n\n/** A box with its margin: the left, top, right and bottom edges. */\ninterface Box {\n l: number;\n t: number;\n r: number;\n b: number;\n}\n\n/** This function tells if the insides of two boxes overlap by more than a tolerance on each axis. */\nfunction overlap(a: Box, b: Box, tolerance: number): boolean {\n return Math.min(a.r, b.r) - Math.max(a.l, b.l) > tolerance && Math.min(a.b, b.b) - Math.max(a.t, b.t) > tolerance;\n}\n\n/**\n * This function counts the breaks of the 4 hard rules of the packer for an output.\n *\n * - `no-overlap`: each pair of items with their margins, and each pair of an item and an obstacle, that overlap by more than `tolerance.overlap`.\n * - `in-container`: each item with its margin that goes out of a fixed side by more than `tolerance.overlap`. The inset of\n * the container makes each fixed side smaller (decision 3 of `docs/PACKER.md`).\n * - `locked-kept`: each locked item that moved by more than `RECORD_EPS`, or that has no position.\n * - `complete`: each item with no position that is not in the overflow.\n *\n * The rules read a shape of the container, of an obstacle or of an item as its bounding box (decision 5). The bounding box\n * of an item shape is relative to the position of the item. The result has no tolerance in it.\n */\nexport function checkHard(input: PackInput, output: PackOutput, tolerance: Pick<Tolerance, \"overlap\"> = DEFAULT_TOLERANCE): HardBreaks {\n const tol = tolerance.overlap;\n const placements = new Map<string, PackOutput[\"placements\"][number]>();\n for (const p of output.placements) if (!placements.has(p.id)) placements.set(p.id, p);\n const overflow = new Set(output.overflow);\n const breaks: HardBreaks = { \"no-overlap\": 0, \"in-container\": 0, \"locked-kept\": 0, complete: 0 };\n\n const boxes: Box[] = [];\n for (const item of input.items) {\n const p = placements.get(item.id);\n if (p === undefined) {\n if (item.locked === true && item.x !== undefined && item.y !== undefined) breaks[\"locked-kept\"] += 1;\n if (!overflow.has(item.id)) breaks.complete += 1;\n continue;\n }\n if (item.locked === true && item.x !== undefined && item.y !== undefined) {\n if (Math.abs(p.x - item.x) > RECORD_EPS || Math.abs(p.y - item.y) > RECORD_EPS) breaks[\"locked-kept\"] += 1;\n }\n const placed: Item = p.turn === 90 ? turnItem(item) : item;\n const m = marginOf(placed);\n const area = placed.shape === undefined ? { x: 0, y: 0, w: placed.w, h: placed.h } : boundsOf(placed.shape);\n const l = p.x + area.x;\n const t = p.y + area.y;\n boxes.push({ l: l - m.left, t: t - m.top, r: l + area.w + m.right, b: t + area.h + m.bottom });\n }\n\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const obstacles: Box[] = (input.obstacles ?? []).map((o) => {\n const b = boundsOf(o.region);\n const at = moved.get(o.id) ?? b;\n return { l: at.x, t: at.y, r: at.x + b.w, b: at.y + b.h };\n });\n\n for (const [i, a] of boxes.entries()) {\n for (let j = i + 1; j < boxes.length; j++) if (overlap(a, boxes[j]!, tol)) breaks[\"no-overlap\"] += 1;\n for (const o of obstacles) if (overlap(a, o, tol)) breaks[\"no-overlap\"] += 1;\n }\n\n const { container } = input;\n const shape = container.shape === undefined ? undefined : boundsOf(container.shape);\n const x = shape?.x ?? 0;\n const y = shape?.y ?? 0;\n const w = shape?.w ?? container.w ?? Infinity;\n const h = shape?.h ?? container.h ?? Infinity;\n const inset = container.inset ?? 0;\n const fixedW = container.fixed === \"size\" || container.fixed === \"width\";\n const fixedH = container.fixed === \"size\" || container.fixed === \"height\";\n for (const box of boxes) {\n const outX = fixedW && (box.l < x + inset - tol || box.r > x + w - inset + tol);\n const outY = fixedH && (box.t < y + inset - tol || box.b > y + h - inset + tol);\n if (outX || outY) breaks[\"in-container\"] += 1;\n }\n return breaks;\n}\n","// The seeded generators of the corpus (`docs/FORMAT.md`, \"The generators\"). Each generator is a pipeline of 3 steps: the\n// container, then the obstacles, then the boxes. Each step has its own random numbers: `mulberry32` of\n// `fnv1a32(\"<seed>:<step>\")`. Thus a packing input and a routing input with the same seed get the same obstacles.\n\nimport type { Container, Item, Obstacle, Region } from \"./contract.ts\";\nimport {\n countCell,\n fnv1a32,\n hashInput,\n round3,\n type CorpusCell,\n type GeneratorParams,\n type LayoutInput,\n type ObstacleLayout,\n type SizeDistribution,\n} from \"./layout-input.ts\";\nimport { mulberry32, type DimensionValue } from \"./strategy.ts\";\n\n/** The largest count of boxes that a generator makes. */\nconst MAX_COUNT = 100_000;\n\n/** A seeded generator of `layout-input/1` files. The same version, parameters and seed give the same file, byte for byte. */\nexport interface CorpusGenerator<P extends GeneratorParams = GeneratorParams> {\n /** The name. The file writes it in `generator.name`. */\n readonly name: string;\n /** The version. A change of the output of a generator needs a new version. */\n readonly version: number;\n /** The default set of an input, when the call gives no set. */\n readonly set: string;\n /** The default parameters. */\n readonly defaults: Readonly<P>;\n /** For each parameter with a list of values, the values that the generator accepts. */\n readonly values: { readonly [K in keyof P]?: readonly P[K][] };\n /** This method gives the full parameters: the defaults with the given parameters over them. It throws a `RangeError` for a bad parameter. */\n withDefaults(params?: Partial<P>): P;\n /** This method gives the cell of each input of the parameters. The cell does not depend on the seed. */\n cell(params?: Partial<P>): CorpusCell;\n /** This method gives the input file of a seed. The `id` is `<set>/<family>/s<seed>`. */\n generate(seed: number, params?: Partial<P>, set?: string): LayoutInput;\n}\n\n/** The parts of a file that a generator makes. */\ntype Parts = Pick<LayoutInput, \"container\" | \"boxes\"> & { obstacles: Obstacle[] };\n\n/** The data of a generator, before `defineGenerator` adds the common steps. */\ninterface GeneratorSpec<P extends GeneratorParams> {\n name: string;\n version: number;\n set: string;\n defaults: P;\n values: { readonly [K in keyof P]?: readonly P[K][] };\n family(params: P): string;\n cell(params: P): CorpusCell;\n build(seed: number, params: P): Parts;\n}\n\n/** A rectangle area in which the obstacles and the sizes of the boxes are made. */\ninterface Frame {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** This function gives the random numbers of one step of a seed. */\nconst stepRandom = (seed: number, step: string): (() => number) => mulberry32(fnv1a32(`${seed}:${step}`));\n\n/** A whole number from lo to hi, both included. */\nconst int = (r: () => number, lo: number, hi: number): number => lo + Math.floor(r() * (hi - lo + 1));\n\n/** A whole number from the floor of lo to the floor of hi, both included. The upper end is not less than the lower end at any time. */\nconst span = (r: () => number, lo: number, hi: number): number => {\n const a = Math.floor(lo);\n return int(r, a, Math.max(a, Math.floor(hi)));\n};\n\n/** A number from lo to hi. */\nconst between = (r: () => number, lo: number, hi: number): number => lo + r() * (hi - lo);\n\n/** This function gives an index with a probability in proportion to its weight. */\nconst pick = (r: () => number, weights: readonly number[]): number => {\n let x = r() * weights.reduce((a, b) => a + b, 0);\n for (const [i, w] of weights.entries()) {\n x -= w;\n if (x < 0) return i;\n }\n return weights.length - 1;\n};\n\n/** This function gives a copy of a value with each number rounded by `round3`. A key with the value `undefined` goes. */\nfunction roundNumbers<T>(value: T): T {\n if (typeof value === \"number\") return round3(value) as T;\n if (Array.isArray(value)) return value.map(roundNumbers) as T;\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) if (v !== undefined) out[k] = roundNumbers(v);\n return out as T;\n }\n return value;\n}\n\n/** This function gives the cell of an input with rectangle items, no rotation, no order and no groups. */\nfunction cellWith(\n containerSize: DimensionValue<\"containerSize\">,\n containerShape: DimensionValue<\"containerShape\">,\n obstacles: ObstacleLayout,\n sizes: SizeDistribution,\n count: number,\n locked = false,\n): CorpusCell {\n const cell: CorpusCell = {\n containerSize,\n containerShape,\n itemShape: \"rect\",\n rotation: \"none\",\n order: \"free\",\n groups: \"none\",\n obstacles,\n sizes,\n count: countCell(count),\n mode: \"offline\",\n };\n if (obstacles !== \"none\" || locked) cell.obstacleMove = \"fixed\";\n return cell;\n}\n\n/** This function makes a generator from its data. It adds the defaults, the checks, the stamp, the rounding and the hash. */\nfunction defineGenerator<P extends GeneratorParams>(spec: GeneratorSpec<P>): CorpusGenerator<P> {\n const withDefaults = (params: Partial<P> = {}): P => {\n const full: GeneratorParams = { ...spec.defaults };\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined) continue;\n if (!(key in spec.defaults)) throw new RangeError(`The generator \"${spec.name}\" has no parameter \"${key}\".`);\n full[key] = value;\n }\n for (const [key, allowed] of Object.entries(spec.values) as [string, readonly (string | number)[] | undefined][]) {\n if (allowed !== undefined && !allowed.includes(full[key]!)) {\n throw new RangeError(`The parameter \"${key}\" of the generator \"${spec.name}\" has no value \"${String(full[key])}\".`);\n }\n }\n const count = full[\"count\"];\n if (count !== undefined && (typeof count !== \"number\" || !Number.isInteger(count) || count < 0 || count > MAX_COUNT)) {\n throw new RangeError(`The parameter \"count\" of the generator \"${spec.name}\" is a whole number from 0 to ${MAX_COUNT}.`);\n }\n return full as P;\n };\n\n return Object.freeze({\n name: spec.name,\n version: spec.version,\n set: spec.set,\n defaults: Object.freeze({ ...spec.defaults }),\n values: spec.values,\n withDefaults,\n cell: (params?: Partial<P>): CorpusCell => spec.cell(withDefaults(params)),\n generate(seed: number, params?: Partial<P>, set: string = spec.set): LayoutInput {\n if (!Number.isInteger(seed) || seed < 0) throw new RangeError(`The seed is a whole number from 0. It is ${seed}.`);\n const full = withDefaults(params);\n const family = spec.family(full);\n const { container, obstacles, boxes } = spec.build(seed, full);\n const file: Omit<LayoutInput, \"hash\"> = roundNumbers({\n schema: \"layout-input/1\" as const,\n id: `${set}/${family}/s${seed}`,\n set,\n family,\n seed,\n source: \"made-up\",\n generator: { name: spec.name, version: spec.version, params: full, seed },\n container,\n obstacles,\n boxes,\n edges: [],\n });\n return { ...file, hash: hashInput(file) };\n },\n });\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The shared generator `rect-scattered` (version 1). `docs/FORMAT.md` gives it step by step. Do not change its output.\n\n/** The parameters of `rect-scattered`. */\nexport type RectScatteredParams = { count: number };\n\n/** The shared generator `rect-scattered` of `docs/FORMAT.md`, version 1: rectangle obstacles at random places in a fixed rectangle. */\nexport const rectScattered: CorpusGenerator<RectScatteredParams> = defineGenerator<RectScatteredParams>({\n name: \"rect-scattered\",\n version: 1,\n set: \"xcheck-v1\",\n defaults: { count: 40 },\n values: {},\n family: () => \"rect-scattered\",\n cell: (p) => cellWith(\"fixed\", \"rect\", \"scattered\", \"uniform\", p.count),\n build(seed, { count }) {\n let r = stepRandom(seed, \"container\");\n const w = int(r, 600, 1000);\n const h = int(r, 400, 800);\n const container: Container = { w, h, fixed: \"size\" };\n\n r = stepRandom(seed, \"obstacles\");\n const n = int(r, 3, 8);\n const obstacles: Obstacle[] = [];\n for (let i = 0; i < n; i++) {\n const ow = int(r, 40, 160);\n const oh = int(r, 40, 160);\n const x = int(r, 0, w - ow);\n const y = int(r, 0, h - oh);\n obstacles.push({ id: `o${i}`, region: { kind: \"rect\", x, y, w: ow, h: oh } });\n }\n\n r = stepRandom(seed, \"boxes\");\n const boxes: Item[] = [];\n for (let i = 0; i < count; i++) {\n const bw = int(r, 20, 120);\n const bh = int(r, 20, 80);\n boxes.push({ id: `b${i}`, w: bw, h: bh });\n }\n return { container, obstacles, boxes };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The steps of `rect-grid` and of the families of a user interface.\n\n/** The values of `containerSize` that the generators make. */\nconst CONTAINER_SIZES = [\"fixed\", \"freeHeight\", \"freeWidth\", \"freeAspect\", \"freeArea\"] as const;\n/** The values of `containerShape`. */\nconst CONTAINER_SHAPES = [\"rect\", \"convex\", \"polygon\", \"circle\", \"ellipse\", \"holes\"] as const;\n/** The values of `obstacles`. */\nconst OBSTACLE_LAYOUTS = [\"none\", \"center\", \"scattered\", \"wall\", \"corridors\", \"touching\", \"edge\"] as const;\n/** The values of `sizes`. */\nconst SIZE_DISTRIBUTIONS = [\"identical\", \"nearIdentical\", \"uniform\", \"heavyTail\", \"bimodal\", \"extremeAspect\"] as const;\n\n/** This function gives the container of a size value for the nominal rectangle `w` by `h`, with an optional shape. */\nfunction containerOf(size: DimensionValue<\"containerSize\">, w: number, h: number, shape?: Region): Container {\n const containers: Record<DimensionValue<\"containerSize\">, Container> = {\n fixed: { w, h, fixed: \"size\" },\n freeHeight: { w, fixed: \"width\" },\n freeWidth: { h, fixed: \"height\" },\n freeAspect: { fixed: \"none\", aspect: round3(w / h) },\n freeArea: { fixed: \"none\", aspectWeight: 0 },\n };\n const container = containers[size];\n if (shape !== undefined) container.shape = shape;\n return container;\n}\n\n/** This function gives the 4 corners of a rectangle, clockwise from the top left. */\nconst corners = (x: number, y: number, w: number, h: number): [number, number][] => [\n [x, y],\n [x + w, y],\n [x + w, y + h],\n [x, y + h],\n];\n\n/**\n * This function gives the shape of a container in the rectangle `w` by `h`, and its frame. The frame is a rectangle in\n * the shape. The obstacles and the sizes of the boxes come from the frame.\n */\nfunction shapeOf(r: () => number, shape: DimensionValue<\"containerShape\">, w: number, h: number): { region?: Region; frame: Frame } {\n const m = Math.min(w, h);\n switch (shape) {\n case \"rect\":\n return { frame: { x: 0, y: 0, w, h } };\n case \"convex\": {\n // A rectangle with its 4 corners cut at 45 degrees\n const [a, b, c, d] = [0, 1, 2, 3].map(() => span(r, m * 0.1, m * 0.25)) as [number, number, number, number];\n const points: [number, number][] = [[a, 0], [w - b, 0], [w, b], [w, h - c], [w - c, h], [d, h], [0, h - d], [0, a]];\n const top = Math.max(a, b);\n const bottom = Math.max(c, d);\n return { region: { kind: \"polygon\", points }, frame: { x: 0, y: top, w, h: h - top - bottom } };\n }\n case \"polygon\": {\n // A rectangle with a notch at the bottom right: an L shape\n const nw = span(r, w * 0.25, w * 0.45);\n const nh = span(r, h * 0.25, h * 0.45);\n const points: [number, number][] = [[0, 0], [w, 0], [w, h - nh], [w - nw, h - nh], [w - nw, h], [0, h]];\n return { region: { kind: \"polygon\", points }, frame: { x: 0, y: 0, w: w - nw, h } };\n }\n case \"circle\": {\n const cx = Math.floor(w / 2);\n const cy = Math.floor(h / 2);\n const radius = Math.min(cx, cy);\n const side = 2 * Math.floor((radius * Math.SQRT2 - 1) / 2);\n return { region: { kind: \"circle\", cx, cy, r: radius }, frame: { x: cx - side / 2, y: cy - side / 2, w: side, h: side } };\n }\n case \"ellipse\": {\n const rx = Math.floor(w / 2);\n const ry = Math.floor(h / 2);\n const a = Math.floor(rx / Math.SQRT2);\n const b = Math.floor(ry / Math.SQRT2);\n return { region: { kind: \"ellipse\", cx: rx, cy: ry, rx, ry }, frame: { x: rx - a, y: ry - b, w: 2 * a, h: 2 * b } };\n }\n case \"holes\": {\n // 1 or 2 rectangle holes, the first in the left half and the second in the right half\n const count = int(r, 1, 2);\n const holes: [number, number][][] = [];\n for (let i = 0; i < count; i++) {\n const hw = span(r, w * 0.08, w * 0.15);\n const hh = span(r, h * 0.1, h * 0.25);\n const x = i === 0 ? span(r, 20, w / 2 - hw - 10) : span(r, w / 2 + 10, w - hw - 20);\n const y = span(r, 20, h - hh - 20);\n holes.push(corners(x, y, hw, hh));\n }\n return { region: { kind: \"polygon\", points: corners(0, 0, w, h), holes }, frame: { x: 0, y: 0, w, h } };\n }\n }\n}\n\n/** This function gives the obstacles of a layout in a frame. Each obstacle is a rectangle with whole-number sides. */\nfunction obstaclesOf(r: () => number, layout: ObstacleLayout, f: Frame): Obstacle[] {\n const m = Math.min(f.w, f.h);\n const rects: { x: number; y: number; w: number; h: number }[] = [];\n switch (layout) {\n case \"none\":\n break;\n case \"center\": {\n const w = span(r, f.w * 0.15, f.w * 0.3);\n const h = span(r, f.h * 0.15, f.h * 0.3);\n const jx = Math.floor(f.w * 0.05);\n const jy = Math.floor(f.h * 0.05);\n rects.push({ x: f.x + Math.floor((f.w - w) / 2) + int(r, -jx, jx), y: f.y + Math.floor((f.h - h) / 2) + int(r, -jy, jy), w, h });\n break;\n }\n case \"scattered\": {\n const n = int(r, 3, 8);\n for (let i = 0; i < n; i++) {\n const w = span(r, m * 0.05, m * 0.2);\n const h = span(r, m * 0.05, m * 0.2);\n rects.push({ x: int(r, f.x, f.x + f.w - w), y: int(r, f.y, f.y + f.h - h), w, h });\n }\n break;\n }\n case \"wall\": {\n // One long, thin obstacle from one side. It leaves a gap at its other end.\n const vertical = r() < 0.5;\n const across = vertical ? f.w : f.h;\n const along = vertical ? f.h : f.w;\n const thick = span(r, Math.max(1, across * 0.03), Math.max(1, across * 0.06));\n const length = span(r, along * 0.7, along * 0.85);\n const at = span(r, across * 0.3, across * 0.7 - thick);\n const from = r() < 0.5 ? 0 : along - length;\n rects.push(vertical ? { x: f.x + at, y: f.y + from, w: thick, h: length } : { x: f.x + from, y: f.y + at, w: length, h: thick });\n break;\n }\n case \"corridors\": {\n // A grid of blocks, with a narrow path between two blocks and between a block and the border\n const cols = int(r, 2, 4);\n const rows = int(r, 2, 3);\n const path = span(r, m * 0.08, m * 0.15);\n const bw = Math.floor((f.w - (cols + 1) * path) / cols);\n const bh = Math.floor((f.h - (rows + 1) * path) / rows);\n for (let j = 0; j < rows; j++) {\n for (let i = 0; i < cols; i++) rects.push({ x: f.x + path + i * (bw + path), y: f.y + path + j * (bh + path), w: bw, h: bh });\n }\n break;\n }\n case \"touching\": {\n // A chain: each obstacle shares a part of a side with the obstacle before it\n const n = int(r, 2, 4);\n let w = span(r, m * 0.08, m * 0.15);\n let h = span(r, m * 0.08, m * 0.15);\n let x = span(r, f.x + f.w * 0.15, f.x + f.w * 0.35);\n let y = span(r, f.y + f.h * 0.15, f.y + f.h * 0.35);\n rects.push({ x, y, w, h });\n for (let i = 1; i < n; i++) {\n const right = r() < 0.5;\n const nw = span(r, m * 0.08, m * 0.15);\n const nh = span(r, m * 0.08, m * 0.15);\n if (right) {\n y = int(r, y, y + Math.floor(h / 2));\n x += w;\n } else {\n x = int(r, x, x + Math.floor(w / 2));\n y += h;\n }\n w = nw;\n h = nh;\n rects.push({ x, y, w, h });\n }\n break;\n }\n case \"edge\": {\n // Each obstacle touches one side of the frame\n const n = int(r, 2, 5);\n for (let i = 0; i < n; i++) {\n const side = int(r, 0, 3);\n const w = span(r, m * 0.06, m * 0.15);\n const h = span(r, m * 0.06, m * 0.15);\n const x = side === 1 ? f.x + f.w - w : side === 3 ? f.x : int(r, f.x, f.x + f.w - w);\n const y = side === 0 ? f.y : side === 2 ? f.y + f.h - h : int(r, f.y, f.y + f.h - h);\n rects.push({ x, y, w, h });\n }\n break;\n }\n }\n return rects.map((rect, i) => ({ id: `o${i}`, region: { kind: \"rect\", ...rect } }));\n}\n\n/**\n * This function gives the boxes of a size distribution for a frame. The mean box has an area of 40 percent of the\n * frame divided by the count. No box is wider or higher than the frame.\n */\nfunction boxesOf(r: () => number, sizes: SizeDistribution, count: number, f: Frame): Item[] {\n const unit = Math.sqrt((f.w * f.h * 0.4) / Math.max(count, 1));\n const fit = (x: number, max: number): number => Math.min(Math.max(round3(x), 0.01), max);\n const boxes: Item[] = new Array<Item>(count);\n const put = (i: number, w: number, h: number): void => {\n boxes[i] = { id: `b${i}`, w: fit(w, f.w), h: fit(h, f.h) };\n };\n switch (sizes) {\n case \"identical\":\n case \"nearIdentical\": {\n const aspect = Math.sqrt(between(r, 0.6, 1.6));\n const bw = unit * aspect;\n const bh = unit / aspect;\n for (let i = 0; i < count; i++) {\n if (sizes === \"identical\") put(i, bw, bh);\n else put(i, bw * (1 + between(r, -0.03, 0.03)), bh * (1 + between(r, -0.03, 0.03)));\n }\n break;\n }\n case \"uniform\":\n for (let i = 0; i < count; i++) put(i, unit * between(r, 0.5, 1.5), unit * between(r, 0.5, 1.5));\n break;\n case \"heavyTail\": {\n // A Pareto distribution with the index 1.6, cut at 60 percent of the frame\n const cap = 0.6 * Math.min(f.w, f.h);\n for (let i = 0; i < count; i++) {\n const s = Math.min(0.6 * unit * (1 - r()) ** (-1 / 1.6), cap);\n put(i, s * between(r, 0.75, 1.33), s * between(r, 0.75, 1.33));\n }\n break;\n }\n case \"bimodal\":\n for (let i = 0; i < count; i++) {\n const s = r() < 0.25 ? 1.8 * unit : 0.6 * unit;\n put(i, s * between(r, 0.85, 1.15), s * between(r, 0.85, 1.15));\n }\n break;\n case \"extremeAspect\":\n for (let i = 0; i < count; i++) {\n const long = unit * between(r, 2.5, 4);\n const short = unit * between(r, 0.15, 0.35);\n if (r() < 0.5) put(i, long, short);\n else put(i, short, long);\n }\n break;\n }\n return boxes;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n// `rect-grid`: one input for each point of the grid of the packer dimensions.\n\n/** The parameters of `rect-grid`: one value for each dimension of the taxonomy that it covers. */\nexport type RectGridParams = {\n containerSize: DimensionValue<\"containerSize\">;\n containerShape: DimensionValue<\"containerShape\">;\n obstacles: ObstacleLayout;\n sizes: SizeDistribution;\n count: number;\n};\n\n/**\n * The generator `rect-grid`, version 1: rectangle boxes for each value of `containerSize`, `containerShape`, `obstacles`\n * and `sizes`, with each count. The container is a nominal rectangle of 600 to 1000 by 400 to 800.\n */\nexport const rectGrid: CorpusGenerator<RectGridParams> = defineGenerator<RectGridParams>({\n name: \"rect-grid\",\n version: 1,\n set: \"corpus-v1\",\n defaults: { containerSize: \"fixed\", containerShape: \"rect\", obstacles: \"none\", sizes: \"uniform\", count: 100 },\n values: { containerSize: CONTAINER_SIZES, containerShape: CONTAINER_SHAPES, obstacles: OBSTACLE_LAYOUTS, sizes: SIZE_DISTRIBUTIONS },\n family: (p) => `rect-grid.${p.containerSize}.${p.containerShape}.${p.obstacles}.${p.sizes}.n${p.count}`,\n cell: (p) => cellWith(p.containerSize, p.containerShape, p.obstacles, p.sizes, p.count),\n build(seed, p) {\n let r = stepRandom(seed, \"container\");\n const w = int(r, 600, 1000);\n const h = int(r, 400, 800);\n const { region, frame } = shapeOf(r, p.containerShape, w, h);\n const container = containerOf(p.containerSize, w, h, region);\n\n r = stepRandom(seed, \"obstacles\");\n const obstacles = obstaclesOf(r, p.obstacles, frame);\n\n r = stepRandom(seed, \"boxes\");\n return { container, obstacles, boxes: boxesOf(r, p.sizes, p.count, frame) };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n// The families of a user interface: gallery, dashboard, cards and word cloud.\n\n/** The parameters of a family of a user interface. */\nexport type UiParams = {\n containerSize: DimensionValue<\"containerSize\">;\n count: number;\n};\n\n/** This function makes the generator of a family of a user interface. The container is 800 to 1400 by 600 to 1000, with no obstacle. */\nfunction uiGenerator(name: string, sizes: SizeDistribution, count: number, boxes: (r: () => number, count: number) => Item[]): CorpusGenerator<UiParams> {\n return defineGenerator<UiParams>({\n name,\n version: 1,\n set: \"corpus-v1\",\n defaults: { containerSize: \"freeHeight\", count },\n values: { containerSize: CONTAINER_SIZES },\n family: (p) => `${name}.${p.containerSize}.n${p.count}`,\n cell: (p) => cellWith(p.containerSize, \"rect\", \"none\", sizes, p.count),\n build(seed, p) {\n const r = stepRandom(seed, \"container\");\n const w = int(r, 800, 1400);\n const h = int(r, 600, 1000);\n return { container: containerOf(p.containerSize, w, h), obstacles: [], boxes: boxes(stepRandom(seed, \"boxes\"), p.count) };\n },\n });\n}\n\n/** The aspects of the thumbnails of a gallery. */\nconst THUMBNAIL_ASPECTS = [1, 4 / 3, 3 / 2, 16 / 9];\n\n/** The generator `gallery`, version 1: thumbnails with one size and one aspect (1, 4:3, 3:2 or 16:9). The default container has a fixed width. */\nexport const gallery: CorpusGenerator<UiParams> = uiGenerator(\"gallery\", \"identical\", 100, (r, count) => {\n const aspect = THUMBNAIL_ASPECTS[int(r, 0, THUMBNAIL_ASPECTS.length - 1)]!;\n const w = int(r, 120, 240);\n return Array.from({ length: count }, (_, i) => ({ id: `b${i}`, w, h: round3(w / aspect) }));\n});\n\n/** The spans of the dashboard tiles in grid units, and their weights. */\nconst TILE_SPANS: readonly [number, number][] = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 2], [4, 2]];\nconst TILE_WEIGHTS = [4, 3, 2, 3, 1, 1];\n\n/** The generator `dashboard`, version 1: tiles in 6 standard sizes, from 1 by 1 to 4 by 2 grid units of 60 to 100. */\nexport const dashboard: CorpusGenerator<UiParams> = uiGenerator(\"dashboard\", \"bimodal\", 10, (r, count) => {\n const unit = int(r, 60, 100);\n return Array.from({ length: count }, (_, i) => {\n const [cw, ch] = TILE_SPANS[pick(r, TILE_WEIGHTS)]!;\n return { id: `b${i}`, w: cw * unit, h: ch * unit };\n });\n});\n\n/** The generator `cards`, version 1: cards with one width from 200 to 320, and a height from 120 to 420 each. */\nexport const cards: CorpusGenerator<UiParams> = uiGenerator(\"cards\", \"uniform\", 100, (r, count) => {\n const w = int(r, 200, 320);\n return Array.from({ length: count }, (_, i) => ({ id: `b${i}`, w, h: int(r, 120, 420) }));\n});\n\n/** The font sizes of a word cloud, and their weights: many small words and few large words. */\nconst FONT_SIZES = [12, 14, 16, 20, 28, 40];\nconst FONT_WEIGHTS = [30, 25, 20, 12, 8, 5];\n\n/** The generator `word-cloud`, version 1: boxes of text. The height comes from 6 font sizes, the width from 3 to 12 letters. */\nexport const wordCloud: CorpusGenerator<UiParams> = uiGenerator(\"word-cloud\", \"heavyTail\", 100, (r, count) =>\n Array.from({ length: count }, (_, i) => {\n const font = FONT_SIZES[pick(r, FONT_WEIGHTS)]!;\n const letters = int(r, 3, 12);\n return { id: `b${i}`, w: round3(letters * font * 0.6), h: round3(font * 1.25) };\n }),\n);\n\n// ---------------------------------------------------------------------------------------------------------------------\n// `edge-cases`: the inputs at the limits.\n\n/** The cases of `edge-cases`. */\nexport type EdgeCase = \"empty\" | \"one\" | \"oversize\" | \"exactTiling\" | \"touchObstacles\";\n\n/** The parameters of `edge-cases`. The cases `empty` and `one` ignore `count`. */\nexport type EdgeCaseParams = { case: EdgeCase; count: number };\n\n/** The values of `case`. */\nconst EDGE_CASES = [\"empty\", \"one\", \"oversize\", \"exactTiling\", \"touchObstacles\"] as const;\n\n/** This function gives the largest divisor of `n` that is not more than the square root of `n`. */\nconst rowsOf = (n: number): number => {\n for (let d = Math.floor(Math.sqrt(n)); d > 1; d--) if (n % d === 0) return d;\n return 1;\n};\n\n/**\n * The generator `edge-cases`, version 1. Each case has a fixed rectangle container.\n *\n * - `empty`: no box.\n * - `one`: one box.\n * - `oversize`: `count` boxes. One box is wider than the container.\n * - `exactTiling`: `count` identical boxes that fill the container with no free space.\n * - `touchObstacles`: a locked box on the top of an obstacle, and boxes as wide as the path between 2 obstacles.\n */\nexport const edgeCases: CorpusGenerator<EdgeCaseParams> = defineGenerator<EdgeCaseParams>({\n name: \"edge-cases\",\n version: 1,\n set: \"corpus-v1\",\n defaults: { case: \"oversize\", count: 12 },\n values: { case: EDGE_CASES },\n family: (p) => (p.case === \"empty\" || p.case === \"one\" ? `edge-cases.${p.case}` : `edge-cases.${p.case}.n${p.count}`),\n cell: (p) => {\n switch (p.case) {\n case \"empty\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", 0);\n case \"one\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", 1);\n case \"oversize\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"heavyTail\", p.count);\n case \"exactTiling\":\n return cellWith(\"fixed\", \"rect\", \"none\", \"identical\", p.count);\n case \"touchObstacles\":\n return cellWith(\"fixed\", \"rect\", \"corridors\", \"uniform\", p.count, true);\n }\n },\n build(seed, p) {\n const needsBoxes = p.case === \"oversize\" || p.case === \"exactTiling\" || p.case === \"touchObstacles\";\n if (needsBoxes && p.count < 1) throw new RangeError(`The case \"${p.case}\" of \"edge-cases\" needs a count of 1 or more.`);\n\n let r = stepRandom(seed, \"container\");\n let w: number;\n let h: number;\n let tile = { w: 0, h: 0, cols: 0, rows: 0 };\n if (p.case === \"exactTiling\") {\n // The container step also picks the size of the tile, because the tiles give the size of the container\n const rows = rowsOf(p.count);\n tile = { w: int(r, 40, 120), h: int(r, 30, 90), cols: p.count / rows, rows };\n w = tile.cols * tile.w;\n h = tile.rows * tile.h;\n } else {\n w = int(r, 600, 1000);\n h = int(r, 400, 800);\n }\n const container: Container = { w, h, fixed: \"size\" };\n\n r = stepRandom(seed, \"obstacles\");\n const obstacles: Obstacle[] = [];\n let path = 0;\n let first = { x: 0, y: 0 };\n if (p.case === \"touchObstacles\") {\n path = int(r, 40, 100);\n const ow = int(r, 60, 150);\n const oh = int(r, 100, 200);\n first = { x: span(r, w * 0.1, w * 0.25), y: span(r, h * 0.2, h * 0.4) };\n obstacles.push({ id: \"o0\", region: { kind: \"rect\", x: first.x, y: first.y, w: ow, h: oh } });\n obstacles.push({ id: \"o1\", region: { kind: \"rect\", x: first.x + ow + path, y: first.y, w: int(r, 60, 150), h: oh } });\n }\n\n r = stepRandom(seed, \"boxes\");\n const boxes: Item[] = [];\n switch (p.case) {\n case \"empty\":\n break;\n case \"one\":\n boxes.push({ id: \"b0\", w: int(r, 40, 200), h: int(r, 30, 150) });\n break;\n case \"oversize\": {\n const big = int(r, 0, p.count - 1);\n for (let i = 0; i < p.count; i++) {\n if (i === big) boxes.push({ id: `b${i}`, w: w + int(r, 10, 200), h: int(r, 40, 100) });\n else boxes.push({ id: `b${i}`, w: int(r, 20, 120), h: int(r, 20, 80) });\n }\n break;\n }\n case \"exactTiling\":\n for (let i = 0; i < p.count; i++) boxes.push({ id: `b${i}`, w: tile.w, h: tile.h });\n break;\n case \"touchObstacles\": {\n const lw = int(r, 30, 80);\n const lh = int(r, 20, 60);\n boxes.push({ id: \"b0\", w: lw, h: lh, x: first.x, y: first.y - lh, locked: true });\n for (let i = 1; i < p.count; i++) boxes.push({ id: `b${i}`, w: path, h: int(r, 20, 80) });\n break;\n }\n }\n return { container, obstacles, boxes };\n },\n});\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/** Each generator of the package. */\nexport const generators: readonly CorpusGenerator[] = Object.freeze([rectScattered, rectGrid, gallery, dashboard, cards, wordCloud, edgeCases] as CorpusGenerator[]);\n\n/** This function gives the generator with a name. It throws a `RangeError` for a name that the package does not have. */\nexport function generator(name: string): CorpusGenerator {\n const found = generators.find((g) => g.name === name);\n if (found === undefined) throw new RangeError(`The package has no generator \"${name}\".`);\n return found;\n}\n","// The manifest of a corpus: `layout-corpus/1` of `docs/FORMAT.md`.\n\nimport { generator } from \"./generators.ts\";\nimport type { CorpusCell, GeneratorParams, LayoutInput } from \"./layout-input.ts\";\n\n/** One spec of a corpus: a generator, its parameters and its seeds. */\nexport interface CorpusSpec {\n /** The name of the generator. */\n generator: string;\n /** The version of the generator. Without it, the spec uses the version of the package. A different version is an error. */\n version?: number;\n /** The parameters over the defaults of the generator. */\n params?: GeneratorParams;\n seeds: readonly number[];\n}\n\n/** One input in the index of a manifest. */\nexport interface CorpusEntry {\n id: string;\n hash: string;\n cell: CorpusCell;\n}\n\n/** The manifest `corpus.json` of a corpus. */\nexport interface CorpusManifest {\n schema: \"layout-corpus/1\";\n /** The name of the corpus. Each input has it in `set`. */\n corpus: string;\n /** The specs, each with its version and its full parameters. */\n specs: { generator: string; version: number; params: GeneratorParams; seeds: number[] }[];\n inputs: CorpusEntry[];\n}\n\n/** A corpus: the manifest and the input files, in the order of the specs and the seeds. */\nexport interface Corpus {\n manifest: CorpusManifest;\n inputs: LayoutInput[];\n}\n\n/**\n * This function generates a corpus from specs. Each input gets the name of the corpus as its set. The function throws a\n * `RangeError` for an unknown generator, a different version or 2 inputs with the same id.\n */\nexport function corpus(name: string, specs: readonly CorpusSpec[]): Corpus {\n const manifest: CorpusManifest = { schema: \"layout-corpus/1\", corpus: name, specs: [], inputs: [] };\n const inputs: LayoutInput[] = [];\n const ids = new Set<string>();\n for (const spec of specs) {\n const gen = generator(spec.generator);\n if (spec.version !== undefined && spec.version !== gen.version) {\n throw new RangeError(`The generator \"${gen.name}\" has the version ${gen.version}, not ${spec.version}.`);\n }\n const params = gen.withDefaults(spec.params);\n const cell = gen.cell(params);\n manifest.specs.push({ generator: gen.name, version: gen.version, params, seeds: [...spec.seeds] });\n for (const seed of spec.seeds) {\n const file = gen.generate(seed, params, name);\n if (ids.has(file.id)) throw new RangeError(`The corpus has 2 inputs with the id \"${file.id}\".`);\n ids.add(file.id);\n inputs.push(file);\n manifest.inputs.push({ id: file.id, hash: file.hash, cell });\n }\n }\n return { manifest, inputs };\n}\n"],"mappings":";;AACA,IAAa,SAAb,MAAa,OAAO;CAClB;CACA;CAEA,YAAY,IAAI,GAAG,IAAI,GAAG;EACxB,KAAK,KAAK;EACV,KAAK,KAAK;CACZ;;CAGA,IAAI,IAAY;EAAE,OAAO,KAAK;CAAI;CAClC,IAAI,EAAE,GAAW;EAAE,KAAK,KAAK;CAAG;;CAEhC,IAAI,IAAY;EAAE,OAAO,KAAK;CAAI;CAClC,IAAI,EAAE,GAAW;EAAE,KAAK,KAAK;CAAG;;CAGhC,IAAI,GAAW,GAAiB;EAC9B,KAAK,KAAK;EACV,KAAK,KAAK;CACZ;;CAGA,MAAM,GAAiB;EACrB,KAAK,KAAK,EAAE;EACZ,KAAK,KAAK,EAAE;CACd;;CAGA,IAAI,OAAuB;EACzB,OAAO,IAAI,OAAO,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,CAAC;CACxD;;CAGA,OAAe;EACb,OAAO,KAAK,KAAK,KAAK;CACxB;;CAGA,QAAgB;EACd,OAAO,IAAI,OAAO,KAAK,IAAI,KAAK,EAAE;CACpC;;CAGA,MAAM,KAAa,KAAqB;EACtC,OAAO,IAAI,OACT,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC,GACxC,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC,CAC1C;CACF;;CAGA,OAAO,GAAG,QAAwB;EAChC,OAAO,IAAI,OAAO,QAAQ,MAAM;CAClC;;CAGA,OAAO,IAAI,SAA2B;EACpC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