@invana/canvas-core 0.0.18 → 0.0.20

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,"sources":["../../src/specs/geometry.ts","../../src/specs/style.ts","../../src/specs/shapeGeometry/polygonMath.ts","../../src/specs/shapeGeometry/tabbedRect.ts","../../src/specs/shapeGeometry/bounds.ts","../../src/specs/shapeGeometry/contains.ts","../../src/specs/shapeGeometry/index.ts","../../src/state/data/flush.ts","../../src/specs/SpecStore.ts"],"names":["TAU"],"mappings":";AA2KO,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,GAAG,UAAS,GAAI,IAAA;AACzC,EAAA,OAAO,IAAA,CAAK,UAAU,QAAQ,CAAA;AAChC;;;ACfO,SAAS,kBAAkB,IAAA,EAAsC;AACtE,EAAA,IAAI,IAAA,KAAS,QAAW,OAAO,KAAA;AAC/B,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA;AACrC,EAAA,MAAM,SAAS,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,IAAA,GAAO,CAAC,IAAsB,CAAA;AACnE,EAAA,OAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,EAAE,IAAA,KAAS,OAAA,IAAW,CAAA,CAAE,IAAA,KAAS,OAAO,CAAA;AACpE;;;AChJO,SAAS,cAAc,QAAA,EAAsC;AAClE,EAAA,IAAI,QAAA,CAAS,MAAA,KAAW,CAAA,EAAG,OAAO,EAAE,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,KAAA,EAAO,CAAA,EAAG,MAAA,EAAQ,CAAA,EAAE;AACpE,EAAA,IAAI,IAAA,GAAO,QAAA,CAAS,CAAC,CAAA,CAAG,CAAA;AACxB,EAAA,IAAI,IAAA,GAAO,IAAA;AACX,EAAA,IAAI,IAAA,GAAO,QAAA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EAAS,CAAC,GAAG,IAAA,CAAK,OAAO,CAAA;AAAA,MACzB,OAAA,EAAS,CAAC,GAAG,IAAA,CAAK,OAAO,CAAA;AAAA,MACzB,OAAA,EAAS,EAAE,IAAA,CAAK;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,MAAM,KAAA,EAAM;AACjB,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,KAAA,MAAW,QAAA,IAAY,IAAA,CAAK,SAAA,EAAW,QAAA,CAAS,KAAK,CAAA;AAAA,EACvD;AAAA,EAEQ,QAAA,GAAiB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAA,IAAa,IAAA,CAAK,SAAA,KAAc,QAAA,EAAU;AACnD,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AACjB,IAAA,IAAA,CAAK,SAAS,aAAA,CAAc,IAAA,CAAK,WAAW,MAAM,IAAA,CAAK,OAAO,CAAA;AAAA,EAChE;AACF","file":"index.js","sourcesContent":["/**\n * Pure geometry — points, rectangles, polylines, paths, and the router / pathStyle\n * function contracts that operate on them. No drawing library appears here.\n *\n * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.\n */\n\n// ─── Geometry primitives ───────────────────────────────────────────────────\n\n// Defined once, in the kernel's geometry vocabulary, and re-exported here so the\n// spec surface stays self-describing. Do not redeclare them — `../geom` is\n// the single home (see the RFC that merged the two definitions:\n// `docs/rfcs/fix/2026-08-10-zustand-imported-outside-canvas-store.md` §4.4).\nexport type { Point, Vec2, Rect, Size } from './geom';\n\nimport type { Point, Vec2, Rect } from './geom';\n\n/** Endpoint anchor a router consumes — point + optional outgoing tangent. */\n\nexport interface Endpoint {\n readonly x: number;\n readonly y: number;\n readonly tangent?: Vec2;\n}\n\n// ─── Polyline (router output, pathStyle input) ─────────────────────────────\n\n/**\n * Flat ordered list of points. Output of a `Router`; input to a `PathStyle`.\n * Also used as the densified form of a `Path` for hit-testing\n * (`samplePath(path)`).\n */\n\nexport type Polyline = ReadonlyArray<Point>;\n\n// ─── Path (pathStyle output, connector input) ──────────────────────────────\n\n/**\n * One step of a `Path`. Mirrors SVG path commands one-for-one:\n * - `M` move to absolute (x, y) — must be the first command of any Path.\n * - `L` line to (x, y) from the current point.\n * - `Q` quadratic Bézier with one control point.\n * - `C` cubic Bézier with two control points.\n *\n * No relative variants, no arcs, no shorthand — pathStyles emit one of these\n * four. Connector renders by walking the path and dispatching to Pixi's\n * `moveTo` / `lineTo` / `quadraticCurveTo` / `bezierCurveTo`.\n */\n\nexport type PathCommand =\n | { readonly kind: 'M'; readonly x: number; readonly y: number }\n | { readonly kind: 'L'; readonly x: number; readonly y: number }\n | { readonly kind: 'Q'; readonly cx: number; readonly cy: number; readonly x: number; readonly y: number }\n | { readonly kind: 'C'; readonly c1x: number; readonly c1y: number; readonly c2x: number; readonly c2y: number; readonly x: number; readonly y: number };\n\nexport type Path = ReadonlyArray<PathCommand>;\n\n/**\n * Read-only scene context handed to routers that need awareness of other\n * shapes — primarily for obstacle-avoidance routing (`manhattan` and\n * friends). Simple geometric routers (`straight`, `orth`) ignore it.\n *\n * `obstacles` are world-space `Rect`s the router should not cross. Each\n * obstacle may also expose `containsInflated` for pixel-accurate silhouette\n * testing (e.g. circles route around their tangent, not their AABB).\n * The renderer auto-collects these from `shapeInstances` (excluding the\n * source/target shapes); callers can override or opt out via\n * `routerOpts.obstacles`.\n */\n\nexport interface RouterCtx {\n readonly obstacles: ReadonlyArray<Obstacle>;\n}\n\n/**\n * Obstacle handed to obstacle-aware routers. `Obstacle extends Rect` so any\n * `Rect[]` is assignable; the optional `containsInflated` callback unlocks\n * silhouette-tight routing for non-rect shapes (circles, polygons, paths).\n */\n\nexport interface Obstacle extends Rect {\n /**\n * Optional silhouette obstacle-test in world coordinates. Returns `true`\n * when `(worldX, worldY)` lies inside the obstacle's silhouette OR within\n * `inflate` world units of it.\n *\n * Routers use this for pixel-accurate marking — when present, the grid\n * blocks only cells that pass this test (in addition to the cheap AABB\n * pre-filter). When absent, the inflated AABB is the source of truth.\n *\n * Shapes opt in by overriding `IShape.obstacleTest`.\n */\n readonly containsInflated?: (worldX: number, worldY: number, inflate: number) => boolean;\n}\n\n/**\n * Router: a pure function `(source, target, waypoints?, opts?, ctx?) → Polyline`.\n *\n * Routers decide path **topology** — where bends sit. They emit a flat\n * polyline (Point[]); the visual style of segments between bend points is\n * decided by the downstream `PathStyle`. Routers never touch pixi.\n *\n * `waypoints` are intermediate user-supplied points the router should respect.\n * Built-in `straight` passes them through verbatim; topological routers\n * (orth, manhattan, …) anchor stair / corner segments to them.\n *\n * `ctx` is optional — only obstacle-aware routers consume it. The renderer\n * always passes a `RouterCtx`; routers that ignore it lose nothing.\n */\n\nexport type IRouter = (\n source: Endpoint,\n target: Endpoint,\n waypoints?: ReadonlyArray<Point>,\n opts?: Record<string, unknown>,\n ctx?: RouterCtx,\n) => Polyline;\n\n/**\n * Anchor-resolved endpoints handed to a pathStyle alongside the polyline.\n *\n * Tangent-aware pathStyles (`bump-horizontal`, …) read `source.tangent` /\n * `target.tangent` to place their Bézier handles along each shape's outward\n * surface normal, so the curve leaves and arrives flush with the silhouette\n * instead of in a hard-coded direction. Tangent-agnostic pathStyles (`normal`,\n * `rounded`, …) simply ignore the argument — it's optional and additive.\n */\n\nexport interface PathStyleEndpoints {\n readonly source: Endpoint;\n readonly target: Endpoint;\n}\n\n/**\n * PathStyle: a pure function `(polyline, opts?, endpoints?) → Path`.\n *\n * PathStyles decide visual **style** — how segments between polyline points\n * are drawn (sharp, rounded fillets, bezier-smoothed, single bezier A→B).\n * They never see the connector spec or shape context; pure geometric\n * transform.\n *\n * `endpoints` carries the anchor-resolved source/target (with `tangent`) so\n * tangent-aware styles can align Bézier handles with each shape's outward\n * normal. Optional — styles that don't need it ignore the argument and a\n * direct unit-test invocation (`bumpHorizontal(polyline)`) keeps working.\n *\n * Built-ins: `normal` (sharp), `rounded` (quadratic fillets at corners),\n * `smooth` (Catmull-Rom → cubic), `bezier` (single cubic with auto controls).\n */\n\nexport type IPathStyle = (\n polyline: Polyline,\n opts?: Record<string, unknown>,\n endpoints?: PathStyleEndpoints,\n) => Path;\n\n// ─── Fill ──────────────────────────────────────────────────────────────────\n\n/**\n * Anchor positions for inset content layers (`glyph`, `svg`, `svg-url`).\n * Defaults to `'center'`. Use `'top-right'` etc. for corner-badge\n * composition.\n */\n\n/**\n * Stable key of a connector spec with paint removed — geometry only.\n *\n * Two specs with the same key route to the same path, so a caller can skip a\n * re-route when only `stroke` changed. Pure: it reads the spec and nothing\n * else, which is why it lives here rather than on a renderer.\n */\nexport function connectorGeometryKey(spec: object): string {\n const { stroke: _stroke, ...geometry } = spec as { stroke?: unknown };\n return JSON.stringify(geometry);\n}\n","/**\n * Fill, stroke and paint-override vocabulary. Values are plain numbers and enums —\n * a colour is `0xRRGGBB`, never a backend colour object.\n *\n * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.\n */\n\nexport type InsetAnchor =\n | 'center'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right';\n\n/**\n * One layer of a shape's fill. Layers split by role:\n *\n * - **Silhouette fillers** (`solid`, `image`) — paint into the silhouette\n * via Pixi's `g.fill()`. Multiple silhouette layers stack via alpha;\n * each is re-traced before painting. Image fills always render the\n * texture cover-fitted to the silhouette (uniform scale, may crop) —\n * the engine intentionally does not expose CSS-style `background-size`\n * / `background-repeat` knobs on raster fills.\n * - **Inset content** (`glyph`, `svg`, `svg-url`) — mounted as Container\n * children of the shape's `gfx`. Sized by `sizeRatio` (fraction of the\n * smaller bounds dimension) and positioned by `anchor` (default\n * `'center'`).\n *\n * The engine has no dedicated \"icon\" kind — icon-library specifics (Font\n * Awesome glyphs, Lucide SVGs, Fluent icons, …) are produced by developer\n * code and dropped into a `glyph` or `svg` layer directly.\n */\n\nexport type ShapeFillLayer =\n | { readonly kind: 'solid'; readonly color: number; readonly alpha?: number }\n | {\n /**\n * Raster image painted into the host silhouette.\n *\n * Two orthogonal knobs control sizing:\n *\n * - `fit` (default `'cover'`) — how the texture's aspect maps to\n * the silhouette's AABB. `'cover'` scales by `max(...)`, fully\n * covers, may crop on the cross-axis. `'contain'` scales by\n * `min(...)`, fully fits, leaves the cross-axis margin\n * transparent (the underlying fill layer reads through; the\n * engine pins the texture sampler to `clamp-to-edge` so the\n * margin doesn't tile).\n *\n * - `padding` (default `0`) — pixel inset on the silhouette\n * *before* fit math runs. The silhouette itself is re-traced at\n * that inset for this layer only, so the gap between the\n * full-size silhouette and the inset silhouette is painted by\n * layers underneath (typically a `solid` `bgFill`). Use this\n * when the host silhouette is more restrictive than its AABB\n * (circle, polygon, star, arc) and the texture corners would\n * otherwise clip against the curve.\n *\n * Tile patterns, repeat modes, and inset-Sprite badge placement\n * aren't on the engine surface — stack a `glyph` / `svg` /\n * `svg-url` layer for icon-shaped content.\n */\n readonly kind: 'image';\n readonly url: string;\n readonly alpha?: number;\n readonly fit?: 'cover' | 'contain';\n readonly padding?: number;\n }\n | {\n /** Font-rendered character (icon-font codepoint, Unicode symbol, emoji). */\n readonly kind: 'glyph';\n readonly char: string;\n /** Required for icon-font glyphs; optional for system-font Unicode. */\n readonly fontFamily?: string;\n /**\n * Font weight (CSS value, e.g. `400`, `900`, `'bold'`). Required for\n * icon fonts that pack different glyph sets per weight.\n */\n readonly fontWeight?: number | string;\n readonly fontStyle?: 'normal' | 'italic';\n /** Glyph color. Default `0xffffff`. */\n readonly color?: number;\n readonly alpha?: number;\n /** Size as fraction of the shape's smaller bounds dimension. Default `0.6`. */\n readonly sizeRatio?: number;\n /** Anchor relative to the shape's bounds. Default `'center'`. */\n readonly anchor?: InsetAnchor;\n }\n | {\n /** SVG path-d. Multiple subpaths (`M...M...`) are supported. */\n readonly kind: 'svg';\n readonly pathD: string;\n /** Viewport the path was authored in. Default `{ width: 24, height: 24 }`. */\n readonly viewBox?: { readonly width: number; readonly height: number };\n /** Stroke width when rendering. Default `2`. */\n readonly strokeWidth?: number;\n readonly color?: number;\n readonly alpha?: number;\n readonly sizeRatio?: number;\n readonly anchor?: InsetAnchor;\n }\n | {\n /**\n * Vector SVG icon fetched from a URL. The engine fetches the SVG,\n * extracts every drawing primitive (`path` / `ellipse` / `circle` /\n * `rect` / `line` / `polyline` / `polygon`) into a single concatenated\n * `pathD`, and renders it as a Pixi Graphics path. Fetched lazily on\n * first use; the resulting `pathD` is cached globally per URL.\n *\n * Use this when a consumer wants to point at their own remote SVG\n * (logo, custom diagram, sample artwork). For curated icon-library\n * usage, prefer an icon-font glyph via `kind: 'glyph'` — the\n * library is icon-vendor-agnostic and intentionally has no\n * vendor-specific fetch glue.\n */\n readonly kind: 'svg-url';\n readonly url: string;\n readonly viewBox?: { readonly width: number; readonly height: number };\n readonly strokeWidth?: number;\n readonly color?: number;\n readonly alpha?: number;\n readonly sizeRatio?: number;\n readonly anchor?: InsetAnchor;\n };\n\n/**\n * A shape's fill. Either a single layer, an array of layers (painted\n * bottom-up — first array entry sits underneath), or the `number` shorthand\n * for a solid color.\n */\n\nexport type ShapeFill =\n | number\n | ShapeFillLayer\n | ReadonlyArray<ShapeFillLayer>;\n\n/**\n * The **inset-content** half of {@link ShapeFillLayer} — the layer kinds a\n * backend mounts *inside* the silhouette as a child rather than painting\n * *into* it. Named here (not only where it is mounted) because it is part of\n * the vocabulary: a `CompositePart` of kind `'icon'` carries one, so the spec\n * types must be able to reference it without reaching into a renderer.\n */\nexport type InsetFillLayer = Extract<\n ShapeFillLayer,\n { kind: 'glyph' | 'svg' | 'svg-url' }\n>;\n\n/**\n * Does this fill paint the **silhouette** — i.e. would a backend emit a fill\n * for it? True for the `number` shorthand and for any `solid` / `image` layer;\n * false for `undefined` and for a fill made only of inset content\n * ({@link InsetFillLayer}), which mounts a child instead of filling.\n *\n * Load-bearing for hit-testing: a shape with no silhouette fill is **hollow**\n * — only its stroke band answers a containment test, exactly as pixi's\n * `Graphics.containsPoint` behaves (it consults a `fill` instruction that was\n * never emitted). See `containsSpec` in `specs/shapeGeometry/`.\n */\nexport function hasSilhouetteFill(fill: ShapeFill | undefined): boolean {\n if (fill === undefined) return false;\n if (typeof fill === 'number') return true;\n const layers = Array.isArray(fill) ? fill : [fill as ShapeFillLayer];\n return layers.some((l) => l.kind === 'solid' || l.kind === 'image');\n}\n\n// ─── Stroke (border) ───────────────────────────────────────────────────────\n\nexport interface ShapeStroke {\n readonly color: number;\n readonly alpha?: number;\n readonly width?: number;\n /** Default `'center'`. */\n readonly alignment?: 'inside' | 'center' | 'outside';\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n readonly cap?: 'butt' | 'round' | 'square';\n readonly join?: 'miter' | 'round' | 'bevel';\n}\n\n// ─── Paint styles (decoration → primitive override) ────────────────────────\n\n/**\n * Decoration entry-point override on `IShape.paintInto`. When supplied, the\n * shape ignores `spec.fill` / `spec.stroke` and paints with these values\n * instead. Decorations like glow widen `strokeWidth` and reduce `alpha` to\n * paint a halo; decorations like marching-ants supply `dashArray` /\n * `dashOffset` to render a dashed silhouette; decorations like ring/halo\n * with non-zero `inset` ask the shape to trace a parallel-offset version of\n * its own silhouette.\n */\n\nexport interface ShapePaintStyle {\n readonly color?: number;\n readonly alpha?: number;\n readonly strokeWidth?: number;\n /**\n * Stroke alignment relative to the silhouette. Default `'outside'` —\n * decorations almost always want their geometry painted outside the\n * host body (halo, glow, ring), so the inner band doesn't eat into the\n * fill. Override per-call when a decoration genuinely wants to bleed\n * inward (e.g. an \"inset border\" effect).\n */\n readonly alignment?: 'inside' | 'center' | 'outside';\n /** Default `false` — decorations almost always stroke without filling. */\n readonly fill?: boolean;\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n /** Positive = inside the silhouette, negative = outside. Default `0`. */\n readonly inset?: number;\n}\n\n/** Mirror of `ShapePaintStyle` for connectors. No `inset` (connectors are 1D). */\n\nexport interface ConnectorPaintStyle {\n readonly color?: number;\n readonly alpha?: number;\n readonly strokeWidth?: number;\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n readonly cap?: 'butt' | 'round' | 'square';\n readonly join?: 'miter' | 'round' | 'bevel';\n /**\n * When `true`, markers paint with `color` / `alpha` instead of their own\n * spec colors. Glow / halo decorations use this so the decoration covers\n * path + markers as a unified silhouette; marching-ants leaves it\n * undefined so markers stay normal-colored over the dashed line.\n */\n readonly tintMarkers?: boolean;\n /**\n * When `true`, `paintInto` paints only the body (no source / target\n * markers). Useful for decorations that handle markers separately or\n * want to leave them untouched. `markerHalo` is preferred for glow /\n * halo coverage; reach for `skipMarkers` only when even outlined\n * markers would be wrong.\n */\n readonly skipMarkers?: boolean;\n /**\n * When `true`, markers paint as **outlines** at `style.strokeWidth`\n * (using `style.color` / `style.alpha`) instead of as filled silhouettes.\n * Marker geometry continues to size off the host connector's spec\n * stroke width — the halo width affects only the outline stroke, never\n * the marker's tip-to-base / wing-spread dimensions. Combined with the\n * widening-stroke / decreasing-alpha pattern of a glow decoration,\n * this produces a halo around the marker that matches the body halo.\n */\n readonly markerHalo?: boolean;\n}\n\n// ─── Spec types ────────────────────────────────────────────────────────────\n\n/**\n * Ordered paint stripe. Earlier entries paint **below** later ones, and a stripe\n * always wins over `zIndex`: `plane` picks the stripe, `zIndex` orders *within*\n * it. Independent of the scene graph — a shape keeps its logical parent (and so\n * its transform); only its render order moves.\n *\n * `'backdrop'` is the only stripe below the connectors, which is what makes a\n * group frame able to sit under the edges between its own members — see\n * `docs/rfcs/fix/2026-08-05-group-frame-occludes-edges.md`.\n *\n * @remarks\n * The design of record (`docs/render-planes-and-emphasis-plan.md` §4.1) defines\n * five stripes — `backdrop` · `background` · `content` · `foreground` ·\n * `overlay`. Two are implemented: `'backdrop'` and the default `'content'`. The\n * remaining three are served today by the renderer's built-in connector / shape\n * / overlay ordering; widening this union later is additive.\n */\n","/**\n * Polygon maths shared by every spec kind whose silhouette is (or densifies\n * to) a closed vertex ring — `polygon`, `regular-polygon`, `star`,\n * `tabbed-rect`, `path`, and the sampled `arc` fallback.\n *\n * Pure functions over plain `{x, y}` arrays in shape-local space. No drawing\n * library, and nothing from `primitives/` — this file is what lets picking and\n * bounds be answered with no GPU (see `docs/renderer-split-design.md` §4.5,\n * \"what stays engine-side\").\n *\n * Convention: all vertex arrays here are **centre-relative** — the silhouette\n * is traced around the origin so that `boundaryIntersect` (which receives\n * centre-relative input) works without an extra translation step. The one\n * exception is `tabbed-rect`, whose outline is AABB-origin-relative; it says so\n * at its own call sites.\n */\n\nimport type { Point, Rect } from '../geometry';\n\n/** Tight axis-aligned bounding box around the vertex list. */\nexport function polygonBounds(vertices: ReadonlyArray<Point>): Rect {\n if (vertices.length === 0) return { x: 0, y: 0, width: 0, height: 0 };\n let minX = vertices[0]!.x;\n let maxX = minX;\n let minY = vertices[0]!.y;\n let maxY = minY;\n for (let i = 1; i < vertices.length; i++) {\n const v = vertices[i]!;\n if (v.x < minX) minX = v.x;\n else if (v.x > maxX) maxX = v.x;\n if (v.y < minY) minY = v.y;\n else if (v.y > maxY) maxY = v.y;\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Even-odd ray-cast point-in-polygon test. Handles convex and concave\n * silhouettes. Treats the polygon as closed (last vertex implicitly\n * connects to first).\n */\nexport function pointInPolygon(\n localX: number,\n localY: number,\n vertices: ReadonlyArray<Point>,\n): boolean {\n const n = vertices.length;\n if (n < 3) return false;\n let inside = false;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const vi = vertices[i]!;\n const vj = vertices[j]!;\n const intersects =\n vi.y > localY !== vj.y > localY &&\n localX < ((vj.x - vi.x) * (localY - vi.y)) / (vj.y - vi.y) + vi.x;\n if (intersects) inside = !inside;\n }\n return inside;\n}\n\n/** Squared distance from `(px, py)` to the segment `(x1, y1) → (x2, y2)`. */\nexport function distanceToSegmentSq(\n px: number,\n py: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const lenSq = dx * dx + dy * dy;\n // Degenerate segment (both endpoints coincide) — fall back to point distance.\n let t = lenSq === 0 ? 0 : ((px - x1) * dx + (py - y1) * dy) / lenSq;\n t = t < 0 ? 0 : t > 1 ? 1 : t;\n const ex = x1 + t * dx - px;\n const ey = y1 + t * dy - py;\n return ex * ex + ey * ey;\n}\n\n/**\n * Squared distance from `(x, y)` to the nearest **edge** of a vertex ring.\n * `closed` includes the wrap-around edge (last → first); an open run omits it,\n * which is what a `path` spec with `closed: false` draws.\n */\nexport function distanceToOutlineSq(\n x: number,\n y: number,\n vertices: ReadonlyArray<Point>,\n closed = true,\n): number {\n const n = vertices.length;\n if (n === 0) return Infinity;\n if (n === 1) {\n const v = vertices[0]!;\n return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y);\n }\n const edges = closed ? n : n - 1;\n let best = Infinity;\n for (let i = 0; i < edges; i++) {\n const a = vertices[i]!;\n const b = vertices[(i + 1) % n]!;\n const d = distanceToSegmentSq(x, y, a.x, a.y, b.x, b.y);\n if (d < best) best = d;\n }\n return best;\n}\n\n/**\n * Containment against a vertex ring **grown (or shrunk) by `pad`**.\n *\n * - `pad > 0` — inside the ring *or* within `pad` of its outline. This is the\n * region a centred stroke of half-width `pad` covers, and it is exactly the\n * union pixi's `Graphics.containsPoint` reports for a filled + stroked\n * polygon (`Polygon.contains` ∪ `Polygon.strokeContains`).\n * - `pad < 0` — inside the ring *and* further than `|pad|` from its outline:\n * the silhouette eroded inward, used to punch the hole out of a\n * fill-less shape so only its stroke band answers `true`.\n *\n * The offset is a true distance offset (round joins at convex corners), not a\n * miter offset, so a spike's tip grows by `pad` rather than by `pad / sin(θ/2)`\n * — the same approximation pixi makes.\n */\nexport function polygonContainsInflated(\n x: number,\n y: number,\n vertices: ReadonlyArray<Point>,\n pad = 0,\n closed = true,\n): boolean {\n const inside = closed && pointInPolygon(x, y, vertices);\n if (pad === 0) return inside;\n const nearOutline = distanceToOutlineSq(x, y, vertices, closed) <= pad * pad;\n return pad > 0 ? inside || nearOutline : inside && !nearOutline;\n}\n\n/**\n * Parallel-offset a closed polygon by `distance` along each edge's inward\n * normal. Positive `distance` shrinks (inset); negative grows (outset).\n *\n * Each vertex is moved along the **bisector** of its two adjacent edge\n * normals, scaled so the perpendicular offset along the edges equals\n * `distance`. Sufficient for convex and mildly concave silhouettes — the\n * regular-polygon and star convenience kinds always produce well-behaved\n * shapes, free-form polygon insets are best-effort and may self-intersect at\n * extreme concavities.\n */\nexport function offsetPolygon(\n vertices: ReadonlyArray<Point>,\n distance: number,\n): Point[] {\n const n = vertices.length;\n if (n < 3 || distance === 0) return vertices.map((v) => ({ x: v.x, y: v.y }));\n\n // Inward normal of edge (a → b) for a clockwise polygon is (dy, -dx)/len;\n // for counter-clockwise it's (-dy, dx)/len. We don't know orientation up\n // front, so compute the signed area and flip accordingly.\n const ccw = signedArea(vertices) > 0;\n\n const out: Point[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const prev = vertices[(i + n - 1) % n]!;\n const curr = vertices[i]!;\n const next = vertices[(i + 1) % n]!;\n\n const e1 = unitNormal(prev, curr, ccw);\n const e2 = unitNormal(curr, next, ccw);\n\n // Bisector = sum of the two edge normals. Scale to preserve perpendicular\n // distance: divide by (1 + n1·n2) / |n1+n2|² … which simplifies to\n // distance / (1 + n1·n2) when |n1| = |n2| = 1 (both unit normals).\n const bx = e1.x + e2.x;\n const by = e1.y + e2.y;\n const dot = e1.x * e2.x + e1.y * e2.y;\n const denom = 1 + dot;\n // `denom` collapses to ~0 at a 180° spike — fall back to the edge normal\n // to avoid blowing up the offset vertex.\n if (Math.abs(denom) < 1e-6) {\n out[i] = { x: curr.x + e1.x * distance, y: curr.y + e1.y * distance };\n } else {\n const k = distance / denom;\n out[i] = { x: curr.x + bx * k, y: curr.y + by * k };\n }\n }\n return out;\n}\n\n/**\n * Vertices of a regular polygon with `sides` sides and circum-radius\n * `radius`, centred at the origin. `rotationRad` is added to the base angle.\n *\n * Base placement: first vertex at angle `-π/2 + rotationRad` (straight up).\n * So with `rotation = 0`: triangle (sides=3) points up, pentagon points up,\n * hexagon has a vertex at the top (pointy-top). For a flat-top hexagon, pass\n * `rotation = Math.PI / 6`.\n */\nexport function regularPolygonVertices(\n sides: number,\n radius: number,\n rotationRad: number,\n): Point[] {\n const n = Math.max(3, Math.floor(sides));\n const out: Point[] = new Array(n);\n const base = -Math.PI / 2 + rotationRad;\n const step = (Math.PI * 2) / n;\n for (let i = 0; i < n; i++) {\n const a = base + i * step;\n out[i] = { x: Math.cos(a) * radius, y: Math.sin(a) * radius };\n }\n return out;\n}\n\n/**\n * Vertices of a star with `points` outer points, alternating outer\n * (`outerRadius`) and inner (`innerRadius`) vertices around the origin.\n * `rotationRad` is added to the base angle.\n *\n * Base placement: first outer vertex at angle `-π/2 + rotationRad` (up).\n */\nexport function starVertices(\n points: number,\n innerRadius: number,\n outerRadius: number,\n rotationRad: number,\n): Point[] {\n const p = Math.max(3, Math.floor(points));\n const total = p * 2;\n const out: Point[] = new Array(total);\n const base = -Math.PI / 2 + rotationRad;\n const step = Math.PI / p; // half of full angular step\n for (let i = 0; i < total; i++) {\n const r = i % 2 === 0 ? outerRadius : innerRadius;\n const a = base + i * step;\n out[i] = { x: Math.cos(a) * r, y: Math.sin(a) * r };\n }\n return out;\n}\n\n/**\n * Ray from the origin toward `localFromCenter`, intersected with the polygon\n * silhouette. Returns the farthest hit (i.e. where the ray exits the\n * polygon) as a centre-relative point, or `null` if the ray doesn't cross\n * any edge.\n *\n * Used by `boundaryIntersect` to snap connector anchors to the exact\n * perimeter of polygonal shapes.\n */\nexport function rayPolygonIntersection(\n localFromCenter: Point,\n vertices: ReadonlyArray<Point>,\n): Point | null {\n const n = vertices.length;\n if (n < 2) return null;\n const dx = localFromCenter.x;\n const dy = localFromCenter.y;\n if (dx === 0 && dy === 0) return null;\n\n let bestT = -Infinity;\n let hit: Point | null = null;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const a = vertices[j]!;\n const b = vertices[i]!;\n const ex = b.x - a.x;\n const ey = b.y - a.y;\n // Solve [dx -ex] [t] = [a.x]\n // [dy -ey] [u] [a.y]\n const denom = dx * -ey - dy * -ex;\n if (denom === 0) continue;\n const t = (a.x * -ey - a.y * -ex) / denom;\n const u = (dx * a.y - dy * a.x) / denom;\n if (t >= 0 && u >= 0 && u <= 1 && t > bestT) {\n bestT = t;\n hit = { x: dx * t, y: dy * t };\n }\n }\n return hit;\n}\n\n/**\n * One vertex of a {@link roundedPolygonOutline} input ring: a corner point\n * plus the fillet radius to apply there. `r <= 0` keeps the corner sharp.\n */\nexport interface RoundedCorner extends Point {\n readonly r: number;\n}\n\n/**\n * Densify a closed corner ring into a polyline, replacing each corner that\n * carries `r > 0` with a tangent circular fillet.\n *\n * Works for **convex and concave** corners alike — the fillet centre is\n * placed along the corner's interior bisector, which flips side with the\n * corner's turn direction automatically. That's what lets a silhouette with\n * re-entrant corners (a folder's tab shoulder, a callout's notch) round its\n * outer corners while leaving the re-entrant ones sharp.\n *\n * The requested radius is clamped so a fillet can never consume more than\n * half of either adjacent edge, so authored radii larger than the geometry\n * degrade gracefully instead of self-intersecting. Arcs are sampled at\n * roughly one vertex per 2 px of arc length (min 2 segments), matching the\n * density the rounded-rect outline sampler uses.\n *\n * Output winds in the same direction as the input ring, starting at the\n * first corner (or the start of its fillet when it has one).\n */\nexport function roundedPolygonOutline(\n corners: ReadonlyArray<RoundedCorner>,\n): Point[] {\n const n = corners.length;\n if (n < 3) return corners.map((c) => ({ x: c.x, y: c.y }));\n\n const out: Point[] = [];\n for (let i = 0; i < n; i++) {\n const p = corners[i]!;\n const prev = corners[(i + n - 1) % n]!;\n const next = corners[(i + 1) % n]!;\n\n // Unit vectors from the corner toward each neighbour.\n const v1x = prev.x - p.x;\n const v1y = prev.y - p.y;\n const v2x = next.x - p.x;\n const v2y = next.y - p.y;\n const l1 = Math.hypot(v1x, v1y);\n const l2 = Math.hypot(v2x, v2y);\n if (p.r <= 0 || l1 < 1e-9 || l2 < 1e-9) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n const u1x = v1x / l1;\n const u1y = v1y / l1;\n const u2x = v2x / l2;\n const u2y = v2y / l2;\n\n // Interior half-angle at the corner. Collinear neighbours (θ ≈ π, a\n // straight run) and 180° spikes (θ ≈ 0) have no well-defined fillet.\n const cosT = Math.max(-1, Math.min(1, u1x * u2x + u1y * u2y));\n const theta = Math.acos(cosT);\n if (theta < 1e-6 || Math.PI - theta < 1e-6) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n const half = theta / 2;\n\n // Tangent distance from the corner, clamped to half of each adjacent\n // edge so neighbouring fillets can't overlap. The effective radius is\n // recovered from the clamped distance.\n const tangent = Math.min(p.r / Math.tan(half), l1 / 2, l2 / 2);\n const radius = tangent * Math.tan(half);\n if (radius < 1e-6) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n\n // Fillet centre sits along the bisector at `radius / sin(half)`.\n let bx = u1x + u2x;\n let by = u1y + u2y;\n const bl = Math.hypot(bx, by);\n if (bl < 1e-9) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n bx /= bl;\n by /= bl;\n const cx = p.x + bx * (radius / Math.sin(half));\n const cy = p.y + by * (radius / Math.sin(half));\n\n const a1 = Math.atan2(p.y + u1y * tangent - cy, p.x + u1x * tangent - cx);\n const a2 = Math.atan2(p.y + u2y * tangent - cy, p.x + u2x * tangent - cx);\n // Take the minor arc — the fillet never sweeps more than π.\n let delta = a2 - a1;\n while (delta > Math.PI) delta -= 2 * Math.PI;\n while (delta < -Math.PI) delta += 2 * Math.PI;\n\n const steps = Math.max(2, Math.ceil((Math.abs(delta) * radius) / 2));\n for (let s = 0; s <= steps; s++) {\n const a = a1 + delta * (s / steps);\n out.push({ x: cx + Math.cos(a) * radius, y: cy + Math.sin(a) * radius });\n }\n }\n return out;\n}\n\n// ─── Internals ─────────────────────────────────────────────────────────────\n\nfunction signedArea(vertices: ReadonlyArray<Point>): number {\n let sum = 0;\n const n = vertices.length;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const a = vertices[j]!;\n const b = vertices[i]!;\n sum += (b.x - a.x) * (b.y + a.y);\n }\n // Shoelace's signed area is half this sum, with sign flipped for screen\n // coordinates (y grows down). Positive return = counter-clockwise in\n // screen space.\n return -sum * 0.5;\n}\n\nfunction unitNormal(a: Point, b: Point, ccw: boolean): Point {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const len = Math.hypot(dx, dy) || 1;\n // Inward-facing perpendicular: rotate the edge vector by ±90°.\n // CCW polygon (screen space): inward = rotate edge left → (-dy, dx).\n // CW polygon: inward = rotate edge right → (dy, -dx).\n return ccw ? { x: -dy / len, y: dx / len } : { x: dy / len, y: -dx / len };\n}\n","/**\n * The `tabbed-rect` (manila folder) silhouette, as pure maths.\n *\n * Every edge coordinate the outline, fold line, label box, bounds and hit test\n * are built from is resolved here, from the spec alone. It lives in `specs/`\n * rather than beside the renderer because the folder's footprint is a genuine\n * property of the *description* — a layout asking how big a container frame is,\n * an SVG export tracing it, and a headless hit-test all need the same answer\n * without a GPU (`docs/renderer-split-design.md` §4.5).\n *\n * Coordinates are **AABB-origin-relative**: `(0, 0)` is the top-left of the\n * full silhouette, which is the tab band's top-left when the tab is flush left.\n */\n\nimport type { Point, Rect } from '../geometry';\nimport type { TabbedRectSpec } from '../shape';\nimport { roundedPolygonOutline, type RoundedCorner } from './polygonMath';\n\n/** A tabbed-rect spec with its world position removed — geometry only. */\nexport type TabbedRectGeometrySpec = Omit<TabbedRectSpec, 'x' | 'y'>;\n\n/**\n * Every edge coordinate the silhouette, fold line and label box are built\n * from, resolved once against `inset`. `null` when the inset has collapsed the\n * geometry to nothing.\n *\n * The inset is applied analytically per edge rather than via a polygon offset:\n * the re-entrant shoulder corners make a bisector offset unstable, and all but\n * the slanted edges are axis-aligned, so the exact answer is one addition.\n */\nexport interface TabbedRectGeometry {\n left: number;\n right: number;\n bottom: number;\n /** Top of the tab — the silhouette's topmost edge. */\n tabTop: number;\n /** Where the tab meets the body; the fold line's y. */\n shoulder: number;\n /** Tab extent at its **base**, where it meets the body. */\n tabLeft: number;\n tabRight: number;\n /** Tab extent at its **top**, narrowed by the slant on whichever side leans. */\n tabTopLeft: number;\n tabTopRight: number;\n flushLeft: boolean;\n flushRight: boolean;\n /**\n * `true` when `spec.height <= 0` and the silhouette is the tab alone — the\n * closed folder. `left` / `right` / `bottom` describe the tab, and there is\n * no fold line. See {@link bodylessGeometryOf}.\n */\n bodyless: boolean;\n}\n\n/**\n * Resolved tab width: the declared {@link TabbedRectSpec.tabWidth}, falling\n * back to the body's width when it's left unset (a full-width tab).\n *\n * Clamped to the body while there is one — a tab can't outgrow the rectangle\n * it sits on. A bodyless folder's tab *is* the silhouette, so it sizes freely.\n */\nexport function tabbedRectTabWidth(spec: TabbedRectGeometrySpec): number {\n const declared = spec.tabWidth ?? spec.width;\n return spec.height <= 0 ? declared : Math.min(declared, spec.width);\n}\n\n/**\n * AABB of the folder.\n *\n * Bodyless (`height <= 0`): the tab *is* the silhouette, so it's also the\n * footprint — the declared body width describes a rectangle that isn't being\n * drawn. Everything positioned against the AABB (the label box, decorations,\n * edge anchors) therefore lands on the tab.\n */\nexport function tabbedRectBounds(spec: TabbedRectGeometrySpec): Rect {\n if (spec.height <= 0) {\n return { x: 0, y: 0, width: tabbedRectTabWidth(spec), height: spec.tabHeight };\n }\n return { x: 0, y: 0, width: spec.width, height: spec.tabHeight + spec.height };\n}\n\n/**\n * The folder, closed: body gone, tab kept. `width` is deliberately left alone —\n * {@link tabbedRectBounds} already reports the tab as the footprint once the\n * body is gone, so rewriting it would double-apply.\n */\nexport function collapsedTabbedRect(\n _spec: TabbedRectGeometrySpec,\n): Partial<TabbedRectSpec> {\n return { height: 0 };\n}\n\n/**\n * Size the tab to the content it carries — the title.\n *\n * The taper eats into the tab's top edge, so the slant's run is added on top of\n * the text budget; otherwise leaning the tab would push the title into the\n * taper. A centred tab leans on both sides.\n *\n * The clamp to `width` applies **only while there's a body**: a tab can't\n * outgrow the rectangle it sits on, but a closed folder is nothing *but* its\n * tab, so it sizes to the whole title rather than ellipsising it. Returns\n * nothing when {@link TabbedRectSpec.tabWidth} is pinned.\n */\nexport function fitTabbedRectToContent(\n spec: TabbedRectGeometrySpec,\n content: { readonly width: number; readonly height: number },\n): Partial<TabbedRectSpec> {\n if (spec.tabWidth !== undefined) return {};\n const pad = spec.tabPadding ?? 10;\n const slantSides = (spec.tabAlign ?? 'left') === 'center' ? 2 : 1;\n const fitted = content.width + 2 * pad + (spec.tabSkew ?? 0) * slantSides;\n return { tabWidth: spec.height <= 0 ? fitted : Math.min(spec.width, fitted) };\n}\n\n/** Uniform scale of every length the folder carries. */\nexport function scaleTabbedRect(\n spec: TabbedRectGeometrySpec,\n factor: number,\n): Partial<TabbedRectSpec> {\n return {\n width: spec.width * factor,\n height: spec.height * factor,\n tabHeight: spec.tabHeight * factor,\n ...(spec.tabWidth !== undefined ? { tabWidth: spec.tabWidth * factor } : {}),\n ...(spec.tabPadding !== undefined ? { tabPadding: spec.tabPadding * factor } : {}),\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius * factor } : {}),\n ...(spec.tabCornerRadius !== undefined\n ? { tabCornerRadius: spec.tabCornerRadius * factor }\n : {}),\n ...(spec.tabOffset !== undefined ? { tabOffset: spec.tabOffset * factor } : {}),\n ...(spec.tabSkew !== undefined ? { tabSkew: spec.tabSkew * factor } : {}),\n };\n}\n\n/**\n * Trace the folder silhouette into a polyline, inset by `inset` on every side.\n * Winds clockwise from the tab's top-left corner.\n *\n * The two re-entrant shoulders stay sharp; the convex corners take a fillet.\n * Rounding a shoulder reads as a dent rather than a fold.\n */\nexport function tabbedRectOutline(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): Point[] {\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo) return [];\n const { left, right, bottom, tabTop, shoulder, tabLeft, tabRight } = geo;\n\n const r = Math.max(0, (spec.cornerRadius ?? 0) - inset);\n const tr = Math.max(0, (spec.tabCornerRadius ?? spec.cornerRadius ?? 0) - inset);\n\n const corners: RoundedCorner[] = [];\n corners.push({ x: geo.tabTopLeft, y: tabTop, r: tr });\n corners.push({ x: geo.tabTopRight, y: tabTop, r: tr });\n // Closed folder — the tab's base closes the outline, so there are no\n // shoulders to turn and the body's fillet applies to its two bottom corners.\n if (geo.bodyless) {\n corners.push({ x: tabRight, y: bottom, r });\n corners.push({ x: tabLeft, y: bottom, r });\n return roundedPolygonOutline(corners);\n }\n if (geo.flushRight) {\n // Tab reaches the body's right edge — the tab's leaning (or vertical)\n // side runs straight into the body's side, one convex bend.\n corners.push({ x: right, y: shoulder, r });\n } else {\n corners.push({ x: tabRight, y: shoulder, r: 0 });\n corners.push({ x: right, y: shoulder, r });\n }\n corners.push({ x: right, y: bottom, r });\n corners.push({ x: left, y: bottom, r });\n if (!geo.flushLeft) {\n corners.push({ x: left, y: shoulder, r });\n corners.push({ x: tabLeft, y: shoulder, r: 0 });\n }\n return roundedPolygonOutline(corners);\n}\n\n/**\n * The tab's bottom border — the fold where the tab meets the body — as a\n * two-point segment, or `undefined` when `tabDivider` is off or the geometry\n * has collapsed. Spans the tab's **base**, so with a flush tab it starts on the\n * body's own edge and the two borders meet cleanly.\n */\nexport function tabbedRectFoldLine(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): [Point, Point] | undefined {\n if (spec.tabDivider === false) return undefined;\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo || geo.bodyless) return undefined;\n return [\n { x: geo.tabLeft, y: geo.shoulder },\n { x: geo.tabRight, y: geo.shoulder },\n ];\n}\n\n/**\n * The tab's **upright** box — its full-height portion, with the slant excluded\n * on whichever side is angled. This is where the folder's own label belongs:\n * the body interior belongs to whatever the frame contains, so a title centred\n * against this box stays put no matter how large the body grows.\n */\nexport function tabbedRectTabBox(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): Rect | undefined {\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo) return undefined;\n return {\n x: geo.tabTopLeft,\n y: geo.tabTop,\n width: Math.max(0, geo.tabTopRight - geo.tabTopLeft),\n height: geo.shoulder - geo.tabTop,\n };\n}\n\n/** Resolve every edge coordinate of the folder against `inset`. */\nexport function tabbedRectGeometry(\n spec: TabbedRectGeometrySpec,\n inset: number,\n): TabbedRectGeometry | null {\n if (spec.height <= 0) return bodylessGeometryOf(spec, inset);\n const totalH = spec.tabHeight + spec.height;\n const left = inset;\n const right = spec.width - inset;\n const bottom = totalH - inset;\n const tabTop = inset;\n const shoulder = spec.tabHeight + inset;\n if (right <= left || bottom <= shoulder) return null;\n\n const x0 = tabXOf(spec);\n const tabLeft = Math.max(left, x0 + inset);\n const tabRight = Math.min(right, x0 + tabbedRectTabWidth(spec) - inset);\n if (tabRight <= tabLeft) return null;\n\n // The tab leans away from the side it hugs, so the angled edge is always\n // the one facing the rest of the frame. A centred tab leans both ways.\n const align = spec.tabAlign ?? 'left';\n const flushLeft = tabLeft - left < 1e-6;\n const flushRight = right - tabRight < 1e-6;\n // A side flush with the body's edge merges into it and can't lean.\n const slantLeft = (align === 'right' || align === 'center') && !flushLeft;\n const slantRight = (align === 'left' || align === 'center') && !flushRight;\n\n const sides = (slantLeft ? 1 : 0) + (slantRight ? 1 : 0);\n // Clamp so the slants can never eat more than half the tab — an over-large\n // skew degrades to a triangle-ish tab instead of inverting the top edge.\n const skew =\n sides === 0\n ? 0\n : Math.max(0, Math.min(spec.tabSkew ?? 0, (tabRight - tabLeft) / (2 * sides)));\n\n return {\n left,\n right,\n bottom,\n tabTop,\n shoulder,\n tabLeft,\n tabRight,\n tabTopLeft: tabLeft + (slantLeft ? skew : 0),\n tabTopRight: tabRight - (slantRight ? skew : 0),\n flushLeft,\n flushRight,\n bodyless: false,\n };\n}\n\n/**\n * Geometry for a **bodyless** spec (`height <= 0`) — the closed folder: the\n * silhouette is the tab and nothing else.\n *\n * Two things flip relative to {@link tabbedRectGeometry}'s main path, both\n * because the tab's base stops being an interior fold and becomes the outline's\n * bottom edge:\n *\n * - The inset pulls that edge **up** (`tabHeight − inset`) instead of pushing\n * the body's top edge down, so a decoration borrowing this silhouette insets\n * uniformly rather than growing downward.\n * - The tab may **lean on either side regardless of flushness**. In the main\n * path a side flush with the body's edge can't slant (it merges into it);\n * with no body there's nothing to merge with, so a tab spanning the full\n * declared width still gets its taper — which is what keeps a collapsed\n * frame reading as a folder rather than a plain rounded rect.\n */\nfunction bodylessGeometryOf(\n spec: TabbedRectGeometrySpec,\n inset: number,\n): TabbedRectGeometry | null {\n const tabTop = inset;\n const base = spec.tabHeight - inset;\n const tabLeft = inset;\n const tabRight = tabbedRectTabWidth(spec) - inset;\n if (base <= tabTop || tabRight <= tabLeft) return null;\n\n const align = spec.tabAlign ?? 'left';\n const slantLeft = align === 'right' || align === 'center';\n const slantRight = align === 'left' || align === 'center';\n const sides = (slantLeft ? 1 : 0) + (slantRight ? 1 : 0);\n const skew =\n sides === 0\n ? 0\n : Math.max(0, Math.min(spec.tabSkew ?? 0, (tabRight - tabLeft) / (2 * sides)));\n\n return {\n left: tabLeft,\n right: tabRight,\n bottom: base,\n tabTop,\n // No fold to sit on: the shoulder *is* the outline's bottom edge, which\n // keeps the label box (tabTop → shoulder) spanning the whole tab.\n shoulder: base,\n tabLeft,\n tabRight,\n tabTopLeft: tabLeft + (slantLeft ? skew : 0),\n tabTopRight: tabRight - (slantRight ? skew : 0),\n flushLeft: true,\n flushRight: true,\n bodyless: true,\n };\n}\n\n/** Left edge of the tab's base in shape-local space, resolved from `tabAlign`. */\nfunction tabXOf(spec: TabbedRectGeometrySpec): number {\n // Bodyless: the tab is the whole footprint, so it starts at the origin —\n // there's no body left for it to be aligned against or offset from.\n if (spec.height <= 0) return 0;\n const tabW = tabbedRectTabWidth(spec);\n const offset = spec.tabOffset ?? 0;\n switch (spec.tabAlign ?? 'left') {\n case 'center':\n return (spec.width - tabW) / 2;\n case 'right':\n return Math.max(0, spec.width - tabW - offset);\n default:\n return Math.min(offset, Math.max(0, spec.width - tabW));\n }\n}\n","/**\n * Per-kind spec measurement: **bounds**, **uniform scale**, **collapse** and\n * **fit-to-content**, as pure functions of the spec.\n *\n * These four used to live as `static` methods on the renderer-side shape\n * classes. They are not drawing — they are properties of the description, and\n * a layout, an exporter or a headless test needs them with no GPU in the\n * process. The shape classes now delegate here, so there is one implementation\n * per kind (`docs/renderer-split-design.md` §9, P4).\n *\n * Every function takes the spec **without** `x` / `y`: bounds are local, so the\n * world position is the caller's business.\n */\n\nimport type { Point, Rect } from '../geometry';\nimport type {\n ArcSpec,\n CircleSpec,\n CompositeRootSpec,\n CompositeSpec,\n EllipseSpec,\n PathSpec,\n PolygonSpec,\n RectSpec,\n RegularPolygonSpec,\n StarSpec,\n} from '../shape';\nimport {\n polygonBounds,\n regularPolygonVertices,\n starVertices,\n} from './polygonMath';\n\n/** A spec of kind `K` with its world position removed — geometry only. */\nexport type LocalSpec<T> = Omit<T, 'x' | 'y'>;\n\nconst TAU = Math.PI * 2;\n\n// ─── circle ────────────────────────────────────────────────────────────────\n\nexport function boundsOfCircle(spec: LocalSpec<CircleSpec>): Rect {\n const r = spec.radius;\n return { x: -r, y: -r, width: r * 2, height: r * 2 };\n}\n\nexport function scaleCircle(\n spec: LocalSpec<CircleSpec>,\n factor: number,\n): Partial<CircleSpec> {\n return { radius: spec.radius * factor };\n}\n\n// ─── ellipse ───────────────────────────────────────────────────────────────\n\nexport function boundsOfEllipse(spec: LocalSpec<EllipseSpec>): Rect {\n return {\n x: -spec.radiusX,\n y: -spec.radiusY,\n width: spec.radiusX * 2,\n height: spec.radiusY * 2,\n };\n}\n\nexport function scaleEllipse(\n spec: LocalSpec<EllipseSpec>,\n factor: number,\n): Partial<EllipseSpec> {\n return { radiusX: spec.radiusX * factor, radiusY: spec.radiusY * factor };\n}\n\n// ─── rect ──────────────────────────────────────────────────────────────────\n\n/** Anchored top-left, so the local box starts at the origin. */\nexport function boundsOfRect(spec: LocalSpec<RectSpec>): Rect {\n return { x: 0, y: 0, width: spec.width, height: spec.height };\n}\n\nexport function scaleRect(\n spec: LocalSpec<RectSpec>,\n factor: number,\n): Partial<RectSpec> {\n return {\n width: spec.width * factor,\n height: spec.height * factor,\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius * factor } : {}),\n };\n}\n\n// ─── polygon ───────────────────────────────────────────────────────────────\n\nexport function boundsOfPolygon(spec: LocalSpec<PolygonSpec>): Rect {\n return polygonBounds(spec.vertices);\n}\n\nexport function scalePolygon(\n spec: LocalSpec<PolygonSpec>,\n factor: number,\n): Partial<PolygonSpec> {\n return { vertices: spec.vertices.map((v) => ({ x: v.x * factor, y: v.y * factor })) };\n}\n\n// ─── regular-polygon ───────────────────────────────────────────────────────\n\n/** The n-gon's vertices at its authored size, centred on the origin. */\nexport function verticesOfRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n): Point[] {\n return regularPolygonVertices(spec.sides, spec.radius, spec.rotation ?? 0);\n}\n\nexport function boundsOfRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n): Rect {\n return polygonBounds(verticesOfRegularPolygon(spec));\n}\n\nexport function scaleRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n factor: number,\n): Partial<RegularPolygonSpec> {\n return { radius: spec.radius * factor };\n}\n\n// ─── star ──────────────────────────────────────────────────────────────────\n\n/** The star's alternating outer / inner vertices, centred on the origin. */\nexport function verticesOfStar(spec: LocalSpec<StarSpec>): Point[] {\n return starVertices(spec.points, spec.innerRadius, spec.outerRadius, spec.rotation ?? 0);\n}\n\nexport function boundsOfStar(spec: LocalSpec<StarSpec>): Rect {\n return polygonBounds(verticesOfStar(spec));\n}\n\nexport function scaleStar(\n spec: LocalSpec<StarSpec>,\n factor: number,\n): Partial<StarSpec> {\n return {\n innerRadius: spec.innerRadius * factor,\n outerRadius: spec.outerRadius * factor,\n };\n}\n\n// ─── arc ───────────────────────────────────────────────────────────────────\n\n/**\n * Axis-aligned bounding box for an annular sector. The extreme points are\n * either on the four sector corners (a0/inner, a0/outer, a1/inner, a1/outer)\n * or at the cardinal angles (0, π/2, π, 3π/2) on the outer radius if those\n * angles fall inside the sweep — those produce the (±outerR, 0) / (0, ±outerR)\n * extents.\n */\nexport function boundsOfArc(spec: LocalSpec<ArcSpec>): Rect {\n const { innerR, outerR, startAngle: a0, endAngle: a1 } = spec;\n if (a1 <= a0 || outerR <= 0) return { x: 0, y: 0, width: 0, height: 0 };\n\n // Corners always contribute.\n const corners: Point[] = [\n { x: Math.cos(a0) * innerR, y: Math.sin(a0) * innerR },\n { x: Math.cos(a0) * outerR, y: Math.sin(a0) * outerR },\n { x: Math.cos(a1) * innerR, y: Math.sin(a1) * innerR },\n { x: Math.cos(a1) * outerR, y: Math.sin(a1) * outerR },\n ];\n\n // Add the cardinal-angle extents on the outer radius if the sweep crosses\n // them. Normalise everything into a single circle's worth of revolutions so\n // sweeps that wrap past 2π still pick up all four cardinals.\n const sweep = a1 - a0;\n for (const k of [0, 1, 2, 3]) {\n const cardinal = (k * Math.PI) / 2;\n // First multiple of 2π that lands `cardinal` at or after a0.\n let n = Math.ceil((a0 - cardinal) / TAU);\n if (cardinal + n * TAU < a0) n++;\n const angle = cardinal + n * TAU;\n if (angle <= a1 || sweep >= TAU) {\n corners.push({ x: Math.cos(angle) * outerR, y: Math.sin(angle) * outerR });\n }\n }\n\n return polygonBounds(corners);\n}\n\nexport function scaleArc(\n spec: LocalSpec<ArcSpec>,\n factor: number,\n): Partial<ArcSpec> {\n return { innerR: spec.innerR * factor, outerR: spec.outerR * factor };\n}\n\n// ─── path ──────────────────────────────────────────────────────────────────\n\nexport function boundsOfPath(spec: LocalSpec<PathSpec>): Rect {\n return polygonBounds(spec.points);\n}\n\nexport function scalePath(\n spec: LocalSpec<PathSpec>,\n factor: number,\n): Partial<PathSpec> {\n return { points: spec.points.map((p) => ({ x: p.x * factor, y: p.y * factor })) };\n}\n\n// ─── composite ─────────────────────────────────────────────────────────────\n\n/**\n * The composite's silhouette fills its declared box (like a rect), whatever\n * root shape it borrows — the root is centred and sized to that box. Layouts\n * (ELK et al.) read node dimensions through this; without it every card falls\n * back to the layout's default size and they overlap.\n */\nexport function boundsOfComposite(\n spec: Pick<CompositeSpec, 'width' | 'height'>,\n): Rect {\n return { x: 0, y: 0, width: spec.width, height: spec.height };\n}\n\n/**\n * The composite's effective root spec: the explicit\n * {@link CompositeSpec.root}, or the default rounded rect built from\n * `cornerRadius` + the inherited `fill` / `stroke`.\n */\nexport function resolveCompositeRoot(spec: CompositeSpec): CompositeRootSpec {\n if (spec.root) return spec.root;\n return {\n kind: 'rect',\n x: 0,\n y: 0,\n width: spec.width,\n height: spec.height,\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius } : {}),\n ...(spec.fill !== undefined ? { fill: spec.fill } : {}),\n ...(spec.stroke !== undefined ? { stroke: spec.stroke } : {}),\n };\n}\n\n/** Local bounds of whichever shape a composite borrows for its silhouette. */\nexport function boundsOfCompositeRoot(root: CompositeRootSpec): Rect {\n switch (root.kind) {\n case 'circle':\n return boundsOfCircle(root);\n case 'ellipse':\n return boundsOfEllipse(root);\n case 'polygon':\n return boundsOfPolygon(root);\n case 'regular-polygon':\n return boundsOfRegularPolygon(root);\n case 'star':\n return boundsOfStar(root);\n case 'arc':\n return boundsOfArc(root);\n default:\n return boundsOfRect(root);\n }\n}\n\n/**\n * Translation from the composite's top-left origin to the borrowed root's own\n * local origin — the offset that centres the root in the `width × height` box.\n *\n * Origin-agnostic by construction: it works off the root's *bounding-box*\n * centre, so a rect (top-left origin) and a circle (centred origin) both land\n * in the middle of the card. The renderer applies exactly this before tracing\n * the root, which is why hit-testing has to apply it too.\n */\nexport function compositeRootOffset(spec: CompositeSpec): Point {\n const b = boundsOfCompositeRoot(resolveCompositeRoot(spec));\n return {\n x: spec.width / 2 - (b.x + b.width / 2),\n y: spec.height / 2 - (b.y + b.height / 2),\n };\n}\n","/**\n * Pure geometric containment, per spec kind — the engine's hit-test narrow\n * phase with no GPU in it.\n *\n * ## Why this exists\n *\n * Picking used to ask the backend: `bodyGfx.containsPoint(...)`, i.e. pixi\n * walked the instructions it had recorded while painting. That made the answer\n * depend on a display object existing, so picking could not be tested headlessly\n * and would have left the engine with the renderer under the P6 extraction\n * (`docs/renderer-split-design.md` §5 — \"geometry answers must not require the\n * backend\"). Here the answer comes from the spec alone, so every backend agrees\n * by construction.\n *\n * ## Matching pixi\n *\n * `Graphics.containsPoint` is a **union over painted instructions**: a `fill`\n * instruction answers `shape.contains`, a `stroke` instruction answers\n * `shape.strokeContains`. Two consequences are reproduced here deliberately:\n *\n * 1. **A shape with no silhouette fill is hollow.** No fill was painted, so only\n * the stroke band answers `true` — clicking the middle of an outline-only\n * contour misses it, exactly as it does today.\n * 2. **The stroke widens the region by its alignment split**: `'center'`\n * (default) puts half the width outside and half inside, `'outside'` puts all\n * of it outside, `'inside'` all of it inside. That mirrors pixi's\n * `outerWidth = (1 - alignment) * width`.\n *\n * Coordinates are **shape-local** — `(0, 0)` is the shape's own origin (centre\n * for circle / ellipse / polygon / star / arc, top-left for rect / tabbed-rect /\n * composite), i.e. the caller has already subtracted `spec.x` / `spec.y` and\n * divided out any renderer-applied scale.\n */\n\nimport type {\n ArcSpec,\n BaseShapeSpec,\n CircleSpec,\n CompositeRootSpec,\n CompositeSpec,\n EllipseSpec,\n PathSpec,\n PolygonSpec,\n RectSpec,\n RegularPolygonSpec,\n StarSpec,\n TabbedRectSpec,\n} from '../shape';\nimport { hasSilhouetteFill, type ShapeStroke } from '../style';\nimport {\n compositeRootOffset,\n resolveCompositeRoot,\n verticesOfRegularPolygon,\n verticesOfStar,\n type LocalSpec,\n} from './bounds';\nimport {\n distanceToSegmentSq,\n polygonContainsInflated,\n} from './polygonMath';\nimport { tabbedRectOutline } from './tabbedRect';\n\nconst TAU = Math.PI * 2;\n\n/**\n * How far a stroke pushes the hit region past the silhouette (`outer`) and how\n * far it reaches back inside it (`inner`).\n *\n * Mirrors pixi's split: `outer = (1 - alignment) * width`, `inner = width -\n * outer`, with the engine's `'inside' | 'center' | 'outside'` mapping to\n * pixi's `1 | 0.5 | 0` alignment. A missing or non-positive width paints\n * nothing, so it widens nothing.\n */\nexport function strokeBandOf(stroke: ShapeStroke | undefined): {\n outer: number;\n inner: number;\n} {\n const width = stroke?.width ?? (stroke ? 1 : 0);\n if (!stroke || width <= 0) return { outer: 0, inner: 0 };\n const alignment = stroke.alignment === 'inside' ? 1 : stroke.alignment === 'outside' ? 0 : 0.5;\n const outer = (1 - alignment) * width;\n return { outer, inner: width - outer };\n}\n\n// ─── Per-kind containment ──────────────────────────────────────────────────\n//\n// Each takes a `pad`: positive grows the silhouette, negative erodes it. That\n// one parameter expresses both halves of the stroke band, so the fill-less\n// \"hollow\" case is `grown && !eroded` rather than a second family of functions.\n\nexport function containsCircle(\n spec: LocalSpec<CircleSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const r = spec.radius + pad;\n if (r <= 0) return false;\n return localX * localX + localY * localY <= r * r;\n}\n\nexport function containsEllipse(\n spec: LocalSpec<EllipseSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n // Padding an ellipse by its radii is not a true parallel offset (the exact\n // offset curve isn't an ellipse), but it is precisely what pixi's\n // `Ellipse.strokeContains` does, so picking stays consistent with what the\n // user sees highlighted.\n const rx = spec.radiusX + pad;\n const ry = spec.radiusY + pad;\n if (rx <= 0 || ry <= 0) return false;\n const nx = localX / rx;\n const ny = localY / ry;\n return nx * nx + ny * ny <= 1;\n}\n\nexport function containsRect(\n spec: LocalSpec<RectSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const w = spec.width + pad * 2;\n const h = spec.height + pad * 2;\n if (w <= 0 || h <= 0) return false;\n const left = -pad;\n const top = -pad;\n if (localX < left || localX > left + w || localY < top || localY > top + h) return false;\n\n const r = Math.min(Math.max(0, (spec.cornerRadius ?? 0) + pad), w / 2, h / 2);\n if (r <= 0) return true;\n // Outside the four corner discs = outside the rounded rect. Clamping the\n // point into the inner \"core\" rectangle finds the nearest corner centre in\n // one step (pixi's `RoundedRectangle.contains` does the same).\n const cx = clamp(localX, left + r, left + w - r);\n const cy = clamp(localY, top + r, top + h - r);\n const dx = localX - cx;\n const dy = localY - cy;\n return dx * dx + dy * dy <= r * r;\n}\n\nexport function containsPolygon(\n spec: LocalSpec<PolygonSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, spec.vertices, pad);\n}\n\nexport function containsRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, verticesOfRegularPolygon(spec), pad);\n}\n\nexport function containsStar(\n spec: LocalSpec<StarSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, verticesOfStar(spec), pad);\n}\n\nexport function containsTabbedRect(\n spec: LocalSpec<TabbedRectSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n // The outline is already densified through its fillets, so the generic\n // polygon test covers the rounded corners and the re-entrant shoulders alike.\n // The fold line is interior geometry and never part of the silhouette.\n return polygonContainsInflated(localX, localY, tabbedRectOutline(spec, 0), pad);\n}\n\n/**\n * An open path is tested against its **run**, not a phantom closed area: only a\n * `closed` (or `smooth`, which implies closed) path has an interior, matching\n * the paint path, which fills only when closed. So an unfilled contour line\n * answers `true` along its stroke and nowhere else.\n *\n * `smooth` paths are approximated by the control polygon rather than the\n * quadratic spline it generates. The spline passes through the segment\n * midpoints and bulges toward each control point, so the two differ by at most\n * half a segment's sagitta — a fraction of a pixel at contour densities.\n */\nexport function containsPath(\n spec: LocalSpec<PathSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const closed = spec.closed === true || spec.smooth === true;\n return polygonContainsInflated(localX, localY, spec.points, pad, closed);\n}\n\n/**\n * Annular sector, tested analytically rather than against a sampled outline:\n * radius inside `[innerR, outerR]` and angle inside the sweep, each relaxed by\n * `pad`. Outside the sweep the nearest point of the sector lies on one of the\n * two straight radial edges, so the padded test falls back to a distance check\n * against those two segments.\n */\nexport function containsArc(\n spec: LocalSpec<ArcSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const { startAngle: a0, endAngle: a1 } = spec;\n const innerR = Math.max(0, spec.innerR - pad);\n const outerR = spec.outerR + pad;\n if (a1 <= a0 || outerR <= 0) return false;\n\n const rSq = localX * localX + localY * localY;\n const inRadial = rSq >= innerR * innerR && rSq <= outerR * outerR;\n const inSweep = a1 - a0 >= TAU || angleWithin(Math.atan2(localY, localX), a0, a1);\n if (inSweep && inRadial) {\n if (pad >= 0) return true;\n // Eroding: also stay clear of the two radial edges, or the band along them\n // would be reported as interior.\n return distanceToRadialEdgesSq(spec, localX, localY) > pad * pad;\n }\n if (pad <= 0 || a1 - a0 >= TAU) return false;\n // Outside the sweep but possibly within `pad` of a radial edge.\n return distanceToRadialEdgesSq(spec, localX, localY) <= pad * pad;\n}\n\n/**\n * A composite is its **root silhouette** (centred in the card box) plus every\n * geometric part painted on top of it. Parts are included because they are\n * painted into the same `Graphics` the backend hit-tests today: a part that\n * pokes outside the root — an accent bar on an unclipped card — is clickable,\n * and stays clickable here.\n *\n * `label` parts are excluded: they are mounted as text children, not painted\n * into the body, so they never contributed a hit region.\n */\nexport function containsComposite(\n spec: CompositeSpec,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const off = compositeRootOffset(spec);\n const root = resolveCompositeRoot(spec);\n if (containsRootSpec(root, localX - off.x, localY - off.y, pad)) return true;\n\n for (const p of spec.parts) {\n if (p.part === 'rect') {\n if (p.fill === undefined && !p.stroke) continue;\n const box: LocalSpec<RectSpec> = {\n kind: 'rect',\n width: p.width,\n height: p.height,\n ...(p.cornerRadius !== undefined ? { cornerRadius: p.cornerRadius } : {}),\n };\n const half = partHalfStroke(p.stroke);\n if (\n withHollowRule(\n (q) => containsRect(box, localX - p.x, localY - p.y, q),\n p.fill !== undefined,\n pad + half,\n half,\n )\n ) {\n return true;\n }\n } else if (p.part === 'circle') {\n if (p.fill === undefined && !p.stroke) continue;\n const disc: LocalSpec<CircleSpec> = { kind: 'circle', radius: p.radius };\n const half = partHalfStroke(p.stroke);\n if (\n withHollowRule(\n (q) => containsCircle(disc, localX - p.x, localY - p.y, q),\n p.fill !== undefined,\n pad + half,\n half,\n )\n ) {\n return true;\n }\n } else if (p.part === 'line') {\n // Stroke-only geometry: a band of half the stroke width around the run.\n const tol = pad + partHalfStroke(p.stroke);\n if (tol > 0 && distanceToSegmentSq(localX, localY, p.x, p.y, p.x2, p.y2) <= tol * tol) {\n return true;\n }\n } else if (p.part === 'icon' && p.background) {\n // The chip behind the glyph is a filled rect; the glyph itself is a child.\n const chip: LocalSpec<RectSpec> = {\n kind: 'rect',\n width: p.size,\n height: p.size,\n ...(p.background.cornerRadius !== undefined\n ? { cornerRadius: p.background.cornerRadius }\n : {}),\n };\n if (containsRect(chip, localX - p.x, localY - p.y, pad)) return true;\n }\n }\n return false;\n}\n\n// ─── Dispatcher ────────────────────────────────────────────────────────────\n\n/**\n * Does `(localX, localY)` fall inside the region this spec paints?\n *\n * `strokeTolerance` overrides the widening the spec's own stroke would imply\n * (both inward and outward). Omit it and the band is derived from\n * `spec.stroke` — width and alignment — which is what the renderer wants: the\n * hit region then tracks whatever the shape actually draws.\n *\n * Returns `undefined` for a kind this module doesn't know. That is not a\n * failure: `registerShape` admits third-party kinds, and the caller falls back\n * to asking the instance (`IShape.getHitArea`). Distinguishing \"not contained\"\n * from \"cannot answer\" is the whole point of the `boolean | undefined` return.\n */\nexport function containsSpec(\n spec: BaseShapeSpec,\n localX: number,\n localY: number,\n strokeTolerance?: number,\n): boolean | undefined {\n const fn = CONTAINS[spec.kind];\n if (!fn) return undefined;\n\n // A composite resolves fill and stroke per borrowed root and per part — its\n // own `stroke` is already folded into the default root — so it owns the\n // hollow rule internally and takes only the caller's extra padding.\n if (spec.kind === 'composite') return fn(spec as never, localX, localY, strokeTolerance ?? 0);\n\n const band =\n strokeTolerance !== undefined\n ? { outer: strokeTolerance, inner: strokeTolerance }\n : strokeBandOf(spec.stroke);\n\n return withHollowRule(\n (pad) => fn(spec as never, localX, localY, pad),\n hasSilhouetteFill(spec.fill),\n band.outer,\n band.inner,\n );\n}\n\n/**\n * Kinds this module can answer for. Keyed by the same string the shape registry\n * uses, so a kind is answerable here exactly when the engine ships geometry for\n * it — third-party kinds are absent by design (see {@link containsSpec}).\n */\nconst CONTAINS: Record<\n string,\n (spec: never, x: number, y: number, pad: number) => boolean\n> = {\n circle: containsCircle as never,\n ellipse: containsEllipse as never,\n rect: containsRect as never,\n 'tabbed-rect': containsTabbedRect as never,\n polygon: containsPolygon as never,\n 'regular-polygon': containsRegularPolygon as never,\n star: containsStar as never,\n arc: containsArc as never,\n path: containsPath as never,\n composite: containsComposite as never,\n};\n\n// ─── Internals ─────────────────────────────────────────────────────────────\n\n/** Containment against whichever shape a composite borrows for its silhouette. */\nfunction containsRootSpec(\n root: CompositeRootSpec,\n x: number,\n y: number,\n pad: number,\n): boolean {\n const band = strokeBandOf(root.stroke);\n const test = (p: number): boolean => {\n switch (root.kind) {\n case 'circle':\n return containsCircle(root, x, y, p);\n case 'ellipse':\n return containsEllipse(root, x, y, p);\n case 'polygon':\n return containsPolygon(root, x, y, p);\n case 'regular-polygon':\n return containsRegularPolygon(root, x, y, p);\n case 'star':\n return containsStar(root, x, y, p);\n case 'arc':\n return containsArc(root, x, y, p);\n default:\n return containsRect(root, x, y, p);\n }\n };\n return withHollowRule(test, hasSilhouetteFill(root.fill), pad + band.outer, band.inner);\n}\n\n/**\n * Apply the fill-less **hollow** rule to a padded containment test: filled\n * geometry answers for its whole grown silhouette; unfilled geometry answers\n * only inside the stroke band, i.e. grown-by-`outer` minus eroded-by-`inner`.\n */\nfunction withHollowRule(\n test: (pad: number) => boolean,\n filled: boolean,\n outer: number,\n inner: number,\n): boolean {\n if (filled) return test(outer);\n if (outer <= 0 && inner <= 0) return false;\n return test(outer) && !test(-inner);\n}\n\n/**\n * Half-width of a composite part's stroke — the distance it reaches past the\n * traced path. Parts are stroked with the backend's default centred alignment,\n * so half the width falls outside; an absent stroke reaches nowhere.\n */\nfunction partHalfStroke(stroke: { readonly width?: number } | undefined): number {\n if (!stroke) return 0;\n return Math.max(0, stroke.width ?? 1) / 2;\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n\n/** Is `theta` inside `[a0, a1]`, allowing for sweeps that wrap past 2π? */\nfunction angleWithin(theta: number, a0: number, a1: number): boolean {\n // Bring θ into the same revolution as a0 so the comparison is unambiguous\n // across the 2π wrap (e.g. a sweep from 3π/2 to 5π/2 hitting θ ≈ 0.1).\n let n = Math.ceil((a0 - theta) / TAU);\n if (theta + n * TAU < a0) n++;\n const t = theta + n * TAU;\n return t >= a0 && t <= a1;\n}\n\n/** Squared distance to the sector's two straight radial edges. */\nfunction distanceToRadialEdgesSq(\n spec: LocalSpec<ArcSpec>,\n x: number,\n y: number,\n): number {\n const edge = (a: number): number => {\n const c = Math.cos(a);\n const s = Math.sin(a);\n return distanceToSegmentSq(\n x,\n y,\n c * spec.innerR,\n s * spec.innerR,\n c * spec.outerR,\n s * spec.outerR,\n );\n };\n return Math.min(edge(spec.startAngle), edge(spec.endAngle));\n}\n","/**\n * Spec geometry — bounds, scale, collapse, fit and containment, computed from a\n * spec and nothing else.\n *\n * This is the half of the old shape classes that was never really drawing: the\n * `static boundsOf` / `scaleSpec` / `collapsedOf` / `fitToContent` methods, plus\n * the new `contains`. They live here so a layout can size a node, an exporter\n * can trace a silhouette and a test can pick a shape with no backend mounted —\n * and so they stay in `@invana/canvas` when the pixi renderer is extracted\n * (`docs/renderer-split-design.md` §9, P4).\n *\n * The renderer-side shape classes now delegate to these functions; the maths\n * exists once.\n */\n\nexport * from './polygonMath';\nexport * from './tabbedRect';\nexport * from './bounds';\nexport * from './contains';\n\nimport type { Rect } from '../geometry';\nimport type { BaseShapeSpec } from '../shape';\nimport {\n boundsOfArc,\n boundsOfCircle,\n boundsOfComposite,\n boundsOfEllipse,\n boundsOfPath,\n boundsOfPolygon,\n boundsOfRect,\n boundsOfRegularPolygon,\n boundsOfStar,\n scaleArc,\n scaleCircle,\n scaleEllipse,\n scalePath,\n scalePolygon,\n scaleRect,\n scaleRegularPolygon,\n scaleStar,\n} from './bounds';\nimport {\n collapsedTabbedRect,\n fitTabbedRectToContent,\n scaleTabbedRect,\n tabbedRectBounds,\n} from './tabbedRect';\n\n/**\n * Local bounds of any built-in spec kind, or `undefined` for a kind this module\n * doesn't know.\n *\n * `undefined` is a real answer, not a failure: `registerShape` admits\n * third-party kinds, so callers that must cover those ask the registry (which\n * consults the class's `static boundsOf`) and fall back to a default box.\n */\nexport function boundsOfSpec(spec: BaseShapeSpec): Rect | undefined {\n switch (spec.kind) {\n case 'circle':\n return boundsOfCircle(spec as never);\n case 'ellipse':\n return boundsOfEllipse(spec as never);\n case 'rect':\n return boundsOfRect(spec as never);\n case 'tabbed-rect':\n return tabbedRectBounds(spec as never);\n case 'polygon':\n return boundsOfPolygon(spec as never);\n case 'regular-polygon':\n return boundsOfRegularPolygon(spec as never);\n case 'star':\n return boundsOfStar(spec as never);\n case 'arc':\n return boundsOfArc(spec as never);\n case 'path':\n return boundsOfPath(spec as never);\n case 'composite':\n return boundsOfComposite(spec as never);\n default:\n return undefined;\n }\n}\n\n/**\n * Uniformly scale a spec's geometry by `factor`, as a partial patch to merge\n * onto it. Paint is untouched — only lengths.\n *\n * The contract: `boundsOfSpec(scaleSpec(spec, k)).width === boundsOfSpec(spec).width * k`\n * (likewise height). `undefined` for kinds with no meaningful uniform scale\n * (`composite` sizes off its box and its parts, so scaling it needs the layer's\n * intent, not a geometric rule).\n */\nexport function scaleSpec(\n spec: BaseShapeSpec,\n factor: number,\n): Record<string, unknown> | undefined {\n switch (spec.kind) {\n case 'circle':\n return scaleCircle(spec as never, factor);\n case 'ellipse':\n return scaleEllipse(spec as never, factor);\n case 'rect':\n return scaleRect(spec as never, factor);\n case 'tabbed-rect':\n return scaleTabbedRect(spec as never, factor);\n case 'polygon':\n return scalePolygon(spec as never, factor);\n case 'regular-polygon':\n return scaleRegularPolygon(spec as never, factor);\n case 'star':\n return scaleStar(spec as never, factor);\n case 'arc':\n return scaleArc(spec as never, factor);\n case 'path':\n return scalePath(spec as never, factor);\n default:\n return undefined;\n }\n}\n\n/**\n * The spec \"as small as it goes\" — what a collapsed container renders as.\n * Purely geometric: the kind decides what collapsing means to it. `undefined`\n * when the kind has no collapsed form, and callers then keep the spec as is.\n */\nexport function collapsedSpec(\n spec: BaseShapeSpec,\n): Record<string, unknown> | undefined {\n return spec.kind === 'tabbed-rect' ? collapsedTabbedRect(spec as never) : undefined;\n}\n\n/**\n * Size the spec's geometry to a measured block of content (a title, a label).\n * The caller measures — text metrics belong to the backend — and the kind turns\n * that size into geometry. `undefined` when the kind doesn't size to content.\n */\nexport function fitSpecToContent(\n spec: BaseShapeSpec,\n content: { readonly width: number; readonly height: number },\n): Record<string, unknown> | undefined {\n return spec.kind === 'tabbed-rect'\n ? fitTabbedRectToContent(spec as never, content)\n : undefined;\n}\n","/**\n * Flush scheduling for the **non-reactive** data stores ({@link DataStore} /\n * {@link LayerData}). A write marks a dirty delta and *arms* a deferred flush; the\n * mode decides **when** that flush fires. The store never notifies per write — it\n * coalesces a whole batch into **one** flush (see `docs/canvas-store-data-event-flow.md` §2).\n */\n\n/** When a coalesced data flush fires. */\nexport type FlushMode =\n /** Next animation frame (browser). Falls back to `microtask` where no rAF exists (node/tests). */\n | 'frame'\n /** End of the current JS task — the kernel default (no DOM assumption, deterministic). */\n | 'microtask'\n /** Never auto-fires; the owner (e.g. the engine's single rAF loop) calls `flush()`. */\n | 'manual';\n\n// Feature-detect rAF so the renderer-free kernel makes no hard DOM assumption.\nconst raf: typeof requestAnimationFrame | undefined =\n typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;\nconst caf: typeof cancelAnimationFrame | undefined =\n typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;\n\n/**\n * Arm a deferred flush per `mode`, returning a **cancel** function (a no-op once the\n * callback has run or for modes that can't be cancelled). `'manual'` arms nothing.\n */\nexport function scheduleFlush(mode: FlushMode, cb: () => void): () => void {\n if (mode === 'manual') return () => {};\n if (mode === 'frame' && raf && caf) {\n const handle = raf(() => cb());\n return () => caf(handle);\n }\n // microtask — and the `frame` fallback when no rAF is present (node / tests)\n let cancelled = false;\n queueMicrotask(() => {\n if (!cancelled) cb();\n });\n return () => {\n cancelled = true;\n };\n}\n","/**\n * `SpecStore` — the durable **visual description** of one layer's elements.\n *\n * A spec says *what to draw* (`{ kind: 'circle', radius, fill, plane }`) and\n * contains no drawing code. Layers resolve style + templates into specs and\n * publish them here; renderers subscribe and project. That inversion is the\n * point: two backends reading one description cannot disagree about intent, and\n * the description is serialisable, diffable and testable without a GPU.\n *\n * **Generic over `T`, though it no longer has to be.** The vocabulary now sits\n * beside this file (`./index`), so this store *could* name its own element types.\n * It stays generic deliberately: nothing needs the narrowing, and a concrete\n * signature would ripple through `SpecProjector` and `GraphLayer` for no new\n * capability. The engine instantiates it as\n * `SpecStore<BaseShapeSpec | BaseConnectorSpec>`.\n *\n * **What does *not* live here:** positions. Those stay in {@link LayerData}'s\n * typed arrays on the machine-rate path — a drag frame moves nodes without\n * touching a single spec. And transient visuals (lasso, brush, drag ghosts) never\n * enter the store at all; they are drawn through the renderer's overlay device,\n * so gesture noise stays out of history, undo and saved files.\n *\n * Writes mark a dirty delta and arm a coalesced flush — the same contract as\n * {@link LayerData}, so both channels settle in the same frame.\n *\n * See `docs/renderer-split-design.md` §2 (specs as state) and §4.2b (the channel).\n */\n\nimport { scheduleFlush, type FlushMode } from '../state/data/flush';\n\n/**\n * One coalesced batch of spec changes. Ids only — the receiver reads the specs\n * it cares about, so a flush stays O(dirty) regardless of collection size.\n */\nexport interface SpecFlush {\n readonly added: readonly string[];\n readonly changed: readonly string[];\n readonly removed: readonly string[];\n /** Monotonic, per store. Lets a consumer detect a missed batch. */\n readonly version: number;\n}\n\nexport class SpecStore<T extends object = object> {\n private readonly specs = new Map<string, T>();\n private readonly added = new Set<string>();\n private readonly changed = new Set<string>();\n private readonly removed = new Set<string>();\n private readonly listeners = new Set<(e: SpecFlush) => void>();\n private version = 0;\n private scheduled = false;\n private flushMode: FlushMode = 'microtask';\n private cancel: (() => void) | undefined;\n\n // ── Reads ──────────────────────────────────────────────────────────────────\n\n get(id: string): T | undefined {\n return this.specs.get(id);\n }\n\n has(id: string): boolean {\n return this.specs.has(id);\n }\n\n get size(): number {\n return this.specs.size;\n }\n\n ids(): IterableIterator<string> {\n return this.specs.keys();\n }\n\n entries(): IterableIterator<[string, T]> {\n return this.specs.entries();\n }\n\n // ── Writes ─────────────────────────────────────────────────────────────────\n\n /** Publish (or replace) the spec for `id`. */\n set(id: string, spec: T): void {\n const existed = this.specs.has(id);\n this.specs.set(id, spec);\n if (existed) {\n this.removed.delete(id);\n // An id added and then re-set before the flush is still just \"added\".\n if (!this.added.has(id)) this.changed.add(id);\n } else {\n this.added.add(id);\n this.removed.delete(id);\n }\n this.schedule();\n }\n\n /**\n * Shallow-merge `partial` over the stored spec. Returns `false` when `id` is\n * unknown, so a caller can fall back to {@link set} with a full spec.\n */\n patch(id: string, partial: Partial<T>): boolean {\n const current = this.specs.get(id);\n if (!current) return false;\n this.specs.set(id, { ...current, ...partial });\n if (!this.added.has(id)) this.changed.add(id);\n this.schedule();\n return true;\n }\n\n delete(id: string): void {\n if (!this.specs.delete(id)) return;\n this.changed.delete(id);\n // Added-then-removed before a flush is a net no-op: the receiver never saw it.\n if (!this.added.delete(id)) this.removed.add(id);\n this.schedule();\n }\n\n /** Drop every spec. Emits one flush listing all ids as removed. */\n clear(): void {\n for (const id of this.specs.keys()) {\n if (!this.added.delete(id)) this.removed.add(id);\n }\n this.specs.clear();\n this.changed.clear();\n this.schedule();\n }\n\n // ── Flush ──────────────────────────────────────────────────────────────────\n\n onFlush(listener: (e: SpecFlush) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Choose **when** a coalesced flush fires. `'manual'` disarms auto-flush so the\n * engine's single rAF drives it — which is how the renderer stays on one clock.\n */\n setFlushMode(mode: FlushMode): void {\n this.flushMode = mode;\n if (mode === 'manual' && this.scheduled) {\n this.cancel?.();\n this.scheduled = false;\n }\n }\n\n /** Emit the pending delta, if any. Safe to call when nothing is dirty. */\n flush(): void {\n this.scheduled = false;\n if (this.added.size === 0 && this.changed.size === 0 && this.removed.size === 0) return;\n const event: SpecFlush = {\n added: [...this.added],\n changed: [...this.changed],\n removed: [...this.removed],\n version: ++this.version,\n };\n this.added.clear();\n this.changed.clear();\n this.removed.clear();\n for (const listener of this.listeners) listener(event);\n }\n\n private schedule(): void {\n if (this.scheduled || this.flushMode === 'manual') return;\n this.scheduled = true;\n this.cancel = scheduleFlush(this.flushMode, () => this.flush());\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/specs/geometry.ts","../../src/specs/style.ts","../../src/specs/shapeGeometry/polygonMath.ts","../../src/specs/shapeGeometry/tabbedRect.ts","../../src/specs/shapeGeometry/bounds.ts","../../src/specs/shapeGeometry/contains.ts","../../src/specs/shapeGeometry/index.ts","../../src/state/data/flush.ts","../../src/specs/SpecStore.ts"],"names":["TAU"],"mappings":";AA2KO,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,GAAG,UAAS,GAAI,IAAA;AACzC,EAAA,OAAO,IAAA,CAAK,UAAU,QAAQ,CAAA;AAChC;;;ACMO,SAAS,kBAAkB,IAAA,EAAsC;AACtE,EAAA,IAAI,IAAA,KAAS,QAAW,OAAO,KAAA;AAC/B,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA;AACrC,EAAA,MAAM,SAAS,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,IAAA,GAAO,CAAC,IAAsB,CAAA;AACnE,EAAA,OAAO,MAAA,CAAO,KAAK,CAAC,CAAA,K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;AACd,MAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AAAA,IACnB;AAAA,EACF;AAAA;AAAA,EAGA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AACjB,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,IAAA,KAAS,CAAA,IAAK,IAAA,CAAK,OAAA,CAAQ,IAAA,KAAS,CAAA,IAAK,IAAA,CAAK,OAAA,CAAQ,IAAA,KAAS,CAAA,EAAG;AACjF,IAAA,MAAM,KAAA,GAAmB;AAAA,MACvB,KAAA,EAAO,CAAC,GAAG,IAAA,CAAK,KAAK,CAAA;AAAA,MACrB,OAAA,EAAS,CAAC,GAAG,IAAA,CAAK,OAAO,CAAA;AAAA,MACzB,OAAA,EAAS,CAAC,GAAG,IAAA,CAAK,OAAO,CAAA;AAAA,MACzB,OAAA,EAAS,EAAE,IAAA,CAAK;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,MAAM,KAAA,EAAM;AACjB,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,KAAA,MAAW,QAAA,IAAY,IAAA,CAAK,SAAA,EAAW,QAAA,CAAS,KAAK,CAAA;AAAA,EACvD;AAAA,EAEQ,QAAA,GAAiB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAA,IAAa,IAAA,CAAK,SAAA,KAAc,QAAA,EAAU;AACnD,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AACjB,IAAA,IAAA,CAAK,SAAS,aAAA,CAAc,IAAA,CAAK,WAAW,MAAM,IAAA,CAAK,OAAO,CAAA;AAAA,EAChE;AACF","file":"index.js","sourcesContent":["/**\n * Pure geometry — points, rectangles, polylines, paths, and the router / pathStyle\n * function contracts that operate on them. No drawing library appears here.\n *\n * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.\n */\n\n// ─── Geometry primitives ───────────────────────────────────────────────────\n\n// Defined once, in the kernel's geometry vocabulary, and re-exported here so the\n// spec surface stays self-describing. Do not redeclare them — `../geom` is\n// the single home (see the RFC that merged the two definitions:\n// `docs/rfcs/fix/2026-08-10-zustand-imported-outside-canvas-store.md` §4.4).\nexport type { Point, Vec2, Rect, Size } from './geom';\n\nimport type { Point, Vec2, Rect } from './geom';\n\n/** Endpoint anchor a router consumes — point + optional outgoing tangent. */\n\nexport interface Endpoint {\n readonly x: number;\n readonly y: number;\n readonly tangent?: Vec2;\n}\n\n// ─── Polyline (router output, pathStyle input) ─────────────────────────────\n\n/**\n * Flat ordered list of points. Output of a `Router`; input to a `PathStyle`.\n * Also used as the densified form of a `Path` for hit-testing\n * (`samplePath(path)`).\n */\n\nexport type Polyline = ReadonlyArray<Point>;\n\n// ─── Path (pathStyle output, connector input) ──────────────────────────────\n\n/**\n * One step of a `Path`. Mirrors SVG path commands one-for-one:\n * - `M` move to absolute (x, y) — must be the first command of any Path.\n * - `L` line to (x, y) from the current point.\n * - `Q` quadratic Bézier with one control point.\n * - `C` cubic Bézier with two control points.\n *\n * No relative variants, no arcs, no shorthand — pathStyles emit one of these\n * four. Connector renders by walking the path and dispatching to Pixi's\n * `moveTo` / `lineTo` / `quadraticCurveTo` / `bezierCurveTo`.\n */\n\nexport type PathCommand =\n | { readonly kind: 'M'; readonly x: number; readonly y: number }\n | { readonly kind: 'L'; readonly x: number; readonly y: number }\n | { readonly kind: 'Q'; readonly cx: number; readonly cy: number; readonly x: number; readonly y: number }\n | { readonly kind: 'C'; readonly c1x: number; readonly c1y: number; readonly c2x: number; readonly c2y: number; readonly x: number; readonly y: number };\n\nexport type Path = ReadonlyArray<PathCommand>;\n\n/**\n * Read-only scene context handed to routers that need awareness of other\n * shapes — primarily for obstacle-avoidance routing (`manhattan` and\n * friends). Simple geometric routers (`straight`, `orth`) ignore it.\n *\n * `obstacles` are world-space `Rect`s the router should not cross. Each\n * obstacle may also expose `containsInflated` for pixel-accurate silhouette\n * testing (e.g. circles route around their tangent, not their AABB).\n * The renderer auto-collects these from `shapeInstances` (excluding the\n * source/target shapes); callers can override or opt out via\n * `routerOpts.obstacles`.\n */\n\nexport interface RouterCtx {\n readonly obstacles: ReadonlyArray<Obstacle>;\n}\n\n/**\n * Obstacle handed to obstacle-aware routers. `Obstacle extends Rect` so any\n * `Rect[]` is assignable; the optional `containsInflated` callback unlocks\n * silhouette-tight routing for non-rect shapes (circles, polygons, paths).\n */\n\nexport interface Obstacle extends Rect {\n /**\n * Optional silhouette obstacle-test in world coordinates. Returns `true`\n * when `(worldX, worldY)` lies inside the obstacle's silhouette OR within\n * `inflate` world units of it.\n *\n * Routers use this for pixel-accurate marking — when present, the grid\n * blocks only cells that pass this test (in addition to the cheap AABB\n * pre-filter). When absent, the inflated AABB is the source of truth.\n *\n * Shapes opt in by overriding `IShape.obstacleTest`.\n */\n readonly containsInflated?: (worldX: number, worldY: number, inflate: number) => boolean;\n}\n\n/**\n * Router: a pure function `(source, target, waypoints?, opts?, ctx?) → Polyline`.\n *\n * Routers decide path **topology** — where bends sit. They emit a flat\n * polyline (Point[]); the visual style of segments between bend points is\n * decided by the downstream `PathStyle`. Routers never touch pixi.\n *\n * `waypoints` are intermediate user-supplied points the router should respect.\n * Built-in `straight` passes them through verbatim; topological routers\n * (orth, manhattan, …) anchor stair / corner segments to them.\n *\n * `ctx` is optional — only obstacle-aware routers consume it. The renderer\n * always passes a `RouterCtx`; routers that ignore it lose nothing.\n */\n\nexport type IRouter = (\n source: Endpoint,\n target: Endpoint,\n waypoints?: ReadonlyArray<Point>,\n opts?: Record<string, unknown>,\n ctx?: RouterCtx,\n) => Polyline;\n\n/**\n * Anchor-resolved endpoints handed to a pathStyle alongside the polyline.\n *\n * Tangent-aware pathStyles (`bump-horizontal`, …) read `source.tangent` /\n * `target.tangent` to place their Bézier handles along each shape's outward\n * surface normal, so the curve leaves and arrives flush with the silhouette\n * instead of in a hard-coded direction. Tangent-agnostic pathStyles (`normal`,\n * `rounded`, …) simply ignore the argument — it's optional and additive.\n */\n\nexport interface PathStyleEndpoints {\n readonly source: Endpoint;\n readonly target: Endpoint;\n}\n\n/**\n * PathStyle: a pure function `(polyline, opts?, endpoints?) → Path`.\n *\n * PathStyles decide visual **style** — how segments between polyline points\n * are drawn (sharp, rounded fillets, bezier-smoothed, single bezier A→B).\n * They never see the connector spec or shape context; pure geometric\n * transform.\n *\n * `endpoints` carries the anchor-resolved source/target (with `tangent`) so\n * tangent-aware styles can align Bézier handles with each shape's outward\n * normal. Optional — styles that don't need it ignore the argument and a\n * direct unit-test invocation (`bumpHorizontal(polyline)`) keeps working.\n *\n * Built-ins: `normal` (sharp), `rounded` (quadratic fillets at corners),\n * `smooth` (Catmull-Rom → cubic), `bezier` (single cubic with auto controls).\n */\n\nexport type IPathStyle = (\n polyline: Polyline,\n opts?: Record<string, unknown>,\n endpoints?: PathStyleEndpoints,\n) => Path;\n\n// ─── Fill ──────────────────────────────────────────────────────────────────\n\n/**\n * Anchor positions for inset content layers (`glyph`, `svg`, `svg-url`).\n * Defaults to `'center'`. Use `'top-right'` etc. for corner-badge\n * composition.\n */\n\n/**\n * Stable key of a connector spec with paint removed — geometry only.\n *\n * Two specs with the same key route to the same path, so a caller can skip a\n * re-route when only `stroke` changed. Pure: it reads the spec and nothing\n * else, which is why it lives here rather than on a renderer.\n */\nexport function connectorGeometryKey(spec: object): string {\n const { stroke: _stroke, ...geometry } = spec as { stroke?: unknown };\n return JSON.stringify(geometry);\n}\n","/**\n * Fill, stroke and paint-override vocabulary. Values are plain numbers and enums —\n * a colour is `0xRRGGBB`, never a backend colour object.\n *\n * Part of the pixi-free spec vocabulary — see `docs/renderer-split-design.md`.\n */\n\nexport type InsetAnchor =\n | 'center'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right';\n\n/**\n * One layer of a shape's fill. Layers split by role:\n *\n * - **Silhouette fillers** (`solid`, `image`) — paint into the silhouette\n * via Pixi's `g.fill()`. Multiple silhouette layers stack via alpha;\n * each is re-traced before painting. Image fills always render the\n * texture cover-fitted to the silhouette (uniform scale, may crop) —\n * the engine intentionally does not expose CSS-style `background-size`\n * / `background-repeat` knobs on raster fills.\n * - **Inset content** (`glyph`, `svg`, `svg-url`) — mounted as Container\n * children of the shape's `gfx`. Sized by `sizeRatio` (fraction of the\n * smaller bounds dimension) and positioned by `anchor` (default\n * `'center'`).\n *\n * The engine has no dedicated \"icon\" kind — icon-library specifics (Font\n * Awesome glyphs, Lucide SVGs, Fluent icons, …) are produced by developer\n * code and dropped into a `glyph` or `svg` layer directly.\n */\n\nexport type ShapeFillLayer =\n | { readonly kind: 'solid'; readonly color: number; readonly alpha?: number }\n | {\n /**\n * Raster image painted into the host silhouette.\n *\n * Two orthogonal knobs control sizing:\n *\n * - `fit` (default `'cover'`) — how the texture's aspect maps to\n * the silhouette's AABB. `'cover'` scales by `max(...)`, fully\n * covers, may crop on the cross-axis. `'contain'` scales by\n * `min(...)`, fully fits, leaves the cross-axis margin\n * transparent (the underlying fill layer reads through; the\n * engine pins the texture sampler to `clamp-to-edge` so the\n * margin doesn't tile).\n *\n * - `padding` (default `0`) — pixel inset on the silhouette\n * *before* fit math runs. The silhouette itself is re-traced at\n * that inset for this layer only, so the gap between the\n * full-size silhouette and the inset silhouette is painted by\n * layers underneath (typically a `solid` `bgFill`). Use this\n * when the host silhouette is more restrictive than its AABB\n * (circle, polygon, star, arc) and the texture corners would\n * otherwise clip against the curve.\n *\n * Tile patterns, repeat modes, and inset-Sprite badge placement\n * aren't on the engine surface — stack a `glyph` / `svg` /\n * `svg-url` layer for icon-shaped content.\n */\n readonly kind: 'image';\n readonly url: string;\n readonly alpha?: number;\n readonly fit?: 'cover' | 'contain';\n readonly padding?: number;\n }\n | {\n /** Font-rendered character (icon-font codepoint, Unicode symbol, emoji). */\n readonly kind: 'glyph';\n readonly char: string;\n /** Required for icon-font glyphs; optional for system-font Unicode. */\n readonly fontFamily?: string;\n /**\n * Font weight (CSS value, e.g. `400`, `900`, `'bold'`). Required for\n * icon fonts that pack different glyph sets per weight.\n */\n readonly fontWeight?: number | string;\n readonly fontStyle?: 'normal' | 'italic';\n /** Glyph color. Default `0xffffff`. */\n readonly color?: number;\n readonly alpha?: number;\n /** Size as fraction of the shape's smaller bounds dimension. Default `0.6`. */\n readonly sizeRatio?: number;\n /** Anchor relative to the shape's bounds. Default `'center'`. */\n readonly anchor?: InsetAnchor;\n /**\n * Rotation of the inset about its own centre, in **radians, clockwise from\n * up** (a compass course in radians). Default `0`. Applied without\n * rebuilding the inset, so it is cheap to change per frame; the shape's\n * label and silhouette are not rotated.\n */\n readonly rotation?: number;\n }\n | {\n /** SVG path-d. Multiple subpaths (`M...M...`) are supported. */\n readonly kind: 'svg';\n readonly pathD: string;\n /** Viewport the path was authored in. Default `{ width: 24, height: 24 }`. */\n readonly viewBox?: { readonly width: number; readonly height: number };\n /** Stroke width when rendering. Default `2`. */\n readonly strokeWidth?: number;\n readonly color?: number;\n readonly alpha?: number;\n readonly sizeRatio?: number;\n readonly anchor?: InsetAnchor;\n /**\n * Rotation of the inset about its own centre, in **radians, clockwise from\n * up** (a compass course in radians). Default `0`. Applied without\n * rebuilding the inset, so it is cheap to change per frame; the shape's\n * label and silhouette are not rotated.\n */\n readonly rotation?: number;\n }\n | {\n /**\n * Vector SVG icon fetched from a URL. The engine fetches the SVG,\n * extracts every drawing primitive (`path` / `ellipse` / `circle` /\n * `rect` / `line` / `polyline` / `polygon`) into a single concatenated\n * `pathD`, and renders it as a Pixi Graphics path. Fetched lazily on\n * first use; the resulting `pathD` is cached globally per URL.\n *\n * Use this when a consumer wants to point at their own remote SVG\n * (logo, custom diagram, sample artwork). For curated icon-library\n * usage, prefer an icon-font glyph via `kind: 'glyph'` — the\n * library is icon-vendor-agnostic and intentionally has no\n * vendor-specific fetch glue.\n */\n readonly kind: 'svg-url';\n readonly url: string;\n readonly viewBox?: { readonly width: number; readonly height: number };\n readonly strokeWidth?: number;\n readonly color?: number;\n readonly alpha?: number;\n readonly sizeRatio?: number;\n readonly anchor?: InsetAnchor;\n /**\n * Rotation of the inset about its own centre, in **radians, clockwise from\n * up** (a compass course in radians). Default `0`. Applied without\n * rebuilding the inset, so it is cheap to change per frame; the shape's\n * label and silhouette are not rotated.\n */\n readonly rotation?: number;\n };\n\n/**\n * A shape's fill. Either a single layer, an array of layers (painted\n * bottom-up — first array entry sits underneath), or the `number` shorthand\n * for a solid color.\n */\n\nexport type ShapeFill =\n | number\n | ShapeFillLayer\n | ReadonlyArray<ShapeFillLayer>;\n\n/**\n * The **inset-content** half of {@link ShapeFillLayer} — the layer kinds a\n * backend mounts *inside* the silhouette as a child rather than painting\n * *into* it. Named here (not only where it is mounted) because it is part of\n * the vocabulary: a `CompositePart` of kind `'icon'` carries one, so the spec\n * types must be able to reference it without reaching into a renderer.\n */\nexport type InsetFillLayer = Extract<\n ShapeFillLayer,\n { kind: 'glyph' | 'svg' | 'svg-url' }\n>;\n\n/**\n * Does this fill paint the **silhouette** — i.e. would a backend emit a fill\n * for it? True for the `number` shorthand and for any `solid` / `image` layer;\n * false for `undefined` and for a fill made only of inset content\n * ({@link InsetFillLayer}), which mounts a child instead of filling.\n *\n * Load-bearing for hit-testing: a shape with no silhouette fill is **hollow**\n * — only its stroke band answers a containment test, exactly as pixi's\n * `Graphics.containsPoint` behaves (it consults a `fill` instruction that was\n * never emitted). See `containsSpec` in `specs/shapeGeometry/`.\n */\nexport function hasSilhouetteFill(fill: ShapeFill | undefined): boolean {\n if (fill === undefined) return false;\n if (typeof fill === 'number') return true;\n const layers = Array.isArray(fill) ? fill : [fill as ShapeFillLayer];\n return layers.some((l) => l.kind === 'solid' || l.kind === 'image');\n}\n\n// ─── Stroke (border) ───────────────────────────────────────────────────────\n\nexport interface ShapeStroke {\n readonly color: number;\n readonly alpha?: number;\n readonly width?: number;\n /** Default `'center'`. */\n readonly alignment?: 'inside' | 'center' | 'outside';\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n readonly cap?: 'butt' | 'round' | 'square';\n readonly join?: 'miter' | 'round' | 'bevel';\n}\n\n// ─── Paint styles (decoration → primitive override) ────────────────────────\n\n/**\n * Decoration entry-point override on `IShape.paintInto`. When supplied, the\n * shape ignores `spec.fill` / `spec.stroke` and paints with these values\n * instead. Decorations like glow widen `strokeWidth` and reduce `alpha` to\n * paint a halo; decorations like marching-ants supply `dashArray` /\n * `dashOffset` to render a dashed silhouette; decorations like ring/halo\n * with non-zero `inset` ask the shape to trace a parallel-offset version of\n * its own silhouette.\n */\n\nexport interface ShapePaintStyle {\n readonly color?: number;\n readonly alpha?: number;\n readonly strokeWidth?: number;\n /**\n * Stroke alignment relative to the silhouette. Default `'outside'` —\n * decorations almost always want their geometry painted outside the\n * host body (halo, glow, ring), so the inner band doesn't eat into the\n * fill. Override per-call when a decoration genuinely wants to bleed\n * inward (e.g. an \"inset border\" effect).\n */\n readonly alignment?: 'inside' | 'center' | 'outside';\n /** Default `false` — decorations almost always stroke without filling. */\n readonly fill?: boolean;\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n /** Positive = inside the silhouette, negative = outside. Default `0`. */\n readonly inset?: number;\n}\n\n/** Mirror of `ShapePaintStyle` for connectors. No `inset` (connectors are 1D). */\n\nexport interface ConnectorPaintStyle {\n readonly color?: number;\n readonly alpha?: number;\n readonly strokeWidth?: number;\n readonly dashArray?: readonly [number, number];\n readonly dashOffset?: number;\n readonly cap?: 'butt' | 'round' | 'square';\n readonly join?: 'miter' | 'round' | 'bevel';\n /**\n * When `true`, markers paint with `color` / `alpha` instead of their own\n * spec colors. Glow / halo decorations use this so the decoration covers\n * path + markers as a unified silhouette; marching-ants leaves it\n * undefined so markers stay normal-colored over the dashed line.\n */\n readonly tintMarkers?: boolean;\n /**\n * When `true`, `paintInto` paints only the body (no source / target\n * markers). Useful for decorations that handle markers separately or\n * want to leave them untouched. `markerHalo` is preferred for glow /\n * halo coverage; reach for `skipMarkers` only when even outlined\n * markers would be wrong.\n */\n readonly skipMarkers?: boolean;\n /**\n * When `true`, markers paint as **outlines** at `style.strokeWidth`\n * (using `style.color` / `style.alpha`) instead of as filled silhouettes.\n * Marker geometry continues to size off the host connector's spec\n * stroke width — the halo width affects only the outline stroke, never\n * the marker's tip-to-base / wing-spread dimensions. Combined with the\n * widening-stroke / decreasing-alpha pattern of a glow decoration,\n * this produces a halo around the marker that matches the body halo.\n */\n readonly markerHalo?: boolean;\n}\n\n// ─── Spec types ────────────────────────────────────────────────────────────\n\n/**\n * Ordered paint stripe. Earlier entries paint **below** later ones, and a stripe\n * always wins over `zIndex`: `plane` picks the stripe, `zIndex` orders *within*\n * it. Independent of the scene graph — a shape keeps its logical parent (and so\n * its transform); only its render order moves.\n *\n * `'backdrop'` is the only stripe below the connectors, which is what makes a\n * group frame able to sit under the edges between its own members — see\n * `docs/rfcs/fix/2026-08-05-group-frame-occludes-edges.md`.\n *\n * @remarks\n * The design of record (`docs/render-planes-and-emphasis-plan.md` §4.1) defines\n * five stripes — `backdrop` · `background` · `content` · `foreground` ·\n * `overlay`. Two are implemented: `'backdrop'` and the default `'content'`. The\n * remaining three are served today by the renderer's built-in connector / shape\n * / overlay ordering; widening this union later is additive.\n */\n","/**\n * Polygon maths shared by every spec kind whose silhouette is (or densifies\n * to) a closed vertex ring — `polygon`, `regular-polygon`, `star`,\n * `tabbed-rect`, `path`, and the sampled `arc` fallback.\n *\n * Pure functions over plain `{x, y}` arrays in shape-local space. No drawing\n * library, and nothing from `primitives/` — this file is what lets picking and\n * bounds be answered with no GPU (see `docs/renderer-split-design.md` §4.5,\n * \"what stays engine-side\").\n *\n * Convention: all vertex arrays here are **centre-relative** — the silhouette\n * is traced around the origin so that `boundaryIntersect` (which receives\n * centre-relative input) works without an extra translation step. The one\n * exception is `tabbed-rect`, whose outline is AABB-origin-relative; it says so\n * at its own call sites.\n */\n\nimport type { Point, Rect } from '../geometry';\n\n/** Tight axis-aligned bounding box around the vertex list. */\nexport function polygonBounds(vertices: ReadonlyArray<Point>): Rect {\n if (vertices.length === 0) return { x: 0, y: 0, width: 0, height: 0 };\n let minX = vertices[0]!.x;\n let maxX = minX;\n let minY = vertices[0]!.y;\n let maxY = minY;\n for (let i = 1; i < vertices.length; i++) {\n const v = vertices[i]!;\n if (v.x < minX) minX = v.x;\n else if (v.x > maxX) maxX = v.x;\n if (v.y < minY) minY = v.y;\n else if (v.y > maxY) maxY = v.y;\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n/**\n * Even-odd ray-cast point-in-polygon test. Handles convex and concave\n * silhouettes. Treats the polygon as closed (last vertex implicitly\n * connects to first).\n */\nexport function pointInPolygon(\n localX: number,\n localY: number,\n vertices: ReadonlyArray<Point>,\n): boolean {\n const n = vertices.length;\n if (n < 3) return false;\n let inside = false;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const vi = vertices[i]!;\n const vj = vertices[j]!;\n const intersects =\n vi.y > localY !== vj.y > localY &&\n localX < ((vj.x - vi.x) * (localY - vi.y)) / (vj.y - vi.y) + vi.x;\n if (intersects) inside = !inside;\n }\n return inside;\n}\n\n/** Squared distance from `(px, py)` to the segment `(x1, y1) → (x2, y2)`. */\nexport function distanceToSegmentSq(\n px: number,\n py: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const lenSq = dx * dx + dy * dy;\n // Degenerate segment (both endpoints coincide) — fall back to point distance.\n let t = lenSq === 0 ? 0 : ((px - x1) * dx + (py - y1) * dy) / lenSq;\n t = t < 0 ? 0 : t > 1 ? 1 : t;\n const ex = x1 + t * dx - px;\n const ey = y1 + t * dy - py;\n return ex * ex + ey * ey;\n}\n\n/**\n * Squared distance from `(x, y)` to the nearest **edge** of a vertex ring.\n * `closed` includes the wrap-around edge (last → first); an open run omits it,\n * which is what a `path` spec with `closed: false` draws.\n */\nexport function distanceToOutlineSq(\n x: number,\n y: number,\n vertices: ReadonlyArray<Point>,\n closed = true,\n): number {\n const n = vertices.length;\n if (n === 0) return Infinity;\n if (n === 1) {\n const v = vertices[0]!;\n return (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y);\n }\n const edges = closed ? n : n - 1;\n let best = Infinity;\n for (let i = 0; i < edges; i++) {\n const a = vertices[i]!;\n const b = vertices[(i + 1) % n]!;\n const d = distanceToSegmentSq(x, y, a.x, a.y, b.x, b.y);\n if (d < best) best = d;\n }\n return best;\n}\n\n/**\n * Containment against a vertex ring **grown (or shrunk) by `pad`**.\n *\n * - `pad > 0` — inside the ring *or* within `pad` of its outline. This is the\n * region a centred stroke of half-width `pad` covers, and it is exactly the\n * union pixi's `Graphics.containsPoint` reports for a filled + stroked\n * polygon (`Polygon.contains` ∪ `Polygon.strokeContains`).\n * - `pad < 0` — inside the ring *and* further than `|pad|` from its outline:\n * the silhouette eroded inward, used to punch the hole out of a\n * fill-less shape so only its stroke band answers `true`.\n *\n * The offset is a true distance offset (round joins at convex corners), not a\n * miter offset, so a spike's tip grows by `pad` rather than by `pad / sin(θ/2)`\n * — the same approximation pixi makes.\n */\nexport function polygonContainsInflated(\n x: number,\n y: number,\n vertices: ReadonlyArray<Point>,\n pad = 0,\n closed = true,\n): boolean {\n const inside = closed && pointInPolygon(x, y, vertices);\n if (pad === 0) return inside;\n const nearOutline = distanceToOutlineSq(x, y, vertices, closed) <= pad * pad;\n return pad > 0 ? inside || nearOutline : inside && !nearOutline;\n}\n\n/**\n * Parallel-offset a closed polygon by `distance` along each edge's inward\n * normal. Positive `distance` shrinks (inset); negative grows (outset).\n *\n * Each vertex is moved along the **bisector** of its two adjacent edge\n * normals, scaled so the perpendicular offset along the edges equals\n * `distance`. Sufficient for convex and mildly concave silhouettes — the\n * regular-polygon and star convenience kinds always produce well-behaved\n * shapes, free-form polygon insets are best-effort and may self-intersect at\n * extreme concavities.\n */\nexport function offsetPolygon(\n vertices: ReadonlyArray<Point>,\n distance: number,\n): Point[] {\n const n = vertices.length;\n if (n < 3 || distance === 0) return vertices.map((v) => ({ x: v.x, y: v.y }));\n\n // Inward normal of edge (a → b) for a clockwise polygon is (dy, -dx)/len;\n // for counter-clockwise it's (-dy, dx)/len. We don't know orientation up\n // front, so compute the signed area and flip accordingly.\n const ccw = signedArea(vertices) > 0;\n\n const out: Point[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const prev = vertices[(i + n - 1) % n]!;\n const curr = vertices[i]!;\n const next = vertices[(i + 1) % n]!;\n\n const e1 = unitNormal(prev, curr, ccw);\n const e2 = unitNormal(curr, next, ccw);\n\n // Bisector = sum of the two edge normals. Scale to preserve perpendicular\n // distance: divide by (1 + n1·n2) / |n1+n2|² … which simplifies to\n // distance / (1 + n1·n2) when |n1| = |n2| = 1 (both unit normals).\n const bx = e1.x + e2.x;\n const by = e1.y + e2.y;\n const dot = e1.x * e2.x + e1.y * e2.y;\n const denom = 1 + dot;\n // `denom` collapses to ~0 at a 180° spike — fall back to the edge normal\n // to avoid blowing up the offset vertex.\n if (Math.abs(denom) < 1e-6) {\n out[i] = { x: curr.x + e1.x * distance, y: curr.y + e1.y * distance };\n } else {\n const k = distance / denom;\n out[i] = { x: curr.x + bx * k, y: curr.y + by * k };\n }\n }\n return out;\n}\n\n/**\n * Vertices of a regular polygon with `sides` sides and circum-radius\n * `radius`, centred at the origin. `rotationRad` is added to the base angle.\n *\n * Base placement: first vertex at angle `-π/2 + rotationRad` (straight up).\n * So with `rotation = 0`: triangle (sides=3) points up, pentagon points up,\n * hexagon has a vertex at the top (pointy-top). For a flat-top hexagon, pass\n * `rotation = Math.PI / 6`.\n */\nexport function regularPolygonVertices(\n sides: number,\n radius: number,\n rotationRad: number,\n): Point[] {\n const n = Math.max(3, Math.floor(sides));\n const out: Point[] = new Array(n);\n const base = -Math.PI / 2 + rotationRad;\n const step = (Math.PI * 2) / n;\n for (let i = 0; i < n; i++) {\n const a = base + i * step;\n out[i] = { x: Math.cos(a) * radius, y: Math.sin(a) * radius };\n }\n return out;\n}\n\n/**\n * Vertices of a star with `points` outer points, alternating outer\n * (`outerRadius`) and inner (`innerRadius`) vertices around the origin.\n * `rotationRad` is added to the base angle.\n *\n * Base placement: first outer vertex at angle `-π/2 + rotationRad` (up).\n */\nexport function starVertices(\n points: number,\n innerRadius: number,\n outerRadius: number,\n rotationRad: number,\n): Point[] {\n const p = Math.max(3, Math.floor(points));\n const total = p * 2;\n const out: Point[] = new Array(total);\n const base = -Math.PI / 2 + rotationRad;\n const step = Math.PI / p; // half of full angular step\n for (let i = 0; i < total; i++) {\n const r = i % 2 === 0 ? outerRadius : innerRadius;\n const a = base + i * step;\n out[i] = { x: Math.cos(a) * r, y: Math.sin(a) * r };\n }\n return out;\n}\n\n/**\n * Ray from the origin toward `localFromCenter`, intersected with the polygon\n * silhouette. Returns the farthest hit (i.e. where the ray exits the\n * polygon) as a centre-relative point, or `null` if the ray doesn't cross\n * any edge.\n *\n * Used by `boundaryIntersect` to snap connector anchors to the exact\n * perimeter of polygonal shapes.\n */\nexport function rayPolygonIntersection(\n localFromCenter: Point,\n vertices: ReadonlyArray<Point>,\n): Point | null {\n const n = vertices.length;\n if (n < 2) return null;\n const dx = localFromCenter.x;\n const dy = localFromCenter.y;\n if (dx === 0 && dy === 0) return null;\n\n let bestT = -Infinity;\n let hit: Point | null = null;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const a = vertices[j]!;\n const b = vertices[i]!;\n const ex = b.x - a.x;\n const ey = b.y - a.y;\n // Solve [dx -ex] [t] = [a.x]\n // [dy -ey] [u] [a.y]\n const denom = dx * -ey - dy * -ex;\n if (denom === 0) continue;\n const t = (a.x * -ey - a.y * -ex) / denom;\n const u = (dx * a.y - dy * a.x) / denom;\n if (t >= 0 && u >= 0 && u <= 1 && t > bestT) {\n bestT = t;\n hit = { x: dx * t, y: dy * t };\n }\n }\n return hit;\n}\n\n/**\n * One vertex of a {@link roundedPolygonOutline} input ring: a corner point\n * plus the fillet radius to apply there. `r <= 0` keeps the corner sharp.\n */\nexport interface RoundedCorner extends Point {\n readonly r: number;\n}\n\n/**\n * Densify a closed corner ring into a polyline, replacing each corner that\n * carries `r > 0` with a tangent circular fillet.\n *\n * Works for **convex and concave** corners alike — the fillet centre is\n * placed along the corner's interior bisector, which flips side with the\n * corner's turn direction automatically. That's what lets a silhouette with\n * re-entrant corners (a folder's tab shoulder, a callout's notch) round its\n * outer corners while leaving the re-entrant ones sharp.\n *\n * The requested radius is clamped so a fillet can never consume more than\n * half of either adjacent edge, so authored radii larger than the geometry\n * degrade gracefully instead of self-intersecting. Arcs are sampled at\n * roughly one vertex per 2 px of arc length (min 2 segments), matching the\n * density the rounded-rect outline sampler uses.\n *\n * Output winds in the same direction as the input ring, starting at the\n * first corner (or the start of its fillet when it has one).\n */\nexport function roundedPolygonOutline(\n corners: ReadonlyArray<RoundedCorner>,\n): Point[] {\n const n = corners.length;\n if (n < 3) return corners.map((c) => ({ x: c.x, y: c.y }));\n\n const out: Point[] = [];\n for (let i = 0; i < n; i++) {\n const p = corners[i]!;\n const prev = corners[(i + n - 1) % n]!;\n const next = corners[(i + 1) % n]!;\n\n // Unit vectors from the corner toward each neighbour.\n const v1x = prev.x - p.x;\n const v1y = prev.y - p.y;\n const v2x = next.x - p.x;\n const v2y = next.y - p.y;\n const l1 = Math.hypot(v1x, v1y);\n const l2 = Math.hypot(v2x, v2y);\n if (p.r <= 0 || l1 < 1e-9 || l2 < 1e-9) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n const u1x = v1x / l1;\n const u1y = v1y / l1;\n const u2x = v2x / l2;\n const u2y = v2y / l2;\n\n // Interior half-angle at the corner. Collinear neighbours (θ ≈ π, a\n // straight run) and 180° spikes (θ ≈ 0) have no well-defined fillet.\n const cosT = Math.max(-1, Math.min(1, u1x * u2x + u1y * u2y));\n const theta = Math.acos(cosT);\n if (theta < 1e-6 || Math.PI - theta < 1e-6) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n const half = theta / 2;\n\n // Tangent distance from the corner, clamped to half of each adjacent\n // edge so neighbouring fillets can't overlap. The effective radius is\n // recovered from the clamped distance.\n const tangent = Math.min(p.r / Math.tan(half), l1 / 2, l2 / 2);\n const radius = tangent * Math.tan(half);\n if (radius < 1e-6) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n\n // Fillet centre sits along the bisector at `radius / sin(half)`.\n let bx = u1x + u2x;\n let by = u1y + u2y;\n const bl = Math.hypot(bx, by);\n if (bl < 1e-9) {\n out.push({ x: p.x, y: p.y });\n continue;\n }\n bx /= bl;\n by /= bl;\n const cx = p.x + bx * (radius / Math.sin(half));\n const cy = p.y + by * (radius / Math.sin(half));\n\n const a1 = Math.atan2(p.y + u1y * tangent - cy, p.x + u1x * tangent - cx);\n const a2 = Math.atan2(p.y + u2y * tangent - cy, p.x + u2x * tangent - cx);\n // Take the minor arc — the fillet never sweeps more than π.\n let delta = a2 - a1;\n while (delta > Math.PI) delta -= 2 * Math.PI;\n while (delta < -Math.PI) delta += 2 * Math.PI;\n\n const steps = Math.max(2, Math.ceil((Math.abs(delta) * radius) / 2));\n for (let s = 0; s <= steps; s++) {\n const a = a1 + delta * (s / steps);\n out.push({ x: cx + Math.cos(a) * radius, y: cy + Math.sin(a) * radius });\n }\n }\n return out;\n}\n\n// ─── Internals ─────────────────────────────────────────────────────────────\n\nfunction signedArea(vertices: ReadonlyArray<Point>): number {\n let sum = 0;\n const n = vertices.length;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const a = vertices[j]!;\n const b = vertices[i]!;\n sum += (b.x - a.x) * (b.y + a.y);\n }\n // Shoelace's signed area is half this sum, with sign flipped for screen\n // coordinates (y grows down). Positive return = counter-clockwise in\n // screen space.\n return -sum * 0.5;\n}\n\nfunction unitNormal(a: Point, b: Point, ccw: boolean): Point {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const len = Math.hypot(dx, dy) || 1;\n // Inward-facing perpendicular: rotate the edge vector by ±90°.\n // CCW polygon (screen space): inward = rotate edge left → (-dy, dx).\n // CW polygon: inward = rotate edge right → (dy, -dx).\n return ccw ? { x: -dy / len, y: dx / len } : { x: dy / len, y: -dx / len };\n}\n","/**\n * The `tabbed-rect` (manila folder) silhouette, as pure maths.\n *\n * Every edge coordinate the outline, fold line, label box, bounds and hit test\n * are built from is resolved here, from the spec alone. It lives in `specs/`\n * rather than beside the renderer because the folder's footprint is a genuine\n * property of the *description* — a layout asking how big a container frame is,\n * an SVG export tracing it, and a headless hit-test all need the same answer\n * without a GPU (`docs/renderer-split-design.md` §4.5).\n *\n * Coordinates are **AABB-origin-relative**: `(0, 0)` is the top-left of the\n * full silhouette, which is the tab band's top-left when the tab is flush left.\n */\n\nimport type { Point, Rect } from '../geometry';\nimport type { TabbedRectSpec } from '../shape';\nimport { roundedPolygonOutline, type RoundedCorner } from './polygonMath';\n\n/** A tabbed-rect spec with its world position removed — geometry only. */\nexport type TabbedRectGeometrySpec = Omit<TabbedRectSpec, 'x' | 'y'>;\n\n/**\n * Every edge coordinate the silhouette, fold line and label box are built\n * from, resolved once against `inset`. `null` when the inset has collapsed the\n * geometry to nothing.\n *\n * The inset is applied analytically per edge rather than via a polygon offset:\n * the re-entrant shoulder corners make a bisector offset unstable, and all but\n * the slanted edges are axis-aligned, so the exact answer is one addition.\n */\nexport interface TabbedRectGeometry {\n left: number;\n right: number;\n bottom: number;\n /** Top of the tab — the silhouette's topmost edge. */\n tabTop: number;\n /** Where the tab meets the body; the fold line's y. */\n shoulder: number;\n /** Tab extent at its **base**, where it meets the body. */\n tabLeft: number;\n tabRight: number;\n /** Tab extent at its **top**, narrowed by the slant on whichever side leans. */\n tabTopLeft: number;\n tabTopRight: number;\n flushLeft: boolean;\n flushRight: boolean;\n /**\n * `true` when `spec.height <= 0` and the silhouette is the tab alone — the\n * closed folder. `left` / `right` / `bottom` describe the tab, and there is\n * no fold line. See {@link bodylessGeometryOf}.\n */\n bodyless: boolean;\n}\n\n/**\n * Resolved tab width: the declared {@link TabbedRectSpec.tabWidth}, falling\n * back to the body's width when it's left unset (a full-width tab).\n *\n * Clamped to the body while there is one — a tab can't outgrow the rectangle\n * it sits on. A bodyless folder's tab *is* the silhouette, so it sizes freely.\n */\nexport function tabbedRectTabWidth(spec: TabbedRectGeometrySpec): number {\n const declared = spec.tabWidth ?? spec.width;\n return spec.height <= 0 ? declared : Math.min(declared, spec.width);\n}\n\n/**\n * AABB of the folder.\n *\n * Bodyless (`height <= 0`): the tab *is* the silhouette, so it's also the\n * footprint — the declared body width describes a rectangle that isn't being\n * drawn. Everything positioned against the AABB (the label box, decorations,\n * edge anchors) therefore lands on the tab.\n */\nexport function tabbedRectBounds(spec: TabbedRectGeometrySpec): Rect {\n if (spec.height <= 0) {\n return { x: 0, y: 0, width: tabbedRectTabWidth(spec), height: spec.tabHeight };\n }\n return { x: 0, y: 0, width: spec.width, height: spec.tabHeight + spec.height };\n}\n\n/**\n * The folder, closed: body gone, tab kept. `width` is deliberately left alone —\n * {@link tabbedRectBounds} already reports the tab as the footprint once the\n * body is gone, so rewriting it would double-apply.\n */\nexport function collapsedTabbedRect(\n _spec: TabbedRectGeometrySpec,\n): Partial<TabbedRectSpec> {\n return { height: 0 };\n}\n\n/**\n * Size the tab to the content it carries — the title.\n *\n * The taper eats into the tab's top edge, so the slant's run is added on top of\n * the text budget; otherwise leaning the tab would push the title into the\n * taper. A centred tab leans on both sides.\n *\n * The clamp to `width` applies **only while there's a body**: a tab can't\n * outgrow the rectangle it sits on, but a closed folder is nothing *but* its\n * tab, so it sizes to the whole title rather than ellipsising it. Returns\n * nothing when {@link TabbedRectSpec.tabWidth} is pinned.\n */\nexport function fitTabbedRectToContent(\n spec: TabbedRectGeometrySpec,\n content: { readonly width: number; readonly height: number },\n): Partial<TabbedRectSpec> {\n if (spec.tabWidth !== undefined) return {};\n const pad = spec.tabPadding ?? 10;\n const slantSides = (spec.tabAlign ?? 'left') === 'center' ? 2 : 1;\n const fitted = content.width + 2 * pad + (spec.tabSkew ?? 0) * slantSides;\n return { tabWidth: spec.height <= 0 ? fitted : Math.min(spec.width, fitted) };\n}\n\n/** Uniform scale of every length the folder carries. */\nexport function scaleTabbedRect(\n spec: TabbedRectGeometrySpec,\n factor: number,\n): Partial<TabbedRectSpec> {\n return {\n width: spec.width * factor,\n height: spec.height * factor,\n tabHeight: spec.tabHeight * factor,\n ...(spec.tabWidth !== undefined ? { tabWidth: spec.tabWidth * factor } : {}),\n ...(spec.tabPadding !== undefined ? { tabPadding: spec.tabPadding * factor } : {}),\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius * factor } : {}),\n ...(spec.tabCornerRadius !== undefined\n ? { tabCornerRadius: spec.tabCornerRadius * factor }\n : {}),\n ...(spec.tabOffset !== undefined ? { tabOffset: spec.tabOffset * factor } : {}),\n ...(spec.tabSkew !== undefined ? { tabSkew: spec.tabSkew * factor } : {}),\n };\n}\n\n/**\n * Trace the folder silhouette into a polyline, inset by `inset` on every side.\n * Winds clockwise from the tab's top-left corner.\n *\n * The two re-entrant shoulders stay sharp; the convex corners take a fillet.\n * Rounding a shoulder reads as a dent rather than a fold.\n */\nexport function tabbedRectOutline(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): Point[] {\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo) return [];\n const { left, right, bottom, tabTop, shoulder, tabLeft, tabRight } = geo;\n\n const r = Math.max(0, (spec.cornerRadius ?? 0) - inset);\n const tr = Math.max(0, (spec.tabCornerRadius ?? spec.cornerRadius ?? 0) - inset);\n\n const corners: RoundedCorner[] = [];\n corners.push({ x: geo.tabTopLeft, y: tabTop, r: tr });\n corners.push({ x: geo.tabTopRight, y: tabTop, r: tr });\n // Closed folder — the tab's base closes the outline, so there are no\n // shoulders to turn and the body's fillet applies to its two bottom corners.\n if (geo.bodyless) {\n corners.push({ x: tabRight, y: bottom, r });\n corners.push({ x: tabLeft, y: bottom, r });\n return roundedPolygonOutline(corners);\n }\n if (geo.flushRight) {\n // Tab reaches the body's right edge — the tab's leaning (or vertical)\n // side runs straight into the body's side, one convex bend.\n corners.push({ x: right, y: shoulder, r });\n } else {\n corners.push({ x: tabRight, y: shoulder, r: 0 });\n corners.push({ x: right, y: shoulder, r });\n }\n corners.push({ x: right, y: bottom, r });\n corners.push({ x: left, y: bottom, r });\n if (!geo.flushLeft) {\n corners.push({ x: left, y: shoulder, r });\n corners.push({ x: tabLeft, y: shoulder, r: 0 });\n }\n return roundedPolygonOutline(corners);\n}\n\n/**\n * The tab's bottom border — the fold where the tab meets the body — as a\n * two-point segment, or `undefined` when `tabDivider` is off or the geometry\n * has collapsed. Spans the tab's **base**, so with a flush tab it starts on the\n * body's own edge and the two borders meet cleanly.\n */\nexport function tabbedRectFoldLine(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): [Point, Point] | undefined {\n if (spec.tabDivider === false) return undefined;\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo || geo.bodyless) return undefined;\n return [\n { x: geo.tabLeft, y: geo.shoulder },\n { x: geo.tabRight, y: geo.shoulder },\n ];\n}\n\n/**\n * The tab's **upright** box — its full-height portion, with the slant excluded\n * on whichever side is angled. This is where the folder's own label belongs:\n * the body interior belongs to whatever the frame contains, so a title centred\n * against this box stays put no matter how large the body grows.\n */\nexport function tabbedRectTabBox(\n spec: TabbedRectGeometrySpec,\n inset = 0,\n): Rect | undefined {\n const geo = tabbedRectGeometry(spec, inset);\n if (!geo) return undefined;\n return {\n x: geo.tabTopLeft,\n y: geo.tabTop,\n width: Math.max(0, geo.tabTopRight - geo.tabTopLeft),\n height: geo.shoulder - geo.tabTop,\n };\n}\n\n/** Resolve every edge coordinate of the folder against `inset`. */\nexport function tabbedRectGeometry(\n spec: TabbedRectGeometrySpec,\n inset: number,\n): TabbedRectGeometry | null {\n if (spec.height <= 0) return bodylessGeometryOf(spec, inset);\n const totalH = spec.tabHeight + spec.height;\n const left = inset;\n const right = spec.width - inset;\n const bottom = totalH - inset;\n const tabTop = inset;\n const shoulder = spec.tabHeight + inset;\n if (right <= left || bottom <= shoulder) return null;\n\n const x0 = tabXOf(spec);\n const tabLeft = Math.max(left, x0 + inset);\n const tabRight = Math.min(right, x0 + tabbedRectTabWidth(spec) - inset);\n if (tabRight <= tabLeft) return null;\n\n // The tab leans away from the side it hugs, so the angled edge is always\n // the one facing the rest of the frame. A centred tab leans both ways.\n const align = spec.tabAlign ?? 'left';\n const flushLeft = tabLeft - left < 1e-6;\n const flushRight = right - tabRight < 1e-6;\n // A side flush with the body's edge merges into it and can't lean.\n const slantLeft = (align === 'right' || align === 'center') && !flushLeft;\n const slantRight = (align === 'left' || align === 'center') && !flushRight;\n\n const sides = (slantLeft ? 1 : 0) + (slantRight ? 1 : 0);\n // Clamp so the slants can never eat more than half the tab — an over-large\n // skew degrades to a triangle-ish tab instead of inverting the top edge.\n const skew =\n sides === 0\n ? 0\n : Math.max(0, Math.min(spec.tabSkew ?? 0, (tabRight - tabLeft) / (2 * sides)));\n\n return {\n left,\n right,\n bottom,\n tabTop,\n shoulder,\n tabLeft,\n tabRight,\n tabTopLeft: tabLeft + (slantLeft ? skew : 0),\n tabTopRight: tabRight - (slantRight ? skew : 0),\n flushLeft,\n flushRight,\n bodyless: false,\n };\n}\n\n/**\n * Geometry for a **bodyless** spec (`height <= 0`) — the closed folder: the\n * silhouette is the tab and nothing else.\n *\n * Two things flip relative to {@link tabbedRectGeometry}'s main path, both\n * because the tab's base stops being an interior fold and becomes the outline's\n * bottom edge:\n *\n * - The inset pulls that edge **up** (`tabHeight − inset`) instead of pushing\n * the body's top edge down, so a decoration borrowing this silhouette insets\n * uniformly rather than growing downward.\n * - The tab may **lean on either side regardless of flushness**. In the main\n * path a side flush with the body's edge can't slant (it merges into it);\n * with no body there's nothing to merge with, so a tab spanning the full\n * declared width still gets its taper — which is what keeps a collapsed\n * frame reading as a folder rather than a plain rounded rect.\n */\nfunction bodylessGeometryOf(\n spec: TabbedRectGeometrySpec,\n inset: number,\n): TabbedRectGeometry | null {\n const tabTop = inset;\n const base = spec.tabHeight - inset;\n const tabLeft = inset;\n const tabRight = tabbedRectTabWidth(spec) - inset;\n if (base <= tabTop || tabRight <= tabLeft) return null;\n\n const align = spec.tabAlign ?? 'left';\n const slantLeft = align === 'right' || align === 'center';\n const slantRight = align === 'left' || align === 'center';\n const sides = (slantLeft ? 1 : 0) + (slantRight ? 1 : 0);\n const skew =\n sides === 0\n ? 0\n : Math.max(0, Math.min(spec.tabSkew ?? 0, (tabRight - tabLeft) / (2 * sides)));\n\n return {\n left: tabLeft,\n right: tabRight,\n bottom: base,\n tabTop,\n // No fold to sit on: the shoulder *is* the outline's bottom edge, which\n // keeps the label box (tabTop → shoulder) spanning the whole tab.\n shoulder: base,\n tabLeft,\n tabRight,\n tabTopLeft: tabLeft + (slantLeft ? skew : 0),\n tabTopRight: tabRight - (slantRight ? skew : 0),\n flushLeft: true,\n flushRight: true,\n bodyless: true,\n };\n}\n\n/** Left edge of the tab's base in shape-local space, resolved from `tabAlign`. */\nfunction tabXOf(spec: TabbedRectGeometrySpec): number {\n // Bodyless: the tab is the whole footprint, so it starts at the origin —\n // there's no body left for it to be aligned against or offset from.\n if (spec.height <= 0) return 0;\n const tabW = tabbedRectTabWidth(spec);\n const offset = spec.tabOffset ?? 0;\n switch (spec.tabAlign ?? 'left') {\n case 'center':\n return (spec.width - tabW) / 2;\n case 'right':\n return Math.max(0, spec.width - tabW - offset);\n default:\n return Math.min(offset, Math.max(0, spec.width - tabW));\n }\n}\n","/**\n * Per-kind spec measurement: **bounds**, **uniform scale**, **collapse** and\n * **fit-to-content**, as pure functions of the spec.\n *\n * These four used to live as `static` methods on the renderer-side shape\n * classes. They are not drawing — they are properties of the description, and\n * a layout, an exporter or a headless test needs them with no GPU in the\n * process. The shape classes now delegate here, so there is one implementation\n * per kind (`docs/renderer-split-design.md` §9, P4).\n *\n * Every function takes the spec **without** `x` / `y`: bounds are local, so the\n * world position is the caller's business.\n */\n\nimport type { Point, Rect } from '../geometry';\nimport type {\n ArcSpec,\n CircleSpec,\n CompositeRootSpec,\n CompositeSpec,\n EllipseSpec,\n PathSpec,\n PolygonSpec,\n RectSpec,\n RegularPolygonSpec,\n StarSpec,\n} from '../shape';\nimport {\n polygonBounds,\n regularPolygonVertices,\n starVertices,\n} from './polygonMath';\n\n/** A spec of kind `K` with its world position removed — geometry only. */\nexport type LocalSpec<T> = Omit<T, 'x' | 'y'>;\n\nconst TAU = Math.PI * 2;\n\n// ─── circle ────────────────────────────────────────────────────────────────\n\nexport function boundsOfCircle(spec: LocalSpec<CircleSpec>): Rect {\n const r = spec.radius;\n return { x: -r, y: -r, width: r * 2, height: r * 2 };\n}\n\nexport function scaleCircle(\n spec: LocalSpec<CircleSpec>,\n factor: number,\n): Partial<CircleSpec> {\n return { radius: spec.radius * factor };\n}\n\n// ─── ellipse ───────────────────────────────────────────────────────────────\n\nexport function boundsOfEllipse(spec: LocalSpec<EllipseSpec>): Rect {\n return {\n x: -spec.radiusX,\n y: -spec.radiusY,\n width: spec.radiusX * 2,\n height: spec.radiusY * 2,\n };\n}\n\nexport function scaleEllipse(\n spec: LocalSpec<EllipseSpec>,\n factor: number,\n): Partial<EllipseSpec> {\n return { radiusX: spec.radiusX * factor, radiusY: spec.radiusY * factor };\n}\n\n// ─── rect ──────────────────────────────────────────────────────────────────\n\n/** Anchored top-left, so the local box starts at the origin. */\nexport function boundsOfRect(spec: LocalSpec<RectSpec>): Rect {\n return { x: 0, y: 0, width: spec.width, height: spec.height };\n}\n\nexport function scaleRect(\n spec: LocalSpec<RectSpec>,\n factor: number,\n): Partial<RectSpec> {\n return {\n width: spec.width * factor,\n height: spec.height * factor,\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius * factor } : {}),\n };\n}\n\n// ─── polygon ───────────────────────────────────────────────────────────────\n\nexport function boundsOfPolygon(spec: LocalSpec<PolygonSpec>): Rect {\n return polygonBounds(spec.vertices);\n}\n\nexport function scalePolygon(\n spec: LocalSpec<PolygonSpec>,\n factor: number,\n): Partial<PolygonSpec> {\n return { vertices: spec.vertices.map((v) => ({ x: v.x * factor, y: v.y * factor })) };\n}\n\n// ─── regular-polygon ───────────────────────────────────────────────────────\n\n/** The n-gon's vertices at its authored size, centred on the origin. */\nexport function verticesOfRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n): Point[] {\n return regularPolygonVertices(spec.sides, spec.radius, spec.rotation ?? 0);\n}\n\nexport function boundsOfRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n): Rect {\n return polygonBounds(verticesOfRegularPolygon(spec));\n}\n\nexport function scaleRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n factor: number,\n): Partial<RegularPolygonSpec> {\n return { radius: spec.radius * factor };\n}\n\n// ─── star ──────────────────────────────────────────────────────────────────\n\n/** The star's alternating outer / inner vertices, centred on the origin. */\nexport function verticesOfStar(spec: LocalSpec<StarSpec>): Point[] {\n return starVertices(spec.points, spec.innerRadius, spec.outerRadius, spec.rotation ?? 0);\n}\n\nexport function boundsOfStar(spec: LocalSpec<StarSpec>): Rect {\n return polygonBounds(verticesOfStar(spec));\n}\n\nexport function scaleStar(\n spec: LocalSpec<StarSpec>,\n factor: number,\n): Partial<StarSpec> {\n return {\n innerRadius: spec.innerRadius * factor,\n outerRadius: spec.outerRadius * factor,\n };\n}\n\n// ─── arc ───────────────────────────────────────────────────────────────────\n\n/**\n * Axis-aligned bounding box for an annular sector. The extreme points are\n * either on the four sector corners (a0/inner, a0/outer, a1/inner, a1/outer)\n * or at the cardinal angles (0, π/2, π, 3π/2) on the outer radius if those\n * angles fall inside the sweep — those produce the (±outerR, 0) / (0, ±outerR)\n * extents.\n */\nexport function boundsOfArc(spec: LocalSpec<ArcSpec>): Rect {\n const { innerR, outerR, startAngle: a0, endAngle: a1 } = spec;\n if (a1 <= a0 || outerR <= 0) return { x: 0, y: 0, width: 0, height: 0 };\n\n // Corners always contribute.\n const corners: Point[] = [\n { x: Math.cos(a0) * innerR, y: Math.sin(a0) * innerR },\n { x: Math.cos(a0) * outerR, y: Math.sin(a0) * outerR },\n { x: Math.cos(a1) * innerR, y: Math.sin(a1) * innerR },\n { x: Math.cos(a1) * outerR, y: Math.sin(a1) * outerR },\n ];\n\n // Add the cardinal-angle extents on the outer radius if the sweep crosses\n // them. Normalise everything into a single circle's worth of revolutions so\n // sweeps that wrap past 2π still pick up all four cardinals.\n const sweep = a1 - a0;\n for (const k of [0, 1, 2, 3]) {\n const cardinal = (k * Math.PI) / 2;\n // First multiple of 2π that lands `cardinal` at or after a0.\n let n = Math.ceil((a0 - cardinal) / TAU);\n if (cardinal + n * TAU < a0) n++;\n const angle = cardinal + n * TAU;\n if (angle <= a1 || sweep >= TAU) {\n corners.push({ x: Math.cos(angle) * outerR, y: Math.sin(angle) * outerR });\n }\n }\n\n return polygonBounds(corners);\n}\n\nexport function scaleArc(\n spec: LocalSpec<ArcSpec>,\n factor: number,\n): Partial<ArcSpec> {\n return { innerR: spec.innerR * factor, outerR: spec.outerR * factor };\n}\n\n// ─── path ──────────────────────────────────────────────────────────────────\n\nexport function boundsOfPath(spec: LocalSpec<PathSpec>): Rect {\n return polygonBounds(spec.points);\n}\n\nexport function scalePath(\n spec: LocalSpec<PathSpec>,\n factor: number,\n): Partial<PathSpec> {\n return { points: spec.points.map((p) => ({ x: p.x * factor, y: p.y * factor })) };\n}\n\n// ─── composite ─────────────────────────────────────────────────────────────\n\n/**\n * The composite's silhouette fills its declared box (like a rect), whatever\n * root shape it borrows — the root is centred and sized to that box. Layouts\n * (ELK et al.) read node dimensions through this; without it every card falls\n * back to the layout's default size and they overlap.\n */\nexport function boundsOfComposite(\n spec: Pick<CompositeSpec, 'width' | 'height'>,\n): Rect {\n return { x: 0, y: 0, width: spec.width, height: spec.height };\n}\n\n/**\n * The composite's effective root spec: the explicit\n * {@link CompositeSpec.root}, or the default rounded rect built from\n * `cornerRadius` + the inherited `fill` / `stroke`.\n */\nexport function resolveCompositeRoot(spec: CompositeSpec): CompositeRootSpec {\n if (spec.root) return spec.root;\n return {\n kind: 'rect',\n x: 0,\n y: 0,\n width: spec.width,\n height: spec.height,\n ...(spec.cornerRadius !== undefined ? { cornerRadius: spec.cornerRadius } : {}),\n ...(spec.fill !== undefined ? { fill: spec.fill } : {}),\n ...(spec.stroke !== undefined ? { stroke: spec.stroke } : {}),\n };\n}\n\n/** Local bounds of whichever shape a composite borrows for its silhouette. */\nexport function boundsOfCompositeRoot(root: CompositeRootSpec): Rect {\n switch (root.kind) {\n case 'circle':\n return boundsOfCircle(root);\n case 'ellipse':\n return boundsOfEllipse(root);\n case 'polygon':\n return boundsOfPolygon(root);\n case 'regular-polygon':\n return boundsOfRegularPolygon(root);\n case 'star':\n return boundsOfStar(root);\n case 'arc':\n return boundsOfArc(root);\n default:\n return boundsOfRect(root);\n }\n}\n\n/**\n * Translation from the composite's top-left origin to the borrowed root's own\n * local origin — the offset that centres the root in the `width × height` box.\n *\n * Origin-agnostic by construction: it works off the root's *bounding-box*\n * centre, so a rect (top-left origin) and a circle (centred origin) both land\n * in the middle of the card. The renderer applies exactly this before tracing\n * the root, which is why hit-testing has to apply it too.\n */\nexport function compositeRootOffset(spec: CompositeSpec): Point {\n const b = boundsOfCompositeRoot(resolveCompositeRoot(spec));\n return {\n x: spec.width / 2 - (b.x + b.width / 2),\n y: spec.height / 2 - (b.y + b.height / 2),\n };\n}\n","/**\n * Pure geometric containment, per spec kind — the engine's hit-test narrow\n * phase with no GPU in it.\n *\n * ## Why this exists\n *\n * Picking used to ask the backend: `bodyGfx.containsPoint(...)`, i.e. pixi\n * walked the instructions it had recorded while painting. That made the answer\n * depend on a display object existing, so picking could not be tested headlessly\n * and would have left the engine with the renderer under the P6 extraction\n * (`docs/renderer-split-design.md` §5 — \"geometry answers must not require the\n * backend\"). Here the answer comes from the spec alone, so every backend agrees\n * by construction.\n *\n * ## Matching pixi\n *\n * `Graphics.containsPoint` is a **union over painted instructions**: a `fill`\n * instruction answers `shape.contains`, a `stroke` instruction answers\n * `shape.strokeContains`. Two consequences are reproduced here deliberately:\n *\n * 1. **A shape with no silhouette fill is hollow.** No fill was painted, so only\n * the stroke band answers `true` — clicking the middle of an outline-only\n * contour misses it, exactly as it does today.\n * 2. **The stroke widens the region by its alignment split**: `'center'`\n * (default) puts half the width outside and half inside, `'outside'` puts all\n * of it outside, `'inside'` all of it inside. That mirrors pixi's\n * `outerWidth = (1 - alignment) * width`.\n *\n * Coordinates are **shape-local** — `(0, 0)` is the shape's own origin (centre\n * for circle / ellipse / polygon / star / arc, top-left for rect / tabbed-rect /\n * composite), i.e. the caller has already subtracted `spec.x` / `spec.y` and\n * divided out any renderer-applied scale.\n */\n\nimport type {\n ArcSpec,\n BaseShapeSpec,\n CircleSpec,\n CompositeRootSpec,\n CompositeSpec,\n EllipseSpec,\n PathSpec,\n PolygonSpec,\n RectSpec,\n RegularPolygonSpec,\n StarSpec,\n TabbedRectSpec,\n} from '../shape';\nimport { hasSilhouetteFill, type ShapeStroke } from '../style';\nimport {\n compositeRootOffset,\n resolveCompositeRoot,\n verticesOfRegularPolygon,\n verticesOfStar,\n type LocalSpec,\n} from './bounds';\nimport {\n distanceToSegmentSq,\n polygonContainsInflated,\n} from './polygonMath';\nimport { tabbedRectOutline } from './tabbedRect';\n\nconst TAU = Math.PI * 2;\n\n/**\n * How far a stroke pushes the hit region past the silhouette (`outer`) and how\n * far it reaches back inside it (`inner`).\n *\n * Mirrors pixi's split: `outer = (1 - alignment) * width`, `inner = width -\n * outer`, with the engine's `'inside' | 'center' | 'outside'` mapping to\n * pixi's `1 | 0.5 | 0` alignment. A missing or non-positive width paints\n * nothing, so it widens nothing.\n */\nexport function strokeBandOf(stroke: ShapeStroke | undefined): {\n outer: number;\n inner: number;\n} {\n const width = stroke?.width ?? (stroke ? 1 : 0);\n if (!stroke || width <= 0) return { outer: 0, inner: 0 };\n const alignment = stroke.alignment === 'inside' ? 1 : stroke.alignment === 'outside' ? 0 : 0.5;\n const outer = (1 - alignment) * width;\n return { outer, inner: width - outer };\n}\n\n// ─── Per-kind containment ──────────────────────────────────────────────────\n//\n// Each takes a `pad`: positive grows the silhouette, negative erodes it. That\n// one parameter expresses both halves of the stroke band, so the fill-less\n// \"hollow\" case is `grown && !eroded` rather than a second family of functions.\n\nexport function containsCircle(\n spec: LocalSpec<CircleSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const r = spec.radius + pad;\n if (r <= 0) return false;\n return localX * localX + localY * localY <= r * r;\n}\n\nexport function containsEllipse(\n spec: LocalSpec<EllipseSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n // Padding an ellipse by its radii is not a true parallel offset (the exact\n // offset curve isn't an ellipse), but it is precisely what pixi's\n // `Ellipse.strokeContains` does, so picking stays consistent with what the\n // user sees highlighted.\n const rx = spec.radiusX + pad;\n const ry = spec.radiusY + pad;\n if (rx <= 0 || ry <= 0) return false;\n const nx = localX / rx;\n const ny = localY / ry;\n return nx * nx + ny * ny <= 1;\n}\n\nexport function containsRect(\n spec: LocalSpec<RectSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const w = spec.width + pad * 2;\n const h = spec.height + pad * 2;\n if (w <= 0 || h <= 0) return false;\n const left = -pad;\n const top = -pad;\n if (localX < left || localX > left + w || localY < top || localY > top + h) return false;\n\n const r = Math.min(Math.max(0, (spec.cornerRadius ?? 0) + pad), w / 2, h / 2);\n if (r <= 0) return true;\n // Outside the four corner discs = outside the rounded rect. Clamping the\n // point into the inner \"core\" rectangle finds the nearest corner centre in\n // one step (pixi's `RoundedRectangle.contains` does the same).\n const cx = clamp(localX, left + r, left + w - r);\n const cy = clamp(localY, top + r, top + h - r);\n const dx = localX - cx;\n const dy = localY - cy;\n return dx * dx + dy * dy <= r * r;\n}\n\nexport function containsPolygon(\n spec: LocalSpec<PolygonSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, spec.vertices, pad);\n}\n\nexport function containsRegularPolygon(\n spec: LocalSpec<RegularPolygonSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, verticesOfRegularPolygon(spec), pad);\n}\n\nexport function containsStar(\n spec: LocalSpec<StarSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n return polygonContainsInflated(localX, localY, verticesOfStar(spec), pad);\n}\n\nexport function containsTabbedRect(\n spec: LocalSpec<TabbedRectSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n // The outline is already densified through its fillets, so the generic\n // polygon test covers the rounded corners and the re-entrant shoulders alike.\n // The fold line is interior geometry and never part of the silhouette.\n return polygonContainsInflated(localX, localY, tabbedRectOutline(spec, 0), pad);\n}\n\n/**\n * An open path is tested against its **run**, not a phantom closed area: only a\n * `closed` (or `smooth`, which implies closed) path has an interior, matching\n * the paint path, which fills only when closed. So an unfilled contour line\n * answers `true` along its stroke and nowhere else.\n *\n * `smooth` paths are approximated by the control polygon rather than the\n * quadratic spline it generates. The spline passes through the segment\n * midpoints and bulges toward each control point, so the two differ by at most\n * half a segment's sagitta — a fraction of a pixel at contour densities.\n */\nexport function containsPath(\n spec: LocalSpec<PathSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const closed = spec.closed === true || spec.smooth === true;\n return polygonContainsInflated(localX, localY, spec.points, pad, closed);\n}\n\n/**\n * Annular sector, tested analytically rather than against a sampled outline:\n * radius inside `[innerR, outerR]` and angle inside the sweep, each relaxed by\n * `pad`. Outside the sweep the nearest point of the sector lies on one of the\n * two straight radial edges, so the padded test falls back to a distance check\n * against those two segments.\n */\nexport function containsArc(\n spec: LocalSpec<ArcSpec>,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const { startAngle: a0, endAngle: a1 } = spec;\n const innerR = Math.max(0, spec.innerR - pad);\n const outerR = spec.outerR + pad;\n if (a1 <= a0 || outerR <= 0) return false;\n\n const rSq = localX * localX + localY * localY;\n const inRadial = rSq >= innerR * innerR && rSq <= outerR * outerR;\n const inSweep = a1 - a0 >= TAU || angleWithin(Math.atan2(localY, localX), a0, a1);\n if (inSweep && inRadial) {\n if (pad >= 0) return true;\n // Eroding: also stay clear of the two radial edges, or the band along them\n // would be reported as interior.\n return distanceToRadialEdgesSq(spec, localX, localY) > pad * pad;\n }\n if (pad <= 0 || a1 - a0 >= TAU) return false;\n // Outside the sweep but possibly within `pad` of a radial edge.\n return distanceToRadialEdgesSq(spec, localX, localY) <= pad * pad;\n}\n\n/**\n * A composite is its **root silhouette** (centred in the card box) plus every\n * geometric part painted on top of it. Parts are included because they are\n * painted into the same `Graphics` the backend hit-tests today: a part that\n * pokes outside the root — an accent bar on an unclipped card — is clickable,\n * and stays clickable here.\n *\n * `label` parts are excluded: they are mounted as text children, not painted\n * into the body, so they never contributed a hit region.\n */\nexport function containsComposite(\n spec: CompositeSpec,\n localX: number,\n localY: number,\n pad = 0,\n): boolean {\n const off = compositeRootOffset(spec);\n const root = resolveCompositeRoot(spec);\n if (containsRootSpec(root, localX - off.x, localY - off.y, pad)) return true;\n\n for (const p of spec.parts) {\n if (p.part === 'rect') {\n if (p.fill === undefined && !p.stroke) continue;\n const box: LocalSpec<RectSpec> = {\n kind: 'rect',\n width: p.width,\n height: p.height,\n ...(p.cornerRadius !== undefined ? { cornerRadius: p.cornerRadius } : {}),\n };\n const half = partHalfStroke(p.stroke);\n if (\n withHollowRule(\n (q) => containsRect(box, localX - p.x, localY - p.y, q),\n p.fill !== undefined,\n pad + half,\n half,\n )\n ) {\n return true;\n }\n } else if (p.part === 'circle') {\n if (p.fill === undefined && !p.stroke) continue;\n const disc: LocalSpec<CircleSpec> = { kind: 'circle', radius: p.radius };\n const half = partHalfStroke(p.stroke);\n if (\n withHollowRule(\n (q) => containsCircle(disc, localX - p.x, localY - p.y, q),\n p.fill !== undefined,\n pad + half,\n half,\n )\n ) {\n return true;\n }\n } else if (p.part === 'line') {\n // Stroke-only geometry: a band of half the stroke width around the run.\n const tol = pad + partHalfStroke(p.stroke);\n if (tol > 0 && distanceToSegmentSq(localX, localY, p.x, p.y, p.x2, p.y2) <= tol * tol) {\n return true;\n }\n } else if (p.part === 'icon' && p.background) {\n // The chip behind the glyph is a filled rect; the glyph itself is a child.\n const chip: LocalSpec<RectSpec> = {\n kind: 'rect',\n width: p.size,\n height: p.size,\n ...(p.background.cornerRadius !== undefined\n ? { cornerRadius: p.background.cornerRadius }\n : {}),\n };\n if (containsRect(chip, localX - p.x, localY - p.y, pad)) return true;\n }\n }\n return false;\n}\n\n// ─── Dispatcher ────────────────────────────────────────────────────────────\n\n/**\n * Does `(localX, localY)` fall inside the region this spec paints?\n *\n * `strokeTolerance` overrides the widening the spec's own stroke would imply\n * (both inward and outward). Omit it and the band is derived from\n * `spec.stroke` — width and alignment — which is what the renderer wants: the\n * hit region then tracks whatever the shape actually draws.\n *\n * Returns `undefined` for a kind this module doesn't know. That is not a\n * failure: `registerShape` admits third-party kinds, and the caller falls back\n * to asking the instance (`IShape.getHitArea`). Distinguishing \"not contained\"\n * from \"cannot answer\" is the whole point of the `boolean | undefined` return.\n */\nexport function containsSpec(\n spec: BaseShapeSpec,\n localX: number,\n localY: number,\n strokeTolerance?: number,\n): boolean | undefined {\n const fn = CONTAINS[spec.kind];\n if (!fn) return undefined;\n\n // A composite resolves fill and stroke per borrowed root and per part — its\n // own `stroke` is already folded into the default root — so it owns the\n // hollow rule internally and takes only the caller's extra padding.\n if (spec.kind === 'composite') return fn(spec as never, localX, localY, strokeTolerance ?? 0);\n\n const band =\n strokeTolerance !== undefined\n ? { outer: strokeTolerance, inner: strokeTolerance }\n : strokeBandOf(spec.stroke);\n\n return withHollowRule(\n (pad) => fn(spec as never, localX, localY, pad),\n hasSilhouetteFill(spec.fill),\n band.outer,\n band.inner,\n );\n}\n\n/**\n * Kinds this module can answer for. Keyed by the same string the shape registry\n * uses, so a kind is answerable here exactly when the engine ships geometry for\n * it — third-party kinds are absent by design (see {@link containsSpec}).\n */\nconst CONTAINS: Record<\n string,\n (spec: never, x: number, y: number, pad: number) => boolean\n> = {\n circle: containsCircle as never,\n ellipse: containsEllipse as never,\n rect: containsRect as never,\n 'tabbed-rect': containsTabbedRect as never,\n polygon: containsPolygon as never,\n 'regular-polygon': containsRegularPolygon as never,\n star: containsStar as never,\n arc: containsArc as never,\n path: containsPath as never,\n composite: containsComposite as never,\n};\n\n// ─── Internals ─────────────────────────────────────────────────────────────\n\n/** Containment against whichever shape a composite borrows for its silhouette. */\nfunction containsRootSpec(\n root: CompositeRootSpec,\n x: number,\n y: number,\n pad: number,\n): boolean {\n const band = strokeBandOf(root.stroke);\n const test = (p: number): boolean => {\n switch (root.kind) {\n case 'circle':\n return containsCircle(root, x, y, p);\n case 'ellipse':\n return containsEllipse(root, x, y, p);\n case 'polygon':\n return containsPolygon(root, x, y, p);\n case 'regular-polygon':\n return containsRegularPolygon(root, x, y, p);\n case 'star':\n return containsStar(root, x, y, p);\n case 'arc':\n return containsArc(root, x, y, p);\n default:\n return containsRect(root, x, y, p);\n }\n };\n return withHollowRule(test, hasSilhouetteFill(root.fill), pad + band.outer, band.inner);\n}\n\n/**\n * Apply the fill-less **hollow** rule to a padded containment test: filled\n * geometry answers for its whole grown silhouette; unfilled geometry answers\n * only inside the stroke band, i.e. grown-by-`outer` minus eroded-by-`inner`.\n */\nfunction withHollowRule(\n test: (pad: number) => boolean,\n filled: boolean,\n outer: number,\n inner: number,\n): boolean {\n if (filled) return test(outer);\n if (outer <= 0 && inner <= 0) return false;\n return test(outer) && !test(-inner);\n}\n\n/**\n * Half-width of a composite part's stroke — the distance it reaches past the\n * traced path. Parts are stroked with the backend's default centred alignment,\n * so half the width falls outside; an absent stroke reaches nowhere.\n */\nfunction partHalfStroke(stroke: { readonly width?: number } | undefined): number {\n if (!stroke) return 0;\n return Math.max(0, stroke.width ?? 1) / 2;\n}\n\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n\n/** Is `theta` inside `[a0, a1]`, allowing for sweeps that wrap past 2π? */\nfunction angleWithin(theta: number, a0: number, a1: number): boolean {\n // Bring θ into the same revolution as a0 so the comparison is unambiguous\n // across the 2π wrap (e.g. a sweep from 3π/2 to 5π/2 hitting θ ≈ 0.1).\n let n = Math.ceil((a0 - theta) / TAU);\n if (theta + n * TAU < a0) n++;\n const t = theta + n * TAU;\n return t >= a0 && t <= a1;\n}\n\n/** Squared distance to the sector's two straight radial edges. */\nfunction distanceToRadialEdgesSq(\n spec: LocalSpec<ArcSpec>,\n x: number,\n y: number,\n): number {\n const edge = (a: number): number => {\n const c = Math.cos(a);\n const s = Math.sin(a);\n return distanceToSegmentSq(\n x,\n y,\n c * spec.innerR,\n s * spec.innerR,\n c * spec.outerR,\n s * spec.outerR,\n );\n };\n return Math.min(edge(spec.startAngle), edge(spec.endAngle));\n}\n","/**\n * Spec geometry — bounds, scale, collapse, fit and containment, computed from a\n * spec and nothing else.\n *\n * This is the half of the old shape classes that was never really drawing: the\n * `static boundsOf` / `scaleSpec` / `collapsedOf` / `fitToContent` methods, plus\n * the new `contains`. They live here so a layout can size a node, an exporter\n * can trace a silhouette and a test can pick a shape with no backend mounted —\n * and so they stay in `@invana/canvas` when the pixi renderer is extracted\n * (`docs/renderer-split-design.md` §9, P4).\n *\n * The renderer-side shape classes now delegate to these functions; the maths\n * exists once.\n */\n\nexport * from './polygonMath';\nexport * from './tabbedRect';\nexport * from './bounds';\nexport * from './contains';\n\nimport type { Rect } from '../geometry';\nimport type { BaseShapeSpec } from '../shape';\nimport {\n boundsOfArc,\n boundsOfCircle,\n boundsOfComposite,\n boundsOfEllipse,\n boundsOfPath,\n boundsOfPolygon,\n boundsOfRect,\n boundsOfRegularPolygon,\n boundsOfStar,\n scaleArc,\n scaleCircle,\n scaleEllipse,\n scalePath,\n scalePolygon,\n scaleRect,\n scaleRegularPolygon,\n scaleStar,\n} from './bounds';\nimport {\n collapsedTabbedRect,\n fitTabbedRectToContent,\n scaleTabbedRect,\n tabbedRectBounds,\n} from './tabbedRect';\n\n/**\n * Local bounds of any built-in spec kind, or `undefined` for a kind this module\n * doesn't know.\n *\n * `undefined` is a real answer, not a failure: `registerShape` admits\n * third-party kinds, so callers that must cover those ask the registry (which\n * consults the class's `static boundsOf`) and fall back to a default box.\n */\nexport function boundsOfSpec(spec: BaseShapeSpec): Rect | undefined {\n switch (spec.kind) {\n case 'circle':\n return boundsOfCircle(spec as never);\n case 'ellipse':\n return boundsOfEllipse(spec as never);\n case 'rect':\n return boundsOfRect(spec as never);\n case 'tabbed-rect':\n return tabbedRectBounds(spec as never);\n case 'polygon':\n return boundsOfPolygon(spec as never);\n case 'regular-polygon':\n return boundsOfRegularPolygon(spec as never);\n case 'star':\n return boundsOfStar(spec as never);\n case 'arc':\n return boundsOfArc(spec as never);\n case 'path':\n return boundsOfPath(spec as never);\n case 'composite':\n return boundsOfComposite(spec as never);\n default:\n return undefined;\n }\n}\n\n/**\n * Uniformly scale a spec's geometry by `factor`, as a partial patch to merge\n * onto it. Paint is untouched — only lengths.\n *\n * The contract: `boundsOfSpec(scaleSpec(spec, k)).width === boundsOfSpec(spec).width * k`\n * (likewise height). `undefined` for kinds with no meaningful uniform scale\n * (`composite` sizes off its box and its parts, so scaling it needs the layer's\n * intent, not a geometric rule).\n */\nexport function scaleSpec(\n spec: BaseShapeSpec,\n factor: number,\n): Record<string, unknown> | undefined {\n switch (spec.kind) {\n case 'circle':\n return scaleCircle(spec as never, factor);\n case 'ellipse':\n return scaleEllipse(spec as never, factor);\n case 'rect':\n return scaleRect(spec as never, factor);\n case 'tabbed-rect':\n return scaleTabbedRect(spec as never, factor);\n case 'polygon':\n return scalePolygon(spec as never, factor);\n case 'regular-polygon':\n return scaleRegularPolygon(spec as never, factor);\n case 'star':\n return scaleStar(spec as never, factor);\n case 'arc':\n return scaleArc(spec as never, factor);\n case 'path':\n return scalePath(spec as never, factor);\n default:\n return undefined;\n }\n}\n\n/**\n * The spec \"as small as it goes\" — what a collapsed container renders as.\n * Purely geometric: the kind decides what collapsing means to it. `undefined`\n * when the kind has no collapsed form, and callers then keep the spec as is.\n */\nexport function collapsedSpec(\n spec: BaseShapeSpec,\n): Record<string, unknown> | undefined {\n return spec.kind === 'tabbed-rect' ? collapsedTabbedRect(spec as never) : undefined;\n}\n\n/**\n * Size the spec's geometry to a measured block of content (a title, a label).\n * The caller measures — text metrics belong to the backend — and the kind turns\n * that size into geometry. `undefined` when the kind doesn't size to content.\n */\nexport function fitSpecToContent(\n spec: BaseShapeSpec,\n content: { readonly width: number; readonly height: number },\n): Record<string, unknown> | undefined {\n return spec.kind === 'tabbed-rect'\n ? fitTabbedRectToContent(spec as never, content)\n : undefined;\n}\n","/**\n * Flush scheduling for the **non-reactive** data stores ({@link DataStore} /\n * {@link LayerData}). A write marks a dirty delta and *arms* a deferred flush; the\n * mode decides **when** that flush fires. The store never notifies per write — it\n * coalesces a whole batch into **one** flush (see `docs/canvas-store-data-event-flow.md` §2).\n */\n\n/** When a coalesced data flush fires. */\nexport type FlushMode =\n /** Next animation frame (browser). Falls back to `microtask` where no rAF exists (node/tests). */\n | 'frame'\n /** End of the current JS task — the kernel default (no DOM assumption, deterministic). */\n | 'microtask'\n /** Never auto-fires; the owner (e.g. the engine's single rAF loop) calls `flush()`. */\n | 'manual';\n\n// Feature-detect rAF so the renderer-free kernel makes no hard DOM assumption.\nconst raf: typeof requestAnimationFrame | undefined =\n typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;\nconst caf: typeof cancelAnimationFrame | undefined =\n typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;\n\n/**\n * Arm a deferred flush per `mode`, returning a **cancel** function (a no-op once the\n * callback has run or for modes that can't be cancelled). `'manual'` arms nothing.\n */\nexport function scheduleFlush(mode: FlushMode, cb: () => void): () => void {\n if (mode === 'manual') return () => {};\n if (mode === 'frame' && raf && caf) {\n const handle = raf(() => cb());\n return () => caf(handle);\n }\n // microtask — and the `frame` fallback when no rAF is present (node / tests)\n let cancelled = false;\n queueMicrotask(() => {\n if (!cancelled) cb();\n });\n return () => {\n cancelled = true;\n };\n}\n","/**\n * `SpecStore` — the durable **visual description** of one layer's elements.\n *\n * A spec says *what to draw* (`{ kind: 'circle', radius, fill, plane }`) and\n * contains no drawing code. Layers resolve style + templates into specs and\n * publish them here; renderers subscribe and project. That inversion is the\n * point: two backends reading one description cannot disagree about intent, and\n * the description is serialisable, diffable and testable without a GPU.\n *\n * **Generic over `T`, though it no longer has to be.** The vocabulary now sits\n * beside this file (`./index`), so this store *could* name its own element types.\n * It stays generic deliberately: nothing needs the narrowing, and a concrete\n * signature would ripple through `SpecProjector` and `GraphLayer` for no new\n * capability. The engine instantiates it as\n * `SpecStore<BaseShapeSpec | BaseConnectorSpec>`.\n *\n * **What does *not* live here:** positions. Those stay in {@link LayerData}'s\n * typed arrays on the machine-rate path — a drag frame moves nodes without\n * touching a single spec. And transient visuals (lasso, brush, drag ghosts) never\n * enter the store at all; they are drawn through the renderer's overlay device,\n * so gesture noise stays out of history, undo and saved files.\n *\n * Writes mark a dirty delta and arm a coalesced flush — the same contract as\n * {@link LayerData}, so both channels settle in the same frame.\n *\n * See `docs/renderer-split-design.md` §2 (specs as state) and §4.2b (the channel).\n */\n\nimport { scheduleFlush, type FlushMode } from '../state/data/flush';\n\n/**\n * One coalesced batch of spec changes. Ids only — the receiver reads the specs\n * it cares about, so a flush stays O(dirty) regardless of collection size.\n */\nexport interface SpecFlush {\n readonly added: readonly string[];\n readonly changed: readonly string[];\n readonly removed: readonly string[];\n /** Monotonic, per store. Lets a consumer detect a missed batch. */\n readonly version: number;\n}\n\nexport class SpecStore<T extends object = object> {\n private readonly specs = new Map<string, T>();\n private readonly added = new Set<string>();\n private readonly changed = new Set<string>();\n private readonly removed = new Set<string>();\n private readonly listeners = new Set<(e: SpecFlush) => void>();\n private version = 0;\n private scheduled = false;\n private flushMode: FlushMode = 'microtask';\n private cancel: (() => void) | undefined;\n\n // ── Reads ──────────────────────────────────────────────────────────────────\n\n get(id: string): T | undefined {\n return this.specs.get(id);\n }\n\n has(id: string): boolean {\n return this.specs.has(id);\n }\n\n get size(): number {\n return this.specs.size;\n }\n\n ids(): IterableIterator<string> {\n return this.specs.keys();\n }\n\n entries(): IterableIterator<[string, T]> {\n return this.specs.entries();\n }\n\n // ── Writes ─────────────────────────────────────────────────────────────────\n\n /** Publish (or replace) the spec for `id`. */\n set(id: string, spec: T): void {\n const existed = this.specs.has(id);\n this.specs.set(id, spec);\n if (existed) {\n this.removed.delete(id);\n // An id added and then re-set before the flush is still just \"added\".\n if (!this.added.has(id)) this.changed.add(id);\n } else {\n this.added.add(id);\n this.removed.delete(id);\n }\n this.schedule();\n }\n\n /**\n * Shallow-merge `partial` over the stored spec. Returns `false` when `id` is\n * unknown, so a caller can fall back to {@link set} with a full spec.\n */\n patch(id: string, partial: Partial<T>): boolean {\n const current = this.specs.get(id);\n if (!current) return false;\n this.specs.set(id, { ...current, ...partial });\n if (!this.added.has(id)) this.changed.add(id);\n this.schedule();\n return true;\n }\n\n delete(id: string): void {\n if (!this.specs.delete(id)) return;\n this.changed.delete(id);\n // Added-then-removed before a flush is a net no-op: the receiver never saw it.\n if (!this.added.delete(id)) this.removed.add(id);\n this.schedule();\n }\n\n /** Drop every spec. Emits one flush listing all ids as removed. */\n clear(): void {\n for (const id of this.specs.keys()) {\n if (!this.added.delete(id)) this.removed.add(id);\n }\n this.specs.clear();\n this.changed.clear();\n this.schedule();\n }\n\n // ── Flush ──────────────────────────────────────────────────────────────────\n\n onFlush(listener: (e: SpecFlush) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Choose **when** a coalesced flush fires. `'manual'` disarms auto-flush so the\n * engine's single rAF drives it — which is how the renderer stays on one clock.\n */\n setFlushMode(mode: FlushMode): void {\n this.flushMode = mode;\n if (mode === 'manual' && this.scheduled) {\n this.cancel?.();\n this.scheduled = false;\n }\n }\n\n /** Emit the pending delta, if any. Safe to call when nothing is dirty. */\n flush(): void {\n this.scheduled = false;\n if (this.added.size === 0 && this.changed.size === 0 && this.removed.size === 0) return;\n const event: SpecFlush = {\n added: [...this.added],\n changed: [...this.changed],\n removed: [...this.removed],\n version: ++this.version,\n };\n this.added.clear();\n this.changed.clear();\n this.removed.clear();\n for (const listener of this.listeners) listener(event);\n }\n\n private schedule(): void {\n if (this.scheduled || this.flushMode === 'manual') return;\n this.scheduled = true;\n this.cancel = scheduleFlush(this.flushMode, () => this.flush());\n }\n}\n"]}