@editframe/elements 0.5.0-beta.3 → 0.5.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/editor/msToTimeCode.mjs +15 -0
  2. package/dist/editor/util/EncodedAsset/EncodedAsset.mjs +537 -0
  3. package/dist/editor/util/MP4File.mjs +161 -0
  4. package/dist/elements/elements/CrossUpdateController.mjs +16 -0
  5. package/dist/elements/elements/EFAudio.mjs +37 -0
  6. package/dist/elements/elements/EFCaptions.mjs +172 -0
  7. package/dist/elements/elements/EFImage.mjs +67 -0
  8. package/dist/elements/elements/EFMedia.mjs +255 -0
  9. package/dist/elements/elements/EFSourceMixin.mjs +57 -0
  10. package/dist/elements/elements/EFTemporal.mjs +186 -0
  11. package/dist/elements/elements/EFTimegroup.mjs +230 -0
  12. package/dist/elements/elements/EFTimeline.mjs +12 -0
  13. package/dist/elements/elements/EFVideo.mjs +123 -0
  14. package/dist/elements/elements/EFWaveform.mjs +203 -0
  15. package/dist/elements/elements/FetchMixin.mjs +30 -0
  16. package/dist/elements/elements/TimegroupController.mjs +20 -0
  17. package/dist/elements/elements/durationConverter.mjs +8 -0
  18. package/dist/elements/elements/parseTimeToMs.mjs +13 -0
  19. package/dist/elements/elements/util.mjs +11 -0
  20. package/dist/elements/elements.css.mjs +1 -0
  21. package/dist/elements/elements.mjs +11 -0
  22. package/dist/elements/gui/EFFilmstrip.mjs +680 -0
  23. package/dist/elements/gui/EFWorkbench.mjs +234 -0
  24. package/dist/elements/gui/TWMixin.css.mjs +4 -0
  25. package/dist/elements/gui/TWMixin.mjs +27 -0
  26. package/dist/style.css +754 -0
  27. package/dist/util/awaitMicrotask.mjs +8 -0
  28. package/dist/util/memoize.mjs +15 -0
  29. package/package.json +9 -2
  30. package/dist/editframe-elements.css +0 -1
  31. package/dist/editframe-elements.mjs +0 -9089
  32. package/dist/editframe-elements.umd.js +0 -288
@@ -0,0 +1,680 @@
1
+ import { EFTimegroup } from "../elements/EFTimegroup.mjs";
2
+ import { css, html, nothing, LitElement } from "lit";
3
+ import { property, customElement, state, eventOptions } from "lit/decorators.js";
4
+ import { styleMap } from "lit/directives/style-map.js";
5
+ import { createRef, ref } from "lit/directives/ref.js";
6
+ import { EFImage } from "../elements/EFImage.mjs";
7
+ import { EFAudio } from "../elements/EFAudio.mjs";
8
+ import { EFVideo } from "../elements/EFVideo.mjs";
9
+ import { EFCaptions, EFCaptionsActiveWord } from "../elements/EFCaptions.mjs";
10
+ import { EFWaveform } from "../elements/EFWaveform.mjs";
11
+ import { TimegroupController } from "../elements/TimegroupController.mjs";
12
+ import { consume } from "@lit/context";
13
+ import { focusContext, focusedElement } from "./EFWorkbench.mjs";
14
+ import { TWMixin } from "./TWMixin.mjs";
15
+ import { msToTimeCode } from "../../editor/msToTimeCode.mjs";
16
+ var __defProp = Object.defineProperty;
17
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
18
+ var __decorateClass = (decorators, target, key, kind) => {
19
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
+ if (decorator = decorators[i])
22
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
+ if (kind && result)
24
+ __defProp(target, key, result);
25
+ return result;
26
+ };
27
+ var __accessCheck = (obj, member, msg) => {
28
+ if (!member.has(obj))
29
+ throw TypeError("Cannot " + msg);
30
+ };
31
+ var __privateGet = (obj, member, getter) => {
32
+ __accessCheck(obj, member, "read from private field");
33
+ return getter ? getter.call(obj) : member.get(obj);
34
+ };
35
+ var __privateAdd = (obj, member, value) => {
36
+ if (member.has(obj))
37
+ throw TypeError("Cannot add the same private member more than once");
38
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
39
+ };
40
+ var __privateSet = (obj, member, value, setter) => {
41
+ __accessCheck(obj, member, "write to private field");
42
+ setter ? setter.call(obj, value) : member.set(obj, value);
43
+ return value;
44
+ };
45
+ var _lastTick;
46
+ class ElementFilmstripController {
47
+ constructor(host, filmstrip) {
48
+ this.host = host;
49
+ this.filmstrip = filmstrip;
50
+ this.host.addController(this);
51
+ }
52
+ remove() {
53
+ this.host.removeController(this);
54
+ }
55
+ hostDisconnected() {
56
+ this.host.removeController(this);
57
+ }
58
+ hostUpdated() {
59
+ this.filmstrip.requestUpdate();
60
+ }
61
+ }
62
+ const CommonEffectKeys = /* @__PURE__ */ new Set([
63
+ "offset",
64
+ "easing",
65
+ "composite",
66
+ "computedOffset"
67
+ ]);
68
+ class FilmstripItem extends TWMixin(LitElement) {
69
+ constructor() {
70
+ super(...arguments);
71
+ this.element = new EFTimegroup();
72
+ this.pixelsPerMs = 0.04;
73
+ }
74
+ static {
75
+ this.styles = [
76
+ css`
77
+ :host {
78
+ display: block;
79
+ }
80
+ `
81
+ ];
82
+ }
83
+ get isFocused() {
84
+ return this.element && this.focusedElement === this.element;
85
+ }
86
+ get styles() {
87
+ return {
88
+ left: `${this.pixelsPerMs * this.element.startTimeMs}px`,
89
+ width: `${this.pixelsPerMs * this.element.durationMs}px`
90
+ };
91
+ }
92
+ render() {
93
+ return html` <div class="" style=${styleMap(this.styles)}>
94
+ <div
95
+ @mouseenter=${() => {
96
+ if (this.focusContext) {
97
+ this.focusContext.focusedElement = this.element;
98
+ }
99
+ }}
100
+ @mouseleave=${() => {
101
+ if (this.focusContext) {
102
+ this.focusContext.focusedElement = null;
103
+ }
104
+ }}
105
+ ?data-focused=${this.isFocused}
106
+ class="border-outset relative mb-[1px] block h-[1.25rem] text-nowrap border border-slate-500 bg-blue-200 text-sm data-[focused]:bg-slate-400"
107
+ >
108
+ ${this.animations()}
109
+ </div>
110
+ ${this.renderChildren()}
111
+ </div>`;
112
+ }
113
+ renderChildren() {
114
+ return renderFilmStripChildren(
115
+ Array.from(this.element.children),
116
+ this.pixelsPerMs
117
+ );
118
+ }
119
+ contents() {
120
+ return html``;
121
+ }
122
+ animations() {
123
+ const animations = this.element.getAnimations();
124
+ return animations.map((animation) => {
125
+ const effect = animation.effect;
126
+ if (!(effect instanceof KeyframeEffect)) {
127
+ return nothing;
128
+ }
129
+ const start = effect.getTiming().delay ?? 0;
130
+ const duration = effect.getTiming().duration;
131
+ if (duration === null) {
132
+ return nothing;
133
+ }
134
+ const keyframes = effect.getKeyframes();
135
+ const firstKeyframe = keyframes[0];
136
+ if (!firstKeyframe) {
137
+ return nothing;
138
+ }
139
+ const properties = new Set(Object.keys(firstKeyframe));
140
+ CommonEffectKeys.forEach((key) => properties.delete(key));
141
+ return html`<div
142
+ class="relative h-[5px] bg-blue-500 opacity-50"
143
+ label="animation"
144
+ style=${styleMap({
145
+ left: `${this.pixelsPerMs * start}px`,
146
+ width: `${this.pixelsPerMs * Number(duration)}px`
147
+ })}
148
+ >
149
+ <!-- <div class="text-nowrap">${Array.from(properties).join(
150
+ " "
151
+ )}</div> -->
152
+ ${effect.getKeyframes().map((keyframe) => {
153
+ return html`<div
154
+ class="absolute top-0 h-full w-1 bg-red-500"
155
+ style=${styleMap({
156
+ left: `${this.pixelsPerMs * keyframe.computedOffset * Number(duration)}px`
157
+ })}
158
+ ></div>`;
159
+ })}
160
+ </div>`;
161
+ });
162
+ }
163
+ update(changedProperties) {
164
+ if (changedProperties.has("element") && this.element instanceof LitElement) {
165
+ this.filmstripController?.remove();
166
+ this.filmstripController = new ElementFilmstripController(
167
+ this.element,
168
+ this
169
+ );
170
+ }
171
+ super.update(changedProperties);
172
+ }
173
+ }
174
+ __decorateClass([
175
+ consume({ context: focusContext })
176
+ ], FilmstripItem.prototype, "focusContext", 2);
177
+ __decorateClass([
178
+ consume({ context: focusedElement, subscribe: true })
179
+ ], FilmstripItem.prototype, "focusedElement", 2);
180
+ __decorateClass([
181
+ property({ type: HTMLElement, attribute: false })
182
+ ], FilmstripItem.prototype, "element", 2);
183
+ __decorateClass([
184
+ property({ type: Number })
185
+ ], FilmstripItem.prototype, "pixelsPerMs", 2);
186
+ let EFAudioFilmstrip = class extends FilmstripItem {
187
+ contents() {
188
+ return html``;
189
+ }
190
+ };
191
+ EFAudioFilmstrip = __decorateClass([
192
+ customElement("ef-audio-filmstrip")
193
+ ], EFAudioFilmstrip);
194
+ let EFVideoFilmstrip = class extends FilmstripItem {
195
+ contents() {
196
+ return html` 📼 `;
197
+ }
198
+ };
199
+ EFVideoFilmstrip = __decorateClass([
200
+ customElement("ef-video-filmstrip")
201
+ ], EFVideoFilmstrip);
202
+ let EFCaptionsFilmstrip = class extends FilmstripItem {
203
+ contents() {
204
+ return html` 📝 `;
205
+ }
206
+ };
207
+ EFCaptionsFilmstrip = __decorateClass([
208
+ customElement("ef-captions-filmstrip")
209
+ ], EFCaptionsFilmstrip);
210
+ let EFWaveformFilmstrip = class extends FilmstripItem {
211
+ contents() {
212
+ return html` 🌊 `;
213
+ }
214
+ renderChildren() {
215
+ return nothing;
216
+ }
217
+ };
218
+ EFWaveformFilmstrip = __decorateClass([
219
+ customElement("ef-waveform-filmstrip")
220
+ ], EFWaveformFilmstrip);
221
+ let EFImageFilmstrip = class extends FilmstripItem {
222
+ contents() {
223
+ return html` 🖼️ `;
224
+ }
225
+ };
226
+ EFImageFilmstrip = __decorateClass([
227
+ customElement("ef-image-filmstrip")
228
+ ], EFImageFilmstrip);
229
+ let EFTimegroupFilmstrip = class extends FilmstripItem {
230
+ contents() {
231
+ return html`
232
+ <span>TIME GROUP</span>
233
+ ${renderFilmStripChildren(
234
+ Array.from(this.element.children || []),
235
+ this.pixelsPerMs
236
+ )}
237
+ </div>
238
+ `;
239
+ }
240
+ };
241
+ EFTimegroupFilmstrip = __decorateClass([
242
+ customElement("ef-timegroup-filmstrip")
243
+ ], EFTimegroupFilmstrip);
244
+ let EFHTMLFilmstrip = class extends FilmstripItem {
245
+ contents() {
246
+ return html`
247
+ <span>${this.element.tagName}</span>
248
+ ${renderFilmStripChildren(
249
+ Array.from(this.element.children || []),
250
+ this.pixelsPerMs
251
+ )}
252
+ `;
253
+ }
254
+ };
255
+ EFHTMLFilmstrip = __decorateClass([
256
+ customElement("ef-html-filmstrip")
257
+ ], EFHTMLFilmstrip);
258
+ let EFHierarchyItem = class extends TWMixin(LitElement) {
259
+ constructor() {
260
+ super(...arguments);
261
+ this.element = new EFTimegroup();
262
+ }
263
+ get icon() {
264
+ return "📼";
265
+ }
266
+ get isFocused() {
267
+ return this.element && this.focusedElement === this.element;
268
+ }
269
+ displayLabel() {
270
+ return nothing;
271
+ }
272
+ render() {
273
+ return html`
274
+ <div>
275
+ <div
276
+ ?data-focused=${this.isFocused}
277
+ class="peer
278
+ flex h-[1.25rem] items-center overflow-hidden text-nowrap border border-slate-500
279
+ bg-slate-200 pl-2 text-sm hover:bg-slate-400 data-[focused]:bg-slate-400"
280
+ @mouseenter=${() => {
281
+ if (this.focusContext) {
282
+ this.focusContext.focusedElement = this.element;
283
+ }
284
+ }}
285
+ @mouseleave=${() => {
286
+ if (this.focusContext) {
287
+ this.focusContext.focusedElement = null;
288
+ }
289
+ }}
290
+ >
291
+ ${this.icon} ${this.displayLabel()}
292
+ </div>
293
+ <div
294
+ class="p-[1px] pb-0 pl-2 pr-0 peer-hover:bg-slate-300 peer-data-[focused]:bg-slate-300 peer-hover:border-slate-400 peer-data-[focused]:border-slate-400""
295
+ >
296
+ ${this.renderChildren()}
297
+ </div>
298
+ </div>`;
299
+ }
300
+ renderChildren() {
301
+ return renderHierarchyChildren(Array.from(this.element.children));
302
+ }
303
+ };
304
+ __decorateClass([
305
+ property({ type: HTMLElement, attribute: false })
306
+ ], EFHierarchyItem.prototype, "element", 2);
307
+ __decorateClass([
308
+ consume({ context: focusContext })
309
+ ], EFHierarchyItem.prototype, "focusContext", 2);
310
+ __decorateClass([
311
+ consume({ context: focusedElement, subscribe: true })
312
+ ], EFHierarchyItem.prototype, "focusedElement", 2);
313
+ EFHierarchyItem = __decorateClass([
314
+ customElement("ef-hierarchy-item")
315
+ ], EFHierarchyItem);
316
+ let EFTimegroupHierarchyItem = class extends EFHierarchyItem {
317
+ get icon() {
318
+ return "🕒";
319
+ }
320
+ displayLabel() {
321
+ return this.element.mode ?? "(no mode)";
322
+ }
323
+ };
324
+ EFTimegroupHierarchyItem = __decorateClass([
325
+ customElement("ef-timegroup-hierarchy-item")
326
+ ], EFTimegroupHierarchyItem);
327
+ let EFAudioHierarchyItem = class extends EFHierarchyItem {
328
+ get icon() {
329
+ return "🔊";
330
+ }
331
+ displayLabel() {
332
+ return this.element.getAttribute("src") ?? "(no src)";
333
+ }
334
+ };
335
+ EFAudioHierarchyItem = __decorateClass([
336
+ customElement("ef-audio-hierarchy-item")
337
+ ], EFAudioHierarchyItem);
338
+ let EFVideoHierarchyItem = class extends EFHierarchyItem {
339
+ get icon() {
340
+ return "📼";
341
+ }
342
+ displayLabel() {
343
+ return this.element.getAttribute("src") ?? "(no src)";
344
+ }
345
+ };
346
+ EFVideoHierarchyItem = __decorateClass([
347
+ customElement("ef-video-hierarchy-item")
348
+ ], EFVideoHierarchyItem);
349
+ let EFCaptionsHierarchyItem = class extends EFHierarchyItem {
350
+ get icon() {
351
+ return "📝 Captions";
352
+ }
353
+ };
354
+ EFCaptionsHierarchyItem = __decorateClass([
355
+ customElement("ef-captions-hierarchy-item")
356
+ ], EFCaptionsHierarchyItem);
357
+ let EFCaptionsActiveWordHierarchyItem = class extends EFHierarchyItem {
358
+ get icon() {
359
+ return "🗣️ Active Word";
360
+ }
361
+ };
362
+ EFCaptionsActiveWordHierarchyItem = __decorateClass([
363
+ customElement("ef-captions-active-word-hierarchy-item")
364
+ ], EFCaptionsActiveWordHierarchyItem);
365
+ let EFWaveformHierarchyItem = class extends EFHierarchyItem {
366
+ get icon() {
367
+ return "🌊";
368
+ }
369
+ renderChildren() {
370
+ return nothing;
371
+ }
372
+ };
373
+ EFWaveformHierarchyItem = __decorateClass([
374
+ customElement("ef-waveform-hierarchy-item")
375
+ ], EFWaveformHierarchyItem);
376
+ let EFImageHierarchyItem = class extends EFHierarchyItem {
377
+ get icon() {
378
+ return "🖼️";
379
+ }
380
+ displayLabel() {
381
+ return this.element.getAttribute("src") ?? "(no src)";
382
+ }
383
+ };
384
+ EFImageHierarchyItem = __decorateClass([
385
+ customElement("ef-image-hierarchy-item")
386
+ ], EFImageHierarchyItem);
387
+ let EFHTMLHierarchyItem = class extends EFHierarchyItem {
388
+ get icon() {
389
+ return html`<code>${`<${this.element.tagName.toLowerCase()}>`}</code>`;
390
+ }
391
+ };
392
+ EFHTMLHierarchyItem = __decorateClass([
393
+ customElement("ef-html-hierarchy-item")
394
+ ], EFHTMLHierarchyItem);
395
+ const renderHierarchyChildren = (children) => {
396
+ return children.map((child) => {
397
+ if (child instanceof EFTimegroup) {
398
+ return html`<ef-timegroup-hierarchy-item
399
+ .element=${child}
400
+ ></ef-timegroup-hierarchy-item>`;
401
+ } else if (child instanceof EFImage) {
402
+ return html`<ef-image-hierarchy-item
403
+ .element=${child}
404
+ ></ef-image-hierarchy-item>`;
405
+ } else if (child instanceof EFAudio) {
406
+ return html`<ef-audio-hierarchy-item
407
+ .element=${child}
408
+ ></ef-audio-hierarchy-item>`;
409
+ } else if (child instanceof EFVideo) {
410
+ return html`<ef-video-hierarchy-item
411
+ .element=${child}
412
+ ></ef-video-hierarchy-item>`;
413
+ } else if (child instanceof EFCaptions) {
414
+ return html`<ef-captions-hierarchy-item
415
+ .element=${child}
416
+ ></ef-captions-hierarchy-item>`;
417
+ } else if (child instanceof EFCaptionsActiveWord) {
418
+ return html`<ef-captions-active-word-hierarchy-item
419
+ .element=${child}
420
+ ></ef-captions-active-word-hierarchy-item>`;
421
+ } else if (child instanceof EFWaveform) {
422
+ return html`<ef-waveform-hierarchy-item
423
+ .element=${child}
424
+ ></ef-waveform-hierarchy-item>`;
425
+ } else {
426
+ return html`<ef-html-hierarchy-item
427
+ .element=${child}
428
+ ></ef-html-hierarchy-item>`;
429
+ }
430
+ });
431
+ };
432
+ const renderFilmStripChildren = (children, pixelsPerMs) => {
433
+ return children.map((child) => {
434
+ if (child instanceof EFTimegroup) {
435
+ return html`<ef-timegroup-filmstrip
436
+ .element=${child}
437
+ .pixelsPerMs=${pixelsPerMs}
438
+ >
439
+ </ef-timegroup-filmstrip>`;
440
+ } else if (child instanceof EFImage) {
441
+ return html`<ef-image-filmstrip
442
+ .element=${child}
443
+ .pixelsPerMs=${pixelsPerMs}
444
+ ></ef-image-filmstrip>`;
445
+ } else if (child instanceof EFAudio) {
446
+ return html`<ef-audio-filmstrip
447
+ .element=${child}
448
+ .pixelsPerMs=${pixelsPerMs}
449
+ ></ef-audio-filmstrip>`;
450
+ } else if (child instanceof EFVideo) {
451
+ return html`<ef-video-filmstrip
452
+ .element=${child}
453
+ .pixelsPerMs=${pixelsPerMs}
454
+ ></ef-video-filmstrip>`;
455
+ } else if (child instanceof EFCaptions) {
456
+ return html`<ef-captions-filmstrip
457
+ .element=${child}
458
+ .pixelsPerMs=${pixelsPerMs}
459
+ ></ef-captions-filmstrip>`;
460
+ } else if (child instanceof EFWaveform) {
461
+ return html`<ef-waveform-filmstrip
462
+ .element=${child}
463
+ .pixelsPerMs=${pixelsPerMs}
464
+ ></ef-waveform-filmstrip>`;
465
+ } else {
466
+ return html`<ef-html-filmstrip
467
+ .element=${child}
468
+ .pixelsPerMs=${pixelsPerMs}
469
+ ></ef-html-filmstrip>`;
470
+ }
471
+ });
472
+ };
473
+ let EFFilmStrip = class extends TWMixin(LitElement) {
474
+ constructor() {
475
+ super(...arguments);
476
+ this.pixelsPerMs = 0.04;
477
+ this.currentTimeMs = 0;
478
+ this.targetSelector = "";
479
+ this.scrubbing = false;
480
+ this.playing = false;
481
+ __privateAdd(this, _lastTick, void 0);
482
+ this.advancePlayhead = (tick) => {
483
+ if (__privateGet(this, _lastTick) && tick && this.target) {
484
+ this.target.currentTimeMs += tick - __privateGet(this, _lastTick);
485
+ if (this.target.currentTimeMs >= this.target.durationMs) {
486
+ this.playing = false;
487
+ }
488
+ }
489
+ __privateSet(this, _lastTick, tick);
490
+ if (this.playing) {
491
+ requestAnimationFrame(this.advancePlayhead);
492
+ }
493
+ };
494
+ this.gutterRef = createRef();
495
+ }
496
+ connectedCallback() {
497
+ super.connectedCallback();
498
+ const target = this.target;
499
+ if (target) {
500
+ this.timegroupController = new TimegroupController(target, this);
501
+ this.currentTimeMs = target.currentTimeMs;
502
+ }
503
+ }
504
+ scrub(e) {
505
+ if (this.playing) {
506
+ return;
507
+ }
508
+ if (!this.scrubbing) {
509
+ return;
510
+ }
511
+ const gutter = this.shadowRoot?.querySelector("#gutter");
512
+ if (!gutter) {
513
+ return;
514
+ }
515
+ const rect = gutter.getBoundingClientRect();
516
+ if (this.target) {
517
+ const layerX = e.pageX - rect.left + gutter.scrollLeft;
518
+ this.target.currentTimeMs = layerX / this.pixelsPerMs;
519
+ }
520
+ }
521
+ startScrub(e) {
522
+ e.preventDefault();
523
+ this.scrubbing = true;
524
+ queueMicrotask(() => {
525
+ const gutter = this.shadowRoot?.querySelector("#gutter");
526
+ if (!gutter) {
527
+ return;
528
+ }
529
+ const rect = gutter.getBoundingClientRect();
530
+ if (this.target) {
531
+ const layerX = e.pageX - rect.left + gutter.scrollLeft;
532
+ this.target.currentTimeMs = layerX / this.pixelsPerMs;
533
+ }
534
+ });
535
+ addEventListener(
536
+ "mouseup",
537
+ () => {
538
+ this.scrubbing = false;
539
+ },
540
+ { once: true }
541
+ );
542
+ }
543
+ scrollScrub(e) {
544
+ if (this.target && this.gutter && !this.playing) {
545
+ e.preventDefault();
546
+ if (this.gutterRef.value.scrollLeft === 0 && e.deltaX < 0) {
547
+ this.gutter.scrollBy(0, e.deltaY);
548
+ return;
549
+ }
550
+ if (this.gutter.scrollWidth - this.gutter.scrollLeft === this.gutter.clientWidth && e.deltaX > 0) {
551
+ this.gutter.scrollBy(0, e.deltaY);
552
+ return;
553
+ }
554
+ if (this) {
555
+ this.gutter.scrollBy(e.deltaX, e.deltaY);
556
+ this.target.currentTimeMs += e.deltaX / this.pixelsPerMs;
557
+ }
558
+ }
559
+ }
560
+ get gutter() {
561
+ return this.gutterRef.value;
562
+ }
563
+ render() {
564
+ const target = this.target;
565
+ return html` <div
566
+ class="grid h-full bg-slate-100 "
567
+ style="grid-template-columns: 200px 1fr; grid-template-rows: 1.5rem 1fr;"
568
+ >
569
+ <div
570
+ class="z-20 col-span-2 border-b-slate-600 bg-slate-100 shadow shadow-slate-300"
571
+ >
572
+ <input
573
+ type="range"
574
+ .value=${this.pixelsPerMs}
575
+ min="0.01"
576
+ max="0.1"
577
+ step="0.001"
578
+ @input=${(e) => {
579
+ const target2 = e.target;
580
+ this.pixelsPerMs = parseFloat(target2.value);
581
+ }}
582
+ />
583
+ <code>${msToTimeCode(this.currentTimeMs, true)} </code> /
584
+ <code>${msToTimeCode(target?.durationMs ?? 0, true)}</code>
585
+ ${this.playing ? html`<button @click=${() => this.playing = false}>⏸️</button>` : html`<button @click=${() => this.playing = true}>▶️</button>`}
586
+ </div>
587
+ <div class="z-10 pl-1 pr-1 pt-2 shadow shadow-slate-600">
588
+ ${renderHierarchyChildren(Array.from(target?.children ?? []))}
589
+ </div>
590
+ <div
591
+ class="h-full w-full cursor-crosshair overflow-auto bg-slate-200 pt-2"
592
+ id="gutter"
593
+ ${ref(this.gutterRef)}
594
+ @wheel=${this.scrollScrub}
595
+ >
596
+ <div
597
+ class="relative h-full w-full"
598
+ style="width: ${this.pixelsPerMs * (target?.durationMs ?? 0)}px;"
599
+ @mousemove=${this.scrub}
600
+ @mousedown=${this.startScrub}
601
+ >
602
+ <div
603
+ class="border-red pointer-events-none absolute top-0 z-10 h-full w-[2px] border-r-2 border-red-700"
604
+ style="left: ${this.pixelsPerMs * this.currentTimeMs}px;"
605
+ ></div>
606
+
607
+ ${renderFilmStripChildren(
608
+ Array.from(target?.children || []),
609
+ this.pixelsPerMs
610
+ )}
611
+ </div>
612
+ </div>
613
+ </div>`;
614
+ }
615
+ update(changedProperties) {
616
+ if (changedProperties.has("playing")) {
617
+ if (this.playing) {
618
+ this.advancePlayhead(0);
619
+ }
620
+ }
621
+ super.update(changedProperties);
622
+ }
623
+ updated(changes) {
624
+ if (!this.target) {
625
+ return;
626
+ }
627
+ if (changes.has("currentTimeMs")) {
628
+ if (this.target.currentTimeMs !== this.currentTimeMs) {
629
+ this.target.currentTimeMs = this.currentTimeMs;
630
+ }
631
+ }
632
+ }
633
+ get target() {
634
+ if (this.getAttribute("target")) {
635
+ const target = document.querySelector(this.getAttribute("target") ?? "");
636
+ if (target instanceof EFTimegroup) {
637
+ return target;
638
+ }
639
+ throw new Error("Invalid target, must be an EFTimegroup element");
640
+ }
641
+ }
642
+ };
643
+ _lastTick = /* @__PURE__ */ new WeakMap();
644
+ __decorateClass([
645
+ property({ type: Number })
646
+ ], EFFilmStrip.prototype, "pixelsPerMs", 2);
647
+ __decorateClass([
648
+ property({ type: Number })
649
+ ], EFFilmStrip.prototype, "currentTimeMs", 2);
650
+ __decorateClass([
651
+ property({ type: String, attribute: "target" })
652
+ ], EFFilmStrip.prototype, "targetSelector", 2);
653
+ __decorateClass([
654
+ state()
655
+ ], EFFilmStrip.prototype, "scrubbing", 2);
656
+ __decorateClass([
657
+ state()
658
+ ], EFFilmStrip.prototype, "playing", 2);
659
+ __decorateClass([
660
+ eventOptions({ capture: false })
661
+ ], EFFilmStrip.prototype, "scrub", 1);
662
+ __decorateClass([
663
+ eventOptions({ capture: false })
664
+ ], EFFilmStrip.prototype, "startScrub", 1);
665
+ __decorateClass([
666
+ eventOptions({ passive: false })
667
+ ], EFFilmStrip.prototype, "scrollScrub", 1);
668
+ EFFilmStrip = __decorateClass([
669
+ customElement("ef-filmstrip")
670
+ ], EFFilmStrip);
671
+ export {
672
+ EFAudioFilmstrip,
673
+ EFCaptionsFilmstrip,
674
+ EFFilmStrip,
675
+ EFHTMLFilmstrip,
676
+ EFImageFilmstrip,
677
+ EFTimegroupFilmstrip,
678
+ EFVideoFilmstrip,
679
+ EFWaveformFilmstrip
680
+ };