@video-editor/ui 0.0.1-beta.19 → 0.0.1-beta.22

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.
@@ -1,814 +0,0 @@
1
- import { defineComponent as re, createElementBlock as _, openBlock as T, withModifiers as oe, normalizeStyle as D, createStaticVNode as Ce, createElementVNode as c, Fragment as xe, renderList as _e, normalizeClass as ze, createCommentVNode as te, toDisplayString as R, renderSlot as X, withDirectives as Ve, vShow as Le, computed as b, ref as z, watch as pe, toRef as Fe, onMounted as Oe, onBeforeUnmount as He, createVNode as ke, unref as K, withCtx as Ye } from "vue";
2
- const We = /* @__PURE__ */ re({
3
- name: "TimelinePlayhead",
4
- __name: "TimelinePlayhead",
5
- props: {
6
- left: {}
7
- },
8
- emits: ["dragStart"],
9
- setup(i, { emit: g }) {
10
- const a = g;
11
- return (r, l) => (T(), _("div", {
12
- class: "ve-playhead",
13
- style: D({ left: `${i.left}px` }),
14
- onMousedown: l[0] || (l[0] = oe((k) => a("dragStart", k), ["stop", "prevent"]))
15
- }, [...l[1] || (l[1] = [
16
- Ce('<svg class="ve-playhead__icon" width="12" height="18" viewBox="0 0 12 18" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-8e647d40><g filter="url(#ve_playhead_drop_shadow)" data-v-8e647d40><path d="M2 3C2 1.89543 2.89543 1 4 1H8C9.10457 1 10 1.89543 10 3V11.0925C10 11.6692 9.75104 12.2178 9.31701 12.5976L7.31701 14.3476C6.56296 15.0074 5.43704 15.0074 4.68299 14.3476L2.68299 12.5976C2.24896 12.2178 2 11.6692 2 11.0925V3Z" fill="white" data-v-8e647d40></path><path d="M4 1.5H8C8.82843 1.5 9.5 2.17157 9.5 3V11.0928C9.49991 11.5252 9.31275 11.9369 8.9873 12.2217L6.9873 13.9717C6.42191 14.466 5.57809 14.466 5.0127 13.9717L3.0127 12.2217C2.68725 11.9369 2.50009 11.5252 2.5 11.0928V3C2.5 2.17157 3.17157 1.5 4 1.5Z" stroke="currentColor" data-v-8e647d40></path></g><defs data-v-8e647d40><filter id="ve_playhead_drop_shadow" x="0" y="0" width="12" height="17.8428" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB" data-v-8e647d40><feFlood flood-opacity="0" result="BackgroundImageFix" data-v-8e647d40></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" data-v-8e647d40></feColorMatrix><feOffset dy="1" data-v-8e647d40></feOffset><feGaussianBlur stdDeviation="1" data-v-8e647d40></feGaussianBlur><feComposite in2="hardAlpha" operator="out" data-v-8e647d40></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0" data-v-8e647d40></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow" data-v-8e647d40></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape" data-v-8e647d40></feBlend></filter></defs></svg><div class="ve-playhead__line" data-v-8e647d40></div>', 2)
17
- ])], 36));
18
- }
19
- }), le = (i, g) => {
20
- const a = i.__vccOpts || i;
21
- for (const [r, l] of g)
22
- a[r] = l;
23
- return a;
24
- }, Ae = /* @__PURE__ */ le(We, [["__scopeId", "data-v-8e647d40"]]), je = { class: "ve-ruler" }, Ue = { class: "ve-ruler__ticks" }, Ke = {
25
- key: 0,
26
- class: "ve-ruler__label"
27
- }, qe = /* @__PURE__ */ re({
28
- name: "TimelineRuler",
29
- __name: "TimelineRuler",
30
- props: {
31
- ticks: {}
32
- },
33
- setup(i) {
34
- return (g, a) => (T(), _("div", je, [
35
- c("div", Ue, [
36
- (T(!0), _(xe, null, _e(i.ticks, (r) => (T(), _("div", {
37
- key: r.timeMs,
38
- class: ze(["ve-ruler__tick", { "ve-ruler__tick--major": r.isMajor }]),
39
- style: D({
40
- left: `${r.position}px`,
41
- transform: "translateX(-50%)"
42
- })
43
- }, [
44
- a[0] || (a[0] = c("div", { class: "ve-ruler__line" }, null, -1)),
45
- r.isMajor && r.label ? (T(), _("div", Ke, R(r.label), 1)) : te("", !0)
46
- ], 6))), 128))
47
- ])
48
- ]));
49
- }
50
- }), Je = /* @__PURE__ */ le(qe, [["__scopeId", "data-v-30f91636"]]), Qe = { class: "ve-toolbar" }, et = { class: "ve-toolbar__group" }, tt = ["disabled"], nt = { class: "ve-toolbar__group" }, at = { class: "ve-zoom" }, st = { class: "ve-toolbar__group" }, it = ["disabled"], ot = { class: "ve-toolbar__time" }, rt = /* @__PURE__ */ re({
51
- name: "TimelineToolbar",
52
- __name: "TimelineToolbar",
53
- props: {
54
- zoom: {},
55
- minZoom: { default: 0.25 },
56
- maxZoom: { default: 10 },
57
- currentTime: { default: 0 },
58
- duration: { default: 0 },
59
- formatTime: { type: Function, default: (i) => `${(i / 1e3).toFixed(2)}s` }
60
- },
61
- emits: ["zoomIn", "zoomOut"],
62
- setup(i, { emit: g }) {
63
- const a = g;
64
- return (r, l) => (T(), _("div", Qe, [
65
- c("div", et, [
66
- X(r.$slots, "left-actions", {}, () => [
67
- c("button", {
68
- class: "ve-btn",
69
- type: "button",
70
- disabled: i.zoom <= i.minZoom,
71
- onClick: l[0] || (l[0] = (k) => a("zoomOut"))
72
- }, " - ", 8, tt)
73
- ], !0)
74
- ]),
75
- c("div", nt, [
76
- X(r.$slots, "center", {}, () => [
77
- c("div", at, R((i.zoom * 100).toFixed(0)) + "% ", 1)
78
- ], !0)
79
- ]),
80
- c("div", st, [
81
- X(r.$slots, "right-actions", {}, () => [
82
- c("button", {
83
- class: "ve-btn",
84
- type: "button",
85
- disabled: i.zoom >= i.maxZoom,
86
- onClick: l[1] || (l[1] = (k) => a("zoomIn"))
87
- }, " + ", 8, it)
88
- ], !0)
89
- ]),
90
- c("div", ot, [
91
- X(r.$slots, "time", {
92
- currentTime: i.currentTime,
93
- duration: i.duration
94
- }, () => [
95
- c("span", null, R(i.formatTime?.(i.currentTime || 0)), 1),
96
- l[2] || (l[2] = c("span", { class: "ve-toolbar__time-divider" }, "/", -1)),
97
- c("span", null, R(i.formatTime?.(i.duration || 0)), 1)
98
- ], !0)
99
- ])
100
- ]));
101
- }
102
- }), lt = /* @__PURE__ */ le(rt, [["__scopeId", "data-v-85ddeb0f"]]), dt = { class: "ve-track__body" }, ut = ["onMousedown", "onClick"], ct = { class: "ve-segment__content" }, mt = { class: "ve-segment__title" }, vt = { class: "ve-segment__time" }, ft = {
103
- key: 0,
104
- class: "ve-segment__selection"
105
- }, gt = ["onMousedown"], ht = ["onMousedown"], pt = /* @__PURE__ */ re({
106
- name: "TimelineTracks",
107
- __name: "TimelineTracks",
108
- props: {
109
- tracks: {},
110
- trackHeight: {},
111
- trackGap: {},
112
- selectedSegmentId: {},
113
- dragPreview: {},
114
- resizePreview: {}
115
- },
116
- emits: ["segment-click", "segment-mousedown", "resize-start"],
117
- setup(i, { emit: g }) {
118
- const a = g;
119
- function r(x, d) {
120
- a("segment-click", x, d);
121
- }
122
- function l(x, d) {
123
- a("segment-mousedown", x, d);
124
- }
125
- function k(x, d, v) {
126
- a("resize-start", x, d, v);
127
- }
128
- return (x, d) => (T(), _("div", {
129
- class: "ve-timeline__tracks",
130
- style: D({ gap: `${i.trackGap}px`, paddingTop: `${i.trackGap}px` })
131
- }, [
132
- (T(!0), _(xe, null, _e(i.tracks, (v) => (T(), _("div", {
133
- key: v.track.id,
134
- class: ze(["ve-track", {
135
- "ve-track--main": v.track.isMain,
136
- "ve-track--has-selection": v.segments.some((s) => s.isSelected)
137
- }]),
138
- style: D({ height: `${i.trackHeight}px` })
139
- }, [
140
- X(x.$slots, "track", {
141
- track: v.track,
142
- index: v.trackIndex,
143
- segments: v.segments,
144
- height: i.trackHeight
145
- }, () => [
146
- c("div", dt, [
147
- (T(!0), _(xe, null, _e(v.segments, (s) => Ve((T(), _("div", {
148
- key: s.segment.id,
149
- class: ze(["ve-segment", {
150
- "ve-segment--selected": s.isSelected
151
- }]),
152
- style: D({
153
- left: `${s.left}px`,
154
- width: `${s.width}px`,
155
- backgroundColor: s.segment.color || v.track.color || "#222226"
156
- }),
157
- onMousedown: oe((u) => l(s, u), ["prevent", "stop"]),
158
- onClick: oe((u) => r(s, u), ["stop"])
159
- }, [
160
- X(x.$slots, "segment", {
161
- layout: s,
162
- segment: s.segment,
163
- track: s.track,
164
- isSelected: s.isSelected
165
- }, () => [
166
- c("div", ct, [
167
- c("div", mt, R(s.segment.type || "segment"), 1),
168
- c("div", vt, R((s.segment.start / 1e3).toFixed(2)) + "s - " + R((s.segment.end / 1e3).toFixed(2)) + "s ", 1)
169
- ])
170
- ], !0),
171
- s.isSelected ? (T(), _("div", ft, [
172
- c("div", {
173
- class: "ve-segment__handle ve-segment__handle--left",
174
- onMousedown: oe((u) => k(s, "start", u), ["stop"])
175
- }, [...d[0] || (d[0] = [
176
- Ce('<div class="ve-segment__handle-dots" data-v-52f6113c><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div></div>', 1)
177
- ])], 40, gt),
178
- c("div", {
179
- class: "ve-segment__handle ve-segment__handle--right",
180
- onMousedown: oe((u) => k(s, "end", u), ["stop"])
181
- }, [...d[1] || (d[1] = [
182
- Ce('<div class="ve-segment__handle-dots" data-v-52f6113c><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div><div class="ve-segment__handle-dot" data-v-52f6113c></div></div>', 1)
183
- ])], 40, ht)
184
- ])) : te("", !0)
185
- ], 46, ut)), [
186
- [Le, i.dragPreview?.segment.id !== s.segment.id && i.resizePreview?.segment.id !== s.segment.id]
187
- ])), 128))
188
- ])
189
- ], !0)
190
- ], 6))), 128))
191
- ], 4));
192
- }
193
- }), kt = /* @__PURE__ */ le(pt, [["__scopeId", "data-v-52f6113c"]]);
194
- function xt(i, g, a, r) {
195
- function l(x) {
196
- if (!i.value || !g.value.length)
197
- return null;
198
- const d = i.value.getBoundingClientRect(), v = x - d.top, s = a.value + r.value, u = r.value;
199
- if (v < u / 2)
200
- return { isGap: !0, insertIndex: 0 };
201
- for (let p = 0; p < g.value.length; p++) {
202
- const f = (p + 1) * s - u / 2, ne = (p + 1) * s + u / 2;
203
- if (v >= f && v < ne)
204
- return { isGap: !0, insertIndex: p + 1 };
205
- }
206
- return null;
207
- }
208
- function k(x) {
209
- if (!i.value || !g.value.length)
210
- return -1;
211
- const d = i.value.getBoundingClientRect(), v = x - d.top, s = a.value + r.value;
212
- return v < 0 ? -1 : Math.min(
213
- g.value.length - 1,
214
- Math.max(0, Math.floor(v / s))
215
- );
216
- }
217
- return {
218
- detectTrackGap: l,
219
- resolveTrackIndexFromClientY: k
220
- };
221
- }
222
- function _t(i, g, a) {
223
- return {
224
- snapGuides: b(() => {
225
- if (!i.value)
226
- return [];
227
- const l = /* @__PURE__ */ new Set(), k = i.value.startTime, x = i.value.endTime, d = 100;
228
- return ("value" in g ? g.value : g).forEach((s) => {
229
- s.segments.forEach((u) => {
230
- u.id !== i.value?.segment.id && (Math.abs(u.start - k) < d && l.add(u.start), Math.abs(u.end - k) < d && l.add(u.end), Math.abs(u.start - x) < d && l.add(u.start), Math.abs(u.end - x) < d && l.add(u.end));
231
- });
232
- }), Array.from(l).map((s) => ({
233
- time: s,
234
- left: s * a.value
235
- }));
236
- })
237
- };
238
- }
239
- function Tt(i) {
240
- const {
241
- tracks: g,
242
- tracksRef: a,
243
- trackHeightPx: r,
244
- trackGapPx: l,
245
- pixelsPerMs: k,
246
- disableInteraction: x,
247
- snap: d,
248
- onDragStart: v,
249
- onDrag: s,
250
- onDragEnd: u
251
- } = i, p = z(null), f = z(null), { detectTrackGap: ne, resolveTrackIndexFromClientY: Te } = xt(
252
- a,
253
- g,
254
- r,
255
- l
256
- ), { snapGuides: de } = _t(
257
- f,
258
- g,
259
- k
260
- );
261
- function ue(h, q) {
262
- x.value || (p.value = {
263
- layout: h,
264
- initialX: q.clientX,
265
- initialY: q.clientY,
266
- moved: !1
267
- });
268
- }
269
- function ce(h, q, G, C) {
270
- const { layout: m, initialX: Me, initialY: we } = h, me = q - Me, H = G - we, Y = Math.abs(me) > 5 || Math.abs(H) > 5;
271
- if (!h.moved && Y) {
272
- h.moved = !0;
273
- const Z = {
274
- segment: m.segment,
275
- track: m.track,
276
- trackIndex: m.trackIndex,
277
- segmentIndex: m.segmentIndex,
278
- startTime: m.segment.start,
279
- endTime: m.segment.end,
280
- targetTrackIndex: m.trackIndex,
281
- targetTrackId: m.track.id,
282
- isNewTrack: !1,
283
- visualTrackIndex: m.trackIndex,
284
- isValidTarget: !0,
285
- mouseDeltaY: 0
286
- };
287
- v(Z);
288
- }
289
- const W = m.segment.end - m.segment.start, A = m.segment.type || m.track.type, J = Te(G), $ = J >= 0 ? J : m.trackIndex, O = g.value[$];
290
- let M, Q, j, B = !1, ae, F = !0;
291
- if (O && O.type === A) {
292
- const Z = ne(G);
293
- Z ? (B = !0, ae = Z.insertIndex, M = Z.insertIndex, Q = Z.insertIndex, j = m.track.id, F = !0) : (M = $, Q = $, j = O.id, F = !0);
294
- } else if (!a.value)
295
- M = m.trackIndex, Q = $, j = m.track.id, F = !1;
296
- else {
297
- const Z = a.value.getBoundingClientRect(), $e = G - Z.top, ve = r.value + l.value, fe = $ * ve + r.value / 2, ge = $e < fe;
298
- B = !0, ae = ge ? $ : $ + 1, M = ae, Q = $, j = m.track.id, F = !0;
299
- }
300
- const Ie = d(m.segment.start + me / Math.max(k.value, 1e-4)), U = Math.max(0, Ie), Se = U + W, ie = {
301
- segment: m.segment,
302
- track: m.track,
303
- trackIndex: m.trackIndex,
304
- segmentIndex: m.segmentIndex,
305
- startTime: U,
306
- endTime: Se,
307
- targetTrackIndex: M,
308
- targetTrackId: j,
309
- isNewTrack: B,
310
- newTrackInsertIndex: ae,
311
- visualTrackIndex: Q,
312
- isValidTarget: F,
313
- mouseDeltaY: H
314
- };
315
- h.moved && (f.value = ie, C === "drag" ? s(ie) : C === "end" && u(ie));
316
- }
317
- function E(h) {
318
- p.value && ce(p.value, h.clientX, h.clientY, "drag");
319
- }
320
- function S(h) {
321
- p.value && (ce(p.value, h.clientX, h.clientY, "end"), p.value = null, f.value = null);
322
- }
323
- return {
324
- // State
325
- draggingState: p,
326
- dragPreview: f,
327
- snapGuides: de,
328
- // Methods
329
- startDrag: ue,
330
- handleDragMove: E,
331
- handleDragEnd: S
332
- };
333
- }
334
- const Mt = { class: "ve-timeline" }, wt = { class: "ve-segment__content" }, bt = { class: "ve-segment__title" }, It = { class: "ve-segment__time" }, St = { class: "ve-segment__content" }, $t = { class: "ve-segment__title" }, yt = { class: "ve-segment__time" }, Ct = 120, Ze = 10, zt = /* @__PURE__ */ re({
335
- name: "VideoTimeline",
336
- __name: "index",
337
- props: {
338
- tracks: {},
339
- currentTime: {},
340
- duration: {},
341
- zoom: {},
342
- minZoom: { default: 0.25 },
343
- maxZoom: { default: 10 },
344
- snapStep: { default: 0 },
345
- trackHeight: { default: 56 },
346
- trackGap: { default: 8 },
347
- rulerHeight: { default: 28 },
348
- minSegmentDuration: { default: 60 },
349
- selectedSegmentId: { default: null },
350
- disableInteraction: { type: Boolean, default: !1 },
351
- fps: { default: 30 }
352
- },
353
- emits: ["update:currentTime", "update:zoom", "segmentClick", "segmentDragStart", "segmentDrag", "segmentDragEnd", "segmentResizeStart", "segmentResize", "segmentResizeEnd", "backgroundClick"],
354
- setup(i, { emit: g }) {
355
- const a = i, r = g, l = z(null), k = z(null), x = z(null), d = z(0);
356
- let v = null;
357
- const s = z(B(a.zoom ?? a.minZoom)), u = z(!1);
358
- pe(() => a.zoom, (e) => {
359
- typeof e == "number" && (s.value = B(e));
360
- }), pe(s, (e) => r("update:zoom", e));
361
- const p = b(() => typeof a.duration == "number" ? Math.max(a.duration, 0) : Math.max(
362
- 0,
363
- ...a.tracks.flatMap(
364
- (n) => n.segments.map((t) => t.end)
365
- )
366
- ));
367
- pe(p, (e, n) => {
368
- if (!n || !e || n <= 0 || e <= 0 || !u.value || !d.value)
369
- return;
370
- const t = d.value * s.value / n;
371
- if (!Number.isFinite(t) || t <= 0)
372
- return;
373
- const o = B(t * e / d.value);
374
- Math.abs(o - s.value) > 1e-6 && (s.value = o);
375
- });
376
- const f = b(() => {
377
- const e = Math.max(p.value, 1);
378
- return Math.max(d.value, 1) * s.value / e;
379
- }), ne = b(() => {
380
- const e = p.value * f.value, n = Number.isFinite(e) ? Math.max(e, 0) : 0;
381
- return Math.max(Math.ceil(n), Math.ceil(d.value || 0));
382
- }), Te = b(() => {
383
- const e = Math.max(f.value, 1e-4), t = (ne.value || d.value || 0) / e;
384
- return Math.max(p.value, t);
385
- }), de = b(() => a.currentTime * f.value), ue = b(() => Ie(Te.value, f.value)), ce = b(() => 1e3 / Math.max(a.fps || 30, 1)), E = b(() => a.trackHeight), S = b(() => a.trackGap), h = b(() => a.rulerHeight), q = b(() => a.tracks.map((e, n) => ({
386
- track: e,
387
- trackIndex: n,
388
- segments: e.segments.map((t, o) => {
389
- const w = Math.max((t.end - t.start) * f.value, 6), I = t.start * f.value;
390
- return {
391
- track: e,
392
- trackIndex: n,
393
- segment: t,
394
- segmentIndex: o,
395
- left: I,
396
- width: w,
397
- isSelected: a.selectedSegmentId === t.id
398
- };
399
- })
400
- }))), {
401
- draggingState: G,
402
- dragPreview: C,
403
- snapGuides: m,
404
- startDrag: Me,
405
- handleDragMove: we,
406
- handleDragEnd: me
407
- } = Tt({
408
- tracks: Fe(a, "tracks"),
409
- tracksRef: x,
410
- trackHeightPx: E,
411
- trackGapPx: S,
412
- pixelsPerMs: f,
413
- disableInteraction: Fe(a, "disableInteraction"),
414
- snap: U,
415
- onDragStart: (e) => {
416
- r("segmentDragStart", e);
417
- },
418
- onDrag: (e) => {
419
- r("segmentDrag", e);
420
- },
421
- onDragEnd: (e) => {
422
- r("segmentDragEnd", e);
423
- }
424
- }), H = z(null), Y = b(() => C.value), W = b(() => H.value), A = z(null), J = z(!1), $ = z(!1), O = z(!1), M = b(() => {
425
- if (!C.value)
426
- return null;
427
- const e = C.value, t = q.value.find((y) => y.track.id === e.track.id)?.segments.find((y) => y.segment.id === e.segment.id);
428
- if (!t)
429
- return null;
430
- const o = (e.startTime - e.segment.start) * f.value, I = h.value + e.trackIndex * (E.value + S.value) + S.value + e.mouseDeltaY;
431
- return {
432
- ...t,
433
- left: t.left + o,
434
- top: I
435
- };
436
- }), Q = b(() => {
437
- if (!C.value)
438
- return 0;
439
- const e = C.value;
440
- return e.isNewTrack && e.newTrackInsertIndex === 0 ? h.value + S.value : h.value + e.targetTrackIndex * (E.value + S.value) + S.value;
441
- });
442
- Oe(() => {
443
- l.value && (v = new ResizeObserver((e) => {
444
- const n = e[0];
445
- d.value = n?.contentRect.width || l.value?.clientWidth || 0;
446
- }), v.observe(l.value), d.value = l.value.clientWidth || 0), window.addEventListener("mousemove", fe), window.addEventListener("mouseup", ge), ae();
447
- }), He(() => {
448
- v?.disconnect(), v = null, window.removeEventListener("mousemove", fe), window.removeEventListener("mouseup", ge);
449
- }), pe(s, () => {
450
- j();
451
- });
452
- function j() {
453
- const e = l.value;
454
- if (!e)
455
- return;
456
- const n = e.clientWidth / 2, t = a.currentTime * f.value - n;
457
- e.scrollLeft = Math.max(0, t);
458
- }
459
- function B(e) {
460
- return Number.isFinite(e) ? Math.min(Math.max(e, a.minZoom), a.maxZoom) : a.minZoom;
461
- }
462
- function ae() {
463
- if (u.value)
464
- return;
465
- if (a.zoom !== void 0) {
466
- u.value = !0;
467
- return;
468
- }
469
- if (!d.value || p.value <= 0)
470
- return;
471
- const e = B(1 / 3);
472
- s.value = e, u.value = !0;
473
- }
474
- function F(e) {
475
- const n = Math.max(e, 0), t = Math.floor(n / 1e3), o = Math.floor(t / 60).toString().padStart(2, "0"), w = (t % 60).toString().padStart(2, "0"), I = Math.floor(n % 1e3 / 10).toString().padStart(2, "0");
476
- return `${o}:${w}.${I}`;
477
- }
478
- function be(e) {
479
- const n = Math.max(e, 0), t = Math.floor(n / 1e3), o = Math.floor(t / 60).toString().padStart(2, "0"), w = (t % 60).toString().padStart(2, "0");
480
- return `${o}:${w}`;
481
- }
482
- function Ie(e, n) {
483
- if (!e || !n)
484
- return [];
485
- const t = Pe(n, a.fps || 30), o = Math.max(1, Math.round(t.mainMs / t.minorMs)), w = Math.max(e, 1), I = Math.ceil(w / t.minorMs), y = [];
486
- for (let P = 0; P <= I; P += 1) {
487
- const N = Math.min(w, P * t.minorMs), V = N * n, L = P % o === 0;
488
- y.push({
489
- position: V,
490
- timeMs: N,
491
- isMajor: L,
492
- label: L ? Be(N, a.fps || 30, t) : void 0
493
- });
494
- }
495
- return y;
496
- }
497
- function U(e) {
498
- const n = a.snapStep, t = n && n > 0 ? n : ce.value;
499
- return Math.max(Math.round(e / t) * t, 0);
500
- }
501
- function Se(e) {
502
- if (!k.value)
503
- return;
504
- if (O.value) {
505
- O.value = !1;
506
- return;
507
- }
508
- const n = k.value.getBoundingClientRect(), t = e.clientX - n.left, o = U(t / Math.max(f.value, 1e-4));
509
- r("update:currentTime", o), r("backgroundClick", e), $.value = !0;
510
- }
511
- function ie(e) {
512
- a.disableInteraction || (e.preventDefault(), J.value = !0, $.value = !0, Z(e.clientX), j());
513
- }
514
- function Z(e) {
515
- if (!k.value)
516
- return;
517
- const n = k.value.getBoundingClientRect(), t = e - n.left, o = U(t / Math.max(f.value, 1e-4));
518
- r("update:currentTime", o);
519
- }
520
- function $e(e, n, t) {
521
- if (a.disableInteraction)
522
- return;
523
- t.stopPropagation(), t.preventDefault(), A.value = {
524
- layout: e,
525
- edge: n,
526
- initialX: t.clientX
527
- };
528
- const o = {
529
- segment: e.segment,
530
- track: e.track,
531
- trackIndex: e.trackIndex,
532
- segmentIndex: e.segmentIndex,
533
- startTime: e.segment.start,
534
- endTime: e.segment.end,
535
- edge: n
536
- };
537
- H.value = o, r("segmentResizeStart", o);
538
- }
539
- function ve(e, n, t) {
540
- const { layout: o, edge: w, initialX: I } = e, P = (n - I) / Math.max(f.value, 1e-4), N = Math.max(a.minSegmentDuration, 10);
541
- let V = o.segment.start, L = o.segment.end;
542
- if (w === "start")
543
- V = U(Math.max(0, o.segment.start + P)), o.segment.end - V < N && (V = o.segment.end - N);
544
- else {
545
- L = U(Math.max(o.segment.start + N, o.segment.end + P));
546
- const { sourceDurationMs: ee, fromTime: he } = o.segment;
547
- if (typeof ee == "number" && Number.isFinite(ee) && ee > 0 && typeof he == "number" && Number.isFinite(he) && he >= 0) {
548
- const Ne = Math.max(0, ee - he), Ee = V + Ne;
549
- L > Ee && (L = Ee);
550
- }
551
- }
552
- const se = {
553
- segment: o.segment,
554
- track: o.track,
555
- trackIndex: o.trackIndex,
556
- segmentIndex: o.segmentIndex,
557
- startTime: V,
558
- endTime: L,
559
- edge: w
560
- };
561
- H.value = se, t === "drag" ? r("segmentResize", se) : t === "end" && r("segmentResizeEnd", se);
562
- }
563
- function ye(e, n) {
564
- G.value?.layout.segment.id === e.segment.id && G.value.moved || r("segmentClick", e, n);
565
- }
566
- function fe(e) {
567
- if (J.value) {
568
- Z(e.clientX);
569
- return;
570
- }
571
- if (A.value) {
572
- ve(A.value, e.clientX, "drag");
573
- return;
574
- }
575
- we(e);
576
- }
577
- function ge(e) {
578
- if (J.value) {
579
- J.value = !1, $.value = !1, Z(e.clientX), O.value = !0;
580
- return;
581
- }
582
- if (A.value) {
583
- ve(A.value, e.clientX, "end"), A.value = null, H.value = null, $.value = !1, O.value = !0;
584
- return;
585
- }
586
- if (G.value)
587
- if (G.value.moved)
588
- O.value = !0;
589
- else {
590
- const { layout: n } = G.value;
591
- ye(n, e);
592
- }
593
- me(e), $.value = !1;
594
- }
595
- function De() {
596
- s.value = B(s.value * 1.25);
597
- }
598
- function Re() {
599
- s.value = B(s.value / 1.25);
600
- }
601
- function Pe(e, n) {
602
- const o = 1e3 / (Number.isFinite(n) && n > 0 ? n : 30), w = e * o, I = Xe(o), y = Ge(o), P = w >= Ze ? [...y, ...I] : I;
603
- let N = null, V = 1 / 0;
604
- for (const L of P) {
605
- const se = L.mainMs * e;
606
- if (se < Ze)
607
- continue;
608
- const ee = Math.abs(se - Ct);
609
- ee < V && (N = L, V = ee);
610
- }
611
- return N || P[P.length - 1] || y[y.length - 1];
612
- }
613
- function Xe(e) {
614
- return [600, 300, 180, 120, 60, 30, 20, 15, 10, 5, 3, 2, 1].map((t) => {
615
- const o = t * 1e3;
616
- return {
617
- mainMs: o,
618
- minorMs: Math.max(o / 10, e),
619
- mode: "time",
620
- label: "time"
621
- };
622
- });
623
- }
624
- function Ge(e) {
625
- return [
626
- {
627
- mainMs: Math.max(e * 2, 1),
628
- minorMs: Math.max(e, 1),
629
- mode: "frame",
630
- label: "frame"
631
- },
632
- {
633
- mainMs: Math.max(e * 10, 1),
634
- minorMs: Math.max(e * 2, 1),
635
- mode: "frame",
636
- label: "frame"
637
- },
638
- {
639
- mainMs: 1e3,
640
- minorMs: Math.max(e * 10, 1),
641
- mode: "frame",
642
- label: "frame"
643
- }
644
- ];
645
- }
646
- function Be(e, n, t) {
647
- if (t.label === "frame") {
648
- const o = Number.isFinite(n) && n > 0 ? n : 30, w = 1e3 / o, y = Math.round(e / w) % o;
649
- return y === 0 ? be(e) : `${y}f`;
650
- }
651
- return be(e);
652
- }
653
- return (e, n) => (T(), _("div", Mt, [
654
- X(e.$slots, "toolbar", {
655
- zoom: s.value,
656
- canZoomIn: s.value < i.maxZoom,
657
- canZoomOut: s.value > i.minZoom,
658
- zoomIn: De,
659
- zoomOut: Re,
660
- currentTime: i.currentTime,
661
- duration: p.value,
662
- formatTime: F
663
- }, () => [
664
- ke(lt, {
665
- zoom: s.value,
666
- "min-zoom": i.minZoom,
667
- "max-zoom": i.maxZoom,
668
- "current-time": i.currentTime,
669
- duration: p.value,
670
- "format-time": F,
671
- onZoomIn: De,
672
- onZoomOut: Re
673
- }, null, 8, ["zoom", "min-zoom", "max-zoom", "current-time", "duration"])
674
- ], !0),
675
- c("div", {
676
- ref_key: "viewportRef",
677
- ref: l,
678
- class: "ve-timeline__viewport",
679
- onClick: Se
680
- }, [
681
- c("div", {
682
- ref_key: "contentRef",
683
- ref: k,
684
- class: "ve-timeline__content",
685
- style: D({ width: `${ne.value}px` })
686
- }, [
687
- X(e.$slots, "ruler", {
688
- ticks: ue.value,
689
- pixelsPerMs: f.value
690
- }, () => [
691
- ke(Je, {
692
- ticks: ue.value,
693
- style: D({ height: `${h.value}px` })
694
- }, null, 8, ["ticks", "style"])
695
- ], !0),
696
- X(e.$slots, "playhead", {
697
- left: de.value,
698
- currentTime: i.currentTime
699
- }, () => [
700
- ke(Ae, {
701
- class: "top-0",
702
- left: de.value,
703
- onDragStart: ie
704
- }, null, 8, ["left"])
705
- ], !0),
706
- c("div", {
707
- ref_key: "tracksRef",
708
- ref: x
709
- }, [
710
- ke(kt, {
711
- tracks: q.value,
712
- "track-height": E.value,
713
- "track-gap": S.value,
714
- "selected-segment-id": a.selectedSegmentId,
715
- "drag-preview": K(C),
716
- "resize-preview": H.value,
717
- onSegmentClick: ye,
718
- onSegmentMousedown: K(Me),
719
- onResizeStart: $e
720
- }, {
721
- segment: Ye(({ layout: t, segment: o, track: w, isSelected: I }) => [
722
- X(e.$slots, "segment", {
723
- layout: t,
724
- segment: o,
725
- track: w,
726
- isSelected: I
727
- }, () => [
728
- c("div", wt, [
729
- c("div", bt, R(o.type || "segment"), 1),
730
- c("div", It, R(F(o.start)) + " - " + R(F(o.end)), 1)
731
- ])
732
- ], !0)
733
- ]),
734
- _: 3
735
- }, 8, ["tracks", "track-height", "track-gap", "selected-segment-id", "drag-preview", "resize-preview", "onSegmentMousedown"])
736
- ], 512),
737
- M.value ? (T(), _("div", {
738
- key: 0,
739
- class: "ve-segment ve-segment--dragging",
740
- style: D({
741
- left: `${M.value.left}px`,
742
- width: `${M.value.width}px`,
743
- top: `${M.value.top}px`,
744
- height: `${E.value}px`,
745
- backgroundColor: M.value.segment.color || "var(--ve-primary)"
746
- })
747
- }, [
748
- X(e.$slots, "segment", {
749
- layout: M.value,
750
- segment: M.value.segment,
751
- track: M.value.track,
752
- isSelected: M.value.isSelected
753
- }, () => [
754
- c("div", St, [
755
- c("div", $t, R(M.value.segment.type || "segment"), 1),
756
- c("div", yt, R(F(M.value.segment.start)) + " - " + R(F(M.value.segment.end)), 1)
757
- ])
758
- ], !0)
759
- ], 4)) : te("", !0),
760
- Y.value && !Y.value.isNewTrack ? (T(), _("div", {
761
- key: 1,
762
- class: "ve-segment ve-segment--placeholder",
763
- style: D({
764
- left: `${Y.value.startTime * f.value}px`,
765
- width: `${(Y.value.endTime - Y.value.startTime) * f.value}px`,
766
- top: `${Q.value}px`,
767
- height: `${E.value}px`
768
- })
769
- }, [
770
- c("div", {
771
- class: "ve-segment--placeholder-inner",
772
- style: D({
773
- backgroundColor: Y.value.segment.color || "var(--ve-primary)"
774
- })
775
- }, null, 4)
776
- ], 4)) : te("", !0),
777
- W.value ? (T(), _("div", {
778
- key: 2,
779
- class: "ve-segment ve-segment--preview",
780
- style: D({
781
- left: `${W.value.startTime * f.value}px`,
782
- width: `${(W.value.endTime - W.value.startTime) * f.value}px`,
783
- top: `${h.value + W.value.trackIndex * (E.value + S.value) + S.value}px`,
784
- height: `${E.value}px`,
785
- backgroundColor: W.value.segment.color || "var(--ve-primary)"
786
- })
787
- }, null, 4)) : te("", !0),
788
- K(C) && K(m).length ? (T(!0), _(xe, { key: 3 }, _e(K(m), (t) => (T(), _("div", {
789
- key: `snap-${t.time}`,
790
- class: "ve-snap-guide",
791
- style: D({
792
- left: `${t.left}px`,
793
- top: `${h.value}px`,
794
- height: `calc(100% - ${h.value}px)`
795
- })
796
- }, null, 4))), 128)) : te("", !0),
797
- K(C) && K(C).isNewTrack ? (T(), _("div", {
798
- key: 4,
799
- class: "ve-new-track-line",
800
- style: D({
801
- top: `${h.value + K(C).targetTrackIndex * (E.value + S.value)}px`,
802
- left: "0",
803
- right: "0"
804
- })
805
- }, null, 4)) : te("", !0)
806
- ], 4)
807
- ], 512)
808
- ]));
809
- }
810
- }), Rt = /* @__PURE__ */ le(zt, [["__scopeId", "data-v-808b21f7"]]);
811
- export {
812
- Rt as V,
813
- le as _
814
- };