@weasel-js/geom 1.11.1 → 1.13.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/booleans/index.js +2 -2
- package/dist/{chunk-EAKE3N7W.js → chunk-2PKPKU4P.js} +178 -178
- package/dist/chunk-2PKPKU4P.js.map +1 -0
- package/dist/{chunk-6FGQML7D.js → chunk-STGSBIOL.js} +3 -3
- package/dist/{chunk-6FGQML7D.js.map → chunk-STGSBIOL.js.map} +1 -1
- package/dist/{chunk-LRVPK7HI.js → chunk-UGE57OTX.js} +3 -3
- package/dist/{chunk-LRVPK7HI.js.map → chunk-UGE57OTX.js.map} +1 -1
- package/dist/{chunk-7F66PQCJ.js → chunk-VHXOCDZ2.js} +3 -3
- package/dist/{chunk-7F66PQCJ.js.map → chunk-VHXOCDZ2.js.map} +1 -1
- package/dist/{chunk-4Y67BZL5.js → chunk-YPWFGFQX.js} +3 -3
- package/dist/{chunk-4Y67BZL5.js.map → chunk-YPWFGFQX.js.map} +1 -1
- package/dist/index.d.ts +262 -56
- package/dist/index.js +663 -180
- package/dist/index.js.map +1 -1
- package/dist/nd/index.d.ts +40 -1
- package/dist/nd/index.js +681 -1
- package/dist/nd/index.js.map +1 -1
- package/dist/tessellate/index.js +3 -3
- package/dist/warp/index.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-EAKE3N7W.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/view.ts","../src/affine.ts","../src/portCurve2.ts","../src/pathSubpaths.ts","../src/screenBand.ts","../src/pathHitTest.ts","../src/paths/cornerOffset.ts","../src/paths/unionBoundsPath.ts","../src/paths/transformPath.ts","../src/paths/transform.ts","../src/paths/compose.ts","../src/paths/splitSubpaths.ts","../src/paths/splitByClosure.ts","../src/paths/winding.ts","../src/paths/pathFromD.ts","../src/paths/pathToD.ts","../src/paths/pathMeasure.ts","../src/paths/pathAt.ts","../src/paths/cubicContours.ts","../src/paths/blendPaths.ts","../src/paths/bendAlongPath.ts","../src/paths/repeatAlongPath.ts","../src/paths/pathDistance.ts","../src/intersect/segmentIntersections.ts","../src/intersect/pathSegments.ts","../src/intersect/pathCrossings.ts","../src/paths/segmentLength.ts","../src/snap/segmentFeatures.ts","../src/snap/pathSnap.ts","../src/intersect/writeSubpaths.ts","../src/paths/trimPath.ts","../src/paths/pathAwayFromAnchors.ts","../src/paths/anchorOrigins.ts","../src/pxExtent.ts","../src/paths/spanFit.ts","../src/paths/anchorEdits.ts","../src/paths/lengthenPathEnd.ts","../src/paths/extendPath.ts","../src/paths/simplifyPath.ts","../src/paths/growRegion.ts","../src/paths/segmentCrossings.ts","../src/paths/mergeRegion.ts","../src/paths/simplifyAnchors.ts","../src/paths/arcRun.ts","../src/paths/resamplePath.ts","../src/paths/extremaAnchors.ts","../src/paths/anchorSelection.ts","../src/paths/joinAnchors.ts","../src/affineFit.ts","../src/paths/markers.ts","../src/glMat3.ts","../src/viewToMat3.ts","../src/place.ts","../src/easings.ts","../src/easingSpec.ts","../src/meanScale.ts","../src/poseRotation.ts","../src/poseFrame.ts","../src/paths/anchorBrush.ts","../src/paths/anchorSymmetry.ts","../src/paths/bendSegment.ts","../src/paths/smudgePath.ts","../src/paths/handleEdits.ts","../src/paths/softSelection.ts","../src/paths/balanceHandles.ts","../src/paths/harmonize.ts","../src/paths/anchorValues.ts","../src/constraints/types.ts","../src/constraints/residuals.ts","../src/constraints/points.ts","../src/constraints/check.ts","../src/constraints/sparse.ts","../src/constraints/solve.ts","../src/constraints/pathConstraints.ts","../src/constraints/pathsEdit.ts","../src/constraints/conflicts.ts","../src/paths/nearestAnchor.ts","../src/paths/pathStructure.ts","../src/paths/segmentType.ts","../src/paths/anchorFields.ts","../src/paths/pathInWorld.ts","../src/typedArrayJson.ts"],"names":["dx","dy","portControls","portCurvePoints","sub","neg","winding","run","sign","at","moved","scaled","emit","reversed","num","dot","measure","offset","rotate","stretch","along","EPS","worst","GL_W","length","near","segs","n","held","scale","normal","segmentAt","a","b","MAX_DEPTH","startTangent","cross","segmentsCross","unit","END","flatten","boxOf","refine","s","t","derivative","snap","keepCorners","starts","reverseInPlace","identity","multiply","invert","linear","len2","apply","other","same","segmentControls","lerp","crossing","neighbors","collapsed","anchorOfPoint"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBO,IAAM,UAAA,GAAa;AAOnB,SAAS,cAAc,IAAA,EAAsB;AAClD,EAAA,OAAO,IAAA,IAAQ,UAAA,IAAc,IAAA,GAAO,QAAA,GAAW,IAAA,GAAO,UAAA;AACxD;;;ACfO,SAAS,QAAA,GAAmB;AACjC,EAAA,OAAO,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAC,CAAA;AAC1B;AAGO,SAAS,SAAA,CAAU,IAAY,EAAA,EAAoB;AACxD,EAAA,OAAO,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,IAAI,EAAE,CAAA;AAC5B;AAIO,SAAS,KAAA,CAAM,IAAY,EAAA,EAAoB;AACpD,EAAA,OAAO,CAAC,EAAA,EAAI,CAAA,EAAG,CAAA,EAAG,EAAA,EAAI,GAAG,CAAC,CAAA;AAC5B;AAIO,SAAS,OAAO,GAAA,EAAqB;AAC1C,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACtB,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACtB,EAAA,OAAO,CAAC,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,CAAA,EAAG,GAAG,CAAC,CAAA;AAC3B;AAGO,SAAS,QAAA,CAAS,GAAW,CAAA,EAAmB;AACrD,EAAA,OAAO;AAAA,IACL,CAAA,CAAE,CAAC,CAAA,GAAI,CAAA,CAAE,CAAC,IAAI,CAAA,CAAE,CAAC,CAAA,GAAI,CAAA,CAAE,CAAC,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,EAAG,IAAI,CAAC,CAAA;AAClE,EAAA,IAAI,CAAC,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA;AAC5B,EAAA,MAAM,MAA+B,EAAC;AACtC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG,GAAA,CAAI,GAAG,CAAA,GAAI,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,EAAG,IAAI,CAAA;AACzE,EAAA,OAAO,GAAA;AACT;AAOO,SAAS,eAAe,KAAA,EAAyB;AACtD,EAAA,OAAO,OAAA,CAAQ,OAAO,aAAa,CAAA;AACrC;AAIO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,OAAO,OAAA,CAAQ,OAAO,eAAe,CAAA;AACvC;AAGO,SAAS,kBAAA,CAAmB,MAAc,KAAA,EAAyB;AACxE,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,IAAK,KAAA;AACjC","file":"index.js","sourcesContent":["/**\n * Viewport state. `(view.x, view.y)` is the world point currently rendered at\n * the canvas top-left; `view.scale.x` / `view.scale.y` is pixels per world\n * unit on each axis.\n *\n * A `View` names no orientation, so a kernel with a camera cannot express its\n * viewport as one.\n */\nexport interface View {\n x: number;\n y: number;\n scale: { x: number; y: number };\n}\n\n/**\n * The smallest zoom magnitude a view can hold, in `View.scale` units.\n *\n * A view's zoom is always finite and at least this far from 0. Nothing can be\n * drawn or picked through a zoom of 0, and every screen↔world conversion\n * divides by it, so it is ruled out where views are made rather than handled\n * by each conversion.\n */\nexport const ZOOM_FLOOR = 1e-9;\n\n/**\n * The one rule for a zoom magnitude: a finite number no smaller than\n * {@link ZOOM_FLOOR}. Anything else (0, negative, NaN, ±Infinity) becomes the\n * floor.\n */\nexport function normalizeZoom(zoom: number): number {\n return zoom >= ZOOM_FLOOR && zoom < Infinity ? zoom : ZOOM_FLOOR;\n}\n","/**\n * 2D affine transforms in canvas/DOMMatrix order: [a, b, c, d, e, f].\n * x' = a·x + c·y + e\n * y' = b·x + d·y + f\n * Represented as a readonly 6-tuple (f64). The affine tier of the kernel.\n *\n * `glMat3.ts` beside this file holds the renderer's matrix: a 9-element\n * column-major array (a full 3×3) laid out for `uniformMatrix3fv`. Its\n * *logical element order* is identical to ours.\n */\nimport { SINGULAR_RATIO } from './scalar';\n\n/** `[a, b, c, d, e, f]`: `x' = a·x + c·y + e`, `y' = b·x + d·y + f`. */\nexport type Affine = readonly [number, number, number, number, number, number];\n\n/** The transform that leaves a point where it is. */\nexport function identity(): Affine {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/** A pure translation by `(tx, ty)`. */\nexport function translate(tx: number, ty: number): Affine {\n return [1, 0, 0, 1, tx, ty];\n}\n\n/** A pure scale about the origin. Scale about another point by composing\n * translate → scale → inverse translate with `multiply`. */\nexport function scale(sx: number, sy: number): Affine {\n return [sx, 0, 0, sy, 0, 0];\n}\n\n/** A pure rotation about the origin, in radians, clockwise in canvas\n * coordinates (y down). */\nexport function rotate(rad: number): Affine {\n const c = Math.cos(rad);\n const s = Math.sin(rad);\n return [c, s, -s, c, 0, 0];\n}\n\n/** Compose: result applies `n` first, then `m` (m·n). */\nexport function multiply(m: Affine, n: Affine): Affine {\n return [\n m[0] * n[0] + m[2] * n[1],\n m[1] * n[0] + m[3] * n[1],\n m[0] * n[2] + m[2] * n[3],\n m[1] * n[2] + m[3] * n[3],\n m[0] * n[4] + m[2] * n[5] + m[4],\n m[1] * n[4] + m[3] * n[5] + m[5],\n ];\n}\n\n/** Inverse, or null when the matrix is singular, non-finite, or too\n * ill-conditioned to invert meaningfully at its own scale. */\nexport function invert(m: Affine): Affine | null {\n const det = m[0] * m[3] - m[1] * m[2];\n // The determinant is an area, so it is judged against the squared column norms.\n const norm2 = Math.max(m[0] * m[0] + m[1] * m[1], m[2] * m[2] + m[3] * m[3]);\n // Negated so a non-finite determinant falls out as singular.\n if (!(Math.abs(det) > SINGULAR_RATIO * norm2)) return null;\n const id = 1 / det;\n const a = m[3] * id;\n const b = -m[1] * id;\n const c = -m[2] * id;\n const d = m[0] * id;\n return [a, b, c, d, -(m[4] * a + m[5] * c), -(m[4] * b + m[5] * d)];\n}\n\n/** Apply to a point, returning a tuple. Cold-path use; hot loops inline. */\nexport function applyToPoint(m: Affine, x: number, y: number): [number, number] {\n return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];\n}\n\n/** Affine that maps source box (sx,sy,sw,sh) onto destination box (dx,dy,dw,dh). */\nexport function boxToBox(\n sx: number, sy: number, sw: number, sh: number,\n dx: number, dy: number, dw: number, dh: number,\n): Affine {\n const kx = sw === 0 ? 1 : dw / sw;\n const ky = sh === 0 ? 1 : dh / sh;\n // translate(dx,dy) · scale(kx,ky) · translate(-sx,-sy)\n return [kx, 0, 0, ky, dx - sx * kx, dy - sy * ky];\n}\n\n/** Rotation by `rad` about pivot (cx,cy): translate(c)·rotate·translate(-c). */\nexport function rotateAboutPoint(cx: number, cy: number, rad: number): Affine {\n return multiply(translate(cx, cy), multiply(rotate(rad), translate(-cx, -cy)));\n}\n\n/**\n * Apply an affine to an interleaved coord stream, returning a fresh f64\n * buffer. Command codes are unaffected — for a Bezier the transformed control\n * points define the transformed curve exactly (affine invariance), so callers\n * pass `path.coords` straight through and keep `path.commands` as-is.\n */\nexport function transformCoords(coords: ArrayLike<number>, m: Affine): Float64Array {\n const out = new Float64Array(coords.length);\n const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];\n for (let i = 0; i + 1 < coords.length; i += 2) {\n const x = coords[i], y = coords[i + 1];\n out[i] = a * x + c * y + e;\n out[i + 1] = b * x + d * y + f;\n }\n return out;\n}\n","/**\n * The port-curve rule in the 2D kernel's currency: loose scalars, the way\n * `cubicEvalAt` and `applyToPoint` take them. The rule itself lives in\n * `./portCurve`, stated once over components, so this and `./3d` cannot drift.\n */\n\nimport {\n PORT_REACH,\n portControls as portControlsN,\n portCurvePoints as portCurvePointsN,\n} from './portCurve';\n\nexport { PORT_REACH };\n\n/**\n * `[c1, c2]` for the cubic from `(ax, ay)` to `(bx, by)`.\n *\n * A null normal falls back to a lerp along the chord. See `./portCurve` for why\n * the two ends are not symmetric.\n */\nexport function portControls(\n ax: number,\n ay: number,\n bx: number,\n by: number,\n outNormal: readonly [number, number] | null | undefined,\n inNormal: readonly [number, number] | null | undefined,\n reach: number = PORT_REACH,\n): [[number, number], [number, number]] {\n const [c1, c2] = portControlsN([ax, ay], [bx, by], outNormal, inNormal, reach);\n return [\n [c1[0]!, c1[1]!],\n [c2[0]!, c2[1]!],\n ];\n}\n\n/** A port curve sampled into `samples` points, excluding its start. */\nexport function portCurvePoints(\n ax: number,\n ay: number,\n bx: number,\n by: number,\n outNormal: readonly [number, number] | null | undefined,\n inNormal: readonly [number, number] | null | undefined,\n samples: number,\n reach: number = PORT_REACH,\n): [number, number][] {\n return portCurvePointsN([ax, ay], [bx, by], outNormal, inNormal, samples, reach).map(\n (p) => [p[0]!, p[1]!],\n );\n}\n","/**\n * A path flattened into runs of points, sorted by whether each subpath\n * encloses area: what the hit tests in `pathHitTest.ts` walk.\n */\nimport { forEachSegment, PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from './commands';\nimport { DEFAULT_FLATTEN_TOLERANCE, flattenCubic, flattenQuadratic } from './flatten';\nimport { fillsOpenSubpaths } from './openFill';\nimport type { PolygonPath } from './path';\nimport { resolveCorners } from './paths/corners';\n\n/**\n * `path` flattened to interleaved `[x, y, …]` runs, sorted by whether each\n * subpath encloses area. A `Z` closing fewer than three points yields an open\n * run, as does any subpath a `Z` never ends. The closing edge of a closed run\n * back to its first vertex is implicit. Corner shapes are walked expanded.\n */\nexport function flatSubpaths(\n path: PolygonPath,\n tolerance: number,\n): { closed: number[][]; open: number[][] } {\n const { commands, coords } = resolveCorners(path);\n const closed: number[][] = [];\n const open: number[][] = [];\n let sub: number[] = [];\n\n forEachSegment(commands, coords, (cmd, ci, curX, curY, _i, opensSubpath) => {\n if (opensSubpath) sub = [curX, curY];\n switch (cmd) {\n case PATH_M:\n if (sub.length >= 2) open.push(sub);\n sub = [coords[ci], coords[ci + 1]];\n break;\n case PATH_L:\n sub.push(coords[ci], coords[ci + 1]);\n break;\n case PATH_C:\n flattenCubic(\n curX, curY,\n coords[ci], coords[ci + 1],\n coords[ci + 2], coords[ci + 3],\n coords[ci + 4], coords[ci + 5],\n tolerance, sub,\n );\n break;\n case PATH_Q:\n flattenQuadratic(\n curX, curY,\n coords[ci], coords[ci + 1],\n coords[ci + 2], coords[ci + 3],\n tolerance, sub,\n );\n break;\n case PATH_Z:\n if (sub.length >= 6) closed.push(sub);\n else if (sub.length >= 2) open.push(sub);\n sub = [];\n break;\n default:\n throw new Error(`pathHitTest: unknown command ${cmd}`);\n }\n });\n if (sub.length >= 2) open.push(sub);\n return { closed, open };\n}\n\n/** `flatSubpaths`, with each open run a fill closes moved among the closed. */\nexport function regionSubpaths(\n path: PolygonPath,\n opts: { tolerance?: number },\n): { closed: number[][]; open: number[][] } {\n const flat = flatSubpaths(path, opts.tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n if (!fillsOpenSubpaths(path)) return flat;\n return {\n closed: [...flat.closed, ...flat.open.filter((sub) => sub.length >= 6)],\n open: flat.open.filter((sub) => sub.length < 6),\n };\n}\n\nexport function closedSubpaths(path: PolygonPath, opts: { tolerance?: number }): number[][] {\n return regionSubpaths(path, opts).closed;\n}\n","/**\n * Is a point within `px` screen pixels of a world-space stroke band?\n *\n * The band is a capsule of radius `r` around each segment, in the frame the\n * path lives in; `m` is the linear part of that frame's map to the screen.\n * Under a similarity the answer is a plain world distance, `r + px / scale`.\n * Under anything else the capsule lands on screen as a parallelogram capped by\n * two ellipses, and the pixel slop has to be measured against that shape:\n * neither a scalar nor a per-axis world tolerance describes it.\n */\nimport { pointSegmentDist2 } from './polyline';\n\n/** Linear part of a map to the screen: `x' = a·x + c·y`, `y' = b·x + d·y`. */\nexport interface Linear2 {\n a: number; b: number; c: number; d: number;\n}\n\n/** A linear map's singular decomposition, as much of it as the band test\n * needs: the two stretch factors, and the screen-space angle of the first. */\nexport interface Stretch {\n s1: number;\n s2: number;\n /** Angle of the first singular direction on screen. */\n phi: number;\n}\n\nexport function stretchOf(m: Linear2): Stretch {\n // Closed-form 2×2 SVD. M = R(phi) · diag(Q + R, Q − R) · R(theta).\n const e = (m.a + m.d) / 2;\n const f = (m.a - m.d) / 2;\n const g = (m.b + m.c) / 2;\n const h = (m.b - m.c) / 2;\n const q = Math.hypot(e, h);\n const r = Math.hypot(f, g);\n const phi = (Math.atan2(h, e) + Math.atan2(g, f)) / 2;\n return { s1: q + r, s2: Math.abs(q - r), phi };\n}\n\n/** True when the map scales every direction alike, so a screen length is one\n * world length. */\nexport function isSimilarity(s: Stretch): boolean {\n return s.s1 - s.s2 <= 1e-9 * s.s1;\n}\n\n/**\n * Screen point `(px0, py0)` against the image of one world capsule\n * `(ax, ay)–(bx, by)`, radius `r`, grown by `slop` pixels. `m`/`st` map world\n * to screen (linear part only — every point shares the translation).\n */\nexport function capsuleWithinPx(\n px0: number, py0: number,\n ax: number, ay: number, bx: number, by: number,\n r: number, slop: number,\n m: Linear2, st: Stretch,\n): boolean {\n const sax = m.a * ax + m.c * ay, say = m.b * ax + m.d * ay;\n const sbx = m.a * bx + m.c * by, sby = m.b * bx + m.d * by;\n const slop2 = slop * slop;\n const dCenter2 = pointSegmentDist2(px0, py0, sax, say, sbx, sby);\n if (dCenter2 <= slop2) return true;\n if (r <= 0) return false;\n // Nothing in the band is farther from the centerline than r·s1 on screen.\n const reach = slop + r * st.s1;\n if (dCenter2 > reach * reach) return false;\n\n // The parallelogram: the capsule's straight part, carried to the screen.\n const wx = bx - ax, wy = by - ay;\n const wl = Math.hypot(wx, wy);\n if (wl > 0) {\n const nx = (-wy / wl) * r, ny = (wx / wl) * r;\n const ox = m.a * nx + m.c * ny, oy = m.b * nx + m.d * ny;\n if (quadWithinPx(px0, py0, [\n sax + ox, say + oy, sbx + ox, sby + oy,\n sbx - ox, sby - oy, sax - ox, say - oy,\n ], slop2)) return true;\n }\n // The round caps: each end's disk lands on screen as an ellipse.\n return ellipseWithinPx(px0 - sax, py0 - say, r, slop, st)\n || ellipseWithinPx(px0 - sbx, py0 - sby, r, slop, st);\n}\n\n/** Inside a convex quad, or within `sqrt(slop2)` of one of its edges. */\nfunction quadWithinPx(x: number, y: number, q: readonly number[], slop2: number): boolean {\n let pos = 0, neg = 0;\n for (let i = 0; i < 8; i += 2) {\n const j = (i + 2) % 8;\n const cr = (q[j] - q[i]) * (y - q[i + 1]) - (q[j + 1] - q[i + 1]) * (x - q[i]);\n if (cr > 0) pos++;\n else if (cr < 0) neg++;\n }\n if (pos === 0 || neg === 0) return true;\n for (let i = 0; i < 8; i += 2) {\n const j = (i + 2) % 8;\n if (pointSegmentDist2(x, y, q[i], q[i + 1], q[j], q[j + 1]) <= slop2) return true;\n }\n return false;\n}\n\n/** `(dx, dy)` from the center of the filled ellipse `M(disk r)`, within `slop`? */\nfunction ellipseWithinPx(dx: number, dy: number, r: number, slop: number, st: Stretch): boolean {\n const cos = Math.cos(st.phi), sin = Math.sin(st.phi);\n const u = Math.abs(cos * dx + sin * dy);\n const v = Math.abs(-sin * dx + cos * dy);\n const e0 = r * st.s1, e1 = r * st.s2;\n if (e1 <= 0) {\n // Collapsed to a segment along the first axis.\n const over = Math.max(0, u - e0);\n return over * over + v * v <= slop * slop;\n }\n return distToEllipse(e0, e1, u, v) <= slop;\n}\n\n/**\n * Distance from `(y0, y1)`, first quadrant, to the filled axis-aligned ellipse\n * with semi-axes `e0 >= e1 > 0`. Eberly, \"Distance from a Point to an\n * Ellipse\" — bisection on the Lagrange root, robust near the axes.\n */\nfunction distToEllipse(e0: number, e1: number, y0: number, y1: number): number {\n const z0 = y0 / e0, z1 = y1 / e1;\n const g = z0 * z0 + z1 * z1 - 1;\n if (g <= 0) return 0;\n if (y1 > 0) {\n if (y0 > 0) {\n const r0 = (e0 / e1) * (e0 / e1);\n const n0 = r0 * z0;\n let s0 = z1 - 1;\n let s1 = Math.hypot(n0, z1) - 1;\n let s = 0;\n for (let i = 0; i < 100; i++) {\n s = (s0 + s1) / 2;\n if (s === s0 || s === s1) break;\n const a = n0 / (s + r0), b = z1 / (s + 1);\n const gs = a * a + b * b - 1;\n if (gs > 0) s0 = s;\n else if (gs < 0) s1 = s;\n else break;\n }\n const x0 = (r0 * y0) / (s + r0);\n const x1 = y1 / (s + 1);\n return Math.hypot(x0 - y0, x1 - y1);\n }\n return y1 - e1;\n }\n const numer = e0 * y0, denom = e0 * e0 - e1 * e1;\n if (numer < denom) {\n const t = numer / denom;\n const x0 = e0 * t, x1 = e1 * Math.sqrt(1 - t * t);\n return Math.hypot(x0 - y0, x1);\n }\n return y0 - e0;\n}\n","/**\n * Path hit-testing: path-vs-point (filled region and stroke distance),\n * path-vs-rect, and path-vs-polygon in both directions.\n *\n * A `rect` path short-circuits to AABB arithmetic. A `polygon` path is its\n * filled region: beziers are flattened, `fillRule` is honored (default\n * `nonzero`), and every closed subpath counts — the hole of a donut is not\n * part of the shape under `evenodd`. An open subpath counts as closed where a\n * fill closes it and encloses nothing where one does not: see\n * `fillsOpenSubpaths`.\n */\n\nimport { DEFAULT_FLATTEN_TOLERANCE } from './flatten';\nimport { pointInPolygon, pointSegmentDist2, segmentsCross } from './polyline';\nimport type { Rect } from './box';\nimport type { Path } from './path';\nimport { closedSubpaths, flatSubpaths, regionSubpaths } from './pathSubpaths';\nimport type { Affine } from './affine';\nimport type { Point } from './paths/cubicMath';\nimport { capsuleWithinPx, isSimilarity, stretchOf, type Linear2 } from './screenBand';\n\n\n/** Options for the path hit-tests. */\nexport interface PointInPathOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n}\n\n/** Options for {@link polygonIntersectsPath}. */\nexport interface PolygonIntersectsPathOptions extends PointInPathOptions {\n /** False when nothing paints the path's interior: only its outline can meet\n * the polygon, and a polygon lying wholly inside meets nothing. Default true. */\n filled?: boolean;\n}\n\n/** Options for {@link strokeHitTest}. */\nexport interface StrokeHitTestOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n /** Extra reach past the band measured in screen pixels rather than world\n * units: `px` pixels, after `transform` carries the path's frame to the\n * screen (only its linear part matters). A pointer's forgiveness is a\n * screen distance, and under a non-uniform or rotated-then-squished\n * transform no world distance equals it. */\n slop?: { px: number; transform: Affine };\n}\n\n// ─── Point vs path ──────────────────────────────────────────────────────────\n\n/** Filled-region hit-test for a path. Rect short-circuits to AABB; polygons run ray-cast / winding per `fillRule`. */\nexport function pointInPath(\n path: Path,\n x: number,\n y: number,\n opts: PointInPathOptions = {},\n): boolean {\n if (path.kind === 'rect') {\n return x >= path.x && x <= path.x + path.width && y >= path.y && y <= path.y + path.height;\n }\n let crossings = 0;\n let winding = 0;\n for (const sub of closedSubpaths(path, opts)) {\n const n = sub.length;\n for (let i = 0; i < n; i += 2) {\n const j = (i + 2) % n;\n const ay = sub[i + 1], by = sub[j + 1];\n if ((ay > y) === (by > y)) continue;\n const ax = sub[i], bx = sub[j];\n if (x >= ax + ((y - ay) / (by - ay)) * (bx - ax)) continue;\n crossings++;\n winding += ay <= y ? 1 : -1;\n }\n }\n return path.fillRule === 'evenodd' ? (crossings & 1) === 1 : winding !== 0;\n}\n\n/**\n * Stroke-distance hit-test. True when (x, y) lies within `threshold` world\n * units of the path's outline — when a stroke of total width `2 * threshold`\n * drawn along the path would cover the point. Works for open and closed\n * subpaths alike; OR it with {@link pointInPath} for fill-plus-stroke picking.\n * Every flattened segment is treated as a capsule of radius `threshold`.\n */\nexport function strokeHitTest(\n path: Path,\n x: number,\n y: number,\n threshold: number,\n opts: StrokeHitTestOptions = {},\n): boolean {\n const slop = opts.slop;\n if (slop && slop.px > 0) {\n const [a, b, c, d] = slop.transform;\n const m: Linear2 = { a, b, c, d };\n const st = stretchOf(m);\n // A view collapsed to a point shows nothing to hit, and a pixel there is no world length.\n if (st.s1 === 0) return false;\n if (isSimilarity(st)) {\n return strokeHitTest(path, x, y, threshold + slop.px / st.s1, { tolerance: opts.tolerance });\n }\n const sx = a * x + c * y, sy = b * x + d * y;\n return someSegment(path, opts.tolerance, (ax, ay, bx, by) =>\n capsuleWithinPx(sx, sy, ax, ay, bx, by, threshold, slop.px, m, st));\n }\n const t2 = threshold * threshold;\n return someSegment(path, opts.tolerance, (ax, ay, bx, by) =>\n pointSegmentDist2(x, y, ax, ay, bx, by) <= t2);\n}\n\n/** Does `visit` answer true for any outline segment — every edge of a rect,\n * closing edges of closed subpaths included? */\nfunction someSegment(\n path: Path,\n tolerance: number | undefined,\n visit: (ax: number, ay: number, bx: number, by: number) => boolean,\n): boolean {\n if (path.kind === 'rect') {\n const { x: rx, y: ry, width: w, height: h } = path;\n return visit(rx, ry, rx + w, ry) || visit(rx + w, ry, rx + w, ry + h)\n || visit(rx + w, ry + h, rx, ry + h) || visit(rx, ry + h, rx, ry);\n }\n const { closed, open } = flatSubpaths(path, tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n const run = (sub: readonly number[], wrap: boolean): boolean => {\n const n = sub.length;\n const last = wrap ? n : n - 2;\n for (let i = 0; i < last; i += 2) {\n const j = (i + 2) % n;\n if (visit(sub[i], sub[i + 1], sub[j], sub[j + 1])) return true;\n }\n return false;\n };\n return closed.some((sub) => run(sub, true)) || open.some((sub) => run(sub, false));\n}\n\n// ─── Region vs path ─────────────────────────────────────────────────────────\n\nfunction rectToVerts(r: Rect): Point[] {\n return [\n { x: r.x, y: r.y },\n { x: r.x + r.width, y: r.y },\n { x: r.x + r.width, y: r.y + r.height },\n { x: r.x, y: r.y + r.height },\n ];\n}\n\n/** Flatten a vertex array into an interleaved [x0,y0,x1,y1,...] array. */\nfunction flattenVerts(poly: readonly Point[]): number[] {\n const flat: number[] = new Array(poly.length * 2);\n for (let i = 0; i < poly.length; i++) {\n flat[i * 2] = poly[i].x;\n flat[i * 2 + 1] = poly[i].y;\n }\n return flat;\n}\n\n/** Edge-vs-edge segment intersection check between two closed polygons. */\nfunction polygonsIntersect(a: readonly Point[], b: readonly Point[]): boolean {\n if (a.length === 0 || b.length === 0) return false;\n if (pointInPolygon(flattenVerts(a), b[0].x, b[0].y)) return true;\n if (pointInPolygon(flattenVerts(b), a[0].x, a[0].y)) return true;\n for (let i = 0; i < a.length; i++) {\n const a0 = a[i], a1 = a[(i + 1) % a.length];\n for (let j = 0; j < b.length; j++) {\n const b0 = b[j], b1 = b[(j + 1) % b.length];\n if (segmentsCross(a0.x, a0.y, a1.x, a1.y, b0.x, b0.y, b1.x, b1.y)) return true;\n }\n }\n return false;\n}\n\n/** Run `visit` over every edge of every closed subpath until it answers true. */\nfunction anyEdge(\n subpaths: readonly number[][],\n visit: (ax: number, ay: number, bx: number, by: number) => boolean,\n): boolean {\n for (const sub of subpaths) {\n const n = sub.length;\n for (let i = 0; i < n; i += 2) {\n const j = (i + 2) % n;\n if (visit(sub[i], sub[i + 1], sub[j], sub[j + 1])) return true;\n }\n }\n return false;\n}\n\nfunction anyEdgeCrossesRect(subpaths: readonly number[][], r: Rect): boolean {\n const x0 = r.x, y0 = r.y, x1 = r.x + r.width, y1 = r.y + r.height;\n return anyEdge(subpaths, (ax, ay, bx, by) =>\n segmentsCross(ax, ay, bx, by, x0, y0, x1, y0) ||\n segmentsCross(ax, ay, bx, by, x1, y0, x1, y1) ||\n segmentsCross(ax, ay, bx, by, x1, y1, x0, y1) ||\n segmentsCross(ax, ay, bx, by, x0, y1, x0, y0),\n );\n}\n\nfunction anyEdgeCrossesPolygon(subpaths: readonly number[][], poly: readonly Point[]): boolean {\n if (poly.length === 0) return false;\n return anyEdge(subpaths, (ax, ay, bx, by) => {\n for (let i = 0; i < poly.length; i++) {\n const p0 = poly[i], p1 = poly[(i + 1) % poly.length];\n if (segmentsCross(ax, ay, bx, by, p0.x, p0.y, p1.x, p1.y)) return true;\n }\n return false;\n });\n}\n\n/** `anyEdgeCrossesPolygon` for open runs: no edge back to the first vertex. */\nfunction anyOpenEdgeCrossesPolygon(runs: readonly number[][], poly: readonly Point[]): boolean {\n for (const run of runs) {\n for (let i = 0; i + 3 < run.length; i += 2) {\n const ax = run[i], ay = run[i + 1], bx = run[i + 2], by = run[i + 3];\n for (let k = 0; k < poly.length; k++) {\n const p0 = poly[k], p1 = poly[(k + 1) % poly.length];\n if (segmentsCross(ax, ay, bx, by, p0.x, p0.y, p1.x, p1.y)) return true;\n }\n }\n }\n return false;\n}\n\nfunction anyVertexInRect(subpaths: readonly number[][], r: Rect): boolean {\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n const x = sub[i], y = sub[i + 1];\n if (x >= r.x && x <= r.x + r.width && y >= r.y && y <= r.y + r.height) return true;\n }\n }\n return false;\n}\n\nfunction anyVertexInPolygon(subpaths: readonly number[][], flatPoly: readonly number[]): boolean {\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n if (pointInPolygon(flatPoly, sub[i], sub[i + 1])) return true;\n }\n }\n return false;\n}\n\n/** Returns true if (x, y) lies within the filled region of `path`. */\nexport function pathContainsPoint(\n path: Path,\n x: number,\n y: number,\n opts: PointInPathOptions = {},\n): boolean {\n return pointInPath(path, x, y, opts);\n}\n\n/** Returns true if `rect` is entirely contained within `path`. */\nexport function pathContainsRect(path: Path, rect: Rect, opts: PointInPathOptions = {}): boolean {\n if (path.kind === 'rect') {\n return (\n rect.x >= path.x &&\n rect.y >= path.y &&\n rect.x + rect.width <= path.x + path.width &&\n rect.y + rect.height <= path.y + path.height\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const c of rectToVerts(rect)) {\n if (!pointInPath(path, c.x, c.y, opts)) return false;\n }\n // Every corner is filled, but any contour reaching into the rect — the\n // boundary of a hole, or a concave notch — leaves part of it unfilled.\n return !anyVertexInRect(subpaths, rect) && !anyEdgeCrossesRect(subpaths, rect);\n}\n\n/** Returns true if `rect` overlaps (intersects or contains) `path`. */\nexport function pathIntersectsRect(path: Path, rect: Rect, opts: PointInPathOptions = {}): boolean {\n if (path.kind === 'rect') {\n return (\n rect.x < path.x + path.width &&\n rect.x + rect.width > path.x &&\n rect.y < path.y + path.height &&\n rect.y + rect.height > path.y\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const c of rectToVerts(rect)) {\n if (pointInPath(path, c.x, c.y, opts)) return true;\n }\n if (anyVertexInRect(subpaths, rect)) return true;\n return anyEdgeCrossesRect(subpaths, rect);\n}\n\n/** Returns true if every vertex of `polygon` lies inside `path`. */\nexport function pathContainsPolygon(\n path: Path,\n polygon: readonly Point[],\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length === 0) return false;\n if (path.kind === 'rect') {\n return polygon.every(\n (p) =>\n p.x >= path.x &&\n p.x <= path.x + path.width &&\n p.y >= path.y &&\n p.y <= path.y + path.height,\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const p of polygon) {\n if (!pointInPath(path, p.x, p.y, opts)) return false;\n }\n return !anyVertexInPolygon(subpaths, flattenVerts(polygon)) &&\n !anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/** Returns true if `polygon` overlaps (intersects or is contained by) `path`. */\nexport function pathIntersectsPolygon(\n path: Path,\n polygon: readonly Point[],\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length === 0) return false;\n if (path.kind === 'rect') {\n return polygonsIntersect(rectToVerts(path), polygon);\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const p of polygon) {\n if (pointInPath(path, p.x, p.y, opts)) return true;\n }\n if (anyVertexInPolygon(subpaths, flattenVerts(polygon))) return true;\n return anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/**\n * Returns true if all of `path` — every subpath, open ones included, beziers\n * flattened — lies inside the closed `polygon`: the inverse of\n * {@link pathContainsPolygon}. A lasso enclosing a shape asks this.\n */\nexport function polygonContainsPath(\n polygon: readonly Point[],\n path: Path,\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length < 3) return false;\n let subpaths: number[][];\n if (path.kind === 'rect') {\n subpaths = [flattenVerts(rectToVerts(path))];\n } else {\n const { closed, open } = regionSubpaths(path, opts);\n subpaths = [...closed, ...open];\n }\n if (subpaths.length === 0) return false;\n const flatPoly = flattenVerts(polygon);\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n if (!pointInPolygon(flatPoly, sub[i], sub[i + 1])) return false;\n }\n }\n // Every vertex is inside, but a concave polygon can still cut an edge. An\n // open subpath is checked as if closed, so this can only err toward false.\n return !anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/**\n * Returns true if any of `path` meets the closed `polygon`: its filled region,\n * or the line of an open subpath, which encloses nothing. With `filled: false`\n * a closed subpath is a line too. Beziers are\n * flattened, so a control point off the curve never counts. The companion of\n * {@link polygonContainsPath}; a lasso touching a shape asks this.\n */\nexport function polygonIntersectsPath(\n polygon: readonly Point[],\n path: Path,\n opts: PolygonIntersectsPathOptions = {},\n): boolean {\n if (polygon.length < 3) return false;\n const filled = opts.filled !== false;\n if (path.kind === 'rect' && filled) return polygonsIntersect(rectToVerts(path), polygon);\n const { closed, open } = path.kind === 'rect'\n ? { closed: [flattenVerts(rectToVerts(path))], open: [] }\n : regionSubpaths(path, opts);\n const flatPoly = flattenVerts(polygon);\n if (anyVertexInPolygon(closed, flatPoly) || anyVertexInPolygon(open, flatPoly)) return true;\n if (anyEdgeCrossesPolygon(closed, polygon) || anyOpenEdgeCrossesPolygon(open, polygon)) {\n return true;\n }\n // No vertex inside and no crossing: the polygon lies wholly in one region\n // of the path, so one of its vertices decides whether that region is filled.\n return filled && closed.length > 0 && pointInPath(path, polygon[0].x, polygon[0].y, opts);\n}\n","/**\n * The corners an offset outline would hold as corners: each of the source's,\n * moved to where its offset edges meet and resized so its cut keeps the\n * same center.\n */\nimport type { Path } from '../path';\nimport { pointInPath } from '../pathHitTest';\nimport { PathBuilder } from './builder';\nimport type { CornerTrace } from './cornerRestore';\nimport { withCorner } from './cornerSpec';\nimport { cornerCuts, resolveCorners } from './corners';\n\n/**\n * Where the corners of `path` would sit on its outline grown by `distance`\n * (shrunk by a negative one), for `restoreCorners` to look for. A corner\n * moves with its edges and keeps its center, so its setback changes by\n * `distance / tan(half the corner's angle)`: a round corner at a right angle\n * grows its radius by exactly `distance`, and is then exactly what the offset\n * draws. A shape whose offset is no longer that shape, or a corner between\n * curved edges, draws differently from its trace, so `restoreCorners` leaves\n * it expanded. A corner shrunk to nothing has no trace.\n */\nexport function offsetCornerTraces(path: Path, distance: number): CornerTrace[] {\n if (path.kind !== 'polygon' || distance === 0) return [];\n const drawn = resolveCorners(path);\n const out: CornerTrace[] = [];\n for (const cut of cornerCuts(path)) {\n const { anchor: v, spec } = cut;\n const inLen = Math.hypot(cut.start.x - v.x, cut.start.y - v.y);\n const outLen = Math.hypot(cut.end.x - v.x, cut.end.y - v.y);\n if (inLen === 0 || outLen === 0) continue;\n const din = { x: (cut.start.x - v.x) / inLen, y: (cut.start.y - v.y) / inLen };\n const dout = { x: (cut.end.x - v.x) / outLen, y: (cut.end.y - v.y) / outLen };\n const bx = din.x + dout.x, by = din.y + dout.y;\n const bl = Math.hypot(bx, by);\n if (bl < 1e-9) continue;\n const b = { x: bx / bl, y: by / bl };\n const half = Math.acos(Math.max(-1, Math.min(1, din.x * b.x + din.y * b.y)));\n // Just inside the wedge, between the anchor and its cut: filled only\n // where the corner turns away from the fill.\n const probe = Math.min(inLen, outLen) * 0.01;\n const sign = pointInPath(drawn, v.x + b.x * probe, v.y + b.y * probe) ? -1 : 1;\n const radius = spec.radius + (sign * distance) / Math.tan(half);\n if (!(radius > 0)) continue;\n const at = { x: v.x - (b.x * sign * distance) / Math.sin(half), y: v.y - (b.y * sign * distance) / Math.sin(half) };\n const reach = radius * 2 + 1;\n const wedge = new PathBuilder()\n .moveTo(at.x + din.x * reach, at.y + din.y * reach)\n .lineTo(at.x, at.y)\n .lineTo(at.x + dout.x * reach, at.y + dout.y * reach)\n .build();\n const [moved] = cornerCuts(withCorner(wedge, 1, { shape: spec.shape, radius }));\n if (moved) out.push({ anchor: at, spec: moved.spec, start: moved.start, end: moved.end, pieces: moved.pieces });\n }\n return out;\n}\n","/**\n * AABB union over a heterogeneous set of `Path` poses. Returns the\n * envelope as a `RectPath`, or `null` for empty input — analog of\n * `unionBounds` for the rect-only model.\n */\n\nimport { boundsOfPath } from './bounds';\nimport type { Path, RectPath } from '../path';\n\n/** AABB envelope over a set of `Path` instances; returns `null` for empty input. */\nexport function unionBoundsPath(paths: Iterable<Path>): RectPath | null {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let any = false;\n for (const p of paths) {\n any = true;\n const b = boundsOfPath(p);\n if (b.x < minX) minX = b.x;\n if (b.y < minY) minY = b.y;\n const right = b.x + b.width;\n const bottom = b.y + b.height;\n if (right > maxX) maxX = right;\n if (bottom > maxY) maxY = bottom;\n }\n if (!any) return null;\n return { kind: 'rect', x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n","import type { Affine } from '../affine';\nimport { transformCoords } from '../affine';\nimport { PathBuilder } from './builder';\nimport type { Path, PolygonPath } from '../path';\nimport { scaleCorners } from './cornerSpec';\n\n/** Below this, a matrix's rotation and shear terms are rounding left by\n * composing transforms (a half turn's sine is 1.2e-16), not a slant. */\nconst AXIS_ALIGNED_EPSILON = 1e-9;\n\n/** Apply an `Affine` to a path's geometry. Never mutates the input.\n *\n * Axis-aligned maps (no rotation/shear: `m[1]` and `m[2]` within 1e-9 of 0) keep a\n * `RectPath` a rect, normalizing negative extent (mirror). Rotation or\n * shear promotes the rect's four corners to a `PolygonPath`. */\nexport function transformPath(path: Path, m: Affine): Path {\n const [a, b, c, d, e, f] = m;\n if (path.kind === 'rect') {\n if (Math.abs(b) < AXIS_ALIGNED_EPSILON && Math.abs(c) < AXIS_ALIGNED_EPSILON) {\n // Pure scale + translate — corners remain axis-aligned.\n const x0 = a * path.x + e;\n const y0 = d * path.y + f;\n const x1 = a * (path.x + path.width) + e;\n const y1 = d * (path.y + path.height) + f;\n return {\n kind: 'rect',\n x: Math.min(x0, x1),\n y: Math.min(y0, y1),\n width: Math.abs(x1 - x0),\n height: Math.abs(y1 - y0),\n };\n }\n // Rotation / shear — promote to polygon with the four rect corners.\n const poly = new PathBuilder()\n .moveTo(path.x, path.y)\n .lineTo(path.x + path.width, path.y)\n .lineTo(path.x + path.width, path.y + path.height)\n .lineTo(path.x, path.y + path.height)\n .close()\n .build();\n return transformPolygon(poly, m);\n }\n return transformPolygon(path, m);\n}\n\nfunction transformPolygon(path: PolygonPath, m: Affine): PolygonPath {\n // transformCoords returns Float64Array; PolygonPath.coords is Float32Array.\n const mapped = transformCoords(path.coords, m);\n // A corner radius scales as a length does: by the map's mean scale.\n const scaled = scaleCorners(path, Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])));\n return { ...scaled, coords: Float32Array.from(mapped) };\n}\n","/**\n * In-place and copy-out path transforms. Translation is the most common —\n * called every pointermove during a drag — so the polygon variant mutates\n * the float buffer directly to keep allocation pressure off the GC.\n *\n * `scalePathToBounds` is for the resize interaction: given the path's\n * current AABB and the desired new AABB, scales every coordinate\n * proportionally.\n */\n\nimport { boxToBox } from '../affine';\nimport { forEachSegment, pathCommandCoordCount } from '../commands';\nimport { boundsOfPath } from './bounds';\nimport { transformPath } from './transformPath';\nimport type { Path, PolygonPath, RectPath } from '../path';\n\n/**\n * Translate a path by (dx, dy). Returns a new instance — the kit's pose\n * model treats poses as immutable to keep React state-update semantics\n * predictable. Polygon coords are copied into a fresh `Float32Array`.\n */\nexport function translatePath(path: Path, dx: number, dy: number): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: path.x + dx, y: path.y + dy, width: path.width, height: path.height };\n }\n return translatePolygonCopy(path, dx, dy);\n}\n\nfunction translatePolygonCopy(path: PolygonPath, dx: number, dy: number): PolygonPath {\n const next = new Float32Array(path.coords.length);\n const { commands, coords } = path;\n forEachSegment(commands, coords, (cmd, ci) => {\n for (let k = 0, len = pathCommandCoordCount(cmd); k < len; k += 2) {\n next[ci + k] = coords[ci + k] + dx;\n next[ci + k + 1] = coords[ci + k + 1] + dy;\n }\n });\n return { ...path, coords: next };\n}\n\n/**\n * Scale a path's coords so its current AABB maps to `target`. Resize\n * interactions use this to make a polygon follow a corner-handle drag.\n *\n * A degenerate source axis (zero width or height) has no ratio to scale by,\n * so `boxToBox` translates that axis instead — a zero scale is not\n * invertible and would discard what is left on it.\n */\nexport function scalePathToBounds(path: Path, target: RectPath): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: target.x, y: target.y, width: target.width, height: target.height };\n }\n const src = boundsOfPath(path);\n return scalePolygon(path, src, target);\n}\n\nfunction scalePolygon(path: PolygonPath, src: RectPath, dst: RectPath): PolygonPath {\n const m = boxToBox(src.x, src.y, src.width, src.height, dst.x, dst.y, dst.width, dst.height);\n // src/dst are axis-aligned, so the polygon stays a polygon after this pure scale+translate.\n return transformPath(path, m) as PolygonPath;\n}\n","/**\n * Translation-only compose/decompose for `Path` poses, the analog of\n * `composeRectPose` / `decomposeRectPose` for the rect-only model. Pair\n * with `composeWorldPose` / `rebaseLocalPose` when an adapter uses `Path`\n * as its `TPose`.\n *\n * Only translation is folded — the kit's hierarchy contract is\n * translation-only, same as for rects. Parent rotation/scale would require\n * a richer compose; that's out of scope here.\n */\n\nimport { boundsOfPath } from './bounds';\nimport { translatePath } from './transform';\nimport type { Path } from '../path';\n\n/** Express `child` (in `parent`'s local frame) in the next frame up. */\nexport function composePath(parent: Path, child: Path): Path {\n const origin = pathOrigin(parent);\n return translatePath(child, origin.x, origin.y);\n}\n\n/** Inverse of `composePath` — undo `parent`'s translation from a world pose. */\nexport function decomposePath(parent: Path, world: Path): Path {\n const origin = pathOrigin(parent);\n return translatePath(world, -origin.x, -origin.y);\n}\n\nfunction pathOrigin(path: Path): { x: number; y: number } {\n const { x, y } = boundsOfPath(path);\n return { x, y };\n}\n","import { forEachSegment, PATH_M, PATH_Z } from '../commands';\nimport type { PolygonPath } from '../path';\nimport { anchorRange, carryCorners } from './cornerCarry';\nimport { withoutCorners } from './cornerSpec';\n\n/** Split a path into one path per subpath, cutting at each `M`. A path with a\n * single subpath comes back as a one-element array. `fillRule` is propagated\n * unchanged, so even-odd compound paths with interior \"holes\" lose the hole\n * semantics — each subpath becomes its own filled region. Each subpath keeps\n * the corner specs of its own anchors. */\nexport function splitSubpaths(path: PolygonPath): PolygonPath[] {\n const { commands, coords } = path;\n const bare = withoutCorners(path);\n const out: PolygonPath[] = [];\n\n // Walk the command stream, tracking the (cmdStart, coordStart) of the\n // active subpath. On each subsequent `M`, slice out the previous subpath.\n let cmdStart = 0;\n let coordStart = 0;\n let anchorStart = 0;\n let anchors = 0;\n\n const emit = (end: number, coordEnd: number) => {\n const sub = { ...bare, commands: commands.slice(cmdStart, end), coords: coords.slice(coordStart, coordEnd) };\n const count = anchors - anchorStart;\n out.push(path.corners ? carryCorners(path, sub, anchorRange(anchorStart, count)) : sub);\n anchorStart = anchors;\n };\n\n forEachSegment(commands, coords, (cmd, ci, _px, _py, i) => {\n if (cmd === PATH_M && i > cmdStart) {\n emit(i, ci);\n cmdStart = i;\n coordStart = ci;\n }\n if (cmd !== PATH_Z) anchors++;\n });\n\n emit(commands.length, coords.length);\n\n return out;\n}\n","import { PATH_Z } from '../commands';\nimport type { Path, PolygonPath } from '../path';\nimport { countPathAnchors } from './anchors';\nimport { anchorRange, carryCorners } from './cornerCarry';\nimport { withoutCorners } from './cornerSpec';\nimport { splitSubpaths } from './splitSubpaths';\n\ninterface Placed { sub: PolygonPath; first: number; count: number }\n\nconst endsInZ = (sub: PolygonPath): boolean => sub.commands[sub.commands.length - 1] === PATH_Z;\n\n/** Whether any subpath of `path` lacks the `Z` that closes it. */\nexport function hasOpenSubpath(path: Path): boolean {\n return path.kind === 'polygon' && path.commands.length > 0\n && splitSubpaths(path).some((sub) => !endsInZ(sub));\n}\n\n/**\n * `path` as two paths: the subpaths a `Z` closes, and those left open, each in\n * the order `path` holds them and with its fill rules. A side with no subpaths\n * is `null`. A fill that does not close an open subpath covers `closed` alone.\n */\nexport function splitByClosure(\n path: PolygonPath,\n): { closed: PolygonPath | null; open: PolygonPath | null } {\n const closed: Placed[] = [];\n const open: Placed[] = [];\n if (path.commands.length > 0) {\n let first = 0;\n for (const sub of splitSubpaths(path)) {\n const count = countPathAnchors(sub);\n (endsInZ(sub) ? closed : open).push({ sub, first, count });\n first += count;\n }\n }\n const join = (placed: Placed[]): PolygonPath | null => {\n if (placed.length === 0) return null;\n const subs = placed.map((p) => p.sub);\n const commands = new Uint8Array(subs.reduce((n, s) => n + s.commands.length, 0));\n const coords = new Float32Array(subs.reduce((n, s) => n + s.coords.length, 0));\n let ci = 0, xi = 0;\n for (const s of subs) {\n commands.set(s.commands, ci);\n coords.set(s.coords, xi);\n ci += s.commands.length;\n xi += s.coords.length;\n }\n const joined = { ...withoutCorners(path), commands, coords };\n if (!path.corners) return joined;\n const sources = new Int32Array(placed.reduce((n, p) => n + p.count, 0));\n let at = 0;\n for (const p of placed) { sources.set(anchorRange(p.first, p.count), at); at += p.count; }\n return carryCorners(path, joined, sources);\n };\n return { closed: join(closed), open: join(open) };\n}\n","/**\n * Contour orientation: which way a path winds, and the same path wound the\n * other way. Under `'nonzero'` two overlapping contours fill their overlap\n * only when they wind the same way, so composing shapes from different\n * sources into one compound path first needs them to agree.\n */\n\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z, forEachSegment } from '../commands';\nimport type { Path, PolygonPath } from '../path';\nimport { fillsOpenSubpaths } from '../openFill';\nimport { carryCorners } from './cornerCarry';\n\n// Three-point Gauss-Legendre: exact for polynomials up to degree 5, and the\n// Green's-theorem integrand of a cubic is degree 5.\nconst GL_T = [0.5 - Math.sqrt(15) / 10, 0.5, 0.5 + Math.sqrt(15) / 10];\nconst GL_W = [5 / 18, 8 / 18, 5 / 18];\n\n/**\n * Signed area enclosed by `path`, summed over its contours. Positive for a\n * contour that turns clockwise on a y-down screen (the shoelace sign), so a\n * hole wound against its outer contour subtracts. An open contour counts as\n * closed by a straight edge back to its start where a fill closes it, and as\n * nothing where one does not: see `fillsOpenSubpaths`.\n * Curved segments are integrated exactly, not through their control polygon.\n * A `RectPath` has no direction and counts as positive.\n */\nexport function pathSignedArea(path: Path): number {\n if (path.kind === 'rect') return path.width * path.height;\n const { commands, coords } = path;\n const fillsOpen = fillsOpenSubpaths(path);\n let total = 0;\n let twice = 0;\n let startX = 0, startY = 0;\n let open = false;\n let endX = 0, endY = 0;\n const close = (drawn: boolean) => {\n if (open && (drawn || fillsOpen)) total += twice + endX * startY - startX * endY;\n twice = 0;\n open = false;\n };\n forEachSegment(commands, coords, (cmd, ci, px, py) => {\n if (cmd === PATH_M) {\n close(false);\n startX = endX = coords[ci];\n startY = endY = coords[ci + 1];\n open = true;\n return;\n }\n if (cmd === PATH_Z) { close(true); endX = startX; endY = startY; return; }\n if (!open) { startX = px; startY = py; open = true; }\n if (cmd === PATH_L) {\n endX = coords[ci]; endY = coords[ci + 1];\n twice += px * endY - endX * py;\n return;\n }\n const cubic = cmd === PATH_C;\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n const x3 = cubic ? coords[ci + 4] : x2, y3 = cubic ? coords[ci + 5] : y2;\n for (let k = 0; k < 3; k++) {\n const t = GL_T[k], u = 1 - t;\n let x: number, y: number, dx: number, dy: number;\n if (cubic) {\n x = u * u * u * px + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * x3;\n y = u * u * u * py + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * y3;\n dx = 3 * (u * u * (x1 - px) + 2 * u * t * (x2 - x1) + t * t * (x3 - x2));\n dy = 3 * (u * u * (y1 - py) + 2 * u * t * (y2 - y1) + t * t * (y3 - y2));\n } else {\n x = u * u * px + 2 * u * t * x1 + t * t * x2;\n y = u * u * py + 2 * u * t * y1 + t * t * y2;\n dx = 2 * (u * (x1 - px) + t * (x2 - x1));\n dy = 2 * (u * (y1 - py) + t * (y2 - y1));\n }\n twice += GL_W[k] * (x * dy - y * dx);\n }\n endX = x3; endY = y3;\n });\n close(false);\n return total / 2;\n}\n\ninterface Segment {\n cmd: number;\n /** Control points followed by the end point, as the command stores them. */\n args: number[];\n fromX: number;\n fromY: number;\n /** The anchor command the segment starts from, or -1 for an implicit start. */\n from: number;\n}\n\n/**\n * `path` with every contour traversed backwards: same region, same curves,\n * opposite winding. A closed contour keeps its starting point; an open one\n * starts from where it used to end. Corner specs stay on their anchors.\n */\nexport function reversePath(path: PolygonPath): PolygonPath {\n const cmds: number[] = [];\n const out: number[] = [];\n let segs: Segment[] = [];\n const sources: number[] = [];\n let sx = 0, sy = 0;\n let started = false;\n let anchor = -1, start = -1;\n\n const flush = (closed: boolean) => {\n if (!started) return;\n const last = segs[segs.length - 1];\n const ex = last ? last.args[last.args.length - 2] : sx;\n const ey = last ? last.args[last.args.length - 1] : sy;\n if (closed) {\n cmds.push(PATH_M); out.push(sx, sy); sources.push(start);\n if (ex !== sx || ey !== sy) { cmds.push(PATH_L); out.push(ex, ey); sources.push(last ? anchor : start); }\n } else {\n cmds.push(PATH_M); out.push(ex, ey); sources.push(last ? anchor : start);\n }\n for (let i = segs.length - 1; i >= 0; i--) {\n const s = segs[i];\n cmds.push(s.cmd);\n if (s.cmd === PATH_C) out.push(s.args[2], s.args[3], s.args[0], s.args[1]);\n else if (s.cmd === PATH_Q) out.push(s.args[0], s.args[1]);\n out.push(s.fromX, s.fromY);\n sources.push(s.from);\n }\n if (closed) cmds.push(PATH_Z);\n segs = [];\n started = false;\n };\n\n const { commands, coords } = path;\n forEachSegment(commands, coords, (cmd, ci, px, py) => {\n if (cmd === PATH_M) {\n flush(false);\n sx = coords[ci]; sy = coords[ci + 1];\n start = ++anchor;\n started = true;\n return;\n }\n if (cmd === PATH_Z) { flush(true); return; }\n if (!started) { sx = px; sy = py; start = -1; started = true; }\n const n = cmd === PATH_C ? 6 : cmd === PATH_Q ? 4 : 2;\n const from = segs.length > 0 ? anchor : start;\n segs.push({ cmd, args: Array.from(coords.subarray(ci, ci + n)), fromX: px, fromY: py, from });\n anchor++;\n });\n flush(false);\n\n const reversed = { ...path, commands: new Uint8Array(cmds), coords: new Float32Array(out) };\n return path.corners ? carryCorners(path, reversed, sources) : reversed;\n}\n","/**\n * `pathFromD` — build a weasel `Path` from an **SVG path-data string** (the\n * value of SVG's `d` attribute, e.g. `\"M0 0 L100 0 Z\"`).\n *\n * Lowers every supported command (M/m L/l H/h V/v C/c S/s Q/q T/t A/a Z/z)\n * into weasel's `PathBuilder` primitives (move, line, cubic, quadratic,\n * close). Arc commands (`A`/`a`) convert to a series of cubic Bezier curves\n * using the standard endpoint-parameterization formulas (F.6.5 in the SVG\n * spec).\n */\n\nimport { PathBuilder } from './builder';\n\nconst NUM_RE = /[+-]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][+-]?\\d+)?/g;\n/** Same grammar, anchored — used where a number's position matters. */\nconst NUM_RE_AT = /[+-]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][+-]?\\d+)?/y;\n\n/**\n * Is `d[j]` a command letter, as opposed to the `e` of an exponent? `1e2` is\n * a legal coordinate, and treating its `e` as a command drops the number and\n * everything after it in that argument run.\n */\nfunction isCommandLetter(d: string, j: number): boolean {\n const c = d[j];\n if (!/[A-Za-z]/.test(c)) return false;\n if (c !== 'e' && c !== 'E') return true;\n if (!/[\\d.]/.test(d[j - 1] ?? '')) return true;\n const k = d[j + 1] === '+' || d[j + 1] === '-' ? j + 2 : j + 1;\n return !/\\d/.test(d[k] ?? '');\n}\n\n/** Tokenize the command stream from a `d` string. */\nfunction tokenize(d: string): { cmd: string; args: number[] }[] {\n const out: { cmd: string; args: number[] }[] = [];\n // Walk character by character so we can group command-letter + arg-run.\n let i = 0;\n while (i < d.length) {\n if (isCommandLetter(d, i)) {\n // Collect numeric args until the next command letter.\n let j = i + 1;\n while (j < d.length && !isCommandLetter(d, j)) j++;\n const argSlice = d.slice(i + 1, j);\n const cmd = d[i];\n out.push({\n cmd,\n args: cmd === 'A' || cmd === 'a' ? readArcArgs(argSlice) : readNumbers(argSlice),\n });\n i = j;\n } else {\n // Skip any whitespace / commas at the head.\n i++;\n }\n }\n return out;\n}\n\nfunction readNumbers(s: string): number[] {\n const out: number[] = [];\n let m: RegExpExecArray | null;\n NUM_RE.lastIndex = 0;\n while ((m = NUM_RE.exec(s)) !== null) {\n const n = Number(m[0]);\n if (Number.isFinite(n)) out.push(n);\n }\n return out;\n}\n\n/**\n * Read an `A`/`a` argument run. The two flags are single `0`/`1` digits that\n * need no separator after them, so `a25 25 -30 0 1 50 -25` may legally be\n * written `a25 25 -30 0150 -25` — which a plain number scan reads as two\n * arguments instead of four, leaving the whole arc short and dropped.\n */\nfunction readArcArgs(s: string): number[] {\n const out: number[] = [];\n let i = 0;\n while (i < s.length) {\n const c = s[i];\n if (c === ',' || c === ' ' || c === '\\t' || c === '\\n' || c === '\\r') { i++; continue; }\n const slot = out.length % 7;\n if (slot === 3 || slot === 4) {\n if (c !== '0' && c !== '1') return out;\n out.push(c === '1' ? 1 : 0);\n i++;\n continue;\n }\n NUM_RE_AT.lastIndex = i;\n const m = NUM_RE_AT.exec(s);\n if (!m) return out;\n out.push(Number(m[0]));\n i = NUM_RE_AT.lastIndex;\n }\n return out;\n}\n\n/** Per-command argument counts (in floats). A = 7: rx ry x-axis-rotation\n * large-arc-flag sweep-flag x y. */\nconst ARG_COUNTS: Record<string, number> = {\n M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0,\n};\n\ninterface ParseState {\n x: number;\n y: number;\n startX: number;\n startY: number;\n /** Last cubic control point for S/s reflection (in absolute coords). */\n lastCubicCtrl: { x: number; y: number } | null;\n /** Last quadratic control point for T/t reflection (in absolute coords). */\n lastQuadCtrl: { x: number; y: number } | null;\n}\n\n/**\n * Build a weasel `PolygonPath` from an SVG path-data (`d`) string. Unknown\n * command letters are skipped (and reported via `onWarn` when provided); the\n * builder still returns whatever valid commands preceded them. Data that does\n * not begin with a moveto builds an empty path, and a command with the wrong\n * number of arguments ends the path before it, as SVG renders both.\n */\nexport function pathFromD(\n d: string,\n onWarn?: (message: string) => void,\n): ReturnType<PathBuilder['build']> {\n const tokens = tokenize(d);\n const b = new PathBuilder();\n const st: ParseState = {\n x: 0, y: 0, startX: 0, startY: 0,\n lastCubicCtrl: null, lastQuadCtrl: null,\n };\n\n let started = false;\n for (const { cmd, args } of tokens) {\n const upper = cmd.toUpperCase();\n const relative = cmd !== upper;\n const argCount = ARG_COUNTS[upper];\n if (argCount === undefined) {\n onWarn?.(`unknown path command: ${cmd}`);\n continue;\n }\n if (!started && upper !== 'M') {\n onWarn?.(`path data does not begin with a moveto (\"${cmd}\" comes first); nothing is drawn`);\n break;\n }\n if (upper === 'Z') {\n b.close();\n st.x = st.startX;\n st.y = st.startY;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n continue;\n }\n // M with multiple coord pairs implies subsequent pairs are L (per SVG spec).\n const groups = Math.floor(args.length / argCount);\n for (let g = 0; g < groups; g++) {\n const a = args.slice(g * argCount, (g + 1) * argCount);\n // For repeated 'M'/'m' coord pairs after the first, downgrade to L/l.\n const effectiveUpper = upper === 'M' && g > 0 ? 'L' : upper;\n runCommand(effectiveUpper, relative, a, st, b);\n started = true;\n }\n // SVG draws a path up to the command in error and no further: carrying on\n // would start every later relative command from the wrong point.\n if (groups === 0 || args.length % argCount !== 0) {\n onWarn?.(`path command \"${cmd}\" takes ${argCount} arguments at a time and has ${args.length}; the path ends before it`);\n break;\n }\n }\n\n return b.build();\n}\n\nfunction runCommand(\n upper: string,\n relative: boolean,\n a: number[],\n st: ParseState,\n b: PathBuilder,\n): void {\n const rx = relative ? st.x : 0;\n const ry = relative ? st.y : 0;\n switch (upper) {\n case 'M': {\n const x = a[0] + rx;\n const y = a[1] + ry;\n b.moveTo(x, y);\n st.x = x; st.y = y;\n st.startX = x; st.startY = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'L': {\n const x = a[0] + rx;\n const y = a[1] + ry;\n b.lineTo(x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'H': {\n const x = a[0] + (relative ? st.x : 0);\n b.lineTo(x, st.y);\n st.x = x;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'V': {\n const y = a[0] + (relative ? st.y : 0);\n b.lineTo(st.x, y);\n st.y = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'C': {\n const x1 = a[0] + rx, y1 = a[1] + ry;\n const x2 = a[2] + rx, y2 = a[3] + ry;\n const x = a[4] + rx, y = a[5] + ry;\n b.curveTo(x1, y1, x2, y2, x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = { x: x2, y: y2 };\n st.lastQuadCtrl = null;\n return;\n }\n case 'S': {\n // Reflect prior cubic ctrl about the current point; fall back to\n // current point when prior wasn't a cubic.\n const ref = st.lastCubicCtrl ?? { x: st.x, y: st.y };\n const x1 = 2 * st.x - ref.x;\n const y1 = 2 * st.y - ref.y;\n const x2 = a[0] + rx, y2 = a[1] + ry;\n const x = a[2] + rx, y = a[3] + ry;\n b.curveTo(x1, y1, x2, y2, x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = { x: x2, y: y2 };\n st.lastQuadCtrl = null;\n return;\n }\n case 'Q': {\n const x1 = a[0] + rx, y1 = a[1] + ry;\n const x = a[2] + rx, y = a[3] + ry;\n b.quadTo(x1, y1, x, y);\n st.x = x; st.y = y;\n st.lastQuadCtrl = { x: x1, y: y1 };\n st.lastCubicCtrl = null;\n return;\n }\n case 'T': {\n const ref = st.lastQuadCtrl ?? { x: st.x, y: st.y };\n const x1 = 2 * st.x - ref.x;\n const y1 = 2 * st.y - ref.y;\n const x = a[0] + rx, y = a[1] + ry;\n b.quadTo(x1, y1, x, y);\n st.x = x; st.y = y;\n st.lastQuadCtrl = { x: x1, y: y1 };\n st.lastCubicCtrl = null;\n return;\n }\n case 'A': {\n const rxA = Math.abs(a[0]);\n const ryA = Math.abs(a[1]);\n const xRot = a[2];\n const largeArc = a[3] !== 0;\n const sweep = a[4] !== 0;\n const ex = a[5] + rx;\n const ey = a[6] + ry;\n arcToCubics(st.x, st.y, ex, ey, rxA, ryA, xRot, largeArc, sweep, b);\n st.x = ex; st.y = ey;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n default:\n return;\n }\n}\n\n/**\n * Convert an SVG elliptical arc segment to a series of cubic Bezier\n * `curveTo` calls on the builder. Standard endpoint-parameterization\n * implementation (SVG spec appendix F.6.5).\n */\nfunction arcToCubics(\n x1: number, y1: number,\n x2: number, y2: number,\n rx: number, ry: number,\n xAxisRotationDeg: number,\n largeArc: boolean,\n sweep: boolean,\n b: PathBuilder,\n): void {\n if (x1 === x2 && y1 === y2) return;\n if (rx === 0 || ry === 0) {\n b.lineTo(x2, y2);\n return;\n }\n const phi = (xAxisRotationDeg * Math.PI) / 180;\n const cosPhi = Math.cos(phi);\n const sinPhi = Math.sin(phi);\n\n // Step 1: compute (x1', y1') — rotate so x-axis aligns with ellipse axis.\n const dx = (x1 - x2) / 2;\n const dy = (y1 - y2) / 2;\n const x1p = cosPhi * dx + sinPhi * dy;\n const y1p = -sinPhi * dx + cosPhi * dy;\n\n // Correct radii if they're too small.\n let rxs = rx * rx;\n let rys = ry * ry;\n const x1ps = x1p * x1p;\n const y1ps = y1p * y1p;\n const lambda = x1ps / rxs + y1ps / rys;\n let rxFixed = rx;\n let ryFixed = ry;\n if (lambda > 1) {\n const sqrtLambda = Math.sqrt(lambda);\n rxFixed = sqrtLambda * rx;\n ryFixed = sqrtLambda * ry;\n rxs = rxFixed * rxFixed;\n rys = ryFixed * ryFixed;\n }\n\n // Step 2: center (cx', cy') in the rotated frame.\n const sign = largeArc === sweep ? -1 : 1;\n const num = rxs * rys - rxs * y1ps - rys * x1ps;\n const den = rxs * y1ps + rys * x1ps;\n const factor = sign * Math.sqrt(Math.max(0, num / den));\n const cxp = (factor * (rxFixed * y1p)) / ryFixed;\n const cyp = (factor * -(ryFixed * x1p)) / rxFixed;\n\n // Step 3: un-rotate the center back to user coords.\n const cx = cosPhi * cxp - sinPhi * cyp + (x1 + x2) / 2;\n const cy = sinPhi * cxp + cosPhi * cyp + (y1 + y2) / 2;\n\n // Step 4: start and sweep angles.\n const angle = (ux: number, uy: number, vx: number, vy: number): number => {\n const dot = ux * vx + uy * vy;\n const len = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));\n let a = Math.acos(Math.max(-1, Math.min(1, dot / len)));\n if (ux * vy - uy * vx < 0) a = -a;\n return a;\n };\n const theta1 = angle(1, 0, (x1p - cxp) / rxFixed, (y1p - cyp) / ryFixed);\n let dTheta = angle(\n (x1p - cxp) / rxFixed,\n (y1p - cyp) / ryFixed,\n (-x1p - cxp) / rxFixed,\n (-y1p - cyp) / ryFixed,\n );\n if (!sweep && dTheta > 0) dTheta -= 2 * Math.PI;\n else if (sweep && dTheta < 0) dTheta += 2 * Math.PI;\n\n // Step 5: split into ≤ 90° segments; emit a cubic per segment.\n const segCount = Math.max(1, Math.ceil(Math.abs(dTheta) / (Math.PI / 2)));\n const segAngle = dTheta / segCount;\n // Magic constant: cubic bezier handle length to approximate a circular\n // arc — for a segment of half-angle a, t = (4/3) * tan(a/2).\n const t = (4 / 3) * Math.tan(segAngle / 4);\n\n let prevX = x1;\n let prevY = y1;\n let prevDx = -Math.sin(theta1) * rxFixed;\n let prevDy = Math.cos(theta1) * ryFixed;\n\n for (let i = 1; i <= segCount; i++) {\n const theta = theta1 + i * segAngle;\n const cosT = Math.cos(theta);\n const sinT = Math.sin(theta);\n const px = cosPhi * (cosT * rxFixed) - sinPhi * (sinT * ryFixed) + cx;\n const py = sinPhi * (cosT * rxFixed) + cosPhi * (sinT * ryFixed) + cy;\n const dxNew = -sinT * rxFixed;\n const dyNew = cosT * ryFixed;\n const c1x = prevX + cosPhi * (t * prevDx) - sinPhi * (t * prevDy);\n const c1y = prevY + sinPhi * (t * prevDx) + cosPhi * (t * prevDy);\n const c2x = px - cosPhi * (t * dxNew) + sinPhi * (t * dyNew);\n const c2y = py - sinPhi * (t * dxNew) - cosPhi * (t * dyNew);\n b.curveTo(c1x, c1y, c2x, c2y, px, py);\n prevX = px;\n prevY = py;\n prevDx = dxNew;\n prevDy = dyNew;\n }\n}\n","/**\n * `pathToD` — a weasel `Path` as an SVG `d=` string, the inverse of\n * `pathFromD`. `RectPath` lowers to `M h v h Z`; `PolygonPath` walks the\n * (commands, coords) arrays, one SVG command per kit command, with corner\n * shapes expanded into the geometry they draw.\n *\n * Absolute commands only; numbers are rounded to 6 decimals.\n */\n\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from '../commands';\nimport type { Path } from '../path';\nimport { resolveCorners } from './corners';\n\nconst num = (n: number): string => (Number.isFinite(n) ? String(Math.round(n * 1e6) / 1e6) : '0');\n\n/** `path` as SVG path data. */\nexport function pathToD(given: Path): string {\n const path = resolveCorners(given);\n if (path.kind === 'rect') {\n const { x, y, width, height } = path;\n return `M${num(x)} ${num(y)}h${num(width)}v${num(height)}h${num(-width)}Z`;\n }\n const cmds = path.commands;\n const xs = path.coords;\n const out: string[] = [];\n let ci = 0;\n for (let i = 0; i < cmds.length; i++) {\n const c = cmds[i];\n if (c === PATH_M) {\n out.push(`M${num(xs[ci])} ${num(xs[ci + 1])}`);\n ci += 2;\n } else if (c === PATH_L) {\n out.push(`L${num(xs[ci])} ${num(xs[ci + 1])}`);\n ci += 2;\n } else if (c === PATH_C) {\n out.push(\n `C${num(xs[ci])} ${num(xs[ci + 1])} ${num(xs[ci + 2])} ${num(xs[ci + 3])} `\n + `${num(xs[ci + 4])} ${num(xs[ci + 5])}`,\n );\n ci += 6;\n } else if (c === PATH_Q) {\n out.push(`Q${num(xs[ci])} ${num(xs[ci + 1])} ${num(xs[ci + 2])} ${num(xs[ci + 3])}`);\n ci += 4;\n } else if (c === PATH_Z) {\n out.push('Z');\n }\n }\n return out.join('');\n}\n","/**\n * A path measured once by arc length, so many stations along it cost a binary\n * search each rather than a fresh flatten: what `pointAlongPath` answers one\n * fraction at a time, and what anything placing or bending geometry along a\n * path reads many times over.\n */\nimport type { Path } from '../path';\nimport { extractPolylines } from '../tessellate/polyline';\nimport type { Point } from './cubicMath';\n\n/** A point on a path and its heading there. */\nexport interface PathStation {\n point: Point;\n /** Unit vector along the path at `point`, pointing toward the end. */\n tangent: Point;\n}\n\n/** Options for {@link measurePath}. */\nexport interface MeasurePathOptions {\n /** Curve flattening tolerance, in world units. Default 0.5. */\n flattenTolerance?: number;\n}\n\n/** The station on a path nearest a point. */\nexport interface PathNearestStation extends PathStation {\n /** Arc length at `point`, on the scale {@link PathMeasure.at} reads. */\n s: number;\n /** Distance from the queried point to `point`. */\n dist: number;\n}\n\n/** A measured path: its length, and the station at any distance along it. */\nexport interface PathMeasure {\n /** Total arc length, every subpath counted in order. */\n readonly length: number;\n /** True when the path is a single closed contour, so a distance past the\n * end can wrap round to the start. */\n readonly closed: boolean;\n /**\n * The station `s` along the path, `s` clamped to `0..length`.\n *\n * The tangent is the heading of the flattened segment under `s`. With\n * `smooth`, it is instead blended across each segment from the heading at\n * one vertex to the next, so geometry bent along it turns without facets.\n */\n at(s: number, smooth?: boolean): PathStation;\n /**\n * The inverse of `at`: the station nearest `p`. On a tie the earliest\n * segment wins. The tangent is the heading of the segment holding it.\n */\n nearest(p: Point): PathNearestStation;\n}\n\ninterface Segment {\n ax: number; ay: number; bx: number; by: number;\n /** Arc length at the segment's start. */\n start: number;\n len: number;\n /** Unit heading. */\n tx: number; ty: number;\n /** Headings at either end, averaged with the neighbor's, for `smooth`. */\n t0x: number; t0y: number; t1x: number; t1y: number;\n}\n\n/**\n * Measure `path` by arc length. Subpaths are measured in order and treated as\n * one run, the way a browser measures a whole `<path>`. Returns `null` for a\n * path with no points; a path of zero length answers at its single point,\n * heading along +X.\n */\nexport function measurePath(path: Path, opts: MeasurePathOptions = {}): PathMeasure | null {\n const polylines = extractPolylines(\n path,\n opts.flattenTolerance === undefined ? {} : { flattenTolerance: opts.flattenTolerance },\n );\n const segments: Segment[] = [];\n let total = 0;\n let first: Point | undefined;\n let contours = 0;\n let lastClosed = false;\n for (const pl of polylines) {\n const count = pl.points.length / 2;\n if (count === 0) continue;\n contours++;\n lastClosed = pl.closed;\n first ??= { x: pl.points[0]!, y: pl.points[1]! };\n const startIndex = segments.length;\n const last = pl.closed ? count : count - 1;\n for (let i = 0; i < last; i++) {\n const j = (i + 1) % count;\n const ax = pl.points[i * 2]!;\n const ay = pl.points[i * 2 + 1]!;\n const bx = pl.points[j * 2]!;\n const by = pl.points[j * 2 + 1]!;\n const len = Math.hypot(bx - ax, by - ay);\n if (len === 0) continue;\n const tx = (bx - ax) / len;\n const ty = (by - ay) / len;\n segments.push({ ax, ay, bx, by, start: total, len, tx, ty, t0x: tx, t0y: ty, t1x: tx, t1y: ty });\n total += len;\n }\n smoothVertexHeadings(segments, startIndex, pl.closed);\n }\n if (first === undefined) return null;\n const origin = first;\n const closed = contours === 1 && lastClosed;\n if (segments.length === 0) {\n return {\n length: 0,\n closed,\n at: () => ({ point: { ...origin }, tangent: { x: 1, y: 0 } }),\n nearest: (p) => ({\n s: 0,\n dist: Math.hypot(p.x - origin.x, p.y - origin.y),\n point: { ...origin },\n tangent: { x: 1, y: 0 },\n }),\n };\n }\n\n return {\n length: total,\n closed,\n at(s, smooth = false) {\n const target = Math.min(Math.max(s, 0), total);\n const seg = segments[segmentAt(segments, target)]!;\n const u = Math.min(Math.max((target - seg.start) / seg.len, 0), 1);\n const point = { x: seg.ax + (seg.bx - seg.ax) * u, y: seg.ay + (seg.by - seg.ay) * u };\n if (!smooth) return { point, tangent: { x: seg.tx, y: seg.ty } };\n const x = seg.t0x + (seg.t1x - seg.t0x) * u;\n const y = seg.t0y + (seg.t1y - seg.t0y) * u;\n const l = Math.hypot(x, y);\n return { point, tangent: l === 0 ? { x: seg.tx, y: seg.ty } : { x: x / l, y: y / l } };\n },\n nearest(p) {\n let best = segments[0]!;\n let bestU = 0;\n let bestDist = Infinity;\n for (const seg of segments) {\n const u = Math.min(Math.max(((p.x - seg.ax) * seg.tx + (p.y - seg.ay) * seg.ty) / seg.len, 0), 1);\n const d = Math.hypot(p.x - (seg.ax + (seg.bx - seg.ax) * u), p.y - (seg.ay + (seg.by - seg.ay) * u));\n if (d < bestDist) {\n best = seg;\n bestU = u;\n bestDist = d;\n }\n }\n return {\n s: best.start + best.len * bestU,\n dist: bestDist,\n point: { x: best.ax + (best.bx - best.ax) * bestU, y: best.ay + (best.by - best.ay) * bestU },\n tangent: { x: best.tx, y: best.ty },\n };\n },\n };\n}\n\n/** Give each interior vertex of one contour the mean heading of the two\n * segments meeting there; a closed contour's seam is interior too. */\nfunction smoothVertexHeadings(segments: Segment[], from: number, closed: boolean): void {\n const n = segments.length - from;\n if (n < 2) return;\n const pairs = closed ? n : n - 1;\n for (let k = 0; k < pairs; k++) {\n const a = segments[from + k]!;\n const b = segments[from + ((k + 1) % n)]!;\n let x = a.tx + b.tx;\n let y = a.ty + b.ty;\n const l = Math.hypot(x, y);\n // Two segments doubling back on each other have no mean heading.\n if (l < 1e-9) continue;\n x /= l;\n y /= l;\n a.t1x = x; a.t1y = y;\n b.t0x = x; b.t0y = y;\n }\n}\n\n/** Index of the segment covering arc length `s`: binary search on `start`. */\nfunction segmentAt(segments: readonly Segment[], s: number): number {\n let lo = 0;\n let hi = segments.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (segments[mid]!.start <= s) lo = mid;\n else hi = mid - 1;\n }\n return lo;\n}\n","/**\n * A station along a path: where it is at a fraction of its length, and which\n * way it is heading there.\n *\n * For anything positioned *along* geometry rather than beside it — a label on a\n * routed edge, a tick on a curve, a badge near an arrowhead. Curves are\n * flattened first, so the fraction is arc length along the drawn shape rather\n * than a curve parameter, which is what makes 0.5 look like the middle. For\n * many stations along one path, measure it once with `measurePath`.\n */\nimport type { Path } from '../path';\nimport { measurePath, type MeasurePathOptions, type PathStation } from './pathMeasure';\n\nexport type { PathStation };\n\n/** Options for `pointAlongPath`. */\nexport type PointAlongPathOptions = MeasurePathOptions;\n\n/**\n * Where `path` is at `t` of its total length, and its heading there.\n *\n * `t` is clamped to 0..1. Subpaths are measured in order and treated as one\n * run, the way a browser measures a whole `<path>`. Returns `null` for a path\n * with no points at all; a path of zero length answers at its single point,\n * heading along +X.\n */\nexport function pointAlongPath(\n path: Path,\n t: number,\n opts: PointAlongPathOptions = {},\n): PathStation | null {\n const measure = measurePath(path, opts);\n if (measure === null) return null;\n return measure.at(Math.min(Math.max(t, 0), 1) * measure.length);\n}\n","/**\n * A path as contours of cubic segments: every line and quadratic raised to a\n * cubic, each closing edge written out. The form a computation wants when it\n * treats every segment alike — interpolating two shapes, or carrying one\n * through a warp — and still needs to know which segments were straight.\n */\nimport { elevateQuadraticToCubic, splitCubicAt } from '../curve';\nimport { forEachSegment, PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from '../commands';\nimport type { Path, PathFillRule, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { resolveCorners } from './corners';\n\n/** One cubic segment, `[x0, y0, x1, y1, x2, y2, x3, y3]`, and whether it was\n * drawn straight. A straight one keeps its controls at its thirds, so it\n * interpolates and warps as a line would. */\nexport interface CubicSegment {\n c: [number, number, number, number, number, number, number, number];\n line: boolean;\n}\n\n/** One contour of segments, each starting where the one before it ends. */\nexport interface CubicContour {\n segs: CubicSegment[];\n closed: boolean;\n}\n\n/** A straight segment from (ax, ay) to (bx, by), controls at its thirds. */\nexport function lineSegment(ax: number, ay: number, bx: number, by: number): CubicSegment {\n const dx = (bx - ax) / 3;\n const dy = (by - ay) / 3;\n return { c: [ax, ay, ax + dx, ay + dy, bx - dx, by - dy, bx, by], line: true };\n}\n\n/**\n * `path`'s contours as cubic segments. A closed contour whose last point\n * stops short of its first gains the straight closing edge it is drawn with;\n * zero-length straight segments are dropped. A contour with no segments is a\n * lone point and is left out. Corner specs are expanded first.\n */\nexport function pathToCubicContours(path: Path): CubicContour[] {\n if (path.kind === 'rect') {\n const { x, y, width: w, height: h } = path;\n return [{\n closed: true,\n segs: [\n lineSegment(x, y, x + w, y),\n lineSegment(x + w, y, x + w, y + h),\n lineSegment(x + w, y + h, x, y + h),\n lineSegment(x, y + h, x, y),\n ],\n }];\n }\n const out: CubicContour[] = [];\n let current: CubicContour | null = null;\n let sx = 0;\n let sy = 0;\n const finish = (closed: boolean, px: number, py: number) => {\n if (current === null) return;\n if (closed) {\n if (px !== sx || py !== sy) current.segs.push(lineSegment(px, py, sx, sy));\n current.closed = true;\n }\n if (current.segs.length > 0) out.push(current);\n current = null;\n };\n const { commands, coords } = resolveCorners(path);\n forEachSegment(commands, coords, (cmd, ci, px, py, _i, opens) => {\n if (opens) {\n current = { segs: [], closed: false };\n sx = px;\n sy = py;\n }\n switch (cmd) {\n case PATH_M:\n finish(false, px, py);\n current = { segs: [], closed: false };\n sx = coords[ci]!;\n sy = coords[ci + 1]!;\n break;\n case PATH_L: {\n const x = coords[ci]!;\n const y = coords[ci + 1]!;\n if (x !== px || y !== py) current!.segs.push(lineSegment(px, py, x, y));\n break;\n }\n case PATH_Q: {\n const [c1x, c1y, c2x, c2y] = elevateQuadraticToCubic(\n px, py, coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!,\n );\n current!.segs.push({ c: [px, py, c1x, c1y, c2x, c2y, coords[ci + 2]!, coords[ci + 3]!], line: false });\n break;\n }\n case PATH_C:\n current!.segs.push({\n c: [px, py, coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!, coords[ci + 4]!, coords[ci + 5]!],\n line: false,\n });\n break;\n case PATH_Z:\n finish(true, px, py);\n break;\n }\n });\n const tail = current as CubicContour | null;\n if (tail !== null) {\n const last = tail.segs.at(-1);\n finish(false, last ? last.c[6] : sx, last ? last.c[7] : sy);\n }\n return out;\n}\n\n/** The path drawing `contours`: a straight segment as `L`, the rest as `C`. */\nexport function cubicContoursToPath(contours: readonly CubicContour[], fillRule: PathFillRule = 'nonzero'): PolygonPath {\n const b = new PathBuilder().setFillRule(fillRule);\n for (const { segs, closed } of contours) {\n if (segs.length === 0) continue;\n b.moveTo(segs[0]!.c[0], segs[0]!.c[1]);\n for (const { c, line } of segs) {\n if (line) b.lineTo(c[6], c[7]);\n else b.curveTo(c[2], c[3], c[4], c[5], c[6], c[7]);\n }\n if (closed) b.close();\n }\n return b.build();\n}\n\n/** `seg` split in two at parameter `t`. */\nexport function splitSegment(seg: CubicSegment, t: number): [CubicSegment, CubicSegment] {\n const [l, r] = splitCubicAt(...seg.c, t);\n return [\n { c: [...l] as CubicSegment['c'], line: seg.line },\n { c: [...r] as CubicSegment['c'], line: seg.line },\n ];\n}\n\n/** `contour` run the other way: segments in reverse order, each reversed. */\nexport function reverseContour(contour: CubicContour): CubicContour {\n return {\n closed: contour.closed,\n segs: contour.segs.slice().reverse().map(({ c, line }) => ({\n c: [c[6], c[7], c[4], c[5], c[2], c[3], c[0], c[1]],\n line,\n })),\n };\n}\n","/**\n * Shape interpolation between two paths: the steps of a blend, or the frames\n * of a morph.\n *\n * The two shapes are matched once — contour to contour, then segment to\n * segment — and every step is a straight lerp of the matched control points.\n * Where one contour has fewer segments, its longest ones are split in half\n * until the counts agree, which adds anchors without moving the outline.\n */\nimport type { Path, PathFillRule, PolygonPath } from '../path';\nimport {\n cubicContoursToPath, pathToCubicContours, reverseContour, splitSegment,\n type CubicContour, type CubicSegment,\n} from './cubicContours';\n\n/** How a blend matches the second shape's anchors to the first's. */\nexport interface BlendPathsOptions {\n /**\n * Choose, for each pair of contours, the start point (and, when `reverse`\n * is unset, the direction) of the second that keeps matched anchors\n * closest, with both contours centered on their own middles first so that\n * where the shapes sit does not decide it. Default `true`.\n */\n autoAlign?: boolean;\n /**\n * Turn the second shape's start point this many anchors further round each\n * closed contour, after any `autoAlign` choice. Negative turns it back.\n * Default 0.\n */\n startOffset?: number;\n /** Run the second shape's contours backwards. Unset, `autoAlign` decides;\n * without it, they run as drawn. */\n reverse?: boolean;\n}\n\n/** Two shapes matched for interpolation. */\nexport interface PathBlend {\n /** The shape `t` of the way from the first to the second: exactly the\n * first at 0 and the second at 1, up to the anchors matching added. */\n at(t: number): PolygonPath;\n /** Segments per matched pair of contours. */\n readonly segmentCounts: readonly number[];\n}\n\n/** The shape `t` of the way from `a` to `b`. Matching once with\n * {@link prepareBlend} is cheaper when several steps are wanted. */\nexport function blendPaths(a: Path, b: Path, t: number, opts: BlendPathsOptions = {}): PolygonPath {\n return prepareBlend(a, b, opts).at(t);\n}\n\n/** Match `a` to `b` for interpolation. */\nexport function prepareBlend(a: Path, b: Path, opts: BlendPathsOptions = {}): PathBlend {\n const ca = pathToCubicContours(a);\n const cb = pathToCubicContours(b);\n const n = Math.max(ca.length, cb.length);\n const pairs: [CubicContour, CubicContour][] = [];\n for (let i = 0; i < n; i++) {\n const x = ca[i] ?? collapsed(cb[i]!);\n const y = cb[i] ?? collapsed(ca[i]!);\n pairs.push(matchContours(x, y, opts));\n }\n const ruleA = fillRuleOf(a);\n const ruleB = fillRuleOf(b);\n return {\n segmentCounts: pairs.map(([x]) => x.segs.length),\n at(t) {\n const out = pairs.map(([x, y]) => lerpContour(x, y, t));\n return cubicContoursToPath(out, t < 0.5 ? ruleA : ruleB);\n },\n };\n}\n\nfunction fillRuleOf(path: Path): PathFillRule {\n return path.kind === 'polygon' ? path.fillRule : 'nonzero';\n}\n\n/** A contour with nothing to blend against grows from, or shrinks to, a\n * point at its own middle. */\nfunction collapsed(contour: CubicContour): CubicContour {\n const [cx, cy] = centroid(contour);\n return {\n closed: contour.closed,\n segs: contour.segs.map(({ line }) => ({ c: [cx, cy, cx, cy, cx, cy, cx, cy], line })),\n };\n}\n\n/** The mean of a contour's anchors. */\nfunction centroid(contour: CubicContour): [number, number] {\n let x = 0;\n let y = 0;\n for (const { c } of contour.segs) {\n x += c[0];\n y += c[1];\n }\n const n = Math.max(contour.segs.length, 1);\n return [x / n, y / n];\n}\n\n/** `a` and `b` with equal segment counts and `b` started where it best\n * corresponds to `a`. Both closed stay closed; otherwise both open. */\nfunction matchContours(a: CubicContour, b: CubicContour, opts: BlendPathsOptions): [CubicContour, CubicContour] {\n const closed = a.closed && b.closed;\n const x: CubicContour = { closed, segs: a.segs };\n const y: CubicContour = { closed, segs: b.segs };\n const auto = opts.autoAlign ?? true;\n const offset = Math.round(opts.startOffset ?? 0);\n const directions = opts.reverse !== undefined ? [opts.reverse] : auto ? [false, true] : [false];\n\n let best: { score: number; a: CubicContour; b: CubicContour; reversed: boolean; turn: number } | null = null;\n for (const reversed of directions) {\n const run = reversed ? reverseContour(y) : y;\n const turns = closed && auto ? run.segs.length : 1;\n for (let k = 0; k < turns; k++) {\n const [ma, mb] = equalize(x, rotate(run, k));\n const score = auto ? correspondence(ma, mb) : 0;\n if (best === null || score < best.score - 1e-9) best = { score, a: ma, b: mb, reversed, turn: k };\n }\n }\n const chosen = best!;\n if (!closed || offset === 0) return [chosen.a, chosen.b];\n const run = chosen.reversed ? reverseContour(y) : y;\n return equalize(x, rotate(run, chosen.turn + offset));\n}\n\n/** `contour` started `k` segments later; a no-op on an open one. */\nfunction rotate(contour: CubicContour, k: number): CubicContour {\n const n = contour.segs.length;\n if (!contour.closed || n === 0) return contour;\n const s = ((k % n) + n) % n;\n if (s === 0) return contour;\n return { closed: true, segs: [...contour.segs.slice(s), ...contour.segs.slice(0, s)] };\n}\n\n/** Both contours split until they have as many segments as each other. */\nfunction equalize(a: CubicContour, b: CubicContour): [CubicContour, CubicContour] {\n const n = Math.max(a.segs.length, b.segs.length);\n return [\n { closed: a.closed, segs: subdivideTo(a.segs, n) },\n { closed: b.closed, segs: subdivideTo(b.segs, n) },\n ];\n}\n\n/** `segs` with its longest segments halved until there are `n` of them. */\nfunction subdivideTo(segs: readonly CubicSegment[], n: number): CubicSegment[] {\n const out = segs.slice();\n if (out.length === 0) return out;\n while (out.length < n) {\n let longest = 0;\n let longestLen = -1;\n for (let i = 0; i < out.length; i++) {\n const len = hullLength(out[i]!);\n if (len > longestLen) { longest = i; longestLen = len; }\n }\n out.splice(longest, 1, ...splitSegment(out[longest]!, 0.5));\n }\n return out;\n}\n\n/** A segment's length estimate: the mean of its chord and control polygon. */\nfunction hullLength({ c }: CubicSegment): number {\n const chord = Math.hypot(c[6] - c[0], c[7] - c[1]);\n const hull = Math.hypot(c[2] - c[0], c[3] - c[1])\n + Math.hypot(c[4] - c[2], c[5] - c[3])\n + Math.hypot(c[6] - c[4], c[7] - c[5]);\n return (chord + hull) / 2;\n}\n\n/** How far matched anchors sit apart once each contour is centered: the sum\n * of squared distances. */\nfunction correspondence(a: CubicContour, b: CubicContour): number {\n const [ax, ay] = centroid(a);\n const [bx, by] = centroid(b);\n let sum = 0;\n const add = (pa: number, pb: number, qa: number, qb: number) => {\n sum += (pa - ax - (qa - bx)) ** 2 + (pb - ay - (qb - by)) ** 2;\n };\n for (let i = 0; i < a.segs.length; i++) {\n const p = a.segs[i]!.c;\n const q = b.segs[i]!.c;\n add(p[0], p[1], q[0], q[1]);\n }\n if (!a.closed && a.segs.length > 0) {\n const p = a.segs.at(-1)!.c;\n const q = b.segs.at(-1)!.c;\n add(p[6], p[7], q[6], q[7]);\n }\n return sum;\n}\n\nfunction lerpContour(a: CubicContour, b: CubicContour, t: number): CubicContour {\n return {\n closed: a.closed,\n segs: a.segs.map((sa, i) => {\n const sb = b.segs[i]!;\n const c = sa.c.map((v, j) => v + (sb.c[j]! - v) * t) as CubicSegment['c'];\n return { c, line: sa.line && sb.line };\n }),\n };\n}\n","/**\n * Bend a shape along a spine: the shape's x becomes distance along the spine\n * and its y distance off it, along the spine's normal. A straight edge of the\n * shape comes out curved wherever the spine bends, so each segment is\n * sampled through the warp and refit to cubics within a tolerance; anchors\n * stay where they were, so a corner of the shape stays a corner.\n */\nimport type { Path, PolygonPath } from '../path';\nimport { cubicEvalAt } from '../curve';\nimport { boundsOfPath } from './bounds';\nimport { PathBuilder } from './builder';\nimport { pathToCubicContours, type CubicSegment } from './cubicContours';\nimport type { Point } from './cubicMath';\nimport { measurePath, type PathMeasure } from './pathMeasure';\nimport { schneiderFit } from './schneiderFit';\n\n/** How a shape is laid along its spine. */\nexport interface BendAlongPathOptions {\n /**\n * `'stretch'`, the default, spreads the shape's width over the spine's\n * whole length. `'natural'` keeps its width: one unit across the shape is\n * one unit along the spine, starting at the spine's start, and a shape\n * longer than the spine runs on straight past its end.\n */\n fit?: 'stretch' | 'natural';\n /** Where across the shape's height the spine runs, 0 at its top and 1 at\n * its bottom. Default 0.5, the middle. */\n baseline?: number;\n /** Lay the shape on the other side of the spine, mirrored across it. */\n flip?: boolean;\n /** How far the refit curves may stray from the exact bend, in world\n * units. Default 0.5. */\n tolerance?: number;\n}\n\n/**\n * `shape` bent along `spine`. A spine heading left to right keeps the shape\n * upright; one heading the other way turns it over, as a road sign painted\n * along a lane does. Returns `null` when the spine has no length or the shape\n * nothing to bend.\n */\nexport function bendAlongPath(shape: Path, spine: Path, opts: BendAlongPathOptions = {}): PolygonPath | null {\n const tolerance = Math.max(opts.tolerance ?? 0.5, 1e-3);\n const measure = measurePath(spine, { flattenTolerance: tolerance / 4 });\n if (measure === null || measure.length === 0) return null;\n const contours = pathToCubicContours(shape);\n if (contours.length === 0) return null;\n\n const box = boundsOfPath(shape);\n const stretch = (opts.fit ?? 'stretch') === 'stretch';\n const along = stretch && box.width > 0 ? measure.length / box.width : 1;\n const baseY = box.y + box.height * (opts.baseline ?? 0.5);\n const side = opts.flip ? -1 : 1;\n const warp = (x: number, y: number): Point =>\n stationOff(measure, (x - box.x) * along, (y - baseY) * side);\n\n // A sample every few tolerances along the bent outline keeps the warp's own\n // curvature inside what the fit can see.\n const step = Math.max(tolerance * 4, 0.5);\n const b = new PathBuilder().setFillRule(shape.kind === 'polygon' ? shape.fillRule : 'nonzero');\n for (const { segs, closed } of contours) {\n const start = warp(segs[0]!.c[0], segs[0]!.c[1]);\n b.moveTo(start.x, start.y);\n for (const seg of segs) appendBent(b, seg, warp, step, along, tolerance);\n if (closed) b.close();\n }\n return b.build();\n}\n\n/** The point `s` along the spine and `v` off it along its normal. Past\n * either end of an open spine it carries on straight; round a closed one it\n * wraps. */\nfunction stationOff(measure: PathMeasure, s: number, v: number): Point {\n const L = measure.length;\n let at = s;\n if (measure.closed) at = ((s % L) + L) % L;\n const clamped = Math.min(Math.max(at, 0), L);\n const { point, tangent } = measure.at(clamped, true);\n const run = at - clamped;\n return {\n x: point.x + tangent.x * run - tangent.y * v,\n y: point.y + tangent.y * run + tangent.x * v,\n };\n}\n\nfunction appendBent(\n b: PathBuilder,\n seg: CubicSegment,\n warp: (x: number, y: number) => Point,\n step: number,\n along: number,\n tolerance: number,\n): void {\n const c = seg.c;\n const reach = (Math.hypot(c[2] - c[0], c[3] - c[1]) + Math.hypot(c[4] - c[2], c[5] - c[3])\n + Math.hypot(c[6] - c[4], c[7] - c[5])) * Math.max(along, 1);\n const n = Math.min(Math.max(Math.ceil(reach / step), 4), 512);\n const samples: Point[] = [];\n for (let i = 0; i <= n; i++) {\n const [x, y] = cubicEvalAt(...c, i / n);\n samples.push(warp(x, y));\n }\n const fit = schneiderFit(samples, tolerance);\n const { commands, coords } = fit;\n // The fit opens with an M at the first sample, which the pen already holds.\n for (let i = 1, ci = 2; i < commands.length; i++, ci += 6) {\n b.curveTo(coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!, coords[ci + 4]!, coords[ci + 5]!);\n }\n}\n","/**\n * Copies of a shape placed at intervals along a path: the stations they sit\n * at, and the copies themselves.\n */\nimport { multiply, rotate, translate } from '../affine';\nimport type { Path } from '../path';\nimport { boundsOfPath } from './bounds';\nimport type { Point } from './cubicMath';\nimport { measurePath } from './pathMeasure';\nimport { transformPath } from './transformPath';\n\n/** How copies are spaced along a path. */\nexport interface RepeatAlongPathOptions {\n /**\n * How many copies. With no `spacing`, they spread evenly over the whole\n * path — end to end on an open one, evenly round a closed one — and the\n * default is 5. With a `spacing`, it caps the run; unset, as many as fit.\n */\n count?: number;\n /** Distance along the path from one copy's center to the next. */\n spacing?: number;\n /** Where a spaced run that is shorter than the path sits on it. Default\n * `'start'`. */\n align?: 'start' | 'center' | 'end';\n /** Slide every copy this far along the path. On an open path a copy slid\n * off either end is dropped; round a closed one it wraps. Default 0. */\n offset?: number;\n /** Turn each copy to the path's heading where it sits. Default `true`. */\n orient?: boolean;\n /** Curve flattening tolerance for measuring the path. Default 0.5. */\n flattenTolerance?: number;\n}\n\n/** Where one copy sits. */\nexport interface RepeatStation {\n point: Point;\n /** The path's heading there, radians clockwise from +X in a y-down frame. */\n angle: number;\n /** Arc length from the path's start. */\n distance: number;\n}\n\nconst EPS = 1e-6;\n\n/** The stations copies sit at along `path`, in order. Empty for a path with\n * no points. */\nexport function stationsAlongPath(path: Path, opts: RepeatAlongPathOptions = {}): RepeatStation[] {\n const measure = measurePath(path, opts.flattenTolerance === undefined ? {} : { flattenTolerance: opts.flattenTolerance });\n if (measure === null) return [];\n const L = measure.length;\n const offset = opts.offset ?? 0;\n const distances: number[] = [];\n const spacing = opts.spacing;\n if (spacing === undefined || !(spacing > 0)) {\n const n = Math.max(Math.floor(opts.count ?? 5), 0);\n if (measure.closed) for (let i = 0; i < n; i++) distances.push(offset + (i * L) / Math.max(n, 1));\n else if (n === 1) distances.push(offset + L / 2);\n else for (let i = 0; i < n; i++) distances.push(offset + (i * L) / (n - 1));\n } else {\n const fit = measure.closed ? Math.floor(L / spacing + EPS) : Math.floor(L / spacing + EPS) + 1;\n const n = Math.max(Math.min(opts.count === undefined ? fit : Math.floor(opts.count), fit), 0);\n const run = Math.max(n - 1, 0) * spacing;\n const align = opts.align ?? 'start';\n const start = align === 'center' ? (L - run) / 2 : align === 'end' ? L - run : 0;\n for (let i = 0; i < n; i++) distances.push(start + offset + i * spacing);\n }\n\n const out: RepeatStation[] = [];\n for (const d of distances) {\n let s = d;\n if (measure.closed && L > 0) s = ((d % L) + L) % L;\n else if (d < -EPS || d > L + EPS) continue;\n const { point, tangent } = measure.at(s);\n out.push({ point, angle: Math.atan2(tangent.y, tangent.x), distance: s });\n }\n return out;\n}\n\n/**\n * Copies of `shape`, each centered on a station along `path` — its bounding\n * box's middle on the path — and, with `orient`, turned to the heading\n * there. The shape's own +X runs along the path.\n */\nexport function repeatAlongPath(shape: Path, path: Path, opts: RepeatAlongPathOptions = {}): Path[] {\n const box = boundsOfPath(shape);\n const cx = box.x + box.width / 2;\n const cy = box.y + box.height / 2;\n const orient = opts.orient ?? true;\n return stationsAlongPath(path, opts).map(({ point, angle }) => {\n const toOrigin = translate(-cx, -cy);\n const place = translate(point.x, point.y);\n const m = orient ? multiply(place, multiply(rotate(angle), toOrigin)) : multiply(place, toOrigin);\n return transformPath(shape, m);\n });\n}\n","/**\n * Pure-geometry distance from a point to a path's boundary (stroke), with\n * no fill-side logic. Used by pickers that want to know \"how close is this\n * click to the visible edge of the shape?\" Callers combine this with\n * `pathContainsPoint` from `pathHitTest.ts` to get a closed-region\n * pick distance (0 inside, stroke-distance outside).\n *\n * A polygon path defers to geom's `nearestOnPath`; a RectPath short-circuits\n * to AABB-perimeter math.\n */\n\nimport { nearestOnPath } from '../nearest';\nimport { resolveCorners } from './corners';\nimport type { Path } from '../path';\n\n/** Distance from (px, py) to the perimeter of an axis-aligned rectangle.\n * Returns 0 if the point is on the perimeter; positive value outside or\n * inside (distance to the nearest edge). */\nfunction pointToRectPerimeterDist(\n px: number, py: number,\n rx: number, ry: number, rw: number, rh: number,\n): number {\n // Distance to the rect as a region: 0 if inside, else Euclidean distance\n // to the AABB. For interior points, return distance to the closest edge.\n const dx = Math.max(rx - px, px - (rx + rw), 0);\n const dy = Math.max(ry - py, py - (ry + rh), 0);\n if (dx > 0 || dy > 0) return Math.hypot(dx, dy);\n // Inside: distance to closest edge.\n const left = px - rx, right = rx + rw - px;\n const top = py - ry, bottom = ry + rh - py;\n return Math.min(left, right, top, bottom);\n}\n\n/** Closest Euclidean distance from (px, py) to the boundary of `path`.\n * Pure stroke distance — does *not* consult fill rule or interior. For\n * closed-region pick distance (\"0 inside, stroke-distance outside\"),\n * combine with `pathContainsPoint` at the call site. */\nexport function pathDistanceToPoint(path: Path, px: number, py: number): number {\n if (path.kind === 'rect') {\n return pointToRectPerimeterDist(px, py, path.x, path.y, path.width, path.height);\n }\n const drawn = resolveCorners(path);\n return nearestOnPath(drawn.commands, drawn.coords, px, py)?.dist ?? Infinity;\n}\n","/** Where two Bézier segments cross, by subdivision then Newton refinement. */\n\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, derivSeg, type Seg } from '../booleans/contourSegments';\n\n/** One crossing of segments `a` and `b`: the parameter on each, and the point. */\nexport interface SegmentCrossing {\n ta: number;\n tb: number;\n x: number;\n y: number;\n}\n\n/** Subdivision stops once both pieces are this flat (world units). */\nconst FLAT = 1e-4;\nconst MAX_DEPTH = 48;\n/** Crossings closer than this along both parameters are one crossing. */\nconst SAME_T = 1e-7;\n/** Two overlapping curves cross everywhere; stop collecting past this. */\nconst MAX_HITS = 16;\n\ninterface Piece {\n pts: Seg;\n t0: number;\n t1: number;\n}\n\nfunction boxOf(pts: Seg): [number, number, number, number] {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of pts) {\n if (p.x < x0) x0 = p.x;\n if (p.x > x1) x1 = p.x;\n if (p.y < y0) y0 = p.y;\n if (p.y > y1) y1 = p.y;\n }\n return [x0, y0, x1, y1];\n}\n\n/** How far the control points stray from the chord. Zero for a line. */\nfunction flatness(pts: Seg): number {\n if (pts.length === 2) return 0;\n const a = pts[0], b = pts[pts.length - 1];\n const dx = b.x - a.x, dy = b.y - a.y;\n const len = Math.hypot(dx, dy);\n let worst = 0;\n for (let i = 1; i < pts.length - 1; i++) {\n const p = pts[i];\n const d = len === 0 ? Math.hypot(p.x - a.x, p.y - a.y) : Math.abs((p.x - a.x) * dy - (p.y - a.y) * dx) / len;\n if (d > worst) worst = d;\n }\n return worst;\n}\n\n/** De Casteljau at one half, for a segment of any degree. */\nfunction halve(p: Piece): [Piece, Piece] {\n let row = p.pts;\n const left: Point[] = [row[0]];\n const right: Point[] = [row[row.length - 1]];\n while (row.length > 1) {\n const next: Point[] = [];\n for (let i = 0; i + 1 < row.length; i++) {\n next.push({ x: (row[i].x + row[i + 1].x) / 2, y: (row[i].y + row[i + 1].y) / 2 });\n }\n row = next;\n left.push(row[0]);\n right.unshift(row[row.length - 1]);\n }\n const tm = (p.t0 + p.t1) / 2;\n return [{ pts: left, t0: p.t0, t1: tm }, { pts: right, t0: tm, t1: p.t1 }];\n}\n\n/** Where chords p0→p1 and q0→q1 cross, as parameters on each, or null when\n * they are parallel or miss. `slack` widens [0, 1] on both. */\nfunction chordCross(p0: Point, p1: Point, q0: Point, q1: Point, slack: number): [number, number] | null {\n const rx = p1.x - p0.x, ry = p1.y - p0.y;\n const sx = q1.x - q0.x, sy = q1.y - q0.y;\n const den = rx * sy - ry * sx;\n if (den === 0) return null;\n const qx = q0.x - p0.x, qy = q0.y - p0.y;\n const u = (qx * sy - qy * sx) / den;\n const v = (qx * ry - qy * rx) / den;\n if (u < -slack || u > 1 + slack || v < -slack || v > 1 + slack) return null;\n return [u, v];\n}\n\n/** Newton on A(ta) − B(tb) = 0, kept inside [0, 1]. */\nfunction refine(a: Seg, b: Seg, ta: number, tb: number): [number, number] {\n for (let i = 0; i < 12; i++) {\n const pa = evalSeg(a, ta), pb = evalSeg(b, tb);\n const fx = pa.x - pb.x, fy = pa.y - pb.y;\n if (Math.abs(fx) + Math.abs(fy) < 1e-12) break;\n const da = derivSeg(a, ta), db = derivSeg(b, tb);\n // J = [da, -db]; solve J·[δa, δb] = −f.\n const det = -da.x * db.y + da.y * db.x;\n if (det === 0) break;\n const dta = (-fx * -db.y - -fy * -db.x) / det;\n const dtb = (da.x * -fy - da.y * -fx) / det;\n ta = Math.min(1, Math.max(0, ta + dta));\n tb = Math.min(1, Math.max(0, tb + dtb));\n }\n return [ta, tb];\n}\n\n/**\n * Every point where segment `a` crosses or touches segment `b` — each a line,\n * quadratic or cubic given by its control points — with the parameter on\n * each. Two lines are solved exactly; a curve is subdivided until its pieces\n * are flat, their chords crossed, and the answer refined against the curves.\n * Segments that overlap along a stretch report at most a few points of it.\n * Sorted by `ta`.\n */\nexport function intersectSegments(a: Point[], b: Point[]): SegmentCrossing[] {\n if (a.length === 2 && b.length === 2) {\n const uv = chordCross(a[0], a[1], b[0], b[1], 1e-12);\n if (!uv) return [];\n const ta = Math.min(1, Math.max(0, uv[0]));\n const tb = Math.min(1, Math.max(0, uv[1]));\n const p = evalSeg(a, ta);\n return [{ ta, tb, x: p.x, y: p.y }];\n }\n const out: SegmentCrossing[] = [];\n const push = (ta: number, tb: number) => {\n [ta, tb] = refine(a, b, ta, tb);\n const pa = evalSeg(a, ta), pb = evalSeg(b, tb);\n if (Math.hypot(pa.x - pb.x, pa.y - pb.y) > 1e-6 * (1 + Math.abs(pa.x) + Math.abs(pa.y))) return;\n if (out.some((h) => Math.abs(h.ta - ta) < SAME_T && Math.abs(h.tb - tb) < SAME_T)) return;\n out.push({ ta, tb, x: pa.x, y: pa.y });\n };\n const stack: Array<[Piece, Piece, number]> = [[{ pts: a, t0: 0, t1: 1 }, { pts: b, t0: 0, t1: 1 }, 0]];\n while (stack.length > 0 && out.length < MAX_HITS) {\n const [p, q, depth] = stack.pop()!;\n const bp = boxOf(p.pts), bq = boxOf(q.pts);\n if (bp[0] > bq[2] + FLAT || bq[0] > bp[2] + FLAT || bp[1] > bq[3] + FLAT || bq[1] > bp[3] + FLAT) continue;\n const fp = flatness(p.pts), fq = flatness(q.pts);\n if ((fp <= FLAT && fq <= FLAT) || depth >= MAX_DEPTH) {\n const uv = chordCross(p.pts[0], p.pts[p.pts.length - 1], q.pts[0], q.pts[q.pts.length - 1], 1e-6);\n if (uv) push(p.t0 + uv[0] * (p.t1 - p.t0), q.t0 + uv[1] * (q.t1 - q.t0));\n continue;\n }\n if (fp >= fq) {\n const [l, r] = halve(p);\n stack.push([l, q, depth + 1], [r, q, depth + 1]);\n } else {\n const [l, r] = halve(q);\n stack.push([p, l, depth + 1], [p, r, depth + 1]);\n }\n }\n return out.sort((h, k) => h.ta - k.ta);\n}\n","/** A path's stroke as a flat list of segments, each knowing where it sits. */\n\nimport type { Path } from '../path';\nimport { parseSubpaths } from '../booleans/contours';\nimport type { Point } from '../paths/cubicMath';\n\n/** One segment of a path's stroke, in the order the path draws them. */\nexport interface PathSegment {\n /** Control points: 2 for a line, 3 for a quadratic, 4 for a cubic. */\n pts: Point[];\n /** Index of its subpath among the path's subpaths. */\n sub: number;\n /** Index within its subpath. */\n index: number;\n /** Segments in its subpath. */\n count: number;\n /** Whether its subpath is closed, so its last segment meets its first. */\n closed: boolean;\n /** Axis-aligned box of the control points, which holds the segment. */\n box: { x0: number; y0: number; x1: number; y1: number };\n}\n\n/** `path`'s stroke as segments: a closed subpath includes its closing edge,\n * an open one does not, and a zero-length line is left out. */\nexport function pathSegments(path: Path): PathSegment[] {\n const out: PathSegment[] = [];\n parseSubpaths(path, false).forEach(({ segs, closed }, sub) => {\n segs.forEach((pts, index) => {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of pts) {\n x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x);\n y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y);\n }\n out.push({ pts, sub, index, count: segs.length, closed, box: { x0, y0, x1, y1 } });\n });\n });\n return out;\n}\n\n/** Whether two boxes overlap or touch. */\nexport function boxesNear(a: PathSegment['box'], b: PathSegment['box']): boolean {\n return a.x0 <= b.x1 && b.x0 <= a.x1 && a.y0 <= b.y1 && b.y0 <= a.y1;\n}\n\n/** Whether segments `a` and `b` of one path follow each other, so they meet\n * at a shared end that is no crossing. */\nexport function adjacentSegments(a: PathSegment, b: PathSegment): boolean {\n if (a.sub !== b.sub) return false;\n const d = Math.abs(a.index - b.index);\n return d === 1 || (a.closed && d === a.count - 1);\n}\n","/** Where paths cross one another and themselves. */\n\nimport type { Path } from '../path';\nimport { intersectSegments } from './segmentIntersections';\nimport { adjacentSegments, boxesNear, pathSegments, type PathSegment } from './pathSegments';\n\n/** A place on a path's stroke: which segment, and how far along it. */\nexport interface PathStop {\n /** Index of the path in the list it came from. */\n path: number;\n sub: number;\n /** Segment index within the subpath. */\n index: number;\n /** Parameter on that segment, in [0, 1]. */\n t: number;\n}\n\n/** A point where two strokes cross or touch, and where it falls on each. */\nexport interface PathCrossing {\n x: number;\n y: number;\n a: PathStop;\n b: PathStop;\n}\n\nconst END = 1e-9;\n\n/** Whether a hit between neighboring segments is just their shared end. */\nfunction sharedEnd(a: PathSegment, b: PathSegment, ta: number, tb: number): boolean {\n if (!adjacentSegments(a, b)) return false;\n return (ta > 1 - END && tb < END) || (ta < END && tb > 1 - END);\n}\n\n/**\n * Every crossing among `paths`: between each pair, and — unless `self` is\n * false — of a path with itself, leaving out the joint where one segment\n * meets the next. Points where strokes merely touch count too. With `of`,\n * only the crossings involving that one path.\n */\nexport function pathCrossings(paths: readonly Path[], opts: { self?: boolean; of?: number } = {}): PathCrossing[] {\n const segs = paths.map(pathSegments);\n const out: PathCrossing[] = [];\n for (let i = 0; i < segs.length; i++) {\n for (let j = i; j < segs.length; j++) {\n if (i === j && opts.self === false) continue;\n if (opts.of !== undefined && i !== opts.of && j !== opts.of) continue;\n for (let m = 0; m < segs[i].length; m++) {\n for (let n = i === j ? m + 1 : 0; n < segs[j].length; n++) {\n const sa = segs[i][m], sb = segs[j][n];\n if (!boxesNear(sa.box, sb.box)) continue;\n for (const h of intersectSegments(sa.pts, sb.pts)) {\n if (i === j && sharedEnd(sa, sb, h.ta, h.tb)) continue;\n out.push({\n x: h.x,\n y: h.y,\n a: { path: i, sub: sa.sub, index: sa.index, t: h.ta },\n b: { path: j, sub: sb.sub, index: sb.index, t: h.tb },\n });\n }\n }\n }\n }\n }\n return out;\n}\n\n/** Where `path`'s stroke is crossed, by `cutters` and by itself, as stops on\n * `path` (each with `path: 0`) — the cuts a trim chooses between. */\nexport function crossingStops(path: Path, cutters: readonly Path[]): PathStop[] {\n const stops: PathStop[] = [];\n for (const c of pathCrossings([path, ...cutters], { of: 0 })) {\n if (c.a.path === 0) stops.push(c.a);\n if (c.b.path === 0) stops.push(c.b);\n }\n return stops;\n}\n","/** Measuring one Bézier segment by arc length, and finding where a run of it ends. */\n\nimport { derivSeg, type Seg } from '../booleans/contourSegments';\n\nconst GL_X = [-0.9602898564975363, -0.7966664774136267, -0.5255324099163290, -0.1834346424956498,\n 0.1834346424956498, 0.5255324099163290, 0.7966664774136267, 0.9602898564975363];\nconst GL_W = [0.1012285362903763, 0.2223810344533745, 0.3137066458778873, 0.3626837833783620,\n 0.3626837833783620, 0.3137066458778873, 0.2223810344533745, 0.1012285362903763];\n\nconst speed = (s: Seg, t: number): number => {\n const d = derivSeg(s, t);\n return Math.hypot(d.x, d.y);\n};\n\n/** Length of `s` between parameters `a` and `b`, by Gauss–Legendre over\n * eight panels. */\nexport function segmentLength(s: Seg, a = 0, b = 1): number {\n if (s.length === 2) return speed(s, 0) * (b - a);\n const panels = 8, h = (b - a) / panels;\n let sum = 0;\n for (let k = 0; k < panels; k++) {\n const mid = a + (k + 0.5) * h;\n for (let i = 0; i < GL_X.length; i++) sum += GL_W[i] * speed(s, mid + GL_X[i] * h / 2);\n }\n return sum * h / 2;\n}\n\n/** The parameter at which `s` has run `length` from its start, clamped to\n * 0..1: Newton steps on the arc length, held inside a shrinking bracket. */\nexport function segmentTAtLength(s: Seg, length: number): number {\n const total = segmentLength(s);\n if (length <= 0 || !(total > 0)) return 0;\n if (length >= total) return 1;\n if (s.length === 2) return length / total;\n let lo = 0, hi = 1, t = length / total;\n for (let i = 0; i < 30; i++) {\n const err = segmentLength(s, 0, t) - length;\n if (Math.abs(err) < 1e-10 * Math.max(1, total)) break;\n if (err > 0) hi = t; else lo = t;\n const v = speed(s, t);\n let next = v > 0 ? t - err / v : NaN;\n if (!(next > lo && next < hi)) next = (lo + hi) / 2;\n t = next;\n }\n return t;\n}\n","/**\n * Distinguished points on one Bézier segment: its middle by length, where its\n * tangent turns horizontal or vertical, and where a line from an outside\n * point meets it at a tangent or at a right angle.\n */\n\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, derivSeg, type Seg } from '../booleans/contourSegments';\nimport { segmentLength, segmentTAtLength } from '../paths/segmentLength';\n\n/** The parameter at the middle of `s` by arc length. */\nexport function segmentMidT(s: Seg): number {\n if (s.length === 2) return 0.5;\n return segmentTAtLength(s, segmentLength(s) / 2);\n}\n\n/** Roots of a quadratic a t² + b t + c in [0, 1]. */\nfunction unitQuadraticRoots(a: number, b: number, c: number): number[] {\n const inside = (t: number) => t >= -1e-9 && t <= 1 + 1e-9;\n if (Math.abs(a) < 1e-12) {\n if (Math.abs(b) < 1e-12) return [];\n const t = -c / b;\n return inside(t) ? [Math.min(1, Math.max(0, t))] : [];\n }\n const disc = b * b - 4 * a * c;\n if (disc < 0) return [];\n const r = Math.sqrt(disc);\n return [(-b - r) / (2 * a), (-b + r) / (2 * a)].filter(inside).map((t) => Math.min(1, Math.max(0, t)));\n}\n\n/** Parameters on a curved segment, its ends included, where its tangent is\n * horizontal or vertical — the local extremes in x or y. None on a line. */\nexport function segmentExtremaT(s: Seg): number[] {\n if (s.length === 2) return [];\n const n = s.length - 1;\n // Derivative control points, then the derivative in power form per axis.\n const d: Point[] = [];\n for (let i = 0; i < n; i++) d.push({ x: n * (s[i + 1].x - s[i].x), y: n * (s[i + 1].y - s[i].y) });\n const axis = (k: 'x' | 'y'): number[] => d.length === 2\n ? unitQuadraticRoots(0, d[1][k] - d[0][k], d[0][k])\n : unitQuadraticRoots(d[0][k] - 2 * d[1][k] + d[2][k], 2 * (d[1][k] - d[0][k]), d[0][k]);\n return [...axis('x'), ...axis('y')].sort((p, q) => p - q);\n}\n\n/** Roots of `f` on [0, 1]: sign changes between samples, closed by bisection. */\nfunction rootsOn(f: (t: number) => number, samples = 48): number[] {\n const out: number[] = [];\n let t0 = 0, f0 = f(0);\n if (f0 === 0) out.push(0);\n for (let k = 1; k <= samples; k++) {\n const t1 = k / samples, f1 = f(t1);\n if (f1 === 0) out.push(t1);\n else if (f0 !== 0 && (f0 < 0) !== (f1 < 0)) {\n let lo = t0, hi = t1, flo = f0;\n for (let i = 0; i < 60; i++) {\n const mid = (lo + hi) / 2, fm = f(mid);\n if ((fm < 0) === (flo < 0)) { lo = mid; flo = fm; } else hi = mid;\n }\n out.push((lo + hi) / 2);\n }\n t0 = t1; f0 = f1;\n }\n return out;\n}\n\n/** Parameters where a line from `o` touches curved segment `s` at a tangent.\n * None on a line, whose tangent is everywhere its own direction. */\nexport function tangentTsFrom(s: Seg, o: Point): number[] {\n if (s.length === 2) return [];\n return rootsOn((t) => {\n const p = evalSeg(s, t), d = derivSeg(s, t);\n return (p.x - o.x) * d.y - (p.y - o.y) * d.x;\n });\n}\n\n/** Parameters where a line from `o` meets `s` at a right angle: the feet of\n * the perpendiculars dropped from `o`, ends of the segment excepted unless\n * the right angle falls exactly there. */\nexport function perpendicularTsFrom(s: Seg, o: Point): number[] {\n return rootsOn((t) => {\n const p = evalSeg(s, t), d = derivSeg(s, t);\n return (p.x - o.x) * d.x + (p.y - o.y) * d.y;\n });\n}\n","/**\n * Geometric snapping onto paths: the points on a set of strokes a drawn or\n * dragged point can lock to, and which of them a probe lands on.\n */\n\nimport type { Path } from '../path';\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, type Seg } from '../booleans/contourSegments';\nimport { nearestOnCubic, nearestOnLine, nearestOnQuadratic } from '../nearest';\nimport { pathCrossings } from '../intersect/pathCrossings';\nimport { intersectSegments } from '../intersect/segmentIntersections';\nimport { pathSegments, type PathSegment } from '../intersect/pathSegments';\nimport { perpendicularTsFrom, segmentExtremaT, segmentMidT, tangentTsFrom } from './segmentFeatures';\n\n/**\n * What a snap target is.\n *\n * - `anchor` — an end of a segment: a path's anchors, a box's corners.\n * - `center` — a point a caller names as the middle of something: a text or\n * image box's center, given to {@link createPathSnapIndex} as a target.\n * - `intersection` — where two strokes cross, or one crosses itself.\n * - `tangent` — where a line from the query's origin touches a curve.\n * - `perpendicular` — where a line from the origin meets a stroke square on.\n * - `midpoint` — the middle of a segment by length.\n * - `extremum` — on a curve, where its tangent turns horizontal or vertical.\n * - `quadrant` — where a closed subpath crosses the horizontal and vertical\n * lines through the center of its box: a circle's four compass points.\n * - `nearest` — the closest point on any stroke, when nothing else is in range.\n */\nexport type PathSnapKind =\n | 'anchor' | 'center' | 'intersection' | 'tangent' | 'perpendicular' | 'midpoint' | 'extremum' | 'quadrant'\n | 'nearest';\n\n/** Every snap kind, in the order a picker lists them. */\nexport const PATH_SNAP_KINDS: readonly PathSnapKind[] = [\n 'anchor', 'center', 'intersection', 'tangent', 'perpendicular', 'midpoint', 'extremum', 'quadrant', 'nearest',\n];\n\n/** The kinds whose targets stand whatever the probe. */\nexport type StaticPathSnapKind = 'anchor' | 'center' | 'intersection' | 'midpoint' | 'extremum' | 'quadrant';\nconst STATIC_KINDS: readonly StaticPathSnapKind[] = ['anchor', 'center', 'intersection', 'midpoint', 'extremum', 'quadrant'];\n\n/** A target the probe landed on. */\nexport interface PathSnapHit {\n kind: PathSnapKind;\n x: number;\n y: number;\n /** Distance from the probe, in the query's `radius` units. */\n distance: number;\n /** Indices of the paths that make the target: two for a crossing between\n * paths, one otherwise. */\n paths: readonly number[];\n}\n\n/** A query for {@link findPathSnap}. */\nexport interface PathSnapQuery {\n /** How far from the probe a target may be, in the paths' units times\n * `scale`. */\n radius: number;\n /** Per-axis scale from the paths' units to the units `radius` is in — a\n * view's, to measure the radius in screen pixels under any zoom. Default\n * `{ x: 1, y: 1 }`. */\n scale?: { x: number; y: number };\n /** Kinds to consider. Absent, all of them. */\n kinds?: Iterable<PathSnapKind>;\n /** Where the line being drawn starts. Tangent and perpendicular targets are\n * measured from it, and there are none without it. */\n origin?: Point;\n /** Paths by index that offer no targets — the ones a drag is moving. */\n skip?: (path: number) => boolean;\n}\n\n/** A target that stands whatever the probe: an anchor, a center, a crossing,\n * a midpoint, an extremum or a quadrant point. */\nexport interface PathSnapTarget {\n kind: StaticPathSnapKind;\n x: number;\n y: number;\n paths: readonly number[];\n}\n\n/** A set of paths, prepared for repeated snapping. Static targets are\n * computed on first use and kept. */\nexport interface PathSnapIndex {\n readonly paths: readonly Path[];\n /** Each path's segments. */\n readonly segments: readonly (readonly PathSegment[])[];\n /** The targets that do not depend on the probe, of one kind. */\n targets(kind: StaticPathSnapKind): readonly PathSnapTarget[];\n}\n\n/** Prepare `paths` for {@link findPathSnap}. Build one per set of paths and\n * reuse it while they stand: a crossing search is quadratic in segments.\n * `extra` adds targets of the caller's own — the center of a box, a point\n * with no segment at it — each naming the path it belongs to. */\nexport function createPathSnapIndex(paths: readonly Path[], extra: readonly PathSnapTarget[] = []): PathSnapIndex {\n const segments = paths.map(pathSegments);\n const cache = new Map<string, PathSnapTarget[]>();\n const build = (kind: string): PathSnapTarget[] => {\n const out: PathSnapTarget[] = extra.filter((t) => t.kind === kind);\n if (kind === 'center') return out;\n if (kind === 'anchor') {\n segments.forEach((segs, path) => {\n const seen = new Set<string>();\n for (const s of segs) {\n for (const p of [s.pts[0], s.pts[s.pts.length - 1]]) {\n const key = `${p.x},${p.y}`;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push({ kind: 'anchor', x: p.x, y: p.y, paths: [path] });\n }\n }\n });\n return out;\n }\n if (kind === 'intersection') {\n for (const c of pathCrossings(paths)) {\n out.push({ kind: 'intersection', x: c.x, y: c.y, paths: c.a.path === c.b.path ? [c.a.path] : [c.a.path, c.b.path] });\n }\n return out;\n }\n segments.forEach((segs, path) => {\n if (kind === 'quadrant') {\n for (const p of quadrantPoints(segs)) out.push({ kind: 'quadrant', ...p, paths: [path] });\n return;\n }\n for (const s of segs) {\n const ts = kind === 'midpoint' ? [segmentMidT(s.pts)] : segmentExtremaT(s.pts);\n for (const t of ts) out.push({ kind: kind as StaticPathSnapKind, ...evalSeg(s.pts, t), paths: [path] });\n }\n });\n return out;\n };\n return {\n paths,\n segments,\n targets(kind) {\n let hit = cache.get(kind);\n if (!hit) cache.set(kind, (hit = build(kind)));\n return hit;\n },\n };\n}\n\n/** The compass points of each closed subpath in `segs` about the center of its box. */\nfunction quadrantPoints(segs: readonly PathSegment[]): Point[] {\n const out: Point[] = [];\n const subs = new Map<number, PathSegment[]>();\n for (const s of segs) if (s.closed) subs.set(s.sub, [...(subs.get(s.sub) ?? []), s]);\n for (const sub of subs.values()) {\n const x0 = Math.min(...sub.map((s) => s.box.x0)), x1 = Math.max(...sub.map((s) => s.box.x1));\n const y0 = Math.min(...sub.map((s) => s.box.y0)), y1 = Math.max(...sub.map((s) => s.box.y1));\n const cx = (x0 + x1) / 2, cy = (y0 + y1) / 2;\n const across: Seg[] = [[{ x: x0 - 1, y: cy }, { x: x1 + 1, y: cy }], [{ x: cx, y: y0 - 1 }, { x: cx, y: y1 + 1 }]];\n for (const line of across) {\n for (const s of sub) {\n for (const h of intersectSegments(s.pts, line)) {\n if (!out.some((p) => Math.hypot(p.x - h.x, p.y - h.y) < 1e-6)) out.push({ x: h.x, y: h.y });\n }\n }\n }\n }\n return out;\n}\n\nfunction nearestOnSeg(s: Seg, p: Point): { x: number; y: number; dist: number } {\n if (s.length === 2) return nearestOnLine(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y);\n if (s.length === 3) return nearestOnQuadratic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y);\n return nearestOnCubic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y, s[3].x, s[3].y);\n}\n\n/**\n * The snap target nearest `probe` within `query.radius`, or null when none\n * is in range. Every enabled kind competes on distance, except `nearest`,\n * which answers only when no other target is in range.\n */\nexport function findPathSnap(index: PathSnapIndex, probe: Point, query: PathSnapQuery): PathSnapHit | null {\n let best: PathSnapHit | null = null;\n for (const hit of findPathSnaps(index, probe, query)) if (!best || hit.distance < best.distance) best = hit;\n return best;\n}\n\n/**\n * Every snap target within `query.radius` of `probe`, unsorted. `nearest`\n * hits appear only when no other target is in range. Tangent and perpendicular targets\n * closer to the origin than the radius are dropped, so a line cannot snap\n * back onto its own start.\n */\nexport function findPathSnaps(index: PathSnapIndex, probe: Point, query: PathSnapQuery): PathSnapHit[] {\n const kinds = new Set(query.kinds ?? PATH_SNAP_KINDS);\n const r = query.radius;\n const sx = Math.abs(query.scale?.x ?? 1), sy = Math.abs(query.scale?.y ?? 1);\n const metric = (dx: number, dy: number) => Math.hypot(dx * sx, dy * sy);\n const skip = query.skip ?? (() => false);\n const hits: PathSnapHit[] = [];\n const offer = (kind: PathSnapKind, x: number, y: number, paths: readonly number[]) => {\n const distance = metric(x - probe.x, y - probe.y);\n if (distance <= r) hits.push({ kind, x, y, distance, paths });\n };\n\n for (const kind of STATIC_KINDS) {\n if (!kinds.has(kind)) continue;\n for (const t of index.targets(kind)) if (!t.paths.some(skip)) offer(kind, t.x, t.y, t.paths);\n }\n\n const rx = r / (sx || 1), ry = r / (sy || 1);\n const near = (s: PathSegment) =>\n s.box.x0 - rx <= probe.x && probe.x <= s.box.x1 + rx && s.box.y0 - ry <= probe.y && probe.y <= s.box.y1 + ry;\n const o = query.origin;\n if (o && (kinds.has('tangent') || kinds.has('perpendicular'))) {\n index.segments.forEach((segs, path) => {\n if (skip(path)) return;\n for (const s of segs) {\n if (!near(s)) continue;\n const lists: Array<[PathSnapKind, number[]]> = [];\n if (kinds.has('tangent')) lists.push(['tangent', tangentTsFrom(s.pts, o)]);\n if (kinds.has('perpendicular')) lists.push(['perpendicular', perpendicularTsFrom(s.pts, o)]);\n for (const [kind, ts] of lists) {\n for (const t of ts) {\n const p = evalSeg(s.pts, t);\n if (metric(p.x - o.x, p.y - o.y) > r) offer(kind, p.x, p.y, [path]);\n }\n }\n }\n });\n }\n\n if (hits.length > 0 || !kinds.has('nearest')) return hits;\n index.segments.forEach((segs, path) => {\n if (skip(path)) return;\n for (const s of segs) {\n if (!near(s)) continue;\n const n = nearestOnSeg(s.pts, probe);\n offer('nearest', n.x, n.y, [path]);\n }\n });\n return hits;\n}\n","/** Writing segment lists back out as a path, the inverse of `pathSegments`. */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Seg } from '../booleans/contourSegments';\nimport { writePath } from '../booleans/cutRegions';\n\n/** A run of segments, open or closed. */\nexport interface SegmentRun {\n segs: Seg[];\n closed: boolean;\n}\n\n/**\n * `runs` as a polygon path carrying `like`'s fill rule and open-fill setting.\n * A closed run's closing line is left to its `Z`, as a path reads it in, so\n * a run that went through `pathSegments` comes back with the same anchors.\n */\nexport function writeSubpaths(runs: readonly SegmentRun[], like: Path): PolygonPath {\n const trimmed = runs.filter((r) => r.segs.length > 0).map((r) => {\n if (!r.closed || r.segs.length < 2) return r;\n const last = r.segs[r.segs.length - 1];\n const start = r.segs[0][0];\n const end = last[last.length - 1];\n const closesItself = last.length === 2 && end.x === start.x && end.y === start.y;\n return closesItself ? { segs: r.segs.slice(0, -1), closed: true } : r;\n });\n const out = writePath(trimmed, like.kind === 'polygon' ? like.fillRule : 'nonzero');\n return like.kind === 'polygon' && like.openFill !== undefined ? { ...out, openFill: like.openFill } : out;\n}\n","/**\n * Trim: remove the piece of a stroke between the crossings on either side of\n * a point, as a drafting trim does.\n */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport { evalSeg, subSeg, type Seg } from '../booleans/contourSegments';\nimport { parseSubpaths } from '../booleans/contours';\nimport { nearestOnCubic, nearestOnLine, nearestOnQuadratic } from '../nearest';\nimport { crossingStops } from '../intersect/pathCrossings';\nimport { writeSubpaths, type SegmentRun } from '../intersect/writeSubpaths';\nimport { keepCorners } from './cornerRestore';\n\n/** Options for {@link trimPathAt}. */\nexport interface TrimPathOptions {\n /** How far from the stroke `probe` may be. Default: any distance. */\n radius?: number;\n}\n\n/** What {@link trimPathAt} did. */\nexport interface TrimResult {\n /** The path with the piece gone; it has no commands when nothing is left. */\n path: PolygonPath;\n /** The piece removed, as an open path. */\n removed: PolygonPath;\n}\n\nconst EDGE = 1e-7;\n\nfunction nearestOn(s: Seg, p: Point): { t: number; dist: number } {\n if (s.length === 2) return nearestOnLine(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y);\n if (s.length === 3) return nearestOnQuadratic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y);\n return nearestOnCubic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y, s[3].x, s[3].y);\n}\n\n/** The stretch of `segs` between run positions `a` and `b`, where position\n * `k + t` is parameter `t` on segment `k`. On a closed run `b` may pass the\n * end and wrap round. */\nfunction stretch(segs: readonly Seg[], a: number, b: number): Seg[] {\n const n = segs.length;\n const out: Seg[] = [];\n for (let k = Math.floor(a); k < b; k++) {\n const s = segs[((k % n) + n) % n];\n const t0 = Math.max(0, a - k), t1 = Math.min(1, b - k);\n if (t1 - t0 <= EDGE) continue;\n const piece = subSeg(s, t0, t1, evalSeg(s, t0), evalSeg(s, t1));\n if (piece) out.push(piece);\n }\n return out;\n}\n\n/**\n * Remove the piece of `path`'s stroke that `probe` is nearest, bounded by the\n * nearest crossings on either side — with any of `cutters`, or with the path\n * itself. On an open subpath an end with no crossing before it bounds the\n * piece too, so a subpath touched only at its ends goes whole; a closed\n * subpath is opened, and one crossed at a single point is removed whole.\n *\n * Returns null when the probe is further than `radius` from the stroke, or\n * when nothing crosses or touches the subpath it is on. Curves are split where they are\n * cut and keep their type; other subpaths are left as they were.\n */\nexport function trimPathAt(\n path: Path,\n cutters: readonly Path[],\n probe: Point,\n opts: TrimPathOptions = {},\n): TrimResult | null {\n const subs = parseSubpaths(path, false);\n let hit: { sub: number; at: number; dist: number } | null = null;\n subs.forEach(({ segs }, sub) => segs.forEach((s, k) => {\n const n = nearestOn(s, probe);\n if (!hit || n.dist < hit.dist) hit = { sub, at: k + n.t, dist: n.dist };\n }));\n const found = hit as { sub: number; at: number; dist: number } | null;\n if (!found || found.dist > (opts.radius ?? Infinity)) return null;\n\n const { segs, closed } = subs[found.sub];\n const n = segs.length;\n const touches = crossingStops(path, cutters)\n .filter((s) => s.sub === found.sub)\n .map((s) => s.index + s.t);\n if (touches.length === 0) return null;\n const stops = touches\n .map((s) => (closed && s > n - EDGE ? 0 : s))\n .filter((s) => closed || (s > EDGE && s < n - EDGE))\n .sort((p, q) => p - q);\n\n const below = stops.filter((s) => s < found.at);\n const above = stops.filter((s) => s > found.at);\n const keep: SegmentRun[] = [];\n let removed: Seg[];\n if (closed) {\n if (stops.length === 0) return null;\n const lo = below.length > 0 ? below[below.length - 1] : stops[stops.length - 1] - n;\n const hi = above.length > 0 ? above[0] : stops[0] + n;\n removed = stretch(segs, lo, hi);\n if (hi < lo + n - EDGE) keep.push({ segs: stretch(segs, hi, lo + n), closed: false });\n } else {\n const lo = below.length > 0 ? below[below.length - 1] : 0;\n const hi = above.length > 0 ? above[0] : n;\n removed = stretch(segs, lo, hi);\n if (lo > EDGE) keep.push({ segs: stretch(segs, 0, lo), closed: false });\n if (hi < n - EDGE) keep.push({ segs: stretch(segs, hi, n), closed: false });\n }\n\n const runs: SegmentRun[] = [];\n subs.forEach((s, i) => {\n if (i === found.sub) runs.push(...keep);\n else runs.push({ segs: s.segs, closed: s.closed });\n });\n return {\n path: keepCorners([path], writeSubpaths(runs, path)),\n removed: writeSubpaths([{ segs: removed, closed: false }], path),\n };\n}\n","import type { PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\n\n/** What stays put of a path while some of its anchors move. */\nexport interface PathAwayFromAnchors {\n /** The segments touching none of the moving anchors, as open runs; a\n * subpath none of them is on stays as it was. */\n path: PolygonPath;\n /** Every anchor that is not moving, a lone one with no segment left at it\n * included. */\n anchors: Point[];\n}\n\n/** An open run of `sub` from anchor `from` through `count` segments, its\n * outer handles dropped. */\nfunction run(sub: readonly PenAnchor[], from: number, count: number): PenAnchor[] {\n const out: PenAnchor[] = [];\n for (let j = 0; j <= count; j++) out.push({ ...sub[(from + j) % sub.length] });\n delete out[0].inHandle;\n delete out[out.length - 1].outHandle;\n return out;\n}\n\n/**\n * The part of `path` that holds still while the anchors at `moving` (flat\n * indices, as anchor editing numbers them) are dragged: every segment with a\n * moving anchor at either end is dropped, and so are the moving anchors.\n */\nexport function pathAwayFromAnchors(path: PolygonPath, moving: Iterable<number>): PathAwayFromAnchors {\n const set = pathToAnchors(path);\n const flat = new Set(moving);\n const subs: PenAnchor[][] = [];\n const closed: boolean[] = [];\n const anchors: Point[] = [];\n let base = 0;\n set.anchors.forEach((sub, s) => {\n const n = sub.length;\n const moves = (i: number) => flat.has(base + (i % n));\n for (let i = 0; i < n; i++) if (!moves(i)) anchors.push({ x: sub[i].x, y: sub[i].y });\n const first = sub.findIndex((_, i) => moves(i));\n if (first < 0) {\n subs.push(sub);\n closed.push(set.closed[s]);\n } else {\n // A closed subpath is walked from a moving anchor, so no kept run wraps.\n const start = set.closed[s] ? first : 0;\n const segs = set.closed[s] ? n : n - 1;\n let runFrom = -1;\n for (let j = 0; j <= segs; j++) {\n const k = start + j;\n const kept = j < segs && !moves(k) && !moves(k + 1);\n if (kept && runFrom < 0) runFrom = k;\n if (!kept && runFrom >= 0) {\n subs.push(run(sub, runFrom % n, k - runFrom));\n closed.push(false);\n runFrom = -1;\n }\n }\n }\n base += n;\n });\n return { path: anchorsToPath(subs, closed, path), anchors };\n}\n","/**\n * Where each point of an edited path came from, so an array kept per point (a skin's\n * weights) can follow an edit that inserts, deletes, or reorders points.\n */\n\nimport type { PolygonPath } from '../path';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\nimport type { AnchorSet } from './anchorEdits';\nimport type { Point } from './cubicMath';\n\n/**\n * Where a point of an edited path came from: point `a` of the path before the edit, or for a\n * point the edit made, a blend `t` of the way from point `a` to point `b`.\n */\nexport interface PointOrigin {\n a: number;\n b: number;\n t: number;\n /** On an anchor's own point: its subpath now runs the other way through it. */\n reversed?: true;\n}\n\n/** The points of the path before the edit that one anchor held. */\ninterface Held {\n point: number;\n in?: number;\n out?: number;\n /** Where the anchor sat before the edit: its subpath and its index there. */\n sub?: number;\n idx?: number;\n}\n\nconst at = (x: number): Point => ({ x, y: x });\nconst keyOf = (p: Point): string => `${p.x},${p.y}`;\n\n/**\n * Which point of `path` each anchor of `set` was decoded from. `pathToAnchors` runs again\n * over a path whose every point holds its own index, so the two walks cannot disagree.\n */\nfunction heldBy(path: PolygonPath, set: AnchorSet): Held[][] {\n const coords = new Float32Array(path.coords.length);\n for (let i = 0; i < coords.length; i++) coords[i] = i >> 1;\n const indexed = pathToAnchors({ ...path, coords }).anchors;\n return indexed.map((sub, s) => {\n // No two index points coincide, so a closing curve the real walk folded is unfolded here.\n if (sub.length === set.anchors[s].length + 1) sub[0].inHandle = sub.pop()!.inHandle;\n return sub.map((a, i) => ({ point: a.x, in: a.inHandle?.x, out: a.outHandle?.x, sub: s, idx: i }));\n });\n}\n\n/** For each anchor of `path`, by flat index, the index of the point that holds it. */\nexport function anchorPointIndices(path: PolygonPath): number[] {\n return heldBy(path, pathToAnchors(path)).flat().map((held) => held.point);\n}\n\n/** For each point `anchorsToPath` writes for `set`: the flat index of the anchor it belongs to,\n * times 3, plus 0 for the anchor's own point, 1 for its in handle, and 2 for its out handle. */\nfunction writtenFrom(set: AnchorSet): Float32Array {\n let flat = 0;\n const coded = set.anchors.map((sub) => sub.map((a) => {\n const k = 3 * flat++;\n return {\n ...at(k),\n ...(a.inHandle ? { inHandle: at(k + 1) } : {}),\n ...(a.outHandle ? { outHandle: at(k + 2) } : {}),\n };\n }));\n return anchorsToPath(coded, set.closed).coords;\n}\n\n/** The nearest anchor of `sub` from `i`, stepping by `step`, that the path before the edit\n * held; around the seam when the subpath is closed. */\nfunction neighbor(sub: readonly (Held | undefined)[], closed: boolean, i: number, step: 1 | -1): number {\n for (let n = 1; n < sub.length; n++) {\n let j = i + step * n;\n if (j < 0 || j >= sub.length) {\n if (!closed) return -1;\n j = (j + sub.length) % sub.length;\n }\n if (sub[j]) return j;\n }\n return -1;\n}\n\n/** The origin of an anchor the edit made: its held neighbors, blended by its distance to each. */\nfunction blended(\n anchors: readonly PenAnchor[],\n held: readonly (Held | undefined)[],\n closed: boolean,\n i: number,\n): PointOrigin | null {\n const p = neighbor(held, closed, i, -1);\n const n = neighbor(held, closed, i, 1);\n if (p === -1 && n === -1) return null;\n const a = held[p === -1 ? n : p]!.point;\n const b = held[n === -1 ? p : n]!.point;\n if (p === -1 || n === -1 || a === b) return { a, b: a, t: 0 };\n const dp = Math.hypot(anchors[i].x - anchors[p].x, anchors[i].y - anchors[p].y);\n const dn = Math.hypot(anchors[i].x - anchors[n].x, anchors[i].y - anchors[n].y);\n return { a, b, t: dp + dn > 0 ? dp / (dp + dn) : 0 };\n}\n\n/**\n * For each anchor of a subpath after an edit, whether the subpath now runs the other way\n * through it: its neighbors in the new walk follow it in the old one more often backward than\n * forward. An anchor the edit made takes the answer of the nearest kept anchor before it.\n */\nfunction runsBackward(\n sub: readonly (Held | undefined)[],\n closed: boolean,\n before: { lengths: readonly number[]; closed: readonly boolean[] },\n): boolean[] {\n const nextWas = (h: Held): number => {\n const n = before.lengths[h.sub!];\n return h.idx! + 1 < n ? h.idx! + 1 : before.closed[h.sub!] ? 0 : -1;\n };\n // +1 when `y`, after `x` in the new walk, came after it in the old one too; -1 when before it.\n const step = (x: Held | undefined, y: Held | undefined): number => {\n if (x?.sub === undefined || y?.sub === undefined || x.sub !== y.sub) return 0;\n return nextWas(x) === y.idx ? 1 : nextWas(y) === x.idx ? -1 : 0;\n };\n const at = (i: number) => (closed ? sub[(i + sub.length) % sub.length] : sub[i]);\n const own = sub.map((h, i) => (h ? step(at(i - 1), h) + step(h, at(i + 1)) < 0 : null));\n return own.map((flag, i) => {\n if (flag !== null) return flag;\n const p = neighbor(sub, closed, i, -1);\n const n = neighbor(sub, closed, i, 1);\n return p !== -1 ? own[p] === true : n !== -1 && own[n] === true;\n });\n}\n\n/** What an anchor the edit put exactly where one was holds: that anchor's point, and each\n * handle that is where one of its handles was. */\nfunction copied(anchor: PenAnchor, byPlace: ReadonlyMap<string, Held>): Held | undefined {\n const was = byPlace.get(keyOf(anchor));\n if (!was) return undefined;\n const handle = (h: Point | undefined) => (h ? byPlace.get(`${keyOf(anchor)}:${keyOf(h)}`)?.point : undefined);\n return { ...was, in: handle(anchor.inHandle), out: handle(anchor.outHandle) };\n}\n\n/**\n * `editAnchorSet`, answering also where each point of the new path came from.\n *\n * An anchor the edit kept, moved or not, keeps its points. One the edit put exactly where an\n * anchor was takes that anchor's, each handle by where it is, so a subpath turned around\n * keeps its weights. A handle an edit gave an anchor that had none takes the anchor's point. An anchor the edit made is a blend of the nearest kept anchors either side\n * of it in its subpath, by its distance to each, or a copy of the one it has; its origin is\n * `null` when its subpath has none.\n */\nexport function editAnchorSetTracked(\n path: PolygonPath,\n edit: (set: AnchorSet) => boolean | void,\n): { path: PolygonPath; origins: (PointOrigin | null)[] } | null {\n const set = pathToAnchors(path);\n const byAnchor = new Map<PenAnchor, Held>();\n const byPlace = new Map<string, Held>();\n heldBy(path, set).forEach((sub, s) => sub.forEach((held, i) => {\n const anchor = set.anchors[s][i];\n byAnchor.set(anchor, held);\n if (byPlace.has(keyOf(anchor))) return;\n // Handles are filed under where they are, for an anchor that comes back as a copy.\n if (anchor.inHandle) byPlace.set(`${keyOf(anchor)}:${keyOf(anchor.inHandle)}`, { point: held.in! });\n if (anchor.outHandle) byPlace.set(`${keyOf(anchor)}:${keyOf(anchor.outHandle)}`, { point: held.out! });\n byPlace.set(keyOf(anchor), { point: held.point, sub: held.sub, idx: held.idx });\n }));\n\n const before = { lengths: set.anchors.map((sub) => sub.length), closed: [...set.closed] };\n if (edit(set) === false) return null;\n\n const held: (Held | undefined)[] = [];\n const own: (PointOrigin | null)[] = [];\n set.anchors.forEach((sub, s) => {\n const subHeld = sub.map((a) => byAnchor.get(a) ?? copied(a, byPlace));\n const flipped = runsBackward(subHeld, set.closed[s], before);\n sub.forEach((_, i) => {\n const h = subHeld[i];\n held.push(h);\n const origin = h ? { a: h.point, b: h.point, t: 0 } : blended(sub, subHeld, set.closed[s], i);\n own.push(origin && flipped[i] ? { ...origin, reversed: true } : origin);\n });\n });\n\n const origins = Array.from(writtenFrom(set).filter((_, i) => i % 2 === 0), (code) => {\n const anchor = Math.floor(code / 3);\n const handle = code % 3 === 1 ? held[anchor]?.in : code % 3 === 2 ? held[anchor]?.out : undefined;\n return handle === undefined ? own[anchor] : { a: handle, b: handle, t: 0 };\n });\n return { path: anchorsToPath(set.anchors, set.closed, path), origins };\n}\n\n/**\n * An array kept per point of a path, carried through an edit: `origins` is what\n * {@link editAnchorSetTracked} answered. A point with no origin, and an origin past the\n * array's end, read 0.\n */\nexport function remapPointValues(\n values: ArrayLike<number>,\n origins: readonly (PointOrigin | null)[],\n): number[] {\n return origins.map((o) => {\n if (!o) return 0;\n const a = values[o.a] ?? 0;\n return o.t === 0 ? a : a + ((values[o.b] ?? 0) - a) * o.t;\n });\n}\n","/**\n * Screen-pixel lengths in world units, per axis.\n *\n * Chrome declares its hit zones in screen pixels — an 8px handle stays 8px at\n * every zoom, because it paints in screen space. Converting one such length to\n * world units with a single scalar (see `meanScale`) is exact only under\n * uniform zoom; per-axis it is too generous on one axis and too mean on the\n * other, so the pickable region stops matching the painted one.\n *\n * Prefer {@link withinPxBox} / {@link withinPxRadius}, which compare in screen\n * space and so can't drift from the paint at all. {@link pxExtent} is for the\n * cases that must stay in world units — a tolerance handed to geometry that\n * doesn't know about the view.\n */\n\nexport interface Scale2 {\n x: number;\n y: number;\n}\n\n/** One screen-pixel length as world-space extents, per axis. `scale` is a\n * view's, so neither axis is zero (see `View`).\n *\n * With `rotation`, the axes are a frame turned that far from world, and each\n * extent is how far along it an edge across it must move to move `px` on\n * screen — which, under non-uniform zoom, is not the extent along the screen\n * axis nearest to it. */\nexport function pxExtent(px: number, scale: Scale2, rotation = 0): { x: number; y: number } {\n if (!rotation) {\n return {\n x: px / Math.abs(scale.x),\n y: px / Math.abs(scale.y),\n };\n }\n const c = Math.cos(rotation), s = Math.sin(rotation);\n return {\n x: px * Math.hypot(c / scale.x, s / scale.y),\n y: px * Math.hypot(s / scale.x, c / scale.y),\n };\n}\n\n/** World delta → screen delta. Only the scale participates: translation\n * cancels in a difference, and the kit's views carry no skew. */\nexport function scaleDelta(dx: number, dy: number, scale: Scale2): { x: number; y: number } {\n return { x: dx * scale.x, y: dy * scale.y };\n}\n\n/**\n * Is a world-space delta inside a screen-space square of half-extent `px`?\n *\n * The square is axis-aligned **on screen**, which is what a handle painted in\n * screen space actually is — so this stays true under non-uniform zoom and\n * under a rotated target, where an axis-aligned world-space test is a rotated\n * rectangle on screen.\n */\nexport function withinPxBox(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return Math.abs(s.x) <= px && Math.abs(s.y) <= px;\n}\n\n/** Is a world-space delta inside a screen-space circle of radius `px`? */\nexport function withinPxRadius(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return s.x * s.x + s.y * s.y <= px * px;\n}\n\n/**\n * A world point pushed `px` screen pixels off an edge, along the edge's normal\n * as it lands on screen. `normal` is the edge's outward normal in world space.\n *\n * Scaling the world normal by the view is not the same thing: under\n * non-uniform zoom the image of a normal is no longer perpendicular to the\n * image of its edge, so chrome placed that way drifts sideways and sits closer\n * than `px`. Returns the point in world coords and the on-screen unit normal.\n */\nexport function standoff(\n anchor: { x: number; y: number },\n normal: { x: number; y: number },\n px: number,\n scale: Scale2,\n): { x: number; y: number; nx: number; ny: number } {\n // The edge's screen normal is S⁻ᵀn, here scaled by det S to stay finite.\n const k = Math.sign(scale.x * scale.y) || 1;\n let nx = normal.x * scale.y * k;\n let ny = normal.y * scale.x * k;\n const l = Math.hypot(nx, ny) || 1;\n nx /= l;\n ny /= l;\n return { x: anchor.x + (nx * px) / scale.x, y: anchor.y + (ny * px) / scale.y, nx, ny };\n}\n\n/** The screen angle a frame turned `rotation` from world lands its x axis at.\n * Equals `rotation` under uniform zoom; non-uniform zoom bends it. */\nexport function screenAngleOf(rotation: number, scale: Scale2): number {\n return Math.atan2(Math.sin(rotation) * scale.y, Math.cos(rotation) * scale.x);\n}\n","import type { PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\nimport { fitCubicWithTangents } from './schneiderFit';\n\nconst SAMPLES_PER_SEGMENT = 16;\nconst SPLIT_SEARCH_STEPS = 40;\n\n/**\n * Controls for the one cubic that replaces `prev → removed → next` when\n * `removed` is deleted. The new controls keep the directions the curve leaves\n * `prev` and arrives at `next` with, and their lengths are least-squares fitted\n * to samples of the two segments being replaced, so the curve keeps its shape\n * as closely as one cubic can. Where `removed` was inserted by splitting a\n * cubic, the original cubic comes back.\n */\nexport function fitCubicThroughDeletion(\n prev: PenAnchor,\n removed: PenAnchor,\n next: PenAnchor,\n): { c1: Point; c2: Point } {\n const first = segmentControls(prev, removed);\n const second = segmentControls(removed, next);\n const samples = [...sampleCubic(first), ...sampleCubic(second).slice(1)];\n const tStart = startTangent(first);\n const tEnd = startTangent(reversed(second));\n\n // Each half is sampled evenly in its own parameter, so on the merged curve\n // the samples sit at a piecewise-linear parameter that breaks at the\n // removed anchor's `s`. Search for the `s` the samples fit best.\n const fitAt = (s: number) => {\n const params = splitParams(s);\n const fit = fitCubicWithTangents(samples, tStart, tEnd, { params, passes: 0 });\n return { fit, error: squaredError(samples, params, prev, fit.cp1, fit.cp2, next) };\n };\n let lo = 0.02;\n let hi = 0.98;\n const phi = (Math.sqrt(5) - 1) / 2;\n let m1 = hi - phi * (hi - lo);\n let m2 = lo + phi * (hi - lo);\n let e1 = fitAt(m1).error;\n let e2 = fitAt(m2).error;\n for (let i = 0; i < SPLIT_SEARCH_STEPS; i++) {\n if (e1 < e2) {\n hi = m2; m2 = m1; e2 = e1;\n m1 = hi - phi * (hi - lo); e1 = fitAt(m1).error;\n } else {\n lo = m1; m1 = m2; e1 = e2;\n m2 = lo + phi * (hi - lo); e2 = fitAt(m2).error;\n }\n }\n const { cp1, cp2 } = fitCubicWithTangents(samples, tStart, tEnd, {\n params: splitParams((lo + hi) / 2),\n });\n return { c1: cp1, c2: cp2 };\n}\n\ntype Cubic = [Point, Point, Point, Point];\n\nfunction splitParams(s: number): number[] {\n const out: number[] = [];\n for (let i = 0; i <= SAMPLES_PER_SEGMENT; i++) out.push((s * i) / SAMPLES_PER_SEGMENT);\n for (let i = 1; i <= SAMPLES_PER_SEGMENT; i++) out.push(s + ((1 - s) * i) / SAMPLES_PER_SEGMENT);\n return out;\n}\n\nfunction squaredError(\n samples: readonly Point[],\n params: readonly number[],\n p0: Point, p1: Point, p2: Point, p3: Point,\n): number {\n let sum = 0;\n for (let i = 0; i < samples.length; i++) {\n const q = cubicPointAt(p0, p1, p2, p3, params[i]);\n sum += (q.x - samples[i].x) ** 2 + (q.y - samples[i].y) ** 2;\n }\n return sum;\n}\n\nfunction segmentControls(a: PenAnchor, b: PenAnchor): Cubic {\n return [\n { x: a.x, y: a.y },\n a.outHandle ?? { x: a.x, y: a.y },\n b.inHandle ?? { x: b.x, y: b.y },\n { x: b.x, y: b.y },\n ];\n}\n\nfunction sampleCubic([p0, p1, p2, p3]: Cubic): Point[] {\n const out: Point[] = [];\n for (let i = 0; i <= SAMPLES_PER_SEGMENT; i++) {\n out.push(cubicPointAt(p0, p1, p2, p3, i / SAMPLES_PER_SEGMENT));\n }\n return out;\n}\n\nfunction reversed([p0, p1, p2, p3]: Cubic): Cubic {\n return [p3, p2, p1, p0];\n}\n\n/** Unit direction the cubic leaves `p0` in: toward the first control that is\n * not on top of it, the way a cubic's derivative degenerates. */\nfunction startTangent([p0, ...rest]: Cubic): Point {\n for (const p of rest) {\n const dx = p.x - p0.x;\n const dy = p.y - p0.y;\n const len = Math.hypot(dx, dy);\n if (len > 1e-9) return { x: dx / len, y: dy / len };\n }\n return { x: 0, y: 0 };\n}\n","/**\n * Pure anchor-set edits on the model `pathToAnchors` produces: subpath-major\n * `PenAnchor[][]` plus a parallel `closed: boolean[]`. Every function here\n * mutates that structure in place; callers decode with `pathToAnchors`,\n * apply, and re-encode with `anchorsToPath` (see {@link editAnchorSet}).\n *\n * Callers address anchors by flat index — the sequential position in walk\n * order across all subpaths, which is what `enumerateAnchors` reports.\n * {@link locateAnchor} and {@link flatAnchorIndex} convert to and from the\n * `(sub, idx)` pair.\n *\n * The two orders agree because `pathToAnchors` and `enumerateAnchors`\n * walk the same command stream and emit one anchor per M/L/C/Q, less the\n * end of a closing curve that lands on its subpath's first point.\n * `countPathAnchors`, which sizes the renderer's per-anchor arrays, counts\n * that end too and so can be one higher per closed subpath.\n */\n\nimport type { PolygonPath } from '../path';\nimport { withinPxRadius, type Scale2 } from '../pxExtent';\nimport {\n isAnchorSmooth,\n isStraightSegment,\n nearestSegmentT,\n segmentEnds,\n type PenAnchor,\n} from './anchors';\nimport { editAnchorSetTracked } from './anchorOrigins';\nimport { cubicPointAt, splitCubicAtT } from './cubicMath';\nimport { fitCubicThroughDeletion } from './spanFit';\n\n/** Subpath-major anchor model — the decoded form of a `PolygonPath`. */\nexport interface AnchorSet {\n anchors: PenAnchor[][];\n closed: boolean[];\n}\n\n/** A world-space rectangle, as produced by a drag-rect gesture. */\nexport interface AnchorRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Total anchors across every subpath. */\nexport function anchorCount(set: AnchorSet): number {\n let n = 0;\n for (const sub of set.anchors) n += sub.length;\n return n;\n}\n\n/** Flat index → `(sub, idx)`. Returns null when out of range. */\nexport function locateAnchor(\n set: AnchorSet,\n flatIndex: number,\n): { sub: number; idx: number } | null {\n if (flatIndex < 0) return null;\n let remaining = flatIndex;\n for (let sub = 0; sub < set.anchors.length; sub++) {\n const len = set.anchors[sub].length;\n if (remaining < len) return { sub, idx: remaining };\n remaining -= len;\n }\n return null;\n}\n\n/** `(sub, idx)` → flat index. Returns -1 when out of range. */\nexport function flatAnchorIndex(set: AnchorSet, sub: number, idx: number): number {\n if (sub < 0 || sub >= set.anchors.length) return -1;\n if (idx < 0 || idx >= set.anchors[sub].length) return -1;\n let base = 0;\n for (let s = 0; s < sub; s++) base += set.anchors[s].length;\n return base + idx;\n}\n\n/** Resolve a flat index to the anchor itself. Null when out of range. */\nexport function anchorAt(set: AnchorSet, flatIndex: number): PenAnchor | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc) return null;\n return set.anchors[loc.sub][loc.idx] ?? null;\n}\n\n/**\n * Decode `path`, hand the mutable anchor set to `edit`, and re-encode.\n * Returns null when `edit` returns `false` (it changed nothing), so callers\n * can skip a no-op commit.\n */\nexport function editAnchorSet(\n path: PolygonPath,\n edit: (set: AnchorSet) => boolean | void,\n): PolygonPath | null {\n return editAnchorSetTracked(path, edit)?.path ?? null;\n}\n\n/** Translate an anchor and both of its handles by `(dx, dy)`. */\nexport function translateAnchorBy(\n set: AnchorSet,\n flatIndex: number,\n dx: number,\n dy: number,\n): boolean {\n const a = anchorAt(set, flatIndex);\n if (!a) return false;\n a.x += dx;\n a.y += dy;\n if (a.inHandle) {\n a.inHandle.x += dx;\n a.inHandle.y += dy;\n }\n if (a.outHandle) {\n a.outHandle.x += dx;\n a.outHandle.y += dy;\n }\n return true;\n}\n\n/**\n * Move one control handle to an absolute world position. When the anchor was\n * smooth (handles collinear through the anchor) and `breakSmoothness` is\n * false, the opposite handle is mirrored so the curve stays smooth.\n */\nexport function moveHandleTo(\n set: AnchorSet,\n flatIndex: number,\n side: 'in' | 'out',\n toX: number,\n toY: number,\n breakSmoothness: boolean,\n): boolean {\n const a = anchorAt(set, flatIndex);\n if (!a) return false;\n const wasSmooth = isAnchorSmooth(a);\n const target = { x: toX, y: toY };\n if (side === 'out') a.outHandle = target;\n else a.inHandle = target;\n const oppositeSide = side === 'out' ? 'in' : 'out';\n const opposite = oppositeSide === 'in' ? a.inHandle : a.outHandle;\n if (!breakSmoothness && wasSmooth && opposite) {\n const mirrored = { x: 2 * a.x - target.x, y: 2 * a.y - target.y };\n if (oppositeSide === 'in') a.inHandle = mirrored;\n else a.outHandle = mirrored;\n }\n return true;\n}\n\n/**\n * Split the segment `(sub, segIdx) → (sub, segIdx + 1)` at parameter `t`,\n * inserting a new anchor there. On a closed subpath `segIdx` may also name\n * the closing segment (`sub.length - 1`); its new anchor is appended.\n *\n * A straight segment stays straight — the new anchor has no handles. A curved\n * one splits by de Casteljau, so the two halves trace the original path.\n *\n * Returns the new anchor's flat index, or -1 when the segment doesn't\n * exist.\n */\nexport function insertAnchorOnSegment(\n set: AnchorSet,\n args: { sub: number; segIdx: number; t: number },\n): number {\n const ends = segmentEnds(set.anchors, set.closed, args.sub, args.segIdx);\n if (!ends) return -1;\n const { a, b } = ends;\n const at = args.segIdx + 1;\n if (isStraightSegment(a, b)) {\n set.anchors[args.sub].splice(at, 0, {\n x: a.x + (b.x - a.x) * args.t,\n y: a.y + (b.y - a.y) * args.t,\n });\n return flatAnchorIndex(set, args.sub, at);\n }\n const p0 = a, p1 = a.outHandle ?? a, p2 = b.inHandle ?? b, p3 = b;\n const { left, right } = splitCubicAtT(p0, p1, p2, p3, args.t);\n a.outHandle = { x: left[1].x, y: left[1].y };\n b.inHandle = { x: right[2].x, y: right[2].y };\n set.anchors[args.sub].splice(at, 0, {\n x: left[3].x,\n y: left[3].y,\n inHandle: { x: left[2].x, y: left[2].y },\n outHandle: { x: right[1].x, y: right[1].y },\n });\n return flatAnchorIndex(set, args.sub, at);\n}\n\n/** A point on a segment, as {@link segmentAt} reports it. */\nexport interface SegmentHit {\n sub: number;\n segIdx: number;\n /** Parameter on the segment — what {@link insertAnchorOnSegment} takes. */\n t: number;\n /** The point on the path at `t`, in the set's own space. */\n x: number;\n y: number;\n}\n\n/**\n * The segment point under `(x, y)`, when it lies within `tolerancePx` of\n * the path on screen and no nearer than that to either of the segment's\n * own anchors — a press on an anchor is about the anchor, not the segment\n * beside it.\n *\n * `scale` is the view's, so the tolerance holds per axis under\n * non-uniform zoom. The search runs in screen-scaled space: scaling is\n * affine, so the curve's parameterization, and therefore `t`, carries\n * straight back to world space.\n */\nexport function segmentAt(\n set: AnchorSet,\n x: number,\n y: number,\n opts: { tolerancePx: number; scale?: Scale2 },\n): SegmentHit | null {\n const scale = opts.scale ?? { x: 1, y: 1 };\n const onScreen = (p: { x: number; y: number }) => ({ x: p.x * scale.x, y: p.y * scale.y });\n const screenAnchors = set.anchors.map((sub) => sub.map((a) => ({\n ...onScreen(a),\n ...(a.inHandle ? { inHandle: onScreen(a.inHandle) } : {}),\n ...(a.outHandle ? { outHandle: onScreen(a.outHandle) } : {}),\n })));\n const hit = nearestSegmentT(screenAnchors, x * scale.x, y * scale.y, set.closed);\n if (!hit) return null;\n const ends = segmentEnds(set.anchors, set.closed, hit.sub, hit.segIdx)!;\n const point = pointOnSegment(ends.a, ends.b, hit.t);\n const tol = opts.tolerancePx;\n if (!withinPxRadius(point.x - x, point.y - y, tol, scale)) return null;\n if (withinPxRadius(point.x - ends.a.x, point.y - ends.a.y, tol, scale)) return null;\n if (withinPxRadius(point.x - ends.b.x, point.y - ends.b.y, tol, scale)) return null;\n return { sub: hit.sub, segIdx: hit.segIdx, t: hit.t, x: point.x, y: point.y };\n}\n\nfunction pointOnSegment(a: PenAnchor, b: PenAnchor, t: number): { x: number; y: number } {\n if (isStraightSegment(a, b)) return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n return cubicPointAt(a, a.outHandle ?? a, b.inHandle ?? b, b, t);\n}\n\n/**\n * Delete the anchors at `flatIndexes`. Where a deleted anchor had\n * neighbors on both sides — across the seam too, on a closed subpath — the\n * surviving segment is refitted to the two it replaces (`fitCubicThroughDeletion`)\n * so the path keeps its shape; a gap between two straight segments closes straight.\n *\n * Subpaths left with fewer than two anchors are dropped entirely. If that\n * would leave the path with no subpaths at all, the whole deletion is refused\n * (returns false, `set` untouched): an empty path leaves the node selected\n * and in the scene with nothing on screen and no anchors to grab it by.\n */\nexport function deleteAnchorsAt(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n const bySub = new Map<number, number[]>();\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const list = bySub.get(loc.sub);\n if (list) list.push(loc.idx);\n else bySub.set(loc.sub, [loc.idx]);\n }\n if (bySub.size === 0) return false;\n\n // Refuse up front if this would wipe the path out — cheaper and safer\n // than mutating and rolling back.\n let survivors = 0;\n for (let s = 0; s < set.anchors.length; s++) {\n const doomed = bySub.get(s)?.length ?? 0;\n if (set.anchors[s].length - doomed >= 2) survivors++;\n }\n if (survivors === 0) return false;\n\n for (const [s, indices] of bySub) {\n const sub = set.anchors[s];\n if (!sub) continue;\n // Descending so each splice leaves the not-yet-processed indices valid.\n indices.sort((a, b) => b - a);\n for (const i of indices) {\n const wraps = set.closed[s] && sub.length > 2;\n const prev = wraps ? sub[(i - 1 + sub.length) % sub.length] : sub[i - 1];\n const next = wraps ? sub[(i + 1) % sub.length] : sub[i + 1];\n if (prev && next && !(isStraightSegment(prev, sub[i]) && isStraightSegment(sub[i], next))) {\n const { c1, c2 } = fitCubicThroughDeletion(prev, sub[i], next);\n prev.outHandle = c1;\n next.inHandle = c2;\n }\n sub.splice(i, 1);\n }\n }\n\n // Drop degenerate subpaths, back to front so indices stay valid.\n for (let s = set.anchors.length - 1; s >= 0; s--) {\n if (set.anchors[s].length < 2) {\n set.anchors.splice(s, 1);\n set.closed.splice(s, 1);\n }\n }\n return true;\n}\n\n/**\n * Scissors: open a closed subpath at the given anchor. The anchor list is\n * rotated to start there and a second anchor at the same point ends it, so\n * every segment survives and the two ends can be pulled apart. No-ops on an\n * already-open subpath — there's nothing to cut.\n */\nexport function openSubpathAt(set: AnchorSet, flatIndex: number): boolean {\n const loc = locateAnchor(set, flatIndex);\n if (!loc) return false;\n if (!set.closed[loc.sub]) return false;\n const sub = set.anchors[loc.sub];\n if (!sub) return false;\n const { inHandle, ...start } = sub[loc.idx];\n const end: PenAnchor = { x: start.x, y: start.y, ...(inHandle ? { inHandle } : {}) };\n set.anchors[loc.sub] = [start, ...sub.slice(loc.idx + 1), ...sub.slice(0, loc.idx), end];\n set.closed[loc.sub] = false;\n return true;\n}\n\n/** Flat indices of every anchor whose on-curve point falls inside `rect`. */\nexport function anchorsInRect(set: AnchorSet, rect: AnchorRect): number[] {\n const x2 = rect.x + rect.width;\n const y2 = rect.y + rect.height;\n const hits: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (a.x >= rect.x && a.x <= x2 && a.y >= rect.y && a.y <= y2) hits.push(flat);\n flat++;\n }\n }\n return hits;\n}\n","/**\n * Grow or trim an open subpath at one of its ends. Lengthen drags this, and\n * Extend to next path reaches it through `lengthenOpenEnd`.\n *\n * A positive distance extends the end outward: straight along the end tangent,\n * or along a circular arc with the curvature the end has, which meets the path\n * with matching direction and curvature. A straight end segment is lengthened\n * in place; a curved one is continued with a new segment. A negative distance\n * trims the path back along itself by arc length, whichever way it would have\n * grown.\n *\n * The arc rather than extrapolating the end cubic past t = 1: a cubic's\n * leading term takes over beyond its range, so a continued curve swings off\n * and curls on itself within a segment's length, while the arc keeps the\n * curvature the end shows for as long as it is drawn.\n */\n\nimport type { AnchorSet } from './anchorEdits';\nimport { flatAnchorIndex, locateAnchor } from './anchorEdits';\nimport { isStraightSegment, type PenAnchor } from './anchors';\nimport { splitCubicAtT, type Point } from './cubicMath';\nimport { cubicCurvatureAt, cubicDerivativeAt } from './curvature';\nimport type { OpenPathEnd } from './extendPath';\nimport { segmentLength, segmentTAtLength } from './segmentLength';\n\n/** How `lengthenPathEnd` grows an end: straight on, or bending as the end bends. */\nexport type LengthenMode = 'tangent' | 'curvature';\n\n/** Where an end is, which way it heads out of the path, and how it bends there. */\nexport interface PathEndFrame {\n point: Point;\n /** Unit vector pointing out of the path. */\n tangent: Point;\n /** Signed curvature along `tangent`: positive turns toward `(-tangent.y, tangent.x)`. */\n curvature: number;\n}\n\n/** Below this turn over the requested length an arc is drawn as a straight run. */\nconst STRAIGHT_TURN = 1e-6;\n/** The share of a subpath's length a trim always leaves. */\nconst MIN_KEEP = 1e-3;\nconst QUARTER = Math.PI / 2;\nconst FULL = 2 * Math.PI;\n\n/** The end of an open subpath that the anchor at `flatIndex` is, or null when it is\n * an inner anchor, on a closed subpath, or alone in its subpath. */\nexport function openEndAt(set: AnchorSet, flatIndex: number): OpenPathEnd | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || set.closed[loc.sub]) return null;\n const len = set.anchors[loc.sub].length;\n if (len < 2) return null;\n if (loc.idx === 0) return { sub: loc.sub, end: 'first' };\n if (loc.idx === len - 1) return { sub: loc.sub, end: 'last' };\n return null;\n}\n\n/** Flat index of the anchor at `end`, or -1 when there is none. */\nexport function pathEndAnchorIndex(set: AnchorSet, end: OpenPathEnd): number {\n const sub = set.anchors[end.sub];\n if (!sub) return -1;\n return flatAnchorIndex(set, end.sub, end.end === 'first' ? 0 : sub.length - 1);\n}\n\n/** The frame at `end`, or null when it is not the end of an open subpath of two or\n * more anchors, or the path has no direction there. */\nexport function pathEndFrame(set: AnchorSet, end: OpenPathEnd): PathEndFrame | null {\n return atTail(set, end, tailFrame) ?? null;\n}\n\n/**\n * Lengthen `end` by `distance` (see the module comment), in place. A curvature arc\n * stops at one full turn. Returns false when `end` is not the end of an open\n * subpath or nothing changed.\n */\nexport function lengthenPathEnd(set: AnchorSet, end: OpenPathEnd, distance: number, mode: LengthenMode): boolean {\n if (!(distance !== 0 && Number.isFinite(distance))) return false;\n return atTail(set, end, (sub) => (distance < 0 ? trimTail(sub, -distance) : growTail(sub, distance, mode))) ?? false;\n}\n\n/**\n * The distance `lengthenPathEnd` takes for its new end to land nearest `point`: the\n * point projected onto the end tangent, or for a curvature lengthening, measured\n * around the circle of curvature. A measurement around the circle can name the\n * same spot a turn apart; it answers the one nearest `near`, so a drag passing\n * half a turn keeps going instead of jumping back.\n */\nexport function lengthToward(\n set: AnchorSet,\n end: OpenPathEnd,\n mode: LengthenMode,\n point: Point,\n near = 0,\n): number {\n const frame = pathEndFrame(set, end);\n if (!frame) return 0;\n const { point: p, tangent: t, curvature } = frame;\n const vx = point.x - p.x;\n const vy = point.y - p.y;\n if (mode === 'tangent' || curvature === 0) return vx * t.x + vy * t.y;\n const s = Math.sign(curvature);\n const r = 1 / Math.abs(curvature);\n const c = arcCenter(frame);\n const ax = p.x - c.x, ay = p.y - c.y;\n const bx = point.x - c.x, by = point.y - c.y;\n const angle = s * Math.atan2(ax * by - ay * bx, ax * bx + ay * by);\n const turns = Math.round((near / r - angle) / FULL);\n return (angle + turns * FULL) * r;\n}\n\n/** Run `edit` on the subpath with `end` as its last anchor, reversing it around\n * the edit for a start. Undefined when `end` is not the end of an open subpath. */\nfunction atTail<R>(set: AnchorSet, end: OpenPathEnd, edit: (sub: PenAnchor[]) => R): R | undefined {\n const sub = set.anchors[end.sub];\n if (!sub || set.closed[end.sub] || sub.length < 2) return undefined;\n if (end.end === 'last') return edit(sub);\n reverseInPlace(sub);\n try {\n return edit(sub);\n } finally {\n reverseInPlace(sub);\n }\n}\n\n/** Reverse a subpath's direction, keeping each anchor object. */\nfunction reverseInPlace(sub: PenAnchor[]): void {\n sub.reverse();\n for (const a of sub) {\n const { inHandle, outHandle } = a;\n if (outHandle) a.inHandle = outHandle;\n else delete a.inHandle;\n if (inHandle) a.outHandle = inHandle;\n else delete a.outHandle;\n }\n}\n\n/** The last segment's four control points, its own handles where it has them. */\nfunction tailCubic(sub: readonly PenAnchor[]): [PenAnchor, Point, Point, PenAnchor] {\n const a = sub[sub.length - 2];\n const b = sub[sub.length - 1];\n return [a, a.outHandle ?? a, b.inHandle ?? b, b];\n}\n\nfunction tailFrame(sub: readonly PenAnchor[]): PathEndFrame | null {\n const [p0, p1, p2, p3] = tailCubic(sub);\n const point = { x: p3.x, y: p3.y };\n if (isStraightSegment(p0, p3)) return frameHeading(point, p3.x - p0.x, p3.y - p0.y, 0);\n const d1 = cubicDerivativeAt(p0, p1, p2, p3, 1);\n if (Math.hypot(d1.x, d1.y) > 1e-9) return frameHeading(point, d1.x, d1.y, cubicCurvatureAt(p0, p1, p2, p3, 1));\n // The near control sits on the end, which leaves no velocity there to read\n // the bend from: head along the next control that does not.\n const from = Math.hypot(p3.x - p1.x, p3.y - p1.y) > 1e-9 ? p1 : p0;\n return frameHeading(point, p3.x - from.x, p3.y - from.y, 0);\n}\n\nfunction frameHeading(point: Point, dx: number, dy: number, curvature: number): PathEndFrame | null {\n const len = Math.hypot(dx, dy);\n if (!(len > 1e-9)) return null;\n return { point, tangent: { x: dx / len, y: dy / len }, curvature };\n}\n\nfunction arcCenter({ point, tangent, curvature }: PathEndFrame): Point {\n return { x: point.x - tangent.y / curvature, y: point.y + tangent.x / curvature };\n}\n\nfunction growTail(sub: PenAnchor[], distance: number, mode: LengthenMode): boolean {\n const frame = tailFrame(sub);\n if (!frame) return false;\n if (mode === 'curvature' && Math.abs(frame.curvature) * distance > STRAIGHT_TURN) {\n appendArc(sub, frame, distance);\n return true;\n }\n const to = { x: frame.point.x + frame.tangent.x * distance, y: frame.point.y + frame.tangent.y * distance };\n const end = sub[sub.length - 1];\n if (isStraightSegment(sub[sub.length - 2], end)) {\n end.x = to.x;\n end.y = to.y;\n } else {\n sub.push(to);\n }\n return true;\n}\n\n/** Continue the subpath along the circle of curvature at its end, one cubic per\n * quarter turn or less. */\nfunction appendArc(sub: PenAnchor[], frame: PathEndFrame, distance: number): void {\n const s = Math.sign(frame.curvature);\n const r = 1 / Math.abs(frame.curvature);\n const sweep = Math.min(distance / r, FULL);\n const pieces = Math.max(1, Math.ceil(sweep / QUARTER - 1e-9));\n const step = sweep / pieces;\n const reach = (4 / 3) * Math.tan(step / 4) * r;\n const c = arcCenter(frame);\n const rx = frame.point.x - c.x;\n const ry = frame.point.y - c.y;\n const at = (turn: number) => {\n const cos = Math.cos(s * turn);\n const sin = Math.sin(s * turn);\n return {\n p: { x: c.x + rx * cos - ry * sin, y: c.y + rx * sin + ry * cos },\n t: { x: frame.tangent.x * cos - frame.tangent.y * sin, y: frame.tangent.x * sin + frame.tangent.y * cos },\n };\n };\n let prev = sub[sub.length - 1];\n for (let i = 1; i <= pieces; i++) {\n const from = at((i - 1) * step);\n const to = at(i * step);\n prev.outHandle = { x: from.p.x + from.t.x * reach, y: from.p.y + from.t.y * reach };\n const next: PenAnchor = { x: to.p.x, y: to.p.y, inHandle: { x: to.p.x - to.t.x * reach, y: to.p.y - to.t.y * reach } };\n sub.push(next);\n prev = next;\n }\n}\n\nfunction tailLength(sub: readonly PenAnchor[]): number {\n const [p0, p1, p2, p3] = tailCubic(sub);\n if (isStraightSegment(p0, p3)) return Math.hypot(p3.x - p0.x, p3.y - p0.y);\n return segmentLength([p0, p1, p2, p3]);\n}\n\nfunction subpathLength(sub: readonly PenAnchor[]): number {\n let total = 0;\n for (let n = 2; n <= sub.length; n++) total += tailLength(sub.slice(n - 2, n));\n return total;\n}\n\n/** Cut `amount` of arc length off the subpath's end, dropping each anchor the cut\n * passes, and always leaving some of the subpath. */\nfunction trimTail(sub: PenAnchor[], amount: number): boolean {\n const total = subpathLength(sub);\n if (!(total > 0)) return false;\n let left = Math.min(amount, total * (1 - MIN_KEEP));\n for (;;) {\n const len = tailLength(sub);\n if (left < len || sub.length === 2) {\n cutTail(sub, Math.max(0, len - left), len);\n return true;\n }\n left -= len;\n sub.pop();\n delete sub[sub.length - 1].outHandle;\n }\n}\n\n/** Shorten the last segment to its first `keep` of `len`. */\nfunction cutTail(sub: PenAnchor[], keep: number, len: number): void {\n const [p0, p1, p2, p3] = tailCubic(sub);\n if (isStraightSegment(p0, p3)) {\n const f = len > 0 ? keep / len : 0;\n p3.x = p0.x + (p3.x - p0.x) * f;\n p3.y = p0.y + (p3.y - p0.y) * f;\n return;\n }\n const t = segmentTAtLength([p0, p1, p2, p3], keep);\n const { left } = splitCubicAtT(p0, p1, p2, p3, t);\n if (p0.outHandle) p0.outHandle = left[1];\n p3.inHandle = left[2];\n p3.x = left[3].x;\n p3.y = left[3].y;\n}\n","/**\n * Growing an open end of a path along its tangent: by a distance, or until it\n * meets another stroke.\n */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport type { Seg } from '../booleans/contourSegments';\nimport { intersectSegments } from '../intersect/segmentIntersections';\nimport { pathSegments, type PathSegment } from '../intersect/pathSegments';\nimport { editAnchorSetTracked } from './anchorOrigins';\nimport { anchorsToPath, pathToAnchors } from './anchors';\nimport { resolveCorners } from './corners';\nimport { lengthenPathEnd, pathEndFrame } from './lengthenPathEnd';\n\n/** One end of an open subpath. `sub` counts subpaths as the path's anchor set\n * (`pathToAnchors`) does, a bare `M` included. */\nexport interface OpenPathEnd {\n sub: number;\n end: 'first' | 'last';\n}\n\n/** Every end of every open subpath of `path` that has a direction to grow in. */\nexport function openPathEnds(path: Path): OpenPathEnd[] {\n if (path.kind !== 'polygon') return [];\n const set = pathToAnchors(path);\n return set.anchors.flatMap((_, sub) =>\n (['first', 'last'] as const).map((end) => ({ sub, end })).filter((e) => pathEndFrame(set, e)));\n}\n\n/** Where `end` sits and the unit direction it points out along, or null when\n * it is no open end or has no direction there. */\nexport function openEndRay(path: Path, end: OpenPathEnd): { at: Point; dir: Point } | null {\n if (path.kind !== 'polygon') return null;\n const frame = pathEndFrame(pathToAnchors(path), end);\n return frame && { at: frame.point, dir: frame.tangent };\n}\n\n/** `path`'s stroke segments but the one at `end`. */\nfunction segmentsBesideEnd(path: PolygonPath, end: OpenPathEnd): PathSegment[] {\n const set = pathToAnchors(resolveCorners(path));\n return set.anchors.flatMap((sub, s) => {\n const segs = pathSegments(anchorsToPath([sub], [set.closed[s]]));\n return s === end.sub ? segs.filter((g) => g.index !== (end.end === 'last' ? g.count - 1 : 0)) : segs;\n });\n}\n\n/**\n * `path` with `end` carried `distance` further along its tangent, by\n * `lengthenPathEnd` in `'tangent'` mode: a straight end segment grows longer,\n * and a curved one gains a straight segment, which keeps the tangent\n * continuous. Null when the end is not open or has no direction, or\n * `distance` is not positive.\n */\nexport function lengthenOpenEnd(path: Path, end: OpenPathEnd, distance: number): PolygonPath | null {\n if (!(distance > 0) || path.kind !== 'polygon') return null;\n return editAnchorSetTracked(path, (set) => lengthenPathEnd(set, end, distance, 'tangent'))?.path ?? null;\n}\n\n/** Options for {@link extendToMeet}. */\nexport interface ExtendToMeetOptions {\n /** The furthest the end may travel. Default: as far as any stroke reaches. */\n maxDistance?: number;\n}\n\n/**\n * Extend `end` of `path` along its tangent to the first stroke it meets —\n * one of `boundaries`, or `path`'s own other segments. Returns the extended\n * path, the point it now ends at and how far it went, or null when the\n * tangent meets nothing.\n */\nexport function extendToMeet(\n path: Path,\n boundaries: readonly Path[],\n end: OpenPathEnd,\n opts: ExtendToMeetOptions = {},\n): { path: PolygonPath; at: Point; distance: number } | null {\n const ray = openEndRay(path, end);\n if (!ray || path.kind !== 'polygon') return null;\n const all = [...boundaries.flatMap((b) => pathSegments(b)), ...segmentsBesideEnd(path, end)];\n let reach = opts.maxDistance ?? 0;\n if (opts.maxDistance === undefined) {\n for (const s of all) {\n for (const p of s.pts) reach = Math.max(reach, Math.hypot(p.x - ray.at.x, p.y - ray.at.y));\n }\n }\n if (!(reach > 0)) return null;\n const line: Seg = [ray.at, { x: ray.at.x + ray.dir.x * reach, y: ray.at.y + ray.dir.y * reach }];\n let best = Infinity;\n for (const s of all) {\n for (const h of intersectSegments(line, s.pts)) {\n const d = h.ta * reach;\n if (d > 1e-6 && d < best) best = d;\n }\n }\n if (!Number.isFinite(best)) return null;\n const next = lengthenOpenEnd(path, end, best);\n if (!next) return null;\n return { path: next, at: { x: ray.at.x + ray.dir.x * best, y: ray.at.y + ray.dir.y * best }, distance: best };\n}\n","import type { PolygonPath } from '../path';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\nimport { fitPointRun, keepCorner } from './fitRun';\n\n/** Options for {@link simplifyPath}. */\nexport interface SimplifyPathOptions {\n /**\n * An anchor whose path turns by more than this many degrees is a corner:\n * it is kept, and the curve is refitted on either side of it. Default 40.\n */\n cornerAngle?: number;\n}\n\nconst CUBIC_SAMPLES = 12;\nconst MAX_LINE_SAMPLES = 8;\n/** How many times longer than both neighbors a straight segment must be to be\n * kept whole. */\nconst LONG_STRAIGHT = 4;\n\n/**\n * `path` refitted with as few anchors as hold it within `tolerance`: every\n * point sampled along the original lies within `tolerance` of the result.\n * Corners (see {@link SimplifyPathOptions.cornerAngle}) and the ends of open\n * subpaths stay where they are; the runs between them are refitted as smooth\n * cubics, Schneider-style, and a run that lies within `tolerance` of a line\n * becomes one straight segment. Fill rules carry over.\n */\nexport function simplifyPath(\n path: PolygonPath,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PolygonPath {\n const { anchors, closed } = pathToAnchors(path);\n const out: PenAnchor[][] = [];\n const outClosed: boolean[] = [];\n anchors.forEach((sub, s) => {\n if (sub.length < 2) return;\n out.push(simplifySubpath(sub, closed[s], tolerance, opts));\n outClosed.push(closed[s]);\n });\n return anchorsToPath(out, outClosed, path);\n}\n\n/** One subpath of {@link simplifyPath}: its anchors refitted, corners and\n * open ends kept. */\nexport function simplifySubpath(\n sub: PenAnchor[],\n closed: boolean,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PenAnchor[] {\n const { tol, cosCorner } = fitParams(tolerance, opts);\n const n = sub.length;\n const corners = [...breaksOf(sub, closed, cosCorner)].sort((a, b) => a - b);\n const result: PenAnchor[] = [];\n if (closed && corners.length === 0) {\n const pts = sampleRun(sub, 0, n, tol);\n const t = unit(sub2(pts[1], pts[pts.length - 2]));\n fitPointRun(pts, t, neg(t), tol, result, true);\n keepCorner(result[0], sub[0]);\n return result;\n }\n fitStops(sub, closed ? [...corners, corners[0] + n] : corners, tol, result, closed);\n return result;\n}\n\n/**\n * The anchors of `sub` from index `from` to `to`, refitted the way\n * {@link simplifyPath} refits a subpath: as few as hold the span within\n * `tolerance`, corners inside it kept. Indices run modulo the subpath's\n * length, so on a closed subpath `to` may pass its end and wrap; the span is\n * shorter than one full turn. The two end anchors stay where they are and\n * keep their handles facing out of the span. Answers the anchors from `from`\n * to `to`, both included, to splice in place of the originals.\n */\nexport function simplifySpan(\n sub: PenAnchor[],\n closed: boolean,\n from: number,\n to: number,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PenAnchor[] {\n const { tol, cosCorner } = fitParams(tolerance, opts);\n const n = sub.length;\n const breaks = breaksOf(sub, closed, cosCorner);\n const stops = [from];\n for (let k = from + 1; k < to; k++) if (breaks.has(k % n)) stops.push(k);\n stops.push(to);\n const first = sub[from % n];\n const result: PenAnchor[] = [{ x: first.x, y: first.y, ...(first.inHandle ? { inHandle: { ...first.inHandle } } : {}) }];\n keepCorner(result[0], first);\n fitStops(sub, stops, tol, result, false);\n const lastOut = sub[to % n].outHandle;\n if (lastOut) result[result.length - 1].outHandle = { ...lastOut };\n return result;\n}\n\nfunction fitParams(tolerance: number, opts: SimplifyPathOptions): { tol: number; cosCorner: number } {\n return {\n tol: Math.max(tolerance, 1e-6),\n cosCorner: Math.cos(((opts.cornerAngle ?? 40) * Math.PI) / 180),\n };\n}\n\n/** The anchors a refit must keep: corners, and both ends of a long straight. */\nfunction breaksOf(sub: PenAnchor[], closed: boolean, cosCorner: number): Set<number> {\n const n = sub.length;\n const breaks = new Set<number>();\n for (let i = 0; i < n; i++) {\n if (isCorner(sub, i, closed, cosCorner)) breaks.add(i);\n if (isLongStraight(sub, i, closed)) {\n breaks.add(i);\n breaks.add((i + 1) % n);\n }\n }\n return breaks;\n}\n\n/** Fit each run between consecutive `stops` and append it to `out`. With\n * `closing`, the last run ends on the subpath's first anchor. */\nfunction fitStops(sub: PenAnchor[], stops: readonly number[], tol: number, out: PenAnchor[], closing: boolean): void {\n const n = sub.length;\n for (let k = 0; k + 1 < stops.length; k++) {\n const pts = sampleRun(sub, stops[k], stops[k + 1], tol);\n // Coincident anchors sample to a single point, which has no run to fit.\n if (pts.length < 2) continue;\n const last = closing && k + 2 === stops.length;\n const fresh = out.length === 0;\n fitPointRun(pts, unit(sub2(pts[1], pts[0])), unit(sub2(pts[pts.length - 2], pts[pts.length - 1])), tol, out, last);\n if (fresh) keepCorner(out[0], sub[stops[k] % n]);\n if (!last) keepCorner(out[out.length - 1], sub[stops[k + 1] % n]);\n }\n}\n\n/** Whether the path turns at `sub[i]` by more than the corner angle. */\nfunction isCorner(sub: PenAnchor[], i: number, closed: boolean, cosCorner: number): boolean {\n const n = sub.length;\n const a = sub[i];\n const prev = sub[(i - 1 + n) % n];\n const next = sub[(i + 1) % n];\n if (!closed && (i === 0 || i === n - 1)) return true;\n const from = a.inHandle && !same(a.inHandle, a) ? a.inHandle : prev.outHandle && !same(prev.outHandle, a) ? prev.outHandle : prev;\n const to = a.outHandle && !same(a.outHandle, a) ? a.outHandle : next.inHandle && !same(next.inHandle, a) ? next.inHandle : next;\n const d1 = unit(sub2(a, from));\n const d2 = unit(sub2(to, a));\n return d1.x * d2.x + d1.y * d2.y < cosCorner;\n}\n\n/** Whether the segment leaving `sub[i]` is straight and far longer than the\n * segments either side: a flat between curves, kept whole rather than folded\n * into a curve fitted across it. */\nfunction isLongStraight(sub: PenAnchor[], i: number, closed: boolean): boolean {\n const n = sub.length;\n const len = (k: number): number => {\n if (!closed && (k < 0 || k >= n - 1)) return 0;\n const a = sub[(k + n) % n];\n const b = sub[(k + 1) % n];\n return Math.hypot(b.x - a.x, b.y - a.y);\n };\n if (!closed && i >= n - 1) return false;\n const a = sub[i];\n const b = sub[(i + 1) % n];\n if (a.outHandle || b.inHandle) return false;\n return len(i) >= LONG_STRAIGHT * Math.max(len(i - 1), len(i + 1));\n}\n\n/** Points along the anchors from index `from` to `to` (mod length), both\n * anchors included. */\nfunction sampleRun(sub: PenAnchor[], from: number, to: number, tol: number): Point[] {\n const n = sub.length;\n const pts: Point[] = [{ x: sub[from % n].x, y: sub[from % n].y }];\n for (let i = from; i < to; i++) {\n const a = sub[i % n];\n const b = sub[(i + 1) % n];\n if (!a.outHandle && !b.inHandle) {\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n const steps = Math.min(MAX_LINE_SAMPLES, Math.max(1, Math.floor(len / (4 * tol))));\n for (let k = 1; k <= steps; k++) pts.push({ x: a.x + ((b.x - a.x) * k) / steps, y: a.y + ((b.y - a.y) * k) / steps });\n } else {\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n for (let k = 1; k <= CUBIC_SAMPLES; k++) pts.push(cubicPointAt(a, c1, c2, b, k / CUBIC_SAMPLES));\n }\n }\n return dedupe(pts);\n}\n\nfunction dedupe(pts: Point[]): Point[] {\n return pts.filter((p, i) => i === 0 || !same(p, pts[i - 1]));\n}\n\nconst same = (p: Point, q: Point): boolean => p.x === q.x && p.y === q.y;\nconst sub2 = (p: Point, q: Point): Point => ({ x: p.x - q.x, y: p.y - q.y });\nconst neg = (p: Point): Point => ({ x: -p.x, y: -p.y });\nfunction unit(p: Point): Point {\n const len = Math.hypot(p.x, p.y);\n return len === 0 ? { x: 0, y: 0 } : { x: p.x / len, y: p.y / len };\n}\n","/**\n * A filled region grown outward by a distance, without a boolean: each\n * contour's edges moved out along their normals, convex corners joined, and\n * the overlaps that leaves fill once under `'nonzero'`. Curves stay curves.\n */\nimport { cubicEvalAt } from '../curve';\nimport type { Path, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { lineSegment, pathToCubicContours, splitSegment, type CubicSegment } from './cubicContours';\nimport { pathSignedArea } from './winding';\n\n/** Options for {@link growRegion}. */\nexport interface GrowRegionOptions {\n /** How a convex corner turns. `'miter'` keeps it sharp, as a pseudo-distance\n * field draws it; `'round'` follows the true distance. Default `'miter'`. */\n join?: 'miter' | 'round';\n /** Past this ratio of miter length to distance a miter corner is beveled.\n * Default 4. */\n miterLimit?: number;\n /** How far a grown curve may stray from the true offset, in the path's\n * units. Default 0.1. */\n tolerance?: number;\n}\n\ntype Pt = [number, number];\ntype Seg = CubicSegment;\n\nconst MAX_DEPTH = 6;\nconst SAMPLES = [0.2, 0.35, 0.5, 0.65, 0.8];\n\n/**\n * The region `path` fills under `'nonzero'`, grown by `distance` (> 0), as a\n * path that fills it under `'nonzero'`. Every subpath counts as closed. Each\n * contour is replaced by its offset, so where grown parts meet the contours\n * overlap rather than merge, and a hole grown shut winds back on itself and\n * fills. At an inside corner the two offset edges are cut back to where they\n * cross; where they do not, the gap is passed through the corner's original\n * point, which closes it with a loop inside the fill. `mergeRegion`\n * redraws the result as its outline alone, for a stroke.\n *\n * What it costs: one segment per curve, more where `tolerance` needs the curve\n * split; a miter corner between two straight edges costs nothing, one beside\n * a curve gains an anchor or two, a round corner an arc, and an inside corner\n * whose edges do not cross two.\n */\nexport function growRegion(path: Path, distance: number, opts: GrowRegionOptions = {}): PolygonPath {\n const b = new PathBuilder();\n if (!(distance > 0)) return b.build();\n const sigma = pathSignedArea(path) < 0 ? -1 : 1;\n const ctx: Ctx = {\n d: distance,\n sigma,\n tol: opts.tolerance ?? 0.1,\n join: opts.join ?? 'miter',\n miterLimit: opts.miterLimit ?? 4,\n };\n for (const contour of pathToCubicContours(path)) {\n const segs = contour.segs.filter((s) => !degenerate(s));\n if (segs.length === 0) continue;\n const last = segs.at(-1)!.c,\n first = segs[0]!.c;\n if (last[6] !== first[0] || last[7] !== first[1]) segs.push(lineSegment(last[6], last[7], first[0], first[1]));\n emitContour(b, growContour(segs, ctx));\n }\n return b.build();\n}\n\ninterface Ctx {\n d: number;\n sigma: number;\n tol: number;\n join: 'miter' | 'round';\n miterLimit: number;\n}\n\n/** One source segment's offset pieces, and the pieces joining it to the next. */\ninterface Grown {\n pieces: Seg[];\n join: Seg[];\n}\n\nfunction growContour(segs: readonly Seg[], ctx: Ctx): Grown[] {\n const out: Grown[] = segs.map((s) => ({\n pieces: offsetSeg(s, ctx, 0),\n join: [],\n }));\n for (let i = 0; i < segs.length; i++) {\n const j = (i + 1) % segs.length;\n const tin = endTangent(segs[i]!.c),\n tout = startTangent(segs[j]!.c);\n const v: Pt = [segs[j]!.c[0], segs[j]!.c[1]];\n out[i]!.join = joinPieces(out[i]!, out[j]!, v, tin, tout, ctx);\n }\n return out;\n}\n\nfunction joinPieces(prev: Grown, next: Grown, v: Pt, tin: Pt, tout: Pt, ctx: Ctx): Seg[] {\n const a = endOf(prev.pieces.at(-1)!),\n b = startOf(next.pieces[0]!);\n const gap = Math.hypot(b[0] - a[0], b[1] - a[1]);\n if (gap <= ctx.tol * 1e-3) return [];\n const cross = tin[0] * tout[1] - tin[1] * tout[0];\n const dot = tin[0] * tout[0] + tin[1] * tout[1];\n const convex = ctx.sigma * cross > 0 || (Math.abs(cross) < 1e-9 && dot < 0);\n if (gap <= ctx.tol) return snap(prev, next, a);\n if (!convex) {\n if (trimAtCrossing(prev, next)) return [];\n return [lineSegment(a[0], a[1], v[0], v[1]), lineSegment(v[0], v[1], b[0], b[1])];\n }\n const nin = normal(tin, ctx.sigma),\n nout = normal(tout, ctx.sigma);\n if (ctx.join === 'round') return arc(v, ctx.d, nin, Math.atan2(cross, dot));\n const cos = nin[0] * nout[0] + nin[1] * nout[1];\n if (1 + cos < 1e-9 || Math.sqrt(2 / (1 + cos)) > ctx.miterLimit) return [lineSegment(a[0], a[1], b[0], b[1])];\n const k = ctx.d / (1 + cos);\n const m: Pt = [v[0] + (nin[0] + nout[0]) * k, v[1] + (nin[1] + nout[1]) * k];\n return miter(prev, next, m);\n}\n\n/** A gap inside the tolerance closed by moving the next piece's start onto\n * `a`, its first handle with it, rather than by a segment of its own. */\nfunction snap(prev: Grown, next: Grown, a: Pt): Seg[] {\n const n = next.pieces[0]!;\n if (n === prev.pieces.at(-1)) return [lineSegment(n.c[6], n.c[7], a[0], a[1])];\n next.pieces[0] = n.line\n ? lineSegment(a[0], a[1], n.c[6], n.c[7])\n : {\n c: [a[0], a[1], n.c[2] + a[0] - n.c[0], n.c[3] + a[1] - n.c[1], n.c[4], n.c[5], n.c[6], n.c[7]],\n line: false,\n };\n return [];\n}\n\n/** The miter point joined in, a straight edge either side carried on to it\n * rather than gaining an anchor. */\nfunction miter(prev: Grown, next: Grown, m: Pt): Seg[] {\n const p = prev.pieces.at(-1)!,\n n = next.pieces[0]!;\n const out: Seg[] = [];\n if (p.line && p !== n) prev.pieces[prev.pieces.length - 1] = lineSegment(p.c[0], p.c[1], m[0], m[1]);\n else out.push(lineSegment(p.c[6], p.c[7], m[0], m[1]));\n if (n.line && p !== n) next.pieces[0] = lineSegment(m[0], m[1], n.c[6], n.c[7]);\n else out.push(lineSegment(m[0], m[1], n.c[0], n.c[1]));\n return out;\n}\n\n/**\n * Cut the offset pieces either side of an inside corner back to where they\n * cross, when they do. The crossing is found on a flattening of each, and both\n * cut ends are moved onto the one point between them.\n */\nfunction trimAtCrossing(prev: Grown, next: Grown): boolean {\n const p = prev.pieces.at(-1)!,\n n = next.pieces[0]!;\n if (p === n) return false;\n const hit = crossing(p.c, n.c);\n if (hit === null) return false;\n const left = hit[0] >= 1 ? p : splitSegment(p, hit[0])[0];\n const right = hit[1] <= 0 ? n : splitSegment(n, hit[1])[1];\n const x = (left.c[6] + right.c[0]) / 2,\n y = (left.c[7] + right.c[1]) / 2;\n prev.pieces[prev.pieces.length - 1] = left.line\n ? lineSegment(left.c[0], left.c[1], x, y)\n : {\n c: [left.c[0], left.c[1], left.c[2], left.c[3], left.c[4] + x - left.c[6], left.c[5] + y - left.c[7], x, y],\n line: false,\n };\n next.pieces[0] = right.line\n ? lineSegment(x, y, right.c[6], right.c[7])\n : {\n c: [\n x,\n y,\n right.c[2] + x - right.c[0],\n right.c[3] + y - right.c[1],\n right.c[4],\n right.c[5],\n right.c[6],\n right.c[7],\n ],\n line: false,\n };\n return true;\n}\n\nconst CROSS_SAMPLES = 32;\n\n/** Where `a` crosses `b`, as a parameter on each: the crossing nearest `a`'s\n * end and `b`'s start, or `null` when they do not cross. */\nfunction crossing(a: Seg['c'], b: Seg['c']): [number, number] | null {\n const pa = flatten(a),\n pb = flatten(b);\n let best: [number, number] | null = null,\n score = Infinity;\n for (let i = 0; i < CROSS_SAMPLES; i++) {\n for (let j = 0; j < CROSS_SAMPLES; j++) {\n const hit = segmentsCross(pa[i]!, pa[i + 1]!, pb[j]!, pb[j + 1]!);\n if (hit === null) continue;\n const ta = (i + hit[0]) / CROSS_SAMPLES,\n tb = (j + hit[1]) / CROSS_SAMPLES;\n if (ta <= 1e-9 || tb >= 1 - 1e-9 || 1 - ta + tb >= score) continue;\n score = 1 - ta + tb;\n best = [ta, tb];\n }\n }\n return best;\n}\n\nfunction flatten(c: Seg['c']): Pt[] {\n const out: Pt[] = [];\n for (let i = 0; i <= CROSS_SAMPLES; i++) out.push(cubicEvalAt(...c, i / CROSS_SAMPLES));\n return out;\n}\n\nfunction segmentsCross(a: Pt, b: Pt, c: Pt, d: Pt): [number, number] | null {\n const rx = b[0] - a[0],\n ry = b[1] - a[1],\n sx = d[0] - c[0],\n sy = d[1] - c[1];\n const den = rx * sy - ry * sx;\n if (Math.abs(den) < 1e-18) return null;\n const u = ((c[0] - a[0]) * sy - (c[1] - a[1]) * sx) / den;\n const w = ((c[0] - a[0]) * ry - (c[1] - a[1]) * rx) / den;\n return u >= 0 && u <= 1 && w >= 0 && w <= 1 ? [u, w] : null;\n}\n\n/** A circular arc about `c` of radius `r`, from normal `n0` turning by `sweep`. */\nfunction arc(c: Pt, r: number, n0: Pt, sweep: number): Seg[] {\n const parts = Math.max(1, Math.ceil(Math.abs(sweep) / (Math.PI / 2)));\n const step = sweep / parts;\n const h = (4 / 3) * Math.tan(step / 4) * r;\n const start = Math.atan2(n0[1], n0[0]);\n const out: Seg[] = [];\n for (let i = 0; i < parts; i++) {\n const t0 = start + step * i,\n t1 = t0 + step;\n const x0 = c[0] + Math.cos(t0) * r,\n y0 = c[1] + Math.sin(t0) * r;\n const x3 = c[0] + Math.cos(t1) * r,\n y3 = c[1] + Math.sin(t1) * r;\n out.push({\n c: [x0, y0, x0 - Math.sin(t0) * h, y0 + Math.cos(t0) * h, x3 + Math.sin(t1) * h, y3 - Math.cos(t1) * h, x3, y3],\n line: false,\n });\n }\n return out;\n}\n\n/**\n * `seg` moved out by `d`. A curve's ends move along their normals and its\n * handles scale by `1 + d·κ`, which matches the offset's first derivative\n * there; a piece that strays past the tolerance is split and retried.\n */\nfunction offsetSeg(seg: Seg, ctx: Ctx, depth: number): Seg[] {\n const c = seg.c;\n const n0 = normal(startTangent(c), ctx.sigma),\n n1 = normal(endTangent(c), ctx.sigma);\n const { d } = ctx;\n if (seg.line) return [lineSegment(c[0] + n0[0] * d, c[1] + n0[1] * d, c[6] + n0[0] * d, c[7] + n0[1] * d)];\n const k0 = Math.max(0, 1 + ctx.sigma * d * curvatureAt(c, 0));\n const k1 = Math.max(0, 1 + ctx.sigma * d * curvatureAt(c, 1));\n const q0x = c[0] + n0[0] * d,\n q0y = c[1] + n0[1] * d;\n const q3x = c[6] + n1[0] * d,\n q3y = c[7] + n1[1] * d;\n const out: Seg = {\n c: [\n q0x,\n q0y,\n q0x + (c[2] - c[0]) * k0,\n q0y + (c[3] - c[1]) * k0,\n q3x + (c[4] - c[6]) * k1,\n q3y + (c[5] - c[7]) * k1,\n q3x,\n q3y,\n ],\n line: false,\n };\n if (depth >= MAX_DEPTH || offsetError(c, out.c, ctx) <= ctx.tol) return [out];\n const [l, r] = splitSegment(seg, 0.5);\n return [...offsetSeg(l, ctx, depth + 1), ...offsetSeg(r, ctx, depth + 1)];\n}\n\nfunction offsetError(c: Seg['c'], q: Seg['c'], ctx: Ctx): number {\n let worst = 0;\n for (const t of SAMPLES) {\n const [dx, dy] = derivative(c, t);\n const len = Math.hypot(dx, dy);\n if (len < 1e-12) continue;\n const [bx, by] = cubicEvalAt(...c, t);\n const tx = bx + ((ctx.sigma * dy) / len) * ctx.d,\n ty = by - ((ctx.sigma * dx) / len) * ctx.d;\n const [ox, oy] = cubicEvalAt(...q, t);\n worst = Math.max(worst, Math.hypot(ox - tx, oy - ty));\n }\n return worst;\n}\n\nfunction derivative(c: Seg['c'], t: number): Pt {\n const u = 1 - t;\n const a = 3 * u * u,\n b = 6 * u * t,\n e = 3 * t * t;\n return [\n a * (c[2] - c[0]) + b * (c[4] - c[2]) + e * (c[6] - c[4]),\n a * (c[3] - c[1]) + b * (c[5] - c[3]) + e * (c[7] - c[5]),\n ];\n}\n\n/** Signed curvature at an end, positive turning left; 0 where the handle is\n * absent, whose offset handle is then absent too. */\nfunction curvatureAt(c: Seg['c'], end: 0 | 1): number {\n const [d1x, d1y] = end === 0 ? [c[2] - c[0], c[3] - c[1]] : [c[6] - c[4], c[7] - c[5]];\n const [d2x, d2y] =\n end === 0 ? [c[0] - 2 * c[2] + c[4], c[1] - 2 * c[3] + c[5]] : [c[6] - 2 * c[4] + c[2], c[7] - 2 * c[5] + c[3]];\n const len = Math.hypot(d1x, d1y);\n if (len < 1e-12) return 0;\n // B' = 3·d1, B'' = 6·d2: κ = (B'×B'')/|B'|³ = (2/3)(d1×d2)/|d1|³.\n return ((2 / 3) * (d1x * d2y - d1y * d2x)) / (len * len * len);\n}\n\nfunction startTangent(c: Seg['c']): Pt {\n return unit(c[2] - c[0], c[3] - c[1]) ?? unit(c[4] - c[0], c[5] - c[1]) ?? unit(c[6] - c[0], c[7] - c[1]) ?? [1, 0];\n}\n\nfunction endTangent(c: Seg['c']): Pt {\n return unit(c[6] - c[4], c[7] - c[5]) ?? unit(c[6] - c[2], c[7] - c[3]) ?? unit(c[6] - c[0], c[7] - c[1]) ?? [1, 0];\n}\n\nfunction unit(x: number, y: number): Pt | null {\n const l = Math.hypot(x, y);\n return l < 1e-12 ? null : [x / l, y / l];\n}\n\n/** The outward normal: right of travel for a positively wound region. */\nfunction normal(t: Pt, sigma: number): Pt {\n return [sigma * t[1], -sigma * t[0]];\n}\n\nfunction degenerate(s: Seg): boolean {\n const c = s.c;\n return c[0] === c[6] && c[1] === c[7] && c[0] === c[2] && c[1] === c[3] && c[0] === c[4] && c[1] === c[5];\n}\n\nconst startOf = (s: Seg): Pt => [s.c[0], s.c[1]];\nconst endOf = (s: Seg): Pt => [s.c[6], s.c[7]];\n\nfunction emitContour(b: PathBuilder, grown: readonly Grown[]): void {\n const first = grown[0]!.pieces[0]!;\n b.moveTo(first.c[0], first.c[1]);\n for (const g of grown) {\n for (const s of [...g.pieces, ...g.join]) {\n if (s.line) b.lineTo(s.c[6], s.c[7]);\n else b.curveTo(s.c[2], s.c[3], s.c[4], s.c[5], s.c[6], s.c[7]);\n }\n }\n b.close();\n}\n","/** Where cubic segments cross one another, as a parameter on each. */\nimport { cubicEvalAt } from '../curve';\nimport type { CubicSegment } from './cubicContours';\n\ntype Pt = [number, number];\ntype C = CubicSegment['c'];\n\n/** One crossing of segments `a` and `b`, at parameter `s` on `a` and `t` on `b`. */\nexport interface SegmentCrossing {\n a: number;\n b: number;\n s: number;\n t: number;\n}\n\nconst STEPS = 16;\nconst END = 1e-7;\n\n/**\n * Every crossing between two of `segs`, a segment with itself left out. A\n * meeting at an end of both is a shared corner, not a crossing, and is left\n * out too. Each curve is found on a flattening and then refined on the curves.\n */\nexport function segmentCrossings(segs: readonly CubicSegment[]): SegmentCrossing[] {\n const flat = segs.map((s) => flatten(s));\n const boxes = flat.map(boxOf);\n const out: SegmentCrossing[] = [];\n for (let a = 0; a < segs.length; a++) {\n for (let b = a + 1; b < segs.length; b++) {\n if (!overlaps(boxes[a]!, boxes[b]!)) continue;\n const pa = flat[a]!,\n pb = flat[b]!;\n for (let i = 0; i + 1 < pa.length; i++) {\n for (let j = 0; j + 1 < pb.length; j++) {\n const hit = linesCross(pa[i]!, pa[i + 1]!, pb[j]!, pb[j + 1]!);\n if (hit === null) continue;\n const guess: Pt = [(i + hit[0]) / (pa.length - 1), (j + hit[1]) / (pb.length - 1)];\n const [s, t] = segs[a]!.line && segs[b]!.line ? guess : refine(segs[a]!.c, segs[b]!.c, guess);\n if (atEnd(s) && atEnd(t)) continue;\n if (out.some((x) => x.a === a && x.b === b && Math.abs(x.s - s) < 1e-6 && Math.abs(x.t - t) < 1e-6)) continue;\n out.push({ a, b, s, t });\n }\n }\n }\n }\n return out;\n}\n\nconst atEnd = (t: number) => t < END || t > 1 - END;\n\nfunction flatten(seg: CubicSegment): Pt[] {\n if (seg.line) return [[seg.c[0], seg.c[1]], [seg.c[6], seg.c[7]]];\n const out: Pt[] = [];\n for (let i = 0; i <= STEPS; i++) out.push(cubicEvalAt(...seg.c, i / STEPS));\n return out;\n}\n\ntype Box = [number, number, number, number];\n\nfunction boxOf(pts: readonly Pt[]): Box {\n const b: Box = [Infinity, Infinity, -Infinity, -Infinity];\n for (const [x, y] of pts) {\n b[0] = Math.min(b[0], x);\n b[1] = Math.min(b[1], y);\n b[2] = Math.max(b[2], x);\n b[3] = Math.max(b[3], y);\n }\n return b;\n}\n\nconst overlaps = (p: Box, q: Box) => p[0] <= q[2] && q[0] <= p[2] && p[1] <= q[3] && q[1] <= p[3];\n\nfunction linesCross(a: Pt, b: Pt, c: Pt, d: Pt): Pt | null {\n const rx = b[0] - a[0],\n ry = b[1] - a[1],\n sx = d[0] - c[0],\n sy = d[1] - c[1];\n const den = rx * sy - ry * sx;\n if (Math.abs(den) < 1e-18) return null;\n const u = ((c[0] - a[0]) * sy - (c[1] - a[1]) * sx) / den;\n const w = ((c[0] - a[0]) * ry - (c[1] - a[1]) * rx) / den;\n return u >= 0 && u <= 1 && w >= 0 && w <= 1 ? [u, w] : null;\n}\n\n/** The crossing near `guess` found on the curves themselves by Newton's\n * method, or `guess` when that does not converge on a closer one. */\nfunction refine(a: C, b: C, guess: Pt): Pt {\n const gap = (s: number, t: number) => {\n const p = cubicEvalAt(...a, s),\n q = cubicEvalAt(...b, t);\n return [p[0] - q[0], p[1] - q[1]] as Pt;\n };\n let [s, t] = guess;\n let f = gap(s, t);\n const start = Math.hypot(...f);\n for (let k = 0; k < 8 && Math.hypot(...f) > 1e-13; k++) {\n const da = derivative(a, s),\n db = derivative(b, t);\n const det = -da[0] * db[1] + db[0] * da[1];\n if (Math.abs(det) < 1e-18) break;\n s = Math.min(1, Math.max(0, s - (-db[1] * f[0] + db[0] * f[1]) / det));\n t = Math.min(1, Math.max(0, t - (-da[1] * f[0] + da[0] * f[1]) / det));\n f = gap(s, t);\n }\n return Math.hypot(...f) <= start ? [s, t] : guess;\n}\n\nfunction derivative(c: C, t: number): Pt {\n const u = 1 - t;\n const a = 3 * u * u,\n b = 6 * u * t,\n e = 3 * t * t;\n return [\n a * (c[2] - c[0]) + b * (c[4] - c[2]) + e * (c[6] - c[4]),\n a * (c[3] - c[1]) + b * (c[5] - c[3]) + e * (c[7] - c[5]),\n ];\n}\n","/**\n * The region a path fills, redrawn as its outline alone: contours that\n * overlap or cross are cut where they cross and only the pieces with fill on\n * one side are kept. Curves stay curves.\n */\nimport { cubicEvalAt } from '../curve';\nimport { flattenCubic } from '../flatten';\nimport type { Path, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { lineSegment, pathToCubicContours, splitSegment, type CubicSegment } from './cubicContours';\nimport { segmentCrossings } from './segmentCrossings';\nimport { pathSignedArea } from './winding';\n\n/** Options for {@link mergeRegion}. */\nexport interface MergeRegionOptions {\n /** How far from an edge a point is taken to tell which side is filled, in\n * the path's units; a sliver of region thinner than this may be lost.\n * Default 0.01. */\n tolerance?: number;\n}\n\ntype Pt = [number, number];\n\n/** A cut on a segment: where, and the point both cut ends move onto. */\ninterface Cut {\n t: number;\n p: Pt;\n}\n\n/**\n * The region `path` fills under `'nonzero'`, as contours that neither cross\n * nor overlap, wound so the fill lies on the same side of each as it does on\n * most of `path`. Stroking it traces only the region's edge. Every subpath\n * counts as closed. Answers `path`'s own contours, unchanged, where nothing\n * needs cutting or dropping.\n */\nexport function mergeRegion(path: Path, opts: MergeRegionOptions = {}): PolygonPath {\n const tol = opts.tolerance ?? 0.01;\n const contours = pathToCubicContours(path).filter((c) => c.segs.length > 0);\n const segs = contours.flatMap((c) => closeContour(c.segs, tol * 1e-3));\n // A positively wound region fills to the right of travel (`growRegion`).\n const fillLeft = pathSignedArea(path) < 0;\n const cuts: Cut[][] = segs.map(() => []);\n for (const x of segmentCrossings(segs)) {\n const p = crossingPoint(segs[x.a]!, x.s, segs[x.b]!, x.t);\n cuts[x.a]!.push({ t: x.s, p });\n cuts[x.b]!.push({ t: x.t, p });\n }\n const rings = flattenAll(segs, tol / 4);\n const pieces: CubicSegment[] = [];\n let changed = false;\n segs.forEach((seg, i) => {\n const parts = cutSegment(seg, cuts[i]!);\n if (parts.length > 1) changed = true;\n for (const part of parts) {\n const side = filledSide(part, rings, tol);\n if (side === null) changed = true;\n else if (side === fillLeft) pieces.push(part);\n else {\n changed = true;\n pieces.push(reversed(part));\n }\n }\n });\n const b = new PathBuilder();\n if (!changed) {\n for (const c of contours) emit(b, closeContour(c.segs, tol * 1e-3));\n return b.build();\n }\n for (const ring of chain(pieces)) emit(b, ring);\n return b.build();\n}\n\n/** `segs` with every straight edge no longer than `snap` dropped, the gap it\n * leaves closed by moving the next start back, and ending where it starts. */\nfunction closeContour(given: readonly CubicSegment[], snap: number): CubicSegment[] {\n const short = (s: CubicSegment) => s.line && Math.hypot(s.c[6] - s.c[0], s.c[7] - s.c[1]) <= snap;\n const segs = given.filter((s) => !short(s));\n if (segs.length === 0) return [];\n for (let i = 0; i < segs.length; i++) {\n const prev = segs[(i + segs.length - 1) % segs.length]!.c,\n s = segs[i]!;\n if (prev[6] !== s.c[0] || prev[7] !== s.c[1]) {\n if (Math.hypot(prev[6] - s.c[0], prev[7] - s.c[1]) <= snap) segs[i] = moveEnds(s, [prev[6], prev[7]], [s.c[6], s.c[7]]);\n else if (i === 0) segs.push(lineSegment(prev[6], prev[7], s.c[0], s.c[1]));\n }\n }\n return segs;\n}\n\n/** One point for a crossing: an end of either segment when it falls there,\n * so the cut lands on the corner already joining it, else the midpoint of\n * the two curves' estimates. */\nfunction crossingPoint(a: CubicSegment, s: number, b: CubicSegment, t: number): Pt {\n const end = (seg: CubicSegment, u: number): Pt | null =>\n u <= 1e-7 ? [seg.c[0], seg.c[1]] : u >= 1 - 1e-7 ? [seg.c[6], seg.c[7]] : null;\n const fixed = end(a, s) ?? end(b, t);\n if (fixed) return fixed;\n const p = cubicEvalAt(...a.c, s),\n q = cubicEvalAt(...b.c, t);\n return [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2];\n}\n\n/** `seg` cut at every interior cut, each cut end moved onto its cut's point,\n * a curve's adjacent handle moved with it. */\nfunction cutSegment(seg: CubicSegment, cuts: Cut[]): CubicSegment[] {\n const inner = cuts.filter((c) => c.t > 1e-7 && c.t < 1 - 1e-7).sort((x, y) => x.t - y.t);\n const out: CubicSegment[] = [];\n let rest = seg,\n from = 0;\n let start: Pt = [seg.c[0], seg.c[1]];\n for (const cut of inner) {\n if (cut.t - from < 1e-9) continue;\n const [l, r] = splitSegment(rest, (cut.t - from) / (1 - from));\n out.push(moveEnds(l, start, cut.p));\n rest = r;\n from = cut.t;\n start = cut.p;\n }\n out.push(moveEnds(rest, start, [seg.c[6], seg.c[7]]));\n return out;\n}\n\nfunction moveEnds(s: CubicSegment, a: Pt, b: Pt): CubicSegment {\n const c = s.c;\n return {\n c: [a[0], a[1], c[2] + a[0] - c[0], c[3] + a[1] - c[1], c[4] + b[0] - c[6], c[5] + b[1] - c[7], b[0], b[1]],\n line: s.line,\n };\n}\n\nfunction reversed(s: CubicSegment): CubicSegment {\n const c = s.c;\n return { c: [c[6], c[7], c[4], c[5], c[2], c[3], c[0], c[1]], line: s.line };\n}\n\n/** Each contour's polyline, for counting winding against. */\nfunction flattenAll(segs: readonly CubicSegment[], tol: number): number[][] {\n const rings: number[][] = [];\n let ring: number[] = [];\n for (const { c, line } of segs) {\n if (ring.length === 0) ring.push(c[0], c[1]);\n else if (ring[ring.length - 2] !== c[0] || ring[ring.length - 1] !== c[1]) {\n rings.push(ring);\n ring = [c[0], c[1]];\n }\n if (line) ring.push(c[6], c[7]);\n else flattenCubic(...c, tol, ring);\n }\n if (ring.length > 0) rings.push(ring);\n return rings;\n}\n\nfunction winding(rings: readonly number[][], x: number, y: number): number {\n let w = 0;\n for (const r of rings) {\n for (let i = 0; i + 3 < r.length; i += 2) {\n const ay = r[i + 1]!,\n by = r[i + 3]!;\n if (ay > y === by > y) continue;\n const ax = r[i]!,\n bx = r[i + 2]!;\n if (x >= ax + ((y - ay) / (by - ay)) * (bx - ax)) continue;\n w += ay <= y ? 1 : -1;\n }\n }\n return w;\n}\n\n/** Whether the fill lies left of `seg`'s travel (`true`) or right of it, or\n * `null` when it lies on both sides or neither. Judged at its middle. */\nfunction filledSide(seg: CubicSegment, rings: readonly number[][], tol: number): boolean | null {\n const c = seg.c;\n const [x, y] = cubicEvalAt(...c, 0.5);\n const dx = c[6] + c[4] - c[2] - c[0],\n dy = c[7] + c[5] - c[3] - c[1];\n const len = Math.hypot(dx, dy);\n if (len < 1e-12) return null;\n const nx = (dy / len) * tol,\n ny = (-dx / len) * tol;\n const left = winding(rings, x + nx, y + ny) !== 0,\n right = winding(rings, x - nx, y - ny) !== 0;\n return left === right ? null : left;\n}\n\n/** The pieces joined end to start into closed rings. */\nfunction chain(pieces: readonly CubicSegment[]): CubicSegment[][] {\n const key = (x: number, y: number) => `${x},${y}`;\n const from = new Map<string, number[]>();\n pieces.forEach((p, i) => {\n const k = key(p.c[0], p.c[1]);\n const list = from.get(k);\n if (list) list.push(i);\n else from.set(k, [i]);\n });\n const used = new Uint8Array(pieces.length);\n const rings: CubicSegment[][] = [];\n for (let i = 0; i < pieces.length; i++) {\n if (used[i]) continue;\n const ring: CubicSegment[] = [];\n let at: number | undefined = i;\n while (at !== undefined && !used[at]) {\n used[at] = 1;\n const p: CubicSegment = pieces[at]!;\n ring.push(p);\n at = from.get(key(p.c[6], p.c[7]))?.find((j) => !used[j]);\n }\n rings.push(ring);\n }\n return rings;\n}\n\nfunction emit(b: PathBuilder, ring: readonly CubicSegment[]): void {\n if (ring.length === 0) return;\n const [x0, y0] = ring[0]!.c;\n b.moveTo(x0, y0);\n for (const [i, { c, line }] of ring.entries()) {\n if (line && i === ring.length - 1 && c[6] === x0 && c[7] === y0) break;\n if (line) b.lineTo(c[6], c[7]);\n else b.curveTo(c[2], c[3], c[4], c[5], c[6], c[7]);\n }\n b.close();\n}\n","import { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { simplifySpan, simplifySubpath, type SimplifyPathOptions } from './simplifyPath';\n\n/**\n * Simplify only where `flatIndexes` say: each unbroken run of those anchors\n * along a subpath is refitted as one span by the fitter {@link simplifyPath}\n * uses (`simplifySpan`), so only anchors the shape does not need, within\n * `tolerance`, go. A run's first and last anchors stay, and every anchor\n * outside a run is left as it was. A closed subpath named whole is simplified\n * whole. Answers whether any anchor went; a run the fit cannot thin is left\n * untouched.\n */\nexport function simplifyAnchorsAt(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): boolean {\n const bySub = new Map<number, Set<number>>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const named = bySub.get(loc.sub) ?? new Set<number>();\n named.add(loc.idx);\n bySub.set(loc.sub, named);\n }\n let changed = false;\n for (const [s, named] of bySub) {\n const sub = set.anchors[s];\n const closed = set.closed[s];\n if (closed && named.size === sub.length) {\n const next = simplifySubpath(sub, true, tolerance, opts);\n if (next.length < sub.length) { set.anchors[s] = next; changed = true; }\n continue;\n }\n // Start a closed subpath on an anchor outside every run, so none wraps.\n const shift = closed ? [...sub.keys()].find((i) => !named.has(i))! : 0;\n const order = closed ? [...sub.slice(shift), ...sub.slice(0, shift)] : sub;\n const inRun = (i: number) => named.has((i + shift) % sub.length);\n const out = order.slice();\n let thinned = false;\n // Back to front, so a splice leaves the runs before it where they were.\n for (let end = order.length - 1; end >= 0; end--) {\n if (!inRun(end)) continue;\n let start = end;\n while (start > 0 && inRun(start - 1)) start--;\n if (end - start >= 2) {\n const refit = simplifySpan(order, closed, start, end, tolerance, opts);\n if (refit.length < end - start + 1) {\n out.splice(start, end - start + 1, ...refit);\n thinned = true;\n }\n }\n end = start;\n }\n if (thinned) { set.anchors[s] = out; changed = true; }\n }\n return changed;\n}\n","/**\n * A run of consecutive segments of a decoded subpath, measured by arc length:\n * where it is, and which way it heads, any distance along it. Curves are\n * measured by sampling, and points are then found on the curve itself, so a\n * point is exact and only its distance along the run is approximate.\n */\nimport { isStraightSegment, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\nconst LENGTH_SAMPLES = 48;\n\ninterface Seg {\n a: Point;\n c1: Point;\n c2: Point;\n b: Point;\n straight: boolean;\n /** Where the segment starts along the run. */\n from: number;\n len: number;\n /** Arc length to each of `LENGTH_SAMPLES + 1` evenly spaced parameters. */\n table: number[];\n}\n\n/** A run's measure: its length, and its point and unit heading at any\n * distance along it. */\nexport interface ArcRun {\n length: number;\n pointAt(s: number): Point;\n /** The unit direction of travel at `s`. At a joint between segments it is\n * the later segment's unless `arriving`, when it is the earlier one's. */\n headingAt(s: number, arriving?: boolean): Point;\n}\n\nconst unit = (x: number, y: number): Point => {\n const len = Math.hypot(x, y);\n return len === 0 ? { x: 0, y: 0 } : { x: x / len, y: y / len };\n};\n\nfunction derivative(seg: Seg, t: number): Point {\n const u = 1 - t;\n const { a, c1, c2, b } = seg;\n return {\n x: 3 * u * u * (c1.x - a.x) + 6 * u * t * (c2.x - c1.x) + 3 * t * t * (b.x - c2.x),\n y: 3 * u * u * (c1.y - a.y) + 6 * u * t * (c2.y - c1.y) + 3 * t * t * (b.y - c2.y),\n };\n}\n\nfunction headingOn(seg: Seg, t: number): Point {\n if (seg.straight) return unit(seg.b.x - seg.a.x, seg.b.y - seg.a.y);\n let d = derivative(seg, t);\n // A handle lying on its anchor zeroes the derivative there; step inside.\n if (Math.hypot(d.x, d.y) < 1e-9) d = derivative(seg, t < 0.5 ? t + 1e-3 : t - 1e-3);\n const h = unit(d.x, d.y);\n return h.x === 0 && h.y === 0 ? unit(seg.b.x - seg.a.x, seg.b.y - seg.a.y) : h;\n}\n\nfunction measure(a: PenAnchor, b: PenAnchor, from: number): Seg {\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const straight = isStraightSegment(a, b);\n const table = [0];\n if (straight) {\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n for (let k = 1; k <= LENGTH_SAMPLES; k++) table.push((len * k) / LENGTH_SAMPLES);\n } else {\n let prev: Point = a;\n let len = 0;\n for (let k = 1; k <= LENGTH_SAMPLES; k++) {\n const p = cubicPointAt(a, c1, c2, b, k / LENGTH_SAMPLES);\n len += Math.hypot(p.x - prev.x, p.y - prev.y);\n table.push(len);\n prev = p;\n }\n }\n return { a, c1, c2, b, straight, from, len: table[LENGTH_SAMPLES], table };\n}\n\n/** The parameter on `seg` lying `d` along it. */\nfunction paramAt(seg: Seg, d: number): number {\n const { table } = seg;\n if (seg.len === 0) return 0;\n let lo = 0;\n let hi = LENGTH_SAMPLES;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (table[mid] <= d) lo = mid;\n else hi = mid;\n }\n const span = table[hi] - table[lo];\n const f = span === 0 ? 0 : (d - table[lo]) / span;\n return Math.min(1, Math.max(0, (lo + f) / LENGTH_SAMPLES));\n}\n\n/** The run through `anchors[from..to]` of `sub`, indices taken modulo its\n * length so a closed subpath's run may wrap past its end. */\nexport function arcRun(sub: readonly PenAnchor[], from: number, to: number): ArcRun {\n const n = sub.length;\n const segs: Seg[] = [];\n let length = 0;\n for (let i = from; i < to; i++) {\n const seg = measure(sub[i % n], sub[(i + 1) % n], length);\n segs.push(seg);\n length += seg.len;\n }\n const locate = (s: number, arriving: boolean): { seg: Seg; t: number } => {\n const d = Math.min(Math.max(s, 0), length);\n let k = 0;\n while (k < segs.length - 1 && (arriving ? segs[k].from + segs[k].len < d : segs[k].from + segs[k].len <= d)) k++;\n return { seg: segs[k], t: paramAt(segs[k], d - segs[k].from) };\n };\n const start: Point = { x: sub[from % n].x, y: sub[from % n].y };\n return {\n length,\n pointAt(s) {\n if (segs.length === 0) return start;\n const { seg, t } = locate(s, false);\n if (seg.straight) return { x: seg.a.x + (seg.b.x - seg.a.x) * t, y: seg.a.y + (seg.b.y - seg.a.y) * t };\n return cubicPointAt(seg.a, seg.c1, seg.c2, seg.b, t);\n },\n headingAt(s, arriving = false) {\n if (segs.length === 0) return { x: 0, y: 0 };\n const { seg, t } = locate(s, arriving);\n return headingOn(seg, t);\n },\n };\n}\n","/**\n * Resample: a path's anchors spread evenly along it by arc length, and its\n * curves refitted through them.\n */\nimport type { PolygonPath } from '../path';\nimport { nearestOnCubic, nearestOnLine } from '../nearest';\nimport { anchorsToPath, isAnchorSmooth, pathToAnchors, type PenAnchor } from './anchors';\nimport { keepCorner } from './fitRun';\nimport { arcRun, type ArcRun } from './arcRun';\nimport type { Point } from './cubicMath';\nimport { fitCubicWithTangents } from './schneiderFit';\n\n/** Options for {@link resamplePath}. */\nexport interface ResamplePathOptions {\n /** How many anchors the result holds across all its subpaths. Default: as\n * many as `path` has. Ignored when `spacing` is given. */\n count?: number;\n /** The distance along the path between neighboring anchors, in path units.\n * Each run between fixed anchors is cut into the whole number of equal\n * pieces nearest this. */\n spacing?: number;\n /** Keep every corner anchor (`isAnchorSmooth` false) where it is, with its\n * corner, and resample the runs between. Default `true`. Open ends are\n * kept either way. */\n keepCorners?: boolean;\n /** How far the result may stray from the original, in path units. A piece\n * that cannot follow the original this closely is halved, so the result can\n * hold more anchors than `count` asks for. Default 0.5. */\n tolerance?: number;\n}\n\nconst FIT_SAMPLES = 16;\nconst MAX_HALVINGS = 6;\n\n/** A run between two fixed anchors, as the arc-length measure over it. */\ninterface Span {\n run: ArcRun;\n pieces: number;\n}\n\n/**\n * `path` with its anchors spread evenly along each run between fixed anchors\n * ({@link ResamplePathOptions}), each new anchor heading the way the original\n * does there. Anchors that were smooth stay smooth, and the curves between\n * are fitted to the original. A closed subpath with no fixed anchor keeps\n * its first one as the place the even spacing starts from. Fill rules carry\n * over.\n */\nexport function resamplePath(path: PolygonPath, opts: ResamplePathOptions = {}): PolygonPath {\n const { anchors, closed } = pathToAnchors(path);\n const keepCorners = opts.keepCorners ?? true;\n const tol = Math.max(opts.tolerance ?? 0.5, 1e-6);\n const fixedBySub = anchors.map((sub, s) => fixedAnchors(sub, closed[s], keepCorners));\n const spansBySub = anchors.map((sub, s) => spansOf(sub, closed[s], fixedBySub[s]));\n allocate(spansBySub.flat(), fixedBySub, opts, anchors);\n\n const out: PenAnchor[][] = [];\n anchors.forEach((sub, s) => {\n if (sub.length < 2) {\n out.push(sub);\n return;\n }\n const fixed = fixedBySub[s];\n const first = sub[fixed[0]];\n const result: PenAnchor[] = [{ x: first.x, y: first.y }];\n keepCorner(result[0], first);\n spansBySub[s].forEach((span, k) => {\n const closing = closed[s] && k === spansBySub[s].length - 1;\n appendSpan(span, tol, result, closing);\n if (!closing) keepCorner(result[result.length - 1], sub[fixed[k + 1]]);\n });\n out.push(result);\n });\n return anchorsToPath(out, closed, path);\n}\n\n/** Indices of the anchors of `sub` that stay where they are, ascending. */\nfunction fixedAnchors(sub: readonly PenAnchor[], closed: boolean, keepCorners: boolean): number[] {\n const n = sub.length;\n const fixed = new Set<number>();\n if (!closed && n > 0) {\n fixed.add(0);\n fixed.add(n - 1);\n }\n if (keepCorners) sub.forEach((a, i) => { if (!isAnchorSmooth(a)) fixed.add(i); });\n if (fixed.size === 0 && n > 0) fixed.add(0);\n return [...fixed].sort((a, b) => a - b);\n}\n\nfunction spansOf(sub: readonly PenAnchor[], closed: boolean, fixed: number[]): Span[] {\n if (sub.length < 2) return [];\n const stops = closed ? [...fixed, fixed[0] + sub.length] : fixed;\n const spans: Span[] = [];\n for (let k = 0; k + 1 < stops.length; k++) spans.push({ run: arcRun(sub, stops[k], stops[k + 1]), pieces: 1 });\n return spans;\n}\n\n/** How many equal pieces each span is cut into. */\nfunction allocate(spans: Span[], fixedBySub: number[][], opts: ResamplePathOptions, anchors: PenAnchor[][]): void {\n if (opts.spacing !== undefined && opts.spacing > 0) {\n for (const span of spans) span.pieces = Math.max(1, Math.round(span.run.length / opts.spacing));\n return;\n }\n const count = Math.floor(opts.count ?? anchors.reduce((n, sub) => n + sub.length, 0));\n const fixedCount = fixedBySub.reduce((n, f, s) => n + (anchors[s].length < 2 ? anchors[s].length : f.length), 0);\n const free = count - fixedCount;\n const total = spans.reduce((n, span) => n + span.run.length, 0);\n if (free <= 0 || total === 0) return;\n // Largest remainder: whole shares first, then the leftover anchors to the\n // spans that lost the most to rounding down.\n const shares = spans.map((span) => (free * span.run.length) / total);\n spans.forEach((span, i) => { span.pieces = 1 + Math.floor(shares[i]); });\n let left = free - spans.reduce((n, span) => n + span.pieces - 1, 0);\n const order = shares.map((v, i) => ({ i, r: v - Math.floor(v) })).sort((a, b) => b.r - a.r);\n for (let k = 0; left > 0 && k < order.length; k++, left--) spans[order[k].i].pieces++;\n}\n\n/** Cut `span` into its pieces, fit each, and append the anchors after the\n * first to `out`. `closing` folds the final anchor into `out[0]`. */\nfunction appendSpan(span: Span, tol: number, out: PenAnchor[], closing: boolean): void {\n const pieces: Array<{ c1?: Point; c2?: Point; end: Point }> = [];\n const { run } = span;\n for (let j = 0; j < span.pieces; j++) {\n fitPiece(run, (run.length * j) / span.pieces, (run.length * (j + 1)) / span.pieces, tol, 0, pieces);\n }\n pieces.forEach((piece, i) => {\n const prev = out[out.length - 1];\n if (piece.c1) prev.outHandle = piece.c1;\n if (closing && i === pieces.length - 1) {\n if (piece.c2) out[0].inHandle = piece.c2;\n return;\n }\n out.push(piece.c2 ? { x: piece.end.x, y: piece.end.y, inHandle: piece.c2 } : { x: piece.end.x, y: piece.end.y });\n });\n}\n\n/** Fit the stretch `[s0, s1]` of `run`, halving it while one cubic strays\n * past `tol`. */\nfunction fitPiece(\n run: ArcRun, s0: number, s1: number, tol: number, depth: number,\n out: Array<{ c1?: Point; c2?: Point; end: Point }>,\n): void {\n const samples: Point[] = [];\n const params: number[] = [];\n for (let i = 0; i <= FIT_SAMPLES; i++) {\n params.push(i / FIT_SAMPLES);\n samples.push(run.pointAt(s0 + ((s1 - s0) * i) / FIT_SAMPLES));\n }\n const a = samples[0];\n const e = samples[FIT_SAMPLES];\n if (worst(samples, (p) => nearestOnLine(p.x, p.y, a.x, a.y, e.x, e.y).dist) <= tol) {\n out.push({ end: e });\n return;\n }\n const tStart = run.headingAt(s0);\n const into = run.headingAt(s1, true);\n const { cp1, cp2 } = fitCubicWithTangents(samples, tStart, { x: -into.x, y: -into.y }, { params, passes: 3 });\n const err = worst(samples, (p) => nearestOnCubic(p.x, p.y, a.x, a.y, cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y).dist);\n if (err > tol && depth < MAX_HALVINGS) {\n const mid = (s0 + s1) / 2;\n fitPiece(run, s0, mid, tol, depth + 1, out);\n fitPiece(run, mid, s1, tol, depth + 1, out);\n return;\n }\n out.push({ c1: cp1, c2: cp2, end: e });\n}\n\nfunction worst(samples: readonly Point[], dist: (p: Point) => number): number {\n let max = 0;\n for (let i = 1; i < samples.length - 1; i++) max = Math.max(max, dist(samples[i]));\n return max;\n}\n\n","/**\n * Anchors at the extremes of a path's curves: where a curved segment is\n * furthest left, right, up or down along its own run. Splitting there puts\n * an anchor with an axis-aligned tangent at each turn, and changes no point\n * of the shape.\n */\nimport { cubicAxisExtremaTs } from '../curve';\nimport { isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\nimport { insertAnchorOnSegment, type AnchorSet } from './anchorEdits';\n\n/** How close to an end, in curve parameter, an extreme may sit and still get\n * an anchor of its own. Nearer, it is the end's. */\nconst END_SLOP = 1e-4;\n\n/** The parameters in (0, 1) where the segment from `a` to `b` turns in x or\n * y, ascending, or none for a straight segment. */\nexport function segmentExtremaTs(a: PenAnchor, b: PenAnchor): number[] {\n if (isStraightSegment(a, b)) return [];\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const ts = [\n ...cubicAxisExtremaTs(a.x, c1.x, c2.x, b.x),\n ...cubicAxisExtremaTs(a.y, c1.y, c2.y, b.y),\n ].filter((t) => t > END_SLOP && t < 1 - END_SLOP).sort((p, q) => p - q);\n return ts.filter((t, i) => i === 0 || t - ts[i - 1] > END_SLOP);\n}\n\n/**\n * Split every curved segment of `set` at its extremes\n * ({@link segmentExtremaTs}), in place. `include(sub, segIdx)` limits it to\n * some segments, named as `segmentEnds` names them; absent, every one.\n * Returns the new anchors' flat indices in the edited set. Each new anchor is\n * smooth, and every anchor after one moves up an index.\n */\nexport function addExtremaAnchors(\n set: AnchorSet,\n include?: (sub: number, segIdx: number) => boolean,\n): number[] {\n const added = new Set<PenAnchor>();\n set.anchors.forEach((sub, s) => {\n const segCount = sub.length - (set.closed[s] && sub.length > 1 ? 0 : 1);\n // Last to first, so a split never renumbers a segment still to come.\n for (let segIdx = segCount - 1; segIdx >= 0; segIdx--) {\n if (include && !include(s, segIdx)) continue;\n const ends = segmentEnds(set.anchors, set.closed, s, segIdx);\n if (!ends) continue;\n // Highest first: what is left to split is then always [0, end].\n let end = 1;\n for (const t of segmentExtremaTs(ends.a, ends.b).reverse()) {\n const at = insertAnchorOnSegment(set, { sub: s, segIdx, t: t / end });\n if (at >= 0) added.add(sub[segIdx + 1]);\n end = t;\n }\n }\n });\n const out: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (added.has(a)) out.push(flat);\n flat++;\n }\n }\n return out;\n}\n","/**\n * Anchor selections walked along the path: grown or shrunk by one anchor,\n * every Nth anchor, anchors by kind, and the complement. Each takes the\n * decoded set and a selection as flat indices, and returns a new selection\n * as sorted flat indices; none of them edits the set.\n *\n * \"Along the path\" means within a subpath: an anchor's neighbors are the\n * anchors before and after it there, and a closed subpath's first and last\n * anchors are neighbors.\n */\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\nimport { anchorCount, type AnchorSet } from './anchorEdits';\n\n/** The flat index of each subpath's first anchor. */\nfunction subpathStarts(set: AnchorSet): number[] {\n const starts: number[] = [];\n let base = 0;\n for (const sub of set.anchors) {\n starts.push(base);\n base += sub.length;\n }\n return starts;\n}\n\nconst sorted = (ids: Iterable<number>): number[] => [...new Set(ids)].sort((a, b) => a - b);\n\n/** The flat indices of the anchors either side of each anchor in `sub`\n * starting at `base`; a missing neighbor is -1. */\nfunction neighbors(set: AnchorSet, s: number, i: number, base: number): [number, number] {\n const n = set.anchors[s].length;\n const closed = set.closed[s] === true && n > 1;\n const prev = i > 0 ? i - 1 : closed ? n - 1 : -1;\n const next = i < n - 1 ? i + 1 : closed ? 0 : -1;\n return [prev < 0 ? -1 : base + prev, next < 0 ? -1 : base + next];\n}\n\n/** `selected` with each selected anchor's neighbors along the path added. */\nexport function growAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n const out = new Set(had);\n const starts = subpathStarts(set);\n set.anchors.forEach((sub, s) => {\n for (let i = 0; i < sub.length; i++) {\n if (!had.has(starts[s] + i)) continue;\n for (const k of neighbors(set, s, i, starts[s])) if (k >= 0) out.add(k);\n }\n });\n const total = anchorCount(set);\n return sorted([...out].filter((k) => k >= 0 && k < total));\n}\n\n/**\n * `selected` less every anchor at the edge of a selected run: one with a\n * neighbor that is unselected, or none on one side, as an open subpath's ends\n * have. A closed subpath selected all the way round has no edge and stays.\n */\nexport function shrinkAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n const out: number[] = [];\n const starts = subpathStarts(set);\n set.anchors.forEach((sub, s) => {\n for (let i = 0; i < sub.length; i++) {\n const flat = starts[s] + i;\n if (!had.has(flat)) continue;\n if (neighbors(set, s, i, starts[s]).every((k) => k >= 0 && had.has(k))) out.push(flat);\n }\n });\n return out;\n}\n\n/**\n * Every `n`th anchor along each subpath, counting from its first selected\n * anchor. With nothing selected, every subpath counts from its first anchor;\n * otherwise only subpaths holding a selected anchor take part. A closed\n * subpath is walked once round, so the count does not wrap onto itself.\n */\nexport function everyNthAnchor(set: AnchorSet, n: number, selected: Iterable<number> = []): number[] {\n const step = Math.max(1, Math.floor(n));\n const had = new Set(selected);\n const starts = subpathStarts(set);\n const out: number[] = [];\n set.anchors.forEach((sub, s) => {\n let from = had.size === 0 ? 0 : -1;\n for (let i = 0; from < 0 && i < sub.length; i++) if (had.has(starts[s] + i)) from = i;\n if (from < 0) return;\n const closed = set.closed[s] === true;\n const reach = closed ? sub.length : sub.length - from;\n for (let k = 0; k < reach; k += step) out.push(starts[s] + ((from + k) % sub.length));\n });\n return sorted(out);\n}\n\n/** Every anchor `keep` says yes to. */\nexport function anchorsWhere(set: AnchorSet, keep: (anchor: PenAnchor) => boolean): number[] {\n const out: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (keep(a)) out.push(flat);\n flat++;\n }\n }\n return out;\n}\n\n/** Every corner anchor: one whose handles are not collinear through it, or\n * that lacks one (`isAnchorSmooth` false). */\nexport function cornerAnchors(set: AnchorSet): number[] {\n return anchorsWhere(set, (a) => !isAnchorSmooth(a));\n}\n\n/** Every smooth anchor (`isAnchorSmooth`). */\nexport function smoothAnchors(set: AnchorSet): number[] {\n return anchorsWhere(set, isAnchorSmooth);\n}\n\n/** Every anchor `selected` leaves out. */\nexport function invertAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n return anchorsWhere(set, () => true).filter((k) => !had.has(k));\n}\n","/**\n * Average and Join: anchor-set edits that bring anchors together. Both mutate\n * the model `pathToAnchors` produces in place, like the edits in\n * `anchorEdits`, and address anchors by flat index.\n */\n\nimport type { PenAnchor } from './anchors';\nimport { locateAnchor, translateAnchorBy, type AnchorSet } from './anchorEdits';\n\n/** Which coordinates {@link averageAnchorsAt} averages: `'x'` lines the\n * anchors up on one vertical, `'y'` on one horizontal, `'both'` stacks them\n * on one point. */\nexport type AverageAxis = 'x' | 'y' | 'both';\n\n/** One end of an open subpath. */\nexport interface SubpathEnd {\n sub: number;\n end: 'first' | 'last';\n}\n\n/** Endpoints closer than this are one point, and joining them merges them. */\nconst COINCIDENT = 1e-6;\n\n/** How {@link joinSubpathEnds} spans the gap between two ends apart. */\nexport interface JoinOptions {\n /** Absent, a straight segment. Given, a curve leaving each end along the\n * direction its path was heading there, each handle `tension` times the\n * gap long; `0` is a straight segment. */\n tension?: number;\n}\n\n/**\n * Move each anchor in `flatIndexes` to their mean position, along `axis`.\n * Each anchor carries its handles with it. Returns false, changing nothing,\n * when fewer than two of the indexes name anchors.\n */\nexport function averageAnchorsAt(set: AnchorSet, flatIndexes: Iterable<number>, axis: AverageAxis = 'both'): boolean {\n const picked: { flat: number; a: PenAnchor }[] = [];\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (loc) picked.push({ flat, a: set.anchors[loc.sub][loc.idx] });\n }\n if (picked.length < 2) return false;\n const mx = picked.reduce((s, p) => s + p.a.x, 0) / picked.length;\n const my = picked.reduce((s, p) => s + p.a.y, 0) / picked.length;\n for (const { flat, a } of picked) {\n translateAnchorBy(set, flat, axis === 'y' ? 0 : mx - a.x, axis === 'x' ? 0 : my - a.y);\n }\n return true;\n}\n\n/** The open-subpath end anchor `flatIndex` names, or null for an interior\n * anchor or one on a closed subpath. A lone anchor reads as `'last'`. */\nexport function subpathEndAt(set: AnchorSet, flatIndex: number): SubpathEnd | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || set.closed[loc.sub]) return null;\n const len = set.anchors[loc.sub].length;\n if (loc.idx === len - 1) return { sub: loc.sub, end: 'last' };\n if (loc.idx === 0) return { sub: loc.sub, end: 'first' };\n return null;\n}\n\n/**\n * Join the two open-subpath ends `a` and `b`. The two ends of one subpath\n * close it; ends of two subpaths make one subpath, `a`'s run followed by\n * `b`'s, in the slot of whichever came first. Ends that coincide merge into\n * one anchor, keeping the handle on either side; ends apart are bridged by a\n * straight segment, or with `options.tension` by a curve meeting each end\n * tangentially. Returns false, changing nothing, when the ends are not two\n * distinct ends of open subpaths.\n */\nexport function joinSubpathEnds(set: AnchorSet, a: SubpathEnd, b: SubpathEnd, options: JoinOptions = {}): boolean {\n const subA = set.anchors[a.sub];\n const subB = set.anchors[b.sub];\n if (!subA || !subB || set.closed[a.sub] || set.closed[b.sub]) return false;\n if (a.sub === b.sub) {\n if (a.end === b.end || subA.length < 2) return false;\n const first = subA[0];\n const last = subA[subA.length - 1];\n if (coincide(first, last) && subA.length > 2) {\n if (last.inHandle) first.inHandle = last.inHandle;\n subA.pop();\n } else if (options.tension !== undefined) {\n bridge(subA, subA, options.tension);\n }\n set.closed[a.sub] = true;\n return true;\n }\n if (a.end === 'first') reverseInPlace(subA);\n if (b.end === 'last') reverseInPlace(subB);\n const tail = subA[subA.length - 1];\n const head = subB[0];\n let joined: PenAnchor[];\n if (coincide(tail, head)) {\n if (head.outHandle) tail.outHandle = head.outHandle;\n joined = [...subA, ...subB.slice(1)];\n } else {\n if (options.tension !== undefined) bridge(subA, subB, options.tension);\n joined = [...subA, ...subB];\n }\n const keep = Math.min(a.sub, b.sub);\n const drop = Math.max(a.sub, b.sub);\n set.anchors[keep] = joined;\n set.anchors.splice(drop, 1);\n set.closed.splice(drop, 1);\n return true;\n}\n\n/** {@link joinSubpathEnds} for two anchors named by flat index, each the end\n * of an open subpath. */\nexport function joinAnchorsAt(set: AnchorSet, flatA: number, flatB: number, options: JoinOptions = {}): boolean {\n if (flatA === flatB) return false;\n const a = subpathEndAt(set, flatA);\n const b = subpathEndAt(set, flatB);\n if (!a || !b) return false;\n return joinSubpathEnds(set, a, b, options);\n}\n\n/**\n * The two open-subpath ends nearest each other that `accept` allows, on two\n * different subpaths. Null when there are no two such subpaths.\n */\nexport function closestOpenEnds(\n set: AnchorSet,\n accept: (a: SubpathEnd, b: SubpathEnd) => boolean = () => true,\n): [SubpathEnd, SubpathEnd] | null {\n const ends: { end: SubpathEnd; at: PenAnchor }[] = [];\n set.anchors.forEach((sub, s) => {\n if (set.closed[s] || sub.length < 2) return;\n ends.push({ end: { sub: s, end: 'first' }, at: sub[0] });\n ends.push({ end: { sub: s, end: 'last' }, at: sub[sub.length - 1] });\n });\n let best: [SubpathEnd, SubpathEnd] | null = null;\n let bestD = Infinity;\n for (let i = 0; i < ends.length; i++) {\n for (let j = i + 1; j < ends.length; j++) {\n const p = ends[i], q = ends[j];\n if (p.end.sub === q.end.sub || !accept(p.end, q.end)) continue;\n const d = Math.hypot(p.at.x - q.at.x, p.at.y - q.at.y);\n if (d < bestD) { bestD = d; best = [p.end, q.end]; }\n }\n }\n return best;\n}\n\nconst coincide = (p: PenAnchor, q: PenAnchor): boolean => Math.hypot(p.x - q.x, p.y - q.y) <= COINCIDENT;\n\ntype Vec = { x: number; y: number };\n\n/** The unit vector from `from` to `to`, or null when they coincide. */\nfunction unit(from: Vec, to: Vec): Vec | null {\n const d = Math.hypot(to.x - from.x, to.y - from.y);\n return d > COINCIDENT ? { x: (to.x - from.x) / d, y: (to.y - from.y) / d } : null;\n}\n\n/** The direction `sub` heads in at its last anchor: along the last segment's\n * final tangent, from the nearest of its controls that is apart from it. */\nfunction headingAtLast(sub: PenAnchor[]): Vec | null {\n const end = sub[sub.length - 1];\n const prev = sub.length > 1 ? sub[sub.length - 2] : null;\n for (const c of [end.inHandle, prev?.outHandle, prev]) {\n const u = c ? unit(c, end) : null;\n if (u) return u;\n }\n return null;\n}\n\n/** The direction `sub` heads in as it leaves its first anchor. */\nfunction headingAtFirst(sub: PenAnchor[]): Vec | null {\n const start = sub[0];\n const next = sub.length > 1 ? sub[1] : null;\n for (const c of [start.outHandle, next?.inHandle, next]) {\n const u = c ? unit(start, c) : null;\n if (u) return u;\n }\n return null;\n}\n\n/**\n * Shape the segment from `from`'s last anchor to `to`'s first as a curve that\n * carries on from each: handles `tension` times the gap long, along the\n * heading of each path at its end. An end with no heading of its own (a lone\n * anchor) aims at the other end.\n */\nfunction bridge(from: PenAnchor[], to: PenAnchor[], tension: number): void {\n const tail = from[from.length - 1];\n const head = to[0];\n const gap = Math.hypot(head.x - tail.x, head.y - tail.y);\n const chord = unit(tail, head);\n if (!chord || tension <= 0) return;\n const out = headingAtLast(from) ?? chord;\n const into = headingAtFirst(to) ?? chord;\n const len = tension * gap;\n tail.outHandle = { x: tail.x + out.x * len, y: tail.y + out.y * len };\n head.inHandle = { x: head.x - into.x * len, y: head.y - into.y * len };\n}\n\n/** Reverse `sub`'s direction keeping each anchor object, so origin tracking\n * (`editAnchorSetTracked`) still recognizes them. */\nfunction reverseInPlace(sub: PenAnchor[]): void {\n sub.reverse();\n for (const a of sub) {\n const { inHandle, outHandle } = a;\n delete a.inHandle;\n delete a.outHandle;\n if (outHandle) a.inHandle = outHandle;\n if (inHandle) a.outHandle = inHandle;\n }\n}\n","import type { Affine } from './affine';\n\n/**\n * The affine map carrying the points of `from` closest to those of `to`, by\n * least squares; both are interleaved `x, y` streams of the same length. When\n * the points lie on one line an affine map is not determined, and the\n * similarity (turn, even scale and move) is returned instead. Null for fewer\n * than two distinct points.\n */\nexport function fitAffine(from: ArrayLike<number>, to: ArrayLike<number>): Affine | null {\n const n = Math.min(from.length, to.length) >> 1;\n if (n === 0) return null;\n let fx = 0, fy = 0, tx = 0, ty = 0;\n for (let i = 0; i < n; i++) {\n fx += from[2 * i]; fy += from[2 * i + 1]; tx += to[2 * i]; ty += to[2 * i + 1];\n }\n fx /= n; fy /= n; tx /= n; ty /= n;\n // Centered sums: sxx = Σ x², sxy = Σ x·y, and so on, from on the left, to on the right.\n let sxx = 0, sxy = 0, syy = 0, sxu = 0, syu = 0, sxv = 0, syv = 0;\n for (let i = 0; i < n; i++) {\n const x = from[2 * i] - fx, y = from[2 * i + 1] - fy;\n const u = to[2 * i] - tx, v = to[2 * i + 1] - ty;\n sxx += x * x; sxy += x * y; syy += y * y;\n sxu += x * u; syu += y * u; sxv += x * v; syv += y * v;\n }\n const spread = sxx + syy;\n if (spread <= 1e-24) return null;\n const det = sxx * syy - sxy * sxy;\n let a: number, b: number, c: number, d: number;\n if (det > 1e-12 * spread * spread) {\n a = (sxu * syy - syu * sxy) / det;\n c = (syu * sxx - sxu * sxy) / det;\n b = (sxv * syy - syv * sxy) / det;\n d = (syv * sxx - sxv * sxy) / det;\n } else {\n a = (sxu + syv) / spread;\n b = (sxv - syu) / spread;\n c = -b;\n d = a;\n }\n return [a, b, c, d, tx - a * fx - c * fy, ty - b * fx - d * fy];\n}\n","/**\n * Ergonomic builders for tiny shape paths used by chrome / overlays / markers.\n * They all return `PolygonPath`.\n *\n * Not appropriate for *user-drawn* shapes (those have a pose and live in the\n * scene).\n */\n\nimport { rectToContour } from '../box';\nimport { PATH_L, PATH_M, PATH_Z } from '../commands';\nimport type { PolygonPath } from '../path';\n\n/**\n * N-segment polygon approximation of a circle. Default 32 segments → max\n * radial deviation of ≈0.005·r (≈0.05 px at r=10). Bump higher for large\n * filled circles where the facets become visible.\n */\nexport function circlePath(cx: number, cy: number, r: number, segments = 32): PolygonPath {\n const cmds = new Uint8Array(segments + 1);\n const coords = new Float32Array(segments * 2);\n cmds[0] = PATH_M;\n coords[0] = cx + r;\n coords[1] = cy;\n for (let i = 1; i < segments; i++) {\n cmds[i] = PATH_L;\n const theta = (i / segments) * Math.PI * 2;\n coords[i * 2] = cx + r * Math.cos(theta);\n coords[i * 2 + 1] = cy + r * Math.sin(theta);\n }\n cmds[segments] = PATH_Z;\n return { kind: 'polygon', commands: cmds, coords, fillRule: 'nonzero' };\n}\n\n/** Axis-aligned square centred at (cx, cy) with side length `size`. */\nexport function squarePath(cx: number, cy: number, size: number): PolygonPath {\n const half = size / 2;\n const x0 = cx - half, y0 = cy - half;\n const x1 = cx + half, y1 = cy + half;\n return {\n kind: 'polygon',\n commands: new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]),\n coords: new Float32Array([x0, y0, x1, y0, x1, y1, x0, y1]),\n fillRule: 'nonzero',\n };\n}\n\n/** Axis-aligned rectangle. Top-left at (x, y), width/height as given. */\nexport function rectMarkerPath(x: number, y: number, width: number, height: number): PolygonPath {\n return {\n kind: 'polygon',\n commands: new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]),\n coords: Float32Array.from(rectToContour(x, y, width, height)),\n fillRule: 'nonzero',\n };\n}\n\n/**\n * Axis-aligned rounded rectangle. Top-left at (x, y); `r` is clamped to half\n * the shorter side. Each corner is `cornerSamples` line segments — the\n * default 8 gives the same angular resolution as `circlePath`'s 32.\n */\nexport function roundRectPath(\n x: number,\n y: number,\n width: number,\n height: number,\n r: number,\n cornerSamples = 8,\n): PolygonPath {\n const radius = Math.max(0, Math.min(r, Math.min(width, height) / 2));\n if (radius === 0) return rectMarkerPath(x, y, width, height);\n\n const HALF_PI = Math.PI / 2;\n // Corner centers paired with the arc's start angle, walked clockwise in\n // screen space from the top-left.\n const corners: Array<[number, number, number]> = [\n [x + radius, y + radius, Math.PI],\n [x + width - radius, y + radius, -HALF_PI],\n [x + width - radius, y + height - radius, 0],\n [x + radius, y + height - radius, HALF_PI],\n ];\n\n const perCorner = cornerSamples + 1;\n const count = corners.length * perCorner;\n const cmds = new Uint8Array(count + 1);\n const coords = new Float32Array(count * 2);\n let i = 0;\n for (const [cx, cy, start] of corners) {\n for (let s = 0; s <= cornerSamples; s++) {\n const theta = start + (s / cornerSamples) * HALF_PI;\n cmds[i] = i === 0 ? PATH_M : PATH_L;\n coords[i * 2] = cx + radius * Math.cos(theta);\n coords[i * 2 + 1] = cy + radius * Math.sin(theta);\n i++;\n }\n }\n cmds[count] = PATH_Z;\n return { kind: 'polygon', commands: cmds, coords, fillRule: 'nonzero' };\n}\n","/**\n * 2D affine matrix utilities. Column-major 9 elements, matching\n * `WebGL2RenderingContext.uniformMatrix3fv` element order so an upload needs\n * no transpose flag.\n *\n * Layout (column-major):\n * [m00, m10, 0,\n * m01, m11, 0,\n * tx, ty, 1]\n */\n\nimport { invert as invertAffine, type Affine } from './affine';\n\n/**\n * A 2D affine transform as a column-major 9-element array, laid out as above.\n *\n * Every matrix the kit builds is a `Float64Array`: a view translation far\n * from the origin at high zoom needs more than a float32's 24 bits to hold a\n * fraction of a pixel. A `Float32Array` is accepted wherever one is read.\n * `mat3.toUniform` makes the float32 copy a GL uniform upload wants.\n */\nexport type GlMat3 = Float32Array | Float64Array;\n\nfunction create(a: number, b: number, c: number, d: number, tx: number, ty: number): GlMat3 {\n // Column-major:\n // col 0: (a, b, 0)\n // col 1: (c, d, 0)\n // col 2: (tx, ty, 1)\n return new Float64Array([a, b, 0, c, d, 0, tx, ty, 1]);\n}\n\nfunction identity(): GlMat3 {\n return create(1, 0, 0, 1, 0, 0);\n}\n\nfunction multiply(out: GlMat3, m: GlMat3): GlMat3 {\n // out := out · m (right-multiply by m).\n const a = out[0], b = out[1];\n const c = out[3], d = out[4];\n const tx = out[6], ty = out[7];\n const ma = m[0], mb = m[1];\n const mc = m[3], md = m[4];\n const mtx = m[6], mty = m[7];\n\n return create(\n a * ma + c * mb, // new a\n b * ma + d * mb, // new b\n a * mc + c * md, // new c\n b * mc + d * md, // new d\n a * mtx + c * mty + tx, // new tx\n b * mtx + d * mty + ty, // new ty\n );\n}\n\n/** `m · T(tx, ty)`: composes onto `m`, where `@weasel-js/geom`'s `translate`\n * constructs a fresh matrix. */\nfunction translated(m: GlMat3, tx: number, ty: number): GlMat3 {\n const t = create(1, 0, 0, 1, tx, ty);\n return multiply(m, t);\n}\n\n/** `m · S(sx, sy)`: composes onto `m`, where geom's `scale` constructs one. */\nfunction scaled(m: GlMat3, sx: number, sy: number): GlMat3 {\n const s = create(sx, 0, 0, sy, 0, 0);\n return multiply(m, s);\n}\n\n/** This layout read as the kernel's 6-element affine. The two carry the same\n * logical order, so the conversion is a repack and nothing else. */\nfunction toAffine(m: GlMat3): Affine {\n return [m[0], m[1], m[3], m[4], m[6], m[7]];\n}\n\n/** The kernel's affine in this layout. The inverse of {@link toAffine}. */\nfunction fromAffine(a: Affine): GlMat3 {\n return create(a[0], a[1], a[2], a[3], a[4], a[5]);\n}\n\n/** Inverse of an affine matrix, or `null` when `@weasel-js/geom`'s `invert`\n * finds it singular — the same rule, read through this layout. */\nfunction invert(m: GlMat3): GlMat3 | null {\n const inv = invertAffine(toAffine(m));\n return inv && fromAffine(inv);\n}\n\n/** A float32 copy of `m`, for `uniformMatrix3fv` or a shader uniform value. */\nfunction toUniform(m: GlMat3): Float32Array {\n return Float32Array.from(m);\n}\n\nfunction apply(m: GlMat3, x: number, y: number): [number, number] {\n const a = m[0], b = m[1];\n const c = m[3], d = m[4];\n const tx = m[6], ty = m[7];\n return [a * x + c * y + tx, b * x + d * y + ty];\n}\n\n/**\n * Map screen pixel coords (0..width on X, 0..height on Y, top-left origin)\n * into clip space (-1..1 on X, 1..-1 on Y — note Y flip so screen-down\n * matches clip-down).\n */\nfunction screenToClip(width: number, height: number): GlMat3 {\n return create(\n 2 / width, // a\n 0, // b\n 0, // c\n -2 / height, // d\n -1, // tx\n 1, // ty\n );\n}\n\n/**\n * Uniform-equivalent scale factor: the square root of the absolute\n * determinant of the linear part, i.e. the geometric mean of the two axis\n * scales. Rotation-invariant. Under non-uniform scale it is between the two\n * axes and exact on neither — the same compromise `meanScale` documents.\n */\nfunction meanScaleOf(m: GlMat3): number {\n return Math.sqrt(Math.abs(m[0] * m[4] - m[1] * m[3]));\n}\n\n/** The least any direction is scaled by the linear part — its smaller singular\n * value. What a screen length is worth in world units, at most. */\nfunction minScaleOf(m: GlMat3): number {\n const sum = m[0] * m[0] + m[1] * m[1] + m[3] * m[3] + m[4] * m[4];\n const det = m[0] * m[4] - m[1] * m[3];\n return Math.sqrt(Math.max(0, (sum - Math.sqrt(Math.max(0, sum * sum - 4 * det * det))) / 2));\n}\n\n/** The renderer's 3x3 matrix operations, as one namespace. These work on the\n * 9-element form the GL uniform upload wants — distinct from the 6-element\n * `Affine`, though the logical element order is the same. */\nexport const mat3 = {\n identity,\n toAffine,\n fromAffine,\n multiply,\n translated,\n scaled,\n invert,\n toUniform,\n apply,\n screenToClip,\n meanScaleOf,\n minScaleOf,\n};\n","import type { GlMat3 } from './glMat3';\nimport type { View } from './view';\n\n/**\n * Build the world→screen transform matrix for a `View`.\n * Use as the `transform` field of a `kind: 'group'` DrawCommand to wrap\n * world-space content emitted from a layer `draw` implementation.\n *\n * Mapping: `screen = (world − {view.x, view.y}) × {view.scale.x, view.scale.y}`.\n *\n * Column-major layout (matches `mat3.identity()`):\n * `[scale.x, 0, 0, 0, scale.y, 0, -view.x*scale.x, -view.y*scale.y, 1]`.\n */\nexport function viewToMat3(view: View): GlMat3 {\n const sx = view.scale.x;\n const sy = view.scale.y;\n // Add 0 to coerce -0 → 0, matching `mat3.identity()` for the {0,0,1} case.\n const tx = -view.x * sx + 0;\n const ty = -view.y * sy + 0;\n return new Float64Array([\n sx, 0, 0,\n 0, sy, 0,\n tx, ty, 1,\n ]);\n}\n","import type { Rect } from './box';\n\n/** Which side of the anchor the overlay sits on. */\nexport type PlacementSide = 'top' | 'bottom' | 'left' | 'right';\n\n/** How the overlay lines up along the side it sits on. */\nexport type PlacementAlign = 'start' | 'center' | 'end';\n\n/** A side paired with an alignment along it. */\nexport interface Placement {\n side: PlacementSide;\n align: PlacementAlign;\n}\n\n/** Inputs to {@link placeRect}. All rects share one coordinate space. */\nexport interface PlaceRectOptions {\n anchor: Rect;\n overlay: { width: number; height: number };\n boundary: Rect;\n placement: Placement;\n /** Gap between anchor and overlay along the side axis. Default 0. */\n offset?: number;\n /** Shift along the alignment axis. Default 0. */\n crossOffset?: number;\n /** Minimum gap kept between the overlay and the boundary. Default 0. */\n padding?: number;\n /** Whether to try the opposite side when the preferred one lacks room. Default true. */\n flip?: boolean;\n}\n\n/** Where the overlay landed, and the placement that produced it. */\nexport interface PlacedRect {\n rect: Rect;\n placement: Placement;\n}\n\nfunction alignAlong(start: number, extent: number, size: number, align: PlacementAlign): number {\n if (align === 'start') return start;\n if (align === 'end') return start + extent - size;\n return start + (extent - size) / 2;\n}\n\nfunction positionOn(\n anchor: Rect,\n overlay: { width: number; height: number },\n placement: Placement,\n offset: number,\n crossOffset: number,\n): Rect {\n const { width, height } = overlay;\n const { side, align } = placement;\n if (side === 'top' || side === 'bottom') {\n const y = side === 'bottom' ? anchor.y + anchor.height + offset : anchor.y - offset - height;\n return { x: alignAlong(anchor.x, anchor.width, width, align) + crossOffset, y, width, height };\n }\n const x = side === 'right' ? anchor.x + anchor.width + offset : anchor.x - offset - width;\n return { x, y: alignAlong(anchor.y, anchor.height, height, align) + crossOffset, width, height };\n}\n\nfunction clampAxis(start: number, size: number, low: number, extent: number, padding: number): number {\n const min = low + padding;\n return Math.max(min, Math.min(start, min + extent - padding * 2 - size));\n}\n\n/**\n * Move `rect` the shortest distance that puts it inside `boundary`, keeping its\n * size. A rect too big to fit pins to the boundary's leading edge.\n */\nexport function clampRectWithin(rect: Rect, boundary: Rect, padding = 0): Rect {\n return {\n ...rect,\n x: clampAxis(rect.x, rect.width, boundary.x, boundary.width, padding),\n y: clampAxis(rect.y, rect.height, boundary.y, boundary.height, padding),\n };\n}\n\n/** Slide along the alignment axis until the overlay is inside. */\nfunction shiftAcross(rect: Rect, boundary: Rect, side: PlacementSide, padding: number): Rect {\n const vertical = side === 'top' || side === 'bottom';\n const size = vertical ? rect.width : rect.height;\n const low = (vertical ? boundary.x : boundary.y) + padding;\n const high = low + (vertical ? boundary.width : boundary.height) - padding * 2 - size;\n const placed = Math.max(low, Math.min(vertical ? rect.x : rect.y, high));\n return vertical ? { ...rect, x: placed } : { ...rect, y: placed };\n}\n\nconst OPPOSITE: Record<PlacementSide, PlacementSide> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n};\n\nfunction fitsAlongSide(rect: Rect, boundary: Rect, side: PlacementSide, padding: number): boolean {\n const vertical = side === 'top' || side === 'bottom';\n const start = vertical ? rect.y : rect.x;\n const end = start + (vertical ? rect.height : rect.width);\n const low = (vertical ? boundary.y : boundary.x) + padding;\n const high = low + (vertical ? boundary.height : boundary.width) - padding * 2;\n return start >= low && end <= high;\n}\n\n/**\n * Position an overlay beside `anchor` at the requested placement. With `flip`,\n * a side that overflows the boundary is swapped for the opposite one when that\n * fits. The result then slides along the alignment axis to stay inside the\n * boundary; along the side axis it is left where it is, even if it overflows.\n */\nexport function placeRect(options: PlaceRectOptions): PlacedRect {\n const { anchor, overlay, boundary, placement, offset = 0, crossOffset = 0 } = options;\n const { padding = 0, flip = true } = options;\n\n let resolved = placement;\n let rect = positionOn(anchor, overlay, resolved, offset, crossOffset);\n\n if (flip && !fitsAlongSide(rect, boundary, resolved.side, padding)) {\n const opposite = { side: OPPOSITE[resolved.side], align: resolved.align };\n const flipped = positionOn(anchor, overlay, opposite, offset, crossOffset);\n if (fitsAlongSide(flipped, boundary, opposite.side, padding)) {\n resolved = opposite;\n rect = flipped;\n }\n }\n\n return { rect: shiftAcross(rect, boundary, resolved.side, padding), placement: resolved };\n}\n","/** An easing curve: maps normalized progress `t ∈ [0, 1]` to eased progress.\n * Curves may leave the 0–1 range in the middle (back, elastic) but should\n * pass through 0 at 0 and 1 at 1. */\nexport type EasingFn = (t: number) => number;\n\n/** A spring's physical parameters. Higher stiffness settles faster, higher\n * damping overshoots less, higher mass makes both sluggish. */\nexport interface SpringPreset {\n stiffness: number;\n damping: number;\n mass: number;\n}\n\n/** One of the tunings in `SPRING_PRESETS`. */\nexport type SpringPresetName = 'gentle' | 'wobbly' | 'stiff' | 'slow';\n\n// --- Polynomial family (degree 1-5). The unsuffixed `easeIn`/`easeOut`/\n// `easeInOut` aliases mirror the `easeInQuad` curve (degree 2) for backwards\n// compatibility with existing call sites.\n\n/** No easing: constant rate from start to finish. */\nexport const linear: EasingFn = (t) => t;\n\n// Quadratic (degree 2)\n/** Accelerates from a standstill, gently. */\nexport const easeInQuad: EasingFn = (t) => t * t;\n/** Decelerates to a stop, gently. The safe default for UI motion. */\nexport const easeOutQuad: EasingFn = (t) => 1 - (1 - t) * (1 - t);\n/** Accelerates then decelerates, gently. */\nexport const easeInOutQuad: EasingFn = (t) =>\n t < 0.5 ? 2 * t * t : 1 - 2 * (1 - t) * (1 - t);\n\n// Cubic (degree 3)\n/** Accelerates from a standstill, moderately. */\nexport const easeInCubic: EasingFn = (t) => t * t * t;\n/** Decelerates to a stop, moderately. */\nexport const easeOutCubic: EasingFn = (t) => 1 - Math.pow(1 - t, 3);\n/** Accelerates then decelerates, moderately. */\nexport const easeInOutCubic: EasingFn = (t) =>\n t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;\n\n// Quartic (degree 4)\n/** Accelerates from a standstill, sharply. */\nexport const easeInQuart: EasingFn = (t) => t * t * t * t;\n/** Decelerates to a stop, sharply. */\nexport const easeOutQuart: EasingFn = (t) => 1 - Math.pow(1 - t, 4);\n/** Accelerates then decelerates, sharply. */\nexport const easeInOutQuart: EasingFn = (t) =>\n t < 0.5 ? 8 * t * t * t * t : 1 - Math.pow(-2 * t + 2, 4) / 2;\n\n// Quintic (degree 5)\n/** Accelerates from a standstill, very sharply. */\nexport const easeInQuint: EasingFn = (t) => t * t * t * t * t;\n/** Decelerates to a stop, very sharply. */\nexport const easeOutQuint: EasingFn = (t) => 1 - Math.pow(1 - t, 5);\n/** Accelerates then decelerates, very sharply. */\nexport const easeInOutQuint: EasingFn = (t) =>\n t < 0.5 ? 16 * t * t * t * t * t : 1 - Math.pow(-2 * t + 2, 5) / 2;\n\n// --- Trigonometric / transcendental\n\n/** Accelerates from a standstill along a sine curve — the mildest\n * acceleration of the built-ins. */\nexport const easeInSine: EasingFn = (t) => 1 - Math.cos((t * Math.PI) / 2);\n/** Decelerates to a stop along a sine curve — the mildest\n * deceleration of the built-ins. */\nexport const easeOutSine: EasingFn = (t) => Math.sin((t * Math.PI) / 2);\n/** Accelerates then decelerates along a sine curve. */\nexport const easeInOutSine: EasingFn = (t) => -(Math.cos(Math.PI * t) - 1) / 2;\n\n/** Accelerates exponentially: barely moves at first, then rushes. */\nexport const easeInExpo: EasingFn = (t) => (t === 0 ? 0 : Math.pow(2, 10 * t - 10));\n/** Decelerates exponentially: leaps away, then creeps in. */\nexport const easeOutExpo: EasingFn = (t) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t));\n/** Exponential at both ends — a very fast middle between two\n * near-still extremes. */\nexport const easeInOutExpo: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return t < 0.5\n ? Math.pow(2, 20 * t - 10) / 2\n : (2 - Math.pow(2, -20 * t + 10)) / 2;\n};\n\n/** Accelerates along a circular arc: slow start, abrupt arrival. */\nexport const easeInCirc: EasingFn = (t) => 1 - Math.sqrt(1 - t * t);\n/** Decelerates along a circular arc: abrupt start, slow arrival. */\nexport const easeOutCirc: EasingFn = (t) => Math.sqrt(1 - Math.pow(t - 1, 2));\n/** Circular arcs at both ends. */\nexport const easeInOutCirc: EasingFn = (t) =>\n t < 0.5\n ? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2\n : (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;\n\n// --- Overshoot / oscillate / decay (Penner's named curves).\n// Constants are the well-known defaults; a future iteration could expose\n// per-call tuning (stiffness on back, amplitude/period on elastic).\n\nconst C1 = 1.70158; // back overshoot\nconst C2 = C1 * 1.525; // back inOut\nconst C3 = C1 + 1;\nconst C4 = (2 * Math.PI) / 3; // elastic in/out\nconst C5 = (2 * Math.PI) / 4.5;\n\n/** Pulls back past the start before moving forward. Overshoots below 0. */\nexport const easeInBack: EasingFn = (t) => C3 * t * t * t - C1 * t * t;\n/** Overshoots the target, then settles back onto it. Exceeds 1. */\nexport const easeOutBack: EasingFn = (t) =>\n 1 + C3 * Math.pow(t - 1, 3) + C1 * Math.pow(t - 1, 2);\n/** Overshoots at both ends. Leaves the 0–1 range on each side. */\nexport const easeInOutBack: EasingFn = (t) =>\n t < 0.5\n ? (Math.pow(2 * t, 2) * ((C2 + 1) * 2 * t - C2)) / 2\n : (Math.pow(2 * t - 2, 2) * ((C2 + 1) * (2 * t - 2) + C2) + 2) / 2;\n\n/** Oscillates around the start with growing amplitude, then snaps away. */\nexport const easeInElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * C4);\n};\n/** Springs past the target and wobbles into it. Exceeds 1. */\nexport const easeOutElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * C4) + 1;\n};\n/** Wobbles at both ends. Leaves the 0–1 range on each side. */\nexport const easeInOutElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return t < 0.5\n ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * C5)) / 2\n : (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * C5)) / 2 + 1;\n};\n\n/** Lands on the target and bounces, in hops of decreasing height. */\nexport const easeOutBounce: EasingFn = (t) => {\n const n1 = 7.5625;\n const d1 = 2.75;\n if (t < 1 / d1) return n1 * t * t;\n if (t < 2 / d1) { t -= 1.5 / d1; return n1 * t * t + 0.75; }\n if (t < 2.5 / d1) { t -= 2.25 / d1; return n1 * t * t + 0.9375; }\n t -= 2.625 / d1;\n return n1 * t * t + 0.984375;\n};\n/** Bounces up to the start before departing — `easeOutBounce` reversed. */\nexport const easeInBounce: EasingFn = (t) => 1 - easeOutBounce(1 - t);\n/** Bounces at both ends. */\nexport const easeInOutBounce: EasingFn = (t) =>\n t < 0.5\n ? (1 - easeOutBounce(1 - 2 * t)) / 2\n : (1 + easeOutBounce(2 * t - 1)) / 2;\n\n// --- Backwards-compat aliases. Pre-library callers asked for `easeIn`/\n// `easeOut`/`easeInOut`; those resolve to the quadratic curve.\n/** Alias for `easeInQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeIn = easeInQuad;\n/** Alias for `easeOutQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeOut = easeOutQuad;\n/** Alias for `easeInOutQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeInOut = easeInOutQuad;\n\n/** All easings in one bag — useful for demos / pickers. */\nexport const EASINGS = {\n linear,\n easeInQuad, easeOutQuad, easeInOutQuad,\n easeInCubic, easeOutCubic, easeInOutCubic,\n easeInQuart, easeOutQuart, easeInOutQuart,\n easeInQuint, easeOutQuint, easeInOutQuint,\n easeInSine, easeOutSine, easeInOutSine,\n easeInExpo, easeOutExpo, easeInOutExpo,\n easeInCirc, easeOutCirc, easeInOutCirc,\n easeInBack, easeOutBack, easeInOutBack,\n easeInElastic, easeOutElastic, easeInOutElastic,\n easeInBounce, easeOutBounce, easeInOutBounce,\n} as const;\n\n/** The name of one of the built-in easing curves. */\nexport type EasingName = keyof typeof EASINGS;\n\n/** Named spring tunings, from softest to firmest. Springs settle on a target\n * rather than running for a fixed duration, so these are an alternative to an\n * easing curve, not a modifier on one. */\nexport const SPRING_PRESETS: Record<SpringPresetName, SpringPreset> = {\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n wobbly: { stiffness: 180, damping: 12, mass: 1 },\n stiff: { stiffness: 210, damping: 20, mass: 1 },\n slow: { stiffness: 80, damping: 20, mass: 1 },\n};\n","import { EASINGS, type EasingFn, type EasingName } from './easings';\n\n/** Cubic-bezier control points, CSS `cubic-bezier()` order. The curve's two\n * endpoints are implicit at (0,0) and (1,1). */\nexport interface BezierEasing {\n /** `readonly` so an `as const` preset is assignable; nothing ever writes it. */\n bezier: readonly [number, number, number, number];\n}\n\n/** An easing curve as a value: a function, the name of a built-in, or control\n * points. Anything an editor has to name, show or serialize must not be a bare\n * function, which is why the union exists. */\nexport type EasingSpec = EasingFn | EasingName | BezierEasing;\n\nconst NEWTON_ITERATIONS = 8;\nconst NEWTON_MIN_SLOPE = 1e-3;\nconst SUBDIVISION_EPSILON = 1e-7;\nconst SUBDIVISION_MAX = 12;\n\nfunction bezierAt(t: number, a1: number, a2: number): number {\n const c = 3 * a1;\n const b = 3 * (a2 - a1) - c;\n const a = 1 - c - b;\n return ((a * t + b) * t + c) * t;\n}\n\nfunction bezierSlope(t: number, a1: number, a2: number): number {\n const c = 3 * a1;\n const b = 3 * (a2 - a1) - c;\n const a = 1 - c - b;\n return (3 * a * t + 2 * b) * t + c;\n}\n\n/** Solve for the bezier parameter that puts the curve at `x`. Newton-Raphson\n * where the slope allows it, bisection where it does not — the standard\n * approach, and the one browsers use for `cubic-bezier()`. */\nfunction solveForX(x: number, x1: number, x2: number): number {\n let t = x;\n for (let i = 0; i < NEWTON_ITERATIONS; i++) {\n const slope = bezierSlope(t, x1, x2);\n if (slope < NEWTON_MIN_SLOPE) break;\n t -= (bezierAt(t, x1, x2) - x) / slope;\n }\n let lo = 0;\n let hi = 1;\n t = Math.min(1, Math.max(0, t));\n for (let i = 0; i < SUBDIVISION_MAX; i++) {\n const err = bezierAt(t, x1, x2) - x;\n if (Math.abs(err) < SUBDIVISION_EPSILON) return t;\n if (err > 0) hi = t; else lo = t;\n t = (lo + hi) / 2;\n }\n return t;\n}\n\n/** Build the easing curve for four cubic-bezier control points. `x1`/`x2` are\n * clamped to [0,1] — CSS `cubic-bezier()`'s constraint for a monotone x(t),\n * which both `solveForX` root-finders assume. `y1`/`y2` are unclamped: an\n * overshoot easing (back, elastic) needs them outside 0..1. */\nexport function cubicBezierEasing(\n x1: number, y1: number, x2: number, y2: number,\n): EasingFn {\n const cx1 = Math.min(1, Math.max(0, x1));\n const cx2 = Math.min(1, Math.max(0, x2));\n return (t) => {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n return bezierAt(solveForX(t, cx1, cx2), y1, y2);\n };\n}\n\n/** Memoized so two equal specs resolve to one function, not a fresh solver per call. */\nconst bezierCache = new Map<string, EasingFn>();\nconst BEZIER_CACHE_LIMIT = 256;\n\nfunction isBezier(spec: EasingSpec): spec is BezierEasing {\n return typeof spec === 'object' && spec !== null && 'bezier' in spec;\n}\n\n/** Resolve a spec to the function that shapes progress. `undefined` is linear. */\nexport function resolveEasing(spec?: EasingSpec): EasingFn {\n if (spec === undefined) return EASINGS.linear;\n if (typeof spec === 'function') return spec;\n if (typeof spec === 'string') {\n const fn = EASINGS[spec];\n if (!fn) throw new Error(`resolveEasing: unknown easing name \"${spec}\"`);\n return fn;\n }\n if (isBezier(spec)) {\n const [x1, y1, x2, y2] = spec.bezier;\n const key = `${x1},${y1},${x2},${y2}`;\n let fn = bezierCache.get(key);\n if (!fn) {\n fn = cubicBezierEasing(x1, y1, x2, y2);\n // A handle being dragged resolves a new curve every pointer move.\n if (bezierCache.size >= BEZIER_CACHE_LIMIT) bezierCache.delete(bezierCache.keys().next().value!);\n bezierCache.set(key, fn);\n }\n return fn;\n }\n throw new Error('resolveEasing: unrecognized easing spec');\n}\n","/**\n * Geometric mean of a per-axis scale's magnitudes, so a flipped (negative)\n * axis counts by its size.\n *\n * **Not for hit-testing.** A screen-pixel length is not one world distance\n * under non-uniform zoom, and collapsing it to a scalar makes a pickable\n * region too generous on one axis and too mean on the other. Use `pxExtent`\n * for a per-axis world length, or `withinPxBox` / `withinPxRadius` to compare\n * in screen space directly. Nor for placing chrome or measuring a pick slop:\n * `standoff` and `strokeHitTest`'s `slop` work on screen.\n *\n * What legitimately remains is a stroke width for a line that is not\n * axis-aligned: the renderer resolves a `{ px }` width through this same\n * mean, so a picker reading ink widths must too.\n */\nexport function meanScale(s: { x: number; y: number }): number {\n return Math.sqrt(Math.abs(s.x * s.y));\n}\n","/**\n * The kit's single encoding of the pose-rotation convention: \"rotate about the\n * pose's unrotated AABB center by `pose.rotation` (radians).\"\n *\n * A pose may also carry a `transform` inside the rotation. `poseFrameOf`\n * (`./poseFrame`) composes the two, and is what a reader that draws, bounds,\n * or picks the node wants; this module is the angle and pivot alone.\n */\nimport { forEachSegment, pathCommandCoordCount, PATH_L, PATH_M, PATH_Z } from './commands';\nimport type { Path, PolygonPath } from './path';\n\n/** Pivot (`cx`, `cy`) and angle resolved from a pose's rotation convention. */\nexport interface PoseRotation {\n cx: number;\n cy: number;\n rotation: number;\n}\n\n/**\n * Resolve a pose's rotation transform, or `null` when the pose carries no\n * effective rotation. Non-null requires a nonzero `rotation` **and** all four\n * AABB fields (`x`, `y`, `width`, `height`) — the pivot is the unrotated AABB\n * center.\n */\nexport function poseRotationOf(pose: unknown): PoseRotation | null {\n const p = pose as Partial<{ x: number; y: number; width: number; height: number; rotation: number }>;\n if (p.rotation && p.x != null && p.y != null && p.width != null && p.height != null) {\n return { cx: p.x + p.width / 2, cy: p.y + p.height / 2, rotation: p.rotation };\n }\n return null;\n}\n\n/**\n * Rotate every coordinate of `path` about `(cx, cy)` by `rotation` radians.\n * A `rect` promotes to a four-corner polygon (axis-aligned rects can't encode\n * rotation). Returns a fresh `PolygonPath`; never mutates the input.\n */\nexport function rotatePathAround(path: Path, cx: number, cy: number, rotation: number): PolygonPath {\n if (path.kind === 'rect') {\n return rotateRectCorners(path.x, path.y, path.width, path.height, cx, cy, rotation);\n }\n return rotatePolygon(path, cx, cy, rotation);\n}\n\nfunction rotatePolygon(path: PolygonPath, cx: number, cy: number, rotation: number): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const { commands, coords } = path;\n const next = new Float32Array(coords.length);\n forEachSegment(commands, coords, (cmd, ci) => {\n for (let k = 0, len = pathCommandCoordCount(cmd); k < len; k += 2) {\n const dx = coords[ci + k] - cx;\n const dy = coords[ci + k + 1] - cy;\n next[ci + k] = cx + dx * cos - dy * sin;\n next[ci + k + 1] = cy + dx * sin + dy * cos;\n }\n });\n return { ...path, coords: next };\n}\n\nfunction rotateRectCorners(\n x: number, y: number, w: number, h: number,\n cx: number, cy: number, rotation: number,\n): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const rotate = (px: number, py: number): [number, number] => {\n const dx = px - cx;\n const dy = py - cy;\n return [cx + dx * cos - dy * sin, cy + dx * sin + dy * cos];\n };\n const [x0, y0] = rotate(x, y);\n const [x1, y1] = rotate(x + w, y);\n const [x2, y2] = rotate(x + w, y + h);\n const [x3, y3] = rotate(x, y + h);\n const commands = new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]);\n const coords = new Float32Array([x0, y0, x1, y1, x2, y2, x3, y3]);\n return { kind: 'polygon', commands, coords, fillRule: 'nonzero' };\n}\n","/**\n * The one composition of a box pose into the matrix that carries its own\n * frame to its parent's: the rotation convention of `poseRotationOf`, and the\n * pose's residual `transform` inside it. Painting, culling, silhouettes, and\n * picking all read a pose through `poseFrameOf` so they agree on where the\n * node is.\n */\nimport { invert, multiply, rotateAboutPoint, type Affine } from './affine';\nimport type { Path } from './path';\nimport { transformPath } from './paths/transformPath';\nimport { poseRotationOf, rotatePathAround } from './poseRotation';\n\n/**\n * The linear part of a box pose that its box, rotation, and flips cannot\n * hold: a skew, or a scale that differs by axis. `[a, b, c, d]` in\n * `Affine` order (`x' = a·x + c·y`, `y' = b·x + d·y`), applied about the\n * box center to what the node draws in its unrotated box, before the\n * rotation. Absent is the identity.\n */\nexport type PoseLinear = readonly [a: number, b: number, c: number, d: number];\n\n/**\n * Axis-aligned rectangle in world space. The optional `rotation` (radians,\n * around the AABB center) and `transform` (inside it, about the same center)\n * let chrome carry the frame a box is drawn in without a parallel type;\n * `poseFrameOf` composes the two. routing and core call it `Bounds`.\n */\nexport interface FramedBox {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n transform?: PoseLinear;\n}\n\n/** `transform` when it changes anything, `null` for absent or the identity. */\nexport function poseLinearOf(pose: unknown): PoseLinear | null {\n const t = (pose as { transform?: unknown } | null | undefined)?.transform;\n if (!Array.isArray(t) || t.length !== 4) return null;\n if (t[0] === 1 && t[1] === 0 && t[2] === 0 && t[3] === 1) return null;\n return t as unknown as PoseLinear;\n}\n\n/**\n * The matrix taking a point in the pose's own unrotated box frame to where\n * the node draws it: `rotate(rotation) · transform`, about the box center.\n * `null` when the pose has neither, or is not a box, so a caller can skip\n * the step.\n */\nexport function poseFrameOf(pose: unknown): Affine | null {\n const p = pose as Partial<FramedBox> | null | undefined;\n if (!p || p.x == null || p.y == null || p.width == null || p.height == null) return null;\n const linear = poseLinearOf(p);\n if (!p.rotation && !linear) return null;\n const cx = p.x + p.width / 2;\n const cy = p.y + p.height / 2;\n if (!linear) return rotateAboutPoint(cx, cy, p.rotation as number);\n const [a, b, c, d] = linear;\n const about: Affine = [a, b, c, d, cx - (a * cx + c * cy), cy - (b * cx + d * cy)];\n return p.rotation ? multiply(rotateAboutPoint(cx, cy, p.rotation), about) : about;\n}\n\n/**\n * The inverse of {@link poseFrameOf}: where a parent-frame point falls in the\n * pose's unrotated box frame. `null` when there is no frame to undo, or when\n * the `transform` is singular and nothing maps back.\n */\nexport function poseFrameInverseOf(pose: unknown): Affine | null {\n if (!poseLinearOf(pose)) {\n // The same pivot turned back: exact, where inverting the matrix is not.\n const r = poseRotationOf(pose);\n return r && rotateAboutPoint(r.cx, r.cy, -r.rotation);\n }\n const frame = poseFrameOf(pose);\n return frame && invert(frame);\n}\n\n/** `path`, given in the pose's unrotated box frame, as the node draws it. */\nexport function pathThroughPoseFrame(path: Path, pose: unknown): Path {\n if (poseLinearOf(pose)) {\n const frame = poseFrameOf(pose);\n return frame ? transformPath(path, frame) : path;\n }\n const r = poseRotationOf(pose);\n return r ? rotatePathAround(path, r.cx, r.cy, r.rotation) : path;\n}\n","import type { Scale2 } from '../pxExtent';\nimport type { AnchorSet } from './anchorEdits';\nimport type { Point } from './cubicMath';\n\n/**\n * Flat indices of every anchor a round brush covers as it moves from `from` to\n * `to`: those within `radiusPx` of that segment, measured on screen. A dab is a\n * segment of zero length. `scale` is the view's, so the brush stays round on\n * screen under non-uniform zoom; omitted, one unit is one pixel.\n */\nexport function anchorsUnderBrush(\n set: AnchorSet,\n from: Point,\n to: Point,\n opts: { radiusPx: number; scale?: Scale2 },\n): number[] {\n const scale = opts.scale ?? { x: 1, y: 1 };\n const ax = from.x * scale.x, ay = from.y * scale.y;\n const dx = to.x * scale.x - ax, dy = to.y * scale.y - ay;\n const len2 = dx * dx + dy * dy;\n const r2 = opts.radiusPx * opts.radiusPx;\n const hits: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n const px = a.x * scale.x - ax, py = a.y * scale.y - ay;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, (px * dx + py * dy) / len2));\n const ex = px - t * dx, ey = py - t * dy;\n if (ex * ex + ey * ey <= r2) hits.push(flat);\n flat++;\n }\n }\n return hits;\n}\n","import { applyToPoint, type Affine } from '../affine';\nimport { anchorAt, anchorCount, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\nimport type { Point } from './cubicMath';\n\ntype Side = 'in' | 'out';\n\n/**\n * How a path maps onto itself under one transform `m`: `partners[i]` is the\n * flat index of the anchor that anchor `i` lands on, and `flips[i]` whether\n * its in-handle lands on that anchor's out-handle — a mirror reverses which\n * way a path runs, a rotation does not. An anchor `m` fixes is its own\n * partner.\n */\nexport interface AnchorSymmetry {\n readonly m: Affine;\n readonly partners: readonly number[];\n readonly flips: readonly boolean[];\n}\n\nfunction near(a: Point | undefined, b: Point | undefined, tol: number): boolean {\n if (!a || !b) return a === b;\n return Math.abs(a.x - b.x) <= tol && Math.abs(a.y - b.y) <= tol;\n}\n\nfunction image(m: Affine, p: Point): Point;\nfunction image(m: Affine, p: Point | undefined): Point | undefined;\nfunction image(m: Affine, p: Point | undefined): Point | undefined {\n if (!p) return undefined;\n const [x, y] = applyToPoint(m, p.x, p.y);\n return { x, y };\n}\n\nfunction linear(m: Affine, d: Point): Point {\n return { x: m[0] * d.x + m[2] * d.y, y: m[1] * d.x + m[3] * d.y };\n}\n\n/** How `a` lands on `b` under `m`: `false` with the handles side for side,\n * `true` with them swapped, `null` when it is not `b`'s image. Side for side\n * is tried first, so an anchor with no handles is never a flip. */\nfunction landing(m: Affine, a: PenAnchor, b: PenAnchor, tol: number): boolean | null {\n if (!near(image(m, a), b, tol)) return null;\n const i = image(m, a.inHandle);\n const o = image(m, a.outHandle);\n if (near(i, b.inHandle, tol) && near(o, b.outHandle, tol)) return false;\n if (near(i, b.outHandle, tol) && near(o, b.inHandle, tol)) return true;\n return null;\n}\n\n/**\n * The pairing that makes `set` its own image under `m`, or `null` when it is\n * not one: every anchor, handles included, must land on a distinct anchor\n * within `tolerance` on each axis.\n */\nexport function anchorSymmetry(set: AnchorSet, m: Affine, tolerance = 1e-6): AnchorSymmetry | null {\n const n = anchorCount(set);\n const partners: number[] = [];\n const flips: boolean[] = [];\n const taken = new Set<number>();\n for (let i = 0; i < n; i++) {\n const a = anchorAt(set, i)!;\n let found = -1;\n let flip = false;\n for (let j = 0; j < n && found < 0; j++) {\n if (taken.has(j)) continue;\n const how = landing(m, a, anchorAt(set, j)!, tolerance);\n if (how === null) continue;\n found = j;\n flip = how;\n }\n if (found < 0) return null;\n taken.add(found);\n partners.push(found);\n flips.push(flip);\n }\n return { m, partners, flips };\n}\n\n/** Every transform in `group` that `set` is its own image under, paired. */\nexport function anchorSymmetries(set: AnchorSet, group: readonly Affine[], tolerance = 1e-6): AnchorSymmetry[] {\n return group\n .map((m) => anchorSymmetry(set, m, tolerance))\n .filter((s): s is AnchorSymmetry => s !== null);\n}\n\n/**\n * `d` averaged over every transform in `syms` that fixes what `fixes` names,\n * and the identity: the part of the move that keeps it where those transforms\n * hold it. Exact when `syms` is a group less its identity — an anchor on a\n * mirror axis slides along it, an anchor at a center of rotation stays put.\n */\nfunction averaged(d: Point, syms: readonly AnchorSymmetry[], fixes: (s: AnchorSymmetry) => boolean, apply: (m: Affine, p: Point) => Point): Point {\n let x = d.x;\n let y = d.y;\n let k = 1;\n for (const s of syms) {\n if (!fixes(s)) continue;\n const p = apply(s.m, d);\n x += p.x;\n y += p.y;\n k++;\n }\n return { x: x / k, y: y / k };\n}\n\n/**\n * Translate the anchors `flats` by `(dx, dy)` the way `translateAnchorBy`\n * does, and every image of each under `syms` by the transformed delta, so a\n * path that was its own image under each of them still is. `syms` should be\n * the whole symmetry group less its identity, as `anchorSymmetries` gives it\n * for a group; with a part of one, the anchors it fixes are only partly held.\n * An anchor that is itself being dragged moves as dragged.\n */\nexport function translateAnchorsSymmetric(\n set: AnchorSet,\n flats: readonly number[],\n dx: number,\n dy: number,\n syms: readonly AnchorSymmetry[],\n): boolean {\n const dragged = new Set(flats);\n const moves = new Map<number, Point>();\n for (const flat of flats) {\n const d = averaged({ x: dx, y: dy }, syms, (s) => s.partners[flat] === flat, linear);\n moves.set(flat, d);\n for (const s of syms) {\n const j = s.partners[flat];\n if (j === undefined || dragged.has(j) || moves.has(j)) continue;\n moves.set(j, linear(s.m, d));\n }\n }\n let changed = false;\n for (const [flat, d] of moves) changed = translateAnchorBy(set, flat, d.x, d.y) || changed;\n return changed;\n}\n\nconst other = (side: Side): Side => (side === 'in' ? 'out' : 'in');\n\n/**\n * Move one handle to `(toX, toY)` and every image of it under `syms` to the\n * image of that point, so a path that was its own image under each of them\n * still is. A handle a transform maps onto itself keeps to where that\n * transform allows; one mapped onto its own anchor's opposite handle drives\n * that handle.\n *\n * Otherwise a smooth anchor keeps the opposite handle opposite, as\n * `moveHandleTo` does, unless `breakSmoothness`, and that handle's images\n * follow it. Every handle is written once, from its target, so no anchor\n * re-aims a handle another image already placed.\n */\nexport function moveHandleSymmetric(\n set: AnchorSet,\n flat: number,\n side: 'in' | 'out',\n toX: number,\n toY: number,\n breakSmoothness: boolean,\n syms: readonly AnchorSymmetry[],\n): boolean {\n const a = anchorAt(set, flat);\n if (!a || !(side === 'in' ? a.inHandle : a.outHandle)) return false;\n const sideUnder = (s: AnchorSymmetry, sd: Side): Side => (s.flips[flat] ? other(sd) : sd);\n const fixesHandle = (s: AnchorSymmetry) => s.partners[flat] === flat && sideUnder(s, side) === side;\n const to = averaged({ x: toX, y: toY }, syms, fixesHandle, image);\n\n const targets = new Map<string, { flat: number; side: Side; to: Point }>();\n const put = (f: number, sd: Side, p: Point): void => {\n const key = `${f}:${sd}`;\n if (!targets.has(key)) targets.set(key, { flat: f, side: sd, to: p });\n };\n put(flat, side, to);\n for (const s of syms) put(s.partners[flat], sideUnder(s, side), image(s.m, to));\n\n const opposite = side === 'in' ? a.outHandle : a.inHandle;\n const drivenBySymmetry = targets.has(`${flat}:${other(side)}`);\n if (!drivenBySymmetry && !breakSmoothness && opposite && isAnchorSmooth(a)) {\n const opp = { x: 2 * a.x - to.x, y: 2 * a.y - to.y };\n put(flat, other(side), opp);\n for (const s of syms) put(s.partners[flat], sideUnder(s, other(side)), image(s.m, opp));\n }\n\n for (const t of targets.values()) {\n const b = anchorAt(set, t.flat);\n if (!b) continue;\n if (t.side === 'in') b.inHandle = t.to;\n else b.outHandle = t.to;\n }\n return true;\n}\n","import type { AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\n\n/** Where on a segment a bend is held, as `segmentAt` reports it. */\nexport interface BendGrip {\n sub: number;\n segIdx: number;\n /** Curve parameter of the held point. */\n t: number;\n}\n\n/** The held point's parameter is kept this far from either end, where moving\n * it by a pixel would throw a handle out by hundreds. */\nconst T_MARGIN = 0.05;\n\n/**\n * Bend one segment so the point held at `grip.t` moves by `(dx, dy)`, by\n * moving its two control handles: each by an amount weighted toward the end it\n * belongs to, together exactly enough to carry the held point along. A straight\n * segment becomes a curve. Where an end anchor was smooth, its other handle\n * turns to stay in line, keeping its length, so the neighboring segment bends\n * with it rather than kinking.\n *\n * Returns false when the segment doesn't exist.\n */\nexport function bendSegment(set: AnchorSet, grip: BendGrip, dx: number, dy: number): boolean {\n const ends = segmentEnds(set.anchors, set.closed, grip.sub, grip.segIdx);\n if (!ends) return false;\n const { a, b } = ends;\n const aSmooth = isAnchorSmooth(a);\n const bSmooth = isAnchorSmooth(b);\n const straight = isStraightSegment(a, b);\n const p1 = a.outHandle ?? (straight ? lerp(a, b, 1 / 3) : { x: a.x, y: a.y });\n const p2 = b.inHandle ?? (straight ? lerp(a, b, 2 / 3) : { x: b.x, y: b.y });\n\n const t = Math.min(1 - T_MARGIN, Math.max(T_MARGIN, grip.t));\n const u = 1 - t;\n // Moving p1 by w1·d and p2 by w2·d moves the point at t by\n // (3u²t·w1 + 3ut²·w2)·d. With w1 = k·u and w2 = k·t, this k makes it exactly d.\n const k = 1 / (3 * t * u * (u * u + t * t));\n a.outHandle = { x: p1.x + k * u * dx, y: p1.y + k * u * dy };\n b.inHandle = { x: p2.x + k * t * dx, y: p2.y + k * t * dy };\n\n if (aSmooth) a.inHandle = alignedOpposite(a, a.outHandle, a.inHandle!);\n if (bSmooth) b.outHandle = alignedOpposite(b, b.inHandle, b.outHandle!);\n return true;\n}\n\nfunction lerp(a: PenAnchor, b: PenAnchor, f: number): { x: number; y: number } {\n return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };\n}\n\n/** `other` turned to point directly away from `moved` through the anchor, at\n * its own length. */\nfunction alignedOpposite(\n anchor: PenAnchor,\n moved: { x: number; y: number },\n other: { x: number; y: number },\n): { x: number; y: number } {\n const mx = moved.x - anchor.x;\n const my = moved.y - anchor.y;\n const len = Math.hypot(mx, my);\n if (len === 0) return other;\n const keep = Math.hypot(other.x - anchor.x, other.y - anchor.y);\n return { x: anchor.x - (mx / len) * keep, y: anchor.y - (my / len) * keep };\n}\n","/**\n * `smudgePath` — one dab of a smudge brush: the outline under a round brush\n * moved along the brush's motion, most at its center and not at all at its rim.\n */\nimport type { PolygonPath } from '../path';\nimport { editAnchorSet, insertAnchorOnSegment, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport { segmentEnds, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\n/** Options for {@link smudgePath}. */\nexport interface SmudgePathOptions {\n /** The brush's center before this dab's motion. */\n center: Point;\n /** How far the brush moved. */\n delta: Point;\n /** The brush's radius, in the path's units. */\n radius: number;\n /** How much of `delta` a point under the brush's center moves: `1` all of it. Default 1. */\n strength?: number;\n /**\n * The longest a segment under the brush may be before an anchor is added at its\n * middle, in the path's units, so the brush has points to move where it needs\n * them. Default a third of `radius`; `Infinity` adds none.\n */\n detail?: number;\n}\n\n/** Samples along a segment when deciding whether it passes under the brush. */\nconst PROBES = 12;\n/** Most anchors a single dab may add. */\nconst MAX_ADDED = 512;\n\n/**\n * `path` with the outline under the brush pushed along `delta`. A point at distance\n * `d` from `center` moves by `delta × strength × (1 − (d/radius)²)²`, and an anchor's\n * handles move with it, so a smooth anchor stays smooth. First, every segment that\n * passes under the brush and is longer than `detail` is split at its middle until it\n * is not, so a long straight edge bends where the brush meets it. Returns `path`\n * itself when nothing is under the brush.\n */\nexport function smudgePath(path: PolygonPath, opts: SmudgePathOptions): PolygonPath {\n const { center, delta, radius } = opts;\n const strength = opts.strength ?? 1;\n if (!(radius > 0) || strength === 0 || (delta.x === 0 && delta.y === 0)) return path;\n const detail = opts.detail ?? radius / 3;\n return editAnchorSet(path, (set) => {\n refine(set, center, radius, detail);\n let touched = false;\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n const w = weight(a, center, radius) * strength;\n if (w !== 0) {\n touched = true;\n translateAnchorBy(set, flat, delta.x * w, delta.y * w);\n }\n flat++;\n }\n }\n return touched;\n }) ?? path;\n}\n\n/** The brush's falloff at `p`: 1 at its center, 0 at its rim and beyond. */\nfunction weight(p: Point, c: Point, radius: number): number {\n const u2 = ((p.x - c.x) ** 2 + (p.y - c.y) ** 2) / (radius * radius);\n return u2 >= 1 ? 0 : (1 - u2) ** 2;\n}\n\n/** Split the segments under the brush at their middles until none is longer than\n * `detail`, adding at most {@link MAX_ADDED} anchors. */\nfunction refine(set: AnchorSet, c: Point, radius: number, detail: number): void {\n if (!Number.isFinite(detail) || detail <= 0) return;\n let added = 0;\n for (let sub = 0; sub < set.anchors.length; sub++) {\n // Back to front, so a split does not shift the segments still to visit; a\n // split segment's first half is visited again at the same index.\n for (let seg = set.anchors[sub].length - 1; seg >= 0 && added < MAX_ADDED; seg--) {\n const ends = segmentEnds(set.anchors, set.closed, sub, seg);\n if (!ends || controlLength(ends.a, ends.b) <= detail || !underBrush(ends.a, ends.b, c, radius)) continue;\n insertAnchorOnSegment(set, { sub, segIdx: seg, t: 0.5 });\n added++;\n seg += 2;\n }\n }\n}\n\nconst controls = (a: PenAnchor, b: PenAnchor): [Point, Point, Point, Point] =>\n [a, a.outHandle ?? a, b.inHandle ?? b, b];\n\n/** The length of the segment's control polygon, which is never shorter than the segment. */\nfunction controlLength(a: PenAnchor, b: PenAnchor): number {\n const [p0, p1, p2, p3] = controls(a, b);\n return Math.hypot(p1.x - p0.x, p1.y - p0.y) + Math.hypot(p2.x - p1.x, p2.y - p1.y)\n + Math.hypot(p3.x - p2.x, p3.y - p2.y);\n}\n\n/** Whether any of the segment from `a` to `b` lies under the brush. */\nfunction underBrush(a: PenAnchor, b: PenAnchor, c: Point, radius: number): boolean {\n const [p0, p1, p2, p3] = controls(a, b);\n for (let k = 0; k <= PROBES; k++) {\n const p = cubicPointAt(p0, p1, p2, p3, k / PROBES);\n if ((p.x - c.x) ** 2 + (p.y - c.y) ** 2 < radius * radius) return true;\n }\n return false;\n}\n","import { anchorAt, locateAnchor, type AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\nimport type { Point } from './cubicMath';\n\n/**\n * Collapse the handles of the anchors at `flatIndexes` onto their anchors,\n * leaving sharp corners. A segment whose ends both lose their handles turns\n * straight.\n *\n * Returns false when every handle was already on its anchor. A segment that\n * stays curved because its far end keeps a handle still encodes a control at\n * this end, so it decodes as a handle sitting on the anchor: retracted.\n */\nexport function retractHandles(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const a = anchorAt(set, flat);\n if (!a) continue;\n if (a.inHandle) { changed = changed || !same(a.inHandle, a); delete a.inHandle; }\n if (a.outHandle) { changed = changed || !same(a.outHandle, a); delete a.outHandle; }\n }\n return changed;\n}\n\n/**\n * Give each anchor at `flatIndexes` two handles of equal length pointing in\n * opposite directions, so the curve passes through it smoothly. The shared\n * direction splits the difference between the two handles' own directions,\n * and the shared length is their mean; an anchor with one handle mirrors it.\n *\n * Skipped: an anchor with no handles, and the ends of an open subpath, which\n * have only one segment to shape. Returns false when nothing changed.\n */\nexport function makeHandlesSymmetric(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const sub = set.anchors[loc.sub];\n const isEnd = !set.closed[loc.sub] && (loc.idx === 0 || loc.idx === sub.length - 1);\n if (isEnd) continue;\n changed = symmetrize(sub[loc.idx]) || changed;\n }\n return changed;\n}\n\nfunction symmetrize(a: PenAnchor): boolean {\n const out = a.outHandle ? offset(a, a.outHandle) : null;\n // The in-handle turned around, so both vectors point along the outgoing side.\n const inFlipped = a.inHandle ? scale(offset(a, a.inHandle), -1) : null;\n const outLen = out ? Math.hypot(out.x, out.y) : 0;\n const inLen = inFlipped ? Math.hypot(inFlipped.x, inFlipped.y) : 0;\n if (outLen === 0 && inLen === 0) return false;\n\n let dir: Point;\n let len: number;\n if (outLen > 0 && inLen > 0) {\n const sum = { x: out!.x / outLen + inFlipped!.x / inLen, y: out!.y / outLen + inFlipped!.y / inLen };\n const sumLen = Math.hypot(sum.x, sum.y);\n // Handles pointing the same way leave no bisector; keep the out-handle's line.\n dir = sumLen > 1e-9 ? scale(sum, 1 / sumLen) : scale(out!, 1 / outLen);\n len = (outLen + inLen) / 2;\n } else if (outLen > 0) {\n dir = scale(out!, 1 / outLen);\n len = outLen;\n } else {\n dir = scale(inFlipped!, 1 / inLen);\n len = inLen;\n }\n const nextOut = { x: a.x + dir.x * len, y: a.y + dir.y * len };\n const nextIn = { x: a.x - dir.x * len, y: a.y - dir.y * len };\n if (same(a.outHandle, nextOut) && same(a.inHandle, nextIn)) return false;\n a.outHandle = nextOut;\n a.inHandle = nextIn;\n return true;\n}\n\n/**\n * Where a handle lands when dragged toward `to` but held to its current\n * direction from `anchor`: `to` projected onto that ray. The length never\n * goes below zero, so the handle can shrink onto the anchor but not flip\n * through it. A handle already sitting on its anchor has no direction to\n * keep and follows `to` freely.\n */\nexport function handleAlongItsAngle(anchor: Point, handle: Point, to: Point): Point {\n const d = offset(anchor, handle);\n const len = Math.hypot(d.x, d.y);\n if (len === 0) return { x: to.x, y: to.y };\n const ux = d.x / len;\n const uy = d.y / len;\n const along = Math.max(0, (to.x - anchor.x) * ux + (to.y - anchor.y) * uy);\n return { x: anchor.x + ux * along, y: anchor.y + uy * along };\n}\n\n/**\n * Where a handle lands when dragged toward `to` but held to its current\n * length from `anchor`: on the circle of that length, aimed at `to`. A `to`\n * on the anchor itself gives no direction, and leaves the handle where it is.\n */\nexport function handleAtItsLength(anchor: Point, handle: Point, to: Point): Point {\n const len = Math.hypot(handle.x - anchor.x, handle.y - anchor.y);\n const d = offset(anchor, to);\n const dl = Math.hypot(d.x, d.y);\n if (dl === 0) return { x: handle.x, y: handle.y };\n return { x: anchor.x + (d.x / dl) * len, y: anchor.y + (d.y / dl) * len };\n}\n\nfunction offset(from: Point, to: Point): Point {\n return { x: to.x - from.x, y: to.y - from.y };\n}\n\nfunction scale(p: Point, k: number): Point {\n return { x: p.x * k, y: p.y * k };\n}\n\nfunction same(p: Point | undefined, q: Point): boolean {\n return !!p && Math.abs(p.x - q.x) < 1e-9 && Math.abs(p.y - q.y) < 1e-9;\n}\n","/**\n * Soft selection over an anchor set: how strongly an edit to some anchors\n * carries to the anchors near them, by distance measured along the path.\n *\n * Distance is arc length along the drawn curve, not a straight line, so two\n * anchors that sit close across a gap in a shape are as far apart as the\n * path between them. A `scale` measures it in screen pixels under a view's\n * zoom, per axis.\n */\nimport type { AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\n/** How influence fades from 1 at a selected anchor to 0 at the radius:\n * `smooth` eases out and in, `linear` falls evenly, `sharp` drops fast and\n * tails off. */\nexport type SoftFalloff = 'smooth' | 'linear' | 'sharp';\n\n/**\n * The weight `falloff` gives a point `distance` from the selection, for a\n * radius of `radius`: 1 at distance 0, 0 at the radius and beyond.\n */\nexport function softFalloff(falloff: SoftFalloff, distance: number, radius: number): number {\n if (!(radius > 0) || distance >= radius) return 0;\n if (distance <= 0) return 1;\n const u = distance / radius;\n switch (falloff) {\n case 'linear': return 1 - u;\n case 'sharp': return (1 - u) * (1 - u);\n case 'smooth': return 0.5 + 0.5 * Math.cos(Math.PI * u);\n }\n}\n\n/** Arc length along one segment, sampled at evenly spaced curve parameters. */\nexport interface SegmentMeasure {\n /** Arc length from the subpath's start to each sample; sample `i` is at\n * parameter `i / (lengths.length - 1)`. */\n lengths: Float64Array;\n}\n\n/** Arc lengths along one subpath, as {@link measureAnchorPath} takes them. */\nexport interface AnchorSubpathMeasure {\n closed: boolean;\n /** Flat index of the subpath's first anchor. */\n first: number;\n /** Arc length from the subpath's start to each anchor. */\n at: Float64Array;\n /** Total length, the closing segment included on a closed subpath. */\n length: number;\n /** Segment `i` runs from anchor `i` to anchor `i + 1`, wrapping on a closed subpath. */\n segments: SegmentMeasure[];\n}\n\n/** Arc lengths along every subpath of an anchor set, as\n * {@link measureAnchorPath} takes them. Read it with\n * {@link softSelectionWeights} and {@link softSelectionBand}. */\nexport interface AnchorPathMeasure {\n readonly subpaths: readonly AnchorSubpathMeasure[];\n}\n\n/** Options for {@link measureAnchorPath}. */\nexport interface MeasureAnchorPathOptions {\n /** Per-axis factor applied before measuring — a view's scale, to measure in\n * screen pixels. Default 1 on both axes. */\n scale?: { x: number; y: number };\n /** Samples taken along each curved segment. Default 24. */\n samples?: number;\n}\n\n/** The control points of segment `i` of `sub`, or null past its last segment. */\nfunction segmentControls(sub: readonly PenAnchor[], closed: boolean, i: number): [Point, Point, Point, Point] | null {\n const n = sub.length;\n if (i >= n - 1 && !(closed && i === n - 1)) return null;\n const a = sub[i]!;\n const b = sub[(i + 1) % n]!;\n return [a, a.outHandle ?? a, b.inHandle ?? b, b];\n}\n\nfunction isStraight(c: readonly Point[]): boolean {\n return c[1] === c[0] && c[2] === c[3];\n}\n\n/** Measure the arc length along every subpath of `set`. */\nexport function measureAnchorPath(set: AnchorSet, opts: MeasureAnchorPathOptions = {}): AnchorPathMeasure {\n const sx = opts.scale?.x ?? 1;\n const sy = opts.scale?.y ?? 1;\n const samples = Math.max(2, Math.round(opts.samples ?? 24));\n const subpaths: AnchorSubpathMeasure[] = [];\n let first = 0;\n set.anchors.forEach((sub, s) => {\n const closed = set.closed[s] ?? false;\n const at = new Float64Array(sub.length);\n const segments: SegmentMeasure[] = [];\n let run = 0;\n for (let i = 0; ; i++) {\n const c = segmentControls(sub, closed, i);\n if (!c) break;\n at[i] = run;\n const steps = isStraight(c) ? 1 : samples;\n const lengths = new Float64Array(steps + 1);\n lengths[0] = run;\n let prev = c[0];\n for (let k = 1; k <= steps; k++) {\n const p = steps === 1 ? c[3] : cubicPointAt(c[0], c[1], c[2], c[3], k / steps);\n run += Math.hypot((p.x - prev.x) * sx, (p.y - prev.y) * sy);\n lengths[k] = run;\n prev = p;\n }\n segments.push({ lengths });\n }\n // An open subpath's last anchor ends the last segment.\n if (!closed && sub.length > 0) at[sub.length - 1] = run;\n subpaths.push({ closed, first, at, length: run, segments });\n first += sub.length;\n });\n return { subpaths };\n}\n\n/** Arc lengths of the selected anchors on `sub`. */\nfunction sourcesOn(sub: AnchorSubpathMeasure, selected: ReadonlySet<number>): number[] {\n const out: number[] = [];\n for (let i = 0; i < sub.at.length; i++) if (selected.has(sub.first + i)) out.push(sub.at[i]!);\n return out;\n}\n\n/** Distance along `sub` from arc length `s` to the nearest of `sources`. */\nfunction distanceTo(sub: AnchorSubpathMeasure, sources: readonly number[], s: number): number {\n let best = Infinity;\n for (const src of sources) {\n let d = Math.abs(s - src);\n if (sub.closed) d = Math.min(d, sub.length - d);\n if (d < best) best = d;\n }\n return best;\n}\n\n/**\n * How much of an edit to the `selected` anchors each anchor receives: 1 for\n * a selected anchor, the falloff of its distance along the path for one\n * within `radius` of the nearest selected anchor on its subpath. Anchors\n * that receive nothing are absent, as are anchors on a subpath with no\n * selected anchor.\n */\nexport function softSelectionWeights(\n measure: AnchorPathMeasure,\n selected: Iterable<number>,\n radius: number,\n falloff: SoftFalloff,\n): Map<number, number> {\n const sel = new Set(selected);\n const out = new Map<number, number>();\n for (const sub of measure.subpaths) {\n const sources = sourcesOn(sub, sel);\n if (sources.length === 0) continue;\n for (let i = 0; i < sub.at.length; i++) {\n const flat = sub.first + i;\n const w = sel.has(flat) ? 1 : softFalloff(falloff, distanceTo(sub, sources, sub.at[i]!), radius);\n if (w > 0) out.set(flat, w);\n }\n }\n return out;\n}\n\n/**\n * The stretches of path within `radius` of the `selected` anchors, as world\n * polylines drawn on `set`. `measure` is of the set the distances are taken\n * on — the path as it was when the edit began — and `set` the geometry to\n * draw on, which must have the same anchors. A stretch crossing the seam of a\n * closed subpath comes back as one run.\n */\nexport function softSelectionBand(\n measure: AnchorPathMeasure,\n set: AnchorSet,\n selected: Iterable<number>,\n radius: number,\n): Point[][] {\n const sel = new Set(selected);\n const runs: Point[][] = [];\n measure.subpaths.forEach((sub, s) => {\n const sources = sourcesOn(sub, sel);\n const anchors = set.anchors[s];\n if (sources.length === 0 || !anchors) return;\n const inside = (len: number) => distanceTo(sub, sources, len) <= radius;\n const subRuns: Point[][] = [];\n let current: Point[] | null = null;\n let startsAtSeam = false;\n sub.segments.forEach((seg, i) => {\n const c = segmentControls(anchors, sub.closed, i);\n if (!c) return;\n const at = (t: number): Point => (isStraight(c) ? lerp(c[0], c[3], t) : cubicPointAt(c[0], c[1], c[2], c[3], t));\n const steps = seg.lengths.length - 1;\n for (let k = 0; k <= steps; k++) {\n const len = seg.lengths[k]!;\n const t = k / steps;\n const isIn = inside(len);\n if (k === 0 && i === 0) startsAtSeam = isIn;\n if (k > 0) {\n const prevLen = seg.lengths[k - 1]!;\n const wasIn = inside(prevLen);\n if (wasIn !== isIn) {\n // The edge sits where the distance crosses `radius`, found by bisection on arc length.\n const edge = crossing(prevLen, len, wasIn, inside);\n const te = ((k - 1) + (len === prevLen ? 0 : (edge - prevLen) / (len - prevLen))) / steps;\n const p = at(te);\n if (wasIn) {\n current?.push(p);\n if (current) subRuns.push(current);\n current = null;\n } else {\n current = [p];\n }\n }\n }\n if (isIn) {\n current ??= [];\n const p = at(t);\n const last = current[current.length - 1];\n if (!last || last.x !== p.x || last.y !== p.y) current.push(p);\n }\n }\n });\n if (current) subRuns.push(current);\n // A closed subpath's last run and first run meet at its first anchor.\n if (sub.closed && startsAtSeam && subRuns.length > 1) {\n const head = subRuns.shift()!;\n subRuns[subRuns.length - 1]!.push(...head.slice(1));\n }\n runs.push(...subRuns.filter((r) => r.length >= 2));\n });\n return runs;\n}\n\nfunction crossing(a: number, b: number, aIn: boolean, inside: (s: number) => boolean): number {\n let lo = a;\n let hi = b;\n for (let i = 0; i < 24; i++) {\n const mid = (lo + hi) / 2;\n if (inside(mid) === aIn) lo = mid;\n else hi = mid;\n }\n return (lo + hi) / 2;\n}\n\nfunction lerp(a: Point, b: Point, t: number): Point {\n return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n}\n","import { flatAnchorIndex, type AnchorSet } from './anchorEdits';\nimport { isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\nimport { moveHandleSymmetric, type AnchorSymmetry } from './anchorSymmetry';\nimport type { Point } from './cubicMath';\n\n/** A curved segment's balance line: from its first handle's tip to its\n * second's, with a grip at the middle. */\nexport interface HandleBalance {\n sub: number;\n segIdx: number;\n /** Flat index of the anchor the segment starts at, which names the segment\n * the way an anchor's flat index names the anchor. */\n flat: number;\n /** Tip of the segment's first handle, the start anchor's out-handle. */\n from: Point;\n /** Tip of the segment's second handle, the end anchor's in-handle. */\n to: Point;\n /** Midway between the two tips. */\n grip: Point;\n}\n\n/**\n * The balance line of every curved segment in `set` that has both handles\n * pulled off their anchors. Dragging a line's grip scales both handles\n * together ({@link scaleSegmentHandles}), which fills the curve out toward\n * its corner or flattens it toward its chord without turning either end.\n */\nexport function handleBalances(set: AnchorSet): HandleBalance[] {\n const out: HandleBalance[] = [];\n for (let sub = 0; sub < set.anchors.length; sub++) {\n const count = set.anchors[sub].length - (set.closed[sub] ? 0 : 1);\n for (let segIdx = 0; segIdx < count; segIdx++) {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) continue;\n const { from, to } = handles;\n out.push({\n sub,\n segIdx,\n flat: flatAnchorIndex(set, sub, segIdx),\n from: { ...from },\n to: { ...to },\n grip: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 },\n });\n }\n }\n return out;\n}\n\n/** The segment's anchors and handle tips, when it is curved with both\n * handles off their anchors. */\nfunction segmentHandles(\n set: AnchorSet,\n sub: number,\n segIdx: number,\n): { a: PenAnchor; b: PenAnchor; from: Point; to: Point } | null {\n const ends = segmentEnds(set.anchors, set.closed, sub, segIdx);\n if (!ends || isStraightSegment(ends.a, ends.b)) return null;\n const { a, b } = ends;\n if (!a.outHandle || !b.inHandle) return null;\n if (length(a, a.outHandle) === 0 || length(b, b.inHandle) === 0) return null;\n return { a, b, from: a.outHandle, to: b.inHandle };\n}\n\n/**\n * Scale both handles of segment `(sub, segIdx)` by `factor`, each along its\n * own direction, so the segment keeps its end tangents. A smooth anchor at\n * either end stays smooth: its other handle points the same way as before.\n * `factor` below zero counts as zero, which retracts both handles.\n *\n * Under `syms`, as `anchorSymmetries` gives them, every image of either handle\n * moves to the image of where that handle goes, the way `moveHandleSymmetric`\n * moves a dragged handle's.\n *\n * Returns false when the segment has no balance line or nothing moved.\n */\nexport function scaleSegmentHandles(\n set: AnchorSet,\n sub: number,\n segIdx: number,\n factor: number,\n syms: readonly AnchorSymmetry[] = [],\n): boolean {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return false;\n const k = Math.max(0, factor);\n if (k === 1) return false;\n const { a, b } = handles;\n // Both targets before either write: an image of the first handle can be the second.\n const out = scaledFrom(a, a.outHandle!, k);\n const into = scaledFrom(b, b.inHandle!, k);\n const next = segIdx + 1 === set.anchors[sub].length ? 0 : segIdx + 1;\n moveHandleSymmetric(set, flatAnchorIndex(set, sub, segIdx), 'out', out.x, out.y, true, syms);\n moveHandleSymmetric(set, flatAnchorIndex(set, sub, next), 'in', into.x, into.y, true, syms);\n return true;\n}\n\n/**\n * The factor {@link scaleSegmentHandles} takes to bring segment\n * `(sub, segIdx)`'s grip as near `to` as scaling can: `to` projected onto the\n * line the grip slides along as both handles grow. 1 when the segment has no\n * balance line.\n */\nexport function balanceFactorToward(set: AnchorSet, sub: number, segIdx: number, to: Point): number {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return 1;\n const { a, b, from, to: tip } = handles;\n // grip(k) = mid + k·w, where mid is the chord's middle and w the handles'\n // mean offset; k = 1 is where the grip is now.\n const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };\n const w = { x: (from.x - a.x + tip.x - b.x) / 2, y: (from.y - a.y + tip.y - b.y) / 2 };\n const w2 = w.x * w.x + w.y * w.y;\n if (w2 < 1e-12) return 1;\n return Math.max(0, ((to.x - mid.x) * w.x + (to.y - mid.y) * w.y) / w2);\n}\n\n/**\n * Give both handles of segment `(sub, segIdx)` the same proportion: each\n * reaches the same fraction of the way from its anchor to the corner where\n * the two handle lines cross, that fraction being the mean of the two they\n * had. Where the lines don't cross ahead of both handles, both take the mean\n * length instead. Directions are kept either way.\n *\n * Returns false when the segment has no balance line or the handles already\n * match.\n */\nexport function equalizeSegmentHandles(set: AnchorSet, sub: number, segIdx: number): boolean {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return false;\n const { a, b, from, to } = handles;\n const lenA = length(a, from);\n const lenB = length(b, to);\n const ua = { x: (from.x - a.x) / lenA, y: (from.y - a.y) / lenA };\n const ub = { x: (to.x - b.x) / lenB, y: (to.y - b.y) / lenB };\n const corner = rayCrossing(a, ua, b, ub);\n let nextA: number;\n let nextB: number;\n if (corner) {\n const share = (lenA / corner.ta + lenB / corner.tb) / 2;\n nextA = share * corner.ta;\n nextB = share * corner.tb;\n } else {\n nextA = nextB = (lenA + lenB) / 2;\n }\n if (Math.abs(nextA - lenA) < 1e-9 && Math.abs(nextB - lenB) < 1e-9) return false;\n a.outHandle = { x: a.x + ua.x * nextA, y: a.y + ua.y * nextA };\n b.inHandle = { x: b.x + ub.x * nextB, y: b.y + ub.y * nextB };\n return true;\n}\n\n/** Where the ray from `p` along `u` meets the ray from `q` along `v`, as the\n * distance along each; null when they are parallel or meet behind either. */\nfunction rayCrossing(p: Point, u: Point, q: Point, v: Point): { ta: number; tb: number } | null {\n const den = u.x * v.y - u.y * v.x;\n if (Math.abs(den) < 1e-12) return null;\n const dx = q.x - p.x;\n const dy = q.y - p.y;\n const ta = (dx * v.y - dy * v.x) / den;\n const tb = (dx * u.y - dy * u.x) / den;\n return ta > 0 && tb > 0 ? { ta, tb } : null;\n}\n\nfunction length(a: Point, b: Point): number {\n return Math.hypot(b.x - a.x, b.y - a.y);\n}\n\nfunction scaledFrom(anchor: Point, handle: Point, k: number): Point {\n return { x: anchor.x + (handle.x - anchor.x) * k, y: anchor.y + (handle.y - anchor.y) * k };\n}\n","import { anchorCount, locateAnchor, type AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\n\ntype Point = { x: number; y: number };\n\n/** Passes over the anchors before giving up on settling. Each anchor's fix\n * moves its neighbors' curvature a little, so a few passes are needed. */\nconst MAX_PASSES = 64;\n/** A pass that moves no handle further than this fraction of its length has\n * settled. */\nconst SETTLED = 1e-12;\n/** Handles that end up no further than this fraction of their length from\n * where they started count as unchanged: a path stored in single precision\n * comes back this far off the harmony it was given. */\nconst UNCHANGED = 1e-6;\n\n/**\n * Make each smooth anchor at `flatIndexes` curvature-continuous: the curve\n * bends as tightly just after the anchor as just before it, so it shows no\n * kink in its curvature there. Only handle lengths change — each handle keeps\n * its direction, so the anchor stays smooth and the tangent stays put — and\n * the product of the two lengths is kept, so the anchor's pull on the curve\n * stays about as strong.\n *\n * Absent `flatIndexes`, every anchor in the set. Moving one anchor's handles\n * changes the curvature at its neighbors, so the fixes are repeated until\n * they settle.\n *\n * Skipped, because lengths alone cannot do it: a corner, an anchor missing a\n * handle, an end of an open subpath, and an anchor the curve bends opposite\n * ways either side of, or straight through on one side.\n *\n * Returns false when nothing changed.\n */\nexport function harmonizeAnchors(set: AnchorSet, flatIndexes?: Iterable<number>): boolean {\n const targets = flatIndexes\n ? [...new Set(flatIndexes)]\n : Array.from({ length: anchorCount(set) }, (_, i) => i);\n const located = targets\n .map((flat) => locateAnchor(set, flat))\n .filter((loc): loc is { sub: number; idx: number } => loc !== null);\n const anchors = located.map(({ sub, idx }) => set.anchors[sub][idx]);\n const before = anchors.map((a) => ({ inHandle: a.inHandle, outHandle: a.outHandle }));\n for (let pass = 0; pass < MAX_PASSES; pass++) {\n let moved = 0;\n for (const { sub, idx } of located) moved = Math.max(moved, harmonizeOne(set, sub, idx));\n if (moved <= SETTLED) break;\n }\n const changed = anchors.some((a, i) =>\n movedFar(a, before[i].inHandle, a.inHandle) || movedFar(a, before[i].outHandle, a.outHandle));\n if (!changed) {\n anchors.forEach((a, i) => { a.inHandle = before[i].inHandle; a.outHandle = before[i].outHandle; });\n }\n return changed;\n}\n\nfunction movedFar(a: Point, from: Point | undefined, to: Point | undefined): boolean {\n if (!from || !to || from === to) return false;\n const len = Math.hypot(from.x - a.x, from.y - a.y);\n return Math.hypot(to.x - from.x, to.y - from.y) > UNCHANGED * Math.max(len, 1e-9);\n}\n\n/** Harmonize one anchor; returns how far its handles moved, relative to\n * their lengths. */\nfunction harmonizeOne(set: AnchorSet, sub: number, idx: number): number {\n const anchors = set.anchors[sub];\n const closed = set.closed[sub];\n const n = anchors.length;\n if (!closed && (idx === 0 || idx === n - 1)) return 0;\n if (n < 2) return 0;\n const a = anchors[idx];\n if (!isAnchorSmooth(a)) return 0;\n const prev = anchors[(idx - 1 + n) % n];\n const next = anchors[(idx + 1) % n];\n\n const hIn = Math.hypot(a.inHandle!.x - a.x, a.inHandle!.y - a.y);\n const hOut = Math.hypot(a.outHandle!.x - a.x, a.outHandle!.y - a.y);\n const u = { x: (a.outHandle!.x - a.x) / hOut, y: (a.outHandle!.y - a.y) / hOut };\n\n // Curvature at the anchor is 2/3 · d / h², where h is the handle's length\n // and d how far the far control of that segment sits off the tangent line.\n const dIn = offTangent(a, u, prev.outHandle ?? prev);\n const dOut = offTangent(a, u, next.inHandle ?? next);\n if (dIn === 0 || dOut === 0 || Math.sign(dIn) !== Math.sign(dOut)) return 0;\n\n const ratio = Math.sqrt(dIn / dOut);\n const product = hIn * hOut;\n const nextIn = Math.sqrt(product * ratio);\n const nextOut = Math.sqrt(product / ratio);\n const moved = Math.max(Math.abs(nextIn - hIn) / hIn, Math.abs(nextOut - hOut) / hOut);\n if (moved <= SETTLED) return 0;\n a.inHandle = along(a, u, -nextIn);\n a.outHandle = along(a, u, nextOut);\n return moved;\n}\n\n/** Signed distance of `p` from the line through `a` along unit `u`. */\nfunction offTangent(a: PenAnchor, u: Point, p: Point): number {\n const d = u.x * (p.y - a.y) - u.y * (p.x - a.x);\n return Math.abs(d) < 1e-12 ? 0 : d;\n}\n\nfunction along(a: PenAnchor, u: Point, len: number): Point {\n return { x: a.x + u.x * len, y: a.y + u.y * len };\n}\n","/**\n * Arrays kept per anchor of a path — vertex colors, stroke widths — carried through an edit\n * that `editAnchorSetTracked` reported.\n */\n\nimport { PATH_C, PATH_Q, PATH_Z, forEachSegment } from '../commands';\nimport type { PolygonPath } from '../path';\nimport type { PointOrigin } from './anchorOrigins';\n\n/** For each point of `path`, the index of the anchor it ends, as `countPathAnchors` counts\n * them (one per M, L, C and Q), or -1 for a control point. */\nfunction anchorOfPoint(path: PolygonPath): Int32Array {\n const owner = new Int32Array(path.coords.length >> 1).fill(-1);\n let anchor = 0;\n forEachSegment(path.commands, path.coords, (cmd, ci) => {\n if (cmd === PATH_Z) return;\n const n = cmd === PATH_C ? 6 : cmd === PATH_Q ? 4 : 2;\n owner[(ci + n - 2) >> 1] = anchor++;\n });\n return owner;\n}\n\n/**\n * Where each anchor of `after` came from, in anchors of `before` as `countPathAnchors` counts\n * them, given the point `origins` `editAnchorSetTracked` answered for the edit: anchor `a`, or\n * for an anchor the edit made, a blend `t` of the way from `a` to `b`. `reversed` marks an\n * anchor whose subpath now runs the other way through it. Null for an anchor with no origin.\n */\nexport function anchorOriginsOf(\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): (PointOrigin | null)[] {\n const wasAnchor = anchorOfPoint(before);\n const out: (PointOrigin | null)[] = [];\n anchorOfPoint(after).forEach((anchor, point) => {\n if (anchor === -1) return;\n const o = origins[point];\n const a = o ? wasAnchor[o.a] ?? -1 : -1;\n if (!o || a === -1) {\n out.push(null);\n return;\n }\n const b = wasAnchor[o.b] ?? -1;\n out.push({ a, b: b === -1 ? a : b, t: b === -1 ? 0 : o.t, ...(o.reversed ? { reversed: true as const } : {}) });\n });\n return out;\n}\n\n/**\n * An array kept per anchor of a path, `stride` numbers each — four color channels, say —\n * carried through an edit from `before` to `after`, with `origins` as\n * `editAnchorSetTracked` answered. An anchor the edit kept keeps its numbers; one it\n * made blends those of the anchors it came between. An anchor with no origin reads 0. Anchors\n * are counted as `countPathAnchors` counts them.\n */\nexport function remapAnchorValues(\n values: ArrayLike<number>,\n stride: number,\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): number[] {\n const out: number[] = [];\n for (const o of anchorOriginsOf(before, after, origins)) {\n for (let k = 0; k < stride; k++) {\n const va = o ? values[o.a * stride + k] ?? 0 : 0;\n const vb = o ? values[o.b * stride + k] ?? 0 : 0;\n out.push(o && o.t !== 0 ? va + (vb - va) * o.t : va);\n }\n }\n return out;\n}\n","/**\n * Geometric constraints on a path's anchors. Each names anchors by flat index,\n * the walk-order numbering `enumerateAnchors` and `anchorAt` use, and is plain\n * JSON, so a list of them can be kept in scene data and saved with it.\n */\n\n/** Two anchors by flat index: the straight line from the first to the second. */\nexport type AnchorPair = readonly [number, number];\n\n/**\n * One constraint. `fixed` holds an anchor where it was before an edit, so it\n * moves with its node but not with any edit of the path. `horizontal` and\n * `vertical` read the axes of the frame the solve is given; `length` is in\n * the path's own units. `tangent` keeps an anchor's two handles on one line\n * through it, pointing apart (G1 continuity), their lengths free; it needs\n * both handles. `onPath` holds an anchor on the path's segment from\n * `segment[0]` to `segment[1]`, anywhere along it.\n */\nexport type PathConstraint =\n | { readonly kind: 'fixed' | 'tangent'; readonly anchor: number }\n | { readonly kind: 'horizontal' | 'vertical'; readonly segment: AnchorPair }\n | {\n readonly kind: 'parallel' | 'perpendicular' | 'equalLength';\n readonly segments: readonly [AnchorPair, AnchorPair];\n }\n | { readonly kind: 'length'; readonly segment: AnchorPair; readonly length: number }\n | { readonly kind: 'coincident'; readonly anchors: AnchorPair }\n | { readonly kind: 'onPath'; readonly anchor: number; readonly segment: AnchorPair };\n\n/** Every kind of {@link PathConstraint}. */\nexport type PathConstraintKind = PathConstraint['kind'];\n\n/** The anchors `c` reads, in the order it names them; an anchor named twice is listed twice. */\nexport function constraintAnchors(c: PathConstraint): number[] {\n switch (c.kind) {\n case 'fixed':\n case 'tangent': return [c.anchor];\n case 'horizontal':\n case 'vertical':\n case 'length': return [...c.segment];\n case 'coincident': return [...c.anchors];\n case 'onPath': return [c.anchor, ...c.segment];\n default: return [...c.segments[0], ...c.segments[1]];\n }\n}\n\n/**\n * `c` with every anchor index passed through `to`, or null when `to` answers\n * `undefined` for any of them — the anchor is gone, and so is the constraint.\n */\nexport function mapConstraintAnchors(\n c: PathConstraint,\n to: (anchor: number) => number | undefined,\n): PathConstraint | null {\n const pair = (p: AnchorPair): AnchorPair | null => {\n const a = to(p[0]);\n const b = to(p[1]);\n return a === undefined || b === undefined ? null : [a, b];\n };\n switch (c.kind) {\n case 'fixed':\n case 'tangent': {\n const anchor = to(c.anchor);\n return anchor === undefined ? null : { kind: c.kind, anchor };\n }\n case 'horizontal':\n case 'vertical': {\n const segment = pair(c.segment);\n return segment && { kind: c.kind, segment };\n }\n case 'length': {\n const segment = pair(c.segment);\n return segment && { kind: 'length', segment, length: c.length };\n }\n case 'coincident': {\n const anchors = pair(c.anchors);\n return anchors && { kind: 'coincident', anchors };\n }\n case 'onPath': {\n const anchor = to(c.anchor);\n const segment = pair(c.segment);\n return anchor === undefined || !segment ? null : { kind: 'onPath', anchor, segment };\n }\n default: {\n const first = pair(c.segments[0]);\n const second = pair(c.segments[1]);\n return first && second && { kind: c.kind, segments: [first, second] };\n }\n }\n}\n\n/** Whether every anchor `c` names is an index below `count`. */\nexport function constraintFits(c: PathConstraint, count: number): boolean {\n return constraintAnchors(c).every((i) => Number.isInteger(i) && i >= 0 && i < count);\n}\n","/**\n * Each constraint as residual rows: numbers that are all zero exactly when it\n * holds. Every row is in the path's units, so one tolerance reads them all.\n * Each row's derivatives are analytic, handed out one nonzero at a time.\n */\n\nimport { nearestOnCubic } from '../nearest';\nimport type { AnchorPair, PathConstraint } from './types';\n\n/** The axes `horizontal` and `vertical` read: the x axis is `(cos, sin)`. */\nexport interface ConstraintFrame {\n cos: number;\n sin: number;\n}\n\n/** The frame turned `angle` radians from the world's axes. */\nexport function frameAt(angle = 0): ConstraintFrame {\n return { cos: Math.cos(angle), sin: Math.sin(angle) };\n}\n\n/**\n * Where a solve keeps its coordinates. `x` holds every anchor's position,\n * interleaved, then every anchor's in and out handle as offsets from it, so a\n * handle rides with its anchor and a constraint on handles reads only them.\n */\nexport interface ResidualSpace {\n frame: ConstraintFrame;\n /** Anchors. */\n count: number;\n}\n\n/** Where anchor `i`'s in handle offset starts in a space of `count` anchors; its out handle follows. */\nexport const handleAt = (count: number, i: number): number => 2 * count + 4 * i;\n\n/** Coordinates a space of `count` anchors holds. */\nexport const spaceSize = (count: number): number => 6 * count;\n\n/** Takes one derivative: of residual row `row` (counted from the constraint's first) by coordinate `v`. */\nexport type Grad = (row: number, v: number, d: number) => void;\n\n/** How many residual rows `c` writes. */\nexport function residualRows(c: PathConstraint): number {\n return c.kind === 'coincident' || c.kind === 'onPath' ? 2 : c.kind === 'fixed' ? 0 : 1;\n}\n\n/** The cubic from anchor `a` to anchor `b` of `x`, by `a`'s out handle and `b`'s in handle: [x0, y0, … x3, y3]. */\nfunction segmentCubic(x: ArrayLike<number>, count: number, [a, b]: AnchorPair): number[] {\n const out = handleAt(count, a) + 2;\n const inn = handleAt(count, b);\n return [\n x[2 * a], x[2 * a + 1],\n x[2 * a] + x[out], x[2 * a + 1] + x[out + 1],\n x[2 * b] + x[inn], x[2 * b + 1] + x[inn + 1],\n x[2 * b], x[2 * b + 1],\n ];\n}\n\n/** The parameter of the point on `c`'s segment nearest its anchor, in `x`. */\nexport function nearestParam(c: PathConstraint & { kind: 'onPath' }, x: ArrayLike<number>, count: number): number {\n const q = segmentCubic(x, count, c.segment);\n return nearestOnCubic(x[2 * c.anchor], x[2 * c.anchor + 1], q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]).t;\n}\n\n/** The anchor less the point at parameter `x[param]` on the segment, as two rows. */\nfunction onPathRows(\n c: PathConstraint & { kind: 'onPath' },\n x: ArrayLike<number>,\n count: number,\n out: Float64Array,\n at: number,\n grad: Grad | undefined,\n param: number,\n): void {\n const t = x[param];\n const s = 1 - t;\n const q = segmentCubic(x, count, c.segment);\n const w = [s * s * s, 3 * s * s * t, 3 * s * t * t, t * t * t];\n for (let k = 0; k < 2; k++) {\n out[at + k] = x[2 * c.anchor + k] - (w[0] * q[k] + w[1] * q[2 + k] + w[2] * q[4 + k] + w[3] * q[6 + k]);\n }\n if (!grad) return;\n const [a, b] = c.segment;\n for (let k = 0; k < 2; k++) {\n grad(k, 2 * c.anchor + k, 1);\n grad(k, 2 * a + k, -(w[0] + w[1]));\n grad(k, 2 * b + k, -(w[2] + w[3]));\n grad(k, handleAt(count, a) + 2 + k, -w[1]);\n grad(k, handleAt(count, b) + k, -w[2]);\n grad(k, param, -(3 * s * s * (q[2 + k] - q[k]) + 6 * s * t * (q[4 + k] - q[2 + k]) + 3 * t * t * (q[6 + k] - q[4 + k])));\n }\n}\n\n/**\n * The angle between anchor `i`'s in handle and its out handle turned round,\n * times the geometric mean of their lengths: zero exactly when they point\n * apart along one line. Zero when either has no length.\n */\nfunction tangentRow(x: ArrayLike<number>, count: number, i: number, grad: Grad | undefined): number {\n const h = handleAt(count, i);\n const px = x[h];\n const py = x[h + 1];\n const qx = x[h + 2];\n const qy = x[h + 3];\n const pp = px * px + py * py;\n const qq = qx * qx + qy * qy;\n const scale = Math.sqrt(Math.sqrt(pp) * Math.sqrt(qq));\n if (scale < 1e-9) return 0;\n const theta = Math.atan2(-(px * qy - py * qx), -(px * qx + py * qy));\n if (grad) {\n // r = θ L: ∂θ/∂p = (py, -px) / |p|², ∂θ/∂q = (-qy, qx) / |q|², ∂L = (L / 2) (p / |p|², q / |q|²).\n const k = theta / 2;\n grad(0, h, scale * (py / pp + (k * px) / pp));\n grad(0, h + 1, scale * (-px / pp + (k * py) / pp));\n grad(0, h + 2, scale * (-qy / qq + (k * qx) / qq));\n grad(0, h + 3, scale * (qx / qq + (k * qy) / qq));\n }\n return theta * scale;\n}\n\nconst dx = (x: ArrayLike<number>, [a, b]: AnchorPair) => x[2 * b] - x[2 * a];\nconst dy = (x: ArrayLike<number>, [a, b]: AnchorPair) => x[2 * b + 1] - x[2 * a + 1];\n\n/** `d` times the derivative of segment `s`'s vector by its own `(gx, gy)`, spread onto its two ends. */\nfunction segmentGrad(grad: Grad, row: number, [a, b]: AnchorPair, gx: number, gy: number): void {\n grad(row, 2 * b, gx);\n grad(row, 2 * b + 1, gy);\n grad(row, 2 * a, -gx);\n grad(row, 2 * a + 1, -gy);\n}\n\nfunction lengthOf(x: ArrayLike<number>, s: AnchorPair, grad: Grad | undefined, row: number, sign: number): number {\n const ux = dx(x, s);\n const uy = dy(x, s);\n const len = Math.hypot(ux, uy);\n if (grad && len > 1e-12) segmentGrad(grad, row, s, (sign * ux) / len, (sign * uy) / len);\n return len;\n}\n\n/**\n * The cross (`parallel`) or dot (`perpendicular`) product of two segments,\n * over the geometric mean of their lengths: the sine or cosine of the angle\n * between them, times a length. Zero when either segment has no length,\n * which leaves the angle undefined rather than wrong.\n */\nfunction angleRow(\n x: ArrayLike<number>,\n s: readonly [AnchorPair, AnchorPair],\n cross: boolean,\n grad: Grad | undefined,\n row: number,\n): number {\n const ux = dx(x, s[0]);\n const uy = dy(x, s[0]);\n const vx = dx(x, s[1]);\n const vy = dy(x, s[1]);\n const uu = ux * ux + uy * uy;\n const vv = vx * vx + vy * vy;\n const scale = Math.sqrt(Math.sqrt(uu) * Math.sqrt(vv));\n if (scale < 1e-9) return 0;\n const g = cross ? ux * vy - uy * vx : ux * vx + uy * vy;\n const f = g / scale;\n if (grad) {\n // f = g / S with S = sqrt(|u| |v|): ∂f = ∂g / S - (f / 2) (u / |u|² + v / |v|²).\n const [gux, guy, gvx, gvy] = cross ? [vy, -vx, -uy, ux] : [vx, vy, ux, uy];\n segmentGrad(grad, row, s[0], gux / scale - (f / 2) * (ux / uu), guy / scale - (f / 2) * (uy / uu));\n segmentGrad(grad, row, s[1], gvx / scale - (f / 2) * (vx / vv), gvy / scale - (f / 2) * (vy / vv));\n }\n return f;\n}\n\n/**\n * Write `c`'s residual rows for coordinates `x`, laid out as `space` says, into\n * `out` at `at`, and hand each nonzero derivative to `grad` when given. An\n * `onPath` constraint reads its parameter from `x[param]`.\n */\nexport function writeResiduals(\n c: PathConstraint,\n x: ArrayLike<number>,\n space: ResidualSpace,\n out: Float64Array,\n at: number,\n grad?: Grad,\n param = -1,\n): void {\n const { frame } = space;\n switch (c.kind) {\n case 'fixed': return;\n case 'onPath':\n onPathRows(c, x, space.count, out, at, grad, param);\n return;\n case 'tangent':\n out[at] = tangentRow(x, space.count, c.anchor, grad);\n return;\n case 'horizontal':\n out[at] = -frame.sin * dx(x, c.segment) + frame.cos * dy(x, c.segment);\n if (grad) segmentGrad(grad, 0, c.segment, -frame.sin, frame.cos);\n return;\n case 'vertical':\n out[at] = frame.cos * dx(x, c.segment) + frame.sin * dy(x, c.segment);\n if (grad) segmentGrad(grad, 0, c.segment, frame.cos, frame.sin);\n return;\n case 'length':\n out[at] = lengthOf(x, c.segment, grad, 0, 1) - c.length;\n return;\n case 'coincident':\n out[at] = dx(x, c.anchors);\n out[at + 1] = dy(x, c.anchors);\n if (grad) {\n segmentGrad(grad, 0, c.anchors, 1, 0);\n segmentGrad(grad, 1, c.anchors, 0, 1);\n }\n return;\n case 'equalLength':\n out[at] = lengthOf(x, c.segments[0], grad, 0, 1) - lengthOf(x, c.segments[1], grad, 0, -1);\n return;\n case 'parallel':\n out[at] = angleRow(x, c.segments, true, grad, 0);\n return;\n case 'perpendicular':\n out[at] = angleRow(x, c.segments, false, grad, 0);\n }\n}\n","/**\n * The points a constraint solve reads, and the coordinate vector it works in:\n * anchors, then each anchor's handles as offsets from it (see `ResidualSpace`).\n */\n\nimport { handleAt, spaceSize } from './residuals';\nimport { constraintFits, type PathConstraint } from './types';\n\n/** An anchor the solver reads and writes, with its handles where it has them. */\nexport interface ConstraintPoint {\n x: number;\n y: number;\n inHandle?: { x: number; y: number };\n outHandle?: { x: number; y: number };\n}\n\n/** One handle of an anchor. */\nexport interface HandleRef {\n anchor: number;\n side: 'in' | 'out';\n}\n\n/**\n * Whether `c` can be solved over `points`: every anchor it names exists, and\n * a `tangent` anchor has both handles.\n */\nexport function constraintApplies(c: PathConstraint, points: readonly ConstraintPoint[]): boolean {\n if (!constraintFits(c, points.length)) return false;\n if (c.kind !== 'tangent') return true;\n const a = points[c.anchor];\n return !!a.inHandle && !!a.outHandle;\n}\n\n/** `points` as a coordinate vector, each anchor at `at(i)` — its reference, say — and its handles riding with it. */\nexport function pack(points: readonly ConstraintPoint[], at: (i: number) => ConstraintPoint = (i) => points[i]): Float64Array {\n const n = points.length;\n const x = new Float64Array(spaceSize(n));\n points.forEach((p, i) => {\n const place = at(i);\n x[2 * i] = place.x;\n x[2 * i + 1] = place.y;\n const h = handleAt(n, i);\n if (p.inHandle) {\n x[h] = p.inHandle.x - p.x;\n x[h + 1] = p.inHandle.y - p.y;\n }\n if (p.outHandle) {\n x[h + 2] = p.outHandle.x - p.x;\n x[h + 3] = p.outHandle.y - p.y;\n }\n });\n return x;\n}\n\n/** The points `x` holds, each with the handles its counterpart in `like` has. */\nexport function unpack(x: Float64Array, like: readonly ConstraintPoint[]): ConstraintPoint[] {\n const n = like.length;\n return like.map((p, i) => {\n const out: ConstraintPoint = { x: x[2 * i], y: x[2 * i + 1] };\n const h = handleAt(n, i);\n if (p.inHandle) out.inHandle = { x: out.x + x[h], y: out.y + x[h + 1] };\n if (p.outHandle) out.outHandle = { x: out.x + x[h + 2], y: out.y + x[h + 3] };\n return out;\n });\n}\n","/**\n * Whether constraints hold for a set of points, and whether a solve made them\n * hold only by collapsing what they measure.\n */\n\nimport { constraintApplies, pack, type ConstraintPoint } from './points';\nimport { frameAt, nearestParam, residualRows, writeResiduals } from './residuals';\nimport type { AnchorPair, PathConstraint } from './types';\n\n/** The residual, in the path's units, under which a constraint counts as holding. */\nexport const CONSTRAINT_TOLERANCE = 1e-3;\n\n/** The anchor pairs `c` measures as segments. */\nfunction segmentsOf(c: PathConstraint): AnchorPair[] {\n switch (c.kind) {\n case 'fixed':\n case 'tangent':\n case 'coincident': return [];\n case 'horizontal':\n case 'vertical':\n case 'onPath':\n case 'length': return [c.segment];\n default: return [...c.segments];\n }\n}\n\nconst handleLength = (p: ConstraintPoint, h: { x: number; y: number } | undefined) =>\n (h ? Math.hypot(h.x - p.x, h.y - p.y) : 0);\n\n/**\n * Constraints the solve satisfied only by shrinking what they measure to a\n * point — horizontal and vertical on one segment both hold once its ends\n * meet, and a tangent holds once a handle has no length. That is a conflict,\n * not a solution. A pair a constraint means to join, by `coincident` or a\n * zero `length`, is exempt.\n */\nexport function collapsedBy(\n from: readonly ConstraintPoint[],\n to: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n skipped: ReadonlySet<number>,\n): number[] {\n const key = ([a, b]: AnchorPair) => (a < b ? `${a},${b}` : `${b},${a}`);\n const joined = new Set(constraints.flatMap((c) =>\n c.kind === 'coincident' ? [key(c.anchors)]\n : c.kind === 'length' && c.length <= CONSTRAINT_TOLERANCE ? [key(c.segment)] : []));\n const len = (p: readonly ConstraintPoint[], [a, b]: AnchorPair) => Math.hypot(p[b].x - p[a].x, p[b].y - p[a].y);\n const shrank = (was: number, now: number) => was > 10 * CONSTRAINT_TOLERANCE && now <= CONSTRAINT_TOLERANCE;\n const out: number[] = [];\n constraints.forEach((c, i) => {\n if (skipped.has(i) || !constraintApplies(c, from)) return;\n if (c.kind === 'tangent') {\n const [a, b] = [from[c.anchor], to[c.anchor]];\n if (shrank(handleLength(a, a.inHandle), handleLength(b, b.inHandle))\n || shrank(handleLength(a, a.outHandle), handleLength(b, b.outHandle))) out.push(i);\n return;\n }\n if (segmentsOf(c).some((s) => !joined.has(key(s)) && shrank(len(from, s), len(to, s)))) out.push(i);\n });\n return out;\n}\n\n/** Options for {@link unsatisfiedConstraints}. */\nexport interface UnsatisfiedConstraintsOptions {\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle`. */\n axisAngles?: readonly (number | undefined)[];\n /** Where a `fixed` anchor belongs. Absent, a `fixed` constraint always holds. */\n reference?: readonly (ConstraintPoint | undefined)[];\n /** Default {@link CONSTRAINT_TOLERANCE}. */\n tolerance?: number;\n}\n\n/**\n * Indices of the constraints that do not hold for `points`: a residual past\n * the tolerance, an anchor index the points do not have, or a tangent on an\n * anchor missing a handle.\n */\nexport function unsatisfiedConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: UnsatisfiedConstraintsOptions = {},\n): number[] {\n const { tolerance = CONSTRAINT_TOLERANCE, reference } = opts;\n const spaceOf = (i: number) => ({ frame: frameAt(opts.axisAngles?.[i] ?? opts.axisAngle), count: points.length });\n const packed = pack(points);\n // One slot past the points for an `onPath` parameter, set to the nearest point's each time.\n const x = new Float64Array(packed.length + 1);\n x.set(packed);\n const param = packed.length;\n const r = new Float64Array(2);\n const out: number[] = [];\n constraints.forEach((c, i) => {\n if (!constraintApplies(c, points)) {\n out.push(i);\n return;\n }\n if (c.kind === 'fixed') {\n const at = reference?.[c.anchor];\n const p = points[c.anchor];\n if (at && Math.hypot(at.x - p.x, at.y - p.y) > tolerance) out.push(i);\n return;\n }\n if (c.kind === 'onPath') x[param] = nearestParam(c, x, points.length);\n writeResiduals(c, x, spaceOf(i), r, 0, undefined, param);\n for (let k = 0; k < residualRows(c); k++) {\n if (Math.abs(r[k]) > tolerance) {\n out.push(i);\n return;\n }\n }\n });\n return out;\n}\n","/**\n * The damped normal equations of a constraint solve, `(J M Jᵀ + λI) y = b`,\n * kept sparse. Each row of `J` reads a handful of coordinates, so two rows\n * meet in the normal matrix only when they share one. The rows are put in\n * reverse Cuthill-McKee order, which packs those meetings near the diagonal,\n * and the matrix is factored by Cholesky inside that envelope: a chain of\n * constraints along a path costs time linear in its length, where the dense\n * solve cost its cube.\n */\n\n/** A row's position in `order` for each row, and the rows in that order. */\nfunction reverseCuthillMcKee(neighbors: readonly number[][]): { order: Int32Array; rank: Int32Array } {\n const m = neighbors.length;\n const order = new Int32Array(m);\n const rank = new Int32Array(m).fill(-1);\n const byDegree = [...neighbors.keys()].sort((a, b) => neighbors[a].length - neighbors[b].length);\n let n = 0;\n for (const start of byDegree) {\n if (rank[start] >= 0) continue;\n rank[start] = n;\n order[n++] = start;\n for (let head = n - 1; head < n; head++) {\n const next = neighbors[order[head]].filter((q) => rank[q] < 0)\n .sort((a, b) => neighbors[a].length - neighbors[b].length);\n for (const q of next) {\n rank[q] = n;\n order[n++] = q;\n }\n }\n }\n order.reverse();\n order.forEach((row, i) => { rank[row] = i; });\n return { order, rank };\n}\n\nexport class NormalSystem {\n private readonly cols: Int32Array[];\n private readonly vals: Float64Array[];\n private readonly mobility: Float64Array;\n private readonly rank: Int32Array;\n /** For each row in envelope order, the first column its envelope holds, and where its entries start. */\n private readonly first: Int32Array;\n private readonly offset: Int32Array;\n private readonly env: Float64Array;\n /**\n * Each product one coordinate makes between two rows' entries:\n * envelope position, the two rows, their slots, and the coordinate.\n */\n private readonly pairs: { pos: Int32Array; p: Int32Array; sp: Int32Array; q: Int32Array; sq: Int32Array; v: Int32Array };\n\n /**\n * `rowCols[p]` lists the coordinates row `p` may read; one whose `mobility`\n * is 0 here is dropped. `mobility` is read again at every solve, so a\n * coordinate may be stilled for a step by zeroing it.\n */\n constructor(rowCols: readonly Int32Array[], mobility: Float64Array) {\n this.mobility = mobility;\n this.cols = rowCols.map((c) => Int32Array.from(new Set(c)).filter((v) => mobility[v] > 0));\n this.vals = this.cols.map((c) => new Float64Array(c.length));\n const m = this.cols.length;\n const readers = new Map<number, { row: number; slot: number }[]>();\n this.cols.forEach((c, row) => c.forEach((v, slot) => {\n let list = readers.get(v);\n if (!list) readers.set(v, (list = []));\n list.push({ row, slot });\n }));\n const linked = Array.from({ length: m }, () => new Set<number>());\n for (const list of readers.values()) {\n for (const a of list) for (const b of list) if (a.row !== b.row) linked[a.row].add(b.row);\n }\n const { rank } = reverseCuthillMcKee(linked.map((s) => [...s]));\n this.rank = rank;\n this.first = new Int32Array(m);\n for (let p = 0; p < m; p++) {\n let f = rank[p];\n for (const q of linked[p]) f = Math.min(f, rank[q]);\n this.first[rank[p]] = f;\n }\n this.offset = new Int32Array(m + 1);\n for (let i = 0; i < m; i++) this.offset[i + 1] = this.offset[i] + i - this.first[i] + 1;\n this.env = new Float64Array(this.offset[m]);\n\n const pos: number[] = [];\n const ps: number[] = [];\n const sps: number[] = [];\n const qs: number[] = [];\n const sqs: number[] = [];\n const vs: number[] = [];\n for (const [v, list] of readers) {\n for (const a of list) {\n for (const b of list) {\n const i = rank[a.row];\n const j = rank[b.row];\n if (j > i) continue;\n pos.push(this.at(i, j));\n ps.push(a.row);\n sps.push(a.slot);\n qs.push(b.row);\n sqs.push(b.slot);\n vs.push(v);\n }\n }\n }\n this.pairs = {\n pos: Int32Array.from(pos), p: Int32Array.from(ps), sp: Int32Array.from(sps),\n q: Int32Array.from(qs), sq: Int32Array.from(sqs), v: Int32Array.from(vs),\n };\n }\n\n /** Rows. */\n get m(): number {\n return this.cols.length;\n }\n\n private at(i: number, j: number): number {\n return this.offset[i] + j - this.first[i];\n }\n\n /** Zero every entry of `J`. */\n clear(): void {\n for (const v of this.vals) v.fill(0);\n }\n\n /** Add `d` to `J[row][v]`; nothing when the row cannot move `v`. */\n add(row: number, v: number, d: number): void {\n const c = this.cols[row];\n for (let k = 0; k < c.length; k++) {\n if (c[k] === v) {\n this.vals[row][k] += d;\n return;\n }\n }\n }\n\n /** `y` for `(J M Jᵀ + λI) y = b`, or null when the matrix will not factor. */\n solve(b: Float64Array, lambda: number): Float64Array | null {\n const { env, first, offset, pairs, vals, rank, mobility } = this;\n const m = this.m;\n env.fill(0);\n for (let k = 0; k < pairs.pos.length; k++) {\n env[pairs.pos[k]] += vals[pairs.p[k]][pairs.sp[k]] * mobility[pairs.v[k]] * vals[pairs.q[k]][pairs.sq[k]];\n }\n for (let i = 0; i < m; i++) env[offset[i + 1] - 1] += lambda;\n // Cholesky in place, L sharing A's envelope.\n for (let i = 0; i < m; i++) {\n const fi = first[i];\n for (let j = fi; j <= i; j++) {\n const fj = first[j];\n let s = env[offset[i] + j - fi];\n for (let k = Math.max(fi, fj); k < j; k++) s -= env[offset[i] + k - fi] * env[offset[j] + k - fj];\n if (j < i) env[offset[i] + j - fi] = s / env[offset[j + 1] - 1];\n else if (s > 0) env[offset[i + 1] - 1] = Math.sqrt(s);\n else return null;\n }\n }\n const z = new Float64Array(m);\n for (let p = 0; p < m; p++) z[rank[p]] = b[p];\n for (let i = 0; i < m; i++) {\n let s = z[i];\n for (let k = first[i]; k < i; k++) s -= env[offset[i] + k - first[i]] * z[k];\n z[i] = s / env[offset[i + 1] - 1];\n }\n for (let i = m - 1; i >= 0; i--) {\n z[i] /= env[offset[i + 1] - 1];\n for (let k = first[i]; k < i; k++) z[k] -= env[offset[i] + k - first[i]] * z[i];\n }\n const y = new Float64Array(m);\n for (let p = 0; p < m; p++) y[p] = z[rank[p]];\n return y;\n }\n\n /** The step `-M Jᵀ y` over every coordinate the mobility names. */\n step(y: Float64Array): Float64Array {\n const delta = new Float64Array(this.mobility.length);\n this.cols.forEach((c, p) => c.forEach((v, k) => {\n delta[v] -= this.mobility[v] * this.vals[p][k] * y[p];\n }));\n return delta;\n }\n}\n","/**\n * A damped Gauss-Newton solve for anchor constraints: from the state an edit\n * left, the smallest weighted move of the anchors and handles that makes\n * every residual zero. Each step is the minimum-norm solution of the\n * linearized system, `Δ = -M Jᵀ (J M Jᵀ + λI)⁻¹ r`, where `M` weighs how\n * freely each coordinate may move; λ grows when a step makes things worse and\n * shrinks when it helps, which is the Levenberg-Marquardt schedule run on the\n * constraint side.\n *\n * A handle is a coordinate of its own only where a `tangent` reads it; any\n * other rides with its anchor, as an offset nothing changes.\n */\n\nimport { CONSTRAINT_TOLERANCE, collapsedBy, unsatisfiedConstraints } from './check';\nimport { constraintApplies, pack, unpack, type ConstraintPoint, type HandleRef } from './points';\nimport {\n frameAt, handleAt, nearestParam, residualRows, spaceSize, writeResiduals, type ResidualSpace,\n} from './residuals';\nimport { NormalSystem } from './sparse';\nimport { constraintAnchors, type PathConstraint } from './types';\n\n/** How freely a held anchor moves, against 1 for any other: it gives way only when nothing else can. */\nconst HELD_MOBILITY = 1e-3;\n\n/** How freely an `onPath` parameter moves, over the square of its segment's chord: freely enough that the anchor slides along before anything bends. */\nconst PARAM_MOBILITY = 1e6;\n\n/** Options for {@link solveConstraints}. */\nexport interface SolveConstraintsOptions {\n /** Anchors the edit put where they are — the dragged ones. They move only when no other anchor can satisfy the constraints. */\n held?: Iterable<number>;\n /** Handles the edit put where they are, held the way `held` holds anchors. */\n heldHandles?: Iterable<HandleRef>;\n /** Where each anchor was before the edit, which is where a `fixed` constraint keeps it. Default: where it is now. */\n reference?: readonly (ConstraintPoint | undefined)[];\n /** Radians the frame `horizontal` and `vertical` read is turned from the world's axes. Default 0. */\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle` — for constraints gathered from paths drawn in different frames. */\n axisAngles?: readonly (number | undefined)[];\n /** Indices of constraints to leave out of the solve — ones already known not to hold. */\n skip?: Iterable<number>;\n /** Default 100. */\n maxIterations?: number;\n /** The largest residual the solve stops at. Default 1e-7. */\n tolerance?: number;\n}\n\n/** What {@link solveConstraints} answers. */\nexport interface SolveConstraintsResult {\n /** Every anchor, moved, with its handles. */\n points: ConstraintPoint[];\n /** Whether every constraint the solve took holds within its tolerance. */\n converged: boolean;\n iterations: number;\n /** Indices of the constraints that do not hold in `points`, skipped ones included. */\n unsatisfied: number[];\n}\n\ninterface Row {\n c: PathConstraint;\n /** First residual row. */\n at: number;\n /** Where an `onPath` constraint's parameter sits in the coordinates; -1 for any other. */\n param: number;\n space: ResidualSpace;\n}\n\ninterface System {\n rows: Row[];\n m: number;\n normal: NormalSystem;\n pinned: Set<number>;\n mobility: Float64Array;\n /** Coordinates: the points', then a parameter per `onPath`. */\n size: number;\n}\n\nfunction residualsOf(sys: System, x: Float64Array): Float64Array {\n const r = new Float64Array(sys.m);\n for (const row of sys.rows) writeResiduals(row.c, x, row.space, r, row.at, undefined, row.param);\n return r;\n}\n\n/** Load the analytic Jacobian at `x` into the normal system. */\nfunction loadJacobian(sys: System, x: Float64Array): void {\n const { normal } = sys;\n normal.clear();\n const scratch = new Float64Array(2);\n for (const row of sys.rows) {\n writeResiduals(row.c, x, row.space, scratch, 0, (k, v, d) => normal.add(row.at + k, v, d), row.param);\n }\n}\n\n/**\n * The damped minimum-norm step for residuals `r` at the loaded Jacobian, or\n * null when it cannot be taken. A parameter at an end of its segment that the\n * step would push past it is held there, and the step taken again without it.\n */\nfunction stepOf(sys: System, x: Float64Array, r: Float64Array, lambda: number): Float64Array | null {\n const y = sys.normal.solve(r, lambda);\n const delta = y && sys.normal.step(y);\n if (!delta) return null;\n const stuck = sys.rows.filter(({ param: p }) =>\n p >= 0 && sys.mobility[p] > 0 && ((x[p] <= 0 && delta[p] < 0) || (x[p] >= 1 && delta[p] > 0)));\n if (stuck.length === 0) return delta;\n const keep = stuck.map(({ param }) => sys.mobility[param]);\n for (const { param } of stuck) sys.mobility[param] = 0;\n const again = sys.normal.solve(r, lambda);\n const out = again && sys.normal.step(again);\n stuck.forEach(({ param }, k) => { sys.mobility[param] = keep[k]; });\n return out;\n}\n\nconst sumSq = (r: Float64Array) => r.reduce((s, v) => s + v * v, 0);\nconst maxAbs = (r: Float64Array) => r.reduce((s, v) => Math.max(s, Math.abs(v)), 0);\n\n/** The coordinates `c` reads, its parameter at `param`. */\nfunction coordinatesOf(c: PathConstraint, count: number, param: number): number[] {\n if (c.kind === 'tangent') {\n const h = handleAt(count, c.anchor);\n return [h, h + 1, h + 2, h + 3];\n }\n const anchors = constraintAnchors(c).flatMap((i) => [2 * i, 2 * i + 1]);\n if (c.kind !== 'onPath') return anchors;\n const out = handleAt(count, c.segment[0]) + 2;\n const inn = handleAt(count, c.segment[1]);\n return [...anchors, out, out + 1, inn, inn + 1, param];\n}\n\n/** How freely each coordinate moves: anchors and the handles a tangent reads, the held ones at `heldMobility`, pinned ones not at all. */\nfunction mobilityOf(\n points: readonly ConstraintPoint[],\n active: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n pinned: ReadonlySet<number>,\n): Float64Array {\n const count = points.length;\n const params = active.filter((c): c is PathConstraint & { kind: 'onPath' } => c.kind === 'onPath');\n const mobility = new Float64Array(spaceSize(count) + params.length);\n mobility.fill(1, 0, 2 * count);\n const held = new Set(opts.held ?? []);\n for (const i of held) {\n if (i >= 0 && i < count) mobility.fill(heldMobility, 2 * i, 2 * i + 2);\n }\n params.forEach((c, k) => {\n const [a, b] = c.segment.map((i) => points[i]);\n mobility[spaceSize(count) + k] = PARAM_MOBILITY / ((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + 1e-6);\n });\n for (const i of pinned) mobility.fill(0, 2 * i, 2 * i + 2);\n for (const c of active) {\n if (c.kind === 'tangent') mobility.fill(1, handleAt(count, c.anchor), handleAt(count, c.anchor) + 4);\n }\n for (const { anchor, side } of opts.heldHandles ?? []) {\n if (anchor < 0 || anchor >= count) continue;\n const h = handleAt(count, anchor) + (side === 'out' ? 2 : 0);\n if (mobility[h] > 0) mobility.fill(heldMobility, h, h + 2);\n }\n return mobility;\n}\n\nfunction buildSystem(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n): System {\n const count = points.length;\n const skip = new Set(opts.skip ?? []);\n const activeIndices = constraints.flatMap((c, i) => (!skip.has(i) && constraintApplies(c, points) ? [i] : []));\n const active = activeIndices.map((i) => constraints[i]);\n const pinned = new Set(active.flatMap((c) => (c.kind === 'fixed' ? [c.anchor] : [])));\n const mobility = mobilityOf(points, active, opts, heldMobility, pinned);\n const rows: Row[] = [];\n const rowCols: Int32Array[] = [];\n let size = spaceSize(count);\n const frames = new Map<number, ResidualSpace>();\n const spaceAt = (angle: number) => {\n let space = frames.get(angle);\n if (!space) frames.set(angle, (space = { frame: frameAt(angle), count }));\n return space;\n };\n for (const i of activeIndices) {\n const c = constraints[i];\n const height = residualRows(c);\n if (height === 0) continue;\n const param = c.kind === 'onPath' ? size++ : -1;\n rows.push({ c, at: rowCols.length, param, space: spaceAt(opts.axisAngles?.[i] ?? opts.axisAngle ?? 0) });\n const vars = Int32Array.from(coordinatesOf(c, count, param));\n for (let k = 0; k < height; k++) rowCols.push(vars);\n }\n const normal = new NormalSystem(rowCols, mobility);\n return { rows, m: rowCols.length, normal, pinned, mobility, size };\n}\n\n/**\n * Move `points` the least that makes `constraints` hold. Anchors named by a\n * `fixed` constraint go back to `reference` and stay there; `held` anchors\n * and `heldHandles` stay where they are when the rest can satisfy the\n * constraints, and give way as little as they must when not. When the\n * constraints cannot all hold, `converged` is false and `unsatisfied` names\n * the ones that do not.\n */\nexport function solveConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions = {},\n): SolveConstraintsResult {\n const held = [...(opts.held ?? [])];\n const heldHandles = [...(opts.heldHandles ?? [])];\n const withHeld = { ...opts, held, heldHandles };\n if (held.length > 0 || heldHandles.length > 0) {\n const still = solveWith(points, constraints, withHeld, 0);\n if (still.converged) return still;\n }\n return solveWith(points, constraints, withHeld, HELD_MOBILITY);\n}\n\nfunction solveWith(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n): SolveConstraintsResult {\n const { maxIterations = 100, tolerance = 1e-7 } = opts;\n const sys = buildSystem(points, constraints, opts, heldMobility);\n const x = new Float64Array(sys.size);\n x.set(pack(points, (i) => (sys.pinned.has(i) ? opts.reference?.[i] ?? points[i] : points[i])));\n // A held anchor an `onPath` binds slides: it starts from the point on its segment nearest where the edit put it.\n const held = new Set(opts.held ?? []);\n const r0 = new Float64Array(2);\n for (const row of sys.rows) {\n if (row.c.kind !== 'onPath') continue;\n x[row.param] = nearestParam(row.c, x, points.length);\n const a = row.c.anchor;\n if (!held.has(a) || sys.pinned.has(a)) continue;\n writeResiduals(row.c, x, row.space, r0, 0, undefined, row.param);\n x[2 * a] -= r0[0];\n x[2 * a + 1] -= r0[1];\n }\n\n let r = residualsOf(sys, x);\n let lambda = 1e-6;\n let iterations = 0;\n while (maxAbs(r) > tolerance && iterations < maxIterations && lambda < 1e12) {\n iterations++;\n loadJacobian(sys, x);\n const before = sumSq(r);\n for (; lambda < 1e12; lambda *= 10) {\n const delta = stepOf(sys, x, r, lambda);\n if (!delta) continue;\n const next = x.map((v, i) => v + delta[i]);\n for (const row of sys.rows) {\n if (row.param >= 0) next[row.param] = Math.min(1, Math.max(0, next[row.param]));\n }\n const rn = residualsOf(sys, next);\n if (sumSq(rn) < before) {\n x.set(next);\n r = rn;\n lambda = Math.max(lambda / 3, 1e-12);\n break;\n }\n }\n }\n\n const out = unpack(x, points);\n const skipped = new Set(opts.skip ?? []);\n const collapsed = collapsedBy(points, out, constraints, skipped);\n const unsatisfied = [...new Set([\n ...unsatisfiedConstraints(out, constraints, {\n axisAngle: opts.axisAngle, axisAngles: opts.axisAngles, reference: opts.reference,\n }),\n ...collapsed,\n ])].sort((a, b) => a - b);\n return {\n points: out,\n converged: maxAbs(r) <= Math.max(tolerance, CONSTRAINT_TOLERANCE) && unsatisfied.every((i) => skipped.has(i)),\n iterations,\n unsatisfied,\n };\n}\n","/**\n * Constraints on a `PolygonPath`: solving them over its anchors, and carrying\n * them through an edit that renumbers the anchors.\n */\n\nimport type { PolygonPath } from '../path';\nimport { anchorPointIndices, type PointOrigin } from '../paths/anchorOrigins';\nimport { anchorAt, editAnchorSet } from '../paths/anchorEdits';\nimport { pathToAnchors } from '../paths/anchors';\nimport type { ConstraintPoint } from './points';\nimport { solveConstraints, type SolveConstraintsOptions, type SolveConstraintsResult } from './solve';\nimport { mapConstraintAnchors, type AnchorPair, type PathConstraint } from './types';\n\n/** Every anchor of `path`, by flat index, with the handles it has. */\nexport function pathAnchorPoints(path: PolygonPath): ConstraintPoint[] {\n return pathToAnchors(path).anchors.flat().map((a) => {\n const p: ConstraintPoint = { x: a.x, y: a.y };\n if (a.inHandle) p.inHandle = { ...a.inHandle };\n if (a.outHandle) p.outHandle = { ...a.outHandle };\n return p;\n });\n}\n\nconst samePoint = (a: { x: number; y: number } | undefined, b: { x: number; y: number } | undefined) =>\n a === b || (!!a && !!b && a.x === b.x && a.y === b.y);\n\n/** Whether the solve moved anchor `p` to `q` or turned either of its handles. */\nconst moved = (p: ConstraintPoint, q: ConstraintPoint) =>\n !samePoint(p, q) || !samePoint(p.inHandle, q.inHandle) || !samePoint(p.outHandle, q.outHandle);\n\n/** {@link solveConstraints} over `path`'s anchors, and `path` with them moved. */\nexport interface SolvePathConstraintsResult extends SolveConstraintsResult {\n /** `path` with each anchor moved where the solve put it, its handles moved with it; `path` itself when none moved. */\n path: PolygonPath;\n}\n\n/**\n * Solve `constraints` over the anchors of `path` and write the result back,\n * carrying each moved anchor's handles with it so its curves keep their\n * shape, except where a `tangent` turned them.\n */\nexport function solvePathConstraints(\n path: PolygonPath,\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions = {},\n): SolvePathConstraintsResult {\n const points = pathAnchorPoints(path);\n const result = solveConstraints(points, constraints, opts);\n return { ...result, path: withAnchorPoints(path, points, result.points) };\n}\n\n/**\n * `path` with its anchors and handles where `to` puts them, given `from`,\n * where they are now; `path` itself when nothing moved.\n */\nexport function withAnchorPoints(\n path: PolygonPath,\n from: readonly ConstraintPoint[],\n to: readonly ConstraintPoint[],\n): PolygonPath {\n const moves = to.flatMap((p, i) => (moved(from[i], p) ? [i] : []));\n if (moves.length === 0) return path;\n const next = editAnchorSet(path, (set) => {\n for (const i of moves) {\n const a = anchorAt(set, i)!;\n const p = to[i];\n a.x = p.x;\n a.y = p.y;\n if (a.inHandle && p.inHandle) a.inHandle = { ...p.inHandle };\n if (a.outHandle && p.outHandle) a.outHandle = { ...p.outHandle };\n }\n });\n return next ?? path;\n}\n\n/**\n * For each anchor of `after`, the anchor of `before` it is: the one whose\n * point `origins` says it was copied from. An anchor the edit made has none.\n * `origins` is what `editAnchorSetTracked` answered for the edit.\n */\nexport function anchorsBefore(\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): (number | undefined)[] {\n const anchorOfPoint = new Map<number, number>();\n anchorPointIndices(before).forEach((point, anchor) => anchorOfPoint.set(point, anchor));\n return anchorPointIndices(after).map((point) => {\n const o = origins[point];\n if (!o || (o.t !== 0 && o.a !== o.b)) return undefined;\n return anchorOfPoint.get(o.a);\n });\n}\n\n/**\n * `constraints` renumbered for the anchors of a path after an edit, given\n * `wasAnchor` — for each new anchor, the old one it is, as\n * {@link anchorsBefore} answers. A constraint naming an anchor the edit\n * removed is dropped; `from` holds each kept one's index in `constraints`.\n */\nexport function remapConstraints(\n constraints: readonly PathConstraint[],\n wasAnchor: readonly (number | undefined)[],\n): { constraints: PathConstraint[]; from: number[] } {\n const now = new Map<number, number>();\n wasAnchor.forEach((old, i) => {\n if (old !== undefined && !now.has(old)) now.set(old, i);\n });\n const out: PathConstraint[] = [];\n const from: number[] = [];\n constraints.forEach((c, i) => {\n const mapped = mapConstraintAnchors(c, (a) => now.get(a));\n if (!mapped) return;\n out.push(mapped);\n from.push(i);\n });\n return { constraints: out, from };\n}\n\n/**\n * The segment of `path` joining anchors `a` and `b`, as the pair in the order\n * the path runs it, or null when no segment joins them.\n */\nexport function segmentBetween(path: PolygonPath, a: number, b: number): AnchorPair | null {\n const { anchors, closed } = pathToAnchors(path);\n let base = 0;\n for (let s = 0; s < anchors.length; s++) {\n const n = anchors[s].length;\n const next = (i: number) => (i + 1 < n ? i + 1 : closed[s] && n > 2 ? 0 : -1);\n for (const [p, q] of [[a, b], [b, a]] as const) {\n const i = p - base;\n if (i >= 0 && i < n && next(i) >= 0 && base + next(i) === q) return [p, q];\n }\n base += n;\n }\n return null;\n}\n\n","/**\n * Finishing an edit of constrained paths so their constraints hold: one path\n * on its own, or several solved together when links — constraints naming\n * anchors of more than one — tie them.\n */\n\nimport type { PolygonPath } from '../path';\nimport type { PointOrigin } from '../paths/anchorOrigins';\nimport { unsatisfiedConstraints } from './check';\nimport {\n anchorsBefore, pathAnchorPoints, remapConstraints, segmentBetween, withAnchorPoints,\n} from './pathConstraints';\nimport type { ConstraintPoint, HandleRef } from './points';\nimport { solveConstraints } from './solve';\nimport { mapConstraintAnchors, type PathConstraint } from './types';\n\n/** Options for {@link constrainPathEdit}. */\nexport interface ConstrainPathEditOptions {\n /**\n * Where each point of the edited path came from, as `editAnchorSetTracked`\n * answers. Absent, the edit is taken to keep every anchor's number, and one\n * that changes the anchor count drops every constraint.\n */\n origins?: readonly (PointOrigin | null)[];\n /** See {@link SolveConstraintsOptions.axisAngle}. */\n axisAngle?: number;\n}\n\n/** What {@link constrainPathEdit} answers. */\nexport interface ConstrainedPathEdit {\n /** The edited path with the constraints holding again. */\n path: PolygonPath;\n /** The constraints renumbered for `path`'s anchors. */\n constraints: PathConstraint[];\n /** Whether every constraint that held before the edit holds after it. */\n converged: boolean;\n /** Indices into `constraints` of the ones that do not hold, including any that already did not before the edit. */\n unsatisfied: number[];\n}\n\n/** One path of a {@link constrainPathsEdit}: its edit, and its own constraints. */\nexport interface PathsEditItem extends ConstrainPathEditOptions {\n before: PolygonPath;\n /** `before` as the edit left it; `before` itself for a path the edit did not touch. */\n after: PolygonPath;\n constraints: readonly PathConstraint[];\n /** For a path the edit left alone: its anchors give way as freely as any the edit did not move, rather than only when the edited paths cannot. */\n yields?: boolean;\n}\n\n/**\n * A constraint across paths. Its anchors are numbered over the anchors of\n * `paths` — indices into the items — one after another in that order: with\n * `paths: [2, 0]` and a 5-anchor item 2, anchor 6 is item 0's anchor 1. Its\n * `horizontal` and `vertical` read the world's axes.\n */\nexport interface PathLink {\n constraint: PathConstraint;\n paths: readonly number[];\n}\n\n/** What {@link constrainPathsEdit} answers. */\nexport interface ConstrainedPathsEdit {\n /** Each item, in order: its path with the constraints holding, and its own constraints renumbered for it. */\n items: { path: PolygonPath; constraints: PathConstraint[]; unsatisfied: number[] }[];\n /** Each link renumbered over its paths' anchors after the edit; null when the edit removed an anchor it names. */\n links: { constraint: PathConstraint | null; satisfied: boolean }[];\n /** Whether every constraint that held before the edit holds after it. */\n converged: boolean;\n}\n\n/** The handles of `now` turned or stretched from where their anchors' `reference` had them. */\nfunction handlesMoved(now: readonly ConstraintPoint[], reference: readonly (ConstraintPoint | undefined)[]): HandleRef[] {\n const offset = (p: ConstraintPoint, h: { x: number; y: number } | undefined) => h && { x: h.x - p.x, y: h.y - p.y };\n // Translating an anchor moves its handles by the same amount, which can round their offsets.\n const near = (a?: { x: number; y: number }, b?: { x: number; y: number }) =>\n a === b || (!!a && !!b && Math.abs(a.x - b.x) <= 1e-9 * (1 + Math.abs(a.x)) && Math.abs(a.y - b.y) <= 1e-9 * (1 + Math.abs(a.y)));\n return now.flatMap((p, anchor) => {\n const r = reference[anchor];\n if (!r) return [];\n const sides: HandleRef[] = [];\n if (!near(offset(p, p.inHandle), offset(r, r.inHandle))) sides.push({ anchor, side: 'in' });\n if (!near(offset(p, p.outHandle), offset(r, r.outHandle))) sides.push({ anchor, side: 'out' });\n return sides;\n });\n}\n\nconst starts = (counts: readonly number[]) => counts.reduce<number[]>((acc, n, i) => [...acc, acc[i] + n], [0]);\n\n/** Link anchor `a`, numbered over `paths` with `counts`, as a global index, given each item's `offsets`. */\nfunction linkToGlobal(link: PathLink, counts: readonly number[], offsets: readonly number[]) {\n const local = starts(link.paths.map((p) => counts[p]));\n return (a: number): number | undefined => {\n for (let k = 0; k < link.paths.length; k++) {\n if (a >= local[k] && a < local[k + 1]) return offsets[link.paths[k]] + a - local[k];\n }\n return undefined;\n };\n}\n\n/** Global index `g` as an item and its anchor there. */\nfunction itemOf(g: number, offsets: readonly number[]): { item: number; anchor: number } {\n let item = 0;\n while (item + 1 < offsets.length - 1 && g >= offsets[item + 1]) item++;\n return { item, anchor: g - offsets[item] };\n}\n\n/**\n * An edit of constrained paths, finished so their constraints and the links\n * between them hold, as one solve over every anchor: the anchors and handles\n * the edit moved are held, and so are the anchors of a path it left alone\n * (`after === before`), except one held on a segment or on a path that\n * `yields`; `fixed` anchors go\n * back to where they were, and the rest move the least they must. A constraint\n * that did not hold before the edit is left out of the solve, and reported.\n * Each item's own `horizontal` and `vertical` read its own `axisAngle`.\n */\nexport function constrainPathsEdit(items: readonly PathsEditItem[], links: readonly PathLink[] = []): ConstrainedPathsEdit {\n const was = items.map((it) => pathAnchorPoints(it.before));\n const now = items.map((it) => pathAnchorPoints(it.after));\n const wasStart = starts(was.map((p) => p.length));\n const nowStart = starts(now.map((p) => p.length));\n const wasAnchor = items.flatMap((it, i) => {\n const map = it.origins\n ? anchorsBefore(it.before, it.after, it.origins)\n : now[i].map((_, j) => (now[i].length === was[i].length ? j : undefined));\n return map.map((old) => (old === undefined ? undefined : wasStart[i] + old));\n });\n\n // Every constraint numbered over all the anchors before the edit, the items' own first.\n const all: PathConstraint[] = [];\n const angles: (number | undefined)[] = [];\n items.forEach((it, i) => it.constraints.forEach((c) => {\n all.push(mapConstraintAnchors(c, (a) => wasStart[i] + a)!);\n angles.push(it.axisAngle);\n }));\n const ownCount = all.length;\n for (const link of links) {\n all.push(mapConstraintAnchors(link.constraint, linkToGlobal(link, was.map((p) => p.length), wasStart))\n ?? { kind: 'fixed', anchor: -1 });\n angles.push(0);\n }\n\n const wasAll = was.flat();\n const nowAll = now.flat();\n const broken = new Set(unsatisfiedConstraints(wasAll, all, { axisAngles: angles }));\n // An `onPath` whose segment the edit split or broke has no segment left to hold its anchor on.\n const remapped = remapConstraints(all, wasAnchor);\n const joined = remapped.constraints.map((c) => {\n if (c.kind !== 'onPath') return true;\n const [a, b] = c.segment.map((g) => itemOf(g, nowStart));\n return a.item === b.item && !!segmentBetween(items[a.item].after, a.anchor, b.anchor);\n });\n const kept = remapped.constraints.filter((_, i) => joined[i]);\n const from = remapped.from.filter((_, i) => joined[i]);\n const skip = from.flatMap((old, i) => (broken.has(old) ? [i] : []));\n const reference = wasAnchor.map((old) => (old === undefined ? undefined : wasAll[old]));\n // A path the edit left alone gives way only when the edited ones cannot, but an anchor held\n // on a segment still follows the segment.\n const sliding = new Set(kept.flatMap((c) => (c.kind === 'onPath' ? [c.anchor] : [])));\n const still = (i: number) => {\n const { item } = itemOf(i, nowStart);\n const it = items[item];\n return items.length > 1 && it.before === it.after && !it.yields && !sliding.has(i);\n };\n const held = nowAll.flatMap((p, i) => {\n const r = reference[i];\n return !r || r.x !== p.x || r.y !== p.y || still(i) ? [i] : [];\n });\n const solved = solveConstraints(nowAll, kept, {\n held, heldHandles: handlesMoved(nowAll, reference), reference, skip, axisAngles: from.map((old) => angles[old]),\n });\n const failing = new Set(solved.unsatisfied);\n\n const outItems: ConstrainedPathsEdit['items'] = items.map((it, i) => ({\n path: withAnchorPoints(it.after, now[i], solved.points.slice(nowStart[i], nowStart[i + 1])),\n constraints: [],\n unsatisfied: [],\n }));\n const outLinks: ConstrainedPathsEdit['links'] = links.map(() => ({ constraint: null, satisfied: false }));\n kept.forEach((c, k) => {\n const old = from[k];\n if (old < ownCount) {\n const { item } = itemOf(constraintFirstAnchor(all[old]), wasStart);\n const out = outItems[item];\n if (failing.has(k)) out.unsatisfied.push(out.constraints.length);\n out.constraints.push(mapConstraintAnchors(c, (g) => g - nowStart[item])!);\n return;\n }\n const link = links[old - ownCount];\n const local = starts(link.paths.map((p) => now[p].length));\n const toLocal = (g: number) => {\n const { item, anchor } = itemOf(g, nowStart);\n const k2 = link.paths.indexOf(item);\n return k2 < 0 ? undefined : local[k2] + anchor;\n };\n outLinks[old - ownCount] = { constraint: mapConstraintAnchors(c, toLocal), satisfied: !failing.has(k) };\n });\n return { items: outItems, links: outLinks, converged: solved.converged };\n}\n\nfunction constraintFirstAnchor(c: PathConstraint): number {\n switch (c.kind) {\n case 'fixed':\n case 'tangent':\n case 'onPath': return c.anchor;\n case 'horizontal':\n case 'vertical':\n case 'length': return c.segment[0];\n case 'coincident': return c.anchors[0];\n default: return c.segments[0][0];\n }\n}\n\n/**\n * An edit of a constrained path, `before` → `after`, finished so its\n * constraints hold: the anchors and handles the edit moved are held, `fixed`\n * anchors go back to where they were, and the rest move the least they must.\n * A constraint that did not hold before the edit conflicts with the others\n * and is left out of the solve rather than allowed to pull them out of true;\n * `unsatisfied` reports it.\n */\nexport function constrainPathEdit(\n before: PolygonPath,\n after: PolygonPath,\n constraints: readonly PathConstraint[],\n opts: ConstrainPathEditOptions = {},\n): ConstrainedPathEdit {\n const done = constrainPathsEdit([{ before, after, constraints, ...opts }]);\n const [item] = done.items;\n return { path: item.path, constraints: item.constraints, converged: done.converged, unsatisfied: item.unsatisfied };\n}\n","/**\n * Which constraints conflict: not merely the ones a failed solve leaves\n * unsatisfied, but a smallest set that cannot all hold together, found by a\n * deletion filter — drop each member in turn, and keep it out when what is\n * left still fails. Every member of the answer is needed for the conflict.\n */\n\nimport { constraintApplies, type ConstraintPoint } from './points';\nimport { solveConstraints } from './solve';\nimport { constraintAnchors, type PathConstraint } from './types';\n\n/** Options for {@link conflictingConstraints}. */\nexport interface ConflictingConstraintsOptions {\n /** Radians the frame `horizontal` and `vertical` read is turned from the world's axes. Default 0. */\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle`. */\n axisAngles?: readonly (number | undefined)[];\n /** Where each anchor belongs for a `fixed` constraint. Default: where it is now. */\n reference?: readonly (ConstraintPoint | undefined)[];\n}\n\n/** Constraints sharing an anchor, directly or through others, as lists of indices into `constraints`. */\nfunction componentsOf(constraints: readonly PathConstraint[], indices: readonly number[]): number[][] {\n const parent = new Map<number, number>();\n const find = (a: number): number => {\n let r = a;\n while (parent.has(r) && parent.get(r) !== r) r = parent.get(r)!;\n parent.set(a, r);\n return r;\n };\n for (const i of indices) {\n const [first, ...rest] = constraintAnchors(constraints[i]);\n for (const a of rest) parent.set(find(a), find(first));\n }\n const groups = new Map<number, number[]>();\n for (const i of indices) {\n const root = find(constraintAnchors(constraints[i])[0]);\n let g = groups.get(root);\n if (!g) groups.set(root, (g = []));\n g.push(i);\n }\n return [...groups.values()];\n}\n\n/**\n * The constraints of `constraints` that conflict over `points`: for every\n * group of them sharing anchors that cannot all hold, a smallest subset that\n * still cannot — each member needed, the later ones in the list kept in\n * preference to the earlier — and every constraint that cannot apply at all.\n * Sorted; empty when every constraint can hold at once.\n */\nexport function conflictingConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: ConflictingConstraintsOptions = {},\n): number[] {\n const all = constraints.map((_, i) => i);\n const applies = all.filter((i) => constraintApplies(constraints[i], points));\n const out = all.filter((i) => !applies.includes(i));\n const holds = (subset: readonly number[]) => {\n const keep = new Set(subset);\n const skip = all.filter((i) => !keep.has(i));\n return solveConstraints(points, constraints, { ...opts, skip }).converged;\n };\n if (holds(applies)) return out;\n for (const group of componentsOf(constraints, applies)) {\n if (holds(group)) continue;\n const set = [...group];\n for (const i of group) {\n const without = set.filter((j) => j !== i);\n if (!holds(without)) set.splice(set.indexOf(i), 1);\n }\n out.push(...set);\n }\n return out.sort((a, b) => a - b);\n}\n","/**\n * Anchor lookup across several paths, measured on screen: which existing\n * anchor is nearest a point, and whether it ends an open subpath. Feeds the\n * pen's anchor snapping and its pick-up of an open path's endpoint.\n */\n\nimport type { PolygonPath } from '../path';\nimport { scaleDelta, type Scale2 } from '../pxExtent';\nimport { pathToAnchors, type PenAnchor } from './anchors';\n\n/** An existing anchor found near a point. */\nexport interface PathAnchorHit {\n /** The id the path was supplied under. */\n id: string;\n /** Subpath index, then anchor index within that subpath. */\n sub: number;\n idx: number;\n x: number;\n y: number;\n /** Which end of an open subpath this anchor is, or null when it is an\n * interior anchor or its subpath is closed. A lone anchor reads `'last'`. */\n end: 'first' | 'last' | null;\n}\n\n/**\n * The anchor nearest `point` within a screen-space circle of radius `px`,\n * across every subpath of every path in `paths`. Paths and `point` share one\n * world frame; `scale` is the view's, so the radius stays round under\n * non-uniform zoom. `accept` narrows the candidates (endpoints only, say).\n * Ties go to the earlier path, so pass paths front-to-back.\n */\nexport function nearestPathAnchor(\n paths: Iterable<{ id: string; path: PolygonPath }>,\n point: { x: number; y: number },\n px: number,\n scale: Scale2,\n accept?: (hit: PathAnchorHit) => boolean,\n): PathAnchorHit | null {\n let best: PathAnchorHit | null = null;\n let bestD2 = px * px;\n for (const { id, path } of paths) {\n const { anchors, closed } = pathToAnchors(path);\n for (let sub = 0; sub < anchors.length; sub++) {\n const list = anchors[sub];\n for (let idx = 0; idx < list.length; idx++) {\n const a = list[idx];\n const s = scaleDelta(a.x - point.x, a.y - point.y, scale);\n const d2 = s.x * s.x + s.y * s.y;\n if (d2 > bestD2 || (best !== null && d2 === bestD2)) continue;\n const end = closed[sub]\n ? null\n : idx === list.length - 1 ? 'last' : idx === 0 ? 'first' : null;\n const hit: PathAnchorHit = { id, sub, idx, x: a.x, y: a.y, end };\n if (accept && !accept(hit)) continue;\n best = hit;\n bestD2 = d2;\n }\n }\n }\n return best;\n}\n\n/** Reverse a subpath's direction without changing its shape: the anchor\n * order flips and each anchor's in and out handles trade places. */\nexport function reverseAnchors<A extends PenAnchor>(anchors: readonly A[]): A[] {\n return anchors.map((a) => {\n const { inHandle, outHandle, ...rest } = a;\n const r = { ...rest } as A;\n if (outHandle) r.inHandle = { ...outHandle };\n if (inHandle) r.outHandle = { ...inHandle };\n return r;\n }).reverse();\n}\n","/**\n * Edits to a path's order rather than its shape: where a subpath starts, and\n * which way it runs. Each mutates an `AnchorSet` in place, like the edits in\n * `anchorEdits`, and moves anchors whole, so anything an anchor carries beside\n * its point and handles travels with it.\n */\n\nimport { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { cubicPointAt } from './cubicMath';\nimport { isStraightSegment, segmentEnds } from './anchors';\nimport { reverseAnchors } from './nearestAnchor';\n\n/**\n * Make the anchor at `flatIndex` its subpath's first. A closed subpath turns\n * so it starts there, keeping its direction. An open subpath can only start\n * at one of its ends: its last anchor makes it run the other way, and an\n * interior anchor changes nothing. Returns whether the set changed.\n */\nexport function setSubpathStart(set: AnchorSet, flatIndex: number): boolean {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || loc.idx === 0) return false;\n const sub = set.anchors[loc.sub];\n if (set.closed[loc.sub]) {\n set.anchors[loc.sub] = [...sub.slice(loc.idx), ...sub.slice(0, loc.idx)];\n return true;\n }\n if (loc.idx !== sub.length - 1) return false;\n set.anchors[loc.sub] = reverseAnchors(sub);\n return true;\n}\n\n/**\n * Run each subpath in `subs` the other way, every one when `subs` is absent.\n * The shape is unchanged: each anchor's handles trade places. A closed\n * subpath keeps its start anchor, as `reversePath` does; an open one starts\n * where it used to end. Returns whether any subpath had a segment to turn.\n */\nexport function reverseSubpaths(set: AnchorSet, subs?: Iterable<number>): boolean {\n const which = subs ? new Set(subs) : set.anchors.map((_, s) => s);\n let changed = false;\n for (const s of which) {\n const sub = set.anchors[s];\n if (!sub || sub.length < 2) continue;\n const back = reverseAnchors(sub);\n // `reverseAnchors` ends on the old start; a closed subpath turns it back to the front.\n set.anchors[s] = set.closed[s] ? [back[back.length - 1], ...back.slice(0, -1)] : back;\n changed = true;\n }\n return changed;\n}\n\n/**\n * Where each anchor at `flatIndexes` sits once `reverseSubpaths(set, subs)`\n * has run: an anchor keeps its point, so a selection can follow it. Indexes\n * outside the set are dropped.\n */\nexport function flatIndexesAfterReverse(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n subs?: Iterable<number>,\n): number[] {\n const which = subs ? new Set(subs) : null;\n const out: number[] = [];\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const n = set.anchors[loc.sub].length;\n if (which && !which.has(loc.sub)) { out.push(flat); continue; }\n const idx = set.closed[loc.sub] ? (n - loc.idx) % n : n - 1 - loc.idx;\n out.push(flat - loc.idx + idx);\n }\n return out;\n}\n\n/** The subpaths holding the anchors at `flatIndexes`, each once, in order. */\nexport function subpathsOfAnchors(set: AnchorSet, flatIndexes: Iterable<number>): number[] {\n const subs = new Set<number>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (loc) subs.add(loc.sub);\n }\n return [...subs].sort((a, b) => a - b);\n}\n\n/** A mark showing which way a path runs: a point on it and the unit vector of its heading there. */\nexport interface DirectionMark {\n x: number;\n y: number;\n dx: number;\n dy: number;\n /** The subpath the mark is on. */\n sub: number;\n}\n\n/**\n * One {@link DirectionMark} at the middle of every segment of `set`, closing\n * segments included, in walk order. A segment with no length gets none.\n */\nexport function directionMarks(set: AnchorSet): DirectionMark[] {\n const out: DirectionMark[] = [];\n set.anchors.forEach((sub, s) => {\n const count = set.closed[s] ? sub.length : sub.length - 1;\n for (let i = 0; i < count; i++) {\n const ends = segmentEnds(set.anchors, set.closed, s, i);\n if (!ends) continue;\n const mark = midMark(ends.a, ends.b);\n if (mark) out.push({ ...mark, sub: s });\n }\n });\n return out;\n}\n\ntype Point = { x: number; y: number };\n\nfunction midMark(a: Point & { outHandle?: Point }, b: Point & { inHandle?: Point }): Omit<DirectionMark, 'sub'> | null {\n if (isStraightSegment(a, b)) return unit({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, b.x - a.x, b.y - a.y);\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const mid = cubicPointAt(a, c1, c2, b, 0.5);\n // The cubic's derivative at t = 1/2, up to a constant factor.\n const dx = (c2.x + b.x) - (a.x + c1.x);\n const dy = (c2.y + b.y) - (a.y + c1.y);\n return unit(mid, dx, dy) ?? unit(mid, b.x - a.x, b.y - a.y);\n}\n\nfunction unit(at: Point, dx: number, dy: number): Omit<DirectionMark, 'sub'> | null {\n const len = Math.hypot(dx, dy);\n return len > 1e-9 ? { x: at.x, y: at.y, dx: dx / len, dy: dy / len } : null;\n}\n","/**\n * Straight and curved segments, converted in place. A segment runs from one\n * anchor to the next, the closing segment of a closed subpath included, and is\n * named `(sub, segIdx)` as `segmentAt` reports it.\n */\n\nimport { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { isStraightSegment, segmentEnds } from './anchors';\n\n/** A segment of an `AnchorSet`: `segIdx === sub.length - 1` is a closed\n * subpath's closing segment. */\nexport interface SegmentRef {\n sub: number;\n segIdx: number;\n}\n\n/** What a segment is made: a line, a curve, or the other of what it is. */\nexport type SegmentType = 'line' | 'curve';\n\n/**\n * The segments both of whose ends are among `flatIndexes`, in walk order.\n * Two adjacent selected anchors select the segment between them; a closed\n * subpath with every anchor selected has all its segments.\n */\nexport function segmentsBetweenAnchors(set: AnchorSet, flatIndexes: Iterable<number>): SegmentRef[] {\n const picked = new Map<number, Set<number>>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n let s = picked.get(loc.sub);\n if (!s) picked.set(loc.sub, (s = new Set()));\n s.add(loc.idx);\n }\n const out: SegmentRef[] = [];\n for (const [sub, idxs] of [...picked].sort((a, b) => a[0] - b[0])) {\n const n = set.anchors[sub].length;\n const count = set.closed[sub] ? n : n - 1;\n for (let i = 0; i < count; i++) {\n if (idxs.has(i) && idxs.has((i + 1) % n)) out.push({ sub, segIdx: i });\n }\n }\n return out;\n}\n\n/** Whether segment `seg` is straight, or null when it does not exist. */\nexport function isSegmentStraight(set: AnchorSet, seg: SegmentRef): boolean | null {\n const ends = segmentEnds(set.anchors, set.closed, seg.sub, seg.segIdx);\n return ends ? isStraightSegment(ends.a, ends.b) : null;\n}\n\n/**\n * Make each segment in `segs` straight or curved without moving its anchors.\n * A line becomes a curve with its handles a third of the way in from each\n * end, which draws the same line; a curve becomes a line by dropping the two\n * handles that shape it, leaving the handles of the segments beside it alone.\n * With no `to`, every segment turns curved when any of them is straight, and\n * straight when all are curved: one press flips the lot.\n *\n * Returns whether any segment changed.\n */\nexport function convertSegments(set: AnchorSet, segs: readonly SegmentRef[], to?: SegmentType): boolean {\n const target = to ?? (segs.some((seg) => isSegmentStraight(set, seg) === true) ? 'curve' : 'line');\n let changed = false;\n for (const seg of segs) {\n const ends = segmentEnds(set.anchors, set.closed, seg.sub, seg.segIdx);\n if (!ends) continue;\n const { a, b } = ends;\n const straight = isStraightSegment(a, b);\n if (target === 'line' && !straight) {\n delete a.outHandle;\n delete b.inHandle;\n changed = true;\n } else if (target === 'curve' && straight) {\n a.outHandle = { x: a.x + (b.x - a.x) / 3, y: a.y + (b.y - a.y) / 3 };\n b.inHandle = { x: b.x + (a.x - b.x) / 3, y: b.y + (a.y - b.y) / 3 };\n changed = true;\n }\n }\n return changed;\n}\n","/**\n * Anchors as numbers a person types: the position of the selected anchors,\n * and for a lone anchor its handles' positions, angles and lengths. Reading\n * answers what a field shows; writing sets a value on every selected anchor,\n * or offsets each by an amount.\n */\n\nimport { anchorAt, moveHandleTo, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\n\n/** One number of an anchor. Handle angles are degrees counterclockwise from\n * +x as drawn, where y grows downward; lengths and positions are in the\n * set's own units. */\nexport type AnchorField =\n | 'x' | 'y'\n | 'inX' | 'inY' | 'inAngle' | 'inLength'\n | 'outX' | 'outY' | 'outAngle' | 'outLength';\n\n/** Every {@link AnchorField}, in the order a panel lists them. */\nexport const ANCHOR_FIELDS: readonly AnchorField[] = [\n 'x', 'y', 'inX', 'inY', 'inAngle', 'inLength', 'outX', 'outY', 'outAngle', 'outLength',\n];\n\n/** What a typed field asks for: a value for every anchor, or an amount added to each one's own. */\nexport type NumberEntry = { to: number } | { by: number };\n\n/**\n * What each field shows for the anchors at `flatIndexes`: a number where\n * they agree, `null` where they differ, and no key for a field that does not\n * apply. Position applies to any selection; handle fields only to a single\n * anchor, and only for a handle it has.\n */\nexport type AnchorFieldValues = Partial<Record<AnchorField, number | null>>;\n\n/** Differences below this read as agreement, so float noise does not show as mixed. */\nconst SAME = 1e-6;\n\n/** The fields for the anchors at `flatIndexes`; `{}` when none of them exists. */\nexport function readAnchorFields(set: AnchorSet, flatIndexes: Iterable<number>): AnchorFieldValues {\n const anchors = [...new Set(flatIndexes)].flatMap((flat) => anchorAt(set, flat) ?? []);\n if (anchors.length === 0) return {};\n const out: AnchorFieldValues = { x: agreed(anchors.map((a) => a.x)), y: agreed(anchors.map((a) => a.y)) };\n if (anchors.length !== 1) return out;\n const [a] = anchors;\n for (const side of ['in', 'out'] as const) {\n const h = handleOf(a, side);\n if (!h) continue;\n out[`${side}X`] = h.x;\n out[`${side}Y`] = h.y;\n out[`${side}Angle`] = angleOf(a, h);\n out[`${side}Length`] = Math.hypot(h.x - a.x, h.y - a.y);\n }\n return out;\n}\n\n/**\n * Write `entry` into `field` of every anchor at `flatIndexes`. Moving an\n * anchor carries its handles. A handle field moves the handle as a drag to\n * the typed spot would (`moveHandleTo`): on a smooth anchor the opposite\n * handle mirrors it, taking its turn and its length, and on a corner it stays\n * where it is. An anchor without that handle is skipped. An angle keeps the\n * handle's length, and a length keeps its angle. Returns whether anything\n * moved.\n */\nexport function writeAnchorField(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n field: AnchorField,\n entry: NumberEntry,\n): boolean {\n if (!Number.isFinite('to' in entry ? entry.to : entry.by)) return false;\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const a = anchorAt(set, flat);\n if (!a) continue;\n if (field === 'x' || field === 'y') {\n const next = apply(a[field], entry);\n if (next === a[field]) continue;\n translateAnchorBy(set, flat, field === 'x' ? next - a.x : 0, field === 'y' ? next - a.y : 0);\n changed = true;\n continue;\n }\n const side = field.startsWith('in') ? 'in' : 'out';\n const h = handleOf(a, side);\n if (!h) continue;\n const to = handleTarget(a, h, field.slice(side.length) as 'X' | 'Y' | 'Angle' | 'Length', entry);\n if (to.x === h.x && to.y === h.y) continue;\n moveHandleTo(set, flat, side, to.x, to.y, false);\n changed = true;\n }\n return changed;\n}\n\ntype Point = { x: number; y: number };\n\nfunction handleOf(a: PenAnchor, side: 'in' | 'out'): Point | undefined {\n return side === 'in' ? a.inHandle : a.outHandle;\n}\n\nfunction handleTarget(a: PenAnchor, h: Point, part: 'X' | 'Y' | 'Angle' | 'Length', entry: NumberEntry): Point {\n if (part === 'X') return { x: apply(h.x, entry), y: h.y };\n if (part === 'Y') return { x: h.x, y: apply(h.y, entry) };\n const length = Math.hypot(h.x - a.x, h.y - a.y);\n const angle = angleOf(a, h);\n const nextAngle = part === 'Angle' ? apply(angle, entry) : angle;\n const nextLength = part === 'Length' ? Math.max(0, apply(length, entry)) : length;\n const rad = (nextAngle * Math.PI) / 180;\n return { x: a.x + Math.cos(rad) * nextLength, y: a.y - Math.sin(rad) * nextLength };\n}\n\nfunction apply(current: number, entry: NumberEntry): number {\n return 'to' in entry ? entry.to : current + entry.by;\n}\n\nfunction angleOf(a: Point, h: Point): number {\n if (h.x === a.x && h.y === a.y) return 0;\n return (Math.atan2(a.y - h.y, h.x - a.x) * 180) / Math.PI;\n}\n\nfunction agreed(values: number[]): number | null {\n const first = values[0];\n return values.every((v) => Math.abs(v - first) < SAME) ? first : null;\n}\n","/**\n * Project a leaf path from its source frame into world coordinates given a\n * `{x, y, width, height, rotation?}` pose.\n *\n * RectPaths can't carry rotation as-is (they're axis-aligned by definition);\n * a non-zero `pose.rotation` on a rect promotes the result to a polygon so\n * the four corners are baked into world coords.\n */\n\nimport { applyToPoint, boxToBox } from '../affine';\nimport type { Path, PolygonPath } from '../path';\nimport { poseFrameInverseOf, poseFrameOf, type PoseLinear } from '../poseFrame';\nimport { boundsOfPath } from './bounds';\nimport { translatePath } from './transform';\nimport { transformPath } from './transformPath';\n\n/** Subset of pose fields this helper consumes: `x/y/width/height` define an\n * AABB whose unrotated center is the rotation pivot. */\nexport interface PathInWorldPose {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n transform?: PoseLinear;\n}\n\n/**\n * Project a stored path into the pose's **local frame**: rebase its AABB onto\n * the pose box. It does NOT apply `pose.rotation`; `pathInWorld` composes\n * this with the rotation wrap.\n *\n * Rects rebase onto the pose's `width`/`height` because resize updates the pose,\n * not the stored `RectPath` — so the live size lives on the pose.\n */\nexport function pathInPoseFrame(path: Path, pose: PathInWorldPose): Path {\n if (path.kind === 'rect') {\n if (\n path.x === pose.x && path.y === pose.y\n && path.width === pose.width && path.height === pose.height\n ) return path;\n return { kind: 'rect', x: pose.x, y: pose.y, width: pose.width, height: pose.height };\n }\n // Polygon: rebase the path's own AABB into the pose box. For geometry-in-data\n // nodes whose pose box was resized independently, it scales the contents to fill the box.\n const b = boundsOfPath(path);\n if (b.x === pose.x && b.y === pose.y && b.width === pose.width && b.height === pose.height) {\n return path;\n }\n const m = boxToBox(b.x, b.y, b.width, b.height, pose.x, pose.y, pose.width, pose.height);\n return transformPath(path, m);\n}\n\n/**\n * Bake `pose` into `path`'s coordinates so the returned path is positioned\n * in world space. Returns a fresh `Path` instance; never mutates inputs.\n */\nexport function pathInWorld(path: Path, pose: PathInWorldPose): Path {\n // Shares `pathInPoseFrame` with the renderer so world geometry never diverges\n // from what's painted.\n const local = pathInPoseFrame(path, pose);\n\n // The pose's rotation and its `transform` about its AABB center, composed by\n // `poseFrameOf` as the renderer's wrap composes them.\n const frame = poseFrameOf(pose);\n if (!frame) return local;\n return transformPath(local, frame) as PolygonPath;\n}\n\n/**\n * Inverse of `pathInWorld` for a path in **world** space: the stored path\n * in the pose's own frame plus the pose that draws it there. The pose's\n * `rotation` and `transform` are preserved, and its AABB fields are fit to\n * the result. The new box's center is placed where the old frame carries it,\n * since the pivot moves with the box: `pathInWorld(result.path, result.pose)`\n * reproduces `worldPath` whether or not its bounds changed.\n */\nexport function worldEditToStorage<P extends PathInWorldPose>(\n pose: P,\n worldPath: PolygonPath,\n): { pose: P; path: PolygonPath };\nexport function worldEditToStorage<P extends PathInWorldPose>(pose: P, worldPath: Path): { pose: P; path: Path };\nexport function worldEditToStorage<P extends PathInWorldPose>(\n pose: P,\n worldPath: Path,\n): { pose: P; path: Path } {\n // A singular `transform` has no way back, and the path is stored as drawn.\n const back = poseFrameInverseOf(pose);\n const frame = back && poseFrameOf(pose);\n const unrotated = back ? transformPath(worldPath, back) : worldPath;\n const b = boundsOfPath(unrotated);\n const aligned = translatePath(unrotated, -b.x, -b.y);\n let x = b.x, y = b.y;\n if (frame) {\n const [cx, cy] = applyToPoint(frame, b.x + b.width / 2, b.y + b.height / 2);\n x = cx - b.width / 2;\n y = cy - b.height / 2;\n }\n return {\n pose: { ...pose, x, y, width: b.width, height: b.height },\n path: aligned,\n };\n}\n","/** The constructor of each typed array of numbers, under the tag its type is written by. */\nexport const TYPED_ARRAY_CONSTRUCTORS = {\n i8: Int8Array,\n u8: Uint8Array,\n u8c: Uint8ClampedArray,\n i16: Int16Array,\n u16: Uint16Array,\n i32: Int32Array,\n u32: Uint32Array,\n f32: Float32Array,\n f64: Float64Array,\n} as const;\n\n/** The name a typed array's type is written under. */\nexport type TypedArrayTag = keyof typeof TYPED_ARRAY_CONSTRUCTORS;\n\n/** A typed array of numbers: what a `Path` keeps its commands and coords in. */\nexport type NumberTypedArray = InstanceType<(typeof TYPED_ARRAY_CONSTRUCTORS)[TypedArrayTag]>;\n\n/** A typed array as JSON holds it: its type's tag and its numbers. */\nexport interface TaggedTypedArray {\n __ta: TypedArrayTag;\n data: number[];\n}\n\nconst TAGS = new Map<string, TypedArrayTag>(\n (Object.keys(TYPED_ARRAY_CONSTRUCTORS) as TypedArrayTag[]).map((tag) => [TYPED_ARRAY_CONSTRUCTORS[tag].name, tag]),\n);\n\n// By its string tag rather than `instanceof`, which is false for an array made in another realm.\nconst classOf = (value: unknown): string => Object.prototype.toString.call(value).slice(8, -1);\n\n/** `value` as a tag and its numbers where it is a typed array of numbers, else `undefined`. */\nexport function tagTypedArray(value: unknown): TaggedTypedArray | undefined {\n if (!ArrayBuffer.isView(value)) return undefined;\n const tag = TAGS.get(classOf(value));\n return tag && { __ta: tag, data: Array.from(value as NumberTypedArray) };\n}\n\n/** The typed array a `TaggedTypedArray` describes, or `undefined` for anything else. */\nexport function untagTypedArray(value: unknown): NumberTypedArray | undefined {\n if (value === null || typeof value !== 'object') return undefined;\n const { __ta: tag, data } = value as Partial<TaggedTypedArray>;\n if (typeof tag !== 'string' || !Object.hasOwn(TYPED_ARRAY_CONSTRUCTORS, tag) || !Array.isArray(data)) return undefined;\n return TYPED_ARRAY_CONSTRUCTORS[tag].from(data);\n}\n\nconst isPlain = (value: unknown): value is Record<string, unknown> => classOf(value) === 'Object';\n\nfunction mapDeep(value: unknown, leaf: (v: unknown) => unknown): unknown {\n const swapped = leaf(value);\n if (swapped !== undefined) return swapped;\n if (Array.isArray(value)) return value.map((v) => mapDeep(v, leaf));\n if (!isPlain(value)) return value;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)) out[key] = mapDeep(value[key], leaf);\n return out;\n}\n\n/**\n * A copy of `value` that `JSON.stringify` writes whole: every typed array in it, at any\n * depth of arrays and plain objects, becomes a `TaggedTypedArray`. A `Path` goes through it\n * to be saved, and `reviveTypedArrays` reads it back.\n */\nexport function tagTypedArrays(value: unknown): unknown {\n return mapDeep(value, tagTypedArray);\n}\n\n/** A copy of `value` with every `TaggedTypedArray` in it a typed array again: what\n * `JSON.parse` answered for something `tagTypedArrays` or `typedArrayReplacer` wrote. */\nexport function reviveTypedArrays(value: unknown): unknown {\n return mapDeep(value, untagTypedArray);\n}\n\n/** `tagTypedArrays` as a `JSON.stringify` replacer. */\nexport function typedArrayReplacer(_key: string, value: unknown): unknown {\n return tagTypedArray(value) ?? value;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/view.ts","../src/affine.ts","../src/track/shape.ts","../src/track/arc.ts","../src/track/ellipse.ts","../src/paths/pathMeasure.ts","../src/track/path.ts","../src/track/run.ts","../src/paths/pathToD.ts","../src/track/pathData.ts","../src/track/shift.ts","../src/track/slice.ts","../src/track/place.ts","../src/portCurve2.ts","../src/pathSubpaths.ts","../src/screenBand.ts","../src/pathHitTest.ts","../src/paths/cornerOffset.ts","../src/paths/unionBoundsPath.ts","../src/paths/transformPath.ts","../src/paths/transform.ts","../src/paths/compose.ts","../src/paths/splitSubpaths.ts","../src/paths/splitByClosure.ts","../src/paths/winding.ts","../src/paths/pathFromD.ts","../src/paths/pathAt.ts","../src/paths/cubicContours.ts","../src/paths/blendPaths.ts","../src/paths/bendAlongPath.ts","../src/paths/repeatAlongPath.ts","../src/paths/pathDistance.ts","../src/intersect/segmentIntersections.ts","../src/intersect/pathSegments.ts","../src/intersect/pathCrossings.ts","../src/paths/segmentLength.ts","../src/snap/segmentFeatures.ts","../src/snap/pathSnap.ts","../src/intersect/writeSubpaths.ts","../src/paths/trimPath.ts","../src/paths/pathAwayFromAnchors.ts","../src/paths/anchorOrigins.ts","../src/pxExtent.ts","../src/paths/spanFit.ts","../src/paths/anchorEdits.ts","../src/paths/lengthenPathEnd.ts","../src/paths/extendPath.ts","../src/paths/simplifyPath.ts","../src/paths/growRegion.ts","../src/paths/segmentCrossings.ts","../src/paths/mergeRegion.ts","../src/paths/simplifyAnchors.ts","../src/paths/arcRun.ts","../src/paths/resamplePath.ts","../src/paths/extremaAnchors.ts","../src/paths/anchorSelection.ts","../src/paths/joinAnchors.ts","../src/affineFit.ts","../src/paths/markers.ts","../src/glMat3.ts","../src/viewToMat3.ts","../src/place.ts","../src/easings.ts","../src/easingSpec.ts","../src/meanScale.ts","../src/poseRotation.ts","../src/poseFrame.ts","../src/paths/anchorBrush.ts","../src/paths/anchorSymmetry.ts","../src/paths/bendSegment.ts","../src/paths/smudgePath.ts","../src/paths/handleEdits.ts","../src/paths/softSelection.ts","../src/paths/balanceHandles.ts","../src/paths/harmonize.ts","../src/paths/anchorValues.ts","../src/constraints/types.ts","../src/constraints/residuals.ts","../src/constraints/points.ts","../src/constraints/check.ts","../src/constraints/sparse.ts","../src/constraints/solve.ts","../src/constraints/pathConstraints.ts","../src/constraints/pathsEdit.ts","../src/constraints/conflicts.ts","../src/paths/nearestAnchor.ts","../src/paths/pathStructure.ts","../src/paths/segmentType.ts","../src/paths/anchorFields.ts","../src/paths/pathInWorld.ts","../src/typedArrayJson.ts"],"names":["dx","dy","length","normal","sign","at","offset","RAD","mod360","measure","options","reversed","num","SAMPLES","dot","moved","run","place","point","portControls","portCurvePoints","sub","neg","winding","scaled","emit","rotate","stretch","along","EPS","worst","GL_W","speed","seen","near","segs","n","held","scale","segmentAt","isCorner","a","b","MAX_DEPTH","startTangent","cross","segmentsCross","unit","END","flatten","boxOf","refine","s","t","derivative","snap","keepCorners","starts","reverseInPlace","identity","multiply","invert","linear","len2","apply","other","same","segmentControls","lerp","crossing","neighbors","collapsed","anchorOfPoint"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBO,IAAM,UAAA,GAAa;AAOnB,SAAS,cAAc,IAAA,EAAsB;AAClD,EAAA,OAAO,IAAA,IAAQ,UAAA,IAAc,IAAA,GAAO,QAAA,GAAW,IAAA,GAAO,UAAA;AACxD;;;ACfO,SAAS,QAAA,GAAmB;AACjC,EAAA,OAAO,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAC,CAAA;AAC1B;AAGO,SAAS,SAAA,CAAU,IAAY,EAAA,EAAoB;AACxD,EAAA,OAAO,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,IAAI,EAAE,CAAA;AAC5B;AAIO,SAAS,KAAA,CAAM,IAAY,EAAA,EAAoB;AACpD,EAAA,OAAO,CAAC,EAAA,EAAI,CAAA,EAAG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AQ,IAAI,GAAG,OAAO,MAAA;AAC7G,EAAA,OAAO,wBAAA,CAAyB,GAAG,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAChD;AAEA,IAAM,OAAA,GAAU,CAAC,KAAA,KAAqD,OAAA,CAAQ,KAAK,CAAA,KAAM,QAAA;AAEzF,SAAS,OAAA,CAAQ,OAAgB,IAAA,EAAwC;AACvE,EAAA,MAAM,OAAA,GAAU,KAAK,KAAK,CAAA;AAC1B,EAAA,IAAI,OAAA,KAAY,QAAW,OAAO,OAAA;AAClC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,KAAM,OAAA,CAAQ,CAAA,EAAG,IAAI,CAAC,CAAA;AAClE,EAAA,IAAI,CAAC,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA;AAC5B,EAAA,MAAM,MAA+B,EAAC;AACtC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG,GAAA,CAAI,GAAG,CAAA,GAAI,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,EAAG,IAAI,CAAA;AACzE,EAAA,OAAO,GAAA;AACT;AAOO,SAAS,eAAe,KAAA,EAAyB;AACtD,EAAA,OAAO,OAAA,CAAQ,OAAO,aAAa,CAAA;AACrC;AAIO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,OAAO,OAAA,CAAQ,OAAO,eAAe,CAAA;AACvC;AAGO,SAAS,kBAAA,CAAmB,MAAc,KAAA,EAAyB;AACxE,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,IAAK,KAAA;AACjC","file":"index.js","sourcesContent":["/**\n * Viewport state. `(view.x, view.y)` is the world point currently rendered at\n * the canvas top-left; `view.scale.x` / `view.scale.y` is pixels per world\n * unit on each axis.\n *\n * A `View` names no orientation, so a kernel with a camera cannot express its\n * viewport as one.\n */\nexport interface View {\n x: number;\n y: number;\n scale: { x: number; y: number };\n}\n\n/**\n * The smallest zoom magnitude a view can hold, in `View.scale` units.\n *\n * A view's zoom is always finite and at least this far from 0. Nothing can be\n * drawn or picked through a zoom of 0, and every screen↔world conversion\n * divides by it, so it is ruled out where views are made rather than handled\n * by each conversion.\n */\nexport const ZOOM_FLOOR = 1e-9;\n\n/**\n * The one rule for a zoom magnitude: a finite number no smaller than\n * {@link ZOOM_FLOOR}. Anything else (0, negative, NaN, ±Infinity) becomes the\n * floor.\n */\nexport function normalizeZoom(zoom: number): number {\n return zoom >= ZOOM_FLOOR && zoom < Infinity ? zoom : ZOOM_FLOOR;\n}\n","/**\n * 2D affine transforms in canvas/DOMMatrix order: [a, b, c, d, e, f].\n * x' = a·x + c·y + e\n * y' = b·x + d·y + f\n * Represented as a readonly 6-tuple (f64). The affine tier of the kernel.\n *\n * `glMat3.ts` beside this file holds the renderer's matrix: a 9-element\n * column-major array (a full 3×3) laid out for `uniformMatrix3fv`. Its\n * *logical element order* is identical to ours.\n */\nimport { SINGULAR_RATIO } from './scalar';\n\n/** `[a, b, c, d, e, f]`: `x' = a·x + c·y + e`, `y' = b·x + d·y + f`. */\nexport type Affine = readonly [number, number, number, number, number, number];\n\n/** The transform that leaves a point where it is. */\nexport function identity(): Affine {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/** A pure translation by `(tx, ty)`. */\nexport function translate(tx: number, ty: number): Affine {\n return [1, 0, 0, 1, tx, ty];\n}\n\n/** A pure scale about the origin. Scale about another point by composing\n * translate → scale → inverse translate with `multiply`. */\nexport function scale(sx: number, sy: number): Affine {\n return [sx, 0, 0, sy, 0, 0];\n}\n\n/** A pure rotation about the origin, in radians, clockwise in canvas\n * coordinates (y down). */\nexport function rotate(rad: number): Affine {\n const c = Math.cos(rad);\n const s = Math.sin(rad);\n return [c, s, -s, c, 0, 0];\n}\n\n/** Compose: result applies `n` first, then `m` (m·n). */\nexport function multiply(m: Affine, n: Affine): Affine {\n return [\n m[0] * n[0] + m[2] * n[1],\n m[1] * n[0] + m[3] * n[1],\n m[0] * n[2] + m[2] * n[3],\n m[1] * n[2] + m[3] * n[3],\n m[0] * n[4] + m[2] * n[5] + m[4],\n m[1] * n[4] + m[3] * n[5] + m[5],\n ];\n}\n\n/** Inverse, or null when the matrix is singular, non-finite, or too\n * ill-conditioned to invert meaningfully at its own scale. */\nexport function invert(m: Affine): Affine | null {\n const det = m[0] * m[3] - m[1] * m[2];\n // The determinant is an area, so it is judged against the squared column norms.\n const norm2 = Math.max(m[0] * m[0] + m[1] * m[1], m[2] * m[2] + m[3] * m[3]);\n // Negated so a non-finite determinant falls out as singular.\n if (!(Math.abs(det) > SINGULAR_RATIO * norm2)) return null;\n const id = 1 / det;\n const a = m[3] * id;\n const b = -m[1] * id;\n const c = -m[2] * id;\n const d = m[0] * id;\n return [a, b, c, d, -(m[4] * a + m[5] * c), -(m[4] * b + m[5] * d)];\n}\n\n/** Apply to a point, returning a tuple. Cold-path use; hot loops inline. */\nexport function applyToPoint(m: Affine, x: number, y: number): [number, number] {\n return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];\n}\n\n/** Affine that maps source box (sx,sy,sw,sh) onto destination box (dx,dy,dw,dh). */\nexport function boxToBox(\n sx: number, sy: number, sw: number, sh: number,\n dx: number, dy: number, dw: number, dh: number,\n): Affine {\n const kx = sw === 0 ? 1 : dw / sw;\n const ky = sh === 0 ? 1 : dh / sh;\n // translate(dx,dy) · scale(kx,ky) · translate(-sx,-sy)\n return [kx, 0, 0, ky, dx - sx * kx, dy - sy * ky];\n}\n\n/** Rotation by `rad` about pivot (cx,cy): translate(c)·rotate·translate(-c). */\nexport function rotateAboutPoint(cx: number, cy: number, rad: number): Affine {\n return multiply(translate(cx, cy), multiply(rotate(rad), translate(-cx, -cy)));\n}\n\n/**\n * Apply an affine to an interleaved coord stream, returning a fresh f64\n * buffer. Command codes are unaffected — for a Bezier the transformed control\n * points define the transformed curve exactly (affine invariance), so callers\n * pass `path.coords` straight through and keep `path.commands` as-is.\n */\nexport function transformCoords(coords: ArrayLike<number>, m: Affine): Float64Array {\n const out = new Float64Array(coords.length);\n const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];\n for (let i = 0; i + 1 < coords.length; i += 2) {\n const x = coords[i], y = coords[i + 1];\n out[i] = a * x + c * y + e;\n out[i + 1] = b * x + d * y + f;\n }\n return out;\n}\n","import { nearestOnLine } from '../nearest';\nimport type { Point } from '../paths/cubicMath';\nimport type { PathStation } from '../paths/pathMeasure';\nimport { clamp } from '../scalar';\n\n/** A station on a track, plus the side items stand on. */\nexport interface TrackStation extends PathStation {\n /** Unit vector the items stand on: away from an arc's center, left of travel on a line. */\n normal: Point;\n}\n\n/** The nearest spot on a track to a point: its fraction along and the distance to it. */\nexport interface TrackNearest {\n f: number;\n dist: number;\n}\n\n/** How `nearest` treats a track's ends. */\nexport interface TrackNearestOptions {\n /** Let `f` run on past 0 and 1: a line extends straight, an arc, an ellipse or a closed path round itself, unwrapped about\n * `about`. A shape that cannot extend clamps. `dist` is to the track either way. */\n open?: boolean;\n /** Where along the track an open arc is unwrapped about, in the same terms as the `f` this `nearest` answers (a\n * `TrackRun` reads it in reading order): a point is placed on whichever side of it is nearer by angle. Default 0.5,\n * the middle. */\n about?: number;\n}\n\n/** How `at` treats a fraction past 0 or 1. */\nexport interface TrackAtOptions {\n /** Carry on past the ends rather than clamp: a line and an open path straight along their end, an arc and an ellipse\n * round themselves, a closed path round its contour. Default false. */\n open?: boolean;\n}\n\n/** Which family a track shape belongs to. `'path'` is a shape over a measured `Path` (`pathShape`). */\nexport type TrackShapeKind = 'line' | 'arc' | 'ellipse' | 'path';\n\n/** A curve a control lies along, addressed by fraction 0..1 of its length. */\nexport interface TrackShape {\n readonly kind: TrackShapeKind;\n readonly length: number;\n /** True when the track's end meets its start: a whole circle or ellipse, or a path that is one closed contour. */\n readonly closed: boolean;\n /** The station at fraction `f`, clamped to 0..1 unless `options.open`. */\n at(f: number, options?: TrackAtOptions): TrackStation;\n /** The spot on the track nearest `p`. */\n nearest(p: Point, options?: TrackNearestOptions): TrackNearest;\n}\n\n/** A straight track from `from` to `to`; its normal is the left of travel. */\nexport function lineShape(from: Point, to: Point): TrackShape {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n const length = Math.hypot(dx, dy);\n const tangent = length === 0 ? { x: 1, y: 0 } : { x: dx / length, y: dy / length };\n const normal = { x: tangent.y, y: -tangent.x };\n return {\n kind: 'line',\n length,\n closed: false,\n at(f, options) {\n const t = options?.open ? f : clamp(f, 0, 1);\n return {\n point: { x: from.x + t * dx, y: from.y + t * dy },\n tangent: { ...tangent },\n normal: { ...normal },\n };\n },\n nearest(p, options) {\n const n = nearestOnLine(p.x, p.y, from.x, from.y, to.x, to.y);\n if (!options?.open || length === 0) return { f: n.t, dist: n.dist };\n const f = ((p.x - from.x) * dx + (p.y - from.y) * dy) / (length * length);\n return { f, dist: n.dist };\n },\n };\n}\n","import type { Point } from '../paths/cubicMath';\nimport { clamp } from '../scalar';\nimport type { TrackAtOptions, TrackShape, TrackStation } from './shape';\n\n/** An arc track: degrees clockwise from 12 o'clock on a y-down plane. Equal `start` and `end` is a whole circle. */\nexport interface ArcTrackSpec {\n center: Point;\n radius: number;\n start: number;\n end: number;\n /** Which way the track runs from `start` to `end`. Default `'cw'`. */\n direction?: 'cw' | 'ccw';\n}\n\nconst RAD = Math.PI / 180;\nconst mod360 = (a: number): number => ((a % 360) + 360) % 360;\n\n/** A track shape that remembers the arc it was built from, so path data can be drawn as arcs. */\nexport type ArcTrackShape = TrackShape & { readonly arc: ArcTrackSpec };\n\n/** An arc track; its normal points away from the center, whichever way it runs. */\nexport function arcShape(spec: ArcTrackSpec): ArcTrackShape {\n const { center, radius, start } = spec;\n const sign = spec.direction === 'ccw' ? -1 : 1;\n const raw = mod360(sign * (spec.end - start));\n const sweep = raw === 0 ? 360 : raw;\n const length = radius * sweep * RAD;\n\n const at = (f: number, options?: TrackAtOptions): TrackStation => {\n const t = options?.open ? f : clamp(f, 0, 1);\n const theta = (start + sign * t * sweep) * RAD;\n const s = Math.sin(theta);\n const c = Math.cos(theta);\n return {\n point: { x: center.x + radius * s, y: center.y - radius * c },\n tangent: { x: sign * c, y: sign * s },\n normal: { x: s, y: -c },\n };\n };\n\n const shape: TrackShape = {\n kind: 'arc',\n length,\n closed: raw === 0,\n at,\n nearest(p, options) {\n const dx = p.x - center.x;\n const dy = p.y - center.y;\n const angle = dx === 0 && dy === 0 ? 0 : Math.atan2(dx, -dy) / RAD;\n const offset = mod360(sign * (angle - start));\n let f: number;\n if (offset <= sweep) f = offset / sweep;\n else f = 360 - offset < offset - sweep ? 0 : 1;\n const q = at(f).point;\n const dist = Math.hypot(p.x - q.x, p.y - q.y);\n if (!options?.open) return { f, dist };\n const mid = (options.about ?? 0.5) * sweep;\n const unwrapped = mid + mod360(offset - mid + 180) - 180;\n return { f: unwrapped / sweep, dist };\n },\n };\n Object.defineProperty(shape, 'arc', { value: spec, enumerable: false });\n return shape as ArcTrackShape;\n}\n","import type { Point } from '../paths/cubicMath';\nimport { clamp } from '../scalar';\nimport type { TrackAtOptions, TrackNearest, TrackShape, TrackStation } from './shape';\n\n/** An axis-aligned elliptical arc track. `start` and `end` are directions seen from the center, in degrees clockwise\n * from 12 o'clock on a y-down plane, as an arc's are; equal `start` and `end` is the whole ellipse. */\nexport interface EllipseTrackSpec {\n center: Point;\n /** Half the width. */\n radiusX: number;\n /** Half the height. */\n radiusY: number;\n start: number;\n end: number;\n /** Which way the track runs from `start` to `end`. Default `'cw'`. */\n direction?: 'cw' | 'ccw';\n}\n\n/** A track shape that remembers the ellipse it was built from, so path data can be drawn as elliptical arcs. */\nexport type EllipseTrackShape = TrackShape & { readonly ellipse: EllipseTrackSpec };\n\nconst RAD = Math.PI / 180;\nconst mod360 = (a: number): number => ((a % 360) + 360) % 360;\n/** Pieces the sweep is cut into for the length table, and Simpson panels in each. */\nconst PIECES = 128;\nconst PANELS = 4;\n/** Samples round the whole ellipse an open `nearest` starts its search from. */\nconst RING = 256;\n\n/** The ellipse in sweep offsets: degrees of its own parameter from the track's start, in the track's direction. */\ninterface Param {\n center: Point;\n a: number;\n b: number;\n /** The start's parameter, clockwise from 12 o'clock: the point at `t` is (a sin t, -b cos t) from the center. */\n t0: number;\n sign: 1 | -1;\n}\n\nconst pointAt = ({ center, a, b, t0, sign }: Param, u: number): Point => {\n const t = (t0 + sign * u) * RAD;\n return { x: center.x + a * Math.sin(t), y: center.y - b * Math.cos(t) };\n};\n\n/** Length along the ellipse per degree of offset at `u`. */\nconst speed = ({ a, b, t0, sign }: Param, u: number): number => {\n const t = (t0 + sign * u) * RAD;\n return Math.hypot(a * Math.cos(t), b * Math.sin(t)) * RAD;\n};\n\n/** The length table over `sweep` degrees: the length to any offset, and the offset at any fraction of the length. */\nfunction lengthTable(e: Param, sweep: number) {\n const simpson = (u0: number, u1: number) => {\n const h = (u1 - u0) / PANELS;\n let sum = speed(e, u0) + speed(e, u1);\n for (let i = 1; i < PANELS; i++) sum += speed(e, u0 + i * h) * (i % 2 ? 4 : 2);\n return (sum * h) / 3;\n };\n const du = sweep / PIECES;\n const table = [0];\n for (let i = 0; i < PIECES; i++) table.push(table[i]! + simpson(i * du, (i + 1) * du));\n const length = table[PIECES]!;\n\n /** Length from the start to offset `u`, negative before the start; beyond the sweep, by integration. */\n const lengthTo = (u: number): number => {\n if (u >= 0 && u <= sweep) {\n const i = Math.min(PIECES - 1, Math.floor(u / du));\n return table[i]! + simpson(i * du, u);\n }\n const n = Math.max(1, Math.ceil(Math.abs(u) / du));\n let s = 0;\n for (let i = 0; i < n; i++) s += simpson((u * i) / n, (u * (i + 1)) / n);\n return s;\n };\n const offsetAt = (f: number): number => {\n if (length === 0) return f * sweep;\n const s = f * length;\n let lo = 0;\n let hi = PIECES;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (table[mid]! <= s) lo = mid;\n else hi = mid;\n }\n const piece = table[lo + 1]! - table[lo]!;\n let u = (lo + (piece === 0 ? 0 : (s - table[lo]!) / piece)) * du;\n // The table's straight-line guess, made consistent with `lengthTo`, which `nearest` answers through.\n for (let i = 0; i < 3; i++) {\n const v = speed(e, u);\n if (!(v > 0)) break;\n u -= (lengthTo(u) - s) / v;\n }\n return u;\n };\n return { length, lengthTo, offsetAt };\n}\n\nconst dist2 = (e: Param, p: Point, u: number) => {\n const q = pointAt(e, u);\n return (p.x - q.x) ** 2 + (p.y - q.y) ** 2;\n};\n\n/**\n * The offset nearest `p` among `n` samples from `lo` to `hi`, refined by Newton's method within a sample of it. A tie\n * goes to the later sample when `late`, else the earlier: an arc's tie between its ends goes to its end, and an open\n * one's, half a turn from `about`, to the side before it.\n */\nfunction footBetween(e: Param, p: Point, lo: number, hi: number, n: number, late: boolean): number {\n let best = lo;\n let bestD = dist2(e, p, lo);\n const step = (hi - lo) / n;\n for (let i = 1; i <= n; i++) {\n const v = i === n ? hi : lo + i * step;\n const d = dist2(e, p, v);\n if (late ? d <= bestD * (1 + 1e-12) : d < bestD * (1 - 1e-12)) [best, bestD] = [v, d];\n }\n const { a, b, t0, sign } = e;\n const dx = p.x - e.center.x;\n const dy = p.y - e.center.y;\n let u = best;\n for (let i = 0; i < 12; i++) {\n // d/dt of half the squared distance, and its derivative, at t = t0 + sign u.\n const t = (t0 + sign * u) * RAD;\n const s = Math.sin(t);\n const c = Math.cos(t);\n const g = (a * a - b * b) * s * c - dx * a * c - dy * b * s;\n const g1 = (a * a - b * b) * (c * c - s * s) + dx * a * s - dy * b * c;\n if (!(g1 > 0)) break;\n const next = clamp(u - (sign * g) / g1 / RAD, Math.max(lo, best - step), Math.min(hi, best + step));\n if (Math.abs(next - u) < 1e-12) break;\n u = next;\n }\n return dist2(e, p, u) <= bestD ? u : best;\n}\n\n/**\n * An elliptical arc track, addressed by fraction of its length; its normal points away from the center, square to the\n * ellipse, whichever way it runs. With equal radii it is `arcShape`'s arc.\n */\nexport function ellipseShape(spec: EllipseTrackSpec): EllipseTrackShape {\n const { center, radiusX: a, radiusY: b } = spec;\n const sign = spec.direction === 'ccw' ? -1 : 1;\n const param = (seenDeg: number) => Math.atan2(b * Math.sin(seenDeg * RAD), a * Math.cos(seenDeg * RAD)) / RAD;\n const e: Param = { center, a, b, t0: param(spec.start), sign };\n const raw = mod360(sign * (param(spec.end) - e.t0));\n const sweep = raw === 0 ? 360 : raw;\n const { length, lengthTo, offsetAt } = lengthTable(e, sweep);\n /** The offset `f` of the length along, `f` outside 0..1: a whole ellipse wraps; an arc carries on round its ellipse. */\n const offsetPast = (f: number): number => {\n if (raw === 0) return offsetAt(((f % 1) + 1) % 1);\n let u = f * sweep;\n for (let i = 0; i < 8; i++) {\n const v = speed(e, u);\n if (!(v > 0)) break;\n u -= (lengthTo(u) - f * length) / v;\n }\n return u;\n };\n\n const at = (f: number, options?: TrackAtOptions): TrackStation => {\n const u = options?.open && (f < 0 || f > 1) ? offsetPast(f) : offsetAt(clamp(f, 0, 1));\n const t = (e.t0 + sign * u) * RAD;\n const s = Math.sin(t);\n const c = Math.cos(t);\n const k = Math.hypot(a * c, b * s);\n const tangent = k === 0 ? { x: sign * c, y: sign * s } : { x: (sign * a * c) / k, y: (sign * b * s) / k };\n const normal = k === 0 ? { x: s, y: -c } : { x: (b * s) / k, y: (-a * c) / k };\n return { point: pointAt(e, u), tangent, normal };\n };\n\n const shape: TrackShape = {\n kind: 'ellipse',\n length,\n closed: raw === 0,\n at,\n nearest(p, options): TrackNearest {\n const u = footBetween(e, p, 0, sweep, PIECES, true);\n const f = length === 0 ? 0 : clamp(lengthTo(u) / length, 0, 1);\n const dist = Math.sqrt(dist2(e, p, u));\n if (!options?.open || length === 0) return { f, dist };\n // Searched only within half a turn either side of `about`, so the answer is already unwrapped about it.\n const mid = offsetAt(options.about ?? 0.5);\n return { f: lengthTo(footBetween(e, p, mid - 180, mid + 180, RING, false)) / length, dist };\n },\n };\n Object.defineProperty(shape, 'ellipse', { value: spec, enumerable: false });\n return shape as EllipseTrackShape;\n}\n","/**\n * A path measured once by arc length, so many stations along it cost a binary\n * search each rather than a fresh flatten: what `pointAlongPath` answers one\n * fraction at a time, and what anything placing or bending geometry along a\n * path reads many times over.\n */\nimport type { Path } from '../path';\nimport { extractPolylines } from '../tessellate/polyline';\nimport type { Point } from './cubicMath';\n\n/** A point on a path and its heading there. */\nexport interface PathStation {\n point: Point;\n /** Unit vector along the path at `point`, pointing toward the end. */\n tangent: Point;\n}\n\n/** Options for {@link measurePath}. */\nexport interface MeasurePathOptions {\n /** Curve flattening tolerance, in world units. Default 0.5. */\n flattenTolerance?: number;\n /** Keep a vertex that turns further than flattening at the tolerance could as a corner: `at`'s `smooth` heading then\n * blends only across the vertices flattening made, and a straight edge heads along itself. Default false. */\n keepCorners?: boolean;\n}\n\n/** The station on a path nearest a point. */\nexport interface PathNearestStation extends PathStation {\n /** Arc length at `point`, on the scale {@link PathMeasure.at} reads. */\n s: number;\n /** Distance from the queried point to `point`. */\n dist: number;\n}\n\n/** A measured path: its length, and the station at any distance along it. */\nexport interface PathMeasure {\n /** Total arc length, every subpath counted in order. */\n readonly length: number;\n /** True when the path is a single closed contour, so a distance past the\n * end can wrap round to the start. */\n readonly closed: boolean;\n /**\n * The station `s` along the path, `s` clamped to `0..length`.\n *\n * The tangent is the heading of the flattened segment under `s`. With\n * `smooth`, it is instead blended across each segment from the heading at\n * one vertex to the next, so geometry bent along it turns without facets.\n */\n at(s: number, smooth?: boolean): PathStation;\n /**\n * The inverse of `at`: the station nearest `p`. On a tie the earliest\n * segment wins. The tangent is the heading of the segment holding it.\n */\n nearest(p: Point): PathNearestStation;\n}\n\ninterface Segment {\n ax: number; ay: number; bx: number; by: number;\n /** Arc length at the segment's start. */\n start: number;\n len: number;\n /** Unit heading. */\n tx: number; ty: number;\n /** Headings at either end, averaged with the neighbor's, for `smooth`. */\n t0x: number; t0y: number; t1x: number; t1y: number;\n}\n\n/**\n * Measure `path` by arc length. Subpaths are measured in order and treated as\n * one run, the way a browser measures a whole `<path>`. Returns `null` for a\n * path with no points; a path of zero length answers at its single point,\n * heading along +X.\n */\nexport function measurePath(path: Path, opts: MeasurePathOptions = {}): PathMeasure | null {\n const polylines = extractPolylines(\n path,\n opts.flattenTolerance === undefined ? {} : { flattenTolerance: opts.flattenTolerance },\n );\n const segments: Segment[] = [];\n let total = 0;\n let first: Point | undefined;\n let contours = 0;\n let lastClosed = false;\n for (const pl of polylines) {\n const count = pl.points.length / 2;\n if (count === 0) continue;\n contours++;\n lastClosed = pl.closed;\n first ??= { x: pl.points[0]!, y: pl.points[1]! };\n const startIndex = segments.length;\n const last = pl.closed ? count : count - 1;\n for (let i = 0; i < last; i++) {\n const j = (i + 1) % count;\n const ax = pl.points[i * 2]!;\n const ay = pl.points[i * 2 + 1]!;\n const bx = pl.points[j * 2]!;\n const by = pl.points[j * 2 + 1]!;\n const len = Math.hypot(bx - ax, by - ay);\n if (len === 0) continue;\n const tx = (bx - ax) / len;\n const ty = (by - ay) / len;\n segments.push({ ax, ay, bx, by, start: total, len, tx, ty, t0x: tx, t0y: ty, t1x: tx, t1y: ty });\n total += len;\n }\n smoothVertexHeadings(segments, startIndex, pl.closed, opts.keepCorners ? (opts.flattenTolerance ?? 0.5) : null);\n }\n if (first === undefined) return null;\n const origin = first;\n const closed = contours === 1 && lastClosed;\n if (segments.length === 0) {\n return {\n length: 0,\n closed,\n at: () => ({ point: { ...origin }, tangent: { x: 1, y: 0 } }),\n nearest: (p) => ({\n s: 0,\n dist: Math.hypot(p.x - origin.x, p.y - origin.y),\n point: { ...origin },\n tangent: { x: 1, y: 0 },\n }),\n };\n }\n\n return {\n length: total,\n closed,\n at(s, smooth = false) {\n const target = Math.min(Math.max(s, 0), total);\n const seg = segments[segmentAt(segments, target)]!;\n const u = Math.min(Math.max((target - seg.start) / seg.len, 0), 1);\n const point = { x: seg.ax + (seg.bx - seg.ax) * u, y: seg.ay + (seg.by - seg.ay) * u };\n if (!smooth) return { point, tangent: { x: seg.tx, y: seg.ty } };\n const x = seg.t0x + (seg.t1x - seg.t0x) * u;\n const y = seg.t0y + (seg.t1y - seg.t0y) * u;\n const l = Math.hypot(x, y);\n return { point, tangent: l === 0 ? { x: seg.tx, y: seg.ty } : { x: x / l, y: y / l } };\n },\n nearest(p) {\n let best = segments[0]!;\n let bestU = 0;\n let bestDist = Infinity;\n for (const seg of segments) {\n const u = Math.min(Math.max(((p.x - seg.ax) * seg.tx + (p.y - seg.ay) * seg.ty) / seg.len, 0), 1);\n const d = Math.hypot(p.x - (seg.ax + (seg.bx - seg.ax) * u), p.y - (seg.ay + (seg.by - seg.ay) * u));\n if (d < bestDist) {\n best = seg;\n bestU = u;\n bestDist = d;\n }\n }\n return {\n s: best.start + best.len * bestU,\n dist: bestDist,\n point: { x: best.ax + (best.bx - best.ax) * bestU, y: best.ay + (best.by - best.ay) * bestU },\n tangent: { x: best.tx, y: best.ty },\n };\n },\n };\n}\n\n/** Give each interior vertex of one contour the mean heading of the two\n * segments meeting there; a closed contour's seam is interior too. Given a\n * `cornerTolerance`, a vertex turning further than a flattened curve could is left a corner. */\nfunction smoothVertexHeadings(segments: Segment[], from: number, closed: boolean, cornerTolerance: number | null): void {\n const n = segments.length - from;\n if (n < 2) return;\n const pairs = closed ? n : n - 1;\n for (let k = 0; k < pairs; k++) {\n const a = segments[from + k]!;\n const b = segments[from + ((k + 1) % n)]!;\n if (cornerTolerance !== null && isCorner(a, b, cornerTolerance)) continue;\n let x = a.tx + b.tx;\n let y = a.ty + b.ty;\n const l = Math.hypot(x, y);\n // Two segments doubling back on each other have no mean heading.\n if (l < 1e-9) continue;\n x /= l;\n y /= l;\n a.t1x = x; a.t1y = y;\n b.t0x = x; b.t0y = y;\n }\n}\n\n/** Whether `a` turns into `b` by more than twice what a curve flattened to `tolerance` turns between chords that long:\n * a chord of length L whose sagitta is the tolerance turns from the next by about 8·tolerance/L. */\nfunction isCorner(a: Segment, b: Segment, tolerance: number): boolean {\n const turn = Math.acos(Math.min(1, Math.max(-1, a.tx * b.tx + a.ty * b.ty)));\n return turn > (16 * tolerance) / Math.min(a.len, b.len);\n}\n\n/** Index of the segment covering arc length `s`: binary search on `start`. */\nfunction segmentAt(segments: readonly Segment[], s: number): number {\n let lo = 0;\n let hi = segments.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (segments[mid]!.start <= s) lo = mid;\n else hi = mid - 1;\n }\n return lo;\n}\n","import type { Path } from '../path';\nimport type { Point } from '../paths/cubicMath';\nimport { measurePath } from '../paths/pathMeasure';\nimport { clamp } from '../scalar';\nimport type { TrackShape } from './shape';\n\n/** A track shape that remembers the path it was built from, so path data can be drawn as the path itself. */\nexport type PathTrackShape = TrackShape & { readonly path: Path };\n\n/**\n * A track along any path, every subpath counted in order, addressed by fraction of its length. Its normal is the left of\n * travel, as a line's is: outward on a contour drawn clockwise on screen. `null` for a path with no points.\n */\nexport function pathShape(path: Path, options: { flattenTolerance?: number } = {}): PathTrackShape | null {\n const measure = measurePath(path, { ...options, keepCorners: true });\n if (!measure) return null;\n const { length, closed } = measure;\n\n const shape: TrackShape = {\n kind: 'path',\n length,\n closed,\n at(f, options) {\n const open = options?.open === true && (f < 0 || f > 1);\n const g = open && closed ? ((f % 1) + 1) % 1 : clamp(f, 0, 1);\n const { point, tangent } = measure.at(g * length, true);\n // An open path past an end carries on straight along it.\n const past = open && !closed ? (f - g) * length : 0;\n return { point: { x: point.x + past * tangent.x, y: point.y + past * tangent.y }, tangent, normal: { x: tangent.y, y: -tangent.x } };\n },\n nearest(p: Point, opts) {\n const n = measure.nearest(p);\n const f = length === 0 ? 0 : n.s / length;\n if (!opts?.open || !closed || length === 0) return { f, dist: n.dist };\n const about = opts.about ?? 0.5;\n const unwrapped = [f - 1, f + 1].reduce((best, g) => (Math.abs(g - about) < Math.abs(best - about) ? g : best), f);\n return { f: unwrapped, dist: n.dist };\n },\n };\n Object.defineProperty(shape, 'path', { value: path, enumerable: false });\n return shape as PathTrackShape;\n}\n","import type { Point } from '../paths/cubicMath';\nimport { clamp } from '../scalar';\nimport type {\n TrackAtOptions,\n TrackNearest,\n TrackNearestOptions,\n TrackShape,\n TrackStation,\n} from './shape';\n\n/** A station as a run places an item: `normal` is the item's up after any flip, `tangent` its reading direction,\n * `angle` the CSS rotation in degrees that tips an upright item to it (0 = upright, clockwise positive, in (-180, 180]). */\nexport interface TrackPlace extends TrackStation {\n angle: number;\n /** True when `normal` points down the screen, so an item tipped by `angle` reads upside down. A run is turned over\n * by one place alone, so one across 3 or 9 o'clock has turned places toward one end; an item that should read\n * upright turns a half turn about its own center there. Nothing else in the place reflects it. */\n turned: boolean;\n}\n\n/** Whether an up `normal` points down the screen, y growing downward. */\nconst pointsDown = (normal: Point): boolean => normal.y > 1e-9;\n\n/** The stretch `from..to` of a shape in reading order. It is itself a TrackShape: `at(g)` and `nearest(p).f` are\n * in reading order, g = 0 at the reading start. */\nexport interface TrackRun extends TrackShape {\n readonly shape: TrackShape;\n readonly from: number;\n readonly to: number;\n /** True when items stand on the shape's normal turned over: under `side: 'auto'`, when that normal points down the screen\n * at `about`, so they stand upright. */\n readonly flipped: boolean;\n /** True when reading order runs against the shape's own direction. */\n readonly reversed: boolean;\n at(g: number, options?: TrackAtOptions): TrackPlace;\n}\n\n/** Which side of a shape a run's items stand on: `'auto'` whichever is upright, `'path'` the shape's own normal, `'flipped'`\n * the other. */\nexport type TrackSide = 'auto' | 'path' | 'flipped';\n\n/** How {@link trackRun} reads a shape: which side of it is up, and where that is judged. */\nexport interface TrackRunOptions {\n /** Default `'auto'`. */\n side?: TrackSide;\n /** The shape fraction `'auto'` judges the side at. Default the run's middle, `(from + to) / 2`. */\n about?: number;\n}\n\n/** The stretch `from..to` (default the whole shape) as items read it: on the side `options.side` picks, reversed to read\n * left to right on that side. */\nexport function trackRun(shape: TrackShape, from = 0, to = 1, options: TrackRunOptions = {}): TrackRun {\n const { side = 'auto', about = (from + to) / 2 } = options;\n const mid = shape.at(about);\n const flipped = side === 'auto' ? pointsDown(mid.normal) : side === 'flipped';\n const sgn = flipped ? -1 : 1;\n const reading = (n: Point): Point => ({ x: -(sgn * n.y), y: sgn * n.x });\n const r0 = reading(mid.normal);\n const reversed = r0.x * mid.tangent.x + r0.y * mid.tangent.y < 0;\n const span = to - from;\n const lo = Math.min(from, to);\n const hi = Math.max(from, to);\n const toF = (g: number): number => reversed ? to - g * span : from + g * span;\n\n const at = (g: number, options?: TrackAtOptions): TrackPlace => {\n const s = options?.open ? shape.at(toF(g), options) : shape.at(toF(clamp(g, 0, 1)));\n const dir = reading(s.normal);\n const angle = (Math.atan2(dir.y, dir.x) * 180) / Math.PI;\n const normal = { x: sgn * s.normal.x, y: sgn * s.normal.y };\n return {\n point: s.point,\n tangent: dir,\n normal,\n angle: angle === 0 ? 0 : angle === -180 ? 180 : angle,\n turned: pointsDown(normal),\n };\n };\n\n const toG = (f: number): number => span === 0 ? 0 : reversed ? (to - f) / span : (f - from) / span;\n\n const nearest = (p: Point, options?: TrackNearestOptions): TrackNearest => {\n const f = clamp(shape.nearest(p).f, lo, hi);\n const q = shape.at(f).point;\n const dist = Math.hypot(p.x - q.x, p.y - q.y);\n if (!options?.open) return { f: toG(f), dist };\n return { f: toG(shape.nearest(p, { open: true, about: toF(options.about ?? 0.5) }).f), dist };\n };\n\n return {\n kind: shape.kind,\n length: shape.length * Math.abs(span),\n closed: shape.closed && Math.abs(span) === 1,\n shape,\n from,\n to,\n flipped,\n reversed,\n at,\n nearest,\n };\n}\n","/**\n * `pathToD` — a weasel `Path` as an SVG `d=` string, the inverse of\n * `pathFromD`. `RectPath` lowers to `M h v h Z`; `PolygonPath` walks the\n * (commands, coords) arrays, one SVG command per kit command, with corner\n * shapes expanded into the geometry they draw.\n *\n * Absolute commands only; numbers are rounded to 6 decimals.\n */\n\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from '../commands';\nimport type { Path } from '../path';\nimport { resolveCorners } from './corners';\n\nconst num = (n: number): string => (Number.isFinite(n) ? String(Math.round(n * 1e6) / 1e6) : '0');\n\n/** `path` as SVG path data. */\nexport function pathToD(given: Path): string {\n const path = resolveCorners(given);\n if (path.kind === 'rect') {\n const { x, y, width, height } = path;\n return `M${num(x)} ${num(y)}h${num(width)}v${num(height)}h${num(-width)}Z`;\n }\n const cmds = path.commands;\n const xs = path.coords;\n const out: string[] = [];\n let ci = 0;\n for (let i = 0; i < cmds.length; i++) {\n const c = cmds[i];\n if (c === PATH_M) {\n out.push(`M${num(xs[ci])} ${num(xs[ci + 1])}`);\n ci += 2;\n } else if (c === PATH_L) {\n out.push(`L${num(xs[ci])} ${num(xs[ci + 1])}`);\n ci += 2;\n } else if (c === PATH_C) {\n out.push(\n `C${num(xs[ci])} ${num(xs[ci + 1])} ${num(xs[ci + 2])} ${num(xs[ci + 3])} `\n + `${num(xs[ci + 4])} ${num(xs[ci + 5])}`,\n );\n ci += 6;\n } else if (c === PATH_Q) {\n out.push(`Q${num(xs[ci])} ${num(xs[ci + 1])} ${num(xs[ci + 2])} ${num(xs[ci + 3])}`);\n ci += 4;\n } else if (c === PATH_Z) {\n out.push('Z');\n }\n }\n return out.join('');\n}\n","import type { Point } from '../paths/cubicMath';\nimport type { ArcTrackShape } from './arc';\nimport type { EllipseTrackShape } from './ellipse';\nimport type { PathTrackShape } from './path';\nimport { pathToD } from '../paths/pathToD';\nimport type { TrackShape } from './shape';\n\nconst SAMPLES = 64;\n\nconst num = (v: number): string => {\n const r = Math.round(v * 1e4) / 1e4;\n return String(r === 0 ? 0 : r);\n};\nconst pt = (p: Point): string => `${num(p.x)} ${num(p.y)}`;\nconst isArc = (s: TrackShape): s is ArcTrackShape => s.kind === 'arc' && 'arc' in s;\nconst isPath = (s: TrackShape): s is PathTrackShape => s.kind === 'path' && 'path' in s;\nconst isEllipse = (s: TrackShape): s is EllipseTrackShape => s.kind === 'ellipse' && 'ellipse' in s;\n\n/** Arcs of radii `rx` by `ry` from `a` to `b` turning `turn` radians: one arc, or two halves through `m` for a whole turn. */\nfunction arcsD(a: Point, b: Point, m: () => Point, rx: number, ry: number, turn: number, sweep: 0 | 1): string {\n const r = `${num(rx)} ${num(ry)}`;\n if (turn >= 2 * Math.PI - 1e-9) return `M ${pt(a)} A ${r} 0 0 ${sweep} ${pt(m())} A ${r} 0 0 ${sweep} ${pt(b)}`;\n return `M ${pt(a)} A ${r} 0 ${turn > Math.PI + 1e-9 ? 1 : 0} ${sweep} ${pt(b)}`;\n}\n\n/** SVG path data for the stretch `from..to` of a shape: a segment for a line, true arcs for an arc or an ellipse, else a\n * 64-step polyline. A whole path shape is its path's own data. */\nexport function trackShapeD(shape: TrackShape, from = 0, to = 1): string {\n if (isPath(shape) && from === 0 && to === 1) return pathToD(shape.path);\n const a = shape.at(from).point;\n const b = shape.at(to).point;\n if (shape.kind === 'line') return `M ${pt(a)} L ${pt(b)}`;\n const m = () => shape.at((from + to) / 2).point;\n if (isArc(shape)) {\n const { radius, direction } = shape.arc;\n const turn = (shape.length * Math.abs(to - from)) / radius;\n return arcsD(a, b, m, radius, radius, turn, (direction === 'ccw') === to < from ? 1 : 0);\n }\n if (isEllipse(shape)) {\n const { radiusX, radiusY, direction, center } = shape.ellipse;\n // The turn is in the ellipse's own parameter, which is what SVG's large-arc flag reads.\n const param = (p: Point) => Math.atan2((p.x - center.x) / radiusX, (center.y - p.y) / radiusY);\n const sign = direction === 'ccw' ? -1 : 1;\n const whole = (shape.ellipse.start - shape.ellipse.end) % 360 === 0 && Math.abs(to - from) >= 1 - 1e-12;\n const raw = (sign * Math.sign(to - from) * (param(b) - param(a)) + 4 * Math.PI) % (2 * Math.PI);\n return arcsD(a, b, m, radiusX, radiusY, whole ? 2 * Math.PI : raw, (direction === 'ccw') === to < from ? 1 : 0);\n }\n let d = `M ${pt(a)}`;\n for (let i = 1; i <= SAMPLES; i++)\n d += ` L ${pt(shape.at(from + ((to - from) * i) / SAMPLES).point)}`;\n return d;\n}\n","import type { Point } from '../paths/cubicMath';\nimport { clamp } from '../scalar';\nimport type { TrackAtOptions, TrackNearestOptions, TrackShape, TrackStation } from './shape';\n\nconst SAMPLES = 256;\n\nconst dot = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/** Which way `shape` bends, against its own normal: 1 toward it, -1 away from it, 0 straight. A shape that bends both\n * ways answers for the way it turns more in all. An arc and an ellipse bend away from their normal. */\nexport function bendSide(shape: TrackShape): -1 | 0 | 1 {\n let turn = 0;\n let prev = shape.at(0);\n for (let i = 1; i <= SAMPLES; i++) {\n const next = shape.at(i / SAMPLES);\n turn += dot({ x: next.tangent.x - prev.tangent.x, y: next.tangent.y - prev.tangent.y }, prev.normal);\n prev = next;\n }\n return Math.abs(turn) < 1e-9 ? 0 : turn > 0 ? 1 : -1;\n}\n\n/**\n * The track `shift` px along `shape`'s normal from it at every point — negative is against the normal — as a track\n * of its own, addressed by fraction of its own length, its tangent and normal those of `shape` at the point it came\n * from. Null when the shift reaches a center of curvature, where the track would fold back over itself: an arc shifted\n * in by its radius or more.\n */\nexport function shiftTrack(shape: TrackShape, shift: number): TrackShape | null {\n if (shift === 0) return shape;\n const moved = (s: TrackStation): TrackStation => ({ ...s, point: { x: s.point.x + shift * s.normal.x, y: s.point.y + shift * s.normal.y } });\n // `table[i]` is the shifted track's length to the base's fraction i / SAMPLES.\n const table = new Float64Array(SAMPLES + 1);\n let prev = moved(shape.at(0));\n for (let i = 1; i <= SAMPLES; i++) {\n const next = moved(shape.at(i / SAMPLES));\n const step = { x: next.point.x - prev.point.x, y: next.point.y - prev.point.y };\n const tangent = { x: prev.tangent.x + next.tangent.x, y: prev.tangent.y + next.tangent.y };\n if (shape.length > 0 && dot(step, tangent) <= 0) return null;\n table[i] = table[i - 1]! + Math.hypot(step.x, step.y);\n prev = next;\n }\n const length = table[SAMPLES]!;\n const per = shape.length / SAMPLES;\n // Base length per shifted length off either end, where the track carries on as its shape does.\n const startRatio = table[1]! > 0 ? per / table[1]! : 1;\n const endRatio = table[SAMPLES]! - table[SAMPLES - 1]! > 0 ? per / (table[SAMPLES]! - table[SAMPLES - 1]!) : 1;\n\n /** The base fraction under shifted fraction `f`, carried on past the ends at the end's ratio. */\n const toBase = (f: number): number => {\n const d = f * length;\n if (length <= 0 || shape.length <= 0) return f;\n if (d < 0) return (d * startRatio) / shape.length;\n if (d > length) return 1 + ((d - length) * endRatio) / shape.length;\n let lo = 0;\n let hi = SAMPLES;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (table[mid]! <= d) lo = mid;\n else hi = mid;\n }\n const span = table[hi]! - table[lo]!;\n return (lo + (span > 0 ? (d - table[lo]!) / span : 0)) / SAMPLES;\n };\n\n /** The shifted fraction over base fraction `g`, the inverse of {@link toBase}. */\n const fromBase = (g: number): number => {\n if (length <= 0 || shape.length <= 0) return g;\n if (g < 0) return (g * shape.length) / startRatio / length;\n if (g > 1) return (length + ((g - 1) * shape.length) / endRatio) / length;\n const x = g * SAMPLES;\n const i = Math.min(SAMPLES - 1, Math.floor(x));\n return (table[i]! + (x - i) * (table[i + 1]! - table[i]!)) / length;\n };\n\n const at = (f: number, options?: TrackAtOptions): TrackStation =>\n moved(shape.at(toBase(options?.open ? f : clamp(f, 0, 1)), options));\n\n return {\n kind: shape.kind,\n length,\n closed: shape.closed,\n at,\n nearest(p: Point, options?: TrackNearestOptions) {\n const base = shape.nearest(p, options?.open ? { open: true, about: toBase(options.about ?? 0.5) } : undefined);\n const f = fromBase(base.f);\n const q = at(f, options).point;\n return { f, dist: Math.hypot(p.x - q.x, p.y - q.y) };\n },\n };\n}\n","import { clamp } from '../scalar';\nimport { arcShape, type ArcTrackShape } from './arc';\nimport { ellipseShape, type EllipseTrackShape } from './ellipse';\nimport { lineShape, type TrackShape } from './shape';\n\nconst RAD = Math.PI / 180;\n\n/** The direction of `p` seen from `c`, in degrees clockwise from 12 o'clock on a y-down plane. */\nconst seen = (c: { x: number; y: number }, p: { x: number; y: number }): number => Math.atan2(p.x - c.x, c.y - p.y) / RAD;\n\n/**\n * The stretch `from..to` of a shape (fractions of it, `from` below `to`) as a shape of its own, running the same way.\n * An arc stays an arc and an ellipse an ellipse, so `trackShapeD` still draws it as one; any other shape is read through.\n */\nexport function trackSlice(shape: TrackShape, from: number, to: number): TrackShape {\n const lo = clamp(Math.min(from, to), 0, 1);\n const hi = clamp(Math.max(from, to), 0, 1);\n if (lo === 0 && hi === 1) return shape;\n const a = shape.at(lo).point;\n const b = shape.at(hi).point;\n if (shape.kind === 'line') return lineShape(a, b);\n if (shape.kind === 'arc' && 'arc' in shape) {\n const { center, radius, direction } = (shape as ArcTrackShape).arc;\n if (hi === lo) return arcShape({ center, radius: 0, start: 0, end: 0 });\n return arcShape({ center, radius, start: seen(center, a), end: seen(center, b), direction });\n }\n if (shape.kind === 'ellipse' && 'ellipse' in shape) {\n const { center, radiusX, radiusY, direction } = (shape as EllipseTrackShape).ellipse;\n if (hi === lo) return ellipseShape({ center, radiusX: 0, radiusY: 0, start: 0, end: 0 });\n return ellipseShape({ center, radiusX, radiusY, start: seen(center, a), end: seen(center, b), direction });\n }\n const span = hi - lo;\n return {\n kind: shape.kind,\n length: shape.length * span,\n closed: false,\n at: (f, options) => shape.at(lo + (options?.open ? f : clamp(f, 0, 1)) * span, options),\n nearest(p) {\n const n = shape.nearest(p);\n const f = clamp(n.f, lo, hi);\n const q = shape.at(f).point;\n return { f: span === 0 ? 0 : (f - lo) / span, dist: Math.hypot(p.x - q.x, p.y - q.y) };\n },\n };\n}\n","import { clamp } from '../scalar';\nimport type { TrackPlace, TrackRun } from './run';\n\n/** Where a sequence sits along a run: against its reading start, its middle, or its reading end. */\nexport type RunAlign = 'start' | 'center' | 'end';\n\n/** The order {@link placeAlongRun} lays items in: along the run's reading order, or from the end where the underlying\n * shape's own direction starts. The two differ only on a run that is `reversed`. */\nexport type RunOrder = 'reading' | 'track';\n\n/** Where one item of a run falls: its center along the run, and how much of it lies past the run's ends. */\nexport interface RunSpot {\n center: number;\n clipped: 'none' | 'part' | 'past';\n}\n\nconst clipOf = (lo: number, hi: number, start: number, end: number, hair = 0): RunSpot['clipped'] =>\n lo >= start - hair && hi <= end + hair ? 'none' : hi <= start + hair || lo >= end - hair ? 'past' : 'part';\n\n/**\n * Where each item's center falls along a run `room` px long, gaps measured along it. Without `at`, a sequence that fits\n * sits as `align` says, and one that does not is laid from the start less `offset`. With `at`, the sequence's align\n * point sits at `at - offset` whether or not it fits.\n */\nexport function runPlaces(\n lengths: readonly number[],\n gap: number,\n room: number,\n align: RunAlign,\n offset: number,\n at?: number,\n): RunSpot[] {\n const total = runLength(lengths, gap);\n const fits = at === undefined && total <= room;\n const lead = align === 'start' ? 0 : align === 'end' ? total : total / 2;\n let lo = at !== undefined ? at - offset - lead : !fits ? -offset : align === 'start' ? 0 : align === 'end' ? room - total : (room - total) / 2;\n return lengths.map((length) => {\n const start = lo;\n const hi = start + length;\n lo = hi + gap;\n return { center: start + length / 2, clipped: fits ? 'none' : clipOf(start, hi, 0, room) };\n });\n}\n\n/** How long items of `lengths` are laid end to end with `gap` between each two. */\nexport function runLength(lengths: readonly number[], gap: number): number {\n return lengths.reduce((sum, length, i) => sum + length + (i > 0 ? gap : 0), 0);\n}\n\n/** How {@link runStationAt} carries a place past either end of its run: straight along that end, tipped as it is there\n * (`'extend'`), or on along the run's shape itself (`'follow'`), as a shape's `at` reads `open`. */\nexport type RunPast = 'extend' | 'follow';\n\n/** The place `distance` along `run`, carried past either end as `past` says (default `'extend'`). The point then moves\n * `shift` along the place's up. */\nexport function runStationAt(run: TrackRun, distance: number, shift = 0, past: RunPast = 'extend'): TrackPlace {\n const { length } = run;\n if (past === 'follow' && length > 0) {\n const place = run.at(distance / length, { open: true });\n const { point, normal } = place;\n return { ...place, point: { x: point.x + shift * normal.x, y: point.y + shift * normal.y } };\n }\n const place = run.at(length === 0 ? 0 : distance / length);\n const beyond = distance < 0 ? distance : distance > length ? distance - length : 0;\n const { point, tangent, normal } = place;\n return {\n ...place,\n point: { x: point.x + beyond * tangent.x + shift * normal.x, y: point.y + beyond * tangent.y + shift * normal.y },\n };\n}\n\n/** How {@link placeAlongRun} lays its items: spacing, alignment, offset, anchor, stand-off, wrap and past-end handling. */\nexport interface PlaceAlongRunOptions {\n /** Space between each two items, along the run. Default 0. */\n gap?: number;\n /** Default `'center'`. */\n align?: RunAlign;\n /** How far the sequence is laid back along the run. Default 0. */\n offset?: number;\n /** Where along the run the sequence's align point sits, fitting or not; see {@link runPlaces}. */\n at?: number;\n /** How far each item stands off the run, along its up. Default 0. */\n shift?: number;\n /** Carry items on round a closed run past its seam, and count an item past once it is a whole lap on from the first\n * item's start. Default false. */\n wrap?: boolean;\n /** Where an item past an end is placed: carried on straight beyond it (`'extend'`, the default), or on along the run's\n * own shape (`'follow'`); `'hold'` follows the shape until the item is wholly past, then holds it at that end. */\n past?: RunPast | 'hold';\n /** `'reading'` (the default) lays item 1 at the run's reading start. `'track'` lays it at the shape's own start and\n * proceeds in the shape's direction; items still stand as the run reads them. In `'track'` order `align`, `at`,\n * `offset` and each `center` are measured from the shape's start. */\n order?: RunOrder;\n}\n\n/** One item laid along a run: where its center falls and the place there. `center` is unwrapped. */\nexport interface RunPlace extends RunSpot, TrackPlace {}\n\n/** Items of `lengths` laid end to end along `run`, each centered on its place and tipped to it. */\nexport function placeAlongRun(run: TrackRun, lengths: readonly number[], options: PlaceAlongRunOptions = {}): RunPlace[] {\n const { gap = 0, align = 'center', offset = 0, at, shift = 0, wrap = false, past = 'extend', order = 'reading' } = options;\n const { length } = run;\n const mirror = order === 'track' && run.reversed;\n const spots = runPlaces(lengths, gap, length, align, offset, at);\n const lap = wrap && run.closed && spots.length > 0 ? wrapWindow(spots[0]!, lengths[0]!, length) : null;\n return spots.map((spot, i) => {\n const half = lengths[i]! / 2;\n const clipped = lap ? clipOf(spot.center - half, spot.center + half, lap.start, lap.end, lap.hair) : spot.clipped;\n let distance = spot.center;\n if (past === 'hold' && clipped === 'past') distance = clamp(distance, lap?.start ?? 0, lap?.end ?? length);\n if (lap && length > 0) distance = ((distance % length) + length) % length;\n return { ...runStationAt(run, mirror ? length - distance : distance, shift, past === 'extend' ? 'extend' : 'follow'), center: spot.center, clipped };\n });\n}\n\n/** The lap a wrapped sequence fills, from the first item's start. Items meet that lap's end exactly whenever they fill it,\n * so it is judged within a `hair` of rounding error. */\nfunction wrapWindow(first: RunSpot, firstLength: number, length: number) {\n const start = first.center - firstLength / 2;\n return { start, end: start + length, hair: 1e-9 * Math.max(1, length) };\n}\n","/**\n * The port-curve rule in the 2D kernel's currency: loose scalars, the way\n * `cubicEvalAt` and `applyToPoint` take them. The rule itself lives in\n * `./portCurve`, stated once over components, so this and `./3d` cannot drift.\n */\n\nimport {\n PORT_REACH,\n portControls as portControlsN,\n portCurvePoints as portCurvePointsN,\n} from './portCurve';\n\nexport { PORT_REACH };\n\n/**\n * `[c1, c2]` for the cubic from `(ax, ay)` to `(bx, by)`.\n *\n * A null normal falls back to a lerp along the chord. See `./portCurve` for why\n * the two ends are not symmetric.\n */\nexport function portControls(\n ax: number,\n ay: number,\n bx: number,\n by: number,\n outNormal: readonly [number, number] | null | undefined,\n inNormal: readonly [number, number] | null | undefined,\n reach: number = PORT_REACH,\n): [[number, number], [number, number]] {\n const [c1, c2] = portControlsN([ax, ay], [bx, by], outNormal, inNormal, reach);\n return [\n [c1[0]!, c1[1]!],\n [c2[0]!, c2[1]!],\n ];\n}\n\n/** A port curve sampled into `samples` points, excluding its start. */\nexport function portCurvePoints(\n ax: number,\n ay: number,\n bx: number,\n by: number,\n outNormal: readonly [number, number] | null | undefined,\n inNormal: readonly [number, number] | null | undefined,\n samples: number,\n reach: number = PORT_REACH,\n): [number, number][] {\n return portCurvePointsN([ax, ay], [bx, by], outNormal, inNormal, samples, reach).map(\n (p) => [p[0]!, p[1]!],\n );\n}\n","/**\n * A path flattened into runs of points, sorted by whether each subpath\n * encloses area: what the hit tests in `pathHitTest.ts` walk.\n */\nimport { forEachSegment, PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from './commands';\nimport { DEFAULT_FLATTEN_TOLERANCE, flattenCubic, flattenQuadratic } from './flatten';\nimport { fillsOpenSubpaths } from './openFill';\nimport type { PolygonPath } from './path';\nimport { resolveCorners } from './paths/corners';\n\n/**\n * `path` flattened to interleaved `[x, y, …]` runs, sorted by whether each\n * subpath encloses area. A `Z` closing fewer than three points yields an open\n * run, as does any subpath a `Z` never ends. The closing edge of a closed run\n * back to its first vertex is implicit. Corner shapes are walked expanded.\n */\nexport function flatSubpaths(\n path: PolygonPath,\n tolerance: number,\n): { closed: number[][]; open: number[][] } {\n const { commands, coords } = resolveCorners(path);\n const closed: number[][] = [];\n const open: number[][] = [];\n let sub: number[] = [];\n\n forEachSegment(commands, coords, (cmd, ci, curX, curY, _i, opensSubpath) => {\n if (opensSubpath) sub = [curX, curY];\n switch (cmd) {\n case PATH_M:\n if (sub.length >= 2) open.push(sub);\n sub = [coords[ci], coords[ci + 1]];\n break;\n case PATH_L:\n sub.push(coords[ci], coords[ci + 1]);\n break;\n case PATH_C:\n flattenCubic(\n curX, curY,\n coords[ci], coords[ci + 1],\n coords[ci + 2], coords[ci + 3],\n coords[ci + 4], coords[ci + 5],\n tolerance, sub,\n );\n break;\n case PATH_Q:\n flattenQuadratic(\n curX, curY,\n coords[ci], coords[ci + 1],\n coords[ci + 2], coords[ci + 3],\n tolerance, sub,\n );\n break;\n case PATH_Z:\n if (sub.length >= 6) closed.push(sub);\n else if (sub.length >= 2) open.push(sub);\n sub = [];\n break;\n default:\n throw new Error(`pathHitTest: unknown command ${cmd}`);\n }\n });\n if (sub.length >= 2) open.push(sub);\n return { closed, open };\n}\n\n/** `flatSubpaths`, with each open run a fill closes moved among the closed. */\nexport function regionSubpaths(\n path: PolygonPath,\n opts: { tolerance?: number },\n): { closed: number[][]; open: number[][] } {\n const flat = flatSubpaths(path, opts.tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n if (!fillsOpenSubpaths(path)) return flat;\n return {\n closed: [...flat.closed, ...flat.open.filter((sub) => sub.length >= 6)],\n open: flat.open.filter((sub) => sub.length < 6),\n };\n}\n\nexport function closedSubpaths(path: PolygonPath, opts: { tolerance?: number }): number[][] {\n return regionSubpaths(path, opts).closed;\n}\n","/**\n * Is a point within `px` screen pixels of a world-space stroke band?\n *\n * The band is a capsule of radius `r` around each segment, in the frame the\n * path lives in; `m` is the linear part of that frame's map to the screen.\n * Under a similarity the answer is a plain world distance, `r + px / scale`.\n * Under anything else the capsule lands on screen as a parallelogram capped by\n * two ellipses, and the pixel slop has to be measured against that shape:\n * neither a scalar nor a per-axis world tolerance describes it.\n */\nimport { pointSegmentDist2 } from './polyline';\n\n/** Linear part of a map to the screen: `x' = a·x + c·y`, `y' = b·x + d·y`. */\nexport interface Linear2 {\n a: number; b: number; c: number; d: number;\n}\n\n/** A linear map's singular decomposition, as much of it as the band test\n * needs: the two stretch factors, and the screen-space angle of the first. */\nexport interface Stretch {\n s1: number;\n s2: number;\n /** Angle of the first singular direction on screen. */\n phi: number;\n}\n\nexport function stretchOf(m: Linear2): Stretch {\n // Closed-form 2×2 SVD. M = R(phi) · diag(Q + R, Q − R) · R(theta).\n const e = (m.a + m.d) / 2;\n const f = (m.a - m.d) / 2;\n const g = (m.b + m.c) / 2;\n const h = (m.b - m.c) / 2;\n const q = Math.hypot(e, h);\n const r = Math.hypot(f, g);\n const phi = (Math.atan2(h, e) + Math.atan2(g, f)) / 2;\n return { s1: q + r, s2: Math.abs(q - r), phi };\n}\n\n/** True when the map scales every direction alike, so a screen length is one\n * world length. */\nexport function isSimilarity(s: Stretch): boolean {\n return s.s1 - s.s2 <= 1e-9 * s.s1;\n}\n\n/**\n * Screen point `(px0, py0)` against the image of one world capsule\n * `(ax, ay)–(bx, by)`, radius `r`, grown by `slop` pixels. `m`/`st` map world\n * to screen (linear part only — every point shares the translation).\n */\nexport function capsuleWithinPx(\n px0: number, py0: number,\n ax: number, ay: number, bx: number, by: number,\n r: number, slop: number,\n m: Linear2, st: Stretch,\n): boolean {\n const sax = m.a * ax + m.c * ay, say = m.b * ax + m.d * ay;\n const sbx = m.a * bx + m.c * by, sby = m.b * bx + m.d * by;\n const slop2 = slop * slop;\n const dCenter2 = pointSegmentDist2(px0, py0, sax, say, sbx, sby);\n if (dCenter2 <= slop2) return true;\n if (r <= 0) return false;\n // Nothing in the band is farther from the centerline than r·s1 on screen.\n const reach = slop + r * st.s1;\n if (dCenter2 > reach * reach) return false;\n\n // The parallelogram: the capsule's straight part, carried to the screen.\n const wx = bx - ax, wy = by - ay;\n const wl = Math.hypot(wx, wy);\n if (wl > 0) {\n const nx = (-wy / wl) * r, ny = (wx / wl) * r;\n const ox = m.a * nx + m.c * ny, oy = m.b * nx + m.d * ny;\n if (quadWithinPx(px0, py0, [\n sax + ox, say + oy, sbx + ox, sby + oy,\n sbx - ox, sby - oy, sax - ox, say - oy,\n ], slop2)) return true;\n }\n // The round caps: each end's disk lands on screen as an ellipse.\n return ellipseWithinPx(px0 - sax, py0 - say, r, slop, st)\n || ellipseWithinPx(px0 - sbx, py0 - sby, r, slop, st);\n}\n\n/** Inside a convex quad, or within `sqrt(slop2)` of one of its edges. */\nfunction quadWithinPx(x: number, y: number, q: readonly number[], slop2: number): boolean {\n let pos = 0, neg = 0;\n for (let i = 0; i < 8; i += 2) {\n const j = (i + 2) % 8;\n const cr = (q[j] - q[i]) * (y - q[i + 1]) - (q[j + 1] - q[i + 1]) * (x - q[i]);\n if (cr > 0) pos++;\n else if (cr < 0) neg++;\n }\n if (pos === 0 || neg === 0) return true;\n for (let i = 0; i < 8; i += 2) {\n const j = (i + 2) % 8;\n if (pointSegmentDist2(x, y, q[i], q[i + 1], q[j], q[j + 1]) <= slop2) return true;\n }\n return false;\n}\n\n/** `(dx, dy)` from the center of the filled ellipse `M(disk r)`, within `slop`? */\nfunction ellipseWithinPx(dx: number, dy: number, r: number, slop: number, st: Stretch): boolean {\n const cos = Math.cos(st.phi), sin = Math.sin(st.phi);\n const u = Math.abs(cos * dx + sin * dy);\n const v = Math.abs(-sin * dx + cos * dy);\n const e0 = r * st.s1, e1 = r * st.s2;\n if (e1 <= 0) {\n // Collapsed to a segment along the first axis.\n const over = Math.max(0, u - e0);\n return over * over + v * v <= slop * slop;\n }\n return distToEllipse(e0, e1, u, v) <= slop;\n}\n\n/**\n * Distance from `(y0, y1)`, first quadrant, to the filled axis-aligned ellipse\n * with semi-axes `e0 >= e1 > 0`. Eberly, \"Distance from a Point to an\n * Ellipse\" — bisection on the Lagrange root, robust near the axes.\n */\nfunction distToEllipse(e0: number, e1: number, y0: number, y1: number): number {\n const z0 = y0 / e0, z1 = y1 / e1;\n const g = z0 * z0 + z1 * z1 - 1;\n if (g <= 0) return 0;\n if (y1 > 0) {\n if (y0 > 0) {\n const r0 = (e0 / e1) * (e0 / e1);\n const n0 = r0 * z0;\n let s0 = z1 - 1;\n let s1 = Math.hypot(n0, z1) - 1;\n let s = 0;\n for (let i = 0; i < 100; i++) {\n s = (s0 + s1) / 2;\n if (s === s0 || s === s1) break;\n const a = n0 / (s + r0), b = z1 / (s + 1);\n const gs = a * a + b * b - 1;\n if (gs > 0) s0 = s;\n else if (gs < 0) s1 = s;\n else break;\n }\n const x0 = (r0 * y0) / (s + r0);\n const x1 = y1 / (s + 1);\n return Math.hypot(x0 - y0, x1 - y1);\n }\n return y1 - e1;\n }\n const numer = e0 * y0, denom = e0 * e0 - e1 * e1;\n if (numer < denom) {\n const t = numer / denom;\n const x0 = e0 * t, x1 = e1 * Math.sqrt(1 - t * t);\n return Math.hypot(x0 - y0, x1);\n }\n return y0 - e0;\n}\n","/**\n * Path hit-testing: path-vs-point (filled region and stroke distance),\n * path-vs-rect, and path-vs-polygon in both directions.\n *\n * A `rect` path short-circuits to AABB arithmetic. A `polygon` path is its\n * filled region: beziers are flattened, `fillRule` is honored (default\n * `nonzero`), and every closed subpath counts — the hole of a donut is not\n * part of the shape under `evenodd`. An open subpath counts as closed where a\n * fill closes it and encloses nothing where one does not: see\n * `fillsOpenSubpaths`.\n */\n\nimport { DEFAULT_FLATTEN_TOLERANCE } from './flatten';\nimport { pointInPolygon, pointSegmentDist2, segmentsCross } from './polyline';\nimport type { Rect } from './box';\nimport type { Path } from './path';\nimport { closedSubpaths, flatSubpaths, regionSubpaths } from './pathSubpaths';\nimport type { Affine } from './affine';\nimport type { Point } from './paths/cubicMath';\nimport { capsuleWithinPx, isSimilarity, stretchOf, type Linear2 } from './screenBand';\n\n\n/** Options for the path hit-tests. */\nexport interface PointInPathOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n}\n\n/** Options for {@link polygonIntersectsPath}. */\nexport interface PolygonIntersectsPathOptions extends PointInPathOptions {\n /** False when nothing paints the path's interior: only its outline can meet\n * the polygon, and a polygon lying wholly inside meets nothing. Default true. */\n filled?: boolean;\n}\n\n/** Options for {@link strokeHitTest}. */\nexport interface StrokeHitTestOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n /** Extra reach past the band measured in screen pixels rather than world\n * units: `px` pixels, after `transform` carries the path's frame to the\n * screen (only its linear part matters). A pointer's forgiveness is a\n * screen distance, and under a non-uniform or rotated-then-squished\n * transform no world distance equals it. */\n slop?: { px: number; transform: Affine };\n}\n\n// ─── Point vs path ──────────────────────────────────────────────────────────\n\n/** Filled-region hit-test for a path. Rect short-circuits to AABB; polygons run ray-cast / winding per `fillRule`. */\nexport function pointInPath(\n path: Path,\n x: number,\n y: number,\n opts: PointInPathOptions = {},\n): boolean {\n if (path.kind === 'rect') {\n return x >= path.x && x <= path.x + path.width && y >= path.y && y <= path.y + path.height;\n }\n let crossings = 0;\n let winding = 0;\n for (const sub of closedSubpaths(path, opts)) {\n const n = sub.length;\n for (let i = 0; i < n; i += 2) {\n const j = (i + 2) % n;\n const ay = sub[i + 1], by = sub[j + 1];\n if ((ay > y) === (by > y)) continue;\n const ax = sub[i], bx = sub[j];\n if (x >= ax + ((y - ay) / (by - ay)) * (bx - ax)) continue;\n crossings++;\n winding += ay <= y ? 1 : -1;\n }\n }\n return path.fillRule === 'evenodd' ? (crossings & 1) === 1 : winding !== 0;\n}\n\n/**\n * Stroke-distance hit-test. True when (x, y) lies within `threshold` world\n * units of the path's outline — when a stroke of total width `2 * threshold`\n * drawn along the path would cover the point. Works for open and closed\n * subpaths alike; OR it with {@link pointInPath} for fill-plus-stroke picking.\n * Every flattened segment is treated as a capsule of radius `threshold`.\n */\nexport function strokeHitTest(\n path: Path,\n x: number,\n y: number,\n threshold: number,\n opts: StrokeHitTestOptions = {},\n): boolean {\n const slop = opts.slop;\n if (slop && slop.px > 0) {\n const [a, b, c, d] = slop.transform;\n const m: Linear2 = { a, b, c, d };\n const st = stretchOf(m);\n // A view collapsed to a point shows nothing to hit, and a pixel there is no world length.\n if (st.s1 === 0) return false;\n if (isSimilarity(st)) {\n return strokeHitTest(path, x, y, threshold + slop.px / st.s1, { tolerance: opts.tolerance });\n }\n const sx = a * x + c * y, sy = b * x + d * y;\n return someSegment(path, opts.tolerance, (ax, ay, bx, by) =>\n capsuleWithinPx(sx, sy, ax, ay, bx, by, threshold, slop.px, m, st));\n }\n const t2 = threshold * threshold;\n return someSegment(path, opts.tolerance, (ax, ay, bx, by) =>\n pointSegmentDist2(x, y, ax, ay, bx, by) <= t2);\n}\n\n/** Does `visit` answer true for any outline segment — every edge of a rect,\n * closing edges of closed subpaths included? */\nfunction someSegment(\n path: Path,\n tolerance: number | undefined,\n visit: (ax: number, ay: number, bx: number, by: number) => boolean,\n): boolean {\n if (path.kind === 'rect') {\n const { x: rx, y: ry, width: w, height: h } = path;\n return visit(rx, ry, rx + w, ry) || visit(rx + w, ry, rx + w, ry + h)\n || visit(rx + w, ry + h, rx, ry + h) || visit(rx, ry + h, rx, ry);\n }\n const { closed, open } = flatSubpaths(path, tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n const run = (sub: readonly number[], wrap: boolean): boolean => {\n const n = sub.length;\n const last = wrap ? n : n - 2;\n for (let i = 0; i < last; i += 2) {\n const j = (i + 2) % n;\n if (visit(sub[i], sub[i + 1], sub[j], sub[j + 1])) return true;\n }\n return false;\n };\n return closed.some((sub) => run(sub, true)) || open.some((sub) => run(sub, false));\n}\n\n// ─── Region vs path ─────────────────────────────────────────────────────────\n\nfunction rectToVerts(r: Rect): Point[] {\n return [\n { x: r.x, y: r.y },\n { x: r.x + r.width, y: r.y },\n { x: r.x + r.width, y: r.y + r.height },\n { x: r.x, y: r.y + r.height },\n ];\n}\n\n/** Flatten a vertex array into an interleaved [x0,y0,x1,y1,...] array. */\nfunction flattenVerts(poly: readonly Point[]): number[] {\n const flat: number[] = new Array(poly.length * 2);\n for (let i = 0; i < poly.length; i++) {\n flat[i * 2] = poly[i].x;\n flat[i * 2 + 1] = poly[i].y;\n }\n return flat;\n}\n\n/** Edge-vs-edge segment intersection check between two closed polygons. */\nfunction polygonsIntersect(a: readonly Point[], b: readonly Point[]): boolean {\n if (a.length === 0 || b.length === 0) return false;\n if (pointInPolygon(flattenVerts(a), b[0].x, b[0].y)) return true;\n if (pointInPolygon(flattenVerts(b), a[0].x, a[0].y)) return true;\n for (let i = 0; i < a.length; i++) {\n const a0 = a[i], a1 = a[(i + 1) % a.length];\n for (let j = 0; j < b.length; j++) {\n const b0 = b[j], b1 = b[(j + 1) % b.length];\n if (segmentsCross(a0.x, a0.y, a1.x, a1.y, b0.x, b0.y, b1.x, b1.y)) return true;\n }\n }\n return false;\n}\n\n/** Run `visit` over every edge of every closed subpath until it answers true. */\nfunction anyEdge(\n subpaths: readonly number[][],\n visit: (ax: number, ay: number, bx: number, by: number) => boolean,\n): boolean {\n for (const sub of subpaths) {\n const n = sub.length;\n for (let i = 0; i < n; i += 2) {\n const j = (i + 2) % n;\n if (visit(sub[i], sub[i + 1], sub[j], sub[j + 1])) return true;\n }\n }\n return false;\n}\n\nfunction anyEdgeCrossesRect(subpaths: readonly number[][], r: Rect): boolean {\n const x0 = r.x, y0 = r.y, x1 = r.x + r.width, y1 = r.y + r.height;\n return anyEdge(subpaths, (ax, ay, bx, by) =>\n segmentsCross(ax, ay, bx, by, x0, y0, x1, y0) ||\n segmentsCross(ax, ay, bx, by, x1, y0, x1, y1) ||\n segmentsCross(ax, ay, bx, by, x1, y1, x0, y1) ||\n segmentsCross(ax, ay, bx, by, x0, y1, x0, y0),\n );\n}\n\nfunction anyEdgeCrossesPolygon(subpaths: readonly number[][], poly: readonly Point[]): boolean {\n if (poly.length === 0) return false;\n return anyEdge(subpaths, (ax, ay, bx, by) => {\n for (let i = 0; i < poly.length; i++) {\n const p0 = poly[i], p1 = poly[(i + 1) % poly.length];\n if (segmentsCross(ax, ay, bx, by, p0.x, p0.y, p1.x, p1.y)) return true;\n }\n return false;\n });\n}\n\n/** `anyEdgeCrossesPolygon` for open runs: no edge back to the first vertex. */\nfunction anyOpenEdgeCrossesPolygon(runs: readonly number[][], poly: readonly Point[]): boolean {\n for (const run of runs) {\n for (let i = 0; i + 3 < run.length; i += 2) {\n const ax = run[i], ay = run[i + 1], bx = run[i + 2], by = run[i + 3];\n for (let k = 0; k < poly.length; k++) {\n const p0 = poly[k], p1 = poly[(k + 1) % poly.length];\n if (segmentsCross(ax, ay, bx, by, p0.x, p0.y, p1.x, p1.y)) return true;\n }\n }\n }\n return false;\n}\n\nfunction anyVertexInRect(subpaths: readonly number[][], r: Rect): boolean {\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n const x = sub[i], y = sub[i + 1];\n if (x >= r.x && x <= r.x + r.width && y >= r.y && y <= r.y + r.height) return true;\n }\n }\n return false;\n}\n\nfunction anyVertexInPolygon(subpaths: readonly number[][], flatPoly: readonly number[]): boolean {\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n if (pointInPolygon(flatPoly, sub[i], sub[i + 1])) return true;\n }\n }\n return false;\n}\n\n/** Returns true if (x, y) lies within the filled region of `path`. */\nexport function pathContainsPoint(\n path: Path,\n x: number,\n y: number,\n opts: PointInPathOptions = {},\n): boolean {\n return pointInPath(path, x, y, opts);\n}\n\n/** Returns true if `rect` is entirely contained within `path`. */\nexport function pathContainsRect(path: Path, rect: Rect, opts: PointInPathOptions = {}): boolean {\n if (path.kind === 'rect') {\n return (\n rect.x >= path.x &&\n rect.y >= path.y &&\n rect.x + rect.width <= path.x + path.width &&\n rect.y + rect.height <= path.y + path.height\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const c of rectToVerts(rect)) {\n if (!pointInPath(path, c.x, c.y, opts)) return false;\n }\n // Every corner is filled, but any contour reaching into the rect — the\n // boundary of a hole, or a concave notch — leaves part of it unfilled.\n return !anyVertexInRect(subpaths, rect) && !anyEdgeCrossesRect(subpaths, rect);\n}\n\n/** Returns true if `rect` overlaps (intersects or contains) `path`. */\nexport function pathIntersectsRect(path: Path, rect: Rect, opts: PointInPathOptions = {}): boolean {\n if (path.kind === 'rect') {\n return (\n rect.x < path.x + path.width &&\n rect.x + rect.width > path.x &&\n rect.y < path.y + path.height &&\n rect.y + rect.height > path.y\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const c of rectToVerts(rect)) {\n if (pointInPath(path, c.x, c.y, opts)) return true;\n }\n if (anyVertexInRect(subpaths, rect)) return true;\n return anyEdgeCrossesRect(subpaths, rect);\n}\n\n/** Returns true if every vertex of `polygon` lies inside `path`. */\nexport function pathContainsPolygon(\n path: Path,\n polygon: readonly Point[],\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length === 0) return false;\n if (path.kind === 'rect') {\n return polygon.every(\n (p) =>\n p.x >= path.x &&\n p.x <= path.x + path.width &&\n p.y >= path.y &&\n p.y <= path.y + path.height,\n );\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const p of polygon) {\n if (!pointInPath(path, p.x, p.y, opts)) return false;\n }\n return !anyVertexInPolygon(subpaths, flattenVerts(polygon)) &&\n !anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/** Returns true if `polygon` overlaps (intersects or is contained by) `path`. */\nexport function pathIntersectsPolygon(\n path: Path,\n polygon: readonly Point[],\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length === 0) return false;\n if (path.kind === 'rect') {\n return polygonsIntersect(rectToVerts(path), polygon);\n }\n const subpaths = closedSubpaths(path, opts);\n if (subpaths.length === 0) return false;\n for (const p of polygon) {\n if (pointInPath(path, p.x, p.y, opts)) return true;\n }\n if (anyVertexInPolygon(subpaths, flattenVerts(polygon))) return true;\n return anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/**\n * Returns true if all of `path` — every subpath, open ones included, beziers\n * flattened — lies inside the closed `polygon`: the inverse of\n * {@link pathContainsPolygon}. A lasso enclosing a shape asks this.\n */\nexport function polygonContainsPath(\n polygon: readonly Point[],\n path: Path,\n opts: PointInPathOptions = {},\n): boolean {\n if (polygon.length < 3) return false;\n let subpaths: number[][];\n if (path.kind === 'rect') {\n subpaths = [flattenVerts(rectToVerts(path))];\n } else {\n const { closed, open } = regionSubpaths(path, opts);\n subpaths = [...closed, ...open];\n }\n if (subpaths.length === 0) return false;\n const flatPoly = flattenVerts(polygon);\n for (const sub of subpaths) {\n for (let i = 0; i < sub.length; i += 2) {\n if (!pointInPolygon(flatPoly, sub[i], sub[i + 1])) return false;\n }\n }\n // Every vertex is inside, but a concave polygon can still cut an edge. An\n // open subpath is checked as if closed, so this can only err toward false.\n return !anyEdgeCrossesPolygon(subpaths, polygon);\n}\n\n/**\n * Returns true if any of `path` meets the closed `polygon`: its filled region,\n * or the line of an open subpath, which encloses nothing. With `filled: false`\n * a closed subpath is a line too. Beziers are\n * flattened, so a control point off the curve never counts. The companion of\n * {@link polygonContainsPath}; a lasso touching a shape asks this.\n */\nexport function polygonIntersectsPath(\n polygon: readonly Point[],\n path: Path,\n opts: PolygonIntersectsPathOptions = {},\n): boolean {\n if (polygon.length < 3) return false;\n const filled = opts.filled !== false;\n if (path.kind === 'rect' && filled) return polygonsIntersect(rectToVerts(path), polygon);\n const { closed, open } = path.kind === 'rect'\n ? { closed: [flattenVerts(rectToVerts(path))], open: [] }\n : regionSubpaths(path, opts);\n const flatPoly = flattenVerts(polygon);\n if (anyVertexInPolygon(closed, flatPoly) || anyVertexInPolygon(open, flatPoly)) return true;\n if (anyEdgeCrossesPolygon(closed, polygon) || anyOpenEdgeCrossesPolygon(open, polygon)) {\n return true;\n }\n // No vertex inside and no crossing: the polygon lies wholly in one region\n // of the path, so one of its vertices decides whether that region is filled.\n return filled && closed.length > 0 && pointInPath(path, polygon[0].x, polygon[0].y, opts);\n}\n","/**\n * The corners an offset outline would hold as corners: each of the source's,\n * moved to where its offset edges meet and resized so its cut keeps the\n * same center.\n */\nimport type { Path } from '../path';\nimport { pointInPath } from '../pathHitTest';\nimport { PathBuilder } from './builder';\nimport type { CornerTrace } from './cornerRestore';\nimport { withCorner } from './cornerSpec';\nimport { cornerCuts, resolveCorners } from './corners';\n\n/**\n * Where the corners of `path` would sit on its outline grown by `distance`\n * (shrunk by a negative one), for `restoreCorners` to look for. A corner\n * moves with its edges and keeps its center, so its setback changes by\n * `distance / tan(half the corner's angle)`: a round corner at a right angle\n * grows its radius by exactly `distance`, and is then exactly what the offset\n * draws. A shape whose offset is no longer that shape, or a corner between\n * curved edges, draws differently from its trace, so `restoreCorners` leaves\n * it expanded. A corner shrunk to nothing has no trace.\n */\nexport function offsetCornerTraces(path: Path, distance: number): CornerTrace[] {\n if (path.kind !== 'polygon' || distance === 0) return [];\n const drawn = resolveCorners(path);\n const out: CornerTrace[] = [];\n for (const cut of cornerCuts(path)) {\n const { anchor: v, spec } = cut;\n const inLen = Math.hypot(cut.start.x - v.x, cut.start.y - v.y);\n const outLen = Math.hypot(cut.end.x - v.x, cut.end.y - v.y);\n if (inLen === 0 || outLen === 0) continue;\n const din = { x: (cut.start.x - v.x) / inLen, y: (cut.start.y - v.y) / inLen };\n const dout = { x: (cut.end.x - v.x) / outLen, y: (cut.end.y - v.y) / outLen };\n const bx = din.x + dout.x, by = din.y + dout.y;\n const bl = Math.hypot(bx, by);\n if (bl < 1e-9) continue;\n const b = { x: bx / bl, y: by / bl };\n const half = Math.acos(Math.max(-1, Math.min(1, din.x * b.x + din.y * b.y)));\n // Just inside the wedge, between the anchor and its cut: filled only\n // where the corner turns away from the fill.\n const probe = Math.min(inLen, outLen) * 0.01;\n const sign = pointInPath(drawn, v.x + b.x * probe, v.y + b.y * probe) ? -1 : 1;\n const radius = spec.radius + (sign * distance) / Math.tan(half);\n if (!(radius > 0)) continue;\n const at = { x: v.x - (b.x * sign * distance) / Math.sin(half), y: v.y - (b.y * sign * distance) / Math.sin(half) };\n const reach = radius * 2 + 1;\n const wedge = new PathBuilder()\n .moveTo(at.x + din.x * reach, at.y + din.y * reach)\n .lineTo(at.x, at.y)\n .lineTo(at.x + dout.x * reach, at.y + dout.y * reach)\n .build();\n const [moved] = cornerCuts(withCorner(wedge, 1, { shape: spec.shape, radius }));\n if (moved) out.push({ anchor: at, spec: moved.spec, start: moved.start, end: moved.end, pieces: moved.pieces });\n }\n return out;\n}\n","/**\n * AABB union over a heterogeneous set of `Path` poses. Returns the\n * envelope as a `RectPath`, or `null` for empty input — analog of\n * `unionBounds` for the rect-only model.\n */\n\nimport { boundsOfPath } from './bounds';\nimport type { Path, RectPath } from '../path';\n\n/** AABB envelope over a set of `Path` instances; returns `null` for empty input. */\nexport function unionBoundsPath(paths: Iterable<Path>): RectPath | null {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let any = false;\n for (const p of paths) {\n any = true;\n const b = boundsOfPath(p);\n if (b.x < minX) minX = b.x;\n if (b.y < minY) minY = b.y;\n const right = b.x + b.width;\n const bottom = b.y + b.height;\n if (right > maxX) maxX = right;\n if (bottom > maxY) maxY = bottom;\n }\n if (!any) return null;\n return { kind: 'rect', x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n","import type { Affine } from '../affine';\nimport { transformCoords } from '../affine';\nimport { PathBuilder } from './builder';\nimport type { Path, PolygonPath } from '../path';\nimport { scaleCorners } from './cornerSpec';\n\n/** Below this, a matrix's rotation and shear terms are rounding left by\n * composing transforms (a half turn's sine is 1.2e-16), not a slant. */\nconst AXIS_ALIGNED_EPSILON = 1e-9;\n\n/** Apply an `Affine` to a path's geometry. Never mutates the input.\n *\n * Axis-aligned maps (no rotation/shear: `m[1]` and `m[2]` within 1e-9 of 0) keep a\n * `RectPath` a rect, normalizing negative extent (mirror). Rotation or\n * shear promotes the rect's four corners to a `PolygonPath`. */\nexport function transformPath(path: Path, m: Affine): Path {\n const [a, b, c, d, e, f] = m;\n if (path.kind === 'rect') {\n if (Math.abs(b) < AXIS_ALIGNED_EPSILON && Math.abs(c) < AXIS_ALIGNED_EPSILON) {\n // Pure scale + translate — corners remain axis-aligned.\n const x0 = a * path.x + e;\n const y0 = d * path.y + f;\n const x1 = a * (path.x + path.width) + e;\n const y1 = d * (path.y + path.height) + f;\n return {\n kind: 'rect',\n x: Math.min(x0, x1),\n y: Math.min(y0, y1),\n width: Math.abs(x1 - x0),\n height: Math.abs(y1 - y0),\n };\n }\n // Rotation / shear — promote to polygon with the four rect corners.\n const poly = new PathBuilder()\n .moveTo(path.x, path.y)\n .lineTo(path.x + path.width, path.y)\n .lineTo(path.x + path.width, path.y + path.height)\n .lineTo(path.x, path.y + path.height)\n .close()\n .build();\n return transformPolygon(poly, m);\n }\n return transformPolygon(path, m);\n}\n\nfunction transformPolygon(path: PolygonPath, m: Affine): PolygonPath {\n // transformCoords returns Float64Array; PolygonPath.coords is Float32Array.\n const mapped = transformCoords(path.coords, m);\n // A corner radius scales as a length does: by the map's mean scale.\n const scaled = scaleCorners(path, Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])));\n return { ...scaled, coords: Float32Array.from(mapped) };\n}\n","/**\n * In-place and copy-out path transforms. Translation is the most common —\n * called every pointermove during a drag — so the polygon variant mutates\n * the float buffer directly to keep allocation pressure off the GC.\n *\n * `scalePathToBounds` is for the resize interaction: given the path's\n * current AABB and the desired new AABB, scales every coordinate\n * proportionally.\n */\n\nimport { boxToBox } from '../affine';\nimport { forEachSegment, pathCommandCoordCount } from '../commands';\nimport { boundsOfPath } from './bounds';\nimport { transformPath } from './transformPath';\nimport type { Path, PolygonPath, RectPath } from '../path';\n\n/**\n * Translate a path by (dx, dy). Returns a new instance — the kit's pose\n * model treats poses as immutable to keep React state-update semantics\n * predictable. Polygon coords are copied into a fresh `Float32Array`.\n */\nexport function translatePath(path: Path, dx: number, dy: number): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: path.x + dx, y: path.y + dy, width: path.width, height: path.height };\n }\n return translatePolygonCopy(path, dx, dy);\n}\n\nfunction translatePolygonCopy(path: PolygonPath, dx: number, dy: number): PolygonPath {\n const next = new Float32Array(path.coords.length);\n const { commands, coords } = path;\n forEachSegment(commands, coords, (cmd, ci) => {\n for (let k = 0, len = pathCommandCoordCount(cmd); k < len; k += 2) {\n next[ci + k] = coords[ci + k] + dx;\n next[ci + k + 1] = coords[ci + k + 1] + dy;\n }\n });\n return { ...path, coords: next };\n}\n\n/**\n * Scale a path's coords so its current AABB maps to `target`. Resize\n * interactions use this to make a polygon follow a corner-handle drag.\n *\n * A degenerate source axis (zero width or height) has no ratio to scale by,\n * so `boxToBox` translates that axis instead — a zero scale is not\n * invertible and would discard what is left on it.\n */\nexport function scalePathToBounds(path: Path, target: RectPath): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: target.x, y: target.y, width: target.width, height: target.height };\n }\n const src = boundsOfPath(path);\n return scalePolygon(path, src, target);\n}\n\nfunction scalePolygon(path: PolygonPath, src: RectPath, dst: RectPath): PolygonPath {\n const m = boxToBox(src.x, src.y, src.width, src.height, dst.x, dst.y, dst.width, dst.height);\n // src/dst are axis-aligned, so the polygon stays a polygon after this pure scale+translate.\n return transformPath(path, m) as PolygonPath;\n}\n","/**\n * Translation-only compose/decompose for `Path` poses, the analog of\n * `composeRectPose` / `decomposeRectPose` for the rect-only model. Pair\n * with `composeWorldPose` / `rebaseLocalPose` when an adapter uses `Path`\n * as its `TPose`.\n *\n * Only translation is folded — the kit's hierarchy contract is\n * translation-only, same as for rects. Parent rotation/scale would require\n * a richer compose; that's out of scope here.\n */\n\nimport { boundsOfPath } from './bounds';\nimport { translatePath } from './transform';\nimport type { Path } from '../path';\n\n/** Express `child` (in `parent`'s local frame) in the next frame up. */\nexport function composePath(parent: Path, child: Path): Path {\n const origin = pathOrigin(parent);\n return translatePath(child, origin.x, origin.y);\n}\n\n/** Inverse of `composePath` — undo `parent`'s translation from a world pose. */\nexport function decomposePath(parent: Path, world: Path): Path {\n const origin = pathOrigin(parent);\n return translatePath(world, -origin.x, -origin.y);\n}\n\nfunction pathOrigin(path: Path): { x: number; y: number } {\n const { x, y } = boundsOfPath(path);\n return { x, y };\n}\n","import { forEachSegment, PATH_M, PATH_Z } from '../commands';\nimport type { PolygonPath } from '../path';\nimport { anchorRange, carryCorners } from './cornerCarry';\nimport { withoutCorners } from './cornerSpec';\n\n/** Split a path into one path per subpath, cutting at each `M`. A path with a\n * single subpath comes back as a one-element array. `fillRule` is propagated\n * unchanged, so even-odd compound paths with interior \"holes\" lose the hole\n * semantics — each subpath becomes its own filled region. Each subpath keeps\n * the corner specs of its own anchors. */\nexport function splitSubpaths(path: PolygonPath): PolygonPath[] {\n const { commands, coords } = path;\n const bare = withoutCorners(path);\n const out: PolygonPath[] = [];\n\n // Walk the command stream, tracking the (cmdStart, coordStart) of the\n // active subpath. On each subsequent `M`, slice out the previous subpath.\n let cmdStart = 0;\n let coordStart = 0;\n let anchorStart = 0;\n let anchors = 0;\n\n const emit = (end: number, coordEnd: number) => {\n const sub = { ...bare, commands: commands.slice(cmdStart, end), coords: coords.slice(coordStart, coordEnd) };\n const count = anchors - anchorStart;\n out.push(path.corners ? carryCorners(path, sub, anchorRange(anchorStart, count)) : sub);\n anchorStart = anchors;\n };\n\n forEachSegment(commands, coords, (cmd, ci, _px, _py, i) => {\n if (cmd === PATH_M && i > cmdStart) {\n emit(i, ci);\n cmdStart = i;\n coordStart = ci;\n }\n if (cmd !== PATH_Z) anchors++;\n });\n\n emit(commands.length, coords.length);\n\n return out;\n}\n","import { PATH_Z } from '../commands';\nimport type { Path, PolygonPath } from '../path';\nimport { countPathAnchors } from './anchors';\nimport { anchorRange, carryCorners } from './cornerCarry';\nimport { withoutCorners } from './cornerSpec';\nimport { splitSubpaths } from './splitSubpaths';\n\ninterface Placed { sub: PolygonPath; first: number; count: number }\n\nconst endsInZ = (sub: PolygonPath): boolean => sub.commands[sub.commands.length - 1] === PATH_Z;\n\n/** Whether any subpath of `path` lacks the `Z` that closes it. */\nexport function hasOpenSubpath(path: Path): boolean {\n return path.kind === 'polygon' && path.commands.length > 0\n && splitSubpaths(path).some((sub) => !endsInZ(sub));\n}\n\n/**\n * `path` as two paths: the subpaths a `Z` closes, and those left open, each in\n * the order `path` holds them and with its fill rules. A side with no subpaths\n * is `null`. A fill that does not close an open subpath covers `closed` alone.\n */\nexport function splitByClosure(\n path: PolygonPath,\n): { closed: PolygonPath | null; open: PolygonPath | null } {\n const closed: Placed[] = [];\n const open: Placed[] = [];\n if (path.commands.length > 0) {\n let first = 0;\n for (const sub of splitSubpaths(path)) {\n const count = countPathAnchors(sub);\n (endsInZ(sub) ? closed : open).push({ sub, first, count });\n first += count;\n }\n }\n const join = (placed: Placed[]): PolygonPath | null => {\n if (placed.length === 0) return null;\n const subs = placed.map((p) => p.sub);\n const commands = new Uint8Array(subs.reduce((n, s) => n + s.commands.length, 0));\n const coords = new Float32Array(subs.reduce((n, s) => n + s.coords.length, 0));\n let ci = 0, xi = 0;\n for (const s of subs) {\n commands.set(s.commands, ci);\n coords.set(s.coords, xi);\n ci += s.commands.length;\n xi += s.coords.length;\n }\n const joined = { ...withoutCorners(path), commands, coords };\n if (!path.corners) return joined;\n const sources = new Int32Array(placed.reduce((n, p) => n + p.count, 0));\n let at = 0;\n for (const p of placed) { sources.set(anchorRange(p.first, p.count), at); at += p.count; }\n return carryCorners(path, joined, sources);\n };\n return { closed: join(closed), open: join(open) };\n}\n","/**\n * Contour orientation: which way a path winds, and the same path wound the\n * other way. Under `'nonzero'` two overlapping contours fill their overlap\n * only when they wind the same way, so composing shapes from different\n * sources into one compound path first needs them to agree.\n */\n\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z, forEachSegment } from '../commands';\nimport type { Path, PolygonPath } from '../path';\nimport { fillsOpenSubpaths } from '../openFill';\nimport { carryCorners } from './cornerCarry';\n\n// Three-point Gauss-Legendre: exact for polynomials up to degree 5, and the\n// Green's-theorem integrand of a cubic is degree 5.\nconst GL_T = [0.5 - Math.sqrt(15) / 10, 0.5, 0.5 + Math.sqrt(15) / 10];\nconst GL_W = [5 / 18, 8 / 18, 5 / 18];\n\n/**\n * Signed area enclosed by `path`, summed over its contours. Positive for a\n * contour that turns clockwise on a y-down screen (the shoelace sign), so a\n * hole wound against its outer contour subtracts. An open contour counts as\n * closed by a straight edge back to its start where a fill closes it, and as\n * nothing where one does not: see `fillsOpenSubpaths`.\n * Curved segments are integrated exactly, not through their control polygon.\n * A `RectPath` has no direction and counts as positive.\n */\nexport function pathSignedArea(path: Path): number {\n if (path.kind === 'rect') return path.width * path.height;\n const { commands, coords } = path;\n const fillsOpen = fillsOpenSubpaths(path);\n let total = 0;\n let twice = 0;\n let startX = 0, startY = 0;\n let open = false;\n let endX = 0, endY = 0;\n const close = (drawn: boolean) => {\n if (open && (drawn || fillsOpen)) total += twice + endX * startY - startX * endY;\n twice = 0;\n open = false;\n };\n forEachSegment(commands, coords, (cmd, ci, px, py) => {\n if (cmd === PATH_M) {\n close(false);\n startX = endX = coords[ci];\n startY = endY = coords[ci + 1];\n open = true;\n return;\n }\n if (cmd === PATH_Z) { close(true); endX = startX; endY = startY; return; }\n if (!open) { startX = px; startY = py; open = true; }\n if (cmd === PATH_L) {\n endX = coords[ci]; endY = coords[ci + 1];\n twice += px * endY - endX * py;\n return;\n }\n const cubic = cmd === PATH_C;\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n const x3 = cubic ? coords[ci + 4] : x2, y3 = cubic ? coords[ci + 5] : y2;\n for (let k = 0; k < 3; k++) {\n const t = GL_T[k], u = 1 - t;\n let x: number, y: number, dx: number, dy: number;\n if (cubic) {\n x = u * u * u * px + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * x3;\n y = u * u * u * py + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * y3;\n dx = 3 * (u * u * (x1 - px) + 2 * u * t * (x2 - x1) + t * t * (x3 - x2));\n dy = 3 * (u * u * (y1 - py) + 2 * u * t * (y2 - y1) + t * t * (y3 - y2));\n } else {\n x = u * u * px + 2 * u * t * x1 + t * t * x2;\n y = u * u * py + 2 * u * t * y1 + t * t * y2;\n dx = 2 * (u * (x1 - px) + t * (x2 - x1));\n dy = 2 * (u * (y1 - py) + t * (y2 - y1));\n }\n twice += GL_W[k] * (x * dy - y * dx);\n }\n endX = x3; endY = y3;\n });\n close(false);\n return total / 2;\n}\n\ninterface Segment {\n cmd: number;\n /** Control points followed by the end point, as the command stores them. */\n args: number[];\n fromX: number;\n fromY: number;\n /** The anchor command the segment starts from, or -1 for an implicit start. */\n from: number;\n}\n\n/**\n * `path` with every contour traversed backwards: same region, same curves,\n * opposite winding. A closed contour keeps its starting point; an open one\n * starts from where it used to end. Corner specs stay on their anchors.\n */\nexport function reversePath(path: PolygonPath): PolygonPath {\n const cmds: number[] = [];\n const out: number[] = [];\n let segs: Segment[] = [];\n const sources: number[] = [];\n let sx = 0, sy = 0;\n let started = false;\n let anchor = -1, start = -1;\n\n const flush = (closed: boolean) => {\n if (!started) return;\n const last = segs[segs.length - 1];\n const ex = last ? last.args[last.args.length - 2] : sx;\n const ey = last ? last.args[last.args.length - 1] : sy;\n if (closed) {\n cmds.push(PATH_M); out.push(sx, sy); sources.push(start);\n if (ex !== sx || ey !== sy) { cmds.push(PATH_L); out.push(ex, ey); sources.push(last ? anchor : start); }\n } else {\n cmds.push(PATH_M); out.push(ex, ey); sources.push(last ? anchor : start);\n }\n for (let i = segs.length - 1; i >= 0; i--) {\n const s = segs[i];\n cmds.push(s.cmd);\n if (s.cmd === PATH_C) out.push(s.args[2], s.args[3], s.args[0], s.args[1]);\n else if (s.cmd === PATH_Q) out.push(s.args[0], s.args[1]);\n out.push(s.fromX, s.fromY);\n sources.push(s.from);\n }\n if (closed) cmds.push(PATH_Z);\n segs = [];\n started = false;\n };\n\n const { commands, coords } = path;\n forEachSegment(commands, coords, (cmd, ci, px, py) => {\n if (cmd === PATH_M) {\n flush(false);\n sx = coords[ci]; sy = coords[ci + 1];\n start = ++anchor;\n started = true;\n return;\n }\n if (cmd === PATH_Z) { flush(true); return; }\n if (!started) { sx = px; sy = py; start = -1; started = true; }\n const n = cmd === PATH_C ? 6 : cmd === PATH_Q ? 4 : 2;\n const from = segs.length > 0 ? anchor : start;\n segs.push({ cmd, args: Array.from(coords.subarray(ci, ci + n)), fromX: px, fromY: py, from });\n anchor++;\n });\n flush(false);\n\n const reversed = { ...path, commands: new Uint8Array(cmds), coords: new Float32Array(out) };\n return path.corners ? carryCorners(path, reversed, sources) : reversed;\n}\n","/**\n * `pathFromD` — build a weasel `Path` from an **SVG path-data string** (the\n * value of SVG's `d` attribute, e.g. `\"M0 0 L100 0 Z\"`).\n *\n * Lowers every supported command (M/m L/l H/h V/v C/c S/s Q/q T/t A/a Z/z)\n * into weasel's `PathBuilder` primitives (move, line, cubic, quadratic,\n * close). Arc commands (`A`/`a`) convert to a series of cubic Bezier curves\n * using the standard endpoint-parameterization formulas (F.6.5 in the SVG\n * spec).\n */\n\nimport { PathBuilder } from './builder';\n\nconst NUM_RE = /[+-]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][+-]?\\d+)?/g;\n/** Same grammar, anchored — used where a number's position matters. */\nconst NUM_RE_AT = /[+-]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][+-]?\\d+)?/y;\n\n/**\n * Is `d[j]` a command letter, as opposed to the `e` of an exponent? `1e2` is\n * a legal coordinate, and treating its `e` as a command drops the number and\n * everything after it in that argument run.\n */\nfunction isCommandLetter(d: string, j: number): boolean {\n const c = d[j];\n if (!/[A-Za-z]/.test(c)) return false;\n if (c !== 'e' && c !== 'E') return true;\n if (!/[\\d.]/.test(d[j - 1] ?? '')) return true;\n const k = d[j + 1] === '+' || d[j + 1] === '-' ? j + 2 : j + 1;\n return !/\\d/.test(d[k] ?? '');\n}\n\n/** Tokenize the command stream from a `d` string. */\nfunction tokenize(d: string): { cmd: string; args: number[] }[] {\n const out: { cmd: string; args: number[] }[] = [];\n // Walk character by character so we can group command-letter + arg-run.\n let i = 0;\n while (i < d.length) {\n if (isCommandLetter(d, i)) {\n // Collect numeric args until the next command letter.\n let j = i + 1;\n while (j < d.length && !isCommandLetter(d, j)) j++;\n const argSlice = d.slice(i + 1, j);\n const cmd = d[i];\n out.push({\n cmd,\n args: cmd === 'A' || cmd === 'a' ? readArcArgs(argSlice) : readNumbers(argSlice),\n });\n i = j;\n } else {\n // Skip any whitespace / commas at the head.\n i++;\n }\n }\n return out;\n}\n\nfunction readNumbers(s: string): number[] {\n const out: number[] = [];\n let m: RegExpExecArray | null;\n NUM_RE.lastIndex = 0;\n while ((m = NUM_RE.exec(s)) !== null) {\n const n = Number(m[0]);\n if (Number.isFinite(n)) out.push(n);\n }\n return out;\n}\n\n/**\n * Read an `A`/`a` argument run. The two flags are single `0`/`1` digits that\n * need no separator after them, so `a25 25 -30 0 1 50 -25` may legally be\n * written `a25 25 -30 0150 -25` — which a plain number scan reads as two\n * arguments instead of four, leaving the whole arc short and dropped.\n */\nfunction readArcArgs(s: string): number[] {\n const out: number[] = [];\n let i = 0;\n while (i < s.length) {\n const c = s[i];\n if (c === ',' || c === ' ' || c === '\\t' || c === '\\n' || c === '\\r') { i++; continue; }\n const slot = out.length % 7;\n if (slot === 3 || slot === 4) {\n if (c !== '0' && c !== '1') return out;\n out.push(c === '1' ? 1 : 0);\n i++;\n continue;\n }\n NUM_RE_AT.lastIndex = i;\n const m = NUM_RE_AT.exec(s);\n if (!m) return out;\n out.push(Number(m[0]));\n i = NUM_RE_AT.lastIndex;\n }\n return out;\n}\n\n/** Per-command argument counts (in floats). A = 7: rx ry x-axis-rotation\n * large-arc-flag sweep-flag x y. */\nconst ARG_COUNTS: Record<string, number> = {\n M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0,\n};\n\ninterface ParseState {\n x: number;\n y: number;\n startX: number;\n startY: number;\n /** Last cubic control point for S/s reflection (in absolute coords). */\n lastCubicCtrl: { x: number; y: number } | null;\n /** Last quadratic control point for T/t reflection (in absolute coords). */\n lastQuadCtrl: { x: number; y: number } | null;\n}\n\n/**\n * Build a weasel `PolygonPath` from an SVG path-data (`d`) string. Unknown\n * command letters are skipped (and reported via `onWarn` when provided); the\n * builder still returns whatever valid commands preceded them. Data that does\n * not begin with a moveto builds an empty path, and a command with the wrong\n * number of arguments ends the path before it, as SVG renders both.\n */\nexport function pathFromD(\n d: string,\n onWarn?: (message: string) => void,\n): ReturnType<PathBuilder['build']> {\n const tokens = tokenize(d);\n const b = new PathBuilder();\n const st: ParseState = {\n x: 0, y: 0, startX: 0, startY: 0,\n lastCubicCtrl: null, lastQuadCtrl: null,\n };\n\n let started = false;\n for (const { cmd, args } of tokens) {\n const upper = cmd.toUpperCase();\n const relative = cmd !== upper;\n const argCount = ARG_COUNTS[upper];\n if (argCount === undefined) {\n onWarn?.(`unknown path command: ${cmd}`);\n continue;\n }\n if (!started && upper !== 'M') {\n onWarn?.(`path data does not begin with a moveto (\"${cmd}\" comes first); nothing is drawn`);\n break;\n }\n if (upper === 'Z') {\n b.close();\n st.x = st.startX;\n st.y = st.startY;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n continue;\n }\n // M with multiple coord pairs implies subsequent pairs are L (per SVG spec).\n const groups = Math.floor(args.length / argCount);\n for (let g = 0; g < groups; g++) {\n const a = args.slice(g * argCount, (g + 1) * argCount);\n // For repeated 'M'/'m' coord pairs after the first, downgrade to L/l.\n const effectiveUpper = upper === 'M' && g > 0 ? 'L' : upper;\n runCommand(effectiveUpper, relative, a, st, b);\n started = true;\n }\n // SVG draws a path up to the command in error and no further: carrying on\n // would start every later relative command from the wrong point.\n if (groups === 0 || args.length % argCount !== 0) {\n onWarn?.(`path command \"${cmd}\" takes ${argCount} arguments at a time and has ${args.length}; the path ends before it`);\n break;\n }\n }\n\n return b.build();\n}\n\nfunction runCommand(\n upper: string,\n relative: boolean,\n a: number[],\n st: ParseState,\n b: PathBuilder,\n): void {\n const rx = relative ? st.x : 0;\n const ry = relative ? st.y : 0;\n switch (upper) {\n case 'M': {\n const x = a[0] + rx;\n const y = a[1] + ry;\n b.moveTo(x, y);\n st.x = x; st.y = y;\n st.startX = x; st.startY = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'L': {\n const x = a[0] + rx;\n const y = a[1] + ry;\n b.lineTo(x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'H': {\n const x = a[0] + (relative ? st.x : 0);\n b.lineTo(x, st.y);\n st.x = x;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'V': {\n const y = a[0] + (relative ? st.y : 0);\n b.lineTo(st.x, y);\n st.y = y;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n case 'C': {\n const x1 = a[0] + rx, y1 = a[1] + ry;\n const x2 = a[2] + rx, y2 = a[3] + ry;\n const x = a[4] + rx, y = a[5] + ry;\n b.curveTo(x1, y1, x2, y2, x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = { x: x2, y: y2 };\n st.lastQuadCtrl = null;\n return;\n }\n case 'S': {\n // Reflect prior cubic ctrl about the current point; fall back to\n // current point when prior wasn't a cubic.\n const ref = st.lastCubicCtrl ?? { x: st.x, y: st.y };\n const x1 = 2 * st.x - ref.x;\n const y1 = 2 * st.y - ref.y;\n const x2 = a[0] + rx, y2 = a[1] + ry;\n const x = a[2] + rx, y = a[3] + ry;\n b.curveTo(x1, y1, x2, y2, x, y);\n st.x = x; st.y = y;\n st.lastCubicCtrl = { x: x2, y: y2 };\n st.lastQuadCtrl = null;\n return;\n }\n case 'Q': {\n const x1 = a[0] + rx, y1 = a[1] + ry;\n const x = a[2] + rx, y = a[3] + ry;\n b.quadTo(x1, y1, x, y);\n st.x = x; st.y = y;\n st.lastQuadCtrl = { x: x1, y: y1 };\n st.lastCubicCtrl = null;\n return;\n }\n case 'T': {\n const ref = st.lastQuadCtrl ?? { x: st.x, y: st.y };\n const x1 = 2 * st.x - ref.x;\n const y1 = 2 * st.y - ref.y;\n const x = a[0] + rx, y = a[1] + ry;\n b.quadTo(x1, y1, x, y);\n st.x = x; st.y = y;\n st.lastQuadCtrl = { x: x1, y: y1 };\n st.lastCubicCtrl = null;\n return;\n }\n case 'A': {\n const rxA = Math.abs(a[0]);\n const ryA = Math.abs(a[1]);\n const xRot = a[2];\n const largeArc = a[3] !== 0;\n const sweep = a[4] !== 0;\n const ex = a[5] + rx;\n const ey = a[6] + ry;\n arcToCubics(st.x, st.y, ex, ey, rxA, ryA, xRot, largeArc, sweep, b);\n st.x = ex; st.y = ey;\n st.lastCubicCtrl = null;\n st.lastQuadCtrl = null;\n return;\n }\n default:\n return;\n }\n}\n\n/**\n * Convert an SVG elliptical arc segment to a series of cubic Bezier\n * `curveTo` calls on the builder. Standard endpoint-parameterization\n * implementation (SVG spec appendix F.6.5).\n */\nfunction arcToCubics(\n x1: number, y1: number,\n x2: number, y2: number,\n rx: number, ry: number,\n xAxisRotationDeg: number,\n largeArc: boolean,\n sweep: boolean,\n b: PathBuilder,\n): void {\n if (x1 === x2 && y1 === y2) return;\n if (rx === 0 || ry === 0) {\n b.lineTo(x2, y2);\n return;\n }\n const phi = (xAxisRotationDeg * Math.PI) / 180;\n const cosPhi = Math.cos(phi);\n const sinPhi = Math.sin(phi);\n\n // Step 1: compute (x1', y1') — rotate so x-axis aligns with ellipse axis.\n const dx = (x1 - x2) / 2;\n const dy = (y1 - y2) / 2;\n const x1p = cosPhi * dx + sinPhi * dy;\n const y1p = -sinPhi * dx + cosPhi * dy;\n\n // Correct radii if they're too small.\n let rxs = rx * rx;\n let rys = ry * ry;\n const x1ps = x1p * x1p;\n const y1ps = y1p * y1p;\n const lambda = x1ps / rxs + y1ps / rys;\n let rxFixed = rx;\n let ryFixed = ry;\n if (lambda > 1) {\n const sqrtLambda = Math.sqrt(lambda);\n rxFixed = sqrtLambda * rx;\n ryFixed = sqrtLambda * ry;\n rxs = rxFixed * rxFixed;\n rys = ryFixed * ryFixed;\n }\n\n // Step 2: center (cx', cy') in the rotated frame.\n const sign = largeArc === sweep ? -1 : 1;\n const num = rxs * rys - rxs * y1ps - rys * x1ps;\n const den = rxs * y1ps + rys * x1ps;\n const factor = sign * Math.sqrt(Math.max(0, num / den));\n const cxp = (factor * (rxFixed * y1p)) / ryFixed;\n const cyp = (factor * -(ryFixed * x1p)) / rxFixed;\n\n // Step 3: un-rotate the center back to user coords.\n const cx = cosPhi * cxp - sinPhi * cyp + (x1 + x2) / 2;\n const cy = sinPhi * cxp + cosPhi * cyp + (y1 + y2) / 2;\n\n // Step 4: start and sweep angles.\n const angle = (ux: number, uy: number, vx: number, vy: number): number => {\n const dot = ux * vx + uy * vy;\n const len = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));\n let a = Math.acos(Math.max(-1, Math.min(1, dot / len)));\n if (ux * vy - uy * vx < 0) a = -a;\n return a;\n };\n const theta1 = angle(1, 0, (x1p - cxp) / rxFixed, (y1p - cyp) / ryFixed);\n let dTheta = angle(\n (x1p - cxp) / rxFixed,\n (y1p - cyp) / ryFixed,\n (-x1p - cxp) / rxFixed,\n (-y1p - cyp) / ryFixed,\n );\n if (!sweep && dTheta > 0) dTheta -= 2 * Math.PI;\n else if (sweep && dTheta < 0) dTheta += 2 * Math.PI;\n\n // Step 5: split into ≤ 90° segments; emit a cubic per segment.\n const segCount = Math.max(1, Math.ceil(Math.abs(dTheta) / (Math.PI / 2)));\n const segAngle = dTheta / segCount;\n // Magic constant: cubic bezier handle length to approximate a circular\n // arc — for a segment of half-angle a, t = (4/3) * tan(a/2).\n const t = (4 / 3) * Math.tan(segAngle / 4);\n\n let prevX = x1;\n let prevY = y1;\n let prevDx = -Math.sin(theta1) * rxFixed;\n let prevDy = Math.cos(theta1) * ryFixed;\n\n for (let i = 1; i <= segCount; i++) {\n const theta = theta1 + i * segAngle;\n const cosT = Math.cos(theta);\n const sinT = Math.sin(theta);\n const px = cosPhi * (cosT * rxFixed) - sinPhi * (sinT * ryFixed) + cx;\n const py = sinPhi * (cosT * rxFixed) + cosPhi * (sinT * ryFixed) + cy;\n const dxNew = -sinT * rxFixed;\n const dyNew = cosT * ryFixed;\n const c1x = prevX + cosPhi * (t * prevDx) - sinPhi * (t * prevDy);\n const c1y = prevY + sinPhi * (t * prevDx) + cosPhi * (t * prevDy);\n const c2x = px - cosPhi * (t * dxNew) + sinPhi * (t * dyNew);\n const c2y = py - sinPhi * (t * dxNew) - cosPhi * (t * dyNew);\n b.curveTo(c1x, c1y, c2x, c2y, px, py);\n prevX = px;\n prevY = py;\n prevDx = dxNew;\n prevDy = dyNew;\n }\n}\n","/**\n * A station along a path: where it is at a fraction of its length, and which\n * way it is heading there.\n *\n * For anything positioned *along* geometry rather than beside it — a label on a\n * routed edge, a tick on a curve, a badge near an arrowhead. Curves are\n * flattened first, so the fraction is arc length along the drawn shape rather\n * than a curve parameter, which is what makes 0.5 look like the middle. For\n * many stations along one path, measure it once with `measurePath`.\n */\nimport type { Path } from '../path';\nimport { measurePath, type MeasurePathOptions, type PathStation } from './pathMeasure';\n\nexport type { PathStation };\n\n/** Options for `pointAlongPath`. */\nexport type PointAlongPathOptions = MeasurePathOptions;\n\n/**\n * Where `path` is at `t` of its total length, and its heading there.\n *\n * `t` is clamped to 0..1. Subpaths are measured in order and treated as one\n * run, the way a browser measures a whole `<path>`. Returns `null` for a path\n * with no points at all; a path of zero length answers at its single point,\n * heading along +X.\n */\nexport function pointAlongPath(\n path: Path,\n t: number,\n opts: PointAlongPathOptions = {},\n): PathStation | null {\n const measure = measurePath(path, opts);\n if (measure === null) return null;\n return measure.at(Math.min(Math.max(t, 0), 1) * measure.length);\n}\n","/**\n * A path as contours of cubic segments: every line and quadratic raised to a\n * cubic, each closing edge written out. The form a computation wants when it\n * treats every segment alike — interpolating two shapes, or carrying one\n * through a warp — and still needs to know which segments were straight.\n */\nimport { elevateQuadraticToCubic, splitCubicAt } from '../curve';\nimport { forEachSegment, PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from '../commands';\nimport type { Path, PathFillRule, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { resolveCorners } from './corners';\n\n/** One cubic segment, `[x0, y0, x1, y1, x2, y2, x3, y3]`, and whether it was\n * drawn straight. A straight one keeps its controls at its thirds, so it\n * interpolates and warps as a line would. */\nexport interface CubicSegment {\n c: [number, number, number, number, number, number, number, number];\n line: boolean;\n}\n\n/** One contour of segments, each starting where the one before it ends. */\nexport interface CubicContour {\n segs: CubicSegment[];\n closed: boolean;\n}\n\n/** A straight segment from (ax, ay) to (bx, by), controls at its thirds. */\nexport function lineSegment(ax: number, ay: number, bx: number, by: number): CubicSegment {\n const dx = (bx - ax) / 3;\n const dy = (by - ay) / 3;\n return { c: [ax, ay, ax + dx, ay + dy, bx - dx, by - dy, bx, by], line: true };\n}\n\n/**\n * `path`'s contours as cubic segments. A closed contour whose last point\n * stops short of its first gains the straight closing edge it is drawn with;\n * zero-length straight segments are dropped. A contour with no segments is a\n * lone point and is left out. Corner specs are expanded first.\n */\nexport function pathToCubicContours(path: Path): CubicContour[] {\n if (path.kind === 'rect') {\n const { x, y, width: w, height: h } = path;\n return [{\n closed: true,\n segs: [\n lineSegment(x, y, x + w, y),\n lineSegment(x + w, y, x + w, y + h),\n lineSegment(x + w, y + h, x, y + h),\n lineSegment(x, y + h, x, y),\n ],\n }];\n }\n const out: CubicContour[] = [];\n let current: CubicContour | null = null;\n let sx = 0;\n let sy = 0;\n const finish = (closed: boolean, px: number, py: number) => {\n if (current === null) return;\n if (closed) {\n if (px !== sx || py !== sy) current.segs.push(lineSegment(px, py, sx, sy));\n current.closed = true;\n }\n if (current.segs.length > 0) out.push(current);\n current = null;\n };\n const { commands, coords } = resolveCorners(path);\n forEachSegment(commands, coords, (cmd, ci, px, py, _i, opens) => {\n if (opens) {\n current = { segs: [], closed: false };\n sx = px;\n sy = py;\n }\n switch (cmd) {\n case PATH_M:\n finish(false, px, py);\n current = { segs: [], closed: false };\n sx = coords[ci]!;\n sy = coords[ci + 1]!;\n break;\n case PATH_L: {\n const x = coords[ci]!;\n const y = coords[ci + 1]!;\n if (x !== px || y !== py) current!.segs.push(lineSegment(px, py, x, y));\n break;\n }\n case PATH_Q: {\n const [c1x, c1y, c2x, c2y] = elevateQuadraticToCubic(\n px, py, coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!,\n );\n current!.segs.push({ c: [px, py, c1x, c1y, c2x, c2y, coords[ci + 2]!, coords[ci + 3]!], line: false });\n break;\n }\n case PATH_C:\n current!.segs.push({\n c: [px, py, coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!, coords[ci + 4]!, coords[ci + 5]!],\n line: false,\n });\n break;\n case PATH_Z:\n finish(true, px, py);\n break;\n }\n });\n const tail = current as CubicContour | null;\n if (tail !== null) {\n const last = tail.segs.at(-1);\n finish(false, last ? last.c[6] : sx, last ? last.c[7] : sy);\n }\n return out;\n}\n\n/** The path drawing `contours`: a straight segment as `L`, the rest as `C`. */\nexport function cubicContoursToPath(contours: readonly CubicContour[], fillRule: PathFillRule = 'nonzero'): PolygonPath {\n const b = new PathBuilder().setFillRule(fillRule);\n for (const { segs, closed } of contours) {\n if (segs.length === 0) continue;\n b.moveTo(segs[0]!.c[0], segs[0]!.c[1]);\n for (const { c, line } of segs) {\n if (line) b.lineTo(c[6], c[7]);\n else b.curveTo(c[2], c[3], c[4], c[5], c[6], c[7]);\n }\n if (closed) b.close();\n }\n return b.build();\n}\n\n/** `seg` split in two at parameter `t`. */\nexport function splitSegment(seg: CubicSegment, t: number): [CubicSegment, CubicSegment] {\n const [l, r] = splitCubicAt(...seg.c, t);\n return [\n { c: [...l] as CubicSegment['c'], line: seg.line },\n { c: [...r] as CubicSegment['c'], line: seg.line },\n ];\n}\n\n/** `contour` run the other way: segments in reverse order, each reversed. */\nexport function reverseContour(contour: CubicContour): CubicContour {\n return {\n closed: contour.closed,\n segs: contour.segs.slice().reverse().map(({ c, line }) => ({\n c: [c[6], c[7], c[4], c[5], c[2], c[3], c[0], c[1]],\n line,\n })),\n };\n}\n","/**\n * Shape interpolation between two paths: the steps of a blend, or the frames\n * of a morph.\n *\n * The two shapes are matched once — contour to contour, then segment to\n * segment — and every step is a straight lerp of the matched control points.\n * Where one contour has fewer segments, its longest ones are split in half\n * until the counts agree, which adds anchors without moving the outline.\n */\nimport type { Path, PathFillRule, PolygonPath } from '../path';\nimport {\n cubicContoursToPath, pathToCubicContours, reverseContour, splitSegment,\n type CubicContour, type CubicSegment,\n} from './cubicContours';\n\n/** How a blend matches the second shape's anchors to the first's. */\nexport interface BlendPathsOptions {\n /**\n * Choose, for each pair of contours, the start point (and, when `reverse`\n * is unset, the direction) of the second that keeps matched anchors\n * closest, with both contours centered on their own middles first so that\n * where the shapes sit does not decide it. Default `true`.\n */\n autoAlign?: boolean;\n /**\n * Turn the second shape's start point this many anchors further round each\n * closed contour, after any `autoAlign` choice. Negative turns it back.\n * Default 0.\n */\n startOffset?: number;\n /** Run the second shape's contours backwards. Unset, `autoAlign` decides;\n * without it, they run as drawn. */\n reverse?: boolean;\n}\n\n/** Two shapes matched for interpolation. */\nexport interface PathBlend {\n /** The shape `t` of the way from the first to the second: exactly the\n * first at 0 and the second at 1, up to the anchors matching added. */\n at(t: number): PolygonPath;\n /** Segments per matched pair of contours. */\n readonly segmentCounts: readonly number[];\n}\n\n/** The shape `t` of the way from `a` to `b`. Matching once with\n * {@link prepareBlend} is cheaper when several steps are wanted. */\nexport function blendPaths(a: Path, b: Path, t: number, opts: BlendPathsOptions = {}): PolygonPath {\n return prepareBlend(a, b, opts).at(t);\n}\n\n/** Match `a` to `b` for interpolation. */\nexport function prepareBlend(a: Path, b: Path, opts: BlendPathsOptions = {}): PathBlend {\n const ca = pathToCubicContours(a);\n const cb = pathToCubicContours(b);\n const n = Math.max(ca.length, cb.length);\n const pairs: [CubicContour, CubicContour][] = [];\n for (let i = 0; i < n; i++) {\n const x = ca[i] ?? collapsed(cb[i]!);\n const y = cb[i] ?? collapsed(ca[i]!);\n pairs.push(matchContours(x, y, opts));\n }\n const ruleA = fillRuleOf(a);\n const ruleB = fillRuleOf(b);\n return {\n segmentCounts: pairs.map(([x]) => x.segs.length),\n at(t) {\n const out = pairs.map(([x, y]) => lerpContour(x, y, t));\n return cubicContoursToPath(out, t < 0.5 ? ruleA : ruleB);\n },\n };\n}\n\nfunction fillRuleOf(path: Path): PathFillRule {\n return path.kind === 'polygon' ? path.fillRule : 'nonzero';\n}\n\n/** A contour with nothing to blend against grows from, or shrinks to, a\n * point at its own middle. */\nfunction collapsed(contour: CubicContour): CubicContour {\n const [cx, cy] = centroid(contour);\n return {\n closed: contour.closed,\n segs: contour.segs.map(({ line }) => ({ c: [cx, cy, cx, cy, cx, cy, cx, cy], line })),\n };\n}\n\n/** The mean of a contour's anchors. */\nfunction centroid(contour: CubicContour): [number, number] {\n let x = 0;\n let y = 0;\n for (const { c } of contour.segs) {\n x += c[0];\n y += c[1];\n }\n const n = Math.max(contour.segs.length, 1);\n return [x / n, y / n];\n}\n\n/** `a` and `b` with equal segment counts and `b` started where it best\n * corresponds to `a`. Both closed stay closed; otherwise both open. */\nfunction matchContours(a: CubicContour, b: CubicContour, opts: BlendPathsOptions): [CubicContour, CubicContour] {\n const closed = a.closed && b.closed;\n const x: CubicContour = { closed, segs: a.segs };\n const y: CubicContour = { closed, segs: b.segs };\n const auto = opts.autoAlign ?? true;\n const offset = Math.round(opts.startOffset ?? 0);\n const directions = opts.reverse !== undefined ? [opts.reverse] : auto ? [false, true] : [false];\n\n let best: { score: number; a: CubicContour; b: CubicContour; reversed: boolean; turn: number } | null = null;\n for (const reversed of directions) {\n const run = reversed ? reverseContour(y) : y;\n const turns = closed && auto ? run.segs.length : 1;\n for (let k = 0; k < turns; k++) {\n const [ma, mb] = equalize(x, rotate(run, k));\n const score = auto ? correspondence(ma, mb) : 0;\n if (best === null || score < best.score - 1e-9) best = { score, a: ma, b: mb, reversed, turn: k };\n }\n }\n const chosen = best!;\n if (!closed || offset === 0) return [chosen.a, chosen.b];\n const run = chosen.reversed ? reverseContour(y) : y;\n return equalize(x, rotate(run, chosen.turn + offset));\n}\n\n/** `contour` started `k` segments later; a no-op on an open one. */\nfunction rotate(contour: CubicContour, k: number): CubicContour {\n const n = contour.segs.length;\n if (!contour.closed || n === 0) return contour;\n const s = ((k % n) + n) % n;\n if (s === 0) return contour;\n return { closed: true, segs: [...contour.segs.slice(s), ...contour.segs.slice(0, s)] };\n}\n\n/** Both contours split until they have as many segments as each other. */\nfunction equalize(a: CubicContour, b: CubicContour): [CubicContour, CubicContour] {\n const n = Math.max(a.segs.length, b.segs.length);\n return [\n { closed: a.closed, segs: subdivideTo(a.segs, n) },\n { closed: b.closed, segs: subdivideTo(b.segs, n) },\n ];\n}\n\n/** `segs` with its longest segments halved until there are `n` of them. */\nfunction subdivideTo(segs: readonly CubicSegment[], n: number): CubicSegment[] {\n const out = segs.slice();\n if (out.length === 0) return out;\n while (out.length < n) {\n let longest = 0;\n let longestLen = -1;\n for (let i = 0; i < out.length; i++) {\n const len = hullLength(out[i]!);\n if (len > longestLen) { longest = i; longestLen = len; }\n }\n out.splice(longest, 1, ...splitSegment(out[longest]!, 0.5));\n }\n return out;\n}\n\n/** A segment's length estimate: the mean of its chord and control polygon. */\nfunction hullLength({ c }: CubicSegment): number {\n const chord = Math.hypot(c[6] - c[0], c[7] - c[1]);\n const hull = Math.hypot(c[2] - c[0], c[3] - c[1])\n + Math.hypot(c[4] - c[2], c[5] - c[3])\n + Math.hypot(c[6] - c[4], c[7] - c[5]);\n return (chord + hull) / 2;\n}\n\n/** How far matched anchors sit apart once each contour is centered: the sum\n * of squared distances. */\nfunction correspondence(a: CubicContour, b: CubicContour): number {\n const [ax, ay] = centroid(a);\n const [bx, by] = centroid(b);\n let sum = 0;\n const add = (pa: number, pb: number, qa: number, qb: number) => {\n sum += (pa - ax - (qa - bx)) ** 2 + (pb - ay - (qb - by)) ** 2;\n };\n for (let i = 0; i < a.segs.length; i++) {\n const p = a.segs[i]!.c;\n const q = b.segs[i]!.c;\n add(p[0], p[1], q[0], q[1]);\n }\n if (!a.closed && a.segs.length > 0) {\n const p = a.segs.at(-1)!.c;\n const q = b.segs.at(-1)!.c;\n add(p[6], p[7], q[6], q[7]);\n }\n return sum;\n}\n\nfunction lerpContour(a: CubicContour, b: CubicContour, t: number): CubicContour {\n return {\n closed: a.closed,\n segs: a.segs.map((sa, i) => {\n const sb = b.segs[i]!;\n const c = sa.c.map((v, j) => v + (sb.c[j]! - v) * t) as CubicSegment['c'];\n return { c, line: sa.line && sb.line };\n }),\n };\n}\n","/**\n * Bend a shape along a spine: the shape's x becomes distance along the spine\n * and its y distance off it, along the spine's normal. A straight edge of the\n * shape comes out curved wherever the spine bends, so each segment is\n * sampled through the warp and refit to cubics within a tolerance; anchors\n * stay where they were, so a corner of the shape stays a corner.\n */\nimport type { Path, PolygonPath } from '../path';\nimport { cubicEvalAt } from '../curve';\nimport { boundsOfPath } from './bounds';\nimport { PathBuilder } from './builder';\nimport { pathToCubicContours, type CubicSegment } from './cubicContours';\nimport type { Point } from './cubicMath';\nimport { measurePath, type PathMeasure } from './pathMeasure';\nimport { schneiderFit } from './schneiderFit';\n\n/** How a shape is laid along its spine. */\nexport interface BendAlongPathOptions {\n /**\n * `'stretch'`, the default, spreads the shape's width over the spine's\n * whole length. `'natural'` keeps its width: one unit across the shape is\n * one unit along the spine, starting at the spine's start, and a shape\n * longer than the spine runs on straight past its end.\n */\n fit?: 'stretch' | 'natural';\n /** Where across the shape's height the spine runs, 0 at its top and 1 at\n * its bottom. Default 0.5, the middle. */\n baseline?: number;\n /** Lay the shape on the other side of the spine, mirrored across it. */\n flip?: boolean;\n /** How far the refit curves may stray from the exact bend, in world\n * units. Default 0.5. */\n tolerance?: number;\n}\n\n/**\n * `shape` bent along `spine`. A spine heading left to right keeps the shape\n * upright; one heading the other way turns it over, as a road sign painted\n * along a lane does. Returns `null` when the spine has no length or the shape\n * nothing to bend.\n */\nexport function bendAlongPath(shape: Path, spine: Path, opts: BendAlongPathOptions = {}): PolygonPath | null {\n const tolerance = Math.max(opts.tolerance ?? 0.5, 1e-3);\n const measure = measurePath(spine, { flattenTolerance: tolerance / 4 });\n if (measure === null || measure.length === 0) return null;\n const contours = pathToCubicContours(shape);\n if (contours.length === 0) return null;\n\n const box = boundsOfPath(shape);\n const stretch = (opts.fit ?? 'stretch') === 'stretch';\n const along = stretch && box.width > 0 ? measure.length / box.width : 1;\n const baseY = box.y + box.height * (opts.baseline ?? 0.5);\n const side = opts.flip ? -1 : 1;\n const warp = (x: number, y: number): Point =>\n stationOff(measure, (x - box.x) * along, (y - baseY) * side);\n\n // A sample every few tolerances along the bent outline keeps the warp's own\n // curvature inside what the fit can see.\n const step = Math.max(tolerance * 4, 0.5);\n const b = new PathBuilder().setFillRule(shape.kind === 'polygon' ? shape.fillRule : 'nonzero');\n for (const { segs, closed } of contours) {\n const start = warp(segs[0]!.c[0], segs[0]!.c[1]);\n b.moveTo(start.x, start.y);\n for (const seg of segs) appendBent(b, seg, warp, step, along, tolerance);\n if (closed) b.close();\n }\n return b.build();\n}\n\n/** The point `s` along the spine and `v` off it along its normal. Past\n * either end of an open spine it carries on straight; round a closed one it\n * wraps. */\nfunction stationOff(measure: PathMeasure, s: number, v: number): Point {\n const L = measure.length;\n let at = s;\n if (measure.closed) at = ((s % L) + L) % L;\n const clamped = Math.min(Math.max(at, 0), L);\n const { point, tangent } = measure.at(clamped, true);\n const run = at - clamped;\n return {\n x: point.x + tangent.x * run - tangent.y * v,\n y: point.y + tangent.y * run + tangent.x * v,\n };\n}\n\nfunction appendBent(\n b: PathBuilder,\n seg: CubicSegment,\n warp: (x: number, y: number) => Point,\n step: number,\n along: number,\n tolerance: number,\n): void {\n const c = seg.c;\n const reach = (Math.hypot(c[2] - c[0], c[3] - c[1]) + Math.hypot(c[4] - c[2], c[5] - c[3])\n + Math.hypot(c[6] - c[4], c[7] - c[5])) * Math.max(along, 1);\n const n = Math.min(Math.max(Math.ceil(reach / step), 4), 512);\n const samples: Point[] = [];\n for (let i = 0; i <= n; i++) {\n const [x, y] = cubicEvalAt(...c, i / n);\n samples.push(warp(x, y));\n }\n const fit = schneiderFit(samples, tolerance);\n const { commands, coords } = fit;\n // The fit opens with an M at the first sample, which the pen already holds.\n for (let i = 1, ci = 2; i < commands.length; i++, ci += 6) {\n b.curveTo(coords[ci]!, coords[ci + 1]!, coords[ci + 2]!, coords[ci + 3]!, coords[ci + 4]!, coords[ci + 5]!);\n }\n}\n","/**\n * Copies of a shape placed at intervals along a path: the stations they sit\n * at, and the copies themselves.\n */\nimport { multiply, rotate, translate } from '../affine';\nimport type { Path } from '../path';\nimport { boundsOfPath } from './bounds';\nimport type { Point } from './cubicMath';\nimport { measurePath } from './pathMeasure';\nimport { transformPath } from './transformPath';\n\n/** How copies are spaced along a path. */\nexport interface RepeatAlongPathOptions {\n /**\n * How many copies. With no `spacing`, they spread evenly over the whole\n * path — end to end on an open one, evenly round a closed one — and the\n * default is 5. With a `spacing`, it caps the run; unset, as many as fit.\n */\n count?: number;\n /** Distance along the path from one copy's center to the next. */\n spacing?: number;\n /** Where a spaced run that is shorter than the path sits on it. Default\n * `'start'`. */\n align?: 'start' | 'center' | 'end';\n /** Slide every copy this far along the path. On an open path a copy slid\n * off either end is dropped; round a closed one it wraps. Default 0. */\n offset?: number;\n /** Turn each copy to the path's heading where it sits. Default `true`. */\n orient?: boolean;\n /** Curve flattening tolerance for measuring the path. Default 0.5. */\n flattenTolerance?: number;\n}\n\n/** Where one copy sits. */\nexport interface RepeatStation {\n point: Point;\n /** The path's heading there, radians clockwise from +X in a y-down frame. */\n angle: number;\n /** Arc length from the path's start. */\n distance: number;\n}\n\nconst EPS = 1e-6;\n\n/** The stations copies sit at along `path`, in order. Empty for a path with\n * no points. */\nexport function stationsAlongPath(path: Path, opts: RepeatAlongPathOptions = {}): RepeatStation[] {\n const measure = measurePath(path, opts.flattenTolerance === undefined ? {} : { flattenTolerance: opts.flattenTolerance });\n if (measure === null) return [];\n const L = measure.length;\n const offset = opts.offset ?? 0;\n const distances: number[] = [];\n const spacing = opts.spacing;\n if (spacing === undefined || !(spacing > 0)) {\n const n = Math.max(Math.floor(opts.count ?? 5), 0);\n if (measure.closed) for (let i = 0; i < n; i++) distances.push(offset + (i * L) / Math.max(n, 1));\n else if (n === 1) distances.push(offset + L / 2);\n else for (let i = 0; i < n; i++) distances.push(offset + (i * L) / (n - 1));\n } else {\n const fit = measure.closed ? Math.floor(L / spacing + EPS) : Math.floor(L / spacing + EPS) + 1;\n const n = Math.max(Math.min(opts.count === undefined ? fit : Math.floor(opts.count), fit), 0);\n const run = Math.max(n - 1, 0) * spacing;\n const align = opts.align ?? 'start';\n const start = align === 'center' ? (L - run) / 2 : align === 'end' ? L - run : 0;\n for (let i = 0; i < n; i++) distances.push(start + offset + i * spacing);\n }\n\n const out: RepeatStation[] = [];\n for (const d of distances) {\n let s = d;\n if (measure.closed && L > 0) s = ((d % L) + L) % L;\n else if (d < -EPS || d > L + EPS) continue;\n const { point, tangent } = measure.at(s);\n out.push({ point, angle: Math.atan2(tangent.y, tangent.x), distance: s });\n }\n return out;\n}\n\n/**\n * Copies of `shape`, each centered on a station along `path` — its bounding\n * box's middle on the path — and, with `orient`, turned to the heading\n * there. The shape's own +X runs along the path.\n */\nexport function repeatAlongPath(shape: Path, path: Path, opts: RepeatAlongPathOptions = {}): Path[] {\n const box = boundsOfPath(shape);\n const cx = box.x + box.width / 2;\n const cy = box.y + box.height / 2;\n const orient = opts.orient ?? true;\n return stationsAlongPath(path, opts).map(({ point, angle }) => {\n const toOrigin = translate(-cx, -cy);\n const place = translate(point.x, point.y);\n const m = orient ? multiply(place, multiply(rotate(angle), toOrigin)) : multiply(place, toOrigin);\n return transformPath(shape, m);\n });\n}\n","/**\n * Pure-geometry distance from a point to a path's boundary (stroke), with\n * no fill-side logic. Used by pickers that want to know \"how close is this\n * click to the visible edge of the shape?\" Callers combine this with\n * `pathContainsPoint` from `pathHitTest.ts` to get a closed-region\n * pick distance (0 inside, stroke-distance outside).\n *\n * A polygon path defers to geom's `nearestOnPath`; a RectPath short-circuits\n * to AABB-perimeter math.\n */\n\nimport { nearestOnPath } from '../nearest';\nimport { resolveCorners } from './corners';\nimport type { Path } from '../path';\n\n/** Distance from (px, py) to the perimeter of an axis-aligned rectangle.\n * Returns 0 if the point is on the perimeter; positive value outside or\n * inside (distance to the nearest edge). */\nfunction pointToRectPerimeterDist(\n px: number, py: number,\n rx: number, ry: number, rw: number, rh: number,\n): number {\n // Distance to the rect as a region: 0 if inside, else Euclidean distance\n // to the AABB. For interior points, return distance to the closest edge.\n const dx = Math.max(rx - px, px - (rx + rw), 0);\n const dy = Math.max(ry - py, py - (ry + rh), 0);\n if (dx > 0 || dy > 0) return Math.hypot(dx, dy);\n // Inside: distance to closest edge.\n const left = px - rx, right = rx + rw - px;\n const top = py - ry, bottom = ry + rh - py;\n return Math.min(left, right, top, bottom);\n}\n\n/** Closest Euclidean distance from (px, py) to the boundary of `path`.\n * Pure stroke distance — does *not* consult fill rule or interior. For\n * closed-region pick distance (\"0 inside, stroke-distance outside\"),\n * combine with `pathContainsPoint` at the call site. */\nexport function pathDistanceToPoint(path: Path, px: number, py: number): number {\n if (path.kind === 'rect') {\n return pointToRectPerimeterDist(px, py, path.x, path.y, path.width, path.height);\n }\n const drawn = resolveCorners(path);\n return nearestOnPath(drawn.commands, drawn.coords, px, py)?.dist ?? Infinity;\n}\n","/** Where two Bézier segments cross, by subdivision then Newton refinement. */\n\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, derivSeg, type Seg } from '../booleans/contourSegments';\n\n/** One crossing of segments `a` and `b`: the parameter on each, and the point. */\nexport interface SegmentCrossing {\n ta: number;\n tb: number;\n x: number;\n y: number;\n}\n\n/** Subdivision stops once both pieces are this flat (world units). */\nconst FLAT = 1e-4;\nconst MAX_DEPTH = 48;\n/** Crossings closer than this along both parameters are one crossing. */\nconst SAME_T = 1e-7;\n/** Two overlapping curves cross everywhere; stop collecting past this. */\nconst MAX_HITS = 16;\n\ninterface Piece {\n pts: Seg;\n t0: number;\n t1: number;\n}\n\nfunction boxOf(pts: Seg): [number, number, number, number] {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of pts) {\n if (p.x < x0) x0 = p.x;\n if (p.x > x1) x1 = p.x;\n if (p.y < y0) y0 = p.y;\n if (p.y > y1) y1 = p.y;\n }\n return [x0, y0, x1, y1];\n}\n\n/** How far the control points stray from the chord. Zero for a line. */\nfunction flatness(pts: Seg): number {\n if (pts.length === 2) return 0;\n const a = pts[0], b = pts[pts.length - 1];\n const dx = b.x - a.x, dy = b.y - a.y;\n const len = Math.hypot(dx, dy);\n let worst = 0;\n for (let i = 1; i < pts.length - 1; i++) {\n const p = pts[i];\n const d = len === 0 ? Math.hypot(p.x - a.x, p.y - a.y) : Math.abs((p.x - a.x) * dy - (p.y - a.y) * dx) / len;\n if (d > worst) worst = d;\n }\n return worst;\n}\n\n/** De Casteljau at one half, for a segment of any degree. */\nfunction halve(p: Piece): [Piece, Piece] {\n let row = p.pts;\n const left: Point[] = [row[0]];\n const right: Point[] = [row[row.length - 1]];\n while (row.length > 1) {\n const next: Point[] = [];\n for (let i = 0; i + 1 < row.length; i++) {\n next.push({ x: (row[i].x + row[i + 1].x) / 2, y: (row[i].y + row[i + 1].y) / 2 });\n }\n row = next;\n left.push(row[0]);\n right.unshift(row[row.length - 1]);\n }\n const tm = (p.t0 + p.t1) / 2;\n return [{ pts: left, t0: p.t0, t1: tm }, { pts: right, t0: tm, t1: p.t1 }];\n}\n\n/** Where chords p0→p1 and q0→q1 cross, as parameters on each, or null when\n * they are parallel or miss. `slack` widens [0, 1] on both. */\nfunction chordCross(p0: Point, p1: Point, q0: Point, q1: Point, slack: number): [number, number] | null {\n const rx = p1.x - p0.x, ry = p1.y - p0.y;\n const sx = q1.x - q0.x, sy = q1.y - q0.y;\n const den = rx * sy - ry * sx;\n if (den === 0) return null;\n const qx = q0.x - p0.x, qy = q0.y - p0.y;\n const u = (qx * sy - qy * sx) / den;\n const v = (qx * ry - qy * rx) / den;\n if (u < -slack || u > 1 + slack || v < -slack || v > 1 + slack) return null;\n return [u, v];\n}\n\n/** Newton on A(ta) − B(tb) = 0, kept inside [0, 1]. */\nfunction refine(a: Seg, b: Seg, ta: number, tb: number): [number, number] {\n for (let i = 0; i < 12; i++) {\n const pa = evalSeg(a, ta), pb = evalSeg(b, tb);\n const fx = pa.x - pb.x, fy = pa.y - pb.y;\n if (Math.abs(fx) + Math.abs(fy) < 1e-12) break;\n const da = derivSeg(a, ta), db = derivSeg(b, tb);\n // J = [da, -db]; solve J·[δa, δb] = −f.\n const det = -da.x * db.y + da.y * db.x;\n if (det === 0) break;\n const dta = (-fx * -db.y - -fy * -db.x) / det;\n const dtb = (da.x * -fy - da.y * -fx) / det;\n ta = Math.min(1, Math.max(0, ta + dta));\n tb = Math.min(1, Math.max(0, tb + dtb));\n }\n return [ta, tb];\n}\n\n/**\n * Every point where segment `a` crosses or touches segment `b` — each a line,\n * quadratic or cubic given by its control points — with the parameter on\n * each. Two lines are solved exactly; a curve is subdivided until its pieces\n * are flat, their chords crossed, and the answer refined against the curves.\n * Segments that overlap along a stretch report at most a few points of it.\n * Sorted by `ta`.\n */\nexport function intersectSegments(a: Point[], b: Point[]): SegmentCrossing[] {\n if (a.length === 2 && b.length === 2) {\n const uv = chordCross(a[0], a[1], b[0], b[1], 1e-12);\n if (!uv) return [];\n const ta = Math.min(1, Math.max(0, uv[0]));\n const tb = Math.min(1, Math.max(0, uv[1]));\n const p = evalSeg(a, ta);\n return [{ ta, tb, x: p.x, y: p.y }];\n }\n const out: SegmentCrossing[] = [];\n const push = (ta: number, tb: number) => {\n [ta, tb] = refine(a, b, ta, tb);\n const pa = evalSeg(a, ta), pb = evalSeg(b, tb);\n if (Math.hypot(pa.x - pb.x, pa.y - pb.y) > 1e-6 * (1 + Math.abs(pa.x) + Math.abs(pa.y))) return;\n if (out.some((h) => Math.abs(h.ta - ta) < SAME_T && Math.abs(h.tb - tb) < SAME_T)) return;\n out.push({ ta, tb, x: pa.x, y: pa.y });\n };\n const stack: Array<[Piece, Piece, number]> = [[{ pts: a, t0: 0, t1: 1 }, { pts: b, t0: 0, t1: 1 }, 0]];\n while (stack.length > 0 && out.length < MAX_HITS) {\n const [p, q, depth] = stack.pop()!;\n const bp = boxOf(p.pts), bq = boxOf(q.pts);\n if (bp[0] > bq[2] + FLAT || bq[0] > bp[2] + FLAT || bp[1] > bq[3] + FLAT || bq[1] > bp[3] + FLAT) continue;\n const fp = flatness(p.pts), fq = flatness(q.pts);\n if ((fp <= FLAT && fq <= FLAT) || depth >= MAX_DEPTH) {\n const uv = chordCross(p.pts[0], p.pts[p.pts.length - 1], q.pts[0], q.pts[q.pts.length - 1], 1e-6);\n if (uv) push(p.t0 + uv[0] * (p.t1 - p.t0), q.t0 + uv[1] * (q.t1 - q.t0));\n continue;\n }\n if (fp >= fq) {\n const [l, r] = halve(p);\n stack.push([l, q, depth + 1], [r, q, depth + 1]);\n } else {\n const [l, r] = halve(q);\n stack.push([p, l, depth + 1], [p, r, depth + 1]);\n }\n }\n return out.sort((h, k) => h.ta - k.ta);\n}\n","/** A path's stroke as a flat list of segments, each knowing where it sits. */\n\nimport type { Path } from '../path';\nimport { parseSubpaths } from '../booleans/contours';\nimport type { Point } from '../paths/cubicMath';\n\n/** One segment of a path's stroke, in the order the path draws them. */\nexport interface PathSegment {\n /** Control points: 2 for a line, 3 for a quadratic, 4 for a cubic. */\n pts: Point[];\n /** Index of its subpath among the path's subpaths. */\n sub: number;\n /** Index within its subpath. */\n index: number;\n /** Segments in its subpath. */\n count: number;\n /** Whether its subpath is closed, so its last segment meets its first. */\n closed: boolean;\n /** Axis-aligned box of the control points, which holds the segment. */\n box: { x0: number; y0: number; x1: number; y1: number };\n}\n\n/** `path`'s stroke as segments: a closed subpath includes its closing edge,\n * an open one does not, and a zero-length line is left out. */\nexport function pathSegments(path: Path): PathSegment[] {\n const out: PathSegment[] = [];\n parseSubpaths(path, false).forEach(({ segs, closed }, sub) => {\n segs.forEach((pts, index) => {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of pts) {\n x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x);\n y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y);\n }\n out.push({ pts, sub, index, count: segs.length, closed, box: { x0, y0, x1, y1 } });\n });\n });\n return out;\n}\n\n/** Whether two boxes overlap or touch. */\nexport function boxesNear(a: PathSegment['box'], b: PathSegment['box']): boolean {\n return a.x0 <= b.x1 && b.x0 <= a.x1 && a.y0 <= b.y1 && b.y0 <= a.y1;\n}\n\n/** Whether segments `a` and `b` of one path follow each other, so they meet\n * at a shared end that is no crossing. */\nexport function adjacentSegments(a: PathSegment, b: PathSegment): boolean {\n if (a.sub !== b.sub) return false;\n const d = Math.abs(a.index - b.index);\n return d === 1 || (a.closed && d === a.count - 1);\n}\n","/** Where paths cross one another and themselves. */\n\nimport type { Path } from '../path';\nimport { intersectSegments } from './segmentIntersections';\nimport { adjacentSegments, boxesNear, pathSegments, type PathSegment } from './pathSegments';\n\n/** A place on a path's stroke: which segment, and how far along it. */\nexport interface PathStop {\n /** Index of the path in the list it came from. */\n path: number;\n sub: number;\n /** Segment index within the subpath. */\n index: number;\n /** Parameter on that segment, in [0, 1]. */\n t: number;\n}\n\n/** A point where two strokes cross or touch, and where it falls on each. */\nexport interface PathCrossing {\n x: number;\n y: number;\n a: PathStop;\n b: PathStop;\n}\n\nconst END = 1e-9;\n\n/** Whether a hit between neighboring segments is just their shared end. */\nfunction sharedEnd(a: PathSegment, b: PathSegment, ta: number, tb: number): boolean {\n if (!adjacentSegments(a, b)) return false;\n return (ta > 1 - END && tb < END) || (ta < END && tb > 1 - END);\n}\n\n/**\n * Every crossing among `paths`: between each pair, and — unless `self` is\n * false — of a path with itself, leaving out the joint where one segment\n * meets the next. Points where strokes merely touch count too. With `of`,\n * only the crossings involving that one path.\n */\nexport function pathCrossings(paths: readonly Path[], opts: { self?: boolean; of?: number } = {}): PathCrossing[] {\n const segs = paths.map(pathSegments);\n const out: PathCrossing[] = [];\n for (let i = 0; i < segs.length; i++) {\n for (let j = i; j < segs.length; j++) {\n if (i === j && opts.self === false) continue;\n if (opts.of !== undefined && i !== opts.of && j !== opts.of) continue;\n for (let m = 0; m < segs[i].length; m++) {\n for (let n = i === j ? m + 1 : 0; n < segs[j].length; n++) {\n const sa = segs[i][m], sb = segs[j][n];\n if (!boxesNear(sa.box, sb.box)) continue;\n for (const h of intersectSegments(sa.pts, sb.pts)) {\n if (i === j && sharedEnd(sa, sb, h.ta, h.tb)) continue;\n out.push({\n x: h.x,\n y: h.y,\n a: { path: i, sub: sa.sub, index: sa.index, t: h.ta },\n b: { path: j, sub: sb.sub, index: sb.index, t: h.tb },\n });\n }\n }\n }\n }\n }\n return out;\n}\n\n/** Where `path`'s stroke is crossed, by `cutters` and by itself, as stops on\n * `path` (each with `path: 0`) — the cuts a trim chooses between. */\nexport function crossingStops(path: Path, cutters: readonly Path[]): PathStop[] {\n const stops: PathStop[] = [];\n for (const c of pathCrossings([path, ...cutters], { of: 0 })) {\n if (c.a.path === 0) stops.push(c.a);\n if (c.b.path === 0) stops.push(c.b);\n }\n return stops;\n}\n","/** Measuring one Bézier segment by arc length, and finding where a run of it ends. */\n\nimport { derivSeg, type Seg } from '../booleans/contourSegments';\n\nconst GL_X = [-0.9602898564975363, -0.7966664774136267, -0.5255324099163290, -0.1834346424956498,\n 0.1834346424956498, 0.5255324099163290, 0.7966664774136267, 0.9602898564975363];\nconst GL_W = [0.1012285362903763, 0.2223810344533745, 0.3137066458778873, 0.3626837833783620,\n 0.3626837833783620, 0.3137066458778873, 0.2223810344533745, 0.1012285362903763];\n\nconst speed = (s: Seg, t: number): number => {\n const d = derivSeg(s, t);\n return Math.hypot(d.x, d.y);\n};\n\n/** Length of `s` between parameters `a` and `b`, by Gauss–Legendre over\n * eight panels. */\nexport function segmentLength(s: Seg, a = 0, b = 1): number {\n if (s.length === 2) return speed(s, 0) * (b - a);\n const panels = 8, h = (b - a) / panels;\n let sum = 0;\n for (let k = 0; k < panels; k++) {\n const mid = a + (k + 0.5) * h;\n for (let i = 0; i < GL_X.length; i++) sum += GL_W[i] * speed(s, mid + GL_X[i] * h / 2);\n }\n return sum * h / 2;\n}\n\n/** The parameter at which `s` has run `length` from its start, clamped to\n * 0..1: Newton steps on the arc length, held inside a shrinking bracket. */\nexport function segmentTAtLength(s: Seg, length: number): number {\n const total = segmentLength(s);\n if (length <= 0 || !(total > 0)) return 0;\n if (length >= total) return 1;\n if (s.length === 2) return length / total;\n let lo = 0, hi = 1, t = length / total;\n for (let i = 0; i < 30; i++) {\n const err = segmentLength(s, 0, t) - length;\n if (Math.abs(err) < 1e-10 * Math.max(1, total)) break;\n if (err > 0) hi = t; else lo = t;\n const v = speed(s, t);\n let next = v > 0 ? t - err / v : NaN;\n if (!(next > lo && next < hi)) next = (lo + hi) / 2;\n t = next;\n }\n return t;\n}\n","/**\n * Distinguished points on one Bézier segment: its middle by length, where its\n * tangent turns horizontal or vertical, and where a line from an outside\n * point meets it at a tangent or at a right angle.\n */\n\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, derivSeg, type Seg } from '../booleans/contourSegments';\nimport { segmentLength, segmentTAtLength } from '../paths/segmentLength';\n\n/** The parameter at the middle of `s` by arc length. */\nexport function segmentMidT(s: Seg): number {\n if (s.length === 2) return 0.5;\n return segmentTAtLength(s, segmentLength(s) / 2);\n}\n\n/** Roots of a quadratic a t² + b t + c in [0, 1]. */\nfunction unitQuadraticRoots(a: number, b: number, c: number): number[] {\n const inside = (t: number) => t >= -1e-9 && t <= 1 + 1e-9;\n if (Math.abs(a) < 1e-12) {\n if (Math.abs(b) < 1e-12) return [];\n const t = -c / b;\n return inside(t) ? [Math.min(1, Math.max(0, t))] : [];\n }\n const disc = b * b - 4 * a * c;\n if (disc < 0) return [];\n const r = Math.sqrt(disc);\n return [(-b - r) / (2 * a), (-b + r) / (2 * a)].filter(inside).map((t) => Math.min(1, Math.max(0, t)));\n}\n\n/** Parameters on a curved segment, its ends included, where its tangent is\n * horizontal or vertical — the local extremes in x or y. None on a line. */\nexport function segmentExtremaT(s: Seg): number[] {\n if (s.length === 2) return [];\n const n = s.length - 1;\n // Derivative control points, then the derivative in power form per axis.\n const d: Point[] = [];\n for (let i = 0; i < n; i++) d.push({ x: n * (s[i + 1].x - s[i].x), y: n * (s[i + 1].y - s[i].y) });\n const axis = (k: 'x' | 'y'): number[] => d.length === 2\n ? unitQuadraticRoots(0, d[1][k] - d[0][k], d[0][k])\n : unitQuadraticRoots(d[0][k] - 2 * d[1][k] + d[2][k], 2 * (d[1][k] - d[0][k]), d[0][k]);\n return [...axis('x'), ...axis('y')].sort((p, q) => p - q);\n}\n\n/** Roots of `f` on [0, 1]: sign changes between samples, closed by bisection. */\nfunction rootsOn(f: (t: number) => number, samples = 48): number[] {\n const out: number[] = [];\n let t0 = 0, f0 = f(0);\n if (f0 === 0) out.push(0);\n for (let k = 1; k <= samples; k++) {\n const t1 = k / samples, f1 = f(t1);\n if (f1 === 0) out.push(t1);\n else if (f0 !== 0 && (f0 < 0) !== (f1 < 0)) {\n let lo = t0, hi = t1, flo = f0;\n for (let i = 0; i < 60; i++) {\n const mid = (lo + hi) / 2, fm = f(mid);\n if ((fm < 0) === (flo < 0)) { lo = mid; flo = fm; } else hi = mid;\n }\n out.push((lo + hi) / 2);\n }\n t0 = t1; f0 = f1;\n }\n return out;\n}\n\n/** Parameters where a line from `o` touches curved segment `s` at a tangent.\n * None on a line, whose tangent is everywhere its own direction. */\nexport function tangentTsFrom(s: Seg, o: Point): number[] {\n if (s.length === 2) return [];\n return rootsOn((t) => {\n const p = evalSeg(s, t), d = derivSeg(s, t);\n return (p.x - o.x) * d.y - (p.y - o.y) * d.x;\n });\n}\n\n/** Parameters where a line from `o` meets `s` at a right angle: the feet of\n * the perpendiculars dropped from `o`, ends of the segment excepted unless\n * the right angle falls exactly there. */\nexport function perpendicularTsFrom(s: Seg, o: Point): number[] {\n return rootsOn((t) => {\n const p = evalSeg(s, t), d = derivSeg(s, t);\n return (p.x - o.x) * d.x + (p.y - o.y) * d.y;\n });\n}\n","/**\n * Geometric snapping onto paths: the points on a set of strokes a drawn or\n * dragged point can lock to, and which of them a probe lands on.\n */\n\nimport type { Path } from '../path';\nimport type { Point } from '../paths/cubicMath';\nimport { evalSeg, type Seg } from '../booleans/contourSegments';\nimport { nearestOnCubic, nearestOnLine, nearestOnQuadratic } from '../nearest';\nimport { pathCrossings } from '../intersect/pathCrossings';\nimport { intersectSegments } from '../intersect/segmentIntersections';\nimport { pathSegments, type PathSegment } from '../intersect/pathSegments';\nimport { perpendicularTsFrom, segmentExtremaT, segmentMidT, tangentTsFrom } from './segmentFeatures';\n\n/**\n * What a snap target is.\n *\n * - `anchor` — an end of a segment: a path's anchors, a box's corners.\n * - `center` — a point a caller names as the middle of something: a text or\n * image box's center, given to {@link createPathSnapIndex} as a target.\n * - `intersection` — where two strokes cross, or one crosses itself.\n * - `tangent` — where a line from the query's origin touches a curve.\n * - `perpendicular` — where a line from the origin meets a stroke square on.\n * - `midpoint` — the middle of a segment by length.\n * - `extremum` — on a curve, where its tangent turns horizontal or vertical.\n * - `quadrant` — where a closed subpath crosses the horizontal and vertical\n * lines through the center of its box: a circle's four compass points.\n * - `nearest` — the closest point on any stroke, when nothing else is in range.\n */\nexport type PathSnapKind =\n | 'anchor' | 'center' | 'intersection' | 'tangent' | 'perpendicular' | 'midpoint' | 'extremum' | 'quadrant'\n | 'nearest';\n\n/** Every snap kind, in the order a picker lists them. */\nexport const PATH_SNAP_KINDS: readonly PathSnapKind[] = [\n 'anchor', 'center', 'intersection', 'tangent', 'perpendicular', 'midpoint', 'extremum', 'quadrant', 'nearest',\n];\n\n/** The kinds whose targets stand whatever the probe. */\nexport type StaticPathSnapKind = 'anchor' | 'center' | 'intersection' | 'midpoint' | 'extremum' | 'quadrant';\nconst STATIC_KINDS: readonly StaticPathSnapKind[] = ['anchor', 'center', 'intersection', 'midpoint', 'extremum', 'quadrant'];\n\n/** A target the probe landed on. */\nexport interface PathSnapHit {\n kind: PathSnapKind;\n x: number;\n y: number;\n /** Distance from the probe, in the query's `radius` units. */\n distance: number;\n /** Indices of the paths that make the target: two for a crossing between\n * paths, one otherwise. */\n paths: readonly number[];\n}\n\n/** A query for {@link findPathSnap}. */\nexport interface PathSnapQuery {\n /** How far from the probe a target may be, in the paths' units times\n * `scale`. */\n radius: number;\n /** Per-axis scale from the paths' units to the units `radius` is in — a\n * view's, to measure the radius in screen pixels under any zoom. Default\n * `{ x: 1, y: 1 }`. */\n scale?: { x: number; y: number };\n /** Kinds to consider. Absent, all of them. */\n kinds?: Iterable<PathSnapKind>;\n /** Where the line being drawn starts. Tangent and perpendicular targets are\n * measured from it, and there are none without it. */\n origin?: Point;\n /** Paths by index that offer no targets — the ones a drag is moving. */\n skip?: (path: number) => boolean;\n}\n\n/** A target that stands whatever the probe: an anchor, a center, a crossing,\n * a midpoint, an extremum or a quadrant point. */\nexport interface PathSnapTarget {\n kind: StaticPathSnapKind;\n x: number;\n y: number;\n paths: readonly number[];\n}\n\n/** A set of paths, prepared for repeated snapping. Static targets are\n * computed on first use and kept. */\nexport interface PathSnapIndex {\n readonly paths: readonly Path[];\n /** Each path's segments. */\n readonly segments: readonly (readonly PathSegment[])[];\n /** The targets that do not depend on the probe, of one kind. */\n targets(kind: StaticPathSnapKind): readonly PathSnapTarget[];\n}\n\n/** Prepare `paths` for {@link findPathSnap}. Build one per set of paths and\n * reuse it while they stand: a crossing search is quadratic in segments.\n * `extra` adds targets of the caller's own — the center of a box, a point\n * with no segment at it — each naming the path it belongs to. */\nexport function createPathSnapIndex(paths: readonly Path[], extra: readonly PathSnapTarget[] = []): PathSnapIndex {\n const segments = paths.map(pathSegments);\n const cache = new Map<string, PathSnapTarget[]>();\n const build = (kind: string): PathSnapTarget[] => {\n const out: PathSnapTarget[] = extra.filter((t) => t.kind === kind);\n if (kind === 'center') return out;\n if (kind === 'anchor') {\n segments.forEach((segs, path) => {\n const seen = new Set<string>();\n for (const s of segs) {\n for (const p of [s.pts[0], s.pts[s.pts.length - 1]]) {\n const key = `${p.x},${p.y}`;\n if (seen.has(key)) continue;\n seen.add(key);\n out.push({ kind: 'anchor', x: p.x, y: p.y, paths: [path] });\n }\n }\n });\n return out;\n }\n if (kind === 'intersection') {\n for (const c of pathCrossings(paths)) {\n out.push({ kind: 'intersection', x: c.x, y: c.y, paths: c.a.path === c.b.path ? [c.a.path] : [c.a.path, c.b.path] });\n }\n return out;\n }\n segments.forEach((segs, path) => {\n if (kind === 'quadrant') {\n for (const p of quadrantPoints(segs)) out.push({ kind: 'quadrant', ...p, paths: [path] });\n return;\n }\n for (const s of segs) {\n const ts = kind === 'midpoint' ? [segmentMidT(s.pts)] : segmentExtremaT(s.pts);\n for (const t of ts) out.push({ kind: kind as StaticPathSnapKind, ...evalSeg(s.pts, t), paths: [path] });\n }\n });\n return out;\n };\n return {\n paths,\n segments,\n targets(kind) {\n let hit = cache.get(kind);\n if (!hit) cache.set(kind, (hit = build(kind)));\n return hit;\n },\n };\n}\n\n/** The compass points of each closed subpath in `segs` about the center of its box. */\nfunction quadrantPoints(segs: readonly PathSegment[]): Point[] {\n const out: Point[] = [];\n const subs = new Map<number, PathSegment[]>();\n for (const s of segs) if (s.closed) subs.set(s.sub, [...(subs.get(s.sub) ?? []), s]);\n for (const sub of subs.values()) {\n const x0 = Math.min(...sub.map((s) => s.box.x0)), x1 = Math.max(...sub.map((s) => s.box.x1));\n const y0 = Math.min(...sub.map((s) => s.box.y0)), y1 = Math.max(...sub.map((s) => s.box.y1));\n const cx = (x0 + x1) / 2, cy = (y0 + y1) / 2;\n const across: Seg[] = [[{ x: x0 - 1, y: cy }, { x: x1 + 1, y: cy }], [{ x: cx, y: y0 - 1 }, { x: cx, y: y1 + 1 }]];\n for (const line of across) {\n for (const s of sub) {\n for (const h of intersectSegments(s.pts, line)) {\n if (!out.some((p) => Math.hypot(p.x - h.x, p.y - h.y) < 1e-6)) out.push({ x: h.x, y: h.y });\n }\n }\n }\n }\n return out;\n}\n\nfunction nearestOnSeg(s: Seg, p: Point): { x: number; y: number; dist: number } {\n if (s.length === 2) return nearestOnLine(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y);\n if (s.length === 3) return nearestOnQuadratic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y);\n return nearestOnCubic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y, s[3].x, s[3].y);\n}\n\n/**\n * The snap target nearest `probe` within `query.radius`, or null when none\n * is in range. Every enabled kind competes on distance, except `nearest`,\n * which answers only when no other target is in range.\n */\nexport function findPathSnap(index: PathSnapIndex, probe: Point, query: PathSnapQuery): PathSnapHit | null {\n let best: PathSnapHit | null = null;\n for (const hit of findPathSnaps(index, probe, query)) if (!best || hit.distance < best.distance) best = hit;\n return best;\n}\n\n/**\n * Every snap target within `query.radius` of `probe`, unsorted. `nearest`\n * hits appear only when no other target is in range. Tangent and perpendicular targets\n * closer to the origin than the radius are dropped, so a line cannot snap\n * back onto its own start.\n */\nexport function findPathSnaps(index: PathSnapIndex, probe: Point, query: PathSnapQuery): PathSnapHit[] {\n const kinds = new Set(query.kinds ?? PATH_SNAP_KINDS);\n const r = query.radius;\n const sx = Math.abs(query.scale?.x ?? 1), sy = Math.abs(query.scale?.y ?? 1);\n const metric = (dx: number, dy: number) => Math.hypot(dx * sx, dy * sy);\n const skip = query.skip ?? (() => false);\n const hits: PathSnapHit[] = [];\n const offer = (kind: PathSnapKind, x: number, y: number, paths: readonly number[]) => {\n const distance = metric(x - probe.x, y - probe.y);\n if (distance <= r) hits.push({ kind, x, y, distance, paths });\n };\n\n for (const kind of STATIC_KINDS) {\n if (!kinds.has(kind)) continue;\n for (const t of index.targets(kind)) if (!t.paths.some(skip)) offer(kind, t.x, t.y, t.paths);\n }\n\n const rx = r / (sx || 1), ry = r / (sy || 1);\n const near = (s: PathSegment) =>\n s.box.x0 - rx <= probe.x && probe.x <= s.box.x1 + rx && s.box.y0 - ry <= probe.y && probe.y <= s.box.y1 + ry;\n const o = query.origin;\n if (o && (kinds.has('tangent') || kinds.has('perpendicular'))) {\n index.segments.forEach((segs, path) => {\n if (skip(path)) return;\n for (const s of segs) {\n if (!near(s)) continue;\n const lists: Array<[PathSnapKind, number[]]> = [];\n if (kinds.has('tangent')) lists.push(['tangent', tangentTsFrom(s.pts, o)]);\n if (kinds.has('perpendicular')) lists.push(['perpendicular', perpendicularTsFrom(s.pts, o)]);\n for (const [kind, ts] of lists) {\n for (const t of ts) {\n const p = evalSeg(s.pts, t);\n if (metric(p.x - o.x, p.y - o.y) > r) offer(kind, p.x, p.y, [path]);\n }\n }\n }\n });\n }\n\n if (hits.length > 0 || !kinds.has('nearest')) return hits;\n index.segments.forEach((segs, path) => {\n if (skip(path)) return;\n for (const s of segs) {\n if (!near(s)) continue;\n const n = nearestOnSeg(s.pts, probe);\n offer('nearest', n.x, n.y, [path]);\n }\n });\n return hits;\n}\n","/** Writing segment lists back out as a path, the inverse of `pathSegments`. */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Seg } from '../booleans/contourSegments';\nimport { writePath } from '../booleans/cutRegions';\n\n/** A run of segments, open or closed. */\nexport interface SegmentRun {\n segs: Seg[];\n closed: boolean;\n}\n\n/**\n * `runs` as a polygon path carrying `like`'s fill rule and open-fill setting.\n * A closed run's closing line is left to its `Z`, as a path reads it in, so\n * a run that went through `pathSegments` comes back with the same anchors.\n */\nexport function writeSubpaths(runs: readonly SegmentRun[], like: Path): PolygonPath {\n const trimmed = runs.filter((r) => r.segs.length > 0).map((r) => {\n if (!r.closed || r.segs.length < 2) return r;\n const last = r.segs[r.segs.length - 1];\n const start = r.segs[0][0];\n const end = last[last.length - 1];\n const closesItself = last.length === 2 && end.x === start.x && end.y === start.y;\n return closesItself ? { segs: r.segs.slice(0, -1), closed: true } : r;\n });\n const out = writePath(trimmed, like.kind === 'polygon' ? like.fillRule : 'nonzero');\n return like.kind === 'polygon' && like.openFill !== undefined ? { ...out, openFill: like.openFill } : out;\n}\n","/**\n * Trim: remove the piece of a stroke between the crossings on either side of\n * a point, as a drafting trim does.\n */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport { evalSeg, subSeg, type Seg } from '../booleans/contourSegments';\nimport { parseSubpaths } from '../booleans/contours';\nimport { nearestOnCubic, nearestOnLine, nearestOnQuadratic } from '../nearest';\nimport { crossingStops } from '../intersect/pathCrossings';\nimport { writeSubpaths, type SegmentRun } from '../intersect/writeSubpaths';\nimport { keepCorners } from './cornerRestore';\n\n/** Options for {@link trimPathAt}. */\nexport interface TrimPathOptions {\n /** How far from the stroke `probe` may be. Default: any distance. */\n radius?: number;\n}\n\n/** What {@link trimPathAt} did. */\nexport interface TrimResult {\n /** The path with the piece gone; it has no commands when nothing is left. */\n path: PolygonPath;\n /** The piece removed, as an open path. */\n removed: PolygonPath;\n}\n\nconst EDGE = 1e-7;\n\nfunction nearestOn(s: Seg, p: Point): { t: number; dist: number } {\n if (s.length === 2) return nearestOnLine(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y);\n if (s.length === 3) return nearestOnQuadratic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y);\n return nearestOnCubic(p.x, p.y, s[0].x, s[0].y, s[1].x, s[1].y, s[2].x, s[2].y, s[3].x, s[3].y);\n}\n\n/** The stretch of `segs` between run positions `a` and `b`, where position\n * `k + t` is parameter `t` on segment `k`. On a closed run `b` may pass the\n * end and wrap round. */\nfunction stretch(segs: readonly Seg[], a: number, b: number): Seg[] {\n const n = segs.length;\n const out: Seg[] = [];\n for (let k = Math.floor(a); k < b; k++) {\n const s = segs[((k % n) + n) % n];\n const t0 = Math.max(0, a - k), t1 = Math.min(1, b - k);\n if (t1 - t0 <= EDGE) continue;\n const piece = subSeg(s, t0, t1, evalSeg(s, t0), evalSeg(s, t1));\n if (piece) out.push(piece);\n }\n return out;\n}\n\n/**\n * Remove the piece of `path`'s stroke that `probe` is nearest, bounded by the\n * nearest crossings on either side — with any of `cutters`, or with the path\n * itself. On an open subpath an end with no crossing before it bounds the\n * piece too, so a subpath touched only at its ends goes whole; a closed\n * subpath is opened, and one crossed at a single point is removed whole.\n *\n * Returns null when the probe is further than `radius` from the stroke, or\n * when nothing crosses or touches the subpath it is on. Curves are split where they are\n * cut and keep their type; other subpaths are left as they were.\n */\nexport function trimPathAt(\n path: Path,\n cutters: readonly Path[],\n probe: Point,\n opts: TrimPathOptions = {},\n): TrimResult | null {\n const subs = parseSubpaths(path, false);\n let hit: { sub: number; at: number; dist: number } | null = null;\n subs.forEach(({ segs }, sub) => segs.forEach((s, k) => {\n const n = nearestOn(s, probe);\n if (!hit || n.dist < hit.dist) hit = { sub, at: k + n.t, dist: n.dist };\n }));\n const found = hit as { sub: number; at: number; dist: number } | null;\n if (!found || found.dist > (opts.radius ?? Infinity)) return null;\n\n const { segs, closed } = subs[found.sub];\n const n = segs.length;\n const touches = crossingStops(path, cutters)\n .filter((s) => s.sub === found.sub)\n .map((s) => s.index + s.t);\n if (touches.length === 0) return null;\n const stops = touches\n .map((s) => (closed && s > n - EDGE ? 0 : s))\n .filter((s) => closed || (s > EDGE && s < n - EDGE))\n .sort((p, q) => p - q);\n\n const below = stops.filter((s) => s < found.at);\n const above = stops.filter((s) => s > found.at);\n const keep: SegmentRun[] = [];\n let removed: Seg[];\n if (closed) {\n if (stops.length === 0) return null;\n const lo = below.length > 0 ? below[below.length - 1] : stops[stops.length - 1] - n;\n const hi = above.length > 0 ? above[0] : stops[0] + n;\n removed = stretch(segs, lo, hi);\n if (hi < lo + n - EDGE) keep.push({ segs: stretch(segs, hi, lo + n), closed: false });\n } else {\n const lo = below.length > 0 ? below[below.length - 1] : 0;\n const hi = above.length > 0 ? above[0] : n;\n removed = stretch(segs, lo, hi);\n if (lo > EDGE) keep.push({ segs: stretch(segs, 0, lo), closed: false });\n if (hi < n - EDGE) keep.push({ segs: stretch(segs, hi, n), closed: false });\n }\n\n const runs: SegmentRun[] = [];\n subs.forEach((s, i) => {\n if (i === found.sub) runs.push(...keep);\n else runs.push({ segs: s.segs, closed: s.closed });\n });\n return {\n path: keepCorners([path], writeSubpaths(runs, path)),\n removed: writeSubpaths([{ segs: removed, closed: false }], path),\n };\n}\n","import type { PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\n\n/** What stays put of a path while some of its anchors move. */\nexport interface PathAwayFromAnchors {\n /** The segments touching none of the moving anchors, as open runs; a\n * subpath none of them is on stays as it was. */\n path: PolygonPath;\n /** Every anchor that is not moving, a lone one with no segment left at it\n * included. */\n anchors: Point[];\n}\n\n/** An open run of `sub` from anchor `from` through `count` segments, its\n * outer handles dropped. */\nfunction run(sub: readonly PenAnchor[], from: number, count: number): PenAnchor[] {\n const out: PenAnchor[] = [];\n for (let j = 0; j <= count; j++) out.push({ ...sub[(from + j) % sub.length] });\n delete out[0].inHandle;\n delete out[out.length - 1].outHandle;\n return out;\n}\n\n/**\n * The part of `path` that holds still while the anchors at `moving` (flat\n * indices, as anchor editing numbers them) are dragged: every segment with a\n * moving anchor at either end is dropped, and so are the moving anchors.\n */\nexport function pathAwayFromAnchors(path: PolygonPath, moving: Iterable<number>): PathAwayFromAnchors {\n const set = pathToAnchors(path);\n const flat = new Set(moving);\n const subs: PenAnchor[][] = [];\n const closed: boolean[] = [];\n const anchors: Point[] = [];\n let base = 0;\n set.anchors.forEach((sub, s) => {\n const n = sub.length;\n const moves = (i: number) => flat.has(base + (i % n));\n for (let i = 0; i < n; i++) if (!moves(i)) anchors.push({ x: sub[i].x, y: sub[i].y });\n const first = sub.findIndex((_, i) => moves(i));\n if (first < 0) {\n subs.push(sub);\n closed.push(set.closed[s]);\n } else {\n // A closed subpath is walked from a moving anchor, so no kept run wraps.\n const start = set.closed[s] ? first : 0;\n const segs = set.closed[s] ? n : n - 1;\n let runFrom = -1;\n for (let j = 0; j <= segs; j++) {\n const k = start + j;\n const kept = j < segs && !moves(k) && !moves(k + 1);\n if (kept && runFrom < 0) runFrom = k;\n if (!kept && runFrom >= 0) {\n subs.push(run(sub, runFrom % n, k - runFrom));\n closed.push(false);\n runFrom = -1;\n }\n }\n }\n base += n;\n });\n return { path: anchorsToPath(subs, closed, path), anchors };\n}\n","/**\n * Where each point of an edited path came from, so an array kept per point (a skin's\n * weights) can follow an edit that inserts, deletes, or reorders points.\n */\n\nimport type { PolygonPath } from '../path';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\nimport type { AnchorSet } from './anchorEdits';\nimport type { Point } from './cubicMath';\n\n/**\n * Where a point of an edited path came from: point `a` of the path before the edit, or for a\n * point the edit made, a blend `t` of the way from point `a` to point `b`.\n */\nexport interface PointOrigin {\n a: number;\n b: number;\n t: number;\n /** On an anchor's own point: its subpath now runs the other way through it. */\n reversed?: true;\n}\n\n/** The points of the path before the edit that one anchor held. */\ninterface Held {\n point: number;\n in?: number;\n out?: number;\n /** Where the anchor sat before the edit: its subpath and its index there. */\n sub?: number;\n idx?: number;\n}\n\nconst at = (x: number): Point => ({ x, y: x });\nconst keyOf = (p: Point): string => `${p.x},${p.y}`;\n\n/**\n * Which point of `path` each anchor of `set` was decoded from. `pathToAnchors` runs again\n * over a path whose every point holds its own index, so the two walks cannot disagree.\n */\nfunction heldBy(path: PolygonPath, set: AnchorSet): Held[][] {\n const coords = new Float32Array(path.coords.length);\n for (let i = 0; i < coords.length; i++) coords[i] = i >> 1;\n const indexed = pathToAnchors({ ...path, coords }).anchors;\n return indexed.map((sub, s) => {\n // No two index points coincide, so a closing curve the real walk folded is unfolded here.\n if (sub.length === set.anchors[s].length + 1) sub[0].inHandle = sub.pop()!.inHandle;\n return sub.map((a, i) => ({ point: a.x, in: a.inHandle?.x, out: a.outHandle?.x, sub: s, idx: i }));\n });\n}\n\n/** For each anchor of `path`, by flat index, the index of the point that holds it. */\nexport function anchorPointIndices(path: PolygonPath): number[] {\n return heldBy(path, pathToAnchors(path)).flat().map((held) => held.point);\n}\n\n/** For each point `anchorsToPath` writes for `set`: the flat index of the anchor it belongs to,\n * times 3, plus 0 for the anchor's own point, 1 for its in handle, and 2 for its out handle. */\nfunction writtenFrom(set: AnchorSet): Float32Array {\n let flat = 0;\n const coded = set.anchors.map((sub) => sub.map((a) => {\n const k = 3 * flat++;\n return {\n ...at(k),\n ...(a.inHandle ? { inHandle: at(k + 1) } : {}),\n ...(a.outHandle ? { outHandle: at(k + 2) } : {}),\n };\n }));\n return anchorsToPath(coded, set.closed).coords;\n}\n\n/** The nearest anchor of `sub` from `i`, stepping by `step`, that the path before the edit\n * held; around the seam when the subpath is closed. */\nfunction neighbor(sub: readonly (Held | undefined)[], closed: boolean, i: number, step: 1 | -1): number {\n for (let n = 1; n < sub.length; n++) {\n let j = i + step * n;\n if (j < 0 || j >= sub.length) {\n if (!closed) return -1;\n j = (j + sub.length) % sub.length;\n }\n if (sub[j]) return j;\n }\n return -1;\n}\n\n/** The origin of an anchor the edit made: its held neighbors, blended by its distance to each. */\nfunction blended(\n anchors: readonly PenAnchor[],\n held: readonly (Held | undefined)[],\n closed: boolean,\n i: number,\n): PointOrigin | null {\n const p = neighbor(held, closed, i, -1);\n const n = neighbor(held, closed, i, 1);\n if (p === -1 && n === -1) return null;\n const a = held[p === -1 ? n : p]!.point;\n const b = held[n === -1 ? p : n]!.point;\n if (p === -1 || n === -1 || a === b) return { a, b: a, t: 0 };\n const dp = Math.hypot(anchors[i].x - anchors[p].x, anchors[i].y - anchors[p].y);\n const dn = Math.hypot(anchors[i].x - anchors[n].x, anchors[i].y - anchors[n].y);\n return { a, b, t: dp + dn > 0 ? dp / (dp + dn) : 0 };\n}\n\n/**\n * For each anchor of a subpath after an edit, whether the subpath now runs the other way\n * through it: its neighbors in the new walk follow it in the old one more often backward than\n * forward. An anchor the edit made takes the answer of the nearest kept anchor before it.\n */\nfunction runsBackward(\n sub: readonly (Held | undefined)[],\n closed: boolean,\n before: { lengths: readonly number[]; closed: readonly boolean[] },\n): boolean[] {\n const nextWas = (h: Held): number => {\n const n = before.lengths[h.sub!];\n return h.idx! + 1 < n ? h.idx! + 1 : before.closed[h.sub!] ? 0 : -1;\n };\n // +1 when `y`, after `x` in the new walk, came after it in the old one too; -1 when before it.\n const step = (x: Held | undefined, y: Held | undefined): number => {\n if (x?.sub === undefined || y?.sub === undefined || x.sub !== y.sub) return 0;\n return nextWas(x) === y.idx ? 1 : nextWas(y) === x.idx ? -1 : 0;\n };\n const at = (i: number) => (closed ? sub[(i + sub.length) % sub.length] : sub[i]);\n const own = sub.map((h, i) => (h ? step(at(i - 1), h) + step(h, at(i + 1)) < 0 : null));\n return own.map((flag, i) => {\n if (flag !== null) return flag;\n const p = neighbor(sub, closed, i, -1);\n const n = neighbor(sub, closed, i, 1);\n return p !== -1 ? own[p] === true : n !== -1 && own[n] === true;\n });\n}\n\n/** What an anchor the edit put exactly where one was holds: that anchor's point, and each\n * handle that is where one of its handles was. */\nfunction copied(anchor: PenAnchor, byPlace: ReadonlyMap<string, Held>): Held | undefined {\n const was = byPlace.get(keyOf(anchor));\n if (!was) return undefined;\n const handle = (h: Point | undefined) => (h ? byPlace.get(`${keyOf(anchor)}:${keyOf(h)}`)?.point : undefined);\n return { ...was, in: handle(anchor.inHandle), out: handle(anchor.outHandle) };\n}\n\n/**\n * `editAnchorSet`, answering also where each point of the new path came from.\n *\n * An anchor the edit kept, moved or not, keeps its points. One the edit put exactly where an\n * anchor was takes that anchor's, each handle by where it is, so a subpath turned around\n * keeps its weights. A handle an edit gave an anchor that had none takes the anchor's point. An anchor the edit made is a blend of the nearest kept anchors either side\n * of it in its subpath, by its distance to each, or a copy of the one it has; its origin is\n * `null` when its subpath has none.\n */\nexport function editAnchorSetTracked(\n path: PolygonPath,\n edit: (set: AnchorSet) => boolean | void,\n): { path: PolygonPath; origins: (PointOrigin | null)[] } | null {\n const set = pathToAnchors(path);\n const byAnchor = new Map<PenAnchor, Held>();\n const byPlace = new Map<string, Held>();\n heldBy(path, set).forEach((sub, s) => sub.forEach((held, i) => {\n const anchor = set.anchors[s][i];\n byAnchor.set(anchor, held);\n if (byPlace.has(keyOf(anchor))) return;\n // Handles are filed under where they are, for an anchor that comes back as a copy.\n if (anchor.inHandle) byPlace.set(`${keyOf(anchor)}:${keyOf(anchor.inHandle)}`, { point: held.in! });\n if (anchor.outHandle) byPlace.set(`${keyOf(anchor)}:${keyOf(anchor.outHandle)}`, { point: held.out! });\n byPlace.set(keyOf(anchor), { point: held.point, sub: held.sub, idx: held.idx });\n }));\n\n const before = { lengths: set.anchors.map((sub) => sub.length), closed: [...set.closed] };\n if (edit(set) === false) return null;\n\n const held: (Held | undefined)[] = [];\n const own: (PointOrigin | null)[] = [];\n set.anchors.forEach((sub, s) => {\n const subHeld = sub.map((a) => byAnchor.get(a) ?? copied(a, byPlace));\n const flipped = runsBackward(subHeld, set.closed[s], before);\n sub.forEach((_, i) => {\n const h = subHeld[i];\n held.push(h);\n const origin = h ? { a: h.point, b: h.point, t: 0 } : blended(sub, subHeld, set.closed[s], i);\n own.push(origin && flipped[i] ? { ...origin, reversed: true } : origin);\n });\n });\n\n const origins = Array.from(writtenFrom(set).filter((_, i) => i % 2 === 0), (code) => {\n const anchor = Math.floor(code / 3);\n const handle = code % 3 === 1 ? held[anchor]?.in : code % 3 === 2 ? held[anchor]?.out : undefined;\n return handle === undefined ? own[anchor] : { a: handle, b: handle, t: 0 };\n });\n return { path: anchorsToPath(set.anchors, set.closed, path), origins };\n}\n\n/**\n * An array kept per point of a path, carried through an edit: `origins` is what\n * {@link editAnchorSetTracked} answered. A point with no origin, and an origin past the\n * array's end, read 0.\n */\nexport function remapPointValues(\n values: ArrayLike<number>,\n origins: readonly (PointOrigin | null)[],\n): number[] {\n return origins.map((o) => {\n if (!o) return 0;\n const a = values[o.a] ?? 0;\n return o.t === 0 ? a : a + ((values[o.b] ?? 0) - a) * o.t;\n });\n}\n","/**\n * Screen-pixel lengths in world units, per axis.\n *\n * Chrome declares its hit zones in screen pixels — an 8px handle stays 8px at\n * every zoom, because it paints in screen space. Converting one such length to\n * world units with a single scalar (see `meanScale`) is exact only under\n * uniform zoom; per-axis it is too generous on one axis and too mean on the\n * other, so the pickable region stops matching the painted one.\n *\n * Prefer {@link withinPxBox} / {@link withinPxRadius}, which compare in screen\n * space and so can't drift from the paint at all. {@link pxExtent} is for the\n * cases that must stay in world units — a tolerance handed to geometry that\n * doesn't know about the view.\n */\n\nexport interface Scale2 {\n x: number;\n y: number;\n}\n\n/** One screen-pixel length as world-space extents, per axis. `scale` is a\n * view's, so neither axis is zero (see `View`).\n *\n * With `rotation`, the axes are a frame turned that far from world, and each\n * extent is how far along it an edge across it must move to move `px` on\n * screen — which, under non-uniform zoom, is not the extent along the screen\n * axis nearest to it. */\nexport function pxExtent(px: number, scale: Scale2, rotation = 0): { x: number; y: number } {\n if (!rotation) {\n return {\n x: px / Math.abs(scale.x),\n y: px / Math.abs(scale.y),\n };\n }\n const c = Math.cos(rotation), s = Math.sin(rotation);\n return {\n x: px * Math.hypot(c / scale.x, s / scale.y),\n y: px * Math.hypot(s / scale.x, c / scale.y),\n };\n}\n\n/** World delta → screen delta. Only the scale participates: translation\n * cancels in a difference, and the kit's views carry no skew. */\nexport function scaleDelta(dx: number, dy: number, scale: Scale2): { x: number; y: number } {\n return { x: dx * scale.x, y: dy * scale.y };\n}\n\n/**\n * Is a world-space delta inside a screen-space square of half-extent `px`?\n *\n * The square is axis-aligned **on screen**, which is what a handle painted in\n * screen space actually is — so this stays true under non-uniform zoom and\n * under a rotated target, where an axis-aligned world-space test is a rotated\n * rectangle on screen.\n */\nexport function withinPxBox(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return Math.abs(s.x) <= px && Math.abs(s.y) <= px;\n}\n\n/** Is a world-space delta inside a screen-space circle of radius `px`? */\nexport function withinPxRadius(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return s.x * s.x + s.y * s.y <= px * px;\n}\n\n/**\n * A world point pushed `px` screen pixels off an edge, along the edge's normal\n * as it lands on screen. `normal` is the edge's outward normal in world space.\n *\n * Scaling the world normal by the view is not the same thing: under\n * non-uniform zoom the image of a normal is no longer perpendicular to the\n * image of its edge, so chrome placed that way drifts sideways and sits closer\n * than `px`. Returns the point in world coords and the on-screen unit normal.\n */\nexport function standoff(\n anchor: { x: number; y: number },\n normal: { x: number; y: number },\n px: number,\n scale: Scale2,\n): { x: number; y: number; nx: number; ny: number } {\n // The edge's screen normal is S⁻ᵀn, here scaled by det S to stay finite.\n const k = Math.sign(scale.x * scale.y) || 1;\n let nx = normal.x * scale.y * k;\n let ny = normal.y * scale.x * k;\n const l = Math.hypot(nx, ny) || 1;\n nx /= l;\n ny /= l;\n return { x: anchor.x + (nx * px) / scale.x, y: anchor.y + (ny * px) / scale.y, nx, ny };\n}\n\n/** The screen angle a frame turned `rotation` from world lands its x axis at.\n * Equals `rotation` under uniform zoom; non-uniform zoom bends it. */\nexport function screenAngleOf(rotation: number, scale: Scale2): number {\n return Math.atan2(Math.sin(rotation) * scale.y, Math.cos(rotation) * scale.x);\n}\n","import type { PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\nimport { fitCubicWithTangents } from './schneiderFit';\n\nconst SAMPLES_PER_SEGMENT = 16;\nconst SPLIT_SEARCH_STEPS = 40;\n\n/**\n * Controls for the one cubic that replaces `prev → removed → next` when\n * `removed` is deleted. The new controls keep the directions the curve leaves\n * `prev` and arrives at `next` with, and their lengths are least-squares fitted\n * to samples of the two segments being replaced, so the curve keeps its shape\n * as closely as one cubic can. Where `removed` was inserted by splitting a\n * cubic, the original cubic comes back.\n */\nexport function fitCubicThroughDeletion(\n prev: PenAnchor,\n removed: PenAnchor,\n next: PenAnchor,\n): { c1: Point; c2: Point } {\n const first = segmentControls(prev, removed);\n const second = segmentControls(removed, next);\n const samples = [...sampleCubic(first), ...sampleCubic(second).slice(1)];\n const tStart = startTangent(first);\n const tEnd = startTangent(reversed(second));\n\n // Each half is sampled evenly in its own parameter, so on the merged curve\n // the samples sit at a piecewise-linear parameter that breaks at the\n // removed anchor's `s`. Search for the `s` the samples fit best.\n const fitAt = (s: number) => {\n const params = splitParams(s);\n const fit = fitCubicWithTangents(samples, tStart, tEnd, { params, passes: 0 });\n return { fit, error: squaredError(samples, params, prev, fit.cp1, fit.cp2, next) };\n };\n let lo = 0.02;\n let hi = 0.98;\n const phi = (Math.sqrt(5) - 1) / 2;\n let m1 = hi - phi * (hi - lo);\n let m2 = lo + phi * (hi - lo);\n let e1 = fitAt(m1).error;\n let e2 = fitAt(m2).error;\n for (let i = 0; i < SPLIT_SEARCH_STEPS; i++) {\n if (e1 < e2) {\n hi = m2; m2 = m1; e2 = e1;\n m1 = hi - phi * (hi - lo); e1 = fitAt(m1).error;\n } else {\n lo = m1; m1 = m2; e1 = e2;\n m2 = lo + phi * (hi - lo); e2 = fitAt(m2).error;\n }\n }\n const { cp1, cp2 } = fitCubicWithTangents(samples, tStart, tEnd, {\n params: splitParams((lo + hi) / 2),\n });\n return { c1: cp1, c2: cp2 };\n}\n\ntype Cubic = [Point, Point, Point, Point];\n\nfunction splitParams(s: number): number[] {\n const out: number[] = [];\n for (let i = 0; i <= SAMPLES_PER_SEGMENT; i++) out.push((s * i) / SAMPLES_PER_SEGMENT);\n for (let i = 1; i <= SAMPLES_PER_SEGMENT; i++) out.push(s + ((1 - s) * i) / SAMPLES_PER_SEGMENT);\n return out;\n}\n\nfunction squaredError(\n samples: readonly Point[],\n params: readonly number[],\n p0: Point, p1: Point, p2: Point, p3: Point,\n): number {\n let sum = 0;\n for (let i = 0; i < samples.length; i++) {\n const q = cubicPointAt(p0, p1, p2, p3, params[i]);\n sum += (q.x - samples[i].x) ** 2 + (q.y - samples[i].y) ** 2;\n }\n return sum;\n}\n\nfunction segmentControls(a: PenAnchor, b: PenAnchor): Cubic {\n return [\n { x: a.x, y: a.y },\n a.outHandle ?? { x: a.x, y: a.y },\n b.inHandle ?? { x: b.x, y: b.y },\n { x: b.x, y: b.y },\n ];\n}\n\nfunction sampleCubic([p0, p1, p2, p3]: Cubic): Point[] {\n const out: Point[] = [];\n for (let i = 0; i <= SAMPLES_PER_SEGMENT; i++) {\n out.push(cubicPointAt(p0, p1, p2, p3, i / SAMPLES_PER_SEGMENT));\n }\n return out;\n}\n\nfunction reversed([p0, p1, p2, p3]: Cubic): Cubic {\n return [p3, p2, p1, p0];\n}\n\n/** Unit direction the cubic leaves `p0` in: toward the first control that is\n * not on top of it, the way a cubic's derivative degenerates. */\nfunction startTangent([p0, ...rest]: Cubic): Point {\n for (const p of rest) {\n const dx = p.x - p0.x;\n const dy = p.y - p0.y;\n const len = Math.hypot(dx, dy);\n if (len > 1e-9) return { x: dx / len, y: dy / len };\n }\n return { x: 0, y: 0 };\n}\n","/**\n * Pure anchor-set edits on the model `pathToAnchors` produces: subpath-major\n * `PenAnchor[][]` plus a parallel `closed: boolean[]`. Every function here\n * mutates that structure in place; callers decode with `pathToAnchors`,\n * apply, and re-encode with `anchorsToPath` (see {@link editAnchorSet}).\n *\n * Callers address anchors by flat index — the sequential position in walk\n * order across all subpaths, which is what `enumerateAnchors` reports.\n * {@link locateAnchor} and {@link flatAnchorIndex} convert to and from the\n * `(sub, idx)` pair.\n *\n * The two orders agree because `pathToAnchors` and `enumerateAnchors`\n * walk the same command stream and emit one anchor per M/L/C/Q, less the\n * end of a closing curve that lands on its subpath's first point.\n * `countPathAnchors`, which sizes the renderer's per-anchor arrays, counts\n * that end too and so can be one higher per closed subpath.\n */\n\nimport type { PolygonPath } from '../path';\nimport { withinPxRadius, type Scale2 } from '../pxExtent';\nimport {\n isAnchorSmooth,\n isStraightSegment,\n nearestSegmentT,\n segmentEnds,\n type PenAnchor,\n} from './anchors';\nimport { editAnchorSetTracked } from './anchorOrigins';\nimport { cubicPointAt, splitCubicAtT } from './cubicMath';\nimport { fitCubicThroughDeletion } from './spanFit';\n\n/** Subpath-major anchor model — the decoded form of a `PolygonPath`. */\nexport interface AnchorSet {\n anchors: PenAnchor[][];\n closed: boolean[];\n}\n\n/** A world-space rectangle, as produced by a drag-rect gesture. */\nexport interface AnchorRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Total anchors across every subpath. */\nexport function anchorCount(set: AnchorSet): number {\n let n = 0;\n for (const sub of set.anchors) n += sub.length;\n return n;\n}\n\n/** Flat index → `(sub, idx)`. Returns null when out of range. */\nexport function locateAnchor(\n set: AnchorSet,\n flatIndex: number,\n): { sub: number; idx: number } | null {\n if (flatIndex < 0) return null;\n let remaining = flatIndex;\n for (let sub = 0; sub < set.anchors.length; sub++) {\n const len = set.anchors[sub].length;\n if (remaining < len) return { sub, idx: remaining };\n remaining -= len;\n }\n return null;\n}\n\n/** `(sub, idx)` → flat index. Returns -1 when out of range. */\nexport function flatAnchorIndex(set: AnchorSet, sub: number, idx: number): number {\n if (sub < 0 || sub >= set.anchors.length) return -1;\n if (idx < 0 || idx >= set.anchors[sub].length) return -1;\n let base = 0;\n for (let s = 0; s < sub; s++) base += set.anchors[s].length;\n return base + idx;\n}\n\n/** Resolve a flat index to the anchor itself. Null when out of range. */\nexport function anchorAt(set: AnchorSet, flatIndex: number): PenAnchor | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc) return null;\n return set.anchors[loc.sub][loc.idx] ?? null;\n}\n\n/**\n * Decode `path`, hand the mutable anchor set to `edit`, and re-encode.\n * Returns null when `edit` returns `false` (it changed nothing), so callers\n * can skip a no-op commit.\n */\nexport function editAnchorSet(\n path: PolygonPath,\n edit: (set: AnchorSet) => boolean | void,\n): PolygonPath | null {\n return editAnchorSetTracked(path, edit)?.path ?? null;\n}\n\n/** Translate an anchor and both of its handles by `(dx, dy)`. */\nexport function translateAnchorBy(\n set: AnchorSet,\n flatIndex: number,\n dx: number,\n dy: number,\n): boolean {\n const a = anchorAt(set, flatIndex);\n if (!a) return false;\n a.x += dx;\n a.y += dy;\n if (a.inHandle) {\n a.inHandle.x += dx;\n a.inHandle.y += dy;\n }\n if (a.outHandle) {\n a.outHandle.x += dx;\n a.outHandle.y += dy;\n }\n return true;\n}\n\n/**\n * Move one control handle to an absolute world position. When the anchor was\n * smooth (handles collinear through the anchor) and `breakSmoothness` is\n * false, the opposite handle is mirrored so the curve stays smooth.\n */\nexport function moveHandleTo(\n set: AnchorSet,\n flatIndex: number,\n side: 'in' | 'out',\n toX: number,\n toY: number,\n breakSmoothness: boolean,\n): boolean {\n const a = anchorAt(set, flatIndex);\n if (!a) return false;\n const wasSmooth = isAnchorSmooth(a);\n const target = { x: toX, y: toY };\n if (side === 'out') a.outHandle = target;\n else a.inHandle = target;\n const oppositeSide = side === 'out' ? 'in' : 'out';\n const opposite = oppositeSide === 'in' ? a.inHandle : a.outHandle;\n if (!breakSmoothness && wasSmooth && opposite) {\n const mirrored = { x: 2 * a.x - target.x, y: 2 * a.y - target.y };\n if (oppositeSide === 'in') a.inHandle = mirrored;\n else a.outHandle = mirrored;\n }\n return true;\n}\n\n/**\n * Split the segment `(sub, segIdx) → (sub, segIdx + 1)` at parameter `t`,\n * inserting a new anchor there. On a closed subpath `segIdx` may also name\n * the closing segment (`sub.length - 1`); its new anchor is appended.\n *\n * A straight segment stays straight — the new anchor has no handles. A curved\n * one splits by de Casteljau, so the two halves trace the original path.\n *\n * Returns the new anchor's flat index, or -1 when the segment doesn't\n * exist.\n */\nexport function insertAnchorOnSegment(\n set: AnchorSet,\n args: { sub: number; segIdx: number; t: number },\n): number {\n const ends = segmentEnds(set.anchors, set.closed, args.sub, args.segIdx);\n if (!ends) return -1;\n const { a, b } = ends;\n const at = args.segIdx + 1;\n if (isStraightSegment(a, b)) {\n set.anchors[args.sub].splice(at, 0, {\n x: a.x + (b.x - a.x) * args.t,\n y: a.y + (b.y - a.y) * args.t,\n });\n return flatAnchorIndex(set, args.sub, at);\n }\n const p0 = a, p1 = a.outHandle ?? a, p2 = b.inHandle ?? b, p3 = b;\n const { left, right } = splitCubicAtT(p0, p1, p2, p3, args.t);\n a.outHandle = { x: left[1].x, y: left[1].y };\n b.inHandle = { x: right[2].x, y: right[2].y };\n set.anchors[args.sub].splice(at, 0, {\n x: left[3].x,\n y: left[3].y,\n inHandle: { x: left[2].x, y: left[2].y },\n outHandle: { x: right[1].x, y: right[1].y },\n });\n return flatAnchorIndex(set, args.sub, at);\n}\n\n/** A point on a segment, as {@link segmentAt} reports it. */\nexport interface SegmentHit {\n sub: number;\n segIdx: number;\n /** Parameter on the segment — what {@link insertAnchorOnSegment} takes. */\n t: number;\n /** The point on the path at `t`, in the set's own space. */\n x: number;\n y: number;\n}\n\n/**\n * The segment point under `(x, y)`, when it lies within `tolerancePx` of\n * the path on screen and no nearer than that to either of the segment's\n * own anchors — a press on an anchor is about the anchor, not the segment\n * beside it.\n *\n * `scale` is the view's, so the tolerance holds per axis under\n * non-uniform zoom. The search runs in screen-scaled space: scaling is\n * affine, so the curve's parameterization, and therefore `t`, carries\n * straight back to world space.\n */\nexport function segmentAt(\n set: AnchorSet,\n x: number,\n y: number,\n opts: { tolerancePx: number; scale?: Scale2 },\n): SegmentHit | null {\n const scale = opts.scale ?? { x: 1, y: 1 };\n const onScreen = (p: { x: number; y: number }) => ({ x: p.x * scale.x, y: p.y * scale.y });\n const screenAnchors = set.anchors.map((sub) => sub.map((a) => ({\n ...onScreen(a),\n ...(a.inHandle ? { inHandle: onScreen(a.inHandle) } : {}),\n ...(a.outHandle ? { outHandle: onScreen(a.outHandle) } : {}),\n })));\n const hit = nearestSegmentT(screenAnchors, x * scale.x, y * scale.y, set.closed);\n if (!hit) return null;\n const ends = segmentEnds(set.anchors, set.closed, hit.sub, hit.segIdx)!;\n const point = pointOnSegment(ends.a, ends.b, hit.t);\n const tol = opts.tolerancePx;\n if (!withinPxRadius(point.x - x, point.y - y, tol, scale)) return null;\n if (withinPxRadius(point.x - ends.a.x, point.y - ends.a.y, tol, scale)) return null;\n if (withinPxRadius(point.x - ends.b.x, point.y - ends.b.y, tol, scale)) return null;\n return { sub: hit.sub, segIdx: hit.segIdx, t: hit.t, x: point.x, y: point.y };\n}\n\nfunction pointOnSegment(a: PenAnchor, b: PenAnchor, t: number): { x: number; y: number } {\n if (isStraightSegment(a, b)) return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n return cubicPointAt(a, a.outHandle ?? a, b.inHandle ?? b, b, t);\n}\n\n/**\n * Delete the anchors at `flatIndexes`. Where a deleted anchor had\n * neighbors on both sides — across the seam too, on a closed subpath — the\n * surviving segment is refitted to the two it replaces (`fitCubicThroughDeletion`)\n * so the path keeps its shape; a gap between two straight segments closes straight.\n *\n * Subpaths left with fewer than two anchors are dropped entirely. If that\n * would leave the path with no subpaths at all, the whole deletion is refused\n * (returns false, `set` untouched): an empty path leaves the node selected\n * and in the scene with nothing on screen and no anchors to grab it by.\n */\nexport function deleteAnchorsAt(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n const bySub = new Map<number, number[]>();\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const list = bySub.get(loc.sub);\n if (list) list.push(loc.idx);\n else bySub.set(loc.sub, [loc.idx]);\n }\n if (bySub.size === 0) return false;\n\n // Refuse up front if this would wipe the path out — cheaper and safer\n // than mutating and rolling back.\n let survivors = 0;\n for (let s = 0; s < set.anchors.length; s++) {\n const doomed = bySub.get(s)?.length ?? 0;\n if (set.anchors[s].length - doomed >= 2) survivors++;\n }\n if (survivors === 0) return false;\n\n for (const [s, indices] of bySub) {\n const sub = set.anchors[s];\n if (!sub) continue;\n // Descending so each splice leaves the not-yet-processed indices valid.\n indices.sort((a, b) => b - a);\n for (const i of indices) {\n const wraps = set.closed[s] && sub.length > 2;\n const prev = wraps ? sub[(i - 1 + sub.length) % sub.length] : sub[i - 1];\n const next = wraps ? sub[(i + 1) % sub.length] : sub[i + 1];\n if (prev && next && !(isStraightSegment(prev, sub[i]) && isStraightSegment(sub[i], next))) {\n const { c1, c2 } = fitCubicThroughDeletion(prev, sub[i], next);\n prev.outHandle = c1;\n next.inHandle = c2;\n }\n sub.splice(i, 1);\n }\n }\n\n // Drop degenerate subpaths, back to front so indices stay valid.\n for (let s = set.anchors.length - 1; s >= 0; s--) {\n if (set.anchors[s].length < 2) {\n set.anchors.splice(s, 1);\n set.closed.splice(s, 1);\n }\n }\n return true;\n}\n\n/**\n * Scissors: open a closed subpath at the given anchor. The anchor list is\n * rotated to start there and a second anchor at the same point ends it, so\n * every segment survives and the two ends can be pulled apart. No-ops on an\n * already-open subpath — there's nothing to cut.\n */\nexport function openSubpathAt(set: AnchorSet, flatIndex: number): boolean {\n const loc = locateAnchor(set, flatIndex);\n if (!loc) return false;\n if (!set.closed[loc.sub]) return false;\n const sub = set.anchors[loc.sub];\n if (!sub) return false;\n const { inHandle, ...start } = sub[loc.idx];\n const end: PenAnchor = { x: start.x, y: start.y, ...(inHandle ? { inHandle } : {}) };\n set.anchors[loc.sub] = [start, ...sub.slice(loc.idx + 1), ...sub.slice(0, loc.idx), end];\n set.closed[loc.sub] = false;\n return true;\n}\n\n/** Flat indices of every anchor whose on-curve point falls inside `rect`. */\nexport function anchorsInRect(set: AnchorSet, rect: AnchorRect): number[] {\n const x2 = rect.x + rect.width;\n const y2 = rect.y + rect.height;\n const hits: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (a.x >= rect.x && a.x <= x2 && a.y >= rect.y && a.y <= y2) hits.push(flat);\n flat++;\n }\n }\n return hits;\n}\n","/**\n * Grow or trim an open subpath at one of its ends. Lengthen drags this, and\n * Extend to next path reaches it through `lengthenOpenEnd`.\n *\n * A positive distance extends the end outward: straight along the end tangent,\n * or along a circular arc with the curvature the end has, which meets the path\n * with matching direction and curvature. A straight end segment is lengthened\n * in place; a curved one is continued with a new segment. A negative distance\n * trims the path back along itself by arc length, whichever way it would have\n * grown.\n *\n * The arc rather than extrapolating the end cubic past t = 1: a cubic's\n * leading term takes over beyond its range, so a continued curve swings off\n * and curls on itself within a segment's length, while the arc keeps the\n * curvature the end shows for as long as it is drawn.\n */\n\nimport type { AnchorSet } from './anchorEdits';\nimport { flatAnchorIndex, locateAnchor } from './anchorEdits';\nimport { isStraightSegment, type PenAnchor } from './anchors';\nimport { splitCubicAtT, type Point } from './cubicMath';\nimport { cubicCurvatureAt, cubicDerivativeAt } from './curvature';\nimport type { OpenPathEnd } from './extendPath';\nimport { segmentLength, segmentTAtLength } from './segmentLength';\n\n/** How `lengthenPathEnd` grows an end: straight on, or bending as the end bends. */\nexport type LengthenMode = 'tangent' | 'curvature';\n\n/** Where an end is, which way it heads out of the path, and how it bends there. */\nexport interface PathEndFrame {\n point: Point;\n /** Unit vector pointing out of the path. */\n tangent: Point;\n /** Signed curvature along `tangent`: positive turns toward `(-tangent.y, tangent.x)`. */\n curvature: number;\n}\n\n/** Below this turn over the requested length an arc is drawn as a straight run. */\nconst STRAIGHT_TURN = 1e-6;\n/** The share of a subpath's length a trim always leaves. */\nconst MIN_KEEP = 1e-3;\nconst QUARTER = Math.PI / 2;\nconst FULL = 2 * Math.PI;\n\n/** The end of an open subpath that the anchor at `flatIndex` is, or null when it is\n * an inner anchor, on a closed subpath, or alone in its subpath. */\nexport function openEndAt(set: AnchorSet, flatIndex: number): OpenPathEnd | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || set.closed[loc.sub]) return null;\n const len = set.anchors[loc.sub].length;\n if (len < 2) return null;\n if (loc.idx === 0) return { sub: loc.sub, end: 'first' };\n if (loc.idx === len - 1) return { sub: loc.sub, end: 'last' };\n return null;\n}\n\n/** Flat index of the anchor at `end`, or -1 when there is none. */\nexport function pathEndAnchorIndex(set: AnchorSet, end: OpenPathEnd): number {\n const sub = set.anchors[end.sub];\n if (!sub) return -1;\n return flatAnchorIndex(set, end.sub, end.end === 'first' ? 0 : sub.length - 1);\n}\n\n/** The frame at `end`, or null when it is not the end of an open subpath of two or\n * more anchors, or the path has no direction there. */\nexport function pathEndFrame(set: AnchorSet, end: OpenPathEnd): PathEndFrame | null {\n return atTail(set, end, tailFrame) ?? null;\n}\n\n/**\n * Lengthen `end` by `distance` (see the module comment), in place. A curvature arc\n * stops at one full turn. Returns false when `end` is not the end of an open\n * subpath or nothing changed.\n */\nexport function lengthenPathEnd(set: AnchorSet, end: OpenPathEnd, distance: number, mode: LengthenMode): boolean {\n if (!(distance !== 0 && Number.isFinite(distance))) return false;\n return atTail(set, end, (sub) => (distance < 0 ? trimTail(sub, -distance) : growTail(sub, distance, mode))) ?? false;\n}\n\n/**\n * The distance `lengthenPathEnd` takes for its new end to land nearest `point`: the\n * point projected onto the end tangent, or for a curvature lengthening, measured\n * around the circle of curvature. A measurement around the circle can name the\n * same spot a turn apart; it answers the one nearest `near`, so a drag passing\n * half a turn keeps going instead of jumping back.\n */\nexport function lengthToward(\n set: AnchorSet,\n end: OpenPathEnd,\n mode: LengthenMode,\n point: Point,\n near = 0,\n): number {\n const frame = pathEndFrame(set, end);\n if (!frame) return 0;\n const { point: p, tangent: t, curvature } = frame;\n const vx = point.x - p.x;\n const vy = point.y - p.y;\n if (mode === 'tangent' || curvature === 0) return vx * t.x + vy * t.y;\n const s = Math.sign(curvature);\n const r = 1 / Math.abs(curvature);\n const c = arcCenter(frame);\n const ax = p.x - c.x, ay = p.y - c.y;\n const bx = point.x - c.x, by = point.y - c.y;\n const angle = s * Math.atan2(ax * by - ay * bx, ax * bx + ay * by);\n const turns = Math.round((near / r - angle) / FULL);\n return (angle + turns * FULL) * r;\n}\n\n/** Run `edit` on the subpath with `end` as its last anchor, reversing it around\n * the edit for a start. Undefined when `end` is not the end of an open subpath. */\nfunction atTail<R>(set: AnchorSet, end: OpenPathEnd, edit: (sub: PenAnchor[]) => R): R | undefined {\n const sub = set.anchors[end.sub];\n if (!sub || set.closed[end.sub] || sub.length < 2) return undefined;\n if (end.end === 'last') return edit(sub);\n reverseInPlace(sub);\n try {\n return edit(sub);\n } finally {\n reverseInPlace(sub);\n }\n}\n\n/** Reverse a subpath's direction, keeping each anchor object. */\nfunction reverseInPlace(sub: PenAnchor[]): void {\n sub.reverse();\n for (const a of sub) {\n const { inHandle, outHandle } = a;\n if (outHandle) a.inHandle = outHandle;\n else delete a.inHandle;\n if (inHandle) a.outHandle = inHandle;\n else delete a.outHandle;\n }\n}\n\n/** The last segment's four control points, its own handles where it has them. */\nfunction tailCubic(sub: readonly PenAnchor[]): [PenAnchor, Point, Point, PenAnchor] {\n const a = sub[sub.length - 2];\n const b = sub[sub.length - 1];\n return [a, a.outHandle ?? a, b.inHandle ?? b, b];\n}\n\nfunction tailFrame(sub: readonly PenAnchor[]): PathEndFrame | null {\n const [p0, p1, p2, p3] = tailCubic(sub);\n const point = { x: p3.x, y: p3.y };\n if (isStraightSegment(p0, p3)) return frameHeading(point, p3.x - p0.x, p3.y - p0.y, 0);\n const d1 = cubicDerivativeAt(p0, p1, p2, p3, 1);\n if (Math.hypot(d1.x, d1.y) > 1e-9) return frameHeading(point, d1.x, d1.y, cubicCurvatureAt(p0, p1, p2, p3, 1));\n // The near control sits on the end, which leaves no velocity there to read\n // the bend from: head along the next control that does not.\n const from = Math.hypot(p3.x - p1.x, p3.y - p1.y) > 1e-9 ? p1 : p0;\n return frameHeading(point, p3.x - from.x, p3.y - from.y, 0);\n}\n\nfunction frameHeading(point: Point, dx: number, dy: number, curvature: number): PathEndFrame | null {\n const len = Math.hypot(dx, dy);\n if (!(len > 1e-9)) return null;\n return { point, tangent: { x: dx / len, y: dy / len }, curvature };\n}\n\nfunction arcCenter({ point, tangent, curvature }: PathEndFrame): Point {\n return { x: point.x - tangent.y / curvature, y: point.y + tangent.x / curvature };\n}\n\nfunction growTail(sub: PenAnchor[], distance: number, mode: LengthenMode): boolean {\n const frame = tailFrame(sub);\n if (!frame) return false;\n if (mode === 'curvature' && Math.abs(frame.curvature) * distance > STRAIGHT_TURN) {\n appendArc(sub, frame, distance);\n return true;\n }\n const to = { x: frame.point.x + frame.tangent.x * distance, y: frame.point.y + frame.tangent.y * distance };\n const end = sub[sub.length - 1];\n if (isStraightSegment(sub[sub.length - 2], end)) {\n end.x = to.x;\n end.y = to.y;\n } else {\n sub.push(to);\n }\n return true;\n}\n\n/** Continue the subpath along the circle of curvature at its end, one cubic per\n * quarter turn or less. */\nfunction appendArc(sub: PenAnchor[], frame: PathEndFrame, distance: number): void {\n const s = Math.sign(frame.curvature);\n const r = 1 / Math.abs(frame.curvature);\n const sweep = Math.min(distance / r, FULL);\n const pieces = Math.max(1, Math.ceil(sweep / QUARTER - 1e-9));\n const step = sweep / pieces;\n const reach = (4 / 3) * Math.tan(step / 4) * r;\n const c = arcCenter(frame);\n const rx = frame.point.x - c.x;\n const ry = frame.point.y - c.y;\n const at = (turn: number) => {\n const cos = Math.cos(s * turn);\n const sin = Math.sin(s * turn);\n return {\n p: { x: c.x + rx * cos - ry * sin, y: c.y + rx * sin + ry * cos },\n t: { x: frame.tangent.x * cos - frame.tangent.y * sin, y: frame.tangent.x * sin + frame.tangent.y * cos },\n };\n };\n let prev = sub[sub.length - 1];\n for (let i = 1; i <= pieces; i++) {\n const from = at((i - 1) * step);\n const to = at(i * step);\n prev.outHandle = { x: from.p.x + from.t.x * reach, y: from.p.y + from.t.y * reach };\n const next: PenAnchor = { x: to.p.x, y: to.p.y, inHandle: { x: to.p.x - to.t.x * reach, y: to.p.y - to.t.y * reach } };\n sub.push(next);\n prev = next;\n }\n}\n\nfunction tailLength(sub: readonly PenAnchor[]): number {\n const [p0, p1, p2, p3] = tailCubic(sub);\n if (isStraightSegment(p0, p3)) return Math.hypot(p3.x - p0.x, p3.y - p0.y);\n return segmentLength([p0, p1, p2, p3]);\n}\n\nfunction subpathLength(sub: readonly PenAnchor[]): number {\n let total = 0;\n for (let n = 2; n <= sub.length; n++) total += tailLength(sub.slice(n - 2, n));\n return total;\n}\n\n/** Cut `amount` of arc length off the subpath's end, dropping each anchor the cut\n * passes, and always leaving some of the subpath. */\nfunction trimTail(sub: PenAnchor[], amount: number): boolean {\n const total = subpathLength(sub);\n if (!(total > 0)) return false;\n let left = Math.min(amount, total * (1 - MIN_KEEP));\n for (;;) {\n const len = tailLength(sub);\n if (left < len || sub.length === 2) {\n cutTail(sub, Math.max(0, len - left), len);\n return true;\n }\n left -= len;\n sub.pop();\n delete sub[sub.length - 1].outHandle;\n }\n}\n\n/** Shorten the last segment to its first `keep` of `len`. */\nfunction cutTail(sub: PenAnchor[], keep: number, len: number): void {\n const [p0, p1, p2, p3] = tailCubic(sub);\n if (isStraightSegment(p0, p3)) {\n const f = len > 0 ? keep / len : 0;\n p3.x = p0.x + (p3.x - p0.x) * f;\n p3.y = p0.y + (p3.y - p0.y) * f;\n return;\n }\n const t = segmentTAtLength([p0, p1, p2, p3], keep);\n const { left } = splitCubicAtT(p0, p1, p2, p3, t);\n if (p0.outHandle) p0.outHandle = left[1];\n p3.inHandle = left[2];\n p3.x = left[3].x;\n p3.y = left[3].y;\n}\n","/**\n * Growing an open end of a path along its tangent: by a distance, or until it\n * meets another stroke.\n */\n\nimport type { Path, PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\nimport type { Seg } from '../booleans/contourSegments';\nimport { intersectSegments } from '../intersect/segmentIntersections';\nimport { pathSegments, type PathSegment } from '../intersect/pathSegments';\nimport { editAnchorSetTracked } from './anchorOrigins';\nimport { anchorsToPath, pathToAnchors } from './anchors';\nimport { resolveCorners } from './corners';\nimport { lengthenPathEnd, pathEndFrame } from './lengthenPathEnd';\n\n/** One end of an open subpath. `sub` counts subpaths as the path's anchor set\n * (`pathToAnchors`) does, a bare `M` included. */\nexport interface OpenPathEnd {\n sub: number;\n end: 'first' | 'last';\n}\n\n/** Every end of every open subpath of `path` that has a direction to grow in. */\nexport function openPathEnds(path: Path): OpenPathEnd[] {\n if (path.kind !== 'polygon') return [];\n const set = pathToAnchors(path);\n return set.anchors.flatMap((_, sub) =>\n (['first', 'last'] as const).map((end) => ({ sub, end })).filter((e) => pathEndFrame(set, e)));\n}\n\n/** Where `end` sits and the unit direction it points out along, or null when\n * it is no open end or has no direction there. */\nexport function openEndRay(path: Path, end: OpenPathEnd): { at: Point; dir: Point } | null {\n if (path.kind !== 'polygon') return null;\n const frame = pathEndFrame(pathToAnchors(path), end);\n return frame && { at: frame.point, dir: frame.tangent };\n}\n\n/** `path`'s stroke segments but the one at `end`. */\nfunction segmentsBesideEnd(path: PolygonPath, end: OpenPathEnd): PathSegment[] {\n const set = pathToAnchors(resolveCorners(path));\n return set.anchors.flatMap((sub, s) => {\n const segs = pathSegments(anchorsToPath([sub], [set.closed[s]]));\n return s === end.sub ? segs.filter((g) => g.index !== (end.end === 'last' ? g.count - 1 : 0)) : segs;\n });\n}\n\n/**\n * `path` with `end` carried `distance` further along its tangent, by\n * `lengthenPathEnd` in `'tangent'` mode: a straight end segment grows longer,\n * and a curved one gains a straight segment, which keeps the tangent\n * continuous. Null when the end is not open or has no direction, or\n * `distance` is not positive.\n */\nexport function lengthenOpenEnd(path: Path, end: OpenPathEnd, distance: number): PolygonPath | null {\n if (!(distance > 0) || path.kind !== 'polygon') return null;\n return editAnchorSetTracked(path, (set) => lengthenPathEnd(set, end, distance, 'tangent'))?.path ?? null;\n}\n\n/** Options for {@link extendToMeet}. */\nexport interface ExtendToMeetOptions {\n /** The furthest the end may travel. Default: as far as any stroke reaches. */\n maxDistance?: number;\n}\n\n/**\n * Extend `end` of `path` along its tangent to the first stroke it meets —\n * one of `boundaries`, or `path`'s own other segments. Returns the extended\n * path, the point it now ends at and how far it went, or null when the\n * tangent meets nothing.\n */\nexport function extendToMeet(\n path: Path,\n boundaries: readonly Path[],\n end: OpenPathEnd,\n opts: ExtendToMeetOptions = {},\n): { path: PolygonPath; at: Point; distance: number } | null {\n const ray = openEndRay(path, end);\n if (!ray || path.kind !== 'polygon') return null;\n const all = [...boundaries.flatMap((b) => pathSegments(b)), ...segmentsBesideEnd(path, end)];\n let reach = opts.maxDistance ?? 0;\n if (opts.maxDistance === undefined) {\n for (const s of all) {\n for (const p of s.pts) reach = Math.max(reach, Math.hypot(p.x - ray.at.x, p.y - ray.at.y));\n }\n }\n if (!(reach > 0)) return null;\n const line: Seg = [ray.at, { x: ray.at.x + ray.dir.x * reach, y: ray.at.y + ray.dir.y * reach }];\n let best = Infinity;\n for (const s of all) {\n for (const h of intersectSegments(line, s.pts)) {\n const d = h.ta * reach;\n if (d > 1e-6 && d < best) best = d;\n }\n }\n if (!Number.isFinite(best)) return null;\n const next = lengthenOpenEnd(path, end, best);\n if (!next) return null;\n return { path: next, at: { x: ray.at.x + ray.dir.x * best, y: ray.at.y + ray.dir.y * best }, distance: best };\n}\n","import type { PolygonPath } from '../path';\nimport { anchorsToPath, pathToAnchors, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\nimport { fitPointRun, keepCorner } from './fitRun';\n\n/** Options for {@link simplifyPath}. */\nexport interface SimplifyPathOptions {\n /**\n * An anchor whose path turns by more than this many degrees is a corner:\n * it is kept, and the curve is refitted on either side of it. Default 40.\n */\n cornerAngle?: number;\n}\n\nconst CUBIC_SAMPLES = 12;\nconst MAX_LINE_SAMPLES = 8;\n/** How many times longer than both neighbors a straight segment must be to be\n * kept whole. */\nconst LONG_STRAIGHT = 4;\n\n/**\n * `path` refitted with as few anchors as hold it within `tolerance`: every\n * point sampled along the original lies within `tolerance` of the result.\n * Corners (see {@link SimplifyPathOptions.cornerAngle}) and the ends of open\n * subpaths stay where they are; the runs between them are refitted as smooth\n * cubics, Schneider-style, and a run that lies within `tolerance` of a line\n * becomes one straight segment. Fill rules carry over.\n */\nexport function simplifyPath(\n path: PolygonPath,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PolygonPath {\n const { anchors, closed } = pathToAnchors(path);\n const out: PenAnchor[][] = [];\n const outClosed: boolean[] = [];\n anchors.forEach((sub, s) => {\n if (sub.length < 2) return;\n out.push(simplifySubpath(sub, closed[s], tolerance, opts));\n outClosed.push(closed[s]);\n });\n return anchorsToPath(out, outClosed, path);\n}\n\n/** One subpath of {@link simplifyPath}: its anchors refitted, corners and\n * open ends kept. */\nexport function simplifySubpath(\n sub: PenAnchor[],\n closed: boolean,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PenAnchor[] {\n const { tol, cosCorner } = fitParams(tolerance, opts);\n const n = sub.length;\n const corners = [...breaksOf(sub, closed, cosCorner)].sort((a, b) => a - b);\n const result: PenAnchor[] = [];\n if (closed && corners.length === 0) {\n const pts = sampleRun(sub, 0, n, tol);\n const t = unit(sub2(pts[1], pts[pts.length - 2]));\n fitPointRun(pts, t, neg(t), tol, result, true);\n keepCorner(result[0], sub[0]);\n return result;\n }\n fitStops(sub, closed ? [...corners, corners[0] + n] : corners, tol, result, closed);\n return result;\n}\n\n/**\n * The anchors of `sub` from index `from` to `to`, refitted the way\n * {@link simplifyPath} refits a subpath: as few as hold the span within\n * `tolerance`, corners inside it kept. Indices run modulo the subpath's\n * length, so on a closed subpath `to` may pass its end and wrap; the span is\n * shorter than one full turn. The two end anchors stay where they are and\n * keep their handles facing out of the span. Answers the anchors from `from`\n * to `to`, both included, to splice in place of the originals.\n */\nexport function simplifySpan(\n sub: PenAnchor[],\n closed: boolean,\n from: number,\n to: number,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): PenAnchor[] {\n const { tol, cosCorner } = fitParams(tolerance, opts);\n const n = sub.length;\n const breaks = breaksOf(sub, closed, cosCorner);\n const stops = [from];\n for (let k = from + 1; k < to; k++) if (breaks.has(k % n)) stops.push(k);\n stops.push(to);\n const first = sub[from % n];\n const result: PenAnchor[] = [{ x: first.x, y: first.y, ...(first.inHandle ? { inHandle: { ...first.inHandle } } : {}) }];\n keepCorner(result[0], first);\n fitStops(sub, stops, tol, result, false);\n const lastOut = sub[to % n].outHandle;\n if (lastOut) result[result.length - 1].outHandle = { ...lastOut };\n return result;\n}\n\nfunction fitParams(tolerance: number, opts: SimplifyPathOptions): { tol: number; cosCorner: number } {\n return {\n tol: Math.max(tolerance, 1e-6),\n cosCorner: Math.cos(((opts.cornerAngle ?? 40) * Math.PI) / 180),\n };\n}\n\n/** The anchors a refit must keep: corners, and both ends of a long straight. */\nfunction breaksOf(sub: PenAnchor[], closed: boolean, cosCorner: number): Set<number> {\n const n = sub.length;\n const breaks = new Set<number>();\n for (let i = 0; i < n; i++) {\n if (isCorner(sub, i, closed, cosCorner)) breaks.add(i);\n if (isLongStraight(sub, i, closed)) {\n breaks.add(i);\n breaks.add((i + 1) % n);\n }\n }\n return breaks;\n}\n\n/** Fit each run between consecutive `stops` and append it to `out`. With\n * `closing`, the last run ends on the subpath's first anchor. */\nfunction fitStops(sub: PenAnchor[], stops: readonly number[], tol: number, out: PenAnchor[], closing: boolean): void {\n const n = sub.length;\n for (let k = 0; k + 1 < stops.length; k++) {\n const pts = sampleRun(sub, stops[k], stops[k + 1], tol);\n // Coincident anchors sample to a single point, which has no run to fit.\n if (pts.length < 2) continue;\n const last = closing && k + 2 === stops.length;\n const fresh = out.length === 0;\n fitPointRun(pts, unit(sub2(pts[1], pts[0])), unit(sub2(pts[pts.length - 2], pts[pts.length - 1])), tol, out, last);\n if (fresh) keepCorner(out[0], sub[stops[k] % n]);\n if (!last) keepCorner(out[out.length - 1], sub[stops[k + 1] % n]);\n }\n}\n\n/** Whether the path turns at `sub[i]` by more than the corner angle. */\nfunction isCorner(sub: PenAnchor[], i: number, closed: boolean, cosCorner: number): boolean {\n const n = sub.length;\n const a = sub[i];\n const prev = sub[(i - 1 + n) % n];\n const next = sub[(i + 1) % n];\n if (!closed && (i === 0 || i === n - 1)) return true;\n const from = a.inHandle && !same(a.inHandle, a) ? a.inHandle : prev.outHandle && !same(prev.outHandle, a) ? prev.outHandle : prev;\n const to = a.outHandle && !same(a.outHandle, a) ? a.outHandle : next.inHandle && !same(next.inHandle, a) ? next.inHandle : next;\n const d1 = unit(sub2(a, from));\n const d2 = unit(sub2(to, a));\n return d1.x * d2.x + d1.y * d2.y < cosCorner;\n}\n\n/** Whether the segment leaving `sub[i]` is straight and far longer than the\n * segments either side: a flat between curves, kept whole rather than folded\n * into a curve fitted across it. */\nfunction isLongStraight(sub: PenAnchor[], i: number, closed: boolean): boolean {\n const n = sub.length;\n const len = (k: number): number => {\n if (!closed && (k < 0 || k >= n - 1)) return 0;\n const a = sub[(k + n) % n];\n const b = sub[(k + 1) % n];\n return Math.hypot(b.x - a.x, b.y - a.y);\n };\n if (!closed && i >= n - 1) return false;\n const a = sub[i];\n const b = sub[(i + 1) % n];\n if (a.outHandle || b.inHandle) return false;\n return len(i) >= LONG_STRAIGHT * Math.max(len(i - 1), len(i + 1));\n}\n\n/** Points along the anchors from index `from` to `to` (mod length), both\n * anchors included. */\nfunction sampleRun(sub: PenAnchor[], from: number, to: number, tol: number): Point[] {\n const n = sub.length;\n const pts: Point[] = [{ x: sub[from % n].x, y: sub[from % n].y }];\n for (let i = from; i < to; i++) {\n const a = sub[i % n];\n const b = sub[(i + 1) % n];\n if (!a.outHandle && !b.inHandle) {\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n const steps = Math.min(MAX_LINE_SAMPLES, Math.max(1, Math.floor(len / (4 * tol))));\n for (let k = 1; k <= steps; k++) pts.push({ x: a.x + ((b.x - a.x) * k) / steps, y: a.y + ((b.y - a.y) * k) / steps });\n } else {\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n for (let k = 1; k <= CUBIC_SAMPLES; k++) pts.push(cubicPointAt(a, c1, c2, b, k / CUBIC_SAMPLES));\n }\n }\n return dedupe(pts);\n}\n\nfunction dedupe(pts: Point[]): Point[] {\n return pts.filter((p, i) => i === 0 || !same(p, pts[i - 1]));\n}\n\nconst same = (p: Point, q: Point): boolean => p.x === q.x && p.y === q.y;\nconst sub2 = (p: Point, q: Point): Point => ({ x: p.x - q.x, y: p.y - q.y });\nconst neg = (p: Point): Point => ({ x: -p.x, y: -p.y });\nfunction unit(p: Point): Point {\n const len = Math.hypot(p.x, p.y);\n return len === 0 ? { x: 0, y: 0 } : { x: p.x / len, y: p.y / len };\n}\n","/**\n * A filled region grown outward by a distance, without a boolean: each\n * contour's edges moved out along their normals, convex corners joined, and\n * the overlaps that leaves fill once under `'nonzero'`. Curves stay curves.\n */\nimport { cubicEvalAt } from '../curve';\nimport type { Path, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { lineSegment, pathToCubicContours, splitSegment, type CubicSegment } from './cubicContours';\nimport { pathSignedArea } from './winding';\n\n/** Options for {@link growRegion}. */\nexport interface GrowRegionOptions {\n /** How a convex corner turns. `'miter'` keeps it sharp, as a pseudo-distance\n * field draws it; `'round'` follows the true distance. Default `'miter'`. */\n join?: 'miter' | 'round';\n /** Past this ratio of miter length to distance a miter corner is beveled.\n * Default 4. */\n miterLimit?: number;\n /** How far a grown curve may stray from the true offset, in the path's\n * units. Default 0.1. */\n tolerance?: number;\n}\n\ntype Pt = [number, number];\ntype Seg = CubicSegment;\n\nconst MAX_DEPTH = 6;\nconst SAMPLES = [0.2, 0.35, 0.5, 0.65, 0.8];\n\n/**\n * The region `path` fills under `'nonzero'`, grown by `distance` (> 0), as a\n * path that fills it under `'nonzero'`. Every subpath counts as closed. Each\n * contour is replaced by its offset, so where grown parts meet the contours\n * overlap rather than merge, and a hole grown shut winds back on itself and\n * fills. At an inside corner the two offset edges are cut back to where they\n * cross; where they do not, the gap is passed through the corner's original\n * point, which closes it with a loop inside the fill. `mergeRegion`\n * redraws the result as its outline alone, for a stroke.\n *\n * What it costs: one segment per curve, more where `tolerance` needs the curve\n * split; a miter corner between two straight edges costs nothing, one beside\n * a curve gains an anchor or two, a round corner an arc, and an inside corner\n * whose edges do not cross two.\n */\nexport function growRegion(path: Path, distance: number, opts: GrowRegionOptions = {}): PolygonPath {\n const b = new PathBuilder();\n if (!(distance > 0)) return b.build();\n const sigma = pathSignedArea(path) < 0 ? -1 : 1;\n const ctx: Ctx = {\n d: distance,\n sigma,\n tol: opts.tolerance ?? 0.1,\n join: opts.join ?? 'miter',\n miterLimit: opts.miterLimit ?? 4,\n };\n for (const contour of pathToCubicContours(path)) {\n const segs = contour.segs.filter((s) => !degenerate(s));\n if (segs.length === 0) continue;\n const last = segs.at(-1)!.c,\n first = segs[0]!.c;\n if (last[6] !== first[0] || last[7] !== first[1]) segs.push(lineSegment(last[6], last[7], first[0], first[1]));\n emitContour(b, growContour(segs, ctx));\n }\n return b.build();\n}\n\ninterface Ctx {\n d: number;\n sigma: number;\n tol: number;\n join: 'miter' | 'round';\n miterLimit: number;\n}\n\n/** One source segment's offset pieces, and the pieces joining it to the next. */\ninterface Grown {\n pieces: Seg[];\n join: Seg[];\n}\n\nfunction growContour(segs: readonly Seg[], ctx: Ctx): Grown[] {\n const out: Grown[] = segs.map((s) => ({\n pieces: offsetSeg(s, ctx, 0),\n join: [],\n }));\n for (let i = 0; i < segs.length; i++) {\n const j = (i + 1) % segs.length;\n const tin = endTangent(segs[i]!.c),\n tout = startTangent(segs[j]!.c);\n const v: Pt = [segs[j]!.c[0], segs[j]!.c[1]];\n out[i]!.join = joinPieces(out[i]!, out[j]!, v, tin, tout, ctx);\n }\n return out;\n}\n\nfunction joinPieces(prev: Grown, next: Grown, v: Pt, tin: Pt, tout: Pt, ctx: Ctx): Seg[] {\n const a = endOf(prev.pieces.at(-1)!),\n b = startOf(next.pieces[0]!);\n const gap = Math.hypot(b[0] - a[0], b[1] - a[1]);\n if (gap <= ctx.tol * 1e-3) return [];\n const cross = tin[0] * tout[1] - tin[1] * tout[0];\n const dot = tin[0] * tout[0] + tin[1] * tout[1];\n const convex = ctx.sigma * cross > 0 || (Math.abs(cross) < 1e-9 && dot < 0);\n if (gap <= ctx.tol) return snap(prev, next, a);\n if (!convex) {\n if (trimAtCrossing(prev, next)) return [];\n return [lineSegment(a[0], a[1], v[0], v[1]), lineSegment(v[0], v[1], b[0], b[1])];\n }\n const nin = normal(tin, ctx.sigma),\n nout = normal(tout, ctx.sigma);\n if (ctx.join === 'round') return arc(v, ctx.d, nin, Math.atan2(cross, dot));\n const cos = nin[0] * nout[0] + nin[1] * nout[1];\n if (1 + cos < 1e-9 || Math.sqrt(2 / (1 + cos)) > ctx.miterLimit) return [lineSegment(a[0], a[1], b[0], b[1])];\n const k = ctx.d / (1 + cos);\n const m: Pt = [v[0] + (nin[0] + nout[0]) * k, v[1] + (nin[1] + nout[1]) * k];\n return miter(prev, next, m);\n}\n\n/** A gap inside the tolerance closed by moving the next piece's start onto\n * `a`, its first handle with it, rather than by a segment of its own. */\nfunction snap(prev: Grown, next: Grown, a: Pt): Seg[] {\n const n = next.pieces[0]!;\n if (n === prev.pieces.at(-1)) return [lineSegment(n.c[6], n.c[7], a[0], a[1])];\n next.pieces[0] = n.line\n ? lineSegment(a[0], a[1], n.c[6], n.c[7])\n : {\n c: [a[0], a[1], n.c[2] + a[0] - n.c[0], n.c[3] + a[1] - n.c[1], n.c[4], n.c[5], n.c[6], n.c[7]],\n line: false,\n };\n return [];\n}\n\n/** The miter point joined in, a straight edge either side carried on to it\n * rather than gaining an anchor. */\nfunction miter(prev: Grown, next: Grown, m: Pt): Seg[] {\n const p = prev.pieces.at(-1)!,\n n = next.pieces[0]!;\n const out: Seg[] = [];\n if (p.line && p !== n) prev.pieces[prev.pieces.length - 1] = lineSegment(p.c[0], p.c[1], m[0], m[1]);\n else out.push(lineSegment(p.c[6], p.c[7], m[0], m[1]));\n if (n.line && p !== n) next.pieces[0] = lineSegment(m[0], m[1], n.c[6], n.c[7]);\n else out.push(lineSegment(m[0], m[1], n.c[0], n.c[1]));\n return out;\n}\n\n/**\n * Cut the offset pieces either side of an inside corner back to where they\n * cross, when they do. The crossing is found on a flattening of each, and both\n * cut ends are moved onto the one point between them.\n */\nfunction trimAtCrossing(prev: Grown, next: Grown): boolean {\n const p = prev.pieces.at(-1)!,\n n = next.pieces[0]!;\n if (p === n) return false;\n const hit = crossing(p.c, n.c);\n if (hit === null) return false;\n const left = hit[0] >= 1 ? p : splitSegment(p, hit[0])[0];\n const right = hit[1] <= 0 ? n : splitSegment(n, hit[1])[1];\n const x = (left.c[6] + right.c[0]) / 2,\n y = (left.c[7] + right.c[1]) / 2;\n prev.pieces[prev.pieces.length - 1] = left.line\n ? lineSegment(left.c[0], left.c[1], x, y)\n : {\n c: [left.c[0], left.c[1], left.c[2], left.c[3], left.c[4] + x - left.c[6], left.c[5] + y - left.c[7], x, y],\n line: false,\n };\n next.pieces[0] = right.line\n ? lineSegment(x, y, right.c[6], right.c[7])\n : {\n c: [\n x,\n y,\n right.c[2] + x - right.c[0],\n right.c[3] + y - right.c[1],\n right.c[4],\n right.c[5],\n right.c[6],\n right.c[7],\n ],\n line: false,\n };\n return true;\n}\n\nconst CROSS_SAMPLES = 32;\n\n/** Where `a` crosses `b`, as a parameter on each: the crossing nearest `a`'s\n * end and `b`'s start, or `null` when they do not cross. */\nfunction crossing(a: Seg['c'], b: Seg['c']): [number, number] | null {\n const pa = flatten(a),\n pb = flatten(b);\n let best: [number, number] | null = null,\n score = Infinity;\n for (let i = 0; i < CROSS_SAMPLES; i++) {\n for (let j = 0; j < CROSS_SAMPLES; j++) {\n const hit = segmentsCross(pa[i]!, pa[i + 1]!, pb[j]!, pb[j + 1]!);\n if (hit === null) continue;\n const ta = (i + hit[0]) / CROSS_SAMPLES,\n tb = (j + hit[1]) / CROSS_SAMPLES;\n if (ta <= 1e-9 || tb >= 1 - 1e-9 || 1 - ta + tb >= score) continue;\n score = 1 - ta + tb;\n best = [ta, tb];\n }\n }\n return best;\n}\n\nfunction flatten(c: Seg['c']): Pt[] {\n const out: Pt[] = [];\n for (let i = 0; i <= CROSS_SAMPLES; i++) out.push(cubicEvalAt(...c, i / CROSS_SAMPLES));\n return out;\n}\n\nfunction segmentsCross(a: Pt, b: Pt, c: Pt, d: Pt): [number, number] | null {\n const rx = b[0] - a[0],\n ry = b[1] - a[1],\n sx = d[0] - c[0],\n sy = d[1] - c[1];\n const den = rx * sy - ry * sx;\n if (Math.abs(den) < 1e-18) return null;\n const u = ((c[0] - a[0]) * sy - (c[1] - a[1]) * sx) / den;\n const w = ((c[0] - a[0]) * ry - (c[1] - a[1]) * rx) / den;\n return u >= 0 && u <= 1 && w >= 0 && w <= 1 ? [u, w] : null;\n}\n\n/** A circular arc about `c` of radius `r`, from normal `n0` turning by `sweep`. */\nfunction arc(c: Pt, r: number, n0: Pt, sweep: number): Seg[] {\n const parts = Math.max(1, Math.ceil(Math.abs(sweep) / (Math.PI / 2)));\n const step = sweep / parts;\n const h = (4 / 3) * Math.tan(step / 4) * r;\n const start = Math.atan2(n0[1], n0[0]);\n const out: Seg[] = [];\n for (let i = 0; i < parts; i++) {\n const t0 = start + step * i,\n t1 = t0 + step;\n const x0 = c[0] + Math.cos(t0) * r,\n y0 = c[1] + Math.sin(t0) * r;\n const x3 = c[0] + Math.cos(t1) * r,\n y3 = c[1] + Math.sin(t1) * r;\n out.push({\n c: [x0, y0, x0 - Math.sin(t0) * h, y0 + Math.cos(t0) * h, x3 + Math.sin(t1) * h, y3 - Math.cos(t1) * h, x3, y3],\n line: false,\n });\n }\n return out;\n}\n\n/**\n * `seg` moved out by `d`. A curve's ends move along their normals and its\n * handles scale by `1 + d·κ`, which matches the offset's first derivative\n * there; a piece that strays past the tolerance is split and retried.\n */\nfunction offsetSeg(seg: Seg, ctx: Ctx, depth: number): Seg[] {\n const c = seg.c;\n const n0 = normal(startTangent(c), ctx.sigma),\n n1 = normal(endTangent(c), ctx.sigma);\n const { d } = ctx;\n if (seg.line) return [lineSegment(c[0] + n0[0] * d, c[1] + n0[1] * d, c[6] + n0[0] * d, c[7] + n0[1] * d)];\n const k0 = Math.max(0, 1 + ctx.sigma * d * curvatureAt(c, 0));\n const k1 = Math.max(0, 1 + ctx.sigma * d * curvatureAt(c, 1));\n const q0x = c[0] + n0[0] * d,\n q0y = c[1] + n0[1] * d;\n const q3x = c[6] + n1[0] * d,\n q3y = c[7] + n1[1] * d;\n const out: Seg = {\n c: [\n q0x,\n q0y,\n q0x + (c[2] - c[0]) * k0,\n q0y + (c[3] - c[1]) * k0,\n q3x + (c[4] - c[6]) * k1,\n q3y + (c[5] - c[7]) * k1,\n q3x,\n q3y,\n ],\n line: false,\n };\n if (depth >= MAX_DEPTH || offsetError(c, out.c, ctx) <= ctx.tol) return [out];\n const [l, r] = splitSegment(seg, 0.5);\n return [...offsetSeg(l, ctx, depth + 1), ...offsetSeg(r, ctx, depth + 1)];\n}\n\nfunction offsetError(c: Seg['c'], q: Seg['c'], ctx: Ctx): number {\n let worst = 0;\n for (const t of SAMPLES) {\n const [dx, dy] = derivative(c, t);\n const len = Math.hypot(dx, dy);\n if (len < 1e-12) continue;\n const [bx, by] = cubicEvalAt(...c, t);\n const tx = bx + ((ctx.sigma * dy) / len) * ctx.d,\n ty = by - ((ctx.sigma * dx) / len) * ctx.d;\n const [ox, oy] = cubicEvalAt(...q, t);\n worst = Math.max(worst, Math.hypot(ox - tx, oy - ty));\n }\n return worst;\n}\n\nfunction derivative(c: Seg['c'], t: number): Pt {\n const u = 1 - t;\n const a = 3 * u * u,\n b = 6 * u * t,\n e = 3 * t * t;\n return [\n a * (c[2] - c[0]) + b * (c[4] - c[2]) + e * (c[6] - c[4]),\n a * (c[3] - c[1]) + b * (c[5] - c[3]) + e * (c[7] - c[5]),\n ];\n}\n\n/** Signed curvature at an end, positive turning left; 0 where the handle is\n * absent, whose offset handle is then absent too. */\nfunction curvatureAt(c: Seg['c'], end: 0 | 1): number {\n const [d1x, d1y] = end === 0 ? [c[2] - c[0], c[3] - c[1]] : [c[6] - c[4], c[7] - c[5]];\n const [d2x, d2y] =\n end === 0 ? [c[0] - 2 * c[2] + c[4], c[1] - 2 * c[3] + c[5]] : [c[6] - 2 * c[4] + c[2], c[7] - 2 * c[5] + c[3]];\n const len = Math.hypot(d1x, d1y);\n if (len < 1e-12) return 0;\n // B' = 3·d1, B'' = 6·d2: κ = (B'×B'')/|B'|³ = (2/3)(d1×d2)/|d1|³.\n return ((2 / 3) * (d1x * d2y - d1y * d2x)) / (len * len * len);\n}\n\nfunction startTangent(c: Seg['c']): Pt {\n return unit(c[2] - c[0], c[3] - c[1]) ?? unit(c[4] - c[0], c[5] - c[1]) ?? unit(c[6] - c[0], c[7] - c[1]) ?? [1, 0];\n}\n\nfunction endTangent(c: Seg['c']): Pt {\n return unit(c[6] - c[4], c[7] - c[5]) ?? unit(c[6] - c[2], c[7] - c[3]) ?? unit(c[6] - c[0], c[7] - c[1]) ?? [1, 0];\n}\n\nfunction unit(x: number, y: number): Pt | null {\n const l = Math.hypot(x, y);\n return l < 1e-12 ? null : [x / l, y / l];\n}\n\n/** The outward normal: right of travel for a positively wound region. */\nfunction normal(t: Pt, sigma: number): Pt {\n return [sigma * t[1], -sigma * t[0]];\n}\n\nfunction degenerate(s: Seg): boolean {\n const c = s.c;\n return c[0] === c[6] && c[1] === c[7] && c[0] === c[2] && c[1] === c[3] && c[0] === c[4] && c[1] === c[5];\n}\n\nconst startOf = (s: Seg): Pt => [s.c[0], s.c[1]];\nconst endOf = (s: Seg): Pt => [s.c[6], s.c[7]];\n\nfunction emitContour(b: PathBuilder, grown: readonly Grown[]): void {\n const first = grown[0]!.pieces[0]!;\n b.moveTo(first.c[0], first.c[1]);\n for (const g of grown) {\n for (const s of [...g.pieces, ...g.join]) {\n if (s.line) b.lineTo(s.c[6], s.c[7]);\n else b.curveTo(s.c[2], s.c[3], s.c[4], s.c[5], s.c[6], s.c[7]);\n }\n }\n b.close();\n}\n","/** Where cubic segments cross one another, as a parameter on each. */\nimport { cubicEvalAt } from '../curve';\nimport type { CubicSegment } from './cubicContours';\n\ntype Pt = [number, number];\ntype C = CubicSegment['c'];\n\n/** One crossing of segments `a` and `b`, at parameter `s` on `a` and `t` on `b`. */\nexport interface SegmentCrossing {\n a: number;\n b: number;\n s: number;\n t: number;\n}\n\nconst STEPS = 16;\nconst END = 1e-7;\n\n/**\n * Every crossing between two of `segs`, a segment with itself left out. A\n * meeting at an end of both is a shared corner, not a crossing, and is left\n * out too. Each curve is found on a flattening and then refined on the curves.\n */\nexport function segmentCrossings(segs: readonly CubicSegment[]): SegmentCrossing[] {\n const flat = segs.map((s) => flatten(s));\n const boxes = flat.map(boxOf);\n const out: SegmentCrossing[] = [];\n for (let a = 0; a < segs.length; a++) {\n for (let b = a + 1; b < segs.length; b++) {\n if (!overlaps(boxes[a]!, boxes[b]!)) continue;\n const pa = flat[a]!,\n pb = flat[b]!;\n for (let i = 0; i + 1 < pa.length; i++) {\n for (let j = 0; j + 1 < pb.length; j++) {\n const hit = linesCross(pa[i]!, pa[i + 1]!, pb[j]!, pb[j + 1]!);\n if (hit === null) continue;\n const guess: Pt = [(i + hit[0]) / (pa.length - 1), (j + hit[1]) / (pb.length - 1)];\n const [s, t] = segs[a]!.line && segs[b]!.line ? guess : refine(segs[a]!.c, segs[b]!.c, guess);\n if (atEnd(s) && atEnd(t)) continue;\n if (out.some((x) => x.a === a && x.b === b && Math.abs(x.s - s) < 1e-6 && Math.abs(x.t - t) < 1e-6)) continue;\n out.push({ a, b, s, t });\n }\n }\n }\n }\n return out;\n}\n\nconst atEnd = (t: number) => t < END || t > 1 - END;\n\nfunction flatten(seg: CubicSegment): Pt[] {\n if (seg.line) return [[seg.c[0], seg.c[1]], [seg.c[6], seg.c[7]]];\n const out: Pt[] = [];\n for (let i = 0; i <= STEPS; i++) out.push(cubicEvalAt(...seg.c, i / STEPS));\n return out;\n}\n\ntype Box = [number, number, number, number];\n\nfunction boxOf(pts: readonly Pt[]): Box {\n const b: Box = [Infinity, Infinity, -Infinity, -Infinity];\n for (const [x, y] of pts) {\n b[0] = Math.min(b[0], x);\n b[1] = Math.min(b[1], y);\n b[2] = Math.max(b[2], x);\n b[3] = Math.max(b[3], y);\n }\n return b;\n}\n\nconst overlaps = (p: Box, q: Box) => p[0] <= q[2] && q[0] <= p[2] && p[1] <= q[3] && q[1] <= p[3];\n\nfunction linesCross(a: Pt, b: Pt, c: Pt, d: Pt): Pt | null {\n const rx = b[0] - a[0],\n ry = b[1] - a[1],\n sx = d[0] - c[0],\n sy = d[1] - c[1];\n const den = rx * sy - ry * sx;\n if (Math.abs(den) < 1e-18) return null;\n const u = ((c[0] - a[0]) * sy - (c[1] - a[1]) * sx) / den;\n const w = ((c[0] - a[0]) * ry - (c[1] - a[1]) * rx) / den;\n return u >= 0 && u <= 1 && w >= 0 && w <= 1 ? [u, w] : null;\n}\n\n/** The crossing near `guess` found on the curves themselves by Newton's\n * method, or `guess` when that does not converge on a closer one. */\nfunction refine(a: C, b: C, guess: Pt): Pt {\n const gap = (s: number, t: number) => {\n const p = cubicEvalAt(...a, s),\n q = cubicEvalAt(...b, t);\n return [p[0] - q[0], p[1] - q[1]] as Pt;\n };\n let [s, t] = guess;\n let f = gap(s, t);\n const start = Math.hypot(...f);\n for (let k = 0; k < 8 && Math.hypot(...f) > 1e-13; k++) {\n const da = derivative(a, s),\n db = derivative(b, t);\n const det = -da[0] * db[1] + db[0] * da[1];\n if (Math.abs(det) < 1e-18) break;\n s = Math.min(1, Math.max(0, s - (-db[1] * f[0] + db[0] * f[1]) / det));\n t = Math.min(1, Math.max(0, t - (-da[1] * f[0] + da[0] * f[1]) / det));\n f = gap(s, t);\n }\n return Math.hypot(...f) <= start ? [s, t] : guess;\n}\n\nfunction derivative(c: C, t: number): Pt {\n const u = 1 - t;\n const a = 3 * u * u,\n b = 6 * u * t,\n e = 3 * t * t;\n return [\n a * (c[2] - c[0]) + b * (c[4] - c[2]) + e * (c[6] - c[4]),\n a * (c[3] - c[1]) + b * (c[5] - c[3]) + e * (c[7] - c[5]),\n ];\n}\n","/**\n * The region a path fills, redrawn as its outline alone: contours that\n * overlap or cross are cut where they cross and only the pieces with fill on\n * one side are kept. Curves stay curves.\n */\nimport { cubicEvalAt } from '../curve';\nimport { flattenCubic } from '../flatten';\nimport type { Path, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { lineSegment, pathToCubicContours, splitSegment, type CubicSegment } from './cubicContours';\nimport { segmentCrossings } from './segmentCrossings';\nimport { pathSignedArea } from './winding';\n\n/** Options for {@link mergeRegion}. */\nexport interface MergeRegionOptions {\n /** How far from an edge a point is taken to tell which side is filled, in\n * the path's units; a sliver of region thinner than this may be lost.\n * Default 0.01. */\n tolerance?: number;\n}\n\ntype Pt = [number, number];\n\n/** A cut on a segment: where, and the point both cut ends move onto. */\ninterface Cut {\n t: number;\n p: Pt;\n}\n\n/**\n * The region `path` fills under `'nonzero'`, as contours that neither cross\n * nor overlap, wound so the fill lies on the same side of each as it does on\n * most of `path`. Stroking it traces only the region's edge. Every subpath\n * counts as closed. Answers `path`'s own contours, unchanged, where nothing\n * needs cutting or dropping.\n */\nexport function mergeRegion(path: Path, opts: MergeRegionOptions = {}): PolygonPath {\n const tol = opts.tolerance ?? 0.01;\n const contours = pathToCubicContours(path).filter((c) => c.segs.length > 0);\n const segs = contours.flatMap((c) => closeContour(c.segs, tol * 1e-3));\n // A positively wound region fills to the right of travel (`growRegion`).\n const fillLeft = pathSignedArea(path) < 0;\n const cuts: Cut[][] = segs.map(() => []);\n for (const x of segmentCrossings(segs)) {\n const p = crossingPoint(segs[x.a]!, x.s, segs[x.b]!, x.t);\n cuts[x.a]!.push({ t: x.s, p });\n cuts[x.b]!.push({ t: x.t, p });\n }\n const rings = flattenAll(segs, tol / 4);\n const pieces: CubicSegment[] = [];\n let changed = false;\n segs.forEach((seg, i) => {\n const parts = cutSegment(seg, cuts[i]!);\n if (parts.length > 1) changed = true;\n for (const part of parts) {\n const side = filledSide(part, rings, tol);\n if (side === null) changed = true;\n else if (side === fillLeft) pieces.push(part);\n else {\n changed = true;\n pieces.push(reversed(part));\n }\n }\n });\n const b = new PathBuilder();\n if (!changed) {\n for (const c of contours) emit(b, closeContour(c.segs, tol * 1e-3));\n return b.build();\n }\n for (const ring of chain(pieces)) emit(b, ring);\n return b.build();\n}\n\n/** `segs` with every straight edge no longer than `snap` dropped, the gap it\n * leaves closed by moving the next start back, and ending where it starts. */\nfunction closeContour(given: readonly CubicSegment[], snap: number): CubicSegment[] {\n const short = (s: CubicSegment) => s.line && Math.hypot(s.c[6] - s.c[0], s.c[7] - s.c[1]) <= snap;\n const segs = given.filter((s) => !short(s));\n if (segs.length === 0) return [];\n for (let i = 0; i < segs.length; i++) {\n const prev = segs[(i + segs.length - 1) % segs.length]!.c,\n s = segs[i]!;\n if (prev[6] !== s.c[0] || prev[7] !== s.c[1]) {\n if (Math.hypot(prev[6] - s.c[0], prev[7] - s.c[1]) <= snap) segs[i] = moveEnds(s, [prev[6], prev[7]], [s.c[6], s.c[7]]);\n else if (i === 0) segs.push(lineSegment(prev[6], prev[7], s.c[0], s.c[1]));\n }\n }\n return segs;\n}\n\n/** One point for a crossing: an end of either segment when it falls there,\n * so the cut lands on the corner already joining it, else the midpoint of\n * the two curves' estimates. */\nfunction crossingPoint(a: CubicSegment, s: number, b: CubicSegment, t: number): Pt {\n const end = (seg: CubicSegment, u: number): Pt | null =>\n u <= 1e-7 ? [seg.c[0], seg.c[1]] : u >= 1 - 1e-7 ? [seg.c[6], seg.c[7]] : null;\n const fixed = end(a, s) ?? end(b, t);\n if (fixed) return fixed;\n const p = cubicEvalAt(...a.c, s),\n q = cubicEvalAt(...b.c, t);\n return [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2];\n}\n\n/** `seg` cut at every interior cut, each cut end moved onto its cut's point,\n * a curve's adjacent handle moved with it. */\nfunction cutSegment(seg: CubicSegment, cuts: Cut[]): CubicSegment[] {\n const inner = cuts.filter((c) => c.t > 1e-7 && c.t < 1 - 1e-7).sort((x, y) => x.t - y.t);\n const out: CubicSegment[] = [];\n let rest = seg,\n from = 0;\n let start: Pt = [seg.c[0], seg.c[1]];\n for (const cut of inner) {\n if (cut.t - from < 1e-9) continue;\n const [l, r] = splitSegment(rest, (cut.t - from) / (1 - from));\n out.push(moveEnds(l, start, cut.p));\n rest = r;\n from = cut.t;\n start = cut.p;\n }\n out.push(moveEnds(rest, start, [seg.c[6], seg.c[7]]));\n return out;\n}\n\nfunction moveEnds(s: CubicSegment, a: Pt, b: Pt): CubicSegment {\n const c = s.c;\n return {\n c: [a[0], a[1], c[2] + a[0] - c[0], c[3] + a[1] - c[1], c[4] + b[0] - c[6], c[5] + b[1] - c[7], b[0], b[1]],\n line: s.line,\n };\n}\n\nfunction reversed(s: CubicSegment): CubicSegment {\n const c = s.c;\n return { c: [c[6], c[7], c[4], c[5], c[2], c[3], c[0], c[1]], line: s.line };\n}\n\n/** Each contour's polyline, for counting winding against. */\nfunction flattenAll(segs: readonly CubicSegment[], tol: number): number[][] {\n const rings: number[][] = [];\n let ring: number[] = [];\n for (const { c, line } of segs) {\n if (ring.length === 0) ring.push(c[0], c[1]);\n else if (ring[ring.length - 2] !== c[0] || ring[ring.length - 1] !== c[1]) {\n rings.push(ring);\n ring = [c[0], c[1]];\n }\n if (line) ring.push(c[6], c[7]);\n else flattenCubic(...c, tol, ring);\n }\n if (ring.length > 0) rings.push(ring);\n return rings;\n}\n\nfunction winding(rings: readonly number[][], x: number, y: number): number {\n let w = 0;\n for (const r of rings) {\n for (let i = 0; i + 3 < r.length; i += 2) {\n const ay = r[i + 1]!,\n by = r[i + 3]!;\n if (ay > y === by > y) continue;\n const ax = r[i]!,\n bx = r[i + 2]!;\n if (x >= ax + ((y - ay) / (by - ay)) * (bx - ax)) continue;\n w += ay <= y ? 1 : -1;\n }\n }\n return w;\n}\n\n/** Whether the fill lies left of `seg`'s travel (`true`) or right of it, or\n * `null` when it lies on both sides or neither. Judged at its middle. */\nfunction filledSide(seg: CubicSegment, rings: readonly number[][], tol: number): boolean | null {\n const c = seg.c;\n const [x, y] = cubicEvalAt(...c, 0.5);\n const dx = c[6] + c[4] - c[2] - c[0],\n dy = c[7] + c[5] - c[3] - c[1];\n const len = Math.hypot(dx, dy);\n if (len < 1e-12) return null;\n const nx = (dy / len) * tol,\n ny = (-dx / len) * tol;\n const left = winding(rings, x + nx, y + ny) !== 0,\n right = winding(rings, x - nx, y - ny) !== 0;\n return left === right ? null : left;\n}\n\n/** The pieces joined end to start into closed rings. */\nfunction chain(pieces: readonly CubicSegment[]): CubicSegment[][] {\n const key = (x: number, y: number) => `${x},${y}`;\n const from = new Map<string, number[]>();\n pieces.forEach((p, i) => {\n const k = key(p.c[0], p.c[1]);\n const list = from.get(k);\n if (list) list.push(i);\n else from.set(k, [i]);\n });\n const used = new Uint8Array(pieces.length);\n const rings: CubicSegment[][] = [];\n for (let i = 0; i < pieces.length; i++) {\n if (used[i]) continue;\n const ring: CubicSegment[] = [];\n let at: number | undefined = i;\n while (at !== undefined && !used[at]) {\n used[at] = 1;\n const p: CubicSegment = pieces[at]!;\n ring.push(p);\n at = from.get(key(p.c[6], p.c[7]))?.find((j) => !used[j]);\n }\n rings.push(ring);\n }\n return rings;\n}\n\nfunction emit(b: PathBuilder, ring: readonly CubicSegment[]): void {\n if (ring.length === 0) return;\n const [x0, y0] = ring[0]!.c;\n b.moveTo(x0, y0);\n for (const [i, { c, line }] of ring.entries()) {\n if (line && i === ring.length - 1 && c[6] === x0 && c[7] === y0) break;\n if (line) b.lineTo(c[6], c[7]);\n else b.curveTo(c[2], c[3], c[4], c[5], c[6], c[7]);\n }\n b.close();\n}\n","import { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { simplifySpan, simplifySubpath, type SimplifyPathOptions } from './simplifyPath';\n\n/**\n * Simplify only where `flatIndexes` say: each unbroken run of those anchors\n * along a subpath is refitted as one span by the fitter {@link simplifyPath}\n * uses (`simplifySpan`), so only anchors the shape does not need, within\n * `tolerance`, go. A run's first and last anchors stay, and every anchor\n * outside a run is left as it was. A closed subpath named whole is simplified\n * whole. Answers whether any anchor went; a run the fit cannot thin is left\n * untouched.\n */\nexport function simplifyAnchorsAt(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n tolerance: number,\n opts: SimplifyPathOptions = {},\n): boolean {\n const bySub = new Map<number, Set<number>>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const named = bySub.get(loc.sub) ?? new Set<number>();\n named.add(loc.idx);\n bySub.set(loc.sub, named);\n }\n let changed = false;\n for (const [s, named] of bySub) {\n const sub = set.anchors[s];\n const closed = set.closed[s];\n if (closed && named.size === sub.length) {\n const next = simplifySubpath(sub, true, tolerance, opts);\n if (next.length < sub.length) { set.anchors[s] = next; changed = true; }\n continue;\n }\n // Start a closed subpath on an anchor outside every run, so none wraps.\n const shift = closed ? [...sub.keys()].find((i) => !named.has(i))! : 0;\n const order = closed ? [...sub.slice(shift), ...sub.slice(0, shift)] : sub;\n const inRun = (i: number) => named.has((i + shift) % sub.length);\n const out = order.slice();\n let thinned = false;\n // Back to front, so a splice leaves the runs before it where they were.\n for (let end = order.length - 1; end >= 0; end--) {\n if (!inRun(end)) continue;\n let start = end;\n while (start > 0 && inRun(start - 1)) start--;\n if (end - start >= 2) {\n const refit = simplifySpan(order, closed, start, end, tolerance, opts);\n if (refit.length < end - start + 1) {\n out.splice(start, end - start + 1, ...refit);\n thinned = true;\n }\n }\n end = start;\n }\n if (thinned) { set.anchors[s] = out; changed = true; }\n }\n return changed;\n}\n","/**\n * A run of consecutive segments of a decoded subpath, measured by arc length:\n * where it is, and which way it heads, any distance along it. Curves are\n * measured by sampling, and points are then found on the curve itself, so a\n * point is exact and only its distance along the run is approximate.\n */\nimport { isStraightSegment, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\nconst LENGTH_SAMPLES = 48;\n\ninterface Seg {\n a: Point;\n c1: Point;\n c2: Point;\n b: Point;\n straight: boolean;\n /** Where the segment starts along the run. */\n from: number;\n len: number;\n /** Arc length to each of `LENGTH_SAMPLES + 1` evenly spaced parameters. */\n table: number[];\n}\n\n/** A run's measure: its length, and its point and unit heading at any\n * distance along it. */\nexport interface ArcRun {\n length: number;\n pointAt(s: number): Point;\n /** The unit direction of travel at `s`. At a joint between segments it is\n * the later segment's unless `arriving`, when it is the earlier one's. */\n headingAt(s: number, arriving?: boolean): Point;\n}\n\nconst unit = (x: number, y: number): Point => {\n const len = Math.hypot(x, y);\n return len === 0 ? { x: 0, y: 0 } : { x: x / len, y: y / len };\n};\n\nfunction derivative(seg: Seg, t: number): Point {\n const u = 1 - t;\n const { a, c1, c2, b } = seg;\n return {\n x: 3 * u * u * (c1.x - a.x) + 6 * u * t * (c2.x - c1.x) + 3 * t * t * (b.x - c2.x),\n y: 3 * u * u * (c1.y - a.y) + 6 * u * t * (c2.y - c1.y) + 3 * t * t * (b.y - c2.y),\n };\n}\n\nfunction headingOn(seg: Seg, t: number): Point {\n if (seg.straight) return unit(seg.b.x - seg.a.x, seg.b.y - seg.a.y);\n let d = derivative(seg, t);\n // A handle lying on its anchor zeroes the derivative there; step inside.\n if (Math.hypot(d.x, d.y) < 1e-9) d = derivative(seg, t < 0.5 ? t + 1e-3 : t - 1e-3);\n const h = unit(d.x, d.y);\n return h.x === 0 && h.y === 0 ? unit(seg.b.x - seg.a.x, seg.b.y - seg.a.y) : h;\n}\n\nfunction measure(a: PenAnchor, b: PenAnchor, from: number): Seg {\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const straight = isStraightSegment(a, b);\n const table = [0];\n if (straight) {\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n for (let k = 1; k <= LENGTH_SAMPLES; k++) table.push((len * k) / LENGTH_SAMPLES);\n } else {\n let prev: Point = a;\n let len = 0;\n for (let k = 1; k <= LENGTH_SAMPLES; k++) {\n const p = cubicPointAt(a, c1, c2, b, k / LENGTH_SAMPLES);\n len += Math.hypot(p.x - prev.x, p.y - prev.y);\n table.push(len);\n prev = p;\n }\n }\n return { a, c1, c2, b, straight, from, len: table[LENGTH_SAMPLES], table };\n}\n\n/** The parameter on `seg` lying `d` along it. */\nfunction paramAt(seg: Seg, d: number): number {\n const { table } = seg;\n if (seg.len === 0) return 0;\n let lo = 0;\n let hi = LENGTH_SAMPLES;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (table[mid] <= d) lo = mid;\n else hi = mid;\n }\n const span = table[hi] - table[lo];\n const f = span === 0 ? 0 : (d - table[lo]) / span;\n return Math.min(1, Math.max(0, (lo + f) / LENGTH_SAMPLES));\n}\n\n/** The run through `anchors[from..to]` of `sub`, indices taken modulo its\n * length so a closed subpath's run may wrap past its end. */\nexport function arcRun(sub: readonly PenAnchor[], from: number, to: number): ArcRun {\n const n = sub.length;\n const segs: Seg[] = [];\n let length = 0;\n for (let i = from; i < to; i++) {\n const seg = measure(sub[i % n], sub[(i + 1) % n], length);\n segs.push(seg);\n length += seg.len;\n }\n const locate = (s: number, arriving: boolean): { seg: Seg; t: number } => {\n const d = Math.min(Math.max(s, 0), length);\n let k = 0;\n while (k < segs.length - 1 && (arriving ? segs[k].from + segs[k].len < d : segs[k].from + segs[k].len <= d)) k++;\n return { seg: segs[k], t: paramAt(segs[k], d - segs[k].from) };\n };\n const start: Point = { x: sub[from % n].x, y: sub[from % n].y };\n return {\n length,\n pointAt(s) {\n if (segs.length === 0) return start;\n const { seg, t } = locate(s, false);\n if (seg.straight) return { x: seg.a.x + (seg.b.x - seg.a.x) * t, y: seg.a.y + (seg.b.y - seg.a.y) * t };\n return cubicPointAt(seg.a, seg.c1, seg.c2, seg.b, t);\n },\n headingAt(s, arriving = false) {\n if (segs.length === 0) return { x: 0, y: 0 };\n const { seg, t } = locate(s, arriving);\n return headingOn(seg, t);\n },\n };\n}\n","/**\n * Resample: a path's anchors spread evenly along it by arc length, and its\n * curves refitted through them.\n */\nimport type { PolygonPath } from '../path';\nimport { nearestOnCubic, nearestOnLine } from '../nearest';\nimport { anchorsToPath, isAnchorSmooth, pathToAnchors, type PenAnchor } from './anchors';\nimport { keepCorner } from './fitRun';\nimport { arcRun, type ArcRun } from './arcRun';\nimport type { Point } from './cubicMath';\nimport { fitCubicWithTangents } from './schneiderFit';\n\n/** Options for {@link resamplePath}. */\nexport interface ResamplePathOptions {\n /** How many anchors the result holds across all its subpaths. Default: as\n * many as `path` has. Ignored when `spacing` is given. */\n count?: number;\n /** The distance along the path between neighboring anchors, in path units.\n * Each run between fixed anchors is cut into the whole number of equal\n * pieces nearest this. */\n spacing?: number;\n /** Keep every corner anchor (`isAnchorSmooth` false) where it is, with its\n * corner, and resample the runs between. Default `true`. Open ends are\n * kept either way. */\n keepCorners?: boolean;\n /** How far the result may stray from the original, in path units. A piece\n * that cannot follow the original this closely is halved, so the result can\n * hold more anchors than `count` asks for. Default 0.5. */\n tolerance?: number;\n}\n\nconst FIT_SAMPLES = 16;\nconst MAX_HALVINGS = 6;\n\n/** A run between two fixed anchors, as the arc-length measure over it. */\ninterface Span {\n run: ArcRun;\n pieces: number;\n}\n\n/**\n * `path` with its anchors spread evenly along each run between fixed anchors\n * ({@link ResamplePathOptions}), each new anchor heading the way the original\n * does there. Anchors that were smooth stay smooth, and the curves between\n * are fitted to the original. A closed subpath with no fixed anchor keeps\n * its first one as the place the even spacing starts from. Fill rules carry\n * over.\n */\nexport function resamplePath(path: PolygonPath, opts: ResamplePathOptions = {}): PolygonPath {\n const { anchors, closed } = pathToAnchors(path);\n const keepCorners = opts.keepCorners ?? true;\n const tol = Math.max(opts.tolerance ?? 0.5, 1e-6);\n const fixedBySub = anchors.map((sub, s) => fixedAnchors(sub, closed[s], keepCorners));\n const spansBySub = anchors.map((sub, s) => spansOf(sub, closed[s], fixedBySub[s]));\n allocate(spansBySub.flat(), fixedBySub, opts, anchors);\n\n const out: PenAnchor[][] = [];\n anchors.forEach((sub, s) => {\n if (sub.length < 2) {\n out.push(sub);\n return;\n }\n const fixed = fixedBySub[s];\n const first = sub[fixed[0]];\n const result: PenAnchor[] = [{ x: first.x, y: first.y }];\n keepCorner(result[0], first);\n spansBySub[s].forEach((span, k) => {\n const closing = closed[s] && k === spansBySub[s].length - 1;\n appendSpan(span, tol, result, closing);\n if (!closing) keepCorner(result[result.length - 1], sub[fixed[k + 1]]);\n });\n out.push(result);\n });\n return anchorsToPath(out, closed, path);\n}\n\n/** Indices of the anchors of `sub` that stay where they are, ascending. */\nfunction fixedAnchors(sub: readonly PenAnchor[], closed: boolean, keepCorners: boolean): number[] {\n const n = sub.length;\n const fixed = new Set<number>();\n if (!closed && n > 0) {\n fixed.add(0);\n fixed.add(n - 1);\n }\n if (keepCorners) sub.forEach((a, i) => { if (!isAnchorSmooth(a)) fixed.add(i); });\n if (fixed.size === 0 && n > 0) fixed.add(0);\n return [...fixed].sort((a, b) => a - b);\n}\n\nfunction spansOf(sub: readonly PenAnchor[], closed: boolean, fixed: number[]): Span[] {\n if (sub.length < 2) return [];\n const stops = closed ? [...fixed, fixed[0] + sub.length] : fixed;\n const spans: Span[] = [];\n for (let k = 0; k + 1 < stops.length; k++) spans.push({ run: arcRun(sub, stops[k], stops[k + 1]), pieces: 1 });\n return spans;\n}\n\n/** How many equal pieces each span is cut into. */\nfunction allocate(spans: Span[], fixedBySub: number[][], opts: ResamplePathOptions, anchors: PenAnchor[][]): void {\n if (opts.spacing !== undefined && opts.spacing > 0) {\n for (const span of spans) span.pieces = Math.max(1, Math.round(span.run.length / opts.spacing));\n return;\n }\n const count = Math.floor(opts.count ?? anchors.reduce((n, sub) => n + sub.length, 0));\n const fixedCount = fixedBySub.reduce((n, f, s) => n + (anchors[s].length < 2 ? anchors[s].length : f.length), 0);\n const free = count - fixedCount;\n const total = spans.reduce((n, span) => n + span.run.length, 0);\n if (free <= 0 || total === 0) return;\n // Largest remainder: whole shares first, then the leftover anchors to the\n // spans that lost the most to rounding down.\n const shares = spans.map((span) => (free * span.run.length) / total);\n spans.forEach((span, i) => { span.pieces = 1 + Math.floor(shares[i]); });\n let left = free - spans.reduce((n, span) => n + span.pieces - 1, 0);\n const order = shares.map((v, i) => ({ i, r: v - Math.floor(v) })).sort((a, b) => b.r - a.r);\n for (let k = 0; left > 0 && k < order.length; k++, left--) spans[order[k].i].pieces++;\n}\n\n/** Cut `span` into its pieces, fit each, and append the anchors after the\n * first to `out`. `closing` folds the final anchor into `out[0]`. */\nfunction appendSpan(span: Span, tol: number, out: PenAnchor[], closing: boolean): void {\n const pieces: Array<{ c1?: Point; c2?: Point; end: Point }> = [];\n const { run } = span;\n for (let j = 0; j < span.pieces; j++) {\n fitPiece(run, (run.length * j) / span.pieces, (run.length * (j + 1)) / span.pieces, tol, 0, pieces);\n }\n pieces.forEach((piece, i) => {\n const prev = out[out.length - 1];\n if (piece.c1) prev.outHandle = piece.c1;\n if (closing && i === pieces.length - 1) {\n if (piece.c2) out[0].inHandle = piece.c2;\n return;\n }\n out.push(piece.c2 ? { x: piece.end.x, y: piece.end.y, inHandle: piece.c2 } : { x: piece.end.x, y: piece.end.y });\n });\n}\n\n/** Fit the stretch `[s0, s1]` of `run`, halving it while one cubic strays\n * past `tol`. */\nfunction fitPiece(\n run: ArcRun, s0: number, s1: number, tol: number, depth: number,\n out: Array<{ c1?: Point; c2?: Point; end: Point }>,\n): void {\n const samples: Point[] = [];\n const params: number[] = [];\n for (let i = 0; i <= FIT_SAMPLES; i++) {\n params.push(i / FIT_SAMPLES);\n samples.push(run.pointAt(s0 + ((s1 - s0) * i) / FIT_SAMPLES));\n }\n const a = samples[0];\n const e = samples[FIT_SAMPLES];\n if (worst(samples, (p) => nearestOnLine(p.x, p.y, a.x, a.y, e.x, e.y).dist) <= tol) {\n out.push({ end: e });\n return;\n }\n const tStart = run.headingAt(s0);\n const into = run.headingAt(s1, true);\n const { cp1, cp2 } = fitCubicWithTangents(samples, tStart, { x: -into.x, y: -into.y }, { params, passes: 3 });\n const err = worst(samples, (p) => nearestOnCubic(p.x, p.y, a.x, a.y, cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y).dist);\n if (err > tol && depth < MAX_HALVINGS) {\n const mid = (s0 + s1) / 2;\n fitPiece(run, s0, mid, tol, depth + 1, out);\n fitPiece(run, mid, s1, tol, depth + 1, out);\n return;\n }\n out.push({ c1: cp1, c2: cp2, end: e });\n}\n\nfunction worst(samples: readonly Point[], dist: (p: Point) => number): number {\n let max = 0;\n for (let i = 1; i < samples.length - 1; i++) max = Math.max(max, dist(samples[i]));\n return max;\n}\n\n","/**\n * Anchors at the extremes of a path's curves: where a curved segment is\n * furthest left, right, up or down along its own run. Splitting there puts\n * an anchor with an axis-aligned tangent at each turn, and changes no point\n * of the shape.\n */\nimport { cubicAxisExtremaTs } from '../curve';\nimport { isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\nimport { insertAnchorOnSegment, type AnchorSet } from './anchorEdits';\n\n/** How close to an end, in curve parameter, an extreme may sit and still get\n * an anchor of its own. Nearer, it is the end's. */\nconst END_SLOP = 1e-4;\n\n/** The parameters in (0, 1) where the segment from `a` to `b` turns in x or\n * y, ascending, or none for a straight segment. */\nexport function segmentExtremaTs(a: PenAnchor, b: PenAnchor): number[] {\n if (isStraightSegment(a, b)) return [];\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const ts = [\n ...cubicAxisExtremaTs(a.x, c1.x, c2.x, b.x),\n ...cubicAxisExtremaTs(a.y, c1.y, c2.y, b.y),\n ].filter((t) => t > END_SLOP && t < 1 - END_SLOP).sort((p, q) => p - q);\n return ts.filter((t, i) => i === 0 || t - ts[i - 1] > END_SLOP);\n}\n\n/**\n * Split every curved segment of `set` at its extremes\n * ({@link segmentExtremaTs}), in place. `include(sub, segIdx)` limits it to\n * some segments, named as `segmentEnds` names them; absent, every one.\n * Returns the new anchors' flat indices in the edited set. Each new anchor is\n * smooth, and every anchor after one moves up an index.\n */\nexport function addExtremaAnchors(\n set: AnchorSet,\n include?: (sub: number, segIdx: number) => boolean,\n): number[] {\n const added = new Set<PenAnchor>();\n set.anchors.forEach((sub, s) => {\n const segCount = sub.length - (set.closed[s] && sub.length > 1 ? 0 : 1);\n // Last to first, so a split never renumbers a segment still to come.\n for (let segIdx = segCount - 1; segIdx >= 0; segIdx--) {\n if (include && !include(s, segIdx)) continue;\n const ends = segmentEnds(set.anchors, set.closed, s, segIdx);\n if (!ends) continue;\n // Highest first: what is left to split is then always [0, end].\n let end = 1;\n for (const t of segmentExtremaTs(ends.a, ends.b).reverse()) {\n const at = insertAnchorOnSegment(set, { sub: s, segIdx, t: t / end });\n if (at >= 0) added.add(sub[segIdx + 1]);\n end = t;\n }\n }\n });\n const out: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (added.has(a)) out.push(flat);\n flat++;\n }\n }\n return out;\n}\n","/**\n * Anchor selections walked along the path: grown or shrunk by one anchor,\n * every Nth anchor, anchors by kind, and the complement. Each takes the\n * decoded set and a selection as flat indices, and returns a new selection\n * as sorted flat indices; none of them edits the set.\n *\n * \"Along the path\" means within a subpath: an anchor's neighbors are the\n * anchors before and after it there, and a closed subpath's first and last\n * anchors are neighbors.\n */\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\nimport { anchorCount, type AnchorSet } from './anchorEdits';\n\n/** The flat index of each subpath's first anchor. */\nfunction subpathStarts(set: AnchorSet): number[] {\n const starts: number[] = [];\n let base = 0;\n for (const sub of set.anchors) {\n starts.push(base);\n base += sub.length;\n }\n return starts;\n}\n\nconst sorted = (ids: Iterable<number>): number[] => [...new Set(ids)].sort((a, b) => a - b);\n\n/** The flat indices of the anchors either side of each anchor in `sub`\n * starting at `base`; a missing neighbor is -1. */\nfunction neighbors(set: AnchorSet, s: number, i: number, base: number): [number, number] {\n const n = set.anchors[s].length;\n const closed = set.closed[s] === true && n > 1;\n const prev = i > 0 ? i - 1 : closed ? n - 1 : -1;\n const next = i < n - 1 ? i + 1 : closed ? 0 : -1;\n return [prev < 0 ? -1 : base + prev, next < 0 ? -1 : base + next];\n}\n\n/** `selected` with each selected anchor's neighbors along the path added. */\nexport function growAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n const out = new Set(had);\n const starts = subpathStarts(set);\n set.anchors.forEach((sub, s) => {\n for (let i = 0; i < sub.length; i++) {\n if (!had.has(starts[s] + i)) continue;\n for (const k of neighbors(set, s, i, starts[s])) if (k >= 0) out.add(k);\n }\n });\n const total = anchorCount(set);\n return sorted([...out].filter((k) => k >= 0 && k < total));\n}\n\n/**\n * `selected` less every anchor at the edge of a selected run: one with a\n * neighbor that is unselected, or none on one side, as an open subpath's ends\n * have. A closed subpath selected all the way round has no edge and stays.\n */\nexport function shrinkAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n const out: number[] = [];\n const starts = subpathStarts(set);\n set.anchors.forEach((sub, s) => {\n for (let i = 0; i < sub.length; i++) {\n const flat = starts[s] + i;\n if (!had.has(flat)) continue;\n if (neighbors(set, s, i, starts[s]).every((k) => k >= 0 && had.has(k))) out.push(flat);\n }\n });\n return out;\n}\n\n/**\n * Every `n`th anchor along each subpath, counting from its first selected\n * anchor. With nothing selected, every subpath counts from its first anchor;\n * otherwise only subpaths holding a selected anchor take part. A closed\n * subpath is walked once round, so the count does not wrap onto itself.\n */\nexport function everyNthAnchor(set: AnchorSet, n: number, selected: Iterable<number> = []): number[] {\n const step = Math.max(1, Math.floor(n));\n const had = new Set(selected);\n const starts = subpathStarts(set);\n const out: number[] = [];\n set.anchors.forEach((sub, s) => {\n let from = had.size === 0 ? 0 : -1;\n for (let i = 0; from < 0 && i < sub.length; i++) if (had.has(starts[s] + i)) from = i;\n if (from < 0) return;\n const closed = set.closed[s] === true;\n const reach = closed ? sub.length : sub.length - from;\n for (let k = 0; k < reach; k += step) out.push(starts[s] + ((from + k) % sub.length));\n });\n return sorted(out);\n}\n\n/** Every anchor `keep` says yes to. */\nexport function anchorsWhere(set: AnchorSet, keep: (anchor: PenAnchor) => boolean): number[] {\n const out: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n if (keep(a)) out.push(flat);\n flat++;\n }\n }\n return out;\n}\n\n/** Every corner anchor: one whose handles are not collinear through it, or\n * that lacks one (`isAnchorSmooth` false). */\nexport function cornerAnchors(set: AnchorSet): number[] {\n return anchorsWhere(set, (a) => !isAnchorSmooth(a));\n}\n\n/** Every smooth anchor (`isAnchorSmooth`). */\nexport function smoothAnchors(set: AnchorSet): number[] {\n return anchorsWhere(set, isAnchorSmooth);\n}\n\n/** Every anchor `selected` leaves out. */\nexport function invertAnchorSelection(set: AnchorSet, selected: Iterable<number>): number[] {\n const had = new Set(selected);\n return anchorsWhere(set, () => true).filter((k) => !had.has(k));\n}\n","/**\n * Average and Join: anchor-set edits that bring anchors together. Both mutate\n * the model `pathToAnchors` produces in place, like the edits in\n * `anchorEdits`, and address anchors by flat index.\n */\n\nimport type { PenAnchor } from './anchors';\nimport { locateAnchor, translateAnchorBy, type AnchorSet } from './anchorEdits';\n\n/** Which coordinates {@link averageAnchorsAt} averages: `'x'` lines the\n * anchors up on one vertical, `'y'` on one horizontal, `'both'` stacks them\n * on one point. */\nexport type AverageAxis = 'x' | 'y' | 'both';\n\n/** One end of an open subpath. */\nexport interface SubpathEnd {\n sub: number;\n end: 'first' | 'last';\n}\n\n/** Endpoints closer than this are one point, and joining them merges them. */\nconst COINCIDENT = 1e-6;\n\n/** How {@link joinSubpathEnds} spans the gap between two ends apart. */\nexport interface JoinOptions {\n /** Absent, a straight segment. Given, a curve leaving each end along the\n * direction its path was heading there, each handle `tension` times the\n * gap long; `0` is a straight segment. */\n tension?: number;\n}\n\n/**\n * Move each anchor in `flatIndexes` to their mean position, along `axis`.\n * Each anchor carries its handles with it. Returns false, changing nothing,\n * when fewer than two of the indexes name anchors.\n */\nexport function averageAnchorsAt(set: AnchorSet, flatIndexes: Iterable<number>, axis: AverageAxis = 'both'): boolean {\n const picked: { flat: number; a: PenAnchor }[] = [];\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (loc) picked.push({ flat, a: set.anchors[loc.sub][loc.idx] });\n }\n if (picked.length < 2) return false;\n const mx = picked.reduce((s, p) => s + p.a.x, 0) / picked.length;\n const my = picked.reduce((s, p) => s + p.a.y, 0) / picked.length;\n for (const { flat, a } of picked) {\n translateAnchorBy(set, flat, axis === 'y' ? 0 : mx - a.x, axis === 'x' ? 0 : my - a.y);\n }\n return true;\n}\n\n/** The open-subpath end anchor `flatIndex` names, or null for an interior\n * anchor or one on a closed subpath. A lone anchor reads as `'last'`. */\nexport function subpathEndAt(set: AnchorSet, flatIndex: number): SubpathEnd | null {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || set.closed[loc.sub]) return null;\n const len = set.anchors[loc.sub].length;\n if (loc.idx === len - 1) return { sub: loc.sub, end: 'last' };\n if (loc.idx === 0) return { sub: loc.sub, end: 'first' };\n return null;\n}\n\n/**\n * Join the two open-subpath ends `a` and `b`. The two ends of one subpath\n * close it; ends of two subpaths make one subpath, `a`'s run followed by\n * `b`'s, in the slot of whichever came first. Ends that coincide merge into\n * one anchor, keeping the handle on either side; ends apart are bridged by a\n * straight segment, or with `options.tension` by a curve meeting each end\n * tangentially. Returns false, changing nothing, when the ends are not two\n * distinct ends of open subpaths.\n */\nexport function joinSubpathEnds(set: AnchorSet, a: SubpathEnd, b: SubpathEnd, options: JoinOptions = {}): boolean {\n const subA = set.anchors[a.sub];\n const subB = set.anchors[b.sub];\n if (!subA || !subB || set.closed[a.sub] || set.closed[b.sub]) return false;\n if (a.sub === b.sub) {\n if (a.end === b.end || subA.length < 2) return false;\n const first = subA[0];\n const last = subA[subA.length - 1];\n if (coincide(first, last) && subA.length > 2) {\n if (last.inHandle) first.inHandle = last.inHandle;\n subA.pop();\n } else if (options.tension !== undefined) {\n bridge(subA, subA, options.tension);\n }\n set.closed[a.sub] = true;\n return true;\n }\n if (a.end === 'first') reverseInPlace(subA);\n if (b.end === 'last') reverseInPlace(subB);\n const tail = subA[subA.length - 1];\n const head = subB[0];\n let joined: PenAnchor[];\n if (coincide(tail, head)) {\n if (head.outHandle) tail.outHandle = head.outHandle;\n joined = [...subA, ...subB.slice(1)];\n } else {\n if (options.tension !== undefined) bridge(subA, subB, options.tension);\n joined = [...subA, ...subB];\n }\n const keep = Math.min(a.sub, b.sub);\n const drop = Math.max(a.sub, b.sub);\n set.anchors[keep] = joined;\n set.anchors.splice(drop, 1);\n set.closed.splice(drop, 1);\n return true;\n}\n\n/** {@link joinSubpathEnds} for two anchors named by flat index, each the end\n * of an open subpath. */\nexport function joinAnchorsAt(set: AnchorSet, flatA: number, flatB: number, options: JoinOptions = {}): boolean {\n if (flatA === flatB) return false;\n const a = subpathEndAt(set, flatA);\n const b = subpathEndAt(set, flatB);\n if (!a || !b) return false;\n return joinSubpathEnds(set, a, b, options);\n}\n\n/**\n * The two open-subpath ends nearest each other that `accept` allows, on two\n * different subpaths. Null when there are no two such subpaths.\n */\nexport function closestOpenEnds(\n set: AnchorSet,\n accept: (a: SubpathEnd, b: SubpathEnd) => boolean = () => true,\n): [SubpathEnd, SubpathEnd] | null {\n const ends: { end: SubpathEnd; at: PenAnchor }[] = [];\n set.anchors.forEach((sub, s) => {\n if (set.closed[s] || sub.length < 2) return;\n ends.push({ end: { sub: s, end: 'first' }, at: sub[0] });\n ends.push({ end: { sub: s, end: 'last' }, at: sub[sub.length - 1] });\n });\n let best: [SubpathEnd, SubpathEnd] | null = null;\n let bestD = Infinity;\n for (let i = 0; i < ends.length; i++) {\n for (let j = i + 1; j < ends.length; j++) {\n const p = ends[i], q = ends[j];\n if (p.end.sub === q.end.sub || !accept(p.end, q.end)) continue;\n const d = Math.hypot(p.at.x - q.at.x, p.at.y - q.at.y);\n if (d < bestD) { bestD = d; best = [p.end, q.end]; }\n }\n }\n return best;\n}\n\nconst coincide = (p: PenAnchor, q: PenAnchor): boolean => Math.hypot(p.x - q.x, p.y - q.y) <= COINCIDENT;\n\ntype Vec = { x: number; y: number };\n\n/** The unit vector from `from` to `to`, or null when they coincide. */\nfunction unit(from: Vec, to: Vec): Vec | null {\n const d = Math.hypot(to.x - from.x, to.y - from.y);\n return d > COINCIDENT ? { x: (to.x - from.x) / d, y: (to.y - from.y) / d } : null;\n}\n\n/** The direction `sub` heads in at its last anchor: along the last segment's\n * final tangent, from the nearest of its controls that is apart from it. */\nfunction headingAtLast(sub: PenAnchor[]): Vec | null {\n const end = sub[sub.length - 1];\n const prev = sub.length > 1 ? sub[sub.length - 2] : null;\n for (const c of [end.inHandle, prev?.outHandle, prev]) {\n const u = c ? unit(c, end) : null;\n if (u) return u;\n }\n return null;\n}\n\n/** The direction `sub` heads in as it leaves its first anchor. */\nfunction headingAtFirst(sub: PenAnchor[]): Vec | null {\n const start = sub[0];\n const next = sub.length > 1 ? sub[1] : null;\n for (const c of [start.outHandle, next?.inHandle, next]) {\n const u = c ? unit(start, c) : null;\n if (u) return u;\n }\n return null;\n}\n\n/**\n * Shape the segment from `from`'s last anchor to `to`'s first as a curve that\n * carries on from each: handles `tension` times the gap long, along the\n * heading of each path at its end. An end with no heading of its own (a lone\n * anchor) aims at the other end.\n */\nfunction bridge(from: PenAnchor[], to: PenAnchor[], tension: number): void {\n const tail = from[from.length - 1];\n const head = to[0];\n const gap = Math.hypot(head.x - tail.x, head.y - tail.y);\n const chord = unit(tail, head);\n if (!chord || tension <= 0) return;\n const out = headingAtLast(from) ?? chord;\n const into = headingAtFirst(to) ?? chord;\n const len = tension * gap;\n tail.outHandle = { x: tail.x + out.x * len, y: tail.y + out.y * len };\n head.inHandle = { x: head.x - into.x * len, y: head.y - into.y * len };\n}\n\n/** Reverse `sub`'s direction keeping each anchor object, so origin tracking\n * (`editAnchorSetTracked`) still recognizes them. */\nfunction reverseInPlace(sub: PenAnchor[]): void {\n sub.reverse();\n for (const a of sub) {\n const { inHandle, outHandle } = a;\n delete a.inHandle;\n delete a.outHandle;\n if (outHandle) a.inHandle = outHandle;\n if (inHandle) a.outHandle = inHandle;\n }\n}\n","import type { Affine } from './affine';\n\n/**\n * The affine map carrying the points of `from` closest to those of `to`, by\n * least squares; both are interleaved `x, y` streams of the same length. When\n * the points lie on one line an affine map is not determined, and the\n * similarity (turn, even scale and move) is returned instead. Null for fewer\n * than two distinct points.\n */\nexport function fitAffine(from: ArrayLike<number>, to: ArrayLike<number>): Affine | null {\n const n = Math.min(from.length, to.length) >> 1;\n if (n === 0) return null;\n let fx = 0, fy = 0, tx = 0, ty = 0;\n for (let i = 0; i < n; i++) {\n fx += from[2 * i]; fy += from[2 * i + 1]; tx += to[2 * i]; ty += to[2 * i + 1];\n }\n fx /= n; fy /= n; tx /= n; ty /= n;\n // Centered sums: sxx = Σ x², sxy = Σ x·y, and so on, from on the left, to on the right.\n let sxx = 0, sxy = 0, syy = 0, sxu = 0, syu = 0, sxv = 0, syv = 0;\n for (let i = 0; i < n; i++) {\n const x = from[2 * i] - fx, y = from[2 * i + 1] - fy;\n const u = to[2 * i] - tx, v = to[2 * i + 1] - ty;\n sxx += x * x; sxy += x * y; syy += y * y;\n sxu += x * u; syu += y * u; sxv += x * v; syv += y * v;\n }\n const spread = sxx + syy;\n if (spread <= 1e-24) return null;\n const det = sxx * syy - sxy * sxy;\n let a: number, b: number, c: number, d: number;\n if (det > 1e-12 * spread * spread) {\n a = (sxu * syy - syu * sxy) / det;\n c = (syu * sxx - sxu * sxy) / det;\n b = (sxv * syy - syv * sxy) / det;\n d = (syv * sxx - sxv * sxy) / det;\n } else {\n a = (sxu + syv) / spread;\n b = (sxv - syu) / spread;\n c = -b;\n d = a;\n }\n return [a, b, c, d, tx - a * fx - c * fy, ty - b * fx - d * fy];\n}\n","/**\n * Ergonomic builders for tiny shape paths used by chrome / overlays / markers.\n * They all return `PolygonPath`.\n *\n * Not appropriate for *user-drawn* shapes (those have a pose and live in the\n * scene).\n */\n\nimport { rectToContour } from '../box';\nimport { PATH_L, PATH_M, PATH_Z } from '../commands';\nimport type { PolygonPath } from '../path';\n\n/**\n * N-segment polygon approximation of a circle. Default 32 segments → max\n * radial deviation of ≈0.005·r (≈0.05 px at r=10). Bump higher for large\n * filled circles where the facets become visible.\n */\nexport function circlePath(cx: number, cy: number, r: number, segments = 32): PolygonPath {\n const cmds = new Uint8Array(segments + 1);\n const coords = new Float32Array(segments * 2);\n cmds[0] = PATH_M;\n coords[0] = cx + r;\n coords[1] = cy;\n for (let i = 1; i < segments; i++) {\n cmds[i] = PATH_L;\n const theta = (i / segments) * Math.PI * 2;\n coords[i * 2] = cx + r * Math.cos(theta);\n coords[i * 2 + 1] = cy + r * Math.sin(theta);\n }\n cmds[segments] = PATH_Z;\n return { kind: 'polygon', commands: cmds, coords, fillRule: 'nonzero' };\n}\n\n/** Axis-aligned square centred at (cx, cy) with side length `size`. */\nexport function squarePath(cx: number, cy: number, size: number): PolygonPath {\n const half = size / 2;\n const x0 = cx - half, y0 = cy - half;\n const x1 = cx + half, y1 = cy + half;\n return {\n kind: 'polygon',\n commands: new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]),\n coords: new Float32Array([x0, y0, x1, y0, x1, y1, x0, y1]),\n fillRule: 'nonzero',\n };\n}\n\n/** Axis-aligned rectangle. Top-left at (x, y), width/height as given. */\nexport function rectMarkerPath(x: number, y: number, width: number, height: number): PolygonPath {\n return {\n kind: 'polygon',\n commands: new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]),\n coords: Float32Array.from(rectToContour(x, y, width, height)),\n fillRule: 'nonzero',\n };\n}\n\n/**\n * Axis-aligned rounded rectangle. Top-left at (x, y); `r` is clamped to half\n * the shorter side. Each corner is `cornerSamples` line segments — the\n * default 8 gives the same angular resolution as `circlePath`'s 32.\n */\nexport function roundRectPath(\n x: number,\n y: number,\n width: number,\n height: number,\n r: number,\n cornerSamples = 8,\n): PolygonPath {\n const radius = Math.max(0, Math.min(r, Math.min(width, height) / 2));\n if (radius === 0) return rectMarkerPath(x, y, width, height);\n\n const HALF_PI = Math.PI / 2;\n // Corner centers paired with the arc's start angle, walked clockwise in\n // screen space from the top-left.\n const corners: Array<[number, number, number]> = [\n [x + radius, y + radius, Math.PI],\n [x + width - radius, y + radius, -HALF_PI],\n [x + width - radius, y + height - radius, 0],\n [x + radius, y + height - radius, HALF_PI],\n ];\n\n const perCorner = cornerSamples + 1;\n const count = corners.length * perCorner;\n const cmds = new Uint8Array(count + 1);\n const coords = new Float32Array(count * 2);\n let i = 0;\n for (const [cx, cy, start] of corners) {\n for (let s = 0; s <= cornerSamples; s++) {\n const theta = start + (s / cornerSamples) * HALF_PI;\n cmds[i] = i === 0 ? PATH_M : PATH_L;\n coords[i * 2] = cx + radius * Math.cos(theta);\n coords[i * 2 + 1] = cy + radius * Math.sin(theta);\n i++;\n }\n }\n cmds[count] = PATH_Z;\n return { kind: 'polygon', commands: cmds, coords, fillRule: 'nonzero' };\n}\n","/**\n * 2D affine matrix utilities. Column-major 9 elements, matching\n * `WebGL2RenderingContext.uniformMatrix3fv` element order so an upload needs\n * no transpose flag.\n *\n * Layout (column-major):\n * [m00, m10, 0,\n * m01, m11, 0,\n * tx, ty, 1]\n */\n\nimport { invert as invertAffine, type Affine } from './affine';\n\n/**\n * A 2D affine transform as a column-major 9-element array, laid out as above.\n *\n * Every matrix the kit builds is a `Float64Array`: a view translation far\n * from the origin at high zoom needs more than a float32's 24 bits to hold a\n * fraction of a pixel. A `Float32Array` is accepted wherever one is read.\n * `mat3.toUniform` makes the float32 copy a GL uniform upload wants.\n */\nexport type GlMat3 = Float32Array | Float64Array;\n\nfunction create(a: number, b: number, c: number, d: number, tx: number, ty: number): GlMat3 {\n // Column-major:\n // col 0: (a, b, 0)\n // col 1: (c, d, 0)\n // col 2: (tx, ty, 1)\n return new Float64Array([a, b, 0, c, d, 0, tx, ty, 1]);\n}\n\nfunction identity(): GlMat3 {\n return create(1, 0, 0, 1, 0, 0);\n}\n\nfunction multiply(out: GlMat3, m: GlMat3): GlMat3 {\n // out := out · m (right-multiply by m).\n const a = out[0], b = out[1];\n const c = out[3], d = out[4];\n const tx = out[6], ty = out[7];\n const ma = m[0], mb = m[1];\n const mc = m[3], md = m[4];\n const mtx = m[6], mty = m[7];\n\n return create(\n a * ma + c * mb, // new a\n b * ma + d * mb, // new b\n a * mc + c * md, // new c\n b * mc + d * md, // new d\n a * mtx + c * mty + tx, // new tx\n b * mtx + d * mty + ty, // new ty\n );\n}\n\n/** `m · T(tx, ty)`: composes onto `m`, where `@weasel-js/geom`'s `translate`\n * constructs a fresh matrix. */\nfunction translated(m: GlMat3, tx: number, ty: number): GlMat3 {\n const t = create(1, 0, 0, 1, tx, ty);\n return multiply(m, t);\n}\n\n/** `m · S(sx, sy)`: composes onto `m`, where geom's `scale` constructs one. */\nfunction scaled(m: GlMat3, sx: number, sy: number): GlMat3 {\n const s = create(sx, 0, 0, sy, 0, 0);\n return multiply(m, s);\n}\n\n/** This layout read as the kernel's 6-element affine. The two carry the same\n * logical order, so the conversion is a repack and nothing else. */\nfunction toAffine(m: GlMat3): Affine {\n return [m[0], m[1], m[3], m[4], m[6], m[7]];\n}\n\n/** The kernel's affine in this layout. The inverse of {@link toAffine}. */\nfunction fromAffine(a: Affine): GlMat3 {\n return create(a[0], a[1], a[2], a[3], a[4], a[5]);\n}\n\n/** Inverse of an affine matrix, or `null` when `@weasel-js/geom`'s `invert`\n * finds it singular — the same rule, read through this layout. */\nfunction invert(m: GlMat3): GlMat3 | null {\n const inv = invertAffine(toAffine(m));\n return inv && fromAffine(inv);\n}\n\n/** A float32 copy of `m`, for `uniformMatrix3fv` or a shader uniform value. */\nfunction toUniform(m: GlMat3): Float32Array {\n return Float32Array.from(m);\n}\n\nfunction apply(m: GlMat3, x: number, y: number): [number, number] {\n const a = m[0], b = m[1];\n const c = m[3], d = m[4];\n const tx = m[6], ty = m[7];\n return [a * x + c * y + tx, b * x + d * y + ty];\n}\n\n/**\n * Map screen pixel coords (0..width on X, 0..height on Y, top-left origin)\n * into clip space (-1..1 on X, 1..-1 on Y — note Y flip so screen-down\n * matches clip-down).\n */\nfunction screenToClip(width: number, height: number): GlMat3 {\n return create(\n 2 / width, // a\n 0, // b\n 0, // c\n -2 / height, // d\n -1, // tx\n 1, // ty\n );\n}\n\n/**\n * Uniform-equivalent scale factor: the square root of the absolute\n * determinant of the linear part, i.e. the geometric mean of the two axis\n * scales. Rotation-invariant. Under non-uniform scale it is between the two\n * axes and exact on neither — the same compromise `meanScale` documents.\n */\nfunction meanScaleOf(m: GlMat3): number {\n return Math.sqrt(Math.abs(m[0] * m[4] - m[1] * m[3]));\n}\n\n/** The least any direction is scaled by the linear part — its smaller singular\n * value. What a screen length is worth in world units, at most. */\nfunction minScaleOf(m: GlMat3): number {\n const sum = m[0] * m[0] + m[1] * m[1] + m[3] * m[3] + m[4] * m[4];\n const det = m[0] * m[4] - m[1] * m[3];\n return Math.sqrt(Math.max(0, (sum - Math.sqrt(Math.max(0, sum * sum - 4 * det * det))) / 2));\n}\n\n/** The renderer's 3x3 matrix operations, as one namespace. These work on the\n * 9-element form the GL uniform upload wants — distinct from the 6-element\n * `Affine`, though the logical element order is the same. */\nexport const mat3 = {\n identity,\n toAffine,\n fromAffine,\n multiply,\n translated,\n scaled,\n invert,\n toUniform,\n apply,\n screenToClip,\n meanScaleOf,\n minScaleOf,\n};\n","import type { GlMat3 } from './glMat3';\nimport type { View } from './view';\n\n/**\n * Build the world→screen transform matrix for a `View`.\n * Use as the `transform` field of a `kind: 'group'` DrawCommand to wrap\n * world-space content emitted from a layer `draw` implementation.\n *\n * Mapping: `screen = (world − {view.x, view.y}) × {view.scale.x, view.scale.y}`.\n *\n * Column-major layout (matches `mat3.identity()`):\n * `[scale.x, 0, 0, 0, scale.y, 0, -view.x*scale.x, -view.y*scale.y, 1]`.\n */\nexport function viewToMat3(view: View): GlMat3 {\n const sx = view.scale.x;\n const sy = view.scale.y;\n // Add 0 to coerce -0 → 0, matching `mat3.identity()` for the {0,0,1} case.\n const tx = -view.x * sx + 0;\n const ty = -view.y * sy + 0;\n return new Float64Array([\n sx, 0, 0,\n 0, sy, 0,\n tx, ty, 1,\n ]);\n}\n","import type { Rect } from './box';\n\n/** Which side of the anchor the overlay sits on. */\nexport type PlacementSide = 'top' | 'bottom' | 'left' | 'right';\n\n/** How the overlay lines up along the side it sits on. */\nexport type PlacementAlign = 'start' | 'center' | 'end';\n\n/** A side paired with an alignment along it. */\nexport interface Placement {\n side: PlacementSide;\n align: PlacementAlign;\n}\n\n/** Inputs to {@link placeRect}. All rects share one coordinate space. */\nexport interface PlaceRectOptions {\n anchor: Rect;\n overlay: { width: number; height: number };\n boundary: Rect;\n placement: Placement;\n /** Gap between anchor and overlay along the side axis. Default 0. */\n offset?: number;\n /** Shift along the alignment axis. Default 0. */\n crossOffset?: number;\n /** Minimum gap kept between the overlay and the boundary. Default 0. */\n padding?: number;\n /** Whether to try the opposite side when the preferred one lacks room. Default true. */\n flip?: boolean;\n}\n\n/** Where the overlay landed, and the placement that produced it. */\nexport interface PlacedRect {\n rect: Rect;\n placement: Placement;\n}\n\nfunction alignAlong(start: number, extent: number, size: number, align: PlacementAlign): number {\n if (align === 'start') return start;\n if (align === 'end') return start + extent - size;\n return start + (extent - size) / 2;\n}\n\nfunction positionOn(\n anchor: Rect,\n overlay: { width: number; height: number },\n placement: Placement,\n offset: number,\n crossOffset: number,\n): Rect {\n const { width, height } = overlay;\n const { side, align } = placement;\n if (side === 'top' || side === 'bottom') {\n const y = side === 'bottom' ? anchor.y + anchor.height + offset : anchor.y - offset - height;\n return { x: alignAlong(anchor.x, anchor.width, width, align) + crossOffset, y, width, height };\n }\n const x = side === 'right' ? anchor.x + anchor.width + offset : anchor.x - offset - width;\n return { x, y: alignAlong(anchor.y, anchor.height, height, align) + crossOffset, width, height };\n}\n\nfunction clampAxis(start: number, size: number, low: number, extent: number, padding: number): number {\n const min = low + padding;\n return Math.max(min, Math.min(start, min + extent - padding * 2 - size));\n}\n\n/**\n * Move `rect` the shortest distance that puts it inside `boundary`, keeping its\n * size. A rect too big to fit pins to the boundary's leading edge.\n */\nexport function clampRectWithin(rect: Rect, boundary: Rect, padding = 0): Rect {\n return {\n ...rect,\n x: clampAxis(rect.x, rect.width, boundary.x, boundary.width, padding),\n y: clampAxis(rect.y, rect.height, boundary.y, boundary.height, padding),\n };\n}\n\n/** Slide along the alignment axis until the overlay is inside. */\nfunction shiftAcross(rect: Rect, boundary: Rect, side: PlacementSide, padding: number): Rect {\n const vertical = side === 'top' || side === 'bottom';\n const size = vertical ? rect.width : rect.height;\n const low = (vertical ? boundary.x : boundary.y) + padding;\n const high = low + (vertical ? boundary.width : boundary.height) - padding * 2 - size;\n const placed = Math.max(low, Math.min(vertical ? rect.x : rect.y, high));\n return vertical ? { ...rect, x: placed } : { ...rect, y: placed };\n}\n\nconst OPPOSITE: Record<PlacementSide, PlacementSide> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n};\n\nfunction fitsAlongSide(rect: Rect, boundary: Rect, side: PlacementSide, padding: number): boolean {\n const vertical = side === 'top' || side === 'bottom';\n const start = vertical ? rect.y : rect.x;\n const end = start + (vertical ? rect.height : rect.width);\n const low = (vertical ? boundary.y : boundary.x) + padding;\n const high = low + (vertical ? boundary.height : boundary.width) - padding * 2;\n return start >= low && end <= high;\n}\n\n/**\n * Position an overlay beside `anchor` at the requested placement. With `flip`,\n * a side that overflows the boundary is swapped for the opposite one when that\n * fits. The result then slides along the alignment axis to stay inside the\n * boundary; along the side axis it is left where it is, even if it overflows.\n */\nexport function placeRect(options: PlaceRectOptions): PlacedRect {\n const { anchor, overlay, boundary, placement, offset = 0, crossOffset = 0 } = options;\n const { padding = 0, flip = true } = options;\n\n let resolved = placement;\n let rect = positionOn(anchor, overlay, resolved, offset, crossOffset);\n\n if (flip && !fitsAlongSide(rect, boundary, resolved.side, padding)) {\n const opposite = { side: OPPOSITE[resolved.side], align: resolved.align };\n const flipped = positionOn(anchor, overlay, opposite, offset, crossOffset);\n if (fitsAlongSide(flipped, boundary, opposite.side, padding)) {\n resolved = opposite;\n rect = flipped;\n }\n }\n\n return { rect: shiftAcross(rect, boundary, resolved.side, padding), placement: resolved };\n}\n","/** An easing curve: maps normalized progress `t ∈ [0, 1]` to eased progress.\n * Curves may leave the 0–1 range in the middle (back, elastic) but should\n * pass through 0 at 0 and 1 at 1. */\nexport type EasingFn = (t: number) => number;\n\n/** A spring's physical parameters. Higher stiffness settles faster, higher\n * damping overshoots less, higher mass makes both sluggish. */\nexport interface SpringPreset {\n stiffness: number;\n damping: number;\n mass: number;\n}\n\n/** One of the tunings in `SPRING_PRESETS`. */\nexport type SpringPresetName = 'gentle' | 'wobbly' | 'stiff' | 'slow';\n\n// --- Polynomial family (degree 1-5). The unsuffixed `easeIn`/`easeOut`/\n// `easeInOut` aliases mirror the `easeInQuad` curve (degree 2) for backwards\n// compatibility with existing call sites.\n\n/** No easing: constant rate from start to finish. */\nexport const linear: EasingFn = (t) => t;\n\n// Quadratic (degree 2)\n/** Accelerates from a standstill, gently. */\nexport const easeInQuad: EasingFn = (t) => t * t;\n/** Decelerates to a stop, gently. The safe default for UI motion. */\nexport const easeOutQuad: EasingFn = (t) => 1 - (1 - t) * (1 - t);\n/** Accelerates then decelerates, gently. */\nexport const easeInOutQuad: EasingFn = (t) =>\n t < 0.5 ? 2 * t * t : 1 - 2 * (1 - t) * (1 - t);\n\n// Cubic (degree 3)\n/** Accelerates from a standstill, moderately. */\nexport const easeInCubic: EasingFn = (t) => t * t * t;\n/** Decelerates to a stop, moderately. */\nexport const easeOutCubic: EasingFn = (t) => 1 - Math.pow(1 - t, 3);\n/** Accelerates then decelerates, moderately. */\nexport const easeInOutCubic: EasingFn = (t) =>\n t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;\n\n// Quartic (degree 4)\n/** Accelerates from a standstill, sharply. */\nexport const easeInQuart: EasingFn = (t) => t * t * t * t;\n/** Decelerates to a stop, sharply. */\nexport const easeOutQuart: EasingFn = (t) => 1 - Math.pow(1 - t, 4);\n/** Accelerates then decelerates, sharply. */\nexport const easeInOutQuart: EasingFn = (t) =>\n t < 0.5 ? 8 * t * t * t * t : 1 - Math.pow(-2 * t + 2, 4) / 2;\n\n// Quintic (degree 5)\n/** Accelerates from a standstill, very sharply. */\nexport const easeInQuint: EasingFn = (t) => t * t * t * t * t;\n/** Decelerates to a stop, very sharply. */\nexport const easeOutQuint: EasingFn = (t) => 1 - Math.pow(1 - t, 5);\n/** Accelerates then decelerates, very sharply. */\nexport const easeInOutQuint: EasingFn = (t) =>\n t < 0.5 ? 16 * t * t * t * t * t : 1 - Math.pow(-2 * t + 2, 5) / 2;\n\n// --- Trigonometric / transcendental\n\n/** Accelerates from a standstill along a sine curve — the mildest\n * acceleration of the built-ins. */\nexport const easeInSine: EasingFn = (t) => 1 - Math.cos((t * Math.PI) / 2);\n/** Decelerates to a stop along a sine curve — the mildest\n * deceleration of the built-ins. */\nexport const easeOutSine: EasingFn = (t) => Math.sin((t * Math.PI) / 2);\n/** Accelerates then decelerates along a sine curve. */\nexport const easeInOutSine: EasingFn = (t) => -(Math.cos(Math.PI * t) - 1) / 2;\n\n/** Accelerates exponentially: barely moves at first, then rushes. */\nexport const easeInExpo: EasingFn = (t) => (t === 0 ? 0 : Math.pow(2, 10 * t - 10));\n/** Decelerates exponentially: leaps away, then creeps in. */\nexport const easeOutExpo: EasingFn = (t) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t));\n/** Exponential at both ends — a very fast middle between two\n * near-still extremes. */\nexport const easeInOutExpo: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return t < 0.5\n ? Math.pow(2, 20 * t - 10) / 2\n : (2 - Math.pow(2, -20 * t + 10)) / 2;\n};\n\n/** Accelerates along a circular arc: slow start, abrupt arrival. */\nexport const easeInCirc: EasingFn = (t) => 1 - Math.sqrt(1 - t * t);\n/** Decelerates along a circular arc: abrupt start, slow arrival. */\nexport const easeOutCirc: EasingFn = (t) => Math.sqrt(1 - Math.pow(t - 1, 2));\n/** Circular arcs at both ends. */\nexport const easeInOutCirc: EasingFn = (t) =>\n t < 0.5\n ? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2\n : (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;\n\n// --- Overshoot / oscillate / decay (Penner's named curves).\n// Constants are the well-known defaults; a future iteration could expose\n// per-call tuning (stiffness on back, amplitude/period on elastic).\n\nconst C1 = 1.70158; // back overshoot\nconst C2 = C1 * 1.525; // back inOut\nconst C3 = C1 + 1;\nconst C4 = (2 * Math.PI) / 3; // elastic in/out\nconst C5 = (2 * Math.PI) / 4.5;\n\n/** Pulls back past the start before moving forward. Overshoots below 0. */\nexport const easeInBack: EasingFn = (t) => C3 * t * t * t - C1 * t * t;\n/** Overshoots the target, then settles back onto it. Exceeds 1. */\nexport const easeOutBack: EasingFn = (t) =>\n 1 + C3 * Math.pow(t - 1, 3) + C1 * Math.pow(t - 1, 2);\n/** Overshoots at both ends. Leaves the 0–1 range on each side. */\nexport const easeInOutBack: EasingFn = (t) =>\n t < 0.5\n ? (Math.pow(2 * t, 2) * ((C2 + 1) * 2 * t - C2)) / 2\n : (Math.pow(2 * t - 2, 2) * ((C2 + 1) * (2 * t - 2) + C2) + 2) / 2;\n\n/** Oscillates around the start with growing amplitude, then snaps away. */\nexport const easeInElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * C4);\n};\n/** Springs past the target and wobbles into it. Exceeds 1. */\nexport const easeOutElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * C4) + 1;\n};\n/** Wobbles at both ends. Leaves the 0–1 range on each side. */\nexport const easeInOutElastic: EasingFn = (t) => {\n if (t === 0) return 0;\n if (t === 1) return 1;\n return t < 0.5\n ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * C5)) / 2\n : (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * C5)) / 2 + 1;\n};\n\n/** Lands on the target and bounces, in hops of decreasing height. */\nexport const easeOutBounce: EasingFn = (t) => {\n const n1 = 7.5625;\n const d1 = 2.75;\n if (t < 1 / d1) return n1 * t * t;\n if (t < 2 / d1) { t -= 1.5 / d1; return n1 * t * t + 0.75; }\n if (t < 2.5 / d1) { t -= 2.25 / d1; return n1 * t * t + 0.9375; }\n t -= 2.625 / d1;\n return n1 * t * t + 0.984375;\n};\n/** Bounces up to the start before departing — `easeOutBounce` reversed. */\nexport const easeInBounce: EasingFn = (t) => 1 - easeOutBounce(1 - t);\n/** Bounces at both ends. */\nexport const easeInOutBounce: EasingFn = (t) =>\n t < 0.5\n ? (1 - easeOutBounce(1 - 2 * t)) / 2\n : (1 + easeOutBounce(2 * t - 1)) / 2;\n\n// --- Backwards-compat aliases. Pre-library callers asked for `easeIn`/\n// `easeOut`/`easeInOut`; those resolve to the quadratic curve.\n/** Alias for `easeInQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeIn = easeInQuad;\n/** Alias for `easeOutQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeOut = easeOutQuad;\n/** Alias for `easeInOutQuad`, kept for call sites that predate the\n * named-curve library. */\nexport const easeInOut = easeInOutQuad;\n\n/** All easings in one bag — useful for demos / pickers. */\nexport const EASINGS = {\n linear,\n easeInQuad, easeOutQuad, easeInOutQuad,\n easeInCubic, easeOutCubic, easeInOutCubic,\n easeInQuart, easeOutQuart, easeInOutQuart,\n easeInQuint, easeOutQuint, easeInOutQuint,\n easeInSine, easeOutSine, easeInOutSine,\n easeInExpo, easeOutExpo, easeInOutExpo,\n easeInCirc, easeOutCirc, easeInOutCirc,\n easeInBack, easeOutBack, easeInOutBack,\n easeInElastic, easeOutElastic, easeInOutElastic,\n easeInBounce, easeOutBounce, easeInOutBounce,\n} as const;\n\n/** The name of one of the built-in easing curves. */\nexport type EasingName = keyof typeof EASINGS;\n\n/** Named spring tunings, from softest to firmest. Springs settle on a target\n * rather than running for a fixed duration, so these are an alternative to an\n * easing curve, not a modifier on one. */\nexport const SPRING_PRESETS: Record<SpringPresetName, SpringPreset> = {\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n wobbly: { stiffness: 180, damping: 12, mass: 1 },\n stiff: { stiffness: 210, damping: 20, mass: 1 },\n slow: { stiffness: 80, damping: 20, mass: 1 },\n};\n","import { EASINGS, type EasingFn, type EasingName } from './easings';\n\n/** Cubic-bezier control points, CSS `cubic-bezier()` order. The curve's two\n * endpoints are implicit at (0,0) and (1,1). */\nexport interface BezierEasing {\n /** `readonly` so an `as const` preset is assignable; nothing ever writes it. */\n bezier: readonly [number, number, number, number];\n}\n\n/** An easing curve as a value: a function, the name of a built-in, or control\n * points. Anything an editor has to name, show or serialize must not be a bare\n * function, which is why the union exists. */\nexport type EasingSpec = EasingFn | EasingName | BezierEasing;\n\nconst NEWTON_ITERATIONS = 8;\nconst NEWTON_MIN_SLOPE = 1e-3;\nconst SUBDIVISION_EPSILON = 1e-7;\nconst SUBDIVISION_MAX = 12;\n\nfunction bezierAt(t: number, a1: number, a2: number): number {\n const c = 3 * a1;\n const b = 3 * (a2 - a1) - c;\n const a = 1 - c - b;\n return ((a * t + b) * t + c) * t;\n}\n\nfunction bezierSlope(t: number, a1: number, a2: number): number {\n const c = 3 * a1;\n const b = 3 * (a2 - a1) - c;\n const a = 1 - c - b;\n return (3 * a * t + 2 * b) * t + c;\n}\n\n/** Solve for the bezier parameter that puts the curve at `x`. Newton-Raphson\n * where the slope allows it, bisection where it does not — the standard\n * approach, and the one browsers use for `cubic-bezier()`. */\nfunction solveForX(x: number, x1: number, x2: number): number {\n let t = x;\n for (let i = 0; i < NEWTON_ITERATIONS; i++) {\n const slope = bezierSlope(t, x1, x2);\n if (slope < NEWTON_MIN_SLOPE) break;\n t -= (bezierAt(t, x1, x2) - x) / slope;\n }\n let lo = 0;\n let hi = 1;\n t = Math.min(1, Math.max(0, t));\n for (let i = 0; i < SUBDIVISION_MAX; i++) {\n const err = bezierAt(t, x1, x2) - x;\n if (Math.abs(err) < SUBDIVISION_EPSILON) return t;\n if (err > 0) hi = t; else lo = t;\n t = (lo + hi) / 2;\n }\n return t;\n}\n\n/** Build the easing curve for four cubic-bezier control points. `x1`/`x2` are\n * clamped to [0,1] — CSS `cubic-bezier()`'s constraint for a monotone x(t),\n * which both `solveForX` root-finders assume. `y1`/`y2` are unclamped: an\n * overshoot easing (back, elastic) needs them outside 0..1. */\nexport function cubicBezierEasing(\n x1: number, y1: number, x2: number, y2: number,\n): EasingFn {\n const cx1 = Math.min(1, Math.max(0, x1));\n const cx2 = Math.min(1, Math.max(0, x2));\n return (t) => {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n return bezierAt(solveForX(t, cx1, cx2), y1, y2);\n };\n}\n\n/** Memoized so two equal specs resolve to one function, not a fresh solver per call. */\nconst bezierCache = new Map<string, EasingFn>();\nconst BEZIER_CACHE_LIMIT = 256;\n\nfunction isBezier(spec: EasingSpec): spec is BezierEasing {\n return typeof spec === 'object' && spec !== null && 'bezier' in spec;\n}\n\n/** Resolve a spec to the function that shapes progress. `undefined` is linear. */\nexport function resolveEasing(spec?: EasingSpec): EasingFn {\n if (spec === undefined) return EASINGS.linear;\n if (typeof spec === 'function') return spec;\n if (typeof spec === 'string') {\n const fn = EASINGS[spec];\n if (!fn) throw new Error(`resolveEasing: unknown easing name \"${spec}\"`);\n return fn;\n }\n if (isBezier(spec)) {\n const [x1, y1, x2, y2] = spec.bezier;\n const key = `${x1},${y1},${x2},${y2}`;\n let fn = bezierCache.get(key);\n if (!fn) {\n fn = cubicBezierEasing(x1, y1, x2, y2);\n // A handle being dragged resolves a new curve every pointer move.\n if (bezierCache.size >= BEZIER_CACHE_LIMIT) bezierCache.delete(bezierCache.keys().next().value!);\n bezierCache.set(key, fn);\n }\n return fn;\n }\n throw new Error('resolveEasing: unrecognized easing spec');\n}\n","/**\n * Geometric mean of a per-axis scale's magnitudes, so a flipped (negative)\n * axis counts by its size.\n *\n * **Not for hit-testing.** A screen-pixel length is not one world distance\n * under non-uniform zoom, and collapsing it to a scalar makes a pickable\n * region too generous on one axis and too mean on the other. Use `pxExtent`\n * for a per-axis world length, or `withinPxBox` / `withinPxRadius` to compare\n * in screen space directly. Nor for placing chrome or measuring a pick slop:\n * `standoff` and `strokeHitTest`'s `slop` work on screen.\n *\n * What legitimately remains is a stroke width for a line that is not\n * axis-aligned: the renderer resolves a `{ px }` width through this same\n * mean, so a picker reading ink widths must too.\n */\nexport function meanScale(s: { x: number; y: number }): number {\n return Math.sqrt(Math.abs(s.x * s.y));\n}\n","/**\n * The kit's single encoding of the pose-rotation convention: \"rotate about the\n * pose's unrotated AABB center by `pose.rotation` (radians).\"\n *\n * A pose may also carry a `transform` inside the rotation. `poseFrameOf`\n * (`./poseFrame`) composes the two, and is what a reader that draws, bounds,\n * or picks the node wants; this module is the angle and pivot alone.\n */\nimport { forEachSegment, pathCommandCoordCount, PATH_L, PATH_M, PATH_Z } from './commands';\nimport type { Path, PolygonPath } from './path';\n\n/** Pivot (`cx`, `cy`) and angle resolved from a pose's rotation convention. */\nexport interface PoseRotation {\n cx: number;\n cy: number;\n rotation: number;\n}\n\n/**\n * Resolve a pose's rotation transform, or `null` when the pose carries no\n * effective rotation. Non-null requires a nonzero `rotation` **and** all four\n * AABB fields (`x`, `y`, `width`, `height`) — the pivot is the unrotated AABB\n * center.\n */\nexport function poseRotationOf(pose: unknown): PoseRotation | null {\n const p = pose as Partial<{ x: number; y: number; width: number; height: number; rotation: number }>;\n if (p.rotation && p.x != null && p.y != null && p.width != null && p.height != null) {\n return { cx: p.x + p.width / 2, cy: p.y + p.height / 2, rotation: p.rotation };\n }\n return null;\n}\n\n/**\n * Rotate every coordinate of `path` about `(cx, cy)` by `rotation` radians.\n * A `rect` promotes to a four-corner polygon (axis-aligned rects can't encode\n * rotation). Returns a fresh `PolygonPath`; never mutates the input.\n */\nexport function rotatePathAround(path: Path, cx: number, cy: number, rotation: number): PolygonPath {\n if (path.kind === 'rect') {\n return rotateRectCorners(path.x, path.y, path.width, path.height, cx, cy, rotation);\n }\n return rotatePolygon(path, cx, cy, rotation);\n}\n\nfunction rotatePolygon(path: PolygonPath, cx: number, cy: number, rotation: number): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const { commands, coords } = path;\n const next = new Float32Array(coords.length);\n forEachSegment(commands, coords, (cmd, ci) => {\n for (let k = 0, len = pathCommandCoordCount(cmd); k < len; k += 2) {\n const dx = coords[ci + k] - cx;\n const dy = coords[ci + k + 1] - cy;\n next[ci + k] = cx + dx * cos - dy * sin;\n next[ci + k + 1] = cy + dx * sin + dy * cos;\n }\n });\n return { ...path, coords: next };\n}\n\nfunction rotateRectCorners(\n x: number, y: number, w: number, h: number,\n cx: number, cy: number, rotation: number,\n): PolygonPath {\n const cos = Math.cos(rotation);\n const sin = Math.sin(rotation);\n const rotate = (px: number, py: number): [number, number] => {\n const dx = px - cx;\n const dy = py - cy;\n return [cx + dx * cos - dy * sin, cy + dx * sin + dy * cos];\n };\n const [x0, y0] = rotate(x, y);\n const [x1, y1] = rotate(x + w, y);\n const [x2, y2] = rotate(x + w, y + h);\n const [x3, y3] = rotate(x, y + h);\n const commands = new Uint8Array([PATH_M, PATH_L, PATH_L, PATH_L, PATH_Z]);\n const coords = new Float32Array([x0, y0, x1, y1, x2, y2, x3, y3]);\n return { kind: 'polygon', commands, coords, fillRule: 'nonzero' };\n}\n","/**\n * The one composition of a box pose into the matrix that carries its own\n * frame to its parent's: the rotation convention of `poseRotationOf`, and the\n * pose's residual `transform` inside it. Painting, culling, silhouettes, and\n * picking all read a pose through `poseFrameOf` so they agree on where the\n * node is.\n */\nimport { invert, multiply, rotateAboutPoint, type Affine } from './affine';\nimport type { Path } from './path';\nimport { transformPath } from './paths/transformPath';\nimport { poseRotationOf, rotatePathAround } from './poseRotation';\n\n/**\n * The linear part of a box pose that its box, rotation, and flips cannot\n * hold: a skew, or a scale that differs by axis. `[a, b, c, d]` in\n * `Affine` order (`x' = a·x + c·y`, `y' = b·x + d·y`), applied about the\n * box center to what the node draws in its unrotated box, before the\n * rotation. Absent is the identity.\n */\nexport type PoseLinear = readonly [a: number, b: number, c: number, d: number];\n\n/**\n * Axis-aligned rectangle in world space. The optional `rotation` (radians,\n * around the AABB center) and `transform` (inside it, about the same center)\n * let chrome carry the frame a box is drawn in without a parallel type;\n * `poseFrameOf` composes the two. routing and core call it `Bounds`.\n */\nexport interface FramedBox {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n transform?: PoseLinear;\n}\n\n/** `transform` when it changes anything, `null` for absent or the identity. */\nexport function poseLinearOf(pose: unknown): PoseLinear | null {\n const t = (pose as { transform?: unknown } | null | undefined)?.transform;\n if (!Array.isArray(t) || t.length !== 4) return null;\n if (t[0] === 1 && t[1] === 0 && t[2] === 0 && t[3] === 1) return null;\n return t as unknown as PoseLinear;\n}\n\n/**\n * The matrix taking a point in the pose's own unrotated box frame to where\n * the node draws it: `rotate(rotation) · transform`, about the box center.\n * `null` when the pose has neither, or is not a box, so a caller can skip\n * the step.\n */\nexport function poseFrameOf(pose: unknown): Affine | null {\n const p = pose as Partial<FramedBox> | null | undefined;\n if (!p || p.x == null || p.y == null || p.width == null || p.height == null) return null;\n const linear = poseLinearOf(p);\n if (!p.rotation && !linear) return null;\n const cx = p.x + p.width / 2;\n const cy = p.y + p.height / 2;\n if (!linear) return rotateAboutPoint(cx, cy, p.rotation as number);\n const [a, b, c, d] = linear;\n const about: Affine = [a, b, c, d, cx - (a * cx + c * cy), cy - (b * cx + d * cy)];\n return p.rotation ? multiply(rotateAboutPoint(cx, cy, p.rotation), about) : about;\n}\n\n/**\n * The inverse of {@link poseFrameOf}: where a parent-frame point falls in the\n * pose's unrotated box frame. `null` when there is no frame to undo, or when\n * the `transform` is singular and nothing maps back.\n */\nexport function poseFrameInverseOf(pose: unknown): Affine | null {\n if (!poseLinearOf(pose)) {\n // The same pivot turned back: exact, where inverting the matrix is not.\n const r = poseRotationOf(pose);\n return r && rotateAboutPoint(r.cx, r.cy, -r.rotation);\n }\n const frame = poseFrameOf(pose);\n return frame && invert(frame);\n}\n\n/** `path`, given in the pose's unrotated box frame, as the node draws it. */\nexport function pathThroughPoseFrame(path: Path, pose: unknown): Path {\n if (poseLinearOf(pose)) {\n const frame = poseFrameOf(pose);\n return frame ? transformPath(path, frame) : path;\n }\n const r = poseRotationOf(pose);\n return r ? rotatePathAround(path, r.cx, r.cy, r.rotation) : path;\n}\n","import type { Scale2 } from '../pxExtent';\nimport type { AnchorSet } from './anchorEdits';\nimport type { Point } from './cubicMath';\n\n/**\n * Flat indices of every anchor a round brush covers as it moves from `from` to\n * `to`: those within `radiusPx` of that segment, measured on screen. A dab is a\n * segment of zero length. `scale` is the view's, so the brush stays round on\n * screen under non-uniform zoom; omitted, one unit is one pixel.\n */\nexport function anchorsUnderBrush(\n set: AnchorSet,\n from: Point,\n to: Point,\n opts: { radiusPx: number; scale?: Scale2 },\n): number[] {\n const scale = opts.scale ?? { x: 1, y: 1 };\n const ax = from.x * scale.x, ay = from.y * scale.y;\n const dx = to.x * scale.x - ax, dy = to.y * scale.y - ay;\n const len2 = dx * dx + dy * dy;\n const r2 = opts.radiusPx * opts.radiusPx;\n const hits: number[] = [];\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n const px = a.x * scale.x - ax, py = a.y * scale.y - ay;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, (px * dx + py * dy) / len2));\n const ex = px - t * dx, ey = py - t * dy;\n if (ex * ex + ey * ey <= r2) hits.push(flat);\n flat++;\n }\n }\n return hits;\n}\n","import { applyToPoint, type Affine } from '../affine';\nimport { anchorAt, anchorCount, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\nimport type { Point } from './cubicMath';\n\ntype Side = 'in' | 'out';\n\n/**\n * How a path maps onto itself under one transform `m`: `partners[i]` is the\n * flat index of the anchor that anchor `i` lands on, and `flips[i]` whether\n * its in-handle lands on that anchor's out-handle — a mirror reverses which\n * way a path runs, a rotation does not. An anchor `m` fixes is its own\n * partner.\n */\nexport interface AnchorSymmetry {\n readonly m: Affine;\n readonly partners: readonly number[];\n readonly flips: readonly boolean[];\n}\n\nfunction near(a: Point | undefined, b: Point | undefined, tol: number): boolean {\n if (!a || !b) return a === b;\n return Math.abs(a.x - b.x) <= tol && Math.abs(a.y - b.y) <= tol;\n}\n\nfunction image(m: Affine, p: Point): Point;\nfunction image(m: Affine, p: Point | undefined): Point | undefined;\nfunction image(m: Affine, p: Point | undefined): Point | undefined {\n if (!p) return undefined;\n const [x, y] = applyToPoint(m, p.x, p.y);\n return { x, y };\n}\n\nfunction linear(m: Affine, d: Point): Point {\n return { x: m[0] * d.x + m[2] * d.y, y: m[1] * d.x + m[3] * d.y };\n}\n\n/** How `a` lands on `b` under `m`: `false` with the handles side for side,\n * `true` with them swapped, `null` when it is not `b`'s image. Side for side\n * is tried first, so an anchor with no handles is never a flip. */\nfunction landing(m: Affine, a: PenAnchor, b: PenAnchor, tol: number): boolean | null {\n if (!near(image(m, a), b, tol)) return null;\n const i = image(m, a.inHandle);\n const o = image(m, a.outHandle);\n if (near(i, b.inHandle, tol) && near(o, b.outHandle, tol)) return false;\n if (near(i, b.outHandle, tol) && near(o, b.inHandle, tol)) return true;\n return null;\n}\n\n/**\n * The pairing that makes `set` its own image under `m`, or `null` when it is\n * not one: every anchor, handles included, must land on a distinct anchor\n * within `tolerance` on each axis.\n */\nexport function anchorSymmetry(set: AnchorSet, m: Affine, tolerance = 1e-6): AnchorSymmetry | null {\n const n = anchorCount(set);\n const partners: number[] = [];\n const flips: boolean[] = [];\n const taken = new Set<number>();\n for (let i = 0; i < n; i++) {\n const a = anchorAt(set, i)!;\n let found = -1;\n let flip = false;\n for (let j = 0; j < n && found < 0; j++) {\n if (taken.has(j)) continue;\n const how = landing(m, a, anchorAt(set, j)!, tolerance);\n if (how === null) continue;\n found = j;\n flip = how;\n }\n if (found < 0) return null;\n taken.add(found);\n partners.push(found);\n flips.push(flip);\n }\n return { m, partners, flips };\n}\n\n/** Every transform in `group` that `set` is its own image under, paired. */\nexport function anchorSymmetries(set: AnchorSet, group: readonly Affine[], tolerance = 1e-6): AnchorSymmetry[] {\n return group\n .map((m) => anchorSymmetry(set, m, tolerance))\n .filter((s): s is AnchorSymmetry => s !== null);\n}\n\n/**\n * `d` averaged over every transform in `syms` that fixes what `fixes` names,\n * and the identity: the part of the move that keeps it where those transforms\n * hold it. Exact when `syms` is a group less its identity — an anchor on a\n * mirror axis slides along it, an anchor at a center of rotation stays put.\n */\nfunction averaged(d: Point, syms: readonly AnchorSymmetry[], fixes: (s: AnchorSymmetry) => boolean, apply: (m: Affine, p: Point) => Point): Point {\n let x = d.x;\n let y = d.y;\n let k = 1;\n for (const s of syms) {\n if (!fixes(s)) continue;\n const p = apply(s.m, d);\n x += p.x;\n y += p.y;\n k++;\n }\n return { x: x / k, y: y / k };\n}\n\n/**\n * Translate the anchors `flats` by `(dx, dy)` the way `translateAnchorBy`\n * does, and every image of each under `syms` by the transformed delta, so a\n * path that was its own image under each of them still is. `syms` should be\n * the whole symmetry group less its identity, as `anchorSymmetries` gives it\n * for a group; with a part of one, the anchors it fixes are only partly held.\n * An anchor that is itself being dragged moves as dragged.\n */\nexport function translateAnchorsSymmetric(\n set: AnchorSet,\n flats: readonly number[],\n dx: number,\n dy: number,\n syms: readonly AnchorSymmetry[],\n): boolean {\n const dragged = new Set(flats);\n const moves = new Map<number, Point>();\n for (const flat of flats) {\n const d = averaged({ x: dx, y: dy }, syms, (s) => s.partners[flat] === flat, linear);\n moves.set(flat, d);\n for (const s of syms) {\n const j = s.partners[flat];\n if (j === undefined || dragged.has(j) || moves.has(j)) continue;\n moves.set(j, linear(s.m, d));\n }\n }\n let changed = false;\n for (const [flat, d] of moves) changed = translateAnchorBy(set, flat, d.x, d.y) || changed;\n return changed;\n}\n\nconst other = (side: Side): Side => (side === 'in' ? 'out' : 'in');\n\n/**\n * Move one handle to `(toX, toY)` and every image of it under `syms` to the\n * image of that point, so a path that was its own image under each of them\n * still is. A handle a transform maps onto itself keeps to where that\n * transform allows; one mapped onto its own anchor's opposite handle drives\n * that handle.\n *\n * Otherwise a smooth anchor keeps the opposite handle opposite, as\n * `moveHandleTo` does, unless `breakSmoothness`, and that handle's images\n * follow it. Every handle is written once, from its target, so no anchor\n * re-aims a handle another image already placed.\n */\nexport function moveHandleSymmetric(\n set: AnchorSet,\n flat: number,\n side: 'in' | 'out',\n toX: number,\n toY: number,\n breakSmoothness: boolean,\n syms: readonly AnchorSymmetry[],\n): boolean {\n const a = anchorAt(set, flat);\n if (!a || !(side === 'in' ? a.inHandle : a.outHandle)) return false;\n const sideUnder = (s: AnchorSymmetry, sd: Side): Side => (s.flips[flat] ? other(sd) : sd);\n const fixesHandle = (s: AnchorSymmetry) => s.partners[flat] === flat && sideUnder(s, side) === side;\n const to = averaged({ x: toX, y: toY }, syms, fixesHandle, image);\n\n const targets = new Map<string, { flat: number; side: Side; to: Point }>();\n const put = (f: number, sd: Side, p: Point): void => {\n const key = `${f}:${sd}`;\n if (!targets.has(key)) targets.set(key, { flat: f, side: sd, to: p });\n };\n put(flat, side, to);\n for (const s of syms) put(s.partners[flat], sideUnder(s, side), image(s.m, to));\n\n const opposite = side === 'in' ? a.outHandle : a.inHandle;\n const drivenBySymmetry = targets.has(`${flat}:${other(side)}`);\n if (!drivenBySymmetry && !breakSmoothness && opposite && isAnchorSmooth(a)) {\n const opp = { x: 2 * a.x - to.x, y: 2 * a.y - to.y };\n put(flat, other(side), opp);\n for (const s of syms) put(s.partners[flat], sideUnder(s, other(side)), image(s.m, opp));\n }\n\n for (const t of targets.values()) {\n const b = anchorAt(set, t.flat);\n if (!b) continue;\n if (t.side === 'in') b.inHandle = t.to;\n else b.outHandle = t.to;\n }\n return true;\n}\n","import type { AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\n\n/** Where on a segment a bend is held, as `segmentAt` reports it. */\nexport interface BendGrip {\n sub: number;\n segIdx: number;\n /** Curve parameter of the held point. */\n t: number;\n}\n\n/** The held point's parameter is kept this far from either end, where moving\n * it by a pixel would throw a handle out by hundreds. */\nconst T_MARGIN = 0.05;\n\n/**\n * Bend one segment so the point held at `grip.t` moves by `(dx, dy)`, by\n * moving its two control handles: each by an amount weighted toward the end it\n * belongs to, together exactly enough to carry the held point along. A straight\n * segment becomes a curve. Where an end anchor was smooth, its other handle\n * turns to stay in line, keeping its length, so the neighboring segment bends\n * with it rather than kinking.\n *\n * Returns false when the segment doesn't exist.\n */\nexport function bendSegment(set: AnchorSet, grip: BendGrip, dx: number, dy: number): boolean {\n const ends = segmentEnds(set.anchors, set.closed, grip.sub, grip.segIdx);\n if (!ends) return false;\n const { a, b } = ends;\n const aSmooth = isAnchorSmooth(a);\n const bSmooth = isAnchorSmooth(b);\n const straight = isStraightSegment(a, b);\n const p1 = a.outHandle ?? (straight ? lerp(a, b, 1 / 3) : { x: a.x, y: a.y });\n const p2 = b.inHandle ?? (straight ? lerp(a, b, 2 / 3) : { x: b.x, y: b.y });\n\n const t = Math.min(1 - T_MARGIN, Math.max(T_MARGIN, grip.t));\n const u = 1 - t;\n // Moving p1 by w1·d and p2 by w2·d moves the point at t by\n // (3u²t·w1 + 3ut²·w2)·d. With w1 = k·u and w2 = k·t, this k makes it exactly d.\n const k = 1 / (3 * t * u * (u * u + t * t));\n a.outHandle = { x: p1.x + k * u * dx, y: p1.y + k * u * dy };\n b.inHandle = { x: p2.x + k * t * dx, y: p2.y + k * t * dy };\n\n if (aSmooth) a.inHandle = alignedOpposite(a, a.outHandle, a.inHandle!);\n if (bSmooth) b.outHandle = alignedOpposite(b, b.inHandle, b.outHandle!);\n return true;\n}\n\nfunction lerp(a: PenAnchor, b: PenAnchor, f: number): { x: number; y: number } {\n return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };\n}\n\n/** `other` turned to point directly away from `moved` through the anchor, at\n * its own length. */\nfunction alignedOpposite(\n anchor: PenAnchor,\n moved: { x: number; y: number },\n other: { x: number; y: number },\n): { x: number; y: number } {\n const mx = moved.x - anchor.x;\n const my = moved.y - anchor.y;\n const len = Math.hypot(mx, my);\n if (len === 0) return other;\n const keep = Math.hypot(other.x - anchor.x, other.y - anchor.y);\n return { x: anchor.x - (mx / len) * keep, y: anchor.y - (my / len) * keep };\n}\n","/**\n * `smudgePath` — one dab of a smudge brush: the outline under a round brush\n * moved along the brush's motion, most at its center and not at all at its rim.\n */\nimport type { PolygonPath } from '../path';\nimport { editAnchorSet, insertAnchorOnSegment, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport { segmentEnds, type PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\n/** Options for {@link smudgePath}. */\nexport interface SmudgePathOptions {\n /** The brush's center before this dab's motion. */\n center: Point;\n /** How far the brush moved. */\n delta: Point;\n /** The brush's radius, in the path's units. */\n radius: number;\n /** How much of `delta` a point under the brush's center moves: `1` all of it. Default 1. */\n strength?: number;\n /**\n * The longest a segment under the brush may be before an anchor is added at its\n * middle, in the path's units, so the brush has points to move where it needs\n * them. Default a third of `radius`; `Infinity` adds none.\n */\n detail?: number;\n}\n\n/** Samples along a segment when deciding whether it passes under the brush. */\nconst PROBES = 12;\n/** Most anchors a single dab may add. */\nconst MAX_ADDED = 512;\n\n/**\n * `path` with the outline under the brush pushed along `delta`. A point at distance\n * `d` from `center` moves by `delta × strength × (1 − (d/radius)²)²`, and an anchor's\n * handles move with it, so a smooth anchor stays smooth. First, every segment that\n * passes under the brush and is longer than `detail` is split at its middle until it\n * is not, so a long straight edge bends where the brush meets it. Returns `path`\n * itself when nothing is under the brush.\n */\nexport function smudgePath(path: PolygonPath, opts: SmudgePathOptions): PolygonPath {\n const { center, delta, radius } = opts;\n const strength = opts.strength ?? 1;\n if (!(radius > 0) || strength === 0 || (delta.x === 0 && delta.y === 0)) return path;\n const detail = opts.detail ?? radius / 3;\n return editAnchorSet(path, (set) => {\n refine(set, center, radius, detail);\n let touched = false;\n let flat = 0;\n for (const sub of set.anchors) {\n for (const a of sub) {\n const w = weight(a, center, radius) * strength;\n if (w !== 0) {\n touched = true;\n translateAnchorBy(set, flat, delta.x * w, delta.y * w);\n }\n flat++;\n }\n }\n return touched;\n }) ?? path;\n}\n\n/** The brush's falloff at `p`: 1 at its center, 0 at its rim and beyond. */\nfunction weight(p: Point, c: Point, radius: number): number {\n const u2 = ((p.x - c.x) ** 2 + (p.y - c.y) ** 2) / (radius * radius);\n return u2 >= 1 ? 0 : (1 - u2) ** 2;\n}\n\n/** Split the segments under the brush at their middles until none is longer than\n * `detail`, adding at most {@link MAX_ADDED} anchors. */\nfunction refine(set: AnchorSet, c: Point, radius: number, detail: number): void {\n if (!Number.isFinite(detail) || detail <= 0) return;\n let added = 0;\n for (let sub = 0; sub < set.anchors.length; sub++) {\n // Back to front, so a split does not shift the segments still to visit; a\n // split segment's first half is visited again at the same index.\n for (let seg = set.anchors[sub].length - 1; seg >= 0 && added < MAX_ADDED; seg--) {\n const ends = segmentEnds(set.anchors, set.closed, sub, seg);\n if (!ends || controlLength(ends.a, ends.b) <= detail || !underBrush(ends.a, ends.b, c, radius)) continue;\n insertAnchorOnSegment(set, { sub, segIdx: seg, t: 0.5 });\n added++;\n seg += 2;\n }\n }\n}\n\nconst controls = (a: PenAnchor, b: PenAnchor): [Point, Point, Point, Point] =>\n [a, a.outHandle ?? a, b.inHandle ?? b, b];\n\n/** The length of the segment's control polygon, which is never shorter than the segment. */\nfunction controlLength(a: PenAnchor, b: PenAnchor): number {\n const [p0, p1, p2, p3] = controls(a, b);\n return Math.hypot(p1.x - p0.x, p1.y - p0.y) + Math.hypot(p2.x - p1.x, p2.y - p1.y)\n + Math.hypot(p3.x - p2.x, p3.y - p2.y);\n}\n\n/** Whether any of the segment from `a` to `b` lies under the brush. */\nfunction underBrush(a: PenAnchor, b: PenAnchor, c: Point, radius: number): boolean {\n const [p0, p1, p2, p3] = controls(a, b);\n for (let k = 0; k <= PROBES; k++) {\n const p = cubicPointAt(p0, p1, p2, p3, k / PROBES);\n if ((p.x - c.x) ** 2 + (p.y - c.y) ** 2 < radius * radius) return true;\n }\n return false;\n}\n","import { anchorAt, locateAnchor, type AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\nimport type { Point } from './cubicMath';\n\n/**\n * Collapse the handles of the anchors at `flatIndexes` onto their anchors,\n * leaving sharp corners. A segment whose ends both lose their handles turns\n * straight.\n *\n * Returns false when every handle was already on its anchor. A segment that\n * stays curved because its far end keeps a handle still encodes a control at\n * this end, so it decodes as a handle sitting on the anchor: retracted.\n */\nexport function retractHandles(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const a = anchorAt(set, flat);\n if (!a) continue;\n if (a.inHandle) { changed = changed || !same(a.inHandle, a); delete a.inHandle; }\n if (a.outHandle) { changed = changed || !same(a.outHandle, a); delete a.outHandle; }\n }\n return changed;\n}\n\n/**\n * Give each anchor at `flatIndexes` two handles of equal length pointing in\n * opposite directions, so the curve passes through it smoothly. The shared\n * direction splits the difference between the two handles' own directions,\n * and the shared length is their mean; an anchor with one handle mirrors it.\n *\n * Skipped: an anchor with no handles, and the ends of an open subpath, which\n * have only one segment to shape. Returns false when nothing changed.\n */\nexport function makeHandlesSymmetric(set: AnchorSet, flatIndexes: Iterable<number>): boolean {\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const sub = set.anchors[loc.sub];\n const isEnd = !set.closed[loc.sub] && (loc.idx === 0 || loc.idx === sub.length - 1);\n if (isEnd) continue;\n changed = symmetrize(sub[loc.idx]) || changed;\n }\n return changed;\n}\n\nfunction symmetrize(a: PenAnchor): boolean {\n const out = a.outHandle ? offset(a, a.outHandle) : null;\n // The in-handle turned around, so both vectors point along the outgoing side.\n const inFlipped = a.inHandle ? scale(offset(a, a.inHandle), -1) : null;\n const outLen = out ? Math.hypot(out.x, out.y) : 0;\n const inLen = inFlipped ? Math.hypot(inFlipped.x, inFlipped.y) : 0;\n if (outLen === 0 && inLen === 0) return false;\n\n let dir: Point;\n let len: number;\n if (outLen > 0 && inLen > 0) {\n const sum = { x: out!.x / outLen + inFlipped!.x / inLen, y: out!.y / outLen + inFlipped!.y / inLen };\n const sumLen = Math.hypot(sum.x, sum.y);\n // Handles pointing the same way leave no bisector; keep the out-handle's line.\n dir = sumLen > 1e-9 ? scale(sum, 1 / sumLen) : scale(out!, 1 / outLen);\n len = (outLen + inLen) / 2;\n } else if (outLen > 0) {\n dir = scale(out!, 1 / outLen);\n len = outLen;\n } else {\n dir = scale(inFlipped!, 1 / inLen);\n len = inLen;\n }\n const nextOut = { x: a.x + dir.x * len, y: a.y + dir.y * len };\n const nextIn = { x: a.x - dir.x * len, y: a.y - dir.y * len };\n if (same(a.outHandle, nextOut) && same(a.inHandle, nextIn)) return false;\n a.outHandle = nextOut;\n a.inHandle = nextIn;\n return true;\n}\n\n/**\n * Where a handle lands when dragged toward `to` but held to its current\n * direction from `anchor`: `to` projected onto that ray. The length never\n * goes below zero, so the handle can shrink onto the anchor but not flip\n * through it. A handle already sitting on its anchor has no direction to\n * keep and follows `to` freely.\n */\nexport function handleAlongItsAngle(anchor: Point, handle: Point, to: Point): Point {\n const d = offset(anchor, handle);\n const len = Math.hypot(d.x, d.y);\n if (len === 0) return { x: to.x, y: to.y };\n const ux = d.x / len;\n const uy = d.y / len;\n const along = Math.max(0, (to.x - anchor.x) * ux + (to.y - anchor.y) * uy);\n return { x: anchor.x + ux * along, y: anchor.y + uy * along };\n}\n\n/**\n * Where a handle lands when dragged toward `to` but held to its current\n * length from `anchor`: on the circle of that length, aimed at `to`. A `to`\n * on the anchor itself gives no direction, and leaves the handle where it is.\n */\nexport function handleAtItsLength(anchor: Point, handle: Point, to: Point): Point {\n const len = Math.hypot(handle.x - anchor.x, handle.y - anchor.y);\n const d = offset(anchor, to);\n const dl = Math.hypot(d.x, d.y);\n if (dl === 0) return { x: handle.x, y: handle.y };\n return { x: anchor.x + (d.x / dl) * len, y: anchor.y + (d.y / dl) * len };\n}\n\nfunction offset(from: Point, to: Point): Point {\n return { x: to.x - from.x, y: to.y - from.y };\n}\n\nfunction scale(p: Point, k: number): Point {\n return { x: p.x * k, y: p.y * k };\n}\n\nfunction same(p: Point | undefined, q: Point): boolean {\n return !!p && Math.abs(p.x - q.x) < 1e-9 && Math.abs(p.y - q.y) < 1e-9;\n}\n","/**\n * Soft selection over an anchor set: how strongly an edit to some anchors\n * carries to the anchors near them, by distance measured along the path.\n *\n * Distance is arc length along the drawn curve, not a straight line, so two\n * anchors that sit close across a gap in a shape are as far apart as the\n * path between them. A `scale` measures it in screen pixels under a view's\n * zoom, per axis.\n */\nimport type { AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\nimport { cubicPointAt, type Point } from './cubicMath';\n\n/** How influence fades from 1 at a selected anchor to 0 at the radius:\n * `smooth` eases out and in, `linear` falls evenly, `sharp` drops fast and\n * tails off. */\nexport type SoftFalloff = 'smooth' | 'linear' | 'sharp';\n\n/**\n * The weight `falloff` gives a point `distance` from the selection, for a\n * radius of `radius`: 1 at distance 0, 0 at the radius and beyond.\n */\nexport function softFalloff(falloff: SoftFalloff, distance: number, radius: number): number {\n if (!(radius > 0) || distance >= radius) return 0;\n if (distance <= 0) return 1;\n const u = distance / radius;\n switch (falloff) {\n case 'linear': return 1 - u;\n case 'sharp': return (1 - u) * (1 - u);\n case 'smooth': return 0.5 + 0.5 * Math.cos(Math.PI * u);\n }\n}\n\n/** Arc length along one segment, sampled at evenly spaced curve parameters. */\nexport interface SegmentMeasure {\n /** Arc length from the subpath's start to each sample; sample `i` is at\n * parameter `i / (lengths.length - 1)`. */\n lengths: Float64Array;\n}\n\n/** Arc lengths along one subpath, as {@link measureAnchorPath} takes them. */\nexport interface AnchorSubpathMeasure {\n closed: boolean;\n /** Flat index of the subpath's first anchor. */\n first: number;\n /** Arc length from the subpath's start to each anchor. */\n at: Float64Array;\n /** Total length, the closing segment included on a closed subpath. */\n length: number;\n /** Segment `i` runs from anchor `i` to anchor `i + 1`, wrapping on a closed subpath. */\n segments: SegmentMeasure[];\n}\n\n/** Arc lengths along every subpath of an anchor set, as\n * {@link measureAnchorPath} takes them. Read it with\n * {@link softSelectionWeights} and {@link softSelectionBand}. */\nexport interface AnchorPathMeasure {\n readonly subpaths: readonly AnchorSubpathMeasure[];\n}\n\n/** Options for {@link measureAnchorPath}. */\nexport interface MeasureAnchorPathOptions {\n /** Per-axis factor applied before measuring — a view's scale, to measure in\n * screen pixels. Default 1 on both axes. */\n scale?: { x: number; y: number };\n /** Samples taken along each curved segment. Default 24. */\n samples?: number;\n}\n\n/** The control points of segment `i` of `sub`, or null past its last segment. */\nfunction segmentControls(sub: readonly PenAnchor[], closed: boolean, i: number): [Point, Point, Point, Point] | null {\n const n = sub.length;\n if (i >= n - 1 && !(closed && i === n - 1)) return null;\n const a = sub[i]!;\n const b = sub[(i + 1) % n]!;\n return [a, a.outHandle ?? a, b.inHandle ?? b, b];\n}\n\nfunction isStraight(c: readonly Point[]): boolean {\n return c[1] === c[0] && c[2] === c[3];\n}\n\n/** Measure the arc length along every subpath of `set`. */\nexport function measureAnchorPath(set: AnchorSet, opts: MeasureAnchorPathOptions = {}): AnchorPathMeasure {\n const sx = opts.scale?.x ?? 1;\n const sy = opts.scale?.y ?? 1;\n const samples = Math.max(2, Math.round(opts.samples ?? 24));\n const subpaths: AnchorSubpathMeasure[] = [];\n let first = 0;\n set.anchors.forEach((sub, s) => {\n const closed = set.closed[s] ?? false;\n const at = new Float64Array(sub.length);\n const segments: SegmentMeasure[] = [];\n let run = 0;\n for (let i = 0; ; i++) {\n const c = segmentControls(sub, closed, i);\n if (!c) break;\n at[i] = run;\n const steps = isStraight(c) ? 1 : samples;\n const lengths = new Float64Array(steps + 1);\n lengths[0] = run;\n let prev = c[0];\n for (let k = 1; k <= steps; k++) {\n const p = steps === 1 ? c[3] : cubicPointAt(c[0], c[1], c[2], c[3], k / steps);\n run += Math.hypot((p.x - prev.x) * sx, (p.y - prev.y) * sy);\n lengths[k] = run;\n prev = p;\n }\n segments.push({ lengths });\n }\n // An open subpath's last anchor ends the last segment.\n if (!closed && sub.length > 0) at[sub.length - 1] = run;\n subpaths.push({ closed, first, at, length: run, segments });\n first += sub.length;\n });\n return { subpaths };\n}\n\n/** Arc lengths of the selected anchors on `sub`. */\nfunction sourcesOn(sub: AnchorSubpathMeasure, selected: ReadonlySet<number>): number[] {\n const out: number[] = [];\n for (let i = 0; i < sub.at.length; i++) if (selected.has(sub.first + i)) out.push(sub.at[i]!);\n return out;\n}\n\n/** Distance along `sub` from arc length `s` to the nearest of `sources`. */\nfunction distanceTo(sub: AnchorSubpathMeasure, sources: readonly number[], s: number): number {\n let best = Infinity;\n for (const src of sources) {\n let d = Math.abs(s - src);\n if (sub.closed) d = Math.min(d, sub.length - d);\n if (d < best) best = d;\n }\n return best;\n}\n\n/**\n * How much of an edit to the `selected` anchors each anchor receives: 1 for\n * a selected anchor, the falloff of its distance along the path for one\n * within `radius` of the nearest selected anchor on its subpath. Anchors\n * that receive nothing are absent, as are anchors on a subpath with no\n * selected anchor.\n */\nexport function softSelectionWeights(\n measure: AnchorPathMeasure,\n selected: Iterable<number>,\n radius: number,\n falloff: SoftFalloff,\n): Map<number, number> {\n const sel = new Set(selected);\n const out = new Map<number, number>();\n for (const sub of measure.subpaths) {\n const sources = sourcesOn(sub, sel);\n if (sources.length === 0) continue;\n for (let i = 0; i < sub.at.length; i++) {\n const flat = sub.first + i;\n const w = sel.has(flat) ? 1 : softFalloff(falloff, distanceTo(sub, sources, sub.at[i]!), radius);\n if (w > 0) out.set(flat, w);\n }\n }\n return out;\n}\n\n/**\n * The stretches of path within `radius` of the `selected` anchors, as world\n * polylines drawn on `set`. `measure` is of the set the distances are taken\n * on — the path as it was when the edit began — and `set` the geometry to\n * draw on, which must have the same anchors. A stretch crossing the seam of a\n * closed subpath comes back as one run.\n */\nexport function softSelectionBand(\n measure: AnchorPathMeasure,\n set: AnchorSet,\n selected: Iterable<number>,\n radius: number,\n): Point[][] {\n const sel = new Set(selected);\n const runs: Point[][] = [];\n measure.subpaths.forEach((sub, s) => {\n const sources = sourcesOn(sub, sel);\n const anchors = set.anchors[s];\n if (sources.length === 0 || !anchors) return;\n const inside = (len: number) => distanceTo(sub, sources, len) <= radius;\n const subRuns: Point[][] = [];\n let current: Point[] | null = null;\n let startsAtSeam = false;\n sub.segments.forEach((seg, i) => {\n const c = segmentControls(anchors, sub.closed, i);\n if (!c) return;\n const at = (t: number): Point => (isStraight(c) ? lerp(c[0], c[3], t) : cubicPointAt(c[0], c[1], c[2], c[3], t));\n const steps = seg.lengths.length - 1;\n for (let k = 0; k <= steps; k++) {\n const len = seg.lengths[k]!;\n const t = k / steps;\n const isIn = inside(len);\n if (k === 0 && i === 0) startsAtSeam = isIn;\n if (k > 0) {\n const prevLen = seg.lengths[k - 1]!;\n const wasIn = inside(prevLen);\n if (wasIn !== isIn) {\n // The edge sits where the distance crosses `radius`, found by bisection on arc length.\n const edge = crossing(prevLen, len, wasIn, inside);\n const te = ((k - 1) + (len === prevLen ? 0 : (edge - prevLen) / (len - prevLen))) / steps;\n const p = at(te);\n if (wasIn) {\n current?.push(p);\n if (current) subRuns.push(current);\n current = null;\n } else {\n current = [p];\n }\n }\n }\n if (isIn) {\n current ??= [];\n const p = at(t);\n const last = current[current.length - 1];\n if (!last || last.x !== p.x || last.y !== p.y) current.push(p);\n }\n }\n });\n if (current) subRuns.push(current);\n // A closed subpath's last run and first run meet at its first anchor.\n if (sub.closed && startsAtSeam && subRuns.length > 1) {\n const head = subRuns.shift()!;\n subRuns[subRuns.length - 1]!.push(...head.slice(1));\n }\n runs.push(...subRuns.filter((r) => r.length >= 2));\n });\n return runs;\n}\n\nfunction crossing(a: number, b: number, aIn: boolean, inside: (s: number) => boolean): number {\n let lo = a;\n let hi = b;\n for (let i = 0; i < 24; i++) {\n const mid = (lo + hi) / 2;\n if (inside(mid) === aIn) lo = mid;\n else hi = mid;\n }\n return (lo + hi) / 2;\n}\n\nfunction lerp(a: Point, b: Point, t: number): Point {\n return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n}\n","import { flatAnchorIndex, type AnchorSet } from './anchorEdits';\nimport { isStraightSegment, segmentEnds, type PenAnchor } from './anchors';\nimport { moveHandleSymmetric, type AnchorSymmetry } from './anchorSymmetry';\nimport type { Point } from './cubicMath';\n\n/** A curved segment's balance line: from its first handle's tip to its\n * second's, with a grip at the middle. */\nexport interface HandleBalance {\n sub: number;\n segIdx: number;\n /** Flat index of the anchor the segment starts at, which names the segment\n * the way an anchor's flat index names the anchor. */\n flat: number;\n /** Tip of the segment's first handle, the start anchor's out-handle. */\n from: Point;\n /** Tip of the segment's second handle, the end anchor's in-handle. */\n to: Point;\n /** Midway between the two tips. */\n grip: Point;\n}\n\n/**\n * The balance line of every curved segment in `set` that has both handles\n * pulled off their anchors. Dragging a line's grip scales both handles\n * together ({@link scaleSegmentHandles}), which fills the curve out toward\n * its corner or flattens it toward its chord without turning either end.\n */\nexport function handleBalances(set: AnchorSet): HandleBalance[] {\n const out: HandleBalance[] = [];\n for (let sub = 0; sub < set.anchors.length; sub++) {\n const count = set.anchors[sub].length - (set.closed[sub] ? 0 : 1);\n for (let segIdx = 0; segIdx < count; segIdx++) {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) continue;\n const { from, to } = handles;\n out.push({\n sub,\n segIdx,\n flat: flatAnchorIndex(set, sub, segIdx),\n from: { ...from },\n to: { ...to },\n grip: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 },\n });\n }\n }\n return out;\n}\n\n/** The segment's anchors and handle tips, when it is curved with both\n * handles off their anchors. */\nfunction segmentHandles(\n set: AnchorSet,\n sub: number,\n segIdx: number,\n): { a: PenAnchor; b: PenAnchor; from: Point; to: Point } | null {\n const ends = segmentEnds(set.anchors, set.closed, sub, segIdx);\n if (!ends || isStraightSegment(ends.a, ends.b)) return null;\n const { a, b } = ends;\n if (!a.outHandle || !b.inHandle) return null;\n if (length(a, a.outHandle) === 0 || length(b, b.inHandle) === 0) return null;\n return { a, b, from: a.outHandle, to: b.inHandle };\n}\n\n/**\n * Scale both handles of segment `(sub, segIdx)` by `factor`, each along its\n * own direction, so the segment keeps its end tangents. A smooth anchor at\n * either end stays smooth: its other handle points the same way as before.\n * `factor` below zero counts as zero, which retracts both handles.\n *\n * Under `syms`, as `anchorSymmetries` gives them, every image of either handle\n * moves to the image of where that handle goes, the way `moveHandleSymmetric`\n * moves a dragged handle's.\n *\n * Returns false when the segment has no balance line or nothing moved.\n */\nexport function scaleSegmentHandles(\n set: AnchorSet,\n sub: number,\n segIdx: number,\n factor: number,\n syms: readonly AnchorSymmetry[] = [],\n): boolean {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return false;\n const k = Math.max(0, factor);\n if (k === 1) return false;\n const { a, b } = handles;\n // Both targets before either write: an image of the first handle can be the second.\n const out = scaledFrom(a, a.outHandle!, k);\n const into = scaledFrom(b, b.inHandle!, k);\n const next = segIdx + 1 === set.anchors[sub].length ? 0 : segIdx + 1;\n moveHandleSymmetric(set, flatAnchorIndex(set, sub, segIdx), 'out', out.x, out.y, true, syms);\n moveHandleSymmetric(set, flatAnchorIndex(set, sub, next), 'in', into.x, into.y, true, syms);\n return true;\n}\n\n/**\n * The factor {@link scaleSegmentHandles} takes to bring segment\n * `(sub, segIdx)`'s grip as near `to` as scaling can: `to` projected onto the\n * line the grip slides along as both handles grow. 1 when the segment has no\n * balance line.\n */\nexport function balanceFactorToward(set: AnchorSet, sub: number, segIdx: number, to: Point): number {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return 1;\n const { a, b, from, to: tip } = handles;\n // grip(k) = mid + k·w, where mid is the chord's middle and w the handles'\n // mean offset; k = 1 is where the grip is now.\n const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };\n const w = { x: (from.x - a.x + tip.x - b.x) / 2, y: (from.y - a.y + tip.y - b.y) / 2 };\n const w2 = w.x * w.x + w.y * w.y;\n if (w2 < 1e-12) return 1;\n return Math.max(0, ((to.x - mid.x) * w.x + (to.y - mid.y) * w.y) / w2);\n}\n\n/**\n * Give both handles of segment `(sub, segIdx)` the same proportion: each\n * reaches the same fraction of the way from its anchor to the corner where\n * the two handle lines cross, that fraction being the mean of the two they\n * had. Where the lines don't cross ahead of both handles, both take the mean\n * length instead. Directions are kept either way.\n *\n * Returns false when the segment has no balance line or the handles already\n * match.\n */\nexport function equalizeSegmentHandles(set: AnchorSet, sub: number, segIdx: number): boolean {\n const handles = segmentHandles(set, sub, segIdx);\n if (!handles) return false;\n const { a, b, from, to } = handles;\n const lenA = length(a, from);\n const lenB = length(b, to);\n const ua = { x: (from.x - a.x) / lenA, y: (from.y - a.y) / lenA };\n const ub = { x: (to.x - b.x) / lenB, y: (to.y - b.y) / lenB };\n const corner = rayCrossing(a, ua, b, ub);\n let nextA: number;\n let nextB: number;\n if (corner) {\n const share = (lenA / corner.ta + lenB / corner.tb) / 2;\n nextA = share * corner.ta;\n nextB = share * corner.tb;\n } else {\n nextA = nextB = (lenA + lenB) / 2;\n }\n if (Math.abs(nextA - lenA) < 1e-9 && Math.abs(nextB - lenB) < 1e-9) return false;\n a.outHandle = { x: a.x + ua.x * nextA, y: a.y + ua.y * nextA };\n b.inHandle = { x: b.x + ub.x * nextB, y: b.y + ub.y * nextB };\n return true;\n}\n\n/** Where the ray from `p` along `u` meets the ray from `q` along `v`, as the\n * distance along each; null when they are parallel or meet behind either. */\nfunction rayCrossing(p: Point, u: Point, q: Point, v: Point): { ta: number; tb: number } | null {\n const den = u.x * v.y - u.y * v.x;\n if (Math.abs(den) < 1e-12) return null;\n const dx = q.x - p.x;\n const dy = q.y - p.y;\n const ta = (dx * v.y - dy * v.x) / den;\n const tb = (dx * u.y - dy * u.x) / den;\n return ta > 0 && tb > 0 ? { ta, tb } : null;\n}\n\nfunction length(a: Point, b: Point): number {\n return Math.hypot(b.x - a.x, b.y - a.y);\n}\n\nfunction scaledFrom(anchor: Point, handle: Point, k: number): Point {\n return { x: anchor.x + (handle.x - anchor.x) * k, y: anchor.y + (handle.y - anchor.y) * k };\n}\n","import { anchorCount, locateAnchor, type AnchorSet } from './anchorEdits';\nimport { isAnchorSmooth, type PenAnchor } from './anchors';\n\ntype Point = { x: number; y: number };\n\n/** Passes over the anchors before giving up on settling. Each anchor's fix\n * moves its neighbors' curvature a little, so a few passes are needed. */\nconst MAX_PASSES = 64;\n/** A pass that moves no handle further than this fraction of its length has\n * settled. */\nconst SETTLED = 1e-12;\n/** Handles that end up no further than this fraction of their length from\n * where they started count as unchanged: a path stored in single precision\n * comes back this far off the harmony it was given. */\nconst UNCHANGED = 1e-6;\n\n/**\n * Make each smooth anchor at `flatIndexes` curvature-continuous: the curve\n * bends as tightly just after the anchor as just before it, so it shows no\n * kink in its curvature there. Only handle lengths change — each handle keeps\n * its direction, so the anchor stays smooth and the tangent stays put — and\n * the product of the two lengths is kept, so the anchor's pull on the curve\n * stays about as strong.\n *\n * Absent `flatIndexes`, every anchor in the set. Moving one anchor's handles\n * changes the curvature at its neighbors, so the fixes are repeated until\n * they settle.\n *\n * Skipped, because lengths alone cannot do it: a corner, an anchor missing a\n * handle, an end of an open subpath, and an anchor the curve bends opposite\n * ways either side of, or straight through on one side.\n *\n * Returns false when nothing changed.\n */\nexport function harmonizeAnchors(set: AnchorSet, flatIndexes?: Iterable<number>): boolean {\n const targets = flatIndexes\n ? [...new Set(flatIndexes)]\n : Array.from({ length: anchorCount(set) }, (_, i) => i);\n const located = targets\n .map((flat) => locateAnchor(set, flat))\n .filter((loc): loc is { sub: number; idx: number } => loc !== null);\n const anchors = located.map(({ sub, idx }) => set.anchors[sub][idx]);\n const before = anchors.map((a) => ({ inHandle: a.inHandle, outHandle: a.outHandle }));\n for (let pass = 0; pass < MAX_PASSES; pass++) {\n let moved = 0;\n for (const { sub, idx } of located) moved = Math.max(moved, harmonizeOne(set, sub, idx));\n if (moved <= SETTLED) break;\n }\n const changed = anchors.some((a, i) =>\n movedFar(a, before[i].inHandle, a.inHandle) || movedFar(a, before[i].outHandle, a.outHandle));\n if (!changed) {\n anchors.forEach((a, i) => { a.inHandle = before[i].inHandle; a.outHandle = before[i].outHandle; });\n }\n return changed;\n}\n\nfunction movedFar(a: Point, from: Point | undefined, to: Point | undefined): boolean {\n if (!from || !to || from === to) return false;\n const len = Math.hypot(from.x - a.x, from.y - a.y);\n return Math.hypot(to.x - from.x, to.y - from.y) > UNCHANGED * Math.max(len, 1e-9);\n}\n\n/** Harmonize one anchor; returns how far its handles moved, relative to\n * their lengths. */\nfunction harmonizeOne(set: AnchorSet, sub: number, idx: number): number {\n const anchors = set.anchors[sub];\n const closed = set.closed[sub];\n const n = anchors.length;\n if (!closed && (idx === 0 || idx === n - 1)) return 0;\n if (n < 2) return 0;\n const a = anchors[idx];\n if (!isAnchorSmooth(a)) return 0;\n const prev = anchors[(idx - 1 + n) % n];\n const next = anchors[(idx + 1) % n];\n\n const hIn = Math.hypot(a.inHandle!.x - a.x, a.inHandle!.y - a.y);\n const hOut = Math.hypot(a.outHandle!.x - a.x, a.outHandle!.y - a.y);\n const u = { x: (a.outHandle!.x - a.x) / hOut, y: (a.outHandle!.y - a.y) / hOut };\n\n // Curvature at the anchor is 2/3 · d / h², where h is the handle's length\n // and d how far the far control of that segment sits off the tangent line.\n const dIn = offTangent(a, u, prev.outHandle ?? prev);\n const dOut = offTangent(a, u, next.inHandle ?? next);\n if (dIn === 0 || dOut === 0 || Math.sign(dIn) !== Math.sign(dOut)) return 0;\n\n const ratio = Math.sqrt(dIn / dOut);\n const product = hIn * hOut;\n const nextIn = Math.sqrt(product * ratio);\n const nextOut = Math.sqrt(product / ratio);\n const moved = Math.max(Math.abs(nextIn - hIn) / hIn, Math.abs(nextOut - hOut) / hOut);\n if (moved <= SETTLED) return 0;\n a.inHandle = along(a, u, -nextIn);\n a.outHandle = along(a, u, nextOut);\n return moved;\n}\n\n/** Signed distance of `p` from the line through `a` along unit `u`. */\nfunction offTangent(a: PenAnchor, u: Point, p: Point): number {\n const d = u.x * (p.y - a.y) - u.y * (p.x - a.x);\n return Math.abs(d) < 1e-12 ? 0 : d;\n}\n\nfunction along(a: PenAnchor, u: Point, len: number): Point {\n return { x: a.x + u.x * len, y: a.y + u.y * len };\n}\n","/**\n * Arrays kept per anchor of a path — vertex colors, stroke widths — carried through an edit\n * that `editAnchorSetTracked` reported.\n */\n\nimport { PATH_C, PATH_Q, PATH_Z, forEachSegment } from '../commands';\nimport type { PolygonPath } from '../path';\nimport type { PointOrigin } from './anchorOrigins';\n\n/** For each point of `path`, the index of the anchor it ends, as `countPathAnchors` counts\n * them (one per M, L, C and Q), or -1 for a control point. */\nfunction anchorOfPoint(path: PolygonPath): Int32Array {\n const owner = new Int32Array(path.coords.length >> 1).fill(-1);\n let anchor = 0;\n forEachSegment(path.commands, path.coords, (cmd, ci) => {\n if (cmd === PATH_Z) return;\n const n = cmd === PATH_C ? 6 : cmd === PATH_Q ? 4 : 2;\n owner[(ci + n - 2) >> 1] = anchor++;\n });\n return owner;\n}\n\n/**\n * Where each anchor of `after` came from, in anchors of `before` as `countPathAnchors` counts\n * them, given the point `origins` `editAnchorSetTracked` answered for the edit: anchor `a`, or\n * for an anchor the edit made, a blend `t` of the way from `a` to `b`. `reversed` marks an\n * anchor whose subpath now runs the other way through it. Null for an anchor with no origin.\n */\nexport function anchorOriginsOf(\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): (PointOrigin | null)[] {\n const wasAnchor = anchorOfPoint(before);\n const out: (PointOrigin | null)[] = [];\n anchorOfPoint(after).forEach((anchor, point) => {\n if (anchor === -1) return;\n const o = origins[point];\n const a = o ? wasAnchor[o.a] ?? -1 : -1;\n if (!o || a === -1) {\n out.push(null);\n return;\n }\n const b = wasAnchor[o.b] ?? -1;\n out.push({ a, b: b === -1 ? a : b, t: b === -1 ? 0 : o.t, ...(o.reversed ? { reversed: true as const } : {}) });\n });\n return out;\n}\n\n/**\n * An array kept per anchor of a path, `stride` numbers each — four color channels, say —\n * carried through an edit from `before` to `after`, with `origins` as\n * `editAnchorSetTracked` answered. An anchor the edit kept keeps its numbers; one it\n * made blends those of the anchors it came between. An anchor with no origin reads 0. Anchors\n * are counted as `countPathAnchors` counts them.\n */\nexport function remapAnchorValues(\n values: ArrayLike<number>,\n stride: number,\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): number[] {\n const out: number[] = [];\n for (const o of anchorOriginsOf(before, after, origins)) {\n for (let k = 0; k < stride; k++) {\n const va = o ? values[o.a * stride + k] ?? 0 : 0;\n const vb = o ? values[o.b * stride + k] ?? 0 : 0;\n out.push(o && o.t !== 0 ? va + (vb - va) * o.t : va);\n }\n }\n return out;\n}\n","/**\n * Geometric constraints on a path's anchors. Each names anchors by flat index,\n * the walk-order numbering `enumerateAnchors` and `anchorAt` use, and is plain\n * JSON, so a list of them can be kept in scene data and saved with it.\n */\n\n/** Two anchors by flat index: the straight line from the first to the second. */\nexport type AnchorPair = readonly [number, number];\n\n/**\n * One constraint. `fixed` holds an anchor where it was before an edit, so it\n * moves with its node but not with any edit of the path. `horizontal` and\n * `vertical` read the axes of the frame the solve is given; `length` is in\n * the path's own units. `tangent` keeps an anchor's two handles on one line\n * through it, pointing apart (G1 continuity), their lengths free; it needs\n * both handles. `onPath` holds an anchor on the path's segment from\n * `segment[0]` to `segment[1]`, anywhere along it.\n */\nexport type PathConstraint =\n | { readonly kind: 'fixed' | 'tangent'; readonly anchor: number }\n | { readonly kind: 'horizontal' | 'vertical'; readonly segment: AnchorPair }\n | {\n readonly kind: 'parallel' | 'perpendicular' | 'equalLength';\n readonly segments: readonly [AnchorPair, AnchorPair];\n }\n | { readonly kind: 'length'; readonly segment: AnchorPair; readonly length: number }\n | { readonly kind: 'coincident'; readonly anchors: AnchorPair }\n | { readonly kind: 'onPath'; readonly anchor: number; readonly segment: AnchorPair };\n\n/** Every kind of {@link PathConstraint}. */\nexport type PathConstraintKind = PathConstraint['kind'];\n\n/** The anchors `c` reads, in the order it names them; an anchor named twice is listed twice. */\nexport function constraintAnchors(c: PathConstraint): number[] {\n switch (c.kind) {\n case 'fixed':\n case 'tangent': return [c.anchor];\n case 'horizontal':\n case 'vertical':\n case 'length': return [...c.segment];\n case 'coincident': return [...c.anchors];\n case 'onPath': return [c.anchor, ...c.segment];\n default: return [...c.segments[0], ...c.segments[1]];\n }\n}\n\n/**\n * `c` with every anchor index passed through `to`, or null when `to` answers\n * `undefined` for any of them — the anchor is gone, and so is the constraint.\n */\nexport function mapConstraintAnchors(\n c: PathConstraint,\n to: (anchor: number) => number | undefined,\n): PathConstraint | null {\n const pair = (p: AnchorPair): AnchorPair | null => {\n const a = to(p[0]);\n const b = to(p[1]);\n return a === undefined || b === undefined ? null : [a, b];\n };\n switch (c.kind) {\n case 'fixed':\n case 'tangent': {\n const anchor = to(c.anchor);\n return anchor === undefined ? null : { kind: c.kind, anchor };\n }\n case 'horizontal':\n case 'vertical': {\n const segment = pair(c.segment);\n return segment && { kind: c.kind, segment };\n }\n case 'length': {\n const segment = pair(c.segment);\n return segment && { kind: 'length', segment, length: c.length };\n }\n case 'coincident': {\n const anchors = pair(c.anchors);\n return anchors && { kind: 'coincident', anchors };\n }\n case 'onPath': {\n const anchor = to(c.anchor);\n const segment = pair(c.segment);\n return anchor === undefined || !segment ? null : { kind: 'onPath', anchor, segment };\n }\n default: {\n const first = pair(c.segments[0]);\n const second = pair(c.segments[1]);\n return first && second && { kind: c.kind, segments: [first, second] };\n }\n }\n}\n\n/** Whether every anchor `c` names is an index below `count`. */\nexport function constraintFits(c: PathConstraint, count: number): boolean {\n return constraintAnchors(c).every((i) => Number.isInteger(i) && i >= 0 && i < count);\n}\n","/**\n * Each constraint as residual rows: numbers that are all zero exactly when it\n * holds. Every row is in the path's units, so one tolerance reads them all.\n * Each row's derivatives are analytic, handed out one nonzero at a time.\n */\n\nimport { nearestOnCubic } from '../nearest';\nimport type { AnchorPair, PathConstraint } from './types';\n\n/** The axes `horizontal` and `vertical` read: the x axis is `(cos, sin)`. */\nexport interface ConstraintFrame {\n cos: number;\n sin: number;\n}\n\n/** The frame turned `angle` radians from the world's axes. */\nexport function frameAt(angle = 0): ConstraintFrame {\n return { cos: Math.cos(angle), sin: Math.sin(angle) };\n}\n\n/**\n * Where a solve keeps its coordinates. `x` holds every anchor's position,\n * interleaved, then every anchor's in and out handle as offsets from it, so a\n * handle rides with its anchor and a constraint on handles reads only them.\n */\nexport interface ResidualSpace {\n frame: ConstraintFrame;\n /** Anchors. */\n count: number;\n}\n\n/** Where anchor `i`'s in handle offset starts in a space of `count` anchors; its out handle follows. */\nexport const handleAt = (count: number, i: number): number => 2 * count + 4 * i;\n\n/** Coordinates a space of `count` anchors holds. */\nexport const spaceSize = (count: number): number => 6 * count;\n\n/** Takes one derivative: of residual row `row` (counted from the constraint's first) by coordinate `v`. */\nexport type Grad = (row: number, v: number, d: number) => void;\n\n/** How many residual rows `c` writes. */\nexport function residualRows(c: PathConstraint): number {\n return c.kind === 'coincident' || c.kind === 'onPath' ? 2 : c.kind === 'fixed' ? 0 : 1;\n}\n\n/** The cubic from anchor `a` to anchor `b` of `x`, by `a`'s out handle and `b`'s in handle: [x0, y0, … x3, y3]. */\nfunction segmentCubic(x: ArrayLike<number>, count: number, [a, b]: AnchorPair): number[] {\n const out = handleAt(count, a) + 2;\n const inn = handleAt(count, b);\n return [\n x[2 * a], x[2 * a + 1],\n x[2 * a] + x[out], x[2 * a + 1] + x[out + 1],\n x[2 * b] + x[inn], x[2 * b + 1] + x[inn + 1],\n x[2 * b], x[2 * b + 1],\n ];\n}\n\n/** The parameter of the point on `c`'s segment nearest its anchor, in `x`. */\nexport function nearestParam(c: PathConstraint & { kind: 'onPath' }, x: ArrayLike<number>, count: number): number {\n const q = segmentCubic(x, count, c.segment);\n return nearestOnCubic(x[2 * c.anchor], x[2 * c.anchor + 1], q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]).t;\n}\n\n/** The anchor less the point at parameter `x[param]` on the segment, as two rows. */\nfunction onPathRows(\n c: PathConstraint & { kind: 'onPath' },\n x: ArrayLike<number>,\n count: number,\n out: Float64Array,\n at: number,\n grad: Grad | undefined,\n param: number,\n): void {\n const t = x[param];\n const s = 1 - t;\n const q = segmentCubic(x, count, c.segment);\n const w = [s * s * s, 3 * s * s * t, 3 * s * t * t, t * t * t];\n for (let k = 0; k < 2; k++) {\n out[at + k] = x[2 * c.anchor + k] - (w[0] * q[k] + w[1] * q[2 + k] + w[2] * q[4 + k] + w[3] * q[6 + k]);\n }\n if (!grad) return;\n const [a, b] = c.segment;\n for (let k = 0; k < 2; k++) {\n grad(k, 2 * c.anchor + k, 1);\n grad(k, 2 * a + k, -(w[0] + w[1]));\n grad(k, 2 * b + k, -(w[2] + w[3]));\n grad(k, handleAt(count, a) + 2 + k, -w[1]);\n grad(k, handleAt(count, b) + k, -w[2]);\n grad(k, param, -(3 * s * s * (q[2 + k] - q[k]) + 6 * s * t * (q[4 + k] - q[2 + k]) + 3 * t * t * (q[6 + k] - q[4 + k])));\n }\n}\n\n/**\n * The angle between anchor `i`'s in handle and its out handle turned round,\n * times the geometric mean of their lengths: zero exactly when they point\n * apart along one line. Zero when either has no length.\n */\nfunction tangentRow(x: ArrayLike<number>, count: number, i: number, grad: Grad | undefined): number {\n const h = handleAt(count, i);\n const px = x[h];\n const py = x[h + 1];\n const qx = x[h + 2];\n const qy = x[h + 3];\n const pp = px * px + py * py;\n const qq = qx * qx + qy * qy;\n const scale = Math.sqrt(Math.sqrt(pp) * Math.sqrt(qq));\n if (scale < 1e-9) return 0;\n const theta = Math.atan2(-(px * qy - py * qx), -(px * qx + py * qy));\n if (grad) {\n // r = θ L: ∂θ/∂p = (py, -px) / |p|², ∂θ/∂q = (-qy, qx) / |q|², ∂L = (L / 2) (p / |p|², q / |q|²).\n const k = theta / 2;\n grad(0, h, scale * (py / pp + (k * px) / pp));\n grad(0, h + 1, scale * (-px / pp + (k * py) / pp));\n grad(0, h + 2, scale * (-qy / qq + (k * qx) / qq));\n grad(0, h + 3, scale * (qx / qq + (k * qy) / qq));\n }\n return theta * scale;\n}\n\nconst dx = (x: ArrayLike<number>, [a, b]: AnchorPair) => x[2 * b] - x[2 * a];\nconst dy = (x: ArrayLike<number>, [a, b]: AnchorPair) => x[2 * b + 1] - x[2 * a + 1];\n\n/** `d` times the derivative of segment `s`'s vector by its own `(gx, gy)`, spread onto its two ends. */\nfunction segmentGrad(grad: Grad, row: number, [a, b]: AnchorPair, gx: number, gy: number): void {\n grad(row, 2 * b, gx);\n grad(row, 2 * b + 1, gy);\n grad(row, 2 * a, -gx);\n grad(row, 2 * a + 1, -gy);\n}\n\nfunction lengthOf(x: ArrayLike<number>, s: AnchorPair, grad: Grad | undefined, row: number, sign: number): number {\n const ux = dx(x, s);\n const uy = dy(x, s);\n const len = Math.hypot(ux, uy);\n if (grad && len > 1e-12) segmentGrad(grad, row, s, (sign * ux) / len, (sign * uy) / len);\n return len;\n}\n\n/**\n * The cross (`parallel`) or dot (`perpendicular`) product of two segments,\n * over the geometric mean of their lengths: the sine or cosine of the angle\n * between them, times a length. Zero when either segment has no length,\n * which leaves the angle undefined rather than wrong.\n */\nfunction angleRow(\n x: ArrayLike<number>,\n s: readonly [AnchorPair, AnchorPair],\n cross: boolean,\n grad: Grad | undefined,\n row: number,\n): number {\n const ux = dx(x, s[0]);\n const uy = dy(x, s[0]);\n const vx = dx(x, s[1]);\n const vy = dy(x, s[1]);\n const uu = ux * ux + uy * uy;\n const vv = vx * vx + vy * vy;\n const scale = Math.sqrt(Math.sqrt(uu) * Math.sqrt(vv));\n if (scale < 1e-9) return 0;\n const g = cross ? ux * vy - uy * vx : ux * vx + uy * vy;\n const f = g / scale;\n if (grad) {\n // f = g / S with S = sqrt(|u| |v|): ∂f = ∂g / S - (f / 2) (u / |u|² + v / |v|²).\n const [gux, guy, gvx, gvy] = cross ? [vy, -vx, -uy, ux] : [vx, vy, ux, uy];\n segmentGrad(grad, row, s[0], gux / scale - (f / 2) * (ux / uu), guy / scale - (f / 2) * (uy / uu));\n segmentGrad(grad, row, s[1], gvx / scale - (f / 2) * (vx / vv), gvy / scale - (f / 2) * (vy / vv));\n }\n return f;\n}\n\n/**\n * Write `c`'s residual rows for coordinates `x`, laid out as `space` says, into\n * `out` at `at`, and hand each nonzero derivative to `grad` when given. An\n * `onPath` constraint reads its parameter from `x[param]`.\n */\nexport function writeResiduals(\n c: PathConstraint,\n x: ArrayLike<number>,\n space: ResidualSpace,\n out: Float64Array,\n at: number,\n grad?: Grad,\n param = -1,\n): void {\n const { frame } = space;\n switch (c.kind) {\n case 'fixed': return;\n case 'onPath':\n onPathRows(c, x, space.count, out, at, grad, param);\n return;\n case 'tangent':\n out[at] = tangentRow(x, space.count, c.anchor, grad);\n return;\n case 'horizontal':\n out[at] = -frame.sin * dx(x, c.segment) + frame.cos * dy(x, c.segment);\n if (grad) segmentGrad(grad, 0, c.segment, -frame.sin, frame.cos);\n return;\n case 'vertical':\n out[at] = frame.cos * dx(x, c.segment) + frame.sin * dy(x, c.segment);\n if (grad) segmentGrad(grad, 0, c.segment, frame.cos, frame.sin);\n return;\n case 'length':\n out[at] = lengthOf(x, c.segment, grad, 0, 1) - c.length;\n return;\n case 'coincident':\n out[at] = dx(x, c.anchors);\n out[at + 1] = dy(x, c.anchors);\n if (grad) {\n segmentGrad(grad, 0, c.anchors, 1, 0);\n segmentGrad(grad, 1, c.anchors, 0, 1);\n }\n return;\n case 'equalLength':\n out[at] = lengthOf(x, c.segments[0], grad, 0, 1) - lengthOf(x, c.segments[1], grad, 0, -1);\n return;\n case 'parallel':\n out[at] = angleRow(x, c.segments, true, grad, 0);\n return;\n case 'perpendicular':\n out[at] = angleRow(x, c.segments, false, grad, 0);\n }\n}\n","/**\n * The points a constraint solve reads, and the coordinate vector it works in:\n * anchors, then each anchor's handles as offsets from it (see `ResidualSpace`).\n */\n\nimport { handleAt, spaceSize } from './residuals';\nimport { constraintFits, type PathConstraint } from './types';\n\n/** An anchor the solver reads and writes, with its handles where it has them. */\nexport interface ConstraintPoint {\n x: number;\n y: number;\n inHandle?: { x: number; y: number };\n outHandle?: { x: number; y: number };\n}\n\n/** One handle of an anchor. */\nexport interface HandleRef {\n anchor: number;\n side: 'in' | 'out';\n}\n\n/**\n * Whether `c` can be solved over `points`: every anchor it names exists, and\n * a `tangent` anchor has both handles.\n */\nexport function constraintApplies(c: PathConstraint, points: readonly ConstraintPoint[]): boolean {\n if (!constraintFits(c, points.length)) return false;\n if (c.kind !== 'tangent') return true;\n const a = points[c.anchor];\n return !!a.inHandle && !!a.outHandle;\n}\n\n/** `points` as a coordinate vector, each anchor at `at(i)` — its reference, say — and its handles riding with it. */\nexport function pack(points: readonly ConstraintPoint[], at: (i: number) => ConstraintPoint = (i) => points[i]): Float64Array {\n const n = points.length;\n const x = new Float64Array(spaceSize(n));\n points.forEach((p, i) => {\n const place = at(i);\n x[2 * i] = place.x;\n x[2 * i + 1] = place.y;\n const h = handleAt(n, i);\n if (p.inHandle) {\n x[h] = p.inHandle.x - p.x;\n x[h + 1] = p.inHandle.y - p.y;\n }\n if (p.outHandle) {\n x[h + 2] = p.outHandle.x - p.x;\n x[h + 3] = p.outHandle.y - p.y;\n }\n });\n return x;\n}\n\n/** The points `x` holds, each with the handles its counterpart in `like` has. */\nexport function unpack(x: Float64Array, like: readonly ConstraintPoint[]): ConstraintPoint[] {\n const n = like.length;\n return like.map((p, i) => {\n const out: ConstraintPoint = { x: x[2 * i], y: x[2 * i + 1] };\n const h = handleAt(n, i);\n if (p.inHandle) out.inHandle = { x: out.x + x[h], y: out.y + x[h + 1] };\n if (p.outHandle) out.outHandle = { x: out.x + x[h + 2], y: out.y + x[h + 3] };\n return out;\n });\n}\n","/**\n * Whether constraints hold for a set of points, and whether a solve made them\n * hold only by collapsing what they measure.\n */\n\nimport { constraintApplies, pack, type ConstraintPoint } from './points';\nimport { frameAt, nearestParam, residualRows, writeResiduals } from './residuals';\nimport type { AnchorPair, PathConstraint } from './types';\n\n/** The residual, in the path's units, under which a constraint counts as holding. */\nexport const CONSTRAINT_TOLERANCE = 1e-3;\n\n/** The anchor pairs `c` measures as segments. */\nfunction segmentsOf(c: PathConstraint): AnchorPair[] {\n switch (c.kind) {\n case 'fixed':\n case 'tangent':\n case 'coincident': return [];\n case 'horizontal':\n case 'vertical':\n case 'onPath':\n case 'length': return [c.segment];\n default: return [...c.segments];\n }\n}\n\nconst handleLength = (p: ConstraintPoint, h: { x: number; y: number } | undefined) =>\n (h ? Math.hypot(h.x - p.x, h.y - p.y) : 0);\n\n/**\n * Constraints the solve satisfied only by shrinking what they measure to a\n * point — horizontal and vertical on one segment both hold once its ends\n * meet, and a tangent holds once a handle has no length. That is a conflict,\n * not a solution. A pair a constraint means to join, by `coincident` or a\n * zero `length`, is exempt.\n */\nexport function collapsedBy(\n from: readonly ConstraintPoint[],\n to: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n skipped: ReadonlySet<number>,\n): number[] {\n const key = ([a, b]: AnchorPair) => (a < b ? `${a},${b}` : `${b},${a}`);\n const joined = new Set(constraints.flatMap((c) =>\n c.kind === 'coincident' ? [key(c.anchors)]\n : c.kind === 'length' && c.length <= CONSTRAINT_TOLERANCE ? [key(c.segment)] : []));\n const len = (p: readonly ConstraintPoint[], [a, b]: AnchorPair) => Math.hypot(p[b].x - p[a].x, p[b].y - p[a].y);\n const shrank = (was: number, now: number) => was > 10 * CONSTRAINT_TOLERANCE && now <= CONSTRAINT_TOLERANCE;\n const out: number[] = [];\n constraints.forEach((c, i) => {\n if (skipped.has(i) || !constraintApplies(c, from)) return;\n if (c.kind === 'tangent') {\n const [a, b] = [from[c.anchor], to[c.anchor]];\n if (shrank(handleLength(a, a.inHandle), handleLength(b, b.inHandle))\n || shrank(handleLength(a, a.outHandle), handleLength(b, b.outHandle))) out.push(i);\n return;\n }\n if (segmentsOf(c).some((s) => !joined.has(key(s)) && shrank(len(from, s), len(to, s)))) out.push(i);\n });\n return out;\n}\n\n/** Options for {@link unsatisfiedConstraints}. */\nexport interface UnsatisfiedConstraintsOptions {\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle`. */\n axisAngles?: readonly (number | undefined)[];\n /** Where a `fixed` anchor belongs. Absent, a `fixed` constraint always holds. */\n reference?: readonly (ConstraintPoint | undefined)[];\n /** Default {@link CONSTRAINT_TOLERANCE}. */\n tolerance?: number;\n}\n\n/**\n * Indices of the constraints that do not hold for `points`: a residual past\n * the tolerance, an anchor index the points do not have, or a tangent on an\n * anchor missing a handle.\n */\nexport function unsatisfiedConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: UnsatisfiedConstraintsOptions = {},\n): number[] {\n const { tolerance = CONSTRAINT_TOLERANCE, reference } = opts;\n const spaceOf = (i: number) => ({ frame: frameAt(opts.axisAngles?.[i] ?? opts.axisAngle), count: points.length });\n const packed = pack(points);\n // One slot past the points for an `onPath` parameter, set to the nearest point's each time.\n const x = new Float64Array(packed.length + 1);\n x.set(packed);\n const param = packed.length;\n const r = new Float64Array(2);\n const out: number[] = [];\n constraints.forEach((c, i) => {\n if (!constraintApplies(c, points)) {\n out.push(i);\n return;\n }\n if (c.kind === 'fixed') {\n const at = reference?.[c.anchor];\n const p = points[c.anchor];\n if (at && Math.hypot(at.x - p.x, at.y - p.y) > tolerance) out.push(i);\n return;\n }\n if (c.kind === 'onPath') x[param] = nearestParam(c, x, points.length);\n writeResiduals(c, x, spaceOf(i), r, 0, undefined, param);\n for (let k = 0; k < residualRows(c); k++) {\n if (Math.abs(r[k]) > tolerance) {\n out.push(i);\n return;\n }\n }\n });\n return out;\n}\n","/**\n * The damped normal equations of a constraint solve, `(J M Jᵀ + λI) y = b`,\n * kept sparse. Each row of `J` reads a handful of coordinates, so two rows\n * meet in the normal matrix only when they share one. The rows are put in\n * reverse Cuthill-McKee order, which packs those meetings near the diagonal,\n * and the matrix is factored by Cholesky inside that envelope: a chain of\n * constraints along a path costs time linear in its length, where the dense\n * solve cost its cube.\n */\n\n/** A row's position in `order` for each row, and the rows in that order. */\nfunction reverseCuthillMcKee(neighbors: readonly number[][]): { order: Int32Array; rank: Int32Array } {\n const m = neighbors.length;\n const order = new Int32Array(m);\n const rank = new Int32Array(m).fill(-1);\n const byDegree = [...neighbors.keys()].sort((a, b) => neighbors[a].length - neighbors[b].length);\n let n = 0;\n for (const start of byDegree) {\n if (rank[start] >= 0) continue;\n rank[start] = n;\n order[n++] = start;\n for (let head = n - 1; head < n; head++) {\n const next = neighbors[order[head]].filter((q) => rank[q] < 0)\n .sort((a, b) => neighbors[a].length - neighbors[b].length);\n for (const q of next) {\n rank[q] = n;\n order[n++] = q;\n }\n }\n }\n order.reverse();\n order.forEach((row, i) => { rank[row] = i; });\n return { order, rank };\n}\n\nexport class NormalSystem {\n private readonly cols: Int32Array[];\n private readonly vals: Float64Array[];\n private readonly mobility: Float64Array;\n private readonly rank: Int32Array;\n /** For each row in envelope order, the first column its envelope holds, and where its entries start. */\n private readonly first: Int32Array;\n private readonly offset: Int32Array;\n private readonly env: Float64Array;\n /**\n * Each product one coordinate makes between two rows' entries:\n * envelope position, the two rows, their slots, and the coordinate.\n */\n private readonly pairs: { pos: Int32Array; p: Int32Array; sp: Int32Array; q: Int32Array; sq: Int32Array; v: Int32Array };\n\n /**\n * `rowCols[p]` lists the coordinates row `p` may read; one whose `mobility`\n * is 0 here is dropped. `mobility` is read again at every solve, so a\n * coordinate may be stilled for a step by zeroing it.\n */\n constructor(rowCols: readonly Int32Array[], mobility: Float64Array) {\n this.mobility = mobility;\n this.cols = rowCols.map((c) => Int32Array.from(new Set(c)).filter((v) => mobility[v] > 0));\n this.vals = this.cols.map((c) => new Float64Array(c.length));\n const m = this.cols.length;\n const readers = new Map<number, { row: number; slot: number }[]>();\n this.cols.forEach((c, row) => c.forEach((v, slot) => {\n let list = readers.get(v);\n if (!list) readers.set(v, (list = []));\n list.push({ row, slot });\n }));\n const linked = Array.from({ length: m }, () => new Set<number>());\n for (const list of readers.values()) {\n for (const a of list) for (const b of list) if (a.row !== b.row) linked[a.row].add(b.row);\n }\n const { rank } = reverseCuthillMcKee(linked.map((s) => [...s]));\n this.rank = rank;\n this.first = new Int32Array(m);\n for (let p = 0; p < m; p++) {\n let f = rank[p];\n for (const q of linked[p]) f = Math.min(f, rank[q]);\n this.first[rank[p]] = f;\n }\n this.offset = new Int32Array(m + 1);\n for (let i = 0; i < m; i++) this.offset[i + 1] = this.offset[i] + i - this.first[i] + 1;\n this.env = new Float64Array(this.offset[m]);\n\n const pos: number[] = [];\n const ps: number[] = [];\n const sps: number[] = [];\n const qs: number[] = [];\n const sqs: number[] = [];\n const vs: number[] = [];\n for (const [v, list] of readers) {\n for (const a of list) {\n for (const b of list) {\n const i = rank[a.row];\n const j = rank[b.row];\n if (j > i) continue;\n pos.push(this.at(i, j));\n ps.push(a.row);\n sps.push(a.slot);\n qs.push(b.row);\n sqs.push(b.slot);\n vs.push(v);\n }\n }\n }\n this.pairs = {\n pos: Int32Array.from(pos), p: Int32Array.from(ps), sp: Int32Array.from(sps),\n q: Int32Array.from(qs), sq: Int32Array.from(sqs), v: Int32Array.from(vs),\n };\n }\n\n /** Rows. */\n get m(): number {\n return this.cols.length;\n }\n\n private at(i: number, j: number): number {\n return this.offset[i] + j - this.first[i];\n }\n\n /** Zero every entry of `J`. */\n clear(): void {\n for (const v of this.vals) v.fill(0);\n }\n\n /** Add `d` to `J[row][v]`; nothing when the row cannot move `v`. */\n add(row: number, v: number, d: number): void {\n const c = this.cols[row];\n for (let k = 0; k < c.length; k++) {\n if (c[k] === v) {\n this.vals[row][k] += d;\n return;\n }\n }\n }\n\n /** `y` for `(J M Jᵀ + λI) y = b`, or null when the matrix will not factor. */\n solve(b: Float64Array, lambda: number): Float64Array | null {\n const { env, first, offset, pairs, vals, rank, mobility } = this;\n const m = this.m;\n env.fill(0);\n for (let k = 0; k < pairs.pos.length; k++) {\n env[pairs.pos[k]] += vals[pairs.p[k]][pairs.sp[k]] * mobility[pairs.v[k]] * vals[pairs.q[k]][pairs.sq[k]];\n }\n for (let i = 0; i < m; i++) env[offset[i + 1] - 1] += lambda;\n // Cholesky in place, L sharing A's envelope.\n for (let i = 0; i < m; i++) {\n const fi = first[i];\n for (let j = fi; j <= i; j++) {\n const fj = first[j];\n let s = env[offset[i] + j - fi];\n for (let k = Math.max(fi, fj); k < j; k++) s -= env[offset[i] + k - fi] * env[offset[j] + k - fj];\n if (j < i) env[offset[i] + j - fi] = s / env[offset[j + 1] - 1];\n else if (s > 0) env[offset[i + 1] - 1] = Math.sqrt(s);\n else return null;\n }\n }\n const z = new Float64Array(m);\n for (let p = 0; p < m; p++) z[rank[p]] = b[p];\n for (let i = 0; i < m; i++) {\n let s = z[i];\n for (let k = first[i]; k < i; k++) s -= env[offset[i] + k - first[i]] * z[k];\n z[i] = s / env[offset[i + 1] - 1];\n }\n for (let i = m - 1; i >= 0; i--) {\n z[i] /= env[offset[i + 1] - 1];\n for (let k = first[i]; k < i; k++) z[k] -= env[offset[i] + k - first[i]] * z[i];\n }\n const y = new Float64Array(m);\n for (let p = 0; p < m; p++) y[p] = z[rank[p]];\n return y;\n }\n\n /** The step `-M Jᵀ y` over every coordinate the mobility names. */\n step(y: Float64Array): Float64Array {\n const delta = new Float64Array(this.mobility.length);\n this.cols.forEach((c, p) => c.forEach((v, k) => {\n delta[v] -= this.mobility[v] * this.vals[p][k] * y[p];\n }));\n return delta;\n }\n}\n","/**\n * A damped Gauss-Newton solve for anchor constraints: from the state an edit\n * left, the smallest weighted move of the anchors and handles that makes\n * every residual zero. Each step is the minimum-norm solution of the\n * linearized system, `Δ = -M Jᵀ (J M Jᵀ + λI)⁻¹ r`, where `M` weighs how\n * freely each coordinate may move; λ grows when a step makes things worse and\n * shrinks when it helps, which is the Levenberg-Marquardt schedule run on the\n * constraint side.\n *\n * A handle is a coordinate of its own only where a `tangent` reads it; any\n * other rides with its anchor, as an offset nothing changes.\n */\n\nimport { CONSTRAINT_TOLERANCE, collapsedBy, unsatisfiedConstraints } from './check';\nimport { constraintApplies, pack, unpack, type ConstraintPoint, type HandleRef } from './points';\nimport {\n frameAt, handleAt, nearestParam, residualRows, spaceSize, writeResiduals, type ResidualSpace,\n} from './residuals';\nimport { NormalSystem } from './sparse';\nimport { constraintAnchors, type PathConstraint } from './types';\n\n/** How freely a held anchor moves, against 1 for any other: it gives way only when nothing else can. */\nconst HELD_MOBILITY = 1e-3;\n\n/** How freely an `onPath` parameter moves, over the square of its segment's chord: freely enough that the anchor slides along before anything bends. */\nconst PARAM_MOBILITY = 1e6;\n\n/** Options for {@link solveConstraints}. */\nexport interface SolveConstraintsOptions {\n /** Anchors the edit put where they are — the dragged ones. They move only when no other anchor can satisfy the constraints. */\n held?: Iterable<number>;\n /** Handles the edit put where they are, held the way `held` holds anchors. */\n heldHandles?: Iterable<HandleRef>;\n /** Where each anchor was before the edit, which is where a `fixed` constraint keeps it. Default: where it is now. */\n reference?: readonly (ConstraintPoint | undefined)[];\n /** Radians the frame `horizontal` and `vertical` read is turned from the world's axes. Default 0. */\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle` — for constraints gathered from paths drawn in different frames. */\n axisAngles?: readonly (number | undefined)[];\n /** Indices of constraints to leave out of the solve — ones already known not to hold. */\n skip?: Iterable<number>;\n /** Default 100. */\n maxIterations?: number;\n /** The largest residual the solve stops at. Default 1e-7. */\n tolerance?: number;\n}\n\n/** What {@link solveConstraints} answers. */\nexport interface SolveConstraintsResult {\n /** Every anchor, moved, with its handles. */\n points: ConstraintPoint[];\n /** Whether every constraint the solve took holds within its tolerance. */\n converged: boolean;\n iterations: number;\n /** Indices of the constraints that do not hold in `points`, skipped ones included. */\n unsatisfied: number[];\n}\n\ninterface Row {\n c: PathConstraint;\n /** First residual row. */\n at: number;\n /** Where an `onPath` constraint's parameter sits in the coordinates; -1 for any other. */\n param: number;\n space: ResidualSpace;\n}\n\ninterface System {\n rows: Row[];\n m: number;\n normal: NormalSystem;\n pinned: Set<number>;\n mobility: Float64Array;\n /** Coordinates: the points', then a parameter per `onPath`. */\n size: number;\n}\n\nfunction residualsOf(sys: System, x: Float64Array): Float64Array {\n const r = new Float64Array(sys.m);\n for (const row of sys.rows) writeResiduals(row.c, x, row.space, r, row.at, undefined, row.param);\n return r;\n}\n\n/** Load the analytic Jacobian at `x` into the normal system. */\nfunction loadJacobian(sys: System, x: Float64Array): void {\n const { normal } = sys;\n normal.clear();\n const scratch = new Float64Array(2);\n for (const row of sys.rows) {\n writeResiduals(row.c, x, row.space, scratch, 0, (k, v, d) => normal.add(row.at + k, v, d), row.param);\n }\n}\n\n/**\n * The damped minimum-norm step for residuals `r` at the loaded Jacobian, or\n * null when it cannot be taken. A parameter at an end of its segment that the\n * step would push past it is held there, and the step taken again without it.\n */\nfunction stepOf(sys: System, x: Float64Array, r: Float64Array, lambda: number): Float64Array | null {\n const y = sys.normal.solve(r, lambda);\n const delta = y && sys.normal.step(y);\n if (!delta) return null;\n const stuck = sys.rows.filter(({ param: p }) =>\n p >= 0 && sys.mobility[p] > 0 && ((x[p] <= 0 && delta[p] < 0) || (x[p] >= 1 && delta[p] > 0)));\n if (stuck.length === 0) return delta;\n const keep = stuck.map(({ param }) => sys.mobility[param]);\n for (const { param } of stuck) sys.mobility[param] = 0;\n const again = sys.normal.solve(r, lambda);\n const out = again && sys.normal.step(again);\n stuck.forEach(({ param }, k) => { sys.mobility[param] = keep[k]; });\n return out;\n}\n\nconst sumSq = (r: Float64Array) => r.reduce((s, v) => s + v * v, 0);\nconst maxAbs = (r: Float64Array) => r.reduce((s, v) => Math.max(s, Math.abs(v)), 0);\n\n/** The coordinates `c` reads, its parameter at `param`. */\nfunction coordinatesOf(c: PathConstraint, count: number, param: number): number[] {\n if (c.kind === 'tangent') {\n const h = handleAt(count, c.anchor);\n return [h, h + 1, h + 2, h + 3];\n }\n const anchors = constraintAnchors(c).flatMap((i) => [2 * i, 2 * i + 1]);\n if (c.kind !== 'onPath') return anchors;\n const out = handleAt(count, c.segment[0]) + 2;\n const inn = handleAt(count, c.segment[1]);\n return [...anchors, out, out + 1, inn, inn + 1, param];\n}\n\n/** How freely each coordinate moves: anchors and the handles a tangent reads, the held ones at `heldMobility`, pinned ones not at all. */\nfunction mobilityOf(\n points: readonly ConstraintPoint[],\n active: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n pinned: ReadonlySet<number>,\n): Float64Array {\n const count = points.length;\n const params = active.filter((c): c is PathConstraint & { kind: 'onPath' } => c.kind === 'onPath');\n const mobility = new Float64Array(spaceSize(count) + params.length);\n mobility.fill(1, 0, 2 * count);\n const held = new Set(opts.held ?? []);\n for (const i of held) {\n if (i >= 0 && i < count) mobility.fill(heldMobility, 2 * i, 2 * i + 2);\n }\n params.forEach((c, k) => {\n const [a, b] = c.segment.map((i) => points[i]);\n mobility[spaceSize(count) + k] = PARAM_MOBILITY / ((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + 1e-6);\n });\n for (const i of pinned) mobility.fill(0, 2 * i, 2 * i + 2);\n for (const c of active) {\n if (c.kind === 'tangent') mobility.fill(1, handleAt(count, c.anchor), handleAt(count, c.anchor) + 4);\n }\n for (const { anchor, side } of opts.heldHandles ?? []) {\n if (anchor < 0 || anchor >= count) continue;\n const h = handleAt(count, anchor) + (side === 'out' ? 2 : 0);\n if (mobility[h] > 0) mobility.fill(heldMobility, h, h + 2);\n }\n return mobility;\n}\n\nfunction buildSystem(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n): System {\n const count = points.length;\n const skip = new Set(opts.skip ?? []);\n const activeIndices = constraints.flatMap((c, i) => (!skip.has(i) && constraintApplies(c, points) ? [i] : []));\n const active = activeIndices.map((i) => constraints[i]);\n const pinned = new Set(active.flatMap((c) => (c.kind === 'fixed' ? [c.anchor] : [])));\n const mobility = mobilityOf(points, active, opts, heldMobility, pinned);\n const rows: Row[] = [];\n const rowCols: Int32Array[] = [];\n let size = spaceSize(count);\n const frames = new Map<number, ResidualSpace>();\n const spaceAt = (angle: number) => {\n let space = frames.get(angle);\n if (!space) frames.set(angle, (space = { frame: frameAt(angle), count }));\n return space;\n };\n for (const i of activeIndices) {\n const c = constraints[i];\n const height = residualRows(c);\n if (height === 0) continue;\n const param = c.kind === 'onPath' ? size++ : -1;\n rows.push({ c, at: rowCols.length, param, space: spaceAt(opts.axisAngles?.[i] ?? opts.axisAngle ?? 0) });\n const vars = Int32Array.from(coordinatesOf(c, count, param));\n for (let k = 0; k < height; k++) rowCols.push(vars);\n }\n const normal = new NormalSystem(rowCols, mobility);\n return { rows, m: rowCols.length, normal, pinned, mobility, size };\n}\n\n/**\n * Move `points` the least that makes `constraints` hold. Anchors named by a\n * `fixed` constraint go back to `reference` and stay there; `held` anchors\n * and `heldHandles` stay where they are when the rest can satisfy the\n * constraints, and give way as little as they must when not. When the\n * constraints cannot all hold, `converged` is false and `unsatisfied` names\n * the ones that do not.\n */\nexport function solveConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions = {},\n): SolveConstraintsResult {\n const held = [...(opts.held ?? [])];\n const heldHandles = [...(opts.heldHandles ?? [])];\n const withHeld = { ...opts, held, heldHandles };\n if (held.length > 0 || heldHandles.length > 0) {\n const still = solveWith(points, constraints, withHeld, 0);\n if (still.converged) return still;\n }\n return solveWith(points, constraints, withHeld, HELD_MOBILITY);\n}\n\nfunction solveWith(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions,\n heldMobility: number,\n): SolveConstraintsResult {\n const { maxIterations = 100, tolerance = 1e-7 } = opts;\n const sys = buildSystem(points, constraints, opts, heldMobility);\n const x = new Float64Array(sys.size);\n x.set(pack(points, (i) => (sys.pinned.has(i) ? opts.reference?.[i] ?? points[i] : points[i])));\n // A held anchor an `onPath` binds slides: it starts from the point on its segment nearest where the edit put it.\n const held = new Set(opts.held ?? []);\n const r0 = new Float64Array(2);\n for (const row of sys.rows) {\n if (row.c.kind !== 'onPath') continue;\n x[row.param] = nearestParam(row.c, x, points.length);\n const a = row.c.anchor;\n if (!held.has(a) || sys.pinned.has(a)) continue;\n writeResiduals(row.c, x, row.space, r0, 0, undefined, row.param);\n x[2 * a] -= r0[0];\n x[2 * a + 1] -= r0[1];\n }\n\n let r = residualsOf(sys, x);\n let lambda = 1e-6;\n let iterations = 0;\n while (maxAbs(r) > tolerance && iterations < maxIterations && lambda < 1e12) {\n iterations++;\n loadJacobian(sys, x);\n const before = sumSq(r);\n for (; lambda < 1e12; lambda *= 10) {\n const delta = stepOf(sys, x, r, lambda);\n if (!delta) continue;\n const next = x.map((v, i) => v + delta[i]);\n for (const row of sys.rows) {\n if (row.param >= 0) next[row.param] = Math.min(1, Math.max(0, next[row.param]));\n }\n const rn = residualsOf(sys, next);\n if (sumSq(rn) < before) {\n x.set(next);\n r = rn;\n lambda = Math.max(lambda / 3, 1e-12);\n break;\n }\n }\n }\n\n const out = unpack(x, points);\n const skipped = new Set(opts.skip ?? []);\n const collapsed = collapsedBy(points, out, constraints, skipped);\n const unsatisfied = [...new Set([\n ...unsatisfiedConstraints(out, constraints, {\n axisAngle: opts.axisAngle, axisAngles: opts.axisAngles, reference: opts.reference,\n }),\n ...collapsed,\n ])].sort((a, b) => a - b);\n return {\n points: out,\n converged: maxAbs(r) <= Math.max(tolerance, CONSTRAINT_TOLERANCE) && unsatisfied.every((i) => skipped.has(i)),\n iterations,\n unsatisfied,\n };\n}\n","/**\n * Constraints on a `PolygonPath`: solving them over its anchors, and carrying\n * them through an edit that renumbers the anchors.\n */\n\nimport type { PolygonPath } from '../path';\nimport { anchorPointIndices, type PointOrigin } from '../paths/anchorOrigins';\nimport { anchorAt, editAnchorSet } from '../paths/anchorEdits';\nimport { pathToAnchors } from '../paths/anchors';\nimport type { ConstraintPoint } from './points';\nimport { solveConstraints, type SolveConstraintsOptions, type SolveConstraintsResult } from './solve';\nimport { mapConstraintAnchors, type AnchorPair, type PathConstraint } from './types';\n\n/** Every anchor of `path`, by flat index, with the handles it has. */\nexport function pathAnchorPoints(path: PolygonPath): ConstraintPoint[] {\n return pathToAnchors(path).anchors.flat().map((a) => {\n const p: ConstraintPoint = { x: a.x, y: a.y };\n if (a.inHandle) p.inHandle = { ...a.inHandle };\n if (a.outHandle) p.outHandle = { ...a.outHandle };\n return p;\n });\n}\n\nconst samePoint = (a: { x: number; y: number } | undefined, b: { x: number; y: number } | undefined) =>\n a === b || (!!a && !!b && a.x === b.x && a.y === b.y);\n\n/** Whether the solve moved anchor `p` to `q` or turned either of its handles. */\nconst moved = (p: ConstraintPoint, q: ConstraintPoint) =>\n !samePoint(p, q) || !samePoint(p.inHandle, q.inHandle) || !samePoint(p.outHandle, q.outHandle);\n\n/** {@link solveConstraints} over `path`'s anchors, and `path` with them moved. */\nexport interface SolvePathConstraintsResult extends SolveConstraintsResult {\n /** `path` with each anchor moved where the solve put it, its handles moved with it; `path` itself when none moved. */\n path: PolygonPath;\n}\n\n/**\n * Solve `constraints` over the anchors of `path` and write the result back,\n * carrying each moved anchor's handles with it so its curves keep their\n * shape, except where a `tangent` turned them.\n */\nexport function solvePathConstraints(\n path: PolygonPath,\n constraints: readonly PathConstraint[],\n opts: SolveConstraintsOptions = {},\n): SolvePathConstraintsResult {\n const points = pathAnchorPoints(path);\n const result = solveConstraints(points, constraints, opts);\n return { ...result, path: withAnchorPoints(path, points, result.points) };\n}\n\n/**\n * `path` with its anchors and handles where `to` puts them, given `from`,\n * where they are now; `path` itself when nothing moved.\n */\nexport function withAnchorPoints(\n path: PolygonPath,\n from: readonly ConstraintPoint[],\n to: readonly ConstraintPoint[],\n): PolygonPath {\n const moves = to.flatMap((p, i) => (moved(from[i], p) ? [i] : []));\n if (moves.length === 0) return path;\n const next = editAnchorSet(path, (set) => {\n for (const i of moves) {\n const a = anchorAt(set, i)!;\n const p = to[i];\n a.x = p.x;\n a.y = p.y;\n if (a.inHandle && p.inHandle) a.inHandle = { ...p.inHandle };\n if (a.outHandle && p.outHandle) a.outHandle = { ...p.outHandle };\n }\n });\n return next ?? path;\n}\n\n/**\n * For each anchor of `after`, the anchor of `before` it is: the one whose\n * point `origins` says it was copied from. An anchor the edit made has none.\n * `origins` is what `editAnchorSetTracked` answered for the edit.\n */\nexport function anchorsBefore(\n before: PolygonPath,\n after: PolygonPath,\n origins: readonly (PointOrigin | null)[],\n): (number | undefined)[] {\n const anchorOfPoint = new Map<number, number>();\n anchorPointIndices(before).forEach((point, anchor) => anchorOfPoint.set(point, anchor));\n return anchorPointIndices(after).map((point) => {\n const o = origins[point];\n if (!o || (o.t !== 0 && o.a !== o.b)) return undefined;\n return anchorOfPoint.get(o.a);\n });\n}\n\n/**\n * `constraints` renumbered for the anchors of a path after an edit, given\n * `wasAnchor` — for each new anchor, the old one it is, as\n * {@link anchorsBefore} answers. A constraint naming an anchor the edit\n * removed is dropped; `from` holds each kept one's index in `constraints`.\n */\nexport function remapConstraints(\n constraints: readonly PathConstraint[],\n wasAnchor: readonly (number | undefined)[],\n): { constraints: PathConstraint[]; from: number[] } {\n const now = new Map<number, number>();\n wasAnchor.forEach((old, i) => {\n if (old !== undefined && !now.has(old)) now.set(old, i);\n });\n const out: PathConstraint[] = [];\n const from: number[] = [];\n constraints.forEach((c, i) => {\n const mapped = mapConstraintAnchors(c, (a) => now.get(a));\n if (!mapped) return;\n out.push(mapped);\n from.push(i);\n });\n return { constraints: out, from };\n}\n\n/**\n * The segment of `path` joining anchors `a` and `b`, as the pair in the order\n * the path runs it, or null when no segment joins them.\n */\nexport function segmentBetween(path: PolygonPath, a: number, b: number): AnchorPair | null {\n const { anchors, closed } = pathToAnchors(path);\n let base = 0;\n for (let s = 0; s < anchors.length; s++) {\n const n = anchors[s].length;\n const next = (i: number) => (i + 1 < n ? i + 1 : closed[s] && n > 2 ? 0 : -1);\n for (const [p, q] of [[a, b], [b, a]] as const) {\n const i = p - base;\n if (i >= 0 && i < n && next(i) >= 0 && base + next(i) === q) return [p, q];\n }\n base += n;\n }\n return null;\n}\n\n","/**\n * Finishing an edit of constrained paths so their constraints hold: one path\n * on its own, or several solved together when links — constraints naming\n * anchors of more than one — tie them.\n */\n\nimport type { PolygonPath } from '../path';\nimport type { PointOrigin } from '../paths/anchorOrigins';\nimport { unsatisfiedConstraints } from './check';\nimport {\n anchorsBefore, pathAnchorPoints, remapConstraints, segmentBetween, withAnchorPoints,\n} from './pathConstraints';\nimport type { ConstraintPoint, HandleRef } from './points';\nimport { solveConstraints } from './solve';\nimport { mapConstraintAnchors, type PathConstraint } from './types';\n\n/** Options for {@link constrainPathEdit}. */\nexport interface ConstrainPathEditOptions {\n /**\n * Where each point of the edited path came from, as `editAnchorSetTracked`\n * answers. Absent, the edit is taken to keep every anchor's number, and one\n * that changes the anchor count drops every constraint.\n */\n origins?: readonly (PointOrigin | null)[];\n /** See {@link SolveConstraintsOptions.axisAngle}. */\n axisAngle?: number;\n}\n\n/** What {@link constrainPathEdit} answers. */\nexport interface ConstrainedPathEdit {\n /** The edited path with the constraints holding again. */\n path: PolygonPath;\n /** The constraints renumbered for `path`'s anchors. */\n constraints: PathConstraint[];\n /** Whether every constraint that held before the edit holds after it. */\n converged: boolean;\n /** Indices into `constraints` of the ones that do not hold, including any that already did not before the edit. */\n unsatisfied: number[];\n}\n\n/** One path of a {@link constrainPathsEdit}: its edit, and its own constraints. */\nexport interface PathsEditItem extends ConstrainPathEditOptions {\n before: PolygonPath;\n /** `before` as the edit left it; `before` itself for a path the edit did not touch. */\n after: PolygonPath;\n constraints: readonly PathConstraint[];\n /** For a path the edit left alone: its anchors give way as freely as any the edit did not move, rather than only when the edited paths cannot. */\n yields?: boolean;\n}\n\n/**\n * A constraint across paths. Its anchors are numbered over the anchors of\n * `paths` — indices into the items — one after another in that order: with\n * `paths: [2, 0]` and a 5-anchor item 2, anchor 6 is item 0's anchor 1. Its\n * `horizontal` and `vertical` read the world's axes.\n */\nexport interface PathLink {\n constraint: PathConstraint;\n paths: readonly number[];\n}\n\n/** What {@link constrainPathsEdit} answers. */\nexport interface ConstrainedPathsEdit {\n /** Each item, in order: its path with the constraints holding, and its own constraints renumbered for it. */\n items: { path: PolygonPath; constraints: PathConstraint[]; unsatisfied: number[] }[];\n /** Each link renumbered over its paths' anchors after the edit; null when the edit removed an anchor it names. */\n links: { constraint: PathConstraint | null; satisfied: boolean }[];\n /** Whether every constraint that held before the edit holds after it. */\n converged: boolean;\n}\n\n/** The handles of `now` turned or stretched from where their anchors' `reference` had them. */\nfunction handlesMoved(now: readonly ConstraintPoint[], reference: readonly (ConstraintPoint | undefined)[]): HandleRef[] {\n const offset = (p: ConstraintPoint, h: { x: number; y: number } | undefined) => h && { x: h.x - p.x, y: h.y - p.y };\n // Translating an anchor moves its handles by the same amount, which can round their offsets.\n const near = (a?: { x: number; y: number }, b?: { x: number; y: number }) =>\n a === b || (!!a && !!b && Math.abs(a.x - b.x) <= 1e-9 * (1 + Math.abs(a.x)) && Math.abs(a.y - b.y) <= 1e-9 * (1 + Math.abs(a.y)));\n return now.flatMap((p, anchor) => {\n const r = reference[anchor];\n if (!r) return [];\n const sides: HandleRef[] = [];\n if (!near(offset(p, p.inHandle), offset(r, r.inHandle))) sides.push({ anchor, side: 'in' });\n if (!near(offset(p, p.outHandle), offset(r, r.outHandle))) sides.push({ anchor, side: 'out' });\n return sides;\n });\n}\n\nconst starts = (counts: readonly number[]) => counts.reduce<number[]>((acc, n, i) => [...acc, acc[i] + n], [0]);\n\n/** Link anchor `a`, numbered over `paths` with `counts`, as a global index, given each item's `offsets`. */\nfunction linkToGlobal(link: PathLink, counts: readonly number[], offsets: readonly number[]) {\n const local = starts(link.paths.map((p) => counts[p]));\n return (a: number): number | undefined => {\n for (let k = 0; k < link.paths.length; k++) {\n if (a >= local[k] && a < local[k + 1]) return offsets[link.paths[k]] + a - local[k];\n }\n return undefined;\n };\n}\n\n/** Global index `g` as an item and its anchor there. */\nfunction itemOf(g: number, offsets: readonly number[]): { item: number; anchor: number } {\n let item = 0;\n while (item + 1 < offsets.length - 1 && g >= offsets[item + 1]) item++;\n return { item, anchor: g - offsets[item] };\n}\n\n/**\n * An edit of constrained paths, finished so their constraints and the links\n * between them hold, as one solve over every anchor: the anchors and handles\n * the edit moved are held, and so are the anchors of a path it left alone\n * (`after === before`), except one held on a segment or on a path that\n * `yields`; `fixed` anchors go\n * back to where they were, and the rest move the least they must. A constraint\n * that did not hold before the edit is left out of the solve, and reported.\n * Each item's own `horizontal` and `vertical` read its own `axisAngle`.\n */\nexport function constrainPathsEdit(items: readonly PathsEditItem[], links: readonly PathLink[] = []): ConstrainedPathsEdit {\n const was = items.map((it) => pathAnchorPoints(it.before));\n const now = items.map((it) => pathAnchorPoints(it.after));\n const wasStart = starts(was.map((p) => p.length));\n const nowStart = starts(now.map((p) => p.length));\n const wasAnchor = items.flatMap((it, i) => {\n const map = it.origins\n ? anchorsBefore(it.before, it.after, it.origins)\n : now[i].map((_, j) => (now[i].length === was[i].length ? j : undefined));\n return map.map((old) => (old === undefined ? undefined : wasStart[i] + old));\n });\n\n // Every constraint numbered over all the anchors before the edit, the items' own first.\n const all: PathConstraint[] = [];\n const angles: (number | undefined)[] = [];\n items.forEach((it, i) => it.constraints.forEach((c) => {\n all.push(mapConstraintAnchors(c, (a) => wasStart[i] + a)!);\n angles.push(it.axisAngle);\n }));\n const ownCount = all.length;\n for (const link of links) {\n all.push(mapConstraintAnchors(link.constraint, linkToGlobal(link, was.map((p) => p.length), wasStart))\n ?? { kind: 'fixed', anchor: -1 });\n angles.push(0);\n }\n\n const wasAll = was.flat();\n const nowAll = now.flat();\n const broken = new Set(unsatisfiedConstraints(wasAll, all, { axisAngles: angles }));\n // An `onPath` whose segment the edit split or broke has no segment left to hold its anchor on.\n const remapped = remapConstraints(all, wasAnchor);\n const joined = remapped.constraints.map((c) => {\n if (c.kind !== 'onPath') return true;\n const [a, b] = c.segment.map((g) => itemOf(g, nowStart));\n return a.item === b.item && !!segmentBetween(items[a.item].after, a.anchor, b.anchor);\n });\n const kept = remapped.constraints.filter((_, i) => joined[i]);\n const from = remapped.from.filter((_, i) => joined[i]);\n const skip = from.flatMap((old, i) => (broken.has(old) ? [i] : []));\n const reference = wasAnchor.map((old) => (old === undefined ? undefined : wasAll[old]));\n // A path the edit left alone gives way only when the edited ones cannot, but an anchor held\n // on a segment still follows the segment.\n const sliding = new Set(kept.flatMap((c) => (c.kind === 'onPath' ? [c.anchor] : [])));\n const still = (i: number) => {\n const { item } = itemOf(i, nowStart);\n const it = items[item];\n return items.length > 1 && it.before === it.after && !it.yields && !sliding.has(i);\n };\n const held = nowAll.flatMap((p, i) => {\n const r = reference[i];\n return !r || r.x !== p.x || r.y !== p.y || still(i) ? [i] : [];\n });\n const solved = solveConstraints(nowAll, kept, {\n held, heldHandles: handlesMoved(nowAll, reference), reference, skip, axisAngles: from.map((old) => angles[old]),\n });\n const failing = new Set(solved.unsatisfied);\n\n const outItems: ConstrainedPathsEdit['items'] = items.map((it, i) => ({\n path: withAnchorPoints(it.after, now[i], solved.points.slice(nowStart[i], nowStart[i + 1])),\n constraints: [],\n unsatisfied: [],\n }));\n const outLinks: ConstrainedPathsEdit['links'] = links.map(() => ({ constraint: null, satisfied: false }));\n kept.forEach((c, k) => {\n const old = from[k];\n if (old < ownCount) {\n const { item } = itemOf(constraintFirstAnchor(all[old]), wasStart);\n const out = outItems[item];\n if (failing.has(k)) out.unsatisfied.push(out.constraints.length);\n out.constraints.push(mapConstraintAnchors(c, (g) => g - nowStart[item])!);\n return;\n }\n const link = links[old - ownCount];\n const local = starts(link.paths.map((p) => now[p].length));\n const toLocal = (g: number) => {\n const { item, anchor } = itemOf(g, nowStart);\n const k2 = link.paths.indexOf(item);\n return k2 < 0 ? undefined : local[k2] + anchor;\n };\n outLinks[old - ownCount] = { constraint: mapConstraintAnchors(c, toLocal), satisfied: !failing.has(k) };\n });\n return { items: outItems, links: outLinks, converged: solved.converged };\n}\n\nfunction constraintFirstAnchor(c: PathConstraint): number {\n switch (c.kind) {\n case 'fixed':\n case 'tangent':\n case 'onPath': return c.anchor;\n case 'horizontal':\n case 'vertical':\n case 'length': return c.segment[0];\n case 'coincident': return c.anchors[0];\n default: return c.segments[0][0];\n }\n}\n\n/**\n * An edit of a constrained path, `before` → `after`, finished so its\n * constraints hold: the anchors and handles the edit moved are held, `fixed`\n * anchors go back to where they were, and the rest move the least they must.\n * A constraint that did not hold before the edit conflicts with the others\n * and is left out of the solve rather than allowed to pull them out of true;\n * `unsatisfied` reports it.\n */\nexport function constrainPathEdit(\n before: PolygonPath,\n after: PolygonPath,\n constraints: readonly PathConstraint[],\n opts: ConstrainPathEditOptions = {},\n): ConstrainedPathEdit {\n const done = constrainPathsEdit([{ before, after, constraints, ...opts }]);\n const [item] = done.items;\n return { path: item.path, constraints: item.constraints, converged: done.converged, unsatisfied: item.unsatisfied };\n}\n","/**\n * Which constraints conflict: not merely the ones a failed solve leaves\n * unsatisfied, but a smallest set that cannot all hold together, found by a\n * deletion filter — drop each member in turn, and keep it out when what is\n * left still fails. Every member of the answer is needed for the conflict.\n */\n\nimport { constraintApplies, type ConstraintPoint } from './points';\nimport { solveConstraints } from './solve';\nimport { constraintAnchors, type PathConstraint } from './types';\n\n/** Options for {@link conflictingConstraints}. */\nexport interface ConflictingConstraintsOptions {\n /** Radians the frame `horizontal` and `vertical` read is turned from the world's axes. Default 0. */\n axisAngle?: number;\n /** A frame per constraint, by index, over `axisAngle`. */\n axisAngles?: readonly (number | undefined)[];\n /** Where each anchor belongs for a `fixed` constraint. Default: where it is now. */\n reference?: readonly (ConstraintPoint | undefined)[];\n}\n\n/** Constraints sharing an anchor, directly or through others, as lists of indices into `constraints`. */\nfunction componentsOf(constraints: readonly PathConstraint[], indices: readonly number[]): number[][] {\n const parent = new Map<number, number>();\n const find = (a: number): number => {\n let r = a;\n while (parent.has(r) && parent.get(r) !== r) r = parent.get(r)!;\n parent.set(a, r);\n return r;\n };\n for (const i of indices) {\n const [first, ...rest] = constraintAnchors(constraints[i]);\n for (const a of rest) parent.set(find(a), find(first));\n }\n const groups = new Map<number, number[]>();\n for (const i of indices) {\n const root = find(constraintAnchors(constraints[i])[0]);\n let g = groups.get(root);\n if (!g) groups.set(root, (g = []));\n g.push(i);\n }\n return [...groups.values()];\n}\n\n/**\n * The constraints of `constraints` that conflict over `points`: for every\n * group of them sharing anchors that cannot all hold, a smallest subset that\n * still cannot — each member needed, the later ones in the list kept in\n * preference to the earlier — and every constraint that cannot apply at all.\n * Sorted; empty when every constraint can hold at once.\n */\nexport function conflictingConstraints(\n points: readonly ConstraintPoint[],\n constraints: readonly PathConstraint[],\n opts: ConflictingConstraintsOptions = {},\n): number[] {\n const all = constraints.map((_, i) => i);\n const applies = all.filter((i) => constraintApplies(constraints[i], points));\n const out = all.filter((i) => !applies.includes(i));\n const holds = (subset: readonly number[]) => {\n const keep = new Set(subset);\n const skip = all.filter((i) => !keep.has(i));\n return solveConstraints(points, constraints, { ...opts, skip }).converged;\n };\n if (holds(applies)) return out;\n for (const group of componentsOf(constraints, applies)) {\n if (holds(group)) continue;\n const set = [...group];\n for (const i of group) {\n const without = set.filter((j) => j !== i);\n if (!holds(without)) set.splice(set.indexOf(i), 1);\n }\n out.push(...set);\n }\n return out.sort((a, b) => a - b);\n}\n","/**\n * Anchor lookup across several paths, measured on screen: which existing\n * anchor is nearest a point, and whether it ends an open subpath. Feeds the\n * pen's anchor snapping and its pick-up of an open path's endpoint.\n */\n\nimport type { PolygonPath } from '../path';\nimport { scaleDelta, type Scale2 } from '../pxExtent';\nimport { pathToAnchors, type PenAnchor } from './anchors';\n\n/** An existing anchor found near a point. */\nexport interface PathAnchorHit {\n /** The id the path was supplied under. */\n id: string;\n /** Subpath index, then anchor index within that subpath. */\n sub: number;\n idx: number;\n x: number;\n y: number;\n /** Which end of an open subpath this anchor is, or null when it is an\n * interior anchor or its subpath is closed. A lone anchor reads `'last'`. */\n end: 'first' | 'last' | null;\n}\n\n/**\n * The anchor nearest `point` within a screen-space circle of radius `px`,\n * across every subpath of every path in `paths`. Paths and `point` share one\n * world frame; `scale` is the view's, so the radius stays round under\n * non-uniform zoom. `accept` narrows the candidates (endpoints only, say).\n * Ties go to the earlier path, so pass paths front-to-back.\n */\nexport function nearestPathAnchor(\n paths: Iterable<{ id: string; path: PolygonPath }>,\n point: { x: number; y: number },\n px: number,\n scale: Scale2,\n accept?: (hit: PathAnchorHit) => boolean,\n): PathAnchorHit | null {\n let best: PathAnchorHit | null = null;\n let bestD2 = px * px;\n for (const { id, path } of paths) {\n const { anchors, closed } = pathToAnchors(path);\n for (let sub = 0; sub < anchors.length; sub++) {\n const list = anchors[sub];\n for (let idx = 0; idx < list.length; idx++) {\n const a = list[idx];\n const s = scaleDelta(a.x - point.x, a.y - point.y, scale);\n const d2 = s.x * s.x + s.y * s.y;\n if (d2 > bestD2 || (best !== null && d2 === bestD2)) continue;\n const end = closed[sub]\n ? null\n : idx === list.length - 1 ? 'last' : idx === 0 ? 'first' : null;\n const hit: PathAnchorHit = { id, sub, idx, x: a.x, y: a.y, end };\n if (accept && !accept(hit)) continue;\n best = hit;\n bestD2 = d2;\n }\n }\n }\n return best;\n}\n\n/** Reverse a subpath's direction without changing its shape: the anchor\n * order flips and each anchor's in and out handles trade places. */\nexport function reverseAnchors<A extends PenAnchor>(anchors: readonly A[]): A[] {\n return anchors.map((a) => {\n const { inHandle, outHandle, ...rest } = a;\n const r = { ...rest } as A;\n if (outHandle) r.inHandle = { ...outHandle };\n if (inHandle) r.outHandle = { ...inHandle };\n return r;\n }).reverse();\n}\n","/**\n * Edits to a path's order rather than its shape: where a subpath starts, and\n * which way it runs. Each mutates an `AnchorSet` in place, like the edits in\n * `anchorEdits`, and moves anchors whole, so anything an anchor carries beside\n * its point and handles travels with it.\n */\n\nimport { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { cubicPointAt } from './cubicMath';\nimport { isStraightSegment, segmentEnds } from './anchors';\nimport { reverseAnchors } from './nearestAnchor';\n\n/**\n * Make the anchor at `flatIndex` its subpath's first. A closed subpath turns\n * so it starts there, keeping its direction. An open subpath can only start\n * at one of its ends: its last anchor makes it run the other way, and an\n * interior anchor changes nothing. Returns whether the set changed.\n */\nexport function setSubpathStart(set: AnchorSet, flatIndex: number): boolean {\n const loc = locateAnchor(set, flatIndex);\n if (!loc || loc.idx === 0) return false;\n const sub = set.anchors[loc.sub];\n if (set.closed[loc.sub]) {\n set.anchors[loc.sub] = [...sub.slice(loc.idx), ...sub.slice(0, loc.idx)];\n return true;\n }\n if (loc.idx !== sub.length - 1) return false;\n set.anchors[loc.sub] = reverseAnchors(sub);\n return true;\n}\n\n/**\n * Run each subpath in `subs` the other way, every one when `subs` is absent.\n * The shape is unchanged: each anchor's handles trade places. A closed\n * subpath keeps its start anchor, as `reversePath` does; an open one starts\n * where it used to end. Returns whether any subpath had a segment to turn.\n */\nexport function reverseSubpaths(set: AnchorSet, subs?: Iterable<number>): boolean {\n const which = subs ? new Set(subs) : set.anchors.map((_, s) => s);\n let changed = false;\n for (const s of which) {\n const sub = set.anchors[s];\n if (!sub || sub.length < 2) continue;\n const back = reverseAnchors(sub);\n // `reverseAnchors` ends on the old start; a closed subpath turns it back to the front.\n set.anchors[s] = set.closed[s] ? [back[back.length - 1], ...back.slice(0, -1)] : back;\n changed = true;\n }\n return changed;\n}\n\n/**\n * Where each anchor at `flatIndexes` sits once `reverseSubpaths(set, subs)`\n * has run: an anchor keeps its point, so a selection can follow it. Indexes\n * outside the set are dropped.\n */\nexport function flatIndexesAfterReverse(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n subs?: Iterable<number>,\n): number[] {\n const which = subs ? new Set(subs) : null;\n const out: number[] = [];\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n const n = set.anchors[loc.sub].length;\n if (which && !which.has(loc.sub)) { out.push(flat); continue; }\n const idx = set.closed[loc.sub] ? (n - loc.idx) % n : n - 1 - loc.idx;\n out.push(flat - loc.idx + idx);\n }\n return out;\n}\n\n/** The subpaths holding the anchors at `flatIndexes`, each once, in order. */\nexport function subpathsOfAnchors(set: AnchorSet, flatIndexes: Iterable<number>): number[] {\n const subs = new Set<number>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (loc) subs.add(loc.sub);\n }\n return [...subs].sort((a, b) => a - b);\n}\n\n/** A mark showing which way a path runs: a point on it and the unit vector of its heading there. */\nexport interface DirectionMark {\n x: number;\n y: number;\n dx: number;\n dy: number;\n /** The subpath the mark is on. */\n sub: number;\n}\n\n/**\n * One {@link DirectionMark} at the middle of every segment of `set`, closing\n * segments included, in walk order. A segment with no length gets none.\n */\nexport function directionMarks(set: AnchorSet): DirectionMark[] {\n const out: DirectionMark[] = [];\n set.anchors.forEach((sub, s) => {\n const count = set.closed[s] ? sub.length : sub.length - 1;\n for (let i = 0; i < count; i++) {\n const ends = segmentEnds(set.anchors, set.closed, s, i);\n if (!ends) continue;\n const mark = midMark(ends.a, ends.b);\n if (mark) out.push({ ...mark, sub: s });\n }\n });\n return out;\n}\n\ntype Point = { x: number; y: number };\n\nfunction midMark(a: Point & { outHandle?: Point }, b: Point & { inHandle?: Point }): Omit<DirectionMark, 'sub'> | null {\n if (isStraightSegment(a, b)) return unit({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, b.x - a.x, b.y - a.y);\n const c1 = a.outHandle ?? a;\n const c2 = b.inHandle ?? b;\n const mid = cubicPointAt(a, c1, c2, b, 0.5);\n // The cubic's derivative at t = 1/2, up to a constant factor.\n const dx = (c2.x + b.x) - (a.x + c1.x);\n const dy = (c2.y + b.y) - (a.y + c1.y);\n return unit(mid, dx, dy) ?? unit(mid, b.x - a.x, b.y - a.y);\n}\n\nfunction unit(at: Point, dx: number, dy: number): Omit<DirectionMark, 'sub'> | null {\n const len = Math.hypot(dx, dy);\n return len > 1e-9 ? { x: at.x, y: at.y, dx: dx / len, dy: dy / len } : null;\n}\n","/**\n * Straight and curved segments, converted in place. A segment runs from one\n * anchor to the next, the closing segment of a closed subpath included, and is\n * named `(sub, segIdx)` as `segmentAt` reports it.\n */\n\nimport { locateAnchor, type AnchorSet } from './anchorEdits';\nimport { isStraightSegment, segmentEnds } from './anchors';\n\n/** A segment of an `AnchorSet`: `segIdx === sub.length - 1` is a closed\n * subpath's closing segment. */\nexport interface SegmentRef {\n sub: number;\n segIdx: number;\n}\n\n/** What a segment is made: a line, a curve, or the other of what it is. */\nexport type SegmentType = 'line' | 'curve';\n\n/**\n * The segments both of whose ends are among `flatIndexes`, in walk order.\n * Two adjacent selected anchors select the segment between them; a closed\n * subpath with every anchor selected has all its segments.\n */\nexport function segmentsBetweenAnchors(set: AnchorSet, flatIndexes: Iterable<number>): SegmentRef[] {\n const picked = new Map<number, Set<number>>();\n for (const flat of flatIndexes) {\n const loc = locateAnchor(set, flat);\n if (!loc) continue;\n let s = picked.get(loc.sub);\n if (!s) picked.set(loc.sub, (s = new Set()));\n s.add(loc.idx);\n }\n const out: SegmentRef[] = [];\n for (const [sub, idxs] of [...picked].sort((a, b) => a[0] - b[0])) {\n const n = set.anchors[sub].length;\n const count = set.closed[sub] ? n : n - 1;\n for (let i = 0; i < count; i++) {\n if (idxs.has(i) && idxs.has((i + 1) % n)) out.push({ sub, segIdx: i });\n }\n }\n return out;\n}\n\n/** Whether segment `seg` is straight, or null when it does not exist. */\nexport function isSegmentStraight(set: AnchorSet, seg: SegmentRef): boolean | null {\n const ends = segmentEnds(set.anchors, set.closed, seg.sub, seg.segIdx);\n return ends ? isStraightSegment(ends.a, ends.b) : null;\n}\n\n/**\n * Make each segment in `segs` straight or curved without moving its anchors.\n * A line becomes a curve with its handles a third of the way in from each\n * end, which draws the same line; a curve becomes a line by dropping the two\n * handles that shape it, leaving the handles of the segments beside it alone.\n * With no `to`, every segment turns curved when any of them is straight, and\n * straight when all are curved: one press flips the lot.\n *\n * Returns whether any segment changed.\n */\nexport function convertSegments(set: AnchorSet, segs: readonly SegmentRef[], to?: SegmentType): boolean {\n const target = to ?? (segs.some((seg) => isSegmentStraight(set, seg) === true) ? 'curve' : 'line');\n let changed = false;\n for (const seg of segs) {\n const ends = segmentEnds(set.anchors, set.closed, seg.sub, seg.segIdx);\n if (!ends) continue;\n const { a, b } = ends;\n const straight = isStraightSegment(a, b);\n if (target === 'line' && !straight) {\n delete a.outHandle;\n delete b.inHandle;\n changed = true;\n } else if (target === 'curve' && straight) {\n a.outHandle = { x: a.x + (b.x - a.x) / 3, y: a.y + (b.y - a.y) / 3 };\n b.inHandle = { x: b.x + (a.x - b.x) / 3, y: b.y + (a.y - b.y) / 3 };\n changed = true;\n }\n }\n return changed;\n}\n","/**\n * Anchors as numbers a person types: the position of the selected anchors,\n * and for a lone anchor its handles' positions, angles and lengths. Reading\n * answers what a field shows; writing sets a value on every selected anchor,\n * or offsets each by an amount.\n */\n\nimport { anchorAt, moveHandleTo, translateAnchorBy, type AnchorSet } from './anchorEdits';\nimport type { PenAnchor } from './anchors';\n\n/** One number of an anchor. Handle angles are degrees counterclockwise from\n * +x as drawn, where y grows downward; lengths and positions are in the\n * set's own units. */\nexport type AnchorField =\n | 'x' | 'y'\n | 'inX' | 'inY' | 'inAngle' | 'inLength'\n | 'outX' | 'outY' | 'outAngle' | 'outLength';\n\n/** Every {@link AnchorField}, in the order a panel lists them. */\nexport const ANCHOR_FIELDS: readonly AnchorField[] = [\n 'x', 'y', 'inX', 'inY', 'inAngle', 'inLength', 'outX', 'outY', 'outAngle', 'outLength',\n];\n\n/** What a typed field asks for: a value for every anchor, or an amount added to each one's own. */\nexport type NumberEntry = { to: number } | { by: number };\n\n/**\n * What each field shows for the anchors at `flatIndexes`: a number where\n * they agree, `null` where they differ, and no key for a field that does not\n * apply. Position applies to any selection; handle fields only to a single\n * anchor, and only for a handle it has.\n */\nexport type AnchorFieldValues = Partial<Record<AnchorField, number | null>>;\n\n/** Differences below this read as agreement, so float noise does not show as mixed. */\nconst SAME = 1e-6;\n\n/** The fields for the anchors at `flatIndexes`; `{}` when none of them exists. */\nexport function readAnchorFields(set: AnchorSet, flatIndexes: Iterable<number>): AnchorFieldValues {\n const anchors = [...new Set(flatIndexes)].flatMap((flat) => anchorAt(set, flat) ?? []);\n if (anchors.length === 0) return {};\n const out: AnchorFieldValues = { x: agreed(anchors.map((a) => a.x)), y: agreed(anchors.map((a) => a.y)) };\n if (anchors.length !== 1) return out;\n const [a] = anchors;\n for (const side of ['in', 'out'] as const) {\n const h = handleOf(a, side);\n if (!h) continue;\n out[`${side}X`] = h.x;\n out[`${side}Y`] = h.y;\n out[`${side}Angle`] = angleOf(a, h);\n out[`${side}Length`] = Math.hypot(h.x - a.x, h.y - a.y);\n }\n return out;\n}\n\n/**\n * Write `entry` into `field` of every anchor at `flatIndexes`. Moving an\n * anchor carries its handles. A handle field moves the handle as a drag to\n * the typed spot would (`moveHandleTo`): on a smooth anchor the opposite\n * handle mirrors it, taking its turn and its length, and on a corner it stays\n * where it is. An anchor without that handle is skipped. An angle keeps the\n * handle's length, and a length keeps its angle. Returns whether anything\n * moved.\n */\nexport function writeAnchorField(\n set: AnchorSet,\n flatIndexes: Iterable<number>,\n field: AnchorField,\n entry: NumberEntry,\n): boolean {\n if (!Number.isFinite('to' in entry ? entry.to : entry.by)) return false;\n let changed = false;\n for (const flat of new Set(flatIndexes)) {\n const a = anchorAt(set, flat);\n if (!a) continue;\n if (field === 'x' || field === 'y') {\n const next = apply(a[field], entry);\n if (next === a[field]) continue;\n translateAnchorBy(set, flat, field === 'x' ? next - a.x : 0, field === 'y' ? next - a.y : 0);\n changed = true;\n continue;\n }\n const side = field.startsWith('in') ? 'in' : 'out';\n const h = handleOf(a, side);\n if (!h) continue;\n const to = handleTarget(a, h, field.slice(side.length) as 'X' | 'Y' | 'Angle' | 'Length', entry);\n if (to.x === h.x && to.y === h.y) continue;\n moveHandleTo(set, flat, side, to.x, to.y, false);\n changed = true;\n }\n return changed;\n}\n\ntype Point = { x: number; y: number };\n\nfunction handleOf(a: PenAnchor, side: 'in' | 'out'): Point | undefined {\n return side === 'in' ? a.inHandle : a.outHandle;\n}\n\nfunction handleTarget(a: PenAnchor, h: Point, part: 'X' | 'Y' | 'Angle' | 'Length', entry: NumberEntry): Point {\n if (part === 'X') return { x: apply(h.x, entry), y: h.y };\n if (part === 'Y') return { x: h.x, y: apply(h.y, entry) };\n const length = Math.hypot(h.x - a.x, h.y - a.y);\n const angle = angleOf(a, h);\n const nextAngle = part === 'Angle' ? apply(angle, entry) : angle;\n const nextLength = part === 'Length' ? Math.max(0, apply(length, entry)) : length;\n const rad = (nextAngle * Math.PI) / 180;\n return { x: a.x + Math.cos(rad) * nextLength, y: a.y - Math.sin(rad) * nextLength };\n}\n\nfunction apply(current: number, entry: NumberEntry): number {\n return 'to' in entry ? entry.to : current + entry.by;\n}\n\nfunction angleOf(a: Point, h: Point): number {\n if (h.x === a.x && h.y === a.y) return 0;\n return (Math.atan2(a.y - h.y, h.x - a.x) * 180) / Math.PI;\n}\n\nfunction agreed(values: number[]): number | null {\n const first = values[0];\n return values.every((v) => Math.abs(v - first) < SAME) ? first : null;\n}\n","/**\n * Project a leaf path from its source frame into world coordinates given a\n * `{x, y, width, height, rotation?}` pose.\n *\n * RectPaths can't carry rotation as-is (they're axis-aligned by definition);\n * a non-zero `pose.rotation` on a rect promotes the result to a polygon so\n * the four corners are baked into world coords.\n */\n\nimport { applyToPoint, boxToBox } from '../affine';\nimport type { Path, PolygonPath } from '../path';\nimport { poseFrameInverseOf, poseFrameOf, type PoseLinear } from '../poseFrame';\nimport { boundsOfPath } from './bounds';\nimport { translatePath } from './transform';\nimport { transformPath } from './transformPath';\n\n/** Subset of pose fields this helper consumes: `x/y/width/height` define an\n * AABB whose unrotated center is the rotation pivot. */\nexport interface PathInWorldPose {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n transform?: PoseLinear;\n}\n\n/**\n * Project a stored path into the pose's **local frame**: rebase its AABB onto\n * the pose box. It does NOT apply `pose.rotation`; `pathInWorld` composes\n * this with the rotation wrap.\n *\n * Rects rebase onto the pose's `width`/`height` because resize updates the pose,\n * not the stored `RectPath` — so the live size lives on the pose.\n */\nexport function pathInPoseFrame(path: Path, pose: PathInWorldPose): Path {\n if (path.kind === 'rect') {\n if (\n path.x === pose.x && path.y === pose.y\n && path.width === pose.width && path.height === pose.height\n ) return path;\n return { kind: 'rect', x: pose.x, y: pose.y, width: pose.width, height: pose.height };\n }\n // Polygon: rebase the path's own AABB into the pose box. For geometry-in-data\n // nodes whose pose box was resized independently, it scales the contents to fill the box.\n const b = boundsOfPath(path);\n if (b.x === pose.x && b.y === pose.y && b.width === pose.width && b.height === pose.height) {\n return path;\n }\n const m = boxToBox(b.x, b.y, b.width, b.height, pose.x, pose.y, pose.width, pose.height);\n return transformPath(path, m);\n}\n\n/**\n * Bake `pose` into `path`'s coordinates so the returned path is positioned\n * in world space. Returns a fresh `Path` instance; never mutates inputs.\n */\nexport function pathInWorld(path: Path, pose: PathInWorldPose): Path {\n // Shares `pathInPoseFrame` with the renderer so world geometry never diverges\n // from what's painted.\n const local = pathInPoseFrame(path, pose);\n\n // The pose's rotation and its `transform` about its AABB center, composed by\n // `poseFrameOf` as the renderer's wrap composes them.\n const frame = poseFrameOf(pose);\n if (!frame) return local;\n return transformPath(local, frame) as PolygonPath;\n}\n\n/**\n * Inverse of `pathInWorld` for a path in **world** space: the stored path\n * in the pose's own frame plus the pose that draws it there. The pose's\n * `rotation` and `transform` are preserved, and its AABB fields are fit to\n * the result. The new box's center is placed where the old frame carries it,\n * since the pivot moves with the box: `pathInWorld(result.path, result.pose)`\n * reproduces `worldPath` whether or not its bounds changed.\n */\nexport function worldEditToStorage<P extends PathInWorldPose>(\n pose: P,\n worldPath: PolygonPath,\n): { pose: P; path: PolygonPath };\nexport function worldEditToStorage<P extends PathInWorldPose>(pose: P, worldPath: Path): { pose: P; path: Path };\nexport function worldEditToStorage<P extends PathInWorldPose>(\n pose: P,\n worldPath: Path,\n): { pose: P; path: Path } {\n // A singular `transform` has no way back, and the path is stored as drawn.\n const back = poseFrameInverseOf(pose);\n const frame = back && poseFrameOf(pose);\n const unrotated = back ? transformPath(worldPath, back) : worldPath;\n const b = boundsOfPath(unrotated);\n const aligned = translatePath(unrotated, -b.x, -b.y);\n let x = b.x, y = b.y;\n if (frame) {\n const [cx, cy] = applyToPoint(frame, b.x + b.width / 2, b.y + b.height / 2);\n x = cx - b.width / 2;\n y = cy - b.height / 2;\n }\n return {\n pose: { ...pose, x, y, width: b.width, height: b.height },\n path: aligned,\n };\n}\n","/** The constructor of each typed array of numbers, under the tag its type is written by. */\nexport const TYPED_ARRAY_CONSTRUCTORS = {\n i8: Int8Array,\n u8: Uint8Array,\n u8c: Uint8ClampedArray,\n i16: Int16Array,\n u16: Uint16Array,\n i32: Int32Array,\n u32: Uint32Array,\n f32: Float32Array,\n f64: Float64Array,\n} as const;\n\n/** The name a typed array's type is written under. */\nexport type TypedArrayTag = keyof typeof TYPED_ARRAY_CONSTRUCTORS;\n\n/** A typed array of numbers: what a `Path` keeps its commands and coords in. */\nexport type NumberTypedArray = InstanceType<(typeof TYPED_ARRAY_CONSTRUCTORS)[TypedArrayTag]>;\n\n/** A typed array as JSON holds it: its type's tag and its numbers. */\nexport interface TaggedTypedArray {\n __ta: TypedArrayTag;\n data: number[];\n}\n\nconst TAGS = new Map<string, TypedArrayTag>(\n (Object.keys(TYPED_ARRAY_CONSTRUCTORS) as TypedArrayTag[]).map((tag) => [TYPED_ARRAY_CONSTRUCTORS[tag].name, tag]),\n);\n\n// By its string tag rather than `instanceof`, which is false for an array made in another realm.\nconst classOf = (value: unknown): string => Object.prototype.toString.call(value).slice(8, -1);\n\n/** `value` as a tag and its numbers where it is a typed array of numbers, else `undefined`. */\nexport function tagTypedArray(value: unknown): TaggedTypedArray | undefined {\n if (!ArrayBuffer.isView(value)) return undefined;\n const tag = TAGS.get(classOf(value));\n return tag && { __ta: tag, data: Array.from(value as NumberTypedArray) };\n}\n\n/** The typed array a `TaggedTypedArray` describes, or `undefined` for anything else. */\nexport function untagTypedArray(value: unknown): NumberTypedArray | undefined {\n if (value === null || typeof value !== 'object') return undefined;\n const { __ta: tag, data } = value as Partial<TaggedTypedArray>;\n if (typeof tag !== 'string' || !Object.hasOwn(TYPED_ARRAY_CONSTRUCTORS, tag) || !Array.isArray(data)) return undefined;\n return TYPED_ARRAY_CONSTRUCTORS[tag].from(data);\n}\n\nconst isPlain = (value: unknown): value is Record<string, unknown> => classOf(value) === 'Object';\n\nfunction mapDeep(value: unknown, leaf: (v: unknown) => unknown): unknown {\n const swapped = leaf(value);\n if (swapped !== undefined) return swapped;\n if (Array.isArray(value)) return value.map((v) => mapDeep(v, leaf));\n if (!isPlain(value)) return value;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value)) out[key] = mapDeep(value[key], leaf);\n return out;\n}\n\n/**\n * A copy of `value` that `JSON.stringify` writes whole: every typed array in it, at any\n * depth of arrays and plain objects, becomes a `TaggedTypedArray`. A `Path` goes through it\n * to be saved, and `reviveTypedArrays` reads it back.\n */\nexport function tagTypedArrays(value: unknown): unknown {\n return mapDeep(value, tagTypedArray);\n}\n\n/** A copy of `value` with every `TaggedTypedArray` in it a typed array again: what\n * `JSON.parse` answered for something `tagTypedArrays` or `typedArrayReplacer` wrote. */\nexport function reviveTypedArrays(value: unknown): unknown {\n return mapDeep(value, untagTypedArray);\n}\n\n/** `tagTypedArrays` as a `JSON.stringify` replacer. */\nexport function typedArrayReplacer(_key: string, value: unknown): unknown {\n return tagTypedArray(value) ?? value;\n}\n"]}
|