@pixerate/editor 0.113.0 → 0.115.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/THIRD_PARTY_NOTICES.md +8 -0
- package/dist/animation-editor/index.cjs +60 -54
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +3 -3
- package/dist/animation-editor/index.d.ts +3 -3
- package/dist/animation-editor/index.js +14 -8
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/builtin-CY97ppKM.d.cts +354 -0
- package/dist/builtin-CY97ppKM.d.ts +354 -0
- package/dist/canvas/index.cjs +3 -3
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.js +9 -9
- package/dist/chunk-26PGXHY7.cjs +753 -0
- package/dist/chunk-26PGXHY7.cjs.map +1 -0
- package/dist/chunk-2OJACTPR.cjs +929 -0
- package/dist/chunk-2OJACTPR.cjs.map +1 -0
- package/dist/chunk-3UFGNHSP.js +929 -0
- package/dist/chunk-3UFGNHSP.js.map +1 -0
- package/dist/chunk-643B2HKC.cjs +534 -0
- package/dist/chunk-643B2HKC.cjs.map +1 -0
- package/dist/chunk-6FCKOS2B.js +534 -0
- package/dist/chunk-6FCKOS2B.js.map +1 -0
- package/dist/chunk-BRLYOPLT.js +2574 -0
- package/dist/chunk-BRLYOPLT.js.map +1 -0
- package/dist/{chunk-LQEEDHOP.js → chunk-C6C5PDKU.js} +759 -761
- package/dist/chunk-C6C5PDKU.js.map +1 -0
- package/dist/{chunk-4KLT7ZYS.cjs → chunk-DFQEX3AM.cjs} +29 -29
- package/dist/{chunk-4KLT7ZYS.cjs.map → chunk-DFQEX3AM.cjs.map} +1 -1
- package/dist/chunk-G5NMLUVF.cjs +2574 -0
- package/dist/chunk-G5NMLUVF.cjs.map +1 -0
- package/dist/{chunk-YGIMK4NX.cjs → chunk-I7FQBWMQ.cjs} +813 -842
- package/dist/chunk-I7FQBWMQ.cjs.map +1 -0
- package/dist/{chunk-LPYOIVLA.js → chunk-LKCYANMW.js} +3 -3
- package/dist/{chunk-W3GXSUSQ.cjs → chunk-LPLCWZTM.cjs} +5087 -1283
- package/dist/chunk-LPLCWZTM.cjs.map +1 -0
- package/dist/chunk-MMVHBKMM.js +753 -0
- package/dist/chunk-MMVHBKMM.js.map +1 -0
- package/dist/{chunk-POGBUYWE.cjs → chunk-ST7E3NEE.cjs} +857 -859
- package/dist/chunk-ST7E3NEE.cjs.map +1 -0
- package/dist/{chunk-7VOHOPLW.cjs → chunk-TCKIXI46.cjs} +59 -59
- package/dist/{chunk-7VOHOPLW.cjs.map → chunk-TCKIXI46.cjs.map} +1 -1
- package/dist/{chunk-XIOMMGPD.cjs → chunk-TFOPHZ3U.cjs} +1 -1
- package/dist/chunk-TFOPHZ3U.cjs.map +1 -0
- package/dist/{chunk-Z4BC6M74.js → chunk-UBIXVXPR.js} +2 -2
- package/dist/{chunk-BLWCAQCW.js → chunk-VXR7XWMF.js} +4574 -770
- package/dist/chunk-VXR7XWMF.js.map +1 -0
- package/dist/{chunk-CZOXTEMN.js → chunk-XICA4PVO.js} +392 -421
- package/dist/chunk-XICA4PVO.js.map +1 -0
- package/dist/{chunk-HNS7UHCM.js → chunk-XK5LZKBD.js} +1 -1
- package/dist/chunk-XK5LZKBD.js.map +1 -0
- package/dist/cms/index.cjs +146 -0
- package/dist/cms/index.cjs.map +1 -0
- package/dist/cms/index.d.cts +51 -0
- package/dist/cms/index.d.ts +51 -0
- package/dist/cms/index.js +146 -0
- package/dist/cms/index.js.map +1 -0
- package/dist/{export-CEXEzqBf.d.cts → export-BJE8T0YA.d.cts} +279 -191
- package/dist/{export-DIkoK8-r.d.ts → export-Con3UKkm.d.ts} +279 -191
- package/dist/image-editor/index.cjs +1848 -1218
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +85 -93
- package/dist/image-editor/index.d.ts +85 -93
- package/dist/image-editor/index.js +871 -241
- package/dist/image-editor/index.js.map +1 -1
- package/dist/opentype-BZEOSOX3.d.ts +188 -0
- package/dist/opentype-Dpe75vL5.d.cts +188 -0
- package/dist/paint/index.cjs +4 -4
- package/dist/paint/index.d.cts +2 -2
- package/dist/paint/index.d.ts +2 -2
- package/dist/paint/index.js +3 -3
- package/dist/paint-editor/index.cjs +147 -145
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +9 -8
- package/dist/paint-editor/index.d.ts +9 -8
- package/dist/paint-editor/index.js +7 -5
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +53 -3
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +62 -91
- package/dist/raster/index.d.ts +62 -91
- package/dist/raster/index.js +59 -9
- package/dist/{render-BEriFuqK.d.cts → render-B1K_OoLy.d.cts} +87 -2
- package/dist/{render-tjzKaik-.d.ts → render-CrmHOgpo.d.ts} +87 -2
- package/dist/{retouch-CEIKR22W.d.cts → retouch-Bxkuc0KH.d.cts} +1 -1
- package/dist/{retouch-BXmeSCaB.d.ts → retouch-Do6tBs2H.d.ts} +1 -1
- package/dist/{surface-C8RRg_Bh.d.cts → surface-Cn30xIV6.d.cts} +6 -1
- package/dist/{surface-C8RRg_Bh.d.ts → surface-Cn30xIV6.d.ts} +6 -1
- package/dist/{svg-D_cfkhlB.d.cts → svg-BnRj0q8i.d.cts} +16 -4
- package/dist/{svg-wIaKLrU0.d.ts → svg-CmmBFfGT.d.ts} +16 -4
- package/dist/{types-DtL_qLFz.d.ts → types-1SUQKDAw.d.ts} +273 -4
- package/dist/{types-DyQq-WPY.d.cts → types-yINF17Ta.d.cts} +273 -4
- package/dist/vector/index.cjs +12170 -7343
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +1579 -16
- package/dist/vector/index.d.ts +1579 -16
- package/dist/vector/index.js +6303 -1476
- package/dist/vector/index.js.map +1 -1
- package/dist/warp-B39VsOtd.d.cts +348 -0
- package/dist/warp-DMN30aY6.d.ts +348 -0
- package/dist/zlib-dxQdgHyN.d.cts +95 -0
- package/dist/zlib-dxQdgHyN.d.ts +95 -0
- package/package.json +9 -2
- package/skills/pixerate-image-editor/SKILL.md +13 -36
- package/skills/pixerate-image-editor/references/color-management.md +42 -0
- package/skills/pixerate-image-editor/references/photoshop-files.md +41 -0
- package/skills/pixerate-paint-editor/SKILL.md +136 -4
- package/skills/pixerate-vector/SKILL.md +72 -2
- package/dist/chunk-BLWCAQCW.js.map +0 -1
- package/dist/chunk-CZOXTEMN.js.map +0 -1
- package/dist/chunk-HNS7UHCM.js.map +0 -1
- package/dist/chunk-JLYX4V57.cjs +0 -2001
- package/dist/chunk-JLYX4V57.cjs.map +0 -1
- package/dist/chunk-KB2YBCVS.js +0 -2001
- package/dist/chunk-KB2YBCVS.js.map +0 -1
- package/dist/chunk-LQEEDHOP.js.map +0 -1
- package/dist/chunk-POGBUYWE.cjs.map +0 -1
- package/dist/chunk-W3GXSUSQ.cjs.map +0 -1
- package/dist/chunk-XIOMMGPD.cjs.map +0 -1
- package/dist/chunk-YGIMK4NX.cjs.map +0 -1
- package/dist/homography-CZ-tFjay.d.cts +0 -50
- package/dist/homography-Ctfjoc1b.d.ts +0 -50
- package/dist/warp-CWHZzE3x.d.ts +0 -118
- package/dist/warp-D5jz_tN7.d.cts +0 -118
- /package/dist/{chunk-LPYOIVLA.js.map → chunk-LKCYANMW.js.map} +0 -0
- /package/dist/{chunk-Z4BC6M74.js.map → chunk-UBIXVXPR.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/blend.ts","../src/vector/gradientStroke.ts","../src/vector/svg.ts"],"sourcesContent":["// Portions ported from effectcraft-main/crates/path/src/interp.rs, vectorcraft-main/crates/doc/src/blend.rs and deckcraft-main/crates/geom/src/morph.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n/**\n * Morphing between vector paths: bring two shapes to matching anchors, then compute in-betweens.\n *\n * - **Contours** pair up in order. A contour without a partner grows out of (or shrinks into) a\n * point at the same place relative to the other shape's box. Straight segments become cubics\n * with handles at a third of the way, so a line bends smoothly into a curve.\n * - **Anchors** are inserted by arc length with de Casteljau splits, so both contours of a pair\n * keep their exact outline and get the same number of segments, spread over the segments in\n * proportion to their length.\n * - **Correspondence**: the closed side of each pair is turned to the cyclic start that costs\n * least — the position differences left after the best-fit rotation (both shapes centred and\n * scaled to unit size), a little for the turn, plus the χ² distance of log-polar\n * shape-context histograms (Belongie, Malik & Puzicha, PAMI 2002; angles taken from the\n * contour's direction) — and the winding is chosen once for all contours (the first closed\n * pair turns the same way), so a nonzero fill keeps its holes.\n * - **In-betweens** follow the shapes' best-fit rotation and scale (Procrustes), with the\n * leftover difference blended in linearly, so a turning shape turns instead of collapsing.\n * - **Paint**: colours mix in OKLab, gradients of one style resample their stops to a common\n * set, a missing paint fades from transparent; stroke width, opacity, dashes, arrowhead\n * scales and width profiles interpolate, and the rest switches halfway.\n * - **Transforms**: both shapes are blended in their parent's space; the in-between's rigid\n * `transform` interpolates as a rotation (the short way round) plus a translation.\n *\n * Live corners are cut into the geometry first, so rounded corners morph as curves.\n */\nimport type { Point } from '../canvas/types.js';\nimport { segmentLength, segmentParamAtLength, splitSegment } from '../canvas/pathops/bezier.js';\nimport { expandVectorGradientStops, explicitVectorGradient, hasExplicitGradientGeometry, isVectorGradient, sampleVectorGradient, sortedVectorGradientStops, vectorGradientPoints } from './gradient.js';\nimport { mixColorsOklab } from '../animation/color.js';\nimport { evaluateEasing, type AnimationEasing } from '../animation/easing.js';\nimport { expandVectorCorners } from './corners.js';\nimport {\n\tapplyMatrix,\n\thasPaint,\n\tIDENTITY_MATRIX,\n\tinferAnchorType,\n\tinvertMatrix,\n\tisIdentityMatrix,\n\tmultiplyMatrices,\n\tnodeMatrix,\n\tunionBounds,\n\ttype AffineMatrix\n} from './geometry.js';\nimport { reverseWidthProfile, widthProfileAt } from './width.js';\nimport type { Vec2, VectorAnchor, VectorBounds, VectorGradient, VectorGradientStop, VectorGroupNode, VectorNode, VectorPaint, VectorPathNode, VectorStyle, VectorSubpath, VectorWidthPoint } from './types.js';\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface VectorMorphOptions {\n\t/**\n\t * Move anchors in straight lines instead of following the shapes' best-fit rotation and\n\t * scale. Default `false`.\n\t */\n\tlinear?: boolean;\n\t/** 0–1: how much the rotation-aware path outweighs the straight one (default 1). */\n\trigidity?: number;\n\t/** Fewest segments each contour pair gets (default 16). */\n\tminSegments?: number;\n\t/** At most this far apart (document units) along the longer contour, when set. */\n\tspacing?: number | null;\n\t/** Most segments a contour pair gets (default 400). */\n\tmaxSegments?: number;\n\t/** Search the start anchor of closed contours (default `true`); off keeps the stored starts. */\n\tmatchStart?: boolean;\n\t/** Compare shape-context histograms when choosing starts (default `true`). */\n\tshapeContext?: boolean;\n\t/**\n\t * The anchor each shape's first subpath starts from (the Blend tool's clicks). A closed\n\t * subpath turns round to it; an open one clicked at its last anchor runs backwards.\n\t */\n\tstarts?: readonly [number | null | undefined, number | null | undefined];\n\t/** Id of the in-between (default: the first shape's id). */\n\tid?: string;\n}\n\n/** Two shapes prepared once; `at(t)` interpolates (0 = `a`, 1 = `b`). */\nexport interface VectorMorph {\n\tat(t: number): VectorNode;\n}\n\n// ---------------------------------------------------------------------------\n// Point helpers\n// ---------------------------------------------------------------------------\n\nconst lerpN = (a: number, b: number, t: number) => a + (b - a) * t;\nconst lerpP = (a: Point, b: Point, t: number): Point => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];\nconst toP = (v: { x: number; y: number }): Point => [v.x, v.y];\nconst mapP = (m: AffineMatrix, p: Point): Point => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];\n\n// ---------------------------------------------------------------------------\n// Contours: a start anchor, then three points (handle, handle, anchor) per cubic segment\n// ---------------------------------------------------------------------------\n\n/** A subpath as cubics. A closed contour's last point repeats its first. */\nexport interface VectorMorphContour {\n\tclosed: boolean;\n\tpts: Point[];\n}\n\nconst curvesOf = (c: VectorMorphContour) => Math.max(0, (c.pts.length - 1) / 3) | 0;\n\n/** A subpath mapped by `m` as cubics (lines with handles at thirds), or null when empty. */\nexport function subpathToMorphContour(sp: VectorSubpath, m: AffineMatrix = IDENTITY_MATRIX): VectorMorphContour | null {\n\tconst n = sp.anchors.length;\n\tif (!n) return null;\n\tconst first = mapP(m, toP(sp.anchors[0]));\n\tconst pts: Point[] = [first];\n\tconst count = n < 2 ? 0 : sp.closed ? n : n - 1;\n\tfor (let i = 0; i < count; i++) {\n\t\tconst a = sp.anchors[i];\n\t\tconst b = sp.anchors[(i + 1) % n];\n\t\tconst pa = toP(a);\n\t\tconst pb = toP(b);\n\t\tconst straight = (!a.out || (a.out.x === a.x && a.out.y === a.y)) && (!b.in || (b.in.x === b.x && b.in.y === b.y));\n\t\tconst c1 = straight ? lerpP(pa, pb, 1 / 3) : toP(a.out ?? a);\n\t\tconst c2 = straight ? lerpP(pa, pb, 2 / 3) : toP(b.in ?? b);\n\t\tpts.push(mapP(m, c1), mapP(m, c2), i === count - 1 && sp.closed ? first : mapP(m, pb));\n\t}\n\treturn { closed: sp.closed && count > 0, pts };\n}\n\n/** Whether the cubic's handles lie on its chord (it draws a straight line). */\nfunction isStraight(p0: Point, p1: Point, p2: Point, p3: Point): boolean {\n\tconst dx = p3[0] - p0[0];\n\tconst dy = p3[1] - p0[1];\n\tconst len = Math.hypot(dx, dy);\n\tconst tol = Math.max(1e-7, len * 1e-7);\n\tif (len < 1e-12) return Math.hypot(p1[0] - p0[0], p1[1] - p0[1]) < tol && Math.hypot(p2[0] - p0[0], p2[1] - p0[1]) < tol;\n\tconst off = (p: Point) => Math.abs((p[0] - p0[0]) * dy - (p[1] - p0[1]) * dx) / len;\n\tconst along = (p: Point) => ((p[0] - p0[0]) * dx + (p[1] - p0[1]) * dy) / (len * len);\n\tconst u1 = along(p1);\n\tconst u2 = along(p2);\n\treturn off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;\n}\n\n/** A contour back to a subpath (`m` maps it out of the morph's space). Straight cubics become lines. */\nexport function morphContourToSubpath(c: VectorMorphContour, m: AffineMatrix = IDENTITY_MATRIX, closed = c.closed): VectorSubpath {\n\tconst pts = isIdentityMatrix(m) ? c.pts : c.pts.map((p) => mapP(m, p));\n\tconst curves = curvesOf(c);\n\t// A closed contour drops its repeated last anchor; one opened mid-morph keeps it.\n\tconst dropLast = closed && c.closed && curves > 0;\n\tconst count = dropLast ? curves : curves + 1;\n\tconst anchors: VectorAnchor[] = [];\n\tfor (let k = 0; k < count; k++) anchors.push({ x: pts[3 * k][0], y: pts[3 * k][1] });\n\tfor (let k = 0; k < curves; k++) {\n\t\tconst p0 = pts[3 * k];\n\t\tconst p1 = pts[3 * k + 1];\n\t\tconst p2 = pts[3 * k + 2];\n\t\tconst p3 = pts[3 * k + 3];\n\t\tif (isStraight(p0, p1, p2, p3)) continue;\n\t\tanchors[k].out = { x: p1[0], y: p1[1] };\n\t\tanchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };\n\t}\n\tfor (const a of anchors) {\n\t\tconst type = inferAnchorType(a);\n\t\tif (type !== 'corner') a.type = type;\n\t}\n\tconst isClosed = closed && curves > 0;\n\treturn { anchors: dropCollinear(anchors, isClosed), closed: isClosed };\n}\n\n/** Anchors without the ones that sit inside a straight run (no handles, in line with both neighbours). */\nfunction dropCollinear(anchors: VectorAnchor[], closed: boolean): VectorAnchor[] {\n\tconst out = anchors.slice();\n\tconst min = closed ? 3 : 2;\n\tlet i = closed ? 0 : 1;\n\twhile (out.length > min && i < out.length - (closed ? 0 : 1)) {\n\t\tconst n = out.length;\n\t\tconst a = out[(i - 1 + n) % n];\n\t\tconst b = out[i];\n\t\tconst c = out[(i + 1) % n];\n\t\tconst plain = !b.in && !b.out && !a.out && !c.in;\n\t\tconst ux = b.x - a.x;\n\t\tconst uy = b.y - a.y;\n\t\tconst vx = c.x - b.x;\n\t\tconst vy = c.y - b.y;\n\t\tconst len = Math.hypot(ux, uy) + Math.hypot(vx, vy);\n\t\tif (plain && Math.abs(ux * vy - uy * vx) <= 1e-9 * Math.max(1, len * len) && ux * vx + uy * vy >= 0) out.splice(i, 1);\n\t\telse i++;\n\t}\n\treturn out;\n}\n\nconst segOf = (c: VectorMorphContour, k: number): Point[] => c.pts.slice(3 * k, 3 * k + 4);\n\n/**\n * Exactly the same outline with `segments` cubics (at least as many as it has), the new\n * anchors spread over its segments in proportion to their arc length (largest remainder)\n * and each segment split into pieces of equal arc length. Also returns where each original\n * anchor went.\n */\nexport function refineMorphContour(c: VectorMorphContour, segments: number): { contour: VectorMorphContour; anchors: number[] } {\n\tconst have = curvesOf(c);\n\tif (have === 0) return { contour: { closed: c.closed, pts: Array.from({ length: 1 + 3 * segments }, () => [c.pts[0][0], c.pts[0][1]] as Point) }, anchors: [0] };\n\tconst identity = Array.from({ length: c.closed ? have : have + 1 }, (_, i) => i);\n\tif (have >= segments) return { contour: c, anchors: identity };\n\tconst segs = Array.from({ length: have }, (_, k) => segOf(c, k));\n\tconst lens = segs.map((s) => segmentLength(s));\n\tconst sum = lens.reduce((a, b) => a + b, 0);\n\tconst extra = segments - have;\n\tconst want = lens.map((l) => (sum > 1e-12 ? (l / sum) * extra : extra / have));\n\tconst parts = want.map((w) => 1 + Math.floor(w));\n\tlet left = segments - parts.reduce((a, b) => a + b, 0);\n\t// Remainders that differ by rounding noise tie, so congruent shapes split alike.\n\tconst frac = want.map((w) => w - Math.floor(w));\n\tconst order = parts.map((_, i) => i).sort((a, b) => (Math.abs(frac[b] - frac[a]) > 1e-9 ? frac[b] - frac[a] : a - b));\n\tfor (let i = 0; left > 0; i = (i + 1) % order.length, left--) parts[order[i]]++;\n\tconst pts: Point[] = [c.pts[0]];\n\tconst anchors: number[] = [0];\n\tlet at = 0;\n\tsegs.forEach((seg, k) => {\n\t\tconst pieces = parts[k];\n\t\tlet rest: Point[] = seg.slice();\n\t\tlet t0 = 0;\n\t\tfor (let j = 1; j < pieces; j++) {\n\t\t\tconst t = segmentParamAtLength(seg, (lens[k] * j) / pieces, lens[k]);\n\t\t\tconst u = Math.min(1, Math.max(0, (t - t0) / (1 - t0 || 1)));\n\t\t\tconst [l, r] = splitSegment(rest, u);\n\t\t\tpts.push(l[1], l[2], l[3]);\n\t\t\trest = r;\n\t\t\tt0 = t;\n\t\t}\n\t\tpts.push(rest[1], rest[2], k === have - 1 && c.closed ? c.pts[0] : rest[3]);\n\t\tat += pieces;\n\t\tif (k < have - 1 || !c.closed) anchors.push(at);\n\t});\n\treturn { contour: { closed: c.closed, pts }, anchors };\n}\n\n/** The same contour run backwards (a closed one keeps its start anchor). */\nexport function reverseMorphContour(c: VectorMorphContour): VectorMorphContour {\n\treturn { closed: c.closed, pts: c.pts.slice().reverse() };\n}\n\n/** A closed contour starting at anchor `s` (deckcraft's `turn`). */\nexport function turnMorphContour(c: VectorMorphContour, s: number): VectorMorphContour {\n\tconst n = curvesOf(c);\n\tif (!c.closed || n === 0) return c;\n\tconst k = ((s % n) + n) % n;\n\tif (k === 0) return c;\n\tconst body = c.pts.slice(1);\n\treturn { closed: true, pts: [c.pts[3 * k], ...body.slice(3 * k), ...body.slice(0, 3 * k)] };\n}\n\n/** Anchor positions of a contour (a closed one without its repeated end). */\nfunction anchorPoints(c: VectorMorphContour): Point[] {\n\tconst n = curvesOf(c);\n\tconst count = c.closed ? n : n + 1;\n\treturn Array.from({ length: Math.max(1, count) }, (_, k) => c.pts[3 * k]);\n}\n\n/** Signed area of a contour's anchor polygon. */\nfunction polygonArea(pts: readonly Point[]): number {\n\tlet s = 0;\n\tfor (let i = 0; i < pts.length; i++) {\n\t\tconst a = pts[i];\n\t\tconst b = pts[(i + 1) % pts.length];\n\t\ts += a[0] * b[1] - b[0] * a[1];\n\t}\n\treturn s / 2;\n}\n\n// ---------------------------------------------------------------------------\n// Correspondence\n// ---------------------------------------------------------------------------\n\n/** Centroid and RMS radius. */\nfunction frame(v: readonly Point[]): { c: Point; r: number } {\n\tconst n = Math.max(1, v.length);\n\tlet cx = 0;\n\tlet cy = 0;\n\tfor (const p of v) {\n\t\tcx += p[0];\n\t\tcy += p[1];\n\t}\n\tcx /= n;\n\tcy /= n;\n\tlet s = 0;\n\tfor (const p of v) s += (p[0] - cx) ** 2 + (p[1] - cy) ** 2;\n\treturn { c: [cx, cy], r: Math.max(1e-9, Math.sqrt(s / n)) };\n}\n\nconst RBINS = 5;\nconst ABINS = 12;\n/** Weight of the turn a start implies: among starts that fit equally well, the least turning wins. */\nconst TURN_WEIGHT = 0.1;\n\n/**\n * Log-polar shape-context histograms of every point, distances normalised by the RMS radius and\n * angles measured from the contour's direction at the point, so turning a shape leaves them\n * unchanged (only the fit below decides how far it turns).\n */\nfunction shapeContexts(v: readonly Point[], closed: boolean): Float64Array[] {\n\tconst { r } = frame(v);\n\tconst n = v.length;\n\treturn v.map((p, i) => {\n\t\tconst prev = v[closed ? (i - 1 + n) % n : Math.max(0, i - 1)];\n\t\tconst next = v[closed ? (i + 1) % n : Math.min(n - 1, i + 1)];\n\t\tconst dir = Math.atan2(next[1] - prev[1], next[0] - prev[0]);\n\t\tconst h = new Float64Array(RBINS * ABINS);\n\t\tlet total = 0;\n\t\tfor (let j = 0; j < n; j++) {\n\t\t\tif (i === j) continue;\n\t\t\tconst dx = v[j][0] - p[0];\n\t\t\tconst dy = v[j][1] - p[1];\n\t\t\tconst d = Math.hypot(dx, dy) / r;\n\t\t\t// log radius in [1/8, 2] → five bins.\n\t\t\tconst lr = ((Math.log2(Math.max(d, 1e-6)) + 3) / 4) * RBINS;\n\t\t\tif (!(lr >= 0 && lr < RBINS)) continue;\n\t\t\tlet ang = Math.atan2(dy, dx) - dir;\n\t\t\tang = ((ang % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI);\n\t\t\th[Math.floor(lr) * ABINS + Math.min(ABINS - 1, Math.floor((ang / (2 * Math.PI)) * ABINS))] += 1;\n\t\t\ttotal++;\n\t\t}\n\t\tif (total > 0) for (let k = 0; k < h.length; k++) h[k] /= total;\n\t\treturn h;\n\t});\n}\n\nfunction chi2(a: Float64Array, b: Float64Array): number {\n\tlet s = 0;\n\tfor (let k = 0; k < a.length; k++) {\n\t\tconst t = a[k] + b[k];\n\t\tif (t > 1e-12) s += ((a[k] - b[k]) * (a[k] - b[k])) / t;\n\t}\n\treturn s / 2;\n}\n\n/**\n * The cyclic start of the closed `free` contour that matches `fixed` best, and its cost. Both\n * shapes are centred and scaled to unit RMS radius (where and how big they are does not\n * matter); a start costs what is left after the best rotation maps one onto the other, plus a\n * little for how far that rotation turns, plus (optionally) the mean χ² shape-context\n * distance. So a turned copy of a shape matches by turning rather than by squashing.\n */\nfunction bestStart(fixed: VectorMorphContour, free: VectorMorphContour, useShapeContext: boolean): { start: number; cost: number } {\n\tconst fa = anchorPoints(fixed);\n\tconst ga = anchorPoints(free);\n\tconst n = ga.length;\n\tconst ff = frame(fa);\n\tconst gf = frame(ga);\n\tconst fn = fa.map((p): Point => [(p[0] - ff.c[0]) / ff.r, (p[1] - ff.c[1]) / ff.r]);\n\tconst gn = ga.map((p): Point => [(p[0] - gf.c[0]) / gf.r, (p[1] - gf.c[1]) / gf.r]);\n\tconst fsc = useShapeContext ? shapeContexts(fa, fixed.closed) : null;\n\tconst gsc = useShapeContext ? shapeContexts(ga, free.closed) : null;\n\tconst m = Math.max(1, fn.length);\n\tconst cost = (s: number) => {\n\t\tlet dot = 0;\n\t\tlet cross = 0;\n\t\tlet sc = 0;\n\t\tfor (let i = 0; i < fn.length; i++) {\n\t\t\tconst j = free.closed ? (i + s) % n : i;\n\t\t\tconst p = fn[i];\n\t\t\tconst q = gn[j];\n\t\t\tdot += p[0] * q[0] + p[1] * q[1];\n\t\t\tcross += p[0] * q[1] - p[1] * q[0];\n\t\t\tif (fsc && gsc) sc += chi2(fsc[i], gsc[j]);\n\t\t}\n\t\t// Unit RMS on both sides: what the best rotation and scale leave over, as a fraction.\n\t\tconst residual = Math.max(0, 1 - (dot * dot + cross * cross) / (m * m));\n\t\tconst turn = 1 - Math.cos(Math.atan2(cross, dot));\n\t\treturn residual + TURN_WEIGHT * turn + sc / m;\n\t};\n\tif (!free.closed) return { start: 0, cost: cost(0) };\n\t// Long contours: every few starts first, then the neighbours of the best.\n\tconst stride = n > 96 ? Math.ceil(n / 48) : 1;\n\tlet best = { start: 0, cost: Infinity };\n\tfor (let s = 0; s < n; s += stride) {\n\t\tconst c = cost(s);\n\t\tif (c < best.cost - 1e-12) best = { start: s, cost: c };\n\t}\n\tif (stride > 1) {\n\t\tconst s0 = best.start;\n\t\tfor (let d = 1; d < stride; d++)\n\t\t\tfor (const s of [(s0 + d) % n, (s0 - d + n) % n]) {\n\t\t\t\tconst c = cost(s);\n\t\t\t\tif (c < best.cost - 1e-12) best = { start: s, cost: c };\n\t\t\t}\n\t}\n\treturn best;\n}\n\n/** The spot a contour without partner grows from: the same place relative to the other shape's box. */\nfunction placeIn(c: VectorMorphContour, from: VectorBounds | null, to: VectorBounds | null): Point {\n\tconst b = unionBounds([boundsOfPoints(c.pts)]);\n\tconst p: Point = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];\n\tif (!from || !to) return p;\n\tconst fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;\n\tconst fy = from.height > 0 ? (p[1] - from.y) / from.height : 0.5;\n\treturn [to.x + to.width * fx, to.y + to.height * fy];\n}\n\nfunction boundsOfPoints(pts: readonly Point[]): VectorBounds | null {\n\tif (!pts.length) return null;\n\tlet x0 = Infinity;\n\tlet y0 = Infinity;\n\tlet x1 = -Infinity;\n\tlet y1 = -Infinity;\n\tfor (const p of pts) {\n\t\tx0 = Math.min(x0, p[0]);\n\t\ty0 = Math.min(y0, p[1]);\n\t\tx1 = Math.max(x1, p[0]);\n\t\ty1 = Math.max(y1, p[1]);\n\t}\n\treturn { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };\n}\n\n/** Two shapes' contours with matching structure: same count, and per pair the same segments. */\nexport interface VectorMorphCorrespondence {\n\ta: VectorMorphContour[];\n\tb: VectorMorphContour[];\n\t/** Whether `b` runs backwards relative to its stored direction. */\n\treversed: boolean;\n}\n\n/**\n * Gives two lists of contours the same structure with matching anchors (see the module notes).\n * Contours pair in order; one without a partner meets a point.\n */\nexport function correspondMorphContours(a: readonly VectorMorphContour[], b: readonly VectorMorphContour[], options: VectorMorphOptions = {}): VectorMorphCorrespondence {\n\tconst minSeg = Math.max(1, Math.round(options.minSegments ?? 16));\n\tconst maxSeg = Math.max(minSeg, Math.round(options.maxSegments ?? 400));\n\tconst spacing = options.spacing && options.spacing > 0 ? options.spacing : null;\n\tconst useSC = options.shapeContext !== false;\n\tconst match = options.matchStart !== false;\n\tconst ba = boundsOfPoints(a.flatMap((c) => c.pts));\n\tconst bb = boundsOfPoints(b.flatMap((c) => c.pts));\n\tconst contourLength = (c: VectorMorphContour) => {\n\t\tlet l = 0;\n\t\tfor (let k = 0; k < curvesOf(c); k++) l += segmentLength(segOf(c, k));\n\t\treturn l;\n\t};\n\ttype Pair = { x: VectorMorphContour; y: VectorMorphContour; point: boolean; startX: number | null; startY: number | null };\n\tconst pairs: Pair[] = [];\n\tconst [sa, sb] = options.starts ?? [];\n\tfor (let k = 0; k < Math.max(a.length, b.length); k++) {\n\t\tconst ca = a[k];\n\t\tconst cb = b[k];\n\t\tconst explicitA = k === 0 && sa !== null && sa !== undefined ? sa : null;\n\t\tconst explicitB = k === 0 && sb !== null && sb !== undefined ? sb : null;\n\t\tconst counts = [ca ? curvesOf(ca) : 0, cb ? curvesOf(cb) : 0];\n\t\tconst longest = Math.max(ca ? contourLength(ca) : 0, cb ? contourLength(cb) : 0);\n\t\tlet n = Math.max(counts[0], counts[1], minSeg, spacing ? Math.ceil(longest / spacing) : 0);\n\t\tn = Math.max(counts[0], counts[1], Math.min(n, maxSeg));\n\t\tconst point = (c: VectorMorphContour, from: VectorBounds | null, to: VectorBounds | null): VectorMorphContour => {\n\t\t\tconst p = placeIn(c, from, to);\n\t\t\treturn { closed: c.closed, pts: Array.from({ length: 1 + 3 * n }, () => [p[0], p[1]] as Point) };\n\t\t};\n\t\tif (ca && cb) {\n\t\t\tconst ra = refineMorphContour(ca, n);\n\t\t\tconst rb = refineMorphContour(cb, n);\n\t\t\tpairs.push({\n\t\t\t\tx: ra.contour,\n\t\t\t\ty: rb.contour,\n\t\t\t\tpoint: false,\n\t\t\t\tstartX: explicitA === null ? null : (ra.anchors[explicitA] ?? null),\n\t\t\t\tstartY: explicitB === null ? null : explicitB === rb.anchors.length - 1 && !cb.closed ? -1 : (rb.anchors[explicitB] ?? null)\n\t\t\t});\n\t\t\tif (explicitA !== null && !ca.closed && explicitA === ra.anchors.length - 1 && explicitA > 0) pairs[pairs.length - 1].startX = -1;\n\t\t} else if (ca) pairs.push({ x: refineMorphContour(ca, n).contour, y: point(ca, ba, bb), point: true, startX: null, startY: null });\n\t\telse if (cb) pairs.push({ x: point(cb, bb, ba), y: refineMorphContour(cb, n).contour, point: true, startX: null, startY: null });\n\t}\n\t// Explicit starts: closed contours turn to the clicked anchor; an open one clicked at its end runs backwards.\n\tconst startAt = (c: VectorMorphContour, s: number | null): VectorMorphContour => {\n\t\tif (s === null) return c;\n\t\tif (s === -1) return reverseMorphContour(c);\n\t\treturn c.closed ? turnMorphContour(c, s) : c;\n\t};\n\tconst explicit = pairs.length > 0 && (pairs[0].startX !== null || pairs[0].startY !== null);\n\t// Winding: closed shapes keep the same turning direction (effectcraft), judged on the first\n\t// pair of closed contours and applied to every contour so a nonzero fill keeps its holes;\n\t// open paths take whichever direction costs less (deckcraft), unless a click fixed it.\n\tconst ref = pairs.find((p) => !p.point && p.x.closed && p.y.closed);\n\tconst fixedBack = ref\n\t\t? Math.sign(polygonArea(anchorPoints(ref.x))) !== Math.sign(polygonArea(anchorPoints(ref.y))) && Math.abs(polygonArea(anchorPoints(ref.y))) > 1e-12\n\t\t: explicit\n\t\t\t? false\n\t\t\t: null;\n\tlet best: { xs: VectorMorphContour[]; ys: VectorMorphContour[]; cost: number; back: boolean } | null = null;\n\tfor (const back of fixedBack === null ? [false, true] : [fixedBack]) {\n\t\tconst xs: VectorMorphContour[] = [];\n\t\tconst ys: VectorMorphContour[] = [];\n\t\tlet cost = 0;\n\t\tpairs.forEach((p, k) => {\n\t\t\tlet x = k === 0 ? startAt(p.x, p.startX) : p.x;\n\t\t\tlet y = k === 0 ? startAt(p.y, p.startY) : p.y;\n\t\t\tif (back) y = reverseMorphContour(y);\n\t\t\tif (p.point) {\n\t\t\t\txs.push(x);\n\t\t\t\tys.push(y);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst pinned = k === 0 && explicit;\n\t\t\t// The closed side turns: `b` when it is closed, else `a`.\n\t\t\tconst turnX = !y.closed && x.closed;\n\t\t\tif (match && !pinned && (y.closed || turnX)) {\n\t\t\t\tconst r = turnX ? bestStart(y, x, useSC) : bestStart(x, y, useSC);\n\t\t\t\tif (turnX) x = turnMorphContour(x, r.start);\n\t\t\t\telse y = turnMorphContour(y, r.start);\n\t\t\t\tcost += r.cost;\n\t\t\t} else cost += bestStart(x, { ...y, closed: false }, useSC).cost;\n\t\t\txs.push(x);\n\t\t\tys.push(y);\n\t\t});\n\t\tif (!best || cost < best.cost - 1e-9) best = { xs, ys, cost, back };\n\t}\n\treturn best ? { a: best.xs, b: best.ys, reversed: best.back } : { a: [], b: [], reversed: false };\n}\n\n/**\n * How many pairs of straight anchor paths (from `a`'s anchor i to `b`'s anchor i) cross: a\n * sanity measure of a correspondence — good matches don't make anchors pass through each other.\n */\nexport function morphPathsCross(a: readonly VectorMorphContour[], b: readonly VectorMorphContour[]): number {\n\tlet count = 0;\n\tconst d = (p: Point, q: Point, r: Point) => (q[0] - p[0]) * (r[1] - p[1]) - (q[1] - p[1]) * (r[0] - p[0]);\n\tfor (let k = 0; k < Math.min(a.length, b.length); k++) {\n\t\tconst pa = anchorPoints(a[k]);\n\t\tconst pb = anchorPoints(b[k]);\n\t\tconst n = Math.min(pa.length, pb.length);\n\t\tfor (let i = 0; i < n; i++)\n\t\t\tfor (let j = i + 1; j < n; j++) {\n\t\t\t\tconst d1 = d(pa[j], pb[j], pa[i]);\n\t\t\t\tconst d2 = d(pa[j], pb[j], pb[i]);\n\t\t\t\tconst d3 = d(pa[i], pb[i], pa[j]);\n\t\t\t\tconst d4 = d(pa[i], pb[i], pb[j]);\n\t\t\t\tif (d1 * d2 < 0 && d3 * d4 < 0) count++;\n\t\t\t}\n\t}\n\treturn count;\n}\n\n// ---------------------------------------------------------------------------\n// In-betweens\n// ---------------------------------------------------------------------------\n\n/** The similarity (rotation θ, scale s, centroids) that best maps `a`'s anchors onto `b`'s. */\ninterface Similarity {\n\tca: Point;\n\tcb: Point;\n\ttheta: number;\n\ts: number;\n}\n\nfunction procrustes(a: readonly VectorMorphContour[], b: readonly VectorMorphContour[]): Similarity {\n\tconst pa = a.flatMap(anchorPoints);\n\tconst pb = b.flatMap(anchorPoints);\n\tconst ca = frame(pa).c;\n\tconst cb = frame(pb).c;\n\tlet ss = 0;\n\tlet dot = 0;\n\tlet cross = 0;\n\tfor (let i = 0; i < Math.min(pa.length, pb.length); i++) {\n\t\tconst p: Point = [pa[i][0] - ca[0], pa[i][1] - ca[1]];\n\t\tconst q: Point = [pb[i][0] - cb[0], pb[i][1] - cb[1]];\n\t\tss += p[0] * p[0] + p[1] * p[1];\n\t\tdot += p[0] * q[0] + p[1] * q[1];\n\t\tcross += p[0] * q[1] - p[1] * q[0];\n\t}\n\treturn { ca, cb, theta: Math.atan2(cross, dot), s: ss > 1e-12 ? Math.hypot(dot, cross) / ss : 1 };\n}\n\n/**\n * Corresponded contours at `u`: each point carried by the similarity interpolated to `u`\n * (rotation θu, scale sᵘ, centroid moving straight), plus `u` of what the full similarity\n * leaves over, blended with the straight path by `rigidity`.\n */\nexport function interpolateMorphContours(\n\ta: readonly VectorMorphContour[],\n\tb: readonly VectorMorphContour[],\n\tu: number,\n\toptions: Pick<VectorMorphOptions, 'linear' | 'rigidity'> & { similarity?: Similarity } = {}\n): VectorMorphContour[] {\n\tconst w = options.linear ? 0 : Math.min(1, Math.max(0, options.rigidity ?? 1));\n\tconst sim = w > 0 ? (options.similarity ?? procrustes(a, b)) : null;\n\tconst rot = (p: Point, ang: number, k: number): Point => {\n\t\tconst c = Math.cos(ang);\n\t\tconst s = Math.sin(ang);\n\t\treturn [k * (c * p[0] - s * p[1]), k * (s * p[0] + c * p[1])];\n\t};\n\tconst thetaU = sim ? sim.theta * u : 0;\n\tconst sU = sim ? Math.max(1e-9, sim.s) ** u : 1;\n\tconst cU = sim ? lerpP(sim.ca, sim.cb, u) : ([0, 0] as Point);\n\treturn a.map((ca, k) => {\n\t\tconst cb = b[k];\n\t\tconst pts = ca.pts.map((p, i) => {\n\t\t\tconst q = cb.pts[i] ?? p;\n\t\t\tconst linear = lerpP(p, q, u);\n\t\t\tif (!sim) return linear;\n\t\t\tconst d: Point = [p[0] - sim.ca[0], p[1] - sim.ca[1]];\n\t\t\tconst full = rot(d, sim.theta, sim.s);\n\t\t\tconst resid: Point = [q[0] - (full[0] + sim.cb[0]), q[1] - (full[1] + sim.cb[1])];\n\t\t\tconst part = rot(d, thetaU, sU);\n\t\t\tconst rigid: Point = [part[0] + cU[0] + resid[0] * u, part[1] + cU[1] + resid[1] * u];\n\t\t\treturn lerpP(linear, rigid, w);\n\t\t});\n\t\treturn { closed: ca.closed && cb.closed, pts };\n\t});\n}\n\n// ---------------------------------------------------------------------------\n// Transforms\n// ---------------------------------------------------------------------------\n\n/**\n * Interpolates two rigid matrices as a rotation (the shorter way round) plus a translation.\n * Any scale or skew is interpolated linearly in the rotated frame.\n */\nexport function interpolateRigidMatrix(a: AffineMatrix, b: AffineMatrix, t: number): AffineMatrix {\n\tconst decompose = (m: AffineMatrix) => {\n\t\tconst sx = Math.hypot(m[0], m[1]);\n\t\tconst ang = sx > 1e-12 ? Math.atan2(m[1], m[0]) : 0;\n\t\tconst c = Math.cos(ang);\n\t\tconst s = Math.sin(ang);\n\t\treturn { e: m[4], f: m[5], ang, sx, sh: c * m[2] + s * m[3], sy: -s * m[2] + c * m[3] };\n\t};\n\tconst p = decompose(a);\n\tconst q = decompose(b);\n\tlet turn = q.ang - p.ang;\n\tturn = ((((turn + Math.PI) % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI)) - Math.PI;\n\tconst ang = p.ang + turn * t;\n\tconst sx = lerpN(p.sx, q.sx, t);\n\tconst sh = lerpN(p.sh, q.sh, t);\n\tconst sy = lerpN(p.sy, q.sy, t);\n\tconst c = Math.cos(ang);\n\tconst s = Math.sin(ang);\n\treturn [c * sx, s * sx, c * sh - s * sy, s * sh + c * sy, lerpN(p.e, q.e, t), lerpN(p.f, q.f, t)];\n}\n\n// ---------------------------------------------------------------------------\n// Paint\n// ---------------------------------------------------------------------------\n\n/** Two colours mixed in OKLab (premultiplied alpha); unreadable colours switch halfway. */\nexport function interpolateVectorColor(a: string, b: string, t: number): string {\n\tif (t <= 0) return a;\n\tif (t >= 1) return b;\n\treturn mixColorsOklab(a, b, t) ?? (t < 0.5 ? a : b);\n}\n\n/**\n * A gradient's stops resampled at `offsets`, each painting what the gradient paints there (its\n * midpoints, smoothness and interpolation space included).\n */\nexport function resampleGradientStops(g: VectorGradient, offsets: readonly number[]): VectorGradientStop[] {\n\treturn offsets.map((offset) => {\n\t\tconst s = sampleVectorGradient(g, offset);\n\t\treturn s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };\n\t});\n}\n\nfunction lerpAngle(a: number, b: number, t: number): number {\n\tconst d = ((((b - a + 180) % 360) + 360) % 360) - 180;\n\treturn a + d * t;\n}\n\nconst lerpPoint = (a: Vec2, b: Vec2, t: number): Vec2 => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });\nconst sameColourModel = (a: VectorGradient, b: VectorGradient) => (a.interpolation ?? 'srgb') === (b.interpolation ?? 'srgb') && (a.smoothness ?? 0) === (b.smoothness ?? 0);\n\n/** Stops of two gradients mixed: stop by stop (midpoints too) when they match, else resampled to a common set. */\nfunction lerpStops(a: VectorGradient, b: VectorGradient, t: number): { stops: VectorGradientStop[]; resampled: boolean } {\n\tlet stopsA = sortedVectorGradientStops(a);\n\tlet stopsB = sortedVectorGradientStops(b);\n\tconst resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);\n\tif (resampled) {\n\t\t// Where either gradient bends (its own stops and the extra stops its midpoints and colour space need).\n\t\tconst offs = [...expandVectorGradientStops(a), ...expandVectorGradientStops(b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);\n\t\tconst common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);\n\t\tstopsA = resampleGradientStops(a, common);\n\t\tstopsB = resampleGradientStops(b, common);\n\t}\n\tconst stops = stopsA.map((x, i) => {\n\t\tconst y = stopsB[i];\n\t\tconst opacity = lerpN(x.opacity ?? 1, y.opacity ?? 1, t);\n\t\tconst stop: VectorGradientStop = { offset: lerpN(x.offset, y.offset, t), color: interpolateVectorColor(x.color, y.color, t) };\n\t\tif (opacity < 1) stop.opacity = opacity;\n\t\tconst mid = lerpN(x.midpoint ?? 0.5, y.midpoint ?? 0.5, t);\n\t\tif (Math.abs(mid - 0.5) > 1e-6) stop.midpoint = mid;\n\t\treturn stop;\n\t});\n\treturn { stops, resampled };\n}\n\n/**\n * Two gradients of one style: stops mixed, then the placement — the shorthand angle / centre /\n * radius, or the start, end, aspect and focal points when both carry them in the same units\n * (one in the box and one in the node's space switch halfway). Null for different styles.\n */\nfunction lerpGradient(a: VectorGradient, b: VectorGradient, t: number): VectorGradient | null {\n\tif (a.type !== b.type) return null;\n\tconst { stops, resampled } = lerpStops(a, b, t);\n\tconst near = t < 0.5 ? a : b;\n\tconst out: VectorGradient = { type: a.type, stops };\n\tif (!resampled) {\n\t\tif (a.interpolation && a.interpolation !== 'srgb') out.interpolation = a.interpolation;\n\t\tif (a.smoothness) out.smoothness = a.smoothness;\n\t}\n\tif (near.spread && near.spread !== 'pad') out.spread = near.spread;\n\tif (near.strokeMode && near.strokeMode !== 'within') out.strokeMode = near.strokeMode;\n\tconst ea = hasExplicitGradientGeometry(a);\n\tconst eb = hasExplicitGradientGeometry(b);\n\tif (!ea && !eb) {\n\t\tif (a.angle !== undefined || b.angle !== undefined || a.type === 'linear' || a.type === 'reflected') {\n\t\t\tconst fallback = a.type === 'linear' || a.type === 'reflected' ? 180 : 90;\n\t\t\tout.angle = lerpAngle(a.angle ?? fallback, b.angle ?? fallback, t);\n\t\t}\n\t\tif (a.type !== 'linear' && a.type !== 'reflected') {\n\t\t\tout.cx = lerpN(a.cx ?? 0.5, b.cx ?? 0.5, t);\n\t\t\tout.cy = lerpN(a.cy ?? 0.5, b.cy ?? 0.5, t);\n\t\t\tout.r = lerpN(a.r ?? 0.5, b.r ?? 0.5, t);\n\t\t}\n\t\treturn out;\n\t}\n\tconst pa = vectorGradientPoints(a);\n\tconst pb = vectorGradientPoints(b);\n\tif (pa.units !== pb.units) {\n\t\tconst src = explicitVectorGradient(near);\n\t\treturn { ...src, stops: out.stops, ...(out.interpolation ? { interpolation: out.interpolation } : {}), ...(out.smoothness ? { smoothness: out.smoothness } : {}) };\n\t}\n\tout.start = lerpPoint(pa.start, pb.start, t);\n\tout.end = lerpPoint(pa.end, pb.end, t);\n\tout.width = lerpPoint(pa.width, pb.width, t);\n\tout.units = pa.units;\n\tif (a.type === 'radial') {\n\t\tif (pa.focal || pb.focal) out.focal = lerpPoint(pa.focal ?? pa.start, pb.focal ?? pb.start, t);\n\t\tconst fr = lerpN(pa.focalRadius, pb.focalRadius, t);\n\t\tif (fr > 0) out.focalRadius = fr;\n\t}\n\treturn out;\n}\n\n/** A gradient shaped like `like` painting one colour (or nothing). */\nfunction solidLike(color: string | null, like: VectorGradient): VectorGradient {\n\treturn { ...like, stops: like.stops.map((s) => (color === null ? { offset: s.offset, color: s.color, opacity: 0 } : { offset: s.offset, color })) };\n}\n\n/**\n * Interpolates paints: colours in OKLab, gradients of one kind with their stops resampled to a\n * common set, a colour and a gradient through a gradient of that colour, and a missing paint\n * fading from transparent. Gradients of different kinds switch halfway.\n */\nexport function interpolateVectorPaint(a: VectorPaint | undefined, b: VectorPaint | undefined, t: number): VectorPaint | undefined {\n\tif (t <= 0) return a;\n\tif (t >= 1) return b;\n\tconst pa = hasPaint(a);\n\tconst pb = hasPaint(b);\n\tif (!pa && !pb) return t < 0.5 ? a : b;\n\tif (typeof a === 'string' && pa && typeof b === 'string' && pb) return interpolateVectorColor(a, b, t);\n\tif (!pa && typeof b === 'string') return interpolateVectorColor('transparent', b, t);\n\tif (!pb && typeof a === 'string') return interpolateVectorColor(a, 'transparent', t);\n\tconst ga = pa && isVectorGradient(a) ? a : null;\n\tconst gb = pb && isVectorGradient(b) ? b : null;\n\tif (ga && gb) return lerpGradient(ga, gb, t) ?? (t < 0.5 ? a : b);\n\tif (gb) return lerpGradient(solidLike(pa ? (a as string) : null, gb), gb, t) ?? b;\n\tif (ga) return lerpGradient(ga, solidLike(pb ? (b as string) : null, ga), t) ?? a;\n\treturn t < 0.5 ? a : b;\n}\n\n/** Width profiles at every position either has a point (no profile is uniform). */\nexport function interpolateWidthProfiles(a: readonly VectorWidthPoint[] | null | undefined, b: readonly VectorWidthPoint[] | null | undefined, t: number): VectorWidthPoint[] | null {\n\tif (!a?.length && !b?.length) return null;\n\tconst at = [...(a ?? []), ...(b ?? []), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);\n\tconst ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);\n\treturn ts.map((pos) => {\n\t\tconst x = widthProfileAt(a, pos);\n\t\tconst y = widthProfileAt(b, pos);\n\t\treturn { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };\n\t});\n}\n\n/** Dash patterns: equal lengths mix; a solid stroke counts as the other's pattern with its gaps closed. */\nfunction lerpDashes(a: number[] | undefined, b: number[] | undefined, t: number): number[] | undefined {\n\tconst dashed = (d: number[] | undefined) => !!d?.length && d.some((v) => v > 0);\n\tif (!dashed(a) && !dashed(b)) return t < 0.5 ? a : b;\n\tconst even = (p: number[]) => (p.length % 2 ? [...p, ...p] : p);\n\tconst solid = (p: number[]) => {\n\t\tconst e = even(p);\n\t\tconst out: number[] = [];\n\t\tfor (let i = 0; i < e.length; i += 2) out.push(e[i] + e[i + 1], 0);\n\t\treturn out;\n\t};\n\tconst x = dashed(a) ? even(a!) : solid(b!);\n\tconst y = dashed(b) ? even(b!) : solid(a!);\n\tif (x.length !== y.length) return t < 0.5 ? a : b;\n\treturn x.map((v, i) => lerpN(v, y[i], t));\n}\n\nconst SWITCHED_KEYS = ['strokeLinecap', 'strokeLinejoin', 'fillRule', 'strokeAlign', 'startArrow', 'endArrow', 'arrowAlign'] as const;\n\n/**\n * Interpolated style of two paths: paints, stroke width, dashes, arrowhead scales and width\n * profiles mix; caps, joins, the fill rule, alignment and arrowheads switch halfway.\n */\nexport function interpolateVectorStyle(a: VectorStyle, b: VectorStyle, t: number): VectorStyle {\n\tconst near = t < 0.5 ? a : b;\n\tconst out: VectorStyle = {};\n\tconst fill = interpolateVectorPaint(a.fill, b.fill, t);\n\tif (fill !== undefined) out.fill = fill;\n\tconst stroke = interpolateVectorPaint(a.stroke, b.stroke, t);\n\tif (stroke !== undefined) out.stroke = stroke;\n\tif (a.strokeWidth !== undefined || b.strokeWidth !== undefined) out.strokeWidth = lerpN(a.strokeWidth ?? 1, b.strokeWidth ?? 1, t);\n\tfor (const key of SWITCHED_KEYS) if (near[key] !== undefined && near[key] !== null) (out as Record<string, unknown>)[key] = near[key];\n\tfor (const key of ['startArrowScale', 'endArrowScale'] as const)\n\t\tif (a[key] !== undefined || b[key] !== undefined) out[key] = lerpN(a[key] ?? 1, b[key] ?? 1, t);\n\tconst dash = lerpDashes(a.strokeDasharray, b.strokeDasharray, t);\n\tif (dash?.length) out.strokeDasharray = dash;\n\tconst profile = interpolateWidthProfiles(a.strokeWidthProfile, b.strokeWidthProfile, t);\n\tif (profile) out.strokeWidthProfile = profile;\n\treturn out;\n}\n\n/** A path's style as seen running backwards: arrowheads swap ends and width profiles reverse. */\nfunction reversedStyle(s: VectorStyle): VectorStyle {\n\tconst out: VectorStyle = { ...s };\n\tout.startArrow = s.endArrow;\n\tout.endArrow = s.startArrow;\n\tout.startArrowScale = s.endArrowScale;\n\tout.endArrowScale = s.startArrowScale;\n\tif (s.strokeWidthProfile?.length) out.strokeWidthProfile = reverseWidthProfile(s.strokeWidthProfile);\n\tfor (const k of ['startArrow', 'endArrow', 'startArrowScale', 'endArrowScale'] as const) if (out[k] === undefined) delete out[k];\n\treturn out;\n}\n\nconst STYLE_KEYS = [\n\t'fill',\n\t'stroke',\n\t'strokeWidth',\n\t'strokeLinecap',\n\t'strokeLinejoin',\n\t'strokeDasharray',\n\t'fillRule',\n\t'strokeAlign',\n\t'startArrow',\n\t'endArrow',\n\t'arrowAlign',\n\t'startArrowScale',\n\t'endArrowScale',\n\t'strokeWidthProfile'\n] as const;\n\nfunction styleOf(n: VectorPathNode): VectorStyle {\n\tconst out: VectorStyle = {};\n\tfor (const k of STYLE_KEYS) if (n[k] !== undefined) (out as Record<string, unknown>)[k] = n[k];\n\treturn out;\n}\n\n// ---------------------------------------------------------------------------\n// Path and node morphs\n// ---------------------------------------------------------------------------\n\nfunction contoursOf(node: VectorPathNode, m: AffineMatrix): VectorMorphContour[] {\n\treturn expandVectorCorners(node.subpaths)\n\t\t.map((sp) => subpathToMorphContour(sp, m))\n\t\t.filter((c): c is VectorMorphContour => !!c);\n}\n\n/**\n * Two paths (each placed by `ma` / `mb` into a common space: by default their own\n * transforms, i.e. their parent's space) prepared for interpolation.\n */\nfunction preparePathMorph(\n\ta: VectorPathNode,\n\tb: VectorPathNode,\n\toptions: VectorMorphOptions,\n\tma: AffineMatrix = nodeMatrix(a),\n\tmb: AffineMatrix = nodeMatrix(b)\n): (t: number) => VectorPathNode {\n\tconst corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);\n\tconst sim = procrustes(corr.a, corr.b);\n\tconst styleA = styleOf(a);\n\tconst styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);\n\tconst rigid = !isIdentityMatrix(ma) || !isIdentityMatrix(mb);\n\tconst id = options.id ?? a.id;\n\treturn (t) => {\n\t\tconst contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });\n\t\tconst m = rigid ? interpolateRigidMatrix(ma, mb, t) : IDENTITY_MATRIX;\n\t\tconst back = rigid ? invertMatrix(m) : IDENTITY_MATRIX;\n\t\tconst subpaths = contours.map((c, k) => {\n\t\t\t// A pair of one closed and one open contour is open in between and takes each key's state at the ends.\n\t\t\tconst closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;\n\t\t\treturn morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);\n\t\t});\n\t\tconst node: VectorPathNode = { id, type: 'path', subpaths, ...interpolateVectorStyle(styleA, styleB, t) };\n\t\tconst opacity = lerpN(a.opacity ?? 1, b.opacity ?? 1, t);\n\t\tif (opacity < 1) node.opacity = opacity;\n\t\tif (rigid && !isIdentityMatrix(m)) node.transform = m;\n\t\treturn node;\n\t};\n}\n\n/** Path nodes of a subtree with their matrices into the subtree's parent space. */\nfunction flattenPaths(node: VectorNode, parent: AffineMatrix = IDENTITY_MATRIX): { path: VectorPathNode; m: AffineMatrix; opacity: number }[] {\n\tconst m = multiplyMatrices(nodeMatrix(node), parent);\n\tif (node.type === 'path') return [{ path: node, m, opacity: 1 }];\n\tconst o = node.opacity ?? 1;\n\treturn node.children\n\t\t.filter((c) => c.visible !== false)\n\t\t.flatMap((c) => flattenPaths(c, m))\n\t\t.map((e) => ({ ...e, opacity: e.opacity * o }));\n}\n\n/** Bounds of a path placed by `m`. */\nconst placedBounds = (path: VectorPathNode, m: AffineMatrix) => boundsOfPoints(contoursOf(path, m).flatMap((c) => c.pts));\n\n/** A copy of `path` shrunk to the point that matches it in the other shape's box (placed by the identity). */\nfunction collapsedPath(path: VectorPathNode, m: AffineMatrix, from: VectorBounds | null, to: VectorBounds | null): VectorPathNode {\n\tconst own = placedBounds(path, m);\n\tconst c: Point = own ? [own.x + own.width / 2, own.y + own.height / 2] : [0, 0];\n\tconst fx = from && from.width > 0 ? (c[0] - from.x) / from.width : 0.5;\n\tconst fy = from && from.height > 0 ? (c[1] - from.y) / from.height : 0.5;\n\tconst p = to ? { x: to.x + to.width * fx, y: to.y + to.height * fy } : { x: c[0], y: c[1] };\n\tconst subpaths = path.subpaths.map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map(() => ({ x: p.x, y: p.y })) }));\n\tconst { transform: _t, ...rest } = path;\n\treturn { ...rest, subpaths };\n}\n\n/**\n * Prepares two shapes for interpolation. Two paths morph directly; with a group on either side\n * the paths inside pair up in stacking order and those without a partner grow out of a point.\n * Shapes are blended in their parent's space.\n */\nexport function createVectorMorph(a: VectorNode, b: VectorNode, options: VectorMorphOptions = {}): VectorMorph {\n\tif (a.type === 'path' && b.type === 'path') {\n\t\tconst at = preparePathMorph(a, b, options);\n\t\treturn { at };\n\t}\n\tconst pa = flattenPaths(a);\n\tconst pb = flattenPaths(b);\n\tconst ba = unionBounds(pa.map((e) => placedBounds(e.path, e.m)));\n\tconst bb = unionBounds(pb.map((e) => placedBounds(e.path, e.m)));\n\tconst id = options.id ?? a.id;\n\tconst parts: ((t: number) => VectorPathNode)[] = [];\n\tconst opacities: [number, number][] = [];\n\tfor (let i = 0; i < Math.max(pa.length, pb.length); i++) {\n\t\tconst x = pa[i];\n\t\tconst y = pb[i];\n\t\tconst sub = { ...options, id: `${id}-${i}`, starts: undefined };\n\t\tif (x && y) {\n\t\t\tparts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));\n\t\t\topacities.push([x.opacity, y.opacity]);\n\t\t} else if (x) {\n\t\t\tparts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, IDENTITY_MATRIX));\n\t\t\topacities.push([x.opacity, x.opacity]);\n\t\t} else if (y) {\n\t\t\tparts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, IDENTITY_MATRIX, y.m));\n\t\t\topacities.push([y.opacity, y.opacity]);\n\t\t}\n\t}\n\treturn {\n\t\tat: (t) => {\n\t\t\tconst children = parts.map((p, i) => {\n\t\t\t\tconst n = p(t);\n\t\t\t\tconst o = lerpN(opacities[i][0], opacities[i][1], t) * (n.opacity ?? 1);\n\t\t\t\tif (o < 1) n.opacity = o;\n\t\t\t\telse delete n.opacity;\n\t\t\t\treturn n;\n\t\t\t});\n\t\t\tconst group: VectorGroupNode = { id, type: 'group', children };\n\t\t\treturn group;\n\t\t}\n\t};\n}\n\n/**\n * The in-between of two shapes at `t` (0 = `a`, 1 = `b`). Prepare once with\n * `createVectorMorph` when interpolating the same pair at many `t`.\n */\nexport function interpolateVectorPaths(a: VectorNode, b: VectorNode, t: number, options: VectorMorphOptions = {}): VectorNode {\n\treturn createVectorMorph(a, b, options).at(t);\n}\n\n/** A keyframe of a path track: a shape at a time (ms), with the easing of the segment leaving it. */\nexport interface VectorPathKeyframe {\n\ttime: number;\n\tvalue: VectorNode;\n\teasing?: AnimationEasing;\n}\n\nconst keyframeMorphs = new WeakMap<VectorNode, WeakMap<VectorNode, VectorMorph>>();\n\n/**\n * A path track's shape at `time`: before the first keyframe its shape, after the last the\n * last; in between the two keyframes morph (prepared once per pair and cached) at the eased\n * fraction. Easings that overshoot are clamped to the keys. `null` without keyframes.\n */\nexport function evaluateVectorPathKeyframes(keyframes: readonly VectorPathKeyframe[], time: number, options: VectorMorphOptions = {}): VectorNode | null {\n\tconst keys = keyframes.filter((k) => Number.isFinite(k.time)).sort((x, y) => x.time - y.time);\n\tif (!keys.length) return null;\n\tif (!(time > keys[0].time)) return keys[0].value;\n\tconst last = keys[keys.length - 1];\n\tif (time >= last.time) return last.value;\n\tlet i = 0;\n\twhile (i + 1 < keys.length && keys[i + 1].time <= time) i++;\n\tconst a = keys[i];\n\tconst b = keys[i + 1];\n\tif (time === a.time) return a.value;\n\tif (a.easing === 'hold') return a.value;\n\tconst span = b.time - a.time;\n\tconst u = Math.min(1, Math.max(0, evaluateEasing(a.easing, (time - a.time) / span, span)));\n\tlet inner = keyframeMorphs.get(a.value);\n\tif (!inner) keyframeMorphs.set(a.value, (inner = new WeakMap()));\n\tlet morph = inner.get(b.value);\n\tif (!morph) inner.set(b.value, (morph = createVectorMorph(a.value, b.value, options)));\n\treturn morph.at(u);\n}\n","/**\n * Gradients laid along or across a stroke (`strokeMode: 'along' | 'across'`), as a `<pattern>`\n * paint server of slices, so the canvases and exported SVG draw them with plain SVG.\n *\n * Each subpath is flattened and cut into slices, one per flattened segment, reaching past\n * everything the stroke paints there (its joins, caps and arrowheads). Gentle turns share a rib on\n * the bisector, so neighbouring slices meet where both give the same colour; a sharp corner gets\n * square ribs and a patch under them in the corner's colour, and the open ends get a patch in the\n * end colour (caps and heads). Along: a slice's linear gradient runs from its start to its end\n * with the part of the gradient between their positions (by length, 0–1 per subpath), padded\n * beyond; across: from the stroke's left edge to its right edge (the visible band of an inside or\n * outside stroke; a width profile's sides at the slice's middle). The pattern paints only where the\n * stroke does, so no clipping is needed. Each slice overlaps the next a little to hide\n * anti-aliasing seams.\n *\n * After vectorcraft `crates/effects/src/stroke/gradient.rs` (ribs on the bisectors of gentle\n * turns, a fan round sharp corners: here one patch), ArtCraft, MIT OR Apache-2.0 — see\n * THIRD_PARTY_NOTICES.md.\n */\nimport type { SvgGradientDef } from '../canvas/gradient.js';\nimport { closeContour, flattenChain, pathToContours } from '../canvas/pathops/bezier.js';\nimport type { Point } from '../canvas/types.js';\nimport { subpathsToBezier } from './geometry.js';\nimport { strokeWidthProfileOf, vectorStrokeReach } from './stroke.js';\nimport { widthProfileAt } from './width.js';\nimport {\n\texpandVectorGradientStops,\n\tpatternAttrs,\n\tspanVectorGradientStops,\n\tvectorGradientArea,\n\ttype VectorPaintDef,\n\ttype VectorSvgPatternDef\n} from './gradient.js';\nimport type { Vec2, VectorBounds, VectorGradient, VectorGradientStop, VectorPathNode } from './types.js';\n\n/** Largest stretch of a rib on a turn's bisector (1 / cos of half the turn, about 74°) before the corner gets a patch. */\nconst SHARP = 1.25;\n/** Flattening tolerance (node units). */\nconst TOLERANCE = 0.2;\n/** How far each slice reaches into the next (node units). */\nconst OVERLAP = 0.5;\n\nconst fmt = (n: number, digits = 3) => {\n\tconst k = 10 ** digits;\n\tconst v = Math.round(n * k) / k;\n\treturn Object.is(v, -0) ? '0' : String(v);\n};\nconst toSvgStops = (stops: readonly VectorGradientStop[]) =>\n\tstops.map((s) => ({ offset: `${fmt(s.offset * 100)}%`, stopColor: s.color, ...(s.opacity !== undefined && s.opacity !== 1 ? { stopOpacity: Math.round(s.opacity * 1e4) / 1e4 } : {}) }));\nconst polygonD = (pts: readonly Vec2[], precision: number) => `M${pts.map((p) => `${fmt(p.x, precision)} ${fmt(p.y, precision)}`).join('L')}Z`;\nconst add = (a: Vec2, b: Vec2): Vec2 => ({ x: a.x + b.x, y: a.y + b.y });\nconst sub = (a: Vec2, b: Vec2): Vec2 => ({ x: a.x - b.x, y: a.y - b.y });\nconst scale = (a: Vec2, k: number): Vec2 => ({ x: a.x * k, y: a.y * k });\n/** Left of direction `d` looking along it on screen (y down). */\nconst left = (d: Vec2): Vec2 => ({ x: d.y, y: -d.x });\nconst unit = (v: Vec2): Vec2 => {\n\tconst l = Math.hypot(v.x, v.y);\n\treturn l > 1e-12 ? { x: v.x / l, y: v.y / l } : { x: 1, y: 0 };\n};\n\n/** A cross-section of the strip: from `l` (left of the path) through the path to `r`. */\ninterface Rib {\n\tl: Vec2;\n\tr: Vec2;\n}\n\n/** The flattened subpaths of a path (node space): points, whether closed, and their lengths. */\nfunction flattenedSubpaths(node: VectorPathNode): { pts: Vec2[]; closed: boolean }[] {\n\tconst out: { pts: Vec2[]; closed: boolean }[] = [];\n\tfor (const contour of pathToContours(subpathsToBezier(node.subpaths))) {\n\t\tconst segs = closeContour(contour);\n\t\tif (!segs.length) continue;\n\t\tconst ring: Point[] = flattenChain(segs, TOLERANCE);\n\t\tconst pts = ring.map(([x, y]) => ({ x, y })).filter((p, i, a) => i === 0 || Math.hypot(p.x - a[i - 1].x, p.y - a[i - 1].y) > 1e-9);\n\t\tif (contour.closed && pts.length > 2 && Math.hypot(pts[0].x - pts[pts.length - 1].x, pts[0].y - pts[pts.length - 1].y) < 1e-9) pts.pop();\n\t\tif (pts.length >= 2) out.push({ pts, closed: contour.closed && pts.length > 2 });\n\t}\n\treturn out;\n}\n\n/** Shoelace area (positive: clockwise on screen, y down). */\nconst signedArea = (pts: readonly Vec2[]) => {\n\tlet a = 0;\n\tfor (let i = 0; i < pts.length; i++) {\n\t\tconst p = pts[i];\n\t\tconst q = pts[(i + 1) % pts.length];\n\t\ta += p.x * q.y - q.x * p.y;\n\t}\n\treturn a / 2;\n};\n\n/**\n * The paint server of a gradient along or across the stroke of `node` (in its own space): a\n * pattern whose first def id is `id`. `area` defaults to the path's box padded by the stroke's\n * reach.\n */\nexport function vectorStrokeGradientDefs(g: VectorGradient, id: string, node: VectorPathNode, options: { bounds?: VectorBounds | null; area?: VectorBounds | null; precision?: number } = {}): VectorPaintDef[] {\n\tconst precision = options.precision ?? 3;\n\tconst mode = g.strokeMode === 'across' ? 'across' : 'along';\n\tconst expanded = expandVectorGradientStops(g);\n\tconst reach = vectorStrokeReach(node) + 1;\n\tconst area = options.area ?? vectorGradientArea(options.bounds && { x: options.bounds.x - reach, y: options.bounds.y - reach, width: options.bounds.width + 2 * reach, height: options.bounds.height + 2 * reach });\n\tconst width = node.strokeWidth ?? 1;\n\tconst align = node.strokeAlign ?? 'center';\n\tconst profile = strokeWidthProfileOf(node);\n\tconst gradients: SvgGradientDef[] = [];\n\tconst patches: { d: string; fill: string }[] = [];\n\tconst slices: { d: string; fill: string }[] = [];\n\tconst colourAt = (t: number) => {\n\t\tconst s = spanVectorGradientStops(g, t, t, expanded)[0];\n\t\treturn s;\n\t};\n\tlet counter = 0;\n\tconst solid = (pts: Vec2[], t: number) => {\n\t\tconst s = colourAt(t);\n\t\tconst gid = `${id}-p${counter++}`;\n\t\t// A one-stop gradient keeps the stop's opacity (a fill colour would need fill-opacity).\n\t\tgradients.push({ id: gid, type: 'linear', attrs: { gradientUnits: 'userSpaceOnUse', x1: 0, y1: 0, x2: 1, y2: 0 }, stops: toSvgStops([{ ...s, offset: 0 }]) });\n\t\tpatches.push({ d: polygonD(pts, precision), fill: `url(#${gid})` });\n\t};\n\tconst disc = (c: Vec2, r: number) => Array.from({ length: 16 }, (_, k) => add(c, scale({ x: Math.cos((k * Math.PI) / 8), y: Math.sin((k * Math.PI) / 8) }, r)));\n\n\tfor (const { pts, closed } of flattenedSubpaths(node)) {\n\t\tconst n = pts.length;\n\t\tconst segCount = closed ? n : n - 1;\n\t\tconst dirs: Vec2[] = [];\n\t\tconst lengths: number[] = [0];\n\t\tfor (let i = 0; i < segCount; i++) {\n\t\t\tconst a = pts[i];\n\t\t\tconst b = pts[(i + 1) % n];\n\t\t\tdirs.push(unit(sub(b, a)));\n\t\t\tlengths.push(lengths[i] + Math.hypot(b.x - a.x, b.y - a.y));\n\t\t}\n\t\tconst total = lengths[segCount];\n\t\tif (!(total > 1e-9)) continue;\n\t\tconst tAt = (i: number) => lengths[i] / total;\n\t\t// Inside / outside strokes show one side: the right of a clockwise outline is its inside.\n\t\tconst clockwise = closed && signedArea(pts) > 0;\n\t\tconst visibleLeft = align === 'center' || !closed ? null : align === 'inside' ? !clockwise : clockwise;\n\n\t\t// Ribs at each vertex: `before` ends the slice arriving, `after` starts the one leaving.\n\t\tconst ribs: { before: Rib; after: Rib }[] = [];\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tconst p = pts[i];\n\t\t\tconst din = i > 0 || closed ? dirs[(i - 1 + segCount) % segCount] : null;\n\t\t\tconst dout = i < segCount ? dirs[i] : null;\n\t\t\tconst square = (d: Vec2): Rib => ({ l: add(p, scale(left(d), reach)), r: sub(p, scale(left(d), reach)) });\n\t\t\tif (!din || !dout) {\n\t\t\t\tconst rib = square((din ?? dout)!);\n\t\t\t\tribs.push({ before: rib, after: rib });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst nin = left(din);\n\t\t\tconst nout = left(dout);\n\t\t\tconst den = 1 + nin.x * nout.x + nin.y * nout.y;\n\t\t\tconst stretch = den > 1e-12 ? Math.sqrt(2 / den) : Infinity;\n\t\t\tif (stretch <= SHARP) {\n\t\t\t\tconst m = scale(add(nin, nout), reach / den);\n\t\t\t\tconst rib = { l: add(p, m), r: sub(p, m) };\n\t\t\t\tribs.push({ before: rib, after: rib });\n\t\t\t} else {\n\t\t\t\tribs.push({ before: square(din), after: square(dout) });\n\t\t\t\tsolid(disc(p, reach * 1.5), tAt(i));\n\t\t\t}\n\t\t}\n\t\tif (!closed) {\n\t\t\t// Caps and arrowheads beyond the ends paint the end colours.\n\t\t\tconst d0 = dirs[0];\n\t\t\tconst d1 = dirs[segCount - 1];\n\t\t\tconst a = pts[0];\n\t\t\tconst b = pts[n - 1];\n\t\t\tconst cap = (p: Vec2, d: Vec2) => [add(p, scale(left(d), reach)), add(add(p, scale(d, reach)), scale(left(d), reach)), sub(add(p, scale(d, reach)), scale(left(d), reach)), sub(p, scale(left(d), reach))];\n\t\t\tsolid(cap(a, scale(d0, -1)), 0);\n\t\t\tsolid(cap(b, d1), 1);\n\t\t}\n\t\tfor (let i = 0; i < segCount; i++) {\n\t\t\tconst j = (i + 1) % n;\n\t\t\tconst a = pts[i];\n\t\t\tconst b = pts[j];\n\t\t\tconst d = dirs[i];\n\t\t\tconst from = ribs[i].after;\n\t\t\tconst to = ribs[j].before;\n\t\t\tconst ext = scale(d, OVERLAP);\n\t\t\tconst quad = [from.l, add(to.l, ext), add(to.r, ext), from.r];\n\t\t\tconst gid = `${id}-s${counter++}`;\n\t\t\tconst t0 = tAt(i);\n\t\t\tconst t1 = closed && i === segCount - 1 ? 1 : tAt(i + 1);\n\t\t\tif (mode === 'along') {\n\t\t\t\tgradients.push({\n\t\t\t\t\tid: gid,\n\t\t\t\t\ttype: 'linear',\n\t\t\t\t\tattrs: { gradientUnits: 'userSpaceOnUse', x1: fmt(a.x, 4), y1: fmt(a.y, 4), x2: fmt(b.x, 4), y2: fmt(b.y, 4) },\n\t\t\t\t\tstops: toSvgStops(spanVectorGradientStops(g, t0, t1, expanded))\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst mid = scale(add(a, b), 0.5);\n\t\t\t\tconst side = widthProfileAt(profile, (t0 + t1) / 2);\n\t\t\t\tconst nrm = left(d);\n\t\t\t\tconst reachL = visibleLeft === null ? (width / 2) * side.left : visibleLeft ? width * side.left : 0;\n\t\t\t\tconst reachR = visibleLeft === null ? (width / 2) * side.right : visibleLeft ? 0 : width * side.right;\n\t\t\t\tconst p0 = add(mid, scale(nrm, reachL));\n\t\t\t\tconst p1 = sub(mid, scale(nrm, reachR));\n\t\t\t\tgradients.push({\n\t\t\t\t\tid: gid,\n\t\t\t\t\ttype: 'linear',\n\t\t\t\t\tattrs: { gradientUnits: 'userSpaceOnUse', x1: fmt(p0.x, 4), y1: fmt(p0.y, 4), x2: fmt(p1.x, 4), y2: fmt(p1.y, 4) },\n\t\t\t\t\tstops: toSvgStops(expanded)\n\t\t\t\t});\n\t\t\t}\n\t\t\tslices.push({ d: polygonD(quad, precision), fill: `url(#${gid})` });\n\t\t}\n\t}\n\tconst def: VectorSvgPatternDef = {\n\t\tid,\n\t\ttype: 'pattern',\n\t\tattrs: patternAttrs(area),\n\t\tgradients,\n\t\ttiles: [...patches, ...slices]\n\t};\n\treturn [def];\n}\n","/**\n * SVG export and import for vector documents. Import is DOM-free (works in Node and\n * workers): it reads `<svg>`, `<g>`, `<path>`, `<rect>`, `<circle>`, `<ellipse>`, `<line>`,\n * `<polyline>`, `<polygon>`, linear / radial gradients, presentation attributes, `style`\n * declarations, `transform`s, `clip-path` and `mask` references (each becomes a mask group, the\n * clip or mask its first child). Text, images, foreign filters and `<use>` are skipped.\n *\n * Live corners export as their cut outline plus `data-vector-d` (the sharp path) and\n * `data-vector-corners` (the radii), so the editor's own SVG imports with editable corners.\n * Inside / outside strokes, which SVG cannot express, export (after vectorcraft\n * `crates/svg/src/lib.rs`, MIT OR Apache-2.0) as a `<g data-vector-path>` holding the fill, a\n * stroke of twice the width clipped to the shape (inside) or masked by it (outside), and the\n * arrowheads as filled outlines; import merges such a group back into one path. A variable-width\n * stroke exports as its filled outline (`data-vector-part=\"stroke-outline\"`) with the profile\n * and line style kept in `data-vector-width-profile` / `data-vector-stroke-*` attributes.\n *\n * A mask group exports as a `<g data-vector-mask>` (the settings as JSON) carrying the group's\n * transform, opacity, blend mode and filter, around a `<g data-vector-part=\"masked\">` with the\n * contents and `clip-path` / `mask`, so the group's appearance applies to the masked result. A\n * clip's `<clipPath>` holds the mask's outlines; for import, the mask itself is kept in a hidden\n * `<g data-vector-part=\"mask-source\">`. An opacity mask's `<mask>` holds the mask as drawn.\n */\nimport { bezierPathToSvg } from '../canvas/pathops/bezier.js';\nimport { bezierPathBounds } from '../canvas/pathops/bezier.js';\nimport { hasStrokeExtras, strokeWidthProfileOf, vectorStrokeLineArea, vectorStrokeOutlinePath, vectorStrokeParts, vectorStrokeReach } from './stroke.js';\nimport { sanitizeWidthProfile } from './width.js';\nimport { expandVectorAppearance, hasOwnVectorAppearance, sanitizeVectorEffects, transformVectorEffects, vectorAppearanceNodes } from './appearance.js';\nimport { isVectorMaskGroup, sanitizeVectorMask, vectorMaskRenderData } from './mask.js';\nimport { activeVectorFilters, sanitizeVectorFilters, vectorFilterMarkup, vectorFilterSvg, type VectorRenderFilter } from './filters.js';\nimport {\n\tneedsVectorPaintLayers,\n\tvectorFills,\n\tvectorStrokes,\n\tsanitizeVectorFills,\n\tsanitizeVectorStrokes,\n\tvectorBlendModeCss,\n\tvectorBlendModeFromCss,\n\tvectorPaintLayerNodes,\n\tvectorStrokeStackReach,\n\tnormalizeVectorPaintStacks,\n\twithVectorFills,\n\twithVectorStrokes\n} from './paintLayers.js';\nimport { angleToSvgLinearCoords, type SvgGradientDef } from '../canvas/gradient.js';\nimport { bezierPathBounds as pathBounds } from '../canvas/pathops/bezier.js';\nimport { isVectorGradient, sanitizeVectorGradient, vectorGradientSvgDefs, type VectorPaintDef } from './gradient.js';\nimport { vectorStrokeGradientDefs } from './gradientStroke.js';\nimport { formatNumber } from '../canvas/shapeGeometry.js';\nimport {\n\tbezierToSubpaths,\n\tdecomposeRigid,\n\tellipseSubpath,\n\thasPaint,\n\tIDENTITY_MATRIX,\n\tlineSubpath,\n\tmultiplyMatrices,\n\trectSubpath,\n\trotateMatrix,\n\tscaleMatrix,\n\tsubpathsToBezier,\n\ttransformVectorNode,\n\ttranslateMatrix,\n\tvectorPathData,\n\tunionBounds,\n\tvectorNodeBounds,\n\ttype AffineMatrix\n} from './geometry.js';\nimport {\n\tVECTOR_ARROWHEADS,\n\tVECTOR_CORNER_KINDS,\n\ttype VectorArrowhead,\n\ttype VectorBlend,\n\ttype VectorBooleanOperation,\n\ttype VectorCornerKind,\n\ttype VectorDocument,\n\ttype VectorFilter,\n\ttype VectorFillRule,\n\ttype VectorGradient,\n\ttype VectorGradientStop,\n\ttype VectorGroupNode,\n\ttype VectorEffect,\n\ttype VectorLineCap,\n\ttype VectorLineJoin,\n\ttype VectorWidthPoint,\n\ttype VectorNode,\n\ttype VectorPaint,\n\ttype VectorBounds,\n\ttype VectorPathNode,\n\ttype VectorPaintLayer,\n\ttype VectorStrokeAlign,\n\ttype VectorSubpath\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// Export\n// ---------------------------------------------------------------------------\n\nexport interface VectorSvgExportOptions {\n\t/** Decimal places for coordinates (default 3). */\n\tprecision?: number;\n\t/** Draw `document.background` as a full-size rect (default true). */\n\tbackground?: boolean;\n\t/** Include hidden nodes with `display=\"none\"` instead of leaving them out (default false). */\n\tincludeHidden?: boolean;\n\t/** Prefix for gradient ids (default `vg-`), to keep ids unique when several SVGs share a page. */\n\tidPrefix?: string;\n\t/** Indent nested elements (default true). */\n\tpretty?: boolean;\n\t/**\n\t * How strokes with an inside / outside alignment or arrowheads are written: `clip` (default)\n\t * as a double-width stroke clipped or masked by the shape plus filled heads, `outline` as\n\t * one filled path of the area the stroke paints.\n\t */\n\tstrokes?: 'clip' | 'outline';\n\t/**\n\t * Groups to write round nodes, by node id, outermost first: to move a node from outside it\n\t * or clip it (the animation editor's reveals and its Flair export use this).\n\t */\n\twrap?: Readonly<Record<string, readonly VectorSvgWrapper[]>>;\n}\n\n/** A group written round a node (see `VectorSvgExportOptions.wrap`). */\nexport interface VectorSvgWrapper {\n\tid?: string;\n\t/** An SVG `transform` attribute. */\n\ttransform?: string;\n\t/**\n\t * Clips the group through a rect (`x`, `y`, `width`, `height`) or circle (`cx`, `cy`, `r`) in\n\t * the units of the group's own box (`clipPathUnits=\"objectBoundingBox\"`: 0–1 across it).\n\t */\n\tclip?: { id: string; shape: 'rect' | 'circle'; shapeId?: string; attrs: Readonly<Record<string, number>> };\n}\n\n/** `data-vector-corners`: the live corners of subpaths as `subpath.index:radius[:kind]`, space separated. */\nexport function vectorCornersAttribute(subpaths: readonly VectorSubpath[], precision = 3): string {\n\tconst out: string[] = [];\n\tsubpaths.forEach((sp, s) =>\n\t\tsp.anchors.forEach((a, i) => {\n\t\t\tif (!a.corner || !(a.corner.radius > 0)) return;\n\t\t\tout.push(`${s}.${i}:${formatNumber(a.corner.radius, precision)}${a.corner.kind && a.corner.kind !== 'round' ? `:${a.corner.kind}` : ''}`);\n\t\t})\n\t);\n\treturn out.join(' ');\n}\n\n/** Puts `data-vector-corners` back on subpaths (malformed entries are ignored). */\nexport function applyVectorCornersAttribute(subpaths: VectorSubpath[], value: string): VectorSubpath[] {\n\tfor (const item of value.trim().split(/\\s+/)) {\n\t\tconst m = /^(\\d+)\\.(\\d+):([\\d.eE+-]+)(?::([a-z]+))?$/.exec(item);\n\t\tif (!m) continue;\n\t\tconst a = subpaths[+m[1]]?.anchors[+m[2]];\n\t\tconst radius = parseFloat(m[3]);\n\t\tif (!a || !(radius > 0)) continue;\n\t\tconst kind = VECTOR_CORNER_KINDS.includes(m[4] as VectorCornerKind) ? (m[4] as VectorCornerKind) : undefined;\n\t\ta.corner = { radius, ...(kind && kind !== 'round' ? { kind } : {}) };\n\t}\n\treturn subpaths;\n}\n\nconst escapeAttr = (value: string) => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n\n/** Where a paint goes: what `vectorPaintToSvg` needs to place a gradient on a shape. */\nexport interface VectorPaintSvgOptions {\n\t/** The path painted (its box places `objectBoundingBox` gradients; strokes need its geometry). */\n\tnode?: VectorPathNode;\n\t/** `stroke` lays `along` / `across` gradients on the stroke and covers its reach (default `fill`). */\n\trole?: 'fill' | 'stroke';\n\tprecision?: number;\n}\n\n/** The box of a path's drawn outline in its own space (null when it has no points). */\nexport function vectorPathLocalBounds(node: VectorPathNode): VectorBounds | null {\n\tconst b = pathBounds(subpathsToBezier(node.subpaths));\n\treturn b ? { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY } : null;\n}\n\n/** Paint defs are recomputed only when the node (or the id / role asked for) changes. */\nconst paintCache = new WeakMap<object, Map<string, VectorPaintDef[]>>();\n\n/**\n * A paint as an SVG attribute value plus the paint servers it needs (`url(#id)` refers to the\n * first). Gradients sit in the painted element's user space (the node's own space).\n */\nexport function vectorPaintToSvg(paint: VectorPaint | undefined, gradientId: string, options: VectorPaintSvgOptions = {}): { value: string; defs: VectorPaintDef[] } {\n\tif (!hasPaint(paint)) return { value: 'none', defs: [] };\n\tif (typeof paint === 'string') return { value: paint, defs: [] };\n\tif (!isVectorGradient(paint)) return { value: 'none', defs: [] };\n\tconst role = options.role ?? 'fill';\n\tconst precision = options.precision ?? 3;\n\tconst key = `${gradientId}|${role}|${precision}`;\n\tconst owner: object = options.node ?? paint;\n\tconst cached = paintCache.get(owner)?.get(key);\n\tif (cached && (!options.node || (role === 'fill' ? options.node.fill : options.node.stroke) === paint)) return { value: `url(#${gradientId})`, defs: cached };\n\tconst node = options.node;\n\tconst bounds = node ? vectorPathLocalBounds(node) : null;\n\tconst reach = node && role === 'stroke' ? vectorStrokeReach(node) + 1 : 1;\n\tconst area = bounds ? { x: bounds.x - reach, y: bounds.y - reach, width: bounds.width + 2 * reach, height: bounds.height + 2 * reach } : null;\n\tconst defs =\n\t\tnode && role === 'stroke' && (paint.strokeMode === 'along' || paint.strokeMode === 'across')\n\t\t\t? vectorStrokeGradientDefs(paint, gradientId, node, { bounds, area, precision })\n\t\t\t: vectorGradientSvgDefs(paint, gradientId, { bounds, area, precision });\n\tlet byKey = paintCache.get(owner);\n\tif (!byKey) paintCache.set(owner, (byKey = new Map()));\n\tbyKey.set(key, defs);\n\treturn { value: `url(#${gradientId})`, defs };\n}\n\n/** The parts of an aligned or arrowed stroke (see `VectorRenderPath.strokeParts`). */\nexport interface VectorRenderStrokeParts {\n\talign: VectorStrokeAlign;\n\t/** The line the stroke follows (shortened under `tip`-aligned heads). */\n\td: string;\n\t/** Width to draw it with: twice the stroke width when aligned, half of it being clipped away. */\n\twidth: number;\n\t/**\n\t * A variable-width stroke: the area to fill with `stroke` (nonzero) instead of stroking `d`,\n\t * clipped or masked like the stroke would be.\n\t */\n\toutline?: string;\n\t/**\n\t * Inside: a `<clipPath id>` holding the shape (`d`, `clip-rule` = `fillRule`). Outside: a\n\t * `<mask id>` in user space over `bounds`, white with the shape (`d`) in black.\n\t */\n\tclip: { kind: 'clip' | 'mask'; id: string; bounds: VectorBounds } | null;\n\t/** Arrowhead outlines (fill with `stroke`, nonzero). */\n\theads: string[];\n}\n\n/** Stroke parts are recomputed only when the node (or the id / precision asked for) changes. */\nconst partsCache = new WeakMap<VectorPathNode, { clipId: string; precision: number; parts: VectorRenderStrokeParts | undefined }>();\n\n/** The stroke parts of a path whose stroke needs more than one element, in its own space (undefined otherwise). */\nexport function vectorStrokeSvgParts(node: VectorPathNode, clipId: string, precision = 3): VectorRenderStrokeParts | undefined {\n\tif (!hasPaint(node.stroke) || !hasStrokeExtras(node)) return undefined;\n\tconst hit = partsCache.get(node);\n\tif (hit && hit.clipId === clipId && hit.precision === precision) return hit.parts;\n\tconst parts = computeStrokeSvgParts(node, clipId, precision);\n\tpartsCache.set(node, { clipId, precision, parts });\n\treturn parts;\n}\n\nfunction computeStrokeSvgParts(node: VectorPathNode, clipId: string, precision: number): VectorRenderStrokeParts | undefined {\n\tconst path = subpathsToBezier(node.subpaths);\n\tconst parts = vectorStrokeParts(path, node);\n\tconst profiled = !!strokeWidthProfileOf(node);\n\tif (parts.align === 'center' && !parts.heads.length && !profiled) return undefined;\n\tlet clip: VectorRenderStrokeParts['clip'] = null;\n\tif (parts.align !== 'center') {\n\t\tconst b = bezierPathBounds(path);\n\t\tconst pad = vectorStrokeReach(node) + 1;\n\t\tconst bounds = b ? { x: round2(b.minX - pad), y: round2(b.minY - pad), width: round2(b.maxX - b.minX + 2 * pad), height: round2(b.maxY - b.minY + 2 * pad) } : { x: 0, y: 0, width: 0, height: 0 };\n\t\tclip = { kind: parts.align === 'inside' ? 'clip' : 'mask', id: clipId, bounds };\n\t}\n\treturn {\n\t\talign: parts.align,\n\t\td: bezierPathToSvg(parts.line, { precision }),\n\t\twidth: parts.drawWidth,\n\t\t...(profiled && (node.strokeWidth ?? 1) > 0 ? { outline: bezierPathToSvg(vectorStrokeLineArea(parts, node), { precision }) } : {}),\n\t\tclip,\n\t\theads: parts.heads.map((h) => bezierPathToSvg(h.path, { precision }))\n\t};\n}\n\n/**\n * The box a node draws over in its own space (its `transform` not applied): its geometry as drawn\n * (effects applied), padded by how far its strokes reach. Null when it draws nothing.\n */\nexport function vectorNodeLocalPaintBounds(node: VectorNode): VectorBounds | null {\n\tconst drawn = expandVectorAppearance(node);\n\tconst reach = (n: VectorNode): number => (n.type === 'path' ? vectorStrokeStackReach(n) : Math.max(0, ...n.children.map(reach)));\n\tlet b: VectorBounds | null;\n\tif (drawn.type === 'path') b = vectorPathLocalBounds(drawn);\n\telse b = unionBounds(drawn.children.filter((c) => c.visible !== false).map((c) => vectorNodeBounds(c, IDENTITY_MATRIX)));\n\tif (!b) return null;\n\tconst pad = reach(drawn);\n\treturn { x: b.x - pad, y: b.y - pad, width: b.width + 2 * pad, height: b.height + 2 * pad };\n}\n\nconst filterCache = new WeakMap<VectorNode, { id: string; filter: VectorRenderFilter | null }>();\n\n/** A node's filter (`node.filters`) as render data with id `id`, or null when none draws. Cached per node. */\nexport function vectorNodeFilterSvg(node: VectorNode, id: string): VectorRenderFilter | null {\n\tif (!node.filters?.length) return null;\n\tconst hit = filterCache.get(node);\n\tif (hit && hit.id === id) return hit.filter;\n\tconst active = activeVectorFilters(node);\n\tconst filter = active.length ? vectorFilterSvg(active, id, vectorNodeLocalPaintBounds(node)) : null;\n\tfilterCache.set(node, { id, filter });\n\treturn filter;\n}\n\n/** A width profile as a data attribute: `t,left,right` points separated by `;`. */\nexport function widthProfileToAttribute(points: readonly VectorWidthPoint[], precision = 4): string {\n\treturn points.map((p) => [p.t, p.left, p.right].map((n) => formatNumber(n, precision)).join(',')).join(';');\n}\n\n/** Reads `widthProfileToAttribute` output (invalid points are dropped). */\nexport function widthProfileFromAttribute(value: string | undefined): VectorWidthPoint[] {\n\tif (!value) return [];\n\treturn sanitizeWidthProfile(\n\t\tvalue.split(';').map((part) => {\n\t\t\tconst [t, left, right] = part.split(',').map((n) => parseFloat(n));\n\t\t\treturn { t, left, right: Number.isFinite(right) ? right : left };\n\t\t})\n\t);\n}\n\nconst round2 = (n: number) => Math.round(n * 100) / 100;\n\nfunction gradientMarkup(def: SvgGradientDef, extra = ''): string {\n\tconst tag = def.type === 'radial' ? 'radialGradient' : 'linearGradient';\n\tconst attrs = Object.entries(def.attrs)\n\t\t.map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`)\n\t\t.join('');\n\tconst stops = def.stops\n\t\t.map((s) => `<stop offset=\"${s.offset}\" stop-color=\"${escapeAttr(s.stopColor)}\"${s.stopOpacity !== undefined ? ` stop-opacity=\"${s.stopOpacity}\"` : ''}/>`)\n\t\t.join('');\n\treturn `<${tag} id=\"${escapeAttr(def.id)}\"${attrs}${extra}>${stops}</${tag}>`;\n}\n\n/**\n * A paint server's markup. The first def of a gradient carries `data-vector-gradient` (the\n * gradient as JSON, in the node's space) so import restores what SVG cannot say: midpoints,\n * interpolation, smoothness, conic / reflected / diamond styles and stroke modes.\n */\nfunction paintDefMarkup(def: VectorPaintDef, gradient?: VectorGradient): string {\n\tconst extra = gradient ? ` data-vector-gradient=\"${escapeAttr(JSON.stringify(gradient))}\"` : '';\n\tif (def.type !== 'pattern') return gradientMarkup(def, extra);\n\tconst attrs = Object.entries(def.attrs)\n\t\t.map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`)\n\t\t.join('');\n\tconst inner = def.gradients.map((g) => gradientMarkup(g)).join('') + def.tiles.map((t) => `<path d=\"${t.d}\" fill=\"${escapeAttr(t.fill)}\"/>`).join('');\n\treturn `<pattern id=\"${escapeAttr(def.id)}\"${attrs}${extra}>${inner}</pattern>`;\n}\n\n/** Markup of a paint's defs (the gradient's data attribute on the first). */\nconst paintMarkup = (paint: VectorPaint | undefined, defs: readonly VectorPaintDef[]) => defs.map((d, i) => paintDefMarkup(d, i === 0 && isVectorGradient(paint) ? paint : undefined));\n\n/**\n * `data-vector-blend` (a blend group's options as JSON, its spine in the group's space) back to\n * a blend, the spine carried by `m` (import bakes group transforms into the children).\n */\nfunction blendFromAttribute(value: string | undefined, m: AffineMatrix): VectorBlend | null {\n\tif (!value) return null;\n\tlet raw: unknown;\n\ttry {\n\t\traw = JSON.parse(value);\n\t} catch {\n\t\treturn null;\n\t}\n\tif (!raw || typeof raw !== 'object') return null;\n\tconst r = raw as Record<string, unknown>;\n\tconst out: VectorBlend = {};\n\tif (r.spacing === 'steps' || r.spacing === 'distance' || r.spacing === 'smoothColor') out.spacing = r.spacing;\n\tif (typeof r.steps === 'number' && Number.isFinite(r.steps)) out.steps = Math.min(1000, Math.max(1, Math.round(r.steps)));\n\tif (typeof r.distance === 'number' && r.distance > 0) out.distance = r.distance;\n\tif (typeof r.orientToSpine === 'boolean') out.orientToSpine = r.orientToSpine;\n\tif (typeof r.linear === 'boolean') out.linear = r.linear;\n\tif (r.starts && typeof r.starts === 'object') {\n\t\tconst starts = Object.fromEntries(Object.entries(r.starts as Record<string, unknown>).filter((e): e is [string, number] => Number.isInteger(e[1]) && (e[1] as number) >= 0));\n\t\tif (Object.keys(starts).length) out.starts = starts;\n\t}\n\tconst spine = r.spine as VectorSubpath | null | undefined;\n\tif (spine && Array.isArray(spine.anchors) && spine.anchors.every((a) => a && Number.isFinite(a.x) && Number.isFinite(a.y))) {\n\t\tconst sp: VectorSubpath = { closed: !!spine.closed, anchors: spine.anchors.map((a) => ({ x: a.x, y: a.y, ...(a.in ? { in: { x: a.in.x, y: a.in.y } } : {}), ...(a.out ? { out: { x: a.out.x, y: a.out.y } } : {}) })) };\n\t\tout.spine = m === IDENTITY_MATRIX ? sp : transformVectorNode<VectorPathNode>({ id: '', type: 'path', subpaths: [sp] }, m).subpaths[0];\n\t}\n\treturn out;\n}\n\n/** Serializes a vector document as a standalone SVG string. */\nexport function vectorDocumentToSvg(doc: VectorDocument, options: VectorSvgExportOptions = {}): string {\n\tconst precision = options.precision ?? 3;\n\tconst prefix = options.idPrefix ?? 'vg-';\n\tconst pretty = options.pretty !== false;\n\tconst defs: string[] = [];\n\tconst lines: string[] = [];\n\tconst num = (n: number) => formatNumber(n, precision);\n\tconst indent = (depth: number) => (pretty ? ' '.repeat(depth) : '');\n\n\tconst common = (node: VectorNode) => {\n\t\tlet out = ` id=\"${escapeAttr(node.id)}\"`;\n\t\tif (node.transform) out += ` transform=\"matrix(${node.transform.map((n) => formatNumber(n, 6)).join(' ')})\"`;\n\t\tif (node.opacity !== undefined && node.opacity < 1) out += ` opacity=\"${num(node.opacity)}\"`;\n\t\tif (node.visible === false) out += ` display=\"none\"`;\n\t\tif (node.blendStep) out += ` data-vector-blend-step=\"\"`;\n\t\tif (node.type === 'group' && node.blend) out += ` data-vector-blend=\"${escapeAttr(JSON.stringify(node.blend))}\"`;\n\t\tif (node.booleanOperation) out += ` data-vector-boolean-operation=\"${node.booleanOperation}\"`;\n\t\tconst blend = vectorBlendModeCss(node.blendMode);\n\t\tif (blend) out += ` style=\"mix-blend-mode:${blend}\"`;\n\t\tif (node.filters?.length) {\n\t\t\t// The filter as drawn, carrying the filter stack (JSON) for import.\n\t\t\tconst filter = vectorNodeFilterSvg(node, `${prefix}filter-${node.id}`);\n\t\t\tconst data = ` data-vector-filters=\"${escapeAttr(JSON.stringify(node.filters))}\"`;\n\t\t\tif (filter) {\n\t\t\t\tdefs.push(vectorFilterMarkup(filter, data));\n\t\t\t\tout += ` filter=\"url(#${escapeAttr(filter.id)})\"`;\n\t\t\t} else out += data;\n\t\t}\n\t\treturn out;\n\t};\n\n\t/** Opacity and blend mode of one paint layer, as attributes. */\n\tconst layerAttrs = (layer: { opacity?: number; blendMode?: VectorPaintLayer['blendMode'] }) => {\n\t\tlet out = '';\n\t\tif (layer.opacity !== undefined && layer.opacity < 1) out += ` opacity=\"${num(layer.opacity)}\"`;\n\t\tconst blend = vectorBlendModeCss(layer.blendMode);\n\t\tif (blend) out += ` style=\"mix-blend-mode:${blend}\"`;\n\t\treturn out;\n\t};\n\n\t/**\n\t * The elements of a stroke drawn in parts (aligned, arrowed or profiled): the stroke (or its\n\t * outline) clipped or masked by the shape, then the heads. `d` is the shape's path data.\n\t */\n\tconst strokePartLines = (node: VectorPathNode, parts: VectorRenderStrokeParts, strokeValue: string, d: string, lineAttrs: (width: number) => string, depth: number): string[] => {\n\t\tconst out: string[] = [];\n\t\tif (options.strokes === 'outline') {\n\t\t\tconst area = bezierPathToSvg(vectorStrokeOutlinePath(subpathsToBezier(node.subpaths), node), { precision });\n\t\t\tout.push(`${indent(depth)}<path data-vector-part=\"stroke-outline\" d=\"${area}\" fill=\"${escapeAttr(strokeValue)}\"/>`);\n\t\t\treturn out;\n\t\t}\n\t\tlet clip = '';\n\t\tif (parts.clip) {\n\t\t\tconst rule = node.fillRule === 'evenodd' ? 'evenodd' : 'nonzero';\n\t\t\tconst id = escapeAttr(parts.clip.id);\n\t\t\tif (parts.clip.kind === 'clip') {\n\t\t\t\tdefs.push(`<clipPath id=\"${id}\"><path d=\"${d}\" clip-rule=\"${rule}\"/></clipPath>`);\n\t\t\t\tclip = ` clip-path=\"url(#${id})\"`;\n\t\t\t} else {\n\t\t\t\tconst b = parts.clip.bounds;\n\t\t\t\tconst box = `x=\"${num(b.x)}\" y=\"${num(b.y)}\" width=\"${num(b.width)}\" height=\"${num(b.height)}\"`;\n\t\t\t\tdefs.push(`<mask id=\"${id}\" maskUnits=\"userSpaceOnUse\" ${box}><rect ${box} fill=\"#fff\"/><path d=\"${d}\" fill=\"#000\" fill-rule=\"${rule}\"/></mask>`);\n\t\t\t\tclip = ` mask=\"url(#${id})\"`;\n\t\t\t}\n\t\t}\n\t\tif (parts.outline !== undefined) out.push(`${indent(depth)}<path data-vector-part=\"stroke-outline\" d=\"${parts.outline}\" fill=\"${escapeAttr(strokeValue)}\"${clip}/>`);\n\t\telse out.push(`${indent(depth)}<path data-vector-part=\"stroke\" d=\"${parts.d}\" fill=\"none\"${lineAttrs(parts.width)}${clip}/>`);\n\t\tfor (const h of parts.heads) out.push(`${indent(depth)}<path data-vector-part=\"head\" d=\"${h}\" fill=\"${escapeAttr(strokeValue)}\"/>`);\n\t\treturn out;\n\t};\n\n\t/** SVG line attributes of a (layer) node's stroke. */\n\tconst lineAttrsOf = (node: VectorPathNode, strokeValue: string) => (width: number) => {\n\t\tlet out = ` stroke=\"${escapeAttr(strokeValue)}\" stroke-width=\"${num(width)}\"`;\n\t\tif (node.strokeLinecap && node.strokeLinecap !== 'butt') out += ` stroke-linecap=\"${node.strokeLinecap}\"`;\n\t\tif (node.strokeLinejoin && node.strokeLinejoin !== 'miter') out += ` stroke-linejoin=\"${node.strokeLinejoin}\"`;\n\t\tif (node.strokeDasharray?.length) out += ` stroke-dasharray=\"${node.strokeDasharray.map(num).join(' ')}\"`;\n\t\treturn out;\n\t};\n\n\t/** `data-vector-d` / `data-vector-corners` of a path with live corners ('' without). */\n\tconst liveCorners = (node: VectorPathNode) => {\n\t\tconst corners = vectorCornersAttribute(node.subpaths, precision);\n\t\treturn corners ? ` data-vector-d=\"${bezierPathToSvg(subpathsToBezier(node.subpaths, { corners: false }), { precision })}\" data-vector-corners=\"${corners}\"` : '';\n\t};\n\n\t/**\n\t * A path painted through its stacks: a `<g data-vector-path>` carrying the stacks (JSON, for\n\t * import), holding each drawn layer bottom to top. The first part is a fill part with the\n\t * geometry (unpainted when no fill is drawn).\n\t */\n\tconst emitStacked = (node: VectorPathNode, depth: number) => {\n\t\tconst d = vectorPathData(node, precision);\n\t\tconst rule = node.fillRule === 'evenodd' ? ` fill-rule=\"evenodd\"` : '';\n\t\tlet data = ` data-vector-path=\"\" data-vector-fills=\"${escapeAttr(JSON.stringify(vectorFills(node)))}\" data-vector-strokes=\"${escapeAttr(JSON.stringify(vectorStrokes(node)))}\"`;\n\t\tif (node.fillRule === 'evenodd') data += ` data-vector-fill-rule=\"evenodd\"`;\n\t\tlines.push(`${indent(depth)}<g${common(node)}${data}>`);\n\t\tconst layers = vectorPaintLayerNodes(node).filter((l) => l.drawn);\n\t\tlet geometry = liveCorners(node);\n\t\tif (!layers.some((l) => l.kind === 'fill')) {\n\t\t\tlines.push(`${indent(depth + 1)}<path data-vector-part=\"fill\" d=\"${d}\" fill=\"none\"${rule}${geometry}/>`);\n\t\t\tgeometry = '';\n\t\t}\n\t\tfor (const l of layers) {\n\t\t\tconst id = `${prefix}${l.kind}-${node.id}-${l.index}`;\n\t\t\tconst paint = vectorPaintToSvg(l.layer.paint, id, { node: l.node, precision, ...(l.kind === 'stroke' ? { role: 'stroke' as const } : {}) });\n\t\t\tdefs.push(...paintMarkup(l.layer.paint, paint.defs));\n\t\t\tconst attrs = ` data-vector-layer=\"${l.index}\"${layerAttrs(l.layer)}`;\n\t\t\tif (l.kind === 'fill') {\n\t\t\t\tlines.push(`${indent(depth + 1)}<path data-vector-part=\"fill\"${attrs} d=\"${d}\" fill=\"${escapeAttr(paint.value)}\"${rule}${geometry}/>`);\n\t\t\t\tgeometry = '';\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst lineAttrs = lineAttrsOf(l.node, paint.value);\n\t\t\tconst parts = vectorStrokeSvgParts(l.node, `${prefix}clip-${node.id}-${l.index}`, precision);\n\t\t\tif (!parts) {\n\t\t\t\tlines.push(`${indent(depth + 1)}<path data-vector-part=\"stroke\"${attrs} d=\"${d}\" fill=\"none\"${lineAttrs(l.node.strokeWidth ?? 1)}/>`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlines.push(`${indent(depth + 1)}<g data-vector-part=\"stroke-layer\"${attrs}>`);\n\t\t\tlines.push(...strokePartLines(l.node, parts, paint.value, d, lineAttrs, depth + 2));\n\t\t\tlines.push(`${indent(depth + 1)}</g>`);\n\t\t}\n\t\tlines.push(`${indent(depth)}</g>`);\n\t};\n\n\tconst emit = (node: VectorNode, depth: number) => {\n\t\tif (node.visible === false && !options.includeHidden) return;\n\t\tconst wrappers = options.wrap?.[node.id] ?? [];\n\t\twrappers.forEach((w, i) => {\n\t\t\tlet attrs = w.id !== undefined ? ` id=\"${escapeAttr(w.id)}\"` : '';\n\t\t\tif (w.transform) attrs += ` transform=\"${escapeAttr(w.transform)}\"`;\n\t\t\tif (w.clip) {\n\t\t\t\tconst shape = Object.entries(w.clip.attrs).map(([k, v]) => ` ${k}=\"${formatNumber(v, 4)}\"`).join('');\n\t\t\t\tdefs.push(`<clipPath id=\"${escapeAttr(w.clip.id)}\" clipPathUnits=\"objectBoundingBox\"><${w.clip.shape}${w.clip.shapeId !== undefined ? ` id=\"${escapeAttr(w.clip.shapeId)}\"` : ''}${shape}/></clipPath>`);\n\t\t\t\tattrs += ` clip-path=\"url(#${escapeAttr(w.clip.id)})\"`;\n\t\t\t}\n\t\t\tlines.push(`${indent(depth + i)}<g${attrs}>`);\n\t\t});\n\t\temitNode(node, depth + wrappers.length);\n\t\tfor (let i = wrappers.length - 1; i >= 0; i--) lines.push(`${indent(depth + i)}</g>`);\n\t};\n\n\t/** The lines `fn` emits, taken out of the document (for markup that goes into `defs`). */\n\tconst capture = (fn: () => void): string => {\n\t\tconst at = lines.length;\n\t\tfn();\n\t\treturn lines.splice(at).map((l) => l.trim()).join('');\n\t};\n\n\t/**\n\t * A mask group: its appearance on the outer `<g data-vector-mask>`, the contents in an inner\n\t * `<g data-vector-part=\"masked\">` that references the `<clipPath>` or `<mask>`. Effects of the\n\t * group act on the contents, exported as a live group `<id>~content` around them.\n\t */\n\tconst emitMaskGroup = (node: VectorGroupNode & { mask: NonNullable<VectorGroupNode['mask']> }, depth: number) => {\n\t\tconst [source, ...contents] = node.children;\n\t\tconst body: VectorNode[] = node.effects?.length && contents.length ? [{ id: `${node.id}~content`, type: 'group', effects: node.effects, children: contents }] : contents;\n\t\tconst settings = { type: node.mask.type, ...(node.mask.invert ? { invert: true } : {}) };\n\t\tlines.push(`${indent(depth)}<g${common(node)} data-vector-mask=\"${escapeAttr(JSON.stringify(settings))}\">`);\n\t\tconst mask = vectorMaskRenderData(node, `${prefix}mask-${node.id}`, `${prefix}mask-filter-${node.id}`, precision);\n\t\tlet ref = '';\n\t\tif (mask && mask.type !== 'clip') {\n\t\t\tconst b = mask.bounds!;\n\t\t\tconst box = `x=\"${num(b.x)}\" y=\"${num(b.y)}\" width=\"${num(b.width)}\" height=\"${num(b.height)}\"`;\n\t\t\tif (mask.invertFilter) defs.push(vectorFilterMarkup(mask.invertFilter));\n\t\t\tconst inner = capture(() => emitNode(source, depth + 1));\n\t\t\tconst drawn = mask.filter ? `<g data-vector-part=\"mask-invert\" filter=\"${escapeAttr(mask.filter)}\">${inner}</g>` : inner;\n\t\t\tdefs.push(`<mask id=\"${escapeAttr(mask.id)}\" data-vector-part=\"mask-source\" maskUnits=\"userSpaceOnUse\" ${box}${mask.type === 'alpha' ? ' mask-type=\"alpha\"' : ''}>${drawn}</mask>`);\n\t\t\tref = ` mask=\"url(#${escapeAttr(mask.id)})\"`;\n\t\t} else {\n\t\t\t// The mask itself, hidden, for import (a clip's paint is not drawn; a mask turned off is hidden).\n\t\t\tlines.push(`${indent(depth + 1)}<g data-vector-part=\"mask-source\" display=\"none\">`);\n\t\t\temitNode(source, depth + 2);\n\t\t\tlines.push(`${indent(depth + 1)}</g>`);\n\t\t\tif (mask?.clip) {\n\t\t\t\tdefs.push(`<clipPath id=\"${escapeAttr(mask.id)}\">${mask.clip.map((c) => `<path d=\"${c.d}\" clip-rule=\"${c.clipRule}\"/>`).join('')}</clipPath>`);\n\t\t\t\tref = ` clip-path=\"url(#${escapeAttr(mask.id)})\"`;\n\t\t\t}\n\t\t}\n\t\tlines.push(`${indent(depth + 1)}<g data-vector-part=\"masked\"${ref}>`);\n\t\tfor (const child of body) emit(child, depth + 2);\n\t\tlines.push(`${indent(depth + 1)}</g>`);\n\t\tlines.push(`${indent(depth)}</g>`);\n\t};\n\n\tconst emitNode = (node: VectorNode, depth: number) => {\n\t\tif (isVectorMaskGroup(node)) {\n\t\t\temitMaskGroup(node, depth);\n\t\t\treturn;\n\t\t}\n\t\tif (hasOwnVectorAppearance(node)) {\n\t\t\t// Live: what it draws, then the editable source (hidden) for import.\n\t\t\tconst live = {\n\t\t\t\tkind: node.type,\n\t\t\t\t...(node.effects?.length ? { effects: node.effects } : {}),\n\t\t\t\t...(node.type === 'group' && node.liveBoolean ? { liveBoolean: node.liveBoolean } : {})\n\t\t\t};\n\t\t\tlines.push(`${indent(depth)}<g${common(node)} data-vector-live=\"${escapeAttr(JSON.stringify(live))}\">`);\n\t\t\tlines.push(`${indent(depth + 1)}<g data-vector-part=\"appearance\">`);\n\t\t\tfor (const shape of vectorAppearanceNodes(node)) emit(shape, depth + 2);\n\t\t\tlines.push(`${indent(depth + 1)}</g>`);\n\t\t\tlines.push(`${indent(depth + 1)}<g data-vector-part=\"source\" display=\"none\">`);\n\t\t\tif (node.type === 'path') {\n\t\t\t\tconst { effects: _e, transform: _t, opacity: _o, visible: _v, booleanOperation: _b, blendStep: _s, blendMode: _bm, filters: _f, ...source } = node;\n\t\t\t\temit({ ...source, id: `${node.id}~src` }, depth + 2);\n\t\t\t} else for (const child of node.children) emit(child, depth + 2);\n\t\t\tlines.push(`${indent(depth + 1)}</g>`);\n\t\t\tlines.push(`${indent(depth)}</g>`);\n\t\t\treturn;\n\t\t}\n\t\tif (node.type === 'group') {\n\t\t\tlines.push(`${indent(depth)}<g${common(node)}>`);\n\t\t\tfor (const child of node.children) emit(child, depth + 1);\n\t\t\tlines.push(`${indent(depth)}</g>`);\n\t\t\treturn;\n\t\t}\n\t\tif (needsVectorPaintLayers(node)) {\n\t\t\temitStacked(node, depth);\n\t\t\treturn;\n\t\t}\n\t\tconst fill = vectorPaintToSvg(node.fill, `${prefix}fill-${node.id}`, { node, precision });\n\t\tconst stroke = vectorPaintToSvg(node.stroke, `${prefix}stroke-${node.id}`, { node, role: 'stroke', precision });\n\t\tdefs.push(...paintMarkup(node.fill, fill.defs), ...paintMarkup(node.stroke, stroke.defs));\n\t\tconst d = vectorPathData(node, precision);\n\t\tconst live = liveCorners(node);\n\t\tconst fillAttrs = ` fill=\"${escapeAttr(fill.value)}\"${node.fillRule === 'evenodd' ? ` fill-rule=\"evenodd\"` : ''}`;\n\t\tconst lineAttrs = lineAttrsOf(node, stroke.value);\n\t\tconst parts = stroke.value !== 'none' ? vectorStrokeSvgParts(node, `${prefix}clip-${node.id}`, precision) : undefined;\n\t\tif (!parts) {\n\t\t\tlines.push(`${indent(depth)}<path${common(node)} d=\"${d}\"${fillAttrs}${stroke.value !== 'none' ? lineAttrs(node.strokeWidth ?? 1) : ''}${live}/>`);\n\t\t\treturn;\n\t\t}\n\t\t// The stroke options SVG has no attribute for, kept for import.\n\t\tlet data = ` data-vector-path=\"\" data-vector-stroke-width=\"${num(node.strokeWidth ?? 1)}\"`;\n\t\tif (parts.align !== 'center') data += ` data-vector-stroke-align=\"${parts.align}\"`;\n\t\tif (node.startArrow) data += ` data-vector-start-arrow=\"${node.startArrow}\"`;\n\t\tif (node.endArrow) data += ` data-vector-end-arrow=\"${node.endArrow}\"`;\n\t\tif (node.arrowAlign && node.arrowAlign !== 'extend') data += ` data-vector-arrow-align=\"${node.arrowAlign}\"`;\n\t\tif (node.startArrowScale !== undefined && node.startArrowScale !== 1) data += ` data-vector-start-arrow-scale=\"${num(node.startArrowScale)}\"`;\n\t\tif (node.endArrowScale !== undefined && node.endArrowScale !== 1) data += ` data-vector-end-arrow-scale=\"${num(node.endArrowScale)}\"`;\n\t\tconst profile = strokeWidthProfileOf(node);\n\t\tif (profile) {\n\t\t\t// Drawn as a filled outline: keep the line style the outline was built with.\n\t\t\tdata += ` data-vector-width-profile=\"${widthProfileToAttribute(profile)}\"`;\n\t\t\tif (node.strokeLinecap && node.strokeLinecap !== 'butt') data += ` data-vector-stroke-linecap=\"${node.strokeLinecap}\"`;\n\t\t\tif (node.strokeLinejoin && node.strokeLinejoin !== 'miter') data += ` data-vector-stroke-linejoin=\"${node.strokeLinejoin}\"`;\n\t\t\tif (node.strokeDasharray?.length) data += ` data-vector-stroke-dasharray=\"${node.strokeDasharray.map(num).join(' ')}\"`;\n\t\t}\n\t\tlines.push(`${indent(depth)}<g${common(node)}${data}>`);\n\t\tlines.push(`${indent(depth + 1)}<path data-vector-part=\"fill\" d=\"${d}\"${fillAttrs}${live}/>`);\n\t\tlines.push(...strokePartLines(node, parts, stroke.value, d, lineAttrs, depth + 1));\n\t\tlines.push(`${indent(depth)}</g>`);\n\t};\n\n\tfor (const node of doc.nodes) emit(node, 1);\n\tconst w = num(doc.width);\n\tconst h = num(doc.height);\n\tconst nl = pretty ? '\\n' : '';\n\tconst out = [`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${w}\" height=\"${h}\" viewBox=\"0 0 ${w} ${h}\">`];\n\tif (defs.length) out.push(`${indent(1)}<defs>${defs.join('')}</defs>`);\n\tif (doc.background && options.background !== false && hasPaint(doc.background)) {\n\t\tout.push(`${indent(1)}<rect width=\"${w}\" height=\"${h}\" fill=\"${escapeAttr(doc.background)}\"/>`);\n\t}\n\tout.push(...lines, '</svg>');\n\treturn out.join(nl);\n}\n\n// ---------------------------------------------------------------------------\n// Import\n// ---------------------------------------------------------------------------\n\nconst BOOLEAN_OPERATIONS: readonly VectorBooleanOperation[] = ['union', 'subtract', 'intersect', 'exclude'];\n\nexport interface VectorSvgImportOptions {\n\t/** Makes ids for elements without a usable `id` (default `node-1`, `node-2`, …). */\n\tcreateId?: () => string;\n\t/**\n\t * Merge neighbouring shapes with the same outline into one path with stacked fills and strokes,\n\t * as design tools export several paints on one layer (default false: an SVG may hold identical\n\t * shapes on purpose). Shapes merge only when the paint order stays the same (no stroke under a\n\t * later fill) and they share opacity, visibility, filters and blend mode.\n\t */\n\tmergeStackedShapes?: boolean;\n}\n\ninterface Element {\n\tname: string;\n\tattrs: Record<string, string>;\n\tchildren: Element[];\n}\n\n/** A tiny non-validating XML reader: elements and attributes only. */\nfunction parseXml(source: string): Element | null {\n\tconst text = source\n\t\t.replace(/<!--[\\s\\S]*?-->/g, '')\n\t\t.replace(/<\\?[\\s\\S]*?\\?>/g, '')\n\t\t.replace(/<!\\[CDATA\\[[\\s\\S]*?\\]\\]>/g, '')\n\t\t.replace(/<!DOCTYPE[^>[]*(\\[[\\s\\S]*?\\])?\\s*>/gi, '');\n\tconst root: Element = { name: '#root', attrs: {}, children: [] };\n\tconst stack: Element[] = [root];\n\tconst tag = /<(\\/?)([A-Za-z_][\\w:.-]*)((?:\\s+[^\\s=/>]+(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+))?)*)\\s*(\\/?)>/g;\n\tconst attr = /([^\\s=/>]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+)))?/g;\n\tlet m: RegExpExecArray | null;\n\twhile ((m = tag.exec(text))) {\n\t\tconst [, closing, rawName, rawAttrs, selfClosing] = m;\n\t\tconst name = rawName.replace(/^svg:/, '');\n\t\tif (closing) {\n\t\t\tfor (let i = stack.length - 1; i > 0; i--) {\n\t\t\t\tif (stack[i].name === name) {\n\t\t\t\t\tstack.length = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst attrs: Record<string, string> = {};\n\t\tlet a: RegExpExecArray | null;\n\t\tattr.lastIndex = 0;\n\t\twhile ((a = attr.exec(rawAttrs))) attrs[a[1]] = decodeEntities(a[2] ?? a[3] ?? a[4] ?? '');\n\t\tconst el: Element = { name, attrs, children: [] };\n\t\tstack[stack.length - 1].children.push(el);\n\t\tif (!selfClosing) stack.push(el);\n\t}\n\tconst find = (el: Element): Element | null => {\n\t\tif (el.name === 'svg') return el;\n\t\tfor (const c of el.children) {\n\t\t\tconst f = find(c);\n\t\t\tif (f) return f;\n\t\t}\n\t\treturn null;\n\t};\n\treturn find(root);\n}\n\nfunction decodeEntities(s: string): string {\n\treturn s\n\t\t.replace(/&#x([0-9a-f]+);/gi, (_, h) => String.fromCodePoint(parseInt(h, 16)))\n\t\t.replace(/&#(\\d+);/g, (_, d) => String.fromCodePoint(parseInt(d, 10)))\n\t\t.replace(/"/g, '\"')\n\t\t.replace(/'/g, \"'\")\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/&/g, '&');\n}\n\nconst numberList = (s: string | undefined): number[] =>\n\t(s ?? '')\n\t\t.trim()\n\t\t.split(/[\\s,]+|(?=-)(?<![eE])/)\n\t\t.filter(Boolean)\n\t\t.map(Number)\n\t\t.filter((n) => Number.isFinite(n));\n\nconst length = (s: string | undefined, fallback = 0): number => {\n\tif (s === undefined) return fallback;\n\tconst n = parseFloat(s);\n\treturn Number.isFinite(n) ? n : fallback;\n};\n\n/** Parses an SVG `transform` attribute into one matrix. */\nexport function parseSvgTransform(value: string | undefined): AffineMatrix {\n\tlet m: AffineMatrix = IDENTITY_MATRIX;\n\tif (!value) return m;\n\tconst re = /(matrix|translate|scale|rotate|skewX|skewY)\\s*\\(([^)]*)\\)/g;\n\tlet t: RegExpExecArray | null;\n\twhile ((t = re.exec(value))) {\n\t\tconst n = numberList(t[2]);\n\t\tlet step: AffineMatrix = IDENTITY_MATRIX;\n\t\tswitch (t[1]) {\n\t\t\tcase 'matrix':\n\t\t\t\tif (n.length >= 6) step = [n[0], n[1], n[2], n[3], n[4], n[5]];\n\t\t\t\tbreak;\n\t\t\tcase 'translate':\n\t\t\t\tstep = translateMatrix(n[0] ?? 0, n[1] ?? 0);\n\t\t\t\tbreak;\n\t\t\tcase 'scale':\n\t\t\t\tstep = scaleMatrix(n[0] ?? 1, n[1] ?? n[0] ?? 1);\n\t\t\t\tbreak;\n\t\t\tcase 'rotate':\n\t\t\t\tstep = rotateMatrix(n[0] ?? 0, { x: n[1] ?? 0, y: n[2] ?? 0 });\n\t\t\t\tbreak;\n\t\t\tcase 'skewX':\n\t\t\t\tstep = [1, 0, Math.tan(((n[0] ?? 0) * Math.PI) / 180), 1, 0, 0];\n\t\t\t\tbreak;\n\t\t\tcase 'skewY':\n\t\t\t\tstep = [1, Math.tan(((n[0] ?? 0) * Math.PI) / 180), 0, 1, 0, 0];\n\t\t\t\tbreak;\n\t\t}\n\t\t// SVG lists apply right to left: `translate(…) rotate(…)` rotates first.\n\t\tm = multiplyMatrices(step, m);\n\t}\n\treturn m;\n}\n\ninterface InheritedStyle {\n\tfill: string;\n\tstroke: string;\n\tstrokeWidth: string;\n\tstrokeLinecap?: string;\n\tstrokeLinejoin?: string;\n\tstrokeDasharray?: string;\n\tfillRule?: string;\n\tfillOpacity?: string;\n\tstrokeOpacity?: string;\n\t/** Not inherited: the element's own `mix-blend-mode` (reset for each element). */\n\tmixBlendMode?: string;\n\t/** Not inherited: the element's own `filter` (reset for each element). */\n\tfilter?: string;\n}\n\nconst STYLE_KEYS: Record<string, keyof InheritedStyle> = {\n\tfill: 'fill',\n\tstroke: 'stroke',\n\t'stroke-width': 'strokeWidth',\n\t'stroke-linecap': 'strokeLinecap',\n\t'stroke-linejoin': 'strokeLinejoin',\n\t'stroke-dasharray': 'strokeDasharray',\n\t'fill-rule': 'fillRule',\n\t'fill-opacity': 'fillOpacity',\n\t'stroke-opacity': 'strokeOpacity',\n\t'mix-blend-mode': 'mixBlendMode',\n\tfilter: 'filter'\n};\n\nfunction readStyle(el: Element, parent: InheritedStyle): InheritedStyle {\n\tconst { mixBlendMode: _m, filter: _f, ...inherited } = parent;\n\tconst out: InheritedStyle = { ...inherited };\n\tfor (const [attr, key] of Object.entries(STYLE_KEYS)) if (el.attrs[attr] !== undefined) out[key] = el.attrs[attr].trim();\n\tfor (const decl of (el.attrs.style ?? '').split(';')) {\n\t\tconst i = decl.indexOf(':');\n\t\tif (i < 0) continue;\n\t\tconst key = STYLE_KEYS[decl.slice(0, i).trim()];\n\t\tif (key) out[key] = decl.slice(i + 1).replace(/!important/, '').trim();\n\t}\n\treturn out;\n}\n\nfunction readStops(el: Element): VectorGradientStop[] {\n\treturn el.children\n\t\t.filter((c) => c.name === 'stop')\n\t\t.map((c) => {\n\t\t\tconst style = Object.fromEntries(\n\t\t\t\t(c.attrs.style ?? '')\n\t\t\t\t\t.split(';')\n\t\t\t\t\t.map((d) => d.split(':').map((s) => s.trim()))\n\t\t\t\t\t.filter((d) => d.length === 2)\n\t\t\t);\n\t\t\tconst raw = c.attrs.offset ?? '0';\n\t\t\tconst offset = raw.endsWith('%') ? parseFloat(raw) / 100 : parseFloat(raw);\n\t\t\tconst opacity = style['stop-opacity'] ?? c.attrs['stop-opacity'];\n\t\t\treturn {\n\t\t\t\toffset: Number.isFinite(offset) ? Math.max(0, Math.min(1, offset)) : 0,\n\t\t\t\tcolor: style['stop-color'] ?? c.attrs['stop-color'] ?? '#000',\n\t\t\t\t...(opacity !== undefined ? { opacity: parseFloat(opacity) } : {})\n\t\t\t};\n\t\t});\n}\n\nconst fraction = (s: string | undefined, fallback: number) => {\n\tif (s === undefined) return fallback;\n\tconst n = parseFloat(s);\n\tif (!Number.isFinite(n)) return fallback;\n\treturn s.trim().endsWith('%') ? n / 100 : n;\n};\n\nconst PAINT_SERVERS = new Set(['linearGradient', 'radialGradient', 'pattern']);\n\nfunction collectGradients(el: Element, raw: Map<string, Element>) {\n\tif (PAINT_SERVERS.has(el.name) && el.attrs.id) raw.set(el.attrs.id, el);\n\tfor (const c of el.children) collectGradients(c, raw);\n}\n\n/** Every `<clipPath>` and `<mask>` with an id. */\nfunction collectMasks(el: Element, raw: Map<string, Element>) {\n\tif ((el.name === 'clipPath' || el.name === 'mask') && el.attrs.id) raw.set(el.attrs.id, el);\n\tfor (const c of el.children) collectMasks(c, raw);\n}\n\n/** An attribute, or the same property in the element's `style`. */\nfunction attrOrStyle(el: Element, name: string): string | undefined {\n\tfor (const decl of (el.attrs.style ?? '').split(';')) {\n\t\tconst i = decl.indexOf(':');\n\t\tif (i >= 0 && decl.slice(0, i).trim() === name) return decl.slice(i + 1).replace(/!important/, '').trim();\n\t}\n\treturn el.attrs[name];\n}\n\n/** The id an `url(#id)` reference names, or null. */\nfunction urlId(value: string | undefined): string | null {\n\treturn /^url\\(\\s*['\"]?#([^'\")\\s]+)['\"]?\\s*\\)/.exec((value ?? '').trim())?.[1] ?? null;\n}\n\n/** A `<clipPath>`'s content with each `clip-rule` read as the `fill-rule` import knows. */\nfunction clipRulesAsFillRules(el: Element): Element {\n\tconst attrs = { ...el.attrs };\n\tconst rule = attrOrStyle(el, 'clip-rule');\n\tif (rule) attrs['fill-rule'] = rule;\n\treturn { ...el, attrs, children: el.children.map(clipRulesAsFillRules) };\n}\n\nfunction collectFilters(el: Element, raw: Map<string, Element>) {\n\tif (el.name === 'filter' && el.attrs.id) raw.set(el.attrs.id, el);\n\tfor (const c of el.children) collectFilters(c, raw);\n}\n\n/**\n * A `<filter>` as vector filters: our own export's `data-vector-filters`, or the simple filters\n * other tools write — `feDropShadow`, or a lone `feGaussianBlur` of the source (a layer blur).\n * Anything else is skipped (empty list).\n */\nfunction filtersFromElement(el: Element): VectorFilter[] {\n\tconst own = el.attrs['data-vector-filters'];\n\tif (own !== undefined) {\n\t\ttry {\n\t\t\treturn sanitizeVectorFilters(JSON.parse(own));\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\tconst prims = el.children.filter((c) => c.name.startsWith('fe'));\n\tconst out: unknown[] = [];\n\tfor (const p of prims) {\n\t\tconst std = numberList(p.attrs.stdDeviation)[0] ?? 0;\n\t\tif (p.name === 'feDropShadow') {\n\t\t\tconst style = Object.fromEntries(\n\t\t\t\t(p.attrs.style ?? '')\n\t\t\t\t\t.split(';')\n\t\t\t\t\t.map((d) => d.split(':').map((x) => x.trim()))\n\t\t\t\t\t.filter((d) => d.length === 2)\n\t\t\t);\n\t\t\tconst opacity = parseFloat(style['flood-opacity'] ?? p.attrs['flood-opacity'] ?? '1');\n\t\t\tout.push({\n\t\t\t\ttype: 'dropShadow',\n\t\t\t\tparams: {\n\t\t\t\t\tcolor: style['flood-color'] ?? p.attrs['flood-color'] ?? '#000000',\n\t\t\t\t\topacity: Number.isFinite(opacity) ? opacity : 1,\n\t\t\t\t\toffsetX: length(p.attrs.dx, 2),\n\t\t\t\t\toffsetY: length(p.attrs.dy, 2),\n\t\t\t\t\tblur: std * 2,\n\t\t\t\t\tspread: 0\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (p.name === 'feGaussianBlur' && prims.length === 1 && (p.attrs.in === undefined || p.attrs.in === 'SourceGraphic')) {\n\t\t\tout.push({ type: 'layerBlur', params: { radius: std * 2 } });\n\t\t} else return [];\n\t}\n\treturn sanitizeVectorFilters(out);\n}\n\n/** The gradient a `data-vector-gradient` attribute (our own export) holds, or null. */\nfunction gradientFromAttribute(value: string | undefined): VectorGradient | null {\n\tif (!value) return null;\n\ttry {\n\t\treturn sanitizeVectorGradient(JSON.parse(value));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * A `<linearGradient>` / `<radialGradient>` (attributes and stops inherited through `href`) as a\n * vector gradient: `gradientUnits`, `gradientTransform`, `spreadMethod`, `fx`, `fy` and `fr` read.\n * Box gradients that match the angle / centre shorthand keep it.\n */\nfunction resolveGradient(id: string, raw: Map<string, Element>): VectorGradient | null {\n\tconst first = raw.get(id);\n\tif (!first) return null;\n\tconst own = gradientFromAttribute(first.attrs['data-vector-gradient']);\n\tif (own) return own;\n\tif (first.name === 'pattern') return null;\n\t// The href chain: attributes and stops come from the nearest element that has them.\n\tconst chain: Element[] = [];\n\tfor (let el: Element | undefined = first; el && !chain.includes(el) && chain.length < 32; ) {\n\t\tchain.push(el);\n\t\tconst href: string | undefined = el.attrs.href ?? el.attrs['xlink:href'];\n\t\tel = href?.startsWith('#') ? raw.get(href.slice(1)) : undefined;\n\t}\n\tconst attr = (name: string) => chain.find((el) => el.attrs[name] !== undefined)?.attrs[name];\n\tconst stops = chain.map(readStops).find((s) => s.length) ?? [];\n\tif (!stops.length) return null;\n\tconst user = attr('gradientUnits') === 'userSpaceOnUse';\n\tconst t = parseSvgTransform(attr('gradientTransform'));\n\tconst plain = t === IDENTITY_MATRIX || (t[0] === 1 && t[1] === 0 && t[2] === 0 && t[3] === 1 && t[4] === 0 && t[5] === 0);\n\tconst at = (name: string, fallback: number) => (user ? length(attr(name), fallback) : fraction(attr(name), fallback));\n\tconst spreadAttr = attr('spreadMethod');\n\tconst spread = spreadAttr === 'reflect' || spreadAttr === 'repeat' ? { spread: spreadAttr as 'reflect' | 'repeat' } : {};\n\tconst map = (p: { x: number; y: number }) => applySvgMatrix(t, p);\n\tif (first.name === 'radialGradient') {\n\t\tconst cx = at('cx', user ? 0 : 0.5);\n\t\tconst cy = at('cy', user ? 0 : 0.5);\n\t\tconst r = at('r', user ? 0 : 0.5);\n\t\tconst fx = attr('fx') !== undefined ? at('fx', cx) : cx;\n\t\tconst fy = attr('fy') !== undefined ? at('fy', cy) : cy;\n\t\tconst fr = attr('fr') !== undefined ? at('fr', 0) : 0;\n\t\tconst focal = Math.abs(fx - cx) > 1e-9 || Math.abs(fy - cy) > 1e-9;\n\t\tif (!user && plain && !focal && !(fr > 0)) return { type: 'radial', cx, cy, r, stops, ...spread };\n\t\tconst g: VectorGradient = {\n\t\t\ttype: 'radial',\n\t\t\tstops,\n\t\t\tstart: map({ x: cx, y: cy }),\n\t\t\tend: map({ x: cx + r, y: cy }),\n\t\t\twidth: map({ x: cx, y: cy + r }),\n\t\t\tunits: user ? 'userSpaceOnUse' : 'objectBoundingBox',\n\t\t\t...spread\n\t\t};\n\t\tif (focal) g.focal = map({ x: fx, y: fy });\n\t\tif (fr > 0 && r > 0) g.focalRadius = Math.min(0.99, fr / r);\n\t\treturn g;\n\t}\n\tconst x1 = at('x1', 0);\n\tconst y1 = at('y1', 0);\n\tconst x2 = attr('x2') !== undefined ? at('x2', 1) : user ? 0 : 1;\n\tconst y2 = at('y2', 0);\n\tif (!user && plain) {\n\t\t// CSS angle: 0° points up, clockwise. Keep the shorthand when it paints the same.\n\t\tconst angle = Math.round(((Math.atan2(x2 - x1, -(y2 - y1)) * 180) / Math.PI + 360) % 360);\n\t\tconst c = angleToSvgLinearCoords(angle);\n\t\tconst len = Math.hypot(x2 - x1, y2 - y1);\n\t\tconst d = len > 0 ? { x: (x2 - x1) / len, y: (y2 - y1) / len } : { x: 0, y: 1 };\n\t\tconst along = (x: number, y: number) => x * d.x + y * d.y;\n\t\tconst same =\n\t\t\tlen > 0 &&\n\t\t\tMath.abs((c.x2 - c.x1) * d.y - (c.y2 - c.y1) * d.x) < 1e-3 &&\n\t\t\tMath.abs(along(c.x1, c.y1) - along(x1, y1)) < 1e-3 &&\n\t\t\tMath.abs(along(c.x2, c.y2) - along(x2, y2)) < 1e-3;\n\t\tif (same) return { type: 'linear', angle, stops, ...spread };\n\t}\n\tconst start = { x: x1, y: y1 };\n\tconst end = { x: x2, y: y2 };\n\treturn {\n\t\ttype: 'linear',\n\t\tstops,\n\t\tstart: map(start),\n\t\tend: map(end),\n\t\twidth: map({ x: x1 - (y2 - y1), y: y1 + (x2 - x1) }),\n\t\tunits: user ? 'userSpaceOnUse' : 'objectBoundingBox',\n\t\t...spread\n\t};\n}\n\nconst applySvgMatrix = (m: AffineMatrix, p: { x: number; y: number }) => ({ x: m[0] * p.x + m[2] * p.y + m[4], y: m[1] * p.x + m[3] * p.y + m[5] });\n\n/** Parses SVG markup into a vector document. Throws when there is no `<svg>` element. */\nexport function parseVectorSvg(svg: string, options: VectorSvgImportOptions = {}): VectorDocument {\n\tconst root = parseXml(svg);\n\tif (!root) throw new Error('The markup has no <svg> element.');\n\tlet counter = 0;\n\tconst usedIds = new Set<string>();\n\tconst createId = options.createId ?? (() => `node-${++counter}`);\n\tconst idFor = (el: Element) => {\n\t\tconst id = el.attrs.id;\n\t\tif (id && !usedIds.has(id)) {\n\t\t\tusedIds.add(id);\n\t\t\treturn id;\n\t\t}\n\t\tlet next = createId();\n\t\twhile (usedIds.has(next)) next = createId();\n\t\tusedIds.add(next);\n\t\treturn next;\n\t};\n\n\tconst rawGradients = new Map<string, Element>();\n\tcollectGradients(root, rawGradients);\n\tconst rawFilters = new Map<string, Element>();\n\tcollectFilters(root, rawFilters);\n\tconst rawMasks = new Map<string, Element>();\n\tcollectMasks(root, rawMasks);\n\t/** Masks being read (a mask that refers back to itself is ignored there). */\n\tconst resolving = new Set<string>();\n\tconst filtersOf = (value: string | undefined): VectorFilter[] => {\n\t\tconst url = /^url\\(\\s*['\"]?#([^'\")\\s]+)['\"]?\\s*\\)/.exec((value ?? '').trim());\n\t\tconst el = url ? rawFilters.get(url[1]) : undefined;\n\t\treturn el ? filtersFromElement(el) : [];\n\t};\n\tconst paint = (value: string): VectorPaint => {\n\t\tconst v = value.trim();\n\t\tconst url = /^url\\(\\s*['\"]?#([^'\")\\s]+)['\"]?\\s*\\)/.exec(v);\n\t\tif (url) return resolveGradient(url[1], rawGradients) ?? null;\n\t\tif (v === 'none' || v === '') return null;\n\t\treturn v;\n\t};\n\n\tconst viewBox = numberList(root.attrs.viewBox);\n\tconst width = viewBox.length === 4 ? viewBox[2] : length(root.attrs.width, 300);\n\tconst height = viewBox.length === 4 ? viewBox[3] : length(root.attrs.height, 150);\n\tconst rootMatrix: AffineMatrix = viewBox.length === 4 ? translateMatrix(-viewBox[0], -viewBox[1]) : IDENTITY_MATRIX;\n\n\tconst SKIP = new Set(['defs', 'clipPath', 'mask', 'symbol', 'style', 'title', 'desc', 'metadata', 'pattern', 'marker', 'filter', 'text', 'image', 'use', 'linearGradient', 'radialGradient', 'script', 'foreignObject']);\n\n\tconst shapeOf = (el: Element): VectorSubpath[] | null => {\n\t\tconst a = el.attrs;\n\t\tswitch (el.name) {\n\t\t\tcase 'path': {\n\t\t\t\t// Our own export: the sharp path and its live corners.\n\t\t\t\tif (a['data-vector-d'] && a['data-vector-corners']) {\n\t\t\t\t\tconst sharp = bezierToSubpaths(a['data-vector-d']);\n\t\t\t\t\tif (sharp.length) return applyVectorCornersAttribute(sharp, a['data-vector-corners']);\n\t\t\t\t}\n\t\t\t\treturn a.d ? bezierToSubpaths(a.d) : null;\n\t\t\t}\n\t\t\tcase 'rect': {\n\t\t\t\tconst w = length(a.width);\n\t\t\t\tconst h = length(a.height);\n\t\t\t\tif (w <= 0 || h <= 0) return null;\n\t\t\t\tconst r = length(a.rx ?? a.ry, 0);\n\t\t\t\treturn [rectSubpath({ x: length(a.x), y: length(a.y), width: w, height: h }, r)];\n\t\t\t}\n\t\t\tcase 'circle': {\n\t\t\t\tconst r = length(a.r);\n\t\t\t\tif (r <= 0) return null;\n\t\t\t\tconst cx = length(a.cx);\n\t\t\t\tconst cy = length(a.cy);\n\t\t\t\treturn [ellipseSubpath({ x: cx - r, y: cy - r, width: 2 * r, height: 2 * r })];\n\t\t\t}\n\t\t\tcase 'ellipse': {\n\t\t\t\tconst rx = length(a.rx);\n\t\t\t\tconst ry = length(a.ry);\n\t\t\t\tif (rx <= 0 || ry <= 0) return null;\n\t\t\t\treturn [ellipseSubpath({ x: length(a.cx) - rx, y: length(a.cy) - ry, width: 2 * rx, height: 2 * ry })];\n\t\t\t}\n\t\t\tcase 'line':\n\t\t\t\treturn [lineSubpath({ x: length(a.x1), y: length(a.y1) }, { x: length(a.x2), y: length(a.y2) })];\n\t\t\tcase 'polyline':\n\t\t\tcase 'polygon': {\n\t\t\t\tconst n = numberList(a.points);\n\t\t\t\tif (n.length < 4) return null;\n\t\t\t\tconst anchors = [];\n\t\t\t\tfor (let i = 0; i + 1 < n.length; i += 2) anchors.push({ x: n[i], y: n[i + 1] });\n\t\t\t\treturn [{ anchors, closed: el.name === 'polygon' }];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t};\n\n\tconst strokeStyle = (s: InheritedStyle): Partial<VectorPathNode> => ({\n\t\t...(s.strokeWidth ? { strokeWidth: length(s.strokeWidth, 1) } : {}),\n\t\t...(s.strokeLinecap ? { strokeLinecap: s.strokeLinecap as VectorLineCap } : {}),\n\t\t...(s.strokeLinejoin ? { strokeLinejoin: s.strokeLinejoin as VectorLineJoin } : {}),\n\t\t...(s.strokeDasharray && s.strokeDasharray !== 'none' ? { strokeDasharray: numberList(s.strokeDasharray) } : {}),\n\t\t...(s.fillRule === 'evenodd' ? { fillRule: 'evenodd' as VectorFillRule } : {})\n\t});\n\n\t/** A node mapped by `m` (scale and skew baked in, stroke width scaled). */\n\tconst placed = (node: VectorPathNode, m: AffineMatrix): VectorPathNode => {\n\t\tif (m === IDENTITY_MATRIX) return node;\n\t\tconst next = transformVectorNode(node, m);\n\t\tconst strokeScale = Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));\n\t\tif (strokeScale > 0 && Math.abs(strokeScale - 1) > 1e-9) {\n\t\t\tif (hasPaint(next.stroke)) next.strokeWidth = (next.strokeWidth ?? 1) * strokeScale;\n\t\t\tif (Array.isArray(next.strokes)) next.strokes = next.strokes.map((l) => ((l.kind ?? 'paint') === 'paint' ? { ...l, strokeWidth: (l.strokeWidth ?? 1) * strokeScale } : l));\n\t\t}\n\t\treturn normalizeVectorPaintStacks(next, 'stack');\n\t};\n\n\t/** Paint with an element's `fill-opacity` / `stroke-opacity`: a one-layer stack when it is below 1. */\n\tconst withOpacities = (node: VectorPathNode, s: InheritedStyle): VectorPathNode => {\n\t\tlet out = node;\n\t\tconst fo = s.fillOpacity !== undefined ? fraction(s.fillOpacity, 1) : 1;\n\t\tconst so = s.strokeOpacity !== undefined ? fraction(s.strokeOpacity, 1) : 1;\n\t\tif (fo < 1 && hasPaint(out.fill)) out = withVectorFills(out, [{ paint: out.fill!, opacity: Math.max(0, fo) }]);\n\t\tif (so < 1 && hasPaint(out.stroke)) out = withVectorStrokes(out, vectorStrokes(out).map((l) => ({ ...l, opacity: Math.max(0, so) })));\n\t\treturn out;\n\t};\n\n\t/**\n\t * A `<g data-vector-path data-vector-fills>` from our own export (a path painted through its\n\t * stacks) as the path it came from: the geometry of its first fill part, the stacks from JSON.\n\t */\n\tconst stackedPath = (g: Element, _style: InheritedStyle, m: AffineMatrix, meta: Partial<VectorPathNode>): VectorPathNode | null => {\n\t\tconst fillEl = g.children.find((c) => c.name === 'path' && c.attrs['data-vector-part'] === 'fill');\n\t\tconst subpaths = fillEl ? shapeOf(fillEl) : null;\n\t\tif (!subpaths?.length) return null;\n\t\tconst parse = (v: string | undefined) => {\n\t\t\ttry {\n\t\t\t\treturn v ? JSON.parse(v) : [];\n\t\t\t} catch {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t};\n\t\tlet node: VectorPathNode = { id: idFor(g), type: 'path', ...meta, subpaths, fill: null, stroke: null };\n\t\tif (g.attrs['data-vector-fill-rule'] === 'evenodd') node.fillRule = 'evenodd';\n\t\tnode = withVectorFills(node, sanitizeVectorFills(parse(g.attrs['data-vector-fills'])));\n\t\tnode = withVectorStrokes(node, sanitizeVectorStrokes(parse(g.attrs['data-vector-strokes'])));\n\t\treturn placed(node, m);\n\t};\n\n\t/**\n\t * Neighbouring paths with the same outline merged into one with stacked paints (see\n\t * `mergeStackedShapes`).\n\t */\n\tconst mergeStacked = (nodes: VectorNode[]): VectorNode[] => {\n\t\tconst out: VectorNode[] = [];\n\t\tconst key = (n: VectorPathNode) =>\n\t\t\tJSON.stringify([n.subpaths, n.transform ?? null, n.opacity ?? 1, n.visible !== false, n.filters ?? null, n.blendMode ?? 'normal', n.fillRule ?? 'nonzero', n.booleanOperation ?? null]);\n\t\tfor (const n of nodes) {\n\t\t\tconst prev = out[out.length - 1];\n\t\t\tif (prev?.type === 'path' && n.type === 'path' && key(prev) === key(n)) {\n\t\t\t\tconst fills = vectorFills(n);\n\t\t\t\tconst strokesBefore = vectorStrokes(prev);\n\t\t\t\t// A later fill would land under an earlier stroke: keep them apart.\n\t\t\t\tif (!(fills.length && strokesBefore.length)) {\n\t\t\t\t\tlet merged = withVectorFills(prev, [...vectorFills(prev), ...fills]);\n\t\t\t\t\tmerged = withVectorStrokes(merged, [...strokesBefore, ...vectorStrokes(n)]);\n\t\t\t\t\tout[out.length - 1] = merged;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tout.push(n);\n\t\t}\n\t\treturn out;\n\t};\n\n\t/**\n\t * A `<g data-vector-path>` from our own export (an aligned or arrowed stroke drawn in parts)\n\t * as the one path it came from: the fill part's outline and fill, the stroke part's paint and\n\t * line style, and the options the group's data attributes keep.\n\t */\n\tconst mergedPath = (g: Element, style: InheritedStyle, m: AffineMatrix, meta: Partial<VectorPathNode>): VectorPathNode | null => {\n\t\tconst part = (name: string) => g.children.find((c) => c.name === 'path' && c.attrs['data-vector-part'] === name);\n\t\tconst fillEl = part('fill');\n\t\tconst subpaths = fillEl ? shapeOf(fillEl) : null;\n\t\tif (!fillEl || !subpaths?.length) return null;\n\t\tconst a = g.attrs;\n\t\tconst fs = readStyle(fillEl, style);\n\t\tconst strokeEl = part('stroke');\n\t\tconst outlineEl = part('stroke-outline');\n\t\tconst ss = strokeEl ? readStyle(strokeEl, style) : null;\n\t\tconst width = length(a['data-vector-stroke-width'], ss ? length(ss.strokeWidth, 1) : 1);\n\t\tconst arrow = (v: string | undefined) => (VECTOR_ARROWHEADS.includes(v as VectorArrowhead) ? (v as VectorArrowhead) : undefined);\n\t\tconst scale = (v: string | undefined) => {\n\t\t\tconst n = v === undefined ? NaN : parseFloat(v);\n\t\t\treturn n > 0 ? n : undefined;\n\t\t};\n\t\tconst align = a['data-vector-stroke-align'];\n\t\tconst profile = widthProfileFromAttribute(a['data-vector-width-profile']);\n\t\tconst kept = (key: string, values: readonly string[]) => (values.includes(a[key]) ? a[key] : undefined);\n\t\tconst keptCap = kept('data-vector-stroke-linecap', ['round', 'square']) as VectorLineCap | undefined;\n\t\tconst keptJoin = kept('data-vector-stroke-linejoin', ['round', 'bevel']) as VectorLineJoin | undefined;\n\t\tconst keptDash = a['data-vector-stroke-dasharray'] ? numberList(a['data-vector-stroke-dasharray']) : undefined;\n\t\tconst node: VectorPathNode = {\n\t\t\tid: idFor(g),\n\t\t\ttype: 'path',\n\t\t\t...meta,\n\t\t\tsubpaths,\n\t\t\tfill: paint(fs.fill),\n\t\t\tstroke: ss ? paint(ss.stroke) : outlineEl ? paint(readStyle(outlineEl, style).fill) : null,\n\t\t\t...(ss ? strokeStyle(ss) : {}),\n\t\t\t...(fs.fillRule === 'evenodd' ? { fillRule: 'evenodd' as VectorFillRule } : {}),\n\t\t\tstrokeWidth: width,\n\t\t\t...(align === 'inside' || align === 'outside' ? { strokeAlign: align } : {}),\n\t\t\t...(arrow(a['data-vector-start-arrow']) ? { startArrow: arrow(a['data-vector-start-arrow']) } : {}),\n\t\t\t...(arrow(a['data-vector-end-arrow']) ? { endArrow: arrow(a['data-vector-end-arrow']) } : {}),\n\t\t\t...(a['data-vector-arrow-align'] === 'tip' ? { arrowAlign: 'tip' as const } : {}),\n\t\t\t...(scale(a['data-vector-start-arrow-scale']) ? { startArrowScale: scale(a['data-vector-start-arrow-scale']) } : {}),\n\t\t\t...(scale(a['data-vector-end-arrow-scale']) ? { endArrowScale: scale(a['data-vector-end-arrow-scale']) } : {}),\n\t\t\t...(profile.length ? { strokeWidthProfile: profile } : {}),\n\t\t\t...(keptCap ? { strokeLinecap: keptCap } : {}),\n\t\t\t...(keptJoin ? { strokeLinejoin: keptJoin } : {}),\n\t\t\t...(keptDash?.length ? { strokeDasharray: keptDash } : {})\n\t\t};\n\t\treturn placed(node, m);\n\t};\n\n\t/**\n\t * A `<g data-vector-live>` from our own export (path effects or a live boolean) as the node it\n\t * came from: its hidden source part with the effects put back (their offsets carried through\n\t * what import bakes into the geometry). The drawn appearance part is regenerated.\n\t */\n\tconst liveNode = (g: Element, style: InheritedStyle, m: AffineMatrix, meta: Pick<VectorNode, 'name' | 'opacity' | 'visible' | 'booleanOperation' | 'blendMode' | 'filters'>): VectorNode | null => {\n\t\tlet raw: Record<string, unknown> = {};\n\t\ttry {\n\t\t\traw = JSON.parse(g.attrs['data-vector-live']) ?? {};\n\t\t} catch {\n\t\t\traw = {};\n\t\t}\n\t\tconst sourceEl = g.children.find((c) => c.name === 'g' && c.attrs['data-vector-part'] === 'source');\n\t\tif (!sourceEl) return null;\n\t\tconst inner = visit(sourceEl, style, m);\n\t\tconst effects = sanitizeVectorEffects(raw.effects);\n\t\tconst liveBoolean = BOOLEAN_OPERATIONS.includes(raw.liveBoolean as VectorBooleanOperation) ? (raw.liveBoolean as VectorBooleanOperation) : null;\n\t\tconst id = idFor(g);\n\t\tif (raw.kind === 'path') {\n\t\t\tconst path = inner.find((n): n is VectorPathNode => n.type === 'path');\n\t\t\tif (!path) return null;\n\t\t\tconst { residual } = decomposeRigid(m);\n\t\t\tconst { visible: _v, ...rest } = path;\n\t\t\treturn { ...rest, id, ...meta, ...(effects.length ? { effects: transformVectorEffects(effects, residual) } : {}) };\n\t\t}\n\t\tif (!inner.length) return null;\n\t\tconst group: VectorGroupNode = { id, type: 'group', ...meta, children: inner };\n\t\tif (effects.length) group.effects = transformVectorEffects(effects, m);\n\t\tif (liveBoolean) group.liveBoolean = liveBoolean;\n\t\tconst blend = blendFromAttribute(g.attrs['data-vector-blend'], m);\n\t\tif (blend) group.blend = blend;\n\t\treturn group;\n\t};\n\n\tconst visit = (el: Element, style: InheritedStyle, matrix: AffineMatrix): VectorNode[] => {\n\t\tconst out: VectorNode[] = [];\n\t\tfor (const child of el.children) {\n\t\t\tif (SKIP.has(child.name)) continue;\n\t\t\tconst nodes = visitOne(child, style, matrix);\n\t\t\tout.push(...(nodes.length ? masked(child, nodes, multiplyMatrices(parseSvgTransform(child.attrs.transform), matrix)) : nodes));\n\t\t}\n\t\treturn options.mergeStackedShapes ? mergeStacked(out) : out;\n\t};\n\n\t/** The base style mask and clip content inherits (the document's, not the referencing element's). */\n\tlet rootStyle: InheritedStyle = { fill: '#000', stroke: 'none', strokeWidth: '' };\n\n\t/** Maps a unit box onto the bounds of `nodes` (`objectBoundingBox` units), or null without bounds. */\n\tconst bboxMatrix = (nodes: readonly VectorNode[]): AffineMatrix | null => {\n\t\tconst b = unionBounds(nodes.map((n) => vectorNodeBounds(n)));\n\t\treturn b && b.width > 0 && b.height > 0 ? [b.width, 0, 0, b.height, b.x, b.y] : null;\n\t};\n\n\t/** The nodes a `<clipPath>` or `<mask>` holds as one mask node (several are grouped), or null. */\n\tconst maskNode = (el: Element, m: AffineMatrix, nodes: readonly VectorNode[], units: string | undefined): VectorNode | null => {\n\t\tconst id = el.attrs.id;\n\t\tif (!id || resolving.has(id)) return null;\n\t\tlet space = m;\n\t\tif (units === 'objectBoundingBox') {\n\t\t\tconst box = bboxMatrix(nodes);\n\t\t\tif (!box) return null;\n\t\t\tspace = box;\n\t\t}\n\t\tresolving.add(id);\n\t\tconst isClip = el.name === 'clipPath';\n\t\tconst content = isClip ? clipRulesAsFillRules(el) : el;\n\t\tconst inner = visit(content, readStyle(content, rootStyle), multiplyMatrices(parseSvgTransform(el.attrs.transform), space));\n\t\tresolving.delete(id);\n\t\t// A clip's paint is not drawn: imported clips are unpainted outlines.\n\t\tconst strip = (n: VectorNode): VectorNode => (n.type === 'path' ? withVectorStrokes(withVectorFills({ ...n, fill: null, stroke: null }, []), []) : { ...n, children: n.children.map(strip) });\n\t\tconst list = isClip ? inner.map(strip) : inner;\n\t\tif (!list.length) return null;\n\t\treturn list.length === 1 ? list[0] : { id: idFor({ name: 'g', attrs: {}, children: [] }), type: 'group', name: isClip ? 'Clip' : 'Mask', children: list };\n\t};\n\n\t/**\n\t * Nodes made from an element that has `clip-path` and / or `mask`: wrapped in a mask group (the\n\t * clip or mask first), the clip inside the mask as SVG applies them. References to unknown or\n\t * unusable masks are dropped.\n\t */\n\tconst masked = (el: Element, nodes: VectorNode[], m: AffineMatrix): VectorNode[] => {\n\t\tlet out = nodes;\n\t\tconst clipEl = rawMasks.get(urlId(attrOrStyle(el, 'clip-path')) ?? '');\n\t\tif (clipEl?.name === 'clipPath') {\n\t\t\tconst source = maskNode(clipEl, m, out, clipEl.attrs.clipPathUnits);\n\t\t\tif (source) out = [{ id: idFor({ name: 'g', attrs: {}, children: [] }), type: 'group', name: 'Clip Group', mask: { type: 'clip' }, children: [source, ...out] }];\n\t\t}\n\t\tconst maskEl = rawMasks.get(urlId(attrOrStyle(el, 'mask')) ?? '');\n\t\tif (maskEl?.name === 'mask') {\n\t\t\tconst source = maskNode(maskEl, m, out, maskEl.attrs.maskContentUnits);\n\t\t\tconst type = attrOrStyle(maskEl, 'mask-type') === 'alpha' ? 'alpha' : 'luminance';\n\t\t\tif (source) out = [{ id: idFor({ name: 'g', attrs: {}, children: [] }), type: 'group', name: 'Opacity Mask', mask: { type }, children: [source, ...out] }];\n\t\t}\n\t\treturn out;\n\t};\n\n\t/**\n\t * A `<g data-vector-mask>` from our own export as the mask group it came from: the mask from its\n\t * hidden source part or its `<mask>`, the contents from the masked part (a `<id>~content` live\n\t * group there gives back the group's effects).\n\t */\n\tconst maskGroup = (g: Element, style: InheritedStyle, m: AffineMatrix, meta: Partial<VectorGroupNode>): VectorNode | null => {\n\t\tlet raw: unknown = null;\n\t\ttry {\n\t\t\traw = JSON.parse(g.attrs['data-vector-mask']);\n\t\t} catch {\n\t\t\traw = null;\n\t\t}\n\t\tconst mask = sanitizeVectorMask(raw);\n\t\tconst part = (name: string) => g.children.find((c) => c.name === 'g' && c.attrs['data-vector-part'] === name);\n\t\tconst maskedEl = part('masked');\n\t\tif (!mask || !maskedEl) return null;\n\t\tconst id = idFor(g);\n\t\tlet sourceEl = part('mask-source');\n\t\tif (!sourceEl) {\n\t\t\tconst el = rawMasks.get(urlId(maskedEl.attrs.mask) ?? '');\n\t\t\tconst invert = el?.children.find((c) => c.name === 'g' && c.attrs['data-vector-part'] === 'mask-invert');\n\t\t\tsourceEl = invert ?? el;\n\t\t}\n\t\tconst source = sourceEl ? visit(sourceEl, style, m)[0] : undefined;\n\t\tlet contents = visit(maskedEl, style, m);\n\t\tlet effects: VectorEffect[] | undefined;\n\t\tconst wrapper = contents.length === 1 && contents[0].type === 'group' && contents[0].id === `${id}~content` ? contents[0] : null;\n\t\tif (wrapper?.type === 'group') {\n\t\t\teffects = wrapper.effects ?? undefined;\n\t\t\tcontents = wrapper.children;\n\t\t}\n\t\tif (!source) return contents.length ? { id, type: 'group', ...meta, children: contents } : null;\n\t\treturn { id, type: 'group', ...meta, mask, ...(effects?.length ? { effects } : {}), children: [source, ...contents] };\n\t};\n\n\tconst visitOne = (child: Element, style: InheritedStyle, matrix: AffineMatrix): VectorNode[] => {\n\t\tconst out: VectorNode[] = [];\n\t\tconst m = multiplyMatrices(parseSvgTransform(child.attrs.transform), matrix);\n\t\tconst s = readStyle(child, style);\n\t\tconst opacity = child.attrs.opacity !== undefined ? parseFloat(child.attrs.opacity) : undefined;\n\t\tconst hidden = child.attrs.display === 'none' || child.attrs.visibility === 'hidden';\n\t\tconst blendMode = vectorBlendModeFromCss(s.mixBlendMode);\n\t\tconst filters = filtersOf(s.filter);\n\t\tconst meta = {\n\t\t\t...(child.attrs['inkscape:label'] || child.attrs['data-name'] ? { name: child.attrs['inkscape:label'] ?? child.attrs['data-name'] } : {}),\n\t\t\t...(opacity !== undefined && Number.isFinite(opacity) && opacity < 1 ? { opacity } : {}),\n\t\t\t...(hidden ? { visible: false } : {}),\n\t\t\t...(blendMode && blendMode !== 'normal' ? { blendMode } : {}),\n\t\t\t...(filters.length ? { filters } : {})\n\t\t};\n\t\t// A blend's in-betweens are regenerated from its keys.\n\t\tif (child.attrs['data-vector-blend-step'] !== undefined) return out;\n\t\tconst operation = child.attrs['data-vector-boolean-operation'];\n\t\tif (BOOLEAN_OPERATIONS.includes(operation as VectorBooleanOperation)) (meta as { booleanOperation?: VectorBooleanOperation }).booleanOperation = operation as VectorBooleanOperation;\n\t\tif (child.name === 'g' && child.attrs['data-vector-mask'] !== undefined) {\n\t\t\tconst node = maskGroup(child, s, m, meta);\n\t\t\tif (node) out.push(node);\n\t\t\treturn out;\n\t\t}\n\t\tif (child.name === 'g' && child.attrs['data-vector-live'] !== undefined) {\n\t\t\tconst node = liveNode(child, s, m, meta);\n\t\t\tif (node) out.push(node);\n\t\t\treturn out;\n\t\t}\n\t\tif (child.name === 'g' && child.attrs['data-vector-path'] !== undefined && child.attrs['data-vector-fills'] !== undefined) {\n\t\t\tconst node = stackedPath(child, s, m, meta);\n\t\t\tif (node) out.push(node);\n\t\t\treturn out;\n\t\t}\n\t\tif (child.name === 'g' && child.attrs['data-vector-path'] !== undefined) {\n\t\t\tconst node = mergedPath(child, s, m, meta);\n\t\t\tif (node) out.push(node);\n\t\t\treturn out;\n\t\t}\n\t\tif (child.name === 'g' || child.name === 'svg' || child.name === 'a' || child.name === 'switch') {\n\t\t\tconst children = visit(child, s, m);\n\t\t\tif (!children.length) return out;\n\t\t\tconst group: VectorGroupNode = { id: idFor(child), type: 'group', ...meta, children };\n\t\t\tconst blend = child.name === 'g' ? blendFromAttribute(child.attrs['data-vector-blend'], m) : null;\n\t\t\tif (blend) group.blend = blend;\n\t\t\tout.push(group);\n\t\t\treturn out;\n\t\t}\n\t\tconst subpaths = shapeOf(child);\n\t\tif (!subpaths || !subpaths.length) return out;\n\t\tconst node = placed(\n\t\t\twithOpacities(\n\t\t\t\t{\n\t\t\t\t\tid: idFor(child),\n\t\t\t\t\ttype: 'path',\n\t\t\t\t\t...meta,\n\t\t\t\t\tsubpaths,\n\t\t\t\t\tfill: child.name === 'line' ? null : paint(s.fill),\n\t\t\t\t\tstroke: paint(s.stroke),\n\t\t\t\t\t...strokeStyle(s)\n\t\t\t\t},\n\t\t\t\ts\n\t\t\t),\n\t\t\tm\n\t\t);\n\t\tout.push(node);\n\t\treturn out;\n\t};\n\n\trootStyle = readStyle(root, rootStyle);\n\tconst nodes = visit(root, rootStyle, rootMatrix);\n\treturn { width, height, nodes };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAM,QAAQ,CAAC,GAAW,GAAW,MAAc,KAAK,IAAI,KAAK;AACjE,IAAM,QAAQ,CAAC,GAAU,GAAU,MAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;AAC3G,IAAM,MAAM,CAAC,MAAuC,CAAC,EAAE,GAAG,EAAE,CAAC;AAC7D,IAAM,OAAO,CAAC,GAAiB,MAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AAYtH,IAAM,WAAW,CAAC,MAA0B,KAAK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