@molecule/app-feature-video-timeline-angular 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,781 @@
1
+ /**
2
+ * VideoTimeline component (React parity): a multi-track video timeline
3
+ * composing one `<TrackLane>` per track row with a shared time ruler,
4
+ * playhead, zoom slider + Ctrl+wheel zoom, and ripple/insert edit modes.
5
+ *
6
+ * @module
7
+ */
8
+ import { Component, ViewChild } from '@angular/core';
9
+ import { useTranslation } from '@molecule/app-angular';
10
+ import { clipToPixels, pixelsToTime, TrackLane } from '@molecule/app-feature-track-lane-angular';
11
+ import { getClassMap } from '@molecule/app-ui';
12
+ import { clampZoom, computeRippleUpdates, computeRulerTicks, DEFAULT_LANE_HEADER_WIDTH, DEFAULT_PIXELS_PER_SECOND, DEFAULT_RULER_HEIGHT, DEFAULT_TRACK_HEIGHT, DEFAULT_ZOOM_MAX, DEFAULT_ZOOM_MIN, formatTickTime, ZOOM_WHEEL_FACTOR, zoomFromWheelDelta, } from './timeline.js';
13
+ import * as i0 from "@angular/core";
14
+ const _c0 = ["rulerBody"];
15
+ const _c1 = () => [];
16
+ const _forTrack0 = ($index, $item) => $item.time;
17
+ const _forTrack1 = ($index, $item) => $item.id;
18
+ function VideoTimeline_For_15_Template(rf, ctx) { if (rf & 1) {
19
+ i0.ɵɵelementStart(0, "div");
20
+ i0.ɵɵelement(1, "div", 13);
21
+ i0.ɵɵelementStart(2, "span", 14);
22
+ i0.ɵɵtext(3);
23
+ i0.ɵɵelementEnd()();
24
+ } if (rf & 2) {
25
+ const tick_r1 = ctx.$implicit;
26
+ const ctx_r1 = i0.ɵɵnextContext();
27
+ i0.ɵɵadvance();
28
+ i0.ɵɵstyleMap(ctx_r1.tickStyle(tick_r1));
29
+ i0.ɵɵattribute("data-time", tick_r1.time);
30
+ i0.ɵɵadvance();
31
+ i0.ɵɵstyleMap(ctx_r1.tickLabelStyle(tick_r1));
32
+ i0.ɵɵattribute("data-time", tick_r1.time);
33
+ i0.ɵɵadvance();
34
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.tickText(tick_r1), " ");
35
+ } }
36
+ function VideoTimeline_For_20_Template(rf, ctx) { if (rf & 1) {
37
+ i0.ɵɵelementStart(0, "div", 11);
38
+ i0.ɵɵelement(1, "div", 15);
39
+ i0.ɵɵelementEnd();
40
+ } if (rf & 2) {
41
+ const track_r3 = ctx.$implicit;
42
+ const ctx_r1 = i0.ɵɵnextContext();
43
+ i0.ɵɵattribute("data-track-id", track_r3.id)("data-track-kind", track_r3.kind);
44
+ i0.ɵɵadvance();
45
+ i0.ɵɵproperty("name", ctx_r1.laneName(track_r3))("clips", track_r3.clips)("pixelsPerSecond", ctx_r1.safeScale())("height", ctx_r1.trackHeightOf())("lane", track_r3.id)("selectedClipId", ctx_r1.selectedClipId)("onClipMove", ctx_r1.moveFor(track_r3))("onClipResize", ctx_r1.resizeFor(track_r3))("onClipClick", ctx_r1.clickFor(track_r3));
46
+ } }
47
+ /**
48
+ * VideoTimeline component.
49
+ *
50
+ * A multi-track video timeline: one `<TrackLane>` per track row with a shared
51
+ * time ruler at the top, a vertical playhead, and a zoom slider row.
52
+ * Pointer-down on the ruler scrubs `onSeek`; Ctrl+wheel anywhere over the body
53
+ * changes zoom; the slider is keyboard-accessible. All styling routes through
54
+ * `getClassMap()` and all user-visible text routes through `useTranslation()`.
55
+ *
56
+ * The host IS React's root `<div>` (`div[mol-video-timeline]`): `role`, the
57
+ * translated `aria-label`, `data-mol-id` and `data-mode` live on it.
58
+ *
59
+ * In `'ripple'` mode (default), dragging a clip on a lane shifts every
60
+ * subsequent clip on that lane by the same delta — `onClipMove` is called once
61
+ * per affected clip. In `'insert'` mode, only the dragged clip moves.
62
+ */
63
+ export class VideoTimeline {
64
+ /** Tracks to render, in display order. */
65
+ tracks;
66
+ /** Current playhead time in seconds. */
67
+ currentTime;
68
+ /** Total timeline duration in seconds. */
69
+ duration;
70
+ /** Called when the user clicks/scrubs the ruler. */
71
+ onSeek;
72
+ /** Called when a clip on a lane is dragged horizontally. */
73
+ onClipMove;
74
+ /** Called when a clip's right-edge resize handle is dragged. */
75
+ onClipResize;
76
+ /** Horizontal scale (px per second), defaults to 20 (read at render time). */
77
+ pixelsPerSecond;
78
+ /** Lower zoom bound, defaults to 2 (read at render time). */
79
+ zoomMin;
80
+ /** Upper zoom bound, defaults to 200 (read at render time). */
81
+ zoomMax;
82
+ /** Edit mode for clip drags, defaults to `'ripple'` (read at render time). */
83
+ mode;
84
+ /** Called when the user changes the zoom (slider or Ctrl+wheel). */
85
+ onZoomChange;
86
+ /** Optional currently-selected clip id. */
87
+ selectedClipId;
88
+ /** Called when a clip is clicked (no drag). */
89
+ onClipClick;
90
+ /** Per-track row height in pixels, defaults to 44 (read at render time). */
91
+ trackHeight;
92
+ /** Width of the leading lane-header column, defaults to 120 (read at render time). */
93
+ laneHeaderWidth;
94
+ /** Height of the time ruler row, defaults to 28 (read at render time). */
95
+ rulerHeight;
96
+ /** Extra classes merged onto the root element. */
97
+ className;
98
+ /** The i18n state; `t` re-reads the provider on every call and on every locale switch. */
99
+ i18n = useTranslation();
100
+ /** The ruler scrub in progress, or null. */
101
+ seekDrag = null;
102
+ /** The ruler body element, for the pointer-to-time math. */
103
+ rulerBodyRef;
104
+ /**
105
+ * The current class map.
106
+ *
107
+ * @returns The UIClassMap.
108
+ */
109
+ cm() {
110
+ return getClassMap();
111
+ }
112
+ /**
113
+ * The root element's class list (React's root `cm.cn(className)`).
114
+ *
115
+ * @returns The class string.
116
+ */
117
+ rootClasses() {
118
+ return this.cm().cn(this.className);
119
+ }
120
+ /**
121
+ * The controls row's class list.
122
+ *
123
+ * @returns The class string.
124
+ */
125
+ controlsClasses() {
126
+ return this.cm().cn(this.cm().flex({ align: 'center', gap: 'sm' }), this.cm().sp('p', 2));
127
+ }
128
+ /**
129
+ * A zoom button's class list.
130
+ *
131
+ * @returns The class string.
132
+ */
133
+ buttonClasses() {
134
+ return this.cm().cn(this.cm().cursorPointer);
135
+ }
136
+ /**
137
+ * The mode span's visually hidden label class list.
138
+ *
139
+ * @returns The class string.
140
+ */
141
+ srOnlyClasses() {
142
+ return this.cm().cn(this.cm().srOnly);
143
+ }
144
+ /**
145
+ * The duration clamped to >= 0 (React's `safeDuration`).
146
+ * @returns The safe duration.
147
+ */
148
+ safeDuration() {
149
+ return (this.duration ?? 0) > 0 ? this.duration : 0;
150
+ }
151
+ /**
152
+ * The horizontal scale in effect (default 20).
153
+ *
154
+ * @returns Pixels per second.
155
+ */
156
+ scaleOf() {
157
+ return this.pixelsPerSecond ?? DEFAULT_PIXELS_PER_SECOND;
158
+ }
159
+ /**
160
+ * The scale clamped to >= 1 (React's `safeScale`).
161
+ *
162
+ * @returns The safe scale.
163
+ */
164
+ safeScale() {
165
+ return this.scaleOf() > 0 ? this.scaleOf() : 1;
166
+ }
167
+ /**
168
+ * The lower zoom bound in effect (default 2).
169
+ *
170
+ * @returns The lower bound.
171
+ */
172
+ zoomMinOf() {
173
+ return this.zoomMin ?? DEFAULT_ZOOM_MIN;
174
+ }
175
+ /**
176
+ * The upper zoom bound in effect (default 200).
177
+ *
178
+ * @returns The upper bound.
179
+ */
180
+ zoomMaxOf() {
181
+ return this.zoomMax ?? DEFAULT_ZOOM_MAX;
182
+ }
183
+ /**
184
+ * The edit mode in effect (default `'ripple'`).
185
+ *
186
+ * @returns The mode.
187
+ */
188
+ modeOf() {
189
+ return this.mode ?? 'ripple';
190
+ }
191
+ /**
192
+ * The lane row height in effect (default 44).
193
+ *
194
+ * @returns The height in pixels.
195
+ */
196
+ trackHeightOf() {
197
+ return this.trackHeight ?? DEFAULT_TRACK_HEIGHT;
198
+ }
199
+ /**
200
+ * The lane-header column width in effect (default 120).
201
+ *
202
+ * @returns The width in pixels.
203
+ */
204
+ laneHeaderWidthOf() {
205
+ return this.laneHeaderWidth ?? DEFAULT_LANE_HEADER_WIDTH;
206
+ }
207
+ /**
208
+ * The ruler row height in effect (default 28).
209
+ *
210
+ * @returns The height in pixels.
211
+ */
212
+ rulerHeightOf() {
213
+ return this.rulerHeight ?? DEFAULT_RULER_HEIGHT;
214
+ }
215
+ /**
216
+ * The scrollable body's content width in pixels (React's `bodyWidth`).
217
+ *
218
+ * @returns The width in pixels.
219
+ */
220
+ bodyWidth() {
221
+ return Math.max(0, this.safeDuration() * this.safeScale());
222
+ }
223
+ /**
224
+ * The ruler ticks (React's `computeRulerTicks` of the safe duration + scale).
225
+ *
226
+ * @returns The tick descriptors.
227
+ */
228
+ ticks() {
229
+ return computeRulerTicks(this.safeDuration(), this.safeScale());
230
+ }
231
+ /**
232
+ * The playhead's pixel offset on the time axis (React's `playheadPx`).
233
+ *
234
+ * @returns The offset in pixels.
235
+ */
236
+ playheadPx() {
237
+ return clipToPixels({ startTime: this.currentTime ?? 0, duration: 0 }, this.safeScale()).left;
238
+ }
239
+ /**
240
+ * The displayed zoom slider value (React's rounded, clamped scale).
241
+ *
242
+ * @returns The slider value.
243
+ */
244
+ sliderValue() {
245
+ return Math.round(clampZoom(this.safeScale(), this.zoomMinOf(), this.zoomMaxOf()));
246
+ }
247
+ /**
248
+ * The translated ruler label (React's `videoTimeline.aria.ruler`).
249
+ *
250
+ * @returns The translated label.
251
+ */
252
+ rulerLabel() {
253
+ return this.i18n.t('videoTimeline.aria.ruler', {}, { defaultValue: 'Time ruler' });
254
+ }
255
+ /**
256
+ * The translated playhead label (React's `videoTimeline.aria.playhead`).
257
+ *
258
+ * @returns The translated label.
259
+ */
260
+ playheadLabel() {
261
+ return this.i18n.t('videoTimeline.aria.playhead', { time: (this.currentTime ?? 0).toFixed(2) }, { defaultValue: 'Playhead at {{time}}s' });
262
+ }
263
+ /**
264
+ * The translated zoom slider label (React's `videoTimeline.aria.zoom`).
265
+ *
266
+ * @returns The translated label.
267
+ */
268
+ zoomLabel() {
269
+ return this.i18n.t('videoTimeline.aria.zoom', {}, { defaultValue: 'Timeline zoom' });
270
+ }
271
+ /**
272
+ * The translated zoom-in label (React's `videoTimeline.zoom.in`).
273
+ *
274
+ * @returns The translated label.
275
+ */
276
+ zoomInLabel() {
277
+ return this.i18n.t('videoTimeline.zoom.in', {}, { defaultValue: 'Zoom in' });
278
+ }
279
+ /**
280
+ * The translated zoom-out label (React's `videoTimeline.zoom.out`).
281
+ *
282
+ * @returns The translated label.
283
+ */
284
+ zoomOutLabel() {
285
+ return this.i18n.t('videoTimeline.zoom.out', {}, { defaultValue: 'Zoom out' });
286
+ }
287
+ /**
288
+ * The translated mode label (React's `videoTimeline.aria.mode`).
289
+ *
290
+ * @returns The translated label.
291
+ */
292
+ modeLabel() {
293
+ return this.i18n.t('videoTimeline.aria.mode', {}, { defaultValue: 'Edit mode' });
294
+ }
295
+ /**
296
+ * The translated root label (React's `videoTimeline.aria.root`).
297
+ *
298
+ * @returns The translated label.
299
+ */
300
+ rootLabel() {
301
+ return this.i18n.t('videoTimeline.aria.root', {}, { defaultValue: 'Video timeline' });
302
+ }
303
+ /**
304
+ * The visible mode text (React's ripple/insert branch).
305
+ *
306
+ * @returns The translated mode text.
307
+ */
308
+ modeText() {
309
+ return this.modeOf() === 'ripple'
310
+ ? this.i18n.t('videoTimeline.mode.ripple', {}, { defaultValue: 'Ripple' })
311
+ : this.i18n.t('videoTimeline.mode.insert', {}, { defaultValue: 'Insert' });
312
+ }
313
+ /**
314
+ * The translated zoom-out glyph (React's `videoTimeline.zoom.out.icon`).
315
+ *
316
+ * @returns The translated glyph.
317
+ */
318
+ zoomOutIcon() {
319
+ return this.i18n.t('videoTimeline.zoom.out.icon', {}, { defaultValue: '−' });
320
+ }
321
+ /**
322
+ * The translated zoom-in glyph (React's `videoTimeline.zoom.in.icon`).
323
+ *
324
+ * @returns The translated glyph.
325
+ */
326
+ zoomInIcon() {
327
+ return this.i18n.t('videoTimeline.zoom.in.icon', {}, { defaultValue: '+' });
328
+ }
329
+ /**
330
+ * The translated label of one track kind (React's `trackKindLabel`).
331
+ *
332
+ * @param kind - The track kind.
333
+ * @returns The translated kind label.
334
+ */
335
+ trackKindLabel(kind) {
336
+ switch (kind) {
337
+ case 'video':
338
+ return this.i18n.t('videoTimeline.trackKind.video', {}, { defaultValue: 'Video' });
339
+ case 'audio':
340
+ return this.i18n.t('videoTimeline.trackKind.audio', {}, { defaultValue: 'Audio' });
341
+ case 'subtitle':
342
+ return this.i18n.t('videoTimeline.trackKind.subtitle', {}, { defaultValue: 'Subtitle' });
343
+ }
344
+ }
345
+ /**
346
+ * The lane name React passes to `<TrackLane>`: the track's name, or the
347
+ * translated kind label.
348
+ *
349
+ * @param track - The track row.
350
+ * @returns The lane name.
351
+ */
352
+ laneName(track) {
353
+ return track.name ?? this.trackKindLabel(track.kind);
354
+ }
355
+ /**
356
+ * The `onClipMove` handler of one track's lane: forwards through the
357
+ * ripple fan-out with the track id.
358
+ *
359
+ * @param track - The track row.
360
+ * @returns The lane handler.
361
+ */
362
+ moveFor(track) {
363
+ return (clipId, startTime) => this.handleClipMove(track.id, clipId, startTime);
364
+ }
365
+ /**
366
+ * The `onClipResize` handler of one track's lane: forwards with the track id.
367
+ *
368
+ * @param track - The track row.
369
+ * @returns The lane handler.
370
+ */
371
+ resizeFor(track) {
372
+ return (clipId, clipDuration) => this.onClipResize?.(clipId, clipDuration, track.id);
373
+ }
374
+ /**
375
+ * The `onClipClick` handler of one track's lane: forwards with the track id.
376
+ *
377
+ * @param track - The track row.
378
+ * @returns The lane handler.
379
+ */
380
+ clickFor(track) {
381
+ return (clipId) => this.onClipClick?.(clipId, track.id);
382
+ }
383
+ /**
384
+ * Convert a pointer's clientX (relative to the ruler body) to a time
385
+ * value, clamped into `[0, duration]`.
386
+ *
387
+ * @param clientX - Pointer clientX in viewport coordinates.
388
+ * @returns The seek time in seconds.
389
+ */
390
+ clientXToTime(clientX) {
391
+ const el = this.rulerBodyRef?.nativeElement;
392
+ if (!el)
393
+ return 0;
394
+ const rect = el.getBoundingClientRect();
395
+ const px = clientX - rect.left;
396
+ const time = pixelsToTime(px, this.safeScale());
397
+ if (time < 0)
398
+ return 0;
399
+ if (time > this.safeDuration())
400
+ return this.safeDuration();
401
+ return time;
402
+ }
403
+ /**
404
+ * Begin a ruler scrub. Subsequent pointermove events while the pointer
405
+ * is captured will continue to fire `onSeek`.
406
+ *
407
+ * @param event - The pointer event from the ruler body.
408
+ */
409
+ onRulerPointerDown(event) {
410
+ if (event.button !== undefined && event.button !== 0)
411
+ return;
412
+ if (!this.onSeek)
413
+ return;
414
+ this.seekDrag = { pointerId: event.pointerId };
415
+ try {
416
+ ;
417
+ event.currentTarget.setPointerCapture(event.pointerId);
418
+ }
419
+ catch (_error) {
420
+ // jsdom doesn't always implement setPointerCapture; ignore.
421
+ }
422
+ this.onSeek(this.clientXToTime(event.clientX));
423
+ }
424
+ /**
425
+ * Continue a ruler scrub.
426
+ *
427
+ * @param event - The pointer event from the ruler body.
428
+ */
429
+ onRulerPointerMove(event) {
430
+ const drag = this.seekDrag;
431
+ if (!drag || drag.pointerId !== event.pointerId)
432
+ return;
433
+ this.onSeek?.(this.clientXToTime(event.clientX));
434
+ }
435
+ /**
436
+ * Finish a ruler scrub.
437
+ *
438
+ * @param event - The pointer event from the ruler body.
439
+ */
440
+ onRulerPointerUp(event) {
441
+ const drag = this.seekDrag;
442
+ if (!drag || drag.pointerId !== event.pointerId)
443
+ return;
444
+ this.seekDrag = null;
445
+ try {
446
+ ;
447
+ event.currentTarget.releasePointerCapture(event.pointerId);
448
+ }
449
+ catch (_error) {
450
+ // releasePointerCapture may throw in jsdom/headless; pointer state already cleared above.
451
+ }
452
+ }
453
+ /**
454
+ * Handle Ctrl+wheel zoom. Plain wheel scrolls the body; Ctrl+wheel
455
+ * (or pinch-zoom on macOS, which surfaces as ctrlKey) zooms.
456
+ *
457
+ * @param event - The wheel event from the tracks area.
458
+ */
459
+ onBodyWheel(event) {
460
+ if (!event.ctrlKey)
461
+ return;
462
+ if (!this.onZoomChange)
463
+ return;
464
+ event.preventDefault();
465
+ const next = zoomFromWheelDelta(this.safeScale(), event.deltaY, this.zoomMinOf(), this.zoomMaxOf());
466
+ if (next !== this.safeScale())
467
+ this.onZoomChange(next);
468
+ }
469
+ /**
470
+ * Forward a track-lane clip move to `onClipMove`, fanning out via
471
+ * `computeRippleUpdates` when in `'ripple'` mode.
472
+ *
473
+ * @param trackId - The track id forwarded as the lane id.
474
+ * @param clipId - The id of the dragged clip.
475
+ * @param proposedStartTime - The candidate new `startTime`.
476
+ */
477
+ handleClipMove(trackId, clipId, proposedStartTime) {
478
+ if (!this.onClipMove)
479
+ return;
480
+ const track = (this.tracks ?? []).find((tr) => tr.id === trackId);
481
+ if (!track) {
482
+ this.onClipMove(clipId, proposedStartTime, trackId);
483
+ return;
484
+ }
485
+ if (this.modeOf() === 'insert') {
486
+ this.onClipMove(clipId, proposedStartTime, trackId);
487
+ return;
488
+ }
489
+ const updates = computeRippleUpdates(track.clips, clipId, proposedStartTime);
490
+ for (const u of updates)
491
+ this.onClipMove(u.id, u.startTime, trackId);
492
+ }
493
+ /**
494
+ * The zoom-out button's handler: `onZoomChange` with the scale divided by
495
+ * the wheel factor, clamped.
496
+ */
497
+ zoomOut() {
498
+ this.onZoomChange?.(clampZoom(this.safeScale() / ZOOM_WHEEL_FACTOR, this.zoomMinOf(), this.zoomMaxOf()));
499
+ }
500
+ /**
501
+ * The zoom-in button's handler: `onZoomChange` with the scale times the
502
+ * wheel factor, clamped.
503
+ */
504
+ zoomIn() {
505
+ this.onZoomChange?.(clampZoom(this.safeScale() * ZOOM_WHEEL_FACTOR, this.zoomMinOf(), this.zoomMaxOf()));
506
+ }
507
+ /**
508
+ * The zoom slider's `input` handler: emits the clamped value, then
509
+ * applies React's controlled-input restore (the DOM value returns to
510
+ * the prop).
511
+ *
512
+ * @param event - The native input event.
513
+ */
514
+ handleZoomInput(event) {
515
+ const element = event.target;
516
+ this.onZoomChange?.(clampZoom(Number(element.value), this.zoomMinOf(), this.zoomMaxOf()));
517
+ element.value = String(this.sliderValue());
518
+ }
519
+ /**
520
+ * The ruler row's inline geometry (React's `rulerRowStyle`).
521
+ *
522
+ * @returns The style declarations.
523
+ */
524
+ rulerRowStyle() {
525
+ const height = this.rulerHeightOf();
526
+ return [
527
+ 'display: flex',
528
+ 'align-items: stretch',
529
+ `height: ${height}px`,
530
+ `min-height: ${height}px`,
531
+ 'position: relative',
532
+ ].join('; ');
533
+ }
534
+ /**
535
+ * The ruler header's inline geometry (React's `rulerHeaderStyle`).
536
+ *
537
+ * @returns The style declarations.
538
+ */
539
+ rulerHeaderStyle() {
540
+ const width = this.laneHeaderWidthOf();
541
+ return ['box-sizing: border-box', `min-width: ${width}px`, `width: ${width}px`].join('; ');
542
+ }
543
+ /**
544
+ * The ruler body's inline geometry (React's `rulerBodyStyle`).
545
+ *
546
+ * @returns The style declarations.
547
+ */
548
+ rulerBodyStyle() {
549
+ return [
550
+ 'cursor: ' + (this.onSeek ? 'pointer' : 'default'),
551
+ 'flex: 1 1 auto',
552
+ `height: ${this.rulerHeightOf()}px`,
553
+ `min-width: ${this.bodyWidth()}px`,
554
+ 'overflow: hidden',
555
+ 'position: relative',
556
+ 'touch-action: none',
557
+ ].join('; ');
558
+ }
559
+ /**
560
+ * One tick's inline geometry (React's `tickStyle`).
561
+ *
562
+ * @param tick - The tick descriptor.
563
+ * @returns The style declarations.
564
+ */
565
+ tickStyle(tick) {
566
+ return [
567
+ 'background: var(--mol-video-timeline-tick, rgba(127, 127, 127, 0.5))',
568
+ 'bottom: 0px',
569
+ `left: ${tick.pixel}px`,
570
+ 'pointer-events: none',
571
+ 'position: absolute',
572
+ 'top: 0px',
573
+ 'width: 1px',
574
+ ].join('; ');
575
+ }
576
+ /**
577
+ * One tick label's inline geometry (React's `labelStyle`).
578
+ *
579
+ * @param tick - The tick descriptor.
580
+ * @returns The style declarations.
581
+ */
582
+ tickLabelStyle(tick) {
583
+ return [
584
+ `left: ${tick.pixel + 2}px`,
585
+ 'font-size: 10px',
586
+ 'pointer-events: none',
587
+ 'position: absolute',
588
+ 'top: 2px',
589
+ ].join('; ');
590
+ }
591
+ /**
592
+ * One tick label's text (React's `formatTickTime`).
593
+ *
594
+ * @param tick - The tick descriptor.
595
+ * @returns The formatted tick time.
596
+ */
597
+ tickText(tick) {
598
+ return formatTickTime(tick.time);
599
+ }
600
+ /**
601
+ * The in-ruler playhead's inline geometry (React's `playheadInRulerStyle`).
602
+ *
603
+ * @returns The style declarations.
604
+ */
605
+ playheadInRulerStyle() {
606
+ return ['left: ' + this.playheadPx() + 'px', this.playheadSharedStyle()].join('; ');
607
+ }
608
+ /**
609
+ * The tracks-area playhead's inline geometry (React's `playheadStyle`).
610
+ *
611
+ * @returns The style declarations.
612
+ */
613
+ playheadStyle() {
614
+ return [
615
+ 'left: ' + (this.playheadPx() + this.laneHeaderWidthOf()) + 'px',
616
+ 'z-index: 2',
617
+ this.playheadSharedStyle(),
618
+ ].join('; ');
619
+ }
620
+ /**
621
+ * The playhead's shared inline geometry (position + fill).
622
+ *
623
+ * @returns The style declarations.
624
+ */
625
+ playheadSharedStyle() {
626
+ return [
627
+ 'background: var(--mol-video-timeline-playhead, #ff3b30)',
628
+ 'bottom: 0px',
629
+ 'pointer-events: none',
630
+ 'position: absolute',
631
+ 'top: 0px',
632
+ 'width: 2px',
633
+ ].join('; ');
634
+ }
635
+ /**
636
+ * The tracks area's inline geometry (React's `tracksScrollStyle`).
637
+ *
638
+ * @returns The style declarations.
639
+ */
640
+ tracksScrollStyle() {
641
+ return ['overflow-x: auto', 'overflow-y: auto', 'position: relative', 'width: 100%'].join('; ');
642
+ }
643
+ /**
644
+ * The tracks' inner div's inline geometry (React's `tracksInnerStyle`).
645
+ *
646
+ * @returns The style declarations.
647
+ */
648
+ tracksInnerStyle() {
649
+ return [
650
+ 'position: relative',
651
+ `min-width: ${this.bodyWidth() + this.laneHeaderWidthOf()}px`,
652
+ ].join('; ');
653
+ }
654
+ /** Clears the scrub state, as React's unmount drops the ref. */
655
+ ngOnDestroy() {
656
+ this.seekDrag = null;
657
+ }
658
+ static ɵfac = function VideoTimeline_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || VideoTimeline)(); };
659
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VideoTimeline, selectors: [["div", "mol-video-timeline", ""]], viewQuery: function VideoTimeline_Query(rf, ctx) { if (rf & 1) {
660
+ i0.ɵɵviewQuery(_c0, 5);
661
+ } if (rf & 2) {
662
+ let _t;
663
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rulerBodyRef = _t.first);
664
+ } }, hostAttrs: ["role", "group", "data-mol-id", "video-timeline"], hostVars: 8, hostBindings: function VideoTimeline_HostBindings(rf, ctx) { if (rf & 2) {
665
+ i0.ɵɵattribute("aria-label", ctx.rootLabel())("data-mode", ctx.modeOf());
666
+ i0.ɵɵclassMap(ctx.rootClasses());
667
+ i0.ɵɵstyleProp("width", "100%")("overflow", "hidden");
668
+ } }, inputs: { tracks: "tracks", currentTime: "currentTime", duration: "duration", onSeek: "onSeek", onClipMove: "onClipMove", onClipResize: "onClipResize", pixelsPerSecond: "pixelsPerSecond", zoomMin: "zoomMin", zoomMax: "zoomMax", mode: "mode", onZoomChange: "onZoomChange", selectedClipId: "selectedClipId", onClipClick: "onClipClick", trackHeight: "trackHeight", laneHeaderWidth: "laneHeaderWidth", rulerHeight: "rulerHeight", className: "className" }, decls: 22, vars: 37, consts: [["rulerBody", ""], ["data-mol-id", "video-timeline-controls"], ["data-mol-id", "video-timeline-mode"], ["type", "button", "data-mol-id", "video-timeline-zoom-out", 3, "click"], ["type", "range", "data-mol-id", "video-timeline-zoom-slider", "step", "1", 3, "input"], ["type", "button", "data-mol-id", "video-timeline-zoom-in", 3, "click"], ["data-mol-id", "video-timeline-ruler-row"], ["data-mol-id", "video-timeline-ruler-header"], ["role", "slider", "tabindex", "0", "aria-valuemin", "0", "data-mol-id", "video-timeline-ruler", 3, "pointerdown", "pointermove", "pointerup", "pointercancel"], ["data-mol-id", "video-timeline-playhead-ruler", "aria-hidden", "true"], ["data-mol-id", "video-timeline-tracks", 3, "wheel"], ["data-mol-id", "video-timeline-track"], ["data-mol-id", "video-timeline-playhead", "aria-hidden", "true"], ["data-mol-id", "video-timeline-tick"], ["data-mol-id", "video-timeline-tick-label"], ["mol-track-lane", "", 3, "name", "clips", "pixelsPerSecond", "height", "lane", "selectedClipId", "onClipMove", "onClipResize", "onClipClick"]], template: function VideoTimeline_Template(rf, ctx) { if (rf & 1) {
669
+ i0.ɵɵelementStart(0, "div", 1)(1, "span", 2)(2, "span");
670
+ i0.ɵɵtext(3);
671
+ i0.ɵɵelementEnd();
672
+ i0.ɵɵtext(4);
673
+ i0.ɵɵelementEnd();
674
+ i0.ɵɵelementStart(5, "button", 3);
675
+ i0.ɵɵlistener("click", function VideoTimeline_Template_button_click_5_listener() { return ctx.zoomOut(); });
676
+ i0.ɵɵtext(6);
677
+ i0.ɵɵelementEnd();
678
+ i0.ɵɵelementStart(7, "input", 4);
679
+ i0.ɵɵlistener("input", function VideoTimeline_Template_input_input_7_listener($event) { return ctx.handleZoomInput($event); });
680
+ i0.ɵɵelementEnd();
681
+ i0.ɵɵelementStart(8, "button", 5);
682
+ i0.ɵɵlistener("click", function VideoTimeline_Template_button_click_8_listener() { return ctx.zoomIn(); });
683
+ i0.ɵɵtext(9);
684
+ i0.ɵɵelementEnd()();
685
+ i0.ɵɵelementStart(10, "div", 6);
686
+ i0.ɵɵelement(11, "div", 7);
687
+ i0.ɵɵelementStart(12, "div", 8, 0);
688
+ i0.ɵɵlistener("pointerdown", function VideoTimeline_Template_div_pointerdown_12_listener($event) { return ctx.onRulerPointerDown($event); })("pointermove", function VideoTimeline_Template_div_pointermove_12_listener($event) { return ctx.onRulerPointerMove($event); })("pointerup", function VideoTimeline_Template_div_pointerup_12_listener($event) { return ctx.onRulerPointerUp($event); })("pointercancel", function VideoTimeline_Template_div_pointercancel_12_listener($event) { return ctx.onRulerPointerUp($event); });
689
+ i0.ɵɵrepeaterCreate(14, VideoTimeline_For_15_Template, 4, 7, "div", null, _forTrack0);
690
+ i0.ɵɵelement(16, "div", 9);
691
+ i0.ɵɵelementEnd()();
692
+ i0.ɵɵelementStart(17, "div", 10);
693
+ i0.ɵɵlistener("wheel", function VideoTimeline_Template_div_wheel_17_listener($event) { return ctx.onBodyWheel($event); });
694
+ i0.ɵɵelementStart(18, "div");
695
+ i0.ɵɵrepeaterCreate(19, VideoTimeline_For_20_Template, 2, 11, "div", 11, _forTrack1);
696
+ i0.ɵɵelement(21, "div", 12);
697
+ i0.ɵɵelementEnd()();
698
+ } if (rf & 2) {
699
+ i0.ɵɵclassMap(ctx.controlsClasses());
700
+ i0.ɵɵadvance(2);
701
+ i0.ɵɵclassMap(ctx.srOnlyClasses());
702
+ i0.ɵɵadvance();
703
+ i0.ɵɵtextInterpolate(ctx.modeLabel());
704
+ i0.ɵɵadvance();
705
+ i0.ɵɵtextInterpolate(ctx.modeText());
706
+ i0.ɵɵadvance();
707
+ i0.ɵɵclassMap(ctx.buttonClasses());
708
+ i0.ɵɵattribute("aria-label", ctx.zoomOutLabel());
709
+ i0.ɵɵadvance();
710
+ i0.ɵɵtextInterpolate1(" ", ctx.zoomOutIcon(), " ");
711
+ i0.ɵɵadvance();
712
+ i0.ɵɵattribute("aria-label", ctx.zoomLabel())("min", ctx.zoomMinOf())("max", ctx.zoomMaxOf())("value", ctx.sliderValue());
713
+ i0.ɵɵadvance();
714
+ i0.ɵɵclassMap(ctx.buttonClasses());
715
+ i0.ɵɵattribute("aria-label", ctx.zoomInLabel());
716
+ i0.ɵɵadvance();
717
+ i0.ɵɵtextInterpolate1(" ", ctx.zoomInIcon(), " ");
718
+ i0.ɵɵadvance();
719
+ i0.ɵɵstyleMap(ctx.rulerRowStyle());
720
+ i0.ɵɵadvance();
721
+ i0.ɵɵstyleMap(ctx.rulerHeaderStyle());
722
+ i0.ɵɵadvance();
723
+ i0.ɵɵstyleMap(ctx.rulerBodyStyle());
724
+ i0.ɵɵattribute("aria-label", ctx.rulerLabel())("aria-valuemax", ctx.safeDuration())("aria-valuenow", ctx.currentTime ?? null)("aria-valuetext", ctx.playheadLabel());
725
+ i0.ɵɵadvance(2);
726
+ i0.ɵɵrepeater(ctx.ticks());
727
+ i0.ɵɵadvance(2);
728
+ i0.ɵɵstyleMap(ctx.playheadInRulerStyle());
729
+ i0.ɵɵadvance();
730
+ i0.ɵɵstyleMap(ctx.tracksScrollStyle());
731
+ i0.ɵɵadvance();
732
+ i0.ɵɵstyleMap(ctx.tracksInnerStyle());
733
+ i0.ɵɵadvance();
734
+ i0.ɵɵrepeater(ctx.tracks ?? i0.ɵɵpureFunction0(36, _c1));
735
+ i0.ɵɵadvance(2);
736
+ i0.ɵɵstyleMap(ctx.playheadStyle());
737
+ } }, dependencies: [TrackLane], encapsulation: 2 });
738
+ }
739
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VideoTimeline, [{
740
+ type: Component,
741
+ args: [{
742
+ selector: 'div[mol-video-timeline]',
743
+ standalone: true,
744
+ imports: [TrackLane],
745
+ inputs: [
746
+ 'tracks',
747
+ 'currentTime',
748
+ 'duration',
749
+ 'onSeek',
750
+ 'onClipMove',
751
+ 'onClipResize',
752
+ 'pixelsPerSecond',
753
+ 'zoomMin',
754
+ 'zoomMax',
755
+ 'mode',
756
+ 'onZoomChange',
757
+ 'selectedClipId',
758
+ 'onClipClick',
759
+ 'trackHeight',
760
+ 'laneHeaderWidth',
761
+ 'rulerHeight',
762
+ 'className',
763
+ ],
764
+ host: {
765
+ role: 'group',
766
+ 'data-mol-id': 'video-timeline',
767
+ '[attr.aria-label]': 'rootLabel()',
768
+ '[attr.data-mode]': 'modeOf()',
769
+ '[class]': 'rootClasses()',
770
+ '[style.width]': `'100%'`,
771
+ '[style.overflow]': `'hidden'`,
772
+ },
773
+ // prettier-ignore
774
+ template: `<div data-mol-id="video-timeline-controls" [class]="controlsClasses()"><span data-mol-id="video-timeline-mode"><span [class]="srOnlyClasses()">{{ modeLabel() }}</span>{{ modeText() }}</span><button type="button" data-mol-id="video-timeline-zoom-out" [attr.aria-label]="zoomOutLabel()" [class]="buttonClasses()" (click)="zoomOut()"> {{ zoomOutIcon() }} </button><input type="range" data-mol-id="video-timeline-zoom-slider" [attr.aria-label]="zoomLabel()" [attr.min]="zoomMinOf()" [attr.max]="zoomMaxOf()" step="1" [attr.value]="sliderValue()" (input)="handleZoomInput($event)" /><button type="button" data-mol-id="video-timeline-zoom-in" [attr.aria-label]="zoomInLabel()" [class]="buttonClasses()" (click)="zoomIn()"> {{ zoomInIcon() }} </button></div><div data-mol-id="video-timeline-ruler-row" [style]="rulerRowStyle()"><div data-mol-id="video-timeline-ruler-header" [style]="rulerHeaderStyle()"></div><div #rulerBody role="slider" tabindex="0" [attr.aria-label]="rulerLabel()" aria-valuemin="0" [attr.aria-valuemax]="safeDuration()" [attr.aria-valuenow]="currentTime ?? null" [attr.aria-valuetext]="playheadLabel()" data-mol-id="video-timeline-ruler" [style]="rulerBodyStyle()" (pointerdown)="onRulerPointerDown($event)" (pointermove)="onRulerPointerMove($event)" (pointerup)="onRulerPointerUp($event)" (pointercancel)="onRulerPointerUp($event)">@for (tick of ticks(); track tick.time) {<div><div data-mol-id="video-timeline-tick" [attr.data-time]="tick.time" [style]="tickStyle(tick)"></div><span data-mol-id="video-timeline-tick-label" [attr.data-time]="tick.time" [style]="tickLabelStyle(tick)"> {{ tickText(tick) }} </span></div>}<div data-mol-id="video-timeline-playhead-ruler" aria-hidden="true" [style]="playheadInRulerStyle()"></div></div></div><div data-mol-id="video-timeline-tracks" [style]="tracksScrollStyle()" (wheel)="onBodyWheel($event)"><div [style]="tracksInnerStyle()">@for (track of tracks ?? []; track track.id) {<div data-mol-id="video-timeline-track" [attr.data-track-id]="track.id" [attr.data-track-kind]="track.kind"><div mol-track-lane [name]="laneName(track)" [clips]="track.clips" [pixelsPerSecond]="safeScale()" [height]="trackHeightOf()" [lane]="track.id" [selectedClipId]="selectedClipId" [onClipMove]="moveFor(track)" [onClipResize]="resizeFor(track)" [onClipClick]="clickFor(track)"></div></div>}<div data-mol-id="video-timeline-playhead" aria-hidden="true" [style]="playheadStyle()"></div></div></div>`,
775
+ }]
776
+ }], null, { rulerBodyRef: [{
777
+ type: ViewChild,
778
+ args: ['rulerBody']
779
+ }] }); })();
780
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(VideoTimeline, { className: "VideoTimeline", filePath: "video-timeline.component.ts", lineNumber: 89 }); })();
781
+ //# sourceMappingURL=video-timeline.component.js.map