distark-render 1.2.0 → 1.2.2

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.
Files changed (76) hide show
  1. package/dist/cli/distark-check.d.ts +1 -0
  2. package/dist/cli/distark-check.d.ts.map +1 -1
  3. package/dist/cli/distark-check.js +11 -0
  4. package/dist/cli/distark-check.js.map +1 -1
  5. package/dist/cli/fix.d.ts +8 -0
  6. package/dist/cli/fix.d.ts.map +1 -0
  7. package/dist/cli/fix.js +159 -0
  8. package/dist/cli/fix.js.map +1 -0
  9. package/dist/cli/validate.d.ts +25 -0
  10. package/dist/cli/validate.d.ts.map +1 -0
  11. package/dist/cli/validate.js +244 -0
  12. package/dist/cli/validate.js.map +1 -0
  13. package/dist/modules/adapters/skiaRenderer.d.ts.map +1 -1
  14. package/dist/modules/adapters/skiaRenderer.js +2 -1
  15. package/dist/modules/adapters/skiaRenderer.js.map +1 -1
  16. package/dist/modules/characterValidator.d.ts +82 -1
  17. package/dist/modules/characterValidator.d.ts.map +1 -1
  18. package/dist/modules/characterValidator.js +330 -0
  19. package/dist/modules/characterValidator.js.map +1 -1
  20. package/dist/modules/imageLoad.d.ts +7 -9
  21. package/dist/modules/imageLoad.d.ts.map +1 -1
  22. package/dist/modules/imageLoad.js +38 -68
  23. package/dist/modules/imageLoad.js.map +1 -1
  24. package/dist/modules/rigAssetFix.d.ts +40 -0
  25. package/dist/modules/rigAssetFix.d.ts.map +1 -0
  26. package/dist/modules/rigAssetFix.js +236 -0
  27. package/dist/modules/rigAssetFix.js.map +1 -0
  28. package/dist/modules/svgAssetAnalysis.d.ts +193 -0
  29. package/dist/modules/svgAssetAnalysis.d.ts.map +1 -0
  30. package/dist/modules/svgAssetAnalysis.js +881 -0
  31. package/dist/modules/svgAssetAnalysis.js.map +1 -0
  32. package/dist/modules/svgAssetFix.d.ts +19 -0
  33. package/dist/modules/svgAssetFix.d.ts.map +1 -0
  34. package/dist/modules/svgAssetFix.js +577 -0
  35. package/dist/modules/svgAssetFix.js.map +1 -0
  36. package/dist/modules/svgRaster.d.ts +3 -0
  37. package/dist/modules/svgRaster.d.ts.map +1 -1
  38. package/dist/modules/svgRaster.js +7 -3
  39. package/dist/modules/svgRaster.js.map +1 -1
  40. package/dist/modules/svgViewBox.d.ts +64 -0
  41. package/dist/modules/svgViewBox.d.ts.map +1 -0
  42. package/dist/modules/svgViewBox.js +188 -0
  43. package/dist/modules/svgViewBox.js.map +1 -0
  44. package/dist/tests/test-cli.js +34 -1
  45. package/dist/tests/test-cli.js.map +1 -1
  46. package/dist/tests/test-fix-visual-parity.d.ts +15 -0
  47. package/dist/tests/test-fix-visual-parity.d.ts.map +1 -0
  48. package/dist/tests/test-fix-visual-parity.js +398 -0
  49. package/dist/tests/test-fix-visual-parity.js.map +1 -0
  50. package/dist/tests/test-newtank-viewport-zoom-body-path.js +14 -10
  51. package/dist/tests/test-newtank-viewport-zoom-body-path.js.map +1 -1
  52. package/dist/tests/test-newtank-viewport-zoom-diagnostic.d.ts +1 -1
  53. package/dist/tests/test-newtank-viewport-zoom-diagnostic.js +11 -22
  54. package/dist/tests/test-newtank-viewport-zoom-diagnostic.js.map +1 -1
  55. package/dist/tests/test-newtank-zoom-sizes.js +9 -9
  56. package/dist/tests/test-newtank-zoom-sizes.js.map +1 -1
  57. package/dist/tests/test-rig-standardization.d.ts +5 -0
  58. package/dist/tests/test-rig-standardization.d.ts.map +1 -0
  59. package/dist/tests/test-rig-standardization.js +171 -0
  60. package/dist/tests/test-rig-standardization.js.map +1 -0
  61. package/dist/tests/test-scene-object-svg-rerasterization.js +5 -5
  62. package/dist/tests/test-svg-asset-fix.d.ts +5 -0
  63. package/dist/tests/test-svg-asset-fix.d.ts.map +1 -0
  64. package/dist/tests/test-svg-asset-fix.js +102 -0
  65. package/dist/tests/test-svg-asset-fix.js.map +1 -0
  66. package/dist/tests/test-svg-rerasterization.js +30 -45
  67. package/dist/tests/test-svg-rerasterization.js.map +1 -1
  68. package/dist/tests/test-svg-viewbox.d.ts +2 -0
  69. package/dist/tests/test-svg-viewbox.d.ts.map +1 -0
  70. package/dist/tests/test-svg-viewbox.js +33 -0
  71. package/dist/tests/test-svg-viewbox.js.map +1 -0
  72. package/dist/tests/test-tanknew-svg-edit-data.d.ts +6 -0
  73. package/dist/tests/test-tanknew-svg-edit-data.d.ts.map +1 -0
  74. package/dist/tests/test-tanknew-svg-edit-data.js +63 -0
  75. package/dist/tests/test-tanknew-svg-edit-data.js.map +1 -0
  76. package/package.json +10 -5
@@ -0,0 +1,881 @@
1
+ /**
2
+ * SVG asset analysis for rig standardization checks.
3
+ * Pure functions — no network, no DOM required.
4
+ */
5
+ export const MAX_TOTAL_VERTICES = 400;
6
+ export const VIEWBOX_PADDING_TOLERANCE_RATIO = 0.02;
7
+ export const VIEWBOX_PADDING_TOLERANCE_MIN_PX = 1;
8
+ export const VIEWBOX_OVERFLOW_EPSILON = 0.5;
9
+ /** Content occupying less than this fraction of viewBox width/height is "shared canvas" padding (breaks SVG edit drag preview). */
10
+ export const VIEWBOX_MIN_CONTENT_COVERAGE = 0.5;
11
+ /** Matches cartoon_maker assertSvgDrawRectAlignedWithOverlay default bounds. */
12
+ export const DIMENSION_LAYOUT_RATIO_MIN = 0.8;
13
+ export const DIMENSION_LAYOUT_RATIO_MAX = 1.25;
14
+ const FORBIDDEN_NON_VECTOR_RE = /<(text|use|foreignObject)\b/gi;
15
+ const PATH_TAG_RE = /<path\b([^>]*?)(?:\/>|>[\s\S]*?<\/path>)/gi;
16
+ const IMAGE_TAG_RE = /<image\b([^>]*?)(?:\/>|>[\s\S]*?<\/image>)/gi;
17
+ function sideMetric(value, tolerance) {
18
+ return { value, tolerance, excess: Math.max(0, value - tolerance) };
19
+ }
20
+ function readAttr(tag, name) {
21
+ return tag.match(new RegExp(`\\b${name}=["']([^"']*)["']`, 'i'))?.[1] ?? null;
22
+ }
23
+ function parseNumber(value, fallback = 0) {
24
+ if (!value)
25
+ return fallback;
26
+ const n = Number(value.trim());
27
+ return Number.isFinite(n) ? n : fallback;
28
+ }
29
+ function getRootTag(svgSource) {
30
+ return svgSource.match(/<svg\b[\s\S]*?>/i)?.[0] ?? null;
31
+ }
32
+ function readStyleProperty(style, prop) {
33
+ if (!style)
34
+ return null;
35
+ const match = style.match(new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*([^;]+)`, 'i'));
36
+ return match?.[1]?.trim() ?? null;
37
+ }
38
+ function detectHiddenReason(tag) {
39
+ const display = (readAttr(tag, 'display') || readStyleProperty(readAttr(tag, 'style'), 'display') || '').toLowerCase();
40
+ if (display === 'none')
41
+ return 'display_none';
42
+ const visibility = (readAttr(tag, 'visibility') || readStyleProperty(readAttr(tag, 'style'), 'visibility') || '').toLowerCase();
43
+ if (visibility === 'hidden' || visibility === 'collapse')
44
+ return 'visibility_hidden';
45
+ const opacityRaw = readAttr(tag, 'opacity') || readStyleProperty(readAttr(tag, 'style'), 'opacity');
46
+ if (opacityRaw !== null && parseNumber(opacityRaw, 1) <= 0.001)
47
+ return 'opacity_zero';
48
+ return null;
49
+ }
50
+ function normalizePathD(d) {
51
+ return d.replace(/\s+/g, ' ').trim().toLowerCase();
52
+ }
53
+ function isTransparentColor(value) {
54
+ if (!value)
55
+ return true;
56
+ const v = value.trim().toLowerCase();
57
+ return v === 'none' || v === 'transparent';
58
+ }
59
+ function hasVisibleFill(path) {
60
+ if (isTransparentColor(path.fill))
61
+ return false;
62
+ return path.fillOpacity > 0.001;
63
+ }
64
+ function hasVisibleStroke(path) {
65
+ if (isTransparentColor(path.stroke))
66
+ return false;
67
+ if (path.strokeWidth <= 0.001)
68
+ return false;
69
+ return path.strokeOpacity > 0.001;
70
+ }
71
+ export function parseLengthUnit(value) {
72
+ if (!value)
73
+ return 'missing';
74
+ const match = value.trim().match(/^([+-]?(?:\d*\.\d+|\d+))([a-z%]*)$/i);
75
+ if (!match)
76
+ return 'unknown';
77
+ const unit = (match[2] || 'px').toLowerCase();
78
+ if (unit === '' || unit === 'px')
79
+ return 'px';
80
+ if (unit === 'mm' || unit === 'cm' || unit === 'in' || unit === 'pt' || unit === 'pc')
81
+ return unit;
82
+ if (unit === '%')
83
+ return '%';
84
+ return 'unknown';
85
+ }
86
+ export function parseSvgRootUnits(svgSource) {
87
+ const rootTag = getRootTag(svgSource) || '';
88
+ const widthRaw = readAttr(rootTag, 'width');
89
+ const heightRaw = readAttr(rootTag, 'height');
90
+ const widthUnit = parseLengthUnit(widthRaw);
91
+ const heightUnit = parseLengthUnit(heightRaw);
92
+ const pixelUnitsOnly = (widthUnit === 'px' || widthUnit === 'missing')
93
+ && (heightUnit === 'px' || heightUnit === 'missing');
94
+ return { widthRaw, heightRaw, widthUnit, heightUnit, pixelUnitsOnly };
95
+ }
96
+ export function checkPreserveAspectRatioNone(svgSource) {
97
+ const rootTag = getRootTag(svgSource);
98
+ if (!rootTag)
99
+ return false;
100
+ return /preserveAspectRatio\s*=\s*["']none["']/i.test(rootTag);
101
+ }
102
+ /** Parse translation from an SVG transform attribute.
103
+ * Handles both `translate(tx[, ty])` and `matrix(a, b, c, d, tx, ty)` formats.
104
+ * For matrix transforms, extracts the translation components (e and f).
105
+ */
106
+ export function parsePathTranslateTransform(transform) {
107
+ if (!transform)
108
+ return null;
109
+ const translateMatch = transform.match(/translate\s*\(\s*(-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?)(?:[\s,]+(-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?))?\s*\)/i);
110
+ if (translateMatch) {
111
+ const tx = Number(translateMatch[1]);
112
+ const ty = translateMatch[2] !== undefined ? Number(translateMatch[2]) : 0;
113
+ if (!Number.isFinite(tx) || !Number.isFinite(ty))
114
+ return null;
115
+ return { tx, ty };
116
+ }
117
+ const NUM = '(-?(?:\\d*\\.\\d+|\\d+)(?:e[-+]?\\d+)?)';
118
+ const SEP = '[\\s,]+';
119
+ const matrixRe = new RegExp(`matrix\\s*\\(\\s*${NUM}${SEP}${NUM}${SEP}${NUM}${SEP}${NUM}${SEP}${NUM}${SEP}${NUM}\\s*\\)`, 'i');
120
+ const matrixMatch = transform.match(matrixRe);
121
+ if (matrixMatch) {
122
+ const [, aStr, bStr, cStr, dStr, eStr, fStr] = matrixMatch;
123
+ const a = Number(aStr);
124
+ const b = Number(bStr);
125
+ const c = Number(cStr);
126
+ const d = Number(dStr);
127
+ const e = Number(eStr);
128
+ const f = Number(fStr);
129
+ if ([a, b, c, d, e, f].some(v => !Number.isFinite(v)))
130
+ return null;
131
+ const isPureTranslation = Math.abs(a - 1) < 1e-6
132
+ && Math.abs(b) < 1e-6
133
+ && Math.abs(c) < 1e-6
134
+ && Math.abs(d - 1) < 1e-6;
135
+ if (!isPureTranslation)
136
+ return null;
137
+ return { tx: e, ty: f };
138
+ }
139
+ return null;
140
+ }
141
+ function offsetBounds(bounds, tx, ty) {
142
+ return {
143
+ minX: bounds.minX + tx,
144
+ minY: bounds.minY + ty,
145
+ maxX: bounds.maxX + tx,
146
+ maxY: bounds.maxY + ty,
147
+ };
148
+ }
149
+ export function parseViewBox(svgSource) {
150
+ const rootTag = getRootTag(svgSource);
151
+ if (!rootTag)
152
+ return null;
153
+ const viewBoxRaw = readAttr(rootTag, 'viewBox');
154
+ if (viewBoxRaw) {
155
+ const parts = viewBoxRaw.trim().split(/[\s,]+/).map(Number);
156
+ if (parts.length === 4 && parts.every(Number.isFinite) && parts[2] > 0 && parts[3] > 0) {
157
+ return { minX: parts[0], minY: parts[1], width: parts[2], height: parts[3] };
158
+ }
159
+ }
160
+ const width = parseNumber(readAttr(rootTag, 'width'), 0);
161
+ const height = parseNumber(readAttr(rootTag, 'height'), 0);
162
+ if (width > 0 && height > 0) {
163
+ return { minX: 0, minY: 0, width, height };
164
+ }
165
+ return null;
166
+ }
167
+ export function extractSvgPaths(svgSource) {
168
+ // Pre-scan: collect <g> open/close events to track ancestor translate transforms.
169
+ const G_OPEN_RE = /<g\b([^>]*)>/gi;
170
+ const G_CLOSE_RE = /<\/g\s*>/gi;
171
+ const gEvents = [];
172
+ for (const m of svgSource.matchAll(G_OPEN_RE)) {
173
+ const transform = readAttr(m[0], 'transform');
174
+ const t = parsePathTranslateTransform(transform);
175
+ gEvents.push({ pos: m.index, type: 'open', tx: t?.tx ?? 0, ty: t?.ty ?? 0 });
176
+ }
177
+ for (const m of svgSource.matchAll(G_CLOSE_RE)) {
178
+ gEvents.push({ pos: m.index, type: 'close', tx: 0, ty: 0 });
179
+ }
180
+ gEvents.sort((a, b) => a.pos - b.pos);
181
+ const paths = [];
182
+ let index = 0;
183
+ let gEventIdx = 0;
184
+ const gStack = [];
185
+ let accTx = 0;
186
+ let accTy = 0;
187
+ for (const match of svgSource.matchAll(PATH_TAG_RE)) {
188
+ // Advance <g> event stack up to this path's position.
189
+ while (gEventIdx < gEvents.length && gEvents[gEventIdx].pos < match.index) {
190
+ const ev = gEvents[gEventIdx];
191
+ if (ev.type === 'open') {
192
+ gStack.push({ tx: ev.tx, ty: ev.ty });
193
+ accTx += ev.tx;
194
+ accTy += ev.ty;
195
+ }
196
+ else if (gStack.length > 0) {
197
+ const popped = gStack.pop();
198
+ accTx -= popped.tx;
199
+ accTy -= popped.ty;
200
+ }
201
+ gEventIdx++;
202
+ }
203
+ index += 1;
204
+ const tag = match[0];
205
+ const attrs = match[1] || tag;
206
+ const d = readAttr(attrs, 'd') ?? readAttr(tag, 'd');
207
+ if (!d || !d.trim())
208
+ continue;
209
+ const hiddenReason = detectHiddenReason(tag) ?? undefined;
210
+ const transformRaw = readAttr(attrs, 'transform') ?? readAttr(tag, 'transform');
211
+ const pathTranslate = parsePathTranslateTransform(transformRaw);
212
+ const totalTx = (pathTranslate?.tx ?? 0) + accTx;
213
+ const totalTy = (pathTranslate?.ty ?? 0) + accTy;
214
+ paths.push({
215
+ index,
216
+ d,
217
+ fill: readAttr(attrs, 'fill') ?? readAttr(tag, 'fill'),
218
+ stroke: readAttr(attrs, 'stroke') ?? readAttr(tag, 'stroke'),
219
+ fillOpacity: parseNumber(readAttr(attrs, 'fill-opacity') ?? readAttr(tag, 'fill-opacity'), 1),
220
+ strokeOpacity: parseNumber(readAttr(attrs, 'stroke-opacity') ?? readAttr(tag, 'stroke-opacity'), 1),
221
+ strokeWidth: parseNumber(readAttr(attrs, 'stroke-width') ?? readAttr(tag, 'stroke-width'), 1),
222
+ visible: hiddenReason === undefined,
223
+ hiddenReason,
224
+ translateX: totalTx || undefined,
225
+ translateY: totalTy || undefined,
226
+ });
227
+ }
228
+ return paths;
229
+ }
230
+ export function extractEmbeddedImages(svgSource) {
231
+ const images = [];
232
+ let index = 0;
233
+ for (const match of svgSource.matchAll(IMAGE_TAG_RE)) {
234
+ index += 1;
235
+ const tag = match[0];
236
+ const attrs = match[1] || tag;
237
+ const href = readAttr(attrs, 'href') ?? readAttr(attrs, 'xlink:href') ?? readAttr(tag, 'href') ?? readAttr(tag, 'xlink:href');
238
+ const hiddenReason = detectHiddenReason(tag) ?? undefined;
239
+ let hrefKind = 'missing';
240
+ if (href) {
241
+ if (/^data:image\//i.test(href) || /^data:.*;base64,/i.test(href)) {
242
+ hrefKind = 'embedded_raster';
243
+ }
244
+ else {
245
+ hrefKind = 'external';
246
+ }
247
+ }
248
+ images.push({
249
+ index,
250
+ hidden: hiddenReason !== undefined,
251
+ hiddenReason,
252
+ hrefKind,
253
+ width: readAttr(attrs, 'width') ?? readAttr(tag, 'width'),
254
+ height: readAttr(attrs, 'height') ?? readAttr(tag, 'height'),
255
+ });
256
+ }
257
+ return images;
258
+ }
259
+ export function countForbiddenNonVectorElements(svgSource) {
260
+ return [...svgSource.matchAll(FORBIDDEN_NON_VECTOR_RE)].length;
261
+ }
262
+ export function getVisiblePaths(paths) {
263
+ return paths.filter(p => p.visible);
264
+ }
265
+ /** Count authoring vertices in an SVG path `d` attribute. */
266
+ export function countPathVertices(d) {
267
+ let vertices = 0;
268
+ const re = /([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g;
269
+ let match;
270
+ while ((match = re.exec(d)) !== null) {
271
+ const cmd = match[1];
272
+ const args = (match[2].match(/-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?/gi) || []).map(Number);
273
+ const upper = cmd.toUpperCase();
274
+ switch (upper) {
275
+ case 'M':
276
+ vertices += Math.max(1, Math.floor(args.length / 2));
277
+ break;
278
+ case 'L':
279
+ vertices += Math.floor(args.length / 2);
280
+ break;
281
+ case 'H':
282
+ case 'V':
283
+ vertices += args.length;
284
+ break;
285
+ case 'C':
286
+ vertices += Math.floor(args.length / 6) * 3;
287
+ break;
288
+ case 'S':
289
+ case 'Q':
290
+ vertices += Math.floor(args.length / 4) * 2;
291
+ break;
292
+ case 'T':
293
+ vertices += Math.floor(args.length / 2);
294
+ break;
295
+ case 'A':
296
+ vertices += Math.floor(args.length / 7);
297
+ break;
298
+ default:
299
+ break;
300
+ }
301
+ }
302
+ return vertices;
303
+ }
304
+ export function getPathStartPoint(d) {
305
+ const match = d.match(/^[Mm]\s*(-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?)[,\s]+(-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?)/);
306
+ if (!match)
307
+ return null;
308
+ return { x: Number(match[1]), y: Number(match[2]) };
309
+ }
310
+ function mergeBounds(a, b) {
311
+ if (!a)
312
+ return b;
313
+ return {
314
+ minX: Math.min(a.minX, b.minX),
315
+ minY: Math.min(a.minY, b.minY),
316
+ maxX: Math.max(a.maxX, b.maxX),
317
+ maxY: Math.max(a.maxY, b.maxY),
318
+ };
319
+ }
320
+ function updateBoundsFromPoint(bounds, x, y) {
321
+ return bounds
322
+ ? { ...bounds, minX: Math.min(bounds.minX, x), minY: Math.min(bounds.minY, y), maxX: Math.max(bounds.maxX, x), maxY: Math.max(bounds.maxY, y) }
323
+ : { minX: x, minY: y, maxX: x, maxY: y };
324
+ }
325
+ /** Conservative axis-aligned bounds for a single path (includes curve control points). */
326
+ export function getPathBounds(d) {
327
+ let bounds = null;
328
+ let cx = 0;
329
+ let cy = 0;
330
+ let sx = 0;
331
+ let sy = 0;
332
+ const re = /([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g;
333
+ let match;
334
+ while ((match = re.exec(d)) !== null) {
335
+ const cmd = match[1];
336
+ const rel = cmd === cmd.toLowerCase();
337
+ const upper = cmd.toUpperCase();
338
+ const args = (match[2].match(/-?(?:\d*\.\d+|\d+)(?:e[-+]?\d+)?/gi) || []).map(Number);
339
+ const abs = (v, base) => rel ? base + v : v;
340
+ switch (upper) {
341
+ case 'M':
342
+ for (let i = 0; i + 1 < args.length; i += 2) {
343
+ cx = abs(args[i], cx);
344
+ cy = abs(args[i + 1], cy);
345
+ bounds = updateBoundsFromPoint(bounds, cx, cy);
346
+ if (i === 0) {
347
+ sx = cx;
348
+ sy = cy;
349
+ }
350
+ }
351
+ break;
352
+ case 'L':
353
+ for (let i = 0; i + 1 < args.length; i += 2) {
354
+ cx = abs(args[i], cx);
355
+ cy = abs(args[i + 1], cy);
356
+ bounds = updateBoundsFromPoint(bounds, cx, cy);
357
+ }
358
+ break;
359
+ case 'H':
360
+ for (const x of args) {
361
+ cx = abs(x, cx);
362
+ bounds = updateBoundsFromPoint(bounds, cx, cy);
363
+ }
364
+ break;
365
+ case 'V':
366
+ for (const y of args) {
367
+ cy = abs(y, cy);
368
+ bounds = updateBoundsFromPoint(bounds, cx, cy);
369
+ }
370
+ break;
371
+ case 'C':
372
+ for (let i = 0; i + 5 < args.length; i += 6) {
373
+ const cp1x = abs(args[i], cx), cp1y = abs(args[i + 1], cy);
374
+ const cp2x = abs(args[i + 2], cx), cp2y = abs(args[i + 3], cy);
375
+ const epx = abs(args[i + 4], cx), epy = abs(args[i + 5], cy);
376
+ bounds = updateBoundsFromPoint(bounds, cp1x, cp1y);
377
+ bounds = updateBoundsFromPoint(bounds, cp2x, cp2y);
378
+ bounds = updateBoundsFromPoint(bounds, epx, epy);
379
+ cx = epx;
380
+ cy = epy;
381
+ }
382
+ break;
383
+ case 'S':
384
+ case 'Q':
385
+ for (let i = 0; i + 3 < args.length; i += 4) {
386
+ const cpx = abs(args[i], cx), cpy = abs(args[i + 1], cy);
387
+ const epx = abs(args[i + 2], cx), epy = abs(args[i + 3], cy);
388
+ bounds = updateBoundsFromPoint(bounds, cpx, cpy);
389
+ bounds = updateBoundsFromPoint(bounds, epx, epy);
390
+ cx = epx;
391
+ cy = epy;
392
+ }
393
+ break;
394
+ case 'T':
395
+ for (let i = 0; i + 1 < args.length; i += 2) {
396
+ cx = abs(args[i], cx);
397
+ cy = abs(args[i + 1], cy);
398
+ bounds = updateBoundsFromPoint(bounds, cx, cy);
399
+ }
400
+ break;
401
+ case 'A':
402
+ for (let i = 0; i + 6 < args.length; i += 7) {
403
+ const rx = args[i];
404
+ const ry = args[i + 1];
405
+ const epx = abs(args[i + 5], cx);
406
+ const epy = abs(args[i + 6], cy);
407
+ bounds = updateBoundsFromPoint(bounds, epx - rx, epy - ry);
408
+ bounds = updateBoundsFromPoint(bounds, epx + rx, epy + ry);
409
+ cx = epx;
410
+ cy = epy;
411
+ }
412
+ break;
413
+ case 'Z':
414
+ cx = sx;
415
+ cy = sy;
416
+ break;
417
+ default:
418
+ break;
419
+ }
420
+ }
421
+ return bounds;
422
+ }
423
+ export function getPathBoundsWithTransform(path) {
424
+ const pb = getPathBounds(path.d);
425
+ if (!pb)
426
+ return null;
427
+ const tx = path.translateX ?? 0;
428
+ const ty = path.translateY ?? 0;
429
+ return tx === 0 && ty === 0 ? pb : offsetBounds(pb, tx, ty);
430
+ }
431
+ export function getContentBounds(paths) {
432
+ let bounds = null;
433
+ for (const path of paths) {
434
+ const pb = getPathBoundsWithTransform(path);
435
+ if (pb)
436
+ bounds = mergeBounds(bounds, pb);
437
+ }
438
+ return bounds;
439
+ }
440
+ function pathStrokeExtent(path) {
441
+ if (!hasVisibleStroke(path))
442
+ return 0;
443
+ return path.strokeWidth / 2;
444
+ }
445
+ /** Visible ink bounds: path geometry plus half stroke-width on stroked paths. */
446
+ export function getVisibleContentBounds(paths) {
447
+ let bounds = null;
448
+ for (const path of paths) {
449
+ let pb = getPathBoundsWithTransform(path);
450
+ if (!pb)
451
+ continue;
452
+ const ext = pathStrokeExtent(path);
453
+ if (ext > 0) {
454
+ pb = {
455
+ minX: pb.minX - ext,
456
+ minY: pb.minY - ext,
457
+ maxX: pb.maxX + ext,
458
+ maxY: pb.maxY + ext,
459
+ };
460
+ }
461
+ bounds = mergeBounds(bounds, pb);
462
+ }
463
+ return bounds;
464
+ }
465
+ /** True when axis-aligned bounds lie fully inside the viewBox (within overflow epsilon). */
466
+ export function contentFitsWithinViewBox(viewBox, bounds) {
467
+ const overflow = {
468
+ left: Math.max(0, viewBox.minX - bounds.minX),
469
+ right: Math.max(0, bounds.maxX - (viewBox.minX + viewBox.width)),
470
+ top: Math.max(0, viewBox.minY - bounds.minY),
471
+ bottom: Math.max(0, bounds.maxY - (viewBox.minY + viewBox.height)),
472
+ };
473
+ return overflow.left <= VIEWBOX_OVERFLOW_EPSILON
474
+ && overflow.right <= VIEWBOX_OVERFLOW_EPSILON
475
+ && overflow.top <= VIEWBOX_OVERFLOW_EPSILON
476
+ && overflow.bottom <= VIEWBOX_OVERFLOW_EPSILON;
477
+ }
478
+ export function getViewBoxContentCoverage(viewBox, bounds) {
479
+ const contentW = bounds.maxX - bounds.minX;
480
+ const contentH = bounds.maxY - bounds.minY;
481
+ return {
482
+ widthRatio: viewBox.width > 0 ? contentW / viewBox.width : 0,
483
+ heightRatio: viewBox.height > 0 ? contentH / viewBox.height : 0,
484
+ };
485
+ }
486
+ export function detectSplitFillStrokePaths(paths) {
487
+ const groups = new Map();
488
+ for (const path of paths) {
489
+ const key = normalizePathD(path.d);
490
+ const list = groups.get(key) || [];
491
+ list.push(path);
492
+ groups.set(key, list);
493
+ }
494
+ for (const group of groups.values()) {
495
+ if (group.length < 2)
496
+ continue;
497
+ const fillOnly = group.some(p => hasVisibleFill(p) && !hasVisibleStroke(p));
498
+ const strokeOnly = group.some(p => hasVisibleStroke(p) && !hasVisibleFill(p));
499
+ if (fillOnly && strokeOnly)
500
+ return true;
501
+ }
502
+ return false;
503
+ }
504
+ export function checkViewBoxFitsVisibleContent(svgSource, visiblePaths) {
505
+ const viewBox = parseViewBox(svgSource);
506
+ const visibleBounds = getVisibleContentBounds(visiblePaths);
507
+ if (!viewBox) {
508
+ return { pass: false, failureKind: 'missing_viewbox', reason: 'missing or invalid viewBox' };
509
+ }
510
+ if (!visibleBounds) {
511
+ return { pass: true, viewBox };
512
+ }
513
+ const overflow = {
514
+ left: Math.max(0, viewBox.minX - visibleBounds.minX),
515
+ right: Math.max(0, visibleBounds.maxX - (viewBox.minX + viewBox.width)),
516
+ top: Math.max(0, viewBox.minY - visibleBounds.minY),
517
+ bottom: Math.max(0, visibleBounds.maxY - (viewBox.minY + viewBox.height)),
518
+ };
519
+ const visiblePathStart = visiblePaths.length > 0 ? getPathStartPoint(visiblePaths[0].d) ?? undefined : undefined;
520
+ const contentW = visibleBounds.maxX - visibleBounds.minX;
521
+ const contentH = visibleBounds.maxY - visibleBounds.minY;
522
+ const contentCoverage = {
523
+ widthRatio: viewBox.width > 0 ? contentW / viewBox.width : 0,
524
+ heightRatio: viewBox.height > 0 ? contentH / viewBox.height : 0,
525
+ };
526
+ const hasOverflow = overflow.left > VIEWBOX_OVERFLOW_EPSILON
527
+ || overflow.right > VIEWBOX_OVERFLOW_EPSILON
528
+ || overflow.top > VIEWBOX_OVERFLOW_EPSILON
529
+ || overflow.bottom > VIEWBOX_OVERFLOW_EPSILON;
530
+ if (hasOverflow) {
531
+ const vb = viewBox;
532
+ return {
533
+ pass: false,
534
+ failureKind: 'content_outside_viewbox',
535
+ viewBox,
536
+ visibleBounds,
537
+ overflow,
538
+ visiblePathStart,
539
+ contentCoverage,
540
+ reason: `visible content outside viewBox (overflow L${overflow.left.toFixed(1)} R${overflow.right.toFixed(1)} T${overflow.top.toFixed(1)} B${overflow.bottom.toFixed(1)}; visible y ${visibleBounds.minY.toFixed(1)}–${visibleBounds.maxY.toFixed(1)} vs viewBox height ${vb.height.toFixed(1)})`,
541
+ };
542
+ }
543
+ return { pass: true, viewBox, visibleBounds, overflow, visiblePathStart, contentCoverage };
544
+ }
545
+ export function checkCenteredTightViewBox(svgSource, paths) {
546
+ const viewBox = parseViewBox(svgSource);
547
+ const content = getVisibleContentBounds(paths);
548
+ if (!viewBox) {
549
+ return { pass: false, failureKind: 'missing_viewbox', reason: 'missing or invalid viewBox' };
550
+ }
551
+ if (!content) {
552
+ return { pass: true, viewBox };
553
+ }
554
+ const padTolX = Math.max(VIEWBOX_PADDING_TOLERANCE_MIN_PX, viewBox.width * VIEWBOX_PADDING_TOLERANCE_RATIO);
555
+ const padTolY = Math.max(VIEWBOX_PADDING_TOLERANCE_MIN_PX, viewBox.height * VIEWBOX_PADDING_TOLERANCE_RATIO);
556
+ const padLeft = content.minX - viewBox.minX;
557
+ const padRight = (viewBox.minX + viewBox.width) - content.maxX;
558
+ const padTop = content.minY - viewBox.minY;
559
+ const padBottom = (viewBox.minY + viewBox.height) - content.maxY;
560
+ const padding = {
561
+ left: sideMetric(padLeft, padTolX),
562
+ right: sideMetric(padRight, padTolX),
563
+ top: sideMetric(padTop, padTolY),
564
+ bottom: sideMetric(padBottom, padTolY),
565
+ };
566
+ const viewCx = viewBox.minX + viewBox.width / 2;
567
+ const viewCy = viewBox.minY + viewBox.height / 2;
568
+ const contentCx = (content.minX + content.maxX) / 2;
569
+ const contentCy = (content.minY + content.maxY) / 2;
570
+ const dx = Math.abs(contentCx - viewCx);
571
+ const dy = Math.abs(contentCy - viewCy);
572
+ const centerOffset = {
573
+ dx, dy,
574
+ toleranceX: padTolX,
575
+ toleranceY: padTolY,
576
+ excessDx: Math.max(0, dx - padTolX),
577
+ excessDy: Math.max(0, dy - padTolY),
578
+ };
579
+ if (padding.left.excess > 0 || padding.right.excess > 0 || padding.top.excess > 0 || padding.bottom.excess > 0) {
580
+ const coverage = getViewBoxContentCoverage(viewBox, content);
581
+ const lowCoverage = Math.max(coverage.widthRatio, coverage.heightRatio) < VIEWBOX_MIN_CONTENT_COVERAGE;
582
+ const svgEditNote = lowCoverage
583
+ ? '; shared document canvas padding breaks SVG edit drag preview — trim viewBox to visible content'
584
+ : '';
585
+ return {
586
+ pass: false,
587
+ failureKind: 'excess_padding',
588
+ viewBox, contentBounds: content, padding, centerOffset,
589
+ reason: `excess viewBox padding (L${padLeft.toFixed(1)} R${padRight.toFixed(1)} T${padTop.toFixed(1)} B${padBottom.toFixed(1)}, tol ${padTolX.toFixed(1)}/${padTolY.toFixed(1)}; content spans ${(coverage.widthRatio * 100).toFixed(0)}%×${(coverage.heightRatio * 100).toFixed(0)}% of viewBox${svgEditNote})`,
590
+ };
591
+ }
592
+ if (centerOffset.excessDx > 0 || centerOffset.excessDy > 0) {
593
+ return {
594
+ pass: false,
595
+ failureKind: 'off_center',
596
+ viewBox, contentBounds: content, padding, centerOffset,
597
+ reason: `content off-center (Δx=${dx.toFixed(1)}, Δy=${dy.toFixed(1)}, tol ${padTolX.toFixed(1)}/${padTolY.toFixed(1)})`,
598
+ };
599
+ }
600
+ return { pass: true, viewBox, contentBounds: content, padding, centerOffset };
601
+ }
602
+ function parseLengthNumber(value) {
603
+ if (!value)
604
+ return null;
605
+ const match = value.trim().match(/^([+-]?(?:\d*\.\d+|\d+))/);
606
+ if (!match)
607
+ return null;
608
+ const n = Number(match[1]);
609
+ return Number.isFinite(n) ? n : null;
610
+ }
611
+ function parseRootNumericPx(svgSource) {
612
+ const root = getRootTag(svgSource);
613
+ if (!root)
614
+ return { width: null, height: null };
615
+ const widthRaw = readAttr(root, 'width');
616
+ const heightRaw = readAttr(root, 'height');
617
+ const widthUnit = parseLengthUnit(widthRaw);
618
+ const heightUnit = parseLengthUnit(heightRaw);
619
+ const width = widthRaw && widthUnit === 'px' ? parseLengthNumber(widthRaw) : null;
620
+ const height = heightRaw && heightUnit === 'px' ? parseLengthNumber(heightRaw) : null;
621
+ return { width, height };
622
+ }
623
+ /**
624
+ * Compare rig dimensionValues to SVG viewBox/root — catches drawRect vs overlay drift in SVG edit.
625
+ */
626
+ export function checkDimensionLayoutParity(layoutWidth, layoutHeight, svgSource) {
627
+ const viewBox = parseViewBox(svgSource);
628
+ if (!viewBox || viewBox.width <= 0 || viewBox.height <= 0) {
629
+ return { pass: false, reason: 'missing or invalid viewBox for layout parity check' };
630
+ }
631
+ const root = parseRootNumericPx(svgSource);
632
+ const widthRatio = layoutWidth / viewBox.width;
633
+ const heightRatio = layoutHeight / viewBox.height;
634
+ const rootWidthMismatch = root.width !== null && Math.abs(root.width - viewBox.width) > 0.5;
635
+ const rootHeightMismatch = root.height !== null && Math.abs(root.height - viewBox.height) > 0.5;
636
+ if (rootWidthMismatch || rootHeightMismatch) {
637
+ const parts = [];
638
+ if (rootWidthMismatch) {
639
+ parts.push(`root width ${root.width}px vs viewBox width ${viewBox.width.toFixed(1)}`);
640
+ }
641
+ if (rootHeightMismatch) {
642
+ parts.push(`root height ${root.height}px vs viewBox height ${viewBox.height.toFixed(1)}`);
643
+ }
644
+ return {
645
+ pass: false,
646
+ layoutWidth,
647
+ layoutHeight,
648
+ viewBoxWidth: viewBox.width,
649
+ viewBoxHeight: viewBox.height,
650
+ rootWidth: root.width,
651
+ rootHeight: root.height,
652
+ widthRatio,
653
+ heightRatio,
654
+ rootWidthMismatch,
655
+ rootHeightMismatch,
656
+ reason: `root dimensions mismatch viewBox (${parts.join('; ')})`,
657
+ };
658
+ }
659
+ return {
660
+ pass: true,
661
+ layoutWidth,
662
+ layoutHeight,
663
+ viewBoxWidth: viewBox.width,
664
+ viewBoxHeight: viewBox.height,
665
+ rootWidth: root.width,
666
+ rootHeight: root.height,
667
+ widthRatio,
668
+ heightRatio,
669
+ rootWidthMismatch: false,
670
+ rootHeightMismatch: false,
671
+ };
672
+ }
673
+ export function formatDimensionLayoutParityFailure(result) {
674
+ if (result.pass)
675
+ return 'pass';
676
+ return result.reason || 'dimension layout parity check failed';
677
+ }
678
+ export function dimensionLayoutParitySeverity(result) {
679
+ if (result.pass)
680
+ return 0;
681
+ const wr = result.widthRatio ?? 1;
682
+ const hr = result.heightRatio ?? 1;
683
+ const widthDev = wr < DIMENSION_LAYOUT_RATIO_MIN
684
+ ? DIMENSION_LAYOUT_RATIO_MIN - wr
685
+ : wr > DIMENSION_LAYOUT_RATIO_MAX ? wr - DIMENSION_LAYOUT_RATIO_MAX : 0;
686
+ const heightDev = hr < DIMENSION_LAYOUT_RATIO_MIN
687
+ ? DIMENSION_LAYOUT_RATIO_MIN - hr
688
+ : hr > DIMENSION_LAYOUT_RATIO_MAX ? hr - DIMENSION_LAYOUT_RATIO_MAX : 0;
689
+ return Math.max(widthDev, heightDev, result.rootWidthMismatch ? 1 : 0, result.rootHeightMismatch ? 1 : 0);
690
+ }
691
+ export function formatViewBoxFitFailure(metrics) {
692
+ if (metrics.pass)
693
+ return 'pass';
694
+ if (metrics.failureKind === 'missing_viewbox')
695
+ return 'missing or invalid viewBox';
696
+ if (metrics.failureKind === 'no_visible_geometry')
697
+ return 'no measurable visible path geometry';
698
+ if (metrics.failureKind === 'content_outside_viewbox' && metrics.overflow && metrics.visibleBounds && metrics.viewBox) {
699
+ const o = metrics.overflow;
700
+ const vb = metrics.viewBox;
701
+ const b = metrics.visibleBounds;
702
+ const parts = [];
703
+ if (o.left > VIEWBOX_OVERFLOW_EPSILON)
704
+ parts.push(`overflow left +${o.left.toFixed(1)}`);
705
+ if (o.right > VIEWBOX_OVERFLOW_EPSILON)
706
+ parts.push(`overflow right +${o.right.toFixed(1)}`);
707
+ if (o.top > VIEWBOX_OVERFLOW_EPSILON)
708
+ parts.push(`overflow top +${o.top.toFixed(1)}`);
709
+ if (o.bottom > VIEWBOX_OVERFLOW_EPSILON)
710
+ parts.push(`overflow bottom +${o.bottom.toFixed(1)}`);
711
+ const start = metrics.visiblePathStart;
712
+ const startNote = start ? `; visible path starts at (${start.x.toFixed(1)}, ${start.y.toFixed(1)})` : '';
713
+ const coverage = metrics.contentCoverage;
714
+ const coverageNote = coverage
715
+ ? `; content spans ${(coverage.heightRatio * 100).toFixed(0)}% of viewBox height (y ${b.minY.toFixed(1)}–${b.maxY.toFixed(1)} vs viewBox h ${vb.height.toFixed(1)})`
716
+ : '';
717
+ return `content outside viewBox — ${parts.join(', ')}${startNote}${coverageNote}`;
718
+ }
719
+ return metrics.reason || 'viewBox fit check failed';
720
+ }
721
+ export function formatViewBoxFailure(metrics) {
722
+ if (metrics.pass)
723
+ return 'pass';
724
+ if (metrics.failureKind === 'missing_viewbox')
725
+ return 'missing or invalid viewBox';
726
+ if (metrics.failureKind === 'no_geometry')
727
+ return 'no measurable path geometry';
728
+ if (metrics.failureKind === 'excess_padding' && metrics.padding) {
729
+ const sides = [
730
+ ['L', metrics.padding.left], ['R', metrics.padding.right],
731
+ ['T', metrics.padding.top], ['B', metrics.padding.bottom],
732
+ ];
733
+ const bad = sides
734
+ .filter(([, m]) => m.excess > 0)
735
+ .map(([label, m]) => `${label} ${m.value.toFixed(1)}px (tol ${m.tolerance.toFixed(1)}, +${m.excess.toFixed(1)})`);
736
+ return bad.length > 0 ? `excess padding — ${bad.join(', ')}` : (metrics.reason || 'excess viewBox padding');
737
+ }
738
+ if (metrics.failureKind === 'off_center' && metrics.centerOffset) {
739
+ const c = metrics.centerOffset;
740
+ return `off-center — Δx=${c.dx.toFixed(1)} (tol ${c.toleranceX.toFixed(1)}, +${c.excessDx.toFixed(1)}), Δy=${c.dy.toFixed(1)} (tol ${c.toleranceY.toFixed(1)}, +${c.excessDy.toFixed(1)})`;
741
+ }
742
+ return metrics.reason || 'viewBox check failed';
743
+ }
744
+ export function viewBoxFitFailureSeverity(metrics) {
745
+ if (metrics.pass)
746
+ return 0;
747
+ if (!metrics.overflow)
748
+ return Number.POSITIVE_INFINITY;
749
+ return Math.max(metrics.overflow.left, metrics.overflow.right, metrics.overflow.top, metrics.overflow.bottom);
750
+ }
751
+ export function viewBoxFailureSeverity(metrics) {
752
+ if (metrics.pass)
753
+ return 0;
754
+ let worst = 0;
755
+ if (metrics.padding) {
756
+ for (const side of [metrics.padding.left, metrics.padding.right, metrics.padding.top, metrics.padding.bottom]) {
757
+ worst = Math.max(worst, side.excess);
758
+ }
759
+ }
760
+ if (metrics.centerOffset) {
761
+ worst = Math.max(worst, metrics.centerOffset.excessDx, metrics.centerOffset.excessDy);
762
+ }
763
+ if (metrics.failureKind === 'missing_viewbox' || metrics.failureKind === 'no_geometry') {
764
+ return Number.POSITIVE_INFINITY;
765
+ }
766
+ return worst;
767
+ }
768
+ export function classifyAssetRef(ref) {
769
+ if (!ref || ref.includes('[MEDIA_REMOVED]'))
770
+ return 'missing';
771
+ if (ref.trim().startsWith('<svg'))
772
+ return 'svg';
773
+ if (ref.startsWith('data:image/svg+xml'))
774
+ return 'svg';
775
+ if (/^data:image\/(png|jpe?g|gif|webp)/i.test(ref))
776
+ return 'raster';
777
+ if (ref.startsWith('http://') || ref.startsWith('https://'))
778
+ return 'url';
779
+ if (/^[a-f0-9]{32}$/i.test(ref))
780
+ return 'url';
781
+ return 'missing';
782
+ }
783
+ function buildHiddenPathDetails(paths) {
784
+ return paths
785
+ .filter(p => !p.visible && p.hiddenReason)
786
+ .map(p => ({
787
+ index: p.index,
788
+ fill: p.fill,
789
+ reason: p.hiddenReason,
790
+ bounds: getPathBounds(p.d),
791
+ }));
792
+ }
793
+ export function analyzeSvgAsset(svgSource) {
794
+ const failures = [];
795
+ const warnings = [];
796
+ const allPaths = extractSvgPaths(svgSource);
797
+ const visiblePaths = getVisiblePaths(allPaths);
798
+ const hiddenPaths = buildHiddenPathDetails(allPaths);
799
+ const embeddedImages = extractEmbeddedImages(svgSource);
800
+ const forbiddenElementCount = countForbiddenNonVectorElements(svgSource);
801
+ const embeddedImageCount = embeddedImages.length;
802
+ const vertexCount = visiblePaths.reduce((sum, p) => sum + countPathVertices(p.d), 0);
803
+ const hasSplitFillStroke = detectSplitFillStrokePaths(visiblePaths);
804
+ const colorOutlineOnSameShape = !hasSplitFillStroke;
805
+ if (hasSplitFillStroke) {
806
+ failures.push('fill and stroke are on separate paths with identical geometry');
807
+ }
808
+ const rootUnits = parseSvgRootUnits(svgSource);
809
+ const pixelUnitsOnly = rootUnits.pixelUnitsOnly;
810
+ if (!pixelUnitsOnly) {
811
+ const unitParts = [];
812
+ if (rootUnits.widthUnit !== 'px' && rootUnits.widthUnit !== 'missing') {
813
+ unitParts.push(`width=${rootUnits.widthRaw} (${rootUnits.widthUnit})`);
814
+ }
815
+ if (rootUnits.heightUnit !== 'px' && rootUnits.heightUnit !== 'missing') {
816
+ unitParts.push(`height=${rootUnits.heightRaw} (${rootUnits.heightUnit})`);
817
+ }
818
+ failures.push(`root dimensions must use px units${unitParts.length ? ` (${unitParts.join(', ')})` : ''}`);
819
+ }
820
+ const preserveAspectRatioNone = checkPreserveAspectRatioNone(svgSource);
821
+ if (!preserveAspectRatioNone) {
822
+ failures.push('root preserveAspectRatio="none" required at export');
823
+ }
824
+ const vectorIssues = [];
825
+ if (forbiddenElementCount > 0) {
826
+ vectorIssues.push(`${forbiddenElementCount} non-vector element(s) (text/use/foreignObject)`);
827
+ }
828
+ if (embeddedImageCount > 0) {
829
+ const embeddedRaster = embeddedImages.filter(i => i.hrefKind === 'embedded_raster');
830
+ if (embeddedRaster.length > 0) {
831
+ vectorIssues.push(`${embeddedRaster.length} embedded raster <image> fallback(s)`);
832
+ }
833
+ else {
834
+ vectorIssues.push(`${embeddedImageCount} <image> element(s)`);
835
+ }
836
+ }
837
+ if (hiddenPaths.length > 0) {
838
+ vectorIssues.push(`${hiddenPaths.length} hidden path(s)`);
839
+ }
840
+ const pathsOnly = vectorIssues.length === 0;
841
+ if (!pathsOnly) {
842
+ failures.push(`vector clean — ${vectorIssues.join('; ')}`);
843
+ }
844
+ if (hiddenPaths.length > 0) {
845
+ for (const hp of hiddenPaths) {
846
+ const fillNote = hp.fill ? ` fill=${hp.fill}` : '';
847
+ warnings.push(`hidden path[${hp.index}]${fillNote} (${hp.reason.replace('_', ':')})`);
848
+ }
849
+ }
850
+ const viewBoxFit = checkViewBoxFitsVisibleContent(svgSource, visiblePaths);
851
+ const viewBoxMatchesVisibleContent = viewBoxFit.pass;
852
+ if (!viewBoxFit.pass && viewBoxFit.reason) {
853
+ failures.push(viewBoxFit.reason);
854
+ }
855
+ const viewBoxCheck = checkCenteredTightViewBox(svgSource, visiblePaths);
856
+ const centeredTightViewBox = viewBoxCheck.pass;
857
+ if (!viewBoxCheck.pass && viewBoxCheck.reason) {
858
+ failures.push(viewBoxCheck.reason);
859
+ }
860
+ return {
861
+ vertexCount,
862
+ visiblePathCount: visiblePaths.length,
863
+ hiddenPathCount: hiddenPaths.length,
864
+ forbiddenElementCount,
865
+ embeddedImageCount,
866
+ colorOutlineOnSameShape,
867
+ pathsOnly,
868
+ pixelUnitsOnly,
869
+ preserveAspectRatioNone,
870
+ viewBoxMatchesVisibleContent,
871
+ centeredTightViewBox,
872
+ viewBoxFit,
873
+ viewBoxMetrics: viewBoxCheck,
874
+ rootUnits,
875
+ hiddenPaths,
876
+ embeddedImages,
877
+ failures,
878
+ warnings,
879
+ };
880
+ }
881
+ //# sourceMappingURL=svgAssetAnalysis.js.map