@pixodesk/svg-animator-core 1.0.44 → 1.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
- OFFSET_DISTANCE_ATTR,
3
2
  PX_DEFAULT_DURATION_MS,
3
+ PX_DEFAULT_ITERATIONS,
4
4
  PX_TIMELINE_SHARED_KEYS,
5
5
  PX_TIME_ONLY_TIMELINE_KEYS,
6
6
  PX_TRANSFORM_PART_KEYS,
@@ -20,6 +20,7 @@ import {
20
20
  PxCloneWithout,
21
21
  PxControlMode,
22
22
  PxDefinitionsSchema,
23
+ PxDiagnosticCode,
23
24
  PxDiagnosticKind,
24
25
  PxEffectsSchema,
25
26
  PxElementAnimationSchema,
@@ -61,6 +62,7 @@ import {
61
62
  PxTextPathEffectSchema,
62
63
  PxTextPathMethod,
63
64
  PxTextPathSpacing,
65
+ PxTimeTimelineSchema,
64
66
  PxTimelineEngine,
65
67
  PxTimelineEngineSetting,
66
68
  PxTimelineSchema,
@@ -72,1880 +74,44 @@ import {
72
74
  PxUnits,
73
75
  PxWireStepKind,
74
76
  PxWireVersionRelation,
75
- TRANSFORM_ATTR,
76
- TRANSFORM_PART,
77
77
  __spreadProps,
78
78
  __spreadValues,
79
- applyTextGlyphsAlongPath,
80
- applyTextGlyphsEffect,
81
- applyTextPathEffect,
82
- applyUseOffsetToG,
83
79
  applyWireSteps,
84
- bezier2D_arcLengthLUT,
85
- bezierToSvgPath,
86
80
  calcAnimationValues,
87
81
  clamp,
88
- clone,
89
82
  compareWireVersion,
90
83
  controlModeTakesOverTrigger,
91
84
  convertWireDocument,
92
- deepClonePxNode,
93
85
  describeSchema,
94
86
  diagnoseDocument,
95
87
  downgradeWireDocument,
96
88
  flattenAnimatorTimeline,
97
89
  formatWireVersion,
98
- genId,
99
90
  generateNewIds,
100
91
  getAnimatorConfig,
101
92
  getBindings,
102
93
  getChildren,
103
94
  getDefinitions,
104
- indexById,
105
95
  isNativeForced,
106
96
  isPxDocument,
107
97
  isValidPxDocument,
108
- keyframeEasing,
109
- keyframeTangentIn,
110
- keyframeTangentOut,
111
- keyframeTime,
112
- keyframeValue,
113
- keyframeWith,
114
- materializeInternalLoopsInTree,
115
- materializeMotionPathsInTree,
98
+ materializeAllInTree,
99
+ materializeNodeEffects,
116
100
  mayUseNativeScrollTimeline,
117
101
  nestAnimatorTimeline,
118
102
  normalizeBindings,
119
- parseSvgPathToBezier,
120
103
  parseWireVersion,
121
- partsRecord,
122
104
  px,
123
- readAnimatable,
124
- readStaticOrigin,
125
105
  readWireVersion,
126
- regenerateIdsAndRewriteRefs,
127
- regenerateIdsInClone,
128
106
  resolveControlMode,
129
107
  resolveTimelineEngine,
130
108
  resolveTrigger,
131
109
  schemaKeys,
132
- spliceDefs,
133
- stripHash,
134
110
  toDomProps,
135
111
  validateDocument,
136
112
  validateNodeEffects,
137
- wireVersionAdvice,
138
- writeAnimatableChannel
139
- } from "./chunk-EFQLDGFY.js";
140
-
141
- // src/effects/transform/transformationEffect.ts
142
- function applyTransformByEffect(node, fx, ctx) {
143
- if (!fx) return node;
144
- delete node.transform;
145
- let n = node;
146
- n = wrapOrigin(
147
- n,
148
- fx.origin,
149
- /*invert=*/
150
- true
151
- );
152
- n = wrapTransformPart(n, "scale" /* Scale */, normalizeScale(fx.scale), ctx);
153
- n = wrapTransformPart(n, "skew" /* Skew */, fx.skew, ctx);
154
- n = wrapTransformPart(n, "rotate" /* Rotate */, fx.rotate, ctx);
155
- n = wrapOrigin(
156
- n,
157
- fx.origin,
158
- /*invert=*/
159
- false
160
- );
161
- if (translateHasAutoOrient(fx.translate)) {
162
- n = wrapOrigin(
163
- n,
164
- fx.origin,
165
- /*invert=*/
166
- true
167
- );
168
- n = wrapTransformPart(n, "translate" /* Translate */, fx.translate, ctx);
169
- n = wrapOrigin(
170
- n,
171
- fx.origin,
172
- /*invert=*/
173
- false
174
- );
175
- } else {
176
- n = wrapTransformPart(n, "translate" /* Translate */, fx.translate, ctx);
177
- }
178
- if (n !== node && node.id) {
179
- n.id = node.id;
180
- delete node.id;
181
- }
182
- return n;
183
- }
184
- function translateHasAutoOrient(translate) {
185
- if (!translate || typeof translate !== "object") return false;
186
- const obj = translate;
187
- if (obj.autoOrient) return true;
188
- return Array.isArray(obj.keyframes) && obj.keyframes.some((kf) => kf.tangentOut || kf.tangentIn);
189
- }
190
- function normalizeScale(raw) {
191
- return raw;
192
- }
193
- function wrapTransformPart(inner, part, raw, ctx) {
194
- if (raw === void 0) return inner;
195
- const v = readAnimatable(raw);
196
- if (v.kind === "static" /* Static */) {
197
- return { type: "g", transform: { value: partsRecord(part, v.value, void 0) }, children: [inner] };
198
- }
199
- if (v.kind === "animated" /* Animated */) {
200
- const animTr = { keyframes: v.keyframes.map((kf) => keyframeWith(kf, partsRecord(part, kf.value, void 0))) };
201
- if (v.autoOrient) animTr.autoOrient = true;
202
- if (v.loop !== void 0) animTr.loop = v.loop;
203
- return {
204
- type: "g",
205
- animate: { transform: animTr },
206
- children: [inner]
207
- };
208
- }
209
- return inner;
210
- }
211
- function wrapOrigin(inner, raw, invert) {
212
- if (raw === void 0) return inner;
213
- const v = readAnimatable(raw);
214
- const sign = (value) => invert ? [-value[0], -value[1]] : value;
215
- if (v.kind === "absent" /* Absent */) return inner;
216
- if (v.kind === "static" /* Static */) {
217
- if (v.value[0] === 0 && v.value[1] === 0) return inner;
218
- return { type: "g", transform: { value: { translate: sign(v.value) } }, children: [inner] };
219
- }
220
- if (v.kind === "animated" /* Animated */) {
221
- const animTr = { keyframes: v.keyframes.map((kf) => keyframeWith(kf, { translate: sign(kf.value) })) };
222
- if (v.loop !== void 0) animTr.loop = v.loop;
223
- return {
224
- type: "g",
225
- animate: { transform: animTr },
226
- children: [inner]
227
- };
228
- }
229
- return inner;
230
- }
231
-
232
- // src/effects/reference/contentRefSplit.ts
233
- function identifyContentRefTargets(node, ctx, allocator) {
234
- var _a, _b, _c;
235
- if (node.type === "use" && ((_b = (_a = node.effects) == null ? void 0 : _a.clone) == null ? void 0 : _b.without) === "translate") {
236
- const sourceId = stripHash(node.effects.clone.source);
237
- if (typeof sourceId === "string" && sourceId && !ctx.contentRefInnerIds.has(sourceId)) {
238
- ctx.contentRefInnerIds.set(sourceId, allocator(sourceId));
239
- }
240
- }
241
- (_c = node.children) == null ? void 0 : _c.forEach((c) => identifyContentRefTargets(c, ctx, allocator));
242
- }
243
- function splitForContentRef(node, transformBy, originalId, innerId, ctx) {
244
- const outerBody = liftBodyTranslate(node, transformBy);
245
- if (typeof node.id === "string") delete node.id;
246
- const { outer: outerTr, inner: innerTr } = splitTransformByEffect(transformBy);
247
- let innerNode = node;
248
- innerNode = applyTransformByEffect(innerNode, innerTr, ctx);
249
- const innerWrapper = { type: "g", id: innerId, children: [innerNode] };
250
- let outerWrapper = { type: "g", id: originalId, children: [innerWrapper] };
251
- if (outerBody.transform !== void 0) outerWrapper.transform = outerBody.transform;
252
- if (outerBody.animate !== void 0) outerWrapper.animate = outerBody.animate;
253
- if (outerTr) {
254
- delete outerWrapper.id;
255
- outerWrapper = applyTransformByEffect(outerWrapper, outerTr, ctx);
256
- outerWrapper.id = originalId;
257
- }
258
- return outerWrapper;
259
- }
260
- function liftBodyTranslate(node, transformBy) {
261
- var _a, _b, _c;
262
- const out = {};
263
- let didLiftAnimate = false;
264
- const animTr = (_a = node.animate) == null ? void 0 : _a.transform;
265
- if (animTr && typeof animTr === "object" && Array.isArray(animTr.keyframes)) {
266
- const kfs = animTr.keyframes;
267
- const hasTranslate = kfs.some((kf) => kf.value && kf.value.translate);
268
- if (hasTranslate) {
269
- const outerHasOrigin = needsOriginOnOuter(animTr);
270
- const outerKfs = kfs.map((kf) => {
271
- const v = kf.value || {};
272
- const newValue = {};
273
- if (v.translate !== void 0) newValue.translate = v.translate;
274
- if (outerHasOrigin && v.origin !== void 0) newValue.origin = v.origin;
275
- const outerKf = { value: newValue };
276
- if (kf.time !== void 0) outerKf.time = kf.time;
277
- if (kf.easing !== void 0) outerKf.easing = kf.easing;
278
- if (kf.tangentOut !== void 0) outerKf.tangentOut = kf.tangentOut;
279
- if (kf.tangentIn !== void 0) outerKf.tangentIn = kf.tangentIn;
280
- return outerKf;
281
- });
282
- const outerAnimTr = { keyframes: outerKfs };
283
- if (animTr.autoOrient) outerAnimTr.autoOrient = true;
284
- const srcLoop = animTr.loop;
285
- if (srcLoop !== void 0) outerAnimTr.loop = srcLoop;
286
- out.animate = { transform: outerAnimTr };
287
- const innerHasPivotedPart = kfs.some((kf) => {
288
- const v = kf.value || {};
289
- return v.rotate !== void 0 || v.scale !== void 0;
290
- });
291
- const innerKfs = kfs.map((kf) => {
292
- const v = kf.value || {};
293
- const newValue = {};
294
- if (v.rotate !== void 0) newValue.rotate = v.rotate;
295
- if (v.scale !== void 0) newValue.scale = v.scale;
296
- if (v.origin !== void 0 && (!outerHasOrigin || innerHasPivotedPart)) newValue.origin = v.origin;
297
- const innerKf = { value: newValue };
298
- if (kf.time !== void 0) innerKf.time = kf.time;
299
- if (kf.easing !== void 0) innerKf.easing = kf.easing;
300
- return innerKf;
301
- });
302
- const allInnerEmpty = innerKfs.every((kf) => Object.keys(kf.value).length === 0);
303
- if (allInnerEmpty) {
304
- delete node.animate.transform;
305
- if (node.animate && Object.keys(node.animate).length === 0) delete node.animate;
306
- } else {
307
- const innerAnimTr = { keyframes: innerKfs };
308
- if (srcLoop !== void 0) innerAnimTr.loop = srcLoop;
309
- node.animate.transform = innerAnimTr;
310
- }
311
- didLiftAnimate = true;
312
- }
313
- }
314
- const transformationHasTranslate = (transformBy == null ? void 0 : transformBy.translate) !== void 0;
315
- const stripBodyTranslateOnly = didLiftAnimate || transformationHasTranslate;
316
- const liftedAnimateIsAutoOriented = didLiftAnimate && needsOriginOnOuter(((_b = node.animate) == null ? void 0 : _b.transform) || void 0) || didLiftAnimate && needsOriginOnOuter(((_c = out.animate) == null ? void 0 : _c.transform) || void 0);
317
- if (typeof node.transform === "string") {
318
- const split = splitTransformString(node.transform);
319
- if (stripBodyTranslateOnly) {
320
- if (split.translate !== void 0) {
321
- if (split.rest) node.transform = split.rest;
322
- else delete node.transform;
323
- } else if (isPureTranslateBody(node.transform)) {
324
- delete node.transform;
325
- } else if (liftedAnimateIsAutoOriented && isSingleMatrixBody(node.transform)) {
326
- delete node.transform;
327
- }
328
- } else if (split.translate) {
329
- out.transform = split.translate;
330
- if (split.rest) node.transform = split.rest;
331
- else delete node.transform;
332
- }
333
- } else if (node.transform && typeof node.transform === "object" && !Array.isArray(node.transform) && !node.transform.keyframes) {
334
- const wrapped = node.transform.value;
335
- const isWrapped = !!(wrapped && typeof wrapped === "object");
336
- const value = isWrapped ? wrapped : node.transform;
337
- const rewrap = (rec) => isWrapped ? { value: rec } : rec;
338
- if (Array.isArray(value.translate)) {
339
- const rest = __spreadValues({}, value);
340
- delete rest.translate;
341
- const hasRest = Object.keys(rest).length > 0;
342
- if (stripBodyTranslateOnly) {
343
- if (hasRest) node.transform = rewrap(rest);
344
- else delete node.transform;
345
- } else {
346
- out.transform = rewrap({ translate: value.translate });
347
- if (hasRest) node.transform = rewrap(rest);
348
- else delete node.transform;
349
- }
350
- }
351
- }
352
- return out;
353
- }
354
- function isSingleMatrixBody(s) {
355
- const re = /(translate|rotate|scale|matrix|skewX|skewY)\(([^)]*)\)/g;
356
- let count = 0;
357
- let isMatrix = false;
358
- let m;
359
- while (m = re.exec(s)) {
360
- count++;
361
- if (m[1] === "matrix") isMatrix = true;
362
- }
363
- return count === 1 && isMatrix;
364
- }
365
- function isPureTranslateBody(s) {
366
- const re = /(translate|rotate|scale|matrix|skewX|skewY)\(([^)]*)\)/g;
367
- const ops = [];
368
- let m;
369
- while (m = re.exec(s)) ops.push({ name: m[1], full: m[0] });
370
- if (ops.length !== 1) return false;
371
- if (ops[0].name === "translate") return true;
372
- if (ops[0].name !== "matrix") return false;
373
- const args = /matrix\(([^)]*)\)/.exec(ops[0].full);
374
- if (!args) return false;
375
- const nums = args[1].split(/[\s,]+/).filter(Boolean).map(Number);
376
- return nums.length >= 4 && nums[0] === 1 && nums[1] === 0 && nums[2] === 0 && nums[3] === 1;
377
- }
378
- function splitTransformString(s) {
379
- const ops = [];
380
- const re = /(translate|rotate|scale|matrix|skewX|skewY)\(([^)]*)\)/g;
381
- let m;
382
- while (m = re.exec(s)) ops.push({ name: m[1], full: m[0] });
383
- if (!ops.length) return { rest: s || void 0 };
384
- if (ops.every((o) => o.name === "translate")) {
385
- return { translate: ops.map((o) => o.full).join("") };
386
- }
387
- const leading = ops[0];
388
- const trailing = ops[ops.length - 1];
389
- if (trailing.name === "translate" && leading.name === "translate") {
390
- const trailingVec = parseTranslateArgs(trailing.full);
391
- const leadingVec = parseTranslateArgs(leading.full);
392
- const ox = -trailingVec[0];
393
- const oy = -trailingVec[1];
394
- const userTx = leadingVec[0] - ox;
395
- const userTy = leadingVec[1] - oy;
396
- if (userTx === 0 && userTy === 0) return { rest: s };
397
- const middleAndTrailing = "translate(" + ox + "," + oy + ")" + ops.slice(1).map((o) => o.full).join("");
398
- return { translate: "translate(" + userTx + "," + userTy + ")", rest: middleAndTrailing };
399
- }
400
- if (trailing.name === "translate") return { rest: s };
401
- const lifted = [];
402
- let i = 0;
403
- while (i < ops.length && ops[i].name === "translate") {
404
- lifted.push(ops[i].full);
405
- i++;
406
- }
407
- if (!lifted.length) return { rest: s };
408
- const rest = ops.slice(i).map((o) => o.full).join("");
409
- return {
410
- translate: lifted.join(""),
411
- rest: rest || void 0
412
- };
413
- }
414
- function parseTranslateArgs(translateOp) {
415
- const m = /translate\(([^)]*)\)/.exec(translateOp);
416
- if (!m) return [0, 0];
417
- const nums = m[1].split(/[\s,]+/).filter(Boolean).map(Number);
418
- return [nums[0] || 0, nums[1] || 0];
419
- }
420
- function splitTransformByEffect(fx) {
421
- if (!fx) return {};
422
- const originOnOuter = needsOriginOnOuter(fx.translate);
423
- const innerHasPivotedPart = fx.rotate !== void 0 || fx.scale !== void 0;
424
- const outer = {};
425
- const inner = {};
426
- if (fx.translate !== void 0) outer.translate = fx.translate;
427
- if (originOnOuter && fx.origin !== void 0) outer.origin = fx.origin;
428
- if (fx.rotate !== void 0) inner.rotate = fx.rotate;
429
- if (fx.scale !== void 0) inner.scale = fx.scale;
430
- if (fx.skew !== void 0) inner.skew = fx.skew;
431
- if (fx.origin !== void 0 && (!originOnOuter || innerHasPivotedPart)) inner.origin = fx.origin;
432
- return {
433
- outer: Object.keys(outer).length ? outer : void 0,
434
- inner: Object.keys(inner).length ? inner : void 0
435
- };
436
- }
437
- function needsOriginOnOuter(translateAnim) {
438
- if (!translateAnim || typeof translateAnim !== "object") return false;
439
- const obj = translateAnim;
440
- if (obj.autoOrient) return true;
441
- if (Array.isArray(obj.keyframes)) {
442
- return obj.keyframes.some((kf) => kf.tangentOut || kf.tangentIn);
443
- }
444
- return false;
445
- }
446
-
447
- // src/effects/paint/gradientEffect.ts
448
- function applyFillGradientEffect(node, fx, ctx) {
449
- return applyGradient(node, fx, ctx, "fill");
450
- }
451
- function applyStrokeGradientEffect(node, fx, ctx) {
452
- return applyGradient(node, fx, ctx, "stroke");
453
- }
454
- function applyGradient(node, fx, ctx, attr) {
455
- if (!fx) return node;
456
- const id = genId(ctx, "grad");
457
- const def = synthesiseGradientDef(fx, id, ctx);
458
- ctx.defs.push(def);
459
- node[attr] = "url(#" + id + ")";
460
- return node;
461
- }
462
- function synthesiseGradientDef(fx, id, ctx) {
463
- const out = {
464
- type: fx.type === PxGradientType.radial ? "radialGradient" : "linearGradient",
465
- id
466
- };
467
- if (fx.type === PxGradientType.linear) {
468
- applyGeomVec(out, "x1", "y1", fx.start);
469
- applyGeomVec(out, "x2", "y2", fx.end);
470
- } else {
471
- applyGeomVec(out, "cx", "cy", fx.center);
472
- applyGeomNumber(out, "r", fx.radius);
473
- applyGeomVec(out, "fx", "fy", fx.focal);
474
- }
475
- if (fx.gradientUnits) out.gradientUnits = fx.gradientUnits;
476
- if (fx.spreadMethod) out.spreadMethod = fx.spreadMethod;
477
- if (fx.gradientTransform) out.gradientTransform = fx.gradientTransform;
478
- out.children = buildStopChildren(fx.stops, ctx);
479
- return out;
480
- }
481
- function applyGeomVec(out, xAttr, yAttr, raw) {
482
- var _a, _b, _c;
483
- const read = readAnimatable(raw);
484
- if (read.kind === "absent" /* Absent */) return;
485
- if (read.kind === "static" /* Static */) {
486
- out[xAttr] = String(read.value[0]);
487
- out[yAttr] = String(read.value[1]);
488
- return;
489
- }
490
- const axisChannel = (idx) => {
491
- const block = {
492
- keyframes: read.keyframes.map((kf) => {
493
- const axisKf = { time: kf.time, value: Array.isArray(kf.value) ? kf.value[idx] : void 0 };
494
- if (kf.easing !== void 0) axisKf.easing = kf.easing;
495
- return axisKf;
496
- })
497
- };
498
- if (read.loop !== void 0) block.loop = read.loop;
499
- return block;
500
- };
501
- const animate = (_a = out.animate) != null ? _a : {};
502
- animate[xAttr] = axisChannel(0);
503
- animate[yAttr] = axisChannel(1);
504
- out.animate = animate;
505
- const baseline = (_c = read.base) != null ? _c : (_b = read.keyframes[0]) == null ? void 0 : _b.value;
506
- if (Array.isArray(baseline)) {
507
- out[xAttr] = String(baseline[0]);
508
- out[yAttr] = String(baseline[1]);
509
- }
510
- }
511
- function applyGeomNumber(out, attrName, raw) {
512
- const read = readAnimatable(raw);
513
- if (read.kind === "absent" /* Absent */) return;
514
- writeAnimatableChannel(out, attrName, read, { asString: true });
515
- }
516
- function buildStopChildren(stops, ctx) {
517
- var _a, _b;
518
- if (!stops) return [];
519
- const read = readAnimatable(stops);
520
- if (read.kind === "absent" /* Absent */) return [];
521
- if (read.kind === "static" /* Static */) return Array.isArray(read.value) ? read.value.map(staticStopNode) : [];
522
- const kfs = read.keyframes;
523
- if (!kfs.length) return [];
524
- const loopFromSource = read.loop;
525
- let stopCount = 0;
526
- for (const kf of kfs) {
527
- const v = keyframeValue(kf);
528
- if (Array.isArray(v) && v.length > stopCount) stopCount = v.length;
529
- }
530
- if (!stopCount) return [];
531
- const firstKfValue = keyframeValue(kfs[0]);
532
- const baselineStops = [];
533
- for (let i = 0; i < stopCount; i++) {
534
- const s = (_b = (_a = firstKfValue == null ? void 0 : firstKfValue[i]) != null ? _a : prevDefinedStop(kfs, 0, i)) != null ? _b : { offset: i / Math.max(1, stopCount - 1), color: "#000000" };
535
- baselineStops.push({ offset: s.offset, color: s.color });
536
- }
537
- return baselineStops.map((bs, i) => animatedStopNode(bs, kfs, i, ctx, loopFromSource));
538
- }
539
- function staticStopNode(s) {
540
- return {
541
- type: "stop",
542
- offset: formatOffset(s.offset),
543
- stopColor: s.color
544
- };
545
- }
546
- function animatedStopNode(baseline, kfs, stopIdx, _ctx, loop) {
547
- var _a;
548
- const colorKfs = [];
549
- const offsetKfs = [];
550
- let offsetVaries = false;
551
- for (const kf of kfs) {
552
- const t = keyframeTime(kf);
553
- const arr = keyframeValue(kf);
554
- const sliced = (_a = arr == null ? void 0 : arr[stopIdx]) != null ? _a : prevDefinedStop(kfs, kfs.indexOf(kf), stopIdx);
555
- if (!sliced) continue;
556
- const easing = keyframeEasing(kf);
557
- const colorOut = { time: t, value: sliced.color };
558
- if (easing !== void 0) colorOut.easing = easing;
559
- colorKfs.push(colorOut);
560
- const offsetOut = { time: t, value: sliced.offset };
561
- if (easing !== void 0) offsetOut.easing = easing;
562
- offsetKfs.push(offsetOut);
563
- if (sliced.offset !== baseline.offset) offsetVaries = true;
564
- }
565
- const stop = {
566
- type: "stop",
567
- offset: formatOffset(baseline.offset),
568
- stopColor: baseline.color
569
- };
570
- const animate = {};
571
- if (colorKfs.length) {
572
- animate.stopColor = { keyframes: colorKfs };
573
- if (loop !== void 0) animate.stopColor.loop = loop;
574
- }
575
- if (offsetVaries && offsetKfs.length) {
576
- animate.offset = { keyframes: offsetKfs };
577
- if (loop !== void 0) animate.offset.loop = loop;
578
- }
579
- if (Object.keys(animate).length) stop.animate = animate;
580
- return stop;
581
- }
582
- function prevDefinedStop(kfs, fromIdx, stopIdx) {
583
- for (let i = fromIdx; i >= 0; i--) {
584
- const arr = keyframeValue(kfs[i]);
585
- if (arr == null ? void 0 : arr[stopIdx]) return arr[stopIdx];
586
- }
587
- for (let i = fromIdx + 1; i < kfs.length; i++) {
588
- const arr = keyframeValue(kfs[i]);
589
- if (arr == null ? void 0 : arr[stopIdx]) return arr[stopIdx];
590
- }
591
- return void 0;
592
- }
593
- function formatOffset(o) {
594
- const pct = Math.round(o * 1e3) / 10;
595
- return pct + "%";
596
- }
597
-
598
- // src/effects/clipping/clipPathEffect.ts
599
- function applyClipPathEffect(node, fx, ctx) {
600
- if (!(fx == null ? void 0 : fx.pathData)) return node;
601
- const clipId = genId(ctx, "clip");
602
- const pathChild = { type: "path" };
603
- const read = readAnimatable(fx.pathData);
604
- if (read.kind !== "absent" /* Absent */) {
605
- if (read.kind === "static" /* Static */) {
606
- pathChild.d = pathString(read.value);
607
- } else {
608
- writeAnimatableChannel(pathChild, "d", read);
609
- if (pathChild.d !== void 0) pathChild.d = pathString(pathChild.d);
610
- }
611
- }
612
- ctx.defs.push({ type: "clipPath", id: clipId, children: [pathChild] });
613
- node.clipPath = "url(#" + clipId + ")";
614
- return node;
615
- }
616
- function pathString(v) {
617
- if (typeof v === "string") return v;
618
- if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
619
- return void 0;
620
- }
621
-
622
- // src/effects/clipping/maskedByEffect.ts
623
- function applyMaskedByEffect(node, fx, transformBy, ctx) {
624
- if (!fx) return node;
625
- const sourceId = stripHash(fx.source);
626
- if (!sourceId) {
627
- ctx.errors.push("maskedBy.source missing \u2014 cannot build mask");
628
- return node;
629
- }
630
- const maskId = genId(ctx, "mask");
631
- let content = { type: "use", href: "#" + sourceId };
632
- if (transformBy) {
633
- content = wrapInverseTransform(content, transformBy, ctx);
634
- } else if (hasAnimateTransform(node)) {
635
- content = wrapInverseAnimatedBodyTransform(content, node, ctx);
636
- } else {
637
- const bodyStatic = readTransformationFromBody(node);
638
- if (bodyStatic) content = wrapInverseTransform(content, bodyStatic, ctx);
639
- }
640
- const includeTargetOwn = transformBy === void 0 && !nodeHasBodyTransform(node);
641
- content = wrapAncestorChainCompensation(content, node, sourceId, ctx, includeTargetOwn);
642
- const mask = { type: "mask", id: maskId, children: [content] };
643
- if (fx.maskType) mask.maskType = fx.maskType;
644
- if (fx.maskUnits) mask.maskUnits = fx.maskUnits;
645
- if (fx.maskContentUnits) mask.maskContentUnits = fx.maskContentUnits;
646
- if (fx.x !== void 0) mask.x = String(fx.x);
647
- if (fx.y !== void 0) mask.y = String(fx.y);
648
- if (fx.width !== void 0) mask.width = String(fx.width);
649
- if (fx.height !== void 0) mask.height = String(fx.height);
650
- ctx.defs.push(mask);
651
- node.mask = "url(#" + maskId + ")";
652
- return node;
653
- }
654
- function wrapInverseTransform(inner, fx, ctx) {
655
- if (!fx) return inner;
656
- const origin = readStaticOrigin(fx.origin, ctx);
657
- let n = inner;
658
- n = wrapInversePart(n, "translate" /* Translate */, fx.translate, void 0, ctx);
659
- n = wrapInversePart(n, "rotate" /* Rotate */, fx.rotate, origin, ctx);
660
- n = wrapInversePart(n, "scale" /* Scale */, fx.scale, origin, ctx);
661
- return n;
662
- }
663
- function wrapInversePart(inner, part, raw, origin, ctx) {
664
- if (raw === void 0) return inner;
665
- const normalizedRaw = part === "scale" /* Scale */ && Array.isArray(raw) ? [raw[0] / 100, raw[1] / 100] : raw;
666
- const v = readAnimatable(normalizedRaw);
667
- if (v.kind === "static" /* Static */) {
668
- return { type: "g", transform: { value: partsRecord(part, invertPartValue(part, v.value), origin) }, children: [inner] };
669
- }
670
- if (v.kind === "animated" /* Animated */) {
671
- const animTr = { keyframes: v.keyframes.map((kf) => {
672
- const out = keyframeWith(kf, partsRecord(part, invertPartValue(part, kf.value), origin));
673
- return part === "translate" /* Translate */ ? __spreadValues(__spreadValues({}, out), negatedSpatialTangents(kf)) : out;
674
- }) };
675
- if (v.loop !== void 0) animTr.loop = v.loop;
676
- return {
677
- type: "g",
678
- animate: { transform: animTr },
679
- children: [inner]
680
- };
681
- }
682
- return inner;
683
- }
684
- function invertPartValue(part, value) {
685
- if (part === "translate" /* Translate */) return [-value[0], -value[1]];
686
- if (part === "rotate" /* Rotate */) return -value;
687
- return [1 / value[0], 1 / value[1]];
688
- }
689
- function negatedSpatialTangents(kf) {
690
- var _a, _b;
691
- const out = {};
692
- const to = (_a = kf.tangentOut) != null ? _a : kf.to;
693
- const ti = (_b = kf.tangentIn) != null ? _b : kf.ti;
694
- if (Array.isArray(to)) out.tangentOut = [-to[0], -to[1]];
695
- if (Array.isArray(ti)) out.tangentIn = [-ti[0], -ti[1]];
696
- return out;
697
- }
698
- function wrapInverseAnimatedBodyTransform(inner, node, _ctx) {
699
- var _a;
700
- const animate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
701
- const animTr = animate == null ? void 0 : animate.transform;
702
- const kfs = animTr && typeof animTr === "object" && Array.isArray(animTr.keyframes) ? animTr.keyframes : void 0;
703
- if (!kfs || !kfs.length) return inner;
704
- const translateKfs = [];
705
- const rotateKfs = [];
706
- const scaleKfs = [];
707
- for (const kf of kfs) {
708
- const v = ((_a = kf.value) != null ? _a : kf.v) || {};
709
- const baseKf = keyframeWith(kf, void 0);
710
- if (Array.isArray(v.translate)) {
711
- translateKfs.push(__spreadProps(__spreadValues(__spreadValues({}, baseKf), negatedSpatialTangents(kf)), { value: { translate: [-v.translate[0], -v.translate[1]] } }));
712
- }
713
- if (typeof v.rotate === "number") {
714
- const rec = { rotate: -v.rotate };
715
- if (Array.isArray(v.origin)) rec.origin = [v.origin[0], v.origin[1]];
716
- rotateKfs.push(__spreadProps(__spreadValues({}, baseKf), { value: rec }));
717
- }
718
- if (Array.isArray(v.scale)) {
719
- const rec = { scale: [1 / v.scale[0], 1 / v.scale[1]] };
720
- if (Array.isArray(v.origin)) rec.origin = [v.origin[0], v.origin[1]];
721
- scaleKfs.push(__spreadProps(__spreadValues({}, baseKf), { value: rec }));
722
- }
723
- }
724
- const srcLoop = animTr == null ? void 0 : animTr.loop;
725
- const withLoop = (kfs2) => {
726
- const block = { keyframes: kfs2 };
727
- if (srcLoop !== void 0) block.loop = srcLoop;
728
- return block;
729
- };
730
- let n = inner;
731
- if (translateKfs.length) n = { type: "g", animate: { transform: withLoop(translateKfs) }, children: [n] };
732
- if (rotateKfs.length) n = { type: "g", animate: { transform: withLoop(rotateKfs) }, children: [n] };
733
- if (scaleKfs.length) n = { type: "g", animate: { transform: withLoop(scaleKfs) }, children: [n] };
734
- return n;
735
- }
736
- function nodeHasBodyTransform(node) {
737
- if (typeof node.transform === "string") return true;
738
- if (node.transform && typeof node.transform === "object") return true;
739
- return hasAnimateTransform(node);
740
- }
741
- function hasAnimateTransform(node) {
742
- const animate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
743
- return !!(animate && animate.transform);
744
- }
745
- function readTransformationFromBody(node) {
746
- if (typeof node.transform === "string") {
747
- const parts = parseTransformStringToParts(node.transform);
748
- if (!parts) return void 0;
749
- const out = {};
750
- if (parts.translate) out.translate = parts.translate;
751
- if (parts.rotate !== void 0) out.rotate = parts.rotate;
752
- if (parts.scale) out.scale = { value: parts.scale };
753
- if (parts.origin) out.origin = parts.origin;
754
- return Object.keys(out).length ? out : void 0;
755
- }
756
- if (node.transform && typeof node.transform === "object" && !node.transform.keyframes) {
757
- const wrapped = node.transform.value;
758
- const value = wrapped && typeof wrapped === "object" ? wrapped : node.transform;
759
- if (value && typeof value === "object") {
760
- const out = {};
761
- if (Array.isArray(value.translate)) out.translate = value.translate;
762
- if (typeof value.rotate === "number") out.rotate = value.rotate;
763
- if (typeof value.skew === "number") out.skew = value.skew;
764
- if (Array.isArray(value.scale)) out.scale = { value: value.scale };
765
- if (Array.isArray(value.origin)) out.origin = value.origin;
766
- return Object.keys(out).length ? out : void 0;
767
- }
768
- }
769
- return void 0;
770
- }
771
- function parseTransformStringToParts(s) {
772
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
773
- const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
774
- let m;
775
- const ops = [];
776
- while ((m = re.exec(s)) !== null) {
777
- const args = m[2].split(/[\s,]+/).filter((a) => a.length > 0).map(Number);
778
- ops.push({ name: m[1], args });
779
- }
780
- if (!ops.length) return void 0;
781
- const last = ops[ops.length - 1];
782
- if (last.name === "translate") {
783
- for (let j = ops.length - 2; j >= 0; j--) {
784
- const cand = ops[j];
785
- if (cand.name !== "translate") continue;
786
- const ox = (_a = cand.args[0]) != null ? _a : 0;
787
- const oy = (_b = cand.args[1]) != null ? _b : 0;
788
- const lx = (_c = last.args[0]) != null ? _c : 0;
789
- const ly = (_d = last.args[1]) != null ? _d : 0;
790
- if (lx !== -ox || ly !== -oy) continue;
791
- const out2 = {};
792
- out2.origin = [ox, oy];
793
- for (let k = 0; k < j; k++) {
794
- if (ops[k].name === "translate") {
795
- const tx = (_e = ops[k].args[0]) != null ? _e : 0;
796
- const ty = (_f = ops[k].args[1]) != null ? _f : 0;
797
- out2.translate = out2.translate ? [out2.translate[0] + tx, out2.translate[1] + ty] : [tx, ty];
798
- }
799
- }
800
- for (let k = j + 1; k < ops.length - 1; k++) {
801
- const op = ops[k];
802
- if (op.name === "rotate") out2.rotate = ((_g = out2.rotate) != null ? _g : 0) + ((_h = op.args[0]) != null ? _h : 0);
803
- else if (op.name === "scale") {
804
- const sx = (_i = op.args[0]) != null ? _i : 1;
805
- const sy = op.args.length > 1 ? op.args[1] : sx;
806
- out2.scale = out2.scale ? [out2.scale[0] * sx, out2.scale[1] * sy] : [sx, sy];
807
- }
808
- }
809
- return out2;
810
- }
811
- }
812
- let translate;
813
- let rotate;
814
- let scale;
815
- for (const op of ops) {
816
- if (op.name === "translate") {
817
- const dx = (_j = op.args[0]) != null ? _j : 0;
818
- const dy = (_k = op.args[1]) != null ? _k : 0;
819
- translate = translate ? [translate[0] + dx, translate[1] + dy] : [dx, dy];
820
- } else if (op.name === "rotate") {
821
- rotate = (rotate != null ? rotate : 0) + ((_l = op.args[0]) != null ? _l : 0);
822
- } else if (op.name === "scale") {
823
- const sx = (_m = op.args[0]) != null ? _m : 1;
824
- const sy = op.args.length > 1 ? op.args[1] : sx;
825
- scale = scale ? [scale[0] * sx, scale[1] * sy] : [sx, sy];
826
- }
827
- }
828
- const out = {};
829
- if (translate) out.translate = translate;
830
- if (rotate !== void 0) out.rotate = rotate;
831
- if (scale) out.scale = scale;
832
- return Object.keys(out).length ? out : void 0;
833
- }
834
- function wrapAncestorChainCompensation(inner, maskedNode, sourceId, ctx, includeTargetOwn) {
835
- const sourceNode = ctx.idMap.get(sourceId);
836
- const targetAncestors = ctx.maskAncestorChains.get(maskedNode) || [];
837
- const targetOwn = includeTargetOwn ? extractTranslateOnly(maskedNode, ctx) : void 0;
838
- const targetChain = targetOwn ? [...targetAncestors, targetOwn] : targetAncestors;
839
- const sourceChain = sourceNode && ctx.maskAncestorChains.get(sourceNode) || [];
840
- if (!targetChain.length && !sourceChain.length) return inner;
841
- const times = /* @__PURE__ */ new Set();
842
- for (const a of targetChain) if (a.translateKeyframes) for (const kf of a.translateKeyframes) times.add(kf.time);
843
- for (const a of sourceChain) if (a.translateKeyframes) for (const kf of a.translateKeyframes) times.add(kf.time);
844
- const animated = times.size > 0;
845
- if (!animated) {
846
- const tgt = sumStaticTranslate(targetChain);
847
- const src = sumStaticTranslate(sourceChain);
848
- const dx = src[0] - tgt[0];
849
- const dy = src[1] - tgt[1];
850
- if (dx === 0 && dy === 0) return inner;
851
- return { type: "g", transform: "translate(" + dx + "," + dy + ")", children: [inner] };
852
- }
853
- const sortedTimes = Array.from(times).sort((a, b) => a - b);
854
- const keyframes = sortedTimes.map((t) => {
855
- const tgt = sumTranslateAt(targetChain, t);
856
- const src = sumTranslateAt(sourceChain, t);
857
- return { time: t, value: { translate: [src[0] - tgt[0], src[1] - tgt[1]] } };
858
- });
859
- return { type: "g", animate: { transform: { keyframes } }, children: [inner] };
860
- }
861
- function sumStaticTranslate(chain) {
862
- let x = 0, y = 0;
863
- for (const a of chain) {
864
- if (a.translate) {
865
- x += a.translate[0];
866
- y += a.translate[1];
867
- }
868
- }
869
- return [x, y];
870
- }
871
- function sumTranslateAt(chain, t) {
872
- let x = 0, y = 0;
873
- for (const a of chain) {
874
- if (a.translateKeyframes && a.translateKeyframes.length) {
875
- const v = interpKfs(a.translateKeyframes, t);
876
- x += v[0];
877
- y += v[1];
878
- } else if (a.translate) {
879
- x += a.translate[0];
880
- y += a.translate[1];
881
- }
882
- }
883
- return [x, y];
884
- }
885
- function interpKfs(kfs, t) {
886
- if (t <= kfs[0].time) return kfs[0].value;
887
- if (t >= kfs[kfs.length - 1].time) return kfs[kfs.length - 1].value;
888
- for (let i = 1; i < kfs.length; i++) {
889
- if (t <= kfs[i].time) {
890
- const prev = kfs[i - 1];
891
- const cur = kfs[i];
892
- const a = (t - prev.time) / (cur.time - prev.time);
893
- return [prev.value[0] + (cur.value[0] - prev.value[0]) * a, prev.value[1] + (cur.value[1] - prev.value[1]) * a];
894
- }
895
- }
896
- return kfs[kfs.length - 1].value;
897
- }
898
- function collectMaskAncestorChains(root, ctx) {
899
- const interestingNodes = /* @__PURE__ */ new Set();
900
- const collectInterestingNodes = (n) => {
901
- var _a, _b;
902
- const maskSourceId = stripHash((_b = (_a = n.effects) == null ? void 0 : _a.maskedBy) == null ? void 0 : _b.source);
903
- if (typeof maskSourceId === "string") {
904
- interestingNodes.add(n);
905
- const sourceNode = ctx.idMap.get(maskSourceId);
906
- if (sourceNode) interestingNodes.add(sourceNode);
907
- }
908
- if (Array.isArray(n.children)) for (const ch of n.children) collectInterestingNodes(ch);
909
- };
910
- collectInterestingNodes(root);
911
- if (interestingNodes.size === 0) return;
912
- const walk = (node, chain) => {
913
- if (interestingNodes.has(node)) ctx.maskAncestorChains.set(node, chain);
914
- if (Array.isArray(node.children)) {
915
- const own = extractTranslateOnly(node, ctx);
916
- const next = own ? [...chain, own] : chain;
917
- for (const ch of node.children) walk(ch, next);
918
- }
919
- };
920
- walk(root, []);
921
- }
922
- function extractTranslateOnly(node, ctx) {
923
- var _a, _b, _c;
924
- const tr = node.transform;
925
- const animateBlock = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate.transform : void 0;
926
- if (tr === void 0 && !animateBlock) return void 0;
927
- const out = {};
928
- if (typeof tr === "string") {
929
- const parts = parseTranslateOnlyFromString(tr, ctx);
930
- if (parts) out.translate = parts;
931
- } else if (tr && typeof tr === "object" && !tr.keyframes) {
932
- const wrapped = tr.value;
933
- const value = wrapped && typeof wrapped === "object" ? wrapped : tr;
934
- if (value && typeof value === "object" && Array.isArray(value.translate)) {
935
- out.translate = [value.translate[0] || 0, value.translate[1] || 0];
936
- }
937
- if (value && (value.rotate !== void 0 || value.scale !== void 0 || value.skew !== void 0)) {
938
- ctx.warnings.push("maskedBy ancestor: non-translate transform parts ignored (rotate/scale not yet supported)");
939
- }
940
- }
941
- if (animateBlock && Array.isArray(animateBlock.keyframes)) {
942
- const kfs = animateBlock.keyframes;
943
- const translateKfs = [];
944
- for (const kf of kfs) {
945
- const v = (_a = kf.value) != null ? _a : kf.v;
946
- const t = (_c = (_b = kf.time) != null ? _b : kf.t) != null ? _c : 0;
947
- if (v && typeof v === "object" && Array.isArray(v.translate)) {
948
- translateKfs.push({ time: t, value: [v.translate[0] || 0, v.translate[1] || 0] });
949
- if (v.rotate !== void 0 || v.scale !== void 0 || v.skew !== void 0) {
950
- ctx.warnings.push("maskedBy ancestor: animated non-translate parts ignored");
951
- }
952
- }
953
- }
954
- if (translateKfs.length) out.translateKeyframes = translateKfs;
955
- }
956
- return out.translate || out.translateKeyframes ? out : void 0;
957
- }
958
- function parseTranslateOnlyFromString(s, ctx) {
959
- const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
960
- let m;
961
- let x = 0, y = 0;
962
- let seen = false;
963
- let droppedNonTranslate = false;
964
- while ((m = re.exec(s)) !== null) {
965
- const name = m[1];
966
- const args = m[2].split(/[\s,]+/).filter((a) => a.length > 0).map(Number);
967
- if (name === "translate") {
968
- x += args[0] || 0;
969
- y += args[1] || 0;
970
- seen = true;
971
- } else {
972
- droppedNonTranslate = true;
973
- }
974
- }
975
- if (droppedNonTranslate) ctx.warnings.push("maskedBy ancestor: non-translate transform in string ignored: " + s);
976
- return seen ? [x, y] : void 0;
977
- }
978
-
979
- // src/effects/reference/refEffect.ts
980
- function applyRefHref(node, clone2, ctx) {
981
- if (!clone2) return;
982
- const sourceId = stripHash(clone2.source);
983
- if (!sourceId) {
984
- if (clone2.without === PxCloneWithout.translate) ctx.errors.push("clone: content ref missing `source`");
985
- return;
986
- }
987
- const targetId = clone2.without === PxCloneWithout.translate ? ctx.contentRefInnerIds.get(sourceId) || sourceId : sourceId;
988
- node.href = "#" + targetId;
989
- }
990
- function applyRefAndTransformationEffect(node, clone2, transformBy, ctx) {
991
- applyRefHref(node, clone2, ctx);
992
- return applyTransformByEffect(node, transformBy, ctx);
993
- }
994
-
995
- // src/effects/transform/repeaterEffect.ts
996
- function applyRepeaterEffect(node, fx, ctx) {
997
- var _a, _b;
998
- if (!fx) return node;
999
- const copies = (_a = fx.copies) != null ? _a : 1;
1000
- if (copies < 1) {
1001
- ctx.errors.push("repeater.copies invalid: " + fx.copies);
1002
- return node;
1003
- }
1004
- const sharedTransform = node.transform;
1005
- const sharedAnimTransform = (_b = node.animate) == null ? void 0 : _b.transform;
1006
- const base = clone(node);
1007
- delete base.transform;
1008
- if (base.animate) {
1009
- delete base.animate.transform;
1010
- if (Object.keys(base.animate).length === 0) delete base.animate;
1011
- }
1012
- delete base.id;
1013
- const children = [base];
1014
- for (let i = 1; i < copies; i++) {
1015
- const baseClone = clone(base);
1016
- const synthFx = synthesisePerCopyFx(fx, i);
1017
- const wrapped = synthFx ? applyTransformByEffect(baseClone, synthFx, ctx) : baseClone;
1018
- children.push(wrapped);
1019
- }
1020
- const wrapper = { type: "g", children };
1021
- if (node.id) wrapper.id = node.id;
1022
- if (sharedTransform !== void 0) wrapper.transform = sharedTransform;
1023
- if (sharedAnimTransform !== void 0) wrapper.animate = { transform: sharedAnimTransform };
1024
- return wrapper;
1025
- }
1026
- function synthesisePerCopyFx(fx, i) {
1027
- const out = {};
1028
- if (fx.translate !== void 0) {
1029
- out.translate = mapAnimatable(fx.translate, (v) => [v[0] * i, v[1] * i]);
1030
- }
1031
- if (fx.rotate !== void 0) {
1032
- out.rotate = mapAnimatable(fx.rotate, (v) => v * i);
1033
- }
1034
- if (fx.skew !== void 0) {
1035
- out.skew = mapAnimatable(fx.skew, (v) => v * i);
1036
- }
1037
- if (fx.scale !== void 0) {
1038
- out.scale = synthesiseScale(fx.scale, i);
1039
- }
1040
- if (fx.origin !== void 0) {
1041
- out.origin = fx.origin;
1042
- }
1043
- return Object.keys(out).length ? out : void 0;
1044
- }
1045
- function mapAnimatable(raw, fn, wrapStatic = false) {
1046
- const read = readAnimatable(raw);
1047
- if (read.kind === "absent" /* Absent */) return raw;
1048
- if (read.kind === "static" /* Static */) {
1049
- const mapped = fn(read.value);
1050
- const wasRawStatic = typeof raw === "number" || Array.isArray(raw);
1051
- return wasRawStatic && !wrapStatic ? mapped : { value: mapped };
1052
- }
1053
- const out = {
1054
- keyframes: read.keyframes.map((kf) => kf && kf.value !== void 0 ? __spreadProps(__spreadValues({}, kf), { value: fn(kf.value) }) : kf)
1055
- };
1056
- if (read.loop !== void 0) out.loop = read.loop;
1057
- if (read.autoOrient !== void 0) out.autoOrient = read.autoOrient;
1058
- if (read.base !== void 0) out.value = fn(read.base);
1059
- return out;
1060
- }
1061
- function synthesiseScale(raw, i) {
1062
- const scalePower = (v) => [Math.pow(v[0], i), Math.pow(v[1], i)];
1063
- return mapAnimatable(raw, scalePower, true);
1064
- }
1065
-
1066
- // src/effects/reference/retimeEffect.ts
1067
- var RETIME_MATERIALIZATION_MODE_INLINE_G = false;
1068
- function asRetime(r) {
1069
- var _a, _b;
1070
- return { start: (_a = r.start) != null ? _a : 0, stretch: (_b = r.stretch) != null ? _b : 1 };
1071
- }
1072
- var CROP_EDGE_MS = 1;
1073
- function applyTimeCrop(useNode, crop, ctx) {
1074
- const [start, end] = crop;
1075
- if (!Number.isFinite(start) || !Number.isFinite(end)) {
1076
- ctx.warnings.push("retime: timeCrop is not a pair of finite numbers \u2014 ignored");
1077
- return;
1078
- }
1079
- const keyframes = end <= start ? [{ time: 0, value: 0 }] : [
1080
- ...start > 0 ? [{ time: Math.max(0, start - CROP_EDGE_MS), value: 0 }] : [],
1081
- { time: Math.max(0, start), value: 1 },
1082
- { time: end, value: 1 },
1083
- { time: end + CROP_EDGE_MS, value: 0 }
1084
- ];
1085
- const inner = __spreadValues({}, useNode);
1086
- for (const k of Object.keys(useNode)) delete useNode[k];
1087
- useNode.type = "g";
1088
- useNode.children = [inner];
1089
- useNode.animate = { opacity: { keyframes } };
1090
- }
1091
- function concatRetime(child, parent) {
1092
- return {
1093
- start: parent.start + parent.stretch * child.start,
1094
- stretch: parent.stretch * child.stretch
1095
- };
1096
- }
1097
- function readCloneRetime(n) {
1098
- var _a, _b;
1099
- return (_b = (_a = n.effects) == null ? void 0 : _a.clone) == null ? void 0 : _b.retime;
1100
- }
1101
- function clearCloneRetime(n) {
1102
- var _a;
1103
- const clone2 = (_a = n.effects) == null ? void 0 : _a.clone;
1104
- if (!clone2) return;
1105
- delete clone2.retime;
1106
- if (Object.keys(clone2).length === 0) delete n.effects.clone;
1107
- if (n.effects && Object.keys(n.effects).length === 0) delete n.effects;
1108
- }
1109
- function applyAllRetimeEffects(root, ctx) {
1110
- ctx.idMap.clear();
1111
- indexById(root, ctx.idMap);
1112
- const sites = [];
1113
- const collect = (n) => {
1114
- var _a;
1115
- if (readCloneRetime(n)) sites.push(n);
1116
- (_a = n.children) == null ? void 0 : _a.forEach(collect);
1117
- };
1118
- collect(root);
1119
- const reachCount = /* @__PURE__ */ new Map();
1120
- for (const site of sites) {
1121
- let count = 0;
1122
- const visited = /* @__PURE__ */ new Set();
1123
- const walk = (n) => {
1124
- var _a;
1125
- if (!n) return;
1126
- if (n !== site && readCloneRetime(n)) count++;
1127
- if (n.type === "use" && n.href) {
1128
- const id = stripHash(n.href);
1129
- if (id && !visited.has(id)) {
1130
- visited.add(id);
1131
- walk(ctx.idMap.get(id));
1132
- }
1133
- }
1134
- (_a = n.children) == null ? void 0 : _a.forEach(walk);
1135
- };
1136
- const rootId = stripHash(site.href);
1137
- if (rootId) {
1138
- visited.add(rootId);
1139
- walk(ctx.idMap.get(rootId));
1140
- }
1141
- reachCount.set(site, count);
1142
- }
1143
- sites.sort((a, b) => {
1144
- var _a, _b;
1145
- return ((_a = reachCount.get(b)) != null ? _a : 0) - ((_b = reachCount.get(a)) != null ? _b : 0);
1146
- });
1147
- for (const useNode of sites) {
1148
- const retime = readCloneRetime(useNode);
1149
- if (!retime) continue;
1150
- const crop = retime.timeCrop;
1151
- clearCloneRetime(useNode);
1152
- materializeRetime(useNode, asRetime(retime), ctx);
1153
- if (crop) applyTimeCrop(useNode, crop, ctx);
1154
- }
1155
- }
1156
- function materializeRetime(useNode, retime, ctx) {
1157
- const targetId = stripHash(useNode.href);
1158
- if (!targetId) {
1159
- ctx.errors.push("retime: <use> has no href to follow");
1160
- return;
1161
- }
1162
- const chainRootId = buildChainClone(targetId, retime, ctx, /* @__PURE__ */ new Set());
1163
- if (!chainRootId) return;
1164
- if (RETIME_MATERIALIZATION_MODE_INLINE_G) {
1165
- const cloneNode = ctx.idMap.get(chainRootId);
1166
- useNode.type = "g";
1167
- delete useNode.href;
1168
- useNode.children = [cloneNode];
1169
- applyUseOffsetToG(useNode);
1170
- ctx.defs = ctx.defs.filter((d) => d !== cloneNode);
1171
- } else {
1172
- useNode.href = "#" + chainRootId;
1173
- }
1174
- }
1175
- function buildChainClone(targetId, accum, ctx, chain) {
1176
- if (chain.has(targetId)) {
1177
- ctx.errors.push('retime: loop via "' + targetId + '"');
1178
- return void 0;
1179
- }
1180
- const target = ctx.idMap.get(targetId);
1181
- if (!target) {
1182
- ctx.warnings.push('retime: target "' + targetId + '" not found');
1183
- return void 0;
1184
- }
1185
- const cloneNode = clone(target);
1186
- regenerateIdsInClone(cloneNode, ctx);
1187
- if (target.type === "use") {
1188
- remapKeyframeTimesOnly(cloneNode, accum.start, accum.stretch);
1189
- } else {
1190
- remapKeyframeTimes(cloneNode, accum.start, accum.stretch);
1191
- }
1192
- clearCloneRetime(cloneNode);
1193
- if (target.type === "use" && target.href) {
1194
- const subId = stripHash(target.href);
1195
- if (subId) {
1196
- const innerRetime = readCloneRetime(target);
1197
- const subAccum = innerRetime ? concatRetime(asRetime(innerRetime), accum) : accum;
1198
- const subChain = new Set(chain);
1199
- subChain.add(targetId);
1200
- const subId2 = buildChainClone(subId, subAccum, ctx, subChain);
1201
- if (subId2) cloneNode.href = "#" + subId2;
1202
- }
1203
- } else {
1204
- materializeNestedRetimeUses(cloneNode, accum, ctx, chain, targetId);
1205
- }
1206
- ctx.defs.push(cloneNode);
1207
- if (typeof cloneNode.id === "string") ctx.idMap.set(cloneNode.id, cloneNode);
1208
- return typeof cloneNode.id === "string" ? cloneNode.id : void 0;
1209
- }
1210
- function materializeNestedRetimeUses(node, accum, ctx, chain, parentTargetId) {
1211
- const visit = (n) => {
1212
- var _a;
1213
- const retime = readCloneRetime(n);
1214
- if (n.type === "use" && retime && n.href) {
1215
- const subId = stripHash(n.href);
1216
- if (subId) {
1217
- const subAccum = concatRetime(asRetime(retime), accum);
1218
- const subChain = new Set(chain);
1219
- subChain.add(parentTargetId);
1220
- const subId2 = buildChainClone(subId, subAccum, ctx, subChain);
1221
- if (subId2) n.href = "#" + subId2;
1222
- }
1223
- clearCloneRetime(n);
1224
- }
1225
- (_a = n.children) == null ? void 0 : _a.forEach(visit);
1226
- };
1227
- visit(node);
1228
- }
1229
- function remapKeyframeTimes(node, start, stretch) {
1230
- var _a;
1231
- remapKeyframeTimesOnly(node, start, stretch);
1232
- (_a = node.children) == null ? void 0 : _a.forEach((c) => remapKeyframeTimes(c, start, stretch));
1233
- }
1234
- function remapKeyframeTimesOnly(node, start, stretch) {
1235
- const remap = (kfs) => {
1236
- for (const kf of kfs) if (typeof kf.time === "number") kf.time = start + kf.time * stretch;
1237
- };
1238
- if (node.transform && typeof node.transform === "object" && Array.isArray(node.transform.keyframes)) {
1239
- remap(node.transform.keyframes);
1240
- }
1241
- if (node.animate && typeof node.animate === "object") {
1242
- for (const prop of Object.keys(node.animate)) {
1243
- const anim = node.animate[prop];
1244
- if (anim && Array.isArray(anim.keyframes)) remap(anim.keyframes);
1245
- }
1246
- }
1247
- }
1248
-
1249
- // src/effects/stroke/strokeTrimEffect.ts
1250
- function applyStrokeTrimEffect(node, strokeTrim, ctx) {
1251
- if (!strokeTrim) return node;
1252
- const combined = strokeTrim.subPaths === PxStrokeTrimSubPaths.combined;
1253
- const leafEntries = [];
1254
- const measure = (n) => {
1255
- if (Array.isArray(n.children) && n.children.length > 0) {
1256
- for (const ch of n.children) measure(ch);
1257
- return;
1258
- }
1259
- const d = typeof n.d === "string" ? n.d : shapeToPathD(n);
1260
- if (d === void 0) return;
1261
- const subpaths = parseSvgPathToBezier(d);
1262
- if (!subpaths.length) return;
1263
- const entry = { leaf: n, subpaths: [] };
1264
- for (const sp of subpaths) {
1265
- const lengthPx = pxBezierPathLength(sp);
1266
- entry.subpaths.push({ subpath: sp, lengthPx, startOffsetPx: 0 });
1267
- }
1268
- leafEntries.push(entry);
1269
- };
1270
- measure(node);
1271
- if (!leafEntries.length) return node;
1272
- let acc = 0;
1273
- const iterOrder = combined ? [...leafEntries].reverse() : leafEntries;
1274
- for (const entry of iterOrder) {
1275
- for (const sp of entry.subpaths) {
1276
- if (!combined) acc = 0;
1277
- sp.startOffsetPx = acc;
1278
- acc += sp.lengthPx;
1279
- }
1280
- }
1281
- const chainLengthPx = acc;
1282
- if (combined && chainLengthPx < 1e-3) return node;
1283
- const offsetReadRaw = readAnimatable(strokeTrim.offset);
1284
- const offsetRead = offsetReadRaw.kind === "absent" /* Absent */ ? { kind: "static" /* Static */, value: 0 } : offsetReadRaw;
1285
- const rangeReadRaw = readRangeWithCrossings(strokeTrim.range);
1286
- const rangeRead = rangeReadRaw.kind === "absent" /* Absent */ ? { kind: "static" /* Static */, value: [0, 1] } : rangeReadRaw;
1287
- const offsetValues = readScalarValues(offsetRead);
1288
- const minOffset = offsetValues.length ? Math.min(...offsetValues) : 0;
1289
- const maxOffset = offsetValues.length ? Math.max(...offsetValues) : 0;
1290
- const minMaxOffset = [minOffset, maxOffset];
1291
- if (leafEntries.length === 1 && leafEntries[0].leaf === node && leafEntries[0].subpaths.length === 1) {
1292
- const entry = leafEntries[0];
1293
- const sp = entry.subpaths[0];
1294
- const pathLengthPx = combined ? chainLengthPx : sp.lengthPx;
1295
- if (pathLengthPx < 1e-3) return node;
1296
- const startOffsetPct = combined ? sp.startOffsetPx / pathLengthPx : 0;
1297
- return collapseLeafWithTrim(entry.leaf, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead);
1298
- }
1299
- const replacements = /* @__PURE__ */ new Map();
1300
- for (const entry of leafEntries) {
1301
- const newChildren = [];
1302
- for (const sp of entry.subpaths) {
1303
- const pathLengthPx = combined ? chainLengthPx : sp.lengthPx;
1304
- if (pathLengthPx < 1e-3) continue;
1305
- const startOffsetPct = combined ? sp.startOffsetPx / pathLengthPx : 0;
1306
- newChildren.push(...buildSubpathNodes(entry.leaf, sp.subpath, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead, ctx));
1307
- }
1308
- replacements.set(entry.leaf, wrapLeafAsGroup(entry.leaf, newChildren));
1309
- }
1310
- const swap = (n) => {
1311
- const r = replacements.get(n);
1312
- if (r) return r;
1313
- if (Array.isArray(n.children) && n.children.length > 0) {
1314
- return __spreadProps(__spreadValues({}, n), { children: n.children.map(swap) });
1315
- }
1316
- return n;
1317
- };
1318
- return swap(node);
1319
- }
1320
- function wrapLeafAsGroup(leaf, children) {
1321
- const wrapper = __spreadProps(__spreadValues({}, leaf), { type: "g", children });
1322
- delete wrapper.d;
1323
- delete wrapper.strokeDasharray;
1324
- delete wrapper.strokeDashoffset;
1325
- delete wrapper.effects;
1326
- return wrapper;
1327
- }
1328
- function buildSubpathNodes(leaf, subpath, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead, ctx) {
1329
- const offsetToDashOffset = makeOffsetToDashOffset(startOffsetPct, pathLengthPx, minMaxOffset);
1330
- const rangeToDasharray = makeRangeToDasharray(pathLengthPx, minMaxOffset);
1331
- const dashOffsetAttr = computeAnimAttr(offsetRead, offsetToDashOffset);
1332
- const dashArrayAttr = computeAnimAttr(rangeRead, rangeToDasharray);
1333
- const strokeOpacityAttr = computeOpacityFromRange(rangeRead);
1334
- const dStr = bezierToSvgPath(subpath);
1335
- const base = makeBareSubpath(dStr);
1336
- applyAttr(base, "strokeDasharray", dashArrayAttr);
1337
- applyAttr(base, "strokeDashoffset", dashOffsetAttr);
1338
- applyAttr(base, "strokeOpacity", strokeOpacityAttr);
1339
- return [base];
1340
- }
1341
- function collapseLeafWithTrim(leaf, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead) {
1342
- const offsetToDashOffset = makeOffsetToDashOffset(startOffsetPct, pathLengthPx, minMaxOffset);
1343
- const rangeToDasharray = makeRangeToDasharray(pathLengthPx, minMaxOffset);
1344
- const node = __spreadValues({}, leaf);
1345
- delete node.effects;
1346
- applyAttr(node, "strokeDasharray", computeAnimAttr(rangeRead, rangeToDasharray));
1347
- applyAttr(node, "strokeDashoffset", computeAnimAttr(offsetRead, offsetToDashOffset));
1348
- applyAttr(node, "strokeOpacity", computeOpacityFromRange(rangeRead));
1349
- return node;
1350
- }
1351
- function makeBareSubpath(dStr) {
1352
- return { type: "path", d: dStr };
1353
- }
1354
- var SMALL_PADDING_PX = 1;
1355
- function makeOffsetToDashOffset(startOffsetPct, pathLengthPx, minMaxOffset) {
1356
- const [minIdx] = getOffsetIndexRange(minMaxOffset);
1357
- return (offsetVal) => pathLengthPx * (-offsetVal - minIdx + startOffsetPct) + SMALL_PADDING_PX;
1358
- }
1359
- function makeRangeToDasharray(pathLengthPx, minMaxOffset) {
1360
- const [minIdx, maxIdx] = getOffsetIndexRange(minMaxOffset);
1361
- const repeats = maxIdx - minIdx + 1;
1362
- return (rangeVal) => {
1363
- const a = clamp(rangeVal[0], 0, 1);
1364
- const b = clamp(rangeVal[1], 0, 1);
1365
- const minR = Math.min(a, b);
1366
- const maxR = Math.max(a, b);
1367
- const out = [0];
1368
- let gap = SMALL_PADDING_PX;
1369
- for (let i = 0; i < repeats; i++) {
1370
- out.push(gap + minR * pathLengthPx);
1371
- out.push((maxR - minR) * pathLengthPx);
1372
- gap = (1 - maxR) * pathLengthPx;
1373
- }
1374
- out.push(gap + SMALL_PADDING_PX);
1375
- return out;
1376
- };
1377
- }
1378
- function getOffsetIndexRange(minMaxOffset) {
1379
- return [
1380
- Math.floor(Math.min(-minMaxOffset[0], -minMaxOffset[1])),
1381
- Math.ceil(Math.max(-minMaxOffset[0], -minMaxOffset[1]))
1382
- ];
1383
- }
1384
- function readScalarValues(r) {
1385
- if (r.kind === "absent" /* Absent */) return [];
1386
- if (r.kind === "static" /* Static */) return [r.value];
1387
- const out = [];
1388
- for (const kf of r.keyframes) {
1389
- const v = keyframeValue(kf);
1390
- if (typeof v === "number") out.push(v);
1391
- }
1392
- return out;
1393
- }
1394
- function computeAnimAttr(read, map) {
1395
- if (read.kind === "absent" /* Absent */) return void 0;
1396
- if (read.kind === "static" /* Static */) return { kind: "static" /* Static */, value: map(read.value) };
1397
- return {
1398
- kind: "animated" /* Animated */,
1399
- keyframes: read.keyframes.map((kf) => ({
1400
- time: keyframeTime(kf),
1401
- value: map(keyframeValue(kf)),
1402
- easing: keyframeEasing(kf)
1403
- })),
1404
- loop: read.loop
1405
- };
1406
- }
1407
- function applyAttr(node, attrName, attr) {
1408
- if (!attr) return;
1409
- writeAnimatableChannel(node, attrName, attr);
1410
- }
1411
- var OPACITY_STEP_MS = 10;
1412
- function computeOpacityFromRange(rangeRead) {
1413
- const hide = (v) => v[0] === v[1];
1414
- if (rangeRead.kind === "absent" /* Absent */) return void 0;
1415
- if (rangeRead.kind === "static" /* Static */) return hide(rangeRead.value) ? { kind: "static" /* Static */, value: 0 } : void 0;
1416
- const kfs = rangeRead.keyframes;
1417
- let anyHide = false;
1418
- let allHide = true;
1419
- for (const kf of kfs) {
1420
- if (hide(keyframeValue(kf))) anyHide = true;
1421
- else allHide = false;
1422
- }
1423
- if (!anyHide) return void 0;
1424
- if (allHide) return { kind: "static" /* Static */, value: 0 };
1425
- const out = [];
1426
- for (let i = 0; i < kfs.length; i++) {
1427
- const kf = kfs[i];
1428
- const prevKf = i > 0 ? kfs[i - 1] : void 0;
1429
- const nextKf = i < kfs.length - 1 ? kfs[i + 1] : void 0;
1430
- const t = keyframeTime(kf);
1431
- const thisHide = hide(keyframeValue(kf));
1432
- const prevHide = prevKf ? thisHide && hide(keyframeValue(prevKf)) : thisHide;
1433
- const nextHide = nextKf ? thisHide && hide(keyframeValue(nextKf)) : thisHide;
1434
- if (prevHide && !nextHide) {
1435
- out.push({ time: t, value: 0 });
1436
- out.push({ time: t + OPACITY_STEP_MS, value: 1 });
1437
- } else if (!prevHide && nextHide) {
1438
- out.push({ time: t - OPACITY_STEP_MS, value: 1 });
1439
- out.push({ time: t, value: 0 });
1440
- }
1441
- }
1442
- if (out.length <= 1) return void 0;
1443
- return { kind: "animated" /* Animated */, keyframes: out };
1444
- }
1445
- function readRangeWithCrossings(raw) {
1446
- const r = readAnimatable(raw);
1447
- if (r.kind !== "animated" /* Animated */) return r;
1448
- const kfs = r.keyframes.map((kf) => ({
1449
- time: keyframeTime(kf),
1450
- value: keyframeValue(kf),
1451
- easing: keyframeEasing(kf)
1452
- }));
1453
- const hasReverse = kfs.some((kf) => kf.value[0] > kf.value[1]);
1454
- if (!hasReverse) {
1455
- return {
1456
- kind: "animated" /* Animated */,
1457
- keyframes: kfs.map((kf) => ({ time: kf.time, value: kf.value, easing: kf.easing }))
1458
- };
1459
- }
1460
- const crossingTimes = [];
1461
- for (let i = 1; i < kfs.length; i++) {
1462
- const prev = kfs[i - 1];
1463
- const cur = kfs[i];
1464
- const dPrev = prev.value[1] - prev.value[0];
1465
- const dCur = cur.value[1] - cur.value[0];
1466
- if (dPrev * dCur < 0) {
1467
- const t = bisectionForRangeCrossing(prev, cur);
1468
- if (t !== null && t > prev.time && t < cur.time) {
1469
- crossingTimes.push(Math.round(t));
1470
- }
1471
- }
1472
- }
1473
- const uniqueTs = Array.from(new Set(crossingTimes)).sort((a, b) => a - b);
1474
- const out = [];
1475
- let j = 0;
1476
- for (const kf of kfs) {
1477
- while (j < uniqueTs.length && uniqueTs[j] < kf.time) {
1478
- const t = uniqueTs[j++];
1479
- const v2 = interpolateRangeAt(kfs, t);
1480
- const m = (v2[0] + v2[1]) / 2;
1481
- out.push({ time: t, value: [m, m] });
1482
- }
1483
- const v = kf.value[0] > kf.value[1] ? [kf.value[1], kf.value[0]] : kf.value;
1484
- out.push({ time: kf.time, value: v, easing: kf.easing });
1485
- }
1486
- while (j < uniqueTs.length) {
1487
- const t = uniqueTs[j++];
1488
- const v = interpolateRangeAt(kfs, t);
1489
- const m = (v[0] + v[1]) / 2;
1490
- out.push({ time: t, value: [m, m] });
1491
- }
1492
- return { kind: "animated" /* Animated */, keyframes: out };
1493
- }
1494
- function bisectionForRangeCrossing(prev, cur) {
1495
- const f = (t) => {
1496
- const a = (t - prev.time) / (cur.time - prev.time);
1497
- const v0 = prev.value[0] + (cur.value[0] - prev.value[0]) * a;
1498
- const v1 = prev.value[1] + (cur.value[1] - prev.value[1]) * a;
1499
- return v1 - v0;
1500
- };
1501
- let lo = prev.time, hi = cur.time;
1502
- let fLo = f(lo);
1503
- if (fLo === 0) return lo;
1504
- const fHi = f(hi);
1505
- if (fHi === 0) return hi;
1506
- if (fLo * fHi > 0) return null;
1507
- for (let i = 0; i < 100; i++) {
1508
- const mid = (lo + hi) / 2;
1509
- const fMid = f(mid);
1510
- if (fMid === 0 || Math.abs(hi - lo) < 1e-4) return mid;
1511
- if (fLo * fMid < 0) {
1512
- hi = mid;
1513
- } else {
1514
- lo = mid;
1515
- fLo = fMid;
1516
- }
1517
- }
1518
- return (lo + hi) / 2;
1519
- }
1520
- function interpolateRangeAt(kfs, t) {
1521
- if (t <= kfs[0].time) return kfs[0].value;
1522
- if (t >= kfs[kfs.length - 1].time) return kfs[kfs.length - 1].value;
1523
- for (let i = 1; i < kfs.length; i++) {
1524
- if (t <= kfs[i].time) {
1525
- const prev = kfs[i - 1];
1526
- const cur = kfs[i];
1527
- const a = (t - prev.time) / (cur.time - prev.time);
1528
- return [
1529
- prev.value[0] + (cur.value[0] - prev.value[0]) * a,
1530
- prev.value[1] + (cur.value[1] - prev.value[1]) * a
1531
- ];
1532
- }
1533
- }
1534
- return kfs[kfs.length - 1].value;
1535
- }
1536
- function pxBezierPathLength(path) {
1537
- const v = path.v;
1538
- if (!v || v.length < 2) return 0;
1539
- let total = 0;
1540
- for (let i = 0; i < v.length - 1; i++) {
1541
- total += segmentLength(path, i, i + 1);
1542
- }
1543
- if (path.c && v.length > 1) {
1544
- total += segmentLength(path, v.length - 1, 0);
1545
- }
1546
- return total;
1547
- }
1548
- function segmentLength(path, from, to) {
1549
- var _a, _b, _c, _d;
1550
- const v = path.v;
1551
- const p0 = v[from];
1552
- const p3 = v[to];
1553
- const p1 = (_b = (_a = path.o) == null ? void 0 : _a[from]) != null ? _b : p0;
1554
- const p2 = (_d = (_c = path.i) == null ? void 0 : _c[to]) != null ? _d : p3;
1555
- const lut = bezier2D_arcLengthLUT(p0, p1, p2, p3);
1556
- return lut.ds[lut.ds.length - 1];
1557
- }
1558
- var ARC_KAPPA = 0.5522847498307936;
1559
- function shapeToPathD(node) {
1560
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1561
- if (node.type === "rect") {
1562
- const x = Number((_a = node.x) != null ? _a : 0), y = Number((_b = node.y) != null ? _b : 0);
1563
- const w = Number((_c = node.width) != null ? _c : 0), h = Number((_d = node.height) != null ? _d : 0);
1564
- return "M" + (x + w) + "," + y + "L" + (x + w) + "," + (y + h) + "L" + x + "," + (y + h) + "L" + x + "," + y + "L" + (x + w) + "," + y + "z";
1565
- }
1566
- if (node.type === "ellipse" || node.type === "circle") {
1567
- const cx = Number((_e = node.cx) != null ? _e : 0), cy = Number((_f = node.cy) != null ? _f : 0);
1568
- const rx = node.type === "circle" ? Number((_g = node.r) != null ? _g : 0) : Number((_h = node.rx) != null ? _h : 0);
1569
- const ry = node.type === "circle" ? Number((_i = node.r) != null ? _i : 0) : Number((_j = node.ry) != null ? _j : 0);
1570
- if (!(rx > 0) || !(ry > 0)) return void 0;
1571
- const kx = rx * ARC_KAPPA, ky = ry * ARC_KAPPA;
1572
- const c = (x1, y1, x2, y2, x, y) => "C" + x1 + "," + y1 + " " + x2 + "," + y2 + " " + x + "," + y;
1573
- return "M" + (cx + rx) + "," + cy + c(cx + rx, cy + ky, cx + kx, cy + ry, cx, cy + ry) + c(cx - kx, cy + ry, cx - rx, cy + ky, cx - rx, cy) + c(cx - rx, cy - ky, cx - kx, cy - ry, cx, cy - ry) + c(cx + kx, cy - ry, cx + rx, cy - ky, cx + rx, cy) + "z";
1574
- }
1575
- return void 0;
1576
- }
1577
-
1578
- // src/effects/PlayerEffectsUtil.ts
1579
- function materializeNodeEffects(root) {
1580
- var _a, _b;
1581
- const ctx = {
1582
- defs: [],
1583
- warnings: [],
1584
- errors: [],
1585
- idMap: /* @__PURE__ */ new Map(),
1586
- nextId: 0,
1587
- contentRefInnerIds: /* @__PURE__ */ new Map(),
1588
- maskAncestorChains: /* @__PURE__ */ new Map(),
1589
- // Resolved engine: `frames` ONLY when explicitly set; auto/waapi/unset →
1590
- // waapi (we're not 100% sure it's frames, and CSS/WAAPI need the inline form).
1591
- engine: resolveTimelineEngine((_a = getAnimatorConfig(root)) == null ? void 0 : _a.engine),
1592
- glyphs: (_b = getDefinitions(root)) == null ? void 0 : _b.fonts
1593
- };
1594
- const working = clone(root);
1595
- indexById(working, ctx.idMap);
1596
- identifyContentRefTargets(working, ctx, () => genId(ctx, "inner"));
1597
- collectMaskAncestorChains(working, ctx);
1598
- const afterPass1 = applyPlayerEffects_exceptRetime(working, ctx);
1599
- const out = applyPlayerEffects_retime(afterPass1, ctx);
1600
- spliceDefs(out, ctx.defs);
1601
- return { root: out, defs: ctx.defs, warnings: ctx.warnings, errors: ctx.errors };
1602
- }
1603
- function applyPlayerEffects_exceptRetime(node, ctx) {
1604
- if (node.children) node.children = node.children.map((child) => applyPlayerEffects_exceptRetime(child, ctx));
1605
- const fx = node.effects;
1606
- const originalId = typeof node.id === "string" ? node.id : void 0;
1607
- const innerIdForContentRef = originalId ? ctx.contentRefInnerIds.get(originalId) : void 0;
1608
- if (!fx && !innerIdForContentRef) return node;
1609
- const { transformBy, repeater, maskedBy, clipPath, strokeTrim, clone: cloneFx, fillGradient, strokeGradient, textPath, text } = fx != null ? fx : {};
1610
- if (fx) delete node.effects;
1611
- let n = node;
1612
- let consumedByGlyphs = false;
1613
- if (text == null ? void 0 : text.useGlyphs) {
1614
- if (textPath) {
1615
- const pathD = typeof textPath.pathData === "string" ? textPath.pathData : void 0;
1616
- const glyphed = applyTextGlyphsAlongPath(n, ctx, pathD, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
1617
- if (glyphed) {
1618
- n = glyphed;
1619
- consumedByGlyphs = true;
1620
- }
1621
- } else {
1622
- n = applyTextGlyphsEffect(n, text, ctx);
1623
- consumedByGlyphs = true;
1624
- }
1625
- }
1626
- if (!consumedByGlyphs) n = applyTextPathEffect(n, textPath, ctx);
1627
- n = applyFillGradientEffect(n, fillGradient, ctx);
1628
- n = applyStrokeGradientEffect(n, strokeGradient, ctx);
1629
- n = applyStrokeTrimEffect(n, strokeTrim, ctx);
1630
- n = applyRepeaterEffect(n, repeater, ctx);
1631
- n = applyMaskedByEffect(n, maskedBy, transformBy, ctx);
1632
- n = applyClipPathEffect(n, clipPath, ctx);
1633
- if (innerIdForContentRef) {
1634
- applyRefHref(n, cloneFx, ctx);
1635
- n = splitForContentRef(n, transformBy, originalId, innerIdForContentRef, ctx);
1636
- } else {
1637
- n = applyRefAndTransformationEffect(n, cloneFx, transformBy, ctx);
1638
- }
1639
- if (cloneFx == null ? void 0 : cloneFx.retime) node.effects = { clone: { retime: cloneFx.retime } };
1640
- if (originalId) ctx.idMap.set(originalId, n);
1641
- return n;
1642
- }
1643
- function applyPlayerEffects_retime(node, ctx) {
1644
- applyAllRetimeEffects(node, ctx);
1645
- return node;
1646
- }
1647
-
1648
- // src/materialize/PxOffsetPathMaterializer.ts
1649
- function cubicAt(p0, c1, c2, p1, t) {
1650
- const u = 1 - t;
1651
- const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
1652
- return [
1653
- a * p0[0] + b * c1[0] + c * c2[0] + d * p1[0],
1654
- a * p0[1] + b * c1[1] + c * c2[1] + d * p1[1]
1655
- ];
1656
- }
1657
- function cubicLength(p0, c1, c2, p1, steps = 64) {
1658
- let len = 0;
1659
- let prev = p0;
1660
- for (let i = 1; i <= steps; i++) {
1661
- const pt = cubicAt(p0, c1, c2, p1, i / steps);
1662
- len += Math.hypot(pt[0] - prev[0], pt[1] - prev[1]);
1663
- prev = pt;
1664
- }
1665
- return len;
1666
- }
1667
- var fmt = (n) => {
1668
- const r = Math.round(n * 1e4) / 1e4;
1669
- return Object.is(r, -0) ? "0" : String(r);
1670
- };
1671
- function buildOffsetPath(propAnim) {
1672
- var _a, _b, _c;
1673
- if (propAnim.alongPathMode !== "offsetPath") return void 0;
1674
- const kfs = propAnim.keyframes;
1675
- if (!kfs || kfs.length < 2) return void 0;
1676
- const first = keyframeValue(kfs[0]);
1677
- const anchor = (first == null ? void 0 : first.origin) && first.origin.length >= 2 ? [first.origin[0], first.origin[1]] : [0, 0];
1678
- const points = [];
1679
- for (const kf of kfs) {
1680
- const v = keyframeValue(kf);
1681
- const tr = v == null ? void 0 : v.translate;
1682
- if (!tr || tr.length < 2) return void 0;
1683
- const parts = Object.keys(v);
1684
- if (parts.some((p) => p !== "translate" && p !== "origin")) return void 0;
1685
- const o = (_a = v == null ? void 0 : v.origin) != null ? _a : [0, 0];
1686
- if (o[0] !== anchor[0] || o[1] !== anchor[1]) return void 0;
1687
- points.push([tr[0] + anchor[0], tr[1] + anchor[1]]);
1688
- }
1689
- if (!kfs.some((kf) => keyframeTangentIn(kf) || keyframeTangentOut(kf))) return void 0;
1690
- let d = "M" + fmt(points[0][0]) + "," + fmt(points[0][1]);
1691
- const segLens = [];
1692
- for (let i = 0; i < points.length - 1; i++) {
1693
- const p0 = points[i], p1 = points[i + 1];
1694
- const to = (_b = keyframeTangentOut(kfs[i])) != null ? _b : [0, 0];
1695
- const ti = (_c = keyframeTangentIn(kfs[i + 1])) != null ? _c : [0, 0];
1696
- const c1 = [p0[0] + to[0], p0[1] + to[1]];
1697
- const c2 = [p1[0] + ti[0], p1[1] + ti[1]];
1698
- d += "C" + fmt(c1[0]) + "," + fmt(c1[1]) + "," + fmt(c2[0]) + "," + fmt(c2[1]) + "," + fmt(p1[0]) + "," + fmt(p1[1]);
1699
- segLens.push(cubicLength(p0, c1, c2, p1));
1700
- }
1701
- const total = segLens.reduce((a, b) => a + b, 0);
1702
- if (!(total > 0)) return void 0;
1703
- const distanceKfs = [];
1704
- let cum = 0;
1705
- for (let i = 0; i < kfs.length; i++) {
1706
- if (i > 0) cum += segLens[i - 1];
1707
- const out = { t: keyframeTime(kfs[i]), v: cum / total };
1708
- const e = keyframeEasing(kfs[i]);
1709
- if (e !== void 0) out.e = e;
1710
- distanceKfs.push(out);
1711
- }
1712
- return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor };
1713
- }
1714
- function materializeOffsetPathsInTree(root) {
1715
- const walk = (node) => {
1716
- var _a;
1717
- let out = node;
1718
- const anim = node.animate;
1719
- const transform = anim == null ? void 0 : anim["transform"];
1720
- if (transform) {
1721
- const built = buildOffsetPath(transform);
1722
- if (built) {
1723
- const newAnimate = __spreadValues({}, anim);
1724
- delete newAnimate[TRANSFORM_ATTR];
1725
- const distance = { keyframes: built.distanceKfs };
1726
- if (transform.loop !== void 0) distance.loop = transform.loop;
1727
- newAnimate[OFFSET_DISTANCE_ATTR] = distance;
1728
- const staticTr = node.transform;
1729
- let newTransform = staticTr;
1730
- if (staticTr && typeof staticTr === "object") {
1731
- const t = __spreadValues({}, staticTr);
1732
- delete t[TRANSFORM_PART.translate];
1733
- delete t[TRANSFORM_PART.origin];
1734
- newTransform = Object.keys(t).length ? t : void 0;
1735
- }
1736
- out = __spreadProps(__spreadValues({}, node), {
1737
- animate: newAnimate,
1738
- style: __spreadProps(__spreadValues({}, node.style), {
1739
- offsetPath: "path('" + built.pathStr + "')",
1740
- offsetAnchor: fmt(built.anchor[0]) + "px " + fmt(built.anchor[1]) + "px",
1741
- offsetRotate: built.autoOrient ? "auto" : "0deg",
1742
- offsetDistance: "0%"
1743
- })
1744
- });
1745
- if (newTransform !== void 0) out.transform = newTransform;
1746
- else delete out.transform;
1747
- }
1748
- }
1749
- if ((_a = out.children) == null ? void 0 : _a.length) {
1750
- const children = out.children.map(walk);
1751
- if (children.some((c, i) => c !== out.children[i])) out = __spreadProps(__spreadValues({}, out), { children });
1752
- }
1753
- return out;
1754
- };
1755
- return walk(root);
1756
- }
1757
-
1758
- // src/materialize/PxAnimatorUseMaterializer.ts
1759
- function materializeAnimatedUseInstances(root) {
1760
- var _a;
1761
- const idMap = buildIdMap(root);
1762
- const animatedIds = computeAnimatedSubtreeIds(root, idMap);
1763
- if (animatedIds.size === 0) return root;
1764
- let idCounter = 0;
1765
- const genId3 = () => "_lw_use_mat_" + ++idCounter;
1766
- const rootViewport = readRootViewport(root);
1767
- const defsCollector = [];
1768
- const walked = walkAndMaterialize(root, idMap, animatedIds, genId3, defsCollector, rootViewport);
1769
- if (defsCollector.length === 0) return walked;
1770
- const defsNode = { type: "defs", children: defsCollector };
1771
- const newChildren = [...(_a = walked.children) != null ? _a : [], defsNode];
1772
- return __spreadProps(__spreadValues({}, walked), { children: newChildren });
1773
- }
1774
- function readRootViewport(root) {
1775
- const vb = parseViewBox(root.viewBox);
1776
- if (vb) return [vb[2], vb[3]];
1777
- const w = numericAttr(root.width);
1778
- const h = numericAttr(root.height);
1779
- if (w !== void 0 && h !== void 0) return [w, h];
1780
- return [1, 1];
1781
- }
1782
- function numericAttr(v) {
1783
- if (typeof v === "number") return v;
1784
- if (typeof v === "string") {
1785
- const n = parseFloat(v);
1786
- return Number.isFinite(n) ? n : void 0;
1787
- }
1788
- return void 0;
1789
- }
1790
- function buildIdMap(root) {
1791
- const map = /* @__PURE__ */ new Map();
1792
- const visit = (n) => {
1793
- var _a;
1794
- if (typeof n.id === "string") map.set(n.id, n);
1795
- (_a = n.children) == null ? void 0 : _a.forEach(visit);
1796
- };
1797
- visit(root);
1798
- return map;
1799
- }
1800
- function computeAnimatedSubtreeIds(root, idMap) {
1801
- const cache = /* @__PURE__ */ new WeakMap();
1802
- const result = /* @__PURE__ */ new Set();
1803
- const hasAnim = (n, visiting) => {
1804
- const cached = cache.get(n);
1805
- if (cached !== void 0) return cached;
1806
- if (visiting.has(n)) return false;
1807
- visiting.add(n);
1808
- let r = false;
1809
- if (n.animate && typeof n.animate === "object" && !Array.isArray(n.animate)) {
1810
- for (const _ in n.animate) {
1811
- r = true;
1812
- break;
1813
- }
1814
- }
1815
- if (!r && n.children) {
1816
- for (const ch of n.children) {
1817
- if (hasAnim(ch, visiting)) {
1818
- r = true;
1819
- break;
1820
- }
1821
- }
1822
- }
1823
- if (!r && n.type === "use" && typeof n.href === "string") {
1824
- const targetId = stripHash2(n.href);
1825
- const target = targetId ? idMap.get(targetId) : void 0;
1826
- if (target) r = hasAnim(target, visiting);
1827
- }
1828
- visiting.delete(n);
1829
- cache.set(n, r);
1830
- return r;
1831
- };
1832
- for (const [id, node] of idMap) {
1833
- if (hasAnim(node, /* @__PURE__ */ new Set())) result.add(id);
1834
- }
1835
- return result;
1836
- }
1837
- function stripHash2(href) {
1838
- if (typeof href !== "string") return void 0;
1839
- return href.startsWith("#") ? href.slice(1) : href;
1840
- }
1841
- function materializeOneUse(useNode, target, idMap, animatedIds, genId3, defsCollector, rootViewport) {
1842
- var _a, _b, _c, _d;
1843
- const clone2 = deepClonePxNode(target);
1844
- regenerateIdsAndRewriteRefs(clone2, genId3);
1845
- const symbolViewBox = clone2.type === "symbol" ? parseViewBox(clone2.viewBox) : void 0;
1846
- const useW = (_b = (_a = numericAttr(useNode.width)) != null ? _a : symbolViewBox == null ? void 0 : symbolViewBox[2]) != null ? _b : rootViewport[0];
1847
- const useH = (_d = (_c = numericAttr(useNode.height)) != null ? _c : symbolViewBox == null ? void 0 : symbolViewBox[3]) != null ? _d : rootViewport[1];
1848
- const rewrittenClone = clone2.type === "symbol" ? rewriteSymbolRootToGroup(clone2, genId3, defsCollector, useW, useH) : clone2;
1849
- const materializedClone = walkAndMaterialize(rewrittenClone, idMap, animatedIds, genId3, defsCollector, rootViewport);
1850
- const newNode = __spreadProps(__spreadValues({}, useNode), { type: "g", children: [materializedClone] });
1851
- delete newNode.href;
1852
- delete newNode.width;
1853
- delete newNode.height;
1854
- return applyUseOffsetToG(newNode);
1855
- }
1856
- function rewriteSymbolRootToGroup(symbolNode, genId3, defsCollector, useW, useH) {
1857
- const viewBox = parseViewBox(symbolNode.viewBox);
1858
- const g = __spreadProps(__spreadValues({}, symbolNode), { type: "g" });
1859
- delete g.viewBox;
1860
- delete g.preserveAspectRatio;
1861
- delete g.width;
1862
- delete g.height;
1863
- if (!viewBox) return g;
1864
- const [vbX, vbY, vbW, vbH] = viewBox;
1865
- const scale = vbW > 0 && vbH > 0 ? Math.min(useW / vbW, useH / vbH) : 1;
1866
- const xOff = (useW - vbW * scale) / 2;
1867
- const yOff = (useH - vbH * scale) / 2;
1868
- const parts = [];
1869
- if (xOff !== 0 || yOff !== 0) parts.push("translate(" + xOff + "," + yOff + ")");
1870
- if (scale !== 1) parts.push("scale(" + scale + ")");
1871
- if (vbX !== 0 || vbY !== 0) parts.push("translate(" + -vbX + "," + -vbY + ")");
1872
- if (parts.length) g.transform = parts.join("");
1873
- const clipId = genId3();
1874
- defsCollector.push({
1875
- type: "clipPath",
1876
- id: clipId,
1877
- children: [{ type: "rect", x: vbX, y: vbY, width: vbW, height: vbH }]
1878
- });
1879
- g.clipPath = "url(#" + clipId + ")";
1880
- return g;
1881
- }
1882
- function parseViewBox(v) {
1883
- if (typeof v !== "string") return void 0;
1884
- const parts = v.trim().split(/[\s,]+/).map(Number);
1885
- if (parts.length < 4 || parts.some((n) => !Number.isFinite(n))) return void 0;
1886
- return [parts[0], parts[1], parts[2], parts[3]];
1887
- }
1888
- function walkAndMaterialize(node, idMap, animatedIds, genId3, defsCollector, rootViewport) {
1889
- if (node.type === "use" && typeof node.href === "string") {
1890
- const targetId = stripHash2(node.href);
1891
- if (targetId && animatedIds.has(targetId)) {
1892
- const target = idMap.get(targetId);
1893
- if (target) return materializeOneUse(node, target, idMap, animatedIds, genId3, defsCollector, rootViewport);
1894
- }
1895
- }
1896
- if (!node.children) return node;
1897
- let changed = false;
1898
- const newChildren = node.children.map((ch) => {
1899
- const m = walkAndMaterialize(ch, idMap, animatedIds, genId3, defsCollector, rootViewport);
1900
- if (m !== ch) changed = true;
1901
- return m;
1902
- });
1903
- return changed ? __spreadProps(__spreadValues({}, node), { children: newChildren }) : node;
1904
- }
1905
-
1906
- // src/materialize/PxAnimatorMaterializeAll.ts
1907
- function materializeAllInTree(doc, engine, options) {
1908
- var _a, _b;
1909
- let root = materializeNodeEffects(doc).root;
1910
- root = materializeOffsetPathsInTree(root);
1911
- const duration = (_b = (_a = getAnimatorConfig(root)) == null ? void 0 : _a.duration) != null ? _b : PX_DEFAULT_DURATION_MS;
1912
- root = materializeInternalLoopsInTree(root, duration);
1913
- if (engine === PxTimelineEngine.native) {
1914
- root = materializeMotionPathsInTree(root, options == null ? void 0 : options.motionPath);
1915
- root = materializeAnimatedUseInstances(root);
1916
- root = pruneUnreferencedDefs(root);
1917
- }
1918
- return root;
1919
- }
1920
- function pruneUnreferencedDefs(root) {
1921
- const stripHash3 = (h) => h.startsWith("#") ? h.slice(1) : h;
1922
- const walk = (n, fn) => {
1923
- var _a;
1924
- fn(n);
1925
- (_a = n.children) == null ? void 0 : _a.forEach((c) => walk(c, fn));
1926
- };
1927
- let changed = true;
1928
- while (changed) {
1929
- changed = false;
1930
- const referenced = /* @__PURE__ */ new Set();
1931
- walk(root, (n) => {
1932
- if (n.type === "use" && typeof n.href === "string") referenced.add(stripHash3(n.href));
1933
- });
1934
- walk(root, (n) => {
1935
- if (!n.children) return;
1936
- let kept = n.children;
1937
- if (n.type === "defs") {
1938
- kept = kept.filter((c) => !((c.type === "g" || c.type === "symbol") && typeof c.id === "string" && !referenced.has(c.id)));
1939
- }
1940
- kept = kept.filter((c) => !(c.type === "defs" && (!c.children || c.children.length === 0)));
1941
- if (kept.length !== n.children.length) {
1942
- n.children = kept;
1943
- changed = true;
1944
- }
1945
- });
1946
- }
1947
- return root;
1948
- }
113
+ wireVersionAdvice
114
+ } from "./chunk-37OFJ3RX.js";
1949
115
 
1950
116
  // src/playback/PxPlaybackTime.ts
1951
117
  var PX_RATE_REJECTED = "setPlaybackRate: rate must be finite and non-zero";
@@ -2027,13 +193,13 @@ function createAdapterAnimator(doc, adapter, callbacks) {
2027
193
  const bindings = normalizeBindings(doc, PxTimelineEngine.js);
2028
194
  const _iterations = config.iterations;
2029
195
  let iterations = 1;
2030
- if (typeof _iterations === "number") iterations = _iterations || 1;
196
+ if (typeof _iterations === "number") iterations = _iterations || PX_DEFAULT_ITERATIONS;
2031
197
  if (_iterations === "infinite") iterations = Infinity;
2032
198
  if (iterations < 1) iterations = 1;
2033
199
  const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
2034
- const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : 1) * duration : 0;
2035
- const direction = config.direction || "normal";
2036
- const fill = (_a = config.fill) != null ? _a : "forwards";
200
+ const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : PX_DEFAULT_ITERATIONS) * duration : 0;
201
+ const direction = config.direction || PxTimeTimelineSchema.defaults.direction;
202
+ const fill = (_a = config.fill) != null ? _a : PxTimeTimelineSchema.defaults.fillMode;
2037
203
  const fillsForwards = fill === "forwards" || fill === "both";
2038
204
  const fillsBackwards = fill === "backwards" || fill === "both";
2039
205
  let timerId = null;
@@ -2288,38 +454,6 @@ function createAdapterAnimator(doc, adapter, callbacks) {
2288
454
  return api;
2289
455
  }
2290
456
 
2291
- // src/playback/PxDiagnosticCode.ts
2292
- var PxDiagnosticCode = /* @__PURE__ */ ((PxDiagnosticCode2) => {
2293
- PxDiagnosticCode2[PxDiagnosticCode2["buildFailed"] = 1001] = "buildFailed";
2294
- PxDiagnosticCode2[PxDiagnosticCode2["invalidDocumentAtSrc"] = 1002] = "invalidDocumentAtSrc";
2295
- PxDiagnosticCode2[PxDiagnosticCode2["loadFailed"] = 1003] = "loadFailed";
2296
- PxDiagnosticCode2[PxDiagnosticCode2["animationBuildFailed"] = 1004] = "animationBuildFailed";
2297
- PxDiagnosticCode2[PxDiagnosticCode2["effectsShape"] = 1101] = "effectsShape";
2298
- PxDiagnosticCode2[PxDiagnosticCode2["timelineOverrideIgnored"] = 1102] = "timelineOverrideIgnored";
2299
- PxDiagnosticCode2[PxDiagnosticCode2["blockedTag"] = 1103] = "blockedTag";
2300
- PxDiagnosticCode2[PxDiagnosticCode2["unsupportedAnimatedAttrs"] = 1104] = "unsupportedAnimatedAttrs";
2301
- PxDiagnosticCode2[PxDiagnosticCode2["noBindings"] = 1105] = "noBindings";
2302
- PxDiagnosticCode2[PxDiagnosticCode2["unresolvedBinding"] = 1106] = "unresolvedBinding";
2303
- PxDiagnosticCode2[PxDiagnosticCode2["triggersNoRoot"] = 1201] = "triggersNoRoot";
2304
- PxDiagnosticCode2[PxDiagnosticCode2["noRootForSelector"] = 1202] = "noRootForSelector";
2305
- PxDiagnosticCode2[PxDiagnosticCode2["noRootElement"] = 1203] = "noRootElement";
2306
- PxDiagnosticCode2[PxDiagnosticCode2["noElementsForSelector"] = 1206] = "noElementsForSelector";
2307
- PxDiagnosticCode2[PxDiagnosticCode2["setAttributeNoElement"] = 1207] = "setAttributeNoElement";
2308
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSmoothingNeedsOwnDriver"] = 1301] = "scrollSmoothingNeedsOwnDriver";
2309
- PxDiagnosticCode2[PxDiagnosticCode2["scrollNativeUnavailable"] = 1302] = "scrollNativeUnavailable";
2310
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectInvalid"] = 1303] = "scrollSubjectInvalid";
2311
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectNoMatch"] = 1304] = "scrollSubjectNoMatch";
2312
- PxDiagnosticCode2[PxDiagnosticCode2["scrollNoRootToObserve"] = 1305] = "scrollNoRootToObserve";
2313
- PxDiagnosticCode2[PxDiagnosticCode2["scrollTriggerIgnored"] = 1306] = "scrollTriggerIgnored";
2314
- PxDiagnosticCode2[PxDiagnosticCode2["rateRejected"] = 1401] = "rateRejected";
2315
- PxDiagnosticCode2[PxDiagnosticCode2["controlPropsConflict"] = 1501] = "controlPropsConflict";
2316
- PxDiagnosticCode2[PxDiagnosticCode2["rnCompileFailed"] = 1601] = "rnCompileFailed";
2317
- PxDiagnosticCode2[PxDiagnosticCode2["rnRenderFailed"] = 1602] = "rnRenderFailed";
2318
- PxDiagnosticCode2[PxDiagnosticCode2["rnBoundaryCaught"] = 1603] = "rnBoundaryCaught";
2319
- PxDiagnosticCode2[PxDiagnosticCode2["rnUnsupported"] = 1604] = "rnUnsupported";
2320
- return PxDiagnosticCode2;
2321
- })(PxDiagnosticCode || {});
2322
-
2323
457
  // src/playback/PxAnimatorConfigPatch.ts
2324
458
  var FLAT_ONLY_KEYS = [
2325
459
  "timelineSource",
@@ -2532,6 +666,7 @@ export {
2532
666
  PxTextPathEffectSchema,
2533
667
  PxTextPathMethod,
2534
668
  PxTextPathSpacing,
669
+ PxTimeTimelineSchema,
2535
670
  PxTimelineEngine,
2536
671
  PxTimelineEngineSetting,
2537
672
  PxTimelineSchema,